Commit 1e5cb526c173627fdb3f4d8e4548bebe6d5c001f

Authored by 潘钊
1 parent 0be569ef

update

src/main/java/com/bsth/controller/realcontrol/summary/FastAndSlowController.java
... ... @@ -2,9 +2,16 @@ package com.bsth.controller.realcontrol.summary;
2 2  
3 3 import com.bsth.controller.BaseController;
4 4 import com.bsth.data.summary.entity.FastAndSlow;
  5 +import com.bsth.data.summary.service.FastAndSlowService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.PathVariable;
5 8 import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestParam;
6 10 import org.springframework.web.bind.annotation.RestController;
7 11  
  12 +import javax.servlet.http.HttpServletRequest;
  13 +import javax.servlet.http.HttpServletResponse;
  14 +
8 15 /**
9 16 * 快慢误点统计
10 17 * Created by panzhao on 2017/10/24.
... ... @@ -12,4 +19,13 @@ import org.springframework.web.bind.annotation.RestController;
12 19 @RestController
13 20 @RequestMapping("/summary/fastAndSlow")
14 21 public class FastAndSlowController extends BaseController<FastAndSlow, Long> {
  22 +
  23 + @Autowired
  24 + FastAndSlowService fastAndSlowService;
  25 +
  26 + @RequestMapping("/excel/{lineCode}")
  27 + public void excel(@PathVariable("lineCode") String lineCode, @RequestParam String st
  28 + , @RequestParam String et, @RequestParam int type, HttpServletRequest request, HttpServletResponse response) {
  29 + fastAndSlowService.excel(lineCode, st, et, type, request, response);
  30 + }
15 31 }
... ...
src/main/java/com/bsth/data/summary/service/FastAndSlowService.java
... ... @@ -3,8 +3,12 @@ package com.bsth.data.summary.service;
3 3 import com.bsth.data.summary.entity.FastAndSlow;
4 4 import com.bsth.service.BaseService;
5 5  
  6 +import javax.servlet.http.HttpServletRequest;
  7 +import javax.servlet.http.HttpServletResponse;
  8 +
6 9 /**
7 10 * Created by panzhao on 2017/10/24.
8 11 */
9 12 public interface FastAndSlowService extends BaseService<FastAndSlow, Long>{
  13 + void excel(String lineCode, String st, String et, int type, HttpServletRequest request, HttpServletResponse response);
10 14 }
... ...
src/main/java/com/bsth/data/summary/service/impl/FastAndSlowServiceImpl.java
1 1 package com.bsth.data.summary.service.impl;
2 2  
  3 +import com.bsth.data.BasicData;
3 4 import com.bsth.data.summary.entity.FastAndSlow;
4 5 import com.bsth.data.summary.service.FastAndSlowService;
  6 +import com.bsth.data.utils.ConvertUtil;
5 7 import com.bsth.service.impl.BaseServiceImpl;
  8 +import com.google.common.collect.ArrayListMultimap;
  9 +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  10 +import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  11 +import org.apache.poi.ss.usermodel.Row;
  12 +import org.apache.poi.ss.usermodel.Sheet;
  13 +import org.apache.poi.ss.util.CellRangeAddress;
  14 +import org.joda.time.format.DateTimeFormat;
  15 +import org.joda.time.format.DateTimeFormatter;
6 16 import org.slf4j.Logger;
7 17 import org.slf4j.LoggerFactory;
8 18 import org.springframework.stereotype.Service;
9 19  
10   -import java.util.ArrayList;
11   -import java.util.List;
12   -import java.util.Map;
  20 +import javax.servlet.http.HttpServletRequest;
  21 +import javax.servlet.http.HttpServletResponse;
  22 +import java.io.FileInputStream;
  23 +import java.io.OutputStream;
  24 +import java.net.URLEncoder;
  25 +import java.text.ParseException;
  26 +import java.text.SimpleDateFormat;
  27 +import java.util.*;
