Commit b56a9043ef442ba58d6bb98f91082ed8ffb24dac

Authored by 王通
1 parent 441126ca

1.sso保留以前的登录地址

2.发车信息和实际班次批量保存的地方代码变更,加入异常数据记录
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
1   -package com.bsth.data.car_out_info;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
5   -import com.bsth.data.gpsdata_v2.entity.StationRoute;
6   -import com.bsth.data.schedule.DayOfSchedule;
7   -import com.bsth.data.schedule.ScheduleComparator;
8   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
9   -import com.google.common.collect.ArrayListMultimap;
10   -import org.apache.commons.lang3.StringUtils;
11   -import org.slf4j.Logger;
12   -import org.slf4j.LoggerFactory;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.jdbc.core.BatchPreparedStatementSetter;
15   -import org.springframework.jdbc.core.JdbcTemplate;
16   -import org.springframework.jdbc.datasource.DataSourceTransactionManager;
17   -import org.springframework.stereotype.Component;
18   -import org.springframework.transaction.TransactionDefinition;
19   -import org.springframework.transaction.TransactionStatus;
20   -import org.springframework.transaction.support.DefaultTransactionDefinition;
21   -
22   -import java.sql.PreparedStatement;
23   -import java.sql.SQLException;
24   -import java.util.*;
25   -
26   -/**
27   - * 发车信息表处理程序
28   - * Created by panzhao on 2017/5/5.
29   - */
30   -@Component
31   -public class CarOutInfoHandler {
32   -
33   - @Autowired
34   - DayOfSchedule dayOfSchedule;
35   -
36   - //班次类型对照表
37   - static Map<String, String> bcTypeMap;
38   -
39   - static{
40   - bcTypeMap = new HashMap<>();
41   - bcTypeMap.put("normal", "正常班次");
42   - bcTypeMap.put("region", "区间");
43   - bcTypeMap.put("venting", "直放");
44   - bcTypeMap.put("major", "放站");
45   - bcTypeMap.put("ldks", "两点间空驶");
46   - }
47   -
48   - private static ScheduleComparator.DFSJ2 schDFSJComparator = new ScheduleComparator.DFSJ2();
49   -
50   - @Autowired
51   - JdbcTemplate jdbcTemplate;
52   -
53   - Logger logger = LoggerFactory.getLogger(this.getClass());
54   -
55   -
56   - ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create();
57   - List<ScheduleRealInfo> pstList = new ArrayList<>();
58   - /**
59   - * 全量更新发车信息表
60   - */
61   - public void updateAll() {
62   - try{
63   - //将班次按线路分组
64   - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
65   - for(ScheduleRealInfo sch : all){
66   - xlMaps.put(sch.getXlBm(), sch);
67   - }
68   -
69   - Set<String> ks = xlMaps.keySet();
70   - for (String k : ks) {
71   - pstList.addAll(update(xlMaps.get(k)));
72   - }
73   -
74   - save(pstList);
75   - pstList.clear();
76   - xlMaps.clear();
77   - }catch (Exception e){
78   - logger.error("", e);
79   - }
80   - }
81   -
82   - public List<ScheduleRealInfo> update(List<ScheduleRealInfo> list) {
83   - if (list.size() == 0)
84   - return new ArrayList<>();
85   - //按上下行分组
86   - List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>();
87   - for (ScheduleRealInfo sch : list) {
88   - if (sch.getXlDir().equals("0"))
89   - ups.add(sch);
90   - else
91   - downs.add(sch);
92   - }
93   -
94   - ScheduleRealInfo[] upArray = nexts(ups),
95   - downArray = nexts(downs);
96   -
97   - List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray);
98   -
99   - return pstArray;
100   - }
101   -
102   - private void save(final List<ScheduleRealInfo> pstList){
103   - //编程式事务
104   - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
105   - DefaultTransactionDefinition def = new DefaultTransactionDefinition();
106   - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
107   - TransactionStatus status = tran.getTransaction(def);
108   -
109   - try{
110   - //删除
111   - jdbcTemplate.update("delete from bsth_t_clfcxxb");
112   - //重新写入
113   - jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" +
114   - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
115   - @Override
116   - public void setValues(PreparedStatement ps, int i) throws SQLException {
117   - ScheduleRealInfo sch = pstList.get(i);
118   - ps.setString(1, sch.getScheduleDateStr());
119   - ps.setString(2, sch.getXlBm());
120   - ps.setString(3, sch.getXlName());
121   - ps.setString(4, /*sch.getLpName()*/"0");
122   - ps.setInt(5, sch.getFcno()==null?-1:sch.getFcno());
123   - ps.setString(6, sch.getDfsj().replace(":", ""));
124   - ps.setString(7, sch.getClZbh().replace("-", ""));
125   - ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh()));
126   - ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType());
127   - ps.setString(10, sch.getZdzName());
128   - ps.setInt(11, Integer.parseInt(sch.getXlDir()));
129   - ps.setString(12, sch.getjGh());
130   - ps.setString(13, sch.getjName());
131   - ps.setString(14, sch.getRemarks());
132   - ps.setInt(15, sch.getFcpSn());
133   - }
134   -
135   - @Override
136   - public int getBatchSize() {
137   - return pstList.size();
138   - }
139   - });
140   -
141   - tran.commit(status);
142   - }catch (Exception e){
143   - tran.rollback(status);
144   - }
145   - }
146   -
147   - private List<ScheduleRealInfo> mergeArray(ScheduleRealInfo[] upArray, ScheduleRealInfo[] downArray) {
148   - List<ScheduleRealInfo> list = new ArrayList<>();
149   - for (int i = 0; i < upArray.length; i++) {
150   - if (upArray[i] != null) {
151   - upArray[i].setFcpSn(i + 1);
152   - list.add(upArray[i]);
153   - }
154   - }
155   - for (int i = 0; i < downArray.length; i++) {
156   - if (downArray[i] != null) {
157   - downArray[i].setFcpSn(i + 1);
158   - list.add(downArray[i]);
159   - }
160   - }
161   - return list;
162   - }
163   -
164   - /**
165   - * 接下来要执行的3个班次
166   - *
167   - * @param list
168   - * @return
169   - */
170   - private static String[] fls = new String[]{"in","out","ldks","venting","major"};
171   - private static List<String> clearTypes;
172   - static {
173   - clearTypes = Arrays.asList(fls);
174   - }
175   - private ScheduleRealInfo[] nexts(List<ScheduleRealInfo> list) {
176   - ScheduleRealInfo[] array = new ScheduleRealInfo[3];
177   - Collections.sort(list, schDFSJComparator);
178   -
179   - int count = 0;//, threshold = 1000 * 60 * 60 * 4;
180   - //long t = System.currentTimeMillis();
181   - for (ScheduleRealInfo sch : list) {
182   - if (count == 3)
183   - break;
184   -
185   - //烂班
186   - if (sch.isDestroy())
187   - continue;
188   -
189   - //进场、出场、2点间空驶
190   - if (clearTypes.contains(sch.getBcType()))
191   - continue;
192   -
193   - //区间
194   - if (sch.getBcType().equals("region")){
195   - //是否起点发出
196   - if(!isStartOut(sch))
197   - continue;
198   - }
199   -
200   - //有实发实达时间的
201   - if (StringUtils.isNotEmpty(sch.getFcsjActual())
202   - || StringUtils.isNotEmpty(sch.getZdsjActual()))
203   - continue;
204   -
205   - /*if (t - sch.getDfsjT() > threshold)
206   - continue;*/
207   -
208   - array[count] = sch;
209   - count++;
210   - }
211   - return array;
212   - }
213   -
214   - private static StationRouteComp sComp = new StationRouteComp();
215   - private boolean isStartOut(ScheduleRealInfo sch) {
216   - try{
217   - List<StationRoute> list = GeoCacheData.getStationRoute(sch.getXlBm(), Integer.parseInt(sch.getXlDir()));
218   -
219   - if(null == list && list.size() == 0)
220   - return false;
221   - //排序
222   - Collections.sort(list, sComp);
223   -
224   - if(sch.getQdzName().equals(list.get(0).getName()))
225   - return true;
226   - }catch (Exception e){
227   - logger.error("", e);
228   - }
229   - return false;
230   - }
231   -
232   - private static class StationRouteComp implements Comparator<StationRoute> {
233   -
234   - @Override
235   - public int compare(StationRoute s1, StationRoute s2) {
236   - return s1.getRouteSort() - s2.getRouteSort();
237   - }
238   - }
239   -}
  1 +package com.bsth.data.car_out_info;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.data.schedule.ScheduleComparator;
  8 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import com.fasterxml.jackson.core.JsonProcessingException;
  10 +import com.fasterxml.jackson.databind.ObjectMapper;
  11 +import com.google.common.collect.ArrayListMultimap;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  17 +import org.springframework.jdbc.core.JdbcTemplate;
  18 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  19 +import org.springframework.stereotype.Component;
  20 +import org.springframework.transaction.TransactionDefinition;
  21 +import org.springframework.transaction.TransactionStatus;
  22 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  23 +import org.springframework.transaction.support.TransactionCallback;
  24 +import org.springframework.transaction.support.TransactionCallbackWithoutResult;
  25 +import org.springframework.transaction.support.TransactionTemplate;
  26 +
  27 +import java.sql.PreparedStatement;
  28 +import java.sql.SQLException;
  29 +import java.util.*;
  30 +
  31 +/**
  32 + * 发车信息表处理程序
  33 + * Created by panzhao on 2017/5/5.
  34 + */
  35 +@Component
  36 +public class CarOutInfoHandler {
  37 +
  38 + @Autowired
  39 + DayOfSchedule dayOfSchedule;
  40 +
  41 + //班次类型对照表
  42 + static Map<String, String> bcTypeMap;
  43 +
  44 + static{
  45 + bcTypeMap = new HashMap<>();
  46 + bcTypeMap.put("normal", "正常班次");
  47 + bcTypeMap.put("region", "区间");
  48 + bcTypeMap.put("venting", "直放");
  49 + bcTypeMap.put("major", "放站");
  50 + bcTypeMap.put("ldks", "两点间空驶");
  51 + }
  52 +
  53 + private static ScheduleComparator.DFSJ2 schDFSJComparator = new ScheduleComparator.DFSJ2();
  54 +
  55 + @Autowired
  56 + JdbcTemplate jdbcTemplate;
  57 +
  58 + @Autowired
  59 + private TransactionTemplate transactionTemplate;
  60 +
  61 + @Autowired
  62 + private ObjectMapper mapper;
  63 +
  64 + Logger logger = LoggerFactory.getLogger(this.getClass());
  65 +
  66 +
  67 + ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create();
  68 + List<ScheduleRealInfo> pstList = new ArrayList<>();
  69 + /**
  70 + * 全量更新发车信息表
  71 + */
  72 + public void updateAll() {
  73 + try{
  74 + //将班次按线路分组
  75 + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
  76 + for(ScheduleRealInfo sch : all){
  77 + xlMaps.put(sch.getXlBm(), sch);
  78 + }
  79 +
  80 + Set<String> ks = xlMaps.keySet();
  81 + for (String k : ks) {
  82 + pstList.addAll(update(xlMaps.get(k)));
  83 + }
  84 +
  85 + save(pstList);
  86 + pstList.clear();
  87 + xlMaps.clear();
  88 + }catch (Exception e){
  89 + logger.error("", e);
  90 + }
  91 + }
  92 +
  93 + public List<ScheduleRealInfo> update(List<ScheduleRealInfo> list) {
  94 + if (list.size() == 0)
  95 + return new ArrayList<>();
  96 + //按上下行分组
  97 + List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>();
  98 + for (ScheduleRealInfo sch : list) {
  99 + if (sch.getXlDir().equals("0"))
  100 + ups.add(sch);
  101 + else
  102 + downs.add(sch);
  103 + }
  104 +
  105 + ScheduleRealInfo[] upArray = nexts(ups),
  106 + downArray = nexts(downs);
  107 +
  108 + List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray);
  109 +
  110 + return pstArray;
  111 + }
  112 +
  113 + private void save(final List<ScheduleRealInfo> pstList){
  114 + transactionTemplate.execute(new TransactionCallbackWithoutResult() {
  115 +
  116 + @Override
  117 + public void doInTransactionWithoutResult(TransactionStatus status) {
  118 + try {
  119 + //删除
  120 + jdbcTemplate.update("delete from bsth_t_clfcxxb");
  121 + //重新写入
  122 + jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" +
  123 + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
  124 + @Override
  125 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  126 + ScheduleRealInfo sch = pstList.get(i);
  127 + ps.setString(1, sch.getScheduleDateStr());
  128 + ps.setString(2, sch.getXlBm());
  129 + ps.setString(3, sch.getXlName());
  130 + ps.setString(4, /*sch.getLpName()*/"0");
  131 + ps.setInt(5, sch.getFcno()==null?-1:sch.getFcno());
  132 + ps.setString(6, sch.getDfsj().replace(":", ""));
  133 + ps.setString(7, sch.getClZbh().replace("-", ""));
  134 + ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh()));
  135 + ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType());
  136 + ps.setString(10, sch.getZdzName());
  137 + ps.setInt(11, Integer.parseInt(sch.getXlDir()));
  138 + ps.setString(12, sch.getjGh());
  139 + ps.setString(13, sch.getjName());
  140 + ps.setString(14, sch.getRemarks());
  141 + ps.setInt(15, sch.getFcpSn());
  142 + }
  143 +
  144 + @Override
  145 + public int getBatchSize() {
  146 + return pstList.size();
  147 + }
  148 + });
  149 + } catch (Exception e) {
  150 + status.setRollbackOnly();
  151 + try {
  152 + logger.error(String.format("发车信息批量保存异常: %s", mapper.writeValueAsString(pstList)), e);
  153 + } catch (JsonProcessingException jsonProcessingException) {
  154 + jsonProcessingException.printStackTrace();
  155 + }
  156 + }
  157 + }
  158 + });
  159 + }
  160 +
  161 + private List<ScheduleRealInfo> mergeArray(ScheduleRealInfo[] upArray, ScheduleRealInfo[] downArray) {
  162 + List<ScheduleRealInfo> list = new ArrayList<>();
  163 + for (int i = 0; i < upArray.length; i++) {
  164 + if (upArray[i] != null) {
  165 + upArray[i].setFcpSn(i + 1);
  166 + list.add(upArray[i]);
  167 + }
  168 + }
  169 + for (int i = 0; i < downArray.length; i++) {
  170 + if (downArray[i] != null) {
  171 + downArray[i].setFcpSn(i + 1);
  172 + list.add(downArray[i]);
  173 + }
  174 + }
  175 + return list;
  176 + }
  177 +
  178 + /**
  179 + * 接下来要执行的3个班次
  180 + *
  181 + * @param list
  182 + * @return
  183 + */
  184 + private static String[] fls = new String[]{"in","out","ldks","venting","major"};
  185 + private static List<String> clearTypes;
  186 + static {
  187 + clearTypes = Arrays.asList(fls);
  188 + }
  189 + private ScheduleRealInfo[] nexts(List<ScheduleRealInfo> list) {
  190 + ScheduleRealInfo[] array = new ScheduleRealInfo[3];
  191 + Collections.sort(list, schDFSJComparator);
  192 +
  193 + int count = 0;//, threshold = 1000 * 60 * 60 * 4;
  194 + //long t = System.currentTimeMillis();
  195 + for (ScheduleRealInfo sch : list) {
  196 + if (count == 3)
  197 + break;
  198 +
  199 + //烂班
  200 + if (sch.isDestroy())
  201 + continue;
  202 +
  203 + //进场、出场、2点间空驶
  204 + if (clearTypes.contains(sch.getBcType()))
  205 + continue;
  206 +
  207 + //区间
  208 + if (sch.getBcType().equals("region")){
  209 + //是否起点发出
  210 + if(!isStartOut(sch))
  211 + continue;
  212 + }
  213 +
  214 + //有实发实达时间的
  215 + if (StringUtils.isNotEmpty(sch.getFcsjActual())
  216 + || StringUtils.isNotEmpty(sch.getZdsjActual()))
  217 + continue;
  218 +
  219 + /*if (t - sch.getDfsjT() > threshold)
  220 + continue;*/
  221 +
  222 + array[count] = sch;
  223 + count++;
  224 + }
  225 + return array;
  226 + }
  227 +
  228 + private static StationRouteComp sComp = new StationRouteComp();
  229 + private boolean isStartOut(ScheduleRealInfo sch) {
  230 + try{
  231 + List<StationRoute> list = GeoCacheData.getStationRoute(sch.getXlBm(), Integer.parseInt(sch.getXlDir()));
  232 +
  233 + if(null == list && list.size() == 0)
  234 + return false;
  235 + //排序
  236 + Collections.sort(list, sComp);
  237 +
  238 + if(sch.getQdzName().equals(list.get(0).getName()))
  239 + return true;
  240 + }catch (Exception e){
  241 + logger.error("", e);
  242 + }
  243 + return false;
  244 + }
  245 +
  246 + private static class StationRouteComp implements Comparator<StationRoute> {
  247 +
  248 + @Override
  249 + public int compare(StationRoute s1, StationRoute s2) {
  250 + return s1.getRouteSort() - s2.getRouteSort();
  251 + }
  252 + }
  253 +}
