Commit 769bfda98b4adbb9e0479e9ecf63787dee76f06c

Authored by zq
1 parent dd60c6dd

运管处接口代码编写

src/main/java/com/bsth/data/BasicData.java
... ... @@ -20,7 +20,6 @@ import com.bsth.entity.Line;
20 20 import com.bsth.entity.Station;
21 21 import com.bsth.entity.StationRoute;
22 22 import com.bsth.entity.schedule.CarConfigInfo;
23   -import com.bsth.oplog.normal.OpLogger;
24 23 import com.bsth.repository.CarParkRepository;
25 24 import com.bsth.repository.CarsRepository;
26 25 import com.bsth.repository.LineRepository;
... ... @@ -69,6 +68,12 @@ public class BasicData implements CommandLineRunner{
69 68 //停车场
70 69 public static List<String> parkCodeList;
71 70  
  71 + //线路ID和shangHaiLinecode 对照
  72 + public static Map<Integer, String> lineId2ShangHaiCodeMap;
  73 +
  74 + //线路Code和shangHaiLinecode 对照
  75 + public static Map<String, String> lineCode2ShangHaiCodeMap;
  76 +
72 77 static Logger logger = LoggerFactory.getLogger(BasicData.class);
73 78  
74 79 @Autowired
... ... @@ -101,8 +106,6 @@ public class BasicData implements CommandLineRunner{
101 106 @Autowired
102 107 StationRouteRepository stationRouteRepository;
103 108  
104   - @Autowired
105   - OpLogger opLog;
106 109  
107 110 @Override
108 111 public void run() {
... ... @@ -122,8 +125,6 @@ public class BasicData implements CommandLineRunner{
122 125  
123 126 loadStationRouteInfo();
124 127 logger.info("加载基础数据成功!," );
125   -
126   - opLog.info("load_basic");
127 128 }catch(Exception e){
128 129 logger.error("加载基础数据时出现异常," , e);
129 130 }
... ... @@ -218,15 +219,21 @@ public class BasicData implements CommandLineRunner{
218 219 Line line;
219 220 BiMap<Integer, String> biMap = HashBiMap.create();
220 221 Map<String, String> code2name = new HashMap<>();
  222 + Map<Integer, String> id2SHcode = new HashMap<Integer, String>();
  223 + Map<String, String> code2SHcode = new HashMap<String, String>();
221 224  
222 225 while(iterator.hasNext()){
223 226 line = iterator.next();
224 227 biMap.put(line.getId(), line.getLineCode());
225 228 code2name.put(line.getLineCode(), line.getName());
  229 + id2SHcode.put(line.getId(),line.getShanghaiLinecode());
  230 + code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode());
226 231 }
227 232  
228 233 lineId2CodeMap = biMap;
229 234 lineCode2NameMap = code2name;
  235 + lineId2ShangHaiCodeMap = id2SHcode;
  236 + lineCode2ShangHaiCodeMap = code2SHcode;
230 237 }
231 238 }
232 239 }
... ...
src/main/java/com/bsth/repository/CarsRepository.java
1 1 package com.bsth.repository;
2 2  
  3 +import java.util.List;
  4 +
  5 +import org.springframework.data.jpa.repository.Query;
3 6 import org.springframework.stereotype.Repository;
4 7  
5 8 import com.bsth.entity.Cars;
... ... @@ -7,4 +10,6 @@ import com.bsth.entity.Cars;
7 10 @Repository
8 11 public interface CarsRepository extends BaseRepository<Cars, Integer>{
9 12  
  13 + @Query(value="select s from Cars s where s.id in(select e.cl.id from CarConfigInfo e where e.xl.id = ?1) ")
  14 + List<Cars> findCarsByLineId(Integer lineId);
10 15 }
... ...
src/main/java/com/bsth/repository/PersonnelRepository.java
1 1 package com.bsth.repository;
2 2  
3   -import com.bsth.entity.Personnel;
4   -
5 3 import java.util.List;
6 4  
  5 +import com.bsth.entity.Personnel;
7 6 import org.springframework.data.jpa.repository.Query;
8 7 import org.springframework.stereotype.Repository;
9 8  
... ... @@ -12,4 +11,10 @@ import org.springframework.stereotype.Repository;
12 11 */
13 12 @Repository
14 13 public interface PersonnelRepository extends BaseRepository<Personnel, Integer> {
  14 +
  15 + @Query(value="select s from Personnel s where s.id in(select e.jsy.id from EmployeeConfigInfo e where e.xl.id = ?1) ")
  16 + List<Personnel> findJsysByLineId(Integer lineId);
  17 +
  18 + @Query(value="select s from Personnel s where s.id in(select e.spy.id from EmployeeConfigInfo e where e.xl.id = ?1) ")
  19 + List<Personnel> findSpysByLineId(Integer lineId);
15 20 }
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -75,6 +75,15 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
75 75 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2")
76 76 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
77 77  
78   - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh) from ScheduleRealInfo s where (s.xlBm = ?1 or s.xlBm is not null) and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY xlBm,clZbh,jGh ORDER BY xlBm,clZbh,realExecDate,fcsjActual")
79   - List<Map<String,Object>> yesterdayDataList(String line,String date);
  78 + @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir")
  79 + List<ScheduleRealInfo> setLD(String date);
  80 +
  81 + @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 GROUP BY xlBm,lpName,clZbh ORDER BY xlBm,lpName,clZbh")
  82 + List<ScheduleRealInfo> setLDGroup(String date);
  83 +
  84 + @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 GROUP BY xlBm,clZbh ORDER BY xlBm,clZbh")
  85 + List<ScheduleRealInfo> setLCYHGroup(String date);
  86 +
  87 + @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 GROUP BY xlBm ORDER BY xlBm")
  88 + List<ScheduleRealInfo> setDDRBGroup(String date);
80 89 }
... ...
src/main/java/com/bsth/repository/schedule/SchedulePlanInfoRepository.java
1 1 package com.bsth.repository.schedule;
2 2  
  3 +import com.bsth.entity.Cars;
3 4 import com.bsth.entity.schedule.SchedulePlanInfo;
4 5 import com.bsth.repository.BaseRepository;
5 6  
... ... @@ -117,5 +118,8 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
117 118 @Param("p5") Date scheduleDate,
118 119 @Param("p6") String lpName,
119 120 @Param("p7") Integer spyId_src);
  121 +
  122 + @Query(value="select s from SchedulePlanInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 order by s.xlBm,clZbh,lp,xlDir")
  123 + List<SchedulePlanInfo> findLineScheduleBc(String scheduleDate);
