Commit c34e29c0cd88eef3025766d866b4485aeedf1063

Authored by 王通
1 parent cd110d9c

1.冲突文件处理

Too many changes to show.

To preserve performance only 2 of 3 files are displayed.

src/main/java/com/bsth/filter/AccessLogFilter.java
1   -<<<<<<< HEAD
2 1 package com.bsth.filter;
3 2  
4 3 import com.alibaba.fastjson.JSON;
... ... @@ -99,105 +98,3 @@ public class AccessLogFilter extends BaseFilter {
99 98 return "[" + msg.toString() + "]";
100 99 }
101 100 }
102   -=======
103   -package com.bsth.filter;
104   -
105   -import com.alibaba.fastjson.JSON;
106   -import com.bsth.entity.sys.SysUser;
107   -import com.bsth.security.util.SecurityUtils;
108   -import com.bsth.util.IpUtils;
109   -import com.google.common.collect.Lists;
110   -import com.google.common.collect.Maps;
111   -import org.slf4j.Logger;
112   -import org.slf4j.LoggerFactory;
113   -import org.springframework.stereotype.Component;
114   -
115   -import javax.servlet.FilterChain;
116   -import javax.servlet.ServletException;
117   -import javax.servlet.http.HttpServletRequest;
118   -import javax.servlet.http.HttpServletResponse;
119   -import java.io.IOException;
120   -import java.util.Enumeration;
121   -import java.util.List;
122   -import java.util.Map;
123   -
124   -/**
125   - *
126   - * @ClassName: AccessLogFilter
127   - * @Description: TODO(记录访问日志)
128   - * @author PanZhao
129   - * @date 2016年3月17日 下午4:28:31
130   - *
131   - */
132   -@Component
133   -public class AccessLogFilter extends BaseFilter {
134   -
135   - Logger logger = LoggerFactory.getLogger(this.getClass());
136   -
137   - @Override
138   - public void doFilter(HttpServletRequest request,
139   - HttpServletResponse response, FilterChain chain)
140   - throws IOException, ServletException {
141   -
142   - SysUser user = null;
143   - if (request.getParameter("token") != null) {
144   - user = new SysUser();
145   - user.setUserName("admin");
146   - } else {
147   - user = SecurityUtils.getCurrentUser();
148   - }
149   - String username = user.getUserName();
150   - String name = user.getName();
151   - String jsessionId = request.getRequestedSessionId();
152   - String ip = IpUtils.getIpAddr(request);
153   - String userAgent = request.getHeader("User-Agent");
154   - String url = request.getRequestURI();
155   - String params = getParams(request);
156   - String headers = getHeaders(request);
157   - String method = request.getMethod();
158   -
159   - StringBuilder s = new StringBuilder();
160   - s.append(getBlock(username + " -" + name));
161   - s.append(getBlock(jsessionId));
162   - s.append(getBlock(ip));
163   - s.append(getBlock(userAgent));
164   - s.append(getBlock(url));
165   - s.append(getBlock(method));
166   - s.append(getBlock(params));
167   - s.append(getBlock(headers));
168   - s.append(getBlock(request.getHeader("Referer")));
169   -
170   - long now = System.currentTimeMillis();
171   - chain.doFilter(request, response);
172   - s.append("<cost time:").append(System.currentTimeMillis() - now).append(">");
173   - logger.info(s.toString());
174   - }
175   -
176   - private static String getParams(HttpServletRequest request) {
177   - Map<String, String[]> params = request.getParameterMap();
178   - return JSON.toJSONString(params);
179   - }
180   -
181   - private static String getHeaders(HttpServletRequest request) {
182   - Map<String, List<String>> headers = Maps.newHashMap();
183   - Enumeration<String> namesEnumeration = request.getHeaderNames();
184   - while (namesEnumeration.hasMoreElements()) {
185   - String name = namesEnumeration.nextElement();
186   - Enumeration<String> valueEnumeration = request.getHeaders(name);
187   - List<String> values = Lists.newArrayList();
188   - while (valueEnumeration.hasMoreElements()) {
189   - values.add(valueEnumeration.nextElement());
190   - }
191   - headers.put(name, values);
192   - }
193   - return JSON.toJSONString(headers);
194   - }
195   -
196   - public static String getBlock(Object msg) {
197   - if (msg == null) {
198   - msg = "";
199   - }
200   - return "[" + msg.toString() + "]";
201   - }
202   -}
203   ->>>>>>> 2021.05.11 历史版本 选择版本 查看历史版本修改当前版本和待更新版本
... ...
src/main/java/com/bsth/service/oil/impl/CwjyServiceImpl.java
1   -<<<<<<< HEAD
2   -package com.bsth.service.oil.impl;
3   -
4   -import java.io.File;
5   -import java.io.FileInputStream;
6   -import java.sql.ResultSet;
7   -import java.sql.SQLException;
8   -import java.text.DecimalFormat;
9   -import java.text.ParseException;
10   -import java.text.SimpleDateFormat;
11   -import java.util.ArrayList;
12   -import java.util.Arrays;
13   -import java.util.Date;
14   -import java.util.HashMap;
15   -import java.util.List;
16   -import java.util.Map;
17   -
18   -import javax.transaction.Transactional;
19   -
20   -import org.apache.commons.lang3.StringEscapeUtils;
21   -import org.apache.poi.hssf.usermodel.HSSFCell;
22   -import org.apache.poi.hssf.usermodel.HSSFRow;
23   -import org.apache.poi.hssf.usermodel.HSSFSheet;
24   -import org.apache.poi.hssf.usermodel.HSSFWorkbook;
25   -import org.apache.poi.poifs.filesystem.POIFSFileSystem;
26   -import org.apache.poi.ss.usermodel.Cell;
27   -import org.slf4j.Logger;
28   -import org.slf4j.LoggerFactory;
29   -import org.springframework.beans.factory.annotation.Autowired;
30   -import org.springframework.jdbc.core.JdbcTemplate;
31   -import org.springframework.jdbc.core.RowMapper;
32   -import org.springframework.stereotype.Service;
33   -
34   -import com.alibaba.fastjson.JSONArray;
35   -import com.alibaba.fastjson.JSONObject;
36   -import com.bsth.common.ResponseCode;
37   -import com.bsth.data.BasicData;
38   -import com.bsth.entity.oil.Cwjy;
39   -import com.bsth.entity.oil.Cyl;
40   -import com.bsth.entity.oil.Ylb;
41   -import com.bsth.entity.oil.Ylxxb;
42   -import com.bsth.repository.oil.CwjyRepository;
43   -import com.bsth.repository.oil.YlxxbRepository;
44   -import com.bsth.service.impl.BaseServiceImpl;
45   -import com.bsth.service.oil.CwjyService;
46   -import com.bsth.util.Arith;
47   -import com.bsth.util.PageHelper;
48   -import com.bsth.util.PageObject;
49   -
50   -@Service
51   -public class CwjyServiceImpl extends BaseServiceImpl<Cwjy,Integer> implements CwjyService
52   -{
53   - @Autowired
54   - CwjyRepository repository;
55   - @Autowired
56   - YlxxbRepository ylxxbRepository;
57   -
58   - @Autowired
59   - JdbcTemplate jdbcTemplate;
60   - Logger logger = LoggerFactory.getLogger(this.getClass());
61   - /*@SuppressWarnings("unchecked")
62   - public PageObject<Ylxxb> Pagequery(Map<String, Object> map) {
63   - int page=Integer.parseInt(map.get("page").toString());
64   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
65   -
66   - String rq=map.get("rq").toString();
67   - String nbbm="";
68   - if(map.get("nbbh")!=null){
69   - nbbm=map.get("nbbh").toString();
70   - }
71   -
72   - Object gsdmIn=map.get("gsdm_in");
73   - Object fgsdmIn=map.get("fgsdm_in");
74   - String addSql="";
75   - String gsdmLike="";
76   - String fgsdmLike="";
77   -
78   - //选择了公司
79   - if(gsdmIn==null){
80   - gsdmLike=map.get("gsdm_like").toString();
81   - addSql += " and a.gsdm = '"+gsdmLike+ "' ";
82   -
83   - //选择了分公司
84   - if(fgsdmIn==null){
85   - fgsdmLike=map.get("fgsdm_like").toString();;
86   - addSql += " and a.fgsdm = '"+fgsdmLike+ "' ";
87   - }else{
88   - String fgsdmIns[]= fgsdmIn.toString().split(",");
89   - addSql +=" and a.fgsdm in (";
90   - for(int i=0;i<fgsdmIns.length;i++){
91   - addSql +="'"+fgsdmIns[i]+"'";
92   - if(i<fgsdmIns.length-1){
93   - addSql +=",";
94   - }
95   - }
96   - addSql +=")";
97   - }
98   - }else{
99   - //没有选择公司 (分公司也没有选择)
100   - String gsdmIns[]=gsdmIn.toString().split(",");
101   - addSql += " and a.gsdm in (";
102   - for(int i=0;i<gsdmIns.length;i++){
103   - addSql +="'" +gsdmIns[i]+"'";
104   - if(i<gsdmIns.length-1){
105   - addSql+=",";
106   - }
107   - }
108   - addSql +=")";
109   - String fgsdmIns[]= fgsdmIn.toString().split(",");
110   - addSql +=" and a.fgsdm in (";
111   - for(int i=0;i<fgsdmIns.length;i++){
112   - addSql +="'"+fgsdmIns[i]+"'";
113   - if(i<fgsdmIns.length-1){
114   - addSql +=",";
115   - }
116   - }
117   - addSql +=")";
118   -
119   -
120   - }
121   - String countSql="SELECT ifnull(count(*),0) as countTs FROM bsth_c_cwjy a "+
122   - " left join ( select * from bsth_c_ylxxb b where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " +
123   - " on a.nbbm=b.nbbm left join (select nbbm,group_concat(jsy) as jsy "
124   - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+
125   - " ) c on a.nbbm=c.nbbm where a.nbbm like '%"+nbbm+"%' " +addSql ;
126   - int listsize=jdbcTemplate.queryForObject(countSql, Integer.class);
127   - // TODO Auto-generated method stub
128   - String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm,b.jsy as jsy,b.jzl as jzl ,b.stationid as stationid,"
129   - + "b.nylx as nylx,b.yj as yj,b.bz as bz,c.jsy as ldgh FROM bsth_c_cwjy a "+
130   - " left join ( select * from bsth_c_ylxxb b where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " +
131   - " on a.nbbm=b.nbbm left join (select nbbm,group_concat(jsy) as jsy "
132   - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+
133   - " ) c on a.nbbm=c.nbbm where a.nbbm like '%"+nbbm+"%' " +addSql+ " limit "+page*10+","+10;
134   -
135   -
136   - List<Ylxxb> yList= jdbcTemplate.query(sql,
137   - new RowMapper<Ylxxb>(){
138   - @Override
139   - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {
140   - Ylxxb t=new Ylxxb();
141   - t.setGsdm(rs.getString("gsdm"));
142   - t.setFgsdm(rs.getString("fgsdm"));
143   - t.setNbbm(rs.getString("nbbm"));
144   - t.setJsy(rs.getString("jsy"));
145   - t.setJzl(rs.getDouble("jzl"));
146   - t.setStationid(rs.getString("stationid"));
147   - t.setNylx(rs.getInt("nylx"));
148   - t.setYj(rs.getDouble("yj"));
149   - t.setBz(rs.getString("bz"));
150   - t.setLdgh(rs.getString("ldgh"));
151   - return t;
152   - }
153   - });
154   - List<Object[]> list=repository.obtainCwjycl(rq,nbbm);
155   - for (int i = 0; i < list.size(); i++) {
156   - Ylxxb y=new Ylxxb();
157   - y.setGsdm(list.get(i)[0]==null?"":list.get(i)[0].toString());
158   - y.setNbbm(list.get(i)[1]==null?"":list.get(i)[1].toString());
159   - y.setJsy(list.get(i)[2]==null?"":list.get(i)[2].toString());
160   - y.setJzl(list.get(i)[3]==null?0.0:Double.parseDouble(list.get(i)[3].toString()));
161   - y.setStationid(list.get(i)[4]==null?"":list.get(i)[4].toString());
162   - y.setNylx(list.get(i)[5]==null?0:Integer.parseInt(list.get(i)[5].toString()));
163   - y.setYj(list.get(i)[6]==null?0.0:Double.parseDouble(list.get(i)[6].toString()));
164   - y.setBz(list.get(i)[7]==null?"":list.get(i)[7].toString());
165   - y.setLdgh(list.get(i)[8]==null?"":list.get(i)[8].toString());
166   - try {
167   - y.setYyrq(sdf.parse(rq));
168   - } catch (ParseException e) {
169   - // TODO Auto-generated catch block
170   - e.printStackTrace();
171   - }
172   - yList.add(y);
173   - }
174   - PageHelper pageHelper = new PageHelper(listsize, map);
175   - pageHelper.getMap();
176   - PageObject<Ylxxb> pageObject=pageHelper.getPageObject();
177   - pageObject.setDataList(yList);
178   - return pageObject;
179   - }*/
180   -
181   - @Override
182   - public Ylxxb bynbbm(Map<String, Object> map) {
183   - // TODO Auto-generated method stub
184   - // TODO Auto-generated method stub
185   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
186   - String rq = map.get("rq").toString();
187   - String nbbm = "";
188   - if (map.get("nbbm") != null) {
189   - nbbm = map.get("nbbm").toString();
190   - }
191   - List<Object[]> list = repository.obtainCwjycl(rq, nbbm);
192   - Ylxxb y = new Ylxxb();
193   - if (list.size() > 0) {
194   - y.setGsdm(list.get(0)[0] == null ? "" : list.get(0)[0].toString());
195   - y.setNbbm(list.get(0)[1] == null ? "" : list.get(0)[1].toString());
196   - y.setJsy(list.get(0)[2] == null ? "" : list.get(0)[2].toString());
197   - y.setJzl(list.get(0)[3] == null ? 0.0 : Double.parseDouble(list.get(0)[3].toString()));
198   - y.setStationid(list.get(0)[4] == null ? "" : list.get(0)[4].toString());
199   - y.setNylx(list.get(0)[5] == null ? 0 : Integer.parseInt(list.get(0)[5].toString()));
200   - y.setYj(list.get(0)[6] == null ? 0.0 : Double.parseDouble(list.get(0)[6].toString()));
201   - y.setBz(list.get(0)[7] == null ? "" : list.get(0)[7].toString());
202   - y.setLdgh(list.get(0)[8] == null ? "" : list.get(0)[8].toString());
203   - try {
204   - y.setYyrq(sdf.parse(rq));
205   - } catch (ParseException e) {
206   - // TODO Auto-generated catch block
207   - e.printStackTrace();
208   - }
209   - }
210   - return y;
211   - }
212   -
213   - @Transactional
214   - @Override
215   - public Map<String, Object> savejzl(Map<String, Object> maps) throws Exception {
216   - // TODO Auto-generated method stub
217   - Map<String, Object> map=new HashMap<String,Object>();
218   - try {
219   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
220   -// String rq = sdf.format(t.getYyrq());
221   -// String nbbm=t.getNbbm();
222   -// List<Ylxxb> yList=ylxxbRepository.obtainYlxx2(rq,nbbm);
223   -// if(yList.size()>0){
224   -// t.setId(yList.get(0).getId());
225   -// ylxxbRepository.save(t);
226   -// }else{
227   -// ylxxbRepository.save(t);
228   -// }
229   - String gsbm=maps.get("gsbm").toString();
230   - String fgsbm=maps.get("fgsbm").toString();
231   - String rq=maps.get("rq").toString();
232   - Date date=sdf.parse(rq);
233   - String json =StringEscapeUtils.unescapeHtml4(maps.get("ylbList").toString());
234   - JSONArray jsonArray=JSONArray.parseArray(json);
235   - JSONObject jsonObject;
236   - // 获取车辆存油信息
237   - for (int i = 0; i < jsonArray.size(); i++) {
238   - jsonObject=jsonArray.getJSONObject(i);
239   - Integer id =jsonObject.getInteger("id");
240   - String jsy=jsonObject.getString("jsy");
241   - double jzl=jsonObject.getDoubleValue("jzl");
242   - String stationid=jsonObject.getString("stationid");
243   - String nbbm=jsonObject.getString("nbbm");
244   - int nylx=jsonObject.getIntValue("nylx");
245   - String jyggh=jsonObject.getString("jyggh");
246   - String bz=jsonObject.getString("bz");
247   - Ylxxb y;
248   - if(id>0){
249   - y=ylxxbRepository.findById(id).get();
250   - y.setJsy(jsy);
251   - y.setJzl(jzl);
252   - y.setStationid(stationid);
253   - y.setJyggh(jyggh);
254   - y.setBz(bz);
255   - y.setCreatetime(new Date());
256   - y.setYyrq(date);
257   - ylxxbRepository.save(y);
258   - }else{
259   - if(jsy!="" && jzl>0){
260   - y=new Ylxxb();
261   - y.setGsdm(gsbm);
262   - y.setJsy(jsy);
263   - y.setNbbm(nbbm);
264   - y.setJzl(jzl);
265   - y.setStationid(stationid);
266   - y.setJyggh(jyggh);
267   - y.setBz(bz);
268   - y.setCreatetime(new Date());
269   - y.setYyrq(date);
270   - y.setJylx(1);
271   - y.setNylx(0);
272   - ylxxbRepository.save(y);
273   - }
274   - }
275   - }
276   - map.put("status", ResponseCode.SUCCESS);
277   -
278   - } catch (Exception e) {
279   - map.put("status", ResponseCode.ERROR);
280   - logger.error("save erro.", e);
281   - throw e;
282   - // TODO: handle exception
283   - }
284   - return map;
285   - }
286   -
287   -
288   -
289   - @Override
290   - public List<Ylxxb> Pagequery(Map<String, Object> map) {
291   - // TODO Auto-generated method stub
292   - String rq=map.get("rq").toString();
293   - String nbbm=map.get("nbbh").toString();
294   - String gsdm=map.get("gsdm_like").toString();
295   -
296   - String fgsdm=map.get("fgsdm_like").toString();
297   - String line =map.get("line_like").toString().trim();
298   - /*String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm,"
299   - + "b.jyggh as jyggh,b.jzl as jzl ,b.stationid as stationid,b.jsy as jsy,"
300   - + "b.nylx as nylx,b.yj as yj,b.bz as bz,b.id as id ,c.jsy as ldgh FROM bsth_c_cwjy a "+
301   - " left join ("
302   - + " select * from bsth_c_ylxxb b "
303   - + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1 "
304   - + " and gsdm = '"+gsdm+"') b " +
305   - " on a.nbbm=b.nbbm "
306   - + "left join (select nbbm,group_concat(jsy) as jsy "
307   - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) "
308   - + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' group by nbbm "+
309   - " ) c on a.nbbm=c.nbbm "
310   - + "where a.nbbm like '%"+nbbm+"%' and a.gsdm='"+gsdm+"' and a.fgsdm ='"+fgsdm+"'"
311   - + " order by a.nbbm";*/
312   - String sql= " select * from bsth_c_ylxxb b "
313   - + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1 "
314   - + " and gsdm = '"+gsdm+"'";
315   -
316   - List<Ylxxb> yList= jdbcTemplate.query(sql,
317   - new RowMapper<Ylxxb>(){
318   - @Override
319   - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {
320   - Ylxxb t=new Ylxxb();
321   - t.setId(rs.getInt("id"));
322   - t.setGsdm(rs.getString("gsdm"));
323   - t.setFgsdm(rs.getString("fgsdm"));
324   - t.setNbbm(rs.getString("nbbm"));
325   - t.setJyggh(rs.getString("jyggh"));
326   - t.setJsy(rs.getString("jsy"));
327   - t.setJzl(rs.getDouble("jzl"));
328   - t.setStationid(rs.getString("stationid"));
329   - t.setNylx(rs.getInt("nylx"));
330   - t.setYj(rs.getDouble("yj"));
331   - t.setBz(rs.getString("bz"));
332   - return t;
333   - }
334   - });
335   - List<Cwjy> cwList=null;
336   - if(line.equals("")){
337   - cwList = repository.selectAll(nbbm, gsdm, fgsdm);
338   - }else{
339   - cwList = repository.selectAll_s(nbbm, gsdm, fgsdm, line);
340   - }
341   -
342   - String sql_ylb="SELECT nbbm,group_concat(jsy) AS jsy FROM bsth_c_ylb WHERE "
343   - + " rq = '"+rq+"' AND ssgsdm = '"+gsdm+"' AND "
344   - + " fgsdm = '"+fgsdm+"' GROUP BY nbbm";
345   -
346   - List<Map<String, String>> ylbList= jdbcTemplate.query(sql_ylb,
347   - new RowMapper<Map<String, String>>(){
348   - @Override
349   - public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
350   - Map<String, String> maps =new HashMap<String, String>();
351   - maps.put("nbbm", rs.getString("nbbm"));
352   - maps.put("ldgh", rs.getString("jsy"));
353   - return maps;
354   - }
355   - });
356   -
357   - List<Ylxxb> ylxxbList= new ArrayList<Ylxxb>();
358   - Ylxxb y=null;
359   - for (int i = 0; i < cwList.size(); i++) {
360   - Cwjy cwjy=cwList.get(i);
361   - y=new Ylxxb();
362   - y.setNylx(0);
363   - y.setId(0);
364   - y.setJzl(0.0);
365   - y.setGsdm(cwjy.getGsdm());
366   - y.setFgsdm(cwjy.getFgsdm());
367   - y.setNbbm(cwjy.getNbbm());
368   - y.setLinename(cwjy.getLinename());
369   - for (int j = 0; j < yList.size(); j++) {
370   - Ylxxb ylxxb=yList.get(j);
371   - if(y.getNbbm().equals(ylxxb.getNbbm())){
372   - y.setId(ylxxb.getId());
373   - y.setJyggh(ylxxb.getJyggh());
374   - y.setJsy(ylxxb.getJsy());
375   - y.setJzl(ylxxb.getJzl());
376   - y.setStationid(ylxxb.getStationid());
377   - y.setNylx(ylxxb.getNylx());
378   - y.setYj(ylxxb.getYj());
379   - y.setBz(ylxxb.getBz());
380   - break;
381   - }
382   - }
383   - for (int j = 0; j < ylbList.size(); j++) {
384   - Map<String, String> m=ylbList.get(j);
385   - if(m.get("nbbm").toString().equals(cwjy.getNbbm())){
386   - y.setLdgh(m.get("ldgh").toString());
387   - break;
388   - }
389   -
390   - }
391   -
392   - ylxxbList.add(y);
393   -
394   - }
395   -
396   - return ylxxbList;
397   - }
398   -
399   - @Override
400   - public int checkNbbm(Cwjy t) {
401   - // TODO Auto-generated method stub
402   - String sql="select count(*) from bsth_c_cwjy where nbbm ='"+t.getNbbm()+"'"
403   - + " and gsdm ='"+t.getFgsdm()+"' and fgsdm ='"+t.getFgsdm()+"'";
404   - int cs=jdbcTemplate.queryForObject(sql, Integer.class);
405   -
406   - return cs;
407   - }
408   -
409   - @Override
410   - public List<Ylxxb> cwjyList(Map<String, Object> map) {
411   - String rq=map.get("rq").toString();
412   - String nbbm=map.get("nbbh").toString();
413   - String gsdm=map.get("gsdm_like").toString();
414   -
415   - String fgsdm=map.get("fgsdm_like").toString();
416   - String line =map.get("line_like").toString().trim();
417   - boolean type=false;
418   - if(map.get("type")!=null){
419   - type=true;
420   - }
421   - String sql="select a.nbbm,a.gsdm,a.fgsdm,IFNULL(b.id,0) as id,IFNULL(b.jzl,0) as jzl,"
422   - + " IFNULL(b.jyggh,0) as jyggh,IFNULL(b.jsy,0) as jsy,IFNULL(b.stationid,0) as stationid ,"
423   - + " IFNULL(b.yj,0) as yj,IFNULL(b.nylx,0) as nylx,IFNULL(b.bz,'') as bz,IFNULL(c.jsy,'') as ldgh ,"
424   - + " IFNULL(c.xlname,c.linename) as xlname from "
425   - + " (select * from bsth_c_cwjy where gsdm='"+gsdm+"' and fgsdm='"+fgsdm+"') a "
426   - + " left join (select * from bsth_c_ylxxb where yyrq='"+rq+"' and gsdm='"+gsdm+"' and jylx=1) b"
427   - + " on a.nbbm=b.nbbm LEFT JOIN (select u.nbbm,u.jsy,v.linename,v.xlname,v.xlbm from(select a.nbbm,GROUP_CONCAT(a.jsy) as jsy "
428   - + " from (select nbbm,jsy from bsth_c_ylb x where x.rq='"+rq+"' "
429   - + " and x.ssgsdm='"+gsdm+"' and x.fgsdm='"+fgsdm+"' group by nbbm,jsy ) a group by a.nbbm) u"
430   - + " LEFT JOIN(select o.nbbm,GROUP_CONCAT(o.xlbm) xlbm ,GROUP_CONCAT(o.linename) as xlname,"
431   - + " GROUP_CONCAT(p.`name`) as linename from (select nbbm,xlbm,linename from bsth_c_ylb "
432   - + " where rq='"+rq+"' and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"' group by nbbm,xlbm,linename) o "
433   - + " LEFT JOIN bsth_c_line p on o.xlbm=p.line_code group by o.nbbm ) v on u.nbbm=v.nbbm) c "
434   - + " on a.nbbm=c.nbbm where 1=1 ";
435   - if(!nbbm.equals("")){
436   - sql +=" and a.nbbm like '%"+nbbm+"%'";
437   - }
438   - if(!line.equals("")){
439   - sql += " and c.xlbm ='"+line+"'";
440   - }
441   - if(type){
442   - sql +=" and c.xlbm is not null";
443   - }
444   - sql +=" order by xlname desc";
445   - List<Ylxxb> yList= jdbcTemplate.query(sql,
446   - new RowMapper<Ylxxb>(){
447   - @Override
448   - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {
449   - Ylxxb t=new Ylxxb();
450   - t.setId(rs.getInt("id"));
451   - t.setGsdm(rs.getString("gsdm"));
452   - t.setFgsdm(rs.getString("fgsdm"));
453   - t.setNbbm(rs.getString("nbbm"));
454   - t.setJyggh(rs.getString("jyggh"));
455   - t.setJsy(rs.getString("jsy"));
456   - t.setJzl(rs.getDouble("jzl"));
457   - t.setStationid(rs.getString("stationid"));
458   - t.setNylx(rs.getInt("nylx"));
459   - t.setYj(rs.getDouble("yj"));
460   - t.setBz(rs.getString("bz"));
461   - t.setLdgh(rs.getString("ldgh"));
462   - t.setLinename(rs.getString("xlname"));
463   - return t;
464   - }
465   - });
466   - return yList;
467   - }
468   -
469   -
470   - @Override
471   - public String importExcel(File file, String gsbm, String gsName) {
472   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
473   - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
474   - DecimalFormat df = new DecimalFormat("######0.00");
475   - List<String> textList = new ArrayList<String>();
476   - try {
477   - POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file));
478   - HSSFWorkbook wb = new HSSFWorkbook(fs);
479   - HSSFSheet sheet = wb.getSheetAt(0);
480   - // 取得总行数
481   - int rowNum = sheet.getLastRowNum() + 1;
482   - // 取得总列数
483   - int cellNum = sheet.getRow(0).getLastCellNum();
484   - HSSFRow row = null;
485   - HSSFCell cell = null;
486   - for(int i = 2; i < rowNum; i++){
487   - row = sheet.getRow(i);
488   - if (row == null){
489   - continue;
490   - }
491   - String text = "";
492   - for(int j = 0; j < cellNum; j++){
493   - cell = row.getCell(j);
494   - if(cell == null){
495   - text += ",";
496   - continue;
497   - }
498   - text += String.valueOf(cell) + ",";
499   - }
500   - String[] split = (text+";").split(",");
501   - String str = "";
502   - for(int j = 0; j < split.length && j < 5; j++){
503   - str += split[j];
504   - }
505   - if(str.trim().length() == 0){
506   - continue;
507   - }
508   - textList.add(text + ";");
509   - }
510   - for(int i = 0; i < textList.size(); i++){
511   - String text = textList.get(i);
512   - System.out.println(text);
513   - String[] split = text.split(",");
514   - String rq = split[0].trim();
515   - String nbbm = split[1].trim();
516   - String jsy = split[2].trim();
517   - double jzl = Double.valueOf(split[3].trim().length()!=0?split[3]:"0");
518   - String jyz = split[4].trim();
519   - String remarks = split[5].trim();
520   - if(rq.trim().length() == 0){
521   - rq = sdf.format(new Date());
522   - }
523   -
524   - List<Double> jzl_ = repository.import_queryBySame(gsbm, rq, nbbm);
525   -//
526   - if(jzl_.size() == 0){
527   - repository.import_insertData(gsbm, rq, nbbm, jsy,
528   - df.format(jzl), jyz, remarks, sd.format(new Date()));
529   - }else{
530   - repository.import_UpdateJzl(df.format(jzl), jsy, jyz, remarks, gsbm, rq, nbbm);
531   - }
532   - }
533   -
534   - /** 以下为测试导入ylxxb用 */
535   -// Date date = new Date();
536   -// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
537   -// for(int i = 1; i < rowNum; i++){
538   -// row = sheet.getRow(i);
539   -// if (row == null){
540   -// continue;
541   -// }
542   -// String text = "";
543   -// for(int j = 0; j < cellNum; j++){
544   -// cell = row.getCell(j);
545   -// if(cell == null){
546   -// text += ",";
547   -// continue;
548   -// }
549   -// if(j == 1 && cell.getCellType() == Cell.CELL_TYPE_NUMERIC){
550   -// text += dateFormat.format(cell.getDateCellValue()) + ",";
551   -// } else if(j == 4 || j == 7){
552   -// text += "0,";
553   -//// } else if(j == 6 && String.valueOf(cell).contains("-")){
554   -//// String str = String.valueOf(cell);
555   -//// text += str.split("-")[1] + ",";
556   -// } else {
557   -// text += String.valueOf(cell) + ",";
558   -// }
559   -// }
560   -// System.out.println(text);
561   -// Ylxxb ylxxb = new Ylxxb();
562   -// String[] split = text.split(",");
563   -// ylxxb.setCreatetime(date);
564   -// ylxxb.setYyrq(sdf.parse(split[0].trim()));
565   -// ylxxb.setJlrq(dateFormat.parse(split[1]));
566   -// ylxxb.setFromgsdm("22");
567   -// ylxxb.setNbbm(split[2]);
568   -// ylxxb.setJzl(Double.valueOf(split[3]));
569   -// ylxxb.setNylx(Integer.valueOf(split[4]));
570   -// ylxxb.setStationid(split[5]);
571   -// if(split[6].contains("-")){
572   -// ylxxb.setJsy(split[6].split("-")[1]);
573   -// }
574   -// ylxxb.setBz(split[6]);
575   -// ylxxb.setJylx(Integer.valueOf(split[7]));
576   -// ylxxbRepository.save(ylxxb);
577   -// }
578   - wb.close();
579   - fs.close();
580   - } catch (Exception e) {
581   - // TODO Auto-generated catch block
582   - e.printStackTrace();
583   - return "文件导入失败";
584   - } finally {
585   - file.delete();
586   - }
587   - return "文件导入成功";
588   - }
589   -
590   -
591   -}
592   -=======
593 1 package com.bsth.service.oil.impl;
594 2  
595 3 import java.io.File;
... ... @@ -1179,5 +587,4 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw
1179 587 }
1180 588  
1181 589  
1182   -}
1183   ->>>>>>> 2021.05.11 历史版本 选择版本 查看历史版本修改当前版本和待更新版本
  590 +}
1184 591 \ No newline at end of file
... ...