mmsuploadserviceimpl.java
来自「移动彩信管理平台」· Java 代码 · 共 636 行 · 第 1/2 页
JAVA
636 行
package com.my7g.zj.mobile.mms.business.service;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.dom4j.Document;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import com.my7g.zj.mobile.mms.bean.UploadMmsBean;
import com.my7g.zj.mobile.mms.bean.UploadSort;
import com.my7g.zj.mobile.mms.business.IMmsUploadService;
import com.my7g.zj.mobile.mms.mapping.TbMmsCpProvider;
import com.my7g.zj.mobile.mms.mapping.TbMmsType;
import com.my7g.zj.mobile.mms.mapping.TbMmsUpload;
import com.my7g.zj.mobile.mms.sys.BasicDao;
import com.my7g.zj.mobile.mms.sys.Constant;
import com.my7g.zj.mobile.mms.util.DividePageBean;
import com.my7g.zj.mobile.mms.util.PageBean;
public class MmsUploadServiceImpl extends BasicDao implements IMmsUploadService {
private DividePageBean dividePage;
/**
* @return the dividePage
*/
public DividePageBean getDividePage() {
return dividePage;
}
/**
* @param dividePage
* the dividePage to set
*/
public void setDividePage(DividePageBean dividePage) {
this.dividePage = dividePage;
}
/**
* 获取登陆用户对应的cp提供商信息
*
* @return 所有彩信cp提供商信息
*/
public TbMmsCpProvider getMmsCpProvider(int user) {
List list = null;
String hql = "from TbMmsCpProvider cp where cp.userId = " + user;
list = daoSupport.find(hql);
return (TbMmsCpProvider) (list.isEmpty() ? null : list.get(0));
}
/**
* 根据cp分类索引获得栏目名称
*
* @param cp
* @return
*/
public List<TbMmsType> getMmsTypeIndex(TbMmsCpProvider cp) {
List<TbMmsType> typeList = null;
String hql = "from TbMmsType tn where tn.sortIndex = '"
+ cp.getTypeIndex() + "'";
typeList = daoSupport.find(hql);
return typeList;
}
/**
* 获取所有子类栏目
*
* @return
*/
public List<TbMmsType> getMmsTypeIndex() {
List<TbMmsType> typeList = null;
String hql = "from TbMmsType tn where tn.sortDeep = 3";
typeList = daoSupport.find(hql);
return typeList;
}
/**
* 按条件查询总数
*
* @param state
* @param typeid
* @param startDate
* @param endDate
* @return
*/
public Long getAllUploadMmsCount(String state, String typeid,
String startDate, String endDate) {
String hqlcount = "";
String start = startDate + " 00:00:00";
String end = endDate + " 23:59:59";
if ((typeid != null && typeid.length() > 0)
&& (startDate != null && startDate.length() > 0)
&& (endDate != null && endDate.length() > 0)) {
// 按栏目and下发时间段查询语句
// hqlcount = "select count(*) from TbMmsUpload u where u.auditingState = '"
// + state
// + "' and u.typeIndex ='"
// + typeid
// + "' and u.groupSendTime between '"
// + start
// + "' and '"
// + end + "'";
hqlcount = "select count(*) from TbMmsUpload u,TbMmsType mt where u.typeIndex = mt.sortIndex and u.auditingState = '"
+ state
+ "' and u.typeIndex ='"
+ typeid
+ "' and u.groupSendTime between '"
+ start
+ "' and '"
+ end + "'";
} else if (typeid != null && typeid.length() > 0) {
// 按栏目查询语句
hqlcount = "select count(*) from TbMmsUpload u,TbMmsType mt where u.typeIndex = mt.sortIndex and u.auditingState = '"
+ state + "' and u.typeIndex ='" + typeid + "'";
} else if ((startDate != null && startDate.length() > 0)
&& (endDate != null && endDate.length() > 0)) {
// 按下发时间段查询语句
hqlcount = "select count(*) from TbMmsUpload u,TbMmsType mt where u.typeIndex = mt.sortIndex and u.auditingState = '"
+ state
+ "' and u.typeIndex ='"
+ typeid
+ "' and u.groupSendTime between '"
+ start
+ "' and '"
+ end + "'";
} else {
System.out.println("彩信审核查询条件为空!");
}
return this.getResultCount(hqlcount);
}
/**
* 按条件查询的结果集
*
* @param page
* @param rowPerPage
* @param state
* @param sortName
* @param typeid
* @param startDate
* @param endDate
* @return
*/
public List getAllUploadMmsList(int page, int rowPerPage, String state,
String sortName, String typeid, String startDate, String endDate) {
String hql = "";
String start = startDate + " 00:00:00";
String end = endDate + " 23:59:59";
List<UploadMmsBean> uploadMmsList = null;
if ((typeid != null && typeid.length() > 0)
&& (startDate != null && startDate.length() > 0)
&& (endDate != null && endDate.length() > 0)) {
// 按栏目and下发时间段查询语句
hql = "select u.uplodId,mt.sortName,u.provideId,u.mmsTitle,u.groupSendTime from TbMmsUpload u,TbMmsType mt where u.typeIndex = mt.sortIndex and u.auditingState = '" + state
+ "' and u.typeIndex ='" + typeid + "' and u.typeIndex ='"
+ typeid + "' and u.groupSendTime between '" + start
+ "' and '" + end + "' order by u.uploadTime " + sortName;
} else if (typeid != null && typeid.length() > 0) {
// 按栏目查询语句
hql = "select u.uplodId,mt.sortName,u.provideId,u.mmsTitle,u.groupSendTime from TbMmsUpload u,TbMmsType mt where u.typeIndex = mt.sortIndex and u.auditingState = '" + state
+ "' and u.typeIndex ='" + typeid
+ "'order by u.uploadTime " + sortName;
} else if ((startDate != null && startDate.length() > 0)
&& (endDate != null && endDate.length() > 0)) {
// 按下发时间段查询语句
hql = "select u.uplodId,mt.sortName,u.provideId,u.mmsTitle,u.groupSendTime from TbMmsUpload u,TbMmsType mt where u.typeIndex = mt.sortIndex and u.auditingState = '" + state
+ "' and u.typeIndex ='" + typeid + "' and u.typeIndex ='"
+ typeid + "' and u.groupSendTime between '" + start
+ "' and '" + end + "' order by u.uploadTime " + sortName;
} else {
System.out.println("彩信审核查询条件为空!");
}
uploadMmsList = this.find(hql, rowPerPage, page);
return uploadMmsList.isEmpty() ? null : uploadMmsList;
}
/**
* 获取待审核彩信列表
*
* @param page
* 总页数
* @param rowPerPage
* 每页显示数
* @param href
* 跳转链接
* @param state
* 彩信审核状态
* @param sortName
* 排序
* @param typeid
* 栏目索引
* @param startDate
* 开始时间
* @param endDate
* 结束时间
* @return
*/
public PageBean getAllUploadMms(int page, int rowPerPage, String href,
String state, String sortName, String typeid, String startDate,
String endDate) {
PageBean bean = null;
System.out.println(page);
System.out.println(rowPerPage);
dividePage.setwaitPage(String.valueOf(page), rowPerPage);
Long mmsCount = this.getAllUploadMmsCount(state, typeid, startDate,
endDate);
dividePage.setPageInfo(mmsCount.intValue());
String pageHref = dividePage.gethrefPage(href, "pagesel", "page");
List list = this.getAllUploadMmsList((page - 1) * rowPerPage,
rowPerPage, state, sortName, typeid, startDate, endDate);
bean = new PageBean(pageHref, list);
return bean;
}
/**
* 保存上传彩信
*
* @param mmsUpload
*/
public void saveMmsUpload(TbMmsUpload mmsUpload) {
mmsUpload.setAuditingId(0);
mmsUpload.setAuditingState(Short.parseShort("0"));
mmsUpload.setNeedCatch(Byte.parseByte("1"));
mmsUpload.setPatchStatus(Short.parseShort("1"));
this.saveOrUpdate(mmsUpload);
}
/**
* 元素名or关键字合并
*
* @param str
* @return
*/
public String sparateChar(String[] str) {
String names = "";
if (str != null) {
for (int i = 0; i < str.length; i++) {
if (i == str.length - 1) {
names += str[i];
} else {
names += str[i] + ",";
}
}
}
return names;
}
/**
* 创建预览smil文件
*
*/
public String createShowFile(List sortList) {
System.out.println("进入预览smil文件方法");
Document doc = DocumentFactory.getInstance().createDocument();
doc.addDocType("smil", "-//W3C//DTD SMIL 2.0//EN",
"http://www.w3.org/2001/SMIL20/SMIL20.dtd");
Element smil = doc.addElement("smil");
smil.addAttribute(" xmlns", "http://www.w3.org/2001/SMIL20/Language");
Element head = smil.addElement("head");
Element meta = head.addElement("meta");
meta.addAttribute("name", "title");
meta.addAttribute("content", "The title");
Element layout = head.addElement("layout");
layout.addAttribute("type", "text/smil-basic-layout");
Element rootlayout = layout.addElement("root-layout");
rootlayout.addAttribute("id", "rootLayout");
rootlayout.addAttribute("width", "300");
rootlayout.addAttribute("height", "300");
rootlayout.addAttribute("backgroundColor", "white");
Element region1 = layout.addElement("region");
region1.addAttribute("width", "240");
region1.addAttribute("top", "20");
region1.addAttribute("height", "100");
region1.addAttribute("left", "24");
region1.addAttribute("id", "region_1");
region1.addAttribute("fit", "meet");
Element region2 = layout.addElement("region");
region2.addAttribute("width", "240");
region2.addAttribute("top", "60");
region2.addAttribute("height", "200");
region2.addAttribute("left", "24");
region2.addAttribute("id", "region_2");
region2.addAttribute("fit", "meet");
Element region3 = layout.addElement("region");
region3.addAttribute("width", "240");
region3.addAttribute("top", "230");
region3.addAttribute("height", "100");
region3.addAttribute("left", "24");
region3.addAttribute("id", "region_3");
region3.addAttribute("fit", "meet");
Element body = smil.addElement("body");
Element par = null;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?