Commit b7fe348a522985c9ae94de7ea9a9158125797da0

Authored by mcy123
1 parent d40f83dd

mcy

src/main/java/com/bsth/service/forms/CommonService.java 0 → 100644
  1 +package com.bsth.service.forms;
  2 +
  3 +import java.util.Map;
  4 +
  5 +import org.springframework.stereotype.Service;
  6 +
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import com.bsth.service.BaseService;
  9 +
  10 +@Service
  11 +public interface CommonService{
  12 +
  13 + Map<String,Object> findKMBC1(String jName,String clZbh, String date,String enddate);
  14 +
  15 + Map<String,Object> findKMBC2(String jName,String clZbh,String date);
  16 +}
... ...
src/main/java/com/bsth/service/forms/impl/CommonServiceImpl.java 0 → 100644
  1 +package com.bsth.service.forms.impl;
  2 +
  3 +import java.text.DecimalFormat;
  4 +import java.util.HashMap;
  5 +import java.util.Iterator;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +import java.util.Set;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Service;
  11 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  12 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  13 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  14 +import com.bsth.service.forms.CommonService;
  15 +
  16 +@Service
  17 +public class CommonServiceImpl implements CommonService{
  18 +
  19 +
  20 + @Autowired
  21 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  22 +
  23 + @Override
  24 + public Map<String, Object> findKMBC1(String jName, String clZbh,
  25 + String date, String enddate) {
  26 +
  27 + String sql=" select s from bsth_c_s_sp_info_real s "
  28 + + " where s.j_gh ='" + jName + "' and s.cl_zbh ='" + clZbh + "' and "
  29 + + " to_days(s.schedule_date) BETWEEN to_days('" + date + "') and to_days('" + enddate + "')"
  30 + + " order by bcs";
  31 +
  32 +
  33 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);
  34 + DecimalFormat format = new DecimalFormat("0.00");
  35 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  36 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  37 + int jhbc = 0,cjbc = 0,ljbc = 0;
  38 + double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
  39 + float addMileage = 0l,remMileage = 0l;
  40 + Map<String,Object> map = new HashMap<String, Object>();
  41 + for(ScheduleRealInfo scheduleRealInfo : list){
  42 + if(scheduleRealInfo != null){
  43 + //计划里程(主任务过滤掉临加班次),
  44 + //烂班里程(主任务烂班),
  45 + //临加里程(主任务临加),
  46 + //计划班次,烂班班次,增加班次
  47 + tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  48 + if(scheduleRealInfo.isSflj()){
  49 + addMileage += tempJhlc;
  50 + ljbc++;
  51 + }else{
  52 + jhlc += tempJhlc;
  53 + jhbc++;
  54 + if(scheduleRealInfo.getStatus() == -1){
  55 + remMileage += tempJhlc;
  56 + cjbc++;
  57 + }
  58 + }
  59 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  60 + //计算营运里程,空驶里程
  61 + if(childTaskPlans.isEmpty()){
  62 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  63 + || scheduleRealInfo.getBcType().equals("venting")){
  64 + ksgl += tempJhlc;
  65 + }else{
  66 + yygl += tempJhlc;
  67 + }
  68 + }else{
  69 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  70 + while(it.hasNext()){
  71 + ChildTaskPlan childTaskPlan = it.next();
  72 + if(childTaskPlan.getMileageType().equals("empty")){
  73 + ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  74 + }else{
  75 + yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  76 + }
  77 + }
  78 + }
  79 + }
  80 + }
  81 + map.put("jhlc", format.format(jhlc));
  82 + map.put("remMileage", format.format(remMileage));
  83 + map.put("addMileage", format.format(addMileage));
  84 + map.put("yygl", format.format(yygl));
  85 + map.put("ksgl", format.format(ksgl));
  86 + map.put("realMileage", format.format(yygl+ksgl));
  87 + map.put("jhbc", jhbc);
  88 + map.put("cjbc", cjbc);
  89 + map.put("ljbc", ljbc);
  90 + map.put("sjbc", jhbc-cjbc+ljbc);
  91 + return map;
  92 + }
  93 +
  94 +
  95 + @Override
  96 + public Map<String, Object> findKMBC2(String jName, String clZbh,String date) {
  97 +
  98 + String sql=" select s from bsth_c_s_sp_info_real s "
  99 + + " where s.j_gh ='" + jName + "' and s.cl_zbh ='" + clZbh + "' and "
  100 + + " to_days(s.schedule_date) =to_days('" + date + "')"
  101 + + " order by bcs";
  102 +
  103 +
  104 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh , date);
  105 +
  106 + DecimalFormat format = new DecimalFormat("0.00");
  107 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  108 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  109 + int jhbc = 0,cjbc = 0,ljbc = 0;
  110 + double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
  111 + float addMileage = 0l,remMileage = 0l;
  112 + String j_Name="";
  113 + Map<String,Object> map = new HashMap<String, Object>();
  114 + for(ScheduleRealInfo scheduleRealInfo : list){
  115 + if(scheduleRealInfo != null){
  116 + j_Name=scheduleRealInfo.getjName();
  117 + //计划里程(主任务过滤掉临加班次),
  118 + //烂班里程(主任务烂班),
  119 + //临加里程(主任务临加),
  120 + //计划班次,烂班班次,增加班次
  121 + tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  122 + if(scheduleRealInfo.isSflj()){
  123 + addMileage += tempJhlc;
  124 + ljbc++;
  125 + }else{
  126 + jhlc += tempJhlc;
  127 + jhbc++;
  128 + if(scheduleRealInfo.getStatus() == -1){
  129 + remMileage += tempJhlc;
  130 + cjbc++;
  131 + }
  132 + }
  133 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  134 + //计算营运里程,空驶里程
  135 + if(childTaskPlans.isEmpty()){
  136 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  137 + || scheduleRealInfo.getBcType().equals("venting")){
  138 + ksgl += tempJhlc;
  139 + }else{
  140 + yygl += tempJhlc;
  141 + }
  142 + }else{
  143 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  144 + while(it.hasNext()){
  145 + ChildTaskPlan childTaskPlan = it.next();
  146 + if(childTaskPlan.getMileageType().equals("empty")){
  147 + ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  148 + }else{
  149 + yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  150 + }
  151 + }
  152 + }
  153 + }
  154 + }
  155 + map.put("j_name", j_Name);
  156 + map.put("jhlc", format.format(jhlc));
  157 + map.put("remMileage", format.format(remMileage));
  158 + map.put("addMileage", format.format(addMileage));
  159 + map.put("yygl", format.format(yygl));
  160 + map.put("ksgl", format.format(ksgl));
  161 + map.put("realMileage", format.format(yygl+ksgl));
  162 + map.put("jhbc", jhbc);
  163 + map.put("cjbc", cjbc);
  164 + map.put("ljbc", ljbc);
  165 + map.put("sjbc", jhbc-cjbc+ljbc);
  166 + return map;
  167 + }
  168 +
  169 +
  170 +
  171 +
  172 +}
... ...