|
@@ -13,9 +13,12 @@ import com.imed.costaccount.mapper.CostIncomeGroupMapper;
|
|
|
import com.imed.costaccount.model.*;
|
|
|
import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
|
|
|
import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
|
|
|
+import com.imed.costaccount.model.vo.IncomeErrorMessage;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -33,12 +36,17 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
|
|
|
private final AccountingService accountingService;
|
|
|
|
|
|
+ private final ResponsibilityDepartmentService responsibilityDepartmentService;
|
|
|
|
|
|
- public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService) {
|
|
|
+ private final AccountingProductService accountingProductService;
|
|
|
+
|
|
|
+ public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService) {
|
|
|
this.departmentService = departmentService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.productService = productService;
|
|
|
this.accountingService = accountingService;
|
|
|
+ this.responsibilityDepartmentService = responsibilityDepartmentService;
|
|
|
+ this.accountingProductService = accountingProductService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -98,8 +106,9 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
public Result importIncomeGroup(List<List<Object>> list, Long hospId) {
|
|
|
- // 移除前几行的抬头内容
|
|
|
+ // 移除前几行的抬头内容 list的大小对应的就是行数的大小
|
|
|
for (int i = list.size() - 1; i >= 0; i--) {
|
|
|
if (i == NumberConstant.ZERO || i == NumberConstant.ONE || i == NumberConstant.TWO || i == NumberConstant.THREE) {
|
|
|
list.remove(list.get(i));
|
|
@@ -107,15 +116,66 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
}
|
|
|
log.info("读取的数据为:{}", list);
|
|
|
List<CostIncomeGroup> costIncomeGroupList = new ArrayList<>();
|
|
|
- List<String> errRowNums = new ArrayList<>();
|
|
|
+ List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
|
|
|
+ //获取所有的科室 成本项目 责任中心 会计科目
|
|
|
+ Map<String, Department> departmentMap = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
|
|
|
+ Map<String,Product> productMap= productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
|
|
|
+ Map<Long, Responsibility> responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId,synOe->synOe));
|
|
|
+ Map<Long, Accounting> accountingMap = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
|
|
|
+
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
+ // 用来检验数据合理性的循环
|
|
|
+ IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
List<Object> data = list.get(i);
|
|
|
log.info("用户输入的数据是{}",data);
|
|
|
- CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
|
|
|
- costIncomeGroup.setCreateTime(System.currentTimeMillis());
|
|
|
- costIncomeGroup.setHospId(hospId);
|
|
|
+ Object money = data.get(data.size() - 1);
|
|
|
+ if (!Objects.isNull(money) && !NumberConstant.ZERO.equals(Integer.parseInt(money.toString()))){
|
|
|
+ // 要求这一行的数据必须全部填写
|
|
|
+ for (int j=0;j<data.size();j++){
|
|
|
+ if (Objects.isNull(data.get(j))){
|
|
|
+ incomeErrorMessage.setTotal(i);
|
|
|
+ int row=i+1;
|
|
|
+ int column=j+1;
|
|
|
+ incomeErrorMessage.setErrMessage("第{"+row+"}行第{"+column+"}列数据为空");
|
|
|
+ incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // TODO 暂时不走循环 直接获取数据的处理
|
|
|
+ // 成本项目的代码和名称
|
|
|
+ String productCode = data.get(0).toString();
|
|
|
+ String productName = data.get(1).toString();
|
|
|
+ // 开单科室 执行科室的代码和名称
|
|
|
+ String openDepartmentName = data.get(2).toString();
|
|
|
+ String openDepartmentCode = data.get(3).toString();
|
|
|
+ String startDepartmentName = data.get(4).toString();
|
|
|
+ String startDepartmentCode = data.get(5).toString();
|
|
|
+ // 检验数据是否存在
|
|
|
+ Product product = productMap.get(productCode + productName);
|
|
|
+ Department department = departmentMap.get(openDepartmentCode + openDepartmentName);
|
|
|
+ Department department1 = departmentMap.get(startDepartmentCode + startDepartmentName);
|
|
|
+ if (Objects.isNull(product)){
|
|
|
+ incomeErrorMessage.setTotal(i);
|
|
|
+ incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"成本项目不存在");
|
|
|
+ incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
+ }else {
|
|
|
+ // 检验对应的会计科目是否存在
|
|
|
+ Long id = product.getId();
|
|
|
|
|
|
+ }
|
|
|
+ if (Objects.isNull(department)){
|
|
|
+ incomeErrorMessage.setTotal(i);
|
|
|
+ incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"开单科室不存在");
|
|
|
+ incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
+ }
|
|
|
+ if (Objects.isNull(department1)){
|
|
|
+ incomeErrorMessage.setTotal(i);
|
|
|
+ incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"执行科室不存在");
|
|
|
+ incomeErrorMessageList.add(incomeErrorMessage);
|
|
|
+ }
|
|
|
+ // 检验科室对应的责任中心是否存在
|
|
|
+ // 检验成本项目对应的会计科目是否存在
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
return Result.ok();
|
|
|
}
|