package com.ld.igds.timer;
|
|
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;
|
import org.apache.commons.lang3.time.DateUtils;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
/**
|
* @Desc: 账面库存 - 每月底自动统计每个仓库的账面库存
|
* @author: czt
|
* @update-time: 2023/10/30
|
*/
|
@Slf4j
|
@Component(DepotBookStoreScheduled.BEAN_ID)
|
public class DepotBookStoreScheduled {
|
|
public static final String BEAN_ID = "inout.depotBookStoreScheduled";
|
|
@Resource
|
private CoreCommonService commonService;
|
|
/**
|
* 每月最后一天22点25分执行
|
*/
|
@Scheduled(cron = "0 25 22 28-31 * ?")
|
public void scheduled() {
|
|
final Calendar c = Calendar.getInstance();
|
//如果是最后一天 则执行定时任务
|
if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)) {
|
|
List<DefaultCompany> listCompany = commonService.getCompanyList();
|
if (null == listCompany){
|
return;
|
}
|
|
for (DefaultCompany company : listCompany) {
|
//TODO 统计每个仓库账面库存
|
|
}
|
}
|
}
|
|
/**
|
* 统计账面库存
|
* @param companyId
|
* @param listLossOver
|
* @param param
|
*/
|
private void sumDepotBookStore(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);
|
// }
|
}
|
|
}
|