|
@@ -1,6 +1,7 @@
|
|
|
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;
|
|
@@ -51,13 +52,16 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
|
|
|
private final AccountingProductService accountingProductService;
|
|
|
|
|
|
- public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService) {
|
|
|
+ private final CostIncomeFileService costIncomeFileService;
|
|
|
+
|
|
|
+ public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService) {
|
|
|
this.departmentService = departmentService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.productService = productService;
|
|
|
this.accountingService = accountingService;
|
|
|
this.responsibilityDepartmentService = responsibilityDepartmentService;
|
|
|
this.accountingProductService = accountingProductService;
|
|
|
+ this.costIncomeFileService = costIncomeFileService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -117,13 +121,14 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
* 批量导入收入数据
|
|
|
*
|
|
|
* @param list 输入的文件
|
|
|
- * @param hospId 医院Id
|
|
|
+ * @param user 用户
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public Result importIncomeGroup(List<List<Object>> list, Long hospId, MultipartFile file,Integer year,Integer month) {
|
|
|
+ public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file,Integer year,Integer month) {
|
|
|
+ Long hospId = user.getHospId();
|
|
|
// 移除前几行的抬头内容 list的大小对应的就是行数的大小
|
|
|
for (int i = list.size() - 1; i >= 0; i--) {
|
|
|
if (i == NumberConstant.ZERO || i == NumberConstant.ONE || i == NumberConstant.TWO || i == NumberConstant.THREE) {
|
|
@@ -158,11 +163,28 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
if (StrUtil.isBlank(uploadFile)){
|
|
|
throw new CostException(500,"文件上传异常");
|
|
|
}
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
|
|
|
- // 才将数据保存到收入归集里面
|
|
|
+ // 记录文件上传记录
|
|
|
+ CostIncomeFile costIncomeFile = new CostIncomeFile();
|
|
|
+ costIncomeFile.setFileType(file.getContentType());
|
|
|
+ costIncomeFile.setFileName(file.getOriginalFilename());
|
|
|
+ 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);
|
|
|
+ Long id = costIncomeFile.getId();
|
|
|
+ costIncomeGroupArrayList.forEach(i->{
|
|
|
+ // 设置文件Id
|
|
|
+ i.setFileId(id);
|
|
|
+ });
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|