Browse Source

价格表查询

dongql 7 years ago
parent
commit
9b8c6a0e75

+ 0 - 1
oa_service/src/main/java/com/bjlt/spider/table/controller/OaLineInExcelController.java

@@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.sql.SQLException;
 import java.util.List;
 
 @RequestMapping(value = "/oaLineInExcel")

+ 38 - 0
oa_service/src/main/java/com/bjlt/spider/table/controller/OaPriceInExcelController.java

@@ -0,0 +1,38 @@
+package com.bjlt.spider.table.controller;
+
+import com.bjlt.spider.entity.OaPriceInExcel;
+import com.bjlt.spider.table.service.OaPriceInExcelService;
+import com.bjlt.spider.utils.LayuiTableRespEntity;
+import groovy.util.logging.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
+
+@RequestMapping(value = "/oaPriceInExcel")
+@Slf4j
+@Controller
+public class OaPriceInExcelController {
+
+    @Autowired
+    OaPriceInExcelService oaPriceInExcelService;
+
+    @RequestMapping(value = "/find",method = RequestMethod.POST)
+    @ResponseBody
+    public LayuiTableRespEntity listPageOaPriceInExcel(OaPriceInExcel oaPriceInExcel, String pageIndex, String pageSize){
+        LayuiTableRespEntity layuiTableRespEntity = new LayuiTableRespEntity();
+        oaPriceInExcel.setStart(Integer.parseInt(pageIndex)-1);
+        oaPriceInExcel.setSize(Integer.parseInt(pageSize));
+        List<OaPriceInExcel> list = oaPriceInExcelService.listPageOaPriceInExcel(oaPriceInExcel);
+        layuiTableRespEntity.setCount(oaPriceInExcel.getTotal());
+        layuiTableRespEntity.setList(list);
+        layuiTableRespEntity.setMsg("获取成功");
+        layuiTableRespEntity.setRel(true);
+
+        return layuiTableRespEntity;
+    }
+
+}

+ 10 - 0
oa_service/src/main/java/com/bjlt/spider/table/dao/OaPriceInExcelDao.java

@@ -0,0 +1,10 @@
+package com.bjlt.spider.table.dao;
+
+import com.bjlt.spider.entity.OaPriceInExcel;
+
+import java.util.List;
+
+public interface OaPriceInExcelDao {
+
+    List<OaPriceInExcel> listPageOaPriceInExcel(OaPriceInExcel oaPriceInExcel);
+}

+ 87 - 0
oa_service/src/main/java/com/bjlt/spider/table/dao/impl/OaPriceInExcelDaoImpl.java

