出差流程没有外勤打卡不计算考勤

dev-chenwnj
chenwei 1 year ago
parent bb8fb2ae0a
commit d38ea317e5

@ -41,6 +41,10 @@ public class GetTabsCmdInter extends AbstractCommandProxy<Map<String, Object>> {
temp.put("key","3");
temp.put("title", SystemEnv.getHtmlLabelName(10000,user.getLanguage()));
tabs.add(temp);
temp = new HashMap<>();
temp.put("key","4");
temp.put("title", SystemEnv.getHtmlLabelName(10003,user.getLanguage()));
tabs.add(temp);
}
}
}

@ -626,6 +626,34 @@ public class KQAttFlowSetBiz {
bb.writeLog("-buildFlowSetTableString orderby: " + orderby);
/*考勤二开--转事假end*/
/*考勤二开--异常考勤转事假start*/
if ( ("leaveType_"+calLeaveId).equals(type) && "4".equals(tabkey)) {
backfields = " a.resourceid, a.duration, a.belongdate, b.lastname, b.departmentId ";
fromSql = " from uf_AbnAttToComLeave a " +
" left join hrmresource b " +
" on b.id = a.resourceid ";
sqlWhere = " where a.resourceid = " + resourceId + " and a.belongdate >='" + fromDate + "' and a.belongdate <='" + toDate + "' ";
tableString =" <table pageUid=\""+pageUid+"\" tabletype=\""+tabletype+"\" pagesize=\"10\" >"+
" <sql backfields=\""+backfields+"\" sqlform=\""+fromSql+"\" sqlwhere=\""+Util.toHtmlForSplitPage(sqlWhere)+"\" sqlorderby=\""+orderby+"\" sqlprimarykey=\"a.id\" sqlsortway=\"desc\" sqlisdistinct=\"false\"/>"+
" <head>";
tableString += " <col width=\"20%\" text=\""+ SystemEnv.getHtmlLabelName(413,user.getLanguage()) +"\" column=\"lastname\" orderkey=\"lastname\" />";
tableString += " <col width=\"20%\" text=\""+ SystemEnv.getHtmlLabelName(714,user.getLanguage()) +"\" column=\"resourceid\" orderkey=\"resourceid\" transmethod=\"weaver.hrm.resource.ResourceComInfo.getWorkcode\" />";
tableString += " <col width=\"20%\" text=\""+ SystemEnv.getHtmlLabelName(124,user.getLanguage()) +"\" column=\"departmentId\" orderkey=\"departmentId\" transmethod=\"com.engine.hrm.util.HrmUtil.getKqDepartmentTransMethodnew\" otherpara=\"column:resourceId\" />";
tableString += " <col width=\"20%\" text=\""+ SystemEnv.getHtmlLabelName(-84063,user.getLanguage()) +"\" column=\"belongdate\" orderkey=\"endtime\" />";
tableString += " <col width=\"20%\" text=\""+ SystemEnv.getHtmlLabelName(21551,user.getLanguage()) +"\" column=\"duration\" orderkey=\"duration\" />";
tableString +=" </head>"+
" </table>";
}
bb.writeLog("-buildFlowSetTableString backfields: " + backfields);
bb.writeLog("-buildFlowSetTableString fromSql: " + fromSql);
bb.writeLog("-buildFlowSetTableString sqlwhere: " + sqlWhere);
bb.writeLog("-buildFlowSetTableString orderby: " + orderby);
/*考勤二开--异常考勤转事假end*/
String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionkey, tableString);
return sessionkey;

