Commit a20368b40fde22c7d74204c6529084d9f876efdb
Merge branch 'pudong' of 192.168.168.201:panzhaov5/bsth_control into pudong
Showing
14 changed files
with
2850 additions
and
1839 deletions
Too many changes to show.
To preserve performance only 14 of 15 files are displayed.
src/main/java/com/bsth/controller/report/CardIsingningController.java
0 → 100644
| 1 | +package com.bsth.controller.report; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.bsth.entity.card_signing.CardSigning; | ||
| 5 | +import com.bsth.service.report.CardSigningService; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.*; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +@RestController | ||
| 13 | +@RequestMapping("CardSigning") | ||
| 14 | +public class CardIsingningController { | ||
| 15 | + @Autowired | ||
| 16 | + CardSigningService cardSigningService; | ||
| 17 | + | ||
| 18 | + //线路插卡率列表 | ||
| 19 | + @RequestMapping(value = "/cardList",method = RequestMethod.GET) | ||
| 20 | + public List<CardSigning> sheetList(@RequestParam Map<String, Object> map){ | ||
| 21 | + List<CardSigning> list= cardSigningService.cardList(map); | ||
| 22 | + return list; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + //线路插卡率 线路详细列表第二级 | ||
| 26 | + @RequestMapping(value = "/calcListSheet",method = RequestMethod.GET) | ||
| 27 | + public List<CardSigning> calcListSheet(@RequestParam Map<String, Object> map){ | ||
| 28 | + List<CardSigning> list= cardSigningService.calcListSheet(map); | ||
| 29 | + return list; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + //线路插卡率 线路详细列表第二级 | ||
| 33 | + @RequestMapping(value = "/calcSheet",method = RequestMethod.GET) | ||
| 34 | + public List<CardSigning> calcSheet(@RequestParam Map<String, Object> map){ | ||
| 35 | + List<CardSigning> list= cardSigningService.calcSheet(map); | ||
| 36 | + return list; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +} |
src/main/java/com/bsth/entity/card_signing/CardSigning.java
0 → 100644
| 1 | +package com.bsth.entity.card_signing; | ||
| 2 | + | ||
| 3 | +import javax.persistence.GeneratedValue; | ||
| 4 | +import javax.persistence.Id; | ||
| 5 | + | ||
| 6 | +public class CardSigning { | ||
| 7 | + /* 主键*/ | ||
| 8 | + @Id | ||
| 9 | + @GeneratedValue | ||
| 10 | + private Integer id; | ||
| 11 | + //公司名称 | ||
| 12 | + private String gsName; | ||
| 13 | + //公司代码 | ||
| 14 | + private String gsBm; | ||
| 15 | + //分公司名称 | ||
| 16 | + private String fgsName; | ||
| 17 | + //分公司代码 | ||
| 18 | + private String fgsBm; | ||
| 19 | + //线路名称 | ||
| 20 | + private String xlName; | ||
| 21 | + //线路代码 | ||
| 22 | + private String xlBm; | ||
| 23 | + //时间 | ||
| 24 | + private String scheduleDateStr; | ||
| 25 | + //班次数 | ||
| 26 | + private Integer bcs; | ||
| 27 | + //签卡数 | ||
| 28 | + private Integer qks; | ||
| 29 | + /* //签卡率 | ||
| 30 | + private Double qkl;*/ | ||
| 31 | + //签卡率 | ||
| 32 | + private String qklName; | ||
| 33 | + //人卡故障数 | ||
| 34 | + private Integer rkgzs; | ||
| 35 | + /*//人卡故障率 | ||
| 36 | + private double rkgzl;*/ | ||
| 37 | + //人卡故障率 | ||
| 38 | + private String rkgzlName; | ||
| 39 | + //车卡故障数 | ||
| 40 | + private Integer ckgzs; | ||
| 41 | + /* //车卡故障率 | ||
| 42 | + private double ckgzl;*/ | ||
| 43 | + //车卡故障率 | ||
| 44 | + private String ckgzlName; | ||
| 45 | + //起点站 | ||
| 46 | + private String qdzName; | ||
| 47 | + //rfid状态 | ||
| 48 | + private Integer rfidState; | ||
| 49 | + //是否故障 | ||
| 50 | + private String rfidName; | ||
| 51 | + /** 计划发车时间(格式 HH:mm) */ | ||
| 52 | + private String fcsj; | ||
| 53 | + /** 实际发车时间*/ | ||
| 54 | + private String fcsjActual; | ||
| 55 | + | ||
| 56 | + public String getFcsj() { | ||
| 57 | + return fcsj; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setFcsj(String fcsj) { | ||
| 61 | + this.fcsj = fcsj; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public String getFcsjActual() { | ||
| 65 | + return fcsjActual; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setFcsjActual(String fcsjActual) { | ||
| 69 | + this.fcsjActual = fcsjActual; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public String getQdzName() { | ||
| 73 | + return qdzName; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setQdzName(String qdzName) { | ||
| 77 | + this.qdzName = qdzName; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public Integer getRfidState() { | ||
| 81 | + return rfidState; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public void setRfidState(Integer rfidState) { | ||
| 85 | + this.rfidState = rfidState; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public String getRfidName() { | ||
| 89 | + return rfidName; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public Integer getId() { | ||
| 93 | + return id; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public void setId(Integer id) { | ||
| 97 | + this.id = id; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public String getGsName() { | ||
| 101 | + return gsName; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public void setGsName(String gsName) { | ||
| 105 | + this.gsName = gsName; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public String getGsBm() { | ||
| 109 | + return gsBm; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public void setGsBm(String gsBm) { | ||
| 113 | + this.gsBm = gsBm; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public String getFgsName() { | ||
| 117 | + return fgsName; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public void setFgsName(String fgsName) { | ||
| 121 | + this.fgsName = fgsName; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public String getFgsBm() { | ||
| 125 | + return fgsBm; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public Integer getBcs() { | ||
| 129 | + return bcs; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public void setBcs(Integer bcs) { | ||
| 133 | + this.bcs = bcs; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public void setFgsBm(String fgsBm) { | ||
| 137 | + this.fgsBm = fgsBm; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public String getXlName() { | ||
| 141 | + return xlName; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + public void setXlName(String xlName) { | ||
| 145 | + this.xlName = xlName; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + public String getXlBm() { | ||
| 149 | + return xlBm; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + public void setXlBm(String xlBm) { | ||
| 153 | + this.xlBm = xlBm; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public String getScheduleDateStr() { | ||
| 157 | + return scheduleDateStr; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public void setScheduleDateStr(String scheduleDateStr) { | ||
| 161 | + this.scheduleDateStr = scheduleDateStr; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + public Integer getQks() { | ||
| 165 | + return qks; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + public void setQks(Integer qks) { | ||
| 169 | + this.qks = qks; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + public Integer getRkgzs() { | ||
| 173 | + return rkgzs; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + public void setRkgzs(Integer rkgzs) { | ||
| 177 | + this.rkgzs = rkgzs; | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + public Integer getCkgzs() { | ||
| 181 | + return ckgzs; | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + public void setCkgzs(Integer ckgzs) { | ||
| 185 | + this.ckgzs = ckgzs; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + public String getQklName() { | ||
| 189 | + return qklName; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + public void setQklName(String qklName) { | ||
| 193 | + this.qklName = qklName; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public String getRkgzlName() { | ||
| 197 | + return rkgzlName; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + public void setRkgzlName(String rkgzlName) { | ||
| 201 | + this.rkgzlName = rkgzlName; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + public String getCkgzlName() { | ||
| 205 | + return ckgzlName; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + public void setCkgzlName(String ckgzlName) { | ||
| 209 | + this.ckgzlName = ckgzlName; | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + public void setRfidName(String rfidName) { | ||
| 213 | + this.rfidName = rfidName; | ||
| 214 | + } | ||
| 215 | +} |
src/main/java/com/bsth/repository/StationRouteRepository.java
| @@ -229,7 +229,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -229,7 +229,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 229 | "a.station_route_code," + | 229 | "a.station_route_code," + |
| 230 | "b.station_cod," + | 230 | "b.station_cod," + |
| 231 | "a.distances,"+ | 231 | "a.distances,"+ |
| 232 | - "b.station_name," + | 232 | + "s.station_name," + |
| 233 | "a.directions FROM (SELECT " + | 233 | "a.directions FROM (SELECT " + |
| 234 | "s.station_mark," + | 234 | "s.station_mark," + |
| 235 | "s.station_route_code," + | 235 | "s.station_route_code," + |
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.bsth.common.ResponseCode; | 5 | import com.bsth.common.ResponseCode; |
| 6 | import com.bsth.data.BasicData; | 6 | import com.bsth.data.BasicData; |
| 7 | +import com.bsth.entity.Cars; | ||
| 7 | import com.bsth.entity.Line; | 8 | import com.bsth.entity.Line; |
| 8 | import com.bsth.entity.calc.CalcBusMileage; | 9 | import com.bsth.entity.calc.CalcBusMileage; |
| 9 | import com.bsth.entity.calc.CalcInterval; | 10 | import com.bsth.entity.calc.CalcInterval; |
| @@ -16,6 +17,7 @@ import com.bsth.entity.oil.Ylb; | @@ -16,6 +17,7 @@ import com.bsth.entity.oil.Ylb; | ||
| 16 | import com.bsth.entity.realcontrol.ChildTaskPlan; | 17 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 17 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 18 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 18 | import com.bsth.entity.sys.Interval; | 19 | import com.bsth.entity.sys.Interval; |
| 20 | +import com.bsth.repository.CarsRepository; | ||
| 19 | import com.bsth.repository.LineRepository; | 21 | import com.bsth.repository.LineRepository; |
| 20 | import com.bsth.repository.calc.CalcBusMileageRepository; | 22 | import com.bsth.repository.calc.CalcBusMileageRepository; |
| 21 | import com.bsth.repository.calc.CalcIntervalRepository; | 23 | import com.bsth.repository.calc.CalcIntervalRepository; |
| @@ -91,6 +93,8 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -91,6 +93,8 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 91 | private LineService lineService; | 93 | private LineService lineService; |
| 92 | @Autowired | 94 | @Autowired |
| 93 | private ReportService reportService; | 95 | private ReportService reportService; |
| 96 | + @Autowired | ||
| 97 | + CarsRepository carsRepository; | ||
| 94 | 98 | ||
| 95 | @Autowired | 99 | @Autowired |
| 96 | JdbcTemplate jdbcTemplate; | 100 | JdbcTemplate jdbcTemplate; |
| @@ -2207,6 +2211,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -2207,6 +2211,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 2207 | } else if(flag==3){ | 2211 | } else if(flag==3){ |
| 2208 | list1.add("自编号"); | 2212 | list1.add("自编号"); |
| 2209 | list1.add("车牌号"); | 2213 | list1.add("车牌号"); |
| 2214 | + list1.add("燃油类型"); | ||
| 2210 | } | 2215 | } |
| 2211 | list1.add("计划公里"); | 2216 | list1.add("计划公里"); |
| 2212 | list1.add("总公里"); | 2217 | list1.add("总公里"); |
| @@ -2223,8 +2228,14 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -2223,8 +2228,14 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 2223 | list1.add("合计"); | 2228 | list1.add("合计"); |
| 2224 | resList.add(list1); | 2229 | resList.add(list1); |
| 2225 | 2230 | ||
| 2226 | - int i=1; | 2231 | + Map<String, String> carsMap = new HashMap<>(); |
| 2232 | + List<Cars> carsList = carsRepository.findCars(); | ||
| 2233 | + for (Cars c:carsList) { | ||
| 2234 | + String sfdc = c.getSfdc()+""; | ||
| 2235 | + carsMap.put(c.getInsideCode(), sfdc.equals("true")?"纯电动":"柴油"); | ||
| 2236 | + } | ||
| 2227 | 2237 | ||
| 2238 | + int i=1; | ||
| 2228 | DecimalFormat df = new DecimalFormat("0.00");//格式化小数 | 2239 | DecimalFormat df = new DecimalFormat("0.00");//格式化小数 |
| 2229 | double allNum = 0.0; | 2240 | double allNum = 0.0; |
| 2230 | while (iter.hasNext()) { | 2241 | while (iter.hasNext()) { |
| @@ -2250,6 +2261,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -2250,6 +2261,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 2250 | } else if("cl".equals(statisticalObj)){ | 2261 | } else if("cl".equals(statisticalObj)){ |
| 2251 | listStr.add(c.getCl()); | 2262 | listStr.add(c.getCl()); |
| 2252 | listStr.add(BasicData.nbbmCompanyPlateMap.get(c.getCl())+""); | 2263 | listStr.add(BasicData.nbbmCompanyPlateMap.get(c.getCl())+""); |
| 2264 | + listStr.add(carsMap.get(c.getCl())); | ||
| 2253 | } else if("xl".equals(statisticalObj)){ | 2265 | } else if("xl".equals(statisticalObj)){ |
| 2254 | 2266 | ||
| 2255 | } | 2267 | } |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| 1 | -package com.bsth.service.impl; | ||
| 2 | - | ||
| 3 | -import com.bsth.data.BasicData; | ||
| 4 | -import com.bsth.email.SendEmailController; | ||
| 5 | -import com.bsth.email.entity.EmailBean; | ||
| 6 | -import com.bsth.entity.*; | ||
| 7 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | ||
| 8 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 9 | -import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 10 | -import com.bsth.entity.schedule.TTInfo; | ||
| 11 | -import com.bsth.entity.schedule.TTInfoDetail; | ||
| 12 | -import com.bsth.entity.search.CustomerSpecs; | ||
| 13 | -import com.bsth.entity.sys.SysUser; | ||
| 14 | -import com.bsth.entity.traffic.SKBUploadLogger; | ||
| 15 | -import com.bsth.repository.*; | ||
| 16 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 17 | -import com.bsth.repository.schedule.*; | ||
| 18 | -import com.bsth.repository.traffic.SKBUploadLoggerRepository; | ||
| 19 | -import com.bsth.security.util.SecurityUtils; | ||
| 20 | -import com.bsth.service.TrafficManageService; | ||
| 21 | -import com.bsth.service.traffic.YgcBasicDataService; | ||
| 22 | -import com.bsth.util.TimeUtils; | ||
| 23 | -import com.bsth.util.db.DBUtils_MS; | ||
| 24 | -import com.bsth.webService.trafficManage.org.tempuri.Results; | ||
| 25 | -import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; | ||
| 26 | -import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; | ||
| 27 | -import org.apache.commons.lang.StringEscapeUtils; | ||
| 28 | -import org.apache.commons.lang.StringUtils; | ||
| 29 | -import org.apache.commons.lang.time.DateUtils; | ||
| 30 | -import org.slf4j.Logger; | ||
| 31 | -import org.slf4j.LoggerFactory; | ||
| 32 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 33 | -import org.springframework.data.domain.Sort; | ||
| 34 | -import org.springframework.data.domain.Sort.Direction; | ||
| 35 | -import org.springframework.security.core.context.SecurityContextHolder; | ||
| 36 | -import org.springframework.stereotype.Service; | ||
| 37 | - | ||
| 38 | -import java.io.*; | ||
| 39 | -import java.net.InetAddress; | ||
| 40 | -import java.sql.Connection; | ||
| 41 | -import java.sql.PreparedStatement; | ||
| 42 | -import java.sql.ResultSet; | ||
| 43 | -import java.text.DecimalFormat; | ||
| 44 | -import java.text.SimpleDateFormat; | ||
| 45 | -import java.util.*; | ||
| 46 | -import java.util.regex.Matcher; | ||
| 47 | -import java.util.regex.Pattern; | ||
| 48 | - | ||
| 49 | -/** | ||
| 50 | - * | ||
| 51 | - * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) | ||
| 52 | - * | ||
| 53 | - * @Extends : BaseService | ||
| 54 | - * | ||
| 55 | - * @Description: TODO(运管处接口service业务层) | ||
| 56 | - * | ||
| 57 | - * @Author bsth@zq | ||
| 58 | - * | ||
| 59 | - * @Date 2016年10月28日 上午9:21:17 | ||
| 60 | - * | ||
| 61 | - * @Version 公交调度系统BS版 0.1 | ||
| 62 | - * | ||
| 63 | - */ | ||
| 64 | - | ||
| 65 | -@Service | ||
| 66 | -public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 67 | - | ||
| 68 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 69 | - // 运管处上传日志类型 | ||
| 70 | - public static final String UPLOAD_TYPE_SKB = "1"; | ||
| 71 | - public static final String UPLOAD_TYPE_XL = "2"; | ||
| 72 | - public static final String UPLOAD_TYPE_LD = "3"; | ||
| 73 | - | ||
| 74 | - // 线路repository | ||
| 75 | - @Autowired | ||
| 76 | - private LineRepository lineRepository; | ||
| 77 | - | ||
| 78 | - @Autowired | ||
| 79 | - private LineInformationRepository lineInformationRepository; | ||
| 80 | - | ||
| 81 | - // 站点路由repository | ||
| 82 | - @Autowired | ||
| 83 | - private StationRouteRepository stationRouteRepository; | ||
| 84 | - | ||
| 85 | - // 历史站点路由repository | ||
| 86 | - @Autowired | ||
| 87 | - private LsStationRouteRepository lsStationRouteRepository; | ||
| 88 | - | ||
| 89 | - @Autowired | ||
| 90 | - private SectionRepository sectionRepository; | ||
| 91 | - | ||
| 92 | - // 车辆repository | ||
| 93 | - @Autowired | ||
| 94 | - private CarsRepository carsRepository; | ||
| 95 | - | ||
| 96 | - // 人员repository | ||
| 97 | - @Autowired | ||
| 98 | - private PersonnelRepository personnelRepository; | ||
| 99 | - | ||
| 100 | - // 时刻模板repository | ||
| 101 | - @Autowired | ||
| 102 | - private TTInfoRepository ttInfoRepository; | ||
| 103 | - | ||
| 104 | - // 时刻模板明细repository | ||
| 105 | - @Autowired | ||
| 106 | - private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 107 | - | ||
| 108 | - // 排班计划明细repository | ||
| 109 | - @Autowired | ||
| 110 | - private SchedulePlanInfoRepository schedulePlanInfoRepository; | ||
| 111 | - | ||
| 112 | - // 实际排班计划明细repository | ||
| 113 | - @Autowired | ||
| 114 | - private ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 115 | - | ||
| 116 | - // 时刻表上传记录repository | ||
| 117 | - @Autowired | ||
| 118 | - private SKBUploadLoggerRepository skbUploadLoggerRepository; | ||
| 119 | - | ||
| 120 | - // 线路站点repository | ||
| 121 | - @Autowired | ||
| 122 | - private YgcBasicDataService ygcBasicDataService; | ||
| 123 | - | ||
| 124 | - // 发送邮件 | ||
| 125 | - @Autowired | ||
| 126 | - private SendEmailController sendEmailController; | ||
| 127 | - | ||
| 128 | - // 运管处上传接口 | ||
| 129 | - private com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap webServiceSoapUp; | ||
| 130 | - private WebServiceSoap ssop ; | ||
| 131 | - { | ||
| 132 | - try { | ||
| 133 | - ssop = new WebServiceLocator().getWebServiceSoap(); | ||
| 134 | - } catch (Exception e) { | ||
| 135 | - e.printStackTrace(); | ||
| 136 | - } | ||
| 137 | - } | ||
| 138 | - // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母 | ||
| 139 | - private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 140 | - | ||
| 141 | - // 格式化 年月日 | ||
| 142 | - private SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 143 | - | ||
| 144 | - // 数字格式化 | ||
| 145 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 146 | - | ||
| 147 | - // 用户名 | ||
| 148 | - private final String userNameOther = "user"; | ||
| 149 | - // 密码 | ||
| 150 | - private final String passwordOther = "user"; | ||
| 151 | - | ||
| 152 | - // 用户名 | ||
| 153 | - private final String userNameUp = "user"; | ||
| 154 | - // 密码 | ||
| 155 | - private final String passwordUp = "user"; | ||
| 156 | - // 接收邮件人 | ||
| 157 | - private final String emailSendToAddress = "113252620@qq.com"; | ||
| 158 | - // 记录路单上线的成功、失败线路数 | ||
| 159 | - private Integer countSuccess,countFailure; | ||
| 160 | - | ||
| 161 | - private synchronized com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap getWebServiceSoapUp(){ | ||
| 162 | - try { | ||
| 163 | - if(webServiceSoapUp == null){ | ||
| 164 | - webServiceSoapUp = new com.bsth.webService.trafficManage.up.org.tempuri.WebServiceLocator().getWebServiceSoap(); | ||
| 165 | - } | ||
| 166 | - }catch (Exception e){ | ||
| 167 | - e.printStackTrace(); | ||
| 168 | - }finally { | ||
| 169 | - return webServiceSoapUp; | ||
| 170 | - } | ||
| 171 | - } | ||
| 172 | - /** | ||
| 173 | - * 上传线路信息 | ||
| 174 | - */ | ||
| 175 | - @Override | ||
| 176 | - public String setXL(String ids) { | ||
| 177 | - String result = "failure"; | ||
| 178 | - String xml ; | ||
| 179 | - String[] idArray = ids.split(","); | ||
| 180 | - try { | ||
| 181 | - for (String id : idArray) { | ||
| 182 | - if(id == null || id.trim().equals("")){ | ||
| 183 | - continue; | ||
| 184 | - } | ||
| 185 | - Map<String,Object> map = new HashMap<>(); | ||
| 186 | - map.put("lineCode_eq", id); | ||
| 187 | - Line line ; | ||
| 188 | - LineInformation lineInformation; | ||
| 189 | - line = lineRepository.findOne(new CustomerSpecs<Line>(map)); | ||
| 190 | - if(line == null){ | ||
| 191 | - continue; | ||
| 192 | - } | ||
| 193 | - if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){ | ||
| 194 | - return result; | ||
| 195 | - } | ||
| 196 | - map = new HashMap<>(); | ||
| 197 | - map.put("line.id_eq",line.getId()); | ||
| 198 | - lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(map)); | ||
| 199 | - if(lineInformation == null){ | ||
| 200 | - continue; | ||
| 201 | - } | ||
| 202 | - // 取得封装好的xml | ||
| 203 | - xml = getSetXlXml(line,lineInformation); | ||
| 204 | - // 站点序号不能为0,如果为0,则返回错误 | ||
| 205 | - if(xml.indexOf("<ZDXH>0</ZDXH>") != -1){ | ||
| 206 | - return "0"; | ||
| 207 | - } | ||
| 208 | - String state;// 是否上传成功 | ||
| 209 | - // 调用上传方法 | ||
| 210 | - if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,xml).isSuccess()){ | ||
| 211 | - result = "success"; | ||
| 212 | - state = "1"; | ||
| 213 | - }else{ | ||
| 214 | - result = "failure"; | ||
| 215 | - state = "0"; | ||
| 216 | - } | ||
| 217 | - logger.info("setXL:"+xml); | ||
| 218 | - logger.info("setXL:"+result); | ||
| 219 | - // 保存运管处上传记录 | ||
| 220 | - saveYgcUploadLog(line,xml,TrafficManageServiceImpl.UPLOAD_TYPE_XL,state); | ||
| 221 | - } | ||
| 222 | - } catch (Exception e) { | ||
| 223 | - logger.error("setXL:",e); | ||
| 224 | - e.printStackTrace(); | ||
| 225 | - } | ||
| 226 | - return result; | ||
| 227 | - } | ||
| 228 | - | ||
| 229 | - /** | ||
| 230 | - * 加载运管处的站点及序号 | ||
| 231 | - * 上行从1开始,下行顺序续编 | ||
| 232 | - */ | ||
| 233 | - private Map<String, Integer> getStationName2YgcNumberMap (String lineCode){ | ||
| 234 | - Map<String, Integer> resultMap = new HashMap<>(); | ||
| 235 | - List<Map<String, String>> ygcLines = stationRouteRepository.findLineWithYgcByLine(lineCode); | ||
| 236 | - if(ygcLines != null && ygcLines.size() > 0){ | ||
| 237 | - int size = ygcLines.size(); | ||
| 238 | - Map<String, String> tempMap ; | ||
| 239 | - int num = 1; | ||
| 240 | - String key; | ||
| 241 | - for (int i = 0; i < size; i ++){ | ||
| 242 | - tempMap = ygcLines.get(i); | ||
| 243 | - key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | ||
| 244 | - + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | ||
| 245 | - resultMap.put(key,num++); | ||
| 246 | - } | ||
| 247 | - } | ||
| 248 | - return resultMap; | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - /** | ||
| 252 | - * 上传线路信息(按in_use上传) | ||
| 253 | - */ | ||
| 254 | - @Override | ||
| 255 | - public String setXLByInUse(String inUse) { | ||
| 256 | - StringBuffer result = new StringBuffer(); | ||
| 257 | - try { | ||
| 258 | - Map<String,Object> map = new HashMap<>(); | ||
| 259 | - if(inUse != null && inUse.equals("1")){ | ||
| 260 | - map.put("inUse_eq", inUse); | ||
| 261 | - } | ||
| 262 | - List<Line> lines ; | ||
| 263 | - Line line; | ||
| 264 | - lines = lineRepository.findAll(new CustomerSpecs<Line>(map)); | ||
| 265 | - if(lines != null && lines.size() > 0){ | ||
| 266 | - for(int i = 0 ; i < lines.size() ; i ++){ | ||
| 267 | - line = lines.get(i); | ||
| 268 | - if(line != null && line.getId() != null){ | ||
| 269 | - result.append(line.getLineCode()).append(":").append(setXL(line.getLineCode())).append(";"); | ||
| 270 | - } | ||
| 271 | - } | ||
| 272 | - } | ||
| 273 | - } catch (Exception e) { | ||
| 274 | - result.append("failure"); | ||
| 275 | - logger.error("setXLByInUse:",e); | ||
| 276 | - e.printStackTrace(); | ||
| 277 | - } | ||
| 278 | - return result.toString(); | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - /** | ||
| 282 | - * 上传车辆信息 | ||
| 283 | - */ | ||
| 284 | - @Override | ||
| 285 | - public String setCL() { | ||
| 286 | - String result = "failure"; | ||
| 287 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 288 | - try { | ||
| 289 | - sBuffer.append("<CLs>"); | ||
| 290 | - Cars cars = null; | ||
| 291 | - String company; | ||
| 292 | - Iterator<Cars> carsIterator = carsRepository.findAll().iterator(); | ||
| 293 | - while(carsIterator.hasNext()){ | ||
| 294 | - cars = carsIterator.next(); | ||
| 295 | - sBuffer.append("<CL>"); | ||
| 296 | - company = cars.getCompany(); | ||
| 297 | - setCompanyName(company);// 统一公司名称 | ||
| 298 | - sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | ||
| 299 | - sBuffer.append("<NBH>").append(cars.getInsideCode()).append("</NBH>"); | ||
| 300 | - sBuffer.append("<CPH>").append(cars.getCarPlate()).append("</CPH>"); | ||
| 301 | - sBuffer.append("<YYZBH>").append(cars.getServiceNo()).append("</YYZBH>"); | ||
| 302 | - sBuffer.append("<CZCPH>").append(cars.getCarPlate()).append("</CZCPH>");//******这个数据没有*********** | ||
| 303 | - sBuffer.append("<CZZDBH>").append(cars.getEquipmentCode()).append("</CZZDBH>"); | ||
| 304 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 305 | - sBuffer.append("</CL>"); | ||
| 306 | - } | ||
| 307 | - sBuffer.append("</CLs>"); | ||
| 308 | - if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 309 | - result = "success"; | ||
| 310 | - } | ||
| 311 | - } catch (Exception e) { | ||
| 312 | - logger.error("setCL:",e); | ||
| 313 | - e.printStackTrace(); | ||
| 314 | - }finally{ | ||
| 315 | - logger.info("setCL:"+sBuffer.toString()); | ||
| 316 | - logger.info("setCL:"+result); | ||
| 317 | - } | ||
| 318 | - return result; | ||
| 319 | - } | ||
| 320 | - | ||
| 321 | - /** | ||
| 322 | - * 上传司机信息 | ||
| 323 | - */ | ||
| 324 | - @Override | ||
| 325 | - public String setSJ() { | ||
| 326 | - String result = "failure"; | ||
| 327 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 328 | - try { | ||
| 329 | - sBuffer.append("<SJs>"); | ||
| 330 | - Personnel personnel = null; | ||
| 331 | - String company; | ||
| 332 | - Iterator<Personnel> personIterator = personnelRepository.findAll().iterator(); | ||
| 333 | - while(personIterator.hasNext()){ | ||
| 334 | - personnel = personIterator.next(); | ||
| 335 | - sBuffer.append("<SJ>"); | ||
| 336 | - company = personnel.getCompany(); | ||
| 337 | - setCompanyName(company);// 统一公司名称 | ||
| 338 | - sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | ||
| 339 | - sBuffer.append("<SJGH>").append(personnel.getJobCode()).append("</SJGH>"); | ||
| 340 | - sBuffer.append("<CYZGZH>").append(personnel.getPapersCode()).append("</CYZGZH>");//*********** | ||
| 341 | - sBuffer.append("<XM>").append(personnel.getPersonnelName()).append("</XM>"); | ||
| 342 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 343 | - sBuffer.append("</SJ>"); | ||
| 344 | - } | ||
| 345 | - sBuffer.append("</SJs>"); | ||
| 346 | - if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 347 | - result = "success"; | ||
| 348 | - }; | ||
| 349 | - } catch (Exception e) { | ||
| 350 | - logger.error("setSJ:",e); | ||
| 351 | - e.printStackTrace(); | ||
| 352 | - }finally{ | ||
| 353 | - logger.info("setSJ:"+sBuffer.toString()); | ||
| 354 | - logger.info("setSJ:"+result); | ||
| 355 | - } | ||
| 356 | - return result; | ||
| 357 | - } | ||
| 358 | - | ||
| 359 | - /** | ||
| 360 | - * 上传路单 指定日期 yyyy-MM-dd | ||
| 361 | - * @param theDate | ||
| 362 | - * @return | ||
| 363 | - */ | ||
| 364 | - public String setLD(String theDate){ | ||
| 365 | - return uploadLD(theDate); | ||
| 366 | - } | ||
| 367 | - | ||
| 368 | - /** | ||
| 369 | - * 上传路单 上传前一天的路单 | ||
| 370 | - * @return | ||
| 371 | - */ | ||
| 372 | - public String setLD(){ | ||
| 373 | - return uploadLD(null); | ||
| 374 | - } | ||
| 375 | - /** | ||
| 376 | - * 上传路单 | ||
| 377 | - * @return 上传成功标识 | ||
| 378 | - */ | ||
| 379 | - private String uploadLD(String theDate){ | ||
| 380 | - String result = "failure"; | ||
| 381 | - countSuccess = 0 ;countFailure = 0; | ||
| 382 | - Line line; | ||
| 383 | - // 取昨天 的日期 | ||
| 384 | - String date = theDate == null ?sdfnyr.format(DateUtils.addDays(new Date(), -1)) : theDate; | ||
| 385 | - StringBuffer sf = new StringBuffer(); | ||
| 386 | - StringBuffer logSuccess = new StringBuffer("成功:"); | ||
| 387 | - StringBuffer logFailure = new StringBuffer("失败:"); | ||
| 388 | - HashMap logXlbmSuccessMap = new HashMap(); | ||
| 389 | - HashMap logXlbmFailureMap = new HashMap(); | ||
| 390 | - HashMap logXlbmMap = new HashMap(); | ||
| 391 | - Results results = null; | ||
| 392 | - String str = "",xlbm; | ||
| 393 | - // 保存线路(运管处日志用) | ||
| 394 | - Map<String , Line> logLineMap = null; | ||
| 395 | - try { | ||
| 396 | - int counter = 0; // 计数器 | ||
| 397 | - int per = 10; // 每几条线路上传一次路单 | ||
| 398 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | ||
| 399 | - List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLDGroup(date); | ||
| 400 | - Map<String,Object> map = new HashMap(); | ||
| 401 | - HashMap<String,String> paramMap; | ||
| 402 | - HashMap<String,String> otherMap = new HashMap(); | ||
| 403 | - for(Map<String,Object> schRealInfo:listGroup){ | ||
| 404 | - if(schRealInfo != null){ | ||
| 405 | - //根据车辆自编号查询车牌号 | ||
| 406 | - map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | ||
| 407 | - Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | ||
| 408 | - // 获取线路是否使用标识,如果未使用,则不查该线路数据 | ||
| 409 | - line = lineRepository.findByLineCode(schRealInfo.get("xlBm")+""); | ||
| 410 | - if(line == null || line.getInUse() == null || line.getInUse() == 0){ | ||
| 411 | - continue; | ||
| 412 | - } | ||
| 413 | - if(counter % per == 0){ | ||
| 414 | - sf = new StringBuffer(); | ||
| 415 | - sf.append("<DLDS>"); | ||
| 416 | - logLineMap = new HashMap<>(); | ||
| 417 | - } | ||
| 418 | - counter ++; | ||
| 419 | - xlbm = BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm")+""); | ||
| 420 | - // 保存一线次路单的路编码,用于发送邮箱 | ||
| 421 | - if(xlbm != null && !xlbm.equals("null") && logXlbmMap.get(xlbm) == null){ | ||
| 422 | - logXlbmMap.put(xlbm,xlbm); | ||
| 423 | - } | ||
| 424 | - logLineMap.put(line.getLineCode(),line); | ||
| 425 | - sf.append("<DLD>"); | ||
| 426 | - sf.append("<RQ>"+date+"</RQ>"); | ||
| 427 | - sf.append("<XLBM>"+xlbm+"</XLBM>"); | ||
| 428 | - sf.append("<LPBH>"+schRealInfo.get("lpName")+"</LPBH>"); | ||
| 429 | - sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | ||
| 430 | - sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | ||
| 431 | - sf.append("<LDList>"); | ||
| 432 | - for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 433 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("lpName")+"") | ||
| 434 | - .equals(scheduleRealInfo.getLpName()) | ||
| 435 | - && (schRealInfo.get("clZbh")+"").equals(scheduleRealInfo.getClZbh())){ | ||
| 436 | - | ||
| 437 | - if(scheduleRealInfo.isDestroy()){ | ||
| 438 | - if(scheduleRealInfo.isReissue()){ | ||
| 439 | - scheduleRealInfo.setFcsjActualAll(scheduleRealInfo.getDfsj()); | ||
| 440 | - scheduleRealInfo.setZdsjActualAll(scheduleRealInfo.getZdsj()); | ||
| 441 | - } | ||
| 442 | - else | ||
| 443 | - continue; | ||
| 444 | - } | ||
| 445 | - | ||
| 446 | - if(scheduleRealInfo.getBcType().equals("in") | ||
| 447 | - || scheduleRealInfo.getBcType().equals("out")){ | ||
| 448 | - continue; | ||
| 449 | - } | ||
| 450 | - | ||
| 451 | - sf.append("<LD>"); | ||
| 452 | - sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>"); | ||
| 453 | - sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>"); | ||
| 454 | - sf.append("<FCZDMC>"+scheduleRealInfo.getQdzName()+"</FCZDMC>"); | ||
| 455 | - // 起点站的参数 | ||
| 456 | - otherMap.put("stationMark","B"); | ||
| 457 | - paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | ||
| 458 | - sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) + "</FCZDXH>"); | ||
| 459 | - sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); | ||
| 460 | - sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); | ||
| 461 | - sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); | ||
| 462 | - sf.append("<SJFCSJ>"+scheduleRealInfo.getFcsjActual()+"</SJFCSJ>"); | ||
| 463 | - sf.append("<FCZDLX>"+""+"</FCZDLX>"); | ||
| 464 | - sf.append("<DDZDMC>"+scheduleRealInfo.getZdzName()+"</DDZDMC>"); | ||
| 465 | - // 终点站的参数 | ||
| 466 | - otherMap.put("stationMark","E"); | ||
| 467 | - paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | ||
| 468 | - sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) +"</DDZDXH>"); | ||
| 469 | - sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); | ||
| 470 | - sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); | ||
| 471 | - sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); | ||
| 472 | - sf.append("<DDZDLX>"+""+"</DDZDLX>"); | ||
| 473 | - sf.append("<LDSCBZ>"+0+"</LDSCBZ>"); | ||
| 474 | - sf.append("<DDBZ>"+scheduleRealInfo.getRemarks()+"</DDBZ>"); | ||
| 475 | - sf.append("</LD>"); | ||
| 476 | - } | ||
| 477 | - } | ||
| 478 | - sf.append("</LDList>"); | ||
| 479 | - sf.append("</DLD>"); | ||
| 480 | - } | ||
| 481 | - if(counter % per == per - 1){ | ||
| 482 | - counter = 0; | ||
| 483 | - sf.append("</DLDS>"); | ||
| 484 | - str = sf.toString().replace("'","");// 去掉'号 | ||
| 485 | - results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str)); | ||
| 486 | - try { | ||
| 487 | - // 记录日志 | ||
| 488 | - result = logRecord(results,logXlbmMap,logXlbmSuccessMap,logXlbmFailureMap,logSuccess,logFailure,str,logLineMap); | ||
| 489 | - }catch (Exception e){ | ||
| 490 | - logger.error("logRecord:",e); | ||
| 491 | - continue; | ||
| 492 | - } | ||
| 493 | - } | ||
| 494 | - } | ||
| 495 | - // 每per条线路上传后剩下的数据再上传 | ||
| 496 | - if(counter > 0){ | ||
| 497 | - sf.append("</DLDS>"); | ||
| 498 | - str = sf.toString().replace("'","");// 去掉'号 | ||
| 499 | - results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str)); | ||
| 500 | - try { | ||
| 501 | - // 记录日志 | ||
| 502 | - result = logRecord(results, logXlbmMap, logXlbmSuccessMap, logXlbmFailureMap, logSuccess, logFailure, str, logLineMap); | ||
| 503 | - }catch (Exception e){ | ||
| 504 | - logger.error("logRecord:",e); | ||
| 505 | - } | ||
| 506 | - } | ||
| 507 | - } catch (Exception e) { | ||
| 508 | - logger.error("setLD:",e); | ||
| 509 | - logFailure.append(e).append("<br/>"); | ||
| 510 | - for (StackTraceElement traceElement : e.getStackTrace()){ | ||
| 511 | - logFailure.append("\r\t").append(traceElement); | ||
| 512 | - } | ||
| 513 | - e.printStackTrace(); | ||
| 514 | - }finally{ | ||
| 515 | - try { | ||
| 516 | - //发送邮件 | ||
| 517 | - EmailBean mail = new EmailBean(); | ||
| 518 | - mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date); | ||
| 519 | - mail.setContent("成功数:"+countSuccess+"<br/>失败数:"+countFailure+"<br/>" +logSuccess + "<br/>"+logFailure); | ||
| 520 | - sendEmailController.sendMail(emailSendToAddress, mail); | ||
| 521 | - logger.info("setLD-sendMail:邮件发送成功!"); | ||
| 522 | - }catch (Exception e){ | ||
| 523 | - e.printStackTrace(); | ||
| 524 | - logger.error("setLD-sendMail:",e); | ||
| 525 | - } | ||
| 526 | - } | ||
| 527 | - return result; | ||
| 528 | - } | ||
| 529 | - | ||
| 530 | - /** | ||
| 531 | - * 记录日志 | ||
| 532 | - * @param results | ||
| 533 | - * @param logXlbmMap | ||
| 534 | - * @param logXlbmSuccessMap | ||
| 535 | - * @param logXlbmFailureMap | ||
| 536 | - * @param logSuccess | ||
| 537 | - * @param logFailure | ||
| 538 | - * @param str | ||
| 539 | - */ | ||
| 540 | - private String logRecord(Results results,HashMap logXlbmMap,HashMap logXlbmSuccessMap,HashMap logXlbmFailureMap,StringBuffer logSuccess, | ||
| 541 | - StringBuffer logFailure,String str,Map<String ,Line> logLineMap) throws Exception{ | ||
| 542 | - String result = "failure"; | ||
| 543 | - String state; | ||
| 544 | - // 记录日志 | ||
| 545 | - if(results != null){ | ||
| 546 | - if(results.isSuccess()){// 上传成功 | ||
| 547 | - // 把上线成功的线路编码放入 logXlbmSuccessMap,并记录logSuccess | ||
| 548 | - countSuccess += fillMailXlbmMap(logXlbmMap,logXlbmSuccessMap,logSuccess); | ||
| 549 | - result = "success"; | ||
| 550 | - state = "1"; | ||
| 551 | - }else{// 上传失败 | ||
| 552 | - // 把上线失败的线路编码放入 logXlbmFailureMap,并记录logFailure | ||
| 553 | - countFailure += fillMailXlbmMap(logXlbmMap,logXlbmFailureMap,logFailure); | ||
| 554 | - result = "failure"; | ||
| 555 | - state = "0"; | ||
| 556 | - } | ||
| 557 | - logger.info("setLD:"+str); | ||
| 558 | - logger.info("setLD:"+result); | ||
| 559 | - // 保存运管处上传记录 | ||
| 560 | - saveYgcUploadLog(logLineMap,str,TrafficManageServiceImpl.UPLOAD_TYPE_LD,state); | ||
| 561 | - results = null; | ||
| 562 | - logXlbmMap = new HashMap(); | ||
| 563 | - } | ||
| 564 | - return result; | ||
| 565 | - } | ||
| 566 | - /** | ||
| 567 | - * 填充线路编码到相应的map | ||
| 568 | - * @param fromMap | ||
| 569 | - * @param toMap | ||
| 570 | - */ | ||
| 571 | - private int fillMailXlbmMap(HashMap fromMap,HashMap toMap,StringBuffer logStr){ | ||
| 572 | - int tmpCount = 0; | ||
| 573 | - for (Object key : fromMap.keySet()) { | ||
| 574 | - if(toMap.get(key) == null){ | ||
| 575 | - toMap.put(key,fromMap.get(key)); | ||
| 576 | - logStr.append(key).append(","); | ||
| 577 | - tmpCount ++; | ||
| 578 | - } | ||
| 579 | - } | ||
| 580 | - fromMap = new HashMap(); | ||
| 581 | - return tmpCount; | ||
| 582 | - } | ||
| 583 | - /** | ||
| 584 | - * 上传路单 xml来自文件 | ||
| 585 | - * @return 上传成功标识 | ||
| 586 | - */ | ||
| 587 | - public String setLDFile(){ | ||
| 588 | - String result = "failure"; | ||
| 589 | - try { | ||
| 590 | - String tmp = readXmlFromFile("E:/ld.txt"); | ||
| 591 | - Results rss = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(tmp)); | ||
| 592 | - if(rss.isSuccess()){ | ||
| 593 | - result = "success"; | ||
| 594 | - } | ||
| 595 | - } catch (Exception e) { | ||
| 596 | - logger.error("setLD:",e); | ||
| 597 | - e.printStackTrace(); | ||
| 598 | - }finally{ | ||
| 599 | - | ||
| 600 | - } | ||
| 601 | - return result; | ||
| 602 | - } | ||
| 603 | - | ||
| 604 | - /** | ||
| 605 | - * 从文件中读取xml | ||
| 606 | - * @param fileName 例:D:/test.txt | ||
| 607 | - * @return | ||
| 608 | - * @throws Exception | ||
| 609 | - */ | ||
| 610 | - private String readXmlFromFile(String fileName) throws Exception { | ||
| 611 | - StringBuffer sf = new StringBuffer(""); | ||
| 612 | - File file = new File(fileName); | ||
| 613 | - InputStreamReader reader = new InputStreamReader(new FileInputStream(file),"GBK"); | ||
| 614 | - BufferedReader bufferedReader = new BufferedReader(reader); | ||
| 615 | - String lineTxt = ""; | ||
| 616 | - while((lineTxt = bufferedReader.readLine()) != null){ | ||
| 617 | - sf.append(lineTxt); | ||
| 618 | - } | ||
| 619 | - reader.close(); | ||
| 620 | - return sf.toString().replaceAll("\t",""); | ||
| 621 | - } | ||
| 622 | - /** | ||
| 623 | - * 上传里程油耗 | ||
| 624 | - * @return 上传成功标识 | ||
| 625 | - */ | ||
| 626 | - public String setLCYH(){ | ||
| 627 | - String result = "failure"; | ||
| 628 | - // 取昨天 的日期 | ||
| 629 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | ||
| 630 | - StringBuffer sf = new StringBuffer(); | ||
| 631 | - try { | ||
| 632 | - sf.append("<LCYHS>"); | ||
| 633 | - List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | ||
| 634 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | ||
| 635 | - Map<String,Object> map = new HashMap<String,Object>(); | ||
| 636 | - for(Map<String,Object> schRealInfo:listGroup){ | ||
| 637 | - if(schRealInfo != null){ | ||
| 638 | - map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | ||
| 639 | - Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | ||
| 640 | - /** | ||
| 641 | - * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, | ||
| 642 | - * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 | ||
| 643 | - */ | ||
| 644 | - if(car == null){ | ||
| 645 | - continue; | ||
| 646 | - } | ||
| 647 | - //计算总公里和空驶公里,营运公里=总公里-空驶公里 | ||
| 648 | - double totalKilometers = 0,emptyKilometers =0; | ||
| 649 | - sf.append("<LCYH>"); | ||
| 650 | - sf.append("<RQ>"+date+"</RQ>"); | ||
| 651 | - sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | ||
| 652 | - sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | ||
| 653 | - if(list != null && list.size() > 0){ | ||
| 654 | - for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 655 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"") | ||
| 656 | - .equals(scheduleRealInfo.getClZbh())){ | ||
| 657 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 658 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | ||
| 659 | - if(childTaskPlans.isEmpty()){ | ||
| 660 | - if(scheduleRealInfo.getStatus() == 2){ | ||
| 661 | - totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 662 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 663 | - || scheduleRealInfo.getBcType().equals("venting")){ | ||
| 664 | - emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 665 | - } | ||
| 666 | - } | ||
| 667 | - }else{ | ||
| 668 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 669 | - while(it.hasNext()){ | ||
| 670 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 671 | - if(!childTaskPlan.isDestroy()){ | ||
| 672 | - totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | ||
| 673 | - if(childTaskPlan.getMileageType().equals("empty")){ | ||
| 674 | - emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | ||
| 675 | - } | ||
| 676 | - } | ||
| 677 | - } | ||
| 678 | - } | ||
| 679 | - } | ||
| 680 | - } | ||
| 681 | - } | ||
| 682 | - sf.append("<ZLC>"+totalKilometers+"</ZLC>"); | ||
| 683 | - sf.append("<YYLC>"+emptyKilometers+"</YYLC>"); | ||
| 684 | - sf.append("<YH>"+""+"</YH>"); | ||
| 685 | - sf.append("<JZYL>"+""+"</JZYL>"); | ||
| 686 | - sf.append("<DH>"+""+"</DH>"); | ||
| 687 | - sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | ||
| 688 | - sf.append("<BBSCBZ>"+0+"</BBSCBZ>"); | ||
| 689 | - sf.append("</LCYH>"); | ||
| 690 | - } | ||
| 691 | - } | ||
| 692 | - sf.append("</LCYHS>"); | ||
| 693 | - if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ | ||
| 694 | - result = "success"; | ||
| 695 | - } | ||
| 696 | - } catch (Exception e) { | ||
| 697 | - logger.error("setLCYH:",e); | ||
| 698 | - e.printStackTrace(); | ||
| 699 | - }finally{ | ||
| 700 | - logger.info("setLCYH:"+sf.toString()); | ||
| 701 | - logger.info("setLCYH:"+result); | ||
| 702 | - } | ||
| 703 | - return result; | ||
| 704 | - } | ||
| 705 | - | ||
| 706 | - /** | ||
| 707 | - * 上传线路调度日报 | ||
| 708 | - * @return | ||
| 709 | - */ | ||
| 710 | - public String setDDRB(){ | ||
| 711 | - String result = "failure"; | ||
| 712 | - // 取昨天 的日期 | ||
| 713 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | ||
| 714 | - StringBuffer sf = new StringBuffer(); | ||
| 715 | - try { | ||
| 716 | - sf.append("<DDRBS>"); | ||
| 717 | - List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | ||
| 718 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | ||
| 719 | - for(Map<String,Object> schRealInfo:listGroup){ | ||
| 720 | - if(schRealInfo != null){ | ||
| 721 | - double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0; | ||
| 722 | - int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0; | ||
| 723 | - sf.append("<DDRB>"); | ||
| 724 | - sf.append("<RQ>"+date+"</RQ>"); | ||
| 725 | - sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | ||
| 726 | - for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 727 | - if(scheduleRealInfo != null){ | ||
| 728 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm())){ | ||
| 729 | - //计划 | ||
| 730 | - if(!scheduleRealInfo.isSflj()){ | ||
| 731 | - jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 732 | - //计划空驶 | ||
| 733 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){ | ||
| 734 | - jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 735 | - } | ||
| 736 | - //计划早高峰,计划晚高峰 | ||
| 737 | - if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | ||
| 738 | - jhzgfbc++; | ||
| 739 | - } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | ||
| 740 | - jhwgfbc++; | ||
| 741 | - } | ||
| 742 | - } | ||
| 743 | - jhbc++; | ||
| 744 | - | ||
| 745 | - //实际 | ||
| 746 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 747 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | ||
| 748 | - if(childTaskPlans.isEmpty()){ | ||
| 749 | - if(scheduleRealInfo.getStatus() == 2){ | ||
| 750 | - sjbc++; | ||
| 751 | - zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 752 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 753 | - || scheduleRealInfo.getBcType().equals("venting")){ | ||
| 754 | - sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | ||
| 755 | - } | ||
| 756 | - } | ||
| 757 | - }else{ | ||
| 758 | - sjbc++; | ||
| 759 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 760 | - while(it.hasNext()){ | ||
| 761 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 762 | - if(!childTaskPlan.isDestroy()){ | ||
| 763 | - zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | ||
| 764 | - if(childTaskPlan.getMileageType().equals("empty")){ | ||
| 765 | - sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | ||
| 766 | - } | ||
| 767 | - } | ||
| 768 | - } | ||
| 769 | - } | ||
| 770 | - //实际早高峰,计划晚高峰 | ||
| 771 | - if(scheduleRealInfo.getFcsjActual() != null){ | ||
| 772 | - if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | ||
| 773 | - sjzgfbc++; | ||
| 774 | - } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | ||
| 775 | - sjwgfbc++; | ||
| 776 | - } | ||
| 777 | - } | ||
| 778 | - } | ||
| 779 | - } | ||
| 780 | - } | ||
| 781 | - sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>"); | ||
| 782 | - sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>"); | ||
| 783 | - sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>"); | ||
| 784 | - sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>"); | ||
| 785 | - sf.append("<JHBC>"+jhbc+"</JHBC>"); | ||
| 786 | - sf.append("<SJBC>"+sjbc+"</SJBC>"); | ||
| 787 | - sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>"); | ||
| 788 | - sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>"); | ||
| 789 | - sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>"); | ||
| 790 | - sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>"); | ||
| 791 | - sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | ||
| 792 | - sf.append("<RBSCBZ>"+0+"</RBSCBZ>"); | ||
| 793 | - sf.append("</DDRB>"); | ||
| 794 | - } | ||
| 795 | - } | ||
| 796 | - sf.append("</DDRBS>"); | ||
| 797 | - if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ | ||
| 798 | - result = "success"; | ||
| 799 | - } | ||
| 800 | - } catch (Exception e) { | ||
| 801 | - logger.error("setDDRB:",e); | ||
| 802 | - e.printStackTrace(); | ||
| 803 | - }finally{ | ||
| 804 | - logger.info("setDDRB:"+sf.toString()); | ||
| 805 | - logger.info("setDDRB:"+result); | ||
| 806 | - } | ||
| 807 | - return result; | ||
| 808 | - } | ||
| 809 | - | ||
| 810 | - /** | ||
| 811 | - * 上传计划班次 指定日期 yyyy-MM-dd | ||
| 812 | - * @param theDate | ||
| 813 | - * @return | ||
| 814 | - */ | ||
| 815 | - public String setJHBC(String theDate){ | ||
| 816 | - return uploadJHBC(theDate); | ||
| 817 | - } | ||
| 818 | - | ||
| 819 | - /** | ||
| 820 | - * 上传计划班次 | ||
| 821 | - * @return | ||
| 822 | - */ | ||
| 823 | - public String setJHBC(){ | ||
| 824 | - return uploadJHBC(null); | ||
| 825 | - } | ||
| 826 | - /** | ||
| 827 | - * 上传线路计划班次表 | ||
| 828 | - */ | ||
| 829 | - | ||
| 830 | - private String uploadJHBC(String theDate) { | ||
| 831 | - String result = "failure"; | ||
| 832 | - Line line; | ||
| 833 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 834 | - try { | ||
| 835 | - sBuffer.append("<JHBCs>"); | ||
| 836 | - // 声明变量 | ||
| 837 | - SchedulePlanInfo schedulePlanInfo; | ||
| 838 | - String xlbm,zbh = ""; | ||
| 839 | - Long lp = 0L; | ||
| 840 | - // 取得计划班次时间 | ||
| 841 | - String tomorrow = theDate == null ? sdfnyr.format(DateUtils.addDays(new Date(), +1)) : theDate; | ||
| 842 | - // 查询所有班次 | ||
| 843 | - List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); | ||
| 844 | - int j = 0; // 初始化标识 | ||
| 845 | - if(schedulePlanList != null ){ | ||
| 846 | - HashMap<String,String> paramMap; | ||
| 847 | - HashMap<String,String> otherMap = new HashMap<String, String>(); | ||
| 848 | - int size = schedulePlanList.size(); | ||
| 849 | - for (int i = 0; i < size; i++) { | ||
| 850 | - schedulePlanInfo = schedulePlanList.get(i); | ||
| 851 | - xlbm = schedulePlanInfo.getXlBm(); | ||
| 852 | - // 获取线路是否使用标识,如果未使用,则不查该线路数据 | ||
| 853 | - line = lineRepository.findByLineCode(xlbm); | ||
| 854 | - if(line.getInUse() == null || line.getInUse() == 0){ | ||
| 855 | - continue; | ||
| 856 | - } | ||
| 857 | - if(++j == 1){// 第一次,则初始化值 | ||
| 858 | - zbh = schedulePlanInfo.getClZbh(); | ||
| 859 | - lp = schedulePlanInfo.getLp(); | ||
| 860 | - // 拼装XML | ||
| 861 | - assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | ||
| 862 | - } | ||
| 863 | - // 比较是否为同一条线路同一辆车 | ||
| 864 | - if(xlbm.equals(schedulePlanInfo.getXlBm()) | ||
| 865 | - && zbh.equals(schedulePlanInfo.getClZbh()) | ||
| 866 | - && lp == schedulePlanInfo.getLp()){ | ||
| 867 | - if(schedulePlanInfo.getBcType().equals("in") || schedulePlanInfo.getBcType().equals("out")){ | ||
| 868 | - continue; | ||
| 869 | - } | ||
| 870 | - sBuffer.append("<BC>"); | ||
| 871 | - sBuffer.append("<SJGH>").append(schedulePlanInfo.getjGh()).append("</SJGH>"); | ||
| 872 | - sBuffer.append("<SXX>").append(schedulePlanInfo.getXlDir()).append("</SXX>"); | ||
| 873 | - sBuffer.append("<FCZDMC>").append(schedulePlanInfo.getQdzName()).append("</FCZDMC>"); | ||
| 874 | - // 起点站的参数 | ||
| 875 | - otherMap.put("stationMark","B"); | ||
| 876 | - paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | ||
| 877 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | ||
| 878 | - sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); | ||
| 879 | - sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); | ||
| 880 | - // 起点站的参数 | ||
| 881 | - otherMap.put("stationMark","E"); | ||
| 882 | - paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | ||
| 883 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | ||
| 884 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) | ||
| 885 | - .append("</JHDDSJ>"); | ||
| 886 | - sBuffer.append("</BC>"); | ||
| 887 | - if(i == size -1 ){ | ||
| 888 | - sBuffer.append("</BCList>"); | ||
| 889 | - sBuffer.append("</JHBC>"); | ||
| 890 | - } | ||
| 891 | - }else{ | ||
| 892 | - zbh = schedulePlanInfo.getClZbh(); | ||
| 893 | - lp = schedulePlanInfo.getLp(); | ||
| 894 | - sBuffer.append("</BCList>"); | ||
| 895 | - sBuffer.append("</JHBC>"); | ||
| 896 | - // 拼装XML | ||
| 897 | - assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | ||
| 898 | - } | ||
| 899 | - } | ||
| 900 | - } | ||
| 901 | - // 判断XML是否以</BCList>结尾,如果不是,则加上 | ||
| 902 | - String regex = "^*</JHBC>$"; | ||
| 903 | - Pattern p = Pattern.compile(regex); | ||
| 904 | - Matcher m = p.matcher(sBuffer); | ||
| 905 | - boolean isEndWithTrueFlag = false; | ||
| 906 | - while (m.find()) { | ||
| 907 | - isEndWithTrueFlag = true; | ||
| 908 | - } | ||
| 909 | - // 加上缺失的标签 | ||
| 910 | - if(!isEndWithTrueFlag){ | ||
| 911 | - sBuffer.append("</BCList>"); | ||
| 912 | - sBuffer.append("</JHBC>"); | ||
| 913 | - } | ||
| 914 | - sBuffer.append("</JHBCs>"); | ||
| 915 | - if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 916 | - result = "success"; | ||
| 917 | - } | ||
| 918 | - } catch (Exception e) { | ||
| 919 | - logger.error("setJHBC:",e); | ||
| 920 | - e.printStackTrace(); | ||
| 921 | - }finally{ | ||
| 922 | - logger.info("setJHBC:"+sBuffer.toString()); | ||
| 923 | - logger.info("setJHBC:"+result); | ||
| 924 | - } | ||
| 925 | - return result; | ||
| 926 | - } | ||
| 927 | - | ||
| 928 | - /** | ||
| 929 | - * 上传线路班次时刻表数据 | ||
| 930 | - */ | ||
| 931 | - @Override | ||
| 932 | - public String setSKB(String ids) { | ||
| 933 | - String result = "上传失败,"; | ||
| 934 | - StringBuffer sBuffer = new StringBuffer("<SKBs>"); | ||
| 935 | - DecimalFormat df = new DecimalFormat("######0.000"); | ||
| 936 | - Map<String,String> lsStationCode2NameMap = null; | ||
| 937 | - Map<String, Integer> lsStationName2YgcNumber = null; | ||
| 938 | - try { | ||
| 939 | - String[] idArray = ids.split(","); | ||
| 940 | - StringBuffer sBufferA ,sBufferB ,sBufferC ; | ||
| 941 | - double zlc,yylc,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | ||
| 942 | - String bcType,sxx;// 班次类型、上下行 | ||
| 943 | - // 上传的时刻表集合 | ||
| 944 | - List<TTInfo> ttinfoList = new ArrayList<>(); | ||
| 945 | - TTInfo ttInfo; | ||
| 946 | - TTInfoDetail ttInfoDetail; | ||
| 947 | - LineInformation lineInformation; | ||
| 948 | - Iterator<TTInfoDetail> ttInfoDetailIterator; | ||
| 949 | - HashMap<String,Object> param ; | ||
| 950 | - HashMap<String,String> paramMap; | ||
| 951 | - HashMap<String,String> otherMap = new HashMap<>(); | ||
| 952 | - // 线路编码、周几执行、发车站点名称、发车站点序号、到达站点名称、到达站点序号 | ||
| 953 | - String xlbm,zjzx,fczdmc,zdxh,ddzdmc,ddxh; | ||
| 954 | - // 得到时刻表版本号 | ||
| 955 | - int lineVersion; | ||
| 956 | - long ttinfoId; | ||
| 957 | - // 是否输出站点信息 | ||
| 958 | - boolean isLogStation; | ||
| 959 | - for (int i = 0; i < idArray.length; i++) { | ||
| 960 | - ttinfoId = Long.valueOf(idArray[i]); | ||
| 961 | - ttInfo = ttInfoRepository.findOne(ttinfoId); | ||
| 962 | - if(ttInfo == null) | ||
| 963 | - continue; | ||
| 964 | - ttinfoList.add(ttInfo); // 保存时刻表 | ||
| 965 | - // 得到时刻表版本号 | ||
| 966 | - lineVersion = ttInfo.getLineVersion(); | ||
| 967 | - // 查询历史站点路由 | ||
| 968 | - lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion); | ||
| 969 | - // 查询历史站点路由 | ||
| 970 | - lsStationName2YgcNumber = getLsStationRoute(ttInfo.getXl().getLineCode(),lineVersion); | ||
| 971 | - zlc = 0.0f; | ||
| 972 | - yylc = 0.0f; | ||
| 973 | - // 获得时刻表 | ||
| 974 | - param = new HashMap(); | ||
| 975 | - param.put("ttinfo.id_eq", ttInfo.getId()); | ||
| 976 | - ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | ||
| 977 | - new Sort(Direction.ASC, "xlDir")).iterator(); | ||
| 978 | - // 获得lineInformation | ||
| 979 | - param = new HashMap(); | ||
| 980 | - param.put("line.id_eq", ttInfo.getXl().getId()); | ||
| 981 | - lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | ||
| 982 | - // 初始化 | ||
| 983 | - isLogStation = true; | ||
| 984 | - if(ttInfoDetailIterator.hasNext()){ | ||
| 985 | - // 得到线路信息 | ||
| 986 | - Line line = lineRepository.findOne(ttInfo.getXl().getId()); | ||
| 987 | - if(line == null){ | ||
| 988 | - result += "未找到相应的线路信息,请设置线路信息后再上传"; | ||
| 989 | - return result; | ||
| 990 | - } | ||
| 991 | - // 得到上海市线路编码 | ||
| 992 | - xlbm = line.getShanghaiLinecode(); | ||
| 993 | - if("".equals(xlbm) || "null".equals(xlbm)){ | ||
| 994 | - result += "线路编码为空,请设置线路编码后再上传"; | ||
| 995 | - return result; | ||
| 996 | - } | ||
| 997 | - // 拿到周几执行 | ||
| 998 | - zjzx = changeRuleDay(ttInfo.getRule_days()); | ||
| 999 | - if("".equals(zjzx) || "null".equals(zjzx)){ | ||
| 1000 | - result += "时刻表执行时间为空,请设置执行时间后再上传"; | ||
| 1001 | - return result; | ||
| 1002 | - } | ||
| 1003 | - sBuffer.append("<SKB>"); | ||
| 1004 | - sBuffer.append("<XLBM>").append(xlbm).append("</XLBM>"); | ||
| 1005 | - sBufferB = new StringBuffer(); | ||
| 1006 | - sBufferC = new StringBuffer(); | ||
| 1007 | - sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | ||
| 1008 | - // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 | ||
| 1009 | - sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); | ||
| 1010 | - sBufferB.append("<ZJZX>").append(zjzx).append("</ZJZX>"); | ||
| 1011 | - sBufferB.append("<TBYY>").append("").append("</TBYY>"); | ||
| 1012 | - sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1013 | - sBufferB.append("<BCList>"); | ||
| 1014 | - while (ttInfoDetailIterator.hasNext()) { | ||
| 1015 | - ttInfoDetail = ttInfoDetailIterator.next(); | ||
| 1016 | - bcType = ttInfoDetail.getBcType(); | ||
| 1017 | - sxx = ttInfoDetail.getXlDir(); | ||
| 1018 | - // 进出场班次的里程,加入总里程 | ||
| 1019 | - if(bcType.equals("in") || bcType.equals("out")){ | ||
| 1020 | - // 进出班次的计划里程,算空驶里程 | ||
| 1021 | - emptyLc = ttInfoDetail.getJhlc(); | ||
| 1022 | - // 总里程需要加上空驶里程 | ||
| 1023 | - zlc += emptyLc; | ||
| 1024 | - continue; | ||
| 1025 | - } | ||
| 1026 | - // 不是正常班次,不传到运管处 | ||
| 1027 | - if(!bcType.equals("normal")){ | ||
| 1028 | - continue; | ||
| 1029 | - } | ||
| 1030 | - // 如果发车时间格式错误,忽略此条 | ||
| 1031 | - if(changeTimeFormat(ttInfoDetail) == null){ | ||
| 1032 | - continue; | ||
| 1033 | - } | ||
| 1034 | - // 发生站点名称 | ||
| 1035 | - fczdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getQdzCode()); | ||
| 1036 | - if("".equals(fczdmc) || "null".equals(fczdmc)){ | ||
| 1037 | - result += "发车站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1038 | - return result; | ||
| 1039 | - } | ||
| 1040 | - sBufferC.append("<BC>"); | ||
| 1041 | - sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | ||
| 1042 | - sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | ||
| 1043 | - sBufferC.append("<FCZDMC>").append(fczdmc).append("</FCZDMC>"); | ||
| 1044 | - // 起点站的参数 | ||
| 1045 | - otherMap.put("stationMark","B"); | ||
| 1046 | - paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | ||
| 1047 | - if(isLogStation){// 输出起点站信息 | ||
| 1048 | - logger.info("setSKB:"+"起点站信息:"+paramMap); | ||
| 1049 | - } | ||
| 1050 | - // 发车站点序号 | ||
| 1051 | - zdxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | ||
| 1052 | - if("".equals(zdxh) || "null".equals(zdxh) || "0".equals(zdxh)){ | ||
| 1053 | - result += "发车站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1054 | - return result; | ||
| 1055 | - } | ||
| 1056 | - // 到达站点名称 | ||
| 1057 | - ddzdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getZdzCode()); | ||
| 1058 | - if("".equals(ddzdmc) || "null".equals(ddzdmc)){ | ||
| 1059 | - result += "到达站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1060 | - return result; | ||
| 1061 | - } | ||
| 1062 | - sBufferC.append("<ZDXH>").append(zdxh).append("</ZDXH>"); | ||
| 1063 | - sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | ||
| 1064 | - sBufferC.append("<DDZDMC>").append(ddzdmc).append("</DDZDMC>"); | ||
| 1065 | - // 终点站的参数 | ||
| 1066 | - otherMap.put("stationMark","E"); | ||
| 1067 | - paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | ||
| 1068 | - if(isLogStation){// 输出终点站信息 | ||
| 1069 | - logger.info("setSKB:"+"终点站信息:"+paramMap); | ||
| 1070 | - } | ||
| 1071 | - // 到达站点序号 | ||
| 1072 | - ddxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | ||
| 1073 | - if("".equals(ddxh) || "null".equals(ddxh) || "0".equals(ddxh)){ | ||
| 1074 | - result += "到达站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1075 | - return result; | ||
| 1076 | - } | ||
| 1077 | - isLogStation = false; // 一条线路只输出一次,后面的不输出了 | ||
| 1078 | - sBufferC.append("<DDXH>").append(ddxh).append("</DDXH>"); | ||
| 1079 | - sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | ||
| 1080 | - sBufferC.append("</BC>"); | ||
| 1081 | - // 0:上行;1:下行 | ||
| 1082 | - if("0".equals(sxx)){ | ||
| 1083 | - singleLc = lineInformation.getUpMileage(); | ||
| 1084 | - }else{ | ||
| 1085 | - singleLc = lineInformation.getDownMileage(); | ||
| 1086 | - } | ||
| 1087 | - zlc += singleLc ; | ||
| 1088 | - yylc += singleLc; | ||
| 1089 | - } | ||
| 1090 | - sBufferC.append("</BCList>"); | ||
| 1091 | - sBufferC.append("</SKB>"); | ||
| 1092 | - sBufferA = new StringBuffer(); | ||
| 1093 | - sBufferA.append("<JHZLC>").append(df.format(zlc)).append("</JHZLC>"); | ||
| 1094 | - sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>"); | ||
| 1095 | - sBuffer.append(sBufferA).append(sBufferB).append(sBufferC); | ||
| 1096 | - } | ||
| 1097 | - logger.info("setSKB:"+"ttinfoId:"+ttinfoId+";当前站点版本号:"+lineVersion+";查询历史站点路由:"+lsStationCode2NameMap+";查询历史站点编号:"+lsStationName2YgcNumber); | ||
| 1098 | - } | ||
| 1099 | - sBuffer.append("</SKBs>"); | ||
| 1100 | - String state;// 是否上传成功 | ||
| 1101 | - if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 1102 | - result = "上传成功"; | ||
| 1103 | - state = "1"; | ||
| 1104 | - }else{// 上传失败 | ||
| 1105 | - result = "上传失败"; | ||
| 1106 | - state = "0"; | ||
| 1107 | - } | ||
| 1108 | - // 保存运管处上传记录 | ||
| 1109 | - saveYgcUploadLog(ttinfoList,sBuffer.toString(),TrafficManageServiceImpl.UPLOAD_TYPE_SKB,state); | ||
| 1110 | - } catch (Exception e) { | ||
| 1111 | - logger.error("setSKB:", e); | ||
| 1112 | - e.printStackTrace(); | ||
| 1113 | - }finally{ | ||
| 1114 | - logger.info("setSKB:"+sBuffer.toString()); | ||
| 1115 | - logger.info("setSKB:"+result); | ||
| 1116 | - } | ||
| 1117 | - return result; | ||
| 1118 | - } | ||
| 1119 | - | ||
| 1120 | - /** | ||
| 1121 | - * 保存上传运管处的日志 | ||
| 1122 | - * @param obj 参数 | ||
| 1123 | - * @param type 日志类型 | ||
| 1124 | - * @param xml 上传参数 | ||
| 1125 | - */ | ||
| 1126 | - private void saveYgcUploadLog(Object obj,String xml,String type,String state){ | ||
| 1127 | - SKBUploadLogger skbUploadLogger = new SKBUploadLogger(); | ||
| 1128 | - SysUser user; | ||
| 1129 | - // 如果不是人为上传,SysUser则为空,设置上传人员为管理员 | ||
| 1130 | - if(SecurityContextHolder.getContext() == null || SecurityContextHolder.getContext().getAuthentication() == null){ | ||
| 1131 | - user = new SysUser(); | ||
| 1132 | - user.setId(1); | ||
| 1133 | - }else{// 获取上传人员 | ||
| 1134 | - user = SecurityUtils.getCurrentUser(); | ||
| 1135 | - } | ||
| 1136 | - // 最大的字符长度 | ||
| 1137 | - int maxLength = 60000; | ||
| 1138 | - int cutLength = 50000;// 需要截取的字符长度 | ||
| 1139 | - String xml_sub = null; | ||
| 1140 | - skbUploadLogger.setType(type);// 设置类型 | ||
| 1141 | - // 判断xml是否超长,如果超长,则截取 | ||
| 1142 | - if(xml != null && xml.length() > maxLength){ | ||
| 1143 | - int xmlLength = xml.length(); | ||
| 1144 | - int cutCount = xmlLength / cutLength + (xmlLength % cutLength > 0 ? 1 : 0); | ||
| 1145 | - if(cutCount > 2){ | ||
| 1146 | - xml = "由于上传参数内容超长,请查看服务器的系统日志"; | ||
| 1147 | - }else if(cutCount == 2){ | ||
| 1148 | - xml_sub =xml.substring(cutLength); | ||
| 1149 | - xml = xml.substring(0,cutLength); | ||
| 1150 | - }else{ | ||
| 1151 | - // 不做处理 | ||
| 1152 | - } | ||
| 1153 | - } | ||
| 1154 | -// skbUploadLogger.setUploadXml(xml);// 上传的参数 | ||
| 1155 | -// skbUploadLogger.setUploadXmlSub(xml_sub); | ||
| 1156 | - skbUploadLogger.setState(state);// 状态:是否成功 | ||
| 1157 | - skbUploadLogger.setUser(user); | ||
| 1158 | - // 时刻表 | ||
| 1159 | - if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_SKB)){ | ||
| 1160 | - List<TTInfo> ttInfoList = (List<TTInfo>)obj; | ||
| 1161 | - String name = ""; | ||
| 1162 | - Line line = null; | ||
| 1163 | - for(TTInfo ttInfo : ttInfoList){ | ||
| 1164 | - name += ttInfo.getName() + " "; | ||
| 1165 | - line = ttInfo.getXl(); | ||
| 1166 | - } | ||
| 1167 | - skbUploadLogger.setLine(line); | ||
| 1168 | - skbUploadLogger.setUser(user); | ||
| 1169 | - skbUploadLogger.setName(name); | ||
| 1170 | - skbUploadLoggerRepository.save(skbUploadLogger); | ||
| 1171 | - }else{ | ||
| 1172 | - if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_XL)){ | ||
| 1173 | - Line line = (Line) obj; | ||
| 1174 | - String name = line.getName() + "线路停靠站上传"; | ||
| 1175 | - skbUploadLogger.setLine(line); | ||
| 1176 | - skbUploadLogger.setName(name); | ||
| 1177 | - skbUploadLoggerRepository.save(skbUploadLogger); | ||
| 1178 | - }else if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_LD)){ | ||
| 1179 | - Map<String ,Line> logLineMap = (Map<String ,Line> )obj; | ||
| 1180 | - for (String key : logLineMap.keySet()) { | ||
| 1181 | - Line line = logLineMap.get(key); | ||
| 1182 | - String name = line.getName() + "路单上传"; | ||
| 1183 | - skbUploadLogger = new SKBUploadLogger(); | ||
| 1184 | - skbUploadLogger.setType(type);// 设置类型 | ||
| 1185 | -// skbUploadLogger.setUploadXml(xml);// 上传的参数 | ||
| 1186 | -// skbUploadLogger.setUploadXmlSub(xml_sub); | ||
| 1187 | - skbUploadLogger.setState(state);// 状态:是否成功 | ||
| 1188 | - skbUploadLogger.setUser(user); | ||
| 1189 | - skbUploadLogger.setLine(line); | ||
| 1190 | - skbUploadLogger.setName(name); | ||
| 1191 | -// skbUploadLoggerRepository.save(skbUploadLogger); | ||
| 1192 | - } | ||
| 1193 | - } | ||
| 1194 | - } | ||
| 1195 | - } | ||
| 1196 | - /** | ||
| 1197 | - * 上传线路人员车辆配置信息 | ||
| 1198 | - */ | ||
| 1199 | - @Override | ||
| 1200 | - public String setXLPC() { | ||
| 1201 | - String result = "failure"; | ||
| 1202 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 1203 | - try { | ||
| 1204 | - sBuffer.append("<XLPCs>"); | ||
| 1205 | - // 声明变量 | ||
| 1206 | - Line line = null; | ||
| 1207 | - Cars cars = null; | ||
| 1208 | - List<Personnel> personnelList = null; | ||
| 1209 | - List<Cars> carsList = null; | ||
| 1210 | - int totalPersonnel,totalCar ;// 人员数量。车辆数量 | ||
| 1211 | - // 查询所有线路 | ||
| 1212 | - Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | ||
| 1213 | - // 循环查找线路下的信息 | ||
| 1214 | - while(lineIterator.hasNext()){ | ||
| 1215 | - line = lineIterator.next(); | ||
| 1216 | - sBuffer.append("<XLPC>"); | ||
| 1217 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | ||
| 1218 | - // 查询驾驶员数量 | ||
| 1219 | - personnelList = personnelRepository.findJsysByLineId(line.getId()); | ||
| 1220 | - totalPersonnel = personnelList != null ? personnelList.size():0; | ||
| 1221 | - sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>"); | ||
| 1222 | - // 查询售票员人员数量 | ||
| 1223 | - personnelList = personnelRepository.findSpysByLineId(line.getId()); | ||
| 1224 | - totalPersonnel = personnelList != null ? personnelList.size():0; | ||
| 1225 | - sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>"); | ||
| 1226 | - // 查询车辆 | ||
| 1227 | - carsList = carsRepository.findCarsByLineId(line.getId()); | ||
| 1228 | - totalCar = carsList != null ? carsList.size():0; | ||
| 1229 | - sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>"); | ||
| 1230 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1231 | - int carsNum = 0; | ||
| 1232 | - // 取车牌号 | ||
| 1233 | - if(carsList != null){ | ||
| 1234 | - carsNum = carsList.size(); | ||
| 1235 | - sBuffer.append("<CPHList>"); | ||
| 1236 | - for (int i = 0; i < carsNum; i++) { | ||
| 1237 | - cars = carsList.get(i); | ||
| 1238 | - sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>"); | ||
| 1239 | - } | ||
| 1240 | - sBuffer.append("</CPHList>"); | ||
| 1241 | - } | ||
| 1242 | - sBuffer.append("</XLPC>"); | ||
| 1243 | - } | ||
| 1244 | - sBuffer.append("</XLPCs>"); | ||
| 1245 | - if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 1246 | - result = "success"; | ||
| 1247 | - } | ||
| 1248 | - } catch (Exception e) { | ||
| 1249 | - logger.error("setXLPC:",e); | ||
| 1250 | - e.printStackTrace(); | ||
| 1251 | - }finally{ | ||
| 1252 | - logger.info("setXLPC:"+sBuffer.toString()); | ||
| 1253 | - logger.info("setXLPC:"+result); | ||
| 1254 | - } | ||
| 1255 | - return result; | ||
| 1256 | - } | ||
| 1257 | - | ||
| 1258 | - | ||
| 1259 | - /** | ||
| 1260 | - * 上传超速数据 | ||
| 1261 | - */ | ||
| 1262 | - @Override | ||
| 1263 | - public String setCS() { | ||
| 1264 | - String result = "failure"; | ||
| 1265 | - StringBuffer sBuffer =new StringBuffer(); | ||
| 1266 | - sBuffer.append("<CSs>"); | ||
| 1267 | - String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date "; | ||
| 1268 | - Connection conn = null; | ||
| 1269 | - PreparedStatement ps = null; | ||
| 1270 | - ResultSet rs = null; | ||
| 1271 | - // 取昨天 的日期 | ||
| 1272 | - String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | ||
| 1273 | - try { | ||
| 1274 | - conn = DBUtils_MS.getConnection(); | ||
| 1275 | - ps = conn.prepareStatement(sql); | ||
| 1276 | - ps.setString(1, yesterday); | ||
| 1277 | - rs = ps.executeQuery(); | ||
| 1278 | - Float lon, lat; | ||
| 1279 | - String kssk; | ||
| 1280 | - String speed; | ||
| 1281 | - while (rs.next()) { | ||
| 1282 | - kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP")); | ||
| 1283 | - speed = rs.getString("SPEED"); | ||
| 1284 | - // 经纬度 | ||
| 1285 | - lon = rs.getFloat("LON"); | ||
| 1286 | - lat = rs.getFloat("LAT"); | ||
| 1287 | - sBuffer.append("<CS>"); | ||
| 1288 | - sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>"); | ||
| 1289 | - sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");//////// | ||
| 1290 | - sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>"); | ||
| 1291 | - sBuffer.append("<KSSK>").append(kssk).append("</KSSK>"); | ||
| 1292 | - sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>"); | ||
| 1293 | - sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>"); | ||
| 1294 | - sBuffer.append("<KSLD>").append("").append("</KSLD>");//********************** | ||
| 1295 | - sBuffer.append("<JSSK>").append(kssk).append("</JSSK>"); | ||
| 1296 | - sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>"); | ||
| 1297 | - sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>"); | ||
| 1298 | - sBuffer.append("<JSLD>").append("").append("</JSLD>");//********************** | ||
| 1299 | - sBuffer.append("<PJSD>").append(speed).append("</PJSD>"); | ||
| 1300 | - sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>"); | ||
| 1301 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1302 | - sBuffer.append("</CS>"); | ||
| 1303 | - } | ||
| 1304 | - sBuffer.append("</CSs>"); | ||
| 1305 | - if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 1306 | - result = "success"; | ||
| 1307 | - } | ||
| 1308 | - } catch (Exception e) { | ||
| 1309 | - logger.error("setCS:",e); | ||
| 1310 | - e.printStackTrace(); | ||
| 1311 | - } finally { | ||
| 1312 | - logger.info("setCS:"+sBuffer.toString()); | ||
| 1313 | - logger.info("setCS:"+result); | ||
| 1314 | - DBUtils_MS.close(rs, ps, conn); | ||
| 1315 | - } | ||
| 1316 | - return result; | ||
| 1317 | - } | ||
| 1318 | - | ||
| 1319 | - | ||
| 1320 | - /** | ||
| 1321 | - * 下载全量的公交基础数据 | ||
| 1322 | - */ | ||
| 1323 | - public String getDownLoadAllDataFile() { | ||
| 1324 | - String result = "failure"; | ||
| 1325 | - try { | ||
| 1326 | - try { | ||
| 1327 | - if(ygcBasicDataService.download("admin","000000","abc.zip")){ | ||
| 1328 | - result = "success"; | ||
| 1329 | - } | ||
| 1330 | - } catch (Exception e) { | ||
| 1331 | - e.printStackTrace(); | ||
| 1332 | - } | ||
| 1333 | - } catch (Exception e) { | ||
| 1334 | - e.printStackTrace(); | ||
| 1335 | - } | ||
| 1336 | - | ||
| 1337 | - return result; | ||
| 1338 | - } | ||
| 1339 | - | ||
| 1340 | - /** | ||
| 1341 | - * 下载增量的公交基础数据 | ||
| 1342 | - */ | ||
| 1343 | - public String getDownLoadIncreaseDataFile() { | ||
| 1344 | - String result = "success"; | ||
| 1345 | - try { | ||
| 1346 | - //System.out.println(portType.downloadIncreaseDataFile(args0, args1, args2)); | ||
| 1347 | - } catch (Exception e) { | ||
| 1348 | - e.printStackTrace(); | ||
| 1349 | - } | ||
| 1350 | - | ||
| 1351 | - return result; | ||
| 1352 | - } | ||
| 1353 | - | ||
| 1354 | - /** | ||
| 1355 | - * 指定线路查询方式公交基础数据下载 | ||
| 1356 | - */ | ||
| 1357 | - public String getDownLoadWarrantsBusLineStation() { | ||
| 1358 | - String result = "success"; | ||
| 1359 | - try { | ||
| 1360 | - | ||
| 1361 | - //portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | ||
| 1362 | - } catch (Exception e) { | ||
| 1363 | - e.printStackTrace(); | ||
| 1364 | - } | ||
| 1365 | - | ||
| 1366 | - return result; | ||
| 1367 | - } | ||
| 1368 | - | ||
| 1369 | - /** | ||
| 1370 | - * 计算结束时间 | ||
| 1371 | - * @param fcsj 发车时间 | ||
| 1372 | - * @param bcsj 班次历时 | ||
| 1373 | - * @return | ||
| 1374 | - */ | ||
| 1375 | - private String calcDdsj(String fcsj,Integer bcsj){ | ||
| 1376 | - String result = ""; | ||
| 1377 | - if(fcsj.indexOf(":") != -1){ | ||
| 1378 | - if(bcsj == null){ | ||
| 1379 | - return fcsj; | ||
| 1380 | - } | ||
| 1381 | - // 时和分隔开 | ||
| 1382 | - String[] fcsjArray = fcsj.split(":"); | ||
| 1383 | - // 分和历时时间相加 | ||
| 1384 | - Integer fullTime = Integer.valueOf(fcsjArray[1])+ bcsj; | ||
| 1385 | - int hour,min,sumHour; | ||
| 1386 | - hour = fullTime / 60; | ||
| 1387 | - min = fullTime % 60; | ||
| 1388 | - sumHour = Integer.valueOf(fcsjArray[0])+hour; | ||
| 1389 | - if(sumHour >= 24){ | ||
| 1390 | - result = String.format("%02d",sumHour - 24); | ||
| 1391 | - }else{ | ||
| 1392 | - result = String.format("%02d",sumHour);; | ||
| 1393 | - } | ||
| 1394 | - result +=":"+String.format("%02d", min); | ||
| 1395 | - }else{ | ||
| 1396 | - result = fcsj; | ||
| 1397 | - } | ||
| 1398 | - return result; | ||
| 1399 | - } | ||
| 1400 | - | ||
| 1401 | - /** | ||
| 1402 | - * 改变时间格式 | ||
| 1403 | - * @param ttInfoDetail 时刻表详细 | ||
| 1404 | - * @return xx:yy | ||
| 1405 | - */ | ||
| 1406 | - private String changeTimeFormat(TTInfoDetail ttInfoDetail){ | ||
| 1407 | - String result = "00:00"; | ||
| 1408 | - String fcsj = ttInfoDetail.getFcsj(); | ||
| 1409 | - if(fcsj.indexOf(":") != -1){ | ||
| 1410 | - // 时和分隔开 | ||
| 1411 | - String[] fcsjArray = fcsj.split(":"); | ||
| 1412 | - result = String.format("%02d", Integer.valueOf(fcsjArray[0]))+":"; | ||
| 1413 | - result +=String.format("%02d", Integer.valueOf(fcsjArray[1])); | ||
| 1414 | - }else{ | ||
| 1415 | - result = null; | ||
| 1416 | - logger.info("setSKB:发车时间错误:ttInfoDetail.id="+ttInfoDetail.getId()); | ||
| 1417 | - } | ||
| 1418 | - return result; | ||
| 1419 | - } | ||
| 1420 | - | ||
| 1421 | - /** | ||
| 1422 | - * 拼装线路计划班次表的XML | ||
| 1423 | - * @param sBuffer | ||
| 1424 | - * @param schedulePlanInfo | ||
| 1425 | - * @param xlbm | ||
| 1426 | - * @param zbh | ||
| 1427 | - * @param lp | ||
| 1428 | - */ | ||
| 1429 | - private void assembleJHBC(StringBuffer sBuffer,SchedulePlanInfo schedulePlanInfo,String xlbm,String zbh,Long lp){ | ||
| 1430 | - sBuffer.append("<JHBC>"); | ||
| 1431 | - sBuffer.append("<RQ>").append(sdfnyr.format(schedulePlanInfo.getScheduleDate())).append("</RQ>"); | ||
| 1432 | - sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(xlbm)).append("</XLBM>"); | ||
| 1433 | - sBuffer.append("<CPH>").append("沪"+zbh).append("</CPH>"); | ||
| 1434 | - sBuffer.append("<LPBH>").append(lp).append("</LPBH>"); | ||
| 1435 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1436 | - sBuffer.append("<BCList>"); | ||
| 1437 | - } | ||
| 1438 | - /** | ||
| 1439 | - * 转换排班规则 | ||
| 1440 | - * @param ruleDay | ||
| 1441 | - * @return | ||
| 1442 | - */ | ||
| 1443 | - private String changeRuleDay(String ruleDay){ | ||
| 1444 | - String result = ""; | ||
| 1445 | - int flag ; | ||
| 1446 | - String[] ruleDayArray = ruleDay.split(","); | ||
| 1447 | - for (int i = 0; i < ruleDayArray.length; i++) { | ||
| 1448 | - if(ruleDayArray[i].equals("1")){ | ||
| 1449 | - flag = i+1; | ||
| 1450 | - }else{ | ||
| 1451 | - flag = 0; | ||
| 1452 | - } | ||
| 1453 | - if(flag > 0){ | ||
| 1454 | - result += flag + ","; | ||
| 1455 | - } | ||
| 1456 | - } | ||
| 1457 | - // 去掉最后一个字符 | ||
| 1458 | - if(StringUtils.endsWith(result,",")){ | ||
| 1459 | - result = StringUtils.removeEnd(result,","); | ||
| 1460 | - } | ||
| 1461 | - return result; | ||
| 1462 | - } | ||
| 1463 | - /** | ||
| 1464 | - * 设置统一的公司名称 | ||
| 1465 | - * @param company | ||
| 1466 | - */ | ||
| 1467 | - private void setCompanyName(String company){ | ||
| 1468 | - if(company.equals("闵行公司")){ | ||
| 1469 | - company = "浦东闵行公交公司"; | ||
| 1470 | - }else if(company.equals("杨高公司")){ | ||
| 1471 | - company = "浦东杨高公交公司"; | ||
| 1472 | - }else if(company.equals("上南公司")){ | ||
| 1473 | - company = "浦东上南公交公司"; | ||
| 1474 | - }else if(company.equals("金高公司")){ | ||
| 1475 | - company = "浦东金高公交公司"; | ||
| 1476 | - }else if(company.equals("南汇公司")){ | ||
| 1477 | - company = "浦东南汇公交公司"; | ||
| 1478 | - }else if(company.equals("青浦公交")){ | ||
| 1479 | - company = "浦东青浦公交公司"; | ||
| 1480 | - } | ||
| 1481 | - } | ||
| 1482 | - /** | ||
| 1483 | - * @param stationsList 站点路由集 | ||
| 1484 | - * @param sBuffer sBuffer | ||
| 1485 | - * @param startId 站点序号起始ID | ||
| 1486 | - * | ||
| 1487 | - * @return 站点序号累加后的ID | ||
| 1488 | - */ | ||
| 1489 | - private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId,Map<String, Integer> stationNumMap){ | ||
| 1490 | - int size = stationsList.size(); | ||
| 1491 | - StationRoute srRoute; | ||
| 1492 | - HashMap<String,String> paraMap; | ||
| 1493 | - String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 | ||
| 1494 | - for (int i = 0; i < size; i++) { | ||
| 1495 | - srRoute = stationsList.get(i); | ||
| 1496 | - zdlx = srRoute.getStationMark(); | ||
| 1497 | - if(zdlx.equals("B")){ | ||
| 1498 | - zdlx = "0"; | ||
| 1499 | - }else if(zdlx.equals("E")){ | ||
| 1500 | - zdlx = "1"; | ||
| 1501 | - }else{ | ||
| 1502 | - zdlx = "2"; | ||
| 1503 | - } | ||
| 1504 | - paraMap = packageYgcStationNumParam(srRoute,null); | ||
| 1505 | - sBuffer.append("<Station>"); | ||
| 1506 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); | ||
| 1507 | - sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); | ||
| 1508 | - sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); | ||
| 1509 | - sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); | ||
| 1510 | - sBuffer.append("<ZDJD>").append(srRoute.getStation().getgLonx()).append("</ZDJD>"); | ||
| 1511 | - sBuffer.append("<ZDWD>").append(srRoute.getStation().getgLaty()).append("</ZDWD>"); | ||
| 1512 | - sBuffer.append("<ZZ>").append(srRoute.getStation().getAddr() == null ? "" : srRoute.getStation().getAddr()).append("</ZZ>"); | ||
| 1513 | - sBuffer.append("<ZDLX>").append(zdlx).append("</ZDLX>"); | ||
| 1514 | - sBuffer.append("<ZJLC>").append(srRoute.getDistances()).append("</ZJLC>"); | ||
| 1515 | - sBuffer.append("</Station>"); | ||
| 1516 | - startId++; | ||
| 1517 | - } | ||
| 1518 | - return startId; | ||
| 1519 | - } | ||
| 1520 | - | ||
| 1521 | - /** | ||
| 1522 | - * @param pointList 站点点位集 | ||
| 1523 | - * @param sBuffer sBuffer | ||
| 1524 | - * @param startId 站点序号起始ID | ||
| 1525 | - * | ||
| 1526 | - * @return 站点序号累加后的ID | ||
| 1527 | - */ | ||
| 1528 | - private int packagStationPointXml(List<Object[]> pointList,StringBuffer sBuffer,int startId){ | ||
| 1529 | - int size = pointList.size(); | ||
| 1530 | - Object[] objs; | ||
| 1531 | - String bsection,dir,section; | ||
| 1532 | - String[] sections ; | ||
| 1533 | - for (int i = 0; i < size; i++) { | ||
| 1534 | - objs = pointList.get(i); | ||
| 1535 | - bsection = objs[0]+""; | ||
| 1536 | - dir = objs[1]+""; | ||
| 1537 | - // 取括号内的内容 | ||
| 1538 | - Pattern pattern = Pattern.compile("(?<=\\()(.+?)(?=\\))"); | ||
| 1539 | - Matcher matcher = pattern.matcher(bsection); | ||
| 1540 | - if(matcher.find()){ | ||
| 1541 | - sections = matcher.group().split(","); | ||
| 1542 | - for (int j = 0 ; j < sections.length ; j ++){ | ||
| 1543 | - section = sections[j]; | ||
| 1544 | - sBuffer.append("<LinePoint>"); | ||
| 1545 | - sBuffer.append("<ZDXH>").append(startId).append("</ZDXH>"); | ||
| 1546 | - sBuffer.append("<SXX>").append(dir).append("</SXX>"); | ||
| 1547 | - sBuffer.append("<ZDJD>").append(section.split(" ")[0]).append("</ZDJD>"); | ||
| 1548 | - sBuffer.append("<ZDWD>").append(section.split(" ")[1]).append("</ZDWD>"); | ||
| 1549 | - sBuffer.append("</LinePoint>"); | ||
| 1550 | - startId++; | ||
| 1551 | - } | ||
| 1552 | - } | ||
| 1553 | - } | ||
| 1554 | - return startId; | ||
| 1555 | - } | ||
| 1556 | - | ||
| 1557 | - /** | ||
| 1558 | - * 获取运管处站点序号 | ||
| 1559 | - * @param map | ||
| 1560 | - * @return 运管处站点序号 | ||
| 1561 | - */ | ||
| 1562 | - private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map,Map<String, Integer> stationNumMap){ | ||
| 1563 | - // 线路编码 | ||
| 1564 | - String lineCode = map.get("lineCode"); | ||
| 1565 | - // 线路走向 0:上行 1:下行 | ||
| 1566 | - String direction = map.get("direction"); | ||
| 1567 | - // 站点编码 | ||
| 1568 | - String stationCode = map.get("stationCode"); | ||
| 1569 | - // 站点类型:B:起点站 Z:中途站 E:终点站 T:停车场 | ||
| 1570 | - String stationMark = map.get("stationMark"); | ||
| 1571 | - String[] marks = null; | ||
| 1572 | - // 起点站,先从起点找,找不到再从中途站找,最后从终点找 | ||
| 1573 | - if(stationMark.equals("B")){ | ||
| 1574 | - marks= new String[]{"B","Z","E"}; | ||
| 1575 | - }else if(stationMark.equals("E")){// 终点站相反 | ||
| 1576 | - marks= new String[]{"E","Z","B"}; | ||
| 1577 | - }else if(stationMark.equals("Z")){ | ||
| 1578 | - marks= new String[]{"Z"}; | ||
| 1579 | - } | ||
| 1580 | - // 默认从缓存BasicData.stationName2YgcNumber | ||
| 1581 | - Map<String, Integer> tempMap = BasicData.stationName2YgcNumber; | ||
| 1582 | - // 如果传入的stationNumMap不为空,则不是缓存取,而从stationNumMap取 | ||
| 1583 | - if(stationNumMap != null){ | ||
| 1584 | - tempMap = stationNumMap; | ||
| 1585 | - } | ||
| 1586 | - Integer number = null; | ||
| 1587 | - for (int i = 0 ;i < marks.length ; i ++){ | ||
| 1588 | - number = tempMap.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | ||
| 1589 | - if(number != null){ | ||
| 1590 | - break; | ||
| 1591 | - } | ||
| 1592 | - } | ||
| 1593 | - return number == null ? 0 : number; | ||
| 1594 | - } | ||
| 1595 | - | ||
| 1596 | - /** | ||
| 1597 | - * 封装查询站序条件 | ||
| 1598 | - * @param obj | ||
| 1599 | - * @return | ||
| 1600 | - */ | ||
| 1601 | - private HashMap packageYgcStationNumParam(Object obj,HashMap<String,String> otherParam){ | ||
| 1602 | - HashMap<String,String> map = new HashMap<String,String>(); | ||
| 1603 | - String lineCode = "",direction = "",stationCode = "",stationMark = ""; | ||
| 1604 | - // 站点路由 | ||
| 1605 | - if(obj instanceof StationRoute){ | ||
| 1606 | - StationRoute sr = (StationRoute)obj; | ||
| 1607 | - lineCode = sr.getLineCode(); | ||
| 1608 | - direction = String.valueOf(sr.getDirections()); | ||
| 1609 | - stationCode = sr.getStationCode(); | ||
| 1610 | - stationMark = sr.getStationMark(); | ||
| 1611 | - }else if(obj instanceof ScheduleRealInfo){ //实际排班计划明细。 | ||
| 1612 | - ScheduleRealInfo sri = (ScheduleRealInfo)obj; | ||
| 1613 | - lineCode = sri.getXlBm(); | ||
| 1614 | - direction = sri.getXlDir(); | ||
| 1615 | - if(otherParam != null && otherParam.get("stationMark") != null){ | ||
| 1616 | - stationMark = otherParam.get("stationMark"); | ||
| 1617 | - if(stationMark.equals("B")){ // 起点站 | ||
| 1618 | - stationCode = sri.getQdzCode(); | ||
| 1619 | - }else if(stationMark.equals("E")){ // 终点站 | ||
| 1620 | - stationCode = sri.getZdzCode(); | ||
| 1621 | - } | ||
| 1622 | - } | ||
| 1623 | - }else if(obj instanceof SchedulePlanInfo){ //排班计划明细 | ||
| 1624 | - SchedulePlanInfo spi = (SchedulePlanInfo)obj; | ||
| 1625 | - lineCode = spi.getXlBm(); | ||
| 1626 | - direction = spi.getXlDir(); | ||
| 1627 | - if(otherParam != null && otherParam.get("stationMark") != null){ | ||
| 1628 | - stationMark = otherParam.get("stationMark"); | ||
| 1629 | - if(stationMark.equals("B")){ // 起点站 | ||
| 1630 | - stationCode = spi.getQdzCode(); | ||
| 1631 | - }else if(stationMark.equals("E")){ // 终点站 | ||
| 1632 | - stationCode = spi.getZdzCode(); | ||
| 1633 | - } | ||
| 1634 | - } | ||
| 1635 | - }else if(obj instanceof TTInfoDetail){ //时刻表明细 | ||
| 1636 | - TTInfoDetail ttid = (TTInfoDetail)obj; | ||
| 1637 | - lineCode = ttid.getXl().getLineCode(); | ||
| 1638 | - direction = ttid.getXlDir(); | ||
| 1639 | - if(otherParam != null && otherParam.get("stationMark") != null){ | ||
| 1640 | - stationMark = otherParam.get("stationMark"); | ||
| 1641 | - if(stationMark.equals("B")){ // 起点站 | ||
| 1642 | - stationCode = ttid.getQdzCode(); | ||
| 1643 | - }else if(stationMark.equals("E")){ // 终点站 | ||
| 1644 | - stationCode = ttid.getZdzCode(); | ||
| 1645 | - } | ||
| 1646 | - } | ||
| 1647 | - } | ||
| 1648 | - map.put("lineCode",lineCode);// 站点编码 | ||
| 1649 | - map.put("direction",direction); // 上下行 | ||
| 1650 | - map.put("stationCode",stationCode); // 站点编号 | ||
| 1651 | - map.put("stationMark",stationMark); // 站点类型 | ||
| 1652 | - return map; | ||
| 1653 | - } | ||
| 1654 | - | ||
| 1655 | - /** | ||
| 1656 | - * 取得历史站点编码和站点名称的对应关系 | ||
| 1657 | - * @return | ||
| 1658 | - */ | ||
| 1659 | - private Map<String, String> getLsStationCode(String lineCode,int lineVersion){ | ||
| 1660 | - Map<String,Object> map = new HashMap<>(); | ||
| 1661 | - map.put("lineCode_eq", lineCode); | ||
| 1662 | - map.put("versions_eq",lineVersion); | ||
| 1663 | - LsStationRoute lsroute; | ||
| 1664 | - Iterator<LsStationRoute> iterator = lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map)).iterator(); | ||
| 1665 | - Map<String, String> stationCode2Name = new HashMap<>(); | ||
| 1666 | - while (iterator.hasNext()) { | ||
| 1667 | - lsroute = iterator.next(); | ||
| 1668 | - stationCode2Name.put(lsroute.getLineCode() + "_" + lsroute.getDirections() + "_" + lsroute.getStationCode(), lsroute.getStationName()); | ||
| 1669 | - } | ||
| 1670 | - return stationCode2Name; | ||
| 1671 | - } | ||
| 1672 | - | ||
| 1673 | - private Map<String, Integer> getLsStationRoute(String xlbm,int lineVersion){ | ||
| 1674 | - Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); | ||
| 1675 | - /** | ||
| 1676 | - * 加载运管处的站点及序号 | ||
| 1677 | - * 上行从1开始,下行顺序续编 | ||
| 1678 | - */ | ||
| 1679 | - List<Map<String, String>> ygcLines = lsStationRouteRepository.findLineWithLineCode4Ygc(xlbm,lineVersion); | ||
| 1680 | - if(ygcLines != null && ygcLines.size() > 0){ | ||
| 1681 | - int size = ygcLines.size(); | ||
| 1682 | - Map<String, String> tempMap ; | ||
| 1683 | - int num = 1; | ||
| 1684 | - String key; | ||
| 1685 | - String lineCode = ""; | ||
| 1686 | - for (int i = 0; i < size; i ++){ | ||
| 1687 | - tempMap = ygcLines.get(i); | ||
| 1688 | - if(lineCode.equals("")){ | ||
| 1689 | - lineCode = tempMap.get("lineCode"); | ||
| 1690 | - }else if(!lineCode.equals(tempMap.get("lineCode"))){ | ||
| 1691 | - num = 1; | ||
| 1692 | - lineCode = tempMap.get("lineCode"); | ||
| 1693 | - } | ||
| 1694 | - key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | ||
| 1695 | - + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | ||
| 1696 | - tempStationName2YgcNumber.put(key,num++); | ||
| 1697 | - } | ||
| 1698 | - } | ||
| 1699 | - return tempStationName2YgcNumber; | ||
| 1700 | - } | ||
| 1701 | - | ||
| 1702 | - private String getSetXlXml(Line line,LineInformation lineInformation){ | ||
| 1703 | - StringBuffer sBuffer = new StringBuffer(); | ||
| 1704 | - List<StationRoute> upStationsList ;// 上行站点路由集 | ||
| 1705 | - List<StationRoute> downStationsList;// 下行站点路由集 | ||
| 1706 | - List<Object[]> downPointList;// 下行站点集 | ||
| 1707 | - List<Object[]> upPointList;// 上行站点集 | ||
| 1708 | - sBuffer.append("<XLs>"); | ||
| 1709 | - sBuffer.append("<XL>"); | ||
| 1710 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | ||
| 1711 | - sBuffer.append("<XLMC>").append(line.getName()).append("</XLMC>"); | ||
| 1712 | - sBuffer.append("<QDZ>").append(line.getStartStationName()).append("</QDZ>"); | ||
| 1713 | - sBuffer.append("<ZDZ>").append(line.getEndStationName()).append("</ZDZ>"); | ||
| 1714 | - sBuffer.append("<QZLC>").append(lineInformation.getUpMileage()).append("</QZLC>"); | ||
| 1715 | - sBuffer.append("<ZQLC>").append(lineInformation.getDownMileage()).append("</ZQLC>"); | ||
| 1716 | - sBuffer.append("<XLGH>").append(line.getLinePlayType()).append("</XLGH>"); | ||
| 1717 | - sBuffer.append("<UPDATE_DATE>").append(sdfnyr.format(new Date())).append("</UPDATE_DATE>"); | ||
| 1718 | - // 循环添加站点信息 | ||
| 1719 | - sBuffer.append("<StationList>"); | ||
| 1720 | - // 先查上行 | ||
| 1721 | - upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); | ||
| 1722 | - Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | ||
| 1723 | - int startId = 1; | ||
| 1724 | - startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); | ||
| 1725 | - // 环线不查下行 | ||
| 1726 | - if(line.getLinePlayType() != 1){ | ||
| 1727 | - // 再查下行 | ||
| 1728 | - downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); | ||
| 1729 | - packagStationXml(downStationsList, sBuffer, startId,stationNumMap); | ||
| 1730 | - } | ||
| 1731 | - sBuffer.append("</StationList>"); | ||
| 1732 | - // 循环添加站点点位信息 | ||
| 1733 | - sBuffer.append("<LinePointList>"); | ||
| 1734 | - upPointList = sectionRepository.getSectionDirByLineId(line.getId(),0); | ||
| 1735 | - startId = 1; | ||
| 1736 | - startId = packagStationPointXml(upPointList, sBuffer, startId); | ||
| 1737 | - // 环线不查下行 | ||
| 1738 | - if(line.getLinePlayType() != 1){ | ||
| 1739 | - downPointList = sectionRepository.getSectionDirByLineId(line.getId(),1); | ||
| 1740 | - packagStationPointXml(downPointList, sBuffer, startId); | ||
| 1741 | - } | ||
| 1742 | - sBuffer.append("</LinePointList>"); | ||
| 1743 | - sBuffer.append("</XL>"); | ||
| 1744 | - sBuffer.append("</XLs>"); | ||
| 1745 | - return sBuffer.toString(); | ||
| 1746 | - } | ||
| 1747 | -} | 1 | +package com.bsth.service.impl; |
| 2 | + | ||
| 3 | +import com.bsth.data.BasicData; | ||
| 4 | +import com.bsth.email.SendEmailController; | ||
| 5 | +import com.bsth.email.entity.EmailBean; | ||
| 6 | +import com.bsth.entity.*; | ||
| 7 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | ||
| 8 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 9 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 10 | +import com.bsth.entity.schedule.TTInfo; | ||
| 11 | +import com.bsth.entity.schedule.TTInfoDetail; | ||
| 12 | +import com.bsth.entity.search.CustomerSpecs; | ||
| 13 | +import com.bsth.entity.sys.SysUser; | ||
| 14 | +import com.bsth.entity.traffic.SKBUploadLogger; | ||
| 15 | +import com.bsth.repository.*; | ||
| 16 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 17 | +import com.bsth.repository.schedule.*; | ||
| 18 | +import com.bsth.repository.traffic.SKBUploadLoggerRepository; | ||
| 19 | +import com.bsth.security.util.SecurityUtils; | ||
| 20 | +import com.bsth.service.TrafficManageService; | ||
| 21 | +import com.bsth.service.traffic.YgcBasicDataService; | ||
| 22 | +import com.bsth.util.TimeUtils; | ||
| 23 | +import com.bsth.util.db.DBUtils_MS; | ||
| 24 | +import com.bsth.webService.trafficManage.org.tempuri.Results; | ||
| 25 | +import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; | ||
| 26 | +import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; | ||
| 27 | +import org.apache.commons.lang.StringEscapeUtils; | ||
| 28 | +import org.apache.commons.lang.StringUtils; | ||
| 29 | +import org.apache.commons.lang.time.DateUtils; | ||
| 30 | +import org.slf4j.Logger; | ||
| 31 | +import org.slf4j.LoggerFactory; | ||
| 32 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 33 | +import org.springframework.data.domain.Sort; | ||
| 34 | +import org.springframework.data.domain.Sort.Direction; | ||
| 35 | +import org.springframework.security.core.context.SecurityContextHolder; | ||
| 36 | +import org.springframework.stereotype.Service; | ||
| 37 | + | ||
| 38 | +import java.io.*; | ||
| 39 | +import java.net.InetAddress; | ||
| 40 | +import java.sql.Connection; | ||
| 41 | +import java.sql.PreparedStatement; | ||
| 42 | +import java.sql.ResultSet; | ||
| 43 | +import java.text.DecimalFormat; | ||
| 44 | +import java.text.SimpleDateFormat; | ||
| 45 | +import java.util.*; | ||
| 46 | +import java.util.regex.Matcher; | ||
| 47 | +import java.util.regex.Pattern; | ||
| 48 | + | ||
| 49 | +/** | ||
| 50 | + * | ||
| 51 | + * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) | ||
| 52 | + * | ||
| 53 | + * @Extends : BaseService | ||
| 54 | + * | ||
| 55 | + * @Description: TODO(运管处接口service业务层) | ||
| 56 | + * | ||
| 57 | + * @Author bsth@zq | ||
| 58 | + * | ||
| 59 | + * @Date 2016年10月28日 上午9:21:17 | ||
| 60 | + * | ||
| 61 | + * @Version 公交调度系统BS版 0.1 | ||
| 62 | + * | ||
| 63 | + */ | ||
| 64 | + | ||
| 65 | +@Service | ||
| 66 | +public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 67 | + | ||
| 68 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 69 | + // 运管处上传日志类型 | ||
| 70 | + public static final String UPLOAD_TYPE_SKB = "1"; | ||
| 71 | + public static final String UPLOAD_TYPE_XL = "2"; | ||
| 72 | + public static final String UPLOAD_TYPE_LD = "3"; | ||
| 73 | + | ||
| 74 | + // 线路repository | ||
| 75 | + @Autowired | ||
| 76 | + private LineRepository lineRepository; | ||
| 77 | + | ||
| 78 | + @Autowired | ||
| 79 | + private LineInformationRepository lineInformationRepository; | ||
| 80 | + | ||
| 81 | + // 站点路由repository | ||
| 82 | + @Autowired | ||
| 83 | + private StationRouteRepository stationRouteRepository; | ||
| 84 | + | ||
| 85 | + // 历史站点路由repository | ||
| 86 | + @Autowired | ||
| 87 | + private LsStationRouteRepository lsStationRouteRepository; | ||
| 88 | + | ||
| 89 | + @Autowired | ||
| 90 | + private SectionRepository sectionRepository; | ||
| 91 | + | ||
| 92 | + // 车辆repository | ||
| 93 | + @Autowired | ||
| 94 | + private CarsRepository carsRepository; | ||
| 95 | + | ||
| 96 | + // 人员repository | ||
| 97 | + @Autowired | ||
| 98 | + private PersonnelRepository personnelRepository; | ||
| 99 | + | ||
| 100 | + // 时刻模板repository | ||
| 101 | + @Autowired | ||
| 102 | + private TTInfoRepository ttInfoRepository; | ||
| 103 | + | ||
| 104 | + // 时刻模板明细repository | ||
| 105 | + @Autowired | ||
| 106 | + private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 107 | + | ||
| 108 | + // 排班计划明细repository | ||
| 109 | + @Autowired | ||
| 110 | + private SchedulePlanInfoRepository schedulePlanInfoRepository; | ||
| 111 | + | ||
| 112 | + // 实际排班计划明细repository | ||
| 113 | + @Autowired | ||
| 114 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 115 | + | ||
| 116 | + // 时刻表上传记录repository | ||
| 117 | + @Autowired | ||
| 118 | + private SKBUploadLoggerRepository skbUploadLoggerRepository; | ||
| 119 | + | ||
| 120 | + // 线路站点repository | ||
| 121 | + @Autowired | ||
| 122 | + private YgcBasicDataService ygcBasicDataService; | ||
| 123 | + | ||
| 124 | + // 发送邮件 | ||
| 125 | + @Autowired | ||
| 126 | + private SendEmailController sendEmailController; | ||
| 127 | + | ||
| 128 | + // 运管处上传接口 | ||
| 129 | + private com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap webServiceSoapUp; | ||
| 130 | + private WebServiceSoap ssop ; | ||
| 131 | + { | ||
| 132 | + try { | ||
| 133 | + ssop = new WebServiceLocator().getWebServiceSoap(); | ||
| 134 | + } catch (Exception e) { | ||
| 135 | + e.printStackTrace(); | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母 | ||
| 139 | + private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 140 | + | ||
| 141 | + // 格式化 年月日 | ||
| 142 | + private SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 143 | + | ||
| 144 | + // 数字格式化 | ||
| 145 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 146 | + | ||
| 147 | + // 用户名 | ||
| 148 | + private final String userNameOther = "user"; | ||
| 149 | + // 密码 | ||
| 150 | + private final String passwordOther = "user"; | ||
| 151 | + | ||
| 152 | + // 用户名 | ||
| 153 | + private final String userNameUp = "user"; | ||
| 154 | + // 密码 | ||
| 155 | + private final String passwordUp = "user"; | ||
| 156 | + // 接收邮件人 | ||
| 157 | + private final String emailSendToAddress = "113252620@qq.com"; | ||
| 158 | + // 记录路单上线的成功、失败线路数 | ||
| 159 | + private Integer countSuccess,countFailure; | ||
| 160 | + | ||
| 161 | + private synchronized com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap getWebServiceSoapUp(){ | ||
| 162 | + try { | ||
| 163 | + if(webServiceSoapUp == null){ | ||
| 164 | + webServiceSoapUp = new com.bsth.webService.trafficManage.up.org.tempuri.WebServiceLocator().getWebServiceSoap(); | ||
| 165 | + } | ||
| 166 | + }catch (Exception e){ | ||
| 167 | + e.printStackTrace(); | ||
| 168 | + }finally { | ||
| 169 | + return webServiceSoapUp; | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + /** | ||
| 173 | + * 上传线路信息 | ||
| 174 | + */ | ||
| 175 | + @Override | ||
| 176 | + public String setXL(String ids) { | ||
| 177 | + String result = "failure"; | ||
| 178 | + String xml ; | ||
| 179 | + String[] idArray = ids.split(","); | ||
| 180 | + try { | ||
| 181 | + for (String id : idArray) { | ||
| 182 | + if(id == null || id.trim().equals("")){ | ||
| 183 | + continue; | ||
| 184 | + } | ||
| 185 | + Map<String,Object> map = new HashMap<>(); | ||
| 186 | + map.put("lineCode_eq", id); | ||
| 187 | + Line line ; | ||
| 188 | + LineInformation lineInformation; | ||
| 189 | + line = lineRepository.findOne(new CustomerSpecs<Line>(map)); | ||
| 190 | + if(line == null){ | ||
| 191 | + continue; | ||
| 192 | + } | ||
| 193 | + if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){ | ||
| 194 | + return result; | ||
| 195 | + } | ||
| 196 | + map = new HashMap<>(); | ||
| 197 | + map.put("line.id_eq",line.getId()); | ||
| 198 | + lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(map)); | ||
| 199 | + if(lineInformation == null){ | ||
| 200 | + continue; | ||
| 201 | + } | ||
| 202 | + // 取得封装好的xml | ||
| 203 | + xml = getSetXlXml(line,lineInformation); | ||
| 204 | + // 站点序号不能为0,如果为0,则返回错误 | ||
| 205 | + if(xml.indexOf("<ZDXH>0</ZDXH>") != -1){ | ||
| 206 | + return "0"; | ||
| 207 | + } | ||
| 208 | + String state;// 是否上传成功 | ||
| 209 | + // 调用上传方法 | ||
| 210 | + if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,xml).isSuccess()){ | ||
| 211 | + result = "success"; | ||
| 212 | + state = "1"; | ||
| 213 | + }else{ | ||
| 214 | + result = "failure"; | ||
| 215 | + state = "0"; | ||
| 216 | + } | ||
| 217 | + logger.info("setXL:"+xml); | ||
| 218 | + logger.info("setXL:"+result); | ||
| 219 | + // 保存运管处上传记录 | ||
| 220 | + saveYgcUploadLog(line,xml,TrafficManageServiceImpl.UPLOAD_TYPE_XL,state); | ||
| 221 | + } | ||
| 222 | + } catch (Exception e) { | ||
| 223 | + logger.error("setXL:",e); | ||
| 224 | + e.printStackTrace(); | ||
| 225 | + } | ||
| 226 | + return result; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 230 | + * 加载运管处的站点及序号 | ||
| 231 | + * 上行从1开始,下行顺序续编 | ||
| 232 | + */ | ||
| 233 | + private Map<String, Integer> getStationName2YgcNumberMap (String lineCode){ | ||
| 234 | + Map<String, Integer> resultMap = new HashMap<>(); | ||
| 235 | + List<Map<String, String>> ygcLines = stationRouteRepository.findLineWithYgcByLine(lineCode); | ||
| 236 | + if(ygcLines != null && ygcLines.size() > 0){ | ||
| 237 | + int size = ygcLines.size(); | ||
| 238 | + Map<String, String> tempMap ; | ||
| 239 | + int num = 1; | ||
| 240 | + String key; | ||
| 241 | + for (int i = 0; i < size; i ++){ | ||
| 242 | + tempMap = ygcLines.get(i); | ||
| 243 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | ||
| 244 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | ||
| 245 | + resultMap.put(key,num++); | ||
| 246 | + } | ||
| 247 | + } | ||
| 248 | + return resultMap; | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + /** | ||
| 252 | + * 上传线路信息(按in_use上传) | ||
| 253 | + */ | ||
| 254 | + @Override | ||
| 255 | + public String setXLByInUse(String inUse) { | ||
| 256 | + StringBuffer result = new StringBuffer(); | ||
| 257 | + try { | ||
| 258 | + Map<String,Object> map = new HashMap<>(); | ||
| 259 | + if(inUse != null && inUse.equals("1")){ | ||
| 260 | + map.put("inUse_eq", inUse); | ||
| 261 | + } | ||
| 262 | + List<Line> lines ; | ||
| 263 | + Line line; | ||
| 264 | + lines = lineRepository.findAll(new CustomerSpecs<Line>(map)); | ||
| 265 | + if(lines != null && lines.size() > 0){ | ||
| 266 | + for(int i = 0 ; i < lines.size() ; i ++){ | ||
| 267 | + line = lines.get(i); | ||
| 268 | + if(line != null && line.getId() != null){ | ||
| 269 | + result.append(line.getLineCode()).append(":").append(setXL(line.getLineCode())).append(";"); | ||
| 270 | + } | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | + } catch (Exception e) { | ||
| 274 | + result.append("failure"); | ||
| 275 | + logger.error("setXLByInUse:",e); | ||
| 276 | + e.printStackTrace(); | ||
| 277 | + } | ||
| 278 | + return result.toString(); | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + /** | ||
| 282 | + * 上传车辆信息 | ||
| 283 | + */ | ||
| 284 | + @Override | ||
| 285 | + public String setCL() { | ||
| 286 | + String result = "failure"; | ||
| 287 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 288 | + try { | ||
| 289 | + sBuffer.append("<CLs>"); | ||
| 290 | + Cars cars = null; | ||
| 291 | + String company; | ||
| 292 | + Iterator<Cars> carsIterator = carsRepository.findAll().iterator(); | ||
| 293 | + while(carsIterator.hasNext()){ | ||
| 294 | + cars = carsIterator.next(); | ||
| 295 | + sBuffer.append("<CL>"); | ||
| 296 | + company = cars.getCompany(); | ||
| 297 | + setCompanyName(company);// 统一公司名称 | ||
| 298 | + sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | ||
| 299 | + sBuffer.append("<NBH>").append(cars.getInsideCode()).append("</NBH>"); | ||
| 300 | + sBuffer.append("<CPH>").append(cars.getCarPlate()).append("</CPH>"); | ||
| 301 | + sBuffer.append("<YYZBH>").append(cars.getServiceNo()).append("</YYZBH>"); | ||
| 302 | + sBuffer.append("<CZCPH>").append(cars.getCarPlate()).append("</CZCPH>");//******这个数据没有*********** | ||
| 303 | + sBuffer.append("<CZZDBH>").append(cars.getEquipmentCode()).append("</CZZDBH>"); | ||
| 304 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 305 | + sBuffer.append("</CL>"); | ||
| 306 | + } | ||
| 307 | + sBuffer.append("</CLs>"); | ||
| 308 | + if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 309 | + result = "success"; | ||
| 310 | + } | ||
| 311 | + } catch (Exception e) { | ||
| 312 | + logger.error("setCL:",e); | ||
| 313 | + e.printStackTrace(); | ||
| 314 | + }finally{ | ||
| 315 | + logger.info("setCL:"+sBuffer.toString()); | ||
| 316 | + logger.info("setCL:"+result); | ||
| 317 | + } | ||
| 318 | + return result; | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + /** | ||
| 322 | + * 上传司机信息 | ||
| 323 | + */ | ||
| 324 | + @Override | ||
| 325 | + public String setSJ() { | ||
| 326 | + String result = "failure"; | ||
| 327 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 328 | + try { | ||
| 329 | + sBuffer.append("<SJs>"); | ||
| 330 | + Personnel personnel = null; | ||
| 331 | + String company; | ||
| 332 | + Iterator<Personnel> personIterator = personnelRepository.findAll().iterator(); | ||
| 333 | + while(personIterator.hasNext()){ | ||
| 334 | + personnel = personIterator.next(); | ||
| 335 | + sBuffer.append("<SJ>"); | ||
| 336 | + company = personnel.getCompany(); | ||
| 337 | + setCompanyName(company);// 统一公司名称 | ||
| 338 | + sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | ||
| 339 | + sBuffer.append("<SJGH>").append(personnel.getJobCode()).append("</SJGH>"); | ||
| 340 | + sBuffer.append("<CYZGZH>").append(personnel.getPapersCode()).append("</CYZGZH>");//*********** | ||
| 341 | + sBuffer.append("<XM>").append(personnel.getPersonnelName()).append("</XM>"); | ||
| 342 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 343 | + sBuffer.append("</SJ>"); | ||
| 344 | + } | ||
| 345 | + sBuffer.append("</SJs>"); | ||
| 346 | + if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 347 | + result = "success"; | ||
| 348 | + }; | ||
| 349 | + } catch (Exception e) { | ||
| 350 | + logger.error("setSJ:",e); | ||
| 351 | + e.printStackTrace(); | ||
| 352 | + }finally{ | ||
| 353 | + logger.info("setSJ:"+sBuffer.toString()); | ||
| 354 | + logger.info("setSJ:"+result); | ||
| 355 | + } | ||
| 356 | + return result; | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + /** | ||
| 360 | + * 上传路单 指定日期 yyyy-MM-dd | ||
| 361 | + * @param theDate | ||
| 362 | + * @return | ||
| 363 | + */ | ||
| 364 | + public String setLD(String theDate){ | ||
| 365 | + return uploadLD(theDate); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + /** | ||
| 369 | + * 上传路单 上传前一天的路单 | ||
| 370 | + * @return | ||
| 371 | + */ | ||
| 372 | + public String setLD(){ | ||
| 373 | + return uploadLD(null); | ||
| 374 | + } | ||
| 375 | + /** | ||
| 376 | + * 上传路单 | ||
| 377 | + * @return 上传成功标识 | ||
| 378 | + */ | ||
| 379 | + private String uploadLD(String theDate){ | ||
| 380 | + // 取昨天 的日期 | ||
| 381 | + String date = theDate == null ?sdfnyr.format(DateUtils.addDays(new Date(), -1)) : theDate; | ||
| 382 | + StringBuffer sf = new StringBuffer(); | ||
| 383 | + Results results = null; | ||
| 384 | + String str = "",xlbm; | ||
| 385 | + List<Map<String,Object>> listGroup = null; | ||
| 386 | + int scount = 0, ccount = 0; | ||
| 387 | + long start = System.currentTimeMillis(); | ||
| 388 | + try { | ||
| 389 | + // 计数器 | ||
| 390 | + int counter = 0; | ||
| 391 | + // 每几条线路上传一次路单 | ||
| 392 | + int per = 10; | ||
| 393 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | ||
| 394 | + listGroup = scheduleRealInfoRepository.setLDGroup(date); | ||
| 395 | + Map<String,Object> map = new HashMap(); | ||
| 396 | + HashMap<String,String> paramMap; | ||
| 397 | + HashMap<String,String> otherMap = new HashMap(); | ||
| 398 | + | ||
| 399 | + // 车辆内部编码和车牌做映射 | ||
| 400 | + Map<String, String> inside2plate = new HashMap<>(); | ||
| 401 | + Iterable<Cars> cars = carsRepository.findAll(); | ||
| 402 | + for (Cars car : cars) { | ||
| 403 | + inside2plate.put(car.getInsideCode(), car.getCarPlate()); | ||
| 404 | + } | ||
| 405 | + | ||
| 406 | + // 线路编码和线路信息映射 | ||
| 407 | + Map<String, Line> code2line = new HashMap<>(); | ||
| 408 | + Iterable<Line> lines = lineRepository.findAll(); | ||
| 409 | + for (Line line : lines) { | ||
| 410 | + code2line.put(line.getLineCode(), line); | ||
| 411 | + } | ||
| 412 | + | ||
| 413 | + for(Map<String,Object> schRealInfo:listGroup){ | ||
| 414 | + if(schRealInfo != null){ | ||
| 415 | + // 获取线路是否使用标识,如果未使用,则不查该线路数据 | ||
| 416 | + Line line = code2line.get(schRealInfo.get("xlBm")+""); | ||
| 417 | + if(line == null || line.getInUse() == null || line.getInUse() == 0){ | ||
| 418 | + ccount++; | ||
| 419 | + continue; | ||
| 420 | + } | ||
| 421 | + if(counter % per == 0){ | ||
| 422 | + sf = new StringBuffer(); | ||
| 423 | + sf.append("<DLDS>"); | ||
| 424 | + } | ||
| 425 | + counter ++; | ||
| 426 | + xlbm = BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm")+""); | ||
| 427 | + | ||
| 428 | + sf.append("<DLD>"); | ||
| 429 | + sf.append("<RQ>").append(date).append("</RQ>"); | ||
| 430 | + sf.append("<XLBM>").append(xlbm).append("</XLBM>"); | ||
| 431 | + sf.append("<LPBH>").append(schRealInfo.get("lpName")).append("</LPBH>"); | ||
| 432 | + sf.append("<CPH>").append(inside2plate.get(schRealInfo.get("clZbh"))).append("</CPH>"); | ||
| 433 | + sf.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 434 | + sf.append("<LDList>"); | ||
| 435 | + for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 436 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("lpName")+"") | ||
| 437 | + .equals(scheduleRealInfo.getLpName()) | ||
| 438 | + && (schRealInfo.get("clZbh")+"").equals(scheduleRealInfo.getClZbh())){ | ||
| 439 | + | ||
| 440 | + if(scheduleRealInfo.isDestroy()){ | ||
| 441 | + if(scheduleRealInfo.isReissue()){ | ||
| 442 | + scheduleRealInfo.setFcsjActualAll(scheduleRealInfo.getDfsj()); | ||
| 443 | + scheduleRealInfo.setZdsjActualAll(scheduleRealInfo.getZdsj()); | ||
| 444 | + } | ||
| 445 | + else | ||
| 446 | + continue; | ||
| 447 | + } | ||
| 448 | + | ||
| 449 | + if(scheduleRealInfo.getBcType().equals("in") | ||
| 450 | + || scheduleRealInfo.getBcType().equals("out")){ | ||
| 451 | + continue; | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + sf.append("<LD>"); | ||
| 455 | + sf.append("<SJGH>").append(scheduleRealInfo.getjGh()).append("</SJGH>"); | ||
| 456 | + sf.append("<SXX>").append(scheduleRealInfo.getXlDir()).append("</SXX>"); | ||
| 457 | + sf.append("<FCZDMC>").append(scheduleRealInfo.getQdzName()).append("</FCZDMC>"); | ||
| 458 | + // 起点站的参数 | ||
| 459 | + otherMap.put("stationMark","B"); | ||
| 460 | + paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | ||
| 461 | + sf.append("<FCZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</FCZDXH>"); | ||
| 462 | + sf.append("<FCZDBM>").append(scheduleRealInfo.getQdzCode()).append("</FCZDBM>"); | ||
| 463 | + sf.append("<JHFCSJ>").append(scheduleRealInfo.getFcsj()).append("</JHFCSJ>"); | ||
| 464 | + sf.append("<DFSJ>").append(scheduleRealInfo.getDfsj()).append("</DFSJ>"); | ||
| 465 | + sf.append("<SJFCSJ>").append(scheduleRealInfo.getFcsjActual()).append("</SJFCSJ>"); | ||
| 466 | + sf.append("<FCZDLX></FCZDLX>"); | ||
| 467 | + sf.append("<DDZDMC>").append(scheduleRealInfo.getZdzName()).append("</DDZDMC>"); | ||
| 468 | + // 终点站的参数 | ||
| 469 | + otherMap.put("stationMark","E"); | ||
| 470 | + paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | ||
| 471 | + sf.append("<DDZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDZDXH>"); | ||
| 472 | + sf.append("<DDZDBM>").append(scheduleRealInfo.getZdzCode()).append("</DDZDBM>"); | ||
| 473 | + sf.append("<JHDDSJ>").append(scheduleRealInfo.getZdsj()).append("</JHDDSJ>"); | ||
| 474 | + sf.append("<SJDDSJ>").append(scheduleRealInfo.getZdsjActual()).append("</SJDDSJ>"); | ||
| 475 | + sf.append("<DDZDLX></DDZDLX>"); | ||
| 476 | + sf.append("<LDSCBZ>0</LDSCBZ>"); | ||
| 477 | + sf.append("<DDBZ>").append(scheduleRealInfo.getRemarks()).append("</DDBZ>"); | ||
| 478 | + sf.append("</LD>"); | ||
| 479 | + } | ||
| 480 | + } | ||
| 481 | + sf.append("</LDList>"); | ||
| 482 | + sf.append("</DLD>"); | ||
| 483 | + } | ||
| 484 | + if(counter % per == per - 1){ | ||
| 485 | + sf.append("</DLDS>"); | ||
| 486 | + // 去掉'号 | ||
| 487 | + str = sf.toString().replace("'",""); | ||
| 488 | + scount += invokeSetLD(str, counter); | ||
| 489 | + counter = 0; | ||
| 490 | + } | ||
| 491 | + } | ||
| 492 | + // 每per条线路上传后剩下的数据再上传 | ||
| 493 | + if(counter > 0){ | ||
| 494 | + sf.append("</DLDS>"); | ||
| 495 | + // 去掉'号 | ||
| 496 | + str = sf.toString().replace("'",""); | ||
| 497 | + scount += invokeSetLD(str, counter); | ||
| 498 | + } | ||
| 499 | + } catch (Exception e) { | ||
| 500 | + logger.error("setLD:", e); | ||
| 501 | + } finally { | ||
| 502 | + try { | ||
| 503 | + //发送邮件 | ||
| 504 | + EmailBean mail = new EmailBean(); | ||
| 505 | + mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date); | ||
| 506 | + mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); | ||
| 507 | + sendEmailController.sendMail(emailSendToAddress, mail); | ||
| 508 | + logger.info("setLD-sendMail:邮件发送成功!"); | ||
| 509 | + } catch (Exception e) { | ||
| 510 | + e.printStackTrace(); | ||
| 511 | + logger.error("setLD-sendMail:",e); | ||
| 512 | + } | ||
| 513 | + } | ||
| 514 | + return "success"; | ||
| 515 | + } | ||
| 516 | + | ||
| 517 | + /** | ||
| 518 | + * 调用运管处电子路单接口,如果上传失败或有网络问题,最多执行10次 | ||
| 519 | + * @param xml 拼接的xml字符串 | ||
| 520 | + * @param counter 分组数 | ||
| 521 | + * @return 成功返回counter 失败返回0 | ||
| 522 | + */ | ||
| 523 | + private int invokeSetLD(String xml, int counter) { | ||
| 524 | + for (int i = 0;i < 10;i++) { | ||
| 525 | + try { | ||
| 526 | + Results results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(xml)); | ||
| 527 | + if (results.isSuccess()) { | ||
| 528 | + logger.info("setLD: " + xml); | ||
| 529 | + logger.info("setLD: 成功"); | ||
| 530 | + return counter; | ||
| 531 | + } | ||
| 532 | + Thread.sleep(2000); | ||
| 533 | + } catch (Exception e) { | ||
| 534 | + logger.error("运管处接口调用异常", e); | ||
| 535 | + try { | ||
| 536 | + Thread.sleep(2000); | ||
| 537 | + } catch (InterruptedException ex) { | ||
| 538 | + ex.printStackTrace(); | ||
| 539 | + } | ||
| 540 | + } | ||
| 541 | + } | ||
| 542 | + | ||
| 543 | + return 0; | ||
| 544 | + } | ||
| 545 | + | ||
| 546 | + /** | ||
| 547 | + * 上传路单 xml来自文件 | ||
| 548 | + * @return 上传成功标识 | ||
| 549 | + */ | ||
| 550 | + public String setLDFile(){ | ||
| 551 | + String result = "failure"; | ||
| 552 | + try { | ||
| 553 | + String tmp = readXmlFromFile("E:/ld.txt"); | ||
| 554 | + Results rss = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(tmp)); | ||
| 555 | + if(rss.isSuccess()){ | ||
| 556 | + result = "success"; | ||
| 557 | + } | ||
| 558 | + } catch (Exception e) { | ||
| 559 | + logger.error("setLD:",e); | ||
| 560 | + e.printStackTrace(); | ||
| 561 | + }finally{ | ||
| 562 | + | ||
| 563 | + } | ||
| 564 | + return result; | ||
| 565 | + } | ||
| 566 | + | ||
| 567 | + /** | ||
| 568 | + * 从文件中读取xml | ||
| 569 | + * @param fileName 例:D:/test.txt | ||
| 570 | + * @return | ||
| 571 | + * @throws Exception | ||
| 572 | + */ | ||
| 573 | + private String readXmlFromFile(String fileName) throws Exception { | ||
| 574 | + StringBuffer sf = new StringBuffer(""); | ||
| 575 | + File file = new File(fileName); | ||
| 576 | + InputStreamReader reader = new InputStreamReader(new FileInputStream(file),"GBK"); | ||
| 577 | + BufferedReader bufferedReader = new BufferedReader(reader); | ||
| 578 | + String lineTxt = ""; | ||
| 579 | + while((lineTxt = bufferedReader.readLine()) != null){ | ||
| 580 | + sf.append(lineTxt); | ||
| 581 | + } | ||
| 582 | + reader.close(); | ||
| 583 | + return sf.toString().replaceAll("\t",""); | ||
| 584 | + } | ||
| 585 | + /** | ||
| 586 | + * 上传里程油耗 | ||
| 587 | + * @return 上传成功标识 | ||
| 588 | + */ | ||
| 589 | + public String setLCYH(){ | ||
| 590 | + String result = "failure"; | ||
| 591 | + // 取昨天 的日期 | ||
| 592 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | ||
| 593 | + StringBuffer sf = new StringBuffer(); | ||
| 594 | + try { | ||
| 595 | + sf.append("<LCYHS>"); | ||
| 596 | + List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | ||
| 597 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | ||
| 598 | + Map<String,Object> map = new HashMap<String,Object>(); | ||
| 599 | + for(Map<String,Object> schRealInfo:listGroup){ | ||
| 600 | + if(schRealInfo != null){ | ||
| 601 | + map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | ||
| 602 | + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | ||
| 603 | + /** | ||
| 604 | + * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, | ||
| 605 | + * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 | ||
| 606 | + */ | ||
| 607 | + if(car == null){ | ||
| 608 | + continue; | ||
| 609 | + } | ||
| 610 | + //计算总公里和空驶公里,营运公里=总公里-空驶公里 | ||
| 611 | + double totalKilometers = 0,emptyKilometers =0; | ||
| 612 | + sf.append("<LCYH>"); | ||
| 613 | + sf.append("<RQ>"+date+"</RQ>"); | ||
| 614 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | ||
| 615 | + sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | ||
| 616 | + if(list != null && list.size() > 0){ | ||
| 617 | + for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 618 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"") | ||
| 619 | + .equals(scheduleRealInfo.getClZbh())){ | ||
| 620 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 621 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | ||
| 622 | + if(childTaskPlans.isEmpty()){ | ||
| 623 | + if(scheduleRealInfo.getStatus() == 2){ | ||
| 624 | + totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 625 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 626 | + || scheduleRealInfo.getBcType().equals("venting")){ | ||
| 627 | + emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 628 | + } | ||
| 629 | + } | ||
| 630 | + }else{ | ||
| 631 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 632 | + while(it.hasNext()){ | ||
| 633 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 634 | + if(!childTaskPlan.isDestroy()){ | ||
| 635 | + totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | ||
| 636 | + if(childTaskPlan.getMileageType().equals("empty")){ | ||
| 637 | + emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | ||
| 638 | + } | ||
| 639 | + } | ||
| 640 | + } | ||
| 641 | + } | ||
| 642 | + } | ||
| 643 | + } | ||
| 644 | + } | ||
| 645 | + sf.append("<ZLC>"+totalKilometers+"</ZLC>"); | ||
| 646 | + sf.append("<YYLC>"+emptyKilometers+"</YYLC>"); | ||
| 647 | + sf.append("<YH>"+""+"</YH>"); | ||
| 648 | + sf.append("<JZYL>"+""+"</JZYL>"); | ||
| 649 | + sf.append("<DH>"+""+"</DH>"); | ||
| 650 | + sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | ||
| 651 | + sf.append("<BBSCBZ>"+0+"</BBSCBZ>"); | ||
| 652 | + sf.append("</LCYH>"); | ||
| 653 | + } | ||
| 654 | + } | ||
| 655 | + sf.append("</LCYHS>"); | ||
| 656 | + if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ | ||
| 657 | + result = "success"; | ||
| 658 | + } | ||
| 659 | + } catch (Exception e) { | ||
| 660 | + logger.error("setLCYH:",e); | ||
| 661 | + e.printStackTrace(); | ||
| 662 | + }finally{ | ||
| 663 | + logger.info("setLCYH:"+sf.toString()); | ||
| 664 | + logger.info("setLCYH:"+result); | ||
| 665 | + } | ||
| 666 | + return result; | ||
| 667 | + } | ||
| 668 | + | ||
| 669 | + /** | ||
| 670 | + * 上传线路调度日报 | ||
| 671 | + * @return | ||
| 672 | + */ | ||
| 673 | + public String setDDRB(){ | ||
| 674 | + String result = "failure"; | ||
| 675 | + // 取昨天 的日期 | ||
| 676 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | ||
| 677 | + StringBuffer sf = new StringBuffer(); | ||
| 678 | + try { | ||
| 679 | + sf.append("<DDRBS>"); | ||
| 680 | + List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | ||
| 681 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | ||
| 682 | + for(Map<String,Object> schRealInfo:listGroup){ | ||
| 683 | + if(schRealInfo != null){ | ||
| 684 | + double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0; | ||
| 685 | + int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0; | ||
| 686 | + sf.append("<DDRB>"); | ||
| 687 | + sf.append("<RQ>"+date+"</RQ>"); | ||
| 688 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | ||
| 689 | + for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 690 | + if(scheduleRealInfo != null){ | ||
| 691 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm())){ | ||
| 692 | + //计划 | ||
| 693 | + if(!scheduleRealInfo.isSflj()){ | ||
| 694 | + jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 695 | + //计划空驶 | ||
| 696 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){ | ||
| 697 | + jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 698 | + } | ||
| 699 | + //计划早高峰,计划晚高峰 | ||
| 700 | + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | ||
| 701 | + jhzgfbc++; | ||
| 702 | + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | ||
| 703 | + jhwgfbc++; | ||
| 704 | + } | ||
| 705 | + } | ||
| 706 | + jhbc++; | ||
| 707 | + | ||
| 708 | + //实际 | ||
| 709 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 710 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | ||
| 711 | + if(childTaskPlans.isEmpty()){ | ||
| 712 | + if(scheduleRealInfo.getStatus() == 2){ | ||
| 713 | + sjbc++; | ||
| 714 | + zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 715 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 716 | + || scheduleRealInfo.getBcType().equals("venting")){ | ||
| 717 | + sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | ||
| 718 | + } | ||
| 719 | + } | ||
| 720 | + }else{ | ||
| 721 | + sjbc++; | ||
| 722 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 723 | + while(it.hasNext()){ | ||
| 724 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 725 | + if(!childTaskPlan.isDestroy()){ | ||
| 726 | + zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | ||
| 727 | + if(childTaskPlan.getMileageType().equals("empty")){ | ||
| 728 | + sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | ||
| 729 | + } | ||
| 730 | + } | ||
| 731 | + } | ||
| 732 | + } | ||
| 733 | + //实际早高峰,计划晚高峰 | ||
| 734 | + if(scheduleRealInfo.getFcsjActual() != null){ | ||
| 735 | + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | ||
| 736 | + sjzgfbc++; | ||
| 737 | + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | ||
| 738 | + sjwgfbc++; | ||
| 739 | + } | ||
| 740 | + } | ||
| 741 | + } | ||
| 742 | + } | ||
| 743 | + } | ||
| 744 | + sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>"); | ||
| 745 | + sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>"); | ||
| 746 | + sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>"); | ||
| 747 | + sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>"); | ||
| 748 | + sf.append("<JHBC>"+jhbc+"</JHBC>"); | ||
| 749 | + sf.append("<SJBC>"+sjbc+"</SJBC>"); | ||
| 750 | + sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>"); | ||
| 751 | + sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>"); | ||
| 752 | + sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>"); | ||
| 753 | + sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>"); | ||
| 754 | + sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | ||
| 755 | + sf.append("<RBSCBZ>"+0+"</RBSCBZ>"); | ||
| 756 | + sf.append("</DDRB>"); | ||
| 757 | + } | ||
| 758 | + } | ||
| 759 | + sf.append("</DDRBS>"); | ||
| 760 | + if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ | ||
| 761 | + result = "success"; | ||
| 762 | + } | ||
| 763 | + } catch (Exception e) { | ||
| 764 | + logger.error("setDDRB:",e); | ||
| 765 | + e.printStackTrace(); | ||
| 766 | + }finally{ | ||
| 767 | + logger.info("setDDRB:"+sf.toString()); | ||
| 768 | + logger.info("setDDRB:"+result); | ||
| 769 | + } | ||
| 770 | + return result; | ||
| 771 | + } | ||
| 772 | + | ||
| 773 | + /** | ||
| 774 | + * 上传计划班次 指定日期 yyyy-MM-dd | ||
| 775 | + * @param theDate | ||
| 776 | + * @return | ||
| 777 | + */ | ||
| 778 | + public String setJHBC(String theDate){ | ||
| 779 | + return uploadJHBC(theDate); | ||
| 780 | + } | ||
| 781 | + | ||
| 782 | + /** | ||
| 783 | + * 上传计划班次 | ||
| 784 | + * @return | ||
| 785 | + */ | ||
| 786 | + public String setJHBC(){ | ||
| 787 | + return uploadJHBC(null); | ||
| 788 | + } | ||
| 789 | + /** | ||
| 790 | + * 上传线路计划班次表 | ||
| 791 | + */ | ||
| 792 | + | ||
| 793 | + private String uploadJHBC(String theDate) { | ||
| 794 | + String result = "failure"; | ||
| 795 | + Line line; | ||
| 796 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 797 | + try { | ||
| 798 | + sBuffer.append("<JHBCs>"); | ||
| 799 | + // 声明变量 | ||
| 800 | + SchedulePlanInfo schedulePlanInfo; | ||
| 801 | + String xlbm,zbh = ""; | ||
| 802 | + Long lp = 0L; | ||
| 803 | + // 取得计划班次时间 | ||
| 804 | + String tomorrow = theDate == null ? sdfnyr.format(DateUtils.addDays(new Date(), +1)) : theDate; | ||
| 805 | + // 查询所有班次 | ||
| 806 | + List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); | ||
| 807 | + int j = 0; // 初始化标识 | ||
| 808 | + if(schedulePlanList != null ){ | ||
| 809 | + HashMap<String,String> paramMap; | ||
| 810 | + HashMap<String,String> otherMap = new HashMap<String, String>(); | ||
| 811 | + int size = schedulePlanList.size(); | ||
| 812 | + for (int i = 0; i < size; i++) { | ||
| 813 | + schedulePlanInfo = schedulePlanList.get(i); | ||
| 814 | + xlbm = schedulePlanInfo.getXlBm(); | ||
| 815 | + // 获取线路是否使用标识,如果未使用,则不查该线路数据 | ||
| 816 | + line = lineRepository.findByLineCode(xlbm); | ||
| 817 | + if(line.getInUse() == null || line.getInUse() == 0){ | ||
| 818 | + continue; | ||
| 819 | + } | ||
| 820 | + if(++j == 1){// 第一次,则初始化值 | ||
| 821 | + zbh = schedulePlanInfo.getClZbh(); | ||
| 822 | + lp = schedulePlanInfo.getLp(); | ||
| 823 | + // 拼装XML | ||
| 824 | + assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | ||
| 825 | + } | ||
| 826 | + // 比较是否为同一条线路同一辆车 | ||
| 827 | + if(xlbm.equals(schedulePlanInfo.getXlBm()) | ||
| 828 | + && zbh.equals(schedulePlanInfo.getClZbh()) | ||
| 829 | + && lp == schedulePlanInfo.getLp()){ | ||
| 830 | + if(schedulePlanInfo.getBcType().equals("in") || schedulePlanInfo.getBcType().equals("out")){ | ||
| 831 | + continue; | ||
| 832 | + } | ||
| 833 | + sBuffer.append("<BC>"); | ||
| 834 | + sBuffer.append("<SJGH>").append(schedulePlanInfo.getjGh()).append("</SJGH>"); | ||
| 835 | + sBuffer.append("<SXX>").append(schedulePlanInfo.getXlDir()).append("</SXX>"); | ||
| 836 | + sBuffer.append("<FCZDMC>").append(schedulePlanInfo.getQdzName()).append("</FCZDMC>"); | ||
| 837 | + // 起点站的参数 | ||
| 838 | + otherMap.put("stationMark","B"); | ||
| 839 | + paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | ||
| 840 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | ||
| 841 | + sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); | ||
| 842 | + sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); | ||
| 843 | + // 起点站的参数 | ||
| 844 | + otherMap.put("stationMark","E"); | ||
| 845 | + paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | ||
| 846 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | ||
| 847 | + sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) | ||
| 848 | + .append("</JHDDSJ>"); | ||
| 849 | + sBuffer.append("</BC>"); | ||
| 850 | + if(i == size -1 ){ | ||
| 851 | + sBuffer.append("</BCList>"); | ||
| 852 | + sBuffer.append("</JHBC>"); | ||
| 853 | + } | ||
| 854 | + }else{ | ||
| 855 | + zbh = schedulePlanInfo.getClZbh(); | ||
| 856 | + lp = schedulePlanInfo.getLp(); | ||
| 857 | + sBuffer.append("</BCList>"); | ||
| 858 | + sBuffer.append("</JHBC>"); | ||
| 859 | + // 拼装XML | ||
| 860 | + assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | ||
| 861 | + } | ||
| 862 | + } | ||
| 863 | + } | ||
| 864 | + // 判断XML是否以</BCList>结尾,如果不是,则加上 | ||
| 865 | + String regex = "^*</JHBC>$"; | ||
| 866 | + Pattern p = Pattern.compile(regex); | ||
| 867 | + Matcher m = p.matcher(sBuffer); | ||
| 868 | + boolean isEndWithTrueFlag = false; | ||
| 869 | + while (m.find()) { | ||
| 870 | + isEndWithTrueFlag = true; | ||
| 871 | + } | ||
| 872 | + // 加上缺失的标签 | ||
| 873 | + if(!isEndWithTrueFlag){ | ||
| 874 | + sBuffer.append("</BCList>"); | ||
| 875 | + sBuffer.append("</JHBC>"); | ||
| 876 | + } | ||
| 877 | + sBuffer.append("</JHBCs>"); | ||
| 878 | + if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 879 | + result = "success"; | ||
| 880 | + } | ||
| 881 | + } catch (Exception e) { | ||
| 882 | + logger.error("setJHBC:",e); | ||
| 883 | + e.printStackTrace(); | ||
| 884 | + }finally{ | ||
| 885 | + logger.info("setJHBC:"+sBuffer.toString()); | ||
| 886 | + logger.info("setJHBC:"+result); | ||
| 887 | + } | ||
| 888 | + return result; | ||
| 889 | + } | ||
| 890 | + | ||
| 891 | + /** | ||
| 892 | + * 上传线路班次时刻表数据 | ||
| 893 | + */ | ||
| 894 | + @Override | ||
| 895 | + public String setSKB(String ids) { | ||
| 896 | + String result = "上传失败,"; | ||
| 897 | + StringBuffer sBuffer = new StringBuffer("<SKBs>"); | ||
| 898 | + DecimalFormat df = new DecimalFormat("######0.000"); | ||
| 899 | + Map<String,String> lsStationCode2NameMap = null; | ||
| 900 | + Map<String, Integer> lsStationName2YgcNumber = null; | ||
| 901 | + try { | ||
| 902 | + String[] idArray = ids.split(","); | ||
| 903 | + StringBuffer sBufferA ,sBufferB ,sBufferC ; | ||
| 904 | + double zlc,yylc,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | ||
| 905 | + String bcType,sxx;// 班次类型、上下行 | ||
| 906 | + // 上传的时刻表集合 | ||
| 907 | + List<TTInfo> ttinfoList = new ArrayList<>(); | ||
| 908 | + TTInfo ttInfo; | ||
| 909 | + TTInfoDetail ttInfoDetail; | ||
| 910 | + LineInformation lineInformation; | ||
| 911 | + Iterator<TTInfoDetail> ttInfoDetailIterator; | ||
| 912 | + HashMap<String,Object> param ; | ||
| 913 | + HashMap<String,String> paramMap; | ||
| 914 | + HashMap<String,String> otherMap = new HashMap<>(); | ||
| 915 | + // 线路编码、周几执行、发车站点名称、发车站点序号、到达站点名称、到达站点序号 | ||
| 916 | + String xlbm,zjzx,fczdmc,zdxh,ddzdmc,ddxh; | ||
| 917 | + // 得到时刻表版本号 | ||
| 918 | + int lineVersion; | ||
| 919 | + long ttinfoId; | ||
| 920 | + // 是否输出站点信息 | ||
| 921 | + boolean isLogStation; | ||
| 922 | + for (int i = 0; i < idArray.length; i++) { | ||
| 923 | + ttinfoId = Long.valueOf(idArray[i]); | ||
| 924 | + ttInfo = ttInfoRepository.findOne(ttinfoId); | ||
| 925 | + if(ttInfo == null) | ||
| 926 | + continue; | ||
| 927 | + ttinfoList.add(ttInfo); // 保存时刻表 | ||
| 928 | + // 得到时刻表版本号 | ||
| 929 | + lineVersion = ttInfo.getLineVersion(); | ||
| 930 | + // 查询历史站点路由 | ||
| 931 | + lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion); | ||
| 932 | + // 查询历史站点路由 | ||
| 933 | + lsStationName2YgcNumber = getLsStationRoute(ttInfo.getXl().getLineCode(),lineVersion); | ||
| 934 | + zlc = 0.0f; | ||
| 935 | + yylc = 0.0f; | ||
| 936 | + // 获得时刻表 | ||
| 937 | + param = new HashMap(); | ||
| 938 | + param.put("ttinfo.id_eq", ttInfo.getId()); | ||
| 939 | + ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | ||
| 940 | + new Sort(Direction.ASC, "xlDir")).iterator(); | ||
| 941 | + // 获得lineInformation | ||
| 942 | + param = new HashMap(); | ||
| 943 | + param.put("line.id_eq", ttInfo.getXl().getId()); | ||
| 944 | + lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | ||
| 945 | + // 初始化 | ||
| 946 | + isLogStation = true; | ||
| 947 | + if(ttInfoDetailIterator.hasNext()){ | ||
| 948 | + // 得到线路信息 | ||
| 949 | + Line line = lineRepository.findOne(ttInfo.getXl().getId()); | ||
| 950 | + if(line == null){ | ||
| 951 | + result += "未找到相应的线路信息,请设置线路信息后再上传"; | ||
| 952 | + return result; | ||
| 953 | + } | ||
| 954 | + // 得到上海市线路编码 | ||
| 955 | + xlbm = line.getShanghaiLinecode(); | ||
| 956 | + if("".equals(xlbm) || "null".equals(xlbm)){ | ||
| 957 | + result += "线路编码为空,请设置线路编码后再上传"; | ||
| 958 | + return result; | ||
| 959 | + } | ||
| 960 | + // 拿到周几执行 | ||
| 961 | + zjzx = changeRuleDay(ttInfo.getRule_days()); | ||
| 962 | + if("".equals(zjzx) || "null".equals(zjzx)){ | ||
| 963 | + result += "时刻表执行时间为空,请设置执行时间后再上传"; | ||
| 964 | + return result; | ||
| 965 | + } | ||
| 966 | + sBuffer.append("<SKB>"); | ||
| 967 | + sBuffer.append("<XLBM>").append(xlbm).append("</XLBM>"); | ||
| 968 | + sBufferB = new StringBuffer(); | ||
| 969 | + sBufferC = new StringBuffer(); | ||
| 970 | + sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | ||
| 971 | + // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 | ||
| 972 | + sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); | ||
| 973 | + sBufferB.append("<ZJZX>").append(zjzx).append("</ZJZX>"); | ||
| 974 | + sBufferB.append("<TBYY>").append("").append("</TBYY>"); | ||
| 975 | + sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 976 | + sBufferB.append("<BCList>"); | ||
| 977 | + while (ttInfoDetailIterator.hasNext()) { | ||
| 978 | + ttInfoDetail = ttInfoDetailIterator.next(); | ||
| 979 | + bcType = ttInfoDetail.getBcType(); | ||
| 980 | + sxx = ttInfoDetail.getXlDir(); | ||
| 981 | + // 进出场班次的里程,加入总里程 | ||
| 982 | + if(bcType.equals("in") || bcType.equals("out")){ | ||
| 983 | + // 进出班次的计划里程,算空驶里程 | ||
| 984 | + emptyLc = ttInfoDetail.getJhlc(); | ||
| 985 | + // 总里程需要加上空驶里程 | ||
| 986 | + zlc += emptyLc; | ||
| 987 | + continue; | ||
| 988 | + } | ||
| 989 | + // 不是正常班次,不传到运管处 | ||
| 990 | + if(!bcType.equals("normal")){ | ||
| 991 | + continue; | ||
| 992 | + } | ||
| 993 | + // 如果发车时间格式错误,忽略此条 | ||
| 994 | + if(changeTimeFormat(ttInfoDetail) == null){ | ||
| 995 | + continue; | ||
| 996 | + } | ||
| 997 | + // 发生站点名称 | ||
| 998 | + fczdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getQdzCode()); | ||
| 999 | + if("".equals(fczdmc) || "null".equals(fczdmc)){ | ||
| 1000 | + result += "发车站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1001 | + return result; | ||
| 1002 | + } | ||
| 1003 | + sBufferC.append("<BC>"); | ||
| 1004 | + sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | ||
| 1005 | + sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | ||
| 1006 | + sBufferC.append("<FCZDMC>").append(fczdmc).append("</FCZDMC>"); | ||
| 1007 | + // 起点站的参数 | ||
| 1008 | + otherMap.put("stationMark","B"); | ||
| 1009 | + paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | ||
| 1010 | + if(isLogStation){// 输出起点站信息 | ||
| 1011 | + logger.info("setSKB:"+"起点站信息:"+paramMap); | ||
| 1012 | + } | ||
| 1013 | + // 发车站点序号 | ||
| 1014 | + zdxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | ||
| 1015 | + if("".equals(zdxh) || "null".equals(zdxh) || "0".equals(zdxh)){ | ||
| 1016 | + result += "发车站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1017 | + return result; | ||
| 1018 | + } | ||
| 1019 | + // 到达站点名称 | ||
| 1020 | + ddzdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getZdzCode()); | ||
| 1021 | + if("".equals(ddzdmc) || "null".equals(ddzdmc)){ | ||
| 1022 | + result += "到达站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1023 | + return result; | ||
| 1024 | + } | ||
| 1025 | + sBufferC.append("<ZDXH>").append(zdxh).append("</ZDXH>"); | ||
| 1026 | + sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | ||
| 1027 | + sBufferC.append("<DDZDMC>").append(ddzdmc).append("</DDZDMC>"); | ||
| 1028 | + // 终点站的参数 | ||
| 1029 | + otherMap.put("stationMark","E"); | ||
| 1030 | + paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | ||
| 1031 | + if(isLogStation){// 输出终点站信息 | ||
| 1032 | + logger.info("setSKB:"+"终点站信息:"+paramMap); | ||
| 1033 | + } | ||
| 1034 | + // 到达站点序号 | ||
| 1035 | + ddxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | ||
| 1036 | + if("".equals(ddxh) || "null".equals(ddxh) || "0".equals(ddxh)){ | ||
| 1037 | + result += "到达站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | ||
| 1038 | + return result; | ||
| 1039 | + } | ||
| 1040 | + isLogStation = false; // 一条线路只输出一次,后面的不输出了 | ||
| 1041 | + sBufferC.append("<DDXH>").append(ddxh).append("</DDXH>"); | ||
| 1042 | + sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | ||
| 1043 | + sBufferC.append("</BC>"); | ||
| 1044 | + // 0:上行;1:下行 | ||
| 1045 | + if("0".equals(sxx)){ | ||
| 1046 | + singleLc = lineInformation.getUpMileage(); | ||
| 1047 | + }else{ | ||
| 1048 | + singleLc = lineInformation.getDownMileage(); | ||
| 1049 | + } | ||
| 1050 | + zlc += singleLc ; | ||
| 1051 | + yylc += singleLc; | ||
| 1052 | + } | ||
| 1053 | + sBufferC.append("</BCList>"); | ||
| 1054 | + sBufferC.append("</SKB>"); | ||
| 1055 | + sBufferA = new StringBuffer(); | ||
| 1056 | + sBufferA.append("<JHZLC>").append(df.format(zlc)).append("</JHZLC>"); | ||
| 1057 | + sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>"); | ||
| 1058 | + sBuffer.append(sBufferA).append(sBufferB).append(sBufferC); | ||
| 1059 | + } | ||
| 1060 | + logger.info("setSKB:"+"ttinfoId:"+ttinfoId+";当前站点版本号:"+lineVersion+";查询历史站点路由:"+lsStationCode2NameMap+";查询历史站点编号:"+lsStationName2YgcNumber); | ||
| 1061 | + } | ||
| 1062 | + sBuffer.append("</SKBs>"); | ||
| 1063 | + String state;// 是否上传成功 | ||
| 1064 | + if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 1065 | + result = "上传成功"; | ||
| 1066 | + state = "1"; | ||
| 1067 | + }else{// 上传失败 | ||
| 1068 | + result = "上传失败"; | ||
| 1069 | + state = "0"; | ||
| 1070 | + } | ||
| 1071 | + // 保存运管处上传记录 | ||
| 1072 | + saveYgcUploadLog(ttinfoList,sBuffer.toString(),TrafficManageServiceImpl.UPLOAD_TYPE_SKB,state); | ||
| 1073 | + } catch (Exception e) { | ||
| 1074 | + logger.error("setSKB:", e); | ||
| 1075 | + e.printStackTrace(); | ||
| 1076 | + }finally{ | ||
| 1077 | + logger.info("setSKB:"+sBuffer.toString()); | ||
| 1078 | + logger.info("setSKB:"+result); | ||
| 1079 | + } | ||
| 1080 | + return result; | ||
| 1081 | + } | ||
| 1082 | + | ||
| 1083 | + /** | ||
| 1084 | + * 保存上传运管处的日志 | ||
| 1085 | + * @param obj 参数 | ||
| 1086 | + * @param type 日志类型 | ||
| 1087 | + * @param xml 上传参数 | ||
| 1088 | + */ | ||
| 1089 | + private void saveYgcUploadLog(Object obj,String xml,String type,String state){ | ||
| 1090 | + SKBUploadLogger skbUploadLogger = new SKBUploadLogger(); | ||
| 1091 | + SysUser user; | ||
| 1092 | + // 如果不是人为上传,SysUser则为空,设置上传人员为管理员 | ||
| 1093 | + if(SecurityContextHolder.getContext() == null || SecurityContextHolder.getContext().getAuthentication() == null){ | ||
| 1094 | + user = new SysUser(); | ||
| 1095 | + user.setId(1); | ||
| 1096 | + }else{// 获取上传人员 | ||
| 1097 | + user = SecurityUtils.getCurrentUser(); | ||
| 1098 | + } | ||
| 1099 | + // 最大的字符长度 | ||
| 1100 | + int maxLength = 60000; | ||
| 1101 | + int cutLength = 50000;// 需要截取的字符长度 | ||
| 1102 | + String xml_sub = null; | ||
| 1103 | + skbUploadLogger.setType(type);// 设置类型 | ||
| 1104 | + // 判断xml是否超长,如果超长,则截取 | ||
| 1105 | + if(xml != null && xml.length() > maxLength){ | ||
| 1106 | + int xmlLength = xml.length(); | ||
| 1107 | + int cutCount = xmlLength / cutLength + (xmlLength % cutLength > 0 ? 1 : 0); | ||
| 1108 | + if(cutCount > 2){ | ||
| 1109 | + xml = "由于上传参数内容超长,请查看服务器的系统日志"; | ||
| 1110 | + }else if(cutCount == 2){ | ||
| 1111 | + xml_sub =xml.substring(cutLength); | ||
| 1112 | + xml = xml.substring(0,cutLength); | ||
| 1113 | + }else{ | ||
| 1114 | + // 不做处理 | ||
| 1115 | + } | ||
| 1116 | + } | ||
| 1117 | +// skbUploadLogger.setUploadXml(xml);// 上传的参数 | ||
| 1118 | +// skbUploadLogger.setUploadXmlSub(xml_sub); | ||
| 1119 | + skbUploadLogger.setState(state);// 状态:是否成功 | ||
| 1120 | + skbUploadLogger.setUser(user); | ||
| 1121 | + // 时刻表 | ||
| 1122 | + if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_SKB)){ | ||
| 1123 | + List<TTInfo> ttInfoList = (List<TTInfo>)obj; | ||
| 1124 | + String name = ""; | ||
| 1125 | + Line line = null; | ||
| 1126 | + for(TTInfo ttInfo : ttInfoList){ | ||
| 1127 | + name += ttInfo.getName() + " "; | ||
| 1128 | + line = ttInfo.getXl(); | ||
| 1129 | + } | ||
| 1130 | + skbUploadLogger.setLine(line); | ||
| 1131 | + skbUploadLogger.setUser(user); | ||
| 1132 | + skbUploadLogger.setName(name); | ||
| 1133 | + skbUploadLoggerRepository.save(skbUploadLogger); | ||
| 1134 | + }else{ | ||
| 1135 | + if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_XL)){ | ||
| 1136 | + Line line = (Line) obj; | ||
| 1137 | + String name = line.getName() + "线路停靠站上传"; | ||
| 1138 | + skbUploadLogger.setLine(line); | ||
| 1139 | + skbUploadLogger.setName(name); | ||
| 1140 | + skbUploadLoggerRepository.save(skbUploadLogger); | ||
| 1141 | + }else if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_LD)){ | ||
| 1142 | + Map<String ,Line> logLineMap = (Map<String ,Line> )obj; | ||
| 1143 | + for (String key : logLineMap.keySet()) { | ||
| 1144 | + Line line = logLineMap.get(key); | ||
| 1145 | + String name = line.getName() + "路单上传"; | ||
| 1146 | + skbUploadLogger = new SKBUploadLogger(); | ||
| 1147 | + skbUploadLogger.setType(type);// 设置类型 | ||
| 1148 | +// skbUploadLogger.setUploadXml(xml);// 上传的参数 | ||
| 1149 | +// skbUploadLogger.setUploadXmlSub(xml_sub); | ||
| 1150 | + skbUploadLogger.setState(state);// 状态:是否成功 | ||
| 1151 | + skbUploadLogger.setUser(user); | ||
| 1152 | + skbUploadLogger.setLine(line); | ||
| 1153 | + skbUploadLogger.setName(name); | ||
| 1154 | +// skbUploadLoggerRepository.save(skbUploadLogger); | ||
| 1155 | + } | ||
| 1156 | + } | ||
| 1157 | + } | ||
| 1158 | + } | ||
| 1159 | + /** | ||
| 1160 | + * 上传线路人员车辆配置信息 | ||
| 1161 | + */ | ||
| 1162 | + @Override | ||
| 1163 | + public String setXLPC() { | ||
| 1164 | + String result = "failure"; | ||
| 1165 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 1166 | + try { | ||
| 1167 | + sBuffer.append("<XLPCs>"); | ||
| 1168 | + // 声明变量 | ||
| 1169 | + Line line = null; | ||
| 1170 | + Cars cars = null; | ||
| 1171 | + List<Personnel> personnelList = null; | ||
| 1172 | + List<Cars> carsList = null; | ||
| 1173 | + int totalPersonnel,totalCar ;// 人员数量。车辆数量 | ||
| 1174 | + // 查询所有线路 | ||
| 1175 | + Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | ||
| 1176 | + // 循环查找线路下的信息 | ||
| 1177 | + while(lineIterator.hasNext()){ | ||
| 1178 | + line = lineIterator.next(); | ||
| 1179 | + sBuffer.append("<XLPC>"); | ||
| 1180 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | ||
| 1181 | + // 查询驾驶员数量 | ||
| 1182 | + personnelList = personnelRepository.findJsysByLineId(line.getId()); | ||
| 1183 | + totalPersonnel = personnelList != null ? personnelList.size():0; | ||
| 1184 | + sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>"); | ||
| 1185 | + // 查询售票员人员数量 | ||
| 1186 | + personnelList = personnelRepository.findSpysByLineId(line.getId()); | ||
| 1187 | + totalPersonnel = personnelList != null ? personnelList.size():0; | ||
| 1188 | + sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>"); | ||
| 1189 | + // 查询车辆 | ||
| 1190 | + carsList = carsRepository.findCarsByLineId(line.getId()); | ||
| 1191 | + totalCar = carsList != null ? carsList.size():0; | ||
| 1192 | + sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>"); | ||
| 1193 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1194 | + int carsNum = 0; | ||
| 1195 | + // 取车牌号 | ||
| 1196 | + if(carsList != null){ | ||
| 1197 | + carsNum = carsList.size(); | ||
| 1198 | + sBuffer.append("<CPHList>"); | ||
| 1199 | + for (int i = 0; i < carsNum; i++) { | ||
| 1200 | + cars = carsList.get(i); | ||
| 1201 | + sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>"); | ||
| 1202 | + } | ||
| 1203 | + sBuffer.append("</CPHList>"); | ||
| 1204 | + } | ||
| 1205 | + sBuffer.append("</XLPC>"); | ||
| 1206 | + } | ||
| 1207 | + sBuffer.append("</XLPCs>"); | ||
| 1208 | + if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 1209 | + result = "success"; | ||
| 1210 | + } | ||
| 1211 | + } catch (Exception e) { | ||
| 1212 | + logger.error("setXLPC:",e); | ||
| 1213 | + e.printStackTrace(); | ||
| 1214 | + }finally{ | ||
| 1215 | + logger.info("setXLPC:"+sBuffer.toString()); | ||
| 1216 | + logger.info("setXLPC:"+result); | ||
| 1217 | + } | ||
| 1218 | + return result; | ||
| 1219 | + } | ||
| 1220 | + | ||
| 1221 | + | ||
| 1222 | + /** | ||
| 1223 | + * 上传超速数据 | ||
| 1224 | + */ | ||
| 1225 | + @Override | ||
| 1226 | + public String setCS() { | ||
| 1227 | + String result = "failure"; | ||
| 1228 | + StringBuffer sBuffer =new StringBuffer(); | ||
| 1229 | + sBuffer.append("<CSs>"); | ||
| 1230 | + String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date "; | ||
| 1231 | + Connection conn = null; | ||
| 1232 | + PreparedStatement ps = null; | ||
| 1233 | + ResultSet rs = null; | ||
| 1234 | + // 取昨天 的日期 | ||
| 1235 | + String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | ||
| 1236 | + try { | ||
| 1237 | + conn = DBUtils_MS.getConnection(); | ||
| 1238 | + ps = conn.prepareStatement(sql); | ||
| 1239 | + ps.setString(1, yesterday); | ||
| 1240 | + rs = ps.executeQuery(); | ||
| 1241 | + Float lon, lat; | ||
| 1242 | + String kssk; | ||
| 1243 | + String speed; | ||
| 1244 | + while (rs.next()) { | ||
| 1245 | + kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP")); | ||
| 1246 | + speed = rs.getString("SPEED"); | ||
| 1247 | + // 经纬度 | ||
| 1248 | + lon = rs.getFloat("LON"); | ||
| 1249 | + lat = rs.getFloat("LAT"); | ||
| 1250 | + sBuffer.append("<CS>"); | ||
| 1251 | + sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>"); | ||
| 1252 | + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");//////// | ||
| 1253 | + sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>"); | ||
| 1254 | + sBuffer.append("<KSSK>").append(kssk).append("</KSSK>"); | ||
| 1255 | + sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>"); | ||
| 1256 | + sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>"); | ||
| 1257 | + sBuffer.append("<KSLD>").append("").append("</KSLD>");//********************** | ||
| 1258 | + sBuffer.append("<JSSK>").append(kssk).append("</JSSK>"); | ||
| 1259 | + sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>"); | ||
| 1260 | + sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>"); | ||
| 1261 | + sBuffer.append("<JSLD>").append("").append("</JSLD>");//********************** | ||
| 1262 | + sBuffer.append("<PJSD>").append(speed).append("</PJSD>"); | ||
| 1263 | + sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>"); | ||
| 1264 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1265 | + sBuffer.append("</CS>"); | ||
| 1266 | + } | ||
| 1267 | + sBuffer.append("</CSs>"); | ||
| 1268 | + if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | ||
| 1269 | + result = "success"; | ||
| 1270 | + } | ||
| 1271 | + } catch (Exception e) { | ||
| 1272 | + logger.error("setCS:",e); | ||
| 1273 | + e.printStackTrace(); | ||
| 1274 | + } finally { | ||
| 1275 | + logger.info("setCS:"+sBuffer.toString()); | ||
| 1276 | + logger.info("setCS:"+result); | ||
| 1277 | + DBUtils_MS.close(rs, ps, conn); | ||
| 1278 | + } | ||
| 1279 | + return result; | ||
| 1280 | + } | ||
| 1281 | + | ||
| 1282 | + | ||
| 1283 | + /** | ||
| 1284 | + * 下载全量的公交基础数据 | ||
| 1285 | + */ | ||
| 1286 | + public String getDownLoadAllDataFile() { | ||
| 1287 | + String result = "failure"; | ||
| 1288 | + try { | ||
| 1289 | + try { | ||
| 1290 | + if(ygcBasicDataService.download("admin","000000","abc.zip")){ | ||
| 1291 | + result = "success"; | ||
| 1292 | + } | ||
| 1293 | + } catch (Exception e) { | ||
| 1294 | + e.printStackTrace(); | ||
| 1295 | + } | ||
| 1296 | + } catch (Exception e) { | ||
| 1297 | + e.printStackTrace(); | ||
| 1298 | + } | ||
| 1299 | + | ||
| 1300 | + return result; | ||
| 1301 | + } | ||
| 1302 | + | ||
| 1303 | + /** | ||
| 1304 | + * 下载增量的公交基础数据 | ||
| 1305 | + */ | ||
| 1306 | + public String getDownLoadIncreaseDataFile() { | ||
| 1307 | + String result = "success"; | ||
| 1308 | + try { | ||
| 1309 | + //System.out.println(portType.downloadIncreaseDataFile(args0, args1, args2)); | ||
| 1310 | + } catch (Exception e) { | ||
| 1311 | + e.printStackTrace(); | ||
| 1312 | + } | ||
| 1313 | + | ||
| 1314 | + return result; | ||
| 1315 | + } | ||
| 1316 | + | ||
| 1317 | + /** | ||
| 1318 | + * 指定线路查询方式公交基础数据下载 | ||
| 1319 | + */ | ||
| 1320 | + public String getDownLoadWarrantsBusLineStation() { | ||
| 1321 | + String result = "success"; | ||
| 1322 | + try { | ||
| 1323 | + | ||
| 1324 | + //portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | ||
| 1325 | + } catch (Exception e) { | ||
| 1326 | + e.printStackTrace(); | ||
| 1327 | + } | ||
| 1328 | + | ||
| 1329 | + return result; | ||
| 1330 | + } | ||
| 1331 | + | ||
| 1332 | + /** | ||
| 1333 | + * 计算结束时间 | ||
| 1334 | + * @param fcsj 发车时间 | ||
| 1335 | + * @param bcsj 班次历时 | ||
| 1336 | + * @return | ||
| 1337 | + */ | ||
| 1338 | + private String calcDdsj(String fcsj,Integer bcsj){ | ||
| 1339 | + String result = ""; | ||
| 1340 | + if(fcsj.indexOf(":") != -1){ | ||
| 1341 | + if(bcsj == null){ | ||
| 1342 | + return fcsj; | ||
| 1343 | + } | ||
| 1344 | + // 时和分隔开 | ||
| 1345 | + String[] fcsjArray = fcsj.split(":"); | ||
| 1346 | + // 分和历时时间相加 | ||
| 1347 | + Integer fullTime = Integer.valueOf(fcsjArray[1])+ bcsj; | ||
| 1348 | + int hour,min,sumHour; | ||
| 1349 | + hour = fullTime / 60; | ||
| 1350 | + min = fullTime % 60; | ||
| 1351 | + sumHour = Integer.valueOf(fcsjArray[0])+hour; | ||
| 1352 | + if(sumHour >= 24){ | ||
| 1353 | + result = String.format("%02d",sumHour - 24); | ||
| 1354 | + }else{ | ||
| 1355 | + result = String.format("%02d",sumHour);; | ||
| 1356 | + } | ||
| 1357 | + result +=":"+String.format("%02d", min); | ||
| 1358 | + }else{ | ||
| 1359 | + result = fcsj; | ||
| 1360 | + } | ||
| 1361 | + return result; | ||
| 1362 | + } | ||
| 1363 | + | ||
| 1364 | + /** | ||
| 1365 | + * 改变时间格式 | ||
| 1366 | + * @param ttInfoDetail 时刻表详细 | ||
| 1367 | + * @return xx:yy | ||
| 1368 | + */ | ||
| 1369 | + private String changeTimeFormat(TTInfoDetail ttInfoDetail){ | ||
| 1370 | + String result = "00:00"; | ||
| 1371 | + String fcsj = ttInfoDetail.getFcsj(); | ||
| 1372 | + if(fcsj.indexOf(":") != -1){ | ||
| 1373 | + // 时和分隔开 | ||
| 1374 | + String[] fcsjArray = fcsj.split(":"); | ||
| 1375 | + result = String.format("%02d", Integer.valueOf(fcsjArray[0]))+":"; | ||
| 1376 | + result +=String.format("%02d", Integer.valueOf(fcsjArray[1])); | ||
| 1377 | + }else{ | ||
| 1378 | + result = null; | ||
| 1379 | + logger.info("setSKB:发车时间错误:ttInfoDetail.id="+ttInfoDetail.getId()); | ||
| 1380 | + } | ||
| 1381 | + return result; | ||
| 1382 | + } | ||
| 1383 | + | ||
| 1384 | + /** | ||
| 1385 | + * 拼装线路计划班次表的XML | ||
| 1386 | + * @param sBuffer | ||
| 1387 | + * @param schedulePlanInfo | ||
| 1388 | + * @param xlbm | ||
| 1389 | + * @param zbh | ||
| 1390 | + * @param lp | ||
| 1391 | + */ | ||
| 1392 | + private void assembleJHBC(StringBuffer sBuffer,SchedulePlanInfo schedulePlanInfo,String xlbm,String zbh,Long lp){ | ||
| 1393 | + sBuffer.append("<JHBC>"); | ||
| 1394 | + sBuffer.append("<RQ>").append(sdfnyr.format(schedulePlanInfo.getScheduleDate())).append("</RQ>"); | ||
| 1395 | + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(xlbm)).append("</XLBM>"); | ||
| 1396 | + sBuffer.append("<CPH>").append("沪"+zbh).append("</CPH>"); | ||
| 1397 | + sBuffer.append("<LPBH>").append(lp).append("</LPBH>"); | ||
| 1398 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | ||
| 1399 | + sBuffer.append("<BCList>"); | ||
| 1400 | + } | ||
| 1401 | + /** | ||
| 1402 | + * 转换排班规则 | ||
| 1403 | + * @param ruleDay | ||
| 1404 | + * @return | ||
| 1405 | + */ | ||
| 1406 | + private String changeRuleDay(String ruleDay){ | ||
| 1407 | + String result = ""; | ||
| 1408 | + int flag ; | ||
| 1409 | + String[] ruleDayArray = ruleDay.split(","); | ||
| 1410 | + for (int i = 0; i < ruleDayArray.length; i++) { | ||
| 1411 | + if(ruleDayArray[i].equals("1")){ | ||
| 1412 | + flag = i+1; | ||
| 1413 | + }else{ | ||
| 1414 | + flag = 0; | ||
| 1415 | + } | ||
| 1416 | + if(flag > 0){ | ||
| 1417 | + result += flag + ","; | ||
| 1418 | + } | ||
| 1419 | + } | ||
| 1420 | + // 去掉最后一个字符 | ||
| 1421 | + if(StringUtils.endsWith(result,",")){ | ||
| 1422 | + result = StringUtils.removeEnd(result,","); | ||
| 1423 | + } | ||
| 1424 | + return result; | ||
| 1425 | + } | ||
| 1426 | + /** | ||
| 1427 | + * 设置统一的公司名称 | ||
| 1428 | + * @param company | ||
| 1429 | + */ | ||
| 1430 | + private void setCompanyName(String company){ | ||
| 1431 | + if(company.equals("闵行公司")){ | ||
| 1432 | + company = "浦东闵行公交公司"; | ||
| 1433 | + }else if(company.equals("杨高公司")){ | ||
| 1434 | + company = "浦东杨高公交公司"; | ||
| 1435 | + }else if(company.equals("上南公司")){ | ||
| 1436 | + company = "浦东上南公交公司"; | ||
| 1437 | + }else if(company.equals("金高公司")){ | ||
| 1438 | + company = "浦东金高公交公司"; | ||
| 1439 | + }else if(company.equals("南汇公司")){ | ||
| 1440 | + company = "浦东南汇公交公司"; | ||
| 1441 | + }else if(company.equals("青浦公交")){ | ||
| 1442 | + company = "浦东青浦公交公司"; | ||
| 1443 | + } | ||
| 1444 | + } | ||
| 1445 | + /** | ||
| 1446 | + * @param stationsList 站点路由集 | ||
| 1447 | + * @param sBuffer sBuffer | ||
| 1448 | + * @param startId 站点序号起始ID | ||
| 1449 | + * | ||
| 1450 | + * @return 站点序号累加后的ID | ||
| 1451 | + */ | ||
| 1452 | + private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId,Map<String, Integer> stationNumMap){ | ||
| 1453 | + int size = stationsList.size(); | ||
| 1454 | + StationRoute srRoute; | ||
| 1455 | + HashMap<String,String> paraMap; | ||
| 1456 | + String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 | ||
| 1457 | + for (int i = 0; i < size; i++) { | ||
| 1458 | + srRoute = stationsList.get(i); | ||
| 1459 | + zdlx = srRoute.getStationMark(); | ||
| 1460 | + if(zdlx.equals("B")){ | ||
| 1461 | + zdlx = "0"; | ||
| 1462 | + }else if(zdlx.equals("E")){ | ||
| 1463 | + zdlx = "1"; | ||
| 1464 | + }else{ | ||
| 1465 | + zdlx = "2"; | ||
| 1466 | + } | ||
| 1467 | + paraMap = packageYgcStationNumParam(srRoute,null); | ||
| 1468 | + sBuffer.append("<Station>"); | ||
| 1469 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); | ||
| 1470 | + sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); | ||
| 1471 | + sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); | ||
| 1472 | + sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); | ||
| 1473 | + sBuffer.append("<ZDJD>").append(srRoute.getStation().getgLonx()).append("</ZDJD>"); | ||
| 1474 | + sBuffer.append("<ZDWD>").append(srRoute.getStation().getgLaty()).append("</ZDWD>"); | ||
| 1475 | + sBuffer.append("<ZZ>").append(srRoute.getStation().getAddr() == null ? "" : srRoute.getStation().getAddr()).append("</ZZ>"); | ||
| 1476 | + sBuffer.append("<ZDLX>").append(zdlx).append("</ZDLX>"); | ||
| 1477 | + sBuffer.append("<ZJLC>").append(srRoute.getDistances()).append("</ZJLC>"); | ||
| 1478 | + sBuffer.append("</Station>"); | ||
| 1479 | + startId++; | ||
| 1480 | + } | ||
| 1481 | + return startId; | ||
| 1482 | + } | ||
| 1483 | + | ||
| 1484 | + /** | ||
| 1485 | + * @param pointList 站点点位集 | ||
| 1486 | + * @param sBuffer sBuffer | ||
| 1487 | + * @param startId 站点序号起始ID | ||
| 1488 | + * | ||
| 1489 | + * @return 站点序号累加后的ID | ||
| 1490 | + */ | ||
| 1491 | + private int packagStationPointXml(List<Object[]> pointList,StringBuffer sBuffer,int startId){ | ||
| 1492 | + int size = pointList.size(); | ||
| 1493 | + Object[] objs; | ||
| 1494 | + String bsection,dir,section; | ||
| 1495 | + String[] sections ; | ||
| 1496 | + for (int i = 0; i < size; i++) { | ||
| 1497 | + objs = pointList.get(i); | ||
| 1498 | + bsection = objs[0]+""; | ||
| 1499 | + dir = objs[1]+""; | ||
| 1500 | + // 取括号内的内容 | ||
| 1501 | + Pattern pattern = Pattern.compile("(?<=\\()(.+?)(?=\\))"); | ||
| 1502 | + Matcher matcher = pattern.matcher(bsection); | ||
| 1503 | + if(matcher.find()){ | ||
| 1504 | + sections = matcher.group().split(","); | ||
| 1505 | + for (int j = 0 ; j < sections.length ; j ++){ | ||
| 1506 | + section = sections[j]; | ||
| 1507 | + sBuffer.append("<LinePoint>"); | ||
| 1508 | + sBuffer.append("<ZDXH>").append(startId).append("</ZDXH>"); | ||
| 1509 | + sBuffer.append("<SXX>").append(dir).append("</SXX>"); | ||
| 1510 | + sBuffer.append("<ZDJD>").append(section.split(" ")[0]).append("</ZDJD>"); | ||
| 1511 | + sBuffer.append("<ZDWD>").append(section.split(" ")[1]).append("</ZDWD>"); | ||
| 1512 | + sBuffer.append("</LinePoint>"); | ||
| 1513 | + startId++; | ||
| 1514 | + } | ||
| 1515 | + } | ||
| 1516 | + } | ||
| 1517 | + return startId; | ||
| 1518 | + } | ||
| 1519 | + | ||
| 1520 | + /** | ||
| 1521 | + * 获取运管处站点序号 | ||
| 1522 | + * @param map | ||
| 1523 | + * @return 运管处站点序号 | ||
| 1524 | + */ | ||
| 1525 | + private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map,Map<String, Integer> stationNumMap){ | ||
| 1526 | + // 线路编码 | ||
| 1527 | + String lineCode = map.get("lineCode"); | ||
| 1528 | + // 线路走向 0:上行 1:下行 | ||
| 1529 | + String direction = map.get("direction"); | ||
| 1530 | + // 站点编码 | ||
| 1531 | + String stationCode = map.get("stationCode"); | ||
| 1532 | + // 站点类型:B:起点站 Z:中途站 E:终点站 T:停车场 | ||
| 1533 | + String stationMark = map.get("stationMark"); | ||
| 1534 | + String[] marks = null; | ||
| 1535 | + // 起点站,先从起点找,找不到再从中途站找,最后从终点找 | ||
| 1536 | + if(stationMark.equals("B")){ | ||
| 1537 | + marks= new String[]{"B","Z","E"}; | ||
| 1538 | + }else if(stationMark.equals("E")){// 终点站相反 | ||
| 1539 | + marks= new String[]{"E","Z","B"}; | ||
| 1540 | + }else if(stationMark.equals("Z")){ | ||
| 1541 | + marks= new String[]{"Z"}; | ||
| 1542 | + } | ||
| 1543 | + // 默认从缓存BasicData.stationName2YgcNumber | ||
| 1544 | + Map<String, Integer> tempMap = BasicData.stationName2YgcNumber; | ||
| 1545 | + // 如果传入的stationNumMap不为空,则不是缓存取,而从stationNumMap取 | ||
| 1546 | + if(stationNumMap != null){ | ||
| 1547 | + tempMap = stationNumMap; | ||
| 1548 | + } | ||
| 1549 | + Integer number = null; | ||
| 1550 | + for (int i = 0 ;i < marks.length ; i ++){ | ||
| 1551 | + number = tempMap.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | ||
| 1552 | + if(number != null){ | ||
| 1553 | + break; | ||
| 1554 | + } | ||
| 1555 | + } | ||
| 1556 | + return number == null ? 0 : number; | ||
| 1557 | + } | ||
| 1558 | + | ||
| 1559 | + /** | ||
| 1560 | + * 封装查询站序条件 | ||
| 1561 | + * @param obj | ||
| 1562 | + * @return | ||
| 1563 | + */ | ||
| 1564 | + private HashMap packageYgcStationNumParam(Object obj,HashMap<String,String> otherParam){ | ||
| 1565 | + HashMap<String,String> map = new HashMap<String,String>(); | ||
| 1566 | + String lineCode = "",direction = "",stationCode = "",stationMark = ""; | ||
| 1567 | + // 站点路由 | ||
| 1568 | + if(obj instanceof StationRoute){ | ||
| 1569 | + StationRoute sr = (StationRoute)obj; | ||
| 1570 | + lineCode = sr.getLineCode(); | ||
| 1571 | + direction = String.valueOf(sr.getDirections()); | ||
| 1572 | + stationCode = sr.getStationCode(); | ||
| 1573 | + stationMark = sr.getStationMark(); | ||
| 1574 | + }else if(obj instanceof ScheduleRealInfo){ //实际排班计划明细。 | ||
| 1575 | + ScheduleRealInfo sri = (ScheduleRealInfo)obj; | ||
| 1576 | + lineCode = sri.getXlBm(); | ||
| 1577 | + direction = sri.getXlDir(); | ||
| 1578 | + if(otherParam != null && otherParam.get("stationMark") != null){ | ||
| 1579 | + stationMark = otherParam.get("stationMark"); | ||
| 1580 | + if(stationMark.equals("B")){ // 起点站 | ||
| 1581 | + stationCode = sri.getQdzCode(); | ||
| 1582 | + }else if(stationMark.equals("E")){ // 终点站 | ||
| 1583 | + stationCode = sri.getZdzCode(); | ||
| 1584 | + } | ||
| 1585 | + } | ||
| 1586 | + }else if(obj instanceof SchedulePlanInfo){ //排班计划明细 | ||
| 1587 | + SchedulePlanInfo spi = (SchedulePlanInfo)obj; | ||
| 1588 | + lineCode = spi.getXlBm(); | ||
| 1589 | + direction = spi.getXlDir(); | ||
| 1590 | + if(otherParam != null && otherParam.get("stationMark") != null){ | ||
| 1591 | + stationMark = otherParam.get("stationMark"); | ||
| 1592 | + if(stationMark.equals("B")){ // 起点站 | ||
| 1593 | + stationCode = spi.getQdzCode(); | ||
| 1594 | + }else if(stationMark.equals("E")){ // 终点站 | ||
| 1595 | + stationCode = spi.getZdzCode(); | ||
| 1596 | + } | ||
| 1597 | + } | ||
| 1598 | + }else if(obj instanceof TTInfoDetail){ //时刻表明细 | ||
| 1599 | + TTInfoDetail ttid = (TTInfoDetail)obj; | ||
| 1600 | + lineCode = ttid.getXl().getLineCode(); | ||
| 1601 | + direction = ttid.getXlDir(); | ||
| 1602 | + if(otherParam != null && otherParam.get("stationMark") != null){ | ||
| 1603 | + stationMark = otherParam.get("stationMark"); | ||
| 1604 | + if(stationMark.equals("B")){ // 起点站 | ||
| 1605 | + stationCode = ttid.getQdzCode(); | ||
| 1606 | + }else if(stationMark.equals("E")){ // 终点站 | ||
| 1607 | + stationCode = ttid.getZdzCode(); | ||
| 1608 | + } | ||
| 1609 | + } | ||
| 1610 | + } | ||
| 1611 | + map.put("lineCode",lineCode);// 站点编码 | ||
| 1612 | + map.put("direction",direction); // 上下行 | ||
| 1613 | + map.put("stationCode",stationCode); // 站点编号 | ||
| 1614 | + map.put("stationMark",stationMark); // 站点类型 | ||
| 1615 | + return map; | ||
| 1616 | + } | ||
| 1617 | + | ||
| 1618 | + /** | ||
| 1619 | + * 取得历史站点编码和站点名称的对应关系 | ||
| 1620 | + * @return | ||
| 1621 | + */ | ||
| 1622 | + private Map<String, String> getLsStationCode(String lineCode,int lineVersion){ | ||
| 1623 | + Map<String,Object> map = new HashMap<>(); | ||
| 1624 | + map.put("lineCode_eq", lineCode); | ||
| 1625 | + map.put("versions_eq",lineVersion); | ||
| 1626 | + LsStationRoute lsroute; | ||
| 1627 | + Iterator<LsStationRoute> iterator = lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map)).iterator(); | ||
| 1628 | + Map<String, String> stationCode2Name = new HashMap<>(); | ||
| 1629 | + while (iterator.hasNext()) { | ||
| 1630 | + lsroute = iterator.next(); | ||
| 1631 | + stationCode2Name.put(lsroute.getLineCode() + "_" + lsroute.getDirections() + "_" + lsroute.getStationCode(), lsroute.getStationName()); | ||
| 1632 | + } | ||
| 1633 | + return stationCode2Name; | ||
| 1634 | + } | ||
| 1635 | + | ||
| 1636 | + private Map<String, Integer> getLsStationRoute(String xlbm,int lineVersion){ | ||
| 1637 | + Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); | ||
| 1638 | + /** | ||
| 1639 | + * 加载运管处的站点及序号 | ||
| 1640 | + * 上行从1开始,下行顺序续编 | ||
| 1641 | + */ | ||
| 1642 | + List<Map<String, String>> ygcLines = lsStationRouteRepository.findLineWithLineCode4Ygc(xlbm,lineVersion); | ||
| 1643 | + if(ygcLines != null && ygcLines.size() > 0){ | ||
| 1644 | + int size = ygcLines.size(); | ||
| 1645 | + Map<String, String> tempMap ; | ||
| 1646 | + int num = 1; | ||
| 1647 | + String key; | ||
| 1648 | + String lineCode = ""; | ||
| 1649 | + for (int i = 0; i < size; i ++){ | ||
| 1650 | + tempMap = ygcLines.get(i); | ||
| 1651 | + if(lineCode.equals("")){ | ||
| 1652 | + lineCode = tempMap.get("lineCode"); | ||
| 1653 | + }else if(!lineCode.equals(tempMap.get("lineCode"))){ | ||
| 1654 | + num = 1; | ||
| 1655 | + lineCode = tempMap.get("lineCode"); | ||
| 1656 | + } | ||
| 1657 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | ||
| 1658 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | ||
| 1659 | + tempStationName2YgcNumber.put(key,num++); | ||
| 1660 | + } | ||
| 1661 | + } | ||
| 1662 | + return tempStationName2YgcNumber; | ||
| 1663 | + } | ||
| 1664 | + | ||
| 1665 | + private String getSetXlXml(Line line,LineInformation lineInformation){ | ||
| 1666 | + StringBuffer sBuffer = new StringBuffer(); | ||
| 1667 | + List<StationRoute> upStationsList ;// 上行站点路由集 | ||
| 1668 | + List<StationRoute> downStationsList;// 下行站点路由集 | ||
| 1669 | + List<Object[]> downPointList;// 下行站点集 | ||
| 1670 | + List<Object[]> upPointList;// 上行站点集 | ||
| 1671 | + sBuffer.append("<XLs>"); | ||
| 1672 | + sBuffer.append("<XL>"); | ||
| 1673 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | ||
| 1674 | + sBuffer.append("<XLMC>").append(line.getName()).append("</XLMC>"); | ||
| 1675 | + sBuffer.append("<QDZ>").append(line.getStartStationName()).append("</QDZ>"); | ||
| 1676 | + sBuffer.append("<ZDZ>").append(line.getEndStationName()).append("</ZDZ>"); | ||
| 1677 | + sBuffer.append("<QZLC>").append(lineInformation.getUpMileage()).append("</QZLC>"); | ||
| 1678 | + sBuffer.append("<ZQLC>").append(lineInformation.getDownMileage()).append("</ZQLC>"); | ||
| 1679 | + sBuffer.append("<XLGH>").append(line.getLinePlayType()).append("</XLGH>"); | ||
| 1680 | + sBuffer.append("<UPDATE_DATE>").append(sdfnyr.format(new Date())).append("</UPDATE_DATE>"); | ||
| 1681 | + // 循环添加站点信息 | ||
| 1682 | + sBuffer.append("<StationList>"); | ||
| 1683 | + // 先查上行 | ||
| 1684 | + upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); | ||
| 1685 | + Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | ||
| 1686 | + int startId = 1; | ||
| 1687 | + startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); | ||
| 1688 | + // 环线不查下行 | ||
| 1689 | + if(line.getLinePlayType() != 1){ | ||
| 1690 | + // 再查下行 | ||
| 1691 | + downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); | ||
| 1692 | + packagStationXml(downStationsList, sBuffer, startId,stationNumMap); | ||
| 1693 | + } | ||
| 1694 | + sBuffer.append("</StationList>"); | ||
| 1695 | + // 循环添加站点点位信息 | ||
| 1696 | + sBuffer.append("<LinePointList>"); | ||
| 1697 | + upPointList = sectionRepository.getSectionDirByLineId(line.getId(),0); | ||
| 1698 | + startId = 1; | ||
| 1699 | + startId = packagStationPointXml(upPointList, sBuffer, startId); | ||
| 1700 | + // 环线不查下行 | ||
| 1701 | + if(line.getLinePlayType() != 1){ | ||
| 1702 | + downPointList = sectionRepository.getSectionDirByLineId(line.getId(),1); | ||
| 1703 | + packagStationPointXml(downPointList, sBuffer, startId); | ||
| 1704 | + } | ||
| 1705 | + sBuffer.append("</LinePointList>"); | ||
| 1706 | + sBuffer.append("</XL>"); | ||
| 1707 | + sBuffer.append("</XLs>"); | ||
| 1708 | + return sBuffer.toString(); | ||
| 1709 | + } | ||
| 1710 | +} |
src/main/java/com/bsth/service/report/CardSigningService.java
0 → 100644
| 1 | +package com.bsth.service.report; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.card_signing.CardSigning; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | +import java.util.Map; | ||
| 7 | + | ||
| 8 | +public interface CardSigningService { | ||
| 9 | + | ||
| 10 | + public List<CardSigning> cardList(Map<String, Object> map); | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + public List<CardSigning> calcListSheet(Map<String, Object> map); | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + public List<CardSigning> calcSheet(Map<String, Object> map); | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +} |
src/main/java/com/bsth/service/report/impl/CardSigningServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.report.impl; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.card_signing.CardSigning; | ||
| 4 | +import com.bsth.service.report.CardSigningService; | ||
| 5 | +import com.bsth.util.ReportUtils; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 8 | +import org.springframework.jdbc.core.RowMapper; | ||
| 9 | +import org.springframework.stereotype.Service; | ||
| 10 | + | ||
| 11 | +import java.sql.ResultSet; | ||
| 12 | +import java.sql.SQLException; | ||
| 13 | +import java.text.DecimalFormat; | ||
| 14 | +import java.util.*; | ||
| 15 | + | ||
| 16 | +@Service | ||
| 17 | +public class CardSigningServiceImpl implements CardSigningService { | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + JdbcTemplate jdbcTemplate; | ||
| 21 | + @Override | ||
| 22 | + public List<CardSigning> cardList(Map<String, Object> map) { | ||
| 23 | + final DecimalFormat df = new DecimalFormat("0.00"); | ||
| 24 | + String line=""; | ||
| 25 | + if(map.get("line")!=null){ | ||
| 26 | + line =map.get("line").toString().trim(); | ||
| 27 | + } | ||
| 28 | + String gs=""; | ||
| 29 | + if(map.get("gs")!=null){ | ||
| 30 | + gs=map.get("gs").toString().trim(); | ||
| 31 | + } | ||
| 32 | + String fgs=""; | ||
| 33 | + if(map.get("fgs")!=null){ | ||
| 34 | + fgs=map.get("fgs").toString().trim(); | ||
| 35 | + } | ||
| 36 | + String nature="0"; | ||
| 37 | + if(map.get("nature")!=null){ | ||
| 38 | + nature=map.get("nature").toString(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + String date=map.get("date").toString(); | ||
| 42 | + String endDate=map.get("endDate").toString(); | ||
| 43 | + String sql="select gs_name,gs_bm,fgs_name,fgs_bm,xl_name,xl_bm,sum(bcs) as bcs,sum(qks) as qks," + | ||
| 44 | + " avg(qkl) as qkl,sum(rkgzs) as rkgzs,avg(rkgzl) as rkgzl ,avg(ckgzs) as ckgzs ,avg(ckgzl) as ckgzl " + | ||
| 45 | + "from card_signing where schedule_date_str BETWEEN '"+date+"' and '"+endDate+"'"; | ||
| 46 | + if(line.trim().equals("")){ | ||
| 47 | + sql +=" and gs_bm = '"+gs+"' and fgs_bm like '%"+fgs+"%'"; | ||
| 48 | + }else{ | ||
| 49 | + sql +=" and xl_bm ='"+line+"'"; | ||
| 50 | + } | ||
| 51 | + sql +=" group by xl_name"; | ||
| 52 | + //条件下所有路单 | ||
| 53 | + List<CardSigning> list=jdbcTemplate.query(sql, | ||
| 54 | + new RowMapper<CardSigning>(){ | ||
| 55 | + @Override | ||
| 56 | + public CardSigning mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 57 | + CardSigning s=new CardSigning(); | ||
| 58 | + s.setGsName(rs.getString("gs_name")); | ||
| 59 | + s.setGsBm(rs.getString("gs_bm")); | ||
| 60 | + s.setFgsName(rs.getString("fgs_name")); | ||
| 61 | + s.setFgsBm(rs.getString("fgs_bm")); | ||
| 62 | + s.setXlName(rs.getString("xl_name")); | ||
| 63 | + s.setXlBm(rs.getString("xl_bm")); | ||
| 64 | + s.setBcs(rs.getInt("bcs")); | ||
| 65 | + s.setQks(rs.getInt("qks")); | ||
| 66 | + s.setQklName(df.format(rs.getDouble("qkl"))+"%"); | ||
| 67 | + s.setRkgzs(rs.getInt("rkgzs")); | ||
| 68 | + s.setRkgzlName(df.format(rs.getDouble("rkgzl"))+"%"); | ||
| 69 | + s.setCkgzs(rs.getInt("ckgzs")); | ||
| 70 | + s.setCkgzlName(df.format(rs.getDouble("ckgzl"))+"%"); | ||
| 71 | + return s; | ||
| 72 | + } | ||
| 73 | + }); | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + if(map.get("type").equals("export")){ | ||
| 77 | + List<Map<String, Object>> listmap=new ArrayList<Map<String, Object>>(); | ||
| 78 | + for (CardSigning c:list) { | ||
| 79 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 80 | + m.put("gs", c.getGsName()); | ||
| 81 | + m.put("fgs", c.getFgsName()); | ||
| 82 | + m.put("line", c.getXlName()); | ||
| 83 | + m.put("bcs", c.getBcs()); | ||
| 84 | + m.put("qks", c.getQks()); | ||
| 85 | + m.put("qkl", c.getQklName()); | ||
| 86 | + m.put("rkgzs", c.getRkgzs()); | ||
| 87 | + m.put("rkgzl", c.getRkgzlName()); | ||
| 88 | + m.put("ckgzs", c.getCkgzs()); | ||
| 89 | + m.put("ckgzl", c.getCkgzlName()); | ||
| 90 | + listmap.add(m); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 94 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 95 | + m.put("date", date); | ||
| 96 | + m.put("endDate", endDate); | ||
| 97 | + ReportUtils ee = new ReportUtils(); | ||
| 98 | + try { | ||
| 99 | + String dateTime = ""; | ||
| 100 | + if(date.equals(endDate)){ | ||
| 101 | + dateTime = date.replaceAll("-", ""); | ||
| 102 | + } else { | ||
| 103 | + dateTime = date.replaceAll("-", "")+"-"+ | ||
| 104 | + endDate.replaceAll("-", ""); | ||
| 105 | + } | ||
| 106 | + listI.add(listmap.iterator()); | ||
| 107 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 108 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/" + "cardSheetList.xls", | ||
| 109 | + path + "export/"+dateTime+"-签卡率.xls"); | ||
| 110 | + } catch (Exception e) { | ||
| 111 | + // TODO: handle exception | ||
| 112 | + e.printStackTrace(); | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + return list; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + | ||
| 120 | + @Override | ||
| 121 | + public List<CardSigning> calcListSheet(Map<String, Object> map) { | ||
| 122 | + String line=map.get("line").toString(); | ||
| 123 | + String date=map.get("date").toString(); | ||
| 124 | + String endDate=map.get("endDate").toString(); | ||
| 125 | + final DecimalFormat df = new DecimalFormat("0.00"); | ||
| 126 | + String sql="select gs_name,gs_bm,fgs_name,fgs_bm,xl_name," + | ||
| 127 | + "xl_bm,schedule_date_str,bcs,qks,qkl,rkgzs,rkgzl,ckgzs,ckgzl from card_signing " + | ||
| 128 | + "where schedule_date_str BETWEEN '"+date+"' and '"+endDate+"' and xl_bm = '"+line+"'" ; | ||
| 129 | + | ||
| 130 | + //条件下所有路单 | ||
| 131 | + List<CardSigning> list=jdbcTemplate.query(sql, | ||
| 132 | + new RowMapper<CardSigning>(){ | ||
| 133 | + @Override | ||
| 134 | + public CardSigning mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 135 | + CardSigning s=new CardSigning(); | ||
| 136 | + s.setGsName(rs.getString("gs_name")); | ||
| 137 | + s.setGsBm(rs.getString("gs_bm")); | ||
| 138 | + s.setFgsName(rs.getString("fgs_name")); | ||
| 139 | + s.setFgsBm(rs.getString("fgs_bm")); | ||
| 140 | + s.setXlName(rs.getString("xl_name")); | ||
| 141 | + s.setXlBm(rs.getString("xl_bm")); | ||
| 142 | + s.setBcs(rs.getInt("bcs")); | ||
| 143 | + s.setRkgzs(rs.getInt("rkgzs")); | ||
| 144 | + s.setRkgzlName(df.format(rs.getDouble("rkgzl"))+"%"); | ||
| 145 | + s.setCkgzs(rs.getInt("ckgzs")); | ||
| 146 | + s.setCkgzlName(df.format(rs.getDouble("ckgzl"))+"%"); | ||
| 147 | + s.setScheduleDateStr(rs.getString("schedule_date_str")); | ||
| 148 | + return s; | ||
| 149 | + } | ||
| 150 | + }); | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + | ||
| 154 | + if(map.get("type").equals("export")){ | ||
| 155 | + List<Map<String, Object>> listmap=new ArrayList<Map<String, Object>>(); | ||
| 156 | + for (CardSigning c:list) { | ||
| 157 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 158 | + m.put("gs", c.getGsName()); | ||
| 159 | + m.put("fgs", c.getFgsName()); | ||
| 160 | + m.put("schedule_date_str", c.getScheduleDateStr()); | ||
| 161 | + m.put("line", c.getXlName()); | ||
| 162 | + m.put("bcs", c.getBcs()); | ||
| 163 | + m.put("rkgzs", c.getRkgzs()); | ||
| 164 | + m.put("rkgzl", c.getRkgzlName()); | ||
| 165 | + m.put("ckgzs", c.getCkgzs()); | ||
| 166 | + m.put("ckgzl", c.getCkgzlName()); | ||
| 167 | + listmap.add(m); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 171 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 172 | + m.put("date", date); | ||
| 173 | + m.put("endDate", endDate); | ||
| 174 | + ReportUtils ee = new ReportUtils(); | ||
| 175 | + try { | ||
| 176 | + String dateTime = ""; | ||
| 177 | + if(date.equals(endDate)){ | ||
| 178 | + dateTime = date.replaceAll("-", ""); | ||
| 179 | + } else { | ||
| 180 | + dateTime = date.replaceAll("-", "")+"-"+ | ||
| 181 | + endDate.replaceAll("-", ""); | ||
| 182 | + } | ||
| 183 | + listI.add(listmap.iterator()); | ||
| 184 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 185 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/" + "cardSheetList1.xls", | ||
| 186 | + path + "export/班次故障率"+date.replaceAll("-", "")+"-"+endDate.replaceAll("-", "")+".xls"); | ||
| 187 | + } catch (Exception e) { | ||
| 188 | + // TODO: handle exception | ||
| 189 | + e.printStackTrace(); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + return list; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + @Override | ||
| 197 | + public List<CardSigning> calcSheet(Map<String, Object> map) { | ||
| 198 | + String line=map.get("line").toString(); | ||
| 199 | + String date=map.get("date").toString(); | ||
| 200 | + String dir =map.get("dir").toString(); | ||
| 201 | + String sql="select gs_name,gs_bm,fgs_name,fgs_bm, xl_name,xl_bm,schedule_date_str ,qdz_name,rfid_state,fcsj,fcsj_actual " + | ||
| 202 | + "from bsth_c_s_sp_info_real where schedule_date_str = '"+date+"' and xl_bm = '"+line+"' and bc_type='normal' ORDER BY qdz_name,fcsj" ; | ||
| 203 | + //条件下所有路单 | ||
| 204 | + List<CardSigning> list=jdbcTemplate.query(sql, | ||
| 205 | + new RowMapper<CardSigning>(){ | ||
| 206 | + @Override | ||
| 207 | + public CardSigning mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 208 | + CardSigning s=new CardSigning(); | ||
| 209 | + s.setGsName(rs.getString("gs_name")); | ||
| 210 | + s.setGsBm(rs.getString("gs_bm")); | ||
| 211 | + s.setFgsName(rs.getString("fgs_name")); | ||
| 212 | + s.setFgsBm(rs.getString("fgs_bm")); | ||
| 213 | + s.setXlName(rs.getString("xl_name")); | ||
| 214 | + s.setXlBm(rs.getString("xl_bm")); | ||
| 215 | + s.setScheduleDateStr(rs.getString("schedule_date_str")); | ||
| 216 | + s.setQdzName(rs.getString("qdz_name")); | ||
| 217 | + s.setRfidState(rs.getInt("rfid_state")); | ||
| 218 | + s.setFcsj(rs.getString("fcsj")); | ||
| 219 | + s.setFcsjActual(rs.getString("fcsj_actual")); | ||
| 220 | + return s; | ||
| 221 | + } | ||
| 222 | + }); | ||
| 223 | + | ||
| 224 | + for (CardSigning c : list){ | ||
| 225 | + String sty = decimalToBinary(c.getRfidState()); | ||
| 226 | + Integer state = Integer.parseInt(sty); | ||
| 227 | + if(dir.equals("1")) { | ||
| 228 | + | ||
| 229 | + if ((state & 4) == 4) { | ||
| 230 | + c.setRfidName("正常"); | ||
| 231 | + } else { | ||
| 232 | + c.setRfidName("人卡故障"); | ||
| 233 | + } | ||
| 234 | + }else { | ||
| 235 | + if ((state & 4) == 4 || (state & 2) == 2) { | ||
| 236 | + c.setRfidName("正常"); | ||
| 237 | + }else { | ||
| 238 | + c.setRfidName("车卡故障"); | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + if(map.get("type").equals("export")){ | ||
| 244 | + List<Map<String, Object>> listmap=new ArrayList<Map<String, Object>>(); | ||
| 245 | + int i = 0; | ||
| 246 | + for (CardSigning c:list) { | ||
| 247 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 248 | + i++; | ||
| 249 | + m.put("id",i); | ||
| 250 | + m.put("schedule_date_str", c.getScheduleDateStr()); | ||
| 251 | + m.put("line", c.getXlName()); | ||
| 252 | + m.put("qdz_name", c.getQdzName()); | ||
| 253 | + m.put("fcsj", c.getFcsj()); | ||
| 254 | + m.put("fcsj_actual", c.getFcsjActual()); | ||
| 255 | + m.put("rfidname", c.getRfidName()); | ||
| 256 | + listmap.add(m); | ||
| 257 | + } | ||
| 258 | + String fileName=""; | ||
| 259 | + if(dir.equals("1")){ | ||
| 260 | + fileName="人卡故障率"+date; | ||
| 261 | + }else{ | ||
| 262 | + fileName="车卡故障率"+date; | ||
| 263 | + } | ||
| 264 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 265 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 266 | + m.put("date", date); | ||
| 267 | + ReportUtils ee = new ReportUtils(); | ||
| 268 | + try { | ||
| 269 | + listI.add(listmap.iterator()); | ||
| 270 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 271 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/" + "cardSheetList2.xls", | ||
| 272 | + path + "export/"+fileName+".xls"); | ||
| 273 | + } catch (Exception e) { | ||
| 274 | + // TODO: handle exception | ||
| 275 | + e.printStackTrace(); | ||
| 276 | + } | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + | ||
| 280 | + return list; | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + | ||
| 284 | + public static String decimalToBinary(int n) { | ||
| 285 | + String str = ""; | ||
| 286 | + if(n == 0){ | ||
| 287 | + return str = "0"; | ||
| 288 | + } | ||
| 289 | + while (n != 0) { | ||
| 290 | + str = n % 2 + str; | ||
| 291 | + n = n / 2; | ||
| 292 | + } | ||
| 293 | + return str; | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + | ||
| 297 | + | ||
| 298 | +} |
src/main/java/com/bsth/util/ReportUtils.java
| @@ -726,20 +726,28 @@ public class ReportUtils { | @@ -726,20 +726,28 @@ public class ReportUtils { | ||
| 726 | 726 | ||
| 727 | //设置wordsheet名 | 727 | //设置wordsheet名 |
| 728 | HSSFSheet sheetYS = workbook.createSheet();//设置wordsheet名 | 728 | HSSFSheet sheetYS = workbook.createSheet();//设置wordsheet名 |
| 729 | + HSSFRow row = sheetYS.createRow(0); | ||
| 730 | + setCellStyleAndValue(row, style, 0, name); | ||
| 731 | + CellRangeAddress callRangeAddress = new CellRangeAddress(0,0,0,list.get(0).size()-1); | ||
| 732 | + sheetYS.addMergedRegion(callRangeAddress); | ||
| 733 | + // 样式 | ||
| 734 | + setMergeCellStyle (callRangeAddress, sheetYS, workbook); | ||
| 729 | 735 | ||
| 730 | try{ | 736 | try{ |
| 731 | for(int i=0; i<list.size(); i++){ | 737 | for(int i=0; i<list.size(); i++){ |
| 732 | - HSSFRow rowYSi = sheetYS.createRow(i); | 738 | + HSSFRow rowYSi = sheetYS.createRow(i+1); |
| 733 | List<String> stringList = list.get(i); | 739 | List<String> stringList = list.get(i); |
| 734 | int num = 4; | 740 | int num = 4; |
| 735 | if("xl".equals(type)) | 741 | if("xl".equals(type)) |
| 736 | num = 2; | 742 | num = 2; |
| 743 | + else if("cl".equals(type)) | ||
| 744 | + num = 5; | ||
| 737 | for(int j=0; j<stringList.size(); j++){ | 745 | for(int j=0; j<stringList.size(); j++){ |
| 738 | String str = stringList.get(j); | 746 | String str = stringList.get(j); |
| 739 | if(i == list.size()-1){ | 747 | if(i == list.size()-1){ |
| 740 | if(j==0) { | 748 | if(j==0) { |
| 741 | setCellStyleAndValue(rowYSi, style, j, str); | 749 | setCellStyleAndValue(rowYSi, style, j, str); |
| 742 | - CellRangeAddress callRangeAddressYSi = new CellRangeAddress(i,i,0,num); | 750 | + CellRangeAddress callRangeAddressYSi = new CellRangeAddress(i+1,i+1,0,num); |
| 743 | sheetYS.addMergedRegion(callRangeAddressYSi); | 751 | sheetYS.addMergedRegion(callRangeAddressYSi); |
| 744 | // 样式 | 752 | // 样式 |
| 745 | setMergeCellStyle (callRangeAddressYSi, sheetYS, workbook); | 753 | setMergeCellStyle (callRangeAddressYSi, sheetYS, workbook); |
| @@ -752,7 +760,7 @@ public class ReportUtils { | @@ -752,7 +760,7 @@ public class ReportUtils { | ||
| 752 | } | 760 | } |
| 753 | 761 | ||
| 754 | // 给列设置宽度自适应 | 762 | // 给列设置宽度自适应 |
| 755 | - setSizeColumn(sheetYS,list.get(0).size()); | 763 | + setSizeColumn1(sheetYS,1,list.get(0).size()); |
| 756 | String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; | 764 | String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; |
| 757 | String targetPath = path+name+".xls"; | 765 | String targetPath = path+name+".xls"; |
| 758 | createFolder(targetPath); | 766 | createFolder(targetPath); |
| @@ -761,6 +769,7 @@ public class ReportUtils { | @@ -761,6 +769,7 @@ public class ReportUtils { | ||
| 761 | workbook.write(fout); | 769 | workbook.write(fout); |
| 762 | fout.close(); | 770 | fout.close(); |
| 763 | } catch (Exception e) { | 771 | } catch (Exception e) { |
| 772 | + e.printStackTrace(); | ||
| 764 | } | 773 | } |
| 765 | } | 774 | } |
| 766 | 775 | ||
| @@ -795,6 +804,38 @@ public class ReportUtils { | @@ -795,6 +804,38 @@ public class ReportUtils { | ||
| 795 | } | 804 | } |
| 796 | } | 805 | } |
| 797 | 806 | ||
| 807 | + /** | ||
| 808 | + * 自适应宽度(中文支持) | ||
| 809 | + * @param sheet | ||
| 810 | + * @param index 从那一行开始自适应 | ||
| 811 | + * @param size | ||
| 812 | + */ | ||
| 813 | + private static void setSizeColumn1(HSSFSheet sheet,int index, int size) { | ||
| 814 | + for (int columnNum = index; columnNum < size; columnNum++) { | ||
| 815 | + int columnWidth = sheet.getColumnWidth(columnNum) / 256; | ||
| 816 | + for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) { | ||
| 817 | + HSSFRow currentRow; | ||
| 818 | + //当前行未被使用过 | ||
| 819 | + if (sheet.getRow(rowNum) == null) { | ||
| 820 | + currentRow = sheet.createRow(rowNum); | ||
| 821 | + } else { | ||
| 822 | + currentRow = sheet.getRow(rowNum); | ||
| 823 | + } | ||
| 824 | + if (currentRow.getCell(columnNum) != null) { | ||
| 825 | + HSSFCell currentCell = currentRow.getCell(columnNum); | ||
| 826 | + if (currentCell.getCellType() == XSSFCell.CELL_TYPE_STRING) { | ||
| 827 | + int length = currentCell.getStringCellValue().getBytes().length; | ||
| 828 | + if (columnWidth < length) { | ||
| 829 | + columnWidth = length; | ||
| 830 | + } | ||
| 831 | + } | ||
| 832 | + } | ||
| 833 | + } | ||
| 834 | + sheet.setColumnWidth(columnNum, columnWidth * 300); | ||
| 835 | +// sheet.setColumnWidth(columnNum, columnWidth * 256); | ||
| 836 | + } | ||
| 837 | + } | ||
| 838 | + | ||
| 798 | /** | 839 | /** |
| 799 | * 设置单元格值和样式 | 840 | * 设置单元格值和样式 |
| 800 | * @param row | 841 | * @param row |
src/main/resources/static/pages/forms/calc/calcDetailMonthly.html
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | 29 | ||
| 30 | #analy_body{ | 30 | #analy_body{ |
| 31 | margin-top: 20px; | 31 | margin-top: 20px; |
| 32 | - height: 650px; | 32 | + height: 620px; |
| 33 | width: 100% | 33 | width: 100% |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
| 46 | 46 | ||
| 47 | .table_body{ | 47 | .table_body{ |
| 48 | width:101%; | 48 | width:101%; |
| 49 | - height:620px; | 49 | + height:580px; |
| 50 | overflow: auto; | 50 | overflow: auto; |
| 51 | margin-top: -20px; | 51 | margin-top: -20px; |
| 52 | } | 52 | } |
| @@ -149,9 +149,10 @@ | @@ -149,9 +149,10 @@ | ||
| 149 | }; | 149 | }; |
| 150 | 150 | ||
| 151 | var d = new Date(); | 151 | var d = new Date(); |
| 152 | + d.setTime(d.getTime() - 4*1000*60*60*24);//只能查4天以前的数据 | ||
| 152 | var year = d.getFullYear(); | 153 | var year = d.getFullYear(); |
| 153 | var month = d.getMonth() + 1; | 154 | var month = d.getMonth() + 1; |
| 154 | - var day = d.getDate()-4;//只能查4天以前的数据 | 155 | + var day = d.getDate(); |
| 155 | if(month < 10) | 156 | if(month < 10) |
| 156 | month = "0" + month; | 157 | month = "0" + month; |
| 157 | if(day < 10) | 158 | if(day < 10) |
| @@ -217,8 +218,8 @@ | @@ -217,8 +218,8 @@ | ||
| 217 | } else if(item == "gl"){ | 218 | } else if(item == "gl"){ |
| 218 | options += '<option value="zgl">总公里</option>' + | 219 | options += '<option value="zgl">总公里</option>' + |
| 219 | '<option value="jhgl">计划公里</option>'; | 220 | '<option value="jhgl">计划公里</option>'; |
| 220 | - /*'<option value="jclm">进场路码</option>'+ | ||
| 221 | - '<option value="cclm">出场路码</option>'*/ | 221 | + /*'<option value="jclm">进场路码</option>'+ |
| 222 | + '<option value="cclm">出场路码</option>'*/ | ||
| 222 | } else if(item == "bc"){ | 223 | } else if(item == "bc"){ |
| 223 | options += '<option value="sjbc">实际班次</option>' + | 224 | options += '<option value="sjbc">实际班次</option>' + |
| 224 | '<option value="jhbc">计划班次</option>'; | 225 | '<option value="jhbc">计划班次</option>'; |
| @@ -254,6 +255,44 @@ | @@ -254,6 +255,44 @@ | ||
| 254 | datas.destroy = $("#destroy").val(); | 255 | datas.destroy = $("#destroy").val(); |
| 255 | datas.statisticalObj = $("#statisticalObj").val(); | 256 | datas.statisticalObj = $("#statisticalObj").val(); |
| 256 | datas.itemDetails = $("#itemDetails").val(); | 257 | datas.itemDetails = $("#itemDetails").val(); |
| 258 | + var itemDetails = datas.itemDetails, | ||
| 259 | + type = "加注量[全部]"; | ||
| 260 | + if(itemDetails=="jzl0"){ | ||
| 261 | + type = "加注量[0#]" | ||
| 262 | + } else if(itemDetails=="jzl-10"){ | ||
| 263 | + type = "加注量[-10#]" | ||
| 264 | + } else if(itemDetails=="yhl"){ | ||
| 265 | + type = "油耗量" | ||
| 266 | + } else if(itemDetails=="cccy"){ | ||
| 267 | + type = "出场存油" | ||
| 268 | + } else if(itemDetails=="jccy"){ | ||
| 269 | + type = "进场存油" | ||
| 270 | + } else if(itemDetails=="bglyh"){ | ||
| 271 | + type = "百公里油耗" | ||
| 272 | + } else if(itemDetails=="zgl"){ | ||
| 273 | + type = "总公里" | ||
| 274 | + } else if(itemDetails=="jhgl"){ | ||
| 275 | + type = "计划公里" | ||
| 276 | + } else if(itemDetails=="jclm"){ | ||
| 277 | + type = "进场路码" | ||
| 278 | + } else if(itemDetails=="cclm"){ | ||
| 279 | + type = "出场路码" | ||
| 280 | + } else if(itemDetails=="sjbc"){ | ||
| 281 | + type = "实际班次" | ||
| 282 | + } else if(itemDetails=="jhbc"){ | ||
| 283 | + type = "计划班次" | ||
| 284 | + } else if(itemDetails=="dh"){ | ||
| 285 | + type = "耗电量" | ||
| 286 | + } else if(itemDetails=="cdl"){ | ||
| 287 | + type = "充电量" | ||
| 288 | + } else if(itemDetails=="cccd"){ | ||
| 289 | + type = "出场存电" | ||
| 290 | + } else if(itemDetails=="jccd"){ | ||
| 291 | + type = "进场存电" | ||
| 292 | + } else if(itemDetails=="bgldh"){ | ||
| 293 | + type = "百公里电耗" | ||
| 294 | + } | ||
| 295 | + datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细月报表("+type+")"; | ||
| 257 | if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ | 296 | if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ |
| 258 | layer.msg('请选择时间段!'); | 297 | layer.msg('请选择时间段!'); |
| 259 | }else if(endTime<startTime){ | 298 | }else if(endTime<startTime){ |
| @@ -275,7 +314,7 @@ | @@ -275,7 +314,7 @@ | ||
| 275 | return; | 314 | return; |
| 276 | }else | 315 | }else |
| 277 | $("#export").removeAttr("disabled"); | 316 | $("#export").removeAttr("disabled"); |
| 278 | - var htmlHead = "", htmlBody = ""; | 317 | + var htmlHead = "<tr><td colspan='"+rs[0].length+"'>"+datas.name+"</td></tr>", htmlBody = ""; |
| 279 | var rsLength = rs.length; | 318 | var rsLength = rs.length; |
| 280 | rs.forEach(function (o, i) { | 319 | rs.forEach(function (o, i) { |
| 281 | var html = "<tr>" | 320 | var html = "<tr>" |
| @@ -283,12 +322,14 @@ | @@ -283,12 +322,14 @@ | ||
| 283 | var colspan; | 322 | var colspan; |
| 284 | if (i == rsLength - 1 && j == 0) { | 323 | if (i == rsLength - 1 && j == 0) { |
| 285 | colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); | 324 | colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); |
| 325 | + if(statisticalObj == "cl") | ||
| 326 | + colspan = "colspan='6'"; | ||
| 286 | } | 327 | } |
| 287 | html += "<td " + colspan + ">" + td + "</td>" | 328 | html += "<td " + colspan + ">" + td + "</td>" |
| 288 | }); | 329 | }); |
| 289 | html += "</tr>" | 330 | html += "</tr>" |
| 290 | if (i == 0) { | 331 | if (i == 0) { |
| 291 | - htmlHead = html; | 332 | + htmlHead += html; |
| 292 | } else | 333 | } else |
| 293 | htmlBody += html; | 334 | htmlBody += html; |
| 294 | }); | 335 | }); |
| @@ -301,44 +342,6 @@ | @@ -301,44 +342,6 @@ | ||
| 301 | }); | 342 | }); |
| 302 | 343 | ||
| 303 | $("#export").on("click",function(){ | 344 | $("#export").on("click",function(){ |
| 304 | - var itemDetails = datas.itemDetails, | ||
| 305 | - type = "加注量[全部]"; | ||
| 306 | - if(itemDetails=="jzl0"){ | ||
| 307 | - type = "加注量[0#]" | ||
| 308 | - } else if(itemDetails=="jzl-10"){ | ||
| 309 | - type = "加注量[-10#]" | ||
| 310 | - } else if(itemDetails=="yhl"){ | ||
| 311 | - type = "油耗量" | ||
| 312 | - } else if(itemDetails=="cccy"){ | ||
| 313 | - type = "出场存油" | ||
| 314 | - } else if(itemDetails=="jccy"){ | ||
| 315 | - type = "进场存油" | ||
| 316 | - } else if(itemDetails=="bglyh"){ | ||
| 317 | - type = "百公里油耗" | ||
| 318 | - } else if(itemDetails=="zgl"){ | ||
| 319 | - type = "总公里" | ||
| 320 | - } else if(itemDetails=="jhgl"){ | ||
| 321 | - type = "计划公里" | ||
| 322 | - } else if(itemDetails=="jclm"){ | ||
| 323 | - type = "进场路码" | ||
| 324 | - } else if(itemDetails=="cclm"){ | ||
| 325 | - type = "出场路码" | ||
| 326 | - } else if(itemDetails=="sjbc"){ | ||
| 327 | - type = "实际班次" | ||
| 328 | - } else if(itemDetails=="jhbc"){ | ||
| 329 | - type = "计划班次" | ||
| 330 | - } else if(itemDetails=="dh"){ | ||
| 331 | - type = "耗电量" | ||
| 332 | - } else if(itemDetails=="cdl"){ | ||
| 333 | - type = "充电量" | ||
| 334 | - } else if(itemDetails=="cccd"){ | ||
| 335 | - type = "出场存电" | ||
| 336 | - } else if(itemDetails=="jccd"){ | ||
| 337 | - type = "进场存电" | ||
| 338 | - } else if(itemDetails=="bgldh"){ | ||
| 339 | - type = "百公里电耗" | ||
| 340 | - } | ||
| 341 | - datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细月报表("+type+")"; | ||
| 342 | $post("/report/calcDetailMonthlyE",datas,function(result){ | 345 | $post("/report/calcDetailMonthlyE",datas,function(result){ |
| 343 | window.open("/downloadFile/download?fileName="+datas.name); | 346 | window.open("/downloadFile/download?fileName="+datas.name); |
| 344 | }); | 347 | }); |
src/main/resources/static/pages/forms/calc/calcDetailYear.html
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | 29 | ||
| 30 | #analy_body{ | 30 | #analy_body{ |
| 31 | margin-top: 20px; | 31 | margin-top: 20px; |
| 32 | - height: 650px; | 32 | + height: 620px; |
| 33 | width: 100% | 33 | width: 100% |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
| 46 | 46 | ||
| 47 | .table_body{ | 47 | .table_body{ |
| 48 | width:101%; | 48 | width:101%; |
| 49 | - height:620px; | 49 | + height:580px; |
| 50 | overflow: auto; | 50 | overflow: auto; |
| 51 | margin-top: -20px; | 51 | margin-top: -20px; |
| 52 | } | 52 | } |
| @@ -263,6 +263,44 @@ | @@ -263,6 +263,44 @@ | ||
| 263 | datas.itemDetails = $("#itemDetails").val(); | 263 | datas.itemDetails = $("#itemDetails").val(); |
| 264 | datas.item = item; | 264 | datas.item = item; |
| 265 | 265 | ||
| 266 | + var itemDetails = datas.itemDetails, | ||
| 267 | + type = "加注量[全部]"; | ||
| 268 | + if(itemDetails=="jzl0"){ | ||
| 269 | + type = "加注量[0#]" | ||
| 270 | + } else if(itemDetails=="jzl-10"){ | ||
| 271 | + type = "加注量[-10#]" | ||
| 272 | + } else if(itemDetails=="yhl"){ | ||
| 273 | + type = "油耗量" | ||
| 274 | + } else if(itemDetails=="cccy"){ | ||
| 275 | + type = "出场存油" | ||
| 276 | + } else if(itemDetails=="jccy"){ | ||
| 277 | + type = "进场存油" | ||
| 278 | + } else if(itemDetails=="bglyh"){ | ||
| 279 | + type = "百公里油耗" | ||
| 280 | + } else if(itemDetails=="zgl"){ | ||
| 281 | + type = "总公里" | ||
| 282 | + } else if(itemDetails=="jhgl"){ | ||
| 283 | + type = "计划公里" | ||
| 284 | + } else if(itemDetails=="jclm"){ | ||
| 285 | + type = "进场路码" | ||
| 286 | + } else if(itemDetails=="cclm"){ | ||
| 287 | + type = "出场路码" | ||
| 288 | + } else if(itemDetails=="sjbc"){ | ||
| 289 | + type = "实际班次" | ||
| 290 | + } else if(itemDetails=="jhbc"){ | ||
| 291 | + type = "计划班次" | ||
| 292 | + } else if(itemDetails=="dh"){ | ||
| 293 | + type = "耗电量" | ||
| 294 | + } else if(itemDetails=="cdl"){ | ||
| 295 | + type = "充电量" | ||
| 296 | + } else if(itemDetails=="cccd"){ | ||
| 297 | + type = "出场存电" | ||
| 298 | + } else if(itemDetails=="jccd"){ | ||
| 299 | + type = "进场存电" | ||
| 300 | + } else if(itemDetails=="bgldh"){ | ||
| 301 | + type = "百公里电耗" | ||
| 302 | + } | ||
| 303 | + datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细年报表("+type+")"; | ||
| 266 | if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ | 304 | if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ |
| 267 | layer.msg('请选择时间段!'); | 305 | layer.msg('请选择时间段!'); |
| 268 | }else if(endTime<startTime){ | 306 | }else if(endTime<startTime){ |
| @@ -284,7 +322,7 @@ | @@ -284,7 +322,7 @@ | ||
| 284 | return; | 322 | return; |
| 285 | }else | 323 | }else |
| 286 | $("#export").removeAttr("disabled"); | 324 | $("#export").removeAttr("disabled"); |
| 287 | - var htmlHead = "", htmlBody = ""; | 325 | + var htmlHead = "<tr><td colspan='"+rs[0].length+"'>"+datas.name+"</td></tr>", htmlBody = ""; |
| 288 | var rsLength = rs.length; | 326 | var rsLength = rs.length; |
| 289 | rs.forEach(function (o, i) { | 327 | rs.forEach(function (o, i) { |
| 290 | var html = "<tr>" | 328 | var html = "<tr>" |
| @@ -292,12 +330,14 @@ | @@ -292,12 +330,14 @@ | ||
| 292 | var colspan; | 330 | var colspan; |
| 293 | if (i == rsLength - 1 && j == 0) { | 331 | if (i == rsLength - 1 && j == 0) { |
| 294 | colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); | 332 | colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); |
| 333 | + if(statisticalObj == "cl") | ||
| 334 | + colspan = "colspan='6'"; | ||
| 295 | } | 335 | } |
| 296 | html += "<td " + colspan + ">" + td + "</td>" | 336 | html += "<td " + colspan + ">" + td + "</td>" |
| 297 | }); | 337 | }); |
| 298 | html += "</tr>" | 338 | html += "</tr>" |
| 299 | if (i == 0) { | 339 | if (i == 0) { |
| 300 | - htmlHead = html; | 340 | + htmlHead += html; |
| 301 | } else | 341 | } else |
| 302 | htmlBody += html; | 342 | htmlBody += html; |
| 303 | }); | 343 | }); |
| @@ -310,44 +350,6 @@ | @@ -310,44 +350,6 @@ | ||
| 310 | }); | 350 | }); |
| 311 | 351 | ||
| 312 | $("#export").on("click",function(){ | 352 | $("#export").on("click",function(){ |
| 313 | - var itemDetails = datas.itemDetails, | ||
| 314 | - type = "加注量[全部]"; | ||
| 315 | - if(itemDetails=="jzl0"){ | ||
| 316 | - type = "加注量[0#]" | ||
| 317 | - } else if(itemDetails=="jzl-10"){ | ||
| 318 | - type = "加注量[-10#]" | ||
| 319 | - } else if(itemDetails=="yhl"){ | ||
| 320 | - type = "油耗量" | ||
| 321 | - } else if(itemDetails=="cccy"){ | ||
| 322 | - type = "出场存油" | ||
| 323 | - } else if(itemDetails=="jccy"){ | ||
| 324 | - type = "进场存油" | ||
| 325 | - } else if(itemDetails=="bglyh"){ | ||
| 326 | - type = "百公里油耗" | ||
| 327 | - } else if(itemDetails=="zgl"){ | ||
| 328 | - type = "总公里" | ||
| 329 | - } else if(itemDetails=="jhgl"){ | ||
| 330 | - type = "计划公里" | ||
| 331 | - } else if(itemDetails=="jclm"){ | ||
| 332 | - type = "进场路码" | ||
| 333 | - } else if(itemDetails=="cclm"){ | ||
| 334 | - type = "出场路码" | ||
| 335 | - } else if(itemDetails=="sjbc"){ | ||
| 336 | - type = "实际班次" | ||
| 337 | - } else if(itemDetails=="jhbc"){ | ||
| 338 | - type = "计划班次" | ||
| 339 | - } else if(itemDetails=="dh"){ | ||
| 340 | - type = "耗电量" | ||
| 341 | - } else if(itemDetails=="cdl"){ | ||
| 342 | - type = "充电量" | ||
| 343 | - } else if(itemDetails=="cccd"){ | ||
| 344 | - type = "出场存电" | ||
| 345 | - } else if(itemDetails=="jccd"){ | ||
| 346 | - type = "进场存电" | ||
| 347 | - } else if(itemDetails=="bgldh"){ | ||
| 348 | - type = "百公里电耗" | ||
| 349 | - } | ||
| 350 | - datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细年报表("+type+")"; | ||
| 351 | $post("/report/calcDetailMonthlyE",datas,function(result){ | 353 | $post("/report/calcDetailMonthlyE",datas,function(result){ |
| 352 | window.open("/downloadFile/download?fileName="+datas.name); | 354 | window.open("/downloadFile/download?fileName="+datas.name); |
| 353 | }); | 355 | }); |
src/main/resources/static/pages/forms/mould/cardSheetList.xls
0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/mould/cardSheetList1.xls
0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/mould/cardSheetList2.xls
0 → 100644
No preview for this file type
src/main/resources/static/pages/report/cardInsertion/cardInsertionList.html
0 → 100644
| 1 | +<style type="text/css"> | ||
| 2 | + .table-bordered { | ||
| 3 | + border: 1px solid; } | ||
| 4 | + .table-bordered > thead > tr > th, | ||
| 5 | + .table-bordered > thead > tr > td, | ||
| 6 | + .table-bordered > tbody > tr > th, | ||
| 7 | + .table-bordered > tbody > tr > td, | ||
| 8 | + .table-bordered > tfoot > tr > th, | ||
| 9 | + .table-bordered > tfoot > tr > td { | ||
| 10 | + border: 1px solid; } | ||
| 11 | + .table-bordered > thead > tr > th, | ||
| 12 | + .table-bordered > thead > tr > td { | ||
| 13 | + border-bottom-width: 2px; } | ||
| 14 | + | ||
| 15 | + .table > tbody + tbody { | ||
| 16 | + border-top: 1px solid; } | ||
| 17 | +</style> | ||
| 18 | + | ||
| 19 | +<div class="page-head"> | ||
| 20 | + <div class="page-title"> | ||
| 21 | + <h1>线路签卡率</h1> | ||
| 22 | + </div> | ||
| 23 | +</div> | ||
| 24 | + | ||
| 25 | +<div class="row"> | ||
| 26 | + <div class="col-md-12"> | ||
| 27 | + <div class="portlet light porttlet-fit bordered"> | ||
| 28 | + <div class="portlet-title"> | ||
| 29 | + <form class="form-inline" action=""> | ||
| 30 | + <div style="display: inline-block; margin-left: 61px;" id="gsdmDiv"> | ||
| 31 | + <span class="item-label" style="width: 80px;">公司: </span> <select | ||
| 32 | + class="form-control" name="company" id="gsdm" | ||
| 33 | + style="width: 180px;"></select> | ||
| 34 | + </div> | ||
| 35 | + <div style="display: inline-block; margin-left: 38px;" | ||
| 36 | + id="fgsdmDiv"> | ||
| 37 | + <span class="item-label" style="width: 80px;">分公司: </span> <select | ||
| 38 | + class="form-control" name="subCompany" id="fgsdm" | ||
| 39 | + style="width: 180px;"></select> | ||
| 40 | + </div> | ||
| 41 | + | ||
| 42 | + <div style="display: inline-block; margin-left: 53px;"> | ||
| 43 | + <span class="item-label" style="width: 80px;">线路: </span> <select | ||
| 44 | + class="form-control" name="line" id="line" style="width: 180px;"></select> | ||
| 45 | + </div> | ||
| 46 | + <div style="margin-top: 10px"></div> | ||
| 47 | + <div style="display: inline-block; margin-left: 33px;"> | ||
| 48 | + <span class="item-label" style="width: 80px;">线路性质: </span> <select | ||
| 49 | + class="form-control" name="nature" id="nature" | ||
| 50 | + style="width: 180px;"> | ||
| 51 | + <option value="0">全部线路</option> | ||
| 52 | + <option value="1" selected="selected">营运线路</option> | ||
| 53 | + <option value="2">非营运线路</option> | ||
| 54 | + </select> | ||
| 55 | + </div> | ||
| 56 | + <div style="display: inline-block;"> | ||
| 57 | + <span class="item-label" style="width: 80px; margin-left: 24px;">开始时间: | ||
| 58 | + </span> <input class="form-control" type="text" id="date" | ||
| 59 | + style="width: 180px;" /> | ||
| 60 | + </div> | ||
| 61 | + <div style="display: inline-block;"> | ||
| 62 | + <span class="item-label" style="width: 80px; margin-left: 24px;">结束时间: | ||
| 63 | + </span> <input class="form-control" type="text" id="endDate" | ||
| 64 | + style="width: 180px;" /> | ||
| 65 | + </div> | ||
| 66 | + | ||
| 67 | + <div class="form-group"> | ||
| 68 | + <input type="hidden" id="id" /> <input class="btn btn-default" | ||
| 69 | + type="button" id="query" value="查询" /> <input | ||
| 70 | + class="btn btn-default" type="button" id="export" value="导出" /> | ||
| 71 | + </div> | ||
| 72 | + </form> | ||
| 73 | + </div> | ||
| 74 | + <div class="portlet-body"> | ||
| 75 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | ||
| 76 | + <table class="table table-bordered table-hover table-checkable" id="forms"> | ||
| 77 | + <thead> | ||
| 78 | + <tr> | ||
| 79 | + <td>公司</td> | ||
| 80 | + <td>分公司</td> | ||
| 81 | + <td>线路</td> | ||
| 82 | + <td>班次数</td> | ||
| 83 | + <td>签卡班次</td> | ||
| 84 | + <td>签卡率</td> | ||
| 85 | + <td>人卡故障班次</td> | ||
| 86 | + <td>人卡故障率</td> | ||
| 87 | + <td>车卡故障班次</td> | ||
| 88 | + <td>车卡故障数率</td> | ||
| 89 | + <td>查看</td> | ||
| 90 | + </tr> | ||
| 91 | + </thead> | ||
| 92 | + | ||
| 93 | + <tbody> | ||
| 94 | + | ||
| 95 | + </tbody> | ||
| 96 | + </table> | ||
| 97 | + | ||
| 98 | + | ||
| 99 | + </div> | ||
| 100 | + | ||
| 101 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | ||
| 102 | + <input class="btn btn-default hidden" type="button" id="export_1" value="导出"/> | ||
| 103 | + <table class="table table-bordered table-hover table-checkable" id="forms_1"> | ||
| 104 | + <thead> | ||
| 105 | + <tr class="hidden"> | ||
| 106 | + <td>公司</td> | ||
| 107 | + <td>分公司</td> | ||
| 108 | + <td>线路</td> | ||
| 109 | + <td>日期</td> | ||
| 110 | + <td>班次数</td> | ||
| 111 | + <td>人卡故障班次</td> | ||
| 112 | + <td>人卡故障率</td> | ||
| 113 | + <td>查看</td> | ||
| 114 | + <td>车卡故障班次</td> | ||
| 115 | + <td>车卡故障率</td> | ||
| 116 | + <td>查看</td> | ||
| 117 | + </tr> | ||
| 118 | + </thead> | ||
| 119 | + | ||
| 120 | + <tbody> | ||
| 121 | + | ||
| 122 | + </tbody> | ||
| 123 | + </table> | ||
| 124 | + | ||
| 125 | + </div> | ||
| 126 | + </div> | ||
| 127 | + </div> | ||
| 128 | + </div> | ||
| 129 | +</div> | ||
| 130 | +<script src="/pages/mforms/singledatas/jquery.table2excel.min.js"></script> | ||
| 131 | +<script> | ||
| 132 | + $(function(){ | ||
| 133 | + // 关闭左侧栏 | ||
| 134 | + if (!$('body').hasClass('page-sidebar-closed')) | ||
| 135 | + $('.menu-toggler.sidebar-toggler').click(); | ||
| 136 | + | ||
| 137 | + var d = new Date(); | ||
| 138 | + d.setTime(d.getTime() - 1*1000*60*60*24); | ||
| 139 | + var year = d.getFullYear(); | ||
| 140 | + var month = d.getMonth() + 1; | ||
| 141 | + var day = d.getDate(); | ||
| 142 | + if(month < 10) | ||
| 143 | + month = "0"+month; | ||
| 144 | + if(day < 10) | ||
| 145 | + day = "0"+day; | ||
| 146 | + var dateTime = year + "-" + month + "-" + day; | ||
| 147 | + $("#date").datetimepicker({ | ||
| 148 | + format : 'YYYY-MM-DD', | ||
| 149 | + locale : 'zh-cn', | ||
| 150 | + maxDate : dateTime | ||
| 151 | + }); | ||
| 152 | + $("#endDate").datetimepicker({ | ||
| 153 | + format : 'YYYY-MM-DD', | ||
| 154 | + locale : 'zh-cn', | ||
| 155 | + maxDate : dateTime | ||
| 156 | + }); | ||
| 157 | + $("#date").val(dateTime); | ||
| 158 | + $("#endDate").val(dateTime); | ||
| 159 | + | ||
| 160 | + var fage=true; | ||
| 161 | + var obj = []; | ||
| 162 | + var xlList; | ||
| 163 | + $.get('/report/lineList',function(result){ | ||
| 164 | + xlList=result; | ||
| 165 | + | ||
| 166 | + $.get('/user/companyData', function(result){ | ||
| 167 | + obj = result; | ||
| 168 | + var options = ''; | ||
| 169 | + for(var i = 0; i < obj.length; i++){ | ||
| 170 | + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; | ||
| 171 | + } | ||
| 172 | + if(obj.length ==0){ | ||
| 173 | + $("#gsdmDiv").css('display','none'); | ||
| 174 | + }else if(obj.length ==1){ | ||
| 175 | + $("#gsdmDiv").css('display','none'); | ||
| 176 | + if(obj[0].children.length == 1 || obj[0].children.length ==0){ | ||
| 177 | + $('#fgsdmDiv').css('display','none'); | ||
| 178 | + fage=false; | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + $('#gsdm').html(options); | ||
| 182 | + | ||
| 183 | + updateCompany(); | ||
| 184 | + }); | ||
| 185 | + }); | ||
| 186 | + | ||
| 187 | + $("#gsdm").on("change",updateCompany); | ||
| 188 | + function updateCompany(){ | ||
| 189 | + var company = $('#gsdm').val(); | ||
| 190 | + var options =''; | ||
| 191 | + if(fage){ | ||
| 192 | + options = '<option value="">请选择</option>'; | ||
| 193 | + } | ||
| 194 | + for(var i = 0; i < obj.length; i++){ | ||
| 195 | + if(obj[i].companyCode == company){ | ||
| 196 | + var children = obj[i].children; | ||
| 197 | + for(var j = 0; j < children.length; j++){ | ||
| 198 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + $('#fgsdm').html(options); | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + var tempData = {}; | ||
| 206 | + $.get('/report/lineList',function(xlList){ | ||
| 207 | + var data = []; | ||
| 208 | + data.push({id: " ", text: "全部线路"}); | ||
| 209 | + $.get('/user/companyData', function(result){ | ||
| 210 | + for(var i = 0; i < result.length; i++){ | ||
| 211 | + var companyCode = result[i].companyCode; | ||
| 212 | + var children = result[i].children; | ||
| 213 | + for(var j = 0; j < children.length; j++){ | ||
| 214 | + var code = children[j].code; | ||
| 215 | + for(var k=0;k < xlList.length;k++ ){ | ||
| 216 | + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){ | ||
| 217 | + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]}); | ||
| 218 | + tempData[xlList[k]["xlbm"]] = companyCode+":"+code; | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + initPinYinSelect2('#line',data,''); | ||
| 224 | + | ||
| 225 | + }); | ||
| 226 | + }); | ||
| 227 | + | ||
| 228 | + $("#line").on("change", function(){ | ||
| 229 | + if($("#line").val() == " "){ | ||
| 230 | + $("#gsdm").attr("disabled", false); | ||
| 231 | + $("#fgsdm").attr("disabled", false); | ||
| 232 | + } else { | ||
| 233 | + var temp = tempData[$("#line").val()].split(":"); | ||
| 234 | + $("#gsdm").val(temp[0]); | ||
| 235 | + updateCompany(); | ||
| 236 | + $("#fgsdm").val(temp[1]); | ||
| 237 | + $("#nature").val(0); | ||
| 238 | + $("#gsdm").attr("disabled", true); | ||
| 239 | + $("#fgsdm").attr("disabled", true); | ||
| 240 | + } | ||
| 241 | + }); | ||
| 242 | + | ||
| 243 | + $("#export").attr('disabled',"true"); | ||
| 244 | + | ||
| 245 | + //查询 | ||
| 246 | + $("#query").on('click',function(){ | ||
| 247 | + var line = $("#line").val(); | ||
| 248 | + var date = $("#date").val(); | ||
| 249 | + var endDate = $("#endDate").val(); | ||
| 250 | + var fgs=$('#fgsdm').val(); | ||
| 251 | + var gs=$('#gsdm').val(); | ||
| 252 | + var nature=$("#nature").val(); | ||
| 253 | + var i = layer.load(2); | ||
| 254 | + $get('/CardSigning/cardList',{line:line,date:date,endDate:endDate,gs:gs,fgs:fgs,nature:nature,type:'query'},function(result){ | ||
| 255 | + layer.close(i); | ||
| 256 | + var calcSheetList = template('calcSheetList',{list:result}); | ||
| 257 | + $('#forms tbody').html(calcSheetList); | ||
| 258 | + $('.btn-calcSheetList').on('click', showcalcSheetList); | ||
| 259 | + | ||
| 260 | + if(result.length == 0) | ||
| 261 | + $("#export").attr('disabled',"true"); | ||
| 262 | + else | ||
| 263 | + $("#export").removeAttr("disabled"); | ||
| 264 | + }); | ||
| 265 | + | ||
| 266 | + }); | ||
| 267 | + function showcalcSheetList(){ | ||
| 268 | + var id = $(this).data('id'); | ||
| 269 | + var date = $("#date").val(); | ||
| 270 | + var endDate = $("#endDate").val(); | ||
| 271 | + $("#id").val(id); | ||
| 272 | + $get('/CardSigning/calcListSheet',{line:id,date:date,endDate:endDate,type:'query'},function(result){ | ||
| 273 | + var calcSheetList = template('calcSheetList_1',{list:result}); | ||
| 274 | + $('#forms_1 tbody').html(calcSheetList); | ||
| 275 | + $('.btn-calcSheetList_1').on('click', opencalcSheetList); | ||
| 276 | + $('.btn-calcSheetList_2').on('click', opencalcSheetList2); | ||
| 277 | + $("#forms_1 .hidden").removeClass("hidden"); | ||
| 278 | + $("html,body").animate({scrollTop:$("#forms_1").offset().top},1000); | ||
| 279 | + $("#export_1").removeClass("hidden"); | ||
| 280 | + }); | ||
| 281 | + } | ||
| 282 | + function opencalcSheetList(){ | ||
| 283 | + var id = $(this).data('id'); | ||
| 284 | + id += ","+$(this).data('date')+",1"; | ||
| 285 | + $.get('/pages/report/cardInsertion/cardList.html', function (content) { | ||
| 286 | + layer.open({ | ||
| 287 | + type: 1, | ||
| 288 | + area: ['800px', '600px'], | ||
| 289 | + content: content, | ||
| 290 | + title: '线路签卡故障率详细', | ||
| 291 | + shift: 5, | ||
| 292 | + scrollbar: false, | ||
| 293 | + success: function () { | ||
| 294 | + $('#calcSheetList').trigger('init', id); | ||
| 295 | + } | ||
| 296 | + }); | ||
| 297 | + }); | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + function opencalcSheetList2(){ | ||
| 301 | + var id = $(this).data('id'); | ||
| 302 | + id += ","+$(this).data('date')+",2"; | ||
| 303 | + $.get('/pages/report/cardInsertion/cardList.html', function (content) { | ||
| 304 | + layer.open({ | ||
| 305 | + type: 1, | ||
| 306 | + area: ['800px', '600px'], | ||
| 307 | + content: content, | ||
| 308 | + title: '线路签卡故障率详细', | ||
| 309 | + shift: 5, | ||
| 310 | + scrollbar: false, | ||
| 311 | + success: function () { | ||
| 312 | + $('#calcSheetList').trigger('init', id); | ||
| 313 | + } | ||
| 314 | + }); | ||
| 315 | + }); | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + $("#export").on("click",function(){ | ||
| 319 | + var line = $("#line").val(); | ||
| 320 | + var date = $("#date").val(); | ||
| 321 | + var endDate = $("#endDate").val(); | ||
| 322 | + var fgs=$('#fgsdm').val(); | ||
| 323 | + var gs=$('#gsdm').val(); | ||
| 324 | + var nature=$("#nature").val(); | ||
| 325 | + var lineName = $('#line option:selected').text(); | ||
| 326 | + if(lineName == "全部线路") | ||
| 327 | + lineName = $('#fgsdm option:selected').text(); | ||
| 328 | + if(lineName == "请选择") | ||
| 329 | + lineName =$('#gsdm option:selected').text(); | ||
| 330 | + var i = layer.load(2); | ||
| 331 | + $get('/CardSigning/cardList',{line:line,date:date,endDate:endDate,gs:gs,fgs:fgs,nature:nature,type:'export'},function(result){ | ||
| 332 | + var dateTime = ""; | ||
| 333 | + if(date == endDate){ | ||
| 334 | + dateTime = moment(date).format("YYYYMMDD"); | ||
| 335 | + } else { | ||
| 336 | + dateTime = moment(date).format("YYYYMMDD")+"-"+ | ||
| 337 | + moment(endDate).format("YYYYMMDD"); | ||
| 338 | + } | ||
| 339 | + window.open("/downloadFile/download?fileName=" | ||
| 340 | + +dateTime+"-签卡率"); | ||
| 341 | + layer.close(i); | ||
| 342 | + }); | ||
| 343 | + }); | ||
| 344 | + | ||
| 345 | + $("#export_1").on("click",function(){ | ||
| 346 | + var id = $("#id").val(); | ||
| 347 | + var date = $("#date").val(); | ||
| 348 | + var endDate = $("#endDate").val(); | ||
| 349 | + var i = layer.load(2); | ||
| 350 | + $get('/CardSigning/calcListSheet',{line:id,date:date,endDate:endDate,type:'export'},function(result){ | ||
| 351 | + window.open("/downloadFile/download?fileName=班次故障率"+moment(date).format("YYYYMMDD")+"-"+moment(endDate).format("YYYYMMDD")); | ||
| 352 | + layer.close(i); | ||
| 353 | + }); | ||
| 354 | + }) | ||
| 355 | + | ||
| 356 | + }); | ||
| 357 | +</script> | ||
| 358 | +<script type="text/html" id="calcSheetList"> | ||
| 359 | + {{each list as obj i}} | ||
| 360 | + <tr> | ||
| 361 | + <td>{{obj.gsName}}</td> | ||
| 362 | + <td>{{obj.fgsName}}</td> | ||
| 363 | + <td>{{obj.xlName}}</td> | ||
| 364 | + <td>{{obj.bcs}}</td> | ||
| 365 | + <td>{{obj.qks}}</td> | ||
| 366 | + <td>{{obj.qklName}}</td> | ||
| 367 | + <td>{{obj.rkgzs}}</td> | ||
| 368 | + <td>{{obj.rkgzlName}}</td> | ||
| 369 | + <td>{{obj.ckgzs}}</td> | ||
| 370 | + <td>{{obj.ckgzlName}}</td> | ||
| 371 | + | ||
| 372 | + <td> | ||
| 373 | + <button type="button" class="btn btn-sm blue btn-calcSheetList" | ||
| 374 | + data-id="{{obj.xlBm}}">查看</button> | ||
| 375 | + </td> | ||
| 376 | + </tr> | ||
| 377 | + {{/each}} | ||
| 378 | + {{if list.length == 0}} | ||
| 379 | + <tr> | ||
| 380 | + <td colspan="11"><h6 class="muted">没有找到相关数据</h6></td> | ||
| 381 | + </tr> | ||
| 382 | + {{/if}} | ||
| 383 | +</script> | ||
| 384 | + | ||
| 385 | + | ||
| 386 | + | ||
| 387 | +<script type="text/html" id="calcSheetList_1"> | ||
| 388 | + {{each list as obj i}} | ||
| 389 | + <tr> | ||
| 390 | + <td>{{obj.gsName}}</td> | ||
| 391 | + <td>{{obj.fgsName}}</td> | ||
| 392 | + <td>{{obj.xlName}}</td> | ||
| 393 | + <td>{{obj.scheduleDateStr}}</td> | ||
| 394 | + <td>{{obj.bcs}}</td> | ||
| 395 | + <td>{{obj.rkgzs}}</td> | ||
| 396 | + <td>{{obj.rkgzlName}}</td> | ||
| 397 | + <td> | ||
| 398 | + <button type="button" class="btn btn-sm blue btn-calcSheetList_1" | ||
| 399 | + data-id="{{obj.xlBm}}" data-date="{{obj.scheduleDateStr}}">详细</button> | ||
| 400 | + </td> | ||
| 401 | + <td>{{obj.ckgzs}}</td> | ||
| 402 | + <td>{{obj.ckgzlName}}</td> | ||
| 403 | + <td> | ||
| 404 | + <button type="button" class="btn btn-sm blue btn-calcSheetList_2" | ||
| 405 | + data-id="{{obj.xlBm}}" data-date="{{obj.scheduleDateStr}}">详细</button> | ||
| 406 | + </td> | ||
| 407 | + </tr> | ||
| 408 | + {{/each}} | ||
| 409 | + {{if list.length == 0}} | ||
| 410 | + <tr> | ||
| 411 | + <td colspan="7"><h6 class="muted">没有找到相关数据</h6></td> | ||
| 412 | + </tr> | ||
| 413 | + {{/if}} | ||
| 414 | +</script> | ||
| 415 | + |