CostIncomeGroupServiceImpl.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. package com.imed.costaccount.service.impl;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.imed.costaccount.common.exception.CostException;
  7. import com.imed.costaccount.common.util.*;
  8. import com.imed.costaccount.constants.NumberConstant;
  9. import com.imed.costaccount.enums.DateStyleEnum;
  10. import com.imed.costaccount.enums.ErrorCodeEnum;
  11. import com.imed.costaccount.mapper.CostIncomeGroupMapper;
  12. import com.imed.costaccount.model.*;
  13. import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
  14. import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
  15. import com.imed.costaccount.model.vo.IncomeErrorMessage;
  16. import com.imed.costaccount.service.*;
  17. import lombok.extern.slf4j.Slf4j;
  18. import org.jetbrains.annotations.NotNull;
  19. import org.springframework.beans.factory.annotation.Value;
  20. import org.springframework.stereotype.Service;
  21. import org.springframework.transaction.annotation.Propagation;
  22. import org.springframework.transaction.annotation.Transactional;
  23. import org.springframework.util.CollectionUtils;
  24. import org.springframework.web.multipart.MultipartFile;
  25. import java.io.File;
  26. import java.io.IOException;
  27. import java.math.BigDecimal;
  28. import java.util.*;
  29. import java.util.concurrent.atomic.AtomicReference;
  30. import java.util.stream.Collectors;
  31. @Slf4j
  32. @Service("costIncomeGroupService")
  33. public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMapper, CostIncomeGroup> implements CostIncomeGroupService {
  34. @Value("${file.serverPath}")
  35. private String fileTempPath;
  36. @Value("${file.serverUrl}")
  37. private String FILE_PATH;
  38. private final DepartmentService departmentService;
  39. private final ResponsibilityService responsibilityService;
  40. private final ProductService productService;
  41. private final AccountingService accountingService;
  42. private final ResponsibilityDepartmentService responsibilityDepartmentService;
  43. private final AccountingProductService accountingProductService;
  44. private final CostIncomeFileService costIncomeFileService;
  45. public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService) {
  46. this.departmentService = departmentService;
  47. this.responsibilityService = responsibilityService;
  48. this.productService = productService;
  49. this.accountingService = accountingService;
  50. this.responsibilityDepartmentService = responsibilityDepartmentService;
  51. this.accountingProductService = accountingProductService;
  52. this.costIncomeFileService = costIncomeFileService;
  53. }
  54. /**
  55. * 分页查询收入归集前的数据
  56. *
  57. * @param current 当前页
  58. * @param pageSize 当前页大小
  59. * @param dateTime 年月
  60. * @param responsibilityCode 责任中心代码
  61. * @param accountCode 会计科目的Code
  62. * @param hospId 医院Id
  63. * @return
  64. */
  65. @Override
  66. public PageUtils queryList(Integer current, Integer pageSize, String dateTime, String responsibilityCode, String accountCode, Long hospId) {
  67. int year = 0;
  68. int month = 0;
  69. if (StrUtil.isNotBlank(dateTime)) {
  70. year = DateUtils.getYear(dateTime);
  71. month = DateUtils.getMonth(dateTime);
  72. }
  73. Page<CostIncomeGroup> costIncomeGroupPage = new Page<>(current, pageSize);
  74. Page<CostIncomeGroup> pages = this.page(costIncomeGroupPage, new QueryWrapper<CostIncomeGroup>().lambda()
  75. .eq(Objects.nonNull(hospId), CostIncomeGroup::getHospId, hospId)
  76. .eq(!NumberConstant.ZERO.equals(year), CostIncomeGroup::getDateYear, year)
  77. .eq(!NumberConstant.ONE.equals(month), CostIncomeGroup::getDateMonth, month)
  78. .and(StrUtil.isNotBlank(responsibilityCode), i -> i.like(CostIncomeGroup::getOpenResponsibilityCode, responsibilityCode)
  79. .or().like(CostIncomeGroup::getStartResponsibilityCode, responsibilityCode))
  80. .like(StrUtil.isNotBlank(accountCode), CostIncomeGroup::getAccountCode, accountCode));
  81. List<CostIncomeGroup> records = pages.getRecords();
  82. List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList = BeanUtil.convertList(records, CostIncomeGroupBeforeVO.class);
  83. // 查询所有的责任中心 科室 会计科目 成本项目的数据 处理名字
  84. // TODO 修改直接获取名字
  85. setCodeName(hospId, costIncomeGroupBeforeVOList);
  86. // 进行金额合并
  87. List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS = baseMapper.countMoney(costIncomeGroupBeforeVOList);
  88. // 对,的金额进行合并
  89. AtomicReference<BigDecimal> totalAmount = new AtomicReference<>(new BigDecimal("0.0000"));
  90. costIncomeGroupAllAmountVoS.forEach(i -> {
  91. String allMoney = i.getAllMoney();
  92. if (StrUtil.isNotBlank(allMoney) && allMoney.contains(StrUtil.COMMA)) {
  93. // 存在,在进行求和
  94. long sum;
  95. List<Long> list = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
  96. sum = list.stream().mapToLong(m -> m).sum();
  97. i.setAmount(BigDecimal.valueOf(sum));
  98. }
  99. //TODO 统计总金额
  100. totalAmount.updateAndGet(v -> v.add(i.getAmount()));
  101. });
  102. PageUtils pageUtils = new PageUtils(pages);
  103. pageUtils.setList(costIncomeGroupAllAmountVoS);
  104. pageUtils.setTotalAmount(totalAmount.get());
  105. return pageUtils;
  106. }
  107. /**
  108. * 批量导入收入数据
  109. *
  110. * @param list 输入的文件
  111. * @param user 用户
  112. * @param file
  113. * @return
  114. */
  115. @Override
  116. @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  117. public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file,Integer year,Integer month) {
  118. // 先检验当前年月是否存在数据
  119. Long hospId = user.getHospId();
  120. List<CostIncomeGroup> groups = this.list(new QueryWrapper<CostIncomeGroup>().lambda().eq(CostIncomeGroup::getHospId, hospId)
  121. .eq(CostIncomeGroup::getDateYear, year).eq(CostIncomeGroup::getDateMonth, month));
  122. if (!CollectionUtils.isEmpty(groups)){
  123. throw new CostException(500,year+"年"+month+"月数据已存在");
  124. }
  125. // 移除前几行的抬头内容 list的大小对应的就是行数的大小
  126. for (int i = list.size() - 1; i >= 0; i--) {
  127. if (i == NumberConstant.ZERO || i == NumberConstant.ONE || i == NumberConstant.TWO || i == NumberConstant.THREE) {
  128. list.remove(list.get(i));
  129. }
  130. }
  131. log.info("读取的数据为:{}", list);
  132. List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
  133. //获取所有的科室 成本项目 责任中心 会计科目
  134. //
  135. Map<String, Department> departmentMap = getDepartmentByCodeNameMap(hospId);
  136. Map<String, Product> productMap = getProductByCodeNameMap(hospId);
  137. Map<Long, Responsibility> responsibilityMap = getLongResponsibilityMap(hospId);
  138. Map<Long, Accounting> accountingMap = getLongAccountingMap(hospId);
  139. List<ResponsibilityDepartment> responsibilityDepartmentList = getResponsibilityDepartments(hospId);
  140. if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
  141. throw new CostException(500, "没有科室责任中心对照数据");
  142. }
  143. List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
  144. if (CollectionUtils.isEmpty(accountingProductList)) {
  145. throw new CostException(500, "没有成本会计对照数据");
  146. }
  147. Map<Long, Long> responsibilityDepMap = getDepartmentIdResponsibilityIdMap(responsibilityDepartmentList);
  148. Map<Long, Long> accountProMap = getProductIdAccountIdMap(accountingProductList);
  149. List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
  150. // 检验数据
  151. checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap,hospId,year,month);
  152. // 文件上传
  153. String uploadFile = uploadFile(file, UserContext.getCurrentUser());
  154. // 上传记录保存
  155. if (StrUtil.isBlank(uploadFile)){
  156. throw new CostException(500,"文件上传异常");
  157. }
  158. // 记录文件上传记录
  159. CostIncomeFile costIncomeFile =costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile);
  160. Long id = costIncomeFile.getId();
  161. costIncomeGroupArrayList.forEach(i->{
  162. // 设置文件Id
  163. i.setFileId(id);
  164. });
  165. if (CollectionUtils.isEmpty(incomeErrorMessageList)){
  166. this.saveBatch(costIncomeGroupArrayList);
  167. }
  168. return Result.ok();
  169. }
  170. /**
  171. * 返回成本会计对照数据 Key 成本项目Id Value 会计科目Id
  172. * @param accountingProductList
  173. * @return
  174. */
  175. @NotNull
  176. private Map<Long, Long> getProductIdAccountIdMap(List<AccountingProduct> accountingProductList) {
  177. return accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
  178. }
  179. /**
  180. *
  181. * @param responsibilityDepartmentList
  182. * @return
  183. */
  184. @NotNull
  185. private Map<Long, Long> getDepartmentIdResponsibilityIdMap(List<ResponsibilityDepartment> responsibilityDepartmentList) {
  186. return responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
  187. }
  188. private List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
  189. return responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
  190. .eq(ResponsibilityDepartment::getHospId, hospId));
  191. }
  192. @NotNull
  193. private Map<Long, Accounting> getLongAccountingMap(Long hospId) {
  194. return accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
  195. }
  196. @NotNull
  197. private Map<Long, Responsibility> getLongResponsibilityMap(Long hospId) {
  198. return responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
  199. }
  200. @NotNull
  201. private Map<String, Product> getProductByCodeNameMap(Long hospId) {
  202. return productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
  203. }
  204. @NotNull
  205. private Map<String, Department> getDepartmentByCodeNameMap(Long hospId) {
  206. return departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
  207. }
  208. /**
  209. * 导入收入数据
  210. *
  211. * @param read 读取到的初始数据
  212. * @param user 当前登录用户
  213. * @param file 导入的文件
  214. * @param year 年
  215. * @param month 月
  216. * @return {@link Result}
  217. */
  218. @Override
  219. public Result importDataByIncomeData(List<List<Object>> read, User user, MultipartFile file, Integer year, Integer month) {
  220. return null;
  221. }
  222. /**
  223. * 检验数据
  224. * @param list 表单数据
  225. * @param incomeErrorMessageList 存储错误信息的集合
  226. * @param costIncomeGroupArrayList
  227. * @param departmentMap 科室Map
  228. * @param productMap 成本项目map
  229. * @param responsibilityMap 责任中心Map
  230. * @param accountingMap 会计科目Map
  231. * @param responsibilityDepMap 责任中心科室对照Map
  232. * @param accountProMap 责任中心Map
  233. * @param hospId
  234. */
  235. private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, List<CostIncomeGroup> costIncomeGroupArrayList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, Long hospId,Integer year,Integer month) {
  236. for (int i = 0; i < list.size(); i++) {
  237. CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
  238. // 用来检验数据合理性的循环
  239. IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
  240. List<Object> data = list.get(i);
  241. log.info("用户输入的数据是{}", data);
  242. // 成本项目的代码和名称
  243. String productCode = data.get(0).toString();
  244. String productName = data.get(1).toString();
  245. // 开单科室 执行科室的代码和名称
  246. String openDepartmentName = data.get(2).toString();
  247. String openDepartmentCode = data.get(3).toString();
  248. String startDepartmentName = data.get(4).toString();
  249. String startDepartmentCode = data.get(5).toString();
  250. BigDecimal beforeMoney = BigDecimal.valueOf(Double.parseDouble(data.get(15).toString()));
  251. boolean checkNull = StrUtil.isBlank(data.get(15).toString());
  252. boolean checkOne = NumberConstant.ZERO.equals(data.get(15).toString());
  253. if (checkNull || checkOne) {
  254. // 要求这一行的数据必须全部填写
  255. for (int j = 0; j < NumberConstant.FIVE; j++) {
  256. if (Objects.isNull(data.get(j))) {
  257. incomeErrorMessage.setTotal(i);
  258. int row = i + 1;
  259. int column = j + 1;
  260. incomeErrorMessage.setErrMessage("第{" + row + "}行第{" + column + "}列数据为空");
  261. incomeErrorMessageList.add(incomeErrorMessage);
  262. }
  263. }
  264. }
  265. // 检验收入成本项目数据是否存在
  266. Product product = productMap.get(productCode + productName);
  267. Department department = departmentMap.get(openDepartmentCode + openDepartmentName);
  268. Department department1 = departmentMap.get(startDepartmentCode + startDepartmentName);
  269. if (!checkNull && !checkOne ){
  270. if (StrUtil.isNotBlank(productCode) && StrUtil.isNotBlank(productName)){
  271. if (Objects.isNull(product)) {
  272. incomeErrorMessage.setTotal(i);
  273. incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "成本项目不存在");
  274. incomeErrorMessageList.add(incomeErrorMessage);
  275. } else {
  276. // 检验对应的会计科目是否存在
  277. Long id = product.getId();
  278. Long accountId = accountProMap.get(id);
  279. if (Objects.isNull(accountingMap.get(accountId))) {
  280. incomeErrorMessage.setTotal(i);
  281. incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "成本项目对应的会计科目不存在");
  282. incomeErrorMessageList.add(incomeErrorMessage);
  283. } else {
  284. costIncomeGroup.setProductCode(productCode);
  285. costIncomeGroup.setProductName(productName);
  286. costIncomeGroup.setAccountCode(accountingMap.get(accountId).getAccountingCode());
  287. costIncomeGroup.setAccountName(accountingMap.get(accountId).getAccountingName());
  288. }
  289. }
  290. }else{
  291. costIncomeGroup.setProductCode(null);
  292. costIncomeGroup.setProductName(null);
  293. costIncomeGroup.setAccountCode( null);
  294. costIncomeGroup.setAccountName(null);
  295. }
  296. }
  297. // 检验开单科室
  298. if (!checkNull && !checkOne ){
  299. if (StrUtil.isNotBlank(openDepartmentCode) && StrUtil.isNotBlank(openDepartmentName)){
  300. // 开单科室
  301. if (Objects.isNull(department)) {
  302. incomeErrorMessage.setTotal(i);
  303. incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "开单科室不存在");
  304. incomeErrorMessageList.add(incomeErrorMessage);
  305. } else {
  306. Long id = department.getId();
  307. Long responsibilityId = responsibilityDepMap.get(id);
  308. if (Objects.isNull(responsibilityMap.get(responsibilityId))) {
  309. incomeErrorMessage.setTotal(i);
  310. incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
  311. incomeErrorMessageList.add(incomeErrorMessage);
  312. } else {
  313. costIncomeGroup.setOpenDepartmentCode(openDepartmentCode);
  314. costIncomeGroup.setOpenDepartmentName(openDepartmentName);
  315. costIncomeGroup.setOpenResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
  316. costIncomeGroup.setOpenResponsibilityName(responsibilityMap.get(responsibilityId).getResponsibilityName());
  317. }
  318. }
  319. }else {
  320. costIncomeGroup.setOpenDepartmentCode(null);
  321. costIncomeGroup.setOpenDepartmentName(null);
  322. costIncomeGroup.setOpenResponsibilityCode(null);
  323. costIncomeGroup.setOpenResponsibilityName(null);
  324. }
  325. }
  326. // 检验执行科室
  327. if ( !checkNull && !checkOne ){
  328. if (StrUtil.isNotBlank(startDepartmentCode) && StrUtil.isNotBlank(startDepartmentName)){
  329. //执行科室
  330. if (Objects.isNull(department1)) {
  331. incomeErrorMessage.setTotal(i);
  332. incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "执行科室不存在");
  333. incomeErrorMessageList.add(incomeErrorMessage);
  334. } else {
  335. Long id = department1.getId();
  336. Long responsibilityId = responsibilityDepMap.get(id);
  337. if (Objects.isNull(responsibilityMap.get(responsibilityId))) {
  338. incomeErrorMessage.setTotal(i);
  339. incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
  340. incomeErrorMessageList.add(incomeErrorMessage);
  341. } else {
  342. costIncomeGroup.setStartDepartmentCode(startDepartmentCode);
  343. costIncomeGroup.setStartDepartmentName(startDepartmentName);
  344. costIncomeGroup.setStartResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
  345. costIncomeGroup.setStartResponsibilityName(responsibilityMap.get(responsibilityId).getResponsibilityName());
  346. }
  347. }
  348. }else {
  349. costIncomeGroup.setStartDepartmentCode(null);
  350. costIncomeGroup.setStartDepartmentName(null);
  351. costIncomeGroup.setStartResponsibilityCode(null);
  352. costIncomeGroup.setStartResponsibilityName(null);
  353. }
  354. }
  355. costIncomeGroup.setDoctorNumber(Long.parseLong(data.get(6).toString())).setDoctorName(data.get(7).toString())
  356. .setPatientId(Long.parseLong(data.get(8).toString())).setOutpatientId(Long.parseLong(data.get(9).toString()))
  357. .setPatientName(data.get(10).toString()).setPatientFee(data.get(11).toString()).setReceiptFee(data.get(12).toString())
  358. .setTotalNumber(Integer.parseInt(data.get(13).toString())).setUnit(data.get(14).toString())
  359. .setFeeDatetime(DateUtils.StringToDate(data.get(16).toString(), DateStyleEnum.YYYY_MM_DD_HH_MM_SS_EN));
  360. //
  361. costIncomeGroup.setHospId(hospId);
  362. costIncomeGroup.setCreateTime(System.currentTimeMillis());
  363. costIncomeGroup.setDateYear(year);
  364. costIncomeGroup.setDateMonth(month);
  365. costIncomeGroup.setAmount(beforeMoney);
  366. costIncomeGroupArrayList.add(costIncomeGroup);
  367. }
  368. }
  369. /**
  370. * 设置相关名称
  371. *
  372. * @param hospId
  373. * @param costIncomeGroupBeforeVOList
  374. */
  375. private void setCodeName(Long hospId, List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList) {
  376. // List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
  377. // Map<String, String> responsibilityMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getResponsibilityName));
  378. // List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId));
  379. // Map<String, String> departmentMap = departmentList.stream().collect(Collectors.toMap(Department::getDepartmentCode, Department::getDepartmentName));
  380. // List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
  381. // Map<String, String> productMap = productList.stream().collect(Collectors.toMap(Product::getProductCode, Product::getProductName));
  382. // List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
  383. // Map<String, String> accountMap = accountingList.stream().collect(Collectors.toMap(Accounting::getAccountingCode, Accounting::getAccountingName));
  384. costIncomeGroupBeforeVOList.forEach(i -> {
  385. // 以为这里的数据导入的 在导入的时候进行数据校验
  386. // 设置开单科室名称 执行科室名称 开单责任中心名称 执行责任中心名称 成本项目的名称 会计科目名称
  387. i.setOpenDepartmentCodeName("[" + i.getOpenDepartmentCode() + "]" + i.getOpenDepartmentName());
  388. i.setOpenResponsibilityCodeName("[" + i.getOpenResponsibilityCode() + "]" + i.getOpenResponsibilityName());
  389. i.setStartDepartmentCodeName("[" + i.getStartDepartmentCode() + "]" + i.getStartDepartmentName());
  390. i.setStartResponsibilityCodeName("[" + i.getStartResponsibilityCode() + "]" + i.getStartResponsibilityCode());
  391. i.setProductCodeName("[" + i.getProductCode() + "]" + i.getProductName());
  392. i.setAccountCodeName("[" + i.getAccountCode() + "]" + i.getAccountName());
  393. });
  394. }
  395. /**
  396. * 文件上传
  397. */
  398. public String uploadFile(MultipartFile file, User user) {
  399. Long hospId = user.getHospId();
  400. String fileName = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf("."))+System.currentTimeMillis()+".xsl";
  401. String localFilePath = fileTempPath + StrUtil.SLASH + hospId + StrUtil.SLASH;
  402. File tempFile = new File(localFilePath);
  403. if (!tempFile.exists()) {
  404. tempFile.mkdirs();
  405. }
  406. localFilePath = localFilePath + fileName;
  407. try {
  408. file.transferTo(new File(localFilePath));
  409. } catch (IOException e) {
  410. log.error("【文件上传至本地】失败,绝对路径:{}", e.getMessage());
  411. throw new CostException(ErrorCodeEnum.FILE_UPLOAD_ERROR);
  412. } finally {
  413. }
  414. return FILE_PATH + hospId + StrUtil.SLASH + fileName;
  415. }
  416. }