Commit 4b460f3d6feb4911f30d14f455240136c9db1f5b

Authored by 潘钊
1 parent 609d71b6

update...

src/main/java/com/bsth/controller/realcontrol/summary/DestroySituationController.java
... ... @@ -2,13 +2,28 @@ package com.bsth.controller.realcontrol.summary;
2 2  
3 3 import com.bsth.controller.BaseController;
4 4 import com.bsth.data.summary.entity.DestroySituation;
  5 +import com.bsth.data.summary.service.DestroySituationService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
5 7 import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestParam;
6 9 import org.springframework.web.bind.annotation.RestController;
7 10  
  11 +import javax.servlet.http.HttpServletRequest;
  12 +import javax.servlet.http.HttpServletResponse;
  13 +import java.util.Map;
  14 +
8 15 /**
9 16 * Created by panzhao on 2017/11/1.
10 17 */
11 18 @RestController
12 19 @RequestMapping("/summary/destroy_detail")
13 20 public class DestroySituationController extends BaseController<DestroySituation, Long> {
  21 +
  22 + @Autowired
  23 + DestroySituationService destroySituationService;
  24 +
  25 + @RequestMapping("excel")
  26 + public void excel(@RequestParam Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) {
  27 + destroySituationService.excel(map, request, response);
  28 + }
14 29 }
... ...
src/main/java/com/bsth/data/summary/service/DestroySituationService.java
... ... @@ -3,8 +3,13 @@ package com.bsth.data.summary.service;
3 3 import com.bsth.data.summary.entity.DestroySituation;
4 4 import com.bsth.service.BaseService;
5 5  
  6 +import javax.servlet.http.HttpServletRequest;
  7 +import javax.servlet.http.HttpServletResponse;
  8 +import java.util.Map;
  9 +
6 10 /**
7 11 * Created by panzhao on 2017/11/1.
8 12 */
9 13 public interface DestroySituationService extends BaseService<DestroySituation, Long> {
  14 + void excel(Map<String, Object> map, HttpServletRequest request, HttpServletResponse response);
10 15 }
... ...
src/main/java/com/bsth/data/summary/service/impl/DestroySituationServiceImpl.java
... ... @@ -2,12 +2,94 @@ package com.bsth.data.summary.service.impl;
2 2  
3 3 import com.bsth.data.summary.entity.DestroySituation;
4 4 import com.bsth.data.summary.service.DestroySituationService;
  5 +import com.bsth.data.utils.CustomStringUtils;
5 6 import com.bsth.service.impl.BaseServiceImpl;
  7 +import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  8 +import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  9 +import org.apache.poi.ss.usermodel.Row;
  10 +import org.apache.poi.ss.usermodel.Sheet;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
6 13 import org.springframework.stereotype.Service;
7 14  
  15 +import javax.servlet.http.HttpServletRequest;
  16 +import javax.servlet.http.HttpServletResponse;
  17 +import java.io.FileInputStream;
  18 +import java.io.OutputStream;
  19 +import java.net.URLEncoder;
  20 +import java.text.SimpleDateFormat;
  21 +import java.util.*;
  22 +
8 23 /**
9 24 * Created by panzhao on 2017/11/1.
10 25 */
11 26 @Service
12 27 public class DestroySituationServiceImpl extends BaseServiceImpl<DestroySituation, Long> implements DestroySituationService {
  28 +
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + @Override
  32 + public void excel(Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) {
  33 + try {
  34 + map.put("rq_le", CustomStringUtils.maxEndTime(map.get("rq_ge").toString()
  35 + , map.get("rq_le").toString(), 62));
  36 +
  37 + List<DestroySituation> list = (List<DestroySituation>) super.list(map);
  38 +
  39 + if(list.size() == 0){
  40 + response.setHeader("Content-type", "text/html;charset=UTF-8");
  41 + response.getWriter().print("<span style='color:red;font-size:24px;'>根据查询条件没有搜索到数据,别导了!</span>");
  42 + return ;
  43 + }
  44 +
  45 + //排序
  46 + Collections.sort(list, new Comparator<DestroySituation>() {
  47 + @Override
  48 + public int compare(DestroySituation o1, DestroySituation o2) {
  49 + return (int) (o1.getT() - o2.getT());
  50 + }
  51 + });
  52 +
  53 + //输出excel
  54 + String basePath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
  55 + String filePath = basePath + "/static/pages/summary/excel/烂班明细情况.xls";
  56 + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filePath));
  57 + HSSFWorkbook wb = new HSSFWorkbook(fs);
  58 +
  59 + //写入数据
  60 + Sheet sheet = wb.getSheetAt(0);
  61 + Row row;
  62 + DestroySituation dys;
  63 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  64 + for(int i = 0; i < list.size(); i++){
  65 + dys = list.get(i);
  66 + row = sheet.createRow(i + 1);
  67 + row.createCell(0).setCellValue(dys.getRq());
  68 + row.createCell(1).setCellValue(dys.getLineName());
  69 + row.createCell(2).setCellValue(dys.getNbbm());
  70 + row.createCell(3).setCellValue(dys.getjGh());
  71 + row.createCell(4).setCellValue(dys.getsGh());
  72 + row.createCell(5).setCellValue(dys.getReason());
  73 + row.createCell(6).setCellValue(dys.getSize());
  74 + row.createCell(7).setCellValue(dys.getMileage());
  75 + row.createCell(8).setCellValue(sdf.format(new Date(dys.getT())));
  76 + row.createCell(9).setCellValue(dys.getRemark());
  77 + }
  78 +
  79 + String name = list.get(0).getLineName();
  80 + wb.setSheetName(0, name + "烂班明细");
  81 + //response 输出
  82 + String filename = name + map.get("rq_ge") + "至" + map.get("rq_le") + "烂班明细情况.xls";
  83 + response.setContentType("application/x-msdownload");
  84 + response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
  85 +
  86 + OutputStream os = response.getOutputStream();
  87 + wb.write(os);
  88 + os.flush();
  89 + os.close();
  90 + } catch (Exception e) {
  91 + logger.error("", e);
  92 + }
  93 + }
  94 +
