From d3f3d4b309cfb285fcbbc48b91c4046111c7e9cd Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 02 七月 2025 13:45:54 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  293 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 201 insertions(+), 92 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 8017176..7f2d211 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4,21 +4,18 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
-import com.core.common.R;
 import com.core.common.SpringUtils;
 import com.core.exception.CoolException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.zy.asrs.domain.enums.TaskStatusType;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.TaskOverToWms;
-import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam;
-import com.zy.asrs.entity.param.taskCreateParam;
-import com.zy.asrs.mapper.*;
+import com.zy.asrs.mapper.BasCrnErrorMapper;
+import com.zy.asrs.mapper.StaDescMapper;
+import com.zy.asrs.mapper.TaskWrkMapper;
+import com.zy.asrs.mapper.WrkMastMapper;
 import com.zy.asrs.service.*;
 import com.zy.asrs.utils.CommandUtils;
-import com.zy.asrs.utils.PostMesDataUtils;
 import com.zy.asrs.utils.Utils;
-import com.zy.common.service.CommonService;
 import com.zy.common.utils.HttpHandler;
 import com.zy.core.CrnThread;
 import com.zy.core.DevpThread;
@@ -34,7 +31,6 @@
 import com.zy.core.model.protocol.StaProtocol;
 import com.zy.core.properties.SlaveProperties;
 import com.zy.core.thread.BarcodeThread;
-import com.zy.core.thread.LedThread;
 import com.zy.core.thread.SiemensDevpThread;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
@@ -91,6 +87,13 @@
 
     @Autowired
     private ApiLogService apiLogService;
+//
+//    // 鍏ュ簱绔欑偣鍙峰搴旂殑鍫嗗灈鏈�
+//    private static final Map<Integer,Integer> staNoToCrnMap = new HashMap<Integer,Integer>(){{
+//        put(103,1); put(205,1); put(107,2); put(211,2);
+//        put(111,3); put(217,3); put(115,4); put(223,4);
+//        put(119,5); put(229,5); put(123,6); put(235,6);
+//    }};
 
     @Value("${wms.url}")
     private String wmsUrl;
@@ -194,11 +197,24 @@
                         if (Cools.isEmpty(taskWrk)){
                             continue;
                         }
-                        List<Integer> list = new ArrayList<>();
-                        list.add(taskWrk.getCrnNo());
+
                         //StaDesc staDesc1 = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no",inSta.getBackSta()));
-                        if (taskWrk.getTargetPoint() != null && taskWrk.getStartPoint() != null){
+                        boolean sign = true;
+                        if (inSta.getBarcode() == 7 || inSta.getBarcode() == 8){
+
+                        }else {
+                            if (taskWrk.getCrnNo() != inSta.getBarcode()){
+                                sign = false;
+                            }
+                        }
+                        if (taskWrk.getTargetPoint() != null && taskWrk.getStartPoint() != null && sign){
                             if ( taskWrk.getWrkNo() != null && taskWrk.getWrkNo().shortValue() == workNo ){
+                                continue;
+                            }
+                            if (taskWrk.getStatus() != 2){
+                                continue;
+                            }
+                            if (!staProtocol.isPakMk()){
                                 continue;
                             }
                             //鑾峰彇鍫嗗灈鏈虹珯鐐�
@@ -210,16 +226,29 @@
                                 staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
                                         .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 400).ge("stn_no", 250));
                             }
