package com.thinkgem.jeesite.modules.yudengjipush.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import com.google.common.collect.Maps;
import com.itextpdf.text.log.SysoLogger;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.SendMailUtil;
import com.thinkgem.jeesite.modules.flight.entity.Detail;
import com.thinkgem.jeesite.modules.flight.entity.FlightIndexBean;
import com.thinkgem.jeesite.modules.flight.entity.FlightInfoList;
import com.thinkgem.jeesite.modules.flight.entity.FlightList;
import com.thinkgem.jeesite.modules.flight.entity.PriceDeatil;
import com.thinkgem.jeesite.modules.flight.entity.ProductList;
import com.thinkgem.jeesite.modules.flight.service.FlightService;
import com.thinkgem.jeesite.modules.hotel.dao.HotelDao;
import com.thinkgem.jeesite.modules.hotel.entity.Hotel;
import com.thinkgem.jeesite.modules.sys.entity.BaseArea;
import com.thinkgem.jeesite.modules.sys.service.BaseAreaService;
import com.thinkgem.jeesite.modules.yudengjipush.dao.YuDengJiPushDao;
import com.thinkgem.jeesite.modules.yudengjipush.entity.YuDengJiPush; /**
* 详情页面意向登记 Service 类
*
* @author Administrator
*
*/
@Service
@Scope
public class YuDengJiPushService extends CrudService<YuDengJiPushDao, YuDengJiPush> { private static final String beijing = "BJS";// 北京三字码
private static final String shanghai = "SHA";// 上海三字码
private static final String guangzhou = "CAN";// 广州三字码
private static final String hongkong = "HKG";// 香港三字码 @Autowired
YuDengJiPushDao yuDengJiPushDao;
@Autowired
FlightService flightService;
@Autowired
BaseAreaService baseAreaService; @Autowired
HotelDao hotelDao; /**
* 查询参观预登记要推送的信息
*
* @param yuDengJiPush
* @throws ParseException
*/
public void queryYuDengJiPush() {
String takeoffDate = flightService.getDateTime(28, "yyyy-MM-dd");// 飞机起飞时间
String returnDate = flightService.getDateTime(37, "yyyy-MM-dd");// 飞机返程日期为展览开展时间的后7天
String launchTime = flightService.getDateTime(30, "yyyy-MM-dd");// 展会举办时间
YuDengJiPush yuDengJiPush = new YuDengJiPush();
yuDengJiPush.setJuBanTime(launchTime);
Hotel ht = new Hotel();
List<YuDengJiPush> yuDengJiPushList = yuDengJiPushDao.findList(yuDengJiPush);
Map<String, Object> map = Maps.newHashMap();
try {
if (yuDengJiPushList != null && yuDengJiPushList.size() > 0) {
for (YuDengJiPush yp : yuDengJiPushList) {
if ("".equals(yp.getCityAdd()) || yp.getCityAdd() == null) {
yp.setCityAdd("北京");
}
// 获取展会所在城市的酒店信息
if (!"".equals(yp.getZhanGuanId()) && yp.getZhanGuanId() != null) {
ht.setZhanGuanId(Integer.parseInt(yp.getZhanGuanId()));
List<Hotel> hotelTop4 = hotelDao.findHotelTop4(ht);
if(hotelTop4.size()>0 && hotelTop4 !=null){
for(int i=0;i<hotelTop4.size();i++){
if(hotelTop4.get(i)!=null){
map.put("hotel"+String.valueOf(i), hotelTop4.get(i));
}else{
map.put("hotel"+String.valueOf(i), null);}
}
} } List<FlightList> flightList = queryFlightList(yp.getZhanGuanId(), yp.getCityAdd(), takeoffDate, returnDate);
if (flightList != null && flightList.size() > 0) { for(int i=0;i<4;i++){
FlightIndexBean ftBean = new FlightIndexBean();
FlightList ft = flightList.get(i);
List<FlightInfoList> flightInfoList = ft.getFlightInfoList();//综合信息
List<ProductList> productList = ft.getProductList();//机票价格信息
if(flightInfoList !=null && flightInfoList.size()>0){
FlightInfoList takeoffList = flightInfoList.get(0);//起飞时的航程信息
FlightInfoList arrivalList = flightInfoList.get(flightInfoList.size()-1);//降落时的航程信息
if(takeoffList !=null){
ftBean.setAirName(takeoffList.getAirName());// 航空公司
ftBean.setEquipment(takeoffList.getEquipment());// 机型
String takeoffTime = takeoffList.getTakeoffTime();
if(takeoffTime.length()>=5){
ftBean.setTakeoffTime(takeoffTime.substring(0, takeoffTime.length()-5));// 起飞时间
}
ftBean.setTakeoffCity(takeoffList.getTakeoffCity());// 出发城市名称
ftBean.setTakeoffAirportName(takeoffList.getTakeoffAirportName());//起飞时机场名称
ftBean.setTakeoffTerminal(takeoffList.getTakeoffTerminal());// 出发航站楼
}
if(arrivalList !=null){
String arrivalTime = arrivalList.getArrivalTime();
if(arrivalTime.length()>=5){
ftBean.setArrivalTime(arrivalTime.substring(0, arrivalTime.length()-5));// 着陆点时间
}
ftBean.setArrivalCity(arrivalList.getArrivalCity());// 着陆点城市
ftBean.setArrivalAirportName(arrivalList.getArrivalAirportName());//着陆点机场名称
ftBean.setArrivalTerminal(arrivalList.getArrivalTerminal());// 着陆点航站楼
ftBean.setArrivalEquipment(arrivalList.getEquipment());//终点站时机型
}
}
if(productList !=null && productList.size()>0){
for(ProductList p : productList){
List<PriceDeatil> priceDeatilList = p.getPriceDeatil();
if(priceDeatilList !=null && priceDeatilList.size()>0){
for(PriceDeatil pd : priceDeatilList){
Detail detail = pd.getDetail();
ftBean.setSalePrice(detail.getSalePrice());
}
}
}
}
map.put("ftBean"+String.valueOf(i), ftBean);
} }
map.put("yp", yp);
SendMailUtil.sendFtlMail(yp.getMail(), "参观预登记提示", "canGuanYuDengJi.ftl", map);// 发送邮件
}
} } catch (Exception e) {
e.printStackTrace();
}
} /**
*
* @param zhanGuanId
* 展馆的ID
* @param cityAdd
* 参观预登记下单人所在的城市
* @param takeoffDate
* 起飞时间
* @return
*/
/*
* public Integer getTicketPrice(String zhanGuanId, String cityAdd, String
* takeoffDate) { int Price = 0; String takeoffSZM = beijing;//
* 默认当前下单用户起飞城市是北京 BaseArea ba = new BaseArea();
* ba.setZhanGuanId(Integer.parseInt(zhanGuanId)); ba =
* baseAreaService.getsanZiMa(ba); if ("".equals(ba.getSanZiMa()) ||
* ba.getSanZiMa() == null) { return Price; } if ("广州".equals(cityAdd)) {
* takeoffSZM = guangzhou; } else if ("上海".equals(cityAdd)) { takeoffSZM =
* shanghai; } else if ("香港".equals(cityAdd)) { takeoffSZM = hongkong; }
* FlightIndexBean flightIndexBean =
* flightService.queryYuDengJiPushFlight(takeoffSZM, ba.getSanZiMa(),
* takeoffDate); if (flightIndexBean != null &&
* flightIndexBean.getSalePrice() != null) { Price =
* Integer.parseInt(flightIndexBean.getSalePrice()); } return Price; }
*/
/**
*
* @param zhanGuanId 展馆的ID
* @param cityAdd 参观预登记下单人所在的城市
* @param takeoffDate 起飞时间
* @param returnDate 返程时间
* @return List<FlightList>
*/
public List<FlightList> queryFlightList(String zhanGuanId, String cityAdd, String takeoffDate, String returnDate) { String takeoffCityCode = beijing;// 默认当前下单用户起飞城市是北京
BaseArea ba = new BaseArea();
ba.setZhanGuanId(Integer.parseInt(zhanGuanId));
ba = baseAreaService.getsanZiMa(ba);
if ("".equals(ba.getSanZiMa()) || ba.getSanZiMa() == null) {
return null;
}
if ("广州".equals(cityAdd)) {
takeoffCityCode = guangzhou;
} else if ("上海".equals(cityAdd)) {
takeoffCityCode = shanghai;
} else if ("香港".equals(cityAdd)) {
takeoffCityCode = hongkong;
}
return flightService.queryYuDengJiPushList(takeoffCityCode, ba.getSanZiMa(), takeoffDate, returnDate);
} }

