From 6fbd63022d55e31cffd60b4e390d608e474e99c0 Mon Sep 17 00:00:00 2001
From: YYC <1833023622@qq.com>
Date: 星期六, 21 十月 2023 16:15:36 +0800
Subject: [PATCH] 账面库存
---
igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java | 1814 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 903 insertions(+), 911 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 b24e026..200a5de 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
@@ -1,32 +1,28 @@
package com.ld.igds.inout.manager;
-import com.bstek.bdf2.core.business.IUser;
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;
import com.ld.igds.inout.dto.InoutData;
-import com.ld.igds.inout.dto.InoutGateDto;
import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.service.InoutService;
import com.ld.igds.m.service.InoutCommonService;
-import com.ld.igds.models.Depot;
import com.ld.igds.models.InoutConf;
+import com.ld.igds.models.InoutPrice;
import com.ld.igds.models.InoutSysConf;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
-import com.ld.igds.util.NumberUtil;
-import com.ld.igds.util.RespUtil;
-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;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -40,1023 +36,1019 @@
*
* @author
*/
-@Slf4j
@Component
public class InoutManager {
- @Autowired
- private InoutService inoutService;
- @Autowired
- private CoreFileService fileService;
- @Autowired
- private CoreCommonService commonService;
- @Autowired
- private InoutCommonService inoutManagerService;
- @Autowired
- private CheckStandardManager checkStandardManager;
- @Resource
- private InoutDeviceManager inoutDeviceManager;
+ @Resource
+ private InoutService inoutService;
+ @Resource
+ private CoreFileService fileService;
+ @Resource
+ private InoutCommonService inoutCommonService;
+ @Resource
+ private CheckStandardManager checkStandardManager;
+ @Resource
+ private InoutEventControlManager inoutEventControl;
+ @Resource
+ private CoreFileService coreFileService;
- /**
- * 褰撳墠鍏堜粠褰撴棩缂撳瓨涓幏鍙栨暟鎹紝濡傛灉缂撳瓨涓病鏈夊啀浠庢暟鎹簱鑾峰彇
- *
- * @param param
- * @return
- */
- public PageResponse<InoutData> inoutQuery(InoutParam param) {
- if (StringUtils.isEmpty(param.getPlateNum())
- && StringUtils.isEmpty(param.getIntelCard())
- && StringUtils.isEmpty(param.getUserId())) {
+ /**
+ * 鐩存帴浠庢暟鎹簱鏌ヨ锛屼笉鑰冭檻淇℃伅鐘舵��
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<InoutData> inoutQueryBack(InoutParam param) {
+ if (StringUtils.isEmpty(param.getPlateNum())
+ && StringUtils.isEmpty(param.getIntelCard())
+ && StringUtils.isEmpty(param.getUserId())) {
- return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
- "鍙傛暟涓嶅畬鏁达紝鏃犳硶鑾峰彇淇℃伅锛�");
- }
-
- if (StringUtils.isEmpty(param.getCompanyId())) {
- param.setCompanyId(ContextUtil.getCompanyId());
- }
-
- InoutData result;
- String progress = param.getProgress();
- try {
- param.setProgress(null);
-
- result = inoutService.inoutProgressQuery(param);
- if (null == result) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "鏈壘鍒版祦绋嬩腑鐨勮溅杈嗭紒", null);
- }
-
- // 濡傛灉娌℃湁娴佺▼鏉′欢璇存槑涓嶉渶瑕佸仛鍒ゆ柇锛岀洿鎺ヨ繑鍥�
- if (StringUtils.isEmpty(progress)) {
- return new PageResponse<>(RespCodeEnum.CODE_0000, result);
- }
-
- if (!result.getType().equals(param.getType())) {
- if (InoutConstant.TYPE_IN.equals(result.getType())) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "绯荤粺锛氬綋鍓嶈溅杈嗕笟鍔′负銆愬叆搴撱��", result);
- } else {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "绯荤粺锛氬綋鍓嶈溅杈嗕笟鍔′负銆愬嚭搴撱��", result);
- }
- }
-
- // 褰撳墠鏍囩鏍囩ず鏃㈠彲浠ユ槸绌鸿溅绉伴噸涔熷彲浠ユ槸婊¤溅
- if (progress.equals(InoutConstant.PROGRESS_WEIGHT_TAG)) {
- if (result.getProgress().equals(
- InoutConstant.PROGRESS_WEIGHT_EMPTY)
- || result.getProgress().equals(
- InoutConstant.PROGRESS_WEIGHT_FULL)) {
- // 琛ㄧず褰撳墠娴佺▼姝e父
- } else {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "闈炲綋鍓嶆祦绋嬶紝璇峰埌"
- + InoutConstant.getProcessName(
- param.getType(),
- result.getProgress()), result);
- }
- } else {
- if (!result.getProgress().equals(progress)) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "闈炲綋鍓嶆祦绋嬶紝璇峰埌"
- + InoutConstant.getProcessName(
- param.getType(),
- result.getProgress()), result);
- }
- }
-
- // 鏍规嵁褰撳墠鏁版嵁鍒ゆ柇鏄惁鎺ㄩ��
- inoutService.notifyWeb(result);
-
- //涓哄綋鍓嶆暟鎹坊鍔犲寲楠岄」鐩拰姘村垎鍜屾潅璐ㄧ殑鍖栭獙缁撴灉,鐢ㄤ簬鍑哄叆搴撳鎵i噸璁$畻
- if (InoutConstant.TYPE_IN.equals(result.getType())) {
- List<CheckItemData> checkItemDataList = inoutService.getCheckCache(result.getCompanyId(), result.getCheckId());
- result.setCheckItems(checkItemDataList);
- if (null != checkItemDataList && checkItemDataList.size() > 0) {
- for (CheckItemData checkItem : checkItemDataList) {
- if (StringUtils.isEmpty(checkItem.getValue())) {
- continue;
- }
-
-// if (InoutConstant.CHECK_ITEM_C01.equals(checkItem.getStandardId())) {
-// result.setWet(Double.valueOf(checkItem.getValue()));
-// }
-// if (InoutConstant.CHECK_ITEM_C02.equals(checkItem.getStandardId())) {
-// result.setImpurity(Double.valueOf(checkItem.getValue()));
-// }
- }
- }
- }
-
- return new PageResponse<>(RespCodeEnum.CODE_0000, result);
-
- } catch (Exception e) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- e.getMessage());
- }
- }
-
- public PageResponse<InoutData> outNextStep(InoutData data) throws Exception {
- String msg;
- IUser user = ContextUtil.getLoginUser();
- if (StringUtils.isEmpty(data.getCompanyId())) {
- data.setCompanyId(user.getCompanyId());
- }
- if (StringUtils.isEmpty(data.getDeptId())) {
- data.setDeptId(ContextUtil.subDeptId(user));
- }
- if (StringUtils.isEmpty(data.getIntelCard())) {
- data.setIntelCard(data.getUserId());
- }
-
- String curProgress = data.getProgress();
- List<FileData> files = data.getFiles();
-
- // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
- InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(
- data.getCompanyId(), data.getDeptId());
- if (null == inoutSysConf
- || StringUtils.isEmpty(inoutSysConf.getProgressIn())) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "褰撳墠搴撳尯鏈厤缃嚭搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳閰嶇疆銆�", data);
- }
- data = updateOutBasicInfo(data, inoutSysConf);
-
- // 濡傛灉褰撳墠鑺傜偣鏄敞鍐岋紝鍒欓渶瑕侀獙璇佷笅锛屾槸鍚︽湁涓哄畬鎴愮殑娴佺▼鍦ㄦ墽琛屼腑
- if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
- InoutData progressData = this.inoutProgressQuery(data);
- if (null != progressData) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "褰撳墠鍗$墖/杞︾墝鍙锋湁娴佺▼鏈粨鏉熴��", progressData);
- }
- }
-
- if(null != data.getPrice() && null != data.getRecordWeight()){
- data.setSettleMoney(NumberUtil.keepPrecision(data.getPrice()*data.getRecordWeight(),2));
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+ "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�");
}
- // 娴佺▼瀹屾垚锛岀洿鎺ヨ皟鐢ㄦ祦绋嬪畬鎴愭帴鍙�
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- inoutService.updateData(data);
- // 鎵ц闄勪欢淇℃伅
- if (null != files) {
- fileService.saveInoutFiles(files, data.getCompanyId(),
- data.getId(), curProgress);
- }
+ // 鑾峰彇涓夊ぉ浠ュ唴鏈�鍚庝竴澶╄褰�
+ param.setStart(DateUtil.getNewByDay(new Date(), -3));
+ param.setType(null);
+ param.setProgress(null);
- // 閫氱煡绉伴噸涓绘帶娴佺▼缁撴潫
- inoutDeviceManager.noticeProgressComplete(data);
+ InoutData result = inoutService.getLastRecord(param);
- return inoutComplete(data);
- }
-
- // 璋冪敤淇濆瓨鏂规硶鎵ц
- if (StringUtils.isEmpty(data.getId())) {
- msg = inoutService.insertData(data);
- } else {
- msg = inoutService.updateData(data);
- }
-
- // 鎵ц闄勪欢淇℃伅
- if (null != files) {
- fileService.saveInoutFiles(files, data.getCompanyId(),
- data.getId(), curProgress);
- }
-
- if (null != msg) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
- data);
- }
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
- data);
- }
-
- public PageResponse<InoutData> inNextStep(InoutData data) throws Exception {
- String msg;
- IUser user = ContextUtil.getLoginUser();
- if (StringUtils.isEmpty(data.getCompanyId())) {
- data.setCompanyId(user.getCompanyId());
- }
- if (StringUtils.isEmpty(data.getDeptId())) {
- data.setDeptId(ContextUtil.subDeptId(user));
- }
- String curProgress = data.getProgress();
- List<FileData> files = data.getFiles();
-
- if (StringUtils.isEmpty(data.getIntelCard())) {
- data.setIntelCard(data.getUserId());
- }
-
- // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
- InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
-
- if (null == inoutSysConf
- || StringUtils.isEmpty(inoutSysConf.getProgressIn())) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "褰撳墠搴撳尯鏈厤缃叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳閰嶇疆銆�", data);
- }
-
- data = updateInBasicInfo(data, inoutSysConf);
-
- // 濡傛灉褰撳墠鑺傜偣鏄敞鍐岋紝鍒欓渶瑕侀獙璇佷笅锛屾槸鍚︽湁涓哄畬鎴愮殑娴佺▼鍦ㄦ墽琛屼腑
- if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
- InoutData progressData = this.inoutProgressQuery(data);
- if (null != progressData) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "褰撳墠鍗$墖/杞︾墝鍙锋湁娴佺▼鏈粨鏉熴��", progressData);
- }
- }
-
- if(null != data.getPrice() && null != data.getRecordWeight()){
- data.setSettleMoney(NumberUtil.keepPrecision(data.getPrice()*data.getRecordWeight(),2));
+ if (null == result) {
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+ "鏍规嵁褰撳墠鏉′欢鏈煡璇㈠埌杞﹁締淇℃伅锛�");
}
- // 娴佺▼瀹屾垚锛岀洿鎺ヨ皟鐢ㄦ祦绋嬪畬鎴愭帴鍙�
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- if (StringUtils.isEmpty(data.getCompanyId())) {
- data.setCompanyId(ContextUtil.getCompanyId());
- }
+ if (InoutConstant.PROGRESS_RECORD.equals(result.getProgress())) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "褰撳墠杞﹁締娴佺▼宸茬粡缁撴潫", result);
+ }
- inoutService.updateData(data);
- // 鎵ц闄勪欢淇℃伅
- if (null != files) {
- fileService.saveInoutFiles(files, data.getCompanyId(),
- data.getId(), curProgress);
- }
+ if (!InoutConstant.PROGRESS_CARD_BACK.equals(result.getProgress())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1008.getCode(),
+ "褰撳墠杞﹁締娴佺▼涓嶅湪褰撳墠鐜妭锛屾棤娉曟墽琛屽嚭搴�", result);
+ }
- // 閫氱煡绉伴噸涓绘帶娴佺▼缁撴潫
- inoutDeviceManager.noticeProgressComplete(data);
+ return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+ }
- return inoutComplete(data);
- }
+ /**
+ * 棣栧厛浠庣紦瀛樹腑鑾峰彇锛岀紦瀛樹腑锛屼粠鏁版嵁搴撲腑鑾峰彇
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<InoutData> inoutQuery(InoutParam param) {
+ if (StringUtils.isEmpty(param.getPlateNum())
+ && StringUtils.isEmpty(param.getIntelCard())
+ && StringUtils.isEmpty(param.getUserId())) {
- // 璋冪敤淇濆瓨鏂规硶鎵ц
- if (StringUtils.isEmpty(data.getId())) {
- msg = inoutService.insertData(data);
- } else {
- msg = inoutService.updateData(data);
- }
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+ "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�");
+ }
- // 鎵ц闄勪欢淇℃伅
- if (null != files) {
- fileService.saveInoutFiles(files, data.getCompanyId(),
- data.getId(), curProgress);
- }
+ InoutData result;
+ String progress = param.getProgress();
+ try {
+ param.setProgress(null);
+ result = inoutService.inoutProgressQuery(param);
+ if (null == result) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "绯荤粺涓烘煡璇㈠埌鎵ц涓殑杞﹁締淇℃伅", null);
+ }
- if (null != msg) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
- }
+ // 濡傛灉娌℃湁娴佺▼鏉′欢璇存槑涓嶉渶瑕佸仛鍒ゆ柇锛岀洿鎺ヨ繑鍥�
+ if (StringUtils.isEmpty(progress)) {
+ return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+ }
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
- data);
- }
+ // 娴佺▼绫诲瀷楠岃瘉
+ if (!result.getType().equals(param.getType())) {
+ String msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬叆搴撱��";
+ if (InoutConstant.TYPE_OUT.equals(result.getType()))
+ msg = "娴佺▼閿欒锛氬綋鍓嶈溅杈嗘祦绋嬩负銆愬嚭搴撱��";
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ msg, result);
+ }
- public InoutData inoutProgressQuery(InoutData data) throws Exception {
- InoutParam param = new InoutParam();
- param.setCompanyId(data.getCompanyId());
- param.setPlateNum(data.getPlateNum());
- param.setIntelCard(data.getIntelCard());
- param.setType(data.getType());
+ // 娴佺▼鐜妭楠岃瘉
+ if (progress.equals(InoutConstant.PROGRESS_WEIGHT_TAG)) {
+ if (result.getProgress().equals(
+ InoutConstant.PROGRESS_WEIGHT_EMPTY)
+ || result.getProgress().equals(
+ InoutConstant.PROGRESS_WEIGHT_FULL)) {
+ // 琛ㄧず褰撳墠娴佺▼姝e父
+ } else {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "鎻愮ず锛氶潪褰撳墠鐜妭锛岃鍒�"
+ + InoutConstant.getProcessName(
+ param.getType(),
+ result.getProgress()), result);
+ }
+ } else {
+ if (!result.getProgress().equals(progress)) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "鎻愮ず锛氶潪褰撳墠鐜妭锛岃鍒�"
+ + InoutConstant.getProcessName(
+ param.getType(),
+ result.getProgress()), result);
+ }
+ }
- return inoutService.inoutProgressQuery(param);
- }
+ return new PageResponse<>(RespCodeEnum.CODE_0000, result);
- @Transactional(rollbackFor = Exception.class)
- public PageResponse<InoutData> updateCheck(InoutData data) throws Exception {
+ } catch (Exception e) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ e.getMessage());
+ }
+ }
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼", data);
- }
- CheckUpdateResult checkResult = this.updateCheckItems(data);
- String tag = checkResult.getMsg();
+ /**
+ * 鍖栭獙缁撴灉涓嶉�氳繃鏃舵牎楠岄厤缃俊鎭�
+ *
+ * @param data
+ * @return
+ */
+ private InoutData checkNoPass(InoutData data) {
+ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
+ data.getCompanyId(), data.getDeptId());
- if (null != tag) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "鍚庡彴鎵ц寮傚父锛�" + tag, data);
- }
+ if (inoutSysConf.getNoPassNext().equals(
+ InoutConstant.CHECK_NOPASS_RECORD)) {
+ // 娴佺▼缁撴潫
+ data.setProgress(InoutConstant.PROGRESS_RECORD);
+ data.setCompleteTime(new Date());
+ }
+ if (inoutSysConf.getNoPassNext()
+ .equals(InoutConstant.CHECK_NOPASS_BACK)) {
+ // 绂诲簱鏀跺崱
+ data.setProgress(InoutConstant.PROGRESS_CARD_BACK);
+ }
+ return data;
+ }
- // 鑾峰彇涓氬姟鏁版嵁淇℃伅
- InoutParam param = new InoutParam();
- param.setCompanyId(data.getCompanyId());
- param.setId(data.getId());
- InoutData progressData = inoutService.inoutProgressQuery(param);
- if (null == progressData) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "娌℃湁鑾峰彇鍒板嚭鍏ュ簱涓氬姟鏁版嵁淇℃伅锛屾洿鏂板け璐�", data);
- }
- if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
- }
- progressData.setCheckStatus(data.getCheckStatus());
+ /**
+ * 鏇存柊璐ㄦ淇℃伅
+ *
+ * @param data
+ * @return
+ */
+ private InoutData updateCheckItems(InoutData data, boolean toSave) throws Exception {
- // 鏇存柊涓嬩竴涓姸鎬佸拰鍩烘湰淇℃伅
- if (InoutConstant.PROGRESS_CHECK.equals(progressData.getProgress())) {
- progressData = updateInBasicInfo(progressData, null);
- // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋�
- if (InoutConstant.STATUS_UNPASS.equals(progressData
- .getCheckStatus())) {
- progressData = checkNoPass(progressData);
- }
- }
- progressData.setCheckUser(ContextUtil.getLoginUserCName());
- if (StringUtils.isNotEmpty(data.getCustomerName())) {
- progressData.setCustomerId(data.getCustomerId());
- progressData.setCustomerName(data.getCustomerName());
- }
- if (StringUtils.isNotEmpty(data.getDepotId())) {
- progressData.setDepotId(data.getDepotId());
- }
- if (StringUtils.isNotEmpty(data.getFoodVariety())) {
- progressData.setFoodVariety(data.getFoodVariety());
- }
- if (StringUtils.isNotEmpty(data.getFoodLevel())) {
- progressData.setFoodLevel(data.getFoodLevel());
- }
- if (StringUtils.isNotEmpty(data.getFoodLocation())) {
- progressData.setFoodLocation(data.getFoodLocation());
- }
- if (StringUtils.isNotEmpty(data.getFoodYear())) {
- progressData.setFoodYear(data.getFoodYear());
- }
- if (null != data.getPrice()) {
- progressData.setPrice(data.getPrice());
- }
- if (StringUtils.isNotEmpty(data.getRemarks())) {
- progressData.setRemarks(data.getRemarks());
- }
- if (StringUtils.isNotEmpty(data.getNoticeId())) {
- progressData.setNoticeId(data.getNoticeId());
- }
+ if (null == data.getCheckItems()) return data;
-// // 鍥炲~姘村垎鍜屾潅璐�
-// if (checkResult.getWet() > 0) {
-// progressData.setWet(checkResult.getWet());
-// }
-//
-// if (checkResult.getImpurity() > 0) {
-// progressData.setImpurity(checkResult.getImpurity());
-// }
+ //璁剧疆娌℃湁璐ㄦID锛屽彇娑堟墽琛屾寔涔呭寲
+ if (!toSave) data.setCheckId(null);
- String msg = inoutService.updateData(progressData);
+ // 鏇存柊妫�楠岄」鏁版嵁
+ CheckUpdateResult checkUpdateResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
- if (null != msg) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
- }
- if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) {
+ if (data.getDeCheck() == 0) {
+ data.setDeCheck(checkUpdateResult.getDeSum());
+ }
+ if (data.getAddCheck() == 0) {
+ data.setAddCheck(checkUpdateResult.getAddSum());
+ }
- inoutComplete(progressData);
- }
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
- }
+ return data;
+ }
- /**
- * 鍖栭獙缁撴灉涓嶉�氳繃鏃舵牎楠岄厤缃俊鎭�
- *
- * @param data
- * @return
- */
- private InoutData checkNoPass(InoutData data) {
- InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(
- data.getCompanyId(), data.getDeptId());
+ /**
+ * 浠庣紦瀛樹腑鑾峰彇涓嬩竴娴佺▼
+ *
+ * @return
+ */
+ private String getNextProgress(String curProgress, String type,
+ InoutSysConf sysConf) {
+ String nextProgress = null;
+ List<String> list = null;
+ if (InoutConstant.TYPE_IN.equals(type)) {
+ list = Arrays.asList(sysConf.getProgressIn().split("-"));
+ }
+ if (InoutConstant.TYPE_OUT.equals(type)) {
+ list = Arrays.asList(sysConf.getProgressOut().split("-"));
+ }
+ if (list != null) {
+ for (int i = 0; i < list.size() - 1; i++) {
+ if (curProgress.equals(list.get(i))) {
+ nextProgress = list.get(i + 1);
+ break;
+ }
+ }
+ }
+ return nextProgress;
+ }
- if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_RECORD)) {
- // 娴佺▼缁撴潫
- data.setProgress(InoutConstant.PROGRESS_RECORD);
- data.setCompleteTime(new Date());
- }
- if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_BACK)) {
- // 绂诲簱鏀跺崱
- data.setProgress(InoutConstant.PROGRESS_CARD_BACK);
- }
- return data;
- }
+ /**
+ * 鏍规嵁鏁版嵁褰撳墠鐘舵�佸拰涓嬩竴涓姸鎬侊紝鏇存柊鍩虹淇℃伅
+ *
+ * @param data
+ * @return
+ */
+ private InoutData updateBasicInfo(InoutData data, String curProgress,
+ String nextProgress) {
- private CheckUpdateResult updateCheckItems(InoutData data) {
- CheckUpdateResult result = new CheckUpdateResult();
- if (null == data.getCheckItems())
- return result;
- try {
- // 鏇存柊妫�楠岄」鏁版嵁
- result = checkStandardManager.updateCheckItems(data.getCheckId(),
- data.getCompanyId(), data.getCheckItems());
+ if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
+ data.setRegisterTime(new Date());
+ data.setRegisterUser(ContextUtil.getLoginUserCName());
+ data.setProgress(nextProgress);
+ }
- // 灏嗗寲楠屾暟鎹瓨鍏ョ紦瀛樹腑
- inoutService.setCheckCache(data);
+ if (InoutConstant.PROGRESS_CHECK.equals(data.getProgress())) {
+ data.setCheckUser(ContextUtil.getLoginUserCName());
+ data.setProgress(nextProgress);
+ return data;
+ }
- return result;
+ if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(curProgress)) {
+ data.setEmptyWeightTime(new Date());
+ data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
+ data.setProgress(nextProgress);
+ }
- } catch (Exception e) {
- log.error("鍚庡彴寮傚父锛歿}", e);
- result.setMsg("鎵ц寮傚父锛�" + e.getMessage());
- }
- return result;
- }
+ if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(curProgress)) {
+ data.setFullWeightTime(new Date());
+ data.setFullWeightUser(ContextUtil.getLoginUserCName());
+ data.setProgress(nextProgress);
+ }
- /**
- * 浠庣紦瀛樹腑鑾峰彇涓嬩竴娴佺▼
- *
- * @return
- */
- private String getNextProgress(String curProgress, String type,
- InoutSysConf sysConf) {
- String nextProgress = null;
- List<String> list = null;
- if (InoutConstant.TYPE_IN.equals(type)) {
- list = Arrays.asList(sysConf.getProgressIn().split("-"));
- }
- if (InoutConstant.TYPE_OUT.equals(type)) {
- list = Arrays.asList(sysConf.getProgressOut().split("-"));
- }
- if (list != null) {
- for (int i = 0; i < list.size() - 1; i++) {
- if (curProgress.equals(list.get(i))) {
- nextProgress = list.get(i + 1);
- break;
- }
- }
- }
- return nextProgress;
- }
+ if (InoutConstant.PROGRESS_HANDLE.equals(curProgress)) {
+ if (null == data.getHandleUser()) {
+ data.setHandleUser(ContextUtil.getLoginUserCName());
+ }
+ data.setProgress(nextProgress);
+ }
- /**
- * 鏍规嵁闇�瑕佷繚瀛樼殑鏁版嵁锛岃皟鏁翠笅涓�涓祦绋嬬姸鎬� 涓嶅悓鐨勪粨搴撶粍缁囨祦绋嬪彲鑳戒笉涓�鏍凤紝闇�瑕佹牴鎹疄闄呰皟鏁�
- *
- * @param data
- * @return
- */
- private InoutData updateInBasicInfo(InoutData data, InoutSysConf sysConf) {
- if (null == sysConf) {
- sysConf = inoutManagerService.getCacheInoutSysConf(
- data.getCompanyId(), data.getDeptId());
- }
+ // 濡傛灉涓嬩竴涓暟鎹姸鎬�=娴佺▼缁撴潫锛岀洿鎺ヨˉ鍏呭畬鏁翠俊鎭�
+ if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) {
+ data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
+ data.setCompleteUser(ContextUtil.getLoginUserCName());
+ data.setProgress(nextProgress);
+ }
- if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
- data.setRegisterTime(new Date());
- data.setRegisterUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
+ return data;
+ }
- return data;
- }
+ /**
+ * 鍗″洖鏀堕�昏緫澶勭悊
+ *
+ * @param data
+ * @return
+ */
+ public PageResponse<InoutData> submitCardBack(InoutData data) {
+ try {
+ // 濡傛灉褰撳墠鏁版嵁宸茬粡缁撴潫
+ if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) {
- data.setFullWeightTime(new Date());
- data.setFullWeightUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
- return data;
- }
- if (InoutConstant.PROGRESS_CHECK.equals(data.getProgress())) {
- data.setCheckUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
- return data;
- }
+ // 鍒犻櫎缂撳瓨
+ inoutService.delFromCache(data.getDeptId(), data.getType(),
+ data.getId());
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(),
+ "褰撹溅杈嗘祦绋嬪凡缁忓畬鎴愶紝鍗$墖宸插洖鏀�", data);
+ }
+
+ // 濡傛灉褰撳墠娴佺▼涓嶆槸鍗″洖鏀�
+ if (!InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
+
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "褰撳墠娴佺▼鐜妭涓嶆纭紝涓嶈兘鎵ц鍗″洖鏀�", data);
+ }
+
+ // 濡傛灉褰撳墠娴佺▼鐘舵�佹槸鍗″洖鏀剁姸鎬侊紝灏辨槸瀹屾垚娴佺▼銆�
+ if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
+ return submitComplete(data);
+ }
+
+ } catch (Exception e) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鍚庣鎵ц寮傚父锛�" + e.getMessage());
+ }
+
+ 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);
+ }
+
+ /**
+ * 琛ュ崟鎿嶄綔 琛ュ崟鍥犱负瀹屾垚鏃堕棿涓嶇‘瀹氾紝鎵�浠ラ渶瑕佺郴缁熸牴鎹綋鍓嶆暟鎹繘琛岃嚜鍔ㄦ娴嬶紝璋冩暣鍘熸潵娴佹按淇℃伅鍜屽簱瀛�
+ *
+ * @param data
+ * @return
+ * @throws Exception
+ */
+ public String addInoutData(InoutData data) throws Exception {
+
+ if (data.getSettleWeight() <= 0.0) {
+ return "绯荤粺锛氳ˉ鍗曟暟鎹姹傜粨绠楅噸閲忓繀椤诲ぇ浜�0";
+ }
+
+ // 琛ュ崟鏁版嵁鐩存帴鍒扮粨鏋滅姸鎬�
+ data.setRecordStatus(InoutConstant.RECORD_STATUS_ADD);
+ data.setProgress(InoutConstant.PROGRESS_RECORD);
+ if (InoutConstant.STATUS_NONE.equals(data.getCheckStatus())) {
+ data.setCheckStatus(InoutConstant.STATUS_PASS);
+ }
+
+ String loginUser = ContextUtil.getLoginUserCName();
+ data.setRegisterUser(loginUser);
+ data.setFullWeightUser(loginUser);
+ data.setEmptyWeightUser(loginUser);
+ data.setHandleUser(loginUser);
+ data.setCompleteUser(loginUser);
+ if (null == data.getCompleteTime()) {
+ data.setCompleteTime(new Date());
+ }
+ // 娉ㄥ唽鏃堕棿姣斿畬鎴愭椂闂存棭涓�涓皬鏃�
+ data.setRegisterTime(DateUtils.addMinutes(new Date(), -80));
+
+ if (StringUtils.isEmpty(data.getUserId())) {
+ data.setUserId(InoutConstant.DEFAULT_ID_CARD);
+ }
+ if (null == data.getIntelCard()) {
+ data.setIntelCard(data.getUserId());
+ }
+ if (null != data.getCheckItems()) {
+ data.setCheckUser(loginUser);
+ }
+
+
+ if (InoutConstant.TYPE_IN.equals(data.getType())) {
+ if (null == data.getFullWeightTime()) {
+ data.setFullWeightTime(DateUtils.addMinutes(new Date(), -50));
+ }
+ if (null == data.getEmptyWeightTime()) {
+ data.setEmptyWeightTime(DateUtils.addMinutes(new Date(), -10));
+ }
+
+ if (data.getCompleteTime().before(data.getEmptyWeightTime())) {
+ data.setEmptyWeightTime(DateUtils.addMinutes(data.getCompleteTime(), -10));
+ }
+ if (data.getEmptyWeightTime().before(data.getFullWeightTime())) {
+ data.setFullWeightTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -40));
+ }
+ if (data.getFullWeightTime().before(data.getRegisterTime())) {
+ data.setRegisterTime(DateUtils.addMinutes(data.getFullWeightTime(), -30));
+ }
+
+ data = this.updateCheckItems(data, false);
+ } else {
+ if (null == data.getEmptyWeightTime()) {
+ data.setEmptyWeightTime(DateUtils.addMinutes(new Date(), -50));
+ }
+ if (null == data.getFullWeightTime()) {
+ data.setFullWeightTime(DateUtils.addMinutes(new Date(), -10));
+ }
+ if (data.getCompleteTime().before(data.getFullWeightTime())) {
+ data.setFullWeightTime(DateUtils.addMinutes(data.getCompleteTime(), -10));
+ }
+ if (data.getFullWeightTime().before(data.getEmptyWeightTime())) {
+ data.setEmptyWeightTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -40));
+ }
+ if (data.getEmptyWeightTime().before(data.getRegisterTime())) {
+ data.setRegisterTime(DateUtils.addMinutes(data.getFullWeightTime(), -30));
+ }
+ }
+
+
+ //鍏堜繚瀛樹富琛紝鍚庢墽琛屽瓙琛�
+ inoutService.insertData(data);
+
+ if (InoutConstant.TYPE_IN.equals(data.getType())) {
+ this.updateCheckItems(data, true);
+ }
+ fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), null);
+ return null;
+ }
+
+ /**
+ * 淇敼鎿嶄綔 淇敼閫昏緫璇存槑锛氫慨鏀规暟鎹渶瑕佽幏鍙栧師鏁版嵁搴撲腑鐨勬暟鎹繘琛屽姣斻��
+ *
+ * @param data
+ * @return
+ * @throws Exception
+ */
+ @Transactional
+ public String updateInoutData(InoutData data) throws Exception {
+
+ if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
+ return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒";
+ }
+
+
+ if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
+ return "绯荤粺锛氭祦绋嬪凡缁忕粨鏉熺殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒";
+ }
+
+ // 淇濆瓨妫�娴嬮」鐩�
+ if (InoutConstant.TYPE_IN.equals(data.getType())) {
+ data = updateCheckItems(data, true);
+ }
+
+ return inoutService.updateData(data);
+ }
+
+
+ /**
+ * 寮傚父缁堟鎿嶄綔 璁剧疆寮傚父 涓轰簡閬垮厤椤甸潰鏁版嵁缂撳瓨锛岄渶瑕侀噸鏂拌幏鍙栨渶鏂版暟鎹垽鏂�
+ *
+ * @param data
+ * @return
+ * @throws Exception
+ */
+ public String errorInoutData(InoutData data) throws Exception {
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setId(data.getId());
+
+ param.setMsg(" 浜�" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm") + " 琚� " + ContextUtil.getLoginUserCName() + " 鎵ц缁堟锛屽師鍥狅細" + data.getRemarks());
+
+ data = inoutService.inoutQueryById(param);
+
+// if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
+// return "娴佺▼缁撴潫鐨勬暟鎹笉鏀寔寮傚父澶勭悊锛�";
+// }
+ if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
+ return "褰撳墠淇℃伅宸插仛寮傚父澶勭悊锛屼笉鏀寔閲嶅鎵ц锛�";
+ }
+
+
+ param.setDeptId(data.getDeptId());
+ param.setType(data.getType());
+ return inoutService.inoutStop(param);
+ }
+
+ /**
+ * 蹇�熺粨鏉熸搷浣� 娴佺▼娌℃湁缁撴潫鐨勫崟鎹繘琛岀粨鏉�
+ *
+ * @param data
+ * @return
+ */
+ public String completeInoutData(InoutData data) throws Exception {
+ // 浠庢柊鏌ヨ鏁版嵁
+ InoutParam param = new InoutParam();
+ param.setId(data.getId());
+ param.setCompanyId(data.getCompanyId());
+ param.setType(data.getType());
+ InoutData cuData = inoutService.inoutQueryById(param);
+ if (null == cuData) {
+ return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒";
+ }
+
+ if (!cuData.getProgress().equals(data.getProgress())) {
+ return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒";
+ }
+
+ if (InoutConstant.RECORD_STATUS_DEL.equals(cuData.getRecordStatus())) {
+ return "褰撳墠淇℃伅宸茬粡琚紓甯哥粓姝紝涓嶆敮鎸佸綋鍓嶅鐞嗭紒";
+ }
+ if (InoutConstant.PROGRESS_RECORD.equals(cuData.getProgress())) {
+ return "娴佺▼宸插畬鎴愮殑鏁版嵁锛屼笉鏀寔瀹屾垚锛�";
+ }
+
+ if (null == data.getCompleteTime()) {
+ return "璇峰~鍐欏畬鎴愭椂闂达紒锛�";
+ }
+ if (StringUtils.isEmpty(data.getDepotId())) {
+ return "璇峰~鍐欎粨搴撲俊鎭紒";
+ }
+ if (StringUtils.isEmpty(data.getFoodYear())) {
+ return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒";
+ }
+ if (StringUtils.isEmpty(data.getFoodVariety())) {
+ return "璇峰~鍐欑伯椋熷搧绉嶄俊鎭紒";
+ }
+
+ if (data.getSettleWeight() <= 0) {
+ return "璇峰~鍐欑粨绠楀噣閲嶄俊鎭紒";
+ }
+
+ String msg = inoutService.quickComplete(data);
+
+
+ return msg;
+ }
+
+ /**
+ * 鍑哄叆搴撶櫥璁板垵濮嬪寲
+ *
+ * @param conf 杞︾墝璇嗗埆閰嶇疆淇℃伅
+ */
+ public void initInoutRegister(InoutConf conf) {
+ inoutEventControl.initInoutRegister(conf);
+ }
+
+ /**
+ * 鍑哄叆搴撴敞鍐屾暟鎹彁浜わ紝鍏ュ簱鐧昏鍜屽嚭鍏ュ簱鐧昏浣跨敤鍚屼竴涓柟娉�
+ *
+ * @param data
+ * @return
+ * @throws Exception
+ */
+ public PageResponse<InoutData> submitRegisterInout(InoutData data) throws Exception {
+
+ // 棣栧厛鍒ゆ柇娴佺▼涓槸鍚︽湁宸茬粡瀛樺湪鐨勮溅杈嗕俊鎭湭鎵ц瀹屾垚锛岀洿鎺ヤ粠鏁版嵁搴撲腑鏌ヨ
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setPlateNum(data.getPlateNum());
+ param.setIntelCard(data.getIntelCard());
+ param.setType(data.getType());
+ param.setStart(DateUtil.getNewByDay(null, -10));
+
+ int num = inoutService.checkExist(param);
+ if (num > 0) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "褰撳墠杞︾墝鎴栨櫤鎱у崱鏈夋鍦ㄦ墽琛屾祦绋嬫湭缁撴潫锛岃鑱旂郴绠$悊鍛�", data);
+ }
+
+ // 鑾峰彇绯荤粺鍙傛暟閰嶇疆
+ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
+ data.getCompanyId(), data.getDeptId());
+ if (null == inoutSysConf) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鎻愮ず锛氬綋鍓嶅簱鍖烘湭閰嶇疆鍑哄叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳", data);
+ }
+ List<FileData> files = data.getFiles();
+ // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+ String curProgress = data.getProgress();
+ String nextProgress = getNextProgress(curProgress, data.getType(),
+ inoutSysConf);
+
+ data = updateBasicInfo(data, curProgress, nextProgress);
+
+ String msg = inoutService.insertData(data);
+
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
+ }
+
+ if(null != files && files.size()>0){
+ // 鎵ц闄勪欢淇℃伅
+ fileService.saveInoutFiles(files, data.getCompanyId(), data.getId(), curProgress);
+ }
+
+ //鐧昏瀹屾垚浜嬩欢
+ inoutEventControl.onInoutRegister(data);
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛",
+ data);
+ }
+
+ public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception {
+ // 鑾峰彇绯荤粺鍙傛暟閰嶇疆
+ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
+ data.getCompanyId(), data.getDeptId());
+ if (null == inoutSysConf) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data);
+ }
+ List<FileData> files = data.getFiles();
+ // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+ String curProgress = data.getProgress();
+ String nextProgress = getNextProgress(curProgress, data.getType(),
+ inoutSysConf);
+ data = updateBasicInfo(data, curProgress, nextProgress);
+
+ // 鍏ュ簱绉伴噸鍙兘璋冩暣璐ㄦ鍗�
+ data = updateCheckItems(data, true);
+
+ // 鎵ц鏁版嵁鏇存柊
+ String msg = inoutService.updateData(data);
+
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
+ data);
+ }
+
+ if(null != files && files.size()>0){
+ // 鎵ц闄勪欢淇℃伅
+ fileService.saveInoutFiles(files, data.getCompanyId(), data.getId(), curProgress);
+ }
+
+ // 绉伴噸瀹屾垚浜嬩欢
+ inoutEventControl.onInoutWeight(data, curProgress, nextProgress);
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
+ }
- if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) {
- data.setEmptyWeightTime(new Date());
- data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
+ public PageResponse<InoutData> submitWeightOut(InoutData data)
+ throws Exception {
+ // 鑾峰彇绯荤粺鍙傛暟閰嶇疆
+ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
+ data.getCompanyId(), data.getDeptId());
+ if (null == inoutSysConf) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data);
+ }
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
+ // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+ String curProgress = data.getProgress();
+ String nextProgress = getNextProgress(curProgress, data.getType(),
+ inoutSysConf);
+ data = updateBasicInfo(data, curProgress, nextProgress);
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
- data.setCompleteUser(ContextUtil.getLoginUserCName());
- }
- return data;
- }
+ // 鎵ц鏁版嵁鏇存柊
+ String msg = inoutService.updateData(data);
- if (InoutConstant.PROGRESS_HANDLE.equals(data.getProgress())) {
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
+ data);
+ }
- // 鏌ヨ缂撳瓨涓粨搴撲俊鎭紝鏍规嵁浠撳簱id璁剧疆鍊间粨浜轰负浠撳簱淇濈鍛�
- Depot depot = commonService.getCacheDepot(data.getCompanyId(),
- data.getDepotId());
- data.setHandleUser(depot == null ? "" : depot.getStoreKeeperName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
- return data;
- }
+ // 鎵ц闄勪欢淇℃伅
+ fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
+ data.getId(), curProgress);
- if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
- data.setCompleteTime(new Date());
- data.setCompleteUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
- return data;
- }
- return data;
- }
- /**
- * 鏍规嵁闇�瑕佷繚瀛樼殑鏁版嵁锛岃皟鏁翠笅涓�涓祦绋嬬姸鎬� 涓嶅悓鐨勪粨搴撶粍缁囨祦绋嬪彲鑳戒笉涓�鏍凤紝闇�瑕佹牴鎹疄闄呰皟鏁�
- *
- * @param data
- * @return
- */
- private InoutData updateOutBasicInfo(InoutData data, InoutSysConf sysConf) {
- if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
- data.setRegisterTime(new Date());
- data.setRegisterUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
+ // 绉伴噸瀹屾垚浜嬩欢
+ inoutEventControl.onInoutWeight(data, curProgress, nextProgress);
- return data;
- }
- if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) {
- data.setEmptyWeightTime(new Date());
- data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
+ }
- return data;
- }
+ public PageResponse<InoutData> submitHandle(InoutData data)
+ throws Exception {
- if (InoutConstant.PROGRESS_HANDLE.equals(data.getProgress())) {
- // 鏌ヨ缂撳瓨涓粨搴撲俊鎭紝鏍规嵁浠撳簱id璁剧疆鍊间粨浜轰负浠撳簱淇濈鍛�
- Depot depot = commonService.getCacheDepot(data.getCompanyId(),
- data.getDepotId());
- data.setHandleUser(depot == null ? "" : depot.getStoreKeeperName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
+ if (null == data.getHandleUser()) {
+ data.setHandleUser(ContextUtil.getLoginUserCName());
+ }
- return data;
- }
+ // 鑾峰彇绯荤粺鍙傛暟閰嶇疆
+ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+ if (null == inoutSysConf) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鎻愮ず锛氬綋鍓嶇郴缁熶腑娴佺▼閰嶇疆寮傚父锛岃鑱旂郴绠$悊鍛�", data);
+ }
- if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) {
- data.setFullWeightTime(new Date());
- data.setFullWeightUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
- data.setCompleteUser(ContextUtil.getLoginUserCName());
- }
- return data;
- }
+ // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+ String curProgress = data.getProgress();
+ String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
+ data = updateBasicInfo(data, curProgress, nextProgress);
- if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
- data.setCompleteTime(new Date());
- data.setCompleteUser(ContextUtil.getLoginUserCName());
- data.setProgress(getNextProgress(data.getProgress(),
- data.getType(), sysConf));
+ // 鎵ц鏁版嵁鏇存柊
+ String msg = inoutService.updateDataByHandle(data);
- return data;
- }
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
+ }
- return data;
- }
+ // 鎵ц闄勪欢淇℃伅
+ fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
- public PageResponse<Page<InoutData>> pageRecordData(InoutParam param) {
+ // 鍊间粨瀹屾垚瑙﹀彂浜嬩欢
+ inoutEventControl.onInoutHandle(data, curProgress, nextProgress);
- log.debug("鍒嗛〉淇℃伅--page={},limit={},cuur={}", param.getPage(),
- param.getLimit(), param.getCurr());
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛", data);
+ }
- Page<InoutData> result = inoutService.pageRecordData(param);
+ /**
+ * 鏍规嵁鏉′欢鑾峰彇鎵︽牱鏁版嵁
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<Page<InoutCheckData>> pageSampleData(
+ InoutCheckParam param) {
- if (null == result.getRecords() || result.getRecords().isEmpty()) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "鑾峰彇鍒版暟鎹俊鎭负绌�");
- }
+ if (StringUtils.isEmpty(param.getCompanyId())) {
+ param.setCompanyId(ContextUtil.getCompanyId());
+ }
+ if (StringUtils.isEmpty(param.getDeptId())) {
+ param.setDeptId(ContextUtil.subDeptId(null));
+ }
- return new PageResponse<>(RespCodeEnum.CODE_0000, result);
- }
+ // 鑻ユ煡璇㈡潯浠朵负宸叉墻鏍凤紝鍒欐祦绋嬬疆绌猴紱鑻ユ湭鎵︽牱锛屽垯娴佺▼涓嶅鐞嗭紝浠嶄负鎵︽牱鍖栭獙娴佺▼(CHECK)
+ if (!"NONE".equals(param.getSampleStatus())) {
+ param.setProgress(null);
+ }
- /**
- * @param param
- * @return
- */
- public PageResponse<Page<InoutData>> pageCheckData(InoutParam param) {
- // 濡傛灉鏄凡鍖栭獙锛屽垯灏嗘祦绋嬬姸鎬佺疆绌猴紝濡傛灉鏄湭鍖栭獙锛屽垯娴佺▼鐘舵�佷笉澶勭悊锛屼粛鏄疌HECK鐘舵��
- if (!"NONE".equals(param.getCheckStatus())) {
- param.setProgress(null);
- }
- // 璁剧疆鍒嗗簱Id
- String deptId = ContextUtil.subDeptId(null);
- param.setDeptId(deptId);
- return pageRecordData(param);
- }
+ // 鑾峰彇鎵︽牱鏁版嵁
+ Page<InoutCheckData> sampleList = inoutService.pageSampleData(param);
+ if (null == sampleList.getRecords()
+ || sampleList.getRecords().isEmpty()) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "鑾峰彇鍒版暟鎹俊鎭负绌�");
+ }
+ return new PageResponse<>(RespCodeEnum.CODE_0000, sampleList);
+ }
- public PageResponse<InoutData> inoutComplete(InoutData data) throws Exception {
- if (StringUtils.isEmpty(data.getId())
- || StringUtils.isEmpty(data.getType())) {
+ public PageResponse<InoutCheckData> submitSample(InoutCheckData data) throws Exception {
- return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
- "娌℃湁鑾峰彇鍒拌溅杈嗕俊鎭��", data);
- }
+ // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setId(data.getId());
+ InoutData curData = inoutService.inoutProgressQuery(param);
- 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(ContextUtil.getLoginUserCName());
- param.setDepotId(data.getDepotId());
- param.setCompleteTime(data.getCompleteTime());
- if (null == param.getCompleteTime()) {
- param.setCompleteTime(new Date());
- }
- // 璁剧疆娴佺▼鑺傜偣鐩存帴瀹屾垚
- param.setProgress(InoutConstant.PROGRESS_RECORD);
- if (null == data.getCompleteTime()) {
- data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2));
- }
- String msg = inoutService.toComplete(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(),
+ "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
+ }
- if (null != msg) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
- }
+ // 鎵︽牱鏃堕棿鍜屾墻鏍蜂汉
+ if (StringUtils.isEmpty(data.getSampleUser())) {
+ data.setSampleUser(ContextUtil.getLoginUserCName());
+ }
- // 搴撳瓨璋冩暣
- commonService.initInoutDepotStore(data);
+ if (null == data.getSampleTime()) {
+ data.setSampleTime(new Date());
+ }
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
- }
+ String msg = inoutService.updateSampleData(data);
- /**
- * 鎵︽牱鍖栭獙椤甸潰鑾峰彇妫�楠岄」鏉$洰淇℃伅
- *
- * @param data
- * @return
- */
- public PageResponse<List<CheckItemData>> getCheckItem(InoutData data) {
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+ }
- List<CheckItemData> result = checkStandardManager.listCheckItem(
- data.getCheckId(), data.getCompanyId(), data.getDeptId(),
- data.getFoodVariety());
+ // 鎵︽牱瀹屾垚瑙﹀彂浜嬩欢
+ inoutEventControl.onInSimple(data);
- return new PageResponse<>(RespCodeEnum.CODE_0000, result);
- }
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
+ }
- /**
- * 鍒犻櫎骞跺畬鎴�
- *
- * @param data
- * @return
- */
- public PageResponse<InoutData> deleteInoutData(InoutData data, String msg) {
- try {
- data.setRemarks(msg);
- String result = this.delInoutData(data, false);
- if (null != result) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- result, data);
- }
- } catch (Exception e) {
- log.error("鍚庡彴寮傚父:{}", e);
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�"
- + e.getMessage(), data);
- }
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц瀹屾垚",
- data);
- }
+ public PageResponse<InoutCheckData> submitCheck(InoutCheckData data) throws Exception {
- /**
- * 鍗″洖鏀堕�昏緫澶勭悊
- *
- * @param data
- * @return
- */
- public PageResponse<InoutData> inoutBack(InoutData data) {
- try {
- // 浠庣紦瀛樹腑鑾峰彇鏈�鏂扮殑鏁版嵁锛屽鏋滄病鏈夊垯琛ㄧず娴佺▼宸茬粡缁撴潫銆�
- InoutParam param = new InoutParam();
- param.setCompanyId(data.getCompanyId());
- param.setId(data.getId());
- InoutData curData = inoutService.inoutProgressQuery(param);
- if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "褰撳墠鍗℃祦绋嬪凡缁忓畬鎴愶紝鏃犻渶鎵ц鍗″洖鏀�", data);
- }
- if (InoutConstant.RECORD_STATUS_DEL.equals(curData
- .getRecordStatus())) {
- return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
- "褰撳墠鍗′俊鎭凡琚垹闄わ紝涓嶈兘鎵ц鍗″洖鏀�", data);
- }
+ // 鑾峰彇绯荤粺鍙傛暟閰嶇疆
+ InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
+ if (null == inoutSysConf) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鎻愮ず锛氬綋鍓嶅簱鍖烘湭閰嶇疆鍑哄叆搴撴祦绋嬩俊鎭紝璇疯仈绯荤鐞嗗憳", data);
+ }
- // 濡傛灉褰撳墠娴佺▼鐘舵�佹槸鍗″洖鏀剁姸鎬侊紝灏辨槸瀹屾垚娴佺▼銆�
- if (InoutConstant.PROGRESS_CARD_BACK.equals(curData.getProgress())) {
- return inoutComplete(curData);
- }
+ // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setId(data.getId());
+ InoutData curData = inoutService.inoutProgressQuery(param);
- // 濡傛灉鏄叾浠栫姸鎬侊紝鍒欐墽琛屽垹闄ら�昏緫
- return deleteInoutData(curData, "鍗″洖鏀跺垹闄�");
+ if (null == curData) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "娌℃湁鑾峰彇鍒板叆搴撲笟鍔℃暟鎹俊鎭紝鏇存柊澶辫触", data);
+ }
- } catch (Exception e) {
- return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
- "鍚庣鎵ц寮傚父锛�" + e.getMessage());
- }
- }
+ 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);
+ }
- /**
- * 琛ュ崟鎿嶄綔 琛ュ崟鍥犱负瀹屾垚鏃堕棿涓嶇‘瀹氾紝鎵�浠ラ渶瑕佺郴缁熸牴鎹綋鍓嶆暟鎹繘琛岃嚜鍔ㄦ娴嬶紝璋冩暣鍘熸潵娴佹按淇℃伅鍜屽簱瀛�
- *
- * @param data
- * @return
- * @throws Exception
- */
- @Transactional
- public String addInoutData(InoutData data) throws Exception {
+ // 璁剧疆鍖栭獙淇℃伅
+ if (checkResult.getDeSum() > 0) {
+ curData.setDeCheck(checkResult.getDeSum());
+ data.setDeCheck(checkResult.getDeSum());
+ }
+ if (checkResult.getAddSum() > 0) {
+ curData.setAddCheck(checkResult.getAddSum());
+ data.setAddCheck(checkResult.getAddSum());
+ }
+ if (null == data.getCheckTime()) {
+ curData.setCheckTime(new Date());
+ data.setCheckTime(new Date());
+ }
+ curData.setCheckStatus(data.getCheckStatus());
+ curData.setFoodYear(data.getFoodYear());
- if (data.getSettleWeight() <= 0.0) {
- return "琛ュ崟鏁版嵁瑕佹眰缁撶畻閲嶉噺蹇呴』澶т簬0";
- }
- // 琛ュ崟鏁版嵁鐩存帴鍒扮粨鏋滅姸鎬�
- data.setRecordStatus(InoutConstant.RECORD_STATUS_ADD);
- data.setProgress(InoutConstant.PROGRESS_RECORD);
- if (InoutConstant.STATUS_NONE.equals(data.getCheckStatus())) {
- data.setCheckStatus(InoutConstant.STATUS_PASS);
- }
+ // 鑾峰彇涓嬩竴涓祦绋嬬姸鎬�
+ String curProgress = curData.getProgress();
+ String nextProgress = getNextProgress(curProgress, curData.getType(), inoutSysConf);
+ curData = updateBasicInfo(curData, curProgress, nextProgress);
- String loginUser = ContextUtil.getLoginUserCName();
- data.setRegisterUser(loginUser);
- data.setFullWeightUser(loginUser);
- data.setEmptyWeightUser(loginUser);
- data.setHandleUser(loginUser);
- data.setCompleteUser(loginUser);
- if (null == data.getCompleteTime()) {
- data.setCompleteTime(new Date());
- }
- // 娉ㄥ唽鏃堕棿姣斿畬鎴愭椂闂存棭涓�涓皬鏃�
- data.setRegisterTime(DateUtil.getNewByMinute(new Date(), -60));
+ // 鑻ュ寲楠岀粨鏋滀笉鍚堟牸锛屽垽鏂厤缃悗缁祦绋�
+ if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) {
+ curData = checkNoPass(curData);
+ }
- if (StringUtils.isEmpty(data.getUserId())) {
- data.setUserId(InoutConstant.DEFAULT_ID_CARD);
- }
- if (null == data.getIntelCard()) {
- data.setIntelCard(data.getUserId());
- }
- if (null != data.getCheckItems()) {
- data.setCheckUser(loginUser);
- }
+ 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 (InoutConstant.TYPE_IN.equals(data.getType())) {
+ if (StringUtils.isEmpty(data.getCheckUser())) {
+ curData.setCheckUser(ContextUtil.getLoginUserCName());
+ }
+ if (null == data.getCheckTime()) {
+ curData.setCheckTime(new Date());
+ }
- if (null == data.getFullWeightTime()) {
- data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50));
- }
- if (null == data.getHandleEnd()) {
- data.setHandleEnd(DateUtil.getNewByMinute(new Date(), -40));
- }
- if (null == data.getEmptyWeightTime()) {
- data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10));
- }
+ String msg = inoutService.updateCheckData(curData);
- // 鍏堟墽琛屽寲楠屼俊鎭繚瀛�
- CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(),data.getCheckItems());
- if (null != checkResult) {
-// if (null == data.getWet())data.setWet(checkResult.getWet());
-// if (null == data.getImpurity())data.setImpurity(checkResult.getImpurity());
- }
- } else {
- if (null == data.getEmptyWeightTime()) {
- data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50));
- }
- if (null == data.getHandleEnd()) {
- data.setHandleEnd(DateUtil.getNewByMinute(new Date(), -40));
- }
- if (null == data.getFullWeightTime()) {
- data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10));
- }
- }
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+ }
- // 娣诲姞琛ュ崟鏁版嵁
- String msg = inoutService.insertData(data);
- // 鍒濆鍖栭獙璇佸嚭鍏ュ簱搴撳瓨
- commonService.initInoutDepotStore(data);
- return msg;
- }
+ // 璐ㄦ瀹屾垚瑙﹀彂浜嬩欢
+ inoutEventControl.onInCheck(data, curProgress, nextProgress);
- /**
- * 淇敼鎿嶄綔 淇敼閫昏緫璇存槑锛氫慨鏀规暟鎹渶瑕佽幏鍙栧師鏁版嵁搴撲腑鐨勬暟鎹繘琛屽姣斻��
- *
- * @param data
- * @return
- * @throws Exception
- */
- @javax.transaction.Transactional(rollbackOn = Exception.class)
- public String updateInoutData(InoutData data) throws Exception {
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛");
+ }
- if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
- return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒";
- }
- if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) {
- return "绯荤粺锛氬紓甯哥粓姝㈢殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒";
- }
+ public PageResponse<InoutCheckData> submitCheckData(InoutCheckData data) throws Exception {
- // 濡傛灉娴佺▼鏈粨鏉燂紝鍙洿鏂版暟鎹�
- if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- return inoutService.updateData(data);
- }
- // 濡傛灉鏄凡缁忓畬鎴愮殑鏁版嵁锛屽厛鑾峰彇鍒颁慨鏀圭洿鎺ョ殑鏁版嵁鏍规嵁鏁版嵁杩涜瀵规瘮
- InoutParam param = new InoutParam();
- param.setId(data.getId());
- param.setCompanyId(data.getCompanyId());
- param.setType(data.getType());
- InoutData record = inoutService.inoutQueryById(param);
+ // 鑾峰彇涓氬姟鏁版嵁淇℃伅
+ InoutParam param = new InoutParam();
+ param.setCompanyId(data.getCompanyId());
+ param.setId(data.getId());
+ InoutData curData = inoutService.inoutProgressQuery(param);
- if (null == record) {
- return "褰撳墠淇敼鏁版嵁宸茬粡涓嶅瓨鍦紒";
- }
+ if (null == curData) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "娌℃湁鑾峰彇鍒板叆搴撲笟鍔℃暟鎹俊鎭紝鏇存柊澶辫触", data);
+ }
- // 閬垮厤鏁版嵁搴撲腑鐨勬暟鎹凡缁忚鍏朵粬浜轰慨鏀�
- if (InoutConstant.RECORD_STATUS_DEL.equals(record.getRecordStatus())) {
- return "绯荤粺锛氬凡缁忓垹闄ょ殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒";
- }
- if (InoutConstant.RECORD_STATUS_ERROR.equals(record.getRecordStatus())) {
- return "绯荤粺锛氬紓甯哥粓姝㈢殑鏁版嵁涓嶆敮鎸佷慨鏀癸紒";
- }
+ if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "褰撳墠娴佺▼宸茬粡缁撴潫锛屼笉鏀寔淇敼");
+ }
- // 淇濆瓨妫�娴嬮」鐩�
- if (InoutConstant.TYPE_IN.equals(data.getType())) {
- // 鍏堟墽琛屽寲楠屼俊鎭繚瀛�
- CheckUpdateResult checkResult = checkStandardManager
- .updateCheckItems(data.getCheckId(), data.getCompanyId(),
- data.getCheckItems());
- if (null != checkResult) {
-// if (null == data.getWet())
-// data.setWet(checkResult.getWet());
-// if (null == data.getImpurity())
-// data.setImpurity(checkResult.getImpurity());
- }
- }
+ // 鏇存柊鍖栭獙椤逛俊鎭�
+ 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);
+ }
- // 鏇存柊鏁版嵁
- inoutService.updateData(data);
- // this.autoCheckByUpdate(data, record);
- return null;
- }
+ curData.setType(curData.getType());
+ curData.setFoodLevel(data.getFoodLevel());
+ curData.setFoodVariety(data.getFoodVariety());
+ curData.setPrice(data.getPrice());
+ curData.setDepotId(data.getDepotId());
+ curData.setCheckItems(data.getCheckItems());
- /**
- * 鍒犻櫎鎿嶄綔 鍒犻櫎鏁版嵁涓鸿蒋鍒犻櫎锛屽垹闄ゆ暟鎹悗闇�瑕佹牴鎹垹闄ゆ儏鍐佃仈鍔ㄥ簱瀛樼瓑淇℃伅
- *
- * @param data
- * @param selected
- * 鏄惁宸茬粡鏌ヨ杩囨暟鎹�
- * @return
- * @throws Exception
- */
- @Transactional
- public String delInoutData(InoutData data, boolean selected)
- throws Exception {
+ String msg = inoutService.updateCheckData(curData);
+ if (null != msg) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
+ }
- // 閬垮厤椤甸潰缂撳瓨棣栧厛鑾峰彇鏁版嵁搴撲腑鏈�鏂扮殑褰撳墠鏁版嵁淇℃伅
- InoutParam param = new InoutParam();
- param.setCompanyId(data.getCompanyId());
- param.setId(data.getId());
- param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]鎵ц鍒犻櫎锛屽師鍥狅細"
- + data.getRemarks());
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "淇濆瓨鎴愬姛");
+ }
- if (!selected) {
- data = inoutService.inoutQueryById(param);
+ /**
+ * @param param
+ * @return
+ */
+ public PageResponse<Page<InoutCheckData>> pageCheckData(
+ InoutCheckParam param) {
- if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
- return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸侀噸澶嶅垹闄わ紒";
- }
- if (InoutConstant.RECORD_STATUS_ERROR
- .equals(data.getRecordStatus())) {
- return "褰撳墠鏁版嵁宸茬粡琚爣璁颁负寮傚父锛屼笉鏀寔鍒犻櫎锛�";
- }
- }
+ if (StringUtils.isEmpty(param.getCompanyId())) {
+ param.setCompanyId(ContextUtil.getCompanyId());
+ }
+ if (StringUtils.isEmpty(param.getDeptId())) {
+ param.setDeptId(ContextUtil.subDeptId(null));
+ }
+ // 濡傛灉鏄凡鍖栭獙锛屽垯灏嗘祦绋嬬姸鎬佺疆绌猴紝濡傛灉鏄湭鍖栭獙锛屽垯娴佺▼鐘舵�佷笉澶勭悊锛屼粛鏄疌HECK鐘舵��
+ if (!"NONE".equals(param.getCheckStatus())) {
+ param.setProgress(null);
+ }
- // 鎵ц鍒犻櫎
- param.setProgress(InoutConstant.PROGRESS_RECORD);
- param.setRecordStatus(InoutConstant.RECORD_STATUS_DEL);
- param.setType(data.getType());
- inoutService.deleteData(param);
+ Page<InoutCheckData> checkList = inoutService.pageCheckData(param);
- // 濡傛灉娴佺▼鏈粨鏉燂紝鐩存帴鍒犻櫎锛屼笉鐗垫壇鍒拌仈鍔ㄨ皟鏁�
- if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- return null;
- }
- return null;
- }
+ if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "鑾峰彇鍒版暟鎹俊鎭负绌�");
+ }
+ return new PageResponse<>(RespCodeEnum.CODE_0000, checkList);
+ }
- /**
- * 寮傚父缁堟鎿嶄綔 璁剧疆寮傚父 涓轰簡閬垮厤椤甸潰鏁版嵁缂撳瓨锛岄渶瑕侀噸鏂拌幏鍙栨渶鏂版暟鎹垽鏂�
- *
- * @param data
- * @return
- * @throws Exception
- */
- @Transactional
- public String errorInoutData(InoutData data){
+ /**
+ * 鑾峰彇鍖栭獙椤逛俊鎭�
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<List<CheckItemData>> getCheckItemData(
+ InoutCheckParam param) {
- InoutParam param = new InoutParam();
- param.setCompanyId(data.getCompanyId());
- param.setId(data.getId());
- param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]鎵ц寮傚父缁堟锛屽師鍥狅細"
- + data.getRemarks());
- data = inoutService.inoutQueryById(param);
+ try {
+ List<CheckItemData> result = checkStandardManager.listCheckItem(
+ param.getCompanyId(), param.getCheckId(),
+ param.getFoodVariety());
- if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
- return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸佸紓甯稿鐞嗭紒";
- }
- if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) {
- return "涓嶆敮鎸侀噸澶嶅紓甯稿鐞嗭紒";
- }
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- return "娴佺▼缁撴潫鐨勬暟鎹笉鏀寔寮傚父澶勭悊锛�";
- }
+ return new PageResponse<>(RespCodeEnum.CODE_0000, result);
+ } catch (Exception e) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�"
+ + e.getMessage(), null);
+ }
+ }
- return inoutService.inoutStop(param);
- }
- /**
- * 蹇�熺粨鏉熸搷浣� 娴佺▼娌℃湁缁撴潫鐨勫崟鎹繘琛岀粨鏉�
- *
- * @param data
- * @return
- */
- public String completeInoutData(InoutData data) throws Exception {
- if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
- return "宸茬粡鍒犻櫎鐨勬暟鎹紝涓嶆敮鎸佸畬鎴愶紒";
- }
- if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) {
- return "寮傚父缁堟鐨勬暟鎹紝涓嶆敮鎸佸畬鎴愶紒";
- }
- if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- return "娴佺▼宸插畬鎴愮殑鏁版嵁锛屼笉鏀寔瀹屾垚锛�";
- }
+ /**
+ * 鑾峰彇鍗曚环淇℃伅
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<InoutPrice> getPrice(InoutCheckParam param) {
+ try {
- // 浠庢柊鏌ヨ鏁版嵁
- InoutParam param = new InoutParam();
- param.setId(data.getId());
- param.setCompanyId(data.getCompanyId());
- param.setType(data.getType());
- InoutData cuData = inoutService.inoutProgressQuery(param);
- if (null == cuData) {
- return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒";
- }
- if (!cuData.getProgress().equals(data.getProgress())) {
- return "褰撳墠杞﹁締娴佺▼鐘舵�佸凡缁忓彉鍖栵紝璇峰埛鏂伴〉闈㈤噸鏂版搷浣滐紒";
- }
+ List<InoutPrice> price = inoutService.getPrice(param);
+ if (null == price || price.isEmpty()) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
+ "鏈幏鍙栧埌绮瀹氫环閰嶇疆淇℃伅");
+ }
+ return new PageResponse<>(RespCodeEnum.CODE_0000, price.get(0));
- if (null == data.getCompleteTime()) {
- return "璇峰~鍐欏畬鎴愭椂闂达紒锛�";
- }
- if (StringUtils.isEmpty(data.getDepotId())) {
- return "璇峰~鍐欎粨搴撲俊鎭紒";
- }
- if (StringUtils.isEmpty(data.getCustomerId())) {
- return "璇峰~鍐欏線鏉ュ崟浣嶄俊鎭紒";
- }
- if (StringUtils.isEmpty(data.getFoodYear())) {
- return "璇峰~鍐欑伯椋熷勾浠戒俊鎭紒";
- }
- if (StringUtils.isEmpty(data.getFoodVariety())) {
- return "璇峰~鍐欑伯椋熷搧绉嶄俊鎭紒";
- }
+ } catch (Exception e) {
+ return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "鍚庡彴寮傚父锛�"
+ + e.getMessage(), null);
+ }
+ }
- if (data.getSettleWeight() <= 0) {
- return "璇峰~鍐欑粨绠楀噣閲嶄俊鎭紒";
- }
+ /**
+ * @param param
+ * @return
+ */
+ public PageResponse<InoutCheckData> inoutDataByCheckId(InoutCheckParam param) {
+ if (StringUtils.isEmpty(param.getCheckId())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
+ "鏌ヨ鍙傛暟涓嶅畬鏁达紝鏌ヨ澶辫触锛�");
+ }
- String msg = inoutService.quickComplete(data);
+ InoutCheckData result;
+ try {
+ param.setProgress(InoutConstant.PROGRESS_CHECK);
+ result = inoutService.inoutDataByCheckId(param);
+ if (null == result) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ "绯荤粺鏈煡璇㈠埌鎵ц涓殑杞﹁締淇℃伅", null);
+ }
- if (null == msg) {
- data.setProgress(InoutConstant.PROGRESS_RECORD);
- commonService.initInoutDepotStore(data);
- }
- return msg;
- }
+ return new PageResponse<>(RespCodeEnum.CODE_0000, result);
- public void initLpr(InoutConf conf) {
- inoutDeviceManager.initLpr(conf);
- }
-
- /**
- * 鑾峰彇鍑哄叆搴撹澶囬厤缃俊鎭�
- *
- * @param companyId
- * @param deptId
- * @return
- */
- public List<InoutConf> getListInoutConf(String companyId, String deptId) {
- return inoutManagerService.getCacheInoutConf(companyId, deptId);
- }
+ } catch (Exception e) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
+ e.getMessage());
+ }
+ }
- /**
- * 鎿嶄綔閬撻椄璁惧
- * @param param
- * @return
- */
- public PageResponse<List<CheckItemData>> gateCtrl(InoutGateDto param){
+ public void initInoutWeight(List<InoutConf> listInoutConf, String sort) {
+ inoutEventControl.initInoutWeight(listInoutConf, sort);
+ }
- return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "", null);
- }
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3