连班加班,补卡不允许补当天还没到班次结束时间点的卡,消除值夜班班次的连班行政岗班次的迟到

dev-chenwnj
chenwei 1 year ago
parent 054dde7d0f
commit fae6234b30

@ -28,6 +28,7 @@ import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
*
@ -808,6 +809,9 @@ public class KQFormatData extends BaseBean {
String nightShift = Util.null2String(bb.getPropValue("project_sskj", "nightShift"));
bb.writeLog("nightShift: " + nightShift);
List<String> nightShiftList = Arrays.asList(nightShift.split(","));
if ( StringUtils.isNotBlank(adminShift) && serialidKq.equals(adminShift) ) {
//获取前一天的班次,判断是否为值夜班这个班次--因为肯定是排班制,所有只需要获取前一天排的班次就行了
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@ -820,7 +824,8 @@ public class KQFormatData extends BaseBean {
String serialId = kq.getSerialId(userId, yesterdayString);
bb.writeLog("serialId: " + serialId);
if (serialId.equals(nightShift)) {
// if (serialId.equals(nightShift)) {
if (nightShiftList.contains(serialId)) {
//根据今天的考勤开始时间,判断打卡是否在班次开始时间后的五分钟之内
//计算workBeginTime到worktime的时间差
String beginTime = workBeginTime;

@ -18,6 +18,8 @@ import weaver.systeminfo.SystemEnv;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Map.Entry;
@ -372,6 +374,10 @@ public class KQReportBiz extends BaseBean {
basebean.writeLog("getDailyFlowData to do ");
datas.putAll(getDailyReissueCardData(params,user));
//考勤二开--加班申请情况
basebean.writeLog("getDailyFlowData appFprOvertime");
datas.putAll(getDailyAppForOvertimeData(params,user));
}catch (Exception e){
writeLog(e);
@ -396,12 +402,144 @@ public class KQReportBiz extends BaseBean {
datas.putAll(getReissueCardData(params,user));
//end
//考勤二开--加班申请情况
basebean.writeLog("getFlowData appFprOvertime");
datas.putAll(getAppForOvertimeData(params,user));
}catch (Exception e){
writeLog(e);
}
return datas;
}
public Map<String,Object> getAppForOvertimeData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect = Util.null2String(jsonObj.get("typeselect"));
if (typeselect.length() == 0) typeselect = "3";
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
if (typeselect.equals("1")) {
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
} else {
fromDate = TimeUtil.getDateByOption(typeselect, "0");
toDate = TimeUtil.getDateByOption(typeselect, "1");
}
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(fromDate, formatter);
LocalDate fromDateL = date.plusDays(1);
fromDate = fromDateL.format(formatter);
LocalDate date1 = LocalDate.parse(toDate, formatter);
LocalDate toDateL = date1.plusDays(1);
toDate = toDateL.format(formatter);
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if (subCompanyId.length() > 0) {
sqlWhere += " and c.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and c.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and c.resourceid in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and c.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and c.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and c.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and c.loginid<>'' ");
}
//初始化需要检查的加班申请时长
int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes("05:00");
int endIdx = kqTimesArrayComInfo.getArrayindexByTimes("08:00");
//先查加班申请流程
String overtimeTableName = basebean.getPropValue("project_sskj","overtimeTableName");
String acqOverTimeSql = "select resourceid, fromdate, fromtime, todate, totime from ( " +
" select a.resourceid, a.fromdate, a.fromtime, a.todate, a.totime,b.subcompanyid1,b.departmentid,b.managerstr,b.managerid,b.loginid " +
" FROM "+overtimeTableName+" a " +
" left join hrmresource b on b.id = a.resourceid " +
" ) c where c.fromdate >= '"+fromDate+"' and c.todate <='" + toDate + "' " + sqlWhere;
rs.executeQuery(acqOverTimeSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
String fromdate = Util.null2String(rs.getString("fromdate"));
String fromtime = Util.null2String(rs.getString("fromtime"));
String todate = Util.null2String(rs.getString("todate"));
String totime = Util.null2String(rs.getString("totime"));
int fromIdx = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toIdx = kqTimesArrayComInfo.getArrayindexByTimes(totime);
if (fromIdx <= beginIdx && toIdx >= endIdx) {
Integer temp = Util.getIntValue(Util.null2String(datas.get(resourceid+"|"+"appForOvertime")));
if (temp > 0) {
temp = temp + 1;
datas.put(resourceid+"|"+"appForOvertime", temp );
} else {
datas.put(resourceid+"|"+"appForOvertime", 1 );
}
}
}
//再查批量加班申请流程
String overtimeBatchTableName = basebean.getPropValue("project_sskj","overtimeBatchTableName");
String acqOverTimeBatchSql = "select jbry, ksrq, kssj, jsrq, jssj from ( " +
" select a.jbry, a.ksrq, a.kssj, a.jsrq, a.jssj, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " +
" FROM "+overtimeBatchTableName+"_dt1 a " +
" left join hrmresource b on b.id = a.jbry " +
" ) c where c.ksrq >= '"+fromDate+"' and c.jsrq <='" + toDate + "' " + sqlWhere;
rs.executeQuery(acqOverTimeBatchSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("jbry"));
String fromdate = Util.null2String(rs.getString("ksrq"));
String fromtime = Util.null2String(rs.getString("kssj"));
String todate = Util.null2String(rs.getString("jsrq"));
String totime = Util.null2String(rs.getString("jssj"));
int fromIdx = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toIdx = kqTimesArrayComInfo.getArrayindexByTimes(totime);
if (fromIdx <= beginIdx && toIdx >= endIdx) {
Integer temp = Util.getIntValue(Util.null2String(datas.get(resourceid+"|"+"appForOvertime")));
if (temp > 0) {
temp = temp + 1;
datas.put(resourceid+"|"+"appForOvertime", temp );
} else {
datas.put(resourceid+"|"+"appForOvertime", 1 );
}
}
}
}catch (Exception e){
writeLog(e);
}
basebean.writeLog("getAppForOvertimeData datas:" + datas);
return datas;
}
/**
*
* @param params
@ -490,6 +628,125 @@ public class KQReportBiz extends BaseBean {
return datas;
}
/**
*
* ,
*/
public Map<String,Object> getDailyAppForOvertimeData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect = Util.null2String(jsonObj.get("typeselect"));
if (typeselect.length() == 0) typeselect = "3";
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
if (typeselect.equals("1")) {
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
} else {
fromDate = TimeUtil.getDateByOption(typeselect, "0");
toDate = TimeUtil.getDateByOption(typeselect, "1");
}
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(fromDate, formatter);
LocalDate fromDateL = date.plusDays(1);
fromDate = fromDateL.format(formatter);
LocalDate date1 = LocalDate.parse(toDate, formatter);
LocalDate toDateL = date1.plusDays(1);
toDate = toDateL.format(formatter);
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if (subCompanyId.length() > 0) {
sqlWhere += " and c.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and c.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and c.resourceid in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and c.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and c.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and c.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and c.loginid<>'' ");
}
//初始化需要检查的加班申请时长
int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes("05:00");
int endIdx = kqTimesArrayComInfo.getArrayindexByTimes("08:00");
//先查加班申请流程
String overtimeTableName = basebean.getPropValue("project_sskj","overtimeTableName");
String acqOverTimeSql = "select resourceid, fromdate, fromtime, todate, totime from ( " +
" select a.resourceid, a.fromdate, a.fromtime, a.todate, a.totime,b.subcompanyid1,b.departmentid,b.managerstr,b.managerid,b.loginid " +
" FROM "+overtimeTableName+" a " +
" left join hrmresource b on b.id = a.resourceid " +
" ) c where c.fromdate >= '"+fromDate+"' and c.todate <='" + toDate + "' " + sqlWhere;
rs.executeQuery(acqOverTimeSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
String fromdate = Util.null2String(rs.getString("fromdate"));
String fromtime = Util.null2String(rs.getString("fromtime"));
String todate = Util.null2String(rs.getString("todate"));
String totime = Util.null2String(rs.getString("totime"));
int fromIdx = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toIdx = kqTimesArrayComInfo.getArrayindexByTimes(totime);
if (fromIdx <= beginIdx && toIdx >= endIdx) {
datas.put(resourceid+"|"+fromdate+"|"+"appForOvertime",1);
}
}
//再查批量加班申请流程
String overtimeBatchTableName = basebean.getPropValue("project_sskj","overtimeBatchTableName");
String acqOverTimeBatchSql = "select jbry, ksrq, kssj, jsrq, jssj from ( " +
" select a.jbry, a.ksrq, a.kssj, a.jsrq, a.jssj, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " +
" FROM "+overtimeBatchTableName+"_dt1 a " +
" left join hrmresource b on b.id = a.jbry " +
" ) c where c.ksrq >= '"+fromDate+"' and c.jsrq <='" + toDate + "' " + sqlWhere;
rs.executeQuery(acqOverTimeBatchSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("jbry"));
String fromdate = Util.null2String(rs.getString("ksrq"));
String fromtime = Util.null2String(rs.getString("kssj"));
String todate = Util.null2String(rs.getString("jsrq"));
String totime = Util.null2String(rs.getString("jssj"));
int fromIdx = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toIdx = kqTimesArrayComInfo.getArrayindexByTimes(totime);
if (fromIdx <= beginIdx && toIdx >= endIdx) {
datas.put(resourceid+"|"+fromdate+"|"+"appForOvertime",1);
}
}
}catch (Exception e){
writeLog(e);
}
basebean.writeLog("getDailyAppForOvertimeData datas:" + datas);
return datas;
}
/**
*
* @param params

@ -11,6 +11,7 @@ import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
@ -23,6 +24,8 @@ import weaver.systeminfo.SystemEnv;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
@ -31,6 +34,8 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
private HttpServletResponse response;
private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportDailyExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
this.params = params;
@ -237,6 +242,8 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
Map<String,String> serialdata = new HashMap<>();
boolean isneedcal = KQSettingsBiz.getKqformatAccurate();
params.put("isneedcal",isneedcal?"1":"0");
@ -344,6 +351,20 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus3"));
data.add(fieldValue);
continue;
}else if ("appForOvertime".equals(fieldName)) {
bb.writeLog("appForOvertime");
LocalDate date = LocalDate.parse(kqdate, formatter);
LocalDate kqdateL = date.plusDays(1);
String kqdateN = kqdateL.format(formatter);
int intValue = Util.getIntValue(Util.null2String(flowData.get(id + "|" + kqdateN + "|" + "appForOvertime")));
bb.writeLog("intValue: " + intValue);
if (intValue == 1) {
data.add("正常");
} else {
data.add("异常");
}
continue;
} else if(fieldName.equals("leave")){
//请假
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();

@ -24,6 +24,8 @@ import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Object>> {
@ -233,6 +235,8 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
rs.execute(sql);
writeLog("howec::::::::::::::::sql:"+sql);
while (rs.next()) {
@ -329,7 +333,20 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
data.put("serialid", tmpserialname);
}
}
}else {
} else if ("appForOvertime".equals(fieldName)) {
bb.writeLog("appForOvertime");
LocalDate date = LocalDate.parse(kqdate, formatter);
LocalDate kqdateL = date.plusDays(1);
String kqdateN = kqdateL.format(formatter);
int intValue = Util.getIntValue(Util.null2String(flowData.get(id + "|" + kqdateN + "|" + "appForOvertime")));
bb.writeLog("intValue: " + intValue);
if (intValue == 1) {
data.put(fieldName, "正常");
} else {
data.put(fieldName, "异常");
}
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
@ -420,85 +437,85 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
Map column = null;
int sumChildColumnWidth = 0;
if(parentid.equals("leave")){
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> leaveRule = leaveRules.get(i);
String id = "leaveType_"+Util.null2String(leaveRule.get("id"));
String name = Util.null2String(leaveRule.get("name"));
String unitType = Util.null2String(leaveRule.get("unitType"));
column = new HashMap();
column.put("title", name);
column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
column.put("width", 65);
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("showDetial","1");
sumChildColumnWidth+=65;
lsChildColumns.add(column);
}
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> leaveRule = leaveRules.get(i);
String id = "leaveType_"+Util.null2String(leaveRule.get("id"));
String name = Util.null2String(leaveRule.get("name"));
String unitType = Util.null2String(leaveRule.get("unitType"));
column = new HashMap();
column.put("title", name);
column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
column.put("width", 65);
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("showDetial","1");
sumChildColumnWidth+=65;
lsChildColumns.add(column);
}
}else if(parentid.equals("overtime")){
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
for(int i=0;i<overtimeChild.length;i++){
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
}else{
fieldlabel = "523";
column.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
String unitTypeName = "";
if(Util.null2String(unitType).length()>0){
if(unitType.equals("1")){
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
}else if(unitType.equals("2")){
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
}else if(unitType.equals("3")){
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
for(int i=0;i<overtimeChild.length;i++){
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
}else{
fieldlabel = "523";
column.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
String unitTypeName = "";
if(Util.null2String(unitType).length()>0){
if(unitType.equals("1")){
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
}else if(unitType.equals("2")){
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
}else if(unitType.equals("3")){
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
column.put("unit", unitTypeName);
}
}
column.put("unit", unitTypeName);
}
column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 1);
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
column.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 1);
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
column.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
}
column.put("width", childWidth+"");
sumChildColumnWidth+=childWidth;
lsChildColumns.add(column);
}
column.put("width", childWidth+"");
sumChildColumnWidth+=childWidth;
lsChildColumns.add(column);
}
}else{
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(kqReportFieldComInfo.getParentid().equals(parentid)) {
if(!kqReportFieldComInfo.getReportType().equals("daily"))continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("isdaily", kqReportFieldComInfo.getReportType1().equals("daily")?"1":"0");
sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth());
lsChildColumns.add(column);
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(kqReportFieldComInfo.getParentid().equals(parentid)) {
if(!kqReportFieldComInfo.getReportType().equals("daily"))continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("isdaily", kqReportFieldComInfo.getReportType1().equals("daily")?"1":"0");
sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth());
lsChildColumns.add(column);
}
}
}
}
returnMap.put("childColumns",lsChildColumns);
returnMap.put("sumChildColumnWidth",sumChildColumnWidth);

@ -10,6 +10,7 @@ import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
@ -22,10 +23,13 @@ import weaver.systeminfo.SystemEnv;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
BaseBean bb = new BaseBean();
public GetKQReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
@ -393,38 +397,38 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0");
String backType = fieldName+"_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0");
String businessLeave = "";
try{
//以防止出现精度问题
if(businessLeaveData.length() == 0){
businessLeaveData = "0.0";
}
if(businessLeavebackData.length() == 0){
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if(Util.getDoubleValue(businessLeave, -1) < 0){
businessLeave = "0.0";
}
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
}else{
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0");
String backType = fieldName+"_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0");
String businessLeave = "";
try{
//以防止出现精度问题
if(businessLeaveData.length() == 0){
businessLeaveData = "0.0";
}
if(businessLeavebackData.length() == 0){
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if(Util.getDoubleValue(businessLeave, -1) < 0){
businessLeave = "0.0";
}
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
}else{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
}
} else {

@ -0,0 +1,293 @@
package weaver.interfaces.sskj.job;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.domain.RecordDetail;
import com.engine.kq.biz.KQFormatBiz;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import com.engine.kq.timer.KQQueue;
import com.engine.kq.timer.KQTaskBean;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.engine.sskj.util.SskjUtil;
import com.github.pagehelper.dialect.helper.InformixDialect;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.BatchRecordSet;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import static weaver.interfaces.sskj.util.HttpsUtil.doPostJsonRequest;
/**
* Created with IntelliJ IDEA.
*
* @Auther: chenwnj
* @Date: 2023/11/27
* @Description:
*/
public class DeductTrainTimesJob extends BaseCronJob {
@Override
public void execute() {
BaseBean bb = new BaseBean();
bb.writeLog("-----DeductTrainTimesJob start-----");
try {
RecordSet rs = new RecordSet();
//获取当前年月日
String nowDay = DateUtil.format(new Date(),"yyyy-MM-dd");
String firstDayOfMonth = DateUtil.format(DateUtil.beginOfMonth(new Date()),"yyyy-MM-dd");
//获取培训数据
Map<String, Object> trainInfo = new HashMap<>();
List< Map<String, Object>> trainInfos = new ArrayList<>();
String acqTrainInfoSql = "select a.pxsj, a.kssj1, a.jssj1, b.xm, b.id " +
" from uf_pxjl a " +
" left join uf_pxjl_dt1 b " +
" on b.mainid = a.id " +
" where (b.isdeduct is null or b.isdeduct = 0) and b.xm is not null " +
" and a.pxsj is not null and a.kssj1 is not null and a.jssj1 is not null " +
" and a.pxsj >='" + firstDayOfMonth + "' and a.pxsj <='" + nowDay + "' ";
bb.writeLog("acqTrainInfoSql: " + acqTrainInfoSql);
rs.executeQuery(acqTrainInfoSql);
while ( rs.next()) {
String pxsj = Util.null2String(rs.getString("pxsj"));
String kssj = Util.null2String(rs.getString("kssj1"));
String jssj = Util.null2String(rs.getString("jssj1"));
String xm = Util.null2String(rs.getString("xm"));
String detailId = Util.null2String(rs.getString("id"));
trainInfo.put("detailId",detailId);
trainInfo.put("pxsj",pxsj);
trainInfo.put("kssj",kssj);
trainInfo.put("jssj",jssj);
trainInfo.put("xm",xm);
trainInfos.add(trainInfo);
}
if ( trainInfos.size() > 0) {
List deduIdList = new ArrayList<>();//记录满足减去培训时长的加班数据
Map< String, Object > deduTiaoxiuMap = new HashMap<>();//记录调休扣减的数据
Map< String, Integer > overtimeTiaoxiuMap = new HashMap<>();//记录加班和调休id
List< List > deduOvertimeList = new ArrayList<>();//批量修改加班时长的数据
for ( Map<String, Object> train: trainInfos) {
String detailId = Util.null2String(train.get("detailId"));
String pxsj = Util.null2String(train.get("pxsj"));
String kssj = Util.null2String(train.get("kssj"));
String jssj = Util.null2String(train.get("jssj"));
String xm = Util.null2String(train.get("xm"));
String acqOverTimeSql = "select id, duration_min, tiaoxiuid from kq_flow_overtime where resourceid = ? and belongdate = ? " +
"and fromtimedb <='" + kssj + "' and totimedb >='" + jssj + "' ";
rs.executeQuery(acqOverTimeSql, xm, pxsj);
while ( rs.next()) {
Integer id = Util.getIntValue(Util.null2String(rs.getString("id")));
Integer durationMin = Util.getIntValue(Util.null2String(rs.getString("duration_min")));
String tiaoxiuid = Util.null2String(rs.getString("tiaoxiuid"));
//加班时长减去培训时长
long minutesDifference = 0;
if ( durationMin> 0 ) {
List deduId = new ArrayList();
deduId.add(detailId);
deduIdList.add(deduId);
LocalTime timeStart = LocalTime.parse(pxsj +" " + kssj);
LocalTime timeEnd = LocalTime.parse(pxsj +" " + jssj);
minutesDifference = ChronoUnit.MINUTES.between(timeStart, timeEnd);
durationMin = durationMin - ((int) minutesDifference);
if ( durationMin < 0) {
durationMin = 0;
}
}
List deduOvertime = new ArrayList<>();
deduOvertime.add(durationMin);
deduOvertime.add(id);
deduOvertimeList.add(deduOvertime);
//记录调休id
if (StringUtils.isNotBlank(tiaoxiuid)) {
deduTiaoxiuMap.put(tiaoxiuid,minutesDifference);
//记录加班和调休id
overtimeTiaoxiuMap.put(tiaoxiuid,id);
}
}
}
//先扣除掉加班的时长
String subOverTimeSql = "update kq_flow_overtime set duration_min = ? where id = ?";
boolean subOverTimeSqlFlag = rs.executeBatchSql(subOverTimeSql, deduOvertimeList);
bb.writeLog("subOverTimeSqlFlag: " + subOverTimeSqlFlag);
//再回写培训台账
String syncTrainSql = "update uf_pxjl set isdeduct = 1 where id = ? ";
boolean syncTrainSqlFlag = rs.executeBatchSql(syncTrainSql, deduIdList);
bb.writeLog("syncTrainSqlFlag: " + syncTrainSqlFlag);
//处理调休时长
String tiaoxiuLeaveId = Util.null2String(bb.getPropValue("project_sskj","tiaoxiuleaveid"));
String casualLeaveId = Util.null2String(bb.getPropValue("project_sskj","casualleaveid"));
if (StringUtils.isNotBlank(tiaoxiuLeaveId) && StringUtils.isNotBlank(casualLeaveId) ) {
String overtimeSubTrainModeId = bb.getPropValue("project_sskj", "overtimeSubTrainModeId");
Integer modedatacreater = 1;
Integer modedatacreatertype = 0;
String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd");
String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss");
//获取在职员工的信息
Map<String, List<String>> resInfos = new HashMap<>();
String acqResSql = "select id, subcompanyid1, departmentid, jobtitle from hrmresource where status in (0,1,2,3)";
rs.executeQuery(acqResSql);
while ( rs.next()) {
String id = Util.null2String(rs.getString("id"));
String subcompanyid = Util.null2String(rs.getString("subcompanyid1"));
String departmentid = Util.null2String(rs.getString("departmentid"));
String jobtitle = Util.null2String(rs.getString("jobtitle"));
List<String> infos = new ArrayList<>();
infos.add(subcompanyid);
infos.add(departmentid);
infos.add(jobtitle);
resInfos.put(id, infos);
}
//获取事假最小请假单位
String minimumUnit = new KQLeaveRulesComInfo().getMinimumUnit(casualLeaveId);
//调休时长扣减
List<List> tiaoxiuSubList = new ArrayList<>();
//转事假
List<List> casualLeaveList = new ArrayList<>();
//变动记录
List<List> changeLogList = new ArrayList<>();
String leaveDetailIds = deduTiaoxiuMap.keySet().stream()
.map(Object::toString)
.collect(Collectors.joining(","));
String acqTiaoxiuSql = "select id, tiaoxiuamount, usedAmount, resourceId from kq_balanceofleave where id in (" + leaveDetailIds + ")";
rs.executeQuery(acqTiaoxiuSql);
while ( rs.next()) {
double tiaoxiuAmount = Util.getDoubleValue(Util.null2String(rs.getString("tiaoxiuamount")));
double usedAmount = Util.getDoubleValue(Util.null2String(rs.getString("usedAmount")));
int resourceId = Util.getIntValue(Util.null2String(rs.getString("resourceId")));
int id = Util.getIntValue(Util.null2String(rs.getString("id")));//调休表id
double duration = Util.getDoubleValue(Util.null2String(deduTiaoxiuMap.get(id)));
if ( (tiaoxiuAmount - usedAmount - duration) >=0 ) {//调休
List tiaoxiuSub = new ArrayList();
tiaoxiuSub.add(tiaoxiuAmount - duration);
tiaoxiuSub.add(id);
tiaoxiuSubList.add(tiaoxiuSub);
List changeLog = new ArrayList();
changeLog.add(resourceId);
Integer overtimeId = overtimeTiaoxiuMap.get(String.valueOf(id));
changeLog.add(overtimeId);
changeLog.add(id);
changeLog.add(duration);
changeLog.add(tiaoxiuAmount);
changeLog.add(tiaoxiuAmount - duration);
changeLog.add(tiaoxiuLeaveId);
changeLogList.add(changeLog);
} else {//事假
List casualLeave = new ArrayList();
casualLeave.add(resourceId);//resourceid
casualLeave.add(resourceId);//fromdate
casualLeave.add(resourceId);//fromtime
casualLeave.add(resourceId);//todate
casualLeave.add(resourceId);//totime
casualLeave.add(casualLeaveId);//newleavetype
casualLeave.add(duration);//duration
casualLeave.add(minimumUnit);//durationrule
casualLeave.add(resourceId);//fromdatedb
casualLeave.add(resourceId);//fromtimedb
casualLeave.add(resourceId);//todatedb
casualLeave.add(resourceId);//totimedb
casualLeave.add(duration);//durationdb
casualLeave.add(resourceId);//belongdate
List<String> infos = resInfos.get(resourceId);
String subcompanyid = infos.get(0);
String departmentid = infos.get(1);
String jobtitle = infos.get(2);
casualLeave.add(subcompanyid);//subcompanyid
casualLeave.add(departmentid);//departmentid
casualLeave.add(jobtitle);//jobtitle
casualLeave.add(resourceId);//changetype
casualLeaveList.add(casualLeave);
List changeLog = new ArrayList();
changeLog.add(resourceId);
Integer overtimeId = overtimeTiaoxiuMap.get(String.valueOf(id));
changeLog.add(overtimeId);
changeLog.add("0");
changeLog.add(duration);
changeLog.add("0.0000");
changeLog.add(duration);
changeLog.add(casualLeaveId);
changeLog.add(overtimeSubTrainModeId);
changeLog.add(modedatacreater);
changeLog.add(modedatacreatertype);
changeLog.add(modedatacreatedate);
changeLog.add(modedatacreatetime);
String uuid = UUID.randomUUID().toString();
changeLog.add(uuid);
changeLogList.add(changeLog);
}
}
//调休扣减
String subTiaoxiuSql = "update kq_balanceofleave set tiaoxiuamount = ? where id = ?";
boolean subTiaoxiuSqlFlag = rs.executeBatchSql(subTiaoxiuSql, tiaoxiuSubList);
bb.writeLog("subTiaoxiuSqlFlag: " + subTiaoxiuSqlFlag);
//事假扣减
String addCasSql = "insert into kq_flow_split_leave " +
" (resourceid, fromdate, fromtime, todate, totime, newleavetype, duration, durationrule, fromdatedb, fromtimedb, todatedb, totimedb," +
" durationdb, belongdate, subcompanyid, departmentid, jobtitle, changetype )" +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean addCasSqlFlag = rs.executeBatchSql(addCasSql, casualLeaveList);
bb.writeLog("addCasSqlFlag: " + addCasSqlFlag);
//变动记录
String syncChangeSql = "insert into uf_overtimesubtrain " +
" (resourceId, overtimedataId, tiaoxiudataId, subduration, beforeduration, afterduration, leavetype, " +
" formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID ) " +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
bb.writeLog("syncChangeSql" + syncChangeSql);
boolean syncChangeSqlFlag = rs.executeBatchSql(syncChangeSql, changeLogList);
bb.writeLog("addFlag" + syncChangeSqlFlag);
if (syncChangeSqlFlag) {
for ( List changeLog: changeLogList) {
String uuid = Util.null2String(changeLog.get(changeLog.size() - 1));
String billid = "-1";
String acqModeIdSql = "select id from uf_NoOutEmpNum where MODEUUID = ?";
rs.executeQuery(acqModeIdSql, uuid);
while (rs.next()) {
billid = Util.null2String(rs.getString("id"));
}
bb.writeLog("billid" + billid);
SskjUtil sskjUtil = new SskjUtil();
sskjUtil.modePerRecon(modedatacreater, overtimeSubTrainModeId, billid);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
bb.writeLog(e);
bb.writeLog("DeductTrainTimesJob Exception: "+e);
}
}
}
Loading…
Cancel
Save