|
|
@@ -11,9 +11,11 @@ import cn.com.taiji.core.entity.dict.log.OperateType; |
|
|
|
import cn.com.taiji.core.entity.invw.InvwStocktakingInfo; |
|
|
|
import cn.com.taiji.core.entity.invw.InvwStocktakingResult; |
|
|
|
import cn.com.taiji.core.entity.invw.InvwWarehouse; |
|
|
|
import cn.com.taiji.core.entity.user.AccountInfo; |
|
|
|
import cn.com.taiji.core.manager.tools.easyExcel.EasyExcelUtil; |
|
|
|
import cn.com.taiji.core.manager.tools.minio.MinioUtil; |
|
|
|
import cn.com.taiji.core.repo.jpa.invw.*; |
|
|
|
import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo; |
|
|
|
import cn.com.taiji.core.repo.request.invw.InvwStocktakingInfoPageRequest; |
|
|
|
import cn.com.taiji.invw.dto.stocktaking.*; |
|
|
|
import cn.com.taiji.invw.manager.AbstractInvwManager; |
|
|
@@ -61,6 +63,8 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
private InvwTransferApplyRepo transferApplyRepo; |
|
|
|
@Autowired |
|
|
|
private InvwRebackApplyRepo rebackApplyRepo; |
|
|
|
@Autowired |
|
|
|
private AccountInfoRepo accountInfoRepo; |
|
|
|
|
|
|
|
private static final DateTimeFormatter DF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
@@ -173,7 +177,7 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
List<InvwStocktakingInfoModel> stockInfoModels = insertStocktakingInfo(stockModels, startTime, req); |
|
|
|
// 执行盘库 |
|
|
|
doStocktaking(stockInfoModels, storeCodes); |
|
|
|
persistOperateLog(OperateType.STOCKTAKING_INFO, null, req.getOrderSource(), findOpenIdByToken(req.getAccessToken()), "库存盘存"); |
|
|
|
persistOperateLog(OperateType.STOCKTAKING_INFO, "-1", req.getOrderSource(), findOpenIdByToken(req.getAccessToken()), "库存盘存"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@@ -196,17 +200,28 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
List<InvwStocktakingResult> results = stocktakingResultRepo.findByMainId(req.getId()); |
|
|
|
List<InvwStocktakingInfoDetailModel> details = new ArrayList<>(); |
|
|
|
|
|
|
|
// 公共属性 |
|
|
|
response.setStartTime(stocktakingInfo.getStartTime()); |
|
|
|
response.setEndTime(stocktakingInfo.getEndTime()); |
|
|
|
response.setType(stocktakingInfo.getType()); |
|
|
|
response.setOpenId(stocktakingInfo.getOpenId()); |
|
|
|
if(hasText(stocktakingInfo.getOpenId())) { |
|
|
|
AccountInfo accountInfo = accountInfoRepo.findByOpenId(stocktakingInfo.getOpenId()); |
|
|
|
if(accountInfo != null){ |
|
|
|
response.setOpenId(accountInfo.getUserName()); |
|
|
|
}else { |
|
|
|
response.setOpenId("未知"); |
|
|
|
} |
|
|
|
}else { |
|
|
|
response.setOpenId("系统自动运行"); |
|
|
|
} |
|
|
|
response.setStoreCode(warehouse.getCode()); |
|
|
|
response.setName(warehouse.getName()); |
|
|
|
|
|
|
|
// 列表 |
|
|
|
for (InvwStocktakingResult result : results) { |
|
|
|
InvwStocktakingInfoDetailModel model = new InvwStocktakingInfoDetailModel(); |
|
|
|
BeanUtils.copyProperties(result, model); |
|
|
|
|
|
|
|
// 公共属性 |
|
|
|
model.setStartTime(stocktakingInfo.getStartTime()); |
|
|
|
model.setEndTime(stocktakingInfo.getEndTime()); |
|
|
|
model.setType(stocktakingInfo.getType()); |
|
|
|
model.setOpenId(stocktakingInfo.getOpenId()); |
|
|
|
model.setName(warehouse.getName()); |
|
|
|
|
|
|
|
details.add(model); |
|
|
|
} |
|
|
|
response.setDetails(details); |
|
|
@@ -227,6 +242,7 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
// 插入盘存信息 |
|
|
|
public List<InvwStocktakingInfoModel> insertStocktakingInfo(List<InvwStocktakingInfoStockModel> stockModels, LocalDateTime startTime, InvwStocktakingInfoStockRequestDTO req) throws ManagerException { |
|
|
|
List<InvwStocktakingInfo> stocktakingInfos = new ArrayList<>(); |
|
|
|
String openId = findOpenIdByToken(req.getAccessToken()); |
|
|
|
for (InvwStocktakingInfoStockModel stockModel : stockModels) { |
|
|
|
stockModel.valid(); |
|
|
|
InvwStocktakingInfo stocktakingInfo = new InvwStocktakingInfo(); |
|
|
@@ -235,7 +251,7 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
stocktakingInfo.setStartTime(startTime); |
|
|
|
stocktakingInfo.setCreateTime(startTime); |
|
|
|
stocktakingInfo.setType(1); |
|
|
|
stocktakingInfo.setOpenId(findOpenIdByToken(req.getAccessToken())); |
|
|
|
stocktakingInfo.setOpenId(openId); |
|
|
|
// stocktakingInfo.setOpenId("1"); |
|
|
|
stocktakingInfos.add(stocktakingInfo); |
|
|
|
} |
|
|
@@ -260,8 +276,8 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("在storeCodes {}盘存过程中发生错误", storeCodes, e); |
|
|
|
} |
|
|
|
// }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// }); |
|
|
|
logger.info("盘存结束"); |
|
|
|
} |
|
|
|
|
|
|
@@ -282,7 +298,7 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
List<InvwStocktakingResultModel> incomeStat = getInStat(storeCode, lastDoneTime, info.getStartTime(), mainId); |
|
|
|
//出库 (调拨出库、回收出库) |
|
|
|
List<InvwStocktakingResultModel> outStat = getOutStat(storeCode, lastDoneTime, info.getStartTime(), mainId); |
|
|
|
//实际用掉的 |
|
|
|
//现在在库的 |
|
|
|
List<InvwStocktakingResultModel> realityStat = getRealityStat(storeCode, lastDoneTime, info.getStartTime(), mainId); |
|
|
|
//结存 |
|
|
|
List<InvwStocktakingResultModel> balanceStat = mergeResultList(bopStat, incomeStat, outStat, realityStat); |
|
|
@@ -389,13 +405,13 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
inMap.setVersion(model.getVersion()); |
|
|
|
|
|
|
|
//期初 |
|
|
|
if (NumberUtil.add(inMap.getInitCount(), model.getInitCount()) != null) { |
|
|
|
inMap.setInitCount(NumberUtil.add(inMap.getInitCount(), model.getInitCount()).intValue()); |
|
|
|
} |
|
|
|
//入库 |
|
|
|
// if (NumberUtil.add(inMap.getEnterCount(), model.getEnterCount()) != null) { |
|
|
|
// inMap.setEnterCount(NumberUtil.add(inMap.getEnterCount(), model.getEnterCount()).intValue()); |
|
|
|
// if (NumberUtil.add(inMap.getInitCount(), model.getInitCount()) != null) { |
|
|
|
// inMap.setInitCount(NumberUtil.add(inMap.getInitCount(), model.getInitCount()).intValue()); |
|
|
|
// } |
|
|
|
//入库 |
|
|
|
if (NumberUtil.add(inMap.getEnterCount(), model.getEnterCount()) != null) { |
|
|
|
inMap.setEnterCount(NumberUtil.add(inMap.getEnterCount(), model.getEnterCount()).intValue()); |
|
|
|
} |
|
|
|
//出库 |
|
|
|
// if (NumberUtil.add(inMap.getTransferCount(), model.getTransferCount()) != null) { |
|
|
|
// inMap.setTransferCount(NumberUtil.add(inMap.getTransferCount(), model.getTransferCount()).intValue()); |
|
|
@@ -491,7 +507,7 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
|
|
|
|
private List<InvwStocktakingResultModel> getRealityStat(String storeCode, LocalDateTime lastDoneTime, LocalDateTime startTime, String mainId) { |
|
|
|
List<InvwStocktakingResultModel> result = new ArrayList<>(); |
|
|
|
//查询卡签实际非在库库存 |
|
|
|
//查询卡签实际在库库存 |
|
|
|
List<Object[]> cardDetails = null; |
|
|
|
List<Object[]> obuDetails = null; |
|
|
|
// if (lastDoneTime == null) { |
|
|
@@ -620,6 +636,9 @@ public class InvwStocktakingInfoManagerImpl extends AbstractInvwManager implemen |
|
|
|
//求和该仓库 |
|
|
|
vo.setInitCount(results.stream().mapToInt(InvwStocktakingResult::getInitCount).sum()); |
|
|
|
vo.setBalanceCount(results.stream().mapToInt(InvwStocktakingResult::getBalanceCount).sum()); |
|
|
|
}else { |
|
|
|
vo.setInitCount(0); |
|
|
|
vo.setBalanceCount(0); |
|
|
|
} |
|
|
|
vo.setStartTime(stocktakingInfo.getStartTime()); |
|
|
|
vo.setEndTime(stocktakingInfo.getEndTime()); |