@@ -0,0 +1,87 @@
+package com.bjlt.spider.table.dao.impl;
+
+import com.bjlt.spider.entity.OaPriceInExcel;
+import com.bjlt.spider.table.dao.OaPriceInExcelDao;
+import groovy.util.logging.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Repository
+public class OaPriceInExcelDaoImpl implements OaPriceInExcelDao {
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Override
+    public List<OaPriceInExcel> listPageOaPriceInExcel(OaPriceInExcel oaPriceInExcel) {
+        StringBuffer stringBuffer = new StringBuffer();
+        String select = "select id,price_table_uuid as priceTableUuid, from_city as fromCity,ret_cicy as retCicy,from_date as fromDate,adult_tax as adultTax,adult_score as adultScore,dep_airport as depAirport,arr_airport as arrAirport,arr_time as arrTime,dep_time as depTime,flight_number as flightNumber from oa_price_in_excel ";
+        stringBuffer.append(select);
+        Map<String,Object> map= map(oaPriceInExcel);
+        String where = " where 1 = 1 " + map.keySet().stream().map(t -> " and " + t + "=?").collect(Collectors.joining(" "));
+        oaPriceInExcel.setTotal(count(where,map.values().toArray()));
+        stringBuffer.append(where);
+        String limit = " limit " + oaPriceInExcel.getStart() + "," + oaPriceInExcel.getSize();
+        stringBuffer.append(limit);
+        RowMapper<OaPriceInExcel> rowMapper = new BeanPropertyRowMapper<OaPriceInExcel>(OaPriceInExcel.class);
+        List<OaPriceInExcel> list = jdbcTemplate.query(stringBuffer.toString(),rowMapper,map.values().toArray());
+        return list;
+    }
+
+    private Integer count(String where, Object[] objects) {
+        String sql = "select count(*) from oa_price_in_excel " + where;
+        return jdbcTemplate.queryForObject(sql,Integer.class,objects);
+    }
+
+    private Map<String, Object> map(OaPriceInExcel oaPriceInExcel) {
+
+        Map<String,Object> map = new HashMap<>();
+
+        if (oaPriceInExcel.getId() != null){
+            map.put("id",oaPriceInExcel.getId());
+        }
+        if (oaPriceInExcel.getPriceTableUuid() != null){
+            map.put("price_table_uuid",oaPriceInExcel.getPriceTableUuid());
+        }
+        if (oaPriceInExcel.getFromCity() != null && !"".equals(oaPriceInExcel.getFromCity())){
+            map.put("from_city",oaPriceInExcel.getFromCity());
+        }
+        if (oaPriceInExcel.getRetCicy() != null && !"".equals(oaPriceInExcel.getRetCicy())){
+            map.put("ret_cicy",oaPriceInExcel.getRetCicy());
+        }
+        if (oaPriceInExcel.getFromDate() != null && !"".equals(oaPriceInExcel.getFromDate())){
+            map.put("from_date",oaPriceInExcel.getFromDate());
+        }
+        if (oaPriceInExcel.getAdultTax() != null && !"".equals(oaPriceInExcel.getAdultTax())){
+            map.put("adult_tax",oaPriceInExcel.getAdultTax());
+        }
+        if (oaPriceInExcel.getAdultScore() != null && !"".equals(oaPriceInExcel.getAdultScore())){
+            map.put("adult_score",oaPriceInExcel.getAdultScore());
+        }
+        if (oaPriceInExcel.getDepAirport() != null && !"".equals(oaPriceInExcel.getDepAirport())){
+            map.put("dep_airport",oaPriceInExcel.getDepAirport());
+        }
+        if (oaPriceInExcel.getArrAirport() != null && !"".equals(oaPriceInExcel.getArrAirport())){
+            map.put("arr_airport",oaPriceInExcel.getArrAirport());
+        }
+        if (oaPriceInExcel.getArrTime() != null && !"".equals(oaPriceInExcel.getArrTime())){
+            map.put("arr_time",oaPriceInExcel.getArrTime());
+        }
+        if (oaPriceInExcel.getDepTime() != null && !"".equals(oaPriceInExcel.getDepTime())){
+            map.put("dep_time",oaPriceInExcel.getDepTime());
+        }
+        if (oaPriceInExcel.getFlightNumber() != null && !"".equals(oaPriceInExcel.getFlightNumber())){
+            map.put("flight_number",oaPriceInExcel.getFlightNumber());
+        }
+        return map;
+    }
+}

+ 11 - 0
oa_service/src/main/java/com/bjlt/spider/table/service/OaPriceInExcelService.java

@@ -0,0 +1,11 @@
+package com.bjlt.spider.table.service;
+
+import com.bjlt.spider.entity.OaPriceInExcel;
+
+import java.util.List;
+
+public interface OaPriceInExcelService {
+    List<OaPriceInExcel> listPageOaPriceInExcel(OaPriceInExcel oaPriceInExcel);
+
+
+}

+ 23 - 0
oa_service/src/main/java/com/bjlt/spider/table/service/impl/OaPriceInExcelServiceImpl.java

@@ -0,0 +1,23 @@
+package com.bjlt.spider.table.service.impl;
+
+import com.bjlt.spider.entity.OaPriceInExcel;
+import com.bjlt.spider.table.dao.OaPriceInExcelDao;
+import com.bjlt.spider.table.service.OaPriceInExcelService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class OaPriceInExcelServiceImpl implements OaPriceInExcelService {
+
+    @Autowired
+    OaPriceInExcelDao oaPriceInExcelDao;
+
+    @Override
+    public List<OaPriceInExcel> listPageOaPriceInExcel(OaPriceInExcel oaPriceInExcel) {
+
+
+        return oaPriceInExcelDao.listPageOaPriceInExcel(oaPriceInExcel);
+    }
+}