|
@@ -12,12 +12,8 @@ import cn.hutool.poi.excel.ExcelWriter;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
-import com.kcim.common.constants.NumberConstant;
|
|
|
|
|
-import com.kcim.common.constants.ParameterConstant;
|
|
|
|
|
-import com.kcim.common.constants.SQLParameter;
|
|
|
|
|
-import com.kcim.common.constants.SplitConstant;
|
|
|
|
|
|
|
+import com.kcim.common.constants.*;
|
|
|
import com.kcim.common.enums.CustomSqlTypeEnum;
|
|
import com.kcim.common.enums.CustomSqlTypeEnum;
|
|
|
import com.kcim.common.enums.DateStyleEnum;
|
|
import com.kcim.common.enums.DateStyleEnum;
|
|
|
import com.kcim.common.enums.ErrorCodeEnum;
|
|
import com.kcim.common.enums.ErrorCodeEnum;
|
|
@@ -30,10 +26,7 @@ import com.kcim.common.util.excel.entity.ColEntity;
|
|
|
import com.kcim.common.util.excel.entity.TitleEntity;
|
|
import com.kcim.common.util.excel.entity.TitleEntity;
|
|
|
import com.kcim.dao.mapper.CostDepartmentProfitMapper;
|
|
import com.kcim.dao.mapper.CostDepartmentProfitMapper;
|
|
|
import com.kcim.dao.model.*;
|
|
import com.kcim.dao.model.*;
|
|
|
-import com.kcim.dao.repository.ComputeLastProfitDateRepository;
|
|
|
|
|
-import com.kcim.dao.repository.CostDepartmentProfitAccountRepository;
|
|
|
|
|
-import com.kcim.dao.repository.CostDepartmentProfitRepository;
|
|
|
|
|
-import com.kcim.dao.repository.ResponsibilityRepository;
|
|
|
|
|
|
|
+import com.kcim.dao.repository.*;
|
|
|
import com.kcim.service.*;
|
|
import com.kcim.service.*;
|
|
|
import com.kcim.vo.*;
|
|
import com.kcim.vo.*;
|
|
|
import com.kcim.web.reponse.BatchCostProfitResponse;
|
|
import com.kcim.web.reponse.BatchCostProfitResponse;
|
|
@@ -56,6 +49,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
@@ -79,7 +73,7 @@ import static com.kcim.common.constants.ParameterConstant.MEDICAL_TECHNIQUES_SHA
|
|
|
@Service("costDepartmentProfitService")
|
|
@Service("costDepartmentProfitService")
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
-public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentProfitMapper, CostDepartmentProfit> implements CostDepartmentProfitService {
|
|
|
|
|
|
|
+public class CostDepartmentProfitServiceImpl extends BaseBatchServiceImpl<CostDepartmentProfitMapper, CostDepartmentProfit> implements CostDepartmentProfitService {
|
|
|
|
|
|
|
|
// @Value("${file.filelocal}")
|
|
// @Value("${file.filelocal}")
|
|
|
// private String hospProfitReportUrl;
|
|
// private String hospProfitReportUrl;
|
|
@@ -122,6 +116,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
ResponsibilityRepository responsibilityRepository;
|
|
ResponsibilityRepository responsibilityRepository;
|
|
|
|
|
|
|
|
CostDepartmentProfitAccountRepository costDepartmentProfitAccountRepository;
|
|
CostDepartmentProfitAccountRepository costDepartmentProfitAccountRepository;
|
|
|
|
|
+ AccountingRepository accountingRepository;
|
|
|
|
|
|
|
|
private final SqlService sqlService;
|
|
private final SqlService sqlService;
|
|
|
private final String AMOUNT = "金额";
|
|
private final String AMOUNT = "金额";
|
|
@@ -1143,6 +1138,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
// DateTime parse = DateUtil.parse(computeDate);
|
|
// DateTime parse = DateUtil.parse(computeDate);
|
|
|
// int year = DateUtil.year(parse);
|
|
// int year = DateUtil.year(parse);
|
|
|
// int month = DateUtil.month(parse) + 1;
|
|
// int month = DateUtil.month(parse) + 1;
|
|
|
|
|
+ Long userId = UserContext.getCurrentUser().getId();
|
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
// 先查询指定条件的报表数据 查询损益表的数据
|
|
// 先查询指定条件的报表数据 查询损益表的数据
|
|
@@ -1226,7 +1222,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
|
|
this.saveBatch(costDepartmentProfits);
|
|
this.saveBatch(costDepartmentProfits);
|
|
|
//记录最后一次 损益计算日期
|
|
//记录最后一次 损益计算日期
|
|
|
- computeLastProfitDateRepository.saveLastComputeDate(hospId, computeDate);
|
|
|
|
|
|
|
+ computeLastProfitDateRepository.saveLastComputeDate(hospId, computeDate,userId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3685,8 +3681,6 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
ProfitCalculationDataVo profitCalculationData = getProfitCalculationData(computeDate, hospId, reportType);
|
|
ProfitCalculationDataVo profitCalculationData = getProfitCalculationData(computeDate, hospId, reportType);
|
|
|
//计算科室损益
|
|
//计算科室损益
|
|
|
List<CostDepartmentProfitVO> costDepartmentProfitVOS = calcDeptProfit(profitCalculationData);
|
|
List<CostDepartmentProfitVO> costDepartmentProfitVOS = calcDeptProfit(profitCalculationData);
|
|
|
- // 删除这个年月的数据
|
|
|
|
|
- deleteDeptProfit(profitCalculationData.getYear(),profitCalculationData.getMonth(),reportType );
|
|
|
|
|
// 添加数据
|
|
// 添加数据
|
|
|
List<CostDepartmentProfit> costDepartmentProfits = BeanUtil.convertList(costDepartmentProfitVOS, CostDepartmentProfit.class);
|
|
List<CostDepartmentProfit> costDepartmentProfits = BeanUtil.convertList(costDepartmentProfitVOS, CostDepartmentProfit.class);
|
|
|
//统一创建时间
|
|
//统一创建时间
|
|
@@ -3694,8 +3688,11 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
costDepartmentProfits.forEach(i -> {
|
|
costDepartmentProfits.forEach(i -> {
|
|
|
i.setCreateTime(l);
|
|
i.setCreateTime(l);
|
|
|
});
|
|
});
|
|
|
|
|
+ // 删除这个年月的数据
|
|
|
|
|
+ deleteDeptProfit(profitCalculationData.getYear(),profitCalculationData.getMonth(),reportType ,hospId);
|
|
|
|
|
+ costDepartmentProfitAccountRepository.deleteDeptProfitAccountWithUser(hospId,computeDate,profitCalculationData.getCurrentUserID());
|
|
|
//保存科室损益数据
|
|
//保存科室损益数据
|
|
|
- this.saveBatch(costDepartmentProfits);
|
|
|
|
|
|
|
+ this.batchInsert(costDepartmentProfits);
|
|
|
//处理科室损益的会计科目金额数据
|
|
//处理科室损益的会计科目金额数据
|
|
|
List<CostDepartmentProfitAccount> costDepartmentProfitAccounts=new ArrayList<>();
|
|
List<CostDepartmentProfitAccount> costDepartmentProfitAccounts=new ArrayList<>();
|
|
|
for (CostDepartmentProfit deptProfit : costDepartmentProfits) {
|
|
for (CostDepartmentProfit deptProfit : costDepartmentProfits) {
|
|
@@ -3707,9 +3704,9 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
costDepartmentProfitAccounts.addAll(deptProfit.getCostDepartmentProfitAccounts());
|
|
costDepartmentProfitAccounts.addAll(deptProfit.getCostDepartmentProfitAccounts());
|
|
|
}
|
|
}
|
|
|
//保存科室损益的会计科目金额数据
|
|
//保存科室损益的会计科目金额数据
|
|
|
- costDepartmentProfitAccountRepository.saveBatch(costDepartmentProfitAccounts);
|
|
|
|
|
|
|
+ costDepartmentProfitAccountRepository.batchInsert(costDepartmentProfitAccounts);
|
|
|
//记录最后一次 损益计算日期
|
|
//记录最后一次 损益计算日期
|
|
|
- computeLastProfitDateRepository.saveLastComputeDate(hospId, computeDate);
|
|
|
|
|
|
|
+ computeLastProfitDateRepository.saveLastComputeDate(hospId, computeDate,profitCalculationData.getCurrentUserID());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3721,6 +3718,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
*/
|
|
*/
|
|
|
public ProfitCalculationDataVo getProfitCalculationData(String computeDate, Long hospId, String reportType) {
|
|
public ProfitCalculationDataVo getProfitCalculationData(String computeDate, Long hospId, String reportType) {
|
|
|
ProfitCalculationDataVo profitCalculationData = new ProfitCalculationDataVo();
|
|
ProfitCalculationDataVo profitCalculationData = new ProfitCalculationDataVo();
|
|
|
|
|
+ profitCalculationData.setCurrentUserID(UserContext.getCurrentUser().getId());
|
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
|
|
@@ -3747,6 +3745,12 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
if (CollUtil.isEmpty(incomeList)) {
|
|
if (CollUtil.isEmpty(incomeList)) {
|
|
|
throw new CostException(500, "归集后数据不存在");
|
|
throw new CostException(500, "归集后数据不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ Map<String, Map<String, List<IncomeCollection>>> respIncomeGroup = incomeList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ IncomeCollection::getResponsibilityCode,
|
|
|
|
|
+ Collectors.groupingBy(IncomeCollection::getAccountingCode)
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 获取分摊后数据
|
|
// 获取分摊后数据
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(hospId,year,month);
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(hospId,year,month);
|
|
@@ -3754,13 +3758,74 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
throw new CostException(500, "分摊后数据不存在");
|
|
throw new CostException(500, "分摊后数据不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ DictDataVo accountingTypeDict = centerService.getDict(Constant.ACCOUNTING_TYPE);
|
|
|
|
|
+ DictDataVo costTypeDict = centerService.getDict(Constant.STANDARD_COST_CATEGORIES);
|
|
|
|
|
+ List<Accounting> allCostAccounting = accountingRepository.getAllCostAccounting();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建一个映射,用于快速查找会计科目的类型,过滤掉 null 对象,过滤掉 accountingCode 为 null 的对象
|
|
|
|
|
+ Map<String, Accounting> accountingMap = allCostAccounting.stream()
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .filter(a -> a.getAccountingCode() != null)
|
|
|
|
|
+ .collect(Collectors.toMap(Accounting::getAccountingCode, o -> o));
|
|
|
|
|
+
|
|
|
|
|
+ List<DictDataVo> accountingTypeDictList = (accountingTypeDict != null && accountingTypeDict.getDataVoList() != null)
|
|
|
|
|
+ ? accountingTypeDict.getDataVoList() : new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ List<DictDataVo> costTypeDictList = (costTypeDict != null && costTypeDict.getDataVoList() != null)
|
|
|
|
|
+ ? costTypeDict.getDataVoList() : new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建一个映射,用于快速查找会计科目类型的扩展字段,过滤掉 null 对象,过滤掉 code 为 null 的对象
|
|
|
|
|
+ Map<String, DictDataVo> accountingTypeMap = accountingTypeDictList.stream()
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .filter(d -> d.getCode() != null)
|
|
|
|
|
+ .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
|
|
|
|
|
+
|
|
|
|
|
+ // 创建一个映射,用于快速查找会计科目类型的扩展字段,过滤掉 null 对象,过滤掉 code 为 null 的对象
|
|
|
|
|
+ Map<String, DictDataVo> costTypeMap = costTypeDictList.stream()
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .filter(d -> d.getCode() != null)
|
|
|
|
|
+ .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
|
|
|
|
|
+
|
|
|
// 封装数据
|
|
// 封装数据
|
|
|
List<AllocationQueryReportVO> allocationQueryReportVOList = BeanUtil.convertList(allocationQueryList, AllocationQueryReportVO.class);
|
|
List<AllocationQueryReportVO> allocationQueryReportVOList = BeanUtil.convertList(allocationQueryList, AllocationQueryReportVO.class);
|
|
|
allocationQueryReportVOList.forEach(i -> {
|
|
allocationQueryReportVOList.forEach(i -> {
|
|
|
i.setAccountingCodes(Arrays.asList(i.getAccountingCode().split(StrUtil.COMMA)));
|
|
i.setAccountingCodes(Arrays.asList(i.getAccountingCode().split(StrUtil.COMMA)));
|
|
|
i.setAccountingNames(Arrays.asList(i.getAccountingName().split(StrUtil.COMMA)));
|
|
i.setAccountingNames(Arrays.asList(i.getAccountingName().split(StrUtil.COMMA)));
|
|
|
|
|
+ //构建会计科目的成本类型及会计科目类型
|
|
|
|
|
+ Accounting accounting = accountingMap.get(i.getAccountingCode());
|
|
|
|
|
+ if(ObjectUtils.isEmpty( accounting)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ DictDataVo costType = costTypeMap.get(String.valueOf(accounting.getCostType()));
|
|
|
|
|
+ if(!ObjectUtils.isEmpty( costType)){
|
|
|
|
|
+ i.setCostType(costType.getExpandOne());
|
|
|
|
|
+ }
|
|
|
|
|
+ DictDataVo accountingType = accountingTypeMap.get(String.valueOf(accounting.getCostType()));
|
|
|
|
|
+ if(!ObjectUtils.isEmpty( accountingType)){
|
|
|
|
|
+ i.setAccountType(accountingType.getExpandOne());
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ //责任中心+会计科目分组
|
|
|
|
|
+ Map<String, Map<String, List<AllocationQueryReportVO>>> respAccountCostGroup = allocationQueryReportVOList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ AllocationQueryReportVO::getTargetResponsibilityCode,
|
|
|
|
|
+ Collectors.groupingBy(AllocationQueryReportVO::getAccountingCode)
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ //责任中心+来源责任中心分组
|
|
|
|
|
+ Map<String, Map<String, List<AllocationQueryReportVO>>> respSourceCostGroup = allocationQueryReportVOList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ AllocationQueryReportVO::getTargetResponsibilityCode,
|
|
|
|
|
+ Collectors.groupingBy(AllocationQueryReportVO::getResponsibilityCode)
|
|
|
|
|
+ ));
|
|
|
|
|
+ //责任中心+分摊层级分组
|
|
|
|
|
+ Map<String, Map<Long, List<AllocationQueryReportVO>>> respShareLevelCostGroup = allocationQueryReportVOList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ AllocationQueryReportVO::getTargetResponsibilityCode,
|
|
|
|
|
+ Collectors.groupingBy(AllocationQueryReportVO::getShareLevelId)
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
// 查询分摊的报表数据 后面的计算方式需要使用 小计等需要使用
|
|
// 查询分摊的报表数据 后面的计算方式需要使用 小计等需要使用
|
|
|
List<Allocation> allocationList = allocationService.getByDate( year, month, hospId);
|
|
List<Allocation> allocationList = allocationService.getByDate( year, month, hospId);
|
|
|
if (CollUtil.isEmpty(allocationList)) {
|
|
if (CollUtil.isEmpty(allocationList)) {
|
|
@@ -3776,6 +3841,10 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
profitCalculationData.setReportRelationMap(reportRelationMap);
|
|
profitCalculationData.setReportRelationMap(reportRelationMap);
|
|
|
profitCalculationData.setCostShareLevelList(costShareLevelList);
|
|
profitCalculationData.setCostShareLevelList(costShareLevelList);
|
|
|
profitCalculationData.setResponsibilityList(responsibilityList);
|
|
profitCalculationData.setResponsibilityList(responsibilityList);
|
|
|
|
|
+ profitCalculationData.setRespIncomeGroup(respIncomeGroup);
|
|
|
|
|
+ profitCalculationData.setRespAccountCostGroup(respAccountCostGroup);
|
|
|
|
|
+ profitCalculationData.setRespSourceCostGroup(respSourceCostGroup);
|
|
|
|
|
+ profitCalculationData.setRespShareLevelCostGroup(respShareLevelCostGroup);
|
|
|
return profitCalculationData;
|
|
return profitCalculationData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -3785,7 +3854,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
private List<CostDepartmentProfitVO> calcDeptProfit(ProfitCalculationDataVo profitCalculationData) {
|
|
private List<CostDepartmentProfitVO> calcDeptProfit(ProfitCalculationDataVo profitCalculationData) {
|
|
|
- List<ReportForm> firstLevelReports = profitCalculationData.getReportFormList().stream().filter(i -> i.getParentId().equals(NumberConstant.ZERO)).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<ReportForm> firstLevelReports = profitCalculationData.getReportFormList().stream().filter(i -> NumberConstant.ZERO.equals(i.getParentId().intValue())).collect(Collectors.toList());
|
|
|
if(CollectionUtils.isEmpty(firstLevelReports)){
|
|
if(CollectionUtils.isEmpty(firstLevelReports)){
|
|
|
throw new CostException(500, "未找到第一层报表项目,请检查报表配置");
|
|
throw new CostException(500, "未找到第一层报表项目,请检查报表配置");
|
|
|
}
|
|
}
|
|
@@ -3798,16 +3867,30 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
setChildReport(reportForm,reportParentGroup);
|
|
setChildReport(reportForm,reportParentGroup);
|
|
|
}
|
|
}
|
|
|
//按责任中心计算科室损益
|
|
//按责任中心计算科室损益
|
|
|
- for (Responsibility responsibility : profitCalculationData.getResponsibilityList()) {
|
|
|
|
|
- Map<Integer,CostDepartmentProfitVO> costDepartmentProfitMap=new HashMap<>();
|
|
|
|
|
- //计算责任中心的所有报表项目
|
|
|
|
|
- for (ReportForm reportForm : firstLevelReports) {
|
|
|
|
|
- calcRespReportAmount(responsibility, reportForm,profitCalculationData, costDepartmentProfitMap);
|
|
|
|
|
- }
|
|
|
|
|
- //添加到结果集合
|
|
|
|
|
- costDepartmentProfitVOList.addAll(costDepartmentProfitMap.values());
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+// for (Responsibility responsibility : profitCalculationData.getResponsibilityList()) {
|
|
|
|
|
+// Map<Integer,CostDepartmentProfitVO> costDepartmentProfitMap=new HashMap<>();
|
|
|
|
|
+// //计算责任中心的所有报表项目
|
|
|
|
|
+// for (ReportForm reportForm : firstLevelReports) {
|
|
|
|
|
+// calcRespReportAmount(responsibility, reportForm,profitCalculationData, costDepartmentProfitMap);
|
|
|
|
|
+// }
|
|
|
|
|
+// //添加到结果集合
|
|
|
|
|
+// costDepartmentProfitVOList.addAll(costDepartmentProfitMap.values());
|
|
|
|
|
+// }
|
|
|
|
|
+ //按责任中心计算科室损益(并行)
|
|
|
|
|
+ List<CostDepartmentProfitVO> result = profitCalculationData.getResponsibilityList().parallelStream()
|
|
|
|
|
+ .map(responsibility -> {
|
|
|
|
|
+ Map<Integer, CostDepartmentProfitVO> costDepartmentProfitMap = new HashMap<>();
|
|
|
|
|
+ // 计算责任中心的所有报表项目
|
|
|
|
|
+ for (ReportForm reportForm : firstLevelReports) {
|
|
|
|
|
+ calcRespReportAmount(responsibility, reportForm, profitCalculationData, costDepartmentProfitMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ return new ArrayList<>(costDepartmentProfitMap.values());
|
|
|
|
|
+ })
|
|
|
|
|
+ .flatMap(List::stream)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ costDepartmentProfitVOList.addAll(result);
|
|
|
|
|
+ return costDepartmentProfitVOList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3927,7 +4010,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
costDepartmentProfitVO.setResponsibilityName(responsibility.getResponsibilityName());
|
|
costDepartmentProfitVO.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
costDepartmentProfitVO.setCostType(NumberConstant.ONE);
|
|
costDepartmentProfitVO.setCostType(NumberConstant.ONE);
|
|
|
costDepartmentProfitVO.setIncomeType(NumberConstant.ONE);
|
|
costDepartmentProfitVO.setIncomeType(NumberConstant.ONE);
|
|
|
- costDepartmentProfitVO.setHospId(UserContext.getHospId());
|
|
|
|
|
|
|
+ costDepartmentProfitVO.setHospId(profitCalculationData.getHospId());
|
|
|
costDepartmentProfitVO.setShareType(Integer.valueOf(profitCalculationData.getReportType()));
|
|
costDepartmentProfitVO.setShareType(Integer.valueOf(profitCalculationData.getReportType()));
|
|
|
costDepartmentProfitVO.setType(reportForm.getCostType());
|
|
costDepartmentProfitVO.setType(reportForm.getCostType());
|
|
|
costDepartmentProfitVO.setFraction(reportForm.getFraction());
|
|
costDepartmentProfitVO.setFraction(reportForm.getFraction());
|
|
@@ -3950,13 +4033,19 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
}
|
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
|
List<String> responsibilityCodeList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
List<String> responsibilityCodeList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
- //类型是收入时取分摊结果表单的数据计算
|
|
|
|
|
- // 需要查询分摊后的表
|
|
|
|
|
- List<AllocationQueryReportVO> reportVOList = profitCalculationData.getAllocationQueryReportVOList().stream().filter(m ->
|
|
|
|
|
- m.getTargetResponsibilityCode().equals(responsibility.getResponsibilityCode())
|
|
|
|
|
- &&NumberConstant.TWO.equals(m.getOriginType().intValue())
|
|
|
|
|
- && responsibilityCodeList.contains(m.getResponsibilityCode())).collect(Collectors.toList());
|
|
|
|
|
- if (CollUtil.isEmpty(reportVOList)) {
|
|
|
|
|
|
|
+ // 获取指定责任中心的分摊数据
|
|
|
|
|
+ Map<String, List<AllocationQueryReportVO>> respSourceCostMap = profitCalculationData.getRespSourceCostGroup().get(responsibility.getResponsibilityCode());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(respSourceCostMap) || respSourceCostMap.isEmpty()){
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取指定会计科目的分摊数据
|
|
|
|
|
+ List<AllocationQueryReportVO> reportVOList=new ArrayList<>();
|
|
|
|
|
+ responsibilityCodeList.forEach(respCode -> {
|
|
|
|
|
+ if(respSourceCostMap.containsKey(respCode)){
|
|
|
|
|
+ reportVOList.addAll(respSourceCostMap.get(respCode));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if(CollectionUtils.isEmpty(reportVOList)){
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
|
List<CostDepartmentProfitAccount> costDepartmentProfitAccounts = calculateCostByTypeAndAccount(reportVOList);
|
|
List<CostDepartmentProfitAccount> costDepartmentProfitAccounts = calculateCostByTypeAndAccount(reportVOList);
|
|
@@ -4149,14 +4238,20 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
|
- List<String> shareLevelIdList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
|
|
- //类型是收入时取分摊结果表单的数据计算
|
|
|
|
|
- // 需要查询分摊后的表
|
|
|
|
|
- List<AllocationQueryReportVO> reportVOList = profitCalculationData.getAllocationQueryReportVOList().stream().filter(m ->
|
|
|
|
|
- m.getTargetResponsibilityCode().equals(responsibility.getResponsibilityCode())
|
|
|
|
|
- &&NumberConstant.TWO.equals(m.getOriginType().intValue())
|
|
|
|
|
- && shareLevelIdList.contains(m.getShareLevelId())).collect(Collectors.toList());
|
|
|
|
|
- if (CollUtil.isEmpty(reportVOList)) {
|
|
|
|
|
|
|
+ List<Long> shareLevelIdList = reportRelationList.stream().map(o->Long.valueOf(o.getRelationCode())).collect(Collectors.toList());
|
|
|
|
|
+ // 获取指定责任中心的分摊数据
|
|
|
|
|
+ Map<Long, List<AllocationQueryReportVO>> respShareLevelCostMap = profitCalculationData.getRespShareLevelCostGroup().get(responsibility.getResponsibilityCode());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(respShareLevelCostMap) || respShareLevelCostMap.isEmpty()){
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取指定会计科目的分摊数据
|
|
|
|
|
+ List<AllocationQueryReportVO> reportVOList=new ArrayList<>();
|
|
|
|
|
+ shareLevelIdList.forEach(shareLevelId -> {
|
|
|
|
|
+ if(respShareLevelCostMap.containsKey(shareLevelId)){
|
|
|
|
|
+ reportVOList.addAll(respShareLevelCostMap.get(shareLevelId));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if(CollectionUtils.isEmpty(reportVOList)){
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
|
List<CostDepartmentProfitAccount> costDepartmentProfitAccounts = calculateCostByTypeAndAccount(reportVOList);
|
|
List<CostDepartmentProfitAccount> costDepartmentProfitAccounts = calculateCostByTypeAndAccount(reportVOList);
|
|
@@ -4183,14 +4278,22 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
}
|
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
|
List<String> accountList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
List<String> accountList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
- // 查找在归集数据里面当前责任中心对应的这些会计科目的金额
|
|
|
|
|
- List<IncomeCollection> incomeCollectionList = profitCalculationData.getIncomeList().stream().filter(income ->
|
|
|
|
|
- income.getResponsibilityCode().equals(responsibility.getResponsibilityCode())
|
|
|
|
|
- && accountList.contains(income.getAccountingCode())).collect(Collectors.toList());
|
|
|
|
|
- if(CollectionUtils.isEmpty(incomeCollectionList)){
|
|
|
|
|
|
|
+ // 获取指定责任中心的收入数据
|
|
|
|
|
+ Map<String, List<IncomeCollection>> respAccountIncomeMap = profitCalculationData.getRespIncomeGroup().get(responsibility.getResponsibilityCode());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(respAccountIncomeMap) || respAccountIncomeMap.isEmpty()){
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
|
- BigDecimal totalAmount = incomeCollectionList.stream()
|
|
|
|
|
|
|
+ //获取指定会计科目的收入数据
|
|
|
|
|
+ List<IncomeCollection> reportVOList=new ArrayList<>();
|
|
|
|
|
+ accountList.forEach(accountCode -> {
|
|
|
|
|
+ if(respAccountIncomeMap.containsKey(accountCode)){
|
|
|
|
|
+ reportVOList.addAll(respAccountIncomeMap.get(accountCode));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if(CollectionUtils.isEmpty(reportVOList)){
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal totalAmount = reportVOList.stream()
|
|
|
.map(IncomeCollection::getAmount)
|
|
.map(IncomeCollection::getAmount)
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
@@ -4211,12 +4314,23 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
}
|
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
|
List<String> accountList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
List<String> accountList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
- //类型是收入时取分摊结果表单的数据计算
|
|
|
|
|
- // 需要查询分摊后的表
|
|
|
|
|
- List<AllocationQueryReportVO> reportVOList = profitCalculationData.getAllocationQueryReportVOList().stream().filter(m ->
|
|
|
|
|
- m.getTargetResponsibilityCode().equals(responsibility.getResponsibilityCode())
|
|
|
|
|
- &&(NumberConstant.ZERO.equals(reportForm.getCostType())||reportForm.getCostType().equals(m.getOriginType().intValue()))
|
|
|
|
|
- &&accountList.contains(m.getAccountingCode())).collect(Collectors.toList());
|
|
|
|
|
|
|
+ // 获取指定责任中心的分摊数据
|
|
|
|
|
+ Map<String, List<AllocationQueryReportVO>> respAccountCostMap = profitCalculationData.getRespAccountCostGroup().get(responsibility.getResponsibilityCode());
|
|
|
|
|
+ if(ObjectUtils.isEmpty(respAccountCostMap) || respAccountCostMap.isEmpty()){
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取指定会计科目的分摊数据
|
|
|
|
|
+ List<AllocationQueryReportVO> reportVOList=new ArrayList<>();
|
|
|
|
|
+ accountList.forEach(accountCode -> {
|
|
|
|
|
+ if(respAccountCostMap.containsKey(accountCode)){
|
|
|
|
|
+ reportVOList.addAll(respAccountCostMap.get(accountCode));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if(CollectionUtils.isEmpty(reportVOList)){
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取指定成本类别(全部/直接/间接)的分摊数据
|
|
|
|
|
+ List<AllocationQueryReportVO> collect = reportVOList.stream().filter(m -> NumberConstant.ZERO.equals(reportForm.getCostType()) || reportForm.getCostType().equals(m.getOriginType().intValue())).collect(Collectors.toList());
|
|
|
if (CollUtil.isEmpty(reportVOList)) {
|
|
if (CollUtil.isEmpty(reportVOList)) {
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
@@ -4327,9 +4441,9 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
* @param month
|
|
* @param month
|
|
|
* @param reportType
|
|
* @param reportType
|
|
|
*/
|
|
*/
|
|
|
- public void deleteDeptProfit(Integer year, Integer month,String reportType) {
|
|
|
|
|
|
|
+ public void deleteDeptProfit(Integer year, Integer month,String reportType,Long hospId) {
|
|
|
// 删除这个年月的数据
|
|
// 删除这个年月的数据
|
|
|
- this.remove(new QueryWrapper<CostDepartmentProfit>().lambda().eq(CostDepartmentProfit::getHospId, UserContext.getHospId())
|
|
|
|
|
|
|
+ this.remove(new QueryWrapper<CostDepartmentProfit>().lambda().eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
.eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month).eq(CostDepartmentProfit::getShareType, Integer.valueOf(reportType)));
|
|
.eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month).eq(CostDepartmentProfit::getShareType, Integer.valueOf(reportType)));
|
|
|
}
|
|
}
|
|
|
|
|
|