发送邮件功能 Service 层
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 层的更多相关文章
- 032医疗项目-模块三:药品供应商目录模块——供货商药品目录查询功能----------Service层和Action层和调试
我们上一篇文章讲了Dao层代码: 这一篇我们讲解Service层和Action层: Service层: 分为接口和实现类,我们主要看实现类:GysemplServiceImpl package yyc ...
- java中Action层、Service层和Dao层的功能区分
Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO只 ...
- [转]JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分
首先这是现在最基本的分层方式,结合了SSH架构.modle层就是对应的数据库表的实体类.Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操 ...
- Java中Action层、Service层、Modle层和Dao层的功能区分
一.Java中Action层.Service层.Modle层和Dao层的功能区分: 首先,这是现在最基本的分层方式,结合了SSH架构. modle层就是对应的数据库表的实体类.(即domain) Da ...
- Action层, Service层 和 Dao层的功能区分
Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO ...
- JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分
Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操作,在这里可以编写自己需要的代码(比如简单的判断).Action层:引用对应的Servi ...
- SSH框架中POJO层, Dao层,Service层, Action层的功能理解
pojo层就是对应的数据库表的实体类(如User类). dao层,一般可以再分为***dao接口和***daoImpl实现类,如userDao接口和userDaoImpl实现类,接口负责定义数据库cu ...
- springboot 注册dao层 service 层
可以使用三种注解来引入DAO层的接口到spring容器中.1.@Mapper,写在每一个DAO层接口上,如下: 2.@MapperScan和@ComponentScan两者之一.前者的意义是将指定包中 ...
- 谈谈service层在mvc框架中的意义和职责
mvc框架由model,view,controller组成,执行流程一般是:在controller访问model获取数据,通过view渲染页面. mvc模式是web开发中的基础模式,采用的是分层设计, ...
随机推荐
- Codeforces Round #579 (Div. 3) 题解
比赛链接:https://codeforc.es/contest/1203/ A. Circle of Students 题意:\(T\)组询问,每组询问给出\(n\)个数字,问这\(n\)个数字能否 ...
- 大组合数Lucas
https://blog.csdn.net/sr_19930829/article/details/39058487 LL Lucas(LL n, LL m, int p){ ; } Saving B ...
- max=(a>b)?a:b;
这个函数的意思是如果a>b,max=a:否则max=b. 实际程序: while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Sta ...
- 记录STM32调试
问题:加入红外初始化后,程序卡在红外初始化处 解决思路: 1.确认时钟是不是好的 2.把定时器分解调试(输入捕获.溢出分开一步一步弄) 已解决:定时器的溢出中断 注意:STM32Cube配置好后,需要 ...
- Comparable
为什么会有Comparable与Comparator接口? 引入策略模式 目录 引入 Comparable接口的来龙去脉 引入Comparator接口 什么是策略模式? 使用了策略模式有什么好处? ...
- Cygwin不能编译及解决办法
最近不知道什么原因,以前使用cygwin编译Android动态库,现在不能使用了,报下面的错误. Android NDK: Host 'awk' tool is outdated. Please de ...
- IIS-URL重写参数
参考:https://www.cnblogs.com/gggzly/p/5960335.html URL 重写规则由以下部分组成: 模式 - 可以理解为规则,分通配符和正则匹配 条件 - 可以 ...
- mcast_get_ttl函数
#include <errno.h> #include <net/if.h> #include <sys/socket.h> #include <netine ...
- php中流行的rpc框架详解
什么是RPC框架? 如果用一句话概括RPC就是:远程调用框架(Remote Procedure Call) 那什么是远程调用? 我的官方群点击此处. 通常我们调用一个php中的方法,比如这样一个函数方 ...
- 15 FFT及其框图实现
FFT及其框图实现 \(FFT\)的全称为快速傅里叶变换,但是\(FFT\)并不是一种变换,而是实现\(DFT\)的一种快速算法.当\(N\)比较大时,使用\(FFT\)可大大减少进行\(DFT\)变 ...