rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/WmsRcsController.java
@@ -4,6 +4,7 @@ import com.vincent.rsf.framework.exception.CoolException; import com.vincent.rsf.openApi.entity.dto.CommonResponse; import com.vincent.rsf.openApi.entity.params.ExMsgCallbackParams; import com.vincent.rsf.openApi.entity.params.LocSiteParams; import com.vincent.rsf.openApi.entity.params.RcsPubTaskParams; import com.vincent.rsf.openApi.entity.params.SyncRcsLocsParam; import com.vincent.rsf.openApi.service.WmsRcsService; @@ -81,5 +82,20 @@ return R.ok().add(wmsRcsService.syncLocs(params)); } /** * @author Ryan * @date 2025/11/10 * @description: WMS 出库成功后,修改库位、站点状态 * @version 1.0 */ @ApiOperation("RCS修改库位或站点状态") @PostMapping("/modify/status") public R modifyLocOrSite(@RequestBody LocSiteParams params) { if (Objects.isNull(params)) { return R.error("参数不能为空!!"); } return wmsRcsService.modifyLocOrSite(params); } } rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/constant/RcsConstant.java
@@ -6,4 +6,6 @@ public static String syncLocs = "/api/open/loc/sync"; public static String modifystatus = "/api/open/modify/status"; } rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/LocSiteParams.java
New file @@ -0,0 +1,26 @@ package com.vincent.rsf.openApi.entity.params; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; import java.io.Serializable; @Data @Accessors(chain = true) @ApiModel(value = "LocSiteParams", description = "库位或状态参数") public class LocSiteParams implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("类型:loc: 库位, site: 站点") private String type = "loc"; @ApiModelProperty("站点或库位") private String code; @ApiModelProperty("库位或站点状态") private String status; } rsf-open-api/src/main/java/com/vincent/rsf/openApi/enums/LocStasEnum.java
@@ -21,6 +21,6 @@ this.desc = desc; } private String code; private String desc; public String code; public String desc; } rsf-open-api/src/main/java/com/vincent/rsf/openApi/enums/LocStsType.java
New file @@ -0,0 +1,60 @@ package com.vincent.rsf.openApi.enums; public enum LocStsType { //空板 LOC_STS_TYPE_D("D", "空板"), //在库 LOC_STS_TYPE_F("F", "在库"), //空库 LOC_STS_TYPE_O("O", "空库"), //禁用 LOC_STS_TYPE_X("X", "禁用"), //入库预约 LOC_STS_TYPE_S("S", "入库预约"), //出库预约 LOC_STS_TYPE_R("R", "出库预约"), ; public String type; public String desc; LocStsType(String type, String desc) { this.type = type; this.desc = desc; } public static LocStsType get(String el) { for (LocStsType value : LocStsType.values()) { if (el.equals(value.toString())) { return value; } } return null; } /** * @author Ryan * @date 2025/8/28 * @description: RCS库位状态转换 * @version 1.0 */ public static String getLocSts(String val) { if (val.equals(LocStasEnum.LOC_STAS_ENUM_IDLE.code)) { return LocStsType.LOC_STS_TYPE_O.type; } else if (val.equals(LocStasEnum.LOC_STAS_ENUM_STOCK.code)) { return LocStsType.LOC_STS_TYPE_F.type; } else if (val.equals(LocStasEnum.LOC_STAS_ENUM_PAKIN.code)) { return LocStsType.LOC_STS_TYPE_S.type; } else if (val.equals(LocStasEnum.LOC_STAS_ENUM_PAKOUT.code)) { return LocStsType.LOC_STS_TYPE_R.type; } else if (val.equals(LocStasEnum.LOC_STAS_ENUM_DISABLED.code)) { return LocStsType.LOC_STS_TYPE_X.type; } return null; } } rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/WmsRcsService.java
@@ -7,6 +7,7 @@ import com.vincent.rsf.openApi.entity.dto.CommonResponse; import com.vincent.rsf.openApi.entity.dto.SyncLocsDto; import com.vincent.rsf.openApi.entity.params.ExMsgCallbackParams; import com.vincent.rsf.openApi.entity.params.LocSiteParams; import com.vincent.rsf.openApi.entity.params.RcsPubTaskParams; import com.vincent.rsf.openApi.entity.params.SyncRcsLocsParam; @@ -22,4 +23,6 @@ CommonResponse callBackEvent(ExMsgCallbackParams params); List<SyncLocsDto> syncLocs(SyncRcsLocsParam params); R modifyLocOrSite(LocSiteParams params); } rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
@@ -16,6 +16,7 @@ import com.vincent.rsf.openApi.entity.constant.RcsConstant; import com.vincent.rsf.openApi.entity.dto.SyncLocsDto; import com.vincent.rsf.openApi.entity.params.ExMsgCallbackParams; import com.vincent.rsf.openApi.entity.params.LocSiteParams; import com.vincent.rsf.openApi.entity.params.RcsPubTaskParams; import com.vincent.rsf.openApi.entity.params.SyncRcsLocsParam; import com.vincent.rsf.openApi.mapper.LocMapper; @@ -41,12 +42,11 @@ @Autowired private PlatformProperties rcsApi; @Autowired private PlatformProperties.WmsApi wmsApi; @Autowired private RestTemplate restTemplate; /** @@ -145,6 +145,43 @@ return syncRcsLocs(params); } /** * @author Ryan * @date 2025/11/10 * @description: 修改库位或站点状态 * @version 1.0 */ @Override public R modifyLocOrSite(LocSiteParams params) { /**RCS基础配置链接*/ String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.modifystatus; log.info("库位或站点状态修改,请求地址: {}, 请求参数: {}", rcsUrl , JSONObject.toJSONString(params)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json"); headers.add("api-version", "v2.0"); HttpEntity httpEntity = new HttpEntity(params, headers); ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class); log.info("库位或站点状态修改,响应结果: {}", exchange); if (Objects.isNull(exchange.getBody())) { throw new CoolException("状态修改失败!!"); } else { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.coercionConfigDefaults() .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); try { CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class); if (result.getCode() == 200) { return R.ok(); } else { throw new CoolException("状态修改失败!!"); } } catch (JsonProcessingException e) { throw new CoolException(e.getMessage()); } } } /** * @author Ryan * @date 2025/8/28 rsf-server/src/main/java/com/vincent/rsf/server/api/entity/constant/RcsConstant.java
@@ -13,4 +13,7 @@ //盘点库存修改 public static String CHECK_LOCITEM_UPDATE = "/rsf-open-api/erp/check/locitem/update"; //上报站点状态 public static String REPORT_SITE_STATUS = "/rsf-open-api/rcs/modify/status"; } rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/params/LocSiteParams.java
New file @@ -0,0 +1,26 @@ package com.vincent.rsf.server.manager.controller.params; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; import java.io.Serializable; @Data @Accessors(chain = true) @ApiModel(value = "LocSiteParams", description = "库位或状态参数") public class LocSiteParams implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("类型:loc: 库位, site: 站点") private String type = "loc"; @ApiModelProperty("站点或库位") private String code; @ApiModelProperty("库位或站点状态") private String status; } rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -1,6 +1,5 @@ package com.vincent.rsf.server.manager.schedules; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -18,6 +17,7 @@ import com.vincent.rsf.server.api.service.ReportMsgService; import com.vincent.rsf.server.api.utils.LocUtils; import com.vincent.rsf.server.common.constant.Constants; import com.vincent.rsf.server.manager.controller.params.LocSiteParams; import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; import com.vincent.rsf.server.manager.enums.*; import com.vincent.rsf.server.manager.entity.*; @@ -522,7 +522,6 @@ } /** * @param * @return @@ -559,6 +558,8 @@ } List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); //入库单据明细上报 if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type) { for (TaskItem taskItem : taskItems) { if (Objects.isNull(taskItem.getOrderId())) { continue; @@ -568,7 +569,6 @@ continue; } //入库单任务明细上报 if (order.getType().equals(OrderType.ORDER_IN.type)) { WkOrderItem wkOrderItem = asnOrderItemService.getOne(new LambdaQueryWrapper<WkOrderItem>() .eq(WkOrderItem::getOrderId, order.getId()) .eq(WkOrderItem::getFieldsIndex, taskItem.getFieldsIndex())); @@ -577,6 +577,13 @@ } /**入库单明细上报*/ reportMsgService.reportOrderItem(wkOrderItem); } } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type && task.getTaskType() <= TaskType.TASK_TYPE_EMPITY_OUT.type) { //出库单上报RCS修改库位状态 try { reportStationStatus(task); } catch (Exception e) { throw new RuntimeException(e); } } @@ -599,11 +606,62 @@ if (!taskItemLogService.saveBatch(itemLogs)) { throw new CoolException("任务明细历史档保存失败!!"); } if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) { throw new CoolException("原始任务明细删除失败!!"); } } }); } /** * @author Ryan * @date 2025/11/10 * @description: 上报站点状态 * @version 1.0 */ public CommonResponse reportStationStatus(Task task) { if (Objects.isNull(task.getTargSite())) { throw new CoolException("目标站点不能为空!!"); } BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite())); if (Objects.isNull(station)) { throw new CoolException("数据错误,目标站点不存在!!"); } station.setUseStatus(LocStsType.LOC_STS_TYPE_O.type); if (!basStationService.updateById(station)) { throw new CoolException("站点状态修改失败!!"); } LocSiteParams locSiteParams = new LocSiteParams(); locSiteParams.setStatus(LocStsType.getLocSts(LocStsType.LOC_STS_TYPE_O.type)) .setType("site") .setCode(station.getStationName()); /**WMS基础配置链接*/ String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.REPORT_SITE_STATUS; log.info("上报已完成订单:{}, 请求参数: {}", rcsUrl, JSONObject.toJSONString(locSiteParams)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json"); headers.add("api-version", "v2.0"); HttpEntity httpEntity = new HttpEntity(locSiteParams, headers); ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class); log.info("上报已完成订单,返回结果: {}", exchange); if (Objects.isNull(exchange.getBody())) { throw new CoolException("修改失败!!"); } else { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.coercionConfigDefaults().setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); try { CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class); return result; } catch (JsonProcessingException e) { throw new CoolException(e.getMessage()); } } } }