13 95 }
... ...
src/main/java/com/bsth/data/summary/service/impl/FastAndSlowServiceImpl.java
... ... @@ -4,6 +4,7 @@ import com.bsth.data.BasicData;
4 4 import com.bsth.data.summary.entity.FastAndSlow;
5 5 import com.bsth.data.summary.service.FastAndSlowService;
6 6 import com.bsth.data.utils.ConvertUtil;
  7 +import com.bsth.data.utils.CustomStringUtils;
7 8 import com.bsth.service.impl.BaseServiceImpl;
8 9 import com.google.common.collect.ArrayListMultimap;
9 10 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
... ... @@ -22,8 +23,6 @@ import javax.servlet.http.HttpServletResponse;
22 23 import java.io.FileInputStream;
23 24 import java.io.OutputStream;
24 25 import java.net.URLEncoder;
25   -import java.text.ParseException;
26   -import java.text.SimpleDateFormat;
27 26 import java.util.*;
28 27  
29 28 /**
... ... @@ -40,7 +39,7 @@ public class FastAndSlowServiceImpl extends BaseServiceImpl&lt;FastAndSlow, Long&gt; i
40 39 public Iterable<FastAndSlow> list(Map<String, Object> map) {
41 40 try {
42 41 //最多5天
43   - map.put("rq_le", maxEndTime(map.get("rq_ge").toString()
  42 + map.put("rq_le", CustomStringUtils.maxEndTime(map.get("rq_ge").toString()
44 43 , map.get("rq_le").toString(), 4));
45 44  
46 45 List<FastAndSlow> list = (List) super.list(map);
... ... @@ -58,7 +57,7 @@ public class FastAndSlowServiceImpl extends BaseServiceImpl&lt;FastAndSlow, Long&gt; i
58 57 try {
59 58 Map<String, Object> params = new HashMap();
60 59 //最多31天
61   - et = maxEndTime(st, et, 31);
  60 + et = CustomStringUtils.maxEndTime(st, et, 31);
62 61 params.put("rq_ge", st);
63 62 params.put("rq_le", et);
64 63 params.put("lineCode_eq", lineCode);
... ... @@ -198,23 +197,6 @@ public class FastAndSlowServiceImpl extends BaseServiceImpl&lt;FastAndSlow, Long&gt; i
198 197 }
199 198  
200 199  
201   - private String maxEndTime(String sStr, String eStr, int space) throws ParseException {
202   - try {
203   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
204   - long st = sdf.parse(sStr).getTime();
205   - long et = sdf.parse(eStr).getTime();
206   - long dayTime = 24 * 60 * 60 * 1000;
207   - long spaceTime = dayTime * space;
208   -
209   - if (et - st > spaceTime) {
210   - eStr = sdf.format(new Date(st + spaceTime));
211   - }
212   - } catch (Exception e) {
213   - throw e;
214   - }
215   - return eStr;
216   - }
217   -
218 200 /**
219 201 * 计划发出快误点
220 202 * @param list
... ...
src/main/java/com/bsth/data/utils/CustomStringUtils.java
... ... @@ -2,6 +2,10 @@ package com.bsth.data.utils;
2 2  
3 3 import org.apache.commons.lang3.StringUtils;
4 4  
  5 +import java.text.ParseException;
  6 +import java.text.SimpleDateFormat;
  7 +import java.util.Date;
  8 +
5 9 /**
6 10 * Created by panzhao on 2017/7/10.
7 11 */
... ... @@ -16,4 +20,21 @@ public class CustomStringUtils {
16 20 }
17 21 return s1.equals(s2);
18 22 }
  23 +
  24 + public static String maxEndTime(String sStr, String eStr, int space) throws ParseException {
  25 + try {
  26 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  27 + long st = sdf.parse(sStr).getTime();
  28 + long et = sdf.parse(eStr).getTime();
  29 + long dayTime = 24 * 60 * 60 * 1000;
  30 + long spaceTime = dayTime * space;
  31 +
  32 + if (et - st > spaceTime) {
  33 + eStr = sdf.format(new Date(st + spaceTime));
  34 + }
  35 + } catch (Exception e) {
  36 + throw e;
  37 + }
  38 + return eStr;
  39 + }
