6 changed files with 564 additions and 0 deletions
@ -0,0 +1,71 @@ |
|||||
|
package com.zdxt.code.controller; |
||||
|
|
||||
|
|
||||
|
import cn.hutool.http.server.HttpServerResponse; |
||||
|
import com.zdxt.code.domain.EnforcementCheckStatistics; |
||||
|
import com.zdxt.code.service.EnforcementCheckStatisticsService; |
||||
|
import com.zdxt.common.ZDResponse; |
||||
|
import com.zdxt.common.controller.BaseController; |
||||
|
import org.apache.poi.hssf.usermodel.*; |
||||
|
import org.apache.poi.ss.usermodel.FillPatternType; |
||||
|
import org.apache.poi.ss.usermodel.IndexedColors; |
||||
|
import org.apache.poi.ss.util.CellRangeAddress; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
import org.springframework.web.context.request.RequestContextHolder; |
||||
|
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
|
||||
|
import javax.servlet.ServletOutputStream; |
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.io.*; |
||||
|
import java.io.File; |
||||
|
import java.io.IOException; |
||||
|
import java.net.URLEncoder; |
||||
|
import java.nio.charset.Charset; |
||||
|
import java.util.*; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 行政执法检查统计Controller |
||||
|
* |
||||
|
* @author zouyaxin |
||||
|
* @date 2024/8/29 |
||||
|
*/ |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/enforcementCheckStatistics") |
||||
|
public class EnforcementCheckStatisticsController extends BaseController { |
||||
|
private String prefix = "code/enforcementCheckStatistics"; |
||||
|
|
||||
|
@Autowired |
||||
|
private EnforcementCheckStatisticsService enforcementCheckStatisticsService; |
||||
|
|
||||
|
@GetMapping ("/queryList/{year}/{month}") |
||||
|
@ResponseBody |
||||
|
public void queryList(HttpServletResponse response, @PathVariable String year, @PathVariable String month) |
||||
|
{ |
||||
|
EnforcementCheckStatistics enforcementCheckStatistics=new EnforcementCheckStatistics(); |
||||
|
enforcementCheckStatistics.setYear(year); |
||||
|
enforcementCheckStatistics.setMonth(month); |
||||
|
//查出区下所有区的id
|
||||
|
List<EnforcementCheckStatistics> areaAllList=enforcementCheckStatisticsService.selectAllAreaList(); |
||||
|
//存放以区ip为键,该ip下的所有记录为值
|
||||
|
Map<String,List<EnforcementCheckStatistics>> list=new HashMap<>(); |
||||
|
for(int i=0;i<areaAllList.size();i++){ |
||||
|
areaAllList.get(i).setMonth(enforcementCheckStatistics.getMonth()); |
||||
|
areaAllList.get(i).setYear(enforcementCheckStatistics.getYear()); |
||||
|
EnforcementCheckStatistics enforcementCheckStatistics1=areaAllList.get(i); |
||||
|
//查找出该区下的所有执法记录
|
||||
|
List<EnforcementCheckStatistics> statisticslist = enforcementCheckStatisticsService.selectEnforcementCheckStatisticsList(enforcementCheckStatistics1); |
||||
|
//以区id为键,区下所有执法记录为值
|
||||
|
list.put(areaAllList.get(i).getDeptId(),statisticslist); |
||||
|
} |
||||
|
enforcementCheckStatisticsService.excelExport(response,enforcementCheckStatistics,areaAllList,list); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
package com.zdxt.code.domain; |
||||
|
|
||||
|
import com.zdxt.common.BaseDomain; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
@Data |
||||
|
public class EnforcementCheckStatistics extends BaseDomain { |
||||
|
/** 主键ID */ |
||||
|
private String id; |
||||
|
/** 局级部门(主体) */ |
||||
|
private String bureauDeptName; |
||||
|
/** 局级部门id(主体) */ |
||||
|
private String bureauDeptId; |
||||
|
/** 被执法企业 */ |
||||
|
private String enterpriseName; |
||||
|
/** 被执法企业纳税识别号 */ |
||||
|
private String enterpriseNumber; |
||||
|
/** 执法部门id */ |
||||
|
private String lawEnforcementId; |
||||
|
/* *//** 执法人员姓名1 *//* |
||||
|
private String lawEnforcer; |
||||
|
*//** 执法人员姓名2 *//*
|
||||
|
private String lawEnforcerTwo;*/ |
||||
|
/** 执法人员姓名2 */ |
||||
|
private String lawEnforcerTwo; |
||||
|
/** 检查事项 */ |
||||
|
private String lawEnforcementItem; |
||||
|
/** 区域 */ |
||||
|
private String deptName; |
||||
|
/** 备注 */ |
||||
|
private String remark; |
||||
|
/** 区域id */ |
||||
|
private String deptId; |
||||
|
/** 预警次数 */ |
||||
|
private String Num; |
||||
|
/** 筛查年份 */ |
||||
|
private String year; |
||||
|
/** 筛查月份 */ |
||||
|
private String month; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
package com.zdxt.code.mapper; |
||||
|
|
||||
|
import com.zdxt.code.domain.EnforcementCheckStatistics; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
public interface EnforcementCheckStatisticsMapper { |
||||
|
/** |
||||
|
* 查询行政执法检查统计 |
||||
|
* |
||||
|
* @param enforcementCheckStatistics |
||||
|
* @return List |
||||
|
*/ |
||||
|
public List<EnforcementCheckStatistics> selectEnforcementCheckStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics); |
||||
|
|
||||
|
/** |
||||
|
* 查询所有区的id和name |
||||
|
* @param |
||||
|
* @return List |
||||
|
*/ |
||||
|
public List<EnforcementCheckStatistics> selectAllAreaList(); |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.zdxt.code.service; |
||||
|
|
||||
|
import cn.hutool.http.server.HttpServerResponse; |
||||
|
import com.zdxt.code.domain.EnforcementCheckStatistics; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public interface EnforcementCheckStatisticsService { |
||||
|
/** |
||||
|
*查询该区下的所有执法记录 |
||||
|
*/ |
||||
|
public List<EnforcementCheckStatistics> selectEnforcementCheckStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics); |
||||
|
/** |
||||
|
*查询区下的所有执法部门 |
||||
|
*/ |
||||
|
public List<EnforcementCheckStatistics> selectAllAreaList(); |
||||
|
/** |
||||
|
*excel导出 |
||||
|
*/ |
||||
|
public void excelExport(HttpServletResponse response, EnforcementCheckStatistics enforcementCheckStatistics, List<EnforcementCheckStatistics> areaAllList, Map<String, List<EnforcementCheckStatistics>> list); |
||||
|
} |
||||
@ -0,0 +1,368 @@ |
|||||
|
package com.zdxt.code.service.impl; |
||||
|
|
||||
|
import cn.hutool.http.server.HttpServerResponse; |
||||
|
import com.zdxt.code.domain.EnforcementCheckStatistics; |
||||
|
import com.zdxt.code.mapper.EnforcementCheckStatisticsMapper; |
||||
|
|
||||
|
import com.zdxt.code.service.EnforcementCheckStatisticsService; |
||||
|
import org.apache.poi.hssf.usermodel.*; |
||||
|
import org.apache.poi.ss.usermodel.*; |
||||
|
import org.apache.poi.ss.util.CellRangeAddress; |
||||
|
import org.apache.poi.ss.util.RegionUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.io.*; |
||||
|
import java.net.URLEncoder; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Service |
||||
|
public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatisticsService { |
||||
|
@Autowired |
||||
|
private EnforcementCheckStatisticsMapper enforcementCheckStatisticsMapper; |
||||
|
/** |
||||
|
*将样式应用到单元格 |
||||
|
*/ |
||||
|
private void setStyle(List<String> cellList,HSSFRow row,HSSFCellStyle styleRow3){ |
||||
|
for (int t=0;t<cellList.size();t++){ |
||||
|
HSSFCell cell= row.createCell(t); |
||||
|
cell.setCellValue(cellList.get(t)); |
||||
|
System.out.println(cellList.get(t)); |
||||
|
cell.setCellStyle(styleRow3); |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
*为合并的单元格修正样式 |
||||
|
*/ |
||||
|
private void hbStyle(int x1,int x2,int y1,int y2,HSSFSheet sheet){ |
||||
|
CellRangeAddress region=new CellRangeAddress(x1, x2,y1,y2); |
||||
|
RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); |
||||
|
RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); |
||||
|
RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); |
||||
|
RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); |
||||
|
} |
||||
|
/** |
||||
|
*查询该区下的所有执法记录 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<EnforcementCheckStatistics> selectEnforcementCheckStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics) { |
||||
|
return enforcementCheckStatisticsMapper.selectEnforcementCheckStatisticsList(enforcementCheckStatistics); |
||||
|
} |
||||
|
/** |
||||
|
*查询区下的所有执法部门 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<EnforcementCheckStatistics> selectAllAreaList() { |
||||
|
return enforcementCheckStatisticsMapper.selectAllAreaList(); |
||||
|
} |
||||
|
/** |
||||
|
*导出excel |
||||
|
*/ |
||||
|
@Override |
||||
|
public void excelExport(HttpServletResponse response, EnforcementCheckStatistics enforcementCheckStatistics, List<EnforcementCheckStatistics> areaAllList, Map<String, List<EnforcementCheckStatistics>> list){ |
||||
|
//创建HSSFWorkbook对象(excel文档对象)
|
||||
|
HSSFWorkbook wb=new HSSFWorkbook(); |
||||
|
//建立新的sheet对象(sheet:表单)
|
||||
|
HSSFSheet sheet= wb.createSheet("行政执法检查统计"+enforcementCheckStatistics.getMonth()+"月"); |
||||
|
//自适应列宽
|
||||
|
sheet.setDefaultColumnWidth(20);//全局
|
||||
|
sheet.setColumnWidth(0,2500);//某列
|
||||
|
sheet.setColumnWidth(1,2500); |
||||
|
//在sheet里创建第一行,参数为excel行数,0~65535
|
||||
|
HSSFRow row1=sheet.createRow(0); |
||||
|
//字体样式
|
||||
|
HSSFFont font1=wb.createFont(); |
||||
|
font1.setFontName("微软雅黑"); |
||||
|
font1.setBold(true); |
||||
|
font1.setFontHeightInPoints((short) 16); |
||||
|
HSSFFont font2=wb.createFont(); |
||||
|
font2.setFontName("微软雅黑"); |
||||
|
font2.setBold(true); |
||||
|
font2.setFontHeightInPoints((short) 11); |
||||
|
HSSFFont font3=wb.createFont(); |
||||
|
font2.setFontName("微软雅黑"); |
||||
|
font2.setFontHeightInPoints((short) 11); |
||||
|
//第一行样式
|
||||
|
HSSFCellStyle styleRow1=wb.createCellStyle(); |
||||
|
styleRow1.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
||||
|
styleRow1.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
||||
|
styleRow1.setAlignment(HorizontalAlignment.CENTER); |
||||
|
styleRow1.setVerticalAlignment(VerticalAlignment.CENTER); |
||||
|
styleRow1.setBorderTop(BorderStyle.THIN);//边框默认黑色
|
||||
|
styleRow1.setBorderRight(BorderStyle.THIN); |
||||
|
styleRow1.setBorderBottom(BorderStyle.THIN); |
||||
|
styleRow1.setBorderLeft(BorderStyle.THIN); |
||||
|
styleRow1.setFont(font1); |
||||
|
//第二行样式
|
||||
|
HSSFCellStyle styleRow2=wb.createCellStyle(); |
||||
|
styleRow2.setWrapText(true);//换行
|
||||
|
styleRow2.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
||||
|
styleRow2.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
||||
|
styleRow2.setAlignment(HorizontalAlignment.CENTER); |
||||
|
styleRow2.setVerticalAlignment(VerticalAlignment.CENTER); |
||||
|
styleRow2.setBorderTop(BorderStyle.THIN); |
||||
|
styleRow2.setBorderRight(BorderStyle.THIN); |
||||
|
styleRow2.setBorderBottom(BorderStyle.THIN); |
||||
|
styleRow2.setBorderLeft(BorderStyle.THIN); |
||||
|
styleRow2.setFont(font2); |
||||
|
//内容样式
|
||||
|
HSSFCellStyle styleRow3=wb.createCellStyle(); |
||||
|
styleRow3.setAlignment(HorizontalAlignment.CENTER); |
||||
|
styleRow3.setVerticalAlignment(VerticalAlignment.CENTER); |
||||
|
styleRow3.setBorderTop(BorderStyle.THIN); |
||||
|
styleRow3.setBorderRight(BorderStyle.THIN); |
||||
|
styleRow3.setBorderBottom(BorderStyle.THIN); |
||||
|
styleRow3.setBorderLeft(BorderStyle.THIN); |
||||
|
styleRow3.setFont(font3); |
||||
|
//创建单元格,参数为列数,0~255
|
||||
|
HSSFCell cell1=row1.createCell(0); |
||||
|
//修改单元格内容
|
||||
|
cell1.setCellValue(enforcementCheckStatistics.getMonth()+"月行政执法检查统计"); |
||||
|
//将单元格样式应用到该单元格
|
||||
|
cell1.setCellStyle(styleRow1); |
||||
|
//合并单元格--CellRangeAddress(起始行,结束行,起始列,结束列)
|
||||
|
sheet.addMergedRegion(new CellRangeAddress(0,0,0,11)); |
||||
|
//在sheet里创建第二行
|
||||
|
HSSFRow row2=sheet.createRow(1); |
||||
|
/* //创建单元格并设置单元格内容
|
||||
|
row2.createCell(0).setCellValue("序号"); |
||||
|
row2.createCell(1).setCellValue("区域"); |
||||
|
row2.createCell(2).setCellValue("企业"); |
||||
|
row2.createCell(3).setCellValue("执法主体"); |
||||
|
row2.createCell(4).setCellValue("执法人员"); |
||||
|
row2.createCell(5).setCellValue("检查事项"); |
||||
|
row2.createCell(6).setCellValue("执法检查次数"); |
||||
|
row2.createCell(7).setCellValue("2次及以下"); |
||||
|
row2.createCell(8).setCellValue("3至4次\n(黄色)"); |
||||
|
row2.createCell(9).setCellValue("5至6次\n(橙色)"); |
||||
|
row2.createCell(10).setCellValue("7次及以上\n(红色)"); |
||||
|
row2.createCell(11).setCellValue("备注");*/ |
||||
|
|
||||
|
List<String> headRow2List=new ArrayList<>(); |
||||
|
Collections.addAll(headRow2List,"序号","区域","企业","执法主体","执法人员","检查事项","执法检查次数", |
||||
|
"2次及以下","3至4次\n(黄色)","5至6次\n(橙色)","7次及以上\n(红色)","备注"); |
||||
|
setStyle(headRow2List,row2,styleRow2); |
||||
|
|
||||
|
int rowNum=1; |
||||
|
|
||||
|
for(int i=0;i<areaAllList.size();i++){//遍历地区list
|
||||
|
String area=areaAllList.get(i).getDeptName();//取出地区名
|
||||
|
List<EnforcementCheckStatistics> e=list.get(areaAllList.get(i).getDeptId());//取出该地区下的所有执法记录
|
||||
|
String enterpriseName1=null; |
||||
|
if(!e.isEmpty()){//判断执法记录是否为空
|
||||
|
if(e.size()>1){//当该区执法记录大于两条时才合并序号、区列
|
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+e.size(),0,0)); |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+e.size(),1,1)); |
||||
|
hbStyle(rowNum+1, rowNum+e.size(),0,0,sheet); |
||||
|
hbStyle(rowNum+1, rowNum+e.size(),1,1,sheet); |
||||
|
} |
||||
|
//非空时将执法以企业划分<企业税号,合计>
|
||||
|
Map<String,Long> qyGroup1=e.stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getEnterpriseNumber,Collectors.counting())); |
||||
|
//将以企业分好组的数据取出
|
||||
|
Map<String,List<EnforcementCheckStatistics>> qyGroup2=e.stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getEnterpriseNumber)); |
||||
|
for(String k:qyGroup2.keySet()){//同企业内遍历执法
|
||||
|
//if分组数<2则后续无需遍历
|
||||
|
if(qyGroup1.get(k)<2){ |
||||
|
HSSFRow row = sheet.createRow(++rowNum); |
||||
|
/* row.createCell(0).setCellValue(i+1); |
||||
|
row.createCell(1).setCellValue(area); |
||||
|
row.createCell(2).setCellValue(qyGroup2.get(k).get(0).getEnterpriseName()); |
||||
|
row.createCell(3).setCellValue(qyGroup2.get(k).get(0).getBureauDeptName()); |
||||
|
row.createCell(4).setCellValue(qyGroup2.get(k).get(0).getLawEnforcerTwo()); |
||||
|
row.createCell(5).setCellValue(qyGroup2.get(k).get(0).getLawEnforcementItem()); |
||||
|
row.createCell(6).setCellValue(1); |
||||
|
row.createCell(7).setCellValue(1); |
||||
|
row.createCell(11).setCellValue(qyGroup2.get(k).get(0).getRemark());*/ |
||||
|
List<String> cellList=new ArrayList<>(); |
||||
|
Collections.addAll(cellList,""+(i+1),area,qyGroup2.get(k).get(0).getEnterpriseName(),qyGroup2.get(k).get(0).getBureauDeptName(), |
||||
|
qyGroup2.get(k).get(0).getLawEnforcerTwo(),qyGroup2.get(k).get(0).getLawEnforcementItem(),"1", |
||||
|
"1","","","",qyGroup2.get(k).get(0).getRemark()); |
||||
|
setStyle(cellList,row,styleRow3); |
||||
|
}else { |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+qyGroup1.get(k)),2,2));//合并企业
|
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+qyGroup1.get(k)),7,7)); |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+qyGroup1.get(k)),8,8)); |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+qyGroup1.get(k)),9,9)); |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+qyGroup1.get(k)),10,10)); |
||||
|
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),2,2,sheet); |
||||
|
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),7,7,sheet); |
||||
|
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),8,8,sheet); |
||||
|
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),9,9,sheet); |
||||
|
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),10,10,sheet); |
||||
|
//以同企业内,以执法分组
|
||||
|
Map<String, Long> zfGroup1 = qyGroup2.get(k).stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getBureauDeptName, Collectors.counting())); |
||||
|
Map<String, List<EnforcementCheckStatistics>> zfGroup2 = qyGroup2.get(k).stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getBureauDeptName)); |
||||
|
for (String zf : zfGroup2.keySet()) { |
||||
|
//if 分组数<2则后续无需遍历
|
||||
|
if(zfGroup1.get(zf)<2){ |
||||
|
HSSFRow row = sheet.createRow(++rowNum); |
||||
|
/* row.createCell(0).setCellValue(i+1); |
||||
|
row.createCell(1).setCellValue(area); |
||||
|
row.createCell(2).setCellValue(zfGroup2.get(zf).get(0).getEnterpriseName()); |
||||
|
row.createCell(3).setCellValue(zfGroup2.get(zf).get(0).getBureauDeptName()); |
||||
|
row.createCell(4).setCellValue(zfGroup2.get(zf).get(0).getLawEnforcerTwo()); |
||||
|
row.createCell(5).setCellValue(zfGroup2.get(zf).get(0).getLawEnforcementItem()); |
||||
|
row.createCell(6).setCellValue(1); |
||||
|
row.createCell(11).setCellValue(zfGroup2.get(zf).get(0).getRemark());*/ |
||||
|
List<String> cellList=new ArrayList<>(); |
||||
|
if(qyGroup1.get(k)<3){ |
||||
|
//row.createCell(7).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,zfGroup2.get(zf).get(0).getEnterpriseName(),zfGroup2.get(zf).get(0).getBureauDeptName(), |
||||
|
zfGroup2.get(zf).get(0).getLawEnforcerTwo(),zfGroup2.get(zf).get(0).getLawEnforcementItem(),"1", |
||||
|
""+qyGroup1.get(k),"","","",zfGroup2.get(zf).get(0).getRemark()); |
||||
|
} else if (3<=qyGroup1.get(k)&&qyGroup1.get(k)<=4) { |
||||
|
//row.createCell(8).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,zfGroup2.get(zf).get(0).getEnterpriseName(),zfGroup2.get(zf).get(0).getBureauDeptName(), |
||||
|
zfGroup2.get(zf).get(0).getLawEnforcerTwo(),zfGroup2.get(zf).get(0).getLawEnforcementItem(),"1", |
||||
|
"",""+qyGroup1.get(k),"","",zfGroup2.get(zf).get(0).getRemark()); |
||||
|
} else if (5<=qyGroup1.get(k)&&qyGroup1.get(k)<=6) { |
||||
|
//row.createCell(9).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,zfGroup2.get(zf).get(0).getEnterpriseName(),zfGroup2.get(zf).get(0).getBureauDeptName(), |
||||
|
zfGroup2.get(zf).get(0).getLawEnforcerTwo(),zfGroup2.get(zf).get(0).getLawEnforcementItem(),"1", |
||||
|
"","",""+qyGroup1.get(k),"",zfGroup2.get(zf).get(0).getRemark()); |
||||
|
}else { |
||||
|
//row.createCell(10).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,zfGroup2.get(zf).get(0).getEnterpriseName(),zfGroup2.get(zf).get(0).getBureauDeptName(), |
||||
|
zfGroup2.get(zf).get(0).getLawEnforcerTwo(),zfGroup2.get(zf).get(0).getLawEnforcementItem(),"1", |
||||
|
"","","",""+qyGroup1.get(k),zfGroup2.get(zf).get(0).getRemark()); |
||||
|
} |
||||
|
setStyle(cellList,row,styleRow3); |
||||
|
}else{ |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+zfGroup1.get(zf)),3,3));//合并执法
|
||||
|
hbStyle(rowNum+1, (int) (rowNum+zfGroup1.get(zf)),3,3,sheet); |
||||
|
//以同企业、执法内,以执法人员分组
|
||||
|
Map<String, Long> ryGroup1 = zfGroup2.get(zf).stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getLawEnforcerTwo, Collectors.counting())); |
||||
|
Map<String, List<EnforcementCheckStatistics>> ryGroup2 = zfGroup2.get(zf).stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getLawEnforcerTwo)); |
||||
|
for (String ry : ryGroup2.keySet()) { |
||||
|
if(ryGroup1.get(ry)<2){ |
||||
|
HSSFRow row = sheet.createRow(++rowNum); |
||||
|
/* row.createCell(0).setCellValue(i+1); |
||||
|
row.createCell(1).setCellValue(area); |
||||
|
row.createCell(2).setCellValue(ryGroup2.get(ry).get(0).getEnterpriseName()); |
||||
|
row.createCell(3).setCellValue(ryGroup2.get(ry).get(0).getBureauDeptName()); |
||||
|
row.createCell(4).setCellValue(ryGroup2.get(ry).get(0).getLawEnforcerTwo()); |
||||
|
row.createCell(5).setCellValue(ryGroup2.get(ry).get(0).getLawEnforcementItem()); |
||||
|
row.createCell(6).setCellValue(1); |
||||
|
row.createCell(11).setCellValue(ryGroup2.get(ry).get(0).getRemark());*/ |
||||
|
List<String> cellList=new ArrayList<>(); |
||||
|
if(qyGroup1.get(k)<3){ |
||||
|
//row.createCell(7).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,ryGroup2.get(ry).get(0).getEnterpriseName(),ryGroup2.get(ry).get(0).getBureauDeptName(), |
||||
|
ryGroup2.get(ry).get(0).getLawEnforcerTwo(),ryGroup2.get(ry).get(0).getLawEnforcementItem(),"1", |
||||
|
""+qyGroup1.get(k),"","","",ryGroup2.get(ry).get(0).getRemark()); |
||||
|
} else if (3<=qyGroup1.get(k)&&qyGroup1.get(k)<=4) { |
||||
|
//row.createCell(8).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,ryGroup2.get(ry).get(0).getEnterpriseName(),ryGroup2.get(ry).get(0).getBureauDeptName(), |
||||
|
ryGroup2.get(ry).get(0).getLawEnforcerTwo(),ryGroup2.get(ry).get(0).getLawEnforcementItem(),"1", |
||||
|
"",""+qyGroup1.get(k),"","",ryGroup2.get(ry).get(0).getRemark()); |
||||
|
} else if (5<=qyGroup1.get(k)&&qyGroup1.get(k)<=6) { |
||||
|
//row.createCell(9).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,ryGroup2.get(ry).get(0).getEnterpriseName(),ryGroup2.get(ry).get(0).getBureauDeptName(), |
||||
|
ryGroup2.get(ry).get(0).getLawEnforcerTwo(),ryGroup2.get(ry).get(0).getLawEnforcementItem(),"1", |
||||
|
"","",""+qyGroup1.get(k),"",ryGroup2.get(ry).get(0).getRemark()); |
||||
|
}else { |
||||
|
//row.createCell(10).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,ryGroup2.get(ry).get(0).getEnterpriseName(),ryGroup2.get(ry).get(0).getBureauDeptName(), |
||||
|
ryGroup2.get(ry).get(0).getLawEnforcerTwo(),ryGroup2.get(ry).get(0).getLawEnforcementItem(),"1", |
||||
|
"","","",""+qyGroup1.get(k),ryGroup2.get(ry).get(0).getRemark()); |
||||
|
} |
||||
|
setStyle(cellList,row,styleRow3); |
||||
|
}else { |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, (int) (rowNum+ryGroup1.get(ry)),4,4));//合并人员
|
||||
|
hbStyle(rowNum+1, (int) (rowNum+ryGroup1.get(ry)),4,4,sheet); |
||||
|
//以同企业、执法、执法人员内,以执法事项分组
|
||||
|
Map<String, Long> sxGroup1 = ryGroup2.get(ry).stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getLawEnforcementItem, Collectors.counting())); |
||||
|
Map<String, List<EnforcementCheckStatistics>> sxGroup2 = ryGroup2.get(ry).stream().collect(Collectors.groupingBy(EnforcementCheckStatistics::getLawEnforcementItem)); |
||||
|
for (String sx : sxGroup2.keySet()) { |
||||
|
HSSFRow row = sheet.createRow(++rowNum); |
||||
|
/*row.createCell(0).setCellValue(i+1); |
||||
|
row.createCell(1).setCellValue(area); |
||||
|
row.createCell(2).setCellValue(sxGroup2.get(sx).get(0).getEnterpriseName()); |
||||
|
row.createCell(3).setCellValue(sxGroup2.get(sx).get(0).getBureauDeptName()); |
||||
|
row.createCell(4).setCellValue(sxGroup2.get(sx).get(0).getLawEnforcerTwo()); |
||||
|
row.createCell(5).setCellValue(sxGroup2.get(sx).get(0).getLawEnforcementItem()); |
||||
|
row.createCell(6).setCellValue(sxGroup1.get(sx)); |
||||
|
row.createCell(11).setCellValue(sxGroup2.get(sx).get(0).getRemark());*/ |
||||
|
List<String> cellList=new ArrayList<>(); |
||||
|
if(qyGroup1.get(k)<3){ |
||||
|
//row.createCell(7).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,sxGroup2.get(sx).get(0).getEnterpriseName(),sxGroup2.get(sx).get(0).getBureauDeptName(), |
||||
|
sxGroup2.get(sx).get(0).getLawEnforcerTwo(),sxGroup2.get(sx).get(0).getLawEnforcementItem(),"1", |
||||
|
""+qyGroup1.get(k),"","","",sxGroup2.get(sx).get(0).getRemark()); |
||||
|
} else if (3<=qyGroup1.get(k)&&qyGroup1.get(k)<=4) { |
||||
|
//row.createCell(8).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,sxGroup2.get(sx).get(0).getEnterpriseName(),sxGroup2.get(sx).get(0).getBureauDeptName(), |
||||
|
sxGroup2.get(sx).get(0).getLawEnforcerTwo(),sxGroup2.get(sx).get(0).getLawEnforcementItem(),"1", |
||||
|
"",""+qyGroup1.get(k),"","",sxGroup2.get(sx).get(0).getRemark()); |
||||
|
} else if (5<=qyGroup1.get(k)&&qyGroup1.get(k)<=6) { |
||||
|
//row.createCell(9).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,sxGroup2.get(sx).get(0).getEnterpriseName(),sxGroup2.get(sx).get(0).getBureauDeptName(), |
||||
|
sxGroup2.get(sx).get(0).getLawEnforcerTwo(),sxGroup2.get(sx).get(0).getLawEnforcementItem(),"1", |
||||
|
"","",""+qyGroup1.get(k),"",sxGroup2.get(sx).get(0).getRemark()); |
||||
|
}else { |
||||
|
//row.createCell(10).setCellValue(qyGroup1.get(k));
|
||||
|
Collections.addAll(cellList,""+(i+1),area,sxGroup2.get(sx).get(0).getEnterpriseName(),sxGroup2.get(sx).get(0).getBureauDeptName(), |
||||
|
sxGroup2.get(sx).get(0).getLawEnforcerTwo(),sxGroup2.get(sx).get(0).getLawEnforcementItem(),"1", |
||||
|
"","","",""+qyGroup1.get(k),sxGroup2.get(sx).get(0).getRemark()); |
||||
|
} |
||||
|
setStyle(cellList,row,styleRow3); |
||||
|
if (sxGroup1.get(sx) >= 2) { |
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum, (int) (rowNum - 1 + sxGroup1.get(sx)), 5, 5));//合并事项
|
||||
|
sheet.addMergedRegion(new CellRangeAddress(rowNum, (int) (rowNum - 1 + sxGroup1.get(sx)), 6, 6)); |
||||
|
hbStyle(rowNum, (int) (rowNum - 1 + sxGroup1.get(sx)), 5, 5,sheet); |
||||
|
hbStyle(rowNum, (int) (rowNum - 1 + sxGroup1.get(sx)), 6, 6,sheet); |
||||
|
hbStyle(rowNum, (int) (rowNum - 1 + sxGroup1.get(sx)), 11, 11,sheet); |
||||
|
rowNum = (int) (rowNum - 1 + sxGroup1.get(sx)); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}else{ |
||||
|
rowNum++; |
||||
|
HSSFRow row=sheet.createRow(rowNum); |
||||
|
List<String> cellList=new ArrayList<>(); |
||||
|
Collections.addAll(cellList,""+(i+1),area,"","","","","","","","","",""); |
||||
|
setStyle(cellList,row,styleRow3); |
||||
|
} |
||||
|
} |
||||
|
//输出Excel文件
|
||||
|
try { |
||||
|
//wb.write(new File("D:/code/执法监督码使用情况统计.xls"));
|
||||
|
FileOutputStream foutputStream = new FileOutputStream("执法监督码使用情况统计.xls"); |
||||
|
wb.write(foutputStream); |
||||
|
wb.close(); |
||||
|
foutputStream.close(); |
||||
|
response.setContentType("application/x-xls"); |
||||
|
response.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode("执法监督码使用情况统计.xls","utf-8")); |
||||
|
OutputStream outputStream = response.getOutputStream(); |
||||
|
FileInputStream fileInputStream = new FileInputStream(new File("执法监督码使用情况统计.xls")); |
||||
|
int length; |
||||
|
byte[] buffer = new byte[1024]; |
||||
|
while ((length = fileInputStream.read(buffer)) > 0) { |
||||
|
outputStream.write(buffer, 0, length); |
||||
|
} |
||||
|
fileInputStream.close(); |
||||
|
outputStream.flush(); |
||||
|
File file=new File("执法监督码使用情况统计.xls"); |
||||
|
if(file.delete()){ |
||||
|
System.out.println("本地删除成功"); |
||||
|
} |
||||
|
} catch (IOException e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper |
||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.zdxt.code.mapper.EnforcementCheckStatisticsMapper"> |
||||
|
<resultMap type="EnforcementCheckStatistics" id="EnforcementCheckStatisticsResult"> |
||||
|
<result property="id" column="id"/> |
||||
|
<result property="bureauDeptName" column="bureau_dept_name"/> |
||||
|
<result property="bureauDeptId" column="bureau_dept_id"/> |
||||
|
<result property="lawEnforcementId" column="law_enforcement_id"/> |
||||
|
<result property="enterpriseName" column="enterprise_name"/> |
||||
|
<result property="enterpriseNumber" column="enterprise_number"/> |
||||
|
<result property="lawEnforcementItem" column="law_enforcement_item"/> |
||||
|
<result property="deptName" column="dept_name"/> |
||||
|
<result property="remark" column="remark"/> |
||||
|
<result property="depId" column="dep_id"/> |
||||
|
|
||||
|
</resultMap> |
||||
|
|
||||
|
<select id="selectEnforcementCheckStatisticsList" parameterType="EnforcementCheckStatistics" resultMap="EnforcementCheckStatisticsResult"> |
||||
|
select e.bureau_dept_name,e.bureau_dept_id,e.law_enforcement_id,e.enterprise_number,e.enterprise_name,concat(e.law_enforcer,",",e.law_enforcer_two)as lawEnforcerTwo,e.law_enforcement_item,e.remark |
||||
|
from enforcement_registration e |
||||
|
inner join sys_dept s on e.law_enforcement_id=s.dept_id |
||||
|
inner join enterprise_information i on e.enterprise_number=i.enterprise_number |
||||
|
where find_in_set(#{deptId},s.ancestors) and (year(e.create_time)=#{year}) and (month(e.create_time)=#{month}) |
||||
|
order by e.enterprise_name |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectAllAreaList" parameterType="EnforcementCheckStatistics" resultMap="EnforcementCheckStatisticsResult"> |
||||
|
select dept_id,dept_Name from sys_dept where parent_id=(select dept_id from sys_dept where dept_Name="区") order by dept_id asc |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
Loading…
Reference in new issue