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. HDU 6631 line symmetric 计算几何

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6631 题意:共\(T\)组数据,每组数据给出\(n\)个点的坐标,这\(n\)个点按顺序给出,相邻的点 ...

  2. SoapUI学习(1)- WebService基础

    转载:http://luyongxin88.blog.163.com/blog/static/92558072011320101454287/ WebService 它是一种构建应用程序的普遍模型,可 ...

  3. 使用php-vmstat遇到的麻烦

    workerman-vmstat是一个基于workerman的扩展,用于监听服务器应用对内存.cpu消耗的友好的查看功能,具体介绍可以去git上看:    https://github.com/wal ...

  4. PAT 1010 Radix (二分)

    Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The an ...

  5. 关于ActiveMq的Exception occurred while processing this request, check the log for more information!问题

    错误原因:jsp渲染的时候报错了.根本原因在于jdk版本和activemq版本的问题. 两种解决方案: 1.把jdk版本改为jdk1.7 2.activeMQ采用5.15,它依赖于jdk1.8

  6. 【C语言】(数组方式)输出一组成绩中的最高分与最低分

    两种不同方式获取最大值与最小值 代码1: #include <stdio.h> int main() { ], sum = , max, min; int i; printf(" ...

  7. Shiro入门学习与实战(一)

    一.概述 1.Shiro是什么? Apache Shiro是java 的一个安全框架,主要提供:认证.授权.加密.会话管理.与Web集成.缓存等功能,其不依赖于Spring即可使用: Spring S ...

  8. C语言:将字符串中的字符逆序输出,但不改变字符串中的内容。-在main函数中将多次调用fun函数,每调用一次,输出链表尾部结点中的数据,并释放该结点,使链表缩短。

    //将字符串中的字符逆序输出,但不改变字符串中的内容. #include <stdio.h> /************found************/ void fun (char ...

  9. python 中的 int() 与 round

    int(x):向下取整 round(x):超过 .5 则向上取整,否则向下取整

  10. plus接口

    //获取手机端本地文件路径 plus.io.resolveLocalFileSystemURL(url, success(e){ }, fail(e){ })