xuxiaofei лет назад: 2
Родитель
Сommit
587a80ddb6

+ 55 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabHazardController.java

@@ -1,10 +1,14 @@
 package com.zd.laboratory.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.zd.algorithm.api.fire.entity.vo.HardwareFireDeviceVO;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.annotation.PreAuthorize;
 import com.zd.common.core.log.BusinessType;
+import com.zd.common.core.redis.RedisService;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.laboratory.domain.LabHazard;
+import com.zd.laboratory.domain.LabHazardSubjectRelation;
 import com.zd.laboratory.domain.LabQpSubjectRelation;
 import com.zd.laboratory.domain.dto.LabHazardDTO;
 import com.zd.laboratory.domain.dto.LabHazardJoinSubDTO;
@@ -17,12 +21,15 @@ import com.zd.laboratory.service.ILabContainerService;
 import com.zd.laboratory.service.ILabHazardService;
 import com.zd.laboratory.service.ILabHazardSubjectRelationService;
 import com.zd.laboratory.service.ILabQpSubjectRelationService;
+import com.zd.model.constant.BaseConstants;
+import com.zd.model.constant.CacheConstants;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.enums.HazardTypeEnum;
 import com.zd.model.page.TableDataInfo;
 import com.zd.model.valid.ValidGroup;
+import com.zd.system.api.entity.SysDictData;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
@@ -31,8 +38,11 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 危险源Controller
@@ -52,6 +62,10 @@ public class LabHazardController extends BaseController {
     private ILabHazardSubjectRelationService labHazardSubjectRelationService;
     @Autowired
     private ILabQpSubjectRelationService labQpSubjectRelationService;
+    @Autowired
+    private RedisService redisService;
+
+
     /**
      * 查询危险源列表
      */
@@ -313,6 +327,47 @@ public class LabHazardController extends BaseController {
     }
 
     /**
+     * 校级大屏-学院危险源统计
+     */
+    @GetMapping("/relationBigViewCount")
+    @ApiOperation(value = "校级大屏-学院危险源统计")
+    public ResultData relationBigViewCount(LabHazardSubjectRelation relation) {
+        Map<String,Object> map = new HashMap<>();
+        //获取数据源
+        List<LabHazardSubjectRelation> list = labHazardSubjectRelationService.relationBigViewCount(relation);
+        //获取危险源列表
+        System.out.println(redisService.getCacheObject(BaseConstants.SYS_DICT_KEY+"lab_hazard_type")+"");
+        List<SysDictData> dictDataList =  redisService.getCacheObject(BaseConstants.SYS_DICT_KEY+"lab_hazard_type");
+
+        List<Object> backList = new ArrayList<>();
+        //按学院分组
+        Map<String, List<LabHazardSubjectRelation>> bottleConfigMap = list.stream().collect(Collectors.groupingBy(LabHazardSubjectRelation::getDeptName));
+        if(!bottleConfigMap.isEmpty()){
+            for (Map.Entry entry : bottleConfigMap.entrySet()) {
+                List<Object> objectList = new ArrayList<>();
+                Object Key = entry.getKey();
+                Object value = entry.getValue();
+                //System.out.println("key"+Key +"||||"+value);
+                objectList.add(Key);
+                for (SysDictData dicData:dictDataList) {
+                    Integer num =0;
+                    for (LabHazardSubjectRelation lsr:list) {
+                        //System.out.println("DeptName:"+lsr.getDeptName()+" key:"+ Key.toString() +" DictValue"+ dicData.getDictValue()+"  HazardTypeMode"+lsr.getHazardTypeMode());
+                        if(Key.equals(lsr.getDeptName()) && dicData.getDictLabel().equals(lsr.getHazardTypeModeName())){
+                            num=num+lsr.getTotalNum();
+                        }
+                    }
+                    objectList.add(num);
+                }
+                backList.add(objectList);
+            }
+        }
+        map.put("hazard",dictDataList);
+        map.put("list",backList);
+        return ResultData.success(map);
+    }
+
+    /**
      * 百分比计算
      *
      * @param y

+ 58 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabRiskPlanAbnormalGroupController.java

@@ -1,6 +1,8 @@
 package com.zd.laboratory.controller;
 
+import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.web.controller.BaseController;
+import com.zd.laboratory.domain.vo.WarningNoticeLogVO;
 import com.zd.model.domain.ResultData;
 import com.zd.laboratory.domain.LabRiskPlanAbnormalGroup;
 import com.zd.laboratory.domain.vo.LabRiskPlanAbnormalGroupVO;
@@ -14,7 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
+import java.util.*;
 
 import static com.zd.common.core.utils.PageHelperUtil.startPage;
 
@@ -69,4 +71,59 @@ public class LabRiskPlanAbnormalGroupController extends BaseController {
         }
         return ResultData.fail();
     }
+
+    /**
+     * 东北大学,数据大屏, 预案执行统计
+     * @param group
+     * @return
+     */
+    @GetMapping("/riskRecordCount")
+    @ApiOperation(value = "查询预案执行记录")
+    public TableDataInfo riskRecordCount(LabRiskPlanAbnormalGroup group) {
+        //结束时间
+        Date endTime =DateUtils.dateTime("yyyy-MM-dd",DateUtils.getDate()) ;
+        //开始时间 本年第一天
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        calendar.clear();
+        calendar.set(Calendar.YEAR, year);
+        Date startTime = calendar.getTime();
+
+        group.setStartTime(startTime);
+        group.setEndTime(endTime);
+        group.setStatus(0L);
+        //集合查询
+        List<LabRiskPlanAbnormalGroup> list = labRiskPlanAbnormalGroupService.queryRiskExeRecordList(group);
+        //list.sort(Comparator.comparing(LabRiskPlanAbnormalGroup::getCreateTime));
+
+        //数据封装
+        List<WarningNoticeLogVO> backList= new ArrayList<>();
+        if(list!=null && list.size()>0){
+            for (int i=1;i<13;i++){
+                WarningNoticeLogVO pag = new WarningNoticeLogVO();
+                pag.setYearMonth(i+"月");
+                int num =0;
+                for (LabRiskPlanAbnormalGroup gp:list) {
+                    String strdate = DateUtils.parseDateToStr("MM",gp.getCreateTime());
+                    if(Integer.valueOf(strdate).equals(i)){
+                        num++;
+                    }
+                }
+                pag.setTotalNum(num);
+                backList.add(pag);
+            }
+        }
+        return getDataTable(backList);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(Integer.valueOf("09"));
+        // 获取当前年第一天
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        calendar.clear();
+        calendar.set(Calendar.YEAR, year);
+        Date yearBegin = calendar.getTime();
+        System.out.println(DateUtils.dateTime(yearBegin));
+    }
 }

