<%@ page import="weaver.general.*" %> <%@page import="weaver.conn.RecordSet"%> <%@ page import="com.alibaba.fastjson.JSONObject" %> <%@ page import="java.util.*" %> <%@ page import="java.text.SimpleDateFormat" %> <%@ page import="weaver.formmode.setup.ModeRightInfo" %> <%@ page import="org.apache.commons.lang3.StringUtils" %> <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% JSONObject jsonObject = new JSONObject(); updateAnniversaryWishes(); jsonObject.put("result",true); %> <%=jsonObject.toJSONString() %> <%! public void updateAnniversaryWishes(){ BaseBean log = new BaseBean(); log.writeLog("updateAnniversaryWishes! "); String uftable = "uf_rzznzfgly"; RecordSet rs = new RecordSet(); int days = 30 ; List> dataList = new ArrayList>(); Map dataMap = null; BaseBean bb = new BaseBean(); SimpleDateFormat sdf = new SimpleDateFormat("MM-dd" ) ; SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ; try{ for(int i=0;i 0 " + " order by k.startday desc " ; bb.writeLog("updateAnniversaryWishes-sql:"+sql); rs.executeQuery(sql); while (rs.next()){ String userid = Util.null2String(rs.getString("id")); String lastname = Util.null2String(rs.getString("lastname")); int rzzn = Util.getIntValue(Util.null2String(rs.getString("rzzn")),0); String rzyr = Util.null2String(rs.getString("startday")); String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); String departmentid = Util.null2String(rs.getString("departmentid")); String companystartdate = Util.null2String(rs.getString("companystartdate")); String zfy = getZfy(lastname,rzzn); dataMap = new HashMap(); dataMap.put("ry",userid); dataMap.put("xm",lastname); dataMap.put("zfy",zfy); dataMap.put("bm",departmentid); dataMap.put("rzrq",companystartdate); dataMap.put("fb",subcompanyid1); dataMap.put("nf",currentYear); dataMap.put("rzzn",rzzn+""); dataMap.put("rzyr",rzyr); dataList.add(dataMap); } } for(int i=0;i dMap = dataList.get(i); String ry = dMap.get("ry"); String nf = dMap.get("nf"); String rzyr = dMap.get("rzyr"); String ufid = "" ; String sql = " select id from "+uftable+" where ry='"+ry+"' and nf = '"+nf+"'"; rs.executeQuery(sql); if(rs.next()){ ufid = Util.null2String(rs.getString("id")); } if(StringUtils.isBlank(ufid)){ updateWishesInfo(uftable,dMap); }else{ String zfy = dMap.get("zfy"); String rzrq = dMap.get("rzrq"); sql = " update "+uftable+" set zfy='"+zfy+"',rzrq='"+rzrq+"',rzyr='"+rzyr+"' where id = "+ ufid ; boolean isTrue = rs.executeUpdate(sql); bb.writeLog("isTrue:"+isTrue); } } // select right(companystartdate,5) from hrmresource where companystartdate is not null // and right(companystartdate,5) >'12-01' and right(companystartdate,5) <'12-30' }catch (Exception e){ } } public int updateWishesInfo(String fromtable,Map datas){ RecordSet rs = new RecordSet(); BaseBean bb = new BaseBean(); int count = 0; ModeRightInfo modeRightInfo = new ModeRightInfo(); String uuid = UUID.randomUUID().toString().replace("-",""); 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 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); datas.put("formmodeid", formmodeid); datas.put("modedatacreater", modedatacreater); datas.put("modedatacreatertype", modedatacreatertype); datas.put("modedatacreatedate", currentdate); datas.put("modedatacreatetime", currenttime); datas.put("uuid", uuid); String tablenvalue = ""; String tablename = ""; for (Map.Entry 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; } public static String convert(int number) { if (number <= 0) { return ""; } //数字对应的汉字 String[] num = {"一", "二", "三", "四", "五", "六", "七", "八", "九"}; //单位 String[] unit = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千", "万亿"}; //将输入数字转换为字符串 String result = String.valueOf(number); //将该字符串分割为数组存放 char[] ch = result.toCharArray(); //结果 字符串 String str = ""; int length = ch.length; for (int i = 0; i < length; i++) { int c = (int) ch[i] - 48; if (c != 0) { str += num[c - 1] + unit[length - i - 1]; } } if (number < 20 && number > 9) { str = str.substring(1); } // System.out.println(str); return str ; } public String getZfy(String lastname,int rzzn){ String rzzzdx = "" ; if(rzzn > 0){ rzzzdx = convert(rzzn); } String zfy ="
\n" + "

亲爱的"+lastname+"

\n" + "

 

\n" + "

衷心祝贺您与铭沣同行"+rzzzdx+"周年快乐!

\n" + "

感谢您将自己的青春年华和工作热情奉献给了铭沣!

\n" + "

感谢您辛勤的付出与不懈的跟随与守候,期待我们一起度过下一个周年!

\n" + "

今天的您是否忙碌在工作岗位上而忽略了这个重要的日子......

\n" + "

但公司记得您每一份付出和努力!

\n" + "

感谢您的一路相伴,未来我们继续同行!

\n" + "

 

\n" + "

 

\n" + "

 MATFRON

\n" + "
"; return zfy; } %>