13 28  
14 29 /**
15 30 * Created by panzhao on 2017/10/24.
... ... @@ -19,30 +34,402 @@ public class FastAndSlowServiceImpl extends BaseServiceImpl&lt;FastAndSlow, Long&gt; i
19 34  
20 35 Logger logger = LoggerFactory.getLogger(this.getClass());
21 36  
  37 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  38 +
22 39 @Override
23 40 public Iterable<FastAndSlow> list(Map<String, Object> map) {
24   - List<FastAndSlow> list = (List) super.list(map);
  41 + try {
  42 + //最多5天
  43 + map.put("rq_le", maxEndTime(map.get("rq_ge").toString()
  44 + , map.get("rq_le").toString(), 5));
25 45  
26   - try{
27   - List rsList = new ArrayList();
  46 + List<FastAndSlow> list = (List) super.list(map);
28 47 String type = String.valueOf(map.get("type"));
29   - if("-1".equals(type)){//慢误
30   - for(FastAndSlow fas : list){
31   - if(fas.isSlow())
32   - rsList.add(fas);
33   - }
34   - return rsList;
  48 +
  49 + return filterByType(list, type);
  50 + } catch (Exception e) {
  51 + logger.error("", e);
  52 + }
  53 + return null;
  54 + }
  55 +
  56 + @Override
  57 + public void excel(String lineCode, String st, String et, int type, HttpServletRequest request, HttpServletResponse response) {
  58 + try {
  59 + Map<String, Object> params = new HashMap();
  60 + //最多31天
  61 + et = maxEndTime(st, et, 31);
  62 + params.put("rq_ge", st);
  63 + params.put("rq_le", et);
  64 + params.put("lineCode_eq", lineCode);
  65 + List<FastAndSlow> list = filterByType((List) super.list(params), type + "");
  66 +
  67 + if(list.size() == 0){
  68 + response.setHeader("Content-type", "text/html;charset=UTF-8");
  69 + response.getWriter().print("<span style='color:red;font-size:24px;'>根据查询条件没有搜索到数据,别导了!</span>");
  70 + return ;
35 71 }
36   - else if("1".equals(type)){//快误
37   - for(FastAndSlow fas : list){
38   - if(fas.isFast())
39   - rsList.add(fas);
  72 + //排序
  73 + Collections.sort(list, new Comparator<FastAndSlow>() {
  74 + @Override
  75 + public int compare(FastAndSlow fas1, FastAndSlow fas2) {
  76 + return (int) (fas1.getT() - fas2.getT());
40 77 }
41   - return rsList;
  78 + });
  79 + //按日期分组
  80 + ArrayListMultimap<String, FastAndSlow> multimap =
  81 + new ConvertUtil<FastAndSlow>().groupMultiList(list, "_", FastAndSlow.class.getDeclaredField("rq"));
  82 + //输出excel
  83 + String basePath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
  84 + String filePath = basePath + "/static/pages/summary/excel/快慢误点报表.xls";
  85 + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filePath));
  86 + HSSFWorkbook wb = new HSSFWorkbook(fs);
  87 +
  88 + //写入数据
  89 + List<String> ks = new ArrayList<>(multimap.keySet());
  90 + Collections.sort(ks);
  91 + for(int i = 0; i < ks.size(); i++){
  92 + Sheet sheet = wb.getSheetAt(i);
  93 + writeData(sheet, multimap.get(ks.get(i)));
  94 + //sheet name
  95 + wb.setSheetName(i, ks.get(i));
42 96 }
43   - }catch (Exception e){
  97 + //删除多余的sheet
  98 + for(int i = ks.size(); i <31; i++){
  99 + wb.removeSheetAt(ks.size());
  100 + }
  101 +
  102 + //response 输出
  103 + String filename = BasicData.lineCode2NameMap.get(lineCode) + st + "至" + et + "快慢误点明细.xls";
  104 + response.setContentType("application/x-msdownload");
  105 + response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
  106 +
  107 + OutputStream os = response.getOutputStream();
  108 + wb.write(os);
  109 + os.flush();
  110 + os.close();
  111 + } catch (Exception e) {
44 112 logger.error("", e);
45 113 }
46   - return list;
  114 + }
  115 +
  116 + private void writeData(Sheet sheet, List<FastAndSlow> list) {
  117 + List<FastAndSlow> ups = new ArrayList<>()
  118 + ,downs = new ArrayList<>();
  119 + //前4行是表头
  120 + Row row;
  121 + row = sheet.getRow(0);
  122 + row.getCell(4).setCellValue(list.get(0).getRq());
  123 + row.getCell(13).setCellValue(BasicData.lineCode2NameMap.get(list.get(0).getLineCode()));
  124 + FastAndSlow fas;
  125 + for(int i = 0; i < list.size(); i++){
  126 + fas = list.get(i);
  127 + row = sheet.createRow(i + 4);
  128 + row.createCell(0).setCellValue(i + 1);
  129 + row.createCell(1).setCellValue(fas.getStationName());
  130 + row.createCell(2).setCellValue(fas.getUpDown());
  131 + row.createCell(3).setCellValue(fas.getFcsj());
  132 + row.createCell(4).setCellValue(fas.getDfsj());
  133 + row.createCell(5).setCellValue(fas.getFcsjActual());
  134 + row.createCell(6).setCellValue(fas.getFcsjFast());
  135 + row.createCell(7).setCellValue(fas.getFcsjSlow());
  136 + row.createCell(8).setCellValue(fas.getDfsjFast());
  137 + row.createCell(9).setCellValue(fas.getDfsjSlow());
  138 + row.createCell(10).setCellValue(fas.getZdsj());
  139 + row.createCell(11).setCellValue(fas.getZdsjDf());
  140 + row.createCell(12).setCellValue(fas.getZdsjActual());
  141 + row.createCell(13).setCellValue(fas.getZdsjFast());
  142 + row.createCell(14).setCellValue(fas.getZdsjSlow());
  143 + row.createCell(15).setCellValue(fas.getZdsjDfFast());
  144 + row.createCell(16).setCellValue(fas.getZdsjDfSlow());
  145 +
  146 + if(fas.getUpDown()==0)
  147 + ups.add(fas);
  148 + else
  149 + downs.add(fas);
  150 + }
  151 + //合计
  152 + int size = list.size();
  153 + row = sheet.createRow(size + 4);
  154 + row.createCell(1).setCellValue("发车:上行(计划快误点:"+jhfcFast(ups)+" 累计时间:"+jhfcFastTime(ups)+" 待发快误点:"+dffcFast(ups)+" 累计时间:"+dffcFastTime(ups)+") ");
  155 + row.createCell(9).setCellValue("下行(计划快误点:"+jhfcFast(downs)+" 累计时间:"+jhfcFastTime(downs)+" 待发快误点:"+dffcFast(downs)+" 累计时间:"+dffcFastTime(downs)+")");
  156 + row = sheet.createRow(size + 5);
  157 + row.createCell(1).setCellValue("发车:上行(计划慢误点:"+jhfcSlow(ups)+" 累计时间:"+jhfcSlowTime(ups)+" 待发慢误点:"+dffcSlow(ups)+" 累计时间:"+dffcSlowTime(ups)+") ");
  158 + row.createCell(9).setCellValue("下行(计划慢误点:"+jhfcSlow(downs)+" 累计时间:"+jhfcSlowTime(downs)+" 待发慢误点:"+dffcSlow(downs)+" 累计时间:"+dffcSlowTime(downs)+")");
  159 + row = sheet.createRow(size + 6);
  160 + row.createCell(1).setCellValue("到达:上行(计划快误点:"+jhzdFast(ups)+" 累计时间:"+jhzdFastTime(ups)+" 待发快误点:"+dfzdFast(ups)+" 累计时间:"+dfzdFastTime(ups)+") ");
  161 + row.createCell(9).setCellValue("下行(计划快误点:"+jhzdFast(downs)+" 累计时间:"+jhzdFastTime(downs)+" 待发快误点:"+dfzdFast(downs)+" 累计时间:"+dfzdFastTime(downs)+")");
  162 + row = sheet.createRow(size + 7);
  163 + row.createCell(1).setCellValue("到达:上行(计划慢误点:"+jhzdSlow(ups)+" 累计时间:"+jhzdSlowTime(ups)+" 待发慢误点:"+dfzdSlow(ups)+" 累计时间:"+dfzdSlowTime(ups)+") ");
  164 + row.createCell(9).setCellValue("下行(计划慢误点:"+jhzdSlow(downs)+" 累计时间:"+jhzdSlowTime(downs)+" 待发慢误点:"+dfzdSlow(downs)+" 累计时间:"+dfzdSlowTime(downs)+")");
  165 + //合并单元格
  166 + sheet.addMergedRegion(new CellRangeAddress(size + 4, size + 4, 1, 8));
  167 + sheet.addMergedRegion(new CellRangeAddress(size + 4, size + 4, 9, 16));
  168 + sheet.addMergedRegion(new CellRangeAddress(size + 5, size + 5, 1, 8));
  169 + sheet.addMergedRegion(new CellRangeAddress(size + 5, size + 5, 9, 16));
  170 + sheet.addMergedRegion(new CellRangeAddress(size + 6, size + 6, 1, 8));
  171 + sheet.addMergedRegion(new CellRangeAddress(size + 6, size + 6, 9, 16));
  172 + sheet.addMergedRegion(new CellRangeAddress(size + 7, size + 7, 1, 8));
  173 + sheet.addMergedRegion(new CellRangeAddress(size + 7, size + 7, 9, 16));
  174 +
  175 + sheet.addMergedRegion(new CellRangeAddress(size + 4, size + 7, 0, 0));
  176 + }
  177 +
  178 + private List<FastAndSlow> filterByType(List<FastAndSlow> all, String type) {
  179 + List rsList = new ArrayList();
  180 + if ("-1".equals(type)) {//慢误
  181 + for (FastAndSlow fas : all) {
  182 + if (fas.isSlow())
  183 + rsList.add(fas);
  184 + }
  185 + return rsList;
  186 + } else if ("1".equals(type)) {//快误
  187 + for (FastAndSlow fas : all) {
  188 + if (fas.isFast())
  189 + rsList.add(fas);
  190 + }
  191 + return rsList;
  192 + }
  193 + return all;
  194 + }
  195 +
  196 +
  197 + private String maxEndTime(String sStr, String eStr, int space) throws ParseException {
  198 + try {
  199 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  200 + long st = sdf.parse(sStr).getTime();
  201 + long et = sdf.parse(eStr).getTime();
  202 + long dayTime = 24 * 60 * 60 * 1000;
  203 + long spaceTime = dayTime * space;
  204 +
  205 + if (et - st > spaceTime) {
  206 + eStr = sdf.format(new Date(st + spaceTime));
  207 + }
  208 + } catch (Exception e) {
  209 + throw e;
  210 + }
  211 + return eStr;
  212 + }
  213 +
  214 + /**
  215 + * 计划发出快误点
  216 + * @param list
  217 + * @return
  218 + */
  219 + private int jhfcFast(List<FastAndSlow> list){
  220 + int count=0;
  221 + for(FastAndSlow fas : list){
  222 + if(fas.getFcsjFast() > 0)
  223 + count++;
  224 + }
  225 + return count;
  226 + }
  227 +
  228 + /**
  229 + * 计划终点快误点
  230 + * @param list
  231 + * @return
  232 + */
  233 + private int jhzdFast(List<FastAndSlow> list){
  234 + int count=0;
  235 + for(FastAndSlow fas : list){
  236 + if(fas.getZdsjFast() > 0)
  237 + count++;
  238 + }
  239 + return count;
  240 + }
  241 +
  242 + /**
  243 + * 待发发出快误点
  244 + * @param list
  245 + * @return
  246 + */
  247 + private int dffcFast(List<FastAndSlow> list){
  248 + int count=0;
  249 + for(FastAndSlow fas : list){
  250 + if(fas.getDfsjFast() > 0)
  251 + count++;
  252 + }
  253 + return count;
  254 + }
  255 +
  256 + /**
  257 + * 待发终点快误点
  258 + * @param list
  259 + * @return
  260 + */
  261 + private int dfzdFast(List<FastAndSlow> list){
  262 + int count=0;
  263 + for(FastAndSlow fas : list){
  264 + if(fas.getZdsjDfFast() > 0)
  265 + count++;
  266 + }
  267 + return count;
  268 + }
  269 +
  270 + //----------
  271 +
  272 + /**
  273 + * 计划发出慢误点
  274 + * @param list
  275 + * @return
  276 + */
  277 + private int jhfcSlow(List<FastAndSlow> list){
  278 + int count=0;
  279 + for(FastAndSlow fas : list){
  280 + if(fas.getFcsjSlow() > 0)
  281 + count++;
  282 + }
  283 + return count;
  284 + }
  285 +
  286 + /**
  287 + * 计划终点慢误点
  288 + * @param list
  289 + * @return
  290 + */
  291 + private int jhzdSlow(List<FastAndSlow> list){
  292 + int count=0;
  293 + for(FastAndSlow fas : list){
  294 + if(fas.getZdsjSlow() > 0)
  295 + count++;
  296 + }
  297 + return count;
  298 + }
  299 +
  300 + /**
  301 + * 待发发出慢误点
  302 + * @param list
  303 + * @return
  304 + */
  305 + private int dffcSlow(List<FastAndSlow> list){
  306 + int count=0;
  307 + for(FastAndSlow fas : list){
  308 + if(fas.getDfsjSlow() > 0)
  309 + count++;
  310 + }
  311 + return count;
  312 + }
  313 +
  314 + /**
  315 + * 待发终点慢误点
  316 + * @param list
  317 + * @return
  318 + */
  319 + private int dfzdSlow(List<FastAndSlow> list){
  320 + int count=0;
  321 + for(FastAndSlow fas : list){
  322 + if(fas.getZdsjDfSlow() > 0)
  323 + count++;
  324 + }
  325 + return count;
  326 + }
  327 + /**
  328 + * ################
  329 + */
  330 + /**
  331 + * 计划发出快误点
  332 + * @param list
  333 + * @return
  334 + */
  335 + private int jhfcFastTime(List<FastAndSlow> list){
  336 + int sum=0;
  337 + for(FastAndSlow fas : list){
  338 + sum+=fas.getFcsjFast();
  339 + }
  340 + return sum;
  341 + }
  342 +
  343 + /**
  344 + * 计划终点快误点
  345 + * @param list
  346 + * @return
  347 + */
  348 + private int jhzdFastTime(List<FastAndSlow> list){
  349 + int sum=0;
  350 + for(FastAndSlow fas : list){
  351 + sum+=fas.getZdsjFast();
  352 + }
  353 + return sum;
  354 + }
  355 +
  356 + /**
  357 + * 待发发出快误点
  358 + * @param list
  359 + * @return
  360 + */
  361 + private int dffcFastTime(List<FastAndSlow> list){
  362 + int sum=0;
  363 + for(FastAndSlow fas : list){
  364 + sum+=fas.getDfsjFast();
  365 + }
  366 + return sum;
  367 + }
  368 +
  369 + /**
  370 + * 待发终点快误点
  371 + * @param list
  372 + * @return
  373 + */
  374 + private int dfzdFastTime(List<FastAndSlow> list){
  375 + int sum=0;
  376 + for(FastAndSlow fas : list){
  377 + sum+=fas.getZdsjDfFast();
  378 + }
  379 + return sum;
  380 + }
  381 +
  382 + //----------
  383 +
  384 + /**
  385 + * 计划发出慢误点
  386 + * @param list
  387 + * @return
  388 + */
  389 + private int jhfcSlowTime(List<FastAndSlow> list){
  390 + int sum=0;
  391 + for(FastAndSlow fas : list){
  392 + sum+=fas.getFcsjSlow();
  393 + }
  394 + return sum;
  395 + }
  396 +
  397 + /**
  398 + * 计划终点慢误点
  399 + * @param list
  400 + * @return
  401 + */
  402 + private int jhzdSlowTime(List<FastAndSlow> list){
  403 + int sum=0;
  404 + for(FastAndSlow fas : list){
  405 + sum+=fas.getZdsjSlow();
  406 + }
  407 + return sum;
  408 + }
  409 +
  410 + /**
  411 + * 待发发出慢误点
  412 + * @param list
  413 + * @return
  414 + */
  415 + private int dffcSlowTime(List<FastAndSlow> list){
  416 + int sum=0;
  417 + for(FastAndSlow fas : list){
  418 + sum+=fas.getDfsjSlow();
  419 + }
  420 + return sum;
  421 + }
  422 +
  423 + /**
  424 + * 待发终点慢误点
  425 + * @param list
  426 + * @return
  427 + */
  428 + private int dfzdSlowTime(List<FastAndSlow> list){
  429 + int sum=0;
  430 + for(FastAndSlow fas : list){
  431 + sum+=fas.getZdsjDfSlow();
  432 + }
  433 + return sum;
47 434 }
48 435 }
... ...
src/main/java/com/bsth/data/utils/ConvertUtil.java 0 → 100644
  1 +package com.bsth.data.utils;
  2 +
  3 +import com.google.common.collect.ArrayListMultimap;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import org.joda.time.format.DateTimeFormatter;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +
  9 +import java.lang.reflect.Field;
  10 +import java.util.*;
  11 +
  12 +/**
  13 + * 数据转换
  14 + * Created by panzhao on 2017/3/13.
  15 + */
  16 +public class ConvertUtil<T> {
  17 +
  18 + Logger logger = LoggerFactory.getLogger(this.getClass());
  19 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyyMMdd");
  20 +
  21 + /**
  22 + * 根据指定字段 将 list 分组
  23 + *
  24 + * @param list
  25 + * @param separator 字段使用分隔符连接 组成key
  26 + * @param fields
  27 + * @return
  28 + */
  29 + public ArrayListMultimap<String, T> groupMultiList(List<T> list, String separator, Field... fields) {
  30 + ArrayListMultimap<String, T> multimap = ArrayListMultimap.create();
  31 +
  32 + String key;
  33 + //Object field;
  34 + try {
  35 + for (T t : list) {
  36 +
  37 + key = "";
  38 + for (Field f : fields) {
  39 + f.setAccessible(true);
  40 + if(null == f.get(t))
  41 + continue;
  42 + //日期类型格式化为 YYYY-MM-DD
  43 + if (f.getType().equals(Date.class))
  44 + key += (separator + fmtyyyyMMdd.print(((Date) f.get(t)).getTime()));
  45 + else
  46 + key += (separator + f.get(t).toString());
  47 + }
  48 + if(key.length() > 1)
  49 + key = key.substring(1);
  50 +
  51 + multimap.put(key, t);
  52 + }
  53 + } catch (Exception e) {
  54 + logger.error("", e);
  55 + }
  56 +
  57 + return multimap;
  58 + }
  59 +
  60 + /**
  61 + * 根据指定字段 将 list 分组
  62 + *
  63 + * @param list
  64 + * @param separator 字段使用分隔符连接 组成key
  65 + * @param fields
  66 + * @return
  67 + */
  68 + public Map<String, T> groupList(List<T> list, String separator, Field... fields) {
  69 + Map<String, T> map = new HashMap<>();
  70 +
  71 + String key;
  72 + //Object field;
  73 + try {
  74 + for (T t : list) {
  75 +
  76 + key = "";
  77 + for (Field f : fields) {
  78 + f.setAccessible(true);
  79 + //日期类型格式化为 YYYY-MM-DD
  80 + if (f.getType().equals(Date.class))
  81 + key += (separator + fmtyyyyMMdd.print(((Date) f.get(t)).getTime()));
  82 + else
  83 + key += (separator + f.get(t).toString());
  84 + }
  85 + key = key.substring(1);
  86 +
  87 + map.put(key, t);
  88 + }
  89 + } catch (Exception e) {
  90 + logger.error("", e);
  91 + }
  92 +
  93 + return map;
  94 + }
  95 +
  96 + /**
  97 + * 计算并集
  98 + *
  99 + * @param all
  100 + * @param sub
  101 + * @return
  102 + */
  103 + public List<String> calcUnion(Collection<String> all, Collection<String> sub) {
  104 + List<String> rs = new ArrayList<>();
  105 +
  106 + for (String str : all) {
  107 + if (sub.contains(str))
  108 + rs.add(str);
  109 + }
  110 + return rs;
  111 + }
  112 +
  113 + /**
  114 + * 计算补集
  115 + *
  116 + * @param all
  117 + * @param sub
  118 + * @return
  119 + */
  120 + public List<String> calcComplement(Collection<String> all, Collection<String> sub) {
  121 + List<String> rs = new ArrayList<>();
  122 +
  123 + for (String str : all) {
  124 + if (!sub.contains(str))
  125 + rs.add(str);
  126 + }
  127 + return rs;
  128 + }
  129 +}
