Forráskód Böngészése

fix:优化上有任务接受

wang.sq@aliyun.com 3 hete
szülő
commit
19e27424b3
11 módosított fájl, 269 hozzáadás és 106 törlés
  1. 4 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/ExternalDrawingMaterialsService.java
  2. 121 76
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/MesNoticeServiceImpl.java
  3. 7 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskServiceImpl.java
  4. 1 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/BomProcedureProductionresourceService.java
  5. 1 1
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/CacheRobotStrategy.java
  6. 64 6
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ExternalDrawingMaterialsController.java
  7. 37 20
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/MesController.java
  8. 2 0
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceMapper.java
  9. 2 0
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/ProductionresourceService.java
  10. 7 0
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java
  11. 23 0
      imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml

+ 4 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/ExternalDrawingMaterialsService.java

@@ -1,5 +1,8 @@
 package com.github.zuihou.business.externalApi.service;
 
+import com.github.zuihou.base.service.SuperService;
+import com.github.zuihou.business.externalApi.entity.ExternalDrawingMaterials;
+
 /**
  * @Project: imcs-admin-boot
  * @Package: com.github.zuihou.business.externalApi.service
@@ -7,5 +10,5 @@ package com.github.zuihou.business.externalApi.service;
  * @Time: 2025 - 08 - 19 18 : 10
  * @Description:
  */
