diff --git a/src/com/engine/kq/biz/KQFormatSignData.java b/src/com/engine/kq/biz/KQFormatSignData.java index 965458d..cef59e6 100644 --- a/src/com/engine/kq/biz/KQFormatSignData.java +++ b/src/com/engine/kq/biz/KQFormatSignData.java @@ -370,245 +370,245 @@ public class KQFormatSignData extends BaseBean { } /*考勤二开--出差公出流程获取外勤打卡数据start*/ - BaseBean bb = new BaseBean(); - - bb.writeLog("+-出差公出流程获取外勤打卡数据start"); - bb.writeLog("lsCheckInfo: " + lsCheckInfo); - bb.writeLog("lsCheckInfo.size(): " + lsCheckInfo.size()); - //获取外勤打卡的前提是已经有归档的出差、公出流程 - String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName")); -// bb.writeLog("evectionTableName: " + evectionTableName); - - String outTableName = Util.null2String(bb.getPropValue("project_hostar","outTableName")); -// bb.writeLog("outTableName: " + outTableName); - - if ( StringUtils.isNotBlank(evectionTableName) && StringUtils.isNotBlank(outTableName) ) { - RecordSet rs = new RecordSet(); - Integer number = -1; - String acqEvecAndOutSql = " select sum(a.number) as number " + - " from ( " + - " SELECT " + - " count(*) as number " + - " FROM " + - " workflow_requestbase " + - " WHERE " + - " requestid IN ( SELECT requestid FROM "+evectionTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"' ) " + - " AND currentnodetype = 3 " + - " UNION all " + - " SELECT " + - " count(*) as number " + - " FROM " + - " workflow_requestbase " + - " WHERE " + - " requestid IN ( SELECT requestid FROM "+outTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"') " + +// BaseBean bb = new BaseBean(); +// +// bb.writeLog("+-出差公出流程获取外勤打卡数据start"); +// bb.writeLog("lsCheckInfo: " + lsCheckInfo); +// bb.writeLog("lsCheckInfo.size(): " + lsCheckInfo.size()); +// //获取外勤打卡的前提是已经有归档的出差、公出流程 +// String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName")); +//// bb.writeLog("evectionTableName: " + evectionTableName); +// +// String outTableName = Util.null2String(bb.getPropValue("project_hostar","outTableName")); +//// bb.writeLog("outTableName: " + outTableName); +// +// if ( StringUtils.isNotBlank(evectionTableName) && StringUtils.isNotBlank(outTableName) ) { +// RecordSet rs = new RecordSet(); +// Integer number = -1; +// String acqEvecAndOutSql = " select sum(a.number) as number " + +// " from ( " + +// " SELECT " + +// " count(*) as number " + +// " FROM " + +// " workflow_requestbase " + +// " WHERE " + +// " requestid IN ( SELECT requestid FROM "+evectionTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"' ) " + // " AND currentnodetype = 3 " + - ") a "; - rs.executeQuery(acqEvecAndOutSql); -// bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql); - - while (rs.next()) { - number = Util.getIntValue(Util.null2String(rs.getString("number"))); - } - bb.writeLog("number: " + number); - - if (lsCheckInfo.size() < 2 && number > 0) {//只考虑每天一次上下班,原始打卡记录没有取到两次打卡记录则考虑外勤打卡 - List legWorkInfos = new ArrayList<>(); - //获取允许打卡时间 - String signBeginTime = signTimeScope.getBeginTime(); -// bb.writeLog("signBeginTime: " + signBeginTime); - if (StringUtils.isNotBlank(signBeginTime)) { - signBeginTime = signBeginTime + ":00"; - } -// bb.writeLog("signBeginTime: " + signBeginTime); - //获取上班时间 - String workBeginTime = workTimeScope.getBeginTime(); -// bb.writeLog("workBeginTime: " + workBeginTime); - if (StringUtils.isNotBlank(workBeginTime)) { - workBeginTime = workBeginTime + ":00"; - } -// bb.writeLog("workBeginTime: " + workBeginTime); - - String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc "; - bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql); -// bb.writeLog("userId: " + userId); - rs.executeQuery(acqLegWorkSignSql, userId); - while ( rs.next()) { - String operateTime = Util.null2String(rs.getString("operate_time")); - if ( StringUtils.isNotBlank(operateTime) ) { - legWorkInfos.add(operateTime); - } - } - bb.writeLog("legWorkInfos: " + legWorkInfos); - - if (legWorkInfos != null && legWorkInfos.size() > 0 ) { - boolean onFlag = false;//上班卡 - boolean offFlag = false;//下班卡 - - //判断需要获取的打卡 - for(Object obj: lsCheckInfo) { - if (obj != null) { - Map checkInfo = (Map ) obj; - Integer signType = Util.getIntValue(Util.null2String(checkInfo.get("signType"))); - if (signType == 1) { - onFlag = true; - } - if (signType == 2) { - offFlag = true; - } - } - } - - String tempSignIn = ""; - String tempSignOut = ""; - Map checkInfo = new HashMap<>(); - if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班 - if ( onFlag && !offFlag ) { - checkInfo.put("signType", "2"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - } - if ( !onFlag && offFlag ) { - checkInfo.put("signType", "1"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - } - - } else { - for ( String signTime : legWorkInfos) { - if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡 - if (StringUtils.isBlank(tempSignIn)) { - tempSignIn = signTime; - } else { - if ( signTime.compareTo(tempSignIn) < 0 ) { - tempSignIn = signTime; - } - } - } - if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔 - if (StringUtils.isBlank(tempSignIn)) { - tempSignOut = signTime; - } else { - if ( signTime.compareTo(tempSignOut) > 0 ) { - tempSignOut = signTime; - } - } - } - } - if (offFlag && !onFlag ) { - checkInfo.put("signType", "1"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", tempSignIn);//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - } - if (onFlag && !offFlag ) { - checkInfo = new HashMap<>(); - checkInfo.put("signType", "2"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", tempSignOut);//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - } - } - } - } else if ( lsCheckInfo.size() == 2) { - List legWorkInfos = new ArrayList<>(); - //获取允许打卡时间 - String signBeginTime = signTimeScope.getBeginTime(); -// bb.writeLog("signBeginTime: " + signBeginTime); - if (StringUtils.isNotBlank(signBeginTime)) { - signBeginTime = signBeginTime + ":00"; - } -// bb.writeLog("signBeginTime: " + signBeginTime); - //获取上班时间 - String workBeginTime = workTimeScope.getBeginTime(); -// bb.writeLog("workBeginTime: " + workBeginTime); - if (StringUtils.isNotBlank(workBeginTime)) { - workBeginTime = workBeginTime + ":00"; - } -// bb.writeLog("workBeginTime: " + workBeginTime); - - String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc "; - bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql); - bb.writeLog("userId: " + userId); - rs.executeQuery(acqLegWorkSignSql, userId); - while ( rs.next()) { - String operateTime = Util.null2String(rs.getString("operate_time")); - if ( StringUtils.isNotBlank(operateTime) ) { - legWorkInfos.add(operateTime); - } - } +// " UNION all " + +// " SELECT " + +// " count(*) as number " + +// " FROM " + +// " workflow_requestbase " + +// " WHERE " + +// " requestid IN ( SELECT requestid FROM "+outTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"') " + +//// " AND currentnodetype = 3 " + +// ") a "; +// rs.executeQuery(acqEvecAndOutSql); +//// bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql); +// +// while (rs.next()) { +// number = Util.getIntValue(Util.null2String(rs.getString("number"))); +// } +// bb.writeLog("number: " + number); +// +// if (lsCheckInfo.size() < 2 && number > 0) {//只考虑每天一次上下班,原始打卡记录没有取到两次打卡记录则考虑外勤打卡 +// List legWorkInfos = new ArrayList<>(); +// //获取允许打卡时间 +// String signBeginTime = signTimeScope.getBeginTime(); +//// bb.writeLog("signBeginTime: " + signBeginTime); +// if (StringUtils.isNotBlank(signBeginTime)) { +// signBeginTime = signBeginTime + ":00"; +// } +//// bb.writeLog("signBeginTime: " + signBeginTime); +// //获取上班时间 +// String workBeginTime = workTimeScope.getBeginTime(); +//// bb.writeLog("workBeginTime: " + workBeginTime); +// if (StringUtils.isNotBlank(workBeginTime)) { +// workBeginTime = workBeginTime + ":00"; +// } +//// bb.writeLog("workBeginTime: " + workBeginTime); +// +// String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc "; +// bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql); +//// bb.writeLog("userId: " + userId); +// rs.executeQuery(acqLegWorkSignSql, userId); +// while ( rs.next()) { +// String operateTime = Util.null2String(rs.getString("operate_time")); +// if ( StringUtils.isNotBlank(operateTime) ) { +// legWorkInfos.add(operateTime); +// } +// } // bb.writeLog("legWorkInfos: " + legWorkInfos); - - if (legWorkInfos != null && legWorkInfos.size() > 0 ) { - - String tempSignIn = ""; - String tempSignOut = ""; - Map checkInfo = new HashMap<>(); - if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班 - - checkInfo.put("signType", "1"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - - - } else { - for ( String signTime : legWorkInfos) { - if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡 - if (StringUtils.isBlank(tempSignIn)) { - tempSignIn = signTime; - } else { - if ( signTime.compareTo(tempSignIn) < 0 ) { - tempSignIn = signTime; - } - } - } - if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔 - if (StringUtils.isBlank(tempSignOut)) { - tempSignOut = signTime; - } else { - if ( signTime.compareTo(tempSignOut) > 0 ) { - tempSignOut = signTime; - } - } - } - } - - if(StringUtils.isNotBlank(tempSignIn)) { - checkInfo.put("signType", "1"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", tempSignIn);//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - } - - if(StringUtils.isNotBlank(tempSignIn)) { - checkInfo = new HashMap<>(); - checkInfo.put("signType", "2"); - checkInfo.put("signDate", kqDate);//签到签退日期 - checkInfo.put("signTime", tempSignOut);//签到签退时间 - checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 - checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); - lsCheckInfo.add(checkInfo); - } - - } - } - } - } - bb.writeLog("lsCheckInfo: " + lsCheckInfo); +// +// if (legWorkInfos != null && legWorkInfos.size() > 0 ) { +// boolean onFlag = false;//上班卡 +// boolean offFlag = false;//下班卡 +// +// //判断需要获取的打卡 +// for(Object obj: lsCheckInfo) { +// if (obj != null) { +// Map checkInfo = (Map ) obj; +// Integer signType = Util.getIntValue(Util.null2String(checkInfo.get("signType"))); +// if (signType == 1) { +// onFlag = true; +// } +// if (signType == 2) { +// offFlag = true; +// } +// } +// } +// +// String tempSignIn = ""; +// String tempSignOut = ""; +// Map checkInfo = new HashMap<>(); +// if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班 +// if ( onFlag && !offFlag ) { +// checkInfo.put("signType", "2"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// } +// if ( !onFlag && offFlag ) { +// checkInfo.put("signType", "1"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// } +// +// } else { +// for ( String signTime : legWorkInfos) { +// if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡 +// if (StringUtils.isBlank(tempSignIn)) { +// tempSignIn = signTime; +// } else { +// if ( signTime.compareTo(tempSignIn) < 0 ) { +// tempSignIn = signTime; +// } +// } +// } +// if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔 +// if (StringUtils.isBlank(tempSignIn)) { +// tempSignOut = signTime; +// } else { +// if ( signTime.compareTo(tempSignOut) > 0 ) { +// tempSignOut = signTime; +// } +// } +// } +// } +// if (offFlag && !onFlag ) { +// checkInfo.put("signType", "1"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", tempSignIn);//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// } +// if (onFlag && !offFlag ) { +// checkInfo = new HashMap<>(); +// checkInfo.put("signType", "2"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", tempSignOut);//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// } +// } +// } +// } else if ( lsCheckInfo.size() == 2) { +// List legWorkInfos = new ArrayList<>(); +// //获取允许打卡时间 +// String signBeginTime = signTimeScope.getBeginTime(); +//// bb.writeLog("signBeginTime: " + signBeginTime); +// if (StringUtils.isNotBlank(signBeginTime)) { +// signBeginTime = signBeginTime + ":00"; +// } +//// bb.writeLog("signBeginTime: " + signBeginTime); +// //获取上班时间 +// String workBeginTime = workTimeScope.getBeginTime(); +//// bb.writeLog("workBeginTime: " + workBeginTime); +// if (StringUtils.isNotBlank(workBeginTime)) { +// workBeginTime = workBeginTime + ":00"; +// } +//// bb.writeLog("workBeginTime: " + workBeginTime); +// +// String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc "; +// bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql); +// bb.writeLog("userId: " + userId); +// rs.executeQuery(acqLegWorkSignSql, userId); +// while ( rs.next()) { +// String operateTime = Util.null2String(rs.getString("operate_time")); +// if ( StringUtils.isNotBlank(operateTime) ) { +// legWorkInfos.add(operateTime); +// } +// } +//// bb.writeLog("legWorkInfos: " + legWorkInfos); +// +// if (legWorkInfos != null && legWorkInfos.size() > 0 ) { +// +// String tempSignIn = ""; +// String tempSignOut = ""; +// Map checkInfo = new HashMap<>(); +// if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班 +// +// checkInfo.put("signType", "1"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// +// +// } else { +// for ( String signTime : legWorkInfos) { +// if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡 +// if (StringUtils.isBlank(tempSignIn)) { +// tempSignIn = signTime; +// } else { +// if ( signTime.compareTo(tempSignIn) < 0 ) { +// tempSignIn = signTime; +// } +// } +// } +// if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔 +// if (StringUtils.isBlank(tempSignOut)) { +// tempSignOut = signTime; +// } else { +// if ( signTime.compareTo(tempSignOut) > 0 ) { +// tempSignOut = signTime; +// } +// } +// } +// } +// +// if(StringUtils.isNotBlank(tempSignIn)) { +// checkInfo.put("signType", "1"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", tempSignIn);//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// } +// +// if(StringUtils.isNotBlank(tempSignIn)) { +// checkInfo = new HashMap<>(); +// checkInfo.put("signType", "2"); +// checkInfo.put("signDate", kqDate);//签到签退日期 +// checkInfo.put("signTime", tempSignOut);//签到签退时间 +// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 +// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); +// lsCheckInfo.add(checkInfo); +// } +// +// } +// } +// } +// } +// bb.writeLog("lsCheckInfo: " + lsCheckInfo); /*考勤二开--出差公出流程获取外勤打卡数据end*/ diff --git a/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java b/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java index 7805b40..645eb34 100644 --- a/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java +++ b/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java @@ -6,6 +6,7 @@ import com.cloudstore.dev.api.util.EMManager; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; +import com.engine.hostar.util.HostarUtil; import com.engine.kq.biz.*; import com.engine.kq.entity.KQGroupEntity; import com.engine.kq.entity.WorkTimeEntity; @@ -26,11 +27,8 @@ import weaver.systeminfo.SystemEnv; import javax.servlet.http.HttpServletRequest; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; /** * 外勤签到签退 @@ -165,7 +163,7 @@ public class PunchOutButtonCmd extends AbstractCommonCommand String signData = Util.null2String(params.get("signData")); String groupid = workTimeEntity.getGroupId(); String text ="wea"+ userId + groupid; - kqLog.writeLog("PunchOutButtonCmd>text=" + text); + kqLog.writeLog("PunchOutButtonCmd>text=" + text); String ma5Text = DigestUtils.md5Hex(text)+"ver"; kqLog.writeLog("PunchOutButtonCmd>ma5Text=" + ma5Text+";signData=" + signData); if(!signData.equals(ma5Text)){ @@ -359,6 +357,73 @@ public class PunchOutButtonCmd extends AbstractCommonCommand new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); //外勤签到转的考勤 处理加班规则 SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userId); + } else { + String acqSql = "select id from mobile_sign where operater = ? and operate_date = ? and operate_time = ? "; + rs.executeQuery(acqSql, userId, signDate, signTime); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + if (StringUtils.isNotBlank(id)) { + //整理原始打卡信息 + Map signInfo = new HashMap<>(); + boolean isInIp = true; + String userType = user.getLogintype(); + String signType = "on".equalsIgnoreCase(type) ? "1" : "2"; + String clientAddress = Util.getIpAddr(request); + String isInCom = isInIp ? "1" : "0"; + JSONObject jsonObject = null; + String deviceInfo = Util.null2String(params.get("deviceInfo")); + if(deviceInfo.length() > 0){ + jsonObject = JSON.parseObject(deviceInfo); + JSONObject jsonObject1 = new JSONObject(); + Set> jsonSet = jsonObject.entrySet(); + for(Entry js : jsonSet){ + String key = js.getKey(); + String value = Util.null2String(js.getValue()); + jsonObject1.put(key, value); + } + if(!jsonObject1.isEmpty()){ + deviceInfo = jsonObject1.toJSONString(); + } + } + signInfo.put("userId", userId); + signInfo.put("userType", userType); + signInfo.put("signType", signType); + signInfo.put("signDate", signDate); + signInfo.put("signTime", signTime); + signInfo.put("clientAddress", clientAddress); + signInfo.put("isInCom", isInCom); + signInfo.put("timeZone", timeZone); + signInfo.put("belongdate", belongdate); + signInfo.put("signfrom", signfrom); + signInfo.put("longitude", longitude); + signInfo.put("latitude", latitude); + signInfo.put("address", address); + signInfo.put("deviceInfo", deviceInfo); + signInfo.put("belongdateIsNull", belongdateIsNull); + String signInfoString = signInfo.toString(); + + String outSignTypeModeId = bb.getPropValue("project_hostar", "outSignTypeModeId"); + Integer modedatacreater = 1; + Integer modedatacreatertype = 0; + String modedatacreatedate = cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM-dd"); + String modedatacreatetime = cn.hutool.core.date.DateUtil.format(new Date(), "HH:mm:ss"); + String abnUuid = UUID.randomUUID().toString(); + String syncSql = "insert into uf_outsigntype (outsignid, signinfo, formmodeid, modedatacreater, " + + "modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID) values (?, ?, ?, ?, ?, ?, ?, ?)"; + boolean b = rs.executeUpdate(syncSql, id, signInfoString, outSignTypeModeId, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, abnUuid); + if (b) { + String billid = "-1"; + String acqModeIdSql = "select id from uf_AbnAttToComLeave where MODEUUID = ?"; + rs.executeQuery(acqModeIdSql, abnUuid); + while (rs.next()) { + billid = Util.null2String(rs.getString("id")); + } + bb.writeLog("billid:" + billid); + new HostarUtil().modePerRecon(modedatacreater, outSignTypeModeId, billid); + } + + } + } } } diff --git a/src/weaver/interfaces/hostar/action/OutSignSyncAction.java b/src/weaver/interfaces/hostar/action/OutSignSyncAction.java new file mode 100644 index 0000000..a8ddb28 --- /dev/null +++ b/src/weaver/interfaces/hostar/action/OutSignSyncAction.java @@ -0,0 +1,119 @@ +package weaver.interfaces.hostar.action; + +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.wfset.util.SplitActionUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; + +public class OutSignSyncAction implements Action { + + BaseBean bb = new BaseBean(); + @Override + public String execute(RequestInfo requestInfo) { + + String startDate = ""; + String endDate = ""; + String resourceid = ""; + + try { + + Property[] properties = requestInfo.getMainTableInfo().getProperty(); + for (Property property : properties) { + if ("ksrq".equals(property.getName())) { + startDate = Util.null2String(property.getValue()); + } + if ("yjjsrq".equals(property.getName())) { + endDate = Util.null2String(property.getValue()); + } + if ("sjccr".equals(property.getName())) { + resourceid = Util.null2String(property.getValue()); + } + } + + if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate) && StringUtils.isNotBlank(resourceid)) { + RecordSet rs = new RecordSet(); + List infos = new ArrayList<>(); + String acqOutSignSql = "select a.id, c.signinfo " + + "from mobile_sign a " + + "left join uf_outsigntype c " + + "on c.outsignid = a.id " + + "where operate_date > '" + startDate + "' and operate_date < '" + endDate + "' and operate = ? "; + rs.executeQuery(acqOutSignSql, resourceid); + while (rs.next()) { + String signinfo = Util.null2String(rs.getString("signinfo")); + infos.add(signinfo); + } + + for (String inf : infos) { + if (inf != null ) { + Map in = mapStringToMap(inf); + String userId = Util.null2String(in.get("userId")); + String userType = Util.null2String(in.get("userType")); + String signType = Util.null2String(in.get("signType")); + String signDate = Util.null2String(in.get("signDate")); + String signTime = Util.null2String(in.get("signTime")); + String clientAddress = Util.null2String(in.get("clientAddress")); + String isInCom = Util.null2String(in.get("isInCom")); + String timeZone = Util.null2String(in.get("timeZone")); + String belongdate = Util.null2String(in.get("belongdate")); + String signfrom = Util.null2String(in.get("signfrom")); + String longitude = Util.null2String(in.get("longitude")); + String latitude = Util.null2String(in.get("latitude")); + String address = Util.null2String(in.get("address")); + String deviceInfo = Util.null2String(in.get("deviceInfo")); + String belongdateIsNull = Util.null2String(in.get("belongdateIsNull")); + + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isok = rs.executeUpdate(punchSql,resourceid,userType,signType,signDate,signTime,clientAddress,isInCom, + timeZone,belongdate,signfrom,longitude,latitude,address,deviceInfo); + bb.writeLog("isok: " + isok); + //同步更新考勤数据到考勤报表 + if("true".equals(belongdateIsNull)){ + //外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤 + bb.writeLog("PunchOutButtonCmd:userId:"+userId+":belongdate:"+ DateUtil.getYesterday()); + new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday()); + } + bb.writeLog("PunchOutButtonCmd:userId:"+userId+":belongdate:"+(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + if(belongdate.length()==0){ + //外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤 + new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday()); + } + new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + //外勤签到转的考勤 处理加班规则 + SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userId); + } + + } + } + } catch (Exception e) { + bb.writeLog("OutSignSyncAction Exception: " + e); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + public static Map mapStringToMap(String str){ + str = str.substring(1, str.length()-1); + String[] strs = str.split(","); + Map map = new HashMap<>(); + for (String string : strs) { + String key = string.split("=")[0]; + String value = string.split("=")[1]; + // 去掉头部空格 + String key1 = key.trim(); + String value1 = value.trim(); + map.put(key1, value1); + } + return map; + } +}