120 124  
121 125 }
... ...
src/main/java/com/bsth/service/TrafficManageService.java
... ... @@ -20,10 +20,54 @@ import com.bsth.entity.Line;
20 20 public interface TrafficManageService {
21 21  
22 22 /**
23   - * 获取线路编码
  23 + * 上传线路信息
24 24 *
25   - * @return long <lineCode:线路编码>
  25 + * @return 调用接口返回信息
26 26 */
27 27 String setXL();
28 28  
  29 + /**
  30 + * 上传车辆信息
  31 + *
  32 + * @return 调用接口返回信息
  33 + */
  34 + String setCL();
  35 +
  36 + /**
  37 + * 上传司机信息
  38 + * @return 调用接口返回信息
  39 + */
  40 + String setSJ();
  41 +
  42 + /**
  43 + * 上传超速数据
  44 + *
  45 + * @return 调用接口返回信息
  46 + */
  47 + String setCS();
  48 +
  49 + /**
  50 + * 上传线路班次时刻表数据
  51 + *
  52 + * @return 调用接口返回信息
  53 + */
  54 + String setSKB(String ids);
  55 +
  56 + /**
  57 + * 线路人员车辆配置信息
  58 + * @return 调用接口返回信息
  59 + */
  60 + String setXLPC();
  61 +
  62 + /**
  63 + * 线路计划班次表
  64 + * @return 调用接口返回信息
  65 + */
  66 + String setJHBC();
  67 +
  68 + String setLD();
  69 +
  70 + String setLCYH();
  71 +
  72 + String setDDRB();
29 73 }
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
1 1 package com.bsth.service.impl;
2 2  
  3 +import java.sql.Connection;
  4 +import java.sql.PreparedStatement;
  5 +import java.sql.ResultSet;
  6 +import java.text.DecimalFormat;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.ArrayList;
  9 +import java.util.Calendar;
  10 +import java.util.Date;
  11 +import java.util.HashMap;
3 12 import java.util.Iterator;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +import java.util.Set;
4 16  
  17 +import org.apache.commons.lang.time.DateUtils;
  18 +import org.slf4j.Logger;
  19 +import org.slf4j.LoggerFactory;
5 20 import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.data.domain.Sort;
  22 +import org.springframework.data.domain.Sort.Direction;
  23 +import org.springframework.jdbc.core.JdbcTemplate;
6 24 import org.springframework.stereotype.Service;
7 25  
  26 +import com.bsth.data.BasicData;
  27 +import com.bsth.entity.Cars;
8 28 import com.bsth.entity.Line;
  29 +import com.bsth.entity.LineInformation;
  30 +import com.bsth.entity.Personnel;
  31 +import com.bsth.entity.StationRoute;
  32 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  33 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  34 +import com.bsth.entity.schedule.SchedulePlanInfo;
  35 +import com.bsth.entity.schedule.TTInfo;
  36 +import com.bsth.entity.schedule.TTInfoDetail;
  37 +import com.bsth.entity.search.CustomerSpecs;
  38 +import com.bsth.repository.CarsRepository;
  39 +import com.bsth.repository.LineInformationRepository;
9 40 import com.bsth.repository.LineRepository;
  41 +import com.bsth.repository.PersonnelRepository;
  42 +import com.bsth.repository.StationRouteRepository;
  43 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  44 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  45 +import com.bsth.repository.schedule.SchedulePlanInfoRepository;
  46 +import com.bsth.repository.schedule.TTInfoDetailRepository;
  47 +import com.bsth.repository.schedule.TTInfoRepository;
10 48 import com.bsth.service.TrafficManageService;
  49 +import com.bsth.util.TimeUtils;
  50 +import com.bsth.util.db.DBUtils_MS;
11 51 import com.bsth.webService.trafficManage.geotool.services.Internal;
12 52 import com.bsth.webService.trafficManage.geotool.services.InternalPortType;
13   -
  53 +import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator;
  54 +import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap;
  55 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
14 56 /**
15 57 *
16 58 * @ClassName: LineServiceImpl(线路service业务层实现类)
... ... @@ -30,31 +72,813 @@ import com.bsth.webService.trafficManage.geotool.services.InternalPortType;
30 72 @Service
31 73 public class TrafficManageServiceImpl implements TrafficManageService{
32 74  
  75 + Logger logger = LoggerFactory.getLogger(this.getClass());
  76 +
  77 + // 线路repository
  78 + @Autowired
  79 + private LineRepository lineRepository;
  80 +
  81 + // 站点路由repository
  82 + @Autowired
  83 + private StationRouteRepository stationRouteRepository;
  84 +
  85 + // 线路标准信息repository
  86 + @Autowired
  87 + private LineInformationRepository lineInformationRepository;
  88 +
  89 + // 车辆repository
  90 + @Autowired
  91 + private CarsRepository carsRepository;
  92 +
  93 + // 人员repository
  94 + @Autowired
  95 + private PersonnelRepository personnelRepository;
  96 +
  97 + // 时刻模板repository
  98 + @Autowired
  99 + private TTInfoRepository ttInfoRepository;
  100 +
  101 + // 时刻模板明细repository
33 102 @Autowired
34   - private LineRepository repository;
  103 + private TTInfoDetailRepository ttInfoDetailRepository;
  104 +
  105 + // 车辆配置信息repository
  106 + @Autowired
  107 + private CarConfigInfoRepository carConfigInfoRepository;
  108 +
  109 + // 人员配置信息repository
  110 + @Autowired
  111 + private EmployeeConfigInfoRepository employeeConfigInfoRepository;
  112 +
  113 + // 排班计划明细repository
  114 + @Autowired
  115 + private SchedulePlanInfoRepository schedulePlanInfoRepository;
  116 +
  117 + // 实际排班计划明细repository
  118 + @Autowired
  119 + private ScheduleRealInfoRepository scheduleRealInfoRepository;
35 120  
36 121 // 运管处接口
37 122 private InternalPortType portType = new Internal().getInternalHttpSoap11Endpoint();
  123 + private WebServiceSoap ssop ;
  124 + {
  125 + try {
  126 + ssop = new WebServiceLocator().getWebServiceSoap();
  127 + } catch (Exception e) {
  128 + e.printStackTrace();
  129 + }
  130 + }
  131 + // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母
  132 + private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  133 +
  134 + // 格式化 年月日
  135 + private SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd");
  136 +
  137 + // 数字格式化
  138 + DecimalFormat format = new DecimalFormat("0.00");
  139 +
38 140 // 用户名
39   - private final String userName = "pudong";
  141 + private final String userNameXl = "pudong";
40 142 // 密码
41   - private final String password = "pudong123";
42   -
  143 + private final String passwordXl = "pudong123";
  144 +
  145 + // 用户名
  146 + private final String userNameOther = "user";
  147 + // 密码
  148 + private final String passwordOther = "user";
43 149 /**
44   - * 获取线路编码
45   - *
46   - * @return int <lineCode:线路编码>
  150 + * 上传线路信息
47 151 */
  152 + @Override
