|
|
@ -1,8 +1,5 @@ |
|
|
|
package com.kms.yxgh.df.service; |
|
|
|
|
|
|
|
import com.alibaba.druid.sql.visitor.functions.If; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
@ -10,15 +7,15 @@ 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.kms.yxgh.common.dto.DocV2Dto; |
|
|
|
import com.kms.yxgh.common.enums.DfYhV2StatusEnum; |
|
|
|
import com.kms.yxgh.df.domain.*; |
|
|
|
import com.kms.yxgh.df.dto.DfCheckingDetailDto; |
|
|
|
import com.kms.yxgh.df.domain.DfCheckingProblemV2; |
|
|
|
import com.kms.yxgh.df.domain.DfCheckingRecord; |
|
|
|
import com.kms.yxgh.df.domain.DfCheckingV2ProjectItem; |
|
|
|
import com.kms.yxgh.df.domain.DfYhV2; |
|
|
|
import com.kms.yxgh.df.dto.v2.DfProblemV2Dto; |
|
|
|
import com.kms.yxgh.df.dto.v2.DfRecordDetailV2Dto; |
|
|
|
import com.kms.yxgh.df.dto.v2.DfRecordSearchV2Dto; |
|
|
|
import com.kms.yxgh.df.mapper.DfCheckingRecordV2Mapper; |
|
|
|
import com.kms.yxgh.util.ListUtil; |
|
|
|
import com.shuili.common.core.domain.SearchParam; |
|
|
|
import com.shuili.common.core.service.BaseService; |
|
|
|
import com.shuili.common.utils.BeanUtils; |
|
|
@ -26,7 +23,9 @@ import lombok.AllArgsConstructor; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -45,6 +44,7 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
private final DfCheckingV2ProjectItemV2Service dfCheckingV2ProjectItemV2Service; |
|
|
|
|
|
|
|
private final DfCheckingProblemV2Service dfCheckingProblemV2Service; |
|
|
|
|
|
|
|
public IPage<DfRecordDetailV2Dto> list(SearchParam<DfRecordSearchV2Dto> sp) { |
|
|
|
// 分页参数
|
|
|
|
Page<DfCheckingRecord> page = new Page<>(sp.getPageNum(), sp.getPageSize()); |
|
|
@ -83,7 +83,6 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询分页数据
|
|
|
|
Page<DfCheckingRecord> queryPage = page(page, queryWrapper); |
|
|
|
if (queryPage == null) { |
|
|
@ -108,7 +107,7 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
} |
|
|
|
|
|
|
|
public DfRecordDetailV2Dto getInfo(String id) { |
|
|
|
DfRecordDetailV2Dto dto=new DfRecordDetailV2Dto(); |
|
|
|
DfRecordDetailV2Dto dto = new DfRecordDetailV2Dto(); |
|
|
|
DfCheckingRecord dfCheckingRecord = getById(id); |
|
|
|
if (dfCheckingRecord != null) { |
|
|
|
BeanUtils.copyProperties(dfCheckingRecord, dto); |
|
|
@ -122,8 +121,8 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
.collect(Collectors.toList())); |
|
|
|
} |
|
|
|
// 巡查详情列表
|
|
|
|
SearchParam<DfRecordSearchV2Dto> sp=new SearchParam<>(); |
|
|
|
DfRecordSearchV2Dto searchV2Dto=new DfRecordSearchV2Dto(); |
|
|
|
SearchParam<DfRecordSearchV2Dto> sp = new SearchParam<>(); |
|
|
|
DfRecordSearchV2Dto searchV2Dto = new DfRecordSearchV2Dto(); |
|
|
|
assert dfCheckingRecord != null; |
|
|
|
searchV2Dto.setRecordId(dfCheckingRecord.getId()); |
|
|
|
sp.setData(searchV2Dto); |
|
|
@ -134,12 +133,12 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
List<DfProblemV2Dto> records = list.getRecords(); |
|
|
|
List<DfRecordDetailV2Dto.DfRecordItemDetailV2Dto> dtoList = new ArrayList<>(); |
|
|
|
for (DfProblemV2Dto record : records) { |
|
|
|
DfRecordDetailV2Dto.DfRecordItemDetailV2Dto detailV2Dto=new DfRecordDetailV2Dto.DfRecordItemDetailV2Dto(); |
|
|
|
if (null!=record.getParts()) { |
|
|
|
DfRecordDetailV2Dto.DfRecordItemDetailV2Dto detailV2Dto = new DfRecordDetailV2Dto.DfRecordItemDetailV2Dto(); |
|
|
|
if (null != record.getParts()) { |
|
|
|
detailV2Dto.setParts(DfCheckingV2Service.getStringList(record.getParts().split(","))); |
|
|
|
} |
|
|
|
if (null!=record.getDoc()){ |
|
|
|
detailV2Dto.setProblemImages(DfCheckingV2Service.getStringList(record.getDoc().split(","))); |
|
|
|
if (null != record.getDoc()) { |
|
|
|
detailV2Dto.setProblemImages(DfCheckingV2Service.getStringList(record.getDoc().split(","))); |
|
|
|
} |
|
|
|
detailV2Dto.setDepict(record.getDepict()); |
|
|
|
detailV2Dto.setPosition(record.getPosition()); |
|
|
@ -152,33 +151,34 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
} |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public DfRecordDetailV2Dto edit(DfRecordDetailV2Dto dfRecord, Boolean commit) { |
|
|
|
// 先删后加
|
|
|
|
myRemovePraIds(dfRecord); |
|
|
|
if (commit) { |
|
|
|
DfCheckingRecord dfCheckingRecord=new DfCheckingRecord(); |
|
|
|
DfCheckingRecord dfCheckingRecord = new DfCheckingRecord(); |
|
|
|
BeanUtils.copyProperties(dfRecord, dfCheckingRecord); |
|
|
|
// 提交为已巡检
|
|
|
|
dfCheckingRecord.setStatus(DfYhV2StatusEnum.INSPECTED.getValue()); |
|
|
|
// 如果相关缺陷大于一条就是养护中
|
|
|
|
if (!dfRecord.getProblems().isEmpty()) { |
|
|
|
dfCheckingRecord.setStatus(DfYhV2StatusEnum.UNDER_MAINTENANCE.getValue()); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 提交时缺陷无数据就是无缺陷
|
|
|
|
dfCheckingRecord.setStatus(DfYhV2StatusEnum.NO_DEFECTS.getValue()); |
|
|
|
} |
|
|
|
saveOrUpdate(dfCheckingRecord); |
|
|
|
dfCheckingProblemV2Service.saveOrUpdateBatch(convertToImages(dfRecord)); |
|
|
|
return dfRecord; |
|
|
|
}else { |
|
|
|
DfCheckingRecord dfCheckingRecord=new DfCheckingRecord(); |
|
|
|
return dfRecord; |
|
|
|
} else { |
|
|
|
DfCheckingRecord dfCheckingRecord = new DfCheckingRecord(); |
|
|
|
BeanUtils.copyProperties(dfRecord, dfCheckingRecord); |
|
|
|
// 未提交维巡查中
|
|
|
|
dfCheckingRecord.setStatus(DfYhV2StatusEnum.DURING_INSPECTION.getValue()); |
|
|
|
saveOrUpdate(dfCheckingRecord); |
|
|
|
dfCheckingProblemV2Service.saveOrUpdateBatch(convertToImages(dfRecord)); |
|
|
|
return dfRecord; |
|
|
|
return dfRecord; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -187,16 +187,16 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
.stream() |
|
|
|
.map(DfRecordDetailV2Dto.DfRecordItemDetailV2Dto::getId).collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(ids)) { |
|
|
|
dfCheckingProblemV2Service.remove(new LambdaQueryWrapper<DfCheckingProblemV2>().in(DfCheckingProblemV2::getId,ids)); |
|
|
|
dfYhV2Service.remove(new LambdaQueryWrapper<DfYhV2>().in(DfYhV2::getDefectId,ids)); |
|
|
|
dfCheckingProblemV2Service.remove(new LambdaQueryWrapper<DfCheckingProblemV2>().in(DfCheckingProblemV2::getId, ids)); |
|
|
|
dfYhV2Service.remove(new LambdaQueryWrapper<DfYhV2>().in(DfYhV2::getDefectId, ids)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static List<DfCheckingProblemV2> convertToImages(DfRecordDetailV2Dto dfRecord) { |
|
|
|
List<DfCheckingProblemV2> dfCheckingProblemV2s = new ArrayList<>(); |
|
|
|
dfRecord.getProblems().forEach(e->{ |
|
|
|
DfCheckingProblemV2 dfCheckingProblemV2=new DfCheckingProblemV2(); |
|
|
|
BeanUtils.copyProperties(e,dfCheckingProblemV2); |
|
|
|
dfRecord.getProblems().forEach(e -> { |
|
|
|
DfCheckingProblemV2 dfCheckingProblemV2 = new DfCheckingProblemV2(); |
|
|
|
BeanUtils.copyProperties(e, dfCheckingProblemV2); |
|
|
|
dfCheckingProblemV2.setCheckingId(dfRecord.getCheckingId()); |
|
|
|
dfCheckingProblemV2.setRecordId(dfRecord.getId()); |
|
|
|
dfCheckingProblemV2.setCheckingName(dfRecord.getCheckingName()); |
|
|
@ -206,29 +206,28 @@ public class DfCheckingRecordV2Service extends BaseService<DfCheckingRecordV2Map |
|
|
|
dfCheckingProblemV2.setDutyHolderId(dfRecord.getCreateUid()); |
|
|
|
dfCheckingProblemV2.setStartDate(dfRecord.getStartDate()); |
|
|
|
dfCheckingProblemV2.setEndDate(dfRecord.getEndDate()); |
|
|
|
dfCheckingProblemV2.setDepict(dfRecord.getDepict()); |
|
|
|
dfCheckingProblemV2.setType(dfRecord.getType()); |
|
|
|
dfCheckingProblemV2.setCategory(dfRecord.getCategory()); |
|
|
|
if (null!= e.getParts()) { |
|
|
|
dfCheckingProblemV2.setParts(e.getParts().stream().collect(Collectors.joining(","))); |
|
|
|
if (null != e.getParts()) { |
|
|
|
dfCheckingProblemV2.setParts(String.join(",", e.getParts())); |
|
|
|
} |
|
|
|
if (null!= e.getProblemImages()){ |
|
|
|
dfCheckingProblemV2.setDoc(e.getProblemImages().stream().collect(Collectors.joining(","))); |
|
|
|
if (null != e.getProblemImages()) { |
|
|
|
dfCheckingProblemV2.setDoc(String.join(",", e.getProblemImages())); |
|
|
|
|
|
|
|
} |
|
|
|
dfCheckingProblemV2.setDepict(e.getDepict()); |
|
|
|
dfCheckingProblemV2s.add(dfCheckingProblemV2); |
|
|
|
}); |
|
|
|
return dfCheckingProblemV2s; |
|
|
|
return dfCheckingProblemV2s; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Boolean myRemove(String[] ids) { |
|
|
|
if ( null!= ids && ids.length > 0) { |
|
|
|
if (null != ids && ids.length > 0) { |
|
|
|
int count = dfCheckingProblemV2Service.count(new LambdaQueryWrapper<DfCheckingProblemV2>() |
|
|
|
.in(DfCheckingProblemV2::getCheckingId |
|
|
|
, DfCheckingV2Service.getIntList(ids)) |
|
|
|
); |
|
|
|
if (count > 0) { |
|
|
|
if (count > 0) { |
|
|
|
throw new RuntimeException("请先删除项目子项"); |
|
|
|
} |
|
|
|
dfCheckingProblemV2Service.remove(new LambdaQueryWrapper<DfCheckingProblemV2>() |
|
|
|