Commit e925771824aff35292183452b193b7dc3b2aa4b9

Authored by yiming
1 parent d5a1fab9

发车到站准确率统计

src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -23,6 +23,7 @@ import com.bsth.entity.mcy_forms.Singledata;
23 23 import com.bsth.entity.realcontrol.ScheduleRealInfo;
24 24 import com.bsth.service.report.ReportService;
25 25 import com.bsth.util.ReportUtils;
  26 +import javax.servlet.http.HttpServletResponse;
26 27  
27 28 @RestController
28 29 @RequestMapping("report")
... ... @@ -406,4 +407,9 @@ public class ReportController {
406 407 public Map<String, Object> calcDetailMonthlyE(@RequestParam Map<String,Object> map) {
407 408 return service.calcDetailMonthlyE(map);
408 409 }
  410 +
  411 + @RequestMapping(value = "/fcdzStatistics", method = RequestMethod.GET)
  412 + public Map<String,Object> fcdzStatistics(@RequestParam Map<String, Object> map, HttpServletResponse resp) {
  413 + return service.fcdzStatistics(map,resp);
  414 + }
409 415 }
... ...
src/main/java/com/bsth/service/report/ReportService.java
... ... @@ -8,6 +8,8 @@ import com.bsth.entity.excep.ArrivalInfo;
8 8 import com.bsth.entity.mcy_forms.Singledata;
9 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
10 10  
  11 +import javax.servlet.http.HttpServletResponse;
  12 +
