Commit 9c3493a1342704b594fae2399e20a3b3601a1748

Authored by zlz
2 parents 1ef06122 325cff18

Merge remote-tracking branch 'origin/minhang' into minhang

src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -186,7 +186,7 @@ public class ExportController {
186 186 m.put("i", i);
187 187 m.put("rQ", l.getrQ());
188 188 m.put("gS", l.getgS());
189   - m.put("xL", l.getxL());
  189 + m.put("xL", l.getXlmc());
190 190 m.put("clzbh", l.getClzbh());
191 191 m.put("jsy", l.getJsy());
192 192 m.put("jName", l.getjName());
... ...
src/main/java/com/bsth/controller/realcontrol/summary/FastAndSlowController.java
1   -package com.bsth.controller.realcontrol.summary;
2   -
3   -import com.bsth.controller.BaseController;
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;
8   -import org.springframework.web.bind.annotation.RequestMapping;
9   -import org.springframework.web.bind.annotation.RequestParam;
10   -import org.springframework.web.bind.annotation.RestController;
11   -
12   -import javax.servlet.http.HttpServletRequest;
13   -import javax.servlet.http.HttpServletResponse;
14   -
15   -/**
16   - * 快慢误点统计
17   - * Created by panzhao on 2017/10/24.
18   - */
19   -@RestController
20   -@RequestMapping("/summary/fastAndSlow")
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   - }
  1 +package com.bsth.controller.realcontrol.summary;
  2 +
  3 +import com.bsth.controller.BaseController;
  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;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import javax.servlet.http.HttpServletRequest;
  13 +import javax.servlet.http.HttpServletResponse;
  14 +
  15 +/**
  16 + * 快慢误点统计
  17 + * Created by panzhao on 2017/10/24.
  18 + */
  19 +@RestController
  20 +@RequestMapping("/summary/fastAndSlow")
  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 + }
