Commit 8f41b106a220c7b00d50f1f962407bae48885a7d

Authored by 潘钊
1 parent b9361d3a

update...

src/main/java/com/bsth/data/pilot80/PilotReport.java
... ... @@ -117,6 +117,10 @@ public class PilotReport {
117 117  
118 118 //推送到页面
119 119 sendUtils.send80ToPage(d80);
  120 +
  121 + //反射搜索用 瞬时字段
  122 + d80.setLineId(d80.getData().getLineId());
  123 + d80.setNbbm(d80.getData().getNbbm());
120 124 } catch (Exception e) {
121 125 logger.error("", e);
122 126 }
... ...
src/main/java/com/bsth/data/utils/ListFilterUtils.java 0 → 100644
  1 +package com.bsth.data.utils;
  2 +
  3 +import org.apache.commons.lang3.StringUtils;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +
  7 +import java.lang.reflect.Field;
  8 +import java.util.ArrayList;
  9 +import java.util.Collection;
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +/**
  14 + * 集合搜索过滤
  15 + * Created by panzhao on 2017/8/2.
  16 + */
  17 +public class ListFilterUtils {
  18 +
  19 + static Logger logger = LoggerFactory.getLogger(ListFilterUtils.class);
  20 +
  21 + public static List filter(Collection all, Map<String, Object> map, Class clazz) {
  22 + List rs = new ArrayList();
  23 + Field[] fields = clazz.getDeclaredFields();
  24 +
  25 + //参与过滤的字段
  26 + List<Field> fs = new ArrayList<>();
  27 + for (Field f : fields) {
  28 + f.setAccessible(true);
  29 + if (map.containsKey(f.getName()))
  30 + fs.add(f);
  31 + }
  32 +
  33 + //过滤数据
  34 + for (Object obj : all) {
  35 + if (fieldEquals(fs, obj, map))
  36 + rs.add(obj);
  37 + }
  38 + return rs;
  39 + }
  40 +
  41 + public static boolean fieldEquals(List<Field> fs, Object obj, Map<String, Object> map) {
  42 + try {
  43 + for (Field f : fs) {
  44 + if (StringUtils.isEmpty(map.get(f.getName()).toString()))
  45 + continue;
  46 +
  47 + if (f.get(obj) == null || f.get(obj).toString().indexOf(map.get(f.getName()).toString()) == -1)
  48 + return false;
  49 + }
  50 + } catch (Exception e) {
  51 + logger.error("", e);
  52 + return false;
  53 + }
  54 + return true;
  55 + }
  56 +}
... ...
src/main/java/com/bsth/data/utils/ListPageQueryUtils.java 0 → 100644
  1 +package com.bsth.data.utils;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * 集合分页工具
  8 + * Created by panzhao on 2017/8/2.
  9 + */
  10 +public class ListPageQueryUtils {
  11 +
  12 + public static List paging(List all, int page, int pageSize) {
  13 + List rs = new ArrayList(pageSize);
  14 +
  15 + int s = page * pageSize;
  16 + int e = (page + 1) * pageSize;
  17 +
  18 + int size = all.size();
  19 +
  20 + if (e > size)
  21 + e = size;
  22 +
  23 + if (s > size)
  24 + return rs;
  25 +
  26 + for (; s < e; s++) {
  27 + rs.add(all.get(s));
  28 + }
  29 + return rs;
  30 + }
  31 +}
... ...
src/main/java/com/bsth/entity/directive/D80.java
1 1 package com.bsth.entity.directive;
2 2  
3 3 import com.bsth.entity.directive.DC0.DC0Data;
  4 +import com.fasterxml.jackson.annotation.JsonIgnore;
