|
@@ -1,8 +1,6 @@
|
|
|
package com.imed.costaccount.web;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
@@ -317,28 +315,35 @@ public class ExcelController {
|
|
|
|
|
|
ExcelWriter writer = new ExcelWriter(url);
|
|
|
// 样式
|
|
|
+ // 所有科室里面对应存在责任中心对应的科室
|
|
|
+ List<Department> departmentLinkedList = getDepartments(hospId);
|
|
|
+ // 设置科室的代码集合
|
|
|
+ List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
|
|
|
+ List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
|
|
|
Sheet sheet = writer.getSheet();
|
|
|
writer.merge(0, 1, 0, 6, "为了保证成功导入,请勿修改模板格式", false);
|
|
|
writer.passCurrentRow();
|
|
|
writer.passCurrentRow();
|
|
|
writer.merge(2, 2, 0, 6, "医院成本数据批量导入", false);
|
|
|
writer.passCurrentRow();
|
|
|
- // 所有科室里面对应存在责任中心对应的科室
|
|
|
- List<Department> departmentLinkedList = getDepartments(hospId);
|
|
|
- // 设置科室的代码集合
|
|
|
- List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
|
|
|
- List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
|
|
|
+ writer.merge(3,3,2,departmentCodeList.size(),"科室",false);
|
|
|
+ writer.passCurrentRow();
|
|
|
departmentCodeList.add(0, null);
|
|
|
departmentCodeList.add(1, null);
|
|
|
+ departmentCodeList.add(2, null);
|
|
|
+ departmentCodeList.add("-1");
|
|
|
writer.writeRow(departmentCodeList);
|
|
|
- departmentNameList.add(0, "成本项目代码");
|
|
|
- departmentNameList.add(1, "成本项目名称");
|
|
|
+ departmentNameList.add(0, null);
|
|
|
+ departmentNameList.add(1, "成本项目代码");
|
|
|
+ departmentNameList.add(2, "成本项目名称");
|
|
|
+ departmentNameList.add("总计");
|
|
|
writer.writeRow(departmentNameList);
|
|
|
// 设置科室名称的集合
|
|
|
writer.setFreezePane(5);
|
|
|
int accountType = NumberConstant.TWO;
|
|
|
int column = NumberConstant.FIVE;
|
|
|
- getProductByAccountType(hospId, writer, accountType, column);
|
|
|
+ List<Product> productList = getProductByAccountType(hospId, writer, accountType, column);
|
|
|
+ writer.merge(6,productList.size(),0,0,"成本项目",false);
|
|
|
writer.setColumnWidth(0, 15);
|
|
|
writer.setColumnWidth(1, 15);
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
@@ -358,7 +363,7 @@ public class ExcelController {
|
|
|
* @param accountType 会计科目类型 1 收入 2支出(成本)
|
|
|
* @param column 控制第几列
|
|
|
*/
|
|
|
- private void getProductByAccountType(Long hospId, ExcelWriter writer, Integer accountType, Integer column) {
|
|
|
+ private List<Product> getProductByAccountType(Long hospId, ExcelWriter writer, Integer accountType, Integer column) {
|
|
|
// 所有的成本项目
|
|
|
List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
|
|
|
// 所有成本会计对照数据
|
|
@@ -381,9 +386,10 @@ public class ExcelController {
|
|
|
});
|
|
|
// 写入响应第一列 第二列的数据
|
|
|
for (int j = 0; j < products.size(); j++) {
|
|
|
- writer.writeCellValue(0, j + column, productList.get(j).getProductCode());
|
|
|
- writer.writeCellValue(1, j + column, productList.get(j).getProductName());
|
|
|
+ writer.writeCellValue(1, j + column, productList.get(j).getProductCode());
|
|
|
+ writer.writeCellValue(2, j + column, productList.get(j).getProductName());
|
|
|
}
|
|
|
+ return productList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -399,27 +405,33 @@ public class ExcelController {
|
|
|
|
|
|
ExcelWriter writer = new ExcelWriter(url);
|
|
|
// 样式
|
|
|
+ // 所有科室里面对应存在责任中心对应的科室进行显示
|
|
|
+ List<Department> departmentLinkedList = getDepartments(hospId);
|
|
|
+ // 设置科室的代码集合
|
|
|
+ List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
|
|
|
+ List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
|
|
|
+ List<CostShareParam> costShareParamList = costShareParamService.list(new QueryWrapper<CostShareParam>().lambda().eq(CostShareParam::getHospId, hospId));
|
|
|
Sheet sheet = writer.getSheet();
|
|
|
writer.merge(0, 1, 0, 6, "为了保证成功导入,请勿修改模板格式", false);
|
|
|
writer.passCurrentRow();
|
|
|
writer.passCurrentRow();
|
|
|
writer.merge(2, 2, 0, 6, "医院成本分摊参数数据批量导入", false);
|
|
|
writer.passCurrentRow();
|
|
|
- // 所有科室里面对应存在责任中心对应的科室进行显示
|
|
|
- List<Department> departmentLinkedList = getDepartments(hospId);
|
|
|
- // 设置科室的代码集合
|
|
|
- List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
|
|
|
- List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
|
|
|
+ writer.merge(3,3,3,departmentCodeList.size(),"科室",false);
|
|
|
+ writer.passCurrentRow();
|
|
|
+ writer.merge(6,costShareParamList.size(),0,0,"成本分摊参数",false);
|
|
|
departmentCodeList.add(0, null);
|
|
|
departmentCodeList.add(1, null);
|
|
|
+ departmentCodeList.add(2, null);
|
|
|
writer.writeRow(departmentCodeList);
|
|
|
- departmentNameList.add(0, "成本分摊参数代码");
|
|
|
- departmentNameList.add(1, "成本分摊参数名称");
|
|
|
+ departmentNameList.add(0, null);
|
|
|
+ departmentNameList.add(1, "成本分摊参数代码");
|
|
|
+ departmentNameList.add(2, "成本分摊参数名称");
|
|
|
writer.writeRow(departmentNameList);
|
|
|
// 设置科室名称的集合
|
|
|
writer.setFreezePane(5);
|
|
|
// 为第一列和第二列设置成本分摊参数的列表数据
|
|
|
- List<CostShareParam> costShareParamList = costShareParamService.list(new QueryWrapper<CostShareParam>().lambda().eq(CostShareParam::getHospId, hospId));
|
|
|
+
|
|
|
for (int j = 0; j < costShareParamList.size(); j++) {
|
|
|
writer.writeCellValue(0, j + 5, costShareParamList.get(j).getShareParamCode());
|
|
|
writer.writeCellValue(1, j + 5, costShareParamList.get(j).getShareParamName());
|
|
@@ -458,12 +470,11 @@ public class ExcelController {
|
|
|
* @param
|
|
|
*/
|
|
|
@PostMapping("/importDataByFileType")
|
|
|
- @ApiOperation("批量导入指定类型数据信息")
|
|
|
+ @ApiOperation("收入数据导入")
|
|
|
public Result importProductAccount(@RequestParam("file") MultipartFile file ,Integer fileType,String dateTime) {
|
|
|
if (Objects.isNull(file)) {
|
|
|
throw new CostException(500, "请选择文件");
|
|
|
}
|
|
|
-
|
|
|
InputStream in;
|
|
|
// 导入的是收入数据
|
|
|
try {
|
|
@@ -480,34 +491,26 @@ public class ExcelController {
|
|
|
throw new CostException(500, "导入失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// @ApiOperation("excel导入收入数据")
|
|
|
-// @PostMapping("/importDataByIncomeData")
|
|
|
-// public Result importDataByIncomeData(@RequestParam("file") MultipartFile file, Integer year, Integer month) {
|
|
|
-// if (Objects.isNull(year) || Objects.isNull(month)) {
|
|
|
-// DateTime dateTime = DateUtil.lastMonth();
|
|
|
-// year = DateUtil.year(dateTime);
|
|
|
-// month = DateUtil.month(dateTime);
|
|
|
-// }
|
|
|
-// if (Objects.isNull(file)) {
|
|
|
-// throw new CostException(500, "请选择文件");
|
|
|
-// }
|
|
|
-// InputStream in;
|
|
|
-// // 导入的是收入数据
|
|
|
-// try {
|
|
|
-// in = file.getInputStream();
|
|
|
-// ExcelReader reader = ExcelUtil.getReader(in);
|
|
|
-// List<List<Object>> read = reader.read();
|
|
|
-// log.info("最开始:read={}", read);
|
|
|
-// log.info("-------------------------------------------------------------------");
|
|
|
-// User user = UserContext.getCurrentUser();
|
|
|
-// return costIncomeGroupService.importDataByIncomeData(read, user, file, year, month);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// ;
|
|
|
-// throw new CostException(500, "导入失败");
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
+ @PostMapping("/importCostingGroup")
|
|
|
+ @ApiOperation("成本数据导入")
|
|
|
+ public Result importCostingGroup(@RequestParam("file") MultipartFile file ,Integer fileType,String dateTime) {
|
|
|
+ if (Objects.isNull(file)) {
|
|
|
+ throw new CostException(500, "请选择文件");
|
|
|
+ }
|
|
|
+ InputStream in;
|
|
|
+ // 导入的是收入数据
|
|
|
+ try {
|
|
|
+ in = file.getInputStream();
|
|
|
+ ExcelReader reader = ExcelUtil.getReader(in);
|
|
|
+ List<List<Object>> read = reader.read();
|
|
|
+ log.info("最开始:read={}", read);
|
|
|
+ log.info("-------------------------------------------------------------------");
|
|
|
+ User user = UserContext.getCurrentUser();
|
|
|
+ return costIncomeGroupService.importIncomeGroup(read, user, file, dateTime,fileType);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ ;
|
|
|
+ throw new CostException(500, "导入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|