wang.sq@aliyun.com пре 2 месеци
родитељ
комит
2499a65993

+ 27 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/centralToolMagazine/service/impl/ToolManagementServiceImpl.java

@@ -19,7 +19,11 @@ import com.github.zuihou.business.cuttercategories.entity.CutterCategories;
 import com.github.zuihou.business.edgeLibrary.dto.ShelvesUpdateDTO;
 import com.github.zuihou.business.operationManagementCenter.dao.PlanProductMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.ToolTaskMapper;
+import com.github.zuihou.business.operationManagementCenter.entity.Order;
+import com.github.zuihou.business.operationManagementCenter.entity.Plan;
 import com.github.zuihou.business.operationManagementCenter.entity.PlanProduct;
+import com.github.zuihou.business.operationManagementCenter.service.OrderService;
+import com.github.zuihou.business.operationManagementCenter.service.PlanService;
 import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BomVersionInfoMapper;
@@ -86,6 +90,8 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
     @Autowired
     private CuttingToolMapper cuttingToolMapper;
 
+    @Autowired
+    private OrderService orderService;
     @Autowired
     private PlanProductMapper planProductMapper;
 
@@ -193,8 +199,8 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
 
     @Override
     public R toolCheck(Map<String, Object> map) {
-        String plan = map.get("plan").toString();
-        List<Long> planIds = Arrays.stream(plan.split(","))
+        String planIdsPar = map.get("plan").toString();
+        List<Long> planIds = Arrays.stream(planIdsPar.split(","))
                 .map(Long::valueOf)
                 .collect(Collectors.toList());
 
@@ -203,6 +209,9 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
 
         planIds.stream().forEach(item ->{
             PlanProduct planProduct = planProductMapper.selectOne(Wraps.<PlanProduct>lbQ().eq(PlanProduct::getPlanId, item));
+
+            Order order = orderService.list(Wraps.<Order>lbQ().eq(Order::getId, planProduct.getOrderId())).get(0);
+
             Long bomId=planProduct.getBomId();
             BBom bBom = bBomMapper.selectOne(Wraps.<BBom>lbQ().eq(BBom::getId, bomId));
             BomVersionInfo bomVersionInfo = bomVersionInfoMapper.selectOne(Wraps.<BomVersionInfo>lbQ()
@@ -211,6 +220,10 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
                     .eq(BomVersionInfo::getBomId,bomId));
             if(Objects.isNull(bomVersionInfo)){
                 ToolCheckDTO toolCheckDTO=new ToolCheckDTO();
+                toolCheckDTO.setId(item);
+                toolCheckDTO.setOrderId(order.getId());
+                toolCheckDTO.setOrderNo(order.getOrderNo());
+                toolCheckDTO.setOrderName(order.getOrderName());
                 toolCheckDTO.setIsNoCutter(0);
                 toolCheckDTO.setName(bBom.getName());
                 toolCheckDTO.setHasCuttingToolsFlag("否");
@@ -254,6 +267,10 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
             if(needToolList.isEmpty()|| needToolList.size()<=0){
                 log.info("刀具校验:未配置工艺刀具");
                 ToolCheckDTO toolCheckDTO=new ToolCheckDTO();
+                toolCheckDTO.setId(item);
+                toolCheckDTO.setOrderId(order.getId());
+                toolCheckDTO.setOrderNo(order.getOrderNo());
+                toolCheckDTO.setOrderName(order.getOrderName());
                 toolCheckDTO.setIsNoCutter(0);
                 toolCheckDTO.setName(bBom.getName());
                 toolCheckDTO.setHasCuttingToolsFlag("否");
@@ -302,6 +319,10 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
                 List<String> cutterTs = needCutterCategories.stream().map(CutterCategories::getCutterT).collect(Collectors.toList());
 
                 ToolCheckDTO toolCheckDTO =new ToolCheckDTO();
+                toolCheckDTO.setId(item);
+                toolCheckDTO.setOrderId(order.getId());
+                toolCheckDTO.setOrderNo(order.getOrderNo());
+                toolCheckDTO.setOrderName(order.getOrderName());
                 toolCheckDTO.setIsNoCutter(1);
                 toolCheckDTO.setIsTask(needCutterCategories.size()>0?"是":"否");
                 toolCheckDTO.setNumber(needCutterCategories.size());
@@ -361,6 +382,10 @@ public class ToolManagementServiceImpl extends SuperCacheServiceImpl<ToolManagem
                     Boolean isFree=freeCount > lackTools.size();
                     //ToolTask findToolTask = toolTaskMapper.selectOne(Wraps.<ToolTask>lbQ().eq(ToolTask::getPlanId, item));
 
+                    toolCheckDTO.setId(item);
+                    toolCheckDTO.setOrderId(order.getId());
+                    toolCheckDTO.setOrderNo(order.getOrderNo());
+                    toolCheckDTO.setOrderName(order.getOrderName());
                     toolCheckDTO.setIsNoCutter(0);
                     toolCheckDTO.setIsTask(lackTools.size()>0?"是":"否");
                     toolCheckDTO.setId(vo.getResourceId());

+ 44 - 14
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/MesController.java

@@ -33,9 +33,11 @@ import com.github.zuihou.business.productionReadyCenter.service.*;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 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.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.file.biz.FileBiz;
@@ -182,22 +184,41 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
     
     @Autowired
     private CuttingToolService cuttingToolService;
-    
+
     @ApiOperation(value = "刀具需求下发给EOP", notes = "刀具需求下发给EOP")
     @PostMapping("/externalApi/sendCutterNeedToEop")
     public R sendCutterNeedToEop(@RequestBody List<ToolCheckDTO> datas) {
         log.info("定时================发送刀具需求给Eop系统开始================");
+        StringBuffer isExist = new StringBuffer();
         BaseContextHandler.setTenant("0000");
 
-        List list = new ArrayList();
+        // 获取远程地址
+        String url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get("cutterApply").toString());
+
         Map<Long, CuttingTool> collect = cuttingToolService.list().stream().collect(Collectors.toMap(t -> t.getCuttingToolNo(), t -> t));
 
         for (ToolCheckDTO data : datas) {
+            Order order = orderService.list(Wraps.<Order>lbQ().eq(Order::getOrderNo, data.getOrderNo())).get(0);
+            OrderProduct orderProduct = orderProductService.getOne(Wraps.<OrderProduct>lbQ().eq(OrderProduct::getOrderNo, data.getOrderNo()));
+            BBom bBom = bBomService.getOne(Wraps.<BBom>lbQ().eq(BBom::getId, orderProduct.getBomId()));
+
+            String needDate = DateUtil.formatTime(DateUtil.getBeforeDate(new Date(), -15));
+            JSONObject cutterApply = new JSONObject();
+            cutterApply.put("AUFNR",order.getOrderNo());
+            cutterApply.put("VORNR",bBom.getNo());
+            cutterApply.put("ZCODE",bBom.getNo());
+            cutterApply.put("TXA1",bBom.getName());
+            cutterApply.put("LJMATNR",bBom.getPartsNo());
+            cutterApply.put("LMAKTX",bBom.getName());
+            cutterApply.put("DEPIID","407109");
+            cutterApply.put("USERC2Z",order.getUpdateUser());
+            cutterApply.put("XQRQ",needDate);
+
+            List list = new ArrayList();
             for (String cutterT : data.getList()) {
                 if (!collect.containsKey(Long.parseLong(cutterT))){
                     continue;
                 }
-
                 CuttingTool cuttingTool = collect.get(Long.parseLong(cutterT));
                 String factoryMaterialCode = cuttingTool.getFactoryMaterialCode();
                 String[] splitFactoryMaterialCode = factoryMaterialCode.split(";");
@@ -209,21 +230,30 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
 
                     list.add(jsonObject);
                 }
+                cutterApply.put("ItemData", list);
             }
-        }
 
-        
-        MesNotice mesNotice = MesNotice.builder().orderNo(System.currentTimeMillis()+"").buType("TASKDISTRIBUTE").lineCode("407109")
-                .status("1").apiType("CUTTERNEED").source("PRODUCTION_LINE").targetSource("EOP").acceptPar(JSONObject.toJSONString(list)).build();
-        try {
-            boolean b = baseService.addNotice(mesNotice);
-            if(b){
-                
+            MesNotice mesNotice = MesNotice.builder().orderNo(data.getOrderNo()).buType("TASKAPPLY").lineCode("407109")
+                    .status("1").apiType("CUTTERNEED").source("产线管控单元").targetSource("刀具系统(EOP)").apiAddress(url)
+                    .acceptPar(JSONObject.toJSONString(cutterApply)).build();
+            try {
+                boolean b = baseService.addNotice(mesNotice);
+                if(b){
+                    // 调用接口发送需求
+                    String returnData = msgUtil.httpForPost(mesNotice.getApiAddress(),mesNotice.getAcceptPar());
+                    log.info("=========接口反馈============"+ returnData);
+                }
+            }catch (Exception e){
+                // 新增失败
+                isExist.append("<br>订单号:"+data.getOrderNo()+";刀具列表:"+ data.getList()+";"+ e.getMessage());
             }
-            // todo 发送远程地址,发送数据
-        } catch (Exception e) {
-            return R.fail(e.getMessage());
+
         }
+
+        if(isExist.length()>0){
+            return R.success(null,"部分成功:"+isExist.toString());
+        }
+
         log.info("定时================发送刀具需求给Eop系统结束================");
         return R.success();
     }

+ 3 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/centralToolMagazine/dto/ToolCheckDTO.java

@@ -10,6 +10,9 @@ public class ToolCheckDTO {
 
 
     private Long id;
+    private Long orderId;
+    private String orderNo;
+    private String orderName;
     private Long deviceId;
     private Long planId;
     private String deviceName;