| | |
| | | import com.ruoyi.device.pojo.DeviceExaminePlanDetails; |
| | | import com.ruoyi.device.pojo.DeviceExamineRecord; |
| | | import com.ruoyi.device.pojo.DeviceExamineRecordDetail; |
| | | import com.ruoyi.device.service.DeviceExaminePlanService; |
| | | import com.ruoyi.device.service.DeviceExamineRecordDetailService; |
| | | import com.ruoyi.device.service.DeviceExamineRecordService; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private DeviceExamineRecordDetailService deviceExamineRecordDetailService; |
| | | @Resource |
| | | private DeviceExaminePlanService deviceExaminePlanService; |
| | | @Resource |
| | | private DeviceExaminePlanDetailsMapper deviceExaminePlanDetailsMapper; |
| | | @Resource |
| | |
| | | if (dto.getPlanDetailsId() == null) { |
| | | throw new ErrorException("缺少计划详细信息id"); |
| | | } |
| | | DeviceExaminePlanDetails planDetails = deviceExaminePlanDetailsMapper.selectById(dto.getPlanDetailsId()); |
| | | if (planDetails == null) { |
| | | throw new ErrorException("核查计划明细不存在"); |
| | | } |
| | | if (planDetails.getCheckChargerUserId() == null && StringUtils.isBlank(planDetails.getCheckChargerUser())) { |
| | | throw new ErrorException("请先在编辑中填写核查负责人"); |
| | | } |
| | | |
| | | Integer reviewStatus = dto.getReviewStatus(); |
| | | Integer reviewerId = SecurityUtils.getUserId().intValue(); |
| | | User reviewer = userMapper.selectById(reviewerId); |
| | | |
| | | LambdaUpdateWrapper<DeviceExamineRecord> wrapper = Wrappers.<DeviceExamineRecord>lambdaUpdate() |
| | | .eq(DeviceExamineRecord::getPlanDetailsId, dto.getPlanDetailsId()) |
| | | .set(DeviceExamineRecord::getReviewStatus, dto.getReviewStatus()) |
| | | .set(DeviceExamineRecord::getReviewStatus, reviewStatus) |
| | | .set(DeviceExamineRecord::getReviewRemark, dto.getReviewRemark()); |
| | | |
| | | // 为0清除审核人 |
| | | if (dto.getReviewStatus().equals(0)) { |
| | | if (reviewStatus != null && reviewStatus == 0) { |
| | | wrapper.set(DeviceExamineRecord::getReviewUserId, null) |
| | | .set(DeviceExamineRecord::getReviewUser, null); |
| | | } else { |
| | | wrapper.set(DeviceExamineRecord::getReviewUserId, reviewerId) |
| | | .set(DeviceExamineRecord::getReviewUser, reviewer == null ? null : reviewer.getName()); |
| | | } |
| | | |
| | | this.update(wrapper); |
| | | boolean updated = this.update(wrapper); |
| | | // 计划行尚未录入核查记录时,补一条审核结果记录,保证列表能显示通过/不通过状态 |
| | | if (!updated) { |
| | | DeviceExamineRecord record = new DeviceExamineRecord(); |
| | | record.setPlanDetailsId(dto.getPlanDetailsId()); |
| | | record.setReviewStatus(reviewStatus); |
| | | record.setReviewRemark(dto.getReviewRemark()); |
| | | record.setCheckerUserId(planDetails.getCheckChargerUserId()); |
| | | record.setCheckerUser(planDetails.getCheckChargerUser()); |
| | | if (reviewStatus != null && reviewStatus == 1) { |
| | | record.setReviewUserId(reviewerId); |
| | | record.setReviewUser(reviewer == null ? null : reviewer.getName()); |
| | | } |
| | | this.save(record); |
| | | } |
| | | |
| | | // 复核通过后,设备档案的最近/下次核查日期进入下一轮 |
| | | if (reviewStatus != null && reviewStatus == 1) { |
| | | // 提前审核时把本轮计划归到实际审核月份,便于系统登记下一轮;手动录入到日的日期保持原样 |
| | | String currentCheckTime = planDetails.getCheckTime(); |
| | | boolean hasCheckDate = currentCheckTime != null && currentCheckTime.trim().length() >= 10; |
| | | if (!hasCheckDate) { |
| | | DeviceExaminePlanDetails updateDetail = new DeviceExaminePlanDetails(); |
| | | updateDetail.setPlanDetailsId(dto.getPlanDetailsId()); |
| | | updateDetail.setCheckTime(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"))); |
| | | deviceExaminePlanService.updateExaminePlanDetail(updateDetail); |
| | | } |
| | | deviceExaminePlanService.updateDeviceExamineDate(dto.getPlanDetailsId()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | public void exportReviewExamineRecordDetail(Integer planDetailsId, HttpServletResponse response) { |
| | | // 查询复核核查记录 |
| | | DeviceExamineRecordDto deviceExamineRecordDto = baseMapper.selectReviewExamineRecordDto(planDetailsId); |
| | | if (deviceExamineRecordDto == null) { |
| | | throw new ErrorException("该计划明细暂无核查记录,请先录入后再导出"); |
| | | } |
| | | |
| | | // 查询复核核查记录详情 |
| | | List<DeviceExamineRecordDetail> deviceExamineRecordDetailList = deviceExamineRecordDetailService.list(Wrappers.<DeviceExamineRecordDetail>lambdaQuery().eq(DeviceExamineRecordDetail::getRecordId, deviceExamineRecordDto.getRecordId())); |
| | |
| | | put("deviceExamineRecordDto", deviceExamineRecordDto); |
| | | put("deviceExamineRecordDetailList", deviceExamineRecordDetailList); |
| | | //获取核查人的签名地址 |
| | | put("checkerUserUrl", UserUtils.getFinalUserSignatureUrl(deviceExamineRecordDto.getCheckerUserId())); |
| | | put("checkerUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceExamineRecordDto.getCheckerUserId())); |
| | | //获取审查人的签名地址 |
| | | put("reviewUserUrl", UserUtils.getFinalUserSignatureUrl(deviceExamineRecordDto.getReviewUserId())); |
| | | put("reviewUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceExamineRecordDto.getReviewUserId())); |
| | | }}); |
| | | |
| | | try { |