Commit 66133844cc4dac354b1eef0189156b0f1599feb7
Merge branch 'master' of 192.168.168.201:panzhaov5/control_service_data_Interface
Showing
2 changed files
with
322 additions
and
293 deletions
src/main/java/com/bsth/repository/ScheduleRealInfoRepository.java
| 1 | -package com.bsth.repository; | |
| 2 | - | |
| 3 | -import com.bsth.entity.ScheduleRealInfo; | |
| 4 | -import org.springframework.data.jpa.repository.EntityGraph; | |
| 5 | -import org.springframework.data.jpa.repository.Query; | |
| 6 | -import org.springframework.data.repository.PagingAndSortingRepository; | |
| 7 | -import org.springframework.stereotype.Repository; | |
| 8 | - | |
| 9 | -import java.util.List; | |
| 10 | - | |
| 11 | -@Repository | |
| 12 | -public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<ScheduleRealInfo, Long> { | |
| 13 | - | |
| 14 | - /** | |
| 15 | - * 根据日期获取班次信息 | |
| 16 | - * @param schDate | |
| 17 | - * @return | |
| 18 | - */ | |
| 19 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 20 | - @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1") | |
| 21 | - List<ScheduleRealInfo> findAll(String schDate); | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * 根据日期和线路编码获取班次信息 | |
| 25 | - * @param schDate | |
| 26 | - * @param lineCode | |
| 27 | - * @return | |
| 28 | - */ | |
| 29 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 30 | - @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 and s.xlBm=?2") | |
| 31 | - List<ScheduleRealInfo> findAll(String schDate, String lineCode); | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * 获取大于指定日期的班次信息 | |
| 35 | - * @param schDate | |
| 36 | - * @return | |
| 37 | - */ | |
| 38 | - @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 39 | - @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr>?1") | |
| 40 | - List<ScheduleRealInfo> findByDateLT(String schDate); | |
| 41 | -} | |
| 1 | +package com.bsth.repository; | |
| 2 | + | |
| 3 | +import com.bsth.entity.ScheduleRealInfo; | |
| 4 | +import org.springframework.data.jpa.repository.EntityGraph; | |
| 5 | +import org.springframework.data.jpa.repository.Query; | |
| 6 | +import org.springframework.data.repository.PagingAndSortingRepository; | |
| 7 | +import org.springframework.stereotype.Repository; | |
| 8 | + | |
| 9 | +import java.util.Date; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +@Repository | |
| 13 | +public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<ScheduleRealInfo, Long> { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 根据日期获取班次信息 | |
| 17 | + * @param schDate | |
| 18 | + * @return | |
| 19 | + */ | |
| 20 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 21 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1") | |
| 22 | + List<ScheduleRealInfo> findAll(String schDate); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 根据日期和线路编码获取班次信息 | |
| 26 | + * @param schDate | |
| 27 | + * @param lineCode | |
| 28 | + * @return | |
| 29 | + */ | |
| 30 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 31 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 and s.xlBm=?2") | |
| 32 | + List<ScheduleRealInfo> findAll(String schDate, String lineCode); | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 获取大于指定日期的班次信息 | |
| 36 | + * @param schDate | |
| 37 | + * @return | |
| 38 | + */ | |
| 39 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 40 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr>?1") | |
| 41 | + List<ScheduleRealInfo> findByDateLT(String schDate); | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 根据日期和公司编码获取班次信息 | |
| 45 | + * @param schDate | |
| 46 | + * @param companyCode | |
| 47 | + * @return | |
| 48 | + */ | |
| 49 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 50 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 and s.gsBm=?2 and s.updateDate>=?3") | |
| 51 | + List<ScheduleRealInfo> findByDateAndCompany(String schDate, String companyCode, Date timestamp); | |
| 52 | +} | ... | ... |
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
| 1 | -package com.bsth.server_rs.schedule.real; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONArray; | |
| 5 | -import com.alibaba.fastjson.JSONObject; | |
| 6 | -import com.bsth.common.BasicData; | |
| 7 | -import com.bsth.common.ResponseCode; | |
| 8 | -import com.bsth.entity.ScheduleRealInfo; | |
| 9 | -import com.bsth.redis.ScheduleRedisService; | |
| 10 | -import com.bsth.server_rs.base_info.line.Line; | |
| 11 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 12 | -import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig; | |
| 13 | -import com.bsth.server_rs.schedule.dto.ScheduleInOut; | |
| 14 | -import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; | |
| 15 | -import com.bsth.util.ConfigUtil; | |
| 16 | -import com.bsth.util.HttpClientUtils; | |
| 17 | -import com.google.common.base.Splitter; | |
| 18 | -import org.apache.commons.lang3.StringUtils; | |
| 19 | -import org.slf4j.Logger; | |
| 20 | -import org.slf4j.LoggerFactory; | |
| 21 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 22 | -import org.springframework.stereotype.Component; | |
| 23 | - | |
| 24 | -import javax.ws.rs.*; | |
| 25 | -import javax.ws.rs.core.MediaType; | |
| 26 | -import java.net.URLEncoder; | |
| 27 | -import java.util.*; | |
| 28 | - | |
| 29 | -/** | |
| 30 | - * Created by panzhao on 2017/8/24. | |
| 31 | - */ | |
| 32 | -@Component | |
| 33 | -@Path("/schedule_real") | |
| 34 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 35 | -public class ScheduleRealService { | |
| 36 | - | |
| 37 | - @Autowired | |
| 38 | - ScheduleRedisService redisService; | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - SchRealDataBuffer schRealDataBuffer; | |
| 42 | - | |
| 43 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 44 | - | |
| 45 | - static String url; | |
| 46 | - static String secretKey; | |
| 47 | - | |
| 48 | - static { | |
| 49 | - secretKey = ConfigUtil.get("http.control.secret.key"); | |
| 50 | - url = ConfigUtil.get("http.control.service_data_url");// + "/execSchList?secretKey=" + secretKey; | |
| 51 | - } | |
| 52 | - | |
| 53 | - @POST | |
| 54 | - @Path("tcc_tzrc") | |
| 55 | - public Map<String, Object> tccTzrc(String jsonStr) { | |
| 56 | - JSONObject rs = new JSONObject(); | |
| 57 | - try { | |
| 58 | - StringBuilder sb = HttpClientUtils.post(url + "/tccHrhc?secretKey=" + secretKey, jsonStr); | |
| 59 | - | |
| 60 | - rs = JSONObject.parseObject(sb.toString()); | |
| 61 | - | |
| 62 | - if ("SUCCESS".equals(rs.get("status"))) { | |
| 63 | - rs.put("list", ScheduleInOut.getMultiInstance(JSONArray.parseArray(rs.getJSONArray("list").toJSONString(), ScheduleRealInfo.class))); | |
| 64 | - } | |
| 65 | - } catch (Exception e) { | |
| 66 | - logger.error("", e); | |
| 67 | - rs.put("status", ResponseCode.ERROR); | |
| 68 | - rs.put("msg", "接口服务器出现异常!"); | |
| 69 | - } | |
| 70 | - return rs; | |
| 71 | - } | |
| 72 | - | |
| 73 | - @POST | |
| 74 | - @Path("tcc_dftz") | |
| 75 | - public Map<String, Object> tccDftz(String jsonStr) { | |
| 76 | - JSONObject rs = new JSONObject(); | |
| 77 | - try { | |
| 78 | - StringBuilder sb = HttpClientUtils.post(url + "/dftzAndDestroy?secretKey=" + secretKey, jsonStr); | |
| 79 | - | |
| 80 | - rs = JSON.parseObject(sb.toString()); | |
| 81 | - | |
| 82 | - if ("SUCCESS".equals(rs.get("status"))) { | |
| 83 | - rs.put("t", new ScheduleInOut(JSON.toJavaObject(JSON.parseObject(rs.get("t").toString()), ScheduleRealInfo.class))); | |
| 84 | - } | |
| 85 | - //ScheduleInOut.getMultiInstance | |
| 86 | - } catch (Exception e) { | |
| 87 | - logger.error("", e); | |
| 88 | - rs.put("status", ResponseCode.ERROR); | |
| 89 | - rs.put("msg", "接口服务器出现异常!"); | |
| 90 | - } | |
| 91 | - return rs; | |
| 92 | - } | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * 获取路牌下的班次信息 | |
| 96 | - * | |
| 97 | - * @param lineCode | |
| 98 | - * @param lpName | |
| 99 | - * @return | |
| 100 | - */ | |
| 101 | - @GET | |
| 102 | - @Path("/findByLpName/{lineCode}/{lpName}") | |
| 103 | - public List<ScheduleRealInfo> findByLpName(@PathParam("lineCode") String lineCode, @PathParam("lpName") String lpName) { | |
| 104 | - List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 105 | - try { | |
| 106 | - if (StringUtils.isEmpty(lineCode) || StringUtils.isEmpty(lpName)) | |
| 107 | - return list; | |
| 108 | - | |
| 109 | - lpName = URLEncoder.encode(lpName, "UTF-8"); | |
| 110 | - StringBuilder sb = HttpClientUtils.get(url + "/findByLpName?secretKey=" + secretKey + "&lineCode=" + lineCode + "&lpName=" + lpName); | |
| 111 | - list = JSON.parseArray(sb.toString(), ScheduleRealInfo.class); | |
| 112 | - } catch (Exception e) { | |
| 113 | - logger.error("", e); | |
| 114 | - } | |
| 115 | - return list; | |
| 116 | - } | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * 获取当天指定停车场的进出场排班数据 | |
| 120 | - * | |
| 121 | - * @return | |
| 122 | - */ | |
| 123 | - @GET | |
| 124 | - @Path("/in_out/{code}") | |
| 125 | - public List<ScheduleInOut> findInOut(@PathParam("code") String code) { | |
| 126 | - Set<String> lineArray = BasicData.lineDateMap.keySet(); | |
| 127 | - | |
| 128 | - List<ScheduleInOut> all = new ArrayList<>(); | |
| 129 | - for (String lineCode : lineArray) { | |
| 130 | - all.addAll(ScheduleInOut.getMultiInstance(redisService.read(BasicData.lineDateMap.get(lineCode), lineCode), code)); | |
| 131 | - } | |
| 132 | - return all; | |
| 133 | - } | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * 获取指定日期,指定公司的人员车辆配置情况(实际排班) | |
| 137 | - * | |
| 138 | - * @param company | |
| 139 | - * @param rq | |
| 140 | - * @return | |
| 141 | - */ | |
| 142 | - @GET | |
| 143 | - @Path("/ccConfig/{company}/{rq}") | |
| 144 | - public List<ScheduleCcInfoConfig> ccInfoConfig(@PathParam("company") String company, @PathParam("rq") String rq) { | |
| 145 | - List<Line> lines = LineBufferData.findByCompany(company); | |
| 146 | - | |
| 147 | - List<ScheduleCcInfoConfig> all = new ArrayList<>(); | |
| 148 | - for (Line line : lines) { | |
| 149 | - all.addAll(ScheduleCcInfoConfig.getMultiInstance(redisService.read(rq, line.getLineCode()))); | |
| 150 | - } | |
| 151 | - return all; | |
| 152 | - } | |
| 153 | - | |
| 154 | - /** | |
| 155 | - * 根据车辆自编号获取对应执行的班次信息 | |
| 156 | - * | |
| 157 | - * @param nbbm | |
| 158 | - * @return | |
| 159 | - */ | |
| 160 | - @GET | |
| 161 | - @Path("/exec/{nbbm}") | |
| 162 | - public JSONObject getExecPlan(@PathParam("nbbm") String nbbm) { | |
| 163 | - return schRealDataBuffer.getExecPlan(nbbm); | |
| 164 | - } | |
| 165 | - | |
| 166 | - /** | |
| 167 | - * 获取全部的 车辆 和班次对照信息 | |
| 168 | - * | |
| 169 | - * @param | |
| 170 | - * @return | |
| 171 | - */ | |
| 172 | - @GET | |
| 173 | - @Path("/execs") | |
| 174 | - public Collection<JSONObject> execs(){ | |
| 175 | - return schRealDataBuffer.execs(); | |
| 176 | - } | |
| 177 | - | |
| 178 | - /** | |
| 179 | - * 获取当天指定停车场的进出场排班数据(潘钊场站VIP特供版 -高实时) | |
| 180 | - * | |
| 181 | - * @return | |
| 182 | - */ | |
| 183 | - @GET | |
| 184 | - @Path("/in_out/pz_vip/{code}") | |
| 185 | - public List<ScheduleInOut> findInOut_real(@PathParam("code") String code) { | |
| 186 | - logger.info("in_out -" + code); | |
| 187 | - return ScheduleInOut.getMultiInstance(schRealDataBuffer.findByParkCode(code)); | |
| 188 | - } | |
| 189 | - | |
| 190 | - @GET | |
| 191 | - @Path("/sch_jk/{company}/{rq}") | |
| 192 | - public List<ScheduleRealInfoDTO_JK> find_JK(@PathParam("company") String company, @PathParam("rq") String rq) { | |
| 193 | - List<ScheduleRealInfoDTO_JK> all = new ArrayList<>(); | |
| 194 | - | |
| 195 | - List<Line> lines = LineBufferData.findByCompany(company); | |
| 196 | - for (Line line : lines) { | |
| 197 | - all.addAll(ScheduleRealInfoDTO_JK.getMultiInstance(redisService.read(rq, line.getLineCode()))); | |
| 198 | - } | |
| 199 | - return all; | |
| 200 | - } | |
| 201 | - | |
| 202 | - /** | |
| 203 | - * 读取指定日期的redis 数据,计算程序调用 | |
| 204 | - * | |
| 205 | - * @param rqs | |
| 206 | - * @return | |
| 207 | - */ | |
| 208 | - @GET | |
| 209 | - @Path("/pz_vip/read/{rqs}") | |
| 210 | - public List<ScheduleRealInfo> read(@PathParam("rqs") String rqs) { | |
| 211 | - List<ScheduleRealInfo> all = new ArrayList<>(), rs = new ArrayList<>(); | |
| 212 | - List<Line> lines = LineBufferData.findAll(); | |
| 213 | - List<String> rqArray = Splitter.on(",").splitToList(rqs); | |
| 214 | - | |
| 215 | - for (Line line : lines) { | |
| 216 | - for (String rq : rqArray) | |
| 217 | - all.addAll(redisService.read(rq, line.getLineCode())); | |
| 218 | - } | |
| 219 | - | |
| 220 | - for (ScheduleRealInfo sch : all) { | |
| 221 | - if (sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks")) | |
| 222 | - continue; | |
| 223 | - | |
| 224 | - //烂班,临加,有子任务的 | |
| 225 | - if (sch.getStatus() == -1 || sch.isSflj() || (sch.getcTasks() != null && sch.getcTasks().size() > 0)) | |
| 226 | - rs.add(sch); | |
| 227 | - } | |
| 228 | - return rs; | |
| 229 | - } | |
| 230 | - | |
| 231 | - /** | |
| 232 | - * 读取指定日期线路的redis 数据,计算程序调用 | |
| 233 | - * | |
| 234 | - * @param rq | |
| 235 | - * @return | |
| 236 | - */ | |
| 237 | - @GET | |
| 238 | - @Path("/pz_vip/readByRqAndLine/{rq}/{lineCode}") | |
| 239 | - public List<ScheduleRealInfo> readByLine(@PathParam("rq") String rq, @PathParam("lineCode") String lineCode) { | |
| 240 | - List<ScheduleRealInfo> all = redisService.read(rq, lineCode), rs = new ArrayList<>(); | |
| 241 | - | |
| 242 | - for (ScheduleRealInfo sch : all) { | |
| 243 | - if (sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks")) | |
| 244 | - continue; | |
| 245 | - | |
| 246 | - //烂班,临加,有子任务的 | |
| 247 | - if (sch.getStatus() == -1 || sch.isSflj() || (sch.getcTasks() != null && sch.getcTasks().size() > 0)) | |
| 248 | - rs.add(sch); | |
| 249 | - } | |
| 250 | - return rs; | |
| 251 | - } | |
| 252 | -} | |
| 1 | +package com.bsth.server_rs.schedule.real; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.alibaba.fastjson.JSONArray; | |
| 5 | +import com.alibaba.fastjson.JSONObject; | |
| 6 | +import com.bsth.common.BasicData; | |
| 7 | +import com.bsth.common.ResponseCode; | |
| 8 | +import com.bsth.entity.ScheduleRealInfo; | |
| 9 | +import com.bsth.redis.ScheduleRedisService; | |
| 10 | +import com.bsth.repository.ScheduleRealInfoRepository; | |
| 11 | +import com.bsth.server_rs.base_info.line.Line; | |
| 12 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 13 | +import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig; | |
| 14 | +import com.bsth.server_rs.schedule.dto.ScheduleInOut; | |
| 15 | +import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; | |
| 16 | +import com.bsth.util.ConfigUtil; | |
| 17 | +import com.bsth.util.HttpClientUtils; | |
| 18 | +import com.google.common.base.Splitter; | |
| 19 | +import org.apache.commons.lang3.StringUtils; | |
| 20 | +import org.joda.time.DateTime; | |
| 21 | +import org.joda.time.DateTimeZone; | |
| 22 | +import org.joda.time.format.DateTimeFormat; | |
| 23 | +import org.joda.time.format.DateTimeFormatter; | |
| 24 | +import org.slf4j.Logger; | |
| 25 | +import org.slf4j.LoggerFactory; | |
| 26 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 27 | +import org.springframework.stereotype.Component; | |
| 28 | + | |
| 29 | +import javax.ws.rs.*; | |
| 30 | +import javax.ws.rs.core.MediaType; | |
| 31 | +import java.net.URLEncoder; | |
| 32 | +import java.util.*; | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * Created by panzhao on 2017/8/24. | |
| 36 | + */ | |
| 37 | +@Component | |
| 38 | +@Path("/schedule_real") | |
| 39 | +@Produces({MediaType.APPLICATION_JSON}) | |
| 40 | +public class ScheduleRealService { | |
| 41 | + | |
| 42 | + @Autowired | |
| 43 | + ScheduleRedisService redisService; | |
| 44 | + | |
| 45 | + @Autowired | |
| 46 | + SchRealDataBuffer schRealDataBuffer; | |
| 47 | + | |
| 48 | + @Autowired | |
| 49 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 50 | + | |
| 51 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 52 | + | |
| 53 | + static String url; | |
| 54 | + static String secretKey; | |
| 55 | + | |
| 56 | + static { | |
| 57 | + secretKey = ConfigUtil.get("http.control.secret.key"); | |
| 58 | + url = ConfigUtil.get("http.control.service_data_url");// + "/execSchList?secretKey=" + secretKey; | |
| 59 | + } | |
| 60 | + | |
| 61 | + @POST | |
| 62 | + @Path("tcc_tzrc") | |
| 63 | + public Map<String, Object> tccTzrc(String jsonStr) { | |
| 64 | + JSONObject rs = new JSONObject(); | |
| 65 | + try { | |
| 66 | + StringBuilder sb = HttpClientUtils.post(url + "/tccHrhc?secretKey=" + secretKey, jsonStr); | |
| 67 | + | |
| 68 | + rs = JSONObject.parseObject(sb.toString()); | |
| 69 | + | |
| 70 | + if ("SUCCESS".equals(rs.get("status"))) { | |
| 71 | + rs.put("list", ScheduleInOut.getMultiInstance(JSONArray.parseArray(rs.getJSONArray("list").toJSONString(), ScheduleRealInfo.class))); | |
| 72 | + } | |
| 73 | + } catch (Exception e) { | |
| 74 | + logger.error("", e); | |
| 75 | + rs.put("status", ResponseCode.ERROR); | |
| 76 | + rs.put("msg", "接口服务器出现异常!"); | |
| 77 | + } | |
| 78 | + return rs; | |
| 79 | + } | |
| 80 | + | |
| 81 | + @POST | |
| 82 | + @Path("tcc_dftz") | |
| 83 | + public Map<String, Object> tccDftz(String jsonStr) { | |
| 84 | + JSONObject rs = new JSONObject(); | |
| 85 | + try { | |
| 86 | + StringBuilder sb = HttpClientUtils.post(url + "/dftzAndDestroy?secretKey=" + secretKey, jsonStr); | |
| 87 | + | |
| 88 | + rs = JSON.parseObject(sb.toString()); | |
| 89 | + | |
| 90 | + if ("SUCCESS".equals(rs.get("status"))) { | |
| 91 | + rs.put("t", new ScheduleInOut(JSON.toJavaObject(JSON.parseObject(rs.get("t").toString()), ScheduleRealInfo.class))); | |
| 92 | + } | |
| 93 | + //ScheduleInOut.getMultiInstance | |
| 94 | + } catch (Exception e) { | |
| 95 | + logger.error("", e); | |
| 96 | + rs.put("status", ResponseCode.ERROR); | |
| 97 | + rs.put("msg", "接口服务器出现异常!"); | |
| 98 | + } | |
| 99 | + return rs; | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 获取路牌下的班次信息 | |
| 104 | + * | |
| 105 | + * @param lineCode | |
| 106 | + * @param lpName | |
| 107 | + * @return | |
| 108 | + */ | |
| 109 | + @GET | |
| 110 | + @Path("/findByLpName/{lineCode}/{lpName}") | |
| 111 | + public List<ScheduleRealInfo> findByLpName(@PathParam("lineCode") String lineCode, @PathParam("lpName") String lpName) { | |
| 112 | + List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 113 | + try { | |
| 114 | + if (StringUtils.isEmpty(lineCode) || StringUtils.isEmpty(lpName)) | |
| 115 | + return list; | |
| 116 | + | |
| 117 | + lpName = URLEncoder.encode(lpName, "UTF-8"); | |
| 118 | + StringBuilder sb = HttpClientUtils.get(url + "/findByLpName?secretKey=" + secretKey + "&lineCode=" + lineCode + "&lpName=" + lpName); | |
| 119 | + list = JSON.parseArray(sb.toString(), ScheduleRealInfo.class); | |
| 120 | + } catch (Exception e) { | |
| 121 | + logger.error("", e); | |
| 122 | + } | |
| 123 | + return list; | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 获取当天指定停车场的进出场排班数据 | |
| 128 | + * | |
| 129 | + * @return | |
| 130 | + */ | |
| 131 | + @GET | |
| 132 | + @Path("/in_out/{code}") | |
| 133 | + public List<ScheduleInOut> findInOut(@PathParam("code") String code) { | |
| 134 | + Set<String> lineArray = BasicData.lineDateMap.keySet(); | |
| 135 | + | |
| 136 | + List<ScheduleInOut> all = new ArrayList<>(); | |
| 137 | + for (String lineCode : lineArray) { | |
| 138 | + all.addAll(ScheduleInOut.getMultiInstance(redisService.read(BasicData.lineDateMap.get(lineCode), lineCode), code)); | |
| 139 | + } | |
| 140 | + return all; | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * 获取指定日期,指定公司的人员车辆配置情况(实际排班) | |
| 145 | + * | |
| 146 | + * @param company | |
| 147 | + * @param rq | |
| 148 | + * @return | |
| 149 | + */ | |
| 150 | + @GET | |
| 151 | + @Path("/ccConfig/{company}/{rq}") | |
| 152 | + public List<ScheduleCcInfoConfig> ccInfoConfig(@PathParam("company") String company, @PathParam("rq") String rq) { | |
| 153 | + List<Line> lines = LineBufferData.findByCompany(company); | |
| 154 | + | |
| 155 | + List<ScheduleCcInfoConfig> all = new ArrayList<>(); | |
| 156 | + for (Line line : lines) { | |
| 157 | + all.addAll(ScheduleCcInfoConfig.getMultiInstance(redisService.read(rq, line.getLineCode()))); | |
| 158 | + } | |
| 159 | + return all; | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * 根据车辆自编号获取对应执行的班次信息 | |
| 164 | + * | |
| 165 | + * @param nbbm | |
| 166 | + * @return | |
| 167 | + */ | |
| 168 | + @GET | |
| 169 | + @Path("/exec/{nbbm}") | |
| 170 | + public JSONObject getExecPlan(@PathParam("nbbm") String nbbm) { | |
| 171 | + return schRealDataBuffer.getExecPlan(nbbm); | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * 获取全部的 车辆 和班次对照信息 | |
| 176 | + * | |
| 177 | + * @param | |
| 178 | + * @return | |
| 179 | + */ | |
| 180 | + @GET | |
| 181 | + @Path("/execs") | |
| 182 | + public Collection<JSONObject> execs(){ | |
| 183 | + return schRealDataBuffer.execs(); | |
| 184 | + } | |
| 185 | + | |
| 186 | + /** | |
| 187 | + * 获取当天指定停车场的进出场排班数据(潘钊场站VIP特供版 -高实时) | |
| 188 | + * | |
| 189 | + * @return | |
| 190 | + */ | |
| 191 | + @GET | |
| 192 | + @Path("/in_out/pz_vip/{code}") | |
| 193 | + public List<ScheduleInOut> findInOut_real(@PathParam("code") String code) { | |
| 194 | + logger.info("in_out -" + code); | |
| 195 | + return ScheduleInOut.getMultiInstance(schRealDataBuffer.findByParkCode(code)); | |
| 196 | + } | |
| 197 | + | |
| 198 | + @GET | |
| 199 | + @Path("/sch_jk/{company}/{rq}") | |
| 200 | + public List<ScheduleRealInfoDTO_JK> find_JK(@PathParam("company") String company, @PathParam("rq") String rq) { | |
| 201 | + List<ScheduleRealInfoDTO_JK> all = new ArrayList<>(); | |
| 202 | + | |
| 203 | + List<Line> lines = LineBufferData.findByCompany(company); | |
| 204 | + for (Line line : lines) { | |
| 205 | + all.addAll(ScheduleRealInfoDTO_JK.getMultiInstance(redisService.read(rq, line.getLineCode()))); | |
| 206 | + } | |
| 207 | + return all; | |
| 208 | + } | |
| 209 | + | |
| 210 | + @GET | |
| 211 | + @Path("/sch_jk4modify/{company}/{rq}/{timestamp}") | |
| 212 | + public List<ScheduleRealInfoDTO_JK> sch_jk4modify(@PathParam("company") String company, @PathParam("rq") String rq, @PathParam("timestamp") long timestamp) { | |
| 213 | + DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd"); | |
| 214 | + DateTime dateTime = fmt.parseDateTime(rq); | |
| 215 | + List<ScheduleRealInfoDTO_JK> result = ScheduleRealInfoDTO_JK.getMultiInstance(scheduleRealInfoRepository.findByDateAndCompany(dateTime.toString("yyyy-MM-dd"), company, new Date(timestamp))); | |
| 216 | + | |
| 217 | + return result; | |
| 218 | + } | |
| 219 | + | |
| 220 | + /** | |
| 221 | + * 读取指定日期的redis 数据,计算程序调用 | |
| 222 | + * | |
| 223 | + * @param rqs | |
| 224 | + * @return | |
| 225 | + */ | |
| 226 | + @GET | |
| 227 | + @Path("/pz_vip/read/{rqs}") | |
| 228 | + public List<ScheduleRealInfo> read(@PathParam("rqs") String rqs) { | |
| 229 | + List<ScheduleRealInfo> all = new ArrayList<>(), rs = new ArrayList<>(); | |
| 230 | + List<Line> lines = LineBufferData.findAll(); | |
| 231 | + List<String> rqArray = Splitter.on(",").splitToList(rqs); | |
| 232 | + | |
| 233 | + for (Line line : lines) { | |
| 234 | + for (String rq : rqArray) | |
| 235 | + all.addAll(redisService.read(rq, line.getLineCode())); | |
| 236 | + } | |
| 237 | + | |
| 238 | + for (ScheduleRealInfo sch : all) { | |
| 239 | + if (sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks")) | |
| 240 | + continue; | |
| 241 | + | |
| 242 | + //烂班,临加,有子任务的 | |
| 243 | + if (sch.getStatus() == -1 || sch.isSflj() || (sch.getcTasks() != null && sch.getcTasks().size() > 0)) | |
| 244 | + rs.add(sch); | |
| 245 | + } | |
| 246 | + return rs; | |
| 247 | + } | |
| 248 | + | |
| 249 | + /** | |
| 250 | + * 读取指定日期线路的redis 数据,计算程序调用 | |
| 251 | + * | |
| 252 | + * @param rq | |
| 253 | + * @return | |
| 254 | + */ | |
| 255 | + @GET | |
| 256 | + @Path("/pz_vip/readByRqAndLine/{rq}/{lineCode}") | |
| 257 | + public List<ScheduleRealInfo> readByLine(@PathParam("rq") String rq, @PathParam("lineCode") String lineCode) { | |
| 258 | + List<ScheduleRealInfo> all = redisService.read(rq, lineCode), rs = new ArrayList<>(); | |
| 259 | + | |
| 260 | + for (ScheduleRealInfo sch : all) { | |
| 261 | + if (sch.getBcType().equals("in") || sch.getBcType().equals("out") || sch.getBcType().equals("ldks")) | |
| 262 | + continue; | |
| 263 | + | |
| 264 | + //烂班,临加,有子任务的 | |
| 265 | + if (sch.getStatus() == -1 || sch.isSflj() || (sch.getcTasks() != null && sch.getcTasks().size() > 0)) | |
| 266 | + rs.add(sch); | |
| 267 | + } | |
| 268 | + return rs; | |
| 269 | + } | |
| 270 | +} | ... | ... |