mitao
2024-12-10 7a995618d41cc70ddd956a708c91a1a7244b632e
医废管理-导出
9个文件已修改
136 ■■■■■ 已修改文件
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwCollectRecordController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-common/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/query/MwCollectRecordQuery.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/MwCollectRecordVO.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/mapper/MwCollectRecordMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/service/MwCollectRecordService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/resources/mapper/system/MwCollectRecordMapper.xml 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwCollectRecordController.java
@@ -20,7 +20,9 @@
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>
@@ -99,4 +101,20 @@
    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);
        }
    }
}
medicalWaste-common/pom.xml
@@ -142,6 +142,12 @@
            <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>
medicalWaste-system/src/main/java/com/sinata/system/domain/query/MwCollectRecordQuery.java
@@ -7,6 +7,7 @@
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
 * @author mitao
@@ -39,4 +40,7 @@
    @ApiModelProperty("收集时间-结束")
    private Date collectTimeEnd;
    @ApiModelProperty(value = "收集记录id列表", notes = "勾选导出")
    private List<Long> collectRecordIds;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/MwCollectRecordVO.java
@@ -1,5 +1,6 @@
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;
@@ -22,27 +23,32 @@
    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")
@@ -55,6 +61,7 @@
    private Date checkoutTime;
    @ApiModelProperty("医废状态 1:暂存中 2:运输中 3:已接收 4:已处置")
    @ExcelProperty(value = "医废状态", index = 8)
    private Integer status;
    @ApiModelProperty("封箱时间")
@@ -64,8 +71,10 @@
    private Long collectUserId;
    @ApiModelProperty("收集人姓名")
    @ExcelProperty(value = "收集人", index = 7)
    private Long collectUserName;
    @ApiModelProperty("收集时间")
    @ExcelProperty(value = "收集时间", index = 1)
    private Date collectTime;
}
medicalWaste-system/src/main/java/com/sinata/system/mapper/MwCollectRecordMapper.java
@@ -9,6 +9,8 @@
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <p>
 * 暂存间入库记录 Mapper 接口
@@ -42,4 +44,12 @@
     * @return
     */
    MedicalWasteProcessVO getProcess(Long id);
    /**
     * 导出数据
     *
     * @param query
     * @return
     */
    List<MwCollectRecordVO> getExportList(@Param("query") MwCollectRecordQuery query);
}
medicalWaste-system/src/main/java/com/sinata/system/service/MwCollectRecordService.java
@@ -8,6 +8,9 @@
import com.sinata.system.domain.vo.MedicalWasteProcessVO;
import com.sinata.system.domain.vo.MwCollectRecordVO;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * <p>
 * 暂存间入库记录 服务类
@@ -47,4 +50,6 @@
     * @return
     */
    MedicalWasteProcessVO getProcess(Long id);
    void export(MwCollectRecordQuery query, HttpServletResponse response) throws IOException;
}
medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwCollectRecordServiceImpl.java
@@ -1,5 +1,6 @@
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;
@@ -15,6 +16,10 @@
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;
/**
@@ -85,4 +90,16 @@
    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);
    }
}
medicalWaste-system/src/main/resources/mapper/system/MwCollectRecordMapper.xml
@@ -152,5 +152,64 @@
            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>
pom.xml
@@ -34,6 +34,7 @@
        <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>
    <!-- 依赖声明 -->
@@ -207,6 +208,13 @@
                <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>