From 94a668864caaf547ec663ae2cbb9769898c2cb54 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Mon, 7 Jul 2025 15:27:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CaseplatformCaseExcelController.java | 25 ++++- .../CaseplatformExpertWhiteController.java | 1 + .../service/CaseplatformCaseService.java | 95 +++++++++++++++++++ 3 files changed, 118 insertions(+), 3 deletions(-) diff --git a/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformCaseExcelController.java b/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformCaseExcelController.java index 804cb8e..9ee5d29 100644 --- a/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformCaseExcelController.java +++ b/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformCaseExcelController.java @@ -13,13 +13,18 @@ import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.Casepla import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.EasyExcelCaseDetailVO; import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.ExportExpertCaseExcelVo; import net.lab1024.sa.admin.module.business.caseplatformcase.service.CaseplatformCaseService; +import net.lab1024.sa.common.common.domain.ResponseDTO; +import net.lab1024.sa.common.common.exception.BusinessException; import net.lab1024.sa.common.module.support.operatelog.annoation.OperateLog; +import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @@ -43,6 +48,7 @@ public class CaseplatformCaseExcelController { private CaseplatformCaseService caseplatformCaseService; // 病例管理导出 + @ApiOperation("病例管理导出") @GetMapping("/caseplatformCase/exportEasyExcel") public void exportEasyExcel(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) { try { @@ -88,7 +94,8 @@ public class CaseplatformCaseExcelController { } // 结算导出 - @GetMapping("/caseplatformCase/exportExpertCaseExcel") + @ApiOperation("结算导出") + @GetMapping("/caseplatformCase/settlementExcel") public void exportExpertCaseExcel(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) { try { List list = caseplatformCaseService.exportExpertCaseExcel(queryForm); @@ -100,7 +107,7 @@ public class CaseplatformCaseExcelController { List> head = new ArrayList<>(); List titleRow = new ArrayList<>(); titleRow.add("人工肝诊疗病例征集项目专家劳务费表"); - for (int i = 0; i < 12; i++) { // 假设你总共有 13 列(从"序号"到"身份证号") + for (int i = 0; i < 13; i++) { // 假设你总共有 13 列(从"序号"到"身份证号") if (i > 0) titleRow.add(""); } head.add(titleRow); @@ -108,7 +115,7 @@ public class CaseplatformCaseExcelController { // 2. 添加第二行字段标题(正常列头) List headerRow = Arrays.asList( "序号", "银行", "账号所在省份", "账户所在地市", - "卡号", "姓名", "实发", "备注", "个税", "应发", "单位", "电话", "身份证号" + "卡号", "姓名", "实发", "备注", "个税", "应发", "单位", "电话", "身份证号", "关联病例" ); head.add(headerRow); @@ -149,4 +156,16 @@ public class CaseplatformCaseExcelController { e.printStackTrace(); } } + + @ApiOperation("结算导入") + @PostMapping("/caseplatformCase/settlementImport") + public ResponseDTO caseplatformCaseSettlementImport(@RequestParam("file") MultipartFile file) { + try { + caseplatformCaseService.caseplatformCaseSettlementImport(file); + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + + return ResponseDTO.ok(); + } } diff --git a/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformExpertWhiteController.java b/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformExpertWhiteController.java index 3c58e13..280ee0b 100644 --- a/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformExpertWhiteController.java +++ b/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/controller/CaseplatformExpertWhiteController.java @@ -50,4 +50,5 @@ public class CaseplatformExpertWhiteController { public ResponseDTO> getCaseplatformExpertWhitePage(@RequestBody @Valid CaseplatformExpertWhiteQueryForm queryForm) { return caseplatformExpertWhiteService.queryPage(queryForm); } + } diff --git a/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/service/CaseplatformCaseService.java b/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/service/CaseplatformCaseService.java index b83370a..e860504 100644 --- a/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/service/CaseplatformCaseService.java +++ b/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/caseplatformcase/service/CaseplatformCaseService.java @@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import net.lab1024.sa.admin.module.app.expert.admin.ExpertWhiteEntity; +import net.lab1024.sa.admin.module.app.expert.dao.CasePlatformBankDao; import net.lab1024.sa.admin.module.app.expert.dao.ExpertWhiteEntityDao; +import net.lab1024.sa.admin.module.app.expert.domain.entity.CasePlatformBankEntity; import net.lab1024.sa.admin.module.business.area.domain.vo.ProvVO; import net.lab1024.sa.admin.module.business.caseplatformcase.dao.CaseplatformCaseDao; import net.lab1024.sa.admin.module.business.caseplatformcase.domain.entity.CaseplatformCaseEntity; @@ -78,6 +80,9 @@ public class CaseplatformCaseService { @Autowired private ExpertWhiteEntityDao expertWhiteDao; + @Autowired + private CasePlatformBankDao casePlatformBankDao; + // 创建 ObjectMapper 实例(建议使用 Spring 注入或静态常量) private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -152,6 +157,7 @@ public class CaseplatformCaseService { return list; } + // 处理 结算导出 数据 public List exportExpertCaseExcelProcess(List list) { // 存放 expertId -> ExportExpertCaseExcelVo 列表 Map> expertMap = new HashMap<>(); @@ -223,6 +229,95 @@ public class CaseplatformCaseService { return result; } + // 结算导入 + public void caseplatformCaseSettlementImport(MultipartFile file) throws Exception { + try (InputStream is = file.getInputStream(); + Workbook workbook = WorkbookFactory.create(is)) { // 自动识别 .xls 或 .xlsx + + Sheet sheet = workbook.getSheetAt(0); + + // 从第 1 行开始读取(跳过标题行) + int rowNum = 0; + for (Iterator it = sheet.rowIterator(); it.hasNext();) { + Row row = it.next(); + + // 跳过第一行 + if (rowNum++ == 0 || rowNum++ == 1) continue; + + // 判断整行是否为空 + boolean isEmptyRow = true; + for (Cell cell : row) { + if (cell != null && cell.getCellType() != CellType.BLANK) { + isEmptyRow = false; + break; + } + } + + if (isEmptyRow) { + continue; // 跳过空行 + } + + String name = ""; + String bankName = ""; + String prov = ""; + String city = ""; + String bankCardNo = ""; + String actualAmountStr = ""; + String remark = ""; + String taxAmountStr = ""; + String totalAmountStr = ""; + String hospitalName = ""; + String mobile = ""; + String idCardNo = ""; + String relatedCaseId = ""; + + DataFormatter dataFormatter = new DataFormatter(); + + Cell cell0 = row.getCell(0); if (cell0 != null) name = cell0.toString().trim(); + Cell cell1 = row.getCell(1); if (cell1 != null) bankName = cell1.toString().trim(); + Cell cell2 = row.getCell(2); if (cell2 != null) prov = cell2.toString().trim(); + Cell cell3 = row.getCell(3); if (cell3 != null) city = cell3.toString().trim(); + Cell cell4 = row.getCell(4); if (cell4 != null) bankCardNo = cell4.toString().trim(); + Cell cell5 = row.getCell(5); if (cell5 != null) actualAmountStr = dataFormatter.formatCellValue(cell5).trim(); + Cell cell6 = row.getCell(6); if (cell6 != null) remark = cell6.toString().trim(); + Cell cell7 = row.getCell(7); if (cell7 != null) taxAmountStr = dataFormatter.formatCellValue(cell7).trim(); + Cell cell8 = row.getCell(8); if (cell8 != null) totalAmountStr = dataFormatter.formatCellValue(cell8).trim(); + Cell cell9 = row.getCell(9); if (cell9 != null) hospitalName = cell9.toString().trim(); + Cell cell10 = row.getCell(10); if (cell10 != null) mobile = dataFormatter.formatCellValue(cell10).trim(); + Cell cell11 = row.getCell(11); if (cell11 != null) idCardNo = dataFormatter.formatCellValue(cell11).trim(); + Cell cell12 = row.getCell(11); if (cell11 != null) relatedCaseId = dataFormatter.formatCellValue(cell12).trim(); + + // 病例id + String[] caseIdList = relatedCaseId.split(","); + for (String id : caseIdList) { + CaseplatformCaseEntity caseplatformCase = caseplatformCaseDao.selectById(id); + if (caseplatformCase == null) { + throw new BusinessException("处理失败: 存在非法病例 " + id); + } + + // 获取专家银行卡 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CasePlatformBankEntity::getExpertId, caseplatformCase.getExpertId()); + CasePlatformBankEntity casePlatformBank = casePlatformBankDao.selectOne(queryWrapper); + if (casePlatformBank == null) { + throw new BusinessException("处理失败: 存在非法病例 " + id); + } + + if (!Objects.equals(casePlatformBank.getBankCardNo(), bankCardNo)){ + throw new BusinessException("处理失败: 存在非法病例 " + id); + } + + // 修改病例结算状态 + caseplatformCase.setSettlementFlag(1); + caseplatformCase.setUpdateTime(LocalDateTime.now()); + caseplatformCaseDao.updateById(caseplatformCase); + } + } + } catch (Exception e) { + throw new BusinessException("文件读取失败: " + e.getMessage()); + } + } + /** * 添加 */