Commit 4a6f4bc424492bd952a6b68567b407a86c2da5ae

Authored by 王通
1 parent 469f70ee

1.加入统计项接口/statistis

src/main/java/com/bsth/CXFConfig.java
@@ -26,6 +26,7 @@ import com.bsth.server_rs.rate.RateService; @@ -26,6 +26,7 @@ import com.bsth.server_rs.rate.RateService;
26 import com.bsth.server_rs.schedule.plan.SchedulePlanService; 26 import com.bsth.server_rs.schedule.plan.SchedulePlanService;
27 import com.bsth.server_rs.schedule.real.ScheduleRealService; 27 import com.bsth.server_rs.schedule.real.ScheduleRealService;
28 import com.bsth.server_rs.schedule.real.StaffViewRealService; 28 import com.bsth.server_rs.schedule.real.StaffViewRealService;
  29 +import com.bsth.server_rs.statistic.StatisticRestService;
29 import com.bsth.server_rs.waybill.WaybillRestService; 30 import com.bsth.server_rs.waybill.WaybillRestService;
30 import com.bsth.server_ws.attendance.AttendanceServiceSoap; 31 import com.bsth.server_ws.attendance.AttendanceServiceSoap;
31 import com.bsth.server_ws.electric_oil.OilServiceSoap; 32 import com.bsth.server_ws.electric_oil.OilServiceSoap;
@@ -146,6 +147,9 @@ public class CXFConfig { @@ -146,6 +147,9 @@ public class CXFConfig {
146 @Autowired 147 @Autowired
147 private BxRestService bxRestService; 148 private BxRestService bxRestService;
148 149
  150 + @Autowired
  151 + private StatisticRestService statisticRestService;
  152 +
149 @Bean 153 @Bean
150 public Server rsServer() { 154 public Server rsServer() {
151 JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); 155 JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
@@ -175,7 +179,8 @@ public class CXFConfig { @@ -175,7 +179,8 @@ public class CXFConfig {
175 dksRestService, 179 dksRestService,
176 xxfbRestService, 180 xxfbRestService,
177 manHoursRestService, 181 manHoursRestService,
178 - bxRestService)); 182 + bxRestService,
  183 + statisticRestService));
179 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); 184 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
180 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); 185 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
181 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); 186 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
src/main/java/com/bsth/server_rs/statistic/StatisticRestService.java 0 → 100644
  1 +package com.bsth.server_rs.statistic;
  2 +
  3 +import com.bsth.server_rs.base_info.car.Car;
  4 +import com.bsth.server_rs.base_info.car.buffer.CarBufferData;
  5 +import org.joda.time.DateTime;
  6 +import org.joda.time.format.DateTimeFormat;
  7 +import org.joda.time.format.DateTimeFormatter;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import javax.ws.rs.GET;
  13 +import javax.ws.rs.Path;
  14 +import javax.ws.rs.PathParam;
  15 +import javax.ws.rs.Produces;
  16 +import javax.ws.rs.core.MediaType;
  17 +import java.util.ArrayList;
  18 +import java.util.HashMap;
  19 +import java.util.List;
  20 +import java.util.Map;
  21 +
  22 +@Component
  23 +@Path("/statistic")
  24 +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  25 +public class StatisticRestService {
  26 +
  27 + @Autowired
  28 + private JdbcTemplate jdbcTemplate;
  29 +
  30 + private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
  31 +
  32 + /**
  33 + * 查询统计项,日期不能晚于当前14天
  34 + * @param rq yyyy-MM-dd
  35 + * @return
  36 + */
  37 + @GET
  38 + @Path("/line/all/{rq}")
  39 + public List<Map<String, Object>> findAll(@PathParam("rq") String rq) {
  40 + DateTime dateTime = formatter.parseDateTime(rq);
  41 + if (dateTime.isAfterNow() || dateTime.plusDays(15).isBeforeNow()) {
  42 + return new ArrayList<>();
  43 + }
  44 + return jdbcTemplate.queryForList("select date, xl, xl_name, jhcc, sjcc, jhyylc, sjyylc,jhbc, sjbc, jhsmbcs, sjsmbczds,jhszfcs, sjszfczds from bsth_c_calc_count where date = ?", rq);
  45 + }
  46 +}