发送邮件功能 Service 层的更多相关文章

  1. 032医疗项目-模块三:药品供应商目录模块——供货商药品目录查询功能----------Service层和Action层和调试

    我们上一篇文章讲了Dao层代码: 这一篇我们讲解Service层和Action层: Service层: 分为接口和实现类,我们主要看实现类:GysemplServiceImpl package yyc ...

  2. java中Action层、Service层和Dao层的功能区分

    Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO只 ...

  3. [转]JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分

    首先这是现在最基本的分层方式,结合了SSH架构.modle层就是对应的数据库表的实体类.Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操 ...

  4. Java中Action层、Service层、Modle层和Dao层的功能区分

    一.Java中Action层.Service层.Modle层和Dao层的功能区分: 首先,这是现在最基本的分层方式,结合了SSH架构. modle层就是对应的数据库表的实体类.(即domain) Da ...

  5. Action层, Service层 和 Dao层的功能区分

    Action/Service/DAO简介:  Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO ...

  6. JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分

    Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操作,在这里可以编写自己需要的代码(比如简单的判断).Action层:引用对应的Servi ...

  7. SSH框架中POJO层, Dao层,Service层, Action层的功能理解

    pojo层就是对应的数据库表的实体类(如User类). dao层,一般可以再分为***dao接口和***daoImpl实现类,如userDao接口和userDaoImpl实现类,接口负责定义数据库cu ...

  8. springboot 注册dao层 service 层

    可以使用三种注解来引入DAO层的接口到spring容器中.1.@Mapper,写在每一个DAO层接口上,如下: 2.@MapperScan和@ComponentScan两者之一.前者的意义是将指定包中 ...

  9. 谈谈service层在mvc框架中的意义和职责

    mvc框架由model,view,controller组成,执行流程一般是:在controller访问model获取数据,通过view渲染页面. mvc模式是web开发中的基础模式,采用的是分层设计, ...

