weaver-hrm-recruit/src/weaver/formmode/recruit/modeexpand/offer/CreateOfferModeExpand.java

130 lines
5.2 KiB
Java
Raw Normal View History

2023-10-23 15:31:54 +08:00
package weaver.formmode.recruit.modeexpand.offer;
2023-10-27 18:01:07 +08:00
import com.engine.recruit.exception.CustomizeRunTimeException;
2023-10-23 15:31:54 +08:00
import com.engine.recruit.util.RecruitMessageUtils;
2023-10-27 18:01:07 +08:00
import org.apache.commons.lang3.StringUtils;
2023-10-23 15:31:54 +08:00
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.Util;
import weaver.hrm.User;
2023-10-27 18:01:07 +08:00
import weaver.hrm.company.SubCompanyComInfo;
2023-10-23 15:31:54 +08:00
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import java.util.Map;
public class CreateOfferModeExpand extends AbstractModeExpandJavaCodeNew {
/**
* 消息来源ID
*/
private String messageType;
/**
* 消息提醒标题
*/
private String title;
private final RecordSet recordSet = new RecordSet();
@Override
public Map<String, String> doModeExpand(Map<String, Object> params) {
Map<String, String> result = new HashMap<>();
try {
//数据id
int billId;
//模块id
int modeId;
RequestInfo requestInfo = (RequestInfo) params.get("RequestInfo");
User user = (User) params.get("user");
if (requestInfo != null) {
billId = Util.getIntValue(requestInfo.getRequestid());
modeId = Util.getIntValue(requestInfo.getWorkflowid());
if (billId > 0 && modeId > 0) {
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] properties = mainTableInfo.getProperty();
Map<String, Object> mainDataMap = new HashMap<>(16);
for (Property property : properties) {
mainDataMap.put(property.getName(), property.getValue());
}
// 发送信息
sendMessage(billId);
2023-10-27 18:01:07 +08:00
// 更新状态为已发送
recordSet.executeUpdate("update uf_jcl_offer set zt = 1 where id = ? ", billId);
2023-10-23 15:31:54 +08:00
}
}
} catch (Exception e) {
result.put("errmsg", "自定义出错信息");
result.put("flag", "false");
}
return result;
}
private void sendMessage(int billId) {
String querySql = "select sjhm,dzyx,yjtzmb,tznr,tzypz from uf_jcl_offer where id = ?";
2023-10-27 18:01:07 +08:00
recordSet.executeQuery(querySql, billId);
2023-10-23 15:31:54 +08:00
String sjhm = "";
String dzyx = "";
String yjtzmb = "";
String tznr = "";
String tzypz = "";
while (recordSet.next()) {
sjhm = Util.null2String(recordSet.getString("sjhm"));
dzyx = Util.null2String(recordSet.getString("dzyx"));
yjtzmb = Util.null2String(recordSet.getString("yjtzmb"));
tznr = Util.null2String(recordSet.getString("tznr"));
tzypz = Util.null2String(recordSet.getString("tzypz"));
}
2023-10-27 18:01:07 +08:00
Map<String, Object> params = new HashMap<>();
2023-10-23 15:31:54 +08:00
String[] ways = tzypz.split(",");
for (String way : ways) {
switch (way) {
case "0":
// 邮件
params.put("sendTo", dzyx);
params.put("emailTitle", getEmailTitle(yjtzmb));
params.put("emailContent", tznr);
RecruitMessageUtils.SendEmail(params);
break;
case "1":
// 短信
2023-10-27 18:01:07 +08:00
recordSet.executeQuery("select b.xm , c.zpzwmc , a.sxrq , a.rzgs from uf_jcl_offer a inner join uf_jcl_yppc b on a.xm = b.id inner join uf_jcl_zp_zpzw c on a.ypzw = c.id where a.id = ?", billId);
if (recordSet.next()) {
String name = recordSet.getString("xm");
String positionName = recordSet.getString("zpzwmc");
String endDate = recordSet.getString("sxrq");
String companyId = recordSet.getString("rzgs");
if (StringUtils.isAnyBlank(name, positionName, endDate, companyId)) {
throw new CustomizeRunTimeException("offer短信发送失败应聘者信息获取失败");
}
String msgContent = name + "你好,恭喜你成功通过" + new SubCompanyComInfo().getSubCompanyname(companyId) + "" + positionName + "面试,聘用通知已发送至你的邮箱,请注意查收邮件,并于" + endDate + "前确认,逾期将失效。";
params.put("receiver", sjhm);
params.put("content", msgContent);
RecruitMessageUtils.sendSMS(params);
}
2023-10-23 15:31:54 +08:00
break;
default:
break;
}
}
}
/**
* 获取邮件模板主题
2023-10-27 18:01:07 +08:00
*
2023-10-23 15:31:54 +08:00
* @param id
*/
2023-10-27 18:01:07 +08:00
private String getEmailTitle(String id) {
2023-10-23 15:31:54 +08:00
String emailTitle = "";
recordSet.executeQuery("select yjzt from uf_jcl_yjtzmb where id = ?", id);
if (recordSet.next()) {
emailTitle = recordSet.getString("yjzt");
}
return emailTitle;
}
}