设备导出支持按筛选条件导出
- 仪器设备一览表导出: 支持设备名称/管理编号/状态/设备分类筛选, 无筛选时导出全部
- 设备使用记录导出: 支持样品编号/管理编号筛选; 未选中具体设备时可导出全部设备记录
| | |
| | | |
| | | @Operation(summary = "仪器设备一览表导出") |
| | | @GetMapping("/exportEquipmentDetails") |
| | | public void exportEquipmentDetails(HttpServletResponse response) { |
| | | deviceService.exportEquipmentDetails(response); |
| | | public void exportEquipmentDetails(DeviceDto itemParameter, HttpServletResponse response) { |
| | | deviceService.exportEquipmentDetails(itemParameter, response); |
| | | } |
| | | |
| | | @Operation(summary = "下载设备导入模板") |
| | |
| | | |
| | | @Operation(summary = "设备使用记录导出") |
| | | @GetMapping("/exportUseRecord") |
| | | public void exportUseRecord(Integer deviceId, String exportDate, HttpServletResponse response){ |
| | | deviceRecordService.exportUseRecord(deviceId, exportDate, response); |
| | | public void exportUseRecord(Integer deviceId, String sampleCode, String managementNumber, String exportDate, HttpServletResponse response){ |
| | | deviceRecordService.exportUseRecord(deviceId, sampleCode, managementNumber, exportDate, response); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 查询导出设备使用记录 |
| | | * @param deviceId |
| | | * @param sampleCode 样品编号筛选 |
| | | * @param managementNumber 管理编号筛选 |
| | | * @param exportDate |
| | | * @return |
| | | */ |
| | | List<DeviceRecord> selectExportList(@Param("deviceId") Integer deviceId, @Param("exportDate") String exportDate); |
| | | List<DeviceRecord> selectExportList(@Param("deviceId") Integer deviceId, @Param("sampleCode") String sampleCode, @Param("managementNumber") String managementNumber, @Param("exportDate") String exportDate); |
| | | } |
| | |
| | | * 导出设备使用记录 |
| | | * |
| | | * @param deviceId |
| | | * @param sampleCode 样品编号筛选 |
| | | * @param managementNumber 管理编号筛选 |
| | | * @param exportDate 导出月份 |
| | | * @param response |
| | | */ |
| | | void exportUseRecord(Integer deviceId, String exportDate, HttpServletResponse response); |
| | | void exportUseRecord(Integer deviceId, String sampleCode, String managementNumber, String exportDate, HttpServletResponse response); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 导出设备工具明细 |
| | | * @param itemParameter 导出筛选条件(设备名称/管理编号/状态/设备分类), 为空时导出全部 |
| | | * @param response |
| | | */ |
| | | void exportEquipmentDetails(HttpServletResponse response); |
| | | void exportEquipmentDetails(DeviceDto itemParameter, HttpServletResponse response); |
| | | |
| | | void downloadImportTemplate(HttpServletResponse response); |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public void exportUseRecord(Integer deviceId, String exportDate, HttpServletResponse response) { |
| | | // 查询cnas设备使用记录 |
| | | List<DeviceRecord> deviceList = baseMapper.selectExportList(deviceId, exportDate); |
| | | // 设备信息 |
| | | Device device = deviceMapper.selectById(deviceId); |
| | | public void exportUseRecord(Integer deviceId, String sampleCode, String managementNumber, String exportDate, HttpServletResponse response) { |
| | | // 查询cnas设备使用记录(按当前筛选条件, 条件为空时导出全部) |
| | | List<DeviceRecord> deviceList = baseMapper.selectExportList(deviceId, sampleCode, managementNumber, exportDate); |
| | | // 设备信息(未选中具体设备时导出全部设备的记录, 设备信息留空) |
| | | Device device = deviceId == null ? null : deviceMapper.selectById(deviceId); |
| | | |
| | | |
| | | // 查询设备属于哪个实验室 |
| | |
| | | Configure configure = Configure.builder() |
| | | .bind("useRecord", new HackLoopTableRenderPolicy()) |
| | | .build(); |
| | | String deviceName = device.getDeviceName(); |
| | | String managementNumber = device.getManagementNumber(); |
| | | String deviceName = device == null ? "" : device.getDeviceName(); |
| | | String deviceManagementNumber = device == null ? "" : device.getManagementNumber(); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("useRecord", deviceExportList); |
| | | put("deviceName", deviceName); |
| | | put("managementNumber", managementNumber); |
| | | put("managementNumber", deviceManagementNumber); |
| | | put("laboratory", laboratoryName); |
| | | }}); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void exportEquipmentDetails(HttpServletResponse response) { |
| | | List<Device> deviceList = baseMapper.selectList(null); |
| | | public void exportEquipmentDetails(DeviceDto itemParameter, HttpServletResponse response) { |
| | | // 按当前筛选条件导出(条件为空时导出全部) |
| | | List<Device> deviceList = baseMapper.selectList(QueryWrappers.<Device>queryWrappers(itemParameter)); |
| | | List<DeviceExport> deviceExportList = new ArrayList<>(); |
| | | |
| | | int index = 1; |
| | |
| | | <select id="selectExportList" resultType="com.ruoyi.device.dto.DeviceRecordDto"> |
| | | select dr.* |
| | | from device_record dr |
| | | left join device d on d.id = dr.device_id |
| | | where dr.use_start_date is not null |
| | | <if test="deviceId != null"> |
| | | and dr.device_id = #{deviceId} |
| | | </if> |
| | | <if test="sampleCode != '' and sampleCode != null"> |
| | | and dr.sample_code like concat('%', #{sampleCode}, '%') |
| | | </if> |
| | | <if test="managementNumber != '' and managementNumber != null"> |
| | | and d.management_number like concat('%', #{managementNumber}, '%') |
| | | </if> |
| | | <if test="exportDate != '' and exportDate != null"> |
| | | and DATE_FORMAT(dr.use_start_date, '%Y-%m') = #{exportDate} |
| | | </if> |