31 31 }
32 32 \ No newline at end of file
... ...
src/main/java/com/bsth/data/summary/entity/FastAndSlow.java
1   -package com.bsth.data.summary.entity;
2   -
3   -import javax.persistence.Column;
4   -import javax.persistence.Entity;
5   -import javax.persistence.Id;
6   -import javax.persistence.Table;
7   -
8   -/**
9   - * 快慢误点
10   - * Created by panzhao on 2017/10/24.
11   - */
12   -@Entity
13   -@Table(name = "z_calc_fast_slow")
14   -public class FastAndSlow {
15   -
16   - /**
17   - * 班次ID
18   - */
19   - @Id
20   - @Column(name = "s_id")
21   - private Long id;
22   -
23   - /**
24   - * 发车站点
25   - */
26   - private String stationName;
27   -
28   - /**
29   - * 日期
30   - */
31   - @Column(name = "rq")
32   - private String rq;
33   -
34   - /**
35   - * 上下行
36   - */
37   - private int upDown;
38   -
39   - /**
40   - * 计发时间
41   - * HH:mm
42   - */
43   - private String fcsj;
44   -
45   - /**
46   - * 待发时间
47   - * HH:mm
48   - */
49   - private String dfsj;
50   -
51   - /**
52   - * 实际发车时间
53   - * HH:mm
54   - */
55   - private String fcsjActual;
56   -
57   - /**
58   - * 计发快误点
59   - */
60   - private int fcsjFast;
61   -
62   - /**
63   - * 计发慢误点
64   - */
65   - private int fcsjSlow;
66   -
67   - /**
68   - * 待发快误点
69   - */
70   - private int dfsjFast;
71   -
72   - /**
73   - * 待发慢误点
74   - */
75   - private int dfsjSlow;
76   -
77   - /**
78   - * 计划终点时间
79   - */
80   - private String zdsj;
81   -
82   - /**
83   - * 待发终点时间
84   - */
85   - private String zdsjDf;
86   -
87   - /**
88   - * 实际终点时间
89   - */
90   - private String zdsjActual;
91   -
92   - /**
93   - * 计发终点快误点
94   - */
95   - private int zdsjFast;
96   -
97   - /**
98   - * 计发终点慢误点
99   - */
100   - private int zdsjSlow;
101   -
102   - /**
103   - * 待发终点快误点
104   - */
105   - private int zdsjDfFast;
106   -
107   - /**
108   - * 待发终点慢误点
109   - */
110   - private int zdsjDfSlow;
111   -
112   - @Column(name = "line_code")
113   - private String lineCode;
114   -
115   - private Long t;
116   -
117   - public String getStationName() {
118   - return stationName;
119   - }
120   -
121   - public void setStationName(String stationName) {
122   - this.stationName = stationName;
123   - }
124   -
125   - public String getRq() {
126   - return rq;
127   - }
128   -
129   - public void setRq(String rq) {
130   - this.rq = rq;
131   - }
132   -
133   - public int getUpDown() {
134   - return upDown;
135   - }
136   -
137   - public void setUpDown(int upDown) {
138   - this.upDown = upDown;
139   - }
140   -
141   - public String getFcsj() {
142   - return fcsj;
143   - }
144   -
145   - public void setFcsj(String fcsj) {
146   - this.fcsj = fcsj;
147   - }
148   -
149   - public String getDfsj() {
150   - return dfsj;
151   - }
152   -
153   - public void setDfsj(String dfsj) {
154   - this.dfsj = dfsj;
155   - }
156   -
157   - public String getFcsjActual() {
158   - return fcsjActual;
159   - }
160   -
161   - public void setFcsjActual(String fcsjActual) {
162   - this.fcsjActual = fcsjActual;
163   - }
164   -
165   - public int getFcsjFast() {
166   - return fcsjFast;
167   - }
168   -
169   - public void setFcsjFast(int fcsjFast) {
170   - this.fcsjFast = fcsjFast;
171   - }
172   -
173   - public int getFcsjSlow() {
174   - return fcsjSlow;
175   - }
176   -
177   - public void setFcsjSlow(int fcsjSlow) {
178   - this.fcsjSlow = fcsjSlow;
179   - }
180   -
181   - public int getDfsjFast() {
182   - return dfsjFast;
183   - }
184   -
185   - public void setDfsjFast(int dfsjFast) {
186   - this.dfsjFast = dfsjFast;
187   - }
188   -
189   - public int getDfsjSlow() {
190   - return dfsjSlow;
191   - }
192   -
193   - public void setDfsjSlow(int dfsjSlow) {
194   - this.dfsjSlow = dfsjSlow;
195   - }
196   -
197   - public String getZdsj() {
198   - return zdsj;
199   - }
200   -
201   - public void setZdsj(String zdsj) {
202   - this.zdsj = zdsj;
203   - }
204   -
205   - public String getZdsjDf() {
206   - return zdsjDf;
207   - }
208   -
209   - public void setZdsjDf(String zdsjDf) {
210   - this.zdsjDf = zdsjDf;
211   - }
212   -
213   - public String getZdsjActual() {
214   - return zdsjActual;
215   - }
216   -
217   - public void setZdsjActual(String zdsjActual) {
218   - this.zdsjActual = zdsjActual;
219   - }
220   -
221   - public int getZdsjFast() {
222   - return zdsjFast;
223   - }
224   -
225   - public void setZdsjFast(int zdsjFast) {
226   - this.zdsjFast = zdsjFast;
227   - }
228   -
229   - public int getZdsjSlow() {
230   - return zdsjSlow;
231   - }
232   -
233   - public void setZdsjSlow(int zdsjSlow) {
234   - this.zdsjSlow = zdsjSlow;
235   - }
236   -
237   - public int getZdsjDfFast() {
238   - return zdsjDfFast;
239   - }
240   -
241   - public void setZdsjDfFast(int zdsjDfFast) {
242   - this.zdsjDfFast = zdsjDfFast;
243   - }
244   -
245   - public int getZdsjDfSlow() {
246   - return zdsjDfSlow;
247   - }
248   -
249   - public void setZdsjDfSlow(int zdsjDfSlow) {
250   - this.zdsjDfSlow = zdsjDfSlow;
251   - }
252   -
253   - public String getLineCode() {
254   - return lineCode;
255   - }
256   -
257   - public void setLineCode(String lineCode) {
258   - this.lineCode = lineCode;
259   - }
260   -
261   - public Long getId() {
262   - return id;
263   - }
264   -
265   - public void setId(Long id) {
266   - this.id = id;
267   - }
268   -
269   - public Long getT() {
270   - return t;
271   - }
272   -
273   - public void setT(Long t) {
274   - this.t = t;
275   - }
276   -
277   - public boolean isSlow() {
278   - return this.fcsjSlow>0 || this.dfsjSlow>0 || this.zdsjSlow>0 || this.zdsjDfSlow>0;
279   - }
280   -
281   - public boolean isFast() {
282   - return this.fcsjFast>0 || this.dfsjFast>0 || this.zdsjFast>0 || this.zdsjDfFast>0;
283   - }
  1 +package com.bsth.data.summary.entity;
  2 +
  3 +import javax.persistence.Column;
  4 +import javax.persistence.Entity;
  5 +import javax.persistence.Id;
  6 +import javax.persistence.Table;
  7 +
  8 +/**
  9 + * 快慢误点
  10 + * Created by panzhao on 2017/10/24.
  11 + */
  12 +@Entity
  13 +@Table(name = "z_calc_fast_slow")
  14 +public class FastAndSlow {
  15 +
  16 + /**
  17 + * 班次ID
  18 + */
  19 + @Id
  20 + @Column(name = "s_id")
  21 + private Long id;
  22 +
  23 + /**
  24 + * 发车站点
  25 + */
  26 + private String stationName;
  27 +
  28 + /**
  29 + * 日期
  30 + */
  31 + @Column(name = "rq")
  32 + private String rq;
  33 +
  34 + /**
  35 + * 上下行
  36 + */
  37 + private int upDown;
  38 +
  39 + /**
  40 + * 计发时间
  41 + * HH:mm
  42 + */
  43 + private String fcsj;
  44 +
  45 + /**
  46 + * 待发时间
  47 + * HH:mm
  48 + */
  49 + private String dfsj;
  50 +
  51 + /**
  52 + * 实际发车时间
  53 + * HH:mm
  54 + */
  55 + private String fcsjActual;
  56 +
  57 + /**
  58 + * 计发快误点
  59 + */
  60 + private int fcsjFast;
  61 +
  62 + /**
  63 + * 计发慢误点
  64 + */
  65 + private int fcsjSlow;
  66 +
  67 + /**
  68 + * 待发快误点
  69 + */
  70 + private int dfsjFast;
  71 +
  72 + /**
  73 + * 待发慢误点
  74 + */
  75 + private int dfsjSlow;
  76 +
  77 + /**
  78 + * 计划终点时间
  79 + */
  80 + private String zdsj;
  81 +
  82 + /**
  83 + * 待发终点时间
  84 + */
  85 + private String zdsjDf;
  86 +
  87 + /**
  88 + * 实际终点时间
  89 + */
  90 + private String zdsjActual;
  91 +
  92 + /**
  93 + * 计发终点快误点
  94 + */
  95 + private int zdsjFast;
  96 +
  97 + /**
  98 + * 计发终点慢误点
  99 + */
  100 + private int zdsjSlow;
  101 +
  102 + /**
  103 + * 待发终点快误点
  104 + */
  105 + private int zdsjDfFast;
  106 +
  107 + /**
  108 + * 待发终点慢误点
  109 + */
  110 + private int zdsjDfSlow;
  111 +
  112 + @Column(name = "line_code")
  113 + private String lineCode;
  114 +
  115 + private Long t;
  116 +
  117 + public String getStationName() {
  118 + return stationName;
  119 + }
  120 +
  121 + public void setStationName(String stationName) {
  122 + this.stationName = stationName;
  123 + }
  124 +
  125 + public String getRq() {
  126 + return rq;
  127 + }
  128 +
  129 + public void setRq(String rq) {
  130 + this.rq = rq;
  131 + }
  132 +
  133 + public int getUpDown() {
  134 + return upDown;
  135 + }
  136 +
  137 + public void setUpDown(int upDown) {
  138 + this.upDown = upDown;
  139 + }
  140 +
  141 + public String getFcsj() {
  142 + return fcsj;
  143 + }
  144 +
  145 + public void setFcsj(String fcsj) {
  146 + this.fcsj = fcsj;
  147 + }
  148 +
  149 + public String getDfsj() {
  150 + return dfsj;
  151 + }
  152 +
  153 + public void setDfsj(String dfsj) {
  154 + this.dfsj = dfsj;
  155 + }
  156 +
  157 + public String getFcsjActual() {
  158 + return fcsjActual;
  159 + }
  160 +
  161 + public void setFcsjActual(String fcsjActual) {
  162 + this.fcsjActual = fcsjActual;
  163 + }
  164 +
  165 + public int getFcsjFast() {
  166 + return fcsjFast;
  167 + }
  168 +
  169 + public void setFcsjFast(int fcsjFast) {
  170 + this.fcsjFast = fcsjFast;
  171 + }
  172 +
  173 + public int getFcsjSlow() {
  174 + return fcsjSlow;
  175 + }
  176 +
  177 + public void setFcsjSlow(int fcsjSlow) {
  178 + this.fcsjSlow = fcsjSlow;
  179 + }
  180 +
  181 + public int getDfsjFast() {
  182 + return dfsjFast;
  183 + }
  184 +
  185 + public void setDfsjFast(int dfsjFast) {
  186 + this.dfsjFast = dfsjFast;
  187 + }
  188 +
  189 + public int getDfsjSlow() {
  190 + return dfsjSlow;
  191 + }
  192 +
  193 + public void setDfsjSlow(int dfsjSlow) {
  194 + this.dfsjSlow = dfsjSlow;
  195 + }
  196 +
  197 + public String getZdsj() {
  198 + return zdsj;
  199 + }
  200 +
  201 + public void setZdsj(String zdsj) {
  202 + this.zdsj = zdsj;
  203 + }
  204 +
  205 + public String getZdsjDf() {
  206 + return zdsjDf;
  207 + }
  208 +
  209 + public void setZdsjDf(String zdsjDf) {
  210 + this.zdsjDf = zdsjDf;
  211 + }
  212 +
  213 + public String getZdsjActual() {
  214 + return zdsjActual;
  215 + }
  216 +
  217 + public void setZdsjActual(String zdsjActual) {
  218 + this.zdsjActual = zdsjActual;
  219 + }
  220 +
  221 + public int getZdsjFast() {
  222 + return zdsjFast;
  223 + }
  224 +
  225 + public void setZdsjFast(int zdsjFast) {
  226 + this.zdsjFast = zdsjFast;
  227 + }
  228 +
  229 + public int getZdsjSlow() {
  230 + return zdsjSlow;
  231 + }
  232 +
  233 + public void setZdsjSlow(int zdsjSlow) {
  234 + this.zdsjSlow = zdsjSlow;
  235 + }
  236 +
  237 + public int getZdsjDfFast() {
  238 + return zdsjDfFast;
  239 + }
  240 +
  241 + public void setZdsjDfFast(int zdsjDfFast) {
  242 + this.zdsjDfFast = zdsjDfFast;
  243 + }
  244 +
  245 + public int getZdsjDfSlow() {
  246 + return zdsjDfSlow;
  247 + }
  248 +
  249 + public void setZdsjDfSlow(int zdsjDfSlow) {
  250 + this.zdsjDfSlow = zdsjDfSlow;
  251 + }
  252 +
  253 + public String getLineCode() {
  254 + return lineCode;
  255 + }
  256 +
  257 + public void setLineCode(String lineCode) {
  258 + this.lineCode = lineCode;
  259 + }
  260 +
  261 + public Long getId() {
  262 + return id;
  263 + }
  264 +
  265 + public void setId(Long id) {
  266 + this.id = id;
  267 + }
  268 +
  269 + public Long getT() {
  270 + return t;
  271 + }
  272 +
  273 + public void setT(Long t) {
  274 + this.t = t;
  275 + }
  276 +
  277 + public boolean isSlow() {
  278 + return this.fcsjSlow>0 || this.dfsjSlow>0 || this.zdsjSlow>0 || this.zdsjDfSlow>0;
  279 + }
  280 +
  281 + public boolean isFast() {
  282 + return this.fcsjFast>0 || this.dfsjFast>0 || this.zdsjFast>0 || this.zdsjDfFast>0;
  283 + }
284 284 }
285 285 \ No newline at end of file
... ...
src/main/java/com/bsth/data/summary/service/FastAndSlowService.java
1   -package com.bsth.data.summary.service;
2   -
3   -import com.bsth.data.summary.entity.FastAndSlow;
4   -import com.bsth.service.BaseService;
5   -
6   -import javax.servlet.http.HttpServletRequest;
7   -import javax.servlet.http.HttpServletResponse;
8   -
9   -/**
10   - * Created by panzhao on 2017/10/24.
11   - */
12   -public interface FastAndSlowService extends BaseService<FastAndSlow, Long>{
13   - void excel(String lineCode, String st, String et, int type, HttpServletRequest request, HttpServletResponse response);
  1 +package com.bsth.data.summary.service;
  2 +
  3 +import com.bsth.data.summary.entity.FastAndSlow;
  4 +import com.bsth.service.BaseService;
  5 +
  6 +import javax.servlet.http.HttpServletRequest;
  7 +import javax.servlet.http.HttpServletResponse;
  8 +
  9 +/**
  10 + * Created by panzhao on 2017/10/24.
  11 + */
  12 +public interface FastAndSlowService extends BaseService<FastAndSlow, Long>{
  13 + void excel(String lineCode, String st, String et, int type, HttpServletRequest request, HttpServletResponse response);
14 14 }
15 15 \ No newline at end of file
... ...
src/main/java/com/bsth/data/summary/service/impl/FastAndSlowServiceImpl.java
1   -package com.bsth.data.summary.service.impl;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.data.summary.entity.FastAndSlow;
5   -import com.bsth.data.summary.service.FastAndSlowService;
6   -import com.bsth.data.utils.ConvertUtil;
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;
16   -import org.slf4j.Logger;
17   -import org.slf4j.LoggerFactory;
18   -import org.springframework.stereotype.Service;
19   -
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.*;
28   -
29   -/**
30   - * Created by panzhao on 2017/10/24.
31   - */
32   -@Service
33   -public class FastAndSlowServiceImpl extends BaseServiceImpl<FastAndSlow, Long> implements FastAndSlowService {
34   -
35   - Logger logger = LoggerFactory.getLogger(this.getClass());
36   -
37   - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
38   -
39   - @Override
40   - public Iterable<FastAndSlow> list(Map<String, Object> map) {
41   - try {
42   - //最多5天
43   - map.put("rq_le", maxEndTime(map.get("rq_ge").toString()
44   - , map.get("rq_le").toString(), 5));
45   -
46   - List<FastAndSlow> list = (List) super.list(map);
47   - String type = String.valueOf(map.get("type"));
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 ;
71   - }
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());
77   - }
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));
96   - }
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) {
112   - logger.error("", e);
113   - }
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;
434   - }
  1 +package com.bsth.data.summary.service.impl;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.summary.entity.FastAndSlow;
  5 +import com.bsth.data.summary.service.FastAndSlowService;
  6 +import com.bsth.data.utils.ConvertUtil;
  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;
  16 +import org.slf4j.Logger;
  17 +import org.slf4j.LoggerFactory;
  18 +import org.springframework.stereotype.Service;
  19 +
  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.*;
  28 +
  29 +/**
  30 + * Created by panzhao on 2017/10/24.
  31 + */
  32 +@Service
  33 +public class FastAndSlowServiceImpl extends BaseServiceImpl<FastAndSlow, Long> implements FastAndSlowService {
  34 +
  35 + Logger logger = LoggerFactory.getLogger(this.getClass());
  36 +
  37 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  38 +
  39 + @Override
  40 + public Iterable<FastAndSlow> list(Map<String, Object> map) {
  41 + try {
  42 + //最多5天
  43 + map.put("rq_le", maxEndTime(map.get("rq_ge").toString()
  44 + , map.get("rq_le").toString(), 5));
  45 +
  46 + List<FastAndSlow> list = (List) super.list(map);
  47 + String type = String.valueOf(map.get("type"));
  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 ;
  71 + }
  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());
  77 + }
  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));
  96 + }
  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) {
  112 + logger.error("", e);
  113 + }
  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;
  434 + }
