zhang
18 小时以前 af5081bc0d0668d526a204076557a171097ddb8d
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java
@@ -17,6 +17,7 @@
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) {
@@ -288,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;
@@ -296,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$());
                        }
                    }
                }
@@ -331,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;
@@ -361,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());
@@ -403,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: