|
@@ -1,5 +1,6 @@
|
|
|
package com.imed.costaccount.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -7,15 +8,17 @@ import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.DateUtils;
|
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
|
import com.imed.costaccount.mapper.CostIncomeGroupMapper;
|
|
|
-import com.imed.costaccount.model.CostIncomeGroup;
|
|
|
-import com.imed.costaccount.model.Department;
|
|
|
-import com.imed.costaccount.model.Responsibility;
|
|
|
+import com.imed.costaccount.model.*;
|
|
|
+import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
|
|
|
import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Service("costIncomeGroupService")
|
|
@@ -29,11 +32,14 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
|
|
|
private final AccountingService accountingService;
|
|
|
|
|
|
- public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService) {
|
|
|
+ private final CostIncomeGroupMapper costIncomeGroupMapper;
|
|
|
+
|
|
|
+ public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, CostIncomeGroupMapper costIncomeGroupMapper) {
|
|
|
this.departmentService = departmentService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.productService = productService;
|
|
|
this.accountingService = accountingService;
|
|
|
+ this.costIncomeGroupMapper = costIncomeGroupMapper;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -56,17 +62,66 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
wrapper.eq("hosp_id",hospId);
|
|
|
wrapper.eq("date_year",year);
|
|
|
wrapper.eq("date_month",month);
|
|
|
- wrapper.like(!StringUtils.isEmpty(responsibilityCode),"open_responsibility_code",responsibilityCode)
|
|
|
- .or()
|
|
|
- .like(!StringUtils.isEmpty(responsibilityCode),"start_responsibility_code",responsibilityCode);
|
|
|
- wrapper.like(!StringUtils.isEmpty(accountCode),"account_code",accountCode);
|
|
|
Page<CostIncomeGroup> pages = this.page(costIncomeGroupPage, wrapper);
|
|
|
List<CostIncomeGroup> records = pages.getRecords();
|
|
|
List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList = BeanUtil.convertList(records, CostIncomeGroupBeforeVO.class);
|
|
|
- // 查询所有的责任中心 科室 会计科目 成本项目的数据
|
|
|
+ // 查询所有的责任中心 科室 会计科目 成本项目的数据 处理名字
|
|
|
+ setCodeName(hospId, costIncomeGroupBeforeVOList);
|
|
|
+ // 进行金额合并
|
|
|
+ List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS =costIncomeGroupMapper.countMoney(costIncomeGroupBeforeVOList);
|
|
|
+ // TODO 对,的金额进行合并
|
|
|
+ costIncomeGroupAllAmountVoS.forEach(i->{
|
|
|
+ String allMoney = i.getAllMoney();
|
|
|
+ if (allMoney.contains(StrUtil.COMMA)){
|
|
|
+ // 存在,在进行求和
|
|
|
+ Long sum;
|
|
|
+ List<Long> list = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<CostIncomeGroupAllAmountVO> amountVOS = costIncomeGroupAllAmountVoS.stream().map(i -> {
|
|
|
+ if (!StringUtils.isEmpty(responsibilityCode)) {
|
|
|
+ boolean equalsBoolean = i.getOpenResponsibilityCode().equals(responsibilityCode);
|
|
|
+ if (!equalsBoolean) {
|
|
|
+ i.getStartResponsibilityCode().equals(responsibilityCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(accountCode)) {
|
|
|
+ i.getAccountCode().equals(accountCode);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ PageUtils pageUtils = new PageUtils(pages);
|
|
|
+ pageUtils.setList(amountVOS);
|
|
|
+ return pageUtils;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置相关名称
|
|
|
+ * @param hospId
|
|
|
+ * @param costIncomeGroupBeforeVOList
|
|
|
+ */
|
|
|
+ private void setCodeName(Long hospId, List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList) {
|
|
|
List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
|
|
|
+ Map<String, List<Responsibility>> responsibilityMap = responsibilityList.stream().collect(Collectors.groupingBy(Responsibility::getResponsibilityCode));
|
|
|
List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId));
|
|
|
-
|
|
|
- return null;
|
|
|
+ Map<String, List<Department>> departmentMap = departmentList.stream().collect(Collectors.groupingBy(Department::getDepartmentCode));
|
|
|
+ List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
|
|
|
+ Map<String, List<Product>> productMap = productList.stream().collect(Collectors.groupingBy(Product::getProductCode));
|
|
|
+ List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
|
|
|
+ Map<String, List<Accounting>> accountMap = accountingList.stream().collect(Collectors.groupingBy(Accounting::getAccountingCode));
|
|
|
+ costIncomeGroupBeforeVOList.forEach(i->{
|
|
|
+ // 以为这里的数据导入的 在导入的时候进行数据校验
|
|
|
+ // 设置开单科室名称 执行科室名称 开单责任中心名称 执行责任中心名称 成本项目的名称 会计科目名称
|
|
|
+ i.setOpenDepartmentCodeName("["+i.getOpenDepartmentCode()+"]"+departmentMap.get(i.getOpenDepartmentCode()).get(0).getDepartmentName());
|
|
|
+ i.setOpenResponsibilityCodeName("["+i.getOpenResponsibilityCode()+"]"+responsibilityMap.get(i.getOpenResponsibilityCode()).get(0).getResponsibilityName());
|
|
|
+ i.setStartDepartmentCodeName("["+i.getStartDepartmentCode()+"]"+departmentMap.get(i.getStartDepartmentCode()).get(0).getDepartmentName());
|
|
|
+ i.setStartResponsibilityCodeName("["+i.getStartResponsibilityCode()+"]"+responsibilityMap.get(i.getStartResponsibilityCode()).get(0).getResponsibilityName());
|
|
|
+ i.setProductCodeName("["+i.getProductCode()+"]"+productMap.get(i.getProductCode()).get(0).getProductName());
|
|
|
+ i.setAccountCodeName("["+i.getAccountCode()+"]"+accountMap.get(i.getAccountCode()).get(0).getAccountingName());
|
|
|
+ });
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 根据年月查询所有的数据
|
|
|
+ */
|
|
|
}
|