435 435 }
436 436 \ No newline at end of file
... ...
src/main/java/com/bsth/data/utils/ConvertUtil.java
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   -}
  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/java/com/bsth/entity/mcy_forms/Singledata.java
... ... @@ -7,6 +7,7 @@ public class Singledata {
7 7 private String gS;//所属公司
8 8  
9 9 private String xL;//线路
  10 + private String xlmc;//线路名称
10 11  
11 12 private String clzbh;//车号
12 13  
... ... @@ -141,6 +142,14 @@ public class Singledata {
141 142 public void setJhjl(String jhjl) {
142 143 this.jhjl = jhjl;
143 144 }
  145 +
  146 + public String getXlmc() {
  147 + return xlmc;
  148 + }
  149 +
  150 + public void setXlmc(String xlmc) {
  151 + this.xlmc = xlmc;
  152 + }
144 153  
145 154  
146 155  
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -765,7 +765,8 @@ public class FormsServiceImpl implements FormsService {
765 765  
766 766 sin.setEmptMileage(String.valueOf(zksgl));
767 767 sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
768   - sin.setxL(BasicData.lineCode2NameMap.get(y.getXlbm()));
  768 + sin.setxL(y.getXlbm());
  769 + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));
769 770 sin.setClzbh(clzbh);
770 771 sin.setJsy(jsy);
771 772 sin.setrQ(startDate);
... ... @@ -787,19 +788,28 @@ public class FormsServiceImpl implements FormsService {
787 788 String line=y.getXlbm();
788 789 String clzbh=y.getNbbm();
789 790 List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  791 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
790 792 for (int j = 0; j < listReal.size(); j++) {
791 793 ScheduleRealInfo s=listReal.get(j);
792 794 if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
793 795 &&s.getXlBm().equals(line)){
794 796 newList.add(s);
  797 + Set<ChildTaskPlan> cts = s.getcTasks();
  798 + if(cts != null && cts.size() > 0){
  799 + newList_.add(s);
  800 + }else{
  801 + if(s.getZdsjActual()!=null){
  802 + newList_.add(s);
  803 + }
  804 + }
795 805 }
796 806 }
797 807 double jhgl=culateMileageService.culateJhgl(newList);
798 808 double jhjcc=culateMileageService.culateJhJccgl(newList);
799   - double yygl=culateMileageService.culateSjgl(newList);
800   - double ljgl=culateMileageService.culateLjgl(newList);
801   - double ksgl=culateMileageService.culateKsgl(newList);
802   - double jcgl=culateMileageService.culateJccgl(newList);
  809 + double yygl=culateMileageService.culateSjgl(newList_);
  810 + double ljgl=culateMileageService.culateLjgl(newList_);
  811 + double ksgl=culateMileageService.culateKsgl(newList_);
  812 + double jcgl=culateMileageService.culateJccgl(newList_);
803 813  
804 814 double zyygl=Arith.add(yygl, ljgl);
805 815 double zksgl=Arith.add(ksgl, jcgl);
... ... @@ -809,7 +819,8 @@ public class FormsServiceImpl implements FormsService {
809 819  
810 820 sin.setEmptMileage(String.valueOf(zksgl));
811 821 sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
812   - sin.setxL(BasicData.lineCode2NameMap.get(y.getXlbm()));
  822 + sin.setxL(y.getXlbm());
  823 + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));
