Commit 235080b44846ff6c407cf5a1a0e0c7437a068503

Authored by 娄高锋
1 parent 7b024f9f

路单年报、月报表中,无路单的油耗电耗没有被统计的问题。

src/main/java/com/bsth/repository/calc/CalcWaybillRepository.java
1 package com.bsth.repository.calc; 1 package com.bsth.repository.calc;
2 2
  3 +import java.util.Date;
3 import java.util.List; 4 import java.util.List;
4 5
5 import javax.transaction.Transactional; 6 import javax.transaction.Transactional;
6 7
7 import com.bsth.entity.calc.CalcWaybill; 8 import com.bsth.entity.calc.CalcWaybill;
  9 +import com.bsth.entity.oil.Dlb;
  10 +import com.bsth.entity.oil.Ylb;
8 import com.bsth.entity.realcontrol.ScheduleRealInfo; 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
9 import com.bsth.repository.BaseRepository; 12 import com.bsth.repository.BaseRepository;
10 13
@@ -90,4 +93,15 @@ public interface CalcWaybillRepository extends BaseRepository<CalcWaybill, Integ @@ -90,4 +93,15 @@ public interface CalcWaybillRepository extends BaseRepository<CalcWaybill, Integ
90 "and c.xl in (select l.lineCode from Line l where l.destroy in (?6)) order by c.fgsdm,c.xl,c.rqStr") 93 "and c.xl in (select l.lineCode from Line l where l.destroy in (?6)) order by c.fgsdm,c.xl,c.rqStr")
91 List<CalcWaybill> scheduleByDateAndLineTjPx(List<String> line,String date,String date2,List<String> gsdm,List<String> fgsdm, List<Integer> destroy); 94 List<CalcWaybill> scheduleByDateAndLineTjPx(List<String> line,String date,String date2,List<String> gsdm,List<String> fgsdm, List<Integer> destroy);
92 95
  96 + //路单没有的加油
  97 + @Query(value="select DISTINCT y from Ylb y left join CalcWaybill c on y.rq = c.rq and y.xlbm = c.xl and y.jsy = c.jGh and y.nbbm = c.cl " +
  98 + "where y.xlbm in(?1) and y.rq between ?2 and ?3 and y.ssgsdm in(?4) and y.fgsdm in(?5) and c.id is null " +
  99 + "and y.xlbm in (select l.lineCode from Line l where l.destroy in (?6))")
  100 + List<Ylb> ylbNotSchedule(List<String> line,Date date,Date date2,List<String> gsdm,List<String> fgsdm, List<Integer> destroy);
  101 +
  102 + //路单没有的加油
  103 + @Query(value="select DISTINCT d from Dlb d left join CalcWaybill c on d.rq = c.rq and d.xlbm = c.xl and d.jsy = c.jGh and d.nbbm = c.cl " +
  104 + "where d.xlbm in(?1) and d.rq between ?2 and ?3 and d.ssgsdm in(?4) and d.fgsdm in(?5) and c.id is null " +
  105 + "and d.xlbm in (select l.lineCode from Line l where l.destroy in (?6))")
  106 + List<Dlb> DlbNotSchedule(List<String> line,Date date,Date date2,List<String> gsdm,List<String> fgsdm, List<Integer> destroy);
93 } 107 }
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
@@ -12,6 +12,7 @@ import com.bsth.entity.calc.CalcLineMileage; @@ -12,6 +12,7 @@ import com.bsth.entity.calc.CalcLineMileage;
12 import com.bsth.entity.calc.CalcStatistics; 12 import com.bsth.entity.calc.CalcStatistics;
13 import com.bsth.entity.calc.CalcWaybill; 13 import com.bsth.entity.calc.CalcWaybill;
14 import com.bsth.entity.calc.CalcWaybillDetail; 14 import com.bsth.entity.calc.CalcWaybillDetail;
  15 +import com.bsth.entity.oil.Cwjy;
