|
@@ -1,7 +1,6 @@
|
|
|
package com.imed.costaccount.service.impl;
|
|
|
|
|
|
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;
|
|
@@ -100,11 +99,10 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
// 进行金额合并
|
|
|
List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS = baseMapper.countMoney(costIncomeGroupBeforeVOList);
|
|
|
// 对,的金额进行合并
|
|
|
- AtomicReference<BigDecimal> totalAmount= null;
|
|
|
+ AtomicReference<BigDecimal> totalAmount = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
costIncomeGroupAllAmountVoS.forEach(i -> {
|
|
|
String allMoney = i.getAllMoney();
|
|
|
-
|
|
|
- if (allMoney.contains(StrUtil.COMMA)) {
|
|
|
+ if (StrUtil.isNotBlank(allMoney) && allMoney.contains(StrUtil.COMMA)) {
|
|
|
// 存在,在进行求和
|
|
|
long sum;
|
|
|
List<Long> list = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
|
|
@@ -112,10 +110,11 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
i.setAmount(BigDecimal.valueOf(sum));
|
|
|
}
|
|
|
//TODO 统计总金额
|
|
|
-// totalAmount.updateAndGet(v -> v + i.getAmount());
|
|
|
+ totalAmount.updateAndGet(v -> v.add(i.getAmount()));
|
|
|
});
|
|
|
PageUtils pageUtils = new PageUtils(pages);
|
|
|
pageUtils.setList(costIncomeGroupAllAmountVoS);
|
|
|
+ pageUtils.setTotalAmount(totalAmount.get());
|
|
|
return pageUtils;
|
|
|
}
|
|
|
|
|
@@ -132,27 +131,23 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file,Integer year,Integer month) {
|
|
|
Long hospId = user.getHospId();
|
|
|
// 移除前几行的抬头内容 list的大小对应的就是行数的大小
|
|
|
- this.removeTitle(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));
|
|
|
+ }
|
|
|
+ }
|
|
|
log.info("读取的数据为:{}", list);
|
|
|
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));
|
|
|
- List<ResponsibilityDepartment> responsibilityDepartmentList = responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
|
|
|
- .eq(ResponsibilityDepartment::getHospId, hospId));
|
|
|
- if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
|
|
|
- throw new CostException(500, "没有科室责任中心对照数据");
|
|
|
- }
|
|
|
- List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
|
|
|
- if (CollectionUtils.isEmpty(accountingProductList)) {
|
|
|
- throw new CostException(500, "没有成本会计对照数据");
|
|
|
- }
|
|
|
- Map<Long, Long> responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
|
|
|
- Map<Long, Long> accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
|
|
|
+ GetCheckData getCheckData = new GetCheckData(hospId).invoke();
|
|
|
+ Map<String, Department> departmentMap = getCheckData.getDepartmentMap();
|
|
|
+ Map<String, Product> productMap = getCheckData.getProductMap();
|
|
|
+ Map<Long, Responsibility> responsibilityMap = getCheckData.getResponsibilityMap();
|
|
|
+ Map<Long, Accounting> accountingMap = getCheckData.getAccountingMap();
|
|
|
+ Map<Long, Long> responsibilityDepMap = getCheckData.getResponsibilityDepMap();
|
|
|
+ Map<Long, Long> accountProMap = getCheckData.getAccountProMap();
|
|
|
List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
|
|
|
- // 检验数据 TODO 缺少文件Id
|
|
|
+ // 检验数据
|
|
|
checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap,hospId,year,month);
|
|
|
|
|
|
// 文件上传
|
|
@@ -162,23 +157,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
throw new CostException(500,"文件上传异常");
|
|
|
}
|
|
|
// 记录文件上传记录
|
|
|
- CostIncomeFile costIncomeFile = new CostIncomeFile();
|
|
|
- costIncomeFile.setFileType(file.getContentType());
|
|
|
- String substring = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf("."))+System.currentTimeMillis()+".xsl";
|
|
|
- costIncomeFile.setFileName(substring);
|
|
|
- costIncomeFile.setFileUrl(uploadFile);
|
|
|
- costIncomeFile.setTotalAmount(list.size());
|
|
|
- if (!CollectionUtils.isEmpty(incomeErrorMessageList)) {
|
|
|
- costIncomeFile.setSuccessAmount(NumberConstant.ZERO);
|
|
|
- costIncomeFile.setErrorList(JSON.toJSONString(incomeErrorMessageList));
|
|
|
- }else {
|
|
|
- costIncomeFile.setSuccessAmount(list.size());
|
|
|
- }
|
|
|
- costIncomeFile.setHospId(hospId);
|
|
|
- costIncomeFile.setUserName(user.getName());
|
|
|
- costIncomeFile.setUserId(user.getId());
|
|
|
- costIncomeFile.setCreateTime(System.currentTimeMillis());
|
|
|
- costIncomeFileService.save(costIncomeFile);
|
|
|
+ CostIncomeFile costIncomeFile =costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile);
|
|
|
Long id = costIncomeFile.getId();
|
|
|
costIncomeGroupArrayList.forEach(i->{
|
|
|
// 设置文件Id
|
|
@@ -190,14 +169,22 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
- private void removeTitle(List<List<Object>> 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));
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 导入收入数据
|
|
|
+ *
|
|
|
+ * @param read 读取到的初始数据
|
|
|
+ * @param user 当前登录用户
|
|
|
+ * @param file 导入的文件
|
|
|
+ * @param year 年
|
|
|
+ * @param month 月
|
|
|
+ * @return {@link Result}
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result importDataByIncomeData(List<List<Object>> read, User user, MultipartFile file, Integer year, Integer month) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 检验数据
|
|
|
* @param list 表单数据
|
|
@@ -397,24 +384,4 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 导入收入数据
|
|
|
- *
|
|
|
- * @param read 读取到的初始数据
|
|
|
- * @param user 当前登录用户
|
|
|
- * @param file 导入的文件
|
|
|
- * @param year 年
|
|
|
- * @param month 月
|
|
|
- * @return {@link Result}
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public Result importDataByIncomeData(List<List<Object>> read, User user, MultipartFile file, Integer year, Integer month) {
|
|
|
- // todo 文件上传
|
|
|
-
|
|
|
- // 去掉头部的
|
|
|
- this.removeTitle(read);
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
}
|