zhou zhou
昨天 1724f77c35022b643c28dd3e5547679a5edc2d49
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
@@ -24,7 +24,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import jakarta.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -264,6 +264,38 @@
            throw new CoolException("任务明细更新失败");
        }
        //判断任务明细是否全部完成
        List<TaskItem> allTaskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>()
                .eq(TaskItem::getTaskId, task.getId()));
        if (Cools.isEmpty(allTaskItems)) {
            throw new CoolException("未找到任务明细");
        }
        boolean allTaskItemsFinished = allTaskItems.stream().allMatch(item -> {
            BigDecimal workQty = BigDecimal.valueOf(Objects.isNull(item.getWorkQty()) ? 0D : item.getWorkQty());
            BigDecimal qty = BigDecimal.valueOf(Objects.isNull(item.getAnfme()) ? 0D : item.getAnfme());
            return workQty.compareTo(qty) == 0;
        });
        if (allTaskItemsFinished) {
            task.setTaskStatus(TaskStsType.COMPLETE_OUT.id)
                    .setUpdateBy(userId)
                    .setUpdateTime(new Date());
            if (!taskService.updateById(task)) {
                throw new CoolException("任务状态更新失败");
            }
            if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
                BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                        .eq(BasStation::getBarcode, param.getContainerNo()));
                if (!Cools.isEmpty(basStation)) {
                    basStation.setUseStatus(LocStsType.LOC_STS_TYPE_D.type);
                    basStation.setUpdateTime(new Date());
                    if (!basStationService.updateById(basStation)){
                        throw new CoolException("站点状态更新失败");
                    }
                }
            }
        }
        return R.ok();
    }
@@ -272,7 +304,10 @@
        if (Cools.isEmpty(param.getContainerNo())) {
            throw new CoolException("无容器号");
        }
        Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, param.getContainerNo()));
        Task task = taskService.getOne(new LambdaQueryWrapper<Task>()
                .eq(Task::getBarcode, param.getContainerNo())
                .eq(Task::getTaskStatus, TaskStsType.AWAIT.id)
        );
        if (null == task) {
            throw new CoolException("未找到任务");
        }
@@ -501,3 +536,4 @@
                item -> new BigDecimal(item.getAnfme().toString()).equals(new BigDecimal(item.getQty().toString())));
    }
}