|
|
package com.engine.sskj.util;
|
|
|
|
|
|
import com.engine.kq.biz.KQOvertimeRulesBiz;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import weaver.conn.RecordSet;
|
|
|
import weaver.formmode.setup.ModeRightInfo;
|
|
|
import weaver.general.BaseBean;
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
import javax.xml.transform.Result;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author chenwnj
|
|
|
* @date 2023/10/20
|
|
|
* @description
|
|
|
**/
|
|
|
public class SskjUtil {
|
|
|
|
|
|
BaseBean basebean = new BaseBean();
|
|
|
|
|
|
final String THISMONTH = "uf_jbtxdyfjs";
|
|
|
final String OTHERMONTH = "uf_jbtxgyfff";
|
|
|
|
|
|
/**
|
|
|
* 建模权限重构
|
|
|
* @param userId
|
|
|
* @param jobGroupDesModeId
|
|
|
* @param billid
|
|
|
*/
|
|
|
public void modePerRecon(Integer userId, String jobGroupDesModeId, String billid) {
|
|
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
|
|
ModeRightInfo.setNewRight(true);
|
|
|
ModeRightInfo.editModeDataShare( userId, Integer.parseInt(jobGroupDesModeId), Integer.parseInt(billid));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取两个时间相差分钟数
|
|
|
*/
|
|
|
public long getTime(String oldTime,String newTime) {
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
long diff = 0;
|
|
|
try {
|
|
|
long NTime =df.parse(newTime).getTime();
|
|
|
//从对象中拿到时间
|
|
|
long OTime = df.parse(oldTime).getTime();
|
|
|
diff=(NTime-OTime)/1000/60;
|
|
|
}catch (Exception e) {
|
|
|
basebean.writeLog("SskjUtil getTime Exception: " + e);
|
|
|
}
|
|
|
|
|
|
return diff;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断培训时长扣减去哪张表中查找
|
|
|
*/
|
|
|
public String getTableName(String resourceId, String kqDate) {
|
|
|
basebean.writeLog("SskjUtil getTableName start");
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
String tableName = "";
|
|
|
//首先判断该人员是当月还是隔月 4-当月,5、6-隔月
|
|
|
String acqOverTimeTypeSql = "select field28 from cus_fielddata where id = ? and scopeid = 3 and scope = 'HrmCustomFieldByInfoType'";
|
|
|
rs.executeQuery(acqOverTimeTypeSql, resourceId);
|
|
|
while ( rs.next()) {
|
|
|
String field28 = Util.null2String(rs.getString("field28"));
|
|
|
if (StringUtils.isNotBlank(field28)) {
|
|
|
if ("4".equals(field28)) {
|
|
|
tableName = THISMONTH;
|
|
|
}
|
|
|
if ("5".equals(field28) || "6".equals(field28)) {
|
|
|
tableName = OTHERMONTH;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//再判断找那个明细表
|
|
|
if (StringUtils.isNotBlank(tableName)) {
|
|
|
//根据加班日期的类型来判断
|
|
|
//1-节假日、2-工作日、3-休息日、-1-数据异常,无效数据
|
|
|
int changeType = KQOvertimeRulesBiz.getChangeType(resourceId, kqDate);
|
|
|
if (changeType == 1) {
|
|
|
tableName = tableName + "_dt1";
|
|
|
} else if (changeType == 2) {
|
|
|
tableName = tableName + "_dt3";
|
|
|
} else if (changeType == 3) {
|
|
|
tableName = tableName + "_dt4";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return tableName;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据加班时长处理是否需要删除转事假对应的事假
|
|
|
*/
|
|
|
public boolean handleCasLeave(String resourceId, String kqDate, String requestid, double duration) {
|
|
|
|
|
|
String tableName = getTableName(resourceId, kqDate);
|
|
|
String[] split = tableName.split("_dt");
|
|
|
String handleTabel = split[0] + "_dt6";
|
|
|
String acqCasData = "select qjsc, qjbid from " + handleTabel + " where sfdk = ? ";
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
Map<String, Double> casMap = new HashMap<>();
|
|
|
rs.executeQuery(acqCasData);
|
|
|
while ( rs.next()) {
|
|
|
double qjsc = Util.getDoubleValue(Util.null2String(rs.getString("qjsc")));
|
|
|
String qjbid = Util.null2String(rs.getString("qjbid"));
|
|
|
if (StringUtils.isNotBlank(qjbid)) {
|
|
|
casMap.put("qjbid", qjsc);
|
|
|
}
|
|
|
}
|
|
|
if (casMap != null && casMap.size() > 0) {
|
|
|
String modCasSql = "update " + handleTabel + " set qjsc = ?, sfdk = ?, dklcid = ? where qjbid = ?";
|
|
|
String modLeaveSql = "update kq_flow_split_leave set duration = ?, durationdb = ? where id = ?";
|
|
|
String delLeaveSql = "";
|
|
|
List<List> modCasList = new ArrayList<>();
|
|
|
List tempList = new ArrayList();
|
|
|
for (String key : casMap.keySet()) {
|
|
|
double qjsc = casMap.get(key);
|
|
|
double temp = duration - qjsc;
|
|
|
if (temp > 0) {
|
|
|
tempList.add(0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|