| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public R<MedicalWasteProcessVO> getProcess(@ApiParam(name = "id", value = "医废追溯id", required = true) @PathVariable("id") Long id) { |
| | | return R.ok(collectRecordService.getProcess(id)); |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | * |
| | | * @param query |
| | | * @param response |
| | | */ |
| | | @PostMapping("/export") |
| | | @ApiOperation("导出") |
| | | public void export(@Valid @RequestBody MwCollectRecordQuery query, HttpServletResponse response) { |
| | | try { |
| | | collectRecordService.export(query, response); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel --> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel("医废追溯查询对象") |
| | | public class MwCollectRecordQuery extends BasePage { |
| | | |
| | | |
| | | private static final long serialVersionUID = -1019864119594661684L; |
| | | |
| | | @ApiModelProperty("机构id") |
| | |
| | | |
| | | @ApiModelProperty("收集时间-结束") |
| | | private Date collectTimeEnd; |
| | | |
| | | @ApiModelProperty(value = "收集记录id列表", notes = "勾选导出") |
| | | private List<Long> collectRecordIds; |
| | | } |
| | |
| | | package com.sinata.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | private Long departmentId; |
| | | |
| | | @ApiModelProperty("医院名称") |
| | | @ExcelProperty(value = "医院", index = 2) |
| | | private String hospitalName; |
| | | |
| | | @ApiModelProperty("暂存间id") |
| | | private Long stagingRoomId; |
| | | |
| | | @ApiModelProperty("医废编号") |
| | | @ExcelProperty(value = "医废编号", index = 3) |
| | | private String medicalWasteNumber; |
| | | |
| | | @ApiModelProperty("转运箱id") |
| | | private Long boxId; |
| | | |
| | | @ApiModelProperty("箱子编号") |
| | | @ExcelProperty(value = "箱子编号", index = 4) |
| | | private String boxNumber; |
| | | |
| | | @ApiModelProperty("医废类型(数据字典id)") |
| | | private Integer wasteType; |
| | | |
| | | @ApiModelProperty("医废类型名称") |
| | | @ExcelProperty(value = "医废类型", index = 5) |
| | | private String wasteTypeStr; |
| | | |
| | | @ApiModelProperty("医废重量") |
| | | @ExcelProperty(value = "医废重量", index = 6) |
| | | private BigDecimal weight; |
| | | |
| | | @ApiModelProperty("出库人员id") |
| | |
| | | private Date checkoutTime; |
| | | |
| | | @ApiModelProperty("医废状态 1:暂存中 2:运输中 3:已接收 4:已处置") |
| | | @ExcelProperty(value = "医废状态", index = 8) |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty("封箱时间") |
| | |
| | | private Long collectUserId; |
| | | |
| | | @ApiModelProperty("收集人姓名") |
| | | @ExcelProperty(value = "收集人", index = 7) |
| | | private Long collectUserName; |
| | | |
| | | @ApiModelProperty("收集时间") |
| | | @ExcelProperty(value = "收集时间", index = 1) |
| | | private Date collectTime; |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 暂存间入库记录 Mapper 接口 |
| | |
| | | * @return |
| | | */ |
| | | MedicalWasteProcessVO getProcess(Long id); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | List<MwCollectRecordVO> getExportList(@Param("query") MwCollectRecordQuery query); |
| | | } |
| | |
| | | import com.sinata.system.domain.vo.MedicalWasteProcessVO; |
| | | import com.sinata.system.domain.vo.MwCollectRecordVO; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * <p> |
| | | * 暂存间入库记录 服务类 |
| | |
| | | * @return |
| | | */ |
| | | MedicalWasteProcessVO getProcess(Long id); |
| | | |
| | | void export(MwCollectRecordQuery query, HttpServletResponse response) throws IOException; |
| | | } |
| | |
| | | package com.sinata.system.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.sinata.common.entity.PageDTO; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | |
| | | public MedicalWasteProcessVO getProcess(Long id) { |
| | | return baseMapper.getProcess(id); |
| | | } |
| | | |
| | | @Override |
| | | public void export(MwCollectRecordQuery query, HttpServletResponse response) throws IOException { |
| | | List<MwCollectRecordVO> vo = baseMapper.getExportList(query); |
| | | // 这里注意 有同学反应使用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"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), MwCollectRecordVO.class).sheet("医废收集记录").doWrite(vo); |
| | | } |
| | | } |
| | |
| | | mcr.ID = #{id} |
| | | </where> |
| | | </select> |
| | | <select id="getExportList" resultType="com.sinata.system.domain.vo.MwCollectRecordVO" |
| | | parameterType="com.sinata.system.domain.query.MwCollectRecordQuery"> |
| | | SELECT mcr.ID, |
| | | mcr.DEPARTMENT_ID, |
| | | mcr.HOSPITAL_NAME, |
| | | mcr.STAGING_ROOM_ID, |
| | | mcr.MEDICAL_WASTE_NUMBER, |
| | | mcr.BOX_ID, |
| | | mcr.BOX_NUMBER, |
| | | mcr.WASTE_TYPE, |
| | | mcr.WASTE_TYPE_STR, |
| | | mcr.WEIGHT, |
| | | mcr.CHECKOUT_USER_ID, |
| | | mcr.CHECKOUT_TIME, |
| | | mcr.STATUS, |
| | | mcr.BOX_TIME, |
| | | mcr.DEL_FLAG, |
| | | mcr.CREATE_BY, |
| | | mcr.CREATE_TIME, |
| | | mcr.UPDATE_BY, |
| | | mcr.UPDATE_TIME, |
| | | mcr.COLLECT_USER_ID, |
| | | mcr.COLLECT_TIME, |
| | | su.NICK_NAME AS COLLECT_USER_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 |
| | | <where> |
| | | <if test="query.departmentId != null"> |
| | | and mcr.DEPARTMENT_ID = #{query.departmentId} |
| | | </if> |
| | | <if test="treeCode != null and treeCode != ''"> |
| | | and sd.TREE_CODE like concat(#{treeCode},'%') |
| | | </if> |
| | | <if test="query.wasteType != null"> |
| | | and mcr.WASTE_TYPE = #{query.wasteType} |
| | | </if> |
| | | <if test="query.status != null"> |
| | | and mcr.STATUS = #{query.status} |
| | | </if> |
| | | <if test="query.medicalWasteNumber != null and query.medicalWasteNumber != ''"> |
| | | and mcr.MEDICAL_WASTE_NUMBER like concat('%',#{query.medicalWasteNumber},'%') |
| | | </if> |
| | | <if test="query.boxNumber != null and query.boxNumber != ''"> |
| | | and mcr.BOX_NUMBER like concat('%',#{query.boxNumber},'%') |
| | | </if> |
| | | <if test="query.collectTimeStart != null and query.collectTimeEnd != null"> |
| | | and mcr.COLLECT_TIME between #{query.collectTimeStart} and #{query.collectTimeEnd} |
| | | </if> |
| | | <if test="collectRecordIds != null and collectRecordIds.size() > 0"> |
| | | and mcr.ID in |
| | | <foreach collection="collectRecordIds" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | ORDER BY mcr.CREATE_TIME DESC |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <mybatis.plus.version>3.5.2</mybatis.plus.version> |
| | | <knife4j.version>3.0.3</knife4j.version> |
| | | <hutool.version>5.7.17</hutool.version> |
| | | <easyexcel.version>4.0.3</easyexcel.version> |
| | | </properties> |
| | | |
| | | <!-- 依赖声明 --> |
| | |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel --> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>${easyexcel.version}</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |