From a99c35bb764b1208141541e32034a973c34a3cd1 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期五, 16 一月 2026 15:42:48 +0800
Subject: [PATCH] 库存定时统计功能

---
 fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutConfPR.java                     |    2 
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutConfService.java        |   34 ++-
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java            |   12 +
 fzzy-igdss-core/src/main/java/com/fzzy/igds/timer/JobDepotStoreService.java      |  294 ++++++++++++++++++++++++++
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotStoreService.java       |   70 +----
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutLossOverService.java    |   22 +
 /dev/null                                                                        |   94 --------
 fzzy-igdss-core/src/main/java/com/fzzy/igds/domain/InoutLossOver.java            |    2 
 fzzy-igdss-web/src/main/resources/templates/login.html                           |    2 
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java      |   57 ++++-
 fzzy-igdss-web/src/main/resources/templates/index.html                           |    2 
 fzzy-igdss-web/src/main/java/com/fzzy/init/SystemRunner.java                     |   11 
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutStockChangeService.java |   26 ++
 13 files changed, 440 insertions(+), 188 deletions(-)

diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/domain/InoutLossOver.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/domain/InoutLossOver.java
index e90bbb8..90ba289 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/domain/InoutLossOver.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/domain/InoutLossOver.java
@@ -35,7 +35,7 @@
 	@TableField("dept_id")
 	private String deptId;
 
-	@Column(name = "depot_id", columnDefinition = "varchar(40) COMMENT '鍏ュ簱浠撳簱'")
+	@Column(name = "depot_id", columnDefinition = "varchar(40) COMMENT '鎹熺泭浠撳簱'")
 	@TableField("depot_id")
 	private String depotId;
 
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java
index 6406358..8c885e6 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.fzzy.igds.constant.RedisConst;
 import com.fzzy.igds.domain.Depot;
+import com.fzzy.igds.domain.DepotStore;
 import com.fzzy.igds.mapper.DepotMapper;
 import com.fzzy.igds.utils.ContextUtil;
 import com.ruoyi.common.core.redis.RedisCache;
@@ -58,6 +59,17 @@
     }
 
     /**
+     * 鏍规嵁搴撳瓨琛ㄤ俊鎭紝鏇存柊浠撳簱搴撳瓨
+     * @param data
+     */
+    public void updateByDepotStore(DepotStore data) {
+        UpdateWrapper<Depot> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.eq("id", data.getDepotId()).set("storage_real", data.getStorageReal());
+
+        depotMapper.update(null, updateWrapper);
+    }
+
+    /**
      * 淇濆瓨鏇存柊浠撳簱淇℃伅
      *
      * @param depot
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotStoreService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotStoreService.java
index 716e401..8fa744a 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotStoreService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotStoreService.java
@@ -1,18 +1,14 @@
 package com.fzzy.igds.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fzzy.igds.data.IgdsBaseParam;
-import com.fzzy.igds.domain.Depot;
 import com.fzzy.igds.domain.DepotStore;
-import com.fzzy.igds.mapper.DepotMapper;
 import com.fzzy.igds.mapper.DepotStoreMapper;
 import com.fzzy.igds.utils.ContextUtil;
 import com.fzzy.igds.utils.DateUtil;
 import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.Date;
@@ -28,9 +24,9 @@
 public class DepotStoreService {
 
     @Resource
-    private DepotStoreMapper depotStoreMapper;
+    private DepotService depotService;
     @Resource
-    private DepotMapper depotMapper;
+    private DepotStoreMapper depotStoreMapper;
 
     public void listPageData(Page<DepotStore> page, IgdsBaseParam param) {
         QueryWrapper<DepotStore> queryWrapper = new QueryWrapper<>();
@@ -53,41 +49,23 @@
         depotStoreMapper.selectPage(page, queryWrapper);
     }
 
-    /**
-     * 鏇存柊淇濆瓨鏁版嵁
-     *
-     * @param data
-     */
-    public void saveDepotStore(DepotStore data) {
-        if (StringUtils.isEmpty(data.getCompanyId())) {
-            data.setCompanyId(ContextUtil.getCompanyId());
-        }
-        if (StringUtils.isEmpty(data.getDeptId())) {
-            data.setDeptId(ContextUtil.subDeptId(null));
-        }
-        if (StringUtils.isEmpty(data.getId())) {
-            data.setId(data.getDepotId() + "_" + DateFormatUtils.format(data.getStoreDate(), "yyyyMMddHHmmss") + "_" + DateFormatUtils.format(data.getUpdateTime(), "yyyyMMddHHmmss"));
-            data.setCreateTime(new Date());
-            data.setRemark("绯荤粺鐢熸垚");
-            data.setUpdateBy(ContextUtil.getLoginUserName());
-            data.setUpdateTime(new Date());
-            depotStoreMapper.insert(data);
-        }else{
-            data.setUpdateBy(ContextUtil.getLoginUserName());
-            data.setUpdateTime(new Date());
-            depotStoreMapper.updateById(data);
-        }
-    }
+
 
     /**
-     * 鍒犻櫎鏁版嵁
-     *
+     * 鍏堟洿鏂帮紝濡傛灉娌℃湁鍒欐柊澧�
+     * 鏁版嵁澶勭悊濂斤紝姝ゆ柟娉曚笉澶勭悊浠讳綍瀛楁
      * @param data
-     * @return
      */
