b19a9a99bc357ea5ddb62ad45198e0d44fe1b238.svn-base 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package com.kingdee.eas.custom.facade.housrapproval;
  2. import java.util.HashSet;
  3. import java.util.Set;
  4. import org.apache.log4j.Logger;
  5. import com.kingdee.bos.BOSException;
  6. import com.kingdee.bos.Context;
  7. import com.kingdee.eas.base.param.IParamControl;
  8. import com.kingdee.eas.base.param.ParamControlFactory;
  9. import com.kingdee.eas.common.EASBizException;
  10. import com.kingdee.eas.custom.utils.SendUtils;
  11. import com.kingdee.eas.mobile.BOSMsgTypeEnum;
  12. import com.kingdee.eas.mobile.MimeTypeEnum;
  13. import com.kingdee.eas.mobile.PriorityEnum;
  14. import com.kingdee.eas.util.app.DbUtil;
  15. import com.kingdee.jdbc.rowset.IRowSet;
  16. // 工时提报审批预警
  17. public class HourapprovalFacadeControllerBean extends AbstractHourapprovalFacadeControllerBean {
  18. private static Logger logger = Logger
  19. .getLogger("com.kingdee.eas.custom.facade.housrapproval.HourapprovalFacadeControllerBean");
  20. @Override
  21. public void __hourApproval(Context ctx) {
  22. // LocalDate today = LocalDate.now(); // 获取当前日期
  23. String sql = "select s.FPERSONUSERID,p.fname_l1 as shenpiName,p.fid,t.fname_l1 as person from T_BAS_AssignRead r left join T_WFR_Assign s on \r\n" +
  24. " r.FASSIGNID = s.FASSIGNID left join T_PM_User c on c.fid=s.FPERSONUSERID left join T_BD_Person p on c.FPersonId =p.fid\r\n" +
  25. "left join (SELECT a.fid,c.fname_l1,c.fid as psid FROM T_HR_SBatchSubmitShemeBill a left join T_HR_SchemeBillEntry b on a.fid=b.fbillid left join T_BD_Person c on b.fpersonid= c.fid )t on t.fid=s.FBIZOBJID \r\n" +
  26. "where r.FBOSTYPE = 'B11DBA5C' and s.FBIZOBJID \r\n" +
  27. "in(select fid from T_HR_SBatchSubmitShemeBill FBillState where FBillState='1')";
  28. logger.error("工时提报单审批人SQL:" + sql);
  29. System.out.println("工时单审批的sql"+sql);
  30. try {
  31. // 获取链接
  32. IParamControl ipc = ParamControlFactory.getLocalInstance(ctx);
  33. String shrEnvironmentIP = ipc.getParamValue(null, "shrEnvironmentIP");
  34. String website= shrEnvironmentIP+"/home.do";
  35. IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
  36. // 为了防止重复发送需要去重
  37. Set<String>personSet=new HashSet<>();
  38. while(rowSet.next()) {
  39. personSet.add(rowSet.getString("fid")+rowSet.getString("person"));
  40. }
  41. System.out.print("personSet的size是"+personSet.size());
  42. rowSet.beforeFirst();
  43. while (rowSet.next()) {
  44. if(personSet.contains(rowSet.getString("fid")+rowSet.getString("person"))) {
  45. StringBuffer strBuffer = new StringBuffer();
  46. //String title = "Workflow "+rowSet.getString("person")+"Work hour submission approval form awaiting your approval";// 标题
  47. String title="Reminder to working hours approval";
  48. // 拼接内容
  49. strBuffer.append("<html><head></head><body>");
  50. strBuffer.append("<span>Dear "+rowSet.getString("shenpiName")+","+"</span><br>");
  51. strBuffer.append("<span></span><br>");
  52. strBuffer.append("<span>"+"AS "+rowSet.getString("person")+" has submitted the working hours for your approval, could you please login to the system by using below link at your earliest convenience?"+"</span><br>");
  53. strBuffer.append("<span></span><br>");
  54. strBuffer.append("<span>");
  55. strBuffer.append(website);
  56. // strBuffer.append("<a href=\"https://gtiit.kdeascloud.com/shr/home.do\">https://gtiit.kdeascloud.com/shr/home.do</a>");
  57. strBuffer.append("</span><br>");
  58. strBuffer.append("<span></span><br>");
  59. strBuffer.append("<span>Please kindly check To-Be-Processed in My Tasks and approve/reject by 8th of this month or the DDL required by HR. Late submission will not be accepted. Feel free to let us know if any problem. Many thanks!</span><br>");
  60. strBuffer.append("<span></span><br>");
  61. strBuffer.append("<span>Best regards,</span><br>");
  62. strBuffer.append("<span>Human Resources Department</span><br>");
  63. strBuffer.append("</body></html>");
  64. String content = strBuffer.toString();
  65. System.out.println("输出是"+strBuffer.toString());
  66. // MsgUtil.msgSend(ctx, title, PriorityEnum.HIGHT_VALUE, false, content, rowSet.getString("fid"),
  67. // BOSMsgTypeEnum.V_TYPE_EMAIL, null, null, null);
  68. SendUtils.msgSend(ctx, title, PriorityEnum.HIGHT_VALUE, false, content, rowSet.getString("fid"),
  69. BOSMsgTypeEnum.V_TYPE_EMAIL, null, null, MimeTypeEnum.HTML);
  70. personSet.remove(rowSet.getString("fid")+rowSet.getString("person"));
  71. System.out.println("发送成功");
  72. }
  73. }
  74. } catch (EASBizException e) {
  75. // TODO 自动生成的 catch 块
  76. e.printStackTrace();
  77. } catch (BOSException e) {
  78. // TODO 自动生成的 catch 块
  79. e.printStackTrace();
  80. } catch (Exception e) {
  81. logger.error("工时提报提醒通知失败:" + e.getMessage());
  82. }
  83. }
  84. public static String emailTable() {
  85. StringBuilder content = new StringBuilder("<html><head></head><body>");
  86. content.append("<a href=\"https://gtiit.kdeascloud.com/shr\">https://gtiit.kdeascloud.com/shr</a>");
  87. content.append("</body></html>");
  88. return content.toString();
  89. }
  90. }