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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,21 @@
package com.hbt.safety.supervision.pojo.vo; package com.hbt.safety.supervision.pojo.vo;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* vo * vo
*/ */
@Data @Data
@NoArgsConstructor
public class StatisticsVo { public class StatisticsVo {
private int classify; // 分类 private int classify; // 分类
private int count; // 数量 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 * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
public interface IEnterpriseInformationService public interface IEnterpriseInformationService
{ {

View File

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

View File

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

View File

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

View File

@ -1,14 +1,12 @@
package com.hbt.safety.supervision.service; package com.hbt.safety.supervision.service;
import java.util.List; import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.pojo.HiddenDanger; import com.hbt.safety.supervision.pojo.HiddenDanger;
/** /**
* Service * Service
* *
* @author hbt * @author hbt
* @date 2023-02-14
*/ */
public interface IHiddenDangerService 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; package com.hbt.safety.supervision.service;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.pojo.LawEnforcementInspection; import com.hbt.safety.supervision.pojo.LawEnforcementInspection;
/** /**
* Service * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
public interface ILawEnforcementInspectionService 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 * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
public interface IMajorHazardSourcesService public interface IMajorHazardSourcesService
{ {

View File

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

View File

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

View File

@ -1,14 +1,12 @@
package com.hbt.safety.supervision.service; package com.hbt.safety.supervision.service;
import java.util.List; import com.github.pagehelper.PageInfo;
import com.hbt.safety.supervision.pojo.Risk; import com.hbt.safety.supervision.pojo.Risk;
/** /**
* Service * Service
* *
* @author * @author
* @date 2023-02-14
*/ */
public interface IRiskService 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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hbt.safety.supervision.mapper.EnterpriseInformationMapper; import com.hbt.safety.supervision.mapper.EnterpriseInformationMapper;
import com.hbt.safety.supervision.pojo.EnterpriseInformation; 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.service.IEnterpriseInformationService;
import com.hbt.safety.supervision.mapper.PersonMapper; import com.hbt.safety.supervision.mapper.PersonMapper;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/** /**
* Service * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
@Service @Service
public class EnterpriseInformationServiceImpl implements IEnterpriseInformationService { public class EnterpriseInformationServiceImpl implements IEnterpriseInformationService {
/** 企业分类 */
private static final int ENTERPRISE_CLASSIFY = 3;
@Autowired @Autowired
private EnterpriseInformationMapper enterpriseInformationMapper; private EnterpriseInformationMapper enterpriseInformationMapper;
@ -100,18 +107,28 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
public String enterpriseStatistics() { public String enterpriseStatistics() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 企业分类及数量 // 企业分类及数量
List<Map<Object, Object>> list = enterpriseInformationMapper.enterpriseStatistics(); List<EnterpriseInformation> list = enterpriseInformationMapper.enterpriseStatistics();
// 在管企业数量 if (CollectionUtils.isEmpty(list)) {
int enterpriseCount = enterpriseInformationMapper.getEnterpriseCount(); map.put("enterpriseClassification", StatisticsResultUtil.defaultResultStatistics(ENTERPRISE_CLASSIFY));
// 企业员工数 map.put("enterpriseCount", 0);
int personCount = personMapper.getPersonCount(); 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); return JSONObject.toJSONString(map);
} }
} }

View File

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

View File

@ -12,7 +12,6 @@ import com.hbt.safety.supervision.service.IEscalateRiskService;
* Service * Service
* *
* @author * @author
* @date 2023-02-14
*/ */
@Service @Service
public class EscalateRiskServiceImpl implements IEscalateRiskService 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.DateVo;
import com.hbt.safety.supervision.pojo.vo.HazardousOperationWeekDateVo; import com.hbt.safety.supervision.pojo.vo.HazardousOperationWeekDateVo;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo; import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import com.hbt.safety.supervision.util.YearWeeksUtil; import com.hbt.safety.supervision.util.YearWeeksUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,11 +20,13 @@ import com.hbt.safety.supervision.service.IHazardousOperationService;
* Service * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
@Service @Service
public class HazardousOperationServiceImpl implements IHazardousOperationService public class HazardousOperationServiceImpl implements IHazardousOperationService
{ {
/** 危险作业类型 */
private static final int OPRATION_TYPE = 9;
@Autowired @Autowired
private HazardousOperationMapper hazardousOperationMapper; private HazardousOperationMapper hazardousOperationMapper;
@ -113,42 +116,39 @@ public class HazardousOperationServiceImpl implements IHazardousOperationService
// 查询危险作业信息 // 查询危险作业信息
List<HazardousOperation> list = hazardousOperationMapper.selectHazardousOperations(); List<HazardousOperation> list = hazardousOperationMapper.selectHazardousOperations();
if (list == null) { 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); return JSONObject.toJSONString(map);
} }

