ソースを参照

fix:修改mes任务接受数据

wang.sq@aliyun.com 1 ヶ月 前
コミット
9253ac9b94

+ 21 - 7
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/MesNoticeServiceImpl.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.externalApi.service.impl;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -17,6 +18,8 @@ import com.github.zuihou.business.externalApi.dto.MesNoticeUpdateDTO;
 import com.github.zuihou.business.externalApi.entity.MesNotice;
 import com.github.zuihou.business.externalApi.entity.MesNoticeLog;
 import com.github.zuihou.business.operationManagementCenter.entity.Order;
+import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
+import com.github.zuihou.business.operationManagementCenter.service.OrderQualityService;
 import com.github.zuihou.business.productionReadyCenter.service.MesNoticeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.MesNoticeService;
 import com.github.zuihou.business.util.MsgUtil;
@@ -93,6 +96,9 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         return mesNotice1;
     }
 
+
+    @Autowired
+    private OrderQualityService orderQualityService;
     /**
      * 零件加工完成报工
      * @param order
@@ -112,12 +118,16 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         // 修改上报MES的数据完工零件数据
         MesNoticeLog mesNoticeLog = mesNoticeLogService.getOne(new LbqWrapper<MesNoticeLog>().eq(MesNoticeLog::getStatus,"4").eq(MesNoticeLog::getNoticeId, mesNotice.getId()).orderByDesc(MesNoticeLog::getCreateTime).last("limit 1"));
         MesNotice mesNoticeRepost = baseMapper.selectOne(new LbqWrapper<MesNotice>().eq(MesNotice::getBatchNo, order.getBatchNo()).eq(MesNotice::getBuType, "TASKAPPLY").ne(MesNotice::getStatus, "3").last("limit 1"));
-        if(mesNoticeRepost == null){
-            mesNotice.getAcceptPar();
-
-        }
         double plmenge =  Double.parseDouble(order.getProduceNum().toString());
         mesNoticeRepost.setStatus("5").setOrderInfo(String.valueOf(plmenge)).setWorkReport(mesNoticeLog!=null? String.format("%.1f",(plmenge - Double.parseDouble(mesNoticeLog.getOrderInfo()))): String.valueOf(plmenge));
+        if(mesNoticeRepost.getApiType().equals("QUALITYREPORT")){
+            OrderQuality orderQuality = orderQualityService.getOne(new LbqWrapper<OrderQuality>().eq(OrderQuality::getOrderId, order.getId()).eq(OrderQuality::getMeasuringType, "1").last("limit 1"));
+            JSONObject dataInfo = JSONObject.parseObject(mesNoticeRepost.getAcceptPar());
+            JSONArray jsonArray = JSONArray.parseArray(orderQuality==null? null : orderQuality.getMeasuringReport());
+            dataInfo.put("resultList", jsonArray);
+            mesNoticeRepost.setAcceptPar(JSONObject.toJSONString(dataInfo));
+        }
+
         mesNoticeList.add(mesNoticeRepost);
 
         // 新增到log日志界面
@@ -137,6 +147,8 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
                 MesNoticeLog newMesNoticeLog = MesNoticeLog.builder().build();
                 BeanUtils.copyProperties(notice, newMesNoticeLog);
                 newMesNoticeLog.setNoticeId(notice.getId());
+                newMesNoticeLog.setCreateTime(null);
+                newMesNoticeLog.setUpdateTime(null);
                 newMesNoticeLog.setId(null);
                 mesNoticeLogsList.add(newMesNoticeLog);
             }
@@ -181,9 +193,10 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         BaseContextHandler.setTenant("0000");
         if (checkExists(model)) {
             MesNotice data = baseMapper.selectOne(new LbqWrapper<MesNotice>().eq(MesNotice::getOrderNo, model.getOrderNo()).ne(MesNotice::getStatus, "3").eq(MesNotice::getBuType, model.getBuType()).last("limit 1"));
-            if(data == null) throw new BizException("数据有误");
+            if(data == null) throw new BizException("数据有误,此任务已经为完成状态");
             String num = null;
-            BigDecimal b1 = new BigDecimal(data.getOrderInfo());
+            BigDecimal b1 = new BigDecimal(data.getOrderInfo() ==null ? "0": data.getOrderInfo() );
+
             if(model.getStatus().equals("0")) {
                 //上料新增
                 BigDecimal b2 = new BigDecimal(0.2);
@@ -193,6 +206,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
                 num = this.orderWorkStatistics(data.getId().toString());
             }
             data.setStatus(model.getStatus()).setOrderInfo(num);
+            data.setAcceptPar(model.getAcceptPar());
             baseMapper.updateAllById(data);
             model.setId(data.getId()).setOrderInfo(data.getOrderInfo());
         }else {
@@ -270,7 +284,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
     @Override
     public String orderWorkStatistics(String mesNoticeId) {
          Map map = baseMapper.orderWorkStatistics(mesNoticeId);
-         return map.get("total").toString();
+         return map ==null? null :map.get("total").toString();
     }
 
     @Override

+ 3 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskServiceImpl.java

@@ -1756,7 +1756,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
 
     @Override
     public void mesProcessReport(Order order, boolean bool) {
-        if(order.getSource().equals("2")){
+        if("2".equals(order.getSource())){
             MesNotice mesNotice = mesNoticeService.getOne(new LbqWrapper<MesNotice>().eq(MesNotice::getBatchNo, order.getBatchNo()).eq(MesNotice::getBuType, "TASKDISTRIBUTE").ne(MesNotice::getStatus, "3").last("limit 1"));
             if(null == mesNotice) return;
             //报工判断处理
@@ -1777,10 +1777,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
                 dataInfo.put("pnr", mesNotice.getUserCode());
                 dataInfo.put("status", status);
                 dataInfo.put("batchno", order.getBatchNo());
-            }else if(mesNotice.getApiType().equals("QUALITYTASK") && !bool){
+            }else if(mesNotice.getApiType().equals("QUALITYTASK") && bool == true){
                 dataInfo = JSONObject.parseObject(mesNotice.getAcceptPar());
                 OrderQuality orderQuality = orderQualityService.getOne(new LbqWrapper<OrderQuality>().eq(OrderQuality::getOrderId, order.getId()).eq(OrderQuality::getMeasuringType, "1").last("limit 1"));
-                JSONArray jsonArray = JSONArray.parseArray(orderQuality.getMeasuringReport());
+                JSONArray jsonArray = JSONArray.parseArray(orderQuality==null? null : orderQuality.getMeasuringReport());
                 dataInfo.put("resultList", jsonArray);
             }
             if(!dataInfo.isEmpty()) {

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

@@ -117,7 +117,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
         ThreeCoordinateDto threeCoordinateDto = JSONObject.parseObject(data, ThreeCoordinateDto.class);
 
 
-        MesNotice mesNotice = MesNotice.builder().orderNo(threeCoordinateDto.getTaskCode()+"&"+threeCoordinateDto.getProcessCode()+"&"+threeCoordinateDto.getPartOrder()).
+        MesNotice mesNotice = MesNotice.builder().orderNo(threeCoordinateDto.getTaskCode()+"_"+threeCoordinateDto.getProcessCode()+"_"+threeCoordinateDto.getPartOrder()).
                 buType("TASKDISTRIBUTE").
                 apiType("QUALITYTASK").
                 lineCode("407109").
@@ -130,6 +130,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
         try {
             boolean b = baseService.addNotice(mesNotice, 1.0);
         } catch (Exception e) {
+            e.printStackTrace();
             return R.fail(e.getMessage());
         }
 
@@ -139,13 +140,14 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
 
     @ApiOperation(value = "质检结果上报", notes = "质检结果上报")
     @PostMapping("/externalApi/qualityResultReport")
-    public R QualityResultReport(@RequestBody Map<String, String> params) {
+    public R QualityResultReport(@RequestBody JSONObject params) {
         log.info("================质检结果上报开始================");
         // 根据代办的质量任务,查询是否已经检测完成,是,进行上报
-        String instructionUrl = "http://192.168.11.37:8080/apis/Schedule/PostBack420TaskCheckData";
+        String url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.POSTBACK420TASKCHECKDATA).toString());
+
         ThreeCoordinateDto threeCoordinateDto = BeanUtil.mapToBean(params, ThreeCoordinateDto.class, true);
         String data = JSONObject.toJSONString(threeCoordinateDto);
-        MesNotice mesNotice = MesNotice.builder().orderNo(threeCoordinateDto.getTaskCode()).
+        MesNotice mesNotice = MesNotice.builder().orderNo(threeCoordinateDto.getTaskCode()+"_"+threeCoordinateDto.getProcessCode()+"_"+threeCoordinateDto.getPartOrder()).
                 buType("TASKAPPLY").
                 apiType("QUALITYREPORT").
                 lineCode("407109").
@@ -155,8 +157,8 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
                 batchNo(threeCoordinateDto.getBatchNo()).
                 source("产线管控单元").
                 targetSource("数字化检测系统").
-                apiAddress(instructionUrl).
-                acceptPar(data).build();
+                apiAddress(url).
+                acceptPar(JSONObject.toJSONString(params)).build();
         try {
             boolean b = baseService.addNotice(mesNotice, 1.0);
         } catch (Exception e) {
@@ -166,7 +168,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
         if (autoPostEnable) {
             mesNotice.setStatus("0");
             baseService.updateById(mesNotice);
-            String returnData = msgUtil.httpForPost(instructionUrl, data);
+            String returnData = msgUtil.httpForPost(url, data);
             return R.success(returnData);
         }
 
@@ -209,7 +211,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
 
 
         // 获取远程地址
-        String url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get("cutterApply").toString());
+        String url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.CUTTERAPPLY).toString());
 
         // 全部刀具信息
         Map<Long, CuttingTool> cutterAllMap = cuttingToolService.list().stream().collect(Collectors.toMap(t -> t.getCuttingToolNo(), t -> t));
@@ -369,7 +371,8 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
     @PostMapping("/externalApi/order/mesProcessReport")
     public R mesProcessReport(@RequestBody JSONObject params) {
         BaseContextHandler.setTenant("0000");
-        String instructionUrl = "http://192.168.11.40:11024/Mesbg";
+        String url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.MESBG).toString());
+
         if (!params.containsKey("auidnr") || !params.containsKey("status")) return R.fail("传参有误");
         Order order = orderService.getOne(new LbqWrapper<Order>().eq(Order::getSource, "2").eq(Order::getOrderNo, params.get("auidnr").toString()));
         BBom bom = bBomService.getOne(new LbqWrapper<BBom>().eq(BBom::getBatchNo, order.getBatchNo()).eq(BBom::getStatus, "1").eq(BBom::getSynFlag, "1").last("LIMIT 1"));
@@ -385,7 +388,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
         String data = jsonParam.toJSONString();
 
         MesNotice mesNotice = MesNotice.builder().orderNo(params.getString("auidnr")).userCode(params.getString("pnr")).batchNo(params.getString("batchno")).
-                buType("TASKAPPLY").lineCode("407109").status(status ? "1" : "0").source("产线管控单元").apiType("MESPROCESSREPORT").apiAddress(instructionUrl)
+                buType("TASKAPPLY").lineCode("407109").status(status ? "1" : "0").source("产线管控单元").apiType("MESPROCESSREPORT").apiAddress(url)
                 .targetSource("智能总控系统").acceptPar(data).orderInfo("0.2").build();
         boolean bool = false;
         try {
@@ -397,7 +400,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
             if (StringUtil.isNotEmpty(mesNotice.getWorkReport())) {
                 mesProcessReportDto.setGutmenge(Double.parseDouble(mesNotice.getWorkReport()));
             }
-            String returnData = msgUtil.httpForPost(instructionUrl, JSONObject.toJSONString(mesProcessReportDto));
+            String returnData = msgUtil.httpForPost(url, JSONObject.toJSONString(mesProcessReportDto));
             return R.success(returnData);
         }
         return R.success();
@@ -542,6 +545,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
                 try {
                     this.handle(ret, mesNotice.getApiType(), mesNotice.getLineCode(), mesNotice.getApiAddress());
                 } catch (Exception e) {
+                    e.printStackTrace();
                     throw new BizException(e.getMessage());
                 }
             }

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

@@ -74,9 +74,9 @@ public class ThreeDimensionalControl  extends SuperController<ThreeCoordinateSer
 
 
     @PostMapping(value = "/three-coordinate-test-results")
-    @SysLog("接受三坐标检测数据")
+    @SysLog("接受三坐标检测数据,三坐标结果上报")
     public R threeCoordinateTestResults(@RequestBody JSONObject json) throws Exception{
-        log.info("====================接受三坐标数据===================={}",json);
+        log.info("====================接受三坐标数据,三坐标结果上报===================={}",json);
 
         R r = threeCoordinateService.threeCoordinateTestResults(json);
 

+ 9 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/ParameterKey.java

@@ -90,6 +90,15 @@ public interface ParameterKey {
     // 反馈上有系统订单状态
     String EXTERNALAPI_MESORDER = "externalApiMesOrder";
 
+    // 331下发刀具需求给上游系统eop
+    String CUTTERAPPLY =  "cutterApply";
+    // 331质量结果上报给上游系统数字化检测系统
+    String POSTBACK420TASKCHECKDATA =  "PostBack420TaskCheckData";
+
+    // 331加工完成上报给上游mes系统
+    String MESBG =  "Mesbg";
+
+
     //Mes通知类型
     String MESNOTICETYPE = "mes_notice_type";