Commit f7ebb9663d0dd8ffb21777ee0df6d00204a50fc1
1 parent
e085fc58
加电量数据源表变化
Showing
1 changed file
with
46 additions
and
44 deletions
src/main/java/com/bsth/server_rs/electric/ElectricService.java
| 1 | -package com.bsth.server_rs.electric; | ||
| 2 | - | ||
| 3 | -import com.bsth.server_ws.electric_oil.entity.Electric; | ||
| 4 | -import org.slf4j.Logger; | ||
| 5 | -import org.slf4j.LoggerFactory; | ||
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 8 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 9 | -import org.springframework.stereotype.Component; | ||
| 10 | - | ||
| 11 | -import javax.ws.rs.GET; | ||
| 12 | -import javax.ws.rs.Path; | ||
| 13 | -import javax.ws.rs.PathParam; | ||
| 14 | -import javax.ws.rs.Produces; | ||
| 15 | -import javax.ws.rs.core.MediaType; | ||
| 16 | -import java.util.List; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * Created by panzhao on 2018/3/27. | ||
| 20 | - */ | ||
| 21 | -@Component | ||
| 22 | -@Path("/electric") | ||
| 23 | -@Produces({MediaType.APPLICATION_JSON}) | ||
| 24 | -public class ElectricService { | ||
| 25 | - | ||
| 26 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 27 | - | ||
| 28 | - @Autowired | ||
| 29 | - JdbcTemplate jdbcTemplate; | ||
| 30 | - | ||
| 31 | - @GET | ||
| 32 | - @Path("/{company}/{rq}") | ||
| 33 | - public List<Electric> list(@PathParam("company") String company, @PathParam("rq") String rq){ | ||
| 34 | - List<Electric> list = null; | ||
| 35 | - try { | ||
| 36 | - //从数据库查询 | ||
| 37 | - list = jdbcTemplate.query("select fgs_bm,fgs_name,gs_bm,gs_name,jdl,jdz,remarks,rq,creater_date,nbbm,jsy from bsth_c_jdl where gs_bm="+company+" and rq='"+rq+"'" | ||
| 38 | - , BeanPropertyRowMapper.newInstance(Electric.class)); | ||
| 39 | - }catch (Exception e){ | ||
| 40 | - logger.error("", e); | ||
| 41 | - } | ||
| 42 | - return list; | ||
| 43 | - } | ||
| 44 | -} | 1 | +package com.bsth.server_rs.electric; |
| 2 | + | ||
| 3 | +import com.bsth.server_ws.electric_oil.entity.Electric; | ||
| 4 | +import org.slf4j.Logger; | ||
| 5 | +import org.slf4j.LoggerFactory; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 8 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 9 | +import org.springframework.stereotype.Component; | ||
| 10 | + | ||
| 11 | +import javax.ws.rs.GET; | ||
| 12 | +import javax.ws.rs.Path; | ||
| 13 | +import javax.ws.rs.PathParam; | ||
| 14 | +import javax.ws.rs.Produces; | ||
| 15 | +import javax.ws.rs.core.MediaType; | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Created by panzhao on 2018/3/27. | ||
| 20 | + */ | ||
| 21 | +@Component | ||
| 22 | +@Path("/electric") | ||
| 23 | +@Produces({MediaType.APPLICATION_JSON}) | ||
| 24 | +public class ElectricService { | ||
| 25 | + | ||
| 26 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + JdbcTemplate jdbcTemplate; | ||
| 30 | + | ||
| 31 | + @GET | ||
| 32 | + @Path("/{company}/{rq}") | ||
| 33 | + public List<Electric> list(@PathParam("company") String company, @PathParam("rq") String rq){ | ||
| 34 | + List<Electric> list = null; | ||
| 35 | + try { | ||
| 36 | + //从数据库查询 | ||
| 37 | + //list = jdbcTemplate.query("select fgs_bm,fgs_name,gs_bm,gs_name,jdl,jdz,remarks,rq,creater_date,nbbm,jsy from bsth_c_jdl where gs_bm="+company+" and rq='"+rq+"'" | ||
| 38 | + // , BeanPropertyRowMapper.newInstance(Electric.class)); | ||
| 39 | + list = jdbcTemplate.query("select fgsdm as fgs_bm,b.business_name,ssgsdm as gs_bm,c.business_name,cdl as jdl,'' as jdz,'' as remarks,rq,createtime as creater_date,nbbm,'' as jsy from (select fgsdm,ssgsdm,sum(cdl * 1000) / 1000 as cdl,rq,max(createtime) as createtime,nbbm from bsth_c_dlb where rq = '2018-08-20' GROUP BY fgsdm,ssgsdm,rq,nbbm) a left join bsth_c_business b on a.ssgsdm = b.business_code LEFT JOIN bsth_c_business c on concat(a.ssgsdm, '_', a.fgsdm) = concat(c.up_code, '_', c.business_code) where ssgsdm="+company+" and rq='"+rq+"'" | ||
| 40 | + , BeanPropertyRowMapper.newInstance(Electric.class)); | ||
| 41 | + }catch (Exception e){ | ||
| 42 | + logger.error("", e); | ||
| 43 | + } | ||
| 44 | + return list; | ||
| 45 | + } | ||
| 46 | +} |