From 9b2838fd5b53ae5ef4aa7e082e2718cc0ccc4466 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期五, 25 八月 2023 09:30:01 +0800
Subject: [PATCH] U8接口相关功能
---
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java | 308 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 234 insertions(+), 74 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
index e24fd80..3307d90 100644
--- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -10,20 +10,21 @@
import com.zy.asrs.entity.param.*;
import com.zy.asrs.entity.result.OpenOrderCompeteResult;
import com.zy.asrs.entity.result.StockVo;
+import com.zy.asrs.mapper.ReportQueryMapper;
import com.zy.asrs.mapper.TagMapper;
import com.zy.asrs.service.*;
-import com.zy.asrs.task.core.ReturnT;
-import com.zy.asrs.task.handler.WorkLogHandler;
import com.zy.asrs.utils.MatUtils;
import com.zy.common.model.DetlDto;
-import com.zy.common.utils.ListUtils;
import com.zy.common.utils.NodeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
/**
* Created by vincent on 2022/4/9
@@ -55,9 +56,9 @@
@Autowired
private WaitPakinService waitPakinService;
@Autowired
- private WrkMastService wrkMastService;
+ private WrkDetlService wrkDetlService;
@Autowired
- private WorkLogHandler workLogHandler;
+ private ReportQueryMapper reportQueryMapper;
@Override
@Transactional
@@ -488,6 +489,11 @@
matSyncParam.setMats(matParams);
return matSyncParam;
}
+ public void callApiLogSave(MatSyncParam.Mats matParam, String tableName, String response, Boolean bool) {
+ apiLogService.save("ERP涓嬪彂鍟嗗搧淇℃伅", tableName, "null", "10.10.10.1",
+ "鐗╂枡缂栫爜锛�" + matParam.getMatnr() + "銆佺墿鏂欏悕绉帮細" + matParam.getMaktx() + "銆佽鏍硷細" + matParam.getSpecs() + "銆佸娉細" + matParam.getMemo(),
+ response, bool);
+ }
@Override
@@ -495,28 +501,32 @@
public void combMes(CombParam param) {
Long userId=9999l;
if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
+ callApiLogSaveMES(null, null, BaseRes.PARAM, false);
throw new CoolException(BaseRes.PARAM);
+ }
+ if(param.getBarcode().length()!=8){
+ callApiLogSaveMES(param, null, param.getBarcode() + "锛氭潯鐮侀暱搴︿笉鏄�8浣�", false);
+ throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
}
// 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+ callApiLogSaveMES(param, null, param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱", false);
throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
}
- // todo: 涓嶄笅绾块噸鏂板叆搴�
- WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode());
- if (wrkMast != null && wrkMast.getWrkSts() == 18) {
- ReturnT<String> start = workLogHandler.start(wrkMast);
- if (!start.isSuccess()) {
- log.error("宸ヤ綔妗workNo={}]鍘嗗彶妗e鐞嗗け璐�", wrkMast.getWrkNo());
- }
+ int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
+ int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
+ if (countLoc > 0) {
+ callApiLogSaveMES(param, null, param.getBarcode() + "锛氬簱瀛樻潯鐮佹暟鎹凡瀛樺湪", false);
+ throw new CoolException("搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+ }else if (countWrk > 0){
+ callApiLogSaveMES(param, null, param.getBarcode() + "锛氬伐浣滄槑缁嗘。宸插瓨鍦ㄦ鏁版嵁", false);
+ throw new CoolException("宸ヤ綔鏄庣粏妗e凡瀛樺湪姝ゆ暟鎹�===>>" + param.getBarcode());
}
Date now = new Date();
-
- // 鏃犲崟缁勬墭
- if (Cools.isEmpty(param.getOrderNo())) {
-
+ try{
// 鐢熸垚鍏ュ簱閫氱煡妗�
List<DetlDto> detlDtos = new ArrayList<>();
param.getCombMats().forEach(elem -> {
@@ -530,10 +540,10 @@
}
});
-
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
+ callApiLogSaveMES(param, null,mat.getMatnr()+"鍟嗗搧妗f涓嶅瓨鍦�", false);
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
WaitPakin waitPakin = new WaitPakin();
@@ -548,68 +558,218 @@
waitPakin.setModiUser(userId);
waitPakin.setModiTime(now);
if (!waitPakinService.insert(waitPakin)) {
+ callApiLogSaveMES(param, null,mat.getMatnr()+"淇濆瓨鍏ュ簱閫氱煡妗eけ璐�", false);
throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
}
}
- // 鍏宠仈缁勬墭
- } else {
- Order order = orderService.selectByNo(param.getOrderNo());
- if (Cools.isEmpty(order)){
- throw new CoolException("鍗曟嵁涓嶅瓨鍦�:"+param.getOrderNo());
- }
- if (order.getSettle() > 2) {
- throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
- }
- // 鐢熸垚鍏ュ簱閫氱煡妗�
- List<DetlDto> detlDtos = new ArrayList<>();
- param.getCombMats().forEach(elem -> {
-
- // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
- OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
- if (elem.getAnfme() > orderDetl.getEnableQty()) {
- throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
- }
- // 淇敼璁㈠崟鏄庣粏鏁伴噺
- if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) {
- throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
- }
-
- DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
- if (DetlDto.has(detlDtos, detlDto)) {
- DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
- assert one != null;
- one.setAnfme(one.getAnfme() + detlDto.getAnfme());
- } else {
- detlDtos.add(detlDto);
- }
- });
- for (DetlDto detlDto : detlDtos) {
- Mat mat = matService.selectByMatnr(detlDto.getMatnr());
- if (Cools.isEmpty(mat)) {
- throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
- }
- WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
- waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿
- waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮�
- waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
- waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
- waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
- waitPakin.setStatus("Y"); // 鐘舵��
- waitPakin.setAppeUser(userId);
- waitPakin.setAppeTime(now);
- waitPakin.setModiUser(userId);
- waitPakin.setModiTime(now);
- if (!waitPakinService.insert(waitPakin)) {
- throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
- }
- }
- orderService.updateSettle(order.getId(), 2L, userId);
+ }catch (Exception e){
+ callApiLogSaveMES(null, null,""+e, false);
+ }
+ callApiLogSaveMES(param, param.getCombMats().get(0),"缁勬墭鎴愬姛", true);
+ }
+ public void callApiLogSaveMES(CombParam combParam,CombParam.CombMat combMat, String response, Boolean bool) {
+ if (Cools.isEmpty(combParam)){
+ apiLogService.save("MES涓嬪彂鍏ュ簱閫氱煡鍗�", "/open/asrs/comb/v1", "null", "10.10.10.1",
+ "",
+ response, bool);
+ }else if (Cools.isEmpty(combMat)){
+ apiLogService.save("MES涓嬪彂鍏ュ簱閫氱煡鍗�", "/open/asrs/comb/v1", "null", "10.10.10.1",
+ "鎵樼洏鐮侊細" + combParam.getBarcode(),
+ response, bool);
+ }else {
+ apiLogService.save("MES涓嬪彂鍏ュ簱閫氱煡鍗�", "/open/asrs/comb/v1", "null", "10.10.10.1",
+ "鎵樼洏鐮侊細" + combParam.getBarcode() + "銆佺墿鏂欑紪鍙凤細" + combMat.getMatnr() + "銆佹暟閲忥細" + combMat.getAnfme(),
+ response, bool);
}
}
- public void callApiLogSave(MatSyncParam.Mats matParam, String tableName, String response, Boolean bool) {
+
+ /**
+ * 鍏ュ簱璁板綍鑾峰彇
+ */
+ @Override
+ @Transactional
+ public List<ViewWorkInBean> inlogERP() {
+ List<ViewWorkInBean> viewWorkInERP = reportQueryMapper.getViewWorkInERP();
+ ArrayList<ViewWorkInBean> viewWorkInBeans = new ArrayList<>();
+ for (ViewWorkInBean viewWorkInBean:viewWorkInERP){
+ viewWorkInBean.sype();
+ viewWorkInBeans.add(viewWorkInBean);
+ }
+ return viewWorkInBeans;
+ }
+
+ /**
+ * 鍑哄簱璁板綍鑾峰彇
+ */
+ @Override
+ @Transactional
+ public List<ViewWorkInBean> outlogERP() {
+ List<ViewWorkInBean> viewWorkInERP = reportQueryMapper.getViewWorkOutERP();
+ ArrayList<ViewWorkInBean> viewWorkInBeans = new ArrayList<>();
+ for (ViewWorkInBean viewWorkInBean:viewWorkInERP){
+ viewWorkInBean.sype();
+ viewWorkInBeans.add(viewWorkInBean);
+ }
+ return viewWorkInBeans;
+ }
+
+ @Transactional
+ public boolean syncMat(MatInfoParam param) {
+ if(!Cools.isEmpty(matService.selectByMatnr(param.getCinvcode()))){
+ callApiLogSave(param, "/open/asrs/mat/v1", "鎺ユ敹ERP涓嬪彂鍟嗗搧淇℃伅澶辫触锛侊紒锛佸晢鍝佸凡瀛樺湪锛侊紒锛�", false);
+ param.setType(false);
+ param.setMemo("鍟嗗搧宸插瓨鍦紒");
+ return false;
+ }
+ Date now = new Date();
+ Mat mat = new Mat();
+ //鐗╂枡鍙�
+ mat.setMatnr(param.getCinvcode());
+ //鐗╂枡鍚嶇О
+ mat.setMaktx(param.getCinvname());
+ //瑙勬牸鍨嬪彿
+ mat.setSpecs(param.getCInvStd());
+ //瀛樿揣鍒嗙被缂栫爜
+ mat.setBrand(param.getCinvccode());
+ //瀛樿揣鍒嗙被鍚嶇О
+ mat.setColor(param.getCInvCName());
+ //璁¢噺鍗曚綅
+ mat.setUnit(param.getCComUnitName());
+ //杩涢」绋�
+ mat.setPrice(param.getIImpTaxRate());
+ //閿�椤圭◣
+ mat.setUnits(param.getITaxRate());
+ //鍚敤鏃ユ湡
+ mat.setDsDate(param.getDSDate());
+ //寤烘。浜�
+ mat.setSupp(param.getCCreatePerson());
+ //寤烘。鏃ユ湡
+ mat.setDInvCreateDatetime(param.getDInvCreateDatetime());
+ //閫氱敤鍨嬪彿
+ mat.setModel(param.getCinvdefine4());
+
+ mat.setCreateTime(now);
+ mat.setUpdateTime(now);
+
+ if (matService.insert(mat)) {
+ callApiLogSave(param, "/open/asrs/mat/v1", "鎺ユ敹ERP涓嬪彂鍟嗗搧淇℃伅鎴愬姛锛佹坊鍔犲晢鍝佷俊鎭垚鍔燂紒", true);
+ param.setType(true);
+ } else {
+ callApiLogSave(param, "/open/asrs/mat/v1", "娣诲姞ERP涓嬪彂鍟嗗搧淇℃伅澶辫触锛侊紒锛佺姸鎬佸紓甯革紒锛侊紒", false);
+ param.setType(false);
+ param.setMemo("娣诲姞ERP涓嬪彂鍟嗗搧淇℃伅澶辫触锛�");
+ }
+
+ matService.insert(mat);
+
+ return true;
+ }
+
+ @Transactional
+ public boolean syncOrder(Map<String, Object> param) {
+ if(Cools.isEmpty(param) || Cools.isEmpty(param.get("orderDetails"))){
+ throw new CoolException("鍗曟嵁鍙傛暟涓虹┖鎴栬�呭崟鎹鎯呬负绌猴紝鏃犳硶鐢熸垚鍗曟嵁淇℃伅");
+ }
+
+ if(!Cools.isEmpty(orderService.selectByNo(param.get("id").toString()))){
+ throw new CoolException("璇ュ崟鎹凡瀛樺湪锛屾棤娉曠敓鎴愬崟鎹俊鎭�");
+ }
+ Order order = orderMapping(param);
+ orderService.insert(order);
+ List<Map<String, Object>> orderDetails = (List<Map<String, Object>>) param.get("orderDetails");
+ orderDetails.forEach(odParam -> {
+ OrderDetl od = orderDetlMapping(order.getOrderNo(),odParam);
+ orderDetlService.insert(od);
+ });
+
+ return true;
+ }
+
+ @Transactional
+ public boolean orderDelete(String orderNo) {
+ Order order = orderService.selectByNo(orderNo);
+ if(Cools.isEmpty(order)){
+ throw new CoolException("鍗曟嵁涓嶅瓨鍦紝鏃犳硶鍒犻櫎鍗曟嵁");
+ }
+
+ if(order.getSettle() != 1){
+ return false;
+ }
+
+ orderService.deleteById(order);
+ orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_no",orderNo));
+
+ return true;
+ }
+
+ private Order orderMapping(Map<String, Object> param){
+ Date now = new Date();
+ Order order = new Order();
+ //uuid
+ order.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
+ //鏍哥畻涓讳綋
+ order.setItemName(param.get("account").toString());
+ //鍗曟嵁鍞竴琛ㄧず
+ order.setOrderNo(param.get("id").toString());
+ //涓氬姟绫诲瀷
+ order.setDefNumber(param.get("cBusType").toString());
+ //鍗曟嵁绫诲瀷
+ DocType docType = docTypeService.selectOrAdd(param.get("cVouchType").toString(), Boolean.TRUE);
+ order.setDocType(docType.getDocId());
+ //鍗曟嵁鏃ユ湡
+ order.setOrderTime(param.get("dDate").toString());
+ //渚涘簲鍟�/瀹㈡埛缂栫爜
+ order.setCstmrName(param.get("ks").toString());
+ //浠撳簱
+ order.setTel(param.get("cWhName").toString());
+ //鍑哄叆搴撶被鍒�
+ order.setOperMemb(param.get("cRdName").toString());
+ //閮ㄩ棬
+ order.setSalesman(param.get("cDepCode").toString());
+ //澶囨敞
+ order.setMemo(param.get("cMemo").toString());
+ //鍒跺崟浜�
+ order.setShipCode(param.get("cMaker").toString());
+
+ order.setCreateTime(now);
+ order.setUpdateTime(now);
+
+ //璁㈠崟鐘舵��
+ order.setSettle(1L);
+ //鐘舵��
+ order.setStatus(1);
+ return order;
+ }
+
+ private OrderDetl orderDetlMapping(String orderId, Map<String, Object> odParam){
+ OrderDetl od = new OrderDetl();
+ od.setOrderNo(orderId);
+ //琛屽敮涓�鏍囪瘑
+ od.setItemNum(odParam.get("autoId").toString());
+ //瀛樿揣缂栫爜
+ od.setMatnr(odParam.get("cInvCode").toString());
+ //瀛樿揣鍚嶇О
+ od.setMaktx(odParam.get("cInvName").toString());
+ //瑙勬牸鍨嬪彿
+ od.setSpecs(odParam.get("cInvStd").toString());
+ //璁¢噺鍗曚綅
+ od.setUnit(odParam.get("cComUnitName").toString());
+ //鏁伴噺
+ od.setAnfme(Double.parseDouble(odParam.get("iQuantity").toString()));
+ //琛屽彿
+ od.setBrand(odParam.get("irowno").toString());
+ //閿�鍞鍗曞彿
+ od.setColor(odParam.get("csocode").toString());
+ //閿�鍞鍗曡鍙�
+ od.setOrigin(odParam.get("isoseq").toString());
+
+ return od;
+ }
+
+
+ public void callApiLogSave(MatInfoParam matParam, String tableName, String response, Boolean bool) {
apiLogService.save("ERP涓嬪彂鍟嗗搧淇℃伅", tableName, "null", "10.10.10.1",
- "鐗╂枡缂栫爜锛�" + matParam.getMatnr() + "銆佺墿鏂欏悕绉帮細" + matParam.getMaktx() + "銆佽鏍硷細" + matParam.getSpecs() + "銆佸娉細" + matParam.getMemo(),
+ "鐗╂枡缂栫爜锛�" + matParam.getCinvcode() + "銆佺墿鏂欏悕绉帮細" + matParam.getCinvname() + "銆佽鏍硷細" + matParam.getCInvStd() + "銆佸娉細" + matParam.getMemo(),
response, bool);
}
--
Gitblit v1.9.1