فهرست منبع

质量巡检检查项目分开保存

qianxb 1 سال پیش
والد
کامیت
aaf101b350

+ 6 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/RoutingInspectionMapper.java

@@ -7,8 +7,14 @@ import org.apache.ibatis.annotations.Param;
 import org.springblade.manager.entity.RoutingInspection;
 import org.springblade.manager.vo.RoutingInspectionVO;
 
+import java.util.List;
+
 
 public interface RoutingInspectionMapper extends BaseMapper<RoutingInspection> {
 
     IPage<RoutingInspectionVO> page(IPage<RoutingInspectionVO> iPage,@Param("inspection") RoutingInspection inspection);
+
+    List<Long> getAllBuildId(@Param("id") Long id);
+
+    IPage<RoutingInspectionVO> page2(IPage<RoutingInspectionVO> iPage,@Param("inspection")  RoutingInspection inspection,@Param("ids") List<Long> ids);
 }

+ 23 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/RoutingInspectionMapper.xml

@@ -19,4 +19,27 @@
         </if>
         order by mri.create_time desc
     </select>
+    <select id="getAllBuildId" resultType="java.lang.Long">
+        select contract_id_sg  from m_contract_relation_jlyz WHERE contract_id_jlyz = #{id}
+    </select>
+    <select id="page2" resultType="org.springblade.manager.vo.RoutingInspectionVO">
+        select mri.*,
+        (select project_name from m_project_info where id = mri.project_id) as projectName,
+        (select dict_value from blade_dict where code = 'inspect_type' and dict_key = mri.inspect_type) as inspectTypeName,
+        (select dict_value from blade_dict where code = 'review_inspect_status' and dict_key = mri.review_inspect_status) as reviewInspectStatusName,
+        case mri.is_rectify
+        when 1 then '需要'
+        when 2 then '不需要'
+        when 3 then '已整改'
+        end as isRectifyName
+        from m_routing_inspection mri
+        where mri.is_deleted = 0 and mri.project_id = #{inspection.projectId} and contract_id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        <if test="inspection.isRectify != null and inspection.isRectify != ''">
+            and mri.is_rectify = #{inspection.isRectify}
+        </if>
+        order by mri.create_time desc
+    </select>
 </mapper>

+ 39 - 18
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/RoutingInspectionServiceImpl.java

@@ -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();