@ -2,12 +2,14 @@ package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.KQShiftRuleEntity;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.log.KQLog;
import com.engine.sskj.util.SskjUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.googlecode.aviator.AviatorEvaluator;
@ -20,7 +22,11 @@ import weaver.general.BaseBean;
import weaver.general.InitServer;
import weaver.general.Util;
import weaver.interfaces.sskj.comInfo.PropBean;
import weaver.soa.workflow.request.RequestInfo;
import weaver.soa.workflow.request.RequestService;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
@ -39,6 +45,8 @@ public class KQFormatData extends BaseBean {
private boolean writeLog = false;
private LinkedHashMap<String,Object> logInfo = new LinkedHashMap<>();
SskjUtil ssutil = new SskjUtil();
/***
*
* @param userId
@ -183,6 +191,7 @@ public class KQFormatData extends BaseBean {
List<List<Object>> lsParam = new ArrayList<>();
List<Object> params = null;
try {
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String nosign_is_absent = Util.null2String(kqSettingsComInfo.getMain_val("nosign_is_absent"),"1");
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
@ -634,6 +643,7 @@ public class KQFormatData extends BaseBean {
}
}
List<Map<String, Object>> restList = new ArrayList<>();
if(lsRestTime != null && !lsRestTime.isEmpty()){
for(int k = 0 ; k < lsRestTime.size(); k++){
TimeScopeEntity restTimeScope = lsRestTime.get(k);
@ -643,6 +653,10 @@ public class KQFormatData extends BaseBean {
beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(restBeginTime);
endIdx = kqTimesArrayComInfo.getArrayindexByTimes(restEndTime);
if (endIdx > beginIdx) {
Map<String, Object> temp = new HashMap<>();
temp.put("start",beginIdx);
temp.put("end",endIdx);
restList.add(temp);
Arrays.fill(dayMins, beginIdx, endIdx, -11);//休息时间
}
}
@ -883,6 +897,58 @@ public class KQFormatData extends BaseBean {
}
}
/*考勤二开--阶梯式记旷工start*/
//迟到、早退(注意严重迟到、严重早退的情况) belateMins--迟到 graveBeLateMins--严重迟到 leaveEarlyMins--早退 graveLeaveEarlyMins--严重早退
String changeBeforeData = "beLateMins:" + beLateMins + "graveBeLateMins:" + graveBeLateMins + "leaveEarlyMins:" + leaveEarlyMins + "graveLeaveEarlyMins:" + graveLeaveEarlyMins;
int abnormalMins = beLateMins + graveBeLateMins + leaveEarlyMins + graveLeaveEarlyMins;
if ( abnormalMins > 0 && abnormalMins <= 30 ) {
beLateMins = 0;
graveBeLateMins = 0;
leaveEarlyMins = 0;
graveLeaveEarlyMins = 0;
}
if ( abnormalMins > 30 && abnormalMins <= 120) {
absenteeismMins = 0;
beLateMins = 0;
graveBeLateMins = 0;
leaveEarlyMins = 0;
graveLeaveEarlyMins = 0;
leaveMins = 240;
//转事假
SskjUtil sskjUtil = new SskjUtil();
RecordSet rs = new RecordSet();
String toCusLeaveSql = "insert into uf_AbnAttToComLeave (resourceid, belongdate, duration, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID) values (?,?,?,?,?,?,?,?,?)";
String abnAttToComLeaveModeId = bb.getPropValue("project_sskj", "abnAttToComLeaveModeId");
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();
bb.writeLog("toCusLeaveSql" + toCusLeaveSql);
boolean addFlag = rs.executeUpdate(toCusLeaveSql, userId, kqDate, leaveMins, abnAttToComLeaveModeId, modedatacreater, modedatacreatertype, modedatacreatedate,
modedatacreatetime, abnUuid);
bb.writeLog("addFlag" + addFlag);
if (addFlag) {
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);
sskjUtil.modePerRecon(modedatacreater, abnAttToComLeaveModeId, billid);
}
}
if ( abnormalMins > 120) {
absenteeismMins = 240;
}
//计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退
attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins;
// ssutil.customLog();
/*考勤二开--阶梯式记旷工end*/
// //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退
// attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins;
// // 如果没有开启"漏签是否算实际出勤"开关,则漏签不算实际出勤时长
@ -898,6 +964,9 @@ public class KQFormatData extends BaseBean {
// }
//end
kqLog.info("实际出勤计算公式" + "实际出勤=应出勤- 旷工-请假-迟到-早退 userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid);
kqLog.info("实际出勤计算结果" + attendanceMins + "=" + workMins + "- " + absenteeismMins + "-" + leaveMins + "-" + (beLateMins + graveBeLateMins) + "-" + (leaveEarlyMins - graveLeaveEarlyMins)+" userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid);
if(this.writeLog) {

@ -14,6 +14,7 @@ import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.sskj.comInfo.PropBean;
import weaver.systeminfo.SystemEnv;
import java.text.DecimalFormat;
@ -382,6 +383,10 @@ public class KQReportBiz extends BaseBean {
basebean.writeLog("getDailyFlowData toComLeave");
datas.putAll(getDailyToComLeaveData(params,user));
//考勤二开--异常考勤转事假
basebean.writeLog("getDailyFlowData abnAttToComLeave");
datas.putAll(getDailyAbnAttToComLeaveData(params,user));
}catch (Exception e){
writeLog(e);
@ -414,9 +419,249 @@ public class KQReportBiz extends BaseBean {
basebean.writeLog("getFlowData getToComLeaveData");
datas.putAll(getToComLeaveData(params,user));
//考勤二开--统计公休时长
basebean.writeLog("getFlowData getHoliDurationData");
datas.putAll(getHoliDurationData(params,user));
//考勤二开--统计劳务工时
basebean.writeLog("getFlowData getLaborHoursData");
datas.putAll(getLaborHoursData(params,user));
//考勤二开--异常考勤转事假
basebean.writeLog("getFlowData getAbnAttToComLeaveData");
datas.putAll(getAbnAttToComLeaveData(params,user));
}catch (Exception e){
writeLog(e);
}
return datas;
}
public Map<String,Object> getLaborHoursData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
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");
}
}
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 b.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and b.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and b.id in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and b.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and b.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and b.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and b.loginid<>'' ");
}
//获取劳务工人员
List<String> empTypes = new ArrayList<>();
String empType = Util.null2String(PropBean.getUfPropValue("empType"),"field9");
basebean.writeLog("empType: " + empType);
String acqLaSql = "select id from cus_fielddata where scopeid = -1 and scope = 'HrmCustomFieldByInfoType' and " + empType + " = 0";
basebean.writeLog("acqLaSql: " + acqLaSql);
rs.executeQuery(acqLaSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id) ) {
empTypes.add(id);
}
}
//获取出勤时长
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
sql = "select a.attendancemins, a.resourceid, a.kqdate from kq_format_total a left join hrmresource b on a.resourceid = b.id " +
" where a.resourceid in (" + String.join(",", empTypes) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' " + sqlWhere;
basebean.writeLog("sql: " + sql);
rs.executeQuery(sql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
String kqdate = Util.null2String(rs.getString("kqdate"));
double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
if (attendancemins >= 0.00) {
int changeType = kqOvertimeRulesBiz.getChangeType(resourceid, kqdate);
//节假日
if (changeType == 1 ) {
double temp = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + resourceid + "|holiday")));
if (temp >=0.00) {
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))) + temp;
datas.put("LaborHoursData|" + resourceid + "|holiday" , attendanceHours);
} else {
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0)));
datas.put("LaborHoursData|" + resourceid + "|holiday" , attendanceHours);
}
}
//工作日
if (changeType == 2 ) {
double temp = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + resourceid + "|workday")));
if (temp >=0.00) {
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))) + temp;
datas.put("LaborHoursData|" + resourceid + "|workday" , attendanceHours);
} else {
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0)));
datas.put("LaborHoursData|" + resourceid + "|workday" , attendanceHours);
}
}
//休息日
if (changeType == 3 ) {
double temp = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + resourceid + "|restday")));
if (temp >=0.00) {
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))) + temp;
datas.put("LaborHoursData|" + resourceid + "|restday" , attendanceHours);
} else {
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0)));
datas.put("LaborHoursData|" + resourceid + "|restday" , attendanceHours);
}
}
}
}
//获取加班时长
Map<String, Object> overTimeDataNew = this.getFlowOverTimeDataNew(params, user);
for (Entry<String, Object> entry : overTimeDataNew.entrySet()) {
String key = entry.getKey();
double value = Util.getDoubleValue(Util.null2String(entry.getValue()), 0.00);
String[] split = key.split("\\|");
if (split[1].contains("holiday")) {
double doubleValue = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + split[0] + "|holiday")), 0.00);
datas.put("LaborHoursData|" + split[0] + "|holiday" , doubleValue + value);
}
if (split[1].contains("workingDay")) {
double doubleValue = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + split[0] + "|workday")), 0.00);
datas.put("LaborHoursData|" + split[0] + "|workday" , doubleValue + value);
}
if (split[1].contains("restDay")) {
double doubleValue = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + split[0] + "|restday")), 0.00);
datas.put("LaborHoursData|" + split[0] + "|restday" , doubleValue + value);
}
}
}catch (Exception e){
writeLog(e);
basebean.writeLog("getLaborHoursData Exception:" + e);
}
basebean.writeLog("getLaborHoursData datas:" + datas);
return datas;
}
public Map<String,Object> getHoliDurationData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
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");
}
}
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 b.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and b.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and a.resourceid in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and b.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and b.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and b.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and b.loginid<>'' ");
}
/*考勤二开--公休时长统计start*/
String offdutyId = Util.null2String(PropBean.getUfPropValue("shift.offduty.id"),"7");
basebean.writeLog("offdutyId: " + offdutyId);
/*考勤二开--公休时长统计end*/
sql = " select a.resourceid, count(*) as number from kq_format_total a left join hrmresource b on b.id = a. resourceid" +
" where a.serialid = " + offdutyId + " " + sqlWhere;
basebean.writeLog("getHoliDurationData sql: " + sql);
rs.executeQuery(sql);
while (rs.next()) {
int number = Util.getIntValue(Util.null2String(rs.getString("number")));
String resourceid = Util.null2String(rs.getString("resourceid"));
datas.put("HoliDurationData|" + resourceid, number);
}
}catch (Exception e){
writeLog(e);
basebean.writeLog("getHoliDurationData Exception:" + e);
}
basebean.writeLog("getHoliDurationData datas:" + datas);
return datas;
}
@ -479,11 +724,11 @@ public class KQReportBiz extends BaseBean {
while (rs.next()) {
double duration = Util.getDoubleValue(Util.null2String(rs.getString("duration")));
if ( duration > 0.00){
double temp = Util.getDoubleValue(Util.null2String(datas.get("ToComLeaveData|" + resourceId)));
double temp = Util.getDoubleValue(Util.null2String(datas.get("-ToComLeaveData|" + resourceId)));
if (temp <= 0.00) {
datas.put("ToComLeaveData|" + resourceId, duration);
datas.put("-ToComLeaveData|" + resourceId, duration);
} else {
datas.put("ToComLeaveData|" + resourceId, temp + duration);
datas.put("-ToComLeaveData|" + resourceId, temp + duration);
}
}
}
@ -496,6 +741,168 @@ public class KQReportBiz extends BaseBean {
return datas;
}
/**
* --
* @param params
* @param user
* @return
*/
public Map<String,Object> getAbnAttToComLeaveData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
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");
}
}
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<>'' ");
}
sql = sql = " select * from (select a.resourceId, a.duration, a.belongDate, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " +
" from uf_AbnAttToComLeave a left join hrmresource b on b.id = a.resourceid " +
" where a.belongdate >='" + fromDate + "' and a.belongdate <='" + toDate + "' ) c where 1=1 " + sqlWhere;
basebean.writeLog("getAbnAttToComLeaveData sql: " + sql);
rs.executeQuery(sql);
while (rs.next()) {
double duration = Util.getDoubleValue(Util.null2String(rs.getString("duration")));
String resId = Util.null2String(rs.getString("resourceId"));
if ( duration > 0.00){
double temp = Util.getDoubleValue(Util.null2String(datas.get("-AbnAttToComLeaveData|" + resId )));
if (temp <= 0.00) {
datas.put("-AbnAttToComLeaveData|" + resId , duration);
} else {
datas.put("-AbnAttToComLeaveData|" + resId , temp + duration);
}
}
}
}catch (Exception e){
writeLog(e);
}
basebean.writeLog("getAbnAttToComLeaveData datas:" + datas);
return datas;
}
public Map<String,Object> getDailyAbnAttToComLeaveData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
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");
}
}
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<>'' ");
}
sql = " select * from (select a.resourceId, a.duration, a.belongDate, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " +
" from uf_AbnAttToComLeave a left join hrmresource b on b.id = a.resourceid " +
" where a.belongdate >='" + fromDate + "' and a.belongdate <='" + toDate + "' ) c where 1=1 " + sqlWhere;
basebean.writeLog("getDailyAbnAttToComLeaveData sql: " + sql);
rs.executeQuery(sql);
while (rs.next()) {
double duration = Util.getDoubleValue(Util.null2String(rs.getString("duration")));
String kqdate = Util.null2String(rs.getString("belongDate"));
String resId = Util.null2String(rs.getString("resourceId"));
if ( duration > 0.00){
double temp = Util.getDoubleValue(Util.null2String(datas.get("DailyAbnAttToComLeaveData|" + resId + "|" + kqdate)));
if (temp <= 0.00) {
datas.put("DailyAbnAttToComLeaveData|" + resId + "|" + kqdate, duration);
} else {
datas.put("DailyAbnAttToComLeaveData|" + resId + "|" + kqdate, temp + duration);
}
}
}
}catch (Exception e){
writeLog(e);
}
basebean.writeLog("getDailyAbnAttToComLeaveData datas:" + datas);
return datas;
}
public Map<String,Object> getDailyToComLeaveData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();
@ -548,8 +955,8 @@ public class KQReportBiz extends BaseBean {
sqlWhere += " and c.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and c.loginid<>'' ");
}
sql = " select * from (select * from uf_casleave a left join hrmresource on a.resourceid = b.id " +
" where a.startdate >='" + fromDate + "' and a.enddate <='" + toDate +"' and (isdecu = 0 or isdecu is null ) ) c where 1=1 " + sqlWhere;
sql = " select * from (select * from uf_casleave a left join hrmresource b on a.resourceid = b.id " +
" where a.startdate >='" + fromDate + "' and a.enddate <='" + toDate +"' and ( a.isdecu = 0 or a.isdecu is null ) ) c where 1=1 " + sqlWhere;
basebean.writeLog("getDailyToComLeaveData sql: " + sql);
rs.executeQuery(sql);

