Exemple #1
0
  /**
   * 拷贝至对应邮箱
   *
   * @param sqlSession
   * @param mapper
   * @param mapperRelation
   * @param mapperContent
   * @param record
   * @param recordRelation
   * @param recordContent
   * @param temp
   * @throws IllegalAccessException
   * @throws UnsupportedEncodingException
   */
  private void copyMail(
      B_T_Ufp_Mail_Attribute record,
      B_T_Ufp_Mail_Relation recordRelation,
      B_T_Ufp_Mail_Content recordContent,
      String temp,
      C_T_Sys_FileExample example,
      C_T_Sys_FileExample.Criteria criteria)
      throws IllegalAccessException, UnsupportedEncodingException {
    String uuid = new GUID().toString();
    // 拷贝邮件时同时拷贝邮件带的附件
    criteria.andMainIdEqualTo(temp.trim());
    List<C_T_Sys_File> c_T_Sys_File_list = mapperFT.selectByExample(example);
    if (c_T_Sys_File_list != null) {
      for (C_T_Sys_File file : c_T_Sys_File_list) {
        file.setUuid(new GUID().toString());
        file.setMainId(uuid); // 设置原始邮件附件
        mapperFT.insertSelective(file);
      }
    }
    // 插入邮件关联表
    b_T_Ufp_Mail_Relation.setUuid(uuid);
    if ("1".equals(mailTypeS)) {
      b_T_Ufp_Mail_Relation.setReplyFlag(4); // 拷贝至发件箱:4
    } else if ("7".equals(mailTypeS)) {
      b_T_Ufp_Mail_Relation.setReplyFlag(1); // 收件箱:1
      // 拷贝至收件箱设置特定收件人为当前登录人
      b_T_Ufp_Mail_Relation.setSpecificRecsysUser(SessionFactory.getSessionUserId());
    } else if ("2".equals(mailTypeS)) {
      b_T_Ufp_Mail_Relation.setReplyFlag(3); // 草稿箱:3
    } else if ("3".equals(mailTypeS)) {
      b_T_Ufp_Mail_Relation.setReplyFlag(3); // 垃圾箱:3
    }
    b_T_Ufp_Mail_Relation.setMailType(Long.valueOf(mailTypeS));
    b_T_Ufp_Mail_Relation.setMailAttributeId(uuid);
    b_T_Ufp_Mail_Relation.setMailContentId(uuid);

    mapperMRT.insertSelective(b_T_Ufp_Mail_Relation);
    // 插入邮件属性表
    b_T_Ufp_Mail_Attribute = mapperMAT.selectByPrimaryKey(temp);
    b_T_Ufp_Mail_Attribute.setUuid(uuid);
    mapperMAT.insertSelective(b_T_Ufp_Mail_Attribute);
    // 插入邮件正文表
    b_T_Ufp_Mail_Content = mapperMCT.selectByPrimaryKey(temp);
    b_T_Ufp_Mail_Content.setUuid(uuid);
    mapperMCT.insertSelective(b_T_Ufp_Mail_Content);
  }
Exemple #2
0
 /**
  * 给所有收件人的邮件附上附件
  *
  * @param mapperFile
  * @param guid
  * @throws IllegalAccessException
  * @throws UnsupportedEncodingException
  */
 private void addForAllRecUser(String guid) throws Exception {
   // newFileIds所有原始附件主键(发邮件时,给每个收邮件的附上附件)
   if (StringTools.isNotNullAndHasValue(newFileIds)) {
     // 将新增附件保存进当前回复中
     // 修改by:youjh 2015-10-21
     newFileIds = newFileIds.replaceAll("[?]", "%3F");
     String[] listTemp = newFileIds.split("%3F");
     C_T_Sys_File c_T_Sys_File = null;
     // 设置回复邮件附件
     for (String file : listTemp) {
       if (StringTools.isNotNullAndHasValue(file.trim())) {
         c_T_Sys_File = mapperFT.selectByPrimaryKey(file);
         if (c_T_Sys_File != null) {
           c_T_Sys_File.setUuid(new GUID().toString());
           c_T_Sys_File.setMainId(guid); // 回复邮件主键
           mapperFT.insertSelective(c_T_Sys_File);
         }
       }
     }
   }
 }
