修复人员管理接口校验与导出,完善设备保养计划与文件受控功能
- 人员管理:补齐新增、修改、删除、提交、确认等校验,修复导出与消息通知,任职授权记录按 JL04 上岗证模板导出
- 设备保养计划:支持明细附件,完善提醒与导出
- 文件受控:增加发布日期、实施日期及批量导入,调整变更、作废、发放回收逻辑
- 原始记录与设备使用记录联动:环境条件、使用时间回填
- lims_delta.sql 补充设备保养附件表及文件受控日期字段,新增数据修复脚本
| | |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.device.dto.DeviceMaintenancePlanDetailsDto; |
| | | import com.ruoyi.device.dto.DeviceMaintenancePlanDto; |
| | | import com.ruoyi.device.pojo.DeviceMaintenanceAttachment; |
| | | import com.ruoyi.device.pojo.DeviceMaintenancePlan; |
| | | import com.ruoyi.device.pojo.DeviceMaintenancePlanDetails; |
| | | import com.ruoyi.device.service.DeviceMaintenancePlanService; |
| | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | */ |
| | | @Operation(summary = "导åºè®¾å¤ä¿å
»è®¡å") |
| | | @GetMapping("/exportDeviceMaintenancePlan") |
| | | public Result exportDeviceMaintenancePlan(@RequestParam("maintenancePlanId") Integer maintenancePlanId, HttpServletResponse response) { |
| | | public Result exportDeviceMaintenancePlan(@RequestParam("maintenancePlanId") Integer maintenancePlanId, |
| | | HttpServletResponse response) { |
| | | return deviceMaintenancePlanService.exportDeviceMaintenancePlanDto(maintenancePlanId, response); |
| | | } |
| | | |
| | |
| | | public Result reviewMaintenancePlanStatus(@RequestBody DeviceMaintenancePlanDto deviceMaintenancePlanDto) { |
| | | return deviceMaintenancePlanService.reviewMaintenancePlanStatus(deviceMaintenancePlanDto); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¿å
»è®¡åæç»éä»¶ |
| | | */ |
| | | @Operation(summary = "æ¥è¯¢ä¿å
»è®¡åæç»éä»¶") |
| | | @GetMapping("/selectAttachments") |
| | | public Result<List<DeviceMaintenanceAttachment>> selectAttachments(Integer maintenancePlanDetailId) { |
| | | return Result.success(deviceMaintenancePlanService.selectAttachments(maintenancePlanDetailId)); |
| | | } |
| | | |
| | | /** |
| | | * ä¸ä¼ ä¿å
»è®¡åæç»éä»¶ |
| | | */ |
| | | @Operation(summary = "ä¸ä¼ ä¿å
»è®¡åæç»éä»¶") |
| | | @PostMapping("/uploadAttachment") |
| | | public Result uploadAttachment(@RequestParam("maintenancePlanDetailId") Integer maintenancePlanDetailId, |
| | | @RequestParam("file") MultipartFile file) { |
| | | return Result.success(deviceMaintenancePlanService.uploadAttachment(maintenancePlanDetailId, file)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä¿å
»è®¡åæç»éä»¶ |
| | | */ |
| | | @Operation(summary = "å é¤ä¿å
»è®¡åæç»éä»¶") |
| | | @DeleteMapping("/deleteAttachment") |
| | | public Result deleteAttachment(Long id) { |
| | | return Result.success(deviceMaintenancePlanService.deleteAttachment(id)); |
| | | } |
| | | } |
| | |
| | | |
| | | @Operation(summary = "å¤ä½¿ç¨è®°å½æ¥è¯¢") |
| | | @GetMapping("/deviceRecordPage") |
| | | public Result deviceRecordPage(Integer deviceId, Page page, String sampleCode, String managementNumber) { |
| | | return Result.success(deviceRecordService.deviceRecordPage(deviceId, page, sampleCode, managementNumber)); |
| | | public Result deviceRecordPage(Integer deviceId, Page page, String deviceName, |
| | | String specificationModel, String sampleCode, String managementNumber) { |
| | | return Result.success(deviceRecordService.deviceRecordPage( |
| | | deviceId, page, deviceName, specificationModel, sampleCode, managementNumber)); |
| | | } |
| | | |
| | | @Operation(summary = "æ°å¢") |
| | |
| | | |
| | | @Operation(summary = "设å¤ä½¿ç¨è®°å½å¯¼åº") |
| | | @GetMapping("/exportUseRecord") |
| | | public void exportUseRecord(Integer deviceId, String sampleCode, String managementNumber, String exportDate, HttpServletResponse response){ |
| | | deviceRecordService.exportUseRecord(deviceId, sampleCode, managementNumber, exportDate, response); |
| | | public void exportUseRecord(Integer deviceId, String deviceName, String specificationModel, |
| | | String managementNumber, String sampleCode, HttpServletResponse response) { |
| | | deviceRecordService.exportUseRecord( |
| | | deviceId, deviceName, specificationModel, managementNumber, sampleCode, response); |
| | | } |
| | | } |
| | |
| | | |
| | | @Schema(description = "å®¡æ ¸æ¶é´") |
| | | private LocalDateTime reviewTime; |
| | | |
| | | @Schema(description = "éä»¶æ°é") |
| | | private Integer attachmentCount; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.device.pojo.DeviceMaintenanceAttachment; |
| | | |
| | | public interface DeviceMaintenanceAttachmentMapper extends BaseMapper<DeviceMaintenanceAttachment> { |
| | | } |
| | |
| | | */ |
| | | public interface DeviceRecordMapper extends BaseMapper<DeviceRecord> { |
| | | |
| | | IPage<DeviceRecordDto> deviceRecordPage(@Param("deviceId") Integer deviceId, @Param("page") Page page, @Param("sampleCode") String sampleCode, @Param("managementNumber") String managementNumber, @Param("userId") Integer userId); |
| | | IPage<DeviceRecordDto> deviceRecordPage(@Param("deviceId") Integer deviceId, @Param("page") Page page, |
| | | @Param("deviceName") String deviceName, |
| | | @Param("specificationModel") String specificationModel, |
| | | @Param("sampleCode") String sampleCode, |
| | | @Param("managementNumber") String managementNumber, |
| | | @Param("userId") Integer userId); |
| | | |
| | | |
| | | /** |
| | |
| | | /** |
| | | * æ¥è¯¢å¯¼åºè®¾å¤ä½¿ç¨è®°å½ |
| | | * @param deviceId |
| | | * @param deviceName 设å¤åç§°çé |
| | | * @param specificationModel 设å¤åå·çé |
| | | * @param managementNumber 设å¤ç¼å·çé |
| | | * @param sampleCode æ ·åç¼å·çé |
| | | * @param managementNumber 管çç¼å·çé |
| | | * @param exportDate |
| | | * @return |
| | | */ |
| | | List<DeviceRecordDto> selectExportList(@Param("deviceId") Integer deviceId, @Param("sampleCode") String sampleCode, @Param("managementNumber") String managementNumber, @Param("exportDate") String exportDate); |
| | | List<DeviceRecordDto> selectExportList(@Param("deviceId") Integer deviceId, |
| | | @Param("deviceName") String deviceName, |
| | | @Param("specificationModel") String specificationModel, |
| | | @Param("managementNumber") String managementNumber, |
| | | @Param("sampleCode") String sampleCode); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @TableName("device_maintenance_attachment") |
| | | public class DeviceMaintenanceAttachment { |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | private Integer maintenancePlanDetailId; |
| | | private String fileName; |
| | | private String fileUrl; |
| | | private Integer sort; |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | } |
| | |
| | | import com.ruoyi.device.dto.DeviceMaintenancePlanDetailsDto; |
| | | import com.ruoyi.device.dto.DeviceMaintenancePlanDto; |
| | | import com.ruoyi.device.pojo.Device; |
| | | import com.ruoyi.device.pojo.DeviceMaintenanceAttachment; |
| | | import com.ruoyi.device.pojo.DeviceMaintenancePlan; |
| | | import com.ruoyi.device.pojo.DeviceMaintenancePlanDetails; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.time.LocalDate; |
| | |
| | | * å é¤è®¾å¤ä¿å
»è®¡å详æ
ï¼å·²åºå®¡æ ¸ç»æçè®°å½éåå²çæ¡£ï¼æªå®¡æ ¸çè®°å½éæç»ä¸èµ·å é¤ |
| | | */ |
| | | boolean removeMaintenancePlanDetail(Integer maintenancePlanDetailId); |
| | | |
| | | /** |
| | | * æ¥è¯¢è®¡åæç»éä»¶å表 |
| | | */ |
| | | List<DeviceMaintenanceAttachment> selectAttachments(Integer maintenancePlanDetailId); |
| | | |
| | | /** |
| | | * ä¸ä¼ 计åæç»éä»¶ |
| | | */ |
| | | DeviceMaintenanceAttachment uploadAttachment(Integer maintenancePlanDetailId, MultipartFile file); |
| | | |
| | | /** |
| | | * å é¤è®¡åæç»éä»¶ |
| | | */ |
| | | boolean deleteAttachment(Long id); |
| | | } |
| | |
| | | */ |
| | | public interface DeviceRecordService extends IService<DeviceRecord> { |
| | | |
| | | IPage<DeviceRecordDto> deviceRecordPage(Integer deviceId, Page page, String sampleCode, String managementNumber); |
| | | IPage<DeviceRecordDto> deviceRecordPage(Integer deviceId, Page page, String deviceName, |
| | | String specificationModel, String sampleCode, String managementNumber); |
| | | |
| | | |
| | | /** |
| | | * 导åºè®¾å¤ä½¿ç¨è®°å½ |
| | | * |
| | | * @param deviceId |
| | | * @param deviceName 设å¤åç§°çé |
| | | * @param specificationModel 设å¤åå·çé |
| | | * @param managementNumber 设å¤ç¼å·çé |
| | | * @param sampleCode æ ·åç¼å·çé |
| | | * @param managementNumber 管çç¼å·çé |
| | | * @param exportDate å¯¼åºæä»½ |
| | | * @param response |
| | | */ |
| | | void exportUseRecord(Integer deviceId, String sampleCode, String managementNumber, String exportDate, HttpServletResponse response); |
| | | void exportUseRecord(Integer deviceId, String deviceName, String specificationModel, |
| | | String managementNumber, String sampleCode, HttpServletResponse response); |
| | | } |
| | |
| | | import com.ruoyi.common.utils.WxCpUtils; |
| | | import com.ruoyi.device.dto.DeviceMaintenancePlanDetailsDto; |
| | | import com.ruoyi.device.dto.DeviceMaintenancePlanDto; |
| | | import com.ruoyi.device.mapper.DeviceMaintenanceAttachmentMapper; |
| | | import com.ruoyi.device.mapper.DeviceMaintenanceMapper; |
| | | import com.ruoyi.device.mapper.DeviceMaintenancePlanDetailsMapper; |
| | | import com.ruoyi.device.mapper.DeviceMaintenancePlanMapper; |
| | | import com.ruoyi.device.mapper.DeviceMapper; |
| | | import com.ruoyi.device.pojo.Device; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.pojo.DeviceMaintenanceAttachment; |
| | | import com.ruoyi.device.pojo.DeviceMaintenancePlan; |
| | | import com.ruoyi.device.pojo.DeviceMaintenancePlanDetails; |
| | | import com.ruoyi.device.service.DeviceMaintenancePlanDetailsService; |
| | |
| | | import com.ruoyi.system.service.InformationNotificationService; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | private DeviceMapper deviceMapper; |
| | | @Resource |
| | | private DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | @Resource |
| | | private DeviceMaintenanceAttachmentMapper deviceMaintenanceAttachmentMapper; |
| | | |
| | | @Value("${file.path}") |
| | | private String filePath; |
| | | |
| | | @Value("${wordUrl}") |
| | | private String wordUrl; |
| | | |
| | | /** |
| | | * å页æ¥è¯¢è®¾å¤ä¿å
»è®¡å |
| | |
| | | } |
| | | this.saveOrUpdate(deviceMaintenancePlanDto); |
| | | |
| | | // å é¤åæ¬ç详æ
|
| | | // å é¤åæ¬ç详æ
ï¼æç»é建åä»ä¿çåæç»idçé件䏿¸
çï¼idä¸¢å¤±çææ¸
ç |
| | | List<DeviceMaintenancePlanDetails> oldDetails = deviceMaintenancePlanDetailsService.list( |
| | | Wrappers.<DeviceMaintenancePlanDetails>lambdaQuery() |
| | | .eq(DeviceMaintenancePlanDetails::getMaintenancePlanId, deviceMaintenancePlanDto.getMaintenancePlanId())); |
| | | deviceMaintenancePlanDetailsService.remove(Wrappers.<DeviceMaintenancePlanDetails>lambdaQuery().eq(DeviceMaintenancePlanDetails::getMaintenancePlanId, deviceMaintenancePlanDto.getMaintenancePlanId())); |
| | | List<Integer> lostDetailIds = oldDetails.stream().map(DeviceMaintenancePlanDetails::getMaintenancePlanDetailId) |
| | | .collect(Collectors.toList()); |
| | | // 详æ
èµå¼å¹¶ä¿å |
| | | List<DeviceMaintenancePlanDetailsDto> deviceMaintenancePlanDetails = deviceMaintenancePlanDto.getDeviceMaintenancePlanDetails(); |
| | | if (CollectionUtils.isNotEmpty(deviceMaintenancePlanDetails)) { // 详æ
ä¸ä¸ºç©º |
| | | List<Integer> keptDetailIds = deviceMaintenancePlanDetails.stream() |
| | | .map(DeviceMaintenancePlanDetails::getMaintenancePlanDetailId) |
| | | .filter(id -> id != null) |
| | | .collect(Collectors.toList()); |
| | | lostDetailIds.removeAll(keptDetailIds); |
| | | List<DeviceMaintenancePlanDetails> collect = deviceMaintenancePlanDetails.stream().map(deviceMaintenancePlanDetail -> { // éå详æ
|
| | | deviceMaintenancePlanDetail.setDeviceId(deviceMaintenancePlanDto.getDeviceId()); // 设å¤ID |
| | | deviceMaintenancePlanDetail.setMaintenancePlanId(deviceMaintenancePlanDto.getMaintenancePlanId()); // ä¿å
»è®¡åID |
| | | DeviceMaintenancePlanDetails planDetails = new DeviceMaintenancePlanDetails(); |
| | | BeanUtils.copyProperties(deviceMaintenancePlanDetail, planDetails); |
| | |
| | | }).collect(Collectors.toList()); |
| | | deviceMaintenancePlanDetailsService.saveBatch(collect); |
| | | } |
| | | removeAttachmentsByDetailIds(lostDetailIds); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public Result deleteMaintenancePlan(DeviceMaintenancePlanDto deviceMaintenancePlanDto) { |
| | | List<DeviceMaintenancePlanDetails> details = deviceMaintenancePlanDetailsService.list( |
| | | Wrappers.<DeviceMaintenancePlanDetails>lambdaQuery() |
| | | .eq(DeviceMaintenancePlanDetails::getMaintenancePlanId, deviceMaintenancePlanDto.getMaintenancePlanId())); |
| | | this.removeById(deviceMaintenancePlanDto); |
| | | deviceMaintenancePlanDetailsService.remove(Wrappers.<DeviceMaintenancePlanDetails>lambdaQuery().eq(DeviceMaintenancePlanDetails::getMaintenancePlanId, deviceMaintenancePlanDto.getMaintenancePlanId())); |
| | | removeAttachmentsByDetailIds(details.stream().map(DeviceMaintenancePlanDetails::getMaintenancePlanDetailId).collect(Collectors.toList())); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | // æ¥è¯¢è®¾å¤ä¿å
»è®¡å |
| | | DeviceMaintenancePlanDto deviceMaintenancePlan = baseMapper.selectMaintenancePlanById(maintenancePlanId); |
| | | |
| | | // æ¥è¯¢è®¾å¤ä¿å
»è®¡å详æ
|
| | | List<DeviceMaintenancePlanDetailsDto> deviceMaintenancePlanDetailsDtoList = deviceMaintenancePlanDetailsMapper.deviceInspectionRecordDetailsList(maintenancePlanId); |
| | | // æ¥è¯¢è®¾å¤ä¿å
»è®¡å详æ
ï¼æâè®¾å¤ + ä¿å
»æä»½âå
åºå»é |
| | | List<DeviceMaintenancePlanDetailsDto> deviceMaintenancePlanDetailsDtoList = dedupeMaintenanceDetails( |
| | | deviceMaintenancePlanDetailsMapper.deviceInspectionRecordDetailsList(maintenancePlanId)); |
| | | // 设置åºå· |
| | | deviceMaintenancePlanDetailsDtoList.forEach(deviceInspectionRecordDetails -> { |
| | | deviceInspectionRecordDetails.setIndex(deviceMaintenancePlanDetailsDtoList.indexOf(deviceInspectionRecordDetails) + 1); |
| | | }); |
| | | for (int i = 0; i < deviceMaintenancePlanDetailsDtoList.size(); i++) { |
| | | deviceMaintenancePlanDetailsDtoList.get(i).setIndex(i + 1); |
| | | } |
| | | |
| | | // è·åè·¯å¾ |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/word/maintenance-plan.docx"); |
| | | Configure configure = Configure.builder() |
| | | .bind("deviceMaintenancePlanDetailsDtoList", new HackLoopTableRenderPolicy()) |
| | | .build(); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("deviceMaintenancePlan", deviceMaintenancePlan); |
| | | put("deviceMaintenancePlanDetailsDtoList", deviceMaintenancePlanDetailsDtoList); |
| | | // ç¼å¶äººç¾åå°å |
| | | put("compilerUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceMaintenancePlan.getCompilerId())); |
| | | // å®¡æ ¸äººç¾åå°å |
| | | put("auditUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceMaintenancePlan.getAuditId())); |
| | | }}); |
| | | Map<String, Object> renderData = new HashMap<>(); |
| | | renderData.put("deviceMaintenancePlan", deviceMaintenancePlan); |
| | | renderData.put("deviceMaintenancePlanDetailsDtoList", deviceMaintenancePlanDetailsDtoList); |
| | | // ç¼å¶äººç¾åå°å |
| | | renderData.put("compilerUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceMaintenancePlan.getCompilerId())); |
| | | // å®¡æ ¸äººç¾åå°å |
| | | renderData.put("auditUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceMaintenancePlan.getAuditId())); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(renderData); |
| | | |
| | | try { |
| | | response.setContentType("application/msword"); |
| | |
| | | // æ¥è¯¢è¯¦æ
|
| | | DeviceMaintenancePlanDto deviceMaintenancePlanDto = new DeviceMaintenancePlanDto(); |
| | | BeanUtils.copyProperties(deviceMaintenancePlan, deviceMaintenancePlanDto); |
| | | deviceMaintenancePlanDto.setDeviceMaintenancePlanDetails(deviceMaintenancePlanDetailsMapper.deviceInspectionRecordDetailsList(maintenancePlanId)); |
| | | deviceMaintenancePlanDto.setDeviceMaintenancePlanDetails(dedupeMaintenanceDetails( |
| | | deviceMaintenancePlanDetailsMapper.deviceInspectionRecordDetailsList(maintenancePlanId))); |
| | | return Result.success(deviceMaintenancePlanDto); |
| | | } |
| | | |
| | |
| | | List<Integer> recordIds = records.stream().map(DeviceMaintenance::getId).collect(Collectors.toList()); |
| | | deviceMaintenanceMapper.deleteBatchIds(recordIds); |
| | | } |
| | | removeAttachmentsByDetailIds(List.of(maintenancePlanDetailId)); |
| | | return deviceMaintenancePlanDetailsMapper.deleteById(maintenancePlanDetailId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceMaintenanceAttachment> selectAttachments(Integer maintenancePlanDetailId) { |
| | | if (maintenancePlanDetailId == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return deviceMaintenanceAttachmentMapper.selectList(Wrappers.<DeviceMaintenanceAttachment>lambdaQuery() |
| | | .eq(DeviceMaintenanceAttachment::getMaintenancePlanDetailId, maintenancePlanDetailId) |
| | | .orderByAsc(DeviceMaintenanceAttachment::getSort, DeviceMaintenanceAttachment::getId)); |
| | | } |
| | | |
| | | @Override |
| | | public DeviceMaintenanceAttachment uploadAttachment(Integer maintenancePlanDetailId, MultipartFile file) { |
| | | if (maintenancePlanDetailId == null) { |
| | | throw new ErrorException("缺å°ä¿å
»è®¡åæç»id"); |
| | | } |
| | | if (deviceMaintenancePlanDetailsMapper.selectById(maintenancePlanDetailId) == null) { |
| | | throw new ErrorException("ä¿å
»è®¡åæç»ä¸åå¨"); |
| | | } |
| | | if (file == null || file.isEmpty()) { |
| | | throw new ErrorException("éä»¶ä¸è½ä¸ºç©º"); |
| | | } |
| | | // ç³»ç»å
¨å±ä¸ä¼ ä¸é为200MBï¼è¿éæåç»åºå好æç¤º |
| | | if (file.getSize() > 200L * 1024 * 1024) { |
| | | throw new ErrorException("éä»¶ä¸è½è¶
è¿200MB"); |
| | | } |
| | | String originalName = file.getOriginalFilename(); |
| | | if (originalName == null || originalName.trim().isEmpty()) { |
| | | originalName = "æªå½åæä»¶"; |
| | | } |
| | | // ä¸ªå«æµè§å¨å¯è½å¸¦ä¸è·¯å¾åç¼ï¼åªä¿çæä»¶åæ¬èº« |
| | | originalName = originalName.replaceAll(".*[/\\\\]", ""); |
| | | try { |
| | | // å¾çæ¾å¾çç®å½ï¼/img éæè·¯å¾ï¼ï¼å
¶ä½ä»»ææ ¼å¼æ¾ word ç®å½ï¼/word éæè·¯å¾ï¼ |
| | | boolean image = originalName.matches("(?i).+\\.(jpg|jpeg|png|gif)$"); |
| | | File directory = new File(image ? filePath : wordUrl); |
| | | if (!directory.exists()) { |
| | | directory.mkdirs(); |
| | | } |
| | | String fileUrl = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmssSSS")) + "-" + originalName; |
| | | file.transferTo(new File(directory, fileUrl)); |
| | | DeviceMaintenanceAttachment attachment = new DeviceMaintenanceAttachment(); |
| | | attachment.setMaintenancePlanDetailId(maintenancePlanDetailId); |
| | | attachment.setFileName(originalName); |
| | | attachment.setFileUrl(fileUrl); |
| | | attachment.setSort(selectAttachments(maintenancePlanDetailId).size()); |
| | | deviceMaintenanceAttachmentMapper.insert(attachment); |
| | | return attachment; |
| | | } catch (IOException e) { |
| | | throw new ErrorException("éä»¶ä¸ä¼ 失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAttachment(Long id) { |
| | | return deviceMaintenanceAttachmentMapper.deleteById(id) > 0; |
| | | } |
| | | |
| | | /** |
| | | * å é¤è®¡åæç»å¯¹åºçéä»¶è®°å½ |
| | | */ |
| | | private void removeAttachmentsByDetailIds(List<Integer> maintenancePlanDetailIds) { |
| | | if (CollectionUtils.isEmpty(maintenancePlanDetailIds)) { |
| | | return; |
| | | } |
| | | deviceMaintenanceAttachmentMapper.delete(Wrappers.<DeviceMaintenanceAttachment>lambdaQuery() |
| | | .in(DeviceMaintenanceAttachment::getMaintenancePlanDetailId, maintenancePlanDetailIds)); |
| | | } |
| | | |
| | | /** |
| | | * åä¸è®¡åãåä¸è®¾å¤åªä¿ç䏿¡ï¼SQL å·²æâå·²æä¿å
»è®°å½ä¼å
ãå®¡æ ¸éè¿ä¼å
ãææ°ä¼å
âæåºï¼è¿éå馿¡ |
| | | */ |
| | | private List<DeviceMaintenancePlanDetailsDto> dedupeMaintenanceDetails(List<DeviceMaintenancePlanDetailsDto> details) { |
| | | if (CollectionUtils.isEmpty(details)) { |
| | | return details; |
| | | } |
| | | Map<String, DeviceMaintenancePlanDetailsDto> unique = new LinkedHashMap<>(); |
| | | for (DeviceMaintenancePlanDetailsDto detail : details) { |
| | | String key = detail.getDeviceId() != null ? String.valueOf(detail.getDeviceId()) |
| | | : "name:" + detail.getDeviceName(); |
| | | unique.putIfAbsent(key, detail); |
| | | } |
| | | return new ArrayList<>(unique.values()); |
| | | } |
| | | |
| | | /** |
| | | * 两个ä¿å
»æ¥æä¹é´ç¸å·®çææ° |
| | | */ |
| | |
| | | import com.ruoyi.device.service.DeviceRecordService; |
| | | import com.ruoyi.system.domain.vo.SysRoleVo; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | import org.apache.poi.xwpf.usermodel.BreakType; |
| | | import org.apache.poi.xwpf.usermodel.ParagraphAlignment; |
| | | import org.apache.poi.xwpf.usermodel.TableRowAlign; |
| | | import org.apache.poi.xwpf.usermodel.UnderlinePatterns; |
| | |
| | | private static final String RECORD_NUMBER = "LMSY-CX07-JL03"; |
| | | private static final String FONT_NAME = "å®ä½"; |
| | | private static final int[] COLUMN_WIDTHS = {1622, 4168, 1288, 1107, 1137, 1076, 940, 1182, 1288, 1350}; |
| | | private static final String[] HEADER_FIRST_ROW = {"ä½¿ç¨æ¥æ", "æ ·åç¼å·", "æ¶é´ 24 å°æ¶å¶", "", "设å¤ç¶åµ", "", "ç¯å¢æ¡ä»¶", "", "使ç¨äºº", "夿³¨"}; |
| | | private static final String[] HEADER_FIRST_ROW = {"ä½¿ç¨æ¥æ", "æ ·ååç§°", "æ¶é´ 24 å°æ¶å¶", "", "设å¤ç¶åµ", "", "ç¯å¢æ¡ä»¶", "", "使ç¨äºº", "夿³¨"}; |
| | | private static final String[] HEADER_SECOND_ROW = {"", "", "å¼å§", "ç»æ", "使ç¨å", "使ç¨å", "â", "%RH", "", ""}; |
| | | private static final int[] COMBINED_COLUMN_WIDTHS = {1300, 2000, 1500, 1600, 2000, 900, 900, 800, 800, 650, 750, 950, 1008}; |
| | | private static final String[] COMBINED_HEADER_FIRST_ROW = {"ä½¿ç¨æ¥æ", "设å¤åç§°", "设å¤åå·", "设å¤ç¼å·", "æ ·åç¼å·", "æ¶é´ 24 å°æ¶å¶", "", "设å¤ç¶åµ", "", "ç¯å¢æ¡ä»¶", "", "使ç¨äºº", "夿³¨"}; |
| | | private static final String[] COMBINED_HEADER_SECOND_ROW = {"", "", "", "", "", "å¼å§", "ç»æ", "使ç¨å", "使ç¨å", "â", "%RH", "", ""}; |
| | | private static final String FOOTNOTE = "注ï¼è®¾å¤ä½¿ç¨åå䏿 ï¼æ£å¸¸åâââï¼ä¸æ£å¸¸åâÃâå¹¶åææ
åµã"; |
| | | private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm"); |
| | | |
| | |
| | | private SysRoleMenuMapper sysRoleMenuMapper; |
| | | |
| | | @Override |
| | | public IPage<DeviceRecordDto> deviceRecordPage(Integer deviceId, Page page, String sampleCode, String managementNumber) { |
| | | public IPage<DeviceRecordDto> deviceRecordPage(Integer deviceId, Page page, String deviceName, |
| | | String specificationModel, String sampleCode, |
| | | String managementNumber) { |
| | | // todo:ä»
çèªå·± |
| | | Long userId = SecurityUtils.getUserId(); |
| | | // è·åæé夿æ¯å¦æ¯ä»
çæ |
| | |
| | | testUserId = SecurityUtils.getUserId().intValue(); |
| | | } |
| | | |
| | | return baseMapper.deviceRecordPage(deviceId, page, sampleCode, managementNumber, testUserId); |
| | | return baseMapper.deviceRecordPage(deviceId, page, deviceName, specificationModel, |
| | | sampleCode, managementNumber, testUserId); |
| | | } |
| | | |
| | | @Override |
| | | public void exportUseRecord(Integer deviceId, String sampleCode, String managementNumber, String exportDate, HttpServletResponse response) { |
| | | List<DeviceRecordDto> records = baseMapper.selectExportList(deviceId, sampleCode, managementNumber, exportDate); |
| | | public void exportUseRecord(Integer deviceId, String deviceName, String specificationModel, |
| | | String managementNumber, String sampleCode, HttpServletResponse response) { |
| | | List<DeviceRecordDto> records = baseMapper.selectExportList(deviceId, deviceName, |
| | | specificationModel, managementNumber, sampleCode); |
| | | if (records == null || records.isEmpty()) { |
| | | throw new ServiceException(exportDate == null || exportDate.isEmpty() |
| | | ? "没æå¯å¯¼åºç使ç¨è®°å½ï¼æ æ³å¯¼åº" |
| | | : exportDate + " 没æå¯å¯¼åºç使ç¨è®°å½ï¼æ æ³å¯¼åº"); |
| | | throw new ServiceException("没æå¯å¯¼åºç使ç¨è®°å½ï¼æ æ³å¯¼åº"); |
| | | } |
| | | |
| | | // åå°è®¾å¤æ²¿ç¨æªå¾è¡¨å¤´; å¤å°è®¾å¤åå¹¶å°ä¸å¼ 表, æ¯è¡å¸¦è®¾å¤ä¿¡æ¯ |
| | | // ä¸å°è®¾å¤ä¸æ¬è¿è¡è®°å½ï¼å¤å°è®¾å¤å¨åä¸ Word å
æè®¾å¤å页 |
| | | Map<Integer, List<DeviceRecordDto>> deviceRecords = new LinkedHashMap<>(); |
| | | for (DeviceRecordDto record : records) { |
| | | deviceRecords.computeIfAbsent(record.getDeviceId(), key -> new ArrayList<>()).add(record); |
| | |
| | | |
| | | try (XWPFDocument document = new XWPFDocument()) { |
| | | setupPage(document); |
| | | if (deviceRecords.size() == 1) { |
| | | List<DeviceRecordDto> group = deviceRecords.values().iterator().next(); |
| | | renderForm(document, group.get(0), group); |
| | | } else { |
| | | renderCombinedForm(document, records); |
| | | boolean first = true; |
| | | for (List<DeviceRecordDto> group : deviceRecords.values()) { |
| | | if (!first) { |
| | | addPageBreak(document); |
| | | } |
| | | renderForm(document, group.get(0), mergeSameConditionRecords(group)); |
| | | first = false; |
| | | } |
| | | |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); |
| | |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("导åºå¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åä¸è®¾å¤ãåä¸å¤©ãèµ·æ¢æ¶é´/温湿度/使ç¨äºº/使ç¨ååç¶åµç¸åçè®°å½åå¹¶ä¸è¡ï¼æ ·åç¼å·ç¨âãâæ¼æ¥ã |
| | | */ |
| | | private List<DeviceRecordDto> mergeSameConditionRecords(List<DeviceRecordDto> records) { |
| | | Map<String, DeviceRecordDto> merged = new LinkedHashMap<>(); |
| | | for (DeviceRecordDto record : records) { |
| | | String key = String.join("|", |
| | | formatDate(record.getUseStartDate()), |
| | | formatTime(record.getUseStartDate()), |
| | | formatTime(record.getUseEndDate()), |
| | | valueOrEmpty(record.getTemperature()), |
| | | valueOrEmpty(record.getHumidity()), |
| | | valueOrEmpty(record.getUsePerson()), |
| | | String.valueOf(record.getUseBefore()), |
| | | String.valueOf(record.getUseAfter())); |
| | | DeviceRecordDto existing = merged.get(key); |
| | | if (existing == null) { |
| | | merged.put(key, record); |
| | | } else { |
| | | existing.setSampleCode(appendDistinct(existing.getSampleCode(), record.getSampleCode())); |
| | | existing.setRemark(appendDistinct(existing.getRemark(), record.getRemark())); |
| | | } |
| | | } |
| | | return new ArrayList<>(merged.values()); |
| | | } |
| | | |
| | | private String appendDistinct(String existing, String addition) { |
| | | if (addition == null || addition.trim().isEmpty()) { |
| | | return existing; |
| | | } |
| | | if (existing == null || existing.trim().isEmpty()) { |
| | | return addition; |
| | | } |
| | | List<String> parts = java.util.Arrays.asList(existing.split("ã")); |
| | | return parts.contains(addition) ? existing : existing + "ã" + addition; |
| | | } |
| | | |
| | | private void addPageBreak(XWPFDocument document) { |
| | | XWPFParagraph paragraph = document.createParagraph(); |
| | | paragraph.setSpacingAfter(0); |
| | | paragraph.createRun().addBreak(BreakType.PAGE); |
| | | } |
| | | |
| | | private void setupPage(XWPFDocument document) { |
| | |
| | | setCellText(row.getCell(j), values[j]); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void renderCombinedForm(XWPFDocument document, List<DeviceRecordDto> records) { |
| | | XWPFParagraph recordNumber = addParagraph(document, "è®°å½ç¼å·ï¼" + RECORD_NUMBER, 10.5, false, ParagraphAlignment.LEFT); |
| | | recordNumber.setSpacingAfter(240); |
| | | |
| | | XWPFParagraph title = addParagraph(document, FORM_TITLE, 22, true, ParagraphAlignment.CENTER); |
| | | title.setSpacingAfter(240); |
| | | |
| | | XWPFTable table = document.createTable(2 + records.size(), COMBINED_COLUMN_WIDTHS.length); |
| | | configureTable(table, COMBINED_COLUMN_WIDTHS); |
| | | |
| | | for (int i = 0; i < table.getNumberOfRows(); i++) { |
| | | XWPFTableRow row = table.getRow(i); |
| | | row.setHeight(i < 2 ? 560 : 520); |
| | | for (int j = 0; j < COMBINED_COLUMN_WIDTHS.length; j++) { |
| | | setCellWidth(row.getCell(j), COMBINED_COLUMN_WIDTHS[j]); |
| | | } |
| | | setRowProperties(row, i < 2); |
| | | } |
| | | |
| | | XWPFTableRow firstHeader = table.getRow(0); |
| | | for (int i = 0; i < COMBINED_HEADER_FIRST_ROW.length; i++) { |
| | | setCellText(firstHeader.getCell(i), COMBINED_HEADER_FIRST_ROW[i]); |
| | | } |
| | | XWPFTableRow secondHeader = table.getRow(1); |
| | | for (int i = 0; i < COMBINED_HEADER_SECOND_ROW.length; i++) { |
| | | setCellText(secondHeader.getCell(i), COMBINED_HEADER_SECOND_ROW[i]); |
| | | } |
| | | |
| | | mergeHorizontal(firstHeader, COMBINED_COLUMN_WIDTHS, 9, 2); |
| | | mergeHorizontal(firstHeader, COMBINED_COLUMN_WIDTHS, 7, 2); |
| | | mergeHorizontal(firstHeader, COMBINED_COLUMN_WIDTHS, 5, 2); |
| | | mergeVertical(firstHeader.getCell(0), secondHeader.getCell(0)); |
| | | mergeVertical(firstHeader.getCell(1), secondHeader.getCell(1)); |
| | | mergeVertical(firstHeader.getCell(2), secondHeader.getCell(2)); |
| | | mergeVertical(firstHeader.getCell(3), secondHeader.getCell(3)); |
| | | mergeVertical(firstHeader.getCell(4), secondHeader.getCell(4)); |
| | | mergeVertical(firstHeader.getCell(8), secondHeader.getCell(11)); |
| | | mergeVertical(firstHeader.getCell(9), secondHeader.getCell(12)); |
| | | |
| | | for (int i = 0; i < records.size(); i++) { |
| | | XWPFTableRow row = table.getRow(2 + i); |
| | | String[] values = buildCombinedRowValues(records.get(i)); |
| | | for (int j = 0; j < values.length; j++) { |
| | | setCellText(row.getCell(j), values[j]); |
| | | } |
| | | } |
| | | XWPFParagraph footnote = addParagraph(document, FOOTNOTE, 10.5, false, ParagraphAlignment.LEFT); |
| | | footnote.setSpacingBefore(120); |
| | | footnote.setSpacingAfter(0); |
| | | } |
| | | |
| | | private XWPFParagraph addParagraph(XWPFDocument document, String text, double fontSize, boolean bold, ParagraphAlignment alignment) { |
| | |
| | | }; |
| | | } |
| | | |
| | | private String[] buildCombinedRowValues(DeviceRecordDto record) { |
| | | return new String[]{ |
| | | formatDate(record.getUseStartDate()), |
| | | valueOrEmpty(record.getDeviceName()), |
| | | valueOrEmpty(record.getSpecificationModel()), |
| | | valueOrEmpty(record.getManagementNumber()), |
| | | valueOrEmpty(record.getSampleCode()), |
| | | formatTime(record.getUseStartDate()), |
| | | formatTime(record.getUseEndDate()), |
| | | statusText(record.getUseBefore()), |
| | | statusText(record.getUseAfter()), |
| | | valueOrEmpty(record.getTemperature()), |
| | | valueOrEmpty(record.getHumidity()), |
| | | valueOrEmpty(record.getUsePerson()), |
| | | valueOrEmpty(record.getRemark()) |
| | | }; |
| | | } |
| | | |
| | | private String formatDate(LocalDateTime value) { |
| | | return value == null ? "" : value.format(DATE_FORMATTER); |
| | | } |
| | |
| | | if (value == null) { |
| | | return ""; |
| | | } |
| | | return value == 0 ? "å¼å¸¸" : "è¯å¥½"; |
| | | return value == 0 ? "å¼å¸¸" : "æ£å¸¸"; |
| | | } |
| | | |
| | | private String valueOrEmpty(String value) { |
| | |
| | | d.management_number device_number, |
| | | d.specification_model, |
| | | d.management_number, |
| | | d.storage_point |
| | | d.storage_point, |
| | | (select count(*) from device_maintenance dm |
| | | where dm.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id) has_record |
| | | from device_maintenance_plan_details dmpd |
| | | left join device d on dmpd.device_id = d.id |
| | | where dmpd.maintenance_plan_id = #{maintenancePlanId} |
| | | order by has_record desc, |
| | | (select count(*) from device_maintenance dm2 |
| | | where dm2.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id |
| | | and dm2.review_status = 1) desc, |
| | | dmpd.maintenance_plan_detail_id desc |
| | | </select> |
| | | |
| | | <!-- 设å¤ä¿å
»è®¡å详æ
å表ï¼å«å°ç¹æ 红ãå
³èçä¿å
»è®°å½ä¸å®¡æ ¸ç¶æï¼ --> |
| | |
| | | case when d.next_maintenance_date is not null |
| | | and d.next_maintenance_date <= date_add(curdate(), interval 1 month) |
| | | and (d.last_maintenance_date is null or d.last_maintenance_date < dmpd.maintenance_date) |
| | | then 1 else 0 end as red_flag |
| | | then 1 else 0 end as red_flag, |
| | | (select count(*) from device_maintenance_attachment a |
| | | where a.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id) attachment_count |
| | | from device_maintenance_plan_details dmpd |
| | | left join device d on dmpd.device_id = d.id |
| | | left join device_maintenance dm on dm.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id |
| | |
| | | <if test="deviceId != null"> |
| | | and dr.device_id = #{deviceId} |
| | | </if> |
| | | <if test="deviceName != '' and deviceName != null"> |
| | | and d.device_name like concat('%', #{deviceName}, '%') |
| | | </if> |
| | | <if test="specificationModel != '' and specificationModel != null"> |
| | | and d.specification_model like concat('%', #{specificationModel}, '%') |
| | | </if> |
| | | <if test="sampleCode != '' and sampleCode != null"> |
| | | and dr.sample_code like concat('%', #{sampleCode}, '%') |
| | | </if> |
| | |
| | | <if test="deviceId != null"> |
| | | and dr.device_id = #{deviceId} |
| | | </if> |
| | | <if test="sampleCode != '' and sampleCode != null"> |
| | | and dr.sample_code like concat('%', #{sampleCode}, '%') |
| | | <if test="deviceName != '' and deviceName != null"> |
| | | and d.device_name like concat('%', #{deviceName}, '%') |
| | | </if> |
| | | <if test="specificationModel != '' and specificationModel != null"> |
| | | and d.specification_model like concat('%', #{specificationModel}, '%') |
| | | </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 test="sampleCode != '' and sampleCode != null"> |
| | | and dr.sample_code like concat('%', #{sampleCode}, '%') |
| | | </if> |
| | | ORDER BY dr.use_start_date asc |
| | | ORDER BY d.device_name asc, d.id asc, dr.use_start_date asc |
| | | </select> |
| | | </mapper> |
| | |
| | | package com.ruoyi.manage.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | |
| | | import com.deepoove.poi.data.style.*; |
| | | |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.utils.JackSonUtil; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.manage.excel.ManageDocumentControlledImportDto; |
| | | import com.ruoyi.manage.excel.ManageDocumentControlledImportListener; |
| | | import com.ruoyi.manage.pojo.ManageDocumentControlled; |
| | | import com.ruoyi.manage.service.ManageDocumentControlledService; |
| | | import com.deepoove.poi.data.style.*; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | return Result.success(manageDocumentControlledService.addManageDocumentControlled(manageDocumentControlled)); |
| | | } |
| | | |
| | | @Operation(summary = "æ¹é导å
¥æä»¶åæ§ç³è¯·") |
| | | @PostMapping("/importManageDocumentControlled") |
| | | public Result importManageDocumentControlled(MultipartFile file) { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new ErrorException("è¯·éæ©å¯¼å
¥æä»¶"); |
| | | } |
| | | try { |
| | | EasyExcel.read(file.getInputStream(), ManageDocumentControlledImportDto.class, |
| | | new ManageDocumentControlledImportListener(manageDocumentControlledService)).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | throw new ErrorException("读å导å
¥æä»¶å¤±è´¥"); |
| | | } |
| | | return Result.success(); |
| | | } |
| | | |
| | | |
| | | @Operation(summary = "æ¥çæä»¶åæ§") |
| | | @GetMapping("/getManageDocumentControlled") |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.manage.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnore; |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * æä»¶åæ§ç³è¯·å¯¼å
¥è¡ |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ExcelIgnoreUnannotated |
| | | public class ManageDocumentControlledImportDto { |
| | | |
| | | @ExcelProperty("æä»¶åç§°") |
| | | private String name; |
| | | |
| | | @ExcelProperty("æä»¶çæ¬") |
| | | private String version; |
| | | |
| | | @ExcelProperty("å叿¥æ") |
| | | private String publishDate; |
| | | |
| | | @ExcelProperty("宿½æ¥æ") |
| | | private String implementDate; |
| | | |
| | | @ExcelIgnore |
| | | private LocalDate publishDateValue; |
| | | |
| | | @ExcelIgnore |
| | | private LocalDate implementDateValue; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.manage.excel; |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.manage.service.ManageDocumentControlledService; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * æä»¶åæ§ç³è¯·æ¹é导å
¥ |
| | | */ |
| | | public class ManageDocumentControlledImportListener extends AnalysisEventListener<ManageDocumentControlledImportDto> { |
| | | |
| | | private static final List<String> HEADERS = Arrays.asList("æä»¶åç§°", "æä»¶çæ¬", "å叿¥æ", "宿½æ¥æ"); |
| | | private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-M-d"); |
| | | |
| | | private final ManageDocumentControlledService manageDocumentControlledService; |
| | | private final List<ManageDocumentControlledImportDto> rows = new ArrayList<>(); |
| | | |
| | | public ManageDocumentControlledImportListener(ManageDocumentControlledService manageDocumentControlledService) { |
| | | this.manageDocumentControlledService = manageDocumentControlledService; |
| | | } |
| | | |
| | | @Override |
| | | public void invoke(ManageDocumentControlledImportDto data, AnalysisContext context) { |
| | | if (isBlankRow(data)) { |
| | | return; |
| | | } |
| | | int rowNum = context.readRowHolder().getRowIndex() + 1; |
| | | if (!StringUtils.hasText(data.getName())) { |
| | | throw new BaseException("第" + rowNum + "è¡ï¼æä»¶åç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | data.setPublishDateValue(parseDate(data.getPublishDate(), rowNum, "å叿¥æ")); |
| | | data.setImplementDateValue(parseDate(data.getImplementDate(), rowNum, "宿½æ¥æ")); |
| | | rows.add(data); |
| | | } |
| | | |
| | | private LocalDate parseDate(String value, int rowNum, String column) { |
| | | if (!StringUtils.hasText(value)) { |
| | | return null; |
| | | } |
| | | String text = value.trim(); |
| | | int space = text.indexOf(' '); |
| | | if (space > 0) { |
| | | text = text.substring(0, space); |
| | | } |
| | | text = text.replace("å¹´", "-").replace("æ", "-").replace("æ¥", "") |
| | | .replace("/", "-").replace(".", "-"); |
| | | try { |
| | | // Excel 鿥æåå
æ ¼å¯è½è¢«è¯»ææ°ååºåï¼1899-12-30 èµ·ç®ï¼ |
| | | if (text.matches("\\d{5}(\\.\\d+)?")) { |
| | | return LocalDate.of(1899, 12, 30).plusDays((long) Double.parseDouble(text)); |
| | | } |
| | | return LocalDate.parse(text, DATE_FORMAT); |
| | | } catch (Exception e) { |
| | | throw new BaseException("第" + rowNum + "è¡ï¼" + column + "æ ¼å¼ä¸æ£ç¡®ï¼è¯·æ yyyy-MM-dd å¡«å"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | if (rows.isEmpty()) { |
| | | throw new BaseException("导å
¥æ°æ®ä¸å¾ä¸ºç©º"); |
| | | } |
| | | manageDocumentControlledService.importManageDocumentControlled(rows); |
| | | } |
| | | |
| | | @Override |
| | | public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
| | | if (CollectionUtils.isEmpty(headMap) || headMap.size() != HEADERS.size()) { |
| | | throw new BaseException("导å
¥æ¨¡æ¿æè¯¯ï¼è¯·ä½¿ç¨ææ°æ¨¡æ¿"); |
| | | } |
| | | for (int i = 0; i < HEADERS.size(); i++) { |
| | | String head = headMap.get(i); |
| | | if (head == null || !HEADERS.get(i).equals(head.trim())) { |
| | | throw new BaseException("导å
¥æ¨¡æ¿æè¯¯ï¼è¡¨å¤´å¿
é¡»ä¸ºï¼æä»¶åç§°ãæä»¶çæ¬ãå叿¥æã宿½æ¥æ"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean isBlankRow(ManageDocumentControlledImportDto data) { |
| | | return data == null |
| | | || (!StringUtils.hasText(data.getName()) |
| | | && !StringUtils.hasText(data.getVersion()) |
| | | && !StringUtils.hasText(data.getPublishDate()) |
| | | && !StringUtils.hasText(data.getImplementDate())); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.manage.pojo.ManageDocumentControlled; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æä»¶åæ§ Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author |
| | | * @author |
| | | * @since 2024-11-08 02:54:44 |
| | | */ |
| | | public interface ManageDocumentControlledMapper extends BaseMapper<ManageDocumentControlled> { |
| | |
| | | IPage<ManageDocumentControlled> pageManageDocumentControlled(Page page, @Param("ew") QueryWrapper<ManageDocumentControlled> queryWrappers); |
| | | |
| | | ManageDocumentControlled getManageDocumentControlled(Long id); |
| | | |
| | | /** |
| | | * 导å
¥è稿ï¼ç¨ Map ä¼ åï¼ç»è¿ MyBatis-Plus ç createUser èªå¨å¡«å
ï¼ |
| | | * 让导å
¥æ°æ®çç³è¯·äººä¸ºç©ºã |
| | | */ |
| | | int insertImportedDraft(Map<String, Object> row); |
| | | } |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate submitDate; |
| | | |
| | | @Schema(description = "å叿¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate publishDate; |
| | | |
| | | @Schema(description = "宿½æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate implementDate; |
| | | |
| | | @Schema(description = "说æ") |
| | | private String instructions; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.manage.excel.ManageDocumentControlledImportDto; |
| | | import com.ruoyi.manage.pojo.ManageDocumentControlled; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | int checkManageDocumentControlled(ManageDocumentControlled manageDocumentControlled); |
| | | |
| | | int importManageDocumentControlled(List<ManageDocumentControlledImportDto> rows); |
| | | |
| | | void checkManageDocumentControlledPdf(Long id, HttpServletResponse response) throws Exception ; |
| | | } |
| | |
| | | manageRecordAudit.setReason(manageDocumentAlter.getAlterNote()); |
| | | manageRecordAudit.setAlterUser(SecurityUtils.getUserId().intValue()); |
| | | manageRecordAudit.setMethod("修订"); |
| | | manageRecordAudit.setCreateTime(LocalDate.now()); |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getFile())) { |
| | | String urlString; |
| | | String pathName; |
| | |
| | | return 0; |
| | | } |
| | | } |
| | | return manageDocumentAlterMapper.updateById(manageDocumentAlter); |
| | | int result = manageDocumentAlterMapper.updateById(manageDocumentAlter); |
| | | // åæ´å
容修æ¹å忥å°èªå¨çæç修订记å½ï¼é¿å
两个页é¢å
容对ä¸ä¸ |
| | | ManageRecordAudit linkedAudit = findLinkedAudit(manageDocumentAlter1); |
| | | if (linkedAudit != null) { |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterBeforeCode())) { |
| | | linkedAudit.setDocumentCode(manageDocumentAlter.getAlterBeforeCode()); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterBeforeName())) { |
| | | linkedAudit.setDocumentName(manageDocumentAlter.getAlterBeforeName()); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterBeforeVersion())) { |
| | | linkedAudit.setBeforeVersion(manageDocumentAlter.getAlterBeforeVersion()); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterAfterVersion())) { |
| | | linkedAudit.setAfterVersion(manageDocumentAlter.getAlterAfterVersion()); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterNote())) { |
| | | linkedAudit.setReason(manageDocumentAlter.getAlterNote()); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterAfterUrl())) { |
| | | linkedAudit.setAfterUrl(manageDocumentAlter.getAlterAfterUrl()); |
| | | } |
| | | manageRecordAuditMapper.updateById(linkedAudit); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // æåæ´åä¿¡æ¯å®ä½èªå¨çæç飿¡ä¿®è®¢è®°å½ |
| | | private ManageRecordAudit findLinkedAudit(ManageDocumentAlter manageDocumentAlter) { |
| | | return manageRecordAuditMapper.selectOne(Wrappers.<ManageRecordAudit>lambdaQuery() |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterBeforeCode()), ManageRecordAudit::getDocumentCode, manageDocumentAlter.getAlterBeforeCode()) |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterBeforeName()), ManageRecordAudit::getDocumentName, manageDocumentAlter.getAlterBeforeName()) |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterBeforeVersion()), ManageRecordAudit::getBeforeVersion, manageDocumentAlter.getAlterBeforeVersion()) |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentAlter.getAlterAfterVersion()), ManageRecordAudit::getAfterVersion, manageDocumentAlter.getAlterAfterVersion()) |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentAlter.getCreateUser()), ManageRecordAudit::getAlterUser, manageDocumentAlter.getCreateUser()) |
| | | .eq(ManageRecordAudit::getMethod, "修订") |
| | | .orderByDesc(ManageRecordAudit::getId) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | @Override |
| | |
| | | manageRecordAudit.setDocumentName(manageDocumentCancel.getName()); |
| | | manageRecordAudit.setAlterThing("ä½åº"); |
| | | manageRecordAudit.setMethod("ä½åº"); |
| | | manageRecordAudit.setAlterUser(oldManageDocumentAlter.getCreateUser()); |
| | | manageRecordAudit.setCreateTime(LocalDate.now()); |
| | | manageRecordAuditMapper.insert(manageRecordAudit); |
| | | }else { |
| | | //妿æ¯åæ¡£ä¸å¯ç¨,é£å°±å°æä»¶æ¸
åçç¶ææ¹ä¸ºæ æ |
| | |
| | | manageRecordCheck.setCheckState(manageDocumentAlter.getState()); |
| | | manageRecordCheck.setRemark(manageDocumentAlter.getAlterNote()); |
| | | manageRecordCheckMapper.insert(manageRecordCheck); |
| | | // å®¡æ ¸éè¿åååæ¹åäººï¼æä»¶ä¿®è®¢ç³è¯·å®¡æ¹è®°å½éè½ç´æ¥çå°å®¡æ¹ç»æ |
| | | ManageRecordAudit linkedAudit = findLinkedAudit(oldManageDocumentAlter); |
| | | if (linkedAudit != null |
| | | && "éè¿".equals(manageDocumentAlter.getState()) |
| | | && linkedAudit.getRatifyUser() == null |
| | | && oldManageDocumentAlter.getCheckUser() != null) { |
| | | linkedAudit.setRatifyUser(oldManageDocumentAlter.getCheckUser()); |
| | | manageRecordAuditMapper.updateById(linkedAudit); |
| | | } |
| | | return manageDocumentAlterMapper.updateById(manageDocumentAlter); |
| | | } |
| | | |
| | |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | |
| | | |
| | | import com.ruoyi.manage.mapper.ManageDocumentCancelMapper; |
| | | import com.ruoyi.manage.mapper.ManageDocumentListMapper; |
| | | import com.ruoyi.manage.mapper.ManageRecordAuditMapper; |
| | | import com.ruoyi.manage.mapper.ManageRecordCancelMapper; |
| | | import com.ruoyi.manage.mapper.ManageRecordCheckMapper; |
| | | import com.ruoyi.manage.pojo.ManageDocumentCancel; |
| | | import com.ruoyi.manage.pojo.ManageDocumentList; |
| | | import com.ruoyi.manage.pojo.ManageRecordAudit; |
| | | import com.ruoyi.manage.pojo.ManageRecordCancel; |
| | | import com.ruoyi.manage.pojo.ManageRecordCheck; |
| | | import com.ruoyi.manage.service.ManageDocumentCancelService; |
| | | |
| | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @Resource |
| | | private ManageRecordAuditMapper manageRecordAuditMapper; |
| | | |
| | | |
| | | @Resource |
| | | private ManageRecordCancelMapper manageRecordCancelMapper; |
| | | |
| | | @Resource |
| | | private ManageDocumentListMapper manageDocumentListMapper; |
| | |
| | | manageRecordAudit.setDocumentName(manageDocumentCancel.getName()); |
| | | manageRecordAudit.setAlterThing("ä½åº"); |
| | | manageRecordAudit.setMethod("ä½åº"); |
| | | manageRecordAudit.setAlterUser(SecurityUtils.getUserId().intValue()); |
| | | manageRecordAudit.setCreateTime(LocalDate.now()); |
| | | manageRecordAuditMapper.insert(manageRecordAudit); |
| | | return manageDocumentCancelMapper.insert(manageDocumentCancel); |
| | | } |
| | |
| | | @Override |
| | | public int checkManageDocumentCancel(Integer id, String state) { |
| | | ManageDocumentCancel manageDocumentCancel = manageDocumentCancelMapper.selectById(id); |
| | | if (state.equals("éè¿")){ |
| | | if (manageDocumentCancel == null) { |
| | | throw new ErrorException("ç³è¯·è®°å½ä¸åå¨"); |
| | | } |
| | | if ("éè¿".equals(state)){ |
| | | //å 餿件æ¸
åå¯¹åºæ°æ® |
| | | manageDocumentListMapper.delete(Wrappers.<ManageDocumentList>lambdaQuery().eq(ManageDocumentList::getDocumentCode,manageDocumentCancel.getDocumentCode())); |
| | | // ä½åºéè¿åèªå¨çæéæ¯å°è´¦ï¼ä¿è¯âæä»¶ä½åºç³è¯·âåâä½åºæä»¶éæ¯è®°å½âçæ°æ®èå¨ |
| | | createRecordCancelIfAbsent(manageDocumentCancel); |
| | | } |
| | | manageDocumentCancel.setState(state); |
| | | /*æ°å¢8.4çæä»¶å®¡æ¹è®°å½*/ |
| | |
| | | public int doManageDocumentCancel(ManageDocumentCancel manageDocumentCancel) { |
| | | return manageDocumentCancelMapper.updateById(manageDocumentCancel); |
| | | } |
| | | |
| | | // ä½åºç³è¯·éè¿åï¼å¨âä½åºæä»¶éæ¯è®°å½âçæä¸æ¡å¾
è¡¥å
¨çå°è´¦è®°å½ |
| | | private void createRecordCancelIfAbsent(ManageDocumentCancel manageDocumentCancel) { |
| | | ManageRecordCancel existing = manageRecordCancelMapper.selectOne(Wrappers.<ManageRecordCancel>lambdaQuery() |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentCancel.getDocumentCode()), ManageRecordCancel::getDocumentCode, manageDocumentCancel.getDocumentCode()) |
| | | .eq(ObjectUtils.isNotEmpty(manageDocumentCancel.getName()), ManageRecordCancel::getDocumentName, manageDocumentCancel.getName()) |
| | | .orderByDesc(ManageRecordCancel::getId) |
| | | .last("limit 1")); |
| | | if (existing != null) { |
| | | return; |
| | | } |
| | | ManageRecordCancel manageRecordCancel = new ManageRecordCancel(); |
| | | manageRecordCancel.setDocumentCode(manageDocumentCancel.getDocumentCode()); |
| | | manageRecordCancel.setDocumentName(manageDocumentCancel.getName()); |
| | | manageRecordCancel.setReason(ObjectUtils.isNotEmpty(manageDocumentCancel.getCancelNote()) |
| | | ? manageDocumentCancel.getCancelNote() : "æä»¶ä½åº"); |
| | | manageRecordCancel.setRemark("ç±æä»¶ä½åºç³è¯·èªå¨çæï¼è¯·è¡¥å
鿝æ°éåæ¹å"); |
| | | manageRecordCancel.setCreateUser(manageDocumentCancel.getCreateUser()); |
| | | manageRecordCancelMapper.insert(manageRecordCancel); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.numgen.NumberGenerator; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.manage.excel.ManageDocumentControlledImportDto; |
| | | import com.ruoyi.manage.mapper.ManageDocumentControlledMapper; |
| | | import com.ruoyi.manage.mapper.ManageDocumentListMapper; |
| | | import com.ruoyi.manage.mapper.ManageRecordCheckMapper; |
| | |
| | | import java.io.FileInputStream; |
| | | import java.io.OutputStream; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | |
| | | @Resource |
| | | private NumberGenerator<ManageDocumentControlled> numberGenerator; |
| | | |
| | | private static final DateTimeFormatter CODE_DATE_FORMAT = DateTimeFormatter.ofPattern("yyMMdd"); |
| | | |
| | | @Override |
| | | public IPage<ManageDocumentControlled> pageManageDocumentControlled(Page page, ManageDocumentControlled manageDocumentControlled) { |
| | | return manageDocumentControlledMapper.pageManageDocumentControlled(page, QueryWrappers.queryWrappers(manageDocumentControlled)); |
| | |
| | | @Override |
| | | public int addManageDocumentControlled(ManageDocumentControlled manageDocumentControlled) { |
| | | manageDocumentControlled.setState("å¾
å®¡æ ¸"); |
| | | // æäº¤æ¥æä¸åå¨çé¢å¡«åï¼å
¥åºæ¶èªå¨åå½å¤©ï¼ä¿çåæå段å«ä¹ |
| | | if (manageDocumentControlled.getSubmitDate() == null) { |
| | | manageDocumentControlled.setSubmitDate(LocalDate.now()); |
| | | } |
| | | String urlString; |
| | | String pathName; |
| | | String path; |
| | |
| | | @Override |
| | | public int checkManageDocumentControlled(ManageDocumentControlled manageDocumentControlled) { |
| | | ManageDocumentControlled documentControlled = manageDocumentControlledMapper.selectById(manageDocumentControlled.getId()); |
| | | if (documentControlled == null) { |
| | | throw new ErrorException("ç³è¯·è®°å½ä¸åå¨"); |
| | | } |
| | | // å·²éè¿çç³è¯·ä¸è½åå®¡æ ¸ï¼å¦åä¼éå¤çææä»¶æ¸
åå审æ¹è®°å½ |
| | | if ("éè¿".equals(documentControlled.getState())) { |
| | | throw new ErrorException("该ç³è¯·å·²å®¡æ ¸éè¿ï¼ä¸è½éå¤å®¡æ ¸"); |
| | | } |
| | | if (manageDocumentControlled.getState().equals("éè¿")) { |
| | | // å 餿§æä»¶ |
| | | File oldFile = new File(wordUrl + "/" + documentControlled.getUrl()); |
| | |
| | | manageDocumentList.setName(documentControlled.getName()); |
| | | manageDocumentList.setVersion(documentControlled.getVersion()); |
| | | manageDocumentList.setWriter(documentControlled.getWriter()); |
| | | manageDocumentList.setEffectiveDate(LocalDate.now()); |
| | | // æä»¶æ¸
åççææ¥æåç³è¯·çâ宿½æ¥æâï¼æ²¡å¡«æç¨å½å¤© |
| | | manageDocumentList.setEffectiveDate(documentControlled.getImplementDate() != null |
| | | ? documentControlled.getImplementDate() : LocalDate.now()); |
| | | manageDocumentList.setState("ææ"); |
| | | manageDocumentList.setUrl(manageDocumentControlled.getUrl()); |
| | | manageDocumentListMapper.insert(manageDocumentList); |
| | |
| | | manageRecordCheck.setDocumentCode(documentControlled.getDocumentCode()); |
| | | manageRecordCheck.setDocumentName(documentControlled.getName()); |
| | | manageRecordCheck.setDocumentVersion(documentControlled.getVersion()); |
| | | manageRecordCheck.setWriteUser(userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getName,documentControlled.getWriter())).getId()); |
| | | // ä½è
å¯è½ä¸æ¯ç³»ç»ç¨æ·ï¼å岿°æ®/æå¡«ï¼ï¼æ¥ä¸å°æ¶ä¸å空æé |
| | | User writerUser = null; |
| | | if (documentControlled.getWriter() != null && !documentControlled.getWriter().trim().isEmpty()) { |
| | | writerUser = userMapper.selectOne(Wrappers.<User>lambdaQuery() |
| | | .eq(User::getName, documentControlled.getWriter()) |
| | | .last("limit 1")); |
| | | } |
| | | manageRecordCheck.setWriteUser(writerUser == null ? null : writerUser.getId()); |
| | | manageRecordCheck.setCheckUser(documentControlled.getDutyUser()); |
| | | manageRecordCheck.setCheckState(manageDocumentControlled.getState()); |
| | | manageRecordCheck.setRemark(documentControlled.getInstructions()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int importManageDocumentControlled(List<ManageDocumentControlledImportDto> rows) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | String codePrefix = "WT" + CODE_DATE_FORMAT.format(today); |
| | | int count = 0; |
| | | for (ManageDocumentControlledImportDto dto : rows) { |
| | | Map<String, Object> row = new HashMap<>(); |
| | | row.put("documentCode", numberGenerator.generateNumberWithPrefix( |
| | | 3, codePrefix, ManageDocumentControlled::getDocumentCode)); |
| | | row.put("type", null); |
| | | row.put("name", dto.getName().trim()); |
| | | row.put("version", trimToNull(dto.getVersion())); |
| | | row.put("writer", null); |
| | | row.put("submitDate", today); |
| | | row.put("publishDate", dto.getPublishDateValue()); |
| | | row.put("implementDate", dto.getImplementDateValue()); |
| | | row.put("instructions", null); |
| | | row.put("state", "è稿"); |
| | | row.put("url", null); |
| | | row.put("dutyUser", null); |
| | | row.put("createTime", now); |
| | | row.put("updateTime", now); |
| | | count += manageDocumentControlledMapper.insertImportedDraft(row); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | private String trimToNull(String value) { |
| | | return value == null || value.trim().isEmpty() ? null : value.trim(); |
| | | } |
| | | |
| | | @Override |
| | | public void checkManageDocumentControlledPdf(Long id, HttpServletResponse response) throws Exception { |
| | | ManageDocumentControlled manageDocumentControlled = manageDocumentControlledMapper.selectById(id); |
| | | if (manageDocumentControlled == null || ObjectUtils.isEmpty(manageDocumentControlled.getUrl())) { |
| | |
| | | if (ObjectUtils.isNotEmpty(manageDocumentIssueRecycle.getRecycleUser())){ |
| | | /*æ°å¢8.3çåæ¾ä¸åæ¶è®°å½*/ |
| | | ManageRecordIssueRecycle manageRecordIssueRecycle = manageRecordIssueRecycleMapper.selectOne(Wrappers.<ManageRecordIssueRecycle>lambdaQuery() |
| | | .eq(ManageRecordIssueRecycle::getDocumentCode, documentIssueRecycle.getDocumentCode()) |
| | | .eq(ManageRecordIssueRecycle::getDocumentName, documentIssueRecycle.getName()) |
| | | .eq(ManageRecordIssueRecycle::getDocumentVersion, documentIssueRecycle.getVersion()) |
| | | .eq(ManageRecordIssueRecycle::getReceiveUser, documentIssueRecycle.getIssueUser()) |
| | | .eq(ManageRecordIssueRecycle::getReceiveDate, documentIssueRecycle.getIssueDate())); |
| | | manageRecordIssueRecycle.setSignedUser(manageDocumentIssueRecycle.getRecycleUser()); |
| | | manageRecordIssueRecycle.setSignedDate(manageDocumentIssueRecycle.getRecycleDate()); |
| | | manageRecordIssueRecycleMapper.updateById(manageRecordIssueRecycle); |
| | | .eq(ObjectUtils.isNotEmpty(documentIssueRecycle.getDocumentCode()), ManageRecordIssueRecycle::getDocumentCode, documentIssueRecycle.getDocumentCode()) |
| | | .eq(ObjectUtils.isNotEmpty(documentIssueRecycle.getName()), ManageRecordIssueRecycle::getDocumentName, documentIssueRecycle.getName()) |
| | | .eq(ObjectUtils.isNotEmpty(documentIssueRecycle.getVersion()), ManageRecordIssueRecycle::getDocumentVersion, documentIssueRecycle.getVersion()) |
| | | .eq(ObjectUtils.isNotEmpty(documentIssueRecycle.getIssueUser()), ManageRecordIssueRecycle::getReceiveUser, documentIssueRecycle.getIssueUser()) |
| | | .eq(ObjectUtils.isNotEmpty(documentIssueRecycle.getIssueDate()), ManageRecordIssueRecycle::getReceiveDate, documentIssueRecycle.getIssueDate()) |
| | | .orderByDesc(ManageRecordIssueRecycle::getId) |
| | | .last("limit 1")); |
| | | if (manageRecordIssueRecycle == null) { |
| | | // åå²åæ¾è®°å½å¨å°è´¦éå¯è½æ²¡æå¯¹åºè¡ï¼åæ¶æ¶è¡¥å»ºï¼ä¿è¯ä¸¤ä¸ªé¡µé¢å§ç»è½å¯¹ä¸ |
| | | manageRecordIssueRecycle = new ManageRecordIssueRecycle(); |
| | | manageRecordIssueRecycle.setDocumentCode(documentIssueRecycle.getDocumentCode()); |
| | | manageRecordIssueRecycle.setDocumentName(documentIssueRecycle.getName()); |
| | | manageRecordIssueRecycle.setDocumentVersion(documentIssueRecycle.getVersion()); |
| | | manageRecordIssueRecycle.setReceiveUser(documentIssueRecycle.getIssueUser()); |
| | | manageRecordIssueRecycle.setReceiveDate(documentIssueRecycle.getIssueDate()); |
| | | manageRecordIssueRecycle.setSignedUser(manageDocumentIssueRecycle.getRecycleUser()); |
| | | manageRecordIssueRecycle.setSignedDate(manageDocumentIssueRecycle.getRecycleDate()); |
| | | manageRecordIssueRecycleMapper.insert(manageRecordIssueRecycle); |
| | | } else { |
| | | // åæ¾ä¿¡æ¯è·çåæ´ï¼åæ¶ä¿¡æ¯ååç¾æ¶äºº/ç¾æ¶æ¥æ |
| | | manageRecordIssueRecycle.setDocumentCode(manageDocumentIssueRecycle.getDocumentCode()); |
| | | manageRecordIssueRecycle.setDocumentName(manageDocumentIssueRecycle.getName()); |
| | | manageRecordIssueRecycle.setDocumentVersion(manageDocumentIssueRecycle.getVersion()); |
| | | manageRecordIssueRecycle.setReceiveUser(manageDocumentIssueRecycle.getIssueUser()); |
| | | manageRecordIssueRecycle.setReceiveDate(manageDocumentIssueRecycle.getIssueDate()); |
| | | manageRecordIssueRecycle.setSignedUser(manageDocumentIssueRecycle.getRecycleUser()); |
| | | manageRecordIssueRecycle.setSignedDate(manageDocumentIssueRecycle.getRecycleDate()); |
| | | manageRecordIssueRecycleMapper.updateById(manageRecordIssueRecycle); |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotEmpty(manageDocumentIssueRecycle.getFile())) { |
| | | if (ObjectUtils.isNotEmpty(documentIssueRecycle.getUrl())) { |
| | |
| | | <result column="version" property="version"/> |
| | | <result column="writer" property="writer"/> |
| | | <result column="submit_date" property="submitDate"/> |
| | | <result column="publish_date" property="publishDate"/> |
| | | <result column="implement_date" property="implementDate"/> |
| | | <result column="instructions" property="instructions"/> |
| | | <result column="state" property="state"/> |
| | | <result column="url" property="url"/> |
| | |
| | | left join user u1 on cmdc.create_user = u1.id |
| | | left join user u2 on cmdc.duty_user = u2.id |
| | | </select> |
| | | |
| | | <!-- 导å
¥è稿ï¼create_user æ¾å¼å NULLï¼ç³è¯·äººç空 --> |
| | | <insert id="insertImportedDraft" parameterType="java.util.Map"> |
| | | insert into cnas_manage_document_controlled |
| | | (document_code, type, name, version, writer, submit_date, publish_date, implement_date, |
| | | instructions, state, url, duty_user, create_user, update_user, create_time, update_time) |
| | | values |
| | | (#{documentCode}, #{type}, #{name}, #{version}, #{writer}, #{submitDate}, #{publishDate}, #{implementDate}, |
| | | #{instructions}, #{state}, #{url}, #{dutyUser}, null, null, #{createTime}, #{updateTime}) |
| | | </insert> |
| | | </mapper> |
| | |
| | | // å 餿件 |
| | | @DeleteMapping("/deleteCNASFile") |
| | | public Result saveFile(String fileName) { |
| | | if (fileName == null || fileName.trim().isEmpty()) { |
| | | throw new ErrorException("ç¼ºå°æä»¶å"); |
| | | } |
| | | String[] split = fileName.split(","); |
| | | for (String s : split) { |
| | | FileSaveUtil.DeleteFile(s); |
| | | String name = s.trim(); |
| | | if (name.isEmpty()) { |
| | | continue; |
| | | } |
| | | // åªå
许å 餿件åï¼ç¦æ¢éè¿è·¯å¾ç©¿è¶å é¤å
¶ä»ç®å½ |
| | | if (name.contains("/") || name.contains("\\") || name.contains("..")) { |
| | | throw new ErrorException("æä»¶åä¸åæ³"); |
| | | } |
| | | FileSaveUtil.DeleteFile(name); |
| | | } |
| | | return Result.success(); |
| | | |
| | |
| | | |
| | | @Operation(summary = "ä¸è½½äººåæ¡£æ¡å¡") |
| | | @GetMapping("/exportPersonBasicInfoById") |
| | | public Result exportPersonBasicInfoById(Integer id, HttpServletResponse response) { |
| | | return Result.success(personBasicInfoService.exportPersonBasicInfoById(id,response)); |
| | | public void exportPersonBasicInfoById(Integer id, HttpServletResponse response) { |
| | | personBasicInfoService.exportPersonBasicInfoById(id, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.personnel.dto.PersonPersonnelCapacityDto; |
| | | import com.ruoyi.personnel.pojo.PersonPersonnelCapacity; |
| | | import com.ruoyi.personnel.service.PersonPersonnelCapacityService; |
| | |
| | | @Operation(summary = "æ°å¢/æ´æ° 人åè½å") |
| | | @PostMapping("addOrUpdatePersonPersonnelCapacity") |
| | | public Result<?> addOrUpdatePersonPersonnelCapacity(@RequestBody PersonPersonnelCapacity personPersonnelCapacity) { |
| | | if (personPersonnelCapacity == null || personPersonnelCapacity.getUserId() == null) { |
| | | throw new ErrorException("缺å°äººå"); |
| | | } |
| | | if (personPersonnelCapacity.getId() != null) { |
| | | PersonPersonnelCapacity existing = personPersonnelCapacityService.getById(personPersonnelCapacity.getId()); |
| | | if (existing == null) { |
| | | throw new ErrorException("人åè½åè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (existing.getConfirmDate() != null) { |
| | | throw new ErrorException("该记å½å·²ç¡®è®¤ï¼ä¸è½ä¿®æ¹"); |
| | | } |
| | | } |
| | | personPersonnelCapacityService.saveOrUpdate(personPersonnelCapacity); |
| | | return Result.success(); |
| | | } |
| | |
| | | @Operation(summary = "å é¤ äººåè½å") |
| | | @DeleteMapping("deletePersonPersonnelCapacity") |
| | | public Result<?> deletePersonPersonnelCapacity(@RequestParam("id") Integer id) { |
| | | // å 餿°æ® |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°äººåè½åè®°å½id"); |
| | | } |
| | | PersonPersonnelCapacity existing = personPersonnelCapacityService.getById(id); |
| | | if (existing == null) { |
| | | throw new ErrorException("人åè½åè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (existing.getConfirmDate() != null) { |
| | | throw new ErrorException("该记å½å·²ç¡®è®¤ï¼ä¸è½å é¤"); |
| | | } |
| | | personPersonnelCapacityService.removeById(id); |
| | | return Result.success(); |
| | | } |
| | |
| | | @Operation(summary = "确认 人åè½å") |
| | | @PostMapping("confirmPersonnelCapability") |
| | | public Result<?> confirmPersonnelCapability(@RequestBody PersonPersonnelCapacity personPersonnelCapacity) { |
| | | if (personPersonnelCapacity == null || personPersonnelCapacity.getId() == null) { |
| | | throw new ErrorException("缺å°äººåè½åè®°å½id"); |
| | | } |
| | | PersonPersonnelCapacity record = personPersonnelCapacityService.getById(personPersonnelCapacity.getId()); |
| | | if (record == null) { |
| | | throw new ErrorException("人åè½åè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (record.getConfirmDate() != null) { |
| | | throw new ErrorException("该记å½å·²ç¡®è®¤ï¼è¯·å¿éå¤ç¡®è®¤"); |
| | | } |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | if (record.getConfirmOperatingPersonnelId() == null |
| | | || !record.getConfirmOperatingPersonnelId().equals(userId)) { |
| | | throw new ErrorException("æ¨ä¸æ¯è¯¥è®°å½æå®çç¡®è®¤äººï¼æ æ³ç¡®è®¤"); |
| | | } |
| | | personPersonnelCapacityService.update(Wrappers.<PersonPersonnelCapacity>lambdaUpdate() |
| | | .eq(PersonPersonnelCapacity::getId, personPersonnelCapacity.getId()) |
| | | .set(PersonPersonnelCapacity::getConfirmOperatingPersonnelId, userId) |
| | | .set(PersonPersonnelCapacity::getConfirmDate, personPersonnelCapacity.getConfirmDate())); |
| | | .eq(PersonPersonnelCapacity::getId, record.getId()) |
| | | .set(PersonPersonnelCapacity::getConfirmDate, LocalDateTime.now())); |
| | | return Result.success(); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.common.utils.FileSaveUtil; |
| | | import com.ruoyi.personnel.dto.PersonPostAuthorizationRecordDto; |
| | | import com.ruoyi.personnel.pojo.PersonPostAuthorizationRecord; |
| | |
| | | @Operation(summary = "æ°å¢/æ´æ° ä»»èææè®°å½") |
| | | @PostMapping("/addOrUpdatePersonPostAuthorizationRecord") |
| | | public Result<?> addOrUpdatePersonPostAuthorizationRecord(@RequestBody PersonPostAuthorizationRecord personRewardPunishmentRecord) { |
| | | if (personRewardPunishmentRecord == null || personRewardPunishmentRecord.getUserId() == null) { |
| | | throw new ErrorException("è¯·éæ©è¢«ä»»è人å"); |
| | | } |
| | | if (personRewardPunishmentRecord.getPost() == null || personRewardPunishmentRecord.getPost().trim().isEmpty()) { |
| | | throw new ErrorException("请è¾å
¥ä»»èå²ä½"); |
| | | } |
| | | if (personRewardPunishmentRecord.getId() != null |
| | | && personPostAuthorizationRecordService.getById(personRewardPunishmentRecord.getId()) == null) { |
| | | throw new ErrorException("ä»»èææè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | personPostAuthorizationRecordService.saveOrUpdate(personRewardPunishmentRecord); |
| | | return Result.success(); |
| | | } |
| | |
| | | @Operation(summary = "å é¤ ä»»èææè®°å½") |
| | | @DeleteMapping("/deletePersonPostAuthorizationRecord") |
| | | public Result<?> deletePersonPostAuthorizationRecord(@RequestParam("id") Integer id) { |
| | | // å 餿件 |
| | | PersonPostAuthorizationRecord postAuthorizationRecord = personPostAuthorizationRecordService.getById(id); |
| | | if (postAuthorizationRecord == null) { |
| | | throw new ErrorException("ä»»èææè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | // å 餿件 |
| | | FileSaveUtil.DeleteFile(postAuthorizationRecord.getSystemFileName()); |
| | | // å 餿°æ® |
| | | personPostAuthorizationRecordService.removeById(id); |
| | |
| | | @Schema(description = "è§è²") |
| | | private String roleName; |
| | | |
| | | @Schema(description = "ç»ç»æ¶æid") |
| | | private Integer departmentId; |
| | | |
| | | } |
| | |
| | | private String personnelClassification; |
| | | |
| | | @Schema(description = "åºçæ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
| | | @TableField(updateStrategy = FieldStrategy.ALWAYS) // 为空å¯ä»¥æ´æ° |
| | | private LocalDateTime dateBirth; |
| | | |
| | |
| | | private String officialAcademicRedentials; |
| | | |
| | | @Schema(description = "æ¯ä¸æ¶é´1") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
| | | @ExcelProperty("æ¯ä¸æ¶é´") |
| | | private LocalDateTime graduationTime1; |
| | | |
| | |
| | | private String major1; |
| | | |
| | | @Schema(description = "æ¯ä¸æ¶é´2") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
| | | @TableField(updateStrategy = FieldStrategy.ALWAYS) // 为空å¯ä»¥æ´æ° |
| | | private LocalDateTime graduationTime2; |
| | | |
| | |
| | | package com.ruoyi.personnel.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | |
| | | private String submittingOperator; |
| | | |
| | | @Schema(description = "1æäº¤æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime submittingDate; |
| | | |
| | | @Schema(description = "2 ä»»è人 主管id") |
| | |
| | | private String incumbentOperator; |
| | | |
| | | @Schema(description = "2 ä»»è人 æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime incumbentDate; |
| | | |
| | | @Schema(description = "3 主管 æä½äºº") |
| | | private String supervisorOperator; |
| | | |
| | | @Schema(description = "3 主管 æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime supervisorDate; |
| | | |
| | | @Schema(description = "å建人id", hidden = true) |
| | |
| | | |
| | | @Schema(description = "åå»ºæ¥æ / æäº¤æ¥æ", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "å½åè´è´£äºº") |
| | |
| | | package com.ruoyi.personnel.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | |
| | | private Integer confirmOperatingPersonnelId; |
| | | |
| | | @Schema(description = "2 确认人 æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime confirmDate; |
| | | |
| | | @Schema(description = "åå»ºæ¥æ", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "æ´æ°æ¥æ", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @Schema(description = "å建人", hidden = true) |
| | |
| | | package com.ruoyi.personnel.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | |
| | | |
| | | @Schema(description = "å建æ¶é´", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "æ´æ°æ¶é´", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @Schema(description = "æ´æ°äººid", hidden = true) |
| | |
| | | package com.ruoyi.personnel.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | |
| | | private Integer compilerId; |
| | | |
| | | @Schema(description = "ç¼å¶æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime compilationDate; |
| | | |
| | | @Schema(description = "å®¡æ ¸äººid") |
| | | private Integer reviewerId; |
| | | |
| | | @Schema(description = "å®¡æ ¸æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime auditDate; |
| | | |
| | | @Schema(description = "å®¡æ ¸ç¶æ") |
| | |
| | | private Integer approvalStatus; |
| | | |
| | | @Schema(description = "æ¹åæ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime approvalDate; |
| | | |
| | | @Schema(description = "åå»ºæ¥æ") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "å建人id") |
| | |
| | | |
| | | @Schema(description = "æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @Schema(description = "æ´æ°äººid") |
| | |
| | | @Override |
| | | public void exportPersonBasicInfo(UserPageDto userPageDto, HttpServletResponse response) throws Exception { |
| | | ArrayList<PersonBasicInfoDto> data = new ArrayList<>(); |
| | | List<User> list = userMapper.selectList(null); |
| | | LambdaQueryWrapper<User> userWrapper = Wrappers.<User>lambdaQuery() |
| | | .and(w -> w.eq(User::getDelFlag, "0").or().isNull(User::getDelFlag)) |
| | | .and(w -> w.eq(User::getIsCustom, 0).or().isNull(User::getIsCustom)); |
| | | if (userPageDto != null) { |
| | | if (ObjectUtils.isNotEmpty(userPageDto.getName())) { |
| | | userWrapper.like(User::getName, userPageDto.getName().trim()); |
| | | } |
| | | if (userPageDto.getDepartmentId() != null) { |
| | | userWrapper.apply("FIND_IN_SET({0}, depart_lims_id)", userPageDto.getDepartmentId()); |
| | | } |
| | | } |
| | | List<User> list = userMapper.selectList(userWrapper); |
| | | for (User user : list) { |
| | | PersonBasicInfoDto personBasicInfoDto = new PersonBasicInfoDto(); |
| | | PersonBasicInfo personBasicInfo = baseMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery().eq(PersonBasicInfo::getUserId, user.getId())); |
| | |
| | | |
| | | @Override |
| | | public String exportPersonBasicInfoById(Integer id, HttpServletResponse response) { |
| | | Map<String, Object> userMap = baseMapper.selectexportPersonBasic(id); |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°äººåid"); |
| | | } |
| | | User user = userMapper.selectById(id); |
| | | PersonBasicInfo personBasicInfo = baseMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery().eq(PersonBasicInfo::getUserId, user.getId())); |
| | | if (user == null) { |
| | | throw new ErrorException("人åä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | PersonBasicInfo personBasicInfo = baseMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery().eq(PersonBasicInfo::getUserId, id)); |
| | | if (ObjectUtils.isEmpty(personBasicInfo)){ |
| | | throw new ErrorException("è¯¥ç¨æ·çåºæ¬ä¿¡æ¯æ²¡æå½å
¥,ææ æ³å¯¼åº"); |
| | | } |
| | | Map<String, Object> userMap = baseMapper.selectexportPersonBasic(id); |
| | | // è¯ä»¶ |
| | | List<Annex> annexList = annexMapper.selectList(Wrappers.<Annex>lambdaQuery() |
| | | .eq(Annex::getUserId, id)); |
| | |
| | | */ |
| | | @Override |
| | | public boolean delDepartment(Integer id) { |
| | | //夿æ¯å¦æåç±»,ç´å°æ²¡æä¸ºæ¢ |
| | | List<DepartmentLims> department = getDepartment(id); |
| | | List<Integer> ids = department.stream().map(DepartmentLims::getId).collect(Collectors.toList()); |
| | | departmentMapper.delete(Wrappers.<DepartmentLims>lambdaQuery() |
| | | .in(DepartmentLims::getId, ids)); |
| | | return true; |
| | | } |
| | | |
| | | //夿æ¯å¦æåç±»,ç´å°æ²¡æä¸ºæ¢ |
| | | public List<DepartmentLims> getDepartment(Integer id) { |
| | | List<DepartmentLims> list = new ArrayList<>(); |
| | | DepartmentLims depart = departmentMapper.selectById(id); |
| | | list.add(depart); |
| | | List<DepartmentLims> departments = departmentMapper.selectList(Wrappers.<DepartmentLims>lambdaQuery().eq(DepartmentLims::getFatherId, id)); |
| | | if (ObjectUtils.isNotEmpty(departments)) { |
| | | list.addAll(departments); |
| | | for (DepartmentLims department : departments) { |
| | | list.addAll(getDepartment(department.getId())); |
| | | } |
| | | if (id == null) { |
| | | throw new ErrorException("ç¼ºå°æ¶æid"); |
| | | } |
| | | return list; |
| | | DepartmentLims depart = departmentMapper.selectById(id); |
| | | if (depart == null) { |
| | | throw new ErrorException("è¯¥æ¶æä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | Long childCount = departmentMapper.selectCount(Wrappers.<DepartmentLims>lambdaQuery() |
| | | .eq(DepartmentLims::getFatherId, id)); |
| | | if (childCount != null && childCount > 0) { |
| | | throw new ErrorException("è¯¥æ¶æä¸åå¨ä¸çº§æ¶æï¼è¯·å
å é¤ä¸çº§æ¶æ"); |
| | | } |
| | | Long userCount = userMapper.selectCount(Wrappers.<User>lambdaQuery() |
| | | .and(w -> w.eq(User::getDelFlag, "0").or().isNull(User::getDelFlag)) |
| | | .apply("FIND_IN_SET({0}, depart_lims_id)", id)); |
| | | if (userCount != null && userCount > 0) { |
| | | throw new ErrorException("è¯¥æ¶æä¸è¿æäººåï¼è¯·å
å°äººåç§»åºè¯¥æ¶æ"); |
| | | } |
| | | departmentMapper.deleteById(id); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.config.ConfigureBuilder; |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.personnel.dto.PersonJobResponsibilitiesDto; |
| | | import com.ruoyi.personnel.mapper.PersonJobResponsibilitiesMapper; |
| | | import com.ruoyi.personnel.pojo.PersonJobResponsibilities; |
| | |
| | | |
| | | @Override |
| | | public void exportPersonJobResponsibilities(Integer id, HttpServletResponse response) { |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°å²ä½èè´£id"); |
| | | } |
| | | PersonJobResponsibilities personJobResponsibilities = baseMapper.selectById(id); |
| | | if (personJobResponsibilities == null) { |
| | | throw new ErrorException("å²ä½èè´£ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (ObjectUtils.isEmpty(personJobResponsibilities.getIncumbentId())) { |
| | | throw new ErrorException("该å²ä½èè´£è¿æ²¡æéæ©ä»»èäººï¼ææ æ³å¯¼åº"); |
| | | } |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyå¹´MMæddæ¥"); |
| | | //å²ä½åç§° |
| | | String name = personJobResponsibilities.getPostName(); |
| | | Integer incumbentUserId = Integer.parseInt(personJobResponsibilities.getIncumbentId()); |
| | | //æå±é¨é¨ |
| | | String departLims = userMapper.selectUserDepartmentLimsName(Integer.parseInt(personJobResponsibilities.getIncumbentId())); |
| | | String departLims = userMapper.selectUserDepartmentLimsName(incumbentUserId); |
| | | //å·¥ä½ç®æ |
| | | String objective = personJobResponsibilities.getJobObjective(); |
| | | //å²ä½èè´£ |
| | | String responsibilities = personJobResponsibilities.getJobResponsibilities(); |
| | | //ä»»è人 |
| | | User user = userMapper.selectById(Integer.parseInt(personJobResponsibilities.getIncumbentId())); |
| | | User user = userMapper.selectById(incumbentUserId); |
| | | if (user == null) { |
| | | throw new ErrorException("ä»»è人ä¸åå¨æå·²è¢«å é¤ï¼è¯·éæ°éæ©ä»»è人"); |
| | | } |
| | | String incumbent = user.getName(); |
| | | //ä»»èæ¶é´ |
| | | String incumbentDate = ""; |
| | |
| | | //主管 |
| | | String supervisor = ""; |
| | | if (ObjectUtils.isNotEmpty(personJobResponsibilities.getSupervisorId())) { |
| | | supervisor = userMapper.selectById(personJobResponsibilities.getSupervisorId()).getName(); |
| | | User supervisorUser = userMapper.selectById(personJobResponsibilities.getSupervisorId()); |
| | | supervisor = supervisorUser != null ? supervisorUser.getName() : ""; |
| | | } |
| | | //主管æ¶é´ |
| | | String supervisorDate = ""; |
| | |
| | | |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | |
| | | */ |
| | | @Override |
| | | public void exportPersonnelCapacity(Integer id, HttpServletResponse response) { |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°äººåè½åè®°å½id"); |
| | | } |
| | | PersonPersonnelCapacityExportDto capacityExportDto = baseMapper.selectExportPersonnelCapacity(id); |
| | | if (capacityExportDto == null) { |
| | | throw new ErrorException("人åè½åè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | |
| | | // 确认人 |
| | | String confirmUrl = null; |
| | | if (capacityExportDto.getConfirmOperatingPersonnelId() != null) { |
| | | confirmUrl = userMapper.selectById(capacityExportDto.getConfirmOperatingPersonnelId()).getSignatureUrl(); |
| | | User confirmUser = userMapper.selectById(capacityExportDto.getConfirmOperatingPersonnelId()); |
| | | if (confirmUser == null) { |
| | | throw new ErrorException("确认人ä¸åå¨æå·²è¢«å é¤ï¼æ æ³å¯¼åº"); |
| | | } |
| | | confirmUrl = confirmUser.getSignatureUrl(); |
| | | if (StringUtils.isBlank(confirmUrl)) { |
| | | throw new ErrorException("缺å°ç¡®è®¤äººç¾å"); |
| | | throw new ErrorException("ç¡®è®¤äººè¿æ²¡æä¸ä¼ ç¾åï¼æ æ³å¯¼åº"); |
| | | } |
| | | if (!new File(imgUrl + "/" + confirmUrl).exists()) { |
| | | throw new ErrorException("确认人ç¾åæä»¶ä¸åå¨ï¼è¯·è®©ç¡®è®¤äººéæ°ä¸ä¼ "); |
| | | } |
| | | } |
| | | |
| | | // è·åè·¯å¾ |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/personnel-capacity.docx"); |
| | | if (inputStream == null) { |
| | | throw new ErrorException("人åè½åå¯¼åºæ¨¡æ¿ä¸åå¨"); |
| | | } |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | String finalConfirmUrl = confirmUrl; |
| | |
| | | |
| | | try { |
| | | response.setContentType("application/msword"); |
| | | String fileName = URLEncoder.encode( |
| | | "人åè½å", "UTF-8"); |
| | | String userName = StringUtils.isBlank(capacityExportDto.getUserName()) ? "人åè½å" : capacityExportDto.getUserName() + "人åè½å认å®"; |
| | | String fileName = URLEncoder.encode(userName, "UTF-8"); |
| | | response.setHeader("Content-disposition", |
| | | "attachment;filename=" + fileName + ".docx"); |
| | | OutputStream os = response.getOutputStream(); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void submitConfirmPersonnelCapability(PersonPersonnelCapacity personPersonnelCapacity) { |
| | | if (personPersonnelCapacity.getUserId() == null) { |
| | | throw new ErrorException("缺å°äººå"); |
| | | } |
| | | if (personPersonnelCapacity.getConfirmOperatingPersonnelId() == null) { |
| | | throw new ErrorException("缺å°ç¡®è®¤äºº"); |
| | | } |
| | | User formUser = userMapper.selectById(personPersonnelCapacity.getUserId()); |
| | | if (formUser == null) { |
| | | throw new ErrorException("人åä¸åå¨æå·²è¢«å é¤ï¼æ æ³æäº¤"); |
| | | } |
| | | User confirmUser = userMapper.selectById(personPersonnelCapacity.getConfirmOperatingPersonnelId()); |
| | | if (confirmUser == null) { |
| | | throw new ErrorException("确认人ä¸åå¨æå·²è¢«å é¤ï¼æ æ³æäº¤"); |
| | | } |
| | | if (personPersonnelCapacity.getId() != null) { |
| | | PersonPersonnelCapacity existing = this.getById(personPersonnelCapacity.getId()); |
| | | if (existing == null) { |
| | | throw new ErrorException("人åè½åè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (existing.getConfirmDate() != null) { |
| | | throw new ErrorException("该记å½å·²ç¡®è®¤ï¼ä¸è½éå¤æäº¤"); |
| | | } |
| | | } |
| | | |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId); |
| | | // æäº¤åç¡®è®¤æ¥æåå¼ï¼ç¡®è®¤æ¥æåªå¨ç¡®è®¤æä½æ¶ç±ç³»ç»åå
¥ |
| | | personPersonnelCapacity.setConfirmDate(null); |
| | | this.saveOrUpdate(personPersonnelCapacity); |
| | | |
| | | // æ¶æ¯åé |
| | | InformationNotification info = new InformationNotification(); |
| | | // åé人 |
| | | info.setCreateUser(user.getName()); |
| | | info.setCreateUser(user != null ? user.getName() : ""); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNAS人åè½å确认éç¥"); |
| | | info.setContent(formUser.getName() + "ç人åè½åå¾
确认"); |
| | |
| | | info.setConsigneeId(personPersonnelCapacity.getConfirmOperatingPersonnelId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | this.saveOrUpdate(personPersonnelCapacity); |
| | | |
| | | // åéä¼ä¸å¾®ä¿¡éç¥ |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // æ¥è¯¢æ¥æ¶äºº |
| | | User personnel = userMapper.selectById(personPersonnelCapacity.getConfirmOperatingPersonnelId()); |
| | | |
| | | if (confirmUser.getAccount() == null || confirmUser.getAccount().trim().isEmpty()) { |
| | | return; |
| | | } |
| | | String message = ""; |
| | | message += "CNAS人åè½å确认éç¥"; |
| | | message += "\n请å»èµæºç®¡ç-人å-人åè½åå¡«å"; |
| | | message += "\n请å»èµæºè¦æ±-人å-人å管ç-人åè½åå¡«å"; |
| | | message += "\n" + formUser.getName() + "ç人åè½åå¾
确认"; |
| | | //åéä¼ä¸å¾®ä¿¡æ¶æ¯éç¥ |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | WxCpUtils.inform(confirmUser.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.personnel.dto.PersonPostAuthorizationRecordDto; |
| | | import com.ruoyi.personnel.mapper.PersonBasicInfoMapper; |
| | | import com.ruoyi.personnel.mapper.PersonPostAuthorizationRecordMapper; |
| | | import com.ruoyi.personnel.pojo.PersonBasicInfo; |
| | | import com.ruoyi.personnel.pojo.PersonPostAuthorizationRecord; |
| | | import com.ruoyi.personnel.service.PersonPostAuthorizationRecordService; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | |
| | | |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | @Resource |
| | | private PersonBasicInfoMapper personBasicInfoMapper; |
| | | |
| | | @Value("${file.path}") |
| | | private String imgUrl; |
| | |
| | | |
| | | @Override |
| | | public void exportPersonPostAuthorizationRecord(Integer id, HttpServletResponse response) { |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°ä»»èææè®°å½id"); |
| | | } |
| | | PersonPostAuthorizationRecord personPostAuthorizationRecord = baseMapper.selectById(id); |
| | | if (personPostAuthorizationRecord == null) { |
| | | throw new ErrorException("ä»»èææè®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | Integer incumbentUserId; |
| | | try { |
| | | incumbentUserId = Integer.valueOf(personPostAuthorizationRecord.getUserId()); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("è¯¥è®°å½æ²¡æéæ©è¢«ä»»è人åï¼æ æ³å¯¼åºä¸å²è¯"); |
| | | } |
| | | //å§å |
| | | User user = userMapper.selectById(personPostAuthorizationRecord.getUserId()); |
| | | User user = userMapper.selectById(incumbentUserId); |
| | | if (user == null) { |
| | | throw new ErrorException("被任è人åä¸åå¨æå·²è¢«å é¤ï¼æ æ³å¯¼åºä¸å²è¯"); |
| | | } |
| | | String name = user.getName(); |
| | | //todo: 人åä»»èææè®°å½å§åè±æ |
| | | // HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); |
| | | // format.setCaseType(HanyuPinyinCaseType.LOWERCASE); |
| | | // format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
| | | // StringBuilder pinyinBuilder = new StringBuilder(); |
| | | // for (int i = 0; i < name.length(); i++) { |
| | | // char c = name.charAt(i); |
| | | // // 夿æ¯å¦æ¯æ±å |
| | | // if (Character.toString(c).matches("[\\u4E00-\\u9FFF]")) { |
| | | // // è·åæ±åçæ¼é³æ°ç» |
| | | // String[] pinyinArray = new String[0]; |
| | | // try { |
| | | // pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format); |
| | | // } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { |
| | | // |
| | | // } |
| | | // if (pinyinArray!= null && pinyinArray.length > 0) { |
| | | // pinyinBuilder.append(pinyinArray[0]); |
| | | // } |
| | | // } else { |
| | | // pinyinBuilder.append(c); |
| | | // } |
| | | // } |
| | | // String nameEn = pinyinBuilder.toString(); |
| | | String nameEn = user.getNameEn(); |
| | | //ç论ç¥è¯èè¯æç»© |
| | | String num1=personPostAuthorizationRecord.getNum1(); |
| | | //æä½æè½èè¯æç»© |
| | | String num2=personPostAuthorizationRecord.getNum2(); |
| | | //身份è¯å· |
| | | PersonBasicInfo basicInfo = personBasicInfoMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery() |
| | | .eq(PersonBasicInfo::getUserId, incumbentUserId) |
| | | .last("limit 1")); |
| | | if (basicInfo == null || StringUtils.isBlank(basicInfo.getIdentityCard())) { |
| | | throw new ErrorException(name + "è¿æ²¡æå¨äººååºæ¬ä¿¡æ¯ä¸å¡«å身份è¯å·ï¼æ æ³å¯¼åºä¸å²è¯"); |
| | | } |
| | | String identityCard = basicInfo.getIdentityCard(); |
| | | //è¯ä¹¦ç¼å· |
| | | String code = personPostAuthorizationRecord.getCertificateNumber(); |
| | | if (StringUtils.isBlank(code)) { |
| | | throw new ErrorException("该记å½è¿æ²¡æå¡«åè¯ä¹¦ç¼å·ï¼æ æ³å¯¼åºä¸å²è¯"); |
| | | } |
| | | //ä»»èå²ä½ |
| | | String post = personPostAuthorizationRecord.getPost(); |
| | | String finalPost = StringUtils.isBlank(post) ? "æ£æµ" : post; |
| | | //åè¯æ¶é´ |
| | | LocalDateTime createTime = personPostAuthorizationRecord.getCreateTime(); |
| | | if (createTime == null) { |
| | | createTime = LocalDateTime.now(); |
| | | } |
| | | String year = createTime.getYear() + ""; |
| | | String mon = createTime.getMonth().getValue() + ""; |
| | | String mon = createTime.getMonthValue() + ""; |
| | | String day = createTime.getDayOfMonth() + ""; |
| | | //个人ç
§ç |
| | | if (ObjectUtils.isEmpty(user.getPictureUrl())) { |
| | | throw new ErrorException(name+"ç个人ç
§ç没æä¸ä¼ "); |
| | | throw new ErrorException(name + "ç个人ç
§ç没æä¸ä¼ ï¼æ æ³å¯¼åºä¸å²è¯"); |
| | | } |
| | | String pictureUrl = user.getPictureUrl(); |
| | | |
| | | if (!new File(imgUrl + "/" + pictureUrl).exists()) { |
| | | throw new ErrorException(name + "ç个人ç
§çæä»¶ä¸åå¨ï¼è¯·éæ°ä¸ä¼ "); |
| | | } |
| | | |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/credentials-deal.docx"); |
| | | if (inputStream == null) { |
| | | throw new ErrorException("ä¸å²è¯å¯¼åºæ¨¡æ¿ä¸åå¨"); |
| | | } |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("name", name); |
| | | put("nameEn", nameEn); |
| | | put("num1", num1); |
| | | put("num2", num2); |
| | | put("identityCard", identityCard); |
| | | put("code", code); |
| | | put("post", finalPost); |
| | | put("year", year); |
| | | put("mon", mon); |
| | | put("day", day); |
| | | put("writeUrl", new FilePictureRenderData(100,50,imgUrl + "/" + pictureUrl)); |
| | | put("writeUrl", new FilePictureRenderData(100, 140, imgUrl + "/" + pictureUrl)); |
| | | }}); |
| | | |
| | | try { |
| | | response.setContentType("application/msword"); |
| | | String fileName = URLEncoder.encode( |
| | | name+"çå²ä½èä¸èµæ ¼æ£å¼", "UTF-8"); |
| | | name + "çæ£æµäººåä¸å²è¯", "UTF-8"); |
| | | response.setHeader("Content-disposition", |
| | | "attachment;filename=" + fileName + ".docx"); |
| | | OutputStream os = response.getOutputStream(); |
| | |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.WxCpUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.util.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.personnel.dto.PersonTrainingRecordDto; |
| | | import com.ruoyi.personnel.dto.PersonTrainingRecordListDto; |
| | |
| | | |
| | | @Override |
| | | public void exportTrainingRecordAddTrainingDate(Integer userId, Integer trainingDate, HttpServletResponse response) { |
| | | if (userId == null) { |
| | | throw new ErrorException("缺å°äººåid"); |
| | | } |
| | | // æ¥è¯¢äººåäººä¿¡æ¯ |
| | | PersonTrainingRecordListDto trainingRecordListDto = baseMapper.selectUserTraining(userId); |
| | | if (trainingRecordListDto == null) { |
| | | throw new ErrorException("人åä¸åå¨æå·²è¢«å é¤ï¼æ æ³å¯¼åº"); |
| | | } |
| | | |
| | | // æ¥è¯¢å¹è®è®°å½ |
| | | List<TrainingRecordPersonDetailedDto> personDetailedDtos = baseMapper.selectPersonDetailedDtosByTrainingDate(userId, trainingDate); |
| | |
| | | |
| | | // è·åè·¯å¾ |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/training-record.docx"); |
| | | if (inputStream == null) { |
| | | throw new ErrorException("å¹è®è®°å½å¯¼åºæ¨¡æ¿ä¸åå¨"); |
| | | } |
| | | Configure configure = Configure.builder() |
| | | .bind("personnelDetailsLisat", new HackLoopTableRenderPolicy()) |
| | | .build(); |
| | |
| | | */ |
| | | @Override |
| | | public void trainingAndAssessmentRecordsAdded(PersonTrainingRecordSubmitDto personTrainingRecordSubmitDto) { |
| | | if (personTrainingRecordSubmitDto == null || personTrainingRecordSubmitDto.getTrainingDetailedId() == null) { |
| | | throw new ErrorException("缺å°å¹è®æç»id"); |
| | | } |
| | | if (personTrainingRecordSubmitDto.getState() == null) { |
| | | throw new ErrorException("缺å°å¹è®ç¶æ"); |
| | | } |
| | | PersonTrainingDetailed personPersonnelCapacity = personTrainingDetailedService.getById(personTrainingRecordSubmitDto.getTrainingDetailedId()); |
| | | if (personPersonnelCapacity == null) { |
| | | throw new ErrorException("å¹è®è®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | boolean waitEvaluate = Integer.valueOf(2).equals(personTrainingRecordSubmitDto.getState()); |
| | | if (waitEvaluate && personTrainingRecordSubmitDto.getAssessmentUserId() == null) { |
| | | throw new ErrorException("è¯·éæ©è¯ä»·äºº"); |
| | | } |
| | | |
| | | personTrainingDetailedService.update(Wrappers.<PersonTrainingDetailed>lambdaUpdate() |
| | | .eq(PersonTrainingDetailed::getId, personTrainingRecordSubmitDto.getTrainingDetailedId()) |
| | | .set(PersonTrainingDetailed::getAssessmentMethod, personTrainingRecordSubmitDto.getAssessmentMethod()) |
| | |
| | | .set(PersonTrainingDetailed::getAssessmentUserId, personTrainingRecordSubmitDto.getAssessmentUserId()) |
| | | .set(PersonTrainingDetailed::getState, personTrainingRecordSubmitDto.getState())); |
| | | |
| | | // åéæ¶æ¯éç¥ |
| | | if (personTrainingRecordSubmitDto.getState().equals(2)) { |
| | | PersonTrainingDetailed personPersonnelCapacity = personTrainingDetailedService.getById(personTrainingRecordSubmitDto.getTrainingDetailedId()); |
| | | |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId); |
| | | // æ¶æ¯åé |
| | | InformationNotification info = new InformationNotification(); |
| | | // åé人 |
| | | info.setCreateUser(user.getName()); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNAS人åå¹è®è®¡åå¾
è¯ä»·"); |
| | | info.setContent("å¹è®å
容:" + personPersonnelCapacity.getTrainingContent() + "ç人åå¹è®å¾
è¯ä»·"); |
| | | info.setSenderId(userId); |
| | | // æ¥æ¶äºº |
| | | info.setConsigneeId(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // åéä¼ä¸å¾®ä¿¡éç¥ |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // æ¥è¯¢æ¥æ¶äºº |
| | | User personnel = userMapper.selectById(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | |
| | | String message = ""; |
| | | message += "CNAS人åå¹è®è®¡åå¾
è¯ä»·"; |
| | | message += "\n请å»èµæºç®¡ç-人å-人åå¹è®è®¡å"; |
| | | message += "\n" + "å¹è®å
容:" + personPersonnelCapacity.getTrainingContent() + "ç人åå¹è®å¾
è¯ä»·"; |
| | | //åéä¼ä¸å¾®ä¿¡æ¶æ¯éç¥ |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | // åªææäº¤å¾
è¯ä»·æ¶æéç¥è¯ä»·äºº |
| | | if (!waitEvaluate) { |
| | | return; |
| | | } |
| | | |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId); |
| | | // æ¶æ¯åé |
| | | InformationNotification info = new InformationNotification(); |
| | | // åé人 |
| | | info.setCreateUser(user != null ? user.getName() : ""); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNAS人åå¹è®è®¡åå¾
è¯ä»·"); |
| | | info.setContent("å¹è®å
容:" + personPersonnelCapacity.getTrainingContent() + "ç人åå¹è®å¾
è¯ä»·"); |
| | | info.setSenderId(userId); |
| | | // æ¥æ¶äºº |
| | | info.setConsigneeId(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // åéä¼ä¸å¾®ä¿¡éç¥ |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // æ¥è¯¢æ¥æ¶äºº |
| | | User personnel = userMapper.selectById(personTrainingRecordSubmitDto.getAssessmentUserId()); |
| | | if (personnel == null || personnel.getAccount() == null || personnel.getAccount().trim().isEmpty()) { |
| | | return; |
| | | } |
| | | String message = ""; |
| | | message += "CNAS人åå¹è®è®¡åå¾
è¯ä»·"; |
| | | message += "\n请å»èµæºç®¡ç-人å-人åå¹è®è®¡å"; |
| | | message += "\n" + "å¹è®å
容:" + personPersonnelCapacity.getTrainingContent() + "ç人åå¹è®å¾
è¯ä»·"; |
| | | //åéä¼ä¸å¾®ä¿¡æ¶æ¯éç¥ |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.personnel.pojo.PersonTraining; |
| | | import com.ruoyi.personnel.pojo.PersonTrainingDetailed; |
| | | import com.ruoyi.personnel.pojo.PersonTrainingDetailedFile; |
| | | import com.ruoyi.personnel.pojo.PersonTrainingRecord; |
| | | import com.ruoyi.personnel.service.PersonTrainingDetailedService; |
| | | import com.ruoyi.personnel.service.PersonTrainingService; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Override |
| | | public void personTrainingImport(MultipartFile file, PersonTraining training) { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new ErrorException("è¯·éæ©å¯¼å
¥æä»¶"); |
| | | } |
| | | if (training == null || StringUtils.isBlank(training.getPlanYear())) { |
| | | throw new ErrorException("è¯·éæ©è®¡å年份"); |
| | | } |
| | | if (training.getReviewerId() == null) { |
| | | throw new ErrorException("è¯·éæ©å®¡æ ¸äºº"); |
| | | } |
| | | String originalFilename = file.getOriginalFilename(); |
| | | if (StringUtils.isBlank(originalFilename)) { |
| | | throw new ErrorException("æä»¶åä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | // 年度计åç¶çº§æ°å¢æ°æ® |
| | | PersonTraining personSupervisePlan = new PersonTraining(); |
| | | String fileName = file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")); |
| | | String fileName = originalFilename.contains(".") |
| | | ? originalFilename.substring(0, originalFilename.lastIndexOf(".")) |
| | | : originalFilename; |
| | | personSupervisePlan.setFileName(fileName); |
| | | personSupervisePlan.setPlanYear(training.getPlanYear()); |
| | | personSupervisePlan.setCompilerId(userId); |
| | | personSupervisePlan.setReviewerId(training.getReviewerId()); |
| | | personSupervisePlan.setCompilationDate(LocalDateTime.now()); |
| | | baseMapper.insert(personSupervisePlan); |
| | | User user = userMapper.selectById(userId); |
| | | // æ¶æ¯åé |
| | | InformationNotification info = new InformationNotification(); |
| | | // åé人 |
| | | info.setCreateUser(user.getName()); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNASå¹è®è®¡åå®¡æ ¸éç¥"); |
| | | info.setContent("æ¨æä¸æ¡å¹è®è®¡åå¾
å®¡æ ¸"); |
| | | info.setSenderId(userId); |
| | | // æ¥æ¶äºº |
| | | info.setConsigneeId(training.getApproverId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // åéä¼ä¸å¾®ä¿¡éç¥ |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // æ¥è¯¢æ¥æ¶äºº |
| | | User personnel = userMapper.selectById(training.getApproverId()); |
| | | |
| | | String message = ""; |
| | | message += "CNASå¹è®è®¡åå®¡æ ¸éç¥"; |
| | | message += "\n请å»èµæºç®¡ç-人å-å¹è®è®¡åå¡«å"; |
| | | message += "\n" + fileName + "çå¹è®è®¡åå¾
å®¡æ ¸"; |
| | | //åéä¼ä¸å¾®ä¿¡æ¶æ¯éç¥ï¼æ¥æ¶äººä¸å卿åé失败ä¸å½±å导å
¥æµç¨ï¼ |
| | | if (personnel == null || StringUtils.isBlank(personnel.getAccount())) { |
| | | return; |
| | | } |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | |
| | | // 年度计å详æ
æ°å¢ |
| | | try { |
| | |
| | | personSupervisePlanDetailsListener.setPlanId(personSupervisePlan.getId()); |
| | | EasyExcel.read(file.getInputStream(), PersonTrainingDetailedUpload.class, personSupervisePlanDetailsListener).sheet().doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw new ErrorException("读å导å
¥æä»¶å¤±è´¥ï¼è¯·æ£æ¥æä»¶æ ¼å¼"); |
| | | } |
| | | |
| | | User user = userMapper.selectById(userId); |
| | | // æ¶æ¯åéï¼æ¥æ¶äººä¸ºéå®çå®¡æ ¸äººï¼ |
| | | InformationNotification info = new InformationNotification(); |
| | | info.setCreateUser(user != null ? user.getName() : ""); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNASå¹è®è®¡åå®¡æ ¸éç¥"); |
| | | info.setContent("æ¨æä¸æ¡å¹è®è®¡åå¾
å®¡æ ¸"); |
| | | info.setSenderId(userId); |
| | | info.setConsigneeId(training.getReviewerId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // åéä¼ä¸å¾®ä¿¡éç¥ï¼æ¥æ¶äººä¸å卿åé失败ä¸å½±å导å
¥æµç¨ï¼ |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | User personnel = userMapper.selectById(training.getReviewerId()); |
| | | if (personnel == null || StringUtils.isBlank(personnel.getAccount())) { |
| | | return; |
| | | } |
| | | String message = ""; |
| | | message += "CNASå¹è®è®¡åå®¡æ ¸éç¥"; |
| | | message += "\n请å»èµæºç®¡ç-人å-å¹è®è®¡åå¡«å"; |
| | | message += "\n" + fileName + "çå¹è®è®¡åå¾
å®¡æ ¸"; |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void personTrainingDelete(Integer id) { |
| | | personTrainingDetailedService.remove(Wrappers.<PersonTrainingDetailed>lambdaQuery() |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°è®¡åid"); |
| | | } |
| | | List<PersonTrainingDetailed> details = personTrainingDetailedService.list(Wrappers.<PersonTrainingDetailed>lambdaQuery() |
| | | .eq(PersonTrainingDetailed::getPlanId, id)); |
| | | if (!details.isEmpty()) { |
| | | List<Integer> detailIds = details.stream().map(PersonTrainingDetailed::getId).collect(Collectors.toList()); |
| | | // è¿åæç»ä¸çå¹è®è®°å½ãéä»¶ä¸èµ·å é¤ï¼é¿å
çä¸å¤å¿æ°æ® |
| | | personTrainingRecordMapper.delete(Wrappers.<PersonTrainingRecord>lambdaQuery() |
| | | .in(PersonTrainingRecord::getCourseId, detailIds)); |
| | | personTrainingDetailedFileMapper.delete(Wrappers.<PersonTrainingDetailedFile>lambdaQuery() |
| | | .in(PersonTrainingDetailedFile::getTrainingDetailedId, detailIds)); |
| | | personTrainingDetailedService.remove(Wrappers.<PersonTrainingDetailed>lambdaQuery() |
| | | .eq(PersonTrainingDetailed::getPlanId, id)); |
| | | } |
| | | baseMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void reviewAnnualPersonnelTraining(PersonTraining training) { |
| | | PersonTraining personTraining = new PersonTraining(); |
| | | personTraining.setId(training.getId()); |
| | | personTraining.setApproverId(training.getApproverId());// æ·»å æ¹å人 |
| | | personTraining.setAuditDate(LocalDateTime.now()); |
| | | personTraining.setAuditRemarks(training.getAuditRemarks()); |
| | | personTraining.setReviewerStatus(training.getReviewerStatus()); |
| | | |
| | | if (training == null || training.getId() == null) { |
| | | throw new ErrorException("缺å°è®¡åid"); |
| | | } |
| | | if (!Integer.valueOf(1).equals(training.getReviewerStatus()) && !Integer.valueOf(2).equals(training.getReviewerStatus())) { |
| | | throw new ErrorException("å®¡æ ¸ç»æä¸æ£ç¡®"); |
| | | } |
| | | PersonTraining old = baseMapper.selectById(training.getId()); |
| | | if (old == null) { |
| | | throw new ErrorException("å¹è®è®¡åä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (Integer.valueOf(1).equals(old.getReviewerStatus())) { |
| | | throw new ErrorException("该计åå·²å®¡æ ¸éè¿ï¼è¯·å¿éå¤å®¡æ ¸"); |
| | | } |
| | | boolean passed = Integer.valueOf(1).equals(training.getReviewerStatus()); |
| | | if (passed && training.getApproverId() == null) { |
| | | throw new ErrorException("è¯·éæ©æ¹å人"); |
| | | } |
| | | |
| | | // æ¶æ¯åé |
| | | baseMapper.update(null, Wrappers.<PersonTraining>lambdaUpdate() |
| | | .eq(PersonTraining::getId, training.getId()) |
| | | .set(PersonTraining::getApproverId, passed ? training.getApproverId() : null) |
| | | .set(PersonTraining::getAuditDate, LocalDateTime.now()) |
| | | .set(PersonTraining::getAuditRemarks, training.getAuditRemarks()) |
| | | .set(PersonTraining::getReviewerStatus, training.getReviewerStatus())); |
| | | |
| | | // åªæå®¡æ ¸éè¿æéç¥æ¹å人 |
| | | if (!passed) { |
| | | return; |
| | | } |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | User user = userMapper.selectById(userId); |
| | | InformationNotification info = new InformationNotification(); |
| | | // åé人 |
| | | info.setCreateUser(user.getName()); |
| | | info.setCreateUser(user != null ? user.getName() : ""); |
| | | info.setMessageType("6"); |
| | | info.setTheme("CNASå¹è®è®¡åå®¡æ ¸éç¥"); |
| | | info.setContent("æ¨æä¸æ¡å¹è®è®¡åå¾
æ¹å"); |
| | | info.setSenderId(userId); |
| | | // æ¥æ¶äºº |
| | | info.setConsigneeId(training.getApproverId()); |
| | | info.setJumpPath(MenuJumpPathConstants.PERSONNEL); |
| | | informationNotificationService.addInformationNotification(info); |
| | | |
| | | // åéä¼ä¸å¾®ä¿¡éç¥ |
| | | threadPoolTaskExecutor.execute(() -> { |
| | | // æ¥è¯¢æ¥æ¶äºº |
| | | User personnel = userMapper.selectById(training.getApproverId()); |
| | | |
| | | if (personnel == null || StringUtils.isBlank(personnel.getAccount())) { |
| | | return; |
| | | } |
| | | String message = ""; |
| | | message += "CNASå¹è®è®¡åæ¹åéç¥"; |
| | | message += "\n请å»èµæºç®¡ç-人å-å¹è®è®¡åå¡«å"; |
| | | message += "\n" + old.getFileName() + "çå¹è®è®¡åå¾
æ¹å"; |
| | | //åéä¼ä¸å¾®ä¿¡æ¶æ¯éç¥ |
| | | try { |
| | | WxCpUtils.inform(personnel.getAccount(), message, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | |
| | | baseMapper.updateById(personTraining); |
| | | } |
| | | |
| | | @Override |
| | | public void approveAnnualPersonnelTraining(PersonTraining training) { |
| | | if (training == null || training.getId() == null) { |
| | | throw new ErrorException("缺å°è®¡åid"); |
| | | } |
| | | if (!Integer.valueOf(1).equals(training.getApprovalStatus()) && !Integer.valueOf(2).equals(training.getApprovalStatus())) { |
| | | throw new ErrorException("æ¹åç»æä¸æ£ç¡®"); |
| | | } |
| | | PersonTraining old = baseMapper.selectById(training.getId()); |
| | | if (old == null) { |
| | | throw new ErrorException("å¹è®è®¡åä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | if (!Integer.valueOf(1).equals(old.getReviewerStatus())) { |
| | | throw new ErrorException("该计åå°æªå®¡æ ¸éè¿ï¼ä¸è½æ¹å"); |
| | | } |
| | | if (Integer.valueOf(1).equals(old.getApprovalStatus())) { |
| | | throw new ErrorException("该计åå·²æ¹åï¼è¯·å¿é夿ä½"); |
| | | } |
| | | LambdaUpdateWrapper<PersonTraining> wrapper = Wrappers.<PersonTraining>lambdaUpdate() |
| | | .eq(PersonTraining::getId, training.getId()) |
| | | .set(PersonTraining::getApprovalDate, LocalDateTime.now()) |
| | |
| | | @Override |
| | | public void exportPersonTraining(Integer id, HttpServletResponse response) { |
| | | |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°è®¡åid"); |
| | | } |
| | | // æ¥è¯¢è¯¦æ
|
| | | PersonTraining personTraining = baseMapper.selectById(id); |
| | | |
| | | //è·åæäº¤äººçç¾åå°å |
| | | String writeUrl = userMapper.selectById(personTraining.getCompilerId()).getSignatureUrl(); |
| | | if (ObjectUtils.isEmpty(writeUrl) || writeUrl.equals("")) { |
| | | throw new ErrorException("æ¾ä¸å°æ£éªäººçç¾å"); |
| | | if (personTraining == null) { |
| | | throw new ErrorException("å¹è®è®¡åä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | |
| | | //è·å夿 ¸äººçç¾åå°å |
| | | //è·åç¼å¶äººçç¾åå°å |
| | | User compiler = userMapper.selectById(personTraining.getCompilerId()); |
| | | String writeUrl = compiler != null ? compiler.getSignatureUrl() : null; |
| | | if (StringUtils.isBlank(writeUrl)) { |
| | | throw new ErrorException("ç¼å¶äººæªä¸ä¼ ç¾åï¼ææ æ³å¯¼åº"); |
| | | } |
| | | if (!new File(imgUrl + "/" + writeUrl).exists()) { |
| | | throw new ErrorException("ç¼å¶äººçç¾åå¾çä¸åå¨ï¼è¯·éæ°ä¸ä¼ ç¾å"); |
| | | } |
| | | |
| | | //è·åå®¡æ ¸äººçç¾åå°å |
| | | String examineUrl = null; |
| | | if (personTraining.getReviewerId() != null) { |
| | | examineUrl = userMapper.selectById(personTraining.getReviewerId()).getSignatureUrl(); |
| | | User reviewer = userMapper.selectById(personTraining.getReviewerId()); |
| | | examineUrl = reviewer != null ? reviewer.getSignatureUrl() : null; |
| | | if (StringUtils.isBlank(examineUrl)) { |
| | | throw new ErrorException("æ¾ä¸å°å¤æ ¸äººçç¾å"); |
| | | throw new ErrorException("å®¡æ ¸äººæªä¸ä¼ ç¾åï¼ææ æ³å¯¼åº"); |
| | | } |
| | | if (!new File(imgUrl + "/" + examineUrl).exists()) { |
| | | throw new ErrorException("å®¡æ ¸äººçç¾åå¾çä¸åå¨ï¼è¯·éæ°ä¸ä¼ ç¾å"); |
| | | } |
| | | } |
| | | |
| | | //è·åæ¹å人çç¾åå°å |
| | | String ratifyUrl = null; |
| | | if (personTraining.getApproverId() != null) { |
| | | ratifyUrl = userMapper.selectById(personTraining.getApproverId()).getSignatureUrl(); |
| | | User approver = userMapper.selectById(personTraining.getApproverId()); |
| | | ratifyUrl = approver != null ? approver.getSignatureUrl() : null; |
| | | if (StringUtils.isBlank(ratifyUrl)) { |
| | | throw new ErrorException("æ¾ä¸å°å¤æ ¸äººçç¾å"); |
| | | throw new ErrorException("æ¹å人æªä¸ä¼ ç¾åï¼ææ æ³å¯¼åº"); |
| | | } |
| | | if (!new File(imgUrl + "/" + ratifyUrl).exists()) { |
| | | throw new ErrorException("æ¹å人çç¾åå¾çä¸åå¨ï¼è¯·éæ°ä¸ä¼ ç¾å"); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void exportPersonTrainingRecord(Integer id, HttpServletResponse response) { |
| | | if (id == null) { |
| | | throw new ErrorException("缺å°å¹è®æç»id"); |
| | | } |
| | | // æ¥è¯¢äººåå¹è®æç» |
| | | PersonTrainingDetailedDto detailedDto = personTrainingDetailedMapper.selectTrainingDetail(id); |
| | | if (detailedDto == null) { |
| | | throw new ErrorException("å¹è®è®°å½ä¸åå¨æå·²è¢«å é¤"); |
| | | } |
| | | |
| | | // çæå¹è®èå¸ç¾åï¼æªé
ç½®ç¾åæ¶ç¨éæå¾çå
åºï¼æ¨¡æ¿éçå¾çå ä½ä¸è½ä¸º nullï¼ |
| | | detailedDto.setTrainingLecturerRender(UserUtils.orTransparentPicture( |
| | |
| | | <select id="selectLimsUser" resultType="com.ruoyi.common.core.domain.entity.DepartmentDto"> |
| | | SELECT u.id userId, u.name, SUBSTRING_INDEX(SUBSTRING_INDEX(u.depart_lims_id, ',', -2), ',', 1) AS fatherId |
| | | FROM user u |
| | | where u.is_custom = 0 |
| | | where COALESCE(u.is_custom, 0) = 0 |
| | | and COALESCE(u.del_flag, '0') = '0' |
| | | and u.depart_lims_id is not null |
| | | and u.depart_lims_id != '' |
| | | </select> |
| | | |
| | | <select id="getCNASPersonnelInfo" resultType="com.ruoyi.personnel.dto.PersonBasicInfoDto"> |
| | | SELECT * |
| | | SELECT cpbi.id AS id, |
| | | u.id AS userId, |
| | | u.account AS account, |
| | | u.name AS name, |
| | | u.name_en AS nameEn, |
| | | u.age AS age, |
| | | u.phone AS phone, |
| | | u.email AS email, |
| | | u.signature_url AS signatureUrl, |
| | | u.picture_url AS pictureUrl, |
| | | u.depart_lims_id AS departLimsId, |
| | | cpbi.current_state AS currentState, |
| | | cpbi.professional_title AS professionalTitle, |
| | | cpbi.sex AS sex, |
| | | cpbi.personnel_classification AS personnelClassification, |
| | | cpbi.date_birth AS dateBirth, |
| | | cpbi.identity_card AS identityCard, |
| | | cpbi.nation AS nation, |
| | | cpbi.political_status AS politicalStatus, |
| | | cpbi.official_academic_redentials AS officialAcademicRedentials, |
| | | cpbi.graduation_time1 AS graduationTime1, |
| | | cpbi.graduated_institutions1 AS graduatedInstitutions1, |
| | | cpbi.major1 AS major1, |
| | | cpbi.graduation_time2 AS graduationTime2, |
| | | cpbi.graduated_institutions2 AS graduatedInstitutions2, |
| | | cpbi.major2 AS major2, |
| | | cpbi.telephone AS telephone, |
| | | cpbi.remarks AS remarks, |
| | | cpbi.corporate_name AS corporateName, |
| | | cpbi.post_name AS postName, |
| | | cpbi.group_time AS groupTime, |
| | | cpbi.labor_relations AS laborRelations, |
| | | cpbi.working_time AS workingTime, |
| | | cpbi.contract_life_time AS contractLifeTime, |
| | | cpbi.native_place AS nativePlace, |
| | | cpbi.validity_period AS validityPeriod, |
| | | cpbi.marital_status AS maritalStatus, |
| | | cpbi.id_address AS idAddress, |
| | | cpbi.id_detail_address AS idDetailAddress, |
| | | cpbi.dumpling_time AS dumplingTime, |
| | | cpbi.highest_degree AS highestDegree, |
| | | cpbi.last_update_time AS lastUpdateTime |
| | | FROM user u |
| | | left join cnas_person_basic_info cpbi on cpbi.user_id = u.id |
| | | where u.id = #{userId} |
| | |
| | | from user u |
| | | left join cnas_person_basic_info cpbi on cpbi.user_id = u.id |
| | | <where> |
| | | FIND_IN_SET(#{departmentId},u.depart_lims_id) |
| | | <if test="departmentId != null"> |
| | | FIND_IN_SET(#{departmentId},u.depart_lims_id) |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | and u.name like concat('%',#{name},'%') |
| | | </if> |
| | | and COALESCE(u.is_custom, 0) = 0 |
| | | and COALESCE(u.del_flag, '0') = '0' |
| | | </where> |
| | | </select> |
| | | |
| | |
| | | and u3.name like concat('%', #{userName}, '%') |
| | | </if> |
| | | </where> |
| | | order by cppc.id desc |
| | | </select> |
| | | |
| | | <!-- æ¥è¯¢äººåè½åæ¥å£ --> |
| | |
| | | |
| | | <select id="personnelTrainingPersonnel" resultType="com.ruoyi.personnel.dto.PersonTrainingRecordListDto"> |
| | | select u.name, u.account, dl.name depart_lims_name, cpbi.professional_title, |
| | | cpbi.official_academic_redentials, u.id user_id |
| | | cpbi.official_academic_redentials, u.id user_id, |
| | | DATE_FORMAT(cpbi.group_time, '%Y-%m-%d') AS unitTimeSting |
| | | from user u |
| | | left join cnas_person_basic_info cpbi on cpbi.user_id = u.id |
| | | left join department_lims dl on dl.id = SUBSTRING_INDEX(SUBSTRING_INDEX(u.depart_lims_id, ',', -2), ',', 1) |
| | | where u.is_custom = 0 |
| | | where COALESCE(u.is_custom, 0) = 0 |
| | | and COALESCE(u.del_flag, '0') = '0' |
| | | <if test="userName != '' and userName != null and userName != 'null'"> |
| | | and u.name like concat('%', #{userName}, '%') |
| | | </if> |
| | |
| | | from user u |
| | | left join cnas_person_basic_info cpbi on cpbi.user_id = u.id |
| | | left join department_lims dl on dl.id = SUBSTRING_INDEX(SUBSTRING_INDEX(u.depart_lims_id, ',', -2), ',', 1) |
| | | where u.is_custom = 0 |
| | | where COALESCE(u.is_custom, 0) = 0 |
| | | and u.id = #{userId} |
| | | </select> |
| | | |
| | |
| | | and cptr.user_id = #{userId} |
| | | <where> |
| | | <if test="year!= null and year!= ''"> |
| | | and cptd.training_date like concat('%', #{year}, '%')} |
| | | and cptd.training_date like concat('%', #{year}, '%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | and cptd.training_date like concat('%', #{year}, '%') |
| | | </if> |
| | | </where> |
| | | order by STR_TO_DATE(CONCAT(cptd.training_date, '.01'), '%Y.%m.%d') |
| | | order by cptd.training_date |
| | | |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | /** |
| | | * åå§è®°å½ä¿ååï¼æå½å模æ¿éç¨ç设å¤çæå¾
å¡«åç使ç¨è®°å½ã |
| | | * åä¸è®¢åãæ ·åã设å¤åªçæä¸æ¡ï¼å·²ç»å¡«åè¿çè®°å½ä¸ä¼è¢«è¦çã |
| | | * åä¸è®¢åãæ ·åã设å¤åªçæä¸æ¡ï¼æ¸©æ¹¿åº¦åä½¿ç¨æ¥æååå§è®°å½å¿«ç
§ï¼ |
| | | * æ¶é´é»è®¤ 10:00-19:30ï¼å·²ç»æå·¥å¡«åè¿çè®°å½ä¸ä¼è¢«è¦çã |
| | | */ |
| | | private synchronized void syncDeviceRecordsFromTemplate(Integer orderId, Integer sampleId, |
| | | Integer templateId, Integer userId) { |
| | |
| | | if (CollectionUtils.isEmpty(deviceIds)) { |
| | | return; |
| | | } |
| | | InsOrderStandardTemplate snapshot = insOrderStandardTemplateService.getOne( |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, orderId) |
| | | .eq(InsOrderStandardTemplate::getTemplateId, templateId) |
| | | .last("limit 1")); |
| | | String temperature = snapshot == null || StringUtils.isBlank(snapshot.getTemperature()) |
| | | ? order.getTemperature() : snapshot.getTemperature(); |
| | | String humidity = snapshot == null || StringUtils.isBlank(snapshot.getHumidity()) |
| | | ? order.getHumidity() : snapshot.getHumidity(); |
| | | // åå§è®°å½æ²¡ææ£æµæ¥ææ¶ç空ï¼ä¸é»è®¤å½å¤© |
| | | LocalDateTime useStartDate = null; |
| | | LocalDateTime useEndDate = null; |
| | | if (snapshot != null && snapshot.getDetectionTime() != null) { |
| | | useStartDate = snapshot.getDetectionTime().atTime(10, 0); |
| | | LocalDate endDate = snapshot.getDetectionEndTime() != null |
| | | ? snapshot.getDetectionEndTime() : snapshot.getDetectionTime(); |
| | | useEndDate = endDate.atTime(19, 30); |
| | | } |
| | | User user = userMapper.selectById(userId); |
| | | String usePerson = user == null ? "" : user.getName(); |
| | | String sampleCode = StringUtils.isNotBlank(sample.getSampleCode()) |
| | |
| | | if (deviceId == null) { |
| | | continue; |
| | | } |
| | | Long count = insOrderDeviceRecordMapper.selectCount(Wrappers.<InsOrderDeviceRecord>lambdaQuery() |
| | | .eq(InsOrderDeviceRecord::getInsOrderId, orderId) |
| | | .eq(InsOrderDeviceRecord::getDeviceId, deviceId) |
| | | .eq(InsOrderDeviceRecord::getSampleCode, sampleCode)); |
| | | if (count != null && count > 0) { |
| | | InsOrderDeviceRecord existing = insOrderDeviceRecordMapper.selectOne( |
| | | Wrappers.<InsOrderDeviceRecord>lambdaQuery() |
| | | .eq(InsOrderDeviceRecord::getInsOrderId, orderId) |
| | | .eq(InsOrderDeviceRecord::getDeviceId, deviceId) |
| | | .eq(InsOrderDeviceRecord::getSampleCode, sampleCode) |
| | | .last("limit 1")); |
| | | if (existing != null) { |
| | | // åªè¡¥èªå¨çæä½å°æªå¡«åçè®°å½ |
| | | if (existing.getUseStartDate() != null) { |
| | | continue; |
| | | } |
| | | InsOrderDeviceRecord update = new InsOrderDeviceRecord(); |
| | | update.setId(existing.getId()); |
| | | if (StringUtils.isBlank(existing.getTemperature())) { |
| | | update.setTemperature(temperature); |
| | | } |
| | | if (StringUtils.isBlank(existing.getHumidity())) { |
| | | update.setHumidity(humidity); |
| | | } |
| | | if (useStartDate != null) { |
| | | update.setUseStartDate(useStartDate); |
| | | update.setUseEndDate(useEndDate); |
| | | } |
| | | if (existing.getUsePersonId() == null) { |
| | | update.setUsePersonId(userId); |
| | | } |
| | | if (StringUtils.isBlank(existing.getUsePerson())) { |
| | | update.setUsePerson(usePerson); |
| | | } |
| | | insOrderDeviceRecordMapper.updateById(update); |
| | | continue; |
| | | } |
| | | InsOrderDeviceRecord record = new InsOrderDeviceRecord(); |
| | | record.setInsOrderId(orderId); |
| | | record.setDeviceId(deviceId); |
| | | record.setSampleCode(sampleCode); |
| | | record.setTemperature(order.getTemperature()); |
| | | record.setHumidity(order.getHumidity()); |
| | | record.setTemperature(temperature); |
| | | record.setHumidity(humidity); |
| | | record.setUseStartDate(useStartDate); |
| | | record.setUseEndDate(useEndDate); |
| | | record.setUseBefore(1); |
| | | record.setUseAfter(1); |
| | | record.setUsePersonId(userId); |
| | |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.dto.InsProductBindingDto; |
| | | import com.ruoyi.inspect.dto.WriteInspectionConditionDto; |
| | | import com.ruoyi.inspect.mapper.InsOrderDeviceRecordMapper; |
| | | import com.ruoyi.inspect.mapper.InsOrderMapper; |
| | | import com.ruoyi.inspect.mapper.InsOrderStandardTemplateMapper; |
| | | import com.ruoyi.inspect.mapper.InsOrderTemplateDeviceMapper; |
| | | import com.ruoyi.inspect.mapper.InsProductMapper; |
| | | import com.ruoyi.inspect.mapper.InsSampleMapper; |
| | | import com.ruoyi.inspect.pojo.InsOrder; |
| | | import com.ruoyi.inspect.pojo.InsOrderDeviceRecord; |
| | | import com.ruoyi.inspect.pojo.InsOrderStandardTemplate; |
| | | import com.ruoyi.inspect.pojo.InsOrderTemplateDevice; |
| | | import com.ruoyi.inspect.pojo.InsProduct; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private InsOrderStandardTemplateMapper insOrderStandardTemplateMapper; |
| | | |
| | | private InsOrderTemplateDeviceMapper insOrderTemplateDeviceMapper; |
| | | |
| | | private InsOrderDeviceRecordMapper insOrderDeviceRecordMapper; |
| | | |
| | | @Override |
| | | public int selectOrderManDay(Integer orderId) { |
| | |
| | | if (!hasSnapshotField && !dto.isDeviceIdsPresent()) { |
| | | throw new ErrorException("没æéè¦ä¿åçæ¨¡æ¿æ£éªæ¡ä»¶"); |
| | | } |
| | | refreshPendingDeviceRecords(dto); |
| | | return true; |
| | | } |
| | | InsOrder insOrder = new InsOrder(); |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * åå§è®°å½çç¯å¢æ¡ä»¶åè¡¥æ¶ï¼åæ¥å°å°æªå¡«åç使ç¨è®°å½ã |
| | | * å·²æå·¥æ¹å¨è¿çè®°å½ï¼å·²æå¼å§æ¥æï¼ä¸è¦çã |
| | | */ |
| | | private void refreshPendingDeviceRecords(WriteInspectionConditionDto dto) { |
| | | boolean hasTemperature = dto.isTemperaturePresent() |
| | | && dto.getTemperature() != null && !dto.getTemperature().trim().isEmpty(); |
| | | boolean hasDetectionRange = dto.isDetectionTimePresent() && dto.getDetectionTime() != null; |
| | | if (!hasTemperature && !hasDetectionRange) { |
| | | return; |
| | | } |
| | | List<Integer> deviceIds = insOrderTemplateDeviceMapper |
| | | .selectDeviceIdsByOrderAndTemplate(dto.getId(), dto.getTemplateId()); |
| | | if (deviceIds == null || deviceIds.isEmpty()) { |
| | | return; |
| | | } |
| | | LocalDateTime start = null; |
| | | LocalDateTime end = null; |
| | | if (hasDetectionRange) { |
| | | start = dto.getDetectionTime().atTime(10, 0); |
| | | LocalDate endDate = dto.getDetectionEndTime() != null ? dto.getDetectionEndTime() : dto.getDetectionTime(); |
| | | end = endDate.atTime(19, 30); |
| | | } |
| | | insOrderDeviceRecordMapper.update(null, Wrappers.<InsOrderDeviceRecord>lambdaUpdate() |
| | | .eq(InsOrderDeviceRecord::getInsOrderId, dto.getId()) |
| | | .in(InsOrderDeviceRecord::getDeviceId, deviceIds) |
| | | .isNull(InsOrderDeviceRecord::getUseStartDate) |
| | | .set(hasTemperature, InsOrderDeviceRecord::getTemperature, dto.getTemperature()) |
| | | .set(hasDetectionRange, InsOrderDeviceRecord::getUseStartDate, start) |
| | | .set(hasDetectionRange, InsOrderDeviceRecord::getUseEndDate, end)); |
| | | } |
| | | |
| | | //æ¥è¯¢å¾
æ£é¡¹ç® |
| | | @Override |
| | | public IPage<InsProduct> selectNoProducts(Page page, InsProduct insProduct, Integer orderId, String ids) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ============================================================ |
| | | -- 设å¤ä¿å
»è®¡åæç»å»éï¼æ°æ®ä¿®å¤ï¼éç»æåæ´ï¼ |
| | | -- çææ¥æï¼2026-11-06 |
| | | -- |
| | | -- èæ¯ï¼åå²çæ¬è¡¥è®¾å¤/æ¹æ¥ææ¶ï¼å¯è½ç»åä¸è®¡åãåä¸è®¾å¤ã |
| | | -- åä¸ä¿å
»æä»½çä¸å¤æ¡æç»ï¼å¯¼è´å¯¼åºææ¡£éå¤ã |
| | | -- |
| | | -- å»éå£å¾ï¼åä¸ maintenance_plan_id + device_id + ä¿å
»æä»½ |
| | | -- åªä¿ç䏿¡ã |
| | | -- ä¼å
ä¿çå·²æä¿å
»è®°å½çæç»ï¼é½æ²¡æè®°å½æ¶ä¿çææ°ä¸æ¡ã |
| | | -- 为ä¿è¯æ°æ®å®å
¨ï¼åªå é¤â没æä»»ä½ä¿å
»è®°å½âçéå¤è¡ï¼ |
| | | -- è¥åä¸ç»éæå¤æ¡é½å·²æä¿å
»è®°å½ï¼ä¸èªå¨å é¤ï¼é人工确认ã |
| | | -- |
| | | -- æ§è¡åå¿
é¡»å
å¤ä»½ï¼èæ¬ä¼èªå¨å建å¤ä»½è¡¨ï¼å·²åå¨åä¸è¦çï¼ã |
| | | -- èæ¬å¯é夿§è¡ï¼å¹çï¼ã |
| | | -- ============================================================ |
| | | |
| | | -- 1. å¤ä»½æç»è¡¨ï¼é¦æ¬¡æ§è¡å建ï¼é夿§è¡ä¸è¦çï¼ |
| | | CREATE TABLE IF NOT EXISTS `device_maintenance_plan_details_bak_20261106` AS |
| | | SELECT * FROM `device_maintenance_plan_details`; |
| | | |
| | | -- 2. æ¥çå»éåçé夿
åµ |
| | | SELECT maintenance_plan_id, device_id, DATE_FORMAT(maintenance_date, '%Y-%m') AS maintenance_month, |
| | | COUNT(*) AS duplicate_count, |
| | | GROUP_CONCAT(maintenance_plan_detail_id ORDER BY maintenance_plan_detail_id) AS detail_ids |
| | | FROM device_maintenance_plan_details |
| | | GROUP BY maintenance_plan_id, device_id, DATE_FORMAT(maintenance_date, '%Y-%m') |
| | | HAVING COUNT(*) > 1; |
| | | |
| | | -- 3. å é¤éå¤è¡ï¼æâæä¿å
»è®°å½ä¼å
ãææ°ä¼å
âæåºï¼ä»
å 餿 ä¿å
»è®°å½çéå¤è¡ |
| | | START TRANSACTION; |
| | | |
| | | DELETE d |
| | | FROM device_maintenance_plan_details d |
| | | JOIN ( |
| | | SELECT maintenance_plan_detail_id |
| | | FROM ( |
| | | SELECT dmpd.maintenance_plan_detail_id, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY dmpd.maintenance_plan_id, dmpd.device_id, DATE_FORMAT(dmpd.maintenance_date, '%Y-%m') |
| | | ORDER BY (SELECT COUNT(*) FROM device_maintenance dm |
| | | WHERE dm.maintenance_plan_detail_id = dmpd.maintenance_plan_detail_id) DESC, |
| | | dmpd.maintenance_plan_detail_id DESC |
| | | ) AS rn |
| | | FROM device_maintenance_plan_details dmpd |
| | | ) ranked |
| | | WHERE ranked.rn > 1 |
| | | ) dup ON d.maintenance_plan_detail_id = dup.maintenance_plan_detail_id |
| | | WHERE NOT EXISTS ( |
| | | SELECT 1 FROM device_maintenance dm |
| | | WHERE dm.maintenance_plan_detail_id = d.maintenance_plan_detail_id |
| | | ); |
| | | |
| | | COMMIT; |
| | | |
| | | -- 4. æ ¡éªï¼æ§è¡å®å¯äººå·¥æ ¸å¯¹ï¼ |
| | | -- 4.1 åºä¸º 0 è¡ï¼åä¸è®¡å + åä¸è®¾å¤ + åä¸ä¿å
»æä»½ä»æéå¤ |
| | | -- SELECT maintenance_plan_id, device_id, DATE_FORMAT(maintenance_date, '%Y-%m') AS maintenance_month, COUNT(*) AS c |
| | | -- FROM device_maintenance_plan_details |
| | | -- GROUP BY maintenance_plan_id, device_id, DATE_FORMAT(maintenance_date, '%Y-%m') |
| | | -- HAVING c > 1; |
| | | -- |
| | | -- 4.2 åºä¸º 0 è¡ï¼ä¿å
»è®°å½å
³èç计åæç»å·²ä¸åå¨ï¼é²æ¢è¯¯å 导è´è®°å½å¤å¿ï¼ |
| | | -- SELECT dm.id, dm.maintenance_plan_detail_id |
| | | -- FROM device_maintenance dm |
| | | -- LEFT JOIN device_maintenance_plan_details dmpd |
| | | -- ON dmpd.maintenance_plan_detail_id = dm.maintenance_plan_detail_id |
| | | -- WHERE dmpd.maintenance_plan_detail_id IS NULL; |
| | | -- |
| | | -- 4.3 æ¸
çååæ°é对æ¯ï¼ |
| | | -- SELECT COUNT(*) FROM device_maintenance_plan_details; |
| | | -- SELECT COUNT(*) FROM device_maintenance_plan_details_bak_20261106; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ============================================================ |
| | | -- 设å¤ä½¿ç¨è®°å½å岿°æ®åå¡«ï¼æ°æ®ä¿®å¤ï¼éç»æåæ´ï¼ |
| | | -- çææ¥æï¼2026-11-06 |
| | | -- |
| | | -- èæ¯ï¼æ§çæ¬èªå¨çæä½¿ç¨è®°å½æ¶åªå设å¤ãæ ·åå使ç¨äººï¼ |
| | | -- 没æåä½¿ç¨æ¥æãèµ·æ¢æ¶é´å温湿度ï¼å¯¼è´ä½¿ç¨è®°å½é¡µé¢è¿äºå为空ã |
| | | -- æ°çæ¬å¨ä¿ååå§è®°å½æ¶ä¼èªå¨å¸¦åºï¼ä½ä¸ä¼å头修æ¹å岿°æ®ã |
| | | -- |
| | | -- åå¡«å£å¾ï¼æå®¢æ·ç¡®è®¤çè§åï¼ï¼ |
| | | -- 1. åªå¤ç use_start_date 为空çåå²è®°å½ï¼å·²æå·¥å¡«åçä¸å¨ï¼ |
| | | -- 2. éè¿ ins_order_template_device æ¾å°è¯¥è®¢åã该设å¤å¯¹åºç |
| | | -- åå§è®°å½å¿«ç
§ ins_order_standard_templateï¼ |
| | | -- 3. åä¸è®¾å¤å¨åä¸è®¢å对åºå¤ä¸ªæ¨¡æ¿æ¶ï¼åæ£æµæ¥æææ©ç䏿¡ï¼ |
| | | -- 4. 使ç¨å¼å§æ¥æ = æ£æµå¼å§æ¥æ 10:00:00ï¼ |
| | | -- 使ç¨ç»ææ¥æ = æ£æµç»ææ¥æ 19:30:00ï¼ |
| | | -- æ²¡ææ£æµç»ææ¥ææ¶æå¼å§æ¥æå½å¤© 19:30:00ï¼ |
| | | -- 5. 温度ååå§è®°å½å¿«ç
§æ¸©åº¦ï¼å·²æçä¸è¦çï¼ |
| | | -- 6. åå§è®°å½æ²¡ææ¹¿åº¦åæ®µï¼æ¹¿åº¦ä¸åå¡«ï¼ |
| | | -- 7. æ¾ä¸å°åå§è®°å½è®¾å¤å
³èçæå·¥è®°å½ä¿æä¸ºç©ºï¼ç±å®éªäººå补填ã |
| | | -- |
| | | -- æ°æ®æ¥æºå为åºä¸å·²åå¨çåå§è®°å½å¿«ç
§ï¼ä»
10:00 / 19:30 |
| | | -- 为æå®¢æ·è§åå¡«å
¥çé»è®¤æ¶é´ã |
| | | -- |
| | | -- èæ¬å¯é夿§è¡ï¼å¹çï¼ã |
| | | -- ============================================================ |
| | | |
| | | -- 1. å¤ä»½ä½¿ç¨è®°å½è¡¨ï¼é¦æ¬¡æ§è¡å建ï¼é夿§è¡ä¸è¦çï¼ |
| | | CREATE TABLE IF NOT EXISTS `device_record_bak_20261106` AS |
| | | SELECT * FROM `device_record`; |
| | | |
| | | -- 2. åå¡«åç»è®¡ |
| | | -- 2.1 ç©ºè®°å½æ»æ° |
| | | SELECT COUNT(*) AS blank_total |
| | | FROM device_record |
| | | WHERE use_start_date IS NULL; |
| | | |
| | | -- 2.2 è½å¹é
å°åå§è®°å½æ¡ä»¶çç©ºè®°å½æ° |
| | | SELECT COUNT(*) AS matchable_total |
| | | FROM device_record dr |
| | | WHERE dr.use_start_date IS NULL |
| | | AND EXISTS ( |
| | | SELECT 1 |
| | | FROM ins_order_template_device t |
| | | JOIN ins_order_standard_template s |
| | | ON s.ins_order_id = t.ins_order_id AND s.template_id = t.template_id |
| | | WHERE t.ins_order_id = dr.ins_order_id |
| | | AND t.device_id = dr.device_id |
| | | AND s.detection_time IS NOT NULL |
| | | ); |
| | | |
| | | -- 2.3 å¹é
ä¸å°ãå°ä¿æä¸ºç©ºçè®°å½ï¼äººå·¥è¡¥å¡«ï¼ |
| | | SELECT dr.id, dr.ins_order_id, dr.device_id, dr.sample_code |
| | | FROM device_record dr |
| | | WHERE dr.use_start_date IS NULL |
| | | AND NOT EXISTS ( |
| | | SELECT 1 |
| | | FROM ins_order_template_device t |
| | | JOIN ins_order_standard_template s |
| | | ON s.ins_order_id = t.ins_order_id AND s.template_id = t.template_id |
| | | WHERE t.ins_order_id = dr.ins_order_id |
| | | AND t.device_id = dr.device_id |
| | | AND s.detection_time IS NOT NULL |
| | | ); |
| | | |
| | | -- 3. åå¡« |
| | | START TRANSACTION; |
| | | |
| | | UPDATE device_record dr |
| | | JOIN ( |
| | | SELECT t.ins_order_id, t.device_id, |
| | | s.temperature, s.detection_time, s.detection_end_time |
| | | FROM ins_order_template_device t |
| | | JOIN ins_order_standard_template s |
| | | ON s.ins_order_id = t.ins_order_id AND s.template_id = t.template_id |
| | | WHERE s.detection_time IS NOT NULL |
| | | AND s.id = ( |
| | | SELECT s2.id |
| | | FROM ins_order_template_device t2 |
| | | JOIN ins_order_standard_template s2 |
| | | ON s2.ins_order_id = t2.ins_order_id AND s2.template_id = t2.template_id |
| | | WHERE t2.ins_order_id = t.ins_order_id |
| | | AND t2.device_id = t.device_id |
| | | AND s2.detection_time IS NOT NULL |
| | | ORDER BY s2.detection_time ASC, s2.id ASC |
| | | LIMIT 1 |
| | | ) |
| | | ) picked ON picked.ins_order_id = dr.ins_order_id AND picked.device_id = dr.device_id |
| | | SET dr.use_start_date = TIMESTAMP(picked.detection_time, '10:00:00'), |
| | | dr.use_end_date = TIMESTAMP(COALESCE(picked.detection_end_time, picked.detection_time), '19:30:00'), |
| | | dr.temperature = COALESCE(NULLIF(dr.temperature, ''), picked.temperature) |
| | | WHERE dr.use_start_date IS NULL; |
| | | |
| | | COMMIT; |
| | | |
| | | -- 4. æ ¡éªï¼æ§è¡å®å¯äººå·¥æ ¸å¯¹ï¼ |
| | | -- 4.1 åå¡«åå对æ¯ï¼å¤ä»½è¡¨ç©ºæ ¼æ° - ç°è¡¨ç©ºæ ¼æ° = æ¬æ¬¡åå¡«æ¡æ° |
| | | -- SELECT |
| | | -- (SELECT COUNT(*) FROM device_record_bak_20261106 WHERE use_start_date IS NULL) AS blank_before, |
| | | -- (SELECT COUNT(*) FROM device_record WHERE use_start_date IS NULL) AS blank_after; |
| | | -- |
| | | -- 4.2 æ½æ¥æè®¢åçåå¡«ç»æ |
| | | -- SELECT id, device_id, ins_order_id, sample_code, temperature, use_start_date, use_end_date, use_person |
| | | -- FROM device_record |
| | | -- WHERE ins_order_id = ?; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ============================================================ |
| | | -- æ£éªå§æåæ§æ°æ®æç»åå¡«ï¼æ°æ®ä¿®å¤ï¼éç»æåæ´ï¼ |
| | | -- çææ¥æï¼2026-11-06 |
| | | -- |
| | | -- èæ¯ï¼æ§çèªå¨çææ£éªå§æåæ¶åªåäºè¡¨å¤´ï¼æ²¡æåå
¥ |
| | | -- cnas_inspection_order_detail æç»è¡ï¼å¯¼è´æ¥ç/ç¼è¾å¼¹çªé |
| | | -- æ ·ååç§°ãæ ·åç¼å·ãæ£æµé¡¹ç®ãæ°éãç¶æãæ£æµä¾æ®ã夿³¨ã |
| | | -- å§æç¼å·å
¨é¨ä¸ºç©ºãæ°ççå¬å¨å·²ä¼åæç»ï¼ä»
éåå¡«å岿°æ®ã |
| | | -- |
| | | -- åå¡«æ¥æºï¼ |
| | | -- æ ·ååç§° cnas_inspection_order.sample_nameï¼ç©ºæ¶å ins_orderï¼ |
| | | -- æ ·åç¼å· ins_sample ç¬¬ä¸æ¡æ ·åç¼å· |
| | | -- æ£æµé¡¹ç® ins_order_standard_template.name å»éåâãâæ¼æ¥ |
| | | -- æ°é/ç¶æ cnas_inspection_order 表头ï¼ç©ºæ¶å ins_orderï¼ |
| | | -- æ£æµä¾æ® standard_tree -> standard_method çâç¼å· åç§°âï¼ |
| | | -- åä¸å°æ¶åéå°æ¨¡æ¿å¿«ç
§ç¼å· |
| | | -- 夿³¨ ins_order.remark |
| | | -- |
| | | -- ä»
å¤çâå·²æä¸åè®°å½ä½æ²¡æä»»ä½æç»è¡âçå§æåï¼ |
| | | -- å·²ææç»çè®°å½ä¸æ¹ãä¸é夿å
¥ãå¯é夿§è¡ï¼å¹çï¼ã |
| | | -- |
| | | -- æ§è¡å建议å¤ä»½ï¼å¨ LIMS æ°æ®åºå
æ§è¡ï¼ï¼ |
| | | -- CREATE TABLE cnas_inspection_order_detail_bak_20261106 AS |
| | | -- SELECT * FROM cnas_inspection_order_detail; |
| | | -- ============================================================ |
| | | |
| | | START TRANSACTION; |
| | | |
| | | INSERT INTO cnas_inspection_order_detail |
| | | (inspection_order_id, sample_number, sample_name, test_item, |
| | | quantity, sample_status, test_standard, remark) |
| | | SELECT |
| | | io.inspection_order_id, |
| | | (SELECT s.sample_code |
| | | FROM ins_sample s |
| | | WHERE s.ins_order_id = o.id |
| | | ORDER BY s.id |
| | | LIMIT 1), |
| | | COALESCE(NULLIF(io.sample_name, ''), NULLIF(o.sample_view, ''), o.sample), |
| | | (SELECT GROUP_CONCAT(DISTINCT t.name ORDER BY t.sort, t.id SEPARATOR 'ã') |
| | | FROM ins_order_standard_template t |
| | | WHERE t.ins_order_id = o.id), |
| | | COALESCE(NULLIF(io.quantity, ''), o.test_quantity), |
| | | COALESCE(NULLIF(io.sample_status, ''), o.sample_status), |
| | | COALESCE( |
| | | NULLIF(TRIM(CONCAT(COALESCE(sm.code, ''), ' ', COALESCE(sm.name, ''))), ''), |
| | | (SELECT GROUP_CONCAT(DISTINCT t.number ORDER BY t.sort, t.id SEPARATOR 'ã') |
| | | FROM ins_order_standard_template t |
| | | WHERE t.ins_order_id = o.id) |
| | | ), |
| | | o.remark |
| | | FROM cnas_inspection_order io |
| | | JOIN ins_order o ON o.id = io.ins_order_id |
| | | LEFT JOIN standard_tree st ON st.id = o.standard_tree_id |
| | | LEFT JOIN standard_method sm ON sm.id = st.standard_method_id |
| | | WHERE NOT EXISTS ( |
| | | SELECT 1 FROM cnas_inspection_order_detail d |
| | | WHERE d.inspection_order_id = io.inspection_order_id |
| | | ); |
| | | |
| | | COMMIT; |
| | | |
| | | -- æ ¡éªï¼æ§è¡å®å¯äººå·¥æ ¸å¯¹ï¼åºè¿å 0 è¡ï¼ï¼ |
| | | -- SELECT io.inspection_order_id, io.entrust_code |
| | | -- FROM cnas_inspection_order io |
| | | -- JOIN ins_order o ON o.id = io.ins_order_id |
| | | -- WHERE NOT EXISTS ( |
| | | -- SELECT 1 FROM cnas_inspection_order_detail d |
| | | -- WHERE d.inspection_order_id = io.inspection_order_id |
| | | -- ); |
| | | -- |
| | | -- æ½æ¥åå¡«ç»æï¼ |
| | | -- SELECT d.inspection_order_detail_id, d.inspection_order_id, d.sample_name, |
| | | -- d.sample_number, d.test_item, d.quantity, d.sample_status, |
| | | -- d.test_standard, d.remark |
| | | -- FROM cnas_inspection_order_detail d |
| | | -- JOIN cnas_inspection_order io ON io.inspection_order_id = d.inspection_order_id |
| | | -- ORDER BY d.inspection_order_id; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- ============================================================ |
| | | -- æ£éªå§æåå¤å¿æ°æ®æ¸
çï¼æ°æ®ä¿®å¤ï¼éç»æåæ´ï¼ |
| | | -- çææ¥æï¼2026-11-06 |
| | | -- |
| | | -- èæ¯ï¼å®¢æ·åºå
±æ 24 æ¡æ£éªå§æåï¼ä½å§æä¸ååªæ 22 æ¡ã |
| | | -- å¤åºç 2 æ¡å§æåï¼LMSY-20260922-01ãLMSY-20260929-è¯æ ·ï¼ |
| | | -- 对åºçä¸åè®°å½ï¼ins_order 10908ã10938ï¼å·²è¢«å é¤ï¼å±äº |
| | | -- åå²éççå¤å¿æ°æ®ãå½åå é¤ä¸åçé»è¾å·²ä¼çº§èæ¸
çå§æåï¼ |
| | | -- è¿ä¸¤æ¡æ¯æ§çæ¬å 餿¶çä¸çã |
| | | -- |
| | | -- å·²æ ¸å®ï¼è¿ä¸¤æ¡å§æå没ææç»ãæ ·åæ¥æ¶ãæ¥åã设å¤ä½¿ç¨ç |
| | | -- ä»»ä½å
³èè®°å½ï¼å é¤ä¸å½±åå
¶ä»æ°æ®ã |
| | | -- |
| | | -- ä»
æå§æç¼å·ç²¾ç¡®å¹é
ï¼ä¸åæ¬¡æ ¡éªâä¸åä¸åå¨ + æ ä»»ä½å
³èè®°å½â |
| | | -- åæå é¤ï¼å¯é夿§è¡ï¼å¹çï¼ã |
| | | -- |
| | | -- æ§è¡å建议å¤ä»½ï¼å¨ LIMS æ°æ®åºå
æ§è¡ï¼ï¼ |
| | | -- CREATE TABLE cnas_inspection_order_bak_20261106 AS |
| | | -- SELECT * FROM cnas_inspection_order; |
| | | -- ============================================================ |
| | | |
| | | START TRANSACTION; |
| | | |
| | | DELETE io |
| | | FROM cnas_inspection_order io |
| | | LEFT JOIN ins_order o ON o.id = io.ins_order_id |
| | | WHERE o.id IS NULL |
| | | AND io.entrust_code IN ('LMSY-20260922-01', 'LMSY-20260929-è¯æ ·') |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM cnas_inspection_order_detail d |
| | | WHERE d.inspection_order_id = io.inspection_order_id) |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM cnas_process_sample ps |
| | | WHERE ps.inspection_order_id = io.inspection_order_id) |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM cnas_process_report pr |
| | | WHERE pr.inspection_order_id = io.inspection_order_id) |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM cnas_process_order_device pod |
| | | WHERE pod.inspection_order_id = io.inspection_order_id); |
| | | |
| | | COMMIT; |
| | | |
| | | -- æ ¡éªï¼æ§è¡å®å¯äººå·¥æ ¸å¯¹ï¼ï¼ |
| | | -- å§æåæ»æ°åºä¸å§æä¸åæ°ä¸è´ï¼å®¢æ·åºåºä¸º 22ï¼ï¼ |
| | | -- SELECT COUNT(*) AS inspection_order_total FROM cnas_inspection_order; |
| | | -- SELECT COUNT(*) AS ins_order_total FROM ins_order; |
| | | -- |
| | | -- åºè¿å 0 è¡ï¼ |
| | | -- SELECT io.inspection_order_id, io.entrust_code, io.ins_order_id |
| | | -- FROM cnas_inspection_order io |
| | | -- LEFT JOIN ins_order o ON o.id = io.ins_order_id |
| | | -- WHERE o.id IS NULL; |
| | |
| | | -- æ¹éä¸åæ¹æ¬¡å·ï¼å䏿¬¡æ¹éä¸åçæ ·åå
±äº«ä¸ä¸ªæ¹æ¬¡å· |
| | | ALTER TABLE ins_order ADD COLUMN batch_no VARCHAR(64) NULL COMMENT 'æ¹éä¸åæ¹æ¬¡å·' AFTER entrust_code; |
| | | ALTER TABLE cnas_inspection_order ADD COLUMN batch_no VARCHAR(64) NULL COMMENT 'æ¹éä¸åæ¹æ¬¡å·' AFTER entrust_code; |
| | | |
| | | -- 设å¤ä¿å
»è®¡åæç»é件表ï¼éä»¶æè®¡åæç»ï¼è®¾å¤è¡ï¼æè½½ |
| | | CREATE TABLE IF NOT EXISTS `device_maintenance_attachment` ( |
| | | `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'éä»¶id', |
| | | `maintenance_plan_detail_id` int NOT NULL COMMENT '设å¤ä¿å
»è®¡åæç»id', |
| | | `file_name` varchar(255) NOT NULL COMMENT 'æä»¶å', |
| | | `file_url` varchar(500) NOT NULL COMMENT 'æä»¶å°å', |
| | | `sort` int DEFAULT '0' COMMENT 'æåº', |
| | | `create_user` int DEFAULT NULL COMMENT 'å建人', |
| | | `create_time` datetime DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_user` int DEFAULT NULL COMMENT 'ä¿®æ¹äºº', |
| | | `update_time` datetime DEFAULT NULL COMMENT 'ä¿®æ¹æ¶é´', |
| | | PRIMARY KEY (`id`), |
| | | KEY `idx_dmpa_detail_id` (`maintenance_plan_detail_id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设å¤ä¿å
»è®¡åæç»é件表'; |
| | | |
| | | -- æä»¶åæ§ç³è¯·ï¼å¢å å叿¥æã宿½æ¥æï¼æäº¤æ¥æåä¿çï¼ä½çé¢ä¸åæ¾ç¤ºï¼ |
| | | ALTER TABLE cnas_manage_document_controlled ADD COLUMN publish_date DATE NULL COMMENT 'å叿¥æ' AFTER submit_date; |
| | | ALTER TABLE cnas_manage_document_controlled ADD COLUMN implement_date DATE NULL COMMENT '宿½æ¥æ' AFTER publish_date; |