|
@@ -3,8 +3,6 @@ package com.imed.costaccount.service.impl;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.imed.costaccount.common.exception.CostException;
|
|
|
import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.DateUtils;
|
|
@@ -12,13 +10,16 @@ import com.imed.costaccount.common.util.Result;
|
|
|
import com.imed.costaccount.common.util.UserContext;
|
|
|
import com.imed.costaccount.constants.NumberConstant;
|
|
|
import com.imed.costaccount.enums.DateStyleEnum;
|
|
|
-import com.imed.costaccount.mapper.CostShareParamGroupMapper;
|
|
|
import com.imed.costaccount.model.*;
|
|
|
import com.imed.costaccount.model.vo.IncomeErrorMessage;
|
|
|
import com.imed.costaccount.service.CostIncomeFileService;
|
|
|
-import com.imed.costaccount.service.CostShareParamGroupService;
|
|
|
import com.imed.costaccount.service.CostShareParamService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+
|
|
|
+import com.imed.costaccount.mapper.ShareParamValueMapper;
|
|
|
+import com.imed.costaccount.service.ShareParamValueService;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -29,8 +30,8 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
-@Service("costShareParamGroupService")
|
|
|
-public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGroupMapper, CostShareParamGroup> implements CostShareParamGroupService {
|
|
|
+@Service("shareParamValueService")
|
|
|
+public class ShareParamValueServiceImpl extends ServiceImpl<ShareParamValueMapper, ShareParamValue> implements ShareParamValueService {
|
|
|
|
|
|
private final CostIncomeGroupServiceImpl costIncomeGroupService;
|
|
|
|
|
@@ -38,12 +39,16 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
|
|
|
private final CostIncomeFileService costIncomeFileService;
|
|
|
|
|
|
- public CostShareParamGroupServiceImpl(CostIncomeGroupServiceImpl costIncomeGroupService, CostShareParamService costShareParamService, CostIncomeFileService costIncomeFileService) {
|
|
|
+
|
|
|
+ public ShareParamValueServiceImpl(CostIncomeGroupServiceImpl costIncomeGroupService,
|
|
|
+ CostShareParamService costShareParamService,
|
|
|
+ CostIncomeFileService costIncomeFileService) {
|
|
|
this.costIncomeGroupService = costIncomeGroupService;
|
|
|
this.costShareParamService = costShareParamService;
|
|
|
this.costIncomeFileService = costIncomeFileService;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 成本分摊参数导入
|
|
|
*
|
|
@@ -66,8 +71,8 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
month = DateUtil.month(date) + 1;
|
|
|
}
|
|
|
Long hospId = user.getHospId();
|
|
|
- List<CostShareParamGroup> groups = this.list(new QueryWrapper<CostShareParamGroup>().lambda().eq(CostShareParamGroup::getHospId, hospId)
|
|
|
- .eq(CostShareParamGroup::getDateYear, year).eq(CostShareParamGroup::getDateMonth, month));
|
|
|
+ List<ShareParamValue> groups = this.list(new QueryWrapper<ShareParamValue>().lambda().eq(ShareParamValue::getHospId, hospId)
|
|
|
+ .eq(ShareParamValue::getDateYear, year).eq(ShareParamValue::getDateMonth, month));
|
|
|
if (!CollectionUtils.isEmpty(groups)) {
|
|
|
throw new CostException(500, year + "年" + month + "月数据已存在");
|
|
|
}
|
|
@@ -86,12 +91,13 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
Map<Long, Long> responsibilityDepMap = costIncomeGroupService.getDepartmentIdResponsibilityIdMap(responsibilityDepartmentList);
|
|
|
Map<String, CostShareParam> shareParamMap = costShareParamService.list(new QueryWrapper<CostShareParam>().lambda().eq(CostShareParam::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getShareParamCode() + k.getShareParamName(), synOe -> synOe));
|
|
|
// 要保存的数据
|
|
|
- List<CostShareParamGroup> costShareParamGroupList = new LinkedList<>();
|
|
|
+ List<ShareParamValue> shareParamValues = new LinkedList<>();
|
|
|
+// List<CostShareParamGroup> costShareParamGroupList = new LinkedList<>();
|
|
|
List<Object> departmentCodes = list.get(0);
|
|
|
List<Object> departmentNames = list.get(1);
|
|
|
|
|
|
//检验数据是否准确 list包含了科室Code行与Name行 所以要从list的第三行开始
|
|
|
- checkShareParamGroupData(list, year, month, incomeErrorMessageList, departmentMap, responsibilityMap, responsibilityDepMap, shareParamMap, costShareParamGroupList, departmentCodes, departmentNames);
|
|
|
+ checkShareParamGroupData(list, year, month, incomeErrorMessageList, departmentMap, responsibilityMap, responsibilityDepMap, shareParamMap, shareParamValues, departmentCodes, departmentNames);
|
|
|
// 文件上传
|
|
|
String uploadFile = costIncomeGroupService.uploadFile(file, UserContext.getCurrentUser());
|
|
|
// 上传记录保存
|
|
@@ -99,32 +105,36 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
throw new CostException(500, "文件上传异常");
|
|
|
}
|
|
|
// 记录文件上传记录
|
|
|
- CostIncomeFile costIncomeFile = costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile, fileType,year,month);
|
|
|
+ CostIncomeFile costIncomeFile = costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile, fileType, year, month);
|
|
|
Long id = costIncomeFile.getId();
|
|
|
- costShareParamGroupList.forEach(i -> {
|
|
|
+ shareParamValues.forEach(i -> {
|
|
|
// 设置文件Id
|
|
|
i.setFileId(id);
|
|
|
+ i.setDataSourceType(1);
|
|
|
});
|
|
|
if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
|
|
|
- this.saveBatch(costShareParamGroupList);
|
|
|
+ this.saveBatch(shareParamValues);
|
|
|
return Result.build(200, "数据导入成功", null);
|
|
|
} else {
|
|
|
return Result.build(200, "数据未成功导入", null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void checkShareParamGroupData(List<List<Object>> list, int year, int month, List<IncomeErrorMessage> incomeErrorMessageList, Map<String, Department> departmentMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Long> responsibilityDepMap, Map<String, CostShareParam> shareParamMap, List<CostShareParamGroup> costShareParamGroupList, List<Object> departmentCodes, List<Object> departmentNames) {
|
|
|
+ private void checkShareParamGroupData(List<List<Object>> list, int year, int month,
|
|
|
+ List<IncomeErrorMessage> incomeErrorMessageList, Map<String, Department> departmentMap,
|
|
|
+ Map<Long, Responsibility> responsibilityMap, Map<Long, Long> responsibilityDepMap,
|
|
|
+ Map<String, CostShareParam> shareParamMap, List<ShareParamValue> shareParamValues,
|
|
|
+ List<Object> departmentCodes, List<Object> departmentNames) {
|
|
|
for (int i = 2; i < list.size(); i++) {
|
|
|
int row = i + 4;
|
|
|
List<Object> data = list.get(i);
|
|
|
// 检验成本分摊参数是否正确
|
|
|
- CostShareParamGroup costShareParamGroupRequest = new CostShareParamGroup();
|
|
|
+ ShareParamValue shareParamValueRequest = new ShareParamValue();
|
|
|
String shareParamCode = data.get(0).toString();
|
|
|
String shareParamName = data.get(1).toString();
|
|
|
CostShareParam costShareParam = shareParamMap.get(shareParamCode + shareParamName);
|
|
|
if (Objects.nonNull(costShareParam)) {
|
|
|
- costShareParamGroupRequest.setShareParamCode(shareParamCode);
|
|
|
- costShareParamGroupRequest.setShareParamName(shareParamName);
|
|
|
+ shareParamValueRequest.setShareParamCode(shareParamCode);
|
|
|
} else {
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
incomeErrorMessage.setTotal(1);
|
|
@@ -132,19 +142,19 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
}
|
|
|
for (int j = 2; j < departmentCodes.size(); j++) {
|
|
|
- int column=j+1;
|
|
|
- if (data.size() > j ) {
|
|
|
- if (Objects.isNull(data.get(j))){
|
|
|
+ int column = j + 1;
|
|
|
+ if (data.size() > j) {
|
|
|
+ if (Objects.isNull(data.get(j))) {
|
|
|
data.set(j, NumberConstant.ZERO);
|
|
|
- }else if (data.get(j).toString().contains("-")||!StringUtils.isNumber(data.get(j).toString())){
|
|
|
+ } else if (data.get(j).toString().contains("-") || !StringUtils.isNumber(data.get(j).toString())) {
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
incomeErrorMessage.setTotal(row);
|
|
|
- incomeErrorMessage.setErrMessage("第"+row+"行 第"+column+"列数据不符合规范");
|
|
|
+ incomeErrorMessage.setErrMessage("第" + row + "行 第" + column + "列数据不符合规范");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
data.set(j, Double.parseDouble(data.get(j).toString()));
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
data.add(NumberConstant.ZERO);
|
|
|
}
|
|
|
}
|
|
@@ -159,7 +169,7 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
}
|
|
|
if (NumberConstant.ONE.equals(zeroStatus)) {
|
|
|
for (int j = 2; j < data.size(); j++) {
|
|
|
- CostShareParamGroup costShareParamGroup = BeanUtil.convertObj(costShareParamGroupRequest, CostShareParamGroup.class);
|
|
|
+ ShareParamValue shareParamValue = BeanUtil.convertObj(shareParamValueRequest, ShareParamValue.class);
|
|
|
// 检验科室信息是否准确
|
|
|
String departmentCode = departmentCodes.get(j).toString();
|
|
|
String departmentName = departmentNames.get(j).toString();
|
|
@@ -171,8 +181,7 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
if (Objects.nonNull(responsibilityId)) {
|
|
|
Responsibility responsibility = responsibilityMap.get(responsibilityId);
|
|
|
if (Objects.nonNull(responsibility)) {
|
|
|
- costShareParamGroup.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
- costShareParamGroup.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ shareParamValue.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
|
|
|
} else {
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
@@ -192,12 +201,12 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
}
|
|
|
- costShareParamGroup.setAmount(BigDecimal.valueOf(Double.parseDouble(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ? "0.00" : data.get(j).toString())));
|
|
|
- costShareParamGroup.setHospId(UserContext.getHospId());
|
|
|
- costShareParamGroup.setCreateTime(System.currentTimeMillis());
|
|
|
- costShareParamGroup.setDateYear(year);
|
|
|
- costShareParamGroup.setDateMonth(month);
|
|
|
- costShareParamGroupList.add(costShareParamGroup);
|
|
|
+ shareParamValue.setValueNum(BigDecimal.valueOf(Double.parseDouble(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ? "0.00" : data.get(j).toString())));
|
|
|
+ shareParamValue.setHospId(UserContext.getHospId());
|
|
|
+ shareParamValue.setCreateTime(System.currentTimeMillis());
|
|
|
+ shareParamValue.setDateYear(year);
|
|
|
+ shareParamValue.setDateMonth(month);
|
|
|
+ shareParamValues.add(shareParamValue);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -205,4 +214,6 @@ public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGr
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|