czt
2026-02-26 181252cf8ba494441b1fdb3873da7afa90ff0813
fzzy-igdss-core/src/main/java/com/fzzy/igds/timer/JobDepotStoreService.java
@@ -13,6 +13,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.*;
@@ -41,6 +42,32 @@
    @Scheduled(cron = "0 0 1 * * ?")
    public void timer() {
        doExe();
    }
    /**
     * 手动执行库存统计
     * @param timeStr
     * @throws ParseException
     */
    public void doExeHand(String timeStr) throws ParseException {
        log.info("===============手动统计库存信息===============");
        //获取所有的库区信息
        List<Dept> listDept = deptService.listDept(null, ContextUtil.getCompanyId(), null);
        if (null == listDept || listDept.isEmpty()) {
            log.info("-----未获取到库区,不执行库存定时统计-----");
            return;
        }
        Date startTime = DateUtils.parseDate(timeStr, "yyyy-MM-dd");
        Date endTime = new Date();
        for (Dept dept : listDept) {
            //多天循环统计
            sumMoreDepotStore(startTime, endTime, dept);
        }
    }
    /**
@@ -201,14 +228,8 @@
            if (null == lastData) {
                lastData = new DepotStore();
                //主键ID规则:yyyyMMddHHmm_仓库编码
                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);
@@ -217,6 +238,18 @@
                    //设置出库时间
                    lastData.setOutDate(time);
                }
            }
            //主键ID规则:yyyyMMddHHmm_仓库编码
            lastData.setId(DateFormatUtils.format(time, "yyyyMMddHHmm") + "_" + s);
            lastData.setCompanyId(dept.getCompanyId());
            lastData.setDeptId(dept.getId());
            lastData.setDepotId(s);
            lastData.setUpdateTime(time);
            lastData.setUpdateBy("系统定时统计");
                //获取仓库信息
                depot = depotService.getCacheDepot(dept.getCompanyId(), s);
                if (null != depot) {
@@ -227,8 +260,6 @@
                    lastData.setFoodLocationId(depot.getFoodLocationId());
                    lastData.setFoodType(depot.getFoodType());
                    lastData.setFoodYear(depot.getFoodYear());
                }
            }
            lastData.setStorageReal(lastData.getStorageReal() + sum);