View File

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

View File

@ -4,6 +4,8 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; 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.EscalateHiddenDangerMapper;
import com.hbt.safety.supervision.mapper.EscalateRiskMapper; import com.hbt.safety.supervision.mapper.EscalateRiskMapper;
import com.hbt.safety.supervision.mapper.LawEnforcementInspectionMapper; import com.hbt.safety.supervision.mapper.LawEnforcementInspectionMapper;
@ -19,7 +21,6 @@ import com.hbt.safety.supervision.service.ILawEnforcementInspectionService;
* Service * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
@Service @Service
public class LawEnforcementInspectionServiceImpl implements ILawEnforcementInspectionService public class LawEnforcementInspectionServiceImpl implements ILawEnforcementInspectionService
@ -48,12 +49,16 @@ public class LawEnforcementInspectionServiceImpl implements ILawEnforcementInspe
/** /**
* *
* *
* @return * @param currentPage
* @param pageSize
* @return
*/ */
@Override @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.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.service.IMajorHazardSourcesService; import com.hbt.safety.supervision.service.IMajorHazardSourcesService;
import com.hbt.safety.supervision.pojo.MajorHazardSources; import com.hbt.safety.supervision.pojo.MajorHazardSources;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hbt.safety.supervision.mapper.MajorHazardSourcesMapper; import com.hbt.safety.supervision.mapper.MajorHazardSourcesMapper;
import org.springframework.util.CollectionUtils;
/** /**
* Service * Service
* *
* @author zhangyu * @author zhangyu
* @date 2023-02-14
*/ */
@Service @Service
public class MajorHazardSourcesServiceImpl implements IMajorHazardSourcesService public class MajorHazardSourcesServiceImpl implements IMajorHazardSourcesService
{ {
private static final int DANGER_LEVEL = 4;
@Autowired @Autowired
private MajorHazardSourcesMapper majorHazardSourcesMapper; private MajorHazardSourcesMapper majorHazardSourcesMapper;
@ -104,34 +107,27 @@ public class MajorHazardSourcesServiceImpl implements IMajorHazardSourcesService
// 查询重大危险源信息 // 查询重大危险源信息
List<MajorHazardSources> list = majorHazardSourcesMapper.majorHazardSourcesStatistics(); List<MajorHazardSources> list = majorHazardSourcesMapper.majorHazardSourcesStatistics();
if (list == null) { if (CollectionUtils.isEmpty(list)) {
return ""; // 返回默认值
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); return JSONObject.toJSONString(map);
} }
} }

View File

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

View File

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

View File

@ -4,23 +4,28 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; 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.mapper.RiskMapper;
import com.hbt.safety.supervision.pojo.Risk; import com.hbt.safety.supervision.pojo.Risk;
import com.hbt.safety.supervision.pojo.vo.DateVo; import com.hbt.safety.supervision.pojo.vo.DateVo;
import com.hbt.safety.supervision.service.IRiskService; import com.hbt.safety.supervision.service.IRiskService;
import com.hbt.safety.supervision.util.StatisticsResultUtil;
import com.hbt.safety.supervision.util.YearWeeksUtil; import com.hbt.safety.supervision.util.YearWeeksUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/** /**
* Service * Service
* *
* @author * @author
* @date 2023-02-14
*/ */
@Service @Service
public class RiskServiceImpl implements IRiskService public class RiskServiceImpl implements IRiskService
{ {
/** 风险等级 */
private static final int RISK_LEVEL = 4;
@Autowired @Autowired
private RiskMapper riskMapper; private RiskMapper riskMapper;
@ -37,14 +42,18 @@ public class RiskServiceImpl implements IRiskService
} }
/** /**
* *
* *
* @return * @param currentPage
* @param pageSize
* @return
*/ */
@Override @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() { public String riskStatistics() {
List<Map<Object, Object>> map = riskMapper.riskStatistics(); List<Risk> list = riskMapper.riskStatistics();
return JSONObject.toJSONString(map); 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 from enterprise_information
</select> </select>
<select id="enterpriseStatistics" resultType="java.util.Map"> <select id="enterpriseStatistics" resultType="EnterpriseInformation">
select type as classify, count(id) as count from enterprise_information group by type select type from enterprise_information
</select> </select>
<select id="getEnterpriseCount" resultType="Integer"> <select id="getEnterpriseCount" resultType="Integer">

View File

@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectLawEnforcementInspectionVo"> <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, b.hidden_danger_id hiddenDangerId,
c.risk_id riskId c.risk_id riskId
from law_enforcement_inspection as a from law_enforcement_inspection as a

View File

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