Browse Source

数据统计

v3
zouyx 2 years ago
parent
commit
f27251e116
  1. 5
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementCheckStatisticsController.java
  2. 18
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/StatisticsIndicator.java
  3. 2
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/EnforcementRegistrationMapper.java
  4. 12
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/EnforcementCheckStatisticsService.java
  5. 567
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java
  6. 6
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml

5
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementCheckStatisticsController.java

@ -129,4 +129,9 @@ public class EnforcementCheckStatisticsController extends BaseController {
inOrderList.add("其他"); inOrderList.add("其他");
enforcementCheckStatisticsService.excelExport(response,enforcementCheckStatistics,inOrderList,enforcementCheckStatisticsMap,enterpriseStreet); enforcementCheckStatisticsService.excelExport(response,enforcementCheckStatistics,inOrderList,enforcementCheckStatisticsMap,enterpriseStreet);
} }
@GetMapping("/statisticsIndicator")
@ResponseBody
public ZDResponse statisticsIndicator(){
return ZDResponse.success("统计成功", enforcementCheckStatisticsService.sjtjzb());
}
} }

18
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/StatisticsIndicator.java

@ -0,0 +1,18 @@
package com.zdxt.code.domain;
import com.zdxt.common.BaseDomain;
import lombok.Data;
import java.util.List;
@Data
public class StatisticsIndicator extends BaseDomain {
private String name;
private int numInt;
private Double numDouble;
private List<StatisticsIndicator> statisticsIndicatorList;
public void setNumDouble(Double numDouble) {
this.numDouble = new Double(String.format("%.3f",numDouble));
}
}

2
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/EnforcementRegistrationMapper.java

@ -90,4 +90,6 @@ public interface EnforcementRegistrationMapper
* @return * @return
*/ */
List<EnforceRegCount> countMentByTimeQyNew(@Param("beginTime") String beginTime, @Param("endTime") String endTime); List<EnforceRegCount> countMentByTimeQyNew(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
List<EnforcementRegistration> selectAllList(EnforcementRegistration enforcementRegistration);
} }

12
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/EnforcementCheckStatisticsService.java

@ -1,7 +1,9 @@
package com.zdxt.code.service; package com.zdxt.code.service;
import com.zdxt.code.domain.EnforcementCheckStatistics; import com.zdxt.code.domain.EnforcementCheckStatistics;
import com.zdxt.code.domain.EnterpriseComplaint;
import com.zdxt.code.domain.EnterpriseStreet; import com.zdxt.code.domain.EnterpriseStreet;
import com.zdxt.code.domain.StatisticsIndicator;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@ -40,6 +42,11 @@ public interface EnforcementCheckStatisticsService {
*/ */
public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics); public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics);
/**
*查询所有在线投诉记录
*/
public List<EnterpriseComplaint> selectEnterpriseComplaintList(EnterpriseComplaint enterpriseComplaint);
/** /**
*excel导出(执法监督码使用情况) *excel导出(执法监督码使用情况)
*/ */
@ -50,4 +57,9 @@ public interface EnforcementCheckStatisticsService {
*/ */
public void excelExport2(HttpServletResponse response, List<EnterpriseStreet> enterpriseStreetList,String enterpriseAddress); public void excelExport2(HttpServletResponse response, List<EnterpriseStreet> enterpriseStreetList,String enterpriseAddress);
/**
*导出excel3 (数据统计指标)
*/
public List<List<StatisticsIndicator>> sjtjzb();
} }

567
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java

