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. Django 报错no sucn column: OpretionalError

    1.报错原因:新增的字段未能同步数据库 2.解决办法:删除整个数据库,然后重新编译,然后over 1.rm -rf db.sqlites3 #删除数据库 2.rm -rf cmdb/migrarion ...

  2. oracle中以dba_、user_、v$_、all_、session_、index_开头

    原 oracle中以dba_.user_.v$_.all_.session_.index_开头 2011年07月05日 11:26:06 clbxp 阅读数:3279   oracle中以dba_.u ...

  3. VS Code的git配置

    最近打算使用VS Code作为python的编辑器,这里记录一下VS Code中git的配置方法 因为vscode中git只是使用本地的git,所以本地必须先安装git才行. 1.git的安装 git ...

  4. 解决 上下拉的橡皮筋 和 复制无效 和 ios滑动屏幕定时器停止问题cordova

    cordova 安装插件cordova plugin add cordova-plugin-wkwebview-engine@latest --save config.xml 的 <platfo ...

  5. 【PAT甲级】1086 Tree Traversals Again (25 分)(树知二求一)

    题意:输入一个正整数N(<=30),接着输入2*N行表示栈的出入(入栈顺序表示了二叉搜索树的先序序列,出栈顺序表示了二叉搜索树的中序序列),输出后序序列. AAAAAccepted code: ...

  6. Linux虚拟机(CentOS)安装gcc, g++

    1.    确保自己的虚拟机联网 点击那个三角形可以选择连接网络 如果还是连不了网,参考https://www.cnblogs.com/xingbo/p/6100554.html 2.联网后,使用命令 ...

  7. C语言:将3*4矩阵中找出行最大,列最小的那个元素。-将低于平均值的人数作为函数返回值,将低于平均分的分数放入below数组中。

    //将3*4矩阵中找出行最大,列最小的那个元素. #include <stdio.h> #define M 3 #define N 4 void fun(int (*a)[N]) { ,j ...

  8. C# 集合类型学习

    如果你掌握了一门语言的数据结构 ,那么你离掌握这门语言 也不远了 1.列表 对于list,值得一提的是 Capacity 属性,使用默认的构造函数 ,让我们用代码来说明 var intList = n ...

  9. ETCD监控

    Watch key changes Applications can watch on a key or a range of keys to monitor for any updates. Her ...

  10. Cisco Spectrum Expert(Wave2 AP)

    在一些版本中,我们可能会发现,AP16,26或AP17,27,37等支持Spectrum Expert Connect (即SE-Connect),该模式可以让AP将频谱分析所述数据发送到对应的分析仪 ...