Преглед изворни кода

东北大学院级大屏统计

xuxiaofei пре 2 година
родитељ
комит
a6d5151aa6

+ 0 - 1
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/DbStatisticsController.java

@@ -94,7 +94,6 @@ public class DbStatisticsController extends BaseController {
     @ApiOperation(value = "实验室排名统计")
     public ResultData subjectGroup(DbStockBo bo) {
         //集合查询
-        startPage();
         List<DbStockVo> list =  dbStockService.selectSubjectListGroupBy(bo);
         return ResultData.success(list);
     }

+ 33 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabHazardController.java

@@ -9,6 +9,7 @@ import com.zd.laboratory.domain.LabQpSubjectRelation;
 import com.zd.laboratory.domain.dto.LabHazardDTO;
 import com.zd.laboratory.domain.dto.LabHazardJoinSubDTO;
 import com.zd.laboratory.domain.dto.LabHazardNewVo;
+import com.zd.laboratory.domain.vo.LabHazardBigViewVO;
 import com.zd.laboratory.domain.vo.LabHazardColumnarVO;
 import com.zd.laboratory.domain.vo.LabHazardSubVO;
 import com.zd.laboratory.domain.vo.LabHazardVO;
@@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.DecimalFormat;
 import java.util.List;
 import java.util.Map;
 
@@ -299,6 +301,36 @@ public class LabHazardController extends BaseController {
     @GetMapping("/queryBigViewHazardList")
     @ApiOperation(value = "危险源统计列表(大屏用)")
     public ResultData queryBigViewHazardList(LabHazardVO labHazardVO) {
-        return ResultData.success(labHazardService.queryBigViewHazardList(labHazardVO));
+        List<LabHazardBigViewVO> list = labHazardService.queryBigViewHazardList(labHazardVO);
+        if(list!=null && list.size()>0){
+            //占比计算
+            Integer count= list.stream().mapToInt(a->a.getTotalNum()).sum();
+            for (LabHazardBigViewVO vo:list) {
+                vo.setRatio(myPercent(vo.getTotalNum(),count,"##.0%"));
+            }
+        }
+        return ResultData.success(list);
+    }
+
+    /**
+     * 百分比计算
+     *
+     * @param y
+     * @param z
+     * @return
+     */
+    public String myPercent(Integer y, Integer z, String format) {
+        if (0 == y || 0 == z) {
+            return "0%";
+        }
+        // 接受百分比的值
+        String baifenbi = "";
+        double baiy = y * 1.0;
+        double baiz = z * 1.0;
+        double fen = baiy / baiz;
+        DecimalFormat df1 = new DecimalFormat(format);
+        // 百分比格式,后面不足2位的用0补齐
+        baifenbi = df1.format(fen);
+        return baifenbi;
     }
 }

+ 57 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/WarningNoticeLogController.java

@@ -18,10 +18,18 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.HashMap;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -138,4 +146,53 @@ public class WarningNoticeLogController extends AbstractController {
         warningNoticeLogService.labCoatTask();
         return ResultData.success();
     }
+
+
+    @GetMapping("/warningCollect")
+    @ApiOperation("数据大屏,预警通知统计")
+    public ResultData warningCollect() {
+        List<WarningNoticeLogVO> backList = new ArrayList<>();
+        //集合查询
+        List<WarningNoticeLogVO> list = warningNoticeLogService.selectWarningNoticelist();
+
+        if(list!=null && list.size()>0){
+            //根据部门分组
+            Map<String,List<WarningNoticeLogVO>>  gourpList = list.stream().collect(Collectors.groupingBy(WarningNoticeLogVO::getDeptName));
+            //数据收集
+            for (Map.Entry<String, List<WarningNoticeLogVO>> entry : gourpList.entrySet()) {
+                WarningNoticeLogVO noticeLogVO = new WarningNoticeLogVO();
+                String deptName = entry.getKey();
+                int cl = 0;
+                int wcl = 0;
+                for (WarningNoticeLogVO vo2 : list) {
+                    if (deptName.equals(vo2.getDeptName())) {
+                        if (vo2.getDispose().equals(0)) {
+                            wcl = wcl + vo2.getTotalNum();
+                        } else {
+                            cl = cl + vo2.getTotalNum();
+                        }
+                    }
+                }
+                noticeLogVO.setDeptName(deptName);
+                noticeLogVO.setTotalNum(cl + wcl);
+                noticeLogVO.setDisposeNum(cl);
+                backList.add(noticeLogVO);
+            }
+            //排序
+            //backList.stream().sorted(Comparator.comparing(WarningNoticeLogVO::getTotalNum).reversed()).collect(Collectors.toList());
+            backList.sort(Comparator.comparing(WarningNoticeLogVO::getTotalNum).reversed());
+        }
+        return ResultData.success(backList);
+    }
+
+    @GetMapping("/airCollect")
+    @ApiOperation("数据大屏,定位预警统计")
+    public ResultData airCollect() {
+        LambdaQueryWrapper<WarningNoticeLog> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(WarningNoticeLog::getWarningType,3);
+        //queryWrapper.gt(WarningNoticeLog::getCreateTime,LocalDateTime.now().minusMonths(1)).lt(WarningNoticeLog::getCreateTime,LocalDateTime.now()).orderByDesc(WarningNoticeLog::getCreateTime);
+        queryWrapper.between(WarningNoticeLog::getCreateTime,LocalDateTime.now().minusMonths(1),LocalDateTime.now()).orderByDesc(WarningNoticeLog::getCreateTime);
+        return ResultData.success(warningNoticeLogService.list(queryWrapper));
+    }
+
 }

