From af5081bc0d0668d526a204076557a171097ddb8d Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 05 二月 2026 14:02:59 +0800
Subject: [PATCH] Merge branch 'refs/heads/rcs_master' into ctu_conveyor
---
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java | 235 ++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 155 insertions(+), 80 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java
index 248ee81..2613bdb 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java
@@ -6,16 +6,18 @@
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.SnowflakeIdWorker;
import com.zy.acs.framework.exception.CoolException;
+import com.zy.acs.manager.common.constant.Constants;
import com.zy.acs.manager.common.domain.BaseParam;
import com.zy.acs.manager.common.domain.PageParam;
import com.zy.acs.manager.common.domain.PageResult;
import com.zy.acs.manager.common.exception.BusinessException;
-import com.zy.acs.manager.core.domain.Lane;
-import com.zy.acs.manager.core.service.LaneService;
+import com.zy.acs.manager.core.domain.LaneDto;
+import com.zy.acs.manager.core.service.LaneBuilder;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.*;
import com.zy.acs.manager.manager.mapper.TaskMapper;
import com.zy.acs.manager.manager.service.*;
+import com.zy.acs.manager.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -40,9 +42,17 @@
@Autowired
private SnowflakeIdWorker snowflakeIdWorker;
@Autowired
- private LaneService laneService;
+ private LaneBuilder laneBuilder;
@Autowired
private StaReserveService staReserveService;
+ @Autowired
+ private SegmentService segmentService;
+ @Autowired
+ private ActionService actionService;
+ @Autowired
+ private TravelService travelService;
+ @Autowired
+ private ConfigService configService;
@Override
public PageResult<Task> pageRel(PageParam<Task, BaseParam> pageParam) {
@@ -61,8 +71,16 @@
}
@Override
- public Task selectByUuid(String uuid) {
- return this.getOne(new LambdaQueryWrapper<Task>().eq(Task::getUuid, uuid));
+ public Task selectBySeqNum(Long busId, String seqNum) {
+ if (Cools.isEmpty(seqNum)) {
+ return null;
+ }
+ LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
+ if (null != busId) {
+ wrapper.eq(Task::getBusId, busId);
+ }
+ wrapper.eq(Task::getSeqNum, seqNum);
+ return this.getOne(wrapper.last(Constants.LIMIT_ONE));
}
@Override
@@ -93,44 +111,87 @@
@Override
@Transactional
- public Boolean complete(Long taskId, Long userId) {
+ public Boolean complete(Long taskId, Long userId, String from) {
Task task = this.getById(taskId);
if (null == task) {
return Boolean.FALSE;
}
- this.maintainLocSts(task, Boolean.TRUE);
-
+ Date now = new Date();
+ // stock
+ this.maintainLocAndStaHandler(task, Boolean.TRUE);
+ // task
task.setTaskSts(TaskStsType.COMPLETE.val());
- task.setUpdateTime(new Date());
+ task.setUpdateTime(now);
task.setUpdateBy(userId);
+ task.setMemo(from + " " + TaskStsType.COMPLETE);
if (!this.updateById(task)) {
throw new CoolException(BaseRes.ERROR);
}
+ // bus
busService.checkoutComplete(task.getBusId());
+ // segment
+ List<Segment> segments = segmentService.list(new LambdaQueryWrapper<Segment>().eq(Segment::getTaskId, taskId));
+ if (!Cools.isEmpty(segments)) {
+ for (Segment segment : segments) {
+ if (segment.getState().equals(SegmentStateType.FINISH.toString())) {
+ continue;
+ }
+ segment.setState(SegmentStateType.FINISH.toString());
+ segment.setUpdateTime(now);
+ segment.setUpdateBy(userId);
+ segment.setMemo(Constants.HANDLE);
+ if (!segmentService.updateById(segment)) {
+ throw new CoolException(BaseRes.ERROR);
+ }
+ }
+ // travel
+ travelService.checkFinish(segments.get(0).getTravelId());
+ }
return Boolean.TRUE;
}
@Override
@Transactional
- public Boolean cancel(Long taskId, Long userId) {
+ public Boolean cancel(Long taskId, Long userId, String from) {
Task task = this.getById(taskId);
if (null == task) {
return Boolean.FALSE;
}
- this.maintainLocSts(task, Boolean.FALSE);
-
+ Date now = new Date();
+ // stock
+ this.maintainLocAndStaHandler(task, Boolean.FALSE);
+ // task
task.setTaskSts(TaskStsType.CANCEL.val());
- task.setUpdateTime(new Date());
+ task.setUpdateTime(now);
task.setUpdateBy(userId);
+ task.setMemo(from + " " + TaskStsType.CANCEL);
if (!this.updateById(task)) {
throw new CoolException(BaseRes.ERROR);
}
busService.checkoutComplete(task.getBusId());
+ // segment
+ List<Segment> segments = segmentService.list(new LambdaQueryWrapper<Segment>().eq(Segment::getTaskId, taskId));
+ if (!Cools.isEmpty(segments)) {
+ for (Segment segment : segments) {
+ if (segment.getState().equals(SegmentStateType.FINISH.toString())) {
+ continue;
+ }
+ segment.setState(SegmentStateType.FINISH.toString());
+ segment.setUpdateTime(now);
+ segment.setUpdateBy(userId);
+ segment.setMemo(Constants.HANDLE);
+ if (!segmentService.updateById(segment)) {
+ throw new CoolException(BaseRes.ERROR);
+ }
+ }
+ // travel
+ travelService.checkFinish(segments.get(0).getTravelId());
+ }
return Boolean.TRUE;
}
@Override
- public Lane checkoutOriginLane(Task task) {
+ public LaneDto checkoutOriginLane(Task task) {
Long codeId = null;
TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());
switch (Objects.requireNonNull(typeType)) {
@@ -149,11 +210,11 @@
if (null == codeId) {
return null;
}
- return laneService.search(codeService.getCacheById(codeId).getData());
+ return laneBuilder.search(codeService.getCacheById(codeId).getData());
}
@Override
- public Lane checkoutDestinationLane(Task task) {
+ public LaneDto checkoutDestinationLane(Task task) {
Long codeId = null;
TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());
switch (Objects.requireNonNull(typeType)) {
@@ -172,7 +233,7 @@
if (null == codeId) {
return null;
}
- return laneService.search(codeService.getCacheById(codeId).getData());
+ return laneBuilder.search(codeService.getCacheById(codeId).getData());
}
@Override
@@ -230,6 +291,7 @@
if (!task.getTaskSts().equals(TaskStsType.COMPLETE.val())) {
return;
}
+ Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class);
Date now = new Date();
// loc status
Loc oriLoc = null;
@@ -238,31 +300,35 @@
Sta destSta = null;
switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) {
case LOC_TO_LOC:
- oriLoc = locService.getById(task.getOriLoc());
- if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) {
- oriLoc.setLocSts(LocStsType.IDLE.val());
- oriLoc.setUpdateTime(now);
- if (!locService.updateById(oriLoc)) {
- log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getOriLoc$());
+ if (maintainLocSts) {
+ oriLoc = locService.getById(task.getOriLoc());
+ if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) {
+ oriLoc.setLocSts(LocStsType.IDLE.val());
+ oriLoc.setUpdateTime(now);
+ if (!locService.updateById(oriLoc)) {
+ log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getOriLoc$());
+ }
}
- }
- destLoc = locService.getById(task.getDestLoc());
- if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) {
- destLoc.setLocSts(LocStsType.STOCK.val());
- destLoc.setUpdateTime(now);
- if (!locService.updateById(destLoc)) {
- log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getDestLoc$());
+ destLoc = locService.getById(task.getDestLoc());
+ if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) {
+ destLoc.setLocSts(LocStsType.STOCK.val());
+ destLoc.setUpdateTime(now);
+ if (!locService.updateById(destLoc)) {
+ log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getDestLoc$());
+ }
}
}
break;
case LOC_TO_STA:
- oriLoc = locService.getById(task.getOriLoc());
- if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) {
- oriLoc.setLocSts(LocStsType.IDLE.val());
- oriLoc.setUpdateTime(now);
- if (!locService.updateById(oriLoc)) {
- log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getOriLoc$());
+ if (maintainLocSts) {
+ oriLoc = locService.getById(task.getOriLoc());
+ if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) {
+ oriLoc.setLocSts(LocStsType.IDLE.val());
+ oriLoc.setUpdateTime(now);
+ if (!locService.updateById(oriLoc)) {
+ log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getOriLoc$());
+ }
}
}
@@ -273,12 +339,14 @@
oriSta = staService.getById(task.getOriSta());
staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT);
- destLoc = locService.getById(task.getDestLoc());
- if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) {
- destLoc.setLocSts(LocStsType.STOCK.val());
- destLoc.setUpdateTime(now);
- if (!locService.updateById(destLoc)) {
- log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getDestLoc$());
+ if (maintainLocSts) {
+ destLoc = locService.getById(task.getDestLoc());
+ if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) {
+ destLoc.setLocSts(LocStsType.STOCK.val());
+ destLoc.setUpdateTime(now);
+ if (!locService.updateById(destLoc)) {
+ log.error("Loc [{}] 搴撲綅淇敼鐘舵�佸け璐�", task.getDestLoc$());
+ }
}
}
break;
@@ -300,71 +368,78 @@
@Transactional
- public void maintainLocSts(Task task, Boolean complete) {
+ public void maintainLocAndStaHandler(Task task, Boolean complete) {
Loc oriLoc = null; Loc destLoc = null;
Sta oriSta = null; Sta destSta = null;
+ Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class);
Date now = new Date();
TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());
switch (Objects.requireNonNull(typeType)) {
case LOC_TO_LOC:
- oriLoc = locService.getById(task.getOriLoc());
- destLoc = locService.getById(task.getDestLoc());
+ if (maintainLocSts) {
+ oriLoc = locService.getById(task.getOriLoc());
+ destLoc = locService.getById(task.getDestLoc());
- oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val());
- oriLoc.setUpdateTime(now);
- if (!locService.updateById(oriLoc)) {
- throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
- }
+ oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val());
+ oriLoc.setUpdateTime(now);
+ if (!locService.updateById(oriLoc)) {
+ throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ }
- destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val());
- destLoc.setUpdateTime(now);
- if (!locService.updateById(destLoc)) {
- throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val());
+ destLoc.setUpdateTime(now);
+ if (!locService.updateById(destLoc)) {
+ throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ }
}
break;
case LOC_TO_STA:
- oriLoc = locService.getById(task.getOriLoc());
- oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val());
- oriLoc.setUpdateTime(now);
- if (!locService.updateById(oriLoc)) {
- throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ if (maintainLocSts) {
+ oriLoc = locService.getById(task.getOriLoc());
+ oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val());
+ oriLoc.setUpdateTime(now);
+ if (!locService.updateById(oriLoc)) {
+ throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ }
}
destSta = staService.getById(task.getDestSta());
- destSta.setStaSts(complete?StaStsType.STOCK.val():StaStsType.IDLE.val());
- destSta.setUpdateTime(now);
- if (!staService.updateById(destSta)) {
- throw new BusinessException("Sta [" + destSta.getStaNo() + "] 绔欑偣淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ if (complete) {
+ staReserveService.confirmStaReserve(destSta, task, 1, StaReserveType.IN);
+ } else {
+ staReserveService.cancelStaReserve(destSta, task, 1, StaReserveType.IN);
}
break;
case STA_TO_LOC:
oriSta = staService.getById(task.getOriSta());
- oriSta.setStaSts(complete?StaStsType.IDLE.val():StaStsType.STOCK.val());
- oriSta.setUpdateTime(now);
- if (!staService.updateById(oriSta)) {
- throw new BusinessException("Sta [" + oriSta.getStaNo() + "] 绔欑偣淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ if (complete) {
+ staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT);
+ } else {
+ staReserveService.cancelStaReserve(oriSta, task, 1, StaReserveType.OUT);
}
- destLoc = locService.getById(task.getDestLoc());
- destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val());
- destLoc.setUpdateTime(now);
- if (!locService.updateById(destLoc)) {
- throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ if (maintainLocSts) {
+ destLoc = locService.getById(task.getDestLoc());
+ destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val());
+ destLoc.setUpdateTime(now);
+ if (!locService.updateById(destLoc)) {
+ throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 搴撲綅淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ }
}
break;
case STA_TO_STA:
oriSta = staService.getById(task.getOriSta());
- oriSta.setStaSts(complete?StaStsType.IDLE.val():StaStsType.STOCK.val());
- oriSta.setUpdateTime(now);
- if (!staService.updateById(oriSta)) {
- throw new BusinessException("Sta [" + oriSta.getStaNo() + "] 绔欑偣淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ if (complete) {
+ staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT);
+ } else {
+ staReserveService.cancelStaReserve(oriSta, task, 1, StaReserveType.OUT);
}
destSta = staService.getById(task.getDestSta());
- destSta.setStaSts(complete?StaStsType.STOCK.val():StaStsType.IDLE.val());
- destSta.setUpdateTime(now);
- if (!staService.updateById(destSta)) {
- throw new BusinessException("Sta [" + destSta.getStaNo() + "] 绔欑偣淇敼鐘舵�佸け璐� 锛侊紒锛�");
+ if (complete) {
+ staReserveService.confirmStaReserve(destSta, task, 1, StaReserveType.IN);
+ } else {
+ staReserveService.cancelStaReserve(destSta, task, 1, StaReserveType.IN);
}
break;
case TO_CHARGE:
--
Gitblit v1.9.1