|
@@ -2,6 +2,7 @@ package com.imed.costaccount.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -56,7 +57,9 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
|
|
|
private final CostIncomeFileService costIncomeFileService;
|
|
|
|
|
|
- public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService) {
|
|
|
+ private final CostIncomeGroupSetService costIncomeGroupSetService;
|
|
|
+
|
|
|
+ public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService, CostIncomeGroupSetService costIncomeGroupSetService) {
|
|
|
this.departmentService = departmentService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.productService = productService;
|
|
@@ -64,6 +67,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
this.responsibilityDepartmentService = responsibilityDepartmentService;
|
|
|
this.accountingProductService = accountingProductService;
|
|
|
this.costIncomeFileService = costIncomeFileService;
|
|
|
+ this.costIncomeGroupSetService = costIncomeGroupSetService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -157,8 +161,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
//
|
|
|
Map<String, Department> departmentMap = getDepartmentByCodeNameMap(hospId);
|
|
|
Map<String, Product> productMap = getProductByCodeNameMap(hospId);
|
|
|
- Map<Long, Responsibility> responsibilityMap = getLongResponsibilityMap(hospId);
|
|
|
- Map<Long, Accounting> accountingMap = getLongAccountingMap(hospId);
|
|
|
+ Map<Long, Responsibility> responsibilityMap = getResponsibilityIdResponsibilityMap(hospId);
|
|
|
+ Map<Long, Accounting> accountingMap = getAccountIdAccountingMap(hospId);
|
|
|
List<ResponsibilityDepartment> responsibilityDepartmentList = getResponsibilityDepartments(hospId);
|
|
|
if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
|
|
|
throw new CostException(500, "没有科室责任中心对照数据");
|
|
@@ -203,37 +207,57 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ * Map类型
|
|
|
+ * Key DepartmentId
|
|
|
+ * Value ResponsibilityId
|
|
|
* @param responsibilityDepartmentList
|
|
|
* @return
|
|
|
*/
|
|
|
- @NotNull
|
|
|
- private Map<Long, Long> getDepartmentIdResponsibilityIdMap(List<ResponsibilityDepartment> responsibilityDepartmentList) {
|
|
|
+ public Map<Long, Long> getDepartmentIdResponsibilityIdMap(List<ResponsibilityDepartment> responsibilityDepartmentList) {
|
|
|
return responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
|
|
|
}
|
|
|
|
|
|
- private List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
|
|
|
+ public List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
|
|
|
return responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
|
|
|
.eq(ResponsibilityDepartment::getHospId, hospId));
|
|
|
}
|
|
|
|
|
|
- @NotNull
|
|
|
- private Map<Long, Accounting> getLongAccountingMap(Long hospId) {
|
|
|
+ /**
|
|
|
+ * Key AccountId
|
|
|
+ * Value Accounting对象
|
|
|
+ * @param hospId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<Long, Accounting> getAccountIdAccountingMap(Long hospId) {
|
|
|
return accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
|
|
|
}
|
|
|
|
|
|
- @NotNull
|
|
|
- private Map<Long, Responsibility> getLongResponsibilityMap(Long hospId) {
|
|
|
+ /**
|
|
|
+ * Key responsibilityId 责任中心Id
|
|
|
+ * Value Responsibility对象
|
|
|
+ * @param hospId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<Long, Responsibility> getResponsibilityIdResponsibilityMap(Long hospId) {
|
|
|
return responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
|
|
|
}
|
|
|
|
|
|
- @NotNull
|
|
|
- private Map<String, Product> getProductByCodeNameMap(Long hospId) {
|
|
|
+ /**
|
|
|
+ * Key 成本项目Code+Name
|
|
|
+ * Value 成本项目对象
|
|
|
+ * @param hospId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Product> getProductByCodeNameMap(Long hospId) {
|
|
|
return productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
|
|
|
}
|
|
|
-
|
|
|
- @NotNull
|
|
|
- private Map<String, Department> getDepartmentByCodeNameMap(Long hospId) {
|
|
|
+ /**
|
|
|
+ * Key 科室项目Code+Name
|
|
|
+ * Value 科室对象
|
|
|
+ * @param hospId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Department> getDepartmentByCodeNameMap(Long hospId) {
|
|
|
return departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
|
|
|
}
|
|
|
|
|
@@ -269,6 +293,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, List<CostIncomeGroup> costIncomeGroupArrayList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, Long hospId,Integer year,Integer month) {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
|
|
|
+ AfterIncomegroup afterIncomegroup = new AfterIncomegroup();
|
|
|
// 用来检验数据合理性的循环
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
List<Object> data = list.get(i);
|
|
@@ -344,10 +369,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
} else {
|
|
|
+ Responsibility responsibility = responsibilityMap.get(responsibilityId);
|
|
|
costIncomeGroup.setOpenDepartmentCode(openDepartmentCode);
|
|
|
costIncomeGroup.setOpenDepartmentName(openDepartmentName);
|
|
|
- costIncomeGroup.setOpenResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
|
|
|
- costIncomeGroup.setOpenResponsibilityName(responsibilityMap.get(responsibilityId).getResponsibilityName());
|
|
|
+ costIncomeGroup.setOpenResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ costIncomeGroup.setOpenResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ afterIncomegroup.setOpenDepartmentStatus(responsibility.getResponsibilityType());
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
@@ -373,10 +400,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
} else {
|
|
|
+ Responsibility responsibility = responsibilityMap.get(responsibilityId);
|
|
|
costIncomeGroup.setStartDepartmentCode(startDepartmentCode);
|
|
|
costIncomeGroup.setStartDepartmentName(startDepartmentName);
|
|
|
- costIncomeGroup.setStartResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
|
|
|
- costIncomeGroup.setStartResponsibilityName(responsibilityMap.get(responsibilityId).getResponsibilityName());
|
|
|
+ costIncomeGroup.setStartResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ costIncomeGroup.setStartResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ afterIncomegroup.setStartDepartmentStatus(responsibility.getResponsibilityType());
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
@@ -391,12 +420,35 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
.setPatientName(data.get(10).toString()).setPatientFee(data.get(11).toString()).setReceiptFee(data.get(12).toString())
|
|
|
.setTotalNumber(Integer.parseInt(data.get(13).toString())).setUnit(data.get(14).toString())
|
|
|
.setFeeDatetime(DateUtils.StringToDate(data.get(16).toString(), DateStyleEnum.YYYY_MM_DD_HH_MM_SS_EN));
|
|
|
- //
|
|
|
+ if (StrUtil.isNotBlank(costIncomeGroup.getOpenResponsibilityCode())){
|
|
|
+
|
|
|
+ }
|
|
|
costIncomeGroup.setHospId(hospId);
|
|
|
costIncomeGroup.setCreateTime(System.currentTimeMillis());
|
|
|
costIncomeGroup.setDateYear(year);
|
|
|
costIncomeGroup.setDateMonth(month);
|
|
|
costIncomeGroup.setAmount(beforeMoney);
|
|
|
+ // 检验数据
|
|
|
+ Integer openDepartmentStatus = afterIncomegroup.getOpenDepartmentStatus();
|
|
|
+ Integer startDepartmentStatus = afterIncomegroup.getStartDepartmentStatus();
|
|
|
+ Map<String, CostIncomeGroupSet> incomeGroupSetMap = costIncomeGroupSetService.list(new QueryWrapper<CostIncomeGroupSet>().lambda().eq(CostIncomeGroupSet::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getOpenDepartmentStatus().toString() + k.getStartDepartmentStatus().toString(), synOe -> synOe));
|
|
|
+ CostIncomeGroupSet costIncomeGroupSet = incomeGroupSetMap.get(openDepartmentStatus.toString() + startDepartmentStatus.toString());
|
|
|
+ if (Objects.nonNull(costIncomeGroupSet)){
|
|
|
+ afterIncomegroup.setOpenDepartmentStatus(costIncomeGroupSet.getOpenDepartmentStatus());
|
|
|
+ afterIncomegroup.setOpenDepartmentProportion(costIncomeGroupSet.getOpenDepartmentProportion());
|
|
|
+ // TODO 金额
|
|
|
+// afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply();
|
|
|
+ afterIncomegroup.setStartDepartmentStatus(costIncomeGroupSet.getStartDepartmentStatus());
|
|
|
+ afterIncomegroup.setStartDepartmentProportion(costIncomeGroupSet.getStartDepartmentProportion());
|
|
|
+ // TODO 金额
|
|
|
+// afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply();
|
|
|
+ if (NumberConstant.ZERO.equals(costIncomeGroupSet.getOpenDepartmentProportion()) && NumberConstant.ZERO.equals(costIncomeGroupSet.getStartDepartmentProportion())){
|
|
|
+ afterIncomegroup.setResponsibilityCodes(costIncomeGroupSet.getResponsibilityCodes());
|
|
|
+ afterIncomegroup.setDirectStatus(NumberConstant.TWO);
|
|
|
+ }
|
|
|
+ costIncomeGroup.setAfterIncomeGroup(JSON.toJSONString(afterIncomegroup));
|
|
|
+ }
|
|
|
+
|
|
|
costIncomeGroupArrayList.add(costIncomeGroup);
|
|
|
}
|
|
|
}
|