jiazx0107@163.com
2023-06-08 08cea428e888b6fdd2a3c3783e87e4f828385783
igds-inout/src/main/java/com/ld/igds/timer/InoutScheduled.java
@@ -23,9 +23,7 @@
import java.util.Map;
/**
 * @Desc: 出入库定时任务。
 * 1、通知单完成量统计
 * 2、出入库库存管理统计
 * @Desc: 出入库定时任务。 1、通知单完成量统计 2、出入库库存管理统计
 * @author: Andy
 * @update-time: 2022/11/22
 */
@@ -44,7 +42,6 @@
    @Resource
    private CoreCommonService commonService;
    /**
     * 每天晚上11点进行更新未完成出入库通知单的完成量
     */
@@ -52,7 +49,8 @@
    public void scheduled1() {
        List<DefaultCompany> listCompany = commonService.getCompanyList();
        if (null == listCompany) return;
      if (null == listCompany)
         return;
        //获取3天内的出入库记录,如果有记录则执行,如果没有,则无需执行
        Date start = DateUtil.getNewByDay(null, -3);
@@ -71,7 +69,6 @@
    }
    /**
     * basic.inoutScheduled#sumDepotStoreExeByHand
     * <p>
@@ -84,7 +81,8 @@
    @Expose
    public String sumDepotStoreExeByHand(Date start) {
        if (null == start) start = new Date();
      if (null == start)
         start = new Date();
        start = DateUtil.getCurZero(start);
@@ -124,22 +122,25 @@
        InoutParam param;
        for (InoutData data : listRecord) {
            key = data.getDepotId() + "_" + data.getType();
            if (null != map.get(key)) continue;
         if (null != map.get(key))
            continue;
            map.put(key, data);
            //根据最后一车进行汇总统计,开始时间是仓库库存最后一个时间截止到当前
            lastStore = commonService.getLastDepotStore(data.getDepotId());
            if (null == lastStore) {
                log.error("--------出入库定时任务-----没有获取到仓库最后库存信息,取消自动统计,请核对业务逻辑--仓库-{}", data.getDepotId());
            log.error(
                  "--------出入库定时任务-----没有获取到仓库最后库存信息,取消自动统计,请核对业务逻辑--仓库-{}",
                  data.getDepotId());
                continue;
            }
            //只有出入库状态的仓库才进行统计,其他状态表示出入库作业完成,不在执行统计
            if (DepotStatus.STATUS_2.getCode().equals(lastStore.getDepotStatus()) ||
                    DepotStatus.STATUS_4.getCode().equals(lastStore.getDepotStatus())) {
         if (DepotStatus.STATUS_2.getCode().equals(
               lastStore.getDepotStatus())
               || DepotStatus.STATUS_4.getCode().equals(
                     lastStore.getDepotStatus())) {
                param = new InoutParam();
                //param.setStart(lastStore.getCreateDate());
@@ -160,11 +161,13 @@
               // lastStore.setCreateDate(new Date());
                if (InoutConstant.TYPE_IN.equals(data.getType())) {
                    lastStore.setStorageReal(lastStore.getStorageReal() + sumRecordWeight);
               lastStore.setStorageReal(lastStore.getStorageReal()
                     + sumRecordWeight);
                }
                if (InoutConstant.TYPE_OUT.equals(data.getType())) {
                    lastStore.setStorageReal(lastStore.getStorageReal() - sumRecordWeight);
               lastStore.setStorageReal(lastStore.getStorageReal()
                     - sumRecordWeight);
                }
                commonService.addDepotStore(lastStore, true);
@@ -172,7 +175,6 @@
        }
    }
    /**
     * 同步通知单完成量,根据近期出入库记录,如果无近期出入库记录,则表示无出入库作业,取消执行
@@ -188,32 +190,22 @@
            return;
        }
        List<InoutSysConf> inoutSysConfList = inoutCommonService.getCacheInoutSysConf(companyId);
        //不配置说明没有启动出入库
        if (null == inoutSysConfList || inoutSysConfList.isEmpty()) {
            return;
        }
      //TODO 待优化
        //获取所有未完成状态的出库通知单
        List<InoutNoticeOut> noticeOutList = inoutCommonService.getUnComNoticeOut(companyId);
        //获取所有未完成状态的入库通知单
        List<InoutNoticeIn> noticeInList = inoutCommonService.getUnComNoticeIn(companyId);
      String deptId  = noticeInList.get(0).getDeptId();
        for (InoutSysConf inoutSysConf : inoutSysConfList) {
            //  判断入库通知单是否启用
            //更新入库通知单完成量
            inoutCommonService.updateSumNoticeIn(inoutSysConf.getDeptId(), noticeInList);
      inoutCommonService.updateSumNoticeIn(deptId,
            noticeInList);
            //  判断出库通知单是否启用
            //更新出库通知单完成量
            inoutCommonService.updateSumNoticeOut(inoutSysConf.getDeptId(), noticeOutList);
        }
      inoutCommonService.updateSumNoticeOut(deptId,noticeOutList);
    }
}