48 153 public String setXL() {
  154 + String result = "success";
  155 + try {
  156 + StringBuffer sBuffer = new StringBuffer(); ;
  157 + Iterator<Line> lineIterator = lineRepository.findAll().iterator();
  158 + Line line = null;
  159 + List<StationRoute> stationsList = null;// 站点路由集
  160 + List<LineInformation> lineInformationsList = null;
  161 + LineInformation lineInformation = null;
  162 + sBuffer.append("<XLs>");
  163 + while(lineIterator.hasNext()){
  164 + line = lineIterator.next();
  165 + if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){
  166 + continue;
  167 + }
  168 + sBuffer.append("<XL>");
  169 + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>");
  170 + sBuffer.append("<XLMC>").append(line.getName()).append("</XLMC>");
  171 + sBuffer.append("<QDZ>").append(line.getStartStationName()).append("</QDZ>");
  172 + sBuffer.append("<ZDZ>").append(line.getEndStationName()).append("</ZDZ>");
  173 + // 线路标准信息实体
  174 + lineInformationsList = lineInformationRepository.findByLine(line);
  175 + int size = lineInformationsList.size();
  176 + if(lineInformationsList != null && size > 0){
  177 + double upMileage = 0.0; // 上行里程
  178 + double downMileage = 0.0; // 下行里程
  179 + // 如果线路标准有多个,累加上行里程和下行里程
  180 + for (int i = 0; i < size; i++) {
  181 + lineInformation = lineInformationsList.get(i);
  182 + upMileage +=lineInformation.getUpMileage();
  183 + downMileage +=lineInformation.getDownMileage();
  184 + }
  185 + sBuffer.append("<QZLC>").append(upMileage).append("</QZLC>");
  186 + sBuffer.append("<ZQLC>").append(downMileage).append("</ZQLC>");
  187 + }
  188 + sBuffer.append("<XLGH>").append(line.getLinePlayType()).append("</XLGH>");
  189 + // 循环添加站点信息
  190 + sBuffer.append("<StationList>");
  191 + // 先查上行
  192 + stationsList = stationRouteRepository.findByLine(line.getLineCode(), 0);
  193 + int startId = 1;
  194 + startId = packagStationXml(stationsList, sBuffer, startId);
  195 + // 再查下行
  196 + stationsList = stationRouteRepository.findByLine(line.getLineCode(), 1);
  197 + packagStationXml(stationsList, sBuffer, startId);
  198 + sBuffer.append("</StationList>");
  199 + sBuffer.append("</XL>");
  200 + }
  201 + sBuffer.append("</XLs>");
  202 + if(sBuffer.indexOf("<XL>") != -1){
  203 + logger.info("setXL:"+sBuffer.toString());
  204 + portType.setXL(userNameXl, passwordXl, sBuffer.toString());
  205 + }
  206 + } catch (Exception e) {
  207 + e.printStackTrace();
  208 + }
  209 +
  210 + return result;
  211 + }
  212 +
  213 + /**
  214 + * 上传车辆信息
  215 + */
  216 + @Override
  217 + public String setCL() {
  218 + String result = "success";
  219 + try {
  220 + StringBuffer sBuffer =new StringBuffer();
  221 + sBuffer.append("<CLs>");
  222 + Cars cars = null;
  223 + String company;
  224 + Iterator<Cars> carsIterator = carsRepository.findAll().iterator();
  225 + while(carsIterator.hasNext()){
  226 + cars = carsIterator.next();
  227 + sBuffer.append("<CL>");
  228 + company = cars.getCompany();
  229 + setCompanyName(company);// 统一公司名称
  230 + sBuffer.append("<GSJC>").append(company).append("</GSJC>");
  231 + sBuffer.append("<NBH>").append(cars.getInsideCode()).append("</NBH>");
  232 + sBuffer.append("<CPH>").append(cars.getCarPlate()).append("</CPH>");
  233 + sBuffer.append("<YYZBH>").append(cars.getServiceNo()).append("</YYZBH>");
  234 + sBuffer.append("<CZCPH>").append(cars.getCarPlate()).append("</CZCPH>");//******这个数据没有***********
  235 + sBuffer.append("<CZZDBH>").append(cars.getEquipmentCode()).append("</CZZDBH>");
  236 + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
  237 + sBuffer.append("</CL>");
  238 + }
  239 + sBuffer.append("</CLs>");
  240 + logger.info("setCL:"+sBuffer.toString());
  241 + ssop.setCL(userNameOther, passwordOther, sBuffer.toString());
  242 + } catch (Exception e) {
  243 + e.printStackTrace();
  244 + }
  245 + return result;
  246 + }
  247 +
  248 + /**
  249 + * 上传司机信息
  250 + */
  251 + @Override
  252 + public String setSJ() {
  253 + String result = "success";
  254 + try {
  255 + StringBuffer sBuffer =new StringBuffer();
  256 + sBuffer.append("<SJs>");
  257 + Personnel personnel = null;
  258 + String company;
  259 + Iterator<Personnel> personIterator = personnelRepository.findAll().iterator();
  260 + while(personIterator.hasNext()){
  261 + personnel = personIterator.next();
  262 + sBuffer.append("<SJ>");
  263 + company = personnel.getCompany();
  264 + setCompanyName(company);// 统一公司名称
  265 + sBuffer.append("<GSJC>").append(company).append("</GSJC>");
  266 + sBuffer.append("<SJGH>").append(personnel.getJobCode()).append("</SJGH>");
  267 + sBuffer.append("<CYZGZH>").append(personnel.getPapersCode()).append("</CYZGZH>");//***********
  268 + sBuffer.append("<XM>").append(personnel.getPersonnelName()).append("</XM>");
  269 + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
  270 + sBuffer.append("</SJ>");
  271 + }
  272 + sBuffer.append("</SJs>");
  273 + logger.info("setSJ:"+sBuffer.toString());
  274 + ssop.setSJ(userNameOther, passwordOther, sBuffer.toString());
  275 + } catch (Exception e) {
  276 + e.printStackTrace();
  277 + }
  278 + return result;
  279 + }
  280 +
  281 + /**
  282 + * 上传超速数据
  283 + */
  284 + @Override
  285 + public String setCS() {
  286 + String result = "success";
  287 + StringBuffer sBuffer =new StringBuffer();
  288 + sBuffer.append("<CSs>");
  289 + String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date ";
  290 + Connection conn = null;
  291 + PreparedStatement ps = null;
  292 + ResultSet rs = null;
  293 + // 取昨天 的日期
  294 + String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1));
  295 + try {
  296 + conn = DBUtils_MS.getConnection();
  297 + ps = conn.prepareStatement(sql);
  298 + ps.setString(1, yesterday);
  299 + rs = ps.executeQuery();
  300 + Float lon, lat;
  301 + String kssk;
  302 + String speed;
  303 + while (rs.next()) {
  304 + kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP"));
  305 + speed = rs.getString("SPEED");
  306 + // 经纬度
  307 + lon = rs.getFloat("LON");
  308 + lat = rs.getFloat("LAT");
  309 + sBuffer.append("<CS>");
  310 + sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>");
  311 + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");////////
  312 + sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>");
  313 + sBuffer.append("<KSSK>").append(kssk).append("</KSSK>");
  314 + sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>");
  315 + sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>");
  316 + sBuffer.append("<KSLD>").append("").append("</KSLD>");//**********************
  317 + sBuffer.append("<JSSK>").append(kssk).append("</JSSK>");
  318 + sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>");
  319 + sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>");
  320 + sBuffer.append("<JSLD>").append("").append("</JSLD>");//**********************
  321 + sBuffer.append("<PJSD>").append(speed).append("</PJSD>");
  322 + sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>");
  323 + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
  324 + sBuffer.append("</CS>");
  325 + }
  326 + sBuffer.append("</CSs>");
  327 + logger.info("setCS:"+sBuffer.toString());
  328 + ssop.setCS(userNameOther, passwordOther, sBuffer.toString());
  329 + } catch (Exception e) {
  330 + e.printStackTrace();
  331 + } finally {
  332 + DBUtils_MS.close(rs, ps, conn);
  333 + }
  334 + return result;
  335 + }
  336 +
  337 + /**
  338 + * 上传线路班次时刻表数据
  339 + */
  340 + @Override
  341 + public String setSKB(String ids) {
  342 + String result = "success";
  343 + try {
  344 + String[] idArray = ids.split(",");
  345 + StringBuffer sBuffer = new StringBuffer();
  346 + TTInfo ttInfo;
  347 + TTInfoDetail ttInfoDetail;
  348 + Iterator<TTInfoDetail> ttInfoDetailIterator;
  349 + HashMap<String,Object> param = new HashMap<String, Object>();
  350 + String ttinfoJhlc = null;//计划总里程
  351 + sBuffer.append("<SKBs>");
  352 + for (int i = 0; i < idArray.length; i++) {
  353 + ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i]));
  354 + param.put("ttinfo.id_eq", ttInfo.getId());
  355 + ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param),
  356 + new Sort(Direction.ASC, "xl_dir")).iterator();
  357 + sBuffer.append("<SKB>");
  358 + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl())).append("</XLBM>");
  359 + ttinfoJhlc = new String();
  360 + sBuffer.append("<JHZLC>").append(ttinfoJhlc).append("</JHZLC>");
  361 + sBuffer.append("<JHYYLC>").append(ttinfoJhlc).append("</JHYYLC>");
  362 + sBuffer.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>");
  363 + sBuffer.append("<JSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</JSRQ>");/////////
  364 + sBuffer.append("<ZJZX>").append(changeRuleDay(ttInfo.getRule_days())).append("</ZJZX>");
  365 + sBuffer.append("<TBYY>").append("").append("</TBYY>");
  366 + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
  367 + int num = 1;
  368 + while (ttInfoDetailIterator.hasNext()) {
  369 + ttInfoDetail = ttInfoDetailIterator.next();
  370 + ttinfoJhlc = ttInfoDetail.getJhlc()+"";// 设置计划总里程
  371 + sBuffer.append("<BCList>");
  372 + sBuffer.append("<BC>");
  373 + sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>");
  374 + sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>");
  375 + sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz()).append("</FCZDMC>");
  376 + sBuffer.append("<ZDXH>").append(num).append("</ZDXH>");
  377 + sBuffer.append("<JHFCSJ>").append(ttInfoDetail.getFcsj()).append("</JHFCSJ>");
  378 + sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz()).append("</DDZDMC>");
  379 + sBuffer.append("<ZDXH>").append(num).append("</ZDXH>");
  380 + sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>");
  381 + sBuffer.append("</BC>");
  382 + sBuffer.append("</BCList>");
  383 + num++;
  384 + }
  385 + sBuffer.append("</SKB>");
  386 + }
  387 + sBuffer.append("</SKBs>");
  388 + logger.info("setSKB:"+sBuffer.toString());
  389 + ssop.setSKB(userNameOther, passwordOther, sBuffer.toString());
  390 + } catch (Exception e) {
  391 + e.printStackTrace();
  392 + }
  393 + return result;
  394 + }
  395 +
  396 + /**
  397 + * 上传线路人员车辆配置信息
  398 + */
  399 + @Override
  400 + public String setXLPC() {
  401 + String result = "success";
  402 + try {
  403 + StringBuffer sBuffer =new StringBuffer();
  404 + sBuffer.append("<XLPCs>");
  405 + // 声明变量
  406 + Line line = null;
  407 + Cars cars = null;
  408 + List<Personnel> personnelList = null;
  409 + List<Cars> carsList = null;
  410 + int totalPersonnel,totalCar ;// 人员数量。车辆数量
  411 + // 查询所有线路
  412 + Iterator<Line> lineIterator = lineRepository.findAll().iterator();
  413 + // 循环查找线路下的信息
  414 + while(lineIterator.hasNext()){
  415 + line = lineIterator.next();
  416 + sBuffer.append("<XLPC>");
  417 + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>");
  418 + // 查询驾驶员数量
  419 + personnelList = personnelRepository.findJsysByLineId(line.getId());
  420 + totalPersonnel = personnelList != null ? personnelList.size():0;
  421 + sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>");
  422 + // 查询售票员人员数量
  423 + personnelList = personnelRepository.findSpysByLineId(line.getId());
  424 + totalPersonnel = personnelList != null ? personnelList.size():0;
  425 + sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>");
  426 + // 查询车辆
  427 + carsList = carsRepository.findCarsByLineId(line.getId());
  428 + totalCar = carsList != null ? carsList.size():0;
  429 + sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>");
  430 + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
  431 + int carsNum = 0;
  432 + // 取车牌号
  433 + if(carsList != null){
  434 + carsNum = carsList.size();
  435 + sBuffer.append("<CPHList>");
  436 + for (int i = 0; i < carsNum; i++) {
  437 + cars = carsList.get(i);
  438 + sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>");
  439 + }
  440 + sBuffer.append("</CPHList>");
  441 + }
  442 + sBuffer.append("</XLPC>");
  443 + }
  444 + sBuffer.append("</XLPCs>");
  445 + logger.info("setXLPC:"+sBuffer.toString());
  446 + ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString());
  447 + } catch (Exception e) {
  448 + e.printStackTrace();
  449 + }
  450 + return result;
  451 + }
  452 +
  453 + /**
  454 + * 上传线路计划班次表
  455 + */
  456 + @Override
  457 + public String setJHBC() {
  458 + String result = "success";
  459 + try {
  460 + StringBuffer sBuffer =new StringBuffer();
  461 + sBuffer.append("<JHBCs>");
  462 + // 声明变量
  463 + SchedulePlanInfo schedulePlanInfo = null;
  464 + String xlbm = "",zbh = "";
  465 + Long lp = 0L;
  466 + int startSerialNum = 0,endSerialNum = 0;;
  467 + // 取明天的日期
  468 + String tomorrow = sdfnyr.format(DateUtils.addDays(new Date(), +1));
  469 + // 查询所有班次
  470 + List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow);
  471 + if(schedulePlanList != null ){
  472 + int size = schedulePlanList.size();
  473 + for (int i = 0; i < size; i++) {
  474 + schedulePlanInfo = schedulePlanList.get(i);
  475 + if(i == 0){// 第一次,则初始化值
  476 + xlbm = schedulePlanInfo.getXlBm();
  477 + zbh = schedulePlanInfo.getClZbh();
  478 + lp = schedulePlanInfo.getLp();
  479 + // 拼装XML
  480 + assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp);
  481 + }
  482 + // 比较是否为同一条线路同一辆车
  483 + if(xlbm.equals(schedulePlanInfo.getXlBm())
  484 + && zbh.equals(schedulePlanInfo.getClZbh())
  485 + && lp == schedulePlanInfo.getLp()){
  486 + sBuffer.append("<BC>");
  487 + sBuffer.append("<SJGH>").append(schedulePlanInfo.getjGh()).append("</SJGH>");
  488 + sBuffer.append("<SXX>").append(schedulePlanInfo.getXlDir()).append("</SXX>");
  489 + sBuffer.append("<FCZDMC>").append(schedulePlanInfo.getQdzName()).append("</FCZDMC>");
  490 + sBuffer.append("<ZDXH>").append(++startSerialNum).append("</ZDXH>");
  491 + sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>");
  492 + sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>");
  493 + sBuffer.append("<ZDXH>").append(++endSerialNum).append("</ZDXH>");
  494 + sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj()))
  495 + .append("</JHDDSJ>");
  496 + sBuffer.append("</BC>");
  497 + if(i == size -1 ){
  498 + sBuffer.append("</BCList>");
  499 + sBuffer.append("</JHBC>");
  500 + }
  501 + }else{
  502 + xlbm = schedulePlanInfo.getXlBm();
  503 + zbh = schedulePlanInfo.getClZbh();
  504 + lp = schedulePlanInfo.getLp();
  505 + sBuffer.append("</BCList>");
  506 + sBuffer.append("</JHBC>");
  507 + startSerialNum = 0;
  508 + endSerialNum = 0;
  509 + // 拼装XML
  510 + assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp);
  511 + }
  512 + }
  513 + }
  514 + sBuffer.append("</JHBCs>");
  515 + logger.info("setJHBC:"+sBuffer.toString());
  516 + ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString());
  517 + } catch (Exception e) {
  518 + e.printStackTrace();
  519 + }
  520 + return result;
  521 + }
  522 +
  523 + /**
  524 + * 上传路单
  525 + * @param date
  526 + * @return xml格式的字符串
  527 + */
  528 + public String setLD(){
  529 + // 取昨天 的日期
  530 + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1));
  531 + try {
  532 + StringBuffer sf = new StringBuffer();
  533 + sf.append("<DLDS>");
  534 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date);
  535 + List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLDGroup(date);
  536 + Map<String,Object> map = new HashMap<String,Object>();
  537 + for(ScheduleRealInfo schRealInfo:listGroup){
  538 + if(schRealInfo != null){
  539 + //根据车辆自编号查询车牌号
  540 + map.put("insideCode_eq", schRealInfo.getClZbh());
  541 + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map));
  542 + sf.append("<DLD>");
  543 + sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>");
  544 + sf.append("<XLBM>"+schRealInfo.getXlBm()+"</XLBM>");
  545 + sf.append("<LPBH>"+schRealInfo.getLpName()+"</LPBH>");
  546 + sf.append("<CPH>"+car.getCarPlate()+"</CPH>");
  547 + sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>");
  548 + sf.append("<LDList>");
  549 +
  550 + int seqNumber = 0;
  551 + for(ScheduleRealInfo scheduleRealInfo:list){
  552 + if(schRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm()) && schRealInfo.getLpName().equals(scheduleRealInfo.getLpName())
  553 + && schRealInfo.getClZbh().equals(scheduleRealInfo.getClZbh())){
  554 + scheduleRealInfo.getQdzCode();
  555 + sf.append("<LD>");
  556 + sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>");
  557 + sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>");
  558 + sf.append("<FCZDMC>"+scheduleRealInfo.getQdzName()+"</FCZDMC>");
  559 + sf.append("<FCZDXH>" + ++seqNumber + "</FCZDXH>");
  560 + sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>");
  561 + sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>");
  562 + sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>");
  563 + sf.append("<SJFCSJ>"+scheduleRealInfo.getFcsjActual()+"</SJFCSJ>");
  564 + sf.append("<FCZDLX>"+""+"</FCZDLX>");
  565 + sf.append("<DDZDMC>"+scheduleRealInfo.getZdzName()+"</DDZDMC>");
  566 + sf.append("<DDZDXH>"+ seqNumber +"</DDZDXH>");
  567 + sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>");
  568 + sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>");
  569 + sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>");
  570 + sf.append("<DDZDLX>"+""+"</DDZDLX>");
  571 + sf.append("<LDSCBZ>"+0+"</LDSCBZ>");
  572 + sf.append("<DDBZ>"+scheduleRealInfo.getRemarks()+"</DDBZ>");
  573 + sf.append("</LD>");
  574 + }
  575 + }
  576 +
  577 + sf.append("</LDList>");
  578 + sf.append("</DLD>");
  579 + }
  580 + }
  581 +
  582 + sf.append("</DLDS>");
  583 + logger.info("setLD:"+sf.toString());
  584 + ssop.setLD(userNameOther, passwordOther, sf.toString());
  585 + } catch (Exception e) {
  586 + e.printStackTrace();
  587 + }
  588 + return "";
  589 + }
  590 +
  591 + /**
  592 + * 上传里程油耗
  593 + * @param date
  594 + * @return
  595 + */
  596 + public String setLCYH(){
  597 + // 取昨天 的日期
  598 + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1));
  599 + try {
  600 + StringBuffer sf = new StringBuffer();
  601 + sf.append("<LCYHS>");
  602 + List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLCYHGroup(date);
  603 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date);
  604 + Map<String,Object> map = new HashMap<String,Object>();
  605 + for(ScheduleRealInfo schRealInfo:listGroup){
  606 + if(schRealInfo != null){
  607 + //计算总公里和空驶公里,营运公里=总公里-空驶公里
  608 + double totalKilometers = 0,emptyKilometers =0;
  609 + sf.append("<LCYH>");
  610 + map.put("insideCode_eq", schRealInfo.getClZbh());
  611 + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map));
  612 +// Cars car = carsRepository.findCarByClzbh(schRealInfo.getClZbh());
  613 + sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>");
  614 + sf.append("<XLBM>"+schRealInfo.getXlBm()+"</XLBM>");
  615 + sf.append("<CPH>"+car.getCarPlate()+"</CPH>");
  616 + for(ScheduleRealInfo scheduleRealInfo:list){
  617 + if(schRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm()) && schRealInfo.getClZbh().equals(scheduleRealInfo.getClZbh())){
  618 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  619 + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
  620 + if(childTaskPlans.isEmpty()){
  621 + if(scheduleRealInfo.getStatus() == 2){
  622 + totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  623 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  624 + || scheduleRealInfo.getBcType().equals("venting")){
  625 + emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();;
  626 + }
  627 + }
  628 + }else{
  629 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  630 + while(it.hasNext()){
  631 + ChildTaskPlan childTaskPlan = it.next();
  632 + if(!childTaskPlan.isDestroy()){
  633 + totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();
  634 + if(childTaskPlan.getMileageType().equals("empty")){
  635 + emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();;
  636 + }
  637 + }
  638 + }
  639 + }
  640 + }
  641 + }
  642 + sf.append("<ZLC>"+totalKilometers+"</ZLC>");
  643 + sf.append("<YYLC>"+emptyKilometers+"</YYLC>");
  644 + sf.append("<YH>"+""+"</YH>");
  645 + sf.append("<JZYL>"+""+"</JZYL>");
  646 + sf.append("<DH>"+""+"</DH>");
  647 + sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>");
  648 + sf.append("<BBSCBZ>"+0+"</BBSCBZ>");
  649 + sf.append("</LCYH>");
  650 + }
  651 + }
  652 + sf.append("</LCYHS>");
  653 + logger.info("setLCYH:"+sf.toString());
  654 + ssop.setLCYH(userNameOther, passwordOther, sf.toString());
  655 + } catch (Exception e) {
  656 + e.printStackTrace();
  657 + }
  658 + return date;
  659 + }
  660 +
  661 + /**
  662 + * 上传线路调度日报
  663 + * @return
  664 + */
  665 + public String setDDRB(){
  666 + // 取昨天 的日期
  667 + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1));
  668 + try {
  669 + StringBuffer sf = new StringBuffer();
  670 + sf.append("<DDRBS>");
  671 + List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setDDRBGroup(date);
  672 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date);
  673 + for(ScheduleRealInfo schRealInfo:listGroup){
  674 + if(schRealInfo != null){
  675 + double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0;
  676 + int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0;
  677 + sf.append("<DDRB>");
  678 + sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>");
  679 + sf.append("<XLBM>"+schRealInfo.getXlBm()+"</XLBM>");
  680 + for(ScheduleRealInfo scheduleRealInfo:list){
  681 + if(scheduleRealInfo != null){
  682 + if(scheduleRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm())){
  683 + //计划
  684 + if(!scheduleRealInfo.isSflj()){
  685 + jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  686 + //计划空驶
  687 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){
  688 + jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  689 + }
  690 + //计划早高峰,计划晚高峰
  691 + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){
  692 + jhzgfbc++;
  693 + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){
  694 + jhwgfbc++;
  695 + }
  696 + }
  697 + jhbc++;
  698 +
  699 + //实际
  700 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  701 + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
  702 + if(childTaskPlans.isEmpty()){
  703 + if(scheduleRealInfo.getStatus() == 2){
  704 + sjbc++;
  705 + zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  706 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  707 + || scheduleRealInfo.getBcType().equals("venting")){
  708 + sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();;
  709 + }
  710 + }
  711 + }else{
  712 + sjbc++;
  713 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  714 + while(it.hasNext()){
  715 + ChildTaskPlan childTaskPlan = it.next();
  716 + if(!childTaskPlan.isDestroy()){
  717 + zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();
  718 + if(childTaskPlan.getMileageType().equals("empty")){
  719 + sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();;
  720 + }
  721 + }
  722 + }
  723 + }
  724 + //实际早高峰,计划晚高峰
  725 + if(scheduleRealInfo.getFcsjActual() != null){
  726 + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){
  727 + sjzgfbc++;
  728 + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){
  729 + sjwgfbc++;
  730 + }
  731 + }
  732 + }
  733 + }
  734 + }
  735 + sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>");
  736 + sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>");
  737 + sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>");
  738 + sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>");
  739 + sf.append("<JHBC>"+jhbc+"</JHBC>");
  740 + sf.append("<SJBC>"+sjbc+"</SJBC>");
  741 + sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>");
  742 + sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>");
  743 + sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>");
  744 + sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>");
  745 + sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>");
  746 + sf.append("<RBSCBZ>"+0+"</RBSCBZ>");
  747 + sf.append("</DDRB>");
  748 + }
  749 + }
  750 + sf.append("</DDRBS>");
  751 + logger.info("setDDRB:"+sf.toString());
  752 + ssop.setDDRB(userNameOther, passwordOther, sf.toString());
  753 + } catch (Exception e) {
  754 + e.printStackTrace();
  755 + }
  756 + return date;
  757 + }
  758 +
  759 + /**
  760 + * 计算结束时间
  761 + * @param fcsj 发车时间
  762 + * @param bcsj 班次历时
  763 + * @return
  764 + */
  765 + private String calcDdsj(String fcsj,Integer bcsj){
  766 + String result = "";
  767 + if(fcsj.indexOf(":") != -1){
  768 + if(bcsj == null){
  769 + return fcsj;
  770 + }
  771 + // 时和分隔开
  772 + String[] fcsjArray = fcsj.split(":");
  773 + // 分和历时时间相加
  774 + Integer fullTime = Integer.valueOf(fcsjArray[1])+ bcsj;
  775 + int hour,min,sumHour;
  776 + hour = fullTime / 60;
  777 + min = fullTime % 60;
  778 + sumHour = Integer.valueOf(fcsjArray[0])+hour;
  779 + if(sumHour >= 24){
  780 + result = sumHour - 24+":";
  781 + }else{
  782 + result = sumHour +":";
  783 + }
  784 + result +=String.format("%02d", min);
  785 + }else{
  786 + result = fcsj;
  787 + }
  788 + return result;
  789 + }
  790 +
  791 + /**
  792 + * 拼装线路计划班次表的XML
  793 + * @param sBuffer
  794 + * @param schedulePlanInfo
  795 + * @param xlbm
  796 + * @param zbh
  797 + * @param lp
  798 + */
  799 + private void assembleJHBC(StringBuffer sBuffer,SchedulePlanInfo schedulePlanInfo,String xlbm,String zbh,Long lp){
  800 + sBuffer.append("<JHBC>");
  801 + sBuffer.append("<RQ>").append(sdfnyr.format(schedulePlanInfo.getScheduleDate())).append("</RQ>");
  802 + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(xlbm)).append("</XLBM>");
  803 + sBuffer.append("<CPH>").append("沪"+zbh).append("</CPH>");
  804 + sBuffer.append("<LPBH>").append(lp).append("</LPBH>");
  805 + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
  806 + sBuffer.append("<BCList>");
  807 + }
  808 + /**
  809 + * 转换排班规则
  810 + * @param ruleDay
  811 + * @return
  812 + */
  813 + private String changeRuleDay(String ruleDay){
49 814 String result = "";
50   - StringBuffer sbBuffer = new StringBuffer();
51   - Iterator<Line> lines = repository.findAll().iterator();
52   - if(lines.hasNext()){
53   - Line line = lines.next();
  815 + int flag ;
  816 + String[] ruleDayArray = ruleDay.split(",");
  817 + for (int i = 0; i < ruleDayArray.length; i++) {
  818 + if(ruleDayArray[i].equals("1")){
  819 + flag = i+1;
  820 + }else{
  821 + flag = 0;
  822 + }
  823 + result += flag;
  824 + if(i !=ruleDayArray.length ){
  825 + result +=",";
  826 + }
54 827 }
55   - System.out.println(portType.setXL(sbBuffer.toString(), userName, password));;
56   - System.out.println("abdfedddddddddddddddddddddddddddd");
57 828 return result;
58 829 }
  830 + /**
  831 + * 设置统一的公司名称
  832 + * @param company
  833 + */
  834 + private void setCompanyName(String company){
  835 + if(company.equals("闵行公司")){
  836 + company = "浦东闵行公交公司";
  837 + }else if(company.equals("杨高公司")){
  838 + company = "浦东杨高公交公司";
  839 + }else if(company.equals("上南公司")){
  840 + company = "浦东上南公交公司";
  841 + }else if(company.equals("金高公司")){
  842 + company = "浦东金高公交公司";
  843 + }else if(company.equals("南汇公司")){
  844 + company = "浦东南汇公交公司";
  845 + }
  846 + }
  847 + /**
  848 + * @param stations 站点路由集
  849 + * @param sBuffer sBuffer
  850 + * @param StartId 站点序号起始ID
  851 + *
  852 + * @return 站点序号累加后的ID
  853 + */
  854 + private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){
  855 + int size = stationsList.size();
  856 + StationRoute srRoute = null;
  857 + String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站
  858 + for (int i = 0; i < size; i++) {
  859 + srRoute = stationsList.get(i);
  860 + zdlx = srRoute.getStationMark();
  861 + if(zdlx.equals("B")){
  862 + zdlx = "0";
  863 + }else if(zdlx.equals("E")){
  864 + zdlx = "1";
  865 + }else{
  866 + zdlx = "2";
  867 + }
  868 + sBuffer.append("<Station>");
  869 + sBuffer.append("<ZDXH>").append(startId).append("</ZDXH>");
  870 + sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>");
  871 + sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>");
  872 + sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>");
  873 + sBuffer.append("<ZDJD>").append(srRoute.getStation().getgLonx()).append("</ZDJD>");
  874 + sBuffer.append("<ZDWD>").append(srRoute.getStation().getgLaty()).append("</ZDWD>");
  875 + sBuffer.append("<ZZ>").append(srRoute.getStation().getAddr()).append("</ZZ>");//站点的具体地址
  876 + sBuffer.append("<ZDLX>").append(zdlx).append("</ZDLX>");
  877 + sBuffer.append("<ZJLC>").append(srRoute.getDistances()).append("</ZJLC>");
  878 + sBuffer.append("</Station>");
  879 + startId++;
  880 + }
  881 + return startId;
  882 + }
