zc
23 小时以前 adb83050b74c2d7fa1845f18e016ef3b18496543
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -23,6 +23,7 @@
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import com.vincent.rsf.server.system.utils.SystemAuthUtils;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +35,7 @@
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service("taskService")
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
@@ -91,6 +93,8 @@
    private CheckDiffService checkDiffService;
    @Autowired
    private CheckDiffItemService checkDiffItemService;
    @Autowired
    private BasContainerService basContainerService;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -303,8 +307,10 @@
            throw new CoolException("请检查组拖状态是否完成!!");
        }
        waitPakins.forEach(pakin -> {
            BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
                    .eq(BasContainer::getCode, pakin.getBarcode()));
            /**获取库位*/
            String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId());
            String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType());
            if (Cools.isEmpty(targetLoc)) {
                throw new CoolException("该站点对应库区未找到库位");
            }
@@ -345,6 +351,18 @@
            if (!this.save(task)) {
                throw new CoolException("任务保存失败!!");
            }
            BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                    .eq(BasStation::getStationName, deviceSite.getSite()));
            if (Objects.isNull(station) || !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                throw new CoolException("站点不存在或站点不处于空库状态!!");
            }
            station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
            if (!basStationService.updateById(station)) {
                 throw new CoolException("站点状态更新失败!!");
             }
            if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
                throw new CoolException("库位预约失败!!");
@@ -406,22 +424,24 @@
     */
    @Synchronized
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void complateInTask(List<Task> tasks) throws Exception {
        Long loginUserId = SystemAuthUtils.getLoginUserId();
        for (Task task : tasks) {
            if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                //1.入库
                complateInstock(task, loginUserId);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                //53.拣料再入库
                //57.盘点再入库
                pickComplateInStock(task, loginUserId);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                //移库
                moveInStock(task, loginUserId);
            try {
                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                    //1.入库
                    complateInstock(task, loginUserId);
                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                    //53.拣料再入库
                    //57.盘点再入库
                    pickComplateInStock(task, loginUserId);
                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                    //移库
                    moveInStock(task, loginUserId);
                }
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
            }
        }
    }
@@ -590,7 +610,7 @@
                //更新库位明细
                saveLocItem(taskItems, task.getId(), loginUserId);
            } catch (Exception e) {
                throw new CoolException("库位明细更新失败!!");
                throw new CoolException("任务号:" + task.getTaskCode() +  "库位明细更新失败!!");
            }
            if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) {
@@ -635,7 +655,6 @@
     */
    @Synchronized
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void completeTask(List<Task> tasks) {
        Long loginUserId = SystemAuthUtils.getLoginUserId();
        for (Task task : tasks) {
@@ -643,7 +662,8 @@
            try {
                complateOutStock(task, loginUserId);
            } catch (Exception e) {
                throw new CoolException(e.getMessage());
                log.error(e.getMessage(), e);
//                throw new CoolException(e.getMessage());
            }
        }
    }
@@ -979,7 +999,8 @@
        if (Objects.isNull(locInfo)) {
            throw new CoolException("获取库位失败!!");
        }
        task.setTargLoc(locInfo.getLocNo());
        task.setTargLoc(locInfo.getLocNo())
                .setOrgSite(task.getTargSite());
        if (!this.updateById(task)) {
            throw new CoolException("任务状态更新失败!!");