From 5f48e04bf4bc594121d2ef3f768407393f643fe7 Mon Sep 17 00:00:00 2001
From: YYC <1833023622@qq.com>
Date: 星期六, 08 七月 2023 15:14:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java | 295 ++++++++++++++++++++++++++++------------------------------
1 files changed, 141 insertions(+), 154 deletions(-)
diff --git a/igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java b/igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java
index 511c9c9..11e9d06 100644
--- a/igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java
+++ b/igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java
@@ -3,7 +3,6 @@
import com.bstek.bdf2.core.model.DefaultCompany;
import com.bstek.dorado.annotation.Expose;
import com.ld.igds.common.CoreCommonService;
-import com.ld.igds.constant.Constant;
import com.ld.igds.constant.DepotStatus;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
@@ -24,9 +23,7 @@
import java.util.Map;
/**
- * @Desc: 鍑哄叆搴撳畾鏃朵换鍔°��
- * 1銆侀�氱煡鍗曞畬鎴愰噺缁熻
- * 2銆佸嚭鍏ュ簱搴撳瓨绠$悊缁熻
+ * @Desc: 鍑哄叆搴撳畾鏃朵换鍔°�� 1銆侀�氱煡鍗曞畬鎴愰噺缁熻 2銆佸嚭鍏ュ簱搴撳瓨绠$悊缁熻
* @author: Andy
* @update-time: 2022/11/22
*/
@@ -34,191 +31,181 @@
@Component(InoutScheduled.BEAN_ID)
public class InoutScheduled {
- public static final String BEAN_ID = "basic.inoutScheduled";
+ public static final String BEAN_ID = "basic.inoutScheduled";
- @Resource
- private InoutCommonService inoutCommonService;
+ @Resource
+ private InoutCommonService inoutCommonService;
- @Resource
- private InoutService inoutService;
+ @Resource
+ private InoutService inoutService;
- @Resource
- private CoreCommonService commonService;
+ @Resource
+ private CoreCommonService commonService;
+ /**
+ * 姣忓ぉ鏅氫笂11鐐硅繘琛屾洿鏂版湭瀹屾垚鍑哄叆搴撻�氱煡鍗曠殑瀹屾垚閲�
+ */
+ @Scheduled(cron = "0 0 23 * * ?")
+ public void scheduled1() {
- /**
- * 姣忓ぉ鏅氫笂11鐐硅繘琛屾洿鏂版湭瀹屾垚鍑哄叆搴撻�氱煡鍗曠殑瀹屾垚閲�
- */
- @Scheduled(cron = "0 0 23 * * ?")
- public void scheduled1() {
+ List<DefaultCompany> listCompany = commonService.getCompanyList();
+ if (null == listCompany)
+ return;
- List<DefaultCompany> listCompany = commonService.getCompanyList();
- if (null == listCompany) return;
+ // 鑾峰彇3澶╁唴鐨勫嚭鍏ュ簱璁板綍锛屽鏋滄湁璁板綍鍒欐墽琛岋紝濡傛灉娌℃湁锛屽垯鏃犻渶鎵ц
+ Date start = DateUtil.getNewByDay(null, -3);
+ InoutParam param;
+ List<InoutData> listRecord;
+ for (DefaultCompany company : listCompany) {
+ param = new InoutParam();
+ param.setStart(start);
+ param.setCompanyId(company.getId());
+ listRecord = inoutService.listRecordData(param);
- //鑾峰彇3澶╁唴鐨勫嚭鍏ュ簱璁板綍锛屽鏋滄湁璁板綍鍒欐墽琛岋紝濡傛灉娌℃湁锛屽垯鏃犻渶鎵ц
- Date start = DateUtil.getNewByDay(null, -3);
- InoutParam param;
- List<InoutData> listRecord;
- for (DefaultCompany company : listCompany) {
- param = new InoutParam();
- param.setStart(start);
- param.setCompanyId(company.getId());
- listRecord = inoutService.listRecordData(param);
+ noticeCompleteExe(company.getId(), listRecord);
- noticeCompleteExe(company.getId(), listRecord);
+ sumDepotStoreExe(company.getId(), listRecord);
+ }
- sumDepotStoreExe(company.getId(), listRecord);
- }
+ }
- }
+ /**
+ * basic.inoutScheduled#sumDepotStoreExeByHand
+ * <p>
+ * <p>
+ * 鎵嬪姩鎵ц鍑哄叆搴撳簱瀛樼粺璁″叆鍙�
+ *
+ * @param start
+ * @return
+ */
+ @Expose
+ public String sumDepotStoreExeByHand(Date start) {
+ if (null == start)
+ start = new Date();
- /**
- * basic.inoutScheduled#sumDepotStoreExeByHand
- * <p>
- * <p>
- * 鎵嬪姩鎵ц鍑哄叆搴撳簱瀛樼粺璁″叆鍙�
- *
- * @param start
- * @return
- */
- @Expose
- public String sumDepotStoreExeByHand(Date start) {
+ start = DateUtil.getCurZero(start);
- if (null == start) start = new Date();
+ // 鑾峰彇3澶╁唴鐨勫嚭鍏ュ簱璁板綍锛屽鏋滄湁璁板綍鍒欐墽琛岋紝濡傛灉娌℃湁锛屽垯鏃犻渶鎵ц
+ start = DateUtil.getNewByDay(null, -3);
+ String companyId = ContextUtil.getCompanyId();
- start = DateUtil.getCurZero(start);
+ InoutParam param = new InoutParam();
+ param.setStart(start);
+ param.setCompanyId(companyId);
- //鑾峰彇3澶╁唴鐨勫嚭鍏ュ簱璁板綍锛屽鏋滄湁璁板綍鍒欐墽琛岋紝濡傛灉娌℃湁锛屽垯鏃犻渶鎵ц
- start = DateUtil.getNewByDay(null, -3);
- String companyId = ContextUtil.getCompanyId();
+ List<InoutData> listRecord = inoutService.listRecordData(param);
- InoutParam param = new InoutParam();
- param.setStart(start);
- param.setCompanyId(companyId);
+ sumDepotStoreExe(companyId, listRecord);
- List<InoutData> listRecord = inoutService.listRecordData(param);
+ return "SUCCESS";
+ }
- sumDepotStoreExe(companyId, listRecord);
+ /**
+ * 鍚屾浠撳簱搴撳瓨锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄病鏈夎褰曞垯琛ㄧず鏃犲嚭鍏ュ簱鎿嶄綔锛屽彇娑堟墽琛�
+ *
+ * @param companyId
+ * @param listRecord
+ */
+ private void sumDepotStoreExe(String companyId, List<InoutData> listRecord) {
- return "SUCCESS";
- }
+ if (null == listRecord || listRecord.isEmpty()) {
+ log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鍑哄叆搴撹褰曪紝鍙栨秷鍚屾浠撳簱搴撳瓨鈥︹�}", companyId);
+ return;
+ }
- /**
- * 鍚屾浠撳簱搴撳瓨锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄病鏈夎褰曞垯琛ㄧず鏃犲嚭鍏ュ簱鎿嶄綔锛屽彇娑堟墽琛�
- *
- * @param companyId
- * @param listRecord
- */
- private void sumDepotStoreExe(String companyId, List<InoutData> listRecord) {
+ // 鑾峰彇鏈夊嚭鍏ュ簱璁板綍鐨勪粨搴�
+ Map<String, InoutRecord> map = new HashMap<>();
+ String key;
+ DepotStore lastStore;
+ double sumRecordWeight = 0.0;
+ InoutParam param;
+ for (InoutData data : listRecord) {
+ key = data.getDepotId() + "_" + data.getType();
+ if (null != map.get(key))
+ continue;
- if (null == listRecord || listRecord.isEmpty()) {
- log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鍑哄叆搴撹褰曪紝鍙栨秷鍚屾浠撳簱搴撳瓨鈥︹�}", companyId);
- return;
- }
+ map.put(key, data);
- //鑾峰彇鏈夊嚭鍏ュ簱璁板綍鐨勪粨搴�
- Map<String, InoutRecord> map = new HashMap<>();
- String key;
- DepotStore lastStore;
- double sumRecordWeight = 0.0;
- InoutParam param;
- for (InoutData data : listRecord) {
- key = data.getDepotId() + "_" + data.getType();
- if (null != map.get(key)) continue;
+ // 鏍规嵁鏈�鍚庝竴杞﹁繘琛屾眹鎬荤粺璁★紝寮�濮嬫椂闂存槸浠撳簱搴撳瓨鏈�鍚庝竴涓椂闂存埅姝㈠埌褰撳墠
+ lastStore = commonService.getLastDepotStore(data.getDepotId());
+ if (null == lastStore) {
+ log.error(
+ "--------鍑哄叆搴撳畾鏃朵换鍔�-----娌℃湁鑾峰彇鍒颁粨搴撴渶鍚庡簱瀛樹俊鎭紝鍙栨秷鑷姩缁熻锛岃鏍稿涓氬姟閫昏緫--浠撳簱-{}",
+ data.getDepotId());
+ continue;
+ }
+ // 鍙湁鍑哄叆搴撶姸鎬佺殑浠撳簱鎵嶈繘琛岀粺璁★紝鍏朵粬鐘舵�佽〃绀哄嚭鍏ュ簱浣滀笟瀹屾垚锛屼笉鍦ㄦ墽琛岀粺璁�
+ if (DepotStatus.STATUS_2.getCode().equals(
+ lastStore.getDepotStatus())
+ || DepotStatus.STATUS_4.getCode().equals(
+ lastStore.getDepotStatus())) {
- map.put(key, data);
+ param = new InoutParam();
+ // param.setStart(lastStore.getCreateDate());
+ param.setEnd(new Date());
+ param.setDeptId(data.getDeptId());
+ param.setDepotId(data.getDepotId());
+ param.setCompanyId(data.getCompanyId());
+ param.setType(data.getType());
- //鏍规嵁鏈�鍚庝竴杞﹁繘琛屾眹鎬荤粺璁★紝寮�濮嬫椂闂存槸浠撳簱搴撳瓨鏈�鍚庝竴涓椂闂存埅姝㈠埌褰撳墠
- lastStore = commonService.getLastDepotStore(data.getDepotId());
- if (null == lastStore) {
- log.error("--------鍑哄叆搴撳畾鏃朵换鍔�-----娌℃湁鑾峰彇鍒颁粨搴撴渶鍚庡簱瀛樹俊鎭紝鍙栨秷鑷姩缁熻锛岃鏍稿涓氬姟閫昏緫--浠撳簱-{}", data.getDepotId());
- continue;
- }
+ // 鍑哄叆搴撻噸閲忓悎璁�
+ sumRecordWeight = inoutService.sumRecordWeight(param);
+ // 鏂板涓�鏉″簱瀛樿褰�
+ lastStore.setRemark("绯荤粺瀹氭椂鐢熸垚璁板綍");
+ lastStore.setId(ContextUtil.getUUID());
+ lastStore.setUpdateUser(null);
+ lastStore.setUpdateDate(new Date());
+ // lastStore.setCreateDate(new Date());
- //鍙湁鍑哄叆搴撶姸鎬佺殑浠撳簱鎵嶈繘琛岀粺璁★紝鍏朵粬鐘舵�佽〃绀哄嚭鍏ュ簱浣滀笟瀹屾垚锛屼笉鍦ㄦ墽琛岀粺璁�
- if (DepotStatus.STATUS_2.getCode().equals(lastStore.getDepotStatus()) ||
- DepotStatus.STATUS_4.getCode().equals(lastStore.getDepotStatus())) {
+ if (InoutConstant.TYPE_IN.equals(data.getType())) {
+ lastStore.setStorageReal(lastStore.getStorageReal()
+ + sumRecordWeight);
+ }
- param = new InoutParam();
- //param.setStart(lastStore.getCreateDate());
- param.setEnd(new Date());
- param.setDeptId(data.getDeptId());
- param.setDepotId(data.getDepotId());
- param.setCompanyId(data.getCompanyId());
- param.setType(data.getType());
+ if (InoutConstant.TYPE_OUT.equals(data.getType())) {
+ lastStore.setStorageReal(lastStore.getStorageReal()
+ - sumRecordWeight);
+ }
- //鍑哄叆搴撻噸閲忓悎璁�
- sumRecordWeight = inoutService.sumRecordWeight(param);
+ commonService.addDepotStore(lastStore, true);
+ }
- //鏂板涓�鏉″簱瀛樿褰�
- lastStore.setRemark("绯荤粺瀹氭椂鐢熸垚璁板綍");
- lastStore.setId(ContextUtil.getUUID());
- lastStore.setUpdateUser(null);
- lastStore.setUpdateDate(new Date());
- // lastStore.setCreateDate(new Date());
+ }
+ }
- if (InoutConstant.TYPE_IN.equals(data.getType())) {
- lastStore.setStorageReal(lastStore.getStorageReal() + sumRecordWeight);
- }
+ /**
+ * 鍚屾閫氱煡鍗曞畬鎴愰噺锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄棤杩戞湡鍑哄叆搴撹褰曪紝鍒欒〃绀烘棤鍑哄叆搴撲綔涓氾紝鍙栨秷鎵ц
+ *
+ * @param companyId
+ * @param listRecord
+ */
+ public void noticeCompleteExe(String companyId, List<InoutData> listRecord) {
+ log.info("----------绯荤粺瀹氭椂鏇存柊鍑哄叆搴撻�氱煡鍗曞畬鎴愰噺----------");
- if (InoutConstant.TYPE_OUT.equals(data.getType())) {
- lastStore.setStorageReal(lastStore.getStorageReal() - sumRecordWeight);
- }
+ if (null == listRecord || listRecord.isEmpty()) {
+ log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鍑哄叆搴撹褰曪紝鍙栨秷鍚屾閫氱煡鍗曞畬鎴愰噺鈥︹�}", companyId);
+ return;
+ }
+
+ //TODO 寰呬紭鍖�
- commonService.addDepotStore(lastStore, true);
- }
+ // 鑾峰彇鎵�鏈夋湭瀹屾垚鐘舵�佺殑鍑哄簱閫氱煡鍗�
+ List<InoutNoticeOut> noticeOutList = inoutCommonService.getUnComNoticeOut(companyId);
- }
- }
+ // 鑾峰彇鎵�鏈夋湭瀹屾垚鐘舵�佺殑鍏ュ簱閫氱煡鍗�
+ List<InoutNoticeIn> noticeInList = inoutCommonService.getUnComNoticeIn(companyId);
+
+ String deptId = noticeInList.get(0).getDeptId();
+ // 鏇存柊鍏ュ簱閫氱煡鍗曞畬鎴愰噺
+ inoutCommonService.updateSumNoticeIn(deptId,
+ noticeInList);
- /**
- * 鍚屾閫氱煡鍗曞畬鎴愰噺锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄棤杩戞湡鍑哄叆搴撹褰曪紝鍒欒〃绀烘棤鍑哄叆搴撲綔涓氾紝鍙栨秷鎵ц
- *
- * @param companyId
- * @param listRecord
- */
- public void noticeCompleteExe(String companyId, List<InoutData> listRecord) {
- log.info("----------绯荤粺瀹氭椂鏇存柊鍑哄叆搴撻�氱煡鍗曞畬鎴愰噺----------");
-
- if (null == listRecord || listRecord.isEmpty()) {
- log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鍑哄叆搴撹褰曪紝鍙栨秷鍚屾閫氱煡鍗曞畬鎴愰噺鈥︹�}", companyId);
- return;
- }
-
-
- List<InoutSysConf> inoutSysConfList = inoutCommonService.getCacheInoutSysConf(companyId);
-
- //涓嶉厤缃鏄庢病鏈夊惎鍔ㄥ嚭鍏ュ簱
- if (null == inoutSysConfList || inoutSysConfList.isEmpty()) {
- return;
- }
-
- //鑾峰彇鎵�鏈夋湭瀹屾垚鐘舵�佺殑鍑哄簱閫氱煡鍗�
- List<InoutNoticeOut> noticeOutList = inoutCommonService.getUnComNoticeOut(companyId);
-
-
- //鑾峰彇鎵�鏈夋湭瀹屾垚鐘舵�佺殑鍏ュ簱閫氱煡鍗�
- List<InoutNoticeIn> noticeInList = inoutCommonService.getUnComNoticeIn(companyId);
-
-
- for (InoutSysConf inoutSysConf : inoutSysConfList) {
-
- // 鍒ゆ柇鍏ュ簱閫氱煡鍗曟槸鍚﹀惎鐢�
- if (Constant.YN_Y.equals(inoutSysConf.getNoticeTagIn())) {
- //鏇存柊鍏ュ簱閫氱煡鍗曞畬鎴愰噺
- inoutCommonService.updateSumNoticeIn(inoutSysConf.getDeptId(), noticeInList);
- }
-
- // 鍒ゆ柇鍑哄簱閫氱煡鍗曟槸鍚﹀惎鐢�
- if (Constant.YN_Y.equals(inoutSysConf.getNoticeTagOut())) {
- //鏇存柊鍑哄簱閫氱煡鍗曞畬鎴愰噺
- inoutCommonService.updateSumNoticeOut(inoutSysConf.getDeptId(), noticeOutList);
- }
- }
- }
+ // 鏇存柊鍑哄簱閫氱煡鍗曞畬鎴愰噺
+ inoutCommonService.updateSumNoticeOut(deptId,noticeOutList);
+ }
}
--
Gitblit v1.9.3