|
|
@@ -1,39 +1,29 @@
|
|
|
package com.nb.web.service.bus.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-import cn.dev33.satoken.annotation.SaMode;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.nb.core.annotation.Log;
|
|
|
-import com.nb.core.entity.GenericEntity;
|
|
|
-import com.nb.core.enums.ExportType;
|
|
|
import com.nb.core.exception.CustomException;
|
|
|
-import com.nb.core.result.ExportResult;
|
|
|
import com.nb.core.result.R;
|
|
|
-import com.nb.web.api.entity.*;
|
|
|
-import com.nb.web.api.feign.query.PatientMonitorQuery;
|
|
|
-import com.nb.web.api.feign.result.PatientMonitorResult;
|
|
|
+import com.nb.web.api.bean.FormulaDrugDetailDomain;
|
|
|
+import com.nb.web.api.bean.FormulaDrugDomain;
|
|
|
import com.nb.web.service.bus.controller.vo.*;
|
|
|
-import com.nb.web.service.bus.entity.BusInfusionModifyEntity;
|
|
|
-import com.nb.web.service.bus.entity.BusPatientEntity;
|
|
|
import com.nb.web.service.bus.service.*;
|
|
|
import com.nb.web.service.bus.service.dto.*;
|
|
|
-import com.nb.web.service.bus.utils.AnalExportUtils;
|
|
|
+import com.nb.web.service.bus.utils.LiquidExcelMergeWriteHandler;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.charset.Charset;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author lifang
|
|
|
@@ -63,4 +53,77 @@ public class BusLiquidController {
|
|
|
clinicService.batchHandleLiquid(source);
|
|
|
return R.success(Boolean.TRUE);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("导出废液记录单")
|
|
|
+ @PostMapping("/export/record")
|
|
|
+ public void exportRecord(HttpServletResponse response, @RequestBody Collection<String> ids) throws IOException {
|
|
|
+ if(CollectionUtil.isEmpty(ids)){
|
|
|
+ throw new CustomException("请选择要导出的废液记录");
|
|
|
+ }
|
|
|
+ List<BusLiquidListVO> records= clinicService.selectLiquidByIds(ids);
|
|
|
+ if(CollectionUtil.isEmpty(records)){
|
|
|
+ throw new CustomException("请选择要导出的废液记录");
|
|
|
+ }
|
|
|
+ List<BusLiquidExcelVO> excelList = new ArrayList<>();
|
|
|
+ // 将BusLiquidListVO转换为BusLiquidExcelVO
|
|
|
+ for (BusLiquidListVO record : records) {
|
|
|
+ excelList.addAll(convertExcelVO(record));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String fileName = "废液记录单";
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("utf-8"), Charset.defaultCharset()) + ".xlsx");
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+
|
|
|
+ ServletOutputStream outputStream = response.getOutputStream();
|
|
|
+ EasyExcel.write(outputStream, BusLiquidExcelVO.class)
|
|
|
+ .registerWriteHandler(new LiquidExcelMergeWriteHandler(excelList))
|
|
|
+ .sheet("废液记录单")
|
|
|
+ .doWrite(excelList);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new CustomException("导出失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<BusLiquidExcelVO> convertExcelVO(BusLiquidListVO record){
|
|
|
+ List<BusLiquidExcelVO> result=new ArrayList<>();
|
|
|
+ List<FormulaDrugDetailDomain> detail=new ArrayList<>();
|
|
|
+ FormulaDrugDomain formula = record.getFormula();
|
|
|
+ if(formula!=null&&CollectionUtil.isNotEmpty(formula.getDetail())){
|
|
|
+ detail=formula.getDetail();
|
|
|
+ }else {
|
|
|
+ detail.add(new FormulaDrugDetailDomain());
|
|
|
+ }
|
|
|
+ for (FormulaDrugDetailDomain formulaDrugDetailDomain : detail) {
|
|
|
+ BusLiquidExcelVO excelVO = new BusLiquidExcelVO();
|
|
|
+ // 这里需要根据实际字段进行映射
|
|
|
+ excelVO.setClinicId(record.getClinicId());
|
|
|
+ excelVO.setClinicName(record.getClinicName());
|
|
|
+ excelVO.setPatientCode(record.getPatientCode());
|
|
|
+ excelVO.setPatientId(record.getPatientId());
|
|
|
+ excelVO.setPatientName(record.getPatientName());
|
|
|
+ excelVO.setWard(record.getWard());
|
|
|
+ excelVO.setBedNo(record.getBedNo());
|
|
|
+ if(StrUtil.isNotEmpty(record.getDeviceAlias())){
|
|
|
+ excelVO.setDeviceAlias(record.getDeviceAlias());
|
|
|
+ }else {
|
|
|
+ excelVO.setDeviceAlias(record.getDeviceId());
|
|
|
+ }
|
|
|
+ excelVO.setClinicStartTime(record.getClinicStartTime());
|
|
|
+ excelVO.setUndoTime(record.getUndoTime());
|
|
|
+ excelVO.setName(formulaDrugDetailDomain.getName());
|
|
|
+ excelVO.setDose(formulaDrugDetailDomain.getDose());
|
|
|
+ excelVO.setUnit(formulaDrugDetailDomain.getUnit());
|
|
|
+ excelVO.setBatchCode(formulaDrugDetailDomain.getBatchCode());
|
|
|
+ excelVO.setUse(formulaDrugDetailDomain.getUse());
|
|
|
+ excelVO.setTotalDose(record.getTotalDose());
|
|
|
+ excelVO.setRemainDose(record.getRemainDose());
|
|
|
+ excelVO.setLiquidExecutor(record.getLiquidExecutor());
|
|
|
+ excelVO.setLiquidChecker(record.getLiquidChecker());
|
|
|
+ excelVO.setLiquidRemark(record.getLiquidRemark());
|
|
|
+ excelVO.setLiquidTime(record.getLiquidTime());
|
|
|
+ result.add(excelVO);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|