From fb4e25eb597358276470daeb9df7a40e0d622616 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期六, 09 四月 2022 14:37:33 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/entity/param/OpenOrderCompleteParam.java | 13 ++
version/自动化立库平台对接协议.docx | 0
src/main/java/com/zy/asrs/controller/OpenController.java | 146 ++++-------------------
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java | 137 ++++++++++++++++++++++
src/main/java/com/zy/asrs/service/OpenService.java | 27 ++++
5 files changed, 206 insertions(+), 117 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 7edb05f..8002f80 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,23 +1,18 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
-import com.core.common.*;
+import com.core.common.BaseRes;
+import com.core.common.Cools;
+import com.core.common.R;
import com.core.exception.CoolException;
-import com.zy.asrs.entity.DocType;
-import com.zy.asrs.entity.Mat;
-import com.zy.asrs.entity.Order;
-import com.zy.asrs.entity.OrderDetl;
+import com.zy.asrs.entity.param.OpenOrderCompleteParam;
import com.zy.asrs.entity.param.OpenOrderPakinParam;
-import com.zy.asrs.service.*;
-import com.zy.common.model.DetlDto;
+import com.zy.asrs.service.OpenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
/**
* Created by vincent on 2022/4/8
@@ -27,40 +22,20 @@
@RequestMapping("open/asrs")
public class OpenController {
+ private static final boolean auth = false;
public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{
add("ea1f0459efc02a79f046f982767939ae");
}};
@Autowired
- private OrderService orderService;
- @Autowired
- private OrderDetlService orderDetlService;
- @Autowired
- private SnowflakeIdWorker snowflakeIdWorker;
- @Autowired
- private DocTypeService docTypeService;
- @Autowired
- private MatService matService;
- @Autowired
- private LocDetlService locDetlService;
-
- private void auth(String appkey, Object obj) {
- log.info("{}鎺ュ彛琚闂紒appkey:{},璇锋眰鏁版嵁锛歿}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
- if (Cools.isEmpty(appkey)) {
- throw new CoolException("璁よ瘉澶辫触锛岃纭appkey鏃犺锛�");
- }
- if (!APP_KEY_LIST.contains(appkey)) {
- throw new CoolException("璁よ瘉澶辫触锛岃纭appkey鏃犺锛�");
- }
- }
+ private OpenService openService;
/**
* 娣诲姞鍏ュ簱鍗�
*/
@PostMapping("/order/pakin/new/default/v1")
- @Transactional
- public synchronized R orderCreate(@RequestHeader(required = false) String appkey,
- @RequestBody OpenOrderPakinParam param) {
+ public synchronized R pakinOrderCreate(@RequestHeader(required = false) String appkey,
+ @RequestBody OpenOrderPakinParam param) {
auth(appkey, param);
if (Cools.isEmpty(param)) {
return R.parse(BaseRes.PARAM);
@@ -74,84 +49,7 @@
if (Cools.isEmpty(param.getOrderDetails())) {
return R.error("鍗曟嵁鏄庣粏[orderDetails]涓嶈兘涓虹┖");
}
- Order order = orderService.selectByNo(param.getOrderNo());
- if (!Cools.isEmpty(order)) {
- return R.error(param.getOrderNo() + "鍗曟嵁宸插瓨鍦紝璇峰嬁閲嶅鎻愪氦");
- }
- DocType docType = docTypeService.selectOrAdd(param.getOrderType());
- Date now = new Date();
- // 鍗曟嵁涓绘。
- order = new Order(
- String.valueOf(snowflakeIdWorker.nextId()), // 缂栧彿[闈炵┖]
- param.getOrderNo(), // 璁㈠崟缂栧彿
- DateUtils.convert(now), // 鍗曟嵁鏃ユ湡
- docType.getDocId(), // 鍗曟嵁绫诲瀷
- null, // 椤圭洰缂栧彿
- null, //
- null, // 璋冩嫧椤圭洰缂栧彿
- null, // 鍒濆绁ㄦ嵁鍙�
- null, // 绁ㄦ嵁鍙�
- null, // 瀹㈡埛缂栧彿
- null, // 瀹㈡埛
- null, // 鑱旂郴鏂瑰紡
- null, // 鎿嶄綔浜哄憳
- null, // 鍚堣閲戦
- null, // 浼樻儬鐜�
- null, // 浼樻儬閲戦
- null, // 閿�鍞垨閲囪喘璐圭敤鍚堣
- null, // 瀹炰粯閲戦
- null, // 浠樻绫诲瀷
- null, // 涓氬姟鍛�
- null, // 缁撶畻澶╂暟
- null, // 閭垂鏀粯绫诲瀷
- null, // 閭垂
- null, // 浠樻鏃堕棿
- null, // 鍙戣揣鏃堕棿
- null, // 鐗╂祦鍚嶇О
- null, // 鐗╂祦鍗曞彿
- 1L, // 璁㈠崟鐘舵��
- 1, // 鐘舵��
- 9527L, // 娣诲姞浜哄憳
- now, // 娣诲姞鏃堕棿
- 9527L, // 淇敼浜哄憳
- now, // 淇敼鏃堕棿
- null // 澶囨敞
- );
- if (!orderService.insert(order)) {
- throw new CoolException("鐢熸垚鍗曟嵁涓绘。澶辫触锛岃鑱旂郴绠$悊鍛�");
- }
- // 鍗曟嵁鏄庣粏妗�
- List<DetlDto> list = new ArrayList<>();
- List<DetlDto> orderDetails = param.getOrderDetails();
- for (DetlDto detail : orderDetails) {
- DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
- if (DetlDto.has(list, dto)) {
- DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
- assert detlDto != null;
- detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
- } else {
- list.add(dto);
- }
- }
- for (DetlDto detlDto : list) {
- Mat mat = matService.selectByMatnr(detlDto.getMatnr());
- if (Cools.isEmpty(mat)) {
- throw new CoolException(detlDto.getMatnr() + "缂栧彿鍟嗗搧妫�绱㈠け璐ワ紝璇峰厛娣诲姞鍟嗗搧");
- }
- OrderDetl orderDetl = new OrderDetl();
- orderDetl.sync(mat);
- orderDetl.setOrderId(order.getId());
- orderDetl.setOrderNo(order.getOrderNo());
- orderDetl.setCreateBy(9527L);
- orderDetl.setCreateTime(now);
- orderDetl.setUpdateBy(9527L);
- orderDetl.setUpdateTime(now);
- orderDetl.setStatus(1);
- orderDetl.setQty(0.0D);
- if (!orderDetlService.insert(orderDetl)) {
- throw new CoolException("鐢熸垚鍗曟嵁鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�");
- }
- }
+ openService.pakinOrderCreate(param);
return R.ok();
}
@@ -159,10 +57,10 @@
* 鍏ュ簱鍗曞洖鍐�
*/
@PostMapping("/order/pakin/complete/default/v1")
- @Transactional
- public synchronized R orderComplete(@RequestHeader(required = false) String appkey) {
- auth(appkey, null);
- return R.ok();
+ public synchronized R orderComplete(@RequestHeader(required = false) String appkey,
+ @RequestBody OpenOrderCompleteParam param) {
+ auth(appkey, param);
+ return R.ok().add(openService.pakinOrderComplete(param));
}
/**
@@ -171,7 +69,21 @@
@RequestMapping("/stock/default/v1")
public R queryStock(@RequestHeader(required = false) String appkey) {
auth(appkey, null);
- return R.ok(locDetlService.queryStockTotal());
+ return R.ok().add(openService.queryStock());
+ }
+
+
+ private void auth(String appkey, Object obj) {
+ log.info("{}鎺ュ彛琚闂紒appkey:{},璇锋眰鏁版嵁锛歿}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
+ if (!auth) {
+ return;
+ }
+ if (Cools.isEmpty(appkey)) {
+ throw new CoolException("璁よ瘉澶辫触锛岃纭appkey鏃犺锛�");
+ }
+ if (!APP_KEY_LIST.contains(appkey)) {
+ throw new CoolException("璁よ瘉澶辫触锛岃纭appkey鏃犺锛�");
+ }
}
}
diff --git a/src/main/java/com/zy/asrs/entity/param/OpenOrderCompleteParam.java b/src/main/java/com/zy/asrs/entity/param/OpenOrderCompleteParam.java
new file mode 100644
index 0000000..d7020f0
--- /dev/null
+++ b/src/main/java/com/zy/asrs/entity/param/OpenOrderCompleteParam.java
@@ -0,0 +1,13 @@
+package com.zy.asrs.entity.param;
+
+import lombok.Data;
+
+/**
+ * Created by vincent on 2022/4/9
+ */
+@Data
+public class OpenOrderCompleteParam {
+
+ private String orderNo;
+
+}
diff --git a/src/main/java/com/zy/asrs/service/OpenService.java b/src/main/java/com/zy/asrs/service/OpenService.java
new file mode 100644
index 0000000..8fa76d2
--- /dev/null
+++ b/src/main/java/com/zy/asrs/service/OpenService.java
@@ -0,0 +1,27 @@
+package com.zy.asrs.service;
+
+import com.zy.asrs.entity.param.OpenOrderCompleteParam;
+import com.zy.asrs.entity.param.OpenOrderPakinParam;
+import com.zy.asrs.entity.result.StockVo;
+
+import java.util.List;
+
+public interface OpenService {
+
+ /**
+ * 娣诲姞鍏ュ簱鍗�
+ */
+ void pakinOrderCreate(OpenOrderPakinParam param);
+
+ /**
+ * 鍏ュ簱鍗曞洖鍐�
+ */
+ Object pakinOrderComplete(OpenOrderCompleteParam param);
+
+ /**
+ * 搴撳瓨缁熻
+ */
+ List<StockVo> queryStock();
+
+
+}
diff --git a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
new file mode 100644
index 0000000..98eb4bd
--- /dev/null
+++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -0,0 +1,137 @@
+package com.zy.asrs.service.impl;
+
+import com.core.common.Cools;
+import com.core.common.DateUtils;
+import com.core.common.SnowflakeIdWorker;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.DocType;
+import com.zy.asrs.entity.Mat;
+import com.zy.asrs.entity.Order;
+import com.zy.asrs.entity.OrderDetl;
+import com.zy.asrs.entity.param.OpenOrderCompleteParam;
+import com.zy.asrs.entity.param.OpenOrderPakinParam;
+import com.zy.asrs.entity.result.StockVo;
+import com.zy.asrs.service.*;
+import com.zy.common.model.DetlDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by vincent on 2022/4/9
+ */
+@Service
+public class OpenServiceImpl implements OpenService {
+
+ @Autowired
+ private OrderService orderService;
+ @Autowired
+ private OrderDetlService orderDetlService;
+ @Autowired
+ private SnowflakeIdWorker snowflakeIdWorker;
+ @Autowired
+ private DocTypeService docTypeService;
+ @Autowired
+ private MatService matService;
+ @Autowired
+ private LocDetlService locDetlService;
+
+ @Override
+ @Transactional
+ public void pakinOrderCreate(OpenOrderPakinParam param) {
+ Order order = orderService.selectByNo(param.getOrderNo());
+ if (!Cools.isEmpty(order)) {
+ throw new CoolException(param.getOrderNo() + "鍗曟嵁宸插瓨鍦紝璇峰嬁閲嶅鎻愪氦");
+ }
+ DocType docType = docTypeService.selectOrAdd(param.getOrderType());
+ Date now = new Date();
+ // 鍗曟嵁涓绘。
+ order = new Order(
+ String.valueOf(snowflakeIdWorker.nextId()), // 缂栧彿[闈炵┖]
+ param.getOrderNo(), // 璁㈠崟缂栧彿
+ DateUtils.convert(now), // 鍗曟嵁鏃ユ湡
+ docType.getDocId(), // 鍗曟嵁绫诲瀷
+ null, // 椤圭洰缂栧彿
+ null, //
+ null, // 璋冩嫧椤圭洰缂栧彿
+ null, // 鍒濆绁ㄦ嵁鍙�
+ null, // 绁ㄦ嵁鍙�
+ null, // 瀹㈡埛缂栧彿
+ null, // 瀹㈡埛
+ null, // 鑱旂郴鏂瑰紡
+ null, // 鎿嶄綔浜哄憳
+ null, // 鍚堣閲戦
+ null, // 浼樻儬鐜�
+ null, // 浼樻儬閲戦
+ null, // 閿�鍞垨閲囪喘璐圭敤鍚堣
+ null, // 瀹炰粯閲戦
+ null, // 浠樻绫诲瀷
+ null, // 涓氬姟鍛�
+ null, // 缁撶畻澶╂暟
+ null, // 閭垂鏀粯绫诲瀷
+ null, // 閭垂
+ null, // 浠樻鏃堕棿
+ null, // 鍙戣揣鏃堕棿
+ null, // 鐗╂祦鍚嶇О
+ null, // 鐗╂祦鍗曞彿
+ 1L, // 璁㈠崟鐘舵��
+ 1, // 鐘舵��
+ 9527L, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ 9527L, // 淇敼浜哄憳
+ now, // 淇敼鏃堕棿
+ null // 澶囨敞
+ );
+ if (!orderService.insert(order)) {
+ throw new CoolException("鐢熸垚鍗曟嵁涓绘。澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ // 鍗曟嵁鏄庣粏妗�
+ List<DetlDto> list = new ArrayList<>();
+ List<DetlDto> orderDetails = param.getOrderDetails();
+ for (DetlDto detail : orderDetails) {
+ DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
+ if (DetlDto.has(list, dto)) {
+ DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
+ assert detlDto != null;
+ detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
+ } else {
+ list.add(dto);
+ }
+ }
+ for (DetlDto detlDto : list) {
+ Mat mat = matService.selectByMatnr(detlDto.getMatnr());
+ if (Cools.isEmpty(mat)) {
+ throw new CoolException(detlDto.getMatnr() + "缂栧彿鍟嗗搧妫�绱㈠け璐ワ紝璇峰厛娣诲姞鍟嗗搧");
+ }
+ OrderDetl orderDetl = new OrderDetl();
+ orderDetl.sync(mat);
+ orderDetl.setOrderId(order.getId());
+ orderDetl.setOrderNo(order.getOrderNo());
+ orderDetl.setCreateBy(9527L);
+ orderDetl.setCreateTime(now);
+ orderDetl.setUpdateBy(9527L);
+ orderDetl.setUpdateTime(now);
+ orderDetl.setStatus(1);
+ orderDetl.setQty(0.0D);
+ if (!orderDetlService.insert(orderDetl)) {
+ throw new CoolException("鐢熸垚鍗曟嵁鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ }
+ }
+
+ @Override
+ public Object pakinOrderComplete(OpenOrderCompleteParam param) {
+ return null;
+ }
+
+ @Override
+ @Transactional
+ public List<StockVo> queryStock() {
+ return locDetlService.queryStockTotal();
+ }
+
+}
diff --git "a/version/\350\207\252\345\212\250\345\214\226\347\253\213\345\272\223\345\271\263\345\217\260\345\257\271\346\216\245\345\215\217\350\256\256.docx" "b/version/\350\207\252\345\212\250\345\214\226\347\253\213\345\272\223\345\271\263\345\217\260\345\257\271\346\216\245\345\215\217\350\256\256.docx"
new file mode 100644
index 0000000..9703d92
--- /dev/null
+++ "b/version/\350\207\252\345\212\250\345\214\226\347\253\213\345\272\223\345\271\263\345\217\260\345\257\271\346\216\245\345\215\217\350\256\256.docx"
Binary files differ
--
Gitblit v1.9.1