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); /** * 根据条件获取正常流水信息,默认升序 * * @param param * @return */ List<InoutLossOver> listLossOver(@Param("param") InoutParam param); /** * 损益获取开始周期---截至周期内,出入库入库重量汇总合计 * * @param param * @return CommonData.numValue1 */ CommonData sumLossOverWeight(@Param("param") InoutParam param); } 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); } 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(); } } 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); } } 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> 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