package com.gaotao.modules.automatedWarehouse.controller; import com.gaotao.common.utils.R; import com.gaotao.modules.api.entity.IfsInventoryPart; import com.gaotao.modules.api.service.IfsApiService; import com.gaotao.modules.automatedWarehouse.entity.*; import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService; import com.gaotao.modules.automatedWarehouse.service.PalletChangeStationService; import com.gaotao.modules.automatedWarehouse.service.PalletCancelService; import com.gaotao.modules.base.entity.PalletType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.List; import java.util.Map; @RestController @RequestMapping("/wcsIntegration") public class WcsIntegrationController { @Autowired private WcsIntegrationService wcsIntegrationService; @Autowired private IfsApiService ifsApiService; @Autowired private PalletChangeStationService palletChangeStationService; @Autowired private PalletCancelService palletCancelService; @PostMapping(value="/getShopOrderFromIFSWithOrderNo") @ResponseBody public R getIfsInventoryPart(@RequestBody IfsInventoryPart data) throws Exception{ //TODO 调用rifs接口获取列表数据 List rows = ifsApiService.getIfsInventoryPart(data); return R.ok().put("rows", rows); } @PostMapping(value="/palletListForPartNo") @ResponseBody public R palletListForPartNo(@RequestBody PartPalletData data) throws Exception{ List rows = wcsIntegrationService.palletListForPartNo(data); return R.ok().put("rows", rows); } /** * * @description call栈板出来 * @author 常熟吴彦祖 * @date 2025/9/19 16:55 * @return R */ @PostMapping(value="/callPalletFromWcs") @ResponseBody public R callPalletFromWcs(@RequestBody List data) { wcsIntegrationService.callPalletFromWcs(data); return R.ok(); } /** * 【新方法】直接Call栈板(不使用定时任务方式) - rqrq * @Description 实时调用WCS接口,返回失败的栈板信息 - rqrq * @Title callPalletFromWcsNew * @param data 栈板明细列表 * @return R * @author rqrq * @date 2025/10/04 */ @PostMapping(value="/callPalletFromWcsNew") @ResponseBody public R callPalletFromWcsNew(@RequestBody List data) throws Exception { Map result = wcsIntegrationService.callPalletFromWcsNew(data); return R.ok() .put("totalCount", result.get("totalCount")) .put("successCount", result.get("successCount")) .put("failedCount", result.get("failedCount")) .put("failedPalletIds", result.get("failedPalletIds")) .put("failedReasons", result.get("failedReasons")); } // ==================== 打托相关接口 - AI制作 ==================== /** * 检查栈板是否存在并获取位置信息 - AI制作 */ @PostMapping(value="/checkPalletExists") @ResponseBody public R checkPalletExists(@RequestBody Map params) { Map result = wcsIntegrationService.checkPalletExists(params); return R.ok() .put("positions", result.get("positions")) .put("palletType", result.get("palletType")) .put("locationCode", result.get("locationCode")) .put("palletId", result.get("palletId")); } /** * @Description 简单查询栈板信息(无任何校验)- rqrq * @Title getPalletInfoSimple * @param params 查询参数(site, palletId) * @return R * @author rqrq * @date 2025/10/09 */ @PostMapping(value="/getPalletInfoSimple") public R getPalletInfoSimple(@RequestBody Map params) throws Exception { Map result = wcsIntegrationService.getPalletInfoSimple(params); return R.ok() .put("palletId", result.get("palletId")) .put("positions", result.get("positions")) .put("palletType", result.get("palletType")) .put("locationCode", result.get("locationCode")); } /** * 获取栈板明细 - AI制作 */ @PostMapping(value="/getPalletDetails") @ResponseBody public R getPalletDetails(@RequestBody Map params) { try { List> details = wcsIntegrationService.getPalletDetails(params); return R.ok().put("details", details); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 根据位置获取层数 - AI制作 */ @PostMapping(value="/getLayersByPosition") @ResponseBody public R getLayersByPosition(@RequestBody Map params) { try { List layers = wcsIntegrationService.getLayersByPosition(params); return R.ok().put("layers", layers); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 保存栈板明细(扫进) - AI制作 */ @PostMapping(value="/savePalletDetail") @ResponseBody public R savePalletDetail(@RequestBody Map params) { try { wcsIntegrationService.savePalletDetail(params); return R.ok(); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 删除栈板明细(扫出) - AI制作 */ @PostMapping(value="/deletePalletDetail") @ResponseBody public R deletePalletDetail(@RequestBody Map params) { try { wcsIntegrationService.deletePalletDetail(params); return R.ok(); } catch (Exception e) { return R.error(e.getMessage()); } } /** * @Description 恢复标签到原栈板(分拣撤回)- rqrq * @Title restorePalletDetail * @param data 恢复标签请求参数实体 * @return R * @author rqrq * @date 2025/10/09 */ @PostMapping(value="/restorePalletDetail") @ResponseBody public R restorePalletDetail(@RequestBody RestorePalletDetailData data) throws Exception { wcsIntegrationService.restorePalletDetail(data); return R.ok(); } /** * @Description 查询标签当前所在栈板的信息 - rqrq * @Title getLabelInfo * @param data 查询标签信息请求参数实体 * @return R * @author rqrq * @date 2025/10/09 */ @PostMapping(value="/getLabelInfo") @ResponseBody public R getLabelInfo(@RequestBody GetLabelInfoData data) throws Exception { LabelInfoResult row = wcsIntegrationService.getLabelInfo(data); return R.ok().put("row", row); } /** * 获取编辑位置时的层数选项(排除指定标签) - AI制作 */ @PostMapping(value="/getLayersForEdit") @ResponseBody public R getLayersForEdit(@RequestBody Map params) { try { List layers = wcsIntegrationService.getLayersForEdit(params); return R.ok().put("layers", layers); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 更新栈板明细位置 - AI制作 */ @PostMapping(value="/updatePalletDetailPosition") @ResponseBody public R updatePalletDetailPosition(@RequestBody Map params) { try { wcsIntegrationService.updatePalletDetailPosition(params); return R.ok(); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 获取指定层数下各个位置的可用状态 - rqrq * @param params {site, palletId, layer} * @return 各位置可用状态 */ @PostMapping(value="/getAvailablePositionsForLayer") @ResponseBody public R getAvailablePositionsForLayer(@RequestBody Map params) throws Exception { Map result = wcsIntegrationService.getAvailablePositionsForLayer(params); return R.ok().put("data", result); } // ==================== 运输任务相关接口 - 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()); } } /** * 获取可用的AGV站点列表(已在后台过滤状态和类型)- AI制作 * 参数:statusDb - 站点状态(0-空闲,1-有货),不传则返回所有正式站点 */ @PostMapping(value="/getAvailableAgvStations") @ResponseBody public R getAvailableAgvStations(@RequestBody Map params) { try { List stations = wcsIntegrationService.getAvailableAgvStations(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 CallPalletRequestDto request) { wcsIntegrationService.callPalletToStation(request); return R.ok(); } /** * @Description 组盘完成后调用运输任务(自动判断空托盘/有货托盘)- rqrq * @Title callPalletToStationWithUpdateZuPan * @param request {site, startStation, targetArea, palletId} * @return R * @author rqrq * @date 2025-10-31 */ @PostMapping(value="/callPalletToStationWithUpdateZuPan") @ResponseBody public R callPalletToStationWithUpdateZuPan(@RequestBody CallPalletRequestDto request) { System.out.println("开始处理组盘入库请求 - rqrq"); // 参数校验 - rqrq if (!StringUtils.hasText(request.getSite()) || !StringUtils.hasText(request.getPalletId())) { return R.error("工厂编码和栈板编码不能为空"); } // 判断栈板是否有明细数据 - rqrq boolean hasPalletDetail = wcsIntegrationService.checkPalletHasDetail(request.getSite(), request.getPalletId()); if (hasPalletDetail) { // 有明细数据,调用组盘入库流程 - rqrq System.out.println("栈板有明细数据,执行组盘入库流程 - rqrq"); wcsIntegrationService.callPalletToStationWithUpdateZuPan(request); } else { // 空托盘,调用空托盘入库流程 - rqrq System.out.println("栈板无明细数据,执行空托盘入库流程 - rqrq"); Map params = new HashMap<>(); params.put("site", request.getSite()); params.put("palletId", request.getPalletId()); params.put("transportFlag", "Y"); // 默认入库并运输 - rqrq params.put("count", 1); wcsIntegrationService.notifyEmptyPalletInbound(params); } return R.ok(); } /** * 获取栈板详细信息(包含palletType和autoSort) - AI制作 */ @PostMapping(value="/getPalletInfo") @ResponseBody public R getPalletInfo(@RequestBody Map params) { try { com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationService.getPalletInfo(params); return R.ok().put("row", palletInfo); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 更新栈板类型和自动分拣标志 - AI制作 */ @PostMapping(value="/updatePalletTypeAndAutoSort") @ResponseBody public R updatePalletTypeAndAutoSort(@RequestBody Map params) { try { wcsIntegrationService.updatePalletTypeAndAutoSort(params); return R.ok(); } catch (Exception e) { return R.error(e.getMessage()); } } /** * 完成组托(不创建运输任务,只推送组托数据到WCS) - AI制作 */ @PostMapping(value="/completePalletAssembly") @ResponseBody public R completePalletAssembly(@RequestBody Map params) throws Exception { wcsIntegrationService.completePalletAssembly(params); return R.ok(); } /** * 手工分拣组托 */ @PostMapping(value="/completePalletAssemblyForFenJian") @ResponseBody public R completePalletAssemblyForFenJian(@RequestBody Map params) throws Exception { wcsIntegrationService.completePalletAssemblyForFenJian(params); return R.ok(); } // ==================== 栈板换站相关接口 - rqrq ==================== /** * @Description 检查栈板是否可以换站(判断calling_flag和获取当前站点信息)- rqrq * @Title checkPalletForChangeStation * @param params {site, palletId} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/checkPalletForChangeStation") @ResponseBody public R checkPalletForChangeStation(@RequestBody Map params) { CheckPalletResult row = wcsIntegrationService.checkPalletForChangeStation(params); return R.ok().put("row", row); } /** * @Description 获取可选择的区域列表(choose_able为Y)- rqrq * @Title getAreaOptionsForChange * @param params 查询参数 * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/getAreaOptionsForChange") @ResponseBody public R getAreaOptionsForChange(@RequestBody Map params) { List rows = wcsIntegrationService.getAreaOptionsForChange(params); return R.ok().put("rows", rows); } /** * @Description 根据区域获取可用站点列表 - rqrq * @Title getStationsByArea * @param params {areaId} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/getStationsByArea") @ResponseBody public R getStationsByArea(@RequestBody Map params) { List rows = wcsIntegrationService.getStationsByArea(params); return R.ok().put("rows", rows); } /** * @Description 提交栈板换站任务 - rqrq * @Title submitChangeStationTask * @param request 换站任务请求参数 * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/submitChangeStationTask") @ResponseBody public R submitChangeStationTask(@RequestBody CallPalletRequestDto request) { palletChangeStationService.handleChangeStationTask(request); return R.ok(); } /** * @Description Call料到指定位置(Call料+预约取盘到指定区域/站点)- rqrq * @Title callOutToStation * @param request Call料到指定位置请求参数 * @return R * @author rqrq * @date 2025/10/17 */ @PostMapping(value="/callOutToStation") @ResponseBody public R callOutToStation(@RequestBody CallOutToStationRequestDto request) { wcsIntegrationService.callOutToStation(request); return R.ok(); } // ==================== 手工移动托盘相关方法 - rqrq ==================== /** * @Description 检查托盘是否可以手工移动 - rqrq * @Title checkPalletForManualMove * @param params {site, palletId} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/checkPalletForManualMove") @ResponseBody public R checkPalletForManualMove(@RequestBody Map params) { CheckPalletResult row = wcsIntegrationService.checkPalletForManualMove(params); return R.ok().put("row", row); } /** * @Description 移出站点 - rqrq * @Title removeFromStation * @param params {site, palletId, stationCode} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/removeFromStation") @ResponseBody public R removeFromStation(@RequestBody Map params) { wcsIntegrationService.removeFromStation(params); return R.ok(); } /** * @Description 获取可绑定的区域列表 - rqrq * @Title getAreaOptionsForBind * @param params {site} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/getAreaOptionsForBind") @ResponseBody public R getAreaOptionsForBind(@RequestBody Map params) { List rows = wcsIntegrationService.getAreaOptionsForChange(params); return R.ok().put("rows", rows); } /** * @Description 根据区域获取可绑定的站点列表 - rqrq * @Title getStationsForBind * @param params {site, areaId} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/getStationsForBind") @ResponseBody public R getStationsForBind(@RequestBody Map params) { List rows = wcsIntegrationService.getStationsByArea(params); return R.ok().put("rows", rows); } /** * @Description 绑定托盘到站点 - rqrq * @Title bindPalletToStation * @param params {site, palletId, stationCode} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/bindPalletToStation") @ResponseBody public R bindPalletToStation(@RequestBody Map params) { wcsIntegrationService.bindPalletToStation(params); return R.ok(); } // ==================== 空托盘组盘相关方法 - rqrq ==================== /** * @Description 检查托盘是否为空托盘 - rqrq * @Title checkEmptyPallet * @param params {site, palletId} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/checkEmptyPallet") @ResponseBody public R checkEmptyPallet(@RequestBody Map params) { CheckPalletResult row = wcsIntegrationService.checkEmptyPallet(params); return R.ok().put("row", row); } /** * @Description 获取托盘类型列表(根据pallet_family过滤)- rqrq * @Title getPalletTypes * @param params {site, palletFamily} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/getPalletTypes") @ResponseBody public R getPalletTypes(@RequestBody Map params) { List rows = wcsIntegrationService.getPalletTypes(params); return R.ok().put("rows", rows); } /** * @Description 空托盘通知入库 - rqrq * @Title notifyEmptyPalletInbound * @param params {site, palletId, transportFlag} * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/notifyEmptyPalletInbound") @ResponseBody public R notifyEmptyPalletInbound(@RequestBody Map params) { wcsIntegrationService.notifyEmptyPalletInbound(params); return R.ok(); } /** * @Description 调用空托盘到指定站点(选择区域、站点、栈板类型)- rqrq * @Title callEmptyPalletToStation * @param params {site, stationCode, palletType} * @return R * @author rqrq * @date 2025/10/19 */ @PostMapping(value="/callEmptyPalletToStation") @ResponseBody public R callEmptyPalletToStation(@RequestBody Map params) throws Exception { wcsIntegrationService.callEmptyPalletToStation(params); return R.ok(); } // ==================== 取消WCS组盘相关方法 - rqrq ==================== /** * @Description 检查栈板WCS组盘状态 - rqrq * @Title checkPalletWcsStatus * @param data 请求参数实体(包含site, palletId) * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/checkPalletWcsStatus") @ResponseBody public R checkPalletWcsStatus(@RequestBody CancelWcsPalletData data) throws Exception { CheckPalletResult row = wcsIntegrationService.checkPalletWcsStatus(data); return R.ok().put("row", row); } /** * @Description 取消组盘(包含AGV任务检查)- rqrq * @Title cancelWcsPallet * @param data 请求参数实体(包含site, palletId) * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/cancelWcsPallet") @ResponseBody public R cancelWcsPallet(@RequestBody CancelWcsPalletData data) throws Exception { palletCancelService.cancelWcsPallet(data); return R.ok(); } /** * @Description 移出全部物料 - rqrq * @Title removeAllPalletDetails * @param data 请求参数实体(包含site, palletId) * @return R * @author rqrq * @date 2025/10/16 */ @PostMapping(value="/removeAllPalletDetails") @ResponseBody public R removeAllPalletDetails(@RequestBody CancelWcsPalletData data) throws Exception { wcsIntegrationService.removeAllPalletDetails(data); return R.ok(); } /** * @Description 结束分拣(下达预约送货任务到Z104区域,并更新pallet_detail的wcs_flag为1)- rqrq * @Title finishSorting * @param params {site, palletId} * @return R * @author rqrq * @date 2025/10/19 */ @PostMapping(value="/finishSorting") @ResponseBody public R finishSorting(@RequestBody Map params) throws Exception { wcsIntegrationService.finishSorting(params); return R.ok(); } @PostMapping(value="/finishSortingNoAgv") @ResponseBody public R finishSortingNoAgv(@RequestBody Map params) throws Exception { wcsIntegrationService.finishSortingNoAgv(params); return R.ok(); } // ==================== 分拣明细查询相关方法 - rqrq ==================== /** * @Description 根据栈板站点获取分拣明细RFID列表 - rqrq * @Title getSortingList * @param params {site, palletId} * @return R (返回devCode和rfidList) * @author rqrq * @date 2025/11/01 */ @PostMapping(value="/getSortingList") @ResponseBody public R getSortingList(@RequestBody Map params) throws Exception { Map result = wcsIntegrationService.getSortingList(params); return R.ok() .put("devCode", result.get("devCode")) .put("rfidList", result.get("rfidList")); } }