+ 53 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabHazardSubjectRelation.java

@@ -110,6 +110,25 @@ public class LabHazardSubjectRelation extends BaseEntity {
      */
     private Long buildId;
 
+    /**
+     * 部门名称
+     */
+    private String deptName;
+
+    /**
+     * 危险源类型名称
+     */
+    private String hazardTypeModeName;
+
+    /**
+     * 危险源类型
+     */
+    private Integer hazardTypeMode;
+
+    /**
+     * 数量
+     */
+    private Integer totalNum;
 
     public HazardTypeEnum getHazardType() {
         return hazardType;
@@ -198,4 +217,38 @@ public class LabHazardSubjectRelation extends BaseEntity {
     public void setBuildId(Long buildId) {
         this.buildId = buildId;
     }
+
+    @Override
+    public String getDeptName() {
+        return deptName;
+    }
+
+    @Override
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    public String getHazardTypeModeName() {
+        return hazardTypeModeName;
+    }
+
+    public void setHazardTypeModeName(String hazardTypeModeName) {
+        this.hazardTypeModeName = hazardTypeModeName;
+    }
+
+    public Integer getHazardTypeMode() {
+        return hazardTypeMode;
+    }
+
+    public void setHazardTypeMode(Integer hazardTypeMode) {
+        this.hazardTypeMode = hazardTypeMode;
+    }
+
+    public Integer getTotalNum() {
+        return totalNum;
+    }
+
+    public void setTotalNum(Integer totalNum) {
+        this.totalNum = totalNum;
+    }
 }

+ 23 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabRiskPlanAbnormalGroup.java

@@ -6,6 +6,8 @@ import com.zd.model.entity.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.Date;
+
 /**
  * 风险异常组级表对象 lab_risk_plan_abnormal_group
  *
@@ -68,6 +70,10 @@ public class LabRiskPlanAbnormalGroup extends BaseEntity {
     @Excel(name = "是否查看预案 0否 1是")
     private Integer ifCheck;
 
+    private Date startTime;
+
+    private Date endTime;
+
     @ApiModelProperty(value = "学院名称")
     @TableField(exist = false)
     private String deptName;
@@ -136,6 +142,23 @@ public class LabRiskPlanAbnormalGroup extends BaseEntity {
         this.ifCheck = ifCheck;
     }
 
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+
     @Override
     public String getDeptName() {
         return deptName;

+ 3 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/WarningNoticeLogVO.java

@@ -156,4 +156,7 @@ public class WarningNoticeLogVO {
 
     @ApiModelProperty("处理数量")
     private Integer disposeNum;
+
+    @ApiModelProperty(value = "日期")
+    private String yearMonth;
 }

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabHazardSubjectRelationMapper.java

@@ -90,4 +90,11 @@ public interface LabHazardSubjectRelationMapper {
     String queryChNameByHazardId(String hazardId);
 
     int deleteBySubId(Long subId);
+
+    /**
+     * 按学院统计危险源数量
+     * @param relation
+     * @return
+     */
+    List<LabHazardSubjectRelation> relationBigViewCount(LabHazardSubjectRelation relation);
 }

+ 8 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabHazardSubjectRelationService.java

@@ -112,4 +112,12 @@ public interface ILabHazardSubjectRelationService {
      * @return
      */
     public List<CommonCount> queryCountBySubIds(Long... ids);
+
+
+    /**
+     * 按学院统计危险源数量
+     * @param relation
+     * @return
+     */
+    List<LabHazardSubjectRelation> relationBigViewCount(LabHazardSubjectRelation relation);
 }

+ 11 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabHazardSubjectRelationServiceImpl.java

@@ -295,4 +295,15 @@ public class LabHazardSubjectRelationServiceImpl implements ILabHazardSubjectRel
     public List<CommonCount> queryCountBySubIds(Long... ids) {
         return labHazardSubjectRelationMapper.queryCountBySubIds(ids);
     }
+
+    /**
+     * 按学院统计危险源数量
+     *
+     * @param relation
+     * @return
+     */
+    @Override
+    public List<LabHazardSubjectRelation> relationBigViewCount(LabHazardSubjectRelation relation) {
+        return labHazardSubjectRelationMapper.relationBigViewCount(relation);
+    }
 }

