夜班天数计算

新美光HR项目
Chengliang 3 weeks ago
parent aae717c314
commit 1e146c826e

@ -0,0 +1,13 @@
package com.api.xmgsecond.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2025/5/16 15:13
* @Description:
* @Version 1.0
*/
@Path("/xmgsecond/kq/cube")
public class KqCloseAccountAction extends com.engine.xmgsecond.web.KqCloseAccountAction{
}

@ -194,7 +194,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField(); Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle,b.groupid," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + " sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
@ -409,13 +409,16 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
}else if("kqGroup".equals(fieldName)){ }else if("kqGroup".equals(fieldName)){
//QC3685035 考勤月度报表增加所属所属考勤组 //QC3685035 考勤月度报表增加所属所属考勤组
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); // KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(id, toDate); // String groupId = kqGroupMemberComInfo.getKQGroupId(id, toDate);
fieldValue = kqGroupComInfo.getGroupname(groupId); fieldValue = kqGroupComInfo.getGroupname(Util.null2String(rs.getString("groupid")));
}else if("absenteeismDays".equals(fieldName)){ }else if("absenteeismDays".equals(fieldName)){
//QC3685035 考勤月度报表增加缺勤天数 //QC3685035 考勤月度报表增加缺勤天数
List<KqFormatTotal> kqFormatTotalList = KqCalulateUtil.abnormalAttendance(id, fromDate, toDate); List<KqFormatTotal> kqFormatTotalList = KqCalulateUtil.abnormalAttendance(id, fromDate, toDate);
fieldValue = String.format("%.1f", kqFormatTotalList.stream().mapToDouble(KqFormatTotal::getAbsenceDays).sum()); fieldValue = String.format("%.1f", kqFormatTotalList.stream().mapToDouble(KqFormatTotal::getAbsenceDays).sum());
}else if("nigntWork".equals(fieldName)){
//QC3685035 考勤月度报表增加夜班次数
fieldValue = String.valueOf(KqCalulateUtil.nightWorkSums(id,fromDate,toDate));
}else if(fieldName.equals("rlzqqxs")){ }else if(fieldName.equals("rlzqqxs")){
String rlzqqxsTime = getXcqts(fromDate,id); String rlzqqxsTime = getXcqts(fromDate,id);
fieldValue = rlzqqxsTime; fieldValue = rlzqqxsTime;

@ -0,0 +1,16 @@
package com.engine.xmgsecond.service;
import com.engine.workflow.entity.publicApi.PAResponseEntity;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2025/5/16 15:17
* @Description: TODO
* @Version 1.0
*/
public interface KqCloseAccountService {
PAResponseEntity closeAccount(Map<String, Object> param);
}

@ -0,0 +1,50 @@
package com.engine.xmgsecond.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.workflow.entity.publicApi.PAResponseEntity;
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
import com.engine.xmgsecond.service.KqCloseAccountService;
import weaver.general.BaseBean;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2025/5/16 15:18
* @Description: TODO
* @Version 1.0
*/
public class KqCloseAccountServiceImpl extends Service implements KqCloseAccountService {
private WorkflowRequestOperatePA getRequestOperatePA() {
return ServiceUtil.getService(WorkflowRequestOperatePAImpl.class);
}
@Override
public PAResponseEntity closeAccount(Map<String, Object> param) {
WorkflowRequestOperatePA operatePA = getRequestOperatePA();
ReqOperateRequestEntity requestParam = new ReqOperateRequestEntity();
//流程干预
// requestParam.setRequestId(1681681);
// requestParam.setSrc("intervenor");
// requestParam.setWorkflowId(95);
// requestParam.setNodeId(392);
// requestParam.setRemark("考勤干预");
// requestParam.setEnableIntervenor(true);
// requestParam.setSubmitNodeId(391);
// requestParam.setIntervenorid("1");
// PAResponseEntity paResponseEntity = operatePA.doIntervenor(user, requestParam);
//强制归档 DoArchivingCmd
return null;
}
}

@ -2,7 +2,6 @@ package com.engine.xmgsecond.util;
import com.engine.xmgsecond.entity.KqFormatTotal; import com.engine.xmgsecond.entity.KqFormatTotal;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util; import weaver.general.Util;
import java.util.ArrayList; import java.util.ArrayList;
@ -20,7 +19,7 @@ public class KqCalulateUtil {
/** /**
* @Description: * @Description:
* @Author: liang.cheng * @Author: liang.cheng
* @Date: 2025/5/14 16:22 * @Date: 2025/5/14 16:22
* @param: [resourceId, fromDate, toDate] * @param: [resourceId, fromDate, toDate]
@ -70,6 +69,59 @@ public class KqCalulateUtil {
} }
/**
* @Description:
* @Author: liang.cheng
* @Date: 2025/5/16 09:28
* @param: [resourceId, fromDate, toDate]
* @return: int
*/
public static int nightWorkSums(String resourceId,String fromDate,String toDate){
RecordSet rs = new RecordSet();
int count = 0;
rs.executeQuery(" select a.kqdate,a.serialid,a.belatemins,a.leaveearlymins,a.absenteeismmins,a.forgotcheckMins,a.leaveMins,\n" +
" a.evectionMins,a.outMins,b.serial,b.is_rest,b.shiftonoffworkcount from kq_format_total a \n" +
" left join kq_ShiftManagement b on a.serialid = b.id where a.resourceid = ? and a.kqdate >= '"+fromDate+"' and a.kqdate <= '"+toDate+"'",resourceId);
while (rs.next()) {
int serialid = Util.getIntValue(rs.getString("serialid"));
String kqdate = Util.null2String(rs.getString("kqdate"));
if(serialid == -1) {
continue;
}
int isRest = Util.getIntValue(rs.getString("is_rest"));
if (isRest == 1) {
//1.休息班
if (Util.getIntValue(rs.getString("shiftonoffworkcount")) == 1){
//一天一次上下班卡
if (calculateClockTime(resourceId,kqdate,serialid)){
count = count + 1;
}
}
}else {
//2.非休息班
String serial = Util.null2String(rs.getString("serial"));
if (serial.contains("夜班")) {
int beLateMins = Util.getIntValue(rs.getString("beLateMins"),0);
int leaveearlymins = Util.getIntValue(rs.getString("leaveearlymins"),0);
int absenteeismmins = Util.getIntValue(rs.getString("absenteeismmins"),0);
int forgotcheckMins = Util.getIntValue(rs.getString("forgotcheckMins"),0);
int leaveMins = Util.getIntValue(rs.getString("leaveMins"),0);
int evectionMins = Util.getIntValue(rs.getString("evectionMins"),0);
int outMins = Util.getIntValue(rs.getString("outMins"),0);
if (beLateMins == 0 && leaveearlymins == 0 && absenteeismmins == 0 && forgotcheckMins == 0
&& leaveMins == 0 && evectionMins == 0 && outMins == 0) {
count = count + 1;
}
}
}
}
return count;
}
public static boolean isPositive(Integer num) { public static boolean isPositive(Integer num) {
return Optional.ofNullable(num).orElse(0) > 0; return Optional.ofNullable(num).orElse(0) > 0;
} }
@ -94,5 +146,12 @@ public class KqCalulateUtil {
return Optional.ofNullable(a).orElse(0) + Optional.ofNullable(b).orElse(0); return Optional.ofNullable(a).orElse(0) + Optional.ofNullable(b).orElse(0);
} }
public static boolean calculateClockTime(String resourceId,String kqDate,int serialid){
RecordSet rs = new RecordSet();
rs.executeQuery("select resourceid,kqdate,signintime,signouttime from kq_format_detail where kqdate = '"+kqDate+"' and resourceid = ? and serialid = ? \n" +
" and signintime >= '18:00:00' and signintime <= '20:30:00' and signouttime <= '05:30:00'",resourceId,serialid);
return rs.getCounts() > 0;
}
} }

@ -0,0 +1,50 @@
package com.engine.xmgsecond.web;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.xmgsecond.service.KqCloseAccountService;
import com.engine.xmgsecond.service.impl.KqCloseAccountServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2025/5/16 15:15
* @Description: TODO
* @Version 1.0
*/
public class KqCloseAccountAction {
private KqCloseAccountService getService(User user) {
return ServiceUtil.getService(KqCloseAccountServiceImpl.class, user);
}
@GET
@Path("/closeAccount")
@Produces(MediaType.TEXT_PLAIN)
public String closeAccount(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("data",getService(user).closeAccount(ParamUtil.request2Map(request)));
data.put("code", 200);
} catch (Exception e) {
data.put("code", 500);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
}

@ -0,0 +1,23 @@
package weaver.interfaces.xmgsecond;
import weaver.general.BaseBean;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
/**
* @Author liang.cheng
* @Date 2025/5/16 14:25
* @Description: TODO
* @Version 1.0
*/
public class TestWorkAction implements Action {
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
bb.writeLog("TestWorkAction1: 执行流程节点附件操作");
return Action.SUCCESS;
}
}
Loading…
Cancel
Save