Commit a2b0ab8c09ffcc097e3f7ee7be5b8837553a608b

Authored by yiming
1 parent ff2f70e9

线调主页加图表

Too many changes to show.

To preserve performance only 1 of 6 files are displayed.

src/main/java/com/bsth/controller/EchartsController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.data.gpsdata_v2.GpsRealData;
  4 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.entity.schedule.SchedulePlanInfo;
  7 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  8 +import com.bsth.repository.schedule.SchedulePlanInfoRepository;
  9 +import com.bsth.service.report.CulateMileageService;
  10 +import com.bsth.util.Arith;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.web.bind.annotation.*;
  13 +import java.time.LocalDate;
  14 +import java.time.format.DateTimeFormatter;
  15 +import java.util.*;
  16 +
  17 +@RestController
  18 +@RequestMapping("echartsData")
  19 +public class EchartsController {
  20 +
  21 + @Autowired
  22 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  23 +
  24 + @Autowired
  25 + SchedulePlanInfoRepository schedulePlanRepository;
  26 +
  27 + @Autowired
  28 + GpsRealData gpsRealData;
  29 +
  30 + @Autowired
  31 + CulateMileageService culateService;
  32 +
  33 + @RequestMapping(value = "/home/echarts1")
  34 + public List<Map<String,Object>> schData(@RequestParam String lineCode) {
  35 + LocalDate localDate=LocalDate.now();
  36 + DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
  37 + List<ScheduleRealInfo> list=scheduleRealInfoRepository.scheduleDaily(lineCode, localDate.format(dtf));
  38 + List<Map<String,Object>> result=new ArrayList<>();
  39 + int wzx=0;
  40 + int zzzx=0;
  41 + int yzx=0;
  42 + int ylb=0;
  43 + /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */
  44 + for (ScheduleRealInfo scheduleRealInfo : list) {
  45 + if(scheduleRealInfo.getStatus()==0){
  46 + wzx++;
  47 + }else if(scheduleRealInfo.getStatus()==1){
  48 + zzzx++;
  49 + }else if(scheduleRealInfo.getStatus()==2){
  50 + yzx++;
  51 + }else if(scheduleRealInfo.getStatus()==-1){
  52 + ylb++;
  53 + }
  54 + }
  55 + Map<String,Object> map1=new HashMap<>();
  56 + map1.put("value",wzx);
  57 + map1.put("name","未执行");
  58 + result.add(map1);
  59 + Map<String,Object> map2=new HashMap<>();
  60 + map2.put("value",zzzx);
  61 + map2.put("name","正在执行");
  62 + result.add(map2);
  63 + Map<String,Object> map3=new HashMap<>();
  64 + map3.put("value",yzx);
  65 + map3.put("name","已执行");
  66 + result.add(map3);
  67 + Map<String,Object> map4=new HashMap<>();
  68 + map4.put("value",ylb);
  69 + map4.put("name","已烂班");
  70 + result.add(map4);
  71 + return result;
  72 + }
  73 +
  74 + @RequestMapping(value = "/home/echarts2")
  75 + public List<List<Object>> echarts2(@RequestParam String lineCode) {
  76 + List<List<Object>> result=new ArrayList<>();
  77 + LocalDate localDate=LocalDate.now();
  78 + DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
  79 + List<ScheduleRealInfo> list=scheduleRealInfoRepository.scheduleDaily(lineCode, localDate.format(dtf));
  80 +
  81 + List<ScheduleRealInfo> lists = new ArrayList<>();
  82 + for (int i = 0; i < list.size(); i++) {
  83 + ScheduleRealInfo s = list.get(i);
  84 + Set<ChildTaskPlan> cts = s.getcTasks();
  85 + if (cts != null && cts.size() > 0) {
  86 + lists.add(s);
  87 + } else {
  88 + if (s.getFcsjActual() != null && s.getZdsjActual() != null) {
  89 + lists.add(s);
  90 + }
  91 + }
  92 + }
  93 +
  94 + List<String> sjjghL=new ArrayList<>();
  95 + List<String> sjjbhL=new ArrayList<>();
  96 + for (ScheduleRealInfo sch : list) {
  97 + if(!sjjghL.contains(sch.getjGh())){
  98 + sjjghL.add(sch.getjGh());
  99 + }
  100 + if(!sjjbhL.contains(sch.getClZbh())){
  101 + sjjbhL.add(sch.getClZbh());
  102 + }
  103 + }
  104 + List<Object> sj=new ArrayList<>();
  105 + sj.add(culateService.culateSjbc(list, "") + culateService.culateLjbc(list, ""));//实际班次(实际+临加)
  106 + sj.add(sjjghL.size());
  107 + sj.add(sjjbhL.size());
  108 + double ksgl = culateService.culateKsgl(list);//子任务空驶公里
  109 + double jccgl = culateService.culateJccgl(lists);//空驶班次公里
  110 + double sjgl = culateService.culateSjgl(lists);//实际营运公里
  111 + double ljgl = culateService.culateLjgl(lists);//临加公里
  112 + sj.add(Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//实际总公里
  113 + sj.add(Arith.add(sjgl, ljgl));//实际总营运公里
  114 + sj.add(Arith.add(ksgl, jccgl));//实际非运营公里
  115 +
  116 +
  117 + List<SchedulePlanInfo> list2=schedulePlanRepository.findPlanByXlAndDate(lineCode, localDate.format(dtf));
  118 + List<String> jhjghL=new ArrayList<>();
  119 + List<String> jhjbhL=new ArrayList<>();
  120 + for (SchedulePlanInfo sch : list2) {
  121 + if(!jhjghL.contains(sch.getjGh())){
  122 + jhjghL.add(sch.getjGh());
  123 + }
  124 + if(!jhjbhL.contains(sch.getClZbh())){
  125 + jhjbhL.add(sch.getClZbh());
  126 + }
  127 + }
  128 + List<Object> jh=new ArrayList<>();
  129 + jh.add(culateService.culateJhbc(list, ""));//计划班次
  130 + jh.add(jhjghL.size());
  131 + jh.add(jhjbhL.size());
  132 + jh.add(Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划总里程
  133 + jh.add(culateService.culateJhgl(list));//计划营运里程
  134 + jh.add(culateService.culateJhJccgl(list));//计划非营运里程
  135 +
  136 + result.add(sj);
  137 + result.add(jh);
  138 + return result;
  139 + }
  140 +
  141 +}