Commit 3b2743e19db2314ccde6ea9003fd4d70811844f5
1 parent
bb164046
调度指令分析根据更换设备号时间处理
Showing
3 changed files
with
64 additions
and
19 deletions
src/main/java/com/bsth/repository/CarDeviceRepository.java
| ... | ... | @@ -15,4 +15,10 @@ import org.springframework.stereotype.Repository; |
| 15 | 15 | public interface CarDeviceRepository extends BaseRepository<CarDevice, Long> { |
| 16 | 16 | @Query(value="select s from CarDevice s where s.newDeviceNo=?1 and s.qyrq<=?2 ") |
| 17 | 17 | List<CarDevice> findCarDevice(String device,Date date ); |
| 18 | + | |
| 19 | + @Query(value="select s from CarDevice s where s.oldDeviceNo=?1 and s.qyrq>=?2 ") | |
| 20 | + List<CarDevice> findCarOldDevice(String device,Date date ); | |
| 21 | + | |
| 22 | + @Query(value="select s from CarDevice s where s.clZbh=?1 and s.qyrq>=?2 ") | |
| 23 | + List<CarDevice> findCarCode(String code,Date date ); | |
| 18 | 24 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -1210,34 +1210,73 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1210 | 1210 | |
| 1211 | 1211 | } |
| 1212 | 1212 | String device = ""; |
| 1213 | + String device2 =""; | |
| 1214 | + long qyrqTime=0l; | |
| 1213 | 1215 | if (!code.equals("")) { |
| 1214 | - device = BasicData.deviceId2NbbmMap.inverse().get(code); | |
| 1216 | + try { | |
| 1217 | + List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00")); | |
| 1218 | + if(deviceList.size()>0){ | |
| 1219 | + device=deviceList.get(0).getOldDeviceNo(); | |
| 1220 | + Date qyrq=deviceList.get(0).getQyrq(); | |
| 1221 | + qyrqTime=qyrq.getTime(); | |
| 1222 | + if(qyrqTime<t){ | |
| 1223 | + device2=deviceList.get(0).getNewDeviceNo(); | |
| 1224 | + } | |
| 1225 | + }else{ | |
| 1226 | + device = BasicData.deviceId2NbbmMap.inverse().get(code); | |
| 1227 | + } | |
| 1228 | + } catch (ParseException e) { | |
| 1229 | + // TODO Auto-generated catch block | |
| 1230 | + e.printStackTrace(); | |
| 1231 | + } | |
| 1215 | 1232 | } |
| 1216 | - List<Object[]> list = scheduleRealInfoRepository.historyMessage(line, d, t, device); | |
| 1217 | - for (Object[] obj : list) { | |
| 1233 | + List<Object[]> list=new ArrayList<Object[]>(); | |
| 1234 | + | |
| 1235 | + List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, d, t, device); | |
| 1236 | + for (Object[] obj : list0) { | |
| 1218 | 1237 | if (obj != null) { |
| 1219 | - | |
| 1220 | - if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) { | |
| 1221 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | |
| 1222 | - try { | |
| 1223 | - carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | |
| 1224 | - } catch (Exception e) { | |
| 1225 | - // TODO Auto-generated catch block | |
| 1226 | - e.printStackTrace(); | |
| 1227 | - } | |
| 1228 | - if (carDeviceList.size() > 0) { | |
| 1229 | - obj[0] = carDeviceList.get(0).getClZbh(); | |
| 1238 | + if(code.equals("")){ | |
| 1239 | + if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) { | |
| 1240 | + List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | |
| 1241 | + try { | |
| 1242 | + carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | |
| 1243 | + //启用日期大于营运日期 还是根据旧设备号查询 | |
| 1244 | + if(carDeviceList.size()==0){ | |
| 1245 | + carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | |
| 1246 | + } | |
| 1247 | + } catch (Exception e) { | |
| 1248 | + // TODO Auto-generated catch block | |
| 1249 | + e.printStackTrace(); | |
| 1250 | + } | |
| 1251 | + if (carDeviceList.size() > 0) { | |
| 1252 | + obj[0] = carDeviceList.get(0).getClZbh(); | |
| 1253 | + } else { | |
| 1254 | + obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | |
| 1255 | + } | |
| 1230 | 1256 | } else { |
| 1231 | 1257 | obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); |
| 1232 | 1258 | } |
| 1233 | - } else { | |
| 1234 | - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | |
| 1235 | - } | |
| 1259 | + }else{ | |
| 1260 | + obj[0]=code; | |
| 1261 | + } | |
| 1262 | + | |
| 1236 | 1263 | obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); |
| 1237 | 1264 | obj[4] = BasicData.lineCode2NameMap.get(line); |
| 1238 | 1265 | } |
| 1239 | 1266 | } |
| 1240 | - | |
| 1267 | + list.addAll(list0); | |
| 1268 | + if(!device2.equals("")){ | |
| 1269 | + List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, d, t, device2); | |
| 1270 | + for (Object[] obj : list1) { | |
| 1271 | + if (obj != null) { | |
| 1272 | + obj[0] =code; | |
| 1273 | + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | |
| 1274 | + obj[4] = BasicData.lineCode2NameMap.get(line); | |
| 1275 | + } | |
| 1276 | + } | |
| 1277 | + list.addAll(list1); | |
| 1278 | + } | |
| 1279 | + | |
| 1241 | 1280 | if (type != null && type.length() != 0 && type.equals("export")) { |
| 1242 | 1281 | String lineName = BasicData.lineCode2NameMap.get(line); |
| 1243 | 1282 | SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), |
| ... | ... | @@ -3268,6 +3307,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3268 | 3307 | List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); |
| 3269 | 3308 | listInfo2.addAll(listInfo); |
| 3270 | 3309 | Collections.sort(listInfo, new compareLpFcsjType()); |
| 3310 | + System.out.println(listInfo); | |
| 3271 | 3311 | Collections.sort(listInfo2,new compareDirLpFcsjType()); |
| 3272 | 3312 | for (int i = 0; i < listInfo.size(); i++) { |
| 3273 | 3313 | ScheduleRealInfo t = listInfo.get(i); | ... | ... |
src/main/resources/static/pages/forms/statement/historyMessage.html
| ... | ... | @@ -159,7 +159,6 @@ |
| 159 | 159 | var type = "query"; |
| 160 | 160 | $(".hidden").removeClass("hidden"); |
| 161 | 161 | var i = layer.load(2); |
| 162 | - console.log("code:"+code); | |
| 163 | 162 | if(code==""||code==null){ |
| 164 | 163 | $get('/realSchedule/historyMessage',{line:line,date:date,code:code,type:type},function(result){ |
| 165 | 164 | // 把数据填充到模版中 | ... | ... |