Exemple #3
0
 /**
  * 给回复,转发邮件设置附件
  *
  * @param mapperFile
  * @param example
  * @param criteria
  * @param uuid
  * @throws IllegalAccessException
  * @throws UnsupportedEncodingException
  * @throws InvocationTargetException
  * @throws NoSuchMethodException
  * @throws IOException
  * @throws ClassNotFoundException
  */
 private void replyMailFile(
     C_T_Sys_FileExample example, C_T_Sys_FileExample.Criteria criteria, String uuid)
     throws Exception {
   // newFileIds原始附件主键
   if (StringTools.isNotNullAndHasValue(newFileIds)) {
     // 将新增附件保存进当前回复中
     // 修改by:youjh 2015-10-21
     newFileIds = newFileIds.replaceAll("[?]", "%3F");
     String[] listTemp = newFileIds.split("%3F");
     C_T_Sys_File c_T_Sys_File = null;
     // 设置转发邮件附件
     for (String temp : listTemp) {
       if (StringTools.isNotNullAndHasValue(temp.trim())) {
         c_T_Sys_File = mapperFT.selectByPrimaryKey(temp);
         if (c_T_Sys_File != null) {
           c_T_Sys_File.setUuid(new GUID().toString());
           c_T_Sys_File.setMainId(uuid); // 回复(转发)邮件主键
           mapperFT.insertSelective(c_T_Sys_File);
         } else {
           // 如果是逻辑删除附件,则可以恢复原始邮件附件
           criteria.andMainIdEqualTo(mainDocId);
           criteria.andIsDeleteEqualTo(1);
           List<C_T_Sys_File> c_T_Sys_File_list = mapperFT.selectByExample(example);
           if (c_T_Sys_File_list != null) {
             for (C_T_Sys_File file : c_T_Sys_File_list) {
               file.setUuid(new GUID().toString());
               file.setMainId(mainDocId); // 回复原始邮件附件
               file.setIsDelete(0);
               mapperFT.insertSelective(file);
             }
           }
         }
       }
     } // --for
   }
 }
Exemple #4
0
 /**
  * 查询邮件对应的附件名
  *
  * @param mapperFile
  * @param example
  * @param criteria
  */
 private String searchFileName(C_T_Sys_FileExample example, String uuid) {
   example.clear();
   example.or().andMainIdEqualTo(uuid);
   List<C_T_Sys_File> listFile = mapperFT.selectByExample(example);
   String temp = "";
   newFileIds = "";
   if (listFile != null) {
     for (C_T_Sys_File c_T_Sys_File : listFile) {
       temp = temp + "\t" + c_T_Sys_File.getFileName();
       if (StringTools.isNotNullAndHasValue(newFileIds)) {
         newFileIds = newFileIds + "?" + c_T_Sys_File.getUuid();
       } else {
         newFileIds = c_T_Sys_File.getUuid();
       }
     }
   }
   return temp;
 }
