diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInTaskController.java b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInTaskController.java index d1dda0c..f7586ae 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInTaskController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsInTaskController.java @@ -17,6 +17,7 @@ import com.ktg.mes.wm.domain.WmsInTask; import com.ktg.mes.wm.service.IWmStorageAreaService; import com.ktg.mes.wm.service.IWmsInPlanDetailEntityService; import com.ktg.mes.wm.service.IWmsInTaskService; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -34,18 +35,14 @@ import java.util.stream.Stream; * @date 2024-11-01 */ @RestController +@RequiredArgsConstructor @RequestMapping("/wm/wmsInTask") public class WmsInTaskController extends BaseController { - @Autowired - private IWmsInTaskService wmsInTaskService; - @Autowired - private IMdItemService mdItemService; - @Autowired - private IBaseKnifeService baseKnifeService; - @Autowired - private IWmStorageAreaService wmStorageAreaService; - @Autowired - private IWmsInPlanDetailEntityService wmsInPlanDetailEntityService; + private final IWmsInTaskService wmsInTaskService; + private final IMdItemService mdItemService; + private final IBaseKnifeService baseKnifeService; + private final IWmStorageAreaService wmStorageAreaService; + private final IWmsInPlanDetailEntityService wmsInPlanDetailEntityService; /** * 查询入库任务列表 @@ -89,6 +86,18 @@ public class WmsInTaskController extends BaseController { return AjaxResult.success(wmsInTaskService.selectWmsInTaskById(id)); } + /** + * 根据料箱rfid查询入库任务信息 + */ + @GetMapping(value = "/open/box/{rfid}") + public AjaxResult getInfoByBox(@PathVariable("rfid") String rfid) { + WmsInTask wmsInTask = wmsInTaskService.selectWmsInTaskByBoxRfid(rfid); + if (wmsInTask == null) { + return AjaxResult.error("未查询到相关任务"); + } + return AjaxResult.success(wmsInTask); + } + /** * 新增入库任务 */ diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInTaskService.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInTaskService.java index e487ccc..43782fc 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInTaskService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInTaskService.java @@ -19,6 +19,14 @@ public interface IWmsInTaskService */ public WmsInTask selectWmsInTaskById(String id); + /** + * 查询入库任务 + * + * @param rfid 料箱 RFID + * @return 入库任务 + */ + public WmsInTask selectWmsInTaskByBoxRfid(String rfid); + /** * 查询入库任务列表 * diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInTaskServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInTaskServiceImpl.java index 7adcf0c..4ed6073 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInTaskServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInTaskServiceImpl.java @@ -1,17 +1,18 @@ package com.ktg.mes.wm.service.impl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; import com.ktg.common.utils.DateUtils; import com.ktg.generator.util.MultiModuleCodeGenerator; +import com.ktg.mes.md.domain.BaseKnife; import com.ktg.mes.md.domain.MdItem; import com.ktg.mes.md.mapper.MdItemMapper; import com.ktg.mes.md.service.IMdItemService; +import com.ktg.mes.wm.domain.UcmCtBase; import com.ktg.mes.wm.domain.WmStorageArea; import com.ktg.mes.wm.domain.WmsInPlanDetailEntity; import com.ktg.mes.wm.mapper.WmStorageAreaMapper; +import com.ktg.mes.wm.service.IUcmCtBaseService; import com.ktg.mes.wm.service.IWmsInPlanDetailEntityService; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; @@ -33,6 +34,7 @@ public class WmsInTaskServiceImpl implements IWmsInTaskService { private final MdItemMapper mdItemMapper; private final IWmsInPlanDetailEntityService wmsInPlanDetailEntityService; private final WmStorageAreaMapper wmStorageAreaMapper; + private final IUcmCtBaseService ucmCtBaseService; /** * 查询入库任务 @@ -45,6 +47,50 @@ public class WmsInTaskServiceImpl implements IWmsInTaskService { return wmsInTaskMapper.selectWmsInTaskById(id); } + /** + * 查询入库任务 + * + * @param rfid 料箱 RFID + * @return 入库任务 + */ + @Override + public WmsInTask selectWmsInTaskByBoxRfid(String rfid) { + List wmsInTaskList = new ArrayList<>(); + + UcmCtBase ucmCtBase = ucmCtBaseService.selectUcmCtBaseByCode(rfid); + if (ucmCtBase == null) { + return null; + } + for (BaseKnife baseKnife : ucmCtBase.getBaseKnifeList()) { + WmsInPlanDetailEntity wmsInPlanDetailEntityQuery = new WmsInPlanDetailEntity(); + wmsInPlanDetailEntityQuery.setRfid(baseKnife.getRfid()); + + // 查询所有符合条件的计划明细 + List planDetailEntities = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery); + + // 遍历所有明细,查询相应的WmsInTask + for (WmsInPlanDetailEntity entity : planDetailEntities) { + WmsInTask wmsInTaskQuery = new WmsInTask(); + wmsInTaskQuery.setDetailInId(entity.getPlanDetailsId()); + wmsInTaskQuery.setPlanInId(entity.getPlanId()); + wmsInTaskQuery.setPlanInStatus("0"); + + // 查询并加入符合条件的任务 + List tasks = selectWmsInTaskList(wmsInTaskQuery); + if (tasks != null && !tasks.isEmpty()) { + wmsInTaskList.addAll(tasks); + } + } + } + + // 返回第一个符合条件的任务 + if (!wmsInTaskList.isEmpty()) { + return wmsInTaskList.get(0); + } + return null; + } + + /** * 查询入库任务列表 *