提交 0c1333ac authored 作者: zhoushaopan's avatar zhoushaopan

fix(决算模块): 修改了数量问题

修改了数量问题
上级 f009b72e
package com.tykj.dev.device.finalcheck.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.file.service.FilesUtil;
import com.tykj.dev.device.finalcheck.entity.domain.FinalDetail;
......@@ -54,8 +56,8 @@ public class FinalCheckServiceImpl implements FinalCheckService {
@Autowired
private FinalDetailDao detailDao;
// @Autowired
// private DeviceLibraryDao deviceDao;
@Autowired
private DeviceLibraryDao deviceDao;
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
......@@ -100,13 +102,31 @@ public class FinalCheckServiceImpl implements FinalCheckService {
// List<DeviceLibrary> devices = deviceDao.findAllByUnitBetweenTime(unitName, localDateToDate(startTime), localDateToDate(endTime));
// List<DeviceLibrary> devices = deviceDao.findAll();
List<DeviceLibrary> devices = deviceLibraryCacheService.getAllDeviceLibraryList();
//过滤出已退役,已报废,已销毁
List<Integer> statusList = new ArrayList<>(Arrays.asList(DeviceLifeStatus.DESTROYED.id,
DeviceLifeStatus.RETIRE.id,DeviceLifeStatus.SCRAP_I.id));
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
if (startTime!=null){
predicateBuilder.gt("updateTime",localDateToDate(startTime));
}
if (endTime !=null){
predicateBuilder.lt("updateTime",localDateToDateEnd(endTime));
}
//非在库装备
List<DeviceLibrary> outDevices = deviceDao.findAll(predicateBuilder.build()).stream()
.filter(deviceLibrary -> statusList.contains(deviceLibrary.getLifeStatus())).collect(Collectors.toList());
//在库装备
devices = devices.stream().filter(deviceLibrary -> !statusList.contains(deviceLibrary.getLifeStatus())).collect(Collectors.toList());
// PredicateBuilder<DeviceLibrary> builder = Specifications.and();
// builder.eq("ownUnit",unitName);
// List<DeviceLibrary> devices = deviceDao.findAll(builder.build());
// 纵向-查 横向-0 委托-0 合计-合计 代管0 收到 发出 报废0
Map<String, List<DeviceLibrary>> map = devices.stream()
.collect(groupingBy(deviceLibrary -> deviceLibrary.getModel()+"Ǵ"+deviceLibrary.getName()));
Map<String, List<DeviceLibrary>> outMap = outDevices.stream()
.collect(groupingBy(deviceLibrary -> deviceLibrary.getModel()+"Ǵ"+deviceLibrary.getName()));
//报废
// List<ScrapBill> scrapBills = scrapBillDao.findAllByUnitBetweenTime(unitName, localDateToDate(startTime), localDateToDate(endTime));
......@@ -124,16 +144,16 @@ public class FinalCheckServiceImpl implements FinalCheckService {
List<FinalDetail> detailList = new ArrayList<>();
//入库
Map<String, DeviceStatistics> storageMap = dataService.getStorageStatistics(localDateToDate(startTime), localDateToDate(endTime))
Map<String, DeviceStatistics> storageMap = dataService.getStorageStatistics(localDateToDate(startTime), localDateToDateEnd(endTime))
.stream()
.collect(toMap(deviceStatistics -> deviceStatistics.getModel()+"Ǵ"+deviceStatistics.getName(), Function.identity()));
//送修
Map<String, DeviceStatistics> repairMap = dataService.getRepairStatistics(localDateToDate(startTime), localDateToDate(endTime))
Map<String, DeviceStatistics> repairMap = dataService.getRepairStatistics(localDateToDate(startTime), localDateToDateEnd(endTime))
.stream()
.collect(toMap(deviceStatistics -> deviceStatistics.getModel()+"Ǵ"+deviceStatistics.getName(), Function.identity()));
//维修退回
Map<String, DeviceStatistics> repairBackMap = dataService.getRepairBackStatistics(localDateToDate(startTime), localDateToDate(endTime))
Map<String, DeviceStatistics> repairBackMap = dataService.getRepairBackStatistics(localDateToDate(startTime), localDateToDateEnd(endTime))
.stream()
.collect(toMap(deviceStatistics -> deviceStatistics.getModel()+"Ǵ"+deviceStatistics.getName(), Function.identity()));
//销毁
......@@ -154,17 +174,11 @@ public class FinalCheckServiceImpl implements FinalCheckService {
.stream()
.collect(toMap(deviceStatistics -> deviceStatistics.getModel() + "G" + deviceStatistics.getName(), Function.identity()));
for (Map.Entry<String, List<DeviceLibrary>> entry : map.entrySet()) {
List<DeviceLibrary> vList = new ArrayList<>();
List<DeviceLibrary> hList = new ArrayList<>();
List<DeviceLibrary> otherList = new ArrayList<>();
List<DeviceLibrary> v = new ArrayList<>();
String key = entry.getKey();
List<DeviceLibrary> v = entry.getValue();
//纵向
List<DeviceLibrary> vList = v.stream().filter(deviceLibrary -> deviceLibrary.getMatchingRange() == 1 ).collect(Collectors.toList());
//横向
List<DeviceLibrary> hList = v.stream().filter(deviceLibrary -> deviceLibrary.getMatchingRange() == 2 || deviceLibrary.getMatchingRange() == 3).collect(Collectors.toList());
//其他
List<DeviceLibrary> otherList = v.stream().filter(deviceLibrary -> deviceLibrary.getMatchingRange() == 4).collect(Collectors.toList());
//收到的 入库+维修退回(中办送回)
//发出的 送修
Integer storage = storageMap.get(key) == null ? 0 : storageMap.get(key).getNum();
Integer repairBack = repairBackMap.get(key) == null ? 0 : repairBackMap.get(key).getNum();
Integer sending = repairMap.get(key) == null ? 0 : repairMap.get(key).getNum();
......@@ -172,12 +186,39 @@ public class FinalCheckServiceImpl implements FinalCheckService {
Integer scrap = scrapMap.get(key) == null ? 0 : scrapMap.get(key).getNum();
Integer destroy = destroyMap.get(key) == null ? 0 : destroyMap.get(key).getNum();
Integer loss = lossMap.get(key) == null ? 0 : destroyMap.get(key).getNum();
v = entry.getValue();
if (!v.isEmpty()){
//纵向
vList = v.stream().filter(deviceLibrary -> deviceLibrary.getMatchingRange() == 1 ).collect(Collectors.toList());
//横向
hList = v.stream().filter(deviceLibrary -> deviceLibrary.getMatchingRange() == 2 || deviceLibrary.getMatchingRange() == 3).collect(Collectors.toList());
//其他
otherList = v.stream().filter(deviceLibrary -> deviceLibrary.getMatchingRange() == 4).collect(Collectors.toList());
}
//收到的 入库+维修退回(中办送回)
//发出的 送修
// detailList.add(new FinalDetail(v.get(0).getModel(), v.get(0).getName(), v.size(), 0, 0, 0, v.size(),
// 0, received, sending, 0, report.getId()));
detailList.add(new FinalDetail(v.get(0).getModel(), v.get(0).getName(), vList.size(), hList.size(), 0, otherList.size(), v.size(),
0, storage+repairBack, sending, scrap,report.getId(),loss ,"",destroy));
detailList.add(new FinalDetail(v.get(0).getModel(), v.get(0).getName(), vList.size(), hList.size(), 0, otherList.size(), v.size(),
0, storage+repairBack, sending, scrap,report.getId(),loss ,"",destroy));
}
for (Map.Entry<String, List<DeviceLibrary>> entry : outMap.entrySet()) {
String key = entry.getKey();
if (!map.containsKey(key)){
List<DeviceLibrary> v = new ArrayList<>();
Integer storage = storageMap.get(key) == null ? 0 : storageMap.get(key).getNum();
Integer repairBack = repairBackMap.get(key) == null ? 0 : repairBackMap.get(key).getNum();
Integer sending = repairMap.get(key) == null ? 0 : repairMap.get(key).getNum();
Integer retire = retireMap.get(key) == null ? 0 : retireMap.get(key).getNum();
Integer scrap = scrapMap.get(key) == null ? 0 : scrapMap.get(key).getNum();
Integer destroy = destroyMap.get(key) == null ? 0 : destroyMap.get(key).getNum();
Integer loss = lossMap.get(key) == null ? 0 : destroyMap.get(key).getNum();
v = entry.getValue();
detailList.add(new FinalDetail(v.get(0).getModel(), v.get(0).getName(), 0, 0, 0, 0, 0,
0, storage+repairBack, sending, scrap,report.getId(),loss ,"",destroy));
}
}
detailList = detailDao.saveAll(detailList);
return report.toVo(detailList);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论