... ...
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
1 1 package com.bsth.data.schedule.thread;
2 2  
  3 +import com.bsth.data.BasicData;
3 4 import com.bsth.data.schedule.DayOfSchedule;
4 5 import com.bsth.entity.realcontrol.ScheduleRealInfo;
5 6 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  7 +import com.fasterxml.jackson.core.JsonProcessingException;
  8 +import com.fasterxml.jackson.databind.ObjectMapper;
6 9 import org.slf4j.Logger;
7 10 import org.slf4j.LoggerFactory;
8 11 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -13,6 +16,8 @@ import org.springframework.stereotype.Component;
13 16 import org.springframework.transaction.TransactionDefinition;
14 17 import org.springframework.transaction.TransactionStatus;
15 18 import org.springframework.transaction.support.DefaultTransactionDefinition;
  19 +import org.springframework.transaction.support.TransactionCallbackWithoutResult;
  20 +import org.springframework.transaction.support.TransactionTemplate;
16 21  
17 22 import java.sql.PreparedStatement;
18 23 import java.sql.SQLException;
... ... @@ -35,8 +40,14 @@ public class SchedulePstThread extends Thread {
35 40 JdbcTemplate jdbcTemplate;
36 41  
37 42 @Autowired
  43 + private TransactionTemplate transactionTemplate;
  44 +
  45 + @Autowired
38 46 DayOfSchedule dayOfSchedule;
39 47  
  48 + @Autowired
  49 + private ObjectMapper mapper;
  50 +
40 51 Logger logger = LoggerFactory.getLogger(this.getClass());
41 52  
42 53 static List<ScheduleRealInfo> saveList = new ArrayList<>();
... ... @@ -82,86 +93,87 @@ public class SchedulePstThread extends Thread {
82 93  
83 94 private void update2Db(){
84 95 final List<ScheduleRealInfo> pstList = saveList;
85   - //编程式事务
86   - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
87   - DefaultTransactionDefinition def = new DefaultTransactionDefinition();
88   - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
89   - TransactionStatus status = tran.getTransaction(def);
90   -
91   - try{
92   - //更新
93   - jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" +
94   - ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" +
95   - ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" +
96   - ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" +
97   - ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" +
98   - ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=?,rfid_state=?,first_rfid_state=? where id=?", new BatchPreparedStatementSetter() {
99   - @Override
100   - public void setValues(PreparedStatement ps, int i) throws SQLException {
101   - ScheduleRealInfo sch = pstList.get(i);
102   - ps.setString(1, sch.getBcType());
103   - ps.setInt(2, sch.getBcs()==null?0:sch.getBcs());
104   - ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj());
105   - ps.setString(4, sch.getClZbh());
106   - ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime()));
107   - ps.setString(6, sch.getDfsj());
108   - ps.setInt(7, sch.getDirectiveState());
109   - ps.setInt(8, sch.getFcno()==null?0:sch.getFcno());
110   - ps.setString(9, sch.getFcsj());
111   - ps.setString(10, sch.getFcsjActual());
112   - ps.setString(11, sch.getjGh());
113   - ps.setString(12, sch.getjName());
114   - ps.setDouble(13, sch.getJhlc());
115   - ps.setString(14, sch.getLpName());
116   - ps.setString(15, sch.getQdzCode());
117   - ps.setString(16, sch.getQdzName());
118   - ps.setString(17, sch.getRealExecDate());
119   - ps.setString(18, sch.getRemarks());
120   - ps.setString(19, sch.getsGh());
121   - ps.setString(20, sch.getsName());
122   - ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime()));
123   - ps.setString(22, sch.getScheduleDateStr());
124   - ps.setBoolean(23, sch.isSflj());
125   - ps.setLong(24, sch.getSpId());
126   - ps.setInt(25, sch.getStatus());
127   - ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime()));
128   - ps.setString(27, sch.getXlBm());
129   - ps.setString(28, sch.getXlDir());
130   - ps.setString(29, sch.getXlName());
131   - ps.setString(30, sch.getZdsj());
132   - ps.setString(31, sch.getZdsjActual());
133   - ps.setString(32, sch.getZdzCode());
134   - ps.setString(33, sch.getZdzName());
135   - ps.setInt(34, sch.getCcno()==null?0:sch.getCcno());
136   - ps.setBoolean(35, sch.isDfAuto());
137   - ps.setString(36, sch.getFgsBm());
138   - ps.setString(37, sch.getFgsName());
139   - ps.setString(38, sch.getGsBm());
140   - ps.setString(39, sch.getGsName());
141   - ps.setBoolean(40, sch.isOnline());
142   - ps.setString(41, sch.getAdjustExps());
143   - ps.setBoolean(42, sch.isReissue());
144   - ps.setDouble(43, sch.getJhlcOrig()==null?0:sch.getJhlcOrig());
145   - ps.setInt(44, sch.getSiginCompate());
146   - ps.setInt(45, sch.getDriftStatus());
147   - ps.setBoolean(46, sch.isCcService());
148   - ps.setString(47, sch.getMajorStationName());
149   - ps.setInt(48, sch.getRfidState());
150   - ps.setInt(49, sch.getFirstRfidState());
151   -
152   - ps.setLong(50, sch.getId());
  96 + transactionTemplate.execute(new TransactionCallbackWithoutResult() {
  97 +
  98 + @Override
  99 + public void doInTransactionWithoutResult(TransactionStatus status) {
  100 + try {
  101 + //更新
  102 + jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" +
  103 + ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" +
  104 + ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" +
  105 + ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" +
  106 + ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" +
  107 + ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=?,rfid_state=?,first_rfid_state=? where id=?", new BatchPreparedStatementSetter() {
  108 + @Override
  109 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  110 + ScheduleRealInfo sch = pstList.get(i);
  111 + ps.setString(1, sch.getBcType());
  112 + ps.setInt(2, sch.getBcs()==null?0:sch.getBcs());
  113 + ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj());
  114 + ps.setString(4, sch.getClZbh());
  115 + ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime()));
  116 + ps.setString(6, sch.getDfsj());
  117 + ps.setInt(7, sch.getDirectiveState());
  118 + ps.setInt(8, sch.getFcno()==null?0:sch.getFcno());
  119 + ps.setString(9, sch.getFcsj());
  120 + ps.setString(10, sch.getFcsjActual());
  121 + ps.setString(11, sch.getjGh());
  122 + ps.setString(12, sch.getjName());
  123 + ps.setDouble(13, sch.getJhlc());
  124 + ps.setString(14, sch.getLpName());
  125 + ps.setString(15, sch.getQdzCode());
  126 + ps.setString(16, sch.getQdzName());
  127 + ps.setString(17, sch.getRealExecDate());
  128 + ps.setString(18, sch.getRemarks());
  129 + ps.setString(19, sch.getsGh());
  130 + ps.setString(20, sch.getsName());
  131 + ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime()));
  132 + ps.setString(22, sch.getScheduleDateStr());
  133 + ps.setBoolean(23, sch.isSflj());
  134 + ps.setLong(24, sch.getSpId());
  135 + ps.setInt(25, sch.getStatus());
  136 + ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime()));
  137 + ps.setString(27, sch.getXlBm());
  138 + ps.setString(28, sch.getXlDir());
  139 + ps.setString(29, sch.getXlName());
  140 + ps.setString(30, sch.getZdsj());
  141 + ps.setString(31, sch.getZdsjActual());
  142 + ps.setString(32, sch.getZdzCode());
  143 + ps.setString(33, sch.getZdzName());
  144 + ps.setInt(34, sch.getCcno()==null?0:sch.getCcno());
  145 + ps.setBoolean(35, sch.isDfAuto());
  146 + ps.setString(36, sch.getFgsBm());
  147 + ps.setString(37, sch.getFgsName());
  148 + ps.setString(38, sch.getGsBm());
  149 + ps.setString(39, sch.getGsName());
  150 + ps.setBoolean(40, sch.isOnline());
  151 + ps.setString(41, sch.getAdjustExps());
  152 + ps.setBoolean(42, sch.isReissue());
  153 + ps.setDouble(43, sch.getJhlcOrig()==null?0:sch.getJhlcOrig());
  154 + ps.setInt(44, sch.getSiginCompate());
  155 + ps.setInt(45, sch.getDriftStatus());
  156 + ps.setBoolean(46, sch.isCcService());
  157 + ps.setString(47, sch.getMajorStationName());
  158 + ps.setInt(48, sch.getRfidState());
  159 + ps.setInt(49, sch.getFirstRfidState());
  160 + ps.setLong(50, sch.getId());
  161 + }
  162 +
  163 + @Override
  164 + public int getBatchSize() {
  165 + return pstList.size();
  166 + }
  167 + });
  168 + } catch (Exception e) {
  169 + status.setRollbackOnly();
  170 + try {
  171 + logger.error(String.format("实际排班批量保存异常: %s", mapper.writeValueAsString(pstList)), e);
  172 + } catch (JsonProcessingException jsonProcessingException) {
  173 + jsonProcessingException.printStackTrace();
  174 + }
153 175 }
154   -
155   - @Override
156   - public int getBatchSize() {
157   - return pstList.size();
158   - }
159   - });
160   -
161   - tran.commit(status);
162   - }catch (Exception e){
163   - tran.rollback(status);
164   - logger.error("同步数据库失败," , e);
165   - }
  176 + }
  177 + });