4 5  
5 6 import javax.persistence.*;
6 7 import java.util.Date;
... ... @@ -65,6 +66,14 @@ public class D80 {
65 66  
66 67 private Long schId;
67 68  
  69 + @Transient
  70 + @JsonIgnore
  71 + private String lineId;
  72 +
  73 + @Transient
  74 + @JsonIgnore
  75 + private String nbbm;
  76 +
68 77 public Long getSchId() {
69 78 return schId;
70 79 }
... ... @@ -73,6 +82,22 @@ public class D80 {
73 82 this.schId = schId;
74 83 }
75 84  
  85 + public String getLineId() {
  86 + return data.lineId;
  87 + }
  88 +
  89 + public String getNbbm() {
  90 + return data.nbbm;
  91 + }
  92 +
  93 + public void setLineId(String lineId) {
  94 + this.lineId = lineId;
  95 + }
  96 +
  97 + public void setNbbm(String nbbm) {
  98 + this.nbbm = nbbm;
  99 + }
  100 +
76 101 @Embeddable
77 102 public static class D80Data {
78 103  
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -11,6 +11,8 @@ import com.bsth.data.gpsdata.GpsEntity;
11 11 import com.bsth.data.gpsdata.GpsRealData;
12 12 import com.bsth.data.pilot80.PilotReport;
13 13 import com.bsth.data.schedule.DayOfSchedule;
  14 +import com.bsth.data.utils.ListFilterUtils;
  15 +import com.bsth.data.utils.ListPageQueryUtils;
14 16 import com.bsth.entity.directive.*;
15 17 import com.bsth.entity.realcontrol.ScheduleRealInfo;
16 18 import com.bsth.entity.sys.SysUser;
... ... @@ -448,7 +450,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
448 450  
449 451 @Override
450 452 public Map<String, Object> findAll80(Map<String, Object> map, int page, int size) {
451   - List<D80> d80s = new ArrayList<>();
  453 + /*List<D80> d80s = new ArrayList<>();
452 454  
453 455 Object nbbm = map.get("nbbm");
454 456 if (null != nbbm && StringUtils.isNotEmpty(nbbm.toString())) {
... ... @@ -492,8 +494,18 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
492 494 Map<String, Object> rsMap = new HashMap<>();
493 495 rsMap.put("list", rs);
494 496 rsMap.put("totalPages", count % size == 0 ? count / size - 1 : count / size);
495   - rsMap.put("page", page);
  497 + rsMap.put("page", page);*/
496 498  
  499 + Collection all = pilotReport.findAll();
  500 + List<D80> d80s = ListPageQueryUtils.paging(ListFilterUtils.filter(all, map, D80.class), page, size);
  501 + //时间格式化
  502 + for (D80 d80 : d80s) {
  503 + d80.setTimeStr(fmtHHmm.print(d80.getTimestamp()));
  504 + }
  505 + Map<String, Object> rsMap = new HashMap<>();
  506 + rsMap.put("list", d80s);
  507 + rsMap.put("totalPages", d80s.size() % size == 0 ? d80s.size() / size - 1 : d80s.size() / size);
  508 + rsMap.put("page", page);
497 509 return rsMap;
498 510 }
499 511  
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/report_80.html
... ... @@ -14,6 +14,10 @@
14 14 <select name="requestCode">
15 15 <option value="-1">全部</option>
16 16 </select>
  17 + <span class="horizontal-field">线路</span>
  18 + <div class="uk-autocomplete uk-form autocomplete-line" >
  19 + <input type="text" name="lineId" placeholder="线路">
  20 + </div>
17 21 <span class="horizontal-field">车辆</span>
18 22 <div class="uk-autocomplete uk-form autocomplete-cars" >
19 23 <input type="text" name="nbbm" placeholder="车辆自编号">
... ... @@ -84,9 +88,9 @@
84 88 }
85 89 $('[name=requestCode]', modal).append(opt);
86 90 //车辆 autocomplete
87   - $.get('/basic/cars', function(rs) {
88   - gb_common.carAutocomplete($('.autocomplete-cars', modal), rs);
89   - });
  91 + gb_common.carAutocomplete($('.autocomplete-cars', modal), gb_data_basic.carsArray());
  92 + //线路 autocomplete
  93 + gb_common.lineAutocomplete($('.autocomplete-line', modal));
90 94 query();
91 95 });
92 96  
... ... @@ -102,6 +106,12 @@
102 106 var data = form.serializeJSON();
103 107 data.page = page;
104 108 data.size = pageSize;
  109 + //线路转换成编码
  110 + if(data.lineId){
  111 + var lineCode = gb_data_basic.findCodeByLinename(data.lineId);
  112 + if(lineCode)
  113 + data.lineId=lineCode;
  114 + }
105 115 $.get('/directive/findAll80', data, function(rs) {
106 116 $.each(rs.list, function(){
107 117 //命令字转中文
... ... @@ -122,7 +132,7 @@
122 132 if (resetPagination)
123 133 pagination(rs.totalPages + 1, rs.page);
124 134 })
125   - }
  135 + };
126 136  
127 137 var resetPagination = true;
128 138 var pagination = function(pages, currentPage) {
... ...