Commit c2a61e1449afdda90086e87e645ca229e96436fc

Authored by 廖磊
1 parent 829cc488

电量表添加

src/main/java/com/bsth/service/oil/impl/DlbServiceImpl.java
... ... @@ -48,6 +48,7 @@ import com.bsth.service.impl.BaseServiceImpl;
48 48 import com.bsth.service.oil.DlbService;
49 49 import com.bsth.service.realcontrol.ScheduleRealInfoService;
50 50 import com.bsth.util.Arith;
  51 +import com.bsth.util.BatchSaveUtils;
51 52  
52 53 @Service
53 54 public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbService{
... ... @@ -245,8 +246,8 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
245 246 List<Cdl> cdyList=cdlRepository.obtainCdl();
246 247 //从排班表中计算出行驶的总里程
247 248 List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList(line,rq,"","","","");
248   - List<Ylb> addList=new ArrayList<Ylb>();
249   - List<Ylb> updateList=new ArrayList<Ylb>();
  249 + List<Dlb> addList=new ArrayList<Dlb>();
  250 + List<Dlb> updateList=new ArrayList<Dlb>();
250 251 for(int x=0;x<listpb.size();x++){
251 252 String type="add";
252 253 boolean sfdc=false;
... ... @@ -332,12 +333,11 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
332 333 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
333 334 t.setRq(sdf.parse(rq));
334 335 t.setCreatetime(new Date());
335   - /*if(type.equals("add")){
  336 + if(type.equals("add")){
336 337 addList.add(t);
337 338 }else{
338 339 updateList.add(t);
339   - }*/
340   - repository.save(t);
  340 + }
341 341 newMap.put("status", ResponseCode.SUCCESS);
342 342 } catch (ParseException e) {
343 343 // TODO Auto-generated catch block
... ... @@ -346,20 +346,30 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
346 346 }
347 347 }
348 348 }
349   - /* try {
  349 + try {
350 350 if(addList.size()>0){
351   - new BatchSaveUtils<Ylb>().saveList(addList, Ylb.class);
  351 + try{
  352 + new BatchSaveUtils<Dlb>().saveList(addList, Dlb.class);
  353 + } catch (Exception e) {
  354 + // TODO: handle exception
  355 + if(e.getMessage().indexOf("PK_DLB_UK")>0){
  356 + newMap.put("fage", "存在相同数据,数据已经过滤");
  357 + logger.info("获取:存在相同数据,数据已经过滤");
  358 + }
  359 + }
352 360 }
353 361  
354 362 if(updateList.size()>0){
355   -
  363 + for (int i = 0; i < updateList.size(); i++) {
  364 + repository.save(updateList.get(i));
  365 + }
356 366 }
357 367 newMap.put("status", ResponseCode.SUCCESS);
358 368 }
359 369 catch (Exception e) {
360 370 // TODO: handle exception
361 371 newMap.put("status", ResponseCode.ERROR);
362   - }*/
  372 + }
363 373 return newMap;
364 374 }
365 375  
... ...