@ -0,0 +1,128 @@
package com.engine.kq.cmd.balanceofleavedetail;
import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQLeaveRulesBiz;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import weaver.general.PageIdConst;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class GetSearchListCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetSearchListCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
/*人员ID*/
String resourceId = Util.null2String(params.get("resourceId"));
/*搜索条件中的年份*/
String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值
String searchYear = Util.null2String(params.get("searchYear"));//年份
if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) {
searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4);
}
//假期类型的ID
String leaveRulesId = Util.null2String(params.get("ruleId"));
if (resourceId.equals("") || searchYear.equals("") || leaveRulesId.equals("")) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误
return resultMap;
}
boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId);
KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo();
//调休的单位
String unitName = rulesComInfo.getUnitName(leaveRulesId, user.getLanguage());
/**********************************************************************************************************/
boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限
boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限
boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限
/**********************************************************************************************************/
String backFields = " b.id,a.lastName,b.belongYear,b.belongMonth,b.overtimeType,b.baseAmount,b.extraAmount,b.usedAmount,0 as invalidAmount,0 as restAmount,b.effectiveDate,b.expirationDate,b.tiaoxiuamount,CASE " +
" WHEN c.changetype = 1 THEN '节假日' " +
" WHEN c.changetype = 2 THEN '工作日' " +
" WHEN c.changetype = 3 THEN '休息日' " +
" ELSE '未知' END as changetype ";
String sqlFrom = " from HrmResource a,KQ_BalanceOfLeave b, kq_flow_overtime c ";
String sqlWhere = " where 1=1 and a.id=b.resourceId and (isDelete is null or isDelete<>1) ";
String orderBy = " b.belongYear asc,b.expirationDate asc,b.id asc ";
if (!resourceId.equals("")) {
sqlWhere += " and a.id in (" + resourceId + ")";
}
if (!searchYear.equals("")) {
sqlWhere += " and b.belongYear='" + searchYear + "' ";
}
if (!leaveRulesId.equals("")) {
sqlWhere += " and b.leaveRulesId=" + leaveRulesId;
}
String pageUid = "b29847fa-6877-f7bd-f12b-5d3a35183b25";
String operateString = "";
operateString = "<operates width=\"20%\">";
operateString += "<popedom transmethod=\"weaver.hrm.common.SplitPageTagOperate.getBasicOperate\" otherpara=\"" + canEdit + ":" + canDelete + ":" + canLog + "\"></popedom> ";
operateString += " <operate href=\"javascript:openDialog();\" text=\"" + SystemEnv.getHtmlLabelName(93, user.getLanguage()) + "\" index=\"0\"/>";
operateString += " <operate href=\"javascript:doDel()\" text=\"" + SystemEnv.getHtmlLabelName(91, user.getLanguage()) + "\" index=\"1\"/>";
operateString += " <operate href=\"javascript:onLog()\" text=\"" + SystemEnv.getHtmlLabelName(83, user.getLanguage()) + "\" index=\"2\"/>";
operateString += "</operates>";
String tiaoxiuColString = "";
if(isTiaoXiu){
tiaoxiuColString =" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(126739, user.getLanguage()) + "\" column=\"tiaoxiuamount\" transmethod=\"com.engine.kq.util.KQTransMethod.getTiaoxiuamountShow\" />";
tiaoxiuColString = tiaoxiuColString + " <col width=\"10%\" text=\"" + "加班类型" + "\" column=\"changetype\" />";
}
String tableString = "" +
"<table pageId=\"KQ:BalanceDetailList\" pageUid=\"" + pageUid + "\" tabletype=\"checkbox\" pagesize=\"" + PageIdConst.getPageSize("KQ:BalanceDetailList", user.getUID(), PageIdConst.HRM) + "\" >" +
"<sql backfields=\"" + backFields + "\" sqlform=\"" + sqlFrom + "\" sqlwhere=\"" + Util.toHtmlForSplitPage(sqlWhere) + "\" sqlorderby=\"" + orderBy + "\" sqlprimarykey=\"id\" sqlsortway=\"asc\" sqlisdistinct=\"false\"/>"
+ operateString +
" <head>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(413, user.getLanguage()) + "\" column=\"lastname\" />" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(15933, user.getLanguage()) + "\" column=\"belongYear\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(887, user.getLanguage()) + "\" column=\"belongMonth\"/>" +
//" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(510282, user.getLanguage()) + "\" column=\"overtimeType\" transmethod=\"com.engine.kq.util.KQTransMethod.getOvertimeTypeShow\" otherpara=\"" + user.getLanguage() + "\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(130286, user.getLanguage()) + unitName + "\" column=\"baseAmount\" transmethod=\"com.engine.kq.util.KQTransMethod.getTotalAmountShow\" otherpara=\"column:extraAmount\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(26642, user.getLanguage()) + unitName + "\" column=\"usedAmount\" transmethod=\"com.engine.kq.util.KQTransMethod.getOriginalShow\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(389611, user.getLanguage()) + unitName + "\" column=\"invalidAmount\" transmethod=\"com.engine.kq.util.KQTransMethod.getInvalidAmountShow\" otherpara=\"column:baseAmount+column:extraAmount+column:usedAmount+column:expirationDate+column:tiaoxiuamount\" />" +
tiaoxiuColString+
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(25723, user.getLanguage()) + unitName + "\" column=\"restAmount\" transmethod=\"com.engine.kq.util.KQTransMethod.getRestAmountShow\" otherpara=\"column:baseAmount+column:extraAmount+column:usedAmount+column:expirationDate+column:tiaoxiuamount\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(508169, user.getLanguage()) + "\" column=\"effectiveDate\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(19547, user.getLanguage()) + "\" column=\"expirationDate\" transmethod=\"com.engine.kq.util.KQTransMethod.getExpirationDateShow\" otherpara=\"" + user.getLanguage() + "\"/>" +
" </head>" +
"</table>";
String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionKey, tableString);
resultMap.put("sessionkey", sessionKey);
} catch (Exception e) {
writeLog(e);
resultMap.put("status", "-1");
resultMap.put("message", e.getMessage());
}
return resultMap;
}
}

@ -5,10 +5,11 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
@ -19,6 +20,7 @@ import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.sskj.comInfo.PropBean;
import weaver.systeminfo.SystemEnv;
import javax.servlet.http.HttpServletRequest;
@ -122,6 +124,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}
}
showColumns = tmpShowColumns;
bb.writeLog("showColumns: " + showColumns);
String today = DateUtil.getCurrentDate();
if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天
@ -262,6 +265,25 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
String calLeaveId = bb.getPropValue("project_sskj", "calLeaveId");
/*考勤二开--转事假end*/
/*考勤二开--公休时长统计start*/
String offdutyId = Util.null2String(PropBean.getUfPropValue("shift.offduty.id"),"7");
bb.writeLog("offdutyId: " + offdutyId);
/*考勤二开--公休时长统计end*/
/*考勤二开--劳务工时start*/
Map<String, Object> empTypes = new HashMap<>();
String empType = Util.null2String(PropBean.getUfPropValue("empType"),"field9");
String acqLaSql = "select id, " + empType + " from cus_fielddata where scopeid = -1 and scope = 'HrmCustomFieldByInfoType'";
rs.executeQuery(acqLaSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
String empTypeValue = Util.null2String(rs.getString(empType));
if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(empTypeValue)) {
empTypes.put(id, empTypeValue);
}
}
/*考勤二开--劳务工时end*/
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
@ -278,6 +300,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
bb.writeLog("-=-=-fieldName: " + fieldName);
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
String fieldValue = "";
if(fieldName.equals("subcompany")){
@ -421,11 +444,26 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyToComLeaveData|" + resourceId + "|" + kqdate)));
bb.writeLog("temp: " + temp);
if (temp >= 0.00) {
flowLeaveData = flowLeaveData + temp;
temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0)));
double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData));
flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp);
}
bb.writeLog("flowLeaveData: " + flowLeaveData);
}
/*考勤二开--转事假end*/
/*考勤二开--异常考勤转事假start*/
if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) {
bb.writeLog("-flowLeaveData: " + flowLeaveData);
double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyAbnAttToComLeaveData|" + id + "|" + kqdate)));
bb.writeLog("-temp: " + temp);
if (temp >= 0.00) {
temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0)));
double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData));
flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp);
}
bb.writeLog("-flowLeaveData: " + flowLeaveData);
}
/*考勤二开--异常考勤转事假end*/
fieldValue = flowLeaveData;
@ -489,7 +527,66 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
}else if(fieldName.equals("kqdate")){
} else if ("holiDuration".equals(fieldName)) {//考勤二开--公休时长统计
bb.writeLog("holiDuration");
String serialid = Util.null2String(rs.getString("serialid"));
bb.writeLog("serialid: " + serialid);
if (offdutyId.equals(serialid)) {
fieldValue = "8";
} else {
fieldValue = "0";
}
bb.writeLog("fieldValue: " + fieldValue);
data.add(fieldValue);
continue;
} else if ("laborHours".equals(fieldName) ) {
bb.writeLog("laborHours");
bb.writeLog("fieldName: " + fieldName);
int emp = Util.getIntValue(Util.null2String(empTypes.get(id)));
bb.writeLog("id: " + id);
bb.writeLog("emp: " + emp);
if (emp == 0) {
double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendanceMins / 60.0)));
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendanceHours + workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
int changeType = KQOvertimeRulesBiz.getChangeType(id, kqdate);
if (changeType == 1 ) {
data.add( fieldValue);
data.add( "0");
data.add( "0");
}
if (changeType == 2 ) {
data.add( "0");
data.add( fieldValue);
data.add( "0");
}
if (changeType == 3 ) {
data.add( "0");
data.add( "0");
data.add( fieldValue);
}
data.add( fieldValue);
}
continue;
} else if(fieldName.equals("kqdate")){
fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate));
} else {
fieldValue = Util.null2String(rs.getString(fieldName));

@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.biz.*;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.UtilKQ;
@ -398,7 +398,30 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
data.add(flowLeaveData);
}
continue;
}else if(fieldName.equals("overtime")){
} else if("holiDuration".equals(fieldName)){
int intValue = Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id)));
if (intValue >= 0) {
data.add(intValue);
} else {
data.add("0");
}
continue;
}else if ("laborHours".equals(fieldName) ) {
double holidayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|holiday")), 0.00);
double workdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|workday")), 0.00);
double restdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|restday")), 0.00);
double total = holidayValue + workdayValue + restdayValue;
fieldValue = String.valueOf(total);
data.add(holidayValue);
data.add(workdayValue);
data.add(restdayValue);
data.add(fieldValue);
continue;
} else if(fieldName.equals("overtime")){
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave"))));

@ -6,12 +6,13 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
@ -21,6 +22,7 @@ import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.sskj.comInfo.PropBean;
import weaver.systeminfo.SystemEnv;
import java.math.BigDecimal;
@ -237,6 +239,25 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
String calLeaveId = bb.getPropValue("project_sskj", "calLeaveId");
/*考勤二开--转事假end*/
/*考勤二开--公休时长统计start*/
String offdutyId = Util.null2String(PropBean.getUfPropValue("shift.offduty.id"),"7");
bb.writeLog("offdutyId: " + offdutyId);
/*考勤二开--公休时长统计end*/
/*考勤二开--劳务工时start*/
Map<String, Object> empTypes = new HashMap<>();
String empType = Util.null2String(PropBean.getUfPropValue("empType"),"field9");
String acqLaSql = "select id, " + empType + " from cus_fielddata where scopeid = -1 and scope = 'HrmCustomFieldByInfoType'";
rs.executeQuery(acqLaSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
String empTypeValue = Util.null2String(rs.getString(empType));
if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(empTypeValue)) {
empTypes.put(id, empTypeValue);
}
}
/*考勤二开--劳务工时end*/
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
@ -252,10 +273,12 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
data = new HashMap<>();
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))
continue;
String fieldName = kqReportFieldComInfo.getFieldname();
String fieldValue = "";
if (fieldName.equals("subcompany")) {
String fieldValueID = rs.getString("subcompanyid");
@ -356,6 +379,56 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
} else {
data.put(fieldName, "异常");
}
} else if ("holiDuration".equals(fieldName)) {//考勤二开--公休时长统计
bb.writeLog("holiDuration");
String serialid = Util.null2String(rs.getString("serialid"));
bb.writeLog("serialid: " + serialid);
if (offdutyId.equals(serialid)) {
fieldValue = "8";
} else {
fieldValue = "0";
}
bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
} else if ("laborHours".equals(kqReportFieldComInfo.getParentid()) ) {
int emp = Util.getIntValue(Util.null2String(empTypes.get(id)));
if (emp == 0) {
double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendanceMins / 60.0)));
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendanceHours + workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
int changeType = KQOvertimeRulesBiz.getChangeType(id, kqdate);
if (changeType == 1 && "holiday".equals(fieldName) ) {
data.put(fieldName, fieldValue);
}
if (changeType == 2 && "workday".equals(fieldName) ) {
data.put(fieldName, fieldValue);
}
if (changeType == 3 && "restday".equals(fieldName) ) {
data.put(fieldName, fieldValue);
}
data.put("laborHoursTotal", fieldValue);
}
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) {
@ -406,14 +479,29 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
/*考勤二开--转事假start*/
if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) {
bb.writeLog("flowLeaveData: " + flowLeaveData);
double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyToComLeaveData|" + resourceId + "|" + kqdate)));
double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyToComLeaveData|" + id + "|" + kqdate)));
bb.writeLog("temp: " + temp);
if (temp >= 0.00) {
flowLeaveData = flowLeaveData + temp;
temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0)));
double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData));
flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp);
}
bb.writeLog("flowLeaveData: " + flowLeaveData);
}
/*考勤二开--转事假end*/
/*考勤二开--异常考勤转事假start*/
if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) {
bb.writeLog("-flowLeaveData: " + flowLeaveData);
double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyAbnAttToComLeaveData|" + id + "|" + kqdate)));
bb.writeLog("-temp: " + temp);
if (temp >= 0.00) {
temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0)));
double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData));
flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp);
}
bb.writeLog("-flowLeaveData: " + flowLeaveData);
}
/*考勤二开--异常考勤转事假end*/
data.put(flowType, flowLeaveData);
}

