优化部分处理逻辑

master
wujingtao 2 years ago
parent db637cf894
commit cf1b12eee6

@ -712,8 +712,8 @@ public class QueryReportServiceImpl implements QueryReportService {
Map<String, Object> map = new HashMap<>(4); Map<String, Object> map = new HashMap<>(4);
if (callMap.containsKey(time)) { if (callMap.containsKey(time)) {
ReportDeduct reportDeduct = callMap.get(time); ReportDeduct reportDeduct = callMap.get(time);
map.put("balance", reportDeduct.getBalance()); map.put("balance", reportDeduct.getBalance() == null ? 0.0 : reportDeduct.getBalance() == null);
map.put("deductAmount", reportDeduct.getDeductAmount()); map.put("deductAmount", reportDeduct.getDeductAmount() == null ? 0.0 : reportDeduct.getDeductAmount());
} else { } else {
map.put("balance", 0); map.put("balance", 0);
map.put("deductAmount", 0); map.put("deductAmount", 0);

@ -59,10 +59,10 @@ public class ReportDeductsSync {
List<CallDeduct> callDeducts; List<CallDeduct> callDeducts;
if (companyId != null) { if (companyId != null) {
callDeducts = callDeductRepository.queryByCompanyIdAndTime(companyId, beginOfDay, endOfDay); callDeducts = callDeductRepository.queryByCompanyIdAndTime(companyId, beginOfDay, endOfDay);
Double sum = callDeducts.stream().mapToDouble(CallDeduct::getDeductAmount).sum(); double sum = callDeducts.stream().mapToDouble(CallDeduct::getDeductAmount).sum();
ReportDeduct reportDeduct = new ReportDeduct(); ReportDeduct reportDeduct = new ReportDeduct();
reportDeduct.setDeductAmount(sum); reportDeduct.setDeductAmount(sum);
reportDeduct.setBalance(map.get(companyId)); reportDeduct.setBalance(map.get(companyId) == null ? 0.0 : map.get(companyId));
reportDeduct.setCreateTime(new Date()); reportDeduct.setCreateTime(new Date());
reportDeduct.setCompanyId(companyId); reportDeduct.setCompanyId(companyId);
list.add(reportDeduct); list.add(reportDeduct);
@ -71,7 +71,7 @@ public class ReportDeductsSync {
Map<Long, List<CallDeduct>> collect = callDeducts.stream().collect(Collectors.groupingBy(CallDeduct::getCompanyId, Collectors.toList())); Map<Long, List<CallDeduct>> collect = callDeducts.stream().collect(Collectors.groupingBy(CallDeduct::getCompanyId, Collectors.toList()));
for (Long key : map.keySet()) { for (Long key : map.keySet()) {
ReportDeduct reportDeduct = new ReportDeduct(); ReportDeduct reportDeduct = new ReportDeduct();
reportDeduct.setBalance(map.get(key)); reportDeduct.setBalance(map.get(key) == null ? 0.0 : map.get(key));
reportDeduct.setCreateTime(new Date()); reportDeduct.setCreateTime(new Date());
reportDeduct.setCompanyId(key); reportDeduct.setCompanyId(key);
List<CallDeduct> callDeducts1 = collect.get(key); List<CallDeduct> callDeducts1 = collect.get(key);

@ -431,14 +431,13 @@ public class ReportTokerServiceImpl implements ReportTokerService {
map.put("usrNumRate", reportTokerCall.getUsrNumRate()); map.put("usrNumRate", reportTokerCall.getUsrNumRate());
map.put("turnOnNum", reportTokerCall.getTurnOnNum()); map.put("turnOnNum", reportTokerCall.getTurnOnNum());
map.put("turnOnRate", reportTokerCall.getTurnOnRate()); map.put("turnOnRate", reportTokerCall.getTurnOnRate());
map.put("time", time);
} else { } else {
map.put("usrNum", 0); map.put("usrNum", 0);
map.put("usrNumRate", 0.0); map.put("usrNumRate", 0.0);
map.put("turnOnNum", 0); map.put("turnOnNum", 0);
map.put("turnOnRate", 0.0); map.put("turnOnRate", 0.0);
map.put("time", time);
} }
map.put("time", time);
maps.add(map); maps.add(map);
} }
return CommonResponse.createBySuccess(maps); return CommonResponse.createBySuccess(maps);

Loading…
Cancel
Save