From a5381945bfbafbdd2d2d4703500620f0f5f5d413 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期一, 16 三月 2026 10:07:29 +0800
Subject: [PATCH] #erp接口对接
---
src/main/java/com/zy/asrs/controller/OpenController.java | 98 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 95 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index cb34a46..2c6d016 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,11 +1,14 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.core.annotations.AppAuth;
import com.core.common.*;
import com.core.exception.CoolException;
import com.zy.asrs.entity.param.*;
+import com.zy.asrs.mapper.LocDetlMapper;
import com.zy.asrs.service.OpenService;
+import com.zy.common.service.wms.Result;
import com.zy.common.model.DetlDto;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
@@ -13,9 +16,9 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* Created by vincent on 2022/4/8
@@ -24,6 +27,10 @@
@RestController
@RequestMapping("open/asrs")
public class OpenController extends BaseController {
+ @Autowired
+ private LocDetlMapper locDetlMapper;
+
+ private static final String MES_WAREHOUSE_ID = "WH01";
private static final boolean auth = true;
public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{
@@ -151,6 +158,91 @@
return R.ok().add(openService.queryStock());
}
+
+ @PostMapping(value = "/MES/inventory/details", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
+ public Result details(@RequestBody(required = false) JSONObject body) {
+ try {
+ String wareHouseId = body == null ? null : body.getString("wareHouseId");
+ String locId = body == null ? null : body.getString("locId");
+ String matNr = body == null ? null : body.getString("matNr");
+ String orderNo = body == null ? null : body.getString("orderNo");
+ String batch = body == null ? null : body.getString("batch");
+ if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) {
+ return new Result(200, "鎿嶄綔鎴愬姛", Collections.emptyList());
+ }
+ return new Result(200, "鎿嶄綔鎴愬姛", locDetlMapper.mesInventoryDetails(wareHouseId, locId, matNr, orderNo, batch));
+ } catch (Exception e) {
+ return new Result(500, e.getMessage(), null);
+ }
+ }
+
+ @PostMapping(value = "/MES/inventory/summary", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
+ public Result summary(@RequestBody(required = false) JSONObject body) {
+ try {
+ String wareHouseId = body == null ? null : body.getString("wareHouseId");
+ String matNr = body == null ? null : body.getString("matNr");
+ if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) {
+ return new Result(200, "鎿嶄綔鎴愬姛", Collections.emptyList());
+ }
+ Collection<String> matNrs = null;
+ if (!Cools.isEmpty(matNr)) {
+ matNrs = Arrays.stream(matNr.split(","))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.toList());
+ }
+ return new Result(200, "鎿嶄綔鎴愬姛", locDetlMapper.mesInventorySummary(wareHouseId, matNrs));
+ } catch (Exception e) {
+ return new Result(500, e.getMessage(), null);
+ }
+ }
+
+ @RestController
+ @RequestMapping("/MES/inventory")
+ public static class MesInventoryController {
+
+ @Autowired
+ private LocDetlMapper locDetlMapper;
+
+ @PostMapping(value = "/details", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
+ public Result details(@RequestBody(required = false) JSONObject body) {
+ try {
+ String wareHouseId = body == null ? null : body.getString("wareHouseId");
+ String locId = body == null ? null : body.getString("locId");
+ String matNr = body == null ? null : body.getString("matNr");
+ String orderNo = body == null ? null : body.getString("orderNo");
+ String batch = body == null ? null : body.getString("batch");
+ if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) {
+ return new Result(200, "鎿嶄綔鎴愬姛", Collections.emptyList());
+ }
+ return new Result(200, "鎿嶄綔鎴愬姛", locDetlMapper.mesInventoryDetails(wareHouseId, locId, matNr, orderNo, batch));
+ } catch (Exception e) {
+ return new Result(500, e.getMessage(), null);
+ }
+ }
+
+ @PostMapping(value = "/summary", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
+ public Result summary(@RequestBody(required = false) JSONObject body) {
+ try {
+ String wareHouseId = body == null ? null : body.getString("wareHouseId");
+ String matNr = body == null ? null : body.getString("matNr");
+ if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) {
+ return new Result(200, "鎿嶄綔鎴愬姛", Collections.emptyList());
+ }
+ Collection<String> matNrs = null;
+ if (!Cools.isEmpty(matNr)) {
+ matNrs = Arrays.stream(matNr.split(","))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.toList());
+ }
+ return new Result(200, "鎿嶄綔鎴愬姛", locDetlMapper.mesInventorySummary(wareHouseId, matNrs));
+ } catch (Exception e) {
+ return new Result(500, e.getMessage(), null);
+ }
+ }
+ }
+
private void auth(String appkey, Object obj, HttpServletRequest request) {
log.info("{}鎺ュ彛琚闂紱appkey:{}锛涜姹傛暟鎹細{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
request.setAttribute("cache", obj);
--
Gitblit v1.9.1