|
@@ -41,6 +41,8 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
|
|
|
|
|
|
private final IInspectionRectifyService rectifyService;
|
|
|
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void add(RoutingInspectionDTO dto) {
|
|
@@ -49,23 +51,31 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
|
|
|
if (list == null || list.size() == 0){
|
|
|
throw new ServiceException("请填写检查项目");
|
|
|
}
|
|
|
- //先保存巡检信息
|
|
|
- Long id = SnowFlakeUtil.getId();
|
|
|
- RoutingInspection inspection = new RoutingInspection();
|
|
|
- BeanUtils.copyProperties(dto,inspection);
|
|
|
- inspection.setId(id);
|
|
|
- inspection.setCreateTime(new Date());
|
|
|
- this.save(inspection);
|
|
|
- //再保存具体的巡检项目
|
|
|
- List<InspectionRectify> list1 = list.stream().map(l -> {
|
|
|
- InspectionRectify rectify = new InspectionRectify();
|
|
|
- BeanUtils.copyProperties(l, rectify);
|
|
|
- rectify.setInspectId(id);
|
|
|
- List<String> autoExpandKeys = l.getAutoExpandKeys();
|
|
|
- rectify.setInspectLocation(JSON.toJSONString(autoExpandKeys));
|
|
|
- return rectify;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- rectifyService.saveBatch(list1);
|
|
|
+ //把巡检项目按照合同段id分组
|
|
|
+ Map<Long, List<InspectionRectifyDTO>> contractMap = list.stream().collect(Collectors.groupingBy(InspectionRectify::getContractId));
|
|
|
+ //循环
|
|
|
+ for (Long aLong : contractMap.keySet()) {
|
|
|
+ //先保存巡检信息
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ RoutingInspection inspection = new RoutingInspection();
|
|
|
+ BeanUtils.copyProperties(dto,inspection);
|
|
|
+ inspection.setId(id);
|
|
|
+ inspection.setContractId(aLong);
|
|
|
+ inspection.setCreateTime(new Date());
|
|
|
+ this.save(inspection);
|
|
|
+ //取出同一个合同段的项目
|
|
|
+ List<InspectionRectifyDTO> list2 = contractMap.get(aLong);
|
|
|
+ //再保存具体的巡检项目
|
|
|
+ List<InspectionRectify> list1 = list2.stream().map(l -> {
|
|
|
+ InspectionRectify rectify = new InspectionRectify();
|
|
|
+ BeanUtils.copyProperties(l, rectify);
|
|
|
+ rectify.setInspectId(id);
|
|
|
+ List<String> autoExpandKeys = l.getAutoExpandKeys();
|
|
|
+ rectify.setInspectLocation(JSON.toJSONString(autoExpandKeys));
|
|
|
+ return rectify;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ rectifyService.saveBatch(list1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -96,7 +106,18 @@ public class RoutingInspectionServiceImpl extends BaseServiceImpl<RoutingInspect
|
|
|
@Override
|
|
|
public IPage<RoutingInspectionVO> page(Query query, RoutingInspection inspection) {
|
|
|
IPage<RoutingInspectionVO> iPage = new Page<>(query.getCurrent(), query.getSize());
|
|
|
- baseMapper.page(iPage,inspection);
|
|
|
+ //先判断当前合同段是否为监理合同段
|
|
|
+ ContractInfo contractInfo = contractInfoService.getById(inspection.getContractId());
|
|
|
+ //如果不为监理合同段则正常流程
|
|
|
+ if (contractInfo.getContractType() == 2){
|
|
|
+ //如果为监理合同段,则查看合同段下所有检查的施工合同段
|
|
|
+ List<Long> ids = baseMapper.getAllBuildId(contractInfo.getId());
|
|
|
+ ids.add(contractInfo.getId());
|
|
|
+ //再统一查询三个合同段的信息
|
|
|
+ baseMapper.page2(iPage,inspection,ids);
|
|
|
+ }else {
|
|
|
+ baseMapper.page(iPage,inspection);
|
|
|
+ }
|
|
|
//设置权限,只能整改人可以点
|
|
|
Long userId = AuthUtil.getUserId();
|
|
|
List<RoutingInspectionVO> records = iPage.getRecords();
|