Merge remote-tracking branch 'origin/main'
# Conflicts: # src/com/engine/common/util/CommonUtil.javazm_dev
commit
5b933ca3bf
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
package com.api.attendance.workflow;
|
||||
|
||||
import com.engine.attendance.workflow.web.AskForLeaveAction;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* 请假流程
|
||||
*/
|
||||
@Path("/attendance/askforleave")
|
||||
@Slf4j
|
||||
public class AskForLeaveActionApi extends AskForLeaveAction {
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.engine.attendance.workflow.action;
|
||||
|
||||
import com.engine.attendance.workflow.service.MakeUpClockInService;
|
||||
import com.engine.attendance.workflow.service.impl.MakeUpClockInServiceImpl;
|
||||
import com.engine.common.util.CommonUtil;
|
||||
import com.engine.common.util.DateUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 请假流程提交检查
|
||||
*/
|
||||
@Slf4j
|
||||
public class AskForLeaveCheckAction implements Action {
|
||||
private MakeUpClockInService makeUpClockInService = ServiceUtil.getService(MakeUpClockInServiceImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
String requestid = requestInfo.getRequestid();
|
||||
// 流程表单主表数据
|
||||
HashMap<String,String> mainTableData = CommonUtil.getMainTableInfo(requestInfo);
|
||||
// 流程表单明细表数据
|
||||
List<Map<String, String>> detailTableData = CommonUtil.getDetailTableInfo(requestInfo,0);
|
||||
//补打卡人员
|
||||
String qjry = mainTableData.get("qjry");
|
||||
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("userId",qjry);
|
||||
params.put("submitDate", DateUtil.getCurrentDate());
|
||||
|
||||
Map<String,Object> dataMap = makeUpClockInService.getKqCycleTimeIntervalCmd(params);
|
||||
|
||||
List<Map<String,Object>> dateList = (List<Map<String,Object>>)dataMap.get("data");
|
||||
|
||||
boolean status = (boolean)dataMap.get("status");
|
||||
if (!status){
|
||||
log.error("该人员没有考勤周期");
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent("该人员没有考勤周期!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
if (dateList.size()==0){
|
||||
log.error("申请人员当前时间没有考勤周期,请联系管理员!");
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent("申请人员当前时间没有考勤周期,请联系管理员!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
for (Map<String, String> detailTable:detailTableData){
|
||||
String bdkrq = detailTable.get("ksrq");
|
||||
boolean mark = true;
|
||||
for (Map<String,Object> date:dateList){
|
||||
//存在考勤周期内
|
||||
String startDate = Util.null2String(date.get("startDate"));
|
||||
String endDate = Util.null2String(date.get("endDate"));
|
||||
if (DateUtil.getTime(startDate).compareTo(DateUtil.getTime(bdkrq)) <=0 &&
|
||||
DateUtil.getTime(endDate).compareTo(DateUtil.getTime(bdkrq)) >=0){
|
||||
mark = false;
|
||||
}
|
||||
}
|
||||
if (mark){
|
||||
//已关账
|
||||
log.error("补打卡日期:{},已关账无法补打卡",bdkrq);
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent("补打卡日期:"+bdkrq+"所在考勤周期已经关账无法再补打卡!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.engine.attendance.workflow.action.askforleave;
|
||||
|
||||
import com.engine.common.util.CommonUtil;
|
||||
import com.engine.common.util.DbTools;
|
||||
import com.engine.common.util.Utils;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class AskForLeaveWorkFlowArchivingAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
|
||||
// 流程表单主表数据
|
||||
HashMap<String,String> mainTableData = CommonUtil.getMainTableInfo(requestInfo);
|
||||
log.info("mainTableData : [{}]",mainTableData);
|
||||
// 流程表单明细表1数据
|
||||
List<Map<String, String>> detailTableData = CommonUtil.getDetailTableInfo(requestInfo,0);
|
||||
log.info("detailTableData : [{}]",detailTableData);
|
||||
|
||||
//流程表单明细表2数据
|
||||
List<Map<String, String>> detailTable2 = CommonUtil.getDetailTableInfo(requestInfo,1);
|
||||
log.info("detailTableData : [{}]",detailTable2);
|
||||
|
||||
|
||||
//请假人员
|
||||
String qjry = mainTableData.get("qjry");
|
||||
//实际假期类型
|
||||
String jqlx = mainTableData.get("sjqjlx");
|
||||
//第一笔开始时间
|
||||
String firstStartDate = detailTableData.get(0).get("ksrq");
|
||||
|
||||
String sql = "select id,jqid,sxrq,ktsc,yxsc,wxsc,yqsxrq,ztsc from uf_jcl_kq_jqye where ygid=? and jqid=? and sxrq<=? and yqsxrq>=? order by sxrq";
|
||||
|
||||
List<Map<String,Object>> holidayBalanceList = DbTools.getSqlToList(sql,qjry,jqlx,firstStartDate,firstStartDate);
|
||||
|
||||
Map<String,Object> holidayBalanceMap = holidayBalanceList.stream().collect(Collectors.toMap(e->e.get("id").toString(), e->e));
|
||||
|
||||
|
||||
try {
|
||||
Map<String,Object> balanceMap = Maps.newHashMap();
|
||||
for (Map<String, String> data : detailTable2){
|
||||
String jqye = Util.null2String(data.get("jqye"));
|
||||
double sysc = Double.valueOf(data.get("sysc").toString());
|
||||
double havedSysc= balanceMap.get(jqye) ==null?0:Double.valueOf(balanceMap.get(jqye).toString());
|
||||
sysc = Utils.add(sysc,havedSysc);
|
||||
balanceMap.put(jqye,sysc);
|
||||
}
|
||||
|
||||
for (Map.Entry<String,Object> entry:balanceMap.entrySet()){
|
||||
String id = entry.getKey();
|
||||
double ztsc = Double.valueOf(entry.getValue().toString());
|
||||
Map<String,Object> map = (Map<String,Object>)holidayBalanceMap.get(id);
|
||||
|
||||
double havedztsc = Util.null2String(map.get("ztsc")).equals("") ? 0 : Double.valueOf(map.get("ztsc").toString());
|
||||
double havedyxsc = Util.null2String(map.get("yxsc")).equals("") ? 0 : Double.valueOf(map.get("yxsc").toString());
|
||||
|
||||
double updatedztsc = Utils.subtract(havedztsc,ztsc);
|
||||
double updatedwxsc = Utils.add(havedyxsc,ztsc);
|
||||
|
||||
String updateSql = "update uf_jcl_kq_jqye set yxsc=?,ztsc=? where id=?";
|
||||
if (!DbTools.update(updateSql,updatedwxsc,updatedztsc,id)){
|
||||
//更新假期余额失败
|
||||
String message = "更新假期余额失败";
|
||||
log.error(message);
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestInfo.getRequestid() + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("AskForLeaveWorkFlowSubmitAction error : [{}]",e);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,213 @@
|
||||
package com.engine.attendance.workflow.action.askforleave;
|
||||
|
||||
import com.engine.attendance.enums.AccountingUnitEnum;
|
||||
import com.engine.attendance.enums.CheckBoxEnum;
|
||||
import com.engine.attendance.workflow.enums.AskAndEvctionWayEnum;
|
||||
import com.engine.attendance.workflow.service.MakeUpClockInService;
|
||||
import com.engine.attendance.workflow.service.impl.MakeUpClockInServiceImpl;
|
||||
import com.engine.common.util.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class AskForLeaveWorkFlowSubmitAction implements Action {
|
||||
private MakeUpClockInService makeUpClockInService = ServiceUtil.getService(MakeUpClockInServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
String requestid = requestInfo.getRequestid();
|
||||
|
||||
try {
|
||||
|
||||
// 流程表单主表数据
|
||||
HashMap<String, String> mainTableData = CommonUtil.getMainTableInfo(requestInfo);
|
||||
log.info("mainTableData : [{}]", mainTableData);
|
||||
// 流程表单明细表1数据
|
||||
List<Map<String, String>> detailTableData = CommonUtil.getDetailTableInfo(requestInfo, 0);
|
||||
log.info("detailTableData : [{}]", detailTableData);
|
||||
|
||||
String detail2TableName = requestInfo.getDetailTableInfo().getDetailTable()[1].getTableDBName();
|
||||
log.info("detail2TableName : [{}]", detail2TableName);
|
||||
//请假人员
|
||||
String qjry = mainTableData.get("qjry");
|
||||
//实际假期类型
|
||||
String jqlx = mainTableData.get("sjqjlx");
|
||||
//第一笔开始时间
|
||||
String firstStartDate = detailTableData.get(0).get("ksrq");
|
||||
|
||||
List<Map<String, Object>> detailTable2 = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* 考勤周期校验
|
||||
*/
|
||||
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("userId", qjry);
|
||||
params.put("submitDate", DateUtil.getCurrentDate());
|
||||
|
||||
Map<String, Object> dataMap = makeUpClockInService.getKqCycleTimeIntervalCmd(params);
|
||||
|
||||
List<Map<String, Object>> dateList = (List<Map<String, Object>>) dataMap.get("data");
|
||||
|
||||
boolean status = (boolean) dataMap.get("status");
|
||||
if (!status) {
|
||||
log.error("该人员没有考勤周期");
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent("该人员没有考勤周期!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
if (dateList.size() == 0) {
|
||||
log.error("申请人员当前时间没有考勤周期,请联系管理员!");
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent("申请人员当前时间没有考勤周期,请联系管理员!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
for (Map<String, String> detailTable : detailTableData) {
|
||||
String bdkrq = detailTable.get("ksrq");
|
||||
boolean mark = true;
|
||||
for (Map<String, Object> date : dateList) {
|
||||
//存在考勤周期内
|
||||
String startDate = Util.null2String(date.get("startDate"));
|
||||
String endDate = Util.null2String(date.get("endDate"));
|
||||
if (DateUtil.getTime(startDate).compareTo(DateUtil.getTime(bdkrq)) <= 0 &&
|
||||
DateUtil.getTime(endDate).compareTo(DateUtil.getTime(bdkrq)) >= 0) {
|
||||
mark = false;
|
||||
}
|
||||
}
|
||||
if (mark) {
|
||||
//已关账
|
||||
log.error("请假日期:{},已关账无法提交", bdkrq);
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent("请假日期:" + bdkrq + "不在当前月份对应考勤周期内无法再提交请假!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 假期校验及入库
|
||||
*/
|
||||
String sql = "select id,jqid,sxrq,ktsc,yxsc,wxsc,yqsxrq,ztsc from uf_jcl_kq_jqye where ygid=? and jqid=? and sxrq<=? and yqsxrq>=? order by sxrq";
|
||||
|
||||
List<Map<String, Object>> holidayBalanceList = DbTools.getSqlToList(sql, qjry, jqlx, firstStartDate, firstStartDate);
|
||||
|
||||
Map<String, Object> holidayBalanceMap = holidayBalanceList.stream().collect(Collectors.toMap(e -> e.get("id").toString(), e -> e));
|
||||
|
||||
sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb from uf_jcl_kq_kqxm where id=?";
|
||||
|
||||
Map<String, Object> holidayItem = DbTools.getSqlToMap(sql, jqlx);
|
||||
|
||||
//假期核算单位
|
||||
String hsdw = Util.null2String(holidayItem.get("hsdw"));
|
||||
//请假方式
|
||||
String cxjqj = mainTableData.get("cxjqj");
|
||||
|
||||
for (Map<String, String> detailData : detailTableData) {
|
||||
String ksrq = detailData.get("ksrq");
|
||||
//请假时间
|
||||
double leaveDuration = 0;
|
||||
if (cxjqj.equals(AskAndEvctionWayEnum.ALLDAY.getKey())) {
|
||||
leaveDuration = 1;
|
||||
} else if (cxjqj.equals(AskAndEvctionWayEnum.HALFDAY.getKey())) {
|
||||
leaveDuration = 0.5;
|
||||
} else if (cxjqj.equals(AskAndEvctionWayEnum.TIME_INTERVAL.getKey()) || cxjqj.equals(AskAndEvctionWayEnum.HOUR.getKey())) {
|
||||
leaveDuration = Double.valueOf(Util.null2String(detailData.get("qjsc")));
|
||||
}
|
||||
if (hsdw.equals(AccountingUnitEnum.HOUR.getKey()) && (cxjqj.equals(AskAndEvctionWayEnum.ALLDAY.getKey()) || cxjqj.equals(AskAndEvctionWayEnum.HALFDAY.getKey()))) {
|
||||
leaveDuration = leaveDuration * 8;
|
||||
}
|
||||
log.info("leaveDuration : [{}]", leaveDuration);
|
||||
List<Map<String, Object>> holidayBalancefilterList = holidayBalanceList.stream().filter(e -> DateUtil.getTime(e.get("yqsxrq").toString()).compareTo(DateUtil.getTime(ksrq)) >= 0).collect(Collectors.toList());
|
||||
for (Map<String, Object> holidayBalance : holidayBalancefilterList) {
|
||||
//额定未休时长
|
||||
double wxsc = holidayBalance.get("wxsc") == null ? 0 : Double.valueOf(holidayBalance.get("wxsc").toString());
|
||||
if (leaveDuration > 0) {
|
||||
Map<String, Object> detail2Map = Maps.newHashMap();
|
||||
detail2Map.put("glmxid", detailData.get("id"));
|
||||
detail2Map.put("jqye", holidayBalance.get("id"));
|
||||
detail2Map.put("mainid", mainTableData.get("id"));
|
||||
detail2Map.put("glrq", detailData.get("ksrq"));
|
||||
if (leaveDuration > wxsc) {
|
||||
detail2Map.put("sysc", wxsc);
|
||||
leaveDuration = Utils.subtract(leaveDuration, wxsc);
|
||||
wxsc = 0;
|
||||
} else {
|
||||
detail2Map.put("sysc", leaveDuration);
|
||||
leaveDuration = 0;
|
||||
wxsc = Utils.subtract(wxsc, leaveDuration);
|
||||
}
|
||||
detailTable2.add(detail2Map);
|
||||
holidayBalance.put("wxsc", wxsc);
|
||||
}
|
||||
}
|
||||
if (leaveDuration > 0) {
|
||||
//假期余额不足
|
||||
String message = ksrq + "对应的" + holidayItem.get("mc") + "假期余额不足!";
|
||||
log.error(message);
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
log.info("detailTable2 : [{}]", detailTable2);
|
||||
|
||||
//更新流程明细表2
|
||||
String delteSql = "delete from " + detail2TableName + " where mainid=?";
|
||||
DbTools.update(delteSql, requestid);
|
||||
if (!CommonUtil.insertBatch(detailTable2, detail2TableName)) {
|
||||
//更新流程明细表2失败
|
||||
String message = "更新流程明细表2失败";
|
||||
log.error(message);
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
//更新假期余额在途时长
|
||||
Map<String, Object> balanceMap = Maps.newHashMap();
|
||||
for (Map<String, Object> data : detailTable2) {
|
||||
String jqye = Util.null2String(data.get("jqye"));
|
||||
double sysc = Double.valueOf(data.get("sysc").toString());
|
||||
double havedSysc = balanceMap.get(jqye) == null ? 0 : Double.valueOf(balanceMap.get(jqye).toString());
|
||||
sysc = Utils.add(sysc, havedSysc);
|
||||
balanceMap.put(jqye, sysc);
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : balanceMap.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
double ztsc = Double.valueOf(entry.getValue().toString());
|
||||
Map<String, Object> map = (Map<String, Object>) holidayBalanceMap.get(id);
|
||||
|
||||
double havedztsc = Util.null2String(map.get("ztsc")).equals("") ? 0 : Double.valueOf(map.get("ztsc").toString());
|
||||
double havedwxsc = Util.null2String(map.get("wxsc")).equals("") ? 0 : Double.valueOf(map.get("wxsc").toString());
|
||||
|
||||
double updatedztsc = Utils.add(havedztsc, ztsc);
|
||||
double updatedwxsc = Utils.subtract(havedwxsc, ztsc);
|
||||
|
||||
String updateSql = "update uf_jcl_kq_jqye set wxsc=?,ztsc=? where id=?";
|
||||
if (!DbTools.update(updateSql, updatedwxsc, updatedztsc, id)) {
|
||||
//更新假期余额失败
|
||||
String message = "更新假期余额失败";
|
||||
log.error(message);
|
||||
requestInfo.getRequestManager().setMessageid("11111" + requestid + "22222");
|
||||
requestInfo.getRequestManager().setMessagecontent(message);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("AskForLeaveWorkFlowSubmitAction error : [{}]",e);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.engine.attendance.workflow.cmd;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.common.util.DbTools;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class GetAskForLeaveRecordListCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
public GetAskForLeaveRecordListCmd(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> retmap = new HashMap<String, Object>();
|
||||
//获取主表id列表
|
||||
String targetUserId = Util.null2String(params.get("targetUserId"));
|
||||
String businessTripsType = Util.null2String(params.get("businessTripsType"));
|
||||
String startDate = Util.null2String(params.get("startDate"));
|
||||
String endDate = Util.null2String(params.get("endDate"));
|
||||
log.info("targetUserId : {}, businessTripsType : {}, startDate : {}, endDate : {}",targetUserId, businessTripsType, startDate, endDate);
|
||||
String sql = "select * from uf_jcl_kq_qjjl where qjry="+targetUserId;
|
||||
if (!businessTripsType.equals("")) {
|
||||
sql += " and jqlx = " + businessTripsType;
|
||||
}
|
||||
if (!startDate.equals("")) {
|
||||
sql += " and ksrq >= '" + startDate+"'";
|
||||
}
|
||||
if (!endDate.equals("")) {
|
||||
sql += " and jsrq <= '" + endDate+"'";
|
||||
}
|
||||
log.info(sql);
|
||||
List<String> maidList = new ArrayList<>();
|
||||
if (!targetUserId.equals("")) {
|
||||
List<Map<String,Object>> datas = DbTools.getSqlToList(sql);
|
||||
if (datas.size() > 0) {
|
||||
datas.forEach(f -> {
|
||||
maidList.add(f.get("id").toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
log.info("maidList : [{}]",maidList);
|
||||
//查询子表数据
|
||||
if (maidList.size() > 0) {
|
||||
String detailSql = "select a.id,a.cxqj,a.ksrq,a.kssj,a.jsrq,a.jssj,a.qjsc,a.qtj,a.btj,a.cxsm from uf_jcl_kq_qjjl_dt1 a where (a.cxqj is null or a.cxqj<>1) mainid in ("+String.join(",",maidList)+")";
|
||||
List<Map<String,Object>> detailList = DbTools.getSqlToList(detailSql);
|
||||
if (detailList.size() > 0) {
|
||||
retmap.put("result", detailList);
|
||||
} else {
|
||||
retmap.put("result", null);
|
||||
}
|
||||
log.info("detailList : [{}]",detailList);
|
||||
} else {
|
||||
retmap.put("result", null);
|
||||
}
|
||||
return retmap;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.engine.attendance.workflow.enums;
|
||||
|
||||
import com.finance.toolkit.BaseEnum;
|
||||
|
||||
/**
|
||||
* 出差请假方式
|
||||
*/
|
||||
public enum AskAndEvctionWayEnum implements BaseEnum {
|
||||
ALLDAY("0","全天"),
|
||||
TIME_INTERVAL("1","指定时间区间"),
|
||||
HALFDAY("2","半天"),
|
||||
HOUR("3","指定时间长度");
|
||||
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
AskAndEvctionWayEnum(String key, String value){
|
||||
this.key=key;
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.engine.attendance.workflow.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AskForLeaveService {
|
||||
Map<String, Object> getUesdHolidayItem(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> getAskForLeaveRecordList(Map<String, Object> params);
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.engine.attendance.workflow.service.impl;
|
||||
|
||||
import com.engine.attendance.enums.CheckBoxEnum;
|
||||
import com.engine.attendance.workflow.cmd.GetAskForLeaveRecordListCmd;
|
||||
import com.engine.attendance.workflow.cmd.GetKqCycleTimeIntervalCmd;
|
||||
import com.engine.attendance.workflow.service.AskForLeaveService;
|
||||
import com.engine.common.exception.AttendanceRunTimeException;
|
||||
import com.engine.common.util.DateUtil;
|
||||
import com.engine.common.util.DbTools;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class AskForLeaveServiceImpl extends Service implements AskForLeaveService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getUesdHolidayItem(Map<String, Object> params) {
|
||||
Map<String,Object> resultMap = Maps.newHashMap();
|
||||
// 流程表单主表数据
|
||||
Map<String,String> mainTableData = (Map<String,String>)params.get("mainTableData");
|
||||
// 流程表单明细表1数据
|
||||
List<Map<String, String>> detailTableData = (List<Map<String, String>>)params.get("detailTableData");
|
||||
detailTableData = detailTableData.stream().sorted(Comparator.comparing(e->DateUtil.getTime(e.get("ksrq")).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
|
||||
|
||||
//第一笔开始时间
|
||||
String firstStartDate = detailTableData.get(0).get("ksrq");
|
||||
|
||||
//请假人员
|
||||
String qjry = mainTableData.get("qjry");
|
||||
//假期类型
|
||||
String jqlx = mainTableData.get("jqlx");
|
||||
|
||||
String sql = "select id,mc,hsdw,hsl,jcbyxsyqjb,yxsydjb,qzsyyxjb from uf_jcl_kq_kqxm where id=?";
|
||||
|
||||
Map<String,Object> holidayItem = DbTools.getSqlToMap(sql,jqlx);
|
||||
|
||||
|
||||
if (CheckBoxEnum.CHECKED.getKey().equals(holidayItem.get("qzsyyxjb")) &&
|
||||
CheckBoxEnum.CHECKED.getKey().equals(holidayItem.get("jcbyxsyqjb"))){
|
||||
Map<String,Object> holidayPriorityItem = DbTools.getSqlToMap(sql,holidayItem.get("yxsydjb"));
|
||||
|
||||
sql = "select id,jqid,sxrq,ktsc,yxsc,wxsc,yqsxrq,ztsc from uf_jcl_kq_jqye where ygid=? and jqid=? and sxrq<=? and yqsxrq>=? order by sxrq";
|
||||
|
||||
List<Map<String,Object>> holidayBalanceList = DbTools.getSqlToList(sql,qjry,holidayPriorityItem.get("id"),firstStartDate,firstStartDate);
|
||||
|
||||
Map<String,Object> useItemMap = Maps.newHashMap();
|
||||
for (Map<String, String> detail:detailTableData){
|
||||
String ksrq = detail.get("ksrq");
|
||||
List<Map<String,Object>> list = holidayBalanceList.stream().filter(e-> DateUtil.getTime(e.get("yqsxrq").toString()).compareTo(DateUtil.getTime(ksrq))>=0).collect(Collectors.toList());
|
||||
log.info("ksrq : [{}], list : [{}]",ksrq,list);
|
||||
double totalUnearnedLeave = list.stream().mapToDouble(e->Double.valueOf(e.get("wxsc").toString())).sum();
|
||||
if (totalUnearnedLeave == 0){
|
||||
List<Map<String,String>> details = (List<Map<String,String>>)useItemMap.get(holidayItem.get("id"));
|
||||
if (details == null){
|
||||
details = Lists.newArrayList();
|
||||
}
|
||||
details.add(detail);
|
||||
useItemMap.put(holidayItem.get("id").toString(),details);
|
||||
}else {
|
||||
List<Map<String,String>> details = (List<Map<String,String>>)useItemMap.get(holidayPriorityItem.get("id"));
|
||||
if (details == null){
|
||||
details = Lists.newArrayList();
|
||||
}
|
||||
details.add(detail);
|
||||
useItemMap.put(holidayPriorityItem.get("id").toString(),details);
|
||||
}
|
||||
}
|
||||
//需要使用到2种以上假期
|
||||
if (useItemMap.size() > 1){
|
||||
throw new AttendanceRunTimeException("优先使用的"+holidayPriorityItem.get("mc")+"余额不足");
|
||||
}else {
|
||||
if (useItemMap.get(holidayPriorityItem.get("id")) != null){
|
||||
resultMap.put("jqlx",holidayPriorityItem.get("id"));
|
||||
resultMap.put("hsdw",holidayPriorityItem.get("hsdw"));
|
||||
resultMap.put("hsl",holidayPriorityItem.get("hsl"));
|
||||
resultMap.put("mc",holidayPriorityItem.get("mc"));
|
||||
resultMap.put("jcbyxsyqjb",CheckBoxEnum.CHECKED.getKey());
|
||||
}else if (useItemMap.get(holidayItem.get("id")) != null){
|
||||
resultMap.put("jqlx",jqlx);
|
||||
resultMap.put("hsdw",holidayItem.get("hsdw"));
|
||||
resultMap.put("hsl",holidayItem.get("hsl"));
|
||||
resultMap.put("mc",holidayItem.get("mc"));
|
||||
resultMap.put("jcbyxsyqjb",CheckBoxEnum.UNCHECKED.getKey());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
resultMap.put("jqlx",jqlx);
|
||||
resultMap.put("hsdw",holidayItem.get("hsdw"));
|
||||
resultMap.put("hsl",holidayItem.get("hsl"));
|
||||
resultMap.put("mc",holidayItem.get("mc"));
|
||||
resultMap.put("jcbyxsyqjb",CheckBoxEnum.UNCHECKED.getKey());
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAskForLeaveRecordList(Map<String, Object> params) {
|
||||
return commandExecutor.execute(new GetAskForLeaveRecordListCmd(params,user));
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.engine.attendance.workflow.web;
|
||||
|
||||
import com.engine.attendance.workflow.service.AskForLeaveService;
|
||||
import com.engine.attendance.workflow.service.impl.AskForLeaveServiceImpl;
|
||||
import com.engine.common.util.*;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
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.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 请假流程
|
||||
*/
|
||||
@Slf4j
|
||||
public class AskForLeaveAction {
|
||||
|
||||
private AskForLeaveService getAskForLeaveService(User user) {
|
||||
return ServiceUtil.getService(AskForLeaveServiceImpl.class,user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请假流程获得实际请假项目
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/getUesdHolidayItem")
|
||||
@Produces({"text/plain"})
|
||||
public String generateVocation(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
Map<String,Object> param = ParamUtil.request2Map(request);
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
String mainTableDataStr = Util.null2String(param.get("mainTableData"));
|
||||
String detailTableDataStr = Util.null2String(param.get("detailTableData"));
|
||||
Gson gson = new Gson();
|
||||
Map<String,Object> mainTableData = gson.fromJson(mainTableDataStr, (Type) Map.class);
|
||||
List<Map<String, String>> detailTableData = gson.fromJson(detailTableDataStr, (Type) List.class);
|
||||
|
||||
param.put("mainTableData",mainTableData);
|
||||
param.put("detailTableData",detailTableData);
|
||||
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getAskForLeaveService(user) :: getUesdHolidayItem,param);
|
||||
}catch (Exception e){
|
||||
log.error("sync fund status fail,catch error: [{}]",e);
|
||||
return ApiReturnTools.error("200","查询失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得请假记录列表数据用于销假
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/getAskForLeaveRecordList")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getAskForLeaveRecordList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String,Object> param = ParamUtil.request2Map(request);
|
||||
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getAskForLeaveService(user) :: getAskForLeaveRecordList,param);
|
||||
}catch (Exception e){
|
||||
log.error("execute fail,catch error: [{}]",e);
|
||||
return ApiReturnTools.error("500","getBusinessTripsApplyList error");
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
import com.engine.common.util.DateUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TestMethod {
|
||||
public static void main(String[] args) {
|
||||
// List<Map<String,Object>> detailTableData = Lists.newArrayList();
|
||||
// detailTableData.add(new HashMap(){{
|
||||
// put("ksrq","2024-02-18");
|
||||
// put("sysc","1");
|
||||
// }});
|
||||
// detailTableData.add(new HashMap(){{
|
||||
// put("ksrq","2024-01-18");
|
||||
// put("sysc","1");
|
||||
// }});
|
||||
//
|
||||
// detailTableData = detailTableData.stream().sorted(Comparator.comparing(e-> DateUtil.getTime(e.get("ksrq").toString()).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
|
||||
// System.out.println(detailTableData);
|
||||
|
||||
List<Map<String,Object>> list = Lists.newArrayList();
|
||||
double totalUnearnedLeave = list.stream().mapToDouble(e->Double.valueOf(e.get("wxsc").toString())).sum();
|
||||
|
||||
System.out.println(totalUnearnedLeave);
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
|
||||
<jsp:useBean id="strUtil" class="weaver.common.StringUtil" scope="page" />
|
||||
<jsp:useBean id="dateUtil" class="weaver.common.DateUtil" scope="page" />
|
||||
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
|
||||
<jsp:useBean id="attProcSetManager" class="com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager" scope="page" />
|
||||
<%
|
||||
|
||||
%>
|
||||
|
||||
<script >
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
try{
|
||||
|
||||
|
||||
WfForm.bindFieldChangeEvent(WfForm.convertFieldNameToId("xjr"),function(obj,id,value){
|
||||
console.log("WfForm.bindFieldChangeEvent--",obj,id,value);
|
||||
detailtTable();
|
||||
});
|
||||
WfForm.bindFieldChangeEvent(WfForm.convertFieldNameToId("qjlx"),function(obj,id,value){
|
||||
console.log("WfForm.bindFieldChangeEvent--",obj,id,value);
|
||||
detailtTable();
|
||||
});
|
||||
WfForm.bindFieldChangeEvent(WfForm.convertFieldNameToId("cxqj"),function(obj,id,value){
|
||||
console.log("WfForm.bindFieldChangeEvent--",obj,id,value);
|
||||
detailtTable();
|
||||
});
|
||||
|
||||
}catch (e) {
|
||||
}
|
||||
});
|
||||
function detailtTable(){
|
||||
let qjlx = WfForm.getFieldValue(WfForm.convertFieldNameToId('qjlx'));
|
||||
let xcr = WfForm.getFieldValue(WfForm.convertFieldNameToId('xjr'));
|
||||
let cxqj = WfForm.getFieldValue(WfForm.convertFieldNameToId('cxqj'));
|
||||
let startDate="";
|
||||
let endDate="";
|
||||
let nowYear = new Date().getFullYear();
|
||||
let nowMonth =new Date().getMonth()+1;
|
||||
let month = 1;
|
||||
let fullDay = 30;
|
||||
if (cxqj == "0"){
|
||||
//上月
|
||||
month = nowMonth-1;
|
||||
if (month == 0){
|
||||
month =12;
|
||||
}
|
||||
fullDay = new Date(nowYear,month,0).getDate();
|
||||
if (month < 10){
|
||||
month = "0"+month;
|
||||
}
|
||||
}else if (cxqj == "1"){
|
||||
//本月
|
||||
month = nowMonth;
|
||||
fullDay = new Date(nowYear,month,0).getDate();
|
||||
if (month < 10){
|
||||
month = "0"+month;
|
||||
}
|
||||
|
||||
}else if (cxqj == "2"){
|
||||
//下月
|
||||
month = nowMonth+1;
|
||||
if (month > 12){
|
||||
month = month-12;
|
||||
nowYear = nowYear+1;
|
||||
}
|
||||
fullDay = new Date(nowYear,month,0).getDate();
|
||||
if (month < 10){
|
||||
month = "0"+month;
|
||||
}
|
||||
|
||||
}else if (cxqj == "3"){
|
||||
//下下月
|
||||
month = nowMonth+2;
|
||||
if (month > 12){
|
||||
month = month-12;
|
||||
nowYear = nowYear+1;
|
||||
}
|
||||
fullDay = new Date(nowYear,month,0).getDate();
|
||||
if (month < 10){
|
||||
month = "0"+month;
|
||||
}
|
||||
}
|
||||
startDate = nowYear+"-"+month+"-01";
|
||||
endDate = nowYear+"-"+month+"-"+fullDay;
|
||||
let data = {
|
||||
targetUserId:xcr,
|
||||
businessTripsType:qjlx,
|
||||
startDate:startDate,
|
||||
endDate:endDate
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url:'/api/attendance/askforleave/getAskForLeaveRecordList',
|
||||
data:data,
|
||||
type:'GET',
|
||||
dataType:'json',
|
||||
success:function(res){
|
||||
console.log(res)
|
||||
let data = res.data.result;
|
||||
WfForm.delDetailRow("detail_1", "all");
|
||||
if (data != undefined){
|
||||
data.filter(item => {
|
||||
var obj = {};
|
||||
//撤销
|
||||
obj[WfForm.convertFieldNameToId("cx", "detail_1")] = {value:item.cxqj};
|
||||
//开始日期
|
||||
obj[WfForm.convertFieldNameToId("ksrq", "detail_1")] = {value:item.ksrq};
|
||||
//开始时间
|
||||
obj[WfForm.convertFieldNameToId("kssj", "detail_1")] = {value:item.kssj};
|
||||
//结束日期
|
||||
obj[WfForm.convertFieldNameToId("jsrq", "detail_1")] = {value:item.jsrq};
|
||||
//结束时间
|
||||
obj[WfForm.convertFieldNameToId("jssj", "detail_1")] = {value:item.jssj};
|
||||
//出差时长
|
||||
obj[WfForm.convertFieldNameToId("qjsc", "detail_1")] = {value:item.qjsc};
|
||||
//全天
|
||||
obj[WfForm.convertFieldNameToId("qt", "detail_1")] = {value:item.qtj};
|
||||
//半天
|
||||
obj[WfForm.convertFieldNameToId("bt", "detail_1")] = {value:item.btj};
|
||||
//撤销id
|
||||
obj[WfForm.convertFieldNameToId("cxlyid", "detail_1")] = {value:item.id};
|
||||
|
||||
WfForm.addDetailRow("detail_1", obj);
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue