Commit 51fd0cc8af8f04c910f60ca899b02606d46e356d

Authored by 娄高锋
1 parent 4c82259a

新增接口:浦东公交线路调查表,给郑鑫的。

src/main/java/com/bsth/server_rs/bigdata/BigdataService.java
... ... @@ -31,13 +31,16 @@ import org.springframework.jdbc.core.JdbcTemplate;
31 31 import org.springframework.jdbc.core.RowMapper;
32 32 import org.springframework.stereotype.Component;
33 33  
  34 +import com.alibaba.fastjson.JSON;
34 35 import com.alibaba.fastjson.JSONObject;
35 36 import com.bsth.common.BusinessCodeData;
  37 +import com.bsth.entity.CalcInvestigateMonth;
36 38 import com.bsth.entity.ChildTaskPlan;
37 39 import com.bsth.entity.DestroySituation;
38 40 import com.bsth.entity.ElecInfo;
39 41 import com.bsth.entity.OilInfo;
40 42 import com.bsth.entity.ScheduleRealInfo;
  43 +import com.bsth.repository.CalcInvestigateMonthRepository;
41 44 import com.bsth.repository.DestroySituationRepository;
42 45 import com.bsth.repository.ElecInfoRepository;
43 46 import com.bsth.repository.OilInfoRepository;
... ... @@ -66,6 +69,10 @@ public class BigdataService {
66 69 @Autowired
67 70 private ElecInfoRepository elecInfoRepository;
68 71  
  72 + @Autowired
  73 + private CalcInvestigateMonthRepository calcInvestigateMonthRepository;
  74 +
  75 +
69 76 DecimalFormat df = new DecimalFormat("0.00");
70 77  
71 78 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
... ... @@ -2066,4 +2073,75 @@ public class BigdataService {
2066 2073 return resList;
2067 2074 }
2068 2075  
  2076 + /**
  2077 + * 浦东公交线路调查表(给郑鑫)
  2078 + * @param date
  2079 + * @return
  2080 + * @throws ParseException
  2081 + */
  2082 + @GET
  2083 + @Path("/calcInvestigateMonth/month/{month}/{gs}/{fgs}/{line}")
  2084 + public List<JSONObject> calcInvestigateMonth(@PathParam("month") String month,
  2085 + @PathParam("gs") String gs, @PathParam("fgs") String fgs,
  2086 + @PathParam("line") String line) throws ParseException {
  2087 + List<JSONObject> resList = new ArrayList<JSONObject>();
  2088 +
  2089 + String xlSql="SELECT line_code, name, nature from bsth_c_line";
  2090 + List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql,
  2091 + new RowMapper<Map<String, Object>>(){
  2092 + @Override
  2093 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  2094 + Map<String, Object> m=new HashMap<String,Object>();
  2095 + m.put("lineCode", rs.getString("line_code"));
  2096 + m.put("lineName", rs.getString("name"));
  2097 + m.put("nature", rs.getString("nature"));
  2098 + return m;
  2099 + }
  2100 + });
  2101 + Set<String> yyLine = new HashSet<String>();
  2102 + for(Map<String, Object> t : xlList){
  2103 + if(t.get("lineCode") != null){
  2104 + String nature = t.get("nature")!=null?t.get("nature").toString():"";
  2105 + if("yxl".equals(nature) || "cgxl".equals(nature) || "gjxl".equals(nature)
  2106 + || "csbs".equals(nature) || "cctxl".equals(nature)){
  2107 + yyLine.add(t.get("lineCode").toString());
  2108 + }
  2109 + }
  2110 + }
  2111 +
  2112 + if(gs == null || gs.trim().length() == 0){ //公司编码别传空值,就让传all代表全部
  2113 + gs = "xxxx";
  2114 + }
  2115 + if("all".equals(gs.trim())){
  2116 + gs = "";
  2117 + }
  2118 + if(fgs == null || fgs.trim().length() == 0){ //分公司编码别传空值,就让传all代表全部
  2119 + fgs = "xxxx";
  2120 + }
  2121 + if("all".equals(fgs.trim())){
  2122 + fgs = "";
  2123 + }
  2124 +
  2125 + List<CalcInvestigateMonth> list = new ArrayList<CalcInvestigateMonth>();
  2126 + if(line != null && !"all".equals(line.trim())){
  2127 + list = calcInvestigateMonthRepository.findByMonthAndLine(month, line);
  2128 + } else if(gs != null && gs.length() > 0){
  2129 + list = calcInvestigateMonthRepository.findByMonth(month, gs, fgs);
  2130 + } else {
  2131 + list = calcInvestigateMonthRepository.findByMonth(month);
  2132 + }
  2133 +
  2134 + for(CalcInvestigateMonth c : list){
  2135 + if(yyLine.contains(c.getXl())){
  2136 + JSONObject jsonObject = (JSONObject)JSON.toJSON(c);
  2137 + jsonObject.put("gsName", BusinessCodeData.code2Name.get(jsonObject.get("gsbm").toString()));
  2138 + jsonObject.put("fgsName", BusinessCodeData.code2Name.get(jsonObject.get("gsbm").toString()
  2139 + + "_" + jsonObject.get("fgsbm").toString()));
  2140 + resList.add(jsonObject);
  2141 + }
  2142 + }
  2143 +
  2144 + return resList;
  2145 + }
  2146 +
2069 2147 }
... ...