|
|
<%@ 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" %>
|
|
|
<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" %>
|
|
|
|
|
|
<%
|
|
|
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<Map<String,String>> dataList = new ArrayList<Map<String,String>>();
|
|
|
Map<String,String> dataMap = null;
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd" ) ;
|
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ;
|
|
|
|
|
|
try{
|
|
|
|
|
|
for(int i=0;i<days;i++)
|
|
|
{
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.add(Calendar.DAY_OF_YEAR, 0-i);
|
|
|
String currentDay = sdf.format(calendar.getTime()) ;
|
|
|
bb.writeLog("currentDay:"+currentDay);
|
|
|
|
|
|
String currentYear = sdf2.format(calendar.getTime()) ;
|
|
|
bb.writeLog("currentYear:"+currentYear);
|
|
|
|
|
|
String sql =" select k.* from (" +
|
|
|
" select h.id,h.lastname,h.sex,h.companystartdate,h.departmentid,h.subcompanyid1,d.departmentname,s.subcompanyname," +
|
|
|
" (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as rzzn," +
|
|
|
" right(companystartdate,5) startday " +
|
|
|
" from hrmresource h " +
|
|
|
" inner join HrmDepartment d on d.id = h.departmentid " +
|
|
|
" inner join HrmSubCompany s on s.id = h.subcompanyid1 " +
|
|
|
" where right(companystartdate,5) = '"+currentDay+"' " +
|
|
|
" and h.status in(0,1,2,3) " +
|
|
|
" and (h.belongto is null or h.belongto = -1 ) " +
|
|
|
" and h.companystartdate is not null " +
|
|
|
" ) k where k.rzzn > 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<String, String>();
|
|
|
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<dataList.size();i++){
|
|
|
Map<String,String> 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' |