|
|
|
@ -1,9 +1,11 @@ |
|
|
|
package com.zdxt.code.service.impl; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
@ -26,10 +28,14 @@ import com.zdxt.common.zdxtFile.AttFileRespDTO; |
|
|
|
import com.zdxt.common.zdxtFile.FilePreviewUtilBean; |
|
|
|
import com.zdxt.common.zdxtFile.ZdxtFileCommon; |
|
|
|
import com.zdxt.domain.auth.DictData; |
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.zdxt.code.mapper.EnforcementRegistrationMapper; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
/** |
|
|
|
* 执法端-执法登记Service业务层处理 |
|
|
|
* |
|
|
|
@ -724,4 +730,186 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void exportRegistration(HttpServletResponse response,EnforcementRegistration enforcementRegistration) throws IOException { |
|
|
|
List<EnforcementRegistration> enforcementRegistrationList=enforcementRegistrationListToExport(enforcementRegistration); |
|
|
|
List<DictData> dictDataList1=iDictDataService.selectDictDataByType("check_category"); |
|
|
|
Map<String,DictData> dictDataMap1=dictDataList1.stream().collect(Collectors.toMap(DictData::getDictValue, Function.identity())); |
|
|
|
List<DictData> dictDataList2=iDictDataService.selectDictDataByType("no-scan-reason"); |
|
|
|
Map<String,DictData> dictDataMap2=dictDataList2.stream().collect(Collectors.toMap(DictData::getDictValue, Function.identity())); |
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook(); |
|
|
|
HSSFSheet sheet = workbook.createSheet("执法检查统计"); |
|
|
|
//设置文件名称
|
|
|
|
String fileName = "员工信息" + LocalDate.now() + ".xls"; |
|
|
|
//设置表头
|
|
|
|
String[] headerList = {"区域", "街道", "执法部门", "执法人员","企业名称","检查事项","联合检查","行政检查类别","是否扫码","未扫码原因","是否投诉","检查时间"}; |
|
|
|
HSSFRow headerRow = sheet.createRow(0); |
|
|
|
for (int i = 0; i < headerList.length; i++) { |
|
|
|
HSSFCell cell = headerRow.createCell(i); |
|
|
|
HSSFRichTextString text = new HSSFRichTextString(headerList[i]); |
|
|
|
cell.setCellValue(text); |
|
|
|
} |
|
|
|
HSSFCellStyle dateStyle= workbook.createCellStyle(); |
|
|
|
HSSFDataFormat cellDataFormat= workbook.createDataFormat();; |
|
|
|
dateStyle.setDataFormat(cellDataFormat.getFormat("yyyy\"年\"m\"月\"d\"日\" h:mm:ss")); |
|
|
|
for(int i=0;i<enforcementRegistrationList.size();i++){ |
|
|
|
EnforcementRegistration e=enforcementRegistrationList.get(i); |
|
|
|
HSSFRow row = sheet.createRow(i+1); |
|
|
|
HSSFCell cell1 = row.createCell(0); |
|
|
|
cell1.setCellValue(e.getQy()); |
|
|
|
HSSFCell cell2 = row.createCell(1); |
|
|
|
cell2.setCellValue(e.getJd()); |
|
|
|
HSSFCell cell3 = row.createCell(2); |
|
|
|
cell3.setCellValue(e.getBureauDeptName()); |
|
|
|
HSSFCell cell4 = row.createCell(3); |
|
|
|
String name=""; |
|
|
|
if(!"".equals(e.getLawEnforcer())&&e.getLawEnforcer()!=null){ |
|
|
|
name=e.getLawEnforcer(); |
|
|
|
} |
|
|
|
if(!"".equals(e.getLawEnforcer())&&e.getLawEnforcer()!=null&&!"".equals(e.getLawEnforcerTwo())&&e.getLawEnforcerTwo()!=null){ |
|
|
|
name=name+","; |
|
|
|
} |
|
|
|
if(!"".equals(e.getLawEnforcerTwo())&&e.getLawEnforcerTwo()!=null){ |
|
|
|
name=name+e.getLawEnforcerTwo(); |
|
|
|
} |
|
|
|
cell4.setCellValue(name); |
|
|
|
HSSFCell cell5 = row.createCell(4); |
|
|
|
cell5.setCellValue(e.getEnterpriseName()); |
|
|
|
HSSFCell cell6 = row.createCell(5); |
|
|
|
cell6.setCellValue(e.getLawEnforcementItemText()); |
|
|
|
HSSFCell cell7 = row.createCell(6); |
|
|
|
if(e.getUniteCheck()!=null&&!"".equals(e.getUniteCheck())){ |
|
|
|
cell7.setCellValue("是"); |
|
|
|
}else { |
|
|
|
cell7.setCellValue("否"); |
|
|
|
} |
|
|
|
HSSFCell cell8 = row.createCell(7); |
|
|
|
if(dictDataMap1.containsKey(e.getCheckCategory())){ |
|
|
|
cell8.setCellValue(dictDataMap1.get(e.getCheckCategory()).getDictLabel()); |
|
|
|
} |
|
|
|
HSSFCell cell9 = row.createCell(8); |
|
|
|
if(e.getCheckCss()!=null&&!"".equals(e.getCheckCss())){ |
|
|
|
cell9.setCellValue("否"); |
|
|
|
}else { |
|
|
|
cell9.setCellValue("是"); |
|
|
|
} |
|
|
|
HSSFCell cell10 = row.createCell(9); |
|
|
|
if(dictDataMap2.containsKey(e.getCheckCss())){ |
|
|
|
cell10.setCellValue(dictDataMap2.get(e.getCheckCss()).getDictLabel()); |
|
|
|
} |
|
|
|
HSSFCell cell11 = row.createCell(10); |
|
|
|
if(e.getIsComplaint()==0){ |
|
|
|
cell11.setCellValue("否"); |
|
|
|
}else { |
|
|
|
cell11.setCellValue("是"); |
|
|
|
} |
|
|
|
HSSFCell cell12 = row.createCell(11 ); |
|
|
|
cell12.setCellValue(e.getCreateTime()); |
|
|
|
cell12.setCellStyle(dateStyle); |
|
|
|
} |
|
|
|
//设置流格式
|
|
|
|
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<EnforcementRegistration> enforcementRegistrationListToExport(EnforcementRegistration enforcementRegistration){ |
|
|
|
if(enforcementRegistration.getQy()!=null&&!"".equals(enforcementRegistration.getQy())){ |
|
|
|
if(enforcementRegistration.getJd()!=null&&!"".equals(enforcementRegistration.getJd())){ |
|
|
|
String qy=iDictDataService.selectDictLabel("address_Type",enforcementRegistration.getQy()); |
|
|
|
String jd=iDictDataService.selectDictLabel(enforcementRegistration.getQy(),enforcementRegistration.getJd()); |
|
|
|
enforcementRegistration.setJd(jd); |
|
|
|
enforcementRegistration.setQy(qy); |
|
|
|
List<EnforcementRegistration> list = enforcementRegistrationMapper.selectEnforcementRegistrationAndAddressList(enforcementRegistration); |
|
|
|
for(int i=0;i<list.size();i++){ |
|
|
|
list.get(i).setQy(qy); |
|
|
|
list.get(i).setJd(jd); |
|
|
|
} |
|
|
|
return list; |
|
|
|
}else { |
|
|
|
List<EnforcementRegistration> enforcementRegistrationList=new ArrayList<>(); |
|
|
|
String qy=iDictDataService.selectDictLabel("address_Type",enforcementRegistration.getQy()); |
|
|
|
List<DictData> jdList=iDictDataService.selectDictDataByType(enforcementRegistration.getQy()); |
|
|
|
enforcementRegistration.setQy(qy); |
|
|
|
List<EnforcementRegistration> list = enforcementRegistrationMapper.selectEnforcementRegistrationAndAddressList(enforcementRegistration); |
|
|
|
/*List<String> jdStrings=new ArrayList<>(); |
|
|
|
for(DictData dictData:jdList){ |
|
|
|
jdStrings.add(dictData.getDictLabel()); |
|
|
|
}*/ |
|
|
|
for(DictData jd:jdList){ |
|
|
|
List<EnforcementRegistration> jdEList=new ArrayList<>(); |
|
|
|
if(qy.equals("光明区")){ |
|
|
|
jdEList=list.stream().filter(item->item.getEnterpriseAddress().startsWith("深圳市光明新区"+jd.getDictLabel())||item.getEnterpriseAddress().startsWith("深圳市"+qy+jd.getDictLabel())).collect(Collectors.toList()); |
|
|
|
}else { |
|
|
|
jdEList=list.stream().filter(item->item.getEnterpriseAddress().startsWith("深圳市"+qy+jd.getDictLabel())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if(jdEList.size()>0){ |
|
|
|
for(int i=0;i<jdEList.size();i++){ |
|
|
|
jdEList.get(i).setQy(qy); |
|
|
|
jdEList.get(i).setJd(jd.getDictLabel()); |
|
|
|
} |
|
|
|
enforcementRegistrationList.addAll(jdEList); |
|
|
|
} |
|
|
|
} |
|
|
|
List<EnforcementRegistration>qtjdList=list.stream().filter(item->!jdMake(qy,jdList,item.getEnterpriseAddress())).collect(Collectors.toList()); |
|
|
|
if(qtjdList.size()>0){ |
|
|
|
for(int i=0;i<qtjdList.size();i++){ |
|
|
|
qtjdList.get(i).setQy(qy); |
|
|
|
} |
|
|
|
enforcementRegistrationList.addAll(qtjdList); |
|
|
|
} |
|
|
|
return enforcementRegistrationList; |
|
|
|
} |
|
|
|
}else { |
|
|
|
List<DictData> qyList=iDictDataService.selectDictDataByType("address_Type"); |
|
|
|
List<String> qyStrings=new ArrayList<>(); |
|
|
|
for(DictData dictData:qyList){ |
|
|
|
qyStrings.add(dictData.getDictLabel()); |
|
|
|
} |
|
|
|
List<EnforcementRegistration> list = enforcementRegistrationMapper.selectEnforcementRegistrationAndAddressList(enforcementRegistration); |
|
|
|
List<EnforcementRegistration> enforcementRegistrationsList=new ArrayList<>(); |
|
|
|
for(DictData qy:qyList){ |
|
|
|
List<DictData> jdList=iDictDataService.selectDictDataByType(qy.getDictValue()); |
|
|
|
/*List<String> jdStrings=new ArrayList<>(); |
|
|
|
for(DictData dictData:jdList){ |
|
|
|
jdStrings.add(dictData.getDictLabel()); |
|
|
|
}*/ |
|
|
|
List<EnforcementRegistration> qyEList=new ArrayList<>(); |
|
|
|
if(qy.getDictLabel().equals("光明区")){ |
|
|
|
qyEList=list.stream().filter(item->item.getEnterpriseAddress().startsWith("深圳市光明新区")||item.getEnterpriseAddress().startsWith("深圳市"+qy.getDictLabel())).collect(Collectors.toList()); |
|
|
|
}else { |
|
|
|
qyEList=list.stream().filter(item->item.getEnterpriseAddress().startsWith("深圳市"+qy.getDictLabel())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
for(DictData jd:jdList){ |
|
|
|
List<EnforcementRegistration> jdEList=new ArrayList<>(); |
|
|
|
if(qy.getDictLabel().equals("光明区")){ |
|
|
|
jdEList=qyEList.stream().filter(item->item.getEnterpriseAddress().startsWith("深圳市光明新区"+jd.getDictLabel())||item.getEnterpriseAddress().startsWith("深圳市"+qy.getDictLabel()+jd.getDictLabel())).collect(Collectors.toList()); |
|
|
|
}else { |
|
|
|
jdEList=qyEList.stream().filter(item->item.getEnterpriseAddress().startsWith("深圳市"+qy.getDictLabel()+jd.getDictLabel())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if(jdEList.size()>0){ |
|
|
|
for(int i=0;i<jdEList.size();i++){ |
|
|
|
jdEList.get(i).setQy(qy.getDictLabel()); |
|
|
|
jdEList.get(i).setJd(jd.getDictLabel()); |
|
|
|
} |
|
|
|
enforcementRegistrationsList.addAll(jdEList); |
|
|
|
} |
|
|
|
} |
|
|
|
List<EnforcementRegistration>qtjdList=qyEList.stream().filter(item->!jdMake(qy.getDictLabel(),jdList,item.getEnterpriseAddress())).collect(Collectors.toList()); |
|
|
|
if(qtjdList.size()>0){ |
|
|
|
for(int i=0;i<qtjdList.size();i++){ |
|
|
|
qtjdList.get(i).setQy(qy.getDictLabel()); |
|
|
|
} |
|
|
|
enforcementRegistrationsList.addAll(qtjdList); |
|
|
|
} |
|
|
|
} |
|
|
|
List<EnforcementRegistration>qtqyList=list.stream().filter(item->!qyMake(qyStrings,item.getEnterpriseAddress())).collect(Collectors.toList()); |
|
|
|
if(qtqyList.size()>0){ |
|
|
|
enforcementRegistrationsList.addAll(qtqyList); |
|
|
|
} |
|
|
|
return enforcementRegistrationsList; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|