+
                             staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
                             staProtocol.setStaNo(staDesc.getCrnStn().shortValue());
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                             Thread.sleep(500);
                         }else {
                             //TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo());
                             toWmsDTO.setWarehouseId("1688469798893297665");
                             toWmsDTO.setContainerCode(barcode);
                             toWmsDTO.setApplyType("TUNNEL_LOCATION");
-                            toWmsDTO.setTaskTunnel(taskWrk.getCrnNo());
+                            List<Integer> list = new ArrayList<>();
+
+                            if (inSta.getBarcode() == 7 || inSta.getBarcode() == 8){
+                                toWmsDTO.setTaskTunnel(taskWrk.getCrnNo());
+                                list.add(taskWrk.getCrnNo());
+                            }else {
+                                toWmsDTO.setTaskTunnel(inSta.getBarcode());
+                                list.add(inSta.getBarcode());
+                            }
+
+
+
                             toWmsDTO.setCanInboundTunnels(list);
                             String response = null;
                             try {
@@ -248,9 +277,23 @@
                                 taskWrk.setOriginTargetPoint(getWmsDto.getTargetLocationCode());
                                 taskWrk.setTargetPoint(Utils.getWcsLocNo(getWmsDto.getTargetLocationCode()));
                                 taskWrk.setStartPoint(String.valueOf(inSta.getBackSta()));
+                                if (inSta.getBarcode() == 7 || inSta.getBarcode() == 8){
+
+                                }else {
+                                    taskWrk.setCrnNo(inSta.getBarcode());
+                                }
                                 if (!taskWrkService.updateById(taskWrk)){
                                     log.error("淇濆瓨wms搴撲綅鍙峰け璐�");
                                 }
+//                                try {
+//                                    // 鏇存柊搴撲綅涓哄叆搴撻绾�
+//                                    LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint());
+//                                    locMast.setLocSts("S");
+//                                    locMastService.updateById(locMast);
+//                                    log.info("-----鍏ュ簱鏇存柊搴撲綅鐘舵�佷负锛歋鎴愬姛----------"+ locMast.getLocNo());
+//                                } catch (Exception e){
+//                                    log.error("-----鍏ュ簱鏇存柊搴撲綅鐘舵�佷负锛歋寮傚父----------"+ e);
+//                                }
 
                             }else {
                                 log.error("wms閫氳澶辫触,"+jsonObject.get("msg"));
@@ -265,12 +308,17 @@
             }
         }
     }
+//
+//    private boolean getCrnByStaNo(Integer staNo) {
+//        int crn = staNoToCrnMap.get(staNo);
+//        BasCrnp crnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crn));
+//        return crnp.getCrnSts() == 0;
+//    }
 
 
     /**
      * 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯
      */
-    @Async
     public void crnStnToOutStn() {
         for (CrnSlave crnSlave : slaveProperties.getCrn()) {
             // 閬嶅巻鍫嗗灈鏈哄嚭搴撶珯
@@ -306,26 +354,42 @@
                                     && crnProtocol.forkPosType == CrnForkPosType.HOME) {
                                 // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
 
-                                //鍙栧嚭杈撻�佺嚎鍛戒护
-                                List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskWrk.getTaskNo());
-                                if (commandInfos.isEmpty()) {
-                                    continue;//鍛戒护绌�
-                                }
+                                try {
+                                    //鍙栧嚭杈撻�佺嚎鍛戒护
+                                    List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskWrk.getTaskNo());
+                                    if (commandInfos.isEmpty()) {
+                                        continue;//鍛戒护绌�
+                                    }
 
 //                                CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//鍙栧嚭鍛戒护鎶ユ枃
 //                                CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class);
-                                Integer commandStep = taskWrk.getCommandStep();
-                                CommandInfo commandInfo = commandInfos.get(commandStep);
-                                CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//鍙栧嚭鍛戒护鎶ユ枃
-                                //StaProtocol staProtocol1 = JSON.parseObject(commandInfo.getCommand(), StaProtocol.class);
-                                StaProtocol staProtocol1 = JSON.parseObject(commandPackage.getCommand().toString(), StaProtocol.class);
-                                if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol1))) {
-                                    log.error("杈撻�佺嚎鍛戒护涓嬫柟澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", taskWrk.getWrkNo());
-                                    continue;//鍛戒护涓嬪彂澶辫触
+                                    Integer commandStep = taskWrk.getCommandStep();
+                                    CommandInfo commandInfo = commandInfos.get(commandStep);
+                                    CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//鍙栧嚭鍛戒护鎶ユ枃
+                                    //StaProtocol staProtocol1 = JSON.parseObject(commandInfo.getCommand(), StaProtocol.class);
+                                    StaProtocol staProtocol1 = JSON.parseObject(commandPackage.getCommand().toString(), StaProtocol.class);
+                                    if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol1))) {
+                                        log.error("杈撻�佺嚎鍛戒护涓嬫柟澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", taskWrk.getWrkNo());
+                                        continue;//鍛戒护涓嬪彂澶辫触
+                                    }
+                                }catch (Exception e){
+                                    throw new CoolException("鍙栧嚭杈撻�佺嚎鍛戒护澶辫触");
                                 }
 
                                 // 澶嶄綅鍫嗗灈鏈�
                                 crnThread.setResetFlag(true);