... ...
src/main/resources/static/pages/summary/excel/快慢误点报表.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/summary/fast_and_slow/data.html
... ... @@ -66,6 +66,7 @@
66 66 </table>
67 67 </div>
68 68 {{each listMap as obj k}}
  69 + <h4><a>{{k}}</a></h4>
69 70 <div class="data_table_wrap data" id="table_{{k}}">
70 71 <table cellspacing="1" class="data_table">
71 72 <col />
... ...
src/main/resources/static/pages/summary/fast_and_slow/main.html
... ... @@ -208,6 +208,9 @@
208 208 .count_col .c_c_1{
209 209 color: #ff0000d1;
210 210 }
  211 + .ct_cont{
  212 + display: none;
  213 + }
211 214 </style>
212 215 </head>
213 216  
... ... @@ -240,7 +243,7 @@
240 243 </div>
241 244 <div class="ct_field">
242 245 <label>日期范围:
243   - <input class="uk-input" name="rq" style="width: 200px;">
  246 + <input class="uk-input" name="rq" style="width: 200px;" >
244 247 </label>
245 248 </div>
246 249 <div class="ct_field">
... ... @@ -249,13 +252,13 @@
249 252 <label><input class="uk-radio" type="radio" name="type" value="-1"> 慢误</label>
250 253 </div>
251 254 <div class="ct_field">
252   - <button class="uk-button uk-button-primary search"><i uk-icon="icon: search"></i>搜索</button>
  255 + <button class="uk-button uk-button-primary search"><i uk-icon="icon: search" ></i>搜索</button>
