|
@@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -62,6 +63,13 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
ItemEquipmentMapRepository itemEquipmentMapRepository;
|
|
|
|
|
|
ItemSpaceMapRepository itemSpaceMapRepository;
|
|
|
+
|
|
|
+ StandItemEmpMapRepository standItemEmpMapRepository;
|
|
|
+
|
|
|
+ StandItemEquipmentMapRepository standItemEquipmentMapRepository;
|
|
|
+
|
|
|
+ StandItemSpaceMapRepository standItemSpaceMapRepository;
|
|
|
+
|
|
|
ShareParamTypeMapRepository shareParamTypeMapRepository;
|
|
|
ResponsibilityDepartmentRepository responsibilityDepartmentRepository;
|
|
|
|
|
@@ -75,11 +83,15 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
SqlService sqlService;
|
|
|
ResponsibilityDepartmentService responsibilityDepartmentService;
|
|
|
|
|
|
- public ShareParamServiceImpl(ComputeShareParamRepository repository, ComputeShareParamDetailRepository detailRepository, ImportPatientItemRepository importPatientItemRepository, ItemRepository itemRepository, ItemEmpMapRepository itemEmpMapRepository, ItemEquipmentMapRepository itemEquipmentMapRepository, ItemSpaceMapRepository itemSpaceMapRepository, ShareParamTypeMapRepository shareParamTypeMapRepository, ResponsibilityDepartmentRepository responsibilityDepartmentRepository, CenterService centerService, ComputeStandShareParamRepository computeStandShareParamRepository, ComputeStandShareParamDetailRepository computeStandShareParamDetailRepository, StandItemService standItemService,SqlService sqlService,ResponsibilityDepartmentService responsibilityDepartmentService) {
|
|
|
+ public ShareParamServiceImpl(ComputeShareParamRepository repository, ComputeShareParamDetailRepository detailRepository, ImportPatientItemRepository importPatientItemRepository, ItemRepository itemRepository, ItemEmpMapRepository itemEmpMapRepository, ItemEquipmentMapRepository itemEquipmentMapRepository, ItemSpaceMapRepository itemSpaceMapRepository, ShareParamTypeMapRepository shareParamTypeMapRepository, ResponsibilityDepartmentRepository responsibilityDepartmentRepository, CenterService centerService, ComputeStandShareParamRepository computeStandShareParamRepository, ComputeStandShareParamDetailRepository computeStandShareParamDetailRepository, StandItemService standItemService,SqlService sqlService,ResponsibilityDepartmentService responsibilityDepartmentService
|
|
|
+ ,StandItemEmpMapRepository standItemEmpMapRepository,StandItemEquipmentMapRepository standItemEquipmentMapRepository,StandItemSpaceMapRepository standItemSpaceMapRepository) {
|
|
|
this.repository = repository;
|
|
|
this.detailRepository = detailRepository;
|
|
|
this.importPatientItemRepository = importPatientItemRepository;
|
|
|
this.itemRepository = itemRepository;
|
|
|
+ this.standItemEmpMapRepository = standItemEmpMapRepository;
|
|
|
+ this.standItemEquipmentMapRepository = standItemEquipmentMapRepository;
|
|
|
+ this.standItemSpaceMapRepository = standItemSpaceMapRepository;
|
|
|
this.itemEmpMapRepository = itemEmpMapRepository;
|
|
|
this.itemEquipmentMapRepository = itemEquipmentMapRepository;
|
|
|
this.itemSpaceMapRepository = itemSpaceMapRepository;
|
|
@@ -252,6 +264,13 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
List<ItemEquipmentMap> itemEquipmentMaps = itemEquipmentMapRepository.getList();
|
|
|
//医疗服务项目的使用空间信息
|
|
|
List<ItemSpaceMap> itemSpaceMaps = itemSpaceMapRepository.getList();
|
|
|
+ //标准项目字典人员对照
|
|
|
+ List<StandItemEmpMap> standItemEmpMaps = standItemEmpMapRepository.getList();
|
|
|
+ //标准项目字典设备对照
|
|
|
+ List<StandItemEquipmentMap> standItemEquipmentMaps = standItemEquipmentMapRepository.getList();
|
|
|
+ //标准项目字典空间对照
|
|
|
+ List<StandItemSpaceMap> standItemSpaceMaps = standItemSpaceMapRepository.getList();
|
|
|
+
|
|
|
//科室责任中心对照信息
|
|
|
List<ResponsibilityDepartIdVO> responsibilityDeptMaps = responsibilityDepartmentService.getResponsibilityDepart();
|
|
|
//分摊参数设置信息
|
|
@@ -293,7 +312,7 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
computeShareParamList.add(computeShareCost);
|
|
|
//创建分摊参数主表对象对应的明细对象
|
|
|
shareParamTypeMaps.stream().forEach(shareParamType -> {
|
|
|
- ComputeShareParamDetail computeShareParamDetail = createComputeShareParamDetail(currentUser, computeDate, ptItem, computeShareCost, shareParamType, itemEmpMaps, itemEquipmentMaps, itemSpaceMaps);
|
|
|
+ ComputeShareParamDetail computeShareParamDetail = createComputeShareParamDetail(currentUser, computeDate, ptItem, computeShareCost, shareParamType, itemEmpMaps, itemEquipmentMaps, itemSpaceMaps,standItemEmpMaps, standItemEquipmentMaps, standItemSpaceMaps);
|
|
|
ComputeShareParamDetailList.add(computeShareParamDetail);
|
|
|
});
|
|
|
}
|
|
@@ -378,7 +397,8 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ComputeShareParamDetail createComputeShareParamDetail( SessionUserVO currentUser,String computeDate,PatientItemDepartmentGroupVo ptItem,ComputeShareParam computeShareCost,ShareParamTypeMap shareParamType,
|
|
|
- List<ItemEmpMap> itemEmpMaps,List<ItemEquipmentMap> itemEquipmentMaps ,List<ItemSpaceMap> itemSpaceMaps){
|
|
|
+ List<ItemEmpMap> itemEmpMaps,List<ItemEquipmentMap> itemEquipmentMaps ,List<ItemSpaceMap> itemSpaceMaps,
|
|
|
+ List<StandItemEmpMap> standItemEmpMaps,List<StandItemEquipmentMap> standItemEquipmentMaps ,List<StandItemSpaceMap> standItemSpaceMaps){
|
|
|
//明细表公共对象
|
|
|
ComputeShareParamDetail costDetail = new ComputeShareParamDetail();
|
|
|
costDetail.setComputeDate(computeDate);
|
|
@@ -391,30 +411,48 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
BigDecimal computeSingleResult = calcEmpParamValue(shareParamType, ptItem, itemEmpMaps);
|
|
|
costDetail.setComputeSingleResult(computeSingleResult);
|
|
|
costDetail.setComputeResult(computeSingleResult.multiply(ptItem.getNum()));
|
|
|
+ //计算标准法参与人员的参数值
|
|
|
+ BigDecimal standComputeSingleResult = calcStandEmpParamValue(shareParamType, ptItem, standItemEmpMaps);
|
|
|
+ costDetail.setStandComputeSingleResult(standComputeSingleResult);
|
|
|
+ costDetail.setStandComputeResult(standComputeSingleResult.multiply(ptItem.getNum()));
|
|
|
}else if(shareParamType.getSourceType().equals(NumberConstant.TWO_S)){
|
|
|
//计算使用设备的参数值
|
|
|
BigDecimal computeSingleResult = calcEquipmentParamValue(shareParamType, ptItem, itemEquipmentMaps);
|
|
|
costDetail.setComputeSingleResult(computeSingleResult);
|
|
|
costDetail.setComputeResult(computeSingleResult.multiply(ptItem.getNum()));
|
|
|
+ //计算标准法使用设备的参数值
|
|
|
+ BigDecimal standComputeSingleResult = calcStandEquipmentParamValue(shareParamType, ptItem, standItemEquipmentMaps);
|
|
|
+ costDetail.setStandComputeSingleResult(standComputeSingleResult);
|
|
|
+ costDetail.setStandComputeResult(standComputeSingleResult.multiply(ptItem.getNum()));
|
|
|
}else if(shareParamType.getSourceType().equals(NumberConstant.THREE_S)){
|
|
|
//计算使用空间的参数值
|
|
|
BigDecimal computeSingleResult = calcSpaceParamValue(shareParamType, ptItem, itemSpaceMaps);
|
|
|
costDetail.setComputeSingleResult(computeSingleResult);
|
|
|
costDetail.setComputeResult(computeSingleResult.multiply(ptItem.getNum()));
|
|
|
+ //计算标准法使用空间的参数值
|
|
|
+ BigDecimal standComputeSingleResult = calcStandSpaceParamValue(shareParamType, ptItem,standItemSpaceMaps);
|
|
|
+ costDetail.setStandComputeSingleResult(standComputeSingleResult);
|
|
|
+ costDetail.setStandComputeResult(standComputeSingleResult.multiply(ptItem.getNum()));
|
|
|
}else if(shareParamType.getSourceType().equals(NumberConstant.FOUR_S)){
|
|
|
//计算项目收入的参数值
|
|
|
BigDecimal computeResult = ptItem.getAmount();
|
|
|
if (!ptItem.getNum().equals(BigDecimal.ZERO.setScale(NumberConstant.TWO, RoundingMode.HALF_UP))) {
|
|
|
costDetail.setComputeSingleResult(computeResult.divide(ptItem.getNum(), NumberConstant.FOUR, RoundingMode.HALF_UP));
|
|
|
+ costDetail.setStandComputeSingleResult(computeResult.divide(ptItem.getNum(), NumberConstant.FOUR, RoundingMode.HALF_UP));
|
|
|
} else {
|
|
|
- costDetail.setComputeSingleResult(BigDecimal.ZERO);
|
|
|
+ costDetail.setComputeSingleResult(BigDecimal.ZERO.setScale(NumberConstant.FOUR, RoundingMode.HALF_UP));
|
|
|
+ costDetail.setStandComputeSingleResult(BigDecimal.ZERO.setScale(NumberConstant.FOUR, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
costDetail.setComputeResult(computeResult);
|
|
|
+ costDetail.setStandComputeResult(computeResult);
|
|
|
}else if(shareParamType.getSourceType().equals(NumberConstant.FIVE_S)){
|
|
|
//计算项目数量的参数值
|
|
|
BigDecimal computeResult = ptItem.getNum();
|
|
|
costDetail.setComputeSingleResult(BigDecimal.ONE.setScale(NumberConstant.FOUR, RoundingMode.HALF_UP));
|
|
|
costDetail.setComputeResult(computeResult);
|
|
|
+ //计算标准法项目数量的参数值
|
|
|
+ costDetail.setStandComputeSingleResult(BigDecimal.ONE.setScale(NumberConstant.FOUR, RoundingMode.HALF_UP));
|
|
|
+ costDetail.setStandComputeResult(computeResult);
|
|
|
}
|
|
|
costDetail.setComputeShareCost(computeShareCost);
|
|
|
return costDetail;
|
|
@@ -459,6 +497,45 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
return paramValue;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算标准项目参与人员的参数值
|
|
|
+ * @param ptItem
|
|
|
+ * @param standItemEmpMaps
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal calcStandEmpParamValue(ShareParamTypeMap shareParamType,PatientItemDepartmentGroupVo ptItem,List<StandItemEmpMap> standItemEmpMaps){
|
|
|
+ //没有人员配置
|
|
|
+ if(CollectionUtils.isEmpty(standItemEmpMaps)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ String sourceCode = shareParamType.getSourceCode();
|
|
|
+ //没有维护对应的来源代码
|
|
|
+ if(Objects.isNull(sourceCode)||sourceCode.equals(Constant.EMPTY_STR)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ //获取项目对应的标准项目的参与人员配置
|
|
|
+ List<StandItemEmpMap> itemEmpList = standItemEmpMaps.stream().filter(itemEmp ->!ObjectUtils.isEmpty(ptItem.getDicItem())&& ptItem.getDicItem().getStandItemCode().equals(itemEmp.getStandItemCode())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(itemEmpList)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ BigDecimal paramValue=BigDecimal.ZERO;
|
|
|
+ //全部项目
|
|
|
+ if(sourceCode.equals(NumberConstant.ZERO_S)){
|
|
|
+ paramValue = itemEmpList.stream().map(itemEmp -> itemEmp.getExecuteTime().multiply(itemEmp.getNum())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+ //不是全部的项目时,有可能会是多个
|
|
|
+ List<String> sourceCodeList = StrUtil.split(sourceCode, "|");
|
|
|
+ //获取符合条件的项目
|
|
|
+ List<StandItemEmpMap> activeItemEmpList = itemEmpList.stream().filter(itemEmp -> sourceCodeList.contains(itemEmp.getEmpTypeCode())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(activeItemEmpList)){
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+ //只统计符合条件的项目
|
|
|
+ paramValue = activeItemEmpList.stream().map(itemEmp -> itemEmp.getExecuteTime().multiply(itemEmp.getNum())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 计算使用设备参数值
|
|
@@ -500,6 +577,46 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
return paramValue;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算标准项目使用设备参数值
|
|
|
+ * @param shareParamType
|
|
|
+ * @param ptItem
|
|
|
+ * @param standItemEquipmentMaps
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal calcStandEquipmentParamValue(ShareParamTypeMap shareParamType,PatientItemDepartmentGroupVo ptItem,List<StandItemEquipmentMap> standItemEquipmentMaps){
|
|
|
+ //没有人员配置
|
|
|
+ if(CollectionUtils.isEmpty(standItemEquipmentMaps)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ String sourceCode = shareParamType.getSourceCode();
|
|
|
+ //没有维护对应的来源代码
|
|
|
+ if(Objects.isNull(sourceCode)||sourceCode.equals(Constant.EMPTY_STR)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ //获取项目对应的标准项目的使用设备配置
|
|
|
+ List<StandItemEquipmentMap> itemEquipmentList = standItemEquipmentMaps.stream().filter(itemEmp ->!ObjectUtils.isEmpty(ptItem.getDicItem())&& itemEmp.getStandItemCode().equals(ptItem.getDicItem().getStandItemCode())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(itemEquipmentList)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ BigDecimal paramValue=BigDecimal.ZERO;
|
|
|
+ //全部项目
|
|
|
+ if(sourceCode.equals(NumberConstant.ZERO_S)){
|
|
|
+ paramValue = itemEquipmentList.stream().map(itemEmp -> itemEmp.getExecuteTime().multiply(itemEmp.getNum())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+ //不是全部的项目时,有可能会是多个
|
|
|
+ List<String> sourceCodeList = StrUtil.split(sourceCode, "|");
|
|
|
+ //获取符合条件的项目
|
|
|
+ List<StandItemEquipmentMap> activeItemEquipmentList = itemEquipmentList.stream().filter(itemEmp -> sourceCodeList.contains(itemEmp.getEquipmentCode())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(activeItemEquipmentList)){
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+ //只统计符合条件的项目
|
|
|
+ paramValue = activeItemEquipmentList.stream().map(itemEmp -> itemEmp.getExecuteTime().multiply(itemEmp.getNum())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 计算使用空间参数值
|
|
|
* @param shareParamType
|
|
@@ -540,6 +657,46 @@ public class ShareParamServiceImpl implements ShareParamService {
|
|
|
return paramValue;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算标准项目使用空间参数值
|
|
|
+ * @param shareParamType
|
|
|
+ * @param ptItem
|
|
|
+ * @param standItemSpaceMaps
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal calcStandSpaceParamValue(ShareParamTypeMap shareParamType,PatientItemDepartmentGroupVo ptItem,List<StandItemSpaceMap> standItemSpaceMaps){
|
|
|
+ //没有人员配置
|
|
|
+ if(CollectionUtils.isEmpty(standItemSpaceMaps)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ String sourceCode = shareParamType.getSourceCode();
|
|
|
+ //没有维护对应的来源代码
|
|
|
+ if(Objects.isNull(sourceCode)||sourceCode.equals(Constant.EMPTY_STR)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ //获取项目对应的使用空间配置
|
|
|
+ List<StandItemSpaceMap> itemSpaceList = standItemSpaceMaps.stream().filter(itemEmp ->!ObjectUtils.isEmpty(ptItem.getDicItem())&&itemEmp.getStandItemCode().equals(ptItem.getDicItem().getStandItemCode())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(itemSpaceList)){
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ BigDecimal paramValue=BigDecimal.ZERO;
|
|
|
+ //全部项目
|
|
|
+ if(sourceCode.equals(NumberConstant.ZERO_S)){
|
|
|
+ paramValue = itemSpaceList.stream().map(itemEmp -> itemEmp.getExecuteTime().multiply(itemEmp.getNum())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+ //不是全部的项目时,有可能会是多个
|
|
|
+ List<String> sourceCodeList = StrUtil.split(sourceCode, "|");
|
|
|
+ //获取符合条件的项目
|
|
|
+ List<StandItemSpaceMap> activeItemSpaceList = itemSpaceList.stream().filter(itemEmp -> sourceCodeList.contains(itemEmp.getSpaceCode())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(activeItemSpaceList)){
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+ //只统计符合条件的项目
|
|
|
+ paramValue = activeItemSpaceList.stream().map(itemEmp -> itemEmp.getExecuteTime().multiply(itemEmp.getNum())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return paramValue;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据责任中心获取医疗服务项目分类
|
|
|
* @param dict
|