Commit 99c1870f5b7e955815f26060000828f6b459cf20
1 parent
a2e50374
路单审计报表导出名称修改。
Showing
3 changed files
with
811 additions
and
811 deletions
src/main/java/com/bsth/service/calc/impl/CalcWaybillAuditServiceImpl.java
| 1 | -package com.bsth.service.calc.impl; | |
| 2 | - | |
| 3 | -import com.bsth.data.BasicData; | |
| 4 | -import com.bsth.entity.Cars; | |
| 5 | -import com.bsth.entity.calc.CalcWaybillAudit; | |
| 6 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 7 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | -import com.bsth.repository.calc.CalcWaybillAuditRepository; | |
| 9 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 10 | -import com.bsth.service.calc.CalcWaybillAuditService; | |
| 11 | -import com.bsth.service.report.CulateMileageService; | |
| 12 | -import com.bsth.util.Arith; | |
| 13 | -import com.bsth.util.ReportUtils; | |
| 14 | -import com.github.stuxuhai.jpinyin.PinyinException; | |
| 15 | -import com.github.stuxuhai.jpinyin.PinyinFormat; | |
| 16 | -import com.github.stuxuhai.jpinyin.PinyinHelper; | |
| 17 | -import org.slf4j.Logger; | |
| 18 | -import org.slf4j.LoggerFactory; | |
| 19 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 20 | -import org.springframework.scheduling.annotation.Scheduled; | |
| 21 | -import org.springframework.stereotype.Component; | |
| 22 | -import org.springframework.stereotype.Service; | |
| 23 | -import java.text.SimpleDateFormat; | |
| 24 | -import java.time.LocalDate; | |
| 25 | -import java.time.format.DateTimeFormatter; | |
| 26 | -import java.util.*; | |
| 27 | -import java.util.stream.Collectors; | |
| 28 | - | |
| 29 | - | |
| 30 | -@Component | |
| 31 | -@Service | |
| 32 | -public class CalcWaybillAuditServiceImpl implements CalcWaybillAuditService { | |
| 33 | - | |
| 34 | - @Autowired | |
| 35 | - ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 36 | - | |
| 37 | - @Autowired | |
| 38 | - CalcWaybillAuditRepository calcWaybillAuditRepository; | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - CulateMileageService culateService; | |
| 42 | - | |
| 43 | - | |
| 44 | - | |
| 45 | - | |
| 46 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 47 | - | |
| 48 | - | |
| 49 | - //统计2天前的数据 | |
| 50 | - @Scheduled(cron = "0 0 2 * * *") | |
| 51 | - public void clear() { | |
| 52 | - LocalDate dateTime = LocalDate.now().minusDays(2); | |
| 53 | - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |
| 54 | -/* dateTime= LocalDate.parse("2025-03-03",formatter);*/ | |
| 55 | - String date = dateTime.format(formatter); | |
| 56 | - this.create(date); | |
| 57 | - } | |
| 58 | - | |
| 59 | - //数据统计 | |
| 60 | - @Override | |
| 61 | - public void create(String date) { | |
| 62 | - List<CalcWaybillAudit> list = new ArrayList<>(); | |
| 63 | - //查询数据 | |
| 64 | - List<ScheduleRealInfo> listAll = scheduleRealInfoRepository.auditReport(date); | |
| 65 | - //按车辆分组 | |
| 66 | - Map<String, List<ScheduleRealInfo>> data=listAll.stream().collect(Collectors.groupingBy(sch-> sch.getScheduleDateStr()+"-"+sch.getXlBm()+"-"+sch.getClZbh())); | |
| 67 | - data.forEach((k,v)->{ | |
| 68 | - CalcWaybillAudit c=new CalcWaybillAudit(); | |
| 69 | - c.setRq(v.get(0).getScheduleDateStr()); | |
| 70 | - c.setLineCode(v.get(0).getXlBm()); | |
| 71 | - c.setLineName(v.get(0).getXlName()); | |
| 72 | - c.setNbbm(v.get(0).getClZbh()); | |
| 73 | - double sjyygl=culateService.culateSjgl(v);//实际营运公里 | |
| 74 | - double ljgl = culateService.culateLjgl(v);//临加公里 | |
| 75 | - c.setYylc(Arith.add(sjyygl,ljgl)); | |
| 76 | - Map<String, Double> ks=this.culateksgl(v); | |
| 77 | - c.setInlc(ks.get("in")); | |
| 78 | - c.setOutlc(ks.get("out")); | |
| 79 | - c.setKslc(ks.get("ksgl")); | |
| 80 | - c.setZkslc(ks.get("zksgl")); | |
| 81 | - c.setZlc(Arith.add(Arith.add(sjyygl,ljgl),ks.get("zksgl"))); | |
| 82 | - c.setFgsbm(v.get(0).getFgsBm()); | |
| 83 | - c.setFgsName(v.get(0).getFgsName()); | |
| 84 | - c.setGsbm(v.get(0).getGsBm()); | |
| 85 | - c.setGsName(v.get(0).getGsName()); | |
| 86 | - list.add(c); | |
| 87 | - }); | |
| 88 | - if(!list.isEmpty()){ | |
| 89 | - calcWaybillAuditRepository.delete(date); | |
| 90 | - calcWaybillAuditRepository.save(list); | |
| 91 | - } | |
| 92 | - } | |
| 93 | - | |
| 94 | - //汇总生成报表 | |
| 95 | - @Override | |
| 96 | - public List<Map<String, Object>> auditReport(String gsdm,String fgsdm,String date, String date2, | |
| 97 | - String line,String nbbm, String type, String xlName) { | |
| 98 | - List<Map<String, Object>> lMap = new ArrayList<>(); | |
| 99 | - //查询数据 | |
| 100 | - List<CalcWaybillAudit> listAll = calcWaybillAuditRepository.auditReport(date, date2,gsdm,fgsdm, line, nbbm); | |
| 101 | - //按车辆分组 | |
| 102 | - Map<String, List<CalcWaybillAudit>> data=listAll.stream().collect(Collectors.groupingBy(audit-> audit.getLineCode()+"-"+audit.getNbbm())); | |
| 103 | - data.forEach((k,v)->{ | |
| 104 | - Map<String, Object> resMap = new HashMap<>(); | |
| 105 | - Map<String,Double> sum=sum(v); | |
| 106 | - resMap.put("lineName", v.get(0).getLineName()); | |
| 107 | - String clzbh=v.get(0).getNbbm(); | |
| 108 | - resMap.put("plate", BasicData.nbbmCompanyPlateMap.get(clzbh)!=null?BasicData.nbbmCompanyPlateMap.get(clzbh):""); | |
| 109 | - Cars car=BasicData.nbbm2CarMap.get(clzbh); | |
| 110 | - String carClass=car!=null&&car.getCarClass()!=null? car.getCarClass():""; | |
| 111 | - resMap.put("carClass",carClass); | |
| 112 | - String carLength=""; | |
| 113 | - if(!"".equals(carClass) && carClass.length()>6){ | |
| 114 | - int i=Integer.parseInt(carClass.substring(4,5)); | |
| 115 | - if(i==1){ | |
| 116 | - carLength=">10"; | |
| 117 | - }else if(i>1&&i<=7){ | |
| 118 | - carLength="<8"; | |
| 119 | - }else if(i>7){ | |
| 120 | - carLength="8~10"; | |
| 121 | - } | |
| 122 | - } | |
| 123 | - resMap.put("carLength",carLength); | |
| 124 | - resMap.put("sfdc",car!=null&&car.getSfdc()!=null? (car.getSfdc()==true?"是":"否"):""); | |
| 125 | - resMap.put("sfmix",car!=null&&car.getSfmix()!=null? (car.getSfmix()==true?"是":"否"):""); | |
| 126 | - resMap.put("yylc", sum.get("yylc")); | |
| 127 | - resMap.put("in", sum.get("inlc")); | |
| 128 | - resMap.put("out", sum.get("outlc")); | |
| 129 | - resMap.put("kslc", sum.get("kslc")); | |
| 130 | - resMap.put("zkslc", sum.get("zkslc")); | |
| 131 | - resMap.put("zlc", sum.get("zlc")); | |
| 132 | - resMap.put("fgsBm", v.get(0).getFgsbm()); | |
| 133 | - resMap.put("xlBm", v.get(0).getLineCode()); | |
| 134 | - resMap.put("fgsName", v.get(0).getFgsName()); | |
| 135 | - try { | |
| 136 | - resMap.put("xlNamePy", PinyinHelper.convertToPinyinString(v.get(0).getFgsbm()+v.get(0).getLineName(), "", PinyinFormat.WITHOUT_TONE)); | |
| 137 | - } catch (PinyinException e) { | |
| 138 | - // TODO Auto-generated catch block | |
| 139 | - e.printStackTrace(); | |
| 140 | - } | |
| 141 | - lMap.add(resMap); | |
| 142 | - }); | |
| 143 | - | |
| 144 | - Collections.sort(lMap, new AccountXlbm()); | |
| 145 | - if (type != null && type.length() != 0 && type.equals("export")) { | |
| 146 | - List<Map<String, Object>> export = new ArrayList<>(); | |
| 147 | - double yylc=0; | |
| 148 | - double in=0; | |
| 149 | - double out=0; | |
| 150 | - double kslc=0; | |
| 151 | - double zkslc=0; | |
| 152 | - double zlc=0; | |
| 153 | - String lineName=null; | |
| 154 | - Map<String, Object> map; | |
| 155 | - for (int i = 0; i < lMap.size(); i++) { | |
| 156 | - map=lMap.get(i); | |
| 157 | - if(lineName!=null && !lineName.equals(map.get("lineName"))){//不同线路 | |
| 158 | - Map<String, Object> xj=new HashMap<>(); | |
| 159 | - xj.put("lineName","小计"); | |
| 160 | - xj.put("plate",""); | |
| 161 | - xj.put("carClass",""); | |
| 162 | - xj.put("carLength",""); | |
| 163 | - xj.put("sfdc",""); | |
| 164 | - xj.put("sfmix",""); | |
| 165 | - xj.put("yylc",yylc); | |
| 166 | - xj.put("in",in); | |
| 167 | - xj.put("out",out); | |
| 168 | - xj.put("kslc",kslc); | |
| 169 | - xj.put("zkslc",zkslc); | |
| 170 | - xj.put("zlc",zlc); | |
| 171 | - export.add(xj); | |
| 172 | - yylc=0; | |
| 173 | - in=0; | |
| 174 | - out=0; | |
| 175 | - kslc=0; | |
| 176 | - zkslc=0; | |
| 177 | - zlc=0; | |
| 178 | - } | |
| 179 | - lineName=(String) map.get("lineName"); | |
| 180 | - yylc=Arith.add(yylc,map.get("yylc")); | |
| 181 | - in=Arith.add(in,map.get("in")); | |
| 182 | - out=Arith.add(out,map.get("out")); | |
| 183 | - kslc=Arith.add(kslc,map.get("kslc")); | |
| 184 | - zkslc=Arith.add(zkslc,map.get("zkslc")); | |
| 185 | - zlc=Arith.add(zlc,map.get("zlc")); | |
| 186 | - export.add(map); | |
| 187 | - if(i==lMap.size()-1){//最后一个 | |
| 188 | - Map<String, Object> xj=new HashMap<>(); | |
| 189 | - xj.put("lineName","小计"); | |
| 190 | - xj.put("plate",""); | |
| 191 | - xj.put("carClass",""); | |
| 192 | - xj.put("carLength",""); | |
| 193 | - xj.put("sfdc",""); | |
| 194 | - xj.put("sfmix",""); | |
| 195 | - xj.put("yylc",yylc); | |
| 196 | - xj.put("in",in); | |
| 197 | - xj.put("out",out); | |
| 198 | - xj.put("kslc",kslc); | |
| 199 | - xj.put("zkslc",zkslc); | |
| 200 | - xj.put("zlc",zlc); | |
| 201 | - export.add(xj); | |
| 202 | - } | |
| 203 | - } | |
| 204 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 205 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 206 | - List<Iterator<?>> listI = new ArrayList<>(); | |
| 207 | - Map<String, Object> m = new HashMap<>(); | |
| 208 | - m.put("date", date + "至" + date2); | |
| 209 | - ReportUtils ee = new ReportUtils(); | |
| 210 | - try { | |
| 211 | - String dateTime = ""; | |
| 212 | - if (date.equals(date2)) { | |
| 213 | - dateTime = sdfSimple.format(sdfMonth.parse(date)); | |
| 214 | - } else { | |
| 215 | - dateTime = sdfSimple.format(sdfMonth.parse(date)) | |
| 216 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | |
| 217 | - } | |
| 218 | - listI.add(export.iterator()); | |
| 219 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 220 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/auditReport.xls", | |
| 221 | - path + "export/" + dateTime + "-" + xlName + "-路单审计.xls"); | |
| 222 | - } catch (Exception e) { | |
| 223 | - logger.error("", e); | |
| 224 | - } | |
| 225 | - } | |
| 226 | - | |
| 227 | - return lMap; | |
| 228 | - } | |
| 229 | - | |
| 230 | - //求和 | |
| 231 | - public static Map<String,Double> sum(List<CalcWaybillAudit> lists) { | |
| 232 | - Map<String,Double> sum=new HashMap<>(); | |
| 233 | - double yylc=0; | |
| 234 | - double inlc=0; | |
| 235 | - double outlc=0; | |
| 236 | - double kslc=0; | |
| 237 | - double zkslc=0; | |
| 238 | - double zlc=0; | |
| 239 | - | |
| 240 | - for (int i = 0; i < lists.size(); i++) { | |
| 241 | - CalcWaybillAudit audit=lists.get(i); | |
| 242 | - yylc=Arith.add(yylc,audit.getYylc()); | |
| 243 | - inlc=Arith.add(inlc,audit.getInlc()); | |
| 244 | - outlc=Arith.add(outlc,audit.getOutlc()); | |
| 245 | - kslc=Arith.add(kslc,audit.getKslc()); | |
| 246 | - zkslc=Arith.add(zkslc,audit.getZkslc()); | |
| 247 | - zlc=Arith.add(zlc,audit.getZlc()); | |
| 248 | - } | |
| 249 | - sum.put("yylc",yylc); | |
| 250 | - sum.put("inlc",inlc); | |
| 251 | - sum.put("outlc",outlc); | |
| 252 | - sum.put("kslc",kslc); | |
| 253 | - sum.put("zkslc",zkslc); | |
| 254 | - sum.put("zlc",zlc); | |
| 255 | - return sum; | |
| 256 | - } | |
| 257 | - | |
| 258 | - | |
| 259 | - | |
| 260 | - //计算少驶里程 | |
| 261 | - //"normal-正常班次、out-出场、in-进场、region-区间、venting-放空班次、major-放站班次、ldks-两点间空驶" | |
| 262 | - @Override | |
| 263 | - public Map<String, Double> culateksgl(List<ScheduleRealInfo> lists) { | |
| 264 | - Map<String, Double> result=new HashMap<>(); | |
| 265 | - double out =0; | |
| 266 | - double in =0; | |
| 267 | - double venting =0; | |
| 268 | - double major =0; | |
| 269 | - double ldks =0; | |
| 270 | - double normal =0; | |
| 271 | - double region =0; | |
| 272 | - double ksgl =0;//除进出场以外的空驶 | |
| 273 | - double zksgl =0; | |
| 274 | - for (int i = 0; i < lists.size(); i++) { | |
| 275 | - ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 276 | - if (scheduleRealInfo.getBcType().equals("in")) { | |
| 277 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 278 | - if(childTaskPlans.isEmpty()){ | |
| 279 | - if(!scheduleRealInfo.isDestroy()) | |
| 280 | - in =Arith.add(in, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 281 | - }else{ | |
| 282 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 283 | - while (it.hasNext()) { | |
| 284 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 285 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 286 | - if (!childTaskPlan.isDestroy()) { | |
| 287 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 288 | - in=Arith.add(in,jhgl); | |
| 289 | - } | |
| 290 | - } | |
| 291 | - } | |
| 292 | - } | |
| 293 | - }else if (scheduleRealInfo.getBcType().equals("out")) { | |
| 294 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 295 | - if(childTaskPlans.isEmpty()){ | |
| 296 | - if(!scheduleRealInfo.isDestroy()) | |
| 297 | - out =Arith.add(out, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 298 | - }else{ | |
| 299 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 300 | - while (it.hasNext()) { | |
| 301 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 302 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 303 | - if (!childTaskPlan.isDestroy()) { | |
| 304 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 305 | - out=Arith.add(out,jhgl); | |
| 306 | - } | |
| 307 | - } | |
| 308 | - } | |
| 309 | - } | |
| 310 | - }else if (scheduleRealInfo.getBcType().equals("venting")) { | |
| 311 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 312 | - if(childTaskPlans.isEmpty()){ | |
| 313 | - if(!scheduleRealInfo.isDestroy()) | |
| 314 | - venting =Arith.add(venting, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 315 | - }else{ | |
| 316 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 317 | - while (it.hasNext()) { | |
| 318 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 319 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 320 | - if (!childTaskPlan.isDestroy()) { | |
| 321 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 322 | - venting=Arith.add(venting,jhgl); | |
| 323 | - } | |
| 324 | - } | |
| 325 | - } | |
| 326 | - } | |
| 327 | - }else if (scheduleRealInfo.getBcType().equals("major")) { | |
| 328 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 329 | - if(childTaskPlans.isEmpty()){ | |
| 330 | - if(!scheduleRealInfo.isDestroy()) | |
| 331 | - major =Arith.add(major, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 332 | - }else{ | |
| 333 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 334 | - while (it.hasNext()) { | |
| 335 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 336 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 337 | - if (!childTaskPlan.isDestroy()) { | |
| 338 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 339 | - major=Arith.add(major,jhgl); | |
| 340 | - } | |
| 341 | - } | |
| 342 | - } | |
| 343 | - } | |
| 344 | - }else if (scheduleRealInfo.getBcType().equals("ldks")) { | |
| 345 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 346 | - if(childTaskPlans.isEmpty()){ | |
| 347 | - if(!scheduleRealInfo.isDestroy()) | |
| 348 | - ldks =Arith.add(ldks, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 349 | - }else{ | |
| 350 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 351 | - while (it.hasNext()) { | |
| 352 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 353 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 354 | - if (!childTaskPlan.isDestroy()) { | |
| 355 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 356 | - ldks=Arith.add(ldks,jhgl); | |
| 357 | - } | |
| 358 | - } | |
| 359 | - } | |
| 360 | - } | |
| 361 | - }else if (scheduleRealInfo.getBcType().equals("normal")) { | |
| 362 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 363 | - if(!childTaskPlans.isEmpty()){ | |
| 364 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 365 | - while (it.hasNext()) { | |
| 366 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 367 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 368 | - if (!childTaskPlan.isDestroy()) { | |
| 369 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 370 | - normal=Arith.add(normal,jhgl); | |
| 371 | - } | |
| 372 | - } | |
| 373 | - } | |
| 374 | - } | |
| 375 | - }else if (scheduleRealInfo.getBcType().equals("region")) { | |
| 376 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 377 | - if(!childTaskPlans.isEmpty()){ | |
| 378 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 379 | - while (it.hasNext()) { | |
| 380 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 381 | - if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 382 | - if (!childTaskPlan.isDestroy()) { | |
| 383 | - Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 384 | - region=Arith.add(region,jhgl); | |
| 385 | - } | |
| 386 | - } | |
| 387 | - } | |
| 388 | - } | |
| 389 | - } | |
| 390 | - } | |
| 391 | - ksgl =Arith.add(Arith.add(Arith.add(Arith.add(venting,major),ldks),normal),region); | |
| 392 | - zksgl=Arith.add(Arith.add(ksgl,in),out); | |
| 393 | - result.put("out",out); | |
| 394 | - result.put("in",in); | |
| 395 | - result.put("venting",venting); | |
| 396 | - result.put("major",major); | |
| 397 | - result.put("in",in); | |
| 398 | - result.put("ldks",ldks); | |
| 399 | - result.put("normal",normal); | |
| 400 | - result.put("region",region); | |
| 401 | - result.put("ksgl",ksgl); | |
| 402 | - result.put("zksgl",zksgl); | |
| 403 | - return result; | |
| 404 | - } | |
| 405 | - | |
| 406 | - @Override | |
| 407 | - public List<Map<String, String>> carList() { | |
| 408 | - List<Map<String, String>> list=new ArrayList<>(); | |
| 409 | - Map<String, Cars> cars=BasicData.nbbm2CarMap; | |
| 410 | - Iterator<String> iterator = cars.keySet().iterator(); | |
| 411 | - String key; | |
| 412 | - while (iterator.hasNext()) { | |
| 413 | - Map<String, String> map = new HashMap<>(); | |
| 414 | - key = iterator.next(); | |
| 415 | - Cars car=cars.get(key); | |
| 416 | - map.put("nbbm", car.getInsideCode()); | |
| 417 | - map.put("carPlate", car.getCarPlate()); | |
| 418 | - map.put("gsbm", car.getBusinessCode()); | |
| 419 | - map.put("fgsbm", car.getBrancheCompanyCode()); | |
| 420 | - list.add(map); | |
| 421 | - } | |
| 422 | - return list; | |
| 423 | - } | |
| 424 | - | |
| 425 | - class AccountXlbm implements Comparator<Map<String, Object>> { | |
| 426 | - @Override | |
| 427 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 428 | - return o1.get("xlNamePy").toString().compareTo( | |
| 429 | - o2.get("xlNamePy").toString()); | |
| 430 | - } | |
| 431 | - } | |
| 432 | -} | |
| 433 | - | |
| 434 | - | |
| 435 | - | |
| 1 | +package com.bsth.service.calc.impl; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.entity.Cars; | |
| 5 | +import com.bsth.entity.calc.CalcWaybillAudit; | |
| 6 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 7 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | +import com.bsth.repository.calc.CalcWaybillAuditRepository; | |
| 9 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 10 | +import com.bsth.service.calc.CalcWaybillAuditService; | |
| 11 | +import com.bsth.service.report.CulateMileageService; | |
| 12 | +import com.bsth.util.Arith; | |
| 13 | +import com.bsth.util.ReportUtils; | |
| 14 | +import com.github.stuxuhai.jpinyin.PinyinException; | |
| 15 | +import com.github.stuxuhai.jpinyin.PinyinFormat; | |
| 16 | +import com.github.stuxuhai.jpinyin.PinyinHelper; | |
| 17 | +import org.slf4j.Logger; | |
| 18 | +import org.slf4j.LoggerFactory; | |
| 19 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 20 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 21 | +import org.springframework.stereotype.Component; | |
| 22 | +import org.springframework.stereotype.Service; | |
| 23 | +import java.text.SimpleDateFormat; | |
| 24 | +import java.time.LocalDate; | |
| 25 | +import java.time.format.DateTimeFormatter; | |
| 26 | +import java.util.*; | |
| 27 | +import java.util.stream.Collectors; | |
| 28 | + | |
| 29 | + | |
| 30 | +@Component | |
| 31 | +@Service | |
| 32 | +public class CalcWaybillAuditServiceImpl implements CalcWaybillAuditService { | |
| 33 | + | |
| 34 | + @Autowired | |
| 35 | + ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + CalcWaybillAuditRepository calcWaybillAuditRepository; | |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + CulateMileageService culateService; | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 47 | + | |
| 48 | + | |
| 49 | + //统计2天前的数据 | |
| 50 | + @Scheduled(cron = "0 0 2 * * *") | |
| 51 | + public void clear() { | |
| 52 | + LocalDate dateTime = LocalDate.now().minusDays(2); | |
| 53 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |
| 54 | +/* dateTime= LocalDate.parse("2025-03-03",formatter);*/ | |
| 55 | + String date = dateTime.format(formatter); | |
| 56 | + this.create(date); | |
| 57 | + } | |
| 58 | + | |
| 59 | + //数据统计 | |
| 60 | + @Override | |
| 61 | + public void create(String date) { | |
| 62 | + List<CalcWaybillAudit> list = new ArrayList<>(); | |
| 63 | + //查询数据 | |
| 64 | + List<ScheduleRealInfo> listAll = scheduleRealInfoRepository.auditReport(date); | |
| 65 | + //按车辆分组 | |
| 66 | + Map<String, List<ScheduleRealInfo>> data=listAll.stream().collect(Collectors.groupingBy(sch-> sch.getScheduleDateStr()+"-"+sch.getXlBm()+"-"+sch.getClZbh())); | |
| 67 | + data.forEach((k,v)->{ | |
| 68 | + CalcWaybillAudit c=new CalcWaybillAudit(); | |
| 69 | + c.setRq(v.get(0).getScheduleDateStr()); | |
| 70 | + c.setLineCode(v.get(0).getXlBm()); | |
| 71 | + c.setLineName(v.get(0).getXlName()); | |
| 72 | + c.setNbbm(v.get(0).getClZbh()); | |
| 73 | + double sjyygl=culateService.culateSjgl(v);//实际营运公里 | |
| 74 | + double ljgl = culateService.culateLjgl(v);//临加公里 | |
| 75 | + c.setYylc(Arith.add(sjyygl,ljgl)); | |
| 76 | + Map<String, Double> ks=this.culateksgl(v); | |
| 77 | + c.setInlc(ks.get("in")); | |
| 78 | + c.setOutlc(ks.get("out")); | |
| 79 | + c.setKslc(ks.get("ksgl")); | |
| 80 | + c.setZkslc(ks.get("zksgl")); | |
| 81 | + c.setZlc(Arith.add(Arith.add(sjyygl,ljgl),ks.get("zksgl"))); | |
| 82 | + c.setFgsbm(v.get(0).getFgsBm()); | |
| 83 | + c.setFgsName(v.get(0).getFgsName()); | |
| 84 | + c.setGsbm(v.get(0).getGsBm()); | |
| 85 | + c.setGsName(v.get(0).getGsName()); | |
| 86 | + list.add(c); | |
| 87 | + }); | |
| 88 | + if(!list.isEmpty()){ | |
| 89 | + calcWaybillAuditRepository.delete(date); | |
| 90 | + calcWaybillAuditRepository.save(list); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + | |
| 94 | + //汇总生成报表 | |
| 95 | + @Override | |
| 96 | + public List<Map<String, Object>> auditReport(String gsdm,String fgsdm,String date, String date2, | |
| 97 | + String line,String nbbm, String type, String xlName) { | |
| 98 | + List<Map<String, Object>> lMap = new ArrayList<>(); | |
| 99 | + //查询数据 | |
| 100 | + List<CalcWaybillAudit> listAll = calcWaybillAuditRepository.auditReport(date, date2,gsdm,fgsdm, line, nbbm); | |
| 101 | + //按车辆分组 | |
| 102 | + Map<String, List<CalcWaybillAudit>> data=listAll.stream().collect(Collectors.groupingBy(audit-> audit.getLineCode()+"-"+audit.getNbbm())); | |
| 103 | + data.forEach((k,v)->{ | |
| 104 | + Map<String, Object> resMap = new HashMap<>(); | |
| 105 | + Map<String,Double> sum=sum(v); | |
| 106 | + resMap.put("lineName", v.get(0).getLineName()); | |
| 107 | + String clzbh=v.get(0).getNbbm(); | |
| 108 | + resMap.put("plate", BasicData.nbbmCompanyPlateMap.get(clzbh)!=null?BasicData.nbbmCompanyPlateMap.get(clzbh):""); | |
| 109 | + Cars car=BasicData.nbbm2CarMap.get(clzbh); | |
| 110 | + String carClass=car!=null&&car.getCarClass()!=null? car.getCarClass():""; | |
| 111 | + resMap.put("carClass",carClass); | |
| 112 | + String carLength=""; | |
| 113 | + if(!"".equals(carClass) && carClass.length()>6){ | |
| 114 | + int i=Integer.parseInt(carClass.substring(4,5)); | |
| 115 | + if(i==1){ | |
| 116 | + carLength=">10"; | |
| 117 | + }else if(i>1&&i<=7){ | |
| 118 | + carLength="<8"; | |
| 119 | + }else if(i>7){ | |
| 120 | + carLength="8~10"; | |
| 121 | + } | |
| 122 | + } | |
| 123 | + resMap.put("carLength",carLength); | |
| 124 | + resMap.put("sfdc",car!=null&&car.getSfdc()!=null? (car.getSfdc()==true?"是":"否"):""); | |
| 125 | + resMap.put("sfmix",car!=null&&car.getSfmix()!=null? (car.getSfmix()==true?"是":"否"):""); | |
| 126 | + resMap.put("yylc", sum.get("yylc")); | |
| 127 | + resMap.put("in", sum.get("inlc")); | |
| 128 | + resMap.put("out", sum.get("outlc")); | |
| 129 | + resMap.put("kslc", sum.get("kslc")); | |
| 130 | + resMap.put("zkslc", sum.get("zkslc")); | |
| 131 | + resMap.put("zlc", sum.get("zlc")); | |
| 132 | + resMap.put("fgsBm", v.get(0).getFgsbm()); | |
| 133 | + resMap.put("xlBm", v.get(0).getLineCode()); | |
| 134 | + resMap.put("fgsName", v.get(0).getFgsName()); | |
| 135 | + try { | |
| 136 | + resMap.put("xlNamePy", PinyinHelper.convertToPinyinString(v.get(0).getFgsbm()+v.get(0).getLineName(), "", PinyinFormat.WITHOUT_TONE)); | |
| 137 | + } catch (PinyinException e) { | |
| 138 | + // TODO Auto-generated catch block | |
| 139 | + e.printStackTrace(); | |
| 140 | + } | |
| 141 | + lMap.add(resMap); | |
| 142 | + }); | |
| 143 | + | |
| 144 | + Collections.sort(lMap, new AccountXlbm()); | |
| 145 | + if (type != null && type.length() != 0 && type.equals("export")) { | |
| 146 | + List<Map<String, Object>> export = new ArrayList<>(); | |
| 147 | + double yylc=0; | |
| 148 | + double in=0; | |
| 149 | + double out=0; | |
| 150 | + double kslc=0; | |
| 151 | + double zkslc=0; | |
| 152 | + double zlc=0; | |
| 153 | + String lineName=null; | |
| 154 | + Map<String, Object> map; | |
| 155 | + for (int i = 0; i < lMap.size(); i++) { | |
| 156 | + map=lMap.get(i); | |
| 157 | + if(lineName!=null && !lineName.equals(map.get("lineName"))){//不同线路 | |
| 158 | + Map<String, Object> xj=new HashMap<>(); | |
| 159 | + xj.put("lineName","小计"); | |
| 160 | + xj.put("plate",""); | |
| 161 | + xj.put("carClass",""); | |
| 162 | + xj.put("carLength",""); | |
| 163 | + xj.put("sfdc",""); | |
| 164 | + xj.put("sfmix",""); | |
| 165 | + xj.put("yylc",yylc); | |
| 166 | + xj.put("in",in); | |
| 167 | + xj.put("out",out); | |
| 168 | + xj.put("kslc",kslc); | |
| 169 | + xj.put("zkslc",zkslc); | |
| 170 | + xj.put("zlc",zlc); | |
| 171 | + export.add(xj); | |
| 172 | + yylc=0; | |
| 173 | + in=0; | |
| 174 | + out=0; | |
| 175 | + kslc=0; | |
| 176 | + zkslc=0; | |
| 177 | + zlc=0; | |
| 178 | + } | |
| 179 | + lineName=(String) map.get("lineName"); | |
| 180 | + yylc=Arith.add(yylc,map.get("yylc")); | |
| 181 | + in=Arith.add(in,map.get("in")); | |
| 182 | + out=Arith.add(out,map.get("out")); | |
| 183 | + kslc=Arith.add(kslc,map.get("kslc")); | |
| 184 | + zkslc=Arith.add(zkslc,map.get("zkslc")); | |
| 185 | + zlc=Arith.add(zlc,map.get("zlc")); | |
| 186 | + export.add(map); | |
| 187 | + if(i==lMap.size()-1){//最后一个 | |
| 188 | + Map<String, Object> xj=new HashMap<>(); | |
| 189 | + xj.put("lineName","小计"); | |
| 190 | + xj.put("plate",""); | |
| 191 | + xj.put("carClass",""); | |
| 192 | + xj.put("carLength",""); | |
| 193 | + xj.put("sfdc",""); | |
| 194 | + xj.put("sfmix",""); | |
| 195 | + xj.put("yylc",yylc); | |
| 196 | + xj.put("in",in); | |
| 197 | + xj.put("out",out); | |
| 198 | + xj.put("kslc",kslc); | |
| 199 | + xj.put("zkslc",zkslc); | |
| 200 | + xj.put("zlc",zlc); | |
| 201 | + export.add(xj); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 205 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 206 | + List<Iterator<?>> listI = new ArrayList<>(); | |
| 207 | + Map<String, Object> m = new HashMap<>(); | |
| 208 | + m.put("date", date + "至" + date2); | |
| 209 | + ReportUtils ee = new ReportUtils(); | |
| 210 | + try { | |
| 211 | + String dateTime = ""; | |
| 212 | + if (date.equals(date2)) { | |
| 213 | + dateTime = sdfSimple.format(sdfMonth.parse(date)); | |
| 214 | + } else { | |
| 215 | + dateTime = sdfSimple.format(sdfMonth.parse(date)) | |
| 216 | + + "-" + sdfSimple.format(sdfMonth.parse(date2)); | |
| 217 | + } | |
| 218 | + listI.add(export.iterator()); | |
| 219 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 220 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/auditReport.xls", | |
| 221 | + path + "export/" + dateTime + "-" + xlName + "-单车里程统计.xls"); | |
| 222 | + } catch (Exception e) { | |
| 223 | + logger.error("", e); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + return lMap; | |
| 228 | + } | |
| 229 | + | |
| 230 | + //求和 | |
| 231 | + public static Map<String,Double> sum(List<CalcWaybillAudit> lists) { | |
| 232 | + Map<String,Double> sum=new HashMap<>(); | |
| 233 | + double yylc=0; | |
| 234 | + double inlc=0; | |
| 235 | + double outlc=0; | |
| 236 | + double kslc=0; | |
| 237 | + double zkslc=0; | |
| 238 | + double zlc=0; | |
| 239 | + | |
| 240 | + for (int i = 0; i < lists.size(); i++) { | |
| 241 | + CalcWaybillAudit audit=lists.get(i); | |
| 242 | + yylc=Arith.add(yylc,audit.getYylc()); | |
| 243 | + inlc=Arith.add(inlc,audit.getInlc()); | |
| 244 | + outlc=Arith.add(outlc,audit.getOutlc()); | |
| 245 | + kslc=Arith.add(kslc,audit.getKslc()); | |
| 246 | + zkslc=Arith.add(zkslc,audit.getZkslc()); | |
| 247 | + zlc=Arith.add(zlc,audit.getZlc()); | |
| 248 | + } | |
| 249 | + sum.put("yylc",yylc); | |
| 250 | + sum.put("inlc",inlc); | |
| 251 | + sum.put("outlc",outlc); | |
| 252 | + sum.put("kslc",kslc); | |
| 253 | + sum.put("zkslc",zkslc); | |
| 254 | + sum.put("zlc",zlc); | |
| 255 | + return sum; | |
| 256 | + } | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + //计算少驶里程 | |
| 261 | + //"normal-正常班次、out-出场、in-进场、region-区间、venting-放空班次、major-放站班次、ldks-两点间空驶" | |
| 262 | + @Override | |
| 263 | + public Map<String, Double> culateksgl(List<ScheduleRealInfo> lists) { | |
| 264 | + Map<String, Double> result=new HashMap<>(); | |
| 265 | + double out =0; | |
| 266 | + double in =0; | |
| 267 | + double venting =0; | |
| 268 | + double major =0; | |
| 269 | + double ldks =0; | |
| 270 | + double normal =0; | |
| 271 | + double region =0; | |
| 272 | + double ksgl =0;//除进出场以外的空驶 | |
| 273 | + double zksgl =0; | |
| 274 | + for (int i = 0; i < lists.size(); i++) { | |
| 275 | + ScheduleRealInfo scheduleRealInfo=lists.get(i); | |
| 276 | + if (scheduleRealInfo.getBcType().equals("in")) { | |
| 277 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 278 | + if(childTaskPlans.isEmpty()){ | |
| 279 | + if(!scheduleRealInfo.isDestroy()) | |
| 280 | + in =Arith.add(in, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 281 | + }else{ | |
| 282 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 283 | + while (it.hasNext()) { | |
| 284 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 285 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 286 | + if (!childTaskPlan.isDestroy()) { | |
| 287 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 288 | + in=Arith.add(in,jhgl); | |
| 289 | + } | |
| 290 | + } | |
| 291 | + } | |
| 292 | + } | |
| 293 | + }else if (scheduleRealInfo.getBcType().equals("out")) { | |
| 294 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 295 | + if(childTaskPlans.isEmpty()){ | |
| 296 | + if(!scheduleRealInfo.isDestroy()) | |
| 297 | + out =Arith.add(out, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 298 | + }else{ | |
| 299 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 300 | + while (it.hasNext()) { | |
| 301 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 302 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 303 | + if (!childTaskPlan.isDestroy()) { | |
| 304 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 305 | + out=Arith.add(out,jhgl); | |
| 306 | + } | |
| 307 | + } | |
| 308 | + } | |
| 309 | + } | |
| 310 | + }else if (scheduleRealInfo.getBcType().equals("venting")) { | |
| 311 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 312 | + if(childTaskPlans.isEmpty()){ | |
| 313 | + if(!scheduleRealInfo.isDestroy()) | |
| 314 | + venting =Arith.add(venting, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 315 | + }else{ | |
| 316 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 317 | + while (it.hasNext()) { | |
| 318 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 319 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 320 | + if (!childTaskPlan.isDestroy()) { | |
| 321 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 322 | + venting=Arith.add(venting,jhgl); | |
| 323 | + } | |
| 324 | + } | |
| 325 | + } | |
| 326 | + } | |
| 327 | + }else if (scheduleRealInfo.getBcType().equals("major")) { | |
| 328 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 329 | + if(childTaskPlans.isEmpty()){ | |
| 330 | + if(!scheduleRealInfo.isDestroy()) | |
| 331 | + major =Arith.add(major, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 332 | + }else{ | |
| 333 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 334 | + while (it.hasNext()) { | |
| 335 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 336 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 337 | + if (!childTaskPlan.isDestroy()) { | |
| 338 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 339 | + major=Arith.add(major,jhgl); | |
| 340 | + } | |
| 341 | + } | |
| 342 | + } | |
| 343 | + } | |
| 344 | + }else if (scheduleRealInfo.getBcType().equals("ldks")) { | |
| 345 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 346 | + if(childTaskPlans.isEmpty()){ | |
| 347 | + if(!scheduleRealInfo.isDestroy()) | |
| 348 | + ldks =Arith.add(ldks, scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | |
| 349 | + }else{ | |
| 350 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 351 | + while (it.hasNext()) { | |
| 352 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 353 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 354 | + if (!childTaskPlan.isDestroy()) { | |
| 355 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 356 | + ldks=Arith.add(ldks,jhgl); | |
| 357 | + } | |
| 358 | + } | |
| 359 | + } | |
| 360 | + } | |
| 361 | + }else if (scheduleRealInfo.getBcType().equals("normal")) { | |
| 362 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 363 | + if(!childTaskPlans.isEmpty()){ | |
| 364 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 365 | + while (it.hasNext()) { | |
| 366 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 367 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 368 | + if (!childTaskPlan.isDestroy()) { | |
| 369 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 370 | + normal=Arith.add(normal,jhgl); | |
| 371 | + } | |
| 372 | + } | |
| 373 | + } | |
| 374 | + } | |
| 375 | + }else if (scheduleRealInfo.getBcType().equals("region")) { | |
| 376 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 377 | + if(!childTaskPlans.isEmpty()){ | |
| 378 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 379 | + while (it.hasNext()) { | |
| 380 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 381 | + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){ | |
| 382 | + if (!childTaskPlan.isDestroy()) { | |
| 383 | + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); | |
| 384 | + region=Arith.add(region,jhgl); | |
| 385 | + } | |
| 386 | + } | |
| 387 | + } | |
| 388 | + } | |
| 389 | + } | |
| 390 | + } | |
| 391 | + ksgl =Arith.add(Arith.add(Arith.add(Arith.add(venting,major),ldks),normal),region); | |
| 392 | + zksgl=Arith.add(Arith.add(ksgl,in),out); | |
| 393 | + result.put("out",out); | |
| 394 | + result.put("in",in); | |
| 395 | + result.put("venting",venting); | |
| 396 | + result.put("major",major); | |
| 397 | + result.put("in",in); | |
| 398 | + result.put("ldks",ldks); | |
| 399 | + result.put("normal",normal); | |
| 400 | + result.put("region",region); | |
| 401 | + result.put("ksgl",ksgl); | |
| 402 | + result.put("zksgl",zksgl); | |
| 403 | + return result; | |
| 404 | + } | |
| 405 | + | |
| 406 | + @Override | |
| 407 | + public List<Map<String, String>> carList() { | |
| 408 | + List<Map<String, String>> list=new ArrayList<>(); | |
| 409 | + Map<String, Cars> cars=BasicData.nbbm2CarMap; | |
| 410 | + Iterator<String> iterator = cars.keySet().iterator(); | |
| 411 | + String key; | |
| 412 | + while (iterator.hasNext()) { | |
| 413 | + Map<String, String> map = new HashMap<>(); | |
| 414 | + key = iterator.next(); | |
| 415 | + Cars car=cars.get(key); | |
| 416 | + map.put("nbbm", car.getInsideCode()); | |
| 417 | + map.put("carPlate", car.getCarPlate()); | |
| 418 | + map.put("gsbm", car.getBusinessCode()); | |
| 419 | + map.put("fgsbm", car.getBrancheCompanyCode()); | |
| 420 | + list.add(map); | |
| 421 | + } | |
| 422 | + return list; | |
| 423 | + } | |
| 424 | + | |
| 425 | + class AccountXlbm implements Comparator<Map<String, Object>> { | |
| 426 | + @Override | |
| 427 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 428 | + return o1.get("xlNamePy").toString().compareTo( | |
| 429 | + o2.get("xlNamePy").toString()); | |
| 430 | + } | |
| 431 | + } | |
| 432 | +} | |
| 433 | + | |
| 434 | + | |
| 435 | + | ... | ... |
src/main/resources/static/pages/forms/mould/auditReport.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/auditReport.html
| 1 | -<style type="text/css"> | |
| 2 | - .table-bordered { | |
| 3 | - border: 1px solid; } | |
| 4 | - .table-bordered > thead > tr > th, | |
| 5 | - .table-bordered > thead > tr > td, | |
| 6 | - .table-bordered > tbody > tr > th, | |
| 7 | - .table-bordered > tbody > tr > td, | |
| 8 | - .table-bordered > tfoot > tr > th, | |
| 9 | - .table-bordered > tfoot > tr > td { | |
| 10 | - border: 1px solid; } | |
| 11 | - .table-bordered > thead > tr > th, | |
| 12 | - .table-bordered > thead > tr > td { | |
| 13 | - border-bottom-width: 2px; } | |
| 14 | - | |
| 15 | - .table > tbody + tbody { | |
| 16 | - border-top: 1px solid; } | |
| 17 | - | |
| 18 | - #forms > thead > tr> td >span{ | |
| 19 | - width: 5px; | |
| 20 | - word-wrap: break-word; | |
| 21 | - letter-spacing: 20px; | |
| 22 | - } | |
| 23 | - | |
| 24 | - #forms > thead > tr> td >label{ | |
| 25 | - word-break: keep-all;white-space:nowrap; | |
| 26 | - } | |
| 27 | -</style> | |
| 28 | - | |
| 29 | -<div class="page-head"> | |
| 30 | - <div class="page-title"> | |
| 31 | - <h1>路单审计</h1> | |
| 32 | - </div> | |
| 33 | -</div> | |
| 34 | - | |
| 35 | -<!-- <div class="row"> --> | |
| 36 | - <div class="col-md-12 portlet light porttlet-fit bordered" style="height:calc(100% - 56px)"> | |
| 37 | -<!-- <div> --> | |
| 38 | - <div class="portlet-title"> | |
| 39 | - <form class="form-inline" action=""> | |
| 40 | - <div style="display: inline-block;margin-left: 29px; " id="gsdmDiv"> | |
| 41 | - <span class="item-label" style="width: 80px;">公司: </span> | |
| 42 | - <select class="form-control" name="company" id="gsdm" style="width: 180px;"></select> | |
| 43 | - </div> | |
| 44 | - <div style="display: inline-block; margin-left: 29px;" id="fgsdmDiv"> | |
| 45 | - <span class="item-label" style="width: 80px;">分公司: </span> | |
| 46 | - <select class="form-control" name="subCompany" id="fgsdm" style="width: 180px;"></select> | |
| 47 | - </div> | |
| 48 | - <div style="display: inline-block;margin-left: 42px;"> | |
| 49 | - <span class="item-label" style="width: 80px;">线路: </span> | |
| 50 | - <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 51 | - </div> | |
| 52 | - <div style="display: inline-block;margin-left: 42px;"> | |
| 53 | - <span class="item-label" style="width: 80px;">车辆: </span> | |
| 54 | - <select class="form-control" name="car" id="car" style="width: 180px;"></select> | |
| 55 | - </div> | |
| 56 | - <div style="margin-top: 3px"></div> | |
| 57 | - <div style="display: inline-block;margin-left: 15px;"> | |
| 58 | - <span class="item-label" style="width: 80px;">开始时间: </span> | |
| 59 | - <input class="form-control" type="text" id="date" style="width: 180px;"/> | |
| 60 | - </div> | |
| 61 | - <div style="display: inline-block;margin-left: 15px;"> | |
| 62 | - <span class="item-label" style="width: 80px;">结束时间: </span> | |
| 63 | - <input class="form-control" type="text" id="date2" style="width: 180px;"/> | |
| 64 | - </div> | |
| 65 | - <div class="form-group"> | |
| 66 | - <input class="btn btn-default" type="button" id="query" value="查询"/> | |
| 67 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 68 | - <input class="btn btn-default" type="button" id="create" value="生成" style="display: none;"/> | |
| 69 | - </div> | |
| 70 | - </form> | |
| 71 | - </div> | |
| 72 | - <div class="portlet-body" id="tjrbBody" style="overflow:auto;height: calc(100% - 80px)"> | |
| 73 | - <div class="table-container" style="margin-top: 10px;min-width: 906px"> | |
| 74 | -<!-- <label>早高峰:6:31~8:30 晚高峰:16:01~18:00</label>--> | |
| 75 | - <table class="table table-bordered table-hover table-checkable" id="forms"> | |
| 76 | - <thead> | |
| 77 | - <tr> | |
| 78 | - <th colspan="46"><label id="tjrq"></label> 路单审计</th> | |
| 79 | - </tr> | |
| 80 | - <tr> | |
| 81 | - <td rowspan="4"><label>线路</label></td> | |
| 82 | - <td rowspan="3"><label>车牌号</label></td> | |
| 83 | - <td rowspan="3"><label>车型类别</label></td> | |
| 84 | - <td rowspan="3"><label>车长</label></td> | |
| 85 | - <td rowspan="3"><label>电车</label></td> | |
| 86 | - <td rowspan="3"><label>混合电车</label></td> | |
| 87 | - <td rowspan="3"><label>营运里程</label></td> | |
| 88 | - <td rowspan="3"><label>进场</label></td> | |
| 89 | - <td rowspan="2"><label>出场</label> | |
| 90 | - <td rowspan="2"><label>空驶</label></td> | |
| 91 | - <td rowspan="2"><label>总空驶</label></td> | |
| 92 | - <td rowspan="2"><label>总里程</label></td> | |
| 93 | - </tr> | |
| 94 | - </thead> | |
| 95 | - <tbody class="statisticsDailyCalc2"> | |
| 96 | - | |
| 97 | - </tbody> | |
| 98 | - </table> | |
| 99 | - </div> | |
| 100 | - </div> | |
| 101 | - </div> | |
| 102 | - | |
| 103 | -<script> | |
| 104 | - $(function(){ | |
| 105 | - $('#export').attr('disabled', "true"); | |
| 106 | - | |
| 107 | - // 关闭左侧栏 | |
| 108 | - if (!$('body').hasClass('page-sidebar-closed')) | |
| 109 | - $('.menu-toggler.sidebar-toggler').click(); | |
| 110 | - | |
| 111 | - var d = new Date(); | |
| 112 | - d.setTime(d.getTime() - 2*1000*60*60*24); | |
| 113 | - var year = d.getFullYear(); | |
| 114 | - var month = d.getMonth() + 1; | |
| 115 | - var day = d.getDate(); | |
| 116 | - if(month < 10) | |
| 117 | - month = "0" + month; | |
| 118 | - if(day < 10) | |
| 119 | - day = "0" + day; | |
| 120 | - var dateTime = year + "-" + month + "-" + day; | |
| 121 | - $("#date").datetimepicker({ | |
| 122 | - format : 'YYYY-MM-DD', | |
| 123 | - locale : 'zh-cn', | |
| 124 | - maxDate : dateTime | |
| 125 | - }); | |
| 126 | - $("#date2").datetimepicker({ | |
| 127 | - format : 'YYYY-MM-DD', | |
| 128 | - locale : 'zh-cn', | |
| 129 | - maxDate : dateTime | |
| 130 | - }); | |
| 131 | - $("#date").val(dateTime); | |
| 132 | - $("#date2").val(dateTime); | |
| 133 | - | |
| 134 | - var fage=false; | |
| 135 | - var obj = []; | |
| 136 | - var xlList; | |
| 137 | - $.get('/report/lineList',function(result){ | |
| 138 | - xlList=result; | |
| 139 | - $.get('/user/companyData', function(result){ | |
| 140 | - obj = result; | |
| 141 | - var options = ''; | |
| 142 | - for(var i = 0; i < obj.length; i++){ | |
| 143 | - options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; | |
| 144 | - } | |
| 145 | - if(obj.length ==0){ | |
| 146 | - $("#gsdmDiv").css('display','none'); | |
| 147 | - }else if(obj.length ==1){ | |
| 148 | - $("#gsdmDiv").css('display','none'); | |
| 149 | - if(obj[0].children.length == 1 || obj[0].children.length ==0) | |
| 150 | - $('#fgsdmDiv').css('display','none'); | |
| 151 | - } | |
| 152 | - $('#gsdm').html(options); | |
| 153 | - updateCompany(); | |
| 154 | - }); | |
| 155 | - }); | |
| 156 | - | |
| 157 | - $("#gsdm").on("change",updateCompany); | |
| 158 | - function updateCompany(){ | |
| 159 | - var company = $('#gsdm').val(); | |
| 160 | - var options = '<option value="">全部</option>'; | |
| 161 | - for(var i = 0; i < obj.length; i++){ | |
| 162 | - if(obj[i].companyCode == company){ | |
| 163 | - var children = obj[i].children; | |
| 164 | - for(var j = 0; j < children.length; j++){ | |
| 165 | - options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 166 | - } | |
| 167 | - } | |
| 168 | - } | |
| 169 | - $('#fgsdm').html(options); | |
| 170 | - initXl(); | |
| 171 | - } | |
| 172 | - | |
| 173 | - | |
| 174 | - | |
| 175 | - | |
| 176 | - $("#fgsdm").on("change",initXl); | |
| 177 | - function initXl(){ | |
| 178 | - var data=[]; | |
| 179 | - data.push({id: " ", text: "全部线路"}); | |
| 180 | - if(fage){ | |
| 181 | - $("#line").select2("destroy").html(''); | |
| 182 | - } | |
| 183 | - var fgs=$('#fgsdm').val(); | |
| 184 | - var gs=$('#gsdm').val(); | |
| 185 | - for(var i=0;i<xlList.length;i++){ | |
| 186 | - if(gs!=""){ | |
| 187 | - if(fgs!=""){ | |
| 188 | - if(xlList[i]["fgsbm"]==fgs && xlList[i]["gsbm"]==gs){ | |
| 189 | - data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]}); | |
| 190 | - } | |
| 191 | - }else{ | |
| 192 | - if(xlList[i]["gsbm"]==gs){ | |
| 193 | - data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]}); | |
| 194 | - } | |
| 195 | - } | |
| 196 | - } | |
| 197 | - } | |
| 198 | - initPinYinSelect2('#line',data,''); | |
| 199 | - fage=true; | |
| 200 | - } | |
| 201 | - | |
| 202 | - $.get('/auditReport/queryCarList',function(carList){ | |
| 203 | - var data = []; | |
| 204 | - data.push({id: " ", text: "全部车辆"}); | |
| 205 | - $.get('/user/companyData', function(result){ | |
| 206 | - for(var i = 0; i < result.length; i++){ | |
| 207 | - var companyCode = result[i].companyCode; | |
| 208 | - var children = result[i].children; | |
| 209 | - for(var j = 0; j < children.length; j++){ | |
| 210 | - var code = children[j].code; | |
| 211 | - for(var k=0;k < carList.length;k++ ){ | |
| 212 | - if(carList[k]["fgsbm"]==code && carList[k]["gsbm"]==companyCode){ | |
| 213 | - data.push({id: carList[k]["nbbm"], text: carList[k]["carPlate"]}); | |
| 214 | - } | |
| 215 | - } | |
| 216 | - } | |
| 217 | - } | |
| 218 | - initPinYinSelect2('#car',data,''); | |
| 219 | - }); | |
| 220 | - }); | |
| 221 | - | |
| 222 | - /*$("#line").on("change", function(){ | |
| 223 | - if($("#line").val() == " "){ | |
| 224 | - $("#gsdm").attr("disabled", false); | |
| 225 | - $("#fgsdm").attr("disabled", false); | |
| 226 | - } else { | |
| 227 | - var temp = tempData[$("#line").val()].split(":"); | |
| 228 | - $("#gsdm").val(temp[0]); | |
| 229 | - updateCompany(); | |
| 230 | - $("#fgsdm").val(temp[1]); | |
| 231 | - $("#gsdm").attr("disabled", true); | |
| 232 | - $("#fgsdm").attr("disabled", true); | |
| 233 | - } | |
| 234 | - });*/ | |
| 235 | - | |
| 236 | - | |
| 237 | - var line =""; | |
| 238 | - var xlName =""; | |
| 239 | - var date = ""; | |
| 240 | - var date2 =""; | |
| 241 | - var gsdm=""; | |
| 242 | - var fgsdm=""; | |
| 243 | - var nbbm=""; | |
| 244 | - $("#query").on("click",function(){ | |
| 245 | - if($("#date").val() == null || $("#date").val().trim().length == 0){ | |
| 246 | - layer.msg("请选择时间范围!"); | |
| 247 | - return; | |
| 248 | - } | |
| 249 | - if($("#date2").val() == null || $("#date2").val().trim().length == 0){ | |
| 250 | - layer.msg("请选择时间范围!"); | |
| 251 | - return; | |
| 252 | - } | |
| 253 | - line = $("#line").val(); | |
| 254 | - date = $("#date").val(); | |
| 255 | - date2 =$("#date2").val(); | |
| 256 | - if(getDateDifference(date, date2)>365){ | |
| 257 | - layer.msg("单次查询最多不超过365天!"); | |
| 258 | - return; | |
| 259 | - } | |
| 260 | - gsdm =$("#gsdm").val(); | |
| 261 | - fgsdm=$("#fgsdm").val(); | |
| 262 | - nbbm = $("#car").val(); | |
| 263 | - xlName = $("#select2-line-container").html(); | |
| 264 | - if(xlName == "全部线路") | |
| 265 | - xlName = $('#fgsdm option:selected').text(); | |
| 266 | - if(xlName =='请选择') | |
| 267 | - xlName = $('#gsdm option:selected').text(); | |
| 268 | - if(line=="请选择"){ | |
| 269 | - line=""; | |
| 270 | - } | |
| 271 | - if(date==null || date =="" ||date2==null || date2 ==""){ | |
| 272 | - layer.msg('请选择时间段.'); | |
| 273 | - }else{ | |
| 274 | - $("#tjrq").html(date+"至"+date2); | |
| 275 | - var params = {}; | |
| 276 | - params['gsdm'] = gsdm; | |
| 277 | - params['fgsdm'] =fgsdm ; | |
| 278 | - params['line'] = line; | |
| 279 | - params['date'] = date; | |
| 280 | - params['date2'] = date2; | |
| 281 | - params['xlName'] = xlName; | |
| 282 | - params['nbbm'] = nbbm; | |
| 283 | - params['type'] = "query"; | |
| 284 | - var i = layer.load(2); | |
| 285 | - $get('/auditReport/queryList',params,function(result){ | |
| 286 | - console.log(result); | |
| 287 | - // 把数据填充到模版中 | |
| 288 | - var tbodyHtml = template('statisticsDailyCalc2',{list:result}); | |
| 289 | - // 把渲染好的模版html文本追加到表格中 | |
| 290 | - $('#forms .statisticsDailyCalc2').html(tbodyHtml); | |
| 291 | - layer.close(i); | |
| 292 | - if(result.length == 0) | |
| 293 | - $("#export").attr('disabled',"true"); | |
| 294 | - else | |
| 295 | - $("#export").removeAttr("disabled"); | |
| 296 | - }); | |
| 297 | - } | |
| 298 | - | |
| 299 | - }); | |
| 300 | -// $("#tjrbBody").height($(window).height()-100); | |
| 301 | - $("#export").on("click",function(){ | |
| 302 | - if(getDateDifference(date, date2)>365){ | |
| 303 | - layer.msg("单次查询最多不超过365天!"); | |
| 304 | - return; | |
| 305 | - } | |
| 306 | - var params = {}; | |
| 307 | - params['gsdm'] = gsdm; | |
| 308 | - params['fgsdm'] =fgsdm ; | |
| 309 | - params['line'] = line; | |
| 310 | - params['date'] = date; | |
| 311 | - params['date2'] = date2; | |
| 312 | - params['xlName'] = xlName; | |
| 313 | - params['nbbm'] = nbbm; | |
| 314 | - params['type'] = "export"; | |
| 315 | - var i = layer.load(2); | |
| 316 | - $get('/auditReport/queryList',params,function(result){ | |
| 317 | - var dateTime = ""; | |
| 318 | - if(date == date2){ | |
| 319 | - dateTime = moment(date).format("YYYYMMDD"); | |
| 320 | - } else { | |
| 321 | - dateTime = moment(date).format("YYYYMMDD") | |
| 322 | - +"-"+moment(date2).format("YYYYMMDD"); | |
| 323 | - } | |
| 324 | - window.open("/downloadFile/download?fileName=" | |
| 325 | - +dateTime+"-"+xlName+"-路单审计"); | |
| 326 | - layer.close(i); | |
| 327 | - }); | |
| 328 | - }); | |
| 329 | - | |
| 330 | - $("#create").on("click",function(){ | |
| 331 | - if($("#date").val() == null || $("#date").val().trim().length == 0){ | |
| 332 | - layer.msg("请选择时间!"); | |
| 333 | - return; | |
| 334 | - } | |
| 335 | - date = $("#date").val(); | |
| 336 | - var params = {}; | |
| 337 | - params['date'] = date; | |
| 338 | - var i = layer.load(2); | |
| 339 | - $get('/auditReport/create',params,function(result){ | |
| 340 | - layer.close(i); | |
| 341 | - layer.msg('生成成功!'); | |
| 342 | - }); | |
| 343 | - }); | |
| 344 | - | |
| 345 | - function getDateDifference(start, end) { | |
| 346 | - const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数 | |
| 347 | - const startDate = new Date(start); // 转换为Date对象 | |
| 348 | - const endDate = new Date(end); // 转换为Date对象 | |
| 349 | - const diffDays = Math.round(Math.abs((endDate - startDate) / oneDay)); // 计算两个日期的差值,取绝对值并四舍五入 | |
| 350 | - return diffDays; | |
| 351 | - } | |
| 352 | - | |
| 353 | - }); | |
| 354 | -</script> | |
| 355 | -<script type="text/html" id="statisticsDailyCalc2"> | |
| 356 | - {{each list as obj i}} | |
| 357 | - <tr> | |
| 358 | - <td>{{obj.lineName}}</td> | |
| 359 | - <td>{{obj.plate}}</td> | |
| 360 | - <td>{{obj.carClass}}</td> | |
| 361 | - <td>{{obj.carLength}}</td> | |
| 362 | - <td>{{obj.sfdc}}</td> | |
| 363 | - <td>{{obj.sfmix}}</td> | |
| 364 | - <td>{{obj.yylc}}</td> | |
| 365 | - <td>{{obj.in}}</td> | |
| 366 | - <td>{{obj.out}}</td> | |
| 367 | - <td>{{obj.kslc}}</td> | |
| 368 | - <td>{{obj.zkslc}}</td> | |
| 369 | - <td>{{obj.zlc}}</td> | |
| 370 | - </tr> | |
| 371 | - {{/each}} | |
| 372 | - {{if list.length == 0}} | |
| 373 | - <tr> | |
| 374 | - <td colspan="46"><h6 class="muted">没有找到相关数据</h6></td> | |
| 375 | - </tr> | |
| 376 | - {{/if}} | |
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; } | |
| 11 | + .table-bordered > thead > tr > th, | |
| 12 | + .table-bordered > thead > tr > td { | |
| 13 | + border-bottom-width: 2px; } | |
| 14 | + | |
| 15 | + .table > tbody + tbody { | |
| 16 | + border-top: 1px solid; } | |
| 17 | + | |
| 18 | + #forms > thead > tr> td >span{ | |
| 19 | + width: 5px; | |
| 20 | + word-wrap: break-word; | |
| 21 | + letter-spacing: 20px; | |
| 22 | + } | |
| 23 | + | |
| 24 | + #forms > thead > tr> td >label{ | |
| 25 | + word-break: keep-all;white-space:nowrap; | |
| 26 | + } | |
| 27 | +</style> | |
| 28 | + | |
| 29 | +<div class="page-head"> | |
| 30 | + <div class="page-title"> | |
| 31 | + <h1>路单审计</h1> | |
| 32 | + </div> | |
| 33 | +</div> | |
| 34 | + | |
| 35 | +<!-- <div class="row"> --> | |
| 36 | + <div class="col-md-12 portlet light porttlet-fit bordered" style="height:calc(100% - 56px)"> | |
| 37 | +<!-- <div> --> | |
| 38 | + <div class="portlet-title"> | |
| 39 | + <form class="form-inline" action=""> | |
| 40 | + <div style="display: inline-block;margin-left: 29px; " id="gsdmDiv"> | |
| 41 | + <span class="item-label" style="width: 80px;">公司: </span> | |
| 42 | + <select class="form-control" name="company" id="gsdm" style="width: 180px;"></select> | |
| 43 | + </div> | |
| 44 | + <div style="display: inline-block; margin-left: 29px;" id="fgsdmDiv"> | |
| 45 | + <span class="item-label" style="width: 80px;">分公司: </span> | |
| 46 | + <select class="form-control" name="subCompany" id="fgsdm" style="width: 180px;"></select> | |
| 47 | + </div> | |
| 48 | + <div style="display: inline-block;margin-left: 42px;"> | |
| 49 | + <span class="item-label" style="width: 80px;">线路: </span> | |
| 50 | + <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 51 | + </div> | |
| 52 | + <div style="display: inline-block;margin-left: 42px;"> | |
| 53 | + <span class="item-label" style="width: 80px;">车辆: </span> | |
| 54 | + <select class="form-control" name="car" id="car" style="width: 180px;"></select> | |
| 55 | + </div> | |
| 56 | + <div style="margin-top: 3px"></div> | |
| 57 | + <div style="display: inline-block;margin-left: 15px;"> | |
| 58 | + <span class="item-label" style="width: 80px;">开始时间: </span> | |
| 59 | + <input class="form-control" type="text" id="date" style="width: 180px;"/> | |
| 60 | + </div> | |
| 61 | + <div style="display: inline-block;margin-left: 15px;"> | |
| 62 | + <span class="item-label" style="width: 80px;">结束时间: </span> | |
| 63 | + <input class="form-control" type="text" id="date2" style="width: 180px;"/> | |
| 64 | + </div> | |
| 65 | + <div class="form-group"> | |
| 66 | + <input class="btn btn-default" type="button" id="query" value="查询"/> | |
| 67 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 68 | + <input class="btn btn-default" type="button" id="create" value="生成" style="display: none;"/> | |
| 69 | + </div> | |
| 70 | + </form> | |
| 71 | + </div> | |
| 72 | + <div class="portlet-body" id="tjrbBody" style="overflow:auto;height: calc(100% - 80px)"> | |
| 73 | + <div class="table-container" style="margin-top: 10px;min-width: 906px"> | |
| 74 | +<!-- <label>早高峰:6:31~8:30 晚高峰:16:01~18:00</label>--> | |
| 75 | + <table class="table table-bordered table-hover table-checkable" id="forms"> | |
| 76 | + <thead> | |
| 77 | + <tr> | |
| 78 | + <th colspan="46"><label id="tjrq"></label> 路单审计</th> | |
| 79 | + </tr> | |
| 80 | + <tr> | |
| 81 | + <td rowspan="4"><label>线路</label></td> | |
| 82 | + <td rowspan="3"><label>车牌号</label></td> | |
| 83 | + <td rowspan="3"><label>车型类别</label></td> | |
| 84 | + <td rowspan="3"><label>车长</label></td> | |
| 85 | + <td rowspan="3"><label>电车</label></td> | |
| 86 | + <td rowspan="3"><label>混合电车</label></td> | |
| 87 | + <td rowspan="3"><label>营运里程</label></td> | |
| 88 | + <td rowspan="3"><label>进场</label></td> | |
| 89 | + <td rowspan="2"><label>出场</label> | |
| 90 | + <td rowspan="2"><label>空驶</label></td> | |
| 91 | + <td rowspan="2"><label>总空驶</label></td> | |
| 92 | + <td rowspan="2"><label>总里程</label></td> | |
| 93 | + </tr> | |
| 94 | + </thead> | |
| 95 | + <tbody class="statisticsDailyCalc2"> | |
| 96 | + | |
| 97 | + </tbody> | |
| 98 | + </table> | |
| 99 | + </div> | |
| 100 | + </div> | |
| 101 | + </div> | |
| 102 | + | |
| 103 | +<script> | |
| 104 | + $(function(){ | |
| 105 | + $('#export').attr('disabled', "true"); | |
| 106 | + | |
| 107 | + // 关闭左侧栏 | |
| 108 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 109 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 110 | + | |
| 111 | + var d = new Date(); | |
| 112 | + d.setTime(d.getTime() - 2*1000*60*60*24); | |
| 113 | + var year = d.getFullYear(); | |
| 114 | + var month = d.getMonth() + 1; | |
| 115 | + var day = d.getDate(); | |
| 116 | + if(month < 10) | |
| 117 | + month = "0" + month; | |
| 118 | + if(day < 10) | |
| 119 | + day = "0" + day; | |
| 120 | + var dateTime = year + "-" + month + "-" + day; | |
| 121 | + $("#date").datetimepicker({ | |
| 122 | + format : 'YYYY-MM-DD', | |
| 123 | + locale : 'zh-cn', | |
| 124 | + maxDate : dateTime | |
| 125 | + }); | |
| 126 | + $("#date2").datetimepicker({ | |
| 127 | + format : 'YYYY-MM-DD', | |
| 128 | + locale : 'zh-cn', | |
| 129 | + maxDate : dateTime | |
| 130 | + }); | |
| 131 | + $("#date").val(dateTime); | |
| 132 | + $("#date2").val(dateTime); | |
| 133 | + | |
| 134 | + var fage=false; | |
| 135 | + var obj = []; | |
| 136 | + var xlList; | |
| 137 | + $.get('/report/lineList',function(result){ | |
| 138 | + xlList=result; | |
| 139 | + $.get('/user/companyData', function(result){ | |
| 140 | + obj = result; | |
| 141 | + var options = ''; | |
| 142 | + for(var i = 0; i < obj.length; i++){ | |
| 143 | + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; | |
| 144 | + } | |
| 145 | + if(obj.length ==0){ | |
| 146 | + $("#gsdmDiv").css('display','none'); | |
| 147 | + }else if(obj.length ==1){ | |
| 148 | + $("#gsdmDiv").css('display','none'); | |
| 149 | + if(obj[0].children.length == 1 || obj[0].children.length ==0) | |
| 150 | + $('#fgsdmDiv').css('display','none'); | |
| 151 | + } | |
| 152 | + $('#gsdm').html(options); | |
| 153 | + updateCompany(); | |
| 154 | + }); | |
| 155 | + }); | |
| 156 | + | |
| 157 | + $("#gsdm").on("change",updateCompany); | |
| 158 | + function updateCompany(){ | |
| 159 | + var company = $('#gsdm').val(); | |
| 160 | + var options = '<option value="">全部</option>'; | |
| 161 | + for(var i = 0; i < obj.length; i++){ | |
| 162 | + if(obj[i].companyCode == company){ | |
| 163 | + var children = obj[i].children; | |
| 164 | + for(var j = 0; j < children.length; j++){ | |
| 165 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 166 | + } | |
| 167 | + } | |
| 168 | + } | |
| 169 | + $('#fgsdm').html(options); | |
| 170 | + initXl(); | |
| 171 | + } | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + $("#fgsdm").on("change",initXl); | |
| 177 | + function initXl(){ | |
| 178 | + var data=[]; | |
| 179 | + data.push({id: " ", text: "全部线路"}); | |
| 180 | + if(fage){ | |
| 181 | + $("#line").select2("destroy").html(''); | |
| 182 | + } | |
| 183 | + var fgs=$('#fgsdm').val(); | |
| 184 | + var gs=$('#gsdm').val(); | |
| 185 | + for(var i=0;i<xlList.length;i++){ | |
| 186 | + if(gs!=""){ | |
| 187 | + if(fgs!=""){ | |
| 188 | + if(xlList[i]["fgsbm"]==fgs && xlList[i]["gsbm"]==gs){ | |
| 189 | + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]}); | |
| 190 | + } | |
| 191 | + }else{ | |
| 192 | + if(xlList[i]["gsbm"]==gs){ | |
| 193 | + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]}); | |
| 194 | + } | |
| 195 | + } | |
| 196 | + } | |
| 197 | + } | |
| 198 | + initPinYinSelect2('#line',data,''); | |
| 199 | + fage=true; | |
| 200 | + } | |
| 201 | + | |
| 202 | + $.get('/auditReport/queryCarList',function(carList){ | |
| 203 | + var data = []; | |
| 204 | + data.push({id: " ", text: "全部车辆"}); | |
| 205 | + $.get('/user/companyData', function(result){ | |
| 206 | + for(var i = 0; i < result.length; i++){ | |
| 207 | + var companyCode = result[i].companyCode; | |
| 208 | + var children = result[i].children; | |
| 209 | + for(var j = 0; j < children.length; j++){ | |
| 210 | + var code = children[j].code; | |
| 211 | + for(var k=0;k < carList.length;k++ ){ | |
| 212 | + if(carList[k]["fgsbm"]==code && carList[k]["gsbm"]==companyCode){ | |
| 213 | + data.push({id: carList[k]["nbbm"], text: carList[k]["carPlate"]}); | |
| 214 | + } | |
| 215 | + } | |
| 216 | + } | |
| 217 | + } | |
| 218 | + initPinYinSelect2('#car',data,''); | |
| 219 | + }); | |
| 220 | + }); | |
| 221 | + | |
| 222 | + /*$("#line").on("change", function(){ | |
| 223 | + if($("#line").val() == " "){ | |
| 224 | + $("#gsdm").attr("disabled", false); | |
| 225 | + $("#fgsdm").attr("disabled", false); | |
| 226 | + } else { | |
| 227 | + var temp = tempData[$("#line").val()].split(":"); | |
| 228 | + $("#gsdm").val(temp[0]); | |
| 229 | + updateCompany(); | |
| 230 | + $("#fgsdm").val(temp[1]); | |
| 231 | + $("#gsdm").attr("disabled", true); | |
| 232 | + $("#fgsdm").attr("disabled", true); | |
| 233 | + } | |
| 234 | + });*/ | |
| 235 | + | |
| 236 | + | |
| 237 | + var line =""; | |
| 238 | + var xlName =""; | |
| 239 | + var date = ""; | |
| 240 | + var date2 =""; | |
| 241 | + var gsdm=""; | |
| 242 | + var fgsdm=""; | |
| 243 | + var nbbm=""; | |
| 244 | + $("#query").on("click",function(){ | |
| 245 | + if($("#date").val() == null || $("#date").val().trim().length == 0){ | |
| 246 | + layer.msg("请选择时间范围!"); | |
| 247 | + return; | |
| 248 | + } | |
| 249 | + if($("#date2").val() == null || $("#date2").val().trim().length == 0){ | |
| 250 | + layer.msg("请选择时间范围!"); | |
| 251 | + return; | |
| 252 | + } | |
| 253 | + line = $("#line").val(); | |
| 254 | + date = $("#date").val(); | |
| 255 | + date2 =$("#date2").val(); | |
| 256 | + if(getDateDifference(date, date2)>365){ | |
| 257 | + layer.msg("单次查询最多不超过365天!"); | |
| 258 | + return; | |
| 259 | + } | |
| 260 | + gsdm =$("#gsdm").val(); | |
| 261 | + fgsdm=$("#fgsdm").val(); | |
| 262 | + nbbm = $("#car").val(); | |
| 263 | + xlName = $("#select2-line-container").html(); | |
| 264 | + if(xlName == "全部线路") | |
| 265 | + xlName = $('#fgsdm option:selected').text(); | |
| 266 | + if(xlName =='请选择') | |
| 267 | + xlName = $('#gsdm option:selected').text(); | |
| 268 | + if(line=="请选择"){ | |
| 269 | + line=""; | |
| 270 | + } | |
| 271 | + if(date==null || date =="" ||date2==null || date2 ==""){ | |
| 272 | + layer.msg('请选择时间段.'); | |
| 273 | + }else{ | |
| 274 | + $("#tjrq").html(date+"至"+date2); | |
| 275 | + var params = {}; | |
| 276 | + params['gsdm'] = gsdm; | |
| 277 | + params['fgsdm'] =fgsdm ; | |
| 278 | + params['line'] = line; | |
| 279 | + params['date'] = date; | |
| 280 | + params['date2'] = date2; | |
| 281 | + params['xlName'] = xlName; | |
| 282 | + params['nbbm'] = nbbm; | |
| 283 | + params['type'] = "query"; | |
| 284 | + var i = layer.load(2); | |
| 285 | + $get('/auditReport/queryList',params,function(result){ | |
| 286 | + console.log(result); | |
| 287 | + // 把数据填充到模版中 | |
| 288 | + var tbodyHtml = template('statisticsDailyCalc2',{list:result}); | |
| 289 | + // 把渲染好的模版html文本追加到表格中 | |
| 290 | + $('#forms .statisticsDailyCalc2').html(tbodyHtml); | |
| 291 | + layer.close(i); | |
| 292 | + if(result.length == 0) | |
| 293 | + $("#export").attr('disabled',"true"); | |
| 294 | + else | |
| 295 | + $("#export").removeAttr("disabled"); | |
| 296 | + }); | |
| 297 | + } | |
| 298 | + | |
| 299 | + }); | |
| 300 | +// $("#tjrbBody").height($(window).height()-100); | |
| 301 | + $("#export").on("click",function(){ | |
| 302 | + if(getDateDifference(date, date2)>365){ | |
| 303 | + layer.msg("单次查询最多不超过365天!"); | |
| 304 | + return; | |
| 305 | + } | |
| 306 | + var params = {}; | |
| 307 | + params['gsdm'] = gsdm; | |
| 308 | + params['fgsdm'] =fgsdm ; | |
| 309 | + params['line'] = line; | |
| 310 | + params['date'] = date; | |
| 311 | + params['date2'] = date2; | |
| 312 | + params['xlName'] = xlName; | |
| 313 | + params['nbbm'] = nbbm; | |
| 314 | + params['type'] = "export"; | |
| 315 | + var i = layer.load(2); | |
| 316 | + $get('/auditReport/queryList',params,function(result){ | |
| 317 | + var dateTime = ""; | |
| 318 | + if(date == date2){ | |
| 319 | + dateTime = moment(date).format("YYYYMMDD"); | |
| 320 | + } else { | |
| 321 | + dateTime = moment(date).format("YYYYMMDD") | |
| 322 | + +"-"+moment(date2).format("YYYYMMDD"); | |
| 323 | + } | |
| 324 | + window.open("/downloadFile/download?fileName=" | |
| 325 | + +dateTime+"-"+xlName+"-单车里程统计"); | |
| 326 | + layer.close(i); | |
| 327 | + }); | |
| 328 | + }); | |
| 329 | + | |
| 330 | + $("#create").on("click",function(){ | |
| 331 | + if($("#date").val() == null || $("#date").val().trim().length == 0){ | |
| 332 | + layer.msg("请选择时间!"); | |
| 333 | + return; | |
| 334 | + } | |
| 335 | + date = $("#date").val(); | |
| 336 | + var params = {}; | |
| 337 | + params['date'] = date; | |
| 338 | + var i = layer.load(2); | |
| 339 | + $get('/auditReport/create',params,function(result){ | |
| 340 | + layer.close(i); | |
| 341 | + layer.msg('生成成功!'); | |
| 342 | + }); | |
| 343 | + }); | |
| 344 | + | |
| 345 | + function getDateDifference(start, end) { | |
| 346 | + const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数 | |
| 347 | + const startDate = new Date(start); // 转换为Date对象 | |
| 348 | + const endDate = new Date(end); // 转换为Date对象 | |
| 349 | + const diffDays = Math.round(Math.abs((endDate - startDate) / oneDay)); // 计算两个日期的差值,取绝对值并四舍五入 | |
| 350 | + return diffDays; | |
| 351 | + } | |
| 352 | + | |
| 353 | + }); | |
| 354 | +</script> | |
| 355 | +<script type="text/html" id="statisticsDailyCalc2"> | |
| 356 | + {{each list as obj i}} | |
| 357 | + <tr> | |
| 358 | + <td>{{obj.lineName}}</td> | |
| 359 | + <td>{{obj.plate}}</td> | |
| 360 | + <td>{{obj.carClass}}</td> | |
| 361 | + <td>{{obj.carLength}}</td> | |
| 362 | + <td>{{obj.sfdc}}</td> | |
| 363 | + <td>{{obj.sfmix}}</td> | |
| 364 | + <td>{{obj.yylc}}</td> | |
| 365 | + <td>{{obj.in}}</td> | |
| 366 | + <td>{{obj.out}}</td> | |
| 367 | + <td>{{obj.kslc}}</td> | |
| 368 | + <td>{{obj.zkslc}}</td> | |
| 369 | + <td>{{obj.zlc}}</td> | |
| 370 | + </tr> | |
| 371 | + {{/each}} | |
| 372 | + {{if list.length == 0}} | |
| 373 | + <tr> | |
| 374 | + <td colspan="46"><h6 class="muted">没有找到相关数据</h6></td> | |
| 375 | + </tr> | |
| 376 | + {{/if}} | |
| 377 | 377 | </script> |
| 378 | 378 | \ No newline at end of file | ... | ... |