+ 51 - 20
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHazardSubjectRelationMapper.xml

@@ -7,8 +7,8 @@
     <resultMap type="com.zd.laboratory.domain.LabHazardSubjectRelation" id="LabHazardSubjectRelationResult">
         <result property="id" column="id"/>
         <result property="hazardId" column="hazard_id"/>
-<!--        <result property="containerId" column="container_id"/>-->
-        <result property="hazardType" column="hazard_type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler" />
+        <!--        <result property="containerId" column="container_id"/>-->
+        <result property="hazardType" column="hazard_type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
         <result property="hazardId" column="hazard_id"/>
         <result property="subjectId" column="subject_id"/>
         <result property="identify" column="identify"/>
@@ -22,10 +22,20 @@
     </resultMap>
 
     <sql id="AllField">
-        id, hazard_id, container_id, subject_id, identify, create_time,x_point,y_point
+        id
+        , hazard_id, container_id, subject_id, identify, create_time,x_point,y_point
     </sql>
     <sql id="selectLabHazardSubjectRelationVo">
-        select id, hazard_id, hazard_type,x_point,y_point, subject_id, identify, create_time,another_name,another_code
+        select id,
+               hazard_id,
+               hazard_type,
+               x_point,
+               y_point,
+               subject_id,
+               identify,
+               create_time,
+               another_name,
+               another_code
         from lab_hazard_subject_relation
     </sql>
 
@@ -38,9 +48,9 @@
             <if test="subjectId != null  ">and subject_id = #{subjectId}</if>
         </where>
     </select>
-<!-- 查询实验室危险品数量 -->
+    <!-- 查询实验室危险品数量 -->
     <select id="queryCountBySubIds" resultType="com.zd.system.api.entity.CommonCount">
-        select count(id) count,lhsr.subject_id as id from  lab_hazard_subject_relation lhsr
+        select count(id) count,lhsr.subject_id as id from lab_hazard_subject_relation lhsr
         where lhsr.subject_id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
@@ -48,18 +58,18 @@
         GROUP BY lhsr.subject_id
     </select>
 
-    <select id="selectLabHazardSubjectRelationById"  resultMap="LabHazardSubjectRelationResult">
+    <select id="selectLabHazardSubjectRelationById" resultMap="LabHazardSubjectRelationResult">
         <include refid="selectLabHazardSubjectRelationVo"/>
         where id = #{id}
     </select>
 
     <select id="queryLabByHazardId" resultMap="LabHazardSubjectRelationResult">
         select
-            sr.id, sr.hazard_id, sr.subject_id, sr.identify, sr.create_time,
+        sr.id, sr.hazard_id, sr.subject_id, sr.identify, sr.create_time,
         sr.x_point,sr.y_point,
-            s.name as subjectName
+        s.name as subjectName
         from
