From 7fbb3a0cec59554367b527f55d81e3997eacf4c9 Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期三, 16 八月 2023 15:57:12 +0800
Subject: [PATCH] 增加根据损益信息定时更新库存
---
igds-inout/src/main/resources/mapper/InoutRecordMapper.xml | 75 ++++++++++++++++++
igds-inout/src/main/java/com/ld/igds/inout/mapper/InoutRecordMapper.java | 19 ++++
igds-web/src/main/resources/application-pro.yml | 4
igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java | 17 ++++
igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java | 75 +++++++++++++++++-
igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java | 17 ++++
6 files changed, 199 insertions(+), 8 deletions(-)
diff --git a/igds-inout/src/main/java/com/ld/igds/inout/mapper/InoutRecordMapper.java b/igds-inout/src/main/java/com/ld/igds/inout/mapper/InoutRecordMapper.java
index b1b0f60..b7421ec 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/mapper/InoutRecordMapper.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/mapper/InoutRecordMapper.java
@@ -5,6 +5,7 @@
import com.ld.igds.data.CommonData;
import com.ld.igds.inout.dto.*;
+import com.ld.igds.models.InoutLossOver;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.plugins.Page;
@@ -145,4 +146,20 @@
int checkExist(@Param("param") InoutParam param);
-}
+ /**
+ * 鏍规嵁鏉′欢鑾峰彇姝e父娴佹按淇℃伅锛岄粯璁ゅ崌搴�
+ *
+ * @param param
+ * @return
+ */
+ List<InoutLossOver> listLossOver(@Param("param") InoutParam param);
+
+ /**
+ * 鎹熺泭鑾峰彇寮�濮嬪懆鏈�---鎴嚦鍛ㄦ湡鍐咃紝鍑哄叆搴撳叆搴撻噸閲忔眹鎬诲悎璁�
+ *
+ * @param param
+ * @return CommonData.numValue1
+ */
+ CommonData sumLossOverWeight(@Param("param") InoutParam param);
+
+}
\ No newline at end of file
diff --git a/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java b/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java
index ee10982..091e600 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/service/InoutService.java
@@ -2,6 +2,7 @@
import com.ld.igds.data.Page;
import com.ld.igds.inout.dto.*;
+import com.ld.igds.models.InoutLossOver;
import com.ld.igds.models.InoutPrice;
import java.util.Date;
@@ -263,4 +264,20 @@
* @throws Exception
*/
InoutCheckData inoutDataByCheckId(InoutCheckParam param) throws Exception;
+
+ /**
+ * 鏍规嵁鏉′欢鑾峰彇鎹熺泭鍒楄〃锛岀敤浜庣粺璁″簱瀛樹娇鐢�
+ *
+ * @param param
+ * @return
+ */
+ List<InoutLossOver> listLossOver(InoutParam param);
+
+ /**
+ * 鑾峰彇鍑哄叆搴撲粠寮�濮嬪懆鏈熷埌缁撴潫鍛ㄦ湡鍐咃紝鍑哄叆搴撶殑鍏ュ簱閲嶉噺鍚堣
+ *
+ * @param param
+ * @return
+ */
+ double sumLossOverWeight(InoutParam param);
}
diff --git a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
index 2037a4d..2a878c5 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
@@ -13,6 +13,7 @@
import com.ld.igds.inout.mapper.InoutCheckMapper;
import com.ld.igds.inout.mapper.InoutRecordMapper;
import com.ld.igds.inout.service.InoutService;
+import com.ld.igds.models.InoutLossOver;
import com.ld.igds.models.InoutPrice;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
@@ -726,4 +727,20 @@
throw new Exception("褰撳墠鏉′欢涓嬪瓨鍦ㄥ涓弧瓒虫潯浠剁殑鏁版嵁锛岃鏍告煡锛侊紒");
}
}
+
+ @Override
+ public List<InoutLossOver> listLossOver(InoutParam param) {
+ if (StringUtils.isEmpty(param.getCompanyId())) {
+ param.setCompanyId(ContextUtil.getCompanyId());
+ }
+ List<InoutLossOver> list = inoutMapper.listLossOver(param);
+
+ return list;
+ }
+
+ @Override
+ public double sumLossOverWeight(InoutParam param) {
+ CommonData result = inoutMapper.sumLossOverWeight(param);
+ return result.getNumValue1();
+ }
}
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
index 6ab6e90..241d2c2 100644
--- a/igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java
+++ b/igds-inout/src/main/java/com/ld/igds/timer/DepotStoreScheduled.java
@@ -2,12 +2,14 @@
import com.bstek.bdf2.core.model.DefaultCompany;
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;
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.InoutLossOver;
import com.ld.igds.models.InoutRecord;
import com.ld.igds.util.ContextUtil;
import lombok.extern.slf4j.Slf4j;
@@ -53,14 +55,81 @@
param.setStart(DateUtils.addDays(param.getEnd(), -1));
List<InoutData> listRecord;
+ List<InoutLossOver> listLossOver;
for (DefaultCompany company : listCompany) {
param.setCompanyId(company.getId());
listRecord = inoutService.listRecordData(param);
- //鏍规嵁鍑哄叆搴撲俊鎭紝鍚屾搴撳瓨淇℃伅
+ // 鏍规嵁鍑哄叆搴撲俊鎭紝鍚屾搴撳瓨淇℃伅
sumDepotStoreExe(company.getId(), listRecord, param);
+
+ listLossOver = inoutService.listLossOver(param);
+ // 鏍规嵁鎹熻�椾俊鎭紝鍚屾搴撳瓨淇℃伅
+ sumDepotStoreByLossOver(company.getId(), listLossOver, param);
+
}
+ }
+
+ /**
+ * 鍚屾浠撳簱搴撳瓨锛屾牴鎹繎鏈熷嚭鍏ュ簱璁板綍锛屽鏋滄病鏈夎褰曞垯琛ㄧず鏃犲嚭鍏ュ簱鎿嶄綔锛屽彇娑堟墽琛�
+ *
+ * @param companyId
+ * @param listLossOver
+ */
+ private void sumDepotStoreByLossOver(String companyId, List<InoutLossOver> listLossOver, InoutParam param) {
+
+ if (null == listLossOver || listLossOver.isEmpty()) {
+ log.info("-----------绯荤粺鑷姩鍚屾搴撳瓨锛岃繎鏈熸棤鎹熺泭璁板綍锛屽彇娑堝悓姝ヤ粨搴撳簱瀛樷�︹�}", companyId);
+ return;
+ }
+
+ // 鑾峰彇鏈夊嚭鍏ュ簱璁板綍鐨勪粨搴�
+ Map<String, InoutLossOver> map = new HashMap<>();
+ String key;
+ DepotStore lastStore;
+ double sumRecordWeight = 0.0;
+ for (InoutLossOver data : listLossOver) {
+ 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.sumLossOverWeight(param);
+
+ //鏂板涓�鏉″簱瀛樿褰�
+ lastStore.setRemark("绯荤粺瀹氭椂鐢熸垚璁板綍");
+ lastStore.setId(ContextUtil.getUUID());
+ lastStore.setUpdateUser("绯荤粺绠$悊鍛�");
+ lastStore.setUpdateDate(new Date());
+ lastStore.setCreateDate(new Date());
+ if(Constant.LOSS_OVER_LOSS.equals(data.getType())){
+ lastStore.setStorageReal(lastStore.getStorageReal() + sumRecordWeight);
+
+ }
+ if(Constant.LOSS_OVER_OVER.equals(data.getType())){
+ lastStore.setStorageReal(lastStore.getStorageReal() - sumRecordWeight);
+ }
+
+ lastStore.setStorageSettle(lastStore.getStorageReal());
+ commonService.addDepotStore(lastStore, true);
+ }
}
/**
@@ -126,10 +195,6 @@
//璁剧疆鍏ュ簱鏃堕棿
if(null == lastStore.getStoreDate()){
lastStore.setStoreDate(data.getCompleteTime());
- }
- //鑻ュ嚭搴撳悗鏁伴噺涓鸿礋鏁帮紝鍒欒缃簱瀛樻暟涓�0.0
- if(lastStore.getStorageReal() < 0){
- lastStore.setStorageReal(0.0);
}
}
diff --git a/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml b/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml
index 53ecaf7..73bd4ac 100644
--- a/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml
+++ b/igds-inout/src/main/resources/mapper/InoutRecordMapper.xml
@@ -558,4 +558,79 @@
</if>
</select>
+ <!-- 鏍规嵁鏉′欢鏌ヨ锛岃姹傛椂闂存潯浠跺繀椤伙紝蹇呴』鏄甯告暟鎹� -->
+ <select id="listLossOver" resultType="com.ld.igds.models.InoutLossOver"
+ parameterType="com.ld.igds.inout.dto.InoutParam">
+ select
+ ID_ as id,
+ COMPANY_ID_ as companyId,
+ DEPT_ID_ as deptId,
+ DEPOT_ID_ as depotId,
+ TYPE_ as type,
+ SUBMIT_TIME_ as submitTime,
+ rkjz as rkjz,
+ rksj as rksj,
+ rksf as rksf,
+ rkzz as rkzz,
+ cksj as cksj,
+ ckjz as ckjz,
+ cksf as cksf,
+ ckzz as ckzz,
+ AMOUNT_ as amount,
+ sysfzc as sysfzc,
+ syyy as syyy,
+ ccshr as ccshr,
+ AUDIT_CCSH_ as auditCcsh,
+ INFO_CCSH_ as InfoCcsh,
+ zjshr as zjshr,
+ AUDIT_ZJSH_ as auditZjsh,
+ INFO_ZJSH_ as infoZjsh,
+ AUDIT_TJSH_ as auditTjsh,
+ INFO_TJSH_ as infoTjsh,
+ kjshr as kjshr,
+ AUDIT_KJSH_ as auditKjsh,
+ INFO_KJSH_ as infoKjsh,
+ ldshr as ldshr,
+ AUDIT_LDSH_ as auditLdsh,
+ INFO_LDSH_ as infoLdsh,
+ REMARK_ as remark,
+ UPDATE_TIME_ as updateTime,
+ UPDATE_USER_ as updateUser
+ from
+ D_INOUT_LOSS_OVER
+ <where>
+ <if test="param.companyId != null and param.companyId != '' ">AND COMPANY_ID_ = #{param.companyId}</if>
+ <if test="param.deptId != null and param.deptId != ''">AND DEPT_ID_ = #{param.deptId}</if>
+ <if test="param.depotId != null and param.depotId != '' ">AND DEPOT_ID_ = #{param.depotId}</if>
+ <if test="param.type != null and param.type != '' ">AND TYPE_ = #{param.type}</if>
+ <if test="param.end != null">AND
+ UPDATE_TIME_ <![CDATA[ < ]]>#{param.end,jdbcType=TIMESTAMP}
+ </if>
+ <if test="param.start != null">AND
+ UPDATE_TIME_ <![CDATA[ > ]]>#{param.start,jdbcType=TIMESTAMP}
+ </if>
+ ORDER BY UPDATE_TIME_
+ </where>
+ </select>
+
+ <!-- 鑾峰彇寮�濮嬪懆鏈�-鎴嚦鍛ㄦ湡鍐咃紝鍑哄叆搴撳叆搴撻噸閲忔眹鎬诲悎璁� -->
+ <select id="sumLossOverWeight" resultType="com.ld.igds.data.CommonData"
+ parameterType="com.ld.igds.inout.dto.InoutParam">
+ select SUM(AMOUNT_) as numValue1
+ from D_INOUT_LOSS_OVER
+ <where>
+ <if test="param.companyId != null and param.companyId != '' ">AND COMPANY_ID_ = #{param.companyId}</if>
+ <if test="param.deptId != null and param.deptId != ''">AND DEPT_ID_ = #{param.deptId}</if>
+ <if test="param.depotId != null and param.depotId != '' ">AND DEPOT_ID_ = #{param.depotId}</if>
+ <if test="param.type != null and param.type != '' ">AND TYPE_ = #{param.type}</if>
+ <if test="param.end != null">AND
+ UPDATE_TIME_ <![CDATA[ < ]]>#{param.end,jdbcType=TIMESTAMP}
+ </if>
+ <if test="param.start != null">AND
+ UPDATE_TIME_ <![CDATA[ > ]]>#{param.start,jdbcType=TIMESTAMP}
+ </if>
+ ORDER BY UPDATE_TIME_
+ </where>
+ </select>
+
</mapper>
\ No newline at end of file
diff --git a/igds-web/src/main/resources/application-pro.yml b/igds-web/src/main/resources/application-pro.yml
index 27476c9..5cc0298 100644
--- a/igds-web/src/main/resources/application-pro.yml
+++ b/igds-web/src/main/resources/application-pro.yml
@@ -1,4 +1,4 @@
-########################## 骞胯タ鏉ュ绮簱椤圭洰 ##########################
+########################## 骞夸笢鎯犲窞鎯犳柊绮簱椤圭洰 ##########################
server:
port: 8888
context-path: /
@@ -71,7 +71,7 @@
## 绯荤粺鎺ュ彛璺敱閰嶇疆 娉ㄦ剰鏁板瓧濡傛灉浠�0寮�澶寸殑璇濓紝鍚庡彴浼氬嚭鐜拌浆涔夛紝璇锋坊鍔�""
igds:
default:
- companyId: 5328
+ companyId: 5326
sys-name: 鏅烘収绮簱绠$悊绯荤粺
logo: logo-default.png
logo-title: logo-title-default.png
--
Gitblit v1.9.3