Merge remote-tracking branch 'origin/pengjdev' into guoshengxiong
This commit is contained in:
commit
b82b21ec9d
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
|
||||
@ -256,4 +257,21 @@ public class HiddenDangerInspectRecordController {
|
||||
public Result<List<EntityMap>> selectEnterpriseScoreList(@RequestBody Map<String, Object> map) {
|
||||
return Result.success(hiddenDangerInspectRecordService.selectEnterpriseScoreList(map));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "按问题检查类型统计问题占比", notes = "按问题检查类型统计问题占比", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/selectHiddenDangerTypeRatio")
|
||||
public Result<List<EntityMap>> selectHiddenDangerTypeRatio(@RequestBody Map<String, Object> map) {
|
||||
return Result.success(hiddenDangerInspectRecordService.selectHiddenDangerTypeRatio(map));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "按问题状态统计问题趋势", notes = "按问题状态统计问题趋势", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "offsetDay", value = "查询天数(不填默认15天)", paramType = "query", dataType = "Integer"),
|
||||
})
|
||||
@PostMapping(value = "/selectHiddenDangerStateTrend")
|
||||
public Result<List<HiddenDangerInspectionStatistics>> selectHiddenDangerStateTrend(@RequestBody Map<String, Object> map) {
|
||||
return Result.success(hiddenDangerInspectRecordService.selectHiddenDangerStateTrend(map));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @Description: 隐患检查记录统计
|
||||
* @author: pengj
|
||||
* @date: 2023-03-23
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("hidden_danger_inspection_statistics")
|
||||
@ApiModel(value = "HiddenDangerInspectionStatistics实体类", description = "HiddenDangerInspectionStatistics")
|
||||
public class HiddenDangerInspectionStatistics implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* 统计时间
|
||||
*/
|
||||
@Excel(name = "统计日期", width = 20, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "统计日期")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 新增隐患
|
||||
*/
|
||||
@Excel(name = "新增隐患", width = 15)
|
||||
@ApiModelProperty(value = "新增隐患")
|
||||
private Integer increaseNum;
|
||||
/**
|
||||
* 消除隐患
|
||||
*/
|
||||
@Excel(name = "消除隐患", width = 15)
|
||||
@ApiModelProperty(value = "消除隐患")
|
||||
private Integer solveNum;
|
||||
/**
|
||||
* 未消除隐患
|
||||
*/
|
||||
@Excel(name = "未消除隐患", width = 15)
|
||||
@ApiModelProperty(value = "未消除隐患")
|
||||
private Integer unResolveNum;
|
||||
|
||||
/**
|
||||
* 项目SN
|
||||
*/
|
||||
@Excel(name = "项目SN", width = 15)
|
||||
@ApiModelProperty(value = "项目SN")
|
||||
private String projectSn;
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.mapper;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
|
||||
@ -59,4 +61,10 @@ public interface HiddenDangerInspectRecordMapper extends BaseMapper<HiddenDanger
|
||||
AllWeekDataHdirVO getAllWeekDataHdir(@Param("projectSn") String projectSn);
|
||||
|
||||
TotalAndWeekHiddenDanger getTotalAndWeekHiddenDanger(String projectSn);
|
||||
|
||||
List<EntityMap> selectHiddenDangerTypeRatio(Map<String, Object> map);
|
||||
|
||||
List<String> getGroupByProjectSn();
|
||||
|
||||
HiddenDangerInspectionStatistics statisticsByStatue(DateTime startTime, DateTime endTime, String projectSn);
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 隐患检查记录统计
|
||||
* @author: pengj
|
||||
* @date: 2023-03-23
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface HiddenDangerInspectionStatisticsMapper extends BaseMapper<HiddenDangerInspectionStatistics> {
|
||||
|
||||
}
|
||||
@ -396,4 +396,22 @@
|
||||
WHERE
|
||||
project_sn = #{projectSn}
|
||||
</select>
|
||||
|
||||
<select id="selectHiddenDangerTypeRatio" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
|
||||
SELECT COUNT(1) num, t.inspect_type_name FROM hidden_danger_inspection_record h
|
||||
LEFT JOIN inspect_type t ON h.inspect_type_id = t.id
|
||||
WHERE h.project_sn = #{projectSn} GROUP BY t.inspect_type_name
|
||||
</select>
|
||||
|
||||
<select id="getGroupByProjectSn" resultType="java.lang.String">
|
||||
SELECT project_sn FROM hidden_danger_inspection_record GROUP BY project_sn
|
||||
</select>
|
||||
|
||||
<select id="statisticsByStatue" resultType="com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics">
|
||||
SELECT
|
||||
IFNULL(sum(if(project_sn = #{projectSn} AND create_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) increaseNum ,
|
||||
IFNULL(sum(if(`status` = 4 AND project_sn = #{projectSn} AND update_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) solveNum,
|
||||
IFNULL(sum(if(`status` != 1 AND `status` != 4 AND project_sn = #{projectSn}, 1, 0)), 0) unResolveNum
|
||||
FROM hidden_danger_inspection_record
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?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.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectionStatisticsMapper">
|
||||
|
||||
</mapper>
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
|
||||
@ -65,4 +66,8 @@ public interface IHiddenDangerInspectRecordService extends IService<HiddenDanger
|
||||
AllWeekDataHdirVO getAllWeekDataHdir(String projectSn);
|
||||
|
||||
TotalAndWeekHiddenDanger getTotalAndWeekHiddenDanger(String projectSn);
|
||||
|
||||
List<EntityMap> selectHiddenDangerTypeRatio(Map<String, Object> map);
|
||||
|
||||
List<HiddenDangerInspectionStatistics> selectHiddenDangerStateTrend(Map<String, Object> map);
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.service;
|
||||
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 隐患检查记录统计
|
||||
* @author: pengj
|
||||
* @date: 2023-03-23
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface IHiddenDangerInspectionStatisticsService extends IService<HiddenDangerInspectionStatistics> {
|
||||
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -12,6 +14,7 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.DangerInspectionAcceptanceTableResult;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerRectifyRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
|
||||
@ -19,6 +22,7 @@ import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.DangerInspectionAcceptanceTableResultMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectRecordMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectionStatisticsMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerRectifyRecordMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
@ -50,6 +54,10 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
|
||||
private HiddenDangerRectifyRecordMapper hiddenDangerRectifyRecordMapper;
|
||||
@Autowired
|
||||
private DangerInspectionAcceptanceTableResultMapper dangerInspectionAcceptanceTableResultMapper;
|
||||
|
||||
@Autowired
|
||||
private HiddenDangerInspectionStatisticsMapper hiddenDangerInspectionStatisticsMapper;
|
||||
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
@Autowired
|
||||
@ -400,6 +408,34 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityMap> selectHiddenDangerTypeRatio(Map<String, Object> map) {
|
||||
Integer total = baseMapper.selectCount(null);
|
||||
List<EntityMap> entityMapList = baseMapper.selectHiddenDangerTypeRatio(map);
|
||||
for (EntityMap entityMap : entityMapList) {
|
||||
Integer num = Integer.parseInt(entityMap.get("num").toString());
|
||||
entityMap.put("total", total);
|
||||
entityMap.put("num", num);
|
||||
entityMap.put("ratio", total == 0 ? 0 : NumberUtil.round(num * 100F / total, 2).floatValue());
|
||||
}
|
||||
return entityMapList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HiddenDangerInspectionStatistics> selectHiddenDangerStateTrend(Map<String, Object> map) {
|
||||
Integer offsetDay = MapUtils.getInteger(map, "offsetDay");
|
||||
if (offsetDay == null || offsetDay <= 1) {
|
||||
offsetDay = -15;
|
||||
} else {
|
||||
offsetDay = -offsetDay;
|
||||
}
|
||||
return hiddenDangerInspectionStatisticsMapper.selectList(Wrappers.<HiddenDangerInspectionStatistics>
|
||||
lambdaQuery().eq(HiddenDangerInspectionStatistics::getProjectSn, MapUtils.getString(map, "projectSn"))
|
||||
.between(HiddenDangerInspectionStatistics::getCreateTime,
|
||||
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), offsetDay)),
|
||||
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1))));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置全部占比
|
||||
*
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zhgd.xmgl.modules.dangerous.service.impl;
|
||||
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectionStatisticsMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectionStatisticsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 隐患检查记录统计
|
||||
* @author: pengj
|
||||
* @date: 2023-03-23
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class HiddenDangerInspectionStatisticsServiceImpl extends ServiceImpl<HiddenDangerInspectionStatisticsMapper, HiddenDangerInspectionStatistics> implements IHiddenDangerInspectionStatisticsService {
|
||||
|
||||
}
|
||||
@ -1,11 +1,19 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.xmgl.config.RundeWSClient;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerRectifyRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectRecordMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectionStatisticsService;
|
||||
import com.zhgd.xmgl.modules.helmet.entity.RundeGroup;
|
||||
import com.zhgd.xmgl.modules.helmet.service.RundeGroupService;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
@ -19,10 +27,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.WebSocketContainer;
|
||||
import java.net.URI;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -45,6 +50,12 @@ public class RundeTask {
|
||||
@Autowired
|
||||
RundeGroupService rundeGroupService;
|
||||
|
||||
@Autowired
|
||||
HiddenDangerInspectRecordMapper hiddenDangerInspectRecordMapper;
|
||||
|
||||
@Autowired
|
||||
IHiddenDangerInspectionStatisticsService hiddenDangerInspectionStatisticsService;
|
||||
|
||||
/**
|
||||
* 获取安全帽最新数量
|
||||
*/
|
||||
@ -98,4 +109,22 @@ public class RundeTask {
|
||||
log.error(String.valueOf(e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按状态统计每天的隐患数量
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void hiddenDangerStatistics() {
|
||||
DateTime startTime = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1));
|
||||
DateTime endTime = DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1));
|
||||
List<String> projectSns = hiddenDangerInspectRecordMapper.getGroupByProjectSn();
|
||||
List<HiddenDangerInspectionStatistics> list = new ArrayList<>();
|
||||
for (String projectSn : projectSns) {
|
||||
HiddenDangerInspectionStatistics statistics = hiddenDangerInspectRecordMapper.statisticsByStatue(startTime, endTime, projectSn);
|
||||
statistics.setProjectSn(projectSn);
|
||||
statistics.setCreateTime(DateUtil.offsetDay(new Date(), -1));
|
||||
list.add(statistics);
|
||||
}
|
||||
hiddenDangerInspectionStatisticsService.saveBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user