@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.biz.*;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import weaver.common.DateUtil;
@ -194,7 +194,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
if(rs.getDBType().equals("oracle")){
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
}
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
String sqlWhere = rightSql;
@ -289,12 +289,10 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
} else if (rs.getDBType().equals("mysql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
}
else if (rs.getDBType().equals("postgresql")) {
} else if (rs.getDBType().equals("postgresql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize);
}
else {
} else {
orderBy = " order by dsporder asc, lastname asc ";
descOrderBy = " order by dsporder desc, lastname desc ";
if (pageIndex > 1) {
@ -384,7 +382,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
for(int i=0;serialIds!=null&&i<serialIds.size();i++){
data.put(serialIds.get(i), kqReportBiz.getSerialCount(id,fromDate,toDate,serialIds.get(i)));
}
}else if(kqReportFieldComInfo.getParentid().equals("overtime")||kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
} else if(kqReportFieldComInfo.getParentid().equals("overtime")||kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
||kqReportFieldComInfo.getParentid().equals("overtime_4leave")||fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
if(fieldName.equals("overtimeTotal")){
writeLog("howeccccccccccccggggggg12"+ System.currentTimeMillis());
@ -429,7 +427,38 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
}else{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
}
}else if("holiDuration".equals(fieldName)){
int intValue = Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id)));
if (intValue >= 0) {
data.put(fieldName,intValue);
} else {
data.put(fieldName,"0");
}
} else if ("laborHours".equals(kqReportFieldComInfo.getParentid()) ) {
if ("laborHoursTotal".equals(fieldName)) {
//
double holidayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|holiday")), 0.00);
double workdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|workday")), 0.00);
double restdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|restday")), 0.00);
//
double total = holidayValue + workdayValue + restdayValue;
bb.writeLog("--total: " +total);
//
// data.put("holiday", holidayValue);
// data.put("workday", workdayValue);
// data.put("restday", restdayValue);
fieldValue = String.valueOf(total);
}else {
double temp = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|" + fieldName)), 0.00);
fieldValue = String.valueOf(temp);
}
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) {
if(fieldValue.length() == 0){
@ -441,8 +470,10 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
}
}
}
data.put(fieldName,fieldValue);
}
bb.writeLog("--end data: " +data);
writeLog("howeccccccccccccggggggg13"+ System.currentTimeMillis());
//请假
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
@ -479,6 +510,34 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
}else{
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0)));
}
/*考勤二开--转事假start*/
if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) {
bb.writeLog("flowLeaveData: " + flowLeaveData);
double temp = Util.getDoubleValue(Util.null2String(flowData.get("-ToComLeaveData|" + id)));
bb.writeLog("temp: " + temp);
if (temp >= 0.00) {
temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0)));
double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData));
flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp);
}
bb.writeLog("flowLeaveData: " + flowLeaveData);
}
/*考勤二开--转事假end*/
/*考勤二开--异常考勤转事假start*/
if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) {
bb.writeLog("-flowLeaveData: " + flowLeaveData);
double temp = Util.getDoubleValue(Util.null2String(flowData.get("-AbnAttToComLeaveData|" + id )));
bb.writeLog("-temp: " + temp);
if (temp >= 0.00) {
temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0)));
double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData));
flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp);
}
bb.writeLog("-flowLeaveData: " + flowLeaveData);
}
/*考勤二开--异常考勤转事假end*/
data.put(flowType,flowLeaveData);
}
@ -553,6 +612,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
}
datas.add(data);
}
bb.writeLog("--datas: " +datas);
List<Object> lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate);
retmap.put("holidays", lsHolidays);