253 256 </div>
254 257 <div class="ct_field ct_field_bottom">
255 258 <button class="uk-button uk-button-text export_excel" style="padding: 0 5px;">导出数据</button>
256 259 </div>
257 260 <div class="ct_field ct_field_bottom">
258   - <span uk-icon="icon: question" title="快1慢3; 排除进出场班次" uk-tooltip="pos: bottom"></span>
  261 + <span uk-icon="icon: question" title="快1慢3; 排除进出场班次<br>一次至多查询5天的数据,如需更大查询范围,请导出" uk-tooltip="pos: bottom"></span>
259 262 </div>
260 263 </form>
261 264 </div>
... ... @@ -300,8 +303,8 @@
300 303  
301 304 //日期选择框
302 305 var fs='YYYY-MM-DD'
303   - , ets=moment().format(fs)
304   - , sts=moment().subtract(5, 'days').format(fs);
  306 + , ets=moment().subtract(1, 'days').format(fs)
  307 + , sts=moment().subtract(6, 'days').format(fs);
305 308 flatpickr('.ct_search_form_wrap [name=rq]', {
306 309 mode: "range", dateFormat: "Y-m-d","locale": "zh", defaultDate: [sts, ets]
307 310 });
... ... @@ -364,11 +367,18 @@
364 367 * 点击搜索
365 368 */
366 369 $('.search', f).on('click', function () {
  370 + var that = this;
  371 + $(that).attr('disabled', 'disabled');
367 372 var params = serializeFormJSON();
  373 + $('.ct_cont').hide();
368 374 $.get('/summary/fastAndSlow/all', params, function (rs) {
  375 + $(that).removeAttr('disabled');
369 376 //按日期分组
370 377 var listMap = groupBy(rs, 'rq');
371 378 $('.ct_data_body_wrap').trigger('init', {listMap: listMap});
  379 + if(!rs || rs.length==0)
  380 + return UIkit.notification('没有搜索到相关数据!!', 'danger');
  381 + $('.ct_cont').show();
372 382 });
373 383 });
374 384  
... ... @@ -407,6 +417,7 @@
407 417 $('.export_excel').on('click', function () {
408 418 var params = serializeFormJSON();
409 419  
  420 + window.open('/summary/fastAndSlow/excel/' + params.lineCode_eq + "?st="+params.rq_ge+"&et="+params.rq_le+"&type="+params.type);
410 421 });
411 422 })();
412 423 </script>
... ...