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.

204 lines
7.0 KiB
Plaintext

<%@ page import="weaver.general.*" %>
<%@page import="weaver.conn.RecordSet"%>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ 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="java.util.*" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="weaver.formmode.setup.ModeRightInfo" %>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean" scope="page" />
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
User user = HrmUserVarify.getUser(request , response) ;
int userid = user.getUID();
String zftp = request.getParameter("zftp");
String sendUserId = request.getParameter("userid");
String rzzn = request.getParameter("rzzn");
String zfy = request.getParameter("zfy");
bb.writeLog("sendUserId:"+sendUserId);
bb.writeLog("rzzn:"+rzzn);
bb.writeLog("zfy:"+zfy);
int smstypeid = Util.getIntValue(request.getParameter("smstypeid"),563);
try{
String uuid = UUID.randomUUID().toString().replace("-","");
if(StringUtils.isNotBlank(sendUserId)){
int count = updateWishesInfo(uuid,userid+"",sendUserId,zfy,zftp);
bb.writeLog("count:"+count);
if(count > 0){
sendMessageBy(sendUserId,smstypeid,zfy,uuid);
}
}
}catch (Exception e){
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("result",true);
%>
<%=jsonObject.toString() %>
<%!
/***
*
* @param
* @param
* @return
*/
private void sendMessageBy(String sendUserId,int smstypeid,String zfy,String uuid) {
String linkUrl = "/spa/custom/static/index.html#/main/cs/app/d598bf2074434c67af3e008d4f9cfe20_anniversaryView?uuid="+uuid;
String linkMobileUrl = "/spa/custom/static/index.html#/main/cs/app/d598bf2074434c67af3e008d4f9cfe20_anniversaryView?uuid="+uuid;
String title = " ";
String content = zfy;
// DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// LocalDate currentDate = LocalDate.now();
// String today = currentDate.format(dateFormatter);
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 flag;
}
MessageType messageType = MessageType.newInstance(smstypeid); // 消息来源(见文档第四点补充 必填)
try {
MessageBean messageBean = Util_Message.createMessage(messageType, sendIdSet, title, context, linkPcUrl, linkMobileUrl);
messageBean.setCreater(1);// 创建人id
messageBean.setDetailTitle("");
flag = Util_Message.store(messageBean);
} catch (IOException e) {
flag = false;
e.printStackTrace();
bs.writeLog("send message error:",e);
}
return flag;
}
%>
<%!
/***
*
* @param uuid
*/
public int updateWishesInfo(String uuid,String fsr,String jsr,String zfy,String zftp){
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
int count = 0;
ModeRightInfo modeRightInfo = new ModeRightInfo();
bb.writeLog("uuid:"+uuid);
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss");
String currentdate = formatter1.format(new Date());
String currenttime = formatter2.format(new Date());
String modedatacreater = "1";
String modedatacreatertype = "0";
String fromtable = "uf_rzznzf" ;
String formmodeid = "" ;
String sql =" select k.id from modeinfo k \n" +
" inner join workflow_bill l on formid = l.id\n" +
" where l.tablename = '"+fromtable+"' " ;
rs.execute(sql);
if(rs.next()){
formmodeid = Util.null2String(rs.getString("id"));
}
bb.writeLog("formmodeid:"+formmodeid);
Map<String, String> datas = new HashMap<String, String>();
datas.put("formmodeid", formmodeid);
datas.put("modedatacreater", modedatacreater);
datas.put("modedatacreatertype", modedatacreatertype);
datas.put("modedatacreatedate", currentdate);
datas.put("modedatacreatetime", currenttime);
datas.put("uuid", uuid);
datas.put("fsr", fsr);
datas.put("fsrid", fsr);
datas.put("jsr", jsr);
datas.put("jsrid", jsr);
datas.put("zfy", zfy);
datas.put("zftp", zftp);
String tablenvalue = "";
String tablename = "";
for (Map.Entry<String, String> entry : datas.entrySet()) {
String fieldname = Util.null2String(entry.getKey()).trim();
String fieldvalue = Util.null2String(entry.getValue()).replace("'", "''").trim();
tablename += tablename == "" ? fieldname : "," + fieldname;
tablenvalue += tablenvalue == "" ? "'" + fieldvalue + "'" : ",'" + fieldvalue + "'";
}
if (tablename != "" && tablenvalue != "") {
sql = " insert into " + fromtable + "(" + tablename + ") values (" + tablenvalue + ")";
bb.writeLog("sql:" + sql);
boolean boo = rs.executeUpdate(sql);
if (boo) {
count++;
}
bb.writeLog("count:" + count);
if (count > 0) {
String dataid = "";
sql = " select id from " + fromtable + " where uuid='" + uuid + "'";
bb.writeLog("sql:" + sql);
rs.execute(sql);
if (rs.next()) {
dataid = Util.null2String(rs.getString("id"));
}
if (!"".equals(dataid)) {
modeRightInfo.editModeDataShare(Integer.valueOf(modedatacreater), Util.getIntValue(formmodeid), Integer.parseInt(dataid));
}
}
}
return count;
}
%>