package com.kingdee.eas.custom.facade.worktime; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import org.apache.log4j.Logger; import javax.ejb.*; import java.nio.charset.StandardCharsets; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.rmi.RemoteException; import java.sql.SQLException; import java.util.HashSet; import java.util.Set; import com.kingdee.bos.*; import com.kingdee.bos.util.BOSObjectType; import com.kingdee.eas.base.param.IParamControl; import com.kingdee.eas.base.param.ParamControlFactory; import com.kingdee.eas.common.EASBizException; import com.kingdee.eas.custom.utils.SendUtils; import com.kingdee.eas.mobile.BOSMsgTypeEnum; import com.kingdee.eas.mobile.MimeTypeEnum; import com.kingdee.eas.mobile.PriorityEnum; import com.kingdee.eas.mobile.msg.util.MsgUtil; import com.kingdee.eas.util.app.DbUtil; import com.kingdee.jdbc.rowset.IRowSet; import com.kingdee.shr.base.syssetting.context.SHRContext; import com.kingdee.bos.metadata.IMetaDataPK; import com.kingdee.bos.metadata.rule.RuleExecutor; import com.kingdee.bos.metadata.MetaDataPK; //import com.kingdee.bos.metadata.entity.EntityViewInfo; import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean; import com.kingdee.bos.message.common.KDMemAttachment; import com.kingdee.bos.message.common.KDMessageAttachment; import com.kingdee.bos.framework.ejb.AbstractBizControllerBean; //import com.kingdee.bos.dao.IObjectPK; import com.kingdee.bos.dao.IObjectValue; import com.kingdee.bos.dao.IObjectCollection; import com.kingdee.bos.service.ServiceContext; import com.kingdee.bos.service.IServiceContext; import java.util.Base64; /** * 除转正、加班、提报单以外,其他单据到审批人节点时间(按天)算起,超过两天未审批则提醒当前审批人 * * @author ISSUSER * */ public class RemindFacadeControllerBean extends AbstractRemindFacadeControllerBean { private static Logger logger = Logger .getLogger("com.kingdee.eas.custom.facade.worktime.RemindFacadeControllerBean"); @Override public void _remindWraning(Context ctx) throws BOSException { Set appovedSet = new HashSet(); try { IRowSet appovedRowSet = getAppoved(ctx); // 获取链接 IParamControl ipc = ParamControlFactory.getLocalInstance(ctx); String shrEnvironmentIP = ipc.getParamValue(null, "shrEnvironmentIP"); String website = shrEnvironmentIP + "/home.do"; while (appovedRowSet.next()) { // 获取审批人 String personempId = appovedRowSet.getString("FPERSONEMPID"); String title = "Reminder: Pending approval workflow"; // if (!appovedSet.contains(personempId)) { // 拼接内容 StringBuffer conteBuffer = new StringBuffer(); conteBuffer.append(""); conteBuffer.append("Dear " + appovedRowSet.getString("FPERSONEMPNAME_L1") + ":
"); conteBuffer.append("
"); conteBuffer.append( "A kind reminder to tasks pending your approval. Please log in to the system to view details in To-Be-Processed in My Tasks and act on pending approval tasks at your earliest convenience.
"); conteBuffer.append("
"); conteBuffer.append("" + website + "
"); conteBuffer.append("
"); conteBuffer .append("This is an automatic workflow email. Do not reply to this mail.
"); conteBuffer.append("
"); conteBuffer.append("Best regards,
"); conteBuffer.append("Human Resources Department"); conteBuffer.append(""); // SendUtils.msgSend(ctx, title, PriorityEnum.HIGHT_VALUE, false, conteBuffer.toString(), appovedRowSet.getString("FPERSONEMPID"), BOSMsgTypeEnum.V_TYPE_EMAIL, null, null, MimeTypeEnum.HTML); // SendUtils.msgSend(ctx, title, PriorityEnum.HIGHT_VALUE, false, conteBuffer.toString(), // "1CV1Xix+Qua9UEeo/uZ6TIDvfe0=", BOSMsgTypeEnum.V_TYPE_EMAIL, null, null, // MimeTypeEnum.HTML); appovedSet.add(personempId); } } } catch (SQLException e) { e.printStackTrace(); } catch (EASBizException e) { e.printStackTrace(); } } /*** * 查询除转正、加班、提报单以外,其他单据到审批人节点时间(按天)算起,超过两天未审批 的审批人 * @param ctx * @return */ public IRowSet getAppoved(Context ctx) { String sql = "SELECT a.* FROM T_WFR_Assign a left join T_BAS_AssignRead b on a.FASSIGNID=b.FASSIGNID where b.FBosType not in('C46A580E','B11DBA5C','B65CCEF1') and DATEDIFF(day,a.flaststatetime, GETDATE()) > 2 ;"; IRowSet rs = null; try { rs = DbUtil.executeQuery(ctx, sql); } catch (BOSException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return rs; } // // 拼接的内容 // public KDMemAttachment[] getContent() { // String imageFilePath = "http://119.3.222.91:6888/shr/leaveTemplate/Image_20240118150510.png"; // KDMemAttachment[] kdments=new KDMemAttachment[1]; // // 读取图片文件 // try { // // 读取本地图片文件 // File imageFile = new File("D:/rz/cs.png"); // byte[] imageData = new byte[(int) imageFile.length()]; // FileInputStream fis = new FileInputStream(imageFile); // BufferedInputStream bis = new BufferedInputStream(fis); // bis.read(imageData, 0, imageData.length); // bis.close(); // fis.close();; // // KDMemAttachment attachment = new KDMemAttachment(); // attachment.setName("example_image"); // 设置附件名称 // attachment.setSize(imageData.length); // 设置附件大小 // attachment.setData(imageData); // 设置附件数据 // // kdments[0] = attachment; // // } catch (IOException e) { // // TODO 自动生成的 catch 块 // e.printStackTrace(); // } // // return kdments; // // } }