-    public String delDepotStore(DepotStore data) {
-        depotStoreMapper.deleteById(data);
-        return null;
+    public void updateAndSave(DepotStore data) {
+        int i = depotStoreMapper.updateById(data);
+        if(i < 1){
+            i = depotStoreMapper.insert(data);
+        }
+
+        if(i > 0){
+            //鏇存敼鍒颁粨搴撹〃
+            depotService.updateByDepotStore(data);
+        }
     }
 
     /**
@@ -101,9 +79,8 @@
 
         QueryWrapper<DepotStore> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("depot_id", depotId);
-        queryWrapper.ge("create_time", time);
-        queryWrapper.le("create_time", time);
-        queryWrapper.orderByDesc("create_time");
+        queryWrapper.le("update_time", time);
+        queryWrapper.orderByDesc("update_time");
 
         List<DepotStore> list = depotStoreMapper.selectList(queryWrapper);
 
@@ -111,19 +88,6 @@
             return null;
         }
         return list.get(0);
-    }
-
-    public void addDepotStore(DepotStore store, boolean updateDepot) {
-        if (null == store.getUpdateTime()) store.setUpdateTime(new Date());
-        if (null == store.getId()) store.setId(ContextUtil.generateId());
-
-        depotStoreMapper.insert(store);
-
-        if (updateDepot) {
-            UpdateWrapper<Depot> updateWrapper = new UpdateWrapper<>();
-            updateWrapper.eq("id", store.getDepotId()).set("storage_real", store.getStorageReal());
-            depotMapper.update(null, updateWrapper);
-        }
     }
 
 }
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutConfService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutConfService.java
index d39c997..c76b494 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutConfService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutConfService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.fzzy.igds.constant.Constant;
 import com.fzzy.igds.constant.RedisConst;
+import com.fzzy.igds.domain.Dept;
 import com.fzzy.igds.mapper.InoutConfMapper;
 import com.fzzy.igds.mapper.InoutSysConfMapper;
 import com.fzzy.igds.domain.InoutConf;
@@ -31,6 +32,8 @@
 public class InoutConfService {
     @Resource
     private ISysDeptService iSysDeptService;
+    @Resource
+    private CoreDeptService deptService;
     @Resource
     private InoutConfMapper inoutConfMapper;
     @Resource
@@ -181,16 +184,16 @@
      * @return
      */
     public List<InoutConf> getInoutConfList(String companyId, String deptId) {
+        QueryWrapper<InoutConf> queryWrapper = new QueryWrapper<>();
+
         if (StringUtils.isEmpty(companyId)) {
             companyId = ContextUtil.getCompanyId();
         }
-        if (StringUtils.isEmpty(deptId)) {
-            deptId = ContextUtil.subDeptId(null);
-        }
-        QueryWrapper<InoutConf> queryWrapper = new QueryWrapper<>();
-
-        queryWrapper.eq("dept_id", deptId);
         queryWrapper.eq("company_id", companyId);
+
+        if (StringUtils.isNotEmpty(deptId)) {
+            queryWrapper.eq("dept_id", deptId);
+        }
 
         return inoutConfMapper.selectList(queryWrapper);
     }
@@ -244,12 +247,21 @@
      * 璁剧疆缂撳瓨
      *
      * @param companyId
-     * @param deptId
      */
-    public void flushInoutConfCache(String companyId, String deptId) {
-        List<InoutConf> list = this.getInoutConfList(companyId, deptId);
-        String key = RedisConst.buildKey(companyId, Constant.CACHE_INOUT_CONF_LIST, deptId);
-        redisCache.setCacheObject(key, list);
+    public void flushInoutConfCache(String companyId) {
+        List<Dept> depts = deptService.listDept(null, companyId, null);
+        if(null == depts || depts.isEmpty()){
+            return;
+        }
+        List<InoutConf> inoutConfList;
+        for (Dept dept : depts) {
+            inoutConfList = this.getInoutConfList(companyId, dept.getId());
+            if(null == inoutConfList || inoutConfList.isEmpty()){
+                continue;
+            }
+            String key = RedisConst.buildKey(companyId, Constant.CACHE_INOUT_CONF_LIST, dept.getId());
+            redisCache.setCacheObject(key, inoutConfList);
+        }
     }
 
     /**
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutLossOverService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutLossOverService.java
index 34192b4..62cfc9d 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutLossOverService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutLossOverService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fzzy.igds.data.IgdsBaseParam;
 import com.fzzy.igds.domain.InoutLossOver;
+import com.fzzy.igds.domain.InoutStockChange;
 import com.fzzy.igds.mapper.InoutLossOverMapper;
 import com.fzzy.igds.utils.ContextUtil;
 import com.fzzy.igds.utils.DateUtil;
@@ -53,21 +54,24 @@
         inoutLossOverMapper.selectPage(page, queryWrapper);
     }
 
+
     /**
-     * 鏌ヨ搴撳尯涓嬫墍鏈変俊鎭�
+     * 鏍规嵁鏃堕棿绫诲瀷锛岃幏鍙栨暟鎹�
+     * @param timeType
+     * @param param
      * @return
      */
-    public List<InoutLossOver> listData(String companyId, String deptId) {
+    public List<InoutLossOver> getDataByTime(String timeType, IgdsBaseParam param) {
+        if(StringUtils.isBlank(timeType)){
+            return null;
+        }
 
         QueryWrapper<InoutLossOver> queryWrapper = new QueryWrapper<>();
 
-        if(StringUtils.isNotBlank(companyId)){
-            queryWrapper.eq("company_id", companyId);
-        }
-        if(StringUtils.isNotBlank(deptId)){
-            queryWrapper.eq("dept_id", deptId);
-        }
-        queryWrapper.orderByDesc("id");
+        queryWrapper.likeRight("dept_id", param.getDeptId());
+        queryWrapper.ge(timeType, param.getStart());
+        queryWrapper.le(timeType, param.getEnd());
+        queryWrapper.orderByAsc("loss_time");
 
         return inoutLossOverMapper.selectList(queryWrapper);
     }
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
index 489f288..159b5c2 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
@@ -6,6 +6,7 @@
 import com.fzzy.igds.constant.Constant;
 import com.fzzy.igds.constant.FoodVariety;
 import com.fzzy.igds.constant.RedisConst;
+import com.fzzy.igds.data.IgdsBaseParam;
 import com.fzzy.igds.data.InoutData;
 import com.fzzy.igds.data.InoutParam;
 import com.fzzy.igds.data.InoutPrintBill;
@@ -23,6 +24,7 @@
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
@@ -51,14 +53,15 @@
 
     /**
      * 鍒嗛〉鏌ヨ鏁版嵁
+     *
      * @param page
      * @param param
      */
     public void listPageInout(Page<InoutRecord> page, InoutParam param) {
-        if(StringUtils.isBlank(param.getCompanyId())){
+        if (StringUtils.isBlank(param.getCompanyId())) {
             param.setCompanyId(ContextUtil.getCompanyId());
         }
-        if(StringUtils.isBlank(param.getDeptId())){
+        if (StringUtils.isBlank(param.getDeptId())) {
             param.setDeptId(ContextUtil.subDeptId(null));
         }
         QueryWrapper<InoutRecord> queryWrapper = getQueryWrapper(param);
@@ -67,13 +70,14 @@
 
     /**
      * 鏌ヨ鏁版嵁闆嗗悎
+     *
      * @param param
      */
     public List<InoutRecord> listInout(InoutParam param) {
-        if(StringUtils.isBlank(param.getCompanyId())){
+        if (StringUtils.isBlank(param.getCompanyId())) {
             param.setCompanyId(ContextUtil.getCompanyId());
         }
-        if(StringUtils.isBlank(param.getDeptId())){
+        if (StringUtils.isBlank(param.getDeptId())) {
             param.setDeptId(ContextUtil.subDeptId(null));
         }
         QueryWrapper<InoutRecord> queryWrapper = getQueryWrapper(param);
@@ -83,6 +87,7 @@
 
     /**
      * 灏佽鏌ヨ鏉′欢
+     *
      * @param param
      */
     public QueryWrapper<InoutRecord> getQueryWrapper(InoutParam param) {
@@ -141,14 +146,37 @@
         return queryWrapper;
     }
 
+    /**
+     * 鏍规嵁鏃堕棿绫诲瀷锛岃幏鍙栧凡瀹屾垚鐨勬甯稿崟鎹�
+     * @param timeType
+     * @param param
+     * @return
+     */
+    public List<InoutRecord> getCompleteInoutByTime(String timeType, IgdsBaseParam param) {
+        if(StringUtils.isBlank(timeType)){
+             return null;
+        }
+
+        QueryWrapper<InoutRecord> queryWrapper = new QueryWrapper<>();
+
+        queryWrapper.likeRight("dept_id", param.getDeptId());
+        queryWrapper.likeRight("progress", Constant.PROGRESS_RECORD); //宸插畬鎴愮殑鍗曟嵁
+        queryWrapper.ne("record_status", Constant.RECORD_STATUS_DEL); //涓嶆槸鍒犻櫎鐨勫崟瀛愶紝鍗虫甯哥殑鍗曞瓙
+        queryWrapper.ge(timeType, param.getStart());
+        queryWrapper.le(timeType, param.getEnd());
+        queryWrapper.orderByAsc("complete_time");
+
+        return inoutRecordMapper.selectList(queryWrapper);
+    }
 
     /**
      * 鏌ヨ鏁版嵁
+     *
      * @param param
      * @return
      */
     public InoutRecord selectOne(InoutParam param) {
-        if(StringUtils.isBlank(param.getCompanyId())){
+        if (StringUtils.isBlank(param.getCompanyId())) {
             param.setCompanyId(ContextUtil.getCompanyId());
         }
         QueryWrapper<InoutRecord> queryWrapper = getQueryWrapper(param);
@@ -158,6 +186,7 @@
 
     /**
      * 楠岃瘉杞︾墝鍙锋槸鍚﹀湪娴佺▼涓�
+     *
      * @param companyId
      * @param plateNum
      * @return
@@ -177,6 +206,7 @@
 
     /**
      * 鎵嬪姩琛ュ崟
+     *
      * @param data
      * @return
      */
@@ -185,7 +215,7 @@
         //琛ュ崟鏁版嵁鐩存帴鍒扮粨鏋滅姸鎬�
         data.setRecordStatus(Constant.RECORD_STATUS_ADD);
         data.setProgress(Constant.PROGRESS_RECORD);
-        if(null != data.getPerWet() && data.getPerWet() > 0){
+        if (null != data.getPerWet() && data.getPerWet() > 0) {
             data.setCheckStatus(Constant.STATUS_CHECK);
         }
         String loginUser = ContextUtil.getLoginUserName();
@@ -238,7 +268,7 @@
                 data.setId("R_" + id);
             } else if (Constant.TYPE_OUT.equals(data.getType())) {
                 data.setId("C_" + id);
-            }else {
+            } else {
                 data.setId("M_" + id);
             }
         }
@@ -251,7 +281,7 @@
         //TODO 鏇存柊缂撳瓨
         //updateInoutCache(data);
         return num;
-        
+
     }
 
     /**
@@ -274,6 +304,7 @@
 
     /**
      * 寮傚父缁堟
+     *
      * @param data
      * @return
      */
@@ -297,15 +328,16 @@
 
         //TODO 鍒犻櫎缂撳瓨
 
-        if(i > 0){
+        if (i > 0) {
             return null;
-        }else {
+        } else {
             return "鎿嶄綔澶辫触锛�";
         }
     }
 
     /**
      * 鍑哄叆搴撴祦绋婭D鍒涘缓 202001030001 202001030001
+     *
      * @param registerTime
      * @param companyId
      * @return
@@ -369,6 +401,7 @@
 
     /**
      * 鏌ヨ鏈�澶d鍙凤紝涓虹┖鍒欒繑鍥瀗ull
+     *
      * @param companyId
      * @param timeKey
      * @return
@@ -385,9 +418,9 @@
         queryWrapper.orderByDesc("create_time");
 
         List<InoutRecord> inoutRecords = inoutRecordMapper.selectList(queryWrapper);
-        if(null == inoutRecords || inoutRecords.isEmpty()){
+        if (null == inoutRecords || inoutRecords.isEmpty()) {
             return null;
-        }else {
+        } else {
             return inoutRecords.get(0).getId();
         }
     }
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutStockChangeService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutStockChangeService.java
index c0aadcf..152e5a9 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutStockChangeService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutStockChangeService.java
@@ -2,6 +2,10 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fzzy.igds.constant.Constant;
+import com.fzzy.igds.data.IgdsBaseParam;
+import com.fzzy.igds.data.InoutParam;
+import com.fzzy.igds.domain.InoutRecord;
 import com.fzzy.igds.domain.InoutStockChange;
 import com.fzzy.igds.mapper.InoutStockChangeMapper;
 import com.fzzy.igds.utils.ContextUtil;
@@ -50,6 +54,28 @@
         inoutStockChangeMapper.selectPage(page, queryWrapper);
     }
 
+
+    /**
+     * 鏍规嵁鏃堕棿绫诲瀷锛岃幏鍙栨暟鎹�
+     * @param timeType
+     * @param param
+     * @return
+     */
+    public List<InoutStockChange> getDataByTime(String timeType, IgdsBaseParam param) {
+        if(StringUtils.isBlank(timeType)){
+            return null;
+        }
+
+        QueryWrapper<InoutStockChange> queryWrapper = new QueryWrapper<>();
+
+        queryWrapper.likeRight("dept_id", param.getDeptId());
+        queryWrapper.ge(timeType, param.getStart());
+        queryWrapper.le(timeType, param.getEnd());
+        queryWrapper.orderByAsc("change_date");
+
+        return inoutStockChangeMapper.selectList(queryWrapper);
+    }
+
     /**
      * 淇濆瓨鏁版嵁
      * @param data
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/timer/JobDepotStoreService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/timer/JobDepotStoreService.java
new file mode 100644
index 0000000..17cb22c
--- /dev/null
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/timer/JobDepotStoreService.java
@@ -0,0 +1,294 @@
+package com.fzzy.igds.timer;
+
+import com.fzzy.igds.constant.Constant;
+import com.fzzy.igds.data.IgdsBaseParam;
+import com.fzzy.igds.domain.*;
+import com.fzzy.igds.service.*;
+import com.fzzy.igds.utils.ContextUtil;
+import com.fzzy.igds.utils.DateUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.util.*;
+
+/**
+ * @Description 搴撳瓨瀹氭椂缁熻鍏ュ彛锛氶�氳繃妗嗘灦瀹氭椂浠诲姟璋冪敤锛岄粯璁ゆ瘡澶╁噷鏅�1鐐规墽琛岋紝缁熻鏄ㄥぉ鐨勫簱瀛樹俊鎭�
+ * @Author CZT
+ * @Date 2026/1/14 10:42
+ */
+@Slf4j
+@Service
+public class JobDepotStoreService {
+
+    @Resource
+    private CoreDeptService deptService;
+    @Resource
+    private InoutRecordService inoutRecordService;
+    @Resource
+    private InoutStockChangeService stockChangeService;
+    @Resource
+    private InoutLossOverService lossOverService;
+    @Resource
+    private DepotStoreService depotStoreService;
+    @Resource
+    private DepotService depotService;
+
+    public void timer() {
+        doExe();
+    }
+
+    /**
+     * 寮�濮嬫墽琛屽簱瀛樼粺璁�
+     */
+    public void doExe() {
+
+        Date time = DateUtil.getNewByDay(new Date(), -1);
+        log.info("===============绯荤粺瀹氭椂缁熻搴撳瓨淇℃伅===============");
+        //鑾峰彇鎵�鏈夌殑搴撳尯淇℃伅
+        List<Dept> listDept = deptService.listDept(null, ContextUtil.getCompanyId(), null);
+
+        if (null == listDept || listDept.isEmpty()) {
+            log.info("-----鏈幏鍙栧埌搴撳尯锛屼笉鎵ц搴撳瓨瀹氭椂缁熻-----");
+            return;
+        }
+
+        Date startTime = null; //鍑哄叆搴撴渶鏃╂椂闂�
+        for (Dept dept : listDept) {
+
+            startTime = getStartTime(time, dept);
+            if (null == startTime) {
+                log.info("-----{}鍦▄}鏈湁搴撳瓨鐩稿叧鏁伴噺鏇存柊锛屼笉鎵ц搴撳瓨缁熻-----", dept.getKqmc(), DateFormatUtils.format(time, "yyyy-MM-dd"));
+                continue;
+            }
+
+            //澶氬ぉ寰幆缁熻
+            sumMoreDepotStore(startTime, time, dept);
+        }
+    }
+
+    /**
+     * 澶氬ぉ寰幆閬嶅巻缁熻搴撳瓨淇℃伅
+     *
+     * @param startTime
+     * @param endTime
+     * @param dept
+     */
+    public void sumMoreDepotStore(Date startTime, Date endTime, Dept dept) {
+
+        log.info("-----缁熻搴撳瓨淇℃伅锛屽簱鍖�={}锛屾椂闂�={}--->{}-----", dept.getKqmc(), DateFormatUtils.format(startTime, "yyyy-MM-dd"), DateFormatUtils.format(endTime, "yyyy-MM-dd"));
+
+        //鑾峰彇涓や釜鏃堕棿鐩稿樊鐨勫ぉ鏁�
+        LocalDate startDate = LocalDate.parse(DateFormatUtils.format(startTime, "yyyy-MM-dd"));
+        LocalDate endDate = LocalDate.parse(DateFormatUtils.format(endTime, "yyyy-MM-dd"));
+
+        //浠庢渶鏃╁ぉ寮�濮嬪惊鐜粺璁″簱瀛樺埌褰撳墠澶�
+        while (!startDate.isAfter(endDate)) {
+
+            //缁熻搴撳尯搴撳瓨
+            sumDepotStore(startTime, dept);
+            //瀵瑰簲鏃堕棿鍔�1澶�
+            startTime = DateUtils.addDays(startTime, 1);
+            //灏嗘棩鏈熷姞1澶�
+            startDate = startDate.plusDays(1);
+        }
+
+    }
+
+    /**
+     * 鏍规嵁鏃堕棿锛岀粺璁℃洿鏂板綋澶╃殑搴撳瓨淇℃伅
+     *
+     * @param time
+     * @param dept
+     */
+    public void sumDepotStore(Date time, Dept dept) {
+        //鏇存敼涓哄綋澶╃殑23鐐�50鍒�
+        time = DateUtils.addMinutes(DateUtil.getNextZero(time), -10);
+
+        log.info("-----缁熻搴撳瓨淇℃伅锛屽簱鍖�={}锛屾椂闂�={}-----", dept.getKqmc(), DateFormatUtils.format(time, "yyyy-MM-dd"));
+        //璁剧疆鍙傛暟
+        IgdsBaseParam param = new IgdsBaseParam();
+        param.setStart(DateUtil.getCurZero(time));
+        param.setEnd(DateUtil.getNextZero(time));
+        param.setDeptId(dept.getId());
+
+        //鐢ㄤ簬瀛樻斁鏁伴噺鍙樺姩鐨勪粨搴�
+        Set<String> set = new HashSet<>();
+
+        //缁熻浠撳簱鐨勬暟閲�
+        Map<String, Double> map1 = new HashMap<>();
+        Map<String, Double> map2 = new HashMap<>();
+        Map<String, Double> map3 = new HashMap<>();
+
+        boolean inTag = false;
+        boolean outTag = false;
+        //鑾峰彇鍑哄叆搴撲俊鎭粺璁′粨搴撴暟閲�
+        List<InoutRecord> inoutRecords = inoutRecordService.getCompleteInoutByTime("complete_time", param);
+        if (null != inoutRecords && !inoutRecords.isEmpty()) {
+            for (InoutRecord inoutRecord : inoutRecords) {
+                set.add(inoutRecord.getDepotId());
+
+                map1.putIfAbsent(inoutRecord.getDepotId(), 0.0);
+
+                //缁熻鏁伴噺
+                if (Constant.TYPE_IN.equals(inoutRecord.getType())) {
+                    inTag = true;
+                    map1.put(inoutRecord.getDepotId(), map1.get(inoutRecord.getDepotId()) + inoutRecord.getRecordWeight());
+                }
+                if (Constant.TYPE_OUT.equals(inoutRecord.getType())) {
+                    outTag = true;
+                    map1.put(inoutRecord.getDepotId(), map1.get(inoutRecord.getDepotId()) - inoutRecord.getRecordWeight());
+                }
+            }
+        }
+
+        //鑾峰彇鍊掍粨淇℃伅缁熻浠撳簱鏁伴噺
+        List<InoutStockChange> stockChanges = stockChangeService.getDataByTime("change_date", param);
+        if (null != stockChanges && !stockChanges.isEmpty()) {
+            for (InoutStockChange stockChange : stockChanges) {
+                set.add(stockChange.getDepotIdIn());
+                set.add(stockChange.getDepotIdOut());
+
+                map2.putIfAbsent(stockChange.getDepotIdIn(), 0.0);
+                map2.putIfAbsent(stockChange.getDepotIdOut(), 0.0);
+
+                //缁熻鏁伴噺
+                map2.put(stockChange.getDepotIdIn(), map2.get(stockChange.getDepotIdIn()) + stockChange.getNumber());
+                map2.put(stockChange.getDepotIdOut(), map2.get(stockChange.getDepotIdOut()) - stockChange.getNumber());
+            }
+        }
+
+        //鑾峰彇鎹熺泭淇℃伅缁熻浠撳簱鏁伴噺
+        List<InoutLossOver> lossOvers = lossOverService.getDataByTime("loss_time", param);
+        if (null != lossOvers && !lossOvers.isEmpty()) {
+            for (InoutLossOver lossOver : lossOvers) {
+                set.add(lossOver.getDepotId());
+
+                map3.putIfAbsent(lossOver.getDepotId(), 0.0);
+
+                //缁熻鏁伴噺
+                if (Constant.TYPE_LOSS.equals(lossOver.getType())) {
+                    map1.put(lossOver.getDepotId(), map1.get(lossOver.getDepotId()) - lossOver.getAmount());
+                }
+                if (Constant.TYPE_OVER.equals(lossOver.getType())) {
+                    map1.put(lossOver.getDepotId(), map1.get(lossOver.getDepotId()) + lossOver.getAmount());
+                }
+            }
+        }
+
+        Double sum = 0.0;
+        Depot depot;
+        for (String s : set) {
+            sum = 0.0;
+            if (null != map1.get(s)) {
+                sum += map1.get(s);
+            }
+            if (null != map2.get(s)) {
+                sum += map2.get(s);
+            }
+            if (null != map3.get(s)) {
+                sum += map3.get(s);
+            }
+
+            //鑾峰彇涓婁竴鏉℃暟鎹�
+            DepotStore lastData = depotStoreService.getLastData(s, time);
+
+            if (null == lastData) {
+                lastData = new DepotStore();
+
+                //涓婚敭ID瑙勫垯锛歽yyyMMddHHmm_浠撳簱缂栫爜
+                lastData.setId(DateFormatUtils.format(time, "yyyyMMddHHmm") + "_" + s);
+                lastData.setCompanyId(dept.getCompanyId());
+                lastData.setDeptId(dept.getId());
+                lastData.setDepotId(s);
+                lastData.setStorageReal(0.0);
+                lastData.setUpdateTime(time);
+                lastData.setUpdateBy("绯荤粺瀹氭椂缁熻");
+                if (inTag) {
+                    //璁剧疆鍏ュ簱鏃堕棿
+                    lastData.setStoreDate(time);
+                }
+                if (outTag) {
+                    //璁剧疆鍑哄簱鏃堕棿
+                    lastData.setOutDate(time);
+                }
+                //鑾峰彇浠撳簱淇℃伅
+                depot = depotService.getCacheDepot(dept.getCompanyId(), s);
+                if (null != depot) {
+                    lastData.setDepotStatus(depot.getDepotStatus());
+                    lastData.setFoodVariety(depot.getFoodVariety());
+                    lastData.setFoodLevel(depot.getFoodLevel());
+                    lastData.setFoodLocation(depot.getFoodLocation());
+                    lastData.setFoodLocationId(depot.getFoodLocationId());
+                    lastData.setFoodType(depot.getFoodType());
+                    lastData.setFoodYear(depot.getFoodYear());
+                }
+
+            }
+
+            lastData.setStorageReal(lastData.getStorageReal() + sum);
+            lastData.setCreateTime(new Date()); //璁剧疆涓烘渶鏂版椂闂达紝鍏朵粬绯荤粺鍙互閫氳繃姝ゆ椂闂存煡璇㈡暟鎹槸鍚︽湁鏇存柊淇敼锛屽悓姝ュ埌鐪佸钩鍙版帴鍙c��
+            lastData.setCreateBy("绯荤粺瀹氭椂缁熻");
+            lastData.setRemark("绯荤粺缁熻" + DateFormatUtils.format(time, "yyyy-MM-dd") + "鏃ュ簱瀛�");
+
+            depotStoreService.updateAndSave(lastData);
+
+        }
+
+    }
+
+
+    /**
+     * 鏍规嵁鏃堕棿锛岀粺璁℃洿鏂板綋澶╃殑搴撳瓨淇℃伅
+     *
+     * @param dept
+     */
+    public Date getStartTime(Date time, Dept dept) {
+
+        Date startTime = time; //鍑哄叆搴撴渶鏃╂椂闂�
+        Date time1 = null; //鍑哄叆搴撴渶鏃╂椂闂�
+        Date time2 = null; //鍊掍粨鏈�鏃╂椂闂�
+        Date time3 = null; //鎹熺泭鏈�鏃╂椂闂�
+
+        //鑾峰彇褰撳ぉ鏈夋洿鏂扮殑鍑哄叆搴撲俊鎭�
+        IgdsBaseParam param = new IgdsBaseParam();
+        param.setStart(DateUtil.getCurZero(time));
+        param.setEnd(DateUtil.getNextZero(time));
+        //鑾峰彇褰撳ぉ鏈夋洿鏂扮殑鍑哄叆搴撲俊鎭�
+        param.setDeptId(dept.getId());
+        List<InoutRecord> inoutRecords = inoutRecordService.getCompleteInoutByTime("update_time", param);
+        if (null != inoutRecords && !inoutRecords.isEmpty()) {
+            time1 = inoutRecords.get(0).getCompleteTime();
+        }
+
+        //鑾峰彇褰撳ぉ鏈夋洿鏂扮殑鍊掍粨鏁版嵁
+        List<InoutStockChange> stockChanges = stockChangeService.getDataByTime("update_time", param);
+        if (null != stockChanges && !stockChanges.isEmpty()) {
+            time2 = stockChanges.get(0).getChangeDate();
+        }
+
+        //鑾峰彇褰撳ぉ鏈夋洿鏂扮殑鎹熺泭鏁版嵁
+        List<InoutLossOver> lossOvers = lossOverService.getDataByTime("update_time", param);
+        if (null != lossOvers && !lossOvers.isEmpty()) {
+            time3 = lossOvers.get(0).getLossTime();
+        }
+
+        if (null == time1 && null == time2 && null == time3) {
+            return null;
+        }
+        if (null != time1 && time1.before(startTime)) {
+            startTime = time1;
+        }
+        if (null != time2 && time2.before(startTime)) {
+            startTime = time2;
+        }
+        if (null != time3 && time3.before(startTime)) {
+            startTime = time3;
+        }
+        return startTime;
+    }
+
+}
diff --git a/fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutConfPR.java b/fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutConfPR.java
index 137223f..4ae2263 100644
--- a/fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutConfPR.java
+++ b/fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutConfPR.java
@@ -65,7 +65,7 @@
      */
     @Expose
     public void flushCache(InoutConf data) {
-        inoutConfService.flushInoutConfCache(data.getCompanyId(), data.getDeptId());
+        inoutConfService.flushInoutConfCache(data.getCompanyId());
     }
 
 }
diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/init/SystemRunner.java b/fzzy-igdss-web/src/main/java/com/fzzy/init/SystemRunner.java
index d243d47..3eea1d2 100644
--- a/fzzy-igdss-web/src/main/java/com/fzzy/init/SystemRunner.java
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/init/SystemRunner.java
@@ -2,6 +2,7 @@
 
 import com.fzzy.igds.domain.Dept;
 import com.fzzy.igds.service.*;
+import com.ruoyi.system.domain.SysCompany;
 import com.ruoyi.system.service.ISysCompanyService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.CommandLineRunner;
@@ -46,11 +47,11 @@
     public void run(String... args) throws Exception {
         //缁勭粐淇℃伅鏀惧叆缂撳瓨
         iSysCompanyService.resetCompanyCache();
-        List<Dept> list = coreDeptService.listDept(null, null, null);
+        List<SysCompany> list = iSysCompanyService.selectAll();
 
-        for (Dept dept : list) {
+        for (SysCompany company : list) {
 
-            flushCache(dept.getCompanyId(),dept.getId(), "绯荤粺璋冪敤");
+            flushCache(company.getCompanyId(), "绯荤粺璋冪敤");
         }
     }
 
@@ -60,7 +61,7 @@
      * @param companyId
      * @param name
      */
-    public void flushCache(String companyId,String deptId, String name) {
+    public void flushCache(String companyId, String name) {
 
         //鍒濆鍖栫敤鎴烽儴闂ㄥ埌鍐呭瓨
         sysDeptService.initUserDeptMap(companyId);
@@ -72,7 +73,7 @@
         inoutConfService.flushInoutSysConfCache();
 
         //鍒濆璁惧閰嶇疆
-        inoutConfService.flushInoutConfCache(companyId, deptId);
+        inoutConfService.flushInoutConfCache(companyId);
 
         //鍒濆鍖栦粨搴撶紦瀛�
         depotService.flushCache(companyId);
diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/sys/init/SystemRunner.java b/fzzy-igdss-web/src/main/java/com/fzzy/sys/init/SystemRunner.java
deleted file mode 100644
index 8700ced..0000000
--- a/fzzy-igdss-web/src/main/java/com/fzzy/sys/init/SystemRunner.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.fzzy.sys.init;
-
-import com.bstek.dorado.annotation.Expose;
-import com.fzzy.igds.service.*;
-import com.ruoyi.system.domain.SysCompany;
-import com.ruoyi.system.service.ISysCompanyService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * @Description 閰嶇疆绯荤粺绾у埆鐨勯」鐩惎鍔ㄥ垵濮嬪寲淇℃伅
- * @Author CZT
- * @Date 2025/11/29 16:49
- */
-@Service
-@Slf4j
-@Order(value = 1)
-public class SystemRunner implements CommandLineRunner {
-
-    @Resource
-    private ISysCompanyService iSysCompanyService;
-    @Resource
-    private SysDeptService sysDeptService;
-    @Resource
-    private DicService dicService;
-    @Resource
-    private DepotService depotService;
-    @Resource
-    private DepotConfService depotConfService;
-    @Resource
-    private DeviceSerService deviceSerService;
-
-    @Override
-    public void run(String... args) throws Exception {
-        //缁勭粐淇℃伅鏀惧叆缂撳瓨
-        iSysCompanyService.resetCompanyCache();
-        List<SysCompany> list = iSysCompanyService.selectAll();
-
-        for (SysCompany company : list) {
-
-            flushCache(company.getCompanyId(), "绯荤粺璋冪敤");
-        }
-    }
-
-    /**
-     * 骞冲彴绯荤粺锛屾墜鍔ㄥ埛鏂版墍鏈夌紦瀛�
-     * <p>
-     * systemRunner#flushAllCache
-     *
-     * @param companyId
-     */
-    @Expose
-    public void flushAllCache(String companyId) {
-        flushCache(companyId, "鎵嬪姩璋冪敤");
-    }
-
-    /**
-     * 鍒嗙粍缁囧垵濮嬪寲
-     *
-     * @param companyId
-     * @param name
-     */
-    public void flushCache(String companyId, String name) {
-
-        //鍒濆鍖栫敤鎴烽儴闂ㄥ埌鍐呭瓨
-        sysDeptService.initUserDeptMap(companyId);
-
-        //鍒濆鍖栧父鐢ㄥ瓧鍏稿埌鍐呭瓨
-        dicService.initDicMap(companyId);
-
-        //鍒濆鍖栦粨搴撶紦瀛�
-        depotService.flushCache(companyId);
-        //鍙傛暟閰嶇疆
-        depotConfService.flushConfCache(companyId);
-        //璁剧疆鍒嗘満鍏ㄩ儴鎺夌嚎
-        deviceSerService.allOffLine(companyId);
-        //鍒锋柊鍒嗘満鍒扮紦瀛�
-        deviceSerService.refreshCache(companyId);
-
-        log.info("* ");
-        log.info("* ========================");
-        log.info("* ");
-        log.info("* 缁勭粐={}锛寋}鍒濆鍖栫紦瀛樺畬鎴愨�︹�︹�︹��", companyId, name);
-        log.info("* ");
-        log.info("* ========================");
-        log.info("* ");
-    }
-
-
-}
diff --git a/fzzy-igdss-web/src/main/resources/templates/index.html b/fzzy-igdss-web/src/main/resources/templates/index.html
index dc7cbdc..ba46527 100644
--- a/fzzy-igdss-web/src/main/resources/templates/index.html
+++ b/fzzy-igdss-web/src/main/resources/templates/index.html
@@ -152,7 +152,7 @@
             </button>
             <nav class="page-tabs menuTabs">
                 <div class="page-tabs-content">
-                    <a th:href="@{/index}" class="active menuTab" th:data-id="${welcomeUrl}">娆㈣繋</a>
+                    <a href="javascript:void(0);" class="active menuTab" th:data-id="${welcomeUrl}">娆㈣繋</a>
                 </div>
             </nav>
             <button class="roll-nav roll-right tabRight">
diff --git a/fzzy-igdss-web/src/main/resources/templates/login.html b/fzzy-igdss-web/src/main/resources/templates/login.html
index b6cc336..d30a247 100644
--- a/fzzy-igdss-web/src/main/resources/templates/login.html
+++ b/fzzy-igdss-web/src/main/resources/templates/login.html
@@ -120,7 +120,7 @@
     <!--鎵嬫満APP-->
     <div class="login2-ewm css-hand">
         <h3>
-            <i class="i-icon"><img th:src="@{/login/images/login-app-code.png}"/></i>涓嬭浇APP
+<!--            <i class="i-icon"><img th:src="@{/login/images/login-app-code.png}"/></i>涓嬭浇APP-->
         </h3>
     </div>
 

--
Gitblit v1.9.3