Explorar o código

后端代码处理更新

oyq28 hai 1 ano
pai
achega
cf1bfc001b

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

@@ -252,6 +252,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
                     Order order = orderMapper.selectById(task.getOrderId());
                     TWorkpiece tWorkpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()));
+                    tWorkpiece.setProductNo(unionCode);
+                    workpieceService.updateById(tWorkpiece);
 
                     BomProcedureVersion procedure = bomProcedureVersionService.getById(task.getProcedureId());
 
@@ -262,7 +264,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     data.put("smallTypeNo", procedure.getLabelMachineConf().equals("1")? Integer.parseInt(procedure.getLabelMachinePrograme()):  1);
                     data.put("orderNo", order.getOrderNo());
                     data.put("taskNo", task.getTaskNo());
-                    data.put("productNo", tWorkpiece.getUniqueCode());
+                    data.put("productNo", unionCode);
                     data.put("batchNo", task.getCompleteBatchNo());
                     data.put("serialNo", task.getProcedureSort().toString());
                     map.put("data", data);

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TTaskMapper.xml

@@ -433,7 +433,7 @@
           <if test="ids != null and ids != ''">
               AND t.id in (${ids})
           </if>
-          AND t.is_reload > 0
+          AND t.is_reload > 0 AND t.is_reload != 5
           GROUP BY t.is_reload
     </select>
 

+ 2 - 2
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/SynProductionStatus.java

@@ -180,7 +180,7 @@ public class SynProductionStatus {
             //获取线边库零件编号
             List<String> completeBatchNos = stockInfoService.list(new LbqWrapper<StockInfo>().eq(StockInfo::getGoodsType, "4").in(StockInfo::getStorgeId, storgeIds)).stream().map(StockInfo::getCompleteBatchNo).collect(Collectors.toList());
             //获取线边库满足条件的节点
-            List<TaskNode> taskNodeList = completeBatchNos.size()>0 ? taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getExeStatus,"2").in(TaskNode::getTargetResourceId, macResourceIds).in(TaskNode::getCompleteBatchNo, completeBatchNos).eq(TaskNode::getNodeName, "放本序设备")) : Lists.newArrayList();
+            List<TaskNode> taskNodeList = completeBatchNos.size()>0 ? taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getExeStatus,"2").in(TaskNode::getTargetResourceId, macResourceIds).in(TaskNode::getCompleteBatchNo, completeBatchNos).eq(TaskNode::getNodeName, "放本序设备").orderByAsc(TaskNode::getStartTime)) : Lists.newArrayList();
             //获得线边库加工设备列表
             //Map<Long, List<TaskNode>> taskNodeMap = taskNodeList.stream().filter(item-> resourceIds.contains(item.getTargetResourceId())).collect(Collectors.groupingBy(TaskNode::getResourceId,  LinkedHashMap::new, Collectors.toList()));
 
