|
@@ -55,7 +55,7 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public Result importCostingGroup(List<List<Object>> list, User user, MultipartFile file, String dateTime, Integer fileType) {
|
|
|
// 先检验当前年月是否存在数据
|
|
|
int year = 0;
|
|
@@ -114,7 +114,7 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
|
|
|
return Result.build(500, "数据未成功导入", null);
|
|
|
}
|
|
|
// 检验收入数据
|
|
|
- checkCostData(list, incomeErrorMessageList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap, costCostingGroupArrayList,year,month);
|
|
|
+ checkCostData(list, incomeErrorMessageList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap, costCostingGroupArrayList, year, month);
|
|
|
// 文件上传
|
|
|
String uploadFile = costIncomeGroupService.uploadFile(file, UserContext.getCurrentUser());
|
|
|
// 上传记录保存
|
|
@@ -130,14 +130,15 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
|
|
|
});
|
|
|
if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
|
|
|
this.saveBatch(costCostingGroupArrayList);
|
|
|
- return Result.build(200,"数据导入成功",null);
|
|
|
- }else {
|
|
|
+ return Result.build(200, "数据导入成功", null);
|
|
|
+ } else {
|
|
|
return Result.build(500, "数据未成功导入", null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检验成本数据
|
|
|
+ *
|
|
|
* @param list
|
|
|
* @param incomeErrorMessageList
|
|
|
* @param departmentMap
|
|
@@ -148,12 +149,24 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
|
|
|
* @param accountProMap
|
|
|
* @param costCostingGroupArrayList
|
|
|
*/
|
|
|
- private void checkCostData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, List<CostCostingGroup> costCostingGroupArrayList,Integer year,Integer month) {
|
|
|
+ private void checkCostData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, List<CostCostingGroup> costCostingGroupArrayList, Integer year, Integer month) {
|
|
|
List<Object> departmentCodes = list.get(0);
|
|
|
List<Object> departmentNames = list.get(1);
|
|
|
//检验数据是否准确
|
|
|
for (int i = 2; i < list.size(); i++) {
|
|
|
List<Object> data = list.get(i);
|
|
|
+ for (int j = 2; j < departmentCodes.size(); j++) {
|
|
|
+ if (data.size() > j ) {
|
|
|
+ if (Objects.isNull(data.get(j))){
|
|
|
+ data.set(j, NumberConstant.ZERO);
|
|
|
+ }else {
|
|
|
+ data.set(j, Integer.parseInt(data.get(j).toString()));
|
|
|
+ }
|
|
|
+ }else if (data.size()<=departmentCodes.size()){
|
|
|
+ data.add(NumberConstant.ZERO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 检验成本项目是否正确
|
|
|
CostCostingGroup costCostingGroupRequest = new CostCostingGroup();
|
|
|
String productCode = data.get(0).toString();
|
|
@@ -187,49 +200,77 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
|
|
|
incomeErrorMessage.setErrMessage("成本代码" + productCode + " 成本名称" + productName + "不存在");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
}
|
|
|
+ // 0表示全为0 1表示不全为0
|
|
|
+ Integer emptyStatus = 0;
|
|
|
for (int j = 2; j < data.size()-1 ; j++) {
|
|
|
- CostCostingGroup costCostingGroup=costCostingGroupRequest;
|
|
|
- // 检验科室信息是否准确
|
|
|
- String departmentCode = departmentCodes.get(j).toString();
|
|
|
- String departmentName = departmentNames.get(j).toString();
|
|
|
- Department department = departmentMap.get(departmentCode + departmentName);
|
|
|
- if (Objects.nonNull(department)) {
|
|
|
- // 检测责任中心是否存在
|
|
|
- Long id = department.getId();
|
|
|
- Long responsibilityId = responsibilityDepMap.get(id);
|
|
|
- if (Objects.nonNull(responsibilityId)) {
|
|
|
- Responsibility responsibility = responsibilityMap.get(responsibilityId);
|
|
|
- if (Objects.nonNull(responsibility)) {
|
|
|
- costCostingGroup.setDepartmentCode(departmentCode);
|
|
|
- costCostingGroup.setDepartmentName(departmentName);
|
|
|
- costCostingGroup.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
- costCostingGroup.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ int parseInt = Integer.parseInt(data.get(j).toString());
|
|
|
+ if (!NumberConstant.ZERO.equals(parseInt)) {
|
|
|
+ emptyStatus = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer combined = Integer.parseInt(data.get(data.size() - 1).toString());
|
|
|
+ if (NumberConstant.ZERO.equals(emptyStatus) && NumberConstant.ZERO.equals(combined)) {
|
|
|
+ // 全为0
|
|
|
+ continue;
|
|
|
+ } else if (!NumberConstant.ZERO.equals(combined) && NumberConstant.ZERO.equals(emptyStatus)) {
|
|
|
+ // 这条数据是保存到其他责任中心的
|
|
|
+ CostCostingGroup costCostingGroup = costCostingGroupRequest;
|
|
|
+ // TODO 设置其他责任中心
|
|
|
+ costCostingGroup.setResponsibilityCode("其他责任中心的Code");
|
|
|
+ costCostingGroup.setResponsibilityName("其他责任中心的Name");
|
|
|
+ costCostingGroup.setAmount(BigDecimal.valueOf(Double.parseDouble(combined.toString())));
|
|
|
+ costCostingGroup.setHospId(UserContext.getHospId());
|
|
|
+ costCostingGroup.setCreateTime(System.currentTimeMillis());
|
|
|
+ costCostingGroup.setDateYear(year);
|
|
|
+ costCostingGroup.setDateMonth(month);
|
|
|
+ costCostingGroupArrayList.add(costCostingGroup);
|
|
|
+ } else {
|
|
|
+ for (int j = 2; j < data.size() - 1; j++) {
|
|
|
+ CostCostingGroup costCostingGroup = costCostingGroupRequest;
|
|
|
+ // 检验科室信息是否准确
|
|
|
+ String departmentCode = departmentCodes.get(j).toString();
|
|
|
+ String departmentName = departmentNames.get(j).toString();
|
|
|
+ Department department = departmentMap.get(departmentCode + departmentName);
|
|
|
+ if (Objects.nonNull(department)) {
|
|
|
+ // 检测责任中心是否存在
|
|
|
+ Long id = department.getId();
|
|
|
+ Long responsibilityId = responsibilityDepMap.get(id);
|
|
|
+ if (Objects.nonNull(responsibilityId)) {
|
|
|
+ Responsibility responsibility = responsibilityMap.get(responsibilityId);
|
|
|
+ if (Objects.nonNull(responsibility)) {
|
|
|
+ costCostingGroup.setDepartmentCode(departmentCode);
|
|
|
+ costCostingGroup.setDepartmentName(departmentName);
|
|
|
+ costCostingGroup.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ costCostingGroup.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
|
|
|
+ } else {
|
|
|
+ IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
+ incomeErrorMessage.setTotal(j);
|
|
|
+ incomeErrorMessage.setErrMessage("第" + j + "列科室信息对应的责任中心不存在");
|
|
|
+ incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
+ }
|
|
|
} else {
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
incomeErrorMessage.setTotal(j);
|
|
|
- incomeErrorMessage.setErrMessage("第" + j + "列科室信息对应的责任中心不存在");
|
|
|
+ incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在对应的责任中心");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
}
|
|
|
} else {
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
incomeErrorMessage.setTotal(j);
|
|
|
- incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在对应的责任中心");
|
|
|
+ incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
|
|
|
incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
}
|
|
|
- } else {
|
|
|
- IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
- incomeErrorMessage.setTotal(j);
|
|
|
- incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
|
|
|
- incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
+ costCostingGroup.setAmount(BigDecimal.valueOf(Double.parseDouble((Objects.isNull(data.get(j)) || "0".equals(data.get(j).toString())) ? "0.00" : data.get(j).toString())));
|
|
|
+ costCostingGroup.setHospId(UserContext.getHospId());
|
|
|
+ costCostingGroup.setCreateTime(System.currentTimeMillis());
|
|
|
+ costCostingGroup.setDateYear(year);
|
|
|
+ costCostingGroup.setDateMonth(month);
|
|
|
+ costCostingGroupArrayList.add(costCostingGroup);
|
|
|
}
|
|
|
- costCostingGroup.setAmount(BigDecimal.valueOf(Double.parseDouble(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ?"0.00":data.get(j).toString())));
|
|
|
- costCostingGroup.setHospId(UserContext.getHospId());
|
|
|
- costCostingGroup.setCreateTime(System.currentTimeMillis());
|
|
|
- costCostingGroup.setDateYear(year);
|
|
|
- costCostingGroup.setDateMonth(month);
|
|
|
- costCostingGroupArrayList.add(costCostingGroup);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|