随机推荐

  1. Requests库网络爬虫实战

    实例一:页面的爬取 >>> import requests>>> r= requests.get("https://item.jd.com/1000037 ...

  2. ‘\0’的ASCII码

    1.'\0'的ASCII码为0 2.用串口发送字符串时,可以通过'\0'判断字符串是否结束,但发送数字数组的时候不能通过'\0'判断数组是否结束,因为数字0与'\0'的ASCII码值相同.

  3. PTA的Python练习题(十七)

    第4章-19 矩阵运算 a=eval(input()) s=[] count=0 for i in range(a): b=input() s.append([int(i) for i in b.sp ...

  4. spring与jdbc,mybatis的结合

    关键点在于把DataSource(数据源)配置到spring容器中,通过数据源获取数据库连接对象 数据库连接池(pool):管理数据库连接对象 四种数据源: 1)<!-- 基于jdk的规范数据源 ...

  5. python 在linux上面安装beautifulsoup4(bs4) No module named 'bs4'

    续费了我的服务器 重做系统成了Linux服务器 然后想把Windown上的Python脚本放上去运行 但是出现了 No module named 'bs4' 的问题 pip install bs4 试 ...

  6. family_to_level函数

    #include <netinet/in.h> #include <sys/socket.h> int family_to_level(int family) { switch ...

  7. 应用 AddressSanitizer 发现程序内存错误

    作为 C/ C++ 工程师,在开发过程中会遇到各类问题,最常见便是内存使用问题,比如,越界,泄漏.过去常用的工具是 Valgrind,但使用 Valgrind 最大问题是它会极大地降低程序运行的速度, ...

  8. 刷题64. Minimum Path Sum

    一.题目说明 题目64. Minimum Path Sum,给一个m*n矩阵,每个元素的值非负,计算从左上角到右下角的最小路径和.难度是Medium! 二.我的解答 乍一看,这个是计算最短路径的,迪杰 ...

  9. arc066E - Addition and Subtraction Hard

    题目链接 题目大意 给定一个只含加减和数字的表达式,在其中添加括号,使其值最大. 解题思路 显然,只有减号后面的括号会使其中表达式的值取反. 然后只有已经有左括号时才能加入右括号. 所以用\(f_0\ ...

  10. MockMVC - 基于RESTful风格的Springboot,SpringMVC的测试

    MockMVC - 基于RESTful风格的SpringMVC的测试 对于前后端分离的项目而言,无法直接从前端静态代码中测试接口的正确性,因此可以通过MockMVC来模拟HTTP请求.基于RESTfu ...