Browse Source

oa_line_in_excel查询

dongql 7 years ago
parent
commit
4777e9fa6f

+ 7 - 0
oa_service/pom.xml

@@ -32,6 +32,13 @@
 
     <dependencies>
         <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
+
+        <dependency>
+            <groupId>net.sourceforge.jexcelapi</groupId>
+            <artifactId>jxl</artifactId>
+            <version>2.6.12</version>
+        </dependency>
+
         <dependency>
             <groupId>com.bjlt.spider</groupId>
             <artifactId>spider-rpc</artifactId>

+ 79 - 0
oa_service/src/main/java/com/bjlt/spider/entity/OaPriceInExcel.java

@@ -0,0 +1,79 @@
+package com.bjlt.spider.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class OaPriceInExcel  extends Page {
+
+	/**
+	   
+	 */
+	private Integer id;
+	
+	/**
+	   
+	 */
+	private String priceTableUuid;
+	
+	/**
+	   
+	 */
+	private String fromCity;
+	
+	/**
+	   
+	 */
+	private String retCicy;
+	
+	/**
+	   
+	 */
+	private String fromDate;
+	
+	/**
+	   
+	 */
+	private String adultTax;
+	
+	/**
+	   
+	 */
+	private java.math.BigDecimal adultScore;
+	
+	/**
+	   
+	 */
+	private String depAirport;
+	
+	/**
+	   
+	 */
+	private String arrAirport;
+	
+	/**
+	   
+	 */
+	private String arrTime;
+	
+	/**
+	   
+	 */
+	private String depTime;
+	
+	/**
+	   
+	 */
+	private String flightNumber;
+
+	/**
+
+	 */
+	private Integer status;
+
+}

+ 64 - 0
oa_service/src/main/java/com/bjlt/spider/entity/PriceInExcelEntity.java

@@ -0,0 +1,64 @@
+package com.bjlt.spider.entity;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class PriceInExcelEntity extends Page implements Serializable{
+    private static final long serialVersionUID = -3455544184370126386L;
+    /**
+
+     */
+    private Integer id;
+
+    /**
+
+     */
+    private String fromCity;
+
+    /**
+
+     */
+    private String toCity;
+
+    /**
+
+     */
+    private String startDate;
+
+    /**
+
+     */
+    private String endDate;
+
+
+    /**
+
+     */
+    private Integer isRequest;
+
+    /**
+
+     */
+    private String updateTime;
+
+    /**
+
+     */
+    private String editUser;
+
+    /**
+     *
+     *
+     */
+    private String priceTableUuid;
+
+}

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

@@ -0,0 +1,40 @@
+package com.bjlt.spider.table.controller;
+
+
+import com.bjlt.spider.entity.PriceInExcelEntity;
+import com.bjlt.spider.table.service.OaLineInExcelService;
+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.sql.SQLException;
+import java.util.List;
+
+@RequestMapping(value = "/oaLineInExcel")
+@Slf4j
+@Controller
+public class OaLineInExcelController {
+
+    @Autowired
+    OaLineInExcelService oaLineInExcelService;
+
+    @RequestMapping(value = "/find", method = RequestMethod.POST)
+    @ResponseBody
+    public LayuiTableRespEntity listPageOaLineInExcel(PriceInExcelEntity priceInExcelEntity, String pageIndex, String pageSize) {
+        LayuiTableRespEntity layuiTableRespEntity = new LayuiTableRespEntity();
+
+        priceInExcelEntity.setStart(Integer.parseInt(pageIndex)-1);
+        priceInExcelEntity.setSize(Integer.parseInt(pageSize));
+        List<PriceInExcelEntity> priceInExcelEntitys = oaLineInExcelService.listPageOaLineInExcel(priceInExcelEntity);
+        layuiTableRespEntity.setCount(priceInExcelEntity.getTotal());
+        layuiTableRespEntity.setList(priceInExcelEntitys);
+        layuiTableRespEntity.setMsg("获取成功");
+        layuiTableRespEntity.setRel(true);
+
+        return layuiTableRespEntity;
+    }
+}

+ 11 - 0
oa_service/src/main/java/com/bjlt/spider/table/dao/OaLineInExcelDao.java

@@ -0,0 +1,11 @@
+package com.bjlt.spider.table.dao;
+
+import com.bjlt.spider.entity.PriceInExcelEntity;
+
+import java.util.List;
+
+public interface OaLineInExcelDao {
+
+    List<PriceInExcelEntity> listPageOaLineInExcel(PriceInExcelEntity priceInExcelEntity);
+
+}

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

