Commit 02439161f133dcba1d52ac96776dba63f9f291f0

Authored by ljq
1 parent 8424a9c4

C

src/main/java/com/bsth/service/oil/impl/DlbServiceImpl.java deleted 100644 → 0
1 -package com.bsth.service.oil.impl;  
2 -  
3 -  
4 -  
5 -import java.sql.ResultSet;  
6 -import java.sql.SQLException;  
7 -import java.text.DecimalFormat;  
8 -import java.text.ParseException;  
9 -import java.text.SimpleDateFormat;  
10 -import java.util.ArrayList;  
11 -import java.util.Calendar;  
12 -import java.util.Collections;  
13 -import java.util.Comparator;  
14 -import java.util.Date;  
15 -import java.util.HashMap;  
16 -import java.util.Iterator;  
17 -import java.util.List;  
18 -import java.util.Map;  
19 -  
20 -import javax.transaction.Transactional;  
21 -  
22 -import org.apache.commons.lang3.StringEscapeUtils;  
23 -import org.apache.commons.lang3.StringUtils;  
24 -import org.slf4j.Logger;  
25 -import org.slf4j.LoggerFactory;  
26 -import org.springframework.beans.factory.annotation.Autowired;  
27 -import org.springframework.data.domain.Sort;  
28 -import org.springframework.data.domain.Sort.Direction;  
29 -import org.springframework.jdbc.core.JdbcTemplate;  
30 -import org.springframework.jdbc.core.RowMapper;  
31 -import org.springframework.stereotype.Service;  
32 -  
33 -import com.alibaba.fastjson.JSONArray;  
34 -import com.alibaba.fastjson.JSONObject;  
35 -import com.bsth.common.ResponseCode;  
36 -import com.bsth.data.BasicData;  
37 -import com.bsth.entity.Cars;  
38 -import com.bsth.entity.Line;  
39 -import com.bsth.entity.oil.Cdl;  
40 -import com.bsth.entity.oil.Cyl;  
41 -import com.bsth.entity.oil.Dlb;  
42 -import com.bsth.entity.oil.Jdl;  
43 -import com.bsth.entity.oil.Nylog;  
44 -import com.bsth.entity.oil.Ylxxb;  
45 -import com.bsth.entity.search.CustomerSpecs;  
46 -import com.bsth.entity.sys.SysUser;  
47 -import com.bsth.repository.CarsRepository;  
48 -import com.bsth.repository.oil.CdlRepository;  
49 -import com.bsth.repository.oil.CylRepository;  
50 -import com.bsth.repository.oil.DlbRepository;  
51 -import com.bsth.repository.oil.JdlRepository;  
52 -import com.bsth.repository.oil.NylogRepository;  
53 -import com.bsth.repository.oil.YlbRepository;  
54 -import com.bsth.repository.oil.YlxxbRepository;  
55 -import com.bsth.security.util.SecurityUtils;  
56 -import com.bsth.service.impl.BaseServiceImpl;  
57 -import com.bsth.service.oil.DlbService;  
58 -import com.bsth.service.realcontrol.ScheduleRealInfoService;  
59 -import com.bsth.util.Arith;  
60 -import com.bsth.util.BatchSaveUtils;  
61 -  
62 -@Service  
63 -public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbService{  
64 - @Autowired  
65 - DlbRepository repository;  
66 - @Autowired  
67 - NylogRepository nylogRepository;  
68 - @Autowired  
69 - YlxxbRepository ylxxbRepository;  
70 -  
71 - @Autowired  
72 - CdlRepository cdlRepository;  
73 - @Autowired  
74 - JdlRepository jdlRepository;  
75 - @Autowired  
76 - CarsRepository carsRepository;  
77 -  
78 - @Autowired  
79 - ScheduleRealInfoService scheduleRealInfoService;  
80 -  
81 - @Autowired  
82 - JdbcTemplate jdbcTemplate;  
83 -  
84 - Logger logger = LoggerFactory.getLogger(this.getClass());  
85 -  
86 - @Transactional  
87 - @Override  
88 - public String obtainDsq() throws Exception{  
89 - String result = "failure";  
90 - List<Cars> carsList=carsRepository.findCars();  
91 - Map<String, Boolean> carsMap=new HashMap<String, Boolean>();  
92 - for (int i = 0; i < carsList.size(); i++) {  
93 - Cars c=carsList.get(i);  
94 - carsMap.put(c.getInsideCode(), c.getSfdc());  
95 - }  
96 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
97 - Date dNow = new Date(); //当前时间  
98 - Date dBefore = new Date();  
99 - Calendar calendar = Calendar.getInstance(); //得到日历  
100 - calendar.setTime(dNow);//把当前时间赋给日历  
101 - calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天  
102 - dBefore = calendar.getTime(); //得到前一天的时间  
103 - String rq=sdf.format(dBefore);  
104 -// String rq="2017-11-02";  
105 - String line="";  
106 - //保留两位小数  
107 - DecimalFormat df = new DecimalFormat("#.00");  
108 - // TODO Auto-generated method stub  
109 - Map<String, Object> newMap=new HashMap<String,Object>();  
110 - //当天DLB信息  
111 - List<Dlb> dlList=repository.obtainDl(rq, "", "", line, "", "nbbm");  
112 - //当天YLXXB信息  
113 - List<Ylxxb> ylxxList=ylxxbRepository.obtainYlxx(rq,1,"");  
114 - //当天加电信息表  
115 - List<Jdl> jdlList=jdlRepository.JdlList(rq);  
116 - //前一天所有车辆最后进场班次信息  
117 -// List<Dlb> dlListBe=repository.obtainYlbefore(rq, "", "", "", "");  
118 - List<Cdl> cdyList=cdlRepository.obtainCdl();  
119 - //从排班表中计算出行驶的总里程  
120 - List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList(line,rq,"","","","");  
121 - for(int x=0;x<listpb.size();x++){  
122 - String type="add";  
123 - boolean sfdc=false;  
124 - Map<String, Object> map=listpb.get(x);  
125 - if (carsMap.get(map.get("clZbh").toString())!=null) {  
126 - sfdc= carsMap.get(map.get("clZbh").toString());  
127 - }else{  
128 - sfdc=false;  
129 - }  
130 - if(sfdc){  
131 - //判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断)  
132 - Dlb t=new Dlb();  
133 - for(int k=0;k<dlList.size();k++){  
134 - Dlb t1=dlList.get(k);  
135 - if(t1.getNbbm().equals(map.get("clZbh").toString())  
136 - &&t1.getJsy().equals(map.get("jGh").toString())  
137 - &&t1.getXlbm().equals(map.get("xlBm").toString())  
138 - &&t1.getLp().equals(map.get("lpName").toString()))  
139 - {  
140 - t=t1;  
141 - type="update";  
142 - }  
143 - }  
144 - try {  
145 - //当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
146 - Double jzl=0.0;  
147 - if(map.get("seqNumber").toString().equals("1")){  
148 - boolean fage=true;  
149 -// for (int i = 0; i < dlListBe.size(); i++) {  
150 -// Dlb dlb=dlListBe.get(i);  
151 -// if(map.get("clZbh").toString().equals(dlb.getNbbm())){  
152 -// t.setCzcd(dlb.getJzcd());  
153 -// fage=false;  
154 -// break;  
155 -// }  
156 -// }  
157 - if(fage){  
158 - for (int y = 0; y < cdyList.size(); y++) {  
159 - Cdl cdl=cdyList.get(y);  
160 - if(map.get("clZbh").toString().equals(cdl.getNbbm())){  
161 - t.setCzcd(cdl.getClcd()==null?0:cdl.getClcd());  
162 - fage=false;  
163 - break;  
164 - }  
165 - }  
166 - }  
167 - if(fage){  
168 - t.setCzcd(0.0);  
169 - }  
170 -  
171 - //手动导入没有驾驶员工号  
172 - for (int i = 0; i < jdlList.size(); i++) {  
173 - Jdl jdl=jdlList.get(i);  
174 - if(map.get("clZbh").toString().equals(jdl.getNbbm())  
175 - &&map.get("jGh").toString().equals(jdl.getJsy())){  
176 - jzl+=jdl.getJdl();  
177 - }  
178 - }  
179 - }  
180 -  
181 -  
182 - //把当天的YLXXB的加注量设置为当天YLB的加注量(根据车号,驾驶员判断)  
183 - for(int j=0;j<ylxxList.size();j++){  
184 - Ylxxb ylxxb= ylxxList.get(j);  
185 - if(map.get("clZbh").toString().equals(ylxxb.getNbbm()) &&map.get("jGh").toString().equals(ylxxb.getJsy())){  
186 - jzl+=ylxxb.getJzl();  
187 - }  
188 - }  
189 -  
190 - t.setCdl(jzl);  
191 - if(type.equals("add")){  
192 - t.setHd(jzl);  
193 - t.setJzcd(t.getCzcd());  
194 - }  
195 -  
196 - t.setNbbm(map.get("clZbh").toString());  
197 - t.setJsy(map.get("jGh")==null?"":map.get("jGh").toString());  
198 - t.setZlc(map.get("totalKilometers")==null?0.0:Double.parseDouble(df.format(Double.parseDouble(map.get("totalKilometers").toString()))));  
199 - t.setXlbm(map.get("xlBm")==null?"":map.get("xlBm").toString());  
200 - t.setLinename(map.get("lineName")==null?"":map.get("lineName").toString());  
201 - t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));  
202 - t.setSsgsdm(map.get("company")==null?"":map.get("company").toString());  
203 - t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());  
204 - t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());  
205 - t.setLp(map.get("lpName").toString());  
206 - t.setRq(sdf.parse(rq));  
207 - t.setCreatetime(new Date());  
208 - t.setJname(map.get("jName").toString());  
209 - /*if(type.equals("add")){  
210 - addList.add(t);  
211 - }else{  
212 - updateList.add(t);  
213 - }*/  
214 - repository.save(t);  
215 - newMap.put("status", ResponseCode.SUCCESS);  
216 - } catch (ParseException e) {  
217 - // TODO Auto-generated catch block  
218 - newMap.put("status", ResponseCode.ERROR);  
219 - e.printStackTrace();  
220 - }  
221 - }  
222 - }  
223 - return result;  
224 - }  
225 -  
226 - /**  
227 - * 获取进存油信息  
228 - * @Transactional 回滚事物  
229 - */  
230 - @Transactional  
231 - @Override  
232 - public Map<String, Object> obtain(Map<String, Object> map2) throws Exception{  
233 - Map<String, Object> newMap = new HashMap<String, Object>();  
234 - try {  
235 - Date date=new Date();  
236 - List<Cars> carsList = carsRepository.findCars();  
237 - Map<String, Boolean> carsMap = new HashMap<String, Boolean>();  
238 - for (int i = 0; i < carsList.size(); i++) {  
239 - Cars c = carsList.get(i);  
240 - carsMap.put(c.getInsideCode(), c.getSfdc());  
241 - }  
242 - String rq = map2.get("rq").toString();  
243 - String line = "";  
244 - if (map2.get("xlbm_like") != null) {  
245 - line = map2.get("xlbm_like").toString().trim();  
246 - }  
247 - String gsbm="";  
248 - if(map2.get("ssgsdm_like")!=null){  
249 - gsbm=map2.get("ssgsdm_like").toString();  
250 - }  
251 - String fgsbm="";  
252 - if(map2.get("fgsdm_like")!=null){  
253 - fgsbm=map2.get("fgsdm_like").toString();  
254 - }  
255 - String nbbm="";  
256 - if(map2.get("nbbm_eq")!=null){  
257 - nbbm=map2.get("nbbm_eq").toString();  
258 - }  
259 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
260 - // 保留两位小数  
261 - DecimalFormat df = new DecimalFormat("#.00");  
262 - // TODO Auto-generated method stub  
263 - // 当天DLB信息  
264 - List<Dlb> dlList = this.listOrderBy(rq,gsbm,fgsbm,"",nbbm,"nbbm");  
265 - // 当天YLXXB信息  
266 - List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(rq, 0,gsbm);  
267 - // 从排班表中计算出行驶的总里程  
268 - List<Map<String, Object>> listpb =new ArrayList<Map<String, Object>>();  
269 - List<Map<String, Object>> listpbs=scheduleRealInfoService.yesterdayDataList("", rq, gsbm, fgsbm, "", nbbm);  
270 - Map<String, Double> lcMap=new HashMap<String,Double>();  
271 - for (int i = 0; i < listpbs.size(); i++) {  
272 - String cl=listpbs.get(i).get("clZbh").toString();  
273 - Double lc= listpbs.get(i).get("totalKilometers") == null ? 0.0  
274 - : Double.parseDouble(listpbs.get(i).get("totalKilometers").toString());  
275 - if(lcMap.get(cl)==null){  
276 - lcMap.put(cl, lc);  
277 - }else{  
278 - double lc_=lcMap.get(cl);  
279 - lcMap.remove(cl);  
280 - lcMap.put(cl, Arith.add(lc, lc_));  
281 - }  
282 - }  
283 -  
284 -// Map<String, Double> shMap=new HashMap<String,Double>();  
285 -// for (int i = 0; i < dlList.size(); i++) {  
286 -// Dlb dlb=dlList.get(i);  
287 -// String cl=dlb.getNbbm();  
288 -// if(shMap.get(cl)==null){  
289 -// shMap.put(cl, dlb.getSh());  
290 -// }else{  
291 -// double sh=shMap.get(cl);  
292 -// shMap.remove(cl);  
293 -// shMap.put(cl, Arith.add(sh, dlb.getSh()));  
294 -// }  
295 -// }  
296 - List<Jdl> jdlList=jdlRepository.JdlList(rq);  
297 - String sxtj=map2.get("sxtj").toString();  
298 - if(sxtj.equals("0")){  
299 - listpb=listpbs;  
300 - }else{  
301 - List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, "",nbbm);  
302 - List<String> stringList=new ArrayList<String>();  
303 - for (int i = 0; i < objectLists.size(); i++) {  
304 - String clbm=objectLists.get(i)[0].toString();  
305 - int cs=Integer.parseInt(objectLists.get(i)[1].toString());  
306 - //一车一单  
307 - if(sxtj.equals("1")){  
308 - if(cs==1){  
309 - stringList.add(clbm);  
310 - }  
311 - }  
312 - //一车多单  
313 - if(sxtj.equals("2")){  
314 - if(cs>1){  
315 - stringList.add(clbm);  
316 - }  
317 - }  
318 - }  
319 -  
320 - for (int i = 0; i < stringList.size(); i++) {  
321 - String strNbbm=stringList.get(i);  
322 - for (int j = 0; j < listpbs.size(); j++) {  
323 - Map<String, Object> map = listpbs.get(j);  
324 - String mapNbbm=map.get("clZbh").toString();  
325 - if(strNbbm.equals(mapNbbm)){  
326 - listpb.add(map);  
327 - }  
328 - }  
329 - }  
330 - }  
331 - Map<String, Object> newMap_=new HashMap<String,Object>();  
332 - List<Dlb> addList = new ArrayList<Dlb>();  
333 - List<Dlb> updateList = new ArrayList<Dlb>();  
334 - Map<String, Object> cMap=new HashMap<String, Object>();  
335 - List<Map<String, Object>> listpb_=listpb;  
336 - Collections.sort(listpb,new NbbmJcsxMap());  
337 - for (int x = 0; x < listpb_.size(); x++) {  
338 - String type = "add";  
339 - boolean sfdc = false;  
340 - Map<String, Object> map_ = listpb_.get(x);  
341 - if (carsMap.get(map_.get("clZbh").toString()) != null) {  
342 - sfdc = carsMap.get(map_.get("clZbh").toString());  
343 - } else {  
344 - sfdc = false;  
345 - }  
346 - if (sfdc) {  
347 - if(newMap_.get(map_.get("clZbh").toString())==null){  
348 - newMap_.put(map_.get("clZbh").toString(), map_.get("clZbh").toString());  
349 - //车辆总里程  
350 - double zlc =lcMap.get(map_.get("clZbh").toString());  
351 - //车辆总加电量  
352 - double zjzl = 0.0;  
353 - for (int j = 0; j < ylxxList.size(); j++) {  
354 - Ylxxb ylxxb = ylxxList.get(j);  
355 - if (map_.get("clZbh").toString().equals(ylxxb.getNbbm())  
356 - && map_.get("company").toString().equals(ylxxb.getGsdm())) {  
357 - zjzl = Arith.add(zjzl, ylxxb.getJzl());  
358 - }  
359 - }  
360 - for (int i = 0; i < jdlList.size(); i++) {  
361 - Jdl jdl=jdlList.get(i);  
362 - if(map_.get("clZbh").toString().equals(jdl.getNbbm())  
363 - &&map_.get("company").toString().equals(jdl.getGsBm())  
364 - &&map_.get("bCompany").toString().equals(jdl.getFgsBm())){  
365 - zjzl = Arith.add(zjzl,jdl.getJdl());  
366 - }  
367 - }  
368 -// double clsh=0.0;  
369 -// if(shMap.get(map_.get("clZbh").toString())==null){  
370 -// clsh=0.0;  
371 -// }else{  
372 -// clsh=shMap.get(map_.get("clZbh").toString());  
373 -// }  
374 -// zjzl =Arith.sub(zjzl, clsh);  
375 - Double nextJzyl = 0.0;  
376 - for (int i = 0; i < listpb.size(); i++) {  
377 - Map<String, Object> map = listpb.get(i);  
378 - if(map_.get("clZbh").toString().equals(map.get("clZbh").toString())){  
379 - // 判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断)  
380 - Dlb t = new Dlb();  
381 - for (int k = 0; k < dlList.size(); k++) {  
382 - Dlb t1 = dlList.get(k);  
383 - if (t1.getNbbm().equals(map.get("clZbh").toString())  
384 - && t1.getJsy().equals(map.get("jGh").toString())  
385 - && t1.getXlbm().equals(map.get("xlBm").toString())) {  
386 - if(t1.getLp()==null){  
387 - //同人同车同线路不同路牌的过滤 (考虑到历史数据)  
388 - if (cMap.get(map.get("clZbh").toString()+map.get("jGh").toString()+map.get("xlBm").toString())==null) {  
389 - t = t1;  
390 - type = "update";  
391 - cMap.put(map.get("clZbh").toString()+map.get("jGh").toString()+map.get("xlBm").toString(),  
392 - map.get("clZbh").toString());  
393 - }  
394 - }else{  
395 - if(t1.getLp().equals(map.get("lpName").toString())){  
396 - t = t1;  
397 - type = "update";  
398 - }  
399 -  
400 - }  
401 - }  
402 - }  
403 - Double lc= Double.parseDouble(map.get("totalKilometers").toString());  
404 - if(map.get("seqNumber").toString().equals("1")){  
405 - // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
406 - Double dh=0.0;  
407 - if(zlc>0){  
408 - dh = Double.parseDouble(df.format(zjzl * (lc / zlc)));  
409 - }  
410 - nextJzyl =Arith.sub(zjzl,dh);  
411 - if(zlc>0){  
412 -// long l=Math.round(nextJzyl);  
413 - double ylxs=nextJzyl;  
414 - dh=Arith.add(dh, Arith.sub(nextJzyl,ylxs));  
415 - if(dh<0){  
416 - t.setHd(0.0);  
417 - t.setCdl(0.0);  
418 - nextJzyl=Arith.add(ylxs, dh);  
419 - }else{  
420 - t.setHd(dh);  
421 - t.setCdl(dh);  
422 - nextJzyl=ylxs;  
423 - }  
424 - }else{  
425 - t.setHd(0.0);  
426 - t.setCdl(0.0);  
427 - }  
428 - }else{  
429 - Double dh=0.0;  
430 - if(zlc>0){  
431 - dh = Double.parseDouble(df.format(zjzl * (lc / zlc)));  
432 - }  
433 - nextJzyl =Arith.sub( nextJzyl,dh);  
434 - if(zlc>0){  
435 -// long l=0l;  
436 - double ylxs=0.0;  
437 - if(i==listpb.size()-1){  
438 -// ylxs=czyl;  
439 - }else{  
440 - if(listpb.get(i+1).get("clZbh").toString().equals(map.get("clZbh").toString())){  
441 -// l=Math.round(nextJzyl);  
442 - ylxs=nextJzyl;  
443 - }  
444 -  
445 - }  
446 - dh=Arith.add(dh, Arith.sub(nextJzyl,ylxs));  
447 - if(dh<0){  
448 - t.setHd(0.0);  
449 - t.setCdl(0.0);  
450 - nextJzyl=Arith.add(ylxs, dh);  
451 - }else{  
452 - t.setHd(dh);  
453 - t.setCdl(dh);  
454 - nextJzyl=ylxs;  
455 - }  
456 - }else{  
457 - t.setHd(0.0);  
458 - t.setCdl(0.0);  
459 - }  
460 - }  
461 - t.setCzcd(100.0);  
462 - t.setJzcd(100.0);  
463 - t.setNbbm(map.get("clZbh").toString());  
464 - t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString());  
465 - t.setZlc(map.get("totalKilometers") == null ? 0.0  
466 - : Double.parseDouble(map.get("totalKilometers").toString()));  
467 - t.setXlbm(map.get("xlBm") == null ? "" : map.get("xlBm").toString());  
468 - t.setLinename(map.get("lineName")==null?"":map.get("lineName").toString());  
469 - t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));  
470 - t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString());  
471 - t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());  
472 - t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());  
473 - t.setRq(sdf.parse(rq));  
474 - t.setLp(map.get("lpName").toString());  
475 - t.setJname(map.get("jName").toString());  
476 - if (!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))) {  
477 - if (t.getHd() < 0) {  
478 - t.setHd(0.0);  
479 - }  
480 - if (t.getCdl() < 0) {  
481 - t.setCdl(0.0);  
482 - }  
483 - if (type.equals("add")) {  
484 - t.setCreatetime(date);  
485 - addList.add(t);  
486 - } else {  
487 - t.setUpdatetime(date);  
488 - updateList.add(t);  
489 - }  
490 - }  
491 - newMap.put("status", ResponseCode.SUCCESS);  
492 - }  
493 - }  
494 - }  
495 - }  
496 - }  
497 - if(addList.size()>0){  
498 - try {  
499 - new BatchSaveUtils<Dlb>().saveList2(addList, Dlb.class);  
500 - } catch (Exception e) {  
501 - // TODO: handle exception  
502 - if(e.getMessage().indexOf("PK_DLB_UK")>0){  
503 - newMap.put("fage", "存在相同数据,数据已经过滤");  
504 - logger.info("获取:存在相同数据,数据已经过滤");  
505 - }  
506 - }  
507 -  
508 - }  
509 -  
510 - if(updateList.size()>0){  
511 - for (int i = 0; i < updateList.size(); i++) {  
512 - repository.save(updateList.get(i));  
513 - }  
514 - }  
515 - SysUser user = SecurityUtils.getCurrentUser();  
516 - Nylog nylog=new Nylog();  
517 - nylog.setCreatedate(new Date());  
518 - nylog.setCzmc("获取");  
519 - nylog.setNylx("电");  
520 - nylog.setUserid(user.getUserName());  
521 - nylog.setUsername(user.getName());  
522 - nylog.setCxtj(line+"-"+ date+"-"+gsbm+"-"+fgsbm);  
523 - nylogRepository.save(nylog);  
524 - newMap.put("status", ResponseCode.SUCCESS);  
525 - } catch (Exception e) {  
526 - // TODO Auto-generated catch block  
527 - newMap.put("status", ResponseCode.ERROR);  
528 - throw e;  
529 - }  
530 -  
531 - return newMap;  
532 - }  
533 -  
534 - /**  
535 - * 拆分  
536 - */  
537 - @Transactional  
538 - @Override  
539 - public Map<String, Object> sort(Map<String, Object> map) {  
540 - // TODO Auto-generated method stub  
541 - Map<String, Object> newMap = new HashMap<String, Object>();  
542 - try{  
543 - int id=Integer.parseInt(map.get("id").toString());  
544 - //最后存油量  
545 - Double jzdl=Double.parseDouble(map.get("jzdl").toString());  
546 - Double hdl=Double.parseDouble(map.get("hdl").toString());  
547 - Dlb dlb=repository.findById(id).get();  
548 - dlb.setJzcd(jzdl);  
549 - dlb.setHd(hdl);  
550 - repository.save(dlb);  
551 - newMap.put("status", ResponseCode.SUCCESS);  
552 - }catch(Exception e){  
553 - newMap.put("status", ResponseCode.ERROR);  
554 - logger.error("save erro.", e);  
555 - }  
556 - return newMap;  
557 - }  
558 -  
559 -  
560 - /**  
561 - * 核对,有加注没里程  
562 - * @param map  
563 - * @return  
564 - */  
565 - @Transactional  
566 - @Override  
567 - public Map<String, Object> checkDl(Map<String, Object> map) {  
568 - Map<String, Object> newMap=new HashMap<String,Object>();  
569 -// String xlbm="";  
570 -// if(map.get("xlbm_like")!=null){  
571 -// xlbm=map.get("xlbm_like").toString();  
572 -// }  
573 - // TODO Auto-generated method stub  
574 -  
575 - List<Cars> carsList = carsRepository.findCars();  
576 - Map<String, String> carsMap = new HashMap<String, String>();  
577 - for (int i = 0; i < carsList.size(); i++) {  
578 - Cars c = carsList.get(i);  
579 - carsMap.put(c.getInsideCode(), c.getBrancheCompanyCode()==null?"":c.getBrancheCompanyCode());  
580 - }  
581 -  
582 - try{  
583 - //获取车辆存油信息  
584 -  
585 - String rq=map.get("rq").toString();  
586 - String xlbm="";  
587 - if(map.get("xlbm_like")!=null){  
588 - xlbm= map.get("xlbm_like").toString().trim();  
589 - }  
590 - String gsbm="";  
591 - if(map.get("ssgsdm_like")!=null){  
592 - gsbm=map.get("ssgsdm_like").toString();  
593 - }  
594 - String fgsbm="";  
595 - if(map.get("fgsdm_like")!=null){  
596 - fgsbm=map.get("fgsdm_like").toString();  
597 - }  
598 - String nbbm="";  
599 - if(map.get("nbbm_eq")!=null){  
600 - nbbm=map.get("nbbm_eq").toString();  
601 - }  
602 -  
603 - String sql="select * from bsth_c_jdl j where j.gs_bm ='"+gsbm+"' "  
604 - + " and j.fgs_bm ='"+fgsbm+"' and rq ='"+rq+"' "  
605 - + "and nbbm not in (select nbbm from bsth_c_dlb d"  
606 - + " where ssgsdm ='"+gsbm+"' and fgsdm ='"+fgsbm+"'"  
607 - + " and rq='"+rq+"')";  
608 - List<Jdl> listJdl=jdbcTemplate.query(sql,  
609 - new RowMapper<Jdl>(){  
610 - @Override  
611 - public Jdl mapRow(ResultSet rs, int rowNum) throws SQLException {  
612 - Jdl s = new Jdl();  
613 - s.setNbbm(rs.getString("nbbm"));  
614 - s.setGsBm(rs.getString("gs_bm"));  
615 - s.setFgsBm(rs.getString("fgs_bm"));  
616 - s.setJdl(rs.getDouble("jdl"));  
617 - s.setRq(rs.getDate("rq"));  
618 - return s;  
619 - }  
620 - });  
621 - for (int i = 0; i < listJdl.size(); i++) {  
622 - Jdl j=listJdl.get(i);  
623 - Dlb t=new Dlb();  
624 - Line line= BasicData.nbbm2LineMap.get(j.getNbbm());  
625 - if(null !=line){  
626 - t.setCdl(j.getJdl());  
627 - t.setNbbm(j.getNbbm());  
628 - t.setRq(j.getRq());  
629 - t.setJsy("");  
630 - t.setCdl(j.getJdl());  
631 - t.setSsgsdm(j.getGsBm());  
632 - t.setFgsdm(j.getFgsBm());  
633 - t.setJzcd(100.0);  
634 - t.setCzcd(100.0);  
635 - t.setHd(0.0);  
636 - t.setJcsx(1);  
637 - t.setXlbm(line.getLineCode());  
638 - t.setLp("");  
639 - repository.save(t);  
640 - }  
641 - }  
642 -  
643 - SysUser user = SecurityUtils.getCurrentUser();  
644 - Nylog nylog=new Nylog();  
645 - nylog.setCreatedate(new Date());  
646 - nylog.setCzmc("核对");  
647 - nylog.setNylx("电");  
648 - nylog.setUserid(user.getUserName());  
649 - nylog.setUsername(user.getName());  
650 - nylog.setCxtj(xlbm+"-"+ rq+"-"+gsbm+"-"+fgsbm);  
651 - nylogRepository.save(nylog);  
652 - newMap.put("status", ResponseCode.SUCCESS);  
653 - }catch(Exception e){  
654 - newMap.put("status", ResponseCode.ERROR);  
655 - logger.error("save erro.", e);  
656 - throw e;  
657 - }  
658 -  
659 - return newMap;  
660 - }  
661 -  
662 - @Override  
663 - public List<Dlb> listDlb(Map<String, Object> map) {  
664 - // TODO Auto-generated method stub  
665 - List<Dlb> listDlb = new ArrayList<Dlb>();  
666 - List<String> stringList = new ArrayList<String>();  
667 - String rq = map.get("rq").toString();  
668 - String gsbm = map.get("ssgsdm_like").toString();  
669 - String fgsbm = map.get("fgsdm_like").toString();  
670 - String xlbm = map.get("xlbm_like").toString().trim();  
671 - String nbbm = map.get("nbbm_eq").toString();  
672 - String sxtj = map.get("sxtj").toString();  
673 - String type = map.get("type").toString();  
674 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
675 - try {  
676 - if (nbbm.trim() != "") {  
677 - stringList.add(nbbm);  
678 - if (type.equals("1"))  
679 - listDlb = repository.listDlb(rq, gsbm, fgsbm, xlbm, stringList);  
680 - else  
681 - listDlb = repository.listDlb_s(sdf.parse(rq + " 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
682 -  
683 - } else {  
684 - // 全部  
685 - if (sxtj.equals("0")) {  
686 - List<Object[]> objectLists = repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm, nbbm);  
687 - for (int i = 0; i < objectLists.size(); i++) {  
688 - String clbm = objectLists.get(i)[0].toString();  
689 - stringList.add(clbm);  
690 - }  
691 - if (stringList.size() > 0) {  
692 - if (type.equals("1"))  
693 - listDlb = repository.listDlb(rq, gsbm, fgsbm, xlbm, stringList);  
694 - else  
695 - listDlb = repository.listDlb_s(sdf.parse(rq + " 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
696 - }  
697 - } else {  
698 - List<Object[]> objectLists;  
699 - if (sxtj.equals("3")) {  
700 - // 有加油没里程  
701 - objectLists = repository.checkNbmmDl(rq, gsbm, fgsbm, xlbm, nbbm);  
702 - for (int i = 0; i < objectLists.size(); i++) {  
703 - String clbm = objectLists.get(i)[0].toString();  
704 - double jzl = Double.parseDouble(objectLists.get(i)[1].toString());  
705 - double zlc = Double.parseDouble(objectLists.get(i)[2].toString());  
706 - if (jzl > 0 && zlc <= 0) {  
707 - stringList.add(clbm);  
708 - }  
709 -  
710 - }  
711 -  
712 - } else if (sxtj.equals("4")) {  
713 - // 有里程没加油  
714 - objectLists = repository.checkNbmmDl(rq, gsbm, fgsbm, xlbm, nbbm);  
715 - for (int i = 0; i < objectLists.size(); i++) {  
716 - String clbm = objectLists.get(i)[0].toString();  
717 - double jzl = Double.parseDouble(objectLists.get(i)[1].toString());  
718 - double zlc = Double.parseDouble(objectLists.get(i)[2].toString());  
719 - if (zlc > 0 && jzl <= 0) {  
720 - stringList.add(clbm);  
721 - }  
722 -  
723 - }  
724 - } else {  
725 - objectLists = repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm, nbbm);  
726 - for (int i = 0; i < objectLists.size(); i++) {  
727 - String clbm = objectLists.get(i)[0].toString();  
728 - int cs = Integer.parseInt(objectLists.get(i)[1].toString());  
729 - // 一车一单  
730 - if (sxtj.equals("1")) {  
731 - if (cs == 1) {  
732 - stringList.add(clbm);  
733 - }  
734 - }  
735 - // 一车多单  
736 - if (sxtj.equals("2")) {  
737 - if (cs > 1) {  
738 - stringList.add(clbm);  
739 - }  
740 - }  
741 - }  
742 - }  
743 -  
744 - if (stringList.size() > 0) {  
745 - if (type.equals("1"))  
746 - listDlb = repository.listDlb(rq, gsbm, fgsbm, xlbm, stringList);  
747 - else  
748 - listDlb = repository.listDlb_s(sdf.parse(rq + " 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
749 - }  
750 - }  
751 - }  
752 - } catch (ParseException e) {  
753 - // TODO Auto-generated catch block  
754 - e.printStackTrace();  
755 - }  
756 - return listDlb;  
757 - }  
758 -  
759 - @Override  
760 - public Map<String, Object> sumYlb(Map<String, Object> map) {  
761 - // TODO Auto-generated method stub  
762 - List<String> stringList = new ArrayList<String>();  
763 - String rq = map.get("rq").toString();  
764 - String gsbm = map.get("ssgsdm_like").toString();  
765 - String fgsbm = map.get("fgsdm_like").toString();  
766 - String xlbm = map.get("xlbm_like").toString().trim();  
767 - String nbbm = map.get("nbbm_eq").toString();  
768 - String sxtj = map.get("sxtj").toString();  
769 - String type = map.get("type").toString();  
770 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
771 - List<Object[]> sumYlbList = new ArrayList<Object[]>();  
772 - try {  
773 - if (nbbm.trim() != "") {  
774 - stringList.add(nbbm);  
775 - } else {  
776 - if (!sxtj.equals("0")) {  
777 - List<Object[]> objectLists;  
778 - if (sxtj.equals("3")) {  
779 - // 有加油没里程  
780 - objectLists = repository.checkNbmmDl(rq, gsbm, fgsbm, xlbm, nbbm);  
781 - for (int i = 0; i < objectLists.size(); i++) {  
782 - String clbm = objectLists.get(i)[0].toString();  
783 - double jzl = Double.parseDouble(objectLists.get(i)[1].toString());  
784 - double zlc = Double.parseDouble(objectLists.get(i)[2].toString());  
785 - if (jzl > 0 && zlc <= 0) {  
786 - stringList.add(clbm);  
787 - }  
788 -  
789 - }  
790 -  
791 - } else if (sxtj.equals("4")) {  
792 - // 有里程没加油  
793 - objectLists = repository.checkNbmmDl(rq, gsbm, fgsbm, xlbm, nbbm);  
794 - for (int i = 0; i < objectLists.size(); i++) {  
795 - String clbm = objectLists.get(i)[0].toString();  
796 - double jzl = Double.parseDouble(objectLists.get(i)[1].toString());  
797 - double zlc = Double.parseDouble(objectLists.get(i)[2].toString());  
798 - if (zlc > 0 && jzl <= 0) {  
799 - stringList.add(clbm);  
800 - }  
801 -  
802 - }  
803 - } else {  
804 - objectLists = repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm, nbbm);  
805 - for (int i = 0; i < objectLists.size(); i++) {  
806 - String clbm = objectLists.get(i)[0].toString();  
807 - int cs = Integer.parseInt(objectLists.get(i)[1].toString());  
808 - // 一车一单  
809 -  
810 - if (sxtj.equals("1")) {  
811 - if (cs == 1) {  
812 - stringList.add(clbm);  
813 - }  
814 - }  
815 - // 一车多单  
816 - if (sxtj.equals("2")) {  
817 - if (cs > 1) {  
818 - stringList.add(clbm);  
819 - }  
820 - }  
821 - }  
822 - }  
823 - }  
824 - }  
825 - if (sxtj.equals("0")) {  
826 - sumYlbList = repository.sumDlb2(rq, gsbm, fgsbm, xlbm, nbbm);  
827 - } else {  
828 - if (stringList.size() > 0) {  
829 -  
830 - // String strings[]=new String[stringList.size()];  
831 - // for(int i=0;i<stringList.size();i++){  
832 - // strings[i]=stringList.get(i);  
833 - // }  
834 - if (type.equals("1"))  
835 - sumYlbList = repository.sumDlb(rq, gsbm, fgsbm, xlbm, stringList);  
836 - else  
837 - sumYlbList = repository.sumDlb_s(sdf.parse(rq + " 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
838 -  
839 - }  
840 - // else {  
841 - // sumYlbList = repository.sumDlb2(rq, gsbm, fgsbm, xlbm, nbbm);  
842 - // }  
843 - }  
844 - } catch (ParseException e) {  
845 - // TODO Auto-generated catch block  
846 - e.printStackTrace();  
847 - }  
848 - Double jzl = 0.0, yh = 0.0, sh = 0.0;  
849 - for (int i = 0; i < sumYlbList.size(); i++) {  
850 - jzl = Arith.add(jzl, Double.valueOf(sumYlbList.get(i)[0].toString()));  
851 - yh = Arith.add(yh, Double.valueOf(sumYlbList.get(i)[1].toString()));  
852 - sh = Arith.add(sh, Double.valueOf(sumYlbList.get(i)[2].toString()));  
853 - }  
854 -  
855 - Map<String, Object> sumMap = new HashMap<String, Object>();  
856 - sumMap.put("jzl", jzl);  
857 - sumMap.put("yh", yh);  
858 - sumMap.put("sh", sh);  
859 - return sumMap;  
860 - }  
861 -  
862 -  
863 - @Transactional  
864 - @Override  
865 - public Map<String, Object> saveDlbList(Map<String, Object> map) throws Exception {  
866 - // TODO Auto-generated method stub  
867 - Map<String, Object> newMap=new HashMap<String,Object>();  
868 - try{  
869 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
870 - String json =StringEscapeUtils.unescapeHtml4(map.get("dlbList").toString());  
871 - JSONArray jsonArray=JSONArray.parseArray(json);  
872 - JSONObject jsonObject;  
873 - // 获取车辆存油信息  
874 -// List<Cyl> cylList = cylRepository.obtainCyl("","");  
875 - for (int i = 0; i < jsonArray.size(); i++) {  
876 -// Ylb t=new Ylb();  
877 - jsonObject=jsonArray.getJSONObject(i);  
878 - double czcd = jsonObject.getDoubleValue("czcd");  
879 - double cdl =jsonObject.getDoubleValue("cdl");  
880 - double jzcd =jsonObject.getDoubleValue("jzcd");  
881 - double sh =jsonObject.getDoubleValue("sh");  
882 - String shyy =jsonObject.getString("shyy");  
883 - double hd = jsonObject.getDoubleValue("hd");  
884 - int yhlx =jsonObject.getIntValue("yhlx");  
885 - Integer id =jsonObject.getInteger("id");  
886 -// String nbbm =jsonObject.getString("nbbm");  
887 -// String rq=jsonObject.getString("rq");  
888 - repository.dlbUpdate(id, czcd, jzcd, hd, sh, shyy, yhlx);  
889 -  
890 - }  
891 -  
892 - SysUser user = SecurityUtils.getCurrentUser();  
893 - Nylog nylog=new Nylog();  
894 - nylog.setCreatedate(new Date());  
895 - nylog.setCzmc("保存全部");  
896 - nylog.setNylx("电");  
897 - nylog.setUserid(user.getUserName());  
898 - nylog.setUsername(user.getName());  
899 - nylog.setCxtj("");  
900 - nylogRepository.save(nylog);  
901 - newMap.put("status", ResponseCode.SUCCESS);  
902 - }catch(Exception e){  
903 - newMap.put("status", ResponseCode.ERROR);  
904 - logger.error("save erro.", e);  
905 - throw e;  
906 - }  
907 - return newMap;  
908 - }  
909 -  
910 - public List<Dlb> listOrderBy(String rq,String gsdm,  
911 - String fgsdm,String xlbm,String nbbm,  
912 - String px) {  
913 - // TODO Auto-generated method stub  
914 - String sql="SELECT * FROM bsth_c_dlb "  
915 - + " where rq='"+rq+"' and ssgsdm like '%"+gsdm+"%' "  
916 - + " and fgsdm like '%"+fgsdm+"%'";  
917 - if(xlbm.equals("")){  
918 - sql+= " and xlbm like '%"+xlbm+"%' ";  
919 - }else{  
920 - sql+= " and xlbm = '"+xlbm+"' ";  
921 - }  
922 -  
923 - sql += "and nbbm like '%"+nbbm+"%' order by "+px+" asc ";  
924 -  
925 - List<Dlb> list = jdbcTemplate.query(sql, new RowMapper<Dlb>() {  
926 - @Override  
927 - public Dlb mapRow(ResultSet arg0, int arg1) throws SQLException {  
928 - Dlb y = new Dlb();  
929 - y.setId(arg0.getInt("id"));  
930 - return y;  
931 - }  
932 - });  
933 - List<Dlb> lists=new ArrayList<Dlb>();  
934 - List<Dlb> dlbLists=repository.obtainDl(rq,gsdm,fgsdm,xlbm,nbbm,"jcsx");  
935 - for (int i = 0; i < list.size(); i++) {  
936 - Dlb t=list.get(i);  
937 - for (int j = 0; j < dlbLists.size(); j++) {  
938 - Dlb t2=dlbLists.get(j);  
939 - if(t.getId().intValue()==t2.getId().intValue()){  
940 - lists.add(t2);  
941 - break;  
942 - }  
943 - }  
944 - }  
945 -  
946 - return lists;  
947 - }  
948 -  
949 -  
950 - @Override  
951 - public String checkJsy(Map<String, Object> map) {  
952 - // TODO Auto-generated method stub  
953 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
954 - String rq=map.get("date").toString();  
955 - String nbbm=map.get("nbbm").toString();  
956 - String jsy =map.get("jsy").toString();  
957 - String xlbm=map.get("xlbm").toString();  
958 - List<Dlb> list= repository.queryListDlb(rq, nbbm, jsy, xlbm);  
959 - String type="1";  
960 - if(list.size()>0){  
961 - type="0";  
962 - }  
963 - return type;  
964 - }  
965 -  
966 - @Override  
967 - public Map<String, Object> saveDlb(Dlb t) {  
968 - // TODO Auto-generated method stub  
969 - Map<String, Object> map = new HashMap<>();  
970 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
971 - String rq=sdf.format(t.getRq());  
972 - String gsdm=t.getSsgsdm();  
973 - String fgsdm=t.getFgsdm();  
974 - String xlbm=t.getXlbm();  
975 - String jhsj=t.getJhsj();  
976 - String jsy=t.getJsy();  
977 - String nbbm=t.getNbbm();  
978 - int sfkt=t.getSfkt();  
979 - t.setCreatetime(new Date());  
980 - String[] jhsjStr = jhsj.split(":");  
981 - long fcsjL= Long.parseLong(jhsjStr[0])*60+Long.parseLong(jhsjStr[1]);  
982 - List<Dlb> list=this.listOrderBy(rq, gsdm, fgsdm, xlbm, nbbm, "jhsj");  
983 -// repository.obtainYl(rq, gsdm, fgsdm, xlbm, nbbm, "jhsj");  
984 - int jcsx=1;  
985 - if(list.size()>0){  
986 - for (int i = 0; i < list.size(); i++) {  
987 - Dlb y=list.get(i);  
988 - String[] fcsjStr = y.getJhsj().split(":");  
989 - long fcsj=Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);  
990 - if(fcsjL>fcsj){  
991 - jcsx=jcsx+y.getJcsx();  
992 - }else{  
993 - y.setJcsx(y.getJcsx()+1);  
994 - repository.save(y);  
995 - }  
996 - }  
997 -  
998 - }  
999 - t.setJcsx(jcsx);  
1000 - repository.save(t);  
1001 -  
1002 - SysUser user = SecurityUtils.getCurrentUser();  
1003 - Nylog nylog=new Nylog();  
1004 - nylog.setCreatedate(new Date());  
1005 - nylog.setCzmc("手动添加");  
1006 - nylog.setNylx("电");  
1007 - nylog.setUserid(user.getUserName());  
1008 - nylog.setUsername(user.getName());  
1009 - nylog.setCxtj("");  
1010 - nylogRepository.save(nylog);  
1011 - map.put("status", ResponseCode.SUCCESS);  
1012 - map.put("t", t);  
1013 - return map;  
1014 - }  
1015 -  
1016 - @Transactional  
1017 - @Override  
1018 - public Map<String, Object> deleteIds(Map<String, Object> map) throws Exception{  
1019 - // TODO Auto-generated method stub  
1020 - Map<String, Object> maps = new HashMap<>();  
1021 - try{  
1022 - String json =StringEscapeUtils.unescapeHtml4(map.get("ids").toString());  
1023 - JSONArray jsonArray=JSONArray.parseArray(json);  
1024 - JSONObject jsonObject;  
1025 - for (int x = 0; x < jsonArray.size(); x++) {  
1026 - jsonObject=jsonArray.getJSONObject(x);  
1027 - Integer id =jsonObject.getInteger("id");  
1028 - repository.deleteById(id);  
1029 - }  
1030 -  
1031 - SysUser user = SecurityUtils.getCurrentUser();  
1032 - Nylog nylog=new Nylog();  
1033 - nylog.setCreatedate(new Date());  
1034 - nylog.setCzmc("删除");  
1035 - nylog.setNylx("电");  
1036 - nylog.setUserid(user.getUserName());  
1037 - nylog.setUsername(user.getName());  
1038 - nylog.setCxtj("");  
1039 - nylogRepository.save(nylog);  
1040 - maps.put("status", ResponseCode.SUCCESS);  
1041 - } catch (Exception e) {  
1042 - maps.put("status", ResponseCode.ERROR);  
1043 - logger.error("save erro.", e);  
1044 - throw e;  
1045 - }  
1046 - return maps;  
1047 - }  
1048 -  
1049 - @Override  
1050 - public Map<String, List<Dlb>> updeteHistory(List<Map<String, Object>> listpbDc,String date,  
1051 - String gsdm,String fgsdm,String line) {  
1052 - // TODO Auto-generated method stub  
1053 - Map<String, List<Dlb>> mapList=new HashMap<String,List<Dlb>>();  
1054 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
1055 - // 保留两位小数  
1056 - DecimalFormat df = new DecimalFormat("#.00");  
1057 - List<Dlb> dlbList=this.listOrderBy(date,gsdm,fgsdm,"","","nbbm");  
1058 - List<Dlb> dlbList_upd=new ArrayList<Dlb>();  
1059 - List<Dlb> dlbList_del=new ArrayList<Dlb>();  
1060 - try{  
1061 - for (int j = 0; j < dlbList.size(); j++) {  
1062 - Dlb t=dlbList.get(j);  
1063 - boolean fage=true;  
1064 - if(StringUtils.isEmpty(t.getLp())){  
1065 - fage=false;  
1066 - }else{  
1067 - for (int i = 0; i < listpbDc.size(); i++) {  
1068 - Map<String, Object> m = listpbDc.get(i);  
1069 - if(t.getNbbm().equals(m.get("clZbh").toString())  
1070 - &&t.getJsy().equals(m.get("jGh").toString())  
1071 - &&t.getXlbm().equals(m.get("xlBm").toString())  
1072 - &&t.getLp().equals(m.get("lpName").toString())){  
1073 - //该条记录不用删除  
1074 - fage =false;  
1075 - dlbList_upd.add(t);  
1076 - }  
1077 - }  
1078 - }  
1079 -  
1080 - if(fage){  
1081 - if(t.getXlbm().equals(line)){  
1082 - dlbList_del.add(t);  
1083 - }  
1084 - }  
1085 - }  
1086 - mapList.put("delList", dlbList_del);  
1087 - Map<String, Double> lcMap=new HashMap<String,Double>();  
1088 - for (int i = 0; i < listpbDc.size(); i++) {  
1089 - String cl=listpbDc.get(i).get("clZbh").toString();  
1090 - Double lc= listpbDc.get(i).get("totalKilometers") == null ? 0.0  
1091 - : Double.parseDouble(listpbDc.get(i).get("totalKilometers").toString());  
1092 - if(lcMap.get(cl)==null){  
1093 - lcMap.put(cl, lc);  
1094 - }else{  
1095 - double lc_=lcMap.get(cl);  
1096 - lcMap.remove(cl);  
1097 - lcMap.put(cl, Arith.add(lc, lc_));  
1098 - }  
1099 - }  
1100 - Map<String, Double> shMap=new HashMap<String,Double>();  
1101 - for (int i = 0; i < dlbList_upd.size(); i++) {  
1102 - Dlb dlb=dlbList_upd.get(i);  
1103 - String cl=dlb.getNbbm();  
1104 - if(shMap.get(cl)==null){  
1105 - shMap.put(cl, dlb.getSh());  
1106 - }else{  
1107 - double sh=shMap.get(cl);  
1108 - shMap.remove(cl);  
1109 - shMap.put(cl, Arith.add(sh, dlb.getSh()));  
1110 - }  
1111 - }  
1112 - List<Jdl> jdlList=jdlRepository.JdlList(date);  
1113 - List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(date, 0,gsdm);  
1114 - Map<String, Object> newMap_=new HashMap<String,Object>();  
1115 - Map<String, Object> cMap=new HashMap<String, Object>();  
1116 - List<Map<String, Object>> listpb_=listpbDc;  
1117 - Collections.sort(listpbDc,new NbbmJcsxMap());  
1118 - List<Dlb> updateDlb=new ArrayList<Dlb>();  
1119 - for (int x = 0; x < listpb_.size(); x++) {  
1120 - String type = "add";  
1121 - Map<String, Object> map_ = listpb_.get(x);  
1122 - if(newMap_.get(map_.get("clZbh").toString())==null){  
1123 - newMap_.put(map_.get("clZbh").toString(), map_.get("clZbh").toString());  
1124 - //车辆总里程  
1125 - double zlc =lcMap.get(map_.get("clZbh").toString());  
1126 - //车辆总加电量  
1127 - double zjzl = 0.0;  
1128 - for (int j = 0; j < ylxxList.size(); j++) {  
1129 - Ylxxb ylxxb = ylxxList.get(j);  
1130 - if (map_.get("clZbh").toString().equals(ylxxb.getNbbm())  
1131 - && map_.get("company").toString().equals(ylxxb.getGsdm())) {  
1132 - zjzl = Arith.add(zjzl, ylxxb.getJzl());  
1133 - }  
1134 - }  
1135 - for (int i = 0; i < jdlList.size(); i++) {  
1136 - Jdl jdl=jdlList.get(i);  
1137 - if(map_.get("clZbh").toString().equals(jdl.getNbbm())  
1138 - &&map_.get("company").toString().equals(jdl.getGsBm())  
1139 - &&map_.get("bCompany").toString().equals(jdl.getFgsBm())){  
1140 - zjzl = Arith.add(zjzl,jdl.getJdl());  
1141 - }  
1142 - }  
1143 - double clsh=0.0;  
1144 - if(shMap.get(map_.get("clZbh").toString())==null){  
1145 - clsh=0.0;  
1146 - }else{  
1147 - clsh=shMap.get(map_.get("clZbh").toString());  
1148 - }  
1149 - zjzl =Arith.sub(zjzl, clsh);  
1150 - Double nextJzyl = 0.0;  
1151 - for (int i = 0; i < listpbDc.size(); i++) {  
1152 - Map<String, Object> map = listpbDc.get(i);  
1153 - if(map_.get("clZbh").toString().equals(map.get("clZbh").toString())){  
1154 - // 判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断)  
1155 - Dlb t = new Dlb();  
1156 - for (int k = 0; k < dlbList_upd.size(); k++) {  
1157 - Dlb t1 = dlbList_upd.get(k);  
1158 - if (t1.getNbbm().equals(map.get("clZbh").toString())  
1159 - && t1.getJsy().equals(map.get("jGh").toString())  
1160 - && t1.getXlbm().equals(map.get("xlBm").toString())  
1161 - && t1.getLp().equals(map.get("lpName").toString())) {  
1162 - t = t1;  
1163 - type = "update";  
1164 - }  
1165 -  
1166 - }  
1167 - Double lc= Double.parseDouble(map.get("totalKilometers").toString());  
1168 - if(map.get("seqNumber").toString().equals("1")){  
1169 - // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
1170 - Double dh=0.0;  
1171 - if(zlc>0){  
1172 - dh = Double.parseDouble(df.format(zjzl * (lc / zlc)));  
1173 - }  
1174 - nextJzyl =Arith.sub(zjzl,dh);  
1175 - if(zlc>0){  
1176 -// long l=Math.round(nextJzyl);  
1177 - double ylxs=nextJzyl;  
1178 - dh=Arith.add(dh, Arith.sub(nextJzyl,ylxs));  
1179 - if(dh<0){  
1180 - t.setHd(0.0);  
1181 - t.setCdl(0.0);  
1182 - nextJzyl=Arith.add(ylxs, dh);  
1183 - }else{  
1184 - t.setHd(dh);  
1185 - t.setCdl(dh);  
1186 - nextJzyl=ylxs;  
1187 - }  
1188 - }else{  
1189 - t.setHd(0.0);  
1190 - t.setCdl(0.0);  
1191 - }  
1192 - }else{  
1193 - Double dh=0.0;  
1194 - if(zlc>0){  
1195 - dh = Double.parseDouble(df.format(zjzl * (lc / zlc)));  
1196 - }  
1197 - nextJzyl =Arith.sub( nextJzyl,dh);  
1198 - if(zlc>0){  
1199 -// long l=0l;  
1200 - double ylxs=0.0;  
1201 - if(i==listpbDc.size()-1){  
1202 -// ylxs=czyl;  
1203 - }else{  
1204 - if(listpbDc.get(i+1).get("clZbh").toString().equals(map.get("clZbh").toString())){  
1205 -// l=Math.round(nextJzyl);  
1206 - ylxs=nextJzyl;  
1207 - }  
1208 -  
1209 - }  
1210 - dh=Arith.add(dh, Arith.sub(nextJzyl,ylxs));  
1211 - if(dh<0){  
1212 - t.setHd(0.0);  
1213 - t.setCdl(0.0);  
1214 - nextJzyl=Arith.add(ylxs, dh);  
1215 - }else{  
1216 - t.setHd(dh);  
1217 - t.setCdl(dh);  
1218 - nextJzyl=ylxs;  
1219 - }  
1220 - }else{  
1221 - t.setHd(0.0);  
1222 - t.setCdl(0.0);  
1223 - }  
1224 - }  
1225 - t.setCzcd(100.0);  
1226 - t.setJzcd(100.0);  
1227 - t.setNbbm(map.get("clZbh").toString());  
1228 - t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString());  
1229 - t.setZlc(map.get("totalKilometers") == null ? 0.0  
1230 - : Double.parseDouble(map.get("totalKilometers").toString()));  
1231 - t.setXlbm(map.get("xlBm") == null ? "" : map.get("xlBm").toString());  
1232 - t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));  
1233 - t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString());  
1234 - t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());  
1235 - t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());  
1236 - t.setRq(sdf.parse(date));  
1237 - t.setLp(map.get("lpName").toString());  
1238 - t.setCdl(Arith.add(t.getCdl(), t.getSh()));  
1239 - if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){  
1240 - if(type.equals("add")){  
1241 - t.setCreatetime(new Date());  
1242 - }else{  
1243 - t.setUpdatetime(new Date());  
1244 - }  
1245 - }  
1246 -  
1247 - if(t.getHd()<0){  
1248 - t.setHd(0.0);  
1249 - }  
1250 - if(t.getCdl()<0){  
1251 - t.setCdl(0.0);  
1252 - }  
1253 - updateDlb.add(t);  
1254 - }  
1255 - }  
1256 - }  
1257 - }  
1258 - mapList.put("updList", updateDlb);  
1259 - }catch(Exception e){  
1260 - logger.error("save erro.", e);  
1261 - }  
1262 - return mapList;  
1263 - }  
1264 -  
1265 - @Override  
1266 - public Map<String, Object> update(Map<String, Object> map) {  
1267 - if(map.get("id")!=null){  
1268 - if(map.get("id").toString().length()>0){  
1269 - Integer id=Integer.parseInt(map.get("id").toString());  
1270 - String jsy=map.get("jsy").toString();  
1271 - Dlb t=repository.findById(id).get();  
1272 - t.setJsy(jsy);  
1273 - repository.save(t);  
1274 - map.put("status", ResponseCode.SUCCESS);  
1275 - }  
1276 - }  
1277 - return map;  
1278 - }  
1279 -  
1280 -}  
1281 -  
1282 -class NbbmJcsxMap implements Comparator<Map<String, Object>>{  
1283 - @Override  
1284 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
1285 - // TODO Auto-generated method stub  
1286 - return (o1.get("clZbh").toString()+o1.get("seqNumber").toString()).compareTo((o2.get("clZbh").toString()+o1.get("seqNumber").toString()));  
1287 - }  
1288 -}  
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java deleted 100644 → 0
1 -package com.bsth.service.oil.impl;  
2 -  
3 -import java.sql.ResultSet;  
4 -import java.sql.SQLException;  
5 -import java.text.DecimalFormat;  
6 -import java.text.ParseException;  
7 -import java.text.SimpleDateFormat;  
8 -import java.util.ArrayList;  
9 -import java.util.Calendar;  
10 -import java.util.Date;  
11 -import java.util.HashMap;  
12 -import java.util.Iterator;  
13 -import java.util.List;  
14 -import java.util.Map;  
15 -  
16 -import javax.transaction.Transactional;  
17 -  
18 -import org.apache.commons.lang3.StringEscapeUtils;  
19 -import org.apache.commons.lang3.StringUtils;  
20 -import org.slf4j.Logger;  
21 -import org.slf4j.LoggerFactory;  
22 -import org.springframework.beans.factory.annotation.Autowired;  
23 -import org.springframework.data.domain.Sort;  
24 -import org.springframework.data.domain.Sort.Direction;  
25 -import org.springframework.jdbc.core.JdbcTemplate;  
26 -import org.springframework.jdbc.core.RowMapper;  
27 -import org.springframework.stereotype.Service;  
28 -  
29 -import com.alibaba.fastjson.JSONArray;  
30 -import com.alibaba.fastjson.JSONObject;  
31 -import com.bsth.common.ResponseCode;  
32 -import com.bsth.data.BasicData;  
33 -import com.bsth.entity.Cars;  
34 -import com.bsth.entity.Line;  
35 -import com.bsth.entity.mcy_forms.Daily;  
36 -import com.bsth.entity.oil.Cyl;  
37 -import com.bsth.entity.oil.Dlb;  
38 -import com.bsth.entity.oil.Nylog;  
39 -import com.bsth.entity.oil.Ylb;  
40 -import com.bsth.entity.oil.Ylxxb;  
41 -import com.bsth.entity.search.CustomerSpecs;  
42 -import com.bsth.entity.sys.SysUser;  
43 -import com.bsth.repository.CarsRepository;  
44 -import com.bsth.repository.LineRepository;  
45 -import com.bsth.repository.oil.CylRepository;  
46 -import com.bsth.repository.oil.DlbRepository;  
47 -import com.bsth.repository.oil.NylogRepository;  
48 -import com.bsth.repository.oil.YlbRepository;  
49 -import com.bsth.repository.oil.YlxxbRepository;  
50 -import com.bsth.security.util.SecurityUtils;  
51 -import com.bsth.service.impl.BaseServiceImpl;  
52 -import com.bsth.service.oil.DlbService;  
53 -import com.bsth.service.oil.YlbService;  
54 -import com.bsth.service.realcontrol.ScheduleRealInfoService;  
55 -import com.bsth.util.Arith;  
56 -import com.bsth.util.BatchSaveUtils;  
57 -import com.bsth.util.ReportUtils;  
58 -import com.github.abel533.echarts.code.Y;  
59 -  
60 -import javassist.bytecode.stackmap.BasicBlock.Catch;  
61 -  
62 -@Service  
63 -public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbService{  
64 - @Autowired  
65 - YlbRepository repository;  
66 - @Autowired  
67 - NylogRepository nylogRepository;  
68 - @Autowired  
69 - YlxxbRepository ylxxbRepository;  
70 -  
71 - @Autowired  
72 - DlbService dlbService;  
73 -  
74 - @Autowired  
75 - DlbRepository dlbRepository;  
76 -  
77 - @Autowired  
78 - CylRepository cylRepository;  
79 -  
80 - @Autowired  
81 - CarsRepository carsRepository;  
82 -  
83 -  
84 - @Autowired  
85 - LineRepository lineRepository;  
86 -  
87 - @Autowired  
88 - ScheduleRealInfoService scheduleRealInfoService;  
89 -  
90 - @Autowired  
91 - JdbcTemplate jdbcTemplate;  
92 -  
93 - Logger logger = LoggerFactory.getLogger(this.getClass());  
94 -  
95 -  
96 -  
97 - /**  
98 - * 获取进存油信息  
99 - * @Transactional 回滚事物  
100 - */  
101 - @Transactional  
102 - @Override  
103 - public String obtainDsq() throws Exception{  
104 - String result = "failure";  
105 - try {  
106 - List<Ylb> addList = new ArrayList<Ylb>();  
107 - String type = "";  
108 - List<Cars> carsList=carsRepository.findCars();  
109 - Map<String, Boolean> carsMap=new HashMap<String, Boolean>();  
110 - for (int i = 0; i < carsList.size(); i++) {  
111 - Cars c=carsList.get(i);  
112 - carsMap.put(c.getInsideCode(), c.getSfdc());  
113 - }  
114 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
115 - Date dNow = new Date(); //当前时间  
116 - Date dBefore = new Date();  
117 - Calendar calendar = Calendar.getInstance(); //得到日历  
118 - calendar.setTime(dNow);//把当前时间赋给日历  
119 - calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天  
120 - dBefore = calendar.getTime(); //得到前一天的时间  
121 - String rq=sdf.format(dBefore);  
122 - //保留两位小数  
123 - DecimalFormat df = new DecimalFormat("#.00");  
124 - // TODO Auto-generated method stub  
125 - Map<String, Object> newMap=new HashMap<String,Object>();  
126 - //当天YLB信息  
127 -// List<Ylb> ylList=repository.obtainYl(rq,"","","","","nbbm");  
128 - List<Ylb> ylList=this.listOrderBy(rq,"","","","","nbbm");  
129 - //当天YLXXB信息  
130 - // List<Ylxxb> ylxxList=ylxxbRepository.obtainYlxx(rq);  
131 - //前一天所有车辆最后进场班次信息  
132 - List<Ylb> ylListBe=this.listByRqJcsx(rq,"","","","");  
133 -// List<Ylb> ylListBe=repository.listMaxRqJcsx(rq, "", "", "", "");  
134 - List<Cyl> clyList=cylRepository.obtainCyl("","");  
135 - //从排班表中计算出行驶的总里程  
136 - List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList("", rq, "", "", "", "");  
137 -  
138 - for(int x=0;x<listpb.size();x++){  
139 - boolean sfdc=true;  
140 - Map<String, Object> map=listpb.get(x);  
141 - if (carsMap.get(map.get("clZbh").toString())!=null) {  
142 - sfdc= carsMap.get(map.get("clZbh").toString());  
143 - }else{  
144 - sfdc=true;  
145 - }  
146 - if(!sfdc){  
147 - //判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断)  
148 - Ylb t=new Ylb();  
149 - for(int k=0;k<ylList.size();k++){  
150 - Ylb t1=ylList.get(k);  
151 - if(t1.getNbbm().equals(map.get("clZbh").toString())  
152 - &&t1.getJsy().equals(map.get("jGh").toString())  
153 - &&t1.getXlbm().equals(map.get("xlBm").toString())  
154 - &&t1.getLp().equals(map.get("lpName").toString()))  
155 - {  
156 - t=t1;  
157 - type="update";  
158 - }  
159 - }  
160 -  
161 - //当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
162 - if(map.get("seqNumber").toString().equals("1")){  
163 - boolean fage=true;  
164 - for (int i = 0; i < ylListBe.size(); i++) {  
165 - Ylb ylb=ylListBe.get(i);  
166 - if(map.get("clZbh").toString().equals(ylb.getNbbm())){  
167 - if(ylb.getJzyl()!=null){  
168 - if(ylb.getJzyl()>0){  
169 - t.setCzyl(ylb.getJzyl());  
170 - fage=false;  
171 - break;  
172 - }  
173 - }  
174 -  
175 - }  
176 - }  
177 - if(fage){  
178 - for (int y = 0; y < clyList.size(); y++) {  
179 - Cyl cyl=clyList.get(y);  
180 - if(map.get("clZbh").toString().equals(cyl.getNbbm())){  
181 - if(cyl.getCyl()!=null){  
182 - t.setCzyl(cyl.getCyl());  
183 - fage=false;  
184 - break;  
185 - }  
186 - }  
187 - }  
188 - }  
189 - if(fage){  
190 - t.setCzyl(0.0);  
191 - }  
192 - }  
193 - t.setNbbm(map.get("clZbh").toString());  
194 - t.setJsy(map.get("jGh")==null?"":map.get("jGh").toString());  
195 - t.setZlc(map.get("totalKilometers")==null?0.0:Double.parseDouble(map.get("totalKilometers").toString()));  
196 - t.setXlbm(map.get("xlBm")==null?"":map.get("xlBm").toString());  
197 - t.setLinename(map.get("lineName")==null?"":map.get("lineName").toString());  
198 - t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));  
199 - t.setSsgsdm(map.get("company")==null?"":map.get("company").toString());  
200 - t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());  
201 - t.setLp(map.get("lpName")==null?"":map.get("lpName").toString());  
202 - t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());  
203 - t.setJname(map.get("jName").toString());  
204 - t.setRq(sdf.parse(rq));  
205 - t.setCreatetime(dNow);  
206 - if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){  
207 - if(type.equals("update")){  
208 - repository.save(t);  
209 - }else{  
210 - addList.add(t);  
211 - }  
212 - }  
213 - }  
214 -  
215 - }  
216 - if(addList.size()>0){  
217 - try {  
218 - new BatchSaveUtils<Ylb>().saveList2(addList, Ylb.class);  
219 - } catch (Exception e) {  
220 - // TODO: handle exception  
221 - if(e.getMessage().indexOf("PK_YLB_UK")>0){  
222 - newMap.put("fage", "存在相同数据,数据已经过滤");  
223 - logger.info("定时器:存在相同数据,数据已经过滤");  
224 - }  
225 - }  
226 - }  
227 - result = "success";  
228 - }catch (Exception e) {  
229 - // TODO Auto-generated catch block  
230 - throw e;  
231 - }finally{  
232 - logger.info("setDDRB:"+result);  
233 - }  
234 -  
235 - return result;  
236 - }  
237 -  
238 - /**  
239 - * 获取进存油信息  
240 - * @Transactional 回滚事物  
241 - */  
242 - @Transactional  
243 - @Override  
244 - public Map<String, Object> obtain(Map<String, Object> map2) throws Exception{  
245 - Map<String, Object> newMap = new HashMap<String, Object>();  
246 - try {  
247 - Date date=new Date();  
248 - List<Cars> carsList = carsRepository.findCars();  
249 - Map<String, Boolean> carsMap = new HashMap<String, Boolean>();  
250 - for (int i = 0; i < carsList.size(); i++) {  
251 - Cars c = carsList.get(i);  
252 - carsMap.put(c.getInsideCode(), c.getSfdc());  
253 - }  
254 - String rq = map2.get("rq").toString();  
255 - String line = "";  
256 - if (map2.get("xlbm_like") != null) {  
257 - line = map2.get("xlbm_like").toString().trim();  
258 - }  
259 - String gsbm="";  
260 - if(map2.get("ssgsdm_like")!=null){  
261 - gsbm=map2.get("ssgsdm_like").toString();  
262 - }  
263 - String fgsbm="";  
264 - if(map2.get("fgsdm_like")!=null){  
265 - fgsbm=map2.get("fgsdm_like").toString();  
266 - }  
267 - String nbbm="";  
268 - if(map2.get("nbbm_eq")!=null){  
269 - nbbm=map2.get("nbbm_eq").toString();  
270 - }  
271 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
272 - // 保留两位小数  
273 - DecimalFormat df = new DecimalFormat("#.00");  
274 - // TODO Auto-generated method stub  
275 - // 当天YLB信息  
276 - List<Ylb> ylList = this.listOrderBy(rq,gsbm,fgsbm,"",nbbm,"nbbm");  
277 -  
278 - // 当天YLXXB信息  
279 - List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(rq, 0,gsbm);  
280 -  
281 - // 前一天所有车辆最后进场班次信息  
282 - List<Ylb> ylListBe = this.listByRqJcsx(rq, gsbm, fgsbm, "", nbbm);  
283 - List<Cyl> clyList = cylRepository.obtainCyl(nbbm,gsbm);  
284 -  
285 - // 从排班表中计算出行驶的总里程  
286 - List<Map<String, Object>> listpb =new ArrayList<Map<String, Object>>();  
287 - List<Map<String, Object>> listpbs=scheduleRealInfoService.yesterdayDataList("", rq, gsbm, fgsbm, "", nbbm);  
288 -  
289 - String sxtj=map2.get("sxtj").toString();  
290 - if(sxtj.equals("0")){  
291 - listpb=listpbs;  
292 - }else if (sxtj.equals("5")){  
293 - List<String> stringList=new ArrayList<String>();  
294 -  
295 - List<Object[]> objectLists = repository.checkNbmmFgs(rq, gsbm);  
296 - for (int i = 0; i < objectLists.size(); i++) {  
297 - String clbm=objectLists.get(i)[0].toString();  
298 - stringList.add(clbm);  
299 - }  
300 -  
301 - for (int i = 0; i < stringList.size(); i++) {  
302 - String strNbbm=stringList.get(i);  
303 - for (int j = 0; j < listpbs.size(); j++) {  
304 - Map<String, Object> map = listpbs.get(j);  
305 - String mapNbbm=map.get("clZbh").toString();  
306 - if(strNbbm.equals(mapNbbm)){  
307 - listpb.add(map);  
308 - }  
309 - }  
310 - }  
311 -  
312 - }else{  
313 - List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, "",nbbm);  
314 - List<String> stringList=new ArrayList<String>();  
315 - for (int i = 0; i < objectLists.size(); i++) {  
316 - String clbm=objectLists.get(i)[0].toString();  
317 - int cs=Integer.parseInt(objectLists.get(i)[1].toString());  
318 - //一车一单  
319 - if(sxtj.equals("1")){  
320 - if(cs==1){  
321 - stringList.add(clbm);  
322 - }  
323 - }  
324 - //一车多单  
325 - if(sxtj.equals("2")){  
326 - if(cs>1){  
327 - stringList.add(clbm);  
328 - }  
329 - }  
330 - }  
331 -  
332 - for (int i = 0; i < stringList.size(); i++) {  
333 - String strNbbm=stringList.get(i);  
334 - for (int j = 0; j < listpbs.size(); j++) {  
335 - Map<String, Object> map = listpbs.get(j);  
336 - String mapNbbm=map.get("clZbh").toString();  
337 - if(strNbbm.equals(mapNbbm)){  
338 - listpb.add(map);  
339 - }  
340 - }  
341 - }  
342 - }  
343 -  
344 - List<Ylb> addList = new ArrayList<Ylb>();  
345 - List<Ylb> updateList = new ArrayList<Ylb>();  
346 - Map<String, Object> ylMap=new HashMap<String, Object>();  
347 -  
348 - Map<String, Object> cMap=new HashMap<String, Object>();  
349 - for (int x = 0; x < listpb.size(); x++) {  
350 - String type = "add";  
351 - boolean sfdc = true;  
352 - Map<String, Object> map = listpb.get(x);  
353 - if (carsMap.get(map.get("clZbh").toString()) != null) {  
354 - sfdc = carsMap.get(map.get("clZbh").toString());  
355 - } else {  
356 - sfdc = true;  
357 - }  
358 - if (!sfdc) {  
359 - // 判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断)  
360 - Ylb t = new Ylb();  
361 - for (int k = 0; k < ylList.size(); k++) {  
362 - Ylb t1 = ylList.get(k);  
363 - if (t1.getNbbm().equals(map.get("clZbh").toString())  
364 - && t1.getJsy().equals(map.get("jGh").toString())  
365 - && t1.getXlbm().equals(map.get("xlBm").toString()  
366 - )) {  
367 - if(t1.getLp()==null){  
368 - //同人同车同线路不同路牌的过滤 (考虑到历史数据)  
369 - if (cMap.get(map.get("clZbh").toString()+map.get("jGh").toString()+map.get("xlBm").toString())==null) {  
370 - t = t1;  
371 - type = "update";  
372 - cMap.put(map.get("clZbh").toString()+map.get("jGh").toString()+map.get("xlBm").toString(),  
373 - map.get("clZbh").toString());  
374 - }  
375 - }else{  
376 - if(t1.getLp().equals(map.get("lpName").toString())){  
377 - t = t1;  
378 - type = "update";  
379 - }  
380 -  
381 - }  
382 - }  
383 - }  
384 - // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
385 - if (map.get("seqNumber").toString().equals("1")) {  
386 - boolean fage = true;  
387 - if(line.equals("")){  
388 - for (int i = 0; i < ylListBe.size(); i++) {  
389 - Ylb ylb = ylListBe.get(i);  
390 - if (map.get("clZbh").toString().equals(ylb.getNbbm())) {  
391 - if(ylb.getJzyl()>0){  
392 - t.setCzyl(ylb.getJzyl());  
393 - fage = false;  
394 - break;  
395 - }  
396 -  
397 - }  
398 - }  
399 - if (fage) {  
400 - for (int y = 0; y < clyList.size(); y++) {  
401 - Cyl cyl = clyList.get(y);  
402 - if (map.get("clZbh").toString().equals(cyl.getNbbm())) {  
403 - if(cyl!=null){  
404 - if(cyl.getCyl()>=0){  
405 - t.setCzyl(cyl.getCyl());  
406 - fage = false;  
407 - break;  
408 - }else {  
409 - if(cyl.getCxrl()!=null){  
410 - if(cyl.getCxrl()>0){  
411 - t.setCzyl(cyl.getCxrl());  
412 - fage = false;  
413 - break;  
414 - }  
415 - }  
416 - }  
417 - }  
418 - }  
419 - }  
420 - }  
421 - if (fage) {  
422 - t.setCzyl(0.0);  
423 - }  
424 - }else{  
425 - if (line.equals(map.get("xlBm").toString())) {  
426 - for (int i = 0; i < ylListBe.size(); i++) {  
427 - Ylb ylb = ylListBe.get(i);  
428 - if (map.get("clZbh").toString().equals(ylb.getNbbm())) {  
429 - if(ylb.getJzyl()>0){  
430 - t.setCzyl(ylb.getJzyl());  
431 - fage = false;  
432 - break;  
433 - }  
434 -  
435 - }  
436 - }  
437 - if (fage) {  
438 - for (int y = 0; y < clyList.size(); y++) {  
439 - Cyl cyl = clyList.get(y);  
440 - if (map.get("clZbh").toString().equals(cyl.getNbbm())) {  
441 - if(cyl!=null){  
442 - if(cyl.getCyl()>=0){  
443 - t.setCzyl(cyl.getCyl());  
444 - fage = false;  
445 - break;  
446 - }else {  
447 - if(cyl.getCxrl()!=null){  
448 - if(cyl.getCxrl()>0){  
449 - t.setCzyl(cyl.getCxrl());  
450 - fage = false;  
451 - break;  
452 - }  
453 - }  
454 - }  
455 - }  
456 - }  
457 - }  
458 - }  
459 - if (fage) {  
460 - t.setCzyl(0.0);  
461 - }  
462 - }  
463 - }  
464 -  
465 - }  
466 -  
467 - Double jzl = 0.0;  
468 - //一人一车加注量只匹配一次  
469 - if(ylMap.get(map.get("clZbh").toString()+"_"+ map.get("jGh").toString())==null){  
470 -  
471 - boolean fage2=false;  
472 - for (int i = 0; i < ylxxList.size(); i++) {  
473 - Ylxxb ylxxb = ylxxList.get(i);  
474 - if (map.get("clZbh").toString().equals(ylxxb.getNbbm())  
475 - && map.get("jGh").toString().equals(ylxxb.getJsy())  
476 - && ylxxb.getJylx()==1) {  
477 - if(ylxxb.getJzl()>0){  
478 - fage2=true;  
479 - }  
480 -  
481 - }  
482 - }  
483 - //车辆的加注量如果有任工干预,略接口过来 数据  
484 - if(fage2){  
485 - // 把当天手工输入的的YLXXB的加注量设置为当天YLB的加注量(根据车号,驾驶员判断,加油类型为1)  
486 - for (int j = 0; j < ylxxList.size(); j++) {  
487 - Ylxxb ylxxb = ylxxList.get(j);  
488 - if (map.get("clZbh").toString().equals(ylxxb.getNbbm())  
489 - && map.get("jGh").toString().equals(ylxxb.getJsy())  
490 - && ylxxb.getJylx()==1) {  
491 - jzl =Arith.add(jzl, ylxxb.getJzl());  
492 - }  
493 - }  
494 - ylMap.put(map.get("clZbh").toString()+"_"+ map.get("jGh").toString(),map.get("xlBm") == null ? "" : map.get("xlBm").toString());  
495 - }else{  
496 - // 把当天的YLXXB的加注量设置为当天YLB的加注量(根据车号,驾驶员判断)  
497 - for (int j = 0; j < ylxxList.size(); j++) {  
498 - Ylxxb ylxxb = ylxxList.get(j);  
499 - if (map.get("clZbh").toString().equals(ylxxb.getNbbm())  
500 - && map.get("jGh").toString().equals(ylxxb.getJsy())) {  
501 - jzl =Arith.add(jzl, ylxxb.getJzl());  
502 - }  
503 - }  
504 - ylMap.put(map.get("clZbh").toString()+"_"+ map.get("jGh").toString(),map.get("xlBm") == null ? "" : map.get("xlBm").toString());  
505 - }  
506 -  
507 - }  
508 - t.setJzl(jzl);  
509 - t.setNbbm(map.get("clZbh").toString());  
510 - t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString());  
511 - t.setZlc(map.get("totalKilometers") == null ? 0.0  
512 - : Double.parseDouble(map.get("totalKilometers").toString()));  
513 - t.setXlbm(map.get("xlBm") == null ? "" : map.get("xlBm").toString());  
514 - t.setLinename(map.get("lineName")==null?"":map.get("lineName").toString());  
515 - t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));  
516 - t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString());  
517 - t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());  
518 - t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());  
519 - t.setRq(sdf.parse(rq));  
520 - t.setLp(map.get("lpName")==null?"":map.get("lpName").toString());  
521 - t.setJname(map.get("jName").toString());  
522 - if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){  
523 - if(type.equals("add")){  
524 - t.setCreatetime(date);  
525 - addList.add(t);  
526 - }else{  
527 - t.setUpdatetime(date);  
528 - updateList.add(t);  
529 - }  
530 - }  
531 -// repository.save(t);  
532 - newMap.put("status", ResponseCode.SUCCESS);  
533 -  
534 - }  
535 - }  
536 - if(addList.size()>0){  
537 - try {  
538 - new BatchSaveUtils<Ylb>().saveList2(addList, Ylb.class);  
539 - } catch (Exception e) {  
540 - // TODO: handle exception  
541 - if(e.getMessage().indexOf("PK_YLB_UK")>0){  
542 - newMap.put("fage", "存在相同数据,数据已经过滤");  
543 - logger.info("获取:存在相同数据,数据已经过滤");  
544 - }  
545 - }  
546 -  
547 - }  
548 - if(updateList.size()>0){  
549 - for (int i = 0; i < updateList.size(); i++) {  
550 - repository.save(updateList.get(i));  
551 - }  
552 - }  
553 - SysUser user = SecurityUtils.getCurrentUser();  
554 - Nylog nylog=new Nylog();  
555 - nylog.setCreatedate(new Date());  
556 - nylog.setCzmc("获取加存油");  
557 - nylog.setNylx("油");  
558 - nylog.setUserid(user.getUserName());  
559 - nylog.setUsername(user.getName());  
560 - nylog.setCxtj(rq+"-"+gsbm+"-"+fgsbm+"-"+line+"-"+nbbm+"-"+sxtj);  
561 - nylogRepository.save(nylog);  
562 - newMap.put("status", ResponseCode.SUCCESS);  
563 - } catch (Exception e) {  
564 - // TODO Auto-generated catch block  
565 - newMap.put("status", ResponseCode.ERROR);  
566 - throw e;  
567 - }  
568 -  
569 - return newMap;  
570 - }  
571 -  
572 -  
573 - /**  
574 - * 进场等于出场  
575 - */  
576 - @Transactional  
577 - @Override  
578 - public Map<String, Object> outAndIn(Map<String, Object> map) throws Exception{  
579 - // TODO Auto-generated method stub  
580 - String xlbm="";  
581 - if(map.get("xlbm_like")!=null){  
582 - xlbm= map.get("xlbm_like").toString().trim();  
583 - }  
584 - String gsbm="";  
585 - if(map.get("ssgsdm_like")!=null){  
586 - gsbm=map.get("ssgsdm_like").toString();  
587 - }  
588 - String fgsbm="";  
589 - if(map.get("fgsdm_like")!=null){  
590 - fgsbm=map.get("fgsdm_like").toString();  
591 - }  
592 - String rq = map.get("rq").toString();  
593 - String nbbm="";  
594 - if(map.get("nbbm_eq")!=null){  
595 - nbbm=map.get("nbbm_eq").toString();  
596 - }  
597 -  
598 - Map<String, Object> newMap=new HashMap<String,Object>();  
599 - Map<String, Object> map2=new HashMap<String,Object>();  
600 - try {  
601 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
602 -  
603 - map.put("rq_eq", sdf.parse(rq));  
604 -// List<Cyl> clyList = cylRepository.obtainCyl();  
605 - // 获取车辆存油信息  
606 - List<Cyl> cylList = cylRepository.obtainCyl(nbbm,gsbm);  
607 - // 指定日期YLB信息  
608 - List<Ylb> ylbList =new ArrayList<Ylb>();  
609 - List<Ylb> ylbLists =new ArrayList<Ylb>();  
610 - List<Ylb> iterator2=new ArrayList<Ylb>();  
611 - ylbLists=this.listOrderBy(rq,gsbm,fgsbm,xlbm,nbbm,"jcsx");  
612 - iterator2=this.listOrderBy(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm,jcsx");  
613 - // 从排班表中计算出行驶的总里程  
614 -  
615 - String sxtj=map.get("sxtj").toString();  
616 - if(sxtj.equals("0")){  
617 - ylbList=ylbLists;  
618 - }else{  
619 - List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);  
620 - List<String> stringList=new ArrayList<String>();  
621 - for (int i = 0; i < objectLists.size(); i++) {  
622 - String clbm=objectLists.get(i)[0].toString();  
623 - int cs=Integer.parseInt(objectLists.get(i)[1].toString());  
624 - //一车一单  
625 - if(sxtj.equals("1")){  
626 - if(cs==1){  
627 - stringList.add(clbm);  
628 - }  
629 - }  
630 - //一车多单  
631 - if(sxtj.equals("2")){  
632 - if(cs>1){  
633 - stringList.add(clbm);  
634 - }  
635 - }  
636 - }  
637 -  
638 - for (int i = 0; i < stringList.size(); i++) {  
639 - String strNbbm=stringList.get(i);  
640 - for (int j = 0; j < ylbLists.size(); j++) {  
641 - Ylb y = ylbLists.get(j);  
642 - String mapNbbm=y.getNbbm();  
643 - if(strNbbm.equals(mapNbbm)){  
644 - ylbList.add(y);  
645 - }  
646 - }  
647 - }  
648 - }  
649 -  
650 - for (int i=0;i<ylbList.size();i++) {  
651 - Ylb ylb = ylbList.get(i);  
652 - // 判断是否已经计算过  
653 - if (newMap.get("nbbm" + ylb.getNbbm()) == null) {  
654 - String nbbm_eq = ylb.getNbbm();  
655 - Date rq_eq = ylb.getRq();  
656 - // 得到一天总的加油和里程(根据车,时间)  
657 - List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,"",gsbm,fgsbm);  
658 - // 保存总的加油量  
659 - Double jzl = 0.0;  
660 - // 保存总的里程  
661 - Double zlc = 0.0;  
662 - //保存总的损耗  
663 - Double zsh = 0.0;  
664 - for (int j = 0; j < sumList.size(); j++) {  
665 - jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString()));  
666 - zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString()));  
667 - zsh = Arith.add(zsh, Double.valueOf(sumList.get(j)[2].toString()));  
668 - }  
669 -// jzl = Arith.sub(jzl, zsh);  
670 - // 保留两位小数  
671 - DecimalFormat df = new DecimalFormat("#.00");  
672 - Double zyl = 0.0;  
673 - Double nextJzyl = 0.0;  
674 - // 保存已经计算过的车辆,相同车辆编号的车不在计算  
675 - newMap.put("nbbm" + ylb.getNbbm(), ylb.getNbbm());  
676 -  
677 - // 查询指定车辆,设置进、存、耗油量  
678 - map.remove("nbbm_eq");  
679 - map.put("nbbm_eq", ylb.getNbbm());  
680 - map.put("xlbm_like", ylb.getXlbm());  
681 -// Iterator<Ylb> iterator2 = repository  
682 -// .findAll(new CustomerSpecs<Ylb>(map), new Sort(Direction.ASC, "jcsx")).iterator();  
683 - double czyl=0.0;  
684 - for (int j = 0; j < iterator2.size(); j++) {  
685 - Ylb t = iterator2.get(j);  
686 - if(t.getNbbm().equals(ylb.getNbbm())){  
687 - if (t.getJcsx() == 1) {  
688 - // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量  
689 -// Double yl = t.getCzyl();  
690 -// Double jcyl = t.getCzyl();  
691 - czyl = t.getCzyl();  
692 - zyl =jzl;  
693 - Double yh=0.0;  
694 - if(zlc>0 ){  
695 - yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
696 - }  
697 - nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh);  
698 -// nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()), t.getCzyl()),yh);  
699 - //把进场油量的小数和整数分别取出  
700 -// int ylxs=(int) nextJzyl; 10.6--11 10.3--10  
701 - if(zlc>0 && t.getZlc()>0){  
702 - long l=Math.round(nextJzyl);  
703 - double ylxs=l*100/100;  
704 -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));  
705 - yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));  
706 - t.setYh(yh);  
707 - t.setJzyl(ylxs);  
708 - nextJzyl=ylxs;  
709 - }else{  
710 - t.setYh(yh);  
711 - t.setJzyl(nextJzyl);  
712 - }  
713 - } else {  
714 - t.setCzyl(nextJzyl);  
715 - Double yh=0.0;  
716 - if(zlc>0){  
717 - yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
718 - }  
719 - nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh);  
720 -// nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()),nextJzyl),yh);  
721 - if(zlc>0 && t.getZlc()>0){  
722 - long l=0l;  
723 - double ylxs=0.0;  
724 - if(j==iterator2.size()-1){  
725 - ylxs=czyl;  
726 - }else{  
727 - if(iterator2.get(j+1).getNbbm().equals(t.getNbbm())){  
728 - l=Math.round(nextJzyl);  
729 - ylxs=l*100/100;  
730 - }else{  
731 - ylxs=czyl;  
732 - }  
733 -  
734 - }  
735 - yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));  
736 -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));  
737 -  
738 - t.setYh(yh);  
739 - t.setJzyl(ylxs);  
740 - nextJzyl=ylxs;  
741 - }else{  
742 - t.setYh(yh);  
743 - t.setJzyl(nextJzyl);  
744 - }  
745 - }  
746 - if(t.getJzyl()<0){  
747 - t.setJzyl(0.0);  
748 - }  
749 - if(t.getCzyl()<0){  
750 - t.setCzyl(0.0);  
751 - }  
752 - if(t.getYh()<0){  
753 - t.setYh(0.0);  
754 - }  
755 - if(t.getSh()<0){  
756 - t.setSh(0.0);  
757 - }  
758 - repository.save(t);  
759 - }  
760 - map2.put("status", ResponseCode.SUCCESS);  
761 - }  
762 - }  
763 - }  
764 -  
765 - SysUser user = SecurityUtils.getCurrentUser();  
766 - Nylog nylog=new Nylog();  
767 - nylog.setCreatedate(new Date());  
768 - nylog.setCzmc("进场等于出场");  
769 - nylog.setNylx("油");  
770 - nylog.setUserid(user.getUserName());  
771 - nylog.setUsername(user.getName());  
772 - nylog.setCxtj(rq+"-"+gsbm+"-"+fgsbm+"-"+xlbm+"-"+nbbm+"-"+sxtj);  
773 -  
774 - nylogRepository.save(nylog);  
775 - } catch (Exception e) {  
776 - map2.put("status", ResponseCode.ERROR);  
777 - logger.error("save erro.", e);  
778 - throw e;  
779 - }  
780 - return map2;  
781 - }  
782 -  
783 -  
784 - /**  
785 - * 核对,有加注没里程  
786 - * @param map  
787 - * @return  
788 - */  
789 - @Transactional  
790 - @Override  
791 - public Map<String, Object> checkYl(Map<String, Object> map) throws Exception{  
792 - Map<String, Object> newMap=new HashMap<String,Object>();  
793 -// String xlbm="";  
794 -// if(map.get("xlbm_like")!=null){  
795 -// xlbm=map.get("xlbm_like").toString();  
796 -// }  
797 - // TODO Auto-generated method stub  
798 -  
799 - List<Cars> carsList = carsRepository.findCars();  
800 - Map<String, String> carsMap = new HashMap<String, String>();  
801 - for (int i = 0; i < carsList.size(); i++) {  
802 - Cars c = carsList.get(i);  
803 - carsMap.put(c.getInsideCode(), c.getBrancheCompanyCode()==null?"":c.getBrancheCompanyCode());  
804 - }  
805 -  
806 - try{  
807 - //获取车辆存油信息  
808 -  
809 - String rq=map.get("rq").toString();  
810 - String xlbm="";  
811 - if(map.get("xlbm_like")!=null){  
812 - xlbm= map.get("xlbm_like").toString().trim();  
813 - }  
814 - String gsbm="";  
815 - if(map.get("ssgsdm_like")!=null){  
816 - gsbm=map.get("ssgsdm_like").toString();  
817 - }  
818 - String fgsbm="";  
819 - if(map.get("fgsdm_like")!=null){  
820 - fgsbm=map.get("fgsdm_like").toString();  
821 - }  
822 - String nbbm="";  
823 - if(map.get("nbbm_eq")!=null){  
824 - nbbm=map.get("nbbm_eq").toString();  
825 - }  
826 -// List<Ylb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm);  
827 - List<Ylb> ylListBe=this.listByRqJcsx(rq, gsbm, fgsbm, "", nbbm);  
828 - List<Ylb> ylbList=this.listOrderBy(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm");  
829 -// repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm");  
830 -// List<Ylxxb> ylxxbList=ylxxbRepository.obtainYlxx(rq,0,gsbm);  
831 - String sql="select * from bsth_c_ylxxb where yyrq='"+rq+"' "  
832 - + " and gsdm ='"+gsbm+"' and nylx ='0' and nbbm "  
833 - + " not in ( select nbbm from bsth_c_ylb "  
834 - + " where rq='"+rq+"' "  
835 - + " and ssgsdm='"+gsbm+"' and fgsdm ='"+fgsbm+"')"  
836 - + " and nbbm in (select inside_code from "  
837 - + " bsth_c_cars where business_code ='"+gsbm+"' "  
838 - + " and branche_company_code='"+fgsbm+"')";  
839 -  
840 - List<Ylxxb> ylxxbList=jdbcTemplate.query(sql,  
841 - new RowMapper<Ylxxb>(){  
842 - @Override  
843 - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {  
844 - Ylxxb s = new Ylxxb();  
845 - s.setId(rs.getInt("id"));  
846 - s.setYyrq(rs.getDate("yyrq"));  
847 - s.setNbbm(rs.getString("nbbm"));  
848 - s.setGsdm(rs.getString("gsdm"));  
849 - s.setFgsdm(rs.getString("fgsdm"));  
850 - s.setJsy(rs.getString("jsy"));  
851 - s.setJzl(rs.getDouble("jzl"));  
852 - s.setStationid(rs.getString("stationid"));  
853 - s.setNylx(rs.getInt("nylx"));  
854 - s.setJyggh(rs.getString("jyggh"));  
855 - s.setYj(rs.getDouble("yj"));  
856 -// s.setLdgh(rs.getString("ldgh"));  
857 - s.setBz(rs.getString("bz"));  
858 - return s;  
859 - }  
860 - });  
861 - Map<String, Object> m=new HashMap<String,Object>();  
862 - for (int i = 0; i < ylxxbList.size(); i++) {  
863 - Boolean fage=false;  
864 - Ylxxb y1=ylxxbList.get(i);  
865 - if(m.get(y1.getNbbm())==null){  
866 - Line line=BasicData.nbbm2LineMap.get(y1.getNbbm());  
867 - if(null !=line){  
868 - if(!xlbm.equals("")){  
869 - if(line.getLineCode().equals(xlbm)){  
870 - fage=true;  
871 - }  
872 - }else{  
873 - fage=true;  
874 - }  
875 - }  
876 -  
877 - if(fage){  
878 - Ylb t=new Ylb();  
879 - t.setNbbm(y1.getNbbm());  
880 - t.setRq(y1.getYyrq());  
881 - t.setJsy(y1.getJsy());  
882 - t.setJname(BasicData.allPerson.get(y1.getGsdm()+"-"+y1.getJsy()));  
883 - t.setJzl(y1.getJzl());  
884 - t.setSsgsdm(y1.getGsdm());  
885 - String fgsdm="";  
886 - if(null !=carsMap.get(y1.getNbbm())){  
887 - fgsdm=carsMap.get(y1.getNbbm());  
888 - }  
889 - t.setFgsdm(fgsdm);  
890 - t.setJcsx(1);  
891 - if(null !=line){  
892 - t.setXlbm(line.getLineCode());  
893 - }else{  
894 - t.setXlbm("");  
895 - }  
896 - t.setJcsx(1);  
897 - boolean status=true;  
898 - for (int j = 0; j < ylListBe.size(); j++) {  
899 - Ylb b=ylListBe.get(j);  
900 - if(b.getNbbm().equals(y1.getNbbm())){  
901 - t.setCzyl(b.getJzyl());  
902 - status=false;  
903 - break;  
904 - }  
905 - }  
906 - if(status){  
907 - t.setCzyl(0.0);  
908 - }  
909 - t.setJzyl(Arith.add(t.getJzl(), t.getCzyl()));  
910 - t.setYh(0.0);  
911 - if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){  
912 - t.setCreatetime(new Date());  
913 - try {  
914 - repository.save(t);  
915 - m.put(t.getName(), t.getName());  
916 - } catch (Exception e) {  
917 - // TODO: handle exception  
918 - if(e.getMessage().indexOf("PK_YLB_UK")>0){  
919 - newMap.put("fage", "存在相同数据,数据已经过滤");  
920 - logger.info("核对有存油没里程:存在相同数据,数据已经过滤");  
921 - }  
922 - }  
923 - }  
924 - }  
925 - }  
926 - }  
927 -  
928 - SysUser user = SecurityUtils.getCurrentUser();  
929 - Nylog nylog=new Nylog();  
930 - nylog.setCreatedate(new Date());  
931 - nylog.setCzmc("核对加注量");  
932 - nylog.setNylx("油");  
933 - nylog.setUserid(user.getUserName());  
934 - nylog.setUsername(user.getName());  
935 - nylog.setCxtj(rq+"-"+gsbm+"-"+fgsbm+"-"+xlbm+"-"+nbbm+"-");  
936 - nylogRepository.save(nylog);  
937 - newMap.put("status", ResponseCode.SUCCESS);  
938 - }catch(Exception e){  
939 - newMap.put("status", ResponseCode.ERROR);  
940 - logger.error("save erro.", e);  
941 - throw e;  
942 - }  
943 -  
944 - return newMap;  
945 - }  
946 -  
947 -  
948 - @Override  
949 - public List<Map<String, Object>> oilListMonth(Map<String, Object> map) {  
950 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
951 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
952 -  
953 - String type=map.get("type").toString();  
954 - String date=map.get("date").toString().trim();  
955 - String gsdm=map.get("gsdm").toString();  
956 - String fgsdm=map.get("fgsdm").toString();  
957 - String date2=date.substring(0, 8)+"01";  
958 - String lineStr="";  
959 - String line =map.get("line").toString().trim();  
960 - /*if(line !=null && !line.equals("")){  
961 - lineStr =" and xlbm= '"+ line +"'";  
962 - }else{  
963 - lineStr =" and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' ";  
964 - }  
965 - String sql="select a.nbbm,a.rq,a.jzyl from (" +  
966 - " select x.nbbm,max(x.rq) as rq,max(x.jcsx) as jcsx from "  
967 - + "(select nbbm,rq,max(jcsx) as jcsx from bsth_c_ylb where rq between '"  
968 - + date2 +"' and '" + date+"' "+lineStr  
969 - + " group by nbbm,rq) x group by x.nbbm ) b"  
970 - + " left join (select nbbm,rq,jzyl,jcsx FROM bsth_c_ylb "  
971 - + " where rq between '"  
972 - + date2 +"' and '" + date+"' "+lineStr  
973 - + ") a "  
974 - + " on a.nbbm =b.nbbm and a.jcsx=b.jcsx and a.rq=b.rq "  
975 - + " where a.nbbm is not null order by a.nbbm";  
976 -  
977 - // TODO Auto-generated method stub  
978 - List<Ylb> list =jdbcTemplate.query(sql,  
979 - new RowMapper<Ylb>(){  
980 - @Override  
981 - public Ylb mapRow(ResultSet rs, int rowNum) throws SQLException {  
982 - Ylb s = new Ylb();  
983 - s.setNbbm(rs.getString("nbbm"));  
984 - s.setRq(rs.getDate("rq"));  
985 - s.setJzyl(rs.getDouble("jzyl"));  
986 - return s;  
987 - }  
988 - }); */  
989 -  
990 - double qtyy=0.0;//其他用油  
991 - double cdyy=0.0;//车队用油  
992 - double byyy=0.0;//保养用油  
993 - double cjxx=0.0;//车间小修  
994 - double cjgb=0.0;//车间高保  
995 - double fyyyhj=0.0;//非营运用油合计  
996 - List<Ylb> listYlb=repository.listByMonthJcsx(date2, date, gsdm, fgsdm, line);  
997 -  
998 - Map<String, Object> ms=new HashMap<String,Object>();  
999 - List<Ylb> list=new ArrayList<Ylb>();  
1000 - for (int i = 0; i < listYlb.size(); i++) {  
1001 - Ylb t=listYlb.get(i);  
1002 - fyyyhj =Arith.add(fyyyhj, t.getSh());  
1003 - if(t.getShyy()==null){  
1004 - qtyy=Arith.add(qtyy, t.getSh());  
1005 - }else{  
1006 - if(t.getShyy().equals("6")){  
1007 - cdyy=Arith.add(cdyy, t.getSh());  
1008 - }else if(t.getShyy().equals("2")){  
1009 - byyy=Arith.add(byyy, t.getSh());  
1010 - }else if(t.getShyy().equals("7")){  
1011 - cjxx=Arith.add(cjxx, t.getSh());  
1012 - }else if(t.getShyy().equals("8")){  
1013 - cjgb=Arith.add(cjgb, t.getSh());  
1014 - }else{  
1015 - qtyy=Arith.add(qtyy, t.getSh());  
1016 - }  
1017 - }  
1018 - if(ms.get(t.getNbbm())==null){  
1019 - ms.put(t.getNbbm(), t.getNbbm());  
1020 - list.add(t);  
1021 - }  
1022 - }  
1023 -  
1024 - List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();  
1025 - int size = 0;  
1026 - Map<String, Object> m_ = new HashMap<String, Object>();  
1027 - double ycyhj=0.0;  
1028 - for(Ylb ylb : list){  
1029 - ycyhj=Arith.add(ycyhj, ylb.getJzyl());  
1030 - int x=size%3;  
1031 - if(x==0 && size>0){  
1032 - mapList.add(m_);  
1033 - m_ = new HashMap<String, Object>();  
1034 - }  
1035 - size++;  
1036 - m_.put("xh"+x, size);  
1037 - m_.put("nbbm"+x, ylb.getNbbm()!=null?ylb.getNbbm():"");  
1038 - m_.put("rq"+x, ylb.getRq()!=null?sdfMonth.format(ylb.getRq()):"");  
1039 - m_.put("jzyl"+x, ylb.getJzyl()!=null?ylb.getJzyl():"");  
1040 -  
1041 - }  
1042 - if(m_.get("nbbm0")!=null){  
1043 - if(m_.get("nbbm1")==null){  
1044 - m_.put("xh1", "");  
1045 - m_.put("nbbm1" , "");  
1046 - m_.put("rq1" , "");  
1047 - m_.put("jzyl1" , "");  
1048 - }  
1049 - if(m_.get("nbbm2")==null){  
1050 - m_.put("xh2", "");  
1051 - m_.put("nbbm2" , "");  
1052 - m_.put("rq2" , "");  
1053 - m_.put("jzyl2" , "");  
1054 - }  
1055 - mapList.add(m_);  
1056 - }  
1057 -  
1058 - if(type != null && type.equals("export")){  
1059 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1060 - Map<String, Object> m = new HashMap<String, Object>();  
1061 - m.put("ycyhj", ycyhj);  
1062 - m.put("qtyy", qtyy);  
1063 - m.put("cdyy", cdyy);  
1064 - m.put("byyy", byyy);  
1065 - m.put("cjxx", cjxx);  
1066 - m.put("cjgb", cjgb);  
1067 - m.put("fyyyhj", fyyyhj);  
1068 - ReportUtils ee = new ReportUtils();  
1069 - try {  
1070 - String lineName = "";  
1071 - if(map.containsKey("lineName"))  
1072 - lineName = map.get("lineName").toString();  
1073 - listI.add(mapList.iterator());  
1074 - String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";  
1075 - ee.excelReplace(listI, new Object[] { m }, path+"mould/oilListMonth.xls",  
1076 - path+"export/" + sdfSimple.format(sdfMonth.parse(date))  
1077 - + "-" + lineName + "-月存油报表.xls");  
1078 - } catch (Exception e) {  
1079 - // TODO: handle exception  
1080 - e.printStackTrace();  
1081 - }  
1082 - }else{  
1083 - m_=new HashMap<String,Object>();  
1084 - m_.put("xh0", "99");  
1085 - m_.put("nbbm0", "存油合计:"+ycyhj +" 非营运用油: 其他用油:"+qtyy +",车队:"+cdyy+",保养用油:"+byyy  
1086 - +",车间(小修):"+cjxx+",车间(高保):"+cjgb+",非营运用油合计:"+fyyyhj);  
1087 - mapList.add(m_);  
1088 - }  
1089 -  
1090 - return mapList;  
1091 - }  
1092 -  
1093 - @Override  
1094 - public StringBuffer checkNbmmNum(String rq, String gsbm, String fgsbm, String xlbm,String nbbm,int lx) {  
1095 - StringBuffer stringList =new StringBuffer();  
1096 - List<Object[]> objectList=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);  
1097 - for (int i = 0; i < objectList.size(); i++) {  
1098 - String clbm=objectList.get(i)[0].toString()+",";  
1099 - int cs=Integer.parseInt(objectList.get(i)[1].toString());  
1100 - //一车一单  
1101 - if(lx==1){  
1102 - if(cs==1){  
1103 - stringList.append(clbm);  
1104 - }  
1105 - }  
1106 - //一车多单  
1107 - if(lx==2){  
1108 - if(cs>1){  
1109 - stringList.append(clbm);  
1110 - }  
1111 -  
1112 - }  
1113 - }  
1114 - return stringList;  
1115 - }  
1116 -  
1117 -  
1118 -  
1119 - @Override  
1120 - public Map<String, Object> sumYlb(Map<String, Object> map) {  
1121 - // TODO Auto-generated method stub  
1122 - List<String> stringList=new ArrayList<String>();  
1123 - String rq=map.get("rq").toString();  
1124 - String gsbm=map.get("ssgsdm_like").toString();  
1125 - String fgsbm=map.get("fgsdm_like").toString();  
1126 - String xlbm=map.get("xlbm_like").toString().trim();  
1127 - String nbbm=map.get("nbbm_eq").toString();  
1128 - String sxtj=map.get("sxtj").toString();  
1129 - String type=map.get("type").toString();  
1130 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1131 - List<Object[]> sumYlbList=new ArrayList<Object[]>();  
1132 - try {  
1133 - if(nbbm.trim()!=""){  
1134 - stringList.add(nbbm);  
1135 - }else{  
1136 - if(!sxtj.equals("0")){  
1137 - List<Object[]> objectLists;  
1138 - if(sxtj.equals("3")){  
1139 - //有加油没里程  
1140 - objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm);  
1141 - for (int i = 0; i < objectLists.size(); i++) {  
1142 - String clbm=objectLists.get(i)[0].toString();  
1143 - double jzl=Double.parseDouble(objectLists.get(i)[1].toString());  
1144 - double zlc=Double.parseDouble(objectLists.get(i)[2].toString());  
1145 - if(jzl>0 && zlc<=0){  
1146 - stringList.add(clbm);  
1147 - }  
1148 -  
1149 - }  
1150 -  
1151 - }else if(sxtj.equals("4")){  
1152 - //有里程没加油  
1153 - objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm);  
1154 - for (int i = 0; i < objectLists.size(); i++) {  
1155 - String clbm=objectLists.get(i)[0].toString();  
1156 - double jzl=Double.parseDouble(objectLists.get(i)[1].toString());  
1157 - double zlc=Double.parseDouble(objectLists.get(i)[2].toString());  
1158 - if(zlc>0 && jzl<=0){  
1159 - stringList.add(clbm);  
1160 - }  
1161 -  
1162 - }  
1163 - }else{  
1164 - objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);  
1165 - for (int i = 0; i < objectLists.size(); i++) {  
1166 - String clbm=objectLists.get(i)[0].toString();  
1167 - int cs=Integer.parseInt(objectLists.get(i)[1].toString());  
1168 - //一车一单  
1169 -  
1170 - if(sxtj.equals("1")){  
1171 - if(cs==1){  
1172 - stringList.add(clbm);  
1173 - }  
1174 - }  
1175 - //一车多单  
1176 - if(sxtj.equals("2")){  
1177 - if(cs>1){  
1178 - stringList.add(clbm);  
1179 - }  
1180 - }  
1181 - }  
1182 - }  
1183 - }  
1184 - }  
1185 - if(sxtj.equals("0")){  
1186 - sumYlbList=repository.sumYlb2(rq, gsbm, fgsbm, xlbm,nbbm);  
1187 - }else{  
1188 - if(stringList.size()>0){  
1189 -  
1190 -// String strings[]=new String[stringList.size()];  
1191 -// for(int i=0;i<stringList.size();i++){  
1192 -// strings[i]=stringList.get(i);  
1193 -// }  
1194 - if (type.equals("1"))  
1195 - sumYlbList=repository.sumYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1196 - else  
1197 - sumYlbList=repository.sumYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1198 - }  
1199 -// else{  
1200 -// sumYlbList=repository.sumYlb2(rq, gsbm, fgsbm, xlbm, nbbm);  
1201 -// }  
1202 -  
1203 - }  
1204 - } catch (ParseException e) {  
1205 - // TODO Auto-generated catch block  
1206 - e.printStackTrace();  
1207 - }  
1208 - Double jzl=0.0,yh=0.0,sh=0.0;  
1209 - for (int i = 0; i < sumYlbList.size(); i++) {  
1210 - jzl = Arith.add(jzl, Double.valueOf(sumYlbList.get(i)[0].toString()));  
1211 - yh = Arith.add(yh, Double.valueOf(sumYlbList.get(i)[1].toString()));  
1212 - sh = Arith.add(sh, Double.valueOf(sumYlbList.get(i)[2].toString()));  
1213 - }  
1214 -  
1215 - Map<String, Object> sumMap=new HashMap<String,Object>();  
1216 - sumMap.put("jzl", jzl);  
1217 - sumMap.put("yh", yh);  
1218 - sumMap.put("sh", sh);  
1219 -  
1220 -// String sql="select sum(jzl),sum(yh),sum(sh) from bsth_c_ylb "  
1221 -// + " where to_days('"+map.get("rq").toString()+"')=to_days(rq) "  
1222 -// + " and ssgsdm like '%"+map.get("ssgsdm_like").toString()+"%' "  
1223 -// + " and fgsdm like '%"+map.get("fgsdm_like").toString()+"%' "  
1224 -// + " and xlbm like '%"+map.get("xlbm_like").toString()+ "%'"  
1225 -// + " and nbbm like '%"+map.get("nbbm_eq").toString()+"% '";  
1226 -// if(map.get("nbbm_in")!=null){  
1227 -//// sql +=" and nbbm in ("  
1228 -// }  
1229 - return sumMap;  
1230 - }  
1231 -  
1232 -  
1233 -  
1234 - @Override  
1235 - public List<Ylb> listYlb(Map<String, Object> map) {  
1236 - // TODO Auto-generated method stub  
1237 - List<Ylb> listYlb = new ArrayList<Ylb>();  
1238 - try {  
1239 - List<String> stringList = new ArrayList<String>();  
1240 - String rq = map.get("rq").toString();  
1241 - String gsbm = map.get("ssgsdm_like").toString();  
1242 - String fgsbm = map.get("fgsdm_like").toString();  
1243 - String xlbm = map.get("xlbm_like").toString().trim();  
1244 - String nbbm = map.get("nbbm_eq").toString();  
1245 - String sxtj = map.get("sxtj").toString();  
1246 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1247 - String type = map.get("type").toString();  
1248 - if (nbbm.trim() != "") {  
1249 - stringList.add(nbbm);  
1250 - List<Object[]> objectLists = repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm, nbbm);  
1251 - if (objectLists.size() > 0) {  
1252 - int cs = Integer.parseInt(objectLists.get(0)[1].toString());  
1253 - if (sxtj.equals("1")) {  
1254 - if (cs == 1) {  
1255 - if (type.equals("1"))  
1256 - listYlb = repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1257 - else  
1258 - listYlb = repository.listYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1259 -  
1260 - }  
1261 - } else if (sxtj.equals("2")) {  
1262 - if (cs > 1) {  
1263 - if (type.equals("1"))  
1264 - listYlb = repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1265 - else  
1266 - listYlb = repository.listYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1267 - }  
1268 - } else {  
1269 - if (type.equals("1"))  
1270 - listYlb = repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1271 - else  
1272 - listYlb = repository.listYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1273 - }  
1274 - }  
1275 -  
1276 - } else {  
1277 - // 全部  
1278 - if (sxtj.equals("0")) {  
1279 - List<Object[]> objectLists = repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm, nbbm);  
1280 - for (int i = 0; i < objectLists.size(); i++) {  
1281 - String clbm = objectLists.get(i)[0].toString();  
1282 - stringList.add(clbm);  
1283 - }  
1284 - if (stringList.size() > 0) {  
1285 - if (type.equals("1"))  
1286 - listYlb = repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1287 - else  
1288 - listYlb = repository.listYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1289 - }  
1290 - }else if(sxtj.equals("5")){  
1291 - List<Object[]> objectLists = repository.checkNbmmFgs(rq, gsbm);  
1292 - for (int i = 0; i < objectLists.size(); i++) {  
1293 - String clbm =objectLists.get(i)[0].toString();  
1294 - stringList.add(clbm);  
1295 - }  
1296 -  
1297 - if (stringList.size() > 0) {  
1298 - if (type.equals("1"))  
1299 - listYlb = repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1300 - else  
1301 - listYlb = repository.listYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1302 - }  
1303 - } else {  
1304 - List<Object[]> objectLists;  
1305 - if (sxtj.equals("3")) {  
1306 - // 有加油没里程  
1307 - objectLists = repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm);  
1308 - for (int i = 0; i < objectLists.size(); i++) {  
1309 - String clbm = objectLists.get(i)[0].toString();  
1310 - double jzl = Double.parseDouble(objectLists.get(i)[1].toString());  
1311 - double zlc = Double.parseDouble(objectLists.get(i)[2].toString());  
1312 - if (jzl > 0 && zlc <= 0) {  
1313 - stringList.add(clbm);  
1314 - }  
1315 -  
1316 - }  
1317 -  
1318 - } else if (sxtj.equals("4")) {  
1319 - // 有里程没加油  
1320 - objectLists = repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm);  
1321 - for (int i = 0; i < objectLists.size(); i++) {  
1322 - String clbm = objectLists.get(i)[0].toString();  
1323 - double jzl = Double.parseDouble(objectLists.get(i)[1].toString());  
1324 - double zlc = Double.parseDouble(objectLists.get(i)[2].toString());  
1325 - if (zlc > 0 && jzl <= 0) {  
1326 - stringList.add(clbm);  
1327 - }  
1328 -  
1329 - }  
1330 - } else {  
1331 - objectLists = repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm, nbbm);  
1332 - for (int i = 0; i < objectLists.size(); i++) {  
1333 - String clbm = objectLists.get(i)[0].toString();  
1334 - int cs = Integer.parseInt(objectLists.get(i)[1].toString());  
1335 - // 一车一单  
1336 - if (sxtj.equals("1")) {  
1337 - if (cs == 1) {  
1338 - stringList.add(clbm);  
1339 - }  
1340 - }  
1341 - // 一车多单  
1342 - if (sxtj.equals("2")) {  
1343 - if (cs > 1) {  
1344 - stringList.add(clbm);  
1345 - }  
1346 - }  
1347 - }  
1348 - }  
1349 -  
1350 - if (stringList.size() > 0) {  
1351 - if (type.equals("1"))  
1352 - listYlb = repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);  
1353 - else  
1354 - listYlb = repository.listYlb_s(sdf.parse(rq+" 00:00:00"), gsbm, fgsbm, xlbm, stringList);  
1355 - }  
1356 - }  
1357 - }  
1358 - } catch (ParseException e) {  
1359 - // TODO Auto-generated catch block  
1360 - e.printStackTrace();  
1361 - }  
1362 - return listYlb;  
1363 - }  
1364 -  
1365 - @Transactional  
1366 - @Override  
1367 - public Map<String, Object> saveYlbList(Map<String, Object> map) throws Exception {  
1368 - // TODO Auto-generated method stub  
1369 - Map<String, Object> newMap=new HashMap<String,Object>();  
1370 - try{  
1371 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
1372 - String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());  
1373 - JSONArray jsonArray=JSONArray.parseArray(json);  
1374 - JSONObject jsonObject;  
1375 - // 获取车辆存油信息  
1376 - List<Cyl> cylList = cylRepository.obtainCyl("","");  
1377 - for (int i = 0; i < jsonArray.size(); i++) {  
1378 -// Ylb t=new Ylb();  
1379 - jsonObject=jsonArray.getJSONObject(i);  
1380 - double czyl = jsonObject.getDoubleValue("czyl");  
1381 - double jzl =jsonObject.getDoubleValue("jzl");  
1382 - double jzyl =jsonObject.getDoubleValue("jzyl");  
1383 - double sh =jsonObject.getDoubleValue("sh");  
1384 - String shyy =jsonObject.getString("shyy");  
1385 - double ns = jsonObject.getDoubleValue("ns");  
1386 - String rylx =jsonObject.getString("rylx");  
1387 - int yhlx =jsonObject.getIntValue("yhlx");  
1388 - Integer id =jsonObject.getInteger("id");  
1389 - String nbbm =jsonObject.getString("nbbm");  
1390 - String rq=jsonObject.getString("rq");  
1391 - double yh = Arith.sub(Arith.add(czyl, jzl),jzyl);  
1392 - if(yh<0){  
1393 - yh=0.0;  
1394 - }  
1395 - repository.ylbUpdate(id, czyl, jzyl, yh, sh, shyy, ns, rylx,yhlx);  
1396 - }  
1397 -// List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList");  
1398 - SysUser user = SecurityUtils.getCurrentUser();  
1399 - Nylog nylog=new Nylog();  
1400 - nylog.setCreatedate(new Date());  
1401 - nylog.setCzmc("保存全部");  
1402 - nylog.setNylx("油");  
1403 - nylog.setUserid(user.getUserName());  
1404 - nylog.setUsername(user.getName());  
1405 - nylog.setCxtj("");  
1406 - nylogRepository.save(nylog);  
1407 - newMap.put("status", ResponseCode.SUCCESS);  
1408 - }catch(Exception e){  
1409 - newMap.put("status", ResponseCode.ERROR);  
1410 - logger.error("save erro.", e);  
1411 - throw e;  
1412 - }  
1413 - return newMap;  
1414 - }  
1415 -  
1416 - /**  
1417 - * 拆分  
1418 - */  
1419 - @Transactional  
1420 - @Override  
1421 - public Map<String, Object> sort(Map<String, Object> map) throws Exception{  
1422 - // TODO Auto-generated method stub  
1423 - Map<String, Object> newMap = new HashMap<String, Object>();  
1424 - SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");  
1425 -  
1426 - try {  
1427 - List<Cyl> cylList = cylRepository.findAll(new CustomerSpecs<Cyl>(newMap));  
1428 - String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());  
1429 - String fgsbm="999";  
1430 - if(map.get("fgsbm")!=null){  
1431 - fgsbm=map.get("fgsbm").toString();  
1432 - }  
1433 - JSONArray jsonArray=JSONArray.parseArray(json);  
1434 - JSONObject jsonObject;  
1435 - for (int x = 0; x < jsonArray.size(); x++) {  
1436 - jsonObject=jsonArray.getJSONObject(x);  
1437 - Double yl =jsonObject.getDoubleValue("jzyl");  
1438 - Double sh =jsonObject.getDoubleValue("sh");  
1439 - String shyy =jsonObject.getString("shyy");  
1440 - Double ns = jsonObject.getDoubleValue("ns");  
1441 - String rylx =jsonObject.getString("rylx");  
1442 - Integer id =jsonObject.getInteger("id");  
1443 - Ylb ylb = repository.findById(id).get();  
1444 - String nbbm_eq = ylb.getNbbm();  
1445 - Date rq_eq = ylb.getRq();  
1446 - // 得到一天总的加油和里程(根据车,时间)  
1447 - List<Object[]> sumList=new ArrayList<Object[]>();  
1448 - if(fgsbm.equals(""))  
1449 - sumList = repository.sumLcYl(nbbm_eq, rq_eq,"",ylb.getSsgsdm(),fgsbm);  
1450 - else  
1451 - sumList = repository.sumLcYl(nbbm_eq, rq_eq,"",ylb.getSsgsdm(),ylb.getFgsdm());  
1452 -  
1453 - // 保存总的加油量  
1454 - Double jzl = 0.0;  
1455 - // 保存总的里程  
1456 - Double zlc = 0.0;  
1457 - //保存总的损耗  
1458 - Double zsh = 0.0;  
1459 - for (int j = 0; j < sumList.size(); j++) {  
1460 - jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString()));  
1461 - zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString()));  
1462 - zsh = Arith.add(zsh, Double.valueOf(sumList.get(j)[2].toString()));  
1463 - }  
1464 -// jzl = Arith.sub(jzl, zsh);  
1465 - //新的 损耗不等于 旧的损耗 总损耗从新算  
1466 - /*if(Arith.sub(ylb.getSh(),sh )!=0){  
1467 - zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh);  
1468 - jzl =Arith.sub(jzl, zsh);  
1469 - }else{  
1470 - jzl =Arith.sub(jzl, zsh);  
1471 - }*/  
1472 - map.put("nbbm_eq", nbbm_eq);  
1473 - map.put("rq_eq", rq_eq);  
1474 - List<Ylb> iterator2=null;  
1475 - if(fgsbm.equals(""))  
1476 - iterator2=this.listOrderBy(sdf.format(rq_eq),ylb.getSsgsdm(),fgsbm,"",  
1477 - ylb.getNbbm(),"jcsx");  
1478 - else  
1479 - iterator2=this.listOrderBy(sdf.format(rq_eq),ylb.getSsgsdm(),ylb.getFgsdm(),"",  
1480 - ylb.getNbbm(),"jcsx");  
1481 -  
1482 -// repository.obtainYl(sdf.format(rq_eq),ylb.getSsgsdm(),ylb.getFgsdm(),"",  
1483 -// ylb.getNbbm(),"jcsx");  
1484 - DecimalFormat df = new DecimalFormat("#.00");  
1485 - Double zyl = 0.0;  
1486 - Double nextJzyl = 0.0;  
1487 - // 车的,进,出油量及耗油  
1488 - double czyl=0.0;  
1489 - for (int i = 0; i < iterator2.size(); i++) {  
1490 - Ylb t = iterator2.get(i);  
1491 - if (t.getJcsx() == 1) {  
1492 - if(t.getId()==id){  
1493 - t.setSh(sh);  
1494 - t.setShyy(shyy);  
1495 - }  
1496 - czyl=t.getCzyl();  
1497 - Double jcyl = t.getCzyl();  
1498 - zyl = Arith.sub(Arith.add(jcyl, jzl), yl);  
1499 - Double yh = 0.0;  
1500 - if (zlc > 0 && t.getZlc() > 0) {  
1501 - yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
1502 - }  
1503 - nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), yh);  
1504 -// nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh()));  
1505 - if(zlc>0 && t.getZlc() > 0){  
1506 - long l=Math.round(nextJzyl);  
1507 - double ylxs=l*100/100;  
1508 -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));  
1509 - yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));  
1510 - t.setYh(yh);  
1511 - t.setJzyl(ylxs);  
1512 - nextJzyl=ylxs;  
1513 - }else{  
1514 - t.setYh(yh);  
1515 - t.setJzyl(nextJzyl);  
1516 - }  
1517 - } else {  
1518 - if(t.getId()==id){  
1519 - t.setSh(sh);  
1520 - t.setShyy(shyy);  
1521 - }  
1522 - t.setCzyl(nextJzyl);  
1523 - Double yh =0.0;  
1524 - if (t.getZlc() >= 0) {  
1525 - yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
1526 - }  
1527 -// nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));  
1528 - nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), yh);  
1529 - if(zlc>0 && t.getZlc() >0){  
1530 - long l=0l;  
1531 - double ylxs=0.0;  
1532 - if(i==iterator2.size()-1){  
1533 - ylxs=yl;  
1534 - }else{  
1535 - l=Math.round(nextJzyl);  
1536 - ylxs=l*100/100;  
1537 - }  
1538 - yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));  
1539 - t.setYh(yh);  
1540 - t.setJzyl(ylxs);  
1541 - nextJzyl=ylxs;  
1542 - }else{  
1543 - t.setYh(yh);  
1544 - t.setJzyl(nextJzyl);  
1545 - }  
1546 - }  
1547 - if(t.getJzyl()<0){  
1548 - t.setJzyl(0.0);  
1549 - }  
1550 - if(t.getCzyl()<0){  
1551 - t.setCzyl(0.0);  
1552 - }  
1553 - if(t.getYh()<0){  
1554 - t.setYh(0.0);  
1555 - }  
1556 - if(t.getSh()<0){  
1557 - t.setSh(0.0);  
1558 - }  
1559 - repository.save(t);  
1560 - }  
1561 - newMap.put("status", ResponseCode.SUCCESS);  
1562 - }  
1563 -  
1564 - SysUser user = SecurityUtils.getCurrentUser();  
1565 - Nylog nylog=new Nylog();  
1566 - nylog.setCreatedate(new Date());  
1567 - nylog.setCzmc("拆分");  
1568 - nylog.setNylx("油");  
1569 - nylog.setUserid(user.getUserName());  
1570 - nylog.setUsername(user.getName());  
1571 - nylog.setCxtj("");  
1572 - nylogRepository.save(nylog);  
1573 - } catch (Exception e) {  
1574 - newMap.put("status", ResponseCode.ERROR);  
1575 - logger.error("save erro.", e);  
1576 - throw e;  
1577 - }  
1578 - return newMap;  
1579 - }  
1580 -  
1581 -  
1582 - @Override  
1583 - public String checkJsy(Map<String, Object> map) {  
1584 - // TODO Auto-generated method stub  
1585 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
1586 - String rq=map.get("date").toString();  
1587 - String nbbm=map.get("nbbm").toString();  
1588 - String jsy =map.get("jsy").toString();  
1589 - String xlbm=map.get("xlbm").toString();  
1590 - List<Ylb> list= repository.checkYlb(rq, nbbm, jsy,xlbm,"nbbm");  
1591 - String type="1";  
1592 - if(list.size()>0){  
1593 - type="0";  
1594 - }  
1595 - return type;  
1596 - }  
1597 -  
1598 - @Override  
1599 - public String checkDate(Map<String, Object> map) {  
1600 - // TODO Auto-generated method stub  
1601 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
1602 - String rq=map.get("rq").toString();  
1603 - String gsbm=map.get("ssgsdm_like").toString();  
1604 - String type="1";  
1605 - if(gsbm.equals("26")){  
1606 - Date date=new Date();  
1607 - try {  
1608 - long day2=date.getTime();  
1609 - long day1=sdf.parse(rq).getTime();  
1610 - long days = (day2 - day1) / (24*3600*1000);  
1611 - if(days>3){  
1612 - type="2";  
1613 - }  
1614 - } catch (ParseException e) {  
1615 - // TODO Auto-generated catch block  
1616 - e.printStackTrace();  
1617 - }  
1618 - }  
1619 - return type;  
1620 - }  
1621 -  
1622 -  
1623 -  
1624 - @Override  
1625 - public Map<String, Object> saveYlb(Ylb t) {  
1626 - Map<String, Object> map = new HashMap<>();  
1627 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
1628 - String rq=sdf.format(t.getRq());  
1629 - String gsdm=t.getSsgsdm();  
1630 - String fgsdm=t.getFgsdm();  
1631 - String xlbm=t.getXlbm();  
1632 - String jhsj=t.getJhsj();  
1633 - String jsy=t.getJsy();  
1634 - String nbbm=t.getNbbm();  
1635 - t.setCreatetime(new Date());  
1636 - String[] jhsjStr = jhsj.split(":");  
1637 - long fcsjL= Long.parseLong(jhsjStr[0])*60+Long.parseLong(jhsjStr[1]);  
1638 - List<Ylb> list=this.listOrderBy(rq, gsdm, fgsdm, xlbm, nbbm, "jhsj");  
1639 -// repository.obtainYl(rq, gsdm, fgsdm, xlbm, nbbm, "jhsj");  
1640 - int jcsx=1;  
1641 - if(list.size()>0){  
1642 - for (int i = 0; i < list.size(); i++) {  
1643 - Ylb y=list.get(i);  
1644 - String[] fcsjStr = y.getJhsj().split(":");  
1645 - long fcsj=Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);  
1646 - if(fcsjL>fcsj){  
1647 - jcsx=jcsx+y.getJcsx();  
1648 - }else{  
1649 - y.setJcsx(y.getJcsx()+1);  
1650 - repository.save(y);  
1651 - }  
1652 - }  
1653 -  
1654 - }  
1655 - t.setJcsx(jcsx);  
1656 - repository.save(t);  
1657 -  
1658 - SysUser user = SecurityUtils.getCurrentUser();  
1659 - Nylog nylog=new Nylog();  
1660 - nylog.setCreatedate(new Date());  
1661 - nylog.setCzmc("手动添加");  
1662 - nylog.setNylx("油");  
1663 - nylog.setUserid(user.getUserName());  
1664 - nylog.setUsername(user.getName());  
1665 - nylog.setCxtj("");  
1666 - nylogRepository.save(nylog);  
1667 - map.put("status", ResponseCode.SUCCESS);  
1668 - map.put("t", t);  
1669 - return map;  
1670 - }  
1671 - @Transactional  
1672 - @Override  
1673 - public Map<String, Object> deleteIds(Map<String, Object> map) throws Exception{  
1674 - // TODO Auto-generated method stub  
1675 - Map<String, Object> maps = new HashMap<>();  
1676 - try{  
1677 - String json =StringEscapeUtils.unescapeHtml4(map.get("ids").toString());  
1678 - JSONArray jsonArray=JSONArray.parseArray(json);  
1679 - JSONObject jsonObject;  
1680 - for (int x = 0; x < jsonArray.size(); x++) {  
1681 - jsonObject=jsonArray.getJSONObject(x);  
1682 - Integer id =jsonObject.getInteger("id");  
1683 - repository.deleteById(id);  
1684 - }  
1685 -  
1686 - SysUser user = SecurityUtils.getCurrentUser();  
1687 - Nylog nylog=new Nylog();  
1688 - nylog.setCreatedate(new Date());  
1689 - nylog.setCzmc("删除");  
1690 - nylog.setNylx("油");  
1691 - nylog.setUserid(user.getUserName());  
1692 - nylog.setUsername(user.getName());  
1693 - nylog.setCxtj("");  
1694 - nylogRepository.save(nylog);  
1695 - maps.put("status", ResponseCode.SUCCESS);  
1696 - } catch (Exception e) {  
1697 - maps.put("status", ResponseCode.ERROR);  
1698 - logger.error("save erro.", e);  
1699 - throw e;  
1700 - }  
1701 - return maps;  
1702 - }  
1703 -  
1704 - public List<Ylb> listOrderBy(String rq,String gsdm,  
1705 - String fgsdm,String xlbm,String nbbm,  
1706 - String px) {  
1707 - // TODO Auto-generated method stub  
1708 - String sql="SELECT * FROM bsth_c_ylb "  
1709 - + " where rq ='"+rq+"' and ssgsdm like '%"+gsdm+"%' "  
1710 - + " and fgsdm like '%"+fgsdm+"%'";  
1711 - if(xlbm.equals("")){  
1712 - sql+= " and xlbm like '%"+xlbm+"%' ";  
1713 - }else{  
1714 - sql+= " and xlbm = '"+xlbm+"' ";  
1715 - }  
1716 -  
1717 - sql += "and nbbm like '%"+nbbm+"%' order by "+px+" asc ";  
1718 -  
1719 - List<Ylb> list = jdbcTemplate.query(sql, new RowMapper<Ylb>() {  
1720 - @Override  
1721 - public Ylb mapRow(ResultSet arg0, int arg1) throws SQLException {  
1722 - Ylb y = new Ylb();  
1723 - y.setId(arg0.getInt("id"));  
1724 - return y;  
1725 - }  
1726 - });  
1727 - List<Ylb> lists=new ArrayList<Ylb>();  
1728 - List<Ylb> ylbLists=repository.obtainYl(rq,gsdm,fgsdm,xlbm,nbbm,"jcsx");  
1729 - for (int i = 0; i < list.size(); i++) {  
1730 - Ylb t=list.get(i);  
1731 - for (int j = 0; j < ylbLists.size(); j++) {  
1732 - Ylb t2=ylbLists.get(j);  
1733 - if(t.getId().intValue()==t2.getId().intValue()){  
1734 - lists.add(t2);  
1735 - break;  
1736 - }  
1737 - }  
1738 - }  
1739 -  
1740 - return lists;  
1741 - }  
1742 -  
1743 - @Override  
1744 - public Map<String, Object> updateHistory(Map<String, Object> map) throws Exception {  
1745 - // TODO Auto-generated method stub  
1746 - Map<String, Object> newMap = new HashMap<String, Object>();  
1747 -  
1748 - List<Cars> carsList = carsRepository.findCars();  
1749 - Map<String, Boolean> carsMap = new HashMap<String, Boolean>();  
1750 - for (int i = 0; i < carsList.size(); i++) {  
1751 - Cars c = carsList.get(i);  
1752 - carsMap.put(c.getInsideCode(), c.getSfdc());  
1753 - }  
1754 - try{  
1755 - String date = map.get("date").toString();  
1756 - String line = map.get("line").toString();  
1757 - List<Line> listLine=lineRepository.findLineByCode(line);  
1758 - String gsdm ="";  
1759 - String fgsdm ="";  
1760 - if(listLine.size()>0){  
1761 - Line l=listLine.get(0);  
1762 - gsdm=l.getCompany();  
1763 - fgsdm=l.getBrancheCompany();  
1764 - }  
1765 -  
1766 - String nbbmstr="";  
1767 - List<Map<String, Object>> listpbYc=new ArrayList<Map<String, Object>>();//油车数据  
1768 - List<Map<String, Object>> listpbDc=new ArrayList<Map<String, Object>>();//电车数据  
1769 - List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList("", date,gsdm, fgsdm, "", "");  
1770 - for (int i = 0; i < listpb.size(); i++) {  
1771 - if(listpb.get(i).get("xlBm").toString().equals(line)){  
1772 - nbbmstr +=listpb.get(i).get("clZbh").toString();  
1773 - }  
1774 - }  
1775 - for (int i = 0; i < listpb.size(); i++) {  
1776 - boolean sfdc=true;  
1777 - Map<String, Object> m = listpb.get(i);  
1778 - if (carsMap.get(m.get("clZbh").toString()) != null) {  
1779 - sfdc = carsMap.get(m.get("clZbh").toString());  
1780 - } else {  
1781 - sfdc = true;  
1782 - }  
1783 - if(nbbmstr.indexOf(m.get("clZbh").toString())>-1){  
1784 - if(sfdc){  
1785 - listpbDc.add(m);  
1786 - }else{  
1787 - listpbYc.add(m);  
1788 - }  
1789 - }  
1790 - }  
1791 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
1792 - //初始存油量  
1793 - List<Cyl> clyList = cylRepository.obtainCyl("",gsdm);  
1794 - List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(date, 0,gsdm);  
1795 - //重新统计油车数据开始  
1796 - List<Ylb> ylListBe =repository.listByRqJcsx(date, gsdm, fgsdm, "", "");  
1797 - List<Ylb> ylbList=this.listOrderBy(date,gsdm,fgsdm,"","","nbbm");  
1798 - List<Ylb> ylbList_upd=new ArrayList<Ylb>();  
1799 - List<Ylb> ylbList_del=new ArrayList<Ylb>();  
1800 -  
1801 - for (int j = 0; j < ylbList.size(); j++) {  
1802 - Ylb t=ylbList.get(j);  
1803 - boolean fage=true;  
1804 - if(StringUtils.isEmpty(t.getLp())){  
1805 - fage=false;  
1806 - }else{  
1807 - for (int i = 0; i < listpbYc.size(); i++) {  
1808 - Map<String, Object> m = listpbYc.get(i);  
1809 - if(t.getNbbm().equals(m.get("clZbh").toString())  
1810 - &&t.getJsy().equals(m.get("jGh").toString())  
1811 - &&t.getXlbm().equals(m.get("xlBm").toString())  
1812 - &&t.getLp().equals(m.get("lpName").toString())){  
1813 - //该条记录不用删除  
1814 - fage =false;  
1815 - ylbList_upd.add(t);  
1816 - }  
1817 - }  
1818 - }  
1819 - if(fage){  
1820 - if(t.getXlbm().equals(line)){  
1821 - ylbList_del.add(t);  
1822 - }  
1823 - }  
1824 -  
1825 - }  
1826 - String nbbmStr="";  
1827 - List<Ylb> list=new ArrayList<Ylb>();  
1828 - /*  
1829 - * 第一步 修改车辆里程 和加注量  
1830 - */  
1831 - Map<String, Object> ylMap=new HashMap<String, Object>();  
1832 - for (int x = 0; x < listpbYc.size(); x++) {  
1833 - String type = "add";  
1834 - Map<String, Object> maps = listpbYc.get(x);  
1835 - // 判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断)  
1836 - Ylb t = new Ylb();  
1837 - for (int k = 0; k < ylbList_upd.size(); k++) {  
1838 - Ylb t1 = ylbList_upd.get(k);  
1839 - if (t1.getNbbm().equals(maps.get("clZbh").toString())  
1840 - && t1.getJsy().equals(maps.get("jGh").toString())  
1841 - && t1.getXlbm().equals(maps.get("xlBm").toString())  
1842 - && t1.getLp().equals(maps.get("lpName").toString())) {  
1843 - t = t1;  
1844 - type = "update";  
1845 - }  
1846 - }  
1847 - if(type.equals("add")){  
1848 - // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
1849 - if (maps.get("seqNumber").toString().equals("1")) {  
1850 - boolean fage = true;  
1851 - for (int i = 0; i < ylListBe.size(); i++) {  
1852 - Ylb ylb = ylListBe.get(i);  
1853 - if (maps.get("clZbh").toString().equals(ylb.getNbbm())) {  
1854 - if(ylb.getJzyl()>0){  
1855 - t.setCzyl(ylb.getJzyl());  
1856 - fage = false;  
1857 - break;  
1858 - }  
1859 - }  
1860 - }  
1861 - if (fage) {  
1862 - for (int y = 0; y < clyList.size(); y++) {  
1863 - Cyl cyl = clyList.get(y);  
1864 - if (maps.get("clZbh").toString().equals(cyl.getNbbm())) {  
1865 - if(cyl!=null){  
1866 - if(cyl.getCyl()>=0){  
1867 - t.setCzyl(cyl.getCyl());  
1868 - fage = false;  
1869 - break;  
1870 - }else {  
1871 - if(cyl.getCxrl()!=null){  
1872 - if(cyl.getCxrl()>0){  
1873 - t.setCzyl(cyl.getCxrl());  
1874 - fage = false;  
1875 - break;  
1876 - }  
1877 - }  
1878 - }  
1879 - }  
1880 - }  
1881 - }  
1882 - }  
1883 - if (fage) {  
1884 - t.setCzyl(0.0);  
1885 - }  
1886 - }  
1887 - }  
1888 -  
1889 - Double jzl = 0.0;  
1890 - //一人一车加注量只匹配一次  
1891 - if(ylMap.get(maps.get("clZbh").toString()+"_"+ maps.get("jGh").toString())!=null){  
1892 - }else{  
1893 - boolean fage2=false;  
1894 - for (int i = 0; i < ylxxList.size(); i++) {  
1895 - Ylxxb ylxxb = ylxxList.get(i);  
1896 - if (maps.get("clZbh").toString().equals(ylxxb.getNbbm())  
1897 - && maps.get("jGh").toString().equals(ylxxb.getJsy())  
1898 - && ylxxb.getJylx()==1) {  
1899 - if(ylxxb.getJzl()>0){  
1900 - fage2=true;  
1901 - }  
1902 - }  
1903 - }  
1904 - //车辆的加注量如果有任工干预,略接口过来 数据  
1905 - if(fage2){  
1906 - // 把当天手工输入的的YLXXB的加注量设置为当天YLB的加注量(根据车号,驾驶员判断,加油类型为1)  
1907 - for (int j = 0; j < ylxxList.size(); j++) {  
1908 - Ylxxb ylxxb = ylxxList.get(j);  
1909 - if (maps.get("clZbh").toString().equals(ylxxb.getNbbm())  
1910 - && maps.get("jGh").toString().equals(ylxxb.getJsy())  
1911 - && ylxxb.getJylx()==1) {  
1912 - jzl =Arith.add(jzl, ylxxb.getJzl());  
1913 - }  
1914 - }  
1915 - ylMap.put(maps.get("clZbh").toString()+"_"+ maps.get("jGh").toString(),maps.get("xlBm") == null ? "" : maps.get("xlBm").toString());  
1916 - }else{  
1917 - // 把当天的YLXXB的加注量设置为当天YLB的加注量(根据车号,驾驶员判断)  
1918 - for (int j = 0; j < ylxxList.size(); j++) {  
1919 - Ylxxb ylxxb = ylxxList.get(j);  
1920 - if (maps.get("clZbh").toString().equals(ylxxb.getNbbm())  
1921 - && maps.get("jGh").toString().equals(ylxxb.getJsy())) {  
1922 - jzl =Arith.add(jzl, ylxxb.getJzl());  
1923 - }  
1924 - }  
1925 - ylMap.put(maps.get("clZbh").toString()+"_"+ maps.get("jGh").toString(),maps.get("xlBm") == null ? "" : maps.get("xlBm").toString());  
1926 - }  
1927 - }  
1928 - t.setJzl(jzl);  
1929 - t.setNbbm(maps.get("clZbh").toString());  
1930 - t.setJsy(maps.get("jGh") == null ? "" : maps.get("jGh").toString());  
1931 - t.setJname(maps.get("jName").toString());  
1932 - t.setZlc(maps.get("totalKilometers") == null ? 0.0  
1933 - : Double.parseDouble(maps.get("totalKilometers").toString()));  
1934 - t.setXlbm(maps.get("xlBm") == null ? "" : maps.get("xlBm").toString());  
1935 - t.setJcsx(Integer.parseInt(maps.get("seqNumber").toString()));  
1936 - t.setSsgsdm(maps.get("company") == null ? "" : maps.get("company").toString());  
1937 - t.setFgsdm(maps.get("bCompany") == null ? "" : maps.get("bCompany").toString());  
1938 - t.setJhsj(maps.get("fcsj")==null?"":maps.get("fcsj").toString());  
1939 - t.setRq(sdf.parse(date));  
1940 - t.setLp(maps.get("lpName")==null?"":maps.get("lpName").toString());  
1941 - if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){  
1942 - if(type.equals("add")){  
1943 - if(nbbmStr.indexOf(t.getNbbm())<0){  
1944 - nbbmStr +=t.getNbbm()+",";  
1945 - }  
1946 - t.setCreatetime(new Date());  
1947 - }else{  
1948 - t.setUpdatetime(new Date());  
1949 - }  
1950 - }  
1951 - try {  
1952 - repository.save(t);  
1953 - } catch (Exception e) {  
1954 - // TODO: handle exception  
1955 - if(e.getMessage().indexOf("PK_YLB_UK")>0){  
1956 - newMap.put("fage", "存在相同数据,数据已经过滤");  
1957 - logger.info("油量存在相同数据,数据已经过滤");  
1958 - }  
1959 - }  
1960 -  
1961 - }  
1962 - for (int i = 0; i < ylbList_del.size(); i++) {  
1963 - Ylb y=ylbList_del.get(i);  
1964 - if(nbbmStr.indexOf(y.getNbbm())<0){  
1965 - nbbmStr +=y.getNbbm()+",";  
1966 - }  
1967 - repository.deleteById(y.getId());  
1968 - }  
1969 -  
1970 - //重新计算删除了的或者新增了的车的车的油耗信息(考虑车辆可能跨线路,从分公司赛选计算)  
1971 - double czyl=0.0;  
1972 - List<Ylb> iterator2=this.listOrderBy(date,gsdm,fgsdm,"","","nbbm,jcsx");  
1973 - String[] nbbms=nbbmStr.split(",");  
1974 - for (int i = 0; i < nbbms.length; i++) {  
1975 - String clzbm=nbbms[i];  
1976 - // 得到一天总的加油和里程(根据车,时间)  
1977 - List<Object[]> sumList = repository.sumLcYl(clzbm, sdf.parse(date),"",gsdm,fgsdm);  
1978 - // 保存总的加油量  
1979 - Double jzl = 0.0;  
1980 - // 保存总的里程  
1981 - Double zlc = 0.0;  
1982 - for (int j = 0; j < sumList.size(); j++) {  
1983 - jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString()));  
1984 - zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString()));  
1985 - }  
1986 - // 保留两位小数  
1987 - DecimalFormat df = new DecimalFormat("#.00");  
1988 - Double zyl = 0.0;  
1989 - Double nextJzyl = 0.0;  
1990 - for (int j = 0; j < iterator2.size(); j++) {  
1991 - Ylb t = iterator2.get(j);  
1992 - if(t.getNbbm().equals(clzbm)){  
1993 - if (t.getJcsx() == 1) {  
1994 - // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量  
1995 - czyl = t.getCzyl();  
1996 - zyl =jzl;  
1997 - Double yh=0.0;  
1998 - if(zlc>0 ){  
1999 - yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
2000 - }  
2001 - nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh);  
2002 - //把进场油量的小数和整数分别取出  
2003 - if(zlc>0 && t.getZlc()>0){  
2004 - long l=Math.round(nextJzyl);  
2005 - double ylxs=l*100/100;  
2006 - yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));  
2007 - t.setYh(yh);  
2008 - t.setJzyl(ylxs);  
2009 - nextJzyl=ylxs;  
2010 - }else{  
2011 - t.setYh(yh);  
2012 - t.setJzyl(nextJzyl);  
2013 - }  
2014 - } else {  
2015 - t.setCzyl(nextJzyl);  
2016 - Double yh=0.0;  
2017 - if(zlc>0){  
2018 - yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
2019 - }  
2020 - nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh);  
2021 - if(zlc>0 && t.getZlc()>0){  
2022 - long l=0l;  
2023 - double ylxs=0.0;  
2024 - if(j==iterator2.size()-1){  
2025 - ylxs=czyl;  
2026 - }else{  
2027 - if(iterator2.get(j+1).getNbbm().equals(t.getNbbm())){  
2028 - l=Math.round(nextJzyl);  
2029 - ylxs=l*100/100;  
2030 - }else{  
2031 - ylxs=czyl;  
2032 - }  
2033 -  
2034 - }  
2035 - yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));  
2036 - t.setYh(yh);  
2037 - t.setJzyl(ylxs);  
2038 - nextJzyl=ylxs;  
2039 - }else{  
2040 - t.setYh(yh);  
2041 - t.setJzyl(nextJzyl);  
2042 - }  
2043 - }  
2044 - if(t.getJzyl()<0){  
2045 - t.setJzyl(0.0);  
2046 - }  
2047 - if(t.getCzyl()<0){  
2048 - t.setCzyl(0.0);  
2049 - }  
2050 - if(t.getYh()<0){  
2051 - t.setYh(0.0);  
2052 - }  
2053 - if(t.getSh()<0){  
2054 - t.setSh(0.0);  
2055 - }  
2056 - repository.save(t);  
2057 - }  
2058 - }  
2059 - }  
2060 -  
2061 - //重新统计油车数据结束  
2062 -  
2063 -  
2064 - //重新获取电耗数据开始  
2065 - Map<String, List<Dlb>> mapList=dlbService.updeteHistory(listpbDc, date, gsdm, fgsdm, line);  
2066 - List<Dlb> delDlb=mapList.get("delList");  
2067 - for (int i = 0; i < delDlb.size(); i++) {  
2068 - Dlb d=delDlb.get(i);  
2069 - dlbRepository.deleteById(d.getId());  
2070 - }  
2071 - List<Dlb> updDlb=mapList.get("updList");  
2072 - for (int i = 0; i < updDlb.size(); i++) {  
2073 - Dlb d=updDlb.get(i);  
2074 - try {  
2075 - dlbRepository.save(d);  
2076 - } catch (Exception e) {  
2077 - // TODO: handle exception  
2078 - if(e.getMessage().indexOf("PK_DLB_UK")>0){  
2079 - newMap.put("fage", "存在相同数据,数据已经过滤");  
2080 - logger.info("电量存在相同数据,数据已经过滤");  
2081 - }  
2082 - }  
2083 - }  
2084 - //重新获取电耗数据结束  
2085 -  
2086 - SysUser user = SecurityUtils.getCurrentUser();  
2087 - Nylog nylog=new Nylog();  
2088 - nylog.setCreatedate(new Date());  
2089 - nylog.setCzmc("重新统计");  
2090 - nylog.setNylx("油");  
2091 - nylog.setUserid(user.getUserName());  
2092 - nylog.setUsername(user.getName());  
2093 - nylog.setCxtj(line+"-"+ date+"-"+gsdm+"-"+fgsdm);  
2094 - nylogRepository.save(nylog);  
2095 - newMap.put("status", ResponseCode.SUCCESS);  
2096 - }catch(Exception e){  
2097 - // TODO Auto-generated catch block  
2098 - newMap.put("status", ResponseCode.ERROR);  
2099 - throw e;  
2100 - }  
2101 -  
2102 -  
2103 - return newMap;  
2104 - }  
2105 -  
2106 - public List<Ylb> listByRqJcsx(String rq,String gsdm,String fgsdm,String xlbm,String nbbm) {  
2107 - List<Ylb> list=repository.listByRqJcsx(rq, gsdm, fgsdm, xlbm, nbbm);  
2108 - Map<String, Object> m=new HashMap<String,Object>();  
2109 - List<Ylb> list_=new ArrayList<Ylb>();  
2110 - for (int i = 0; i < list.size(); i++) {  
2111 - Ylb t=list.get(i);  
2112 - if(m.get(t.getNbbm())==null){  
2113 - m.put(t.getNbbm(), t.getNbbm());  
2114 - list_.add(t);  
2115 - }  
2116 - }  
2117 - return list_;  
2118 - }  
2119 -  
2120 - @Override  
2121 - public Map<String, Object> update(Map<String, Object> map) {  
2122 - if(map.get("id")!=null){  
2123 - if(map.get("id").toString().length()>0){  
2124 - Integer id=Integer.parseInt(map.get("id").toString());  
2125 - String jsy=map.get("jsy").toString();  
2126 - Ylb t=repository.findById(id).get();  
2127 - t.setJsy(jsy);  
2128 - repository.save(t);  
2129 - map.put("status", ResponseCode.SUCCESS);  
2130 - }  
2131 - }  
2132 - return map;  
2133 - }  
2134 -}  
src/main/java/com/bsth/service/oil/impl/YlxxbServiceImpl.java deleted 100644 → 0
1 -package com.bsth.service.oil.impl;  
2 -  
3 -import java.sql.ResultSet;  
4 -import java.sql.SQLException;  
5 -import java.text.DecimalFormat;  
6 -import java.text.ParseException;  
7 -import java.text.SimpleDateFormat;  
8 -import java.util.ArrayList;  
9 -import java.util.Date;  
10 -import java.util.HashMap;  
11 -import java.util.List;  
12 -import java.util.Map;  
13 -  
14 -import javax.transaction.Transactional;  
15 -  
16 -import org.apache.commons.lang3.StringEscapeUtils;  
17 -import org.slf4j.Logger;  
18 -import org.slf4j.LoggerFactory;  
19 -import org.springframework.beans.factory.annotation.Autowired;  
20 -import org.springframework.jdbc.core.JdbcTemplate;  
21 -import org.springframework.jdbc.core.RowMapper;  
22 -import org.springframework.stereotype.Service;  
23 -  
24 -import com.alibaba.fastjson.JSONArray;  
25 -import com.alibaba.fastjson.JSONObject;  
26 -import com.bsth.common.ResponseCode;  
27 -import com.bsth.entity.excep.Offline;  
28 -import com.bsth.entity.oil.Ylb;  
29 -import com.bsth.entity.oil.Ylxxb;  
30 -import com.bsth.entity.oil.YlxxbUpdate;  
31 -import com.bsth.entity.search.CustomerSpecs;  
32 -import com.bsth.repository.oil.YlbRepository;  
33 -import com.bsth.repository.oil.YlxxbRepository;  
34 -import com.bsth.repository.oil.YlxxbUpdateRepository;  
35 -import com.bsth.service.impl.BaseServiceImpl;  
36 -import com.bsth.service.oil.YlxxbService;  
37 -import com.bsth.util.PageHelper;  
38 -import com.bsth.util.PageObject;  
39 -  
40 -@Service  
41 -public class YlxxbServiceImpl extends BaseServiceImpl<Ylxxb,Integer> implements YlxxbService  
42 -{  
43 - Logger logger = LoggerFactory.getLogger(this.getClass());  
44 - @Autowired  
45 - YlxxbRepository repository;  
46 - @Autowired  
47 - YlxxbUpdateRepository updateRepository;  
48 - @Autowired  
49 - YlbRepository ylbRepository;  
50 - @Autowired  
51 - JdbcTemplate jdbcTemplate;  
52 - @Override  
53 - public PageObject<Ylxxb> Pagequery(Map<String, Object> map) {  
54 -  
55 - String rq=map.get("yyrq").toString();  
56 - String gsdm=map.get("gsdm_like").toString();  
57 - String fgsdm=map.get("fgsdm_like").toString();  
58 -  
59 - String sql=" select * from ("  
60 - + "select *,CONCAT(nbbm,jsy) as nj, CONCAT(nbbm,'_',jsy,'_',jzl) as njj "  
61 - + " from bsth_c_ylxxb where yyrq='"+rq+"' "  
62 - + " and gsdm ='"+gsdm+"' and jylx !='1') x where x.nj not in ("  
63 - + " select CONCAT(nbbm,jsy) from bsth_c_ylb "  
64 - + " where rq='"+rq+"'"  
65 - + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"')"  
66 - + " and x.nbbm in (select nbbm from bsth_c_ylb "  
67 - + " where rq='"+rq+"'"  
68 - + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"') "  
69 - + " and x.nj not in (select CONCAT(nbbm,jsy) from bsth_c_ylxxb"  
70 - + " where yyrq='"+rq+"' and gsdm ='"+gsdm+"' AND jylx in (1,3))"  
71 - + " and x.njj not in (SELECT tj FROM bsth_c_ylxxb_update "  
72 - + " where yyrq='"+rq+"' and zt='3')";  
73 -  
74 - //根具条件查询指定日期Ylb的数据  
75 -// List<Ylb> ylbIterator=ylbRepository.checkYl(rq,gsdm,fgsdm);  
76 - List<Ylxxb> list=jdbcTemplate.query(sql,  
77 - new RowMapper<Ylxxb>(){  
78 - @Override  
79 - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {  
80 - Ylxxb s = new Ylxxb();  
81 - s.setId(rs.getInt("id"));  
82 - s.setYyrq(rs.getDate("yyrq"));  
83 - s.setNbbm(rs.getString("nbbm"));  
84 - s.setGsdm(rs.getString("gsdm"));  
85 - s.setFgsdm(rs.getString("fgsdm"));  
86 - s.setJsy(rs.getString("jsy"));  
87 - s.setJzl(rs.getDouble("jzl"));  
88 - s.setStationid(rs.getString("stationid"));  
89 - s.setNylx(rs.getInt("nylx"));  
90 - s.setJyggh(rs.getString("jyggh"));  
91 - s.setYj(rs.getDouble("yj"));  
92 -// s.setLdgh(rs.getString("ldgh"));  
93 - s.setBz(rs.getString("bz"));  
94 - return s;  
95 - }  
96 - });  
97 -  
98 -  
99 - List<Ylb> listylb=ylbRepository.obtainYl(rq, gsdm, fgsdm, "", "", "nbbm");  
100 - for (int i = 0; i < list.size(); i++) {  
101 - String ldgh="";  
102 - for (int j = 0; j < listylb.size(); j++) {  
103 - Ylb ylb =listylb.get(j);  
104 - if(list.get(i).getNbbm().equals(ylb.getNbbm())){  
105 - if(ldgh.equals(""))  
106 - ldgh +=ylb.getJsy();  
107 - else  
108 - ldgh += ","+ylb.getJsy();  
109 - }  
110 - }  
111 - list.get(i).setLdgh(ldgh);  
112 -  
113 - }  
114 -  
115 -  
116 -  
117 - PageHelper pageHelper = new PageHelper(list.size(), map);  
118 - pageHelper.getMap();  
119 - PageObject<Ylxxb> pageObject = pageHelper.getPageObject();  
120 - pageObject.setDataList(list);  
121 - return pageObject;  
122 - }  
123 - @Transactional  
124 - @Override  
125 - public Map<String, Object> checkJsy(Map<String, Object> map) throws Exception{  
126 - Map<String, Object> newMap=new HashMap<String,Object>();  
127 - // TODO Auto-generated method stub  
128 - try {  
129 -// int id=Integer.parseInt(map.get("id").toString());  
130 -// String jsy=map.get("jsy").toString();  
131 -// Ylxxb ylxxb=repository.findOne(id);  
132 -// ylxxb.setJsy(jsy);  
133 -// repository.save(ylxxb);  
134 - DecimalFormat decimalFormat = new DecimalFormat("###################.###########");  
135 -  
136 - String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());  
137 - JSONArray jsonArray=JSONArray.parseArray(json);  
138 - JSONObject jsonObject;  
139 - for (int x = 0; x < jsonArray.size(); x++) {  
140 - jsonObject=jsonArray.getJSONObject(x);  
141 - Integer id =jsonObject.getInteger("id");  
142 - String jsy =jsonObject.getString("jsy");  
143 - String lsjsy =jsonObject.getString("lsjsy");  
144 - String ldgh =jsonObject.getString("ldgh");  
145 - if(!lsjsy.equals(jsy)){  
146 - if(ldgh.indexOf(jsy)>-1){  
147 - Ylxxb ylxxb=repository.findById(id).get();  
148 - YlxxbUpdate ylxxbUpdate=new YlxxbUpdate();  
149 - ylxxbUpdate.setGsdm(ylxxb.getGsdm());  
150 - ylxxbUpdate.setJsy(ylxxb.getJsy());  
151 - ylxxbUpdate.setJzl(ylxxb.getJzl());  
152 - ylxxbUpdate.setJlrq(ylxxb.getJlrq());  
153 - ylxxbUpdate.setNbbm(ylxxb.getNbbm());  
154 - ylxxbUpdate.setYyrq(ylxxb.getYyrq());  
155 - ylxxbUpdate.setCreatetime(new Date());  
156 - ylxxbUpdate.setTj(ylxxb.getNbbm()+"_"+ylxxb.getJsy()+"_"+decimalFormat.format(ylxxb.getJzl()));  
157 - ylxxbUpdate.setZt(3);  
158 - updateRepository.save(ylxxbUpdate);  
159 - ylxxb.setJsy(jsy);  
160 - ylxxb.setJylx(3);  
161 - repository.save(ylxxb);  
162 - }  
163 - }  
164 - }  
165 - newMap.put("status", ResponseCode.SUCCESS);  
166 - }catch(Exception e){  
167 - newMap.put("status", ResponseCode.ERROR);  
168 - logger.error("save erro.", e);  
169 - throw e;  
170 - }  
171 - return newMap;  
172 - }  
173 - @Override  
174 - public List<Ylxxb> Pagequery_nbbm(Map<String, Object> map) {  
175 - // TODO Auto-generated method stub  
176 - String rq=map.get("yyrq").toString();  
177 - String gsdm=map.get("gsdm_like").toString();  
178 - String fgsdm=map.get("fgsdm_like").toString();  
179 -  
180 - String nbbm=map.get("nbbm").toString();  
181 -  
182 - String sql="select * from ("  
183 - + " select t.*,CONCAT(t.nbbm,'_',t.jsy,'_',t.jzl) as tj from bsth_c_ylxxb t where "  
184 - + " t.yyrq='"+rq+"' and t.gsdm='"+gsdm+"' and t.nylx=0 and t.jylx in(0,2) "  
185 - + " and t.nbbm in (select c.inside_code from bsth_c_cars c "  
186 - + " where c.business_code ='"+gsdm+"' and c.sfdc=0 and c.branche_company_code ='"+fgsdm+"')"  
187 - + " and t.nbbm not in (select nbbm from bsth_c_ylb y "  
188 - + " where y.rq= '"+rq+"' and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"') "  
189 - + " union "  
190 - + " select t.*,CONCAT(t.nbbm,'_',t.jsy,'_',t.jzl) as tj from bsth_c_ylxxb t where "  
191 - + " t.yyrq ='"+rq+"' and t.gsdm='"+gsdm+"' and t.nylx=0 and t.jylx in(0,2) "  
192 - + " and t.nbbm not in ( select c.inside_code from bsth_c_cars c "  
193 - + " where c.business_code ='"+gsdm+"' and c.sfdc=0 )"  
194 - + " ) z"  
195 - + " where z.tj not in ("  
196 - + " SELECT x.tj FROM bsth_c_ylxxb_update x where x.yyrq='"+rq+"' and zt=2"  
197 - + " ) and z.nbbm like '%"+nbbm+"%'";  
198 -  
199 - //根具条件查询指定日期Ylb的数据  
200 -// List<Ylb> ylbIterator=ylbRepository.checkYl(rq,gsdm,fgsdm);  
201 - List<Ylxxb> list=jdbcTemplate.query(sql,  
202 - new RowMapper<Ylxxb>(){  
203 - @Override  
204 - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {  
205 - Ylxxb s = new Ylxxb();  
206 - s.setId(rs.getInt("id"));  
207 - s.setYyrq(rs.getDate("yyrq"));  
208 - s.setNbbm(rs.getString("nbbm"));  
209 - s.setGsdm(rs.getString("gsdm"));  
210 - s.setJsy(rs.getString("jsy"));  
211 - s.setJzl(rs.getDouble("jzl"));  
212 - s.setStationid(rs.getString("stationid"));  
213 - s.setNylx(rs.getInt("nylx"));  
214 - s.setJyggh(rs.getString("jyggh"));  
215 - s.setYj(rs.getDouble("yj"));  
216 -// s.setLdgh(rs.getString("ldgh"));  
217 - s.setBz(rs.getString("bz"));  
218 - return s;  
219 - }  
220 - });  
221 - return list;  
222 - }  
223 -  
224 -  
225 - @Transactional  
226 - @Override  
227 - public Map<String, Object> checkNbbm(Map<String, Object> map) throws Exception{  
228 - Map<String, Object> newMap=new HashMap<String,Object>();  
229 - // TODO Auto-generated method stub  
230 - try {  
231 -// int id=Integer.parseInt(map.get("id").toString());  
232 -// String jsy=map.get("jsy").toString();  
233 -// Ylxxb ylxxb=repository.findOne(id);  
234 -// ylxxb.setJsy(jsy);  
235 -// repository.save(ylxxb);  
236 - String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());  
237 - JSONArray jsonArray=JSONArray.parseArray(json);  
238 - DecimalFormat decimalFormat = new DecimalFormat("###################.###########");  
239 -  
240 - JSONObject jsonObject;  
241 - for (int x = 0; x < jsonArray.size(); x++) {  
242 - jsonObject=jsonArray.getJSONObject(x);  
243 - Integer id =jsonObject.getInteger("id");  
244 - String nbbm =jsonObject.getString("nbbm").trim();  
245 - Ylxxb ylxxb=repository.findById(id).get();  
246 - if(!ylxxb.getNbbm().equals(nbbm)){  
247 - ylxxb.setNbbm(nbbm);  
248 - ylxxb.setJylx(2);  
249 - repository.save(ylxxb);  
250 - YlxxbUpdate ylxxbUpdate=new YlxxbUpdate();  
251 - ylxxbUpdate.setGsdm(ylxxb.getGsdm());  
252 - ylxxbUpdate.setJsy(ylxxb.getJsy());  
253 - ylxxbUpdate.setJzl(ylxxb.getJzl());  
254 - ylxxbUpdate.setJlrq(ylxxb.getJlrq());  
255 - ylxxbUpdate.setNbbm(nbbm);  
256 - ylxxbUpdate.setYyrq(ylxxb.getYyrq());  
257 - ylxxbUpdate.setCreatetime(new Date());  
258 - ylxxbUpdate.setTj(nbbm+"_"+ylxxb.getJsy()+"_"+decimalFormat.format(ylxxb.getJzl()));  
259 - ylxxbUpdate.setZt(2);  
260 - updateRepository.save(ylxxbUpdate);  
261 - }  
262 - }  
263 - newMap.put("status", ResponseCode.SUCCESS);  
264 - }catch(Exception e){  
265 - newMap.put("status", ResponseCode.ERROR);  
266 - logger.error("save erro.", e);  
267 - throw e;  
268 - }  
269 - return newMap;  
270 - }  
271 - @Override  
272 - public Map<String, Object> saveYlxxb(Map<String, Object> map) {  
273 - // TODO Auto-generated method stub  
274 - Map<String, Object> newMap=new HashMap<String,Object>();  
275 - try{  
276 - Integer id=Integer.parseInt(map.get("id").toString());  
277 - Ylxxb t=repository.findById(id).get();  
278 - t.setJzl(Double.parseDouble(map.get("jzl").toString().trim()));  
279 - t.setNbbm(map.get("nbbm").toString().trim());  
280 - t.setJsy(map.get("jsy").toString().trim());  
281 - repository.save(t);  
282 - newMap.put("status", ResponseCode.SUCCESS);  
283 - }catch(Exception e){  
284 - newMap.put("status", ResponseCode.ERROR);  
285 - logger.error("save erro.", e);  
286 - throw e;  
287 - }  
288 - return newMap;  
289 - }  
290 -}