19 40 }
... ...
src/main/resources/static/pages/summary/destory_sch_detail/list.html
... ... @@ -158,7 +158,10 @@
158 158 <button class="uk-button uk-button-primary search"><i uk-icon="icon: search"></i>搜索</button>
159 159 </div>
160 160 <div class="ct_field ct_field_bottom">
161   - <span uk-icon="icon: question" title="导出功能先等等" uk-tooltip="pos: bottom"></span>
  161 + <button class="uk-button uk-button-text export_excel" style="padding: 0 5px;">导出数据</button>
  162 + </div>
  163 + <div class="ct_field ct_field_bottom">
  164 + <span uk-icon="icon: question" title="不统计进出场和子任务" uk-tooltip="pos: bottom"></span>
162 165 </div>
163 166 </form>
164 167 </div>
... ... @@ -198,7 +201,7 @@
198 201 <td>{{obj.jGh}}</td>
199 202 <td>{{obj.sGh}}</td>
200 203 <td>{{obj.reason}}</td>
201   - <td><a>{{obj.size}}</a></td>
  204 + <td><a style="text-decoration: underline;">{{obj.size}}</a></td>
202 205 <td>{{obj.mileage}}</td>
203 206 <td>{{obj.timeStr}}</td>
204 207 <td>{{obj.remark}}</td>
... ... @@ -332,6 +335,19 @@
332 335 return false;
333 336 });
334 337  
  338 + /**
  339 + * 导出
  340 + */
  341 + $('.export_excel').on('click', function () {
  342 + var data = f.serializeJSON();
  343 + data.rq_ge = data.rq.substr(0, 10);
  344 + data.rq_le = data.rq.substr(13);
  345 + data.order='t';
  346 + delete data.rq;
  347 +
  348 + window.open('/summary/destroy_detail/excel?' + $.param(data));
  349 + });
  350 +
335 351 </script>
336 352 </body>
337 353 </html>
338 354 \ No newline at end of file
... ...
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/main.html
... ... @@ -259,7 +259,7 @@
259 259 <button class="uk-button uk-button-text export_excel" style="padding: 0 5px;">导出数据</button>
260 260 </div>
261 261 <div class="ct_field ct_field_bottom">
262   - <span uk-icon="icon: question" title="快1慢3; 排除进出场班次<br>一次至多查询5天的数据,如需更大查询范围,请导出" uk-tooltip="pos: bottom"></span>
  262 + <span uk-icon="icon: question" title="快1慢3; 排除进出场和子任务班次<br>一次至多查询5天的数据,如需更大查询范围,请导出" uk-tooltip="pos: bottom"></span>
263 263 </div>
264 264 </form>
265 265 </div>
... ...
src/main/resources/static/real_control_v2/css/home.css
... ... @@ -58,6 +58,7 @@
58 58 padding-left: 0;
59 59 overflow: hidden;
60 60 background: #fff;
  61 + height: 100%;
61 62 }
62 63  
63 64 .home-gps-table {
... ...
src/main/resources/static/real_control_v2/js/main.js
... ... @@ -168,8 +168,8 @@ var disabled_submit_btn = function (form) {
168 168 function showUpdateDescription() {
169 169 //更新说明
170 170 var updateDescription = {
171   - date: '2017-10-25',
172   - text: '<h5>1、修正了双击调整待发时,备注会被清空的bug。!</h5><h5>2、现在发车和到站信使可以撤销和编辑。</h5>'
  171 + date: '2017-11-01',
  172 + text: '<h5>1、修正了XP系统下主页滚动条的显示问题(Windows XP sp3 + chrome 49.0.2623.112)。</h5>'
173 173 };
174 174  
175 175 var storage = window.localStorage
... ...