-             lab_hazard_subject_relation sr left join lab_subject s on sr.subject_id = s.id
+        lab_hazard_subject_relation sr left join lab_subject s on sr.subject_id = s.id
         <where>
             <if test="hazardId != null">
                 and sr.hazard_id = #{hazardId}
@@ -78,7 +88,9 @@
     </select>
 
     <select id="queryChNameByHazardId" resultType="java.lang.String">
-        select ch_name as chName from lab_hazard where id = #{hazardId}
+        select ch_name as chName
+        from lab_hazard
+        where id = #{hazardId}
     </select>
 
     <insert id="insertLabHazardSubjectRelation" parameterType="com.zd.laboratory.domain.LabHazardSubjectRelation">
@@ -113,16 +125,20 @@
     </insert>
 
     <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
-        insert into lab_hazard_subject_relation(id, hazard_id,hazard_type , subject_id, identify,x_point,y_point,create_time,another_name
+        insert into lab_hazard_subject_relation(id, hazard_id,hazard_type , subject_id,
+        identify,x_point,y_point,create_time,another_name
         ,another_code,user_id)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.id}, #{entity.hazardId}, #{entity.hazardType}, #{entity.subjectId}, #{entity.identify},#{entity.xPoint},#{entity.yPoint}
+            (#{entity.id}, #{entity.hazardId}, #{entity.hazardType}, #{entity.subjectId},
+            #{entity.identify},#{entity.xPoint},#{entity.yPoint}
             ,NOW(),#{entity.anotherName},#{entity.anotherCode},#{entity.userId})
         </foreach>
         on duplicate key update
-        hazard_id = values(hazard_id) , hazard_type = values(hazard_type) , subject_id = values(subject_id) , identify = values(identify), x_point = values(x_point), y_point = values(y_point)
-        , create_time = values(NOW()), another_name = values(another_name), another_code = values(another_code), user_id = values(user_id)
+        hazard_id = values(hazard_id) , hazard_type = values(hazard_type) , subject_id = values(subject_id) , identify =
+        values(identify), x_point = values(x_point), y_point = values(y_point)
+        , create_time = values(NOW()), another_name = values(another_name), another_code = values(another_code), user_id
+        = values(user_id)
     </insert>
 
     <update id="updateLabHazardSubjectRelation" parameterType="com.zd.laboratory.domain.LabHazardSubjectRelation">
@@ -138,7 +154,7 @@
         where id = #{id}
     </update>
 
-    <delete id="deleteLabHazardSubjectRelationById" >
+    <delete id="deleteLabHazardSubjectRelationById">
         delete
         from lab_hazard_subject_relation
         where id = #{id}
@@ -150,14 +166,29 @@
             #{id}
         </foreach>
     </delete>
-<!--   删除指定实验室下的危险品关系 -->
-    <delete id="deleteSubLabHazardSubjectRelationByIds" >
-        delete from lab_hazard_subject_relation where subject_id =#{subId} and  id in
+    <!--   删除指定实验室下的危险品关系 -->
+    <delete id="deleteSubLabHazardSubjectRelationByIds">
+        delete from lab_hazard_subject_relation where subject_id =#{subId} and id in
         <foreach item="id" collection="ids" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
     <delete id="deleteBySubId">
-        delete from lab_hazard_subject_relation where subject_id = #{subId}
+        delete
+        from lab_hazard_subject_relation
+        where subject_id = #{subId}
     </delete>
+
+    <select id="relationBigViewCount" parameterType="com.zd.laboratory.domain.LabHazardSubjectRelation"
+            resultType="com.zd.laboratory.domain.LabHazardSubjectRelation">
+        select dept_name deptName, hazard_type_mode hazardTypeMode, hazard_type_mode_name hazardTypeModeName, count(1) totalNum
+        from (
+                 select sr.subject_id, su.`name`, d.dept_name, d.dept_id, h.hazard_type_mode, h.hazard_type_mode_name
+                 from lab_hazard_subject_relation sr
+                          INNER JOIN lab_subject su on sr.subject_id = su.id
+                          INNER JOIN sys_dept d on d.dept_id = su.dept_id
+                          INNER JOIN lab_hazard h on sr.hazard_id = h.id
+             ) t
+        GROUP BY dept_id, hazard_type_mode
+    </select>
 </mapper>

+ 8 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabRiskPlanAbnormalGroupMapper.xml

@@ -169,6 +169,14 @@
                 )
             </if>
             <if test="riskAttribute != null ">and g.risk_attribute = #{riskAttribute}</if>
+
+            <if test="startTime != null ">
+                and date_format(g.create_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
+            </if>
+            <if test="endTime != null ">
+                and date_format(g.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
+            </if>
+
         </where>
         ORDER  BY g.create_time DESC
     </select>