From 87e99cdcfa55ee1a3b19a19506b05e4f554a416e Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期四, 07 五月 2026 19:34:12 +0800
Subject: [PATCH] 修复订单明细中没有batchSeq
---
src/main/java/com/zy/asrs/controller/OpenController.java | 568 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 517 insertions(+), 51 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 4547421..3031070 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -37,6 +37,7 @@
private static final boolean auth = true;
private static final String sign_arm_order = "|s|LABEL_";
private static final String sign_arm_sku = "|sku|LABEL_";
+ private static final long MILLIS_PER_MINUTE = 60L * 1000L;
public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{
add("ea1f0459efc02a79f046f982767939ae");
}};
@@ -56,6 +57,8 @@
@Autowired
private MatService matService;
+ @Autowired
+ private LocMastService locMastService;
@Autowired
private ReportQueryMapper reportQueryMapper;
// @PostMapping("/order/matSync/default/v1")
@@ -123,6 +126,23 @@
return R.ok().add(openService.pakinOrderComplete(param));
}
+ /**
+ * 鎵樼洏鍏ュ簱鍘嗗彶璁板綍閲嶆姤ERP
+ */
+ @PostMapping("/order/pakin/erp/report/v1")
+// @AppAuth(memo = "鍏ュ簱鍘嗗彶閲嶆姤ERP")
+ public synchronized R reportPakinHistoryToErp(@RequestBody(required = false) List<String> barcodes) {
+// auth(appkey, barcodes, request);
+ if (Cools.isEmpty(barcodes)) {
+ return R.parse(BaseRes.PARAM);
+ }
+ try {
+ return openService.reportPakinHistoryToErp(barcodes);
+ } catch (Exception e) {
+ return R.error(e.getMessage());
+ }
+ }
+
@@ -151,6 +171,7 @@
private void auth(String appkey, Object obj, HttpServletRequest request) {
log.info("{}鎺ュ彛琚闂紱appkey:{}锛涜姹傛暟鎹細{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
+ log.info("[auth] cache: {}", obj == null ? "null" : JSON.toJSONString(obj));
request.setAttribute("cache", obj);
if (!auth) {
return;
@@ -209,8 +230,8 @@
@PostMapping("/arm/task/v1")
@AppAuth(memo = "鍒嗘嫞绾夸笂鎶ユ帴鏀�")
public synchronized R TaskArmReport(@RequestHeader(required = false) String appkey,
- @RequestBody TaskArmReportParam param,
- HttpServletRequest request) {
+ @RequestBody TaskArmReportParam param,
+ HttpServletRequest request) {
auth(appkey, param, request);
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
@@ -254,8 +275,8 @@
@PostMapping("/arm/task/cycle_result")
@AppAuth(memo = "鍗曠爜瀹屾垚")
public synchronized R TaskArmCycleResult(@RequestHeader(required = false) String appkey,
- @RequestBody TaskArmCycleResultParam param,
- HttpServletRequest request) {
+ @RequestBody TaskArmCycleResultParam param,
+ HttpServletRequest request) {
auth(appkey, param, request);
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
@@ -286,8 +307,8 @@
@PostMapping("/arm/task/workspace_status")
@AppAuth(memo = "鎵樼洏瀹屾垚")
public synchronized R TaskArmWorkspaceStatus(@RequestHeader(required = false) String appkey,
- @RequestBody TaskArmWorkspaceStatusParam param,
- HttpServletRequest request) {
+ @RequestBody TaskArmWorkspaceStatusParam param,
+ HttpServletRequest request) {
auth(appkey, param, request);
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
@@ -319,8 +340,8 @@
@PostMapping("/arm/task/loc_status")
// @AppAuth(memo = "鎵樼洏灏辩华鐘舵�佹煡璇�")
public synchronized R TaskArmLocStatus(@RequestHeader(required = false) String appkey,
- @RequestBody ArmOKParam param,
- HttpServletRequest request) {
+ @RequestBody ArmOKParam param,
+ HttpServletRequest request) {
auth(appkey, param, request);
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
@@ -346,8 +367,8 @@
@PostMapping("/armAbnormalOperation")
// @AppAuth(memo = "寮傚父涓婃姤")
public synchronized R ArmAbnormalOperation(@RequestHeader(required = false) String appkey,
- @RequestBody TaskArmErrorParam param,
- HttpServletRequest request) {
+ @RequestBody TaskArmErrorParam param,
+ HttpServletRequest request) {
auth(appkey, param, request);
if (Cools.isEmpty(param.getArm_no())) {
return R.error("鏈烘鑷傜紪鍙穂Arm_no]涓嶈兘涓虹┖");
@@ -396,8 +417,12 @@
@PostMapping("/order/matSync/default/v2")
// @AppAuth(memo = "鍟嗗搧淇℃伅鍚屾鎺ュ彛")
- public synchronized R syncMatInfoV2(@RequestBody(required = false) List<MatSyncParam.MatParam> param){
-
+ public synchronized R syncMatInfoV2(@RequestBody(required = false) List<MatSyncParam.MatParam> param,
+ HttpServletRequest request) {
+ if (request != null) {
+ log.info("[syncMatInfoV2] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
System.out.println(param);
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
@@ -422,16 +447,44 @@
* return
*/
@PostMapping("/station/all")
- public synchronized R stationAll(){
+ public synchronized R stationAll(HttpServletRequest request) {
+ if (request != null) {
+ String cachePayload = JSON.toJSONString(Collections.singletonMap("op", "stationAll"));
+ log.info("[stationAll] cache: {}", cachePayload);
+ request.setAttribute("cache", cachePayload);
+ }
return openService.stationAll();
}
/**
- * 缁勬墭淇℃伅涓嬪彂
- * return
+ * 7.3 缁勬墭淇℃伅涓嬪彂
*/
@PostMapping("/comb/auth")
- public synchronized R comb(@RequestBody ArrayList<MesToCombParam> param){
+ public synchronized R comb(@RequestBody ArrayList<MesToCombParam> param, HttpServletRequest request) {
+ if (request != null) {
+ log.info("[comb] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
+
+ if (Cools.isEmpty(param)) {
+ return R.error("娌℃湁鍏ュ簱鏁版嵁");
+ }
+ boolean boo =false;
+ for (MesToCombParam mesToCombParam : param) {
+ if (mesToCombParam.getOperateType()==2){
+ int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", mesToCombParam.getPalletId()));
+ int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", mesToCombParam.getPalletId()));
+ int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",mesToCombParam.getPalletId()).eq("io_status", "Y"));
+ if (countLoc > 0 || countWrk > 0 || countwait > 0) {
+ return R.error(mesToCombParam.getPalletId()+"-宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�,鏃犳硶鍒犻櫎");
+ }
+ waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet",mesToCombParam.getPalletId()));
+ boo = true;
+ }
+ }
+ if (boo){
+ return R.ok();
+ }
List<MesToCombParam> errorComb = Lists.newArrayList();
List<MesToCombParam> validComb = Lists.newArrayList();
for (MesToCombParam mesToCombParam : param) {
@@ -459,6 +512,7 @@
validComb.add(mesToCombParam);
}
for (MesToCombParam mesToCombParam : validComb) {
+ mesToCombParam.setBoxType1("ERP");
openService.mesToComb(mesToCombParam);
}
// TODO:寰呮祴璇�
@@ -470,21 +524,124 @@
}
/**
- * 鍑哄簱閫氱煡鍗�
+ * 7.11 鍑哄簱閫氱煡鍗曪紙浼犻�掓湁搴忔棤搴忚鍒欙級銆�
+ *
+ * ERP 鍑哄簱閫氱煡缁熶竴鍏堣惤鍑哄簱璁㈠崟锛屼笉鍐嶇敱鎺ュ彛绾跨▼鐩存帴鍒涘缓 WrkMast/WrkDetl銆�
+ *
+ * 鍏抽敭瑙勫垯锛�
+ * 1. orderId 浣滀负鍑哄簱璁㈠崟鍙疯惤鍒� man_order_pakout.order_no銆�
+ * 2. stationId > 600 鏃跺繀椤讳紶 entryWmsCode锛屽悗缁寜 entryWmsCode 浣滀负杩涗粨缂栧彿鍒嗘壒鐢熸垚浠诲姟銆�
+ * 3. stationId <= 600 鏃跺厑璁� entryWmsCode 涓虹┖锛屽悗缁敓鎴愪换鍔℃椂浣跨敤 orderId 浣滀负鎵规閿��
+ * 4. 寤哄崟闃舵鍙牎楠屽簱瀛樺拰婊″簱浣嶏紝涓嶉攣搴撲綅銆佷笉鏀� loc_sts锛岀湡姝e崰搴撲粛鐢卞畾鏃剁敓鎴愪换鍔℃椂澶勭悊銆�
+ *
+ * 涓轰粈涔堣繖閲屼笉鍐嶇洿鎺ヨ皟鐢� outOrderBatch锛�
+ * - 鐩存帴寤� WrkMast 浼氶┈涓婃妸搴撲綅浠� F 鏀逛负 R锛孍RP 閲嶅彂銆佷汉宸ヤ腑姝€�乄CS 鍙栨秷鍚庣殑琛ュ伩閮藉緢闅剧粺涓�銆�
+ * - 鍏堣惤璁㈠崟鏄庣粏鍚庯紝鏈敓鎴愪换鍔$殑鏄庣粏鍙互鍒犻櫎閲嶄笅鍙戯紱宸茬敓鎴愪换鍔$殑鏄庣粏鐢卞彇娑堥�昏緫鍥炴粴 work_qty銆�
+ * - 浣庣珯鐐瑰拰楂樼珯鐐硅蛋鍚屼竴鏉¤鍗曢摼璺悗锛宲akoutOrderPause/execute 鎵嶈兘鍚屾椂鎺у埗鈥滄湭鐢熸垚鈥濆拰鈥滃凡鐢熸垚鈥濈殑浠诲姟銆�
*/
-
@PostMapping("/outOrder")
- public synchronized R outOrder (@RequestBody ArrayList<OutTaskParam> params){
+ public synchronized R outOrder(@RequestBody ArrayList<OutTaskParam> params, HttpServletRequest request) {
if (Cools.isEmpty(params)) {
return R.error("璇锋眰鍙傛暟涓嶈兘涓虹┖");
}
- Set<String> orderIds = new LinkedHashSet<>();
+ log.info("[outOrder] cache: {}", JSON.toJSONString(params));
+ request.setAttribute("cache", params);
+
+ // 缁熶竴鍋氭湁搴�/鏃犲簭鏍¢獙鐨勫垎缁勩��
+ //
+ // 娉ㄦ剰锛氳繖閲岀殑鍒嗙粍 key 涓嶆槸 ERP 鍘熷 batchSeq锛岃�屾槸鈥滄湭鏉ョ敓鎴� WrkMast.batchSeq 鐨勫�尖�濄��
+ // 杩欐牱鍙互鍦ㄦ帴鍙e叆鍙e氨鏍¢獙鏈�缁堜换鍔℃壒娆¢噷鐨� seq 鏄惁杩炵画锛岄伩鍏嶈鍗曞凡缁忚惤搴撳悗瀹氭椂鍣ㄦ墠澶辫触銆�
+ //
+ // 鎵规閿鍒欙細
+ // - 楂樼珯鐐规寜 orderId + entryWmsCode锛�
+ // - 浣庣珯鐐规寜 orderId + orderId銆�
+ Map<String, List<OutTaskParam>> linesByValidateKey = new LinkedHashMap<>();
for (OutTaskParam outTaskParam : params) {
if (Cools.isEmpty(outTaskParam) || Cools.isEmpty(outTaskParam.getOrderId())) {
return R.error("鍑哄簱鍗曞彿涓嶈兘涓虹┖");
}
- orderIds.add(outTaskParam.getOrderId());
+ if (Cools.isEmpty(outTaskParam.getBatchSeq())) {
+ // batchSeq 浠嶄繚瀛� ERP 瀛楁锛涙湭浼犳椂鐢� orderId 琛ラ綈锛屼究浜庢槑缁嗚拷婧��
+ // 浣庣珯鐐圭湡姝g敓鎴愪换鍔℃椂涓嶄娇鐢ㄨ瀛楁浣滀负鎵规閿紝鑰屾槸鍥哄畾浣跨敤 orderId銆�
+ outTaskParam.setBatchSeq(outTaskParam.getOrderId());
+ }
+ if (Cools.isEmpty(outTaskParam.getStationId())) {
+ return R.error("鎵樼洏銆�" + outTaskParam.getPalletId() + "銆嶅嚭搴撳彛缂栫爜涓嶈兘涓虹┖");
+ }
+ Integer stationId;
+ try {
+ stationId = Integer.valueOf(outTaskParam.getStationId());
+ } catch (NumberFormatException ex) {
+ return R.error("鎵樼洏銆�" + outTaskParam.getPalletId() + "銆嶅嚭搴撳彛缂栫爜鏍煎紡閿欒锛�" + outTaskParam.getStationId());
+ }
+ if (stationId > 600) {
+ // 楂樼珯鐐逛换鍔″繀椤诲甫杩涗粨缂栧彿锛涜繖鏄畾鏃剁敓鎴愪换鍔℃椂鐨勬壒娆¤竟鐣岋紝
+ // 涔熸槸 OutboundBatchSeqReleaseGuard 鍒ゆ柇鑳藉惁鏀捐涓嬩竴杩涗粨缂栧彿鐨勪緷鎹��
+ // 浣庣珯鐐逛笉鍋氳闄愬埗锛屼綆绔欑偣娌℃湁杩涗粨缂栧彿鏃朵細缁熶竴浣跨敤 orderId 浣滀负鎵规閿��
+ if (Cools.isEmpty(outTaskParam.getEntryWmsCode())) {
+ return R.error("鎵樼洏銆�" + outTaskParam.getPalletId() + "銆嶈繘浠撶紪鍙蜂笉鑳戒负绌�");
+ }
+ }
+ linesByValidateKey.computeIfAbsent(buildOutOrderValidateKey(outTaskParam), k -> new ArrayList<>()).add(outTaskParam);
}
+
+ // 浠嶄繚鐣欏師鎺ュ彛鐨勬湁搴�/鏃犲簭瑙勫垯锛�
+ // - seq=0 琛ㄧず鏃犲簭锛屽悓鎵规鎵�鏈夋槑缁嗛兘蹇呴』涓� 0锛�
+ // - seq>0 琛ㄧず鏈夊簭锛屽悓鎵规蹇呴』浠� 1 寮�濮嬭繛缁紱
+ // - seq=0 鍜� seq>0 涓嶈兘娣风敤銆�
+ //
+ // 鎵�鏈夋槑缁嗚櫧鐒舵殏涓嶇敓鎴愪换鍔★紝涔熻鍦ㄥ缓鍗曞墠淇濊瘉鍚屼竴浠诲姟鎵规鍐呯殑鏄庣粏椤哄簭鍚堟硶锛�
+ // 鍚﹀垯鍚庣画瀹氭椂鐢熸垚浠诲姟鏃舵墠澶辫触浼氭洿闅捐拷婧埌 ERP 鍘熷璇锋眰銆�
+ for (Map.Entry<String, List<OutTaskParam>> entry : linesByValidateKey.entrySet()) {
+ List<OutTaskParam> lines = entry.getValue();
+ OutTaskParam head = lines.get(0);
+ String oid = head.getOrderId();
+ String batchSeq = resolveOutOrderTaskBatchKey(head);
+ boolean hasZero = false;
+ boolean hasPositive = false;
+ List<Integer> orderedSeqs = new ArrayList<>(lines.size());
+ for (OutTaskParam line : lines) {
+ if (line.getSeq() == null) {
+ return R.error("鍑哄簱鍗曘��" + oid + "銆嶆壒娆°��" + batchSeq + "銆嶅簭鍙蜂笉鑳戒负绌�");
+ }
+ if (line.getSeq() < 0) {
+ return R.error("鍑哄簱鍗曘��" + oid + "銆嶆壒娆°��" + batchSeq + "銆嶅簭鍙蜂笉鑳藉皬浜�0");
+ }
+ if (line.getSeq() == 0) {
+ hasZero = true;
+ } else {
+ hasPositive = true;
+ orderedSeqs.add(line.getSeq());
+ }
+ }
+ if (hasZero && hasPositive) {
+ return R.error("鍑哄簱鍗曘��" + oid + "銆嶆壒娆°��" + batchSeq + "銆嶅簭鍙蜂笉鑳芥贩鐢ㄦ棤搴忓拰鏈夊簭");
+ }
+ if (!hasZero) {
+ Collections.sort(orderedSeqs);
+ for (int i = 0; i < orderedSeqs.size(); i++) {
+ if (!Objects.equals(orderedSeqs.get(i), i + 1)) {
+ return R.error("鍑哄簱鍗曘��" + oid + "銆嶆壒娆°��" + batchSeq + "銆嶅簭鍙蜂笉杩炶疮");
+ }
+ }
+ }
+ }
+
+ // 閲嶆柊鎸夋牎楠屽垎缁勯『搴忓睍寮�锛屼繚璇侀噸澶嶆墭鐩樸�佸簱瀛樸�佸簱浣嶆牎楠屼笌涓婇潰鐨勬壒娆℃牎楠岀湅鍒板悓涓�鎵规暟鎹��
+ List<OutTaskParam> groupedParams = new ArrayList<>(params.size());
+ for (List<OutTaskParam> lines : linesByValidateKey.values()) {
+ groupedParams.addAll(lines);
+ }
+
+ Set<String> seenPallet = new LinkedHashSet<>();
+ for (OutTaskParam outTaskParam : groupedParams) {
+ String pid = outTaskParam.getPalletId();
+ String palletKey = pid == null ? "" : pid;
+ if (!seenPallet.add(palletKey)) {
+ return R.error("鎵樼洏鍙烽噸澶嶏細" + (Cools.isEmpty(pid) ? "锛堢┖锛�" : pid));
+ }
+ }
+
// if (!orderIds.isEmpty()) {
// Set<String> existedOrderIds = new LinkedHashSet<>();
// List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("user_no", orderIds));
@@ -504,48 +661,152 @@
// }
// }
- List<OutTaskParam> errorOutOrders = Lists.newArrayList();
- List<OutTaskParam> validOutOrders = Lists.newArrayList();
- for (OutTaskParam outTaskParam : params) {
- // TODO:寰呮脯瑭︼紝鏍¢搴瓨淇℃伅锛屼笉瀛樺湪鍓囪繑鍥�
+ // 璁㈠崟鍖栧悗浠嶅繀椤荤‘璁ゆ墭鐩樻湁搴撳瓨涓斿綋鍓嶅簱浣嶄负婊″簱浣嶃��
+ //
+ // 杩欓噷鍙仛鍑嗗叆鏍¢獙锛屼笉鍦� controller 灞傛彁鍓嶉攣搴撲綅锛�
+ // - 濡傛灉杩欓噷鎻愬墠鏀� loc_sts锛屼細閫犳垚鈥滆鍗曟湭鎵ц浣嗗簱瀛樺凡琚崰鐢ㄢ�濓紱
+ // - 鐪熸閿佸簱浣嶅繀椤诲拰 WrkMast/WrkDetl 鍒涘缓鍦ㄥ悓涓�涓簨鍔¢噷瀹屾垚锛屾墍浠ヤ粛鐢� outOrderBatch 澶勭悊銆�
+ List<OutTaskParam> missingStock = Lists.newArrayList();
+ List<OutTaskParam> missingLoc = Lists.newArrayList();
+ for (OutTaskParam outTaskParam : groupedParams) {
int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", outTaskParam.getPalletId()));
- if (countLoc == 0){
- errorOutOrders.add(outTaskParam);
+ if (countLoc == 0) {
+ missingStock.add(outTaskParam);
continue;
}
- validOutOrders.add(outTaskParam);
- }
-
- for (OutTaskParam outTaskParam : validOutOrders) {
- R r = openService.outOrder(outTaskParam);
- if (!r.get("code").equals(200)){
- return r;
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F").eq("barcode", outTaskParam.getPalletId()));
+ if (locMast == null) {
+ missingLoc.add(outTaskParam);
}
}
-
- if(errorOutOrders.size() > 0) {
- return R.error("搴撳瓨涓笉瀛樺湪璇ユ墭鐩�").add(errorOutOrders);
+ if (!missingStock.isEmpty()) {
+ List<String> missingPalletIds = new ArrayList<>(missingStock.size());
+ for (OutTaskParam p : missingStock) {
+ String pid = p.getPalletId();
+ missingPalletIds.add(Cools.isEmpty(pid) ? "锛堢┖锛�" : pid);
+ }
+ return R.error("搴撳瓨涓笉瀛樺湪璇ユ墭鐩橈細" + String.join("锛�", missingPalletIds)).add(missingStock);
}
+ if (!missingLoc.isEmpty()) {
+ List<String> badPalletIds = new ArrayList<>(missingLoc.size());
+ for (OutTaskParam p : missingLoc) {
+ String pid = p.getPalletId();
+ badPalletIds.add(Cools.isEmpty(pid) ? "锛堢┖锛�" : pid);
+ }
+ return R.error("娌℃湁鎵惧埌鎵樼洏鐮佸搴斿簱浣嶏細" + String.join("锛�", badPalletIds)).add(missingLoc);
+ }
+ // ERP /outOrder 榛樿鍒涘缓鍙墽琛岃鍗曪細
+ // - status=1锛氬畾鏃跺櫒鍏佽鎵弿骞剁敓鎴愪换鍔★紱
+ // - 鐢熸垚浠诲姟鍚庢湇鍔″眰浼氱珛鍗虫妸 wrk_sts=11 鐨勪换鍔$疆涓� pdcType=Y锛�
+ // - 鍥犳 ERP 渚т粛淇濇寔鈥滈�氱煡鍚庤嚜鍔ㄥ嚭搴撯�濈殑浣撻獙锛屽彧鏄换鍔$敓鎴愪粠鎺ュ彛绾跨▼杞Щ鍒颁簡璁㈠崟璋冨害閾捐矾銆�
+ return openService.outOrderCreatePakoutOrder(groupedParams, true);
+ }
- return R.ok();
+ /**
+ * 7.9 鍑哄簱寮傚父鍙樺姩涓婃姤
+ */
+ @PostMapping("/order/pakout/abnormal/report/v1")
+ public synchronized R outOrderAbnormalReport(@RequestBody OutOrderAbnormalReportParam param, HttpServletRequest request) {
+ if (request != null) {
+ log.info("[outOrderAbnormalReport] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
+ if (Cools.isEmpty(param) || Cools.isEmpty(param.getPalletId())) {
+ return R.error("palletId涓嶈兘涓虹┖");
+ }
+ return openService.outOrderAbnormalReport(param);
+ }
+
+ /**
+ * 7.10 鍑哄簱寮傚父鍙樺姩澶勭悊
+ */
+ @PostMapping("/order/pakout/abnormal/handle/v1")
+ public synchronized R outOrderAbnormalHandle(@RequestBody OutOrderAbnormalHandleParam param, HttpServletRequest request) {
+ if (request != null) {
+ log.info("[outOrderAbnormalHandle] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
+ if (Cools.isEmpty(param) || Cools.isEmpty(param.getPalletId())) {
+ return R.error("palletId涓嶈兘涓虹┖");
+ }
+ return openService.outOrderAbnormalHandle(param);
}
/**
* pause out order
*/
@PostMapping("/order/pakout/pause/default/v1")
- public synchronized R pakoutOrderPause(@RequestBody OpenOrderPakoutPauseParam param){
+ public synchronized R pakoutOrderPause(@RequestBody OpenOrderPakoutPauseParam param, HttpServletRequest request) {
+ if (request != null) {
+ log.info("[pakoutOrderPause] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
if (Cools.isEmpty(param) || Cools.isEmpty(param.getOrderId())) {
return R.error("orderNo is empty");
}
return openService.pakoutOrderPause(param);
}
+ /**
+ * 鍏紑鎵ц鎺ュ彛銆�
+ *
+ * IoT/MQTT 绛夐潪 ERP 鍏ュ彛浼氬厛鍒涘缓 status=0 鐨勫嚭搴撹鍗曪紝鍙湁璋冪敤璇ユ帴鍙e悗鎵嶅厑璁哥敓鎴愪换鍔″拰涓嬪彂銆�
+ * 璇ユ帴鍙e彧鏀寔 execute=1锛涗腑姝粛璧� /order/pakout/pause/default/v1 鐨� execute=2銆�
+ */
+ @PostMapping("/order/pakout/execute/default/v1")
+ public synchronized R pakoutOrderExecute(@RequestBody OpenOrderPakoutExecuteParam param, HttpServletRequest request) {
+ if (request != null) {
+ log.info("[pakoutOrderExecute] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
+ if (Cools.isEmpty(param) || Cools.isEmpty(param.getOrderId())) {
+ return R.error("orderNo is empty");
+ }
+ return openService.pakoutOrderExecute(param);
+ }
+
+ private String buildOutOrderValidateKey(OutTaskParam param) {
+ return param.getOrderId() + "#" + resolveOutOrderTaskBatchKey(param);
+ }
+
+ /**
+ * 璁$畻 /outOrder 鍏ュ彛鐨勬渶缁堜换鍔℃壒娆¢敭銆�
+ *
+ * 杩欎釜鍊煎繀椤诲拰 OpenServiceImpl.resolvePakoutTaskBatchSeq 淇濇寔涓�鑷达細
+ * - 楂樼珯鐐癸細entryWmsCode锛�
+ * - 浣庣珯鐐癸細orderId銆�
+ *
+ * 鍏ュ彛鏍¢獙鍜屽悗缁敓鎴愪换鍔′娇鐢ㄥ悓涓�鍙e緞锛屾墠鑳戒繚璇� seq 鏍¢獙銆佹壒娆″畧鍗拰 WCS 涓嬪彂鎵规涓�鑷淬��
+ */
+ private String resolveOutOrderTaskBatchKey(OutTaskParam param) {
+ if (param != null && isPendingOutOrderStation(param.getStationId()) && !Cools.isEmpty(param.getEntryWmsCode())) {
+ return param.getEntryWmsCode();
+ }
+ return param == null ? null : param.getOrderId();
+ }
+
+ private boolean isPendingOutOrderStation(String stationId) {
+ try {
+ return Integer.valueOf(stationId) > 600;
+ } catch (Exception ignored) {
+ return false;
+ }
+ }
+
+ /**
+ * 鎺ㄨ崘鍑哄簱绔欑偣
+ */
+ @PostMapping("/pakoutStaNo")
+ public synchronized R pakoutStaNo(@RequestBody List<String> barcodes) {
+ String StaNo = "1,2,3,4,5";
+ return R.ok().add(StaNo);
+ }
+
/*************************************鐢佃鏈虹▼搴�***********************************************/
@GetMapping("/locDetl/statistics")
- public R locDetlStatistics(){
+ public synchronized R locDetlStatistics(){
HashMap<String, Object> param = new HashMap<>();
Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(1, 100, param, LocDetl.class));
for (LocDetl locDetl : stockStatis.getRecords()) {
@@ -558,20 +819,20 @@
}
@GetMapping("/line/charts")
- public R locIoLineCharts(){
+ public synchronized R locIoLineCharts(){
Map<String,Object> map=new HashMap<String, Object>();
List<AxisBean> list = new ArrayList<AxisBean>();
List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis();
if(listChart!=null) {
- ArrayList<Integer> data1 = new ArrayList<Integer>();
- ArrayList<Integer> data2 = new ArrayList<Integer>();
+ ArrayList<Number> data1 = new ArrayList<Number>();
+ ArrayList<Number> data2 = new ArrayList<Number>();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DATE, -12);
- for(int i=0;i<12;i++) {
+ calendar.add(Calendar.DATE, -7);
+ for(int i=0;i<7;i++) {
boolean flag = true;
calendar.add(Calendar.DATE, 1);
String str = sf.format(calendar.getTime());
@@ -589,17 +850,150 @@
}
}
AxisBean inqty = new AxisBean();
- inqty.setName("鍏ュ簱鏁伴噺");
- Integer[] array1 = new Integer[data1.size()];
+ inqty.setName("鍏ュ簱鎵樼洏鏁�");
+ Number[] array1 = new Number[data1.size()];
inqty.setData(data1.toArray(array1));
list.add(inqty);
AxisBean outqty = new AxisBean();
- outqty.setName("鍑哄簱鏁伴噺");
- Integer[] array2 = new Integer[data2.size()];
+ outqty.setName("鍑哄簱鎵樼洏鏁�");
+ Number[] array2 = new Number[data2.size()];
outqty.setData(data2.toArray(array2));
list.add(outqty);
+
+ AxisBean teu= new AxisBean();
+ teu.setName("TEU");
+ List<WorkTeuTotalAxis> workTeuTotalAxes = reportQueryMapper.getteuTotal();
+ ArrayList<Number> data3 = new ArrayList<Number>();
+ for (WorkTeuTotalAxis w : workTeuTotalAxes) {
+ data3.add(w.getTeu_total());
+ }
+ Number[] array3 = new Number[data3.size()];
+ teu.setData(data3.toArray(array3));
+ list.add(teu);
+
+ AxisBean cube5 = new AxisBean();
+ cube5.setName("鍏ュ簱浣撶Н");
+ List<WorkCubeTotalAxis> workCubeTotalAxes = reportQueryMapper.getInboundCubeTotal();
+ Map<String, WorkCubeTotalAxis> cubeMap = new HashMap<String, WorkCubeTotalAxis>();
+ if (workCubeTotalAxes != null) {
+ for (WorkCubeTotalAxis w : workCubeTotalAxes) {
+ if (w.getYmd() != null) {
+ cubeMap.put(w.getYmd(), w);
+ }
+ }
+ }
+ ArrayList<Number> data4 = new ArrayList<Number>();
+ SimpleDateFormat sfCube = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar calendarCube = Calendar.getInstance();
+ calendarCube.add(Calendar.DATE, -7);
+ for (int i = 0; i < 7; i++) {
+ calendarCube.add(Calendar.DATE, 1);
+ String str = sfCube.format(calendarCube.getTime());
+ WorkCubeTotalAxis cubeAxis = cubeMap.get(str);
+ data4.add(cubeAxis == null || cubeAxis.getCube5Total() == null ? 0 : cubeAxis.getCube5Total());
+ }
+ Number[] array4 = new Number[data4.size()];
+ cube5.setData(data4.toArray(array4));
+ list.add(cube5);
}
map.put("rows",list);
+ return R.ok(map);
+ }
+
+ /**
+ * 鍏ュ嚭搴撴寜灏忔椂鎶樼嚎锛氭í杞翠负銆屽綋鍓嶆暣鐐硅捣鍚戝墠鍏� 12 灏忔椂銆嶆粴鍔ㄧ獥鍙o紝涓庡簱琛� ymd锛坹yyy-MM-dd HH锛夊榻�
+ */
+ @GetMapping("/line/charts/hourly")
+ public synchronized R locIoLineChartsHourly() {
+ Map<String, Object> map = new HashMap<>();
+ List<AxisBean> list = new ArrayList<>();
+
+ List<WorkChartAxis> listChart = reportQueryMapper.getChartAxisHourly();
+ if (listChart == null) {
+ listChart = Collections.emptyList();
+ }
+
+ ArrayList<Integer> data1 = new ArrayList<>();
+ ArrayList<Integer> data2 = new ArrayList<>();
+ ArrayList<Double> data3 = new ArrayList<>();
+ ArrayList<Double> data4 = new ArrayList<>();
+ ArrayList<Double> data5 = new ArrayList<>();
+ List<String> categories = new ArrayList<>();
+
+ final int n = 12;
+ SimpleDateFormat sfKey = new SimpleDateFormat("yyyy-MM-dd HH");
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ calendar.add(Calendar.HOUR_OF_DAY, -(n - 1));
+
+ for (int i = 0; i < n; i++) {
+ String key = sfKey.format(calendar.getTime());
+ categories.add(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
+
+ int inV = 0;
+ int outV = 0;
+ double inC = 0;
+ double outC = 0;
+ double outD = 0;
+ for (WorkChartAxis w : listChart) {
+ if (w.getYmd() != null && key.equals(w.getYmd().trim())) {
+ inV = w.getInqty();
+ outV = w.getOutqty();
+ inC = w.getCubeInqty();
+ outC = w.getCubeOutqty();
+ outD = w.getOutTeu();
+ break;
+ }
+ }
+ data1.add(inV);
+ data2.add(outV);
+ data3.add(inC);
+ data4.add(outC);
+ data5.add(outD);
+ calendar.add(Calendar.HOUR_OF_DAY, 1);
+ }
+
+ AxisBean inqty = new AxisBean();
+ inqty.setName("鍏ュ簱鎵樼洏鏁�");
+ Integer[] array1 = new Integer[data1.size()];
+ inqty.setData(data1.toArray(array1));
+ list.add(inqty);
+
+ AxisBean outqty = new AxisBean();
+ outqty.setName("鍑哄簱鎵樼洏鏁�");
+ Integer[] array2 = new Integer[data2.size()];
+ outqty.setData(data2.toArray(array2));
+ list.add(outqty);
+
+ if (data3.size() >0) {
+ AxisBean cubeInqty = new AxisBean();
+ cubeInqty.setName("鍏ュ簱浣撶Н");
+ Double [] array3 = new Double[data3.size()];
+ cubeInqty.setData(data3.toArray(array3));
+ list.add(cubeInqty);
+ }
+
+ if (data4.size() >0) {
+ AxisBean cubeOutqty = new AxisBean();
+ cubeOutqty.setName("鍑哄簱浣撶Н");
+ Double[] array4 = new Double[data4.size()];
+ cubeOutqty.setData(data4.toArray(array4));
+ list.add(cubeOutqty);
+ }
+
+ if (data5.size() >0) {
+ AxisBean cubeOutqty = new AxisBean();
+ cubeOutqty.setName("鍑哄簱TEU");
+ Double[] array5 = new Double[data4.size()];
+ cubeOutqty.setData(data5.toArray(array5));
+ list.add(cubeOutqty);
+ }
+
+
+ map.put("categories", categories);
+ map.put("rows", list);
return R.ok(map);
}
@@ -634,7 +1028,8 @@
}
// 鎬诲簱浣嶆暟
- Integer total = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
+ Integer total1 = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
+ Integer total = total1>40000?6528:total1;
// 浣跨敤涓�
Integer used = locUseRate.getFqty() + locUseRate.getUqty();
// 搴撲綅浣跨敤鐜�
@@ -656,7 +1051,11 @@
* 浠诲姟鏌ヨ鎺ュ彛
*/
@PostMapping("/queryTask")
- public synchronized R queryTask(@RequestBody QueryTaskParam param) {
+ public synchronized R queryTask(@RequestBody QueryTaskParam param, HttpServletRequest request) {
+ if (request != null) {
+ log.info("[queryTask] cache: {}", param == null ? "null" : JSON.toJSONString(param));
+ request.setAttribute("cache", param);
+ }
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
}
@@ -674,7 +1073,74 @@
map.put("taskNo", param.getTaskNo());
map.put("ioType", wrkMast.getIoType());
map.put("wrkDetls", wrkDetls);
+ Integer count = 0;
+ String supp = "";
+ //璇ヨ鍗曠疮璁″叆鍑哄簱浠舵暟
+ Integer ioType = wrkMast.getIoType();
+ Integer suppCount = 0;
+ Integer sum = 0;
+ if (ioType != null && ioType < 100) {
+ supp = String.valueOf(resolveInboundSupp(wrkMast));
+ map.put("supp", supp);
+ }else {
+ String[] split = wrkDetls.get(0).getSupp().split("/");
+ if (split != null && split.length > 0) {
+ sum = Integer.valueOf(split[split.length - 1]);
+ }else {
+ sum = Integer.valueOf(wrkDetls.get(0).getSupp());
+ }
+ List<WrkMast> userNo = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("user_no", wrkMast.getUserNo()).in("wrk_sts",11,12,21,22,25));
+ suppCount = sum - userNo.size();
+ map.put("supp", suppCount + "/" + sum);
+ }
+
+ //鑰楁椂
+ Long costTime = resolveCostTime(wrkMast);
+ map.put("costTime", String.valueOf(costTime));
+
return R.ok().add(map);
}
+
+ Long resolveCostTime(WrkMast wrkMast) {
+ return resolveCostTime(wrkMast, new Date());
+ }
+
+ Long resolveCostTime(WrkMast wrkMast, Date now) {
+ if (wrkMast == null || wrkMast.getIoType() == null) {
+ return 0L;
+ }
+ if (wrkMast.getIoType() < 100) {
+ if (Cools.isEmpty(wrkMast.getTrainNo())) {
+ return 0L;
+ }
+ return minutesBetween(wrkMastService.firstInboundCreateTimeByTrainNo(wrkMast.getTrainNo()), resolveTaskCreateTime(wrkMast));
+ }
+ return minutesBetween(resolveTaskCreateTime(wrkMast), now);
+ }
+
+ int resolveInboundSupp(WrkMast wrkMast) {
+ if (wrkMast == null || wrkMast.getIoType() == null || wrkMast.getIoType() >= 100 || Cools.isEmpty(wrkMast.getTrainNo())) {
+ return 0;
+ }
+ return wrkMastService.finishedInboundPalletCountByTrainNo(wrkMast.getTrainNo());
+ }
+
+ private Date resolveTaskCreateTime(WrkMast wrkMast) {
+ if (wrkMast == null) {
+ return null;
+ }
+ return wrkMast.getAppeTime() == null ? wrkMast.getIoTime() : wrkMast.getAppeTime();
+ }
+
+ private Long minutesBetween(Date startTime, Date endTime) {
+ if (startTime == null || endTime == null) {
+ return 0L;
+ }
+ long diff = endTime.getTime() - startTime.getTime();
+ if (diff <= 0) {
+ return 0L;
+ }
+ return diff / MILLIS_PER_MINUTE;
+ }
}
--
Gitblit v1.9.1