| | |
| | | } |
| | | |
| | | /** |
| | | * 车辆选择分页列表 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @ApiOperation("车辆选择分页列表") |
| | | @PostMapping("/select-page") |
| | | public R<PageDTO<MwTransitCarVO>> pageSelectList(@Valid @RequestBody TransitCarQuery query) { |
| | | return R.ok(mwTransitCarService.pageSelectList(query)); |
| | | } |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param id |
| | |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>dysmsapi20170525</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.coobird</groupId> |
| | | <artifactId>thumbnailator</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.sinata.system.config; |
| | | |
| | | import cn.idev.excel.metadata.Head; |
| | | import cn.idev.excel.metadata.data.WriteCellData; |
| | | import cn.idev.excel.write.metadata.holder.WriteSheetHolder; |
| | | import cn.idev.excel.write.style.column.AbstractColumnWidthStyleStrategy; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class AutoColumnWidthEntityStrategy extends AbstractColumnWidthStyleStrategy { |
| | | private final Map<Integer, Map<Integer, Integer>> cache = new HashMap<>(); |
| | | |
| | | @Override |
| | | protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, |
| | | Head head, Integer relativeRowIndex, Boolean isHead) { |
| | | boolean needSetWidth = isHead || !cellDataList.isEmpty(); |
| | | if (needSetWidth) { |
| | | Map<Integer, Integer> maxWidthMap = cache.computeIfAbsent(writeSheetHolder.getSheetNo(), k -> new HashMap<>()); |
| | | int columnWidth = calculateWidth(cellDataList, cell, isHead); |
| | | if (columnWidth > 0) { |
| | | columnWidth = Math.min(columnWidth, 255); // 最大支持255字符 |
| | | if (columnWidth > maxWidthMap.getOrDefault(cell.getColumnIndex(), 0)) { |
| | | maxWidthMap.put(cell.getColumnIndex(), columnWidth); |
| | | writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 270); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 计算单元格内容长度(按字节) |
| | | private int calculateWidth(List<WriteCellData<?>> cellDataList, Cell cell, boolean isHead) { |
| | | |
| | | if (isHead) { |
| | | return cell.getStringCellValue().getBytes().length; |
| | | } else { |
| | | WriteCellData<?> cellData = cellDataList.get(0); |
| | | switch (cellData.getType()) { |
| | | case STRING: |
| | | return cellData.getStringValue().getBytes().length; |
| | | case NUMBER: |
| | | return cellData.getNumberValue().toString().getBytes().length; |
| | | case DATE: |
| | | return cellData.getDateValue().toString().getBytes().length; |
| | | default: |
| | | return -1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | if (needSetWidth) { |
| | | Map<Integer, Integer> maxWidthMap = cache.computeIfAbsent(writeSheetHolder.getSheetNo(), k -> new HashMap<>()); |
| | | int columnWidth = calculateWidth(cellDataList, cell, isHead); |
| | | if (columnWidth >= 16) { |
| | | columnWidth = 16; |
| | | } |
| | | if (columnWidth > 0) { |
| | | columnWidth = Math.min(columnWidth, 255); // 最大支持255字符 |
| | | if (columnWidth > maxWidthMap.getOrDefault(cell.getColumnIndex(), 0)) { |
| | | maxWidthMap.put(cell.getColumnIndex(), columnWidth); |
| | | writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256); |
| | | writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 255); |
| | | } |
| | | } |
| | | } |
| | |
| | | return cellData.getStringValue().getBytes().length; |
| | | case NUMBER: |
| | | return cellData.getNumberValue().toString().getBytes().length; |
| | | case DATE: |
| | | return cellData.getDateValue().toString().getBytes().length; |
| | | default: |
| | | return -1; |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.net.URL; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | public class MwCheckoutRecordExcel { |
| | | |
| | | @ApiModelProperty("出库时间") |
| | | @ExcelProperty(value = "出库时间", index = 1) |
| | | @ExcelProperty(value = "出库时间", index = 0) |
| | | private Date checkoutTime; |
| | | |
| | | @ExcelProperty(value = "医院", index = 2) |
| | | @ExcelProperty(value = "医院", index = 1) |
| | | private String hospitalName; |
| | | |
| | | @ExcelProperty(value = "暂存间", index = 3) |
| | | @ExcelProperty(value = "暂存间", index = 2) |
| | | private String roomName; |
| | | |
| | | @ExcelProperty(value = "箱数", index = 4) |
| | | @ExcelProperty(value = "箱数", index = 3) |
| | | private Integer boxNum; |
| | | |
| | | @ExcelProperty(value = "袋数", index = 5) |
| | | @ExcelProperty(value = "袋数", index = 4) |
| | | private Integer bagNum; |
| | | |
| | | @ExcelProperty(value = "总重量", index = 6) |
| | | @ExcelProperty(value = "医废重量(kg)", index = 5) |
| | | private BigDecimal totalWeight; |
| | | |
| | | @ExcelProperty(value = "医院签名", index = 7) |
| | | private URL hospitalSignature; |
| | | @ExcelProperty(value = "医院签名", index = 6) |
| | | private byte[] hospitalSignature; |
| | | |
| | | @ExcelProperty(value = "司机姓名", index = 8) |
| | | @ExcelProperty(value = "司机姓名", index = 7) |
| | | private String driverName; |
| | | |
| | | @ExcelProperty(value = "车牌号", index = 9) |
| | | @ExcelProperty(value = "车牌号", index = 8) |
| | | private String licensePlateNumber; |
| | | |
| | | @ApiModelProperty("记录id") |
| | |
| | | private Integer bagNum; |
| | | |
| | | @ApiModelProperty("总重量") |
| | | @ExcelProperty(value = "重量", index = 4) |
| | | @ExcelProperty(value = "重量(kg)", index = 4) |
| | | private BigDecimal totalWeight; |
| | | |
| | | @ApiModelProperty("司机姓名") |
| | |
| | | private String wasteTypeStr; |
| | | |
| | | @ApiModelProperty("医废重量") |
| | | @ExcelProperty(value = "医废重量", index = 5) |
| | | @ExcelProperty(value = "医废重量(kg)", index = 5) |
| | | private BigDecimal weight; |
| | | |
| | | @ApiModelProperty("出库人员id") |
| | |
| | | package com.sinata.system.domain.vo; |
| | | |
| | | import cn.idev.excel.annotation.ExcelIgnore; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import cn.idev.excel.annotation.format.DateTimeFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | public class MwMicroEquipmentRecordVO { |
| | | |
| | | @ApiModelProperty("设备使用记录id") |
| | | @ExcelIgnore |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("医院名称") |
| | | @ExcelProperty(value = "医院名称", index = 0) |
| | | private String hospitalName; |
| | | |
| | | @ApiModelProperty("设备名称") |
| | | @ExcelProperty(value = "设备名称", index = 1) |
| | | private String equipmentName; |
| | | |
| | | @ApiModelProperty("设备id") |
| | | @ExcelIgnore |
| | | private Long equipmentId; |
| | | |
| | | @ApiModelProperty("使用时间") |
| | | @ExcelProperty(value = "使用时间", index = 2) |
| | | @DateTimeFormat(value = "yyyy-MM-dd HH:mm:ss") |
| | | private Date useTime; |
| | | |
| | | @ApiModelProperty("处理箱数") |
| | | @ExcelProperty(value = "处理箱数", index = 3) |
| | | private Integer boxNum; |
| | | |
| | | @ApiModelProperty("处理袋数") |
| | | @ExcelProperty(value = "处理袋数", index = 4) |
| | | private Integer bagNum; |
| | | |
| | | @ApiModelProperty("处理重量") |
| | | @ExcelProperty(value = "处理重量(kg)", index = 5) |
| | | private BigDecimal totalWeight; |
| | | |
| | | @ApiModelProperty("操作人员") |
| | | @ExcelProperty(value = "操作人员", index = 6) |
| | | private String nickName; |
| | | |
| | | @ApiModelProperty("备注") |
| | | @ExcelProperty(value = "备注", index = 7) |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("医废列表") |
| | | @ExcelIgnore |
| | | private List<MwStorageRecordVO> medicalWasteList; |
| | | } |
| | | |
| | |
| | | private Long departmentId; |
| | | |
| | | @ApiModelProperty("医院名称") |
| | | @ExcelProperty(value = "医院名称", index = 2) |
| | | @ExcelProperty(value = "医院名称", index = 1) |
| | | private String hospitalName; |
| | | |
| | | @ApiModelProperty("暂存间id") |
| | |
| | | private Long stagingRoomId; |
| | | |
| | | @ApiModelProperty("暂存间名称") |
| | | @ExcelProperty(value = "暂存间", index = 3) |
| | | @ExcelProperty(value = "暂存间", index = 2) |
| | | private String roomName; |
| | | |
| | | @ApiModelProperty("医废编号") |
| | | @ExcelProperty(value = "医废编号", index = 4) |
| | | @ExcelProperty(value = "医废编号", index = 3) |
| | | private String medicalWasteNumber; |
| | | |
| | | @ApiModelProperty("转运箱id") |
| | |
| | | private Long boxId; |
| | | |
| | | @ApiModelProperty("箱子编号") |
| | | @ExcelProperty(value = "箱子编号", index = 5) |
| | | @ExcelProperty(value = "箱子编号", index = 4) |
| | | private String boxNumber; |
| | | |
| | | @ApiModelProperty("袋数") |
| | |
| | | private Integer bagNum; |
| | | |
| | | @ApiModelProperty("医废类型(数据字典id)") |
| | | @ExcelIgnore |
| | | private Integer wasteType; |
| | | |
| | | @ApiModelProperty("医废类型名称") |
| | | @ExcelProperty(value = "医废类型", index = 6) |
| | | @ExcelProperty(value = "医废类型", index = 5) |
| | | private String wasteTypeStr; |
| | | |
| | | @ApiModelProperty("医废重量") |
| | | @ExcelProperty(value = "医废重量", index = 7) |
| | | @ExcelProperty(value = "重量(kg)", index = 6) |
| | | private BigDecimal weight; |
| | | |
| | | @ApiModelProperty("出库人员id") |
| | |
| | | private Date checkoutTime; |
| | | |
| | | @ApiModelProperty("医废状态 1:暂存中 2:运输中 3:已接收 4:已处置") |
| | | @ExcelProperty(value = "医废状态", index = 8) |
| | | @ExcelIgnore |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty("封箱时间") |
| | |
| | | private Long collectUserId; |
| | | |
| | | @ApiModelProperty("入库人员") |
| | | @ExcelProperty(value = "入库人员", index = 8) |
| | | @ExcelProperty(value = "入库人员", index = 7) |
| | | private String collectUserName; |
| | | |
| | | @ApiModelProperty("入库时间") |
| | | @ExcelProperty(value = "入库时间", index = 1) |
| | | @ExcelProperty(value = "入库时间", index = 0) |
| | | private Date collectTime; |
| | | |
| | | } |
| | |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("预警时间") |
| | | @ExcelProperty(value = "预警时间", index = 1) |
| | | @ExcelProperty(value = "预警时间", index = 0) |
| | | private Date warnTime; |
| | | |
| | | @ApiModelProperty("预警对象id") |
| | |
| | | private Long warningTargetId; |
| | | |
| | | @ApiModelProperty("预警对象") |
| | | @ExcelProperty(value = "预警对象", index = 2) |
| | | @ExcelProperty(value = "预警对象", index = 1) |
| | | private String warningTargetName; |
| | | |
| | | @ApiModelProperty("预警类型 1:出库超时预警 2:暂存间使用率预警 3:合同到期预警 4:健康记录预警 \" +\n" + |
| | | " \"5:疫苗记录预警 6:防护用品使用预警 7:防护用品库存预警 8:医疗机构产废日预警 \" +\n" + |
| | | " \"9:医疗机构产废月预警 10:医疗机构存储量预警 11:车辆转运异常预警 12:处置单位存储量预警") |
| | | @ExcelProperty(value = "预警类型", index = 3, converter = EConverter.class) |
| | | @ExcelProperty(value = "预警类型", index = 2, converter = EConverter.class) |
| | | @FastExcel(type = WarningTypeEnum.class) |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty("预警消息") |
| | | @ExcelProperty(value = "预警消息", index = 4) |
| | | @ExcelProperty(value = "预警消息", index = 3) |
| | | private String message; |
| | | |
| | | @ApiModelProperty("预警状态 1:未解除;2:已解除") |
| | | @ExcelProperty(value = "预警状态", index = 5) |
| | | @ExcelProperty(value = "预警状态", index = 4, converter = EConverter.class) |
| | | @FastExcel(type = WarningStatusEnum.class) |
| | | private Integer status; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | PageDTO<MwTransitCarVO> pageList(TransitCarQuery query); |
| | | /** |
| | | * 车辆选择分页列表 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | PageDTO<MwTransitCarVO> pageSelectList(TransitCarQuery query); |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | import com.sinata.common.utils.DateUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.config.CustomCellWriteHeightConfig; |
| | | import com.sinata.system.domain.MwCollectRecord; |
| | | import com.sinata.system.domain.MwWarningRecord; |
| | | import com.sinata.system.domain.SysDepartment; |
| | |
| | | import com.sinata.system.service.MwWarningRecordService; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import com.sinata.system.utils.ImageToBase64; |
| | | import com.sinata.system.utils.ImgUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import net.coobird.thumbnailator.Thumbnails; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | |
| | | String finalTitle = title; |
| | | wasteTypeList.forEach(item -> { |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "数量")); |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "重量(KG)")); |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "重量(kg)")); |
| | | }); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "数量")); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "重量(KG)")); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "重量(kg)")); |
| | | headTitles.add(Lists.newArrayList(title, "是否超时", "是否超时")); |
| | | return headTitles; |
| | | } |
| | |
| | | } |
| | | |
| | | public void transformListExport(TransformQuery query) throws IOException { |
| | | List<List<String>> head = transformReportHead(query.getWasteTypeCodeList()); |
| | | List<List<String>> head = transformReportHead(query); |
| | | System.out.println(JSONObject.toJSONString(head)); |
| | | // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 |
| | | String fileName = URLEncoder.encode("医院报表", "UTF-8").replaceAll("\\+", "%20"); |
| | | String fileName = URLEncoder.encode("转移联单", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | // 这里需要设置不关闭流 |
| | | FastExcel.write(response.getOutputStream()) |
| | | .head(head) |
| | | .autoCloseStream(Boolean.TRUE) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("转运联单") |
| | | .registerWriteHandler(new CustomCellWriteHeightConfig()) |
| | | .sheet("转移联单") |
| | | .doWrite(getTransformReportStaticsData(query)); |
| | | } |
| | | |
| | |
| | | List<Object> data = new ArrayList<>(); |
| | | data.add(departmentReportItemVO.getName()); |
| | | data.addAll(departmentReportItemVO.getData()); |
| | | data.add(StringUtils.isNotBlank(departmentReportItemVO.getHospitalSignatureUrl()) ? new URL(departmentReportItemVO.getHospitalSignatureUrl()) : ""); |
| | | if (StringUtils.isNotBlank(departmentReportItemVO.getHospitalSignatureUrl())) { |
| | | try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { |
| | | //获取文件后缀 |
| | | String extension = FilenameUtils.getExtension(departmentReportItemVO.getHospitalSignatureUrl()); |
| | | BufferedImage originalImage = ImageIO.read(ImgUtils.getFileByHttpURL(departmentReportItemVO.getHospitalSignatureUrl())); |
| | | Thumbnails.of(originalImage).scale(0.8).rotate(270).outputFormat(extension).toOutputStream(outputStream); |
| | | data.add(outputStream.toByteArray()); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } else { |
| | | data.add(""); |
| | | } |
| | | data.add(departmentReportItemVO.getDriverName()); |
| | | data.add(departmentReportItemVO.getHandoverTime()); |
| | | result.add(data); |
| | |
| | | } |
| | | return CollUtils.emptyList(); |
| | | } |
| | | |
| | | /** |
| | | * 转运联单导出表头 |
| | | * |
| | | * @param wasteTypeCodeList |
| | | * @param query |
| | | * @return |
| | | */ |
| | | private List<List<String>> transformReportHead(List<Long> wasteTypeCodeList) { |
| | | private List<List<String>> transformReportHead(TransformQuery query) { |
| | | //查询医废类型 |
| | | List<SysDictDataVO> sysDictDataVOS = sysDictDataService.medicalWasteTypeListByDictCode(wasteTypeCodeList); |
| | | List<SysDictDataVO> sysDictDataVOS = sysDictDataService.medicalWasteTypeListByDictCode(query.getWasteTypeCodeList()); |
| | | SysDepartment department = sysDepartmentService.getById(query.getDepartmentId()); |
| | | String title = ""; |
| | | if (Objects.nonNull(department)) { |
| | | title = department.getDepartmentName() + "转移联单"; |
| | | } else { |
| | | title = "转移联单"; |
| | | } |
| | | List<List<String>> headTitles = Lists.newArrayList(); |
| | | headTitles.add(Lists.newArrayList("医院名称", "医院名称")); |
| | | headTitles.add(Lists.newArrayList(title, "医院名称", "医院名称")); |
| | | String finalTitle = title; |
| | | sysDictDataVOS.forEach(item -> { |
| | | headTitles.add(Lists.newArrayList(item.getDictLabel(), "数量")); |
| | | headTitles.add(Lists.newArrayList(item.getDictLabel(), "重量(KG)")); |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "数量")); |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "重量(kg)")); |
| | | }); |
| | | headTitles.add(Lists.newArrayList("小计", "数量")); |
| | | headTitles.add(Lists.newArrayList("小计", "重量(KG)")); |
| | | headTitles.add(Lists.newArrayList("机构人员签字", "机构人员签字")); |
| | | headTitles.add(Lists.newArrayList("运输人员签字", "运输人员签字")); |
| | | headTitles.add(Lists.newArrayList("交接时间", "交接时间")); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "数量")); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "重量(kg)")); |
| | | headTitles.add(Lists.newArrayList(title, "机构人员签字", "机构人员签字")); |
| | | headTitles.add(Lists.newArrayList(title, "运输人员签字", "运输人员签字")); |
| | | headTitles.add(Lists.newArrayList(title, "交接时间", "交接时间")); |
| | | return headTitles; |
| | | } |
| | | |
| | |
| | | import com.sinata.common.utils.CollUtils; |
| | | import com.sinata.common.utils.DateUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.config.AutoColumnWidthEntityStrategy; |
| | | import com.sinata.system.domain.MwCheckoutRecord; |
| | | import com.sinata.system.domain.dto.CollectTotalUpDto; |
| | | import com.sinata.system.domain.query.CheckoutRecordQuery; |
| | |
| | | String fileName = URLEncoder.encode("转运记录", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | FastExcel.write(response.getOutputStream(), MwCheckoutRecordExcelVO.class) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .registerWriteHandler(new AutoColumnWidthEntityStrategy()) |
| | | .sheet("转运记录") |
| | | .doWrite(mwCheckoutRecordExcelVOS); |
| | | } |
| | |
| | | import com.sinata.common.entity.PageDTO; |
| | | import com.sinata.common.exception.ServiceException; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.config.AutoColumnWidthEntityStrategy; |
| | | import com.sinata.system.domain.MedicalWasteStaticsVO; |
| | | import com.sinata.system.domain.MwCollectRecord; |
| | | import com.sinata.system.domain.dto.CollectCarTotalUpDto; |
| | |
| | | String fileName = URLEncoder.encode("医废收集记录", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | FastExcel.write(response.getOutputStream(), MwCollectRecordVO.class) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("医废收集记录").doWrite(vo); |
| | | .registerWriteHandler(new AutoColumnWidthEntityStrategy()) |
| | | .sheet("医废追溯").doWrite(vo); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.sinata.common.utils.DateUtils; |
| | | import com.sinata.common.utils.SecurityUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.config.AutoColumnWidthEntityStrategy; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.domain.MwCollectRecord; |
| | | import com.sinata.system.domain.MwMicroEquipment; |
| | |
| | | import com.sinata.system.domain.query.MwMicroEquipmentStaticsQuery; |
| | | import com.sinata.system.domain.vo.DepartmentReportItemVO; |
| | | import com.sinata.system.domain.vo.DepartmentReportVO; |
| | | import com.sinata.system.domain.vo.MwCollectRecordVO; |
| | | import com.sinata.system.domain.vo.MwMicroEquipmentRecordVO; |
| | | import com.sinata.system.domain.vo.MwMicroEquipmentStaticsTitleVO; |
| | | import com.sinata.system.domain.vo.MwMicroEquipmentStaticsVO; |
| | |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 |
| | | String fileName = URLEncoder.encode("微波设备使用记录", "UTF-8").replaceAll("\\+", "%20"); |
| | | String fileName = URLEncoder.encode("小型微波设备使用记录", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | FastExcel.write(response.getOutputStream(), MwCollectRecordVO.class) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("微波设备使用记录").doWrite(list); |
| | | FastExcel.write(response.getOutputStream(), MwMicroEquipmentRecordVO.class) |
| | | .registerWriteHandler(new AutoColumnWidthEntityStrategy()) |
| | | .sheet("小型微波设备使用记录").doWrite(list); |
| | | } |
| | | |
| | | /** |
| | |
| | | headTitles.add(Lists.newArrayList(title, "日期", "日期")); |
| | | String finalTitle = title; |
| | | medicalWasteTypeList.forEach(item -> { |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "总重量(KG)")); |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "总数量")); |
| | | headTitles.add(Lists.newArrayList(finalTitle, item.getDictLabel(), "总重量(kg)")); |
| | | }); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "总重量(KG)")); |
| | | headTitles.add(Lists.newArrayList(title, "小计", "总数量")); |
| | |
| | | package com.sinata.system.service.impl; |
| | | |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import cn.idev.excel.FastExcel; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.sinata.common.exception.ServiceException; |
| | | import com.sinata.common.utils.BeanUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.config.AutoColumnWidthEntityStrategy; |
| | | import com.sinata.system.config.CustomCellWriteHeightConfig; |
| | | import com.sinata.system.domain.MwStagingRoom; |
| | | import com.sinata.system.domain.dto.MwStagingRoomDTO; |
| | | import com.sinata.system.domain.excel.MwCheckoutRecordExcel; |
| | |
| | | import com.sinata.system.mapper.MwStagingRoomMapper; |
| | | import com.sinata.system.service.MwStagingRoomService; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import com.sinata.system.utils.ImgUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import net.coobird.thumbnailator.Thumbnails; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.net.URL; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | String fileName = URLEncoder.encode("暂存间入库记录", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | FastExcel.write(response.getOutputStream(), MwStorageRecordVO.class) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .registerWriteHandler(new AutoColumnWidthEntityStrategy()) |
| | | .sheet("暂存间入库记录").doWrite(list); |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | List<MwCheckoutRecordVO> list = baseMapper.checkoutRecordList(query, treeCode); |
| | | List<MwCheckoutRecordExcel> mwCheckoutRecordExcels = BeanUtils.copyToList(list, MwCheckoutRecordExcel.class); |
| | | CopyOptions copyOptions = new CopyOptions(); |
| | | copyOptions.setIgnoreProperties("hospitalSignature"); |
| | | List<MwCheckoutRecordExcel> mwCheckoutRecordExcels = BeanUtils.copyToList(list, MwCheckoutRecordExcel.class, copyOptions); |
| | | for (MwCheckoutRecordExcel mwCheckoutRecordExcel : mwCheckoutRecordExcels) { |
| | | for (MwCheckoutRecordVO mwCheckoutRecordVO : list) { |
| | | if (mwCheckoutRecordVO.getId().equals(mwCheckoutRecordExcel.getId())) { |
| | | mwCheckoutRecordExcel.setHospitalSignature(new URL(mwCheckoutRecordVO.getHospitalSignature())); |
| | | if (StringUtils.isNotBlank(mwCheckoutRecordVO.getHospitalSignature())) { |
| | | try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { |
| | | //获取文件后缀 |
| | | String extension = FilenameUtils.getExtension(mwCheckoutRecordVO.getHospitalSignature()); |
| | | BufferedImage originalImage = ImageIO.read(ImgUtils.getFileByHttpURL(mwCheckoutRecordVO.getHospitalSignature())); |
| | | Thumbnails.of(originalImage).scale(0.8).rotate(270).outputFormat(extension).toOutputStream(outputStream); |
| | | mwCheckoutRecordExcel.setHospitalSignature(outputStream.toByteArray()); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | String fileName = URLEncoder.encode("暂存间出库记录", "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | FastExcel.write(response.getOutputStream(), MwCheckoutRecordExcel.class) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .registerWriteHandler(new AutoColumnWidthEntityStrategy()) |
| | | .registerWriteHandler(new CustomCellWriteHeightConfig()) |
| | | .sheet("暂存间出库记录") |
| | | .doWrite(mwCheckoutRecordExcels); |
| | | } |
| | |
| | | import com.sinata.common.entity.PageDTO; |
| | | import com.sinata.common.exception.ServiceException; |
| | | import com.sinata.common.utils.BeanUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.domain.MwTransitCar; |
| | | import com.sinata.system.domain.SysDepartment; |
| | | import com.sinata.system.domain.dto.MwTransitCarDTO; |
| | |
| | | import com.sinata.system.service.MwTransitCarService; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | return PageDTO.of(page); |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<MwTransitCarVO> pageSelectList(TransitCarQuery query) { |
| | | Page<MwTransitCarVO> page = baseMapper.pageList(new Page<>(query.getPageCurr(), query.getPageSize()), query, null); |
| | | return PageDTO.of(page); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | |
| | | import com.sinata.common.entity.PageDTO; |
| | | import com.sinata.common.utils.SecurityUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.config.AutoColumnWidthEntityStrategy; |
| | | import com.sinata.system.domain.MwWarningRecord; |
| | | import com.sinata.system.domain.query.MwWarningRecordQuery; |
| | | import com.sinata.system.domain.vo.MwWarningRecordVO; |
| | |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | |
| | | FastExcel.write(response.getOutputStream(), MwWarningRecordVO.class) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("预警信息") |
| | | .registerWriteHandler(new AutoColumnWidthEntityStrategy()) |
| | | .sheet("预警列表") |
| | | .doWrite(list); |
| | | } |
| | | } |
New file |
| | |
| | | package com.sinata.system.utils; |
| | | |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URL; |
| | | |
| | | public class ImgUtils { |
| | | /** |
| | | * 从URL中获取图片输入流 |
| | | * 并创建本地文件 |
| | | * |
| | | * @param imageUrl |
| | | * @param savePath |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static File getImageFileFromUrl(String imageUrl, String savePath) throws Exception { |
| | | // 从URL中获取图片输入流 |
| | | URL url = new URL(imageUrl); |
| | | InputStream in = url.openStream(); |
| | | |
| | | |
| | | // 构建保存路径 |
| | | String[] split = imageUrl.split("/"); |
| | | String fileName = split[split.length - 1]; |
| | | File file = new File(savePath + fileName); |
| | | if (!file.exists()) { |
| | | file.createNewFile(); |
| | | } |
| | | |
| | | // 写入文件 |
| | | FileOutputStream out = new FileOutputStream(file); |
| | | byte[] buffer = new byte[4096]; |
| | | int n = 0; |
| | | while ((n = in.read(buffer)) != -1) { |
| | | out.write(buffer, 0, n); |
| | | } |
| | | out.close(); |
| | | in.close(); |
| | | |
| | | return file; |
| | | } |
| | | |
| | | /** |
| | | * 根据URL地址获取文件 |
| | | * 得到file对象 |
| | | * |
| | | * @param path URL网络地址 |
| | | * @return File |
| | | */ |
| | | public static File getFileByHttpURL(String path) { |
| | | String newUrl = path.split("[?]")[0]; |
| | | String[] suffix = newUrl.split("/"); |
| | | //得到最后一个分隔符后的名字 |
| | | String fileName = suffix[suffix.length - 1]; |
| | | File file = null; |
| | | InputStream inputStream = null; |
| | | OutputStream outputStream = null; |
| | | try { |
| | | file = File.createTempFile("report", fileName);//创建临时文件 |
| | | URL urlFile = new URL(newUrl); |
| | | inputStream = urlFile.openStream(); |
| | | outputStream = new FileOutputStream(file); |
| | | |
| | | int bytesRead = 0; |
| | | byte[] buffer = new byte[8192]; |
| | | while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) { |
| | | outputStream.write(buffer, 0, bytesRead); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (null != outputStream) { |
| | | outputStream.close(); |
| | | } |
| | | if (null != inputStream) { |
| | | inputStream.close(); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return file; |
| | | } |
| | | |
| | | //顺时针旋转90度(通过交换图像的整数像素RGB 值) |
| | | public static BufferedImage rotateClockwise90(BufferedImage bi) { |
| | | int width = bi.getWidth(); |
| | | int height = bi.getHeight(); |
| | | BufferedImage bufferedImage = new BufferedImage(height, width, bi.getType()); |
| | | for (int i = 0; i < width; i++) |
| | | for (int j = 0; j < height; j++) |
| | | bufferedImage.setRGB(height - 1 - j, width - 1 - i, bi.getRGB(i, j)); |
| | | return bufferedImage; |
| | | } |
| | | |
| | | //逆时针旋转90度(通过交换图像的整数像素RGB 值) |
| | | public static BufferedImage rotateCounterclockwise90(BufferedImage bi) { |
| | | int width = bi.getWidth(); |
| | | int height = bi.getHeight(); |
| | | BufferedImage bufferedImage = new BufferedImage(height, width, bi.getType()); |
| | | for (int i = 0; i < width; i++) |
| | | for (int j = 0; j < height; j++) |
| | | bufferedImage.setRGB(j, i, bi.getRGB(i, j)); |
| | | return bufferedImage; |
| | | } |
| | | |
| | | //旋转180度(通过交换图像的整数像素RGB 值) |
| | | public static BufferedImage rotate180(BufferedImage bi) { |
| | | int width = bi.getWidth(); |
| | | int height = bi.getHeight(); |
| | | BufferedImage bufferedImage = new BufferedImage(width, height, bi.getType()); |
| | | for (int i = 0; i < width; i++) |
| | | for (int j = 0; j < height; j++) |
| | | bufferedImage.setRGB(width - i - 1, height - j - 1, bi.getRGB(i, j)); |
| | | return bufferedImage; |
| | | } |
| | | |
| | | //水平翻转 |
| | | public static BufferedImage rotateHorizon(BufferedImage bi) { |
| | | int width = bi.getWidth(); |
| | | int height = bi.getHeight(); |
| | | BufferedImage bufferedImage = new BufferedImage(width, height, bi.getType()); |
| | | for (int i = 0; i < width; i++) |
| | | for (int j = 0; j < height; j++) |
| | | bufferedImage.setRGB(width - i - 1, j, bi.getRGB(i, j)); |
| | | return bufferedImage; |
| | | } |
| | | |
| | | //垂直翻转 |
| | | public static BufferedImage rotateVertical(BufferedImage bi) { |
| | | int width = bi.getWidth(); |
| | | int height = bi.getHeight(); |
| | | BufferedImage bufferedImage = new BufferedImage(width, height, bi.getType()); |
| | | for (int i = 0; i < width; i++) |
| | | for (int j = 0; j < height; j++) |
| | | bufferedImage.setRGB(i, height - 1 - j, bi.getRGB(i, j)); |
| | | return bufferedImage; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | //File file = ImgUtils.getImageFileFromUrl("【你的图片网络url】", "【你要保存的本地文件位置】"); |
| | | File file = ImgUtils.getFileByHttpURL("【你的图片网络url】"); |
| | | System.out.println("file.length() = " + file.length()); |
| | | } |
| | | } |
| | |
| | | mcr.UPDATE_TIME, |
| | | mcr.COLLECT_USER_ID, |
| | | mcr.COLLECT_TIME, |
| | | su.NICK_NAME AS COLLECT_USER_NAME |
| | | su.NICK_NAME AS COLLECT_USER_NAME, |
| | | msr.ROOM_NAME |
| | | FROM MW_COLLECT_RECORD mcr |
| | | LEFT JOIN SYS_USER su |
| | | ON mcr.COLLECT_USER_ID = su.USER_ID |
| | | LEFT JOIN SYS_DEPARTMENT sd ON su.DEPARTMENT_ID = sd.ID |
| | | LEFT JOIN MW_STAGING_ROOM msr ON msr.DEPARTMENT_ID = sd.ID |
| | | <where> |
| | | mcr.DEL_FLAG = 0 |
| | | <if test="treeCode != null and treeCode != ''"> |
| | |
| | | <if test="query.phoneNumber!=null and query.phoneNumber!=''"> |
| | | AND MTC.PHONE_NUMBER LIKE CONCAT('%',#{query.phoneNumber},'%') |
| | | </if> |
| | | <if test="query.departmentId!=null and query.departmentId!=''"> |
| | | AND MTC.DEPARTMENT_ID =#{query.departmentId} |
| | | </if> |
| | | </where> |
| | | ORDER BY MTC.CREATE_TIME DESC |
| | | </select> |
| | |
| | | <fastexcel.version>1.0.0</fastexcel.version> |
| | | <aliyun-oss.version>3.17.4</aliyun-oss.version> |
| | | <dysmsapi.version>3.1.0</dysmsapi.version> |
| | | <thumbnailator.version>0.4.8</thumbnailator.version> |
| | | </properties> |
| | | |
| | | <!-- 依赖声明 --> |
| | |
| | | <artifactId>dysmsapi20170525</artifactId> |
| | | <version>${dysmsapi.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.coobird</groupId> |
| | | <artifactId>thumbnailator</artifactId> |
| | | <version>${thumbnailator.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |