巡检执法、风险、隐患列表改为分页,首页统计修改

main
zhangyu 2023-02-27 13:56:13 +08:00
parent db3073a249
commit deadb74a66
47 changed files with 228 additions and 183 deletions

View File

@ -1,20 +1,16 @@
package com.hbt.safety.supervision.controller;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hbt.common.core.domain.R;
import com.hbt.safety.supervision.pojo.HiddenDanger;
import com.hbt.safety.supervision.service.IHiddenDangerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
import com.hbt.common.core.web.controller.BaseController;
import com.hbt.common.core.web.domain.AjaxResult;
import com.hbt.common.core.web.page.TableDataInfo;
/**
* Controller
@ -31,15 +27,17 @@ public class HiddenDangerController extends BaseController
/**
*
*
* @param currentPage
* @param pageSize
* @return
*/
@ApiOperation("查询隐患列表")
@GetMapping("/list")
public String list()
public R<PageInfo<HiddenDanger>> list(@RequestParam(value = "currentPage") int currentPage, @RequestParam(value = "pageSize") int pageSize)
{
startPage();
List<HiddenDanger> list = hiddenDangerService.selectHiddenDangerList();
TableDataInfo tableDataInfo = getDataTable(list);
return JSONObject.toJSONString(tableDataInfo);
PageInfo<HiddenDanger> pageInfo = hiddenDangerService.selectHiddenDangerList(currentPage, pageSize);
return R.ok(pageInfo);
}
/**

View File

@ -1,20 +1,16 @@
package com.hbt.safety.supervision.controller;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hbt.common.core.domain.R;
import com.hbt.safety.supervision.pojo.LawEnforcementInspection;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
import com.hbt.safety.supervision.service.ILawEnforcementInspectionService;
import com.hbt.common.core.web.controller.BaseController;
import com.hbt.common.core.web.domain.AjaxResult;
import com.hbt.common.core.web.page.TableDataInfo;
/**
* Controller
@ -31,14 +27,17 @@ public class LawEnforcementInspectionController extends BaseController
/**
*
*
* @param currentPage
* @param pageSize
* @return
*/
@ApiOperation("查询执法巡查列表")
@GetMapping("/list")
public String list()
public R<PageInfo<LawEnforcementInspection>> list(@RequestParam(value = "currentPage") int currentPage, @RequestParam(value = "pageSize") int pageSize)
{
List<LawEnforcementInspection> list = lawEnforcementInspectionService.selectLawEnforcementInspectionList();
TableDataInfo tableDataInfo = getDataTable(list);
return JSONObject.toJSONString(tableDataInfo);
PageInfo<LawEnforcementInspection> pageInfo = lawEnforcementInspectionService.selectLawEnforcementInspectionList(currentPage, pageSize);
return R.ok(pageInfo);
}
/**

View File

@ -1,16 +1,13 @@
package com.hbt.safety.supervision.controller;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hbt.common.core.domain.R;
import com.hbt.safety.supervision.pojo.Risk;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
import com.hbt.safety.supervision.service.IRiskService;
import com.hbt.common.core.web.controller.BaseController;
import com.hbt.common.core.web.domain.AjaxResult;
@ -30,13 +27,17 @@ public class RiskController extends BaseController
/**
*
*
* @param currentPage
* @param pageSize
* @return
*/
@ApiOperation("查询风险列表")
@GetMapping("/list")
public String list()
public R<PageInfo<Risk>> list(@RequestParam(value = "currentPage") int currentPage, @RequestParam(value = "pageSize") int pageSize)
{
List<Risk> list = riskService.selectRiskList();
return JSONObject.toJSONString(list);
PageInfo<Risk> pageInfo = riskService.selectRiskList(currentPage, pageSize);
return R.ok(pageInfo);
}
/**

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import com.hbt.safety.supervision.pojo.EnterpriseInformation;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
/**
* Mapper
@ -71,7 +72,7 @@ public interface EnterpriseInformationMapper
*
* @return
*/
List<Map<Object, Object>> enterpriseStatistics();
List<EnterpriseInformation> enterpriseStatistics();
/**
*

View File

@ -9,7 +9,6 @@ import com.hbt.safety.supervision.pojo.HiddenDanger;
* Mapper
*
* @author
* @date 2023-02-14
*/
public interface EscalateHiddenDangerMapper
{

View File

@ -7,7 +7,6 @@ import com.hbt.safety.supervision.pojo.EscalateRisk;
* Mapper
*
* @author
* @date 2023-02-14
*/
public interface EscalateRiskMapper
{

View File

@ -9,7 +9,6 @@ import com.hbt.safety.supervision.pojo.HazardousOperation;
* Mapper
*
* @author zhangyu
* @date 2023-02-14
*/
public interface HazardousOperationMapper
{

View File

@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Param;
* Mapper
*
* @author hbt
* @date 2023-02-14
*/
public interface HiddenDangerMapper
{

View File

@ -10,7 +10,6 @@ import com.hbt.safety.supervision.pojo.vo.LawEnforcementInspectionVo;
* Mapper
*
* @author zhangyu
* @date 2023-02-14
*/
public interface LawEnforcementInspectionMapper
{

View File

@ -8,7 +8,6 @@ import com.hbt.safety.supervision.pojo.MajorHazardSources;
* Mapper
*
* @author zhangyu
* @date 2023-02-14
*/
public interface MajorHazardSourcesMapper
{

View File

@ -8,7 +8,6 @@ import com.hbt.safety.supervision.pojo.Person;
* Mapper
*
* @author
* @date 2023-02-14
*/
public interface PersonMapper {
/**

View File

@ -7,7 +7,6 @@ import com.hbt.safety.supervision.pojo.RiskArea;
* Mapper
*
* @author
* @date 2023-02-14
*/
public interface RiskAreaMapper
{

View File

@ -12,7 +12,6 @@ import org.apache.ibatis.annotations.Param;
* Mapper
*
* @author
* @date 2023-02-14
*/
@Mapper
public interface RiskMapper
@ -69,7 +68,7 @@ public interface RiskMapper
*
* @return
*/
List<Map<Object, Object>> riskStatistics();
List<Risk> riskStatistics();
/**
*

View File

@ -9,7 +9,6 @@ import lombok.Data;
* enterprise_information
*
* @author zhangyu
* @date 2023-02-14
*/
@ApiModel
@Data

View File

@ -8,7 +8,6 @@ import lombok.Data;
* escalate_hidden_danger
*
* @author
* @date 2023-02-14
*/
@Data
public class EscalateHiddenDanger extends BaseEntity

View File

@ -8,7 +8,6 @@ import lombok.Data;
* escalate_risk
*
* @author
* @date 2023-02-14
*/
@Data
public class EscalateRisk extends BaseEntity

View File

@ -9,7 +9,6 @@ import lombok.Data;
* hazardous_operation
*
* @author zhangyu
* @date 2023-02-14
*/
@ApiModel
@Data

View File

@ -9,7 +9,6 @@ import lombok.Data;
* hidden_danger
*
* @author hbt
* @date 2023-02-14
*/
@ApiModel
@Data

View File

@ -9,7 +9,6 @@ import lombok.Data;
* major_hazard_sources
*
* @author zhangyu
* @date 2023-02-14
*/
@ApiModel
@Data

View File

@ -7,7 +7,6 @@ import lombok.Data;
* person
*
* @author
* @date 2023-02-14
*/
@Data
public class Person extends BaseEntity

View File

@ -9,7 +9,6 @@ import lombok.Data;
* risk
*
* @author
* @date 2023-02-14
*/
@ApiModel
@Data

View File

@ -8,7 +8,6 @@ import lombok.Data;
* risk_area
*
* @author
* @date 2023-02-14
*/
@Data
public class RiskArea extends BaseEntity

View File

@ -1,14 +1,21 @@
package com.hbt.safety.supervision.pojo.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* vo
*/
@Data
@NoArgsConstructor
public class StatisticsVo {
private int classify; // 分类
private int count; // 数量
public StatisticsVo(int classify, int count) {
this.classify = classify;
this.count = count;
}
}

View File

@ -8,7 +8,6 @@ import com.hbt.safety.supervision.pojo.EnterpriseInformation;
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
public interface IEnterpriseInformationService
{

View File

@ -9,7 +9,6 @@ import com.hbt.safety.supervision.pojo.HiddenDanger;
* Service
*
* @author
* @date 2023-02-14
*/
public interface IEscalateHiddenDangerService
{

View File

@ -8,7 +8,6 @@ import com.hbt.safety.supervision.pojo.EscalateRisk;
* Service
*
* @author
* @date 2023-02-14
*/
public interface IEscalateRiskService
{

View File

@ -8,7 +8,6 @@ import com.hbt.safety.supervision.pojo.HazardousOperation;
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
public interface IHazardousOperationService
{

View File

@ -1,14 +1,12 @@
package com.hbt.safety.supervision.service;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.pojo.HiddenDanger;
/**
* Service
*
* @author hbt
* @date 2023-02-14
*/
public interface IHiddenDangerService
{
@ -23,9 +21,11 @@ public interface IHiddenDangerService
/**
*
*
* @return
* @param currentPage
* @param pageSize
* @return
*/
List<HiddenDanger> selectHiddenDangerList();
PageInfo<HiddenDanger> selectHiddenDangerList(int currentPage, int pageSize);
/**
*

View File

@ -1,14 +1,13 @@
package com.hbt.safety.supervision.service;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.pojo.LawEnforcementInspection;
/**
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
public interface ILawEnforcementInspectionService
{
@ -23,9 +22,11 @@ public interface ILawEnforcementInspectionService
/**
*
*
* @return
* @param currentPage
* @param pageSize
* @return
*/
List<LawEnforcementInspection> selectLawEnforcementInspectionList();
PageInfo<LawEnforcementInspection> selectLawEnforcementInspectionList(int currentPage, int pageSize);
/**
*

View File

@ -7,7 +7,6 @@ import com.hbt.safety.supervision.pojo.MajorHazardSources;
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
public interface IMajorHazardSourcesService
{

View File

@ -8,7 +8,6 @@ import com.hbt.safety.supervision.pojo.Person;
* Service
*
* @author
* @date 2023-02-14
*/
public interface IPersonService
{

View File

@ -7,7 +7,6 @@ import com.hbt.safety.supervision.pojo.RiskArea;
* Service
*
* @author
* @date 2023-02-14
*/
public interface IRiskAreaService
{

View File

@ -1,14 +1,12 @@
package com.hbt.safety.supervision.service;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.pojo.Risk;
/**
* Service
*
* @author
* @date 2023-02-14
*/
public interface IRiskService
{
@ -23,9 +21,11 @@ public interface IRiskService
/**
*
*
* @return
* @param currentPage
* @param pageSize
* @return
*/
List<Risk> selectRiskList();
PageInfo<Risk> selectRiskList(int currentPage, int pageSize);
/**
*

View File

@ -3,23 +3,30 @@ package com.hbt.safety.supervision.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.hbt.safety.supervision.mapper.EnterpriseInformationMapper;
import com.hbt.safety.supervision.pojo.EnterpriseInformation;
import com.hbt.safety.supervision.pojo.MajorHazardSources;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.service.IEnterpriseInformationService;
import com.hbt.safety.supervision.mapper.PersonMapper;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/**
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
@Service
public class EnterpriseInformationServiceImpl implements IEnterpriseInformationService {
/** 企业分类 */
private static final int ENTERPRISE_CLASSIFY = 3;
@Autowired
private EnterpriseInformationMapper enterpriseInformationMapper;
@ -100,18 +107,28 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
public String enterpriseStatistics() {
Map<String, Object> map = new HashMap<>();
// 企业分类及数量
List<Map<Object, Object>> list = enterpriseInformationMapper.enterpriseStatistics();
// 在管企业数量
int enterpriseCount = enterpriseInformationMapper.getEnterpriseCount();
// 企业员工数
int personCount = personMapper.getPersonCount();
List<EnterpriseInformation> list = enterpriseInformationMapper.enterpriseStatistics();
if (CollectionUtils.isEmpty(list)) {
map.put("enterpriseClassification", StatisticsResultUtil.defaultResultStatistics(ENTERPRISE_CLASSIFY));
map.put("enterpriseCount", 0);
map.put("personCount", 0);
map.put("carCount", 0);
} else {
Map<Integer, Long> enterpriseMap = list.stream()
.collect(Collectors.groupingBy(EnterpriseInformation :: getType, Collectors.counting()));
// 在管企业数量
int enterpriseCount = enterpriseInformationMapper.getEnterpriseCount();
// 企业员工数
int personCount = personMapper.getPersonCount();
// 等级车辆数
int carCount = enterpriseInformationMapper.getCarCount();
map.put("enterpriseClassification", StatisticsResultUtil.resultStatistics(ENTERPRISE_CLASSIFY, enterpriseMap));
map.put("enterpriseCount", enterpriseCount);
map.put("personCount", personCount);
map.put("carCount", carCount);
}
// 等级车辆数
int carCount = enterpriseInformationMapper.getCarCount();
map.put("enterpriseClassification", list);
map.put("enterpriseCount", enterpriseCount);
map.put("personCount", personCount);
map.put("carCount", carCount);
return JSONObject.toJSONString(map);
}
}

View File

@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
* Service
*
* @author
* @date 2023-02-14
*/
@Service
public class EscalateHiddenDangerServiceImpl implements IEscalateHiddenDangerService

View File

@ -12,7 +12,6 @@ import com.hbt.safety.supervision.service.IEscalateRiskService;
* Service
*
* @author
* @date 2023-02-14
*/
@Service
public class EscalateRiskServiceImpl implements IEscalateRiskService

View File

@ -9,6 +9,7 @@ import com.hbt.safety.supervision.pojo.HazardousOperation;
import com.hbt.safety.supervision.pojo.vo.DateVo;
import com.hbt.safety.supervision.pojo.vo.HazardousOperationWeekDateVo;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import com.hbt.safety.supervision.util.YearWeeksUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -19,11 +20,13 @@ import com.hbt.safety.supervision.service.IHazardousOperationService;
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
@Service
public class HazardousOperationServiceImpl implements IHazardousOperationService
{
/** 危险作业类型 */
private static final int OPRATION_TYPE = 9;
@Autowired
private HazardousOperationMapper hazardousOperationMapper;
@ -113,42 +116,39 @@ public class HazardousOperationServiceImpl implements IHazardousOperationService
// 查询危险作业信息
List<HazardousOperation> list = hazardousOperationMapper.selectHazardousOperations();
if (list == null) {
return "";
map.put("operationTypeList", StatisticsResultUtil.defaultResultStatistics(OPRATION_TYPE));
map.put("underwayHazardousOperation",0);
map.put("underwayEnterprise", 0);
map.put("toBeStarted", 0);
map.put("historyHazardousOperation", 0);
} else {
Map<Integer, Long> typeList = list.stream()
.collect(Collectors.groupingBy(HazardousOperation::getOperationType, Collectors.counting()));
map.put("operationTypeList", StatisticsResultUtil.resultStatistics(OPRATION_TYPE, typeList));
// 进行中的危险作业
List<HazardousOperation> hazardousOperations = list.stream()
.filter(s -> s.getOperationStart().compareTo(dateNowStr) <= 0
&& s.getOperationEnd().compareTo(dateNowStr) >= 0)
.collect(Collectors.toList());
map.put("underwayHazardousOperation", hazardousOperations.size());
// 进行危险作业企业
int underwayEnterprise =hazardousOperations.stream()
.collect(Collectors.groupingBy(HazardousOperation :: getEnterpriseId)).keySet().size();
map.put("underwayEnterprise", underwayEnterprise);
// 待开始危险作业
int toBeStarted = (int) list.stream()
.filter(s -> s.getOperationStart().compareTo(dateNowStr) > 0).count();
map.put("toBeStarted", toBeStarted);
// 历史危险作业
int historyHazardousOperation = (int) list.stream()
.filter(s -> s.getOperationEnd().compareTo(dateNowStr) < 0).count();
map.put("historyHazardousOperation", historyHazardousOperation);
}
Map<Object, List<HazardousOperation>> typeList = list.stream()
.collect(Collectors.groupingBy(HazardousOperation::getOperationType));
// 组装类型统计数据
List<StatisticsVo> operationTypeList = new ArrayList<>();
for(Object key : typeList.keySet()) {
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setClassify(Integer.parseInt(key.toString()));
statisticsVo.setCount(typeList.get(key).size());
operationTypeList.add(statisticsVo);
}
map.put("operationTypeList", JSONObject.toJSONString(operationTypeList));
// 进行中的危险作业
List<HazardousOperation> hazardousOperations = list.stream()
.filter(s -> s.getOperationStart().compareTo(dateNowStr) <= 0 &&s.getOperationEnd().compareTo(dateNowStr) >= 0)
.collect(Collectors.toList());
map.put("underwayHazardousOperation", hazardousOperations.size());
// 进行危险作业企业
int underwayEnterprise = hazardousOperations.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>
(Comparator.comparing(HazardousOperation :: getEnterpriseId))), ArrayList:: new)).size();
map.put("underwayEnterprise", underwayEnterprise);
// 待开始危险作业
int toBeStarted = (int) list.stream()
.filter(s -> s.getOperationStart().compareTo(dateNowStr) > 0).count();
map.put("toBeStarted", toBeStarted);
// 历史危险作业
int historyHazardousOperation = (int) list.stream()
.filter(s -> s.getOperationEnd().compareTo(dateNowStr) < 0).count();
map.put("historyHazardousOperation", historyHazardousOperation);
return JSONObject.toJSONString(map);
}

View File

@ -5,14 +5,18 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.mapper.HiddenDangerMapper;
import com.hbt.safety.supervision.pojo.HiddenDanger;
import com.hbt.safety.supervision.pojo.vo.DateVo;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.service.IHiddenDangerService;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import com.hbt.safety.supervision.util.YearWeeksUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/**
* Service
@ -22,6 +26,8 @@ import org.springframework.stereotype.Service;
@Service
public class HiddenDangerServiceImpl implements IHiddenDangerService
{
/** 隐患治理状态 */
private static final int HIDDENDANGER_STATUS = 4;
@Autowired
private HiddenDangerMapper hiddenDangerMapper;
@ -40,12 +46,16 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
/**
*
*
* @return
* @param currentPage
* @param pageSize
* @return
*/
@Override
public List<HiddenDanger> selectHiddenDangerList()
public PageInfo<HiddenDanger> selectHiddenDangerList(int currentPage, int pageSize)
{
return hiddenDangerMapper.selectHiddenDangerList();
PageHelper.startPage(currentPage, pageSize);
List<HiddenDanger> list = hiddenDangerMapper.selectHiddenDangerList();
return new PageInfo<>(list);
}
/**
@ -103,20 +113,13 @@ public class HiddenDangerServiceImpl implements IHiddenDangerService
Map<String, Object> map = new HashMap<>();
List<HiddenDanger> list = hiddenDangerMapper.selectHiddenDangers();
if (list == null) {
return "";
if (CollectionUtils.isEmpty(list)) {
map.put("hiddenDangerList", StatisticsResultUtil.defaultResultStatistics(HIDDENDANGER_STATUS));
return JSONObject.toJSONString(map);
}
Map<Object, List<HiddenDanger>> hiddenDangerMap = list.stream()
.collect(Collectors.groupingBy(HiddenDanger::getReformStatus));
// 组装隐患状态统计数据
List<StatisticsVo> hiddenDangerList = new ArrayList<>();
for(Object key : hiddenDangerMap.keySet()) {
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setClassify(Integer.parseInt(key.toString()));
statisticsVo.setCount(hiddenDangerMap.get(key).size());
hiddenDangerList.add(statisticsVo);
}
map.put("hiddenDangerList", JSONObject.toJSONString(hiddenDangerList));
Map<Integer, Long> hiddenDangerMap = list.stream()
.collect(Collectors.groupingBy(HiddenDanger::getReformStatus, Collectors.counting()));
map.put("hiddenDangerList", StatisticsResultUtil.resultStatistics(HIDDENDANGER_STATUS, hiddenDangerMap));
return JSONObject.toJSONString(map);
}

View File

@ -4,6 +4,8 @@ import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.mapper.EscalateHiddenDangerMapper;
import com.hbt.safety.supervision.mapper.EscalateRiskMapper;
import com.hbt.safety.supervision.mapper.LawEnforcementInspectionMapper;
@ -19,7 +21,6 @@ import com.hbt.safety.supervision.service.ILawEnforcementInspectionService;
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
@Service
public class LawEnforcementInspectionServiceImpl implements ILawEnforcementInspectionService
@ -48,12 +49,16 @@ public class LawEnforcementInspectionServiceImpl implements ILawEnforcementInspe
/**
*
*
* @return
* @param currentPage
* @param pageSize
* @return
*/
@Override
public List<LawEnforcementInspection> selectLawEnforcementInspectionList()
public PageInfo<LawEnforcementInspection> selectLawEnforcementInspectionList(int currentPage, int pageSize)
{
return lawEnforcementInspectionMapper.selectLawEnforcementInspectionList();
PageHelper.startPage(currentPage, pageSize);
List<LawEnforcementInspection> list = lawEnforcementInspectionMapper.selectLawEnforcementInspectionList();
return new PageInfo<>(list);
}
/**

View File

@ -9,19 +9,22 @@ import com.alibaba.fastjson.JSONObject;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.service.IMajorHazardSourcesService;
import com.hbt.safety.supervision.pojo.MajorHazardSources;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hbt.safety.supervision.mapper.MajorHazardSourcesMapper;
import org.springframework.util.CollectionUtils;
/**
* Service
*
* @author zhangyu
* @date 2023-02-14
*/
@Service
public class MajorHazardSourcesServiceImpl implements IMajorHazardSourcesService
{
private static final int DANGER_LEVEL = 4;
@Autowired
private MajorHazardSourcesMapper majorHazardSourcesMapper;
@ -104,34 +107,27 @@ public class MajorHazardSourcesServiceImpl implements IMajorHazardSourcesService
// 查询重大危险源信息
List<MajorHazardSources> list = majorHazardSourcesMapper.majorHazardSourcesStatistics();
if (list == null) {
return "";
if (CollectionUtils.isEmpty(list)) {
// 返回默认值
map.put("dangerLevelList", StatisticsResultUtil.defaultResultStatistics(DANGER_LEVEL));
map.put("productionUnit", 0);
map.put("storageCell", 0);
} else {
// 根据风险等级分组
Map<Integer, Long> typeList = list.stream()
.collect(Collectors.groupingBy(MajorHazardSources::getDangerLevel, Collectors.counting()));
map.put("dangerLevelList", StatisticsResultUtil.resultStatistics(DANGER_LEVEL, typeList));
// 获取生产单元数量
int productionUnit = (int) list.stream()
.filter(s -> s.getUnitType() == 0).count();
map.put("productionUnit", productionUnit);
// 获取存储单元数量
int storageCell = (int) list.stream()
.filter(s -> s.getUnitType() == 0).count();
map.put("storageCell", storageCell);
}
// 根据风险等级分组
Map<Object, List<MajorHazardSources>> typeList = list.stream()
.collect(Collectors.groupingBy(MajorHazardSources::getDangerLevel));
// 组装风险等级统计数据
List<StatisticsVo> dangerLevelList = new ArrayList<>();
for(Object key : typeList.keySet()) {
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setClassify(Integer.parseInt(key.toString()));
statisticsVo.setCount(typeList.get(key).size());
dangerLevelList.add(statisticsVo);
}
map.put("dangerLevelList", JSONObject.toJSONString(dangerLevelList));
// 获取生产单元数量
int productionUnit = (int) list.stream()
.filter(s -> s.getUnitType() == 0).count();
map.put("productionUnit", productionUnit);
// 获取存储单元数量
int storageCell = (int) list.stream()
.filter(s -> s.getUnitType() == 0).count();
map.put("storageCell", storageCell);
return JSONObject.toJSONString(map);
}
}

View File

@ -12,7 +12,6 @@ import com.hbt.safety.supervision.service.IPersonService;
* Service
*
* @author
* @date 2023-02-14
*/
@Service
public class PersonServiceImpl implements IPersonService

View File

@ -12,7 +12,6 @@ import org.springframework.stereotype.Service;
* Service
*
* @author
* @date 2023-02-14
*/
@Service
public class RiskAreaServiceImpl implements IRiskAreaService

View File

@ -4,23 +4,28 @@ import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.mapper.RiskMapper;
import com.hbt.safety.supervision.pojo.Risk;
import com.hbt.safety.supervision.pojo.vo.DateVo;
import com.hbt.safety.supervision.service.IRiskService;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import com.hbt.safety.supervision.util.YearWeeksUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/**
* Service
*
* @author
* @date 2023-02-14
*/
@Service
public class RiskServiceImpl implements IRiskService
{
/** 风险等级 */
private static final int RISK_LEVEL = 4;
@Autowired
private RiskMapper riskMapper;
@ -37,14 +42,18 @@ public class RiskServiceImpl implements IRiskService
}
/**
*
*
*
* @return
* @param currentPage
* @param pageSize
* @return
*/
@Override
public List<Risk> selectRiskList()
public PageInfo<Risk> selectRiskList(int currentPage, int pageSize)
{
return riskMapper.selectRiskList();
PageHelper.startPage(currentPage, pageSize);
List<Risk> list = riskMapper.selectRiskList();
return new PageInfo<>(list);
}
/**
@ -96,8 +105,13 @@ public class RiskServiceImpl implements IRiskService
}
public String riskStatistics() {
List<Map<Object, Object>> map = riskMapper.riskStatistics();
return JSONObject.toJSONString(map);
List<Risk> list = riskMapper.riskStatistics();
if (CollectionUtils.isEmpty(list)) {
return StatisticsResultUtil.defaultResultStatistics(RISK_LEVEL);
}
Map<Integer, Long> typeList = list.stream()
.collect(Collectors.groupingBy(Risk :: getLevel, Collectors.counting()));
return StatisticsResultUtil.resultStatistics(RISK_LEVEL, typeList);
}
/**

View File

@ -0,0 +1,32 @@
package com.hbt.safety.supervision.util;
import com.alibaba.fastjson2.JSONObject;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class StatisticsResultUtil {
public static String defaultResultStatistics(int count) {
List<StatisticsVo> list = new ArrayList<>();
for (int i = 1; i <= count; i++) {
StatisticsVo statisticsVo = new StatisticsVo(i, 0);
list.add(statisticsVo);
}
return JSONObject.toJSONString(list);
}
public static String resultStatistics(int count, Map<Integer, Long> map) {
List<StatisticsVo> list = new ArrayList<>();
// 组装数据数据
for (int i =1; i <= count; i ++) {
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setClassify(i);
statisticsVo.setCount(map.getOrDefault(i, 0L).intValue());
list.add(statisticsVo);
}
return JSONObject.toJSONString(list);
}
}

View File

@ -101,8 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select from enterprise_information
</select>
<select id="enterpriseStatistics" resultType="java.util.Map">
select type as classify, count(id) as count from enterprise_information group by type
<select id="enterpriseStatistics" resultType="EnterpriseInformation">
select type from enterprise_information
</select>
<select id="getEnterpriseCount" resultType="Integer">

View File

@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectLawEnforcementInspectionVo">
select distinct(a.id) id, a.inspection_date, a.inspection_date, a.person person, a.name name,
select distinct(a.id) id, a.inspection_date inspectionDate, a.person person, a.name name,
b.hidden_danger_id hiddenDangerId,
c.risk_id riskId
from law_enforcement_inspection as a

View File

@ -103,8 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="riskStatistics" resultType="java.util.Map">
select level as level, count(id) as num from risk group by level
<select id="riskStatistics" resultType="Risk">
select level from risk
</select>
<select id="selectRisks" resultType="com.hbt.safety.supervision.pojo.Risk">