Browse Source

excel导出3

v3
zouyx 2 years ago
parent
commit
67dc574820
  1. 42
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementCheckStatisticsController.java
  2. 4
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/EnforcementCheckStatistics.java
  3. 7
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/EnforcementCheckStatisticsMapper.java
  4. 5
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/EnforcementCheckStatisticsService.java
  5. 23
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java
  6. 12
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementCheckStatisticsMapper.xml

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

@ -56,7 +56,7 @@ public class EnforcementCheckStatisticsController extends BaseController {
System.out.println(enforcementCheckStatistics); System.out.println(enforcementCheckStatistics);
//查出区下所有区的id //查出区下所有区的id
List<EnforcementCheckStatistics> areaAllList=enforcementCheckStatisticsService.selectAllAreaList(); List<EnforcementCheckStatistics> areaAllList=enforcementCheckStatisticsService.selectAllAreaList();
//存放以区ip为键,该ip下的所有记录为值 //存放以区id为键,该id下的所有记录为值
Map<String,List<EnforcementCheckStatistics>> list=new HashMap<>(); Map<String,List<EnforcementCheckStatistics>> list=new HashMap<>();
for(int i=0;i<areaAllList.size();i++) { for(int i=0;i<areaAllList.size();i++) {
areaAllList.get(i).setMonth(enforcementCheckStatistics.getMonth()); areaAllList.get(i).setMonth(enforcementCheckStatistics.getMonth());
@ -88,4 +88,44 @@ public class EnforcementCheckStatisticsController extends BaseController {
System.out.println(enterpriseStreetList); System.out.println(enterpriseStreetList);
enforcementCheckStatisticsService.excelExport2(response,enterpriseStreetList,enterpriseAddress); enforcementCheckStatisticsService.excelExport2(response,enterpriseStreetList,enterpriseAddress);
} }
@GetMapping ("/queryAllList/{year}/{month}")
@ResponseBody
public void queryAllList(HttpServletResponse response, @PathVariable String year, @PathVariable List<Integer> month)
{
EnforcementCheckStatistics enforcementCheckStatistics=new EnforcementCheckStatistics();
String month1=StringUtils.join(month,",");
enforcementCheckStatistics.setYear(year);
enforcementCheckStatistics.setMonth(month1);
List<EnforcementCheckStatistics> enforcementCheckStatisticsList=enforcementCheckStatisticsService.selectAllStatisticsList(enforcementCheckStatistics);
List<String> inOrderList=new ArrayList<>();
Collections.addAll(inOrderList,"福田区","罗湖区","盐田区","南山区","宝安区","龙岗区","龙华区",
"坪山区","光明区","大鹏新区","深汕特别合作区");
Map<String,List<EnforcementCheckStatistics>> enforcementCheckStatisticsMap=new HashMap<>();
for(int i=0;i<inOrderList.size();i++){
String area=inOrderList.get(i);
//List<EnforcementCheckStatistics> e1=enforcementCheckStatisticsList.stream().filter(item->item.getEnterpriseAddress().contains(area)).collect(Collectors.toList());
List<EnforcementCheckStatistics> e1=new ArrayList<>();
if(area.equals("光明区")){
//e1 = enforcementCheckStatisticsList.stream().collect(Collectors.groupingBy(item -> ((item.getEnterpriseAddress().contains(area)||(item.getEnterpriseAddress().contains("光明新区")))? area : "其他")));
e1=enforcementCheckStatisticsList.stream().filter(item->(item.getEnterpriseAddress().contains(area)||item.getEnterpriseAddress().contains("光明新区"))).collect(Collectors.toList());
}else {
// e1 = enforcementCheckStatisticsList.stream().collect(Collectors.groupingBy(item -> (item.getEnterpriseAddress().contains(area)? area : "其他")));
e1=enforcementCheckStatisticsList.stream().filter(item->item.getEnterpriseAddress().contains(area)).collect(Collectors.toList());
}
enforcementCheckStatisticsMap.put(area,e1);
}
List<EnforcementCheckStatistics> qt=enforcementCheckStatisticsList.stream().filter(item->!(
item.getEnterpriseAddress().contains("福田区")||item.getEnterpriseAddress().contains("罗湖区")||
item.getEnterpriseAddress().contains("盐田区")||item.getEnterpriseAddress().contains("南山区")||
item.getEnterpriseAddress().contains("宝安区")||item.getEnterpriseAddress().contains("龙岗区")||
item.getEnterpriseAddress().contains("龙华区")||item.getEnterpriseAddress().contains("坪山区")||
item.getEnterpriseAddress().contains("大鹏新区")||item.getEnterpriseAddress().contains("深汕特别合作区")||
item.getEnterpriseAddress().contains("光明区")||item.getEnterpriseAddress().contains("光明新区")))
.collect(Collectors.toList());
enforcementCheckStatisticsMap.put("其他",qt);
List<EnterpriseStreet> enterpriseStreet=enforcementCheckStatisticsService.selectEnterpriseStreetList();
inOrderList.add("其他");
enforcementCheckStatisticsService.excelExport(response,enforcementCheckStatistics,inOrderList,enforcementCheckStatisticsMap,enterpriseStreet);
}
} }

