Procházet zdrojové kódy

后台业务功能改进处理

oyq28 před 1 měsícem
rodič
revize
03bb059d28

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

@@ -379,7 +379,7 @@ public class TaskWorkNode {
                         taskNodeService.updateById(taskNode);
                         tTask.setStatus("3").setEndTime(new Date());
                         taskMapper.updateAllById(tTask);
-                        TWorkpiece currWorkpiece = workpieceService.getWorkPiece(taskNode.getId());
+                        TWorkpiece currWorkpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, taskNode.getCompleteBatchNo()).eq(TWorkpiece::getIsEnd, "0"));
                         currWorkpiece.setIsEnd("1");
                         workpieceService.updateById(currWorkpiece);
                         Plan plan = planMapper.selectById(tTask.getPlanId());
@@ -394,17 +394,21 @@ public class TaskWorkNode {
                             autoNodeLogService.updateAllById(autoNodeLog);
                         }
                         //自定义订单后续处理
-                        if(order.getSingleTaskFlag().equals("1") && order.getHasMaterial().equals("0")){
+                        if(order.getSingleTaskFlag().equals("1")){
                             OrderTask orderTask = orderTaskService.getOne(new LbqWrapper<OrderTask>().eq(OrderTask::getOrderId, order.getId()).last("limit 1"));
+                            if(StringUtils.isNotEmpty(orderTask.getConfBatchNo())){
+                                //将原订单库位信息的同步更新到目的位置
+                                TWorkpiece tWorkpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, orderTask.getConfBatchNo()).eq(TWorkpiece::getIsEnd, "0"));
+                                if(tWorkpiece!=null){
+                                    tWorkpiece.setStorgeId(currWorkpiece.getStorgeId()).setPointId(currWorkpiece.getPointId());
+                                    workpieceService.updateById(tWorkpiece);
+                                }
+                            }
                             taskNodeService.remove(new LbqWrapper<TaskNode>().eq(TaskNode::getCompleteBatchNo, taskNode.getCompleteBatchNo()));
                             taskMapper.deleteById(tTask.getId());
                             workpieceService.removeById(currWorkpiece.getId());
                             planMapper.delete(new LbqWrapper<Plan>().eq(Plan::getOrderId, order.getId()));
                             orderMapper.deleteById(order.getId());
-                            if(StringUtils.isNotEmpty(orderTask.getConfBatchNo())){
-                                //删除自动生成零件库位信息
-                                stockInfoMapper.delete(new LbqWrapper<StockInfo>().eq(StockInfo::getCompleteBatchNo, orderTask.getConfBatchNo()));
-                            }
                             orderTaskService.removeById(orderTask.getId());
                         }
                         return;