813 824 sin.setClzbh(clzbh);
814 825 sin.setJsy(jsy);
815 826 sin.setrQ(startDate);
... ... @@ -823,10 +834,10 @@ public class FormsServiceImpl implements FormsService {
823 834 listD.add(sin);
824 835 }
825 836  
826   - Collections.sort(listY,new SingledataByXlbm());
827   - Collections.sort(listD,new SingledataByXlbm());
828   - list.addAll(listY);
829   - list.addAll(listD);
  837 + Collections.sort(listY,new SingledataByXlbm());
  838 + Collections.sort(listD,new SingledataByXlbm());
  839 + list.addAll(listY);
  840 + list.addAll(listD);
830 841 }else{
831 842 String sql="select r.s_gh,r.s_name, "
832 843 + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm"
... ... @@ -862,19 +873,29 @@ public class FormsServiceImpl implements FormsService {
862 873 String line=sin.getxL();
863 874 String clzbh=sin.getClzbh();
864 875 List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  876 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  877 +
865 878 for (int j = 0; j < listReal.size(); j++) {
866 879 ScheduleRealInfo s=listReal.get(j);
867 880 if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh)
868 881 &&s.getXlBm().equals(line)){
869 882 newList.add(s);
  883 + Set<ChildTaskPlan> cts = s.getcTasks();
  884 + if(cts != null && cts.size() > 0){
  885 + newList_.add(s);
  886 + }else{
  887 + if(s.getZdsjActual()!=null){
  888 + newList_.add(s);
  889 + }
  890 + }
870 891 }
871 892 }
872 893 double jhgl=culateMileageService.culateJhgl(newList);
873 894 double jhjcc=culateMileageService.culateJhJccgl(newList);
874   - double yygl=culateMileageService.culateSjgl(newList);
875   - double ljgl=culateMileageService.culateLjgl(newList);
876   - double ksgl=culateMileageService.culateKsgl(newList);
877   - double jcgl=culateMileageService.culateJccgl(newList);
  895 + double yygl=culateMileageService.culateSjgl(newList_);
  896 + double ljgl=culateMileageService.culateLjgl(newList_);
  897 + double ksgl=culateMileageService.culateKsgl(newList_);
  898 + double jcgl=culateMileageService.culateJccgl(newList_);
878 899  
879 900 double zyygl=Arith.add(yygl, ljgl);
880 901 double zksgl=Arith.add(ksgl, jcgl);
... ...
src/main/resources/static/pages/mforms/singledatas/singledata.html
... ... @@ -221,7 +221,7 @@
221 221 <td>{{i+1}}</td>
222 222 <td>{{obj.rQ}}</td>
223 223 <td>{{obj.gS}}</td>
224   - <td>{{obj.xL}}</td>
  224 + <td>{{obj.xlmc}}</td>
225 225 <td>{{obj.clzbh}}</td>
226 226 <td>{{obj.jsy}}</td>
227 227 <td>{{obj.jName}}</td>
... ...