diff --git a/src/main/java/com/biutag/supervision/controller/work/AnalysisJudgmentController.java b/src/main/java/com/biutag/supervision/controller/work/AnalysisJudgmentController.java new file mode 100644 index 0000000..982547b --- /dev/null +++ b/src/main/java/com/biutag/supervision/controller/work/AnalysisJudgmentController.java @@ -0,0 +1,60 @@ +package com.biutag.supervision.controller.work; + +import com.biutag.supervision.pojo.Result; +import com.biutag.supervision.service.AnalysisJudgmentService; +import lombok.RequiredArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +@RequiredArgsConstructor +@RequestMapping("analysisJudgment") +@RestController +public class AnalysisJudgmentController { + + private final AnalysisJudgmentService analysisJudgmentService; + + // 警务评议总体情况 + @PostMapping("policeEvaluation/export/excel") + public Result policeEvaluationExport(@RequestParam() Integer departId, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + analysisJudgmentService.policeEvaluationExportExcel(departId, beginTime, endTime); + return Result.success(); + } + + // 六分局排名情况 + @PostMapping("sixBranch/export/excel") + public Result sixBranchExport(@RequestParam() Integer departId, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + analysisJudgmentService.sixBranchExportExcel(departId, beginTime, endTime); + return Result.success(); + } + + // 四县市局排名情况 + @PostMapping("fourBureau/export/excel") + public Result fourBureauExport(@RequestParam() Integer departId, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + analysisJudgmentService.fourBureauExportExcel(departId, beginTime, endTime); + return Result.success(); + } + + // 警务评议项目分析 + // project值:110接处警-12、122接处警-18、案件受害人-13、车辆上户-14、驾驶人考试-11、身份证办理-19、户口办理-20 + // level值:分县市局-2,派出所-10,交警大队-11,驾考考场-17,车管所-18 + @PostMapping("projectAnalysis/export/excel") + public Result projectAnalysis(@RequestParam() Integer project, + @RequestParam() Integer departId, + @RequestParam() Integer level, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, + @RequestParam() @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + analysisJudgmentService.projectAnalysisExportExcel(project, departId, level, beginTime, endTime); + return Result.success(); + } +} diff --git a/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMapper.java b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMapper.java new file mode 100644 index 0000000..e34bcab --- /dev/null +++ b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMapper.java @@ -0,0 +1,8 @@ +package com.biutag.supervision.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.supervision.pojo.entity.DataPoliceMeeting; + +public interface DataPoliceMeetingMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java index d0044ce..91dd2da 100644 --- a/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/DataPoliceMeetingMysqlMapper.java @@ -11,6 +11,9 @@ import com.biutag.supervision.pojo.param.DataMigrationQueryParam; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Date; +import java.util.List; + /** * @author 舒云 * @description 针对表【data_police_meeting】的数据库操作Mapper @@ -21,6 +24,10 @@ import org.apache.ibatis.annotations.Param; public interface DataPoliceMeetingMysqlMapper extends BaseMapper { Page queryPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + List selectPoliceEvaluationList(List departIds, Date beginTime, Date endTime); + + List selectProjectAnalysisList(Integer project, List departIds, Date beginTime, Date endTime); + } diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java index fa039d0..b0a679a 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java @@ -1,6 +1,5 @@ package com.biutag.supervision.mapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.supervision.pojo.entity.Negative; import com.biutag.supervision.pojo.vo.*; @@ -1006,6 +1005,7 @@ public interface NegativeMapper extends BaseMapper { "HAVING csd.dept_pid=#{departId} ") List getSubOneSupervisionMapIcon(Date beginTime, Date endTime, Integer departId); + List selectListBySampleId(@Param("args") List sampleIdList); // endregion diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java index 117c93f..38a571c 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/DataPoliceMeeting.java @@ -4,100 +4,70 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; -import java.io.Serializable; -import java.util.Date; +import java.time.LocalDateTime; -/** - * mysql中negative中data_police_meeting表的实体类 - * @TableName data_police_meeting - */ @TableName(value ="data_police_meeting") @Data -public class DataPoliceMeeting implements Serializable { - /** - * - */ - @TableField(value = "sample_id") +public class DataPoliceMeeting { + + // + @TableField("sample_id") private Integer sampleId; - /** - * - */ - @TableField(value = "name") + // + @TableField("name") private String name; - /** - * - */ - @TableField(value = "visit_name") + // + @TableField("visit_name") private String visitName; - /** - * - */ - @TableField(value = "visit_phone") + // + @TableField("visit_phone") private String visitPhone; - /** - * - */ - @TableField(value = "organize_id") + // + @TableField("organize_id") private String organizeId; - /** - * - */ - @TableField(value = "org_name") + // + @TableField("org_name") private String orgName; - /** - * - */ - @TableField(value = "business_id") + // + @TableField("business_id") private Integer businessId; - /** - * - */ - @TableField(value = "business_name") + // + @TableField("business_name") private String businessName; - /** - * - */ - @TableField(value = "sample_time") - private Date sampleTime; - - /** - * - */ - @TableField(value = "create_time") - private Date createTime; - - /** - * - */ - @TableField(value = "sample_content") + // + @TableField("sample_time") + private LocalDateTime sampleTime; + + // + @TableField("create_time") + private LocalDateTime createTime; + + // + @TableField("sample_content") private String sampleContent; - /** - * - */ - @TableField(value = "visit_time") - private Date visitTime; + // + @TableField("visit_time") + private LocalDateTime visitTime; - /** - * - */ - @TableField(value = "result_name") + // + @TableField("result_name") private String resultName; - /** - * - */ - @TableField(value = "code") + // + @TableField("code") private String code; - @TableField(exist = false) - private static final long serialVersionUID = 1L; + // 涉及单位 + @TableField("involve_depart_id") + private String involveDepartId; + } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/entity/Negative.java b/src/main/java/com/biutag/supervision/pojo/entity/Negative.java index 2b57019..a0dff2c 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/Negative.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/Negative.java @@ -2,15 +2,12 @@ package com.biutag.supervision.pojo.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; -import com.biutag.supervision.pojo.dto.flow.VerifyData; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; @Accessors(chain = true) @Setter @@ -306,4 +303,6 @@ public class Negative { // 剩余办理时间 private Long handleRemainingTime; + @TableField("sample_id") + private Integer sampleId; } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java b/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java index 54e01b7..3c96f7a 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java @@ -80,6 +80,7 @@ public class SupDepart { private Boolean firstHost; // + @TableField("statistics_group_id") private String statisticsGroupId; private String img; diff --git a/src/main/java/com/biutag/supervision/pojo/param/AnalysisJudgmentPoliceEvaluationQueryParam.java b/src/main/java/com/biutag/supervision/pojo/param/AnalysisJudgmentPoliceEvaluationQueryParam.java new file mode 100644 index 0000000..6e28408 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/param/AnalysisJudgmentPoliceEvaluationQueryParam.java @@ -0,0 +1,87 @@ +package com.biutag.supervision.pojo.param; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Setter +@Getter +public class AnalysisJudgmentPoliceEvaluationQueryParam { + + private String originId; + + // 问题发生时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private List happenTime = new ArrayList<>(); + + // 问题发现时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private List discoveryTime = new ArrayList<>(); + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private List crtTime = new ArrayList<>(); + + private String responderKey; + + private String responderValue; + + private String flowKey; + + // 办理状态 + private List processingStatus = new ArrayList<>(); + + private String thingDesc; + + // 问题来源 + private List problemSourcesCode; + + private String businessTypeCode; + + private String checkStatus; + + + private String isRectifyCode; + + // 办结是否超时 + private Boolean timeoutFlag; + + // 办理中是否超时 + private Boolean handleTimeoutFlag; + + private String involveDepartId; + + private String handleDepartId; + + // 是否延期 + private Boolean extensionFlag; + + // 排序 + private String order; + private String orderProp; + + private String specialSupervision; + + private String reportNumber; + + private Integer crtDepartLevel; + + // 涉及人员 + private String blameKey; + + // 涉及人员 + private String blameValue; + + private List handleResultCode = new ArrayList<>(); + + private String caseNumber; + + private String checkStatusDesc; + + private String initialPetition; + + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentFourBureau.java b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentFourBureau.java new file mode 100644 index 0000000..9f31f1a --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentFourBureau.java @@ -0,0 +1,107 @@ +package com.biutag.supervision.pojo.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class AnalysisJudgmentFourBureau { + + @ExcelProperty({"序号"}) + private String id; + + @ExcelProperty({"责任单位"}) + private String businessName; + + @ExcelProperty({"110接处警(20)","满意率"}) + private String satisfactionRate110 = "0%"; + + @ExcelProperty({"110接处警(20)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRate110 = "0%"; + + @ExcelProperty({"110接处警(20)","不满意样本查实率"}) + private String unsatisfiedRealRate110 = "0%"; + + @ExcelProperty({"110接处警(20)","不满意样本整改率"}) + private String unsatisfiedRectificationRate110 = "0%"; + + @ExcelProperty({"案件受害人(25)","满意率"}) + private String satisfactionRateVictim = "0%"; + + @ExcelProperty({"案件受害人(25)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateVictim = "0%"; + + @ExcelProperty({"案件受害人(25)","不满意样本查实率"}) + private String unsatisfiedRealRateVictim = "0%"; + + @ExcelProperty({"案件受害人(25)","不满意样本整改率"}) + private String unsatisfiedRectificationRateVictim = "0%"; + + @ExcelProperty({"122接处警(15)","满意率"}) + private String satisfactionRate122 = "0%"; + + @ExcelProperty({"122接处警(15)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRate122 = "0%"; + + @ExcelProperty({"122接处警(15)","不满意样本查实率"}) + private String unsatisfiedRealRate122 = "0%"; + + @ExcelProperty({"122接处警(15)","不满意样本整改率"}) + private String unsatisfiedRectificationRate122 = "0%"; + + @ExcelProperty({"驾驶人考试(10)","满意率"}) + private String satisfactionRateDrivingTest = "0%"; + + @ExcelProperty({"驾驶人考试(10)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateDrivingTest = "0%"; + + @ExcelProperty({"驾驶人考试(10)","不满意样本查实率"}) + private String unsatisfiedRealRateDrivingTest = "0%"; + + @ExcelProperty({"驾驶人考试(10)","不满意样本整改率"}) + private String unsatisfiedRectificationRateDrivingTest = "0%"; + + @ExcelProperty({"车辆上户(10)","满意率"}) + private String satisfactionRateCarRegistration = "0%"; + + @ExcelProperty({"车辆上户(10)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateCarRegistration = "0%"; + + @ExcelProperty({"车辆上户(10)","不满意样本查实率"}) + private String unsatisfiedRealRateCarRegistration = "0%"; + + @ExcelProperty({"车辆上户(10)","不满意样本整改率"}) + private String unsatisfiedRectificationRateCarRegistration = "0%"; + + @ExcelProperty({"身份证办理(10)","满意率"}) + private String satisfactionRateIdCard = "0%"; + + @ExcelProperty({"身份证办理(10)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateIdCard = "0%"; + + @ExcelProperty({"身份证办理(10)","不满意样本查实率"}) + private String unsatisfiedRealRateIdCard = "0%"; + + @ExcelProperty({"身份证办理(10)","不满意样本整改率"}) + private String unsatisfiedRectificationRateIdCard = "0%"; + + @ExcelProperty({"户口办理(10)","满意率"}) + private String satisfactionRateHuKou = "0%"; + + @ExcelProperty({"户口办理(10)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateHuKou = "0%"; + + @ExcelProperty({"户口办理(10)","不满意样本查实率"}) + private String unsatisfiedRealRateHuKou = "0%"; + + @ExcelProperty({"户口办理(10)","不满意样本整改率"}) + private String unsatisfiedRectificationRateHuKou = "0%"; + + @ExcelProperty({"百分制换算综合得分"}) + private String score; + + @ExcelProperty({"排名"}) + private Integer rank; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentPoliceEvaluation.java b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentPoliceEvaluation.java new file mode 100644 index 0000000..d95206f --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentPoliceEvaluation.java @@ -0,0 +1,50 @@ +package com.biutag.supervision.pojo.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class AnalysisJudgmentPoliceEvaluation { + + @ExcelProperty({"序号"}) + private String id; + + @ExcelProperty({"业务类型"}) + private String businessName; + + @ExcelProperty({"有效回复"}) + private Integer effectiveResponse; + + @ExcelProperty({"满意"}) + private Integer satisfied; + + @ExcelProperty({"基本满意"}) + private Integer basicallySatisfied; + + @ExcelProperty({"不满意"}) + private Integer dissatisfied; + + @ExcelProperty({"满意率"}) + private String satisfactionRate; + + @ExcelProperty({"去年同期满意率"}) + private String lastSatisfactionRate; + + @ExcelProperty({"与去年同期比较"}) + private Integer lastSatisfactionCompare; + + @ExcelProperty({"不满意样本查实数"}) + private Integer unsatisfiedRealNumbers; + + @ExcelProperty({"不满意样本查实率"}) + private String unsatisfiedRealRate; + + @ExcelProperty({"不满意样本整改数"}) + private Integer unsatisfiedRectificationNumbers; + + @ExcelProperty({"不满意样本整改率"}) + private String unsatisfiedRectificationRate; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentProjectAnalysis.java b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentProjectAnalysis.java new file mode 100644 index 0000000..efb5f91 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentProjectAnalysis.java @@ -0,0 +1,50 @@ +package com.biutag.supervision.pojo.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class AnalysisJudgmentProjectAnalysis { + + @ExcelProperty({"序号"}) + private String id; + + @ExcelProperty({"责任单位"}) + private String businessName; + + @ExcelProperty({"有效回复"}) + private Integer effectiveResponse; + + @ExcelProperty({"满意"}) + private Integer satisfied; + + @ExcelProperty({"基本满意"}) + private Integer basicallySatisfied; + + @ExcelProperty({"不满意"}) + private Integer dissatisfied; + + @ExcelProperty({"满意率"}) + private String satisfactionRate; + + @ExcelProperty({"不满意样本处理超时数"}) + private Integer unsatisfiedTimeoutNumbers = 0; + + @ExcelProperty({"不满意样本处理超时率"}) + private String unsatisfiedTimeoutRate = "0%"; + + @ExcelProperty({"不满意样本查实数"}) + private Integer unsatisfiedRealNumbers = 0; + + @ExcelProperty({"不满意样本查实率"}) + private String unsatisfiedRealRate = "0%"; + + @ExcelProperty({"不满意样本整改数"}) + private Integer unsatisfiedRectificationNumbers = 0; + + @ExcelProperty({"不满意样本整改率"}) + private String unsatisfiedRectificationRate = "0%"; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentSixBranch.java b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentSixBranch.java new file mode 100644 index 0000000..54d99b4 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/AnalysisJudgmentSixBranch.java @@ -0,0 +1,71 @@ +package com.biutag.supervision.pojo.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class AnalysisJudgmentSixBranch { + + @ExcelProperty({"序号"}) + private String id; + + @ExcelProperty({"责任单位"}) + private String businessName; + + @ExcelProperty({"110接处警(20)","满意率"}) + private String satisfactionRate110 = "0%"; + + @ExcelProperty({"110接处警(20)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRate110 = "0%"; + + @ExcelProperty({"110接处警(20)","不满意样本查实率"}) + private String unsatisfiedRealRate110 = "0%"; + + @ExcelProperty({"110接处警(20)","不满意样本整改率"}) + private String unsatisfiedRectificationRate110 = "0%"; + + @ExcelProperty({"案件受害人(25)","满意率"}) + private String satisfactionRateVictim = "0%"; + + @ExcelProperty({"案件受害人(25)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateVictim = "0%"; + + @ExcelProperty({"案件受害人(25)","不满意样本查实率"}) + private String unsatisfiedRealRateVictim = "0%"; + + @ExcelProperty({"案件受害人(25)","不满意样本整改率"}) + private String unsatisfiedRectificationRateVictim = "0%"; + + @ExcelProperty({"身份证办理(10)","满意率"}) + private String satisfactionRateIdCard = "0%"; + + @ExcelProperty({"身份证办理(10)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateIdCard = "0%"; + + @ExcelProperty({"身份证办理(10)","不满意样本查实率"}) + private String unsatisfiedRealRateIdCard = "0%"; + + @ExcelProperty({"身份证办理(10)","不满意样本整改率"}) + private String unsatisfiedRectificationRateIdCard = "0%"; + + @ExcelProperty({"户口办理(10)","满意率"}) + private String satisfactionRateHuKou = "0%"; + + @ExcelProperty({"户口办理(10)","不满意样本处理及时率"}) + private String unsatisfiedTimelinessRateHuKou = "0%"; + + @ExcelProperty({"户口办理(10)","不满意样本查实率"}) + private String unsatisfiedRealRateHuKou = "0%"; + + @ExcelProperty({"户口办理(10)","不满意样本整改率"}) + private String unsatisfiedRectificationRateHuKou = "0%"; + + @ExcelProperty({"百分制换算综合得分"}) + private String score; + + @ExcelProperty({"排名"}) + private Integer rank; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/DepartTree.java b/src/main/java/com/biutag/supervision/pojo/vo/DepartTree.java index a9bdcac..cb45544 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/DepartTree.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/DepartTree.java @@ -40,4 +40,6 @@ public class DepartTree { private Boolean firstHost; + private String statisticsGroupId; + } diff --git a/src/main/java/com/biutag/supervision/service/AnalysisJudgmentService.java b/src/main/java/com/biutag/supervision/service/AnalysisJudgmentService.java new file mode 100644 index 0000000..8fe48d3 --- /dev/null +++ b/src/main/java/com/biutag/supervision/service/AnalysisJudgmentService.java @@ -0,0 +1,450 @@ +package com.biutag.supervision.service; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.biutag.supervision.mapper.DataPoliceMeetingMysqlMapper; +import com.biutag.supervision.mapper.NegativeMapper; +import com.biutag.supervision.pojo.entity.DataPoliceMeeting; +import com.biutag.supervision.pojo.entity.Negative; +import com.biutag.supervision.pojo.vo.*; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.*; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class AnalysisJudgmentService { + + private final FileService fileService; + + private final DataPoliceMeetingMysqlMapper dataPoliceMeetingMysqlMapper; + + private final NegativeMapper negativeMapper; + + private final SupDepartService departService; + + @Async + public void policeEvaluationExportExcel(Integer departId, Date beginTime, Date endTime) { + List departIds = departService.getAllNodeIds(String.valueOf(departId)); + + // 计算去年的开始时间和结束时间 + LocalDate beginLocalDate = beginTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate endLocalDate = endTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate lastYearBeginLocalDate = beginLocalDate.minusYears(1); + LocalDate lastYearEndLocalDate = endLocalDate.minusYears(1); + + Date lastYearBeginTime = Date.from(lastYearBeginLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); + Date lastYearEndTime = Date.from(lastYearEndLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); + + List dataPoliceMeetingList = dataPoliceMeetingMysqlMapper.selectPoliceEvaluationList(departIds, beginTime, endTime); + if (dataPoliceMeetingList.isEmpty()) { + return; + } + List lastDataPoliceMeetingList = dataPoliceMeetingMysqlMapper.selectPoliceEvaluationList(departIds, lastYearBeginTime, lastYearEndTime); + + List sampleIdList = dataPoliceMeetingList.stream().map(DataPoliceMeeting::getSampleId).toList(); + List negativeList = negativeMapper.selectListBySampleId(sampleIdList); + List data = new ArrayList<>(); + List businessNameCollect = dataPoliceMeetingList.stream().map(DataPoliceMeeting::getBusinessName).distinct().toList(); + int i = 1; + for (String businessName : businessNameCollect) { + AnalysisJudgmentPoliceEvaluation analysisJudgmentPoliceEvaluation = new AnalysisJudgmentPoliceEvaluation(); + analysisJudgmentPoliceEvaluation.setId(String.valueOf(i++)); + analysisJudgmentPoliceEvaluation.setBusinessName(businessName); + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessName().equals(businessName)).toList(); + analysisJudgmentPoliceEvaluation.setEffectiveResponse(filterList.size()); + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + analysisJudgmentPoliceEvaluation.setSatisfied((int) dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessName().equals(businessName) && dataPoliceMeeting.getResultName().equals("满意")).count()); + analysisJudgmentPoliceEvaluation.setBasicallySatisfied((int) dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessName().equals(businessName) && dataPoliceMeeting.getResultName().equals("基本满意")).count()); + analysisJudgmentPoliceEvaluation.setDissatisfied((int) dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessName().equals(businessName) && dataPoliceMeeting.getResultName().equals("不满意")).count()); + analysisJudgmentPoliceEvaluation.setSatisfactionRate(String.format("%.1f%%", (analysisJudgmentPoliceEvaluation.getSatisfied() + analysisJudgmentPoliceEvaluation.getBasicallySatisfied()) / (double) analysisJudgmentPoliceEvaluation.getEffectiveResponse() * 100)); + int lastCount = (int) lastDataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessName().equals(businessName)).count(); + if (lastCount == 0) { + analysisJudgmentPoliceEvaluation.setLastSatisfactionRate("0"); + } else { + analysisJudgmentPoliceEvaluation.setLastSatisfactionRate(String.format("%.1f%%", (lastDataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessName().equals(businessName) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double)lastCount * 100))); + } + analysisJudgmentPoliceEvaluation.setLastSatisfactionCompare(analysisJudgmentPoliceEvaluation.getEffectiveResponse() - lastCount); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + if (negativeFilterList.isEmpty()) { + analysisJudgmentPoliceEvaluation.setUnsatisfiedRealNumbers(0); + analysisJudgmentPoliceEvaluation.setUnsatisfiedRealRate("0%"); + analysisJudgmentPoliceEvaluation.setUnsatisfiedRectificationNumbers(0); + analysisJudgmentPoliceEvaluation.setUnsatisfiedRectificationRate("0%"); + } else { + analysisJudgmentPoliceEvaluation.setUnsatisfiedRealNumbers((int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count()); + analysisJudgmentPoliceEvaluation.setUnsatisfiedRealRate(String.format("%.1f%%", analysisJudgmentPoliceEvaluation.getUnsatisfiedRealNumbers() / (double) negativeFilterList.size() * 100)); + analysisJudgmentPoliceEvaluation.setUnsatisfiedRectificationNumbers((int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count()); + analysisJudgmentPoliceEvaluation.setUnsatisfiedRectificationRate(String.format("%.1f%%", analysisJudgmentPoliceEvaluation.getUnsatisfiedRectificationNumbers() / (double) negativeFilterList.size() * 100)); + } + data.add(analysisJudgmentPoliceEvaluation); + } + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ExcelWriter excelWriter = EasyExcel.write(os).build(); + WriteSheet sheet1 = EasyExcel.writerSheet(0, "警务评议总体情况") + .head(AnalysisJudgmentPoliceEvaluation.class).build(); + excelWriter.write(data, sheet1); + excelWriter.finish(); + String filePath = fileService.upload(new ByteArrayInputStream(os.toByteArray()), os.size(), ".xlsx"); + System.out.println(filePath); + } + + @Async + public void sixBranchExportExcel(Integer departId, Date beginTime, Date endTime) { + List departIds = departService.getAllNodeIds(String.valueOf(departId)); + + List dataPoliceMeetingList = dataPoliceMeetingMysqlMapper.selectPoliceEvaluationList(departIds, beginTime, endTime); + if (dataPoliceMeetingList.isEmpty()) { + return; + } + // 天心分局 + List tianXinDepartIds = departService.getAllNodeIds("3041"); + List tianXinList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> tianXinDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 高新分局 + List gaoXinDepartIds = departService.getAllNodeIds("4437"); + List gaoXinList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> gaoXinDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 芙蓉分局 + List fuRongDepartIds = departService.getAllNodeIds("2898"); + List fuRongList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> fuRongDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 岳麓分局 + List yueLuDepartIds = departService.getAllNodeIds("3178"); + List yueLuList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> yueLuDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 开福分局 + List kaiFuDepartIds = departService.getAllNodeIds("3337"); + List kaiFuList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> kaiFuDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 雨花分局 + List yuHuaDepartIds = departService.getAllNodeIds("3490"); + List yuHuaList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> yuHuaDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + + List sampleIdList = dataPoliceMeetingList.stream().map(DataPoliceMeeting::getSampleId).toList(); + List negativeList = negativeMapper.selectListBySampleId(sampleIdList); + List data = new ArrayList<>(); + + generateSixBranchLine(tianXinList, "天心分局", dataPoliceMeetingList, negativeList, data); + generateSixBranchLine(gaoXinList, "高新分局", dataPoliceMeetingList, negativeList, data); + generateSixBranchLine(fuRongList, "芙蓉分局", dataPoliceMeetingList, negativeList, data); + generateSixBranchLine(yueLuList, "岳麓分局", dataPoliceMeetingList, negativeList, data); + generateSixBranchLine(kaiFuList, "开福分局", dataPoliceMeetingList, negativeList, data); + generateSixBranchLine(yuHuaList, "雨花分局", dataPoliceMeetingList, negativeList, data); + data.sort(Comparator.comparingDouble((AnalysisJudgmentSixBranch branch) -> Double.parseDouble(branch.getScore())).reversed()); + for (AnalysisJudgmentSixBranch datum : data) { + datum.setId(String.valueOf(data.indexOf(datum) + 1)); + datum.setRank(data.indexOf(datum) + 1); + } + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ExcelWriter excelWriter = EasyExcel.write(os).build(); + WriteSheet sheet1 = EasyExcel.writerSheet(0, "六分局排名情况") + .head(AnalysisJudgmentSixBranch.class).build(); + excelWriter.write(data, sheet1); + excelWriter.finish(); + String filePath = fileService.upload(new ByteArrayInputStream(os.toByteArray()), os.size(), ".xlsx"); + System.out.println(filePath); + } + + private static void generateSixBranchLine(List list, String businessName, List dataPoliceMeetingList, List negativeList, List data) { + List businessIdCollect = list.stream().map(DataPoliceMeeting::getBusinessId).distinct().toList(); + AnalysisJudgmentSixBranch sixBranch = new AnalysisJudgmentSixBranch(); + sixBranch.setBusinessName(businessName); + for (Integer businessId : businessIdCollect) { + // 110 + if (businessId == 12) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + sixBranch.setSatisfactionRate110(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + sixBranch.setUnsatisfiedTimelinessRate110(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRealRate110(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRectificationRate110(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 13) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + sixBranch.setSatisfactionRateVictim(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + sixBranch.setUnsatisfiedTimelinessRateVictim(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRealRateVictim(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRectificationRateVictim(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 19) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + sixBranch.setSatisfactionRateIdCard(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + sixBranch.setUnsatisfiedTimelinessRateIdCard(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRealRateIdCard(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRectificationRateIdCard(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 20) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + sixBranch.setSatisfactionRateHuKou(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + sixBranch.setUnsatisfiedTimelinessRateHuKou(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRealRateHuKou(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + sixBranch.setUnsatisfiedRectificationRateHuKou(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } + } + double rate110 = getRateByString(sixBranch.getSatisfactionRate110()); + double rateVictim = getRateByString(sixBranch.getSatisfactionRateVictim()); + double rateIdCard = getRateByString(sixBranch.getSatisfactionRateIdCard()); + double rateHuKou = getRateByString(sixBranch.getSatisfactionRateHuKou()); + double score = (rate110 * 100 * 20 / 65 + + rateVictim * 100 * 25 / 65 + + rateIdCard * 100 * 10 / 65 + + rateHuKou * 100 * 10 / 65); + sixBranch.setScore(String.format("%.1f", score)); + data.add(sixBranch); + } + + @Async + public void fourBureauExportExcel(Integer departId, Date beginTime, Date endTime) { + List departIds = departService.getAllNodeIds(String.valueOf(departId)); + + List dataPoliceMeetingList = dataPoliceMeetingMysqlMapper.selectPoliceEvaluationList(departIds, beginTime, endTime); + if (dataPoliceMeetingList.isEmpty()) { + return; + } + // 宁乡市局 + List ningXiangDepartIds = departService.getAllNodeIds("3994"); + List ningXiangList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> ningXiangDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 望城分局 + List wangChengDepartIds = departService.getAllNodeIds("3799"); + List wangChengList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> wangChengDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 浏阳市局 + List liuYangDepartIds = departService.getAllNodeIds("4170"); + List liuYangList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> liuYangDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + // 长沙县局 + List xingShaDepartIds = departService.getAllNodeIds("3651"); + List xingShaList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> xingShaDepartIds.contains(dataPoliceMeeting.getInvolveDepartId())).toList(); + + List sampleIdList = dataPoliceMeetingList.stream().map(DataPoliceMeeting::getSampleId).toList(); + List negativeList = negativeMapper.selectListBySampleId(sampleIdList); + List data = new ArrayList<>(); + + generateFourBureauLine(ningXiangList, "宁乡市局", dataPoliceMeetingList, negativeList, data); + generateFourBureauLine(wangChengList, "望城分局", dataPoliceMeetingList, negativeList, data); + generateFourBureauLine(liuYangList, "浏阳市局", dataPoliceMeetingList, negativeList, data); + generateFourBureauLine(xingShaList, "长沙县局", dataPoliceMeetingList, negativeList, data); + data.sort(Comparator.comparingDouble((AnalysisJudgmentFourBureau branch) -> Double.parseDouble(branch.getScore())).reversed()); + for (AnalysisJudgmentFourBureau datum : data) { + datum.setId(String.valueOf(data.indexOf(datum) + 1)); + datum.setRank(data.indexOf(datum) + 1); + } + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ExcelWriter excelWriter = EasyExcel.write(os).build(); + WriteSheet sheet1 = EasyExcel.writerSheet(0, "四县市局排名情况") + .head(AnalysisJudgmentFourBureau.class).build(); + excelWriter.write(data, sheet1); + excelWriter.finish(); + String filePath = fileService.upload(new ByteArrayInputStream(os.toByteArray()), os.size(), ".xlsx"); + System.out.println(filePath); + } + + private static void generateFourBureauLine(List list, String businessName, List dataPoliceMeetingList, List negativeList, List data) { + List businessIdCollect = list.stream().map(DataPoliceMeeting::getBusinessId).distinct().toList(); + AnalysisJudgmentFourBureau fourBureau = new AnalysisJudgmentFourBureau(); + fourBureau.setBusinessName(businessName); + for (Integer businessId : businessIdCollect) { + if (businessId == 12) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRate110(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRate110(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRate110(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRate110(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 13) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRateVictim(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRateVictim(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRateVictim(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRateVictim(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 18) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRate122(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRate122(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRate122(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRate122(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 11) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRateDrivingTest(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRateDrivingTest(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRateDrivingTest(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRateDrivingTest(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 14) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRateCarRegistration(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRateCarRegistration(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRateCarRegistration(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRateCarRegistration(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 19) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRateIdCard(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRateIdCard(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRateIdCard(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRateIdCard(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } else if (businessId == 20) { + List filterList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId)).toList(); + if (filterList.isEmpty()) { + continue; + } + Set filterSampleIdList = filterList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + List negativeFilterList = negativeList.stream().filter(negative -> filterSampleIdList.contains(negative.getSampleId())).toList(); + fourBureau.setSatisfactionRateHuKou(String.format("%.1f%%", (filterList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getBusinessId().equals(businessId) && !dataPoliceMeeting.getResultName().equals("不满意")).count() / (double) filterList.size() * 100))); + if (!negativeFilterList.isEmpty()) { + fourBureau.setUnsatisfiedTimelinessRateHuKou(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() == null || negative.getHandleTimeout() == 0).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRealRateHuKou(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count() / (double) negativeFilterList.size() * 100)); + fourBureau.setUnsatisfiedRectificationRateHuKou(String.format("%.1f%%", (int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count() / (double) negativeFilterList.size() * 100)); + } + } + } + double rate110 = getRateByString(fourBureau.getSatisfactionRate110()); + double rateVictim = getRateByString(fourBureau.getSatisfactionRateVictim()); + double rate122 = getRateByString(fourBureau.getSatisfactionRate122()); + double rateDrivingTest = getRateByString(fourBureau.getSatisfactionRateDrivingTest()); + double rateCarRegistration = getRateByString(fourBureau.getSatisfactionRateCarRegistration()); + double rateIdCard = getRateByString(fourBureau.getSatisfactionRateIdCard()); + double rateHuKou = getRateByString(fourBureau.getSatisfactionRateHuKou()); + double score = (rate110 * 100 * 20 / 100 + + rateVictim * 100 * 25 / 100 + + rate122 * 100 * 15 / 100 + + rateDrivingTest * 100 * 10 / 100 + + rateCarRegistration * 100 * 10 / 100 + + rateIdCard * 100 * 10 / 100 + + rateHuKou * 100 * 10 / 100); + fourBureau.setScore(String.format("%.1f", score)); + data.add(fourBureau); + } + + @Async + public void projectAnalysisExportExcel(Integer project, Integer departId, Integer level, Date beginTime, Date endTime) { + List allDepartNode = departService.getAllNode(List.of(String.valueOf(departId))); + List departNodeList; + if (level == 2) { + departNodeList = allDepartNode.stream().filter(departTree -> departTree.getLevel() == 2).toList(); + } else { + departNodeList = allDepartNode.stream().filter(departTree -> departTree.getStatisticsGroupId() != null && departTree.getStatisticsGroupId().equals(String.valueOf(level))).toList(); + } + List departIds = departService.getAllNodeIds(departNodeList.stream().map(DepartTree::getId).toList()); + List dataPoliceMeetingList = dataPoliceMeetingMysqlMapper.selectProjectAnalysisList(project, departIds, beginTime, endTime); + if (dataPoliceMeetingList.isEmpty()) { + return; + } + + List sampleIdList = dataPoliceMeetingList.stream().map(DataPoliceMeeting::getSampleId).toList(); + List negativeList = negativeMapper.selectListBySampleId(sampleIdList); + List data = new ArrayList<>(); + int i = 1; + for (DepartTree departNode : departNodeList) { + List filterDataPoliceMeetingList = dataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getInvolveDepartId().equals(departNode.getId())).toList(); + AnalysisJudgmentProjectAnalysis analysisJudgmentProjectAnalysis = new AnalysisJudgmentProjectAnalysis(); + analysisJudgmentProjectAnalysis.setId(String.valueOf(i++)); + analysisJudgmentProjectAnalysis.setBusinessName(departNode.getName()); + if (filterDataPoliceMeetingList.isEmpty()) { + data.add(analysisJudgmentProjectAnalysis); + continue; + } + analysisJudgmentProjectAnalysis.setEffectiveResponse(filterDataPoliceMeetingList.size()); + Set sampleIdSet = filterDataPoliceMeetingList.stream().map(DataPoliceMeeting::getSampleId).collect(Collectors.toSet()); + analysisJudgmentProjectAnalysis.setSatisfied((int) filterDataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getResultName().equals("满意")).count()); + analysisJudgmentProjectAnalysis.setBasicallySatisfied((int) filterDataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getResultName().equals("基本满意")).count()); + analysisJudgmentProjectAnalysis.setDissatisfied((int) filterDataPoliceMeetingList.stream().filter(dataPoliceMeeting -> dataPoliceMeeting.getResultName().equals("不满意")).count()); + analysisJudgmentProjectAnalysis.setSatisfactionRate(String.format("%.1f%%", (analysisJudgmentProjectAnalysis.getSatisfied() + analysisJudgmentProjectAnalysis.getBasicallySatisfied()) / (double) analysisJudgmentProjectAnalysis.getEffectiveResponse() * 100)); + List negativeFilterList = negativeList.stream().filter(negative -> sampleIdSet.contains(negative.getSampleId())).toList(); + if (negativeFilterList.isEmpty()) { + data.add(analysisJudgmentProjectAnalysis); + continue; + } else { + analysisJudgmentProjectAnalysis.setUnsatisfiedTimeoutNumbers((int) negativeFilterList.stream().filter(negative -> negative.getHandleTimeout() != null && negative.getHandleTimeout() > 0).count()); + analysisJudgmentProjectAnalysis.setUnsatisfiedTimeoutRate(String.format("%.1f%%", analysisJudgmentProjectAnalysis.getUnsatisfiedTimeoutNumbers() / (double) negativeFilterList.size() * 100)); + analysisJudgmentProjectAnalysis.setUnsatisfiedRealNumbers((int) negativeFilterList.stream().filter(negative -> !negative.getCheckStatusName().equals("不属实")).count()); + analysisJudgmentProjectAnalysis.setUnsatisfiedRealRate(String.format("%.1f%%", analysisJudgmentProjectAnalysis.getUnsatisfiedRealNumbers() / (double) negativeFilterList.size() * 100)); + analysisJudgmentProjectAnalysis.setUnsatisfiedRectificationNumbers((int) negativeFilterList.stream().filter(negative -> negative.getIsRectifyName().equals("已整改")).count()); + analysisJudgmentProjectAnalysis.setUnsatisfiedRectificationRate(String.format("%.1f%%", analysisJudgmentProjectAnalysis.getUnsatisfiedRectificationNumbers() / (double) negativeFilterList.size() * 100)); + } + data.add(analysisJudgmentProjectAnalysis); + } + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ExcelWriter excelWriter = EasyExcel.write(os).build(); + WriteSheet sheet1 = EasyExcel.writerSheet(0, "警务评议项目分析") + .head(AnalysisJudgmentProjectAnalysis.class).build(); + excelWriter.write(data, sheet1); + excelWriter.finish(); + String filePath = fileService.upload(new ByteArrayInputStream(os.toByteArray()), os.size(), ".xlsx"); + System.out.println(filePath); + } + + private static double getRateByString(String string) { + if (string == null) { + return 0; + } + return Double.parseDouble(string.replace("%", "")) / 100; + } +} diff --git a/src/main/java/com/biutag/supervision/service/DataPoliceMeetingService.java b/src/main/java/com/biutag/supervision/service/DataPoliceMeetingService.java new file mode 100644 index 0000000..3fee37c --- /dev/null +++ b/src/main/java/com/biutag/supervision/service/DataPoliceMeetingService.java @@ -0,0 +1,11 @@ +package com.biutag.supervision.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.biutag.supervision.pojo.entity.DataPoliceMeeting; +import com.biutag.supervision.mapper.DataPoliceMeetingMapper; +import org.springframework.stereotype.Service; + +@Service +public class DataPoliceMeetingService extends ServiceImpl { + +} diff --git a/src/main/resources/mapper/DataPoliceMeetingMysqlMapper.xml b/src/main/resources/mapper/DataPoliceMeetingMysqlMapper.xml index 452dd16..6cd395e 100644 --- a/src/main/resources/mapper/DataPoliceMeetingMysqlMapper.xml +++ b/src/main/resources/mapper/DataPoliceMeetingMysqlMapper.xml @@ -9,6 +9,39 @@ from data_police_meeting ${ew.getCustomSqlSegment} + + \ No newline at end of file diff --git a/src/main/resources/mapper/NegativeMapper.xml b/src/main/resources/mapper/NegativeMapper.xml index 8b38525..4652623 100644 --- a/src/main/resources/mapper/NegativeMapper.xml +++ b/src/main/resources/mapper/NegativeMapper.xml @@ -80,6 +80,10 @@ ORDER BY m.`month` ASC; +