4
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/EnforcementCheckStatistics.java

@ -40,6 +40,6 @@ public class EnforcementCheckStatistics extends BaseDomain {
private String year; private String year;
/** 筛查月份 */ /** 筛查月份 */
private String month; private String month;
/** 企业地址 */
private String enterpriseAddress;
} }

7
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/EnforcementCheckStatisticsMapper.java

@ -31,4 +31,11 @@ public interface EnforcementCheckStatisticsMapper {
* @return List * @return List
*/ */
public List<EnforcementCheckStatistics> selectAllAreaList(); public List<EnforcementCheckStatistics> selectAllAreaList();
/**
* 查询所有执法检查记录
*
* @param enforcementCheckStatistics
* @return List
*/
public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics);
} }

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

@ -35,6 +35,11 @@ public interface EnforcementCheckStatisticsService {
*/ */
public List<EnterpriseStreet> selectEnterpriseName(EnterpriseStreet enterpriseStreet); public List<EnterpriseStreet> selectEnterpriseName(EnterpriseStreet enterpriseStreet);
/**
*查询所有执法记录
*/
public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics);
/** /**
*excel导出(执法监督码使用情况) *excel导出(执法监督码使用情况)
*/ */

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

@ -36,7 +36,7 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
for (int t=0;t<cellList.size();t++){ for (int t=0;t<cellList.size();t++){
HSSFCell cell= row.createCell(t); HSSFCell cell= row.createCell(t);
cell.setCellValue(cellList.get(t)); cell.setCellValue(cellList.get(t));
System.out.println(cellList.get(t)); //System.out.println(cellList.get(t));
cell.setCellStyle(styleRow3); cell.setCellStyle(styleRow3);
} }
} }
@ -87,6 +87,11 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
return enterpriseStreetMapper.selectEnterpriseName(enterpriseStreet); return enterpriseStreetMapper.selectEnterpriseName(enterpriseStreet);
} }
@Override
public List<EnforcementCheckStatistics> selectAllStatisticsList(EnforcementCheckStatistics enforcementCheckStatistics) {
return enforcementCheckStatisticsMapper.selectAllStatisticsList(enforcementCheckStatistics);
}
/** /**
*导出excel *导出excel
@ -113,8 +118,8 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
font2.setBold(true); font2.setBold(true);
font2.setFontHeightInPoints((short) 11); font2.setFontHeightInPoints((short) 11);
HSSFFont font3=wb.createFont(); HSSFFont font3=wb.createFont();
font2.setFontName("微软雅黑"); font3.setFontName("微软雅黑");
font2.setFontHeightInPoints((short) 11); font3.setFontHeightInPoints((short) 11);
//第一行样式 //第一行样式
HSSFCellStyle styleRow1=wb.createCellStyle(); HSSFCellStyle styleRow1=wb.createCellStyle();
styleRow1.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); styleRow1.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
@ -166,7 +171,7 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
//遍历地区list //遍历地区list
for(int i=0;i<inOrderList.size();i++){ for(int i=0;i<inOrderList.size();i++){
String area=inOrderList.get(i);//取出地区名 String area=inOrderList.get(i);//取出地区名
if(list.get(area)!=null){//判断该区执法记录是否为空 if((list.get(area)!=null) && (!list.get(area).isEmpty())){//判断该区执法记录是否为空
List<EnforcementCheckStatistics> e=list.get(area); List<EnforcementCheckStatistics> e=list.get(area);
if(e.size()>1){//当该区执法记录大于两条时才合并序号、区列 if(e.size()>1){//当该区执法记录大于两条时才合并序号、区列
sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+e.size(),0,0)); sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+e.size(),0,0));
@ -201,10 +206,10 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),9,9,sheet); hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),9,9,sheet);
hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),10,10,sheet); hbStyle(rowNum+1, (int) (rowNum+qyGroup1.get(k)),10,10,sheet);
//以同企业内,以执法分组 //以同企业内,以执法分组
Map<String, Long> zfGroup1 = qyGroup2.get(k).stream().collect(Collectors.groupingBy((m -> m.getDeptName()== null ? Map<String, Long> zfGroup1 = qyGroup2.get(k).stream().collect(Collectors.groupingBy((m -> m.getBureauDeptId()== null ?
"" : m.getDeptName()), Collectors.counting())); "" : m.getBureauDeptId()), Collectors.counting()));
Map<String, List<EnforcementCheckStatistics>> zfGroup2 = qyGroup2.get(k).stream().collect(Collectors.groupingBy(m -> m.getDeptName()== null ? Map<String, List<EnforcementCheckStatistics>> zfGroup2 = qyGroup2.get(k).stream().collect(Collectors.groupingBy(m -> m.getBureauDeptId()== null ?
"" : m.getDeptName())); "" : m.getBureauDeptId()));
for (String zf : zfGroup2.keySet()) { for (String zf : zfGroup2.keySet()) {
//if 分组数<2则后续无需遍历 //if 分组数<2则后续无需遍历
if(zfGroup1.get(zf)<2){ if(zfGroup1.get(zf)<2){
@ -324,7 +329,7 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic
"坪山区","光明区","大鹏新区","深汕特别合作区","其他"); "坪山区","光明区","大鹏新区","深汕特别合作区","其他");
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("深汕特别合作区")); //List<EnterpriseStreet> es1= (List<EnterpriseStreet>) map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,10).equals("深汕特别合作区"));
System.out.println("第317行:"+map1.get("其他")); //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= (List<EnterpriseStreet>) map1.get("其他").stream().filter(item->item.getEnterpriseAddress().substring(3,7).equals("大鹏新区"));

12
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementCheckStatisticsMapper.xml

@ -14,6 +14,7 @@
<result property="deptName" column="dept_name"/> <result property="deptName" column="dept_name"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
<result property="depId" column="dep_id"/> <result property="depId" column="dep_id"/>
<result property="enterpriseAddress" column="enterprise_address"/>
</resultMap> </resultMap>
<select id="selectEnforcementCheckStatisticsList" parameterType="EnforcementCheckStatistics" resultMap="EnforcementCheckStatisticsResult"> <select id="selectEnforcementCheckStatisticsList" parameterType="EnforcementCheckStatistics" resultMap="EnforcementCheckStatisticsResult">
@ -38,4 +39,15 @@
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 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> </select>
<select id="selectAllStatisticsList" parameterType="EnforcementCheckStatistics" resultMap="EnforcementCheckStatisticsResult">
select e.bureau_dept_name,e.bureau_dept_id,e.law_enforcement_id,e.enterprise_number,i.enterprise_name,concat(e.law_enforcer,",",e.law_enforcer_two)as lawEnforcerTwo,e.law_enforcement_item_text,e.remark,i.enterprise_address
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>
<if test="year != null and year != ''"> and year(e.create_time)=#{year}</if>
<if test="month != null and month != ''">and month(e.create_time)in(${month})</if>
</where>
order by e.enterprise_name
</select>
</mapper> </mapper>

Loading…
Cancel
Save