Commit ce780d26cef7317ade751a76af1e1823d07a68a4
1 parent
5b5755e1
南汇路单线路明细月、年报表
Showing
11 changed files
with
2008 additions
and
14 deletions
src/main/java/com/bsth/controller/calc/CalcWaybillController.java
| ... | ... | @@ -317,4 +317,8 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer> |
| 317 | 317 | return calcWaybillService.getBusMileage(line, date, date2, xlName, zt, by, type); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | + @RequestMapping(value="/calcDetailMonthly") | |
| 321 | + public List<List<String>> calcDetailMonthly(@RequestParam Map<String, Object> map){ | |
| 322 | + return calcWaybillService.calcDetailMonthly(map); | |
| 323 | + } | |
| 320 | 324 | } | ... | ... |
src/main/java/com/bsth/controller/report/ReportController.java
| ... | ... | @@ -377,4 +377,16 @@ public class ReportController { |
| 377 | 377 | |
| 378 | 378 | return service.singleEnergy(map); |
| 379 | 379 | } |
| 380 | + | |
| 381 | + /** | |
| 382 | + * @Description :TODO(路单线路明细月报表导出数据) | |
| 383 | + * | |
| 384 | + * @param map <tables> | |
| 385 | + * | |
| 386 | + * @return Map<String, Object> | |
| 387 | + */ | |
| 388 | + @RequestMapping(value = "/calcDetailMonthlyE" , method = RequestMethod.POST) | |
| 389 | + public Map<String, Object> calcDetailMonthlyE(@RequestParam Map<String,Object> map) { | |
| 390 | + return service.calcDetailMonthlyE(map); | |
| 391 | + } | |
| 380 | 392 | } | ... | ... |
src/main/java/com/bsth/entity/calc/CalcWaybillDetail.java
0 → 100644
| 1 | +package com.bsth.entity.calc; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | +// calcDetailMonthly.html 返回类 | |
| 5 | +public class CalcWaybillDetail { | |
| 6 | + private Long id; | |
| 7 | + /* 公司代码*/ | |
| 8 | + private String gsdm; | |
| 9 | + /* 公司名称*/ | |
| 10 | + private String gsname; | |
| 11 | + /* 分公司代码*/ | |
| 12 | + private String fgsdm; | |
| 13 | + /* 分公司名称*/ | |
| 14 | + private String fgsname; | |
| 15 | + /* 日期*/ | |
| 16 | + private Date rq; | |
| 17 | + /* 日期字符串*/ | |
| 18 | + private String rqStr; | |
| 19 | + /* 线路编码*/ | |
| 20 | + private String xl; | |
| 21 | + /* 线路名称*/ | |
| 22 | + private String xlName; | |
| 23 | + /* 车辆自编号*/ | |
| 24 | + private String cl; | |
| 25 | + /* 路牌名字*/ | |
| 26 | + private String lp; | |
| 27 | + /* 驾驶员工号*/ | |
| 28 | + private String jGh; | |
| 29 | + /* 驾驶员名字*/ | |
| 30 | + private String jName; | |
| 31 | + /* 售票员工号*/ | |
| 32 | + private String sGh; | |
| 33 | + /* 售票员名字*/ | |
| 34 | + private String sName; | |
| 35 | + /* 计划营运班次*/ | |
| 36 | + private int jhyybc=0; | |
| 37 | + /* 计划早高峰营运班次*/ | |
| 38 | + private int jhyybczgf=0; | |
| 39 | + /* 计划晚高峰营运班次*/ | |
| 40 | + private int jhyybcwgf=0; | |
| 41 | + /* 计划非营运班次*/ | |
| 42 | + private int jhfyybc=0; | |
| 43 | + /* 计划营运里程*/ | |
| 44 | + private Double jhyylc=0.0; | |
| 45 | + /* 计划非营运里程*/ | |
| 46 | + private Double jhfyylc=0.0; | |
| 47 | + /* 实际营运班次*/ | |
| 48 | + private int sjyybc=0; | |
| 49 | + /* 实际早高峰营运班次*/ | |
| 50 | + private int sjyybczgf=0; | |
| 51 | + /* 实际晚高峰营运班次*/ | |
| 52 | + private int sjyybcwgf=0; | |
| 53 | + /* 实际非营运班次*/ | |
| 54 | + private int sjfyybc=0; | |
| 55 | + /* 实际营运里程*/ | |
| 56 | + private Double sjyylc=0.0; | |
| 57 | + /* 实际非营运里程*/ | |
| 58 | + private Double sjfyylc=0.0; | |
| 59 | + /* 临加班次*/ | |
| 60 | + private int ljbc=0; | |
| 61 | + /* 临加早高峰班次*/ | |
| 62 | + private int ljbczgf=0; | |
| 63 | + /* 临加晚高峰班次*/ | |
| 64 | + private int ljbcwgf=0; | |
| 65 | + /* 临加营运里程*/ | |
| 66 | + private Double ljyylc=0.0; | |
| 67 | + /* 临加非营运里程*/ | |
| 68 | + private Double ljfyylc=0.0; | |
| 69 | + /* 烂班班次*/ | |
| 70 | + private int lbbc=0; | |
| 71 | + /* 烂班里程*/ | |
| 72 | + private Double lblc=0.0; | |
| 73 | + | |
| 74 | + | |
| 75 | + // 总里程 | |
| 76 | + private Double zlc=0.0; | |
| 77 | + private Double czlc=0.0; | |
| 78 | + private Double jzlc=0.0; | |
| 79 | + // 出场油量 | |
| 80 | + private Double czyl=0.0; | |
| 81 | + // 进场油量 | |
| 82 | + private Double jzyl=0.0; | |
| 83 | + // 加注量 | |
| 84 | + private Double jzl=0.0; | |
| 85 | + // 加注量 0号柴油 | |
| 86 | + private Double jzl0=0.0; | |
| 87 | + // 加注量 -10#号柴油 | |
| 88 | + private Double jzl10=0.0; | |
| 89 | + // 油耗 | |
| 90 | + private Double yh=0.0; | |
| 91 | + // 百公里油耗 | |
| 92 | + private Double bglyh=0.0; | |
| 93 | + // 损耗 | |
| 94 | + private Double sh=0.0; | |
| 95 | + // 燃油类型 | |
| 96 | + private String rylx; | |
| 97 | + | |
| 98 | + //出站存电 | |
| 99 | + private Double czcd=0.0; | |
| 100 | + //进站存电 | |
| 101 | + private Double jzcd=0.0; | |
| 102 | + //充电量 | |
| 103 | + private Double cdl=0.0; | |
| 104 | + //耗电 | |
| 105 | + private Double hd=0.0; | |
| 106 | + //百公里耗电 | |
| 107 | + private Double bglhd=0.0; | |
| 108 | + | |
| 109 | + // 天数记录 | |
| 110 | + private int ts; | |
| 111 | + | |
| 112 | + /* 创建时间*/ | |
| 113 | + private Date createTime; | |
| 114 | + /* 修改时间*/ | |
| 115 | + private Date updateTime; | |
| 116 | + public Long getId() { | |
| 117 | + return id; | |
| 118 | + } | |
| 119 | + public void setId(Long id) { | |
| 120 | + this.id = id; | |
| 121 | + } | |
| 122 | + public String getGsdm() { | |
| 123 | + return gsdm; | |
| 124 | + } | |
| 125 | + public void setGsdm(String gsdm) { | |
| 126 | + this.gsdm = gsdm; | |
| 127 | + } | |
| 128 | + public String getGsname() { | |
| 129 | + return gsname; | |
| 130 | + } | |
| 131 | + public void setGsname(String gsname) { | |
| 132 | + this.gsname = gsname; | |
| 133 | + } | |
| 134 | + public String getFgsdm() { | |
| 135 | + return fgsdm; | |
| 136 | + } | |
| 137 | + public void setFgsdm(String fgsdm) { | |
| 138 | + this.fgsdm = fgsdm; | |
| 139 | + } | |
| 140 | + public String getFgsname() { | |
| 141 | + return fgsname; | |
| 142 | + } | |
| 143 | + public void setFgsname(String fgsname) { | |
| 144 | + this.fgsname = fgsname; | |
| 145 | + } | |
| 146 | + public Date getRq() { | |
| 147 | + return rq; | |
| 148 | + } | |
| 149 | + public void setRq(Date rq) { | |
| 150 | + this.rq = rq; | |
| 151 | + } | |
| 152 | + public String getRqStr() { | |
| 153 | + return rqStr; | |
| 154 | + } | |
| 155 | + public void setRqStr(String rqStr) { | |
| 156 | + this.rqStr = rqStr; | |
| 157 | + } | |
| 158 | + public String getXl() { | |
| 159 | + return xl; | |
| 160 | + } | |
| 161 | + public void setXl(String xl) { | |
| 162 | + this.xl = xl; | |
| 163 | + } | |
| 164 | + public String getXlName() { | |
| 165 | + return xlName; | |
| 166 | + } | |
| 167 | + public void setXlName(String xlName) { | |
| 168 | + this.xlName = xlName; | |
| 169 | + } | |
| 170 | + public String getCl() { | |
| 171 | + return cl; | |
| 172 | + } | |
| 173 | + public void setCl(String cl) { | |
| 174 | + this.cl = cl; | |
| 175 | + } | |
| 176 | + public String getLp() { | |
| 177 | + return lp; | |
| 178 | + } | |
| 179 | + public void setLp(String lp) { | |
| 180 | + this.lp = lp; | |
| 181 | + } | |
| 182 | + public String getjGh() { | |
| 183 | + return jGh; | |
| 184 | + } | |
| 185 | + public void setjGh(String jGh) { | |
| 186 | + this.jGh = jGh; | |
| 187 | + } | |
| 188 | + public String getjName() { | |
| 189 | + return jName; | |
| 190 | + } | |
| 191 | + public void setjName(String jName) { | |
| 192 | + this.jName = jName; | |
| 193 | + } | |
| 194 | + public String getsGh() { | |
| 195 | + return sGh; | |
| 196 | + } | |
| 197 | + public void setsGh(String sGh) { | |
| 198 | + this.sGh = sGh; | |
| 199 | + } | |
| 200 | + public String getsName() { | |
| 201 | + return sName; | |
| 202 | + } | |
| 203 | + public void setsName(String sName) { | |
| 204 | + this.sName = sName; | |
| 205 | + } | |
| 206 | + public int getJhyybc() { | |
| 207 | + return jhyybc; | |
| 208 | + } | |
| 209 | + public void setJhyybc(int jhyybc) { | |
| 210 | + this.jhyybc = jhyybc; | |
| 211 | + } | |
| 212 | + public int getJhyybczgf() { | |
| 213 | + return jhyybczgf; | |
| 214 | + } | |
| 215 | + public void setJhyybczgf(int jhyybczgf) { | |
| 216 | + this.jhyybczgf = jhyybczgf; | |
| 217 | + } | |
| 218 | + public int getJhyybcwgf() { | |
| 219 | + return jhyybcwgf; | |
| 220 | + } | |
| 221 | + public void setJhyybcwgf(int jhyybcwgf) { | |
| 222 | + this.jhyybcwgf = jhyybcwgf; | |
| 223 | + } | |
| 224 | + public int getJhfyybc() { | |
| 225 | + return jhfyybc; | |
| 226 | + } | |
| 227 | + public void setJhfyybc(int jhfyybc) { | |
| 228 | + this.jhfyybc = jhfyybc; | |
| 229 | + } | |
| 230 | + public Double getJhyylc() { | |
| 231 | + return jhyylc; | |
| 232 | + } | |
| 233 | + public void setJhyylc(Double jhyylc) { | |
| 234 | + this.jhyylc = jhyylc; | |
| 235 | + } | |
| 236 | + public Double getJhfyylc() { | |
| 237 | + return jhfyylc; | |
| 238 | + } | |
| 239 | + public void setJhfyylc(Double jhfyylc) { | |
| 240 | + this.jhfyylc = jhfyylc; | |
| 241 | + } | |
| 242 | + public int getSjyybc() { | |
| 243 | + return sjyybc; | |
| 244 | + } | |
| 245 | + public void setSjyybc(int sjyybc) { | |
| 246 | + this.sjyybc = sjyybc; | |
| 247 | + } | |
| 248 | + public int getSjyybczgf() { | |
| 249 | + return sjyybczgf; | |
| 250 | + } | |
| 251 | + public void setSjyybczgf(int sjyybczgf) { | |
| 252 | + this.sjyybczgf = sjyybczgf; | |
| 253 | + } | |
| 254 | + public int getSjyybcwgf() { | |
| 255 | + return sjyybcwgf; | |
| 256 | + } | |
| 257 | + public void setSjyybcwgf(int sjyybcwgf) { | |
| 258 | + this.sjyybcwgf = sjyybcwgf; | |
| 259 | + } | |
| 260 | + public int getSjfyybc() { | |
| 261 | + return sjfyybc; | |
| 262 | + } | |
| 263 | + public void setSjfyybc(int sjfyybc) { | |
| 264 | + this.sjfyybc = sjfyybc; | |
| 265 | + } | |
| 266 | + public Double getSjyylc() { | |
| 267 | + return sjyylc; | |
| 268 | + } | |
| 269 | + public void setSjyylc(Double sjyylc) { | |
| 270 | + this.sjyylc = sjyylc; | |
| 271 | + } | |
| 272 | + public Double getSjfyylc() { | |
| 273 | + return sjfyylc; | |
| 274 | + } | |
| 275 | + public void setSjfyylc(Double sjfyylc) { | |
| 276 | + this.sjfyylc = sjfyylc; | |
| 277 | + } | |
| 278 | + public int getLjbc() { | |
| 279 | + return ljbc; | |
| 280 | + } | |
| 281 | + public void setLjbc(int ljbc) { | |
| 282 | + this.ljbc = ljbc; | |
| 283 | + } | |
| 284 | + public int getLjbczgf() { | |
| 285 | + return ljbczgf; | |
| 286 | + } | |
| 287 | + public void setLjbczgf(int ljbczgf) { | |
| 288 | + this.ljbczgf = ljbczgf; | |
| 289 | + } | |
| 290 | + public int getLjbcwgf() { | |
| 291 | + return ljbcwgf; | |
| 292 | + } | |
| 293 | + public void setLjbcwgf(int ljbcwgf) { | |
| 294 | + this.ljbcwgf = ljbcwgf; | |
| 295 | + } | |
| 296 | + public Double getLjyylc() { | |
| 297 | + return ljyylc; | |
| 298 | + } | |
| 299 | + public void setLjyylc(Double ljyylc) { | |
| 300 | + this.ljyylc = ljyylc; | |
| 301 | + } | |
| 302 | + public Double getLjfyylc() { | |
| 303 | + return ljfyylc; | |
| 304 | + } | |
| 305 | + public void setLjfyylc(Double ljfyylc) { | |
| 306 | + this.ljfyylc = ljfyylc; | |
| 307 | + } | |
| 308 | + public int getLbbc() { | |
| 309 | + return lbbc; | |
| 310 | + } | |
| 311 | + public void setLbbc(int lbbc) { | |
| 312 | + this.lbbc = lbbc; | |
| 313 | + } | |
| 314 | + public Double getLblc() { | |
| 315 | + return lblc; | |
| 316 | + } | |
| 317 | + public void setLblc(Double lblc) { | |
| 318 | + this.lblc = lblc; | |
| 319 | + } | |
| 320 | + | |
| 321 | + public Double getZlc() { | |
| 322 | + return zlc; | |
| 323 | + } | |
| 324 | + | |
| 325 | + public void setZlc(Double zlc) { | |
| 326 | + this.zlc = zlc; | |
| 327 | + } | |
| 328 | + | |
| 329 | + public Double getCzlc() { | |
| 330 | + return czlc; | |
| 331 | + } | |
| 332 | + | |
| 333 | + public void setCzlc(Double czlc) { | |
| 334 | + this.czlc = czlc; | |
| 335 | + } | |
| 336 | + | |
| 337 | + public Double getJzlc() { | |
| 338 | + return jzlc; | |
| 339 | + } | |
| 340 | + | |
| 341 | + public void setJzlc(Double jzlc) { | |
| 342 | + this.jzlc = jzlc; | |
| 343 | + } | |
| 344 | + | |
| 345 | + public Double getCzyl() { | |
| 346 | + return czyl; | |
| 347 | + } | |
| 348 | + | |
| 349 | + public void setCzyl(Double czyl) { | |
| 350 | + this.czyl = czyl; | |
| 351 | + } | |
| 352 | + | |
| 353 | + public Double getJzyl() { | |
| 354 | + return jzyl; | |
| 355 | + } | |
| 356 | + | |
| 357 | + public void setJzyl(Double jzyl) { | |
| 358 | + this.jzyl = jzyl; | |
| 359 | + } | |
| 360 | + | |
| 361 | + public Double getJzl() { | |
| 362 | + return jzl; | |
| 363 | + } | |
| 364 | + | |
| 365 | + public Double getJzl0() { | |
| 366 | + return jzl0; | |
| 367 | + } | |
| 368 | + | |
| 369 | + public void setJzl0(Double jzl0) { | |
| 370 | + this.jzl0 = jzl0; | |
| 371 | + } | |
| 372 | + | |
| 373 | + public Double getJzl10() { | |
| 374 | + return jzl10; | |
| 375 | + } | |
| 376 | + | |
| 377 | + public void setJzl10(Double jzl10) { | |
| 378 | + this.jzl10 = jzl10; | |
| 379 | + } | |
| 380 | + | |
| 381 | + public void setJzl(Double jzl) { | |
| 382 | + this.jzl = jzl; | |
| 383 | + } | |
| 384 | + | |
| 385 | + public Double getYh() { | |
| 386 | + return yh; | |
| 387 | + } | |
| 388 | + | |
| 389 | + public void setYh(Double yh) { | |
| 390 | + this.yh = yh; | |
| 391 | + } | |
| 392 | + | |
| 393 | + public Double getBglyh() { | |
| 394 | + return bglyh; | |
| 395 | + } | |
| 396 | + | |
| 397 | + public void setBglyh(Double bglyh) { | |
| 398 | + this.bglyh = bglyh; | |
| 399 | + } | |
| 400 | + | |
| 401 | + public Double getSh() { | |
| 402 | + return sh; | |
| 403 | + } | |
| 404 | + | |
| 405 | + public void setSh(Double sh) { | |
| 406 | + this.sh = sh; | |
| 407 | + } | |
| 408 | + | |
| 409 | + public String getRylx() { | |
| 410 | + return rylx; | |
| 411 | + } | |
| 412 | + | |
| 413 | + public void setRylx(String rylx) { | |
| 414 | + this.rylx = rylx; | |
| 415 | + } | |
| 416 | + | |
| 417 | + public Double getCzcd() { | |
| 418 | + return czcd; | |
| 419 | + } | |
| 420 | + | |
| 421 | + public void setCzcd(Double czcd) { | |
| 422 | + this.czcd = czcd; | |
| 423 | + } | |
| 424 | + | |
| 425 | + public Double getJzcd() { | |
| 426 | + return jzcd; | |
| 427 | + } | |
| 428 | + | |
| 429 | + public void setJzcd(Double jzcd) { | |
| 430 | + this.jzcd = jzcd; | |
| 431 | + } | |
| 432 | + | |
| 433 | + public Double getCdl() { | |
| 434 | + return cdl; | |
| 435 | + } | |
| 436 | + | |
| 437 | + public void setCdl(Double cdl) { | |
| 438 | + this.cdl = cdl; | |
| 439 | + } | |
| 440 | + | |
| 441 | + public Double getHd() { | |
| 442 | + return hd; | |
| 443 | + } | |
| 444 | + | |
| 445 | + public void setHd(Double hd) { | |
| 446 | + this.hd = hd; | |
| 447 | + } | |
| 448 | + | |
| 449 | + public Double getBglhd() { | |
| 450 | + return bglhd; | |
| 451 | + } | |
| 452 | + | |
| 453 | + public void setBglhd(Double bglhd) { | |
| 454 | + this.bglhd = bglhd; | |
| 455 | + } | |
| 456 | + | |
| 457 | + public int getTs() { | |
| 458 | + return ts; | |
| 459 | + } | |
| 460 | + | |
| 461 | + public void setTs(int ts) { | |
| 462 | + this.ts = ts; | |
| 463 | + } | |
| 464 | + | |
| 465 | + public Date getCreateTime() { | |
| 466 | + return createTime; | |
| 467 | + } | |
| 468 | + public void setCreateTime(Date createTime) { | |
| 469 | + this.createTime = createTime; | |
| 470 | + } | |
| 471 | + public Date getUpdateTime() { | |
| 472 | + return updateTime; | |
| 473 | + } | |
| 474 | + public void setUpdateTime(Date updateTime) { | |
| 475 | + this.updateTime = updateTime; | |
| 476 | + } | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | +} | ... | ... |
src/main/java/com/bsth/repository/calc/CalcWaybillRepository.java
| ... | ... | @@ -72,4 +72,21 @@ public interface CalcWaybillRepository extends BaseRepository<CalcWaybill, Integ |
| 72 | 72 | + " and c.cl in (select s.carCode from Cars s where s.sfdc = ?7) order by c.xl") |
| 73 | 73 | List<CalcWaybill> scheduleByZbh(String line,String date,String date2,String gsdm,String fgsdm,String zbh,Boolean sfdc); |
| 74 | 74 | |
| 75 | + | |
| 76 | + //按照时间段统计,公司下线路 (驾驶员) | |
| 77 | + @Query(value="select DISTINCT c from CalcWaybill c where c.xl like %?1% and c.rqStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% order by c.jGh,c.xl,c.rq") | |
| 78 | + List<CalcWaybill> scheduleByJsy2(String line,String date,String date2,String gsdm,String fgsdm); | |
| 79 | + //按照时间段统计,公司下线路 (售票员) coalesce(c.sGh,'') | |
| 80 | + @Query(value="select DISTINCT c from CalcWaybill c where c.xl like %?1% and c.rqStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% and c.sGh <> null and c.sGh <> '' order by c.sGh,c.xl,c.rq") | |
| 81 | + List<CalcWaybill> scheduleBySpy2(String line,String date,String date2,String gsdm,String fgsdm); | |
| 82 | + //按照时间段统计,公司下线路 (车辆自编号) | |
| 83 | + @Query(value="select DISTINCT c from CalcWaybill c where c.xl like %?1% and c.rqStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% order by c.cl,c.xl,c.rq") | |
| 84 | + List<CalcWaybill> scheduleByZbh2(String line,String date,String date2,String gsdm,String fgsdm); | |
| 85 | + //按照时间段统计,公司下线路 排序不同 | |
| 86 | + @Query(value="select DISTINCT c from CalcWaybill c where c.xl like %?1% and c.rqStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% order by c.xl,c.rq") | |
| 87 | + List<CalcWaybill> scheduleByDateAndLineTjPx(String line,String date,String date2,String gsdm,String fgsdm); | |
| 88 | + //按照时间段统计,单条线路 排序不同 | |
| 89 | + @Query(value="select DISTINCT c from CalcWaybill c where c.xl = ?1 and c.rqStr between ?2 and ?3 order by c.xl,c.rq") | |
| 90 | + List<CalcWaybill> scheduleByDateAndLineTjPx2(String line,String date,String date2); | |
| 91 | + | |
| 75 | 92 | } | ... | ... |
src/main/java/com/bsth/service/calc/CalcWaybillService.java
| ... | ... | @@ -41,5 +41,6 @@ public interface CalcWaybillService extends BaseService<CalcWaybill, Integer> { |
| 41 | 41 | List<Map<String, Object>> getLineMileage(String gsdm, String fgsdm, String line, String date, String date2, String xlName, String zt, String by, String type); |
| 42 | 42 | |
| 43 | 43 | List<Map<String, Object>> getBusMileage(String line, String date, String date2, String xlName, String zt, String by, String type); |
| 44 | - | |
| 44 | + | |
| 45 | + List<List<String>> calcDetailMonthly(Map<String, Object> map); | |
| 45 | 46 | } | ... | ... |
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
| ... | ... | @@ -2,23 +2,16 @@ package com.bsth.service.calc.impl; |
| 2 | 2 | |
| 3 | 3 | import java.sql.ResultSet; |
| 4 | 4 | import java.sql.SQLException; |
| 5 | +import java.text.DecimalFormat; | |
| 5 | 6 | import java.text.ParseException; |
| 6 | 7 | import java.text.SimpleDateFormat; |
| 7 | -import java.util.ArrayList; | |
| 8 | -import java.util.Calendar; | |
| 9 | -import java.util.Collections; | |
| 10 | -import java.util.Comparator; | |
| 11 | -import java.util.Date; | |
| 12 | -import java.util.HashMap; | |
| 13 | -import java.util.HashSet; | |
| 14 | -import java.util.Iterator; | |
| 15 | -import java.util.List; | |
| 16 | -import java.util.Map; | |
| 8 | +import java.util.*; | |
| 17 | 9 | import java.util.Map.Entry; |
| 18 | -import java.util.Set; | |
| 19 | 10 | |
| 20 | 11 | import javax.transaction.Transactional; |
| 21 | 12 | |
| 13 | +import com.alibaba.fastjson.JSON; | |
| 14 | +import com.alibaba.fastjson.JSONArray; | |
| 22 | 15 | import com.bsth.common.ResponseCode; |
| 23 | 16 | import com.bsth.data.BasicData; |
| 24 | 17 | import com.bsth.entity.Line; |
| ... | ... | @@ -27,6 +20,10 @@ import com.bsth.entity.calc.CalcInterval; |
| 27 | 20 | import com.bsth.entity.calc.CalcLineMileage; |
| 28 | 21 | import com.bsth.entity.calc.CalcStatistics; |
| 29 | 22 | import com.bsth.entity.calc.CalcWaybill; |
| 23 | +import com.bsth.entity.calc.CalcWaybillDetail; | |
| 24 | +import com.bsth.entity.mcy_forms.Singledata; | |
| 25 | +import com.bsth.entity.oil.Dlb; | |
| 26 | +import com.bsth.entity.oil.Ylb; | |
| 30 | 27 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 31 | 28 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 32 | 29 | import com.bsth.entity.sys.Interval; |
| ... | ... | @@ -51,8 +48,10 @@ import com.github.stuxuhai.jpinyin.PinyinException; |
| 51 | 48 | import com.github.stuxuhai.jpinyin.PinyinFormat; |
| 52 | 49 | import com.github.stuxuhai.jpinyin.PinyinHelper; |
| 53 | 50 | |
| 51 | +import org.apache.commons.lang3.StringUtils; | |
| 54 | 52 | import org.slf4j.Logger; |
| 55 | 53 | import org.slf4j.LoggerFactory; |
| 54 | +import org.springframework.beans.BeanUtils; | |
| 56 | 55 | import org.springframework.beans.factory.annotation.Autowired; |
| 57 | 56 | import org.springframework.jdbc.core.JdbcTemplate; |
| 58 | 57 | import org.springframework.jdbc.core.RowMapper; |
| ... | ... | @@ -75,7 +74,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 75 | 74 | |
| 76 | 75 | @Autowired |
| 77 | 76 | private CalcBusMileageRepository calcBusMileageRepository; |
| 78 | - | |
| 77 | + | |
| 79 | 78 | @Autowired |
| 80 | 79 | private CalcToolService calcToolService; |
| 81 | 80 | |
| ... | ... | @@ -1809,6 +1808,593 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 1809 | 1808 | return temp; |
| 1810 | 1809 | } |
| 1811 | 1810 | |
| 1811 | + @Override | |
| 1812 | + public List<List<String>> calcDetailMonthly(Map<String, Object> map) { | |
| 1813 | + String gsdm=""; | |
| 1814 | + if(map.get("gsdm")!=null){ | |
| 1815 | + gsdm=map.get("gsdm").toString().trim(); | |
| 1816 | + } | |
| 1817 | + String fgsdm=""; | |
| 1818 | + if(map.get("fgsdm")!=null){ | |
| 1819 | + fgsdm=map.get("fgsdm").toString().trim(); | |
| 1820 | + } | |
| 1821 | + String line=""; | |
| 1822 | + if(map.get("lineCode")!=null){ | |
| 1823 | + line=map.get("lineCode").toString().trim(); | |
| 1824 | + } | |
| 1825 | + String startDate=""; | |
| 1826 | + if(map.get("startDate")!=null){ | |
| 1827 | + startDate=map.get("startDate").toString().trim(); | |
| 1828 | + } | |
| 1829 | + String endDate=""; | |
| 1830 | + if(map.get("endDate")!=null){ | |
| 1831 | + endDate=map.get("endDate").toString().trim(); | |
| 1832 | + } | |
| 1833 | + String xlName=""; | |
| 1834 | + if(map.get("xlName")!=null){ | |
| 1835 | + xlName=map.get("xlName").toString().trim(); | |
| 1836 | + } | |
| 1837 | + String type=""; | |
| 1838 | + if(map.get("type")!=null){ | |
| 1839 | + type=map.get("type").toString().trim(); | |
| 1840 | + } | |
| 1841 | + String statisticalObj=""; | |
| 1842 | + if(map.get("statisticalObj")!=null){ | |
| 1843 | + statisticalObj=map.get("statisticalObj").toString().trim(); | |
| 1844 | + } | |
| 1845 | + String itemDetails=""; | |
| 1846 | + if(map.get("itemDetails")!=null){ | |
| 1847 | + itemDetails=map.get("itemDetails").toString().trim(); | |
| 1848 | + } | |
| 1849 | + String timeType=map.get("timeType").toString().trim(); | |
| 1850 | + | |
| 1851 | + List<List<String>> resList = new ArrayList<>(); | |
| 1852 | + List<CalcWaybill> list = new ArrayList<CalcWaybill>(); | |
| 1853 | +// List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 1854 | + // 右边可变天数 | |
| 1855 | + TreeMap<String, List<CalcWaybillDetail>> keyMapList = new TreeMap<String, List<CalcWaybillDetail>>(); | |
| 1856 | + // 左边固定列 | |
| 1857 | + TreeMap<String, CalcWaybillDetail> keyMap = new TreeMap<String, CalcWaybillDetail>(); | |
| 1858 | + | |
| 1859 | + List<Map<String, CalcWaybillDetail>> dayList = new ArrayList<>(); | |
| 1860 | + int day = 0, day2 = 0; | |
| 1861 | + if("m".equals(timeType)){ | |
| 1862 | + day = Integer.parseInt(startDate.substring(8,10)); | |
| 1863 | + day2 = Integer.parseInt(endDate.substring(8,10)); | |
| 1864 | + for(int i=day; i<=day2; i++){ | |
| 1865 | + Map<String, CalcWaybillDetail> daym = new HashMap<>(); | |
| 1866 | + daym.put(startDate.substring(0,7)+"-"+(i<10?"0"+i:i),this.initCalcWaybillDetail()); | |
| 1867 | + dayList.add(daym); | |
| 1868 | + } | |
| 1869 | + } else if("y".equals(timeType)){ | |
| 1870 | + day = Integer.parseInt(startDate.substring(5,7)); | |
| 1871 | + day2 = Integer.parseInt(endDate.substring(5,7)); | |
| 1872 | + for(int i=day; i<=day2; i++){ | |
| 1873 | + Map<String, CalcWaybillDetail> daym = new HashMap<>(); | |
| 1874 | + daym.put(startDate.substring(0,7),this.initCalcWaybillDetail()); | |
| 1875 | + dayList.add(daym); | |
| 1876 | + } | |
| 1877 | + startDate += "-01"; | |
| 1878 | + endDate += "-31"; | |
| 1879 | + } | |
| 1880 | + | |
| 1881 | + int flag = 0; | |
| 1882 | + if("jsy".equals(statisticalObj)){ | |
| 1883 | + flag = 1; | |
| 1884 | + list = calcRepository.scheduleByJsy2(line, startDate, endDate, gsdm, fgsdm); | |
| 1885 | + } else if("cwy".equals(statisticalObj)){ | |
| 1886 | + flag = 2; | |
| 1887 | + list = calcRepository.scheduleBySpy2(line, startDate, endDate, gsdm, fgsdm); | |
| 1888 | + } else if("cl".equals(statisticalObj)){ | |
| 1889 | + flag = 3; | |
| 1890 | + list = calcRepository.scheduleByZbh2(line, startDate, endDate, gsdm, fgsdm); | |
| 1891 | + } else if("xl".equals(statisticalObj)){ | |
| 1892 | + flag = 4; | |
| 1893 | + list = calcRepository.scheduleByDateAndLineTjPx(line,startDate,endDate,gsdm,fgsdm); | |
| 1894 | + /*if(line.equals("")){ | |
| 1895 | + //查询所有线路 | |
| 1896 | + }else{ | |
| 1897 | + //查询单条线路 | |
| 1898 | + list = calcRepository.scheduleByDateAndLineTjPx2(line,startDate,endDate); | |
| 1899 | + }*/ | |
| 1900 | + } | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + // List类转换 | |
| 1904 | + final List<CalcWaybillDetail> listNew = JSONArray.parseArray(JSON.toJSONString(list), CalcWaybillDetail.class); | |
| 1905 | + | |
| 1906 | + if(listNew.size() <= 0){ | |
| 1907 | + return resList; | |
| 1908 | + } | |
| 1909 | + Map<String,Ylb> ylbMap = new HashMap<>(); | |
| 1910 | + Map<String,Ylb> ylbCLMap = new HashMap<>(); | |
| 1911 | + Map<String,Dlb> dlbMap = new HashMap<>(); | |
| 1912 | + Map<String,Dlb> dlbCLMap = new HashMap<>(); | |
| 1913 | + | |
| 1914 | + final SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); | |
| 1915 | + | |
| 1916 | + // 只有在选择 车辆,驾驶员查询时才有 | |
| 1917 | + // 把油量和电量数据查出来,封装成Map,计算时直接取 | |
| 1918 | + if(flag != 2 ){ | |
| 1919 | + String linesql=""; | |
| 1920 | + if(!line.equals("")){ | |
| 1921 | + linesql +=" and xlbm ='"+line+"' "; | |
| 1922 | + } | |
| 1923 | + if(!gsdm.equals("")){ | |
| 1924 | + linesql +=" and ssgsdm ='"+gsdm+"' "; | |
| 1925 | + } | |
| 1926 | + if(!fgsdm.equals("")){ | |
| 1927 | + linesql +=" and fgsdm ='"+fgsdm+"' "; | |
| 1928 | + } | |
| 1929 | + String ylsql="SELECT * FROM bsth_c_ylb" | |
| 1930 | +// String ylsql="SELECT id,xlbm,nbbm,jsy,jzl,czyl,jzyl,yh,sh,fgsdm FROM bsth_c_ylb" | |
| 1931 | + + " WHERE rq >= '"+startDate+"' and rq <= '"+endDate+"' " | |
| 1932 | + + linesql; | |
| 1933 | + String dlSal= " SELECT * FROM bsth_c_dlb" | |
| 1934 | +// String dlSal= " SELECT id,xlbm,nbbm,jsy,cdl,czcd,jzcd,hd,sh,fgsdm FROM bsth_c_dlb" | |
| 1935 | + + " WHERE rq >= '"+startDate+"' and rq <= '"+endDate+"' " | |
| 1936 | + + linesql; | |
| 1937 | + List<Ylb> ylbList = jdbcTemplate.query(ylsql, new RowMapper<Ylb>() { | |
| 1938 | + @Override | |
| 1939 | + public Ylb mapRow(ResultSet arg0, int arg1) throws SQLException{ | |
| 1940 | + Ylb ylb = new Ylb(); | |
| 1941 | + Date rq = null; | |
| 1942 | + try{ | |
| 1943 | + rq = ft.parse(arg0.getString("rq")); | |
| 1944 | + } catch (ParseException e){ | |
| 1945 | + logger.error(e.toString(),e); | |
| 1946 | + } | |
| 1947 | +// Date rq = ft.parse(arg0.getString("rq")); | |
| 1948 | + ylb.setXlbm(arg0.getString("xlbm")); | |
| 1949 | + ylb.setJsy(arg0.getString("jsy")); | |
| 1950 | + ylb.setJname(arg0.getString("jname")); | |
| 1951 | + ylb.setNbbm(arg0.getString("nbbm")); | |
| 1952 | + ylb.setZlc(Double.parseDouble(arg0.getString("zlc"))); | |
| 1953 | + ylb.setJzl(Double.parseDouble(arg0.getString("jzl"))); | |
| 1954 | + ylb.setJzyl(Double.parseDouble(arg0.getString("jzyl"))); | |
| 1955 | + ylb.setCzyl(Double.parseDouble(arg0.getString("czyl"))); | |
| 1956 | + ylb.setYh(Double.parseDouble(arg0.getString("yh"))); | |
| 1957 | + ylb.setSh(Double.parseDouble(arg0.getString("sh"))); | |
| 1958 | + ylb.setRylx(arg0.getString("rylx")); | |
| 1959 | + ylb.setFgsdm(arg0.getString("fgsdm")); | |
| 1960 | + ylb.setRq(rq); | |
| 1961 | + return ylb; | |
| 1962 | + } | |
| 1963 | + }); | |
| 1964 | + List<Dlb> dlbList = jdbcTemplate.query(dlSal, new RowMapper<Dlb>() { | |
| 1965 | + @Override | |
| 1966 | + public Dlb mapRow(ResultSet arg0, int arg1) throws SQLException { | |
| 1967 | + Dlb dlb = new Dlb();Date rq = null; | |
| 1968 | + try{ | |
| 1969 | + rq = ft.parse(arg0.getString("rq")); | |
| 1970 | + } catch (ParseException e){ | |
| 1971 | + logger.error(e.toString(),e); | |
| 1972 | + } | |
| 1973 | + dlb.setXlbm(arg0.getString("xlbm")); | |
| 1974 | + dlb.setJsy(arg0.getString("jsy")); | |
| 1975 | + dlb.setJname(arg0.getString("jname")); | |
| 1976 | + dlb.setNbbm(arg0.getString("nbbm")); | |
| 1977 | + dlb.setZlc(Double.parseDouble(arg0.getString("zlc"))); | |
| 1978 | + dlb.setCdl(Double.parseDouble(arg0.getString("cdl"))); | |
| 1979 | + dlb.setJzcd(Double.parseDouble(arg0.getString("jzcd"))); | |
| 1980 | + dlb.setCzcd(Double.parseDouble(arg0.getString("czcd"))); | |
| 1981 | + dlb.setHd(Double.parseDouble(arg0.getString("hd"))); | |
| 1982 | + dlb.setSh(Double.parseDouble(arg0.getString("sh"))); | |
| 1983 | + dlb.setFgsdm(arg0.getString("fgsdm")); | |
| 1984 | + dlb.setRq(rq); | |
| 1985 | + return dlb; | |
| 1986 | + } | |
| 1987 | + }); | |
| 1988 | + | |
| 1989 | + for (Ylb y:ylbList) { | |
| 1990 | + if(ylbMap.containsKey(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getNbbm())){ | |
| 1991 | + Ylb yo = ylbMap.get(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getNbbm()); | |
| 1992 | + yo.setZlc(Arith.add(yo.getZlc(),y.getZlc())); | |
| 1993 | + yo.setCzyl(Arith.add(yo.getCzyl(),y.getCzyl())); | |
| 1994 | + yo.setJzyl(Arith.add(yo.getJzyl(),y.getJzyl())); | |
| 1995 | + yo.setJzl(Arith.add(yo.getJzl(),y.getJzl())); | |
| 1996 | + yo.setYh(Arith.add(yo.getYh(),y.getYh())); | |
| 1997 | + } else | |
| 1998 | + ylbMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getNbbm(),y); | |
| 1999 | + | |
| 2000 | +// ylbMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getJname()+"_"+y.getNbbm(),y); | |
| 2001 | +// ylbCLMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getNbbm(),y); | |
| 2002 | + } | |
| 2003 | + for (Dlb d:dlbList) { | |
| 2004 | + if(dlbMap.containsKey(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm())){ | |
| 2005 | + Dlb dold = dlbMap.get(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm()); | |
| 2006 | + dold.setZlc(Arith.add(dold.getZlc(),d.getZlc())); | |
| 2007 | + dold.setHd(Arith.add(dold.getHd(),d.getHd())); | |
| 2008 | + dold.setCzcd(Arith.add(dold.getCzcd(),d.getCzcd())); | |
| 2009 | + dold.setJzcd(Arith.add(dold.getJzcd(),d.getJzcd())); | |
| 2010 | + dold.setCdl(Arith.add(dold.getCdl(),d.getCdl())); | |
| 2011 | + dold.setHd(Arith.add(dold.getHd(),d.getHd())); | |
| 2012 | + } else | |
| 2013 | + dlbMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm(),d); | |
| 2014 | +// dlbMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getJname()+"_"+d.getNbbm(),d); | |
| 2015 | +// dlbCLMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getNbbm(),d); | |
| 2016 | + } | |
| 2017 | + } | |
| 2018 | + | |
| 2019 | + CalcWaybillDetail zjCalc = this.initCalcWaybillDetail(); | |
| 2020 | + zjCalc.setjName("合计"); | |
| 2021 | + // 横向数据的第几天下标 | |
| 2022 | + int dayIndex = 0; | |
| 2023 | + int dayIndexPrev = -1; | |
| 2024 | + CalcWaybillDetail cwNext = null; | |
| 2025 | + // 报表纵向列数据生成 | |
| 2026 | + for (int i = 0; listNew.size() > i; i++) { | |
| 2027 | + CalcWaybillDetail cw = listNew.get(i); | |
| 2028 | + | |
| 2029 | + if(i<listNew.size()-1){ | |
| 2030 | + cwNext = listNew.get(i+1); | |
| 2031 | + } | |
| 2032 | + String xl = cw.getXl(); | |
| 2033 | + String jsy = cw.getjGh(); | |
| 2034 | + String cwy = cw.getsGh(); | |
| 2035 | + String cl = cw.getCl(); | |
| 2036 | + | |
| 2037 | + String key = "",keyNext = ""; | |
| 2038 | + if(flag == 1){ | |
| 2039 | + if(cw.getjGh() != null && cw.getjName() != null) | |
| 2040 | + key += cw.getjGh() + "/" + cw.getjName(); | |
| 2041 | + if(cwNext.getjGh() != null && cwNext.getjName() != null) | |
| 2042 | + keyNext += cwNext.getjGh() + "/" + cwNext.getjName(); | |
| 2043 | + } else if(flag == 2){ | |
| 2044 | + if(cw.getsGh() != null && cw.getsName() != null) | |
| 2045 | + key += cw.getsGh() + "/" + cw.getsName(); | |
| 2046 | + if(cwNext.getsGh() != null && cwNext.getsName() != null) | |
| 2047 | + keyNext += cwNext.getsGh() + "/" + cwNext.getsName(); | |
| 2048 | + } else if(flag == 3){ | |
| 2049 | + if(cw.getCl() != null) | |
| 2050 | + key += cw.getCl(); | |
| 2051 | + if(cwNext.getCl() != null) | |
| 2052 | + keyNext += cwNext.getCl(); | |
| 2053 | + } | |
| 2054 | + key = cw.getXl() + "/" + key; | |
| 2055 | + keyNext = cwNext.getXl() + "/" + keyNext; | |
| 2056 | + CalcWaybillDetail calc = new CalcWaybillDetail(); | |
| 2057 | + List<CalcWaybillDetail> calcList = new ArrayList<>(); | |
| 2058 | + // 是否一行数据的第一个、生成key,calc为刚添加,不去和cw相加 | |
| 2059 | + boolean ifFirst = false; | |
| 2060 | + if(keyMapList.containsKey(key)){ | |
| 2061 | + calc = keyMap.get(key); | |
| 2062 | + calcList = keyMapList.get(key); | |
| 2063 | + } else { | |
| 2064 | +// calc = this.initCalcWaybillDetail(); | |
| 2065 | + // 深度拷贝对象 | |
| 2066 | + BeanUtils.copyProperties(cw,calc); | |
| 2067 | + keyMap.put(key, calc); | |
| 2068 | + dayIndex = 0; | |
| 2069 | + ifFirst = true; | |
| 2070 | + } | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + Ylb y = new Ylb(); | |
| 2074 | + Dlb d = new Dlb(); | |
| 2075 | + // 统计类型不同统计的左边列不同 | |
| 2076 | + if(flag != 2){ | |
| 2077 | + // 取了之后删除,防止重复取,应为添加的时候已经合并了 | |
| 2078 | + y = ylbMap.get(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getjGh()+"_"+cw.getCl()); | |
| 2079 | + ylbMap.remove(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getjGh()+"_"+cw.getCl()); | |
| 2080 | + d = dlbMap.get(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getjGh()+"_"+cw.getCl()); | |
| 2081 | + dlbMap.remove(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getjGh()+"_"+cw.getCl()); | |
| 2082 | +// y = ylbMap.get(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getjGh()+"_"+cw.getjName()+"_"+cw.getCl()); | |
| 2083 | +// d = dlbMap.get(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getjGh()+"_"+cw.getjName()+"_"+cw.getCl()); | |
| 2084 | + if(y != null){ | |
| 2085 | + cw.setZlc(y.getZlc()); | |
| 2086 | + cw.setYh(y.getYh()); | |
| 2087 | + cw.setJzl(y.getJzl()); | |
| 2088 | + if("0".equals(y.getRylx())){ | |
| 2089 | + cw.setJzl0(y.getJzl()); | |
| 2090 | + }else if("1".equals(y.getRylx())){ | |
| 2091 | + cw.setJzl10(y.getJzl()); | |
| 2092 | + } | |
| 2093 | + cw.setJzyl(y.getJzyl()); | |
| 2094 | + cw.setCzyl(y.getCzyl()); | |
| 2095 | + cw.setRylx(y.getRylx()); | |
| 2096 | + cw.setBglyh((y.getZlc()==0? 0:100*y.getYh()/y.getZlc())); | |
| 2097 | + } | |
| 2098 | + if(d != null) { | |
| 2099 | + cw.setZlc(d.getZlc()); | |
| 2100 | + cw.setHd(d.getHd()); | |
| 2101 | + cw.setJzcd(d.getJzcd()); | |
| 2102 | + cw.setCzcd(d.getCzcd()); | |
| 2103 | + cw.setCdl(d.getCdl()); | |
| 2104 | + cw.setBglyh((d.getZlc()==0? 0:100*d.getHd()/d.getZlc())); | |
| 2105 | + } | |
| 2106 | + | |
| 2107 | + }/* else if(flag == 3){ | |
| 2108 | + y = ylbCLMap.get(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getCl()); | |
| 2109 | + d = dlbCLMap.get(cw.getRq().getTime()+"_"+cw.getXl()+"_"+cw.getCl()); | |
| 2110 | + }*/ | |
| 2111 | + | |
| 2112 | + CalcWaybillDetail dayc = null; | |
| 2113 | + if("m".equals(timeType)){ | |
| 2114 | + while (!dayList.get(dayIndex).containsKey(cw.getRqStr())){ | |
| 2115 | + calcList.add(new CalcWaybillDetail()); | |
| 2116 | + dayIndex++; | |
| 2117 | + } | |
| 2118 | + dayc = dayList.get(dayIndex).get(cw.getRqStr()); | |
| 2119 | + } else if("y".equals(timeType)){ | |
| 2120 | + while (!dayList.get(dayIndex).containsKey(cw.getRqStr().substring(0,7))){ | |
| 2121 | + calcList.add(new CalcWaybillDetail()); | |
| 2122 | + dayIndex++; | |
| 2123 | + } | |
| 2124 | + dayc = dayList.get(dayIndex).get(cw.getRqStr().substring(0,7)); | |
| 2125 | + } | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + // 天数相加 | |
| 2129 | + this.summation(dayc, cw); | |
| 2130 | + // 左边固定列数据相加 | |
| 2131 | + if(!ifFirst) | |
| 2132 | + this.summation(calc, cw); | |
| 2133 | + // 左边合计相加 | |
| 2134 | + this.summation(zjCalc, cw); | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + if(dayIndexPrev == dayIndex){ | |
| 2138 | + CalcWaybillDetail cwPrev = calcList.get(dayIndex); | |
| 2139 | + this.summation(cwPrev, cw); | |
| 2140 | + } else { | |
| 2141 | + CalcWaybillDetail cwd = new CalcWaybillDetail(); | |
| 2142 | + // 深度拷贝对象 | |
| 2143 | + BeanUtils.copyProperties(cw,cwd); | |
| 2144 | + calcList.add(cwd); | |
| 2145 | + calc.setTs(calc.getTs()+1); | |
| 2146 | + zjCalc.setTs(zjCalc.getTs()+1); | |
| 2147 | + } | |
| 2148 | + | |
| 2149 | + // 把下标 | |
| 2150 | + dayIndexPrev = dayIndex; | |
| 2151 | + | |
| 2152 | +// if(cw.getjGh().equals("007951") && cw.getXlName().equals("浦东40路")){ | |
| 2153 | +// System.out.println(); | |
| 2154 | +// } | |
| 2155 | + /*if(cw.getCl().equals("W0F-058") || cw.getCl().equals("W2F-051") || cw.getCl().equals("S2E-029") || cw.getCl().equals("W1G-058")){ | |
| 2156 | + System.out.println(); | |
| 2157 | + }*/ | |
| 2158 | + // timeType 为m 月报表时,日期不一样就换列,为y 年报表是,月份不一样换列 | |
| 2159 | + if("m".equals(timeType) && cwNext != null && key.equals(keyNext) && !cw.getRqStr().equals(cwNext.getRqStr())){ | |
| 2160 | + dayIndex++; | |
| 2161 | + } else if("y".equals(timeType) && cwNext != null && key.equals(keyNext) && !cw.getRqStr().substring(0,7).equals(cwNext.getRqStr().substring(0,7))){ | |
| 2162 | + dayIndex++; | |
| 2163 | + } else if(!key.equals(keyNext)){ | |
| 2164 | + // 满数据的不用补空格 | |
| 2165 | + while (dayList.size() > dayIndex+1){ | |
| 2166 | + calcList.add(new CalcWaybillDetail()); | |
| 2167 | + dayIndex++; | |
| 2168 | + } | |
| 2169 | + dayIndexPrev = -1; | |
| 2170 | +// dayIndexPrev = dayIndex = 0; | |
| 2171 | + } | |
| 2172 | + // 右边可变列添加数据 | |
| 2173 | + keyMapList.put(key,calcList); | |
| 2174 | + } | |
| 2175 | + | |
| 2176 | + // 表头和数据 | |
| 2177 | + Iterator iter = keyMap.entrySet().iterator(); | |
| 2178 | + | |
| 2179 | + List<String> list1 = new ArrayList<>(); | |
| 2180 | + list1.add("序号"); | |
| 2181 | + list1.add("所属公司"); | |
| 2182 | + list1.add("线路"); | |
| 2183 | + if(flag==1 ||flag==2 ){ | |
| 2184 | + list1.add("工号"); | |
| 2185 | + list1.add("姓名"); | |
| 2186 | + } else if(flag==3){ | |
| 2187 | + list1.add("自编号"); | |
| 2188 | + list1.add("车牌号"); | |
| 2189 | + } | |
| 2190 | + list1.add("计划公里"); | |
| 2191 | + list1.add("总公里"); | |
| 2192 | + list1.add("空驶公里"); | |
| 2193 | + list1.add("临加公里"); | |
| 2194 | + list1.add("烂班公里"); | |
| 2195 | + list1.add("m".equals(timeType)?"天数":"月数"); | |
| 2196 | + for(int i=day; i<=day2; i++){ | |
| 2197 | + list1.add((i<10?"0"+i:i)+("m".equals(timeType)?"日":"月")); | |
| 2198 | + } | |
| 2199 | + resList.add(list1); | |
| 2200 | + | |
| 2201 | + int i=1; | |
| 2202 | + | |
| 2203 | + DecimalFormat df = new DecimalFormat("0.00");//格式化小数 | |
| 2204 | + while (iter.hasNext()) { | |
| 2205 | +// List list = new ArrayList(); | |
| 2206 | + | |
| 2207 | + Map.Entry entry = (Map.Entry) iter.next(); | |
| 2208 | + // 获取key | |
| 2209 | + String key = (String) entry.getKey(); | |
| 2210 | + // 获取value | |
| 2211 | + CalcWaybillDetail c = (CalcWaybillDetail) entry.getValue(); | |
| 2212 | + | |
| 2213 | + List<CalcWaybillDetail> cList = keyMapList.get(key); | |
| 2214 | + | |
| 2215 | + List<String> listStr = new ArrayList<>(); | |
| 2216 | + listStr.add(i+""); | |
| 2217 | + i++; | |
| 2218 | + listStr.add(c.getFgsname()); | |
| 2219 | + listStr.add(c.getXlName()); | |
| 2220 | + if("jsy".equals(statisticalObj)){ | |
| 2221 | + listStr.add(c.getjGh()); | |
| 2222 | + listStr.add(c.getjName()); | |
| 2223 | + } else if("cwy".equals(statisticalObj)){ | |
| 2224 | + listStr.add(c.getsGh()); | |
| 2225 | + listStr.add(c.getsName()); | |
| 2226 | + } else if("cl".equals(statisticalObj)){ | |
| 2227 | + listStr.add(c.getCl()); | |
| 2228 | + listStr.add(BasicData.nbbmCompanyPlateMap.get(c.getCl())+""); | |
| 2229 | + } else if("xl".equals(statisticalObj)){ | |
| 2230 | + | |
| 2231 | + } | |
| 2232 | + listStr.add(df.format(c.getJhyylc()+c.getJhfyylc())); | |
| 2233 | + listStr.add(df.format(c.getSjyylc()+c.getSjfyylc()+c.getLjyylc()+c.getLjfyylc())); | |
| 2234 | +// listStr.add(df.format(c.getSjyylc()+c.getLjyylc())); | |
| 2235 | + listStr.add(df.format(c.getSjfyylc()+c.getLjfyylc())); | |
| 2236 | + listStr.add(df.format(c.getLjyylc()+c.getLjfyylc())); | |
| 2237 | + listStr.add(df.format(c.getLblc())); | |
| 2238 | + listStr.add(c.getTs()+""); | |
| 2239 | + // DecimalFormat df = new DecimalFormat("0.00");//格式化小数 | |
| 2240 | + for (CalcWaybillDetail c1:cList) { | |
| 2241 | + if(StringUtils.isEmpty(c1.getXl())) { | |
| 2242 | + listStr.add(""); | |
| 2243 | + } else{ | |
| 2244 | + if("jzlAll".equals(itemDetails)){ | |
| 2245 | + listStr.add(df.format(c1.getJzl())); | |
| 2246 | + }else if("jzl0".equals(itemDetails)){ | |
| 2247 | + listStr.add(df.format(c1.getJzl0())); | |
| 2248 | + } else if("jzl-10".equals(itemDetails)){ | |
| 2249 | + listStr.add(df.format(c1.getJzl10())); | |
| 2250 | + } else if("yhl".equals(itemDetails)){ | |
| 2251 | + listStr.add(df.format(c1.getYh())); | |
| 2252 | + } else if("jccy".equals(itemDetails)){ | |
| 2253 | + listStr.add(df.format(c1.getJzyl())); | |
| 2254 | + } else if("cccy".equals(itemDetails)){ | |
| 2255 | + listStr.add(df.format(c1.getCzyl())); | |
| 2256 | + } else if("bglyh".equals(itemDetails)){ | |
| 2257 | + listStr.add(df.format(c1.getBglyh())); | |
| 2258 | + } else if("dh".equals(itemDetails)){ | |
| 2259 | + listStr.add(df.format(c1.getHd())); | |
| 2260 | + } else if("cdl".equals(itemDetails)){ | |
| 2261 | + listStr.add(df.format(c1.getCdl())); | |
| 2262 | + } else if("cccd".equals(itemDetails)){ | |
| 2263 | + listStr.add(df.format(c1.getCzcd())); | |
| 2264 | + } else if("jccd".equals(itemDetails)){ | |
| 2265 | + listStr.add(df.format(c1.getJzcd())); | |
| 2266 | + } else if("bgldh".equals(itemDetails)){ | |
| 2267 | + listStr.add(df.format(c1.getBglhd())); | |
| 2268 | + } else if("zgl".equals(itemDetails)){ | |
| 2269 | + listStr.add(df.format((c1.getSjyylc()+c1.getSjfyylc()+c1.getLjfyylc()+c1.getLjyylc()))); | |
| 2270 | + } else if("jhgl".equals(itemDetails)){ | |
| 2271 | + listStr.add(df.format(c1.getJhyylc()+c1.getJhfyylc())); | |
| 2272 | + } else if("sjbc".equals(itemDetails)){ | |
| 2273 | + listStr.add(c1.getSjyybc()+c1.getSjfyybc()+""); | |
| 2274 | + } else if("jhbc".equals(itemDetails)){ | |
| 2275 | + listStr.add(c1.getJhyybc()+c1.getJhfyybc()+""); | |
| 2276 | + } | |
| 2277 | + } | |
| 2278 | + } | |
| 2279 | + resList.add(listStr); | |
| 2280 | + } | |
| 2281 | + | |
| 2282 | + // 合计列 | |
| 2283 | + List<String> listEnd = new ArrayList<>(); | |
| 2284 | + listEnd.add("合计"); | |
| 2285 | + listEnd.add(df.format(zjCalc.getJhyylc()+zjCalc.getJhfyylc())); | |
| 2286 | + listEnd.add(df.format(zjCalc.getSjfyylc()+zjCalc.getSjyylc()+zjCalc.getLjyylc()+zjCalc.getLjfyylc()));//总公里 | |
| 2287 | +// listEnd.add(df.format(zjCalc.getSjyylc()+zjCalc.getLjyylc()));//营运 | |
| 2288 | + listEnd.add(df.format(zjCalc.getSjfyylc()+zjCalc.getLjfyylc())); | |
| 2289 | + listEnd.add(df.format(zjCalc.getLjfyylc()+zjCalc.getLjyylc())); | |
| 2290 | + listEnd.add(df.format(zjCalc.getLblc())); | |
| 2291 | + listEnd.add(zjCalc.getTs()+""); | |
| 2292 | + for (Map<String, CalcWaybillDetail> cmap:dayList) { | |
| 2293 | + for (Map.Entry<String, CalcWaybillDetail> cw : cmap.entrySet()) { | |
| 2294 | +// System.out.println("key = " + cw.getKey() + ", value = " + cw.getValue()); | |
| 2295 | + CalcWaybillDetail c1 = cw.getValue(); | |
| 2296 | + if("jzlAll".equals(itemDetails)){ | |
| 2297 | + listEnd.add(df.format(c1.getJzl())); | |
| 2298 | + } else if("jzl0".equals(itemDetails)){ | |
| 2299 | + listEnd.add(df.format(c1.getJzl0())); | |
| 2300 | + } else if("jzl-10".equals(itemDetails)){ | |
| 2301 | + listEnd.add(df.format(c1.getJzl10())); | |
| 2302 | + } else if("yhl".equals(itemDetails)){ | |
| 2303 | + listEnd.add(df.format(c1.getYh())); | |
| 2304 | + } else if("jccy".equals(itemDetails)){ | |
| 2305 | + listEnd.add(df.format(c1.getJzyl())); | |
| 2306 | + } else if("cccy".equals(itemDetails)){ | |
| 2307 | + listEnd.add(df.format(c1.getCzyl())); | |
| 2308 | + } else if("bglyh".equals(itemDetails)){ | |
| 2309 | + listEnd.add(df.format(c1.getBglyh())); | |
| 2310 | + } else if("dh".equals(itemDetails)){ | |
| 2311 | + listEnd.add(df.format(c1.getHd())); | |
| 2312 | + } else if("cdl".equals(itemDetails)){ | |
| 2313 | + listEnd.add(df.format(c1.getCdl())); | |
| 2314 | + } else if("cccd".equals(itemDetails)){ | |
| 2315 | + listEnd.add(df.format(c1.getCzcd())); | |
| 2316 | + } else if("jccd".equals(itemDetails)){ | |
| 2317 | + listEnd.add(df.format(c1.getJzcd())); | |
| 2318 | + } else if("bgldh".equals(itemDetails)){ | |
| 2319 | + listEnd.add(df.format(c1.getBglhd())); | |
| 2320 | + } else if("zgl".equals(itemDetails)){ | |
| 2321 | + listEnd.add((df.format(c1.getSjyylc()+c1.getSjfyylc()+c1.getLjfyylc()+c1.getLjyylc()))); | |
| 2322 | + } else if("jhgl".equals(itemDetails)){ | |
| 2323 | + listEnd.add((df.format(c1.getJhyylc()+c1.getJhfyylc()))); | |
| 2324 | + } else if("sjbc".equals(itemDetails)){ | |
| 2325 | + listEnd.add(c1.getSjyybc()+c1.getSjfyybc()+""); | |
| 2326 | + } else if("jhbc".equals(itemDetails)){ | |
| 2327 | + listEnd.add((c1.getJhyybc()+c1.getJhfyybc())+""); | |
| 2328 | + | |
| 2329 | + } | |
| 2330 | + } | |
| 2331 | + } | |
| 2332 | + resList.add(listEnd); | |
| 2333 | + | |
| 2334 | + return resList; | |
| 2335 | + } | |
| 2336 | + | |
| 2337 | + public CalcWaybillDetail initCalcWaybillDetail(){ | |
| 2338 | + CalcWaybillDetail calc = new CalcWaybillDetail(); | |
| 2339 | + calc.setJhyybc(0); | |
| 2340 | + calc.setJhyylc(0d); | |
| 2341 | + calc.setJhfyybc(0); | |
| 2342 | + calc.setJhfyylc(0d); | |
| 2343 | + calc.setSjyybc(0); | |
| 2344 | + calc.setSjyylc(0d); | |
| 2345 | + calc.setSjfyybc(0); | |
| 2346 | + calc.setSjfyylc(0d); | |
| 2347 | + calc.setLbbc(0); | |
| 2348 | + calc.setLblc(0d); | |
| 2349 | + calc.setLjbc(0); | |
| 2350 | + calc.setLjyylc(0d); | |
| 2351 | + calc.setZlc(0d); | |
| 2352 | + calc.setCzyl(0d); | |
| 2353 | + calc.setJzyl(0d); | |
| 2354 | + calc.setJzl(0d); | |
| 2355 | + calc.setJzl0(0d); | |
| 2356 | + calc.setJzl10(0d); | |
| 2357 | + calc.setYh(0d); | |
| 2358 | + calc.setCzcd(0d); | |
| 2359 | + calc.setJzcd(0d); | |
| 2360 | + calc.setCdl(0d); | |
| 2361 | + calc.setHd(0d); | |
| 2362 | + calc.setTs(0); | |
| 2363 | + return calc; | |
| 2364 | + } | |
| 2365 | + | |
| 2366 | + public CalcWaybillDetail summation(CalcWaybillDetail c1, CalcWaybillDetail c2){ | |
| 2367 | + c1.setJhyybc(c1.getJhyybc() + c2.getJhyybc()); | |
| 2368 | + c1.setJhyylc(Arith.add(c1.getJhyylc(), c2.getJhyylc())); | |
| 2369 | + c1.setJhfyybc(c1.getJhfyybc() + c2.getJhfyybc()); | |
| 2370 | + c1.setJhfyylc(Arith.add(c1.getJhfyylc(), c2.getJhfyylc())); | |
| 2371 | + c1.setSjyybc(c1.getSjyybc() + c2.getSjyybc()); | |
| 2372 | + c1.setSjyylc(Arith.add(c1.getSjyylc(), c2.getSjyylc())); | |
| 2373 | +// c1.setSjyylc(Arith.add(c1.getSjyylc(), c2.getLjyylc()));// 把临加的也算上了,后面不用加了 | |
| 2374 | + c1.setSjfyybc(c1.getSjfyybc() + c2.getSjfyybc()); | |
| 2375 | + c1.setSjfyylc(Arith.add(c1.getSjfyylc(), c2.getSjfyylc())); | |
| 2376 | +// c1.setSjfyylc(Arith.add(c1.getSjfyylc(), c2.getLjfyylc()));// 把临加的也算上了,后面不用加了 | |
| 2377 | + c1.setLbbc(c1.getLbbc() + c2.getLbbc()); | |
| 2378 | + c1.setLblc(Arith.add(c1.getLblc(), c2.getLblc())); | |
| 2379 | + c1.setLjbc(c1.getLjbc() + c2.getLjbc()); | |
| 2380 | + c1.setLjyylc(Arith.add(c1.getLjyylc(), c2.getLjyylc())); | |
| 2381 | + c1.setLjfyylc(Arith.add(c1.getLjfyylc(), c2.getLjfyylc())); | |
| 2382 | + c1.setZlc(Arith.add(c1.getZlc(),c2.getZlc())); | |
| 2383 | + c1.setCzyl(Arith.add(c1.getCzyl(),c2.getCzyl())); | |
| 2384 | + c1.setJzyl(Arith.add(c1.getJzyl(),c2.getJzyl())); | |
| 2385 | + c1.setJzl(Arith.add(c1.getJzl(),c2.getJzl())); | |
| 2386 | + c1.setJzl0(Arith.add(c1.getJzl0(),c2.getJzl0())); | |
| 2387 | + c1.setJzl10(Arith.add(c1.getJzl10(),c2.getJzl10())); | |
| 2388 | + c1.setYh(Arith.add(c1.getYh(),c2.getYh())); | |
| 2389 | + c1.setHd(Arith.add(c1.getHd(),c2.getHd())); | |
| 2390 | + c1.setCzcd(Arith.add(c1.getCzcd(),c2.getCzcd())); | |
| 2391 | + c1.setJzcd(Arith.add(c1.getJzcd(),c2.getJzcd())); | |
| 2392 | + c1.setCdl(Arith.add(c1.getCdl(),c2.getCdl())); | |
| 2393 | + c1.setHd(Arith.add(c1.getHd(),c2.getHd())); | |
| 2394 | + c1.setTs(c1.getTs()+c2.getTs()); | |
| 2395 | +// c1.setDtbc(c1.getDtbc() + c2.getDtbc()); | |
| 2396 | + return c1; | |
| 2397 | + } | |
| 1812 | 2398 | } |
| 1813 | 2399 | |
| 1814 | 2400 | class AccountXlbmByping implements Comparator<Map<String, Object>> { | ... | ... |
src/main/java/com/bsth/service/report/ReportService.java
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| 1 | 1 | package com.bsth.service.report.impl; |
| 2 | +import com.bsth.common.ResponseCode; | |
| 2 | 3 | import com.bsth.data.BasicData; |
| 3 | 4 | import com.bsth.entity.CarDevice; |
| 4 | 5 | import com.bsth.entity.Line; |
| ... | ... | @@ -16,6 +17,7 @@ import com.bsth.entity.sys.Interval; |
| 16 | 17 | import com.bsth.repository.LineRepository; |
| 17 | 18 | import com.bsth.repository.StationRouteRepository; |
| 18 | 19 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 20 | +import com.bsth.service.calc.CalcWaybillService; | |
| 19 | 21 | import com.bsth.service.report.CulateMileageService; |
| 20 | 22 | import com.bsth.service.report.ReportService; |
| 21 | 23 | import com.bsth.service.sys.DictionaryService; |
| ... | ... | @@ -27,6 +29,7 @@ import com.bsth.util.db.DBUtils_MS; |
| 27 | 29 | import com.google.protobuf.StringValue; |
| 28 | 30 | |
| 29 | 31 | import org.apache.commons.lang.StringUtils; |
| 32 | +import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
| 30 | 33 | import org.slf4j.Logger; |
| 31 | 34 | import org.slf4j.LoggerFactory; |
| 32 | 35 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -34,6 +37,7 @@ import org.springframework.jdbc.core.JdbcTemplate; |
| 34 | 37 | import org.springframework.jdbc.core.RowMapper; |
| 35 | 38 | import org.springframework.stereotype.Service; |
| 36 | 39 | |
| 40 | +import java.io.FileOutputStream; | |
| 37 | 41 | import java.sql.Connection; |
| 38 | 42 | import java.sql.PreparedStatement; |
| 39 | 43 | import java.sql.ResultSet; |
| ... | ... | @@ -75,7 +79,9 @@ public class ReportServiceImpl implements ReportService{ |
| 75 | 79 | CulateMileageService culateMileageService; |
| 76 | 80 | @Autowired |
| 77 | 81 | DictionaryService dictionaryService; |
| 78 | - | |
| 82 | + @Autowired | |
| 83 | + CalcWaybillService calcWaybillService; | |
| 84 | + | |
| 79 | 85 | @Override |
| 80 | 86 | public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) { |
| 81 | 87 | // TODO Auto-generated method stub |
| ... | ... | @@ -4220,6 +4226,27 @@ public class ReportServiceImpl implements ReportService{ |
| 4220 | 4226 | return listAll; |
| 4221 | 4227 | } |
| 4222 | 4228 | |
| 4229 | + public Map<String,Object> calcDetailMonthlyE(Map<String, Object> map){ | |
| 4230 | + | |
| 4231 | + List<List<String>> list = calcWaybillService.calcDetailMonthly(map); | |
| 4232 | + | |
| 4233 | + Map<String, Object> resultMap = new HashMap<String, Object>(); | |
| 4234 | + try { | |
| 4235 | + String name = map.get("name").toString(); | |
| 4236 | + String type = map.get("statisticalObj").toString(); | |
| 4237 | + if(list.size()>0){ | |
| 4238 | + ReportUtils ee = new ReportUtils(); | |
| 4239 | + ee.createFlie(list,name,type); | |
| 4240 | + } | |
| 4241 | + | |
| 4242 | + resultMap.put("status", ResponseCode.SUCCESS); | |
| 4243 | + } catch (Exception e) { | |
| 4244 | + resultMap.put("status", ResponseCode.ERROR); | |
| 4245 | + logger.error("save erro.", e); | |
| 4246 | + } | |
| 4247 | + return resultMap; | |
| 4248 | + } | |
| 4249 | + | |
| 4223 | 4250 | private String getShyy(String node){ |
| 4224 | 4251 | String shyy ="无"; |
| 4225 | 4252 | if(!node.equals("")){ | ... | ... |
src/main/java/com/bsth/util/ReportUtils.java
| ... | ... | @@ -8,20 +8,26 @@ import java.util.HashMap; |
| 8 | 8 | import java.util.Iterator; |
| 9 | 9 | import java.util.List; |
| 10 | 10 | import java.util.Map; |
| 11 | +import java.util.TreeMap; | |
| 11 | 12 | import java.util.regex.Matcher; |
| 12 | 13 | import java.util.regex.Pattern; |
| 13 | 14 | |
| 15 | +import com.bsth.common.ResponseCode; | |
| 14 | 16 | import org.apache.poi.hssf.usermodel.HSSFCell; |
| 15 | 17 | import org.apache.poi.hssf.usermodel.HSSFCellStyle; |
| 18 | +import org.apache.poi.hssf.usermodel.HSSFFont; | |
| 16 | 19 | import org.apache.poi.hssf.usermodel.HSSFRow; |
| 17 | 20 | import org.apache.poi.hssf.usermodel.HSSFSheet; |
| 18 | 21 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| 19 | 22 | import org.apache.poi.poifs.filesystem.POIFSFileSystem; |
| 20 | 23 | import org.apache.poi.ss.usermodel.Cell; |
| 24 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 21 | 25 | import org.apache.poi.ss.util.CellRangeAddress; |
| 22 | 26 | |
| 23 | 27 | import com.bsth.entity.Line; |
| 24 | 28 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 29 | +import org.apache.poi.ss.util.RegionUtil; | |
| 30 | +import org.apache.poi.xssf.usermodel.XSSFCell; | |
| 25 | 31 | |
| 26 | 32 | public class ReportUtils { |
| 27 | 33 | // private final String packaegName = "com.bsth.entity."; |
| ... | ... | @@ -694,4 +700,124 @@ public class ReportUtils { |
| 694 | 700 | } |
| 695 | 701 | } |
| 696 | 702 | |
| 703 | + public void createFlie(List<List<String>> list, String name, String type){ | |
| 704 | + HSSFWorkbook workbook = new HSSFWorkbook(); | |
| 705 | + // 生成一个样式 | |
| 706 | + HSSFCellStyle style = workbook.createCellStyle(); | |
| 707 | + // 设置这些样式 | |
| 708 | +// style.setFillForegroundColor(HSSFColor.SKY_BLUE.index); | |
| 709 | +// style.setFillPattern(HSSFCellStyle.BORDER_THIN); | |
| 710 | + style.setBorderBottom(HSSFCellStyle.BORDER_THIN); | |
| 711 | + style.setBorderLeft(HSSFCellStyle.BORDER_THIN); | |
| 712 | + style.setBorderRight(HSSFCellStyle.BORDER_THIN); | |
| 713 | + style.setBorderTop(HSSFCellStyle.BORDER_THIN); | |
| 714 | + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); | |
| 715 | + // 生成一个字体 | |
| 716 | + HSSFFont font = workbook.createFont(); | |
| 717 | +// font.setColor(HSSFColor.VIOLET.index); | |
| 718 | + font.setFontHeightInPoints((short) 12); | |
| 719 | + font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); | |
| 720 | + // 把字体应用到当前的样式 | |
| 721 | + style.setFont(font); | |
| 722 | + HSSFCellStyle cellStyle =workbook.createCellStyle(); | |
| 723 | + cellStyle.setFont(font); | |
| 724 | + cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); //水平布局:居中 | |
| 725 | + cellStyle.setWrapText(true); | |
| 726 | + | |
| 727 | + //设置wordsheet名 | |
| 728 | + HSSFSheet sheetYS = workbook.createSheet();//设置wordsheet名 | |
| 729 | + | |
| 730 | + try{ | |
| 731 | + for(int i=0; i<list.size(); i++){ | |
| 732 | + HSSFRow rowYSi = sheetYS.createRow(i); | |
| 733 | + List<String> stringList = list.get(i); | |
| 734 | + int num = 4; | |
| 735 | + if("xl".equals(type)) | |
| 736 | + num = 2; | |
| 737 | + for(int j=0; j<stringList.size(); j++){ | |
| 738 | + String str = stringList.get(j); | |
| 739 | + if(i == list.size()-1){ | |
| 740 | + if(j==0) { | |
| 741 | + setCellStyleAndValue(rowYSi, style, j, str); | |
| 742 | + CellRangeAddress callRangeAddressYSi = new CellRangeAddress(i,i,0,num); | |
| 743 | + sheetYS.addMergedRegion(callRangeAddressYSi); | |
| 744 | + // 样式 | |
| 745 | + setMergeCellStyle (callRangeAddressYSi, sheetYS, workbook); | |
| 746 | + }else | |
| 747 | + setCellStyleAndValue(rowYSi,style,j+num,str); | |
| 748 | + } else { | |
| 749 | + setCellStyleAndValue(rowYSi,style,j,str); | |
| 750 | + } | |
| 751 | + } | |
| 752 | + } | |
| 753 | + | |
| 754 | + // 给列设置宽度自适应 | |
| 755 | + setSizeColumn(sheetYS,list.get(0).size()); | |
| 756 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; | |
| 757 | + String targetPath = path+name+".xls"; | |
| 758 | + createFolder(targetPath); | |
| 759 | + FileOutputStream fout = new FileOutputStream(targetPath); | |
| 760 | + //5.输出 | |
| 761 | + workbook.write(fout); | |
| 762 | + fout.close(); | |
| 763 | + } catch (Exception e) { | |
| 764 | + } | |
| 765 | + } | |
| 766 | + | |
| 767 | + /** | |
| 768 | + * 自适应宽度(中文支持) | |
| 769 | + * @param sheet | |
| 770 | + * @param size | |
| 771 | + */ | |
| 772 | + private static void setSizeColumn(HSSFSheet sheet, int size) { | |
| 773 | + for (int columnNum = 0; columnNum < size; columnNum++) { | |
| 774 | + int columnWidth = sheet.getColumnWidth(columnNum) / 256; | |
| 775 | + for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) { | |
| 776 | + HSSFRow currentRow; | |
| 777 | + //当前行未被使用过 | |
| 778 | + if (sheet.getRow(rowNum) == null) { | |
| 779 | + currentRow = sheet.createRow(rowNum); | |
| 780 | + } else { | |
| 781 | + currentRow = sheet.getRow(rowNum); | |
| 782 | + } | |
| 783 | + if (currentRow.getCell(columnNum) != null) { | |
| 784 | + HSSFCell currentCell = currentRow.getCell(columnNum); | |
| 785 | + if (currentCell.getCellType() == XSSFCell.CELL_TYPE_STRING) { | |
| 786 | + int length = currentCell.getStringCellValue().getBytes().length; | |
| 787 | + if (columnWidth < length) { | |
| 788 | + columnWidth = length; | |
| 789 | + } | |
| 790 | + } | |
| 791 | + } | |
| 792 | + } | |
| 793 | + sheet.setColumnWidth(columnNum, columnWidth * 300); | |
| 794 | +// sheet.setColumnWidth(columnNum, columnWidth * 256); | |
| 795 | + } | |
| 796 | + } | |
| 797 | + | |
| 798 | + /** | |
| 799 | + * 设置单元格值和样式 | |
| 800 | + * @param row | |
| 801 | + * @param style | |
| 802 | + * @param index | |
| 803 | + * @param value | |
| 804 | + */ | |
| 805 | + public static void setCellStyleAndValue(HSSFRow row,HSSFCellStyle style,int index,String value){ | |
| 806 | + HSSFCell cell = row.createCell(index); | |
| 807 | + cell.setCellValue(value); | |
| 808 | + cell.setCellStyle(style); | |
| 809 | + } | |
| 810 | + /** | |
| 811 | + * 设置合并单元格样式 | |
| 812 | + * @param cra | |
| 813 | + * @param sheet | |
| 814 | + * @param workbook | |
| 815 | + */ | |
| 816 | + public static void setMergeCellStyle (CellRangeAddress cra, HSSFSheet sheet, Workbook workbook){ | |
| 817 | + // 使用RegionUtil类为合并后的单元格添加边框 | |
| 818 | + RegionUtil.setBorderBottom(1, cra, sheet, workbook); // 下边框 | |
| 819 | + RegionUtil.setBorderLeft(1, cra, sheet, workbook); // 左边框 | |
| 820 | + RegionUtil.setBorderRight(1, cra, sheet, workbook); // 有边框 | |
| 821 | + RegionUtil.setBorderTop(1, cra, sheet, workbook); // 上边框 | |
| 822 | + } | |
| 697 | 823 | } | ... | ... |
src/main/resources/static/pages/forms/calc/calcDetailMonthly.html
0 → 100644
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; | |
| 11 | + text-align: center; } | |
| 12 | + .table-bordered > thead > tr > th, | |
| 13 | + .table-bordered > thead > tr > td { | |
| 14 | + border-bottom-width: 2px; } | |
| 15 | + | |
| 16 | + .table > tbody + tbody { | |
| 17 | + border-top: 1px solid; } | |
| 18 | + | |
| 19 | + | |
| 20 | + #analy_body tr> td >span{ | |
| 21 | + word-break: keep-all;white-space:nowrap; | |
| 22 | + } | |
| 23 | + | |
| 24 | + #analy_body td{ | |
| 25 | + min-width: 100px; | |
| 26 | + max-width: 100px; | |
| 27 | + width: 100px; | |
| 28 | + } | |
| 29 | + | |
| 30 | + #analy_body{ | |
| 31 | + margin-top: 20px; | |
| 32 | + height: 650px; | |
| 33 | + width: 100% | |
| 34 | + } | |
| 35 | + | |
| 36 | + | |
| 37 | + .table_head::-webkit-scrollbar { | |
| 38 | + display:none | |
| 39 | + } | |
| 40 | + | |
| 41 | + .table_head{ | |
| 42 | + min-width: 906px; | |
| 43 | + width: 100%; | |
| 44 | + overflow: hidden; | |
| 45 | + } | |
| 46 | + | |
| 47 | + .table_body{ | |
| 48 | + width:101%; | |
| 49 | + height:620px; | |
| 50 | + overflow: auto; | |
| 51 | + margin-top: -20px; | |
| 52 | + } | |
| 53 | +</style> | |
| 54 | +<div class="page-head"> | |
| 55 | + <div class="page-title"> | |
| 56 | + <h1>路单线路明细月报表</h1> | |
| 57 | + </div> | |
| 58 | +</div> | |
| 59 | + | |
| 60 | +<!--<div class="row">--> | |
| 61 | +<div class=" row col-md-12 portlet light bordered" style="height:calc(100% - 38px)"> | |
| 62 | + <div class=""> | |
| 63 | + <form class="form-inline" > | |
| 64 | + <!--<div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_daily"> | |
| 65 | + <span class="item-label" style="width: 80px;">  公司: </span> | |
| 66 | + <select class="form-control" name="company" id="gsdm" style="width: 180px;"></select> | |
| 67 | + </div>--> | |
| 68 | + <div style="display: inline-block; margin-left: 33px;" id="fgsdmDiv_daily"> | |
| 69 | + <span class="item-label" style="width: 80px;"> 分公司: </span> | |
| 70 | + <select class="form-control" name="fgsdm" id="fgsdm" style="width: 180px;"></select> | |
| 71 | + </div> | |
| 72 | + <!--<div style="display: inline-block;margin-left: 33px;"> | |
| 73 | + <span class="item-label" style="width: 80px;">  线路: </span> | |
| 74 | + <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 75 | + </div>--> | |
| 76 | + | |
| 77 | + <div style="display: inline-block;margin-left: 33px;" class="date-picker"> | |
| 78 | + <span class="item-label" style="width: 80px;">  时间: </span> | |
| 79 | + <!--<input class="form-control" type="text" id="startDate" style="width: 180px;" /> - --> | |
| 80 | + <!--<input class="form-control" type="text" id="endDate" style="width: 180px;" />--> | |
| 81 | + <input class="form-control" type="text" id="startDate" style="width: 180px;" value="2020-10-01"/> - | |
| 82 | + <input class="form-control" type="text" id="endDate" style="width: 180px;" value="2020-10-10"/> | |
| 83 | + </div> | |
| 84 | + <div style="margin-top: 2px"></div> | |
| 85 | + | |
| 86 | + <div style="display: inline-block;margin-left: 33px;"> | |
| 87 | + <span class="item-label" style="width: 80px;">统计对象: </span> | |
| 88 | + <select class="form-control" name="statisticalObj" id="statisticalObj" style="width: 180px;"> | |
| 89 | + <option value="cl">车辆</option> | |
| 90 | + <option value="jsy">驾驶员</option> | |
| 91 | + <option value="cwy">乘务员</option> | |
| 92 | + <option value="xl">线路</option> | |
| 93 | + </select> | |
| 94 | + </div> | |
| 95 | + | |
| 96 | + <div style="display: inline-block; margin-left: 33px;" > | |
| 97 | + <span class="item-label" style="width: 80px;">统计项目: </span> | |
| 98 | + <select class="form-control" name="statisticalItem" id="statisticalItem" style="width: 180px;"> | |
| 99 | + <option value="yh">油耗</option> | |
| 100 | + <option value="dh">电耗</option> | |
| 101 | + <option value="gl">公里</option> | |
| 102 | + <option value="bc">班次</option> | |
| 103 | + </select> | |
| 104 | + </div> | |
| 105 | + <div style="display: inline-block; margin-left: 33px;" > | |
| 106 | + <span class="item-label" style="width: 80px;">项目明细: </span> | |
| 107 | + <select class="form-control" name="itemDetails" id="itemDetails" style="width: 180px;"></select> | |
| 108 | + </div> | |
| 109 | + <div class="form-group" style="display: inline-block;margin-left: 62px;"> | |
| 110 | + <input class="btn btn-default" type="button" id="query" value="筛选"/> | |
| 111 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 112 | + </div> | |
| 113 | + </form> | |
| 114 | + </div> | |
| 115 | + | |
| 116 | + <div id="analy_body"> | |
| 117 | + <div class="table_head" id="table_head"> | |
| 118 | + <table class="table table-bordered table-hover table-checkable " id="forms_head"> | |
| 119 | + <thead> | |
| 120 | + </thead> | |
| 121 | + </table> | |
| 122 | + </div> | |
| 123 | + <div class="table_body" id="table_body"> | |
| 124 | + <table class="table table-bordered table-hover table-checkable" id="forms_body"> | |
| 125 | + <tbody> | |
| 126 | + </tbody> | |
| 127 | + </table> | |
| 128 | + </div> | |
| 129 | + </div> | |
| 130 | +</div> | |
| 131 | +<script > | |
| 132 | + $(function(){ | |
| 133 | + // 关闭左侧栏 | |
| 134 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 135 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 136 | + | |
| 137 | + var table_body1 = document.getElementById("table_body"); | |
| 138 | + table_body1.onscroll = function(){ | |
| 139 | + var table_body1_left = this.scrollLeft; | |
| 140 | + document.getElementById("table_head").scrollLeft = table_body1_left; | |
| 141 | + }; | |
| 142 | + | |
| 143 | + var d = new Date(); | |
| 144 | + var year = d.getFullYear(); | |
| 145 | + var month = d.getMonth() + 1; | |
| 146 | + var day = d.getDate()-1;//只能查一天以前的数据 | |
| 147 | + if(month < 10) | |
| 148 | + month = "0" + month; | |
| 149 | + if(day < 10) | |
| 150 | + day = "0" + day; | |
| 151 | + //时间 | |
| 152 | + var dateTime=year + "-" + month + "-" + day; | |
| 153 | + // $("#startDate").val(dateTime); | |
| 154 | + // $("#endDate").val(dateTime); | |
| 155 | + | |
| 156 | + // $("#endDate").datetimepicker({ | |
| 157 | + // format : 'YYYY-MM-DD', | |
| 158 | + // locale : 'zh-cn', | |
| 159 | + // maxDate : dateTime | |
| 160 | + // }); | |
| 161 | + // $("#startDate").datetimepicker({ | |
| 162 | + // format : 'YYYY-MM-DD', | |
| 163 | + // locale : 'zh-cn', | |
| 164 | + // maxDate : dateTime | |
| 165 | + // }); | |
| 166 | + | |
| 167 | + var fage=false; | |
| 168 | + var xlList; | |
| 169 | + var obj = []; | |
| 170 | + var datas = {}; //查询条件 | |
| 171 | + | |
| 172 | + var tempData = {}; | |
| 173 | + | |
| 174 | + $.get('/report/lineList',function(result){ | |
| 175 | + xlList=result; | |
| 176 | + $.get('/user/companyData', function(result){ | |
| 177 | + obj = result; | |
| 178 | + var options = '<option value="">所有分公司</option>'; | |
| 179 | + for(var i = 0; i < obj.length; i++){ | |
| 180 | + if(obj[i].companyCode == "26"){ | |
| 181 | + var children = obj[i].children; | |
| 182 | + for(var j = 0; j < children.length; j++){ | |
| 183 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 184 | + } | |
| 185 | + } | |
| 186 | + } | |
| 187 | + $('#fgsdm').html(options); | |
| 188 | + }); | |
| 189 | + }); | |
| 190 | + | |
| 191 | + | |
| 192 | + // $("#gsdm").on("change",updateCompany); | |
| 193 | + function updateCompany(){ | |
| 194 | + // var company = $('#gsdm').val(); | |
| 195 | + var options = '<option value="">所有分公司</option>'; | |
| 196 | + for(var i = 0; i < obj.length; i++){ | |
| 197 | + if(obj[i].companyCode == "26"){ | |
| 198 | + var children = obj[i].children; | |
| 199 | + for(var j = 0; j < children.length; j++){ | |
| 200 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 201 | + } | |
| 202 | + } | |
| 203 | + } | |
| 204 | + $('#fgsdm').html(options); | |
| 205 | + } | |
| 206 | + | |
| 207 | + $("#line").on("change", function(){ | |
| 208 | + if($("#line").val() == " "){ | |
| 209 | + $("#gsdm").attr("disabled", false); | |
| 210 | + $("#fgsdm").attr("disabled", false); | |
| 211 | + } else { | |
| 212 | + var temp = tempData[$("#line").val()].split(":"); | |
| 213 | + $("#gsdm").val(temp[0]); | |
| 214 | + updateCompany(); | |
| 215 | + $("#fgsdm").val(temp[1]); | |
| 216 | + $("#gsdm").attr("disabled", true); | |
| 217 | + $("#fgsdm").attr("disabled", true); | |
| 218 | + } | |
| 219 | + }); | |
| 220 | + | |
| 221 | + // 项目明细选项列 | |
| 222 | + // 触发默认选项 | |
| 223 | + updateItem(); | |
| 224 | + $("#statisticalItem").on("change",updateItem); | |
| 225 | + function updateItem() { | |
| 226 | + var item = $('#statisticalItem').val(); | |
| 227 | + var options = ''; | |
| 228 | + if(item == "yh"){ | |
| 229 | + options += '<option value="jzlAll">加注量[全部]</option>' + | |
| 230 | + '<option value="jzl0">加注量[0#]</option>'+ | |
| 231 | + '<option value="jzl-10">加注量[-10#]</option>'+ | |
| 232 | + '<option value="yhl">油耗量</option>'+ | |
| 233 | + '<option value="cccy">出场存油</option>'+ | |
| 234 | + '<option value="jccy">进场存油</option>'+ | |
| 235 | + '<option value="bglyh">百公里油耗</option>'; | |
| 236 | + } else if(item == "gl"){ | |
| 237 | + options += '<option value="zgl">总公里</option>' + | |
| 238 | + '<option value="jhgl">计划公里</option>'; | |
| 239 | + /*'<option value="jclm">进场路码</option>'+ | |
| 240 | + '<option value="cclm">出场路码</option>'*/ | |
| 241 | + } else if(item == "bc"){ | |
| 242 | + options += '<option value="sjbc">实际班次</option>' + | |
| 243 | + '<option value="jhbc">计划班次</option>'; | |
| 244 | + } else if(item == "dh"){ | |
| 245 | + options += '<option value="dh">耗电量</option>'; | |
| 246 | + options += '<option value="cdl">充电量</option>'; | |
| 247 | + options += '<option value="cccd">出场存电</option>'; | |
| 248 | + options += '<option value="jccd">进场存电</option>'; | |
| 249 | + options += '<option value="bgldh">百公里电耗</option>'; | |
| 250 | + } | |
| 251 | + $('#itemDetails').html(options); | |
| 252 | + } | |
| 253 | + | |
| 254 | + //线路名称 | |
| 255 | + var lineName = ''; | |
| 256 | + $("#query").on("click",function(){ | |
| 257 | + var gsdm = "26"; | |
| 258 | + var fgsdm = $("#fgsdm").val(); | |
| 259 | + var lineCode = $("#line").val(); | |
| 260 | + var startDate = $("#startDate").val(); | |
| 261 | + var endDate = $("#endDate").val(); | |
| 262 | + var statisticalObj = $("#statisticalObj").val(); | |
| 263 | + lineName=$("#line option:selected").text(); | |
| 264 | + //开始和结束时间 | |
| 265 | + var startTime = Date.parse(new Date(startDate)); | |
| 266 | + var endTime = Date.parse(new Date(endDate)); | |
| 267 | + | |
| 268 | + datas = {}; // 清空之前数据 | |
| 269 | + datas.gsdm = gsdm; | |
| 270 | + datas.fgsdm = fgsdm; | |
| 271 | + datas.lineCode = lineCode; | |
| 272 | + datas.lineName = lineName; | |
| 273 | + datas.startDate = startDate; | |
| 274 | + datas.timeType = "m"; | |
| 275 | + // datas.startDate = "2020-10-01"; | |
| 276 | + datas.endDate = endDate; | |
| 277 | + // datas.endDate = "2020-10-10"; | |
| 278 | + datas.statisticalObj = $("#statisticalObj").val(); | |
| 279 | + datas.itemDetails = $("#itemDetails").val(); | |
| 280 | + | |
| 281 | + if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ | |
| 282 | + layer.msg('请选择时间段!'); | |
| 283 | + }else if(endTime<startTime){ | |
| 284 | + layer.msg('结束日期不能小于开始日期!'); | |
| 285 | + }else { | |
| 286 | + if (endDate.substring(0, 7) != startDate.substring(0, 7)) { | |
| 287 | + layer.msg("请查询同月份数据!"); | |
| 288 | + return; | |
| 289 | + } else { | |
| 290 | + var lodingI = layer.load(2); | |
| 291 | + $get('/calcWaybill/calcDetailMonthly', datas, function (rs) { | |
| 292 | + if (rs.length <=0) { | |
| 293 | + layer.close(lodingI); | |
| 294 | + layer.open({ | |
| 295 | + title: '提示' | |
| 296 | + , content: '没有您要查询的数据,请重新选择参数!' | |
| 297 | + }); | |
| 298 | + return; | |
| 299 | + } | |
| 300 | + var htmlHead = "", htmlBody = ""; | |
| 301 | + var rsLength = rs.length; | |
| 302 | + rs.forEach(function (o, i) { | |
| 303 | + var html = "<tr>" | |
| 304 | + o.forEach(function (td, j) { | |
| 305 | + var colspan; | |
| 306 | + if (i == rsLength - 1 && j == 0) { | |
| 307 | + colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); | |
| 308 | + } | |
| 309 | + html += "<td " + colspan + ">" + td + "</td>" | |
| 310 | + }); | |
| 311 | + html += "</tr>" | |
| 312 | + if (i == 0) { | |
| 313 | + htmlHead = html; | |
| 314 | + } else | |
| 315 | + htmlBody += html; | |
| 316 | + }); | |
| 317 | + $('#forms_head thead').html(htmlHead); | |
| 318 | + $('#forms_body tbody').html(htmlBody); | |
| 319 | + layer.close(lodingI); | |
| 320 | + }); | |
| 321 | + } | |
| 322 | + } | |
| 323 | + }); | |
| 324 | + | |
| 325 | + $("#export").on("click",function(){ | |
| 326 | + datas.timeType = "m"; | |
| 327 | + var itemDetails = datas.itemDetails, | |
| 328 | + type = "加注量[全部]"; | |
| 329 | + if(itemDetails=="jzl0"){ | |
| 330 | + type = "加注量[0#]" | |
| 331 | + } else if(itemDetails=="jzl-10"){ | |
| 332 | + type = "加注量[-10#]" | |
| 333 | + } else if(itemDetails=="yhl"){ | |
| 334 | + type = "油耗量" | |
| 335 | + } else if(itemDetails=="cccy"){ | |
| 336 | + type = "出场存油" | |
| 337 | + } else if(itemDetails=="jccy"){ | |
| 338 | + type = "进场存油" | |
| 339 | + } else if(itemDetails=="bglyh"){ | |
| 340 | + type = "百公里油耗" | |
| 341 | + } else if(itemDetails=="zgl"){ | |
| 342 | + type = "总公里" | |
| 343 | + } else if(itemDetails=="jhgl"){ | |
| 344 | + type = "计划公里" | |
| 345 | + } else if(itemDetails=="jclm"){ | |
| 346 | + type = "进场路码" | |
| 347 | + } else if(itemDetails=="cclm"){ | |
| 348 | + type = "出场路码" | |
| 349 | + } else if(itemDetails=="sjbc"){ | |
| 350 | + type = "实际班次" | |
| 351 | + } else if(itemDetails=="jhbc"){ | |
| 352 | + type = "计划班次" | |
| 353 | + } else if(itemDetails=="dh"){ | |
| 354 | + type = "耗电量" | |
| 355 | + } else if(itemDetails=="cdl"){ | |
| 356 | + type = "充电量" | |
| 357 | + } else if(itemDetails=="cccd"){ | |
| 358 | + type = "出场存电" | |
| 359 | + } else if(itemDetails=="jccd"){ | |
| 360 | + type = "进场存电" | |
| 361 | + } else if(itemDetails=="bgldh"){ | |
| 362 | + type = "百公里电耗" | |
| 363 | + } | |
| 364 | + datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细月报表("+type+")"; | |
| 365 | + $post("/report/calcDetailMonthlyE",datas,function(result){ | |
| 366 | + window.open("/downloadFile/download?fileName="+datas.name); | |
| 367 | + }); | |
| 368 | + }); | |
| 369 | + }); | |
| 370 | +</script> | |
| 371 | +<!--<script type="application/javascript" src="/pages/forms/calc/calcDetailMonthly.js"></script>--> | ... | ... |
src/main/resources/static/pages/forms/calc/calcDetailYear.html
0 → 100644
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; | |
| 11 | + text-align: center; } | |
| 12 | + .table-bordered > thead > tr > th, | |
| 13 | + .table-bordered > thead > tr > td { | |
| 14 | + border-bottom-width: 2px; } | |
| 15 | + | |
| 16 | + .table > tbody + tbody { | |
| 17 | + border-top: 1px solid; } | |
| 18 | + | |
| 19 | + | |
| 20 | + #analy_body tr> td >span{ | |
| 21 | + word-break: keep-all;white-space:nowrap; | |
| 22 | + } | |
| 23 | + | |
| 24 | + #analy_body td{ | |
| 25 | + min-width: 100px; | |
| 26 | + max-width: 100px; | |
| 27 | + width: 100px; | |
| 28 | + } | |
| 29 | + | |
| 30 | + #analy_body{ | |
| 31 | + margin-top: 20px; | |
| 32 | + height: 650px; | |
| 33 | + width: 100% | |
| 34 | + } | |
| 35 | + | |
| 36 | + | |
| 37 | + .table_head::-webkit-scrollbar { | |
| 38 | + display:none | |
| 39 | + } | |
| 40 | + | |
| 41 | + .table_head{ | |
| 42 | + min-width: 906px; | |
| 43 | + width: 100%; | |
| 44 | + overflow: hidden; | |
| 45 | + } | |
| 46 | + | |
| 47 | + .table_body{ | |
| 48 | + width:101%; | |
| 49 | + height:620px; | |
| 50 | + overflow: auto; | |
| 51 | + margin-top: -20px; | |
| 52 | + } | |
| 53 | +</style> | |
| 54 | +<div class="page-head"> | |
| 55 | + <div class="page-title"> | |
| 56 | + <h1>路单线路明细年报表</h1> | |
| 57 | + </div> | |
| 58 | +</div> | |
| 59 | + | |
| 60 | +<!--<div class="row">--> | |
| 61 | +<div class=" row col-md-12 portlet light bordered" style="height:calc(100% - 38px)"> | |
| 62 | + <div class=""> | |
| 63 | + <form class="form-inline" > | |
| 64 | + <!--<div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_daily"> | |
| 65 | + <span class="item-label" style="width: 80px;">  公司: </span> | |
| 66 | + <select class="form-control" name="company" id="gsdm" style="width: 180px;"></select> | |
| 67 | + </div>--> | |
| 68 | + <div style="display: inline-block; margin-left: 33px;" id="fgsdmDiv_daily"> | |
| 69 | + <span class="item-label" style="width: 80px;"> 分公司: </span> | |
| 70 | + <select class="form-control" name="fgsdm" id="fgsdm" style="width: 180px;"></select> | |
| 71 | + </div> | |
| 72 | + <!--<div style="display: inline-block;margin-left: 33px;"> | |
| 73 | + <span class="item-label" style="width: 80px;">  线路: </span> | |
| 74 | + <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 75 | + </div>--> | |
| 76 | + | |
| 77 | + <div style="display: inline-block;margin-left: 33px;" class="date-picker"> | |
| 78 | + <span class="item-label" style="width: 80px;">  时间: </span> | |
| 79 | + <input class="form-control" type="text" id="startDate" style="width: 180px;" /> - | |
| 80 | + <input class="form-control" type="text" id="endDate" style="width: 180px;" /> | |
| 81 | + <!--<input class="form-control" type="text" id="startDate" style="width: 180px;" value="2020-10"/> - --> | |
| 82 | + <!--<input class="form-control" type="text" id="endDate" style="width: 180px;" value="2020-10"/>--> | |
| 83 | + </div> | |
| 84 | + <div style="margin-top: 2px"></div> | |
| 85 | + | |
| 86 | + <div style="display: inline-block;margin-left: 33px;"> | |
| 87 | + <span class="item-label" style="width: 80px;">统计对象: </span> | |
| 88 | + <select class="form-control" name="statisticalObj" id="statisticalObj" style="width: 180px;"> | |
| 89 | + <option value="cl">车辆</option> | |
| 90 | + <option value="jsy">驾驶员</option> | |
| 91 | + <option value="cwy">乘务员</option> | |
| 92 | + <option value="xl">线路</option> | |
| 93 | + </select> | |
| 94 | + </div> | |
| 95 | + | |
| 96 | + <div style="display: inline-block; margin-left: 33px;" > | |
| 97 | + <span class="item-label" style="width: 80px;">统计项目: </span> | |
| 98 | + <select class="form-control" name="statisticalItem" id="statisticalItem" style="width: 180px;"> | |
| 99 | + <option value="yh">油耗</option> | |
| 100 | + <option value="dh">电耗</option> | |
| 101 | + <option value="gl">公里</option> | |
| 102 | + <option value="bc">班次</option> | |
| 103 | + </select> | |
| 104 | + </div> | |
| 105 | + <div style="display: inline-block; margin-left: 33px;" > | |
| 106 | + <span class="item-label" style="width: 80px;">项目明细: </span> | |
| 107 | + <select class="form-control" name="itemDetails" id="itemDetails" style="width: 180px;"></select> | |
| 108 | + </div> | |
| 109 | + <div class="form-group" style="display: inline-block;margin-left: 62px;"> | |
| 110 | + <input class="btn btn-default" type="button" id="query" value="筛选"/> | |
| 111 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 112 | + </div> | |
| 113 | + </form> | |
| 114 | + </div> | |
| 115 | + | |
| 116 | + <div id="analy_body"> | |
| 117 | + <div class="table_head" id="table_head"> | |
| 118 | + <table class="table table-bordered table-hover table-checkable " id="forms_head"> | |
| 119 | + <thead> | |
| 120 | + </thead> | |
| 121 | + </table> | |
| 122 | + </div> | |
| 123 | + <div class="table_body" id="table_body"> | |
| 124 | + <table class="table table-bordered table-hover table-checkable" id="forms_body"> | |
| 125 | + <tbody> | |
| 126 | + </tbody> | |
| 127 | + </table> | |
| 128 | + </div> | |
| 129 | + </div> | |
| 130 | +</div> | |
| 131 | +<script > | |
| 132 | + $(function(){ | |
| 133 | + // 关闭左侧栏 | |
| 134 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 135 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 136 | + | |
| 137 | + var table_body1 = document.getElementById("table_body"); | |
| 138 | + table_body1.onscroll = function(){ | |
| 139 | + var table_body1_left = this.scrollLeft; | |
| 140 | + document.getElementById("table_head").scrollLeft = table_body1_left; | |
| 141 | + }; | |
| 142 | + | |
| 143 | + var d = new Date(); | |
| 144 | + var year = d.getFullYear(); | |
| 145 | + var month = d.getMonth() + 1; | |
| 146 | + if(month < 10) | |
| 147 | + month = "0" + month; | |
| 148 | + //时间 | |
| 149 | + var dateTime=year + "-" + month; | |
| 150 | + $("#startDate").val(dateTime); | |
| 151 | + $("#endDate").val(dateTime); | |
| 152 | + | |
| 153 | + $("#endDate").datetimepicker({ | |
| 154 | + format : 'YYYY-MM', | |
| 155 | + locale : 'zh-cn', | |
| 156 | + maxDate : dateTime | |
| 157 | + }); | |
| 158 | + $("#startDate").datetimepicker({ | |
| 159 | + format : 'YYYY-MM', | |
| 160 | + locale : 'zh-cn', | |
| 161 | + maxDate : dateTime | |
| 162 | + }); | |
| 163 | + | |
| 164 | + var fage=false; | |
| 165 | + var xlList; | |
| 166 | + var obj = []; | |
| 167 | + var datas = {}; //查询条件 | |
| 168 | + | |
| 169 | + var tempData = {}; | |
| 170 | + | |
| 171 | + $.get('/report/lineList',function(result){ | |
| 172 | + xlList=result; | |
| 173 | + $.get('/user/companyData', function(result){ | |
| 174 | + obj = result; | |
| 175 | + var options = '<option value="">所有分公司</option>'; | |
| 176 | + for(var i = 0; i < obj.length; i++){ | |
| 177 | + if(obj[i].companyCode == "26"){ | |
| 178 | + var children = obj[i].children; | |
| 179 | + for(var j = 0; j < children.length; j++){ | |
| 180 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 181 | + } | |
| 182 | + } | |
| 183 | + } | |
| 184 | + $('#fgsdm').html(options); | |
| 185 | + }); | |
| 186 | + }); | |
| 187 | + | |
| 188 | + | |
| 189 | + // $("#gsdm").on("change",updateCompany); | |
| 190 | + function updateCompany(){ | |
| 191 | + // var company = $('#gsdm').val(); | |
| 192 | + var options = '<option value="">所有分公司</option>'; | |
| 193 | + for(var i = 0; i < obj.length; i++){ | |
| 194 | + if(obj[i].companyCode == "26"){ | |
| 195 | + var children = obj[i].children; | |
| 196 | + for(var j = 0; j < children.length; j++){ | |
| 197 | + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>'; | |
| 198 | + } | |
| 199 | + } | |
| 200 | + } | |
| 201 | + $('#fgsdm').html(options); | |
| 202 | + } | |
| 203 | + | |
| 204 | + $("#line").on("change", function(){ | |
| 205 | + if($("#line").val() == " "){ | |
| 206 | + $("#gsdm").attr("disabled", false); | |
| 207 | + $("#fgsdm").attr("disabled", false); | |
| 208 | + } else { | |
| 209 | + var temp = tempData[$("#line").val()].split(":"); | |
| 210 | + $("#gsdm").val(temp[0]); | |
| 211 | + updateCompany(); | |
| 212 | + $("#fgsdm").val(temp[1]); | |
| 213 | + $("#gsdm").attr("disabled", true); | |
| 214 | + $("#fgsdm").attr("disabled", true); | |
| 215 | + } | |
| 216 | + }); | |
| 217 | + | |
| 218 | + // 项目明细选项列 | |
| 219 | + // 触发默认选项 | |
| 220 | + updateItem(); | |
| 221 | + $("#statisticalItem").on("change",updateItem); | |
| 222 | + function updateItem() { | |
| 223 | + var item = $('#statisticalItem').val(); | |
| 224 | + var options = ''; | |
| 225 | + if(item == "yh"){ | |
| 226 | + options += '<option value="jzlAll">加注量[全部]</option>' + | |
| 227 | + '<option value="jzl0">加注量[0#]</option>'+ | |
| 228 | + '<option value="jzl-10">加注量[-10#]</option>'+ | |
| 229 | + '<option value="yhl">油耗量</option>'+ | |
| 230 | + '<option value="cccy">出场存油</option>'+ | |
| 231 | + '<option value="jccy">进场存油</option>'+ | |
| 232 | + '<option value="bglyh">百公里油耗</option>'; | |
| 233 | + } else if(item == "gl"){ | |
| 234 | + options += '<option value="zgl">总公里</option>' + | |
| 235 | + '<option value="jhgl">计划公里</option>'; | |
| 236 | + /*'<option value="jclm">进场路码</option>'+ | |
| 237 | + '<option value="cclm">出场路码</option>'*/ | |
| 238 | + } else if(item == "bc"){ | |
| 239 | + options += '<option value="sjbc">实际班次</option>' + | |
| 240 | + '<option value="jhbc">计划班次</option>'; | |
| 241 | + } else if(item == "dh"){ | |
| 242 | + options += '<option value="dh">耗电量</option>'; | |
| 243 | + options += '<option value="cdl">充电量</option>'; | |
| 244 | + options += '<option value="cccd">出场存电</option>'; | |
| 245 | + options += '<option value="jccd">进场存电</option>'; | |
| 246 | + options += '<option value="bgldh">百公里电耗</option>'; | |
| 247 | + } | |
| 248 | + $('#itemDetails').html(options); | |
| 249 | + } | |
| 250 | + | |
| 251 | + //线路名称 | |
| 252 | + var lineName = ''; | |
| 253 | + $("#query").on("click",function(){ | |
| 254 | + var gsdm = "26"; | |
| 255 | + var fgsdm = $("#fgsdm").val(); | |
| 256 | + var lineCode = $("#line").val(); | |
| 257 | + var startDate = $("#startDate").val(); | |
| 258 | + var endDate = $("#endDate").val(); | |
| 259 | + var statisticalObj = $("#statisticalObj").val(); | |
| 260 | + lineName=$("#line option:selected").text(); | |
| 261 | + //开始和结束时间 | |
| 262 | + var startTime = Date.parse(new Date(startDate)); | |
| 263 | + var endTime = Date.parse(new Date(endDate)); | |
| 264 | + | |
| 265 | + datas = {}; // 清空之前数据 | |
| 266 | + datas.timeType = "y"; | |
| 267 | + datas.gsdm = gsdm; | |
| 268 | + datas.fgsdm = fgsdm; | |
| 269 | + datas.lineCode = lineCode; | |
| 270 | + datas.lineName = lineName; | |
| 271 | + datas.startDate = startDate; | |
| 272 | + // datas.startDate = "2020-10-01"; | |
| 273 | + datas.endDate = endDate; | |
| 274 | + // datas.endDate = "2020-10-10"; | |
| 275 | + datas.statisticalObj = $("#statisticalObj").val(); | |
| 276 | + datas.itemDetails = $("#itemDetails").val(); | |
| 277 | + | |
| 278 | + if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ | |
| 279 | + layer.msg('请选择时间段!'); | |
| 280 | + }else if(endTime<startTime){ | |
| 281 | + layer.msg('结束日期不能小于开始日期!'); | |
| 282 | + }else { | |
| 283 | + if (endDate.substring(0, 4) != startDate.substring(0, 4)) { | |
| 284 | + layer.msg("请查询同年份数据!"); | |
| 285 | + return; | |
| 286 | + } else { | |
| 287 | + var lodingI = layer.load(2); | |
| 288 | + $get('/calcWaybill/calcDetailMonthly', datas, function (rs) { | |
| 289 | + if (rs.length <=0) { | |
| 290 | + layer.close(lodingI); | |
| 291 | + layer.open({ | |
| 292 | + title: '提示' | |
| 293 | + , content: '没有您要查询的数据,请重新选择参数!' | |
| 294 | + }); | |
| 295 | + return; | |
| 296 | + } | |
| 297 | + var htmlHead = "", htmlBody = ""; | |
| 298 | + var rsLength = rs.length; | |
| 299 | + rs.forEach(function (o, i) { | |
| 300 | + var html = "<tr>" | |
| 301 | + o.forEach(function (td, j) { | |
| 302 | + var colspan; | |
| 303 | + if (i == rsLength - 1 && j == 0) { | |
| 304 | + colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); | |
| 305 | + } | |
| 306 | + html += "<td " + colspan + ">" + td + "</td>" | |
| 307 | + }); | |
| 308 | + html += "</tr>" | |
| 309 | + if (i == 0) { | |
| 310 | + htmlHead = html; | |
| 311 | + } else | |
| 312 | + htmlBody += html; | |
| 313 | + }); | |
| 314 | + $('#forms_head thead').html(htmlHead); | |
| 315 | + $('#forms_body tbody').html(htmlBody); | |
| 316 | + layer.close(lodingI); | |
| 317 | + }); | |
| 318 | + } | |
| 319 | + } | |
| 320 | + }); | |
| 321 | + | |
| 322 | + $("#export").on("click",function(){ | |
| 323 | + datas.timeType = "y"; | |
| 324 | + var itemDetails = datas.itemDetails, | |
| 325 | + type = "加注量[全部]"; | |
| 326 | + if(itemDetails=="jzl0"){ | |
| 327 | + type = "加注量[0#]" | |
| 328 | + } else if(itemDetails=="jzl-10"){ | |
| 329 | + type = "加注量[-10#]" | |
| 330 | + } else if(itemDetails=="yhl"){ | |
| 331 | + type = "油耗量" | |
| 332 | + } else if(itemDetails=="cccy"){ | |
| 333 | + type = "出场存油" | |
| 334 | + } else if(itemDetails=="jccy"){ | |
| 335 | + type = "进场存油" | |
| 336 | + } else if(itemDetails=="bglyh"){ | |
| 337 | + type = "百公里油耗" | |
| 338 | + } else if(itemDetails=="zgl"){ | |
| 339 | + type = "总公里" | |
| 340 | + } else if(itemDetails=="jhgl"){ | |
| 341 | + type = "计划公里" | |
| 342 | + } else if(itemDetails=="jclm"){ | |
| 343 | + type = "进场路码" | |
| 344 | + } else if(itemDetails=="cclm"){ | |
| 345 | + type = "出场路码" | |
| 346 | + } else if(itemDetails=="sjbc"){ | |
| 347 | + type = "实际班次" | |
| 348 | + } else if(itemDetails=="jhbc"){ | |
| 349 | + type = "计划班次" | |
| 350 | + } else if(itemDetails=="dh"){ | |
| 351 | + type = "耗电量" | |
| 352 | + } else if(itemDetails=="cdl"){ | |
| 353 | + type = "充电量" | |
| 354 | + } else if(itemDetails=="cccd"){ | |
| 355 | + type = "出场存电" | |
| 356 | + } else if(itemDetails=="jccd"){ | |
| 357 | + type = "进场存电" | |
| 358 | + } else if(itemDetails=="bgldh"){ | |
| 359 | + type = "百公里电耗" | |
| 360 | + } | |
| 361 | + datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细年报表("+type+")"; | |
| 362 | + $post("/report/calcDetailMonthlyE",datas,function(result){ | |
| 363 | + window.open("/downloadFile/download?fileName="+datas.name); | |
| 364 | + }); | |
| 365 | + }); | |
| 366 | + }); | |
| 367 | +</script> | |
| 368 | +<!--<script type="application/javascript" src="/pages/forms/calc/calcDetailMonthly.js"></script>--> | ... | ... |