+
+                                if (taskWrk.getIoType() == 1 || taskWrk.getIoType() == 3){
+                                    taskWrk.setWrkSts(4);
+                                } else if (taskWrk.getIoType() == 2) {
+                                    taskWrk.setWrkSts(14);
+                                }
+                                Date now = new Date();
+                                taskWrk.setCompleteTime(now);
+                                if (!taskWrkService.updateById(taskWrk)){
+                                    log.error(taskWrk.getTaskNo()+ " 鍫嗗灈鏈轰换鍔″畬鎴愶紝鏀瑰彉浠诲姟鐘舵�佸け璐�");
+                                }
+
 
                             }
                         }
@@ -429,16 +493,16 @@
                 log.error("杩涘叆淇敼宸ヤ綔妗f祦绋�");
                 Date now = new Date();
                 taskWrk.setWrkSts(3);
+                taskWrk.setExecuteTime(now);
                 taskWrk.setModiTime(now);
                 if (taskWrkMapper.updateById(taskWrk) == 0) {
                     log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", taskWrk.getWrkNo());
                 }
-                TaskWrk taskWrk2 = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue());
-
+                TaskWrk taskWrk2 = taskWrkService.selectByWrkNo(taskWrk.getWrkNo());
                 if (taskWrk2.getWrkSts() != 3){
                     continue;
                 }
-                log.error("杩涘叆淇敼宸ヤ綔妗f祦绋嬪畬鎴�,taskWrk=", JSON.toJSONString(taskWrk));
+                log.error("杩涘叆淇敼宸ヤ綔妗f祦绋嬪畬鎴�,taskWrk="+ taskWrk.getWrkNo());
 
 
                 //鍙栧嚭鍛戒护
@@ -454,15 +518,20 @@
                 if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) {
                     log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand));
                 } else {
-                    //寮�濮嬭繍琛�
-                    String response = CrnStartRunning(taskWrk);
-                    JSONObject jsonObject = JSON.parseObject(response);
-                    if (jsonObject.getInteger("code").equals(200)) {
+                    try {
+                        //寮�濮嬭繍琛�
+                        String response = CrnStartRunning(taskWrk);
+                        JSONObject jsonObject = JSON.parseObject(response);
+                        if (jsonObject.getInteger("code").equals(200)) {
 
-                    }else {
-                        log.error("鍏ュ簱寮�濮嬭繍琛岄�氳澶辫触,"+jsonObject.get("msg"));
+                        }else {
+                            log.error("鍏ュ簱寮�濮嬭繍琛寃ms鎶ラ敊,"+jsonObject.get("msg"));
 
+                        }
+                    }catch (Exception e) {
+                        log.error("鍏ュ簱寮�濮嬭繍琛寃ms鎶ラ敊");
                     }
+
                 }
 
 //                // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
@@ -551,6 +620,21 @@
 
                         // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
                         if (Utils.isDeepLoc(slaveProperties, taskWrk.getStartPoint())) {
+                            // 鑾峰彇娴呭簱浣嶏紝鐘舵�佷负S鐩存帴鍑猴紝鐘舵�佷负R锛屽垯鎵惧埌杩欎釜搴撲綅鐨勫伐浣滄。锛屾彁鍗囦紭鍏堢骇鍏堝嚭
+                            String shallowLoc = Utils.getShallowLoc(slaveProperties, taskWrk.getStartPoint());
+                            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", shallowLoc));
+                            if (locMast.getLocSts().equals("Z")) {
+                                List<TaskWrk> wrkMastList = taskWrkMapper.selectList(new EntityWrapper<TaskWrk>().eq("start_point", locMast.getLocNo()));
+                                if (!wrkMastList.isEmpty()) {
+                                    TaskWrk wrkMast = wrkMastList.get(0);
+                                    wrkMast.setIoPri(99);
+                                    taskWrkMapper.updateById(wrkMast);
+                                    log.warn("{}瀵瑰簲娴呭簱浣嶆湁璐э紝鎻愬崌{}搴撲綅浼樺厛绾�",taskWrk.getStartPoint(),wrkMast.getStartPoint());
+                                    continue;
+                                } else {
+                                    log.error("{}瀵瑰簲娴呭簱浣嶆湁璐э紝浣嗘病鏈夌Щ搴撲换鍔�",taskWrk.getStartPoint());
+                                }
+                            }
 
                             taskWrkMapper.selectPakOutIoType(taskWrk.getCrnNo());
 
@@ -607,19 +691,27 @@
                             // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
                             Date now = new Date();
                             taskWrk.setWrkSts(12);
+                            taskWrk.setExecuteTime(now);
                             taskWrk.setModiTime(now);
                             if (taskWrkMapper.updateById(taskWrk) == 0) {
                                 log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", taskWrk.getWrkNo());
-                            }
-                            //寮�濮嬭繍琛�
-                            String response = CrnStartRunning(taskWrk);
-                            JSONObject jsonObject = JSON.parseObject(response);
-                            if (jsonObject.getInteger("code").equals(200)) {
-
                             }else {
-                                log.error("鍑哄簱寮�濮嬭繍琛岄�氳澶辫触,"+jsonObject.get("msg"));
-
+                                log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓紒锛侊紝宸ヤ綔鍙�={}", taskWrk.getWrkNo());
                             }
+                            try {
+                                //寮�濮嬭繍琛�
+                                String response = CrnStartRunning(taskWrk);
+                                JSONObject jsonObject = JSON.parseObject(response);
+                                if (jsonObject.getInteger("code").equals(200)) {
+
+                                }else {
+                                    log.error("鍑哄簱寮�濮嬭繍琛寃ms澶辫触,"+jsonObject.get("msg"));
+
+                                }
+                            }catch (Exception e){
+                                log.error("鍑哄簱寮�濮嬭繍琛寃ms澶辫触,");
+                            }
+
                         }
 
                     }
@@ -639,7 +731,6 @@
                     .eq("wrk_sts",11)
                     .eq("io_type",3));
             for (TaskWrk taskWrk : taskWrks){
-
                 // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
                 if (Utils.isDeepLoc(slaveProperties, taskWrk.getStartPoint())) {
                     String shallowLocNo = Utils.getShallowLoc(slaveProperties, taskWrk.getStartPoint());
@@ -649,7 +740,7 @@
                     }
                 }
                 // 鍫嗗灈鏈烘帶鍒惰繃婊�
-                if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
+                if (!crnProtocol.getModeType().equals(CrnModeType.AUTO) || !crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
                     continue;
                 }
 
@@ -731,16 +822,23 @@
                     taskWrk.setModiTime(now);
                     if (taskWrkMapper.updateById(taskWrk) == 0) {
                         log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", taskWrk.getWrkNo());
+                    }else{
+                        log.info("绉诲簱浠诲姟涓嬪彂浠诲姟鎴愬姛锛屼慨鏀瑰伐浣滄。鐘舵�� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 锛屽伐浣滃彿={}", taskWrk.getWrkNo());
                     }
                     //寮�濮嬭繍琛�
-                    String response = CrnStartRunning(taskWrk);
-                    JSONObject jsonObject = JSON.parseObject(response);
-                    if (jsonObject.getInteger("code").equals(200)) {
+                    try{
+                        String response = CrnStartRunning(taskWrk);
+                        JSONObject jsonObject = JSON.parseObject(response);
+                        if (jsonObject.getInteger("code").equals(200)) {
 
-                    }else {
-                        log.error("绉诲簱浠诲姟寮�濮嬭繍琛岄�氳澶辫触,"+jsonObject.get("msg"));
-                        continue;
+                        }else {
+                            log.error("绉诲簱浠诲姟寮�濮嬭繍琛寃ms杩斿洖澶辫触,"+jsonObject.get("msg"));
+                            continue;
+                        }
+                    }catch (Exception e){
+                        log.error("绉诲簱浠诲姟寮�濮嬭繍琛岃姹倃ms鎶ラ敊,"+e.getMessage());
                     }
+
                     break;
                 }
                 return;
@@ -752,7 +850,7 @@
     /**
      * 鎵ц瀵瑰伐浣滄。鐨勫畬鎴愭搷浣�
      */
-    @Async
+
     public void storeFinished() {
         for (CrnSlave crn : slaveProperties.getCrn()) {
             // 鑾峰彇鍫嗗灈鏈轰俊鎭�
@@ -764,36 +862,47 @@
             if (crnProtocol.getTaskFinish() == 0 && crnProtocol.statusType == CrnStatusType.HANDLING_COMPLETED && crnProtocol.getTaskNo() != 0) {
                 //鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。
                 TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crn.getId(),crnProtocol.getTaskNo().intValue());
+
                 if (Cools.isEmpty(taskWrk)) {
 //                    log.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo());
                     continue;
                 }
-
+                log.info("鏀跺埌鐢宠瀹屾垚璇锋眰锛�" + taskWrk);
                 //鑾峰彇鎸囦护ID
-                Integer commandId = crnProtocol.getCommandId();
-                CommandInfo commandInfo = new CommandInfo();
-                if (Cools.isEmpty(commandId)){
-                    commandInfo = commandInfoService.selectOne(new EntityWrapper<CommandInfo>()
-                            .eq("wrk_no",crnProtocol.getTaskNo())
-                            .eq("device","Crn"));
-                }else {
-                    commandInfo = commandInfoService.selectById(commandId);
-                }
+//                Integer commandId = crnProtocol.getCommandId();
+//                CommandInfo commandInfo = new CommandInfo();
+//                if (Cools.isEmpty(commandId)){
+//                    commandInfo = commandInfoService.selectOne(new EntityWrapper<CommandInfo>()
+//                            .eq("wrk_no",crnProtocol.getTaskNo())
+//                            .eq("device","Crn"));
+//                }else {
+//                    commandInfo = commandInfoService.selectById(commandId);
+//                }
 
 
-                if (commandInfo == null) {
-                    //鎸囦护涓嶅瓨鍦�
-                    continue;
-                }
-                if (commandInfo.getCommandStatus() == 3){
-                    continue;
-                }
-                commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//鎸囦护瀹屾垚
-                commandInfo.setCompleteTime(new Date());//鎸囦护瀹屾垚鏃堕棿
-                if (commandInfoService.updateById(commandInfo)) {//淇敼鎴愬姛鍚庡浣嶅爢鍨涙満
+//                if (commandInfo == null) {
+//                    //鎸囦护涓嶅瓨鍦�
+//                    continue;
+//                }
+//                if (commandInfo.getCommandStatus() == 3){
+//                    continue;
+//                }
+//                commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//鎸囦护瀹屾垚
+//                commandInfo.setCompleteTime(new Date());//鎸囦护瀹屾垚鏃堕棿
+//                if (commandInfoService.updateById(commandInfo)) {//淇敼鎴愬姛鍚庡浣嶅爢鍨涙満
                     // 鍫嗗灈鏈哄浣�
                     crnThread.setResetFlag(true);
-                }
+                    if (taskWrk.getIoType() == 1 || taskWrk.getIoType() == 3){
+                        taskWrk.setWrkSts(4);
+                    } else if (taskWrk.getIoType() == 2) {
+                        taskWrk.setWrkSts(14);
+                    }
+                    Date now = new Date();
+                    taskWrk.setCompleteTime(now);
+                    if (!taskWrkService.updateById(taskWrk)){
+                        log.error(taskWrk.getTaskNo()+ " 鍫嗗灈鏈轰换鍔″畬鎴愶紝鏀瑰彉浠诲姟鐘舵�佸け璐�");
+                    }
+//                }
             }
         }
     }