@@ -241,7 +241,7 @@ public class SynProductionStatus {
 
                 // 执行任务和节点设备更新
                 if(updatedTaskNodeList.size()>0){
-                    TaskNode updatedNode = updatedTaskNodeList.get(0);
+                    TaskNode updatedNode = updatedTaskNodeList.stream().sorted(Comparator.comparing(TaskNode::getStartTime)).collect(Collectors.toList()).get(0);
                     //只默认取当前第一条任务
                     TTask updatedTask = taskService.getById(updatedNode.getTaskId());
                     com.github.zuihou.business.productionResourceCenter.entity.Productionresource targetDevice = productionresourceBizMapper.selectById(updatedNode.getTargetResourceId());

+ 57 - 7
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/ToolQueryController.java

@@ -1,11 +1,14 @@
 package com.github.zuihou.business.controller.operationManagementCenter;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateUnit;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.authority.service.common.ParameterService;
 import com.github.zuihou.base.R;
@@ -17,10 +20,8 @@ import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
 import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
 import com.github.zuihou.business.operationManagementCenter.dto.PlanPageDTO;
-import com.github.zuihou.business.operationManagementCenter.entity.Order;
-import com.github.zuihou.business.operationManagementCenter.entity.OrderTask;
-import com.github.zuihou.business.operationManagementCenter.entity.Plan;
-import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.operationManagementCenter.dto.TTaskPageDTO;
+import com.github.zuihou.business.operationManagementCenter.entity.*;
 import com.github.zuihou.business.operationManagementCenter.service.OrderTaskService;
 import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
 import com.github.zuihou.business.operationManagementCenter.service.TaskService;
@@ -33,6 +34,7 @@ import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.ParameterKey;
 import com.github.zuihou.common.util.DateUtil;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.log.annotation.SysLog;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -168,16 +170,46 @@ public class ToolQueryController {
     @PostMapping("/getOrderTaskList")
     public R getOrderTaskList(@RequestBody Map<String, String> data) {
         PageParams<PlanPageDTO> planPage = new PageParams<PlanPageDTO>();
-        IPage<Plan> page = planPage.buildPage();
         PlanPageDTO planPageDTO = PlanPageDTO.builder().build();
-        planPageDTO.setPlanStatus("2").setSingleTaskFlag("1");
+        //无排产且加工进行状态
+        planPageDTO.setProduceStatus("2").setPlanStatus("1");
         planPage.setModel(planPageDTO);
-        planController.query(planPage, page, 10L);
+        planPage.setSize(100L);
         R result = planController.page(planPage);
         return R.success(result);
     }
 
 
+    @ApiOperation(value = "查询线边库调度任务", notes = "查询线边库调度任务")
+    @PostMapping("/getXbkDyTaskList")
+    public R getXbkDyTaskList(@RequestBody Map<String, String> data) {
+        List<TaskNode> taskNodeList = taskNodeService.list(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getExeStatus,"2").eq(TaskNode::getNodeName,"放本序设备").orderByAsc(TaskNode::getStartTime));
+        List<Long> taskIds = taskNodeList.stream().map(TaskNode::getTaskId).collect(Collectors.toList());
+        PageParams<TTaskPageDTO> taskPage = new PageParams<TTaskPageDTO>();
+        IPage<TTask> page = taskPage.buildPage();
+        page.setSize(100L);
+        Map map = new HashMap();
+        IPage<TTask> ipage = taskService.pageList(page,"2", new LbqWrapper<TTask>().eq(TTask::getStatus, "2").gt(TTask::getIsReload, 0).lt(TTask::getIsReload, 5).in(TTask::getId, taskIds));
+        map.put("data", ipage.getRecords());
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "查询暂存位调度任务", notes = "查询暂存位调度任务")
+    @PostMapping("/getZcwDyTaskList")
+    public R getZcwDyTaskList(@RequestBody Map<String, String> data) {
+        List<TWorkpiece> workpieceList = workpieceService.list(new LambdaQueryWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd, "0").like(TWorkpiece::getPointId, "125").or(i->i.like(TWorkpiece::getPointId, "126")));
+        List<Long> taskNodeIds = workpieceList.stream().map(TWorkpiece::getTaskNodeId).collect(Collectors.toList());
+        List<TaskNode> taskNodeList = taskNodeService.listByIds(taskNodeIds);
+        List<Long> taskIds = taskNodeList.stream().map(TaskNode::getTaskId).collect(Collectors.toList());
+        PageParams<TTaskPageDTO> taskPage = new PageParams<TTaskPageDTO>();
+        IPage<TTask> page = taskPage.buildPage();
+        Map map = new HashMap();
+        IPage<TTask> ipage = taskService.pageList(page,"2", new LbqWrapper<TTask>().eq(TTask::getStatus, "2").in(TTask::getId, taskIds));
+        map.put("data", ipage.getRecords());
+        return R.success(map);
+    }
+
+
     /**
      * 处理超时节点
      *
@@ -199,5 +231,23 @@ public class ToolQueryController {
             String content = dataMap.get("operateName").toString()+"节点("+  dataMap.get("taskNodeId").toString() +")任务执行超时";
             msgUtil.createWarnLog(content, "TimeoutException");
         }
+        //处理线边库等待超时
+        List<TTask> xbkTaskList = taskService.list(new LambdaQueryWrapper<TTask>().eq(TTask::getStatus, "2").gt(TTask::getIsReload, 0).lt(TTask::getIsReload, 5));
+        if(xbkTaskList.size()>0) {
+            List<Long> taskIds = xbkTaskList.stream().filter(item -> {
+                Productionresource productionresource = productionresourceBizMapper.selectById(item.getResourceId());
+                Long timeSpan = cn.hutool.core.date.DateUtil.between(item.getExpectStartTime(), item.getExpectEndTime(), DateUnit.MINUTE);
+                int iTimeSpan = Integer.parseInt(String.valueOf(timeSpan));
+                //动态调度以后超出预定加工周期且延迟20分钟
+                Date waitDate = DateUtils.addMinutes(new Date(), -1 * (iTimeSpan+20));
+                return DateUtil.dateDiff(item.getStartTime(), waitDate) && !productionresource.getStatus().equals("1") && productionresource.getOnlineStatus().equals("1");
+            }).map(TTask::getId).collect(Collectors.toList());
+            if(taskIds.size()>0){
+                UpdateWrapper<TTask> updateWrapper = new UpdateWrapper<TTask>();
+                updateWrapper.lambda().set(TTask::getIsReload, 0).eq(TTask::getStatus, "2").in(TTask::getId, taskIds).ne(TTask::getIsReload, 0);
+                taskService.update(null, updateWrapper);
+            }
+        }
+
     }
 }

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

@@ -65,6 +65,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.client.RestTemplate;
 
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 
@@ -582,5 +583,101 @@ public class ToolbarController {
         return R.success();
     }
 
+    @ApiOperation(value = "添加缓存回调消息", notes = "添加缓存回调消息")
+    @PostMapping("/addCallbackCache")
+    public R addCallbackCache(@RequestBody Map data) {
+        String taskNodeId = data.containsKey("taskNodeId")? data.get("taskNodeId").toString() : null;
+        if(StringUtils.isEmpty(taskNodeId)) return R.fail("数据传参为空");
+
+        String callbackType = data.containsKey("callbackType")? data.get("callbackType").toString() : null;
+        String startNo = data.containsKey("startNo")? data.get("startNo").toString() : null;
+        String targetNo = data.containsKey("targetNo")? data.get("targetNo").toString() : null;
+        String count = data.containsKey("count")? data.get("count").toString() : null;
+        Storge storge = null;
+        Storge targetStorge = null;
+
+        if(StringUtils.isEmpty(callbackType) || StringUtils.isEmpty(startNo) || StringUtils.isEmpty(targetNo) || StringUtils.isEmpty(count)) return R.fail("数据传参为空");
+        TaskNode taskNode = taskNodeService.getById(taskNodeId);
+        if(taskNode==null) return R.fail("节点不存在");
+
+        JSONObject bizJsonObject = new JSONObject();
+        switch(callbackType){
+            case "1":
+                //机床加工完成回调
+                bizJsonObject.put("bizType", "1");
+                bizJsonObject.put("handMode", "");
+                bizJsonObject.put("aimStorge", "");
+                bizJsonObject.put("DEMOLINE_STOCK_TYPE", "DEMOLINE_STOCK_TYPE_ALL_CRK");
+                msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNodeId, bizJsonObject.toJSONString(), 7, TimeUnit.DAYS);
+                break;
+            case "2":
+                //框体机器人节点回调
+                if(startNo.equals("0") || targetNo.equals("0")) return R.fail("点位位置不正确");
+                storge = storgeService.getOne(new LbqWrapper<Storge>().likeRight(Storge::getName, "KT").likeLeft(Storge::getName, startNo).eq(Storge::getPointId, startNo).last("limit 1"));
+                if(null == storge || null == storge.getPointId()) return R.fail("暂存位库位不存在");
+
+                targetStorge = storgeService.getOne(new LbqWrapper<Storge>().likeRight(Storge::getName, "KT").likeLeft(Storge::getName, targetNo).eq(Storge::getPointId, targetNo).last("limit 1"));
+                if(null == targetStorge || null == targetStorge.getPointId()) return R.fail("目标库位不存在");
+
+                bizJsonObject.put("bizType", "1");
+                bizJsonObject.put("handMode", "");
+                bizJsonObject.put("aimStorge", "");
+                bizJsonObject.put("YUNJIAN_ROBORT_CACHE_FLAG", "1");
+                bizJsonObject.put("DEMOLINE_STOCK_TYPE", "DEMOLINE_STOCK_TYPE_ALL_CRK");
+                bizJsonObject.put("srcPosition", storge.getId());
+                bizJsonObject.put("targetPostion", targetStorge.getId());
+                msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNodeId, bizJsonObject.toJSONString(), 7, TimeUnit.DAYS);
+                break;
+            case "3":
+                //舱体机器人节点回调
+                if(startNo.equals("0") || targetNo.equals("0")) return R.fail("点位位置不正确");
+
+                storge = storgeService.getOne(new LbqWrapper<Storge>().likeRight(Storge::getName, "CT").likeLeft(Storge::getName, startNo).eq(Storge::getPointId, startNo).last("limit 1"));
+                if(null == storge || null == storge.getPointId()) return R.fail("暂存位库位不存在");
+
+                targetStorge = storgeService.getOne(new LbqWrapper<Storge>().likeRight(Storge::getName, "CT").likeLeft(Storge::getName, targetNo).eq(Storge::getPointId, targetNo).last("limit 1"));
+                if(null == targetStorge || null == targetStorge.getPointId()) return R.fail("目标库位不存在");
+
+                bizJsonObject.put("bizType", "1");
+                bizJsonObject.put("handMode", "");
+                bizJsonObject.put("aimStorge", "");
+                bizJsonObject.put("YUNJIAN_ROBORT_CACHE_FLAG", "1");
+                bizJsonObject.put("DEMOLINE_STOCK_TYPE", "DEMOLINE_STOCK_TYPE_ALL_CRK");
+                bizJsonObject.put("srcPosition", storge.getId());
+                bizJsonObject.put("targetPostion", targetStorge.getId());
+                bizJsonObject.put(taskNodeId+"count", count);
+                msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNodeId, bizJsonObject.toJSONString(), 7, TimeUnit.DAYS);
+                break;
+            case "4":
+                //伺服舵机节点回调
+                if(startNo.equals("0") || targetNo.equals("0")) return R.fail("点位位置不正确");
+
+                storge = storgeService.getOne(new LbqWrapper<Storge>().eq(Storge::getPointId, startNo).and(item-> item.likeRight(Storge::getName, "bz").or().likeRight(Storge::getName, "BZ")).last("limit 1"));
+                if(null == storge || null == storge.getPointId()) return R.fail("暂存位库位不存在");
+
+                targetStorge = storgeService.getOne(new LbqWrapper<Storge>().eq(Storge::getPointId, targetNo).and(item->item.likeRight(Storge::getName, "BZ").or().likeRight(Storge::getName, "bz")).last("limit 1"));
+                if(null == targetStorge || null == targetStorge.getPointId()) return R.fail("目标库位不存在");
+
+                bizJsonObject.put("bizType", "1");
+                bizJsonObject.put("handMode", "");
+                bizJsonObject.put("aimStorge", "");
+                bizJsonObject.put("DEMOLINE_STOCK_TYPE", "DEMOLINE_STOCK_TYPE_ALL_CRK");
+                bizJsonObject.put("srcPosition", storge.getId());
+                bizJsonObject.put("targetPostion", targetStorge.getId());
+                bizJsonObject.put(taskNodeId+"count", count);
+                msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNodeId, bizJsonObject.toJSONString(), 7, TimeUnit.DAYS);
+                break;
+            case "5":
+                //线边库Flag
+                msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + taskNodeId, "1", 7, TimeUnit.DAYS);
+                break;
+            case "6":
+                //暂存位线边库Flag
+                msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNodeId, "1", 7, TimeUnit.DAYS);
+                break;
+        }
+        return R.success();
+    }
+
 }
 

+ 4 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/TWorkpieceUpdateDTO.java

@@ -65,4 +65,8 @@ public class TWorkpieceUpdateDTO implements Serializable {
     @ApiModelProperty(value = "")
     @Length(max = 32, message = "长度不能超过32")
     private String completeBatchNo;
+
+    @ApiModelProperty(value = "打标唯一码")
+    @Length(max = 255, message = "长度不能超过255")
+    private String productNo;
 }

+ 6 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TWorkpiece.java

@@ -295,4 +295,10 @@ public class TWorkpiece extends Entity implements Serializable {
      */
     @TableField(exist = false)
     private double totalWorkTime;
+
+    /**
+     * 零件打标唯一码
+     */
+    @TableField("product_no")
+    private String productNo;
 }