59 883  
60 884 }
... ...
src/main/java/com/bsth/util/TimeUtils.java
1 1 package com.bsth.util;
2 2  
3 3 public class TimeUtils {
  4 +
  5 + /**
  6 + * 时间差
  7 + * @param date1
  8 + * @param date2
  9 + * @return
  10 + */
4 11 public static String getTimeDifference(String date1,String date2){
5 12 String[] temp1 = date1.split(":");
6 13 String[] temp2 = date2.split(":");
... ... @@ -14,4 +21,41 @@ public class TimeUtils {
14 21 return ((m2+s2)-(m1+s1))+"";
15 22 }
16 23 }
  24 +
  25 + /**
  26 + * 是否是早高峰
  27 + * @param time
  28 + * @return
  29 + */
  30 + public static boolean morningPeak(String time){
  31 + String[] temp = time.split(":");
  32 + int d1 = Integer.parseInt(temp[0])*60;
  33 + int d2 = Integer.parseInt(temp[1]);
  34 + //早高峰时间
  35 + int sj_0 = 6*60+31,sj_1 = 8*60+30;
  36 + if((d1+d2) >= sj_0 && (d1+d2) <= sj_1){
  37 + return true;
  38 + }else{
  39 + return false;
  40 + }
  41 + }
  42 +
  43 + /**
  44 + * 是否是晚高峰
  45 + * @param time
  46 + * @return
  47 + */
  48 + public static boolean evenignPeak(String time){
  49 + String[] temp = time.split(":");
  50 + int d1 = Integer.parseInt(temp[0])*60;
  51 + int d2 = Integer.parseInt(temp[1]);
  52 + //早高峰时间
  53 + int sj_0 = 16*60+1,sj_1 = 18*60;
  54 + if((d1+d2) >= sj_0 && (d1+d2) <= sj_1){
  55 + return true;
  56 + }else{
  57 + return false;
  58 + }
  59 + }
  60 +
17 61 }
... ...
src/main/resources/logback.xml
... ... @@ -85,6 +85,26 @@
85 85 <appender-ref ref="GATEWAY" />
86 86 </logger>
87 87  
  88 + <!-- 和网关通讯日志日志 -->
  89 + <appender name="TRAFFIC"
  90 + class="ch.qos.logback.core.rolling.RollingFileAppender">
  91 + <file>${LOG_BASE}/traffic/traffic.log</file>
  92 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  93 + <fileNamePattern>${LOG_BASE}/traffic/traffic-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  94 + <timeBasedFileNamingAndTriggeringPolicy
  95 + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  96 + <maxFileSize>100MB</maxFileSize>
  97 + </timeBasedFileNamingAndTriggeringPolicy>
  98 + </rollingPolicy>
  99 +
  100 + <layout class="ch.qos.logback.classic.PatternLayout">
  101 + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%file:%line] %-5level -%msg%n
  102 + </pattern>
  103 + </layout>
  104 + </appender>
  105 + <logger name="com.bsth.service.impl.TrafficManageServiceImpl" level="INFO" additivity="false" >
  106 + <appender-ref ref="TRAFFIC" />
  107 + </logger>
