src/main/java/com/gkhy/labRiskManage/application/riskReport/service/impl/RiskAccessAppServiceImpl.java
@@ -564,6 +564,8 @@ if (currentUserId < 0){ throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录"); } //todo 需要评价人员都评价完成才可以 //提交评价结果 AssessPlanUpdateDTO evaluateSubmitResult= assessPlanService.evaluateSubmit(currentUserId, id); src/main/java/com/gkhy/labRiskManage/domain/riskReport/model/bo/AssessQueryBO.java
@@ -3,6 +3,8 @@ import lombok.Data; import java.util.List; /** * 风险辨识与评价 * */ @@ -32,4 +34,10 @@ * 评估计划执行状态:1-未开始;2-辨识阶段;3-评价阶段;4-评价完成 */ private Byte planExecStatus; List<Long> planIds; private Long userId; private Byte userTag; } src/main/java/com/gkhy/labRiskManage/domain/riskReport/repository/jpa/RiskAssessPlanRepository.java
@@ -3,6 +3,7 @@ import com.gkhy.labRiskManage.domain.riskReport.entity.RiskAssessPlan; import com.gkhy.labRiskManage.domain.riskReport.model.bo.ExecStatusSubmitBO; import com.gkhy.labRiskManage.domain.riskReport.model.dto.AssessPlanQueryDTO; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; @@ -63,5 +64,20 @@ @Query(value = "select t from RiskAssessPlan t where t.deleteStatus = 0 and t.riskUnitId = :basicId and riskType = 1") List<RiskAssessPlan> getAssessPlanByInherentUnit(Long basicId); @Query("SELECT COUNT(DISTINCT p.id) FROM RiskAssessPlan p " + "WHERE p.deleteStatus = 0 " + "AND (:assessPlanName IS NULL OR p.assessPlanName LIKE %:assessPlanName%) " + "AND (:experimentId IS NULL OR p.experimentId = :experimentId) " + "AND (:planUserId IS NULL OR p.planUserId = :planUserId) " + "and(coalesce(:riskUnitIds,null) is null or p.riskUnitId in :riskUnitIds)") Long countDynamic( String assessPlanName, Long experimentId, Long planUserId, List<Long> riskUnitIds); } src/main/java/com/gkhy/labRiskManage/domain/riskReport/service/impl/RiskAssessPlanServiceImpl.java
@@ -369,8 +369,17 @@ if (queryParam.getExperimentId() != null) { predicateList.add(criteriaBuilder.equal(root.get("experimentId"), queryParam.getExperimentId())); } Join<RiskAssessPlan, RiskAssessPlanIdentificationUser> identificationUserJoin = root.join("riskAssessPlanIdentificationUsers", JoinType.LEFT); Join<RiskAssessPlan, RiskAssessPlanEvaluateUser> evaluateUserJoin = root.join("riskAssessPlanEvaluateUsers", JoinType.LEFT); // Join<RiskAssessPlan, RiskAssessPlanIdentificationUser> identificationUserJoin = root.join("riskAssessPlanIdentificationUsers", JoinType.LEFT); // Join<RiskAssessPlan, RiskAssessPlanEvaluateUser> evaluateUserJoin = root.join("riskAssessPlanEvaluateUsers", JoinType.LEFT); Join<RiskAssessPlan, RiskAssessPlanIdentificationUser> identificationJoin = root.join("riskAssessPlanIdentificationUsers", JoinType.LEFT); identificationJoin.on(criteriaBuilder.equal(identificationJoin.get("deleteStatus"), StatusEnum.DELETE_NOT.getCode())); // LEFT JOIN riskAssessPlanEvaluateUsers Join<RiskAssessPlan, RiskAssessPlanEvaluateUser> evaluateJoin = root.join("riskAssessPlanEvaluateUsers", JoinType.LEFT); evaluateJoin.on(criteriaBuilder.equal(evaluateJoin.get("deleteStatus"), StatusEnum.DELETE_NOT.getCode())); if (roleTag == UserTagEnum.USER_TAG_0.getCode()) { predicateList.add(criteriaBuilder.equal(root.get("planUserId"), currentUserId)); @@ -382,6 +391,7 @@ // ) // ); } query.groupBy(root.get("id")); predicateList.add(criteriaBuilder.equal(root.get("deleteStatus"), StatusEnum.DELETE_NOT.getCode())); return criteriaBuilder.and(predicateList.toArray(new Predicate[0])); @@ -390,6 +400,11 @@ PageRequest pageParam = PageRequest.of(queryParam.getPageIndex() - 1, queryParam.getPageSize(), Sort.Direction.DESC, "updateTime"); Page<RiskAssessPlan> pageResult = assessPlanRepository.findAll(specification, pageParam); Long countDynamic = assessPlanRepository.countDynamic(queryParam.getAssessPlanName(), queryParam.getExperimentId(), roleTag == UserTagEnum.USER_TAG_0.getCode() ? currentUserId : null, queryParam.getRiskUnitIds()); List<RiskAssessPlanQueryDTO> assessPlanQueryDTOS = BeanCopyUtils.copyBeanList(pageResult.getContent(), RiskAssessPlanQueryDTO.class); @@ -438,7 +453,7 @@ } searchResult.setData(assessPlanQueryDTOS); searchResult.setTotal(pageResult.getTotalElements()); searchResult.setTotal(countDynamic); return searchResult; } @@ -1184,6 +1199,7 @@ } if (planIds.size() > 0) { predicateList.add(criteriaBuilder.in(root.get("id")).value(planIds)); queryParam.setPlanIds(planIds); } Join<RiskAssessPlan, RiskAssessPlanIdentificationUser> identificationUserJoin = root.join("riskAssessPlanIdentificationUsers", JoinType.LEFT); @@ -1192,6 +1208,8 @@ if (roleTag == UserTagEnum.USER_TAG_0.getCode()) { queryParam.setUserTag(UserTagEnum.USER_TAG_0.getCode().byteValue()); queryParam.setUserId(currentUserId); //辨识 if (queryParam.getTag() == 1) { predicateList.add(criteriaBuilder.equal(identificationUserJoin.get("identificationUserId"), currentUserId)); @@ -1217,6 +1235,9 @@ PageRequest pageParam = PageRequest.of(queryParam.getPageIndex() - 1, queryParam.getPageSize(), Sort.Direction.DESC, "updateTime"); Page<RiskAssessPlan> pageResult = assessPlanRepository.findAll(specification, pageParam); long pageCount = riskPlanDataMapper.getPageCount(queryParam); System.out.println("pageCountpageCountpageCountpageCountpageCountpageCount:"+pageCount); //循环遍历结果集,封装查询结果 List<AssessQueryDTO> assessQueryDTOList = new ArrayList<>(); @@ -1866,7 +1887,7 @@ } searchResult.setData(assessQueryDTOList); searchResult.setTotal(pageResult.getTotalElements()); searchResult.setTotal(pageCount); searchResult.setCount(assessQueryDTOList.size()); return searchResult; } src/main/java/com/gkhy/labRiskManage/mapper/RiskPlanDataMapper.java
@@ -1,6 +1,7 @@ package com.gkhy.labRiskManage.mapper; import com.gkhy.labRiskManage.domain.riskReport.entity.RiskAssessPlanIdentificationUser; import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessQueryBO; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -8,4 +9,5 @@ @Mapper public interface RiskPlanDataMapper { List<RiskAssessPlanIdentificationUser> pageList(); long getPageCount(AssessQueryBO queryBO); } src/main/resources/config/application-dev.yaml
@@ -6,12 +6,12 @@ datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://192.168.2.6:7006/laboratory_risk_manage?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true url: jdbc:mysql://192.168.2.19:7006/laboratory_risk_manage?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true username: root password: 2farwL3yPXfbH2AP master: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://192.168.2.6:7006/laboratory_risk_manage?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true url: jdbc:mysql://192.168.2.19:7006/laboratory_risk_manage?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useAffectedRows=true username: root password: 2farwL3yPXfbH2AP type: com.alibaba.druid.pool.DruidDataSource @@ -20,10 +20,15 @@ ddl-auto: none # ddl-auto: update #自动更新 show-sql: true #日志中显示sql语句 properties: hibernate: format_sql: true mybatis: mapper-locations: classpath:mapper/*.xml # type-aliases-package: com.gkhy.labRiskManage.domain.** logging: level: com.gkhy.labRiskManage: debug redis: # host: 192.168.0.52 # port: 6371 src/main/resources/config/application-gslab.yaml
@@ -70,3 +70,6 @@ mybatis: mapper-locations: classpath:mapper/*.xml # type-aliases-package: com.gkhy.labRiskManage.domain.** logging: level: com.gkhy.labRiskManage: debug src/main/resources/config/application.yaml
@@ -4,3 +4,4 @@ profiles: active: dev # active: gslab src/main/resources/mapper/RiskPlanDataMapper.xml
@@ -8,4 +8,47 @@ select id,identification_user identificationUser,identification_user_id identificationUserId from risk_assess_plan_identification_user </select> <select id="getPageCount" resultType="Long" parameterType="com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessQueryBO"> select count(a.id) from ( SELECT DISTINCT p.id as id FROM risk_assess_plan p <if test="userTag != null and userTag == 0"> <if test="userId != null and tag != null and tag == 1"> INNER JOIN risk_assess_plan_identification_user q ON p.id = q.risk_assess_plan_id AND q.delete_status = 0 AND q.identification_user_id = #{userId} </if> <if test="userId != null and tag != null and tag == 2"> INNER JOIN risk_assess_plan_evaluate_user h ON p.id = h.risk_assess_plan_id AND h.delete_status = 0 AND h.evaluate_user_id = #{userId} </if> </if> WHERE p.delete_status = 0 <if test="experimentId != null"> AND p.experiment_id = #{experimentId} </if> <if test="assessPlanName != null and assessPlanName != ''"> AND p.assess_plan_name LIKE CONCAT('%',#{assessPlanName},'%') </if> <if test="tag != null and tag == 2"> AND p.identification_time IS NOT NULL </if> <if test="tag != null and tag == 3"> AND p.evaluate_time IS NOT NULL </if> <if test="planExecStatus != null and planExecStatus == 5"> AND p.plan_exec_status >= 3 </if> <if test="planExecStatus != null and planExecStatus != 5"> AND p.plan_exec_status = #{planExecStatus} </if> <if test="planIds != null and !planIds.isEmpty()"> AND p.id IN <foreach collection="planIds" open="(" separator="," close=")"> #{id} </foreach> </if> GROUP BY p.id ) a </select> </mapper>