#
vincentlu
昨天 0bee2b3f40638460f3fa961792d43570e4b46911
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java
@@ -11,12 +11,13 @@
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.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;
@@ -50,6 +51,8 @@
    private ActionService actionService;
    @Autowired
    private TravelService travelService;
    @Autowired
    private ConfigService configService;
    @Override
    public PageResult<Task> pageRel(PageParam<Task, BaseParam> pageParam) {
@@ -68,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
@@ -100,7 +111,7 @@
    @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;
@@ -112,7 +123,7 @@
        task.setTaskSts(TaskStsType.COMPLETE.val());
        task.setUpdateTime(now);
        task.setUpdateBy(userId);
        task.setMemo(Constants.HANDLE + " " + TaskStsType.COMPLETE);
        task.setMemo(from + " " + TaskStsType.COMPLETE);
        if (!this.updateById(task)) {
            throw new CoolException(BaseRes.ERROR);
        }
@@ -141,7 +152,7 @@
    @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;
@@ -153,7 +164,7 @@
        task.setTaskSts(TaskStsType.CANCEL.val());
        task.setUpdateTime(now);
        task.setUpdateBy(userId);
        task.setMemo(Constants.HANDLE + " " + TaskStsType.CANCEL);
        task.setMemo(from + " " + TaskStsType.CANCEL);
        if (!this.updateById(task)) {
            throw new CoolException(BaseRes.ERROR);
        }
@@ -180,7 +191,7 @@
    }
    @Override
    public Lane checkoutOriginLane(Task task) {
    public LaneDto checkoutOriginLane(Task task) {
        Long codeId = null;
        TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());
        switch (Objects.requireNonNull(typeType)) {
@@ -203,7 +214,7 @@
    }
    @Override
    public Lane checkoutDestinationLane(Task task) {
    public LaneDto checkoutDestinationLane(Task task) {
        Long codeId = null;
        TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());
        switch (Objects.requireNonNull(typeType)) {
@@ -280,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;
@@ -288,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$());
                        }
                    }
                }
@@ -323,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;
@@ -353,31 +371,36 @@
    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());
@@ -395,11 +418,13 @@
                    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: