diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/LawEnforcementWarningList/LawEnforcementWarningList.html b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/LawEnforcementWarningList/LawEnforcementWarningList.html index 07f9eba2..6c531d05 100644 --- a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/LawEnforcementWarningList/LawEnforcementWarningList.html +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/LawEnforcementWarningList/LawEnforcementWarningList.html @@ -23,27 +23,28 @@ -
  • +
  • 预警时间:

    - + - - +
  • -
  • -  搜索 -  重置 +  搜索 +  重置 导出
  • -
    当月累计接受行政检查三至四次为黄色提示,五至六次为橙色提示,七次及以上为红色提示。
    +
    当筛选起止日期为同年同月时有统计
    +
    +
    × @@ -60,19 +61,29 @@ var prefix2 = ctx + "code/registration"; var warnLevel = [[${@dict.getType('warnLevel')}]]; window.onload = function () { + $("#tip").hide(); if(window.sessionStorage.getItem('registrationDetailVueGo')){ document.getElementById("enterpriseName").value=window.sessionStorage.getItem('lawEnforcementWarningList-enterpriseName'); document.getElementById("warningLevel").value=window.sessionStorage.getItem('lawEnforcementWarningList-warningLevel'); document.getElementById("startTime").value=window.sessionStorage.getItem('lawEnforcementWarningList-startTime'); document.getElementById("endTime").value=window.sessionStorage.getItem('lawEnforcementWarningList-endTime'); - $.table.search(); + // $.table.search(); + searchW(); sessionStorage.clear(); console.log(window.sessionStorage.getItem('lawEnforcementWarningList-enterpriseName')); console.log(window.sessionStorage.getItem('lawEnforcementWarningList-warningLevel')); console.log(window.sessionStorage.getItem('lawEnforcementWarningList-startTime')); console.log(window.sessionStorage.getItem('lawEnforcementWarningList-endTime')); + }else{ + searchW(); } } + function tipShow(){ + $("#tip").show(); + } + function tipHide(){ + $("#tip").hide(); + } $(function() { $('#detail2').hide(); var date = new Date(); @@ -80,11 +91,6 @@ var month = date.getMonth() + 1; $("input[name='currentMonth']").val(year + "-" + month); var options = { - url: prefix + "/list", - createUrl: prefix + "/add", - updateUrl: prefix + "/edit/{id}", - removeUrl: prefix + "/remove", - exportUrl: prefix + "/export", modalName: "执法预警列表", showHeader: true, showFooter: false, @@ -146,7 +152,8 @@ } ] }; - $.table.init(options); + // $.table.init(options); + $("#bootstrap-table").bootstrapTable(options); }); function getColor(){ var map=new Map([ @@ -217,10 +224,62 @@ }; $("#bootstrap-table3").bootstrapTable(options); }); - function downloadRW(){ + function searchW(){ + $("#tips").hide() + rTable() + tipsChange() + } + function rTable(){ var currentId=$('form').eq(0).attr('id'); var params = $.common.formToJSON(currentId); $.ajax({ + url: prefix + "/list", + method: 'post', + data:params, + success:function (response){ + $('#bootstrap-table').bootstrapTable('load', response); + data1=response; + console.log(data1); + },error:function (xhr,status,error){ + console.error("请求失败:",status,error); + } + }) + } + function resetW(){ + $('form').eq(0).trigger("reset"); + console.log($.common.formToJSON($('form').eq(0).attr('id'))); + searchW(); + } + + function tipsChange(){ + var beginTime=document.getElementById('startTime').value; + var endTime=document.getElementById('endTime').value; + if(beginTime!=null&&beginTime!=""&&endTime!=null&&endTime!=""){ + var beginDate=new Date(beginTime); + var endDate=new Date(endTime); + if(beginDate.getFullYear()==endDate.getFullYear()&&beginDate.getMonth()==endDate.getMonth()){ + var currentId=$('form').eq(0).attr('id'); + var params = $.common.formToJSON(currentId); + $.ajax({ + url: prefix + "/tips", + method: 'GET', + data:params, + success:function (response){ + console.log(response) + document.getElementById("tips").textContent = "被预警企业数"+response[0]+"家 被检査次数:3~4次"+response[1]+"家、5~6次"+response[2]+"家、7次以上"+response[3]+"家"; + $("#tips").show() + },error:function (xhr,status,error){ + console.error("请求失败:",status,error); + } + }) + } + } + } + + function downloadRW(){ + var currentId=$('form').eq(0).attr('id'); + var params = $.common.formToJSON(currentId); +/* $.ajax({ type: "POST", data: JSON.stringify(params), contentType: 'application/json', @@ -237,7 +296,21 @@ link.click(); document.body.removeChild(link) } - }) + })*/ + console.log(params) + let paramsList=[] + for(var key in params){ + if (params.hasOwnProperty(key)) { + var value = params[key]; + // 检查值是否为空 + if (value!== null && value!== undefined && value!== '') { + paramsList.push(key + '=' + value); + } + } + } + console.log(paramsList) + console.log(paramsList.join("&")) + window.location.href = prefix +"/exportWarnList?"+paramsList.join("&") } diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/LawEnforcementWarningListController.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/LawEnforcementWarningListController.java index 276ef827..50f5abd1 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/LawEnforcementWarningListController.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/LawEnforcementWarningListController.java @@ -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 tips(LawEnforcementWarningList lawEnforcementWarningList) + { + List list = lawEnforcementWarningListService.selectLawEnforcementWarningListListOrderByNumber(lawEnforcementWarningList); + List numList=new ArrayList<>(); + numList.add(list.size()); + Map> 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 lawEnforcementWarningListList=lawEnforcementWarningListService.selectLawEnforcementWarningListListOrderByNumber(lawEnforcementWarningList); ListdictDataList=dictDataMapper.selectDictDataByType("warnLevel"); Map 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> 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 and x.warning_time #{params.endWarningTime} + + and x.warning_time = ]]> #{beginTime} + + + and x.warning_time #{endTime} + AND x.warn_type = #{warnType} x.enforcement_department_id = #{enforcementDepartmentId},