@ -1,18 +1,22 @@
package com.zdxt.code.service.impl; package com.zdxt.code.service.impl;
import cn.hutool.http.server.HttpServerResponse; import com.zdxt.auth.project.system.dept.mapper.DeptMapper;
import com.zdxt.code.domain.EnforcementCheckStatistics; import com.zdxt.auth.project.system.dict.mapper.DictDataMapper;
import com.zdxt.code.domain.EnterpriseStreet; import com.zdxt.auth.project.system.user.mapper.UserMapper;
import com.zdxt.code.mapper.EnforcementCheckStatisticsMapper; import com.zdxt.code.domain.*;
import com.zdxt.code.mapper.*;
import com.zdxt.code.mapper.EnterpriseStreetMapper;
import com.zdxt.code.service.EnforcementCheckStatisticsService; import com.zdxt.code.service.EnforcementCheckStatisticsService;
import com.zdxt.domain.auth.Dept;
import com.zdxt.domain.auth.DictData;
import com.zdxt.domain.auth.User;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil; import org.apache.poi.ss.util.RegionUtil;
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 sun.util.logging.resources.logging;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
@ -21,7 +25,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.zdxt.common.util.StringUtils.substring; import static com.zdxt.common.util.StringUtils.substring;
import static org.apache.commons.io.FilenameUtils.concat; import static org.aspectj.runtime.internal.Conversions.intValue;
@Service @Service
public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatisticsService { public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatisticsService {
@ -29,6 +33,18 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
private EnforcementCheckStatisticsMapper enforcementCheckStatisticsMapper; private EnforcementCheckStatisticsMapper enforcementCheckStatisticsMapper;
@Autowired @Autowired
private EnterpriseStreetMapper enterpriseStreetMapper; private EnterpriseStreetMapper enterpriseStreetMapper;
@Autowired
private EnterpriseComplaintMapper enterpriseComplaintMapper;
@Autowired
private DeptMapper deptMapper;
@Autowired
private EnterpriseInformationMapper enterpriseInformationMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private EnforcementRegistrationMapper enforcementRegistrationMapper;
@Autowired
private DictDataMapper dictDataMapper;
/** /**
*将样式应用到单元格 *将样式应用到单元格
*/ */
@ -50,6 +66,22 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet);
RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet);
} }
/**
*sheet2 填值
*/
private int tz(HSSFSheet sheet2,int rowNum2,String v1,String v2,int v3,HSSFCellStyle styleRow3){
HSSFRow s2Row = sheet2.createRow(++rowNum2);
HSSFCell s2cell1 = s2Row.createCell(0);
HSSFCell s2cell2 = s2Row.createCell(1);
HSSFCell s2cell3 = s2Row.createCell(2);
s2cell1.setCellValue(v1);
s2cell2.setCellValue(v2);
s2cell3.setCellValue(v3);
s2cell1.setCellStyle(styleRow3);
s2cell2.setCellStyle(styleRow3);
s2cell3.setCellStyle(styleRow3);
return rowNum2;
}
/** /**
*查询该区下的所有执法记录 *查询该区下的所有执法记录
*/ */
@ -91,7 +123,13 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics) { public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics) {
return enforcementCheckStatisticsMapper.selectAllStatisticsList(enforcementCheckStatistics); return enforcementCheckStatisticsMapper.selectAllStatisticsList(enforcementCheckStatistics);
} }
/**
* 查询在线投诉记录
*/
@Override
public List<EnterpriseComplaint> selectEnterpriseComplaintList(EnterpriseComplaint enterpriseComplaint) {
return enterpriseComplaintMapper.selectEnterpriseComplaintList(enterpriseComplaint);
}
/** /**
*导出excel *导出excel
@ -328,44 +366,28 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
Collections.addAll(inOrderList2,"福田区","罗湖区","盐田区","南山区","宝安区","龙岗区","龙华区", Collections.addAll(inOrderList2,"福田区","罗湖区","盐田区","南山区","宝安区","龙岗区","龙华区",
"坪山区","光明区","大鹏新区","深汕特别合作区"); "坪山区","光明区","大鹏新区","深汕特别合作区");
Map<String, List<EnterpriseStreet>> map1=enterpriseStreet.stream().collect(Collectors.groupingBy(item->(inOrderList2.contains(item.getEnterpriseAddress().substring(3,6))?item.getEnterpriseAddress().substring(3,6):"其他"))); Map<String, List<EnterpriseStreet>> map1=enterpriseStreet.stream().collect(Collectors.groupingBy(item->(inOrderList2.contains(item.getEnterpriseAddress().substring(3,6))?item.getEnterpriseAddress().substring(3,6):"其他")));
//List<EnterpriseStreet> es1= (List<EnterpriseStreet>) map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,10).equals("深汕特别合作区"));
//System.out.println("第317行:"+map1.get("其他"));
List<EnterpriseStreet> es1= map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,10).equals("深汕特别合作区")).collect(Collectors.toList()); List<EnterpriseStreet> es1= map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,10).equals("深汕特别合作区")).collect(Collectors.toList());
map1.put("深汕特别合作区",es1); map1.put("深汕特别合作区",es1);
//List<EnterpriseStreet> es2= (List<EnterpriseStreet>) map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("大鹏新区"));
List<EnterpriseStreet> es2= map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("大鹏新区")).collect(Collectors.toList()); List<EnterpriseStreet> es2= map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("大鹏新区")).collect(Collectors.toList());
map1.put("大鹏新区",es2); map1.put("大鹏新区",es2);
//List<EnterpriseStreet> es3= (List<EnterpriseStreet>) map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("光明新区"));
List<EnterpriseStreet> es3= map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("光明新区")).collect(Collectors.toList()); List<EnterpriseStreet> es3= map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("光明新区")).collect(Collectors.toList());
/*System.out.println("第324行:"+es3);
System.out.println("第325行:"+map1.get("光明区"));*/
map1.get("光明区").addAll(es3); map1.get("光明区").addAll(es3);
//删除在”其他“中多余的数据
/* for(int i = 0 ;i < map1.get("其他").size(); i++){
if(map1.get("其他").get(i).getEnterpriseAddress().contains("深汕特别合作区")){
map1.get("其他").remove(i);
}else if(map1.get("其他").get(i).getEnterpriseAddress().contains("光明新区")){
map1.get("其他").remove(i);
}else if(map1.get("其他").get(i).getEnterpriseAddress().contains("大鹏新区")){
map1.get("其他").remove(i);
}
}*/
map1.remove("其他"); map1.remove("其他");
List<EnterpriseStreet> e2=enterpriseStreet.stream().filter(item->!( List<EnterpriseStreet> e2=enterpriseStreet.stream().filter(item->!(
item.getEnterpriseAddress().contains("福田区")||item.getEnterpriseAddress().contains("罗湖区")|| item.getEnterpriseAddress().startsWith("深圳市福田区")||item.getEnterpriseAddress().startsWith("深圳市罗湖区")||
item.getEnterpriseAddress().contains("盐田区")||item.getEnterpriseAddress().contains("南山区")|| item.getEnterpriseAddress().startsWith("深圳市盐田区")||item.getEnterpriseAddress().startsWith("深圳市南山区")||
item.getEnterpriseAddress().contains("宝安区")||item.getEnterpriseAddress().contains("龙岗区")|| item.getEnterpriseAddress().startsWith("深圳市宝安区")||item.getEnterpriseAddress().startsWith("深圳市龙岗区")||
item.getEnterpriseAddress().contains("龙华区")||item.getEnterpriseAddress().contains("坪山区")|| item.getEnterpriseAddress().startsWith("深圳市龙华区")||item.getEnterpriseAddress().startsWith("深圳市坪山区")||
item.getEnterpriseAddress().contains("大鹏新区")||item.getEnterpriseAddress().contains("深汕特别合作区")|| item.getEnterpriseAddress().startsWith("深圳市大鹏新区")||item.getEnterpriseAddress().startsWith("深圳市深汕特别合作区")||
item.getEnterpriseAddress().contains("光明区")||item.getEnterpriseAddress().contains("光明新区"))) item.getEnterpriseAddress().startsWith("深圳市光明区")||item.getEnterpriseAddress().startsWith("深圳市光明新区")))
.collect(Collectors.toList()); .collect(Collectors.toList());
map1.put("其他",e2); map1.put("其他",e2);
inOrderList2.add("其他"); inOrderList2.add("其他");
/*System.out.println("第327行:"+map1.get("光明区"));*/
for(String area:inOrderList2){ for(String area:inOrderList2){
if(map1.get(area)!=null) { if(map1.get(area)!=null) {
if(area.equals("其他")){ if(area.equals("其他")){
HSSFRow s2Row = sheet2.createRow(++rowNum2); rowNum2=tz(sheet2,rowNum2,"其他","",map1.get("其他").size(),styleRow3);
/* HSSFRow s2Row = sheet2.createRow(++rowNum2);
HSSFCell s2cell1 = s2Row.createCell(0); HSSFCell s2cell1 = s2Row.createCell(0);
HSSFCell s2cell2 = s2Row.createCell(1); HSSFCell s2cell2 = s2Row.createCell(1);
HSSFCell s2cell3 = s2Row.createCell(2); HSSFCell s2cell3 = s2Row.createCell(2);
@ -373,13 +395,20 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
s2cell3.setCellValue(map1.get("其他").size()); s2cell3.setCellValue(map1.get("其他").size());
s2cell1.setCellStyle(styleRow3); s2cell1.setCellStyle(styleRow3);
s2cell2.setCellStyle(styleRow3); s2cell2.setCellStyle(styleRow3);
s2cell3.setCellStyle(styleRow3); s2cell3.setCellStyle(styleRow3);*/
}else { }else {
Map<String, List<EnterpriseStreet>> jdList = map1.get(area).stream().collect(Collectors.groupingBy(item -> item.getEnterpriseAddress().contains("街道") ? item.getEnterpriseAddress().substring(item.getEnterpriseAddress().indexOf("区") + 1, item.getEnterpriseAddress().indexOf("街道") + 2) : "其他")); Map<String, List<EnterpriseStreet>> jdList = map1.get(area).stream().collect(Collectors.groupingBy(item -> item.getEnterpriseAddress().contains("街道") ? item.getEnterpriseAddress().substring(item.getEnterpriseAddress().indexOf("区") + 1, item.getEnterpriseAddress().indexOf("街道") + 2) : "其他"));
//<街道名字,数量> //<街道名字,数量>
Map<String, Integer> jdNum = new HashMap<>(); boolean qtjd=false;
int qtjdNumber=0;
if(jdList.containsKey("其他")){
qtjd=true;
qtjdNumber=jdList.get("其他").size();
jdList.remove("其他");
}
for (String jd : jdList.keySet()) { for (String jd : jdList.keySet()) {
HSSFRow s2Row = sheet2.createRow(++rowNum2); rowNum2=tz(sheet2,rowNum2,area,jd,jdList.get(jd).size(),styleRow3);
/*HSSFRow s2Row = sheet2.createRow(++rowNum2);
HSSFCell s2cell1 = s2Row.createCell(0); HSSFCell s2cell1 = s2Row.createCell(0);
HSSFCell s2cell2 = s2Row.createCell(1); HSSFCell s2cell2 = s2Row.createCell(1);
HSSFCell s2cell3 = s2Row.createCell(2); HSSFCell s2cell3 = s2Row.createCell(2);
@ -388,7 +417,20 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
s2cell3.setCellValue(jdList.get(jd).size()); s2cell3.setCellValue(jdList.get(jd).size());
s2cell1.setCellStyle(styleRow3); s2cell1.setCellStyle(styleRow3);
s2cell2.setCellStyle(styleRow3); s2cell2.setCellStyle(styleRow3);
s2cell3.setCellStyle(styleRow3); s2cell3.setCellStyle(styleRow3);*/
}
if(qtjd){
rowNum2=tz(sheet2,rowNum2,area,"其他",qtjdNumber,styleRow3);
/*HSSFRow s2Row = sheet2.createRow(++rowNum2);
HSSFCell s2cell1 = s2Row.createCell(0);
HSSFCell s2cell2 = s2Row.createCell(1);
HSSFCell s2cell3 = s2Row.createCell(2);
s2cell1.setCellValue(area);
s2cell2.setCellValue("其他");
s2cell3.setCellValue(qtjdNumber);
s2cell1.setCellStyle(styleRow3);
s2cell2.setCellStyle(styleRow3);
s2cell3.setCellStyle(styleRow3);*/
} }
/*if(!jdList.isEmpty()){ /*if(!jdList.isEmpty()){
System.out.println("第343行:"+rowNum2); System.out.println("第343行:"+rowNum2);
@ -402,6 +444,7 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
} }
} }
}else{ }else{
//tz(sheet2,rowNum2,area,"", 0,styleRow3);
HSSFRow s2Row = sheet2.createRow(++rowNum2); HSSFRow s2Row = sheet2.createRow(++rowNum2);
HSSFCell s2cell1 = s2Row.createCell(0); HSSFCell s2cell1 = s2Row.createCell(0);
HSSFCell s2cell2 = s2Row.createCell(1); HSSFCell s2cell2 = s2Row.createCell(1);
@ -487,5 +530,459 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
} }
} }
/**
*导出excel3 数据统计指标
*/
@Override
public List<List<StatisticsIndicator>> sjtjzb() {
//一级指标-投诉:所有部门被投诉次数的总数;二级指标-联合检查:计算联合检查内所有部门投诉数/一级投诉;二级指标-执法主体:计算各执法主体被投诉数/一级投诉
List<StatisticsIndicator> statisticsIndicatorList4 = new ArrayList<>();//sheet4返回
//在线投诉list
List<EnterpriseComplaint> enterpriseComplaintList = enterpriseComplaintMapper.selectEnterpriseComplaintList(new EnterpriseComplaint());
Map<Integer,List<EnterpriseComplaint>> map1=enterpriseComplaintList.stream().collect(Collectors.groupingBy(item-> item.getComplaintType()==null? 0:item.getComplaintType()));
int bmtsNum = 0;//所有部门被投诉总数
int bmtsNum1 = 0;
int bmtsNum0 = 0;
Map<String, Integer> map2 = new HashMap<>();//联合投诉时被投诉
if (map1.get(1) != null) {
for (EnterpriseComplaint enterpriseComplaint : map1.get(1)) {//遍历投诉列表
if (enterpriseComplaint.getComplaintDepartmentIds() != null) {
List<String> list = Arrays.asList(enterpriseComplaint.getComplaintDepartmentIds().split(","));//将每条投诉取出,以“,”为分隔符
bmtsNum = bmtsNum + list.size();
for (String str : list) {
if (map2.containsKey(str)) {
int num = map2.get(str) + 1;
map2.put(str, num);
} else {
map2.put(str, 1);
}
}
}
}
}
bmtsNum1 = bmtsNum;
List<EnterpriseComplaint> e1=new ArrayList<>();
if(map1.get(0) != null){
e1.addAll(map1.get(0));
}
if(map1.get(2)!=null){
e1.addAll(map1.get(2));
}
Map<String, Integer> map3 = new HashMap<>();//非联合投诉时被投诉,id为键
if (e1 != null) {
for (EnterpriseComplaint enterpriseComplaint : e1) {//遍历投诉列表
if (enterpriseComplaint.getComplaintDepartmentIds() != null) {
List<String> list = Arrays.asList(enterpriseComplaint.getComplaintDepartmentIds().split(","));//将每条投诉取出,以“,”为分隔符
bmtsNum = bmtsNum + list.size();
for (String str : list) {
if (map3.containsKey(str)) {
int num = map3.get(str) + 1;
map3.put(str, num);
} else {
map3.put(str, 1);
}
}
}
}
}
bmtsNum0 = bmtsNum - bmtsNum1;
StatisticsIndicator s1 = new StatisticsIndicator();
s1.setName("投诉");
s1.setNumInt(bmtsNum);
statisticsIndicatorList4.add(s1);
StatisticsIndicator s2 = new StatisticsIndicator();
s2.setName("联合执法投诉率");
Double d1=(double)bmtsNum1 / bmtsNum;
s2.setNumDouble(d1);
statisticsIndicatorList4.add(s2);
System.out.println(bmtsNum+"全部"+bmtsNum1+"联合"+bmtsNum0+"未联");
System.out.println(statisticsIndicatorList4);
List<Dept> deptList=deptMapper.selectDeptList(new Dept());//已滤掉停用
//<执法主体id,执法主体名称>
Map<String,String> deptNamemap=deptList.stream().collect(Collectors.toMap(Dept::getDeptId,Dept::getDeptName));
//各执法主体被投诉总数(包含各种投诉类型)
Map<String, Integer> map4 = new HashMap<>(map2);
for (String Did:map3.keySet()) {
if (map4.containsKey(Did)){
int num=map4.get(Did)+map3.get(Did);
map4.put(Did,num);
}else {
map4.put(Did,map3.get(Did));
}
}
System.out.println(map4.values());
List<StatisticsIndicator> zftsList=new ArrayList<>();
for(String Did:map4.keySet()){
StatisticsIndicator s=new StatisticsIndicator();
Double num= (double) map4.get(Did) / bmtsNum;
s.setName(deptNamemap.get(Did));
s.setNumDouble(num);
s.setNumInt(map4.get(Did));
zftsList.add(s);
}
StatisticsIndicator zfts=new StatisticsIndicator();
zfts.setName("执法主体被投诉");
zfts.setStatisticsIndicatorList(zftsList);
statisticsIndicatorList4.add(zfts);
System.out.println(statisticsIndicatorList4);
//一级指标-企业:所有企业总数;二级指标-企业类型;二级指标-企业地址(区);三级指标-企业地址(街道)
List<StatisticsIndicator> statisticsIndicatorList1=new ArrayList<>();
List<EnterpriseInformation> enterpriseInformationList=enterpriseInformationMapper.selectEnterpriseInformationList(new EnterpriseInformation());
//企业总数
StatisticsIndicator qy=new StatisticsIndicator();
qy.setName("企业总数");
qy.setNumInt(enterpriseInformationList.size());
statisticsIndicatorList1.add(qy);
//企业类型
//Map<String,Integer> s1Map1=enterpriseInformationList.stream().collect(Collectors.groupingBy(item-> item.getCompanyOrgType() == null? "其他" : item.getCompanyOrgType()),Collectors.counting());
Map<String,Long> s1Map1=enterpriseInformationList.stream().collect(Collectors.groupingBy(item-> item.getCompanyOrgType() == null? "其他" : item.getCompanyOrgType(),Collectors.counting()));
List<StatisticsIndicator> qyList=new ArrayList<>();
for (String s:s1Map1.keySet()){
StatisticsIndicator qylx=new StatisticsIndicator();
qylx.setName(s);
qylx.setNumInt(Math.toIntExact(s1Map1.get(s)));
qyList.add(qylx);
}
StatisticsIndicator qylx=new StatisticsIndicator();
qylx.setName("企业类型");
qylx.setStatisticsIndicatorList(qyList);
statisticsIndicatorList1.add(qylx);
System.out.println(statisticsIndicatorList1);
List<String> inOrderList1=new ArrayList<>();
Collections.addAll(inOrderList1,"深圳市福田区","深圳市罗湖区","深圳市盐田区","深圳市南山区","深圳市宝安区","深圳市龙岗区","深圳市龙华区", "深圳市坪山区","深圳市光明区","深圳市大鹏新区","深圳市深汕特别合作区");
List<String> inOrderList2=new ArrayList<>();
Collections.addAll(inOrderList2,"福田区","罗湖区","盐田区","南山区","宝安区","龙岗区","龙华区", "坪山区","光明区","大鹏新区","深汕特别合作区");
Map<String, List<EnterpriseInformation>> qMap=enterpriseInformationList.stream().collect(Collectors.groupingBy(item->(inOrderList1.contains(item.getEnterpriseAddress().substring(0,6))?item.getEnterpriseAddress().substring(3,6):"其他")));
List<EnterpriseInformation> es1= qMap.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(0,10).equals("深圳市深汕特别合作区")).collect(Collectors.toList());
qMap.put("深汕特别合作区",es1);
List<EnterpriseInformation> es2= qMap.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(0,7).equals("深圳市大鹏新区")).collect(Collectors.toList());
qMap.put("大鹏新区",es2);
List<EnterpriseInformation> es3= qMap.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(0,7).equals("深圳市光明新区")).collect(Collectors.toList());
qMap.get("光明区").addAll(es3);
qMap.remove("其他");
List<EnterpriseInformation> e2=enterpriseInformationList.stream().filter(item->!(
item.getEnterpriseAddress().startsWith("深圳市福田区")||item.getEnterpriseAddress().startsWith("深圳市罗湖区")||
item.getEnterpriseAddress().startsWith("深圳市盐田区")||item.getEnterpriseAddress().startsWith("深圳市南山区")||
item.getEnterpriseAddress().startsWith("深圳市宝安区")||item.getEnterpriseAddress().startsWith("深圳市龙岗区")||
item.getEnterpriseAddress().startsWith("深圳市龙华区")||item.getEnterpriseAddress().startsWith("深圳市坪山区")||
item.getEnterpriseAddress().startsWith("深圳市大鹏新区")||item.getEnterpriseAddress().startsWith("深圳市深汕特别合作区")||
item.getEnterpriseAddress().startsWith("深圳市光明区")||item.getEnterpriseAddress().startsWith("深圳市光明新区")))
.collect(Collectors.toList());
for(String s:inOrderList2){
if(qMap.get(s)!=null){
StatisticsIndicator qList=new StatisticsIndicator();
qList.setName(s);
qList.setNumInt(qMap.get(s).size());
Map<String,Long> m=qMap.get(s).stream().collect(Collectors
.groupingBy(item->item.getEnterpriseAddress().contains("街道")
? item.getEnterpriseAddress().substring(item.getEnterpriseAddress().indexOf("区") + 1, item.getEnterpriseAddress().indexOf("街道") + 2)
: "其他",Collectors.counting()));
List<StatisticsIndicator> jdList=new ArrayList<>();
for(String jd:m.keySet()){
StatisticsIndicator jd1=new StatisticsIndicator();
jd1.setName(jd);
jd1.setNumInt(Math.toIntExact(m.get(jd)));
jdList.add(jd1);
}
qList.setStatisticsIndicatorList(jdList);
statisticsIndicatorList1.add(qList);
}
}
StatisticsIndicator sqt=new StatisticsIndicator();
sqt.setName("其他");
sqt.setNumInt(e2.size());
statisticsIndicatorList1.add(sqt);
System.out.println(statisticsIndicatorList1);
//一级指标-执法人员:执法人员总数,二级指标-有执法记录的执法人员:有执法记录的执法人员数量,二级指标-有执法记录的执法人员占比:有执法记录的执法人员数量/所有执法人员
//二级指标-没有执法记录的执法人员占比:没有执法记录的执法人员数量/所有执法人员,三级指标-执法人员检查次数:各执法人员检查次数
List<StatisticsIndicator> statisticsIndicatorList2=new ArrayList<>();
List<User> userList=userMapper.selectUserListByHave(new User());//所有执法人员
Map<Long,String> zfNameMap=userList.stream().collect(Collectors.toMap(User::getUserId,User::getUserName));
StatisticsIndicator zfryAll=new StatisticsIndicator();//一级指标
zfryAll.setName("执法人员");
zfryAll.setNumInt(userList.size());
List<EnforcementRegistration> zfjlList= enforcementRegistrationMapper.selectAllList(new EnforcementRegistration());
Map<String,Integer> zfNumMap=new HashMap<>();//<有执法记录的执法人员ID,执法次数>
for(EnforcementRegistration zfjl:zfjlList){
String person=zfjl.getLawEnforcerId()+","+zfjl.getLawEnforcerIdTwo();
List<String> personList=Arrays.asList(person.split(","));
for(String p:personList) {
if((p!=null)&& (!p.equals("null"))) {
if (zfNameMap.containsKey(Long.valueOf(p))) {
if (!zfNumMap.containsKey(p)) {
zfNumMap.put(p, 1);
} else {
int zfNum = zfNumMap.get(p) + 1;
zfNumMap.put(p, zfNum);
}
}
}
}
System.out.println(personList);
}
System.out.println(zfNumMap.keySet());
if(zfNumMap.get("null")!=null){
zfNumMap.remove("null");
}
if(zfNumMap.get("0")!=null){
zfNumMap.remove("0");
}
Double haveZfNum= (double) zfNumMap.keySet().size()/userList.size();
Double haveNotZfNum=(double) (userList.size()-zfNumMap.keySet().size())/userList.size();
StatisticsIndicator haveZfN=new StatisticsIndicator();//二级一
haveZfN.setName("有执法记录的执法人员");
haveZfN.setNumInt(zfNumMap.keySet().size());
StatisticsIndicator haveZf=new StatisticsIndicator();//二级二
haveZf.setName("有执法记录的执法人员占比");
haveZf.setNumDouble(haveZfNum);
StatisticsIndicator haveNotZf=new StatisticsIndicator();//二级三
haveNotZf.setName("没有执法记录的执法人员占比");
haveNotZf.setNumDouble(haveNotZfNum);
StatisticsIndicator zfNum=new StatisticsIndicator();//三级
List<StatisticsIndicator> zfNumList=new ArrayList<>();
for(String s:zfNumMap.keySet()){
StatisticsIndicator zf=new StatisticsIndicator();
if((s!=null)&& (!s.equals("null"))) {
zf.setName(zfNameMap.get(Long.valueOf(s)));
zf.setNumInt(zfNumMap.get(s));
zfNumList.add(zf);
}
}
zfNum.setName("执法人员检查次数");
zfNum.setStatisticsIndicatorList(zfNumList);
statisticsIndicatorList2.add(zfryAll);
statisticsIndicatorList2.add(haveZfN);
statisticsIndicatorList2.add(haveZf);
statisticsIndicatorList2.add(haveNotZf);
statisticsIndicatorList2.add(zfNum);
System.out.println(statisticsIndicatorList2);
//一级指标-检查事项:检查事项总数,二级指标-行政检查类别;二级指标-检查事项;二级指标-执法主体;二级指标-检查要求;二级指标-投诉比例;二级指标-联合检查占比
List<StatisticsIndicator> statisticsIndicatorList3=new ArrayList<>();
StatisticsIndicator jcsx=new StatisticsIndicator();
jcsx.setName("检查事项");
jcsx.setNumInt(zfjlList.size());
statisticsIndicatorList3.add(jcsx);
//二级指标-行政检查类别
Map<String,List<EnforcementRegistration>> xzjclbNumMap=zfjlList.stream().collect(Collectors.groupingBy(item->item.getCheckCategory()==null|| Objects.equals(item.getCheckCategory(), "") ?"空":item.getCheckCategory()));
DictData dictData=new DictData();
dictData.setDictType("check_category");
List<DictData> dictDataList=dictDataMapper.selectDictDataList(dictData);
Map<Long,String>dictDataMap=dictDataList.stream().collect(Collectors.toMap(DictData::getDictSort,DictData::getDictLabel));
List<StatisticsIndicator>xzjclbList=new ArrayList<>();
for(String s: xzjclbNumMap.keySet()){
if(s!=null){
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
if(!s.equals("空")) {
//当字典里有时则赋字典值,若没有则赋原值
statisticsIndicator.setName(dictDataMap.getOrDefault(Long.valueOf(s), s));
}else {
statisticsIndicator.setName("空");
}
statisticsIndicator.setNumInt(xzjclbNumMap.get(s).size());
xzjclbList.add(statisticsIndicator);
}
}
StatisticsIndicator xzjclb=new StatisticsIndicator();
xzjclb.setName("行政检查类别");
xzjclb.setStatisticsIndicatorList(xzjclbList);
statisticsIndicatorList3.add(xzjclb);
//二级指标-检查事项
Map<String,List<EnforcementRegistration>>jcsxNumMap=zfjlList.stream().collect(Collectors.groupingBy(item->item.getLawEnforcementItemText()==null|| Objects.equals(item.getLawEnforcementItemText(), "") ?"空":item.getLawEnforcementItemText()));
List<StatisticsIndicator>jcsxList=new ArrayList<>();
for (String s:jcsxNumMap.keySet()){
if(s!=null){
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
statisticsIndicator.setName(s);
statisticsIndicator.setNumInt(jcsxNumMap.get(s).size());
jcsxList.add(statisticsIndicator);
}
}
StatisticsIndicator jcsx2=new StatisticsIndicator();
jcsx2.setName("检查事项");
jcsx2.setStatisticsIndicatorList(jcsxList);
statisticsIndicatorList3.add(jcsx2);
//二级指标-执法主体**
Map<String,Long> zfztNumMap=zfjlList.stream().collect(Collectors.groupingBy(item->item.getBureauDeptId()==null|| Objects.equals(item.getBureauDeptId(), "")?"空":item.getBureauDeptId(),Collectors.counting()));
//deptNamemap
List<StatisticsIndicator> zfztList=new ArrayList<>();
for(String s:zfztNumMap.keySet()){
if(s!=null){
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
if(!s.equals("空")) {
//由于该部门map已被滤掉停用的
if(deptNamemap.containsKey(s)) {
statisticsIndicator.setName(deptNamemap.get(s));
}else {
statisticsIndicator.setName(s+"已停用");
}
statisticsIndicator.setNumInt(Math.toIntExact(zfztNumMap.get(s)));
zfztList.add(statisticsIndicator);
}else {
statisticsIndicator.setName("空");
statisticsIndicator.setNumInt(Math.toIntExact(zfztNumMap.get(s)));
zfztList.add(statisticsIndicator);
}
}
}
StatisticsIndicator zfzt=new StatisticsIndicator();
zfzt.setName("执法主体检查次数");
zfzt.setStatisticsIndicatorList(zfztList);
statisticsIndicatorList3.add(zfzt);
//二级指标-检查事项投诉
Map<Integer,List<EnforcementRegistration>>jcsxtsNumMap=zfjlList.stream().collect(Collectors.groupingBy(EnforcementRegistration::getIsComplaint));
List<StatisticsIndicator>jcsxtsList=new ArrayList<>();
System.out.println(jcsxtsNumMap.keySet());
for (int s:jcsxtsNumMap.keySet()){
if (s == 0) {
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
statisticsIndicator.setName("未被投诉占比");
Double num = (double) jcsxtsNumMap.get(0).size() / zfjlList.size();
statisticsIndicator.setNumDouble(num);
jcsxtsList.add(statisticsIndicator);
} else {
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
statisticsIndicator.setName("被投诉占比");
Double num = (double) jcsxtsNumMap.get(1).size() / zfjlList.size();
statisticsIndicator.setNumDouble(num);
jcsxtsList.add(statisticsIndicator);
}
}
StatisticsIndicator jcsxts=new StatisticsIndicator();
jcsxts.setName("检查事项投诉占比");
jcsxts.setStatisticsIndicatorList(jcsxtsList);
statisticsIndicatorList3.add(jcsxts);
//二级指标-联合检查占比
Map<Boolean,List<EnforcementRegistration>>sxlhjcNumMap=zfjlList.stream().collect(Collectors.partitioningBy(item->item.getUniteCheck()!=null&& !item.getUniteCheck().equals("")));
List<StatisticsIndicator>sxlhjcList=new ArrayList<>();
for (Boolean s:sxlhjcNumMap.keySet()){
if(s!=null) {
if (s) {
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
statisticsIndicator.setName("联合检查占比");
Double num = (double) sxlhjcNumMap.get(true).size() / zfjlList.size();
statisticsIndicator.setNumDouble(num);
sxlhjcList.add(statisticsIndicator);
} else {
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
statisticsIndicator.setName("非联合检查占比");
Double num = (double) sxlhjcNumMap.get(false).size() / zfjlList.size();
statisticsIndicator.setNumDouble(num);
sxlhjcList.add(statisticsIndicator);
}
}
}
StatisticsIndicator sxlhjc=new StatisticsIndicator();
sxlhjc.setName("联合检查占比");
sxlhjc.setStatisticsIndicatorList(sxlhjcList);
statisticsIndicatorList3.add(sxlhjc);
//一级指标-执法主体;二级指标-执法主体检查次数
List<StatisticsIndicator> statisticsIndicatorList5=new ArrayList<>();
StatisticsIndicator zfztAll=new StatisticsIndicator();
zfztAll.setName("执法主体");
zfztAll.setNumInt(zfjlList.size());
statisticsIndicatorList5.add(zfztAll);
/* Map<String,Long> zfztNumMap=zfjlList.stream().collect(Collectors.groupingBy(item->item.getBureauDeptId()==null|| Objects.equals(item.getBureauDeptId(), "")?"空":item.getBureauDeptId(),Collectors.counting()));
//deptNamemap
List<StatisticsIndicator> zfztList=new ArrayList<>();
for(String s:zfztNumMap.keySet()){
if(s!=null){
StatisticsIndicator statisticsIndicator = new StatisticsIndicator();
if(!s.equals("空")) {
statisticsIndicator.setName(deptNamemap.get(s));
System.out.println();
statisticsIndicator.setNumInt(Math.toIntExact(zfztNumMap.get(s)));
zfztList.add(statisticsIndicator);
}else {
statisticsIndicator.setName("空");
statisticsIndicator.setNumInt(Math.toIntExact(zfztNumMap.get(s)));
zfztList.add(statisticsIndicator);
}
}
}
StatisticsIndicator zfzt=new StatisticsIndicator();
zfzt.setName("执法主体检查次数");
zfzt.setStatisticsIndicatorList(zfztList);*/
statisticsIndicatorList5.add(zfzt);
System.out.println(statisticsIndicatorList5);
System.out.println(statisticsIndicatorList1);
System.out.println(statisticsIndicatorList2);
System.out.println(statisticsIndicatorList3);
System.out.println(statisticsIndicatorList4);
System.out.println(statisticsIndicatorList5);
List<List<StatisticsIndicator>> lists=new ArrayList<>();
lists.add(statisticsIndicatorList1);
lists.add(statisticsIndicatorList2);
lists.add(statisticsIndicatorList3);
lists.add(statisticsIndicatorList4);
lists.add(statisticsIndicatorList5);
return lists;
/* System.out.println("在线投诉数:"+enterpriseComplaintList.size());
List<StatisticsIndicator> statisticsIndicatorList=new ArrayList<>();
StatisticsIndicator s1=new StatisticsIndicator();
s1.setName("在线投诉数");
s1.setNumInt(enterpriseComplaintList.size());
statisticsIndicatorList.add(s1);
//以投诉类型分组,0:正常,1:联合投诉,2:入企不扫码投诉
StatisticsIndicator s2=new StatisticsIndicator();
s2.setName("普通投诉");
if(map1.containsKey(0)){
s2.setNumInt(map1.get(0).size());
} else {
s2.setNumInt(0);
}
statisticsIndicatorList.add(s2);
StatisticsIndicator s3=new StatisticsIndicator();
s3.setName("联合投诉");
if(map1.containsKey(1)){
s3.setNumInt(map1.get(1).size());
} else {
s3.setNumInt(0);
}
statisticsIndicatorList.add(s3);
StatisticsIndicator s4=new StatisticsIndicator();
s4.setName("入企不扫码投诉");
if(map1.containsKey(2)){
s4.setNumInt(map1.get(2).size());
} else {
s4.setNumInt(0);
}
statisticsIndicatorList.add(s4);
System.out.println(statisticsIndicatorList);
//System.out.println("普通投诉:"+map1.get(0).size()+"\n联合投诉:"+map1.get(1).size()+"\n入企不扫码投诉:"+map1.get(2).size());
if(map1.containsKey(1)){
System.out.println("联合投诉占比:"+String.format("%.2f",(double) map1.get(1).size() /enterpriseComplaintList.size()));
} else {
System.out.println("联合投诉占比:0");
}
//System.out.println("联合投诉占比:"+(map1.get(1).size()/enterpriseComplaintList.size()));
int bmtsNum=0;
//统计各部门投诉数
Map<String,Integer> map2=new HashMap<>();
for(int i=0;i<enterpriseComplaintList.size();i++){//遍历投诉列表
if(enterpriseComplaintList.get(i).getComplaintDepartmentIds()!=null) {
List<String> list = Arrays.asList(enterpriseComplaintList.get(i).getComplaintDepartmentIds().split(","));//将每条投诉取出,以“,”为分隔符
bmtsNum += list.size();
for (String str : list) {
if (map2.containsKey(str)) {
int num = map2.get(str) + 1;
map2.put(str, num);
} else {
map2.put(str, 1);
}
}
}
}
List<Dept> deptList=deptMapper.selectDeptList(new Dept());
System.out.println("部门总投诉数:"+bmtsNum+"\n各部门投诉占比如下:");
Map<String,String> deptNamemap=deptList.stream().collect(Collectors.toMap(Dept::getDeptId,Dept::getDeptName));
for(String dId:map2.keySet()){
//System.out.println((double)(intValue(map2.get(dId))/bmtsNum));
System.out.println(deptNamemap.get(dId)+":"+String.format("%.2f",((double)map2.get(dId)/bmtsNum)));
}
}*/
}
} }

6
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml

@ -438,5 +438,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY IFNULL(unite_check, RAND()) ,law_enforcement_id ) AS t1 GROUP BY IFNULL(unite_check, RAND()) ,law_enforcement_id ) AS t1
GROUP BY t1.enterprise_number GROUP BY t1.enterprise_number
</select> </select>
<select id="selectAllList" parameterType="EnforcementRegistration" resultMap="EnforcementRegistrationResult">
<include refid="selectEnforcementRegistrationVo"/>
where enterprise_number not like "92440300MACQUM2M9C"
</select>
</mapper> </mapper>
Loading…
Cancel
Save