You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
4.0 KiB
Plaintext
120 lines
4.0 KiB
Plaintext
<%@ page import="weaver.general.*" %>
|
|
<%@page import="weaver.conn.RecordSet"%>
|
|
<%@ page import="weaver.hrm.User" %>
|
|
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
|
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
|
<%@ page import="com.cloudstore.dev.api.bean.MessageBean" %>
|
|
<%@ page import="com.cloudstore.dev.api.bean.MessageType" %>
|
|
<%@ page import="com.cloudstore.dev.api.util.Util_Message" %>
|
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
|
<%@ page import="java.io.IOException" %>
|
|
<%@ page import="weaver.systeminfo.SystemEnv" %>
|
|
<%@ page import="java.time.format.DateTimeFormatter" %>
|
|
<%@ page import="java.time.LocalDate" %>
|
|
<%@ page import="java.util.*" %>
|
|
<jsp:useBean id="bb" class="weaver.general.BaseBean" scope="page" />
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
|
|
|
<%
|
|
RecordSet rs = new RecordSet();
|
|
User user = HrmUserVarify.getUser(request , response) ;
|
|
|
|
String sendUserId = request.getParameter("userid");
|
|
int smstypeid = MessageType.HR_BIRTHDAY_BLESSING.getCode();
|
|
try{
|
|
sendMessageBy(sendUserId,smstypeid,user);
|
|
}catch (Exception e){
|
|
|
|
}
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("result",true);
|
|
|
|
%>
|
|
<%=jsonObject.toString() %>
|
|
|
|
|
|
<%!
|
|
|
|
/***
|
|
*
|
|
* @param
|
|
* @param
|
|
* @return
|
|
*/
|
|
private void sendMessageBy(String sendUserId,int smstypeid,User user) {
|
|
|
|
RecordSet rs = new RecordSet();
|
|
String linkUrl = "/spa/hrm/static/index.html#/main/hrm/blessing/";
|
|
String linkMobileUrl = "/spa/hrm/static4mobile/index.html#/blessing/";
|
|
String imgUrl = "/hrm/hrm_e9/image/birth/6.png";
|
|
String title = user.getLastname() + " " + SystemEnv.getHtmlLabelName(521017, user.getLanguage());
|
|
String content = SystemEnv.getHtmlLabelName(521016, user.getLanguage());
|
|
|
|
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
LocalDate currentDate = LocalDate.now();
|
|
String today = currentDate.format(dateFormatter);
|
|
|
|
String recordId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
String sql = "insert into hrm_blessing (id, imgUrl, blessing, creator, createDate) values(?, ?, ?, ?, ?)";
|
|
rs.executeUpdate(sql, recordId, imgUrl, content, user.getUID(), today);
|
|
|
|
linkUrl += recordId;
|
|
linkMobileUrl += recordId;
|
|
|
|
Set<String> userSet = new HashSet<String>();
|
|
userSet.add(sendUserId);
|
|
sendMessage(smstypeid,userSet,title,content,linkUrl,linkMobileUrl);
|
|
|
|
}
|
|
|
|
|
|
/***
|
|
*
|
|
* @param smstypeid
|
|
* @param sendIdSet
|
|
* @param title
|
|
* @param context
|
|
* @param linkPcUrl
|
|
* @param linkMobileUrl
|
|
* @return
|
|
*/
|
|
public boolean sendMessage(int smstypeid, Set<String> sendIdSet, String title, String context, String linkPcUrl, String linkMobileUrl)
|
|
{
|
|
BaseBean bs = new BaseBean();
|
|
RecordSet rs = new RecordSet();
|
|
boolean flag = false;
|
|
String sumcount="";
|
|
String sql=" select count(*) as sumcount from ecology_message_type where id='"+smstypeid+"'";
|
|
rs.execute(sql);
|
|
if(rs.next()){
|
|
sumcount=Util.null2String(rs.getString("sumcount"));
|
|
}
|
|
if("0".equals(sumcount)){
|
|
return false;
|
|
}
|
|
|
|
MessageType messageType = MessageType.newInstance(smstypeid); // 消息来源(见文档第四点补充 必填)
|
|
try {
|
|
MessageBean messageBean = Util_Message.createMessage(messageType, sendIdSet, title, context, linkPcUrl, linkMobileUrl);
|
|
messageBean.setCreater(1);// 创建人id
|
|
messageBean.setDetailTitle(title);
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
map.put("maintitle",title);
|
|
messageBean.setDetailTitleParams(map);
|
|
messageBean.setEnablePC("y");
|
|
messageBean.setEnableEM("y");
|
|
flag = Util_Message.store(messageBean);
|
|
|
|
} catch (IOException e) {
|
|
flag = false;
|
|
e.printStackTrace();
|
|
bs.writeLog("send message error:",e);
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
%>
|
|
|
|
|
|
|