瀏覽代碼

更新日志警报查询SQL和websocket后端数据推送

oyq28 3 年之前
父節點
當前提交
3cbf4b4619

+ 13 - 15
imcs-admin-boot/imcs-authority-server/src/main/java/com/github/zuihou/job/DashboardJob.java

@@ -81,7 +81,7 @@ public class DashboardJob {
 
     private static Logger logger = LoggerFactory.getLogger(DashboardJob.class);
 
-    @Scheduled(cron="0 0/2 * * * ?")
+    @Scheduled(cron="0 0/1 * * * ?")
     public void updateDashboardJob(){
         //taskService.pushTask();
         BaseContextHandler.setTenant("0000");
@@ -147,13 +147,11 @@ public class DashboardJob {
             LbqWrapper<AAutoNodeLog> warnWrapper = warnWrap.lambda();
             //Date start = new Date();
             //警报弹框只执行一次
-            //Date end = DateUtil.stringToDate7(DateUtil.dateToString(new Date()) + " 23:59:59");
-            //warnWrapper.between(AAutoNodeLog::getCreateTime,start, end);
-            //warnWrapper.isNull(AAutoNodeLog::getExeResult).le(AAutoNodeLog::getEndTime,new Date());
-            //warnWrapper.and(condition -> condition.isNull(AAutoNodeLog::getExeResult).or().eq(AAutoNodeLog::getExeResult,"0")).orderByDesc(AAutoNodeLog::getCreateTime);
             //返回还未处理、执行状态为失败,并且还未推送的日志记录
-            warnWrapper.eq(AAutoNodeLog::getExeResult,"0").eq(AAutoNodeLog::getStatus,"0").eq(AAutoNodeLog::getSendStatus,"0");
-            IPage<AAutoNodeLog> warnData = autoNodeLogService.pageList(new Page<AAutoNodeLog>(), warnWrapper);
+            warnWrapper.eq(AAutoNodeLog::getExeResult,"0").eq(AAutoNodeLog::getStatus,"0")
+                    //.eq(AAutoNodeLog::getSendStatus,"0")
+                    .orderByDesc(AAutoNodeLog::getCreateTime);
+            IPage<AAutoNodeLog> warnData = autoNodeLogService.pageList(new Page<AAutoNodeLog>(1L, 5), warnWrapper);
 
             Map warnMap = Maps.newHashMap();
             warnMap.put("warnData", warnData);
@@ -170,14 +168,14 @@ public class DashboardJob {
             webSocketServer.BroadCastInfo(pushMsg);
 
             //更新推送状态
-            if(CollectionUtil.isNotEmpty(warnData.getRecords())) {
-                Long[] ids = warnData.getRecords().stream().map(item -> {
-                    return item.getId();
-                }).toArray(Long[]::new);
-                UpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>();
-                updateWrapper.lambda().set(AAutoNodeLog::getSendStatus, "1").in(AAutoNodeLog::getId, ids);
-                autoNodeLogService.update(null, updateWrapper);
-            }
+//            if(CollectionUtil.isNotEmpty(warnData.getRecords())) {
+//                Long[] ids = warnData.getRecords().stream().map(item -> {
+//                    return item.getId();
+//                }).toArray(Long[]::new);
+//                UpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>();
+//                updateWrapper.lambda().set(AAutoNodeLog::getSendStatus, "1").in(AAutoNodeLog::getId, ids);
+//                autoNodeLogService.update(null, updateWrapper);
+//            }
         }
         catch (Exception e){
             logger.error("推送异常======"+e.getMessage());

+ 5 - 4
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionReadyCenter/AAutoNodeLogMapper.xml

@@ -29,11 +29,12 @@
         select
         <include refid="Base_Column_List"/>
         from (
-        select l.*, a.node_no as nodeNo, c.name as resourceName, d.name as instructionName, p.`name` as procedureName from imcs_a_auto_node_log l
-        left join imcs_a_auto_node a ON l.auto_node_id = a.id
+        select l.*, a.task_node_no as nodeNo, c.name as resourceName, i.name as instructionName, p.`name` as procedureName from imcs_a_auto_node_log l
+        left join imcs_t_task_node a ON l.auto_node_id = a.id
         left join imcs_tenant_productionresource c on a.resource_id = c.id
-        left join imcs_b_bom_procedure p on a.procedure_id = p.id
-        left join view_module_instruction d on a.instruction_id = d.id
+        left join imcs_t_task d on a.task_id = d.id
+        left join imcs_b_bom_procedure p on d.procedure_id = p.id
+        left join view_module_instruction i on l.method = i.code
         ) s ${ew.customSqlSegment}
     </select>
 

+ 99 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/externalApi/dto/AutoInfo.java

@@ -0,0 +1,99 @@
+package com.github.zuihou.business.externalApi.dto;
+
+import io.swagger.annotations.ApiModel;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 实体类
+ * 手动模式任务信息
+ * </p>
+ *
+ * @author imcs
+ * @since 2022-02-21
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "AutoInfo", description = "自动模式任务信息")
+public class AutoInfo {
+    /**
+     * 手动任务id
+     */
+    private String autoId;
+    /**
+     * 起点设备id
+     */
+    private String startResourceId;
+
+    /**
+     * 起点位置
+     */
+    private String startpointId;
+    /**
+     * 终点设备id
+     */
+    private String endResourceId;
+    /**
+     * 结束位置
+     */
+    private String endpointId;
+
+    /**
+     * 机器人设备id
+     */
+    private String robotResourceId;
+
+    /**
+     * 起点动作
+     */
+    private String startoperation;
+    /**
+     * 终点动作
+     */
+    private String endoperation;
+    /**
+     * 协议类型
+     */
+    private String autoIdType;
+
+    /**
+     * 设备单元
+     */
+    private String deviceUnit;
+
+    /**
+     * 下一指令需要
+     */
+    private int nextTaskNodeIndex;
+
+    /**
+     * 执行程序名称
+     */
+    private String execProgram;
+
+    /**
+     * 打标清洗类型
+     */
+    private String workId;
+
+    /**
+     * 打标清洗内容
+     */
+    private String labelContent;
+
+    /**
+     * 工件id
+     */
+    private String workpieceId;
+
+    /**
+     * 手动模式标志1-手动
+     */
+    private String handModeFlag;
+}

+ 13 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionReadyCenter/entity/AAutoNodeLog.java

@@ -103,6 +103,17 @@ public class AAutoNodeLog extends Entity<Long> {
     @Excel(name = "处理状态(1-已处理0-未处理)")
     private String sendStatus;
 
+    /**
+     * 指令方法名
+     */
+    @ApiModelProperty(value = "指令方法")
+    @Length(max = 32, message = "指令方法长度不能超过32")
+    @TableField(value = "method", condition = LIKE)
+    @Excel(name = "指令方法")
+    private String method;
+
+
+
     /**
      * 开始时间
      */
@@ -188,7 +199,7 @@ public class AAutoNodeLog extends Entity<Long> {
     @Builder
     public AAutoNodeLog(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
                     Long autoNodeId, String exeStatus, String exeResult, Date startTime, Date endTime,
-                    String feedback, String feedbackFile) {
+                    String feedback, String feedbackFile, String method) {
         this.id = id;
         this.createTime = createTime;
         this.createUser = createUser;
@@ -201,6 +212,7 @@ public class AAutoNodeLog extends Entity<Long> {
         this.endTime = endTime;
         this.feedback = feedback;
         this.feedbackFile = feedbackFile;
+        this.method = method;
     }
 
 }