166 178 }
167 179 }
... ...
src/main/java/com/bsth/filter/BaseFilter.java
... ... @@ -16,7 +16,7 @@ public abstract class BaseFilter implements Filter {
16 16 /**
17 17 * 白名单
18 18 */
19   - private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
  19 + private String[] whiteListURLs = { Constants.LOGIN_PAGE, Constants.ORIGINAL_LOGIN_PAGE, Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
20 20 Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE,
21 21 Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL,
22 22 Constants.STATION_AND_SECTION_COUNT, Constants.ACTUATOR_MANAGEMENT_HEALTH, Constants.VEHICLE_DATA_SYNC_URL,
... ...
src/main/java/com/bsth/security/filter/LoginInterceptor.java
... ... @@ -32,7 +32,7 @@ public class LoginInterceptor implements Filter {
32 32 * 白名单
33 33 * 相比于 BaseFilter,此处对线调GPS请求进行了拦截验证
34 34 */
35   - private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
  35 + private String[] whiteListURLs = { Constants.LOGIN_PAGE, Constants.ORIGINAL_LOGIN_PAGE, Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
36 36 Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN,
37 37 Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,
38 38 Constants.STATION_AND_SECTION_COUNT, Constants.VEHICLE_DATA_SYNC_URL, Constants.FILE_AUTH };
... ...