81 lines
3.9 KiB
Java
81 lines
3.9 KiB
Java
package com.engine.kq.util.lingyuewuye;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.engine.kq.biz.KQBalanceOfLeaveBiz;
|
||
import weaver.conn.RecordSet;
|
||
import weaver.file.Prop;
|
||
import weaver.general.BaseBean;
|
||
import weaver.general.TimeUtil;
|
||
import weaver.general.Util;
|
||
|
||
import java.time.LocalDate;
|
||
import java.time.format.DateTimeFormatter;
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
|
||
public class NianJiaUtil {
|
||
|
||
public void saveExpirationDate(String ruleId,String belongyear,int organizationType,String organizationIds){
|
||
String nianjiaId = Prop.getInstance().getPropValue("lingyue_nianjia","nianjiaid");
|
||
BaseBean bb = new BaseBean();
|
||
bb.writeLog("qc3222529 nianjiaid = "+nianjiaId +";ruleId = "+ruleId);
|
||
if (!ruleId.equals(nianjiaId)){//如果传进来的假期id不是年假id,不执行下面的代码
|
||
return;
|
||
}
|
||
String searchSql = "select id from hrmresource where (status in (0,1,2,3)) ";
|
||
if (organizationType == 1) {
|
||
searchSql += " and subCompanyId1 in (" + organizationIds + ") ";
|
||
} else if (organizationType == 2) {
|
||
searchSql += " and departmentId in (" + organizationIds + ") ";
|
||
} else if (organizationType == 3) {
|
||
searchSql += " and id in (" + organizationIds + ") ";
|
||
}
|
||
RecordSet searchRS = new RecordSet();
|
||
searchRS.executeQuery(searchSql);
|
||
List<List> sqlList = new ArrayList<>();
|
||
// String resourceid = "";
|
||
while (searchRS.next()){//因为同一个假期规则,它生成的失效日期是一样的,所以,取其中一个人的id出来,用于获取失效日期
|
||
String resourceid = Util.null2String(searchRS.getString("id"));
|
||
String expirationDate = KQBalanceOfLeaveBiz.getExpirationDate(ruleId,resourceid,belongyear,"","");
|
||
bb.writeLog("qc3222529 resourceid is not null ===="+resourceid+";expirationDate="+expirationDate+";ruleid="+ruleId+";belongyear="+belongyear);
|
||
List<String> list = new ArrayList<>();
|
||
list.add(expirationDate);
|
||
list.add(resourceid);
|
||
sqlList.add(list);
|
||
// resourceid = Util.null2String(searchRS.getString("id"));
|
||
// break;
|
||
}
|
||
bb.writeLog("qc3222529 sqlList:"+ JSON.toJSONString(sqlList));
|
||
// if (!resourceid.equals("")){
|
||
if (sqlList != null && sqlList.size() > 0){
|
||
// bb.writeLog("qc3222529 resourceid is not null ===="+resourceid);
|
||
|
||
// String expirationDate = KQBalanceOfLeaveBiz.getExpirationDate(ruleId,resourceid,belongyear,"","");
|
||
String sql = "update kq_BalanceOfLeave set expirationDate=? where leaveRulesId ="+ ruleId +"and belongYear ='"+belongyear+"' and resourceId = ? and (ycts is null or ycts = 0)";
|
||
RecordSet rs = new RecordSet();
|
||
boolean flag = rs.executeBatchSql(sql, sqlList);
|
||
|
||
// boolean flag = rs.executeUpdate(sql, expirationDate, ruleId,belongyear);
|
||
if (!flag){
|
||
bb.writeLog("qc3222529 修改年假失效日期出错!");
|
||
}
|
||
}
|
||
|
||
}
|
||
public static String getNianJiaExpriationDate(String ruleid,String resourceid,String belongYear){
|
||
String sql = "select * from kq_BalanceOfLeave where leaveRulesId = ? and resourceId = ? and belongYear = ?";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery(sql,ruleid,resourceid,belongYear);
|
||
String expirationDate = "";
|
||
while (rs.next()){
|
||
expirationDate = Util.null2String(rs.getString("expirationDate"));
|
||
// int ycts = Util.getIntValue(rs.getString("ycts"),0);
|
||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
// // 解析输入的日期
|
||
// LocalDate date = LocalDate.parse(expirationDate, formatter);
|
||
// expirationDate = date.plusDays(ycts).toString();
|
||
}
|
||
return expirationDate;
|
||
}
|
||
}
|