@@ -447,7 +451,7 @@ public class TaskWorkNode {
 
                     //运行条件验证
                     conMap = checkCon(taskNode, tTask, queryMap);
-                    if(!conMap.containsKey("result")){
+                    if(conMap.isEmpty()){
                         //处理需要丢弃的节点
                         return;
                     }
@@ -541,7 +545,7 @@ public class TaskWorkNode {
                                         JSONObject ret = new JSONObject();
                                         ret.put("result","true");
                                         returnData = ret.toJSONString();
-                                    }else if(taskNode.getCompleteBatchSort()!=1 && beforResourceBusiness!=null && "3".equals(beforTask.getStatus()) && resourceBusiness.getName().contains("下料业务") && "GetServoStacker".equals(method) && "打标业务".equals(beforResourceBusiness.getName())){
+                                    }else if(taskNode.getCompleteBatchSort()!=1 && beforResourceBusiness!=null && "3".equals(beforTask.getStatus()) && resourceBusiness.getName().contains("动态下料") && "GetServoStacker".equals(method) && "打标业务".equals(beforResourceBusiness.getName())){
                                         specialCallBackMyselfFlag = true;
                                         String jsonParam = getRequestParam(conMap);
                                         //缓存执行当前节点传参
@@ -674,11 +678,15 @@ public class TaskWorkNode {
             if (log.getId() == null) {
                 autoNodeLogService.save(log);
             } else {
-                if(log.getFeedback()!=feedBack) {
+                if(StringUtil.isNotEmpty(feedBack) && StringUtil.isNotEmpty(log.getFeedback()) && !log.getFeedback().equals(feedBack)) {
                     log.setExecuteTime(new Date());
                     autoNodeLogService.updateAllById(log);
                 }
             }
+            //if(lock.tryLock()){
+                lock.unlock();
+                logger.info("节点{}名称{}释放锁",taskNode.getId(),taskNode.getNodeName());
+            //}
             logger.info("specialCallBackMyselfFlag={}",specialCallBackMyselfFlag);
             if(specialCallBackMyselfFlag){
                 // 打标机或恒轮上传程序特殊处理
@@ -695,10 +703,6 @@ public class TaskWorkNode {
                 //restTemplate.postForObject(taskNodeCallbackUrl, formEntity, String.class);
                 msgUtil.httpForPost(taskNodeCallbackUrl, callBackData.toJSONString());
             }
-            if(lockFlag){
-                lock.unlock();
-                logger.info("节点{}名称{}释放锁",taskNode.getId(),taskNode.getNodeName());
-            }
             //优先级队列缓存处理
             this.checkPriorityCondition(priority,"PRIORITY_"+consumerQueue.toUpperCase(),(boolean)conMap.get("result"), taskNodeId);
 

+ 7 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java

@@ -247,7 +247,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     instructionUrl = instructionUrl.replace("8083","8081");
                     //打标
                     if(ObjectUtil.isNotEmpty(msgUtil.redis_get(YunjianConstant.YUNJIAN_LABEL_STATUS+"_"+task.getId().toString()))){
-                        return Maps.newHashMap();
+                        map.put("result", false);
+                        return map;
                     }
 
                     //获取打标指令编码imcs_t_workpiece
@@ -278,7 +279,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     data.put("serialNo", task.getProcedureSort().toString());
 
                     //4. 打标成功后:编号递增并更新到order表
-                    String nextBatchNo = incrementBatchNo(completeBatchNoFormat(order.getBatchNo())); //生成下一个编号
+                    //boolean isMpl = labelConfArr[0].equals("D") ? true : false;
+                    String nextBatchNo = incrementBatchNo(completeBatchNoFormat(order.getBatchNo()), false); //生成下一个编号
                     order.setBatchNo(nextBatchNo); //更新订单编号
                     orderMapper.updateById(order); //保存到数据库
                     msgUtil.redis_set(YunjianConstant.YUNJIAN_LABEL_STATUS+"_"+task.getId().toString(), task.getId(), 2, TimeUnit.DAYS );
@@ -475,7 +477,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     }
 
     //新增:编号递增(01-01-25-001 → 01-01-25-002)
-    private String incrementBatchNo(String currentNo) {
+    private String incrementBatchNo(String currentNo, boolean isMpl) {
         String[] parts = currentNo.split("-");
         if (parts.length != 4) {
             throw new IllegalArgumentException("无效的编号格式:" + currentNo);
@@ -483,7 +485,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
         String prefix = parts[0] + "-" + parts[1] + "-" + parts[2];
         int currentSeq = Integer.parseInt(parts[3]);
-        return prefix + "-" + String.format("%03d", currentSeq + 1);
+        int step = isMpl? 3 : 1;
+        return prefix + "-" + String.format("%03d", currentSeq + step);
     }
 
     @Override

+ 4 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java

@@ -962,7 +962,10 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 dataMap.put("data", locationMap);
 
                 //出入库类型
-                if(taskNode.getCompleteBatchSort()==2){//TODO 条件后续再丰富
+                if(goalPointId!=null){
+                    dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+                }
+                else if(taskNode.getCompleteBatchSort()==2){//TODO 条件后续再丰富
                     dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_TRAY_CRK);
                 }else {
                     String bizType = dataMap.get("bizType") == null ? "" : dataMap.get("bizType").toString();
@@ -978,9 +981,6 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                     //把计数去掉,从线边库开始重新计数
                     dataMap.remove(taskNode.getId().toString()+"count");
                 }
-
-                //伺服舵机占用,对多并发MQ请求过滤以提升服务效率和性能
-                msgUtil.redis_set(CacheKey.MQ_SFDJ_INTERCEPT, taskNode.getId(), 1, TimeUnit.HOURS);
                 dataMap.put("result", true);
             }
 

+ 11 - 9
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -222,6 +222,8 @@ public class MsgUtil implements ApplicationContextAware {
             Order order = orderMapper.selectById(task.getOrderId());
             Plan plan = planMapper.selectById(task.getPlanId());
             BBom bom = bBomMapper.selectById(task.getBomId());
+            Productionresource productionresource = productionresourceBizMapper.selectById(task.getResourceId());
+            boolean isBZ = productionresource.getCode().contains("BZ");
 
             if(zoneType.equals(ParameterKey.ZONE_SFX)){
                 //如果是三坐标检测
@@ -317,7 +319,7 @@ public class MsgUtil implements ApplicationContextAware {
 
 
                 //获取配置工序
-                BomProcedure bomProcedure = bomProcedureMapper.selectById(task.getProcedureId());
+                //BomProcedure bomProcedure = bomProcedureMapper.selectById(task.getProcedureId());
                 logger.info("【进入YJ_MQ队列判断】,节点对象:{}",JSONObject.toJSONString(taskNode));
                 //如果是三坐标检测
                 if("3".equals(taskNode.getNodeType())){
@@ -529,7 +531,7 @@ public class MsgUtil implements ApplicationContextAware {
                             taskMapper.updateById(task);
 
                         }else{
-                            this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone);
+                            this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone, isBZ);
                             dynamicRabbitMq.sendMsg(nextTaskNode.getResourceId().toString(),jsonObject.toString());
                         }
 
@@ -582,14 +584,14 @@ public class MsgUtil implements ApplicationContextAware {
                     else if(nextNode!=null){
                         boolean ret = this.priorityHandle(taskNode, nextNode, jsonObject);
                         if(ret) {
-                            this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone);
+                            this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone, false);
                             return;
                         }
                     }
-                }else if(positionCache || agvCache){
+                }else if((positionCache && !isBZ) || agvCache){
                     boolean ret = this.priorityHandle(taskNode, nextNode, jsonObject);
                     if(ret) {
-                        this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone);
+                        this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone, false);
                         return;
                     }
                 }
@@ -606,7 +608,7 @@ public class MsgUtil implements ApplicationContextAware {
                     task.setStatus("3");
                     taskMapper.updateById(task);
                 }else{
-                    logger.info("【节点任务放入MQ】节点id:{}",nextTaskNode);
+                    logger.warn("【节点任务放入MQ】节点id:{}",nextTaskNode);
                     /*
                     TaskNode nextNextNode = taskNodeService.getNextNTaskNode(nextTaskNode, 1);
                     boolean bool = nextTaskNode.getTargetResourceId()==null && nextNextNode!=null && nextNextNode.getTargetResourceId()!=null ;
@@ -617,7 +619,7 @@ public class MsgUtil implements ApplicationContextAware {
                         }
                     } */
                     jsonObject.put(nextTaskNode.getId().toString()+"count","0");
-                    this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone);
+                    this.cleanCacheId(repeatKey, taskNode.getId().toString(), bomzZone, isBZ);
                     dynamicRabbitMq.sendMsg(nextTaskNode.getResourceId().toString(),jsonObject.toString());
                 }
             }
@@ -629,13 +631,13 @@ public class MsgUtil implements ApplicationContextAware {
      *
      * @param repeatKey
      */
-    public void cleanCacheId(String repeatKey, String taskNodeId, ZZone zZone){
+    public void cleanCacheId(String repeatKey, String taskNodeId, ZZone zZone, boolean isBz){
         String cacheUid = msgUtil.redis_get(repeatKey) == null ? "" : msgUtil.redis_get(repeatKey).toString();
         if (StringUtil.isNotEmpty(cacheUid)){
             msgUtil.redis_del(repeatKey);
             msgUtil.redis_fuzzy_del(YunjianConstant.YUNJIAN_SCHEDULE_LIST, taskNodeId);
         }
-        if(StringUtil.isNotEmpty(taskNodeId) && null!=zZone){
+        if(StringUtil.isNotEmpty(taskNodeId) && null!=zZone && !isBz){
             String symbol="";
             switch(zZone.getNo()){
                 case "capsule": symbol = "CT_jqr"; break;

+ 27 - 1
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/ToolbarController.java

@@ -146,6 +146,10 @@ public class ToolbarController {
     private TrayService trayService;
     @Autowired
     private AgvHikOrderInfoMapper agvHikOrderInfoMapper;
+    @Autowired
+    private PlanProductService planProductService;
+    @Autowired
+    private OrderProductService orderProductService;
 
     @ApiOperation(value = "更新库位位置", notes = "更新库位位置")
     @PostMapping("/updateStorge")
@@ -1094,7 +1098,9 @@ public class ToolbarController {
         orderProductList.add(orderProduct);
         params.put("orderProductList", orderProductList);
         Order order = orderService.save(params);
-        String confBatchNo = tWorkpiece != null ? tWorkpiece.getCompleteBatchNo() : "";
+        List<StockInfo> workerPieceInfoList = stockInfoService.getStockInfoByType(startStorge.getId(), "4");
+        StockInfo workerPieceInfo = workerPieceInfoList.size()>0? workerPieceInfoList.get(0) : null;
+        String confBatchNo = tWorkpiece != null ? (workerPieceInfo!=null? workerPieceInfo.getCompleteBatchNo() : tWorkpiece.getCompleteBatchNo()): "";
 
         OrderTask orderTask = OrderTask.builder().orderId(order.getId())
                 .hasMaterial(hasMaterial).isMachine("0").isXbk("1").start(model.get("start").toString()).goal(model.get("goal").toString()).confBatchNo(confBatchNo)
@@ -1111,5 +1117,25 @@ public class ToolbarController {
         return bool? success(orderTask) : fail("生成节点失败,请检查该工装工艺!");
     }
 
+    @ApiOperation(value = "强制删除订单", notes = "强制删除订单")
+    @PostMapping("/delOrder")
+    public R delOrder(@RequestBody Map data) {
+        BaseContextHandler.setTenant("0000");
+        String orderId = data.containsKey("orderId")? data.get("orderId").toString() : null;
+        if(StringUtils.isEmpty(orderId)) return R.fail("数据传参为空");
+        Order order = orderService.getById(orderId);
+        if(null==order) return R.fail("订单数据不能为空");
+
+        taskNodeService.remove(new LbqWrapper<TaskNode>().eq(TaskNode::getOrderId, orderId));
+        taskService.remove(new LbqWrapper<TTask>().eq(TTask::getOrderId, orderId));
+        planService.remove(new LbqWrapper<Plan>().eq(Plan::getOrderId, orderId));
+        planProductService.remove(new LbqWrapper<PlanProduct>().eq(PlanProduct::getOrderId, orderId));
+        orderProductService.remove(new LbqWrapper<OrderProduct>().eq(OrderProduct::getOrderId, orderId));
+        workpieceService.remove(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getOrderId, orderId));
+        orderTaskService.remove(new LbqWrapper<OrderTask>().eq(OrderTask::getOrderId, orderId));
+        orderService.removeById(orderId);
+
+        return R.success();
+    }
 }
 

+ 2 - 2
imcs-admin-boot/imcs-jobs/imcs-jobs-core/src/main/java/com/xxl/job/core/http/RestTemplateConfig.java

@@ -22,8 +22,8 @@ public class RestTemplateConfig {
     @Bean
     public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
         SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
-        factory.setReadTimeout(6000000);//单位为ms
-        factory.setConnectTimeout(6000000);//单位为ms
+        factory.setReadTimeout(3000000);//单位为ms
+        factory.setConnectTimeout(3000000);//单位为ms
         return factory;
     }
 

+ 2 - 4
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java

@@ -47,7 +47,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
-import javax.annotation.Resource;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -102,8 +102,6 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
     @Autowired
     private UserService userService;
 
-    @Autowired
-    private RestTemplate restTemplate;
 
     @Value("${xxl.job.admin.addresses}")
     private String jobAdminUrl;
@@ -119,7 +117,7 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
     private ZZoneMapper zoneMapper;*/
 
     @Autowired
-    private ParameterService parameterService;
+    private RestTemplate restTemplate;
 
     @Override
     protected String getRegion() {