15 import com.bsth.entity.oil.Dlb; 16 import com.bsth.entity.oil.Dlb;
16 import com.bsth.entity.oil.Ylb; 17 import com.bsth.entity.oil.Ylb;
17 import com.bsth.entity.realcontrol.ChildTaskPlan; 18 import com.bsth.entity.realcontrol.ChildTaskPlan;
@@ -1902,6 +1903,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -1902,6 +1903,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1902 1903
1903 @Override 1904 @Override
1904 public List<List<String>> calcDetailMonthly(Map<String, Object> map) { 1905 public List<List<String>> calcDetailMonthly(Map<String, Object> map) {
  1906 + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
1905 List<Integer> destroy= new ArrayList<>(); 1907 List<Integer> destroy= new ArrayList<>();
1906 String destroyStr = ""; 1908 String destroyStr = "";
1907 if(map.get("destroy")!=null){ 1909 if(map.get("destroy")!=null){
@@ -1959,18 +1961,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -1959,18 +1961,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1959 if(map.get("itemDetails")!=null){ 1961 if(map.get("itemDetails")!=null){
1960 itemDetails=map.get("itemDetails").toString().trim(); 1962 itemDetails=map.get("itemDetails").toString().trim();
1961 } 1963 }
1962 -// Boolean item=false;  
1963 - /*String item="";  
1964 - if(map.get("item")!=null){  
1965 - if("dh".equals(map.get("item").toString().trim()))  
1966 - item=" where c.sfdc = 1";  
1967 -// item=false;  
1968 - else if ("dh".equals(map.get("item").toString().trim()))  
1969 - item=" where c.sfdc = 0";  
1970 -// item=true;  
1971 - else  
1972 - item="";  
1973 - }*/  
1974 String timeType=map.get("timeType").toString().trim(); 1964 String timeType=map.get("timeType").toString().trim();
1975 1965
1976 List<List<String>> resList = new ArrayList<>(); 1966 List<List<String>> resList = new ArrayList<>();
@@ -2016,17 +2006,116 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -2016,17 +2006,116 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
2016 } else if("xl".equals(statisticalObj)){ 2006 } else if("xl".equals(statisticalObj)){
2017 flag = 4; 2007 flag = 4;
2018 list = calcRepository.scheduleByDateAndLineTjPx(line,startDate,endDate,gsdm,fgsdm, destroy); 2008 list = calcRepository.scheduleByDateAndLineTjPx(line,startDate,endDate,gsdm,fgsdm, destroy);
2019 - /*if(line.equals("")){  
2020 - //查询所有线路  
2021 - }else{  
2022 - //查询单条线路  
2023 - list = calcRepository.scheduleByDateAndLineTjPx2(line,startDate,endDate);  
2024 - }*/  
2025 } 2009 }
2026 2010
2027 2011
2028 // List类转换 2012 // List类转换
2029 final List<CalcWaybillDetail> listNew = JSONArray.parseArray(JSON.toJSONString(list), CalcWaybillDetail.class); 2013 final List<CalcWaybillDetail> listNew = JSONArray.parseArray(JSON.toJSONString(list), CalcWaybillDetail.class);
  2014 +
  2015 + try {
  2016 + List<Ylb> ylbNotSchedule = calcRepository.ylbNotSchedule(line, dateFormat.parse(startDate), dateFormat.parse(endDate), gsdm, fgsdm, destroy);
  2017 + List<Dlb> dlbNotSchedule = calcRepository.DlbNotSchedule(line, dateFormat.parse(startDate), dateFormat.parse(endDate), gsdm, fgsdm, destroy);
  2018 + for(Ylb y : ylbNotSchedule){
  2019 + Date ylbrq = y.getRq();
  2020 + String ylbxl = y.getXlbm();
  2021 + String ylbgs = y.getSsgsdm();
  2022 + String ylbfgs = y.getFgsdm();
  2023 + boolean f = false;
  2024 + int l = listNew.size();
  2025 + for(int i = 0; i < listNew.size(); i++){
  2026 + CalcWaybillDetail cw = listNew.get(i);
  2027 + if(ylbrq.getTime() == cw.getRq().getTime()
  2028 + && ylbgs.equals(cw.getGsdm())
  2029 + && ylbfgs.equals(cw.getFgsdm())
  2030 + && ylbxl.equals(cw.getXl())){
  2031 + f = true;
  2032 + l = i;
  2033 + break;
  2034 + }
  2035 + }
  2036 + if(f){
  2037 + CalcWaybillDetail cw = listNew.get(l);
  2038 + CalcWaybillDetail cNew = new CalcWaybillDetail();
  2039 + cNew.setRq(cw.getRq());
  2040 + cNew.setRqStr(cw.getRqStr());
  2041 + cNew.setXl(cw.getXl());
  2042 + cNew.setXlName(cw.getXlName());
  2043 + cNew.setGsdm(cw.getGsdm());
  2044 + cNew.setGsname(cw.getGsname());
  2045 + cNew.setFgsdm(cw.getFgsdm());
  2046 + cNew.setFgsname(cw.getFgsname());
  2047 + cNew.setCl(y.getNbbm());
  2048 + cNew.setjGh(y.getJsy());
  2049 + cNew.setjName(BasicData.allPerson.get(y.getSsgsdm()+"-"+y.getJsy()));
  2050 + listNew.add(l+1, cNew);
  2051 + } else {
  2052 + CalcWaybillDetail cNew = new CalcWaybillDetail();
  2053 + cNew.setRq(ylbrq);
  2054 + cNew.setRqStr(dateFormat.format(ylbrq));
  2055 + cNew.setXl(ylbxl);
  2056 + cNew.setXlName(BasicData.lineCodeAllNameMap.get(ylbxl));
  2057 + cNew.setGsdm(y.getSsgsdm());
  2058 + cNew.setGsname(BasicData.businessCodeNameMap.get(y.getSsgsdm()));
  2059 + cNew.setFgsdm(y.getFgsdm());
  2060 + cNew.setFgsname(BasicData.businessFgsCodeNameMap.get(y.getFgsdm()+"_"+y.getFgsdm()));
  2061 + cNew.setCl(y.getNbbm());
  2062 + cNew.setjGh(y.getJsy());
  2063 + cNew.setjName(BasicData.allPerson.get(y.getSsgsdm()+"-"+y.getJsy()));
  2064 + listNew.add(listNew.size(), cNew);
  2065 + }
  2066 + }
  2067 + for(Dlb d : dlbNotSchedule){
  2068 + Date dlbrq = d.getRq();
  2069 + String dlbxl = d.getXlbm();
  2070 + String dlbgs = d.getSsgsdm();
  2071 + String dlbfgs = d.getFgsdm();
  2072 + boolean f = false;
  2073 + int l = listNew.size();
  2074 + for(int i = 0; i < listNew.size(); i++){
  2075 + CalcWaybillDetail cw = listNew.get(i);
  2076 + if(dlbrq.getTime() == cw.getRq().getTime()
  2077 + && dlbgs.equals(cw.getGsdm())
  2078 + && dlbfgs.equals(cw.getFgsdm())
  2079 + && dlbxl.equals(cw.getXl())){
  2080 + f = true;
  2081 + l = i;
  2082 + break;
  2083 + }
  2084 + }
  2085 + if(f){
  2086 + CalcWaybillDetail cw = listNew.get(l);
  2087 + CalcWaybillDetail cNew = new CalcWaybillDetail();
  2088 + cNew.setRq(cw.getRq());
  2089 + cNew.setRqStr(cw.getRqStr());
  2090 + cNew.setXl(cw.getXl());
  2091 + cNew.setXlName(cw.getXlName());
  2092 + cNew.setGsdm(cw.getGsdm());
  2093 + cNew.setGsname(cw.getGsname());
  2094 + cNew.setFgsdm(cw.getFgsdm());
  2095 + cNew.setFgsname(cw.getFgsname());
  2096 + cNew.setCl(d.getNbbm());
  2097 + cNew.setjGh(d.getJsy());
  2098 + cNew.setjName(BasicData.allPerson.get(d.getSsgsdm()+"-"+d.getJsy()));
  2099 + listNew.add(l+1, cNew);
  2100 + } else {
  2101 + CalcWaybillDetail cNew = new CalcWaybillDetail();
  2102 + cNew.setRq(dlbrq);
  2103 + cNew.setRqStr(dateFormat.format(dlbrq));
  2104 + cNew.setXl(dlbxl);
  2105 + cNew.setXlName(BasicData.lineCodeAllNameMap.get(dlbxl));
  2106 + cNew.setGsdm(d.getSsgsdm());
  2107 + cNew.setGsname(BasicData.businessCodeNameMap.get(d.getSsgsdm()));
  2108 + cNew.setFgsdm(d.getFgsdm());
  2109 + cNew.setFgsname(BasicData.businessFgsCodeNameMap.get(d.getFgsdm()+"_"+d.getFgsdm()));
  2110 + cNew.setCl(d.getNbbm());
  2111 + cNew.setjGh(d.getJsy());
  2112 + cNew.setjName(BasicData.allPerson.get(d.getSsgsdm()+"-"+d.getJsy()));
  2113 + listNew.add(listNew.size(), cNew);
  2114 + }
  2115 + }
  2116 + } catch (Exception e) {
  2117 + // TODO: handle exception
  2118 + }
2030 2119
2031 if(listNew.size() <= 0){ 2120 if(listNew.size() <= 0){
2032 return resList; 2121 return resList;
@@ -2052,11 +2141,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -2052,11 +2141,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
2052 linesql +=" and fgsdm in("+fgsdmStr+") "; 2141 linesql +=" and fgsdm in("+fgsdmStr+") ";
2053 } 2142 }
2054 String ylsql="SELECT * FROM bsth_c_ylb" 2143 String ylsql="SELECT * FROM bsth_c_ylb"
2055 -// String ylsql="SELECT id,xlbm,nbbm,jsy,jzl,czyl,jzyl,yh,sh,fgsdm FROM bsth_c_ylb"  
2056 + " WHERE rq >= '"+startDate+"' and rq <= '"+endDate+"' " 2144 + " WHERE rq >= '"+startDate+"' and rq <= '"+endDate+"' "
2057 + linesql; 2145 + linesql;
2058 String dlSal= " SELECT * FROM bsth_c_dlb" 2146 String dlSal= " SELECT * FROM bsth_c_dlb"
2059 -// String dlSal= " SELECT id,xlbm,nbbm,jsy,cdl,czcd,jzcd,hd,sh,fgsdm FROM bsth_c_dlb"  
2060 + " WHERE rq >= '"+startDate+"' and rq <= '"+endDate+"' " 2147 + " WHERE rq >= '"+startDate+"' and rq <= '"+endDate+"' "
2061 + linesql; 2148 + linesql;
2062 List<Ylb> ylbList = jdbcTemplate.query(ylsql, new RowMapper<Ylb>() { 2149 List<Ylb> ylbList = jdbcTemplate.query(ylsql, new RowMapper<Ylb>() {
@@ -2121,9 +2208,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -2121,9 +2208,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
2121 yo.setYh(Arith.add(yo.getYh(),y.getYh())); 2208 yo.setYh(Arith.add(yo.getYh(),y.getYh()));
2122 } else 2209 } else
2123 ylbMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getNbbm(),y); 2210 ylbMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getNbbm(),y);
2124 -  
2125 -// ylbMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getJsy()+"_"+y.getJname()+"_"+y.getNbbm(),y);  
2126 -// ylbCLMap.put(y.getRq().getTime()+"_"+y.getXlbm()+"_"+y.getNbbm(),y);  
2127 } 2211 }
2128 for (Dlb d:dlbList) { 2212 for (Dlb d:dlbList) {
2129 if(dlbMap.containsKey(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm())){ 2213 if(dlbMap.containsKey(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm())){
@@ -2135,8 +2219,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -2135,8 +2219,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
2135 dold.setCdl(Arith.add(dold.getCdl(),d.getCdl())); 2219 dold.setCdl(Arith.add(dold.getCdl(),d.getCdl()));
2136 } else 2220 } else
2137 dlbMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm(),d); 2221 dlbMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getNbbm(),d);
2138 -// dlbMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getJsy()+"_"+d.getJname()+"_"+d.getNbbm(),d);  
2139 -// dlbCLMap.put(d.getRq().getTime()+"_"+d.getXlbm()+"_"+d.getNbbm(),d);  
2140 } 2222 }
2141 } 2223 }
2142 2224