Commit 7b7bd6ff7e6557dd8cfa89ed5212bf839309608d
1 parent
acf67cf5
1.维修上报未设置默认状态码,造成全部显示为上报失败
Showing
1 changed file
with
6848 additions
and
6847 deletions
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| 1 | -package com.bsth.service.realcontrol.impl; | ||
| 2 | - | ||
| 3 | -import java.io.*; | ||
| 4 | -import java.lang.reflect.Field; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.net.HttpURLConnection; | ||
| 7 | -import java.net.MalformedURLException; | ||
| 8 | -import java.net.URL; | ||
| 9 | -import java.sql.ResultSet; | ||
| 10 | -import java.sql.SQLException; | ||
| 11 | -import java.text.DecimalFormat; | ||
| 12 | -import java.text.ParseException; | ||
| 13 | -import java.text.SimpleDateFormat; | ||
| 14 | -import java.util.ArrayList; | ||
| 15 | -import java.util.Calendar; | ||
| 16 | -import java.util.Collection; | ||
| 17 | -import java.util.Collections; | ||
| 18 | -import java.util.Comparator; | ||
| 19 | -import java.util.Date; | ||
| 20 | -import java.util.GregorianCalendar; | ||
| 21 | -import java.util.HashMap; | ||
| 22 | -import java.util.HashSet; | ||
| 23 | -import java.util.Iterator; | ||
| 24 | -import java.util.List; | ||
| 25 | -import java.util.Map; | ||
| 26 | -import java.util.Queue; | ||
| 27 | -import java.util.Set; | ||
| 28 | -import java.util.concurrent.*; | ||
| 29 | -import java.util.regex.Pattern; | ||
| 30 | - | ||
| 31 | -import com.bsth.entity.*; | ||
| 32 | -import com.bsth.util.*; | ||
| 33 | -import com.bsth.data.SystemParamCache; | ||
| 34 | -import org.apache.commons.io.IOUtils; | ||
| 35 | -import org.apache.commons.lang3.StringEscapeUtils; | ||
| 36 | -import org.apache.commons.lang3.StringUtils; | ||
| 37 | -import org.joda.time.DateTime; | ||
| 38 | -import org.joda.time.format.DateTimeFormat; | ||
| 39 | -import org.joda.time.format.DateTimeFormatter; | ||
| 40 | -import org.slf4j.Logger; | ||
| 41 | -import org.slf4j.LoggerFactory; | ||
| 42 | -import org.springframework.beans.factory.DisposableBean; | ||
| 43 | -import org.springframework.beans.factory.InitializingBean; | ||
| 44 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 45 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 46 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 47 | -import org.springframework.jdbc.core.RowMapper; | ||
| 48 | -import org.springframework.stereotype.Service; | ||
| 49 | -import org.springframework.transaction.annotation.Transactional; | ||
| 50 | - | ||
| 51 | -import com.alibaba.fastjson.JSON; | ||
| 52 | -import com.alibaba.fastjson.JSONArray; | ||
| 53 | -import com.alibaba.fastjson.JSONObject; | ||
| 54 | -import com.bsth.common.Constants; | ||
| 55 | -import com.bsth.common.ResponseCode; | ||
| 56 | -import com.bsth.controller.realcontrol.dto.ChangePersonCar; | ||
| 57 | -import com.bsth.controller.realcontrol.dto.DfsjChange; | ||
| 58 | -import com.bsth.controller.realcontrol.dto.LpData; | ||
| 59 | -import com.bsth.data.BasicData; | ||
| 60 | -import com.bsth.data.LineConfigData; | ||
| 61 | -import com.bsth.data.Station2ParkBuffer; | ||
| 62 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 63 | -import com.bsth.data.schedule.SchAttrCalculator; | ||
| 64 | -import com.bsth.data.schedule.ScheduleComparator; | ||
| 65 | -import com.bsth.data.schedule.edit_logs.FormLogger; | ||
| 66 | -import com.bsth.data.schedule.edit_logs.ScheduleModifyLogger; | ||
| 67 | -import com.bsth.data.schedule.edit_logs.loggers.AfterwardsLogger; | ||
| 68 | -import com.bsth.data.schedule.edit_logs.loggers.FcxxwtLogger; | ||
| 69 | -import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; | ||
| 70 | -import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | ||
| 71 | -import com.bsth.data.utils.CustomStringUtils; | ||
| 72 | -import com.bsth.entity.calc.CalcInterval; | ||
| 73 | -import com.bsth.entity.calc.CalcStatistics; | ||
| 74 | -import com.bsth.entity.oil.Dlb; | ||
| 75 | -import com.bsth.entity.oil.Qlb; | ||
| 76 | -import com.bsth.entity.oil.Ylb; | ||
| 77 | -import com.bsth.entity.oil.Ylxxb; | ||
| 78 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | ||
| 79 | -import com.bsth.entity.realcontrol.LineConfig; | ||
| 80 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 81 | -import com.bsth.entity.realcontrol.SvgAttribute; | ||
| 82 | -import com.bsth.entity.report.MileageReport; | ||
| 83 | -import com.bsth.entity.report.RepairReport; | ||
| 84 | -import com.bsth.entity.report.ScheduleCorrectionReport; | ||
| 85 | -import com.bsth.entity.schedule.CarConfigInfo; | ||
| 86 | -import com.bsth.entity.schedule.EmployeeConfigInfo; | ||
| 87 | -import com.bsth.entity.schedule.GuideboardInfo; | ||
| 88 | -import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 89 | -import com.bsth.entity.sys.Dictionary; | ||
| 90 | -import com.bsth.entity.sys.DutyEmployee; | ||
| 91 | -import com.bsth.entity.sys.SysUser; | ||
| 92 | -import com.bsth.repository.BusinessRepository; | ||
| 93 | -import com.bsth.repository.CarDeviceRepository; | ||
| 94 | -import com.bsth.repository.CarsRepository; | ||
| 95 | -import com.bsth.repository.LineRepository; | ||
| 96 | -import com.bsth.repository.RepairReportRepository; | ||
| 97 | -import com.bsth.repository.calc.CalcIntervalRepository; | ||
| 98 | -import com.bsth.repository.oil.DlbRepository; | ||
| 99 | -import com.bsth.repository.oil.QlbRepository; | ||
| 100 | -import com.bsth.repository.oil.YlbRepository; | ||
| 101 | -import com.bsth.repository.oil.YlxxbRepository; | ||
| 102 | -import com.bsth.repository.realcontrol.ChildTaskPlanRepository; | ||
| 103 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 104 | -import com.bsth.repository.realcontrol.SvgAttributeRepository; | ||
| 105 | -import com.bsth.repository.schedule.CarConfigInfoRepository; | ||
| 106 | -import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | ||
| 107 | -import com.bsth.repository.schedule.GuideboardInfoRepository; | ||
| 108 | -import com.bsth.security.util.SecurityUtils; | ||
| 109 | -import com.bsth.service.LineService; | ||
| 110 | -import com.bsth.service.SectionRouteService; | ||
| 111 | -import com.bsth.service.calc.CalcWaybillService; | ||
| 112 | -import com.bsth.service.directive.DirectiveService; | ||
| 113 | -import com.bsth.service.impl.BaseServiceImpl; | ||
| 114 | -import com.bsth.service.realcontrol.ScheduleRealInfoService; | ||
| 115 | -import com.bsth.service.report.CulateMileageService; | ||
| 116 | -import com.bsth.service.report.ReportService; | ||
| 117 | -import com.bsth.service.schedule.SchedulePlanInfoService; | ||
| 118 | -import com.bsth.service.sys.DictionaryService; | ||
| 119 | -import com.bsth.service.sys.DutyEmployeeService; | ||
| 120 | -import com.bsth.util.Arith; | ||
| 121 | -import com.bsth.util.ComparableChild; | ||
| 122 | -import com.bsth.util.ComparableLp; | ||
| 123 | -import com.bsth.util.ComparableReal; | ||
| 124 | -import com.bsth.util.DateUtils; | ||
| 125 | -import com.bsth.util.ReportRelatedUtils; | ||
| 126 | -import com.bsth.util.ReportUtils; | ||
| 127 | -import com.bsth.util.TimeUtils; | ||
| 128 | -import com.bsth.util.CoordinateConverter; | ||
| 129 | -import com.bsth.websocket.handler.SendUtils; | ||
| 130 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 131 | -import com.github.stuxuhai.jpinyin.PinyinException; | ||
| 132 | -import com.github.stuxuhai.jpinyin.PinyinFormat; | ||
| 133 | -import com.github.stuxuhai.jpinyin.PinyinHelper; | ||
| 134 | -import com.google.common.base.Splitter; | ||
| 135 | -import com.google.common.collect.Lists; | ||
| 136 | - | ||
| 137 | -@Service | ||
| 138 | -public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> | ||
| 139 | - implements ScheduleRealInfoService, InitializingBean, DisposableBean { | ||
| 140 | - @Autowired | ||
| 141 | - JdbcTemplate jdbcTemplate; | ||
| 142 | - @Autowired | ||
| 143 | - ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 144 | - | ||
| 145 | - @Autowired | ||
| 146 | - EmployeeConfigInfoRepository employeeConfigInfoRepository; | ||
| 147 | - | ||
| 148 | - @Autowired | ||
| 149 | - CarConfigInfoRepository carConfigInfoRepository; | ||
| 150 | - | ||
| 151 | - @Autowired | ||
| 152 | - SectionRouteService sectionRouteService; | ||
| 153 | - | ||
| 154 | - @Autowired | ||
| 155 | - CulateMileageService culateMieageService; | ||
| 156 | - | ||
| 157 | - @Autowired | ||
| 158 | - DictionaryService dictionaryService; | ||
| 159 | - | ||
| 160 | - @Autowired | ||
| 161 | - CalcWaybillService calcWaybillService; | ||
| 162 | - | ||
| 163 | - @Autowired | ||
| 164 | - CalcIntervalRepository calcIntervalRepository; | ||
| 165 | - | ||
| 166 | - @Autowired | ||
| 167 | - LineRepository lineRepository; | ||
| 168 | - @Autowired | ||
| 169 | - LineService lineService; | ||
| 170 | - @Autowired | ||
| 171 | - GuideboardInfoRepository guideboardInfoRepository; | ||
| 172 | - | ||
| 173 | - @Autowired | ||
| 174 | - ChildTaskPlanRepository cTaskPlanRepository; | ||
| 175 | - | ||
| 176 | - @Autowired | ||
| 177 | - SendUtils sendUtils; | ||
| 178 | - | ||
| 179 | - @Autowired | ||
| 180 | - DayOfSchedule dayOfSchedule; | ||
| 181 | - | ||
| 182 | - @Autowired | ||
| 183 | - SchAttrCalculator schAttrCalculator; | ||
| 184 | - | ||
| 185 | - @Autowired | ||
| 186 | - LineConfigData lineConfigData; | ||
| 187 | - | ||
| 188 | - @Autowired | ||
| 189 | - DutyEmployeeService dutyEmployeeService; | ||
| 190 | - | ||
| 191 | - @Autowired | ||
| 192 | - YlxxbRepository ylxxbRepository; | ||
| 193 | - | ||
| 194 | - @Autowired | ||
| 195 | - YlbRepository ylbRepository; | ||
| 196 | - | ||
| 197 | - @Autowired | ||
| 198 | - DlbRepository dlbRepository; | ||
| 199 | - | ||
| 200 | - @Autowired | ||
| 201 | - QlbRepository qlbRepository; | ||
| 202 | - | ||
| 203 | - @Autowired | ||
| 204 | - ReportService reposrService; | ||
| 205 | - | ||
| 206 | - @Autowired | ||
| 207 | - CulateMileageService culateService; | ||
| 208 | - | ||
| 209 | - @Autowired | ||
| 210 | - FormLogger schModifyLog; | ||
| 211 | - | ||
| 212 | - @Autowired | ||
| 213 | - DirectiveService directiveService; | ||
| 214 | - | ||
| 215 | - @Autowired | ||
| 216 | - CarDeviceRepository carDeviceRepository; | ||
| 217 | - | ||
| 218 | - @Autowired | ||
| 219 | - CarsRepository carsRepository; | ||
| 220 | - | ||
| 221 | - @Autowired | ||
| 222 | - BusinessRepository businessRepository; | ||
| 223 | - | ||
| 224 | - @Autowired | ||
| 225 | - RepairReportRepository repairReportRepository; | ||
| 226 | - | ||
| 227 | - private final static Logger logger = LoggerFactory.getLogger(ScheduleRealInfoServiceImpl.class); | ||
| 228 | - | ||
| 229 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 230 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 231 | - | ||
| 232 | - public static Map<String,String> DIRMAP = new ConcurrentHashMap<>(); // dvr电话 | ||
| 233 | - private Queue<RepairReport> queue = new ConcurrentLinkedQueue<>(); | ||
| 234 | - | ||
| 235 | - private ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { | ||
| 236 | - | ||
| 237 | - @Override | ||
| 238 | - public Thread newThread(Runnable r) { | ||
| 239 | - // TODO Auto-generated method stub | ||
| 240 | - Thread t = new Thread(r); | ||
| 241 | - t.setName("RepairReportReissuer"); | ||
| 242 | - | ||
| 243 | - return t; | ||
| 244 | - } | ||
| 245 | - }); | ||
| 246 | - | ||
| 247 | - | ||
| 248 | - | ||
| 249 | - private static Map<String, String> report2repair = new HashMap<String, String>(); | ||
| 250 | - | ||
| 251 | - static { | ||
| 252 | - report2repair.put("9101", "9109"); | ||
| 253 | - report2repair.put("9102", "9102"); | ||
| 254 | - report2repair.put("9103", "9103"); | ||
| 255 | - report2repair.put("9104", "9104"); | ||
| 256 | - report2repair.put("9109", "9109"); | ||
| 257 | - report2repair.put("9201", "9201"); | ||
| 258 | - report2repair.put("9202", "9202"); | ||
| 259 | - report2repair.put("9203", "9203"); | ||
| 260 | - report2repair.put("9204", "9204"); | ||
| 261 | - report2repair.put("9209", "9209"); | ||
| 262 | - report2repair.put("9301", "9301"); | ||
| 263 | - report2repair.put("9302", "9302"); | ||
| 264 | - report2repair.put("9303", "9303"); | ||
| 265 | - report2repair.put("9304", "9304"); | ||
| 266 | - report2repair.put("9305", "9305"); | ||
| 267 | - report2repair.put("9306", "9306"); | ||
| 268 | - report2repair.put("9309", "9309"); | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - | ||
| 272 | - /** | ||
| 273 | - * 校验人车 和 班次的公司和分公司归属 | ||
| 274 | - * | ||
| 275 | - * @param schId | ||
| 276 | - * @param jGh | ||
| 277 | - * @param sGh | ||
| 278 | - * @param nbbm | ||
| 279 | - * @return -2 跨营运公司,校验不过 | ||
| 280 | - * -1 跨分公司,二次确认 | ||
| 281 | - * 1 校验通过 | ||
| 282 | - */ | ||
| 283 | - @Override | ||
| 284 | - public Map<String, Object> checkPCFgsAscription(Long schId, String jGh, String sGh, String nbbm) { | ||
| 285 | - Map<String, Object> rs = new HashMap<>(); | ||
| 286 | - try { | ||
| 287 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 288 | - rs.put("checkStatus", -2); | ||
| 289 | - | ||
| 290 | - String msg = null; | ||
| 291 | - ScheduleRealInfo sch = dayOfSchedule.get(schId); | ||
| 292 | - String gsbm = sch.getGsBm(), fgsbm = sch.getFgsBm(); | ||
| 293 | - | ||
| 294 | - if (nbbm != null && !carExist(gsbm, nbbm)) { | ||
| 295 | - msg = sch.getGsName() + "没有自编号为" + "[" + nbbm + "]的车辆"; | ||
| 296 | - rs.put("msg", msg); | ||
| 297 | - return rs; | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - if (nbbm != null && !sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) { | ||
| 301 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + nbbm + "】的车辆"); | ||
| 302 | - return rs; | ||
| 303 | - } | ||
| 304 | - | ||
| 305 | - if (nbbm != null && !(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) { | ||
| 306 | - | ||
| 307 | - String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm)); | ||
| 308 | - | ||
| 309 | - msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!"); | ||
| 310 | - rs.put("msg", msg); | ||
| 311 | - rs.put("checkStatus", -1); | ||
| 312 | - return rs; | ||
| 313 | - } | ||
| 314 | - | ||
| 315 | - if(null != jGh && !"/".equals(StringUtils.trim(jGh))){ | ||
| 316 | - Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh); | ||
| 317 | - | ||
| 318 | - if (null == jsy) { | ||
| 319 | - msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员"; | ||
| 320 | - rs.put("msg", msg); | ||
| 321 | - return rs; | ||
| 322 | - } | ||
| 323 | - else if (!fgsbm.equals(jsy.getBrancheCompanyCode())) { | ||
| 324 | - //校验分公司 | ||
| 325 | - msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员"); | ||
| 326 | - rs.put("msg", msg); | ||
| 327 | - rs.put("checkStatus", -1); | ||
| 328 | - return rs; | ||
| 329 | - } | ||
| 330 | - } | ||
| 331 | - | ||
| 332 | - if (null != sGh && !"/".equals(StringUtils.trim(sGh))) { | ||
| 333 | - Personnel spy = BasicData.perMap.get(gsbm + "-" + sGh); | ||
| 334 | - if (null == spy) { | ||
| 335 | - msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员"; | ||
| 336 | - rs.put("msg", msg); | ||
| 337 | - return rs; | ||
| 338 | - } | ||
| 339 | - else if (!fgsbm.equals(spy.getBrancheCompanyCode())) { | ||
| 340 | - msg = ("【售票员】: " + sGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员"); | ||
| 341 | - rs.put("msg", msg); | ||
| 342 | - rs.put("checkStatus", -1); | ||
| 343 | - return rs; | ||
| 344 | - } | ||
| 345 | - } | ||
| 346 | - | ||
| 347 | - rs.put("checkStatus", 1); | ||
| 348 | - } catch (Exception e) { | ||
| 349 | - logger.error("", e); | ||
| 350 | - rs.put("status", ResponseCode.ERROR); | ||
| 351 | - } | ||
| 352 | - return rs; | ||
| 353 | - } | ||
| 354 | - | ||
| 355 | - | ||
| 356 | - /** | ||
| 357 | - * 车辆是否存在 | ||
| 358 | - * | ||
| 359 | - * @param gsbm 公司编码 | ||
| 360 | - * @param nbbm 车辆自编号 | ||
| 361 | - * @return | ||
| 362 | - */ | ||
| 363 | - private boolean carExist(String gsbm, String nbbm) { | ||
| 364 | - return BasicData.nbbm2CompanyCodeMap.containsKey(nbbm); | ||
| 365 | - } | ||
| 366 | - | ||
| 367 | - /** | ||
| 368 | - * 获取人员姓名 | ||
| 369 | - * | ||
| 370 | - * @param gsbm 公司编码 | ||
| 371 | - * @param gh 人员工号 | ||
| 372 | - * @return | ||
| 373 | - */ | ||
| 374 | - private String getPersonName(String gsbm, String gh) { | ||
| 375 | - return BasicData.allPerson.get(gsbm + '-' + gh); | ||
| 376 | - } | ||
| 377 | - | ||
| 378 | - @Override | ||
| 379 | - public Iterable<ScheduleRealInfo> list(Map<String, Object> map) { | ||
| 380 | - Iterator<ScheduleRealInfo> iterator = super.list(map).iterator(); | ||
| 381 | - Set<ScheduleRealInfo> set = new HashSet<>(100); | ||
| 382 | - | ||
| 383 | - DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | ||
| 384 | - //计算时间戳 | ||
| 385 | - ScheduleRealInfo sch; | ||
| 386 | - while (iterator.hasNext()) { | ||
| 387 | - sch = iterator.next(); | ||
| 388 | - //待发时间戳 | ||
| 389 | - sch.setDfsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getDfsj())); | ||
| 390 | - //实发时间戳 | ||
| 391 | - if (StringUtils.isNotEmpty(sch.getFcsjActual())) { | ||
| 392 | - sch.setFcsjActualTime(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsjActual())); | ||
| 393 | - } | ||
| 394 | - set.add(sch); | ||
| 395 | - } | ||
| 396 | - return set; | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | - @Override | ||
| 400 | - public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) { | ||
| 401 | - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines)); | ||
| 402 | - | ||
| 403 | - /*Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | ||
| 404 | - | ||
| 405 | - for (String lineCode : lineList) { | ||
| 406 | - mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode)); | ||
| 407 | - }*/ | ||
| 408 | - return dayOfSchedule.findByLineCodes(lineList); | ||
| 409 | - } | ||
| 410 | - | ||
| 411 | - private final static long DAY_TIME = 1000 * 60 * 60 * 24L; | ||
| 412 | - | ||
| 413 | - private static int BUF_SIZE = 1024; | ||
| 414 | - | ||
| 415 | - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 416 | - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | ||
| 417 | - | ||
| 418 | - @Override | ||
| 419 | - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType, String opType, String userId) { | ||
| 420 | - Map<String, Object> map = new HashMap<>(); | ||
| 421 | - try { | ||
| 422 | - | ||
| 423 | - ScheduleRealInfo schedule = dayOfSchedule.get(id); | ||
| 424 | - | ||
| 425 | - if (schedule.getStatus() > 0) { | ||
| 426 | - map.put("status", ResponseCode.SUCCESS); | ||
| 427 | - map.put("flag", "4008"); | ||
| 428 | - map.put("t", schedule); | ||
| 429 | - return map; | ||
| 430 | - } | ||
| 431 | - | ||
| 432 | - LineConfig config = lineConfigData.get(schedule.getXlBm()); | ||
| 433 | - //小于线路开始运营时间,则默认跨过24点 | ||
| 434 | - if (dfsj.compareTo(config.getStartOpt()) < 0) { | ||
| 435 | - schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME)); | ||
| 436 | - } else { | ||
| 437 | - schedule.setRealExecDate(schedule.getScheduleDateStr()); | ||
| 438 | - } | ||
| 439 | - | ||
| 440 | - //记录日志 | ||
| 441 | - ScheduleModifyLogger.dftz(schedule, opType, schedule.getDfsj(), dfsj, remarks, userId); | ||
| 442 | - | ||
| 443 | - schedule.setDfsjAll(dfsj); | ||
| 444 | - schedule.setDfAuto(false); | ||
| 445 | - if ("1".equals(opType)) | ||
| 446 | - schedule.setRemarks(remarks); | ||
| 447 | - | ||
| 448 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 449 | - ts.add(schedule); | ||
| 450 | - //调整终点时间和下一个班次的应到时间 | ||
| 451 | - //schedule.calcEndTime(); | ||
| 452 | - /*ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule); | ||
| 453 | - if (null != nextSch) { | ||
| 454 | - nextSch.setQdzArrDatejh(schedule.getZdsj()); | ||
| 455 | - ts.add(nextSch); | ||
| 456 | - }*/ | ||
| 457 | - | ||
| 458 | - //调整班次类型 | ||
| 459 | - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) { | ||
| 460 | - if ((schedule.getBcType().equals("major") | ||
| 461 | - || schedule.getBcType().equals("venting")) | ||
| 462 | - && bcType.equals("normal")) { | ||
| 463 | - //清空备注 | ||
| 464 | - schedule.setRemarks(""); | ||
| 465 | - } | ||
| 466 | - schedule.setBcType(bcType); | ||
| 467 | - } | ||
| 468 | - | ||
| 469 | - //如果正在执行该班次 | ||
| 470 | - //ScheduleRealInfo exec = dayOfSchedule.executeCurr(schedule.getClZbh()); | ||
| 471 | - //if(exec != null && exec == schedule){ | ||
| 472 | - //重新计算正在执行班次 | ||
| 473 | - dayOfSchedule.reCalcExecPlan(schedule.getClZbh()); | ||
| 474 | - //} | ||
| 475 | - | ||
| 476 | - //重新计算是否误点 | ||
| 477 | - schedule.reCalcLate(); | ||
| 478 | - //取消应发未到标记,不再自动调整待发 | ||
| 479 | - //if(schedule.isLate2()){ | ||
| 480 | - // schedule.setLate2(false); | ||
| 481 | - //LateAdjustHandle.remove(schedule); | ||
| 482 | - //} | ||
| 483 | - | ||
| 484 | - try { | ||
| 485 | - if (!schedule.getDirectiveState().equals(-1) && schedule.getStatus() == 0) { | ||
| 486 | - //重新下发调度指令 | ||
| 487 | - directiveService.send60Dispatch(schedule.getId(), "待发@系统"); | ||
| 488 | - } | ||
| 489 | - } catch (Exception e) { | ||
| 490 | - logger.error("", e); | ||
| 491 | - } | ||
| 492 | - | ||
| 493 | - // 持久化到数据库 | ||
| 494 | - dayOfSchedule.save(schedule); | ||
| 495 | - | ||
| 496 | - map.put("status", ResponseCode.SUCCESS); | ||
| 497 | - map.put("ts", ts); | ||
| 498 | - } catch (Exception e) { | ||
| 499 | - logger.error("", e); | ||
| 500 | - map.put("status", ResponseCode.ERROR); | ||
| 501 | - } | ||
| 502 | - return map; | ||
| 503 | - } | ||
| 504 | - | ||
| 505 | - @Override | ||
| 506 | - public Map<String, Object> destroy(String idsStr, String remarks, String reason, String userId) { | ||
| 507 | - | ||
| 508 | - Map<String, Object> map = new HashMap<>(); | ||
| 509 | - List<ScheduleRealInfo> rsList = new ArrayList<>(); | ||
| 510 | - map.put("ts", rsList); | ||
| 511 | - try { | ||
| 512 | - List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr)); | ||
| 513 | - | ||
| 514 | - ScheduleRealInfo schedule = null; | ||
| 515 | - for (String id : idList) { | ||
| 516 | - schedule = dayOfSchedule.get(Long.parseLong(id)); | ||
| 517 | - if (schedule.isDestroy()) { | ||
| 518 | - map.put("status", ResponseCode.ERROR); | ||
| 519 | - map.put("msg", "不必要的重复烂班!"); | ||
| 520 | - return map; | ||
| 521 | - } | ||
| 522 | - //记录日志 | ||
| 523 | - ScheduleModifyLogger.jhlb(schedule, remarks, userId); | ||
| 524 | - | ||
| 525 | - schedule.setAdjustExps(reason); | ||
| 526 | - schedule.destroy(); | ||
| 527 | - schedule.addRemarks(remarks); | ||
| 528 | - | ||
| 529 | - dayOfSchedule.save(schedule); | ||
| 530 | - rsList.add(schedule); | ||
| 531 | - } | ||
| 532 | - | ||
| 533 | - //重新计算当前执行班次 | ||
| 534 | - dayOfSchedule.reCalcExecPlan(schedule.getClZbh()); | ||
| 535 | - | ||
| 536 | - map.put("status", ResponseCode.SUCCESS); | ||
| 537 | - } catch (Exception e) { | ||
| 538 | - logger.error("", e); | ||
| 539 | - map.put("status", ResponseCode.ERROR); | ||
| 540 | - } | ||
| 541 | - return map; | ||
| 542 | - } | ||
| 543 | - | ||
| 544 | - // 线路id获取驾驶员 | ||
| 545 | - @Override | ||
| 546 | - public List<Map<String, String>> findDriverByLine(String lineCode) { | ||
| 547 | - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode); | ||
| 548 | - | ||
| 549 | - List<Map<String, String>> rsList = new ArrayList<>(); | ||
| 550 | - Map<String, String> map = null; | ||
| 551 | - Personnel driver = null; | ||
| 552 | - String code = null; | ||
| 553 | - | ||
| 554 | - for (EmployeeConfigInfo employee : list) { | ||
| 555 | - driver = employee.getJsy(); | ||
| 556 | - if (driver != null) { | ||
| 557 | - map = new HashMap<>(); | ||
| 558 | - code = driver.getJobCode(); | ||
| 559 | - map.put("id", code + "/" + driver.getPersonnelName()); | ||
| 560 | - map.put("text", code + "/" + driver.getPersonnelName()); | ||
| 561 | - rsList.add(map); | ||
| 562 | - } | ||
| 563 | - } | ||
| 564 | - return rsList; | ||
| 565 | - } | ||
| 566 | - | ||
| 567 | - // 线路id获取售票员 | ||
| 568 | - @Override | ||
| 569 | - public List<Map<String, String>> findConductorByLine(String lineCode) { | ||
| 570 | - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode); | ||
| 571 | - | ||
| 572 | - List<Map<String, String>> rsList = new ArrayList<>(); | ||
| 573 | - Map<String, String> map = null; | ||
| 574 | - Personnel conductor = null; | ||
| 575 | - String code = null; | ||
| 576 | - | ||
| 577 | - for (EmployeeConfigInfo employee : list) { | ||
| 578 | - conductor = employee.getSpy(); | ||
| 579 | - if (conductor != null) { | ||
| 580 | - code = conductor.getJobCode(); | ||
| 581 | - map = new HashMap<>(); | ||
| 582 | - map.put("id", code + "/" + conductor.getPersonnelName()); | ||
| 583 | - map.put("text", code + "/" + conductor.getPersonnelName()); | ||
| 584 | - rsList.add(map); | ||
| 585 | - } | ||
| 586 | - } | ||
| 587 | - return rsList; | ||
| 588 | - } | ||
| 589 | - | ||
| 590 | - @Override | ||
| 591 | - public List<Map<String, String>> findCarByLine(String lineCode) { | ||
| 592 | - | ||
| 593 | - List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode); | ||
| 594 | - | ||
| 595 | - List<Map<String, String>> rsList = new ArrayList<>(); | ||
| 596 | - Map<String, String> map = null; | ||
| 597 | - Cars car = null; | ||
| 598 | - String code = null; | ||
| 599 | - | ||
| 600 | - for (CarConfigInfo cci : list) { | ||
| 601 | - car = cci.getCl(); | ||
| 602 | - if (car != null) { | ||
| 603 | - code = car.getInsideCode(); | ||
| 604 | - map = new HashMap<>(); | ||
| 605 | - map.put("id", code); | ||
| 606 | - map.put("text", code); | ||
| 607 | - rsList.add(map); | ||
| 608 | - } | ||
| 609 | - } | ||
| 610 | - return rsList; | ||
| 611 | - } | ||
| 612 | - | ||
| 613 | - /** | ||
| 614 | - * 添加到历史库 | ||
| 615 | - * | ||
| 616 | - * @param t | ||
| 617 | - * @return | ||
| 618 | - */ | ||
| 619 | - @Override | ||
| 620 | - public Map<String, Object> addToHistory(ScheduleRealInfo t) { | ||
| 621 | - Map<String, Object> rs = new HashMap<>(); | ||
| 622 | - try { | ||
| 623 | - // 检查调度日期 | ||
| 624 | - DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 625 | - long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(t.getScheduleDateStr()); | ||
| 626 | - String clZbh = t.getClZbh(), lpName = t.getLpName(); | ||
| 627 | - if (today < scheduleDate || today - scheduleDate > 86400000 * PrivilegeUtils.getHistoryEditDays()) { | ||
| 628 | - rs.put("status", ResponseCode.ERROR); | ||
| 629 | - rs.put("msg", "无效的调度日期"); | ||
| 630 | - return rs; | ||
| 631 | - } | ||
| 632 | - if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) { | ||
| 633 | - rs.put("status", ResponseCode.ERROR); | ||
| 634 | - rs.put("msg", "路牌信息缺失"); | ||
| 635 | - return rs; | ||
| 636 | - } | ||
| 637 | - if (!carExist(t.getGsBm(), clZbh)) { | ||
| 638 | - rs.put("msg", "车辆 " + clZbh + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | ||
| 639 | - rs.put("status", ResponseCode.ERROR); | ||
| 640 | - return rs; | ||
| 641 | - } | ||
| 642 | - | ||
| 643 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 644 | - //String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm()); | ||
| 645 | - | ||
| 646 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | ||
| 647 | - | ||
| 648 | - if (StringUtils.isEmpty(t.getjGh())) { | ||
| 649 | - rs.put("status", ResponseCode.ERROR); | ||
| 650 | - rs.put("msg", "驾驶员工号不能为空!"); | ||
| 651 | - return rs; | ||
| 652 | - } | ||
| 653 | - //截取驾驶员工号 | ||
| 654 | - if (t.getjGh().indexOf("-") != -1) { | ||
| 655 | - t.setjGh(t.getjGh().split("-")[1]); | ||
| 656 | - } | ||
| 657 | - //检查驾驶员工号 | ||
| 658 | - String jName = getPersonName(t.getGsBm(), t.getjGh()); | ||
| 659 | - if (StringUtils.isEmpty(jName)) { | ||
| 660 | - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员"); | ||
| 661 | - rs.put("status", ResponseCode.ERROR); | ||
| 662 | - return rs; | ||
| 663 | - } else if (StringUtils.isEmpty(t.getjName())) { | ||
| 664 | - t.setjName(jName);//补上驾驶员名称 | ||
| 665 | - } | ||
| 666 | - | ||
| 667 | - //有售票员 | ||
| 668 | - if (StringUtils.isNotEmpty(t.getsGh())) { | ||
| 669 | - String sName = getPersonName(t.getGsBm(), t.getsGh()); | ||
| 670 | - if (StringUtils.isEmpty(sName)) { | ||
| 671 | - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员"); | ||
| 672 | - rs.put("status", ResponseCode.ERROR); | ||
| 673 | - return rs; | ||
| 674 | - } else if (StringUtils.isEmpty(t.getsName())) { | ||
| 675 | - t.setsName(sName);//补上售票员名称 | ||
| 676 | - } | ||
| 677 | - } else { | ||
| 678 | - t.setsGh(""); | ||
| 679 | - t.setsName(""); | ||
| 680 | - } | ||
| 681 | - | ||
| 682 | - //公司 和 分公司名称 | ||
| 683 | - t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm())); | ||
| 684 | - t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getFgsBm()+ "_" + t.getGsBm() )); | ||
| 685 | - | ||
| 686 | - //t.setScheduleDateStr(schDate); | ||
| 687 | - t.setScheduleDate(sdfyyyyMMdd.parse(t.getScheduleDateStr())); | ||
| 688 | - t.setRealExecDate(t.getScheduleDateStr()); | ||
| 689 | - t.setCreateBy(user); | ||
| 690 | - t.setSflj(true); | ||
| 691 | - t.setLate(false); | ||
| 692 | - t.setDfsj(t.getFcsj()); | ||
| 693 | - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime()); | ||
| 694 | - t.setJhlcOrig(t.getJhlc()); | ||
| 695 | - | ||
| 696 | - //班次历时 | ||
| 697 | - t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60); | ||
| 698 | - | ||
| 699 | - //起终点名称 | ||
| 700 | - String prefix = t.getXlBm() + "_" + t.getXlDir() + "_"; | ||
| 701 | - t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix)); | ||
| 702 | - t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix)); | ||
| 703 | - | ||
| 704 | - //计算班次实际执行时间 | ||
| 705 | - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t); | ||
| 706 | - //处理计达跨24点 | ||
| 707 | - LineConfig conf = lineConfigData.get(t.getXlBm()); | ||
| 708 | - if (t.getZdsj().compareTo(conf.getStartOpt()) < 0) { | ||
| 709 | - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime() + (1000 * 60 * 60 * 24)); | ||
| 710 | - } | ||
| 711 | - if (t.getZdsjT() < t.getFcsjT()) { | ||
| 712 | - rs.put("status", ResponseCode.ERROR); | ||
| 713 | - rs.put("msg", "起终点时间异常!"); | ||
| 714 | - return rs; | ||
| 715 | - } | ||
| 716 | - | ||
| 717 | - t.setId(dayOfSchedule.getId()); | ||
| 718 | - //实时入库 | ||
| 719 | - rs = super.save(t); | ||
| 720 | - } catch (Exception e) { | ||
| 721 | - logger.error("", e); | ||
| 722 | - rs.put("status", ResponseCode.ERROR); | ||
| 723 | - } | ||
| 724 | - return rs; | ||
| 725 | - } | ||
| 726 | - | ||
| 727 | - | ||
| 728 | - /** | ||
| 729 | - * 临加班次 | ||
| 730 | - */ | ||
| 731 | - @Override | ||
| 732 | - public Map<String, Object> save(ScheduleRealInfo sch) { | ||
| 733 | - Map<String, Object> rs = new HashMap<>(); | ||
| 734 | - try { | ||
| 735 | - String clZbh = sch.getClZbh(), lpName = sch.getLpName(); | ||
| 736 | - if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) { | ||
| 737 | - rs.put("status", ResponseCode.ERROR); | ||
| 738 | - rs.put("msg", "路牌信息缺失"); | ||
| 739 | - return rs; | ||
| 740 | - } | ||
| 741 | - if (StringUtils.isNotEmpty(clZbh)) { | ||
| 742 | - //检测 | ||
| 743 | - if (!carExist(sch.getGsBm(), clZbh)) { | ||
| 744 | - rs.put("status", ResponseCode.ERROR); | ||
| 745 | - rs.put("msg", "车辆 " + clZbh + " 不存在!"); | ||
| 746 | - return rs; | ||
| 747 | - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) { | ||
| 748 | - rs.put("status", ResponseCode.ERROR); | ||
| 749 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆"); | ||
| 750 | - return rs; | ||
| 751 | - } | ||
| 752 | - } | ||
| 753 | - | ||
| 754 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 755 | - String schDate = DayOfSchedule.currSchDateMap.get(sch.getXlBm()); | ||
| 756 | - | ||
| 757 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | ||
| 758 | - | ||
| 759 | - if (StringUtils.isEmpty(sch.getjGh())) { | ||
| 760 | - rs.put("status", ResponseCode.ERROR); | ||
| 761 | - rs.put("msg", "驾驶员工号不能为空!"); | ||
| 762 | - return rs; | ||
| 763 | - } | ||
| 764 | - //截取驾驶员工号 | ||
| 765 | - if (sch.getjGh().indexOf("-") != -1) { | ||
| 766 | - sch.setjGh(sch.getjGh().split("-")[1]); | ||
| 767 | - } | ||
| 768 | - //检查驾驶员工号 | ||
| 769 | - String jName = getPersonName(sch.getGsBm(), sch.getjGh()); | ||
| 770 | - if (StringUtils.isEmpty(jName)) { | ||
| 771 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | ||
| 772 | - rs.put("status", ResponseCode.ERROR); | ||
| 773 | - return rs; | ||
| 774 | - } else if (StringUtils.isEmpty(sch.getjName())) { | ||
| 775 | - sch.setjName(jName);//补上驾驶员名称 | ||
| 776 | - } | ||
| 777 | - | ||
| 778 | - //有售票员 | ||
| 779 | - if (StringUtils.isNotEmpty(sch.getsGh())) { | ||
| 780 | - String sName = getPersonName(sch.getGsBm(), sch.getsGh()); | ||
| 781 | - if (StringUtils.isEmpty(sName)) { | ||
| 782 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的售票员"); | ||
| 783 | - rs.put("status", ResponseCode.ERROR); | ||
| 784 | - return rs; | ||
| 785 | - } else if (StringUtils.isEmpty(sch.getsName())) { | ||
| 786 | - sch.setsName(sName);//补上售票员名称 | ||
| 787 | - } | ||
| 788 | - } else { | ||
| 789 | - sch.setsGh(""); | ||
| 790 | - sch.setsName(""); | ||
| 791 | - } | ||
| 792 | - | ||
| 793 | - //公司 和 分公司名称 | ||
| 794 | - sch.setGsName(BasicData.businessCodeNameMap.get(sch.getGsBm())); | ||
| 795 | - sch.setFgsName(BasicData.businessFgsCodeNameMap.get(sch.getFgsBm() + "_" + sch.getGsBm())); | ||
| 796 | - sch.setCreateDate(new Date()); | ||
| 797 | - sch.setScheduleDateStr(schDate); | ||
| 798 | - sch.setScheduleDate(sdfyyyyMMdd.parse(schDate)); | ||
| 799 | - sch.setRealExecDate(schDate); | ||
| 800 | - | ||
| 801 | - sch.setCreateBy(user); | ||
| 802 | - sch.setSflj(true); | ||
| 803 | - sch.setLate(false); | ||
| 804 | - sch.setDfsj(sch.getFcsj()); | ||
| 805 | - sch.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + sch.getZdsj()).getTime()); | ||
| 806 | - sch.setJhlcOrig(sch.getJhlc()); | ||
| 807 | - sch.setCreateDate(new Date()); | ||
| 808 | - sch.setUpdateDate(new Date()); | ||
| 809 | - sch.setSpId(-1L); | ||
| 810 | - //起终点名称 | ||
| 811 | - String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | ||
| 812 | - sch.setQdzName(BasicData.getStationNameByCode(sch.getQdzCode(), prefix)); | ||
| 813 | - sch.setZdzName(BasicData.getStationNameByCode(sch.getZdzCode(), prefix)); | ||
| 814 | - | ||
| 815 | - //计算班次实际执行时间 | ||
| 816 | - schAttrCalculator.calcRealDate(sch).calcAllTimeByFcsj(sch); | ||
| 817 | - | ||
| 818 | - //处理计达跨24点 | ||
| 819 | - LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 820 | - if (sch.getZdsj().compareTo(conf.getStartOpt()) < 0) { | ||
| 821 | - sch.setZdsjT(sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + sch.getZdsj()).getTime() + (1000 * 60 * 60 * 24)); | ||
| 822 | - } | ||
| 823 | - | ||
| 824 | - //班次历时 | ||
| 825 | - sch.setBcsj((int) ((sch.getZdsjT() - sch.getDfsjT()) / 1000 / 60)); | ||
| 826 | - if (sch.getZdsjT() < sch.getFcsjT()) { | ||
| 827 | - rs.put("status", ResponseCode.ERROR); | ||
| 828 | - rs.put("msg", "起终点时间异常!"); | ||
| 829 | - return rs; | ||
| 830 | - } | ||
| 831 | - | ||
| 832 | - sch.setId(dayOfSchedule.getId()); | ||
| 833 | - //实时入库 | ||
| 834 | - super.save(sch); | ||
| 835 | - | ||
| 836 | - // 加入缓存 | ||
| 837 | - dayOfSchedule.put(sch); | ||
| 838 | - | ||
| 839 | - //更新起点应到时间 | ||
| 840 | - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); | ||
| 841 | - | ||
| 842 | - //重新计算车辆当前执行班次 | ||
| 843 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 844 | - | ||
| 845 | - //记录站到场历时数据 | ||
| 846 | - Station2ParkBuffer.put(sch); | ||
| 847 | - | ||
| 848 | - rs.put("ts", ts); | ||
| 849 | - rs.put("t", sch); | ||
| 850 | - } catch (Exception e) { | ||
| 851 | - logger.error("", e); | ||
| 852 | - rs.put("status", ResponseCode.ERROR); | ||
| 853 | - } | ||
| 854 | - return rs; | ||
| 855 | - } | ||
| 856 | - | ||
| 857 | - /** | ||
| 858 | - * 删除历史表临加班次 | ||
| 859 | - * | ||
| 860 | - * @param id | ||
| 861 | - * @return | ||
| 862 | - */ | ||
| 863 | - @Override | ||
| 864 | - public Map<String, Object> deleteToHistory(Long id) { | ||
| 865 | - Map<String, Object> rs = new HashMap<>(); | ||
| 866 | - rs.put("status", ResponseCode.ERROR); | ||
| 867 | - | ||
| 868 | - try { | ||
| 869 | - ScheduleRealInfo sch = super.findById(id); | ||
| 870 | - if (sch == null) { | ||
| 871 | - rs.put("msg", "无效的id号"); | ||
| 872 | - return rs; | ||
| 873 | - } | ||
| 874 | - | ||
| 875 | - if (!sch.isSflj()) { | ||
| 876 | - rs.put("msg", "你只能删除临加班次"); | ||
| 877 | - return rs; | ||
| 878 | - } | ||
| 879 | - | ||
| 880 | - //解除和调度指令的外键约束 | ||
| 881 | - jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | ||
| 882 | - | ||
| 883 | - //数据库删除 | ||
| 884 | - rs = super.delete(id); | ||
| 885 | - } catch (Exception e) { | ||
| 886 | - logger.error("", e); | ||
| 887 | - rs.put("msg", e.getMessage()); | ||
| 888 | - } | ||
| 889 | - | ||
| 890 | - return rs; | ||
| 891 | - } | ||
| 892 | - | ||
| 893 | - @Override | ||
| 894 | - public Map<String, Object> delete(Long id) { | ||
| 895 | - Map<String, Object> rs = new HashMap<>(); | ||
| 896 | - rs.put("status", ResponseCode.ERROR); | ||
| 897 | - | ||
| 898 | - ScheduleRealInfo sch = null; | ||
| 899 | - try { | ||
| 900 | - sch = dayOfSchedule.get(id); | ||
| 901 | - if (sch == null) { | ||
| 902 | - rs.put("msg", "无效的id号"); | ||
| 903 | - return rs; | ||
| 904 | - } | ||
| 905 | - | ||
| 906 | - if (!sch.isSflj()) { | ||
| 907 | - rs.put("msg", "你只能删除临加班次"); | ||
| 908 | - return rs; | ||
| 909 | - } | ||
| 910 | - | ||
| 911 | - sch.setDeleted(true); | ||
| 912 | - //解除和调度指令的外键约束 | ||
| 913 | - jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | ||
| 914 | - | ||
| 915 | - //数据库删除 | ||
| 916 | - rs = super.delete(id); | ||
| 917 | - if (rs.get("status").equals(ResponseCode.SUCCESS)) { | ||
| 918 | - dayOfSchedule.delete(sch); | ||
| 919 | - //更新起点应到时间 | ||
| 920 | - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); | ||
| 921 | - rs.put("ts", ts); | ||
| 922 | - rs.put("delete", sch); | ||
| 923 | - } else | ||
| 924 | - sch.setDeleted(false); | ||
| 925 | - } catch (Exception e) { | ||
| 926 | - logger.error("", e); | ||
| 927 | - rs.put("msg", e.getMessage()); | ||
| 928 | - sch.setDeleted(false); | ||
| 929 | - } | ||
| 930 | - | ||
| 931 | - return rs; | ||
| 932 | - } | ||
| 933 | - | ||
| 934 | - @Override | ||
| 935 | - public List<Map<String, String>> sreachVehic(String nbbm) { | ||
| 936 | - // 转大写 | ||
| 937 | - nbbm = nbbm.toUpperCase(); | ||
| 938 | - | ||
| 939 | - List<Map<String, String>> list = new ArrayList<>(); | ||
| 940 | - Map<String, String> map; | ||
| 941 | - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet(); | ||
| 942 | - | ||
| 943 | - Line line; | ||
| 944 | - for (String k : allSet) { | ||
| 945 | - if (k.indexOf(nbbm) != -1) { | ||
| 946 | - // 所属线路 | ||
| 947 | - map = new HashMap<>(); | ||
| 948 | - line = BasicData.nbbm2LineMap.get(k); | ||
| 949 | - map.put("id", k); | ||
| 950 | - map.put("text", k); | ||
| 951 | - if (null != line) { | ||
| 952 | - map.put("lineName", line.getName()); | ||
| 953 | - map.put("lineCode", line.getLineCode()); | ||
| 954 | - } | ||
| 955 | - | ||
| 956 | - list.add(map); | ||
| 957 | - } | ||
| 958 | - | ||
| 959 | - if (list.size() > 20) | ||
| 960 | - break; | ||
| 961 | - } | ||
| 962 | - return list; | ||
| 963 | - } | ||
| 964 | - | ||
| 965 | - @Override | ||
| 966 | - public void adjustCar(ScheduleRealInfo schedule, String car) { | ||
| 967 | - schedule.setClZbh(car); | ||
| 968 | - } | ||
| 969 | - | ||
| 970 | - @Override | ||
| 971 | - public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) { | ||
| 972 | - if (driver.indexOf("-") != -1) | ||
| 973 | - driver = driver.split("-")[1]; | ||
| 974 | - schedule.setjGh(driver); | ||
| 975 | - schedule.setjName(driverName); | ||
| 976 | - } | ||
| 977 | - | ||
| 978 | - @Override | ||
| 979 | - public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) { | ||
| 980 | - if (conductor.indexOf("-") != -1) | ||
| 981 | - conductor = conductor.split("-")[1]; | ||
| 982 | - schedule.setsGh(conductor); | ||
| 983 | - schedule.setsName(conductorName); | ||
| 984 | - } | ||
| 985 | - | ||
| 986 | - @Override | ||
| 987 | - public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) { | ||
| 988 | - List<ScheduleRealInfo> scheduleRealInfos = new ArrayList<>(); | ||
| 989 | - List<Object[]> objects = null; | ||
| 990 | - if (state.equals("2")) { | ||
| 991 | - objects = scheduleRealInfoRepository.queryUserInfo2(line, date); | ||
| 992 | - for (Object[] objs : objects) { | ||
| 993 | - ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo(); | ||
| 994 | - scheduleRealInfo.setId((Long)objs[0]); | ||
| 995 | - scheduleRealInfo.setjGh((String)objs[1]); | ||
| 996 | - scheduleRealInfo.setClZbh((String)objs[2]); | ||
| 997 | - scheduleRealInfo.setLpName((String)objs[3]); | ||
| 998 | - scheduleRealInfo.setjName((String)objs[4]); | ||
| 999 | - | ||
| 1000 | - scheduleRealInfos.add(scheduleRealInfo); | ||
| 1001 | - } | ||
| 1002 | - } else { | ||
| 1003 | - objects = scheduleRealInfoRepository.queryUserInfo3(line, date); | ||
| 1004 | - for (Object[] objs : objects) { | ||
| 1005 | - ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo(); | ||
| 1006 | - scheduleRealInfo.setId((Long)objs[0]); | ||
| 1007 | - scheduleRealInfo.setClZbh((String)objs[1]); | ||
| 1008 | - | ||
| 1009 | - scheduleRealInfos.add(scheduleRealInfo); | ||
| 1010 | - } | ||
| 1011 | - } | ||
| 1012 | - | ||
| 1013 | - return scheduleRealInfos; | ||
| 1014 | - } | ||
| 1015 | - | ||
| 1016 | - @Override | ||
| 1017 | - public List<ScheduleRealInfo> queryUserInfoPx(String line, String date, String state, String type) { | ||
| 1018 | -// List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | ||
| 1019 | - state = state + ""; | ||
| 1020 | - String lpname = state; | ||
| 1021 | - String px = type; | ||
| 1022 | - if (state.equals("lpName")) { | ||
| 1023 | - state = state + "+1"; | ||
| 1024 | - type = "ASC"; | ||
| 1025 | - } | ||
| 1026 | - String minfcsj = "02:00"; | ||
| 1027 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 1028 | - if (lineList.size() > 0) { | ||
| 1029 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 1030 | - + " id = (" | ||
| 1031 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 1032 | - + ")"; | ||
| 1033 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 1034 | - } | ||
| 1035 | - String sqlPlan = "select * from (select * from (" | ||
| 1036 | - + " select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, " | ||
| 1037 | - + " s.lp_Name as lpName,min(s.j_Name) as jName,max(s.schedule_date_str) as dateStr ," | ||
| 1038 | - + " min(s.fcsj) as fcsj,1 as px from bsth_c_s_sp_info_real s where " | ||
| 1039 | - + " s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'" | ||
| 1040 | - + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name) x where x.fcsj >'" + minfcsj + "'" | ||
| 1041 | - + " UNION " | ||
| 1042 | - + " select * from ( select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, " | ||
| 1043 | - + " s.lp_Name as lpName,min(s.j_Name) as jName, max(s.schedule_date_str) as dateStr," | ||
| 1044 | - + " min(s.fcsj) as fcsj,2 as px from bsth_c_s_sp_info_real s " | ||
| 1045 | - + " where s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'" | ||
| 1046 | - + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name" | ||
| 1047 | - + " ) y where y.fcsj <='" + minfcsj + "') z order by (" + state + "),dateStr,px,fcsj " + type; | ||
| 1048 | - List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan, | ||
| 1049 | - new RowMapper<ScheduleRealInfo>() { | ||
| 1050 | - @Override | ||
| 1051 | - public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1052 | - ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 1053 | - t.setId(rs.getLong("id")); | ||
| 1054 | - t.setjGh(rs.getString("jGh")); | ||
| 1055 | - t.setClZbh(rs.getString("clZbh")); | ||
| 1056 | - t.setLpName(rs.getString("lpName")); | ||
| 1057 | - t.setjName(rs.getString("jName")); | ||
| 1058 | - t.setFcsj(rs.getString("fcsj")); | ||
| 1059 | - return t; | ||
| 1060 | - } | ||
| 1061 | - }); | ||
| 1062 | - if (lpname.equals("lpName")) { | ||
| 1063 | - | ||
| 1064 | - List<ScheduleRealInfo> listNew = new ArrayList<ScheduleRealInfo>(); | ||
| 1065 | - Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); | ||
| 1066 | -// if (px.equals("desc")) { | ||
| 1067 | - int zt = 0; | ||
| 1068 | - for (int l = 0; l < 2; l++) { | ||
| 1069 | - for (int i = 0; i < list.size(); i++) { | ||
| 1070 | - ScheduleRealInfo t = list.get(i); | ||
| 1071 | - if (t.getLpName().indexOf("+") != -1) { | ||
| 1072 | - if (zt == 0) { | ||
| 1073 | - listNew.add(t); | ||
| 1074 | - } | ||
| 1075 | - } else if (pattern.matcher(t.getLpName()).matches()) { | ||
| 1076 | - if (zt == 1) { | ||
| 1077 | - listNew.add(t); | ||
| 1078 | - } | ||
| 1079 | - } else { | ||
| 1080 | - continue; | ||
| 1081 | - } | ||
| 1082 | - } | ||
| 1083 | - zt++; | ||
| 1084 | - } | ||
| 1085 | - | ||
| 1086 | - Collections.sort(list, new ComparableLp()); | ||
| 1087 | - for (int i = 0; i < list.size(); i++) { | ||
| 1088 | - ScheduleRealInfo t = list.get(i); | ||
| 1089 | - if (t.getLpName().indexOf("+") != -1) { | ||
| 1090 | - continue; | ||
| 1091 | - } else if (pattern.matcher(t.getLpName()).matches()) { | ||
| 1092 | - continue; | ||
| 1093 | - } else { | ||
| 1094 | - listNew.add(t); | ||
| 1095 | - } | ||
| 1096 | - } | ||
| 1097 | - return listNew; | ||
| 1098 | - } else { | ||
| 1099 | - return list; | ||
| 1100 | - } | ||
| 1101 | - | ||
| 1102 | - } | ||
| 1103 | - | ||
| 1104 | - /** | ||
| 1105 | - * | ||
| 1106 | - */ | ||
| 1107 | - @Override | ||
| 1108 | - public List<ScheduleRealInfo> exportWaybill(String jName,String jGh, String clZbh, String lpName, String date, String line) { | ||
| 1109 | - ReportUtils ee = new ReportUtils(); | ||
| 1110 | - ReportRelatedUtils rru = new ReportRelatedUtils(); | ||
| 1111 | - List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | ||
| 1112 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 1113 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 1114 | -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line); | ||
| 1115 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 1116 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 1117 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 1118 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 1119 | - if (cts != null && cts.size() > 0) { | ||
| 1120 | - lists.add(s); | ||
| 1121 | - } else { | ||
| 1122 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 1123 | - lists.add(s); | ||
| 1124 | - } | ||
| 1125 | - } | ||
| 1126 | - } | ||
| 1127 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 1128 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 1129 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 1130 | - //计算里程和班次数,并放入Map里 | ||
| 1131 | - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); | ||
| 1132 | - | ||
| 1133 | - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos))); | ||
| 1134 | - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos)); | ||
| 1135 | - map.put("addMileage", culateMieageService.culateLjgl(lists)); | ||
| 1136 | - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists)); | ||
| 1137 | - map.put("yygl", yygl); | ||
| 1138 | - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists)); | ||
| 1139 | - map.put("ksgl", ksgl); | ||
| 1140 | - map.put("realMileage", Arith.add(yygl, ksgl)); | ||
| 1141 | - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, "")); | ||
| 1142 | - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos)); | ||
| 1143 | - map.put("ljbc", culateMieageService.culateLjbc(lists, "")); | ||
| 1144 | - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, ""); | ||
| 1145 | - map.put("sjbc", sjbc); | ||
| 1146 | -// map=new HashMap<String,Object>(); | ||
| 1147 | - | ||
| 1148 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 1149 | - String minfcsj = "02:00"; | ||
| 1150 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 1151 | - if (lineList.size() > 0) { | ||
| 1152 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 1153 | - + " id = (" | ||
| 1154 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 1155 | - + ")"; | ||
| 1156 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 1157 | - } | ||
| 1158 | - String[] minSjs = minfcsj.split(":"); | ||
| 1159 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 1160 | - | ||
| 1161 | - | ||
| 1162 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 1163 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 1164 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 1165 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 1166 | - | ||
| 1167 | - Long fscjT = 0L; | ||
| 1168 | - if (fcsjL < minSj) { | ||
| 1169 | - Calendar calendar = new GregorianCalendar(); | ||
| 1170 | - calendar.setTime(s.getScheduleDate()); | ||
| 1171 | - calendar.add(calendar.DATE, 1); | ||
| 1172 | - s.setScheduleDate(calendar.getTime()); | ||
| 1173 | - try { | ||
| 1174 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 1175 | - } catch (ParseException e) { | ||
| 1176 | - // TODO Auto-generated catch block | ||
| 1177 | - e.printStackTrace(); | ||
| 1178 | - } | ||
| 1179 | - | ||
| 1180 | - } else { | ||
| 1181 | - try { | ||
| 1182 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 1183 | - } catch (ParseException e) { | ||
| 1184 | - // TODO Auto-generated catch block | ||
| 1185 | - e.printStackTrace(); | ||
| 1186 | - } | ||
| 1187 | - ; | ||
| 1188 | - } | ||
| 1189 | - s.setFcsjT(fscjT); | ||
| 1190 | - } | ||
| 1191 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 1192 | - Collections.sort(scheduleRealInfos, new ComparableReal()); | ||
| 1193 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 1194 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 1195 | - s.setAdjustExps(i + 1 + ""); | ||
| 1196 | - String remarks = ""; | ||
| 1197 | - if (s.getRemarks() != null) { | ||
| 1198 | - remarks += s.getRemarks(); | ||
| 1199 | - } | ||
| 1200 | - | ||
| 1201 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 1202 | - if (!childTaskPlans.isEmpty()) { | ||
| 1203 | - s.setFcsjActual(""); | ||
| 1204 | - s.setZdsjActual(""); | ||
| 1205 | - s.setJhlc(0.0); | ||
| 1206 | - } | ||
| 1207 | - | ||
| 1208 | - if (s.isDestroy()) { | ||
| 1209 | - s.setFcsjActual(""); | ||
| 1210 | - s.setZdsjActual(""); | ||
| 1211 | - s.setJhlc(0.0); | ||
| 1212 | - remarks += "(烂班)"; | ||
| 1213 | - s.setRemarks(remarks); | ||
| 1214 | - } | ||
| 1215 | - | ||
| 1216 | - listSchedule.add(s); | ||
| 1217 | - //计算营运里程,空驶里程 | ||
| 1218 | - if (!childTaskPlans.isEmpty()) { | ||
| 1219 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 1220 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 1221 | - Collections.sort(listit, new ComparableChild()); | ||
| 1222 | - for (int j = 0; j < listit.size(); j++) { | ||
| 1223 | - ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 1224 | - ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 1225 | - if (childTaskPlan.isDestroy()) { | ||
| 1226 | - t.setFcsjActual(""); | ||
| 1227 | - t.setZdsjActual(""); | ||
| 1228 | - t.setJhlc(0.0); | ||
| 1229 | - } else { | ||
| 1230 | - t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 1231 | - t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 1232 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 1233 | - } | ||
| 1234 | - t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 1235 | - t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 1236 | - t.setRemarks(childTaskPlan.getRemarks()); | ||
| 1237 | - t.setAdjustExps("子"); | ||
| 1238 | - t.setjGh(""); | ||
| 1239 | - t.setjName(""); | ||
| 1240 | - t.setsGh(""); | ||
| 1241 | - t.setsName(""); | ||
| 1242 | - listSchedule.add(t); | ||
| 1243 | - } | ||
| 1244 | - } | ||
| 1245 | - } | ||
| 1246 | - Map<String, Object> maps; | ||
| 1247 | - for (ScheduleRealInfo scheduleRealInfo : listSchedule) { | ||
| 1248 | - maps = new HashMap<String, Object>(); | ||
| 1249 | - try { | ||
| 1250 | - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | ||
| 1251 | - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | ||
| 1252 | - maps = rru.getMapValue(scheduleRealInfo); | ||
| 1253 | - maps.put("bcs", scheduleRealInfo.getAdjustExps()); | ||
| 1254 | - String zdsj = scheduleRealInfo.getZdsj(); | ||
| 1255 | - String zdsjActual = scheduleRealInfo.getZdsjActual(); | ||
| 1256 | - if (zdsj != null && zdsjActual != null && | ||
| 1257 | - !zdsj.equals(zdsjActual) && | ||
| 1258 | - !zdsj.equals("") && | ||
| 1259 | - !zdsjActual.equals("")) { | ||
| 1260 | - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | ||
| 1261 | - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | ||
| 1262 | - if (zdsj.compareTo(zdsjActual) > 0) { | ||
| 1263 | - if (zdsjT - zdsjAT > 1000) { | ||
| 1264 | - maps.put("fast", ""); | ||
| 1265 | - maps.put("slow", zdsjAT - zdsjT + 1440); | ||
| 1266 | - } else { | ||
| 1267 | - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 1268 | - maps.put("slow", ""); | ||
| 1269 | - } | ||
| 1270 | - } else { | ||
| 1271 | - if (zdsjAT - zdsjT > 1000) { | ||
| 1272 | - maps.put("fast", zdsjT - zdsjAT + 1440); | ||
| 1273 | - maps.put("slow", ""); | ||
| 1274 | - } else { | ||
| 1275 | - maps.put("fast", ""); | ||
| 1276 | - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 1277 | - } | ||
| 1278 | - } | ||
| 1279 | - } else { | ||
| 1280 | - maps.put("fast", ""); | ||
| 1281 | - maps.put("slow", ""); | ||
| 1282 | - } | ||
| 1283 | - listMap.add(maps); | ||
| 1284 | - } catch (Exception e) { | ||
| 1285 | - e.printStackTrace(); | ||
| 1286 | - } | ||
| 1287 | - } | ||
| 1288 | - | ||
| 1289 | - String xls = ""; | ||
| 1290 | - if (map.get("type").toString().equals("0")) { | ||
| 1291 | - xls = "waybill_minhang.xls"; | ||
| 1292 | - } else { | ||
| 1293 | - xls = "waybill_minhang_dl.xls"; | ||
| 1294 | - } | ||
| 1295 | - | ||
| 1296 | - | ||
| 1297 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1298 | - | ||
| 1299 | - list.add(listMap.iterator()); | ||
| 1300 | - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/" + xls, | ||
| 1301 | - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | ||
| 1302 | - return scheduleRealInfos; | ||
| 1303 | - } | ||
| 1304 | - | ||
| 1305 | - @Override | ||
| 1306 | - public List<Map<String, Object>> dailyInfo(String line, String date, String type) { | ||
| 1307 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 1308 | - ReportUtils ee = new ReportUtils(); | ||
| 1309 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1310 | - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date); | ||
| 1311 | - | ||
| 1312 | - double totalZGL = 0, totalKSGL = 0, totalYH = 0; | ||
| 1313 | - int totalBCS = 0; | ||
| 1314 | - for (int i = 0; i < list.size(); i++) { | ||
| 1315 | - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString())); | ||
| 1316 | - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString())); | ||
| 1317 | - if (type.equals("export")) { | ||
| 1318 | - totalZGL += Double.parseDouble(zgl); | ||
| 1319 | - totalKSGL += Double.parseDouble(ksgl); | ||
| 1320 | - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString()); | ||
| 1321 | - } | ||
| 1322 | - list.get(i).put("zgl", zgl); | ||
| 1323 | - list.get(i).put("ksgl", ksgl); | ||
| 1324 | - } | ||
| 1325 | - if (type.equals("export")) { | ||
| 1326 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 1327 | - map.put("line", line); | ||
| 1328 | - map.put("date", date); | ||
| 1329 | - map.put("totalZGL", totalZGL); | ||
| 1330 | - map.put("totalKSGL", totalKSGL); | ||
| 1331 | - map.put("totalYH", totalYH); | ||
| 1332 | - map.put("totalBCS", totalBCS); | ||
| 1333 | - | ||
| 1334 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1335 | - | ||
| 1336 | - listI.add(list.iterator()); | ||
| 1337 | - try { | ||
| 1338 | - ee.excelReplace(listI, new Object[]{map}, path + "mould/daily.xls", | ||
| 1339 | - path + "export/班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | ||
| 1340 | - } catch (ParseException e) { | ||
| 1341 | - e.printStackTrace(); | ||
| 1342 | - } | ||
| 1343 | - } | ||
| 1344 | - return list; | ||
| 1345 | - } | ||
| 1346 | - | ||
| 1347 | - @Override | ||
| 1348 | - public List<Object[]> historyMessage(String line, String date, String code, String type) { | ||
| 1349 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 1350 | - | ||
| 1351 | - long d = 0; | ||
| 1352 | - long t = 0; | ||
| 1353 | - if (date.length() > 0) { | ||
| 1354 | - try { | ||
| 1355 | - d = sdf.parse(date + " 00:00:00").getTime(); | ||
| 1356 | - t = sdf.parse(date + " 23:59:59").getTime(); | ||
| 1357 | - } catch (ParseException e) { | ||
| 1358 | - // TODO Auto-generated catch block | ||
| 1359 | - e.printStackTrace(); | ||
| 1360 | - } | ||
| 1361 | - | ||
| 1362 | - } | ||
| 1363 | - String device = ""; | ||
| 1364 | - String device2 =""; | ||
| 1365 | - long qyrqTime=0l; | ||
| 1366 | - if (!code.equals("")) { | ||
| 1367 | - try { | ||
| 1368 | - List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00")); | ||
| 1369 | - if(deviceList.size()>0){ | ||
| 1370 | - device=deviceList.get(0).getOldDeviceNo(); | ||
| 1371 | - Date qyrq=deviceList.get(0).getQyrq(); | ||
| 1372 | - qyrqTime=qyrq.getTime(); | ||
| 1373 | - if(qyrqTime<t){ | ||
| 1374 | - device2=deviceList.get(0).getNewDeviceNo(); | ||
| 1375 | - } | ||
| 1376 | - }else{ | ||
| 1377 | - device = BasicData.deviceId2NbbmMap.inverse().get(code); | ||
| 1378 | - } | ||
| 1379 | - } catch (ParseException e) { | ||
| 1380 | - // TODO Auto-generated catch block | ||
| 1381 | - e.printStackTrace(); | ||
| 1382 | - } | ||
| 1383 | - } | ||
| 1384 | - List<Object[]> list=new ArrayList<Object[]>(); | ||
| 1385 | - | ||
| 1386 | - device = device.replaceAll("BF-", ""); | ||
| 1387 | - List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, device, d, t); | ||
| 1388 | - for (Object[] obj : list0) { | ||
| 1389 | - if (obj != null) { | ||
| 1390 | - if(code.equals("")){ | ||
| 1391 | - if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) { | ||
| 1392 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | ||
| 1393 | - try { | ||
| 1394 | - carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | ||
| 1395 | - //启用日期大于营运日期 还是根据旧设备号查询 | ||
| 1396 | - if(carDeviceList.size()==0){ | ||
| 1397 | - carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | ||
| 1398 | - } | ||
| 1399 | - } catch (Exception e) { | ||
| 1400 | - // TODO Auto-generated catch block | ||
| 1401 | - e.printStackTrace(); | ||
| 1402 | - } | ||
| 1403 | - if (carDeviceList.size() > 0) { | ||
| 1404 | - obj[0] = carDeviceList.get(0).getClZbh(); | ||
| 1405 | - } else { | ||
| 1406 | - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | ||
| 1407 | - } | ||
| 1408 | - } else { | ||
| 1409 | - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | ||
| 1410 | - } | ||
| 1411 | - }else{ | ||
| 1412 | - obj[0]=code; | ||
| 1413 | - } | ||
| 1414 | - | ||
| 1415 | - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | ||
| 1416 | - obj[4] = BasicData.lineCode2NameMap.get(line); | ||
| 1417 | - } | ||
| 1418 | - } | ||
| 1419 | - list.addAll(list0); | ||
| 1420 | - if(!device2.equals("")){ | ||
| 1421 | - device2.replaceAll("BF-", ""); | ||
| 1422 | - List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, device2, d, t); | ||
| 1423 | - for (Object[] obj : list1) { | ||
| 1424 | - if (obj != null) { | ||
| 1425 | - obj[0] =code; | ||
| 1426 | - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | ||
| 1427 | - obj[4] = BasicData.lineCode2NameMap.get(line); | ||
| 1428 | - } | ||
| 1429 | - } | ||
| 1430 | - list.addAll(list1); | ||
| 1431 | - } | ||
| 1432 | - | ||
| 1433 | - if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 1434 | - String lineName = BasicData.lineCode2NameMap.get(line); | ||
| 1435 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1436 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1437 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1438 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1439 | - ReportUtils ee = new ReportUtils(); | ||
| 1440 | - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | ||
| 1441 | - for (int i = 0; i < list.size(); i++) { | ||
| 1442 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 1443 | - Object[] obj = list.get(i); | ||
| 1444 | - map.put("num", i + 1); | ||
| 1445 | - map.put("line", obj[4]); | ||
| 1446 | - map.put("clZbh", obj[0]); | ||
| 1447 | - map.put("sender", obj[1]); | ||
| 1448 | - map.put("date", obj[3]); | ||
| 1449 | - map.put("text", obj[2]); | ||
| 1450 | - map.put("reply46", "0".equals(obj[5]+"")?"是":""); | ||
| 1451 | - map.put("reply47", "0".equals(obj[6]+"")?"是":""); | ||
| 1452 | - newList.add(map); | ||
| 1453 | - } | ||
| 1454 | - try { | ||
| 1455 | - listI.add(newList.iterator()); | ||
| 1456 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1457 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/historyMessage.xls", | ||
| 1458 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | ||
| 1459 | - + "-" + lineName + "-调度历史消息.xls"); | ||
| 1460 | - } catch (Exception e) { | ||
| 1461 | - // TODO: handle exception | ||
| 1462 | - e.printStackTrace(); | ||
| 1463 | - } | ||
| 1464 | - } | ||
| 1465 | - | ||
| 1466 | - if (type != null && type.length() != 0 && type.equals("export_msg")) { | ||
| 1467 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1468 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1469 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1470 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1471 | - ReportUtils ee = new ReportUtils(); | ||
| 1472 | - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | ||
| 1473 | - for (int i = 0; i < list.size(); i++) { | ||
| 1474 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 1475 | - Object[] obj = list.get(i); | ||
| 1476 | - map.put("num", i + 1); | ||
| 1477 | - map.put("line", obj[4]); | ||
| 1478 | - map.put("clZbh", obj[0]); | ||
| 1479 | - map.put("sender", obj[1]); | ||
| 1480 | - map.put("date", obj[3]); | ||
| 1481 | - map.put("text", obj[2]); | ||
| 1482 | - newList.add(map); | ||
| 1483 | - } | ||
| 1484 | - try { | ||
| 1485 | - listI.add(newList.iterator()); | ||
| 1486 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1487 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls", | ||
| 1488 | - path + "export/调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | ||
| 1489 | - } catch (Exception e) { | ||
| 1490 | - // TODO: handle exception | ||
| 1491 | - e.printStackTrace(); | ||
| 1492 | - } | ||
| 1493 | - } | ||
| 1494 | - return list; | ||
| 1495 | - } | ||
| 1496 | - | ||
| 1497 | - @Override | ||
| 1498 | - public Map<Integer, Integer> trustStatus(String lineStr) { | ||
| 1499 | - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr)); | ||
| 1500 | - | ||
| 1501 | - Map<Integer, Integer> map = new HashMap<>(); | ||
| 1502 | - return map; | ||
| 1503 | - } | ||
| 1504 | - | ||
| 1505 | - @Override | ||
| 1506 | - public Map<String, Object> realOutAdjust(Map<String, String> map) { | ||
| 1507 | - Map<String, Object> rs = new HashMap<>(); | ||
| 1508 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1509 | - try { | ||
| 1510 | - // 维修上报 | ||
| 1511 | - if (StringUtils.isNotBlank(map.get("reportTypes"))) { | ||
| 1512 | - Map<String, Object> param = new HashMap<String, Object>(); | ||
| 1513 | - param.putAll(map); | ||
| 1514 | - rs = repairReport(param, false); | ||
| 1515 | - } | ||
| 1516 | - | ||
| 1517 | - Long id = Long.parseLong(map.get("id")); | ||
| 1518 | - String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual"); | ||
| 1519 | - | ||
| 1520 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1521 | - | ||
| 1522 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 1523 | - //小于线路开始运营时间,则默认跨过24点 | ||
| 1524 | - if (fcsjActual.compareTo(config.getStartOpt()) < 0) { | ||
| 1525 | - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)); | ||
| 1526 | - } else { | ||
| 1527 | - sch.setRealExecDate(sch.getScheduleDateStr()); | ||
| 1528 | - } | ||
| 1529 | - | ||
| 1530 | - //日志记录 | ||
| 1531 | - ScheduleModifyLogger.sftz(sch, fcsjActual, remarks); | ||
| 1532 | - | ||
| 1533 | - sch.setFcsjActualAll(fcsjActual); | ||
| 1534 | - sch.setRemarks(remarks); | ||
| 1535 | - sch.calcStatus(); | ||
| 1536 | - //if(sch.isLate2()){ | ||
| 1537 | - //取消应发未到标记 | ||
| 1538 | - // sch.setLate2(false); | ||
| 1539 | - LateAdjustHandle.remove(sch); | ||
| 1540 | - //} | ||
| 1541 | - | ||
| 1542 | - dayOfSchedule.save(sch); | ||
| 1543 | - | ||
| 1544 | - ts.add(sch); | ||
| 1545 | - | ||
| 1546 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 1547 | - rs.put("ts", ts); | ||
| 1548 | - | ||
| 1549 | - //通知页面刷新 | ||
| 1550 | - sendUtils.refreshSch(ts); | ||
| 1551 | - } catch (Exception e) { | ||
| 1552 | - logger.error("", e); | ||
| 1553 | - rs.put("status", ResponseCode.ERROR); | ||
| 1554 | - } | ||
| 1555 | - | ||
| 1556 | - return rs; | ||
| 1557 | - } | ||
| 1558 | - | ||
| 1559 | - @Override | ||
| 1560 | - public Map<String, Object> revokeDestroy(Long id) { | ||
| 1561 | - Map<String, Object> rs = new HashMap<>(); | ||
| 1562 | - try { | ||
| 1563 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1564 | - if (sch.getStatus() != -1) { | ||
| 1565 | - rs.put("status", ResponseCode.ERROR); | ||
| 1566 | - rs.put("msg", "未烂班,无法撤销!"); | ||
| 1567 | - } else { | ||
| 1568 | - //日志记录 | ||
| 1569 | - ScheduleModifyLogger.cxlb(sch); | ||
| 1570 | - | ||
| 1571 | - sch.setStatus(0); | ||
| 1572 | - sch.setRemarks("");//清空备注 | ||
| 1573 | - sch.setJhlc(sch.getJhlcOrig()); | ||
| 1574 | - | ||
| 1575 | - //入库 | ||
| 1576 | - dayOfSchedule.save(sch); | ||
| 1577 | - //重新计算当前执行班次 | ||
| 1578 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 1579 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 1580 | - rs.put("t", sch); | ||
| 1581 | - | ||
| 1582 | - } | ||
| 1583 | - } catch (Exception e) { | ||
| 1584 | - logger.error("", e); | ||
| 1585 | - rs.put("status", ResponseCode.ERROR); | ||
| 1586 | - } | ||
| 1587 | - return rs; | ||
| 1588 | - } | ||
| 1589 | - | ||
| 1590 | - @Override | ||
| 1591 | - public Map<String, Object> revokeRealOutgo(Long id) { | ||
| 1592 | - Map<String, Object> rs = new HashMap<>(); | ||
| 1593 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1594 | - | ||
| 1595 | - try { | ||
| 1596 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1597 | - if (sch.getFcsjActual() == null) { | ||
| 1598 | - rs.put("status", ResponseCode.ERROR); | ||
| 1599 | - rs.put("msg", "无实发时间,无法撤销!"); | ||
| 1600 | - } else { | ||
| 1601 | - //日志记录 | ||
| 1602 | - ScheduleModifyLogger.cxsf(sch); | ||
| 1603 | - | ||
| 1604 | - sch.clearFcsjActual(); | ||
| 1605 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 1606 | - | ||
| 1607 | - ts.add(sch); | ||
| 1608 | - rs.put("ts", ts); | ||
| 1609 | - | ||
| 1610 | - dayOfSchedule.save(sch); | ||
| 1611 | - | ||
| 1612 | - } | ||
| 1613 | - } catch (Exception e) { | ||
| 1614 | - logger.error("", e); | ||
| 1615 | - rs.put("status", ResponseCode.ERROR); | ||
| 1616 | - } | ||
| 1617 | - return rs; | ||
| 1618 | - } | ||
| 1619 | - | ||
| 1620 | - @Override | ||
| 1621 | - public Map<String, Object> spaceAdjust(Long[] ids, Integer space) { | ||
| 1622 | - | ||
| 1623 | - List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null; | ||
| 1624 | - Map<String, Object> rs = new HashMap<>(), tempRs = new HashMap<>(); | ||
| 1625 | - try { | ||
| 1626 | - ScheduleRealInfo sch, next; | ||
| 1627 | - for (Long id : ids) { | ||
| 1628 | - sch = dayOfSchedule.get(id); | ||
| 1629 | - if (null != sch) | ||
| 1630 | - list.add(sch); | ||
| 1631 | - } | ||
| 1632 | - | ||
| 1633 | - int size = list.size(); | ||
| 1634 | - if (size == 0) { | ||
| 1635 | - rs.put("status", ResponseCode.ERROR); | ||
| 1636 | - } else { | ||
| 1637 | - // 按发车时间排序 | ||
| 1638 | - Collections.sort(list, new ScheduleComparator.FCSJ()); | ||
| 1639 | - | ||
| 1640 | - // 以第一个实际发车/待发时间为起点,调整间隔 | ||
| 1641 | - sch = list.get(0); | ||
| 1642 | - Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L; | ||
| 1643 | - | ||
| 1644 | - for (int i = 1; i < size; i++) { | ||
| 1645 | - st += plus; | ||
| 1646 | - sch = list.get(i); | ||
| 1647 | - | ||
| 1648 | - //调整待发 | ||
| 1649 | - tempRs = outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null, "3", null); | ||
| 1650 | - | ||
| 1651 | - if (null != tempRs && tempRs.get("ts") != null) | ||
| 1652 | - tempTs = (List<ScheduleRealInfo>) tempRs.get("ts"); | ||
| 1653 | - | ||
| 1654 | - ts.addAll(tempTs); | ||
| 1655 | - } | ||
| 1656 | - | ||
| 1657 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 1658 | - //返回最后一个班次,页面会全量刷新 | ||
| 1659 | - rs.put("ts", ts); | ||
| 1660 | - } | ||
| 1661 | - | ||
| 1662 | - } catch (Exception e) { | ||
| 1663 | - logger.error("", e); | ||
| 1664 | - rs.put("status", ResponseCode.ERROR); | ||
| 1665 | - } | ||
| 1666 | - return rs; | ||
| 1667 | - } | ||
| 1668 | - | ||
| 1669 | - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | ||
| 1670 | - | ||
| 1671 | - @Transactional | ||
| 1672 | - @Override | ||
| 1673 | - public Map<String, Object> schInfoFineTune(Map<String, String> map) { | ||
| 1674 | - Map<String, Object> rs = new HashMap<>(); | ||
| 1675 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1676 | - try { | ||
| 1677 | - // 维修上报 | ||
| 1678 | - if (StringUtils.isNotBlank(map.get("reportTypes"))) { | ||
| 1679 | - Map<String, Object> param = new HashMap<String, Object>(); | ||
| 1680 | - param.putAll(map); | ||
| 1681 | - rs = repairReport(param, false); | ||
| 1682 | - } | ||
| 1683 | - | ||
| 1684 | - Long id = Long.parseLong(map.get("id")); | ||
| 1685 | - String remarks = map.get("remarks"); | ||
| 1686 | - | ||
| 1687 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1688 | - | ||
| 1689 | - if (null == sch) { | ||
| 1690 | - rs.put("status", ResponseCode.ERROR); | ||
| 1691 | - rs.put("msg", "不存在的班次!"); | ||
| 1692 | - return rs; | ||
| 1693 | - } | ||
| 1694 | - | ||
| 1695 | - //日志记录器 | ||
| 1696 | - FcxxwtLogger fLog = FcxxwtLogger.start(sch, remarks); | ||
| 1697 | - | ||
| 1698 | - String clZbh = map.get("clZbh"); | ||
| 1699 | - String jsy = map.get("jsy"); | ||
| 1700 | - if (!clZbh.equals(sch.getClZbh()) | ||
| 1701 | - || !jsy.equals(sch.getjGh() + "/" + sch.getjName())) | ||
| 1702 | - schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据 | ||
| 1703 | - /** | ||
| 1704 | - * 换车 | ||
| 1705 | - */ | ||
| 1706 | - if (StringUtils.isNotEmpty(clZbh) && !clZbh.equals(sch.getClZbh())) { | ||
| 1707 | - //换车 | ||
| 1708 | - if (!carExist(sch.getGsBm(), clZbh)) { | ||
| 1709 | - rs.put("status", ResponseCode.ERROR); | ||
| 1710 | - rs.put("msg", "车辆 " + clZbh + " 不存在!"); | ||
| 1711 | - return rs; | ||
| 1712 | - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) { | ||
| 1713 | - rs.put("status", ResponseCode.ERROR); | ||
| 1714 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆"); | ||
| 1715 | - return rs; | ||
| 1716 | - } else { | ||
| 1717 | - fLog.log("换车", sch.getClZbh(), clZbh); | ||
| 1718 | - dayOfSchedule.changeCar(sch, clZbh); | ||
| 1719 | - } | ||
| 1720 | - } | ||
| 1721 | - | ||
| 1722 | - if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){ | ||
| 1723 | - rs.put("status", ResponseCode.ERROR); | ||
| 1724 | - rs.put("msg", "无效的参数【驾驶员】"); | ||
| 1725 | - return rs; | ||
| 1726 | - } | ||
| 1727 | - | ||
| 1728 | - /** | ||
| 1729 | - * 换驾驶员 | ||
| 1730 | - */ | ||
| 1731 | - if (StringUtils.isNotEmpty(jsy)) { | ||
| 1732 | - String jGh = jsy.split("/")[0]; | ||
| 1733 | - String jName = getPersonName(sch.getGsBm(), jGh); | ||
| 1734 | - if (StringUtils.isEmpty(jName)) { | ||
| 1735 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | ||
| 1736 | - rs.put("status", ResponseCode.ERROR); | ||
| 1737 | - return rs; | ||
| 1738 | - } else if (!jGh.equals(sch.getjGh())) { | ||
| 1739 | - fLog.log("换驾驶员", sch.getjGh() + "/" + sch.getjName(), jsy); | ||
| 1740 | - persoChange(sch, jGh); | ||
| 1741 | - } | ||
| 1742 | - } | ||
| 1743 | - | ||
| 1744 | - /** | ||
| 1745 | - * 换售票员 | ||
| 1746 | - */ | ||
| 1747 | - String spy = map.get("spy"); | ||
| 1748 | - if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) { | ||
| 1749 | - String sGh = spy.split("/")[0]; | ||
| 1750 | - | ||
| 1751 | - String sName = getPersonName(sch.getGsBm(), sGh); | ||
| 1752 | - if (StringUtils.isEmpty(sName)) { | ||
| 1753 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | ||
| 1754 | - rs.put("status", ResponseCode.ERROR); | ||
| 1755 | - return rs; | ||
| 1756 | - } else if (!sGh.equals(sch.getsGh())) { | ||
| 1757 | - fLog.log("换售票员", sch.getsGh() + "/" + sch.getsName(), spy); | ||
| 1758 | - persoChangeSPY(sch, sGh); | ||
| 1759 | - } | ||
| 1760 | - } else if (StringUtils.isNotEmpty(sch.getsGh())) { | ||
| 1761 | - fLog.log("撤销售票员"); | ||
| 1762 | - sch.setsGh(""); | ||
| 1763 | - sch.setsName(""); | ||
| 1764 | - } | ||
| 1765 | - | ||
| 1766 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 1767 | - /** | ||
| 1768 | - * 调整实发 | ||
| 1769 | - */ | ||
| 1770 | - String fcsjActual = map.get("fcsjActual"); | ||
| 1771 | - if (StringUtils.isNotBlank(fcsjActual) | ||
| 1772 | - && !fcsjActual.equals(sch.getFcsjActual())) { | ||
| 1773 | - | ||
| 1774 | - //long t = 0L; | ||
| 1775 | - //小于线路开始运营时间,则默认跨过24点 | ||
| 1776 | - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), fcsjActual, config); | ||
| 1777 | - /* if (fcsjActual.compareTo(config.getStartOpt()) < 0) | ||
| 1778 | - t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual); | ||
| 1779 | - else | ||
| 1780 | - t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);*/ | ||
| 1781 | - | ||
| 1782 | - fLog.log("调整实发时间", sch.getFcsjActual(), fcsjActual); | ||
| 1783 | - sch.setFcsjActualAll(t); | ||
| 1784 | - //取消应发未到标记 | ||
| 1785 | - //if(sch.isLate2()){ | ||
| 1786 | - // sch.setLate2(false); | ||
| 1787 | - LateAdjustHandle.remove(sch); | ||
| 1788 | - //} | ||
| 1789 | - } else if (StringUtils.isNotEmpty(sch.getFcsjActual()) && StringUtils.isEmpty(fcsjActual)) { | ||
| 1790 | - fLog.log("撤销实发时间", sch.getFcsjActual(), ""); | ||
| 1791 | - //撤销实发 | ||
| 1792 | - revokeRealOutgo(sch.getId()); | ||
| 1793 | - } | ||
| 1794 | - | ||
| 1795 | - /** | ||
| 1796 | - * 调整实达 | ||
| 1797 | - */ | ||
| 1798 | - String zdsjActual = map.get("zdsjActual"); | ||
| 1799 | - if (StringUtils.isNotBlank(zdsjActual) | ||
| 1800 | - && !zdsjActual.equals(sch.getZdsjActual())) { | ||
| 1801 | - | ||
| 1802 | - //调整实达 | ||
| 1803 | - fLog.log("调整实达时间", sch.getZdsjActual(), zdsjActual); | ||
| 1804 | - | ||
| 1805 | - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), zdsjActual, config); | ||
| 1806 | - sch.setZdsjActualAll(t); | ||
| 1807 | - //路牌下一班起点到达时间 | ||
| 1808 | - ScheduleRealInfo next = dayOfSchedule.nextByLp2(sch); | ||
| 1809 | - if (null != next) { | ||
| 1810 | - next.setQdzArrDatesj(zdsjActual); | ||
| 1811 | - next.setLate2(false); | ||
| 1812 | - ts.add(next); | ||
| 1813 | - } | ||
| 1814 | - | ||
| 1815 | - //重新计算车辆执行班次 | ||
| 1816 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 1817 | - //取消应发未到标记 | ||
| 1818 | - LateAdjustHandle.remove(sch); | ||
| 1819 | - } else if (StringUtils.isNotEmpty(sch.getZdsjActual()) && StringUtils.isEmpty(zdsjActual)) { | ||
| 1820 | - //清除实达时间 | ||
| 1821 | - fLog.log("撤销实达时间", sch.getZdsjActual(), ""); | ||
| 1822 | - sch.clearZdsjActual(); | ||
| 1823 | - //清除路牌下一班起点到达时间 | ||
| 1824 | - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch); | ||
| 1825 | - if (null != next) { | ||
| 1826 | - next.setQdzArrDatesj(null); | ||
| 1827 | - ts.add(next); | ||
| 1828 | - } | ||
| 1829 | - //重新计算车辆执行班次 | ||
| 1830 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 1831 | - } | ||
| 1832 | - | ||
| 1833 | - /** | ||
| 1834 | - * 备注 | ||
| 1835 | - */ | ||
| 1836 | - sch.setRemarks(remarks); | ||
| 1837 | - | ||
| 1838 | - /** | ||
| 1839 | - * 烂班 | ||
| 1840 | - */ | ||
| 1841 | - if (map.get("status") != null | ||
| 1842 | - && Integer.parseInt(map.get("status").toString()) == -1) { | ||
| 1843 | - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null); | ||
| 1844 | - fLog.log("烂班"); | ||
| 1845 | - } | ||
| 1846 | - | ||
| 1847 | - /** | ||
| 1848 | - * 修改班次里程 | ||
| 1849 | - */ | ||
| 1850 | - String jhlc = map.get("jhlc"); | ||
| 1851 | - if (StringUtils.isNotEmpty(jhlc)) { | ||
| 1852 | - double jhlcNum = Double.parseDouble(jhlc); | ||
| 1853 | - //烂班 | ||
| 1854 | - if (jhlcNum == 0 && sch.getJhlcOrig() != 0 && !sch._isInout() && !sch.isDestroy()) { | ||
| 1855 | - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null); | ||
| 1856 | - fLog.log("里程设置为0,自动烂班"); | ||
| 1857 | - } else if (jhlcNum != sch.getJhlc()) { | ||
| 1858 | - fLog.log("设置里程", sch.getJhlc(), jhlcNum); | ||
| 1859 | - sch.setJhlc(jhlcNum); | ||
| 1860 | - //临加班次,实际计划一起改 | ||
| 1861 | - if (sch.isSflj()) | ||
| 1862 | - sch.setJhlcOrig(jhlcNum); | ||
| 1863 | - } | ||
| 1864 | - } | ||
| 1865 | - | ||
| 1866 | - /** | ||
| 1867 | - * 修改班次类型 | ||
| 1868 | - */ | ||
| 1869 | - String bcType = map.get("bcType"); | ||
| 1870 | - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(sch.getBcType())) { | ||
| 1871 | - fLog.log("修改班次类型", sch.getBcType(), bcType); | ||
| 1872 | - sch.setBcType(bcType); | ||
| 1873 | - } | ||
| 1874 | - | ||
| 1875 | - //重新计算班次状态 | ||
| 1876 | - sch.calcStatus(); | ||
| 1877 | - dayOfSchedule.save(sch); | ||
| 1878 | - //页面需要更新的班次信息 | ||
| 1879 | - ts.add(sch); | ||
| 1880 | - | ||
| 1881 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 1882 | - rs.put("ts", ts); | ||
| 1883 | - | ||
| 1884 | - //日志记录结束 | ||
| 1885 | - fLog.end(); | ||
| 1886 | - } catch (Exception e) { | ||
| 1887 | - logger.error("", e); | ||
| 1888 | - rs.put("status", ResponseCode.ERROR); | ||
| 1889 | - } | ||
| 1890 | - return rs; | ||
| 1891 | - } | ||
| 1892 | - | ||
| 1893 | - @Override | ||
| 1894 | - public Map<String, Object> outgoAdjustAll(String params) { | ||
| 1895 | - Map<String, Object> rs = new HashMap<>(); | ||
| 1896 | - try { | ||
| 1897 | - JSONArray jsonArray = JSONArray.parseArray(params); | ||
| 1898 | - | ||
| 1899 | - ScheduleRealInfo schedule = null; | ||
| 1900 | - JSONObject jsonObj; | ||
| 1901 | - String dfsj; | ||
| 1902 | - long id; | ||
| 1903 | - for (int i = 0; i < jsonArray.size(); i++) { | ||
| 1904 | - jsonObj = jsonArray.getJSONObject(i); | ||
| 1905 | - dfsj = jsonObj.getString("t"); | ||
| 1906 | - id = jsonObj.getLong("id"); | ||
| 1907 | - schedule = dayOfSchedule.get(id); | ||
| 1908 | - | ||
| 1909 | - if (schedule != null) | ||
| 1910 | - outgoAdjust(id, null, dfsj, null, "2", null); | ||
| 1911 | - } | ||
| 1912 | - | ||
| 1913 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 1914 | - //将更新的最后一个班次返回,页面会做全量刷新 | ||
| 1915 | - rs.put("t", schedule); | ||
| 1916 | - } catch (Exception e) { | ||
| 1917 | - logger.error("", e); | ||
| 1918 | - rs.put("status", ResponseCode.ERROR); | ||
| 1919 | - } | ||
| 1920 | - return rs; | ||
| 1921 | - } | ||
| 1922 | - | ||
| 1923 | - @Override | ||
| 1924 | - public Map<String, Object> findRouteByLine(String lineCode) { | ||
| 1925 | - Map<String, Object> map = new HashMap<>(); | ||
| 1926 | - //上行 | ||
| 1927 | - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode); | ||
| 1928 | - map.put("line.id_eq", lineId); | ||
| 1929 | - map.put("directions_eq", 0); | ||
| 1930 | - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map); | ||
| 1931 | - | ||
| 1932 | - //下行 | ||
| 1933 | - map.put("directions_eq", 1); | ||
| 1934 | - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map); | ||
| 1935 | - | ||
| 1936 | - Map<String, Object> rs = new HashMap<>(); | ||
| 1937 | - | ||
| 1938 | - String upVectors = "", vec; | ||
| 1939 | - //拼接上行路段 | ||
| 1940 | - for (Map<String, Object> temp : upList) { | ||
| 1941 | - vec = temp.get("sectionBsectionVector").toString(); | ||
| 1942 | - upVectors += vec.subSequence(11, vec.length() - 2) + " "; | ||
| 1943 | - } | ||
| 1944 | - | ||
| 1945 | - //拼接下行路段 | ||
| 1946 | - String downVectors = ""; | ||
| 1947 | - for (Map<String, Object> temp : downList) {//LINESTRING( | ||
| 1948 | - vec = temp.get("sectionBsectionVector").toString(); | ||
| 1949 | - downVectors += vec.subSequence(11, vec.length() - 2) + " "; | ||
| 1950 | - } | ||
| 1951 | - | ||
| 1952 | - | ||
| 1953 | - rs.put("up", upVectors); | ||
| 1954 | - //上行gcj | ||
| 1955 | - rs.put("up_gcj", BdToGcjString(upVectors)); | ||
| 1956 | - rs.put("down", downVectors); | ||
| 1957 | - //下行gcj | ||
| 1958 | - rs.put("down_gcj", BdToGcjString(downVectors)); | ||
| 1959 | - rs.put("lineId", lineId); | ||
| 1960 | - | ||
| 1961 | - return rs; | ||
| 1962 | - } | ||
| 1963 | - | ||
| 1964 | - /** | ||
| 1965 | - * @param @param bdStr | ||
| 1966 | - * @throws | ||
| 1967 | - * @Title: BdToGcjString | ||
| 1968 | - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串) | ||
| 1969 | - */ | ||
| 1970 | - public String BdToGcjString(String bdStr) { | ||
| 1971 | - String[] array = bdStr.split(","), subArray; | ||
| 1972 | - if (array.length == 0 || bdStr.length() < 2) | ||
| 1973 | - return ""; | ||
| 1974 | - | ||
| 1975 | - String gcjStr = ""; | ||
| 1976 | - CoordinateConverter.Location location; | ||
| 1977 | - for (String crd : array) { | ||
| 1978 | - subArray = crd.split(" "); | ||
| 1979 | - if (subArray.length != 2) | ||
| 1980 | - continue; | ||
| 1981 | - location = CoordinateConverter.bd_decrypt(CoordinateConverter.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1]))); | ||
| 1982 | - | ||
| 1983 | - gcjStr += location.getLng() + " " + location.getLat() + ","; | ||
| 1984 | - } | ||
| 1985 | - | ||
| 1986 | - return gcjStr.substring(0, gcjStr.length() - 1); | ||
| 1987 | - } | ||
| 1988 | - | ||
| 1989 | - public List<Map<String, String>> findLine(String line) { | ||
| 1990 | - List<Line> listLine = lineRepository.findLine("%" + line + "%"); | ||
| 1991 | - List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | ||
| 1992 | - Map<String, String> map; | ||
| 1993 | - for (Line temp : listLine) { | ||
| 1994 | - if (temp != null) { | ||
| 1995 | - String xlName = temp.getName(); | ||
| 1996 | - if (xlName.indexOf(line) != -1) { | ||
| 1997 | - map = new HashMap<String, String>(); | ||
| 1998 | - map.put("id", temp.getLineCode()); | ||
| 1999 | - map.put("text", xlName); | ||
| 2000 | - list.add(map); | ||
| 2001 | - } | ||
| 2002 | - } | ||
| 2003 | - } | ||
| 2004 | - return list; | ||
| 2005 | - } | ||
| 2006 | - | ||
| 2007 | - public List<Map<String, String>> findLpName(String lpName) { | ||
| 2008 | - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%"); | ||
| 2009 | - List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | ||
| 2010 | - Map<String, String> map; | ||
| 2011 | - for (GuideboardInfo temp : listLpName) { | ||
| 2012 | - if (temp != null) { | ||
| 2013 | - String lp = temp.getLpName(); | ||
| 2014 | - if (lp.indexOf(lpName) != -1) { | ||
| 2015 | - map = new HashMap<String, String>(); | ||
| 2016 | - map.put("id", lp); | ||
| 2017 | - map.put("text", lp); | ||
| 2018 | - list.add(map); | ||
| 2019 | - } | ||
| 2020 | - } | ||
| 2021 | - } | ||
| 2022 | - return list; | ||
| 2023 | - } | ||
| 2024 | - | ||
| 2025 | - @Override | ||
| 2026 | - public Map<String, Object> findKMBC2(String jName, String clZbh, String date) { | ||
| 2027 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date, "", ""); | ||
| 2028 | - | ||
| 2029 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 2030 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 2031 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 2032 | - int jhbc = 0, cjbc = 0, ljbc = 0; | ||
| 2033 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0; | ||
| 2034 | - float addMileage = 0l, remMileage = 0l; | ||
| 2035 | - String j_Name = ""; | ||
| 2036 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2037 | - for (ScheduleRealInfo scheduleRealInfo : list) { | ||
| 2038 | - if (scheduleRealInfo != null) { | ||
| 2039 | - j_Name = scheduleRealInfo.getjName(); | ||
| 2040 | - //计划里程(主任务过滤掉临加班次), | ||
| 2041 | - //烂班里程(主任务烂班), | ||
| 2042 | - //临加里程(主任务临加), | ||
| 2043 | - //计划班次,烂班班次,增加班次 | ||
| 2044 | - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | ||
| 2045 | - if (scheduleRealInfo.isSflj()) { | ||
| 2046 | - addMileage += tempJhlc; | ||
| 2047 | - ljbc++; | ||
| 2048 | - } else { | ||
| 2049 | - jhlc += tempJhlc; | ||
| 2050 | - jhbc++; | ||
| 2051 | - if (scheduleRealInfo.getStatus() == -1) { | ||
| 2052 | - remMileage += tempJhlc; | ||
| 2053 | - cjbc++; | ||
| 2054 | - } | ||
| 2055 | - } | ||
| 2056 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 2057 | - //计算营运里程,空驶里程 | ||
| 2058 | - if (childTaskPlans.isEmpty()) { | ||
| 2059 | - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 2060 | - || scheduleRealInfo.getBcType().equals("venting")) { | ||
| 2061 | - ksgl += tempJhlc; | ||
| 2062 | - } else { | ||
| 2063 | - yygl += tempJhlc; | ||
| 2064 | - } | ||
| 2065 | - } else { | ||
| 2066 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 2067 | - while (it.hasNext()) { | ||
| 2068 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 2069 | - if (childTaskPlan.getMileageType().equals("empty")) { | ||
| 2070 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 2071 | - } else { | ||
| 2072 | - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 2073 | - } | ||
| 2074 | - } | ||
| 2075 | - } | ||
| 2076 | - } | ||
| 2077 | - } | ||
| 2078 | - map.put("j_name", j_Name); | ||
| 2079 | - map.put("jhlc", format.format(jhlc)); | ||
| 2080 | - map.put("remMileage", format.format(remMileage)); | ||
| 2081 | - map.put("addMileage", format.format(addMileage)); | ||
| 2082 | - map.put("yygl", format.format(yygl)); | ||
| 2083 | - map.put("ksgl", format.format(ksgl)); | ||
| 2084 | - map.put("realMileage", format.format(yygl + ksgl)); | ||
| 2085 | - map.put("jhbc", jhbc); | ||
| 2086 | - map.put("cjbc", cjbc); | ||
| 2087 | - map.put("ljbc", ljbc); | ||
| 2088 | - map.put("sjbc", jhbc - cjbc + ljbc); | ||
| 2089 | - return map; | ||
| 2090 | - } | ||
| 2091 | - | ||
| 2092 | - | ||
| 2093 | - public Map<String, Object> findKMBC(String jGh, String clZbh, | ||
| 2094 | - String lpName, String date, String line) { | ||
| 2095 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2096 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 2097 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2098 | - for (int i = 0; i < list.size(); i++) { | ||
| 2099 | - ScheduleRealInfo s = list.get(i); | ||
| 2100 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2101 | - if (cts != null && cts.size() > 0) { | ||
| 2102 | - lists.add(s); | ||
| 2103 | - } else { | ||
| 2104 | - if (s.getFcsjActual() != null && s.getZdsjActual() != null) { | ||
| 2105 | - lists.add(s); | ||
| 2106 | - } | ||
| 2107 | - } | ||
| 2108 | - } | ||
| 2109 | - map.put("jhbc", culateService.culateJhbc(list, ""));//计划班次 | ||
| 2110 | - map.put("jhlc", Arith.add(culateService.culateJhgl(list), | ||
| 2111 | - culateService.culateJhJccgl(list))); //计划总里程 | ||
| 2112 | - map.put("cjbc", culateService.culateLbbc(list));//烂班班次 | ||
| 2113 | - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里 | ||
| 2114 | - map.put("ljbc", culateService.culateLjbc(lists, ""));//临加班次 | ||
| 2115 | - double ljgl = culateService.culateLjgl(lists); | ||
| 2116 | - map.put("addMileage", ljgl); //临加公里 | ||
| 2117 | - map.put("sjbc", culateService.culateSjbc(lists, "") + culateService.culateLjbc(lists, "")); | ||
| 2118 | - double ksgl = culateService.culateKsgl(list);//子任务空驶公里 | ||
| 2119 | - double jccgl = culateService.culateJccgl(lists);//空驶班次公里 | ||
| 2120 | - map.put("ksgl", ksgl);//空驶公里 | ||
| 2121 | - double sjgl = culateService.culateSjgl(lists);//实际营运公里 | ||
| 2122 | - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//总公里 | ||
| 2123 | - map.put("zkslc", Arith.add(ksgl, jccgl)); | ||
| 2124 | - map.put("jcclc", jccgl); | ||
| 2125 | - map.put("yygl", Arith.add(sjgl, ljgl)); //总营运公里 | ||
| 2126 | - return map; | ||
| 2127 | - } | ||
| 2128 | - | ||
| 2129 | - public Map<String, Object> findKMBC_mh_2(String jGh, String clZbh, | ||
| 2130 | - String lpName, String date, String line) { | ||
| 2131 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2132 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 2133 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2134 | - for (int i = 0; i < list.size(); i++) { | ||
| 2135 | - ScheduleRealInfo s = list.get(i); | ||
| 2136 | - if (s.isDestroy() && s.isReissue()) { | ||
| 2137 | - s.setRemark(""); | ||
| 2138 | - s.setFcsjActual(s.getDfsj()); | ||
| 2139 | - s.setZdsjActual(s.getZdsj()); | ||
| 2140 | - s.setStatus(2); | ||
| 2141 | - s.setJhlc(s.getJhlcOrig()); | ||
| 2142 | - } | ||
| 2143 | - | ||
| 2144 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2145 | - if (cts != null && cts.size() > 0) { | ||
| 2146 | - lists.add(s); | ||
| 2147 | - } else { | ||
| 2148 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2149 | - lists.add(s); | ||
| 2150 | - } | ||
| 2151 | - } | ||
| 2152 | - } | ||
| 2153 | - double ksgl = culateService.culateKsgl(list); | ||
| 2154 | - double sjgl = culateService.culateSjgl(lists); | ||
| 2155 | - double jccgl = culateService.culateJccgl(lists); | ||
| 2156 | - double ljgl = culateService.culateLjgl(lists); | ||
| 2157 | - | ||
| 2158 | - map.put("jhlc", Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划里程 | ||
| 2159 | - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里 | ||
| 2160 | - map.put("addMileage", ljgl); //临加公里 | ||
| 2161 | - map.put("yygl", Arith.add(sjgl, ljgl)); //实际公里 | ||
| 2162 | - map.put("ksgl", ksgl);//空驶公里 | ||
| 2163 | - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl))); | ||
| 2164 | -// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage)); | ||
| 2165 | - map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 2166 | - map.put("cjbc", culateService.culateLbbc(list)); | ||
| 2167 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2168 | - map.put("sjbc", culateService.culateJhbc(lists, "") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists, "")); | ||
| 2169 | - map.put("jcclc", jccgl); | ||
| 2170 | - map.put("zkslc", Arith.add(ksgl, jccgl)); | ||
| 2171 | -// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc)); | ||
| 2172 | - return map; | ||
| 2173 | - } | ||
| 2174 | - | ||
| 2175 | - | ||
| 2176 | - @Override | ||
| 2177 | - public List<Map<String, Object>> accountPx(String line, String date, | ||
| 2178 | - String code, String xlName, String px) { | ||
| 2179 | -// List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px); | ||
| 2180 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 2181 | - if (!code.trim().equals("")) { | ||
| 2182 | - code = BasicData.deviceId2NbbmMap.inverse().get(code); | ||
| 2183 | - } | ||
| 2184 | - String fgs = ""; | ||
| 2185 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2186 | - if (lineList.size() > 0) { | ||
| 2187 | - Line l = lineList.get(0); | ||
| 2188 | - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany()); | ||
| 2189 | - } | ||
| 2190 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 2191 | - String sql = "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ," | ||
| 2192 | - + " device_id FROM bsth_v_report_80 WHERE " | ||
| 2193 | - + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '" + date + "' AND" | ||
| 2194 | - + " line_id = '" + line + "' and device_id like '%" + code + "%'"; | ||
| 2195 | - Map<String, Object> map; | ||
| 2196 | - List<Object[]> lsitObj = jdbcTemplate.query(sql, | ||
| 2197 | - new RowMapper<Object[]>() { | ||
| 2198 | - @Override | ||
| 2199 | - public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 2200 | - Object[] t = new Object[3]; | ||
| 2201 | - t[0] = rs.getString("request_code"); | ||
| 2202 | - t[1] = rs.getString("TIMESTAMP"); | ||
| 2203 | - t[2] = rs.getString("device_id"); | ||
| 2204 | - return t; | ||
| 2205 | - } | ||
| 2206 | - }); | ||
| 2207 | - int i = 1; | ||
| 2208 | - for (Object[] obj : lsitObj) { | ||
| 2209 | - if (obj != null) { | ||
| 2210 | - map = new HashMap<String, Object>(); | ||
| 2211 | - map.put("num", i++); | ||
| 2212 | - map.put("xlName", xlName); | ||
| 2213 | - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) { | ||
| 2214 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | ||
| 2215 | - try { | ||
| 2216 | - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString())); | ||
| 2217 | - } catch (Exception e) { | ||
| 2218 | - // TODO Auto-generated catch block | ||
| 2219 | - e.printStackTrace(); | ||
| 2220 | - } | ||
| 2221 | - if (carDeviceList.size() > 0) { | ||
| 2222 | - map.put("clZbh", carDeviceList.get(0).getClZbh()); | ||
| 2223 | - | ||
| 2224 | - } else { | ||
| 2225 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2226 | - } | ||
| 2227 | - } else { | ||
| 2228 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2229 | - | ||
| 2230 | - } | ||
| 2231 | - map.put("company", fgs); | ||
| 2232 | - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase()); | ||
| 2233 | - map.put("requestTime", obj[1]); | ||
| 2234 | - listMap.add(map); | ||
| 2235 | - } | ||
| 2236 | - } | ||
| 2237 | - if (listMap.size() > 1) { | ||
| 2238 | - if (px.equals("asc")) { | ||
| 2239 | - Collections.sort(listMap, new AccountMap()); | ||
| 2240 | - } else { | ||
| 2241 | - Collections.sort(listMap, new AccountMap2()); | ||
| 2242 | - } | ||
| 2243 | - } | ||
| 2244 | - return listMap; | ||
| 2245 | - } | ||
| 2246 | - | ||
| 2247 | - @Override | ||
| 2248 | - public List<Map<String, Object>> account(String line, String date, | ||
| 2249 | - String code, String xlName, String type) { | ||
| 2250 | - if (!code.trim().equals("")) { | ||
| 2251 | - code = BasicData.deviceId2NbbmMap.inverse().get(code); | ||
| 2252 | - } | ||
| 2253 | - String fgs = ""; | ||
| 2254 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2255 | - if (lineList.size() > 0) { | ||
| 2256 | - Line l = lineList.get(0); | ||
| 2257 | - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany()); | ||
| 2258 | - } | ||
| 2259 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 2260 | - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code); | ||
| 2261 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 2262 | - Map<String, Object> map; | ||
| 2263 | - int i = 1; | ||
| 2264 | - for (Object[] obj : lsitObj) { | ||
| 2265 | - if (obj != null) { | ||
| 2266 | - map = new HashMap<String, Object>(); | ||
| 2267 | - map.put("num", i++); | ||
| 2268 | - map.put("xlName", xlName); | ||
| 2269 | - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) { | ||
| 2270 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | ||
| 2271 | - try { | ||
| 2272 | - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString())); | ||
| 2273 | - } catch (Exception e) { | ||
| 2274 | - // TODO Auto-generated catch block | ||
| 2275 | - e.printStackTrace(); | ||
| 2276 | - } | ||
| 2277 | - if (carDeviceList.size() > 0) { | ||
| 2278 | - map.put("clZbh", carDeviceList.get(0).getClZbh()); | ||
| 2279 | - | ||
| 2280 | - } else { | ||
| 2281 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2282 | - } | ||
| 2283 | - } else { | ||
| 2284 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2285 | - | ||
| 2286 | - } | ||
| 2287 | - map.put("company", fgs); | ||
| 2288 | - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase()); | ||
| 2289 | - map.put("requestTime", obj[1]); | ||
| 2290 | - listMap.add(map); | ||
| 2291 | - } | ||
| 2292 | - } | ||
| 2293 | - | ||
| 2294 | - if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 2295 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2296 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2297 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2298 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2299 | - ReportUtils ee = new ReportUtils(); | ||
| 2300 | - Map<String, Object> typeMap = new HashMap<String, Object>(); | ||
| 2301 | - typeMap.put("0xA1", "请求恢复运营"); | ||
| 2302 | - typeMap.put("0xA2", "申请调档"); | ||
| 2303 | - typeMap.put("0xA3", "出场请求"); | ||
| 2304 | - typeMap.put("0xA5", "进场请求"); | ||
| 2305 | - typeMap.put("0xA7", "加油请求"); | ||
| 2306 | - typeMap.put("0x50", "车辆故障"); | ||
| 2307 | - typeMap.put("0x70", "路阻报告"); | ||
| 2308 | - typeMap.put("0x60", "事故报告"); | ||
| 2309 | - typeMap.put("0x11", "扣证纠纷"); | ||
| 2310 | - typeMap.put("0x12", "报警"); | ||
| 2311 | - for (Map<String, Object> map1 : listMap) { | ||
| 2312 | - map1.put("requestText", typeMap.get(map1.get("requestType"))); | ||
| 2313 | - } | ||
| 2314 | - try { | ||
| 2315 | - listI.add(listMap.iterator()); | ||
| 2316 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2317 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/account.xls", | ||
| 2318 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | ||
| 2319 | - + "-" + xlName + "-驾驶员请求台账.xls"); | ||
| 2320 | - } catch (Exception e) { | ||
| 2321 | - // TODO: handle exception | ||
| 2322 | - e.printStackTrace(); | ||
| 2323 | - } | ||
| 2324 | - } | ||
| 2325 | - | ||
| 2326 | - return listMap; | ||
| 2327 | - } | ||
| 2328 | - | ||
| 2329 | - @Override | ||
| 2330 | - public List<SchEditInfoDto> correctForm(String line, String date, String endDate, | ||
| 2331 | - String lpName, String code, String type, String changType) { | ||
| 2332 | - | ||
| 2333 | -// var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '计划烂班', 'CXLB': '撤销烂班', | ||
| 2334 | -// 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'}; | ||
| 2335 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2336 | - map.put("DFTZ", "待发调整"); | ||
| 2337 | - map.put("FCXXWT", "发车信息微调"); | ||
| 2338 | - map.put("JHLB", "计划烂班"); | ||
| 2339 | - map.put("CXLB", "撤销烂班"); | ||
| 2340 | - map.put("CXZX", "撤销执行"); | ||
| 2341 | - map.put("CXSF", "撤销实发"); | ||
| 2342 | - map.put("SFTZ", "实发调整"); | ||
| 2343 | - map.put("TZRC", "调整人车"); | ||
| 2344 | - | ||
| 2345 | - SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm"); | ||
| 2346 | - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 2347 | - String cont = ""; | ||
| 2348 | - cont = " and xl_bm ='" + line + "'"; | ||
| 2349 | - if (!lpName.equals("")) { | ||
| 2350 | - cont += " and lp_name = '" + lpName + "'"; | ||
| 2351 | - } | ||
| 2352 | - if (!code.equals("")) { | ||
| 2353 | - cont += " and cl_zbh ='" + code + "'"; | ||
| 2354 | - } | ||
| 2355 | - String sql = "select t1.*, t2.real_exec_date," | ||
| 2356 | - + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name," | ||
| 2357 | - + "t2.xl_dir,t2.real_exec_date from (select * from " | ||
| 2358 | - + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )" | ||
| 2359 | - + " t1 INNER JOIN bsth_c_s_sp_info_real t2 on " | ||
| 2360 | - + "t1.sch_id=t2.id where 1=1 " + cont; | ||
| 2361 | - | ||
| 2362 | - List<SchEditInfoDto> list = jdbcTemplate.query(sql, | ||
| 2363 | - new BeanPropertyRowMapper(SchEditInfoDto.class), date, endDate, line); | ||
| 2364 | - List<SchEditInfoDto> lists = new ArrayList<SchEditInfoDto>(); | ||
| 2365 | - for (int i = 0; i < list.size(); i++) { | ||
| 2366 | - Long fcsjs = 0l; | ||
| 2367 | - Long updsj = 0l; | ||
| 2368 | - SchEditInfoDto t = list.get(i); | ||
| 2369 | - if (map.get(t.getType()) != null) { | ||
| 2370 | - | ||
| 2371 | - if (changType.equals("")) { | ||
| 2372 | - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | ||
| 2373 | - } else { | ||
| 2374 | - String fcsj = ""; | ||
| 2375 | - String updtime = ""; | ||
| 2376 | - try { | ||
| 2377 | - fcsj = sdf1.format(sdf1.parse(t.getFcsj())); | ||
| 2378 | - updtime = sdf1.format(sdf1.parse(t.getTimeStr())); | ||
| 2379 | - fcsjs = sdf2.parse(t.getRealExecDate() + " " + fcsj).getTime(); | ||
| 2380 | - updsj = sdf2.parse(t.getRq() + " " + updtime).getTime(); | ||
| 2381 | - } catch (ParseException e) { | ||
| 2382 | - // TODO Auto-generated catch block | ||
| 2383 | - e.printStackTrace(); | ||
| 2384 | - } | ||
| 2385 | - if (changType.equals("1")) { | ||
| 2386 | - if (fcsjs > updsj) { | ||
| 2387 | - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | ||
| 2388 | - } else { | ||
| 2389 | - t.setType2(""); | ||
| 2390 | - } | ||
| 2391 | - } else if (changType.equals("2")) { | ||
| 2392 | - if (fcsjs < updsj) { | ||
| 2393 | - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | ||
| 2394 | - } else { | ||
| 2395 | - t.setType2(""); | ||
| 2396 | - } | ||
| 2397 | - } | ||
| 2398 | - } | ||
| 2399 | - } else { | ||
| 2400 | - t.setType2(""); | ||
| 2401 | - } | ||
| 2402 | - boolean fage = true; | ||
| 2403 | - for (int j = 0; j < lists.size(); j++) { | ||
| 2404 | - SchEditInfoDto s = lists.get(j); | ||
| 2405 | - if (s.getSchId() == t.getSchId()) { | ||
| 2406 | - s.setType2(s.getType2() + " " + t.getType2()); | ||
| 2407 | - fage = false; | ||
| 2408 | - } | ||
| 2409 | - } | ||
| 2410 | - | ||
| 2411 | - if (fage) { | ||
| 2412 | - if (changType.equals("")) { | ||
| 2413 | - lists.add(t); | ||
| 2414 | - } else { | ||
| 2415 | - if (changType.equals("1")) { | ||
| 2416 | - if (fcsjs > updsj) { | ||
| 2417 | - lists.add(t); | ||
| 2418 | - } | ||
| 2419 | - } else if (changType.equals("2")) { | ||
| 2420 | - if (fcsjs < updsj) { | ||
| 2421 | - lists.add(t); | ||
| 2422 | - } | ||
| 2423 | - } | ||
| 2424 | - } | ||
| 2425 | - } | ||
| 2426 | - } | ||
| 2427 | - | ||
| 2428 | - if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 2429 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2430 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2431 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2432 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2433 | - m.put("dates", date); | ||
| 2434 | - ReportUtils ee = new ReportUtils(); | ||
| 2435 | - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 2436 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 2437 | - for (SchEditInfoDto d : lists) { | ||
| 2438 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | ||
| 2439 | - tempMap.put("lpName", d.getLpName()); | ||
| 2440 | - tempMap.put("rq", d.getRq()); | ||
| 2441 | - tempMap.put("clZbh", d.getClZbh()); | ||
| 2442 | - tempMap.put("jName", d.getjName() + "/" + d.getjGh()); | ||
| 2443 | - tempMap.put("fcsj", d.getFcsj()); | ||
| 2444 | - tempMap.put("type", d.getType2()); | ||
| 2445 | - tempList.add(tempMap); | ||
| 2446 | - } | ||
| 2447 | - try { | ||
| 2448 | - String dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 2449 | - if(!endDate.equals(date)){ | ||
| 2450 | - dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate)); | ||
| 2451 | - } | ||
| 2452 | - String lineName = BasicData.lineCode2NameMap.get(line); | ||
| 2453 | - listI.add(tempList.iterator()); | ||
| 2454 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2455 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/correctForm.xls", | ||
| 2456 | - path + "export/" + dateTime + "-" + lineName + "-修正报表.xls"); | ||
| 2457 | - } catch (Exception e) { | ||
| 2458 | - // TODO: handle exception | ||
| 2459 | - e.printStackTrace(); | ||
| 2460 | - } | ||
| 2461 | -// Map<String, Object> maps = tempList.get(tempList.size() - 1); | ||
| 2462 | - } | ||
| 2463 | - return lists; | ||
| 2464 | - } | ||
| 2465 | - | ||
| 2466 | - @Override | ||
| 2467 | - public List<ScheduleRealInfo> queryListWaybill(String jGh, String clZbh, | ||
| 2468 | - String lpName, String date, String line) { | ||
| 2469 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 2470 | - List<ScheduleRealInfo> list = null; | ||
| 2471 | - list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 2472 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 2473 | - String minfcsj = "02:00"; | ||
| 2474 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2475 | - if (lineList.size() > 0) { | ||
| 2476 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 2477 | - + " id = (" | ||
| 2478 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 2479 | - + ")"; | ||
| 2480 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 2481 | - } | ||
| 2482 | - String[] minSjs = minfcsj.split(":"); | ||
| 2483 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 2484 | - | ||
| 2485 | - for (int i = 0; i < list.size(); i++) { | ||
| 2486 | - ScheduleRealInfo s = list.get(i); | ||
| 2487 | - if (s.getBcType().equals("out")) { | ||
| 2488 | - s.setRemark("1"); | ||
| 2489 | - } else if (s.getBcType().equals("in")) { | ||
| 2490 | - s.setRemark("3"); | ||
| 2491 | - } else { | ||
| 2492 | - s.setRemark("2"); | ||
| 2493 | - } | ||
| 2494 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 2495 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 2496 | - | ||
| 2497 | - Long fscjT = 0L; | ||
| 2498 | - if (fcsjL < minSj) { | ||
| 2499 | - Calendar calendar = new GregorianCalendar(); | ||
| 2500 | - calendar.setTime(s.getScheduleDate()); | ||
| 2501 | - calendar.add(calendar.DATE, 1); | ||
| 2502 | - s.setScheduleDate(calendar.getTime()); | ||
| 2503 | - try { | ||
| 2504 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 2505 | - } catch (ParseException e) { | ||
| 2506 | - // TODO Auto-generated catch block | ||
| 2507 | - e.printStackTrace(); | ||
| 2508 | - } | ||
| 2509 | - | ||
| 2510 | - } else { | ||
| 2511 | - try { | ||
| 2512 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 2513 | - } catch (ParseException e) { | ||
| 2514 | - // TODO Auto-generated catch block | ||
| 2515 | - e.printStackTrace(); | ||
| 2516 | - } | ||
| 2517 | - ; | ||
| 2518 | - } | ||
| 2519 | - s.setFcsjT(fscjT); | ||
| 2520 | - } | ||
| 2521 | - Collections.sort(list, new compareFcsjType()); | ||
| 2522 | - for (int i = 0; i < list.size(); i++) { | ||
| 2523 | - ScheduleRealInfo s = list.get(i); | ||
| 2524 | - s.setAdjustExps(i + 1 + ""); | ||
| 2525 | - String remarks = ""; | ||
| 2526 | - if (s.getRemarks() != null) { | ||
| 2527 | - remarks += s.getRemarks(); | ||
| 2528 | - } | ||
| 2529 | - | ||
| 2530 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 2531 | - if (!childTaskPlans.isEmpty()) { | ||
| 2532 | - s.setFcsjActual(""); | ||
| 2533 | - s.setZdsjActual(""); | ||
| 2534 | - s.setJhlc(0.0); | ||
| 2535 | - } | ||
| 2536 | - | ||
| 2537 | - if (s.isDestroy()) { | ||
| 2538 | - s.setFcsjActual(""); | ||
| 2539 | - s.setZdsjActual(""); | ||
| 2540 | - s.setJhlc(0.0); | ||
| 2541 | - remarks += "(烂班)"; | ||
| 2542 | - s.setRemarks(remarks); | ||
| 2543 | - } | ||
| 2544 | - | ||
| 2545 | - listSchedule.add(s); | ||
| 2546 | - //计算营运里程,空驶里程 | ||
| 2547 | - if (!childTaskPlans.isEmpty()) { | ||
| 2548 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 2549 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 2550 | - Collections.sort(listit, new ComparableChild()); | ||
| 2551 | - for (int j = 0; j < listit.size(); j++) { | ||
| 2552 | - ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 2553 | - ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 2554 | - if (childTaskPlan.getCcId() == null) { | ||
| 2555 | - if (childTaskPlan.isDestroy()) { | ||
| 2556 | - t.setFcsjActual(""); | ||
| 2557 | - t.setZdsjActual(""); | ||
| 2558 | - t.setJhlc(0.0); | ||
| 2559 | - } else { | ||
| 2560 | - t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 2561 | - t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 2562 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 2563 | - } | ||
| 2564 | - t.setFcsj(childTaskPlan.getStartDate()); | ||
| 2565 | - t.setZdsj(childTaskPlan.getEndDate()); | ||
| 2566 | - t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 2567 | - t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 2568 | - t.setRemarks(childTaskPlan.getRemarks()); | ||
| 2569 | - t.setAdjustExps("子"); | ||
| 2570 | - listSchedule.add(t); | ||
| 2571 | - } | ||
| 2572 | - } | ||
| 2573 | - } | ||
| 2574 | - } | ||
| 2575 | - | ||
| 2576 | - return listSchedule; | ||
| 2577 | - } | ||
| 2578 | - | ||
| 2579 | - @Override | ||
| 2580 | - public List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh, | ||
| 2581 | - String lpName, String date, String line) { | ||
| 2582 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 2583 | - List<ScheduleRealInfo> list = null; | ||
| 2584 | - list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line); | ||
| 2585 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 2586 | - String minfcsj = "02:00"; | ||
| 2587 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2588 | - if (lineList.size() > 0) { | ||
| 2589 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 2590 | - + " id = (" | ||
| 2591 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 2592 | - + ")"; | ||
| 2593 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 2594 | - } | ||
| 2595 | - String[] minSjs = minfcsj.split(":"); | ||
| 2596 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 2597 | - | ||
| 2598 | - for (int i = 0; i < list.size(); i++) { | ||
| 2599 | - ScheduleRealInfo s = list.get(i); | ||
| 2600 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 2601 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 2602 | - | ||
| 2603 | - Long fscjT = 0L; | ||
| 2604 | - if (fcsjL < minSj) { | ||
| 2605 | - Calendar calendar = new GregorianCalendar(); | ||
| 2606 | - calendar.setTime(s.getScheduleDate()); | ||
| 2607 | - calendar.add(calendar.DATE, 1); | ||
| 2608 | - s.setScheduleDate(calendar.getTime()); | ||
| 2609 | - try { | ||
| 2610 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 2611 | - } catch (ParseException e) { | ||
| 2612 | - // TODO Auto-generated catch block | ||
| 2613 | - e.printStackTrace(); | ||
| 2614 | - } | ||
| 2615 | - | ||
| 2616 | - } else { | ||
| 2617 | - try { | ||
| 2618 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 2619 | - } catch (ParseException e) { | ||
| 2620 | - // TODO Auto-generated catch block | ||
| 2621 | - e.printStackTrace(); | ||
| 2622 | - } | ||
| 2623 | - ; | ||
| 2624 | - } | ||
| 2625 | - s.setFcsjT(fscjT); | ||
| 2626 | - } | ||
| 2627 | - Collections.sort(list, new ComparableReal()); | ||
| 2628 | - for (int i = 0; i < list.size(); i++) { | ||
| 2629 | - ScheduleRealInfo s = list.get(i); | ||
| 2630 | - s.setAdjustExps(i + 1 + ""); | ||
| 2631 | - String remarks = ""; | ||
| 2632 | - if (s.getRemarks() != null) { | ||
| 2633 | - remarks += s.getRemarks(); | ||
| 2634 | - } | ||
| 2635 | - | ||
| 2636 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 2637 | - if (!childTaskPlans.isEmpty()) { | ||
| 2638 | - s.setFcsjActual(""); | ||
| 2639 | - s.setZdsjActual(""); | ||
| 2640 | - s.setJhlc(0.0); | ||
| 2641 | - } | ||
| 2642 | - | ||
| 2643 | - if (s.isDestroy()) { | ||
| 2644 | - if (s.isReissue()) { | ||
| 2645 | - s.setFcsjActual(s.getDfsj()); | ||
| 2646 | - s.setZdsjActual(s.getZdsj()); | ||
| 2647 | - s.setRemarks(""); | ||
| 2648 | - s.setStatus(2); | ||
| 2649 | - s.setJhlc(s.getJhlcOrig()); | ||
| 2650 | - } else { | ||
| 2651 | - s.setFcsjActual(""); | ||
| 2652 | - s.setZdsjActual(""); | ||
| 2653 | - s.setJhlc(0.0); | ||
| 2654 | - remarks += "(烂班)"; | ||
| 2655 | - s.setRemarks(remarks); | ||
| 2656 | - } | ||
| 2657 | - } | ||
| 2658 | - | ||
| 2659 | - listSchedule.add(s); | ||
| 2660 | - //计算营运里程,空驶里程 | ||
| 2661 | - if (!childTaskPlans.isEmpty()) { | ||
| 2662 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 2663 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 2664 | - Collections.sort(listit, new ComparableChild()); | ||
| 2665 | - for (int j = 0; j < listit.size(); j++) { | ||
| 2666 | - ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 2667 | - ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 2668 | - if (childTaskPlan.isDestroy()) { | ||
| 2669 | - t.setFcsjActual(""); | ||
| 2670 | - t.setZdsjActual(""); | ||
| 2671 | - t.setJhlc(0.0); | ||
| 2672 | - } else { | ||
| 2673 | - t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 2674 | - t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 2675 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 2676 | - } | ||
| 2677 | - t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 2678 | - t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 2679 | - t.setRemarks(childTaskPlan.getRemarks()); | ||
| 2680 | - t.setAdjustExps("子"); | ||
| 2681 | - listSchedule.add(t); | ||
| 2682 | - } | ||
| 2683 | - } | ||
| 2684 | - } | ||
| 2685 | - | ||
| 2686 | - return listSchedule; | ||
| 2687 | - } | ||
| 2688 | - | ||
| 2689 | - @Override | ||
| 2690 | - public Map<String, Object> removeChildTask(Long taskId) { | ||
| 2691 | - Map<String, Object> rs = new HashMap<>(); | ||
| 2692 | - ChildTaskPlan chTask = cTaskPlanRepository.findById(taskId).get(); | ||
| 2693 | - | ||
| 2694 | - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId()); | ||
| 2695 | - try { | ||
| 2696 | - | ||
| 2697 | - sch.getcTasks().remove(chTask); | ||
| 2698 | - scheduleRealInfoRepository.save(sch); | ||
| 2699 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 2700 | - } catch (Exception e) { | ||
| 2701 | - logger.error("", e); | ||
| 2702 | - rs.put("status", ResponseCode.ERROR); | ||
| 2703 | - } | ||
| 2704 | - return rs; | ||
| 2705 | - } | ||
| 2706 | - | ||
| 2707 | - @Override | ||
| 2708 | - public List<Map<String, Object>> statisticsDaily(String line, String date, | ||
| 2709 | - String xlName, String type) { | ||
| 2710 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 2711 | - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | ||
| 2712 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2713 | - for (int i = 0; i < list_s.size(); i++) { | ||
| 2714 | - ScheduleRealInfo s = list_s.get(i); | ||
| 2715 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2716 | - if (cts != null && cts.size() > 0) { | ||
| 2717 | - lists.add(s); | ||
| 2718 | - } else { | ||
| 2719 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2720 | - lists.add(s); | ||
| 2721 | - } | ||
| 2722 | - } | ||
| 2723 | - } | ||
| 2724 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2725 | - map.put("xlName", xlName); | ||
| 2726 | - double jhlc = culateService.culateJhgl(list_s); | ||
| 2727 | - map.put("jhlc", jhlc); | ||
| 2728 | - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists))); | ||
| 2729 | - double lbgl = culateService.culateLbgl(list_s); | ||
| 2730 | - map.put("ssgl", lbgl); | ||
| 2731 | - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); | ||
| 2732 | - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | ||
| 2733 | - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | ||
| 2734 | - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | ||
| 2735 | - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | ||
| 2736 | - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | ||
| 2737 | - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | ||
| 2738 | - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | ||
| 2739 | - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | ||
| 2740 | - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | ||
| 2741 | - map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚")); | ||
| 2742 | - double ssgl_pc = culateService.culateCJLC(list_s, "配车"); | ||
| 2743 | - double ssgl_by = culateService.culateCJLC(list_s, "保养"); | ||
| 2744 | - double ssgl_cj = culateService.culateCJLC(list_s, "抽减"); | ||
| 2745 | - double ssgl_qt = culateService.culateCJLC(list_s, "其他"); | ||
| 2746 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 2747 | - map.put("ssbc", culateService.culateLbbc(list_s)); | ||
| 2748 | - double ljgl = culateService.culateLjgl(lists); | ||
| 2749 | - map.put("ljgl", ljgl); | ||
| 2750 | - map.put("jhbc", culateService.culateJhbc(list_s, "")); | ||
| 2751 | - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | ||
| 2752 | - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | ||
| 2753 | - map.put("sjbc", culateService.culateSjbc(lists, "")); | ||
| 2754 | - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | ||
| 2755 | - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | ||
| 2756 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2757 | - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | ||
| 2758 | - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | ||
| 2759 | - map.put("fzbc", culateService.culateFzbc(lists, "")); | ||
| 2760 | - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | ||
| 2761 | - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | ||
| 2762 | - map.put("dtbc", 0); | ||
| 2763 | - map.put("dtbc_m", 0); | ||
| 2764 | - map.put("dtbc_a", 0); | ||
| 2765 | - List<CalcInterval> intervalList=calcIntervalRepository.selectByDateAndLine(line, date,""); | ||
| 2766 | - if(intervalList.size()>0){ | ||
| 2767 | - CalcInterval c=intervalList.get(0); | ||
| 2768 | - map.put("djg",c.getDjgAll()); | ||
| 2769 | - map.put("djg_m", c.getDjgZgf()); | ||
| 2770 | - map.put("djg_a", c.getDjgWgf()); | ||
| 2771 | - map.put("djg_time", c.getDjgTime()); | ||
| 2772 | - }else{ | ||
| 2773 | - Map<String, Object> m = culateService.culateDjg(list_s, line); | ||
| 2774 | - map.put("djg", m.get("djgcsq")); | ||
| 2775 | - map.put("djg_m", m.get("djgcsz")); | ||
| 2776 | - map.put("djg_a", m.get("djgcsw")); | ||
| 2777 | - map.put("djg_time", m.get("djgsj")); | ||
| 2778 | - } | ||
| 2779 | - | ||
| 2780 | - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl)); | ||
| 2781 | - lMap.add(map); | ||
| 2782 | - | ||
| 2783 | - if (date.length() == 10) { | ||
| 2784 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59"); | ||
| 2785 | - String dbdp = ""; | ||
| 2786 | - try { | ||
| 2787 | - for (int i = 0; i < list.size(); i++) { | ||
| 2788 | - DutyEmployee t = list.get(i); | ||
| 2789 | - if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 2790 | - if (!(dbdp.length() > 0)) { | ||
| 2791 | - dbdp = t.getuName(); | ||
| 2792 | - } else { | ||
| 2793 | - dbdp += "," + t.getuName(); | ||
| 2794 | - } | ||
| 2795 | - } | ||
| 2796 | - } | ||
| 2797 | - } catch (Exception e) { | ||
| 2798 | - // TODO: handle exception | ||
| 2799 | - e.printStackTrace(); | ||
| 2800 | - } | ||
| 2801 | - map.put("dbdp", dbdp); | ||
| 2802 | - } | ||
| 2803 | - | ||
| 2804 | - return lMap; | ||
| 2805 | - } | ||
| 2806 | - | ||
| 2807 | - @Override | ||
| 2808 | - public List<Map<String, Object>> statisticsDaily_mh_2(String line, String date, | ||
| 2809 | - String xlName, String type) { | ||
| 2810 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 2811 | - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | ||
| 2812 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2813 | - for (int i = 0; i < list_s.size(); i++) { | ||
| 2814 | - ScheduleRealInfo s = list_s.get(i); | ||
| 2815 | - if (s.isDestroy() && s.isReissue()) { | ||
| 2816 | - s.setRemark(""); | ||
| 2817 | - s.setFcsjActual(s.getDfsj()); | ||
| 2818 | - s.setZdsjActual(s.getZdsj()); | ||
| 2819 | - s.setStatus(2); | ||
| 2820 | - s.setJhlc(s.getJhlcOrig()); | ||
| 2821 | - } | ||
| 2822 | - | ||
| 2823 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2824 | - if (cts != null && cts.size() > 0) { | ||
| 2825 | - lists.add(s); | ||
| 2826 | - } else { | ||
| 2827 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2828 | - lists.add(s); | ||
| 2829 | - } | ||
| 2830 | - } | ||
| 2831 | - } | ||
| 2832 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2833 | - map.put("xlName", xlName); | ||
| 2834 | - double jhlc = culateService.culateJhgl(list_s); | ||
| 2835 | - map.put("jhlc", jhlc); | ||
| 2836 | - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists))); | ||
| 2837 | - double lbgl = culateService.culateLbgl(list_s); | ||
| 2838 | - map.put("ssgl", lbgl); | ||
| 2839 | - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); | ||
| 2840 | - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | ||
| 2841 | - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | ||
| 2842 | - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | ||
| 2843 | - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | ||
| 2844 | - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | ||
| 2845 | - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | ||
| 2846 | - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | ||
| 2847 | - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | ||
| 2848 | - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | ||
| 2849 | - map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚")); | ||
| 2850 | - double ssgl_pc = culateService.culateCJLC(list_s, "配车"); | ||
| 2851 | - double ssgl_by = culateService.culateCJLC(list_s, "保养"); | ||
| 2852 | - double ssgl_cj = culateService.culateCJLC(list_s, "抽减"); | ||
| 2853 | - double ssgl_qt = culateService.culateCJLC(list_s, "其他"); | ||
| 2854 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 2855 | - map.put("ssbc", culateService.culateLbbc(list_s)); | ||
| 2856 | - double ljgl = culateService.culateLjgl(lists); | ||
| 2857 | - map.put("ljgl", ljgl); | ||
| 2858 | - map.put("jhbc", culateService.culateJhbc(list_s, "")); | ||
| 2859 | - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | ||
| 2860 | - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | ||
| 2861 | - map.put("sjbc", culateService.culateSjbc(lists, "")); | ||
| 2862 | - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | ||
| 2863 | - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | ||
| 2864 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2865 | - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | ||
| 2866 | - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | ||
| 2867 | - map.put("fzbc", culateService.culateFzbc(lists, "")); | ||
| 2868 | - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | ||
| 2869 | - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | ||
| 2870 | - map.put("dtbc", 0); | ||
| 2871 | - map.put("dtbc_m", 0); | ||
| 2872 | - map.put("dtbc_a", 0); | ||
| 2873 | - map.put("djg", 0); | ||
| 2874 | - map.put("djg_m", 0); | ||
| 2875 | - map.put("djg_a", 0); | ||
| 2876 | - map.put("djg_time", 0); | ||
| 2877 | - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl)); | ||
| 2878 | - lMap.add(map); | ||
| 2879 | - return lMap; | ||
| 2880 | - } | ||
| 2881 | - | ||
| 2882 | - public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,Map<String, Object> m) { | ||
| 2883 | - | ||
| 2884 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2885 | - for (int i = 0; i < list.size(); i++) { | ||
| 2886 | - ScheduleRealInfo s = list.get(i); | ||
| 2887 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2888 | - if (cts != null && cts.size() > 0) { | ||
| 2889 | - lists.add(s); | ||
| 2890 | - } else { | ||
| 2891 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2892 | - lists.add(s); | ||
| 2893 | - } | ||
| 2894 | - } | ||
| 2895 | - } | ||
| 2896 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2897 | - if (list.size() > 0) { | ||
| 2898 | - map.put("gsBm", list.get(0).getGsBm()); | ||
| 2899 | - map.put("fgsBm", list.get(0).getFgsBm()); | ||
| 2900 | - map.put("xlBm", list.get(0).getXlBm()); | ||
| 2901 | - map.put("xlName", list.get(0).getXlName()); | ||
| 2902 | - map.put("fgsName", list.get(0).getFgsName()); | ||
| 2903 | - map.put("gsName", list.get(0).getGsName()); | ||
| 2904 | - | ||
| 2905 | - try { | ||
| 2906 | - map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getGsBm()+list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE)); | ||
| 2907 | - } catch (PinyinException e) { | ||
| 2908 | - // TODO Auto-generated catch block | ||
| 2909 | - e.printStackTrace(); | ||
| 2910 | - } | ||
| 2911 | - double jhyygl = culateService.culateJhgl(list);//计划营运公里 | ||
| 2912 | - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 2913 | - map.put("jhlc", jhyygl); | ||
| 2914 | - map.put("jcclc", jhjcclc); | ||
| 2915 | - map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | ||
| 2916 | - double ljks=culateService.culateLjksgl(lists); | ||
| 2917 | - map.put("ljks", ljks); | ||
| 2918 | - double ljgl = culateService.culateLjgl(lists); | ||
| 2919 | - double sjyygl = culateService.culateSjgl(lists); | ||
| 2920 | - double zyygl = Arith.add(sjyygl, ljgl); | ||
| 2921 | - | ||
| 2922 | - double sjjccgl = culateService.culateJccgl(lists); | ||
| 2923 | - double sjksgl = culateService.culateKsgl(lists); | ||
| 2924 | - double zksgl = Arith.add(sjjccgl, sjksgl); | ||
| 2925 | - map.put("sjzgl", Arith.add(zyygl, zksgl)); | ||
| 2926 | - map.put("sjgl", zyygl); | ||
| 2927 | - map.put("sjksgl", zksgl); | ||
| 2928 | - double ssgl = culateService.culateLbgl(list); | ||
| 2929 | - map.put("ssgl", ssgl); | ||
| 2930 | - | ||
| 2931 | - //计划+临加-少驶=实驶 | ||
| 2932 | - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | ||
| 2933 | - if (jl == zyygl) { | ||
| 2934 | - map.put("zt", 0); | ||
| 2935 | - } else { | ||
| 2936 | - map.put("zt", 1); | ||
| 2937 | - } | ||
| 2938 | - | ||
| 2939 | - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 2940 | - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 2941 | - map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 2942 | - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 2943 | - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 2944 | - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 2945 | - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 2946 | - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 2947 | - map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 2948 | - map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 2949 | - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚")); | ||
| 2950 | - double ssgl_pc = culateService.culateCJLC(list, "配车"); | ||
| 2951 | - double ssgl_by = culateService.culateCJLC(list, "保养"); | ||
| 2952 | - double ssgl_cj = culateService.culateCJLC(list, "抽减"); | ||
| 2953 | - double ssgl_qt = culateService.culateCJLC(list, "其他"); | ||
| 2954 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 2955 | - map.put("ssbc", culateService.culateLbbc(list)); | ||
| 2956 | - map.put("ljgl", ljgl); | ||
| 2957 | - map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 2958 | - map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 2959 | - map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 2960 | - map.put("sjbc", culateService.culateSjbc(lists, "")); | ||
| 2961 | - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | ||
| 2962 | - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | ||
| 2963 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2964 | - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | ||
| 2965 | - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | ||
| 2966 | - map.put("fzbc", culateService.culateFzbc(lists, "")); | ||
| 2967 | - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | ||
| 2968 | - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | ||
| 2969 | - map.put("dtbc", 0); | ||
| 2970 | - map.put("dtbc_m", 0); | ||
| 2971 | - map.put("dtbc_a", 0); | ||
| 2972 | - if(m.get("xl")==null){ | ||
| 2973 | - Map<String, Object> m_ = culateService.culateDjg(lists, list.get(0).getXlBm()); | ||
| 2974 | - map.put("djg", m_.get("djgcsq")); | ||
| 2975 | - map.put("djg_m", m_.get("djgcsz")); | ||
| 2976 | - map.put("djg_a", m_.get("djgcsw")); | ||
| 2977 | - map.put("djg_time", m_.get("djgsj")); | ||
| 2978 | - }else{ | ||
| 2979 | - map.put("djg", m.get("djgAll")==null?"0":m.get("djgAll")); | ||
| 2980 | - map.put("djg_m", m.get("djgZgf")==null?"0":m.get("djgZgf")); | ||
| 2981 | - map.put("djg_a", m.get("djgWgf")==null?"0":m.get("djgWgf")); | ||
| 2982 | - map.put("djg_time", m.get("djgTime")==null?"0":m.get("djgTime")); | ||
| 2983 | - } | ||
| 2984 | - } | ||
| 2985 | - return map; | ||
| 2986 | - } | ||
| 2987 | - | ||
| 2988 | - @Override | ||
| 2989 | - public List<Map<String, Object>> dispatchDailySum(String date, String date2, String nature, String type) { | ||
| 2990 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 2991 | - | ||
| 2992 | -// List<Map<String, Object>> list = statisticsDailyTj("", "", "", date, date2, "", "query", nature); | ||
| 2993 | - List<CalcStatistics> calc = calcWaybillService.calcStatisticsDaily("", "", "", date, date2, "", "query", nature); | ||
| 2994 | - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | ||
| 2995 | - try { | ||
| 2996 | - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 2997 | - for(CalcStatistics c : calc){ | ||
| 2998 | - Map<String, Object> m = new HashMap<>(); | ||
| 2999 | - Field[] fields = c.getClass().getDeclaredFields(); | ||
| 3000 | - for(Field f : fields){ | ||
| 3001 | - f.setAccessible(true); | ||
| 3002 | - String key = new String(f.getName()); | ||
| 3003 | - m.put(key, f.get(c)); | ||
| 3004 | - } | ||
| 3005 | - tempList.add(m); | ||
| 3006 | - } | ||
| 3007 | - list = tempList; | ||
| 3008 | - } catch (Exception e) { | ||
| 3009 | - // TODO: handle exception | ||
| 3010 | - e.printStackTrace(); | ||
| 3011 | - } | ||
| 3012 | - | ||
| 3013 | - List<Business> allBusiness = businessRepository.getOrder(); | ||
| 3014 | - Set<String> gsFgsSet = new HashSet<String>(); // 有排序编号的公司,防止乱序或者合计值出问题。 | ||
| 3015 | - for(Business b : allBusiness){ | ||
| 3016 | - gsFgsSet.add(b.getUpCode() + "_" + b.getBusinessCode()); | ||
| 3017 | - gsFgsSet.add(b.getBusinessCode()); | ||
| 3018 | - } | ||
| 3019 | - | ||
| 3020 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 3021 | - List<String> keyList = new ArrayList<String>(); | ||
| 3022 | - | ||
| 3023 | - Map<String, Object> hj = new HashMap<String, Object>(); // 合计 | ||
| 3024 | - hj.put("gsName", "合计"); | ||
| 3025 | - hj.put("fgsBm", " "); | ||
| 3026 | - | ||
| 3027 | - for(Map<String, Object> m : list){ | ||
| 3028 | - m.put("gsBm", m.get("gsdm")); | ||
| 3029 | - m.put("fgsBm", m.get("fgsdm")); | ||
| 3030 | - if(m.get("gsBm") != null && m.get("fgsBm") != null | ||
| 3031 | - && m.get("gsBm").toString().trim().length() > 0 | ||
| 3032 | - && m.get("fgsBm").toString().trim().length() > 0){ | ||
| 3033 | - String gsBm = m.get("gsBm").toString().trim(); | ||
| 3034 | - String fgsBm = m.get("fgsBm").toString().trim(); | ||
| 3035 | - String key = gsBm + "_" + fgsBm; // 分公司key | ||
| 3036 | - String key2 = gsBm + "_sum"; // 直属公司key | ||
| 3037 | - if(!gsFgsSet.contains(key) && !gsFgsSet.contains(gsBm)){ | ||
| 3038 | - continue; | ||
| 3039 | - } | ||
| 3040 | - if(!keyMap.containsKey(key)){ // 每个分公司一条 | ||
| 3041 | - Map<String, Object> t = new HashMap<String, Object>(); | ||
| 3042 | - t.put("gsName", m.get("gsName")); | ||
| 3043 | - t.put("fgsName", m.get("fgsName")); | ||
| 3044 | - t.put("key", key); | ||
| 3045 | - keyMap.put(key, t); | ||
| 3046 | - keyList.add(key); | ||
| 3047 | - if(!keyMap.containsKey(key2)){ // 直属公司小计 | ||
| 3048 | - Map<String, Object> t2 = new HashMap<String, Object>(); | ||
| 3049 | - t2.put("gsName", m.get("gsName")); | ||
| 3050 | - t2.put("fgsName", "小计"); | ||
| 3051 | - t2.put("key", key2); | ||
| 3052 | - keyMap.put(key2, t2); | ||
| 3053 | - keyList.add(key2); | ||
| 3054 | - } | ||
| 3055 | - } | ||
| 3056 | - Map<String, Object> t = keyMap.get(key); | ||
| 3057 | - Map<String, Object> t2 = keyMap.get(key2); | ||
| 3058 | - for(String s : m.keySet()){ | ||
| 3059 | - if("gsName,fgsName,key".contains(s)){ | ||
| 3060 | - continue; | ||
| 3061 | - } | ||
| 3062 | - try { | ||
| 3063 | - if(t.containsKey(s)){ // 分公司 | ||
| 3064 | - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString()))); | ||
| 3065 | - } else { | ||
| 3066 | - t.put(s, m.get(s).toString()); | ||
| 3067 | - } | ||
| 3068 | - if(t2.containsKey(s)){ // 直属公司 | ||
| 3069 | - t2.put(s, new BigDecimal(t2.get(s).toString()).add(new BigDecimal(m.get(s).toString()))); | ||
| 3070 | - } else { | ||
| 3071 | - t2.put(s, m.get(s).toString()); | ||
| 3072 | - } | ||
| 3073 | - if(hj.containsKey(s)){ // 合计 | ||
| 3074 | - hj.put(s, new BigDecimal(hj.get(s).toString()).add(new BigDecimal(m.get(s).toString()))); | ||
| 3075 | - } else { | ||
| 3076 | - hj.put(s, m.get(s).toString()); | ||
| 3077 | - } | ||
| 3078 | - } catch (Exception e) { | ||
| 3079 | - // TODO: handle exception | ||
| 3080 | - continue; | ||
| 3081 | - } | ||
| 3082 | - } | ||
| 3083 | - } | ||
| 3084 | - } | ||
| 3085 | - | ||
| 3086 | - for(Business b : allBusiness){ // 根据公司排序插入返回对象 | ||
| 3087 | - String gs = b.getBusinessCode(); | ||
| 3088 | - String gsfgs = b.getUpCode() + "_" + b.getBusinessCode(); | ||
| 3089 | - for(String key : keyList){ | ||
| 3090 | - if(key.equals(gsfgs)){ | ||
| 3091 | - resList.add(keyMap.get(key)); | ||
| 3092 | - break; | ||
| 3093 | - } else if(key.replaceAll("_sum", "").equals(gs)){ | ||
| 3094 | - resList.add(keyMap.get(key)); | ||
| 3095 | - break; | ||
| 3096 | - } | ||
| 3097 | - } | ||
| 3098 | - } | ||
| 3099 | - resList.add(hj); | ||
| 3100 | - | ||
| 3101 | - for(Map<String, Object> m : resList){ | ||
| 3102 | - try { | ||
| 3103 | - m.put("jhzlc", m.get("jhzlc")); | ||
| 3104 | - m.put("jhlc", m.get("jhyylc")); | ||
| 3105 | - m.put("jcclc", m.get("jhkslc")); | ||
| 3106 | - m.put("sjzgl", m.get("sjzlc")); | ||
| 3107 | - m.put("sjgl", m.get("sjyylc")); | ||
| 3108 | - m.put("sjksgl", m.get("sjkslc")); | ||
| 3109 | - m.put("ssbc", m.get("ssbc")); | ||
| 3110 | - m.put("ssgl", m.get("sslc")); | ||
| 3111 | - m.put("ssgl_lz", m.get("lzlc")); | ||
| 3112 | - m.put("ssgl_dm", m.get("dmlc")); | ||
| 3113 | - m.put("ssgl_gz", m.get("gzlc")); | ||
| 3114 | - m.put("ssgl_jf", m.get("jflc")); | ||
| 3115 | - m.put("ssgl_zs", m.get("zslc")); | ||
| 3116 | - m.put("ssgl_qr", m.get("qrlc")); | ||
| 3117 | - m.put("ssgl_qc", m.get("qclc")); | ||
| 3118 | - m.put("ssgl_kx", m.get("kxlc")); | ||
| 3119 | - m.put("ssgl_qh", m.get("qhlc")); | ||
| 3120 | - m.put("ssgl_yw", m.get("ywlc")); | ||
| 3121 | - m.put("ssgl_ljpm", m.get("ljpmlc")); | ||
| 3122 | - m.put("ssgl_other", m.get("qtlc")); | ||
| 3123 | - m.put("ljgl", m.get("ljlc")); | ||
| 3124 | - m.put("ljks", m.get("ljkslc")); | ||
| 3125 | - m.put("jhbc", m.get("jhbcq")); | ||
| 3126 | - m.put("jhbc_m", m.get("jhbcz")); | ||
| 3127 | - m.put("jhbc_a", m.get("jhbcw")); | ||
| 3128 | - m.put("sjbc", m.get("sjbcq")); | ||
| 3129 | - m.put("sjbc_m", m.get("sjbcz")); | ||
| 3130 | - m.put("sjbc_a", m.get("sjbcw")); | ||
| 3131 | - m.put("ljbc", m.get("ljbcq")); | ||
| 3132 | - m.put("ljbc_m", m.get("ljbcz")); | ||
| 3133 | - m.put("ljbc_a", m.get("ljbcw")); | ||
| 3134 | - m.put("fzbc", m.get("fzbcq")); | ||
| 3135 | - m.put("fzbc_m", m.get("fzbcz")); | ||
| 3136 | - m.put("fzbc_a", m.get("fzbcw")); | ||
| 3137 | - m.put("dtbc", m.get("dtbcq")); | ||
| 3138 | - m.put("dtbc_m", m.get("dtbcz")); | ||
| 3139 | - m.put("dtbc_a", m.get("dtbcw")); | ||
| 3140 | - m.put("djg", m.get("djgq")); | ||
| 3141 | - m.put("djg_m", m.get("djgz")); | ||
| 3142 | - m.put("djg_a", m.get("djgw")); | ||
| 3143 | - m.put("djg_time", m.get("djgsj")); | ||
| 3144 | - m.put("ljzgl", new BigDecimal(m.get("ljgl").toString()).add(new BigDecimal(m.get("ljks").toString()))); | ||
| 3145 | - } catch (Exception e) { | ||
| 3146 | - // TODO: handle exception | ||
| 3147 | - m.put("ljzgl", ""); | ||
| 3148 | - continue; | ||
| 3149 | - } | ||
| 3150 | - } | ||
| 3151 | - | ||
| 3152 | - if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 3153 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3154 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3155 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3156 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3157 | - ReportUtils ee = new ReportUtils(); | ||
| 3158 | - try { | ||
| 3159 | - String dateTime = ""; | ||
| 3160 | - if (date.equals(date2)) { | ||
| 3161 | - m.put("date", date); | ||
| 3162 | - dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 3163 | - } else { | ||
| 3164 | - m.put("date", date + "至" + date2); | ||
| 3165 | - dateTime = sdfSimple.format(sdfMonth.parse(date)) | ||
| 3166 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 3167 | - } | ||
| 3168 | - listI.add(resList.iterator()); | ||
| 3169 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3170 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/dispatchDailySum.xls", | ||
| 3171 | - path + "export/" + dateTime + "-调度日报汇总表.xls"); | ||
| 3172 | - } catch (Exception e) { | ||
| 3173 | - // TODO: handle exception | ||
| 3174 | - //e.printStackTrace(); | ||
| 3175 | - logger.info("", e); | ||
| 3176 | - } | ||
| 3177 | - } | ||
| 3178 | - | ||
| 3179 | - return resList; | ||
| 3180 | - } | ||
| 3181 | - | ||
| 3182 | - @Override | ||
| 3183 | - public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2, | ||
| 3184 | - String xlName, String type,String nature) { | ||
| 3185 | - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>(); | ||
| 3186 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 3187 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3188 | - List<Object[]> listInterval=new ArrayList<Object[]>(); | ||
| 3189 | - line = line.trim(); | ||
| 3190 | - if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){ | ||
| 3191 | - //查询所有公司 | ||
| 3192 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2); | ||
| 3193 | - listInterval = calcIntervalRepository.countByDate(date, date2); | ||
| 3194 | - } else if (line.equals("")) { | ||
| 3195 | - //查询所有线路 | ||
| 3196 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | ||
| 3197 | - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2); | ||
| 3198 | - } else { | ||
| 3199 | - //查询单条线路 | ||
| 3200 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | ||
| 3201 | - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2); | ||
| 3202 | - } | ||
| 3203 | - Map<String, Map<String,Object>> mapInterval=new HashMap<String, Map<String,Object>>(); | ||
| 3204 | - for (int i = 0; i < listInterval.size(); i++) { | ||
| 3205 | - Object[] interval=listInterval.get(i); | ||
| 3206 | - String gs=interval[0].toString(); | ||
| 3207 | - String fgs=interval[1].toString(); | ||
| 3208 | - String xl=interval[2].toString(); | ||
| 3209 | - Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3210 | - m.put("gs", gs); | ||
| 3211 | - m.put("fgs", fgs); | ||
| 3212 | - m.put("xl", xl); | ||
| 3213 | - m.put("djgAll", interval[3]); | ||
| 3214 | - m.put("djgZgf", interval[6]); | ||
| 3215 | - m.put("djgWgf", interval[7]); | ||
| 3216 | - m.put("djgTime", interval[8]); | ||
| 3217 | - mapInterval.put(gs+"-"+fgs+"-"+xl, m); | ||
| 3218 | - } | ||
| 3219 | - Map<String, Boolean> lineMap=lineService.lineNature(); | ||
| 3220 | - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | ||
| 3221 | - for (int i = 0; i < listAll.size(); i++) { | ||
| 3222 | - ScheduleRealInfo s=listAll.get(i); | ||
| 3223 | - if (nature.equals("0")) { | ||
| 3224 | - list.add(s); | ||
| 3225 | - }else if(nature.equals("1")){ | ||
| 3226 | - if(lineMap.get(s.getXlBm())){ | ||
| 3227 | - list.add(s); | ||
| 3228 | - } | ||
| 3229 | - }else{ | ||
| 3230 | - if(!lineMap.get(s.getXlBm())){ | ||
| 3231 | - list.add(s); | ||
| 3232 | - } | ||
| 3233 | - } | ||
| 3234 | - } | ||
| 3235 | - for (int i = 0; i < list.size(); i++) { | ||
| 3236 | - ScheduleRealInfo s = list.get(i); | ||
| 3237 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 3238 | - if (cts != null && cts.size() > 0) { | ||
| 3239 | - list_s.add(s); | ||
| 3240 | - } else { | ||
| 3241 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 3242 | - list_s.add(s); | ||
| 3243 | - } | ||
| 3244 | - } | ||
| 3245 | - } | ||
| 3246 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 3247 | - for (int i = 0; i < list.size(); i++) { | ||
| 3248 | - if (i < list.size() - 1) { | ||
| 3249 | - if ((list.get(i+1).getGsBm()+"/"+list.get(i+1).getFgsBm()+"/"+list.get(i+1).getXlBm()).equals( | ||
| 3250 | - list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm())) { | ||
| 3251 | - lists.add(list.get(i)); | ||
| 3252 | - } else { | ||
| 3253 | - lists.add(list.get(i)); | ||
| 3254 | - Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3255 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3256 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3257 | - } | ||
| 3258 | - Map<String, Object> map = staticTj(lists,mm); | ||
| 3259 | - lMap.add(map); | ||
| 3260 | - lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3261 | - } | ||
| 3262 | - } else { | ||
| 3263 | - if ((list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm()).equals( | ||
| 3264 | - list.get(i-1).getGsBm()+"/"+list.get(i-1).getFgsBm()+"/"+list.get(i-1).getXlBm())) { | ||
| 3265 | - lists.add(list.get(i)); | ||
| 3266 | - Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3267 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3268 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3269 | - } | ||
| 3270 | - Map<String, Object> map = staticTj(lists,mm); | ||
| 3271 | - lMap.add(map); | ||
| 3272 | - } else { | ||
| 3273 | - lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3274 | - lists.add(list.get(i)); | ||
| 3275 | - Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3276 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3277 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3278 | - } | ||
| 3279 | - Map<String, Object> map = staticTj(lists,mm); | ||
| 3280 | - lMap.add(map); | ||
| 3281 | - } | ||
| 3282 | - } | ||
| 3283 | - } | ||
| 3284 | - | ||
| 3285 | - Collections.sort(lMap, new AccountXlbm()); | ||
| 3286 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 3287 | - map.put("xlName", "合计"); | ||
| 3288 | - map.put("fgsName", ""); | ||
| 3289 | - map.put("gsName", ""); | ||
| 3290 | - double jhyygl = culateService.culateJhgl(list);//计划营运公里 | ||
| 3291 | - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 3292 | - map.put("jhlc", jhyygl); | ||
| 3293 | - map.put("jcclc", jhjcclc); | ||
| 3294 | - map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | ||
| 3295 | - | ||
| 3296 | - double ljgl = culateService.culateLjgl(list_s); | ||
| 3297 | - double sjyygl = culateService.culateSjgl(list_s); | ||
| 3298 | - double zyygl = Arith.add(sjyygl, ljgl); | ||
| 3299 | - double ljks=culateService.culateLjksgl(list_s); | ||
| 3300 | - map.put("ljks", ljks); | ||
| 3301 | - double sjjccgl = culateService.culateJccgl(list_s); | ||
| 3302 | - double sjksgl = culateService.culateKsgl(list_s); | ||
| 3303 | - double zksgl = Arith.add(sjjccgl, sjksgl); | ||
| 3304 | - map.put("sjzgl", Arith.add(zyygl, zksgl)); | ||
| 3305 | - map.put("sjgl", zyygl); | ||
| 3306 | - map.put("sjksgl", zksgl); | ||
| 3307 | - | ||
| 3308 | - double ssgl = culateService.culateLbgl(list); | ||
| 3309 | - map.put("ssgl", ssgl); | ||
| 3310 | - //计划+临加-少驶=实驶 | ||
| 3311 | - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | ||
| 3312 | - if (jl == zyygl) { | ||
| 3313 | - map.put("zt", 0); | ||
| 3314 | - } else { | ||
| 3315 | - map.put("zt", 1); | ||
| 3316 | - } | ||
| 3317 | - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 3318 | - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 3319 | - map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 3320 | - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 3321 | - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 3322 | - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 3323 | - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 3324 | - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 3325 | - map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 3326 | - map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 3327 | - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚")); | ||
| 3328 | - double ssgl_pc = culateService.culateCJLC(list, "配车"); | ||
| 3329 | - double ssgl_by = culateService.culateCJLC(list, "保养"); | ||
| 3330 | - double ssgl_cj = culateService.culateCJLC(list, "抽减"); | ||
| 3331 | - double ssgl_qt = culateService.culateCJLC(list, "其他"); | ||
| 3332 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 3333 | - | ||
| 3334 | - map.put("ssbc", culateService.culateLbbc(list)); | ||
| 3335 | - map.put("ljgl", ljgl); | ||
| 3336 | - map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 3337 | - map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 3338 | - map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 3339 | - map.put("sjbc", culateService.culateSjbc(list_s, "")); | ||
| 3340 | - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | ||
| 3341 | - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | ||
| 3342 | - map.put("ljbc", culateService.culateLjbc(list_s, "")); | ||
| 3343 | - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | ||
| 3344 | - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | ||
| 3345 | - map.put("fzbc", culateService.culateFzbc(list_s, "")); | ||
| 3346 | - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | ||
| 3347 | - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | ||
| 3348 | - map.put("dtbc", 0); | ||
| 3349 | - map.put("dtbc_m", 0); | ||
| 3350 | - map.put("dtbc_a", 0); | ||
| 3351 | - if (list.size() > 0) { | ||
| 3352 | - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | ||
| 3353 | - for (Map<String, Object> m : lMap) { | ||
| 3354 | - if (m.containsKey("djg") && m.get("djg") != null) | ||
| 3355 | - djg += Integer.valueOf(m.get("djg").toString()); | ||
| 3356 | - if (m.containsKey("djg_m") && m.get("djg_m") != null) | ||
| 3357 | - djg_m += Integer.valueOf(m.get("djg_m").toString()); | ||
| 3358 | - if (m.containsKey("djg_a") && m.get("djg_a") != null) | ||
| 3359 | - djg_a += Integer.valueOf(m.get("djg_a").toString()); | ||
| 3360 | - if (m.containsKey("djg_time") && m.get("djg_time") != null) { | ||
| 3361 | - int t = Integer.valueOf(m.get("djg_time").toString()); | ||
| 3362 | - if (t > djg_time) | ||
| 3363 | - djg_time = t; | ||
| 3364 | - } | ||
| 3365 | - } | ||
| 3366 | - map.put("djg", djg); | ||
| 3367 | - map.put("djg_m", djg_m); | ||
| 3368 | - map.put("djg_a", djg_a); | ||
| 3369 | - map.put("djg_time", djg_time); | ||
| 3370 | -// Map<String, Object> m_=culateService.culateDjg(list_s, list.get(0).getXlBm()); | ||
| 3371 | -// map.put("djg", m_.get("djgcsq")); | ||
| 3372 | -// map.put("djg_m", m_.get("djgcsz")); | ||
| 3373 | -// map.put("djg_a", m_.get("djgcsw")); | ||
| 3374 | -// map.put("djg_time", m_.get("djgsj")); | ||
| 3375 | - } else { | ||
| 3376 | - map.put("djg", "0"); | ||
| 3377 | - map.put("djg_m", "0"); | ||
| 3378 | - map.put("djg_a", "0"); | ||
| 3379 | - map.put("djg_time", "0"); | ||
| 3380 | - } | ||
| 3381 | - lMap.add(map); | ||
| 3382 | - | ||
| 3383 | - if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 3384 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3385 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3386 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3387 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3388 | - m.put("date", date + "至" + date2); | ||
| 3389 | - ReportUtils ee = new ReportUtils(); | ||
| 3390 | - try { | ||
| 3391 | - String dateTime = ""; | ||
| 3392 | - if (date.equals(date2)) { | ||
| 3393 | - dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 3394 | - } else { | ||
| 3395 | - dateTime = sdfSimple.format(sdfMonth.parse(date)) | ||
| 3396 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 3397 | - } | ||
| 3398 | - listI.add(lMap.iterator()); | ||
| 3399 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3400 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls", | ||
| 3401 | - path + "export/" + dateTime + "-" + xlName + "-统计日报.xls"); | ||
| 3402 | - } catch (Exception e) { | ||
| 3403 | - // TODO: handle exception | ||
| 3404 | - //e.printStackTrace(); | ||
| 3405 | - logger.info("", e); | ||
| 3406 | - } | ||
| 3407 | - } | ||
| 3408 | - | ||
| 3409 | - if (type != null && type.length() != 0 && type.equals("exportAll")) { | ||
| 3410 | - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 3411 | - Map<String, Map<String, Object>> tempMap = new HashMap<String, Map<String, Object>>(); | ||
| 3412 | - List<Map<String, Object>> removeList = new ArrayList<Map<String, Object>>(); | ||
| 3413 | - for(Map<String, Object> m : lMap){ | ||
| 3414 | - if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0 | ||
| 3415 | - && m.get("gsName").toString().trim().contains("临港")){ | ||
| 3416 | - removeList.add(m); | ||
| 3417 | - } | ||
| 3418 | - } | ||
| 3419 | - for(Map<String, Object> m : removeList){ | ||
| 3420 | - lMap.remove(m); | ||
| 3421 | - } | ||
| 3422 | - for(Map<String, Object> m : lMap){ | ||
| 3423 | - if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0){ | ||
| 3424 | - String gsName = m.get("gsName").toString().trim(); | ||
| 3425 | - Map<String, Object> temp = new HashMap<String, Object>(); | ||
| 3426 | - if(tempMap.get(gsName) != null){ | ||
| 3427 | - temp = tempMap.get(gsName); | ||
| 3428 | - } else { | ||
| 3429 | - temp.put("gsName", gsName); | ||
| 3430 | - temp.put("fgsName", "小计"); | ||
| 3431 | - temp.put("xlName", ""); | ||
| 3432 | - tempList.add(temp); | ||
| 3433 | - tempMap.put(gsName, temp); | ||
| 3434 | - } | ||
| 3435 | - for(String key : m.keySet()){ | ||
| 3436 | - try { | ||
| 3437 | - temp.put(key, new BigDecimal(m.get(key).toString()).add( | ||
| 3438 | - new BigDecimal(temp.get(key)!=null?temp.get(key).toString():"0"))); | ||
| 3439 | - } catch (Exception e) { | ||
| 3440 | - // TODO: handle exception | ||
| 3441 | - } | ||
| 3442 | - } | ||
| 3443 | - } | ||
| 3444 | - } | ||
| 3445 | - lMap.addAll(lMap.size()>0?lMap.size()-1:0, tempList); | ||
| 3446 | - | ||
| 3447 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3448 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3449 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3450 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3451 | - m.put("date", date + "至" + date2); | ||
| 3452 | - ReportUtils ee = new ReportUtils(); | ||
| 3453 | - try { | ||
| 3454 | - String dateTime = ""; | ||
| 3455 | - if (date.equals(date2)) { | ||
| 3456 | - dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 3457 | - } else { | ||
| 3458 | - dateTime = sdfSimple.format(sdfMonth.parse(date)) | ||
| 3459 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 3460 | - } | ||
| 3461 | - listI.add(lMap.iterator()); | ||
| 3462 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3463 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_4.xls", | ||
| 3464 | - path + "export/" + dateTime + "-全部公司-统计日报.xls"); | ||
| 3465 | - } catch (Exception e) { | ||
| 3466 | - // TODO: handle exception | ||
| 3467 | - //e.printStackTrace(); | ||
| 3468 | - logger.info("", e); | ||
| 3469 | - } | ||
| 3470 | - } | ||
| 3471 | - | ||
| 3472 | - return lMap; | ||
| 3473 | - } | ||
| 3474 | - | ||
| 3475 | - @Override | ||
| 3476 | - public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2, | ||
| 3477 | - String xlName, String type,String nature) { | ||
| 3478 | - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>(); | ||
| 3479 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 3480 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3481 | - List<Object[]> listInterval=new ArrayList<Object[]>(); | ||
| 3482 | - | ||
| 3483 | - line = line.trim(); | ||
| 3484 | - if (line.equals("")) { | ||
| 3485 | - //查询所有线路 | ||
| 3486 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | ||
| 3487 | - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2); | ||
| 3488 | - } else { | ||
| 3489 | - //查询单条线路 | ||
| 3490 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | ||
| 3491 | - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2); | ||
| 3492 | - } | ||
| 3493 | - Map<String, Map<String,Object>> mapInterval=new HashMap<>(); | ||
| 3494 | - for (int i = 0; i < listInterval.size(); i++) { | ||
| 3495 | - Object[] interval=listInterval.get(i); | ||
| 3496 | - String gs=interval[0].toString(); | ||
| 3497 | - String fgs=interval[1].toString(); | ||
| 3498 | - String xl=interval[2].toString(); | ||
| 3499 | - Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3500 | - m.put("gs", gs); | ||
| 3501 | - m.put("fgs", fgs); | ||
| 3502 | - m.put("xl", xl); | ||
| 3503 | - m.put("djgAll", interval[3]); | ||
| 3504 | - m.put("djgZgf", interval[6]); | ||
| 3505 | - m.put("djgWgf", interval[7]); | ||
| 3506 | - m.put("djgTime", interval[8]); | ||
| 3507 | - mapInterval.put(gs+"-"+fgs+"-"+xl, m); | ||
| 3508 | - } | ||
| 3509 | - | ||
| 3510 | - Map<String, Boolean> lineMap=lineService.lineNature(); | ||
| 3511 | - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | ||
| 3512 | - for (int i = 0; i < listAll.size(); i++) { | ||
| 3513 | - ScheduleRealInfo s=listAll.get(i); | ||
| 3514 | - if (nature.equals("0")) { | ||
| 3515 | - list.add(s); | ||
| 3516 | - }else if(nature.equals("1")){ | ||
| 3517 | - if(lineMap.get(s.getXlBm())){ | ||
| 3518 | - list.add(s); | ||
| 3519 | - } | ||
| 3520 | - }else{ | ||
| 3521 | - if(!lineMap.get(s.getXlBm())){ | ||
| 3522 | - list.add(s); | ||
| 3523 | - } | ||
| 3524 | - } | ||
| 3525 | - } | ||
| 3526 | - for (int i = 0; i < list.size(); i++) { | ||
| 3527 | - ScheduleRealInfo s = list.get(i); | ||
| 3528 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 3529 | - if (cts != null && cts.size() > 0) { | ||
| 3530 | - list_s.add(s); | ||
| 3531 | - } else { | ||
| 3532 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 3533 | - list_s.add(s); | ||
| 3534 | - } | ||
| 3535 | - } | ||
| 3536 | - } | ||
| 3537 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 3538 | - for (int i = 0; i < list.size(); i++) { | ||
| 3539 | - if (i < list.size() - 1) { | ||
| 3540 | - if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) { | ||
| 3541 | - lists.add(list.get(i)); | ||
| 3542 | - } else { | ||
| 3543 | - lists.add(list.get(i)); | ||
| 3544 | - Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3545 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3546 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3547 | - } | ||
| 3548 | - Map<String, Object> map = staticTj(lists,mm); | ||
| 3549 | - lMap.add(map); | ||
| 3550 | - lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3551 | - } | ||
| 3552 | - } else { | ||
| 3553 | - if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) { | ||
| 3554 | - lists.add(list.get(i)); | ||
| 3555 | - Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3556 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3557 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3558 | - } | ||
| 3559 | - Map<String, Object> map = staticTj(lists,mm); | ||
| 3560 | - lMap.add(map); | ||
| 3561 | - } else { | ||
| 3562 | - lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3563 | - lists.add(list.get(i)); | ||
| 3564 | - Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3565 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3566 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3567 | - } | ||
| 3568 | - Map<String, Object> map = staticTj(lists,mm); | ||
| 3569 | - lMap.add(map); | ||
| 3570 | - } | ||
| 3571 | - } | ||
| 3572 | - } | ||
| 3573 | - | ||
| 3574 | - Collections.sort(lMap, new AccountXlbm()); | ||
| 3575 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 3576 | - map.put("xlBm", "hj"); | ||
| 3577 | - map.put("xlName", "合计"); | ||
| 3578 | - map.put("fgsBm", ""); | ||
| 3579 | - map.put("fgsName", ""); | ||
| 3580 | - map.put("gsBm", ""); | ||
| 3581 | - double jhyygl = culateService.culateJhgl(list);//计划营运公里 | ||
| 3582 | - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 3583 | - map.put("jhlc", jhyygl); | ||
| 3584 | - map.put("jcclc", jhjcclc); | ||
| 3585 | - map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | ||
| 3586 | - | ||
| 3587 | - double ljgl = culateService.culateLjgl(list_s); | ||
| 3588 | - double sjyygl = culateService.culateSjgl(list_s); | ||
| 3589 | - double zyygl = Arith.add(sjyygl, ljgl); | ||
| 3590 | - double ljks=culateService.culateLjksgl(list_s); | ||
| 3591 | - map.put("ljks", ljks); | ||
| 3592 | - double sjjccgl = culateService.culateJccgl(list_s); | ||
| 3593 | - double sjksgl = culateService.culateKsgl(list_s); | ||
| 3594 | - double zksgl = Arith.add(sjjccgl, sjksgl); | ||
| 3595 | - map.put("sjzgl", Arith.add(zyygl, zksgl)); | ||
| 3596 | - map.put("sjgl", zyygl); | ||
| 3597 | - map.put("sjksgl", zksgl); | ||
| 3598 | - | ||
| 3599 | - double ssgl = culateService.culateLbgl(list); | ||
| 3600 | - map.put("ssgl", ssgl); | ||
| 3601 | - //计划+临加-少驶=实驶 | ||
| 3602 | - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | ||
| 3603 | - if (jl == zyygl) { | ||
| 3604 | - map.put("zt", 0); | ||
| 3605 | - } else { | ||
| 3606 | - map.put("zt", 1); | ||
| 3607 | - } | ||
| 3608 | - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 3609 | - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 3610 | - map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 3611 | - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 3612 | - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 3613 | - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 3614 | - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 3615 | - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 3616 | - map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 3617 | - map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 3618 | - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚")); | ||
| 3619 | - double ssgl_pc = culateService.culateCJLC(list, "配车"); | ||
| 3620 | - double ssgl_by = culateService.culateCJLC(list, "保养"); | ||
| 3621 | - double ssgl_cj = culateService.culateCJLC(list, "抽减"); | ||
| 3622 | - double ssgl_qt = culateService.culateCJLC(list, "其他"); | ||
| 3623 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 3624 | - | ||
| 3625 | - map.put("ssbc", culateService.culateLbbc(list)); | ||
| 3626 | - map.put("ljgl", ljgl); | ||
| 3627 | - map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 3628 | - map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 3629 | - map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 3630 | - map.put("sjbc", culateService.culateSjbc(list_s, "")); | ||
| 3631 | - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | ||
| 3632 | - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | ||
| 3633 | - map.put("ljbc", culateService.culateLjbc(list_s, "")); | ||
| 3634 | - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | ||
| 3635 | - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | ||
| 3636 | - map.put("fzbc", culateService.culateFzbc(list_s, "")); | ||
| 3637 | - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | ||
| 3638 | - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | ||
| 3639 | - map.put("dtbc", 0); | ||
| 3640 | - map.put("dtbc_m", 0); | ||
| 3641 | - map.put("dtbc_a", 0); | ||
| 3642 | - if (list.size() > 0) { | ||
| 3643 | - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | ||
| 3644 | - for (Map<String, Object> m : lMap) { | ||
| 3645 | - if (m.containsKey("djg") && m.get("djg") != null) | ||
| 3646 | - djg += Integer.valueOf(m.get("djg").toString()); | ||
| 3647 | - if (m.containsKey("djg_m") && m.get("djg_m") != null) | ||
| 3648 | - djg_m += Integer.valueOf(m.get("djg_m").toString()); | ||
| 3649 | - if (m.containsKey("djg_a") && m.get("djg_a") != null) | ||
| 3650 | - djg_a += Integer.valueOf(m.get("djg_a").toString()); | ||
| 3651 | - if (m.containsKey("djg_time") && m.get("djg_time") != null) { | ||
| 3652 | - int t = Integer.valueOf(m.get("djg_time").toString()); | ||
| 3653 | - if (t > djg_time) | ||
| 3654 | - djg_time = t; | ||
| 3655 | - } | ||
| 3656 | - } | ||
| 3657 | - map.put("djg", djg); | ||
| 3658 | - map.put("djg_m", djg_m); | ||
| 3659 | - map.put("djg_a", djg_a); | ||
| 3660 | - map.put("djg_time", djg_time); | ||
| 3661 | - } else { | ||
| 3662 | - map.put("djg", "0"); | ||
| 3663 | - map.put("djg_m", "0"); | ||
| 3664 | - map.put("djg_a", "0"); | ||
| 3665 | - map.put("djg_time", "0"); | ||
| 3666 | - } | ||
| 3667 | - lMap.add(map); | ||
| 3668 | - return lMap; | ||
| 3669 | - } | ||
| 3670 | - | ||
| 3671 | - @Override | ||
| 3672 | - public Map<String, Object> scheduleDaily(String line, String date) { | ||
| 3673 | - Map<String, String> tempMap = null; | ||
| 3674 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); | ||
| 3675 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 3676 | - Double jhlc = 0.00; | ||
| 3677 | - Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, | ||
| 3678 | - ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_ljpm = 0f, | ||
| 3679 | - ssgl_other = 0f, ljgl = 0f; | ||
| 3680 | - int jhbc = 0; | ||
| 3681 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | ||
| 3682 | - if (scheduleRealInfo != null) { | ||
| 3683 | - //计算里程(包括子任务) | ||
| 3684 | - jhlc += scheduleRealInfo.getJhlc(); | ||
| 3685 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 3686 | - if (!childTaskPlans.isEmpty()) { | ||
| 3687 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 3688 | - while (it.hasNext()) { | ||
| 3689 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 3690 | - //是否烂班,烂班就是少驶 | ||
| 3691 | - if (!childTaskPlan.isDestroy()) { | ||
| 3692 | - sjgl += childTaskPlan.getMileage(); | ||
| 3693 | - } else { | ||
| 3694 | - ssgl += childTaskPlan.getMileage(); | ||
| 3695 | - if (childTaskPlan.getDestroyReason().equals("路阻")) { | ||
| 3696 | - ssgl_lz += childTaskPlan.getMileage(); | ||
| 3697 | - } else if (childTaskPlan.getDestroyReason().equals("吊慢")) { | ||
| 3698 | - ssgl_dm += childTaskPlan.getMileage(); | ||
| 3699 | - } else if (childTaskPlan.getDestroyReason().equals("故障")) { | ||
| 3700 | - ssgl_gz += childTaskPlan.getMileage(); | ||
| 3701 | - } else if (childTaskPlan.getDestroyReason().equals("纠纷")) { | ||
| 3702 | - ssgl_jf += childTaskPlan.getMileage(); | ||
| 3703 | - } else if (childTaskPlan.getDestroyReason().equals("肇事")) { | ||
| 3704 | - ssgl_zs += childTaskPlan.getMileage(); | ||
| 3705 | - } else if (childTaskPlan.getDestroyReason().equals("缺人")) { | ||
| 3706 | - ssgl_qr += childTaskPlan.getMileage(); | ||
| 3707 | - } else if (childTaskPlan.getDestroyReason().equals("缺车")) { | ||
| 3708 | - ssgl_qc += childTaskPlan.getMileage(); | ||
| 3709 | - } else if (childTaskPlan.getDestroyReason().equals("客稀")) { | ||
| 3710 | - ssgl_kx += childTaskPlan.getMileage(); | ||
| 3711 | - } else if (childTaskPlan.getDestroyReason().equals("气候")) { | ||
| 3712 | - ssgl_qh += childTaskPlan.getMileage(); | ||
| 3713 | - } else if (childTaskPlan.getDestroyReason().equals("援外")) { | ||
| 3714 | - ssgl_yw += childTaskPlan.getMileage(); | ||
| 3715 | - } else if (childTaskPlan.getDestroyReason().equals("路救抛锚")) { | ||
| 3716 | - ssgl_ljpm += childTaskPlan.getMileage(); | ||
| 3717 | - } else { | ||
| 3718 | - ssgl_other += childTaskPlan.getMileage(); | ||
| 3719 | - } | ||
| 3720 | - } | ||
| 3721 | - //临加公里 | ||
| 3722 | - if (childTaskPlan.getType1().equals("临加")) { | ||
| 3723 | - ljgl += childTaskPlan.getMileage(); | ||
| 3724 | - } | ||
| 3725 | - } | ||
| 3726 | - } | ||
| 3727 | - //班次 | ||
| 3728 | - scheduleRealInfo.getFcsjT(); | ||
| 3729 | - scheduleRealInfo.getFcsjActualTime(); | ||
| 3730 | - } | ||
| 3731 | - } | ||
| 3732 | - map.put("jhlc", jhlc); | ||
| 3733 | - map.put("sjgl", sjgl); | ||
| 3734 | - map.put("ssgl", ssgl); | ||
| 3735 | - map.put("ssgl_lz", ssgl_lz); | ||
| 3736 | - map.put("ssgl_dm", ssgl_dm); | ||
| 3737 | - map.put("ssgl_gz", ssgl_gz); | ||
| 3738 | - map.put("ssgl_jf", ssgl_jf); | ||
| 3739 | - map.put("ssgl_zs", ssgl_zs); | ||
| 3740 | - map.put("ssgl_qr", ssgl_qr); | ||
| 3741 | - map.put("ssgl_qc", ssgl_qc); | ||
| 3742 | - map.put("ssgl_kx", ssgl_kx); | ||
| 3743 | - map.put("ssgl_qh", ssgl_qh); | ||
| 3744 | - map.put("ssgl_yw", ssgl_yw); | ||
| 3745 | - map.put("ssgl_ljpm", ssgl_ljpm); | ||
| 3746 | - map.put("ssgl_other", ssgl_other); | ||
| 3747 | - map.put("ljgl", ljgl); | ||
| 3748 | - | ||
| 3749 | - map.put("jhbc", scheduleRealInfos.size()); | ||
| 3750 | - return null; | ||
| 3751 | - } | ||
| 3752 | - | ||
| 3753 | - @Override | ||
| 3754 | - public int countByLineCodeAndDate(String xlBm, String schDate) { | ||
| 3755 | - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate); | ||
| 3756 | - } | ||
| 3757 | - | ||
| 3758 | - @Override | ||
| 3759 | - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) { | ||
| 3760 | - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate); | ||
| 3761 | - } | ||
| 3762 | - | ||
| 3763 | - @Override | ||
| 3764 | - public void deleteByLineCodeAndDate(String xlBm, String schDate) { | ||
| 3765 | - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate); | ||
| 3766 | - } | ||
| 3767 | - | ||
| 3768 | - @Override | ||
| 3769 | - public Long getMaxId() { | ||
| 3770 | - return scheduleRealInfoRepository.getMaxId(); | ||
| 3771 | - } | ||
| 3772 | - | ||
| 3773 | - @Override | ||
| 3774 | - public List<ScheduleRealInfo> realScheduleList(String line, String date) { | ||
| 3775 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 3776 | - String lpName = "lpName"; | ||
| 3777 | - String zdsj = ""; | ||
| 3778 | - String zdsjActual = ""; | ||
| 3779 | - String zdsj1 = ""; | ||
| 3780 | - String zdsjActual1 = ""; | ||
| 3781 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date); | ||
| 3782 | - | ||
| 3783 | - /* | ||
| 3784 | - * 对计划发车时间相同的班次进行排序 out最前 in最后 | ||
| 3785 | - */ | ||
| 3786 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 3787 | - SimpleDateFormat sdfnyr =new SimpleDateFormat("yyyy-MM-dd"); | ||
| 3788 | - String minfcsj = "02:00"; | ||
| 3789 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 3790 | - if (lineList.size() > 0) { | ||
| 3791 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 3792 | - + " id = (" | ||
| 3793 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 3794 | - + ")"; | ||
| 3795 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 3796 | - } | ||
| 3797 | - String[] minSjs = minfcsj.split(":"); | ||
| 3798 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 3799 | - for (int i = 0; i < listInfo.size(); i++) { | ||
| 3800 | - ScheduleRealInfo s = listInfo.get(i); | ||
| 3801 | - if (s.getBcType().equals("out")) { | ||
| 3802 | - s.setRemark("1"); | ||
| 3803 | - } else if (s.getBcType().equals("in")) { | ||
| 3804 | - s.setRemark("3"); | ||
| 3805 | - } else { | ||
| 3806 | - s.setRemark("2"); | ||
| 3807 | - } | ||
| 3808 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 3809 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 3810 | - | ||
| 3811 | - Long fscjT = 0L; | ||
| 3812 | - if (fcsjL < minSj) { | ||
| 3813 | - Calendar calendar = new GregorianCalendar(); | ||
| 3814 | - calendar.setTime(s.getScheduleDate()); | ||
| 3815 | - calendar.add(calendar.DATE, 1); | ||
| 3816 | - Date date_sch= calendar.getTime(); | ||
| 3817 | - try { | ||
| 3818 | - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime(); | ||
| 3819 | - } catch (ParseException e) { | ||
| 3820 | - // TODO Auto-generated catch block | ||
| 3821 | - e.printStackTrace(); | ||
| 3822 | - } | ||
| 3823 | - | ||
| 3824 | - } else { | ||
| 3825 | - try { | ||
| 3826 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 3827 | - } catch (ParseException e) { | ||
| 3828 | - // TODO Auto-generated catch block | ||
| 3829 | - e.printStackTrace(); | ||
| 3830 | - }; | ||
| 3831 | - } | ||
| 3832 | - s.setFcsjT(fscjT); | ||
| 3833 | - } | ||
| 3834 | - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); | ||
| 3835 | - listInfo2.addAll(listInfo); | ||
| 3836 | - Collections.sort(listInfo, new compareLpFcsjType()); | ||
| 3837 | - Collections.sort(listInfo2,new compareDirLpFcsjType()); | ||
| 3838 | - for (int i = 0; i < listInfo.size(); i++) { | ||
| 3839 | - ScheduleRealInfo t = listInfo.get(i); | ||
| 3840 | - if (!lpName.equals(t.getLpName())) { | ||
| 3841 | - zdsjActual = t.getZdsjActual(); | ||
| 3842 | - zdsj = t.getZdsj(); | ||
| 3843 | - t.setZdsjActual(""); | ||
| 3844 | - t.setZdsj(""); | ||
| 3845 | - } else { | ||
| 3846 | - zdsj1 = t.getZdsj(); | ||
| 3847 | - zdsjActual1 = t.getZdsjActual(); | ||
| 3848 | - t.setZdsjActual(zdsjActual); | ||
| 3849 | - t.setZdsj(zdsj); | ||
| 3850 | - zdsj = zdsj1; | ||
| 3851 | - zdsjActual = zdsjActual1; | ||
| 3852 | - } | ||
| 3853 | - lpName = t.getLpName(); | ||
| 3854 | - list.add(t); | ||
| 3855 | - } | ||
| 3856 | -/* | ||
| 3857 | - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date); | ||
| 3858 | - for (int i = 0; i < listInfo2.size(); i++) { | ||
| 3859 | - ScheduleRealInfo s = listInfo2.get(i); | ||
| 3860 | - if (s.getBcType().equals("out")) { | ||
| 3861 | - s.setRemark("1"); | ||
| 3862 | - } else if (s.getBcType().equals("in")) { | ||
| 3863 | - s.setRemark("3"); | ||
| 3864 | - } else { | ||
| 3865 | - s.setRemark("2"); | ||
| 3866 | - } | ||
| 3867 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 3868 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 3869 | - | ||
| 3870 | - Long fscjT = 0L; | ||
| 3871 | - if (fcsjL < minSj) { | ||
| 3872 | - Calendar calendar = new GregorianCalendar(); | ||
| 3873 | - calendar.setTime(s.getScheduleDate()); | ||
| 3874 | - calendar.add(calendar.DATE, 1); | ||
| 3875 | - s.setScheduleDate(calendar.getTime()); | ||
| 3876 | - try { | ||
| 3877 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 3878 | - } catch (ParseException e) { | ||
| 3879 | - // TODO Auto-generated catch block | ||
| 3880 | - e.printStackTrace(); | ||
| 3881 | - } | ||
| 3882 | - | ||
| 3883 | - } else { | ||
| 3884 | - try { | ||
| 3885 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 3886 | - } catch (ParseException e) { | ||
| 3887 | - // TODO Auto-generated catch block | ||
| 3888 | - e.printStackTrace(); | ||
| 3889 | - } | ||
| 3890 | - ; | ||
| 3891 | - } | ||
| 3892 | - s.setFcsjT(fscjT); | ||
| 3893 | - }*/ | ||
| 3894 | - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | ||
| 3895 | - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | ||
| 3896 | - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | ||
| 3897 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 3898 | - if (listInfo2.size() > 0) { | ||
| 3899 | - int a = listInfo2.size() % 3; | ||
| 3900 | - int b = listInfo2.size() / 3; | ||
| 3901 | - int x = 0, y = 0; | ||
| 3902 | - if (a == 2) { | ||
| 3903 | - x = b + 1; | ||
| 3904 | - y = x * 2; | ||
| 3905 | - } else if (a == 1) { | ||
| 3906 | - x = b + 1; | ||
| 3907 | - y = x * 2 - 1; | ||
| 3908 | - } else { | ||
| 3909 | - x = b; | ||
| 3910 | - y = 2 * x; | ||
| 3911 | - | ||
| 3912 | - } | ||
| 3913 | - for (int i = 0; i < listInfo2.size(); i++) { | ||
| 3914 | - ScheduleRealInfo s = listInfo2.get(i); | ||
| 3915 | - if (i + 1 <= x) { | ||
| 3916 | - xList.add(s); | ||
| 3917 | - } else if ((i + 1) > x && (i + 1) <= y) { | ||
| 3918 | - yList.add(s); | ||
| 3919 | - } else { | ||
| 3920 | - zList.add(s); | ||
| 3921 | - } | ||
| 3922 | - } | ||
| 3923 | - for (int i = 0; i < x; i++) { | ||
| 3924 | - newList.add(xList.get(i)); | ||
| 3925 | - if (yList.size() > i) { | ||
| 3926 | - newList.add(yList.get(i)); | ||
| 3927 | - } else { | ||
| 3928 | - newList.add(new ScheduleRealInfo()); | ||
| 3929 | - } | ||
| 3930 | - if (zList.size() > i) { | ||
| 3931 | - newList.add(zList.get(i)); | ||
| 3932 | - } else { | ||
| 3933 | - newList.add(new ScheduleRealInfo()); | ||
| 3934 | - } | ||
| 3935 | - | ||
| 3936 | - } | ||
| 3937 | - } | ||
| 3938 | - for (int i = 0; i < newList.size(); i++) { | ||
| 3939 | - ScheduleRealInfo t1 = newList.get(i); | ||
| 3940 | - for (int j = 0; j < list.size(); j++) { | ||
| 3941 | - ScheduleRealInfo t2 = list.get(j); | ||
| 3942 | - if (t1.getId() == t2.getId()) { | ||
| 3943 | - t1 = t2; | ||
| 3944 | - } | ||
| 3945 | - } | ||
| 3946 | - } | ||
| 3947 | - | ||
| 3948 | - for (int i = 0; i < newList.size(); i++) { | ||
| 3949 | - ScheduleRealInfo t1 = newList.get(i); | ||
| 3950 | - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks(); | ||
| 3951 | - if (reamrks1.length() > 4) { | ||
| 3952 | - t1.setRemarks(reamrks1.substring(0, 4)); | ||
| 3953 | - t1.setRemark(reamrks1); | ||
| 3954 | - } else { | ||
| 3955 | - t1.setRemark(reamrks1); | ||
| 3956 | - } | ||
| 3957 | - } | ||
| 3958 | - return newList; | ||
| 3959 | - } | ||
| 3960 | - | ||
| 3961 | - @Override | ||
| 3962 | - public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) { | ||
| 3963 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 3964 | - String lpName = "lpName"; | ||
| 3965 | - String zdsj = ""; | ||
| 3966 | - String zdsjActual = ""; | ||
| 3967 | - String zdsj1 = ""; | ||
| 3968 | - String zdsjActual1 = ""; | ||
| 3969 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date); | ||
| 3970 | - | ||
| 3971 | - /* | ||
| 3972 | - * 对计划发车时间相同的班次进行排序 out最前 in最后 | ||
| 3973 | - */ | ||
| 3974 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 3975 | - SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 3976 | - | ||
| 3977 | - String minfcsj = "02:00"; | ||
| 3978 | - List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 3979 | - if (lineList.size() > 0) { | ||
| 3980 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 3981 | - + " id = (" | ||
| 3982 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 3983 | - + ")"; | ||
| 3984 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 3985 | - } | ||
| 3986 | - String[] minSjs = minfcsj.split(":"); | ||
| 3987 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 3988 | - for (int i = 0; i < listInfo.size(); i++) { | ||
| 3989 | - ScheduleRealInfo s = listInfo.get(i); | ||
| 3990 | - if (s.getBcType().equals("out")) { | ||
| 3991 | - s.setRemark("1"); | ||
| 3992 | - } else if (s.getBcType().equals("in")) { | ||
| 3993 | - s.setRemark("3"); | ||
| 3994 | - } else { | ||
| 3995 | - s.setRemark("2"); | ||
| 3996 | - } | ||
| 3997 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 3998 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 3999 | - | ||
| 4000 | - Long fscjT = 0L; | ||
| 4001 | - if (fcsjL < minSj) { | ||
| 4002 | - Calendar calendar = new GregorianCalendar(); | ||
| 4003 | - calendar.setTime(s.getScheduleDate()); | ||
| 4004 | - calendar.add(calendar.DATE, 1); | ||
| 4005 | - Date date_sch=calendar.getTime(); | ||
| 4006 | - try { | ||
| 4007 | - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime(); | ||
| 4008 | - } catch (ParseException e) { | ||
| 4009 | - // TODO Auto-generated catch block | ||
| 4010 | - e.printStackTrace(); | ||
| 4011 | - } | ||
| 4012 | - | ||
| 4013 | - } else { | ||
| 4014 | - try { | ||
| 4015 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 4016 | - } catch (ParseException e) { | ||
| 4017 | - // TODO Auto-generated catch block | ||
| 4018 | - e.printStackTrace(); | ||
| 4019 | - } | ||
| 4020 | - ; | ||
| 4021 | - } | ||
| 4022 | - s.setFcsjT(fscjT); | ||
| 4023 | - } | ||
| 4024 | - | ||
| 4025 | -// Collections.sort(listInfo, new compareLpFcsjType()); | ||
| 4026 | - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); | ||
| 4027 | - | ||
| 4028 | - Collections.sort(listInfo, new compareLpFcsjType()); | ||
| 4029 | - for (int i = 0; i < listInfo.size(); i++) { | ||
| 4030 | - ScheduleRealInfo t = listInfo.get(i); | ||
| 4031 | - if (!lpName.equals(t.getLpName())) { | ||
| 4032 | - zdsjActual = t.getZdsjActual(); | ||
| 4033 | - zdsj = t.getZdsj(); | ||
| 4034 | - t.setZdsjActual(""); | ||
| 4035 | - t.setZdsj(""); | ||
| 4036 | - } else { | ||
| 4037 | - zdsj1 = t.getZdsj(); | ||
| 4038 | - zdsjActual1 = t.getZdsjActual(); | ||
| 4039 | - t.setZdsjActual(zdsjActual); | ||
| 4040 | - t.setZdsj(zdsj); | ||
| 4041 | - zdsj = zdsj1; | ||
| 4042 | - zdsjActual = zdsjActual1; | ||
| 4043 | - } | ||
| 4044 | - | ||
| 4045 | - | ||
| 4046 | - | ||
| 4047 | - lpName = t.getLpName(); | ||
| 4048 | - listInfo2.add(t); | ||
| 4049 | - | ||
| 4050 | - } | ||
| 4051 | - | ||
| 4052 | - Collections.sort(listInfo2,new compareDirLpFcsjType()); | ||
| 4053 | - for (int i = 0; i < listInfo2.size(); i++) { | ||
| 4054 | - ScheduleRealInfo t=listInfo2.get(i); | ||
| 4055 | - list.add(t); | ||
| 4056 | - Set<ChildTaskPlan> childTaskPlans = t.getcTasks(); | ||
| 4057 | - //计算营运里程,空驶里程 | ||
| 4058 | - if (!childTaskPlans.isEmpty()) { | ||
| 4059 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 4060 | - Collections.sort(listit, new ComparableChild()); | ||
| 4061 | - for (int j = 0; j < listit.size(); j++) { | ||
| 4062 | - ScheduleRealInfo s = new ScheduleRealInfo(); | ||
| 4063 | - ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 4064 | - if (childTaskPlan.getCcId() == null) { | ||
| 4065 | - if (childTaskPlan.isDestroy()) { | ||
| 4066 | - s.setFcsjActual(""); | ||
| 4067 | - s.setZdsjActual(""); | ||
| 4068 | - } else { | ||
| 4069 | - s.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 4070 | - s.setZdsjActual(""); | ||
| 4071 | - s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 4072 | - } | ||
| 4073 | - s.setFcsj(childTaskPlan.getStartDate()); | ||
| 4074 | - s.setZdsj(""); | ||
| 4075 | - s.setQdzName(childTaskPlan.getStartStationName()); | ||
| 4076 | - s.setZdzName(childTaskPlan.getEndStationName()); | ||
| 4077 | - s.setRemarks(childTaskPlan.getRemarks()); | ||
| 4078 | - s.setAdjustExps("子"); | ||
| 4079 | - s.setLpName(""); | ||
| 4080 | - list.add(s); | ||
| 4081 | - } | ||
| 4082 | - } | ||
| 4083 | - } | ||
| 4084 | - } | ||
| 4085 | - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | ||
| 4086 | - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | ||
| 4087 | - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | ||
| 4088 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 4089 | - if (list.size() > 0) { | ||
| 4090 | - int a = list.size() % 3; | ||
| 4091 | - int b = list.size() / 3; | ||
| 4092 | - int x = 0, y = 0; | ||
| 4093 | - if (a == 2) { | ||
| 4094 | - x = b + 1; | ||
| 4095 | - y = x * 2; | ||
| 4096 | - } else if (a == 1) { | ||
| 4097 | - x = b + 1; | ||
| 4098 | - y = x * 2 - 1; | ||
| 4099 | - } else { | ||
| 4100 | - x = b; | ||
| 4101 | - y = 2 * x; | ||
| 4102 | - | ||
| 4103 | - } | ||
| 4104 | - for (int i = 0; i < list.size(); i++) { | ||
| 4105 | - ScheduleRealInfo s = list.get(i); | ||
| 4106 | - if (i + 1 <= x) { | ||
| 4107 | - xList.add(s); | ||
| 4108 | - } else if ((i + 1) > x && (i + 1) <= y) { | ||
| 4109 | - yList.add(s); | ||
| 4110 | - } else { | ||
| 4111 | - zList.add(s); | ||
| 4112 | - } | ||
| 4113 | - } | ||
| 4114 | - for (int i = 0; i < x; i++) { | ||
| 4115 | - newList.add(xList.get(i)); | ||
| 4116 | - if (yList.size() > i) { | ||
| 4117 | - newList.add(yList.get(i)); | ||
| 4118 | - } else { | ||
| 4119 | - newList.add(new ScheduleRealInfo()); | ||
| 4120 | - } | ||
| 4121 | - if (zList.size() > i) { | ||
| 4122 | - newList.add(zList.get(i)); | ||
| 4123 | - } else { | ||
| 4124 | - newList.add(new ScheduleRealInfo()); | ||
| 4125 | - } | ||
| 4126 | - | ||
| 4127 | - } | ||
| 4128 | - } | ||
| 4129 | - /* for (int i = 0; i < newList.size(); i++) { | ||
| 4130 | - ScheduleRealInfo t1 = newList.get(i); | ||
| 4131 | - for (int j = 0; j < list.size(); j++) { | ||
| 4132 | - ScheduleRealInfo t2 = list.get(j); | ||
| 4133 | - if (t1.getId() == t2.getId()) { | ||
| 4134 | - t1 = t2; | ||
| 4135 | - } | ||
| 4136 | - } | ||
| 4137 | - }*/ | ||
| 4138 | - | ||
| 4139 | - for (int i = 0; i < newList.size(); i++) { | ||
| 4140 | - ScheduleRealInfo t1 = newList.get(i); | ||
| 4141 | - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks(); | ||
| 4142 | - if (reamrks1.length() > 4) { | ||
| 4143 | - t1.setRemarks(reamrks1.substring(0, 4)); | ||
| 4144 | - t1.setRemark(reamrks1); | ||
| 4145 | - } else { | ||
| 4146 | - t1.setRemark(reamrks1); | ||
| 4147 | - } | ||
| 4148 | - } | ||
| 4149 | - return newList; | ||
| 4150 | - } | ||
| 4151 | - | ||
| 4152 | - @Override | ||
| 4153 | - public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) { | ||
| 4154 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 4155 | - String lpName = "lpName"; | ||
| 4156 | - String zdsj = ""; | ||
| 4157 | - String zdsjActual = ""; | ||
| 4158 | - String zdsj1 = ""; | ||
| 4159 | - String zdsjActual1 = ""; | ||
| 4160 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | ||
| 4161 | - | ||
| 4162 | - for (ScheduleRealInfo s : listInfo) { | ||
| 4163 | - if (s.isDestroy() && s.isReissue()) { | ||
| 4164 | - s.setRemark(""); | ||
| 4165 | - s.setFcsjActual(s.getDfsj()); | ||
| 4166 | - s.setZdsjActual(s.getZdsj()); | ||
| 4167 | - s.setStatus(2); | ||
| 4168 | - s.setJhlc(s.getJhlcOrig()); | ||
| 4169 | - } | ||
| 4170 | - } | ||
| 4171 | - | ||
| 4172 | - for (int i = 0; i < listInfo.size(); i++) { | ||
| 4173 | - ScheduleRealInfo t = listInfo.get(i); | ||
| 4174 | - if (!lpName.equals(t.getLpName())) { | ||
| 4175 | - zdsjActual = t.getZdsjActual(); | ||
| 4176 | - zdsj = t.getZdsj(); | ||
| 4177 | - t.setZdsjActual(""); | ||
| 4178 | - t.setZdsj(""); | ||
| 4179 | - } else { | ||
| 4180 | - zdsj1 = t.getZdsj(); | ||
| 4181 | - zdsjActual1 = t.getZdsjActual(); | ||
| 4182 | - t.setZdsjActual(zdsjActual); | ||
| 4183 | - t.setZdsj(zdsj); | ||
| 4184 | - zdsj = zdsj1; | ||
| 4185 | - zdsjActual = zdsjActual1; | ||
| 4186 | - } | ||
| 4187 | - lpName = t.getLpName(); | ||
| 4188 | - list.add(t); | ||
| 4189 | - } | ||
| 4190 | - | ||
| 4191 | - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp2(line, date); | ||
| 4192 | - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | ||
| 4193 | - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | ||
| 4194 | - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | ||
| 4195 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 4196 | - if (listInfo2.size() > 0) { | ||
| 4197 | - int a = listInfo2.size() % 3; | ||
| 4198 | - int b = listInfo2.size() / 3; | ||
| 4199 | - int x = 0, y = 0; | ||
| 4200 | - if (a == 2) { | ||
| 4201 | - x = b + 1; | ||
| 4202 | - y = x * 2; | ||
| 4203 | - } else if (b == 1) { | ||
| 4204 | - x = b + 1; | ||
| 4205 | - y = x * 2 - 1; | ||
| 4206 | - } else { | ||
| 4207 | - x = b; | ||
| 4208 | - y = 2 * x; | ||
| 4209 | - | ||
| 4210 | - } | ||
| 4211 | - for (int i = 0; i < listInfo2.size(); i++) { | ||
| 4212 | - ScheduleRealInfo s = listInfo2.get(i); | ||
| 4213 | - if (i + 1 <= x) { | ||
| 4214 | - xList.add(s); | ||
| 4215 | - } else if ((i + 1) > x && (i + 1) <= y) { | ||
| 4216 | - yList.add(s); | ||
| 4217 | - } else { | ||
| 4218 | - zList.add(s); | ||
| 4219 | - } | ||
| 4220 | - } | ||
| 4221 | - for (int i = 0; i < x; i++) { | ||
| 4222 | - newList.add(xList.get(i)); | ||
| 4223 | - if (yList.size() > i) { | ||
| 4224 | - newList.add(yList.get(i)); | ||
| 4225 | - } else { | ||
| 4226 | - newList.add(new ScheduleRealInfo()); | ||
| 4227 | - } | ||
| 4228 | - if (zList.size() > i) { | ||
| 4229 | - newList.add(zList.get(i)); | ||
| 4230 | - } else { | ||
| 4231 | - newList.add(new ScheduleRealInfo()); | ||
| 4232 | - } | ||
| 4233 | - | ||
| 4234 | - } | ||
| 4235 | - } | ||
| 4236 | - for (int i = 0; i < newList.size(); i++) { | ||
| 4237 | - ScheduleRealInfo t1 = newList.get(i); | ||
| 4238 | - for (int j = 0; j < list.size(); j++) { | ||
| 4239 | - ScheduleRealInfo t2 = list.get(j); | ||
| 4240 | - if (t1.getId() == t2.getId()) { | ||
| 4241 | - t1 = t2; | ||
| 4242 | - } | ||
| 4243 | - } | ||
| 4244 | - } | ||
| 4245 | - return newList; | ||
| 4246 | - } | ||
| 4247 | - | ||
| 4248 | - @Override | ||
| 4249 | - public List<ScheduleRealInfo> realScheduleListQp(String line, String date) { | ||
| 4250 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 4251 | - String lpName = "lpName"; | ||
| 4252 | - String zdsj = ""; | ||
| 4253 | - String zdsjActual = ""; | ||
| 4254 | - String zdsj1 = ""; | ||
| 4255 | - String zdsjActual1 = ""; | ||
| 4256 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | ||
| 4257 | - for (int i = 0; i < listInfo.size(); i++) { | ||
| 4258 | - ScheduleRealInfo t = listInfo.get(i); | ||
| 4259 | - if (!lpName.equals(t.getLpName())) { | ||
| 4260 | - zdsjActual = t.getZdsjActual(); | ||
| 4261 | - zdsj = t.getZdsj(); | ||
| 4262 | - t.setZdsjActual(""); | ||
| 4263 | - t.setZdsj(""); | ||
| 4264 | - } else { | ||
| 4265 | - zdsj1 = t.getZdsj(); | ||
| 4266 | - zdsjActual1 = t.getZdsjActual(); | ||
| 4267 | - t.setZdsjActual(zdsjActual); | ||
| 4268 | - t.setZdsj(zdsj); | ||
| 4269 | - zdsj = zdsj1; | ||
| 4270 | - zdsjActual = zdsjActual1; | ||
| 4271 | - } | ||
| 4272 | - | ||
| 4273 | - lpName = t.getLpName(); | ||
| 4274 | - list.add(t); | ||
| 4275 | - } | ||
| 4276 | - return list; | ||
| 4277 | - } | ||
| 4278 | - | ||
| 4279 | - public List<Map<String, Object>> yesterdayDataList(String line, String date, String gsbm, String fgsbm, String jGh, String nbbm) { | ||
| 4280 | - List<Map<String, Object>> yesterdayDataList = new ArrayList<Map<String, Object>>(); | ||
| 4281 | - if (line.equals("")) { | ||
| 4282 | - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date, gsbm, fgsbm, nbbm); | ||
| 4283 | - } else { | ||
| 4284 | - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList_eq(line, date, gsbm, fgsbm, nbbm); | ||
| 4285 | - } | ||
| 4286 | - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date, gsbm, fgsbm); | ||
| 4287 | - for (int x = 0; x < yesterdayDataList.size(); x++) { | ||
| 4288 | - String jsy = yesterdayDataList.get(x).get("jGh").toString(); | ||
| 4289 | - String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); | ||
| 4290 | - String xlbm = yesterdayDataList.get(x).get("xlBm").toString(); | ||
| 4291 | - String lp = yesterdayDataList.get(x).get("lpName").toString(); | ||
| 4292 | - String realExecDate=yesterdayDataList.get(x).get("realExecDate").toString(); | ||
| 4293 | - String fcsj[] =realExecDate.split(" "); | ||
| 4294 | - //取出最小计划发车时间 | ||
| 4295 | - yesterdayDataList.get(x).put("fcsj", fcsj[1]); | ||
| 4296 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 4297 | - boolean fage = true; | ||
| 4298 | - String company = ""; | ||
| 4299 | - String bCompany = ""; | ||
| 4300 | - String lineName=""; | ||
| 4301 | - String jName=""; | ||
| 4302 | - List<ScheduleRealInfo> listS = new ArrayList<ScheduleRealInfo>(); | ||
| 4303 | - for (ScheduleRealInfo scheduleRealInfo : lists) { | ||
| 4304 | - if (scheduleRealInfo.getjGh().equals(jsy) | ||
| 4305 | - && scheduleRealInfo.getClZbh().equals(clZbh) | ||
| 4306 | - && scheduleRealInfo.getXlBm().equals(xlbm) | ||
| 4307 | - && scheduleRealInfo.getLpName().equals(lp)) { | ||
| 4308 | - if (fage) { | ||
| 4309 | - //根据线路代码获取公司 | ||
| 4310 | - company = scheduleRealInfo.getGsBm(); | ||
| 4311 | - bCompany = scheduleRealInfo.getFgsBm(); | ||
| 4312 | - lineName = scheduleRealInfo.getXlName(); | ||
| 4313 | - jName= scheduleRealInfo.getjName(); | ||
| 4314 | - fage = false; | ||
| 4315 | - } | ||
| 4316 | - Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks(); | ||
| 4317 | - if (cts != null && cts.size() > 0) { | ||
| 4318 | - listS.add(scheduleRealInfo); | ||
| 4319 | - } else { | ||
| 4320 | - if (scheduleRealInfo.getZdsjActual() != null && scheduleRealInfo.getFcsjActual() != null) { | ||
| 4321 | - listS.add(scheduleRealInfo); | ||
| 4322 | - } | ||
| 4323 | - } | ||
| 4324 | - } | ||
| 4325 | - } | ||
| 4326 | - yesterdayDataList.get(x).put("company", company); | ||
| 4327 | - yesterdayDataList.get(x).put("bCompany", bCompany); | ||
| 4328 | - yesterdayDataList.get(x).put("lineName", lineName); | ||
| 4329 | - yesterdayDataList.get(x).put("jName", jName); | ||
| 4330 | - Double ljgl = culateMieageService.culateLjgl(listS); | ||
| 4331 | - Double sjgl = culateMieageService.culateSjgl(listS); | ||
| 4332 | - Double ksgl = culateMieageService.culateKsgl(listS); | ||
| 4333 | - Double jccgl = culateMieageService.culateJccgl(listS); | ||
| 4334 | - Double zyygl = Arith.add(sjgl, ljgl); | ||
| 4335 | - Double zksgl = Arith.add(ksgl, jccgl); | ||
| 4336 | - Double zlc = Arith.add(zyygl, zksgl); | ||
| 4337 | - yesterdayDataList.get(x).put("totalKilometers", zlc); | ||
| 4338 | - | ||
| 4339 | - } | ||
| 4340 | - //增加顺序号 | ||
| 4341 | - for (int i = 0; i < yesterdayDataList.size(); i++) { | ||
| 4342 | - if (i == 0) { | ||
| 4343 | - yesterdayDataList.get(i).put("seqNumber", 1); | ||
| 4344 | - } else { | ||
| 4345 | - if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) { | ||
| 4346 | - yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber")); | ||
| 4347 | - } else { | ||
| 4348 | - yesterdayDataList.get(i).put("seqNumber", 1); | ||
| 4349 | - } | ||
| 4350 | - } | ||
| 4351 | - } | ||
| 4352 | - | ||
| 4353 | - return yesterdayDataList; | ||
| 4354 | - } | ||
| 4355 | - | ||
| 4356 | - /** | ||
| 4357 | - * 批量调整人车 | ||
| 4358 | - */ | ||
| 4359 | - @Override | ||
| 4360 | - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs, String userId) { | ||
| 4361 | - Map<String, Object> rs = new HashMap<>(); | ||
| 4362 | - Set<ScheduleRealInfo> set = new HashSet<>(); | ||
| 4363 | - | ||
| 4364 | - ScheduleRealInfo sch; | ||
| 4365 | - | ||
| 4366 | - String jGh = null, jName, sGh, sName; | ||
| 4367 | - for (ChangePersonCar cpc : cpcs) { | ||
| 4368 | - | ||
| 4369 | - sch = dayOfSchedule.get(cpc.getSchId()); | ||
| 4370 | - if (sch == null) | ||
| 4371 | - continue; | ||
| 4372 | - | ||
| 4373 | - if (cpc.getClZbh() != null) { | ||
| 4374 | - if (!carExist(sch.getGsBm(), cpc.getClZbh())) { | ||
| 4375 | - rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | ||
| 4376 | - rs.put("status", ResponseCode.ERROR); | ||
| 4377 | - return rs; | ||
| 4378 | - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(cpc.getClZbh()))) { | ||
| 4379 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + cpc.getClZbh() + "】的车辆"); | ||
| 4380 | - rs.put("status", ResponseCode.ERROR); | ||
| 4381 | - return rs; | ||
| 4382 | - } | ||
| 4383 | - } | ||
| 4384 | - | ||
| 4385 | - if (StringUtils.isNotEmpty(cpc.getJsy())) { | ||
| 4386 | - try{ | ||
| 4387 | - jGh = cpc.getJsy().split("/")[0]; | ||
| 4388 | - }catch (Exception e){ | ||
| 4389 | - logger.error("", e); | ||
| 4390 | - rs.put("msg", "驾驶员参数异常!!"); | ||
| 4391 | - rs.put("status", ResponseCode.ERROR); | ||
| 4392 | - return rs; | ||
| 4393 | - } | ||
| 4394 | - | ||
| 4395 | - jName = getPersonName(sch.getGsBm(), jGh); | ||
| 4396 | - if (StringUtils.isEmpty(jName)) { | ||
| 4397 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | ||
| 4398 | - rs.put("status", ResponseCode.ERROR); | ||
| 4399 | - return rs; | ||
| 4400 | - } | ||
| 4401 | - } | ||
| 4402 | - | ||
| 4403 | - | ||
| 4404 | - //为换人换车情况表写入数据 | ||
| 4405 | - schModifyLog.saveChangetochange(sch, cpc, userId); | ||
| 4406 | - //日志记录 | ||
| 4407 | - ScheduleModifyLogger.tzrc(sch, cpc, userId); | ||
| 4408 | - | ||
| 4409 | - //换驾驶员 | ||
| 4410 | - if (StringUtils.isNotEmpty(cpc.getJsy())) { | ||
| 4411 | - //换驾驶员 | ||
| 4412 | - if (persoChange(sch, jGh)) | ||
| 4413 | - set.add(sch); | ||
| 4414 | - } | ||
| 4415 | - | ||
| 4416 | - //换售票员 | ||
| 4417 | - if (StringUtils.isNotEmpty(cpc.getSpy()) | ||
| 4418 | - && !"/".equals(StringUtils.trim(cpc.getSpy()))) { | ||
| 4419 | - | ||
| 4420 | - sGh = cpc.getSpy().split("/")[0]; | ||
| 4421 | - sName = getPersonName(sch.getGsBm(), sGh); | ||
| 4422 | - if (StringUtils.isEmpty(sName)) { | ||
| 4423 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | ||
| 4424 | - rs.put("status", ResponseCode.ERROR); | ||
| 4425 | - return rs; | ||
| 4426 | - } | ||
| 4427 | - | ||
| 4428 | - /*if(!sGh.equals(sch.getsGh())) | ||
| 4429 | - sb.append(sch.getsGh() + " 换 " + sGh + ";");*/ | ||
| 4430 | - if (persoChangeSPY(sch, sGh)) | ||
| 4431 | - set.add(sch); | ||
| 4432 | - } else if (StringUtils.isNotEmpty(sch.getsGh())) { | ||
| 4433 | - sch.setsGh(""); | ||
| 4434 | - sch.setsName(""); | ||
| 4435 | - } | ||
| 4436 | - | ||
| 4437 | - //换车 | ||
| 4438 | - if (StringUtils.isNotEmpty(cpc.getClZbh()) && !cpc.getClZbh().equals(sch.getClZbh())) { | ||
| 4439 | - //sb.append(sch.getClZbh() + " 换 " + cpc.getClZbh() + ";"); | ||
| 4440 | - set.add(sch); | ||
| 4441 | - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh())); | ||
| 4442 | - } | ||
| 4443 | - | ||
| 4444 | - /*if(sb.length() > 0) | ||
| 4445 | - sch.setRemarks(sb.toString());*/ | ||
| 4446 | - | ||
| 4447 | - dayOfSchedule.save(sch); | ||
| 4448 | - set.add(sch); | ||
| 4449 | - | ||
| 4450 | - } | ||
| 4451 | - rs.put("ts", set); | ||
| 4452 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4453 | - return rs; | ||
| 4454 | - } | ||
| 4455 | - | ||
| 4456 | - /** | ||
| 4457 | - * @Title: persoChange | ||
| 4458 | - * @Description: TODO(班次换驾驶员) | ||
| 4459 | - */ | ||
| 4460 | - public boolean persoChange(ScheduleRealInfo sch, String jGh) { | ||
| 4461 | - if (sch.getjGh().equals(jGh)) | ||
| 4462 | - return false; | ||
| 4463 | - String jName = getPersonName(sch.getGsBm(), jGh); | ||
| 4464 | - if (StringUtils.isNotEmpty(jName)) { | ||
| 4465 | - | ||
| 4466 | - if (jGh.indexOf("-") != -1) | ||
| 4467 | - sch.setjGh(jGh.substring(jGh.indexOf("-") + 1)); | ||
| 4468 | - else | ||
| 4469 | - sch.setjGh(jGh); | ||
| 4470 | - | ||
| 4471 | - sch.setjName(jName); | ||
| 4472 | - return true; | ||
| 4473 | - } | ||
| 4474 | - return false; | ||
| 4475 | - } | ||
| 4476 | - | ||
| 4477 | - /** | ||
| 4478 | - * @Title: persoChange | ||
| 4479 | - * @Description: TODO(班次换售票员) | ||
| 4480 | - */ | ||
| 4481 | - public boolean persoChangeSPY(ScheduleRealInfo sch, String sGh) { | ||
| 4482 | - if (sch.getsGh().equals(sGh)) | ||
| 4483 | - return false; | ||
| 4484 | - String sName = getPersonName(sch.getGsBm(), sGh); | ||
| 4485 | - if (StringUtils.isNotEmpty(sName)) { | ||
| 4486 | - if (sGh.indexOf("-") != -1) | ||
| 4487 | - sch.setsGh(sGh.substring(sGh.indexOf("-") + 1)); | ||
| 4488 | - else | ||
| 4489 | - sch.setsGh(sGh); | ||
| 4490 | - sch.setsName(sName); | ||
| 4491 | - return true; | ||
| 4492 | - } | ||
| 4493 | - return false; | ||
| 4494 | - } | ||
| 4495 | - | ||
| 4496 | - /** | ||
| 4497 | - * 批量待发调整 | ||
| 4498 | - */ | ||
| 4499 | - @Override | ||
| 4500 | - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) { | ||
| 4501 | - Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>(); | ||
| 4502 | - List<ScheduleRealInfo> list = new ArrayList<>(); | ||
| 4503 | - | ||
| 4504 | - for (DfsjChange dc : dfsjcs) { | ||
| 4505 | - if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj())) | ||
| 4506 | - continue; | ||
| 4507 | - | ||
| 4508 | - tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null, "2", null); | ||
| 4509 | - | ||
| 4510 | - if (tempMap.get("status").equals(ResponseCode.SUCCESS)) { | ||
| 4511 | - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts")); | ||
| 4512 | - } | ||
| 4513 | - } | ||
| 4514 | - | ||
| 4515 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4516 | - rs.put("ts", list); | ||
| 4517 | - return rs; | ||
| 4518 | - } | ||
| 4519 | - | ||
| 4520 | - | ||
| 4521 | - @Override | ||
| 4522 | - public Map<String, Object> findKMBC1(String jName, String clZbh, | ||
| 4523 | - String date, String enddate) { | ||
| 4524 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate); | ||
| 4525 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 4526 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 4527 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 4528 | - int jhbc = 0, cjbc = 0, ljbc = 0; | ||
| 4529 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0; | ||
| 4530 | - float addMileage = 0l, remMileage = 0l; | ||
| 4531 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 4532 | - for (ScheduleRealInfo scheduleRealInfo : list) { | ||
| 4533 | - if (scheduleRealInfo != null) { | ||
| 4534 | - //计划里程(主任务过滤掉临加班次), | ||
| 4535 | - //烂班里程(主任务烂班), | ||
| 4536 | - //临加里程(主任务临加), | ||
| 4537 | - //计划班次,烂班班次,增加班次 | ||
| 4538 | - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | ||
| 4539 | - if (scheduleRealInfo.isSflj()) { | ||
| 4540 | - addMileage += tempJhlc; | ||
| 4541 | - ljbc++; | ||
| 4542 | - } else { | ||
| 4543 | - jhlc += tempJhlc; | ||
| 4544 | - jhbc++; | ||
| 4545 | - if (scheduleRealInfo.getStatus() == -1) { | ||
| 4546 | - remMileage += tempJhlc; | ||
| 4547 | - cjbc++; | ||
| 4548 | - } | ||
| 4549 | - } | ||
| 4550 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 4551 | - //计算营运里程,空驶里程 | ||
| 4552 | - if (childTaskPlans.isEmpty()) { | ||
| 4553 | - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 4554 | - || scheduleRealInfo.getBcType().equals("venting")) { | ||
| 4555 | - ksgl += tempJhlc; | ||
| 4556 | - } else { | ||
| 4557 | - yygl += tempJhlc; | ||
| 4558 | - } | ||
| 4559 | - } else { | ||
| 4560 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 4561 | - while (it.hasNext()) { | ||
| 4562 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 4563 | - if (childTaskPlan.getMileageType().equals("empty")) { | ||
| 4564 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4565 | - } else { | ||
| 4566 | - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4567 | - } | ||
| 4568 | - } | ||
| 4569 | - } | ||
| 4570 | - } | ||
| 4571 | - } | ||
| 4572 | - map.put("jhlc", format.format(jhlc)); | ||
| 4573 | - map.put("remMileage", format.format(remMileage)); | ||
| 4574 | - map.put("addMileage", format.format(addMileage)); | ||
| 4575 | - map.put("yygl", format.format(yygl)); | ||
| 4576 | - map.put("ksgl", format.format(ksgl)); | ||
| 4577 | - map.put("realMileage", format.format(yygl + ksgl)); | ||
| 4578 | - map.put("jhbc", jhbc); | ||
| 4579 | - map.put("cjbc", cjbc); | ||
| 4580 | - map.put("ljbc", ljbc); | ||
| 4581 | - map.put("sjbc", jhbc - cjbc + ljbc); | ||
| 4582 | - return map; | ||
| 4583 | - } | ||
| 4584 | - | ||
| 4585 | - /** | ||
| 4586 | - * 调整班次类型 | ||
| 4587 | - * | ||
| 4588 | - * @param id | ||
| 4589 | - * @param bcType | ||
| 4590 | - * @param remarks | ||
| 4591 | - * @return | ||
| 4592 | - */ | ||
| 4593 | - @Override | ||
| 4594 | - public Map<String, Object> changeBcType(Long id, String bcType, String remarks, String majorStationName) { | ||
| 4595 | - Map<String, Object> rs = new HashMap<>(); | ||
| 4596 | - | ||
| 4597 | - try { | ||
| 4598 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 4599 | - if (sch != null) { | ||
| 4600 | - sch.setBcType(bcType); | ||
| 4601 | - sch.setRemarks(remarks); | ||
| 4602 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4603 | - rs.put("t", sch); | ||
| 4604 | - | ||
| 4605 | - if ("major".equals(bcType)) { | ||
| 4606 | - sch.setMajorStationName(majorStationName); | ||
| 4607 | - } | ||
| 4608 | - | ||
| 4609 | - dayOfSchedule.save(sch); | ||
| 4610 | - } | ||
| 4611 | - } catch (Exception e) { | ||
| 4612 | - logger.error("", e); | ||
| 4613 | - rs.put("status", ResponseCode.ERROR); | ||
| 4614 | - } | ||
| 4615 | - | ||
| 4616 | - return rs; | ||
| 4617 | - } | ||
| 4618 | - | ||
| 4619 | - @Override | ||
| 4620 | - public Map<String, Object> historySave(ScheduleRealInfo sch) { | ||
| 4621 | - Map<String, Object> rs = new HashMap<>(); | ||
| 4622 | - rs.put("status", ResponseCode.ERROR); | ||
| 4623 | - | ||
| 4624 | - ScheduleRealInfo oldSch = super.findById(sch.getId()); | ||
| 4625 | - // 检查调度日期 | ||
| 4626 | - DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 4627 | - long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(oldSch.getScheduleDateStr()); | ||
| 4628 | - if (today < scheduleDate || today - scheduleDate > 86400000 * PrivilegeUtils.getHistoryEditDays()) { | ||
| 4629 | - rs.put("status", ResponseCode.ERROR); | ||
| 4630 | - rs.put("msg", "无效的调度日期"); | ||
| 4631 | - return rs; | ||
| 4632 | - } | ||
| 4633 | - //事后日志记录 | ||
| 4634 | - AfterwardsLogger aflog = AfterwardsLogger.start(oldSch, "事后调整"); | ||
| 4635 | - | ||
| 4636 | - //换车 | ||
| 4637 | - if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) { | ||
| 4638 | - if (!carExist(oldSch.getGsBm(), sch.getClZbh())) { | ||
| 4639 | - rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!"); | ||
| 4640 | - return rs; | ||
| 4641 | - } else { | ||
| 4642 | - aflog.log("换车", oldSch.getClZbh(), sch.getClZbh()); | ||
| 4643 | - oldSch.setClZbh(sch.getClZbh()); | ||
| 4644 | - } | ||
| 4645 | - } | ||
| 4646 | - | ||
| 4647 | - //换驾驶员 | ||
| 4648 | - if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) { | ||
| 4649 | - String jName = getPersonName(oldSch.getGsBm(), sch.getjGh()); | ||
| 4650 | - if (StringUtils.isEmpty(jName)) { | ||
| 4651 | - rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | ||
| 4652 | - return rs; | ||
| 4653 | - } | ||
| 4654 | - aflog.log("换驾驶员", oldSch.getjGh() + "/" + oldSch.getjName(), sch.getjGh() + "/" + sch.getjName()); | ||
| 4655 | - persoChange(oldSch, sch.getjGh()); | ||
| 4656 | - } | ||
| 4657 | - | ||
| 4658 | - //换售票员 | ||
| 4659 | - if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) { | ||
| 4660 | - String sName = getPersonName(oldSch.getGsBm(), sch.getsGh()); | ||
| 4661 | - if (StringUtils.isEmpty(sName)) { | ||
| 4662 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员"); | ||
| 4663 | - return rs; | ||
| 4664 | - } | ||
| 4665 | - aflog.log("换售票员", oldSch.getsGh() + "/" + oldSch.getsName(), sch.getsGh() + "/" + sch.getsName()); | ||
| 4666 | - persoChangeSPY(oldSch, sch.getsGh()); | ||
| 4667 | - } | ||
| 4668 | - | ||
| 4669 | - //烂班 | ||
| 4670 | - boolean dest1 = oldSch.getStatus() == -1; | ||
| 4671 | - boolean dest2 = sch.getStatus() == -1; | ||
| 4672 | - if (!dest1 && dest2) { | ||
| 4673 | - oldSch.destroy(); | ||
| 4674 | - aflog.log("烂班"); | ||
| 4675 | - } else if (dest1 && !dest2) { | ||
| 4676 | - //撤销烂班 | ||
| 4677 | - oldSch.setJhlc(oldSch.getJhlcOrig()); | ||
| 4678 | - oldSch.setStatus(0); | ||
| 4679 | - oldSch.calcStatus(); | ||
| 4680 | - oldSch.setAdjustExps(null); | ||
| 4681 | - aflog.log("撤销烂班"); | ||
| 4682 | - } | ||
| 4683 | - | ||
| 4684 | - oldSch.setAdjustExps(sch.getAdjustExps()); | ||
| 4685 | - | ||
| 4686 | - /** | ||
| 4687 | - * 修改班次里程 | ||
| 4688 | - */ | ||
| 4689 | - if (!oldSch.getJhlc().equals(sch.getJhlc())) { | ||
| 4690 | - double jhlcNum = sch.getJhlc(); | ||
| 4691 | - aflog.log("修改班次里程", oldSch.getJhlc(), jhlcNum); | ||
| 4692 | - //烂班 | ||
| 4693 | - if (jhlcNum == 0 && oldSch.getJhlcOrig() != 0) | ||
| 4694 | - oldSch.destroy(); | ||
| 4695 | - else { | ||
| 4696 | - oldSch.setJhlc(jhlcNum); | ||
| 4697 | - //临加班次,实际计划一起改 | ||
| 4698 | - if (oldSch.isSflj()) | ||
| 4699 | - oldSch.setJhlcOrig(jhlcNum); | ||
| 4700 | - } | ||
| 4701 | - } | ||
| 4702 | - | ||
| 4703 | - //待发时间 | ||
| 4704 | - if (!CustomStringUtils.equals(oldSch.getDfsj(), sch.getDfsj())) { | ||
| 4705 | - aflog.log("修改待发时间", oldSch.getDfsj(), sch.getDfsj()); | ||
| 4706 | - oldSch.setDfsj(sch.getDfsj()); | ||
| 4707 | - } | ||
| 4708 | - //实发时间 | ||
| 4709 | - if (!CustomStringUtils.equals(oldSch.getFcsjActual(), sch.getFcsjActual())) { | ||
| 4710 | - aflog.log("修改实发时间", oldSch.getFcsjActual(), sch.getFcsjActual()); | ||
| 4711 | - oldSch.setFcsjActual(sch.getFcsjActual()); | ||
| 4712 | - } | ||
| 4713 | - //实际终点 | ||
| 4714 | - if (!CustomStringUtils.equals(oldSch.getZdsjActual(), sch.getZdsjActual())) { | ||
| 4715 | - aflog.log("修改实达时间", oldSch.getZdsjActual(), sch.getZdsjActual()); | ||
| 4716 | - oldSch.setZdsjActual(sch.getZdsjActual()); | ||
| 4717 | - } | ||
| 4718 | - | ||
| 4719 | - //备注 | ||
| 4720 | - if (!CustomStringUtils.equals(oldSch.getRemarks(), sch.getRemarks())) { | ||
| 4721 | - aflog.log("修改备注", oldSch.getRemarks(), sch.getRemarks()); | ||
| 4722 | - oldSch.setRemarks(sch.getRemarks()); | ||
| 4723 | - } | ||
| 4724 | - | ||
| 4725 | - scheduleRealInfoRepository.save(oldSch); | ||
| 4726 | - | ||
| 4727 | - aflog.end(); | ||
| 4728 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4729 | - return rs; | ||
| 4730 | - } | ||
| 4731 | - | ||
| 4732 | - @Autowired | ||
| 4733 | - SvgAttributeRepository svgAttributeRepository; | ||
| 4734 | - | ||
| 4735 | - @Override | ||
| 4736 | - public Map<String, Object> svgAttr(String jsonStr) { | ||
| 4737 | - Map<String, Object> rs = new HashMap<>(); | ||
| 4738 | - | ||
| 4739 | - try { | ||
| 4740 | - JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr)); | ||
| 4741 | - | ||
| 4742 | - SvgAttribute svgAttribute = new SvgAttribute(); | ||
| 4743 | - svgAttribute.setLineCode(jObj.getString("lineCode")); | ||
| 4744 | - svgAttribute.setHideStations(jObj.getString("hideStations")); | ||
| 4745 | - svgAttribute.setNicknames(jObj.getString("nicknames")); | ||
| 4746 | - svgAttributeRepository.save(svgAttribute); | ||
| 4747 | - | ||
| 4748 | - rs.put("t", svgAttribute); | ||
| 4749 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4750 | - } catch (Exception e) { | ||
| 4751 | - logger.error("", e); | ||
| 4752 | - rs.put("status", ResponseCode.ERROR); | ||
| 4753 | - } | ||
| 4754 | - return rs; | ||
| 4755 | - } | ||
| 4756 | - | ||
| 4757 | - @Override | ||
| 4758 | - public Map<String, Object> findSvgAttr(String idx) { | ||
| 4759 | - Map<String, Object> rs = new HashMap<>(); | ||
| 4760 | - try { | ||
| 4761 | - List<String> lineCodes = Splitter.on(",").splitToList(idx); | ||
| 4762 | - List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes); | ||
| 4763 | - | ||
| 4764 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4765 | - rs.put("list", list); | ||
| 4766 | - } catch (Exception e) { | ||
| 4767 | - logger.error("", e); | ||
| 4768 | - rs.put("status", ResponseCode.ERROR); | ||
| 4769 | - } | ||
| 4770 | - return rs; | ||
| 4771 | - } | ||
| 4772 | - | ||
| 4773 | - @Override | ||
| 4774 | - public Map<String, Object> addRemarks(Long id, String remarks) { | ||
| 4775 | - Map<String, Object> rs = new HashMap<>(); | ||
| 4776 | - try { | ||
| 4777 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 4778 | - sch.addRemarks(remarks); | ||
| 4779 | - | ||
| 4780 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 4781 | - rs.put("t", sch); | ||
| 4782 | - } catch (Exception e) { | ||
| 4783 | - logger.error("", e); | ||
| 4784 | - rs.put("status", ResponseCode.ERROR); | ||
| 4785 | - } | ||
| 4786 | - return rs; | ||
| 4787 | - } | ||
| 4788 | - | ||
| 4789 | - @Override | ||
| 4790 | - public List<Map<String, Object>> yesterdayDataList(String line) { | ||
| 4791 | - // TODO Auto-generated method stub | ||
| 4792 | - return null; | ||
| 4793 | - } | ||
| 4794 | - | ||
| 4795 | - @Override | ||
| 4796 | - public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) { | ||
| 4797 | - // TODO Auto-generated method stub | ||
| 4798 | - ReportUtils ee = new ReportUtils(); | ||
| 4799 | - ReportRelatedUtils rru = new ReportRelatedUtils(); | ||
| 4800 | - List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | ||
| 4801 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | ||
| 4802 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 4803 | - | ||
| 4804 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 4805 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 4806 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 4807 | - int jhbc = 0, cjbc = 0, ljbc = 0; | ||
| 4808 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; | ||
| 4809 | - float addMileage = 0l, remMileage = 0l, addgl = 0, remgl = 0; | ||
| 4810 | - int xyz = 1; | ||
| 4811 | - Map<String, Object> map; | ||
| 4812 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | ||
| 4813 | - if (scheduleRealInfo != null) { | ||
| 4814 | - //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次 | ||
| 4815 | - //计划里程(主任务过滤掉临加班次), | ||
| 4816 | - //烂班里程(主任务烂班), | ||
| 4817 | - //临加里程(主任务临加), | ||
| 4818 | - //计划班次,烂班班次,增加班次 | ||
| 4819 | - double jh = 0, sj = 0; | ||
| 4820 | - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | ||
| 4821 | - if (scheduleRealInfo.isSflj()) { | ||
| 4822 | - ljbc++; | ||
| 4823 | - } else { | ||
| 4824 | - if (!(scheduleRealInfo.getBcType().equals("in") | ||
| 4825 | - || scheduleRealInfo.getBcType().equals("out"))) { | ||
| 4826 | - jhbc++; | ||
| 4827 | - jh += tempJhlc; | ||
| 4828 | - } | ||
| 4829 | - if (scheduleRealInfo.getStatus() == -1) { | ||
| 4830 | - remMileage += tempJhlc; | ||
| 4831 | - cjbc++; | ||
| 4832 | - } | ||
| 4833 | - } | ||
| 4834 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 4835 | - //计算营运里程,空驶里程 | ||
| 4836 | - if (childTaskPlans.isEmpty()) { | ||
| 4837 | - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 4838 | - ) { | ||
| 4839 | - jcclc += tempJhlc; | ||
| 4840 | - } else { | ||
| 4841 | - if (scheduleRealInfo.getStatus() != -1) { | ||
| 4842 | - if (scheduleRealInfo.isSflj()) { | ||
| 4843 | - addMileage += tempJhlc; | ||
| 4844 | - } | ||
| 4845 | - sj += tempJhlc; | ||
| 4846 | - } | ||
| 4847 | - } | ||
| 4848 | - } else { | ||
| 4849 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 4850 | - while (it.hasNext()) { | ||
| 4851 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 4852 | - if (childTaskPlan.getMileageType().equals("empty")) { | ||
| 4853 | - if (childTaskPlan.isDestroy()) { | ||
| 4854 | - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4855 | - } else { | ||
| 4856 | - if (scheduleRealInfo.isSflj()) { | ||
| 4857 | - addMileage += tempJhlc; | ||
| 4858 | - } | ||
| 4859 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4860 | - } | ||
| 4861 | - } else { | ||
| 4862 | - if (childTaskPlan.isDestroy()) { | ||
| 4863 | - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4864 | -// cjbc++; | ||
| 4865 | - } else { | ||
| 4866 | - if (scheduleRealInfo.isSflj()) { | ||
| 4867 | - addMileage += tempJhlc; | ||
| 4868 | - } | ||
| 4869 | - sj += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4870 | - } | ||
| 4871 | - } | ||
| 4872 | - } | ||
| 4873 | - } | ||
| 4874 | - | ||
| 4875 | - if (!(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out"))) { | ||
| 4876 | - map = new HashMap<String, Object>(); | ||
| 4877 | - try { | ||
| 4878 | - scheduleRealInfo.setBcs(xyz); | ||
| 4879 | - xyz++; | ||
| 4880 | - Set<ChildTaskPlan> cs = scheduleRealInfo.getcTasks(); | ||
| 4881 | - Double sjlc = 0.0; | ||
| 4882 | - if (!cs.isEmpty()) { | ||
| 4883 | - Iterator<ChildTaskPlan> it = cs.iterator(); | ||
| 4884 | - while (it.hasNext()) { | ||
| 4885 | - ChildTaskPlan c = it.next(); | ||
| 4886 | - if (!c.isDestroy()) { | ||
| 4887 | - sjlc += c.getMileage() == null ? 0 : c.getMileage(); | ||
| 4888 | - } | ||
| 4889 | - | ||
| 4890 | - } | ||
| 4891 | - } else { | ||
| 4892 | - if (scheduleRealInfo.getStatus() != -1) { | ||
| 4893 | - sjlc = scheduleRealInfo.getJhlc(); | ||
| 4894 | - } | ||
| 4895 | - } | ||
| 4896 | - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | ||
| 4897 | - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | ||
| 4898 | - scheduleRealInfo.setSjlc(format.format(sjlc)); | ||
| 4899 | - map = rru.getMapValue(scheduleRealInfo); | ||
| 4900 | - String zdsj = scheduleRealInfo.getZdsj(); | ||
| 4901 | - String zdsjActual = scheduleRealInfo.getZdsjActual(); | ||
| 4902 | - if (zdsj != null && zdsjActual != null && | ||
| 4903 | - !zdsj.equals(zdsjActual)) { | ||
| 4904 | - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | ||
| 4905 | - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | ||
| 4906 | - if (zdsj.compareTo(zdsjActual) > 0) { | ||
| 4907 | - if (zdsjT - zdsjAT > 1000) { | ||
| 4908 | - map.put("fast", ""); | ||
| 4909 | - map.put("slow", zdsjAT - zdsjT + 1440); | ||
| 4910 | - } else { | ||
| 4911 | - map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 4912 | - map.put("slow", ""); | ||
| 4913 | - } | ||
| 4914 | - } else { | ||
| 4915 | - if (zdsjAT - zdsjT > 1000) { | ||
| 4916 | - map.put("fast", zdsjT - zdsjAT + 1440); | ||
| 4917 | - map.put("slow", ""); | ||
| 4918 | - } else { | ||
| 4919 | - map.put("fast", ""); | ||
| 4920 | - map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 4921 | - } | ||
| 4922 | - } | ||
| 4923 | - } else { | ||
| 4924 | - map.put("fast", ""); | ||
| 4925 | - map.put("slow", ""); | ||
| 4926 | - } | ||
| 4927 | - listMap.add(map); | ||
| 4928 | - } catch (Exception e) { | ||
| 4929 | - e.printStackTrace(); | ||
| 4930 | - } | ||
| 4931 | - } | ||
| 4932 | - jhlc += jh; | ||
| 4933 | - yygl += sj; | ||
| 4934 | - if (jh > sj) { | ||
| 4935 | - remgl += jh - sj; | ||
| 4936 | - } else { | ||
| 4937 | - addgl += sj - jh; | ||
| 4938 | - } | ||
| 4939 | - } | ||
| 4940 | - } | ||
| 4941 | - | ||
| 4942 | - | ||
| 4943 | - List<Ylxxb> listYlxxb = ylxxbRepository.queryListYlxxb(clZbh, date); | ||
| 4944 | - Double jzl = 0.0; | ||
| 4945 | - for (int t = 0; t < listYlxxb.size(); t++) { | ||
| 4946 | - Ylxxb y = listYlxxb.get(t); | ||
| 4947 | - jzl += y.getJzl(); | ||
| 4948 | - } | ||
| 4949 | - | ||
| 4950 | - //计算里程和班次数,并放入Map里 | ||
| 4951 | - map = findKMBCQp(clZbh, date, line); | ||
| 4952 | - map.put("jzl", jzl); | ||
| 4953 | -// map.put("jhlc", format.format(jhlc + jcclc)); | ||
| 4954 | -// map.put("yygljh", format.format(jhlc)); | ||
| 4955 | -// map.put("ssgl", format.format(remMileage)); | ||
| 4956 | -// map.put("ksgl", format.format(ksgl)); | ||
| 4957 | -// map.put("yyglsj", format.format(yygl)); | ||
| 4958 | -// map.put("jhbc", jhbc); | ||
| 4959 | -// map.put("jcclc", jcclc); | ||
| 4960 | -// | ||
| 4961 | -// map.put("ljgl", format.format(addMileage)); | ||
| 4962 | -// map.put("ssbc", cjbc); | ||
| 4963 | -// map.put("ysgl", format.format(yygl)); | ||
| 4964 | -// map.put("sjbc", jhbc - cjbc + ljbc); | ||
| 4965 | -// map.put("zgl", format.format(yygl + ksgl + jcclc)); | ||
| 4966 | -// map.put("ljbc", ljbc); | ||
| 4967 | - | ||
| 4968 | - String zdp = "", zwdp = "", wdp = ""; | ||
| 4969 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 4970 | - List<DutyEmployee> listDtuy = dutyEmployeeService.getDutyEmployee(line, date + "00:00", date + "23:59"); | ||
| 4971 | - try { | ||
| 4972 | - Long fcsj1 = sdf.parse(date + " 03:00").getTime(); | ||
| 4973 | - Long fcsj2 = sdf.parse(date + " 11:00").getTime(); | ||
| 4974 | - Long fcsj3 = sdf.parse(date + " 22:00").getTime(); | ||
| 4975 | - for (int i = 0; i < listDtuy.size(); i++) { | ||
| 4976 | - DutyEmployee t = listDtuy.get(i); | ||
| 4977 | - Long ts = t.getTs(); | ||
| 4978 | - if (ts > fcsj1 && ts < fcsj2) { | ||
| 4979 | - if (zdp.indexOf(t.getuName()) == -1) { | ||
| 4980 | - zdp += t.getuName() + ","; | ||
| 4981 | - | ||
| 4982 | - } | ||
| 4983 | - } else if (ts > fcsj2 && ts < fcsj3) { | ||
| 4984 | - if (zwdp.indexOf(t.getuName()) == -1) { | ||
| 4985 | - zwdp += t.getuName() + ","; | ||
| 4986 | - } | ||
| 4987 | - } else { | ||
| 4988 | - if (wdp.indexOf(t.getuName()) == -1) { | ||
| 4989 | - wdp += t.getuName() + ","; | ||
| 4990 | - } | ||
| 4991 | - } | ||
| 4992 | - } | ||
| 4993 | - } catch (ParseException e) { | ||
| 4994 | - // TODO Auto-generated catch block | ||
| 4995 | - e.printStackTrace(); | ||
| 4996 | - } | ||
| 4997 | - map.put("zdp", zdp); | ||
| 4998 | - map.put("zwdp", zwdp); | ||
| 4999 | - map.put("wdp", wdp); | ||
| 5000 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 5001 | - list.add(listMap.iterator()); | ||
| 5002 | - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/waybill_qingpu.xls", | ||
| 5003 | - path + "export/" + date + "-" + clZbh + "-行车路单.xls"); | ||
| 5004 | - | ||
| 5005 | - return scheduleRealInfos; | ||
| 5006 | - } | ||
| 5007 | - | ||
| 5008 | - @Override | ||
| 5009 | - public Map<String, Object> findKMBCQp(String clZbh, String date, String line) { | ||
| 5010 | - // TODO Auto-generated method stub | ||
| 5011 | - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | ||
| 5012 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 5013 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 5014 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 5015 | - int jhbc = 0, cjbc = 0, ljbc = 0, sjbc = 0; | ||
| 5016 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0, ljjcclc = 0, jhjcclc = 0; | ||
| 5017 | - double addMileage = 0, remMileage = 0, addgl = 0, remgl = 0; | ||
| 5018 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 5019 | - jhlc = culateMieageService.culateJhgl(lists); | ||
| 5020 | - jcclc = culateMieageService.culateJccgl(lists); | ||
| 5021 | - jhjcclc = culateMieageService.culateJhJccgl(lists); | ||
| 5022 | - remMileage = culateMieageService.culateLbgl(lists); | ||
| 5023 | - ksgl = culateMieageService.culateKsgl(lists); | ||
| 5024 | - yygl = culateMieageService.culateSjgl(lists); | ||
| 5025 | - jhbc = culateMieageService.culateJhbc(lists, ""); | ||
| 5026 | - addMileage = culateMieageService.culateLjgl(lists); | ||
| 5027 | - cjbc = culateMieageService.culateLbbc(lists); | ||
| 5028 | - sjbc = culateMieageService.culateSjbc(lists, ""); | ||
| 5029 | - ljbc = culateMieageService.culateLjbc(lists, ""); | ||
| 5030 | - double zyygl = Arith.add(yygl, addMileage); | ||
| 5031 | - double zksgl = Arith.add(ksgl, jcclc); | ||
| 5032 | - map.put("jhlc", Arith.add(jhlc, jhjcclc)); | ||
| 5033 | - map.put("yygljh", jhlc); | ||
| 5034 | - map.put("ssgl", remMileage); | ||
| 5035 | - map.put("ksgl", ksgl); | ||
| 5036 | - map.put("yyglsj", Arith.add(yygl, addMileage)); | ||
| 5037 | - map.put("jcclc", jcclc); | ||
| 5038 | - map.put("jhbc", jhbc); | ||
| 5039 | - map.put("ljgl", addMileage); | ||
| 5040 | - map.put("ssbc", cjbc); | ||
| 5041 | - map.put("ysgl", Arith.add(yygl, addMileage)); | ||
| 5042 | - map.put("sjbc", sjbc); | ||
| 5043 | - map.put("zgl", Arith.add(zyygl, zksgl)); | ||
| 5044 | - map.put("ljbc", ljbc); | ||
| 5045 | - | ||
| 5046 | - return map; | ||
| 5047 | - } | ||
| 5048 | - | ||
| 5049 | - @Override | ||
| 5050 | - public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) { | ||
| 5051 | - // TODO Auto-generated method stub | ||
| 5052 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 5053 | - List<ScheduleRealInfo> list = null; | ||
| 5054 | - list = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | ||
| 5055 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 5056 | - for (int i = 0; i < list.size(); i++) { | ||
| 5057 | - ScheduleRealInfo s = list.get(i); | ||
| 5058 | - if (!(s.getBcType().equals("in") || s.getBcType().equals("out"))) { | ||
| 5059 | - String remarks = ""; | ||
| 5060 | - Double sjlc = 0.0; | ||
| 5061 | - if (s.getRemarks() != null) { | ||
| 5062 | - remarks += s.getRemarks(); | ||
| 5063 | - } | ||
| 5064 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 5065 | - if (!childTaskPlans.isEmpty()) { | ||
| 5066 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 5067 | - while (it.hasNext()) { | ||
| 5068 | - ChildTaskPlan c = it.next(); | ||
| 5069 | - if (c.getRemarks() != null && c.getRemarks().length() > 0) { | ||
| 5070 | - if (remarks.indexOf(c.getRemarks()) == -1) { | ||
| 5071 | - remarks += c.getRemarks(); | ||
| 5072 | - } | ||
| 5073 | - } | ||
| 5074 | - | ||
| 5075 | - if (!c.isDestroy()) { | ||
| 5076 | - if (c.getMileageType().equals("service")) { | ||
| 5077 | - sjlc += c.getMileage() == null ? 0 : c.getMileage(); | ||
| 5078 | - } | ||
| 5079 | - } | ||
| 5080 | - | ||
| 5081 | - } | ||
| 5082 | - } else { | ||
| 5083 | - if (s.getStatus() != -1) { | ||
| 5084 | - sjlc = s.getJhlc(); | ||
| 5085 | - } | ||
| 5086 | - } | ||
| 5087 | - s.setSjlc(format.format(sjlc)); | ||
| 5088 | - s.setRemarks(remarks); | ||
| 5089 | - newList.add(s); | ||
| 5090 | - } | ||
| 5091 | - | ||
| 5092 | - } | ||
| 5093 | - | ||
| 5094 | - return newList; | ||
| 5095 | - } | ||
| 5096 | - | ||
| 5097 | - @Override | ||
| 5098 | - public Map<String, Object> MapById(Long id) { | ||
| 5099 | - // TODO Auto-generated method stub | ||
| 5100 | - Map<String, Object> dMap=new HashMap<>(); | ||
| 5101 | - dMap.put("dGroup_eq", "oilType"); | ||
| 5102 | - Iterator<Dictionary> it= dictionaryService.list(dMap).iterator(); | ||
| 5103 | - while (it.hasNext()) { | ||
| 5104 | - Dictionary d=it.next(); | ||
| 5105 | - dMap.put(d.getdCode(), d.getdName()); | ||
| 5106 | - } | ||
| 5107 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 5108 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 5109 | - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id); | ||
| 5110 | - String xlbm = s.getXlBm(); | ||
| 5111 | - String fcrq = s.getScheduleDateStr(); | ||
| 5112 | - | ||
| 5113 | - int type = 2; | ||
| 5114 | - Double ccyl = 0.0; | ||
| 5115 | - Double jcyl = 0.0; | ||
| 5116 | - Double yh = 0.0; | ||
| 5117 | - Double jzl = 0.0; | ||
| 5118 | - Double zlc = 0.0; | ||
| 5119 | - String rylx=""; | ||
| 5120 | - int hyd = 0; | ||
| 5121 | - Double czql = 0.0, jzql = 0.0, hq = 0.0, jql = 0.0; | ||
| 5122 | - List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh()); | ||
| 5123 | - if (listCars.size() > 0) { | ||
| 5124 | - if (listCars.get(0).getSfdc() != null) { | ||
| 5125 | - if (listCars.get(0).getSfdc()) { | ||
| 5126 | - List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | ||
| 5127 | - type = 1; | ||
| 5128 | - for (int i = 0; i < listDlb.size(); i++) { | ||
| 5129 | - Dlb d = listDlb.get(i); | ||
| 5130 | - if (d.getLp() == null) { | ||
| 5131 | - ccyl = Arith.add(ccyl, d.getCzcd()); | ||
| 5132 | - jcyl = Arith.add(jcyl, d.getJzcd()); | ||
| 5133 | - yh = Arith.add(yh, d.getHd()); | ||
| 5134 | - jzl = Arith.add(jzl, d.getCdl()); | ||
| 5135 | - zlc = Arith.add(zlc, d.getZlc()); | ||
| 5136 | - } else { | ||
| 5137 | - if (d.getLp().equals(s.getLpName())) { | ||
| 5138 | - ccyl = Arith.add(ccyl, d.getCzcd()); | ||
| 5139 | - jcyl = Arith.add(jcyl, d.getJzcd()); | ||
| 5140 | - yh = Arith.add(yh, d.getHd()); | ||
| 5141 | - jzl = Arith.add(jzl, d.getCdl()); | ||
| 5142 | - zlc = Arith.add(zlc, d.getZlc()); | ||
| 5143 | - } | ||
| 5144 | - } | ||
| 5145 | - | ||
| 5146 | - } | ||
| 5147 | - } else { | ||
| 5148 | - List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | ||
| 5149 | - type = 0; | ||
| 5150 | - for (int i = 0; i < listYlb.size(); i++) { | ||
| 5151 | - Ylb y = listYlb.get(i); | ||
| 5152 | - if (y.getLp() == null) { | ||
| 5153 | - ccyl = Arith.add(ccyl, y.getCzyl()); | ||
| 5154 | - jcyl = Arith.add(jcyl, y.getJzyl()); | ||
| 5155 | - yh = Arith.add(yh, y.getYh()); | ||
| 5156 | - jzl = Arith.add(jzl, y.getJzl()); | ||
| 5157 | - zlc = Arith.add(zlc, y.getZlc()); | ||
| 5158 | - if(dMap.get(y.getRylx())!=null) | ||
| 5159 | - rylx =dMap.get(y.getRylx()).toString(); | ||
| 5160 | - } else { | ||
| 5161 | - if (y.getLp().equals(s.getLpName())) { | ||
| 5162 | - ccyl = Arith.add(ccyl, y.getCzyl()); | ||
| 5163 | - jcyl = Arith.add(jcyl, y.getJzyl()); | ||
| 5164 | - yh = Arith.add(yh, y.getYh()); | ||
| 5165 | - jzl = Arith.add(jzl, y.getJzl()); | ||
| 5166 | - zlc = Arith.add(zlc, y.getZlc()); | ||
| 5167 | - if(dMap.get(y.getRylx())!=null) | ||
| 5168 | - rylx =dMap.get(y.getRylx()).toString(); | ||
| 5169 | - } | ||
| 5170 | - } | ||
| 5171 | - } | ||
| 5172 | - } | ||
| 5173 | - } | ||
| 5174 | - if(listCars.get(0).getHydrogen() != null && listCars.get(0).getHydrogen()){ | ||
| 5175 | - List<Qlb> listQlb = qlbRepository.queryListQlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | ||
| 5176 | - hyd = 1; | ||
| 5177 | - for (int i = 0; i < listQlb.size(); i++) { | ||
| 5178 | - Qlb h = listQlb.get(i); | ||
| 5179 | - if (h.getLp() == null) { | ||
| 5180 | - czql = Arith.add(czql, h.getCzcl()); | ||
| 5181 | - jzql = Arith.add(jzql, h.getJzcl()); | ||
| 5182 | - hq = Arith.add(hq, h.getHn()); | ||
| 5183 | - jql = Arith.add(jql, h.getJql()); | ||
| 5184 | - } else { | ||
| 5185 | - if (h.getLp().equals(s.getLpName())) { | ||
| 5186 | - czql = Arith.add(czql, h.getCzcl()); | ||
| 5187 | - jzql = Arith.add(jzql, h.getJzcl()); | ||
| 5188 | - hq = Arith.add(hq, h.getHn()); | ||
| 5189 | - jql = Arith.add(jql, h.getJql()); | ||
| 5190 | - } | ||
| 5191 | - } | ||
| 5192 | - } | ||
| 5193 | - } | ||
| 5194 | - } | ||
| 5195 | - | ||
| 5196 | - map.put("hyd", hyd); | ||
| 5197 | - map.put("czcl", czql); | ||
| 5198 | - map.put("jzcl", jzql); | ||
| 5199 | - map.put("hn", hq); | ||
| 5200 | - map.put("jql", jql); | ||
| 5201 | - | ||
| 5202 | - map.put("rylx", "加注类别:"+rylx); | ||
| 5203 | - map.put("jzl", jzl); | ||
| 5204 | - map.put("yh", yh); | ||
| 5205 | - map.put("ccyl", ccyl); | ||
| 5206 | - map.put("jcyl", jcyl); | ||
| 5207 | - map.put("type", type); | ||
| 5208 | - map.put("zlc", zlc); | ||
| 5209 | - map.put("xlName", s.getXlName()); | ||
| 5210 | - map.put("clZbh", s.getClZbh()); | ||
| 5211 | - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); | ||
| 5212 | - map.put("fcsjActual", s.getFcsjActual()); | ||
| 5213 | - map.put("zdzName", s.getZdzName()); | ||
| 5214 | - map.put("scheduleDate", s.getScheduleDateStr()); | ||
| 5215 | - map.put("lpName", s.getLpName()); | ||
| 5216 | - String zdp = "", zwdp = "", wdp = ""; | ||
| 5217 | - String zdpT = "", zwdpT = "", wdpT = ""; | ||
| 5218 | - String dbdp = ""; | ||
| 5219 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59"); | ||
| 5220 | - try { | ||
| 5221 | - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime(); | ||
| 5222 | - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime(); | ||
| 5223 | - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime(); | ||
| 5224 | - for (int i = 0; i < list.size(); i++) { | ||
| 5225 | - DutyEmployee t = list.get(i); | ||
| 5226 | - if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 5227 | - if (!(dbdp.length() > 0)) { | ||
| 5228 | - dbdp = t.getuName(); | ||
| 5229 | - } else { | ||
| 5230 | - dbdp += "," + t.getuName(); | ||
| 5231 | - } | ||
| 5232 | - } | ||
| 5233 | - Long ts = t.getTs(); | ||
| 5234 | - if (ts > fcsj1 && ts < fcsj2) { | ||
| 5235 | - if (zdp.indexOf(t.getuName()) == -1) { | ||
| 5236 | - if (!(zdp.length() > 0)) { | ||
| 5237 | - zdpT = t.getuName() + "..."; | ||
| 5238 | - } | ||
| 5239 | - zdp += t.getuName() + ","; | ||
| 5240 | - | ||
| 5241 | - } | ||
| 5242 | - } else if (ts > fcsj2 && ts < fcsj3) { | ||
| 5243 | - if (zwdp.indexOf(t.getuName()) == -1) { | ||
| 5244 | - if (!(zwdp.length() > 0)) { | ||
| 5245 | - zwdpT = t.getuName() + "..."; | ||
| 5246 | - } | ||
| 5247 | - zwdp += t.getuName() + ","; | ||
| 5248 | - } | ||
| 5249 | - } else { | ||
| 5250 | - if (wdp.indexOf(t.getuName()) == -1) { | ||
| 5251 | - if (!(wdp.length() > 0)) { | ||
| 5252 | - wdpT = t.getuName() + "..."; | ||
| 5253 | - } | ||
| 5254 | - wdp += t.getuName() + ","; | ||
| 5255 | - } | ||
| 5256 | - } | ||
| 5257 | - } | ||
| 5258 | - } catch (ParseException e) { | ||
| 5259 | - // TODO Auto-generated catch block | ||
| 5260 | - e.printStackTrace(); | ||
| 5261 | - } | ||
| 5262 | - map.put("zdp", zdp); | ||
| 5263 | - map.put("zwdp", zwdp); | ||
| 5264 | - map.put("wdp", wdp); | ||
| 5265 | - map.put("zdpT", zdpT); | ||
| 5266 | - map.put("zwdpT", zwdpT); | ||
| 5267 | - map.put("wdpT", wdpT); | ||
| 5268 | - map.put("dbdp", dbdp); | ||
| 5269 | - return map; | ||
| 5270 | - } | ||
| 5271 | - | ||
| 5272 | - @Override | ||
| 5273 | - public Map<String, Object> MapByIdQp(Long id) { | ||
| 5274 | - // TODO Auto-generated method stub | ||
| 5275 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 5276 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 5277 | - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id); | ||
| 5278 | - String xlbm = s.getXlBm(); | ||
| 5279 | - String fcrq = s.getScheduleDateStr(); | ||
| 5280 | - | ||
| 5281 | - int type = 0; | ||
| 5282 | - Double ccyl = 0.0; | ||
| 5283 | - Double jcyl = 0.0; | ||
| 5284 | - Double yh = 0.0; | ||
| 5285 | - Double jzl = 0.0; | ||
| 5286 | - Double zlc = 0.0; | ||
| 5287 | -// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); | ||
| 5288 | -// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); | ||
| 5289 | -// if(listYlb.size()>0){ | ||
| 5290 | -// type=0; | ||
| 5291 | -// for (int i = 0; i < listYlb.size(); i++) { | ||
| 5292 | -// Ylb y = listYlb.get(i); | ||
| 5293 | -// if(y.getLp()==null){ | ||
| 5294 | -// ccyl=Arith.add(ccyl, y.getCzyl()); | ||
| 5295 | -// jcyl=Arith.add(jcyl, y.getJzyl()); | ||
| 5296 | -// yh =Arith.add(yh ,y.getYh()); | ||
| 5297 | -// jzl =Arith.add(jzl, y.getJzl()); | ||
| 5298 | -// zlc =Arith.add(zlc, y.getZlc()); | ||
| 5299 | -// }else{ | ||
| 5300 | -// if(y.getLp().equals(s.getLpName())){ | ||
| 5301 | -// ccyl=Arith.add(ccyl, y.getCzyl()); | ||
| 5302 | -// jcyl=Arith.add(jcyl, y.getJzyl()); | ||
| 5303 | -// yh =Arith.add(yh ,y.getYh()); | ||
| 5304 | -// jzl =Arith.add(jzl, y.getJzl()); | ||
| 5305 | -// zlc =Arith.add(zlc, y.getZlc()); | ||
| 5306 | -// } | ||
| 5307 | -// } | ||
| 5308 | -// | ||
| 5309 | -// } | ||
| 5310 | -// }else{ | ||
| 5311 | -// type=1; | ||
| 5312 | -// for (int i = 0; i < listDlb.size(); i++) { | ||
| 5313 | -// Dlb d=listDlb.get(i); | ||
| 5314 | -// if(d.getLp()==null){ | ||
| 5315 | -// ccyl=Arith.add(ccyl, d.getCzcd()); | ||
| 5316 | -// jcyl=Arith.add(jcyl, d.getJzcd()); | ||
| 5317 | -// yh =Arith.add(yh ,d.getHd()); | ||
| 5318 | -// jzl =Arith.add(jzl, d.getCdl()); | ||
| 5319 | -// zlc =Arith.add(zlc, d.getZlc()); | ||
| 5320 | -// }else{ | ||
| 5321 | -// if(d.getLp().equals(s.getLpName())){ | ||
| 5322 | -// ccyl=Arith.add(ccyl, d.getCzcd()); | ||
| 5323 | -// jcyl=Arith.add(jcyl, d.getJzcd()); | ||
| 5324 | -// yh =Arith.add(yh ,d.getHd()); | ||
| 5325 | -// jzl =Arith.add(jzl, d.getCdl()); | ||
| 5326 | -// zlc =Arith.add(zlc, d.getZlc()); | ||
| 5327 | -// } | ||
| 5328 | -// } | ||
| 5329 | -// | ||
| 5330 | -// } | ||
| 5331 | -// } | ||
| 5332 | - | ||
| 5333 | - List<Ylxxb> listylxxb = ylxxbRepository.queryListYlxxb(s.getClZbh(), fcrq); | ||
| 5334 | - for (int i = 0; i < listylxxb.size(); i++) { | ||
| 5335 | - Ylxxb t = listylxxb.get(i); | ||
| 5336 | - jzl = Arith.add(jzl, t.getJzl()); | ||
| 5337 | - } | ||
| 5338 | - map.put("jzl", jzl); | ||
| 5339 | - map.put("yh", yh); | ||
| 5340 | - map.put("ccyl", ccyl); | ||
| 5341 | - map.put("jcyl", jcyl); | ||
| 5342 | - map.put("type", type); | ||
| 5343 | - map.put("zlc", zlc); | ||
| 5344 | - map.put("xlName", s.getXlName()); | ||
| 5345 | - map.put("clZbh", s.getClZbh()); | ||
| 5346 | - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); | ||
| 5347 | - map.put("fcsjActual", s.getFcsjActual()); | ||
| 5348 | - map.put("zdzName", s.getZdzName()); | ||
| 5349 | - map.put("scheduleDate", s.getScheduleDateStr()); | ||
| 5350 | - map.put("lpName", s.getLpName()); | ||
| 5351 | - String zdp = "", zwdp = "", wdp = ""; | ||
| 5352 | - String zdpT = "", zwdpT = "", wdpT = ""; | ||
| 5353 | - String dbdp = ""; | ||
| 5354 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59"); | ||
| 5355 | - try { | ||
| 5356 | - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime(); | ||
| 5357 | - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime(); | ||
| 5358 | - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime(); | ||
| 5359 | - for (int i = 0; i < list.size(); i++) { | ||
| 5360 | - DutyEmployee t = list.get(i); | ||
| 5361 | - if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 5362 | - if (!(dbdp.length() > 0)) { | ||
| 5363 | - dbdp = t.getuName(); | ||
| 5364 | - } else { | ||
| 5365 | - dbdp += "," + t.getuName(); | ||
| 5366 | - } | ||
| 5367 | - } | ||
| 5368 | - Long ts = t.getTs(); | ||
| 5369 | - if (ts > fcsj1 && ts < fcsj2) { | ||
| 5370 | - if (zdp.indexOf(t.getuName()) == -1) { | ||
| 5371 | - if (!(zdp.length() > 0)) { | ||
| 5372 | - zdpT = t.getuName() + "..."; | ||
| 5373 | - } | ||
| 5374 | - zdp += t.getuName() + ","; | ||
| 5375 | - | ||
| 5376 | - } | ||
| 5377 | - } else if (ts > fcsj2 && ts < fcsj3) { | ||
| 5378 | - if (zwdp.indexOf(t.getuName()) == -1) { | ||
| 5379 | - if (!(zwdp.length() > 0)) { | ||
| 5380 | - zwdpT = t.getuName() + "..."; | ||
| 5381 | - } | ||
| 5382 | - zwdp += t.getuName() + ","; | ||
| 5383 | - } | ||
| 5384 | - } else { | ||
| 5385 | - if (wdp.indexOf(t.getuName()) == -1) { | ||
| 5386 | - if (!(wdp.length() > 0)) { | ||
| 5387 | - wdpT = t.getuName() + "..."; | ||
| 5388 | - } | ||
| 5389 | - wdp += t.getuName() + ","; | ||
| 5390 | - } | ||
| 5391 | - } | ||
| 5392 | - } | ||
| 5393 | - } catch (ParseException e) { | ||
| 5394 | - // TODO Auto-generated catch block | ||
| 5395 | - e.printStackTrace(); | ||
| 5396 | - } | ||
| 5397 | - map.put("zdp", zdp); | ||
| 5398 | - map.put("zwdp", zwdp); | ||
| 5399 | - map.put("wdp", wdp); | ||
| 5400 | - map.put("zdpT", zdpT); | ||
| 5401 | - map.put("zwdpT", zwdpT); | ||
| 5402 | - map.put("wdpT", wdpT); | ||
| 5403 | - map.put("dbdp", dbdp); | ||
| 5404 | - return map; | ||
| 5405 | - } | ||
| 5406 | - | ||
| 5407 | - @Override | ||
| 5408 | - public List<Map<String, Object>> scheduleDailyQp(String line, String date) { | ||
| 5409 | - // TODO Auto-generated method stub | ||
| 5410 | - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | ||
| 5411 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDailyQp(line, date); | ||
| 5412 | - Map<String, Object> map = null; | ||
| 5413 | - String lp = "lp"; | ||
| 5414 | - String jgh = "jgh"; | ||
| 5415 | - String clzbh = "clzbh"; | ||
| 5416 | - int bcs = 0; | ||
| 5417 | - String thclzbh = ""; | ||
| 5418 | - String sgh = "sgh"; | ||
| 5419 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5420 | - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(i); | ||
| 5421 | - if (scheduleRealInfo.getLpName().equals(lp)) { | ||
| 5422 | - bcs++; | ||
| 5423 | - String fcsj = scheduleRealInfo.getFcsj(); | ||
| 5424 | - | ||
| 5425 | - if (!clzbh.equals(scheduleRealInfo.getClZbh())) { | ||
| 5426 | - clzbh = scheduleRealInfo.getClZbh(); | ||
| 5427 | - if (thclzbh == "") { | ||
| 5428 | - thclzbh += scheduleRealInfo.getClZbh() + ","; | ||
| 5429 | - } else { | ||
| 5430 | - thclzbh += scheduleRealInfo.getClZbh(); | ||
| 5431 | - } | ||
| 5432 | - map.put("thclzbh", thclzbh); | ||
| 5433 | - } | ||
| 5434 | - | ||
| 5435 | - if (!jgh.equals(scheduleRealInfo.getjGh())) { | ||
| 5436 | - jgh = scheduleRealInfo.getjGh(); | ||
| 5437 | - if (map.get("jjb2") != null) { | ||
| 5438 | - map.put("jjb3", scheduleRealInfo.getjGh() + "/" + | ||
| 5439 | - scheduleRealInfo.getFcsjActual()); | ||
| 5440 | - | ||
| 5441 | - } else { | ||
| 5442 | - map.put("jjb2", scheduleRealInfo.getjGh() + "/" + | ||
| 5443 | - scheduleRealInfo.getFcsjActual()); | ||
| 5444 | - } | ||
| 5445 | - | ||
| 5446 | - } | ||
| 5447 | - | ||
| 5448 | - if (scheduleRealInfo.getsGh() != null) { | ||
| 5449 | - if (!scheduleRealInfo.getsGh().equals(sgh)) { | ||
| 5450 | - sgh = scheduleRealInfo.getsGh() == null ? "" : scheduleRealInfo.getsGh(); | ||
| 5451 | - if (!sgh.equals("")) { | ||
| 5452 | - if (map.get("sjb1") != null) { | ||
| 5453 | - if (map.get("sjb2") != null) { | ||
| 5454 | - map.put("sjb3", scheduleRealInfo.getsGh() + "/" + | ||
| 5455 | - scheduleRealInfo.getFcsjActual()); | ||
| 5456 | - } else { | ||
| 5457 | - map.put("sjb2", scheduleRealInfo.getsGh() + "/" + | ||
| 5458 | - scheduleRealInfo.getFcsjActual()); | ||
| 5459 | - } | ||
| 5460 | - } else { | ||
| 5461 | - map.put("sjb1", scheduleRealInfo.getsGh() + "/" + | ||
| 5462 | - scheduleRealInfo.getFcsjActual()); | ||
| 5463 | - } | ||
| 5464 | - } | ||
| 5465 | - } | ||
| 5466 | - } | ||
| 5467 | - if (scheduleRealInfo.getFcsjActual() != null) { | ||
| 5468 | - String fcsjs[] = fcsj.split(":"); | ||
| 5469 | - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":"); | ||
| 5470 | - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]); | ||
| 5471 | - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]); | ||
| 5472 | - map.put("cz" + bcs, b - a); | ||
| 5473 | - } else { | ||
| 5474 | - map.put("cz" + bcs, "无"); | ||
| 5475 | - } | ||
| 5476 | - map.put("lp", scheduleRealInfo.getLpName()); | ||
| 5477 | - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual()); | ||
| 5478 | - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual()); | ||
| 5479 | - | ||
| 5480 | - if (i < scheduleRealInfos.size() - 1) { | ||
| 5481 | - if (!scheduleRealInfos.get(i + 1).getLpName().equals | ||
| 5482 | - (scheduleRealInfos.get(i).getLpName())) { | ||
| 5483 | - list.add(map); | ||
| 5484 | - lp = "lp"; | ||
| 5485 | - jgh = "jgh"; | ||
| 5486 | - clzbh = "clzbh"; | ||
| 5487 | - bcs = 0; | ||
| 5488 | - thclzbh = ""; | ||
| 5489 | - sgh = "sgh"; | ||
| 5490 | - } | ||
| 5491 | - } else { | ||
| 5492 | - list.add(map); | ||
| 5493 | - } | ||
| 5494 | - } else { | ||
| 5495 | - bcs = 1; | ||
| 5496 | - map = new HashMap<String, Object>(); | ||
| 5497 | - lp = scheduleRealInfo.getLpName(); | ||
| 5498 | - jgh = scheduleRealInfo.getjGh(); | ||
| 5499 | - clzbh = scheduleRealInfo.getClZbh(); | ||
| 5500 | - if (scheduleRealInfo.getsGh() != null) { | ||
| 5501 | - sgh = scheduleRealInfo.getsGh(); | ||
| 5502 | - map.put("sjb1", scheduleRealInfo.getsGh() + "/" + | ||
| 5503 | - scheduleRealInfo.getFcsjActual()); | ||
| 5504 | - } | ||
| 5505 | - String fcsj = scheduleRealInfo.getFcsj(); | ||
| 5506 | - scheduleRealInfo.getFcsjActual(); | ||
| 5507 | - map.put("jjb1", jgh + "/" + scheduleRealInfo.getFcsjActual()); | ||
| 5508 | - map.put("cccl", clzbh); | ||
| 5509 | - | ||
| 5510 | - if (scheduleRealInfo.getFcsjActual() != null) { | ||
| 5511 | - String fcsjs[] = fcsj.split(":"); | ||
| 5512 | - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":"); | ||
| 5513 | - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]); | ||
| 5514 | - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]); | ||
| 5515 | - map.put("cz" + bcs, b - a); | ||
| 5516 | - } else { | ||
| 5517 | - map.put("cz" + bcs, "无"); | ||
| 5518 | - } | ||
| 5519 | - | ||
| 5520 | - | ||
| 5521 | - map.put("lp", scheduleRealInfo.getLpName()); | ||
| 5522 | - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual()); | ||
| 5523 | - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual()); | ||
| 5524 | - | ||
| 5525 | - if (i < scheduleRealInfos.size() - 1) { | ||
| 5526 | - if (!scheduleRealInfos.get(i + 1).getLpName().equals | ||
| 5527 | - (scheduleRealInfos.get(i).getLpName())) { | ||
| 5528 | - list.add(map); | ||
| 5529 | - lp = "lp"; | ||
| 5530 | - jgh = "jgh"; | ||
| 5531 | - clzbh = "clzbh"; | ||
| 5532 | - bcs = 0; | ||
| 5533 | - thclzbh = ""; | ||
| 5534 | - sgh = "sgh"; | ||
| 5535 | - } | ||
| 5536 | - } else { | ||
| 5537 | - list.add(map); | ||
| 5538 | - } | ||
| 5539 | - } | ||
| 5540 | - | ||
| 5541 | - } | ||
| 5542 | - return list; | ||
| 5543 | - } | ||
| 5544 | - | ||
| 5545 | - | ||
| 5546 | - @Override | ||
| 5547 | - public List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map) { | ||
| 5548 | - String line = map.get("line").toString(); | ||
| 5549 | - String date = map.get("date").toString(); | ||
| 5550 | - String xlName = map.get("xlName").toString(); | ||
| 5551 | - String state = map.get("state").toString(); | ||
| 5552 | - String type = map.get("type").toString(); | ||
| 5553 | - String genre =map.get("genre").toString(); | ||
| 5554 | - String df=""; | ||
| 5555 | - if(map.get("df")!=null){ | ||
| 5556 | - df=map.get("df").toString(); | ||
| 5557 | - } | ||
| 5558 | - | ||
| 5559 | - List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>(); | ||
| 5560 | - List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>(); | ||
| 5561 | - List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null); | ||
| 5562 | - List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state); | ||
| 5563 | - List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>(); | ||
| 5564 | - if(genre.equals("qp")) | ||
| 5565 | - list3=this.realScheduleListQp(line, date); | ||
| 5566 | - else if(genre.equals("zrw")) | ||
| 5567 | - list3=this.realScheduleList_zrw(line, date); | ||
| 5568 | - else | ||
| 5569 | - list3=this.realScheduleList(line, date); | ||
| 5570 | - Map<String, Object> nMap = new HashMap<String, Object>(); | ||
| 5571 | - nMap.put("date", xlName + date); | ||
| 5572 | - nMap.put("jls", list1.get(0).get("jls")); | ||
| 5573 | - nMap.put("sjgl", list1.get(0).get("sjgl")); | ||
| 5574 | - | ||
| 5575 | - int size = 0; | ||
| 5576 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | ||
| 5577 | - for (int i = 0; i < list2.size(); i++) { | ||
| 5578 | - ScheduleRealInfo s = list2.get(i); | ||
| 5579 | - if (size == 5) { | ||
| 5580 | - size = 0; | ||
| 5581 | - dataList2.add(tempMap); | ||
| 5582 | - tempMap = new HashMap<String, Object>(); | ||
| 5583 | - } | ||
| 5584 | - tempMap.put("lp" + size, s.getLpName()); | ||
| 5585 | - tempMap.put("ch" + size, s.getClZbh()); | ||
| 5586 | - tempMap.put("jz" + size, s.getjGh() + "/" + s.getjName()); | ||
| 5587 | - tempMap.put("sz" + size, ""); | ||
| 5588 | - tempMap.put("jw" + size, ""); | ||
| 5589 | - tempMap.put("sw" + size, ""); | ||
| 5590 | - | ||
| 5591 | - size++; | ||
| 5592 | - } | ||
| 5593 | - if (size < 5) { | ||
| 5594 | - for (; size < 5; size++) { | ||
| 5595 | - tempMap.put("lp" + size, ""); | ||
| 5596 | - tempMap.put("ch" + size, ""); | ||
| 5597 | - tempMap.put("jz" + size, ""); | ||
| 5598 | - tempMap.put("sz" + size, ""); | ||
| 5599 | - tempMap.put("jw" + size, ""); | ||
| 5600 | - tempMap.put("sw" + size, ""); | ||
| 5601 | - } | ||
| 5602 | - } | ||
| 5603 | - | ||
| 5604 | - dataList2.add(tempMap); | ||
| 5605 | - | ||
| 5606 | - size = 0; | ||
| 5607 | - tempMap = new HashMap<String, Object>(); | ||
| 5608 | - for (ScheduleRealInfo schedule : list3) { | ||
| 5609 | - int x = size % 3; | ||
| 5610 | - if (x == 0 && size > 0) { | ||
| 5611 | - dataList3.add(tempMap); | ||
| 5612 | - tempMap = new HashMap<String, Object>(); | ||
| 5613 | - } | ||
| 5614 | - tempMap.put("lpName" + x, schedule.getLpName()); | ||
| 5615 | - tempMap.put("qdzName" + x, schedule.getQdzName()); | ||
| 5616 | - tempMap.put("zdsj" + x, schedule.getZdsj()); | ||
| 5617 | - String zdsjActual = schedule.getZdsjActual() != null ? schedule.getZdsjActual() : ""; | ||
| 5618 | - tempMap.put("zdsjActual" + x, zdsjActual); | ||
| 5619 | - | ||
| 5620 | - String zdsjk = ""; | ||
| 5621 | - String zdsjm = ""; | ||
| 5622 | - if (!zdsjActual.equals("")) { | ||
| 5623 | - String[] zdsj_s = schedule.getZdsj().split(":"); | ||
| 5624 | - String[] zdsjActual_s = zdsjActual.split(":"); | ||
| 5625 | - Long zdsj_ = Long.parseLong(zdsj_s[0]) * 60 + Long.parseLong(zdsj_s[1]); | ||
| 5626 | - Long zdsjActual_ = Long.parseLong(zdsjActual_s[0]) * 60 + Long.parseLong(zdsjActual_s[1]); | ||
| 5627 | - if ((zdsj_ - zdsjActual_) > 0) { | ||
| 5628 | - if(zdsj_ - zdsjActual_>1200){ | ||
| 5629 | - zdsjm=String.valueOf(1440-(zdsj_-zdsjActual_)); | ||
| 5630 | - }else{ | ||
| 5631 | - zdsjk = String.valueOf(zdsj_ - zdsjActual_); | ||
| 5632 | - } | ||
| 5633 | - } else { | ||
| 5634 | - if(zdsjActual_ - zdsj_>1200){ | ||
| 5635 | - zdsjk =String.valueOf(1440-(zdsjActual_ - zdsj_)); | ||
| 5636 | - }else{ | ||
| 5637 | - zdsjm = String.valueOf(zdsjActual_ - zdsj_); | ||
| 5638 | - } | ||
| 5639 | - } | ||
| 5640 | - } | ||
| 5641 | - tempMap.put("zdsjk" + x, zdsjk); | ||
| 5642 | - tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm); | ||
| 5643 | - tempMap.put("fcsj" + x, schedule.getFcsj()); | ||
| 5644 | - String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : ""; | ||
| 5645 | - String bcType = schedule.getBcType() != null ? schedule.getBcType() : ""; | ||
| 5646 | - String fcsjActuralstr = ""; | ||
| 5647 | - if (bcType.equals("in")) { | ||
| 5648 | - fcsjActuralstr = fcsjActural + "(进)"; | ||
| 5649 | - } else if (bcType.equals("out")) { | ||
| 5650 | - fcsjActuralstr = fcsjActural + "(出)"; | ||
| 5651 | - } else { | ||
| 5652 | - fcsjActuralstr = fcsjActural; | ||
| 5653 | - } | ||
| 5654 | - tempMap.put("fcsjActual" + x, fcsjActuralstr); | ||
| 5655 | - String fcsjk = ""; | ||
| 5656 | - String fcsjm = ""; | ||
| 5657 | - String dfsjk =""; | ||
| 5658 | - String dfsjm=""; | ||
| 5659 | - if (!fcsjActural.equals("")) { | ||
| 5660 | - String[] fcsj_s = schedule.getFcsj().split(":"); | ||
| 5661 | - String[] fcsjActural_s = fcsjActural.split(":"); | ||
| 5662 | - Long fcsj_ = Long.parseLong(fcsj_s[0]) * 60 + Long.parseLong(fcsj_s[1]); | ||
| 5663 | - Long fcsjActural_ = Long.parseLong(fcsjActural_s[0]) * 60 + Long.parseLong(fcsjActural_s[1]); | ||
| 5664 | - if ((fcsj_ - fcsjActural_) > 0) { | ||
| 5665 | - if(fcsj_ - fcsjActural_>1200){ | ||
| 5666 | - fcsjm=String.valueOf(1440-(fcsj_ - fcsjActural_)); | ||
| 5667 | - }else{ | ||
| 5668 | - fcsjk = String.valueOf(fcsj_ - fcsjActural_); | ||
| 5669 | - } | ||
| 5670 | - } else { | ||
| 5671 | - if(fcsjActural_ - fcsj_>1200){ | ||
| 5672 | - fcsjk =String.valueOf(1440-(fcsjActural_ - fcsj_)); | ||
| 5673 | - } | ||
| 5674 | - else{ | ||
| 5675 | - fcsjm = String.valueOf(fcsjActural_ - fcsj_); | ||
| 5676 | - } | ||
| 5677 | - } | ||
| 5678 | - if(df.equals("df")){ | ||
| 5679 | - String[] dfsj_s =schedule.getDfsj().split(":"); | ||
| 5680 | - Long dfsj_ = Long.parseLong(dfsj_s[0]) * 60 + Long.parseLong(dfsj_s[1]); | ||
| 5681 | - if ((dfsj_ - fcsjActural_) > 0) { | ||
| 5682 | - if(dfsj_ - fcsjActural_>1200){ | ||
| 5683 | - dfsjm=String.valueOf(1440-(dfsj_ - fcsjActural_)); | ||
| 5684 | - }else{ | ||
| 5685 | - dfsjk = String.valueOf(dfsj_ - fcsjActural_); | ||
| 5686 | - } | ||
| 5687 | - } else { | ||
| 5688 | - if(fcsjActural_ - dfsj_>1200){ | ||
| 5689 | - dfsjk= String.valueOf(1440-(fcsjActural_ - dfsj_)); | ||
| 5690 | - }else{ | ||
| 5691 | - dfsjm = String.valueOf(fcsjActural_ - dfsj_); | ||
| 5692 | - } | ||
| 5693 | - } | ||
| 5694 | - } | ||
| 5695 | - } | ||
| 5696 | - if(df.equals("df")){ | ||
| 5697 | - tempMap.put("dfsj"+x,schedule.getDfsj()); | ||
| 5698 | - tempMap.put("dfsjk" + x, dfsjk); | ||
| 5699 | - tempMap.put("dfsjm" + x, dfsjm.equals("0")?"":dfsjm); | ||
| 5700 | - } | ||
| 5701 | - tempMap.put("fcsjk" + x, fcsjk); | ||
| 5702 | - tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm); | ||
| 5703 | - tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : ""); | ||
| 5704 | - | ||
| 5705 | - size++; | ||
| 5706 | - } | ||
| 5707 | - if (tempMap.get("lpName0") != null) { | ||
| 5708 | - if (tempMap.get("lpName1") == null) { | ||
| 5709 | - tempMap.put("lpName1", ""); | ||
| 5710 | - tempMap.put("qdzName1", ""); | ||
| 5711 | - tempMap.put("zdsj1", ""); | ||
| 5712 | - tempMap.put("zdsjActual1", ""); | ||
| 5713 | - tempMap.put("zdsjk1", ""); | ||
| 5714 | - tempMap.put("zdsjm1", ""); | ||
| 5715 | - tempMap.put("fcsj1", ""); | ||
| 5716 | - tempMap.put("fcsjActual1", ""); | ||
| 5717 | - tempMap.put("fcsjk1", ""); | ||
| 5718 | - tempMap.put("fcsjm1", ""); | ||
| 5719 | - if(df.equals("df")){ | ||
| 5720 | - tempMap.put("dfsj1",""); | ||
| 5721 | - tempMap.put("dfsjk1" , ""); | ||
| 5722 | - tempMap.put("dfsjm1" , ""); | ||
| 5723 | - } | ||
| 5724 | - tempMap.put("remarks1", ""); | ||
| 5725 | - } | ||
| 5726 | - if (tempMap.get("lpName2") == null) { | ||
| 5727 | - tempMap.put("lpName2", ""); | ||
| 5728 | - tempMap.put("qdzName2", ""); | ||
| 5729 | - tempMap.put("zdsj2", ""); | ||
| 5730 | - tempMap.put("zdsjActual2", ""); | ||
| 5731 | - tempMap.put("zdsjk2", ""); | ||
| 5732 | - tempMap.put("zdsjm2", ""); | ||
| 5733 | - tempMap.put("fcsj2", ""); | ||
| 5734 | - tempMap.put("fcsjActual2", ""); | ||
| 5735 | - tempMap.put("fcsjk2", ""); | ||
| 5736 | - tempMap.put("fcsjm2", ""); | ||
| 5737 | - if(df.equals("df")){ | ||
| 5738 | - tempMap.put("dfsj2",""); | ||
| 5739 | - tempMap.put("dfsjk2" , ""); | ||
| 5740 | - tempMap.put("dfsjm2" , ""); | ||
| 5741 | - } | ||
| 5742 | - tempMap.put("remarks2", ""); | ||
| 5743 | - } | ||
| 5744 | - dataList3.add(tempMap); | ||
| 5745 | - } | ||
| 5746 | - | ||
| 5747 | - if (date.length() == 10) { | ||
| 5748 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59"); | ||
| 5749 | - String dbdp = ""; | ||
| 5750 | - try { | ||
| 5751 | - for (int i = 0; i < list.size(); i++) { | ||
| 5752 | - DutyEmployee t = list.get(i); | ||
| 5753 | - if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 5754 | - if (!(dbdp.length() > 0)) { | ||
| 5755 | - dbdp = t.getuName(); | ||
| 5756 | - } else { | ||
| 5757 | - dbdp += "," + t.getuName(); | ||
| 5758 | - } | ||
| 5759 | - } | ||
| 5760 | - } | ||
| 5761 | - } catch (Exception e) { | ||
| 5762 | - // TODO: handle exception | ||
| 5763 | - e.printStackTrace(); | ||
| 5764 | - } | ||
| 5765 | - nMap.put("dbdp", dbdp); | ||
| 5766 | - } | ||
| 5767 | - | ||
| 5768 | - if (type.equals("export")) { | ||
| 5769 | - String lineName = ""; | ||
| 5770 | - if (map.containsKey("lineName")) | ||
| 5771 | - lineName = "-" + map.get("lineName").toString() + "-"; | ||
| 5772 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 5773 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 5774 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 5775 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 5776 | - ReportUtils ee = new ReportUtils(); | ||
| 5777 | - try { | ||
| 5778 | - listI.add(list1.iterator()); | ||
| 5779 | - listI.add(dataList2.iterator()); | ||
| 5780 | - listI.add(dataList3.iterator()); | ||
| 5781 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 5782 | - String sourcePath = path + "mould/scheduleDaily.xls"; | ||
| 5783 | - if (date.length() == 7) { | ||
| 5784 | - sdfMonth = new SimpleDateFormat("yyyy-MM"); | ||
| 5785 | - sdfSimple = new SimpleDateFormat("yyyyMM"); | ||
| 5786 | - sourcePath = path + "mould/scheduleDaily_m.xls"; | ||
| 5787 | - } | ||
| 5788 | - if(df.equals("df")){ | ||
| 5789 | - sourcePath =path + "mould/scheduleDaily_df.xls"; | ||
| 5790 | - } | ||
| 5791 | - ee.excelReplace(listI, new Object[]{nMap}, sourcePath, | ||
| 5792 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) + lineName + "调度日报.xls"); | ||
| 5793 | - } catch (Exception e) { | ||
| 5794 | - // TODO: handle exception | ||
| 5795 | - e.printStackTrace(); | ||
| 5796 | - } | ||
| 5797 | - } | ||
| 5798 | - | ||
| 5799 | - return new ArrayList<Map<String, Object>>(); | ||
| 5800 | - } | ||
| 5801 | - | ||
| 5802 | - public void exportWaybill_pl(List<ScheduleRealInfo> listpl, | ||
| 5803 | - String date, String jName, String clZbh, String lpName) { | ||
| 5804 | - ReportUtils ee = new ReportUtils(); | ||
| 5805 | - ReportRelatedUtils rru = new ReportRelatedUtils(); | ||
| 5806 | - List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | ||
| 5807 | - List<ScheduleRealInfo> scheduleRealInfos = listpl; | ||
| 5808 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 5809 | -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line); | ||
| 5810 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 5811 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5812 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 5813 | - Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 5814 | - if (cts != null && cts.size() > 0) { | ||
| 5815 | - lists.add(s); | ||
| 5816 | - } else { | ||
| 5817 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 5818 | - lists.add(s); | ||
| 5819 | - } | ||
| 5820 | - } | ||
| 5821 | - } | ||
| 5822 | - DecimalFormat format = new DecimalFormat("0.00"); | ||
| 5823 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 5824 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 5825 | - //计算里程和班次数,并放入Map里 | ||
| 5826 | - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); | ||
| 5827 | - | ||
| 5828 | - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos))); | ||
| 5829 | - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos)); | ||
| 5830 | - map.put("addMileage", culateMieageService.culateLjgl(lists)); | ||
| 5831 | - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists)); | ||
| 5832 | - map.put("yygl", yygl); | ||
| 5833 | - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists)); | ||
| 5834 | - map.put("ksgl", ksgl); | ||
| 5835 | - map.put("realMileage", Arith.add(yygl, ksgl)); | ||
| 5836 | - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, "")); | ||
| 5837 | - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos)); | ||
| 5838 | - map.put("ljbc", culateMieageService.culateLjbc(lists, "")); | ||
| 5839 | - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, ""); | ||
| 5840 | - map.put("sjbc", sjbc); | ||
| 5841 | -// map=new HashMap<String,Object>(); | ||
| 5842 | - | ||
| 5843 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 5844 | - String minfcsj = "02:00"; | ||
| 5845 | - List<Line> lineList = lineRepository.findLineByCode(listpl.get(0).getXlBm()); | ||
| 5846 | - if (lineList.size() > 0) { | ||
| 5847 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 5848 | - + " id = (" | ||
| 5849 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 5850 | - + ")"; | ||
| 5851 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 5852 | - } | ||
| 5853 | - String[] minSjs = minfcsj.split(":"); | ||
| 5854 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 5855 | - | ||
| 5856 | - | ||
| 5857 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5858 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 5859 | - String[] fcsj = s.getFcsj().split(":"); | ||
| 5860 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 5861 | - | ||
| 5862 | - Long fscjT = 0L; | ||
| 5863 | - if (fcsjL < minSj) { | ||
| 5864 | - Calendar calendar = new GregorianCalendar(); | ||
| 5865 | - calendar.setTime(s.getScheduleDate()); | ||
| 5866 | - calendar.add(calendar.DATE, 1); | ||
| 5867 | - s.setScheduleDate(calendar.getTime()); | ||
| 5868 | - try { | ||
| 5869 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 5870 | - } catch (ParseException e) { | ||
| 5871 | - // TODO Auto-generated catch block | ||
| 5872 | - e.printStackTrace(); | ||
| 5873 | - } | ||
| 5874 | - | ||
| 5875 | - } else { | ||
| 5876 | - try { | ||
| 5877 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 5878 | - } catch (ParseException e) { | ||
| 5879 | - // TODO Auto-generated catch block | ||
| 5880 | - e.printStackTrace(); | ||
| 5881 | - } | ||
| 5882 | - ; | ||
| 5883 | - } | ||
| 5884 | - s.setFcsjT(fscjT); | ||
| 5885 | - } | ||
| 5886 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 5887 | - Collections.sort(scheduleRealInfos, new ComparableReal()); | ||
| 5888 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5889 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 5890 | - s.setAdjustExps(i + 1 + ""); | ||
| 5891 | - String remarks = ""; | ||
| 5892 | - if (s.getRemarks() != null) { | ||
| 5893 | - remarks += s.getRemarks(); | ||
| 5894 | - } | ||
| 5895 | - | ||
| 5896 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 5897 | - if (!childTaskPlans.isEmpty()) { | ||
| 5898 | - s.setFcsjActual(""); | ||
| 5899 | - s.setZdsjActual(""); | ||
| 5900 | - s.setJhlc(0.0); | ||
| 5901 | - } | ||
| 5902 | - | ||
| 5903 | - if (s.isDestroy()) { | ||
| 5904 | - s.setFcsjActual(""); | ||
| 5905 | - s.setZdsjActual(""); | ||
| 5906 | - s.setJhlc(0.0); | ||
| 5907 | - remarks += "(烂班)"; | ||
| 5908 | - s.setRemarks(remarks); | ||
| 5909 | - } | ||
| 5910 | - | ||
| 5911 | - listSchedule.add(s); | ||
| 5912 | - //计算营运里程,空驶里程 | ||
| 5913 | - if (!childTaskPlans.isEmpty()) { | ||
| 5914 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 5915 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 5916 | - Collections.sort(listit, new ComparableChild()); | ||
| 5917 | - for (int j = 0; j < listit.size(); j++) { | ||
| 5918 | - ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 5919 | - ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 5920 | - if (childTaskPlan.isDestroy()) { | ||
| 5921 | - t.setFcsjActual(""); | ||
| 5922 | - t.setZdsjActual(""); | ||
| 5923 | - t.setJhlc(0.0); | ||
| 5924 | - } else { | ||
| 5925 | - t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 5926 | - t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 5927 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 5928 | - } | ||
| 5929 | - t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 5930 | - t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 5931 | - t.setRemarks(childTaskPlan.getRemarks()); | ||
| 5932 | - t.setAdjustExps("子"); | ||
| 5933 | - t.setjGh(""); | ||
| 5934 | - t.setjName(""); | ||
| 5935 | - t.setsGh(""); | ||
| 5936 | - t.setsName(""); | ||
| 5937 | - listSchedule.add(t); | ||
| 5938 | - } | ||
| 5939 | - } | ||
| 5940 | - } | ||
| 5941 | - Map<String, Object> maps; | ||
| 5942 | - for (ScheduleRealInfo scheduleRealInfo : listSchedule) { | ||
| 5943 | - maps = new HashMap<String, Object>(); | ||
| 5944 | - try { | ||
| 5945 | - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | ||
| 5946 | - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | ||
| 5947 | - maps = rru.getMapValue(scheduleRealInfo); | ||
| 5948 | - maps.put("bcs", scheduleRealInfo.getAdjustExps()); | ||
| 5949 | - String zdsj = scheduleRealInfo.getZdsj(); | ||
| 5950 | - String zdsjActual = scheduleRealInfo.getZdsjActual(); | ||
| 5951 | - if (zdsj != null && zdsjActual != null && | ||
| 5952 | - !zdsj.equals(zdsjActual) && | ||
| 5953 | - !zdsj.equals("") && | ||
| 5954 | - !zdsjActual.equals("")) { | ||
| 5955 | - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | ||
| 5956 | - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | ||
| 5957 | - if (zdsj.compareTo(zdsjActual) > 0) { | ||
| 5958 | - if (zdsjT - zdsjAT > 1000) { | ||
| 5959 | - maps.put("fast", ""); | ||
| 5960 | - maps.put("slow", zdsjAT - zdsjT + 1440); | ||
| 5961 | - } else { | ||
| 5962 | - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 5963 | - maps.put("slow", ""); | ||
| 5964 | - } | ||
| 5965 | - } else { | ||
| 5966 | - if (zdsjAT - zdsjT > 1000) { | ||
| 5967 | - maps.put("fast", zdsjT - zdsjAT + 1440); | ||
| 5968 | - maps.put("slow", ""); | ||
| 5969 | - } else { | ||
| 5970 | - maps.put("fast", ""); | ||
| 5971 | - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 5972 | - } | ||
| 5973 | - } | ||
| 5974 | - } else { | ||
| 5975 | - maps.put("fast", ""); | ||
| 5976 | - maps.put("slow", ""); | ||
| 5977 | - } | ||
| 5978 | - listMap.add(maps); | ||
| 5979 | - } catch (Exception e) { | ||
| 5980 | - e.printStackTrace(); | ||
| 5981 | - } | ||
| 5982 | - } | ||
| 5983 | - | ||
| 5984 | - | ||
| 5985 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 5986 | - list.add(listMap.iterator()); | ||
| 5987 | - String xls = ""; | ||
| 5988 | - if (map.get("type").toString().equals("0")) { | ||
| 5989 | - xls = "waybill_minhang.xls"; | ||
| 5990 | - } else { | ||
| 5991 | - xls = "waybill_minhang_dl.xls"; | ||
| 5992 | - } | ||
| 5993 | - map.put("sheetName", jName + "-" + clZbh + "-" + lpName); | ||
| 5994 | - ee.excelReplace(list, new Object[]{map}, path + "mould/" + xls, | ||
| 5995 | - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | ||
| 5996 | - } | ||
| 5997 | - | ||
| 5998 | - @Override | ||
| 5999 | - public Map<String, Object> exportWaybillMore(Map<String, Object> map) { | ||
| 6000 | - String date = map.get("date").toString(); | ||
| 6001 | - String line = map.get("line").toString(); | ||
| 6002 | - ReportUtils ee = new ReportUtils(); | ||
| 6003 | - List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class); | ||
| 6004 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; | ||
| 6005 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 6006 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 6007 | - int num = 0; | ||
| 6008 | - File file = null; | ||
| 6009 | - try { | ||
| 6010 | - while (true) { | ||
| 6011 | - String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date)); | ||
| 6012 | -// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹 | ||
| 6013 | - file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件 | ||
| 6014 | - if (file.exists()) { //判断是否已存在重名 | ||
| 6015 | - num++; | ||
| 6016 | - } else { | ||
| 6017 | - break; | ||
| 6018 | - } | ||
| 6019 | - } | ||
| 6020 | -// file.mkdirs(); //创建 | ||
| 6021 | - List<ScheduleRealInfo> lists_line = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date); | ||
| 6022 | - List<File> files = new ArrayList<File>(); | ||
| 6023 | - for (List<String> list : lists) { | ||
| 6024 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 6025 | - String jName = list.get(0); | ||
| 6026 | - String clZbh = list.get(1); | ||
| 6027 | - String lpName = list.get(2); | ||
| 6028 | - String jGh = list.get(3); | ||
| 6029 | - for (int i = 0; i < lists_line.size(); i++) { | ||
| 6030 | - ScheduleRealInfo s = lists_line.get(i); | ||
| 6031 | - if (s.getjGh().equals(jGh) && s.getClZbh().equals(clZbh) && s.getLpName().equals(lpName)) { | ||
| 6032 | - newList.add(s); | ||
| 6033 | - } | ||
| 6034 | - } | ||
| 6035 | - this.exportWaybill_pl(newList, date, jName, clZbh, lpName); | ||
| 6036 | - File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | ||
| 6037 | - String fileName = file.getName(); | ||
| 6038 | - files.add(temp); | ||
| 6039 | - } | ||
| 6040 | - for (int i = 1; i < files.size(); i++) { | ||
| 6041 | - File file1 = files.get(0); | ||
| 6042 | - File file2 = files.get(i); | ||
| 6043 | - ee.copySheetByFile(file2, file1, 0, 145); | ||
| 6044 | - } | ||
| 6045 | - File newFile = files.get(0); | ||
| 6046 | - newFile.renameTo(file); | ||
| 6047 | -// temp.renameTo(new File(path + fileName + "/" + temp.getName())); | ||
| 6048 | -// File[] listFiles = file.listFiles(); | ||
| 6049 | -// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip"))); | ||
| 6050 | -//// zos.setEncoding("gbk"); | ||
| 6051 | -//// zos.putNextEntry(new ZipEntry(fileName + "/")); | ||
| 6052 | -// for (int i = 0; i < listFiles.length; i++) { | ||
| 6053 | -// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName())); | ||
| 6054 | -// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i])); | ||
| 6055 | -// BufferedOutputStream bos = new BufferedOutputStream(zos); | ||
| 6056 | -// int bytesRead = 0; | ||
| 6057 | -// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) { | ||
| 6058 | -//// zos.write(buffer, 0, bytesRead); | ||
| 6059 | -//// zos.flush(); | ||
| 6060 | -// bos.write(buffer, 0, bytesRead); | ||
| 6061 | -// bos.flush(); | ||
| 6062 | -// } | ||
| 6063 | -//// bos.close(); | ||
| 6064 | -// bis.close(); | ||
| 6065 | -// } | ||
| 6066 | -// zos.close(); | ||
| 6067 | -// } | ||
| 6068 | - | ||
| 6069 | - } catch (Exception e) { | ||
| 6070 | - // TODO: handle exception | ||
| 6071 | - e.printStackTrace(); | ||
| 6072 | - } | ||
| 6073 | - | ||
| 6074 | - map.put("fileName", file.getName()); | ||
| 6075 | - return map; | ||
| 6076 | - } | ||
| 6077 | - | ||
| 6078 | - @Autowired | ||
| 6079 | - SchedulePlanInfoService schPlanService; | ||
| 6080 | - | ||
| 6081 | - @Override | ||
| 6082 | - public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) { | ||
| 6083 | - List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode); | ||
| 6084 | - | ||
| 6085 | - if (rs == null || rs.size() == 0) { | ||
| 6086 | - //尝试刷新内存 | ||
| 6087 | - Map<String, Object> data = new HashMap<>(); | ||
| 6088 | - data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode)); | ||
| 6089 | - data.put("xlBm_eq", lineCode); | ||
| 6090 | - List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator()); | ||
| 6091 | - | ||
| 6092 | - if (planItr.size() > 0) { | ||
| 6093 | - dayOfSchedule.schedulePlanMap.put(lineCode, planItr); | ||
| 6094 | - return planItr; | ||
| 6095 | - } | ||
| 6096 | - } | ||
| 6097 | - return rs; | ||
| 6098 | - } | ||
| 6099 | - | ||
| 6100 | - | ||
| 6101 | - @Override | ||
| 6102 | - public Map<String, Object> lpChangeMulti(String leftIdx, String rightIdx, int type) { | ||
| 6103 | - Map<String, Object> rs = new HashMap<>(); | ||
| 6104 | - Set<ScheduleRealInfo> ts = new HashSet<>(); | ||
| 6105 | - try { | ||
| 6106 | - List<String> leftList = Splitter.on(",").splitToList(leftIdx); | ||
| 6107 | - List<String> rightList = Splitter.on(",").splitToList(rightIdx); | ||
| 6108 | - Set<String> lpSet = new HashSet<>(); | ||
| 6109 | - Set<String> carSet = new HashSet<>(); | ||
| 6110 | - | ||
| 6111 | - List<ScheduleRealInfo> largeList, smallList; | ||
| 6112 | - if (leftList.size() > rightList.size()) { | ||
| 6113 | - largeList = getByIdx(leftList); | ||
| 6114 | - smallList = getByIdx(rightList); | ||
| 6115 | - } else { | ||
| 6116 | - largeList = getByIdx(rightList); | ||
| 6117 | - smallList = getByIdx(leftList); | ||
| 6118 | - } | ||
| 6119 | - | ||
| 6120 | - ScheduleRealInfo leftSch, rightSch = null; | ||
| 6121 | - for (int i = 0; i < largeList.size(); i++) { | ||
| 6122 | - leftSch = largeList.get(i); | ||
| 6123 | - leftSch.setLpChange(1); | ||
| 6124 | - if (i < smallList.size()) { | ||
| 6125 | - rightSch = smallList.get(i); | ||
| 6126 | - rightSch.setLpChange(1); | ||
| 6127 | - ts.add(rightSch); | ||
| 6128 | - } else { | ||
| 6129 | - //不对称时多出来的 | ||
| 6130 | - lpChangeByLeft(leftSch, largeList.get(i - 1), type); | ||
| 6131 | - ts.add(leftSch); | ||
| 6132 | - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName()); | ||
| 6133 | - continue; | ||
| 6134 | - } | ||
| 6135 | - | ||
| 6136 | - //调换路牌 | ||
| 6137 | - lpChange(leftSch, rightSch, type); | ||
| 6138 | - ts.add(leftSch); | ||
| 6139 | - | ||
| 6140 | - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName()); | ||
| 6141 | - lpSet.add(rightSch.getXlBm() + "_" + rightSch.getLpName()); | ||
| 6142 | - | ||
| 6143 | - carSet.add(leftSch.getClZbh()); | ||
| 6144 | - carSet.add(rightSch.getClZbh()); | ||
| 6145 | - scheduleRealInfoRepository.updateLpChange(leftSch.getId()); | ||
| 6146 | - scheduleRealInfoRepository.updateLpChange(rightSch.getId()); | ||
| 6147 | - } | ||
| 6148 | - | ||
| 6149 | - //重新计算路牌的起点应到时间 | ||
| 6150 | - for (String lpName : lpSet) { | ||
| 6151 | - ts.addAll(dayOfSchedule.updateQdzTimePlan(lpName)); | ||
| 6152 | - } | ||
| 6153 | - | ||
| 6154 | - //重新就算车辆当前执行班次 | ||
| 6155 | - for(String nbbm : carSet){ | ||
| 6156 | - dayOfSchedule.reCalcExecPlan(nbbm); | ||
| 6157 | - } | ||
| 6158 | - | ||
| 6159 | - | ||
| 6160 | - for (ScheduleRealInfo sch : ts) { | ||
| 6161 | - dayOfSchedule.save(sch); | ||
| 6162 | - } | ||
| 6163 | - | ||
| 6164 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 6165 | - rs.put("ts", ts); | ||
| 6166 | - } catch (Exception e) { | ||
| 6167 | - logger.error("", e); | ||
| 6168 | - rs.put("status", ResponseCode.ERROR); | ||
| 6169 | - rs.put("msg", e.getMessage()); | ||
| 6170 | - } | ||
| 6171 | - | ||
| 6172 | - return rs; | ||
| 6173 | - } | ||
| 6174 | - | ||
| 6175 | - private List<ScheduleRealInfo> getByIdx(List<String> idList) { | ||
| 6176 | - List<ScheduleRealInfo> list = new ArrayList<>(); | ||
| 6177 | - for (String id : idList) { | ||
| 6178 | - list.add(dayOfSchedule.get(Long.parseLong(id))); | ||
| 6179 | - } | ||
| 6180 | - return list; | ||
| 6181 | - } | ||
| 6182 | - | ||
| 6183 | - @Override | ||
| 6184 | - public void lpChange(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) { | ||
| 6185 | - //释放班次映射 | ||
| 6186 | - if (type > 0) { | ||
| 6187 | - dayOfSchedule.removeNbbm2SchMapp(leftSch); | ||
| 6188 | - dayOfSchedule.removeNbbm2SchMapp(rightSch); | ||
| 6189 | - } | ||
| 6190 | - | ||
| 6191 | - //对调数据 | ||
| 6192 | - LpData leftData = new LpData(leftSch); | ||
| 6193 | - LpData rightData = new LpData(rightSch); | ||
| 6194 | - | ||
| 6195 | - leftData.appendTo(rightSch, type); | ||
| 6196 | - rightData.appendTo(leftSch, type); | ||
| 6197 | - | ||
| 6198 | - if (type > 0) { | ||
| 6199 | - //重新映射 | ||
| 6200 | - dayOfSchedule.addNbbm2SchMapp(leftSch); | ||
| 6201 | - dayOfSchedule.addNbbm2SchMapp(rightSch); | ||
| 6202 | - } | ||
| 6203 | - } | ||
| 6204 | - | ||
| 6205 | - /** | ||
| 6206 | - * 更换左边班次的路牌,右边不变 | ||
| 6207 | - * | ||
| 6208 | - * @param leftSch | ||
| 6209 | - * @param rightSch | ||
| 6210 | - * @param type | ||
| 6211 | - */ | ||
| 6212 | - public void lpChangeByLeft(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) { | ||
| 6213 | - //释放班次映射 | ||
| 6214 | - if (type > 0) | ||
| 6215 | - dayOfSchedule.removeNbbm2SchMapp(leftSch); | ||
| 6216 | - | ||
| 6217 | - LpData rightData = new LpData(rightSch); | ||
| 6218 | - rightData.appendTo(leftSch, type); | ||
| 6219 | - | ||
| 6220 | - //重新映射 | ||
| 6221 | - if (type > 0) | ||
| 6222 | - dayOfSchedule.addNbbm2SchMapp(leftSch); | ||
| 6223 | - | ||
| 6224 | - } | ||
| 6225 | - | ||
| 6226 | - @Override | ||
| 6227 | - public Map<String, Object> revokeRealArrive(Long id) { | ||
| 6228 | - Map<String, Object> rs = new HashMap<>(); | ||
| 6229 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 6230 | - | ||
| 6231 | - try { | ||
| 6232 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 6233 | - if (sch.getZdsjActual() == null && sch.getFcsjActual() == null) { | ||
| 6234 | - rs.put("status", ResponseCode.ERROR); | ||
| 6235 | - rs.put("msg", "班次未执行,无法撤销!"); | ||
| 6236 | - } else { | ||
| 6237 | - //日志记录 | ||
| 6238 | - ScheduleModifyLogger.cxzx(sch); | ||
| 6239 | - | ||
| 6240 | - sch.clearFcsjActual(); | ||
| 6241 | - sch.clearZdsjActual(); | ||
| 6242 | - //清除路牌下一个班的起点到达时间 | ||
| 6243 | - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch); | ||
| 6244 | - if (null != next) { | ||
| 6245 | - next.setQdzArrDatesj(null); | ||
| 6246 | - ts.add(next); | ||
| 6247 | - } | ||
| 6248 | - | ||
| 6249 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 6250 | - | ||
| 6251 | - ts.add(sch); | ||
| 6252 | - rs.put("ts", ts); | ||
| 6253 | - | ||
| 6254 | - dayOfSchedule.save(sch); | ||
| 6255 | - //重新计算当前执行班次 | ||
| 6256 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 6257 | - | ||
| 6258 | - } | ||
| 6259 | - } catch (Exception e) { | ||
| 6260 | - logger.error("", e); | ||
| 6261 | - rs.put("status", ResponseCode.ERROR); | ||
| 6262 | - } | ||
| 6263 | - return rs; | ||
| 6264 | - } | ||
| 6265 | - | ||
| 6266 | - @Override | ||
| 6267 | - public Map<String, Object> lateAdjust(String idx, float minute) { | ||
| 6268 | - Map<String, Object> rs = new HashMap<>(); | ||
| 6269 | - try { | ||
| 6270 | - int count = 0; | ||
| 6271 | - List<ScheduleRealInfo> list = new ArrayList<>(); | ||
| 6272 | - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx); | ||
| 6273 | - | ||
| 6274 | - ScheduleRealInfo sch; | ||
| 6275 | - for (String id : ids) { | ||
| 6276 | - sch = dayOfSchedule.get(Long.parseLong(id)); | ||
| 6277 | - if (sch != null && sch.getStatus() == 0) { | ||
| 6278 | - if (minute > 0) { | ||
| 6279 | - sch.setLateMinute(minute); | ||
| 6280 | - } else if (minute == 0) { | ||
| 6281 | - LateAdjustHandle.remove(sch); | ||
| 6282 | - } | ||
| 6283 | - count++; | ||
| 6284 | - list.add(sch); | ||
| 6285 | - } | ||
| 6286 | - } | ||
| 6287 | - | ||
| 6288 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 6289 | - rs.put("count", count); | ||
| 6290 | - rs.put("ts", list); | ||
| 6291 | - } catch (Exception e) { | ||
| 6292 | - logger.error("", e); | ||
| 6293 | - rs.put("status", ResponseCode.ERROR); | ||
| 6294 | - rs.put("msg", e.getMessage()); | ||
| 6295 | - } | ||
| 6296 | - | ||
| 6297 | - return rs; | ||
| 6298 | - } | ||
| 6299 | - | ||
| 6300 | - @Override | ||
| 6301 | - public List<ScheduleRealInfo> allLate2(String idx) { | ||
| 6302 | - List<ScheduleRealInfo> rs = new ArrayList<>(); | ||
| 6303 | - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx); | ||
| 6304 | - | ||
| 6305 | - Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch(); | ||
| 6306 | - for (ScheduleRealInfo sch : all) { | ||
| 6307 | - if (ids.indexOf(sch.getXlBm()) != -1) { | ||
| 6308 | - rs.add(sch); | ||
| 6309 | - } | ||
| 6310 | - } | ||
| 6311 | - return rs; | ||
| 6312 | - } | ||
| 6313 | - | ||
| 6314 | - | ||
| 6315 | - @Override | ||
| 6316 | - public List<Map<String, Object>> mileageReport(String gsdm, | ||
| 6317 | - String fgsdm, String line, String date, String date2) { | ||
| 6318 | - | ||
| 6319 | - String sql = "select * from calc_mileage where 1=1 "; | ||
| 6320 | - if (!line.equals(" ")) { | ||
| 6321 | - sql = sql + " and line_code='" + line + "' "; | ||
| 6322 | - } | ||
| 6323 | - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'"; | ||
| 6324 | - if (!gsdm.equals(" ")) { | ||
| 6325 | - sql = sql + " and company_id=" + gsdm; | ||
| 6326 | - } | ||
| 6327 | - if (!gsdm.equals(" ")) { | ||
| 6328 | - sql = sql + " and sub_company_id=" + fgsdm; | ||
| 6329 | - } | ||
| 6330 | - sql = sql + " order by line_code"; | ||
| 6331 | - List<MileageReport> list = jdbcTemplate.query(sql, | ||
| 6332 | - new RowMapper<MileageReport>() { | ||
| 6333 | - @Override | ||
| 6334 | - public MileageReport mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 6335 | - MileageReport mr = new MileageReport(); | ||
| 6336 | - mr.setCompanyName(rs.getString("company_name")); | ||
| 6337 | - mr.setSubCompanyName(rs.getString("sub_company_name")); | ||
| 6338 | - mr.setLineName(rs.getString("line_name")); | ||
| 6339 | - mr.setSjyygl(rs.getDouble("sjyygl")); | ||
| 6340 | - mr.setSjksgl(rs.getDouble("sjksgl")); | ||
| 6341 | - mr.setZgl(rs.getDouble("zyygl")); | ||
| 6342 | - mr.setZddfgl(rs.getDouble("zddfgl")); | ||
| 6343 | - mr.setSddfgl(rs.getDouble("sddfgl")); | ||
| 6344 | - mr.setWqwxhgl(rs.getDouble("wqwxhgl")); | ||
| 6345 | - mr.setBfwxhgl(rs.getDouble("bfwxhgl")); | ||
| 6346 | - mr.setPygl(rs.getDouble("pygl")); | ||
| 6347 | - mr.setLjgl(rs.getDouble("ljgl")); | ||
| 6348 | - mr.setZrwgl(rs.getDouble("zrwgl")); | ||
| 6349 | - mr.setOther(rs.getString("other")); | ||
| 6350 | - return mr; | ||
| 6351 | - } | ||
| 6352 | - }); | ||
| 6353 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 6354 | - double sjyygl = 0.0; | ||
| 6355 | - double sjksgl = 0.0; | ||
| 6356 | - double zgl = 0.0; | ||
| 6357 | - double sddfgl = 0.0; | ||
| 6358 | - double zddfgl = 0.0; | ||
| 6359 | - double wqwxhgl = 0.0; | ||
| 6360 | - double bfwxhgl = 0.0; | ||
| 6361 | - double pygl = 0.0; | ||
| 6362 | - double ljgl = 0.0; | ||
| 6363 | - double zrwgl = 0.0; | ||
| 6364 | - for (MileageReport mr : list) { | ||
| 6365 | - Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6366 | - resMap.put("gsName", mr.getCompanyName()); | ||
| 6367 | - resMap.put("fgsName", mr.getSubCompanyName()); | ||
| 6368 | - resMap.put("xlName", mr.getLineName()); | ||
| 6369 | - resMap.put("sjyygl", mr.getSjyygl()); | ||
| 6370 | - resMap.put("sjksgl", mr.getSjksgl()); | ||
| 6371 | - resMap.put("zgl", mr.getZgl()); | ||
| 6372 | - resMap.put("sddfgl", mr.getSddfgl()); | ||
| 6373 | - resMap.put("zddfgl", mr.getZddfgl()); | ||
| 6374 | - resMap.put("wqwxhgl", mr.getWqwxhgl()); | ||
| 6375 | - resMap.put("bfwxhgl", mr.getBfwxhgl()); | ||
| 6376 | - resMap.put("pygl", mr.getPygl()); | ||
| 6377 | - resMap.put("ljgl", mr.getLjgl()); | ||
| 6378 | - resMap.put("zrwgl", mr.getZrwgl()); | ||
| 6379 | - resMap.put("other", mr.getOther()); | ||
| 6380 | - lMap.add(resMap); | ||
| 6381 | - sjyygl = Arith.add(sjyygl, mr.getSjyygl()); | ||
| 6382 | - sjksgl = Arith.add(sjksgl, mr.getSjksgl()); | ||
| 6383 | - zgl = Arith.add(zgl, mr.getZgl()); | ||
| 6384 | - sddfgl = Arith.add(sddfgl, mr.getSddfgl()); | ||
| 6385 | - zddfgl = Arith.add(zddfgl, mr.getZddfgl()); | ||
| 6386 | - wqwxhgl = Arith.add(wqwxhgl, mr.getWqwxhgl()); | ||
| 6387 | - bfwxhgl = Arith.add(bfwxhgl, mr.getBfwxhgl()); | ||
| 6388 | - pygl = Arith.add(pygl, mr.getPygl()); | ||
| 6389 | - ljgl = Arith.add(ljgl, mr.getLjgl()); | ||
| 6390 | - zrwgl = Arith.add(zrwgl, mr.getZrwgl()); | ||
| 6391 | - } | ||
| 6392 | - Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6393 | - resMap.put("xlName", "合计"); | ||
| 6394 | - resMap.put("sjyygl", sjyygl); | ||
| 6395 | - resMap.put("sjksgl", sjksgl); | ||
| 6396 | - resMap.put("zgl", zgl); | ||
| 6397 | - resMap.put("sddfgl", sddfgl); | ||
| 6398 | - resMap.put("zddfgl", zddfgl); | ||
| 6399 | - resMap.put("wqwxhgl", wqwxhgl); | ||
| 6400 | - resMap.put("bfwxhgl", bfwxhgl); | ||
| 6401 | - resMap.put("pygl", pygl); | ||
| 6402 | - resMap.put("ljgl", ljgl); | ||
| 6403 | - resMap.put("zrwgl", zrwgl); | ||
| 6404 | - resMap.put("other", null); | ||
| 6405 | - lMap.add(resMap); | ||
| 6406 | - return lMap; | ||
| 6407 | - } | ||
| 6408 | - | ||
| 6409 | - @Override | ||
| 6410 | - public List<Map<String, Object>> scheduleCorrectionReport(String gsdm, | ||
| 6411 | - String fgsdm, String line, String date, String date2) { | ||
| 6412 | - | ||
| 6413 | - String sql = "select * from calc_schedule where 1=1 "; | ||
| 6414 | - if (!line.equals(" ")) { | ||
| 6415 | - sql = sql + " and line_code='" + line + "' "; | ||
| 6416 | - } | ||
| 6417 | - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'"; | ||
| 6418 | - if (!gsdm.equals(" ")) { | ||
| 6419 | - sql = sql + " and company_id=" + gsdm; | ||
| 6420 | - } | ||
| 6421 | - if (!gsdm.equals(" ")) { | ||
| 6422 | - sql = sql + " and sub_company_id=" + fgsdm; | ||
| 6423 | - } | ||
| 6424 | - sql = sql + " order by line_code"; | ||
| 6425 | - List<ScheduleCorrectionReport> list = jdbcTemplate.query(sql, | ||
| 6426 | - new RowMapper<ScheduleCorrectionReport>() { | ||
| 6427 | - @Override | ||
| 6428 | - public ScheduleCorrectionReport mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 6429 | - ScheduleCorrectionReport sReport = new ScheduleCorrectionReport(); | ||
| 6430 | - sReport.setCompanyName(rs.getString("company_name")); | ||
| 6431 | - sReport.setSubCompanyName(rs.getString("sub_company_name")); | ||
| 6432 | - sReport.setLineName(rs.getString("line_name")); | ||
| 6433 | - sReport.setSjyybc(rs.getInt("sjyybc")); | ||
| 6434 | - sReport.setSjksbc(rs.getInt("sjksbc")); | ||
| 6435 | - sReport.setZbc(rs.getInt("zyybc")); | ||
| 6436 | - sReport.setZddfbc(rs.getInt("zddfbc")); | ||
| 6437 | - sReport.setSddfbc(rs.getInt("sddfbc")); | ||
| 6438 | - sReport.setWqwxhbc(rs.getInt("wqwxhbc")); | ||
| 6439 | - sReport.setBfwxhbc(rs.getInt("bfwxhbc")); | ||
| 6440 | - sReport.setPybc(rs.getInt("pybc")); | ||
| 6441 | - sReport.setLjbc(rs.getInt("ljbc")); | ||
| 6442 | - sReport.setZrwbc(rs.getInt("zrwbc")); | ||
| 6443 | - sReport.setOther(rs.getString("other")); | ||
| 6444 | - return sReport; | ||
| 6445 | - } | ||
| 6446 | - }); | ||
| 6447 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 6448 | - int sjyybc = 0; | ||
| 6449 | - int sjksbc = 0; | ||
| 6450 | - int zbc = 0; | ||
| 6451 | - int sddfbc = 0; | ||
| 6452 | - int zddfbc = 0; | ||
| 6453 | - int wqwxhbc = 0; | ||
| 6454 | - int bfwxhbc = 0; | ||
| 6455 | - int pybc = 0; | ||
| 6456 | - int ljbc = 0; | ||
| 6457 | - int zrwbc = 0; | ||
| 6458 | - for (ScheduleCorrectionReport sReport : list) { | ||
| 6459 | - Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6460 | - resMap.put("gsName", sReport.getCompanyName()); | ||
| 6461 | - resMap.put("fgsName", sReport.getSubCompanyName()); | ||
| 6462 | - resMap.put("xlName", sReport.getLineName()); | ||
| 6463 | - resMap.put("sjyybc", sReport.getSjyybc()); | ||
| 6464 | - resMap.put("sjksbc", sReport.getSjksbc()); | ||
| 6465 | - resMap.put("zbc", sReport.getZbc()); | ||
| 6466 | - resMap.put("sddfbc", sReport.getSddfbc()); | ||
| 6467 | - resMap.put("zddfbc", sReport.getZddfbc()); | ||
| 6468 | - resMap.put("wqwxhbc", sReport.getWqwxhbc()); | ||
| 6469 | - resMap.put("bfwxhbc", sReport.getBfwxhbc()); | ||
| 6470 | - resMap.put("pybc", sReport.getPybc()); | ||
| 6471 | - resMap.put("ljbc", sReport.getLjbc()); | ||
| 6472 | - resMap.put("zrwbc", sReport.getZrwbc()); | ||
| 6473 | - resMap.put("other", sReport.getOther()); | ||
| 6474 | - lMap.add(resMap); | ||
| 6475 | - sjyybc = sjyybc + sReport.getSjyybc(); | ||
| 6476 | - sjksbc = sjksbc + sReport.getSjksbc(); | ||
| 6477 | - zbc = zbc + sReport.getZbc(); | ||
| 6478 | - sddfbc = sddfbc + sReport.getSddfbc(); | ||
| 6479 | - zddfbc = zddfbc + sReport.getZddfbc(); | ||
| 6480 | - wqwxhbc = wqwxhbc + sReport.getWqwxhbc(); | ||
| 6481 | - bfwxhbc = bfwxhbc + sReport.getBfwxhbc(); | ||
| 6482 | - pybc = pybc + sReport.getPybc(); | ||
| 6483 | - ljbc = ljbc + sReport.getLjbc(); | ||
| 6484 | - zrwbc = zrwbc + sReport.getZrwbc(); | ||
| 6485 | - } | ||
| 6486 | - Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6487 | - resMap.put("xlName", "合计"); | ||
| 6488 | - resMap.put("sjyybc", sjyybc); | ||
| 6489 | - resMap.put("sjksbc", sjksbc); | ||
| 6490 | - resMap.put("zbc", zbc); | ||
| 6491 | - resMap.put("sddfbc", sddfbc); | ||
| 6492 | - resMap.put("zddfbc", zddfbc); | ||
| 6493 | - resMap.put("wqwxhbc", wqwxhbc); | ||
| 6494 | - resMap.put("bfwxhbc", bfwxhbc); | ||
| 6495 | - resMap.put("pybc", pybc); | ||
| 6496 | - resMap.put("ljbc", ljbc); | ||
| 6497 | - resMap.put("zrwbc", zrwbc); | ||
| 6498 | - resMap.put("other", null); | ||
| 6499 | - lMap.add(resMap); | ||
| 6500 | - return lMap; | ||
| 6501 | - } | ||
| 6502 | - | ||
| 6503 | - @Override | ||
| 6504 | - public Integer isCircleQdz(String clzbh, String sdr, String xlbm, String qdzCode) { | ||
| 6505 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 6506 | - String time =sdf.format(Long.parseLong(sdr)); | ||
| 6507 | - | ||
| 6508 | - Long num=scheduleRealInfoRepository.isCircleQdz(clzbh, time, xlbm, qdzCode); | ||
| 6509 | - Integer num2=num==0L?0:1; | ||
| 6510 | - return num2; | ||
| 6511 | - } | ||
| 6512 | - | ||
| 6513 | - @SuppressWarnings("unchecked") | ||
| 6514 | - private static Map<String, Object> request(String url) { | ||
| 6515 | - Map<String, Object> res = new HashMap<>(); | ||
| 6516 | - try { | ||
| 6517 | - StringBuilder sb = HttpClientUtils.post(url, null); | ||
| 6518 | - if (sb != null) { | ||
| 6519 | - Map<String, Object> response = new ObjectMapper().readValue(sb.toString(), Map.class); | ||
| 6520 | - if (!"报修成功".equals(response.get("msg"))) { | ||
| 6521 | - res.put("status", ResponseCode.ERROR); | ||
| 6522 | - res.putAll(response); | ||
| 6523 | - } | ||
| 6524 | - } else { | ||
| 6525 | - res.put("status", ResponseCode.ERROR); | ||
| 6526 | - res.put("msg", "调用上报接口异常"); | ||
| 6527 | - } | ||
| 6528 | - } catch (Exception e) { | ||
| 6529 | - // TODO Auto-generated catch block | ||
| 6530 | - logger.error("维修上报异常", e); | ||
| 6531 | - res.put("status", ResponseCode.ERROR); | ||
| 6532 | - res.put("msg", "调用上报接口异常"); | ||
| 6533 | - } | ||
| 6534 | - | ||
| 6535 | - return res; | ||
| 6536 | - } | ||
| 6537 | - | ||
| 6538 | - /** | ||
| 6539 | - ** 维修记录上报 | ||
| 6540 | - * @param param 参数信息 | ||
| 6541 | - * @param isActive 主/被动上报 | ||
| 6542 | - */ | ||
| 6543 | - @Override | ||
| 6544 | - @Transactional | ||
| 6545 | - public Map<String, Object> repairReport(Map<String, Object> param, boolean isActive) { | ||
| 6546 | - Map<String, Object> res = new HashMap<String, Object>(); | ||
| 6547 | - res.put("status", ResponseCode.SUCCESS); | ||
| 6548 | - // 获取实际排班信息 | ||
| 6549 | - Long id = Long.parseLong((String)param.get("id")); | ||
| 6550 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 6551 | - | ||
| 6552 | - if (null == sch) { | ||
| 6553 | - res.put("status", ResponseCode.ERROR); | ||
| 6554 | - res.put("msg", "不存在的班次!"); | ||
| 6555 | - | ||
| 6556 | - return res; | ||
| 6557 | - } | ||
| 6558 | - | ||
| 6559 | - int reportState = -1; | ||
| 6560 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 6561 | - String reportUser = user.getUserName(), reportName = user.getName(), incode = (String)param.get("clZbh"), reportTypes = (String)param.get("reportTypes"), repairTypes = reportType2RepairType(reportTypes); | ||
| 6562 | - // 分公司保存格式 分公司编码_公司编码 | ||
| 6563 | - String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode); | ||
| 6564 | - String[] arr = val.split("_"); | ||
| 6565 | - StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpReport(arr[1])); | ||
| 6566 | - url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]); | ||
| 6567 | - | ||
| 6568 | - int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0); | ||
| 6569 | - if (count > 0) return res; | ||
| 6570 | - RepairReport lrr = dayOfSchedule.getLastestRepairReport(incode); | ||
| 6571 | - // 非主动上报并且无上报记录或上次已上报 则不用上报 | ||
| 6572 | - if (!isActive && (lrr == null || lrr.getReportState() != 0)) { | ||
| 6573 | - reportState = 0; | ||
| 6574 | - } else { | ||
| 6575 | - res = request(url.toString()); | ||
| 6576 | - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1; | ||
| 6577 | - } | ||
| 6578 | - // 持久化此次上报记录 | ||
| 6579 | - RepairReport rr = new RepairReport(); | ||
| 6580 | - rr.setLineId(sch.getXlBm()); | ||
| 6581 | - rr.setLineName(sch.getXlName()); | ||
| 6582 | - rr.setReportUser(reportUser); | ||
| 6583 | - rr.setReportName(reportName); | ||
| 6584 | - rr.setSchId(id); | ||
| 6585 | - rr.setIncode(incode); | ||
| 6586 | - rr.setDepartureTime(sch.getFcsj()); | ||
| 6587 | - rr.setRepairType(repairTypes); | ||
| 6588 | - rr.setReportType(reportTypes); | ||
| 6589 | - rr.setReportDate(new Date()); | ||
| 6590 | - rr.setReportState(reportState); | ||
| 6591 | - rr.setReportMode(isActive ? 1 : 0); | ||
| 6592 | - rr = repairReportRepository.save(rr); | ||
| 6593 | - dayOfSchedule.setLastestRepairReport(rr); | ||
| 6594 | - // 如果上报失败,放到重传队列 | ||
| 6595 | - if (rr.getReportState() == -1) queue.add(rr); | ||
| 6596 | - | ||
| 6597 | - return res; | ||
| 6598 | - } | ||
| 6599 | - | ||
| 6600 | - private void repairReport(RepairReport rr) { | ||
| 6601 | - int reportState = -1; | ||
| 6602 | - // 分公司保存格式 分公司编码_公司编码 | ||
| 6603 | - String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode()); | ||
| 6604 | - String[] arr = val.split("_"); | ||
| 6605 | - StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpReport(arr[1])); | ||
| 6606 | - url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]); | ||
| 6607 | - | ||
| 6608 | - Map<String, Object> res = request(url.toString()); | ||
| 6609 | - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1; | ||
| 6610 | - if (reportState == 1) { | ||
| 6611 | - rr.setReportState(1); | ||
| 6612 | - repairReportRepository.save(rr); | ||
| 6613 | - } | ||
| 6614 | - } | ||
| 6615 | - | ||
| 6616 | - /** | ||
| 6617 | - ** 业务类型转报修类型 | ||
| 6618 | - */ | ||
| 6619 | - private String reportType2RepairType(String reportType) { | ||
| 6620 | - String[] reportTypes = reportType.split(";"); | ||
| 6621 | - List<String> repairTypes = new ArrayList<>(); | ||
| 6622 | - for (String rt : reportTypes) { | ||
| 6623 | - repairTypes.add(report2repair.get(rt)); | ||
| 6624 | - } | ||
| 6625 | - | ||
| 6626 | - return StringUtils.join(repairTypes, ";"); | ||
| 6627 | - } | ||
| 6628 | - | ||
| 6629 | - @Override | ||
| 6630 | - public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) { | ||
| 6631 | - List<RepairReport> result = new ArrayList<RepairReport>(); | ||
| 6632 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 6633 | - | ||
| 6634 | - Date start = null, end = null; | ||
| 6635 | - if (date.length() > 0) { | ||
| 6636 | - try { | ||
| 6637 | - start = sdf.parse(date + " 00:00:00"); | ||
| 6638 | - end = sdf.parse(date + " 23:59:59"); | ||
| 6639 | - } catch (ParseException e) { | ||
| 6640 | - // TODO Auto-generated catch block | ||
| 6641 | - e.printStackTrace(); | ||
| 6642 | - } | ||
| 6643 | - | ||
| 6644 | - } | ||
| 6645 | - | ||
| 6646 | - result = repairReportRepository.repairReportList(lineId, start, end, incode); | ||
| 6647 | - Map<String, Object> dMap=new HashMap<>(); | ||
| 6648 | - dMap.put("dGroup_eq", "repairtype"); | ||
| 6649 | - Map<String, String> code2name = new HashMap<String, String>(); | ||
| 6650 | - for (Dictionary dic : dictionaryService.list(dMap)) { | ||
| 6651 | - code2name.put(dic.getdCode(), dic.getdName()); | ||
| 6652 | - } | ||
| 6653 | - for (RepairReport rr : result) { | ||
| 6654 | - String reportType = rr.getReportType(); | ||
| 6655 | - String[] types = reportType.split(";"); | ||
| 6656 | - StringBuilder sb = new StringBuilder(); | ||
| 6657 | - | ||
| 6658 | - for (String t : types) { | ||
| 6659 | - sb.append(code2name.get(t)).append(";"); | ||
| 6660 | - } | ||
| 6661 | - | ||
| 6662 | - rr.setRepairType(sb.toString()); | ||
| 6663 | - rr.setReportDateStr(sdf.format(rr.getReportDate())); | ||
| 6664 | - switch (rr.getReportState()) { | ||
| 6665 | - case 0: | ||
| 6666 | - rr.setReportStateStr("不报"); | ||
| 6667 | - break; | ||
| 6668 | - case 1: | ||
| 6669 | - rr.setReportStateStr("上报成功"); | ||
| 6670 | - break; | ||
| 6671 | - case -1: | ||
| 6672 | - rr.setReportStateStr("上报失败"); | ||
| 6673 | - break; | ||
| 6674 | - default: | ||
| 6675 | - break; | ||
| 6676 | - } | ||
| 6677 | - } | ||
| 6678 | - | ||
| 6679 | - if ("export".equals(type)) { | ||
| 6680 | - String lineName = BasicData.lineCode2NameMap.get(lineId); | ||
| 6681 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 6682 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 6683 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 6684 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 6685 | - ReportUtils ee = new ReportUtils(); | ||
| 6686 | - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | ||
| 6687 | - for (int i = 0; i < result.size(); i++) { | ||
| 6688 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 6689 | - RepairReport rr = result.get(i); | ||
| 6690 | - map.put("row", i + 1); | ||
| 6691 | - map.put("lineId", rr.getLineName()); | ||
| 6692 | - map.put("incode", rr.getIncode()); | ||
| 6693 | - map.put("departureTime", rr.getDepartureTime()); | ||
| 6694 | - map.put("reportUser", rr.getReportUser()); | ||
| 6695 | - map.put("reportDateStr", rr.getReportDate()); | ||
| 6696 | - map.put("repairType", rr.getRepairType()); | ||
| 6697 | - map.put("reportStateStr", rr.getReportStateStr()); | ||
| 6698 | - newList.add(map); | ||
| 6699 | - } | ||
| 6700 | - try { | ||
| 6701 | - listI.add(newList.iterator()); | ||
| 6702 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 6703 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls", | ||
| 6704 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | ||
| 6705 | - + "-" + lineName + "-维修上报记录.xls"); | ||
| 6706 | - } catch (Exception e) { | ||
| 6707 | - // TODO: handle exception | ||
| 6708 | - e.printStackTrace(); | ||
| 6709 | - } | ||
| 6710 | - } | ||
| 6711 | - | ||
| 6712 | - return result; | ||
| 6713 | - } | ||
| 6714 | - | ||
| 6715 | - @Override | ||
| 6716 | - public Map<String, String> getLevelsByLines(List<String> lines) { | ||
| 6717 | - Map<String, String> result = new HashMap<String, String>(), currSchDate = dayOfSchedule.getCurrSchDate(); | ||
| 6718 | - for (String line : lines) { | ||
| 6719 | - String level = BasicData.lineDate2Level.get(line + "_" + currSchDate.get(line)); | ||
| 6720 | - result.put(line, level == null ? "" : level); | ||
| 6721 | - } | ||
| 6722 | - | ||
| 6723 | - return result; | ||
| 6724 | - } | ||
| 6725 | - | ||
| 6726 | - | ||
| 6727 | - @Override | ||
| 6728 | - public void destroy() throws Exception { | ||
| 6729 | - // TODO Auto-generated method stub | ||
| 6730 | - exec.shutdown(); | ||
| 6731 | - } | ||
| 6732 | - | ||
| 6733 | - | ||
| 6734 | - @Override | ||
| 6735 | - public void afterPropertiesSet() throws Exception { | ||
| 6736 | - // TODO Auto-generated method stub | ||
| 6737 | - // 维修上报重发调度 | ||
| 6738 | - exec.scheduleAtFixedRate(new Runnable() { | ||
| 6739 | - | ||
| 6740 | - @Override | ||
| 6741 | - public void run() { | ||
| 6742 | - // TODO Auto-generated method stub | ||
| 6743 | - try { | ||
| 6744 | - Iterator<RepairReport> it = queue.iterator(); | ||
| 6745 | - while (it.hasNext()) { | ||
| 6746 | - RepairReport rr = it.next(); | ||
| 6747 | - repairReport(rr); | ||
| 6748 | - if (rr.getReportState() == 1 || System.currentTimeMillis() - rr.getReportDate().getTime() > 86400000) queue.remove(rr); | ||
| 6749 | - } | ||
| 6750 | - } catch (Exception e) { | ||
| 6751 | - logger.error("维修上报重发错误", e); | ||
| 6752 | - } | ||
| 6753 | - } | ||
| 6754 | - }, 30, 30, TimeUnit.MINUTES); | ||
| 6755 | - | ||
| 6756 | - //// --- | ||
| 6757 | - exec.scheduleWithFixedDelay(new Runnable() { | ||
| 6758 | - @Override | ||
| 6759 | - public void run() { | ||
| 6760 | - Map<String, Object> res = new HashMap<>(); | ||
| 6761 | - InputStream in = null; | ||
| 6762 | - String url ="http://211.95.61.66:9008/modules/tSafedrivingCs/DSMBHforCLBH"; | ||
| 6763 | - | ||
| 6764 | - try { | ||
| 6765 | - HttpURLConnection con = (HttpURLConnection)new URL(url.toString()).openConnection(); | ||
| 6766 | - con.setDoInput(true); | ||
| 6767 | - con.setRequestMethod("POST"); | ||
| 6768 | - con.setConnectTimeout(5000); | ||
| 6769 | - con.setReadTimeout(5000); | ||
| 6770 | - con.setRequestProperty("keep-alive", "true"); | ||
| 6771 | - con.setRequestProperty("accept", "*/*"); | ||
| 6772 | - con.setRequestProperty("content-type", "application/x-www-form-urlencoded"); | ||
| 6773 | - con.connect(); | ||
| 6774 | - | ||
| 6775 | - if (con.getResponseCode() == 200) { | ||
| 6776 | - in = con.getInputStream(); | ||
| 6777 | - ByteArrayOutputStream bout = new ByteArrayOutputStream(); | ||
| 6778 | - IOUtils.copy(in, bout); | ||
| 6779 | - DIRMAP = new ObjectMapper().readValue(bout.toByteArray(), Map.class); | ||
| 6780 | - } | ||
| 6781 | - logger.info("IP打电话接口查询完成"); | ||
| 6782 | - } catch (MalformedURLException e) { | ||
| 6783 | - // TODO Auto-generated catch block | ||
| 6784 | - e.printStackTrace(); | ||
| 6785 | - logger.error("IP打电话接口出错",e); | ||
| 6786 | - } catch (IOException e) { | ||
| 6787 | - // TODO Auto-generated catch block | ||
| 6788 | - e.printStackTrace(); | ||
| 6789 | - } | ||
| 6790 | - | ||
| 6791 | - } | ||
| 6792 | - }, 0, 10, TimeUnit.MINUTES); | ||
| 6793 | - } | ||
| 6794 | -} | ||
| 6795 | - | ||
| 6796 | -class AccountMap implements Comparator<Map<String, Object>> { | ||
| 6797 | - @Override | ||
| 6798 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 6799 | - // TODO Auto-generated method stub | ||
| 6800 | - return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString()); | ||
| 6801 | - } | ||
| 6802 | -} | ||
| 6803 | - | ||
| 6804 | -class AccountMap2 implements Comparator<Map<String, Object>> { | ||
| 6805 | - @Override | ||
| 6806 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 6807 | - // TODO Auto-generated method stub | ||
| 6808 | - return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString()); | ||
| 6809 | - } | ||
| 6810 | -} | ||
| 6811 | - | ||
| 6812 | -class AccountXlbm implements Comparator<Map<String, Object>> { | ||
| 6813 | - @Override | ||
| 6814 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 6815 | - // TODO Auto-generated method stub | ||
| 6816 | -// PinyinHelper.convertToPinyinString(ppy.getName(), | ||
| 6817 | -// "" , PinyinFormat.WITHOUT_TONE) | ||
| 6818 | - return o1.get("xlNamePy").toString().compareTo( | ||
| 6819 | - o2.get("xlNamePy").toString()); | ||
| 6820 | - } | ||
| 6821 | -} | ||
| 6822 | - | ||
| 6823 | -class compareLpFcsjType implements Comparator<ScheduleRealInfo> { | ||
| 6824 | - @Override | ||
| 6825 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 6826 | - // TODO Auto-generated method stub | ||
| 6827 | - return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark()); | ||
| 6828 | - } | ||
| 6829 | - | ||
| 6830 | -} | ||
| 6831 | - | ||
| 6832 | -class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> { | ||
| 6833 | - @Override | ||
| 6834 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 6835 | - // TODO Auto-generated method stub | ||
| 6836 | - return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName()); | ||
| 6837 | - } | ||
| 6838 | - | ||
| 6839 | -} | ||
| 6840 | -class compareFcsjType implements Comparator<ScheduleRealInfo> { | ||
| 6841 | - @Override | ||
| 6842 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 6843 | - // TODO Auto-generated method stub | ||
| 6844 | - return (o1.getFcsjT() + o1.getRemark()).compareTo(o2.getFcsjT() + o2.getRemark()); | ||
| 6845 | - } | ||
| 6846 | - | ||
| 6847 | -} | 1 | +package com.bsth.service.realcontrol.impl; |
| 2 | + | ||
| 3 | +import java.io.*; | ||
| 4 | +import java.lang.reflect.Field; | ||
| 5 | +import java.math.BigDecimal; | ||
| 6 | +import java.net.HttpURLConnection; | ||
| 7 | +import java.net.MalformedURLException; | ||
| 8 | +import java.net.URL; | ||
| 9 | +import java.sql.ResultSet; | ||
| 10 | +import java.sql.SQLException; | ||
| 11 | +import java.text.DecimalFormat; | ||
| 12 | +import java.text.ParseException; | ||
| 13 | +import java.text.SimpleDateFormat; | ||
| 14 | +import java.util.ArrayList; | ||
| 15 | +import java.util.Calendar; | ||
| 16 | +import java.util.Collection; | ||
| 17 | +import java.util.Collections; | ||
| 18 | +import java.util.Comparator; | ||
| 19 | +import java.util.Date; | ||
| 20 | +import java.util.GregorianCalendar; | ||
| 21 | +import java.util.HashMap; | ||
| 22 | +import java.util.HashSet; | ||
| 23 | +import java.util.Iterator; | ||
| 24 | +import java.util.List; | ||
| 25 | +import java.util.Map; | ||
| 26 | +import java.util.Queue; | ||
| 27 | +import java.util.Set; | ||
| 28 | +import java.util.concurrent.*; | ||
| 29 | +import java.util.regex.Pattern; | ||
| 30 | + | ||
| 31 | +import com.bsth.entity.*; | ||
| 32 | +import com.bsth.util.*; | ||
| 33 | +import com.bsth.data.SystemParamCache; | ||
| 34 | +import org.apache.commons.io.IOUtils; | ||
| 35 | +import org.apache.commons.lang3.StringEscapeUtils; | ||
| 36 | +import org.apache.commons.lang3.StringUtils; | ||
| 37 | +import org.joda.time.DateTime; | ||
| 38 | +import org.joda.time.format.DateTimeFormat; | ||
| 39 | +import org.joda.time.format.DateTimeFormatter; | ||
| 40 | +import org.slf4j.Logger; | ||
| 41 | +import org.slf4j.LoggerFactory; | ||
| 42 | +import org.springframework.beans.factory.DisposableBean; | ||
| 43 | +import org.springframework.beans.factory.InitializingBean; | ||
| 44 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 45 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 46 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 47 | +import org.springframework.jdbc.core.RowMapper; | ||
| 48 | +import org.springframework.stereotype.Service; | ||
| 49 | +import org.springframework.transaction.annotation.Transactional; | ||
| 50 | + | ||
| 51 | +import com.alibaba.fastjson.JSON; | ||
| 52 | +import com.alibaba.fastjson.JSONArray; | ||
| 53 | +import com.alibaba.fastjson.JSONObject; | ||
| 54 | +import com.bsth.common.Constants; | ||
| 55 | +import com.bsth.common.ResponseCode; | ||
| 56 | +import com.bsth.controller.realcontrol.dto.ChangePersonCar; | ||
| 57 | +import com.bsth.controller.realcontrol.dto.DfsjChange; | ||
| 58 | +import com.bsth.controller.realcontrol.dto.LpData; | ||
| 59 | +import com.bsth.data.BasicData; | ||
| 60 | +import com.bsth.data.LineConfigData; | ||
| 61 | +import com.bsth.data.Station2ParkBuffer; | ||
| 62 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 63 | +import com.bsth.data.schedule.SchAttrCalculator; | ||
| 64 | +import com.bsth.data.schedule.ScheduleComparator; | ||
| 65 | +import com.bsth.data.schedule.edit_logs.FormLogger; | ||
| 66 | +import com.bsth.data.schedule.edit_logs.ScheduleModifyLogger; | ||
| 67 | +import com.bsth.data.schedule.edit_logs.loggers.AfterwardsLogger; | ||
| 68 | +import com.bsth.data.schedule.edit_logs.loggers.FcxxwtLogger; | ||
| 69 | +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; | ||
| 70 | +import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | ||
| 71 | +import com.bsth.data.utils.CustomStringUtils; | ||
| 72 | +import com.bsth.entity.calc.CalcInterval; | ||
| 73 | +import com.bsth.entity.calc.CalcStatistics; | ||
| 74 | +import com.bsth.entity.oil.Dlb; | ||
| 75 | +import com.bsth.entity.oil.Qlb; | ||
| 76 | +import com.bsth.entity.oil.Ylb; | ||
| 77 | +import com.bsth.entity.oil.Ylxxb; | ||
| 78 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | ||
| 79 | +import com.bsth.entity.realcontrol.LineConfig; | ||
| 80 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 81 | +import com.bsth.entity.realcontrol.SvgAttribute; | ||
| 82 | +import com.bsth.entity.report.MileageReport; | ||
| 83 | +import com.bsth.entity.report.RepairReport; | ||
| 84 | +import com.bsth.entity.report.ScheduleCorrectionReport; | ||
| 85 | +import com.bsth.entity.schedule.CarConfigInfo; | ||
| 86 | +import com.bsth.entity.schedule.EmployeeConfigInfo; | ||
| 87 | +import com.bsth.entity.schedule.GuideboardInfo; | ||
| 88 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 89 | +import com.bsth.entity.sys.Dictionary; | ||
| 90 | +import com.bsth.entity.sys.DutyEmployee; | ||
| 91 | +import com.bsth.entity.sys.SysUser; | ||
| 92 | +import com.bsth.repository.BusinessRepository; | ||
| 93 | +import com.bsth.repository.CarDeviceRepository; | ||
| 94 | +import com.bsth.repository.CarsRepository; | ||
| 95 | +import com.bsth.repository.LineRepository; | ||
| 96 | +import com.bsth.repository.RepairReportRepository; | ||
| 97 | +import com.bsth.repository.calc.CalcIntervalRepository; | ||
| 98 | +import com.bsth.repository.oil.DlbRepository; | ||
| 99 | +import com.bsth.repository.oil.QlbRepository; | ||
| 100 | +import com.bsth.repository.oil.YlbRepository; | ||
| 101 | +import com.bsth.repository.oil.YlxxbRepository; | ||
| 102 | +import com.bsth.repository.realcontrol.ChildTaskPlanRepository; | ||
| 103 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 104 | +import com.bsth.repository.realcontrol.SvgAttributeRepository; | ||
| 105 | +import com.bsth.repository.schedule.CarConfigInfoRepository; | ||
| 106 | +import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | ||
| 107 | +import com.bsth.repository.schedule.GuideboardInfoRepository; | ||
| 108 | +import com.bsth.security.util.SecurityUtils; | ||
| 109 | +import com.bsth.service.LineService; | ||
| 110 | +import com.bsth.service.SectionRouteService; | ||
| 111 | +import com.bsth.service.calc.CalcWaybillService; | ||
| 112 | +import com.bsth.service.directive.DirectiveService; | ||
| 113 | +import com.bsth.service.impl.BaseServiceImpl; | ||
| 114 | +import com.bsth.service.realcontrol.ScheduleRealInfoService; | ||
| 115 | +import com.bsth.service.report.CulateMileageService; | ||
| 116 | +import com.bsth.service.report.ReportService; | ||
| 117 | +import com.bsth.service.schedule.SchedulePlanInfoService; | ||
| 118 | +import com.bsth.service.sys.DictionaryService; | ||
| 119 | +import com.bsth.service.sys.DutyEmployeeService; | ||
| 120 | +import com.bsth.util.Arith; | ||
| 121 | +import com.bsth.util.ComparableChild; | ||
| 122 | +import com.bsth.util.ComparableLp; | ||
| 123 | +import com.bsth.util.ComparableReal; | ||
| 124 | +import com.bsth.util.DateUtils; | ||
| 125 | +import com.bsth.util.ReportRelatedUtils; | ||
| 126 | +import com.bsth.util.ReportUtils; | ||
| 127 | +import com.bsth.util.TimeUtils; | ||
| 128 | +import com.bsth.util.CoordinateConverter; | ||
| 129 | +import com.bsth.websocket.handler.SendUtils; | ||
| 130 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 131 | +import com.github.stuxuhai.jpinyin.PinyinException; | ||
| 132 | +import com.github.stuxuhai.jpinyin.PinyinFormat; | ||
| 133 | +import com.github.stuxuhai.jpinyin.PinyinHelper; | ||
| 134 | +import com.google.common.base.Splitter; | ||
| 135 | +import com.google.common.collect.Lists; | ||
| 136 | + | ||
| 137 | +@Service | ||
| 138 | +public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> | ||
| 139 | + implements ScheduleRealInfoService, InitializingBean, DisposableBean { | ||
| 140 | + @Autowired | ||
| 141 | + JdbcTemplate jdbcTemplate; | ||
| 142 | + @Autowired | ||
| 143 | + ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 144 | + | ||
| 145 | + @Autowired | ||
| 146 | + EmployeeConfigInfoRepository employeeConfigInfoRepository; | ||
| 147 | + | ||
| 148 | + @Autowired | ||
| 149 | + CarConfigInfoRepository carConfigInfoRepository; | ||
| 150 | + | ||
| 151 | + @Autowired | ||
| 152 | + SectionRouteService sectionRouteService; | ||
| 153 | + | ||
| 154 | + @Autowired | ||
| 155 | + CulateMileageService culateMieageService; | ||
| 156 | + | ||
| 157 | + @Autowired | ||
| 158 | + DictionaryService dictionaryService; | ||
| 159 | + | ||
| 160 | + @Autowired | ||
| 161 | + CalcWaybillService calcWaybillService; | ||
| 162 | + | ||
| 163 | + @Autowired | ||
| 164 | + CalcIntervalRepository calcIntervalRepository; | ||
| 165 | + | ||
| 166 | + @Autowired | ||
| 167 | + LineRepository lineRepository; | ||
| 168 | + @Autowired | ||
| 169 | + LineService lineService; | ||
| 170 | + @Autowired | ||
| 171 | + GuideboardInfoRepository guideboardInfoRepository; | ||
| 172 | + | ||
| 173 | + @Autowired | ||
| 174 | + ChildTaskPlanRepository cTaskPlanRepository; | ||
| 175 | + | ||
| 176 | + @Autowired | ||
| 177 | + SendUtils sendUtils; | ||
| 178 | + | ||
| 179 | + @Autowired | ||
| 180 | + DayOfSchedule dayOfSchedule; | ||
| 181 | + | ||
| 182 | + @Autowired | ||
| 183 | + SchAttrCalculator schAttrCalculator; | ||
| 184 | + | ||
| 185 | + @Autowired | ||
| 186 | + LineConfigData lineConfigData; | ||
| 187 | + | ||
| 188 | + @Autowired | ||
| 189 | + DutyEmployeeService dutyEmployeeService; | ||
| 190 | + | ||
| 191 | + @Autowired | ||
| 192 | + YlxxbRepository ylxxbRepository; | ||
| 193 | + | ||
| 194 | + @Autowired | ||
| 195 | + YlbRepository ylbRepository; | ||
| 196 | + | ||
| 197 | + @Autowired | ||
| 198 | + DlbRepository dlbRepository; | ||
| 199 | + | ||
| 200 | + @Autowired | ||
| 201 | + QlbRepository qlbRepository; | ||
| 202 | + | ||
| 203 | + @Autowired | ||
| 204 | + ReportService reposrService; | ||
| 205 | + | ||
| 206 | + @Autowired | ||
| 207 | + CulateMileageService culateService; | ||
| 208 | + | ||
| 209 | + @Autowired | ||
| 210 | + FormLogger schModifyLog; | ||
| 211 | + | ||
| 212 | + @Autowired | ||
| 213 | + DirectiveService directiveService; | ||
| 214 | + | ||
| 215 | + @Autowired | ||
| 216 | + CarDeviceRepository carDeviceRepository; | ||
| 217 | + | ||
| 218 | + @Autowired | ||
| 219 | + CarsRepository carsRepository; | ||
| 220 | + | ||
| 221 | + @Autowired | ||
| 222 | + BusinessRepository businessRepository; | ||
| 223 | + | ||
| 224 | + @Autowired | ||
| 225 | + RepairReportRepository repairReportRepository; | ||
| 226 | + | ||
| 227 | + private final static Logger logger = LoggerFactory.getLogger(ScheduleRealInfoServiceImpl.class); | ||
| 228 | + | ||
| 229 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 230 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 231 | + | ||
| 232 | + public static Map<String,String> DIRMAP = new ConcurrentHashMap<>(); // dvr电话 | ||
| 233 | + private Queue<RepairReport> queue = new ConcurrentLinkedQueue<>(); | ||
| 234 | + | ||
| 235 | + private ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { | ||
| 236 | + | ||
| 237 | + @Override | ||
| 238 | + public Thread newThread(Runnable r) { | ||
| 239 | + // TODO Auto-generated method stub | ||
| 240 | + Thread t = new Thread(r); | ||
| 241 | + t.setName("RepairReportReissuer"); | ||
| 242 | + | ||
| 243 | + return t; | ||
| 244 | + } | ||
| 245 | + }); | ||
| 246 | + | ||
| 247 | + | ||
| 248 | + | ||
| 249 | + private static Map<String, String> report2repair = new HashMap<String, String>(); | ||
| 250 | + | ||
| 251 | + static { | ||
| 252 | + report2repair.put("9101", "9109"); | ||
| 253 | + report2repair.put("9102", "9102"); | ||
| 254 | + report2repair.put("9103", "9103"); | ||
| 255 | + report2repair.put("9104", "9104"); | ||
| 256 | + report2repair.put("9109", "9109"); | ||
| 257 | + report2repair.put("9201", "9201"); | ||
| 258 | + report2repair.put("9202", "9202"); | ||
| 259 | + report2repair.put("9203", "9203"); | ||
| 260 | + report2repair.put("9204", "9204"); | ||
| 261 | + report2repair.put("9209", "9209"); | ||
| 262 | + report2repair.put("9301", "9301"); | ||
| 263 | + report2repair.put("9302", "9302"); | ||
| 264 | + report2repair.put("9303", "9303"); | ||
| 265 | + report2repair.put("9304", "9304"); | ||
| 266 | + report2repair.put("9305", "9305"); | ||
| 267 | + report2repair.put("9306", "9306"); | ||
| 268 | + report2repair.put("9309", "9309"); | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + | ||
| 272 | + /** | ||
| 273 | + * 校验人车 和 班次的公司和分公司归属 | ||
| 274 | + * | ||
| 275 | + * @param schId | ||
| 276 | + * @param jGh | ||
| 277 | + * @param sGh | ||
| 278 | + * @param nbbm | ||
| 279 | + * @return -2 跨营运公司,校验不过 | ||
| 280 | + * -1 跨分公司,二次确认 | ||
| 281 | + * 1 校验通过 | ||
| 282 | + */ | ||
| 283 | + @Override | ||
| 284 | + public Map<String, Object> checkPCFgsAscription(Long schId, String jGh, String sGh, String nbbm) { | ||
| 285 | + Map<String, Object> rs = new HashMap<>(); | ||
| 286 | + try { | ||
| 287 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 288 | + rs.put("checkStatus", -2); | ||
| 289 | + | ||
| 290 | + String msg = null; | ||
| 291 | + ScheduleRealInfo sch = dayOfSchedule.get(schId); | ||
| 292 | + String gsbm = sch.getGsBm(), fgsbm = sch.getFgsBm(); | ||
| 293 | + | ||
| 294 | + if (nbbm != null && !carExist(gsbm, nbbm)) { | ||
| 295 | + msg = sch.getGsName() + "没有自编号为" + "[" + nbbm + "]的车辆"; | ||
| 296 | + rs.put("msg", msg); | ||
| 297 | + return rs; | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + if (nbbm != null && !sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) { | ||
| 301 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + nbbm + "】的车辆"); | ||
| 302 | + return rs; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + if (nbbm != null && !(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) { | ||
| 306 | + | ||
| 307 | + String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm)); | ||
| 308 | + | ||
| 309 | + msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!"); | ||
| 310 | + rs.put("msg", msg); | ||
| 311 | + rs.put("checkStatus", -1); | ||
| 312 | + return rs; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + if(null != jGh && !"/".equals(StringUtils.trim(jGh))){ | ||
| 316 | + Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh); | ||
| 317 | + | ||
| 318 | + if (null == jsy) { | ||
| 319 | + msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员"; | ||
| 320 | + rs.put("msg", msg); | ||
| 321 | + return rs; | ||
| 322 | + } | ||
| 323 | + else if (!fgsbm.equals(jsy.getBrancheCompanyCode())) { | ||
| 324 | + //校验分公司 | ||
| 325 | + msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员"); | ||
| 326 | + rs.put("msg", msg); | ||
| 327 | + rs.put("checkStatus", -1); | ||
| 328 | + return rs; | ||
| 329 | + } | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + if (null != sGh && !"/".equals(StringUtils.trim(sGh))) { | ||
| 333 | + Personnel spy = BasicData.perMap.get(gsbm + "-" + sGh); | ||
| 334 | + if (null == spy) { | ||
| 335 | + msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员"; | ||
| 336 | + rs.put("msg", msg); | ||
| 337 | + return rs; | ||
| 338 | + } | ||
| 339 | + else if (!fgsbm.equals(spy.getBrancheCompanyCode())) { | ||
| 340 | + msg = ("【售票员】: " + sGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员"); | ||
| 341 | + rs.put("msg", msg); | ||
| 342 | + rs.put("checkStatus", -1); | ||
| 343 | + return rs; | ||
| 344 | + } | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + rs.put("checkStatus", 1); | ||
| 348 | + } catch (Exception e) { | ||
| 349 | + logger.error("", e); | ||
| 350 | + rs.put("status", ResponseCode.ERROR); | ||
| 351 | + } | ||
| 352 | + return rs; | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + | ||
| 356 | + /** | ||
| 357 | + * 车辆是否存在 | ||
| 358 | + * | ||
| 359 | + * @param gsbm 公司编码 | ||
| 360 | + * @param nbbm 车辆自编号 | ||
| 361 | + * @return | ||
| 362 | + */ | ||
| 363 | + private boolean carExist(String gsbm, String nbbm) { | ||
| 364 | + return BasicData.nbbm2CompanyCodeMap.containsKey(nbbm); | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + /** | ||
| 368 | + * 获取人员姓名 | ||
| 369 | + * | ||
| 370 | + * @param gsbm 公司编码 | ||
| 371 | + * @param gh 人员工号 | ||
| 372 | + * @return | ||
| 373 | + */ | ||
| 374 | + private String getPersonName(String gsbm, String gh) { | ||
| 375 | + return BasicData.allPerson.get(gsbm + '-' + gh); | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + @Override | ||
| 379 | + public Iterable<ScheduleRealInfo> list(Map<String, Object> map) { | ||
| 380 | + Iterator<ScheduleRealInfo> iterator = super.list(map).iterator(); | ||
| 381 | + Set<ScheduleRealInfo> set = new HashSet<>(100); | ||
| 382 | + | ||
| 383 | + DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | ||
| 384 | + //计算时间戳 | ||
| 385 | + ScheduleRealInfo sch; | ||
| 386 | + while (iterator.hasNext()) { | ||
| 387 | + sch = iterator.next(); | ||
| 388 | + //待发时间戳 | ||
| 389 | + sch.setDfsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getDfsj())); | ||
| 390 | + //实发时间戳 | ||
| 391 | + if (StringUtils.isNotEmpty(sch.getFcsjActual())) { | ||
| 392 | + sch.setFcsjActualTime(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsjActual())); | ||
| 393 | + } | ||
| 394 | + set.add(sch); | ||
| 395 | + } | ||
| 396 | + return set; | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + @Override | ||
| 400 | + public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) { | ||
| 401 | + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines)); | ||
| 402 | + | ||
| 403 | + /*Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | ||
| 404 | + | ||
| 405 | + for (String lineCode : lineList) { | ||
| 406 | + mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode)); | ||
| 407 | + }*/ | ||
| 408 | + return dayOfSchedule.findByLineCodes(lineList); | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + private final static long DAY_TIME = 1000 * 60 * 60 * 24L; | ||
| 412 | + | ||
| 413 | + private static int BUF_SIZE = 1024; | ||
| 414 | + | ||
| 415 | + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 416 | + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | ||
| 417 | + | ||
| 418 | + @Override | ||
| 419 | + public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType, String opType, String userId) { | ||
| 420 | + Map<String, Object> map = new HashMap<>(); | ||
| 421 | + try { | ||
| 422 | + | ||
| 423 | + ScheduleRealInfo schedule = dayOfSchedule.get(id); | ||
| 424 | + | ||
| 425 | + if (schedule.getStatus() > 0) { | ||
| 426 | + map.put("status", ResponseCode.SUCCESS); | ||
| 427 | + map.put("flag", "4008"); | ||
| 428 | + map.put("t", schedule); | ||
| 429 | + return map; | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + LineConfig config = lineConfigData.get(schedule.getXlBm()); | ||
| 433 | + //小于线路开始运营时间,则默认跨过24点 | ||
| 434 | + if (dfsj.compareTo(config.getStartOpt()) < 0) { | ||
| 435 | + schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME)); | ||
| 436 | + } else { | ||
| 437 | + schedule.setRealExecDate(schedule.getScheduleDateStr()); | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + //记录日志 | ||
| 441 | + ScheduleModifyLogger.dftz(schedule, opType, schedule.getDfsj(), dfsj, remarks, userId); | ||
| 442 | + | ||
| 443 | + schedule.setDfsjAll(dfsj); | ||
| 444 | + schedule.setDfAuto(false); | ||
| 445 | + if ("1".equals(opType)) | ||
| 446 | + schedule.setRemarks(remarks); | ||
| 447 | + | ||
| 448 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 449 | + ts.add(schedule); | ||
| 450 | + //调整终点时间和下一个班次的应到时间 | ||
| 451 | + //schedule.calcEndTime(); | ||
| 452 | + /*ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule); | ||
| 453 | + if (null != nextSch) { | ||
| 454 | + nextSch.setQdzArrDatejh(schedule.getZdsj()); | ||
| 455 | + ts.add(nextSch); | ||
| 456 | + }*/ | ||
| 457 | + | ||
| 458 | + //调整班次类型 | ||
| 459 | + if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) { | ||
| 460 | + if ((schedule.getBcType().equals("major") | ||
| 461 | + || schedule.getBcType().equals("venting")) | ||
| 462 | + && bcType.equals("normal")) { | ||
| 463 | + //清空备注 | ||
| 464 | + schedule.setRemarks(""); | ||
| 465 | + } | ||
| 466 | + schedule.setBcType(bcType); | ||
| 467 | + } | ||
| 468 | + | ||
| 469 | + //如果正在执行该班次 | ||
| 470 | + //ScheduleRealInfo exec = dayOfSchedule.executeCurr(schedule.getClZbh()); | ||
| 471 | + //if(exec != null && exec == schedule){ | ||
| 472 | + //重新计算正在执行班次 | ||
| 473 | + dayOfSchedule.reCalcExecPlan(schedule.getClZbh()); | ||
| 474 | + //} | ||
| 475 | + | ||
| 476 | + //重新计算是否误点 | ||
| 477 | + schedule.reCalcLate(); | ||
| 478 | + //取消应发未到标记,不再自动调整待发 | ||
| 479 | + //if(schedule.isLate2()){ | ||
| 480 | + // schedule.setLate2(false); | ||
| 481 | + //LateAdjustHandle.remove(schedule); | ||
| 482 | + //} | ||
| 483 | + | ||
| 484 | + try { | ||
| 485 | + if (!schedule.getDirectiveState().equals(-1) && schedule.getStatus() == 0) { | ||
| 486 | + //重新下发调度指令 | ||
| 487 | + directiveService.send60Dispatch(schedule.getId(), "待发@系统"); | ||
| 488 | + } | ||
| 489 | + } catch (Exception e) { | ||
| 490 | + logger.error("", e); | ||
| 491 | + } | ||
| 492 | + | ||
| 493 | + // 持久化到数据库 | ||
| 494 | + dayOfSchedule.save(schedule); | ||
| 495 | + | ||
| 496 | + map.put("status", ResponseCode.SUCCESS); | ||
| 497 | + map.put("ts", ts); | ||
| 498 | + } catch (Exception e) { | ||
| 499 | + logger.error("", e); | ||
| 500 | + map.put("status", ResponseCode.ERROR); | ||
| 501 | + } | ||
| 502 | + return map; | ||
| 503 | + } | ||
| 504 | + | ||
| 505 | + @Override | ||
| 506 | + public Map<String, Object> destroy(String idsStr, String remarks, String reason, String userId) { | ||
| 507 | + | ||
| 508 | + Map<String, Object> map = new HashMap<>(); | ||
| 509 | + List<ScheduleRealInfo> rsList = new ArrayList<>(); | ||
| 510 | + map.put("ts", rsList); | ||
| 511 | + try { | ||
| 512 | + List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr)); | ||
| 513 | + | ||
| 514 | + ScheduleRealInfo schedule = null; | ||
| 515 | + for (String id : idList) { | ||
| 516 | + schedule = dayOfSchedule.get(Long.parseLong(id)); | ||
| 517 | + if (schedule.isDestroy()) { | ||
| 518 | + map.put("status", ResponseCode.ERROR); | ||
| 519 | + map.put("msg", "不必要的重复烂班!"); | ||
| 520 | + return map; | ||
| 521 | + } | ||
| 522 | + //记录日志 | ||
| 523 | + ScheduleModifyLogger.jhlb(schedule, remarks, userId); | ||
| 524 | + | ||
| 525 | + schedule.setAdjustExps(reason); | ||
| 526 | + schedule.destroy(); | ||
| 527 | + schedule.addRemarks(remarks); | ||
| 528 | + | ||
| 529 | + dayOfSchedule.save(schedule); | ||
| 530 | + rsList.add(schedule); | ||
| 531 | + } | ||
| 532 | + | ||
| 533 | + //重新计算当前执行班次 | ||
| 534 | + dayOfSchedule.reCalcExecPlan(schedule.getClZbh()); | ||
| 535 | + | ||
| 536 | + map.put("status", ResponseCode.SUCCESS); | ||
| 537 | + } catch (Exception e) { | ||
| 538 | + logger.error("", e); | ||
| 539 | + map.put("status", ResponseCode.ERROR); | ||
| 540 | + } | ||
| 541 | + return map; | ||
| 542 | + } | ||
| 543 | + | ||
| 544 | + // 线路id获取驾驶员 | ||
| 545 | + @Override | ||
| 546 | + public List<Map<String, String>> findDriverByLine(String lineCode) { | ||
| 547 | + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode); | ||
| 548 | + | ||
| 549 | + List<Map<String, String>> rsList = new ArrayList<>(); | ||
| 550 | + Map<String, String> map = null; | ||
| 551 | + Personnel driver = null; | ||
| 552 | + String code = null; | ||
| 553 | + | ||
| 554 | + for (EmployeeConfigInfo employee : list) { | ||
| 555 | + driver = employee.getJsy(); | ||
| 556 | + if (driver != null) { | ||
| 557 | + map = new HashMap<>(); | ||
| 558 | + code = driver.getJobCode(); | ||
| 559 | + map.put("id", code + "/" + driver.getPersonnelName()); | ||
| 560 | + map.put("text", code + "/" + driver.getPersonnelName()); | ||
| 561 | + rsList.add(map); | ||
| 562 | + } | ||
| 563 | + } | ||
| 564 | + return rsList; | ||
| 565 | + } | ||
| 566 | + | ||
| 567 | + // 线路id获取售票员 | ||
| 568 | + @Override | ||
| 569 | + public List<Map<String, String>> findConductorByLine(String lineCode) { | ||
| 570 | + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode); | ||
| 571 | + | ||
| 572 | + List<Map<String, String>> rsList = new ArrayList<>(); | ||
| 573 | + Map<String, String> map = null; | ||
| 574 | + Personnel conductor = null; | ||
| 575 | + String code = null; | ||
| 576 | + | ||
| 577 | + for (EmployeeConfigInfo employee : list) { | ||
| 578 | + conductor = employee.getSpy(); | ||
| 579 | + if (conductor != null) { | ||
| 580 | + code = conductor.getJobCode(); | ||
| 581 | + map = new HashMap<>(); | ||
| 582 | + map.put("id", code + "/" + conductor.getPersonnelName()); | ||
| 583 | + map.put("text", code + "/" + conductor.getPersonnelName()); | ||
| 584 | + rsList.add(map); | ||
| 585 | + } | ||
| 586 | + } | ||
| 587 | + return rsList; | ||
| 588 | + } | ||
| 589 | + | ||
| 590 | + @Override | ||
| 591 | + public List<Map<String, String>> findCarByLine(String lineCode) { | ||
| 592 | + | ||
| 593 | + List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode); | ||
| 594 | + | ||
| 595 | + List<Map<String, String>> rsList = new ArrayList<>(); | ||
| 596 | + Map<String, String> map = null; | ||
| 597 | + Cars car = null; | ||
| 598 | + String code = null; | ||
| 599 | + | ||
| 600 | + for (CarConfigInfo cci : list) { | ||
| 601 | + car = cci.getCl(); | ||
| 602 | + if (car != null) { | ||
| 603 | + code = car.getInsideCode(); | ||
| 604 | + map = new HashMap<>(); | ||
| 605 | + map.put("id", code); | ||
| 606 | + map.put("text", code); | ||
| 607 | + rsList.add(map); | ||
| 608 | + } | ||
| 609 | + } | ||
| 610 | + return rsList; | ||
| 611 | + } | ||
| 612 | + | ||
| 613 | + /** | ||
| 614 | + * 添加到历史库 | ||
| 615 | + * | ||
| 616 | + * @param t | ||
| 617 | + * @return | ||
| 618 | + */ | ||
| 619 | + @Override | ||
| 620 | + public Map<String, Object> addToHistory(ScheduleRealInfo t) { | ||
| 621 | + Map<String, Object> rs = new HashMap<>(); | ||
| 622 | + try { | ||
| 623 | + // 检查调度日期 | ||
| 624 | + DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 625 | + long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(t.getScheduleDateStr()); | ||
| 626 | + String clZbh = t.getClZbh(), lpName = t.getLpName(); | ||
| 627 | + if (today < scheduleDate || today - scheduleDate > 86400000 * PrivilegeUtils.getHistoryEditDays()) { | ||
| 628 | + rs.put("status", ResponseCode.ERROR); | ||
| 629 | + rs.put("msg", "无效的调度日期"); | ||
| 630 | + return rs; | ||
| 631 | + } | ||
| 632 | + if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) { | ||
| 633 | + rs.put("status", ResponseCode.ERROR); | ||
| 634 | + rs.put("msg", "路牌信息缺失"); | ||
| 635 | + return rs; | ||
| 636 | + } | ||
| 637 | + if (!carExist(t.getGsBm(), clZbh)) { | ||
| 638 | + rs.put("msg", "车辆 " + clZbh + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | ||
| 639 | + rs.put("status", ResponseCode.ERROR); | ||
| 640 | + return rs; | ||
| 641 | + } | ||
| 642 | + | ||
| 643 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 644 | + //String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm()); | ||
| 645 | + | ||
| 646 | + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | ||
| 647 | + | ||
| 648 | + if (StringUtils.isEmpty(t.getjGh())) { | ||
| 649 | + rs.put("status", ResponseCode.ERROR); | ||
| 650 | + rs.put("msg", "驾驶员工号不能为空!"); | ||
| 651 | + return rs; | ||
| 652 | + } | ||
| 653 | + //截取驾驶员工号 | ||
| 654 | + if (t.getjGh().indexOf("-") != -1) { | ||
| 655 | + t.setjGh(t.getjGh().split("-")[1]); | ||
| 656 | + } | ||
| 657 | + //检查驾驶员工号 | ||
| 658 | + String jName = getPersonName(t.getGsBm(), t.getjGh()); | ||
| 659 | + if (StringUtils.isEmpty(jName)) { | ||
| 660 | + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员"); | ||
| 661 | + rs.put("status", ResponseCode.ERROR); | ||
| 662 | + return rs; | ||
| 663 | + } else if (StringUtils.isEmpty(t.getjName())) { | ||
| 664 | + t.setjName(jName);//补上驾驶员名称 | ||
| 665 | + } | ||
| 666 | + | ||
| 667 | + //有售票员 | ||
| 668 | + if (StringUtils.isNotEmpty(t.getsGh())) { | ||
| 669 | + String sName = getPersonName(t.getGsBm(), t.getsGh()); | ||
| 670 | + if (StringUtils.isEmpty(sName)) { | ||
| 671 | + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员"); | ||
| 672 | + rs.put("status", ResponseCode.ERROR); | ||
| 673 | + return rs; | ||
| 674 | + } else if (StringUtils.isEmpty(t.getsName())) { | ||
| 675 | + t.setsName(sName);//补上售票员名称 | ||
| 676 | + } | ||
| 677 | + } else { | ||
| 678 | + t.setsGh(""); | ||
| 679 | + t.setsName(""); | ||
| 680 | + } | ||
| 681 | + | ||
| 682 | + //公司 和 分公司名称 | ||
| 683 | + t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm())); | ||
| 684 | + t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getFgsBm()+ "_" + t.getGsBm() )); | ||
| 685 | + | ||
| 686 | + //t.setScheduleDateStr(schDate); | ||
| 687 | + t.setScheduleDate(sdfyyyyMMdd.parse(t.getScheduleDateStr())); | ||
| 688 | + t.setRealExecDate(t.getScheduleDateStr()); | ||
| 689 | + t.setCreateBy(user); | ||
| 690 | + t.setSflj(true); | ||
| 691 | + t.setLate(false); | ||
| 692 | + t.setDfsj(t.getFcsj()); | ||
| 693 | + t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime()); | ||
| 694 | + t.setJhlcOrig(t.getJhlc()); | ||
| 695 | + | ||
| 696 | + //班次历时 | ||
| 697 | + t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60); | ||
| 698 | + | ||
| 699 | + //起终点名称 | ||
| 700 | + String prefix = t.getXlBm() + "_" + t.getXlDir() + "_"; | ||
| 701 | + t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix)); | ||
| 702 | + t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix)); | ||
| 703 | + | ||
| 704 | + //计算班次实际执行时间 | ||
| 705 | + schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t); | ||
| 706 | + //处理计达跨24点 | ||
| 707 | + LineConfig conf = lineConfigData.get(t.getXlBm()); | ||
| 708 | + if (t.getZdsj().compareTo(conf.getStartOpt()) < 0) { | ||
| 709 | + t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime() + (1000 * 60 * 60 * 24)); | ||
| 710 | + } | ||
| 711 | + if (t.getZdsjT() < t.getFcsjT()) { | ||
| 712 | + rs.put("status", ResponseCode.ERROR); | ||
| 713 | + rs.put("msg", "起终点时间异常!"); | ||
| 714 | + return rs; | ||
| 715 | + } | ||
| 716 | + | ||
| 717 | + t.setId(dayOfSchedule.getId()); | ||
| 718 | + //实时入库 | ||
| 719 | + rs = super.save(t); | ||
| 720 | + } catch (Exception e) { | ||
| 721 | + logger.error("", e); | ||
| 722 | + rs.put("status", ResponseCode.ERROR); | ||
| 723 | + } | ||
| 724 | + return rs; | ||
| 725 | + } | ||
| 726 | + | ||
| 727 | + | ||
| 728 | + /** | ||
| 729 | + * 临加班次 | ||
| 730 | + */ | ||
| 731 | + @Override | ||
| 732 | + public Map<String, Object> save(ScheduleRealInfo sch) { | ||
| 733 | + Map<String, Object> rs = new HashMap<>(); | ||
| 734 | + try { | ||
| 735 | + String clZbh = sch.getClZbh(), lpName = sch.getLpName(); | ||
| 736 | + if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) { | ||
| 737 | + rs.put("status", ResponseCode.ERROR); | ||
| 738 | + rs.put("msg", "路牌信息缺失"); | ||
| 739 | + return rs; | ||
| 740 | + } | ||
| 741 | + if (StringUtils.isNotEmpty(clZbh)) { | ||
| 742 | + //检测 | ||
| 743 | + if (!carExist(sch.getGsBm(), clZbh)) { | ||
| 744 | + rs.put("status", ResponseCode.ERROR); | ||
| 745 | + rs.put("msg", "车辆 " + clZbh + " 不存在!"); | ||
| 746 | + return rs; | ||
| 747 | + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) { | ||
| 748 | + rs.put("status", ResponseCode.ERROR); | ||
| 749 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆"); | ||
| 750 | + return rs; | ||
| 751 | + } | ||
| 752 | + } | ||
| 753 | + | ||
| 754 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 755 | + String schDate = DayOfSchedule.currSchDateMap.get(sch.getXlBm()); | ||
| 756 | + | ||
| 757 | + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | ||
| 758 | + | ||
| 759 | + if (StringUtils.isEmpty(sch.getjGh())) { | ||
| 760 | + rs.put("status", ResponseCode.ERROR); | ||
| 761 | + rs.put("msg", "驾驶员工号不能为空!"); | ||
| 762 | + return rs; | ||
| 763 | + } | ||
| 764 | + //截取驾驶员工号 | ||
| 765 | + if (sch.getjGh().indexOf("-") != -1) { | ||
| 766 | + sch.setjGh(sch.getjGh().split("-")[1]); | ||
| 767 | + } | ||
| 768 | + //检查驾驶员工号 | ||
| 769 | + String jName = getPersonName(sch.getGsBm(), sch.getjGh()); | ||
| 770 | + if (StringUtils.isEmpty(jName)) { | ||
| 771 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | ||
| 772 | + rs.put("status", ResponseCode.ERROR); | ||
| 773 | + return rs; | ||
| 774 | + } else if (StringUtils.isEmpty(sch.getjName())) { | ||
| 775 | + sch.setjName(jName);//补上驾驶员名称 | ||
| 776 | + } | ||
| 777 | + | ||
| 778 | + //有售票员 | ||
| 779 | + if (StringUtils.isNotEmpty(sch.getsGh())) { | ||
| 780 | + String sName = getPersonName(sch.getGsBm(), sch.getsGh()); | ||
| 781 | + if (StringUtils.isEmpty(sName)) { | ||
| 782 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的售票员"); | ||
| 783 | + rs.put("status", ResponseCode.ERROR); | ||
| 784 | + return rs; | ||
| 785 | + } else if (StringUtils.isEmpty(sch.getsName())) { | ||
| 786 | + sch.setsName(sName);//补上售票员名称 | ||
| 787 | + } | ||
| 788 | + } else { | ||
| 789 | + sch.setsGh(""); | ||
| 790 | + sch.setsName(""); | ||
| 791 | + } | ||
| 792 | + | ||
| 793 | + //公司 和 分公司名称 | ||
| 794 | + sch.setGsName(BasicData.businessCodeNameMap.get(sch.getGsBm())); | ||
| 795 | + sch.setFgsName(BasicData.businessFgsCodeNameMap.get(sch.getFgsBm() + "_" + sch.getGsBm())); | ||
| 796 | + sch.setCreateDate(new Date()); | ||
| 797 | + sch.setScheduleDateStr(schDate); | ||
| 798 | + sch.setScheduleDate(sdfyyyyMMdd.parse(schDate)); | ||
| 799 | + sch.setRealExecDate(schDate); | ||
| 800 | + | ||
| 801 | + sch.setCreateBy(user); | ||
| 802 | + sch.setSflj(true); | ||
| 803 | + sch.setLate(false); | ||
| 804 | + sch.setDfsj(sch.getFcsj()); | ||
| 805 | + sch.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + sch.getZdsj()).getTime()); | ||
| 806 | + sch.setJhlcOrig(sch.getJhlc()); | ||
| 807 | + sch.setCreateDate(new Date()); | ||
| 808 | + sch.setUpdateDate(new Date()); | ||
| 809 | + sch.setSpId(-1L); | ||
| 810 | + //起终点名称 | ||
| 811 | + String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | ||
| 812 | + sch.setQdzName(BasicData.getStationNameByCode(sch.getQdzCode(), prefix)); | ||
| 813 | + sch.setZdzName(BasicData.getStationNameByCode(sch.getZdzCode(), prefix)); | ||
| 814 | + | ||
| 815 | + //计算班次实际执行时间 | ||
| 816 | + schAttrCalculator.calcRealDate(sch).calcAllTimeByFcsj(sch); | ||
| 817 | + | ||
| 818 | + //处理计达跨24点 | ||
| 819 | + LineConfig conf = lineConfigData.get(sch.getXlBm()); | ||
| 820 | + if (sch.getZdsj().compareTo(conf.getStartOpt()) < 0) { | ||
| 821 | + sch.setZdsjT(sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + sch.getZdsj()).getTime() + (1000 * 60 * 60 * 24)); | ||
| 822 | + } | ||
| 823 | + | ||
| 824 | + //班次历时 | ||
| 825 | + sch.setBcsj((int) ((sch.getZdsjT() - sch.getDfsjT()) / 1000 / 60)); | ||
| 826 | + if (sch.getZdsjT() < sch.getFcsjT()) { | ||
| 827 | + rs.put("status", ResponseCode.ERROR); | ||
| 828 | + rs.put("msg", "起终点时间异常!"); | ||
| 829 | + return rs; | ||
| 830 | + } | ||
| 831 | + | ||
| 832 | + sch.setId(dayOfSchedule.getId()); | ||
| 833 | + //实时入库 | ||
| 834 | + super.save(sch); | ||
| 835 | + | ||
| 836 | + // 加入缓存 | ||
| 837 | + dayOfSchedule.put(sch); | ||
| 838 | + | ||
| 839 | + //更新起点应到时间 | ||
| 840 | + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); | ||
| 841 | + | ||
| 842 | + //重新计算车辆当前执行班次 | ||
| 843 | + dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 844 | + | ||
| 845 | + //记录站到场历时数据 | ||
| 846 | + Station2ParkBuffer.put(sch); | ||
| 847 | + | ||
| 848 | + rs.put("ts", ts); | ||
| 849 | + rs.put("t", sch); | ||
| 850 | + } catch (Exception e) { | ||
| 851 | + logger.error("", e); | ||
| 852 | + rs.put("status", ResponseCode.ERROR); | ||
| 853 | + } | ||
| 854 | + return rs; | ||
| 855 | + } | ||
| 856 | + | ||
| 857 | + /** | ||
| 858 | + * 删除历史表临加班次 | ||
| 859 | + * | ||
| 860 | + * @param id | ||
| 861 | + * @return | ||
| 862 | + */ | ||
| 863 | + @Override | ||
| 864 | + public Map<String, Object> deleteToHistory(Long id) { | ||
| 865 | + Map<String, Object> rs = new HashMap<>(); | ||
| 866 | + rs.put("status", ResponseCode.ERROR); | ||
| 867 | + | ||
| 868 | + try { | ||
| 869 | + ScheduleRealInfo sch = super.findById(id); | ||
| 870 | + if (sch == null) { | ||
| 871 | + rs.put("msg", "无效的id号"); | ||
| 872 | + return rs; | ||
| 873 | + } | ||
| 874 | + | ||
| 875 | + if (!sch.isSflj()) { | ||
| 876 | + rs.put("msg", "你只能删除临加班次"); | ||
| 877 | + return rs; | ||
| 878 | + } | ||
| 879 | + | ||
| 880 | + //解除和调度指令的外键约束 | ||
| 881 | + jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | ||
| 882 | + | ||
| 883 | + //数据库删除 | ||
| 884 | + rs = super.delete(id); | ||
| 885 | + } catch (Exception e) { | ||
| 886 | + logger.error("", e); | ||
| 887 | + rs.put("msg", e.getMessage()); | ||
| 888 | + } | ||
| 889 | + | ||
| 890 | + return rs; | ||
| 891 | + } | ||
| 892 | + | ||
| 893 | + @Override | ||
| 894 | + public Map<String, Object> delete(Long id) { | ||
| 895 | + Map<String, Object> rs = new HashMap<>(); | ||
| 896 | + rs.put("status", ResponseCode.ERROR); | ||
| 897 | + | ||
| 898 | + ScheduleRealInfo sch = null; | ||
| 899 | + try { | ||
| 900 | + sch = dayOfSchedule.get(id); | ||
| 901 | + if (sch == null) { | ||
| 902 | + rs.put("msg", "无效的id号"); | ||
| 903 | + return rs; | ||
| 904 | + } | ||
| 905 | + | ||
| 906 | + if (!sch.isSflj()) { | ||
| 907 | + rs.put("msg", "你只能删除临加班次"); | ||
| 908 | + return rs; | ||
| 909 | + } | ||
| 910 | + | ||
| 911 | + sch.setDeleted(true); | ||
| 912 | + //解除和调度指令的外键约束 | ||
| 913 | + jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | ||
| 914 | + | ||
| 915 | + //数据库删除 | ||
| 916 | + rs = super.delete(id); | ||
| 917 | + if (rs.get("status").equals(ResponseCode.SUCCESS)) { | ||
| 918 | + dayOfSchedule.delete(sch); | ||
| 919 | + //更新起点应到时间 | ||
| 920 | + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); | ||
| 921 | + rs.put("ts", ts); | ||
| 922 | + rs.put("delete", sch); | ||
| 923 | + } else | ||
| 924 | + sch.setDeleted(false); | ||
| 925 | + } catch (Exception e) { | ||
| 926 | + logger.error("", e); | ||
| 927 | + rs.put("msg", e.getMessage()); | ||
| 928 | + sch.setDeleted(false); | ||
| 929 | + } | ||
| 930 | + | ||
| 931 | + return rs; | ||
| 932 | + } | ||
| 933 | + | ||
| 934 | + @Override | ||
| 935 | + public List<Map<String, String>> sreachVehic(String nbbm) { | ||
| 936 | + // 转大写 | ||
| 937 | + nbbm = nbbm.toUpperCase(); | ||
| 938 | + | ||
| 939 | + List<Map<String, String>> list = new ArrayList<>(); | ||
| 940 | + Map<String, String> map; | ||
| 941 | + Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet(); | ||
| 942 | + | ||
| 943 | + Line line; | ||
| 944 | + for (String k : allSet) { | ||
| 945 | + if (k.indexOf(nbbm) != -1) { | ||
| 946 | + // 所属线路 | ||
| 947 | + map = new HashMap<>(); | ||
| 948 | + line = BasicData.nbbm2LineMap.get(k); | ||
| 949 | + map.put("id", k); | ||
| 950 | + map.put("text", k); | ||
| 951 | + if (null != line) { | ||
| 952 | + map.put("lineName", line.getName()); | ||
| 953 | + map.put("lineCode", line.getLineCode()); | ||
| 954 | + } | ||
| 955 | + | ||
| 956 | + list.add(map); | ||
| 957 | + } | ||
| 958 | + | ||
| 959 | + if (list.size() > 20) | ||
| 960 | + break; | ||
| 961 | + } | ||
| 962 | + return list; | ||
| 963 | + } | ||
| 964 | + | ||
| 965 | + @Override | ||
| 966 | + public void adjustCar(ScheduleRealInfo schedule, String car) { | ||
| 967 | + schedule.setClZbh(car); | ||
| 968 | + } | ||
| 969 | + | ||
| 970 | + @Override | ||
| 971 | + public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) { | ||
| 972 | + if (driver.indexOf("-") != -1) | ||
| 973 | + driver = driver.split("-")[1]; | ||
| 974 | + schedule.setjGh(driver); | ||
| 975 | + schedule.setjName(driverName); | ||
| 976 | + } | ||
| 977 | + | ||
| 978 | + @Override | ||
| 979 | + public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) { | ||
| 980 | + if (conductor.indexOf("-") != -1) | ||
| 981 | + conductor = conductor.split("-")[1]; | ||
| 982 | + schedule.setsGh(conductor); | ||
| 983 | + schedule.setsName(conductorName); | ||
| 984 | + } | ||
| 985 | + | ||
| 986 | + @Override | ||
| 987 | + public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) { | ||
| 988 | + List<ScheduleRealInfo> scheduleRealInfos = new ArrayList<>(); | ||
| 989 | + List<Object[]> objects = null; | ||
| 990 | + if (state.equals("2")) { | ||
| 991 | + objects = scheduleRealInfoRepository.queryUserInfo2(line, date); | ||
| 992 | + for (Object[] objs : objects) { | ||
| 993 | + ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo(); | ||
| 994 | + scheduleRealInfo.setId((Long)objs[0]); | ||
| 995 | + scheduleRealInfo.setjGh((String)objs[1]); | ||
| 996 | + scheduleRealInfo.setClZbh((String)objs[2]); | ||
| 997 | + scheduleRealInfo.setLpName((String)objs[3]); | ||
| 998 | + scheduleRealInfo.setjName((String)objs[4]); | ||
| 999 | + | ||
| 1000 | + scheduleRealInfos.add(scheduleRealInfo); | ||
| 1001 | + } | ||
| 1002 | + } else { | ||
| 1003 | + objects = scheduleRealInfoRepository.queryUserInfo3(line, date); | ||
| 1004 | + for (Object[] objs : objects) { | ||
| 1005 | + ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo(); | ||
| 1006 | + scheduleRealInfo.setId((Long)objs[0]); | ||
| 1007 | + scheduleRealInfo.setClZbh((String)objs[1]); | ||
| 1008 | + | ||
| 1009 | + scheduleRealInfos.add(scheduleRealInfo); | ||
| 1010 | + } | ||
| 1011 | + } | ||
| 1012 | + | ||
| 1013 | + return scheduleRealInfos; | ||
| 1014 | + } | ||
| 1015 | + | ||
| 1016 | + @Override | ||
| 1017 | + public List<ScheduleRealInfo> queryUserInfoPx(String line, String date, String state, String type) { | ||
| 1018 | +// List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | ||
| 1019 | + state = state + ""; | ||
| 1020 | + String lpname = state; | ||
| 1021 | + String px = type; | ||
| 1022 | + if (state.equals("lpName")) { | ||
| 1023 | + state = state + "+1"; | ||
| 1024 | + type = "ASC"; | ||
| 1025 | + } | ||
| 1026 | + String minfcsj = "02:00"; | ||
| 1027 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 1028 | + if (lineList.size() > 0) { | ||
| 1029 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 1030 | + + " id = (" | ||
| 1031 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 1032 | + + ")"; | ||
| 1033 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 1034 | + } | ||
| 1035 | + String sqlPlan = "select * from (select * from (" | ||
| 1036 | + + " select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, " | ||
| 1037 | + + " s.lp_Name as lpName,min(s.j_Name) as jName,max(s.schedule_date_str) as dateStr ," | ||
| 1038 | + + " min(s.fcsj) as fcsj,1 as px from bsth_c_s_sp_info_real s where " | ||
| 1039 | + + " s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'" | ||
| 1040 | + + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name) x where x.fcsj >'" + minfcsj + "'" | ||
| 1041 | + + " UNION " | ||
| 1042 | + + " select * from ( select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, " | ||
| 1043 | + + " s.lp_Name as lpName,min(s.j_Name) as jName, max(s.schedule_date_str) as dateStr," | ||
| 1044 | + + " min(s.fcsj) as fcsj,2 as px from bsth_c_s_sp_info_real s " | ||
| 1045 | + + " where s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'" | ||
| 1046 | + + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name" | ||
| 1047 | + + " ) y where y.fcsj <='" + minfcsj + "') z order by (" + state + "),dateStr,px,fcsj " + type; | ||
| 1048 | + List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan, | ||
| 1049 | + new RowMapper<ScheduleRealInfo>() { | ||
| 1050 | + @Override | ||
| 1051 | + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1052 | + ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 1053 | + t.setId(rs.getLong("id")); | ||
| 1054 | + t.setjGh(rs.getString("jGh")); | ||
| 1055 | + t.setClZbh(rs.getString("clZbh")); | ||
| 1056 | + t.setLpName(rs.getString("lpName")); | ||
| 1057 | + t.setjName(rs.getString("jName")); | ||
| 1058 | + t.setFcsj(rs.getString("fcsj")); | ||
| 1059 | + return t; | ||
| 1060 | + } | ||
| 1061 | + }); | ||
| 1062 | + if (lpname.equals("lpName")) { | ||
| 1063 | + | ||
| 1064 | + List<ScheduleRealInfo> listNew = new ArrayList<ScheduleRealInfo>(); | ||
| 1065 | + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); | ||
| 1066 | +// if (px.equals("desc")) { | ||
| 1067 | + int zt = 0; | ||
| 1068 | + for (int l = 0; l < 2; l++) { | ||
| 1069 | + for (int i = 0; i < list.size(); i++) { | ||
| 1070 | + ScheduleRealInfo t = list.get(i); | ||
| 1071 | + if (t.getLpName().indexOf("+") != -1) { | ||
| 1072 | + if (zt == 0) { | ||
| 1073 | + listNew.add(t); | ||
| 1074 | + } | ||
| 1075 | + } else if (pattern.matcher(t.getLpName()).matches()) { | ||
| 1076 | + if (zt == 1) { | ||
| 1077 | + listNew.add(t); | ||
| 1078 | + } | ||
| 1079 | + } else { | ||
| 1080 | + continue; | ||
| 1081 | + } | ||
| 1082 | + } | ||
| 1083 | + zt++; | ||
| 1084 | + } | ||
| 1085 | + | ||
| 1086 | + Collections.sort(list, new ComparableLp()); | ||
| 1087 | + for (int i = 0; i < list.size(); i++) { | ||
| 1088 | + ScheduleRealInfo t = list.get(i); | ||
| 1089 | + if (t.getLpName().indexOf("+") != -1) { | ||
| 1090 | + continue; | ||
| 1091 | + } else if (pattern.matcher(t.getLpName()).matches()) { | ||
| 1092 | + continue; | ||
| 1093 | + } else { | ||
| 1094 | + listNew.add(t); | ||
| 1095 | + } | ||
| 1096 | + } | ||
| 1097 | + return listNew; | ||
| 1098 | + } else { | ||
| 1099 | + return list; | ||
| 1100 | + } | ||
| 1101 | + | ||
| 1102 | + } | ||
| 1103 | + | ||
| 1104 | + /** | ||
| 1105 | + * | ||
| 1106 | + */ | ||
| 1107 | + @Override | ||
| 1108 | + public List<ScheduleRealInfo> exportWaybill(String jName,String jGh, String clZbh, String lpName, String date, String line) { | ||
| 1109 | + ReportUtils ee = new ReportUtils(); | ||
| 1110 | + ReportRelatedUtils rru = new ReportRelatedUtils(); | ||
| 1111 | + List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | ||
| 1112 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 1113 | + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 1114 | +// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line); | ||
| 1115 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 1116 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 1117 | + ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 1118 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 1119 | + if (cts != null && cts.size() > 0) { | ||
| 1120 | + lists.add(s); | ||
| 1121 | + } else { | ||
| 1122 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 1123 | + lists.add(s); | ||
| 1124 | + } | ||
| 1125 | + } | ||
| 1126 | + } | ||
| 1127 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 1128 | +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 1129 | +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 1130 | + //计算里程和班次数,并放入Map里 | ||
| 1131 | + Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); | ||
| 1132 | + | ||
| 1133 | + map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos))); | ||
| 1134 | + map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos)); | ||
| 1135 | + map.put("addMileage", culateMieageService.culateLjgl(lists)); | ||
| 1136 | + double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists)); | ||
| 1137 | + map.put("yygl", yygl); | ||
| 1138 | + double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists)); | ||
| 1139 | + map.put("ksgl", ksgl); | ||
| 1140 | + map.put("realMileage", Arith.add(yygl, ksgl)); | ||
| 1141 | + map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, "")); | ||
| 1142 | + map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos)); | ||
| 1143 | + map.put("ljbc", culateMieageService.culateLjbc(lists, "")); | ||
| 1144 | + int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, ""); | ||
| 1145 | + map.put("sjbc", sjbc); | ||
| 1146 | +// map=new HashMap<String,Object>(); | ||
| 1147 | + | ||
| 1148 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 1149 | + String minfcsj = "02:00"; | ||
| 1150 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 1151 | + if (lineList.size() > 0) { | ||
| 1152 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 1153 | + + " id = (" | ||
| 1154 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 1155 | + + ")"; | ||
| 1156 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 1157 | + } | ||
| 1158 | + String[] minSjs = minfcsj.split(":"); | ||
| 1159 | + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 1160 | + | ||
| 1161 | + | ||
| 1162 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 1163 | + ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 1164 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 1165 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 1166 | + | ||
| 1167 | + Long fscjT = 0L; | ||
| 1168 | + if (fcsjL < minSj) { | ||
| 1169 | + Calendar calendar = new GregorianCalendar(); | ||
| 1170 | + calendar.setTime(s.getScheduleDate()); | ||
| 1171 | + calendar.add(calendar.DATE, 1); | ||
| 1172 | + s.setScheduleDate(calendar.getTime()); | ||
| 1173 | + try { | ||
| 1174 | + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 1175 | + } catch (ParseException e) { | ||
| 1176 | + // TODO Auto-generated catch block | ||
| 1177 | + e.printStackTrace(); | ||
| 1178 | + } | ||
| 1179 | + | ||
| 1180 | + } else { | ||
| 1181 | + try { | ||
| 1182 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 1183 | + } catch (ParseException e) { | ||
| 1184 | + // TODO Auto-generated catch block | ||
| 1185 | + e.printStackTrace(); | ||
| 1186 | + } | ||
| 1187 | + ; | ||
| 1188 | + } | ||
| 1189 | + s.setFcsjT(fscjT); | ||
| 1190 | + } | ||
| 1191 | + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 1192 | + Collections.sort(scheduleRealInfos, new ComparableReal()); | ||
| 1193 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 1194 | + ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 1195 | + s.setAdjustExps(i + 1 + ""); | ||
| 1196 | + String remarks = ""; | ||
| 1197 | + if (s.getRemarks() != null) { | ||
| 1198 | + remarks += s.getRemarks(); | ||
| 1199 | + } | ||
| 1200 | + | ||
| 1201 | + Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 1202 | + if (!childTaskPlans.isEmpty()) { | ||
| 1203 | + s.setFcsjActual(""); | ||
| 1204 | + s.setZdsjActual(""); | ||
| 1205 | + s.setJhlc(0.0); | ||
| 1206 | + } | ||
| 1207 | + | ||
| 1208 | + if (s.isDestroy()) { | ||
| 1209 | + s.setFcsjActual(""); | ||
| 1210 | + s.setZdsjActual(""); | ||
| 1211 | + s.setJhlc(0.0); | ||
| 1212 | + remarks += "(烂班)"; | ||
| 1213 | + s.setRemarks(remarks); | ||
| 1214 | + } | ||
| 1215 | + | ||
| 1216 | + listSchedule.add(s); | ||
| 1217 | + //计算营运里程,空驶里程 | ||
| 1218 | + if (!childTaskPlans.isEmpty()) { | ||
| 1219 | +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 1220 | + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 1221 | + Collections.sort(listit, new ComparableChild()); | ||
| 1222 | + for (int j = 0; j < listit.size(); j++) { | ||
| 1223 | + ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 1224 | + ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 1225 | + if (childTaskPlan.isDestroy()) { | ||
| 1226 | + t.setFcsjActual(""); | ||
| 1227 | + t.setZdsjActual(""); | ||
| 1228 | + t.setJhlc(0.0); | ||
| 1229 | + } else { | ||
| 1230 | + t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 1231 | + t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 1232 | + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 1233 | + } | ||
| 1234 | + t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 1235 | + t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 1236 | + t.setRemarks(childTaskPlan.getRemarks()); | ||
| 1237 | + t.setAdjustExps("子"); | ||
| 1238 | + t.setjGh(""); | ||
| 1239 | + t.setjName(""); | ||
| 1240 | + t.setsGh(""); | ||
| 1241 | + t.setsName(""); | ||
| 1242 | + listSchedule.add(t); | ||
| 1243 | + } | ||
| 1244 | + } | ||
| 1245 | + } | ||
| 1246 | + Map<String, Object> maps; | ||
| 1247 | + for (ScheduleRealInfo scheduleRealInfo : listSchedule) { | ||
| 1248 | + maps = new HashMap<String, Object>(); | ||
| 1249 | + try { | ||
| 1250 | + scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | ||
| 1251 | + scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | ||
| 1252 | + maps = rru.getMapValue(scheduleRealInfo); | ||
| 1253 | + maps.put("bcs", scheduleRealInfo.getAdjustExps()); | ||
| 1254 | + String zdsj = scheduleRealInfo.getZdsj(); | ||
| 1255 | + String zdsjActual = scheduleRealInfo.getZdsjActual(); | ||
| 1256 | + if (zdsj != null && zdsjActual != null && | ||
| 1257 | + !zdsj.equals(zdsjActual) && | ||
| 1258 | + !zdsj.equals("") && | ||
| 1259 | + !zdsjActual.equals("")) { | ||
| 1260 | + int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | ||
| 1261 | + int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | ||
| 1262 | + if (zdsj.compareTo(zdsjActual) > 0) { | ||
| 1263 | + if (zdsjT - zdsjAT > 1000) { | ||
| 1264 | + maps.put("fast", ""); | ||
| 1265 | + maps.put("slow", zdsjAT - zdsjT + 1440); | ||
| 1266 | + } else { | ||
| 1267 | + maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 1268 | + maps.put("slow", ""); | ||
| 1269 | + } | ||
| 1270 | + } else { | ||
| 1271 | + if (zdsjAT - zdsjT > 1000) { | ||
| 1272 | + maps.put("fast", zdsjT - zdsjAT + 1440); | ||
| 1273 | + maps.put("slow", ""); | ||
| 1274 | + } else { | ||
| 1275 | + maps.put("fast", ""); | ||
| 1276 | + maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 1277 | + } | ||
| 1278 | + } | ||
| 1279 | + } else { | ||
| 1280 | + maps.put("fast", ""); | ||
| 1281 | + maps.put("slow", ""); | ||
| 1282 | + } | ||
| 1283 | + listMap.add(maps); | ||
| 1284 | + } catch (Exception e) { | ||
| 1285 | + e.printStackTrace(); | ||
| 1286 | + } | ||
| 1287 | + } | ||
| 1288 | + | ||
| 1289 | + String xls = ""; | ||
| 1290 | + if (map.get("type").toString().equals("0")) { | ||
| 1291 | + xls = "waybill_minhang.xls"; | ||
| 1292 | + } else { | ||
| 1293 | + xls = "waybill_minhang_dl.xls"; | ||
| 1294 | + } | ||
| 1295 | + | ||
| 1296 | + | ||
| 1297 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1298 | + | ||
| 1299 | + list.add(listMap.iterator()); | ||
| 1300 | + ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/" + xls, | ||
| 1301 | + path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | ||
| 1302 | + return scheduleRealInfos; | ||
| 1303 | + } | ||
| 1304 | + | ||
| 1305 | + @Override | ||
| 1306 | + public List<Map<String, Object>> dailyInfo(String line, String date, String type) { | ||
| 1307 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 1308 | + ReportUtils ee = new ReportUtils(); | ||
| 1309 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1310 | + List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date); | ||
| 1311 | + | ||
| 1312 | + double totalZGL = 0, totalKSGL = 0, totalYH = 0; | ||
| 1313 | + int totalBCS = 0; | ||
| 1314 | + for (int i = 0; i < list.size(); i++) { | ||
| 1315 | + String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString())); | ||
| 1316 | + String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString())); | ||
| 1317 | + if (type.equals("export")) { | ||
| 1318 | + totalZGL += Double.parseDouble(zgl); | ||
| 1319 | + totalKSGL += Double.parseDouble(ksgl); | ||
| 1320 | + totalBCS += Integer.parseInt(list.get(i).get("bcs").toString()); | ||
| 1321 | + } | ||
| 1322 | + list.get(i).put("zgl", zgl); | ||
| 1323 | + list.get(i).put("ksgl", ksgl); | ||
| 1324 | + } | ||
| 1325 | + if (type.equals("export")) { | ||
| 1326 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 1327 | + map.put("line", line); | ||
| 1328 | + map.put("date", date); | ||
| 1329 | + map.put("totalZGL", totalZGL); | ||
| 1330 | + map.put("totalKSGL", totalKSGL); | ||
| 1331 | + map.put("totalYH", totalYH); | ||
| 1332 | + map.put("totalBCS", totalBCS); | ||
| 1333 | + | ||
| 1334 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1335 | + | ||
| 1336 | + listI.add(list.iterator()); | ||
| 1337 | + try { | ||
| 1338 | + ee.excelReplace(listI, new Object[]{map}, path + "mould/daily.xls", | ||
| 1339 | + path + "export/班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | ||
| 1340 | + } catch (ParseException e) { | ||
| 1341 | + e.printStackTrace(); | ||
| 1342 | + } | ||
| 1343 | + } | ||
| 1344 | + return list; | ||
| 1345 | + } | ||
| 1346 | + | ||
| 1347 | + @Override | ||
| 1348 | + public List<Object[]> historyMessage(String line, String date, String code, String type) { | ||
| 1349 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 1350 | + | ||
| 1351 | + long d = 0; | ||
| 1352 | + long t = 0; | ||
| 1353 | + if (date.length() > 0) { | ||
| 1354 | + try { | ||
| 1355 | + d = sdf.parse(date + " 00:00:00").getTime(); | ||
| 1356 | + t = sdf.parse(date + " 23:59:59").getTime(); | ||
| 1357 | + } catch (ParseException e) { | ||
| 1358 | + // TODO Auto-generated catch block | ||
| 1359 | + e.printStackTrace(); | ||
| 1360 | + } | ||
| 1361 | + | ||
| 1362 | + } | ||
| 1363 | + String device = ""; | ||
| 1364 | + String device2 =""; | ||
| 1365 | + long qyrqTime=0l; | ||
| 1366 | + if (!code.equals("")) { | ||
| 1367 | + try { | ||
| 1368 | + List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00")); | ||
| 1369 | + if(deviceList.size()>0){ | ||
| 1370 | + device=deviceList.get(0).getOldDeviceNo(); | ||
| 1371 | + Date qyrq=deviceList.get(0).getQyrq(); | ||
| 1372 | + qyrqTime=qyrq.getTime(); | ||
| 1373 | + if(qyrqTime<t){ | ||
| 1374 | + device2=deviceList.get(0).getNewDeviceNo(); | ||
| 1375 | + } | ||
| 1376 | + }else{ | ||
| 1377 | + device = BasicData.deviceId2NbbmMap.inverse().get(code); | ||
| 1378 | + } | ||
| 1379 | + } catch (ParseException e) { | ||
| 1380 | + // TODO Auto-generated catch block | ||
| 1381 | + e.printStackTrace(); | ||
| 1382 | + } | ||
| 1383 | + } | ||
| 1384 | + List<Object[]> list=new ArrayList<Object[]>(); | ||
| 1385 | + | ||
| 1386 | + device = device.replaceAll("BF-", ""); | ||
| 1387 | + List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, device, d, t); | ||
| 1388 | + for (Object[] obj : list0) { | ||
| 1389 | + if (obj != null) { | ||
| 1390 | + if(code.equals("")){ | ||
| 1391 | + if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) { | ||
| 1392 | + List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | ||
| 1393 | + try { | ||
| 1394 | + carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | ||
| 1395 | + //启用日期大于营运日期 还是根据旧设备号查询 | ||
| 1396 | + if(carDeviceList.size()==0){ | ||
| 1397 | + carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | ||
| 1398 | + } | ||
| 1399 | + } catch (Exception e) { | ||
| 1400 | + // TODO Auto-generated catch block | ||
| 1401 | + e.printStackTrace(); | ||
| 1402 | + } | ||
| 1403 | + if (carDeviceList.size() > 0) { | ||
| 1404 | + obj[0] = carDeviceList.get(0).getClZbh(); | ||
| 1405 | + } else { | ||
| 1406 | + obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | ||
| 1407 | + } | ||
| 1408 | + } else { | ||
| 1409 | + obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | ||
| 1410 | + } | ||
| 1411 | + }else{ | ||
| 1412 | + obj[0]=code; | ||
| 1413 | + } | ||
| 1414 | + | ||
| 1415 | + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | ||
| 1416 | + obj[4] = BasicData.lineCode2NameMap.get(line); | ||
| 1417 | + } | ||
| 1418 | + } | ||
| 1419 | + list.addAll(list0); | ||
| 1420 | + if(!device2.equals("")){ | ||
| 1421 | + device2.replaceAll("BF-", ""); | ||
| 1422 | + List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, device2, d, t); | ||
| 1423 | + for (Object[] obj : list1) { | ||
| 1424 | + if (obj != null) { | ||
| 1425 | + obj[0] =code; | ||
| 1426 | + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | ||
| 1427 | + obj[4] = BasicData.lineCode2NameMap.get(line); | ||
| 1428 | + } | ||
| 1429 | + } | ||
| 1430 | + list.addAll(list1); | ||
| 1431 | + } | ||
| 1432 | + | ||
| 1433 | + if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 1434 | + String lineName = BasicData.lineCode2NameMap.get(line); | ||
| 1435 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1436 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1437 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1438 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1439 | + ReportUtils ee = new ReportUtils(); | ||
| 1440 | + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | ||
| 1441 | + for (int i = 0; i < list.size(); i++) { | ||
| 1442 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 1443 | + Object[] obj = list.get(i); | ||
| 1444 | + map.put("num", i + 1); | ||
| 1445 | + map.put("line", obj[4]); | ||
| 1446 | + map.put("clZbh", obj[0]); | ||
| 1447 | + map.put("sender", obj[1]); | ||
| 1448 | + map.put("date", obj[3]); | ||
| 1449 | + map.put("text", obj[2]); | ||
| 1450 | + map.put("reply46", "0".equals(obj[5]+"")?"是":""); | ||
| 1451 | + map.put("reply47", "0".equals(obj[6]+"")?"是":""); | ||
| 1452 | + newList.add(map); | ||
| 1453 | + } | ||
| 1454 | + try { | ||
| 1455 | + listI.add(newList.iterator()); | ||
| 1456 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1457 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/historyMessage.xls", | ||
| 1458 | + path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | ||
| 1459 | + + "-" + lineName + "-调度历史消息.xls"); | ||
| 1460 | + } catch (Exception e) { | ||
| 1461 | + // TODO: handle exception | ||
| 1462 | + e.printStackTrace(); | ||
| 1463 | + } | ||
| 1464 | + } | ||
| 1465 | + | ||
| 1466 | + if (type != null && type.length() != 0 && type.equals("export_msg")) { | ||
| 1467 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1468 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1469 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1470 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1471 | + ReportUtils ee = new ReportUtils(); | ||
| 1472 | + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | ||
| 1473 | + for (int i = 0; i < list.size(); i++) { | ||
| 1474 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 1475 | + Object[] obj = list.get(i); | ||
| 1476 | + map.put("num", i + 1); | ||
| 1477 | + map.put("line", obj[4]); | ||
| 1478 | + map.put("clZbh", obj[0]); | ||
| 1479 | + map.put("sender", obj[1]); | ||
| 1480 | + map.put("date", obj[3]); | ||
| 1481 | + map.put("text", obj[2]); | ||
| 1482 | + newList.add(map); | ||
| 1483 | + } | ||
| 1484 | + try { | ||
| 1485 | + listI.add(newList.iterator()); | ||
| 1486 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1487 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls", | ||
| 1488 | + path + "export/调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | ||
| 1489 | + } catch (Exception e) { | ||
| 1490 | + // TODO: handle exception | ||
| 1491 | + e.printStackTrace(); | ||
| 1492 | + } | ||
| 1493 | + } | ||
| 1494 | + return list; | ||
| 1495 | + } | ||
| 1496 | + | ||
| 1497 | + @Override | ||
| 1498 | + public Map<Integer, Integer> trustStatus(String lineStr) { | ||
| 1499 | + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr)); | ||
| 1500 | + | ||
| 1501 | + Map<Integer, Integer> map = new HashMap<>(); | ||
| 1502 | + return map; | ||
| 1503 | + } | ||
| 1504 | + | ||
| 1505 | + @Override | ||
| 1506 | + public Map<String, Object> realOutAdjust(Map<String, String> map) { | ||
| 1507 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1508 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1509 | + try { | ||
| 1510 | + // 维修上报 | ||
| 1511 | + if (StringUtils.isNotBlank(map.get("reportTypes"))) { | ||
| 1512 | + Map<String, Object> param = new HashMap<String, Object>(); | ||
| 1513 | + param.putAll(map); | ||
| 1514 | + rs = repairReport(param, false); | ||
| 1515 | + } | ||
| 1516 | + | ||
| 1517 | + Long id = Long.parseLong(map.get("id")); | ||
| 1518 | + String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual"); | ||
| 1519 | + | ||
| 1520 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1521 | + | ||
| 1522 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 1523 | + //小于线路开始运营时间,则默认跨过24点 | ||
| 1524 | + if (fcsjActual.compareTo(config.getStartOpt()) < 0) { | ||
| 1525 | + sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)); | ||
| 1526 | + } else { | ||
| 1527 | + sch.setRealExecDate(sch.getScheduleDateStr()); | ||
| 1528 | + } | ||
| 1529 | + | ||
| 1530 | + //日志记录 | ||
| 1531 | + ScheduleModifyLogger.sftz(sch, fcsjActual, remarks); | ||
| 1532 | + | ||
| 1533 | + sch.setFcsjActualAll(fcsjActual); | ||
| 1534 | + sch.setRemarks(remarks); | ||
| 1535 | + sch.calcStatus(); | ||
| 1536 | + //if(sch.isLate2()){ | ||
| 1537 | + //取消应发未到标记 | ||
| 1538 | + // sch.setLate2(false); | ||
| 1539 | + LateAdjustHandle.remove(sch); | ||
| 1540 | + //} | ||
| 1541 | + | ||
| 1542 | + dayOfSchedule.save(sch); | ||
| 1543 | + | ||
| 1544 | + ts.add(sch); | ||
| 1545 | + | ||
| 1546 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1547 | + rs.put("ts", ts); | ||
| 1548 | + | ||
| 1549 | + //通知页面刷新 | ||
| 1550 | + sendUtils.refreshSch(ts); | ||
| 1551 | + } catch (Exception e) { | ||
| 1552 | + logger.error("", e); | ||
| 1553 | + rs.put("status", ResponseCode.ERROR); | ||
| 1554 | + } | ||
| 1555 | + | ||
| 1556 | + return rs; | ||
| 1557 | + } | ||
| 1558 | + | ||
| 1559 | + @Override | ||
| 1560 | + public Map<String, Object> revokeDestroy(Long id) { | ||
| 1561 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1562 | + try { | ||
| 1563 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1564 | + if (sch.getStatus() != -1) { | ||
| 1565 | + rs.put("status", ResponseCode.ERROR); | ||
| 1566 | + rs.put("msg", "未烂班,无法撤销!"); | ||
| 1567 | + } else { | ||
| 1568 | + //日志记录 | ||
| 1569 | + ScheduleModifyLogger.cxlb(sch); | ||
| 1570 | + | ||
| 1571 | + sch.setStatus(0); | ||
| 1572 | + sch.setRemarks("");//清空备注 | ||
| 1573 | + sch.setJhlc(sch.getJhlcOrig()); | ||
| 1574 | + | ||
| 1575 | + //入库 | ||
| 1576 | + dayOfSchedule.save(sch); | ||
| 1577 | + //重新计算当前执行班次 | ||
| 1578 | + dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 1579 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1580 | + rs.put("t", sch); | ||
| 1581 | + | ||
| 1582 | + } | ||
| 1583 | + } catch (Exception e) { | ||
| 1584 | + logger.error("", e); | ||
| 1585 | + rs.put("status", ResponseCode.ERROR); | ||
| 1586 | + } | ||
| 1587 | + return rs; | ||
| 1588 | + } | ||
| 1589 | + | ||
| 1590 | + @Override | ||
| 1591 | + public Map<String, Object> revokeRealOutgo(Long id) { | ||
| 1592 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1593 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1594 | + | ||
| 1595 | + try { | ||
| 1596 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1597 | + if (sch.getFcsjActual() == null) { | ||
| 1598 | + rs.put("status", ResponseCode.ERROR); | ||
| 1599 | + rs.put("msg", "无实发时间,无法撤销!"); | ||
| 1600 | + } else { | ||
| 1601 | + //日志记录 | ||
| 1602 | + ScheduleModifyLogger.cxsf(sch); | ||
| 1603 | + | ||
| 1604 | + sch.clearFcsjActual(); | ||
| 1605 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1606 | + | ||
| 1607 | + ts.add(sch); | ||
| 1608 | + rs.put("ts", ts); | ||
| 1609 | + | ||
| 1610 | + dayOfSchedule.save(sch); | ||
| 1611 | + | ||
| 1612 | + } | ||
| 1613 | + } catch (Exception e) { | ||
| 1614 | + logger.error("", e); | ||
| 1615 | + rs.put("status", ResponseCode.ERROR); | ||
| 1616 | + } | ||
| 1617 | + return rs; | ||
| 1618 | + } | ||
| 1619 | + | ||
| 1620 | + @Override | ||
| 1621 | + public Map<String, Object> spaceAdjust(Long[] ids, Integer space) { | ||
| 1622 | + | ||
| 1623 | + List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null; | ||
| 1624 | + Map<String, Object> rs = new HashMap<>(), tempRs = new HashMap<>(); | ||
| 1625 | + try { | ||
| 1626 | + ScheduleRealInfo sch, next; | ||
| 1627 | + for (Long id : ids) { | ||
| 1628 | + sch = dayOfSchedule.get(id); | ||
| 1629 | + if (null != sch) | ||
| 1630 | + list.add(sch); | ||
| 1631 | + } | ||
| 1632 | + | ||
| 1633 | + int size = list.size(); | ||
| 1634 | + if (size == 0) { | ||
| 1635 | + rs.put("status", ResponseCode.ERROR); | ||
| 1636 | + } else { | ||
| 1637 | + // 按发车时间排序 | ||
| 1638 | + Collections.sort(list, new ScheduleComparator.FCSJ()); | ||
| 1639 | + | ||
| 1640 | + // 以第一个实际发车/待发时间为起点,调整间隔 | ||
| 1641 | + sch = list.get(0); | ||
| 1642 | + Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L; | ||
| 1643 | + | ||
| 1644 | + for (int i = 1; i < size; i++) { | ||
| 1645 | + st += plus; | ||
| 1646 | + sch = list.get(i); | ||
| 1647 | + | ||
| 1648 | + //调整待发 | ||
| 1649 | + tempRs = outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null, "3", null); | ||
| 1650 | + | ||
| 1651 | + if (null != tempRs && tempRs.get("ts") != null) | ||
| 1652 | + tempTs = (List<ScheduleRealInfo>) tempRs.get("ts"); | ||
| 1653 | + | ||
| 1654 | + ts.addAll(tempTs); | ||
| 1655 | + } | ||
| 1656 | + | ||
| 1657 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1658 | + //返回最后一个班次,页面会全量刷新 | ||
| 1659 | + rs.put("ts", ts); | ||
| 1660 | + } | ||
| 1661 | + | ||
| 1662 | + } catch (Exception e) { | ||
| 1663 | + logger.error("", e); | ||
| 1664 | + rs.put("status", ResponseCode.ERROR); | ||
| 1665 | + } | ||
| 1666 | + return rs; | ||
| 1667 | + } | ||
| 1668 | + | ||
| 1669 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | ||
| 1670 | + | ||
| 1671 | + @Transactional | ||
| 1672 | + @Override | ||
| 1673 | + public Map<String, Object> schInfoFineTune(Map<String, String> map) { | ||
| 1674 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1675 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1676 | + try { | ||
| 1677 | + // 维修上报 | ||
| 1678 | + if (StringUtils.isNotBlank(map.get("reportTypes"))) { | ||
| 1679 | + Map<String, Object> param = new HashMap<String, Object>(); | ||
| 1680 | + param.putAll(map); | ||
| 1681 | + rs = repairReport(param, false); | ||
| 1682 | + } | ||
| 1683 | + | ||
| 1684 | + Long id = Long.parseLong(map.get("id")); | ||
| 1685 | + String remarks = map.get("remarks"); | ||
| 1686 | + | ||
| 1687 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1688 | + | ||
| 1689 | + if (null == sch) { | ||
| 1690 | + rs.put("status", ResponseCode.ERROR); | ||
| 1691 | + rs.put("msg", "不存在的班次!"); | ||
| 1692 | + return rs; | ||
| 1693 | + } | ||
| 1694 | + | ||
| 1695 | + //日志记录器 | ||
| 1696 | + FcxxwtLogger fLog = FcxxwtLogger.start(sch, remarks); | ||
| 1697 | + | ||
| 1698 | + String clZbh = map.get("clZbh"); | ||
| 1699 | + String jsy = map.get("jsy"); | ||
| 1700 | + if (!clZbh.equals(sch.getClZbh()) | ||
| 1701 | + || !jsy.equals(sch.getjGh() + "/" + sch.getjName())) | ||
| 1702 | + schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据 | ||
| 1703 | + /** | ||
| 1704 | + * 换车 | ||
| 1705 | + */ | ||
| 1706 | + if (StringUtils.isNotEmpty(clZbh) && !clZbh.equals(sch.getClZbh())) { | ||
| 1707 | + //换车 | ||
| 1708 | + if (!carExist(sch.getGsBm(), clZbh)) { | ||
| 1709 | + rs.put("status", ResponseCode.ERROR); | ||
| 1710 | + rs.put("msg", "车辆 " + clZbh + " 不存在!"); | ||
| 1711 | + return rs; | ||
| 1712 | + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) { | ||
| 1713 | + rs.put("status", ResponseCode.ERROR); | ||
| 1714 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆"); | ||
| 1715 | + return rs; | ||
| 1716 | + } else { | ||
| 1717 | + fLog.log("换车", sch.getClZbh(), clZbh); | ||
| 1718 | + dayOfSchedule.changeCar(sch, clZbh); | ||
| 1719 | + } | ||
| 1720 | + } | ||
| 1721 | + | ||
| 1722 | + if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){ | ||
| 1723 | + rs.put("status", ResponseCode.ERROR); | ||
| 1724 | + rs.put("msg", "无效的参数【驾驶员】"); | ||
| 1725 | + return rs; | ||
| 1726 | + } | ||
| 1727 | + | ||
| 1728 | + /** | ||
| 1729 | + * 换驾驶员 | ||
| 1730 | + */ | ||
| 1731 | + if (StringUtils.isNotEmpty(jsy)) { | ||
| 1732 | + String jGh = jsy.split("/")[0]; | ||
| 1733 | + String jName = getPersonName(sch.getGsBm(), jGh); | ||
| 1734 | + if (StringUtils.isEmpty(jName)) { | ||
| 1735 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | ||
| 1736 | + rs.put("status", ResponseCode.ERROR); | ||
| 1737 | + return rs; | ||
| 1738 | + } else if (!jGh.equals(sch.getjGh())) { | ||
| 1739 | + fLog.log("换驾驶员", sch.getjGh() + "/" + sch.getjName(), jsy); | ||
| 1740 | + persoChange(sch, jGh); | ||
| 1741 | + } | ||
| 1742 | + } | ||
| 1743 | + | ||
| 1744 | + /** | ||
| 1745 | + * 换售票员 | ||
| 1746 | + */ | ||
| 1747 | + String spy = map.get("spy"); | ||
| 1748 | + if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) { | ||
| 1749 | + String sGh = spy.split("/")[0]; | ||
| 1750 | + | ||
| 1751 | + String sName = getPersonName(sch.getGsBm(), sGh); | ||
| 1752 | + if (StringUtils.isEmpty(sName)) { | ||
| 1753 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | ||
| 1754 | + rs.put("status", ResponseCode.ERROR); | ||
| 1755 | + return rs; | ||
| 1756 | + } else if (!sGh.equals(sch.getsGh())) { | ||
| 1757 | + fLog.log("换售票员", sch.getsGh() + "/" + sch.getsName(), spy); | ||
| 1758 | + persoChangeSPY(sch, sGh); | ||
| 1759 | + } | ||
| 1760 | + } else if (StringUtils.isNotEmpty(sch.getsGh())) { | ||
| 1761 | + fLog.log("撤销售票员"); | ||
| 1762 | + sch.setsGh(""); | ||
| 1763 | + sch.setsName(""); | ||
| 1764 | + } | ||
| 1765 | + | ||
| 1766 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 1767 | + /** | ||
| 1768 | + * 调整实发 | ||
| 1769 | + */ | ||
| 1770 | + String fcsjActual = map.get("fcsjActual"); | ||
| 1771 | + if (StringUtils.isNotBlank(fcsjActual) | ||
| 1772 | + && !fcsjActual.equals(sch.getFcsjActual())) { | ||
| 1773 | + | ||
| 1774 | + //long t = 0L; | ||
| 1775 | + //小于线路开始运营时间,则默认跨过24点 | ||
| 1776 | + long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), fcsjActual, config); | ||
| 1777 | + /* if (fcsjActual.compareTo(config.getStartOpt()) < 0) | ||
| 1778 | + t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual); | ||
| 1779 | + else | ||
| 1780 | + t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);*/ | ||
| 1781 | + | ||
| 1782 | + fLog.log("调整实发时间", sch.getFcsjActual(), fcsjActual); | ||
| 1783 | + sch.setFcsjActualAll(t); | ||
| 1784 | + //取消应发未到标记 | ||
| 1785 | + //if(sch.isLate2()){ | ||
| 1786 | + // sch.setLate2(false); | ||
| 1787 | + LateAdjustHandle.remove(sch); | ||
| 1788 | + //} | ||
| 1789 | + } else if (StringUtils.isNotEmpty(sch.getFcsjActual()) && StringUtils.isEmpty(fcsjActual)) { | ||
| 1790 | + fLog.log("撤销实发时间", sch.getFcsjActual(), ""); | ||
| 1791 | + //撤销实发 | ||
| 1792 | + revokeRealOutgo(sch.getId()); | ||
| 1793 | + } | ||
| 1794 | + | ||
| 1795 | + /** | ||
| 1796 | + * 调整实达 | ||
| 1797 | + */ | ||
| 1798 | + String zdsjActual = map.get("zdsjActual"); | ||
| 1799 | + if (StringUtils.isNotBlank(zdsjActual) | ||
| 1800 | + && !zdsjActual.equals(sch.getZdsjActual())) { | ||
| 1801 | + | ||
| 1802 | + //调整实达 | ||
| 1803 | + fLog.log("调整实达时间", sch.getZdsjActual(), zdsjActual); | ||
| 1804 | + | ||
| 1805 | + long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), zdsjActual, config); | ||
| 1806 | + sch.setZdsjActualAll(t); | ||
| 1807 | + //路牌下一班起点到达时间 | ||
| 1808 | + ScheduleRealInfo next = dayOfSchedule.nextByLp2(sch); | ||
| 1809 | + if (null != next) { | ||
| 1810 | + next.setQdzArrDatesj(zdsjActual); | ||
| 1811 | + next.setLate2(false); | ||
| 1812 | + ts.add(next); | ||
| 1813 | + } | ||
| 1814 | + | ||
| 1815 | + //重新计算车辆执行班次 | ||
| 1816 | + dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 1817 | + //取消应发未到标记 | ||
| 1818 | + LateAdjustHandle.remove(sch); | ||
| 1819 | + } else if (StringUtils.isNotEmpty(sch.getZdsjActual()) && StringUtils.isEmpty(zdsjActual)) { | ||
| 1820 | + //清除实达时间 | ||
| 1821 | + fLog.log("撤销实达时间", sch.getZdsjActual(), ""); | ||
| 1822 | + sch.clearZdsjActual(); | ||
| 1823 | + //清除路牌下一班起点到达时间 | ||
| 1824 | + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch); | ||
| 1825 | + if (null != next) { | ||
| 1826 | + next.setQdzArrDatesj(null); | ||
| 1827 | + ts.add(next); | ||
| 1828 | + } | ||
| 1829 | + //重新计算车辆执行班次 | ||
| 1830 | + dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 1831 | + } | ||
| 1832 | + | ||
| 1833 | + /** | ||
| 1834 | + * 备注 | ||
| 1835 | + */ | ||
| 1836 | + sch.setRemarks(remarks); | ||
| 1837 | + | ||
| 1838 | + /** | ||
| 1839 | + * 烂班 | ||
| 1840 | + */ | ||
| 1841 | + if (map.get("status") != null | ||
| 1842 | + && Integer.parseInt(map.get("status").toString()) == -1) { | ||
| 1843 | + destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null); | ||
| 1844 | + fLog.log("烂班"); | ||
| 1845 | + } | ||
| 1846 | + | ||
| 1847 | + /** | ||
| 1848 | + * 修改班次里程 | ||
| 1849 | + */ | ||
| 1850 | + String jhlc = map.get("jhlc"); | ||
| 1851 | + if (StringUtils.isNotEmpty(jhlc)) { | ||
| 1852 | + double jhlcNum = Double.parseDouble(jhlc); | ||
| 1853 | + //烂班 | ||
| 1854 | + if (jhlcNum == 0 && sch.getJhlcOrig() != 0 && !sch._isInout() && !sch.isDestroy()) { | ||
| 1855 | + destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null); | ||
| 1856 | + fLog.log("里程设置为0,自动烂班"); | ||
| 1857 | + } else if (jhlcNum != sch.getJhlc()) { | ||
| 1858 | + fLog.log("设置里程", sch.getJhlc(), jhlcNum); | ||
| 1859 | + sch.setJhlc(jhlcNum); | ||
| 1860 | + //临加班次,实际计划一起改 | ||
| 1861 | + if (sch.isSflj()) | ||
| 1862 | + sch.setJhlcOrig(jhlcNum); | ||
| 1863 | + } | ||
| 1864 | + } | ||
| 1865 | + | ||
| 1866 | + /** | ||
| 1867 | + * 修改班次类型 | ||
| 1868 | + */ | ||
| 1869 | + String bcType = map.get("bcType"); | ||
| 1870 | + if (StringUtils.isNotEmpty(bcType) && !bcType.equals(sch.getBcType())) { | ||
| 1871 | + fLog.log("修改班次类型", sch.getBcType(), bcType); | ||
| 1872 | + sch.setBcType(bcType); | ||
| 1873 | + } | ||
| 1874 | + | ||
| 1875 | + //重新计算班次状态 | ||
| 1876 | + sch.calcStatus(); | ||
| 1877 | + dayOfSchedule.save(sch); | ||
| 1878 | + //页面需要更新的班次信息 | ||
| 1879 | + ts.add(sch); | ||
| 1880 | + | ||
| 1881 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1882 | + rs.put("ts", ts); | ||
| 1883 | + | ||
| 1884 | + //日志记录结束 | ||
| 1885 | + fLog.end(); | ||
| 1886 | + } catch (Exception e) { | ||
| 1887 | + logger.error("", e); | ||
| 1888 | + rs.put("status", ResponseCode.ERROR); | ||
| 1889 | + } | ||
| 1890 | + return rs; | ||
| 1891 | + } | ||
| 1892 | + | ||
| 1893 | + @Override | ||
| 1894 | + public Map<String, Object> outgoAdjustAll(String params) { | ||
| 1895 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1896 | + try { | ||
| 1897 | + JSONArray jsonArray = JSONArray.parseArray(params); | ||
| 1898 | + | ||
| 1899 | + ScheduleRealInfo schedule = null; | ||
| 1900 | + JSONObject jsonObj; | ||
| 1901 | + String dfsj; | ||
| 1902 | + long id; | ||
| 1903 | + for (int i = 0; i < jsonArray.size(); i++) { | ||
| 1904 | + jsonObj = jsonArray.getJSONObject(i); | ||
| 1905 | + dfsj = jsonObj.getString("t"); | ||
| 1906 | + id = jsonObj.getLong("id"); | ||
| 1907 | + schedule = dayOfSchedule.get(id); | ||
| 1908 | + | ||
| 1909 | + if (schedule != null) | ||
| 1910 | + outgoAdjust(id, null, dfsj, null, "2", null); | ||
| 1911 | + } | ||
| 1912 | + | ||
| 1913 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1914 | + //将更新的最后一个班次返回,页面会做全量刷新 | ||
| 1915 | + rs.put("t", schedule); | ||
| 1916 | + } catch (Exception e) { | ||
| 1917 | + logger.error("", e); | ||
| 1918 | + rs.put("status", ResponseCode.ERROR); | ||
| 1919 | + } | ||
| 1920 | + return rs; | ||
| 1921 | + } | ||
| 1922 | + | ||
| 1923 | + @Override | ||
| 1924 | + public Map<String, Object> findRouteByLine(String lineCode) { | ||
| 1925 | + Map<String, Object> map = new HashMap<>(); | ||
| 1926 | + //上行 | ||
| 1927 | + Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode); | ||
| 1928 | + map.put("line.id_eq", lineId); | ||
| 1929 | + map.put("directions_eq", 0); | ||
| 1930 | + List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map); | ||
| 1931 | + | ||
| 1932 | + //下行 | ||
| 1933 | + map.put("directions_eq", 1); | ||
| 1934 | + List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map); | ||
| 1935 | + | ||
| 1936 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1937 | + | ||
| 1938 | + String upVectors = "", vec; | ||
| 1939 | + //拼接上行路段 | ||
| 1940 | + for (Map<String, Object> temp : upList) { | ||
| 1941 | + vec = temp.get("sectionBsectionVector").toString(); | ||
| 1942 | + upVectors += vec.subSequence(11, vec.length() - 2) + " "; | ||
| 1943 | + } | ||
| 1944 | + | ||
| 1945 | + //拼接下行路段 | ||
| 1946 | + String downVectors = ""; | ||
| 1947 | + for (Map<String, Object> temp : downList) {//LINESTRING( | ||
| 1948 | + vec = temp.get("sectionBsectionVector").toString(); | ||
| 1949 | + downVectors += vec.subSequence(11, vec.length() - 2) + " "; | ||
| 1950 | + } | ||
| 1951 | + | ||
| 1952 | + | ||
| 1953 | + rs.put("up", upVectors); | ||
| 1954 | + //上行gcj | ||
| 1955 | + rs.put("up_gcj", BdToGcjString(upVectors)); | ||
| 1956 | + rs.put("down", downVectors); | ||
| 1957 | + //下行gcj | ||
| 1958 | + rs.put("down_gcj", BdToGcjString(downVectors)); | ||
| 1959 | + rs.put("lineId", lineId); | ||
| 1960 | + | ||
| 1961 | + return rs; | ||
| 1962 | + } | ||
| 1963 | + | ||
| 1964 | + /** | ||
| 1965 | + * @param @param bdStr | ||
| 1966 | + * @throws | ||
| 1967 | + * @Title: BdToGcjString | ||
| 1968 | + * @Description: TODO(将百度路由字符串 转 成GCJ 字符串) | ||
| 1969 | + */ | ||
| 1970 | + public String BdToGcjString(String bdStr) { | ||
| 1971 | + String[] array = bdStr.split(","), subArray; | ||
| 1972 | + if (array.length == 0 || bdStr.length() < 2) | ||
| 1973 | + return ""; | ||
| 1974 | + | ||
| 1975 | + String gcjStr = ""; | ||
| 1976 | + CoordinateConverter.Location location; | ||
| 1977 | + for (String crd : array) { | ||
| 1978 | + subArray = crd.split(" "); | ||
| 1979 | + if (subArray.length != 2) | ||
| 1980 | + continue; | ||
| 1981 | + location = CoordinateConverter.bd_decrypt(CoordinateConverter.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1]))); | ||
| 1982 | + | ||
| 1983 | + gcjStr += location.getLng() + " " + location.getLat() + ","; | ||
| 1984 | + } | ||
| 1985 | + | ||
| 1986 | + return gcjStr.substring(0, gcjStr.length() - 1); | ||
| 1987 | + } | ||
| 1988 | + | ||
| 1989 | + public List<Map<String, String>> findLine(String line) { | ||
| 1990 | + List<Line> listLine = lineRepository.findLine("%" + line + "%"); | ||
| 1991 | + List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | ||
| 1992 | + Map<String, String> map; | ||
| 1993 | + for (Line temp : listLine) { | ||
| 1994 | + if (temp != null) { | ||
| 1995 | + String xlName = temp.getName(); | ||
| 1996 | + if (xlName.indexOf(line) != -1) { | ||
| 1997 | + map = new HashMap<String, String>(); | ||
| 1998 | + map.put("id", temp.getLineCode()); | ||
| 1999 | + map.put("text", xlName); | ||
| 2000 | + list.add(map); | ||
| 2001 | + } | ||
| 2002 | + } | ||
| 2003 | + } | ||
| 2004 | + return list; | ||
| 2005 | + } | ||
| 2006 | + | ||
| 2007 | + public List<Map<String, String>> findLpName(String lpName) { | ||
| 2008 | + List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%"); | ||
| 2009 | + List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | ||
| 2010 | + Map<String, String> map; | ||
| 2011 | + for (GuideboardInfo temp : listLpName) { | ||
| 2012 | + if (temp != null) { | ||
| 2013 | + String lp = temp.getLpName(); | ||
| 2014 | + if (lp.indexOf(lpName) != -1) { | ||
| 2015 | + map = new HashMap<String, String>(); | ||
| 2016 | + map.put("id", lp); | ||
| 2017 | + map.put("text", lp); | ||
| 2018 | + list.add(map); | ||
| 2019 | + } | ||
| 2020 | + } | ||
| 2021 | + } | ||
| 2022 | + return list; | ||
| 2023 | + } | ||
| 2024 | + | ||
| 2025 | + @Override | ||
| 2026 | + public Map<String, Object> findKMBC2(String jName, String clZbh, String date) { | ||
| 2027 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date, "", ""); | ||
| 2028 | + | ||
| 2029 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 2030 | +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 2031 | +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 2032 | + int jhbc = 0, cjbc = 0, ljbc = 0; | ||
| 2033 | + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0; | ||
| 2034 | + float addMileage = 0l, remMileage = 0l; | ||
| 2035 | + String j_Name = ""; | ||
| 2036 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2037 | + for (ScheduleRealInfo scheduleRealInfo : list) { | ||
| 2038 | + if (scheduleRealInfo != null) { | ||
| 2039 | + j_Name = scheduleRealInfo.getjName(); | ||
| 2040 | + //计划里程(主任务过滤掉临加班次), | ||
| 2041 | + //烂班里程(主任务烂班), | ||
| 2042 | + //临加里程(主任务临加), | ||
| 2043 | + //计划班次,烂班班次,增加班次 | ||
| 2044 | + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | ||
| 2045 | + if (scheduleRealInfo.isSflj()) { | ||
| 2046 | + addMileage += tempJhlc; | ||
| 2047 | + ljbc++; | ||
| 2048 | + } else { | ||
| 2049 | + jhlc += tempJhlc; | ||
| 2050 | + jhbc++; | ||
| 2051 | + if (scheduleRealInfo.getStatus() == -1) { | ||
| 2052 | + remMileage += tempJhlc; | ||
| 2053 | + cjbc++; | ||
| 2054 | + } | ||
| 2055 | + } | ||
| 2056 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 2057 | + //计算营运里程,空驶里程 | ||
| 2058 | + if (childTaskPlans.isEmpty()) { | ||
| 2059 | + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 2060 | + || scheduleRealInfo.getBcType().equals("venting")) { | ||
| 2061 | + ksgl += tempJhlc; | ||
| 2062 | + } else { | ||
| 2063 | + yygl += tempJhlc; | ||
| 2064 | + } | ||
| 2065 | + } else { | ||
| 2066 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 2067 | + while (it.hasNext()) { | ||
| 2068 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 2069 | + if (childTaskPlan.getMileageType().equals("empty")) { | ||
| 2070 | + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 2071 | + } else { | ||
| 2072 | + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 2073 | + } | ||
| 2074 | + } | ||
| 2075 | + } | ||
| 2076 | + } | ||
| 2077 | + } | ||
| 2078 | + map.put("j_name", j_Name); | ||
| 2079 | + map.put("jhlc", format.format(jhlc)); | ||
| 2080 | + map.put("remMileage", format.format(remMileage)); | ||
| 2081 | + map.put("addMileage", format.format(addMileage)); | ||
| 2082 | + map.put("yygl", format.format(yygl)); | ||
| 2083 | + map.put("ksgl", format.format(ksgl)); | ||
| 2084 | + map.put("realMileage", format.format(yygl + ksgl)); | ||
| 2085 | + map.put("jhbc", jhbc); | ||
| 2086 | + map.put("cjbc", cjbc); | ||
| 2087 | + map.put("ljbc", ljbc); | ||
| 2088 | + map.put("sjbc", jhbc - cjbc + ljbc); | ||
| 2089 | + return map; | ||
| 2090 | + } | ||
| 2091 | + | ||
| 2092 | + | ||
| 2093 | + public Map<String, Object> findKMBC(String jGh, String clZbh, | ||
| 2094 | + String lpName, String date, String line) { | ||
| 2095 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2096 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 2097 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2098 | + for (int i = 0; i < list.size(); i++) { | ||
| 2099 | + ScheduleRealInfo s = list.get(i); | ||
| 2100 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2101 | + if (cts != null && cts.size() > 0) { | ||
| 2102 | + lists.add(s); | ||
| 2103 | + } else { | ||
| 2104 | + if (s.getFcsjActual() != null && s.getZdsjActual() != null) { | ||
| 2105 | + lists.add(s); | ||
| 2106 | + } | ||
| 2107 | + } | ||
| 2108 | + } | ||
| 2109 | + map.put("jhbc", culateService.culateJhbc(list, ""));//计划班次 | ||
| 2110 | + map.put("jhlc", Arith.add(culateService.culateJhgl(list), | ||
| 2111 | + culateService.culateJhJccgl(list))); //计划总里程 | ||
| 2112 | + map.put("cjbc", culateService.culateLbbc(list));//烂班班次 | ||
| 2113 | + map.put("remMileage", culateService.culateLbgl(list)); //烂班公里 | ||
| 2114 | + map.put("ljbc", culateService.culateLjbc(lists, ""));//临加班次 | ||
| 2115 | + double ljgl = culateService.culateLjgl(lists); | ||
| 2116 | + map.put("addMileage", ljgl); //临加公里 | ||
| 2117 | + map.put("sjbc", culateService.culateSjbc(lists, "") + culateService.culateLjbc(lists, "")); | ||
| 2118 | + double ksgl = culateService.culateKsgl(list);//子任务空驶公里 | ||
| 2119 | + double jccgl = culateService.culateJccgl(lists);//空驶班次公里 | ||
| 2120 | + map.put("ksgl", ksgl);//空驶公里 | ||
| 2121 | + double sjgl = culateService.culateSjgl(lists);//实际营运公里 | ||
| 2122 | + map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//总公里 | ||
| 2123 | + map.put("zkslc", Arith.add(ksgl, jccgl)); | ||
| 2124 | + map.put("jcclc", jccgl); | ||
| 2125 | + map.put("yygl", Arith.add(sjgl, ljgl)); //总营运公里 | ||
| 2126 | + return map; | ||
| 2127 | + } | ||
| 2128 | + | ||
| 2129 | + public Map<String, Object> findKMBC_mh_2(String jGh, String clZbh, | ||
| 2130 | + String lpName, String date, String line) { | ||
| 2131 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2132 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 2133 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2134 | + for (int i = 0; i < list.size(); i++) { | ||
| 2135 | + ScheduleRealInfo s = list.get(i); | ||
| 2136 | + if (s.isDestroy() && s.isReissue()) { | ||
| 2137 | + s.setRemark(""); | ||
| 2138 | + s.setFcsjActual(s.getDfsj()); | ||
| 2139 | + s.setZdsjActual(s.getZdsj()); | ||
| 2140 | + s.setStatus(2); | ||
| 2141 | + s.setJhlc(s.getJhlcOrig()); | ||
| 2142 | + } | ||
| 2143 | + | ||
| 2144 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2145 | + if (cts != null && cts.size() > 0) { | ||
| 2146 | + lists.add(s); | ||
| 2147 | + } else { | ||
| 2148 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2149 | + lists.add(s); | ||
| 2150 | + } | ||
| 2151 | + } | ||
| 2152 | + } | ||
| 2153 | + double ksgl = culateService.culateKsgl(list); | ||
| 2154 | + double sjgl = culateService.culateSjgl(lists); | ||
| 2155 | + double jccgl = culateService.culateJccgl(lists); | ||
| 2156 | + double ljgl = culateService.culateLjgl(lists); | ||
| 2157 | + | ||
| 2158 | + map.put("jhlc", Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划里程 | ||
| 2159 | + map.put("remMileage", culateService.culateLbgl(list)); //烂班公里 | ||
| 2160 | + map.put("addMileage", ljgl); //临加公里 | ||
| 2161 | + map.put("yygl", Arith.add(sjgl, ljgl)); //实际公里 | ||
| 2162 | + map.put("ksgl", ksgl);//空驶公里 | ||
| 2163 | + map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl))); | ||
| 2164 | +// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage)); | ||
| 2165 | + map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 2166 | + map.put("cjbc", culateService.culateLbbc(list)); | ||
| 2167 | + map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2168 | + map.put("sjbc", culateService.culateJhbc(lists, "") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists, "")); | ||
| 2169 | + map.put("jcclc", jccgl); | ||
| 2170 | + map.put("zkslc", Arith.add(ksgl, jccgl)); | ||
| 2171 | +// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc)); | ||
| 2172 | + return map; | ||
| 2173 | + } | ||
| 2174 | + | ||
| 2175 | + | ||
| 2176 | + @Override | ||
| 2177 | + public List<Map<String, Object>> accountPx(String line, String date, | ||
| 2178 | + String code, String xlName, String px) { | ||
| 2179 | +// List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px); | ||
| 2180 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 2181 | + if (!code.trim().equals("")) { | ||
| 2182 | + code = BasicData.deviceId2NbbmMap.inverse().get(code); | ||
| 2183 | + } | ||
| 2184 | + String fgs = ""; | ||
| 2185 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2186 | + if (lineList.size() > 0) { | ||
| 2187 | + Line l = lineList.get(0); | ||
| 2188 | + fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany()); | ||
| 2189 | + } | ||
| 2190 | + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 2191 | + String sql = "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ," | ||
| 2192 | + + " device_id FROM bsth_v_report_80 WHERE " | ||
| 2193 | + + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '" + date + "' AND" | ||
| 2194 | + + " line_id = '" + line + "' and device_id like '%" + code + "%'"; | ||
| 2195 | + Map<String, Object> map; | ||
| 2196 | + List<Object[]> lsitObj = jdbcTemplate.query(sql, | ||
| 2197 | + new RowMapper<Object[]>() { | ||
| 2198 | + @Override | ||
| 2199 | + public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 2200 | + Object[] t = new Object[3]; | ||
| 2201 | + t[0] = rs.getString("request_code"); | ||
| 2202 | + t[1] = rs.getString("TIMESTAMP"); | ||
| 2203 | + t[2] = rs.getString("device_id"); | ||
| 2204 | + return t; | ||
| 2205 | + } | ||
| 2206 | + }); | ||
| 2207 | + int i = 1; | ||
| 2208 | + for (Object[] obj : lsitObj) { | ||
| 2209 | + if (obj != null) { | ||
| 2210 | + map = new HashMap<String, Object>(); | ||
| 2211 | + map.put("num", i++); | ||
| 2212 | + map.put("xlName", xlName); | ||
| 2213 | + if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) { | ||
| 2214 | + List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | ||
| 2215 | + try { | ||
| 2216 | + carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString())); | ||
| 2217 | + } catch (Exception e) { | ||
| 2218 | + // TODO Auto-generated catch block | ||
| 2219 | + e.printStackTrace(); | ||
| 2220 | + } | ||
| 2221 | + if (carDeviceList.size() > 0) { | ||
| 2222 | + map.put("clZbh", carDeviceList.get(0).getClZbh()); | ||
| 2223 | + | ||
| 2224 | + } else { | ||
| 2225 | + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2226 | + } | ||
| 2227 | + } else { | ||
| 2228 | + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2229 | + | ||
| 2230 | + } | ||
| 2231 | + map.put("company", fgs); | ||
| 2232 | + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase()); | ||
| 2233 | + map.put("requestTime", obj[1]); | ||
| 2234 | + listMap.add(map); | ||
| 2235 | + } | ||
| 2236 | + } | ||
| 2237 | + if (listMap.size() > 1) { | ||
| 2238 | + if (px.equals("asc")) { | ||
| 2239 | + Collections.sort(listMap, new AccountMap()); | ||
| 2240 | + } else { | ||
| 2241 | + Collections.sort(listMap, new AccountMap2()); | ||
| 2242 | + } | ||
| 2243 | + } | ||
| 2244 | + return listMap; | ||
| 2245 | + } | ||
| 2246 | + | ||
| 2247 | + @Override | ||
| 2248 | + public List<Map<String, Object>> account(String line, String date, | ||
| 2249 | + String code, String xlName, String type) { | ||
| 2250 | + if (!code.trim().equals("")) { | ||
| 2251 | + code = BasicData.deviceId2NbbmMap.inverse().get(code); | ||
| 2252 | + } | ||
| 2253 | + String fgs = ""; | ||
| 2254 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2255 | + if (lineList.size() > 0) { | ||
| 2256 | + Line l = lineList.get(0); | ||
| 2257 | + fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany()); | ||
| 2258 | + } | ||
| 2259 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 2260 | + List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code); | ||
| 2261 | + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 2262 | + Map<String, Object> map; | ||
| 2263 | + int i = 1; | ||
| 2264 | + for (Object[] obj : lsitObj) { | ||
| 2265 | + if (obj != null) { | ||
| 2266 | + map = new HashMap<String, Object>(); | ||
| 2267 | + map.put("num", i++); | ||
| 2268 | + map.put("xlName", xlName); | ||
| 2269 | + if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) { | ||
| 2270 | + List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | ||
| 2271 | + try { | ||
| 2272 | + carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString())); | ||
| 2273 | + } catch (Exception e) { | ||
| 2274 | + // TODO Auto-generated catch block | ||
| 2275 | + e.printStackTrace(); | ||
| 2276 | + } | ||
| 2277 | + if (carDeviceList.size() > 0) { | ||
| 2278 | + map.put("clZbh", carDeviceList.get(0).getClZbh()); | ||
| 2279 | + | ||
| 2280 | + } else { | ||
| 2281 | + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2282 | + } | ||
| 2283 | + } else { | ||
| 2284 | + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | ||
| 2285 | + | ||
| 2286 | + } | ||
| 2287 | + map.put("company", fgs); | ||
| 2288 | + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase()); | ||
| 2289 | + map.put("requestTime", obj[1]); | ||
| 2290 | + listMap.add(map); | ||
| 2291 | + } | ||
| 2292 | + } | ||
| 2293 | + | ||
| 2294 | + if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 2295 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2296 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2297 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2298 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2299 | + ReportUtils ee = new ReportUtils(); | ||
| 2300 | + Map<String, Object> typeMap = new HashMap<String, Object>(); | ||
| 2301 | + typeMap.put("0xA1", "请求恢复运营"); | ||
| 2302 | + typeMap.put("0xA2", "申请调档"); | ||
| 2303 | + typeMap.put("0xA3", "出场请求"); | ||
| 2304 | + typeMap.put("0xA5", "进场请求"); | ||
| 2305 | + typeMap.put("0xA7", "加油请求"); | ||
| 2306 | + typeMap.put("0x50", "车辆故障"); | ||
| 2307 | + typeMap.put("0x70", "路阻报告"); | ||
| 2308 | + typeMap.put("0x60", "事故报告"); | ||
| 2309 | + typeMap.put("0x11", "扣证纠纷"); | ||
| 2310 | + typeMap.put("0x12", "报警"); | ||
| 2311 | + for (Map<String, Object> map1 : listMap) { | ||
| 2312 | + map1.put("requestText", typeMap.get(map1.get("requestType"))); | ||
| 2313 | + } | ||
| 2314 | + try { | ||
| 2315 | + listI.add(listMap.iterator()); | ||
| 2316 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2317 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/account.xls", | ||
| 2318 | + path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | ||
| 2319 | + + "-" + xlName + "-驾驶员请求台账.xls"); | ||
| 2320 | + } catch (Exception e) { | ||
| 2321 | + // TODO: handle exception | ||
| 2322 | + e.printStackTrace(); | ||
| 2323 | + } | ||
| 2324 | + } | ||
| 2325 | + | ||
| 2326 | + return listMap; | ||
| 2327 | + } | ||
| 2328 | + | ||
| 2329 | + @Override | ||
| 2330 | + public List<SchEditInfoDto> correctForm(String line, String date, String endDate, | ||
| 2331 | + String lpName, String code, String type, String changType) { | ||
| 2332 | + | ||
| 2333 | +// var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '计划烂班', 'CXLB': '撤销烂班', | ||
| 2334 | +// 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'}; | ||
| 2335 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2336 | + map.put("DFTZ", "待发调整"); | ||
| 2337 | + map.put("FCXXWT", "发车信息微调"); | ||
| 2338 | + map.put("JHLB", "计划烂班"); | ||
| 2339 | + map.put("CXLB", "撤销烂班"); | ||
| 2340 | + map.put("CXZX", "撤销执行"); | ||
| 2341 | + map.put("CXSF", "撤销实发"); | ||
| 2342 | + map.put("SFTZ", "实发调整"); | ||
| 2343 | + map.put("TZRC", "调整人车"); | ||
| 2344 | + | ||
| 2345 | + SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm"); | ||
| 2346 | + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 2347 | + String cont = ""; | ||
| 2348 | + cont = " and xl_bm ='" + line + "'"; | ||
| 2349 | + if (!lpName.equals("")) { | ||
| 2350 | + cont += " and lp_name = '" + lpName + "'"; | ||
| 2351 | + } | ||
| 2352 | + if (!code.equals("")) { | ||
| 2353 | + cont += " and cl_zbh ='" + code + "'"; | ||
| 2354 | + } | ||
| 2355 | + String sql = "select t1.*, t2.real_exec_date," | ||
| 2356 | + + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name," | ||
| 2357 | + + "t2.xl_dir,t2.real_exec_date from (select * from " | ||
| 2358 | + + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )" | ||
| 2359 | + + " t1 INNER JOIN bsth_c_s_sp_info_real t2 on " | ||
| 2360 | + + "t1.sch_id=t2.id where 1=1 " + cont; | ||
| 2361 | + | ||
| 2362 | + List<SchEditInfoDto> list = jdbcTemplate.query(sql, | ||
| 2363 | + new BeanPropertyRowMapper(SchEditInfoDto.class), date, endDate, line); | ||
| 2364 | + List<SchEditInfoDto> lists = new ArrayList<SchEditInfoDto>(); | ||
| 2365 | + for (int i = 0; i < list.size(); i++) { | ||
| 2366 | + Long fcsjs = 0l; | ||
| 2367 | + Long updsj = 0l; | ||
| 2368 | + SchEditInfoDto t = list.get(i); | ||
| 2369 | + if (map.get(t.getType()) != null) { | ||
| 2370 | + | ||
| 2371 | + if (changType.equals("")) { | ||
| 2372 | + t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | ||
| 2373 | + } else { | ||
| 2374 | + String fcsj = ""; | ||
| 2375 | + String updtime = ""; | ||
| 2376 | + try { | ||
| 2377 | + fcsj = sdf1.format(sdf1.parse(t.getFcsj())); | ||
| 2378 | + updtime = sdf1.format(sdf1.parse(t.getTimeStr())); | ||
| 2379 | + fcsjs = sdf2.parse(t.getRealExecDate() + " " + fcsj).getTime(); | ||
| 2380 | + updsj = sdf2.parse(t.getRq() + " " + updtime).getTime(); | ||
| 2381 | + } catch (ParseException e) { | ||
| 2382 | + // TODO Auto-generated catch block | ||
| 2383 | + e.printStackTrace(); | ||
| 2384 | + } | ||
| 2385 | + if (changType.equals("1")) { | ||
| 2386 | + if (fcsjs > updsj) { | ||
| 2387 | + t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | ||
| 2388 | + } else { | ||
| 2389 | + t.setType2(""); | ||
| 2390 | + } | ||
| 2391 | + } else if (changType.equals("2")) { | ||
| 2392 | + if (fcsjs < updsj) { | ||
| 2393 | + t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | ||
| 2394 | + } else { | ||
| 2395 | + t.setType2(""); | ||
| 2396 | + } | ||
| 2397 | + } | ||
| 2398 | + } | ||
| 2399 | + } else { | ||
| 2400 | + t.setType2(""); | ||
| 2401 | + } | ||
| 2402 | + boolean fage = true; | ||
| 2403 | + for (int j = 0; j < lists.size(); j++) { | ||
| 2404 | + SchEditInfoDto s = lists.get(j); | ||
| 2405 | + if (s.getSchId() == t.getSchId()) { | ||
| 2406 | + s.setType2(s.getType2() + " " + t.getType2()); | ||
| 2407 | + fage = false; | ||
| 2408 | + } | ||
| 2409 | + } | ||
| 2410 | + | ||
| 2411 | + if (fage) { | ||
| 2412 | + if (changType.equals("")) { | ||
| 2413 | + lists.add(t); | ||
| 2414 | + } else { | ||
| 2415 | + if (changType.equals("1")) { | ||
| 2416 | + if (fcsjs > updsj) { | ||
| 2417 | + lists.add(t); | ||
| 2418 | + } | ||
| 2419 | + } else if (changType.equals("2")) { | ||
| 2420 | + if (fcsjs < updsj) { | ||
| 2421 | + lists.add(t); | ||
| 2422 | + } | ||
| 2423 | + } | ||
| 2424 | + } | ||
| 2425 | + } | ||
| 2426 | + } | ||
| 2427 | + | ||
| 2428 | + if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 2429 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2430 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2431 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2432 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2433 | + m.put("dates", date); | ||
| 2434 | + ReportUtils ee = new ReportUtils(); | ||
| 2435 | + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 2436 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 2437 | + for (SchEditInfoDto d : lists) { | ||
| 2438 | + Map<String, Object> tempMap = new HashMap<String, Object>(); | ||
| 2439 | + tempMap.put("lpName", d.getLpName()); | ||
| 2440 | + tempMap.put("rq", d.getRq()); | ||
| 2441 | + tempMap.put("clZbh", d.getClZbh()); | ||
| 2442 | + tempMap.put("jName", d.getjName() + "/" + d.getjGh()); | ||
| 2443 | + tempMap.put("fcsj", d.getFcsj()); | ||
| 2444 | + tempMap.put("type", d.getType2()); | ||
| 2445 | + tempList.add(tempMap); | ||
| 2446 | + } | ||
| 2447 | + try { | ||
| 2448 | + String dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 2449 | + if(!endDate.equals(date)){ | ||
| 2450 | + dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate)); | ||
| 2451 | + } | ||
| 2452 | + String lineName = BasicData.lineCode2NameMap.get(line); | ||
| 2453 | + listI.add(tempList.iterator()); | ||
| 2454 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2455 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/correctForm.xls", | ||
| 2456 | + path + "export/" + dateTime + "-" + lineName + "-修正报表.xls"); | ||
| 2457 | + } catch (Exception e) { | ||
| 2458 | + // TODO: handle exception | ||
| 2459 | + e.printStackTrace(); | ||
| 2460 | + } | ||
| 2461 | +// Map<String, Object> maps = tempList.get(tempList.size() - 1); | ||
| 2462 | + } | ||
| 2463 | + return lists; | ||
| 2464 | + } | ||
| 2465 | + | ||
| 2466 | + @Override | ||
| 2467 | + public List<ScheduleRealInfo> queryListWaybill(String jGh, String clZbh, | ||
| 2468 | + String lpName, String date, String line) { | ||
| 2469 | + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 2470 | + List<ScheduleRealInfo> list = null; | ||
| 2471 | + list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | ||
| 2472 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 2473 | + String minfcsj = "02:00"; | ||
| 2474 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2475 | + if (lineList.size() > 0) { | ||
| 2476 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 2477 | + + " id = (" | ||
| 2478 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 2479 | + + ")"; | ||
| 2480 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 2481 | + } | ||
| 2482 | + String[] minSjs = minfcsj.split(":"); | ||
| 2483 | + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 2484 | + | ||
| 2485 | + for (int i = 0; i < list.size(); i++) { | ||
| 2486 | + ScheduleRealInfo s = list.get(i); | ||
| 2487 | + if (s.getBcType().equals("out")) { | ||
| 2488 | + s.setRemark("1"); | ||
| 2489 | + } else if (s.getBcType().equals("in")) { | ||
| 2490 | + s.setRemark("3"); | ||
| 2491 | + } else { | ||
| 2492 | + s.setRemark("2"); | ||
| 2493 | + } | ||
| 2494 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 2495 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 2496 | + | ||
| 2497 | + Long fscjT = 0L; | ||
| 2498 | + if (fcsjL < minSj) { | ||
| 2499 | + Calendar calendar = new GregorianCalendar(); | ||
| 2500 | + calendar.setTime(s.getScheduleDate()); | ||
| 2501 | + calendar.add(calendar.DATE, 1); | ||
| 2502 | + s.setScheduleDate(calendar.getTime()); | ||
| 2503 | + try { | ||
| 2504 | + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 2505 | + } catch (ParseException e) { | ||
| 2506 | + // TODO Auto-generated catch block | ||
| 2507 | + e.printStackTrace(); | ||
| 2508 | + } | ||
| 2509 | + | ||
| 2510 | + } else { | ||
| 2511 | + try { | ||
| 2512 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 2513 | + } catch (ParseException e) { | ||
| 2514 | + // TODO Auto-generated catch block | ||
| 2515 | + e.printStackTrace(); | ||
| 2516 | + } | ||
| 2517 | + ; | ||
| 2518 | + } | ||
| 2519 | + s.setFcsjT(fscjT); | ||
| 2520 | + } | ||
| 2521 | + Collections.sort(list, new compareFcsjType()); | ||
| 2522 | + for (int i = 0; i < list.size(); i++) { | ||
| 2523 | + ScheduleRealInfo s = list.get(i); | ||
| 2524 | + s.setAdjustExps(i + 1 + ""); | ||
| 2525 | + String remarks = ""; | ||
| 2526 | + if (s.getRemarks() != null) { | ||
| 2527 | + remarks += s.getRemarks(); | ||
| 2528 | + } | ||
| 2529 | + | ||
| 2530 | + Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 2531 | + if (!childTaskPlans.isEmpty()) { | ||
| 2532 | + s.setFcsjActual(""); | ||
| 2533 | + s.setZdsjActual(""); | ||
| 2534 | + s.setJhlc(0.0); | ||
| 2535 | + } | ||
| 2536 | + | ||
| 2537 | + if (s.isDestroy()) { | ||
| 2538 | + s.setFcsjActual(""); | ||
| 2539 | + s.setZdsjActual(""); | ||
| 2540 | + s.setJhlc(0.0); | ||
| 2541 | + remarks += "(烂班)"; | ||
| 2542 | + s.setRemarks(remarks); | ||
| 2543 | + } | ||
| 2544 | + | ||
| 2545 | + listSchedule.add(s); | ||
| 2546 | + //计算营运里程,空驶里程 | ||
| 2547 | + if (!childTaskPlans.isEmpty()) { | ||
| 2548 | +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 2549 | + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 2550 | + Collections.sort(listit, new ComparableChild()); | ||
| 2551 | + for (int j = 0; j < listit.size(); j++) { | ||
| 2552 | + ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 2553 | + ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 2554 | + if (childTaskPlan.getCcId() == null) { | ||
| 2555 | + if (childTaskPlan.isDestroy()) { | ||
| 2556 | + t.setFcsjActual(""); | ||
| 2557 | + t.setZdsjActual(""); | ||
| 2558 | + t.setJhlc(0.0); | ||
| 2559 | + } else { | ||
| 2560 | + t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 2561 | + t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 2562 | + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 2563 | + } | ||
| 2564 | + t.setFcsj(childTaskPlan.getStartDate()); | ||
| 2565 | + t.setZdsj(childTaskPlan.getEndDate()); | ||
| 2566 | + t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 2567 | + t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 2568 | + t.setRemarks(childTaskPlan.getRemarks()); | ||
| 2569 | + t.setAdjustExps("子"); | ||
| 2570 | + listSchedule.add(t); | ||
| 2571 | + } | ||
| 2572 | + } | ||
| 2573 | + } | ||
| 2574 | + } | ||
| 2575 | + | ||
| 2576 | + return listSchedule; | ||
| 2577 | + } | ||
| 2578 | + | ||
| 2579 | + @Override | ||
| 2580 | + public List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh, | ||
| 2581 | + String lpName, String date, String line) { | ||
| 2582 | + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 2583 | + List<ScheduleRealInfo> list = null; | ||
| 2584 | + list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line); | ||
| 2585 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 2586 | + String minfcsj = "02:00"; | ||
| 2587 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 2588 | + if (lineList.size() > 0) { | ||
| 2589 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 2590 | + + " id = (" | ||
| 2591 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 2592 | + + ")"; | ||
| 2593 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 2594 | + } | ||
| 2595 | + String[] minSjs = minfcsj.split(":"); | ||
| 2596 | + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 2597 | + | ||
| 2598 | + for (int i = 0; i < list.size(); i++) { | ||
| 2599 | + ScheduleRealInfo s = list.get(i); | ||
| 2600 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 2601 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 2602 | + | ||
| 2603 | + Long fscjT = 0L; | ||
| 2604 | + if (fcsjL < minSj) { | ||
| 2605 | + Calendar calendar = new GregorianCalendar(); | ||
| 2606 | + calendar.setTime(s.getScheduleDate()); | ||
| 2607 | + calendar.add(calendar.DATE, 1); | ||
| 2608 | + s.setScheduleDate(calendar.getTime()); | ||
| 2609 | + try { | ||
| 2610 | + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 2611 | + } catch (ParseException e) { | ||
| 2612 | + // TODO Auto-generated catch block | ||
| 2613 | + e.printStackTrace(); | ||
| 2614 | + } | ||
| 2615 | + | ||
| 2616 | + } else { | ||
| 2617 | + try { | ||
| 2618 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 2619 | + } catch (ParseException e) { | ||
| 2620 | + // TODO Auto-generated catch block | ||
| 2621 | + e.printStackTrace(); | ||
| 2622 | + } | ||
| 2623 | + ; | ||
| 2624 | + } | ||
| 2625 | + s.setFcsjT(fscjT); | ||
| 2626 | + } | ||
| 2627 | + Collections.sort(list, new ComparableReal()); | ||
| 2628 | + for (int i = 0; i < list.size(); i++) { | ||
| 2629 | + ScheduleRealInfo s = list.get(i); | ||
| 2630 | + s.setAdjustExps(i + 1 + ""); | ||
| 2631 | + String remarks = ""; | ||
| 2632 | + if (s.getRemarks() != null) { | ||
| 2633 | + remarks += s.getRemarks(); | ||
| 2634 | + } | ||
| 2635 | + | ||
| 2636 | + Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 2637 | + if (!childTaskPlans.isEmpty()) { | ||
| 2638 | + s.setFcsjActual(""); | ||
| 2639 | + s.setZdsjActual(""); | ||
| 2640 | + s.setJhlc(0.0); | ||
| 2641 | + } | ||
| 2642 | + | ||
| 2643 | + if (s.isDestroy()) { | ||
| 2644 | + if (s.isReissue()) { | ||
| 2645 | + s.setFcsjActual(s.getDfsj()); | ||
| 2646 | + s.setZdsjActual(s.getZdsj()); | ||
| 2647 | + s.setRemarks(""); | ||
| 2648 | + s.setStatus(2); | ||
| 2649 | + s.setJhlc(s.getJhlcOrig()); | ||
| 2650 | + } else { | ||
| 2651 | + s.setFcsjActual(""); | ||
| 2652 | + s.setZdsjActual(""); | ||
| 2653 | + s.setJhlc(0.0); | ||
| 2654 | + remarks += "(烂班)"; | ||
| 2655 | + s.setRemarks(remarks); | ||
| 2656 | + } | ||
| 2657 | + } | ||
| 2658 | + | ||
| 2659 | + listSchedule.add(s); | ||
| 2660 | + //计算营运里程,空驶里程 | ||
| 2661 | + if (!childTaskPlans.isEmpty()) { | ||
| 2662 | +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 2663 | + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 2664 | + Collections.sort(listit, new ComparableChild()); | ||
| 2665 | + for (int j = 0; j < listit.size(); j++) { | ||
| 2666 | + ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 2667 | + ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 2668 | + if (childTaskPlan.isDestroy()) { | ||
| 2669 | + t.setFcsjActual(""); | ||
| 2670 | + t.setZdsjActual(""); | ||
| 2671 | + t.setJhlc(0.0); | ||
| 2672 | + } else { | ||
| 2673 | + t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 2674 | + t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 2675 | + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 2676 | + } | ||
| 2677 | + t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 2678 | + t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 2679 | + t.setRemarks(childTaskPlan.getRemarks()); | ||
| 2680 | + t.setAdjustExps("子"); | ||
| 2681 | + listSchedule.add(t); | ||
| 2682 | + } | ||
| 2683 | + } | ||
| 2684 | + } | ||
| 2685 | + | ||
| 2686 | + return listSchedule; | ||
| 2687 | + } | ||
| 2688 | + | ||
| 2689 | + @Override | ||
| 2690 | + public Map<String, Object> removeChildTask(Long taskId) { | ||
| 2691 | + Map<String, Object> rs = new HashMap<>(); | ||
| 2692 | + ChildTaskPlan chTask = cTaskPlanRepository.findById(taskId).get(); | ||
| 2693 | + | ||
| 2694 | + ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId()); | ||
| 2695 | + try { | ||
| 2696 | + | ||
| 2697 | + sch.getcTasks().remove(chTask); | ||
| 2698 | + scheduleRealInfoRepository.save(sch); | ||
| 2699 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 2700 | + } catch (Exception e) { | ||
| 2701 | + logger.error("", e); | ||
| 2702 | + rs.put("status", ResponseCode.ERROR); | ||
| 2703 | + } | ||
| 2704 | + return rs; | ||
| 2705 | + } | ||
| 2706 | + | ||
| 2707 | + @Override | ||
| 2708 | + public List<Map<String, Object>> statisticsDaily(String line, String date, | ||
| 2709 | + String xlName, String type) { | ||
| 2710 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 2711 | + List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | ||
| 2712 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2713 | + for (int i = 0; i < list_s.size(); i++) { | ||
| 2714 | + ScheduleRealInfo s = list_s.get(i); | ||
| 2715 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2716 | + if (cts != null && cts.size() > 0) { | ||
| 2717 | + lists.add(s); | ||
| 2718 | + } else { | ||
| 2719 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2720 | + lists.add(s); | ||
| 2721 | + } | ||
| 2722 | + } | ||
| 2723 | + } | ||
| 2724 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2725 | + map.put("xlName", xlName); | ||
| 2726 | + double jhlc = culateService.culateJhgl(list_s); | ||
| 2727 | + map.put("jhlc", jhlc); | ||
| 2728 | + map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists))); | ||
| 2729 | + double lbgl = culateService.culateLbgl(list_s); | ||
| 2730 | + map.put("ssgl", lbgl); | ||
| 2731 | + map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); | ||
| 2732 | + map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | ||
| 2733 | + map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | ||
| 2734 | + map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | ||
| 2735 | + map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | ||
| 2736 | + map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | ||
| 2737 | + map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | ||
| 2738 | + map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | ||
| 2739 | + map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | ||
| 2740 | + map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | ||
| 2741 | + map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚")); | ||
| 2742 | + double ssgl_pc = culateService.culateCJLC(list_s, "配车"); | ||
| 2743 | + double ssgl_by = culateService.culateCJLC(list_s, "保养"); | ||
| 2744 | + double ssgl_cj = culateService.culateCJLC(list_s, "抽减"); | ||
| 2745 | + double ssgl_qt = culateService.culateCJLC(list_s, "其他"); | ||
| 2746 | + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 2747 | + map.put("ssbc", culateService.culateLbbc(list_s)); | ||
| 2748 | + double ljgl = culateService.culateLjgl(lists); | ||
| 2749 | + map.put("ljgl", ljgl); | ||
| 2750 | + map.put("jhbc", culateService.culateJhbc(list_s, "")); | ||
| 2751 | + map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | ||
| 2752 | + map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | ||
| 2753 | + map.put("sjbc", culateService.culateSjbc(lists, "")); | ||
| 2754 | + map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | ||
| 2755 | + map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | ||
| 2756 | + map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2757 | + map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | ||
| 2758 | + map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | ||
| 2759 | + map.put("fzbc", culateService.culateFzbc(lists, "")); | ||
| 2760 | + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | ||
| 2761 | + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | ||
| 2762 | + map.put("dtbc", 0); | ||
| 2763 | + map.put("dtbc_m", 0); | ||
| 2764 | + map.put("dtbc_a", 0); | ||
| 2765 | + List<CalcInterval> intervalList=calcIntervalRepository.selectByDateAndLine(line, date,""); | ||
| 2766 | + if(intervalList.size()>0){ | ||
| 2767 | + CalcInterval c=intervalList.get(0); | ||
| 2768 | + map.put("djg",c.getDjgAll()); | ||
| 2769 | + map.put("djg_m", c.getDjgZgf()); | ||
| 2770 | + map.put("djg_a", c.getDjgWgf()); | ||
| 2771 | + map.put("djg_time", c.getDjgTime()); | ||
| 2772 | + }else{ | ||
| 2773 | + Map<String, Object> m = culateService.culateDjg(list_s, line); | ||
| 2774 | + map.put("djg", m.get("djgcsq")); | ||
| 2775 | + map.put("djg_m", m.get("djgcsz")); | ||
| 2776 | + map.put("djg_a", m.get("djgcsw")); | ||
| 2777 | + map.put("djg_time", m.get("djgsj")); | ||
| 2778 | + } | ||
| 2779 | + | ||
| 2780 | + map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl)); | ||
| 2781 | + lMap.add(map); | ||
| 2782 | + | ||
| 2783 | + if (date.length() == 10) { | ||
| 2784 | + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59"); | ||
| 2785 | + String dbdp = ""; | ||
| 2786 | + try { | ||
| 2787 | + for (int i = 0; i < list.size(); i++) { | ||
| 2788 | + DutyEmployee t = list.get(i); | ||
| 2789 | + if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 2790 | + if (!(dbdp.length() > 0)) { | ||
| 2791 | + dbdp = t.getuName(); | ||
| 2792 | + } else { | ||
| 2793 | + dbdp += "," + t.getuName(); | ||
| 2794 | + } | ||
| 2795 | + } | ||
| 2796 | + } | ||
| 2797 | + } catch (Exception e) { | ||
| 2798 | + // TODO: handle exception | ||
| 2799 | + e.printStackTrace(); | ||
| 2800 | + } | ||
| 2801 | + map.put("dbdp", dbdp); | ||
| 2802 | + } | ||
| 2803 | + | ||
| 2804 | + return lMap; | ||
| 2805 | + } | ||
| 2806 | + | ||
| 2807 | + @Override | ||
| 2808 | + public List<Map<String, Object>> statisticsDaily_mh_2(String line, String date, | ||
| 2809 | + String xlName, String type) { | ||
| 2810 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 2811 | + List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | ||
| 2812 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2813 | + for (int i = 0; i < list_s.size(); i++) { | ||
| 2814 | + ScheduleRealInfo s = list_s.get(i); | ||
| 2815 | + if (s.isDestroy() && s.isReissue()) { | ||
| 2816 | + s.setRemark(""); | ||
| 2817 | + s.setFcsjActual(s.getDfsj()); | ||
| 2818 | + s.setZdsjActual(s.getZdsj()); | ||
| 2819 | + s.setStatus(2); | ||
| 2820 | + s.setJhlc(s.getJhlcOrig()); | ||
| 2821 | + } | ||
| 2822 | + | ||
| 2823 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2824 | + if (cts != null && cts.size() > 0) { | ||
| 2825 | + lists.add(s); | ||
| 2826 | + } else { | ||
| 2827 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2828 | + lists.add(s); | ||
| 2829 | + } | ||
| 2830 | + } | ||
| 2831 | + } | ||
| 2832 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2833 | + map.put("xlName", xlName); | ||
| 2834 | + double jhlc = culateService.culateJhgl(list_s); | ||
| 2835 | + map.put("jhlc", jhlc); | ||
| 2836 | + map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists))); | ||
| 2837 | + double lbgl = culateService.culateLbgl(list_s); | ||
| 2838 | + map.put("ssgl", lbgl); | ||
| 2839 | + map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); | ||
| 2840 | + map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | ||
| 2841 | + map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | ||
| 2842 | + map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | ||
| 2843 | + map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | ||
| 2844 | + map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | ||
| 2845 | + map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | ||
| 2846 | + map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | ||
| 2847 | + map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | ||
| 2848 | + map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | ||
| 2849 | + map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚")); | ||
| 2850 | + double ssgl_pc = culateService.culateCJLC(list_s, "配车"); | ||
| 2851 | + double ssgl_by = culateService.culateCJLC(list_s, "保养"); | ||
| 2852 | + double ssgl_cj = culateService.culateCJLC(list_s, "抽减"); | ||
| 2853 | + double ssgl_qt = culateService.culateCJLC(list_s, "其他"); | ||
| 2854 | + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 2855 | + map.put("ssbc", culateService.culateLbbc(list_s)); | ||
| 2856 | + double ljgl = culateService.culateLjgl(lists); | ||
| 2857 | + map.put("ljgl", ljgl); | ||
| 2858 | + map.put("jhbc", culateService.culateJhbc(list_s, "")); | ||
| 2859 | + map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | ||
| 2860 | + map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | ||
| 2861 | + map.put("sjbc", culateService.culateSjbc(lists, "")); | ||
| 2862 | + map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | ||
| 2863 | + map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | ||
| 2864 | + map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2865 | + map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | ||
| 2866 | + map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | ||
| 2867 | + map.put("fzbc", culateService.culateFzbc(lists, "")); | ||
| 2868 | + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | ||
| 2869 | + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | ||
| 2870 | + map.put("dtbc", 0); | ||
| 2871 | + map.put("dtbc_m", 0); | ||
| 2872 | + map.put("dtbc_a", 0); | ||
| 2873 | + map.put("djg", 0); | ||
| 2874 | + map.put("djg_m", 0); | ||
| 2875 | + map.put("djg_a", 0); | ||
| 2876 | + map.put("djg_time", 0); | ||
| 2877 | + map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl)); | ||
| 2878 | + lMap.add(map); | ||
| 2879 | + return lMap; | ||
| 2880 | + } | ||
| 2881 | + | ||
| 2882 | + public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,Map<String, Object> m) { | ||
| 2883 | + | ||
| 2884 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 2885 | + for (int i = 0; i < list.size(); i++) { | ||
| 2886 | + ScheduleRealInfo s = list.get(i); | ||
| 2887 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 2888 | + if (cts != null && cts.size() > 0) { | ||
| 2889 | + lists.add(s); | ||
| 2890 | + } else { | ||
| 2891 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 2892 | + lists.add(s); | ||
| 2893 | + } | ||
| 2894 | + } | ||
| 2895 | + } | ||
| 2896 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 2897 | + if (list.size() > 0) { | ||
| 2898 | + map.put("gsBm", list.get(0).getGsBm()); | ||
| 2899 | + map.put("fgsBm", list.get(0).getFgsBm()); | ||
| 2900 | + map.put("xlBm", list.get(0).getXlBm()); | ||
| 2901 | + map.put("xlName", list.get(0).getXlName()); | ||
| 2902 | + map.put("fgsName", list.get(0).getFgsName()); | ||
| 2903 | + map.put("gsName", list.get(0).getGsName()); | ||
| 2904 | + | ||
| 2905 | + try { | ||
| 2906 | + map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getGsBm()+list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE)); | ||
| 2907 | + } catch (PinyinException e) { | ||
| 2908 | + // TODO Auto-generated catch block | ||
| 2909 | + e.printStackTrace(); | ||
| 2910 | + } | ||
| 2911 | + double jhyygl = culateService.culateJhgl(list);//计划营运公里 | ||
| 2912 | + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 2913 | + map.put("jhlc", jhyygl); | ||
| 2914 | + map.put("jcclc", jhjcclc); | ||
| 2915 | + map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | ||
| 2916 | + double ljks=culateService.culateLjksgl(lists); | ||
| 2917 | + map.put("ljks", ljks); | ||
| 2918 | + double ljgl = culateService.culateLjgl(lists); | ||
| 2919 | + double sjyygl = culateService.culateSjgl(lists); | ||
| 2920 | + double zyygl = Arith.add(sjyygl, ljgl); | ||
| 2921 | + | ||
| 2922 | + double sjjccgl = culateService.culateJccgl(lists); | ||
| 2923 | + double sjksgl = culateService.culateKsgl(lists); | ||
| 2924 | + double zksgl = Arith.add(sjjccgl, sjksgl); | ||
| 2925 | + map.put("sjzgl", Arith.add(zyygl, zksgl)); | ||
| 2926 | + map.put("sjgl", zyygl); | ||
| 2927 | + map.put("sjksgl", zksgl); | ||
| 2928 | + double ssgl = culateService.culateLbgl(list); | ||
| 2929 | + map.put("ssgl", ssgl); | ||
| 2930 | + | ||
| 2931 | + //计划+临加-少驶=实驶 | ||
| 2932 | + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | ||
| 2933 | + if (jl == zyygl) { | ||
| 2934 | + map.put("zt", 0); | ||
| 2935 | + } else { | ||
| 2936 | + map.put("zt", 1); | ||
| 2937 | + } | ||
| 2938 | + | ||
| 2939 | + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 2940 | + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 2941 | + map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 2942 | + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 2943 | + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 2944 | + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 2945 | + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 2946 | + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 2947 | + map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 2948 | + map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 2949 | + map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚")); | ||
| 2950 | + double ssgl_pc = culateService.culateCJLC(list, "配车"); | ||
| 2951 | + double ssgl_by = culateService.culateCJLC(list, "保养"); | ||
| 2952 | + double ssgl_cj = culateService.culateCJLC(list, "抽减"); | ||
| 2953 | + double ssgl_qt = culateService.culateCJLC(list, "其他"); | ||
| 2954 | + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 2955 | + map.put("ssbc", culateService.culateLbbc(list)); | ||
| 2956 | + map.put("ljgl", ljgl); | ||
| 2957 | + map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 2958 | + map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 2959 | + map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 2960 | + map.put("sjbc", culateService.culateSjbc(lists, "")); | ||
| 2961 | + map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | ||
| 2962 | + map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | ||
| 2963 | + map.put("ljbc", culateService.culateLjbc(lists, "")); | ||
| 2964 | + map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | ||
| 2965 | + map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | ||
| 2966 | + map.put("fzbc", culateService.culateFzbc(lists, "")); | ||
| 2967 | + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | ||
| 2968 | + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | ||
| 2969 | + map.put("dtbc", 0); | ||
| 2970 | + map.put("dtbc_m", 0); | ||
| 2971 | + map.put("dtbc_a", 0); | ||
| 2972 | + if(m.get("xl")==null){ | ||
| 2973 | + Map<String, Object> m_ = culateService.culateDjg(lists, list.get(0).getXlBm()); | ||
| 2974 | + map.put("djg", m_.get("djgcsq")); | ||
| 2975 | + map.put("djg_m", m_.get("djgcsz")); | ||
| 2976 | + map.put("djg_a", m_.get("djgcsw")); | ||
| 2977 | + map.put("djg_time", m_.get("djgsj")); | ||
| 2978 | + }else{ | ||
| 2979 | + map.put("djg", m.get("djgAll")==null?"0":m.get("djgAll")); | ||
| 2980 | + map.put("djg_m", m.get("djgZgf")==null?"0":m.get("djgZgf")); | ||
| 2981 | + map.put("djg_a", m.get("djgWgf")==null?"0":m.get("djgWgf")); | ||
| 2982 | + map.put("djg_time", m.get("djgTime")==null?"0":m.get("djgTime")); | ||
| 2983 | + } | ||
| 2984 | + } | ||
| 2985 | + return map; | ||
| 2986 | + } | ||
| 2987 | + | ||
| 2988 | + @Override | ||
| 2989 | + public List<Map<String, Object>> dispatchDailySum(String date, String date2, String nature, String type) { | ||
| 2990 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 2991 | + | ||
| 2992 | +// List<Map<String, Object>> list = statisticsDailyTj("", "", "", date, date2, "", "query", nature); | ||
| 2993 | + List<CalcStatistics> calc = calcWaybillService.calcStatisticsDaily("", "", "", date, date2, "", "query", nature); | ||
| 2994 | + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | ||
| 2995 | + try { | ||
| 2996 | + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 2997 | + for(CalcStatistics c : calc){ | ||
| 2998 | + Map<String, Object> m = new HashMap<>(); | ||
| 2999 | + Field[] fields = c.getClass().getDeclaredFields(); | ||
| 3000 | + for(Field f : fields){ | ||
| 3001 | + f.setAccessible(true); | ||
| 3002 | + String key = new String(f.getName()); | ||
| 3003 | + m.put(key, f.get(c)); | ||
| 3004 | + } | ||
| 3005 | + tempList.add(m); | ||
| 3006 | + } | ||
| 3007 | + list = tempList; | ||
| 3008 | + } catch (Exception e) { | ||
| 3009 | + // TODO: handle exception | ||
| 3010 | + e.printStackTrace(); | ||
| 3011 | + } | ||
| 3012 | + | ||
| 3013 | + List<Business> allBusiness = businessRepository.getOrder(); | ||
| 3014 | + Set<String> gsFgsSet = new HashSet<String>(); // 有排序编号的公司,防止乱序或者合计值出问题。 | ||
| 3015 | + for(Business b : allBusiness){ | ||
| 3016 | + gsFgsSet.add(b.getUpCode() + "_" + b.getBusinessCode()); | ||
| 3017 | + gsFgsSet.add(b.getBusinessCode()); | ||
| 3018 | + } | ||
| 3019 | + | ||
| 3020 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 3021 | + List<String> keyList = new ArrayList<String>(); | ||
| 3022 | + | ||
| 3023 | + Map<String, Object> hj = new HashMap<String, Object>(); // 合计 | ||
| 3024 | + hj.put("gsName", "合计"); | ||
| 3025 | + hj.put("fgsBm", " "); | ||
| 3026 | + | ||
| 3027 | + for(Map<String, Object> m : list){ | ||
| 3028 | + m.put("gsBm", m.get("gsdm")); | ||
| 3029 | + m.put("fgsBm", m.get("fgsdm")); | ||
| 3030 | + if(m.get("gsBm") != null && m.get("fgsBm") != null | ||
| 3031 | + && m.get("gsBm").toString().trim().length() > 0 | ||
| 3032 | + && m.get("fgsBm").toString().trim().length() > 0){ | ||
| 3033 | + String gsBm = m.get("gsBm").toString().trim(); | ||
| 3034 | + String fgsBm = m.get("fgsBm").toString().trim(); | ||
| 3035 | + String key = gsBm + "_" + fgsBm; // 分公司key | ||
| 3036 | + String key2 = gsBm + "_sum"; // 直属公司key | ||
| 3037 | + if(!gsFgsSet.contains(key) && !gsFgsSet.contains(gsBm)){ | ||
| 3038 | + continue; | ||
| 3039 | + } | ||
| 3040 | + if(!keyMap.containsKey(key)){ // 每个分公司一条 | ||
| 3041 | + Map<String, Object> t = new HashMap<String, Object>(); | ||
| 3042 | + t.put("gsName", m.get("gsName")); | ||
| 3043 | + t.put("fgsName", m.get("fgsName")); | ||
| 3044 | + t.put("key", key); | ||
| 3045 | + keyMap.put(key, t); | ||
| 3046 | + keyList.add(key); | ||
| 3047 | + if(!keyMap.containsKey(key2)){ // 直属公司小计 | ||
| 3048 | + Map<String, Object> t2 = new HashMap<String, Object>(); | ||
| 3049 | + t2.put("gsName", m.get("gsName")); | ||
| 3050 | + t2.put("fgsName", "小计"); | ||
| 3051 | + t2.put("key", key2); | ||
| 3052 | + keyMap.put(key2, t2); | ||
| 3053 | + keyList.add(key2); | ||
| 3054 | + } | ||
| 3055 | + } | ||
| 3056 | + Map<String, Object> t = keyMap.get(key); | ||
| 3057 | + Map<String, Object> t2 = keyMap.get(key2); | ||
| 3058 | + for(String s : m.keySet()){ | ||
| 3059 | + if("gsName,fgsName,key".contains(s)){ | ||
| 3060 | + continue; | ||
| 3061 | + } | ||
| 3062 | + try { | ||
| 3063 | + if(t.containsKey(s)){ // 分公司 | ||
| 3064 | + t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString()))); | ||
| 3065 | + } else { | ||
| 3066 | + t.put(s, m.get(s).toString()); | ||
| 3067 | + } | ||
| 3068 | + if(t2.containsKey(s)){ // 直属公司 | ||
| 3069 | + t2.put(s, new BigDecimal(t2.get(s).toString()).add(new BigDecimal(m.get(s).toString()))); | ||
| 3070 | + } else { | ||
| 3071 | + t2.put(s, m.get(s).toString()); | ||
| 3072 | + } | ||
| 3073 | + if(hj.containsKey(s)){ // 合计 | ||
| 3074 | + hj.put(s, new BigDecimal(hj.get(s).toString()).add(new BigDecimal(m.get(s).toString()))); | ||
| 3075 | + } else { | ||
| 3076 | + hj.put(s, m.get(s).toString()); | ||
| 3077 | + } | ||
| 3078 | + } catch (Exception e) { | ||
| 3079 | + // TODO: handle exception | ||
| 3080 | + continue; | ||
| 3081 | + } | ||
| 3082 | + } | ||
| 3083 | + } | ||
| 3084 | + } | ||
| 3085 | + | ||
| 3086 | + for(Business b : allBusiness){ // 根据公司排序插入返回对象 | ||
| 3087 | + String gs = b.getBusinessCode(); | ||
| 3088 | + String gsfgs = b.getUpCode() + "_" + b.getBusinessCode(); | ||
| 3089 | + for(String key : keyList){ | ||
| 3090 | + if(key.equals(gsfgs)){ | ||
| 3091 | + resList.add(keyMap.get(key)); | ||
| 3092 | + break; | ||
| 3093 | + } else if(key.replaceAll("_sum", "").equals(gs)){ | ||
| 3094 | + resList.add(keyMap.get(key)); | ||
| 3095 | + break; | ||
| 3096 | + } | ||
| 3097 | + } | ||
| 3098 | + } | ||
| 3099 | + resList.add(hj); | ||
| 3100 | + | ||
| 3101 | + for(Map<String, Object> m : resList){ | ||
| 3102 | + try { | ||
| 3103 | + m.put("jhzlc", m.get("jhzlc")); | ||
| 3104 | + m.put("jhlc", m.get("jhyylc")); | ||
| 3105 | + m.put("jcclc", m.get("jhkslc")); | ||
| 3106 | + m.put("sjzgl", m.get("sjzlc")); | ||
| 3107 | + m.put("sjgl", m.get("sjyylc")); | ||
| 3108 | + m.put("sjksgl", m.get("sjkslc")); | ||
| 3109 | + m.put("ssbc", m.get("ssbc")); | ||
| 3110 | + m.put("ssgl", m.get("sslc")); | ||
| 3111 | + m.put("ssgl_lz", m.get("lzlc")); | ||
| 3112 | + m.put("ssgl_dm", m.get("dmlc")); | ||
| 3113 | + m.put("ssgl_gz", m.get("gzlc")); | ||
| 3114 | + m.put("ssgl_jf", m.get("jflc")); | ||
| 3115 | + m.put("ssgl_zs", m.get("zslc")); | ||
| 3116 | + m.put("ssgl_qr", m.get("qrlc")); | ||
| 3117 | + m.put("ssgl_qc", m.get("qclc")); | ||
| 3118 | + m.put("ssgl_kx", m.get("kxlc")); | ||
| 3119 | + m.put("ssgl_qh", m.get("qhlc")); | ||
| 3120 | + m.put("ssgl_yw", m.get("ywlc")); | ||
| 3121 | + m.put("ssgl_ljpm", m.get("ljpmlc")); | ||
| 3122 | + m.put("ssgl_other", m.get("qtlc")); | ||
| 3123 | + m.put("ljgl", m.get("ljlc")); | ||
| 3124 | + m.put("ljks", m.get("ljkslc")); | ||
| 3125 | + m.put("jhbc", m.get("jhbcq")); | ||
| 3126 | + m.put("jhbc_m", m.get("jhbcz")); | ||
| 3127 | + m.put("jhbc_a", m.get("jhbcw")); | ||
| 3128 | + m.put("sjbc", m.get("sjbcq")); | ||
| 3129 | + m.put("sjbc_m", m.get("sjbcz")); | ||
| 3130 | + m.put("sjbc_a", m.get("sjbcw")); | ||
| 3131 | + m.put("ljbc", m.get("ljbcq")); | ||
| 3132 | + m.put("ljbc_m", m.get("ljbcz")); | ||
| 3133 | + m.put("ljbc_a", m.get("ljbcw")); | ||
| 3134 | + m.put("fzbc", m.get("fzbcq")); | ||
| 3135 | + m.put("fzbc_m", m.get("fzbcz")); | ||
| 3136 | + m.put("fzbc_a", m.get("fzbcw")); | ||
| 3137 | + m.put("dtbc", m.get("dtbcq")); | ||
| 3138 | + m.put("dtbc_m", m.get("dtbcz")); | ||
| 3139 | + m.put("dtbc_a", m.get("dtbcw")); | ||
| 3140 | + m.put("djg", m.get("djgq")); | ||
| 3141 | + m.put("djg_m", m.get("djgz")); | ||
| 3142 | + m.put("djg_a", m.get("djgw")); | ||
| 3143 | + m.put("djg_time", m.get("djgsj")); | ||
| 3144 | + m.put("ljzgl", new BigDecimal(m.get("ljgl").toString()).add(new BigDecimal(m.get("ljks").toString()))); | ||
| 3145 | + } catch (Exception e) { | ||
| 3146 | + // TODO: handle exception | ||
| 3147 | + m.put("ljzgl", ""); | ||
| 3148 | + continue; | ||
| 3149 | + } | ||
| 3150 | + } | ||
| 3151 | + | ||
| 3152 | + if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 3153 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3154 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3155 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3156 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3157 | + ReportUtils ee = new ReportUtils(); | ||
| 3158 | + try { | ||
| 3159 | + String dateTime = ""; | ||
| 3160 | + if (date.equals(date2)) { | ||
| 3161 | + m.put("date", date); | ||
| 3162 | + dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 3163 | + } else { | ||
| 3164 | + m.put("date", date + "至" + date2); | ||
| 3165 | + dateTime = sdfSimple.format(sdfMonth.parse(date)) | ||
| 3166 | + + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 3167 | + } | ||
| 3168 | + listI.add(resList.iterator()); | ||
| 3169 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3170 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/dispatchDailySum.xls", | ||
| 3171 | + path + "export/" + dateTime + "-调度日报汇总表.xls"); | ||
| 3172 | + } catch (Exception e) { | ||
| 3173 | + // TODO: handle exception | ||
| 3174 | + //e.printStackTrace(); | ||
| 3175 | + logger.info("", e); | ||
| 3176 | + } | ||
| 3177 | + } | ||
| 3178 | + | ||
| 3179 | + return resList; | ||
| 3180 | + } | ||
| 3181 | + | ||
| 3182 | + @Override | ||
| 3183 | + public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2, | ||
| 3184 | + String xlName, String type,String nature) { | ||
| 3185 | + List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>(); | ||
| 3186 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 3187 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3188 | + List<Object[]> listInterval=new ArrayList<Object[]>(); | ||
| 3189 | + line = line.trim(); | ||
| 3190 | + if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){ | ||
| 3191 | + //查询所有公司 | ||
| 3192 | + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2); | ||
| 3193 | + listInterval = calcIntervalRepository.countByDate(date, date2); | ||
| 3194 | + } else if (line.equals("")) { | ||
| 3195 | + //查询所有线路 | ||
| 3196 | + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | ||
| 3197 | + listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2); | ||
| 3198 | + } else { | ||
| 3199 | + //查询单条线路 | ||
| 3200 | + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | ||
| 3201 | + listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2); | ||
| 3202 | + } | ||
| 3203 | + Map<String, Map<String,Object>> mapInterval=new HashMap<String, Map<String,Object>>(); | ||
| 3204 | + for (int i = 0; i < listInterval.size(); i++) { | ||
| 3205 | + Object[] interval=listInterval.get(i); | ||
| 3206 | + String gs=interval[0].toString(); | ||
| 3207 | + String fgs=interval[1].toString(); | ||
| 3208 | + String xl=interval[2].toString(); | ||
| 3209 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3210 | + m.put("gs", gs); | ||
| 3211 | + m.put("fgs", fgs); | ||
| 3212 | + m.put("xl", xl); | ||
| 3213 | + m.put("djgAll", interval[3]); | ||
| 3214 | + m.put("djgZgf", interval[6]); | ||
| 3215 | + m.put("djgWgf", interval[7]); | ||
| 3216 | + m.put("djgTime", interval[8]); | ||
| 3217 | + mapInterval.put(gs+"-"+fgs+"-"+xl, m); | ||
| 3218 | + } | ||
| 3219 | + Map<String, Boolean> lineMap=lineService.lineNature(); | ||
| 3220 | + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | ||
| 3221 | + for (int i = 0; i < listAll.size(); i++) { | ||
| 3222 | + ScheduleRealInfo s=listAll.get(i); | ||
| 3223 | + if (nature.equals("0")) { | ||
| 3224 | + list.add(s); | ||
| 3225 | + }else if(nature.equals("1")){ | ||
| 3226 | + if(lineMap.get(s.getXlBm())){ | ||
| 3227 | + list.add(s); | ||
| 3228 | + } | ||
| 3229 | + }else{ | ||
| 3230 | + if(!lineMap.get(s.getXlBm())){ | ||
| 3231 | + list.add(s); | ||
| 3232 | + } | ||
| 3233 | + } | ||
| 3234 | + } | ||
| 3235 | + for (int i = 0; i < list.size(); i++) { | ||
| 3236 | + ScheduleRealInfo s = list.get(i); | ||
| 3237 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 3238 | + if (cts != null && cts.size() > 0) { | ||
| 3239 | + list_s.add(s); | ||
| 3240 | + } else { | ||
| 3241 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 3242 | + list_s.add(s); | ||
| 3243 | + } | ||
| 3244 | + } | ||
| 3245 | + } | ||
| 3246 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 3247 | + for (int i = 0; i < list.size(); i++) { | ||
| 3248 | + if (i < list.size() - 1) { | ||
| 3249 | + if ((list.get(i+1).getGsBm()+"/"+list.get(i+1).getFgsBm()+"/"+list.get(i+1).getXlBm()).equals( | ||
| 3250 | + list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm())) { | ||
| 3251 | + lists.add(list.get(i)); | ||
| 3252 | + } else { | ||
| 3253 | + lists.add(list.get(i)); | ||
| 3254 | + Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3255 | + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3256 | + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3257 | + } | ||
| 3258 | + Map<String, Object> map = staticTj(lists,mm); | ||
| 3259 | + lMap.add(map); | ||
| 3260 | + lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3261 | + } | ||
| 3262 | + } else { | ||
| 3263 | + if ((list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm()).equals( | ||
| 3264 | + list.get(i-1).getGsBm()+"/"+list.get(i-1).getFgsBm()+"/"+list.get(i-1).getXlBm())) { | ||
| 3265 | + lists.add(list.get(i)); | ||
| 3266 | + Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3267 | + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3268 | + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3269 | + } | ||
| 3270 | + Map<String, Object> map = staticTj(lists,mm); | ||
| 3271 | + lMap.add(map); | ||
| 3272 | + } else { | ||
| 3273 | + lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3274 | + lists.add(list.get(i)); | ||
| 3275 | + Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3276 | + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3277 | + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3278 | + } | ||
| 3279 | + Map<String, Object> map = staticTj(lists,mm); | ||
| 3280 | + lMap.add(map); | ||
| 3281 | + } | ||
| 3282 | + } | ||
| 3283 | + } | ||
| 3284 | + | ||
| 3285 | + Collections.sort(lMap, new AccountXlbm()); | ||
| 3286 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 3287 | + map.put("xlName", "合计"); | ||
| 3288 | + map.put("fgsName", ""); | ||
| 3289 | + map.put("gsName", ""); | ||
| 3290 | + double jhyygl = culateService.culateJhgl(list);//计划营运公里 | ||
| 3291 | + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 3292 | + map.put("jhlc", jhyygl); | ||
| 3293 | + map.put("jcclc", jhjcclc); | ||
| 3294 | + map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | ||
| 3295 | + | ||
| 3296 | + double ljgl = culateService.culateLjgl(list_s); | ||
| 3297 | + double sjyygl = culateService.culateSjgl(list_s); | ||
| 3298 | + double zyygl = Arith.add(sjyygl, ljgl); | ||
| 3299 | + double ljks=culateService.culateLjksgl(list_s); | ||
| 3300 | + map.put("ljks", ljks); | ||
| 3301 | + double sjjccgl = culateService.culateJccgl(list_s); | ||
| 3302 | + double sjksgl = culateService.culateKsgl(list_s); | ||
| 3303 | + double zksgl = Arith.add(sjjccgl, sjksgl); | ||
| 3304 | + map.put("sjzgl", Arith.add(zyygl, zksgl)); | ||
| 3305 | + map.put("sjgl", zyygl); | ||
| 3306 | + map.put("sjksgl", zksgl); | ||
| 3307 | + | ||
| 3308 | + double ssgl = culateService.culateLbgl(list); | ||
| 3309 | + map.put("ssgl", ssgl); | ||
| 3310 | + //计划+临加-少驶=实驶 | ||
| 3311 | + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | ||
| 3312 | + if (jl == zyygl) { | ||
| 3313 | + map.put("zt", 0); | ||
| 3314 | + } else { | ||
| 3315 | + map.put("zt", 1); | ||
| 3316 | + } | ||
| 3317 | + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 3318 | + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 3319 | + map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 3320 | + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 3321 | + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 3322 | + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 3323 | + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 3324 | + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 3325 | + map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 3326 | + map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 3327 | + map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚")); | ||
| 3328 | + double ssgl_pc = culateService.culateCJLC(list, "配车"); | ||
| 3329 | + double ssgl_by = culateService.culateCJLC(list, "保养"); | ||
| 3330 | + double ssgl_cj = culateService.culateCJLC(list, "抽减"); | ||
| 3331 | + double ssgl_qt = culateService.culateCJLC(list, "其他"); | ||
| 3332 | + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 3333 | + | ||
| 3334 | + map.put("ssbc", culateService.culateLbbc(list)); | ||
| 3335 | + map.put("ljgl", ljgl); | ||
| 3336 | + map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 3337 | + map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 3338 | + map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 3339 | + map.put("sjbc", culateService.culateSjbc(list_s, "")); | ||
| 3340 | + map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | ||
| 3341 | + map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | ||
| 3342 | + map.put("ljbc", culateService.culateLjbc(list_s, "")); | ||
| 3343 | + map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | ||
| 3344 | + map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | ||
| 3345 | + map.put("fzbc", culateService.culateFzbc(list_s, "")); | ||
| 3346 | + map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | ||
| 3347 | + map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | ||
| 3348 | + map.put("dtbc", 0); | ||
| 3349 | + map.put("dtbc_m", 0); | ||
| 3350 | + map.put("dtbc_a", 0); | ||
| 3351 | + if (list.size() > 0) { | ||
| 3352 | + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | ||
| 3353 | + for (Map<String, Object> m : lMap) { | ||
| 3354 | + if (m.containsKey("djg") && m.get("djg") != null) | ||
| 3355 | + djg += Integer.valueOf(m.get("djg").toString()); | ||
| 3356 | + if (m.containsKey("djg_m") && m.get("djg_m") != null) | ||
| 3357 | + djg_m += Integer.valueOf(m.get("djg_m").toString()); | ||
| 3358 | + if (m.containsKey("djg_a") && m.get("djg_a") != null) | ||
| 3359 | + djg_a += Integer.valueOf(m.get("djg_a").toString()); | ||
| 3360 | + if (m.containsKey("djg_time") && m.get("djg_time") != null) { | ||
| 3361 | + int t = Integer.valueOf(m.get("djg_time").toString()); | ||
| 3362 | + if (t > djg_time) | ||
| 3363 | + djg_time = t; | ||
| 3364 | + } | ||
| 3365 | + } | ||
| 3366 | + map.put("djg", djg); | ||
| 3367 | + map.put("djg_m", djg_m); | ||
| 3368 | + map.put("djg_a", djg_a); | ||
| 3369 | + map.put("djg_time", djg_time); | ||
| 3370 | +// Map<String, Object> m_=culateService.culateDjg(list_s, list.get(0).getXlBm()); | ||
| 3371 | +// map.put("djg", m_.get("djgcsq")); | ||
| 3372 | +// map.put("djg_m", m_.get("djgcsz")); | ||
| 3373 | +// map.put("djg_a", m_.get("djgcsw")); | ||
| 3374 | +// map.put("djg_time", m_.get("djgsj")); | ||
| 3375 | + } else { | ||
| 3376 | + map.put("djg", "0"); | ||
| 3377 | + map.put("djg_m", "0"); | ||
| 3378 | + map.put("djg_a", "0"); | ||
| 3379 | + map.put("djg_time", "0"); | ||
| 3380 | + } | ||
| 3381 | + lMap.add(map); | ||
| 3382 | + | ||
| 3383 | + if (type != null && type.length() != 0 && type.equals("export")) { | ||
| 3384 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3385 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3386 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3387 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3388 | + m.put("date", date + "至" + date2); | ||
| 3389 | + ReportUtils ee = new ReportUtils(); | ||
| 3390 | + try { | ||
| 3391 | + String dateTime = ""; | ||
| 3392 | + if (date.equals(date2)) { | ||
| 3393 | + dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 3394 | + } else { | ||
| 3395 | + dateTime = sdfSimple.format(sdfMonth.parse(date)) | ||
| 3396 | + + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 3397 | + } | ||
| 3398 | + listI.add(lMap.iterator()); | ||
| 3399 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3400 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls", | ||
| 3401 | + path + "export/" + dateTime + "-" + xlName + "-统计日报.xls"); | ||
| 3402 | + } catch (Exception e) { | ||
| 3403 | + // TODO: handle exception | ||
| 3404 | + //e.printStackTrace(); | ||
| 3405 | + logger.info("", e); | ||
| 3406 | + } | ||
| 3407 | + } | ||
| 3408 | + | ||
| 3409 | + if (type != null && type.length() != 0 && type.equals("exportAll")) { | ||
| 3410 | + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 3411 | + Map<String, Map<String, Object>> tempMap = new HashMap<String, Map<String, Object>>(); | ||
| 3412 | + List<Map<String, Object>> removeList = new ArrayList<Map<String, Object>>(); | ||
| 3413 | + for(Map<String, Object> m : lMap){ | ||
| 3414 | + if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0 | ||
| 3415 | + && m.get("gsName").toString().trim().contains("临港")){ | ||
| 3416 | + removeList.add(m); | ||
| 3417 | + } | ||
| 3418 | + } | ||
| 3419 | + for(Map<String, Object> m : removeList){ | ||
| 3420 | + lMap.remove(m); | ||
| 3421 | + } | ||
| 3422 | + for(Map<String, Object> m : lMap){ | ||
| 3423 | + if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0){ | ||
| 3424 | + String gsName = m.get("gsName").toString().trim(); | ||
| 3425 | + Map<String, Object> temp = new HashMap<String, Object>(); | ||
| 3426 | + if(tempMap.get(gsName) != null){ | ||
| 3427 | + temp = tempMap.get(gsName); | ||
| 3428 | + } else { | ||
| 3429 | + temp.put("gsName", gsName); | ||
| 3430 | + temp.put("fgsName", "小计"); | ||
| 3431 | + temp.put("xlName", ""); | ||
| 3432 | + tempList.add(temp); | ||
| 3433 | + tempMap.put(gsName, temp); | ||
| 3434 | + } | ||
| 3435 | + for(String key : m.keySet()){ | ||
| 3436 | + try { | ||
| 3437 | + temp.put(key, new BigDecimal(m.get(key).toString()).add( | ||
| 3438 | + new BigDecimal(temp.get(key)!=null?temp.get(key).toString():"0"))); | ||
| 3439 | + } catch (Exception e) { | ||
| 3440 | + // TODO: handle exception | ||
| 3441 | + } | ||
| 3442 | + } | ||
| 3443 | + } | ||
| 3444 | + } | ||
| 3445 | + lMap.addAll(lMap.size()>0?lMap.size()-1:0, tempList); | ||
| 3446 | + | ||
| 3447 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3448 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3449 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3450 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3451 | + m.put("date", date + "至" + date2); | ||
| 3452 | + ReportUtils ee = new ReportUtils(); | ||
| 3453 | + try { | ||
| 3454 | + String dateTime = ""; | ||
| 3455 | + if (date.equals(date2)) { | ||
| 3456 | + dateTime = sdfSimple.format(sdfMonth.parse(date)); | ||
| 3457 | + } else { | ||
| 3458 | + dateTime = sdfSimple.format(sdfMonth.parse(date)) | ||
| 3459 | + + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 3460 | + } | ||
| 3461 | + listI.add(lMap.iterator()); | ||
| 3462 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3463 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_4.xls", | ||
| 3464 | + path + "export/" + dateTime + "-全部公司-统计日报.xls"); | ||
| 3465 | + } catch (Exception e) { | ||
| 3466 | + // TODO: handle exception | ||
| 3467 | + //e.printStackTrace(); | ||
| 3468 | + logger.info("", e); | ||
| 3469 | + } | ||
| 3470 | + } | ||
| 3471 | + | ||
| 3472 | + return lMap; | ||
| 3473 | + } | ||
| 3474 | + | ||
| 3475 | + @Override | ||
| 3476 | + public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2, | ||
| 3477 | + String xlName, String type,String nature) { | ||
| 3478 | + List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>(); | ||
| 3479 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 3480 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3481 | + List<Object[]> listInterval=new ArrayList<Object[]>(); | ||
| 3482 | + | ||
| 3483 | + line = line.trim(); | ||
| 3484 | + if (line.equals("")) { | ||
| 3485 | + //查询所有线路 | ||
| 3486 | + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | ||
| 3487 | + listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2); | ||
| 3488 | + } else { | ||
| 3489 | + //查询单条线路 | ||
| 3490 | + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | ||
| 3491 | + listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2); | ||
| 3492 | + } | ||
| 3493 | + Map<String, Map<String,Object>> mapInterval=new HashMap<>(); | ||
| 3494 | + for (int i = 0; i < listInterval.size(); i++) { | ||
| 3495 | + Object[] interval=listInterval.get(i); | ||
| 3496 | + String gs=interval[0].toString(); | ||
| 3497 | + String fgs=interval[1].toString(); | ||
| 3498 | + String xl=interval[2].toString(); | ||
| 3499 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 3500 | + m.put("gs", gs); | ||
| 3501 | + m.put("fgs", fgs); | ||
| 3502 | + m.put("xl", xl); | ||
| 3503 | + m.put("djgAll", interval[3]); | ||
| 3504 | + m.put("djgZgf", interval[6]); | ||
| 3505 | + m.put("djgWgf", interval[7]); | ||
| 3506 | + m.put("djgTime", interval[8]); | ||
| 3507 | + mapInterval.put(gs+"-"+fgs+"-"+xl, m); | ||
| 3508 | + } | ||
| 3509 | + | ||
| 3510 | + Map<String, Boolean> lineMap=lineService.lineNature(); | ||
| 3511 | + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | ||
| 3512 | + for (int i = 0; i < listAll.size(); i++) { | ||
| 3513 | + ScheduleRealInfo s=listAll.get(i); | ||
| 3514 | + if (nature.equals("0")) { | ||
| 3515 | + list.add(s); | ||
| 3516 | + }else if(nature.equals("1")){ | ||
| 3517 | + if(lineMap.get(s.getXlBm())){ | ||
| 3518 | + list.add(s); | ||
| 3519 | + } | ||
| 3520 | + }else{ | ||
| 3521 | + if(!lineMap.get(s.getXlBm())){ | ||
| 3522 | + list.add(s); | ||
| 3523 | + } | ||
| 3524 | + } | ||
| 3525 | + } | ||
| 3526 | + for (int i = 0; i < list.size(); i++) { | ||
| 3527 | + ScheduleRealInfo s = list.get(i); | ||
| 3528 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 3529 | + if (cts != null && cts.size() > 0) { | ||
| 3530 | + list_s.add(s); | ||
| 3531 | + } else { | ||
| 3532 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 3533 | + list_s.add(s); | ||
| 3534 | + } | ||
| 3535 | + } | ||
| 3536 | + } | ||
| 3537 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 3538 | + for (int i = 0; i < list.size(); i++) { | ||
| 3539 | + if (i < list.size() - 1) { | ||
| 3540 | + if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) { | ||
| 3541 | + lists.add(list.get(i)); | ||
| 3542 | + } else { | ||
| 3543 | + lists.add(list.get(i)); | ||
| 3544 | + Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3545 | + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3546 | + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3547 | + } | ||
| 3548 | + Map<String, Object> map = staticTj(lists,mm); | ||
| 3549 | + lMap.add(map); | ||
| 3550 | + lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3551 | + } | ||
| 3552 | + } else { | ||
| 3553 | + if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) { | ||
| 3554 | + lists.add(list.get(i)); | ||
| 3555 | + Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3556 | + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3557 | + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3558 | + } | ||
| 3559 | + Map<String, Object> map = staticTj(lists,mm); | ||
| 3560 | + lMap.add(map); | ||
| 3561 | + } else { | ||
| 3562 | + lists = new ArrayList<ScheduleRealInfo>(); | ||
| 3563 | + lists.add(list.get(i)); | ||
| 3564 | + Map<String, Object> mm=new HashMap<String,Object>(); | ||
| 3565 | + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | ||
| 3566 | + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | ||
| 3567 | + } | ||
| 3568 | + Map<String, Object> map = staticTj(lists,mm); | ||
| 3569 | + lMap.add(map); | ||
| 3570 | + } | ||
| 3571 | + } | ||
| 3572 | + } | ||
| 3573 | + | ||
| 3574 | + Collections.sort(lMap, new AccountXlbm()); | ||
| 3575 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 3576 | + map.put("xlBm", "hj"); | ||
| 3577 | + map.put("xlName", "合计"); | ||
| 3578 | + map.put("fgsBm", ""); | ||
| 3579 | + map.put("fgsName", ""); | ||
| 3580 | + map.put("gsBm", ""); | ||
| 3581 | + double jhyygl = culateService.culateJhgl(list);//计划营运公里 | ||
| 3582 | + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 3583 | + map.put("jhlc", jhyygl); | ||
| 3584 | + map.put("jcclc", jhjcclc); | ||
| 3585 | + map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | ||
| 3586 | + | ||
| 3587 | + double ljgl = culateService.culateLjgl(list_s); | ||
| 3588 | + double sjyygl = culateService.culateSjgl(list_s); | ||
| 3589 | + double zyygl = Arith.add(sjyygl, ljgl); | ||
| 3590 | + double ljks=culateService.culateLjksgl(list_s); | ||
| 3591 | + map.put("ljks", ljks); | ||
| 3592 | + double sjjccgl = culateService.culateJccgl(list_s); | ||
| 3593 | + double sjksgl = culateService.culateKsgl(list_s); | ||
| 3594 | + double zksgl = Arith.add(sjjccgl, sjksgl); | ||
| 3595 | + map.put("sjzgl", Arith.add(zyygl, zksgl)); | ||
| 3596 | + map.put("sjgl", zyygl); | ||
| 3597 | + map.put("sjksgl", zksgl); | ||
| 3598 | + | ||
| 3599 | + double ssgl = culateService.culateLbgl(list); | ||
| 3600 | + map.put("ssgl", ssgl); | ||
| 3601 | + //计划+临加-少驶=实驶 | ||
| 3602 | + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | ||
| 3603 | + if (jl == zyygl) { | ||
| 3604 | + map.put("zt", 0); | ||
| 3605 | + } else { | ||
| 3606 | + map.put("zt", 1); | ||
| 3607 | + } | ||
| 3608 | + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 3609 | + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 3610 | + map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 3611 | + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 3612 | + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 3613 | + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 3614 | + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 3615 | + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 3616 | + map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 3617 | + map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 3618 | + map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚")); | ||
| 3619 | + double ssgl_pc = culateService.culateCJLC(list, "配车"); | ||
| 3620 | + double ssgl_by = culateService.culateCJLC(list, "保养"); | ||
| 3621 | + double ssgl_cj = culateService.culateCJLC(list, "抽减"); | ||
| 3622 | + double ssgl_qt = culateService.culateCJLC(list, "其他"); | ||
| 3623 | + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | ||
| 3624 | + | ||
| 3625 | + map.put("ssbc", culateService.culateLbbc(list)); | ||
| 3626 | + map.put("ljgl", ljgl); | ||
| 3627 | + map.put("jhbc", culateService.culateJhbc(list, "")); | ||
| 3628 | + map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 3629 | + map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 3630 | + map.put("sjbc", culateService.culateSjbc(list_s, "")); | ||
| 3631 | + map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | ||
| 3632 | + map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | ||
| 3633 | + map.put("ljbc", culateService.culateLjbc(list_s, "")); | ||
| 3634 | + map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | ||
| 3635 | + map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | ||
| 3636 | + map.put("fzbc", culateService.culateFzbc(list_s, "")); | ||
| 3637 | + map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | ||
| 3638 | + map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | ||
| 3639 | + map.put("dtbc", 0); | ||
| 3640 | + map.put("dtbc_m", 0); | ||
| 3641 | + map.put("dtbc_a", 0); | ||
| 3642 | + if (list.size() > 0) { | ||
| 3643 | + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | ||
| 3644 | + for (Map<String, Object> m : lMap) { | ||
| 3645 | + if (m.containsKey("djg") && m.get("djg") != null) | ||
| 3646 | + djg += Integer.valueOf(m.get("djg").toString()); | ||
| 3647 | + if (m.containsKey("djg_m") && m.get("djg_m") != null) | ||
| 3648 | + djg_m += Integer.valueOf(m.get("djg_m").toString()); | ||
| 3649 | + if (m.containsKey("djg_a") && m.get("djg_a") != null) | ||
| 3650 | + djg_a += Integer.valueOf(m.get("djg_a").toString()); | ||
| 3651 | + if (m.containsKey("djg_time") && m.get("djg_time") != null) { | ||
| 3652 | + int t = Integer.valueOf(m.get("djg_time").toString()); | ||
| 3653 | + if (t > djg_time) | ||
| 3654 | + djg_time = t; | ||
| 3655 | + } | ||
| 3656 | + } | ||
| 3657 | + map.put("djg", djg); | ||
| 3658 | + map.put("djg_m", djg_m); | ||
| 3659 | + map.put("djg_a", djg_a); | ||
| 3660 | + map.put("djg_time", djg_time); | ||
| 3661 | + } else { | ||
| 3662 | + map.put("djg", "0"); | ||
| 3663 | + map.put("djg_m", "0"); | ||
| 3664 | + map.put("djg_a", "0"); | ||
| 3665 | + map.put("djg_time", "0"); | ||
| 3666 | + } | ||
| 3667 | + lMap.add(map); | ||
| 3668 | + return lMap; | ||
| 3669 | + } | ||
| 3670 | + | ||
| 3671 | + @Override | ||
| 3672 | + public Map<String, Object> scheduleDaily(String line, String date) { | ||
| 3673 | + Map<String, String> tempMap = null; | ||
| 3674 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); | ||
| 3675 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 3676 | + Double jhlc = 0.00; | ||
| 3677 | + Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, | ||
| 3678 | + ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_ljpm = 0f, | ||
| 3679 | + ssgl_other = 0f, ljgl = 0f; | ||
| 3680 | + int jhbc = 0; | ||
| 3681 | + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | ||
| 3682 | + if (scheduleRealInfo != null) { | ||
| 3683 | + //计算里程(包括子任务) | ||
| 3684 | + jhlc += scheduleRealInfo.getJhlc(); | ||
| 3685 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 3686 | + if (!childTaskPlans.isEmpty()) { | ||
| 3687 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 3688 | + while (it.hasNext()) { | ||
| 3689 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 3690 | + //是否烂班,烂班就是少驶 | ||
| 3691 | + if (!childTaskPlan.isDestroy()) { | ||
| 3692 | + sjgl += childTaskPlan.getMileage(); | ||
| 3693 | + } else { | ||
| 3694 | + ssgl += childTaskPlan.getMileage(); | ||
| 3695 | + if (childTaskPlan.getDestroyReason().equals("路阻")) { | ||
| 3696 | + ssgl_lz += childTaskPlan.getMileage(); | ||
| 3697 | + } else if (childTaskPlan.getDestroyReason().equals("吊慢")) { | ||
| 3698 | + ssgl_dm += childTaskPlan.getMileage(); | ||
| 3699 | + } else if (childTaskPlan.getDestroyReason().equals("故障")) { | ||
| 3700 | + ssgl_gz += childTaskPlan.getMileage(); | ||
| 3701 | + } else if (childTaskPlan.getDestroyReason().equals("纠纷")) { | ||
| 3702 | + ssgl_jf += childTaskPlan.getMileage(); | ||
| 3703 | + } else if (childTaskPlan.getDestroyReason().equals("肇事")) { | ||
| 3704 | + ssgl_zs += childTaskPlan.getMileage(); | ||
| 3705 | + } else if (childTaskPlan.getDestroyReason().equals("缺人")) { | ||
| 3706 | + ssgl_qr += childTaskPlan.getMileage(); | ||
| 3707 | + } else if (childTaskPlan.getDestroyReason().equals("缺车")) { | ||
| 3708 | + ssgl_qc += childTaskPlan.getMileage(); | ||
| 3709 | + } else if (childTaskPlan.getDestroyReason().equals("客稀")) { | ||
| 3710 | + ssgl_kx += childTaskPlan.getMileage(); | ||
| 3711 | + } else if (childTaskPlan.getDestroyReason().equals("气候")) { | ||
| 3712 | + ssgl_qh += childTaskPlan.getMileage(); | ||
| 3713 | + } else if (childTaskPlan.getDestroyReason().equals("援外")) { | ||
| 3714 | + ssgl_yw += childTaskPlan.getMileage(); | ||
| 3715 | + } else if (childTaskPlan.getDestroyReason().equals("路救抛锚")) { | ||
| 3716 | + ssgl_ljpm += childTaskPlan.getMileage(); | ||
| 3717 | + } else { | ||
| 3718 | + ssgl_other += childTaskPlan.getMileage(); | ||
| 3719 | + } | ||
| 3720 | + } | ||
| 3721 | + //临加公里 | ||
| 3722 | + if (childTaskPlan.getType1().equals("临加")) { | ||
| 3723 | + ljgl += childTaskPlan.getMileage(); | ||
| 3724 | + } | ||
| 3725 | + } | ||
| 3726 | + } | ||
| 3727 | + //班次 | ||
| 3728 | + scheduleRealInfo.getFcsjT(); | ||
| 3729 | + scheduleRealInfo.getFcsjActualTime(); | ||
| 3730 | + } | ||
| 3731 | + } | ||
| 3732 | + map.put("jhlc", jhlc); | ||
| 3733 | + map.put("sjgl", sjgl); | ||
| 3734 | + map.put("ssgl", ssgl); | ||
| 3735 | + map.put("ssgl_lz", ssgl_lz); | ||
| 3736 | + map.put("ssgl_dm", ssgl_dm); | ||
| 3737 | + map.put("ssgl_gz", ssgl_gz); | ||
| 3738 | + map.put("ssgl_jf", ssgl_jf); | ||
| 3739 | + map.put("ssgl_zs", ssgl_zs); | ||
| 3740 | + map.put("ssgl_qr", ssgl_qr); | ||
| 3741 | + map.put("ssgl_qc", ssgl_qc); | ||
| 3742 | + map.put("ssgl_kx", ssgl_kx); | ||
| 3743 | + map.put("ssgl_qh", ssgl_qh); | ||
| 3744 | + map.put("ssgl_yw", ssgl_yw); | ||
| 3745 | + map.put("ssgl_ljpm", ssgl_ljpm); | ||
| 3746 | + map.put("ssgl_other", ssgl_other); | ||
| 3747 | + map.put("ljgl", ljgl); | ||
| 3748 | + | ||
| 3749 | + map.put("jhbc", scheduleRealInfos.size()); | ||
| 3750 | + return null; | ||
| 3751 | + } | ||
| 3752 | + | ||
| 3753 | + @Override | ||
| 3754 | + public int countByLineCodeAndDate(String xlBm, String schDate) { | ||
| 3755 | + return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate); | ||
| 3756 | + } | ||
| 3757 | + | ||
| 3758 | + @Override | ||
| 3759 | + public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) { | ||
| 3760 | + return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate); | ||
| 3761 | + } | ||
| 3762 | + | ||
| 3763 | + @Override | ||
| 3764 | + public void deleteByLineCodeAndDate(String xlBm, String schDate) { | ||
| 3765 | + scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate); | ||
| 3766 | + } | ||
| 3767 | + | ||
| 3768 | + @Override | ||
| 3769 | + public Long getMaxId() { | ||
| 3770 | + return scheduleRealInfoRepository.getMaxId(); | ||
| 3771 | + } | ||
| 3772 | + | ||
| 3773 | + @Override | ||
| 3774 | + public List<ScheduleRealInfo> realScheduleList(String line, String date) { | ||
| 3775 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 3776 | + String lpName = "lpName"; | ||
| 3777 | + String zdsj = ""; | ||
| 3778 | + String zdsjActual = ""; | ||
| 3779 | + String zdsj1 = ""; | ||
| 3780 | + String zdsjActual1 = ""; | ||
| 3781 | + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date); | ||
| 3782 | + | ||
| 3783 | + /* | ||
| 3784 | + * 对计划发车时间相同的班次进行排序 out最前 in最后 | ||
| 3785 | + */ | ||
| 3786 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 3787 | + SimpleDateFormat sdfnyr =new SimpleDateFormat("yyyy-MM-dd"); | ||
| 3788 | + String minfcsj = "02:00"; | ||
| 3789 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 3790 | + if (lineList.size() > 0) { | ||
| 3791 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 3792 | + + " id = (" | ||
| 3793 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 3794 | + + ")"; | ||
| 3795 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 3796 | + } | ||
| 3797 | + String[] minSjs = minfcsj.split(":"); | ||
| 3798 | + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 3799 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 3800 | + ScheduleRealInfo s = listInfo.get(i); | ||
| 3801 | + if (s.getBcType().equals("out")) { | ||
| 3802 | + s.setRemark("1"); | ||
| 3803 | + } else if (s.getBcType().equals("in")) { | ||
| 3804 | + s.setRemark("3"); | ||
| 3805 | + } else { | ||
| 3806 | + s.setRemark("2"); | ||
| 3807 | + } | ||
| 3808 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 3809 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 3810 | + | ||
| 3811 | + Long fscjT = 0L; | ||
| 3812 | + if (fcsjL < minSj) { | ||
| 3813 | + Calendar calendar = new GregorianCalendar(); | ||
| 3814 | + calendar.setTime(s.getScheduleDate()); | ||
| 3815 | + calendar.add(calendar.DATE, 1); | ||
| 3816 | + Date date_sch= calendar.getTime(); | ||
| 3817 | + try { | ||
| 3818 | + fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime(); | ||
| 3819 | + } catch (ParseException e) { | ||
| 3820 | + // TODO Auto-generated catch block | ||
| 3821 | + e.printStackTrace(); | ||
| 3822 | + } | ||
| 3823 | + | ||
| 3824 | + } else { | ||
| 3825 | + try { | ||
| 3826 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 3827 | + } catch (ParseException e) { | ||
| 3828 | + // TODO Auto-generated catch block | ||
| 3829 | + e.printStackTrace(); | ||
| 3830 | + }; | ||
| 3831 | + } | ||
| 3832 | + s.setFcsjT(fscjT); | ||
| 3833 | + } | ||
| 3834 | + List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); | ||
| 3835 | + listInfo2.addAll(listInfo); | ||
| 3836 | + Collections.sort(listInfo, new compareLpFcsjType()); | ||
| 3837 | + Collections.sort(listInfo2,new compareDirLpFcsjType()); | ||
| 3838 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 3839 | + ScheduleRealInfo t = listInfo.get(i); | ||
| 3840 | + if (!lpName.equals(t.getLpName())) { | ||
| 3841 | + zdsjActual = t.getZdsjActual(); | ||
| 3842 | + zdsj = t.getZdsj(); | ||
| 3843 | + t.setZdsjActual(""); | ||
| 3844 | + t.setZdsj(""); | ||
| 3845 | + } else { | ||
| 3846 | + zdsj1 = t.getZdsj(); | ||
| 3847 | + zdsjActual1 = t.getZdsjActual(); | ||
| 3848 | + t.setZdsjActual(zdsjActual); | ||
| 3849 | + t.setZdsj(zdsj); | ||
| 3850 | + zdsj = zdsj1; | ||
| 3851 | + zdsjActual = zdsjActual1; | ||
| 3852 | + } | ||
| 3853 | + lpName = t.getLpName(); | ||
| 3854 | + list.add(t); | ||
| 3855 | + } | ||
| 3856 | +/* | ||
| 3857 | + List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date); | ||
| 3858 | + for (int i = 0; i < listInfo2.size(); i++) { | ||
| 3859 | + ScheduleRealInfo s = listInfo2.get(i); | ||
| 3860 | + if (s.getBcType().equals("out")) { | ||
| 3861 | + s.setRemark("1"); | ||
| 3862 | + } else if (s.getBcType().equals("in")) { | ||
| 3863 | + s.setRemark("3"); | ||
| 3864 | + } else { | ||
| 3865 | + s.setRemark("2"); | ||
| 3866 | + } | ||
| 3867 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 3868 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 3869 | + | ||
| 3870 | + Long fscjT = 0L; | ||
| 3871 | + if (fcsjL < minSj) { | ||
| 3872 | + Calendar calendar = new GregorianCalendar(); | ||
| 3873 | + calendar.setTime(s.getScheduleDate()); | ||
| 3874 | + calendar.add(calendar.DATE, 1); | ||
| 3875 | + s.setScheduleDate(calendar.getTime()); | ||
| 3876 | + try { | ||
| 3877 | + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 3878 | + } catch (ParseException e) { | ||
| 3879 | + // TODO Auto-generated catch block | ||
| 3880 | + e.printStackTrace(); | ||
| 3881 | + } | ||
| 3882 | + | ||
| 3883 | + } else { | ||
| 3884 | + try { | ||
| 3885 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 3886 | + } catch (ParseException e) { | ||
| 3887 | + // TODO Auto-generated catch block | ||
| 3888 | + e.printStackTrace(); | ||
| 3889 | + } | ||
| 3890 | + ; | ||
| 3891 | + } | ||
| 3892 | + s.setFcsjT(fscjT); | ||
| 3893 | + }*/ | ||
| 3894 | + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | ||
| 3895 | + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | ||
| 3896 | + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | ||
| 3897 | + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 3898 | + if (listInfo2.size() > 0) { | ||
| 3899 | + int a = listInfo2.size() % 3; | ||
| 3900 | + int b = listInfo2.size() / 3; | ||
| 3901 | + int x = 0, y = 0; | ||
| 3902 | + if (a == 2) { | ||
| 3903 | + x = b + 1; | ||
| 3904 | + y = x * 2; | ||
| 3905 | + } else if (a == 1) { | ||
| 3906 | + x = b + 1; | ||
| 3907 | + y = x * 2 - 1; | ||
| 3908 | + } else { | ||
| 3909 | + x = b; | ||
| 3910 | + y = 2 * x; | ||
| 3911 | + | ||
| 3912 | + } | ||
| 3913 | + for (int i = 0; i < listInfo2.size(); i++) { | ||
| 3914 | + ScheduleRealInfo s = listInfo2.get(i); | ||
| 3915 | + if (i + 1 <= x) { | ||
| 3916 | + xList.add(s); | ||
| 3917 | + } else if ((i + 1) > x && (i + 1) <= y) { | ||
| 3918 | + yList.add(s); | ||
| 3919 | + } else { | ||
| 3920 | + zList.add(s); | ||
| 3921 | + } | ||
| 3922 | + } | ||
| 3923 | + for (int i = 0; i < x; i++) { | ||
| 3924 | + newList.add(xList.get(i)); | ||
| 3925 | + if (yList.size() > i) { | ||
| 3926 | + newList.add(yList.get(i)); | ||
| 3927 | + } else { | ||
| 3928 | + newList.add(new ScheduleRealInfo()); | ||
| 3929 | + } | ||
| 3930 | + if (zList.size() > i) { | ||
| 3931 | + newList.add(zList.get(i)); | ||
| 3932 | + } else { | ||
| 3933 | + newList.add(new ScheduleRealInfo()); | ||
| 3934 | + } | ||
| 3935 | + | ||
| 3936 | + } | ||
| 3937 | + } | ||
| 3938 | + for (int i = 0; i < newList.size(); i++) { | ||
| 3939 | + ScheduleRealInfo t1 = newList.get(i); | ||
| 3940 | + for (int j = 0; j < list.size(); j++) { | ||
| 3941 | + ScheduleRealInfo t2 = list.get(j); | ||
| 3942 | + if (t1.getId() == t2.getId()) { | ||
| 3943 | + t1 = t2; | ||
| 3944 | + } | ||
| 3945 | + } | ||
| 3946 | + } | ||
| 3947 | + | ||
| 3948 | + for (int i = 0; i < newList.size(); i++) { | ||
| 3949 | + ScheduleRealInfo t1 = newList.get(i); | ||
| 3950 | + String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks(); | ||
| 3951 | + if (reamrks1.length() > 4) { | ||
| 3952 | + t1.setRemarks(reamrks1.substring(0, 4)); | ||
| 3953 | + t1.setRemark(reamrks1); | ||
| 3954 | + } else { | ||
| 3955 | + t1.setRemark(reamrks1); | ||
| 3956 | + } | ||
| 3957 | + } | ||
| 3958 | + return newList; | ||
| 3959 | + } | ||
| 3960 | + | ||
| 3961 | + @Override | ||
| 3962 | + public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) { | ||
| 3963 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 3964 | + String lpName = "lpName"; | ||
| 3965 | + String zdsj = ""; | ||
| 3966 | + String zdsjActual = ""; | ||
| 3967 | + String zdsj1 = ""; | ||
| 3968 | + String zdsjActual1 = ""; | ||
| 3969 | + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date); | ||
| 3970 | + | ||
| 3971 | + /* | ||
| 3972 | + * 对计划发车时间相同的班次进行排序 out最前 in最后 | ||
| 3973 | + */ | ||
| 3974 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 3975 | + SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 3976 | + | ||
| 3977 | + String minfcsj = "02:00"; | ||
| 3978 | + List<Line> lineList = lineRepository.findLineByCode(line); | ||
| 3979 | + if (lineList.size() > 0) { | ||
| 3980 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 3981 | + + " id = (" | ||
| 3982 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 3983 | + + ")"; | ||
| 3984 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 3985 | + } | ||
| 3986 | + String[] minSjs = minfcsj.split(":"); | ||
| 3987 | + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 3988 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 3989 | + ScheduleRealInfo s = listInfo.get(i); | ||
| 3990 | + if (s.getBcType().equals("out")) { | ||
| 3991 | + s.setRemark("1"); | ||
| 3992 | + } else if (s.getBcType().equals("in")) { | ||
| 3993 | + s.setRemark("3"); | ||
| 3994 | + } else { | ||
| 3995 | + s.setRemark("2"); | ||
| 3996 | + } | ||
| 3997 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 3998 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 3999 | + | ||
| 4000 | + Long fscjT = 0L; | ||
| 4001 | + if (fcsjL < minSj) { | ||
| 4002 | + Calendar calendar = new GregorianCalendar(); | ||
| 4003 | + calendar.setTime(s.getScheduleDate()); | ||
| 4004 | + calendar.add(calendar.DATE, 1); | ||
| 4005 | + Date date_sch=calendar.getTime(); | ||
| 4006 | + try { | ||
| 4007 | + fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime(); | ||
| 4008 | + } catch (ParseException e) { | ||
| 4009 | + // TODO Auto-generated catch block | ||
| 4010 | + e.printStackTrace(); | ||
| 4011 | + } | ||
| 4012 | + | ||
| 4013 | + } else { | ||
| 4014 | + try { | ||
| 4015 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 4016 | + } catch (ParseException e) { | ||
| 4017 | + // TODO Auto-generated catch block | ||
| 4018 | + e.printStackTrace(); | ||
| 4019 | + } | ||
| 4020 | + ; | ||
| 4021 | + } | ||
| 4022 | + s.setFcsjT(fscjT); | ||
| 4023 | + } | ||
| 4024 | + | ||
| 4025 | +// Collections.sort(listInfo, new compareLpFcsjType()); | ||
| 4026 | + List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); | ||
| 4027 | + | ||
| 4028 | + Collections.sort(listInfo, new compareLpFcsjType()); | ||
| 4029 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 4030 | + ScheduleRealInfo t = listInfo.get(i); | ||
| 4031 | + if (!lpName.equals(t.getLpName())) { | ||
| 4032 | + zdsjActual = t.getZdsjActual(); | ||
| 4033 | + zdsj = t.getZdsj(); | ||
| 4034 | + t.setZdsjActual(""); | ||
| 4035 | + t.setZdsj(""); | ||
| 4036 | + } else { | ||
| 4037 | + zdsj1 = t.getZdsj(); | ||
| 4038 | + zdsjActual1 = t.getZdsjActual(); | ||
| 4039 | + t.setZdsjActual(zdsjActual); | ||
| 4040 | + t.setZdsj(zdsj); | ||
| 4041 | + zdsj = zdsj1; | ||
| 4042 | + zdsjActual = zdsjActual1; | ||
| 4043 | + } | ||
| 4044 | + | ||
| 4045 | + | ||
| 4046 | + | ||
| 4047 | + lpName = t.getLpName(); | ||
| 4048 | + listInfo2.add(t); | ||
| 4049 | + | ||
| 4050 | + } | ||
| 4051 | + | ||
| 4052 | + Collections.sort(listInfo2,new compareDirLpFcsjType()); | ||
| 4053 | + for (int i = 0; i < listInfo2.size(); i++) { | ||
| 4054 | + ScheduleRealInfo t=listInfo2.get(i); | ||
| 4055 | + list.add(t); | ||
| 4056 | + Set<ChildTaskPlan> childTaskPlans = t.getcTasks(); | ||
| 4057 | + //计算营运里程,空驶里程 | ||
| 4058 | + if (!childTaskPlans.isEmpty()) { | ||
| 4059 | + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 4060 | + Collections.sort(listit, new ComparableChild()); | ||
| 4061 | + for (int j = 0; j < listit.size(); j++) { | ||
| 4062 | + ScheduleRealInfo s = new ScheduleRealInfo(); | ||
| 4063 | + ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 4064 | + if (childTaskPlan.getCcId() == null) { | ||
| 4065 | + if (childTaskPlan.isDestroy()) { | ||
| 4066 | + s.setFcsjActual(""); | ||
| 4067 | + s.setZdsjActual(""); | ||
| 4068 | + } else { | ||
| 4069 | + s.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 4070 | + s.setZdsjActual(""); | ||
| 4071 | + s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 4072 | + } | ||
| 4073 | + s.setFcsj(childTaskPlan.getStartDate()); | ||
| 4074 | + s.setZdsj(""); | ||
| 4075 | + s.setQdzName(childTaskPlan.getStartStationName()); | ||
| 4076 | + s.setZdzName(childTaskPlan.getEndStationName()); | ||
| 4077 | + s.setRemarks(childTaskPlan.getRemarks()); | ||
| 4078 | + s.setAdjustExps("子"); | ||
| 4079 | + s.setLpName(""); | ||
| 4080 | + list.add(s); | ||
| 4081 | + } | ||
| 4082 | + } | ||
| 4083 | + } | ||
| 4084 | + } | ||
| 4085 | + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | ||
| 4086 | + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | ||
| 4087 | + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | ||
| 4088 | + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 4089 | + if (list.size() > 0) { | ||
| 4090 | + int a = list.size() % 3; | ||
| 4091 | + int b = list.size() / 3; | ||
| 4092 | + int x = 0, y = 0; | ||
| 4093 | + if (a == 2) { | ||
| 4094 | + x = b + 1; | ||
| 4095 | + y = x * 2; | ||
| 4096 | + } else if (a == 1) { | ||
| 4097 | + x = b + 1; | ||
| 4098 | + y = x * 2 - 1; | ||
| 4099 | + } else { | ||
| 4100 | + x = b; | ||
| 4101 | + y = 2 * x; | ||
| 4102 | + | ||
| 4103 | + } | ||
| 4104 | + for (int i = 0; i < list.size(); i++) { | ||
| 4105 | + ScheduleRealInfo s = list.get(i); | ||
| 4106 | + if (i + 1 <= x) { | ||
| 4107 | + xList.add(s); | ||
| 4108 | + } else if ((i + 1) > x && (i + 1) <= y) { | ||
| 4109 | + yList.add(s); | ||
| 4110 | + } else { | ||
| 4111 | + zList.add(s); | ||
| 4112 | + } | ||
| 4113 | + } | ||
| 4114 | + for (int i = 0; i < x; i++) { | ||
| 4115 | + newList.add(xList.get(i)); | ||
| 4116 | + if (yList.size() > i) { | ||
| 4117 | + newList.add(yList.get(i)); | ||
| 4118 | + } else { | ||
| 4119 | + newList.add(new ScheduleRealInfo()); | ||
| 4120 | + } | ||
| 4121 | + if (zList.size() > i) { | ||
| 4122 | + newList.add(zList.get(i)); | ||
| 4123 | + } else { | ||
| 4124 | + newList.add(new ScheduleRealInfo()); | ||
| 4125 | + } | ||
| 4126 | + | ||
| 4127 | + } | ||
| 4128 | + } | ||
| 4129 | + /* for (int i = 0; i < newList.size(); i++) { | ||
| 4130 | + ScheduleRealInfo t1 = newList.get(i); | ||
| 4131 | + for (int j = 0; j < list.size(); j++) { | ||
| 4132 | + ScheduleRealInfo t2 = list.get(j); | ||
| 4133 | + if (t1.getId() == t2.getId()) { | ||
| 4134 | + t1 = t2; | ||
| 4135 | + } | ||
| 4136 | + } | ||
| 4137 | + }*/ | ||
| 4138 | + | ||
| 4139 | + for (int i = 0; i < newList.size(); i++) { | ||
| 4140 | + ScheduleRealInfo t1 = newList.get(i); | ||
| 4141 | + String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks(); | ||
| 4142 | + if (reamrks1.length() > 4) { | ||
| 4143 | + t1.setRemarks(reamrks1.substring(0, 4)); | ||
| 4144 | + t1.setRemark(reamrks1); | ||
| 4145 | + } else { | ||
| 4146 | + t1.setRemark(reamrks1); | ||
| 4147 | + } | ||
| 4148 | + } | ||
| 4149 | + return newList; | ||
| 4150 | + } | ||
| 4151 | + | ||
| 4152 | + @Override | ||
| 4153 | + public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) { | ||
| 4154 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 4155 | + String lpName = "lpName"; | ||
| 4156 | + String zdsj = ""; | ||
| 4157 | + String zdsjActual = ""; | ||
| 4158 | + String zdsj1 = ""; | ||
| 4159 | + String zdsjActual1 = ""; | ||
| 4160 | + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | ||
| 4161 | + | ||
| 4162 | + for (ScheduleRealInfo s : listInfo) { | ||
| 4163 | + if (s.isDestroy() && s.isReissue()) { | ||
| 4164 | + s.setRemark(""); | ||
| 4165 | + s.setFcsjActual(s.getDfsj()); | ||
| 4166 | + s.setZdsjActual(s.getZdsj()); | ||
| 4167 | + s.setStatus(2); | ||
| 4168 | + s.setJhlc(s.getJhlcOrig()); | ||
| 4169 | + } | ||
| 4170 | + } | ||
| 4171 | + | ||
| 4172 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 4173 | + ScheduleRealInfo t = listInfo.get(i); | ||
| 4174 | + if (!lpName.equals(t.getLpName())) { | ||
| 4175 | + zdsjActual = t.getZdsjActual(); | ||
| 4176 | + zdsj = t.getZdsj(); | ||
| 4177 | + t.setZdsjActual(""); | ||
| 4178 | + t.setZdsj(""); | ||
| 4179 | + } else { | ||
| 4180 | + zdsj1 = t.getZdsj(); | ||
| 4181 | + zdsjActual1 = t.getZdsjActual(); | ||
| 4182 | + t.setZdsjActual(zdsjActual); | ||
| 4183 | + t.setZdsj(zdsj); | ||
| 4184 | + zdsj = zdsj1; | ||
| 4185 | + zdsjActual = zdsjActual1; | ||
| 4186 | + } | ||
| 4187 | + lpName = t.getLpName(); | ||
| 4188 | + list.add(t); | ||
| 4189 | + } | ||
| 4190 | + | ||
| 4191 | + List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp2(line, date); | ||
| 4192 | + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | ||
| 4193 | + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | ||
| 4194 | + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | ||
| 4195 | + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 4196 | + if (listInfo2.size() > 0) { | ||
| 4197 | + int a = listInfo2.size() % 3; | ||
| 4198 | + int b = listInfo2.size() / 3; | ||
| 4199 | + int x = 0, y = 0; | ||
| 4200 | + if (a == 2) { | ||
| 4201 | + x = b + 1; | ||
| 4202 | + y = x * 2; | ||
| 4203 | + } else if (b == 1) { | ||
| 4204 | + x = b + 1; | ||
| 4205 | + y = x * 2 - 1; | ||
| 4206 | + } else { | ||
| 4207 | + x = b; | ||
| 4208 | + y = 2 * x; | ||
| 4209 | + | ||
| 4210 | + } | ||
| 4211 | + for (int i = 0; i < listInfo2.size(); i++) { | ||
| 4212 | + ScheduleRealInfo s = listInfo2.get(i); | ||
| 4213 | + if (i + 1 <= x) { | ||
| 4214 | + xList.add(s); | ||
| 4215 | + } else if ((i + 1) > x && (i + 1) <= y) { | ||
| 4216 | + yList.add(s); | ||
| 4217 | + } else { | ||
| 4218 | + zList.add(s); | ||
| 4219 | + } | ||
| 4220 | + } | ||
| 4221 | + for (int i = 0; i < x; i++) { | ||
| 4222 | + newList.add(xList.get(i)); | ||
| 4223 | + if (yList.size() > i) { | ||
| 4224 | + newList.add(yList.get(i)); | ||
| 4225 | + } else { | ||
| 4226 | + newList.add(new ScheduleRealInfo()); | ||
| 4227 | + } | ||
| 4228 | + if (zList.size() > i) { | ||
| 4229 | + newList.add(zList.get(i)); | ||
| 4230 | + } else { | ||
| 4231 | + newList.add(new ScheduleRealInfo()); | ||
| 4232 | + } | ||
| 4233 | + | ||
| 4234 | + } | ||
| 4235 | + } | ||
| 4236 | + for (int i = 0; i < newList.size(); i++) { | ||
| 4237 | + ScheduleRealInfo t1 = newList.get(i); | ||
| 4238 | + for (int j = 0; j < list.size(); j++) { | ||
| 4239 | + ScheduleRealInfo t2 = list.get(j); | ||
| 4240 | + if (t1.getId() == t2.getId()) { | ||
| 4241 | + t1 = t2; | ||
| 4242 | + } | ||
| 4243 | + } | ||
| 4244 | + } | ||
| 4245 | + return newList; | ||
| 4246 | + } | ||
| 4247 | + | ||
| 4248 | + @Override | ||
| 4249 | + public List<ScheduleRealInfo> realScheduleListQp(String line, String date) { | ||
| 4250 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 4251 | + String lpName = "lpName"; | ||
| 4252 | + String zdsj = ""; | ||
| 4253 | + String zdsjActual = ""; | ||
| 4254 | + String zdsj1 = ""; | ||
| 4255 | + String zdsjActual1 = ""; | ||
| 4256 | + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | ||
| 4257 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 4258 | + ScheduleRealInfo t = listInfo.get(i); | ||
| 4259 | + if (!lpName.equals(t.getLpName())) { | ||
| 4260 | + zdsjActual = t.getZdsjActual(); | ||
| 4261 | + zdsj = t.getZdsj(); | ||
| 4262 | + t.setZdsjActual(""); | ||
| 4263 | + t.setZdsj(""); | ||
| 4264 | + } else { | ||
| 4265 | + zdsj1 = t.getZdsj(); | ||
| 4266 | + zdsjActual1 = t.getZdsjActual(); | ||
| 4267 | + t.setZdsjActual(zdsjActual); | ||
| 4268 | + t.setZdsj(zdsj); | ||
| 4269 | + zdsj = zdsj1; | ||
| 4270 | + zdsjActual = zdsjActual1; | ||
| 4271 | + } | ||
| 4272 | + | ||
| 4273 | + lpName = t.getLpName(); | ||
| 4274 | + list.add(t); | ||
| 4275 | + } | ||
| 4276 | + return list; | ||
| 4277 | + } | ||
| 4278 | + | ||
| 4279 | + public List<Map<String, Object>> yesterdayDataList(String line, String date, String gsbm, String fgsbm, String jGh, String nbbm) { | ||
| 4280 | + List<Map<String, Object>> yesterdayDataList = new ArrayList<Map<String, Object>>(); | ||
| 4281 | + if (line.equals("")) { | ||
| 4282 | + yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date, gsbm, fgsbm, nbbm); | ||
| 4283 | + } else { | ||
| 4284 | + yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList_eq(line, date, gsbm, fgsbm, nbbm); | ||
| 4285 | + } | ||
| 4286 | + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date, gsbm, fgsbm); | ||
| 4287 | + for (int x = 0; x < yesterdayDataList.size(); x++) { | ||
| 4288 | + String jsy = yesterdayDataList.get(x).get("jGh").toString(); | ||
| 4289 | + String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); | ||
| 4290 | + String xlbm = yesterdayDataList.get(x).get("xlBm").toString(); | ||
| 4291 | + String lp = yesterdayDataList.get(x).get("lpName").toString(); | ||
| 4292 | + String realExecDate=yesterdayDataList.get(x).get("realExecDate").toString(); | ||
| 4293 | + String fcsj[] =realExecDate.split(" "); | ||
| 4294 | + //取出最小计划发车时间 | ||
| 4295 | + yesterdayDataList.get(x).put("fcsj", fcsj[1]); | ||
| 4296 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 4297 | + boolean fage = true; | ||
| 4298 | + String company = ""; | ||
| 4299 | + String bCompany = ""; | ||
| 4300 | + String lineName=""; | ||
| 4301 | + String jName=""; | ||
| 4302 | + List<ScheduleRealInfo> listS = new ArrayList<ScheduleRealInfo>(); | ||
| 4303 | + for (ScheduleRealInfo scheduleRealInfo : lists) { | ||
| 4304 | + if (scheduleRealInfo.getjGh().equals(jsy) | ||
| 4305 | + && scheduleRealInfo.getClZbh().equals(clZbh) | ||
| 4306 | + && scheduleRealInfo.getXlBm().equals(xlbm) | ||
| 4307 | + && scheduleRealInfo.getLpName().equals(lp)) { | ||
| 4308 | + if (fage) { | ||
| 4309 | + //根据线路代码获取公司 | ||
| 4310 | + company = scheduleRealInfo.getGsBm(); | ||
| 4311 | + bCompany = scheduleRealInfo.getFgsBm(); | ||
| 4312 | + lineName = scheduleRealInfo.getXlName(); | ||
| 4313 | + jName= scheduleRealInfo.getjName(); | ||
| 4314 | + fage = false; | ||
| 4315 | + } | ||
| 4316 | + Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks(); | ||
| 4317 | + if (cts != null && cts.size() > 0) { | ||
| 4318 | + listS.add(scheduleRealInfo); | ||
| 4319 | + } else { | ||
| 4320 | + if (scheduleRealInfo.getZdsjActual() != null && scheduleRealInfo.getFcsjActual() != null) { | ||
| 4321 | + listS.add(scheduleRealInfo); | ||
| 4322 | + } | ||
| 4323 | + } | ||
| 4324 | + } | ||
| 4325 | + } | ||
| 4326 | + yesterdayDataList.get(x).put("company", company); | ||
| 4327 | + yesterdayDataList.get(x).put("bCompany", bCompany); | ||
| 4328 | + yesterdayDataList.get(x).put("lineName", lineName); | ||
| 4329 | + yesterdayDataList.get(x).put("jName", jName); | ||
| 4330 | + Double ljgl = culateMieageService.culateLjgl(listS); | ||
| 4331 | + Double sjgl = culateMieageService.culateSjgl(listS); | ||
| 4332 | + Double ksgl = culateMieageService.culateKsgl(listS); | ||
| 4333 | + Double jccgl = culateMieageService.culateJccgl(listS); | ||
| 4334 | + Double zyygl = Arith.add(sjgl, ljgl); | ||
| 4335 | + Double zksgl = Arith.add(ksgl, jccgl); | ||
| 4336 | + Double zlc = Arith.add(zyygl, zksgl); | ||
| 4337 | + yesterdayDataList.get(x).put("totalKilometers", zlc); | ||
| 4338 | + | ||
| 4339 | + } | ||
| 4340 | + //增加顺序号 | ||
| 4341 | + for (int i = 0; i < yesterdayDataList.size(); i++) { | ||
| 4342 | + if (i == 0) { | ||
| 4343 | + yesterdayDataList.get(i).put("seqNumber", 1); | ||
| 4344 | + } else { | ||
| 4345 | + if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) { | ||
| 4346 | + yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber")); | ||
| 4347 | + } else { | ||
| 4348 | + yesterdayDataList.get(i).put("seqNumber", 1); | ||
| 4349 | + } | ||
| 4350 | + } | ||
| 4351 | + } | ||
| 4352 | + | ||
| 4353 | + return yesterdayDataList; | ||
| 4354 | + } | ||
| 4355 | + | ||
| 4356 | + /** | ||
| 4357 | + * 批量调整人车 | ||
| 4358 | + */ | ||
| 4359 | + @Override | ||
| 4360 | + public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs, String userId) { | ||
| 4361 | + Map<String, Object> rs = new HashMap<>(); | ||
| 4362 | + Set<ScheduleRealInfo> set = new HashSet<>(); | ||
| 4363 | + | ||
| 4364 | + ScheduleRealInfo sch; | ||
| 4365 | + | ||
| 4366 | + String jGh = null, jName, sGh, sName; | ||
| 4367 | + for (ChangePersonCar cpc : cpcs) { | ||
| 4368 | + | ||
| 4369 | + sch = dayOfSchedule.get(cpc.getSchId()); | ||
| 4370 | + if (sch == null) | ||
| 4371 | + continue; | ||
| 4372 | + | ||
| 4373 | + if (cpc.getClZbh() != null) { | ||
| 4374 | + if (!carExist(sch.getGsBm(), cpc.getClZbh())) { | ||
| 4375 | + rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | ||
| 4376 | + rs.put("status", ResponseCode.ERROR); | ||
| 4377 | + return rs; | ||
| 4378 | + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(cpc.getClZbh()))) { | ||
| 4379 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + cpc.getClZbh() + "】的车辆"); | ||
| 4380 | + rs.put("status", ResponseCode.ERROR); | ||
| 4381 | + return rs; | ||
| 4382 | + } | ||
| 4383 | + } | ||
| 4384 | + | ||
| 4385 | + if (StringUtils.isNotEmpty(cpc.getJsy())) { | ||
| 4386 | + try{ | ||
| 4387 | + jGh = cpc.getJsy().split("/")[0]; | ||
| 4388 | + }catch (Exception e){ | ||
| 4389 | + logger.error("", e); | ||
| 4390 | + rs.put("msg", "驾驶员参数异常!!"); | ||
| 4391 | + rs.put("status", ResponseCode.ERROR); | ||
| 4392 | + return rs; | ||
| 4393 | + } | ||
| 4394 | + | ||
| 4395 | + jName = getPersonName(sch.getGsBm(), jGh); | ||
| 4396 | + if (StringUtils.isEmpty(jName)) { | ||
| 4397 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | ||
| 4398 | + rs.put("status", ResponseCode.ERROR); | ||
| 4399 | + return rs; | ||
| 4400 | + } | ||
| 4401 | + } | ||
| 4402 | + | ||
| 4403 | + | ||
| 4404 | + //为换人换车情况表写入数据 | ||
| 4405 | + schModifyLog.saveChangetochange(sch, cpc, userId); | ||
| 4406 | + //日志记录 | ||
| 4407 | + ScheduleModifyLogger.tzrc(sch, cpc, userId); | ||
| 4408 | + | ||
| 4409 | + //换驾驶员 | ||
| 4410 | + if (StringUtils.isNotEmpty(cpc.getJsy())) { | ||
| 4411 | + //换驾驶员 | ||
| 4412 | + if (persoChange(sch, jGh)) | ||
| 4413 | + set.add(sch); | ||
| 4414 | + } | ||
| 4415 | + | ||
| 4416 | + //换售票员 | ||
| 4417 | + if (StringUtils.isNotEmpty(cpc.getSpy()) | ||
| 4418 | + && !"/".equals(StringUtils.trim(cpc.getSpy()))) { | ||
| 4419 | + | ||
| 4420 | + sGh = cpc.getSpy().split("/")[0]; | ||
| 4421 | + sName = getPersonName(sch.getGsBm(), sGh); | ||
| 4422 | + if (StringUtils.isEmpty(sName)) { | ||
| 4423 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | ||
| 4424 | + rs.put("status", ResponseCode.ERROR); | ||
| 4425 | + return rs; | ||
| 4426 | + } | ||
| 4427 | + | ||
| 4428 | + /*if(!sGh.equals(sch.getsGh())) | ||
| 4429 | + sb.append(sch.getsGh() + " 换 " + sGh + ";");*/ | ||
| 4430 | + if (persoChangeSPY(sch, sGh)) | ||
| 4431 | + set.add(sch); | ||
| 4432 | + } else if (StringUtils.isNotEmpty(sch.getsGh())) { | ||
| 4433 | + sch.setsGh(""); | ||
| 4434 | + sch.setsName(""); | ||
| 4435 | + } | ||
| 4436 | + | ||
| 4437 | + //换车 | ||
| 4438 | + if (StringUtils.isNotEmpty(cpc.getClZbh()) && !cpc.getClZbh().equals(sch.getClZbh())) { | ||
| 4439 | + //sb.append(sch.getClZbh() + " 换 " + cpc.getClZbh() + ";"); | ||
| 4440 | + set.add(sch); | ||
| 4441 | + set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh())); | ||
| 4442 | + } | ||
| 4443 | + | ||
| 4444 | + /*if(sb.length() > 0) | ||
| 4445 | + sch.setRemarks(sb.toString());*/ | ||
| 4446 | + | ||
| 4447 | + dayOfSchedule.save(sch); | ||
| 4448 | + set.add(sch); | ||
| 4449 | + | ||
| 4450 | + } | ||
| 4451 | + rs.put("ts", set); | ||
| 4452 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4453 | + return rs; | ||
| 4454 | + } | ||
| 4455 | + | ||
| 4456 | + /** | ||
| 4457 | + * @Title: persoChange | ||
| 4458 | + * @Description: TODO(班次换驾驶员) | ||
| 4459 | + */ | ||
| 4460 | + public boolean persoChange(ScheduleRealInfo sch, String jGh) { | ||
| 4461 | + if (sch.getjGh().equals(jGh)) | ||
| 4462 | + return false; | ||
| 4463 | + String jName = getPersonName(sch.getGsBm(), jGh); | ||
| 4464 | + if (StringUtils.isNotEmpty(jName)) { | ||
| 4465 | + | ||
| 4466 | + if (jGh.indexOf("-") != -1) | ||
| 4467 | + sch.setjGh(jGh.substring(jGh.indexOf("-") + 1)); | ||
| 4468 | + else | ||
| 4469 | + sch.setjGh(jGh); | ||
| 4470 | + | ||
| 4471 | + sch.setjName(jName); | ||
| 4472 | + return true; | ||
| 4473 | + } | ||
| 4474 | + return false; | ||
| 4475 | + } | ||
| 4476 | + | ||
| 4477 | + /** | ||
| 4478 | + * @Title: persoChange | ||
| 4479 | + * @Description: TODO(班次换售票员) | ||
| 4480 | + */ | ||
| 4481 | + public boolean persoChangeSPY(ScheduleRealInfo sch, String sGh) { | ||
| 4482 | + if (sch.getsGh().equals(sGh)) | ||
| 4483 | + return false; | ||
| 4484 | + String sName = getPersonName(sch.getGsBm(), sGh); | ||
| 4485 | + if (StringUtils.isNotEmpty(sName)) { | ||
| 4486 | + if (sGh.indexOf("-") != -1) | ||
| 4487 | + sch.setsGh(sGh.substring(sGh.indexOf("-") + 1)); | ||
| 4488 | + else | ||
| 4489 | + sch.setsGh(sGh); | ||
| 4490 | + sch.setsName(sName); | ||
| 4491 | + return true; | ||
| 4492 | + } | ||
| 4493 | + return false; | ||
| 4494 | + } | ||
| 4495 | + | ||
| 4496 | + /** | ||
| 4497 | + * 批量待发调整 | ||
| 4498 | + */ | ||
| 4499 | + @Override | ||
| 4500 | + public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) { | ||
| 4501 | + Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>(); | ||
| 4502 | + List<ScheduleRealInfo> list = new ArrayList<>(); | ||
| 4503 | + | ||
| 4504 | + for (DfsjChange dc : dfsjcs) { | ||
| 4505 | + if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj())) | ||
| 4506 | + continue; | ||
| 4507 | + | ||
| 4508 | + tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null, "2", null); | ||
| 4509 | + | ||
| 4510 | + if (tempMap.get("status").equals(ResponseCode.SUCCESS)) { | ||
| 4511 | + list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts")); | ||
| 4512 | + } | ||
| 4513 | + } | ||
| 4514 | + | ||
| 4515 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4516 | + rs.put("ts", list); | ||
| 4517 | + return rs; | ||
| 4518 | + } | ||
| 4519 | + | ||
| 4520 | + | ||
| 4521 | + @Override | ||
| 4522 | + public Map<String, Object> findKMBC1(String jName, String clZbh, | ||
| 4523 | + String date, String enddate) { | ||
| 4524 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate); | ||
| 4525 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 4526 | +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 4527 | +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 4528 | + int jhbc = 0, cjbc = 0, ljbc = 0; | ||
| 4529 | + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0; | ||
| 4530 | + float addMileage = 0l, remMileage = 0l; | ||
| 4531 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 4532 | + for (ScheduleRealInfo scheduleRealInfo : list) { | ||
| 4533 | + if (scheduleRealInfo != null) { | ||
| 4534 | + //计划里程(主任务过滤掉临加班次), | ||
| 4535 | + //烂班里程(主任务烂班), | ||
| 4536 | + //临加里程(主任务临加), | ||
| 4537 | + //计划班次,烂班班次,增加班次 | ||
| 4538 | + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | ||
| 4539 | + if (scheduleRealInfo.isSflj()) { | ||
| 4540 | + addMileage += tempJhlc; | ||
| 4541 | + ljbc++; | ||
| 4542 | + } else { | ||
| 4543 | + jhlc += tempJhlc; | ||
| 4544 | + jhbc++; | ||
| 4545 | + if (scheduleRealInfo.getStatus() == -1) { | ||
| 4546 | + remMileage += tempJhlc; | ||
| 4547 | + cjbc++; | ||
| 4548 | + } | ||
| 4549 | + } | ||
| 4550 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 4551 | + //计算营运里程,空驶里程 | ||
| 4552 | + if (childTaskPlans.isEmpty()) { | ||
| 4553 | + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 4554 | + || scheduleRealInfo.getBcType().equals("venting")) { | ||
| 4555 | + ksgl += tempJhlc; | ||
| 4556 | + } else { | ||
| 4557 | + yygl += tempJhlc; | ||
| 4558 | + } | ||
| 4559 | + } else { | ||
| 4560 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 4561 | + while (it.hasNext()) { | ||
| 4562 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 4563 | + if (childTaskPlan.getMileageType().equals("empty")) { | ||
| 4564 | + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4565 | + } else { | ||
| 4566 | + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4567 | + } | ||
| 4568 | + } | ||
| 4569 | + } | ||
| 4570 | + } | ||
| 4571 | + } | ||
| 4572 | + map.put("jhlc", format.format(jhlc)); | ||
| 4573 | + map.put("remMileage", format.format(remMileage)); | ||
| 4574 | + map.put("addMileage", format.format(addMileage)); | ||
| 4575 | + map.put("yygl", format.format(yygl)); | ||
| 4576 | + map.put("ksgl", format.format(ksgl)); | ||
| 4577 | + map.put("realMileage", format.format(yygl + ksgl)); | ||
| 4578 | + map.put("jhbc", jhbc); | ||
| 4579 | + map.put("cjbc", cjbc); | ||
| 4580 | + map.put("ljbc", ljbc); | ||
| 4581 | + map.put("sjbc", jhbc - cjbc + ljbc); | ||
| 4582 | + return map; | ||
| 4583 | + } | ||
| 4584 | + | ||
| 4585 | + /** | ||
| 4586 | + * 调整班次类型 | ||
| 4587 | + * | ||
| 4588 | + * @param id | ||
| 4589 | + * @param bcType | ||
| 4590 | + * @param remarks | ||
| 4591 | + * @return | ||
| 4592 | + */ | ||
| 4593 | + @Override | ||
| 4594 | + public Map<String, Object> changeBcType(Long id, String bcType, String remarks, String majorStationName) { | ||
| 4595 | + Map<String, Object> rs = new HashMap<>(); | ||
| 4596 | + | ||
| 4597 | + try { | ||
| 4598 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 4599 | + if (sch != null) { | ||
| 4600 | + sch.setBcType(bcType); | ||
| 4601 | + sch.setRemarks(remarks); | ||
| 4602 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4603 | + rs.put("t", sch); | ||
| 4604 | + | ||
| 4605 | + if ("major".equals(bcType)) { | ||
| 4606 | + sch.setMajorStationName(majorStationName); | ||
| 4607 | + } | ||
| 4608 | + | ||
| 4609 | + dayOfSchedule.save(sch); | ||
| 4610 | + } | ||
| 4611 | + } catch (Exception e) { | ||
| 4612 | + logger.error("", e); | ||
| 4613 | + rs.put("status", ResponseCode.ERROR); | ||
| 4614 | + } | ||
| 4615 | + | ||
| 4616 | + return rs; | ||
| 4617 | + } | ||
| 4618 | + | ||
| 4619 | + @Override | ||
| 4620 | + public Map<String, Object> historySave(ScheduleRealInfo sch) { | ||
| 4621 | + Map<String, Object> rs = new HashMap<>(); | ||
| 4622 | + rs.put("status", ResponseCode.ERROR); | ||
| 4623 | + | ||
| 4624 | + ScheduleRealInfo oldSch = super.findById(sch.getId()); | ||
| 4625 | + // 检查调度日期 | ||
| 4626 | + DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 4627 | + long today = formatter.parseMillis(new DateTime().toString("yyyy-MM-dd")), scheduleDate = formatter.parseMillis(oldSch.getScheduleDateStr()); | ||
| 4628 | + if (today < scheduleDate || today - scheduleDate > 86400000 * PrivilegeUtils.getHistoryEditDays()) { | ||
| 4629 | + rs.put("status", ResponseCode.ERROR); | ||
| 4630 | + rs.put("msg", "无效的调度日期"); | ||
| 4631 | + return rs; | ||
| 4632 | + } | ||
| 4633 | + //事后日志记录 | ||
| 4634 | + AfterwardsLogger aflog = AfterwardsLogger.start(oldSch, "事后调整"); | ||
| 4635 | + | ||
| 4636 | + //换车 | ||
| 4637 | + if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) { | ||
| 4638 | + if (!carExist(oldSch.getGsBm(), sch.getClZbh())) { | ||
| 4639 | + rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!"); | ||
| 4640 | + return rs; | ||
| 4641 | + } else { | ||
| 4642 | + aflog.log("换车", oldSch.getClZbh(), sch.getClZbh()); | ||
| 4643 | + oldSch.setClZbh(sch.getClZbh()); | ||
| 4644 | + } | ||
| 4645 | + } | ||
| 4646 | + | ||
| 4647 | + //换驾驶员 | ||
| 4648 | + if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) { | ||
| 4649 | + String jName = getPersonName(oldSch.getGsBm(), sch.getjGh()); | ||
| 4650 | + if (StringUtils.isEmpty(jName)) { | ||
| 4651 | + rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | ||
| 4652 | + return rs; | ||
| 4653 | + } | ||
| 4654 | + aflog.log("换驾驶员", oldSch.getjGh() + "/" + oldSch.getjName(), sch.getjGh() + "/" + sch.getjName()); | ||
| 4655 | + persoChange(oldSch, sch.getjGh()); | ||
| 4656 | + } | ||
| 4657 | + | ||
| 4658 | + //换售票员 | ||
| 4659 | + if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) { | ||
| 4660 | + String sName = getPersonName(oldSch.getGsBm(), sch.getsGh()); | ||
| 4661 | + if (StringUtils.isEmpty(sName)) { | ||
| 4662 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员"); | ||
| 4663 | + return rs; | ||
| 4664 | + } | ||
| 4665 | + aflog.log("换售票员", oldSch.getsGh() + "/" + oldSch.getsName(), sch.getsGh() + "/" + sch.getsName()); | ||
| 4666 | + persoChangeSPY(oldSch, sch.getsGh()); | ||
| 4667 | + } | ||
| 4668 | + | ||
| 4669 | + //烂班 | ||
| 4670 | + boolean dest1 = oldSch.getStatus() == -1; | ||
| 4671 | + boolean dest2 = sch.getStatus() == -1; | ||
| 4672 | + if (!dest1 && dest2) { | ||
| 4673 | + oldSch.destroy(); | ||
| 4674 | + aflog.log("烂班"); | ||
| 4675 | + } else if (dest1 && !dest2) { | ||
| 4676 | + //撤销烂班 | ||
| 4677 | + oldSch.setJhlc(oldSch.getJhlcOrig()); | ||
| 4678 | + oldSch.setStatus(0); | ||
| 4679 | + oldSch.calcStatus(); | ||
| 4680 | + oldSch.setAdjustExps(null); | ||
| 4681 | + aflog.log("撤销烂班"); | ||
| 4682 | + } | ||
| 4683 | + | ||
| 4684 | + oldSch.setAdjustExps(sch.getAdjustExps()); | ||
| 4685 | + | ||
| 4686 | + /** | ||
| 4687 | + * 修改班次里程 | ||
| 4688 | + */ | ||
| 4689 | + if (!oldSch.getJhlc().equals(sch.getJhlc())) { | ||
| 4690 | + double jhlcNum = sch.getJhlc(); | ||
| 4691 | + aflog.log("修改班次里程", oldSch.getJhlc(), jhlcNum); | ||
| 4692 | + //烂班 | ||
| 4693 | + if (jhlcNum == 0 && oldSch.getJhlcOrig() != 0) | ||
| 4694 | + oldSch.destroy(); | ||
| 4695 | + else { | ||
| 4696 | + oldSch.setJhlc(jhlcNum); | ||
| 4697 | + //临加班次,实际计划一起改 | ||
| 4698 | + if (oldSch.isSflj()) | ||
| 4699 | + oldSch.setJhlcOrig(jhlcNum); | ||
| 4700 | + } | ||
| 4701 | + } | ||
| 4702 | + | ||
| 4703 | + //待发时间 | ||
| 4704 | + if (!CustomStringUtils.equals(oldSch.getDfsj(), sch.getDfsj())) { | ||
| 4705 | + aflog.log("修改待发时间", oldSch.getDfsj(), sch.getDfsj()); | ||
| 4706 | + oldSch.setDfsj(sch.getDfsj()); | ||
| 4707 | + } | ||
| 4708 | + //实发时间 | ||
| 4709 | + if (!CustomStringUtils.equals(oldSch.getFcsjActual(), sch.getFcsjActual())) { | ||
| 4710 | + aflog.log("修改实发时间", oldSch.getFcsjActual(), sch.getFcsjActual()); | ||
| 4711 | + oldSch.setFcsjActual(sch.getFcsjActual()); | ||
| 4712 | + } | ||
| 4713 | + //实际终点 | ||
| 4714 | + if (!CustomStringUtils.equals(oldSch.getZdsjActual(), sch.getZdsjActual())) { | ||
| 4715 | + aflog.log("修改实达时间", oldSch.getZdsjActual(), sch.getZdsjActual()); | ||
| 4716 | + oldSch.setZdsjActual(sch.getZdsjActual()); | ||
| 4717 | + } | ||
| 4718 | + | ||
| 4719 | + //备注 | ||
| 4720 | + if (!CustomStringUtils.equals(oldSch.getRemarks(), sch.getRemarks())) { | ||
| 4721 | + aflog.log("修改备注", oldSch.getRemarks(), sch.getRemarks()); | ||
| 4722 | + oldSch.setRemarks(sch.getRemarks()); | ||
| 4723 | + } | ||
| 4724 | + | ||
| 4725 | + scheduleRealInfoRepository.save(oldSch); | ||
| 4726 | + | ||
| 4727 | + aflog.end(); | ||
| 4728 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4729 | + return rs; | ||
| 4730 | + } | ||
| 4731 | + | ||
| 4732 | + @Autowired | ||
| 4733 | + SvgAttributeRepository svgAttributeRepository; | ||
| 4734 | + | ||
| 4735 | + @Override | ||
| 4736 | + public Map<String, Object> svgAttr(String jsonStr) { | ||
| 4737 | + Map<String, Object> rs = new HashMap<>(); | ||
| 4738 | + | ||
| 4739 | + try { | ||
| 4740 | + JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr)); | ||
| 4741 | + | ||
| 4742 | + SvgAttribute svgAttribute = new SvgAttribute(); | ||
| 4743 | + svgAttribute.setLineCode(jObj.getString("lineCode")); | ||
| 4744 | + svgAttribute.setHideStations(jObj.getString("hideStations")); | ||
| 4745 | + svgAttribute.setNicknames(jObj.getString("nicknames")); | ||
| 4746 | + svgAttributeRepository.save(svgAttribute); | ||
| 4747 | + | ||
| 4748 | + rs.put("t", svgAttribute); | ||
| 4749 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4750 | + } catch (Exception e) { | ||
| 4751 | + logger.error("", e); | ||
| 4752 | + rs.put("status", ResponseCode.ERROR); | ||
| 4753 | + } | ||
| 4754 | + return rs; | ||
| 4755 | + } | ||
| 4756 | + | ||
| 4757 | + @Override | ||
| 4758 | + public Map<String, Object> findSvgAttr(String idx) { | ||
| 4759 | + Map<String, Object> rs = new HashMap<>(); | ||
| 4760 | + try { | ||
| 4761 | + List<String> lineCodes = Splitter.on(",").splitToList(idx); | ||
| 4762 | + List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes); | ||
| 4763 | + | ||
| 4764 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4765 | + rs.put("list", list); | ||
| 4766 | + } catch (Exception e) { | ||
| 4767 | + logger.error("", e); | ||
| 4768 | + rs.put("status", ResponseCode.ERROR); | ||
| 4769 | + } | ||
| 4770 | + return rs; | ||
| 4771 | + } | ||
| 4772 | + | ||
| 4773 | + @Override | ||
| 4774 | + public Map<String, Object> addRemarks(Long id, String remarks) { | ||
| 4775 | + Map<String, Object> rs = new HashMap<>(); | ||
| 4776 | + try { | ||
| 4777 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 4778 | + sch.addRemarks(remarks); | ||
| 4779 | + | ||
| 4780 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 4781 | + rs.put("t", sch); | ||
| 4782 | + } catch (Exception e) { | ||
| 4783 | + logger.error("", e); | ||
| 4784 | + rs.put("status", ResponseCode.ERROR); | ||
| 4785 | + } | ||
| 4786 | + return rs; | ||
| 4787 | + } | ||
| 4788 | + | ||
| 4789 | + @Override | ||
| 4790 | + public List<Map<String, Object>> yesterdayDataList(String line) { | ||
| 4791 | + // TODO Auto-generated method stub | ||
| 4792 | + return null; | ||
| 4793 | + } | ||
| 4794 | + | ||
| 4795 | + @Override | ||
| 4796 | + public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) { | ||
| 4797 | + // TODO Auto-generated method stub | ||
| 4798 | + ReportUtils ee = new ReportUtils(); | ||
| 4799 | + ReportRelatedUtils rru = new ReportRelatedUtils(); | ||
| 4800 | + List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | ||
| 4801 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | ||
| 4802 | + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 4803 | + | ||
| 4804 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 4805 | +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 4806 | +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 4807 | + int jhbc = 0, cjbc = 0, ljbc = 0; | ||
| 4808 | + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; | ||
| 4809 | + float addMileage = 0l, remMileage = 0l, addgl = 0, remgl = 0; | ||
| 4810 | + int xyz = 1; | ||
| 4811 | + Map<String, Object> map; | ||
| 4812 | + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | ||
| 4813 | + if (scheduleRealInfo != null) { | ||
| 4814 | + //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次 | ||
| 4815 | + //计划里程(主任务过滤掉临加班次), | ||
| 4816 | + //烂班里程(主任务烂班), | ||
| 4817 | + //临加里程(主任务临加), | ||
| 4818 | + //计划班次,烂班班次,增加班次 | ||
| 4819 | + double jh = 0, sj = 0; | ||
| 4820 | + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | ||
| 4821 | + if (scheduleRealInfo.isSflj()) { | ||
| 4822 | + ljbc++; | ||
| 4823 | + } else { | ||
| 4824 | + if (!(scheduleRealInfo.getBcType().equals("in") | ||
| 4825 | + || scheduleRealInfo.getBcType().equals("out"))) { | ||
| 4826 | + jhbc++; | ||
| 4827 | + jh += tempJhlc; | ||
| 4828 | + } | ||
| 4829 | + if (scheduleRealInfo.getStatus() == -1) { | ||
| 4830 | + remMileage += tempJhlc; | ||
| 4831 | + cjbc++; | ||
| 4832 | + } | ||
| 4833 | + } | ||
| 4834 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 4835 | + //计算营运里程,空驶里程 | ||
| 4836 | + if (childTaskPlans.isEmpty()) { | ||
| 4837 | + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 4838 | + ) { | ||
| 4839 | + jcclc += tempJhlc; | ||
| 4840 | + } else { | ||
| 4841 | + if (scheduleRealInfo.getStatus() != -1) { | ||
| 4842 | + if (scheduleRealInfo.isSflj()) { | ||
| 4843 | + addMileage += tempJhlc; | ||
| 4844 | + } | ||
| 4845 | + sj += tempJhlc; | ||
| 4846 | + } | ||
| 4847 | + } | ||
| 4848 | + } else { | ||
| 4849 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 4850 | + while (it.hasNext()) { | ||
| 4851 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 4852 | + if (childTaskPlan.getMileageType().equals("empty")) { | ||
| 4853 | + if (childTaskPlan.isDestroy()) { | ||
| 4854 | + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4855 | + } else { | ||
| 4856 | + if (scheduleRealInfo.isSflj()) { | ||
| 4857 | + addMileage += tempJhlc; | ||
| 4858 | + } | ||
| 4859 | + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4860 | + } | ||
| 4861 | + } else { | ||
| 4862 | + if (childTaskPlan.isDestroy()) { | ||
| 4863 | + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4864 | +// cjbc++; | ||
| 4865 | + } else { | ||
| 4866 | + if (scheduleRealInfo.isSflj()) { | ||
| 4867 | + addMileage += tempJhlc; | ||
| 4868 | + } | ||
| 4869 | + sj += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | ||
| 4870 | + } | ||
| 4871 | + } | ||
| 4872 | + } | ||
| 4873 | + } | ||
| 4874 | + | ||
| 4875 | + if (!(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out"))) { | ||
| 4876 | + map = new HashMap<String, Object>(); | ||
| 4877 | + try { | ||
| 4878 | + scheduleRealInfo.setBcs(xyz); | ||
| 4879 | + xyz++; | ||
| 4880 | + Set<ChildTaskPlan> cs = scheduleRealInfo.getcTasks(); | ||
| 4881 | + Double sjlc = 0.0; | ||
| 4882 | + if (!cs.isEmpty()) { | ||
| 4883 | + Iterator<ChildTaskPlan> it = cs.iterator(); | ||
| 4884 | + while (it.hasNext()) { | ||
| 4885 | + ChildTaskPlan c = it.next(); | ||
| 4886 | + if (!c.isDestroy()) { | ||
| 4887 | + sjlc += c.getMileage() == null ? 0 : c.getMileage(); | ||
| 4888 | + } | ||
| 4889 | + | ||
| 4890 | + } | ||
| 4891 | + } else { | ||
| 4892 | + if (scheduleRealInfo.getStatus() != -1) { | ||
| 4893 | + sjlc = scheduleRealInfo.getJhlc(); | ||
| 4894 | + } | ||
| 4895 | + } | ||
| 4896 | + scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | ||
| 4897 | + scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | ||
| 4898 | + scheduleRealInfo.setSjlc(format.format(sjlc)); | ||
| 4899 | + map = rru.getMapValue(scheduleRealInfo); | ||
| 4900 | + String zdsj = scheduleRealInfo.getZdsj(); | ||
| 4901 | + String zdsjActual = scheduleRealInfo.getZdsjActual(); | ||
| 4902 | + if (zdsj != null && zdsjActual != null && | ||
| 4903 | + !zdsj.equals(zdsjActual)) { | ||
| 4904 | + int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | ||
| 4905 | + int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | ||
| 4906 | + if (zdsj.compareTo(zdsjActual) > 0) { | ||
| 4907 | + if (zdsjT - zdsjAT > 1000) { | ||
| 4908 | + map.put("fast", ""); | ||
| 4909 | + map.put("slow", zdsjAT - zdsjT + 1440); | ||
| 4910 | + } else { | ||
| 4911 | + map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 4912 | + map.put("slow", ""); | ||
| 4913 | + } | ||
| 4914 | + } else { | ||
| 4915 | + if (zdsjAT - zdsjT > 1000) { | ||
| 4916 | + map.put("fast", zdsjT - zdsjAT + 1440); | ||
| 4917 | + map.put("slow", ""); | ||
| 4918 | + } else { | ||
| 4919 | + map.put("fast", ""); | ||
| 4920 | + map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 4921 | + } | ||
| 4922 | + } | ||
| 4923 | + } else { | ||
| 4924 | + map.put("fast", ""); | ||
| 4925 | + map.put("slow", ""); | ||
| 4926 | + } | ||
| 4927 | + listMap.add(map); | ||
| 4928 | + } catch (Exception e) { | ||
| 4929 | + e.printStackTrace(); | ||
| 4930 | + } | ||
| 4931 | + } | ||
| 4932 | + jhlc += jh; | ||
| 4933 | + yygl += sj; | ||
| 4934 | + if (jh > sj) { | ||
| 4935 | + remgl += jh - sj; | ||
| 4936 | + } else { | ||
| 4937 | + addgl += sj - jh; | ||
| 4938 | + } | ||
| 4939 | + } | ||
| 4940 | + } | ||
| 4941 | + | ||
| 4942 | + | ||
| 4943 | + List<Ylxxb> listYlxxb = ylxxbRepository.queryListYlxxb(clZbh, date); | ||
| 4944 | + Double jzl = 0.0; | ||
| 4945 | + for (int t = 0; t < listYlxxb.size(); t++) { | ||
| 4946 | + Ylxxb y = listYlxxb.get(t); | ||
| 4947 | + jzl += y.getJzl(); | ||
| 4948 | + } | ||
| 4949 | + | ||
| 4950 | + //计算里程和班次数,并放入Map里 | ||
| 4951 | + map = findKMBCQp(clZbh, date, line); | ||
| 4952 | + map.put("jzl", jzl); | ||
| 4953 | +// map.put("jhlc", format.format(jhlc + jcclc)); | ||
| 4954 | +// map.put("yygljh", format.format(jhlc)); | ||
| 4955 | +// map.put("ssgl", format.format(remMileage)); | ||
| 4956 | +// map.put("ksgl", format.format(ksgl)); | ||
| 4957 | +// map.put("yyglsj", format.format(yygl)); | ||
| 4958 | +// map.put("jhbc", jhbc); | ||
| 4959 | +// map.put("jcclc", jcclc); | ||
| 4960 | +// | ||
| 4961 | +// map.put("ljgl", format.format(addMileage)); | ||
| 4962 | +// map.put("ssbc", cjbc); | ||
| 4963 | +// map.put("ysgl", format.format(yygl)); | ||
| 4964 | +// map.put("sjbc", jhbc - cjbc + ljbc); | ||
| 4965 | +// map.put("zgl", format.format(yygl + ksgl + jcclc)); | ||
| 4966 | +// map.put("ljbc", ljbc); | ||
| 4967 | + | ||
| 4968 | + String zdp = "", zwdp = "", wdp = ""; | ||
| 4969 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 4970 | + List<DutyEmployee> listDtuy = dutyEmployeeService.getDutyEmployee(line, date + "00:00", date + "23:59"); | ||
| 4971 | + try { | ||
| 4972 | + Long fcsj1 = sdf.parse(date + " 03:00").getTime(); | ||
| 4973 | + Long fcsj2 = sdf.parse(date + " 11:00").getTime(); | ||
| 4974 | + Long fcsj3 = sdf.parse(date + " 22:00").getTime(); | ||
| 4975 | + for (int i = 0; i < listDtuy.size(); i++) { | ||
| 4976 | + DutyEmployee t = listDtuy.get(i); | ||
| 4977 | + Long ts = t.getTs(); | ||
| 4978 | + if (ts > fcsj1 && ts < fcsj2) { | ||
| 4979 | + if (zdp.indexOf(t.getuName()) == -1) { | ||
| 4980 | + zdp += t.getuName() + ","; | ||
| 4981 | + | ||
| 4982 | + } | ||
| 4983 | + } else if (ts > fcsj2 && ts < fcsj3) { | ||
| 4984 | + if (zwdp.indexOf(t.getuName()) == -1) { | ||
| 4985 | + zwdp += t.getuName() + ","; | ||
| 4986 | + } | ||
| 4987 | + } else { | ||
| 4988 | + if (wdp.indexOf(t.getuName()) == -1) { | ||
| 4989 | + wdp += t.getuName() + ","; | ||
| 4990 | + } | ||
| 4991 | + } | ||
| 4992 | + } | ||
| 4993 | + } catch (ParseException e) { | ||
| 4994 | + // TODO Auto-generated catch block | ||
| 4995 | + e.printStackTrace(); | ||
| 4996 | + } | ||
| 4997 | + map.put("zdp", zdp); | ||
| 4998 | + map.put("zwdp", zwdp); | ||
| 4999 | + map.put("wdp", wdp); | ||
| 5000 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 5001 | + list.add(listMap.iterator()); | ||
| 5002 | + ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/waybill_qingpu.xls", | ||
| 5003 | + path + "export/" + date + "-" + clZbh + "-行车路单.xls"); | ||
| 5004 | + | ||
| 5005 | + return scheduleRealInfos; | ||
| 5006 | + } | ||
| 5007 | + | ||
| 5008 | + @Override | ||
| 5009 | + public Map<String, Object> findKMBCQp(String clZbh, String date, String line) { | ||
| 5010 | + // TODO Auto-generated method stub | ||
| 5011 | + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | ||
| 5012 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 5013 | +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 5014 | +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 5015 | + int jhbc = 0, cjbc = 0, ljbc = 0, sjbc = 0; | ||
| 5016 | + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0, ljjcclc = 0, jhjcclc = 0; | ||
| 5017 | + double addMileage = 0, remMileage = 0, addgl = 0, remgl = 0; | ||
| 5018 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 5019 | + jhlc = culateMieageService.culateJhgl(lists); | ||
| 5020 | + jcclc = culateMieageService.culateJccgl(lists); | ||
| 5021 | + jhjcclc = culateMieageService.culateJhJccgl(lists); | ||
| 5022 | + remMileage = culateMieageService.culateLbgl(lists); | ||
| 5023 | + ksgl = culateMieageService.culateKsgl(lists); | ||
| 5024 | + yygl = culateMieageService.culateSjgl(lists); | ||
| 5025 | + jhbc = culateMieageService.culateJhbc(lists, ""); | ||
| 5026 | + addMileage = culateMieageService.culateLjgl(lists); | ||
| 5027 | + cjbc = culateMieageService.culateLbbc(lists); | ||
| 5028 | + sjbc = culateMieageService.culateSjbc(lists, ""); | ||
| 5029 | + ljbc = culateMieageService.culateLjbc(lists, ""); | ||
| 5030 | + double zyygl = Arith.add(yygl, addMileage); | ||
| 5031 | + double zksgl = Arith.add(ksgl, jcclc); | ||
| 5032 | + map.put("jhlc", Arith.add(jhlc, jhjcclc)); | ||
| 5033 | + map.put("yygljh", jhlc); | ||
| 5034 | + map.put("ssgl", remMileage); | ||
| 5035 | + map.put("ksgl", ksgl); | ||
| 5036 | + map.put("yyglsj", Arith.add(yygl, addMileage)); | ||
| 5037 | + map.put("jcclc", jcclc); | ||
| 5038 | + map.put("jhbc", jhbc); | ||
| 5039 | + map.put("ljgl", addMileage); | ||
| 5040 | + map.put("ssbc", cjbc); | ||
| 5041 | + map.put("ysgl", Arith.add(yygl, addMileage)); | ||
| 5042 | + map.put("sjbc", sjbc); | ||
| 5043 | + map.put("zgl", Arith.add(zyygl, zksgl)); | ||
| 5044 | + map.put("ljbc", ljbc); | ||
| 5045 | + | ||
| 5046 | + return map; | ||
| 5047 | + } | ||
| 5048 | + | ||
| 5049 | + @Override | ||
| 5050 | + public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) { | ||
| 5051 | + // TODO Auto-generated method stub | ||
| 5052 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 5053 | + List<ScheduleRealInfo> list = null; | ||
| 5054 | + list = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | ||
| 5055 | + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 5056 | + for (int i = 0; i < list.size(); i++) { | ||
| 5057 | + ScheduleRealInfo s = list.get(i); | ||
| 5058 | + if (!(s.getBcType().equals("in") || s.getBcType().equals("out"))) { | ||
| 5059 | + String remarks = ""; | ||
| 5060 | + Double sjlc = 0.0; | ||
| 5061 | + if (s.getRemarks() != null) { | ||
| 5062 | + remarks += s.getRemarks(); | ||
| 5063 | + } | ||
| 5064 | + Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 5065 | + if (!childTaskPlans.isEmpty()) { | ||
| 5066 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 5067 | + while (it.hasNext()) { | ||
| 5068 | + ChildTaskPlan c = it.next(); | ||
| 5069 | + if (c.getRemarks() != null && c.getRemarks().length() > 0) { | ||
| 5070 | + if (remarks.indexOf(c.getRemarks()) == -1) { | ||
| 5071 | + remarks += c.getRemarks(); | ||
| 5072 | + } | ||
| 5073 | + } | ||
| 5074 | + | ||
| 5075 | + if (!c.isDestroy()) { | ||
| 5076 | + if (c.getMileageType().equals("service")) { | ||
| 5077 | + sjlc += c.getMileage() == null ? 0 : c.getMileage(); | ||
| 5078 | + } | ||
| 5079 | + } | ||
| 5080 | + | ||
| 5081 | + } | ||
| 5082 | + } else { | ||
| 5083 | + if (s.getStatus() != -1) { | ||
| 5084 | + sjlc = s.getJhlc(); | ||
| 5085 | + } | ||
| 5086 | + } | ||
| 5087 | + s.setSjlc(format.format(sjlc)); | ||
| 5088 | + s.setRemarks(remarks); | ||
| 5089 | + newList.add(s); | ||
| 5090 | + } | ||
| 5091 | + | ||
| 5092 | + } | ||
| 5093 | + | ||
| 5094 | + return newList; | ||
| 5095 | + } | ||
| 5096 | + | ||
| 5097 | + @Override | ||
| 5098 | + public Map<String, Object> MapById(Long id) { | ||
| 5099 | + // TODO Auto-generated method stub | ||
| 5100 | + Map<String, Object> dMap=new HashMap<>(); | ||
| 5101 | + dMap.put("dGroup_eq", "oilType"); | ||
| 5102 | + Iterator<Dictionary> it= dictionaryService.list(dMap).iterator(); | ||
| 5103 | + while (it.hasNext()) { | ||
| 5104 | + Dictionary d=it.next(); | ||
| 5105 | + dMap.put(d.getdCode(), d.getdName()); | ||
| 5106 | + } | ||
| 5107 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 5108 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 5109 | + ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id); | ||
| 5110 | + String xlbm = s.getXlBm(); | ||
| 5111 | + String fcrq = s.getScheduleDateStr(); | ||
| 5112 | + | ||
| 5113 | + int type = 2; | ||
| 5114 | + Double ccyl = 0.0; | ||
| 5115 | + Double jcyl = 0.0; | ||
| 5116 | + Double yh = 0.0; | ||
| 5117 | + Double jzl = 0.0; | ||
| 5118 | + Double zlc = 0.0; | ||
| 5119 | + String rylx=""; | ||
| 5120 | + int hyd = 0; | ||
| 5121 | + Double czql = 0.0, jzql = 0.0, hq = 0.0, jql = 0.0; | ||
| 5122 | + List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh()); | ||
| 5123 | + if (listCars.size() > 0) { | ||
| 5124 | + if (listCars.get(0).getSfdc() != null) { | ||
| 5125 | + if (listCars.get(0).getSfdc()) { | ||
| 5126 | + List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | ||
| 5127 | + type = 1; | ||
| 5128 | + for (int i = 0; i < listDlb.size(); i++) { | ||
| 5129 | + Dlb d = listDlb.get(i); | ||
| 5130 | + if (d.getLp() == null) { | ||
| 5131 | + ccyl = Arith.add(ccyl, d.getCzcd()); | ||
| 5132 | + jcyl = Arith.add(jcyl, d.getJzcd()); | ||
| 5133 | + yh = Arith.add(yh, d.getHd()); | ||
| 5134 | + jzl = Arith.add(jzl, d.getCdl()); | ||
| 5135 | + zlc = Arith.add(zlc, d.getZlc()); | ||
| 5136 | + } else { | ||
| 5137 | + if (d.getLp().equals(s.getLpName())) { | ||
| 5138 | + ccyl = Arith.add(ccyl, d.getCzcd()); | ||
| 5139 | + jcyl = Arith.add(jcyl, d.getJzcd()); | ||
| 5140 | + yh = Arith.add(yh, d.getHd()); | ||
| 5141 | + jzl = Arith.add(jzl, d.getCdl()); | ||
| 5142 | + zlc = Arith.add(zlc, d.getZlc()); | ||
| 5143 | + } | ||
| 5144 | + } | ||
| 5145 | + | ||
| 5146 | + } | ||
| 5147 | + } else { | ||
| 5148 | + List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | ||
| 5149 | + type = 0; | ||
| 5150 | + for (int i = 0; i < listYlb.size(); i++) { | ||
| 5151 | + Ylb y = listYlb.get(i); | ||
| 5152 | + if (y.getLp() == null) { | ||
| 5153 | + ccyl = Arith.add(ccyl, y.getCzyl()); | ||
| 5154 | + jcyl = Arith.add(jcyl, y.getJzyl()); | ||
| 5155 | + yh = Arith.add(yh, y.getYh()); | ||
| 5156 | + jzl = Arith.add(jzl, y.getJzl()); | ||
| 5157 | + zlc = Arith.add(zlc, y.getZlc()); | ||
| 5158 | + if(dMap.get(y.getRylx())!=null) | ||
| 5159 | + rylx =dMap.get(y.getRylx()).toString(); | ||
| 5160 | + } else { | ||
| 5161 | + if (y.getLp().equals(s.getLpName())) { | ||
| 5162 | + ccyl = Arith.add(ccyl, y.getCzyl()); | ||
| 5163 | + jcyl = Arith.add(jcyl, y.getJzyl()); | ||
| 5164 | + yh = Arith.add(yh, y.getYh()); | ||
| 5165 | + jzl = Arith.add(jzl, y.getJzl()); | ||
| 5166 | + zlc = Arith.add(zlc, y.getZlc()); | ||
| 5167 | + if(dMap.get(y.getRylx())!=null) | ||
| 5168 | + rylx =dMap.get(y.getRylx()).toString(); | ||
| 5169 | + } | ||
| 5170 | + } | ||
| 5171 | + } | ||
| 5172 | + } | ||
| 5173 | + } | ||
| 5174 | + if(listCars.get(0).getHydrogen() != null && listCars.get(0).getHydrogen()){ | ||
| 5175 | + List<Qlb> listQlb = qlbRepository.queryListQlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | ||
| 5176 | + hyd = 1; | ||
| 5177 | + for (int i = 0; i < listQlb.size(); i++) { | ||
| 5178 | + Qlb h = listQlb.get(i); | ||
| 5179 | + if (h.getLp() == null) { | ||
| 5180 | + czql = Arith.add(czql, h.getCzcl()); | ||
| 5181 | + jzql = Arith.add(jzql, h.getJzcl()); | ||
| 5182 | + hq = Arith.add(hq, h.getHn()); | ||
| 5183 | + jql = Arith.add(jql, h.getJql()); | ||
| 5184 | + } else { | ||
| 5185 | + if (h.getLp().equals(s.getLpName())) { | ||
| 5186 | + czql = Arith.add(czql, h.getCzcl()); | ||
| 5187 | + jzql = Arith.add(jzql, h.getJzcl()); | ||
| 5188 | + hq = Arith.add(hq, h.getHn()); | ||
| 5189 | + jql = Arith.add(jql, h.getJql()); | ||
| 5190 | + } | ||
| 5191 | + } | ||
| 5192 | + } | ||
| 5193 | + } | ||
| 5194 | + } | ||
| 5195 | + | ||
| 5196 | + map.put("hyd", hyd); | ||
| 5197 | + map.put("czcl", czql); | ||
| 5198 | + map.put("jzcl", jzql); | ||
| 5199 | + map.put("hn", hq); | ||
| 5200 | + map.put("jql", jql); | ||
| 5201 | + | ||
| 5202 | + map.put("rylx", "加注类别:"+rylx); | ||
| 5203 | + map.put("jzl", jzl); | ||
| 5204 | + map.put("yh", yh); | ||
| 5205 | + map.put("ccyl", ccyl); | ||
| 5206 | + map.put("jcyl", jcyl); | ||
| 5207 | + map.put("type", type); | ||
| 5208 | + map.put("zlc", zlc); | ||
| 5209 | + map.put("xlName", s.getXlName()); | ||
| 5210 | + map.put("clZbh", s.getClZbh()); | ||
| 5211 | + map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); | ||
| 5212 | + map.put("fcsjActual", s.getFcsjActual()); | ||
| 5213 | + map.put("zdzName", s.getZdzName()); | ||
| 5214 | + map.put("scheduleDate", s.getScheduleDateStr()); | ||
| 5215 | + map.put("lpName", s.getLpName()); | ||
| 5216 | + String zdp = "", zwdp = "", wdp = ""; | ||
| 5217 | + String zdpT = "", zwdpT = "", wdpT = ""; | ||
| 5218 | + String dbdp = ""; | ||
| 5219 | + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59"); | ||
| 5220 | + try { | ||
| 5221 | + Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime(); | ||
| 5222 | + Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime(); | ||
| 5223 | + Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime(); | ||
| 5224 | + for (int i = 0; i < list.size(); i++) { | ||
| 5225 | + DutyEmployee t = list.get(i); | ||
| 5226 | + if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 5227 | + if (!(dbdp.length() > 0)) { | ||
| 5228 | + dbdp = t.getuName(); | ||
| 5229 | + } else { | ||
| 5230 | + dbdp += "," + t.getuName(); | ||
| 5231 | + } | ||
| 5232 | + } | ||
| 5233 | + Long ts = t.getTs(); | ||
| 5234 | + if (ts > fcsj1 && ts < fcsj2) { | ||
| 5235 | + if (zdp.indexOf(t.getuName()) == -1) { | ||
| 5236 | + if (!(zdp.length() > 0)) { | ||
| 5237 | + zdpT = t.getuName() + "..."; | ||
| 5238 | + } | ||
| 5239 | + zdp += t.getuName() + ","; | ||
| 5240 | + | ||
| 5241 | + } | ||
| 5242 | + } else if (ts > fcsj2 && ts < fcsj3) { | ||
| 5243 | + if (zwdp.indexOf(t.getuName()) == -1) { | ||
| 5244 | + if (!(zwdp.length() > 0)) { | ||
| 5245 | + zwdpT = t.getuName() + "..."; | ||
| 5246 | + } | ||
| 5247 | + zwdp += t.getuName() + ","; | ||
| 5248 | + } | ||
| 5249 | + } else { | ||
| 5250 | + if (wdp.indexOf(t.getuName()) == -1) { | ||
| 5251 | + if (!(wdp.length() > 0)) { | ||
| 5252 | + wdpT = t.getuName() + "..."; | ||
| 5253 | + } | ||
| 5254 | + wdp += t.getuName() + ","; | ||
| 5255 | + } | ||
| 5256 | + } | ||
| 5257 | + } | ||
| 5258 | + } catch (ParseException e) { | ||
| 5259 | + // TODO Auto-generated catch block | ||
| 5260 | + e.printStackTrace(); | ||
| 5261 | + } | ||
| 5262 | + map.put("zdp", zdp); | ||
| 5263 | + map.put("zwdp", zwdp); | ||
| 5264 | + map.put("wdp", wdp); | ||
| 5265 | + map.put("zdpT", zdpT); | ||
| 5266 | + map.put("zwdpT", zwdpT); | ||
| 5267 | + map.put("wdpT", wdpT); | ||
| 5268 | + map.put("dbdp", dbdp); | ||
| 5269 | + return map; | ||
| 5270 | + } | ||
| 5271 | + | ||
| 5272 | + @Override | ||
| 5273 | + public Map<String, Object> MapByIdQp(Long id) { | ||
| 5274 | + // TODO Auto-generated method stub | ||
| 5275 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 5276 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 5277 | + ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id); | ||
| 5278 | + String xlbm = s.getXlBm(); | ||
| 5279 | + String fcrq = s.getScheduleDateStr(); | ||
| 5280 | + | ||
| 5281 | + int type = 0; | ||
| 5282 | + Double ccyl = 0.0; | ||
| 5283 | + Double jcyl = 0.0; | ||
| 5284 | + Double yh = 0.0; | ||
| 5285 | + Double jzl = 0.0; | ||
| 5286 | + Double zlc = 0.0; | ||
| 5287 | +// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); | ||
| 5288 | +// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); | ||
| 5289 | +// if(listYlb.size()>0){ | ||
| 5290 | +// type=0; | ||
| 5291 | +// for (int i = 0; i < listYlb.size(); i++) { | ||
| 5292 | +// Ylb y = listYlb.get(i); | ||
| 5293 | +// if(y.getLp()==null){ | ||
| 5294 | +// ccyl=Arith.add(ccyl, y.getCzyl()); | ||
| 5295 | +// jcyl=Arith.add(jcyl, y.getJzyl()); | ||
| 5296 | +// yh =Arith.add(yh ,y.getYh()); | ||
| 5297 | +// jzl =Arith.add(jzl, y.getJzl()); | ||
| 5298 | +// zlc =Arith.add(zlc, y.getZlc()); | ||
| 5299 | +// }else{ | ||
| 5300 | +// if(y.getLp().equals(s.getLpName())){ | ||
| 5301 | +// ccyl=Arith.add(ccyl, y.getCzyl()); | ||
| 5302 | +// jcyl=Arith.add(jcyl, y.getJzyl()); | ||
| 5303 | +// yh =Arith.add(yh ,y.getYh()); | ||
| 5304 | +// jzl =Arith.add(jzl, y.getJzl()); | ||
| 5305 | +// zlc =Arith.add(zlc, y.getZlc()); | ||
| 5306 | +// } | ||
| 5307 | +// } | ||
| 5308 | +// | ||
| 5309 | +// } | ||
| 5310 | +// }else{ | ||
| 5311 | +// type=1; | ||
| 5312 | +// for (int i = 0; i < listDlb.size(); i++) { | ||
| 5313 | +// Dlb d=listDlb.get(i); | ||
| 5314 | +// if(d.getLp()==null){ | ||
| 5315 | +// ccyl=Arith.add(ccyl, d.getCzcd()); | ||
| 5316 | +// jcyl=Arith.add(jcyl, d.getJzcd()); | ||
| 5317 | +// yh =Arith.add(yh ,d.getHd()); | ||
| 5318 | +// jzl =Arith.add(jzl, d.getCdl()); | ||
| 5319 | +// zlc =Arith.add(zlc, d.getZlc()); | ||
| 5320 | +// }else{ | ||
| 5321 | +// if(d.getLp().equals(s.getLpName())){ | ||
| 5322 | +// ccyl=Arith.add(ccyl, d.getCzcd()); | ||
| 5323 | +// jcyl=Arith.add(jcyl, d.getJzcd()); | ||
| 5324 | +// yh =Arith.add(yh ,d.getHd()); | ||
| 5325 | +// jzl =Arith.add(jzl, d.getCdl()); | ||
| 5326 | +// zlc =Arith.add(zlc, d.getZlc()); | ||
| 5327 | +// } | ||
| 5328 | +// } | ||
| 5329 | +// | ||
| 5330 | +// } | ||
| 5331 | +// } | ||
| 5332 | + | ||
| 5333 | + List<Ylxxb> listylxxb = ylxxbRepository.queryListYlxxb(s.getClZbh(), fcrq); | ||
| 5334 | + for (int i = 0; i < listylxxb.size(); i++) { | ||
| 5335 | + Ylxxb t = listylxxb.get(i); | ||
| 5336 | + jzl = Arith.add(jzl, t.getJzl()); | ||
| 5337 | + } | ||
| 5338 | + map.put("jzl", jzl); | ||
| 5339 | + map.put("yh", yh); | ||
| 5340 | + map.put("ccyl", ccyl); | ||
| 5341 | + map.put("jcyl", jcyl); | ||
| 5342 | + map.put("type", type); | ||
| 5343 | + map.put("zlc", zlc); | ||
| 5344 | + map.put("xlName", s.getXlName()); | ||
| 5345 | + map.put("clZbh", s.getClZbh()); | ||
| 5346 | + map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); | ||
| 5347 | + map.put("fcsjActual", s.getFcsjActual()); | ||
| 5348 | + map.put("zdzName", s.getZdzName()); | ||
| 5349 | + map.put("scheduleDate", s.getScheduleDateStr()); | ||
| 5350 | + map.put("lpName", s.getLpName()); | ||
| 5351 | + String zdp = "", zwdp = "", wdp = ""; | ||
| 5352 | + String zdpT = "", zwdpT = "", wdpT = ""; | ||
| 5353 | + String dbdp = ""; | ||
| 5354 | + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59"); | ||
| 5355 | + try { | ||
| 5356 | + Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime(); | ||
| 5357 | + Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime(); | ||
| 5358 | + Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime(); | ||
| 5359 | + for (int i = 0; i < list.size(); i++) { | ||
| 5360 | + DutyEmployee t = list.get(i); | ||
| 5361 | + if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 5362 | + if (!(dbdp.length() > 0)) { | ||
| 5363 | + dbdp = t.getuName(); | ||
| 5364 | + } else { | ||
| 5365 | + dbdp += "," + t.getuName(); | ||
| 5366 | + } | ||
| 5367 | + } | ||
| 5368 | + Long ts = t.getTs(); | ||
| 5369 | + if (ts > fcsj1 && ts < fcsj2) { | ||
| 5370 | + if (zdp.indexOf(t.getuName()) == -1) { | ||
| 5371 | + if (!(zdp.length() > 0)) { | ||
| 5372 | + zdpT = t.getuName() + "..."; | ||
| 5373 | + } | ||
| 5374 | + zdp += t.getuName() + ","; | ||
| 5375 | + | ||
| 5376 | + } | ||
| 5377 | + } else if (ts > fcsj2 && ts < fcsj3) { | ||
| 5378 | + if (zwdp.indexOf(t.getuName()) == -1) { | ||
| 5379 | + if (!(zwdp.length() > 0)) { | ||
| 5380 | + zwdpT = t.getuName() + "..."; | ||
| 5381 | + } | ||
| 5382 | + zwdp += t.getuName() + ","; | ||
| 5383 | + } | ||
| 5384 | + } else { | ||
| 5385 | + if (wdp.indexOf(t.getuName()) == -1) { | ||
| 5386 | + if (!(wdp.length() > 0)) { | ||
| 5387 | + wdpT = t.getuName() + "..."; | ||
| 5388 | + } | ||
| 5389 | + wdp += t.getuName() + ","; | ||
| 5390 | + } | ||
| 5391 | + } | ||
| 5392 | + } | ||
| 5393 | + } catch (ParseException e) { | ||
| 5394 | + // TODO Auto-generated catch block | ||
| 5395 | + e.printStackTrace(); | ||
| 5396 | + } | ||
| 5397 | + map.put("zdp", zdp); | ||
| 5398 | + map.put("zwdp", zwdp); | ||
| 5399 | + map.put("wdp", wdp); | ||
| 5400 | + map.put("zdpT", zdpT); | ||
| 5401 | + map.put("zwdpT", zwdpT); | ||
| 5402 | + map.put("wdpT", wdpT); | ||
| 5403 | + map.put("dbdp", dbdp); | ||
| 5404 | + return map; | ||
| 5405 | + } | ||
| 5406 | + | ||
| 5407 | + @Override | ||
| 5408 | + public List<Map<String, Object>> scheduleDailyQp(String line, String date) { | ||
| 5409 | + // TODO Auto-generated method stub | ||
| 5410 | + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | ||
| 5411 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDailyQp(line, date); | ||
| 5412 | + Map<String, Object> map = null; | ||
| 5413 | + String lp = "lp"; | ||
| 5414 | + String jgh = "jgh"; | ||
| 5415 | + String clzbh = "clzbh"; | ||
| 5416 | + int bcs = 0; | ||
| 5417 | + String thclzbh = ""; | ||
| 5418 | + String sgh = "sgh"; | ||
| 5419 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5420 | + ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(i); | ||
| 5421 | + if (scheduleRealInfo.getLpName().equals(lp)) { | ||
| 5422 | + bcs++; | ||
| 5423 | + String fcsj = scheduleRealInfo.getFcsj(); | ||
| 5424 | + | ||
| 5425 | + if (!clzbh.equals(scheduleRealInfo.getClZbh())) { | ||
| 5426 | + clzbh = scheduleRealInfo.getClZbh(); | ||
| 5427 | + if (thclzbh == "") { | ||
| 5428 | + thclzbh += scheduleRealInfo.getClZbh() + ","; | ||
| 5429 | + } else { | ||
| 5430 | + thclzbh += scheduleRealInfo.getClZbh(); | ||
| 5431 | + } | ||
| 5432 | + map.put("thclzbh", thclzbh); | ||
| 5433 | + } | ||
| 5434 | + | ||
| 5435 | + if (!jgh.equals(scheduleRealInfo.getjGh())) { | ||
| 5436 | + jgh = scheduleRealInfo.getjGh(); | ||
| 5437 | + if (map.get("jjb2") != null) { | ||
| 5438 | + map.put("jjb3", scheduleRealInfo.getjGh() + "/" + | ||
| 5439 | + scheduleRealInfo.getFcsjActual()); | ||
| 5440 | + | ||
| 5441 | + } else { | ||
| 5442 | + map.put("jjb2", scheduleRealInfo.getjGh() + "/" + | ||
| 5443 | + scheduleRealInfo.getFcsjActual()); | ||
| 5444 | + } | ||
| 5445 | + | ||
| 5446 | + } | ||
| 5447 | + | ||
| 5448 | + if (scheduleRealInfo.getsGh() != null) { | ||
| 5449 | + if (!scheduleRealInfo.getsGh().equals(sgh)) { | ||
| 5450 | + sgh = scheduleRealInfo.getsGh() == null ? "" : scheduleRealInfo.getsGh(); | ||
| 5451 | + if (!sgh.equals("")) { | ||
| 5452 | + if (map.get("sjb1") != null) { | ||
| 5453 | + if (map.get("sjb2") != null) { | ||
| 5454 | + map.put("sjb3", scheduleRealInfo.getsGh() + "/" + | ||
| 5455 | + scheduleRealInfo.getFcsjActual()); | ||
| 5456 | + } else { | ||
| 5457 | + map.put("sjb2", scheduleRealInfo.getsGh() + "/" + | ||
| 5458 | + scheduleRealInfo.getFcsjActual()); | ||
| 5459 | + } | ||
| 5460 | + } else { | ||
| 5461 | + map.put("sjb1", scheduleRealInfo.getsGh() + "/" + | ||
| 5462 | + scheduleRealInfo.getFcsjActual()); | ||
| 5463 | + } | ||
| 5464 | + } | ||
| 5465 | + } | ||
| 5466 | + } | ||
| 5467 | + if (scheduleRealInfo.getFcsjActual() != null) { | ||
| 5468 | + String fcsjs[] = fcsj.split(":"); | ||
| 5469 | + String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":"); | ||
| 5470 | + int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]); | ||
| 5471 | + int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]); | ||
| 5472 | + map.put("cz" + bcs, b - a); | ||
| 5473 | + } else { | ||
| 5474 | + map.put("cz" + bcs, "无"); | ||
| 5475 | + } | ||
| 5476 | + map.put("lp", scheduleRealInfo.getLpName()); | ||
| 5477 | + map.put("dd" + bcs, scheduleRealInfo.getZdsjActual()); | ||
| 5478 | + map.put("kc" + bcs, scheduleRealInfo.getFcsjActual()); | ||
| 5479 | + | ||
| 5480 | + if (i < scheduleRealInfos.size() - 1) { | ||
| 5481 | + if (!scheduleRealInfos.get(i + 1).getLpName().equals | ||
| 5482 | + (scheduleRealInfos.get(i).getLpName())) { | ||
| 5483 | + list.add(map); | ||
| 5484 | + lp = "lp"; | ||
| 5485 | + jgh = "jgh"; | ||
| 5486 | + clzbh = "clzbh"; | ||
| 5487 | + bcs = 0; | ||
| 5488 | + thclzbh = ""; | ||
| 5489 | + sgh = "sgh"; | ||
| 5490 | + } | ||
| 5491 | + } else { | ||
| 5492 | + list.add(map); | ||
| 5493 | + } | ||
| 5494 | + } else { | ||
| 5495 | + bcs = 1; | ||
| 5496 | + map = new HashMap<String, Object>(); | ||
| 5497 | + lp = scheduleRealInfo.getLpName(); | ||
| 5498 | + jgh = scheduleRealInfo.getjGh(); | ||
| 5499 | + clzbh = scheduleRealInfo.getClZbh(); | ||
| 5500 | + if (scheduleRealInfo.getsGh() != null) { | ||
| 5501 | + sgh = scheduleRealInfo.getsGh(); | ||
| 5502 | + map.put("sjb1", scheduleRealInfo.getsGh() + "/" + | ||
| 5503 | + scheduleRealInfo.getFcsjActual()); | ||
| 5504 | + } | ||
| 5505 | + String fcsj = scheduleRealInfo.getFcsj(); | ||
| 5506 | + scheduleRealInfo.getFcsjActual(); | ||
| 5507 | + map.put("jjb1", jgh + "/" + scheduleRealInfo.getFcsjActual()); | ||
| 5508 | + map.put("cccl", clzbh); | ||
| 5509 | + | ||
| 5510 | + if (scheduleRealInfo.getFcsjActual() != null) { | ||
| 5511 | + String fcsjs[] = fcsj.split(":"); | ||
| 5512 | + String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":"); | ||
| 5513 | + int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]); | ||
| 5514 | + int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]); | ||
| 5515 | + map.put("cz" + bcs, b - a); | ||
| 5516 | + } else { | ||
| 5517 | + map.put("cz" + bcs, "无"); | ||
| 5518 | + } | ||
| 5519 | + | ||
| 5520 | + | ||
| 5521 | + map.put("lp", scheduleRealInfo.getLpName()); | ||
| 5522 | + map.put("dd" + bcs, scheduleRealInfo.getZdsjActual()); | ||
| 5523 | + map.put("kc" + bcs, scheduleRealInfo.getFcsjActual()); | ||
| 5524 | + | ||
| 5525 | + if (i < scheduleRealInfos.size() - 1) { | ||
| 5526 | + if (!scheduleRealInfos.get(i + 1).getLpName().equals | ||
| 5527 | + (scheduleRealInfos.get(i).getLpName())) { | ||
| 5528 | + list.add(map); | ||
| 5529 | + lp = "lp"; | ||
| 5530 | + jgh = "jgh"; | ||
| 5531 | + clzbh = "clzbh"; | ||
| 5532 | + bcs = 0; | ||
| 5533 | + thclzbh = ""; | ||
| 5534 | + sgh = "sgh"; | ||
| 5535 | + } | ||
| 5536 | + } else { | ||
| 5537 | + list.add(map); | ||
| 5538 | + } | ||
| 5539 | + } | ||
| 5540 | + | ||
| 5541 | + } | ||
| 5542 | + return list; | ||
| 5543 | + } | ||
| 5544 | + | ||
| 5545 | + | ||
| 5546 | + @Override | ||
| 5547 | + public List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map) { | ||
| 5548 | + String line = map.get("line").toString(); | ||
| 5549 | + String date = map.get("date").toString(); | ||
| 5550 | + String xlName = map.get("xlName").toString(); | ||
| 5551 | + String state = map.get("state").toString(); | ||
| 5552 | + String type = map.get("type").toString(); | ||
| 5553 | + String genre =map.get("genre").toString(); | ||
| 5554 | + String df=""; | ||
| 5555 | + if(map.get("df")!=null){ | ||
| 5556 | + df=map.get("df").toString(); | ||
| 5557 | + } | ||
| 5558 | + | ||
| 5559 | + List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>(); | ||
| 5560 | + List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>(); | ||
| 5561 | + List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null); | ||
| 5562 | + List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state); | ||
| 5563 | + List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>(); | ||
| 5564 | + if(genre.equals("qp")) | ||
| 5565 | + list3=this.realScheduleListQp(line, date); | ||
| 5566 | + else if(genre.equals("zrw")) | ||
| 5567 | + list3=this.realScheduleList_zrw(line, date); | ||
| 5568 | + else | ||
| 5569 | + list3=this.realScheduleList(line, date); | ||
| 5570 | + Map<String, Object> nMap = new HashMap<String, Object>(); | ||
| 5571 | + nMap.put("date", xlName + date); | ||
| 5572 | + nMap.put("jls", list1.get(0).get("jls")); | ||
| 5573 | + nMap.put("sjgl", list1.get(0).get("sjgl")); | ||
| 5574 | + | ||
| 5575 | + int size = 0; | ||
| 5576 | + Map<String, Object> tempMap = new HashMap<String, Object>(); | ||
| 5577 | + for (int i = 0; i < list2.size(); i++) { | ||
| 5578 | + ScheduleRealInfo s = list2.get(i); | ||
| 5579 | + if (size == 5) { | ||
| 5580 | + size = 0; | ||
| 5581 | + dataList2.add(tempMap); | ||
| 5582 | + tempMap = new HashMap<String, Object>(); | ||
| 5583 | + } | ||
| 5584 | + tempMap.put("lp" + size, s.getLpName()); | ||
| 5585 | + tempMap.put("ch" + size, s.getClZbh()); | ||
| 5586 | + tempMap.put("jz" + size, s.getjGh() + "/" + s.getjName()); | ||
| 5587 | + tempMap.put("sz" + size, ""); | ||
| 5588 | + tempMap.put("jw" + size, ""); | ||
| 5589 | + tempMap.put("sw" + size, ""); | ||
| 5590 | + | ||
| 5591 | + size++; | ||
| 5592 | + } | ||
| 5593 | + if (size < 5) { | ||
| 5594 | + for (; size < 5; size++) { | ||
| 5595 | + tempMap.put("lp" + size, ""); | ||
| 5596 | + tempMap.put("ch" + size, ""); | ||
| 5597 | + tempMap.put("jz" + size, ""); | ||
| 5598 | + tempMap.put("sz" + size, ""); | ||
| 5599 | + tempMap.put("jw" + size, ""); | ||
| 5600 | + tempMap.put("sw" + size, ""); | ||
| 5601 | + } | ||
| 5602 | + } | ||
| 5603 | + | ||
| 5604 | + dataList2.add(tempMap); | ||
| 5605 | + | ||
| 5606 | + size = 0; | ||
| 5607 | + tempMap = new HashMap<String, Object>(); | ||
| 5608 | + for (ScheduleRealInfo schedule : list3) { | ||
| 5609 | + int x = size % 3; | ||
| 5610 | + if (x == 0 && size > 0) { | ||
| 5611 | + dataList3.add(tempMap); | ||
| 5612 | + tempMap = new HashMap<String, Object>(); | ||
| 5613 | + } | ||
| 5614 | + tempMap.put("lpName" + x, schedule.getLpName()); | ||
| 5615 | + tempMap.put("qdzName" + x, schedule.getQdzName()); | ||
| 5616 | + tempMap.put("zdsj" + x, schedule.getZdsj()); | ||
| 5617 | + String zdsjActual = schedule.getZdsjActual() != null ? schedule.getZdsjActual() : ""; | ||
| 5618 | + tempMap.put("zdsjActual" + x, zdsjActual); | ||
| 5619 | + | ||
| 5620 | + String zdsjk = ""; | ||
| 5621 | + String zdsjm = ""; | ||
| 5622 | + if (!zdsjActual.equals("")) { | ||
| 5623 | + String[] zdsj_s = schedule.getZdsj().split(":"); | ||
| 5624 | + String[] zdsjActual_s = zdsjActual.split(":"); | ||
| 5625 | + Long zdsj_ = Long.parseLong(zdsj_s[0]) * 60 + Long.parseLong(zdsj_s[1]); | ||
| 5626 | + Long zdsjActual_ = Long.parseLong(zdsjActual_s[0]) * 60 + Long.parseLong(zdsjActual_s[1]); | ||
| 5627 | + if ((zdsj_ - zdsjActual_) > 0) { | ||
| 5628 | + if(zdsj_ - zdsjActual_>1200){ | ||
| 5629 | + zdsjm=String.valueOf(1440-(zdsj_-zdsjActual_)); | ||
| 5630 | + }else{ | ||
| 5631 | + zdsjk = String.valueOf(zdsj_ - zdsjActual_); | ||
| 5632 | + } | ||
| 5633 | + } else { | ||
| 5634 | + if(zdsjActual_ - zdsj_>1200){ | ||
| 5635 | + zdsjk =String.valueOf(1440-(zdsjActual_ - zdsj_)); | ||
| 5636 | + }else{ | ||
| 5637 | + zdsjm = String.valueOf(zdsjActual_ - zdsj_); | ||
| 5638 | + } | ||
| 5639 | + } | ||
| 5640 | + } | ||
| 5641 | + tempMap.put("zdsjk" + x, zdsjk); | ||
| 5642 | + tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm); | ||
| 5643 | + tempMap.put("fcsj" + x, schedule.getFcsj()); | ||
| 5644 | + String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : ""; | ||
| 5645 | + String bcType = schedule.getBcType() != null ? schedule.getBcType() : ""; | ||
| 5646 | + String fcsjActuralstr = ""; | ||
| 5647 | + if (bcType.equals("in")) { | ||
| 5648 | + fcsjActuralstr = fcsjActural + "(进)"; | ||
| 5649 | + } else if (bcType.equals("out")) { | ||
| 5650 | + fcsjActuralstr = fcsjActural + "(出)"; | ||
| 5651 | + } else { | ||
| 5652 | + fcsjActuralstr = fcsjActural; | ||
| 5653 | + } | ||
| 5654 | + tempMap.put("fcsjActual" + x, fcsjActuralstr); | ||
| 5655 | + String fcsjk = ""; | ||
| 5656 | + String fcsjm = ""; | ||
| 5657 | + String dfsjk =""; | ||
| 5658 | + String dfsjm=""; | ||
| 5659 | + if (!fcsjActural.equals("")) { | ||
| 5660 | + String[] fcsj_s = schedule.getFcsj().split(":"); | ||
| 5661 | + String[] fcsjActural_s = fcsjActural.split(":"); | ||
| 5662 | + Long fcsj_ = Long.parseLong(fcsj_s[0]) * 60 + Long.parseLong(fcsj_s[1]); | ||
| 5663 | + Long fcsjActural_ = Long.parseLong(fcsjActural_s[0]) * 60 + Long.parseLong(fcsjActural_s[1]); | ||
| 5664 | + if ((fcsj_ - fcsjActural_) > 0) { | ||
| 5665 | + if(fcsj_ - fcsjActural_>1200){ | ||
| 5666 | + fcsjm=String.valueOf(1440-(fcsj_ - fcsjActural_)); | ||
| 5667 | + }else{ | ||
| 5668 | + fcsjk = String.valueOf(fcsj_ - fcsjActural_); | ||
| 5669 | + } | ||
| 5670 | + } else { | ||
| 5671 | + if(fcsjActural_ - fcsj_>1200){ | ||
| 5672 | + fcsjk =String.valueOf(1440-(fcsjActural_ - fcsj_)); | ||
| 5673 | + } | ||
| 5674 | + else{ | ||
| 5675 | + fcsjm = String.valueOf(fcsjActural_ - fcsj_); | ||
| 5676 | + } | ||
| 5677 | + } | ||
| 5678 | + if(df.equals("df")){ | ||
| 5679 | + String[] dfsj_s =schedule.getDfsj().split(":"); | ||
| 5680 | + Long dfsj_ = Long.parseLong(dfsj_s[0]) * 60 + Long.parseLong(dfsj_s[1]); | ||
| 5681 | + if ((dfsj_ - fcsjActural_) > 0) { | ||
| 5682 | + if(dfsj_ - fcsjActural_>1200){ | ||
| 5683 | + dfsjm=String.valueOf(1440-(dfsj_ - fcsjActural_)); | ||
| 5684 | + }else{ | ||
| 5685 | + dfsjk = String.valueOf(dfsj_ - fcsjActural_); | ||
| 5686 | + } | ||
| 5687 | + } else { | ||
| 5688 | + if(fcsjActural_ - dfsj_>1200){ | ||
| 5689 | + dfsjk= String.valueOf(1440-(fcsjActural_ - dfsj_)); | ||
| 5690 | + }else{ | ||
| 5691 | + dfsjm = String.valueOf(fcsjActural_ - dfsj_); | ||
| 5692 | + } | ||
| 5693 | + } | ||
| 5694 | + } | ||
| 5695 | + } | ||
| 5696 | + if(df.equals("df")){ | ||
| 5697 | + tempMap.put("dfsj"+x,schedule.getDfsj()); | ||
| 5698 | + tempMap.put("dfsjk" + x, dfsjk); | ||
| 5699 | + tempMap.put("dfsjm" + x, dfsjm.equals("0")?"":dfsjm); | ||
| 5700 | + } | ||
| 5701 | + tempMap.put("fcsjk" + x, fcsjk); | ||
| 5702 | + tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm); | ||
| 5703 | + tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : ""); | ||
| 5704 | + | ||
| 5705 | + size++; | ||
| 5706 | + } | ||
| 5707 | + if (tempMap.get("lpName0") != null) { | ||
| 5708 | + if (tempMap.get("lpName1") == null) { | ||
| 5709 | + tempMap.put("lpName1", ""); | ||
| 5710 | + tempMap.put("qdzName1", ""); | ||
| 5711 | + tempMap.put("zdsj1", ""); | ||
| 5712 | + tempMap.put("zdsjActual1", ""); | ||
| 5713 | + tempMap.put("zdsjk1", ""); | ||
| 5714 | + tempMap.put("zdsjm1", ""); | ||
| 5715 | + tempMap.put("fcsj1", ""); | ||
| 5716 | + tempMap.put("fcsjActual1", ""); | ||
| 5717 | + tempMap.put("fcsjk1", ""); | ||
| 5718 | + tempMap.put("fcsjm1", ""); | ||
| 5719 | + if(df.equals("df")){ | ||
| 5720 | + tempMap.put("dfsj1",""); | ||
| 5721 | + tempMap.put("dfsjk1" , ""); | ||
| 5722 | + tempMap.put("dfsjm1" , ""); | ||
| 5723 | + } | ||
| 5724 | + tempMap.put("remarks1", ""); | ||
| 5725 | + } | ||
| 5726 | + if (tempMap.get("lpName2") == null) { | ||
| 5727 | + tempMap.put("lpName2", ""); | ||
| 5728 | + tempMap.put("qdzName2", ""); | ||
| 5729 | + tempMap.put("zdsj2", ""); | ||
| 5730 | + tempMap.put("zdsjActual2", ""); | ||
| 5731 | + tempMap.put("zdsjk2", ""); | ||
| 5732 | + tempMap.put("zdsjm2", ""); | ||
| 5733 | + tempMap.put("fcsj2", ""); | ||
| 5734 | + tempMap.put("fcsjActual2", ""); | ||
| 5735 | + tempMap.put("fcsjk2", ""); | ||
| 5736 | + tempMap.put("fcsjm2", ""); | ||
| 5737 | + if(df.equals("df")){ | ||
| 5738 | + tempMap.put("dfsj2",""); | ||
| 5739 | + tempMap.put("dfsjk2" , ""); | ||
| 5740 | + tempMap.put("dfsjm2" , ""); | ||
| 5741 | + } | ||
| 5742 | + tempMap.put("remarks2", ""); | ||
| 5743 | + } | ||
| 5744 | + dataList3.add(tempMap); | ||
| 5745 | + } | ||
| 5746 | + | ||
| 5747 | + if (date.length() == 10) { | ||
| 5748 | + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59"); | ||
| 5749 | + String dbdp = ""; | ||
| 5750 | + try { | ||
| 5751 | + for (int i = 0; i < list.size(); i++) { | ||
| 5752 | + DutyEmployee t = list.get(i); | ||
| 5753 | + if (dbdp.indexOf(t.getuName()) == -1) { | ||
| 5754 | + if (!(dbdp.length() > 0)) { | ||
| 5755 | + dbdp = t.getuName(); | ||
| 5756 | + } else { | ||
| 5757 | + dbdp += "," + t.getuName(); | ||
| 5758 | + } | ||
| 5759 | + } | ||
| 5760 | + } | ||
| 5761 | + } catch (Exception e) { | ||
| 5762 | + // TODO: handle exception | ||
| 5763 | + e.printStackTrace(); | ||
| 5764 | + } | ||
| 5765 | + nMap.put("dbdp", dbdp); | ||
| 5766 | + } | ||
| 5767 | + | ||
| 5768 | + if (type.equals("export")) { | ||
| 5769 | + String lineName = ""; | ||
| 5770 | + if (map.containsKey("lineName")) | ||
| 5771 | + lineName = "-" + map.get("lineName").toString() + "-"; | ||
| 5772 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 5773 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 5774 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 5775 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 5776 | + ReportUtils ee = new ReportUtils(); | ||
| 5777 | + try { | ||
| 5778 | + listI.add(list1.iterator()); | ||
| 5779 | + listI.add(dataList2.iterator()); | ||
| 5780 | + listI.add(dataList3.iterator()); | ||
| 5781 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 5782 | + String sourcePath = path + "mould/scheduleDaily.xls"; | ||
| 5783 | + if (date.length() == 7) { | ||
| 5784 | + sdfMonth = new SimpleDateFormat("yyyy-MM"); | ||
| 5785 | + sdfSimple = new SimpleDateFormat("yyyyMM"); | ||
| 5786 | + sourcePath = path + "mould/scheduleDaily_m.xls"; | ||
| 5787 | + } | ||
| 5788 | + if(df.equals("df")){ | ||
| 5789 | + sourcePath =path + "mould/scheduleDaily_df.xls"; | ||
| 5790 | + } | ||
| 5791 | + ee.excelReplace(listI, new Object[]{nMap}, sourcePath, | ||
| 5792 | + path + "export/" + sdfSimple.format(sdfMonth.parse(date)) + lineName + "调度日报.xls"); | ||
| 5793 | + } catch (Exception e) { | ||
| 5794 | + // TODO: handle exception | ||
| 5795 | + e.printStackTrace(); | ||
| 5796 | + } | ||
| 5797 | + } | ||
| 5798 | + | ||
| 5799 | + return new ArrayList<Map<String, Object>>(); | ||
| 5800 | + } | ||
| 5801 | + | ||
| 5802 | + public void exportWaybill_pl(List<ScheduleRealInfo> listpl, | ||
| 5803 | + String date, String jName, String clZbh, String lpName) { | ||
| 5804 | + ReportUtils ee = new ReportUtils(); | ||
| 5805 | + ReportRelatedUtils rru = new ReportRelatedUtils(); | ||
| 5806 | + List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | ||
| 5807 | + List<ScheduleRealInfo> scheduleRealInfos = listpl; | ||
| 5808 | + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | ||
| 5809 | +// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line); | ||
| 5810 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 5811 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5812 | + ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 5813 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 5814 | + if (cts != null && cts.size() > 0) { | ||
| 5815 | + lists.add(s); | ||
| 5816 | + } else { | ||
| 5817 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | ||
| 5818 | + lists.add(s); | ||
| 5819 | + } | ||
| 5820 | + } | ||
| 5821 | + } | ||
| 5822 | + DecimalFormat format = new DecimalFormat("0.00"); | ||
| 5823 | +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | ||
| 5824 | +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | ||
| 5825 | + //计算里程和班次数,并放入Map里 | ||
| 5826 | + Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); | ||
| 5827 | + | ||
| 5828 | + map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos))); | ||
| 5829 | + map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos)); | ||
| 5830 | + map.put("addMileage", culateMieageService.culateLjgl(lists)); | ||
| 5831 | + double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists)); | ||
| 5832 | + map.put("yygl", yygl); | ||
| 5833 | + double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists)); | ||
| 5834 | + map.put("ksgl", ksgl); | ||
| 5835 | + map.put("realMileage", Arith.add(yygl, ksgl)); | ||
| 5836 | + map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, "")); | ||
| 5837 | + map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos)); | ||
| 5838 | + map.put("ljbc", culateMieageService.culateLjbc(lists, "")); | ||
| 5839 | + int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, ""); | ||
| 5840 | + map.put("sjbc", sjbc); | ||
| 5841 | +// map=new HashMap<String,Object>(); | ||
| 5842 | + | ||
| 5843 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 5844 | + String minfcsj = "02:00"; | ||
| 5845 | + List<Line> lineList = lineRepository.findLineByCode(listpl.get(0).getXlBm()); | ||
| 5846 | + if (lineList.size() > 0) { | ||
| 5847 | + String sqlMinYysj = "select start_opt from bsth_c_line_config where " | ||
| 5848 | + + " id = (" | ||
| 5849 | + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | ||
| 5850 | + + ")"; | ||
| 5851 | + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 5852 | + } | ||
| 5853 | + String[] minSjs = minfcsj.split(":"); | ||
| 5854 | + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | ||
| 5855 | + | ||
| 5856 | + | ||
| 5857 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5858 | + ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 5859 | + String[] fcsj = s.getFcsj().split(":"); | ||
| 5860 | + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | ||
| 5861 | + | ||
| 5862 | + Long fscjT = 0L; | ||
| 5863 | + if (fcsjL < minSj) { | ||
| 5864 | + Calendar calendar = new GregorianCalendar(); | ||
| 5865 | + calendar.setTime(s.getScheduleDate()); | ||
| 5866 | + calendar.add(calendar.DATE, 1); | ||
| 5867 | + s.setScheduleDate(calendar.getTime()); | ||
| 5868 | + try { | ||
| 5869 | + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | ||
| 5870 | + } catch (ParseException e) { | ||
| 5871 | + // TODO Auto-generated catch block | ||
| 5872 | + e.printStackTrace(); | ||
| 5873 | + } | ||
| 5874 | + | ||
| 5875 | + } else { | ||
| 5876 | + try { | ||
| 5877 | + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | ||
| 5878 | + } catch (ParseException e) { | ||
| 5879 | + // TODO Auto-generated catch block | ||
| 5880 | + e.printStackTrace(); | ||
| 5881 | + } | ||
| 5882 | + ; | ||
| 5883 | + } | ||
| 5884 | + s.setFcsjT(fscjT); | ||
| 5885 | + } | ||
| 5886 | + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | ||
| 5887 | + Collections.sort(scheduleRealInfos, new ComparableReal()); | ||
| 5888 | + for (int i = 0; i < scheduleRealInfos.size(); i++) { | ||
| 5889 | + ScheduleRealInfo s = scheduleRealInfos.get(i); | ||
| 5890 | + s.setAdjustExps(i + 1 + ""); | ||
| 5891 | + String remarks = ""; | ||
| 5892 | + if (s.getRemarks() != null) { | ||
| 5893 | + remarks += s.getRemarks(); | ||
| 5894 | + } | ||
| 5895 | + | ||
| 5896 | + Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 5897 | + if (!childTaskPlans.isEmpty()) { | ||
| 5898 | + s.setFcsjActual(""); | ||
| 5899 | + s.setZdsjActual(""); | ||
| 5900 | + s.setJhlc(0.0); | ||
| 5901 | + } | ||
| 5902 | + | ||
| 5903 | + if (s.isDestroy()) { | ||
| 5904 | + s.setFcsjActual(""); | ||
| 5905 | + s.setZdsjActual(""); | ||
| 5906 | + s.setJhlc(0.0); | ||
| 5907 | + remarks += "(烂班)"; | ||
| 5908 | + s.setRemarks(remarks); | ||
| 5909 | + } | ||
| 5910 | + | ||
| 5911 | + listSchedule.add(s); | ||
| 5912 | + //计算营运里程,空驶里程 | ||
| 5913 | + if (!childTaskPlans.isEmpty()) { | ||
| 5914 | +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 5915 | + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 5916 | + Collections.sort(listit, new ComparableChild()); | ||
| 5917 | + for (int j = 0; j < listit.size(); j++) { | ||
| 5918 | + ScheduleRealInfo t = new ScheduleRealInfo(); | ||
| 5919 | + ChildTaskPlan childTaskPlan = listit.get(j); | ||
| 5920 | + if (childTaskPlan.isDestroy()) { | ||
| 5921 | + t.setFcsjActual(""); | ||
| 5922 | + t.setZdsjActual(""); | ||
| 5923 | + t.setJhlc(0.0); | ||
| 5924 | + } else { | ||
| 5925 | + t.setFcsjActual(childTaskPlan.getStartDate()); | ||
| 5926 | + t.setZdsjActual(childTaskPlan.getEndDate()); | ||
| 5927 | + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | ||
| 5928 | + } | ||
| 5929 | + t.setQdzName(childTaskPlan.getStartStationName()); | ||
| 5930 | + t.setZdzName(childTaskPlan.getEndStationName()); | ||
| 5931 | + t.setRemarks(childTaskPlan.getRemarks()); | ||
| 5932 | + t.setAdjustExps("子"); | ||
| 5933 | + t.setjGh(""); | ||
| 5934 | + t.setjName(""); | ||
| 5935 | + t.setsGh(""); | ||
| 5936 | + t.setsName(""); | ||
| 5937 | + listSchedule.add(t); | ||
| 5938 | + } | ||
| 5939 | + } | ||
| 5940 | + } | ||
| 5941 | + Map<String, Object> maps; | ||
| 5942 | + for (ScheduleRealInfo scheduleRealInfo : listSchedule) { | ||
| 5943 | + maps = new HashMap<String, Object>(); | ||
| 5944 | + try { | ||
| 5945 | + scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | ||
| 5946 | + scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | ||
| 5947 | + maps = rru.getMapValue(scheduleRealInfo); | ||
| 5948 | + maps.put("bcs", scheduleRealInfo.getAdjustExps()); | ||
| 5949 | + String zdsj = scheduleRealInfo.getZdsj(); | ||
| 5950 | + String zdsjActual = scheduleRealInfo.getZdsjActual(); | ||
| 5951 | + if (zdsj != null && zdsjActual != null && | ||
| 5952 | + !zdsj.equals(zdsjActual) && | ||
| 5953 | + !zdsj.equals("") && | ||
| 5954 | + !zdsjActual.equals("")) { | ||
| 5955 | + int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | ||
| 5956 | + int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | ||
| 5957 | + if (zdsj.compareTo(zdsjActual) > 0) { | ||
| 5958 | + if (zdsjT - zdsjAT > 1000) { | ||
| 5959 | + maps.put("fast", ""); | ||
| 5960 | + maps.put("slow", zdsjAT - zdsjT + 1440); | ||
| 5961 | + } else { | ||
| 5962 | + maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 5963 | + maps.put("slow", ""); | ||
| 5964 | + } | ||
| 5965 | + } else { | ||
| 5966 | + if (zdsjAT - zdsjT > 1000) { | ||
| 5967 | + maps.put("fast", zdsjT - zdsjAT + 1440); | ||
| 5968 | + maps.put("slow", ""); | ||
| 5969 | + } else { | ||
| 5970 | + maps.put("fast", ""); | ||
| 5971 | + maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | ||
| 5972 | + } | ||
| 5973 | + } | ||
| 5974 | + } else { | ||
| 5975 | + maps.put("fast", ""); | ||
| 5976 | + maps.put("slow", ""); | ||
| 5977 | + } | ||
| 5978 | + listMap.add(maps); | ||
| 5979 | + } catch (Exception e) { | ||
| 5980 | + e.printStackTrace(); | ||
| 5981 | + } | ||
| 5982 | + } | ||
| 5983 | + | ||
| 5984 | + | ||
| 5985 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 5986 | + list.add(listMap.iterator()); | ||
| 5987 | + String xls = ""; | ||
| 5988 | + if (map.get("type").toString().equals("0")) { | ||
| 5989 | + xls = "waybill_minhang.xls"; | ||
| 5990 | + } else { | ||
| 5991 | + xls = "waybill_minhang_dl.xls"; | ||
| 5992 | + } | ||
| 5993 | + map.put("sheetName", jName + "-" + clZbh + "-" + lpName); | ||
| 5994 | + ee.excelReplace(list, new Object[]{map}, path + "mould/" + xls, | ||
| 5995 | + path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | ||
| 5996 | + } | ||
| 5997 | + | ||
| 5998 | + @Override | ||
| 5999 | + public Map<String, Object> exportWaybillMore(Map<String, Object> map) { | ||
| 6000 | + String date = map.get("date").toString(); | ||
| 6001 | + String line = map.get("line").toString(); | ||
| 6002 | + ReportUtils ee = new ReportUtils(); | ||
| 6003 | + List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class); | ||
| 6004 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; | ||
| 6005 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 6006 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 6007 | + int num = 0; | ||
| 6008 | + File file = null; | ||
| 6009 | + try { | ||
| 6010 | + while (true) { | ||
| 6011 | + String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date)); | ||
| 6012 | +// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹 | ||
| 6013 | + file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件 | ||
| 6014 | + if (file.exists()) { //判断是否已存在重名 | ||
| 6015 | + num++; | ||
| 6016 | + } else { | ||
| 6017 | + break; | ||
| 6018 | + } | ||
| 6019 | + } | ||
| 6020 | +// file.mkdirs(); //创建 | ||
| 6021 | + List<ScheduleRealInfo> lists_line = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date); | ||
| 6022 | + List<File> files = new ArrayList<File>(); | ||
| 6023 | + for (List<String> list : lists) { | ||
| 6024 | + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | ||
| 6025 | + String jName = list.get(0); | ||
| 6026 | + String clZbh = list.get(1); | ||
| 6027 | + String lpName = list.get(2); | ||
| 6028 | + String jGh = list.get(3); | ||
| 6029 | + for (int i = 0; i < lists_line.size(); i++) { | ||
| 6030 | + ScheduleRealInfo s = lists_line.get(i); | ||
| 6031 | + if (s.getjGh().equals(jGh) && s.getClZbh().equals(clZbh) && s.getLpName().equals(lpName)) { | ||
| 6032 | + newList.add(s); | ||
| 6033 | + } | ||
| 6034 | + } | ||
| 6035 | + this.exportWaybill_pl(newList, date, jName, clZbh, lpName); | ||
| 6036 | + File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | ||
| 6037 | + String fileName = file.getName(); | ||
| 6038 | + files.add(temp); | ||
| 6039 | + } | ||
| 6040 | + for (int i = 1; i < files.size(); i++) { | ||
| 6041 | + File file1 = files.get(0); | ||
| 6042 | + File file2 = files.get(i); | ||
| 6043 | + ee.copySheetByFile(file2, file1, 0, 145); | ||
| 6044 | + } | ||
| 6045 | + File newFile = files.get(0); | ||
| 6046 | + newFile.renameTo(file); | ||
| 6047 | +// temp.renameTo(new File(path + fileName + "/" + temp.getName())); | ||
| 6048 | +// File[] listFiles = file.listFiles(); | ||
| 6049 | +// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip"))); | ||
| 6050 | +//// zos.setEncoding("gbk"); | ||
| 6051 | +//// zos.putNextEntry(new ZipEntry(fileName + "/")); | ||
| 6052 | +// for (int i = 0; i < listFiles.length; i++) { | ||
| 6053 | +// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName())); | ||
| 6054 | +// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i])); | ||
| 6055 | +// BufferedOutputStream bos = new BufferedOutputStream(zos); | ||
| 6056 | +// int bytesRead = 0; | ||
| 6057 | +// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) { | ||
| 6058 | +//// zos.write(buffer, 0, bytesRead); | ||
| 6059 | +//// zos.flush(); | ||
| 6060 | +// bos.write(buffer, 0, bytesRead); | ||
| 6061 | +// bos.flush(); | ||
| 6062 | +// } | ||
| 6063 | +//// bos.close(); | ||
| 6064 | +// bis.close(); | ||
| 6065 | +// } | ||
| 6066 | +// zos.close(); | ||
| 6067 | +// } | ||
| 6068 | + | ||
| 6069 | + } catch (Exception e) { | ||
| 6070 | + // TODO: handle exception | ||
| 6071 | + e.printStackTrace(); | ||
| 6072 | + } | ||
| 6073 | + | ||
| 6074 | + map.put("fileName", file.getName()); | ||
| 6075 | + return map; | ||
| 6076 | + } | ||
| 6077 | + | ||
| 6078 | + @Autowired | ||
| 6079 | + SchedulePlanInfoService schPlanService; | ||
| 6080 | + | ||
| 6081 | + @Override | ||
| 6082 | + public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) { | ||
| 6083 | + List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode); | ||
| 6084 | + | ||
| 6085 | + if (rs == null || rs.size() == 0) { | ||
| 6086 | + //尝试刷新内存 | ||
| 6087 | + Map<String, Object> data = new HashMap<>(); | ||
| 6088 | + data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode)); | ||
| 6089 | + data.put("xlBm_eq", lineCode); | ||
| 6090 | + List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator()); | ||
| 6091 | + | ||
| 6092 | + if (planItr.size() > 0) { | ||
| 6093 | + dayOfSchedule.schedulePlanMap.put(lineCode, planItr); | ||
| 6094 | + return planItr; | ||
| 6095 | + } | ||
| 6096 | + } | ||
| 6097 | + return rs; | ||
| 6098 | + } | ||
| 6099 | + | ||
| 6100 | + | ||
| 6101 | + @Override | ||
| 6102 | + public Map<String, Object> lpChangeMulti(String leftIdx, String rightIdx, int type) { | ||
| 6103 | + Map<String, Object> rs = new HashMap<>(); | ||
| 6104 | + Set<ScheduleRealInfo> ts = new HashSet<>(); | ||
| 6105 | + try { | ||
| 6106 | + List<String> leftList = Splitter.on(",").splitToList(leftIdx); | ||
| 6107 | + List<String> rightList = Splitter.on(",").splitToList(rightIdx); | ||
| 6108 | + Set<String> lpSet = new HashSet<>(); | ||
| 6109 | + Set<String> carSet = new HashSet<>(); | ||
| 6110 | + | ||
| 6111 | + List<ScheduleRealInfo> largeList, smallList; | ||
| 6112 | + if (leftList.size() > rightList.size()) { | ||
| 6113 | + largeList = getByIdx(leftList); | ||
| 6114 | + smallList = getByIdx(rightList); | ||
| 6115 | + } else { | ||
| 6116 | + largeList = getByIdx(rightList); | ||
| 6117 | + smallList = getByIdx(leftList); | ||
| 6118 | + } | ||
| 6119 | + | ||
| 6120 | + ScheduleRealInfo leftSch, rightSch = null; | ||
| 6121 | + for (int i = 0; i < largeList.size(); i++) { | ||
| 6122 | + leftSch = largeList.get(i); | ||
| 6123 | + leftSch.setLpChange(1); | ||
| 6124 | + if (i < smallList.size()) { | ||
| 6125 | + rightSch = smallList.get(i); | ||
| 6126 | + rightSch.setLpChange(1); | ||
| 6127 | + ts.add(rightSch); | ||
| 6128 | + } else { | ||
| 6129 | + //不对称时多出来的 | ||
| 6130 | + lpChangeByLeft(leftSch, largeList.get(i - 1), type); | ||
| 6131 | + ts.add(leftSch); | ||
| 6132 | + lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName()); | ||
| 6133 | + continue; | ||
| 6134 | + } | ||
| 6135 | + | ||
| 6136 | + //调换路牌 | ||
| 6137 | + lpChange(leftSch, rightSch, type); | ||
| 6138 | + ts.add(leftSch); | ||
| 6139 | + | ||
| 6140 | + lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName()); | ||
| 6141 | + lpSet.add(rightSch.getXlBm() + "_" + rightSch.getLpName()); | ||
| 6142 | + | ||
| 6143 | + carSet.add(leftSch.getClZbh()); | ||
| 6144 | + carSet.add(rightSch.getClZbh()); | ||
| 6145 | + scheduleRealInfoRepository.updateLpChange(leftSch.getId()); | ||
| 6146 | + scheduleRealInfoRepository.updateLpChange(rightSch.getId()); | ||
| 6147 | + } | ||
| 6148 | + | ||
| 6149 | + //重新计算路牌的起点应到时间 | ||
| 6150 | + for (String lpName : lpSet) { | ||
| 6151 | + ts.addAll(dayOfSchedule.updateQdzTimePlan(lpName)); | ||
| 6152 | + } | ||
| 6153 | + | ||
| 6154 | + //重新就算车辆当前执行班次 | ||
| 6155 | + for(String nbbm : carSet){ | ||
| 6156 | + dayOfSchedule.reCalcExecPlan(nbbm); | ||
| 6157 | + } | ||
| 6158 | + | ||
| 6159 | + | ||
| 6160 | + for (ScheduleRealInfo sch : ts) { | ||
| 6161 | + dayOfSchedule.save(sch); | ||
| 6162 | + } | ||
| 6163 | + | ||
| 6164 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 6165 | + rs.put("ts", ts); | ||
| 6166 | + } catch (Exception e) { | ||
| 6167 | + logger.error("", e); | ||
| 6168 | + rs.put("status", ResponseCode.ERROR); | ||
| 6169 | + rs.put("msg", e.getMessage()); | ||
| 6170 | + } | ||
| 6171 | + | ||
| 6172 | + return rs; | ||
| 6173 | + } | ||
| 6174 | + | ||
| 6175 | + private List<ScheduleRealInfo> getByIdx(List<String> idList) { | ||
| 6176 | + List<ScheduleRealInfo> list = new ArrayList<>(); | ||
| 6177 | + for (String id : idList) { | ||
| 6178 | + list.add(dayOfSchedule.get(Long.parseLong(id))); | ||
| 6179 | + } | ||
| 6180 | + return list; | ||
| 6181 | + } | ||
| 6182 | + | ||
| 6183 | + @Override | ||
| 6184 | + public void lpChange(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) { | ||
| 6185 | + //释放班次映射 | ||
| 6186 | + if (type > 0) { | ||
| 6187 | + dayOfSchedule.removeNbbm2SchMapp(leftSch); | ||
| 6188 | + dayOfSchedule.removeNbbm2SchMapp(rightSch); | ||
| 6189 | + } | ||
| 6190 | + | ||
| 6191 | + //对调数据 | ||
| 6192 | + LpData leftData = new LpData(leftSch); | ||
| 6193 | + LpData rightData = new LpData(rightSch); | ||
| 6194 | + | ||
| 6195 | + leftData.appendTo(rightSch, type); | ||
| 6196 | + rightData.appendTo(leftSch, type); | ||
| 6197 | + | ||
| 6198 | + if (type > 0) { | ||
| 6199 | + //重新映射 | ||
| 6200 | + dayOfSchedule.addNbbm2SchMapp(leftSch); | ||
| 6201 | + dayOfSchedule.addNbbm2SchMapp(rightSch); | ||
| 6202 | + } | ||
| 6203 | + } | ||
| 6204 | + | ||
| 6205 | + /** | ||
| 6206 | + * 更换左边班次的路牌,右边不变 | ||
| 6207 | + * | ||
| 6208 | + * @param leftSch | ||
| 6209 | + * @param rightSch | ||
| 6210 | + * @param type | ||
| 6211 | + */ | ||
| 6212 | + public void lpChangeByLeft(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) { | ||
| 6213 | + //释放班次映射 | ||
| 6214 | + if (type > 0) | ||
| 6215 | + dayOfSchedule.removeNbbm2SchMapp(leftSch); | ||
| 6216 | + | ||
| 6217 | + LpData rightData = new LpData(rightSch); | ||
| 6218 | + rightData.appendTo(leftSch, type); | ||
| 6219 | + | ||
| 6220 | + //重新映射 | ||
| 6221 | + if (type > 0) | ||
| 6222 | + dayOfSchedule.addNbbm2SchMapp(leftSch); | ||
| 6223 | + | ||
| 6224 | + } | ||
| 6225 | + | ||
| 6226 | + @Override | ||
| 6227 | + public Map<String, Object> revokeRealArrive(Long id) { | ||
| 6228 | + Map<String, Object> rs = new HashMap<>(); | ||
| 6229 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 6230 | + | ||
| 6231 | + try { | ||
| 6232 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 6233 | + if (sch.getZdsjActual() == null && sch.getFcsjActual() == null) { | ||
| 6234 | + rs.put("status", ResponseCode.ERROR); | ||
| 6235 | + rs.put("msg", "班次未执行,无法撤销!"); | ||
| 6236 | + } else { | ||
| 6237 | + //日志记录 | ||
| 6238 | + ScheduleModifyLogger.cxzx(sch); | ||
| 6239 | + | ||
| 6240 | + sch.clearFcsjActual(); | ||
| 6241 | + sch.clearZdsjActual(); | ||
| 6242 | + //清除路牌下一个班的起点到达时间 | ||
| 6243 | + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch); | ||
| 6244 | + if (null != next) { | ||
| 6245 | + next.setQdzArrDatesj(null); | ||
| 6246 | + ts.add(next); | ||
| 6247 | + } | ||
| 6248 | + | ||
| 6249 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 6250 | + | ||
| 6251 | + ts.add(sch); | ||
| 6252 | + rs.put("ts", ts); | ||
| 6253 | + | ||
| 6254 | + dayOfSchedule.save(sch); | ||
| 6255 | + //重新计算当前执行班次 | ||
| 6256 | + dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | ||
| 6257 | + | ||
| 6258 | + } | ||
| 6259 | + } catch (Exception e) { | ||
| 6260 | + logger.error("", e); | ||
| 6261 | + rs.put("status", ResponseCode.ERROR); | ||
| 6262 | + } | ||
| 6263 | + return rs; | ||
| 6264 | + } | ||
| 6265 | + | ||
| 6266 | + @Override | ||
| 6267 | + public Map<String, Object> lateAdjust(String idx, float minute) { | ||
| 6268 | + Map<String, Object> rs = new HashMap<>(); | ||
| 6269 | + try { | ||
| 6270 | + int count = 0; | ||
| 6271 | + List<ScheduleRealInfo> list = new ArrayList<>(); | ||
| 6272 | + List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx); | ||
| 6273 | + | ||
| 6274 | + ScheduleRealInfo sch; | ||
| 6275 | + for (String id : ids) { | ||
| 6276 | + sch = dayOfSchedule.get(Long.parseLong(id)); | ||
| 6277 | + if (sch != null && sch.getStatus() == 0) { | ||
| 6278 | + if (minute > 0) { | ||
| 6279 | + sch.setLateMinute(minute); | ||
| 6280 | + } else if (minute == 0) { | ||
| 6281 | + LateAdjustHandle.remove(sch); | ||
| 6282 | + } | ||
| 6283 | + count++; | ||
| 6284 | + list.add(sch); | ||
| 6285 | + } | ||
| 6286 | + } | ||
| 6287 | + | ||
| 6288 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 6289 | + rs.put("count", count); | ||
| 6290 | + rs.put("ts", list); | ||
| 6291 | + } catch (Exception e) { | ||
| 6292 | + logger.error("", e); | ||
| 6293 | + rs.put("status", ResponseCode.ERROR); | ||
| 6294 | + rs.put("msg", e.getMessage()); | ||
| 6295 | + } | ||
| 6296 | + | ||
| 6297 | + return rs; | ||
| 6298 | + } | ||
| 6299 | + | ||
| 6300 | + @Override | ||
| 6301 | + public List<ScheduleRealInfo> allLate2(String idx) { | ||
| 6302 | + List<ScheduleRealInfo> rs = new ArrayList<>(); | ||
| 6303 | + List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx); | ||
| 6304 | + | ||
| 6305 | + Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch(); | ||
| 6306 | + for (ScheduleRealInfo sch : all) { | ||
| 6307 | + if (ids.indexOf(sch.getXlBm()) != -1) { | ||
| 6308 | + rs.add(sch); | ||
| 6309 | + } | ||
| 6310 | + } | ||
| 6311 | + return rs; | ||
| 6312 | + } | ||
| 6313 | + | ||
| 6314 | + | ||
| 6315 | + @Override | ||
| 6316 | + public List<Map<String, Object>> mileageReport(String gsdm, | ||
| 6317 | + String fgsdm, String line, String date, String date2) { | ||
| 6318 | + | ||
| 6319 | + String sql = "select * from calc_mileage where 1=1 "; | ||
| 6320 | + if (!line.equals(" ")) { | ||
| 6321 | + sql = sql + " and line_code='" + line + "' "; | ||
| 6322 | + } | ||
| 6323 | + sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'"; | ||
| 6324 | + if (!gsdm.equals(" ")) { | ||
| 6325 | + sql = sql + " and company_id=" + gsdm; | ||
| 6326 | + } | ||
| 6327 | + if (!gsdm.equals(" ")) { | ||
| 6328 | + sql = sql + " and sub_company_id=" + fgsdm; | ||
| 6329 | + } | ||
| 6330 | + sql = sql + " order by line_code"; | ||
| 6331 | + List<MileageReport> list = jdbcTemplate.query(sql, | ||
| 6332 | + new RowMapper<MileageReport>() { | ||
| 6333 | + @Override | ||
| 6334 | + public MileageReport mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 6335 | + MileageReport mr = new MileageReport(); | ||
| 6336 | + mr.setCompanyName(rs.getString("company_name")); | ||
| 6337 | + mr.setSubCompanyName(rs.getString("sub_company_name")); | ||
| 6338 | + mr.setLineName(rs.getString("line_name")); | ||
| 6339 | + mr.setSjyygl(rs.getDouble("sjyygl")); | ||
| 6340 | + mr.setSjksgl(rs.getDouble("sjksgl")); | ||
| 6341 | + mr.setZgl(rs.getDouble("zyygl")); | ||
| 6342 | + mr.setZddfgl(rs.getDouble("zddfgl")); | ||
| 6343 | + mr.setSddfgl(rs.getDouble("sddfgl")); | ||
| 6344 | + mr.setWqwxhgl(rs.getDouble("wqwxhgl")); | ||
| 6345 | + mr.setBfwxhgl(rs.getDouble("bfwxhgl")); | ||
| 6346 | + mr.setPygl(rs.getDouble("pygl")); | ||
| 6347 | + mr.setLjgl(rs.getDouble("ljgl")); | ||
| 6348 | + mr.setZrwgl(rs.getDouble("zrwgl")); | ||
| 6349 | + mr.setOther(rs.getString("other")); | ||
| 6350 | + return mr; | ||
| 6351 | + } | ||
| 6352 | + }); | ||
| 6353 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 6354 | + double sjyygl = 0.0; | ||
| 6355 | + double sjksgl = 0.0; | ||
| 6356 | + double zgl = 0.0; | ||
| 6357 | + double sddfgl = 0.0; | ||
| 6358 | + double zddfgl = 0.0; | ||
| 6359 | + double wqwxhgl = 0.0; | ||
| 6360 | + double bfwxhgl = 0.0; | ||
| 6361 | + double pygl = 0.0; | ||
| 6362 | + double ljgl = 0.0; | ||
| 6363 | + double zrwgl = 0.0; | ||
| 6364 | + for (MileageReport mr : list) { | ||
| 6365 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6366 | + resMap.put("gsName", mr.getCompanyName()); | ||
| 6367 | + resMap.put("fgsName", mr.getSubCompanyName()); | ||
| 6368 | + resMap.put("xlName", mr.getLineName()); | ||
| 6369 | + resMap.put("sjyygl", mr.getSjyygl()); | ||
| 6370 | + resMap.put("sjksgl", mr.getSjksgl()); | ||
| 6371 | + resMap.put("zgl", mr.getZgl()); | ||
| 6372 | + resMap.put("sddfgl", mr.getSddfgl()); | ||
| 6373 | + resMap.put("zddfgl", mr.getZddfgl()); | ||
| 6374 | + resMap.put("wqwxhgl", mr.getWqwxhgl()); | ||
| 6375 | + resMap.put("bfwxhgl", mr.getBfwxhgl()); | ||
| 6376 | + resMap.put("pygl", mr.getPygl()); | ||
| 6377 | + resMap.put("ljgl", mr.getLjgl()); | ||
| 6378 | + resMap.put("zrwgl", mr.getZrwgl()); | ||
| 6379 | + resMap.put("other", mr.getOther()); | ||
| 6380 | + lMap.add(resMap); | ||
| 6381 | + sjyygl = Arith.add(sjyygl, mr.getSjyygl()); | ||
| 6382 | + sjksgl = Arith.add(sjksgl, mr.getSjksgl()); | ||
| 6383 | + zgl = Arith.add(zgl, mr.getZgl()); | ||
| 6384 | + sddfgl = Arith.add(sddfgl, mr.getSddfgl()); | ||
| 6385 | + zddfgl = Arith.add(zddfgl, mr.getZddfgl()); | ||
| 6386 | + wqwxhgl = Arith.add(wqwxhgl, mr.getWqwxhgl()); | ||
| 6387 | + bfwxhgl = Arith.add(bfwxhgl, mr.getBfwxhgl()); | ||
| 6388 | + pygl = Arith.add(pygl, mr.getPygl()); | ||
| 6389 | + ljgl = Arith.add(ljgl, mr.getLjgl()); | ||
| 6390 | + zrwgl = Arith.add(zrwgl, mr.getZrwgl()); | ||
| 6391 | + } | ||
| 6392 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6393 | + resMap.put("xlName", "合计"); | ||
| 6394 | + resMap.put("sjyygl", sjyygl); | ||
| 6395 | + resMap.put("sjksgl", sjksgl); | ||
| 6396 | + resMap.put("zgl", zgl); | ||
| 6397 | + resMap.put("sddfgl", sddfgl); | ||
| 6398 | + resMap.put("zddfgl", zddfgl); | ||
| 6399 | + resMap.put("wqwxhgl", wqwxhgl); | ||
| 6400 | + resMap.put("bfwxhgl", bfwxhgl); | ||
| 6401 | + resMap.put("pygl", pygl); | ||
| 6402 | + resMap.put("ljgl", ljgl); | ||
| 6403 | + resMap.put("zrwgl", zrwgl); | ||
| 6404 | + resMap.put("other", null); | ||
| 6405 | + lMap.add(resMap); | ||
| 6406 | + return lMap; | ||
| 6407 | + } | ||
| 6408 | + | ||
| 6409 | + @Override | ||
| 6410 | + public List<Map<String, Object>> scheduleCorrectionReport(String gsdm, | ||
| 6411 | + String fgsdm, String line, String date, String date2) { | ||
| 6412 | + | ||
| 6413 | + String sql = "select * from calc_schedule where 1=1 "; | ||
| 6414 | + if (!line.equals(" ")) { | ||
| 6415 | + sql = sql + " and line_code='" + line + "' "; | ||
| 6416 | + } | ||
| 6417 | + sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'"; | ||
| 6418 | + if (!gsdm.equals(" ")) { | ||
| 6419 | + sql = sql + " and company_id=" + gsdm; | ||
| 6420 | + } | ||
| 6421 | + if (!gsdm.equals(" ")) { | ||
| 6422 | + sql = sql + " and sub_company_id=" + fgsdm; | ||
| 6423 | + } | ||
| 6424 | + sql = sql + " order by line_code"; | ||
| 6425 | + List<ScheduleCorrectionReport> list = jdbcTemplate.query(sql, | ||
| 6426 | + new RowMapper<ScheduleCorrectionReport>() { | ||
| 6427 | + @Override | ||
| 6428 | + public ScheduleCorrectionReport mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 6429 | + ScheduleCorrectionReport sReport = new ScheduleCorrectionReport(); | ||
| 6430 | + sReport.setCompanyName(rs.getString("company_name")); | ||
| 6431 | + sReport.setSubCompanyName(rs.getString("sub_company_name")); | ||
| 6432 | + sReport.setLineName(rs.getString("line_name")); | ||
| 6433 | + sReport.setSjyybc(rs.getInt("sjyybc")); | ||
| 6434 | + sReport.setSjksbc(rs.getInt("sjksbc")); | ||
| 6435 | + sReport.setZbc(rs.getInt("zyybc")); | ||
| 6436 | + sReport.setZddfbc(rs.getInt("zddfbc")); | ||
| 6437 | + sReport.setSddfbc(rs.getInt("sddfbc")); | ||
| 6438 | + sReport.setWqwxhbc(rs.getInt("wqwxhbc")); | ||
| 6439 | + sReport.setBfwxhbc(rs.getInt("bfwxhbc")); | ||
| 6440 | + sReport.setPybc(rs.getInt("pybc")); | ||
| 6441 | + sReport.setLjbc(rs.getInt("ljbc")); | ||
| 6442 | + sReport.setZrwbc(rs.getInt("zrwbc")); | ||
| 6443 | + sReport.setOther(rs.getString("other")); | ||
| 6444 | + return sReport; | ||
| 6445 | + } | ||
| 6446 | + }); | ||
| 6447 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | ||
| 6448 | + int sjyybc = 0; | ||
| 6449 | + int sjksbc = 0; | ||
| 6450 | + int zbc = 0; | ||
| 6451 | + int sddfbc = 0; | ||
| 6452 | + int zddfbc = 0; | ||
| 6453 | + int wqwxhbc = 0; | ||
| 6454 | + int bfwxhbc = 0; | ||
| 6455 | + int pybc = 0; | ||
| 6456 | + int ljbc = 0; | ||
| 6457 | + int zrwbc = 0; | ||
| 6458 | + for (ScheduleCorrectionReport sReport : list) { | ||
| 6459 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6460 | + resMap.put("gsName", sReport.getCompanyName()); | ||
| 6461 | + resMap.put("fgsName", sReport.getSubCompanyName()); | ||
| 6462 | + resMap.put("xlName", sReport.getLineName()); | ||
| 6463 | + resMap.put("sjyybc", sReport.getSjyybc()); | ||
| 6464 | + resMap.put("sjksbc", sReport.getSjksbc()); | ||
| 6465 | + resMap.put("zbc", sReport.getZbc()); | ||
| 6466 | + resMap.put("sddfbc", sReport.getSddfbc()); | ||
| 6467 | + resMap.put("zddfbc", sReport.getZddfbc()); | ||
| 6468 | + resMap.put("wqwxhbc", sReport.getWqwxhbc()); | ||
| 6469 | + resMap.put("bfwxhbc", sReport.getBfwxhbc()); | ||
| 6470 | + resMap.put("pybc", sReport.getPybc()); | ||
| 6471 | + resMap.put("ljbc", sReport.getLjbc()); | ||
| 6472 | + resMap.put("zrwbc", sReport.getZrwbc()); | ||
| 6473 | + resMap.put("other", sReport.getOther()); | ||
| 6474 | + lMap.add(resMap); | ||
| 6475 | + sjyybc = sjyybc + sReport.getSjyybc(); | ||
| 6476 | + sjksbc = sjksbc + sReport.getSjksbc(); | ||
| 6477 | + zbc = zbc + sReport.getZbc(); | ||
| 6478 | + sddfbc = sddfbc + sReport.getSddfbc(); | ||
| 6479 | + zddfbc = zddfbc + sReport.getZddfbc(); | ||
| 6480 | + wqwxhbc = wqwxhbc + sReport.getWqwxhbc(); | ||
| 6481 | + bfwxhbc = bfwxhbc + sReport.getBfwxhbc(); | ||
| 6482 | + pybc = pybc + sReport.getPybc(); | ||
| 6483 | + ljbc = ljbc + sReport.getLjbc(); | ||
| 6484 | + zrwbc = zrwbc + sReport.getZrwbc(); | ||
| 6485 | + } | ||
| 6486 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 6487 | + resMap.put("xlName", "合计"); | ||
| 6488 | + resMap.put("sjyybc", sjyybc); | ||
| 6489 | + resMap.put("sjksbc", sjksbc); | ||
| 6490 | + resMap.put("zbc", zbc); | ||
| 6491 | + resMap.put("sddfbc", sddfbc); | ||
| 6492 | + resMap.put("zddfbc", zddfbc); | ||
| 6493 | + resMap.put("wqwxhbc", wqwxhbc); | ||
| 6494 | + resMap.put("bfwxhbc", bfwxhbc); | ||
| 6495 | + resMap.put("pybc", pybc); | ||
| 6496 | + resMap.put("ljbc", ljbc); | ||
| 6497 | + resMap.put("zrwbc", zrwbc); | ||
| 6498 | + resMap.put("other", null); | ||
| 6499 | + lMap.add(resMap); | ||
| 6500 | + return lMap; | ||
| 6501 | + } | ||
| 6502 | + | ||
| 6503 | + @Override | ||
| 6504 | + public Integer isCircleQdz(String clzbh, String sdr, String xlbm, String qdzCode) { | ||
| 6505 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 6506 | + String time =sdf.format(Long.parseLong(sdr)); | ||
| 6507 | + | ||
| 6508 | + Long num=scheduleRealInfoRepository.isCircleQdz(clzbh, time, xlbm, qdzCode); | ||
| 6509 | + Integer num2=num==0L?0:1; | ||
| 6510 | + return num2; | ||
| 6511 | + } | ||
| 6512 | + | ||
| 6513 | + @SuppressWarnings("unchecked") | ||
| 6514 | + private static Map<String, Object> request(String url) { | ||
| 6515 | + Map<String, Object> res = new HashMap<>(); | ||
| 6516 | + res.put("status", ResponseCode.SUCCESS); | ||
| 6517 | + try { | ||
| 6518 | + StringBuilder sb = HttpClientUtils.post(url, null); | ||
| 6519 | + if (sb != null) { | ||
| 6520 | + Map<String, Object> response = new ObjectMapper().readValue(sb.toString(), Map.class); | ||
| 6521 | + if (!"报修成功".equals(response.get("msg"))) { | ||
| 6522 | + res.put("status", ResponseCode.ERROR); | ||
| 6523 | + res.putAll(response); | ||
| 6524 | + } | ||
| 6525 | + } else { | ||
| 6526 | + res.put("status", ResponseCode.ERROR); | ||
| 6527 | + res.put("msg", "调用上报接口异常"); | ||
| 6528 | + } | ||
| 6529 | + } catch (Exception e) { | ||
| 6530 | + // TODO Auto-generated catch block | ||
| 6531 | + logger.error("维修上报异常", e); | ||
| 6532 | + res.put("status", ResponseCode.ERROR); | ||
| 6533 | + res.put("msg", "调用上报接口异常"); | ||
| 6534 | + } | ||
| 6535 | + | ||
| 6536 | + return res; | ||
| 6537 | + } | ||
| 6538 | + | ||
| 6539 | + /** | ||
| 6540 | + ** 维修记录上报 | ||
| 6541 | + * @param param 参数信息 | ||
| 6542 | + * @param isActive 主/被动上报 | ||
| 6543 | + */ | ||
| 6544 | + @Override | ||
| 6545 | + @Transactional | ||
| 6546 | + public Map<String, Object> repairReport(Map<String, Object> param, boolean isActive) { | ||
| 6547 | + Map<String, Object> res = new HashMap<String, Object>(); | ||
| 6548 | + res.put("status", ResponseCode.SUCCESS); | ||
| 6549 | + // 获取实际排班信息 | ||
| 6550 | + Long id = Long.parseLong((String)param.get("id")); | ||
| 6551 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 6552 | + | ||
| 6553 | + if (null == sch) { | ||
| 6554 | + res.put("status", ResponseCode.ERROR); | ||
| 6555 | + res.put("msg", "不存在的班次!"); | ||
| 6556 | + | ||
| 6557 | + return res; | ||
| 6558 | + } | ||
| 6559 | + | ||
| 6560 | + int reportState = -1; | ||
| 6561 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 6562 | + String reportUser = user.getUserName(), reportName = user.getName(), incode = (String)param.get("clZbh"), reportTypes = (String)param.get("reportTypes"), repairTypes = reportType2RepairType(reportTypes); | ||
| 6563 | + // 分公司保存格式 分公司编码_公司编码 | ||
| 6564 | + String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode); | ||
| 6565 | + String[] arr = val.split("_"); | ||
| 6566 | + StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpReport(arr[1])); | ||
| 6567 | + url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]); | ||
| 6568 | + | ||
| 6569 | + int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0); | ||
| 6570 | + if (count > 0) return res; | ||
| 6571 | + RepairReport lrr = dayOfSchedule.getLastestRepairReport(incode); | ||
| 6572 | + // 非主动上报并且无上报记录或上次已上报 则不用上报 | ||
| 6573 | + if (!isActive && (lrr == null || lrr.getReportState() != 0)) { | ||
| 6574 | + reportState = 0; | ||
| 6575 | + } else { | ||
| 6576 | + res = request(url.toString()); | ||
| 6577 | + if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1; | ||
| 6578 | + } | ||
| 6579 | + // 持久化此次上报记录 | ||
| 6580 | + RepairReport rr = new RepairReport(); | ||
| 6581 | + rr.setLineId(sch.getXlBm()); | ||
| 6582 | + rr.setLineName(sch.getXlName()); | ||
| 6583 | + rr.setReportUser(reportUser); | ||
| 6584 | + rr.setReportName(reportName); | ||
| 6585 | + rr.setSchId(id); | ||
| 6586 | + rr.setIncode(incode); | ||
| 6587 | + rr.setDepartureTime(sch.getFcsj()); | ||
| 6588 | + rr.setRepairType(repairTypes); | ||
| 6589 | + rr.setReportType(reportTypes); | ||
| 6590 | + rr.setReportDate(new Date()); | ||
| 6591 | + rr.setReportState(reportState); | ||
| 6592 | + rr.setReportMode(isActive ? 1 : 0); | ||
| 6593 | + rr = repairReportRepository.save(rr); | ||
| 6594 | + dayOfSchedule.setLastestRepairReport(rr); | ||
| 6595 | + // 如果上报失败,放到重传队列 | ||
| 6596 | + if (rr.getReportState() == -1) queue.add(rr); | ||
| 6597 | + | ||
| 6598 | + return res; | ||
| 6599 | + } | ||
| 6600 | + | ||
| 6601 | + private void repairReport(RepairReport rr) { | ||
| 6602 | + int reportState = -1; | ||
| 6603 | + // 分公司保存格式 分公司编码_公司编码 | ||
| 6604 | + String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode()); | ||
| 6605 | + String[] arr = val.split("_"); | ||
| 6606 | + StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpReport(arr[1])); | ||
| 6607 | + url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]); | ||
| 6608 | + | ||
| 6609 | + Map<String, Object> res = request(url.toString()); | ||
| 6610 | + if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1; | ||
| 6611 | + if (reportState == 1) { | ||
| 6612 | + rr.setReportState(1); | ||
| 6613 | + repairReportRepository.save(rr); | ||
| 6614 | + } | ||
| 6615 | + } | ||
| 6616 | + | ||
| 6617 | + /** | ||
| 6618 | + ** 业务类型转报修类型 | ||
| 6619 | + */ | ||
| 6620 | + private String reportType2RepairType(String reportType) { | ||
| 6621 | + String[] reportTypes = reportType.split(";"); | ||
| 6622 | + List<String> repairTypes = new ArrayList<>(); | ||
| 6623 | + for (String rt : reportTypes) { | ||
| 6624 | + repairTypes.add(report2repair.get(rt)); | ||
| 6625 | + } | ||
| 6626 | + | ||
| 6627 | + return StringUtils.join(repairTypes, ";"); | ||
| 6628 | + } | ||
| 6629 | + | ||
| 6630 | + @Override | ||
| 6631 | + public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) { | ||
| 6632 | + List<RepairReport> result = new ArrayList<RepairReport>(); | ||
| 6633 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 6634 | + | ||
| 6635 | + Date start = null, end = null; | ||
| 6636 | + if (date.length() > 0) { | ||
| 6637 | + try { | ||
| 6638 | + start = sdf.parse(date + " 00:00:00"); | ||
| 6639 | + end = sdf.parse(date + " 23:59:59"); | ||
| 6640 | + } catch (ParseException e) { | ||
| 6641 | + // TODO Auto-generated catch block | ||
| 6642 | + e.printStackTrace(); | ||
| 6643 | + } | ||
| 6644 | + | ||
| 6645 | + } | ||
| 6646 | + | ||
| 6647 | + result = repairReportRepository.repairReportList(lineId, start, end, incode); | ||
| 6648 | + Map<String, Object> dMap=new HashMap<>(); | ||
| 6649 | + dMap.put("dGroup_eq", "repairtype"); | ||
| 6650 | + Map<String, String> code2name = new HashMap<String, String>(); | ||
| 6651 | + for (Dictionary dic : dictionaryService.list(dMap)) { | ||
| 6652 | + code2name.put(dic.getdCode(), dic.getdName()); | ||
| 6653 | + } | ||
| 6654 | + for (RepairReport rr : result) { | ||
| 6655 | + String reportType = rr.getReportType(); | ||
| 6656 | + String[] types = reportType.split(";"); | ||
| 6657 | + StringBuilder sb = new StringBuilder(); | ||
| 6658 | + | ||
| 6659 | + for (String t : types) { | ||
| 6660 | + sb.append(code2name.get(t)).append(";"); | ||
| 6661 | + } | ||
| 6662 | + | ||
| 6663 | + rr.setRepairType(sb.toString()); | ||
| 6664 | + rr.setReportDateStr(sdf.format(rr.getReportDate())); | ||
| 6665 | + switch (rr.getReportState()) { | ||
| 6666 | + case 0: | ||
| 6667 | + rr.setReportStateStr("不报"); | ||
| 6668 | + break; | ||
| 6669 | + case 1: | ||
| 6670 | + rr.setReportStateStr("上报成功"); | ||
| 6671 | + break; | ||
| 6672 | + case -1: | ||
| 6673 | + rr.setReportStateStr("上报失败"); | ||
| 6674 | + break; | ||
| 6675 | + default: | ||
| 6676 | + break; | ||
| 6677 | + } | ||
| 6678 | + } | ||
| 6679 | + | ||
| 6680 | + if ("export".equals(type)) { | ||
| 6681 | + String lineName = BasicData.lineCode2NameMap.get(lineId); | ||
| 6682 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 6683 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 6684 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 6685 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 6686 | + ReportUtils ee = new ReportUtils(); | ||
| 6687 | + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | ||
| 6688 | + for (int i = 0; i < result.size(); i++) { | ||
| 6689 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
| 6690 | + RepairReport rr = result.get(i); | ||
| 6691 | + map.put("row", i + 1); | ||
| 6692 | + map.put("lineId", rr.getLineName()); | ||
| 6693 | + map.put("incode", rr.getIncode()); | ||
| 6694 | + map.put("departureTime", rr.getDepartureTime()); | ||
| 6695 | + map.put("reportUser", rr.getReportUser()); | ||
| 6696 | + map.put("reportDateStr", rr.getReportDate()); | ||
| 6697 | + map.put("repairType", rr.getRepairType()); | ||
| 6698 | + map.put("reportStateStr", rr.getReportStateStr()); | ||
| 6699 | + newList.add(map); | ||
| 6700 | + } | ||
| 6701 | + try { | ||
| 6702 | + listI.add(newList.iterator()); | ||
| 6703 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 6704 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls", | ||
| 6705 | + path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | ||
| 6706 | + + "-" + lineName + "-维修上报记录.xls"); | ||
| 6707 | + } catch (Exception e) { | ||
| 6708 | + // TODO: handle exception | ||
| 6709 | + e.printStackTrace(); | ||
| 6710 | + } | ||
| 6711 | + } | ||
| 6712 | + | ||
| 6713 | + return result; | ||
| 6714 | + } | ||
| 6715 | + | ||
| 6716 | + @Override | ||
| 6717 | + public Map<String, String> getLevelsByLines(List<String> lines) { | ||
| 6718 | + Map<String, String> result = new HashMap<String, String>(), currSchDate = dayOfSchedule.getCurrSchDate(); | ||
| 6719 | + for (String line : lines) { | ||
| 6720 | + String level = BasicData.lineDate2Level.get(line + "_" + currSchDate.get(line)); | ||
| 6721 | + result.put(line, level == null ? "" : level); | ||
| 6722 | + } | ||
| 6723 | + | ||
| 6724 | + return result; | ||
| 6725 | + } | ||
| 6726 | + | ||
| 6727 | + | ||
| 6728 | + @Override | ||
| 6729 | + public void destroy() throws Exception { | ||
| 6730 | + // TODO Auto-generated method stub | ||
| 6731 | + exec.shutdown(); | ||
| 6732 | + } | ||
| 6733 | + | ||
| 6734 | + | ||
| 6735 | + @Override | ||
| 6736 | + public void afterPropertiesSet() throws Exception { | ||
| 6737 | + // TODO Auto-generated method stub | ||
| 6738 | + // 维修上报重发调度 | ||
| 6739 | + exec.scheduleAtFixedRate(new Runnable() { | ||
| 6740 | + | ||
| 6741 | + @Override | ||
| 6742 | + public void run() { | ||
| 6743 | + // TODO Auto-generated method stub | ||
| 6744 | + try { | ||
| 6745 | + Iterator<RepairReport> it = queue.iterator(); | ||
| 6746 | + while (it.hasNext()) { | ||
| 6747 | + RepairReport rr = it.next(); | ||
| 6748 | + repairReport(rr); | ||
| 6749 | + if (rr.getReportState() == 1 || System.currentTimeMillis() - rr.getReportDate().getTime() > 86400000) queue.remove(rr); | ||
| 6750 | + } | ||
| 6751 | + } catch (Exception e) { | ||
| 6752 | + logger.error("维修上报重发错误", e); | ||
| 6753 | + } | ||
| 6754 | + } | ||
| 6755 | + }, 30, 30, TimeUnit.MINUTES); | ||
| 6756 | + | ||
| 6757 | + //// --- | ||
| 6758 | + exec.scheduleWithFixedDelay(new Runnable() { | ||
| 6759 | + @Override | ||
| 6760 | + public void run() { | ||
| 6761 | + Map<String, Object> res = new HashMap<>(); | ||
| 6762 | + InputStream in = null; | ||
| 6763 | + String url ="http://211.95.61.66:9008/modules/tSafedrivingCs/DSMBHforCLBH"; | ||
| 6764 | + | ||
| 6765 | + try { | ||
| 6766 | + HttpURLConnection con = (HttpURLConnection)new URL(url.toString()).openConnection(); | ||
| 6767 | + con.setDoInput(true); | ||
| 6768 | + con.setRequestMethod("POST"); | ||
| 6769 | + con.setConnectTimeout(5000); | ||
| 6770 | + con.setReadTimeout(5000); | ||
| 6771 | + con.setRequestProperty("keep-alive", "true"); | ||
| 6772 | + con.setRequestProperty("accept", "*/*"); | ||
| 6773 | + con.setRequestProperty("content-type", "application/x-www-form-urlencoded"); | ||
| 6774 | + con.connect(); | ||
| 6775 | + | ||
| 6776 | + if (con.getResponseCode() == 200) { | ||
| 6777 | + in = con.getInputStream(); | ||
| 6778 | + ByteArrayOutputStream bout = new ByteArrayOutputStream(); | ||
| 6779 | + IOUtils.copy(in, bout); | ||
| 6780 | + DIRMAP = new ObjectMapper().readValue(bout.toByteArray(), Map.class); | ||
| 6781 | + } | ||
| 6782 | + logger.info("IP打电话接口查询完成"); | ||
| 6783 | + } catch (MalformedURLException e) { | ||
| 6784 | + // TODO Auto-generated catch block | ||
| 6785 | + e.printStackTrace(); | ||
| 6786 | + logger.error("IP打电话接口出错",e); | ||
| 6787 | + } catch (IOException e) { | ||
| 6788 | + // TODO Auto-generated catch block | ||
| 6789 | + e.printStackTrace(); | ||
| 6790 | + } | ||
| 6791 | + | ||
| 6792 | + } | ||
| 6793 | + }, 0, 10, TimeUnit.MINUTES); | ||
| 6794 | + } | ||
| 6795 | +} | ||
| 6796 | + | ||
| 6797 | +class AccountMap implements Comparator<Map<String, Object>> { | ||
| 6798 | + @Override | ||
| 6799 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 6800 | + // TODO Auto-generated method stub | ||
| 6801 | + return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString()); | ||
| 6802 | + } | ||
| 6803 | +} | ||
| 6804 | + | ||
| 6805 | +class AccountMap2 implements Comparator<Map<String, Object>> { | ||
| 6806 | + @Override | ||
| 6807 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 6808 | + // TODO Auto-generated method stub | ||
| 6809 | + return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString()); | ||
| 6810 | + } | ||
| 6811 | +} | ||
| 6812 | + | ||
| 6813 | +class AccountXlbm implements Comparator<Map<String, Object>> { | ||
| 6814 | + @Override | ||
| 6815 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 6816 | + // TODO Auto-generated method stub | ||
| 6817 | +// PinyinHelper.convertToPinyinString(ppy.getName(), | ||
| 6818 | +// "" , PinyinFormat.WITHOUT_TONE) | ||
| 6819 | + return o1.get("xlNamePy").toString().compareTo( | ||
| 6820 | + o2.get("xlNamePy").toString()); | ||
| 6821 | + } | ||
| 6822 | +} | ||
| 6823 | + | ||
| 6824 | +class compareLpFcsjType implements Comparator<ScheduleRealInfo> { | ||
| 6825 | + @Override | ||
| 6826 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 6827 | + // TODO Auto-generated method stub | ||
| 6828 | + return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark()); | ||
| 6829 | + } | ||
| 6830 | + | ||
| 6831 | +} | ||
| 6832 | + | ||
| 6833 | +class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> { | ||
| 6834 | + @Override | ||
| 6835 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 6836 | + // TODO Auto-generated method stub | ||
| 6837 | + return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName()); | ||
| 6838 | + } | ||
| 6839 | + | ||
| 6840 | +} | ||
| 6841 | +class compareFcsjType implements Comparator<ScheduleRealInfo> { | ||
| 6842 | + @Override | ||
| 6843 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 6844 | + // TODO Auto-generated method stub | ||
| 6845 | + return (o1.getFcsjT() + o1.getRemark()).compareTo(o2.getFcsjT() + o2.getRemark()); | ||
| 6846 | + } | ||
| 6847 | + | ||
| 6848 | +} |