11 13  
12 14 public interface ReportService {
13 15  
... ... @@ -68,4 +70,6 @@ public interface ReportService {
68 70 List<Map<String,Object>> singleEnergy(Map<String, Object> map);
69 71  
70 72 Map<String,Object> calcDetailMonthlyE(Map<String, Object> map);
  73 +
  74 + Map<String,Object> fcdzStatistics(Map<String, Object> map, HttpServletResponse resp);
71 75 }
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -30,6 +30,9 @@ import com.bsth.util.ReportUtils;
30 30 import com.bsth.util.db.DBUtils_MS;
31 31  
32 32 import org.apache.commons.lang.StringUtils;
  33 +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  34 +import org.apache.poi.ss.usermodel.*;
  35 +import org.apache.poi.ss.util.CellRangeAddress;
33 36 import org.slf4j.Logger;
34 37 import org.slf4j.LoggerFactory;
35 38 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -37,7 +40,12 @@ import org.springframework.jdbc.core.JdbcTemplate;
37 40 import org.springframework.jdbc.core.RowMapper;
38 41 import org.springframework.stereotype.Service;
39 42  
  43 +import javax.servlet.http.HttpServletResponse;
  44 +import java.io.IOException;
  45 +import java.io.OutputStream;
  46 +import java.io.UnsupportedEncodingException;
40 47 import java.math.BigDecimal;
  48 +import java.net.URLEncoder;
41 49 import java.sql.Connection;
42 50 import java.sql.PreparedStatement;
43 51 import java.sql.ResultSet;
... ... @@ -45,6 +53,9 @@ import java.sql.SQLException;
45 53 import java.text.DecimalFormat;
46 54 import java.text.ParseException;
47 55 import java.text.SimpleDateFormat;
  56 +import java.time.Duration;
  57 +import java.time.LocalTime;
  58 +import java.time.format.DateTimeFormatter;
48 59 import java.util.*;
49 60  
50 61 @Service
... ... @@ -4548,6 +4559,236 @@ public class ReportServiceImpl implements ReportService{
4548 4559 }
4549 4560 return shyy;
4550 4561 }
  4562 +
  4563 +
  4564 + @Override
  4565 + public Map<String,Object> fcdzStatistics(Map<String, Object> map, HttpServletResponse resp) {
  4566 + Map<String,Object> result = new HashMap<>();
  4567 + String line =map.get("line").toString();
  4568 + String startDate =map.get("startDate").toString();
  4569 + String endDate =map.get("endDate").toString();
  4570 + String gsdm =map.get("gsdm").toString();
  4571 + String fgsdm =map.get("fgsdm").toString();
  4572 + String type =map.get("type").toString();
  4573 +
  4574 + StringBuffer sql=new StringBuffer("select gs_name,fgs_name,xl_name,schedule_date_str,fcsj,fcsj_actual,zdsj,zdsj_actual,adjust_exps,remarks " +
  4575 + "from bsth_c_s_sp_info_real where bc_type not in ('in','out') and schedule_date_str >= '"+startDate+"' and schedule_date_str <= '"+endDate+"' ");
  4576 + if(!gsdm.trim().equals("")){
  4577 + sql.append(" and gs_bm ="+gsdm);
  4578 + }
  4579 + if(!fgsdm.trim().equals("")){
  4580 + sql.append(" and fgs_bm ="+fgsdm);
  4581 + }
  4582 + if(!line.trim().equals("")){
  4583 + sql.append(" and xl_bm ="+line);
  4584 + }
  4585 + sql.append(" order by schedule_date_str,xl_name,fcsj");
  4586 + List<Map<String, Object>> list = jdbcTemplate.queryForList(sql.toString());
  4587 + if (type.equals("query")) {
  4588 + int count=100;
  4589 + int page = Integer.parseInt(map.get("page").toString());
  4590 + //计算准确率
  4591 + result = zql(list);
  4592 + //计算页数
  4593 + int totalPages =list.size()/count+1;
  4594 + result.put("totalPages",totalPages);
  4595 + if(list.size()==0){
  4596 + result.put("list",list);
  4597 + }
  4598 + else if(page*count>list.size()){
  4599 + result.put("list",new ArrayList());
  4600 + }
  4601 + else if((page+1)*count>list.size()){
  4602 + result.put("list",list.subList(page*count,list.size()));
  4603 + }else {
  4604 + result.put("list",list.subList(page*count,(page+1)*count));
  4605 + }
  4606 + }
  4607 +
  4608 + if (type.equals("export")) {
  4609 + //创建excel工作簿
  4610 + Workbook wb = new HSSFWorkbook();
  4611 +
  4612 + Map<String, List<Map<String, Object>>> groupByLine = new HashMap<>();
  4613 + for (Map<String, Object> m : list) {
  4614 + String name = (String) m.get("xl_name");
  4615 + if (!groupByLine.containsKey(name)) {
  4616 + groupByLine.put(name, new ArrayList<>());
  4617 + }
  4618 + groupByLine.get(name).add(m);
  4619 + }
  4620 + Set<String> keys = groupByLine.keySet();
  4621 + for (String key : keys) {
  4622 + List<Map<String, Object>> v=groupByLine.get(key);
  4623 + if(v.size() > 0){
  4624 + Map<String,Object> m = zql(v);
  4625 + List<Map<String, Object>> listList= (List<Map<String, Object>>) m.get("list");
  4626 + //创建工作表
  4627 + Sheet sheet = wb.createSheet(key);
  4628 +
  4629 + //创建表头样式(加粗、居中)
  4630 + CellStyle headerStyle = wb.createCellStyle();
  4631 + Font headerFont = wb.createFont();
  4632 + headerFont.setBold(true);// 加粗
  4633 + headerFont.setFontHeightInPoints((short) 18);
  4634 + headerStyle.setFont(headerFont);
  4635 + headerStyle.setAlignment(CellStyle.ALIGN_CENTER); // 水平居中
  4636 + headerStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); // 垂直居中
  4637 + //创建表头行(第一行)
  4638 + Row headerRow = sheet.createRow(0);
  4639 +
  4640 + //合并单元格(例如合并 A1:C1 作为大标题)
  4641 + sheet.addMergedRegion(new CellRangeAddress(
  4642 + 0, 0, // 起始行和结束行(这里是第1行)
  4643 + 0, 9 // 起始列和结束列(0=A, 1=B, 2=C)
  4644 + ));
  4645 +
  4646 + //设置合并后的标题
  4647 + Cell mergedTitleCell = headerRow.createCell(0);
  4648 + mergedTitleCell.setCellValue("发车到站统计");
  4649 + mergedTitleCell.setCellStyle(headerStyle);
  4650 +
  4651 + //创建表头样式(加粗、居中)
  4652 + CellStyle titleStyle = wb.createCellStyle();
  4653 + Font titleFont = wb.createFont();
  4654 + titleFont.setBold(true);// 加粗
  4655 + titleFont.setFontHeightInPoints((short) 12);
  4656 + titleStyle.setFont(titleFont);
  4657 +
  4658 + //准点率
  4659 + Cell titleCell =headerRow.createCell(10);
  4660 + titleCell.setCellValue("发车准点率");
  4661 + titleCell.setCellStyle(titleStyle);
  4662 + headerRow.createCell(11).setCellValue(m.get("fczdl").toString());
  4663 + titleCell =headerRow.createCell(12);
  4664 + titleCell.setCellValue("到站准点率");
  4665 + titleCell.setCellStyle(titleStyle);
  4666 + headerRow.createCell(13).setCellValue(m.get("dzzdl").toString());
  4667 +
  4668 + //表头
  4669 + Row row = sheet.createRow(1);
  4670 + row.setHeight((short) (1.5 * 256));
  4671 + row.createCell(0).setCellValue("日期");
  4672 + row.createCell(1).setCellValue("公司");
  4673 + row.createCell(2).setCellValue("分公司");
  4674 + row.createCell(3).setCellValue("线路");
  4675 + row.createCell(4).setCellValue("计划发车时间");
  4676 + row.createCell(5).setCellValue("实际发车时间");
  4677 + row.createCell(6).setCellValue("计划到站时间");
  4678 + row.createCell(7).setCellValue("实际到站时间");
  4679 + row.createCell(8).setCellValue("烂班类型");
  4680 + row.createCell(9).setCellValue("备注");
  4681 + row.createCell(10).setCellValue("发车延迟");
  4682 + row.createCell(11).setCellValue("发车准点");
  4683 + row.createCell(12).setCellValue("到站延迟");
  4684 + row.createCell(13).setCellValue("到站准点");
  4685 +
  4686 + //设置列宽
  4687 + int cellNum=sheet.getRow(0).getLastCellNum();
  4688 + for (int i = 0; i < cellNum; i++) {
  4689 + sheet.setColumnWidth(i, 15 * 256);
  4690 + }
  4691 +
  4692 + Map<String, Object> schedule;
  4693 + for(int i = 0; i < listList.size(); i++){
  4694 + schedule = listList.get(i);
  4695 + row = sheet.createRow(i + 2);
  4696 + row.createCell(0).setCellValue(schedule.get("schedule_date_str").toString());
  4697 + row.createCell(1).setCellValue(schedule.get("gs_name").toString());
  4698 + row.createCell(2).setCellValue(schedule.get("fgs_name").toString());
  4699 + row.createCell(3).setCellValue(schedule.get("xl_name").toString());
  4700 + row.createCell(4).setCellValue(schedule.get("fcsj")!=null?schedule.get("fcsj").toString():"");
  4701 + row.createCell(5).setCellValue(schedule.get("fcsj_actual")!=null?schedule.get("fcsj_actual").toString():"");
  4702 + row.createCell(6).setCellValue(schedule.get("zdsj")!=null?schedule.get("zdsj").toString():"");
  4703 + row.createCell(7).setCellValue(schedule.get("zdsj_actual")!=null?schedule.get("zdsj_actual").toString():"");
  4704 + row.createCell(8).setCellValue(schedule.get("adjust_exps")!=null?schedule.get("adjust_exps").toString():"");
  4705 + row.createCell(9).setCellValue(schedule.get("remarks")!=null?schedule.get("remarks").toString():"");
  4706 + row.createCell(10).setCellValue(schedule.get("fcyc")!=null?schedule.get("fcyc").toString():"");
  4707 + row.createCell(11).setCellValue(schedule.get("fczd")!=null?schedule.get("fczd").toString():"");
  4708 + row.createCell(12).setCellValue(schedule.get("dzyc")!=null?schedule.get("dzyc").toString():"");
  4709 + row.createCell(13).setCellValue(schedule.get("dzzd")!=null?schedule.get("dzzd").toString():"");
  4710 + }
  4711 + }
  4712 + }
  4713 +
  4714 + String filename = "发车到站统计" + startDate +"~"+ endDate + ".xls";
  4715 + try {
  4716 + resp.setContentType("application/x-msdownload");
  4717 + resp.addHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
  4718 + OutputStream out=resp.getOutputStream();
  4719 + wb.write(out);
  4720 + out.flush();
  4721 + out.close();
  4722 + } catch (UnsupportedEncodingException e) {
  4723 + logger.error("", e);
  4724 + } catch (IOException e) {
  4725 + logger.error("", e);
  4726 + }
  4727 + }
  4728 + return result;
  4729 + }
  4730 +
  4731 + private static DecimalFormat df = new DecimalFormat("0.00");
  4732 + public static Map<String,Object> zql(List<Map<String, Object>> list){
  4733 + Map<String,Object> result = new HashMap<>();
  4734 + int fczs=0;
  4735 + int fczd=0;
  4736 + int dzzs=0;
  4737 + int dzzd=0;
  4738 + for (Map<String, Object> schedule : list) {
  4739 + String fcsj=schedule.get("fcsj")!=null?schedule.get("fcsj").toString():null;
  4740 + String fcsjActual=schedule.get("fcsj_actual")!=null?schedule.get("fcsj_actual").toString():null;
  4741 + if(fcsj!=null && fcsjActual!=null){
  4742 + fczs++;
  4743 + DateTimeFormatter dtf=DateTimeFormatter.ofPattern("HH:mm");
  4744 + LocalTime fc=LocalTime.parse(fcsj,dtf);
  4745 + LocalTime fca=LocalTime.parse(fcsjActual,dtf);
  4746 + // 计算时间差
  4747 + Duration duration = Duration.between(fc,fca);
  4748 + // 获取分钟数差异(包括正负)
  4749 + long minutes = duration.toMinutes();
  4750 + schedule.put("fcyc",minutes);
  4751 + if(minutes<-2 || minutes>5){
  4752 + schedule.put("fczd","不准点");
  4753 + }else {
  4754 + schedule.put("fczd","准点");
  4755 + fczd++;
  4756 + }
  4757 + }
  4758 + String zdsj=schedule.get("zdsj")!=null?schedule.get("zdsj").toString():null;
  4759 + String zdsjActual=schedule.get("zdsj_actual")!=null?schedule.get("zdsj_actual").toString():null;
  4760 + if(zdsj!=null && zdsjActual!=null){
  4761 + dzzs++;
  4762 + DateTimeFormatter dtf=DateTimeFormatter.ofPattern("HH:mm");
  4763 + LocalTime zd=LocalTime.parse(zdsj,dtf);
  4764 + LocalTime zda=LocalTime.parse(zdsjActual,dtf);
  4765 + // 计算时间差
  4766 + Duration duration = Duration.between(zd,zda);
  4767 + // 获取分钟数差异(包括正负)
  4768 + long minutes = duration.toMinutes();
  4769 + schedule.put("dzyc",minutes);
  4770 + if(minutes<-2 || minutes>5){
  4771 + schedule.put("dzzd","不准点");
  4772 + }else {
  4773 + schedule.put("dzzd","准点");
  4774 + dzzd++;
  4775 + }
  4776 + }
  4777 + }
  4778 + String fczdl="0.00";
  4779 + if(fczs>0){
  4780 + fczdl=df.format((double) fczd/fczs*100);
  4781 + }
  4782 + result.put("fczdl",fczdl);
  4783 +
  4784 + String dzzdl="0.00";
  4785 + if(fczs>0){
  4786 + dzzdl=df.format((double)dzzd/dzzs*100);
  4787 + }
  4788 + result.put("dzzdl",dzzdl);
  4789 + result.put("list",list);
  4790 + return result;
  4791 + }
