From 096ed3f92817b4f95f90b2a572667ecb6679c91a Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期一, 14 八月 2023 16:01:31 +0800
Subject: [PATCH] 优化
---
igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java | 272 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 196 insertions(+), 76 deletions(-)
diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
index 8f53a96..7e92309 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
@@ -3,11 +3,11 @@
import com.ld.igds.check.CheckStandardManager;
import com.ld.igds.check.dto.CheckItemData;
import com.ld.igds.check.dto.CheckUpdateResult;
-import com.ld.igds.common.CoreCommonService;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.data.Page;
import com.ld.igds.data.PageResponse;
import com.ld.igds.file.CoreFileService;
+import com.ld.igds.file.dto.FileData;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutCheckData;
import com.ld.igds.inout.dto.InoutCheckParam;
@@ -20,9 +20,6 @@
import com.ld.igds.models.InoutSysConf;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
-
-import lombok.extern.slf4j.Slf4j;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
@@ -30,7 +27,6 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
-
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -40,7 +36,6 @@
*
* @author
*/
-@Slf4j
@Component
public class InoutManager {
@@ -49,13 +44,13 @@
@Resource
private CoreFileService fileService;
@Resource
- private CoreCommonService commonService;
- @Resource
private InoutCommonService inoutCommonService;
@Resource
private CheckStandardManager checkStandardManager;
@Resource
- private InoutDeviceManager inoutDeviceManager;
+ private InoutEventControlManager inoutEventControl;
+ @Resource
+ private CoreFileService coreFileService;
/**
* 鐩存帴浠庢暟鎹簱鏌ヨ锛屼笉鑰冭檻淇℃伅鐘舵��
@@ -199,9 +194,12 @@
* @param data
* @return
*/
- private InoutData updateCheckItems(InoutData data) throws Exception {
+ private InoutData updateCheckItems(InoutData data, boolean toSave) throws Exception {
if (null == data.getCheckItems()) return data;
+
+ //璁剧疆娌℃湁璐ㄦID锛屽彇娑堟墽琛屾寔涔呭寲
+ if (!toSave) data.setCheckId(null);
// 鏇存柊妫�楠岄」鏁版嵁
CheckUpdateResult checkUpdateResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
@@ -216,6 +214,22 @@
return data;
}
+ private InoutData updateFiles(InoutData data) throws Exception {
+ List<FileData> files = data.getFiles();
+ if (null == files) {
+ return data;
+ }
+
+ for (FileData fileData : files) {
+ fileData.setFileId(ContextUtil.getUUID());
+ fileData.setCompanyId(data.getCompanyId());
+ fileData.setBizId(data.getId());
+ fileData.setCreateTime(new Date());
+ coreFileService.addRecord(fileData);
+ }
+
+ return data;
+ }
/**
* 浠庣紦瀛樹腑鑾峰彇涓嬩竴娴佺▼
@@ -293,46 +307,6 @@
return data;
}
- public PageResponse<InoutData> submitComplete(InoutData data)
- throws Exception {
-
- if (StringUtils.isEmpty(data.getId())
- || StringUtils.isEmpty(data.getType())
- || StringUtils.isEmpty(data.getProgress())) {
-
- return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
- "娌℃湁鑾峰彇鍒拌溅杈嗕俊鎭��", data);
- }
-
- data.setUpdateTime(new Date());
- if (null == data.getCompleteTime()) {
- data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2));
- }
- if (null == data.getCompleteUser()) {
- data.setCompleteUser(ContextUtil.getLoginUserCName());
- }
-
- // 璁剧疆娴佺▼鑺傜偣鐩存帴瀹屾垚
- InoutParam param = new InoutParam();
- param.setCompanyId(data.getCompanyId());
- param.setId(data.getId());
- param.setType(data.getType());
- param.setDeptId(data.getDeptId());
- param.setIntelCard(data.getIntelCard());
- param.setUserId(data.getCompleteUser());
- param.setDepotId(data.getDepotId());
- param.setCompleteTime(data.getCompleteTime());
- param.setProgress(InoutConstant.PROGRESS_RECORD);
-
- String msg = inoutService.toComplete(param);
-
- if (null != msg) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
- }
-
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
- }
-
/**
* 鍗″洖鏀堕�昏緫澶勭悊
*
@@ -371,6 +345,52 @@
return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
data);
+ }
+
+
+ public PageResponse<InoutData> submitComplete(InoutData data)
+ throws Exception {
+
+ if (StringUtils.isEmpty(data.getId())
+ || StringUtils.isEmpty(data.getType())
+ || StringUtils.isEmpty(data.getProgress())) {
+
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+ "娌℃湁鑾峰彇鍒拌溅杈嗕俊鎭��", data);
+ }
+
+ data.setUpdateTime(new Date());
+ if (null == data.getCompleteTime()) {
+ data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2));
+ }
+ if (null == data.getCompleteUser()) {
+ data.setCompleteUser(ContextUtil.getLoginUserCName());
+ }
+
+ // 璁剧疆娴佺▼鑺傜偣鐩存帴瀹屾垚
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setId(data.getId());
+ param.setType(data.getType());
+ param.setDeptId(data.getDeptId());
+ param.setIntelCard(data.getIntelCard());
+ param.setUserId(data.getCompleteUser());
+ param.setDepotId(data.getDepotId());
+ param.setCompleteTime(new Date());
+ param.setProgress(InoutConstant.PROGRESS_RECORD);
+
+ String msg = inoutService.toComplete(param);
+
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+ }
+ data.setCompleteTime(param.getCompleteTime());
+ data.setProgress(InoutConstant.PROGRESS_RECORD);
+ inoutService.updateInoutCache(data);
+ // 娴佺▼瀹屾垚鏀朵簨浠�
+ inoutEventControl.onInoutComplete(data);
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
}
/**
@@ -424,7 +444,7 @@
data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10));
}
- data = this.updateCheckItems(data);
+ data = this.updateCheckItems(data, false);
} else {
if (null == data.getEmptyWeightTime()) {
data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50));
@@ -434,8 +454,16 @@
}
}
- // 娣诲姞琛ュ崟鏁版嵁
- return inoutService.insertData(data);
+
+ //鍏堜繚瀛樹富琛紝鍚庢墽琛屽瓙琛�
+ inoutService.insertData(data);
+
+ if (InoutConstant.TYPE_IN.equals(data.getType())) {
+ this.updateCheckItems(data, true);
+ }
+ this.updateFiles(data);
+
+ return null;
}
/**
@@ -459,7 +487,7 @@
// 淇濆瓨妫�娴嬮」鐩�
if (InoutConstant.TYPE_IN.equals(data.getType())) {
- data = updateCheckItems(data);
+ data = updateCheckItems(data, true);
}
return inoutService.updateData(data);
@@ -546,8 +574,13 @@
return msg;
}
- public void initLpr(InoutConf conf) {
- inoutDeviceManager.initLpr(conf);
+ /**
+ * 鍑哄叆搴撶櫥璁板垵濮嬪寲
+ *
+ * @param conf 杞︾墝璇嗗埆閰嶇疆淇℃伅
+ */
+ public void initInoutRegister(InoutConf conf) {
+ inoutEventControl.initInoutRegister(conf);
}
/**
@@ -557,8 +590,7 @@
* @return
* @throws Exception
*/
- public PageResponse<InoutData> submitRegisterInout(InoutData data)
- throws Exception {
+ public PageResponse<InoutData> submitRegisterInout(InoutData data) throws Exception {
// 棣栧厛鍒ゆ柇娴佺▼涓槸鍚︽湁宸茬粡瀛樺湪鐨勮溅杈嗕俊鎭湭鎵ц瀹屾垚锛岀洿鎺ヤ粠鏁版嵁搴撲腑鏌ヨ
InoutParam param = new InoutParam();
@@ -592,20 +624,20 @@
String msg = inoutService.insertData(data);
if (null != msg) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
- data);
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
}
// 鎵ц闄勪欢淇℃伅
- fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
- data.getId(), curProgress);
+ fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
+
+ //鐧昏瀹屾垚浜嬩欢
+ inoutEventControl.onInoutRegister(data);
return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
data);
}
- public PageResponse<InoutData> submitWeightIn(InoutData data)
- throws Exception {
+ public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception {
// 鑾峰彇绯荤粺鍙傛暟閰嶇疆
InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
data.getCompanyId(), data.getDeptId());
@@ -621,7 +653,7 @@
data = updateBasicInfo(data, curProgress, nextProgress);
// 鍏ュ簱绉伴噸鍙兘璋冩暣璐ㄦ鍗�
- data = updateCheckItems(data);
+ data = updateCheckItems(data, true);
// 鎵ц鏁版嵁鏇存柊
String msg = inoutService.updateData(data);
@@ -632,14 +664,12 @@
}
// 鎵ц闄勪欢淇℃伅
- fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
- data.getId(), curProgress);
+ fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
- // 绉伴噸瀹屾垚锛岃皟鐢ㄥ嚭鍏ュ簱鎺у埗閫昏緫澶勭悊
- inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
+ // 绉伴噸瀹屾垚浜嬩欢
+ inoutEventControl.onInoutWeight(data, curProgress, nextProgress);
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
- data);
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
}
public PageResponse<InoutData> submitWeightOut(InoutData data)
@@ -670,11 +700,11 @@
fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
data.getId(), curProgress);
- // 绉伴噸鍚庢牴鎹綋鍓嶆祦绋嬬姸鎬佸拰涓嬩竴涓姸鎬侊紝閫氱煡绉伴噸鎺у埗鍣�
- inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
- data);
+ // 绉伴噸瀹屾垚浜嬩欢
+ inoutEventControl.onInoutWeight(data, curProgress, nextProgress);
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
}
public PageResponse<InoutData> submitHandle(InoutData data)
@@ -705,6 +735,9 @@
// 鎵ц闄勪欢淇℃伅
fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
+
+ // 鍊间粨瀹屾垚瑙﹀彂浜嬩欢
+ inoutEventControl.onInoutHandle(data, curProgress, nextProgress);
return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
}
@@ -775,6 +808,9 @@
return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
}
+ // 鎵︽牱瀹屾垚瑙﹀彂浜嬩欢
+ inoutEventControl.onInSimple(data);
+
return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
}
@@ -824,6 +860,7 @@
data.setCheckTime(new Date());
}
curData.setCheckStatus(data.getCheckStatus());
+ curData.setFoodYear(data.getFoodYear());
// 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
@@ -838,6 +875,13 @@
curData.setProgress(curData.getProgress());
curData.setType(curData.getType());
+ curData.setFoodLevel(data.getFoodLevel());
+ curData.setFoodVariety(data.getFoodVariety());
+ curData.setPrice(data.getPrice());
+ curData.setRemarks(data.getRemarks());
+ curData.setCheckItems(data.getCheckItems());
+ curData.setCheckTime(data.getCheckTime());
+ curData.setDepotId(data.getDepotId());
if (StringUtils.isEmpty(data.getCheckUser())) {
curData.setCheckUser(ContextUtil.getLoginUserCName());
@@ -852,7 +896,52 @@
return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
}
+
+ // 璐ㄦ瀹屾垚瑙﹀彂浜嬩欢
+ inoutEventControl.onInCheck(data, curProgress, nextProgress);
+
return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
+ }
+
+ public PageResponse<InoutCheckData> submitCheckData(InoutCheckData data) throws Exception {
+
+
+ // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setId(data.getId());
+ InoutData curData = inoutService.inoutProgressQuery(param);
+
+ if (null == curData) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "娌℃湁鑾峰彇鍒板叆搴撲笟鍔℃暟鎹俊鎭紝鏇存柊澶辫触", data);
+ }
+
+ if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
+ }
+
+ // 鏇存柊鍖栭獙椤逛俊鎭�
+ CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
+ if (StringUtils.isNotEmpty(checkResult.getMsg())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鍚庡彴鎵ц寮傚父锛�" + checkResult.getMsg(), data);
+ }
+
+ curData.setType(curData.getType());
+ curData.setFoodLevel(data.getFoodLevel());
+ curData.setFoodVariety(data.getFoodVariety());
+ curData.setPrice(data.getPrice());
+ curData.setDepotId(data.getDepotId());
+ curData.setCheckItems(data.getCheckItems());
+
+ String msg = inoutService.updateCheckData(curData);
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+ }
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "淇濆瓨鎴愬姛");
}
/**
@@ -893,7 +982,7 @@
try {
List<CheckItemData> result = checkStandardManager.listCheckItem(
- param.getCheckId(), param.getCompanyId(),
+ param.getCompanyId(), param.getCheckId(),
param.getFoodVariety());
return new PageResponse<>(RespCodeEnum.CODE_0000, result);
@@ -926,4 +1015,35 @@
}
}
+ /**
+ * @param param
+ * @return
+ */
+ public PageResponse<InoutCheckData> inoutDataByCheckId(InoutCheckParam param) {
+ if (StringUtils.isEmpty(param.getCheckId())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+ "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�");
+ }
+
+ InoutCheckData result;
+ try {
+ param.setProgress(InoutConstant.PROGRESS_CHECK);
+ result = inoutService.inoutDataByCheckId(param);
+ if (null == result) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "绯荤粺鏈煡璇㈠埌鎵ц涓殑杞﹁締淇℃伅", null);
+ }
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+
+ } catch (Exception e) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ e.getMessage());
+ }
+ }
+
+ public void initInoutWeight(List<InoutConf> listInoutConf, String sort) {
+ inoutEventControl.initInoutWeight(listInoutConf, sort);
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.3