|
@@ -108,13 +108,14 @@ public class IncomeCollectionServiceImpl
|
|
|
boolean lock = redisLock.lock(key, timestamp);
|
|
|
try {
|
|
|
if (lock) {
|
|
|
- List<CostIncomeGroup> costIncomeGroups = incomeGroupMapper.selectList(
|
|
|
- new LambdaQueryWrapper<CostIncomeGroup>()
|
|
|
- .eq(CostIncomeGroup::getDateYear, year)
|
|
|
- .eq(CostIncomeGroup::getDateMonth, month)
|
|
|
- .eq(CostIncomeGroup::getHospId, hospId)
|
|
|
- .groupBy(CostIncomeGroup::getOpenDepartmentCode, CostIncomeGroup::getStartDepartmentCode, CostIncomeGroup::getProductCode)
|
|
|
- );
|
|
|
+ List<CostIncomeGroupAllAmountBO> costIncomeGroups = incomeGroupMapper.selectListAndMoney(year,month,hospId);
|
|
|
+// List<CostIncomeGroup> costIncomeGroups = incomeGroupMapper.selectList(
|
|
|
+// new LambdaQueryWrapper<CostIncomeGroup>()
|
|
|
+// .eq(CostIncomeGroup::getDateYear, year)
|
|
|
+// .eq(CostIncomeGroup::getDateMonth, month)
|
|
|
+// .eq(CostIncomeGroup::getHospId, hospId)
|
|
|
+// .groupBy(CostIncomeGroup::getOpenDepartmentCode, CostIncomeGroup::getStartDepartmentCode, CostIncomeGroup::getProductCode)
|
|
|
+// );
|
|
|
|
|
|
if (costIncomeGroups.isEmpty()) {
|
|
|
String format = StrUtil.format("{}年{}月数据不存在,请先导入数据", year, month);
|
|
@@ -126,13 +127,22 @@ public class IncomeCollectionServiceImpl
|
|
|
new LambdaQueryWrapper<IncomeCollection>().eq(IncomeCollection::getYear, year).eq(IncomeCollection::getMonth, month).eq(IncomeCollection::getHospId, hospId)
|
|
|
);
|
|
|
// 根据会计科目和成本项目归纳所有数据
|
|
|
- Map<String, List<CostIncomeGroup>> collectMap = costIncomeGroups.stream()
|
|
|
+ Map<String, List<CostIncomeGroupAllAmountBO>> collectMap = costIncomeGroups.stream()
|
|
|
.collect(Collectors.groupingBy(i -> i.getOpenDepartmentCode() + "cost" + i.getStartDepartmentCode() + "cost" + i.getProductCode()));
|
|
|
|
|
|
// 遍历map 组装成List保存
|
|
|
List<IncomeCollection> list = new LinkedList<>();
|
|
|
- Set<Map.Entry<String, List<CostIncomeGroup>>> entries = collectMap.entrySet();
|
|
|
+ Set<Map.Entry<String, List<CostIncomeGroupAllAmountBO>>> entries = collectMap.entrySet();
|
|
|
entries.stream().map(Map.Entry::getValue).flatMap(Collection::stream).forEach(costIncomeGroup -> {
|
|
|
+ String allMoney = costIncomeGroup.getAllMoney();
|
|
|
+ if (StrUtil.isNotBlank(allMoney) && allMoney.contains(StrUtil.COMMA)) {
|
|
|
+ // 存在,在进行求和
|
|
|
+ BigDecimal sum;
|
|
|
+ List<BigDecimal> bigDecimals = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(BigDecimal::new).collect(Collectors.toList());
|
|
|
+ sum = bigDecimals.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ costIncomeGroup.setAmount(sum);
|
|
|
+ }
|
|
|
+ //TODO 统计总金额
|
|
|
IncomeCollection incomeCollection = new IncomeCollection();
|
|
|
incomeCollection.setYear(year);
|
|
|
incomeCollection.setMonth(month);
|
|
@@ -140,7 +150,7 @@ public class IncomeCollectionServiceImpl
|
|
|
incomeCollection.setAccountingName(costIncomeGroup.getAccountName());
|
|
|
incomeCollection.setProductName(costIncomeGroup.getProductName());
|
|
|
incomeCollection.setProductCode(costIncomeGroup.getProductCode());
|
|
|
- incomeCollection.setAmount(costIncomeGroup.getAmount());
|
|
|
+// incomeCollection.setAmount(costIncomeGroup.getAmount());
|
|
|
incomeCollection.setHospId(hospId);
|
|
|
// todo 来源id暂时不确定
|
|
|
incomeCollection.setFileId(costIncomeGroup.getFileId());
|
|
@@ -160,25 +170,35 @@ public class IncomeCollectionServiceImpl
|
|
|
// responsibilityCode = "-";
|
|
|
// afterIncomegroup.setResponsibilityName("-");
|
|
|
// }
|
|
|
- // 开单中心的数据
|
|
|
- incomeCollection.setAmount(afterIncomegroup.getOpenDepartmentDecimal());
|
|
|
- incomeCollection.setDepartmentCode(afterIncomegroup.getOpenDepartmentCode());
|
|
|
- incomeCollection.setDepartmentName(afterIncomegroup.getOpenDepartmentName());
|
|
|
- incomeCollection.setResponsibilityCode(afterIncomegroup.getOpenResponsibilityCode());
|
|
|
- incomeCollection.setResponsibilityName(afterIncomegroup.getOpenResponsibilityName());
|
|
|
-
|
|
|
- list.add(incomeCollection);
|
|
|
- // 执行科室数据
|
|
|
-
|
|
|
- IncomeCollection startCollect = BeanUtil.convertObj(incomeCollection, IncomeCollection.class);
|
|
|
- startCollect.setAmount(afterIncomegroup.getStartDepartmentDecimal());
|
|
|
- startCollect.setDepartmentCode(afterIncomegroup.getStartDepartmentCode());
|
|
|
- startCollect.setDepartmentName(afterIncomegroup.getStartDepartmentName());
|
|
|
- startCollect.setResponsibilityCode(afterIncomegroup.getStartResponsibilityCode());
|
|
|
- startCollect.setResponsibilityName(afterIncomegroup.getStartResponsibilityName());
|
|
|
- log.info("start:{}", startCollect);
|
|
|
- log.info("open:{}", incomeCollection);
|
|
|
- list.add(startCollect);
|
|
|
+ String responsibilityCode = afterIncomegroup.getResponsibilityCode();
|
|
|
+ if (StrUtil.isNotBlank(responsibilityCode)) {
|
|
|
+ incomeCollection.setDepartmentName(afterIncomegroup.getOpenDepartmentName() + "|" + afterIncomegroup.getStartDepartmentName());
|
|
|
+ incomeCollection.setDepartmentCode(afterIncomegroup.getOpenDepartmentCode() + "|" + afterIncomegroup.getStartDepartmentCode());
|
|
|
+ incomeCollection.setResponsibilityCode(responsibilityCode);
|
|
|
+ incomeCollection.setResponsibilityName(afterIncomegroup.getResponsibilityName());
|
|
|
+ incomeCollection.setAmount(afterIncomegroup.getOtherResponsibilityDecimal());
|
|
|
+ list.add(incomeCollection);
|
|
|
+ } else {
|
|
|
+ // 开单中心的数据
|
|
|
+ incomeCollection.setAmount(afterIncomegroup.getOpenDepartmentDecimal());
|
|
|
+ incomeCollection.setDepartmentCode(afterIncomegroup.getOpenDepartmentCode());
|
|
|
+ incomeCollection.setDepartmentName(afterIncomegroup.getOpenDepartmentName());
|
|
|
+ incomeCollection.setResponsibilityCode(afterIncomegroup.getOpenResponsibilityCode());
|
|
|
+ incomeCollection.setResponsibilityName(afterIncomegroup.getOpenResponsibilityName());
|
|
|
+
|
|
|
+ list.add(incomeCollection);
|
|
|
+ // 执行科室数据
|
|
|
+
|
|
|
+ IncomeCollection startCollect = BeanUtil.convertObj(incomeCollection, IncomeCollection.class);
|
|
|
+ startCollect.setAmount(afterIncomegroup.getStartDepartmentDecimal());
|
|
|
+ startCollect.setDepartmentCode(afterIncomegroup.getStartDepartmentCode());
|
|
|
+ startCollect.setDepartmentName(afterIncomegroup.getStartDepartmentName());
|
|
|
+ startCollect.setResponsibilityCode(afterIncomegroup.getStartResponsibilityCode());
|
|
|
+ startCollect.setResponsibilityName(afterIncomegroup.getStartResponsibilityName());
|
|
|
+ log.info("start:{}", startCollect);
|
|
|
+ log.info("open:{}", incomeCollection);
|
|
|
+ list.add(startCollect);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
|