From a56420ff2042a3f6b1e824341a717a28c692cad4 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期五, 30 一月 2026 16:39:15 +0800
Subject: [PATCH] 查询库存明细
---
rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java | 85 +++++++
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/phyz/Station.java | 2
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/InventoryQueryConditionParam.java | 129 +++++++++++
rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/fallback/WmsServerFeignClientFallback.java | 21 +
rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java | 7
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java | 284 +++++++++++++++++++++++++
rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/WmsServerFeignClient.java | 34 +++
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ErpQueryController.java | 35 ++
rsf-open-api/pom.xml | 29 ++
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/constant/WmsConstant.java | 2
rsf-open-api/src/main/java/com/vincent/rsf/openApi/OpenApi.java | 6
11 files changed, 612 insertions(+), 22 deletions(-)
diff --git a/rsf-open-api/pom.xml b/rsf-open-api/pom.xml
index 0d1c326..06209de 100644
--- a/rsf-open-api/pom.xml
+++ b/rsf-open-api/pom.xml
@@ -14,6 +14,7 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.proc>full</maven.compiler.proc>
</properties>
<dependencies>
<dependency>
@@ -44,6 +45,18 @@
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
+ <!-- OpenFeign渚濊禆 -->
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-openfeign</artifactId>
+ </dependency>
+ <!-- Lombok渚濊禆 -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.30</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<finalName>rsf-open-api</finalName>
@@ -64,6 +77,22 @@
</nonFilteredFileExtensions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>17</source>
+ <target>17</target>
+ <encoding>UTF-8</encoding>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.30</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/OpenApi.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/OpenApi.java
index b058da5..4910858 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/OpenApi.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/OpenApi.java
@@ -4,8 +4,12 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
+import org.springframework.cloud.openfeign.EnableFeignClients;
-@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class })
+@SpringBootApplication(
+ exclude = {SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class}
+)
+@EnableFeignClients(basePackages = "com.vincent.rsf.openApi.feign")
public class OpenApi {
public static void main(String[] args) {
SpringApplication.run(OpenApi.class, args);
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
index a75afc4..90edbd6 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
@@ -3,21 +3,26 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.openApi.entity.dto.CommonResponse;
import com.vincent.rsf.openApi.entity.phyz.*;
+import com.vincent.rsf.openApi.feign.wms.WmsServerFeignClient;
import com.vincent.rsf.openApi.service.phyz.ErpReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import static com.vincent.rsf.openApi.controller.AuthController.SIMULATED_DATA_ENABLE;
@@ -32,6 +37,9 @@
@Resource
private ErpReportService erpReportService;
+
+ @Autowired(required = false)
+ private WmsServerFeignClient wmsServerFeignClient;
@ApiOperation("浠撳簱淇℃伅鍚屾")
@@ -147,7 +155,7 @@
@ApiOperation("搴撳瓨鏌ヨ鏄庣粏")
@PostMapping("/inventory/details")
- public CommonResponse queryInventoryDetails(@RequestBody JSONObject params) {
+ public CommonResponse queryInventoryDetails(@RequestBody InventoryQueryCondition condition) {
if (SIMULATED_DATA_ENABLE.equals("1")) {
String x = "[\n" +
" {\n" +
@@ -193,10 +201,77 @@
return CommonResponse.ok(JSONArray.parseArray(map.toJSONString(), InventoryDetails.class));
}
- InventoryQueryCondition condition = JSON.parseObject(params.toJSONString(), InventoryQueryCondition.class);
- // 鏁版嵁澶勭悊锛岃浆鍙憇erver
- List<InventoryDetails> inventoryDetails = Lists.newArrayList();
- return new CommonResponse().setCode(200).setData(inventoryDetails);
+ try {
+ if (wmsServerFeignClient == null) {
+ log.warn("WmsServerFeignClient鏈敞鍏ワ紝鏃犳硶杩涜璋冪敤");
+ return CommonResponse.error("鏈嶅姟鏈垵濮嬪寲");
+ }
+
+ // 鍙傛暟楠岃瘉
+ if (condition == null) {
+ return CommonResponse.error("鏌ヨ鏉′欢涓嶈兘涓虹┖");
+ }
+
+ log.info("搴撳瓨鏌ヨ鏄庣粏璇锋眰鍙傛暟锛� {}", JSON.toJSONString(condition));
+
+ // 鐩存帴浼犻�掑疄浣撶被锛孎eign浼氳嚜鍔ㄥ簭鍒楀寲涓篔SON
+ R result = wmsServerFeignClient.queryInventoryDetails(condition);
+
+ log.info("搴撳瓨鏌ヨ鏄庣粏杩斿洖缁撴灉锛� {}", JSON.toJSONString(result));
+
+ if (result != null) {
+ // R绫荤户鎵胯嚜HashMap锛屼娇鐢╣et鏂规硶鑾峰彇鍊�
+ Integer code = (Integer) result.get("code");
+ String msg = (String) result.get("msg");
+ Object data = result.get("data");
+
+ if (code != null && code == 200) {
+ // 灏哅ap鍒楄〃杞崲涓篒nventoryDetails鍒楄〃
+ if (data != null) {
+ @SuppressWarnings("unchecked")
+ List<Map<String, Object>> dataList = (List<Map<String, Object>>) data;
+ List<InventoryDetails> inventoryDetails = new ArrayList<>();
+ for (Map<String, Object> item : dataList) {
+ InventoryDetails details = JSON.parseObject(JSON.toJSONString(item), InventoryDetails.class);
+ inventoryDetails.add(details);
+ }
+ return CommonResponse.ok(inventoryDetails);
+ } else {
+ return CommonResponse.ok(new ArrayList<>());
+ }
+ } else {
+ return CommonResponse.error(msg != null ? msg : "鏌ヨ澶辫触");
+ }
+ } else {
+ return CommonResponse.error("鏌ヨ澶辫触锛氳繑鍥炵粨鏋滀负绌�");
+ }
+ } catch (Exception e) {
+ log.error("搴撳瓨鏌ヨ鏄庣粏澶辫触", e);
+ // 杩囨护閿欒娑堟伅涓殑URL锛屽彧淇濈暀閿欒绫诲瀷
+ String errorMessage = e.getMessage();
+ if (errorMessage != null) {
+ // 濡傛灉鍖呭惈"executing"锛岃鏄庢槸HTTP璇锋眰閿欒锛屽幓鎺塙RL閮ㄥ垎
+ if (errorMessage.contains("executing")) {
+ int executingIndex = errorMessage.indexOf("executing");
+ if (executingIndex > 0) {
+ // 鎻愬彇"executing"涔嬪墠鐨勯儴鍒嗭紙濡�"Read timed out"锛�
+ errorMessage = errorMessage.substring(0, executingIndex).trim();
+ } else {
+ // 濡傛灉"executing"鍦ㄥ紑澶达紝浣跨敤榛樿閿欒娑堟伅
+ errorMessage = "璇锋眰瓒呮椂";
+ }
+ }
+ // 濡傛灉鍖呭惈"http://"鎴�"https://"锛屼篃灏濊瘯鍘绘帀URL閮ㄥ垎
+ else if (errorMessage.contains("http://") || errorMessage.contains("https://")) {
+ // 浣跨敤姝e垯琛ㄨ揪寮忓幓鎺塙RL
+ errorMessage = errorMessage.replaceAll("https?://[^\\s]+", "").trim();
+ if (errorMessage.isEmpty()) {
+ errorMessage = "璇锋眰澶辫触";
+ }
+ }
+ }
+ return CommonResponse.error("鏌ヨ澶辫触锛�" + (errorMessage != null && !errorMessage.isEmpty() ? errorMessage : "鏈煡閿欒"));
+ }
}
@ApiOperation("搴撳瓨鏌ヨ姹囨��")
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/constant/WmsConstant.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/constant/WmsConstant.java
index 26c84d9..f36148d 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/constant/WmsConstant.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/constant/WmsConstant.java
@@ -40,6 +40,8 @@
//绉诲簱浠诲姟鐢宠
public static String WCS_CREATE_LOC_MOVE_TASK = "/rsf-server/wcs/createLocMoveTask";
+ //搴撳瓨鏌ヨ鏄庣粏锛圗RP鎺ュ彛锛屽搴攐pen-api鐨�/inventory/details锛�
+ public static final String QUERY_INVENTORY_DETAILS = "/rsf-server/erp/inventory/details";
}
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/phyz/Station.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/phyz/Station.java
index d3f5a08..905ba38 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/phyz/Station.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/phyz/Station.java
@@ -47,5 +47,5 @@
// 鏄惁鍙敤
@JsonProperty("IsValid")
@JSONField(name = "IsValid")
- private boolean isValid;
+ private Boolean valid;
}
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/WmsServerFeignClient.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/WmsServerFeignClient.java
new file mode 100644
index 0000000..e48e236
--- /dev/null
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/WmsServerFeignClient.java
@@ -0,0 +1,34 @@
+package com.vincent.rsf.openApi.feign.wms;
+
+import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.openApi.entity.constant.WmsConstant;
+import com.vincent.rsf.openApi.entity.phyz.InventoryQueryCondition;
+import com.vincent.rsf.openApi.feign.wms.fallback.WmsServerFeignClientFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * WMS Server妯″潡Feign瀹㈡埛绔�
+ * 鐢ㄤ簬璋冪敤rsf-server妯″潡鐨勬帴鍙�
+ *
+ * 娉ㄦ剰锛歶rl閰嶇疆浠巃pplication.yml涓鍙杙latform.wms.host鍜宲latform.wms.port
+ * 濡傛灉open-api鍜宻erver鍦ㄥ悓涓�搴旂敤涓繍琛岋紝鍙互閰嶇疆涓烘湰鍦板湴鍧�
+ * 濡傛灉鍒嗗紑閮ㄧ讲锛寀rl搴旇閰嶇疆涓簊erver妯″潡鐨勫疄闄呭湴鍧�锛屽锛歨ttp://127.0.0.1:8085
+ */
+@FeignClient(
+ name = "wms-server",
+ url = "${platform.wms.host:http://127.0.0.1}:${platform.wms.port:8085}",
+ path = "",
+ fallback = WmsServerFeignClientFallback.class
+)
+public interface WmsServerFeignClient {
+
+ /**
+ * 搴撳瓨鏌ヨ鏄庣粏锛堣皟鐢╯erver绔殑erpQueryInventoryDetails鏂规硶锛�
+ * @param condition 鏌ヨ鏉′欢瀹炰綋绫�
+ * @return 搴撳瓨鏄庣粏鍒楄〃
+ */
+ @PostMapping(WmsConstant.QUERY_INVENTORY_DETAILS)
+ R queryInventoryDetails(@RequestBody InventoryQueryCondition condition);
+}
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/fallback/WmsServerFeignClientFallback.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/fallback/WmsServerFeignClientFallback.java
new file mode 100644
index 0000000..0c846f7
--- /dev/null
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/feign/wms/fallback/WmsServerFeignClientFallback.java
@@ -0,0 +1,21 @@
+package com.vincent.rsf.openApi.feign.wms.fallback;
+
+import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.openApi.entity.phyz.InventoryQueryCondition;
+import com.vincent.rsf.openApi.feign.wms.WmsServerFeignClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * WMS Server Feign瀹㈡埛绔檷绾у鐞�
+ */
+@Slf4j
+@Component
+public class WmsServerFeignClientFallback implements WmsServerFeignClient {
+
+ @Override
+ public R queryInventoryDetails(InventoryQueryCondition condition) {
+ log.error("璋冪敤WMS Server搴撳瓨鏌ヨ鏄庣粏鎺ュ彛澶辫触锛岃Е鍙戦檷绾у鐞�");
+ return R.error("鏈嶅姟璋冪敤澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ErpQueryController.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ErpQueryController.java
index 50168ab..c70bf3d 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ErpQueryController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ErpQueryController.java
@@ -1,25 +1,24 @@
package com.vincent.rsf.server.api.controller.erp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.vincent.rsf.server.api.service.ReceiveMsgService;
+import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
-import com.vincent.rsf.server.api.controller.erp.params.*;
+import com.vincent.rsf.server.api.controller.erp.params.InventoryQueryConditionParam;
+import com.vincent.rsf.server.api.controller.erp.params.QueryOrderParam;
+import com.vincent.rsf.server.api.service.ReceiveMsgService;
import com.vincent.rsf.server.common.annotation.OperationLog;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.PageParam;
-import com.vincent.rsf.framework.common.R;
-
import com.vincent.rsf.server.manager.entity.Loc;
-import com.vincent.rsf.server.manager.entity.Transfer;
-import com.vincent.rsf.server.manager.service.MatnrGroupService;
+import com.vincent.rsf.server.manager.service.*;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.Objects;
@@ -104,4 +103,22 @@
return receiveMsgService.queryTransfer(queryParams);
}
+ /**
+ * ERP搴撳瓨鏌ヨ鏄庣粏锛堜緵open-api妯″潡璋冪敤锛�
+ * 瀵瑰簲open-api鐨� /inventory/details 鎺ュ彛
+ * @param condition 鏌ヨ鏉′欢
+ * @return 搴撳瓨鏄庣粏鍒楄〃
+ */
+ @PostMapping("/inventory/details")
+ @ApiOperation(value = "ERP搴撳瓨鏌ヨ鏄庣粏", hidden = true)
+ @OperationLog("ERP搴撳瓨鏌ヨ鏄庣粏")
+ public R erpQueryInventoryDetails(@RequestBody InventoryQueryConditionParam condition) {
+ // 鍙傛暟楠岃瘉
+ if (condition == null) {
+ return R.error("鏌ヨ鏉′欢涓嶈兘涓虹┖");
+ }
+
+ return receiveMsgService.erpQueryInventoryDetails(condition);
+ }
+
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/InventoryQueryConditionParam.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/InventoryQueryConditionParam.java
new file mode 100644
index 0000000..0ae6a43
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/params/InventoryQueryConditionParam.java
@@ -0,0 +1,129 @@
+package com.vincent.rsf.server.api.controller.erp.params;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Map;
+
+/**
+ * 搴撳瓨鏌ヨ鏄庣粏鏉′欢鍙傛暟锛堜緵ERP璋冪敤锛�
+ * 瀵瑰簲open-api鐨処nventoryQueryCondition
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@Accessors(chain = true)
+@ApiModel(value = "InventoryQueryConditionParam", description = "搴撳瓨鏌ヨ鏄庣粏鏉′欢鍙傛暟")
+public class InventoryQueryConditionParam {
+
+ /**
+ * 浠撳簱缂栫爜
+ */
+ @ApiModelProperty(value = "浠撳簱缂栫爜")
+ private String wareHouseId;
+
+ /**
+ * 搴撲綅缂栫爜
+ */
+ @ApiModelProperty(value = "搴撲綅缂栫爜")
+ private String locId;
+
+ /**
+ * 鐗╂枡缂栫爜
+ */
+ @ApiModelProperty(value = "鐗╂枡缂栫爜")
+ private String matNr;
+
+ /**
+ * 璁㈠崟鍙�/宸ュ崟鍙�/MES宸ュ崟鍙�
+ */
+ @ApiModelProperty(value = "璁㈠崟鍙�/宸ュ崟鍙�/MES宸ュ崟鍙�")
+ private String orderNo;
+
+ /**
+ * 璁″垝璺熻釜鍙�
+ */
+ @ApiModelProperty(value = "璁″垝璺熻釜鍙�")
+ private String planNo;
+
+ /**
+ * 鎵规鍙�
+ */
+ @ApiModelProperty(value = "鎵规鍙�")
+ private String batch;
+
+ /**
+ * 鐗╂枡缁�
+ */
+ @ApiModelProperty(value = "鐗╂枡缁�")
+ private String matGroup;
+
+ /**
+ * 浠嶮ap鏋勯�營nventoryQueryConditionParam瀵硅薄
+ * 鐢ㄤ簬鎺ユ敹鍏朵粬鏂规硶杩斿洖鐨凪ap鍙傛暟骞惰嚜鍔ㄨ浆鎹�
+ *
+ * @param map 鏌ヨ鏉′欢Map
+ * @return InventoryQueryConditionParam瀵硅薄
+ */
+ public static InventoryQueryConditionParam fromMap(Map<String, Object> map) {
+ if (map == null) {
+ return null;
+ }
+ InventoryQueryConditionParam param = new InventoryQueryConditionParam();
+ if (map.containsKey("wareHouseId")) {
+ param.setWareHouseId((String) map.get("wareHouseId"));
+ }
+ if (map.containsKey("locId")) {
+ param.setLocId((String) map.get("locId"));
+ }
+ if (map.containsKey("matNr")) {
+ param.setMatNr((String) map.get("matNr"));
+ }
+ if (map.containsKey("orderNo")) {
+ param.setOrderNo((String) map.get("orderNo"));
+ }
+ if (map.containsKey("planNo")) {
+ param.setPlanNo((String) map.get("planNo"));
+ }
+ if (map.containsKey("batch")) {
+ param.setBatch((String) map.get("batch"));
+ }
+ if (map.containsKey("matGroup")) {
+ param.setMatGroup((String) map.get("matGroup"));
+ }
+ return param;
+ }
+
+ /**
+ * 杞崲涓篗ap锛堢敤浜庡吋瀹归渶瑕丮ap鍙傛暟鐨勬柟娉曪級
+ *
+ * @return Map瀵硅薄
+ */
+ public Map<String, Object> toMap() {
+ Map<String, Object> map = new java.util.HashMap<>();
+ if (wareHouseId != null) {
+ map.put("wareHouseId", wareHouseId);
+ }
+ if (locId != null) {
+ map.put("locId", locId);
+ }
+ if (matNr != null) {
+ map.put("matNr", matNr);
+ }
+ if (orderNo != null) {
+ map.put("orderNo", orderNo);
+ }
+ if (planNo != null) {
+ map.put("planNo", planNo);
+ }
+ if (batch != null) {
+ map.put("batch", batch);
+ }
+ if (matGroup != null) {
+ map.put("matGroup", matGroup);
+ }
+ return map;
+ }
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java
index 14c8691..78a0464 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/ReceiveMsgService.java
@@ -152,4 +152,11 @@
* @return
*/
R matUpdate(BaseMatParms baseMatParms);
+
+ /**
+ * 搴撳瓨鏌ヨ鏄庣粏锛堜緵open-api璋冪敤锛�
+ * @param condition 鏌ヨ鏉′欢
+ * @return 搴撳瓨鏄庣粏鍒楄〃
+ */
+ R erpQueryInventoryDetails(InventoryQueryConditionParam condition);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java
index 179200f..8e1fe0c 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/ReceiveMsgServiceImpl.java
@@ -47,6 +47,8 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
+import static com.vincent.rsf.server.manager.enums.OrderWorkType.*;
+
/**
* @author Ryan
* @version 1.0
@@ -108,6 +110,8 @@
private WaitPakinService waitPakinService;
@Autowired
private WarehouseAreasItemServiceImpl warehouseAreasItemService;
+ @Autowired
+ private LocItemService locItemService;
/**
@@ -418,7 +422,7 @@
if (Objects.isNull(one)) {
throw new CoolException("鍗曟嵁锛�" + syncOrder.getOrderNo() + ", 涓氬姟绫诲瀷涓嶅瓨鍦紒锛�");
}
- WkOrder order = asnOrderService.getOne(new LambdaQueryWrapper<WkOrder>()
+ WkOrder order = asnOrderService.getOne(new LambdaQueryWrapper<WkOrder>()
.eq(!Objects.isNull(syncOrder.getOrderId()), WkOrder::getPoId, syncOrder.getOrderId())
.eq(WkOrder::getPoCode, syncOrder.getOrderNo()));
if (!Objects.isNull(order)) {
@@ -439,7 +443,7 @@
//閾跺骇鐗逛緵
String orderNs = null;
- if (rule.equals(SerialRuleCode.SYS_ASN_ORDER) || rule.equals(SerialRuleCode.SYS_OUT_STOCK_CODE) ){
+ if (rule.equals(SerialRuleCode.SYS_ASN_ORDER) || rule.equals(SerialRuleCode.SYS_OUT_STOCK_CODE)) {
StringBuffer buffer = new StringBuffer();
Object poCode = syncOrder.getOrderNo();
orderNs = poCode == null ? "" : buffer.append(poCode).toString();
@@ -461,7 +465,7 @@
.setCreateBy(loginUserId)
.setUpdateBy(loginUserId);
- if (syncOrder.getType().equals(OrderType.ORDER_OUT.type)){
+ if (syncOrder.getType().equals(OrderType.ORDER_OUT.type)) {
wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val);
}
if (!asnOrderService.save(wkOrder)) {
@@ -469,10 +473,10 @@
}
AtomicReference<String> palletId = new AtomicReference<>();
syncOrder.getOrderItems().forEach(orderItem -> {
- if (Cools.isEmpty(palletId.get())){
+ if (Cools.isEmpty(palletId.get())) {
palletId.set(orderItem.getPalletId());
} else {
- if (!palletId.get().equals(orderItem.getPalletId())){
+ if (!palletId.get().equals(orderItem.getPalletId())) {
throw new CoolException("鍚屼竴涓崟鎹槑缁嗕腑鐨勬墭鐩樼爜蹇呴』涓�鑷达紒锛侊紒");
}
}
@@ -549,7 +553,7 @@
int i = 0;
while (true) {
i++;
- if (i>5) return;
+ if (i > 5) return;
Thread.sleep(3000);
List<WarehouseAreasItem> list = warehouseAreasItemService.list(new LambdaQueryWrapper<WarehouseAreasItem>()
.eq(WarehouseAreasItem::getAsnCode, orderNo));
@@ -575,6 +579,7 @@
log.error("璁㈠崟 {} 鑷姩缁勬墭澶辫触: {}", orderNo, e.getMessage(), e);
}
}
+
/**
* @author Ryan
* @date 2025/8/19
@@ -863,6 +868,7 @@
/**
* 鍩虹鐗╂枡淇℃伅鍙樻洿
+ *
* @param baseMatParms
* @return
*/
@@ -908,4 +914,270 @@
return R.ok();
}
+
+ /**
+ * 搴撳瓨鏌ヨ鏄庣粏锛堜緵open-api璋冪敤锛�
+ *
+ * @param condition 鏌ヨ鏉′欢瀹炰綋绫�
+ * @return 搴撳瓨鏄庣粏鍒楄〃
+ */
+ @Override
+ public R erpQueryInventoryDetails(InventoryQueryConditionParam condition) {
+ try {
+ // 鍙傛暟楠岃瘉
+ if (condition == null) {
+ return R.error("鏌ヨ鏉′欢涓嶈兘涓虹┖");
+ }
+
+ // 灏咵RP鍙傛暟鏄犲皠涓篔ava瀹炰綋瀛楁鍚嶏紙椹煎嘲鏍煎紡锛夛紝PageParam浼氳嚜鍔ㄨ浆鎹负鏁版嵁搴撳瓧娈靛悕锛堜笅鍒掔嚎鏍煎紡锛�
+ Map<String, Object> queryMap = new HashMap<>();
+
+ // 浠庡疄浣撶被涓彁鍙栨煡璇㈡潯浠讹紝鏄犲皠涓烘暟鎹簱瀛楁鍚�
+ if (StringUtils.isNotBlank(condition.getLocId())) {
+ queryMap.put("locCode", condition.getLocId());
+ }
+ if (StringUtils.isNotBlank(condition.getMatNr())) {
+ queryMap.put("matnrCode", condition.getMatNr());
+ }
+ if (StringUtils.isNotBlank(condition.getPlanNo())) {
+ queryMap.put("trackCode", condition.getPlanNo());
+ }
+ if (StringUtils.isNotBlank(condition.getBatch())) {
+ queryMap.put("batch", condition.getBatch());
+ }
+
+ BaseParam baseParam = new BaseParam();
+ baseParam.syncMap(queryMap);
+ PageParam<LocItem, BaseParam> pageParam = new PageParam<>(baseParam, LocItem.class);
+
+ QueryWrapper<LocItem> wrapper = pageParam.buildWrapper(false);
+
+ // 璁㈠崟鍙�/宸ュ崟鍙�/MES宸ュ崟鍙�
+ if (StringUtils.isNotBlank(condition.getOrderNo())) {
+ String orderNo = condition.getOrderNo();
+ wrapper.and(w -> w.eq("plat_order_code", orderNo)
+ .or().eq("plat_work_code", orderNo));
+ }
+
+ // 鐗╂枡缁勶紙闇�瑕侀�氳繃鐗╂枡琛ㄥ叧鑱旀煡璇級
+ if (StringUtils.isNotBlank(condition.getMatGroup())) {
+ // 璋冪敤鐗╂枡Service鏌ヨ鐗╂枡缁勫搴旂殑鐗╂枡ID鍒楄〃锛堝鐢ㄥ凡鏈夋柟娉曪級
+ LambdaQueryWrapper<Matnr> matnrWrapper = new LambdaQueryWrapper<>();
+ matnrWrapper.eq(Matnr::getGroupId, condition.getMatGroup());
+ List<Matnr> matnrs = matnrService.list(matnrWrapper);
+ if (!matnrs.isEmpty()) {
+ List<Long> matnrIds = matnrs.stream().map(Matnr::getId).collect(Collectors.toList());
+ wrapper.in("matnr_id", matnrIds);
+ } else {
+ // 濡傛灉娌℃湁鎵惧埌鐗╂枡锛岃繑鍥炵┖缁撴灉
+ return R.ok().add(new ArrayList<>());
+ }
+ }
+
+ // 鍙煡璇㈡甯哥姸鎬佺殑搴撳瓨锛坰tatus=1琛ㄧず姝e父锛�
+ wrapper.eq("status", 1);
+
+ pageParam.setCurrent(1);
+ pageParam.setSize(Integer.MAX_VALUE);
+ PageParam<LocItem, BaseParam> pageResult = locItemService.page(pageParam, wrapper);
+ List<LocItem> locItems = pageResult.getRecords();
+
+ if (locItems.isEmpty()) {
+ return R.ok().add(new ArrayList<>());
+ }
+
+ // 鑾峰彇鎵�鏈夐渶瑕佸叧鑱旂殑ID
+ List<Long> locIds = locItems.stream()
+ .map(LocItem::getLocId)
+ .filter(Objects::nonNull)
+ .distinct()
+ .collect(Collectors.toList());
+
+ List<Long> warehouseIds = new ArrayList<>();
+ List<Long> orderIds = locItems.stream()
+ .map(LocItem::getOrderId)
+ .filter(Objects::nonNull)
+ .distinct()
+ .collect(Collectors.toList());
+
+ // 璋冪敤LocService鏌ヨ搴撲綅淇℃伅锛堝鐢⊿ervice灞傛柟娉曪級
+ Map<Long, Loc> locMap = new HashMap<>();
+ if (!locIds.isEmpty()) {
+ List<Loc> locs = locService.listByIds(locIds);
+ locMap = locs.stream().collect(Collectors.toMap(Loc::getId, loc -> loc));
+
+ // 鏀堕泦浠撳簱ID
+ warehouseIds = locs.stream()
+ .map(Loc::getWarehouseId)
+ .filter(Objects::nonNull)
+ .distinct()
+ .collect(Collectors.toList());
+ }
+
+ // 浠撳簱缂栫爜杩囨护
+ if (StringUtils.isNotBlank(condition.getWareHouseId())) {
+ String wareHouseId = condition.getWareHouseId();
+ LambdaQueryWrapper<Warehouse> whWrapper = new LambdaQueryWrapper<>();
+ whWrapper.eq(Warehouse::getCode, wareHouseId);
+ // 璋冪敤WarehouseService鏌ヨ浠撳簱淇℃伅锛堝鐢⊿ervice灞傛柟娉曪級
+ List<Warehouse> warehouses = warehouseService.list(whWrapper);
+ if (!warehouses.isEmpty()) {
+ Long targetWarehouseId = warehouses.get(0).getId();
+ // 杩囨护搴撲綅锛屽彧淇濈暀鐩爣浠撳簱鐨勫簱浣�
+ locMap = locMap.entrySet().stream()
+ .filter(entry -> Objects.equals(entry.getValue().getWarehouseId(), targetWarehouseId))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+ // 杩囨护locItems锛屽彧淇濈暀鐩爣浠撳簱鐨�
+ Set<Long> validLocIds = locMap.keySet();
+ locItems = locItems.stream()
+ .filter(item -> item.getLocId() != null && validLocIds.contains(item.getLocId()))
+ .collect(Collectors.toList());
+
+ warehouseIds = Collections.singletonList(targetWarehouseId);
+ } else {
+ return R.ok().add(new ArrayList<>());
+ }
+ }
+
+ // 璋冪敤WarehouseService鏌ヨ浠撳簱淇℃伅锛堝鐢⊿ervice灞傛柟娉曪級
+ Map<Long, Warehouse> warehouseMap = new HashMap<>();
+ if (!warehouseIds.isEmpty()) {
+ List<Warehouse> warehouses = warehouseService.listByIds(warehouseIds);
+ warehouseMap = warehouses.stream().collect(Collectors.toMap(Warehouse::getId, wh -> wh));
+ }
+
+ // 璋冪敤AsnOrderService鏌ヨ璁㈠崟淇℃伅锛堝鐢⊿ervice灞傛柟娉曪級
+ Map<Long, WkOrder> orderMap = new HashMap<>();
+ if (!orderIds.isEmpty()) {
+ List<WkOrder> orders = asnOrderService.listByIds(orderIds);
+ orderMap = orders.stream().collect(Collectors.toMap(WkOrder::getId, order -> order));
+ }
+
+ // 杞崲缁撴灉
+ List<Map<String, Object>> result = new ArrayList<>();
+ for (LocItem locItem : locItems) {
+ Map<String, Object> details = convertToInventoryDetails(locItem, locMap, warehouseMap, orderMap);
+ if (details != null) {
+ result.add(details);
+ }
+ }
+
+ return R.ok().add(result);
+ } catch (Exception e) {
+ log.error("搴撳瓨鏌ヨ鏄庣粏澶辫触", e);
+ return R.error("鏌ヨ澶辫触锛�" + e.getMessage());
+ }
+ }
+
+ /**
+ * 杞崲涓哄簱瀛樻槑缁嗗璞�
+ */
+ private Map<String, Object> convertToInventoryDetails(LocItem locItem, Map<Long, Loc> locMap,
+ Map<Long, Warehouse> warehouseMap,
+ Map<Long, WkOrder> orderMap) {
+ Map<String, Object> details = new HashMap<>();
+
+ // 搴撲綅缂栫爜
+ details.put("locId", locItem.getLocCode());
+
+ // 浠撳簱淇℃伅
+ Loc loc = null;
+ if (locItem.getLocId() != null) {
+ loc = locMap.get(locItem.getLocId());
+ }
+
+ if (loc != null) {
+ // 鎵樼洏鐮侊紙浠庡簱浣嶇殑barcode鑾峰彇锛�
+ details.put("palletId", loc.getBarcode());
+
+ // 浠撳簱淇℃伅
+ if (loc.getWarehouseId() != null && warehouseMap.containsKey(loc.getWarehouseId())) {
+ Warehouse warehouse = warehouseMap.get(loc.getWarehouseId());
+ if (warehouse != null) {
+ details.put("wareHouseId", warehouse.getCode());
+ details.put("wareHouseName", warehouse.getName());
+ }
+ }
+ }
+
+ // 鐗╂枡淇℃伅
+ details.put("matNr", locItem.getMatnrCode());
+ details.put("makTx", locItem.getMaktx());
+ details.put("spec", locItem.getSpec());
+ details.put("anfme", locItem.getAnfme());
+ details.put("unit", locItem.getUnit());
+
+ // 搴撳瓨鐘舵�侊細1-姝e父(鍙敤)锛�0-鍐荤粨
+ if (locItem.getStatus() != null) {
+ details.put("status", locItem.getStatus() == 1 ? "鍙敤" : "鍐荤粨");
+ }
+
+ // 鎵规鍙�
+ details.put("batch", locItem.getBatch());
+
+ // 璁″垝璺熻釜鍙�
+ details.put("planNo", locItem.getTrackCode());
+
+ // 璁㈠崟淇℃伅
+ if (locItem.getOrderId() != null && orderMap.containsKey(locItem.getOrderId())) {
+ WkOrder order = orderMap.get(locItem.getOrderId());
+ if (order != null) {
+ // 璁㈠崟鍙�
+ details.put("orderNo", order.getCode());
+ details.put("orderType", null);
+ // 璁㈠崟绫诲瀷锛�1-鍑哄簱鍗曪紝2-鍏ュ簱鍗曪紝3-璋冩嫈鍗�
+ // 瀛楃涓茬被鍨嬫槧灏勶細out->1(鍑哄簱鍗�), in->2(鍏ュ簱鍗�), revise->(璋冩嫈鍗�), check->(鐩樼偣鍗�))
+ if (StringUtils.isNotBlank(order.getType())) {
+ String orderTypeStr = order.getType().toLowerCase().trim();
+ switch (orderTypeStr) {
+ case "out":
+ details.put("orderType", 1);
+ break;
+ case "in":
+ details.put("orderType", 2);
+ break;
+ case "revise":
+ break;
+ case "check":
+ break;
+ default:
+ break;
+ }
+
+ //鍖呭惈 澶囨枡鍗曞叧閿瘝灏卞彉鎴�3
+ if (StringUtils.isNotBlank(order.getWkType())) {
+ String workDesc = getWorkDesc(order.getWkType());
+ if (workDesc != null && workDesc.contains("澶囨枡鍗�")) {
+ details.put("orderType", 3);
+ }
+ }
+ }
+
+ // 澶囨枡绫诲瀷锛氭牴鎹笟鍔$被鍨嬪垽鏂�
+ // 姝e父棰嗘枡(1)锛岀敓浜цˉ鏂�(2)
+ details.put("prepareType", 1);
+ if (StringUtils.isNotBlank(order.getWkType())) {
+ String workDesc = getWorkDesc(order.getWkType());
+ if (workDesc != null && workDesc.contains("鐢熶骇琛ユ枡")) {
+ details.put("prepareType", 2);
+ }
+ }
+ }
+ }
+
+ // 濡傛灉璁㈠崟鍙蜂负绌猴紝灏濊瘯浠巔latOrderCode鎴杙latWorkCode鑾峰彇
+ if (!details.containsKey("orderNo") || details.get("orderNo") == null) {
+ if (StringUtils.isNotBlank(locItem.getPlatOrderCode())) {
+ details.put("orderNo", locItem.getPlatOrderCode());
+ } else if (StringUtils.isNotBlank(locItem.getPlatWorkCode())) {
+ details.put("orderNo", locItem.getPlatWorkCode());
+ }
+ }
+
+ // 搴撳瓨缁勭粐锛堜粠useOrgId鑾峰彇锛�
+ details.put("stockOrgId", locItem.getUseOrgId());
+
+ return details;
+ }
}
--
Gitblit v1.9.1