@ -0,0 +1,78 @@
package com.engine.kq.cmd.reportdetial;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQAttFlowSetBiz;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.Map;
/***
*
*/
public class GetLeaveInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetLeaveInfoCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String dialogTitle = "";
String type = Util.null2String(params.get("type"));
if(type.equals("leave")||type.startsWith("leaveType_")){//请假
dialogTitle = SystemEnv.getHtmlLabelName(20092, user.getLanguage());
if(type.startsWith("leaveType_")) {
String[] typeInfo = Util.splitString(type, "_");
if (typeInfo[0].equals("leaveType")) {
params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype());
}
params.put("newleavetype", typeInfo[1]);
}else{
params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype());
}
}else{
if(type.equals("overtimeTotal")){//加班
dialogTitle = SystemEnv.getHtmlLabelName(33501, user.getLanguage());
params.put("kqtype",KqSplitFlowTypeEnum.OVERTIME.getFlowtype());
}else if(type.equals("businessLeave")){//出差
dialogTitle = SystemEnv.getHtmlLabelName(20093, user.getLanguage());
params.put("kqtype",KqSplitFlowTypeEnum.EVECTION.getFlowtype());
}else if(type.equals("officialBusiness")){//公出
dialogTitle = SystemEnv.getHtmlLabelName(20094, user.getLanguage());
params.put("kqtype",KqSplitFlowTypeEnum.OUT.getFlowtype());
}else if(type.equals("leaveDeduction")){//异常冲抵
dialogTitle = SystemEnv.getHtmlLabelName(391404, user.getLanguage());
params.put("kqtype",KqSplitFlowTypeEnum.OTHER.getFlowtype());
}
}
retmap.put("dialogTitle",dialogTitle);
retmap.put("sessionkey",new KQAttFlowSetBiz().buildFlowSetTableString(params, user));
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,359 @@
package com.engine.kq.cmd.shiftschedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQShiftManagementComInfo;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.ExcelUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletRequest request;
private HttpServletResponse response;
BaseBean bb = new BaseBean();
public ExportExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
this.params = params;
this.request = request;
this.response = response;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return retmap;
}
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String status = Util.null2String(jsonObj.get("status"));
String groupId = Util.null2String(jsonObj.get("groupId"));//考勤组id
String kqMonth = Util.null2String(jsonObj.get("kqMonth"));//年月
String viewscope = Util.null2String(jsonObj.get("viewscope"));
String startDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
String endDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
LinkedHashMap<String, Object> workbook = new LinkedHashMap<>();
List<Object> lsSheet = new ArrayList<>();
Map<String, Object> sheet = null;
List<Object> titleList = null;
Map<String,Object> title = null;
List<List<Object>> dataList = null;
List<Object> data = null;
List<Map<String,Object>> constraintList = null;
Map<String,Object> constraint = null;
sheet = new HashMap<>();
sheet.put("sheetName", SystemEnv.getHtmlLabelName(389516, user.getLanguage()));
sheet.put("sheetTitle", Util.formatMultiLang(kqGroupComInfo.getGroupname(groupId), user.getLanguage() + "")+SystemEnv.getHtmlLabelName(389516, user.getLanguage()));
boolean isEnd = false;
Calendar cal = DateUtil.getCalendar();
//部门 工号 姓名
titleList = new ArrayList<>();
title = new HashMap<>();
title.put("title",SystemEnv.getHtmlLabelName(124, user.getLanguage()));
title.put("width",30*256);
titleList.add(title);
title = new HashMap<>();
title.put("title",SystemEnv.getHtmlLabelName(714, user.getLanguage()));
title.put("width",15*256);
titleList.add(title);
title = new HashMap<>();
title.put("title",SystemEnv.getHtmlLabelName(413, user.getLanguage()));
title.put("width",15*256);
titleList.add(title);
int firstRow = 6;
int endRow = 0;
int firstCol = 3;
int endCol = 0;
for(String date=startDate; !isEnd;) {
if (date.equals(endDate)) isEnd = true;
title = new HashMap<>();
title.put("title",date);
title.put("width",16*256);
titleList.add(title);
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
endCol = titleList.size()+firstCol;
sheet.put("titleList", titleList);
Map<String,Object> mapShiftSchedule = new HashMap<>();
String tmpSerialids = "";
sql = " select serialid, resourceid, kqdate from kq_shiftschedule where (isdelete is null or isdelete <> '1') and groupid=? ";
rs.executeQuery(sql,groupId);
while(rs.next()){
mapShiftSchedule.put(rs.getString("kqdate")+"|"+rs.getString("resourceid"),rs.getString("serialid"));
if((","+tmpSerialids+",").indexOf(","+rs.getString("serialid")+",")==-1 && rs.getInt("serialid")>0) {
if (tmpSerialids.length() > 0) tmpSerialids += ",";
tmpSerialids += rs.getString("serialid");
}
}
List<Object> sheetMemo = new ArrayList<>();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
sheetMemo.add(SystemEnv.getHtmlLabelName(390620, user.getLanguage()));
List<String> tmpserialids = Util.splitString2List( Util.null2String(kqGroupComInfo.getSerialids(groupId)),",");
tmpSerialids = "" ;
if(tmpSerialids != null){
for(String ts : tmpserialids){
if(tmpSerialids.length() > 0) tmpSerialids += "," ;
tmpSerialids += ts ;
}
}
sheetMemo.add( Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(tmpSerialids,user.getLanguage()), user.getLanguage()+"")+" "+SystemEnv.getHtmlLabelName(390605, user.getLanguage()));
sheet.put("sheetMemo",sheetMemo);
String sqlWhere = " ";
//考勤二开--权限处理
sqlWhere += getViewDepts(user);
bb.writeLog("schedule exportExcelCmd sqlWhere: " + sqlWhere);
if(viewscope.length()>0){
if(viewscope.equals("1")){//分部
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
sqlWhere += " and t.subcompanyid1 in ("+subCompanyId+") ";
}else if(viewscope.equals("2")){//部门
String departmentId = Util.null2String(jsonObj.get("departmentId"));
sqlWhere += " and t.departmentid in ("+departmentId+") ";
}else if(viewscope.equals("3")){//人员
String resourceId = Util.null2String(jsonObj.get("resourceId"));
sqlWhere += " and t.resourceid in ("+resourceId+") ";
}
}
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));// 是否显示无账号人员
if (!"1".equals(isNoAccount)) {
sqlWhere += " and status in(0,1,2,3) and loginid is not null "+(rs.getDBType().equals("oracle")?"":" and loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and t.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) ";
}
}
if(!Util.null2String(kqGroupComInfo.getExcludecount(groupId)).equals("1")) {
//剔除无需排班人员
String excludeid = Util.null2String(kqGroupComInfo.getExcludeid(groupId));
if (excludeid.length() > 0) {
sqlWhere += " and t.resourceid not in (" + excludeid + ")";
}
}
dataList = new ArrayList<>();
List<String> resList = new ArrayList<>();
sql = " select b.id, b.kqdate, b.serialid, t.resourceid, t.subcompanyid1, t.departmentid, t.loginid from (\n" +
" SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE (a.id=b.typevalue and b.type =1) and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE (a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2) and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE (a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3) and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1'))t) t left join kq_shiftschedule b on t.resourceid=b.resourceid " +
" and t.groupid=b.groupid and (b.isdelete is null or b.isdelete <> '1') and b.kqdate>=? and b.kqdate<=? where t.groupid=? \n " +
sqlWhere +
" order by t.dsporder,t.lastname";
new KQLog().info("ExportExcelCmd:"+sql);
bb.writeLog("schedule ExportExcelCmd sql: " + sql);
rs.executeQuery(sql,startDate,startDate,groupId);
while(rs.next()){
data = new ArrayList<>();
String resourceid = rs.getString("resourceid");
if(resList.contains(resourceid)){
continue;
}
resList.add(resourceid);
data.add(Util.formatMultiLang(departmentComInfo.getDepartmentName(resourceComInfo.getDepartmentID(resourceid)),""+user.getLanguage()));
data.add(Util.formatMultiLang(resourceComInfo.getWorkcode(resourceid),""+user.getLanguage()));
data.add(Util.formatMultiLang(resourceComInfo.getLastname(resourceid),""+user.getLanguage()));
isEnd = false;
for(String date=startDate; !isEnd;) {
if (date.equals(endDate)) isEnd = true;
String serialId = Util.null2String(mapShiftSchedule.get(date+"|"+resourceid));
String serialName = "";
if(serialId.equals("-1")){
serialName = SystemEnv.getHtmlLabelName(26593, user.getLanguage());
}else{
serialName = Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialId),""+user.getLanguage());
}
data.add(serialName);
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
dataList.add(data);
}
endRow = dataList.size()+firstRow;
sheet.put("dataList", dataList);
//增加数据有效性校验
constraintList = new ArrayList<>();
constraint = new HashMap<>();
constraint.put("firstRow",firstRow);
constraint.put("endRow",endRow);
constraint.put("firstCol",firstCol);
constraint.put("endCol",endCol);
List<String> serialids = Util.splitString2List( Util.null2String(kqGroupComInfo.getSerialids(groupId)),",");
serialids.add("-1");
String[] serialnames = new String[serialids.size()];
for(int i=0;i<serialids.size();i++){
if(serialids.get(i).equals("-1")){
serialnames[i] = SystemEnv.getHtmlLabelName(26593, user.getLanguage());
}else{
serialnames[i] = Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialids.get(i)),""+user.getLanguage());
}
}
constraint.put("constraintDatas", serialnames);
constraintList.add(constraint);
sheet.put("constraintList",constraintList);
sheet.put("createFile", "1");
lsSheet.add(sheet);
workbook.put("sheet", lsSheet);
String fileName = "";//SystemEnv.getHtmlLabelName(389978, user.getLanguage()).replace("$groupName$",kqGroupComInfo.getGroupname(groupId));
fileName = fileName.replace("$date$",startDate.replace("-","")+"-"+endDate.replace("-",""));
workbook.put("fileName", fileName);
ExcelUtil ExcelUtil = new ExcelUtil();
Map<String, Object> exportMap = ExcelUtil.export(workbook, request, response);
retmap.putAll(exportMap);
retmap.put("status", "1");
} catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return retmap;
}
@Override
public BizLogContext getLogContext() {
return null;
}
/*考勤二开--权限处理start*/
private String getViewDepts(User user) {
String result = " and 1=1 ";
try {
int userId = user.getUID();
if (userId == 1 ) {
return result;
} else {
List<String> temp = new ArrayList<>();
String acqDeptsSql = "select department from uf_scheauthority where resourceid = ? ";
RecordSet rs = new RecordSet();
rs.executeQuery(acqDeptsSql, userId);
while (rs.next()) {
String department = Util.null2String(rs.getString("department"));
if (StringUtils.isNotBlank(department)) {
temp.add(department);
}
}
if (temp != null & temp.size() > 0) {
String sqlWhere = queryDepartmentSubordinate(temp);
result += " and departmentid in (" + sqlWhere + ")";
}
}
}catch (Exception e) {
bb.writeLog("getViewDepts exception: " +e);
}
return result;
}
public String queryDepartmentSubordinate(List<String> deptids){
bb.writeLog("queryDepartmentSubordinate start");
RecordSet rs = new RecordSet();
List<String> list = new ArrayList<String>();
if(deptids != null && deptids.size() > 0) {
String sql = " select * from hrmdepartment where id in ("+ String.join(",", deptids) +")";
bb.writeLog("sql: " + sql);
rs.executeQuery(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
list.add(id);
bb.writeLog("id: " + id);
bb.writeLog("list: " + list);
addChildDept(list,id);
}
}
bb.writeLog("-=-=-list: " + list);
if(list !=null && list.size()> 0){
String sqlWhere = String.join(",", list);
return sqlWhere;
}else{
return "";
}
}
public void addChildDept(List<String> datasList, String parentid){
bb.writeLog("addChildDept start");
String sql = " select id from hrmdepartment where supdepid="+parentid;
bb.writeLog("sql: " + sql);
List<Map<String,Object>> dataList = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.execute(sql);
while(rs.next()){
String id = Util.null2String(rs.getString("id"));
bb.writeLog("id: " + id);
if(!datasList.contains(id)){
datasList.add(id);
}
bb.writeLog("datasList: " + datasList);
addChildDept(datasList,id);
}
}
/*考勤二开--权限处理end*/
}