88 108  
89 109 <!-- 日志输出级别 -->
90 110 <root level="info">
... ...
src/main/resources/static/pages/trafficManage/js/timeTempletUpload.js
... ... @@ -34,31 +34,46 @@
34 34 }
35 35 var lines = new Array();
36 36 var gsmap = getBusMap();
37   - // 取得所有线路
38   - $get('/line/all', null, function(allLine) {
39   - // 遍历数组
40   - $.each(allLine, function(i, e) {
41   - var companyCode = e.company;
42   - e.company = gsmap[e.company];
43   - e.brancheCompany = gsmap[companyCode+"_"+e.brancheCompany];
44   - var line = '{"hex":"' + e.company + '","label":"' + e.name
45   - + '"}';
46   - var obj = jQuery.parseJSON(line);
47   - lines[i] = obj;
48   - });
49   - });
50   - // 给输入框绑定autocomplete事件
51   - $("input[name='xl.name_eq']").autocompleter({
52   - highlightMatches : true,
53   - source : lines,
54   - template : '{{ label }} <span>({{ hex }})</span>',
55   - hint : true,
56   - empty : false,
57   - limit : 5,
  37 +
  38 + $('#line').select2({
  39 + ajax: {
  40 + url: '/realSchedule/findLine',
  41 + type: 'post',
  42 + dataType: 'json',
  43 + delay: 150,
  44 + data: function(params){
  45 + return{line: params.term};
  46 + },
  47 + processResults: function (data) {
  48 + return {
  49 + results: data
  50 + };
  51 + },
  52 + cache: true
  53 + },
  54 + templateResult: function(repo){
  55 + if (repo.loading) return repo.text;
  56 + var h = '<span>'+repo.text+'</span>';
  57 + return h;
  58 + },
  59 + escapeMarkup: function (markup) { return markup; },
  60 + minimumInputLength: 1,
  61 + templateSelection: function(repo){
  62 + return repo.text;
  63 + },
  64 + language: {
  65 + noResults: function(){
  66 + return '<span style="color:red;font-size: 12px;">没有搜索到线路!</span>';
  67 + },
  68 + inputTooShort : function(e) {
  69 + return '<span style="color:gray;font-size: 12px;"><i class="fa fa-search"></i> 输入线路搜索线路</span>';
  70 + },
  71 + searching : function() {
  72 + return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>';
  73 + }
  74 + }
58 75 });
59   - // 设置autocompleter的宽度和输入框一样
60   - $(".autocompleter").css("width",
61   - $("input[name='xl.name_eq']").css("width"));
  76 +
62 77 // 绑定查询事件
63 78 $("#search").click(searchM);
64 79 // 绑定上传事件
... ... @@ -77,13 +92,13 @@
77 92 $("#right_div table tbody").empty();
78 93 var params = {};
79 94 // 取得输入框的值
80   - var inputs = $("ul.breadcrumb input");
  95 + var inputs = $(".param input,select");debugger;
81 96 // 遍历数组
82 97 $.each(inputs, function(i, element) {
83 98 params[$(element).attr("name")] = $(element).val();
84 99 });
85 100 var i = layer.load(2);
86   - $get('/spc', params, function(data) {
  101 + $get('/tic', params, function(data) {
87 102 _dateFormat(data.content);
88 103 var bodyHtm = template('timeTemplet_list_temp', {
89 104 list : data.content
... ... @@ -97,16 +112,33 @@
97 112  
98 113 // 上传方法
99 114 function uploadM() {
100   - var params = {};
  115 +
101 116 // 取得输入框的值
102   - var trs = $("#right_div tbody tr");
  117 + var trs = $("#right_div tbody tr input");
103 118 if (trs.length == 0) {
104 119 alert("请选择模板");
105 120 return;
106 121 }
  122 + var ids ="0,";
107 123 // 遍历数组
108 124 $.each(trs, function(i, element) {
109   - alert($(".ttInfoId", element).html());
  125 + ids +=$(element).val()+",";
  126 + });
  127 + var params = {"ids":ids};
  128 + $.ajax({
  129 + type: 'get',url: '/trmg/setSKB',
  130 + data: params ,dataType:'text',
  131 + success:function(data) {
  132 + if(data == 'success'){
  133 + alert("上传成功");
  134 + }else{
  135 + alert("上传失败");
  136 + }
  137 +
  138 + }, error : function() {
  139 + alert("操作失败");
  140 + }
  141 +
110 142 });
111 143 }
112 144  
... ... @@ -145,10 +177,10 @@
145 177 function _dateFormat(list) {
146 178 var fs = 'YYYY-MM-DD HH:mm';
147 179 $.each(list, function(i, obj) {
148   - obj.ttInfo.qyrq = moment(obj.ttInfo.qyrq).format(fs);
  180 + obj.qyrq = moment(obj.qyrq).format(fs);
149 181 });
150 182 }
151   -
  183 + /*
152 184 // 绑定查询事件
153 185 $("#setXL").click(setXLF);
154 186 var params = {};
... ... @@ -164,4 +196,85 @@
164 196  
165 197 });
166 198 }
  199 +
  200 + // 绑定查询事件
  201 + $("#setCL").click(setCLF);
  202 + var params = {};
  203 + function setCLF() {
  204 + $.ajax({
  205 + type: 'get',url: '/trmg/setCL',
  206 + data: params ,dataType:'text',
  207 + success:function(data) {
  208 + alert(data);
  209 + }, error : function() {
  210 + alert("操作失败");
  211 + }
  212 +
  213 + });
  214 + }
  215 +
  216 + // 绑定查询事件
  217 + $("#setSJ").click(setSJF);
  218 + var params = {};
  219 + function setSJF() {
  220 + $.ajax({
  221 + type: 'get',url: '/trmg/setSJ',
  222 + data: params ,dataType:'text',
  223 + success:function(data) {
  224 + alert(data);
  225 + }, error : function() {
  226 + alert("操作失败");
  227 + }
  228 +
  229 + });
  230 + }
  231 +
  232 + // 绑定查询事件
  233 + $("#setCS").click(setCSF);
  234 + var params = {};
  235 + function setCSF() {
  236 + $.ajax({
  237 + type: 'get',url: '/trmg/setCS',
  238 + data: params ,dataType:'text',
  239 + success:function(data) {
  240 + alert(data);
  241 + }, error : function() {
  242 + alert("操作失败");
  243 + }
  244 +
  245 + });
  246 + }
  247 +
  248 + // 绑定查询事件
  249 + $("#setXLPC").click(setXLPCF);
  250 + var params = {};
  251 + function setXLPCF() {
  252 + $.ajax({
  253 + type: 'get',url: '/trmg/setXLPC',
  254 + data: params ,dataType:'text',
  255 + success:function(data) {
  256 + alert(data);
  257 + }, error : function() {
  258 + alert("操作失败");
  259 + }
  260 +
  261 + });
  262 + }
  263 +
  264 + // 绑定查询事件
  265 + $("#setJHBC").click(setJHBCF);
  266 + var params = {};
  267 + function setJHBCF() {
  268 + $.ajax({
  269 + type: 'get',url: '/trmg/setJHBC',
  270 + data: params ,dataType:'text',
  271 + success:function(data) {
  272 + alert(data);
  273 + }, error : function() {
  274 + alert("操作失败");
  275 + }
  276 +
  277 + });
  278 + }*/
  279 +
167 280 })();
168 281 \ No newline at end of file
... ...
src/main/resources/static/pages/trafficManage/timeTempletUpload.html
... ... @@ -7,17 +7,26 @@
7 7 </ul>
8 8 <div class="tab_line">
9 9 <div class="col-md-12">
10   - <ul class="breadcrumb">
11   - <li>线路名称:</li>
12   - <li><input type="text" class="form-control form-filter input-sm"
13   - name="xl.name_eq" placeholder="请输入线路名称" maxlength="40" /></li>
14   - <li>模板名称(关键字):</li>
15   - <li><input type="text" class="form-control form-filter input-sm"
16   - name="ttInfo.name_like" maxlength="40" /></li>
17   - <li><a class="btn btn-circle blue" id="search">查询</a></li>
18   - <li><a class="btn btn-circle red" id="upload">上传</a></li>
19   - <li><a class="btn btn-circle red" id="setXL">上传线路</a></li>
20   - </ul>
  10 + <form class="form-inline" action="">
  11 + <div style="display: inline-block;" class="param">
  12 + <span class="item-label" style="width: 80px;">线路: </span>
  13 + <select class="form-control" name="xl.lineCode_like" id="line" style="width: 180px;"></select>
  14 + </div>
  15 + <div style="display: inline-block;margin-left: 15px;" class="param">
  16 + <span class="item-label" style="width: 80px;">模板名称(关键字): </span>
  17 + <input class="form-control" type="text" id="tempName" name="name_like" style="width: 180px;"/>
  18 + </div>
  19 + <div class="form-group" style="display: inline-block;margin-left: 15px;">
  20 + <input class="btn btn-default" type="button" id="search" value="查询"/>
  21 + <input class="btn btn-default" type="button" id="upload" value="上传"/>
  22 + <!-- <input class="btn btn-default" type="button" id="setXL" value="上传线路"/>
  23 + <input class="btn btn-default" type="button" id="setCL" value="上传车辆"/>
  24 + <input class="btn btn-default" type="button" id="setSJ" value="上传司机"/>
  25 + <input class="btn btn-default" type="button" id="setCS" value="超速"/>
  26 + <input class="btn btn-default" type="button" id="setXLPC" value="线路人员车辆"/>
  27 + <input class="btn btn-default" type="button" id="setJHBC" value="线路计划班次表"/> -->
  28 + </div>
  29 + </form>
21 30 </div>
22 31 <!-- Begin: left-div -->
23 32 <div class="col-md-5 panel-wrap" style="height: 60%;">
... ... @@ -67,13 +76,14 @@
67 76 {{obj.xl.name}}
68 77 </td>
69 78 <td class="ttInfoId">
70   - {{obj.ttInfo.id}}
  79 + {{obj.id}}
  80 + <input type="hidden" value="{{obj.id}}"/>
71 81 </td>
72 82 <td>
73   - {{obj.ttInfo.name}}
  83 + {{obj.name}}
74 84 </td>
75 85 <td >
76   - {{obj.ttInfo.qyrq}}
  86 + {{obj.qyrq}}
77 87 </td>
78 88 </tr>
79 89 {{/each}}
... ...