大屏代码提交
This commit is contained in:
parent
15c6c37726
commit
b840272936
|
|
@ -0,0 +1,44 @@
|
|||
package com.securitycontrol.screen.controller;
|
||||
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.screen.domain.SjNewHjjcAnalysis;
|
||||
import com.securitycontrol.screen.service.ISjNewHjjcAnalysisService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 环境检测分析 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/environment/analysis")
|
||||
public class SjNewHjjcAnalysisController {
|
||||
|
||||
@Resource
|
||||
private ISjNewHjjcAnalysisService analysisService;
|
||||
|
||||
/**
|
||||
* 查询环境检测数据
|
||||
*
|
||||
* @return 环境检测数据列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult getAnalysisList(@RequestBody SjNewHjjcAnalysis analysis) {
|
||||
|
||||
List<SjNewHjjcAnalysis> list = analysisService.getAnalysisByDateRange(analysis.getProjectId(), analysis.getStartTime(), analysis.getEndTime());
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询环境检测数据预警
|
||||
*
|
||||
* @return 环境检测数据列表
|
||||
*/
|
||||
@GetMapping("/warnlist")
|
||||
public AjaxResult warnlist(@RequestBody SjNewHjjcAnalysis analysis) {
|
||||
|
||||
List<SjNewHjjcAnalysis> list = analysisService.getwarnlist(analysis.getProjectId(), analysis.getStartTime(), analysis.getEndTime());
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,13 +3,12 @@ package com.securitycontrol.screen.controller;
|
|||
import com.securitycontrol.common.core.web.controller.BaseController;
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.common.core.web.page.TableDataInfo;
|
||||
import com.securitycontrol.screen.domain.WorkerAnalysisVO;
|
||||
import com.securitycontrol.screen.domain.WorkerTaskSummaryVO;
|
||||
import com.securitycontrol.screen.domain.WorkerWarnVO;
|
||||
import com.securitycontrol.screen.service.WorkerTaskAnalysisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/worker/analysis")
|
||||
|
|
@ -66,9 +65,21 @@ public class SjNewWorkerAnalysisController extends BaseController {
|
|||
* 电工 30%
|
||||
*/
|
||||
@GetMapping("/delay/workType")
|
||||
public AjaxResult delayDistributionByWorkType(WorkerTaskSummaryVO vo) {
|
||||
public AjaxResult delayDistributionByWorkType( @RequestBody WorkerTaskSummaryVO vo) {
|
||||
return AjaxResult.success(
|
||||
workerTaskAnalysisService.selectDelayDistributionByWorkType(vo)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/yujingdetail")
|
||||
public AjaxResult getWarnDetailByMonth(@RequestBody WorkerWarnVO vo) {
|
||||
return AjaxResult.success(
|
||||
workerTaskAnalysisService.selectWarnDetailByMonth(vo.getStartTime())
|
||||
);
|
||||
}
|
||||
@GetMapping("/gzsummary")
|
||||
public AjaxResult getSummary(@RequestBody WorkerAnalysisVO work) {
|
||||
WorkerAnalysisVO vo = workerTaskAnalysisService.getWorkerAnalysis(work);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.securitycontrol.screen.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 环境检测分析表实体类
|
||||
*/
|
||||
@Data
|
||||
public class SjNewHjjcAnalysis {
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 检测时间(yyyy-MM-dd HH:mm:ss 或 yyyy-MM-dd) */
|
||||
private String jcTime;
|
||||
|
||||
/** 温度 */
|
||||
private String wd;
|
||||
|
||||
/** 湿度 */
|
||||
private String sd;
|
||||
|
||||
/** 风速 */
|
||||
private String speed;
|
||||
|
||||
/** 噪声 */
|
||||
private String noise;
|
||||
|
||||
/** 空气质量 */
|
||||
private String kqzl;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** pm10 */
|
||||
private String pm1Data;
|
||||
|
||||
/** pm2.5 */
|
||||
private String pm2Data;
|
||||
|
||||
/** 创建时间 */
|
||||
private String createTime;
|
||||
|
||||
/** 项目ID */
|
||||
private String projectId;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
private String content;
|
||||
private String txTime;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.securitycontrol.screen.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class WorkerAnalysisVO {
|
||||
private Integer totalPerson; // 任务人员数量
|
||||
private Integer totalTask; // 总任务数量
|
||||
private Double avgTaskPerPerson; // 人均任务数量
|
||||
private Map<String, Integer> taskCountByWorkType; // 工种 -> 任务数量
|
||||
private String projectId;
|
||||
private String month;
|
||||
private String startTime;
|
||||
|
||||
}
|
||||
|
|
@ -88,4 +88,6 @@ public class WorkerTaskSummaryVO {
|
|||
/** 延期数量 */
|
||||
private Integer delayCount;
|
||||
|
||||
private String progress;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.securitycontrol.screen.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WorkerWarnVO {
|
||||
|
||||
private Long id;
|
||||
private String txTime; // 提醒时间
|
||||
private String txType; // 预警类型
|
||||
private String content; // 提醒内容
|
||||
private String dataType; // 类型
|
||||
private String remark; // 备注
|
||||
private String createTime; // 创建时间
|
||||
private String measureData; // 处理措施
|
||||
private String filePath; // 文件路径
|
||||
private String startTime; // 文件路径
|
||||
|
||||
/** 查询参数:月份 yyyy-MM */
|
||||
private String month;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.securitycontrol.screen.mapper;
|
||||
|
||||
import com.securitycontrol.screen.domain.SjNewHjjcAnalysis;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 环境检测分析 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SjNewHjjcAnalysisMapper {
|
||||
|
||||
/**
|
||||
* 根据项目ID和日期区间查询环境检测数据
|
||||
*
|
||||
* @param projectId 项目ID,可为空
|
||||
* @param startTime 开始日期(yyyy-MM-dd)
|
||||
* @param endTime 结束日期(yyyy-MM-dd)
|
||||
* @return 环境检测数据列表
|
||||
*/
|
||||
List<SjNewHjjcAnalysis> selectByDateRange(
|
||||
@Param("projectId") String projectId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
List<SjNewHjjcAnalysis> getwarnlist(String projectId, String startTime, String endTime);
|
||||
}
|
||||
|
|
@ -2,8 +2,12 @@ package com.securitycontrol.screen.mapper;
|
|||
|
||||
import com.securitycontrol.screen.domain.WorkerDelayDTO;
|
||||
import com.securitycontrol.screen.domain.WorkerTaskSummaryVO;
|
||||
import com.securitycontrol.screen.domain.WorkerWarnVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface WorkerTaskAnalysisMapper {
|
||||
/**
|
||||
|
|
@ -25,4 +29,12 @@ public interface WorkerTaskAnalysisMapper {
|
|||
* 月任务延期分布(按工种)
|
||||
*/
|
||||
List<WorkerTaskSummaryVO> selectDelayDistributionByWorkType(WorkerTaskSummaryVO vo);
|
||||
|
||||
List<WorkerWarnVO> selectWarnDetailByMonth(
|
||||
@Param("month") String month
|
||||
);
|
||||
Integer countDistinctUser(@Param("projectId") String projectId, @Param("month") String month);
|
||||
Integer countTotalTask(@Param("projectId") String projectId, @Param("month") String month);
|
||||
|
||||
List<Map<String, Object>> countTaskByWorkType(@Param("projectId") String projectId, @Param("month") String month);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.securitycontrol.screen.service;
|
||||
|
||||
|
||||
import com.securitycontrol.screen.domain.SjNewHjjcAnalysis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 环境检测分析 Service 接口
|
||||
*/
|
||||
public interface ISjNewHjjcAnalysisService {
|
||||
|
||||
/**
|
||||
* 根据项目ID和日期区间查询环境检测数据
|
||||
*
|
||||
* @param projectId 项目ID,可为空
|
||||
* @param startDate 开始日期(yyyy-MM-dd)
|
||||
* @param endDate 结束日期(yyyy-MM-dd)
|
||||
* @return 环境检测数据列表
|
||||
*/
|
||||
List<SjNewHjjcAnalysis> getAnalysisByDateRange(String projectId, String startDate, String endDate);
|
||||
|
||||
List<SjNewHjjcAnalysis> getwarnlist(String projectId, String startTime, String endTime);
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package com.securitycontrol.screen.service;
|
||||
|
||||
import com.securitycontrol.screen.domain.WorkerAnalysisVO;
|
||||
import com.securitycontrol.screen.domain.WorkerDelayDTO;
|
||||
import com.securitycontrol.screen.domain.WorkerTaskSummaryVO;
|
||||
import com.securitycontrol.screen.domain.WorkerWarnVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -31,4 +33,8 @@ public interface WorkerTaskAnalysisService {
|
|||
* 月任务延期分布(按工种)
|
||||
*/
|
||||
List<WorkerTaskSummaryVO> selectDelayDistributionByWorkType(WorkerTaskSummaryVO vo);
|
||||
|
||||
List<WorkerWarnVO> selectWarnDetailByMonth(String month);
|
||||
|
||||
WorkerAnalysisVO getWorkerAnalysis(WorkerAnalysisVO vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.securitycontrol.screen.service.impl;
|
||||
|
||||
import com.securitycontrol.screen.domain.SjNewHjjcAnalysis;
|
||||
import com.securitycontrol.screen.mapper.SjNewHjjcAnalysisMapper;
|
||||
import com.securitycontrol.screen.service.ISjNewHjjcAnalysisService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 环境检测分析 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class SjNewHjjcAnalysisServiceImpl implements ISjNewHjjcAnalysisService {
|
||||
|
||||
@Resource
|
||||
private SjNewHjjcAnalysisMapper analysisMapper;
|
||||
|
||||
/**
|
||||
* 根据项目ID和日期区间查询环境检测数据
|
||||
*/
|
||||
@Override
|
||||
public List<SjNewHjjcAnalysis> getAnalysisByDateRange(String projectId, String startDate, String endDate) {
|
||||
return analysisMapper.selectByDateRange(projectId, startDate, endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SjNewHjjcAnalysis> getwarnlist(String projectId, String startTime, String endTime) {
|
||||
return analysisMapper.getwarnlist(projectId, startTime, endTime);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,17 @@
|
|||
package com.securitycontrol.screen.service.impl;
|
||||
|
||||
import com.securitycontrol.screen.domain.WorkerAnalysisVO;
|
||||
import com.securitycontrol.screen.domain.WorkerDelayDTO;
|
||||
import com.securitycontrol.screen.domain.WorkerTaskSummaryVO;
|
||||
import com.securitycontrol.screen.domain.WorkerWarnVO;
|
||||
import com.securitycontrol.screen.mapper.WorkerTaskAnalysisMapper;
|
||||
import com.securitycontrol.screen.service.WorkerTaskAnalysisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class WorkerTaskAnalysisServiceImpl
|
||||
|
|
@ -34,4 +38,41 @@ public class WorkerTaskAnalysisServiceImpl
|
|||
public List<WorkerTaskSummaryVO> selectDelayDistributionByWorkType(WorkerTaskSummaryVO vo) {
|
||||
return workerTaskAnalysisMapper.selectDelayDistributionByWorkType(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkerWarnVO> selectWarnDetailByMonth(String month) {
|
||||
return workerTaskAnalysisMapper.selectWarnDetailByMonth(month);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkerAnalysisVO getWorkerAnalysis(WorkerAnalysisVO vo) {
|
||||
// 1. 任务人员数量
|
||||
Integer totalPerson = workerTaskAnalysisMapper.countDistinctUser(vo.getProjectId(), vo.getMonth());
|
||||
vo.setTotalPerson(totalPerson != null ? totalPerson : 0);
|
||||
|
||||
// 2. 总任务数量
|
||||
Integer totalTask = workerTaskAnalysisMapper.countTotalTask(vo.getProjectId(), vo.getMonth());
|
||||
vo.setTotalTask(totalTask != null ? totalTask : 0);
|
||||
|
||||
// 3. 人均任务数量
|
||||
if (totalPerson != null && totalPerson > 0) {
|
||||
vo.setAvgTaskPerPerson(totalTask.doubleValue() / totalPerson);
|
||||
} else {
|
||||
vo.setAvgTaskPerPerson(0.0);
|
||||
}
|
||||
|
||||
// 4. 按工种统计任务数量
|
||||
List<Map<String, Object>> taskByWorkType = workerTaskAnalysisMapper.countTaskByWorkType(vo.getProjectId(), vo.getMonth());
|
||||
Map<String, Integer> taskCountByWorkType = new HashMap<>();
|
||||
if (taskByWorkType != null) {
|
||||
for (Map<String, Object> map : taskByWorkType) {
|
||||
String workType = (String) map.get("workType");
|
||||
Number count = (Number) map.get("taskCount");
|
||||
taskCountByWorkType.put(workType != null ? workType : "未知", count != null ? count.intValue() : 0);
|
||||
}
|
||||
}
|
||||
vo.setTaskCountByWorkType(taskCountByWorkType);
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.securitycontrol.screen.mapper.SjNewHjjcAnalysisMapper">
|
||||
<select id="selectByDateRange" resultType="com.securitycontrol.screen.domain.SjNewHjjcAnalysis">
|
||||
SELECT *
|
||||
FROM sj_new_hjjc_analysis
|
||||
WHERE 1=1
|
||||
<!-- 按项目ID过滤 -->
|
||||
<if test="projectId != null and projectId != ''">
|
||||
AND project_id = #{projectId}
|
||||
</if>
|
||||
<!-- 按开始日期过滤 -->
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND jc_time >= #{startTime}
|
||||
</if>
|
||||
<!-- 按结束日期过滤 -->
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND jc_time <= #{endTime}
|
||||
</if>
|
||||
ORDER BY jc_time ASC
|
||||
</select>
|
||||
<select id="getwarnlist" resultType="com.securitycontrol.screen.domain.SjNewHjjcAnalysis">
|
||||
SELECT content, tx_time as txTime
|
||||
FROM sj_new_hjjcfx_warn
|
||||
WHERE 1=1
|
||||
<!-- 按项目ID过滤 -->
|
||||
<if test="projectId != null and projectId != ''">
|
||||
AND project_id = #{projectId}
|
||||
</if>
|
||||
<!-- 按开始日期过滤 -->
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND tx_time >= #{startTime}
|
||||
</if>
|
||||
<!-- 按结束日期过滤 -->
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND tx_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -84,33 +84,87 @@
|
|||
<select id="selectDelayDistributionByWorkType" resultType="com.securitycontrol.screen.domain.WorkerTaskSummaryVO">
|
||||
SELECT
|
||||
p.work_type AS workType,
|
||||
COUNT(1) AS delayCount,
|
||||
ROUND(
|
||||
COUNT(1) / (
|
||||
SELECT COUNT(1)
|
||||
COUNT(*) AS delayCount,
|
||||
ROUND(COUNT(*) * 100.0 / (
|
||||
SELECT COUNT(*)
|
||||
FROM sj_new_worker_analysic
|
||||
WHERE project_id = #{projectId}
|
||||
AND task_status = '4'
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND STR_TO_DATE(plan_end_time, '%Y-%m-%d') >= STR_TO_DATE(#{startTime}, '%Y-%m-%d')
|
||||
AND DATE_FORMAT(plan_end_time, '%Y-%m') = #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND STR_TO_DATE(plan_end_time, '%Y-%m-%d') <STR_TO_DATE(#{endTime}, '%Y-%m-%d')
|
||||
</if>
|
||||
) * 100, 2
|
||||
) AS progress
|
||||
), 2) AS progress
|
||||
FROM sj_new_worker_analysic a
|
||||
LEFT JOIN sj_team_people p
|
||||
ON CAST(a.user_name AS UNSIGNED) = p.id
|
||||
LEFT JOIN sj_team_people p ON a.user_name = p.id
|
||||
WHERE a.project_id = #{projectId}
|
||||
AND a.task_status = '4'
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND STR_TO_DATE(a.plan_end_time, '%Y-%m-%d') >= STR_TO_DATE(#{startTime}, '%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND STR_TO_DATE(a.plan_end_time, '%Y-%m-%d') <= STR_TO_DATE(#{endTime}, '%Y-%m-%d')
|
||||
AND DATE_FORMAT(a.plan_end_time, '%Y-%m') = #{startTime}
|
||||
</if>
|
||||
GROUP BY p.work_type
|
||||
ORDER BY delayCount DESC
|
||||
</select>
|
||||
<select id="selectWarnDetailByMonth"
|
||||
resultType="com.securitycontrol.screen.domain.WorkerWarnVO">
|
||||
SELECT
|
||||
id,
|
||||
tx_time,
|
||||
tx_type,
|
||||
content,
|
||||
data_type,
|
||||
remark,
|
||||
create_time,
|
||||
measure_data,
|
||||
file_path
|
||||
FROM sj_new_worker_warn
|
||||
<where>
|
||||
<if test="month != null and month != ''">
|
||||
AND create_time LIKE CONCAT(#{month}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
<!-- 按月份和项目ID统计不同人员数量 -->
|
||||
<select id="countDistinctUser" resultType="java.lang.Integer">
|
||||
SELECT COUNT(DISTINCT user_name)
|
||||
FROM sj_new_worker_analysic
|
||||
WHERE 1=1
|
||||
<if test="projectId != null and projectId != ''">
|
||||
AND project_id = #{projectId}
|
||||
</if>
|
||||
<if test="month != null and month != ''">
|
||||
AND DATE_FORMAT(plan_start_time, '%Y-%m') = #{month}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 按月份和项目ID统计总任务数量 -->
|
||||
<select id="countTotalTask" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM sj_new_worker_analysic
|
||||
WHERE 1=1
|
||||
<if test="projectId != null and projectId != ''">
|
||||
AND project_id = #{projectId}
|
||||
</if>
|
||||
<if test="month != null and month != ''">
|
||||
AND DATE_FORMAT(plan_start_time, '%Y-%m') = #{month}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 按工种统计任务数量 -->
|
||||
<select id="countTaskByWorkType" resultType="map">
|
||||
SELECT
|
||||
COALESCE(p.work_type, '未知') AS workType,
|
||||
COUNT(a.id) AS taskCount
|
||||
FROM sj_new_worker_analysic a
|
||||
LEFT JOIN sj_team_people p ON a.user_name = p.id
|
||||
WHERE 1=1
|
||||
<if test="projectId != null and projectId != ''">
|
||||
AND a.project_id = #{projectId}
|
||||
</if>
|
||||
<if test="month != null and month != ''">
|
||||
AND DATE_FORMAT(a.plan_start_time, '%Y-%m') = #{month}
|
||||
</if>
|
||||
GROUP BY p.work_type
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue