#
Junjie
1 天以前 a2a5f1b9b70be48687ac7f84ebf6aa132c3721e9
src/main/java/com/zy/common/service/CommonService.java
@@ -13,6 +13,7 @@
import com.zy.common.utils.NavigateUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.service.WrkCommandRollbackService;
import com.zy.core.enums.*;
import com.zy.core.model.StationObjModel;
import lombok.extern.slf4j.Slf4j;
@@ -20,6 +21,7 @@
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Random;
@@ -44,6 +46,8 @@
    private RedisUtil redisUtil;
    @Autowired
    private BasOutStationAreaService basOutStationAreaService;
    @Autowired
    private WrkCommandRollbackService wrkCommandRollbackService;
    /**
     * 生成工作号
@@ -56,8 +60,8 @@
        }
        int workNo = wrkLastno.getWrkNo();
        int sNo = wrkLastno.getSNo();
        int eNo = wrkLastno.getENo();
        int sNo = wrkLastno.getsNo();
        int eNo = wrkLastno.geteNo();
        workNo = workNo>=eNo ? sNo : workNo+1;
        while (true) {
            WrkMast wrkMast = wrkMastService.selectByWorkNo(workNo);
@@ -149,6 +153,33 @@
        return true;
    }
    public boolean updateTaskPriorityAndBatchSeq(UpdateTaskPriorityAndBatchSeqParam param) {
        if (param == null) {
            throw new CoolException("参数不能为空");
        }
        if (Cools.isEmpty(param.getTaskNo())) {
            throw new CoolException("WMS任务号不能为空");
        }
        if (param.getTaskPri() == null && param.getBatchSeq() == null) {
            throw new CoolException("任务优先级和批次序号不能同时为空");
        }
        WrkMast wrkMast = wrkMastService.getOne(new QueryWrapper<WrkMast>().eq("wms_wrk_no", param.getTaskNo()));
        if (wrkMast == null) {
            throw new CoolException("任务不存在");
        }
        if (param.getTaskPri() != null) {
            wrkMast.setIoPri(param.getTaskPri().doubleValue());
        }
        if (param.getBatchSeq() != null) {
            wrkMast.setBatchSeq(param.getBatchSeq());
        }
        wrkMast.setModiTime(new Date());
        wrkMastService.updateById(wrkMast);
        return true;
    }
    public CancelTaskBatchResult cancelTaskBatch(CancelTaskBatchParam param) {
        if (param == null) {
            throw new CoolException("参数不能为空");
@@ -184,6 +215,10 @@
        result.setSuccessList(successList);
        result.setFailList(failList);
        return result;
    }
    public boolean manualRollbackTask(ManualRollbackTaskParam param) {
        return wrkCommandRollbackService.manualRollbackTask(param);
    }
    //移库任务
@@ -447,6 +482,48 @@
        return true;
    }
    public boolean createOutTaskBatch(CreateOutTaskBatchParam param) {
        if (param == null) {
            throw new CoolException("参数不能为空");
        }
        List<CreateOutTaskParam> taskList = param.getTaskList();
        if (taskList == null || taskList.isEmpty()) {
            throw new CoolException("任务列表不能为空");
        }
        List<CreateOutTaskParam> sortedTaskList = new ArrayList<>(taskList);
        sortedTaskList.sort(Comparator.nullsLast(Comparator
                .comparing(this::getSortableBatch, Comparator.nullsLast(String::compareTo))
                .thenComparing(this::getSortableBatchSeq, Comparator.nullsLast(Integer::compareTo))));
        for (CreateOutTaskParam createOutTaskParam : sortedTaskList) {
            if (createOutTaskParam == null) {
                throw new CoolException("任务参数不能为空");
            }
            createOutTask(createOutTaskParam);
        }
        return true;
    }
    private String getSortableBatch(CreateOutTaskParam param) {
        if (param == null) {
            return null;
        }
        String batch = param.getBatch();
        if (batch == null || batch.trim().isEmpty()) {
            return null;
        }
        return batch;
    }
    private Integer getSortableBatchSeq(CreateOutTaskParam param) {
        if (param == null) {
            return null;
        }
        return param.getBatchSeq();
    }
    public FindCrnNoResult findCrnNoByLocNo(String locNo) {
        List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
@@ -496,7 +573,7 @@
        Integer targetStationId = null;
        for (StationObjModel stationObjModel : stationList) {
            try {
                List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(sourceStationId, stationObjModel.getStationId());
                List<NavigateNode> navigateNodes = navigateUtils.calcReachablePathByStationId(sourceStationId, stationObjModel.getStationId());
                if(!navigateNodes.isEmpty()) {
                    targetStationId = stationObjModel.getStationId();
                    break;
@@ -528,7 +605,7 @@
        Integer finalSourceStationId = null;
        for (StationObjModel stationObjModel : stationList) {
            try {
                List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(stationObjModel.getStationId(), targetStationId);
                List<NavigateNode> navigateNodes = navigateUtils.calcReachablePathByStationId(stationObjModel.getStationId(), targetStationId);
                if(!navigateNodes.isEmpty()) {
                    finalSourceStationId = stationObjModel.getStationId();
                    break;