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/TaskWrkServiceImpl.java | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/TaskWrkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/TaskWrkServiceImpl.java index 2393ee9..1ea1de4 100644 --- a/src/main/java/com/zy/asrs/service/impl/TaskWrkServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/TaskWrkServiceImpl.java @@ -1,6 +1,7 @@ package com.zy.asrs.service.impl; import com.alibaba.fastjson.JSON; +import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.domain.enums.TaskStatusType; import com.zy.asrs.domain.enums.WorkNoType; @@ -24,6 +25,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.Date; @@ -59,7 +61,7 @@ } @Override - @Transactional + @Transactional(propagation = Propagation.REQUIRES_NEW) public void distribute(String taskNo, Long userId) { TaskWrk taskWrk = this.selectByTaskNo(taskNo); if (taskWrk == null) { @@ -73,6 +75,9 @@ //鍒涘缓浠诲姟 if (taskWrk.getIoType() == 1) { //1.鍏ュ簱 + if (taskWrk.getStartPoint() == null || taskWrk.getTargetPoint() == null) { + throw new CoolException("鏈帴鏀跺埌璧风偣鍜岀粓鐐癸紝涓嶈繘琛屾淳鍙�"); + } startup(taskWrk, userId); }else if(taskWrk.getIoType() == 2){ //2.鍑哄簱 @@ -86,7 +91,7 @@ @Override public void startup(TaskWrk taskWrk, Long userId) { //鍏ュ簱浠诲姟娲惧彂 - StaDesc staDesc = staDescService.queryCrn(taskWrk.getIoType(), Integer.parseInt(taskWrk.getStartPoint())); + StaDesc staDesc = staDescService.queryCrn(taskWrk.getIoType(), Integer.parseInt(taskWrk.getStartPoint()), taskWrk.getCrnNo()); if (staDesc == null) { throw new CoolException("鍏ュ簱璺緞涓嶅瓨鍦�"); } @@ -117,7 +122,7 @@ crnCommand.setDestinationPosY(Utils.getLevShort(taskWrk.getTargetPoint())); // 鐩爣搴撲綅灞� crnCommand.setDestinationPosZ(Utils.getRowShort(taskWrk.getTargetPoint())); // 鐩爣搴撲綅鎺� crnCommand.setCommand((short)1); - if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { + if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand))) { log.error("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); throw new CoolException("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐�"); } @@ -126,7 +131,7 @@ @Override public void stockOut(TaskWrk taskWrk, Long userId) { //鍑哄簱浠诲姟娲惧彂 - StaDesc staDesc = staDescService.queryCrn(taskWrk.getIoType(), Integer.parseInt(taskWrk.getTargetPoint())); + StaDesc staDesc = staDescService.queryCrn(taskWrk.getIoType(), Integer.parseInt(taskWrk.getTargetPoint()), taskWrk.getCrnNo()); if (staDesc == null) { return;//涓嶅瓨鍦ㄨ矾寰� } @@ -157,7 +162,7 @@ crnCommand.setDestinationPosY(crnStn.getLev().shortValue()); // 鐩爣搴撲綅鍒� crnCommand.setDestinationPosZ(crnStn.getRow().shortValue()); // 鐩爣搴撲綅灞� crnCommand.setCommand((short)1); - if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { + if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand))) { log.error("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); throw new CoolException("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐�"); } @@ -167,7 +172,7 @@ StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone(); staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); staProtocol.setStaNo((short) Integer.parseInt(taskWrk.getTargetPoint())); - if (!CommandUtils.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) { + if (!CommandUtils.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(3, staProtocol))) { log.error("杈撻�佺嚎鍛戒护鐢熸垚澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); throw new CoolException("杈撻�佺嚎鍛戒护鐢熸垚澶辫触"); } @@ -176,19 +181,37 @@ @Override public void locMove(TaskWrk taskWrk, Long userId) { //搴撴牸绉昏浇浠诲姟娲惧彂 - StaDesc staDesc = staDescService.queryCrn(taskWrk.getIoType(), Integer.parseInt(taskWrk.getTargetPoint())); - if (staDesc == null) { - return;//涓嶅瓨鍦ㄨ矾寰� - } + if (Cools.isEmpty(taskWrk.getTargetPoint())){ + return; + } int workNo = commonService.getWorkNo(WorkNoType.OTHER.type);//鑾峰彇宸ヤ綔鍙� taskWrk.setWrkNo(workNo);//宸ヤ綔鍙� taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//娲惧彂鐘舵�� taskWrk.setAssignTime(new Date());//娲惧彂鏃堕棿 taskWrk.setWrkSts(11);//宸ヤ綔鐘舵�� 11.鐢熸垚鍑哄簱ID - taskWrk.setCrnNo(staDesc.getCrnNo());//鍫嗗灈鏈哄彿 + //taskWrk.setCrnNo(staDesc.getCrnNo());//鍫嗗灈鏈哄彿 taskWrk.setModiTime(new Date()); taskWrk.setModiUser(userId); updateById(taskWrk); + + + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(taskWrk.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo(taskWrk.getWrkNo().shortValue()); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 + crnCommand.setSourcePosZ(Utils.getRowShort(taskWrk.getStartPoint())); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosX(Utils.getBayShort(taskWrk.getStartPoint())); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosY(Utils.getLevShort(taskWrk.getStartPoint())); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosZ(Utils.getRowShort(taskWrk.getTargetPoint())); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosX(Utils.getBayShort(taskWrk.getTargetPoint())); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosY(Utils.getLevShort(taskWrk.getTargetPoint())); // 鐩爣搴撲綅灞� + crnCommand.setCommand((short) 1); + + if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand))) { + log.error("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); + throw new CoolException("鍫嗗灈鏈哄懡浠ょ敓鎴愬け璐�"); + } } @Override @@ -200,4 +223,9 @@ public int saveToHistory(String taskNo) { return this.baseMapper.saveToHistory(taskNo); } + + @Override + public List<TaskWrk> selectbyWrksts4() { + return this.baseMapper.selectbyWrksts4(); + } } -- Gitblit v1.9.1