@ -0,0 +1,396 @@
package com.engine.kq.cmd.shiftschedule;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.domain.UserInfoFromNJ;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQShiftManagementComInfo;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.log.KQLog;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.util.*;
public class GetShiftScheduleCmd extends AbstractCommonCommand<Map<String, Object>> {
BaseBean bb = new BaseBean();
public GetShiftScheduleCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
Map<String, Object> shiftSchedule = new HashMap<String, Object>();
List<Object> lsDatas = null;
List<Object> lsKeyDatas = null;
Map<String, Object> data = null;
RecordSet rs = new RecordSet();
String sql = "";
try{
//必要的权限判断
if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return retmap;
}
int count = 0;
int pageCount = 0;
int isHavePre = 0;
int isHaveNext = 0;
KQGroupComInfo kQGroupComInfo = new KQGroupComInfo();
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
ResourceComInfo resourceComInfo = new ResourceComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
String status = Util.null2String(params.get("status"));
String groupId = Util.null2String(params.get("groupId"));//考勤组id
String kqMonth = Util.null2String(params.get("kqMonth"));//月份
String viewscope = Util.null2String(params.get("viewscope"));//0总部 1分部 2部门 3人员 4我的下属
int pageIndex = Util.getIntValue(Util.null2String(params.get("pageIndex")), 1);
int pageSize = Util.getIntValue(Util.null2String(params.get("pageSize")), 20);
String year = kqMonth.substring(0,4);
String month = kqMonth.substring(5,7);
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
String serialidStr = Util.null2String(kQGroupComInfo.getSerialids(groupId));
List<String> serialids = new ArrayList<>();
List<Object> lsSerialDatas = new ArrayList<>();
if(serialidStr.length() > 0){
serialids = Util.splitString2List(serialidStr,",");
for(int i=0;i<serialids.size();i++){
data = new HashMap<>();
data.put("id",serialids.get(i));
data.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialids.get(i),user.getLanguage()));
data.put("bgColor",kQShiftManagementComInfo.getColor(serialids.get(i)));
lsSerialDatas.add(data);
}
}
lsDatas = new ArrayList<>();
sql = "select id,shiftcyclename,shiftcycleserialids from kq_group_shiftcycle where groupid = ? order by id asc ";
rs.executeQuery(sql,groupId);
while(rs.next()){
data = new HashMap<>();
data.put("name",Util.null2String(rs.getString("shiftcyclename")));//周期名称,
data.put("serial",Util.splitString(Util.null2String(rs.getString("shiftcycleserialids")),","));//周期顺序例7天一周期
lsDatas.add(data);
}
retmap.put("serialInfo", lsDatas);
lsDatas = KQHolidaySetBiz.getGroupHolidaySetList(groupId,year,month);
retmap.put("holidays", lsDatas);
String sqlWhere = " ";
if(viewscope.length()>0){
if(viewscope.equals("1")){//分部
String subCompanyId = Util.null2String(params.get("subCompanyId"));
sqlWhere += " and t.subcompanyid1 in ("+subCompanyId+") ";
}else if(viewscope.equals("2")){//部门
String departmentId = Util.null2String(params.get("departmentId"));
sqlWhere += " and t.departmentid in ("+departmentId+") ";
}else if(viewscope.equals("3")){//人员
String resourceId = Util.null2String(params.get("resourceId"));
sqlWhere += " and t.resourceid in ("+resourceId+") ";
}
}
String isNoAccount = Util.null2String(params.get("isNoAccount"));// 是否显示无账号人员
if (!"1".equals(isNoAccount)) {
sqlWhere += " and t.status in(0,1,2,3) and t.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and t.loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and t.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) ";
}
}
if(!Util.null2String(kQGroupComInfo.getExcludecount(groupId)).equals("1")) {
//剔除无需排班人员
String excludeid = Util.null2String(kQGroupComInfo.getExcludeid(groupId));
if (excludeid.length() > 0) {
sqlWhere += " and t.resourceid not in (" + excludeid + ")";
}
}
String backFields = " t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid ";
String sqlFrom = " from (SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" +
" UNION ALL " +
" SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')" +
" )t ) t where t.groupid = "+groupId;
String groupBy = " ";
lsKeyDatas = new ArrayList<>();
lsDatas = new ArrayList<>();
// sql = " select b.id, b.kqdate, b.serialid, t.resourceid, t.subcompanyid1, t.departmentid, t.loginid from (\n" +
// " SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" +
// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
// " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" +
// " UNION ALL \n" +
// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
// " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" +
// " UNION ALL \n" +
// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
// " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" +
// " UNION ALL \n" +
// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
// " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" +
// " UNION ALL " +
// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
// " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')" +
// " )t ) t left join kq_shiftschedule b on t.resourceid=b.resourceid and t.groupid = b.groupid and (b.isdelete is null or b.isdelete <> '1') and b.kqdate>=? and b.kqdate<=? where t.groupid=? \n " +
// sqlWhere +
// " order by t.dsporder,t.lastname";
// sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t";
//考勤二开
String newSqlWhere = getViewDepts(user);
sql = " select count(*) as c from ( select 1 as c, departmentid "+sqlFrom+sqlWhere + " and" +newSqlWhere +groupBy+") t";
bb.writeLog("--==--sql: " + sql);
rs.execute(sql);
if (rs.next()){
count = rs.getInt("c");
}
if (count <= 0) {
pageCount = 0;
}
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
String orderBy = " order by t.dsporder asc, t.lastname asc ";
String descOrderBy = " order by t.dsporder desc, t.lastname desc ";
sql = backFields + sqlFrom + sqlWhere + groupBy;
if (pageIndex > 0 && pageSize > 0) {
if (rs.getDBType().equals("oracle")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
} else if (rs.getDBType().equals("mysql")) {
sql = " select * from (select " + sql+") t "+orderBy;
// sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
sql = "select t1.* from (" + sql + ") t1 where " + newSqlWhere + " limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
} else if (rs.getDBType().equals("postgresql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize);
} else {
orderBy = " order by dsporder asc, lastname asc ";
descOrderBy = " order by dsporder desc, lastname desc ";
if (pageIndex > 1) {
int topSize = pageSize;
if (pageSize * pageIndex > count) {
topSize = count - (pageSize * (pageIndex - 1));
}
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
+ (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
} else {
sql = " select top " + pageSize + sql+orderBy;
}
}
} else {
sql = " select " + sql;
}
new KQLog().info("GetShiftScheduleCmd:"+sql);
bb.writeLog("GetShiftScheduleCmd sql: " + sql);
rs.executeQuery(sql);
while(rs.next()){
String resourceid = Util.null2String(rs.getString("resourceid"));
data = new HashMap<>();
data.put("resourceid",resourceid);
data.put("name",resourceComInfo.getLastname(resourceid));
data.put("department",departmentComInfo.getDepartmentname(resourceComInfo.getDepartmentID(resourceid)));
List<Object> shiftScheduleDatas = this.getShiftSchedule(groupId, resourceid, monthBeginDate,monthEndDate);
for(int i=0;shiftScheduleDatas!=null&&i<shiftScheduleDatas.size();i++){
Map<String,Object> shiftScheduleData = (Map<String,Object>)shiftScheduleDatas.get(i);
String id = Util.null2String(shiftScheduleData.get("id"));
String kqdate = Util.null2String(shiftScheduleData.get("kqdate"));
String serialid = Util.null2String(shiftScheduleData.get("serialid"));
if(!serialids.contains(serialid) && !serialid.equals("-1")){
serialids.add(serialid);
Map<String,Object> serialdata = new HashMap<>();
serialdata.put("id",serialid);
serialdata.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialid,user.getLanguage()));
serialdata.put("bgColor",kQShiftManagementComInfo.getColor(serialid));
serialdata.put("isDelete",1);
lsSerialDatas.add(serialdata);
}
data.put(kqdate,serialid);
lsKeyDatas.add(resourceid+"|"+kqdate+"|"+id);
}
lsDatas.add(data);
}
retmap.put("pagesize", pageSize);
retmap.put("pageindex", pageIndex);
retmap.put("count", count);
retmap.put("pagecount", pageCount);
retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext);
retmap.put("datas", lsDatas);
retmap.put("keyDatas", lsKeyDatas);
retmap.put("shiftList", lsSerialDatas);
retmap.put("groupName", kQGroupComInfo.getGroupname(groupId));
retmap.put("today", DateUtil.getCurrentDate());
if(Util.null2String(kQGroupComInfo.getValidity(groupId)).equals("1")){//考勤组设置了有效期
retmap.put("validityFromDate", kQGroupComInfo.getValidityfromdate(groupId));
retmap.put("validityEndDate", kQGroupComInfo.getValidityenddate(groupId));
}
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
private List<Object> getShiftSchedule(String groupid, String resourceid, String monthBeginDate,String monthEndDate){
List<Object> datas = new ArrayList<>();
Map<String,Object> data = null;
String sql = "";
RecordSet rs = new RecordSet();
sql = " select id,kqdate, serialid from kq_shiftschedule where groupid= '"+groupid+"' and resourceid="+resourceid+" " +
" and kqdate>='"+monthBeginDate+"' and kqdate<='"+monthEndDate+"' and (isdelete is null or isdelete <> '1')";
rs.executeQuery(sql);
while(rs.next()){
String id = Util.null2String(rs.getString("id"));
String kqdate = Util.null2String(rs.getString("kqdate"));
String serialid = Util.null2String(rs.getString("serialid"));
data = new HashMap<>();
data.put("id",id);
data.put("kqdate",kqdate);
data.put("serialid",serialid);
datas.add(data);
}
return datas;
}
@Override
public BizLogContext getLogContext() {
return null;
}
/*考勤二开--权限处理start*/
private String getViewDepts(User user) {
String result = " 1=1 ";
try {
int userId = user.getUID();
if (userId == 1 ) {
return result;
} else {
List<String> temp = new ArrayList<>();
String acqDeptsSql = "select department from uf_scheauthority where resourceid = ? ";
RecordSet rs = new RecordSet();
rs.executeQuery(acqDeptsSql, userId);
while (rs.next()) {
String department = Util.null2String(rs.getString("department"));
if (StringUtils.isNotBlank(department)) {
temp.add(department);
}
}
if (temp != null & temp.size() > 0) {
String sqlWhere = queryDepartmentSubordinate(temp);
result += " and departmentid in (" + sqlWhere + ")";
}
}
}catch (Exception e) {
bb.writeLog("getViewDepts exception: " +e);
}
return result;
}
public String queryDepartmentSubordinate(List<String> deptids){
bb.writeLog("queryDepartmentSubordinate start");
RecordSet rs = new RecordSet();
List<String> list = new ArrayList<String>();
if(deptids != null && deptids.size() > 0) {
String sql = " select * from hrmdepartment where id in ("+ String.join(",", deptids) +")";
bb.writeLog("sql: " + sql);
rs.executeQuery(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
list.add(id);
bb.writeLog("id: " + id);
bb.writeLog("list: " + list);
addChildDept(list,id);
}
}
bb.writeLog("-=-=-list: " + list);
if(list !=null && list.size()> 0){
String sqlWhere = String.join(",", list);
return sqlWhere;
}else{
return "";
}
}
public void addChildDept(List<String> datasList, String parentid){
bb.writeLog("addChildDept start");
String sql = " select id from hrmdepartment where supdepid="+parentid;
bb.writeLog("sql: " + sql);
List<Map<String,Object>> dataList = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.execute(sql);
while(rs.next()){
String id = Util.null2String(rs.getString("id"));
bb.writeLog("id: " + id);
if(!datasList.contains(id)){
datasList.add(id);
}
bb.writeLog("datasList: " + datasList);
addChildDept(datasList,id);
}
}
/*考勤二开--权限处理end*/
}

