From 2e121f643a6776e6063796c104c95647faa000a8 Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期三, 16 八月 2023 11:52:32 +0800
Subject: [PATCH] 优化定时更新库存信息
---
igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java | 119 -------------------
igds-core/src/main/java/com/ld/igds/common/dto/DepotParam.java | 3
igds-core/src/main/java/com/ld/igds/common/impl/CommonDataServiceImpl.java | 1
igds-core/src/main/java/com/ld/igds/models/SecCamera.java | 5
igds-recir/src/main/java/com/ld/igds/models/DrugLogApply.java | 2
igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java | 140 +++++++++++++++++++++++
igds-core/src/main/resources/mapper/CommonMapper.xml | 3
igds-core/src/main/java/models/igds.model.xml | 36 ++++++
8 files changed, 190 insertions(+), 119 deletions(-)
diff --git a/igds-core/src/main/java/com/ld/igds/common/dto/DepotParam.java b/igds-core/src/main/java/com/ld/igds/common/dto/DepotParam.java
index ab2bd55..da0c126 100644
--- a/igds-core/src/main/java/com/ld/igds/common/dto/DepotParam.java
+++ b/igds-core/src/main/java/com/ld/igds/common/dto/DepotParam.java
@@ -23,6 +23,9 @@
@PropertyDef(label = "鎵�灞炰粨搴�", description = "浠撳簱缂栧彿")
private String depotId;
+ @PropertyDef(label = "浠撳簱鐘舵��", description = "浠撳簱鐘舵��")
+ private String depotStatus;
+
private Double weight;//閲嶉噺淇℃伅锛屽崟浣嶉渶瑕佽皟鏁翠负鍚�
}
diff --git a/igds-core/src/main/java/com/ld/igds/common/impl/CommonDataServiceImpl.java b/igds-core/src/main/java/com/ld/igds/common/impl/CommonDataServiceImpl.java
index 4fb07ed..3cc6230 100644
--- a/igds-core/src/main/java/com/ld/igds/common/impl/CommonDataServiceImpl.java
+++ b/igds-core/src/main/java/com/ld/igds/common/impl/CommonDataServiceImpl.java
@@ -330,6 +330,7 @@
param.setCompanyId(store.getCompanyId());
param.setDepotId(store.getDepotId());
param.setWeight(store.getStorageReal());
+ param.setDepotStatus(store.getDepotStatus());
commonMapper.updateDepotStorage(param);
}
diff --git a/igds-core/src/main/java/com/ld/igds/models/SecCamera.java b/igds-core/src/main/java/com/ld/igds/models/SecCamera.java
index 56c3288..ea10760 100644
--- a/igds-core/src/main/java/com/ld/igds/models/SecCamera.java
+++ b/igds-core/src/main/java/com/ld/igds/models/SecCamera.java
@@ -5,6 +5,7 @@
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
+import java.util.Date;
/**
* 瀹夐槻瑙嗛鐩戞帶璁惧
@@ -106,6 +107,10 @@
@PropertyDef(label = "鐩戠鑷姩鎶撴媿")
private String snapTag = Constant.YN_N;
+ @Column(name = "UPDATE_TIME_", length = 1)
+ @PropertyDef(label = "鏇存柊鏃堕棿")
+ private Date updateTime;
+
public int getChanNum() {
return chanNum;
}
diff --git a/igds-core/src/main/java/models/igds.model.xml b/igds-core/src/main/java/models/igds.model.xml
index 3ac10d3..68c3feb 100644
--- a/igds-core/src/main/java/models/igds.model.xml
+++ b/igds-core/src/main/java/models/igds.model.xml
@@ -344,6 +344,42 @@
<PropertyDef name="country">
<Property></Property>
<Property name="label">鍥藉埆</Property>
+ <Property name="mapping">
+ <Property name="keyProperty">key</Property>
+ <Property name="valueProperty">value</Property>
+ <Property name="mapValues">
+ <Collection>
+ <Entity>
+ <Property name="key">156</Property>
+ <Property name="value">涓浗</Property>
+ </Entity>
+ <Entity>
+ <Property name="key">076</Property>
+ <Property name="value">宸磋タ</Property>
+ </Entity>
+ <Entity>
+ <Property name="key">124</Property>
+ <Property name="value">鍔犳嬁澶�</Property>
+ </Entity>
+ <Entity>
+ <Property name="key">036</Property>
+ <Property name="value">婢冲ぇ鍒╀簹</Property>
+ </Entity>
+ <Entity>
+ <Property name="key">356</Property>
+ <Property name="value">鍗板害</Property>
+ </Entity>
+ <Entity>
+ <Property name="key">764</Property>
+ <Property name="value">娉板浗</Property>
+ </Entity>
+ <Entity>
+ <Property name="key">840</Property>
+ <Property name="value">缇庡浗</Property>
+ </Entity>
+ </Collection>
+ </Property>
+ </Property>
</PropertyDef>
<PropertyDef name="manageType">
<Property></Property>
diff --git a/igds-core/src/main/resources/mapper/CommonMapper.xml b/igds-core/src/main/resources/mapper/CommonMapper.xml
index 7948a31..11d7a80 100644
--- a/igds-core/src/main/resources/mapper/CommonMapper.xml
+++ b/igds-core/src/main/resources/mapper/CommonMapper.xml
@@ -119,7 +119,8 @@
<!--鏇存柊搴撳瓨 -->
<update id="updateDepotStorage" parameterType="com.ld.igds.common.dto.DepotParam">
update D_DEPOT set
- STORAGE_REAL_ = #{param.weight}
+ STORAGE_REAL_ = #{param.weight},
+ DEPOT_STATUS_ = #{param.depotStatus}
where COMPANY_ID_ =
#{param.companyId}
and ID_ = #{param.depotId}
diff --git a/igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java b/igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java
new file mode 100644
index 0000000..6ab6e90
--- /dev/null
+++ b/igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java
@@ -0,0 +1,140 @@
+package com.ld.igds.timer;
+
+import com.bstek.bdf2.core.model.DefaultCompany;
+import com.ld.igds.common.CoreCommonService;
+import com.ld.igds.constant.DepotStatus;
+import com.ld.igds.inout.InoutConstant;
+import com.ld.igds.inout.dto.InoutData;
+import com.ld.igds.inout.dto.InoutParam;
+import com.ld.igds.inout.service.InoutService;
+import com.ld.igds.models.DepotStore;
+import com.ld.igds.models.InoutRecord;
+import com.ld.igds.util.ContextUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Desc: 搴撳瓨瀹氭椂绠$悊 - 姣忔棩鏈夊嚭鍏ュ簱銆佹崯鐩婄瓑鏁版嵁鏃讹紝鐢熸垚1鏉″簱瀛樻暟鎹紝骞舵洿鏂板簱瀛�
+ * @author: czt
+ * @update-time: 2023/08/14
+ */
+@Slf4j
+@Component(DepotStoreScheduled.BEAN_ID)
+public class DepotStoreScheduled {
+
+ public static final String BEAN_ID = "inout.depotStoreScheduled";
+
+ @Resource
+ private InoutService inoutService;
+
+ @Resource
+ private CoreCommonService commonService;
+
+ /**
+ * 姣忓ぉ鏅氫笂11鐐�25鍒嗘洿鏂板簱瀛樻暟鎹�
+ */
+ @Scheduled(cron = "0 10 23 * * ?")
+ public void scheduled1() {
+
+ List<DefaultCompany> listCompany = commonService.getCompanyList();
+ if (null == listCompany)
+ return;
+
+ // 鑾峰彇褰撳ぉ鐨勫嚭鍏ュ簱璁板綍锛屽鏋滄湁璁板綍鍒欐墽琛岋紝濡傛灉娌℃湁锛屽垯鏃犻渶鎵ц
+ InoutParam param = new InoutParam();
+ param.setEnd(new Date());
+ param.setStart(DateUtils.addDays(param.getEnd(), -1));
+
+ List<InoutData> listRecord;
+ for (DefaultCompany company : listCompany) {
+ param.setCompanyId(company.getId());
+ listRecord = inoutService.listRecordData(param);
+
+ //鏍规嵁鍑哄叆搴撲俊鎭紝鍚屾搴撳瓨淇℃伅
+ sumDepotStoreExe(company.getId(), listRecord, param);
+ }
+
+ }
+
+ /**
+ * 鍚屾浠撳簱搴撳瓨锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄病鏈夎褰曞垯琛ㄧず鏃犲嚭鍏ュ簱鎿嶄綔锛屽彇娑堟墽琛�
+ *
+ * @param companyId
+ * @param listRecord
+ */
+ private void sumDepotStoreExe(String companyId, List<InoutData> listRecord, InoutParam param) {
+
+ if (null == listRecord || listRecord.isEmpty()) {
+ log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鍑哄叆搴撹褰曪紝鍙栨秷鍚屾浠撳簱搴撳瓨鈥︹�}", companyId);
+ return;
+ }
+
+ // 鑾峰彇鏈夊嚭鍏ュ簱璁板綍鐨勪粨搴�
+ Map<String, InoutRecord> map = new HashMap<>();
+ String key;
+ DepotStore lastStore;
+ double sumRecordWeight = 0.0;
+ for (InoutData data : listRecord) {
+ key = data.getDepotId() + "_" + data.getType();
+ if (null != map.get(key)) {
+ continue;
+ }
+
+ map.put(key, data);
+
+ // 鏍规嵁鏈�鍚庝竴杞﹁繘琛屾眹鎬荤粺璁★紝寮�濮嬫椂闂存槸浠撳簱搴撳瓨鏈�鍚庝竴涓椂闂存埅姝㈠埌褰撳墠
+ lastStore = commonService.getLastDepotStore(data.getDepotId());
+ if (null == lastStore) {
+ log.error("--------搴撳瓨瀹氭椂浠诲姟-----娌℃湁鑾峰彇鍒颁粨搴撴渶鍚庡簱瀛樹俊鎭紝鍙栨秷鑷姩缁熻锛岃鏍稿涓氬姟閫昏緫--浠撳簱-{}",
+ data.getDepotId());
+ continue;
+ }
+
+ param.setDeptId(data.getDeptId());
+ param.setDepotId(data.getDepotId());
+ param.setCompanyId(data.getCompanyId());
+ param.setType(data.getType());
+
+ //鑾峰彇鍑哄叆搴撶殑閲嶉噺淇℃伅
+ sumRecordWeight = inoutService.sumRecordWeight(param);
+
+ //鏂板涓�鏉″簱瀛樿褰�
+ lastStore.setRemark("绯荤粺瀹氭椂鐢熸垚璁板綍");
+ lastStore.setId(ContextUtil.getUUID());
+ lastStore.setUpdateUser("绯荤粺绠$悊鍛�");
+ lastStore.setUpdateDate(new Date());
+ lastStore.setCreateDate(new Date());
+ if(InoutConstant.TYPE_IN.equals(data.getType())){
+ lastStore.setStorageReal(lastStore.getStorageReal() + sumRecordWeight);
+ //璁剧疆浠撳簱鐘舵��
+ lastStore.setDepotStatus(DepotStatus.STATUS_2.getCode());
+ //璁剧疆鍏ュ簱鏃堕棿
+ if(null == lastStore.getStoreDate()){
+ lastStore.setStoreDate(data.getCompleteTime());
+ }
+ }
+ if(InoutConstant.TYPE_OUT.equals(data.getType())){
+ lastStore.setStorageReal(lastStore.getStorageReal() - sumRecordWeight);
+ lastStore.setDepotStatus(DepotStatus.STATUS_4.getCode());
+ //璁剧疆鍏ュ簱鏃堕棿
+ if(null == lastStore.getStoreDate()){
+ lastStore.setStoreDate(data.getCompleteTime());
+ }
+ //鑻ュ嚭搴撳悗鏁伴噺涓鸿礋鏁帮紝鍒欒缃簱瀛樻暟涓�0.0
+ if(lastStore.getStorageReal() < 0){
+ lastStore.setStorageReal(0.0);
+ }
+ }
+
+ lastStore.setStorageSettle(lastStore.getStorageReal());
+ commonService.addDepotStore(lastStore, true);
+ }
+ }
+}
\ No newline at end of file
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 11e9d06..787fe38 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
@@ -1,26 +1,19 @@
package com.ld.igds.timer;
import com.bstek.bdf2.core.model.DefaultCompany;
-import com.bstek.dorado.annotation.Expose;
import com.ld.igds.common.CoreCommonService;
-import com.ld.igds.constant.DepotStatus;
-import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
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.*;
-import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
-
import javax.annotation.Resource;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* @Desc: 鍑哄叆搴撳畾鏃朵换鍔°�� 1銆侀�氱煡鍗曞畬鎴愰噺缁熻 2銆佸嚭鍏ュ簱搴撳瓨绠$悊缁熻
@@ -31,7 +24,7 @@
@Component(InoutScheduled.BEAN_ID)
public class InoutScheduled {
- public static final String BEAN_ID = "basic.inoutScheduled";
+ public static final String BEAN_ID = "inout.inoutScheduled";
@Resource
private InoutCommonService inoutCommonService;
@@ -62,116 +55,8 @@
param.setCompanyId(company.getId());
listRecord = inoutService.listRecordData(param);
+ //鏍规嵁鍑哄叆搴撲俊鎭悓姝ラ�氱煡鍗曞畬鎴愰噺
noticeCompleteExe(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();
-
- start = DateUtil.getCurZero(start);
-
- // 鑾峰彇3澶╁唴鐨勫嚭鍏ュ簱璁板綍锛屽鏋滄湁璁板綍鍒欐墽琛岋紝濡傛灉娌℃湁锛屽垯鏃犻渶鎵ц
- start = DateUtil.getNewByDay(null, -3);
- String companyId = ContextUtil.getCompanyId();
-
- InoutParam param = new InoutParam();
- param.setStart(start);
- param.setCompanyId(companyId);
-
- List<InoutData> listRecord = inoutService.listRecordData(param);
-
- sumDepotStoreExe(companyId, listRecord);
-
- return "SUCCESS";
- }
-
- /**
- * 鍚屾浠撳簱搴撳瓨锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄病鏈夎褰曞垯琛ㄧず鏃犲嚭鍏ュ簱鎿嶄綔锛屽彇娑堟墽琛�
- *
- * @param companyId
- * @param listRecord
- */
- private void sumDepotStoreExe(String companyId, List<InoutData> listRecord) {
-
- if (null == listRecord || listRecord.isEmpty()) {
- log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鍑哄叆搴撹褰曪紝鍙栨秷鍚屾浠撳簱搴撳瓨鈥︹�}", companyId);
- return;
- }
-
- // 鑾峰彇鏈夊嚭鍏ュ簱璁板綍鐨勪粨搴�
- 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;
-
- map.put(key, data);
-
- // 鏍规嵁鏈�鍚庝竴杞﹁繘琛屾眹鎬荤粺璁★紝寮�濮嬫椂闂存槸浠撳簱搴撳瓨鏈�鍚庝竴涓椂闂存埅姝㈠埌褰撳墠
- 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())) {
-
- 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());
-
- // 鍑哄叆搴撻噸閲忓悎璁�
- sumRecordWeight = inoutService.sumRecordWeight(param);
-
- // 鏂板涓�鏉″簱瀛樿褰�
- 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);
- }
-
- if (InoutConstant.TYPE_OUT.equals(data.getType())) {
- lastStore.setStorageReal(lastStore.getStorageReal()
- - sumRecordWeight);
- }
-
- commonService.addDepotStore(lastStore, true);
- }
}
}
diff --git a/igds-recir/src/main/java/com/ld/igds/models/DrugLogApply.java b/igds-recir/src/main/java/com/ld/igds/models/DrugLogApply.java
index e9e08b8..6d03bad 100644
--- a/igds-recir/src/main/java/com/ld/igds/models/DrugLogApply.java
+++ b/igds-recir/src/main/java/com/ld/igds/models/DrugLogApply.java
@@ -10,7 +10,7 @@
import java.util.List;
/**
- * 鐔忚捀浣滀笟涓昏〃淇℃伅
+ * 鐔忚捀澶囨涓昏〃淇℃伅
*
* @Author:YAN
*/
--
Gitblit v1.9.3