YlxxbServiceImpl.java
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.bsth.service.oil.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bsth.common.ResponseCode;
import com.bsth.entity.oil.Ylb;
import com.bsth.entity.oil.Ylxxb;
import com.bsth.entity.search.CustomerSpecs;
import com.bsth.repository.oil.YlbRepository;
import com.bsth.repository.oil.YlxxbRepository;
import com.bsth.service.impl.BaseServiceImpl;
import com.bsth.service.oil.YlxxbService;
import com.bsth.util.PageHelper;
import com.bsth.util.PageObject;
@Service
public class YlxxbServiceImpl extends BaseServiceImpl<Ylxxb,Integer> implements YlxxbService
{
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
YlxxbRepository repository;
@Autowired
YlbRepository ylbRepository;
@Override
public PageObject<Ylxxb> Pagequery(Map<String, Object> map) {
String rq=map.get("yyrq").toString();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
try {
map.put("yyrq_eq", sdf.parseObject(rq));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//根具条件查询指定日期Ylxxb的数据
List<Ylxxb> iterator=repository.findAll(new CustomerSpecs<Ylxxb>(map));
map.remove("yyrq_eq");
try {
map.put("rq_eq", sdf.parse(rq));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//根具条件查询指定日期Ylb的数据
List<Ylb> ylbIterator=(List<Ylb>) ylbRepository.findAll(new CustomerSpecs<Ylb>(map));
List<Ylxxb> list=new ArrayList<Ylxxb>();
for (int i = 0; i < iterator.size(); i++) {
Ylxxb y1=iterator.get(i);
boolean fage=true;
String ldgh="";
for (int j = 0; j < ylbIterator.size(); j++) {
Ylb y2 = ylbIterator.get(j);
if(y1.getNbbm().equals(y2.getNbbm())){
if(y1.getJsy().equals(y2.getJsy())){
fage=false;
}
ldgh +=y2.getJsy()+"/";
}
}
if(fage){
y1.setLdgh(ldgh);
list.add(y1);
}
}
PageHelper pageHelper = new PageHelper(list.size(), map);
pageHelper.getMap();
PageObject<Ylxxb> pageObject=pageHelper.getPageObject();
pageObject.setDataList(list);
return pageObject;
}
@Override
public Map<String, Object> checkJsy(Map<String, Object> map) {
Map<String, Object> newMap=new HashMap<String,Object>();
// TODO Auto-generated method stub
try {
int id=Integer.parseInt(map.get("id").toString());
String jsy=map.get("jsy").toString();
Ylxxb ylxxb=repository.findOne(id);
ylxxb.setJsy(jsy);
repository.save(ylxxb);
newMap.put("status", ResponseCode.SUCCESS);
}catch(Exception e){
newMap.put("status", ResponseCode.ERROR);
logger.error("save erro.", e);
}
return newMap;
}
}