Exemple #5
0
  /**
   * 发邮件时保存邮件,并发送邮件
   *
   * @param sqlSession
   * @param mapper
   * @param mapperRelation
   * @param mapperContent
   * @param record
   * @param recordRelation
   * @param recordContent
   * @param sendTime
   * @param sendUser
   * @param sendSysUser
   * @return
   */
  private String saveMail(
      B_T_Ufp_Mail_Attribute record,
      B_T_Ufp_Mail_Relation recordRelation,
      B_T_Ufp_Mail_Content recordContent,
      String sendTime,
      String sendUser,
      String sendSysUser,
      int replyFlag,
      C_T_Sys_FileExample example,
      C_T_Sys_FileExample.Criteria criteria)
      throws Exception {
    String returnMsg;
    // 向邮件属性表 添加
    String uuid = new GUID().toString();
    String isFile = null;
    // 所有收邮件人:收件人、抄送人和暗送人
    String allReceiverSysUser = null;
    if (b_T_Ufp_Mail_Relation != null) {
      allReceiverSysUser = b_T_Ufp_Mail_Relation.getUserId();
      if (b_T_Ufp_Mail_Attribute != null) {
        if (StringTools.isNotNullAndHasValue(allReceiverSysUser)) {
          allReceiverSysUser =
              allReceiverSysUser
                  + ","
                  + b_T_Ufp_Mail_Attribute.getCopySysUser()
                  + ","
                  + b_T_Ufp_Mail_Attribute.getDarkSysUser();
        } else {
          allReceiverSysUser =
              b_T_Ufp_Mail_Attribute.getCopySysUser()
                  + ","
                  + b_T_Ufp_Mail_Attribute.getDarkSysUser();
        }
      }
    } else {
      allReceiverSysUser = "";
      if (b_T_Ufp_Mail_Attribute != null) {
        if (StringTools.isNotNullAndHasValue(allReceiverSysUser)) {
          allReceiverSysUser =
              allReceiverSysUser
                  + ","
                  + b_T_Ufp_Mail_Attribute.getCopySysUser()
                  + ","
                  + b_T_Ufp_Mail_Attribute.getDarkSysUser();
        } else {
          allReceiverSysUser =
              b_T_Ufp_Mail_Attribute.getCopySysUser()
                  + ","
                  + b_T_Ufp_Mail_Attribute.getDarkSysUser();
        }
      }
    }

    try {
      // 更新附件表的主文档ID
      FileIdUpdata.Updata(newFileIds, uuid);
      criteria.andMainIdEqualTo(uuid);
      List<C_T_Sys_File> listFile = mapperFT.selectByExample(example);
      if (listFile != null) {
        if (listFile.size() > 0) {
          isFile = "1"; // 有附件
        } else {
          isFile = "0"; // 没有附件
        }
      } else {
        isFile = "0"; // 没有附件
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    b_T_Ufp_Mail_Attribute.setUuid(uuid);
    b_T_Ufp_Mail_Attribute.setSendTime(sendTime);
    b_T_Ufp_Mail_Attribute.setSendUser(sendUser);
    b_T_Ufp_Mail_Attribute.setSendSysUser(sendSysUser);
    b_T_Ufp_Mail_Attribute.setIsReceipt(Integer.valueOf(booleanToString(isReceipt))); // 回执
    // b_T_Ufp_Mail_Attribute.setIsSendMsg(Integer.valueOf(booleanToString(isSendMsg)));//是否发送短消息
    mapperMAT.insertSelective(b_T_Ufp_Mail_Attribute);
    // 向邮件联系表添加(发送箱里面的邮件特定收件人统一不设置)
    b_T_Ufp_Mail_Relation.setUuid(uuid);
    if (StringTools.isNullOrNoValue(isPaper)) {
      if ("false".equals(mailType)) {
        // 未勾选保存至发件箱复选框,则保存至垃圾箱
        b_T_Ufp_Mail_Relation.setMailType(Long.valueOf("3"));
        b_T_Ufp_Mail_Relation.setReplyFlag(3); // 垃圾箱标志:3
      } else {
        // 1:默认勾选保存至发件箱
        b_T_Ufp_Mail_Relation.setMailType(Long.valueOf(booleanToString(mailType)));
        b_T_Ufp_Mail_Relation.setReplyFlag(replyFlag); // 收邮件默认值:1
      }
    } else {
      mailType = "2";
      b_T_Ufp_Mail_Relation.setMailType(Long.valueOf(mailType)); // 存原稿保存至草稿箱
      b_T_Ufp_Mail_Relation.setReplyFlag(3); // 存草稿箱标志:3
    }
    b_T_Ufp_Mail_Relation.setIsNew(0); // 新邮件
    b_T_Ufp_Mail_Relation.setMailAttributeId(uuid);
    b_T_Ufp_Mail_Relation.setMailContentId(uuid);
    b_T_Ufp_Mail_Relation.setReceiverTime(sendTime); // 未收邮件日期为发件日期
    b_T_Ufp_Mail_Relation.setIsFile(Integer.valueOf(isFile)); // 有无附件标志
    mapperMRT.insertSelective(b_T_Ufp_Mail_Relation);
    // 向邮件正文表添加
    b_T_Ufp_Mail_Content.setUuid(uuid);
    mapperMCT.insertSelective(b_T_Ufp_Mail_Content);

    // 给所有收邮件人:收件人、抄送人和暗送人发邮件
    String isuserxt = "";
    if (StringTools.isNullOrNoValue(isPaper) || !"2".equals(isPaper)) {
      if (StringTools.isNotNullAndHasValue(allReceiverSysUser)) {
        String temps[] = allReceiverSysUser.split(",");
        String guid = null;
        for (String temp : temps) {
          if (isuserxt.indexOf(temp) < 0) {
            if (StringTools.isNotNullAndHasValue(temp.trim())) {
              guid = new GUID().toString();
              addForAllRecUser(guid);

              String darkSysUser = b_T_Ufp_Mail_Attribute.getDarkSysUser();
              // 循环变量值包含在暗送人中时,设置信息
              if (darkSysUser.indexOf(temp) > -1) {
                b_T_Ufp_Mail_Attribute.setTipDarkInfo("你是这封邮件的密送人,所以不会显示在收件人中。");
              }

              b_T_Ufp_Mail_Attribute.setUuid(guid);
              b_T_Ufp_Mail_Attribute.setSendTime(sendTime);
              b_T_Ufp_Mail_Attribute.setSendUser(sendUser);
              b_T_Ufp_Mail_Attribute.setSendSysUser(sendSysUser);
              b_T_Ufp_Mail_Attribute.setIsReceipt(
                  Integer.valueOf(booleanToString(isReceipt))); // 回执
              // b_T_Ufp_Mail_Attribute.setIsSendMsg(Integer.valueOf(booleanToString(isSendMsg)));//是否发送短消息
              mapperMAT.insertSelective(b_T_Ufp_Mail_Attribute);
              // 向邮件联系表添加
              b_T_Ufp_Mail_Relation.setUuid(guid);
              b_T_Ufp_Mail_Relation.setMailType(
                  Long.valueOf("7")); // 7:发邮件时,发送给所有收邮件人(allReceiverSysUser)的邮件标志
              b_T_Ufp_Mail_Relation.setIsNew(0); // 新邮件
              b_T_Ufp_Mail_Relation.setMailAttributeId(guid);
              b_T_Ufp_Mail_Relation.setMailContentId(guid);
              b_T_Ufp_Mail_Relation.setReceiverTime(sendTime); // 未收邮件日期为发件日期
              b_T_Ufp_Mail_Relation.setReplyFlag(replyFlag); // 收邮件默认值:1
              b_T_Ufp_Mail_Relation.setIsFile(Integer.valueOf(isFile)); // 有无附件标志
              b_T_Ufp_Mail_Relation.setSpecificRecsysUser(temp); // 设置指定收件人系统名
              mapperMRT.insertSelective(b_T_Ufp_Mail_Relation);
              // 向邮件正文表添加
              b_T_Ufp_Mail_Content.setUuid(guid);
              mapperMCT.insertSelective(b_T_Ufp_Mail_Content);
            }
            if (isuserxt.equals("")) {
              isuserxt += "," + temp + ",";
            } else {
              isuserxt += temp + ",";
            }
          }
        }
      }
    }
    returnMsg = Constants.SAVE_SUCCESSFUL_MSG;
    return returnMsg;
  }
Exemple #6
0
  /**
   * 回复,转发邮件
   *
   * @param sqlSession
   * @param mapper
   * @param mapperRelation
   * @param mapperContent
   * @param record
   * @param recordRelation
   * @param recordContent
   * @param sendTime
   * @param sendUser
   * @param sendSysUser
   * @return
   * @throws IllegalAccessException
   * @throws UnsupportedEncodingException
   */
  private String replyTrunMail(
      B_T_Ufp_Mail_Attribute record,
      B_T_Ufp_Mail_Relation recordRelation,
      B_T_Ufp_Mail_Content recordContent,
      String sendTime,
      String sendUser,
      String sendSysUser,
      C_T_Sys_FileExample example,
      C_T_Sys_FileExample.Criteria criteria)
      throws IllegalAccessException, UnsupportedEncodingException {
    String returnMsg;
    String uuid = new GUID().toString();
    // 更新附件表的主文档ID
    String isFile = null;
    try {
      replyMailFile(example, criteria, uuid);
      criteria.andMainIdEqualTo(uuid);
      List<C_T_Sys_File> listFile = mapperFT.selectByExample(example);
      if (listFile != null) {
        if (listFile.size() > 0) {
          isFile = "1"; // 有附件
        } else {
          isFile = "0"; // 没有附件
        }
      } else {
        isFile = "0"; // 没有附件
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    // 收件人未收邮件
    b_T_Ufp_Mail_Relation.setUuid(uuid);
    b_T_Ufp_Mail_Relation.setMailType(Long.valueOf(mailTypeS));
    b_T_Ufp_Mail_Relation.setMailAttributeId(uuid);
    b_T_Ufp_Mail_Relation.setMailContentId(uuid);
    b_T_Ufp_Mail_Relation.setReceiverTime(sendTime);
    b_T_Ufp_Mail_Relation.setReplyFlag(1); // 正常回复
    b_T_Ufp_Mail_Relation.setIsFile(Integer.valueOf(isFile)); // 有无附件
    if (b_T_Ufp_Mail_Relation != null) {
      b_T_Ufp_Mail_Relation.setSpecificRecsysUser(b_T_Ufp_Mail_Relation.getUserId());
    }

    mapperMRT.insertSelective(b_T_Ufp_Mail_Relation);
    // 插入邮件属性表
    b_T_Ufp_Mail_Attribute.setUuid(uuid);
    b_T_Ufp_Mail_Attribute.setSendTime(sendTime); // 回复时:发件箱中的发送时间
    b_T_Ufp_Mail_Attribute.setSendUser(sendUser);
    b_T_Ufp_Mail_Attribute.setSendSysUser(sendSysUser);
    b_T_Ufp_Mail_Attribute.setIsReceipt(Integer.valueOf(booleanToString(isReceipt))); // 回执选项
    mapperMAT.insertSelective(b_T_Ufp_Mail_Attribute);
    // 插入邮件正文表
    b_T_Ufp_Mail_Content.setUuid(uuid);
    mapperMCT.insertSelective(recordContent);

    // 发件箱显示
    String newUuid = new GUID().toString();
    String isNewFile = null;
    // 更新附件表的主文档ID
    try {
      replyMailFile(example, criteria, newUuid);

      example.clear();
      criteria = example.createCriteria();
      criteria.andMainIdEqualTo(newUuid);
      List<C_T_Sys_File> listFile = mapperFT.selectByExample(example);
      if (listFile != null) {
        if (listFile.size() > 0) {
          isNewFile = "1"; // 有附件
        } else {
          isNewFile = "0"; // 没有附件
        }
      } else {
        isNewFile = "0"; // 没有附件
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    b_T_Ufp_Mail_Relation.setUuid(newUuid);
    b_T_Ufp_Mail_Relation.setMailType(Long.valueOf("1"));
    b_T_Ufp_Mail_Relation.setMailAttributeId(uuid);
    b_T_Ufp_Mail_Relation.setMailContentId(uuid);
    b_T_Ufp_Mail_Relation.setReceiverTime(sendTime);
    b_T_Ufp_Mail_Relation.setReplyFlag(2); // 自己发的回复信息
    b_T_Ufp_Mail_Relation.setIsFile(Integer.valueOf(isNewFile)); // 有无附件
    mapperMRT.insertSelective(b_T_Ufp_Mail_Relation);
    // 插入邮件属性表
    b_T_Ufp_Mail_Attribute.setUuid(newUuid);
    b_T_Ufp_Mail_Attribute.setSendTime(sendTime); // 回复时:发件箱中的发送时间
    b_T_Ufp_Mail_Attribute.setSendUser(sendUser);
    b_T_Ufp_Mail_Attribute.setSendSysUser(sendSysUser);
    b_T_Ufp_Mail_Attribute.setIsReceipt(Integer.valueOf(booleanToString(isReceipt))); // 回执选项
    b_T_Ufp_Mail_Attribute.setIsSendMsg(Integer.valueOf(booleanToString(isSendMsg))); // 是否发送短消息
    mapperMAT.insertSelective(b_T_Ufp_Mail_Attribute);
    // 插入邮件正文表
    b_T_Ufp_Mail_Content.setUuid(newUuid);
    mapperMCT.insertSelective(b_T_Ufp_Mail_Content);

    if ("0".equals(isReplyTrun)) {
      returnMsg = "回复成功!";
    } else if ("1".equals(isReplyTrun)) {
      returnMsg = "转发成功!";
    } else {
      returnMsg = Constants.SAVE_SUCCESSFUL_MSG;
    }
    return returnMsg;
  }