+ 3 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabHazardBigViewVO.java

@@ -24,10 +24,12 @@ public class LabHazardBigViewVO {
     private String dictValue;
 
     @ApiModelProperty("危险源总量")
-    private BigDecimal totalNum;
+    private Integer totalNum;
 
     @ApiModelProperty("危险源单位")
     private String unit;
 
+    @ApiModelProperty("比率")
+    private String ratio;
 
 }

+ 9 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/WarningNoticeLogMapper.java

@@ -2,8 +2,12 @@ package com.zd.laboratory.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zd.laboratory.domain.WarningNoticeLog;
+import com.zd.laboratory.domain.vo.WarningNoticeLogVO;
+import org.apache.catalina.LifecycleState;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * <p>
  * 预警通知日志 Mapper 接口
@@ -15,4 +19,9 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface WarningNoticeLogMapper extends BaseMapper<WarningNoticeLog> {
 
+    /***
+     * 查询学院下的隐患统计 top
+     * @return
+     */
+    List<WarningNoticeLogVO> selectWarningNoticelist();
 }

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

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.zd.laboratory.domain.WarningNoticeLog;
 import com.zd.laboratory.domain.vo.WarningNoticeLogVO;
 
+import java.util.List;
+
 /**
  * <p>
  * 预警通知日志 服务类
@@ -34,4 +36,10 @@ public interface WarningNoticeLogService extends IService<WarningNoticeLog> {
      * @Return void
      **/
     void labCoatTask();
+
+    /***
+     * 查询学院下的隐患统计 top
+     * @return
+     */
+    List<WarningNoticeLogVO> selectWarningNoticelist();
 }

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

@@ -56,6 +56,8 @@ public class WarningNoticeLogServiceImpl extends ServiceImpl<WarningNoticeLogMap
     private WarningDetailService warningDetailService;
     @Autowired
     private IAlarmLogService alarmLogService;
+    @Autowired
+    private WarningNoticeLogMapper warningNoticeLogMapper;
 
     @Override
     public Long addWarningNoticeLog(WarningNoticeLog warningNoticeLog) {
@@ -116,4 +118,13 @@ public class WarningNoticeLogServiceImpl extends ServiceImpl<WarningNoticeLogMap
             }
         }
     }
+
+    /***
+     * 查询学院下的隐患统计 top
+     * @return
+     */
+    @Override
+    public List<WarningNoticeLogVO> selectWarningNoticelist() {
+        return warningNoticeLogMapper.selectWarningNoticelist();
+    }
 }

+ 12 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/WarningNoticeLogMapper.xml

@@ -49,4 +49,16 @@
         id, key_id, warning_content, warning_type, warning_sub_type, warning_way, sub_id, sub_name, build_name, floor_name, room_num, warning_time, name, margin, specification, apply_user, apply_time, deposit, record_video, record_photo, risk_duration, responder, indoor_user, start_time, end_time, expiration_time, entry_time, holder, voice_broadcast, remark, dispose, create_name, create_by, create_time, update_name, update_by, update_time, is_deleted
     </sql>
 
+    <select id="selectWarningNoticelist"
+            resultType="com.zd.laboratory.domain.vo.WarningNoticeLogVO">
+        select (select de.dept_name
+                from lab_subject su
+                         LEFT JOIN sys_dept de on su.dept_id = de.dept_id
+                where su.id = l.sub_id) deptName,
+               dispose,
+               count(l.id)              totalNum
+        from lab_warning_notice_log l
+        where DATE_FORMAT(l.create_time, '%Y%m') = DATE_FORMAT(NOW(), '%Y%m')
+        GROUP BY deptName, l.dispose;
+    </select>
 </mapper>