4551 4792  
4552 4793 }
4553 4794  
... ...
src/main/resources/static/pages/report/fcdzStatistics.html 0 → 100644
  1 +<style type="text/css">
  2 +.table-bordered {
  3 + border: 1px solid;
  4 +}
  5 +
  6 +.table-bordered>thead>tr>th, .table-bordered>thead>tr>td,
  7 + .table-bordered>tbody>tr>th, .table-bordered>tbody>tr>td,
  8 + .table-bordered>tfoot>tr>th, .table-bordered>tfoot>tr>td {
  9 + border: 1px solid;
  10 +}
  11 +
  12 +.table-bordered>thead>tr>th, .table-bordered>thead>tr>td {
  13 + border-bottom-width: 2px;
  14 + text-align: center;
  15 +}
  16 +
  17 +.table>tbody+tbody {
  18 + border-top: 1px solid;
  19 +}
  20 +
  21 +.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th,
  22 + .table>thead>tr>td, .table>thead>tr>th {
  23 + text-align: center;
  24 +}
  25 +
  26 +.table-checkable tr>th:first-child, .table-checkable tr>td:first-child {
  27 + text-align: center;
  28 + max-width: initial;
  29 + min-width: 40px;
  30 + padding-left: 0;
  31 + padding-right: 0;
  32 +}
  33 +</style>
  34 +
  35 +<div class="page-head">
  36 + <div class="page-title">
  37 + <h1>发车到站统计</h1>
  38 + </div>
  39 +</div>
  40 +
  41 +<div class="row">
  42 + <div class="col-md-12">
  43 + <div class="portlet light porttlet-fit bordered">
  44 + <div class="portlet-title">
  45 + <form class="form-inline" action="" method="post">
  46 + <div style="display: inline-block; margin-left: 33px;"
  47 + id="gsdmDiv">
  48 + <span class="item-label" style="width: 80px;">公司: </span> <select
  49 + class="form-control" name="company" id="gsdm"
  50 + style="width: 140px;"></select>
  51 + </div>
  52 + <div style="display: inline-block; margin-left: 19px;"
  53 + id="fgsdmDiv">
  54 + <span class="item-label" style="width: 80px;">分公司: </span> <select
  55 + class="form-control" name="subCompany" id="fgsdm"
  56 + style="width: 140px;"></select>
  57 + </div>
  58 + <div style="display: inline-block; margin-left: 33px;">
  59 + <span class="item-label" style="width: 80px;">线路: </span> <select
  60 + class="form-control" name="line" id="line" style="width: 180px;"></select>
  61 + </div>
  62 + <div style="display: inline-block; margin-left: 5px;">
  63 + <span class="item-label" style="width: 80px;">开始日期: </span> <input
  64 + class="form-control" type="text" id="startDate"
  65 + style="width: 140px;" />
  66 + </div>
  67 + <div style="display: inline-block; margin-left: 5px;">
  68 + <span class="item-label" style="width: 80px;">结束日期: </span> <input
  69 + class="form-control" type="text" id="endDate"
  70 + style="width: 140px;" />
  71 + </div>
  72 + <div class="form-group">
  73 + <input class="btn btn-default" type="button" id="query" value="筛选" />
  74 + <input class="btn btn-default" type="button" id="export"
  75 + value="导出" />
  76 + </div>
  77 + </form>
  78 + </div>
  79 + <div class="portlet-body">
  80 + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px">
  81 + <table class="table table-bordered table-hover table-checkable" id="forms">
  82 + <thead>
  83 + <tr>
  84 + <th colspan="10">发车到站统计</th>
  85 + <th colspan="1">发车准点率:</th>
  86 + <th colspan="1" id="fczdl"></th>
  87 + <th colspan="1">到站准点率:</th>
  88 + <th colspan="1" id="dzzdl"></th>
  89 + </tr>
  90 + <tr>
  91 + <td >日期</td>
  92 + <td >公司</td>
  93 + <td >分公司</td>
  94 + <td >线路</td>
  95 + <td >计划发车时间</td>
  96 + <td >实际发车时间</td>
  97 + <td >计划到站时间</td>
  98 + <td >实际到站时间</td>
  99 + <td >烂班类型</td>
  100 + <td >备注</td>
  101 + <td >发车延迟</td>
  102 + <td >发车准点</td>
  103 + <td >到站延迟</td>
  104 + <td >到站准点</td>
  105 + </tr>
  106 + </thead>
  107 + <tbody >
  108 +
  109 + </tbody>
  110 + </table>
  111 + <div style="text-align: right;">
  112 + <ul id="pagination" class="pagination"></ul>
  113 + </div>
  114 + </div>
  115 + </div>
  116 + </div>
  117 + </div>
  118 +</div>
  119 +
  120 +<script>
  121 + $(function() {
  122 + // 关闭左侧栏
  123 + if (!$('body').hasClass('page-sidebar-closed'))
  124 + $('.menu-toggler.sidebar-toggler').click();
  125 +
  126 + var d = new Date();
  127 + d.setTime(d.getTime() - 1*1000*60*60*24);
  128 + var year = d.getFullYear();
  129 + var month = d.getMonth() + 1;
  130 + var day = d.getDate();
  131 + if(month < 10)
  132 + month = "0" + month;
  133 + if(day < 10)
  134 + day = "0" + day;
  135 + var dateTime = year + "-" + month + "-" + day;
  136 + $("#startDate,#endDate").datetimepicker({
  137 + format : 'YYYY-MM-DD',
  138 + locale : 'zh-cn',
  139 + maxDate : dateTime
  140 + });
  141 + $("#startDate,#endDate").val(dateTime);
  142 +
  143 + var fage=false;
  144 + var xlList;
  145 + var obj = [];
  146 +
  147 +
  148 + $.get('/report/lineList',function(result){
  149 + xlList=result;
  150 + $.get('/user/companyData', function(result){
  151 + obj = result;
  152 + var options = '';
  153 + for(var i = 0; i < obj.length; i++){
  154 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  155 + }
  156 +
  157 + if(obj.length ==0){
  158 + $("#gsdmDiv").css('display','none');
  159 + }else if(obj.length ==1){
  160 + $("#gsdmDiv").css('display','none');
  161 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  162 + $('#fgsdmDiv').css('display','none');
  163 + }
  164 + $('#gsdm').html(options);
  165 + updateCompany();
  166 + });
  167 + })
  168 + $("#gsdm").on("change",updateCompany);
  169 + function updateCompany(){
  170 + var company = $('#gsdm').val();
  171 + var options = '<option value="">全部分公司</option>';
  172 + for(var i = 0; i < obj.length; i++){
  173 + if(obj[i].companyCode == company){
  174 + var children = obj[i].children;
  175 + for(var j = 0; j < children.length; j++){
  176 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  177 + }
  178 + }
  179 + }
  180 + $('#fgsdm').html(options);
  181 + initXl();
  182 + }
  183 +
  184 +
  185 + $("#fgsdm").on("change",initXl);
  186 + function initXl(){
  187 + var data=[];
  188 + data.push({id: " ", text: "全部线路"});
  189 + if(fage){
  190 + $("#line").select2("destroy").html('');
  191 + }
  192 + var fgs=$('#fgsdm').val();
  193 + var gs=$('#gsdm').val();
  194 + for(var i=0;i<xlList.length;i++){
  195 + if(gs!=""){
  196 + if(fgs!=""){
  197 + if(xlList[i]["fgsbm"]==fgs && xlList[i]["gsbm"]==gs){
  198 + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]});
  199 + }
  200 + }else{
  201 + if(xlList[i]["gsbm"]==gs){
  202 + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]});
  203 + }
  204 + }
  205 + }
  206 + }
  207 + initPinYinSelect2('#line',data,'');
  208 + fage=true;
  209 + }
  210 +
  211 + $("#startDate").on("change", function(){
  212 + console.log(">>>>>>>>");
  213 + });
  214 + /*$("#line").on("change", function(){
  215 + if($("#line").val() == " "){
  216 + $("#gsdm").attr("disabled", false);
  217 + $("#fgsdm").attr("disabled", false);
  218 + } else {
  219 + var temp = tempData[$("#line").val()].split(":");
  220 + $("#gsdm").val(temp[0]);
  221 + updateCompany();
  222 + $("#fgsdm").val("");
  223 + $("#gsdm").attr("disabled", true);
  224 + }
  225 + });*/
  226 +
  227 +
  228 + $("#query").on(
  229 + "click",
  230 + function() {
  231 + var startDate = $("#startDate").val();
  232 + var endDate = $("#endDate").val();
  233 + if(getDateDifference(startDate, endDate)>60){
  234 + layer.msg("单次查询最多不超过60天!");
  235 + return;
  236 + }
  237 + if (startDate != '') {
  238 + page=0;
  239 + loadTableDate(true);
  240 + } else {
  241 + alert("请选择时间范围!");
  242 + }
  243 + });
  244 +
  245 + $("#export").on(
  246 + "click",
  247 + function() {
  248 + var line = $("#line").val();
  249 + var startDate = $("#startDate").val();
  250 + var endDate = $("#endDate").val();
  251 + var gsdm= $("#gsdm").val();
  252 + var fgsdm= $("#fgsdm").val();
  253 + if(getDateDifference(startDate, endDate)>60){
  254 + layer.msg("单次查询最多不超过60天!");
  255 + return;
  256 + }
  257 + var i = layer.load(2);
  258 + window.open('/report/fcdzStatistics/?line=' + line + "&startDate=" + startDate + "&endDate=" + endDate +
  259 + "&gsdm=" + gsdm + "&fgsdm=" + fgsdm + "&type=export");
  260 + layer.close(i);
  261 + });
  262 + function getDateDifference(start, end) {
  263 + const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数
  264 + const startDate = new Date(start); // 转换为Date对象
  265 + const endDate = new Date(end); // 转换为Date对象
  266 + const diffDays = Math.round(Math.abs((endDate - startDate) / oneDay)); // 计算两个日期的差值,取绝对值并四舍五入
  267 + return diffDays;
  268 + }
  269 + function getParams() {
  270 + // 搜索参数集合
  271 + var params = {};
  272 + params['line'] = $("#line").val();
  273 + params['startDate'] = $("#startDate").val();
  274 + params['endDate'] = $("#endDate").val();
  275 + params['gsdm'] = $("#gsdm").val();
  276 + params['fgsdm'] = $("#fgsdm").val();
  277 + return params;
  278 + }
  279 + var page = 0,
  280 + initPag;
  281 + function showPagination(data){
  282 + // 分页组件
  283 + $('#pagination').jqPaginator({
  284 + // 总页数
  285 + totalPages: data.totalPages,
  286 + // 中间显示页数
  287 + visiblePages: 6,
  288 + // 当前页
  289 + currentPage: page + 1,
  290 + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
  291 + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
  292 + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
  293 + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
  294 + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
  295 + onPageChange: function (num, type) {
  296 + if(initPag){
  297 + initPag = false;
  298 + return;
  299 + }
  300 + page = num - 1;
  301 + loadTableDate(false);
  302 + }
  303 + });
  304 + }
  305 + /** 表格数据分页加载事件 @param:<param : 查询参数;isPon : 是否重新分页> */
  306 + function loadTableDate(isPon){
  307 + // 搜索参数
  308 + var params = getParams();
  309 + params['type'] = 'query';
  310 + // 记录当前页数
  311 + params['page'] = page;
  312 + // 弹出正在加载层
  313 + var i = layer.load(2);
  314 + $.get('/report/fcdzStatistics',params,function(result){
  315 + $("#fczdl").html(result.fczdl);
  316 + $("#dzzdl").html(result.dzzdl);
  317 + // 把数据填充到模版中
  318 + var tbodyHtml = template('changetochange',{list:result.list});
  319 + // 把渲染好的模版html文本追加到表格中
  320 + $('#forms tbody').html(tbodyHtml);
  321 + // 是重新分页且返回数据长度大于0
  322 + if(isPon){
  323 + // 重新分页
  324 + initPag = true;
  325 + // 分页栏
  326 + showPagination(result);
  327 + }
  328 + // 关闭弹出加载层
  329 + layer.close(i);
  330 + });
  331 + }
  332 + });
  333 +</script>
  334 +<script type="text/html" id="changetochange">
  335 + {{each list as obj i}}
  336 + <tr>
  337 + <td>{{obj.schedule_date_str}}</td>
  338 + <td>{{obj.gs_name}}</td>
  339 + <td>{{obj.fgs_name}}</td>
  340 + <td>{{obj.xl_name}}</td>
  341 + <td>{{obj.fcsj}}</td>
  342 + <td>{{obj.fcsj_actual}}</td>
  343 + <td>{{obj.zdsj}}</td>
  344 + <td>{{obj.zdsj_actual}}</td>
  345 + <td>{{obj.adjust_exps}}</td>
  346 + <td>{{obj.remarks}}</td>
  347 + <td>{{obj.fcyc}}</td>
  348 + <td>{{obj.fczd}}</td>
  349 + <td>{{obj.dzyc}}</td>
  350 + <td>{{obj.dzzd}}</td>
  351 + </tr>
  352 + {{/each}}
  353 + {{if list.length == 0}}
  354 + <tr>
  355 + <td colspan="15"><h6 class="muted">没有找到相关数据</h6></td>
  356 + </tr>
  357 + {{/if}}
  358 +</script>
0 359 \ No newline at end of file
... ...