|
|
|
@ -1,6 +1,10 @@ |
|
|
|
package com.zdxt.code.controller; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.Function; |
|
|
|
@ -15,6 +19,7 @@ import com.zdxt.common.util.TableDataInfo; |
|
|
|
import com.zdxt.domain.auth.DictData; |
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
@ -23,6 +28,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
import com.zdxt.code.domain.LawEnforcementWarningList; |
|
|
|
import com.zdxt.code.service.ILawEnforcementWarningListService; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
@ -64,6 +70,31 @@ public class LawEnforcementWarningListController extends BaseController |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/tips") |
|
|
|
@ResponseBody |
|
|
|
public List<Integer> tips(LawEnforcementWarningList lawEnforcementWarningList) |
|
|
|
{ |
|
|
|
List<LawEnforcementWarningList> list = lawEnforcementWarningListService.selectLawEnforcementWarningListListOrderByNumber(lawEnforcementWarningList); |
|
|
|
List<Integer> numList=new ArrayList<>(); |
|
|
|
numList.add(list.size()); |
|
|
|
Map<Integer,List<LawEnforcementWarningList>> map=list.stream().collect(Collectors.groupingBy(LawEnforcementWarningList::getWarningLevel)); |
|
|
|
Integer numLevel1=0; |
|
|
|
Integer numLevel2=0; |
|
|
|
Integer numLevel3=0; |
|
|
|
for(Integer i:map.keySet()){ |
|
|
|
if(i==3){ |
|
|
|
numLevel3+=map.get(i).size(); |
|
|
|
} else if (i==2) { |
|
|
|
numLevel2+=map.get(i).size(); |
|
|
|
} else if (i==1) { |
|
|
|
numLevel1+=map.get(i).size(); |
|
|
|
} |
|
|
|
} |
|
|
|
numList.add(numLevel3); |
|
|
|
numList.add(numLevel2); |
|
|
|
numList.add(numLevel1); |
|
|
|
return numList; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 查询执法预警列表列表 |
|
|
|
*/ |
|
|
|
@ -148,9 +179,9 @@ public class LawEnforcementWarningListController extends BaseController |
|
|
|
|
|
|
|
return prefix + "/registrationDetail"; |
|
|
|
} |
|
|
|
@PostMapping("/exportWarnList") |
|
|
|
@GetMapping("/exportWarnList") |
|
|
|
@ResponseBody |
|
|
|
public void export(HttpServletResponse httpServletResponse, @RequestBody LawEnforcementWarningList lawEnforcementWarningList) throws IOException { |
|
|
|
public void export(HttpServletResponse httpServletResponse,LawEnforcementWarningList lawEnforcementWarningList) throws IOException { |
|
|
|
List<LawEnforcementWarningList> lawEnforcementWarningListList=lawEnforcementWarningListService.selectLawEnforcementWarningListListOrderByNumber(lawEnforcementWarningList); |
|
|
|
List<DictData>dictDataList=dictDataMapper.selectDictDataByType("warnLevel"); |
|
|
|
Map<String,DictData> map=dictDataList.stream().collect(Collectors.toMap(DictData::getDictValue, Function.identity())); |
|
|
|
@ -158,6 +189,7 @@ public class LawEnforcementWarningListController extends BaseController |
|
|
|
HSSFSheet sheet = workbook.createSheet("预警列表"); |
|
|
|
//设置文件名称
|
|
|
|
String fileName = "预警列表.xls"; |
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8"); |
|
|
|
//自适应列宽
|
|
|
|
sheet.setDefaultColumnWidth(20);//全局
|
|
|
|
//表头样式
|
|
|
|
@ -176,9 +208,36 @@ public class LawEnforcementWarningListController extends BaseController |
|
|
|
styleRow2.setBorderBottom(BorderStyle.THIN); |
|
|
|
styleRow2.setBorderLeft(BorderStyle.THIN); |
|
|
|
styleRow2.setFont(font2); |
|
|
|
int top=0; |
|
|
|
DateTimeFormatter str=DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
|
if(lawEnforcementWarningList != null&&lawEnforcementWarningList.getBeginTime() != null&&!lawEnforcementWarningList.getBeginTime().equals("")&&lawEnforcementWarningList.getEndTime() != null&&!lawEnforcementWarningList.getEndTime().equals("")){ |
|
|
|
LocalDate beginTime= LocalDate.parse(lawEnforcementWarningList.getBeginTime(),str); |
|
|
|
LocalDate endTime=LocalDate.parse(lawEnforcementWarningList.getEndTime(),str); |
|
|
|
if(beginTime.getYear()==endTime.getYear()&&beginTime.getMonth()==beginTime.getMonth()){ |
|
|
|
Map<Integer,List<LawEnforcementWarningList>> listMap=lawEnforcementWarningListList.stream().collect(Collectors.groupingBy(LawEnforcementWarningList::getWarningLevel)); |
|
|
|
Integer numLevel1=0; |
|
|
|
Integer numLevel2=0; |
|
|
|
Integer numLevel3=0; |
|
|
|
for(Integer i:listMap.keySet()){ |
|
|
|
if(i==3){ |
|
|
|
numLevel3+=listMap.get(i).size(); |
|
|
|
} else if (i==2) { |
|
|
|
numLevel2+=listMap.get(i).size(); |
|
|
|
} else if (i==1) { |
|
|
|
numLevel1+=listMap.get(i).size(); |
|
|
|
} |
|
|
|
} |
|
|
|
HSSFRow headerRowTips = sheet.createRow(0); |
|
|
|
HSSFCell cellTips = headerRowTips.createCell(0); |
|
|
|
cellTips.setCellValue("被预警企业数"+lawEnforcementWarningListList.size()+"家 被检査次数:3~4次"+numLevel3+"家、5~6次"+numLevel2+"家、7次以上"+numLevel1+"家"); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(0,0,0,3)); |
|
|
|
cellTips.setCellStyle(styleRow2); |
|
|
|
top+=1; |
|
|
|
} |
|
|
|
} |
|
|
|
//设置表头
|
|
|
|
String[] headerList = {"企业名称","预警原因","预警等级","预警时间"}; |
|
|
|
HSSFRow headerRow = sheet.createRow(0); |
|
|
|
HSSFRow headerRow = sheet.createRow(0+top); |
|
|
|
for (int i = 0; i < headerList.length; i++) { |
|
|
|
HSSFCell cell = headerRow.createCell(i); |
|
|
|
HSSFRichTextString text = new HSSFRichTextString(headerList[i]); |
|
|
|
@ -189,7 +248,7 @@ public class LawEnforcementWarningListController extends BaseController |
|
|
|
HSSFDataFormat cellDataFormat= workbook.createDataFormat();; |
|
|
|
dateStyle.setDataFormat(cellDataFormat.getFormat("yyyy\"-\"m\"-\"d")); |
|
|
|
for(int i=0;i<lawEnforcementWarningListList.size();i++){ |
|
|
|
HSSFRow row = sheet.createRow(i+1); |
|
|
|
HSSFRow row = sheet.createRow(i+1+top); |
|
|
|
row.createCell(0).setCellValue(lawEnforcementWarningListList.get(i).getEnterpriseName()); |
|
|
|
row.createCell(1).setCellValue(lawEnforcementWarningListList.get(i).getWarningCause()); |
|
|
|
if(map.containsKey(lawEnforcementWarningListList.get(i).getWarningLevel()+"")){ |
|
|
|
@ -205,8 +264,10 @@ public class LawEnforcementWarningListController extends BaseController |
|
|
|
httpServletResponse.setCharacterEncoding("UTF-8"); |
|
|
|
httpServletResponse.setContentType("application/vnd.ms-excel"); |
|
|
|
httpServletResponse.setHeader("Content-disposition", "attachment;filename=" + fileName); |
|
|
|
httpServletResponse.flushBuffer(); |
|
|
|
workbook.write(httpServletResponse.getOutputStream()); |
|
|
|
/* httpServletResponse.flushBuffer(); |
|
|
|
workbook.write(httpServletResponse.getOutputStream());*/ |
|
|
|
ServletOutputStream outputStream = httpServletResponse.getOutputStream(); |
|
|
|
workbook.write(outputStream); |
|
|
|
workbook.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|