From 3b20b8b1316e47b0d92cc64f965a78d198b29944 Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期五, 18 四月 2025 08:56:15 +0800 Subject: [PATCH] 1.添加设备使用授权 2.报告编制添加导出功能 --- cnas-device/src/main/resources/mapper/DeviceImpowerDetailsMapper.xml | 3 inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java | 14 +++ cnas-device/src/main/resources/mapper/DeviceTraceabilityManagementDetailsMapper.xml | 1 inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java | 9 ++ inspect-server/src/main/resources/mapper/InsReportMapper.xml | 70 +++++++++++++++++ inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java | 53 +++++++++++++ inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportMapper.java | 11 ++ inspect-server/src/main/java/com/ruoyi/inspect/dto/InsReportExport.java | 75 ++++++++++++++++++ 8 files changed, 233 insertions(+), 3 deletions(-) diff --git a/cnas-device/src/main/resources/mapper/DeviceImpowerDetailsMapper.xml b/cnas-device/src/main/resources/mapper/DeviceImpowerDetailsMapper.xml index 6e41e20..18b36c6 100644 --- a/cnas-device/src/main/resources/mapper/DeviceImpowerDetailsMapper.xml +++ b/cnas-device/src/main/resources/mapper/DeviceImpowerDetailsMapper.xml @@ -7,11 +7,10 @@ select did.*, d.device_name, - d.device_name, d.specification_model, d.management_number from device_impower_details did left join device d on did.device_id = d.id - where did.traceability_management_id = #{traceabilityManagementId} + where did.impower_id = #{impowerId} </select> </mapper> diff --git a/cnas-device/src/main/resources/mapper/DeviceTraceabilityManagementDetailsMapper.xml b/cnas-device/src/main/resources/mapper/DeviceTraceabilityManagementDetailsMapper.xml index 7de51b3..6fc4960 100644 --- a/cnas-device/src/main/resources/mapper/DeviceTraceabilityManagementDetailsMapper.xml +++ b/cnas-device/src/main/resources/mapper/DeviceTraceabilityManagementDetailsMapper.xml @@ -7,7 +7,6 @@ select dtmd.*, d.device_name, - d.device_name, d.specification_model, d.management_number from device_traceability_management_details dtmd diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java index a85f42d..a60e47d 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java @@ -167,4 +167,18 @@ Integer id = (Integer) param.get("id"); return Result.success(insReportService.sendBackTask(id)); } + + /** + * 鎶ュ憡瀵煎嚭 + * @param dto + * @param response + * @throws Exception + */ + @ApiOperation(value = "鎶ュ憡瀵煎嚭") + @GetMapping("/reportAllExport") + @PreAuthorize("@ss.hasPermi('business:reportPreparation')") + @PersonalScope(permsName = "business:reportPreparation", objectName = ReportPageDto.class, paramName = "createOrderUser") + public void reportAllExport(ReportPageDto dto, HttpServletResponse response) throws Exception { + insReportService.reportAllExport(dto,response); + } } diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/dto/InsReportExport.java b/inspect-server/src/main/java/com/ruoyi/inspect/dto/InsReportExport.java new file mode 100644 index 0000000..ab41511 --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/dto/InsReportExport.java @@ -0,0 +1,75 @@ +package com.ruoyi.inspect.dto; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author zhuo + * @Date 2025/4/18 + */ +@Data +@ExcelIgnoreUnannotated +public class InsReportExport { + + @ExcelProperty(value = "鎶ュ憡缂栧彿") + @ApiModelProperty("濮旀墭缂栧彿") + private String code; + + @ExcelProperty(value = "涓嬪崟绫诲瀷") + @ApiModelProperty("涓嬪崟绫诲瀷") + private String typeSource; + + @ExcelProperty(value = "妫�楠岀被鍨�") + @ApiModelProperty("妫�楠岀被鍨�") + private String orderType; + + @ExcelProperty(value = "鍒涘缓鏃堕棿") + @ApiModelProperty("鍒涘缓鏃堕棿") + private String createTime; + + @ExcelProperty(value = "鎻愪氦浜�") + @ApiModelProperty("鎻愪氦浜�") + private String writeUserName; + + @ExcelProperty(value = "鎻愪氦鏃堕棿") + @ApiModelProperty("鎻愪氦鏃堕棿") + private String writeTime; + + @ExcelProperty(value = "鎻愪氦鐘舵��") + @ApiModelProperty("鎻愪氦鐘舵��") + private String state; + + @ExcelProperty(value = "瀹℃牳浜�") + @ApiModelProperty("瀹℃牳浜�") + private String examineUser; + + @ExcelProperty(value = "瀹℃牳鏃堕棿") + @ApiModelProperty("瀹℃牳鏃堕棿") + private String examineTime; + + @ExcelProperty(value = "瀹℃牳鐘舵��") + @ApiModelProperty("瀹℃牳鐘舵��") + private String isExamine; + + @ExcelProperty(value = "瀹℃牳澶囨敞") + @ApiModelProperty("瀹℃牳澶囨敞") + private String examineTell; + + @ExcelProperty(value = "鎵瑰噯浜�") + @ApiModelProperty("鎵瑰噯浜�") + private String ratifyUser; + + @ExcelProperty(value = "鎵瑰噯鏃堕棿") + @ApiModelProperty("鎵瑰噯鏃堕棿") + private String ratifyTime; + + @ExcelProperty(value = "鎵瑰噯鐘舵��") + @ApiModelProperty("鎵瑰噯鐘舵��") + private String isRatify; + + @ExcelProperty(value = "鎵瑰噯澶囨敞") + @ApiModelProperty("鎵瑰噯澶囨敞") + private String ratifyTell; +} diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportMapper.java index 3f6176e..99c120f 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportMapper.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsReportMapper.java @@ -3,9 +3,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.inspect.dto.InsReportExport; import com.ruoyi.inspect.dto.ReportPageDto; import com.ruoyi.inspect.pojo.InsReport; import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @author Administrator @@ -31,6 +34,14 @@ String getLaboratoryByName(@Param("name") String name, @Param("type") String type); + /** + * 鎶ュ憡鎶ヨ〃瀵煎嚭 + * @return + */ + List<InsReportExport> reportAllExport(@Param("ew") QueryWrapper<ReportPageDto> ew, + @Param("userId") Integer userId, + @Param("queryStatus") String queryStatus, + @Param("createOrderUser") Integer createOrderUser); } diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java index c082507..0959257 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java @@ -8,7 +8,9 @@ import com.ruoyi.inspect.pojo.InsReport; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.Map; /** @@ -58,4 +60,11 @@ * @return */ boolean sendBackTask(Integer id); + + /** + * 鎶ュ憡瀵煎嚭 + * @param dto + * @param response + */ + void reportAllExport(ReportPageDto dto, HttpServletResponse response) throws UnsupportedEncodingException; } diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java index 8df0b56..9c08968 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java @@ -1,11 +1,17 @@ package com.ruoyi.inspect.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.aspose.words.License; import com.aspose.words.SaveFormat; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -19,6 +25,7 @@ import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.pdf.PdfStamper; +import com.ruoyi.basic.dto.IfsInventoryQuantitySupplierDto; import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; import com.ruoyi.basic.pojo.IfsInventoryQuantity; import com.ruoyi.common.constant.InsOrderTypeConstants; @@ -29,6 +36,7 @@ import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.api.IfsApiUtils; import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.inspect.dto.InsReportExport; import com.ruoyi.inspect.dto.ReportPageDto; import com.ruoyi.inspect.mapper.*; import com.ruoyi.inspect.pojo.*; @@ -48,8 +56,10 @@ import javax.annotation.Resource; import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.*; +import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -988,6 +998,49 @@ return false; } + /** + * 鎶ュ憡鎶ヨ〃瀵煎嚭 + * @param dto + * @param response + */ + @Override + public void reportAllExport(ReportPageDto dto, HttpServletResponse response) throws UnsupportedEncodingException { + //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹� + + //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id + + Integer createOrderUser = dto.getCreateOrderUser(); + String queryStatus = dto.getQueryStatus(); + dto.setQueryStatus(null); + dto.setCreateOrderUser(null); + + List<InsReportExport> insReportExports = insReportMapper.reportAllExport(QueryWrappers.queryWrappers(dto), + SecurityUtils.getUserId().intValue(), + queryStatus, + createOrderUser); + + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 + String fileName = URLEncoder.encode("鎶ュ憡鎶ヨ〃瀵煎嚭", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + try { + //鏂板缓ExcelWriter + ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); + //鑾峰彇sheet0瀵硅薄 + WriteSheet mainSheet = EasyExcel.writerSheet(0, "鎶ュ憡鎶ヨ〃瀵煎嚭").head(InsReportExport.class).build(); + + //鍚憇heet0鍐欏叆鏁版嵁 浼犲叆绌簂ist杩欐牱鍙鍑鸿〃澶� + excelWriter.write(insReportExports, mainSheet); + //鍏抽棴娴� + excelWriter.finish(); + } catch (IOException e) { + throw new RuntimeException("瀵煎嚭澶辫触"); + } + + + } + /** * 鍏堜慨鏀归噰璐鍗曟壒娆″彿, 鍚庤繘琛岀Щ搴撴搷浣� diff --git a/inspect-server/src/main/resources/mapper/InsReportMapper.xml b/inspect-server/src/main/resources/mapper/InsReportMapper.xml index f4b741e..fa58164 100644 --- a/inspect-server/src/main/resources/mapper/InsReportMapper.xml +++ b/inspect-server/src/main/resources/mapper/InsReportMapper.xml @@ -64,4 +64,74 @@ order by s.create_time desc limit 1 </select> + + <!-- 鎶ュ憡鎶ヨ〃瀵煎嚭 --> + <select id="reportAllExport" resultType="com.ruoyi.inspect.dto.InsReportExport"> + select code, + case when type_source = 0 then '鎴愬搧涓嬪崟' else '鍘熸潗鏂欎笅鍗�' end type_source, + case + when order_type = '鎶芥' then '鎶芥' + when order_type = 'Customer-ordered test' then '濮旀墭妫�楠�' + when order_type = '杩涘巶妫�楠�' then '杩涘巶妫�楠�' + when order_type = 'Quarterly inspection' then '瀛e害妫�楠�' + else '' end order_type, + DATE_FORMAT(create_Time, '%Y-%m-%d %H:%i:%s') create_Time, + write_user_name, + DATE_FORMAT(write_time, '%Y-%m-%d %H:%i:%s') write_time, + case when state = 0 then '寰呮彁浜�' when state = 1 then '宸叉彁浜�' else '' end state, + examine_user, + DATE_FORMAT(examine_time, '%Y-%m-%d %H:%i:%s') examine_time, + case when is_examine = 0 then '涓嶉�氳繃' when is_examine = 1 then '閫氳繃' else '' end is_examine, + examine_tell, + ratify_user, + DATE_FORMAT(ratify_time, '%Y-%m-%d %H:%i:%s') ratify_time, + case when is_ratify = 0 then '涓嶆壒鍑�' when is_ratify = 1 then '鎵瑰噯' else '' end is_ratify, + ratify_tell + from ( + select + ir.*, + io.entrust_code, + u.name write_user_name, + u1.name ratify_user, + u2.name examine_user, + io.type_source, + io.order_type, + io.laboratory, + io.ifs_inventory_id, + iiq.is_copper, + ip.son_laboratory + from ins_report ir + left join ins_order io on io.id = ir.ins_order_id + LEFT JOIN ifs_inventory_quantity iiq ON iiq.id = io.ifs_inventory_id + left join user u on u.id = ir.write_user_id + left join user u1 on u1.id = ir.ratify_user_id + left join user u2 on u2.id = ir.examine_user_id + left join ins_sample is2 on is2.ins_order_id = io.id + left join ins_product ip on ip.ins_sample_id = is2.id + where 1=1 + and ir.is_pass = 1 + <if test="createOrderUser != null and createOrderUser != ''"> + and (ir.write_user_id = #{createOrderUser} or ir.examine_user_id = #{createOrderUser} or ir.ratify_user_id = #{createOrderUser}) + </if> + <if test="queryStatus != null and queryStatus != ''"> + <!-- 寰呮彁浜�--> + <if test='queryStatus == 0'> + and ir.state = 0 + </if> + <!-- 寰呭鎵�--> + <if test='queryStatus == 1'> + and ir.state = 1 and (ir.is_examine != 1 or ir.is_examine is null) + </if> + <!-- 寰呮壒鍑�--> + <if test='queryStatus == 2'> + and ir.state = 1 and ir.is_examine = 1 and (ir.is_ratify != 1 or ir.is_ratify is null) + </if> + </if> + group by ir.id + ) a + <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> + ${ew.customSqlSegment} + </if> + ORDER BY a.create_time DESC + </select> </mapper> -- Gitblit v1.9.3