| | |
| | | import com.ruoyi.device.mapper.DeviceExamineAttachmentMapper; |
| | | import com.ruoyi.device.mapper.DeviceExaminePlanDetailsMapper; |
| | | import com.ruoyi.device.mapper.DeviceExaminePlanMapper; |
| | | import com.ruoyi.device.mapper.DeviceExamineRecordContrastDetailsMapper; |
| | | import com.ruoyi.device.mapper.DeviceExamineRecordContrastMapper; |
| | | import com.ruoyi.device.mapper.DeviceExamineRecordDetailMapper; |
| | | import com.ruoyi.device.mapper.DeviceExamineRecordMapper; |
| | | import com.ruoyi.device.mapper.DeviceMapper; |
| | | import com.ruoyi.device.pojo.Device; |
| | |
| | | import com.ruoyi.device.pojo.DeviceExaminePlanDetails; |
| | | import com.ruoyi.device.pojo.DeviceExamineRecord; |
| | | import com.ruoyi.device.pojo.DeviceExamineRecordContrast; |
| | | import com.ruoyi.device.pojo.DeviceExamineRecordContrastDetails; |
| | | import com.ruoyi.device.pojo.DeviceExamineRecordDetail; |
| | | import com.ruoyi.device.service.DeviceExaminePlanDetailsService; |
| | | import com.ruoyi.device.service.DeviceExaminePlanService; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private DeviceExamineRecordMapper deviceExamineRecordMapper; |
| | | @Resource |
| | | private DeviceExamineRecordContrastMapper deviceExamineRecordContrastMapper; |
| | | @Resource |
| | | private DeviceExamineRecordDetailMapper deviceExamineRecordDetailMapper; |
| | | @Resource |
| | | private DeviceExamineRecordContrastDetailsMapper deviceExamineRecordContrastDetailsMapper; |
| | | @Resource |
| | | private DeviceExamineAttachmentMapper deviceExamineAttachmentMapper; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除计划明细;已有核查/比对记录的不允许删除,保证历史留档 |
| | | * 删除计划明细;已审核完成的核查/比对记录随历史留档不允许删除,未审核的记录随明细一起删除 |
| | | */ |
| | | @Override |
| | | public boolean removeExaminePlanDetail(Integer planDetailsId) { |
| | |
| | | if (detail == null) { |
| | | return false; |
| | | } |
| | | Long recordCount = deviceExamineRecordMapper.selectCount(Wrappers.<DeviceExamineRecord>lambdaQuery() |
| | | List<DeviceExamineRecord> records = deviceExamineRecordMapper.selectList(Wrappers.<DeviceExamineRecord>lambdaQuery() |
| | | .eq(DeviceExamineRecord::getPlanDetailsId, planDetailsId)); |
| | | Long contrastCount = deviceExamineRecordContrastMapper.selectCount(Wrappers.<DeviceExamineRecordContrast>lambdaQuery() |
| | | List<DeviceExamineRecordContrast> contrasts = deviceExamineRecordContrastMapper.selectList(Wrappers.<DeviceExamineRecordContrast>lambdaQuery() |
| | | .eq(DeviceExamineRecordContrast::getPlanDetailsId, planDetailsId)); |
| | | if ((recordCount != null && recordCount > 0) || (contrastCount != null && contrastCount > 0)) { |
| | | throw new ErrorException("该计划已存在核查记录,为保留历史记录不允许删除"); |
| | | boolean hasReviewedRecord = records.stream().anyMatch(item -> item.getReviewStatus() != null |
| | | && (item.getReviewStatus() == 0 || item.getReviewStatus() == 1)); |
| | | boolean hasReviewedContrast = contrasts.stream().anyMatch(item -> item.getReviewStatus() != null |
| | | && (item.getReviewStatus() == 0 || item.getReviewStatus() == 1)); |
| | | if (hasReviewedRecord || hasReviewedContrast) { |
| | | throw new ErrorException("该计划已存在审核完成的核查记录,为保留历史记录不允许删除"); |
| | | } |
| | | if (!records.isEmpty()) { |
| | | List<Integer> recordIds = records.stream().map(DeviceExamineRecord::getRecordId).collect(Collectors.toList()); |
| | | deviceExamineRecordDetailMapper.delete(Wrappers.<DeviceExamineRecordDetail>lambdaQuery() |
| | | .in(DeviceExamineRecordDetail::getRecordId, recordIds)); |
| | | deviceExamineRecordMapper.deleteBatchIds(recordIds); |
| | | } |
| | | if (!contrasts.isEmpty()) { |
| | | List<Integer> contrastIds = contrasts.stream().map(DeviceExamineRecordContrast::getRecordContrastId).collect(Collectors.toList()); |
| | | deviceExamineRecordContrastDetailsMapper.delete(Wrappers.<DeviceExamineRecordContrastDetails>lambdaQuery() |
| | | .in(DeviceExamineRecordContrastDetails::getRecordContrastId, contrastIds)); |
| | | deviceExamineRecordContrastMapper.deleteBatchIds(contrastIds); |
| | | } |
| | | deviceExamineAttachmentMapper.delete(Wrappers.<DeviceExamineAttachment>lambdaQuery() |
| | | .eq(DeviceExamineAttachment::getPlanDetailsId, planDetailsId)); |
| | | boolean removed = deviceExaminePlanDetailsService.removeById(planDetailsId); |
| | | if (removed && detail.getDeviceId() != null) { |
| | | rollbackDeviceExamineDate(detail); |