@ -112,13 +112,13 @@ public class EntryServiceImpl extends Service implements EntryService {
return result;
}
if ( "6".equals(entryType) && StringUtils.isEmpty(serviceCompany)) {
if ( "4".equals(entryType) && StringUtils.isEmpty(serviceCompany)) {
result.put("code",500);
result.put("msg","请先选择劳务公司");
return result;
}
if ( "6".equals(entryType)) {//劳务外包
if ( "4".equals(entryType)) {//劳务派遣
//获取劳务公司代码
String compCode = "";
String acqOutCompSql = "select gsdm from uf_lwgs where id = ? ";
@ -142,8 +142,8 @@ public class EntryServiceImpl extends Service implements EntryService {
if ( StringUtils.isBlank(maxNum)) {//该公司该月没有生成最大流程号
SskjUtil sskjUtil =new SskjUtil();
maxNum = "001";
String addMaxNumSql = "insert into uf_OutEmpNum ( outComp, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" +
" values (?,?,?,?,?,?,?,?,?)";
String addMaxNumSql = "insert into uf_OutEmpNum ( prefix, outComp, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" +
" values (?,?,?,?,?,?,?,?,?,?)";
String outEmpNumModeId = basebean.getPropValue("project_sskj", "outEmpNumModeId");
Integer modedatacreater = user.getUID();
Integer modedatacreatertype = user.getType();
@ -151,7 +151,7 @@ public class EntryServiceImpl extends Service implements EntryService {
String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss");
String uuid = UUID.randomUUID().toString();
boolean addFlag = rs.executeUpdate(addMaxNumSql, serviceCompany, entryMonth, maxNum, outEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate,
boolean addFlag = rs.executeUpdate(addMaxNumSql, compCode, serviceCompany, entryMonth, maxNum, outEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate,
modedatacreatetime, uuid);
if (addFlag) {
String billid = "-1";
@ -198,8 +198,8 @@ public class EntryServiceImpl extends Service implements EntryService {
basebean.writeLog("非外包,没有流水");
basebean.writeLog("maxNum" + maxNum);
String addMaxNumSql = "insert into uf_NoOutEmpNum ( entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" +
" values (?,?,?,?,?,?,?,?)";
String addMaxNumSql = "insert into uf_NoOutEmpNum ( prefix, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" +
" values (?,?,?,?,?,?,?,?,?)";
String noOutEmpNumModeId = basebean.getPropValue("project_sskj", "noOutEmpNumModeId");
Integer modedatacreater = user.getUID();
Integer modedatacreatertype = user.getType();
@ -208,7 +208,7 @@ public class EntryServiceImpl extends Service implements EntryService {
String uuid = UUID.randomUUID().toString();
basebean.writeLog("addMaxNumSql" + addMaxNumSql);
boolean addFlag = rs.executeUpdate(addMaxNumSql, entryMonth, maxNum, noOutEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate,
boolean addFlag = rs.executeUpdate(addMaxNumSql, "SSKJ", entryMonth, maxNum, noOutEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate,
modedatacreatetime, uuid);
basebean.writeLog("addFlag" + addFlag);
if (addFlag) {

@ -35,6 +35,25 @@ import static weaver.interfaces.sskj.util.HttpsUtil.doPostJsonRequest;
*/
public class SyncZkKqDataJob extends BaseCronJob {
private String startTime;
private String endTime;
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
@Override
public void execute() {
new BaseBean();
@ -53,13 +72,18 @@ public class SyncZkKqDataJob extends BaseCronJob {
idWorkcodeMap.put(workcode,userId);
}
}
//获取开始时间结束时间
Calendar beforeTime = Calendar.getInstance();
beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间
Date beforeD = beforeTime.getTime();
String startTime = DateUtil.format(beforeD,"yyyy-MM-dd HH:mm:ss");
Date now = new Date();
String endTime = DateUtil.format(now,"yyyy-MM-dd HH:mm:ss");
bb.writeLog("startTime = " + startTime);
bb.writeLog("endTime = " + endTime);
if (StringUtils.isBlank(startTime) && StringUtils.isNotBlank(endTime)) {
Calendar beforeTime = Calendar.getInstance();
beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间
Date beforeD = beforeTime.getTime();
startTime = DateUtil.format(beforeD,"yyyy-MM-dd HH:mm:ss");
Date now = new Date();
endTime = DateUtil.format(now,"yyyy-MM-dd HH:mm:ss");
}
bb.writeLog("startTime:"+startTime);
bb.writeLog("endTime:"+endTime);

Loading…
Cancel
Save