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

fix:刀具任务优化

wang.sq@aliyun.com 3 hete
szülő
commit
91f8f38138

+ 28 - 0
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.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -12,6 +13,7 @@ import com.github.zuihou.business.externalApi.entity.MesNotice;
 import com.github.zuihou.business.externalApi.entity.MesNoticeLog;
 import com.github.zuihou.business.productionReadyCenter.service.MesNoticeLogService;
 import com.github.zuihou.business.productionReadyCenter.service.MesNoticeService;
+import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
@@ -20,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.stream.Collectors;
@@ -28,6 +31,9 @@ import java.util.stream.Collectors;
 @Service
 public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesNotice> implements MesNoticeService {
 
+    @Autowired
+    private MsgUtil msgUtil;
+
     @Autowired
     private MesNoticeLogService mesNoticeLogService;
 
@@ -82,6 +88,28 @@ public class MesNoticeServiceImpl extends SuperServiceImpl<MesNoticeMapper, MesN
         return true;
     }
 
+    @Override
+    @Transactional
+    public String sendCutterNeedToEop(MesNotice model) {
+
+        this.addNotice(model);
+        // 调用接口发送需求
+        String returnData = msgUtil.httpForPost(model.getApiAddress(),model.getAcceptPar());
+
+        return returnData;
+    }
+
+    @Override
+    public boolean acceptCutterNeedResult(JSONObject jsonObject) {
+
+        BaseContextHandler.setTenant("0000");
+        MesNotice mesNotice1 = baseMapper.selectOne(Wraps.<MesNotice>lbQ().eq(MesNotice::getOrderNo, jsonObject.getString("AUFNR")));
+        mesNotice1.setStatus("0");
+        baseMapper.updateById(mesNotice1);
+
+        return true;
+    }
+
     @Override
     public boolean checkExists(MesNotice model){
         Integer integer = baseMapper.selectCount(Wraps.<MesNotice>lbQ().eq(MesNotice::getOrderNo, model.getOrderNo()).eq(MesNotice::getBuType, model.getBuType()));

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

@@ -1,5 +1,6 @@
 package com.github.zuihou.business.productionReadyCenter.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
@@ -23,6 +24,12 @@ public interface MesNoticeService extends SuperService<MesNotice> {
     //批量新增
    boolean addNotice(MesNotice model);
 
+
+    String sendCutterNeedToEop(MesNotice model);
+
+
+    boolean acceptCutterNeedResult(JSONObject jsonObject);
+
    boolean checkExists(MesNotice model);
 
    boolean modify(MesNotice model);

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

@@ -47,6 +47,7 @@ import com.github.zuihou.file.biz.FileBiz;
 import com.github.zuihou.file.service.AttachmentService;
 import com.github.zuihou.log.annotation.SysLog;
 import com.github.zuihou.tenant.service.CodeRuleService;
+import com.mysql.cj.protocol.x.Notice;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -191,7 +192,7 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
     @ApiOperation(value = "刀具需求下发给EOP", notes = "刀具需求下发给EOP")
     @PostMapping("/externalApi/sendCutterNeedToEop")
     public R sendCutterNeedToEop(@RequestBody List<ToolCheckDTO> datas) {
-        log.info("定时================发送刀具需求给Eop系统开始================");
+        log.info("================发送刀具需求给Eop系统开始================");
         StringBuffer isExist = new StringBuffer();
         BaseContextHandler.setTenant("0000");
 
@@ -241,14 +242,14 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
             }
 
             MesNotice mesNotice = MesNotice.builder().orderNo(data.getOrderNo()).buType("TASKAPPLY").lineCode("407109")
-                    .status("1").apiType("CUTTERNEED").source("产线管控单元").targetSource("刀具系统(EOP)").apiAddress(url)
+                    .status("0").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);
+                String s = baseService.sendCutterNeedToEop(mesNotice);
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if(!jsonObject.get("code").equals(200)){
+                    isExist.append("<br>订单号:"+data.getOrderNo()+";刀具列表:"+ data.getList()+";"+ jsonObject.get("msg"));
                 }
             }catch (Exception e){
                 // 新增失败
@@ -261,25 +262,29 @@ public class MesController extends SuperController<MesNoticeService, Long, MesNo
             return R.success(null,"部分成功:"+isExist.toString());
         }
 
-        log.info("定时================发送刀具需求给Eop系统结束================");
+        log.info("================发送刀具需求给Eop系统结束================");
         return R.success();
     }
 
     @ApiOperation(value = "接受刀具分拣结果", notes = "接受刀具分拣结果")
-    @PostMapping("/externalApi/acceptSortingResult")
-    public R acceptSortingResult(@RequestBody CutterNeedDto data) {
-        log.info("定时================质检结果上报开始================");
+    @PostMapping("/externalApi/acceptCutterNeedResult")
+    public R acceptCutterNeedResult(@RequestBody JSONObject jsonObject) {
+        log.info("================质检结果上报开始================{}", jsonObject.toJSONString());
         // 根据代办的质量任务,查询是否已经检测完成,是,进行上报
         try {
-            MesNotice mesNotice = MesNotice.builder().build();
-            mesNotice.setSource("QUALITY");
-            baseService.QualityResultReport(mesNotice);
-        } catch (Exception e) {
-            log.error("质检结果上报失败:" + e);
 
+            boolean b = baseService.acceptCutterNeedResult(jsonObject);
+
+        }catch (NullPointerException nulle){
+            log.error("===================刀具分拣接口失败:" + nulle);
+            nulle.printStackTrace();
+            return R.fail("没查询到任务");
+        }catch (Exception e) {
+            log.error("===================刀具分拣接口失败:" + e);
+            e.printStackTrace();
             return R.fail(e.getMessage());
         }
-        log.info("定时================质检结果上报结束================");
+        log.info("================质检结果上报结束================");
         return R.success();
 
     }