Pārlūkot izejas kodu

更新抽检结果展示 、 节点扩展异常日志、 指令重发增加功能判断

oyq28 3 gadi atpakaļ
vecāks
revīzija
1267e98c63

+ 32 - 11
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -160,6 +160,9 @@ public class TaskWorkNode {
         //多产品搬运类型
         String carryType = jsonObject.getString("carryType");
         if (StringUtil.isEmpty(taskNodeId) || StringUtil.isEmpty(bizType)) {
+            AAutoNodeLog log = AAutoNodeLog.builder().build();
+            log.setExeResult("0").setManual("1").setFeedback("全局异常处理");
+            autoNodeLogService.save(log);
             throw new RuntimeException("全局通知异常");
         }
         logger.info("=======================" + taskNodeId);
@@ -169,10 +172,16 @@ public class TaskWorkNode {
 //
         if (taskNode == null || taskNode.getTaskId() == null) {
             //模拟处理数据
+            AAutoNodeLog log = AAutoNodeLog.builder().build();
+            log.setExeResult("0").setManual("0").setFeedback("当前任务节点为空");
+            autoNodeLogService.save(log);
             throw new RuntimeException("当前任务节点为空");
         }
         TTask tTask = taskMapper.selectById(taskNode.getTaskId());
         if (tTask == null || tTask.getStatus() == "3") {
+            AAutoNodeLog log = AAutoNodeLog.builder().build();
+            log.setTaskNodeId(taskNode.getId()).setExeResult("0").setManual("0").setFeedback("当前任务为空");
+            autoNodeLogService.save(log);
             throw new RuntimeException("当前任务为空");
         }
 //        //获取配置序数据
@@ -197,21 +206,13 @@ public class TaskWorkNode {
         isFinal = resourceAutoCode.isFinal() ? true : false;
         msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE + "_" + taskNode.getResourceId(), resourceAutoCode);
 
-        List<AAutoNodeLog> autoNodeLogList = autoNodeLogMapper.selectList(Wraps.<AAutoNodeLog>lbQ().eq(AAutoNodeLog::getTaskNodeId, taskNode.getId()));
-        //插入执行日志
-        AAutoNodeLog log = new AAutoNodeLog();
-        if (autoNodeLogList == null || autoNodeLogList.size() == 0) {
-            log.setTaskNodeId(taskNode.getId()).setAutoNodeId(taskNode.getAutoNode().getId()).setOrderId(tTask.getOrderId())
-                    .setTaskId(tTask.getId()).setExeStatus("2").setStartTime(new Date()).setFeedbackFile(fileName);
-        } else {
-            log = autoNodeLogList.get(0);
-            log.setFeedbackFile(fileName);
-        }
-
         //更新节点任务
         taskNode.setExeStatus("2").setStartTime(new Date());
         taskNodeMapper.updateAllById(taskNode);
 
+        //初始化业务日志
+        AAutoNodeLog log = getBusinessLog(tTask, taskNode);
+
 //        logger.info("==================请求地址=============" + autoProgramUrl);
         String returnData = "";
 
@@ -923,5 +924,25 @@ public class TaskWorkNode {
         }
         return false;
     }
+
+    /**
+     * 动态获取业务日志
+     *
+     * @return AAutoNodeLog
+     */
+    public AAutoNodeLog getBusinessLog(TTask tTask, TaskNode taskNode){
+        //插入执行日志
+        AAutoNodeLog log = new AAutoNodeLog();
+        List<AAutoNodeLog> autoNodeLogList = autoNodeLogMapper.selectList(Wraps.<AAutoNodeLog>lbQ().eq(AAutoNodeLog::getTaskNodeId, taskNode.getId()));
+
+        if (autoNodeLogList == null || autoNodeLogList.size() == 0) {
+            log.setTaskNodeId(taskNode.getId()).setAutoNodeId(taskNode.getAutoNode().getId()).setOrderId(tTask.getOrderId())
+                    .setTaskId(tTask.getId()).setExeStatus("2").setStartTime(new Date()).setFeedbackFile(fileName);
+        } else {
+            log = autoNodeLogList.get(0);
+            log.setFeedbackFile(fileName);
+        }
+        return log;
+    }
 }
 