@@ -845,7 +954,7 @@
     /**
      * 鍫嗗灈鏈哄紓甯镐俊鎭褰�
      */
-    @Async
+
     public void recCrnErr(){
         Date now = new Date();
         for (CrnSlave crn : slaveProperties.getCrn()) {
@@ -975,8 +1084,8 @@
         for (TaskWrk taskWrk : taskWrkService.selectReceive()) {
             try {
                 taskWrkService.distribute(taskWrk.getTaskNo(), 9527L);
-            } catch (CoolException e) {
-//                log.info(e.getMessage());
+            } catch (Exception e) {
+//                log.error("鑷姩娲惧彂浠诲姟寮傚父锛�"+e.getMessage()+"{" + taskWrk.toString());
             }
         }
     }
@@ -985,24 +1094,24 @@
     public synchronized void autoCompleteTask() {
         List<TaskWrk> taskWrks = taskWrkMapper.selectWorkingTask();
         for (TaskWrk taskWrk : taskWrks) {
-            //鑾峰彇鍛戒护闆嗗悎
-            List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskWrk.getTaskNo());
-            if (taskWrk.getCommandStep() < commandInfos.size()) {
-                continue;//褰撳墠姝ュ簭娌℃湁鍒拌揪鏈�鍚庝竴鏉″懡浠�
-            }
-
-            //鍒ゆ柇鏈鍛戒护鏄惁鎵ц瀹屾垚
-            if (!commandInfos.isEmpty()){
-                CommandInfo commandInfo = commandInfos.get(commandInfos.size() - 1);
-                if (commandInfo.getCommandStatus() != CommandStatusType.COMPLETE.id) {
-                    continue;//鎸囦护鏈畬鎴�
-                }
-            }
+//            //鑾峰彇鍛戒护闆嗗悎
+//            List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskWrk.getTaskNo());
+//            if (taskWrk.getCommandStep() < commandInfos.size()) {
+//                continue;//褰撳墠姝ュ簭娌℃湁鍒拌揪鏈�鍚庝竴鏉″懡浠�
+//            }
+//
+//            //鍒ゆ柇鏈鍛戒护鏄惁鎵ц瀹屾垚
+//            if (!commandInfos.isEmpty()){
+//                CommandInfo commandInfo = commandInfos.get(commandInfos.size() - 1);
+//                if (commandInfo.getCommandStatus() != CommandStatusType.COMPLETE.id) {
+//                    continue;//鎸囦护鏈畬鎴�
+//                }
+//            }
 
 
             Date now = new Date();
             //鎸囦护宸插畬鎴愶紝鏇存柊浠诲姟
-            if (taskWrk.getIoType() == 1) {
+            if (taskWrk.getIoType() == 1 && taskWrk.getWrkSts() == 5) {
                 //鍏ュ簱浠诲姟
 //                taskWrk.setWrkSts(4);//3.鍚婅溅鍏ュ簱涓� => 4.鍏ュ簱瀹屾垚
                 taskWrk.setStatus(TaskStatusType.OVER.id);
@@ -1016,7 +1125,7 @@
                 locMast.setModiTime(now);
                 locMast.setModiUser(9999L);
                 locMastService.updateById(locMast);
-            } else if (taskWrk.getIoType() == 2) {
+            } else if (taskWrk.getIoType() == 2 && taskWrk.getWrkSts() == 15) {
                 //鍑哄簱浠诲姟
 //                taskWrk.setWrkSts(14);//12.鍚婅溅鍑哄簱涓� => 14.鍑哄簱瀹屾垚
                 taskWrk.setStatus(TaskStatusType.OVER.id);
@@ -1030,7 +1139,7 @@
                 locMast.setModiTime(now);
                 locMast.setModiUser(9999L);
                 locMastService.updateById(locMast);
-            } else if (taskWrk.getIoType() == 3) {
+            } else if (taskWrk.getIoType() == 3 && taskWrk.getWrkSts() == 5) {
 
                 //鏇存柊璧峰搴撲綅鐘舵��
                 LocMast locMastStart = locMastService.selectByLocNo(taskWrk.getStartPoint());

--
Gitblit v1.9.1