|
@@ -20,6 +20,7 @@ import com.imed.costaccount.model.dto.ShareParamValueSaveDTO;
|
|
|
import com.imed.costaccount.model.dto.ShareParamValueVO;
|
|
|
import com.imed.costaccount.model.vo.IncomeErrorMessage;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
+import io.lettuce.core.Limit;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -32,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.hutool.core.date.DatePattern.PURE_DATE_PATTERN;
|
|
|
+import static com.imed.costaccount.common.constants.Constant.LIMIT;
|
|
|
|
|
|
|
|
|
@Service("shareParamValueService")
|
|
@@ -431,26 +433,51 @@ public class ShareParamValueServiceImpl extends ServiceImpl<ShareParamValueMappe
|
|
|
new LambdaQueryWrapper<ShareParamValue>()
|
|
|
.eq(ShareParamValue::getDateYear, year).eq(ShareParamValue::getDateMonth, month).eq(ShareParamValue::getHospId, hospId)
|
|
|
);
|
|
|
- if (list.isEmpty()){
|
|
|
- throw new CostException(500,parse+"数据未录入");
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ throw new CostException(500, parse + "数据未录入");
|
|
|
}
|
|
|
- // 得到这些责任中心代码
|
|
|
- List<String> responsibilityCodes = list.stream().map(ShareParamValue::getResponsibilityCode).distinct().collect(Collectors.toList());
|
|
|
+ // 得到这些会计科目代码
|
|
|
+ List<String> accountCodes = new ArrayList<>();
|
|
|
+ list.forEach(i -> {
|
|
|
+ String shareParamCode = i.getShareParamCode();
|
|
|
+ CostShareParam one = costShareParamService.getOne(
|
|
|
+ new LambdaQueryWrapper<CostShareParam>()
|
|
|
+ .eq(CostShareParam::getHospId, hospId)
|
|
|
+ .eq(CostShareParam::getShareParamCode, shareParamCode)
|
|
|
+ .last(LIMIT)
|
|
|
+ );
|
|
|
+ if (Objects.isNull(one)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String accountingCodes = one.getAccountingCodes();
|
|
|
+ if (StrUtil.isBlank(accountingCodes)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String[] split = StrUtil.split(accountingCodes, StrUtil.COMMA);
|
|
|
+ ArrayList<String> accountCodeList = CollUtil.newArrayList(split);
|
|
|
+ accountCodes.addAll(accountCodeList);
|
|
|
+ List<String> calcList = new ArrayList<>();
|
|
|
+ accountCodeList.forEach(j -> {
|
|
|
+ calcList.add(i.getResponsibilityCode() + "cost" + j);
|
|
|
+ });
|
|
|
+ i.setCalcList(calcList);
|
|
|
+ });
|
|
|
List<IncomeCollection> incomeCollections = incomeCollectionService.list(
|
|
|
new LambdaQueryWrapper<IncomeCollection>()
|
|
|
.eq(IncomeCollection::getYear, year)
|
|
|
.eq(IncomeCollection::getMonth, month)
|
|
|
.eq(IncomeCollection::getHospId, hospId)
|
|
|
- .in(IncomeCollection::getResponsibilityCode, responsibilityCodes)
|
|
|
+ .in(IncomeCollection::getAccountingCode, accountCodes)
|
|
|
);
|
|
|
if (incomeCollections.isEmpty()) {
|
|
|
throw new CostException("本月未归集数据,请先归集数据");
|
|
|
}
|
|
|
|
|
|
- Map<String, List<IncomeCollection>> collectMap = incomeCollections.stream().collect(Collectors.groupingBy(IncomeCollection::getResponsibilityCode));
|
|
|
+ Map<String, List<IncomeCollection>> collectMap = incomeCollections.stream()
|
|
|
+ .collect(Collectors.groupingBy(i->i.getResponsibilityCode() + "cost" + i.getAccountingCode()));
|
|
|
Set<String> strings = collectMap.keySet();
|
|
|
- Map<String,BigDecimal> map = new ConcurrentHashMap<>();
|
|
|
- for (String str : strings) {
|
|
|
+ Map<String, BigDecimal> map = new ConcurrentHashMap<>();
|
|
|
+ strings.forEach(str -> {
|
|
|
List<IncomeCollection> collections = collectMap.get(str);
|
|
|
if (CollUtil.isNotEmpty(collections)) {
|
|
|
BigDecimal reduce = incomeCollections.stream().map(IncomeCollection::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
@@ -458,13 +485,13 @@ public class ShareParamValueServiceImpl extends ServiceImpl<ShareParamValueMappe
|
|
|
incomeCollection.setAmount(reduce);
|
|
|
map.put(str, reduce);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
list.forEach(i -> {
|
|
|
- // TODO: 2021/8/19
|
|
|
- BigDecimal bigDecimal = map.get(i.getResponsibilityCode());
|
|
|
- if (Objects.nonNull(bigDecimal)) {
|
|
|
- i.setValueNum(bigDecimal);
|
|
|
- }
|
|
|
+ map.keySet().forEach(j -> {
|
|
|
+ if (CollUtil.isNotEmpty(i.getCalcList()) && i.getCalcList().contains(j)) {
|
|
|
+ i.setValueNum(map.get(j));
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
this.updateBatchById(list);
|
|
|
}
|