diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java index fe69dac..2973185 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java @@ -152,4 +152,62 @@ public class WcsIntegrationController { return R.error(e.getMessage()); } } + + // ==================== 运输任务相关接口 - AI制作 ==================== + + /** + * 获取AGV站点列表 - AI制作 + */ + @PostMapping(value="/getAgvStations") + @ResponseBody + public R getAgvStations(@RequestBody Map params) { + try { + List> stations = wcsIntegrationService.getAgvStations(params); + return R.ok().put("stations", stations); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } + + /** + * 根据起点站点获取可达目标站点 - AI制作 + */ + @PostMapping(value="/getTargetStations") + @ResponseBody + public R getTargetStations(@RequestBody Map params) { + try { + List> targets = wcsIntegrationService.getTargetStations(params); + return R.ok().put("targets", targets); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } + + /** + * 创建栈板运输任务 - AI制作 + */ + @PostMapping(value="/createPalletTransportTask") + @ResponseBody + public R createPalletTransportTask(@RequestBody Map params) { + try { + wcsIntegrationService.createPalletTransportTask(params); + return R.ok(); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } + + /** + * Call栈板到指定站点 - AI制作 + */ + @PostMapping(value="/callPalletToStation") + @ResponseBody + public R callPalletToStation(@RequestBody Map params) { + try { + wcsIntegrationService.callPalletToStation(params); + return R.ok(); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java index 9223d7f..eac6192 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java @@ -100,4 +100,21 @@ public interface WcsIntegrationMapper { * 检查栈板是否正在被调用 - AI制作 */ String checkPalletCallingFlag(@Param("site") String site, @Param("palletId") String palletId); + + // ==================== 运输任务相关方法 - AI制作 ==================== + + /** + * 获取AGV站点列表 - AI制作 + */ + List> getAgvStations(); + + /** + * 根据起点站点获取可达目标站点 - AI制作 + */ + List> getTargetStationsByStart(@Param("startStation") String startStation); + + /** + * 插入单个运输任务 - AI制作 + */ + void insertTransportTask(WmsTransportTask task); } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java index d82eec7..e11d6a8 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java @@ -47,4 +47,26 @@ public interface WcsIntegrationService { * 更新栈板明细位置 - AI制作 */ void updatePalletDetailPosition(Map params) throws Exception; + + // ==================== 运输任务相关方法 - AI制作 ==================== + + /** + * 获取AGV站点列表 - AI制作 + */ + List> getAgvStations(Map params) throws Exception; + + /** + * 根据起点站点获取可达目标站点 - AI制作 + */ + List> getTargetStations(Map params) throws Exception; + + /** + * 创建栈板运输任务 - AI制作 + */ + void createPalletTransportTask(Map params) throws Exception; + + /** + * Call栈板到指定站点 - AI制作 + */ + void callPalletToStation(Map params) throws Exception; } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java index 260410e..b8e833a 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java @@ -403,4 +403,102 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); wcsIntegrationMapper.updatePalletDetailPosition(site, palletId, serialNo, newPosition, newLayer, username); } + + // ==================== 运输任务相关方法实现 - AI制作 ==================== + + @Override + public List> getAgvStations(Map params) throws Exception { + return wcsIntegrationMapper.getAgvStations(); + } + + @Override + public List> getTargetStations(Map params) throws Exception { + String startStation = (String) params.get("startStation"); + if (!StringUtils.hasText(startStation)) { + throw new Exception("起点站点不能为空"); + } + return wcsIntegrationMapper.getTargetStationsByStart(startStation); + } + + @Override + @Transactional + public void createPalletTransportTask(Map params) throws Exception { + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + String startStation = (String) params.get("startStation"); + String endStation = (String) params.get("endStation"); + + if (!StringUtils.hasText(site) || !StringUtils.hasText(palletId) || + !StringUtils.hasText(startStation) || !StringUtils.hasText(endStation)) { + throw new Exception("参数不能为空"); + } + + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + Date currentTime = new Date(); + + // 检查栈板calling_flag状态 + String callingFlag = wcsIntegrationMapper.checkPalletCallingFlag(site, palletId); + if ("Y".equals(callingFlag)) { + throw new Exception("栈板正在被调用中,无法创建运输任务"); + } + + // 生成任务编号 + TransNoControl transData = transNoService.getTransNo(site, "WTT", 10); + + // 创建运输任务 + WmsTransportTask task = new WmsTransportTask(); + task.setSite(site); + task.setTaskNo(transData.getNewTransNo()); + task.setItemNo(1); + task.setSourceType("运输栈板"); + task.setSourceBillNo(""); + task.setSourceLineId(0L); + task.setPartNo(""); // 栈板运输不需要物料信息 + task.setQty(BigDecimal.ZERO); + task.setBatchNo(""); + task.setSerialNo(""); + task.setFromLocation(startStation); + task.setToLocation(endStation); + task.setPalletId(palletId); + task.setAgvCode(""); + task.setPriority(0); + task.setStatus("CREATED"); + task.setWmsSendTime(currentTime); + task.setCreatedBy(username); + task.setCreatedTime(currentTime); + task.setUpdatedTime(currentTime); + task.setFinishQty(BigDecimal.ZERO); + + // 插入运输任务 + wcsIntegrationMapper.insertTransportTask(task); + + // 更新栈板calling_flag为Y + wcsIntegrationMapper.updatePalletCallingFlag(site, palletId, "Y", username); + } + + @Override + @Transactional + public void callPalletToStation(Map params) throws Exception { + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + String station = (String) params.get("station"); + + if (!StringUtils.hasText(site) || !StringUtils.hasText(palletId) || !StringUtils.hasText(station)) { + throw new Exception("参数不能为空"); + } + + // 检查栈板calling_flag状态 + String callingFlag = wcsIntegrationMapper.checkPalletCallingFlag(site, palletId); + if ("Y".equals(callingFlag)) { + throw new Exception("栈板正在被调用中,无法执行Call操作"); + } + + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + + // TODO: 后期在这里调用WCS接口实现Call栈板功能 + // 示例:wcsApiService.callPalletToStation(site, palletId, station); + + // 更新栈板calling_flag为Y + // wcsIntegrationMapper.updatePalletCallingFlag(site, palletId, "Y", username); + } } diff --git a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml index 87fdcb9..c990d89 100644 --- a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml @@ -184,4 +184,42 @@ WHERE site = #{site} AND pallet_id = #{palletId} AND is_deleted = '0' + + + + + + + + + + + INSERT INTO wms_transport_task ( + site, task_no, item_no, source_type, source_bill_no, source_line_id, + part_no, qty, batch_no, serial_no, from_location, to_location, + pallet_id, agv_code, priority, status, wms_send_time, + created_by, created_time, updated_time + ) VALUES ( + #{site}, #{taskNo}, #{itemNo}, #{sourceType}, #{sourceBillNo}, #{sourceLineId}, + #{partNo}, #{qty}, #{batchNo}, #{serialNo}, #{fromLocation}, #{toLocation}, + #{palletId}, #{agvCode}, #{priority}, #{status}, #{wmsSendTime}, + #{createdBy}, #{createdTime}, #{updatedTime} + ) + + \ No newline at end of file