-public interface ExternalDrawingMaterialsService {
+public interface ExternalDrawingMaterialsService extends SuperService<ExternalDrawingMaterials> {
 }

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

@@ -15,8 +15,10 @@ import com.github.zuihou.business.classSchedule.service.ScheduleUserDateService;
 import com.github.zuihou.business.externalApi.dao.MesNoticeLogMapper;
 import com.github.zuihou.business.externalApi.dao.MesNoticeMapper;
 import com.github.zuihou.business.externalApi.dto.MesNoticeUpdateDTO;
+import com.github.zuihou.business.externalApi.entity.ExternalDrawingMaterials;
 import com.github.zuihou.business.externalApi.entity.MesNotice;
 import com.github.zuihou.business.externalApi.entity.MesNoticeLog;
+import com.github.zuihou.business.externalApi.service.ExternalDrawingMaterialsService;
 import com.github.zuihou.business.operationManagementCenter.entity.Order;
 import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
@@ -24,6 +26,7 @@ import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
 import com.github.zuihou.business.operationManagementCenter.service.OrderQualityService;
 import com.github.zuihou.business.operationManagementCenter.service.OrderService;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
 import com.github.zuihou.business.productionReadyCenter.service.MesNoticeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.MesNoticeService;
 import com.github.zuihou.business.util.MsgUtil;
@@ -33,6 +36,8 @@ 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.exception.BizException;
+import com.github.zuihou.tenant.entity.Productionresource;
+import com.github.zuihou.tenant.service.ProductionresourceService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -62,6 +67,9 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
     @Autowired
     private ScheduleUserDateService scheduleUserDateService;
+    
+    @Autowired
+    private ProductionresourceService productionresourceService;
 
 
     @Value("${mes-work-schedule.enabled:false}")
@@ -91,7 +99,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
         // 新增到log日志界面
         MesNoticeLog mesNoticeLog = new MesNoticeLog();
-        BeanUtils.copyProperties(mesNotice1,mesNoticeLog);
+        BeanUtils.copyProperties(mesNotice1, mesNoticeLog);
         mesNoticeLog.setNoticeId(mesNotice1.getId());
         mesNoticeLog.setId(null);
         mesNoticeLogService.save(mesNoticeLog);
@@ -102,8 +110,10 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
     @Autowired
     private OrderQualityService orderQualityService;
+
     /**
      * 上游,上报零件加工完成报工
+     *
      * @param order
      * @return
      */
@@ -114,20 +124,20 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         List<MesNoticeLog> mesNoticeLogsList = new ArrayList<>();
         // 修改代办为完工
         MesNotice mesNotice = baseMapper.selectOne(new LbqWrapper<MesNotice>().eq(MesNotice::getBatchNo, order.getBatchNo()).eq(MesNotice::getBuType, "TASKDISTRIBUTE").ne(MesNotice::getStatus, "3").last("limit 1"));
-        if(mesNotice==null || mesNotice.getId() == null || mesNotice.getOrderNo() == null) return null;
+        if (mesNotice == null || mesNotice.getId() == null || mesNotice.getOrderNo() == null) return null;
         mesNotice.setStatus("3");
         mesNoticeList.add(mesNotice);
 
         // 修改上报MES的数据完工零件数据
-        MesNoticeLog mesNoticeLog = mesNoticeLogService.getOne(new LbqWrapper<MesNoticeLog>().eq(MesNoticeLog::getStatus,"4").eq(MesNoticeLog::getNoticeId, mesNotice.getId()).orderByDesc(MesNoticeLog::getCreateTime).last("limit 1"));
+        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"));
-        double plmenge =  Double.parseDouble(order.getProduceNum().toString());
-        if(mesNoticeRepost!=null) {
-            mesNoticeRepost.setStatus("5").setOrderInfo(String.valueOf(plmenge)).setWorkReport(mesNoticeLog!=null? String.format("%.1f",(plmenge - Double.parseDouble(mesNoticeLog.getOrderInfo()))): String.valueOf(plmenge));
-            if("QUALITYREPORT".equals(mesNoticeRepost.getApiType())){
+        double plmenge = Double.parseDouble(order.getProduceNum().toString());
+        if (mesNoticeRepost != null) {
+            mesNoticeRepost.setStatus("5").setOrderInfo(String.valueOf(plmenge)).setWorkReport(mesNoticeLog != null ? String.format("%.1f", (plmenge - Double.parseDouble(mesNoticeLog.getOrderInfo()))) : String.valueOf(plmenge));
+            if ("QUALITYREPORT".equals(mesNoticeRepost.getApiType())) {
                 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());
+                JSONArray jsonArray = JSONArray.parseArray(orderQuality == null ? null : orderQuality.getMeasuringReport());
                 dataInfo.put("resultList", jsonArray);
                 mesNoticeRepost.setAcceptPar(JSONObject.toJSONString(dataInfo));
             }
@@ -140,11 +150,11 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 //        if(count<=0){
 //            mesNoticeLogService.save(mesNoticeLog);
 //        }
-        if(mesNoticeList!=null && mesNoticeList.size()>0){
+        if (mesNoticeList != null && mesNoticeList.size() > 0) {
             for (MesNotice notice : mesNoticeList) {
-                if(notice.getId()==null){
+                if (notice.getId() == null) {
                     baseMapper.insert(notice);
-                }else  {
+                } else {
                     baseMapper.updateById(notice);
                 }
 
@@ -158,42 +168,62 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
             }
         }
 
-        if(!mesNoticeLogsList.isEmpty()){
+        if (!mesNoticeLogsList.isEmpty()) {
             mesNoticeLogService.saveBatchSomeColumn(mesNoticeLogsList);
         }
 
         return mesNotice;
     }
 
+    @Autowired
+    private ExternalDrawingMaterialsService externalDrawingMaterialsService;
+
     @Override
     public IPage<MesNotice> pageList(IPage page, Wrapper<MesNotice> queryWrapper) {
         BaseContextHandler.setTenant("0000");
-        return baseMapper.pageList(page, queryWrapper);
+        IPage<MesNotice> mesNoticeIPage = baseMapper.pageList(page, queryWrapper);
+        List<ExternalDrawingMaterials> listR = externalDrawingMaterialsService.list(Wraps.<ExternalDrawingMaterials>lbQ().eq(ExternalDrawingMaterials::getEnabled, 1));
+        Map<String, ExternalDrawingMaterials> map = listR == null ? null : listR.stream().collect(Collectors.toMap(ExternalDrawingMaterials::getExternalMeterialCode, t -> t));
+        if (!mesNoticeIPage.getRecords().isEmpty()) {
+            for (MesNotice record : mesNoticeIPage.getRecords()) {
+                try {
+                    JSONObject jsonObject = JSONObject.parseObject(record.getAcceptPar());
+                    jsonObject.getString("");
+                } catch (Exception ex) {
+                    log.info("转换出错,不做处理");
+                }
+
+            }
+
+        }
+
+
+        return mesNoticeIPage;
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String addNoticeMore(List<MesNotice> models, boolean isExist) {
         log.info("==============新增notice数据开始====================={}", JSONObject.toJSONString(models));
-        
+
         StringBuffer existMsg = new StringBuffer();
         List<MesNotice> needAddMesNotice = new ArrayList<>();
         List<MesNotice> needUpdateMesNotice = new ArrayList<>();
 
         for (MesNotice model : models) {
             MesNotice mesNotice = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getCheckPar, model.getCheckPar()));
-            if(mesNotice ==null){
+            if (mesNotice == null) {
                 MesNotice newModel = new MesNotice();
                 BeanUtils.copyProperties(model, newModel);
                 needAddMesNotice.add(newModel);
-            }else if (isExist){
-                if("1".equals(mesNotice.getStatus())) {
+            } else if (isExist) {
+                if ("1".equals(mesNotice.getStatus())) {
                     model.setId(mesNotice.getId());
-                    existMsg.append("\n此订单已存在:"+ model.getOrderNo());
-                }else {
-                    existMsg.append("\n此订单已存在:"+ model.getOrderNo());
+                    existMsg.append("\n此订单已存在:" + model.getOrderNo());
+                } else {
+                    existMsg.append("\n此订单已存在:" + model.getOrderNo());
                 }
-            }else {
+            } else {
                 // 以传输的数据为主
                 model.setId(mesNotice.getId());
                 BeanUtils.copyProperties(model, mesNotice);
@@ -204,12 +234,12 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         }
 
         // 新增
-        if(!needAddMesNotice.isEmpty()){
+        if (!needAddMesNotice.isEmpty()) {
             baseMapper.insertBatchSomeColumn(needAddMesNotice);
         }
 
         // 修改
-        if(!needUpdateMesNotice.isEmpty()){
+        if (!needUpdateMesNotice.isEmpty()) {
             for (MesNotice mesNotice : needUpdateMesNotice) {
                 baseMapper.updateAllById(mesNotice);
             }
@@ -218,7 +248,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         List<MesNoticeLog> mesNoticeLogs = new ArrayList<>();
         // 新增,修改,的数据添加日志
         needAddMesNotice.addAll(needUpdateMesNotice);
-        for (MesNotice  model: needAddMesNotice) {
+        for (MesNotice model : needAddMesNotice) {
             MesNoticeLog build = MesNoticeLog.builder().build();
             BeanUtils.copyProperties(model, build);
             build.setNoticeId(model.getId());
@@ -232,7 +262,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
         // 已存在只增加日志
         for (MesNotice model : models) {
-            if(model.getId()==null){
+            if (model.getId() == null) {
                 continue;
             }
             MesNoticeLog build = MesNoticeLog.builder().build();
@@ -247,7 +277,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
             mesNoticeLogs.add(build);
         }
 
-        if(!mesNoticeLogs.isEmpty()){
+        if (!mesNoticeLogs.isEmpty()) {
             mesNoticeLogMapper.insertBatchSomeColumn(mesNoticeLogs);
         }
 
@@ -265,23 +295,23 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         MesNotice mesNotice = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getCheckPar, model.getCheckPar()));
         if (!Objects.isNull(mesNotice)) {
             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() ==null ? "0": data.getOrderInfo() );
+            BigDecimal b1 = new BigDecimal(data.getOrderInfo() == null ? "0" : data.getOrderInfo());
 
-            if(model.getStatus().equals("0")) {
+            if (model.getStatus().equals("0")) {
                 //上料新增
                 BigDecimal b2 = new BigDecimal(0.2);
                 double val = b1.add(b2).doubleValue();
                 num = String.valueOf(val);
-            }else{
+            } else {
                 num = this.orderWorkStatistics(data.getId());
             }
             data.setStatus(model.getStatus()).setOrderInfo(num);
             data.setAcceptPar(model.getAcceptPar());
             baseMapper.updateAllById(data);
             model.setId(data.getId()).setOrderInfo(data.getOrderInfo());
-        }else {
+        } else {
             baseMapper.insert(model);
         }
 
@@ -289,12 +319,12 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         MesNoticeLog mesNoticeLog = new MesNoticeLog();
         BeanUtils.copyProperties(model, mesNoticeLog, "id");
         mesNoticeLog.setNoticeId(model.getId());
-        if(model.getApiType().equals("MESPROCESSREPORT")) {
+        if (model.getApiType().equals("MESPROCESSREPORT")) {
             //Long parentId = (this.mesWorkSchedule)?this.getCurrentScheduleId(model.getUserCode()) : 1L;
             //mesNoticeLog.setParentId(parentId);
             List<MesNoticeLog> mesNoticeLogList = mesNoticeLogService.list(new LbqWrapper<MesNoticeLog>().eq(MesNoticeLog::getNoticeId, model.getId()).eq(MesNoticeLog::getApiType, "MESPROCESSREPORT").orderByDesc(MesNoticeLog::getCreateTime).last("limit 1"));
             //首次报工和上班打卡报工和订单加工完成报工
-            if(mesNoticeLogList.size() == 0 || (mesNoticeLogList.size()==1 && mesNoticeLogList.get(0).getStatus().equals("4"))||(model.getOrderInfo() == String.valueOf(plmenge))){
+            if (mesNoticeLogList.size() == 0 || (mesNoticeLogList.size() == 1 && mesNoticeLogList.get(0).getStatus().equals("4")) || (model.getOrderInfo() == String.valueOf(plmenge))) {
                 isAutoPost = true;
             }
         }
@@ -308,7 +338,7 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
         this.addNotice(model, 1.0);
         // 调用接口发送需求
-        String returnData = msgUtil.httpForPost(model.getApiAddress(),model.getAcceptPar());
+        String returnData = msgUtil.httpForPost(model.getApiAddress(), model.getAcceptPar());
 
         return returnData;
     }
@@ -335,68 +365,83 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R processReport(List<Long> orderIds, TTask tTask, boolean onWork) {
+        BaseContextHandler.setTenant("0000");
+
         List<MesNotice> needAddMesNotices = new ArrayList<>();
         // 需要先增加日志
         List<Order> list = orderService.list(Wraps.<Order>lbQ().in(Order::getId, orderIds));
         // 完工数量
-        double gutmenge =0;
+        double gutmenge = 0;
 
         for (Order order : list) {
-            MesNotice mesNoticeSource = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getId, order.getNoticeId()));
-            MesNotice mesNotice = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getParentNoticeId, mesNoticeSource.getParentNoticeId()));
+            if (order.getNoticeId() == null) {
+                return R.success("检测到为自定义订单");
+            }
+            MesNotice mesNoticeSource = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getId, order.getNoticeId()).orderByDesc(MesNotice::getCreateTime).last("limit 1"));
+            if (mesNoticeSource == null) {
+                return R.success("检测到为自定义订单");
+            }
+            MesNotice mesNotice = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getParentNoticeId, mesNoticeSource.getId()).orderByDesc(MesNotice::getCreateTime).last("limit 1"));
             String needReplacement = null;
-            if(mesNotice==null || Objects.isNull(mesNotice)){
-                needReplacement = mesNotice.getLineCode()+"&"+mesNotice.getBuType()+"&"+mesNotice.getApiType();
+            if (mesNotice == null || Objects.isNull(mesNotice)) {
+                mesNotice = new MesNotice();
+                BeanUtils.copyProperties(mesNoticeSource, mesNotice);
+                needReplacement = mesNoticeSource.getLineCode() + "&" + mesNoticeSource.getBuType() + "&" + mesNoticeSource.getApiType();
                 gutmenge = 0;
-                mesNotice.setId(null).setBuType("TASKAPPLY").setSource(mesNoticeSource.getTargetSource()).setTargetSource(mesNoticeSource.getSource()).setOrderInfo(gutmenge+"");
-                if(mesNotice.getApiType().equals("MESTASK")){
+                mesNotice.setId(null).setBuType("TASKAPPLY").setSource(mesNoticeSource.getTargetSource()).setTargetSource(mesNoticeSource.getSource()).setOrderInfo(gutmenge + "");
+                if (mesNotice.getApiType().equals("MESTASK")) {
                     mesNotice.setApiType("MESPROCESSREPORT");
-                }else if(mesNotice.getApiType().equals("QUALITYTASK")){
+                } else if (mesNotice.getApiType().equals("QUALITYTASK")) {
                     mesNotice.setApiType("QUALITYREPORT");
                 }
-            }else {
+            } else {
                 gutmenge = Double.parseDouble(mesNotice.getOrderInfo());
             }
 
             // 计算完成度
-            if(tTask !=null){
+            if (tTask != null) {
                 List<TWorkpiece> tWorkpieces = workpieceService.list(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getOrderId, order.getId()).eq(TWorkpiece::getCompleteBatchNo, tTask.getCompleteBatchNo()));
-                if(!tWorkpieces.isEmpty()){
+                if (!tWorkpieces.isEmpty()) {
                     //计算完工数量
                     String number = this.orderWorkStatistics(order.getNoticeId());
 
                     BigDecimal newCompletionDegree = new BigDecimal(number);
-                    BigDecimal oldCompletionDegree = new BigDecimal( tWorkpieces.get(0).getCompleteProgress()==null? "0":  tWorkpieces.get(0).getCompleteProgress());
-                    BigDecimal latestCompletionDegree = new BigDecimal(mesNotice.getOrderInfo()==null? "0": mesNotice.getOrderInfo());
-                    BigDecimal xzCompletionDegree  = latestCompletionDegree.subtract(oldCompletionDegree).add(newCompletionDegree);
+                    BigDecimal oldCompletionDegree = new BigDecimal(tWorkpieces.get(0).getCompleteProgress() == null ? "0" : tWorkpieces.get(0).getCompleteProgress());
+                    BigDecimal latestCompletionDegree = new BigDecimal(mesNotice.getOrderInfo() == null ? "0" : mesNotice.getOrderInfo());
+                    BigDecimal xzCompletionDegree = latestCompletionDegree.subtract(oldCompletionDegree).add(newCompletionDegree);
 
                     gutmenge = xzCompletionDegree.doubleValue();
                 }
             }
 
-            // 计算是否完工
+            // 是否进行中
             boolean inProgress = true;
 
-            BigDecimal sumReport = new BigDecimal(mesNotice.getSumReport()==null?"0":mesNotice.getSumReport());
-            BigDecimal wrkReport = new BigDecimal(gutmenge).add(new BigDecimal(mesNotice.getOrderInfo()==null? "0": mesNotice.getOrderInfo()));
-            if(sumReport.compareTo(wrkReport) <= 0){
-                inProgress =false;
+            BigDecimal sumReport = new BigDecimal(mesNotice.getSumReport() == null ? "0" : mesNotice.getSumReport());
+            BigDecimal wrkReport = new BigDecimal(gutmenge).add(new BigDecimal(mesNotice.getOrderInfo() == null ? "0" : mesNotice.getOrderInfo()));
+            if (sumReport.compareTo(wrkReport) <= 0) {
+                inProgress = false;
                 mesNotice.setStatus("5");
-                if(autoPostEnable){
+                if (autoPostEnable) {
                     mesNotice.setStatus("3");
                 }
                 //把 来源的任务也给改成完成
                 mesNoticeSource.setStatus("3");
                 needAddMesNotices.add(mesNoticeSource);
-            }else {
-                mesNotice.setStatus(onWork?"0":"4");// 0进行中,4暂停
+            } else {
+                mesNotice.setStatus(onWork ? "0" : "4");// 0进行中,4暂停
             }
-            mesNotice.setWorkReport(gutmenge+"");
-            mesNotice.setOrderInfo(mesNotice.getOrderInfo()==null?"0" : mesNotice.getOrderInfo());
+            mesNotice.setWorkReport(gutmenge + "");
+            mesNotice.setOrderInfo(mesNotice.getOrderInfo() == null ? "0" : mesNotice.getOrderInfo());
 
             String url = null;
             JSONObject dataInfo = new JSONObject();
-            if(mesNotice.getApiType().equals("MESPROCESSREPORT")){
+            if (mesNotice.getApiType().equals("MESPROCESSREPORT")) {
+
+                Map map = new HashMap();
+                Object o = tTask == null ? map.put("orderId", order.getId()) : map.put("tTaskId", tTask.getId());
+                List<Productionresource> resourceByConditions = productionresourceService.getResourceByConditions(map);
+
                 url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.MESBG).toString());
                 JSONObject acceptPar = JSONObject.parseObject(mesNotice.getAcceptPar());
                 dataInfo.put("finr", "407");
@@ -404,52 +449,52 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
                 dataInfo.put("auidnr", acceptPar.getString("auidnr"));
                 dataInfo.put("afonr", acceptPar.getString("afonr"));
                 dataInfo.put("kpos", acceptPar.getString("kpos"));
-                dataInfo.put("kapaz", acceptPar.getString("kapaz")==null? "0" :  acceptPar.getString("kapaz").isEmpty());
+                dataInfo.put("kapaz", resourceByConditions.isEmpty() ? "0" : resourceByConditions.get(0).getProductionNo());
                 dataInfo.put("plmenge", acceptPar.getString("plmenge"));
                 dataInfo.put("gutmenge", gutmenge);
                 dataInfo.put("ausschuss", 0);
                 dataInfo.put("aussfinish", 0);
                 dataInfo.put("pnr", mesNotice.getUserCode());
-                dataInfo.put("status", inProgress ? "KS":"JS");
+                dataInfo.put("status", inProgress ? "KS" : "JS");
                 dataInfo.put("batchno", order.getBatchNo());
-            }else if ( mesNotice.getApiType().equals("QUALITYREPORT")) {
+            } else if (mesNotice.getApiType().equals("QUALITYREPORT")) {
                 url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS) ? "" : ((Map<String, String>) msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.POSTBACK420TASKCHECKDATA).toString());
                 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==null? null : orderQuality.getMeasuringReport());
+                JSONArray jsonArray = JSONArray.parseArray(orderQuality == null ? null : orderQuality.getMeasuringReport());
                 dataInfo.put("resultList", jsonArray);
             }
             mesNotice.setAcceptPar(dataInfo.toJSONString());
             mesNotice.setApiAddress(url);
 
 
-            if(!mesNotice.getCheckPar().isEmpty() && needReplacement!=null){
-                mesNotice.setCheckPar(mesNotice.getCheckPar().replace(needReplacement,mesNotice.getLineCode()+"&"+mesNotice.getBuType()+"&"+mesNotice.getApiType()));
+            if (!mesNotice.getCheckPar().isEmpty() && needReplacement != null) {
+                mesNotice.setCheckPar(mesNotice.getCheckPar().replace(needReplacement, mesNotice.getLineCode() + "&" + mesNotice.getBuType() + "&" + mesNotice.getApiType()));
             }
 
             needAddMesNotices.add(mesNotice);
         }
 
-        String s = this.addNoticeMore(needAddMesNotices,false);
+        String s = this.addNoticeMore(needAddMesNotices, false);
 
         StringBuffer errorInfo = new StringBuffer();
         for (MesNotice needAddMesNotice : needAddMesNotices) {
             String returnData = null;
             try {
-                BigDecimal wrkReport = new BigDecimal(needAddMesNotice.getWorkReport()==null? "0":needAddMesNotice.getWorkReport()).add(new BigDecimal(needAddMesNotice.getOrderInfo()==null? "0": needAddMesNotice.getOrderInfo()));
+                BigDecimal wrkReport = new BigDecimal(needAddMesNotice.getWorkReport() == null ? "0" : needAddMesNotice.getWorkReport()).add(new BigDecimal(needAddMesNotice.getOrderInfo() == null ? "0" : needAddMesNotice.getOrderInfo()));
                 if (autoPostEnable && !needAddMesNotice.getApiAddress().isEmpty() && (wrkReport.compareTo(BigDecimal.ZERO) == 0 || needAddMesNotice.getStatus().equals("3"))) {
                     returnData = msgUtil.httpForPost(needAddMesNotice.getApiAddress(), needAddMesNotice.getAcceptPar());
                 }
-            }catch (Exception ex){
+            } catch (Exception ex) {
                 ex.printStackTrace();
-                errorInfo.append("<br> 上报失败:"+needAddMesNotice.getOrderNo()+" ;原因:"+ ex.getMessage() +" ;返回结果:"+ returnData);
+                errorInfo.append("<br> 上报失败:" + needAddMesNotice.getOrderNo() + " ;原因:" + ex.getMessage() + " ;返回结果:" + returnData);
             }
         }
 
-        if(errorInfo == null || errorInfo.toString().isEmpty()){
+        if (errorInfo == null || errorInfo.toString().isEmpty()) {
             return R.success();
         }
-        return R.success(null, "上报失败,需要手动触发:"+errorInfo.toString());
+        return R.success(null, "上报失败,需要手动触发:" + errorInfo.toString());
     }
 
 
@@ -478,16 +523,16 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
 
     @Override
     public String orderWorkStatistics(Long mesNoticeId) {
-         Map map = baseMapper.orderWorkStatistics(mesNoticeId);
-         return map ==null? null :map.get("total").toString();
+        Map map = baseMapper.orderWorkStatistics(mesNoticeId);
+        return map == null ? null : map.get("total").toString();
     }
 
     @Override
-    public Long getCurrentScheduleId(String userCode){
-        User user  = userService.getOne(new LbqWrapper<User>().eq(User::getWorkDescribe, userCode).last("limit 1"));
+    public Long getCurrentScheduleId(String userCode) {
+        User user = userService.getOne(new LbqWrapper<User>().eq(User::getWorkDescribe, userCode).last("limit 1"));
         String date = DateUtil.dateToString0(new Date(), "yyyy-MM-dd");
         List<ScheduleUserDate> scheduleUserDateList = scheduleUserDateService.getPageList(new LbqWrapper<ScheduleUserDate>().eq(ScheduleUserDate::getUserId, user.getId()).eq(ScheduleUserDate::getDate, date).orderByDesc(ScheduleUserDate::getCreateTime).last("limit 1"));
-        ScheduleUserDate scheduleUserDate = scheduleUserDateList.size()==1? scheduleUserDateList.get(0) : null;
+        ScheduleUserDate scheduleUserDate = scheduleUserDateList.size() == 1 ? scheduleUserDateList.get(0) : null;
         return scheduleUserDate != null ? scheduleUserDate.getId() : null;
     }
 }

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

@@ -1280,7 +1280,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
             String cacheId = msgUtil.redis_get(id) == null ? "" : msgUtil.redis_get(id).toString();
             if (StringUtil.isNotEmpty(cacheId)) {//排除掉重复回调
                 log.info("上下料重复了======================" + cacheId);
-                return null;
+                throw new BizException("上下料重复了"+cacheId );
             }
             //把当前id存放入缓存
             msgUtil.redis_set(id, id, 1, TimeUnit.HOURS);
@@ -1357,7 +1357,12 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
                     //报工给上游系统,完成上料 开始
                     List<Long> ordersIds = new ArrayList<>();
                     ordersIds.add(order.getId());
-                    mesNoticeService.processReport(ordersIds, newtTask,true);
+                    try {
+                        mesNoticeService.processReport(ordersIds, newtTask,true);
+                    }catch (Exception ex){
+                        ex.printStackTrace();
+                        throw  new BizException("报工失败:"+ex.getMessage());
+                    }
                     //报工给上游系统,完成上料 结束
 
                     //节点完成业务

+ 1 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/BomProcedureProductionresourceService.java

@@ -5,6 +5,7 @@ import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProdu
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureVersion;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/CacheRobotStrategy.java

@@ -239,7 +239,7 @@ public class CacheRobotStrategy implements RobotStrategy {
         }
         //锁定暂存缓存位库位
         if(startStorge==null){
-            throw new RuntimeException("库位不满足没用查询到可用子盘");
+            throw new RuntimeException("库位不满足 or 没用查询到可用子盘");
         }
         startStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
         storgeService.lockStorge(startStorge, taskNode.getId());

+ 64 - 6
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ExternalDrawingMaterialsController.java

@@ -1,18 +1,29 @@
 package com.github.zuihou.business.controller.externalApi;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.github.zuihou.base.R;
 import com.github.zuihou.base.controller.SuperController;
-import com.github.zuihou.business.externalApi.dto.MesNoticePageDTO;
-import com.github.zuihou.business.externalApi.dto.MesNoticeSaveDTO;
-import com.github.zuihou.business.externalApi.dto.MesNoticeUpdateDTO;
-import com.github.zuihou.business.externalApi.entity.MesNotice;
-import com.github.zuihou.business.productionReadyCenter.service.MesNoticeService;
+import com.github.zuihou.business.centralToolMagazine.dto.ToolStorgePageDTO;
+import com.github.zuihou.business.cuttercategories.entity.CutterCategoriesGroup;
+import com.github.zuihou.business.externalApi.entity.ExternalDrawingMaterials;
+import com.github.zuihou.business.externalApi.service.ExternalDrawingMaterialsService;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+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;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * @Project: imcs-admin-boot
  * @Package: com.github.zuihou.business.controller.externalApi
@@ -27,7 +38,54 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/externalDrawingMaterials")
 @Api(value = "externalDrawingMaterials", tags = "外部物料与图号对照关系")
 @SysLog(enabled = true)
-public class ExternalDrawingMaterialsController {
+public class ExternalDrawingMaterialsController extends SuperController<ExternalDrawingMaterialsService, Long, ExternalDrawingMaterials, ExternalDrawingMaterials, ExternalDrawingMaterials, ExternalDrawingMaterials> {
+
+    @ApiOperation(value = "物料与图号关系集合", notes = "物料与图号关系集合")
+    @PostMapping("/drawingMaterialsList")
+    public R<List<ExternalDrawingMaterials>> drawingMaterialsList(@RequestBody ExternalDrawingMaterials  externalDrawingMaterials) {
+        log.info("================物料与图号关系集合开始================{}", JSONObject.toJSONString(externalDrawingMaterials));
+        LbqWrapper<ExternalDrawingMaterials> wrapper = Wraps.<ExternalDrawingMaterials>lbQ();
+        if(externalDrawingMaterials.getDrawNumber()!=null){
+            wrapper.like(ExternalDrawingMaterials::getDrawNumber, externalDrawingMaterials.getDrawNumber());
+        }
+        if(externalDrawingMaterials.getExternalMeterialCode()!=null){
+            wrapper.like(ExternalDrawingMaterials::getExternalMeterialCode, externalDrawingMaterials.getExternalMeterialCode());
+        }
+        List<ExternalDrawingMaterials> list = baseService.list(wrapper);
+        log.info("================物料与图号关系集合结束================");
+        return R.success(list);
+    }
+    @ApiOperation(value = "物料与图号关系集合", notes = "物料与图号关系集合")
+    @PostMapping("/getKeyIsMeterialCodeMaps")
+    public R getKeyIsMeterialCodeMaps(@RequestBody ExternalDrawingMaterials  externalDrawingMaterials) {
+        log.info("================物料与图号关系集合开始================{}", JSONObject.toJSONString(externalDrawingMaterials));
+        R<List<ExternalDrawingMaterials>> listR = this.drawingMaterialsList(externalDrawingMaterials);
+        Map<String, ExternalDrawingMaterials> map = listR.getData() == null ? null : listR.getData().stream().collect(Collectors.toMap(ExternalDrawingMaterials::getExternalMeterialCode, t -> t));
+
+        log.info("================物料与图号关系集合结束================");
+
+        return R.success(map);
+    }
+
+    @ApiOperation(value = "新增物料与图号关系", notes = "新增物料与图号关系")
+    @PostMapping("/addDrawingMaterials")
+    public R addDrawingMaterials(@RequestBody ExternalDrawingMaterials  externalDrawingMaterials) {
+        log.info("================新增物料与图号关系开始================{}", JSONObject.toJSONString(externalDrawingMaterials));
+
+        if(externalDrawingMaterials.getDrawNumber()==null || externalDrawingMaterials.getExternalMeterialCode() ==null){
+            return R.fail("图号不能为空");
+        }
+        int count = baseService.count(Wraps.<ExternalDrawingMaterials>lbQ().eq(ExternalDrawingMaterials::getExternalMeterialCode, externalDrawingMaterials.getExternalMeterialCode()));
+        if (count>0){
+            return R.fail("重复新增");
+        }
+        boolean save = baseService.save(externalDrawingMaterials);
+        log.info("================新增物料与图号关系结束================{}", save);
+        return R.success();
+    }
+
+
+
 
 
 }

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

@@ -12,8 +12,10 @@ import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.request.PageParams;
 import com.github.zuihou.business.centralToolMagazine.dto.ToolCheckDTO;
 import com.github.zuihou.business.externalApi.dto.*;
+import com.github.zuihou.business.externalApi.entity.ExternalDrawingMaterials;
 import com.github.zuihou.business.externalApi.entity.MesAttachment;
 import com.github.zuihou.business.externalApi.entity.MesNotice;
+import com.github.zuihou.business.externalApi.service.ExternalDrawingMaterialsService;
 import com.github.zuihou.business.externalApi.service.MesAttachmentService;
 import com.github.zuihou.business.operationManagementCenter.entity.Order;
 import com.github.zuihou.business.operationManagementCenter.entity.OrderProduct;
@@ -103,6 +105,9 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
     @Autowired
     private FileBiz fileBiz;
 
+    @Autowired
+    private ExternalDrawingMaterialsService externalDrawingMaterialsService;
+
     @Value("${zuihou.file.storage-path}")
     private String storagePath;
 
@@ -551,28 +556,29 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
     @PostMapping("/updateStatus")
     public R<MesNotice> updateStatus(@RequestBody MesNoticeUpdateDTO model) {
         BaseContextHandler.setTenant("0000");
-        MesNotice mesNotice = baseService.updateStatus(model);
+        MesNotice mesNotice = baseService.getOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getId, model.getId()));
         JSONObject ret = null;
         if (StringUtil.isNotEmpty(mesNotice.getApiAddress()) || StringUtil.isNotEmpty(mesNotice.getAcceptPar())) {
-            JSONArray jsonParam = new JSONArray();
-            jsonParam.add(mesNotice.getOrderNo());
-            if (mesNotice.getBuType().equals("TASKDISTRIBUTE")) {
-                //处理推送订单
-                this.distributeHandle(mesNotice.getOrderNo(), mesNotice.getLineCode());
-            } else {
-                String returnData = mesNotice.getAcceptPar();
-                ret = JSONObject.parseObject(returnData);
-                //本地代码处理
-                try {
+            List<MesNotice> mesNotices = new ArrayList<>();
+            try {
+                JSONArray jsonParam = new JSONArray();
+                jsonParam.add(mesNotice.getOrderNo());
+                if (mesNotice.getBuType().equals("TASKDISTRIBUTE")) {
+                    //处理推送订单
+                    this.distributeHandle(mesNotice.getOrderNo(), mesNotice.getLineCode());
+                    mesNotice.setStatus("0");
+                } else {
+                    String returnData = mesNotice.getAcceptPar();
+                    ret = JSONObject.parseObject(returnData);
+                    //本地代码处理
                     this.handle(ret, mesNotice.getApiType(), mesNotice.getLineCode(), mesNotice.getApiAddress());
-                    List<MesNotice> mesNotices = new ArrayList<>();
                     mesNotice.setStatus("3");
-                    mesNotices.add(mesNotice);
-                    baseService.addNoticeMore(mesNotices, false);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                    throw new BizException(e.getMessage());
                 }
+
+                mesNotices.add(mesNotice);
+                baseService.addNoticeMore(mesNotices, false);
+            }catch (Exception ex){
+                throw new BizException("处理失败:"+ex.getMessage());
             }
         } else {
             ret = new JSONObject();
@@ -1047,8 +1053,19 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
 //                    throw new BizException(list.isEmpty()?"缺少物料与图号对应关系": "物料编码不能对应多个图号");
 //                }
 //            }
-            if(drawingNo ==null || processNo ==null){
-                throw new BizException("图号与工序号不能为空");
+            if(processNo ==null || processNo.isEmpty()){
+                throw new BizException("工序号不能为空");
+            }
+            if(drawingNo ==null || drawingNo.isEmpty()){
+                if(idnr.isEmpty()){
+                    throw new BizException("物料编号不能为空");
+                }
+                ExternalDrawingMaterials drawingMaterials = externalDrawingMaterialsService.getOne(Wraps.<ExternalDrawingMaterials>lbQ().eq(ExternalDrawingMaterials::getExternalMeterialCode, idnr).last("limit 1"));
+                if(drawingMaterials ==null){
+                    throw new BizException("缺少物料与图号的对应关系");
+                }else {
+                    drawingNo = drawingMaterials.getDrawNumber();
+                }
             }
 
             // 数字话检测系统点单号需要拼接,才能保证唯一
@@ -1273,7 +1290,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
         //产品编码+ 密级编码 + 批次号 + 工艺版本
         String orderName = "MES_" + workOrder.getString("materialCode") + "_" + workOrder.getString("planSecretLevel").toUpperCase() + "_" + workOrder.getString("batchNo") + "_" + workOrder.getString("processRouteVersion");
         orderName = partName==null? (processName==null ? orderName :processName+"_"+processNo) : (partName +"_"+ processNo);
-        order.setCustId(0L).setOrderName(orderName).setZoneId(zone.getId()).setAuditStatus("0");
+        order.setCustId(0L).setOrderName(orderName).setZoneId(zone.getId()).setAuditStatus("0").setSingleRunFlag(1);
         orderService.save(order);
 
         OrderProduct orderProduct = OrderProduct.builder().build();

+ 2 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceMapper.java

@@ -72,4 +72,6 @@ public interface ProductionresourceMapper extends SuperMapper<Productionresource
     List<Productionresource> getByIndition(Map params);
 
     Productionresource findOneByPointId(String param);
+
+    List<Productionresource> getResourceByConditions(Map queryMap);
 }

+ 2 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/ProductionresourceService.java

@@ -119,4 +119,6 @@ public interface ProductionresourceService extends SuperCacheService<Productionr
 
     Productionresource findOneByPointId(String param);
 
+    List<Productionresource> getResourceByConditions(Map map);
+
 }

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

@@ -1140,4 +1140,11 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
     public Productionresource findOneByPointId(String param) {
         return  baseMapper.findOneByPointId(param);
     }
+
+    @Override
+    public List<Productionresource> getResourceByConditions(Map map) {
+        BaseContextHandler.setTenant("0000");
+
+        return  baseMapper.getResourceByConditions(map);
+    }
 }

+ 23 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml

@@ -109,4 +109,27 @@
         WHERE
         ippp.point_id = #{pointId}
     </select>
+
+
+    <select id="getResourceByConditions" resultType="com.github.zuihou.tenant.entity.Productionresource">
+        SELECT
+        DISTINCT c.*
+        FROM
+        imcs_base_331_0000.imcs_t_task a
+        INNER JOIN ( SELECT DISTINCT
+        complete_batch_no
+        FROM imcs_base_331_0000.imcs_t_task
+        WHERE 1=1
+        <if test="orderId !=null and orderId !=''">
+            AND order_id = #{orderId}
+        </if>
+        <if test="tTaskId !=null and tTaskId !=''">
+            AND id = #{tTaskId}
+        </if>
+        ) b ON b.complete_batch_no = a.complete_batch_no
+        LEFT JOIN imcs_base_331_0000.imcs_tenant_productionresource c ON a.resource_id = c.id
+        WHERE
+        mode_specification IS NOT NULL
+    </select>
+
 </mapper>