• 收发邮件 草稿等 Action


    package com.sdjt.web.smsbox;

    import static org.jmesa.limit.ExportType.CSV;
    import static org.jmesa.limit.ExportType.EXCEL;
    import static org.jmesa.limit.ExportType.PDFP;

    import java.io.File;
    import java.text.SimpleDateFormat;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Date;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.UUID;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    import javax.annotation.Resource;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import org.apache.commons.lang.StringUtils;
    import org.apache.commons.io.FileUtils;
    import org.apache.commons.lang.StringUtils;
    import org.jmesa.facade.TableFacade;
    import org.jmesa.facade.TableFacadeImpl;
    import org.jmesa.limit.Limit;
    import org.jmesa.facade.TableFacade;
    import org.jmesa.facade.TableFacadeImpl;
    import org.jmesa.limit.Limit;
    import org.jmesa.pageLimit.JmesaPageList;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Controller;

    import com.sdjt.bean.smsbox.ContactsGroupPO;
    import com.sdjt.bean.smsbox.InBoxPO;
    import com.sdjt.bean.smsbox.SmsPO;
    import com.sdjt.bean.system.DeptPO;
    import com.sdjt.bean.system.UserPO;
    import com.sdjt.service.smsbox.ContactsService;
    import com.sdjt.service.smsbox.EmailService;
    import com.sdjt.service.smsbox.impl.EmailServiceImpl;
    import com.sdjt.service.system.DeptService;
    import com.sdjt.util.CommonMethod;
    import com.sdjt.util.Constant;
    import com.sdjt.util.mail.receive.EmailAccount;
    import com.sdjt.util.mail.receive.EmailControl;
    import com.sdjt.util.mail.receive.EmailInfo;
    import com.sdjt.util.mail.send.MailUtil;
    import com.sdjt.util.page.PageData;
    import com.sdjt.web.base.FileUploadAction;


    /**
     * Title:企业信箱-Email Copyright: Copyright(c)unicom 2011
     *
     * @Description TODO
     * @ClassName SmsBoxAction
     * @company:济南舜德竟天软件有限公司
     * @author 张菡菡
     * @date 2013-10-09 上午11:29:53
     * @version 4.0
     */
    @Controller(value = "emailAction")
    @Scope(value = "prototype")
    public class EmailAction extends FileUploadAction {
        
        private static final long serialVersionUID = 1L;

        @Resource(name = "emailServiceImpl")
        private EmailService emailServiceImpl;
        
        @Resource(name = "contactsServiceImpl")
        private ContactsService contactsServiceImpl;// 用户联系人service
        
        @Resource(name = "deptServiceImpl")
        private DeptService deptServiceImpl;//部门信息
        
        private List datas; // list类型变量 可通用于jmesa
        
        private int id;// 前台传参(主键)
        
        private String type;// 前台传参标示
        
        private List<PageData> emaillist;//已发邮件
        
        private List<PageData> emailsetlist; //邮件配置设置
        
        private PageData pd;// PageData对象
        private PageData pf;// PageData对象
        
        private PageData pd_config;//配置对象
        
        private String pageFlag; // 跳转页面标示
        
        private String file_id;// 文件夹id
        
        private String file_name;// 文件名

        private String tableType;// 不同信箱的标识
        
        private String optionType;// 操作类型 edit编辑 add 添加 huifu回复 zhuanfa转发
        
        private String body;// 邮件内容
        
        private String sent;//发件人 email_send前台

        private String deleteStr;// 删除类型(1:普通删除,2:彻底删除)
        
        private String read_sign;// 邮件未读标示
        
        private String subject;//邮件主题
        
        private String sentto;//收件人地址
        
        private String sentto_name;////收邮件人的姓名
        
        private String copyto;//抄送人地址
        
        private String copyto_name;//抄送人姓名
        
        private String blindcopyto;//密送邮件地址
        
        private String blindcopyto_name;//密送人姓名

        private InBoxPO inBoxPO;
        
        private SmsPO smsPO;
        
        private String flag;// 判断标识
        
        private String tempFileDir;// 转发时存放临时文件的文件夹名
        
        private String fileNames;// 存放文件名的集合
        
        List<ContactsGroupPO> groupLists;// 存放个人联系人
        
        private UserPO userPO; // 用户po声明
        
        private String[] forwardFileNames;// 转发时附件的名称(原信息带有的附件)
        private static final String BASEDir = Constant.DOC_MMS_DIR + "\";
        
        private String[] items;// 操作多条数据的 存放id数组
        
        private String markName;// 文件夹名字
        
        private int att_mail_id;//回显附件返回的邮件id
        
        /**
         * 邮件左侧
         * */
        public String emailBoxCount(){
            try {
                datas = emailServiceImpl.findEmailCount(session.get("UserId")
                        .toString());
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "emailleft";
        }


        /**
         * 跳转到发信页面
         * @Title: findemailsend方法
         * @Description:
         * @return 跳转的页面 email_send.jsp
         * @author:刘东升
         */
        public String findemailsend() {
            try {
                pd = new PageData(this.getRequest());
                if (tableType != null && !"".equals(tableType)) {
                    String tablename = this.judgeTable(tableType);
                    if ("mbx_inbox".equals(tablename)) {
                        if ("zhuanfa".equals(optionType)){
                            body = inBoxPO.getContent();
                            if ("1".equals(inBoxPO.getIsfiles())) {
                                getTempFile(inBoxPO.getId());// 转发回显文件
                            }
                        } else {
                            if ("edit".equals(optionType)) {
                                body = inBoxPO.getContent();
                            }
                            if ("1".equals(inBoxPO.getIsfiles())) {
                                getTempFile(inBoxPO.getId());// 编辑回显文件
                            }
                        }
                    } else if ("mbx_sms".equals(tablename)) {
                        int z_id = Integer.parseInt(pd.getString("id"));
                        if ("zhuanfa".equals(optionType)){
                            body = pd.getString("body");
                            subject = pd.getString("subject");
                            
                            if ("1".equals(pd.getString("isfiles"))) {
                                getTempFile(z_id);// 转发回显文件
                            }
                        } else {
                            if ("edit".equals(optionType)) {
                                body = pd.getString("body");
                                subject = pd.getString("subject");
                            }
                            if ("1".equals(pd.getString("isfiles"))) {
                                getTempFile(z_id);// 编辑回显文件
                            }
                        }
                    }
                }
                this.queryLinks();
                if (flag == null || "".equals(flag)) {
                    flag = "flag";
                }
                int user_id = (Integer) session.get(Constant.UserId);
                pd_config = emailServiceImpl.findConfig(user_id);//获取当前有效的邮箱
                pd.put("mail_address", pd_config.getString("mail_address"));//放入pd中传到jsp页面
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "emailsend";
            
        }
        
        
        /**
         * 跳转到收件箱
         * @Title: findReceviceBox方法
         * @Description:
         * @return 跳转的页面 email_receive.jsp
         * @author:张菡菡
         */
        public String findReceviceBox() {
            try {
                System.out.println("开始获取邮件");
                Long start = System.currentTimeMillis();
                pd = new PageData(this.getRequest());
                int user_id = (Integer) session.get(Constant.UserId);
                pd.put("accept_id", user_id);
                
                /**收取邮件**/
                pd_config = emailServiceImpl.findConfig(user_id);//获取服务器配置
                EmailAccount emailAccount = new EmailAccount();
                emailAccount.setSendHost(pd_config.getString("mail_send_server"));//发送服务器
                emailAccount.setReceiveHost(pd_config.getString("mail_receive_server"));//接收服务器
                emailAccount.setSendProxy("smtp");//发送协议
                emailAccount.setReceiveProxy("pop3");//接收协议
                emailAccount.setUserName(pd_config.getString("mail_address"));
                emailAccount.setUserPassword(pd_config.getString("mail_password"));
                //emailAccount.setAttachPath(makeDir("Mail"+"\recevice\"));
                emailAccount.setValidate(true);
                
                EmailControl control = new EmailControl(emailAccount,EmailControl.HTML);
                EmailInfo[] emails = control.getEmails();
                System.out.println("从服务器获取邮件:"+emails.length);
                
                Long end = System.currentTimeMillis();
                Long time = end-start;
                System.out.println("获取邮件"+emails.length+"封,用时:"+time);
                for (int i = 0 ; i < emails.length ; i++ ) {
                    EmailInfo email = emails[i];
                    System.out.println("总数"+i);
                    System.out.println("email.isNew():"+email.isNew());
                    if(email.isNew()==false){
                        System.out.println("发件人:"+email.getFrom());
                        pd.put("sent", email.getFrom());
                        pd.put("sentto",email.getTo());
                        pd.put("copyto", email.getCc());
                        String sendtime = email.getSentDate();
                        pd.put("subject", email.getSubject());
                        pd.put("body", email.getBodyText().toString());
                        pd.put("isfiles", 0);
                        List<PageData> repeat = emailServiceImpl.findRepeatemail(pd);//将整个信息带入到查询语句中,作为查询条件来看数据表中有无该数据
                        if(repeat.size() == 0){//没有该数据就插入数据库中并显示
                            emailServiceImpl.saveSendEmail(pd);

                            /*附件
                             * String testID = email.getID();
                            EmailInfo testEmail = control.getEmail(testID);
                            
                            System.out.println("1"+testEmail.getID());
                            System.out.println("2"+testEmail.getSubject());
                            System.out.println("3"+testEmail.getBodyText().toString());
                            System.out.println("4"+testEmail.getAttachment().toString());*/
                        }
                    }
                }
                /**收取邮件结束**/
                
                emaillist = emailServiceImpl.findEmailService(pd);
                for(PageData pd:emaillist){
                    pd.put("sent", pd.getString("sent").replace("<", "").replace(">", ""));
                }
                System.out.println("收取结束");
                
                
                
                // jmesa分页开始
                TableFacade tableFacade = new TableFacadeImpl("emailAction",this.getRequest());
                Collection<PageData> items = emaillist;
                tableFacade.setItems(items);

                // jmesa分页开始
                tableFacade.setExportTypes(getResponse(), CSV, EXCEL, PDFP);// 导出文件的格式
                Limit limit = tableFacade.getLimit();// 导出附件
                if (limit.isExported()) {
                    tableFacade.setColumnProperties("id","sent","sentto","sentto_name","copyto",
                            "copyto_name","blindcopyto","blindcopyto_name","subject","body","sent_time");// 导出的列
                    tableFacade.getTable().setCaption("收件箱列表");
                    tableFacade.getTable().getRow().getColumn("id")
                    .setTitle("编号");//
                    tableFacade.getTable().getRow().getColumn("sent")
                    .setTitle("发件人邮箱地址");//
                    tableFacade.getTable().getRow().getColumn("sentto")
                    .setTitle("收件人邮箱");//
                    tableFacade.getTable().getRow().getColumn("sentto_name")
                    .setTitle("收件人姓名");//
                    tableFacade.getTable().getRow().getColumn("copyto")
                            .setTitle("抄送人邮件地址");//
                    tableFacade.getTable().getRow().getColumn("copyto_name")
                            .setTitle("抄送人姓名");
                    tableFacade.getTable().getRow().getColumn("blindcopyto")
                               .setTitle("密送人邮箱地址");
                    tableFacade.getTable().getRow().getColumn("blindcopyto_name")
                            .setTitle("密送人姓名");
                    tableFacade.getTable().getRow().getColumn("subject")
                            .setTitle("主题");
                    tableFacade.getTable().getRow().getColumn("body")
                            .setTitle("内容");
                    tableFacade.getTable().getRow().getColumn("sent_time")
                            .setTitle("发送时间");
                    tableFacade.render();
                    return null;
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "emailreceive";
        }

        /**
         * 查询收到的邮件详细信息
         * @return
        */
        public String findEmailServiceById() {
            pd = new PageData(this.getRequest());
            try {
                pd = emailServiceImpl.findEmailServiceById(id);
                if ("0".equals(pd.getString("read_sign"))) {
                    emailServiceImpl.updateReadSign(id); // 如果该条信息为未读则设置为已读
                    pd.put("read_sign", 1);
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "emailreceiveinfo";
        }
        /*public String updateReadSign(){
            pd = new PageData(this.getRequest());
            try{
                
            }catch(Exception e){
                logger.error(e.toString(),e);
            }
            return SUCCESS;
        }
        */
        /**
         * 查询收到的郵件查看页面信息
         * 查看页面
         * @return
         */
        public String findemailServiceById1() {
            try {
                System.out.println("打印出pd1"+pd);
                PageData p = new PageData(this.getRequest());
                pd = emailServiceImpl.findEmailServiceById(Integer.parseInt(p.getString("chakanid")));
                System.out.println("打印出pd2"+pd);
                if ("0".equals(pd.getString("read_sign"))) {
                    emailServiceImpl.updateReadSign(Integer.parseInt(p.getString("chakanid"))); // 将该条邮件设置为已读
                }
                if("1".equals(pd.getString("isfiles"))){
                        pd = addFile(pd);
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "serviceinfo1";
        }
        
        /**
         * 将pd中放入附件的值
         *
         * @param pd
         * @return
         */
        public PageData addFile(PageData pd) {
            File file = new File(findInitPath() + "\" + BASEDir + pd.get("mms_id"));
            pd.put("filename", file.list());
            return pd;
        }

        
        /**
         * 收件箱(删除以及彻底删除)
         *
         * @return
         *//*
        public String deleteRecevice() {
            try {
                if ("1".equals(deleteStr)) { // 普通删除
                    Object[] obj = new Object[items.length];
                    PageData pdparam;
                    for (int i = 0; i < items.length; i++) {
                        pdparam = new PageData();
                        pdparam.put("sign", "1");
                        pdparam.put("id", items[i]);
                        obj[i] = pdparam;
                    }
                    emailServiceImpl.updateEmailSign(obj);
                } else if ("2".equals(deleteStr)) { // 彻底删除
                    emailServiceImpl.deteleService(items);
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return findReceviceBox();
        }*/

        
        /**
         * 删除以及彻底删除邮件草稿箱(暂只有彻底删除.if-2)
         *
         * @return
        
        public String deleteDraft() {
            try {
                
                if ("1".equals(deleteStr)) { // 普通删除
                    Object[] obj = new Object[items.length];
                    PageData pdparam;
                    for (int i = 0; i < items.length; i++) {
                        pdparam = new PageData();
                        pdparam.put("sign", "1");
                        pdparam.put("id", items[i]);
                        obj[i] = pdparam;
                    }
                    emailServiceImpl.updateEmailSign(obj);
                } else if ("2".equals(deleteStr)) {// 彻底删除
                    emailServiceImpl.deteleEmail(items);
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return findDraftList();
        } */
        
        
        /**
         * 查询邮件草稿箱基本信息详细信息
         *
         * @return
         */
        public String findEmailById() {
            try {
                pd = emailServiceImpl.findEmailById(id);
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return pageFlag;
        }
        /**
         * 查询草稿箱/未发信箱
         *
         * @return
         */
        public String findDraftList() {
            try {
                pd = new PageData(this.getRequest());
                UserPO user = (UserPO) this.session.get("user");
                if ("draft".equals(pd.getString("type"))) { // 草稿箱
                    pd.put("status", "0"); // 未发送
                    pd.put("sign", "0"); // 正常数据
                } else if ("errorSend".equals(pd.getString("type"))) { // 未发信箱
                    pd.put("status", "2"); // 发送失败
                    pd.put("sign", "0"); // 正常数据
                }
                int user_id = (Integer) session.get(Constant.UserId);
                pd.put("user_id", user_id);
                emaillist = emailServiceImpl.findDraftList(pd);
                // jmesa分页开始
                TableFacade tableFacade = new TableFacadeImpl("emailAction",
                        getRequest());
                Collection<PageData> items = emaillist;
                tableFacade.setItems(items);
                // jmesa分页开始
                tableFacade.setExportTypes(getResponse(), CSV, EXCEL, PDFP);// 导出文件的格式
                Limit limit = tableFacade.getLimit();// 导出附件
                if (limit.isExported()) {
                    tableFacade.setColumnProperties("id","sent","sentto","sentto_name","copyto",
                            "copyto_name","blindcopyto","blindcopyto_name","subject","body","sent_time");// 导出的列
                    if ("draft".equals(type)) {
                        tableFacade.getTable().setCaption("草稿箱列表");
                    } else if ("errorSend".equals(type)) {
                        tableFacade.getTable().setCaption("未发彩信列表");
                    }
                    tableFacade.getTable().getRow().getColumn("id")
                    .setTitle("编号");//
                    tableFacade.getTable().getRow().getColumn("sent")
                    .setTitle("发件人邮箱地址");//
                    tableFacade.getTable().getRow().getColumn("sentto")
                    .setTitle("收件人邮箱");//
                    tableFacade.getTable().getRow().getColumn("sentto_name")
                    .setTitle("收件人姓名");//
                    tableFacade.getTable().getRow().getColumn("copyto")
                            .setTitle("抄送人邮件地址");//
                    tableFacade.getTable().getRow().getColumn("copyto_name")
                            .setTitle("抄送人姓名");
                    tableFacade.getTable().getRow().getColumn("blindcopyto")
                               .setTitle("密送人邮箱地址");
                    tableFacade.getTable().getRow().getColumn("blindcopyto_name")
                            .setTitle("密送人姓名");
                    tableFacade.getTable().getRow().getColumn("subject")
                            .setTitle("主题");
                    tableFacade.getTable().getRow().getColumn("body")
                            .setTitle("内容");
                    tableFacade.getTable().getRow().getColumn("sent_time")
                            .setTitle("发送时间");
                    tableFacade.render();
                    return null;
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "emaildraft";
        }
        
        /**
         * 未发邮件的重新发送
         *
         * @return
         * @author:宋逸文
         */
        public String reSend() {
            try {
                pd = emailServiceImpl.findEmailById(id);
                pd.put("sent_time", new Date());//发送时间
                String isfiles = pd.getString("isfiles");//有无附件
                pd.put("status","1");
                //发送邮件
                String user_id = session.get("UserId").toString();
                PageData pds = emailServiceImpl.findConfig(Integer.parseInt(user_id));//获取邮箱配置
                String sentname = pd.getString("sent");//发送者邮箱地址
                String subject = pd.getString("subject");//标题
                String body = pd.getString("body");//内容
                String password = pds.getString("mail_password");//密码
                String serverhost = pds.getString("mail_send_server");//发送服务器
                String serverport = pds.getString("mail_send_serverport");//发送服务器端口
                //获取接收邮件地址名
                
                
                //从表中获取数据
                /*String sentto_name = pd.getString("sentto_name");//全部接收人的姓名
                String copyto_name = pd.getString("copyto_name");//全部抄送人的姓名
                String blindcopyto_name = pd.getString("blindcopyto_name");//全部密送人的姓名
    */            String senttos = pd.getString("sentto");//接收人邮箱地址
                /*String senttoAll = pd.getString("sentto");//全部接收人的邮箱地址
    */            String copyto = pd.getString("copyto");//全部抄送人的邮箱地址
                String blindcopyto = pd.getString("blindcopyto");//全部密送人的邮箱地址
                String sent_time = pd.getString("sent_time");//二次发送时间
                String sign = pd.getString("sign");//删除标记
                String read_sign = pd.getString("read_sign");//是否阅读过
                String status = pd.getString("status");//删除标记

                String Allemail = senttos + copyto + blindcopyto;
                //发送邮件;// 发送成功标示(发送邮件时先将标示设为成功,若发送失败再将其改为2;0'表示保存,'1'表示已发送,'2'表示发送失败)
                String[] strsentto = Allemail.split(",");
                for(int i=0;i<strsentto.length-1;i++){
                    String sentto = strsentto[i];
                    MailUtil.sendtoMail(sentname, password, serverhost, serverport, sentto, body, subject);//调用邮件发送方法重复发送
                }
                pd.put("status","1");//发送的邮件改变状态
                //调用方法,发送邮件
                String id=pd.getString("id");
                emailServiceImpl.updateUnsentList(id);//删除未发送的原邮件
                this.setMsg("发送成功!");// 页面提示

                
    //            均从表中获取,非页面获取
    //            pd.put("sentto", senttoAll);
    //            pd.put("copyto", copyto);
    //            pd.put("blindcopyto", blindcopyto);
    //            pd.put("sentto_name", senttonames);
    //            pd.put("copyto_name", copyto_name);
    //            pd.put("blindcopyto_name", blindcopyto_name);
    //            
    //    

                //int mail_id = emailServiceImpl.saveSendEmail(pd);
                /*HttpServletResponse response = this.getResponse();
                response.setContentType("text/html;charset=utf-8");
                PrintWriter writer = null;
                writer = this.getResponse().getWriter();
                List<File> list = this.getFiles();
                List<String> listname = this.getFilesFileName();//获取文件的名字

                
                if("1".equals(isfiles)){//有附件  执行发送附件
                    if(!"".equals(tableType)){//第一次发送的时候tableType为空,转发的时候不为空
                        File file = new File(makeDir("Mail"+"\" + tempFileDir));
                        if(file != null){
                            File[] files = file.listFiles();
                            if (files != null && files.length > 0) {
                                // 源文件夹路径
                                String filePath = makeDir("Mail"+"\" + tempFileDir );
                                // 目标文件夹路径
                                String tempPath = makeDir("Mail"+"\" + tableType + "\" + mail_id);
                                
                                // 循环遍历每个文件
                                for (int i = 0; i < files.length; i++) {
                                    // 获取文件名
                                    String tempFileName = files[i].getName();
                                    // 源文件路径
                                    String fileNamePath = filePath + "\" + tempFileName;
                                    // 目标文件路径
                                    String tempFilePath = tempPath + "\" + tempFileName;
                                    // 进行文件复制
                                    copyFile(fileNamePath, tempFilePath);
                                }
                                delDirOrFile(file);
                        }
                     }
                        //判断是否在转发的过程中又重新上传了文件
                        if(list != null && list.size() > 0){//有文件传过来
                            for(int i=0;i<list.size();i++){
                                File srcFile = list.get(i);//得到原始文件名字,该名字可以用来存到数据库
                                String saveName = listname.get(i);
                                String savePath;
                                if("1".equals(status)){
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/success/"+mail_id+"/";//保存路径
                                }else{
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/save/"+mail_id+"/";
                                }
                                pd.put("mail_id", mail_id);
                                pd.put("file_name", saveName);
                                pd.put("file_path", savePath);
                                emailServiceImpl.saveFile(pd);
                                
                                this.saveFile(srcFile,savePath,saveName);
                            }
                        writer.write("success");
                        }
                    }else{//第一发送tableType为空,新上传文件
                        if(list != null && list.size() > 0){//有文件传过来
                            for(int i=0;i<list.size();i++){
                                File srcFile = list.get(i);//得到原始文件名字,该名字可以用来存到数据库
                                String saveName = listname.get(i);
                                String savePath;
                                if("1".equals(status)){
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/success/"+mail_id+"/";//保存路径
                                }else{
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/save/"+mail_id+"/";
                                }
                                pd.put("mail_id", mail_id);
                                pd.put("file_name", saveName);
                                pd.put("file_path", savePath);
                                emailServiceImpl.saveFile(pd);
                                
                                this.saveFile(srcFile,savePath,saveName);
                            }
                        }
                        writer.write("success");
                    }
                }*/
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "resend";
        }
        
        
        /**
         * 草稿箱/未发邮件的编辑.
         *
         * @return
         * @author:songyiwen
        
        public String draftEdit() {
            try {

                pd = emailServiceImpl.findEmailById(id);
                body = pd.getString("body");//取内容
                sent = pd.getString("sent");//发件人
                subject = pd.getString("subject");//取主题
                sentto = pd.getString("sentto");//取收邮件地址
                sentto_name = pd.getString("sentto_name");//取收邮件人的姓名
                copyto = pd.getString("copyto");            //取抄送人地址
                copyto_name = pd.getString("copyto_name");//取抄送人姓名
                blindcopyto = pd.getString("blindcopyto");//取密送邮件地址
                blindcopyto_name = pd.getString("blindcopyto_name");//取密送人姓名
                
                
                getTempFile(id);//回显附件
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return sendMmsPage();
        }
         */
        
        /**
         * 发邮件页面
         *
         * @return
         */
        public String sendMmsPage() {
            try {
                // userpos = userServiceImpl.findAllUserInfo();
                queryLinks();
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return "emailsend";
        }

        
        /**
         * @Title: judgeTable方法
         * @Description: 根据参数判断表名
         * @param tableType表类型
         *            收件箱 read 未读信箱 unread 草稿箱 save  已发信箱
         *            success 配置 set
         * @return
         * @author:刘东升
         */
        public String judgeTable(String tableType) {
            if ("read".equals(tableType) || "unread".equals(tableType)) {
                return "mbx_inbox";
            }
            return "mbx_sms";
        }
        /**
         * 转发时创建临时文件夹存放附件
         * @param id
         */
        public void getTempFile(int id) throws Exception {
            File file = new File(makeDir("Mail"+"\" + tableType + "\" + id));
            if (file != null) {
                File[] files = file.listFiles();
                if (files != null && files.length > 0) {
                    // 生成随机文件夹名
                    String s = UUID.randomUUID().toString();//用来生成数据库的主键id非常不错。。
                    tempFileDir = s.replace("-", "");
                    // 源文件夹路径
                    String filePath = makeDir("Mail"+"\" + tableType + "\" + id);
                    // 目标文件夹路径
                    String tempPath = makeDir("Mail"+"\" + tempFileDir);
                    fileNames = "";
                    //FileUtils.copyDirectory(file, new File(tempPath));
                    
                    // 循环遍历每个文件
                    for (int i = 0; i < files.length; i++) {
                        // 获取文件名
                        String tempFileName = files[i].getName();
                        // 源文件路径
                        String fileNamePath = filePath + "\" + tempFileName;
                        // 目标文件路径
                        String tempFilePath = tempPath + "\" + tempFileName;
                        // 进行文件复制
                        copyFile(fileNamePath, tempFilePath);
                        fileNames += tempFileName + ",";
                    }
                    fileNames = fileNames.substring(0, fileNames.length() - 1);
                }
            }
        }
        /**
         * @Title: getFile方法
         * @Description: 编辑转发回显文件
         * @param pd
         * @return
         * @author:刘东升
        
        public void getFile(int id) {
            File file = new File(findInitPath() + "\"+"Mail"+"\" + tableType + "\" + id);
            if (file != null) {
                File[] files = file.listFiles();
                if (files != null && files.length > 0) {
                    fileNames = "";
                    for (int i = 0; i < files.length; i++) {
                        fileNames += files[i].getName() + ",";
                    }
                    fileNames = fileNames.substring(0, fileNames.length() - 1);
                }
            }
        }*/
        /**
         * @Title: queryLinks方法
         * @Description: 联系人树赋值
         * @throws Exception
         * @author:刘东升
         */
        public void queryLinks() throws Exception {
            
            long start = System.currentTimeMillis();
            int user_id = (Integer) session.get(Constant.UserId);
            groupLists = contactsServiceImpl.findGroupInfo(user_id, true);//获取分组信息(名称、id、人数)
            List<DeptPO> deptpos = deptServiceImpl.findDeptUserse();//部门信息
            
            List<PageData> phonePersonList = new ArrayList<PageData>();//手机分组的联系人信息
            phonePersonList = contactsServiceImpl.findMyPhonePersons(user_id);//
            List<PageData> Tslist = (List<PageData>)contactsServiceImpl.findTsList();//同事列表
            List<PageData> Khlist = (List<PageData>)contactsServiceImpl.findKhList();//客户列表
            //给tag-it组件付初始值
            System.out.println("短信:查询右侧通讯录信息开始");
            List<PageData> tagitList = new ArrayList<PageData>();
            //tagitList = contactsServiceImpl.findTagitList(user_id);//特注:这个查询很耗时间啊
            Map<String ,PageData> map = new HashMap<String,PageData>();
            //先遍历手机联系人,在遍历内部联系人,这样内部联系人可覆盖掉重复的人员。
            for(PageData p:phonePersonList){
                String id = p.getString("id");
                String name = p.getString("name");
                String phone = p.getString("phone");
                String email = p.getString("email");
                String type = "p";
                
                PageData t = new PageData();
                t.put("user_id", id);
                t.put("user_name", name);
                t.put("number_default", phone);
                t.put("email", email);
                t.put("type", type);
                
                String key = name+":"+email;
                map.put(key, t);
            }
            for(PageData p:Khlist){
                String id = p.getString("kh_id");
                String name = p.getString("name");
                String phone = p.getString("mobile");
                String email = p.getString("email");
                String type = "p";
                
                PageData t = new PageData();
                t.put("user_id", id);
                t.put("user_name", name);
                t.put("number_default", phone);
                t.put("email", email);
                t.put("type", type);
                
                String key = name+":"+email;
                map.put(key, t);
            }
            //再遍历内部联系人
            for(PageData p:Tslist){
                String id = p.getString("user_id");
                String name = p.getString("user_name");
                String phone = p.getString("number_default");
                String email = p.getString("email");
                String type = "";
                
                PageData t = new PageData();
                t.put("user_id", id);
                t.put("user_name", name);
                t.put("number_default", phone);
                t.put("email", email);
                t.put("type", type);
                
                String key = name+":"+email;
                map.put(key, t);
            }
            
            tagitList.addAll(map.values());
            
            //用于形成组织树
            this.getRequest().setAttribute("groupinfo", groupLists);
            this.getRequest().setAttribute("deptpos", deptpos);
            this.getRequest().setAttribute("phonePersons", phonePersonList);
            this.getRequest().setAttribute("Khlist", Khlist);
            //用户给tag-it赋值
            this.getRequest().setAttribute("tagitList", tagitList);
            long end = System.currentTimeMillis();
            long time = end - start;
            System.out.println("短信:查询右侧通讯录信息结束");
            System.out.println("短信:查询右侧通讯录耗时:"+time/1000+"秒");
        }

        /**
         * @Title: emailSetInfo方法
         * @Description: 跳转到配置页面
         * @throws Exception
         * @author:张菡菡
         */
        public String emailSetInfo(){
            try{
                pd = new PageData(this.getRequest());
                String sid = pd.getString("id");
                pd = emailServiceImpl.findsetEmail(sid);
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "emailsetinfo";
        }
        
        /**
         * @Title: toEdit方法
         * @Description: 配置跳转到编辑
         * @throws Exception
         * @author:张菡菡
         */
        public String toEdit(){
            try{
                pd = new PageData(this.getRequest());
                String sid = pd.getString("id");
                pd = emailServiceImpl.findsetEmail(sid);
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "toedit";
        }
        /**
         * @Title: updateEdit方法
         * @Description:修改配置
         * @throws Exception
         * @author:张菡菡
         */
        public String updateEdit(){
            pd = new PageData(this.getRequest());
            try{
                String sign = pd.getString("sign");
                int id = Integer.parseInt(pd.getString("id"));
                if("1".equals(sign)){
                    emailServiceImpl.updateSign(id);
                }
                emailServiceImpl.updateEdit(pd);
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "saveemail";
        }
        /**
         * @Title: updatesign方法
         * @Description:是否启用-list
         * @throws Exception
         * @author:张菡菡
         */
        public String updatesign(){
            pd = new PageData(this.getRequest());
            try{
                String itemss = pd.getString("id");
                int id = Integer.parseInt(itemss);
                String sign = pd.getString("sign");
                if("1".equals(sign)){//确保只有一个邮箱启用
                    emailServiceImpl.updateSign(id);
                }
                emailServiceImpl.updateSignOnly(pd);
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "saveemail";
        }
        /**
         * @Title: saveSetEmail方法
         * @Description:保存配置
         * @throws Exception
         * @author:张菡菡
         */
        public String saveSetEmail(){
            try{
                pd = new PageData(this.getRequest());
                String user_id = session.get("UserId").toString();
                pd.put("user_id", user_id);
                String email = pd.getString("mail_address");
                
                //将email重新放入session中
                /*
                UserPO user = (UserPO) session.get("user");//从session中获取到user
                user.setEmail(email);//重新设置user中的email值
                HttpSession session = this.getSession(); // 获取当前session
                session.setAttribute(Constant.WEBUSER, user);//再放入到session中*/
                emailServiceImpl.saveSetEmail(pd);
                
                
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "saveemail";
        }
        /**
         * @Title: deleteset方法
         * @Description: 删除配置
         * @throws Exception
         * @author:张菡菡
         */
        public String deleteset(){
            pd = new PageData(this.getRequest());
            try{
                String itemss = pd.getString("items");
                items = itemss.split(",");
                for(String id:items){
                    emailServiceImpl.deleteset(id);
                }
                
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "saveemail";
        }
        
        /**
         * @Title: sendEmailbox方法
         * @Description: 发送邮件
         * @throws Exception
         * @author:张菡菡
         */
        public String sendEmailbox(){
            pd = new PageData(this.getRequest());
            try{
                //pd.put("sent_time", now());
                String isfiles = pd.getString("isfiles");
                String state = pd.getString("state");
                String user_id = session.get("UserId").toString();
                PageData pds = emailServiceImpl.findConfig(Integer.parseInt(user_id));//获取邮箱配置
                String sentname = pd.getString("sent");//发送者邮箱地址
                String subject = pd.getString("subject");//标题
                String body = pd.getString("body");//内容
                String password = pds.getString("mail_password");//密码
                String serverhost = pds.getString("mail_send_server");//发送服务器
                String serverport = pds.getString("mail_send_serverport");//发送服务器端口
                
                //获取接收邮件地址名
                Pattern p = Pattern.compile("<(.*?)>"); //尖括号的正则表达式
                String useremail = pd.getString("oldlinks");
                String usere[] = useremail.split(",");
                String acceptemail = pd.getString("acceptInfo");
                String carbonemail = pd.getString("carbonInfo");
                String bccemail = pd.getString("bccInfo");
                String senttonames = "";//全部接收人的姓名
                String copyto_name = "";//全部抄送人的姓名
                String blindcopyto_name = "";//全部密送人的姓名
                String sentto = "";//接收人邮箱地址
                String senttoAll = "";//全部接收人的邮箱地址
                String copyto = "";//全部抄送人的邮箱地址
                String blindcopyto = "";//全部密送人的邮箱地址
                
                //发送邮件
                if("success".equals(state)){
                    pd.put("status", 1);//发送的邮件
                    //调用方法,发送邮件
                    if(!"".equals(acceptemail)){
                        Matcher useremailemail = p.matcher(acceptemail); //截取尖括号中的值
                        while (useremailemail.find()) {//收件人
                            sentto = useremailemail.group(1);
                            MailUtil.sendtoMail(sentname, password, serverhost, serverport, sentto, body, subject);//调用邮件发送方法
                        }
                    }
                    if(!"".equals(carbonemail)){
                        Matcher useremailemail = p.matcher(carbonemail); //截取尖括号中的值
                        while (useremailemail.find()) {//收件人
                            sentto = useremailemail.group(1);
                            MailUtil.sendtoMail(sentname, password, serverhost, serverport, sentto, body, subject);//调用邮件发送方法
                        }
                    }
                    if(!"".equals(bccemail)){
                        Matcher useremailemail = p.matcher(bccemail); //截取尖括号中的值
                        while (useremailemail.find()) {//收件人
                            sentto = useremailemail.group(1);
                            MailUtil.sendtoMail(sentname, password, serverhost, serverport, sentto, body, subject);//调用邮件发送方法
                        }
                    }
                    this.setMsg("发送成功!");// 页面提示
                }else if("save".equals(state)){
                    pd.put("status", 0);//保存的邮件
                    this.setMsg("保存成功!");// 页面提示
                }
                
                /*各类接收邮箱*/
                String accept = pd.getString("acceptInfo"); //收件人邮箱
                String carbon = pd.getString("carbonInfo");//抄送人邮箱
                String bcc = pd.getString("bccInfo");//密送人
                
                int length = 0;
                if(!"".equals(accept)){
                    //全部接收人邮箱
                    Matcher macceptemail = p.matcher(accept); //截取尖括号中的值
                    while (macceptemail.find()) {//收件人
                        senttoAll = senttoAll + macceptemail.group(1)+",";
                    }
                    int indexs = senttoAll.lastIndexOf(",");//去掉最后一个逗号
                    senttoAll = senttoAll.substring(0, indexs);
                    //全部收件人
                    String acceptperson[] = accept.split(";");//先获取单个值
                    for(String ept:acceptperson){//遍历单个的值取出双引号中的值
                        int i = ept.indexOf('"');
                        int b = ept.lastIndexOf('"');
                        senttonames = senttonames + ept.substring(i+1, b);
                        length += 1;
                        if(length<acceptperson.length){
                            senttonames = senttonames + ",";
                        }
                    }
                }
                if(!"".equals(carbon)){
                    //全部抄送人邮箱
                    Matcher mcarbonemail = p.matcher(carbon);
                    while (mcarbonemail.find()) {//抄送人
                        copyto = copyto + mcarbonemail.group(1)+",";
                    }
                    int indexs = copyto.lastIndexOf(",");//去掉最后一个逗号
                    copyto = copyto.substring(0, indexs);
                    //全部抄送人
                    String carbonperson[] = carbon.split(";");//先获取单个值
                    for(String ept:carbonperson){//遍历单个的值取出双引号中的值
                        int i = ept.indexOf('"');
                        int b = ept.lastIndexOf('"');
                        copyto_name = copyto_name + ept.substring(i+1, b);
                        length += 1;
                        if(length<carbonperson.length){//最后一个不加逗号
                            copyto_name = copyto_name + ",";
                        }
                    }
                }
                if(!"".equals(bcc)){
                    Matcher mbccemail = p.matcher(bcc);
                    while (mbccemail.find()) {//密送人
                        blindcopyto = blindcopyto + mbccemail.group(1)+",";
                    }
                    int indexs = blindcopyto.lastIndexOf(",");//去掉最后一个逗号
                    blindcopyto = blindcopyto.substring(0, indexs);
                    //全部密送人
                    String bccperson[] = bcc.split(";");
                    for(String ept:bccperson){
                        int i = ept.indexOf('"');
                        int b = ept.lastIndexOf('"');
                        blindcopyto_name = blindcopyto_name + ept.substring(i+1, b);
                        length += 1;
                        if(length<bccperson.length){
                            blindcopyto_name = blindcopyto_name + ",";
                        }
                    }
                }
                pd.put("sentto", senttoAll);
                pd.put("copyto", copyto);
                pd.put("blindcopyto", blindcopyto);
                pd.put("sentto_name", senttonames);
                pd.put("copyto_name", copyto_name);
                pd.put("blindcopyto_name", blindcopyto_name);
        
                int mail_id = emailServiceImpl.saveSendEmail(pd);
                HttpServletResponse response = this.getResponse();
                response.setContentType("text/html;charset=utf-8");
                PrintWriter writer = null;
                writer = this.getResponse().getWriter();
                List<File> list = this.getFiles();
                List<String> listname = this.getFilesFileName();//获取文件的名字

                
                if("1".equals(isfiles)){//有附件  执行发送附件
                    if(!"".equals(tableType)){//第一次发送的时候tableType为空,转发的时候不为空
                        File file = new File(makeDir("Mail"+"\" + tempFileDir));
                        if(file != null){
                            File[] files = file.listFiles();
                            if (files != null && files.length > 0) {
                                // 源文件夹路径
                                String filePath = makeDir("Mail"+"\" + tempFileDir );
                                // 目标文件夹路径
                                String tempPath;
                                if("success".equals(state)){
                                    tempPath = makeDir("Mail"+"\success\" + mail_id);//保存路径
                                }else{
                                    tempPath = makeDir("Mail"+"\save\" + mail_id);
                                }
                                // 循环遍历每个文件
                                for (int i = 0; i < files.length; i++) {
                                    // 获取文件名
                                    String tempFileName = files[i].getName();
                                    // 源文件路径
                                    String fileNamePath = filePath + "\" + tempFileName;
                                    // 目标文件路径
                                    String tempFilePath = tempPath + "\" + tempFileName;
                                    // 进行文件复制
                                    copyFile(fileNamePath, tempFilePath);
                                }
                                delDirOrFile(file);
                        }
                     }
                        //判断是否在转发的过程中又重新上传了文件
                        if(list != null && list.size() > 0){//有文件传过来
                            for(int i=0;i<list.size();i++){
                                File srcFile = list.get(i);//得到原始文件名字,该名字可以用来存到数据库
                                String saveName = listname.get(i);
                                String savePath;
                                if("success".equals(state)){
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/success/"+mail_id+"/";//保存路径
                                }else{
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/save/"+mail_id+"/";
                                }
                                pd.put("mail_id", mail_id);
                                pd.put("file_name", saveName);
                                pd.put("file_path", savePath);
                                emailServiceImpl.saveFile(pd);
                                
                                this.saveFile(srcFile,savePath,saveName);
                            }
                        writer.write("success");
                        }
                    }else{//第一发送tableType为空,新上传文件
                        if(list != null && list.size() > 0){//有文件传过来
                            for(int i=0;i<list.size();i++){
                                File srcFile = list.get(i);//得到原始文件名字,该名字可以用来存到数据库
                                String saveName = listname.get(i);
                                String savePath;
                                if("success".equals(state)){
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/success/"+mail_id+"/";//保存路径
                                }else{
                                    savePath = CommonMethod.getWebRootAbsolutePath()+"smsdocument/Mail/save/"+mail_id+"/";
                                }
                                pd.put("mail_id", mail_id);
                                pd.put("file_name", saveName);
                                pd.put("file_path", savePath);
                                emailServiceImpl.saveFile(pd);
                                
                                this.saveFile(srcFile,savePath,saveName);
                            }
                        }
                        writer.write("success");
                    }
                }
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "sendmailto";
        }
        
        
        /**
         * @Title: delFujian方法
         * @Description:删除已上传的附件
         * @return
         * @author:刘东升
         */
        public String delFujian() {
            try {
                if ("transpond".equals(flag) || "successzf".equals(flag)) {
                    String path = makeDir("Mail" + "\" + tempFileDir);
                    this.delFile(path, file_name);
                    File f[] = findFilesByPath("Mail" + "\" + tempFileDir);
                    if(f == null || f.length == 0){
                        delDirOrFile(path);//如果临时文件夹里面没有附件了就删除文件夹
                    }
                } else {
                    String path = makeDir("Mail" + "\" + tableType + "\" + file_id);
                    this.delFile(path, file_name);
                    // 如果此目录下没有附件了,则将数据库中此信息的附件标识改为0
                    File[] myfiles = this.findFilesByPath("Mail" + "\" + tableType + "\" + file_id);
                    if (myfiles == null || myfiles.length == 0) {
                        // pnoticeServiceImpl.updateFujian(file_id);
                        Map map = new HashMap();
                        map.put("tableName", judgeTable(tableType));// 删除的表名字
                        map.put("id", file_id);// 删除信息的id
                        this.emailServiceImpl.updateFujian(map);
                        delDirOrFile(path);
                    }
                }
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
            return NONE;
        }
        

        public String getPageFlag() {
            return pageFlag;
        }

        public void setPageFlag(String pageFlag) {
            this.pageFlag = pageFlag;
        }

        
        /**
         * @Title: download方法
         * @Description: 附件下载
         * @return
         * @throws Exception
         * @author:刘东升
         */
        public String download() throws Exception {
            try {
                String path = this.makeDir("Mail"+"\" + markName + "\" + file_id)
                        + "\";
                this.downloadFile(this.getResponse(), path, this.file_name);
            } catch (Exception e) {
                // logger.error(e.toString(), e);
            }
            return null;
        }
        
        /**
         * @Title: findEmailSetList方法
         * @Description: 查询邮件配置列表
         * @throws Exception
         * @author:赵可
         */
        
        public String findEmailSetList(){
            pd = new PageData(this.getRequest());
            TableFacade tablefacade = new TableFacadeImpl("emailAction", this.getRequest());
            try{
                String user_id = session.get("UserId").toString();
                pd.put("user_id", user_id);
                JmesaPageList jmesaObject = emailServiceImpl.findEmailSetLists(new JmesaPageList(tablefacade, pd),pd);
                emailsetlist = jmesaObject.getItemsList();
                // jmesa分页开始
                Limit limit = jmesaObject.getLimit();
                this.getRequest().setAttribute("limit", limit);
                Collection<PageData> items = emailsetlist;
                tablefacade.setItems(items);
                
                // jmesa分页开始
                tablefacade.setExportTypes(getResponse(), CSV, EXCEL, PDFP);// 导出文件的格式
                if (limit.isExported()) {
                    tablefacade.setColumnProperties("account_name", "mail_address", "mail_password"); // 导出的列
                    tablefacade.getTable().setCaption("邮件设置列表");// 导出的文件名
                    tablefacade.getTable().getRow().getColumn("account_name").setTitle(
                            "账号");
                    tablefacade.getTable().getRow().getColumn("mail_address").setTitle(
                            "邮箱");
                    tablefacade.getTable().getRow().getColumn("mail_password").setTitle(
                            "密码");
                    tablefacade.render();
                    
                    return null;
                }
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "emailsetlist";
        }
        
        /**
         * @Title: findEmailList方法
         * @Description: 查询已发邮件列表
         * @throws Exception
         * @author:张菡菡
         */
        
        public String findEmailList(){
            System.out.println("第三方士大夫发");
            pd = new PageData(this.getRequest());
            System.out.println("pd为"+pd);
            TableFacade tablefacade = new TableFacadeImpl("emailAction", this.getRequest());
            try{
                String user_id = session.get("UserId").toString();
                pd.put("user_id", user_id);
                JmesaPageList jmesaObject = emailServiceImpl.findEmailLists(new JmesaPageList(tablefacade, pd),pd);
                emaillist = jmesaObject.getItemsList();
                System.out.println("emaillist+++"+emaillist);
                // jmesa分页开始
                Limit limit = jmesaObject.getLimit();
                this.getRequest().setAttribute("limit", limit);
                Collection<PageData> items = emaillist;
                tablefacade.setItems(items);
                
                // jmesa分页开始
                tablefacade.setExportTypes(getResponse(), CSV, EXCEL, PDFP);// 导出文件的格式
                if (limit.isExported()) {
                    tablefacade.setColumnProperties("sentto_name", "sentto",
                            "sent_time", "body"); // 导出的列
                    tablefacade.getTable().setCaption("已发邮件列表");// 导出的文件名
                    tablefacade.getTable().getRow().getColumn("sentto_name").setTitle(
                            "接收人姓名");
                    tablefacade.getTable().getRow().getColumn("sentto").setTitle(
                            "接收人邮箱");
                    tablefacade.getTable().getRow().getColumn("sent_time").setTitle(
                            "发送时间");
                    tablefacade.getTable().getRow().getColumn("body").setTitle("内容");
                    
                    tablefacade.render();
                    
                    return null;
                }
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "Esuccess";
        }
        
        /**
         * @Title: findSuccessById方法
         * @Description: 根据id查询已发邮件
         * @throws Exception
         * @author:张菡菡
         */
        public String findSuccessById(){
            pd = new PageData(this.getRequest());
            try{
                pd = emailServiceImpl.findSuccessById(pd);
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "emailsuccessInfo";
        }
        /**
         * @Title: deleteSentList方法
         * @Description: 删除和彻底删除
         * @throws Exception
         * @author:张菡菡
         */
        public String deleteSentList(){
            String result = "";
            pd = new PageData(this.getRequest());
            try{
                String type = pd.getString("tableType");
                if("success".equals(type)){//已发邮件
                    result = "dsl";
                }else if("delete".equals(type)){//垃圾箱
                    result = "fdlr";
                }else if("save".equals(type)){//草稿箱
                    result = "savedel";
                }else if("receive".equals(type)){//收件箱
                    result = "receivedel";
                }else if("unsend".equals(type)){
                    result = "errordel";//未发邮件
                }
                String itemss = pd.getString("items");//获取提交的id
                items = itemss.split(",");
                String deleteFlag = pd.getString("deleteFlag");
                for (String id : items) {//遍历id执行
                    if("true".equals(deleteFlag)){//删除
                        emailServiceImpl.updateSentList(id);
                    }else{//彻底删除
                        emailServiceImpl.deleteSentList(id);
                    }
                }
            }catch(Exception e){
                logger.error(e.toString());
            }
            return result;
        }
        /**
         * @Title: findDeleteList方法
         * @Description: 垃圾箱
         * @throws Exception
         * @author:张菡菡
         */
        public String findDeleteList(){
            try{
                pd = new PageData(this.getRequest());
                String user_id = session.get("UserId").toString();
                pd.put("user_id", user_id);
                TableFacade tablefacade = new TableFacadeImpl("emailAction", this
                        .getRequest());
                JmesaPageList jmesaObject = emailServiceImpl.findDeletelist(new JmesaPageList(tablefacade, pd),pd);
                emaillist = jmesaObject.getItemsList();
                // jmesa分页开始
                Limit limit = jmesaObject.getLimit();
                this.getRequest().setAttribute("limit", limit);
                Collection<PageData> items = emaillist;
                tablefacade.setItems(items);
                //jmesa分页开始
                
                tablefacade.setExportTypes(getResponse(), CSV, EXCEL, PDFP);// 导出文件的格式
                if (limit.isExported()) {
                    tablefacade.setColumnProperties("sentto_name", "sentto",
                            "sent_time", "body"); // 导出的列
                    tablefacade.getTable().setCaption("已发邮件列表");// 导出的文件名
                    tablefacade.getTable().getRow().getColumn("sentto_name").setTitle(
                            "接收人姓名");
                    tablefacade.getTable().getRow().getColumn("sentto").setTitle(
                            "接收人邮箱");
                    tablefacade.getTable().getRow().getColumn("sent_time").setTitle(
                            "发送时间");
                    tablefacade.getTable().getRow().getColumn("body").setTitle("内容");
                    
                    tablefacade.render();
                    
                    return null;
                }
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "dellist";
        }
        /**
         * @Title: setdelete方法
         * @Description: 恢复
         * @throws Exception
         * @author:张菡菡
         */
        public String resetdelete(){
            pd = new PageData(this.getRequest());
            try{
                String itemss = pd.getString("items");
                items = itemss.split(",");
                for (String id : items) {
                    emailServiceImpl.resetdelete(id);
                }
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "fdlr";
        }
        /**
         * @Title: finddelById方法
         * @Description: 根据id查询删除数据的详细信息
         * @throws Exception
         * @author:张菡菡
         */
        public String finddelById(){
            pd = new PageData(this.getRequest());
            try{
                pd = emailServiceImpl.finddelById(pd);
            }catch(Exception e){
                logger.error(e.toString());
            }
            return "delById";
        }
        
        
        
        public void setDatas(List datas) {
            this.datas = datas;
        }
        public List getDatas() {
            return datas;
        }
        public String[] getItems() {
            return items;
        }

        public void setItems(String[] items) {
            this.items = items;
        }

        public PageData getPd() {
            return pd;
        }

        public void setPd(PageData pd) {
            this.pd = pd;
        }



        public String getTableType() {
            return tableType;
        }



        public void setTableType(String tableType) {
            this.tableType = tableType;
        }



        public String getOptionType() {
            return optionType;
        }



        public void setOptionType(String optionType) {
            this.optionType = optionType;
        }



        public InBoxPO getInBoxPO() {
            return inBoxPO;
        }



        public void setInBoxPO(InBoxPO inBoxPO) {
            this.inBoxPO = inBoxPO;
        }



        public SmsPO getSmsPO() {
            return smsPO;
        }



        public void setSmsPO(SmsPO smsPO) {
            this.smsPO = smsPO;
        }



        public String getFlag() {
            return flag;
        }



        public void setFlag(String flag) {
            this.flag = flag;
        }



        public String getTempFileDir() {
            return tempFileDir;
        }



        public void setTempFileDir(String tempFileDir) {
            this.tempFileDir = tempFileDir;
        }


        public String getFileNames() {
            return fileNames;
        }



        public void setFileNames(String fileNames) {
            this.fileNames = fileNames;
        }


        public String getFile_id() {
            return file_id;
        }

        public void setFile_id(String file_id) {
            this.file_id = file_id;
        }
        



        public List<ContactsGroupPO> getGroupLists() {
            return groupLists;
        }



        public void setGroupLists(List<ContactsGroupPO> groupLists) {
            this.groupLists = groupLists;
        }



        public UserPO getUserPO() {
            return userPO;
        }



        public void setUserPO(UserPO userPO) {
            this.userPO = userPO;
        }



        public List<PageData> getEmaillist() {
            return emaillist;
        }



        public void setEmaillist(List<PageData> emaillist) {
            this.emaillist = emaillist;
        }



        public String getSubject() {
            return subject;
        }



        public void setSubject(String subject) {
            this.subject = subject;
        }



        public String getMarkName() {
            return markName;
        }



        public void setMarkName(String markName) {
            this.markName = markName;
        }




        public String getFile_name() {
            return file_name;
        }



        public void setFile_name(String file_name) {
            this.file_name = file_name;
        }
        

        public String[] getForwardFileNames() {
            return forwardFileNames;
        }

        public void setForwardFileNames(String[] forwardFileNames) {
            this.forwardFileNames = forwardFileNames;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getDeleteStr() {
            return deleteStr;
        }

        public void setDeleteStr(String deleteStr) {
            this.deleteStr = deleteStr;
        }



        public int getAtt_mail_id() {
            return att_mail_id;
        }



        public void setAtt_mail_id(int att_mail_id) {
            this.att_mail_id = att_mail_id;
        }

        public String getRead_sign() {
            return read_sign;
        }

        public void setRead_sign(String read_sign) {
            this.read_sign = read_sign;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getBody() {
            return body;
        }

        public void setBody(String body) {
            this.body = body;

        }
        
        public String getSentto() {
            return sentto;
        }


        public PageData getPd_config() {
            return pd_config;
        }


        public void setPd_config(PageData pd_config) {
            this.pd_config = pd_config;
        }

        public void setSentto(String sentto) {
            this.sentto = sentto;
        }


        public String getSentto_name() {
            return sentto_name;
        }


        public void setSentto_name(String sentto_name) {
            this.sentto_name = sentto_name;
        }


        public String getCopyto() {
            return copyto;
        }


        public void setCopyto(String copyto) {
            this.copyto = copyto;
        }


        public String getCopyto_name() {
            return copyto_name;
        }


        public void setCopyto_name(String copyto_name) {
            this.copyto_name = copyto_name;
        }


        public String getBlindcopyto() {
            return blindcopyto;
        }


        public void setBlindcopyto(String blindcopyto) {
            this.blindcopyto = blindcopyto;
        }


        public String getBlindcopyto_name() {
            return blindcopyto_name;
        }


        public void setBlindcopyto_name(String blindcopyto_name) {
            this.blindcopyto_name = blindcopyto_name;
        }

        public String getSent() {
            return sent;
        }


        public void setSent(String sent) {
            this.sent = sent;
        }


        public List<PageData> getEmailsetlist() {
            return emailsetlist;
        }


        public void setEmailsetlist(List<PageData> emailsetlist) {
            this.emailsetlist = emailsetlist;
        }

        
    }

  • 相关阅读:
    eclipse新 java 文件时自动生成注释
    int占几个字节
    eclipse常用插件
    Asp.net中IsPostBack的实现原理
    Github的入门简介
    Hypertable
    VA01/VA02行项目物料搜索帮助新增页签
    rich_text
    js之Math
    js function参数
  • 原文地址:https://www.cnblogs.com/edmundsong/p/3419128.html
Copyright © 2020-2023  润新知