Browse Source

企业统计导出修改

v4
zouyx 2 years ago
parent
commit
ab59883e74
  1. 153
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticsEnterpriseController.java
  2. 2
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/StatisticsEnterpriseService.java
  3. 112
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticsEnterpriseServiceImpl.java

153
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/StatisticsEnterpriseController.java

@ -110,80 +110,6 @@ public class StatisticsEnterpriseController extends BaseController {
@GetMapping("/listQY")
@ResponseBody
public List<StatisticsIndicator> statisticsEnterpriseQY(SearchType searchType) {
/*List<DictData>dictDataList=iDictDataService.selectDictDataByType("address_type");//有序->区
Map<String,String> dictDataMap=dictDataList.stream().collect(Collectors.toMap(DictData::getDictValue,DictData::getDictLabel));
List<String> list=new ArrayList<>();//无序->深圳市+区
for(String s:dictDataMap.keySet()){
list.add("深圳市"+dictDataMap.get(s));
}
EnterpriseInformation enterpriseInformation=new EnterpriseInformation();
List<StatisticsIndicator> statisticsIndicatorList = new ArrayList<>();
if(searchType.getQy()!=null&&!"".equals(searchType.getQy())) {
String qy=iDictDataService.selectDictLabel("address_type",searchType.getQy());
enterpriseInformation.setEnterpriseAddress("深圳市" + qy);
if (searchType.getJd() != null && !"".equals(searchType.getJd())) {
String jd=iDictDataService.selectDictLabel(searchType.getQy(),searchType.getJd());
enterpriseInformation.setEnterpriseAddress("深圳市" + qy + jd);
}
List<EnterpriseInformation> enterpriseInformationList=new ArrayList<>();
if(qy.equals("光明区")){
//光明区
enterpriseInformationList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseInformation);
EnterpriseInformation e2=new EnterpriseInformation();
e2.setEnterpriseAddress("深圳市光明新区");
//光明新区
if (searchType.getJd() != null && !"".equals(searchType.getJd())) {
String jd=iDictDataService.selectDictLabel(searchType.getQy(),searchType.getJd());
e2.setEnterpriseAddress("深圳市光明新区" + jd);
}
List<EnterpriseInformation> e2List = iEnterpriseInformationService.selectEnterpriseInformationList1(e2);
enterpriseInformationList.addAll(e2List);
}else {
enterpriseInformationList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseInformation);
}
StatisticsIndicator s = new StatisticsIndicator();
List<EnterpriseInformation> existList = enterpriseInformationList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = enterpriseInformationList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
s.setName(qy);
s.setTotalNumber(enterpriseInformationList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
return statisticsIndicatorList;
}else {
List<EnterpriseInformation> enterpriseInformationList = iEnterpriseInformationService.selectEnterpriseInformationList1(new EnterpriseInformation());
for (DictData d : dictDataList) {
StatisticsIndicator s = new StatisticsIndicator();
String name = d.getDictLabel();
List<EnterpriseInformation> qyList = new ArrayList<>();//有序区--企业
if (name.equals("光明区")) {
qyList = enterpriseInformationList.stream().filter(item -> item.getEnterpriseAddress().startsWith("深圳市" + name) || item.getEnterpriseAddress().startsWith("深圳市光明新区")).collect(Collectors.toList());
} else {
qyList = enterpriseInformationList.stream().filter(item -> item.getEnterpriseAddress().startsWith("深圳市" + name)).collect(Collectors.toList());
}
List<EnterpriseInformation> existList = qyList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = qyList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
s.setName(name);
s.setTotalNumber(qyList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
}
List<EnterpriseInformation> qtList = enterpriseInformationList.stream().filter(item -> !qyMake(list, item.getEnterpriseAddress())).collect(Collectors.toList());
qtList = qtList.stream().filter(item -> !item.getEnterpriseAddress().startsWith("深圳市光明新区")).collect(Collectors.toList());
if (qtList != null && qtList.size() > 0) {
List<EnterpriseInformation> existList = qtList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = qtList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
StatisticsIndicator s = new StatisticsIndicator();
s.setName("其他");
s.setTotalNumber(qtList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
}
return statisticsIndicatorList;
}*/
return iEnterpriseInformationService.enterpriseInformationAllListToQY(searchType);
}
@ -191,78 +117,8 @@ public class StatisticsEnterpriseController extends BaseController {
@GetMapping("/listJD")
@ResponseBody
public List<StatisticsIndicator> statisticsEnterpriseJD(SearchType searchType) {
/*List<DictData>dictDataList=iDictDataService.selectDictDataByType("address_type");
Map<String,String> qyMap=dictDataList.stream().collect(Collectors.toMap(DictData::getDictLabel,DictData::getDictValue));
EnterpriseInformation enterpriseInformation=new EnterpriseInformation();
if(searchType.getQy()!=null&&!"".equals(searchType.getQy())){
enterpriseInformation.setEnterpriseAddress("深圳市"+searchType.getQy());
if(searchType.getJd()!=null&&!"".equals(searchType.getJd())){
enterpriseInformation.setEnterpriseAddress("深圳市"+searchType.getQy()+searchType.getJd());
}
}
List<EnterpriseInformation> enterpriseInformationList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseInformation);//所有企业
List<StatisticsIndicator> statisticsIndicatorList = new ArrayList<>();
if(qyMap.containsKey(searchType.getName())) {
List<DictData> jdDictList = iDictDataService.selectDictDataByType(qyMap.get(searchType.getName()));//有序街道
Map<String, String> jdMap = jdDictList.stream().collect(Collectors.toMap(DictData::getDictValue, DictData::getDictLabel));
if (searchType.getName().equals("光明区")) {//将该区内的过滤出来
enterpriseInformationList=enterpriseInformationList.stream().filter(item -> item.getEnterpriseAddress().startsWith("深圳市"+ searchType.getName())|| item.getEnterpriseAddress().startsWith("深圳市光明新区")).collect(Collectors.toList());
} else {
enterpriseInformationList=enterpriseInformationList.stream().filter(item -> item.getEnterpriseAddress().startsWith("深圳市"+ searchType.getName())).collect(Collectors.toList());
}
for (DictData d : jdDictList) {//遍历按序版的区域list
StatisticsIndicator s = new StatisticsIndicator();
String name = d.getDictLabel();
List<EnterpriseInformation> qyList = new ArrayList<>();
if (searchType.getName().equals("光明区")) {
qyList = enterpriseInformationList.stream().filter(item -> item.getEnterpriseAddress().startsWith("深圳市"+ searchType.getName() + name) || item.getEnterpriseAddress().startsWith("深圳市光明新区"+ name)).collect(Collectors.toList());
} else {
qyList = enterpriseInformationList.stream().filter(item -> item.getEnterpriseAddress().startsWith("深圳市"+ searchType.getName() + name)).collect(Collectors.toList());
}
List<EnterpriseInformation> existList = qyList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = qyList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
s.setName(name);
s.setAddress(searchType.getName());
s.setTotalNumber(qyList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
}
List<EnterpriseInformation> qtList=enterpriseInformationList.stream().filter(item->!jdMake(searchType.getName(),jdDictList,item.getEnterpriseAddress())).collect(Collectors.toList());
if(qtList!=null&&qtList.size()>0) {
List<EnterpriseInformation> existList = qtList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = qtList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
StatisticsIndicator s = new StatisticsIndicator();
s.setName("其他");
s.setAddress(searchType.getName());
s.setTotalNumber(qtList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
}
return statisticsIndicatorList;
}else {
Map<String,String> dictDataMap=dictDataList.stream().collect(Collectors.toMap(DictData::getDictValue,DictData::getDictLabel));
List<String> list=new ArrayList<>();//无序->深圳市+区
for(String s:dictDataMap.keySet()){
list.add("深圳市"+dictDataMap.get(s));
}
List<EnterpriseInformation> qtList=enterpriseInformationList.stream().filter(item->!qyMake(list,item.getEnterpriseAddress())).collect(Collectors.toList());
qtList = qtList.stream().filter(item -> !item.getEnterpriseAddress().startsWith("深圳市光明新区")).collect(Collectors.toList());
if(qtList!=null&&qtList.size()>0) {
List<EnterpriseInformation> existList = qtList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = qtList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
StatisticsIndicator s = new StatisticsIndicator();
s.setAddress("其他");
s.setTotalNumber(qtList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
}
return statisticsIndicatorList;
}*/
return iEnterpriseInformationService.enterpriseInformationAllListToJD(searchType);
}
return iEnterpriseInformationService.enterpriseInformationAllListToJD(searchType);
}
@RequiresPermissions("code:statisticsEnterprise:list")
@GetMapping("/type")
@ResponseBody
@ -335,13 +191,14 @@ public class StatisticsEnterpriseController extends BaseController {
@PostMapping("/export1")
@ResponseBody
public void export1(HttpServletResponse httpServletResponse,@RequestBody SearchType searchType) throws IOException {
if(searchType.getJd()!=null&&!"".equals(searchType.getJd())){
/*if(searchType.getJd()!=null&&!"".equals(searchType.getJd())){
searchType.setJd(iDictDataService.selectDictLabel(searchType.getQy(), searchType.getJd()));
}
if(searchType.getQy()!=null&&!"".equals(searchType.getQy())){
searchType.setQy(iDictDataService.selectDictLabel("address_type", searchType.getQy()));
}
statisticsEnterpriseService.qyAllList(httpServletResponse,searchType);
statisticsEnterpriseService.qyAllList(httpServletResponse,searchType);*/
statisticsEnterpriseService.export1(httpServletResponse, searchType);
}
@PostMapping("/export2")

2
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/StatisticsEnterpriseService.java

@ -12,4 +12,6 @@ public interface StatisticsEnterpriseService {
void qyAllList(HttpServletResponse response, SearchType searchType) throws IOException;
List<StatisticsIndicator> type(List<EnterpriseInformation> enterpriseInformationList);
void export1(HttpServletResponse response, SearchType searchType) throws IOException;
}

112
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/StatisticsEnterpriseServiceImpl.java

@ -1,5 +1,6 @@
package com.zdxt.code.service.impl;
import com.zdxt.auth.project.system.dict.mapper.DictDataMapper;
import com.zdxt.auth.project.system.dict.service.IDictDataService;
import com.zdxt.code.domain.EnterpriseInformation;
import com.zdxt.code.domain.SearchType;
@ -26,6 +27,10 @@ public class StatisticsEnterpriseServiceImpl implements StatisticsEnterpriseServ
private IDictDataService iDictDataService;
@Autowired
private EnterpriseInformationMapper enterpriseInformationMapper;
@Autowired
private IEnterpriseInformationService iEnterpriseInformationService;
@Autowired
private DictDataMapper dictDataMapper;
@Override
public void qyAllList(HttpServletResponse response, SearchType searchType) throws IOException {
@ -213,4 +218,111 @@ public class StatisticsEnterpriseServiceImpl implements StatisticsEnterpriseServ
}
return false;
}
@Override
public void export1(HttpServletResponse response, SearchType searchType) throws IOException {
//设置文件名称
String fileName = "企业数量统计.xls";
HSSFWorkbook workbook = new HSSFWorkbook();
//全市页
HSSFSheet sheet1 = workbook.createSheet("全市");
//自适应列宽
sheet1.setDefaultColumnWidth(20);//全局
//表头样式
HSSFFont font2=workbook.createFont();
font2.setFontName("微软雅黑");
font2.setBold(true);
font2.setFontHeightInPoints((short) 11);
HSSFCellStyle styleRow2=workbook.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);
//设置表头
String[] headerList = {"区域", "企业数量", "续存企业数量","注销企业数量"};
int qyRowNum=0;
HSSFRow headerRow = sheet1.createRow(qyRowNum);
qyRowNum++;
for (int i = 0; i < headerList.length; i++) {
HSSFCell headerCell = headerRow.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(headerList[i]);
headerCell.setCellValue(text);
headerCell.setCellStyle(styleRow2);
}
List<StatisticsIndicator> qyList=iEnterpriseInformationService.enterpriseInformationAllListToQY(searchType);
if(qyList.size()>0){
for(StatisticsIndicator s:qyList){
HSSFRow s1row= sheet1.createRow(qyRowNum);
s1row.createCell(0).setCellValue(s.getName());
s1row.createCell(1).setCellValue(s.getTotalNumber());
s1row.createCell(2).setCellValue(s.getNumInt());
s1row.createCell(3).setCellValue(s.getValue());
qyRowNum++;
//街道页
HSSFSheet sheet = workbook.createSheet(s.getName());
sheet.setDefaultColumnWidth(20);//全局
//设置表头
String[] hList = {"区域", "街道", "企业数量", "续存企业数量","注销企业数量"};
int jdRowNum=0;
HSSFRow hRow = sheet.createRow(jdRowNum);
jdRowNum++;
for (int i = 0; i < hList.length; i++) {
HSSFCell hCell = hRow.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(hList[i]);
hCell.setCellValue(text);
hCell.setCellStyle(styleRow2);
}
List<StatisticsIndicator> jdList=new ArrayList<>();
if(searchType.getJd()!=null&&!"".equals(searchType.getJd())){
jdList=jdListByJD(searchType);
}else {
SearchType searchType1=new SearchType();
searchType1.setName(s.getName());
jdList=iEnterpriseInformationService.enterpriseInformationAllListToJD(searchType1);
}
if(jdList.size()>0) {
for (StatisticsIndicator sjd : jdList) {
HSSFRow row = sheet.createRow(jdRowNum);
row.createCell(0).setCellValue(sjd.getAddress());
row.createCell(1).setCellValue(sjd.getName());
row.createCell(2).setCellValue(sjd.getTotalNumber());
row.createCell(3).setCellValue(sjd.getNumInt());
row.createCell(4).setCellValue(sjd.getValue());
jdRowNum++;
}
}
}
}
//设置流格式
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=" + fileName);
response.flushBuffer();
workbook.write(response.getOutputStream());
workbook.close();
}
private List<StatisticsIndicator> jdListByJD(SearchType searchType){
EnterpriseInformation enterpriseInformation=new EnterpriseInformation();
String qyName = dictDataMapper.selectDictLabel("address_type", searchType.getQy());
String jdName = dictDataMapper.selectDictLabel(searchType.getQy(), searchType.getJd());
enterpriseInformation.setJd(jdName);
enterpriseInformation.setQy(qyName);
List<EnterpriseInformation> jdList = iEnterpriseInformationService.selectEnterpriseInformationList1(enterpriseInformation);
List<EnterpriseInformation> existList = jdList.stream().filter(item -> item.getIsDelete() == 0).collect(Collectors.toList());
List<EnterpriseInformation> logoutList = jdList.stream().filter(item -> item.getIsDelete() == 1).collect(Collectors.toList());
List<StatisticsIndicator> statisticsIndicatorList=new ArrayList<>();
StatisticsIndicator s=new StatisticsIndicator();
s.setName(jdName);
s.setAddress(qyName);
s.setTotalNumber(jdList.size());
s.setNumInt(existList.size());
s.setValue(logoutList.size());
statisticsIndicatorList.add(s);
return statisticsIndicatorList;
}
}

Loading…
Cancel
Save