Exemple #1
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 #2
0
  /** 电子邮件详细信息新建或修改 */
  public String detailsUpdate() throws Exception {
    // 取得数据连接
    B_T_Ufp_Mail_Attribute record = null;
    B_T_Ufp_Mail_Relation recordRelation = null;
    B_T_Ufp_Mail_Content recordContent = null;
    C_T_Sys_FileExample example = null;
    C_T_Sys_FileExample.Criteria criteria = null;
    try {
      example = new C_T_Sys_FileExample();
      criteria = example.createCriteria();
      // 创建需要更新的记录集合
      record = new B_T_Ufp_Mail_Attribute();
      recordRelation = new B_T_Ufp_Mail_Relation();
      recordContent = new B_T_Ufp_Mail_Content();
      String returnMsg = null;
      String sendTime = DateTools.getServerDateTime(10);
      String sendUser = SessionFactory.getSessionUserNm();
      String sendSysUser = SessionFactory.getSessionUserId();

      if (StringTools.isNullOrNoValue(isTranferCopy)) {
        if (StringTools.isNullOrNoValue(mainDocId)) {
          returnMsg =
              saveMail(
                  record,
                  recordRelation,
                  recordContent,
                  sendTime,
                  sendUser,
                  sendSysUser,
                  1,
                  example,
                  criteria);
        } else {
          if (isPaper != null && ("2".equals(isPaper) || "".equals(isPaper))) {
            DbOperationFation.deleteByExample("B_T_Ufp_Mail_Attribute", mainDocId, moduleId);
            DbOperationFation.deleteByExample("B_T_Ufp_Mail_Relation", mainDocId, moduleId);
            DbOperationFation.deleteByExample("B_T_Ufp_Mail_Content", mainDocId, moduleId);
            returnMsg =
                saveMail(
                    record,
                    recordRelation,
                    recordContent,
                    sendTime,
                    sendUser,
                    sendSysUser,
                    1,
                    example,
                    criteria);
          } else {
            returnMsg =
                replyTrunMail(
                    record,
                    recordRelation,
                    recordContent,
                    sendTime,
                    sendUser,
                    sendSysUser,
                    example,
                    criteria);
          }
        }
      } else {
        // 转移拷贝(isTranferCopy)信件设置
        if (!"".equals(checkedIds)) {
          String temps[] = checkedIds.split(",");
          for (String temp : temps) {
            b_T_Ufp_Mail_Relation = mapperMRT.selectByPrimaryKey(temp.trim());
            if ("1".equals(isTranferCopy)) {
              // 转移至
              tranferMail(recordRelation);
            } else if ("2".equals(isTranferCopy)) {
              // 拷贝至
              copyMail(record, recordRelation, recordContent, temp.trim(), example, criteria);
            }
          }
        }
      }
      sucessMessage(returnMsg);
    } catch (Exception e) {
      throw e;
    } finally {
      // 释放资源
      example = null;
      criteria = null;
    }
    return SUCCESS;
  }