@@ -0,0 +1,87 @@
+package com.bjlt.spider.table.dao.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.bjlt.spider.entity.PriceInExcelEntity;
+import com.bjlt.spider.table.dao.OaLineInExcelDao;
+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 OaLineInExcelDaoImpl implements OaLineInExcelDao {
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    /**
+     * 分页查询oa_line_in_excel表的所有数据
+     * @param
+     * @return
+     */
+    @Override
+    public List<PriceInExcelEntity> listPageOaLineInExcel(PriceInExcelEntity priceInExcelEntity){
+        StringBuffer stringBuffer = new StringBuffer();
+        String select = "select id,price_table_uuid as priceTableUuid,from_city as fromCity,to_city as toCity,start_date as startDate,end_date as endDate,is_request as isRequest,edit_user as editUser,update_time as updateTime from oa_line_in_excel ";
+        stringBuffer.append(select);
+        Map<String,Object> map= map(priceInExcelEntity);
+        String where = "where 1 = 1" + map.keySet().stream().map(t -> " and " + t + "=?").collect(Collectors.joining(" "));
+        priceInExcelEntity.setTotal(count(where,map.values().toArray()));
+        stringBuffer.append(where);
+        String limit = " limit " + priceInExcelEntity.getStart() + "," + priceInExcelEntity.getSize();
+        stringBuffer.append(limit);
+        RowMapper<PriceInExcelEntity> rowMapper = new BeanPropertyRowMapper<PriceInExcelEntity>(PriceInExcelEntity.class);
+        System.out.println(stringBuffer.toString());
+        System.out.println(JSON.toJSONString(map));
+        List<PriceInExcelEntity> list = jdbcTemplate.query(stringBuffer.toString(),rowMapper,map.values().toArray());
+        System.out.println(JSON.toJSONString(list));
+        return list;
+    }
+
+    private Integer count(String where, Object[] objects) {
+        String sql = "select count(*) from oa_line_in_excel " + where;
+        return jdbcTemplate.queryForObject(sql, Integer.class,objects);
+    }
+
+    private static Map<String,Object> map(PriceInExcelEntity priceInExcelEntity) {
+        Map<String, Object> map = new HashMap();
+        if (priceInExcelEntity.getId() != null) {
+            map.put("id", priceInExcelEntity.getId());
+        }
+        if (priceInExcelEntity.getPriceTableUuid() != null) {
+            map.put("price_table_uuid", priceInExcelEntity.getPriceTableUuid());
+        }
+        if (priceInExcelEntity.getFromCity() != null && !"".equals(priceInExcelEntity.getFromCity())) {
+            map.put("from_city", priceInExcelEntity.getFromCity());
+        }
+        if (priceInExcelEntity.getToCity() != null && !"".equals(priceInExcelEntity.getToCity())) {
+            map.put("to_city", priceInExcelEntity.getToCity());
+        }
+        if (priceInExcelEntity.getStartDate() != null && !"".equals(priceInExcelEntity.getStartDate())) {
+            map.put("start_date", priceInExcelEntity.getStartDate());
+        }
+        if (priceInExcelEntity.getEndDate() != null && !"".equals(priceInExcelEntity.getEndDate())) {
+            map.put("end_date", priceInExcelEntity.getEndDate());
+        }
+        if (priceInExcelEntity.getIsRequest() != null && !"".equals(priceInExcelEntity.getIsRequest())) {
+            map.put("is_request", priceInExcelEntity.getIsRequest());
+        }
+        if (priceInExcelEntity.getEditUser() != null && !"".equals(priceInExcelEntity.getEditUser())) {
+            map.put("edit_user", priceInExcelEntity.getEditUser());
+        }
+        if (priceInExcelEntity.getUpdateTime() != null && !"".equals(priceInExcelEntity.getUpdateTime())) {
+            map.put("update_time", priceInExcelEntity.getUpdateTime());
+        }
+
+        return map;
+    }
+
+
+}

+ 9 - 0
oa_service/src/main/java/com/bjlt/spider/table/service/OaLineInExcelService.java

@@ -0,0 +1,9 @@
+package com.bjlt.spider.table.service;
+
+import com.bjlt.spider.entity.PriceInExcelEntity;
+
+import java.util.List;
+
+public interface OaLineInExcelService {
+    List<PriceInExcelEntity> listPageOaLineInExcel(PriceInExcelEntity priceInExcelEntity);
+}

+ 21 - 0
oa_service/src/main/java/com/bjlt/spider/table/service/impl/OaLineInExcelServiceImpl.java

@@ -0,0 +1,21 @@
+package com.bjlt.spider.table.service.impl;
+
+import com.bjlt.spider.entity.PriceInExcelEntity;
+import com.bjlt.spider.table.dao.OaLineInExcelDao;
+import com.bjlt.spider.table.service.OaLineInExcelService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class OaLineInExcelServiceImpl implements OaLineInExcelService{
+
+    @Autowired
+    OaLineInExcelDao oaLineInExcelDao;
+
+    @Override
+    public List<PriceInExcelEntity> listPageOaLineInExcel(PriceInExcelEntity priceInExcelEntity) {
+        return oaLineInExcelDao.listPageOaLineInExcel(priceInExcelEntity);
+    }
+}