|
|
@ -86,6 +86,7 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> { |
|
|
|
if (record == null) { |
|
|
|
throw new DfException("巡查记录不能为空"); |
|
|
|
} |
|
|
|
record.setHandleStatus(handleStatus(dto)); |
|
|
|
int rsp = getBaseMapper().insert(record); |
|
|
|
if (rsp <= 0) { |
|
|
|
throw new DfException("新增巡查记录失败"); |
|
|
@ -100,6 +101,19 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> { |
|
|
|
return this.getDetailById(id); |
|
|
|
} |
|
|
|
|
|
|
|
private String handleStatus(DfRecordDetailDto dto) { |
|
|
|
if (CollectionUtil.isEmpty(dto.getItems()) || dto.getItems().stream().allMatch(r -> CollectionUtil.isEmpty(r.getProblemImages()))) { |
|
|
|
//无异常
|
|
|
|
return "0"; |
|
|
|
} |
|
|
|
if (dto.getItems().stream().anyMatch(r -> CollectionUtil.isEmpty(r.getHandleImages()) && CollectionUtil.isNotEmpty(r.getProblemImages()))) { |
|
|
|
//未处置
|
|
|
|
return "1"; |
|
|
|
} |
|
|
|
//已处置
|
|
|
|
return "2"; |
|
|
|
} |
|
|
|
|
|
|
|
private static Function<DfRecordItemDto, DfRecordItem> getDfRecordItemDtoDfRecordItemFunction(String recordId) { |
|
|
|
return o -> { |
|
|
|
DfRecordItem item = BeanCopyUtils.copy(o, DfRecordItem.class); |
|
|
@ -149,6 +163,7 @@ public class DfRecordService extends BaseService<DfRecordMapper, DfRecord> { |
|
|
|
if (record == null) { |
|
|
|
throw new DfException("巡查记录不存在"); |
|
|
|
} |
|
|
|
record.setHandleStatus(handleStatus(dfRecord)); |
|
|
|
if (CollectionUtil.isNotEmpty(dfRecord.getItems())) { |
|
|
|
List<DfRecordItem> items = dfRecord.getItems() |
|
|
|
.stream().map(getDfRecordItemDtoDfRecordItemFunction(dfRecord.getId())) |
|
|
|