+ 4 - 3
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/InspectionMapper.xml

@@ -21,8 +21,8 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,create_time,update_time,create_user, update_user, bom_id,zone_id,task_id,order_id,plan_id, workpiece_id, result,report,org_id,
-        bomName, partsNo, startTime, endTime,procedureNo, procedureName, zoneNo
+        id,create_time,update_time,create_user, update_user, bom_id,zone_id,task_id,order_id,plan_id, workpiece_id, org_id,
+        bomName, partsNo, startTime, endTime,procedureNo, procedureName, zoneNo, ifnull(ok_flag, result) as result,  measuring_report as report
     </sql>
 
     <!-- 分页 -->
@@ -30,12 +30,13 @@
         select
         <include refid="Base_Column_List"/>
         from (
-           select a.*, b.name as bomName, b.parts_no as partsNo, o.start_time as startTime, o.end_time as endTime, p.name as procedureName, p.no as procedureNo, z.org_id, z.no as zoneNo from imcs_o_order_inspection a
+           select a.*,b.name as bomName, b.parts_no as partsNo, o.start_time as startTime, o.end_time as endTime, p.name as procedureName, p.no as procedureNo, z.org_id, z.no as zoneNo, q.ok_flag, q.measuring_report from imcs_o_order_inspection a
            left join imcs_p_plan o on a.plan_id = o.id
            left join imcs_b_bom b on a.bom_id = b.id
            left join imcs_z_zone z on a.zone_id = z.id
            left join imcs_t_task k on a.task_id = k.id
            left join imcs_b_bom_procedure p on k.procedure_id = p.id
+           left join imcs_order_quality_info q on a.workpiece_id = q.workpiece_id
         ) s ${ew.customSqlSegment}
     </select>
 

+ 17 - 3
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/dispatchRecord/DispatchExceptionController.java

@@ -17,6 +17,7 @@ import com.github.zuihou.business.dispatchRecord.service.DispatchExceptionServic
 import com.github.zuihou.business.dispatchRecord.service.DispatchRecordService;
 import com.github.zuihou.business.operationManagementCenter.entity.Order;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
 import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
 import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
@@ -50,6 +51,7 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Validated
@@ -163,7 +165,9 @@ public class DispatchExceptionController extends SuperSimpleController<AAutoNode
         Map<String, Object> conMap = msgUtil.redis_get_map(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNodeId);
         //获取重发执行传参
         String jsonParam = msgUtil.redis_get(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNodeId).toString();
-
+        if(StringUtils.isEmpty(jsonParam)){
+            return R.fail("指令请求不存在");
+        }
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
         HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
@@ -172,8 +176,18 @@ public class DispatchExceptionController extends SuperSimpleController<AAutoNode
         String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
         JSONObject retJson = JSONObject.parseObject(returnData);
         String code = retJson.getString("code").trim();
-
-        return R.success(("1" == code)? true: false);
+        if(code.equals("0")){
+            autoNodeLog.setExeResult("0").setManual("1").setFeedback(retJson.getString("msg"));
+            aAutoNodeLogService.updateAllById(autoNodeLog);
+            return R.fail("指令重发失败");
+        }else{
+            //将同一节点的指令请求日志状态批量改为处理
+            List<Long> ids = aAutoNodeLogService.list(new LbqWrapper<AAutoNodeLog>().eq(AAutoNodeLog::getTaskNodeId, taskNodeId).eq(AAutoNodeLog::getStatus, "0").orderByAsc(AAutoNodeLog::getCreateTime)).stream().map(AAutoNodeLog::getId).collect(Collectors.toList());
+            UpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>();
+            updateWrapper.lambda().in(AAutoNodeLog::getId, ids.toArray()).set(AAutoNodeLog::getStatus, "1");
+            aAutoNodeLogService.update(updateWrapper);
+        }
+        return R.success(true);
     }
 
 }