领悦代码备份
This commit is contained in:
parent
95d26b89df
commit
93dca27c6d
|
|
@ -0,0 +1,208 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
String ry = request.getParameter("ry");
|
||||
String tbrq = request.getParameter("tbrq");
|
||||
// out.print("ry:"+ry+"</br>");
|
||||
// out.print("tbrq:"+tbrq+"</br>");
|
||||
String activeGroupId = "" ;
|
||||
String wfidstatus = "";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
activeGroupId = getUserActiveGroupId(ry);
|
||||
|
||||
if(StringUtils.isNotBlank(tbrq) && StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select t.wfidstatus\n" +
|
||||
" from kq_flow_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid" +
|
||||
" where t.kqdate='"+tbrq+"' \n" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and t.resourceid = " + ry ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
wfidstatus = Util.null2String(rs.getString("wfidstatus"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// out.print("serialid:"+serialid+"</br>");
|
||||
// out.print("serial:"+serial+"</br>");
|
||||
|
||||
jsonObject.put("wfidstatus",wfidstatus);
|
||||
jsonObject.put("ry",ry);
|
||||
jsonObject.put("tbrq",tbrq);
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<%@ page import="weaver.conn.RecordSet" %>
|
||||
<%@ page import="weaver.general.Util" %>
|
||||
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
||||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="weaver.hrm.User" %>
|
||||
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="weaver.general.BaseBean" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupComInfo" %>
|
||||
<%@ page import="com.engine.kq.biz.KQGroupBiz" %>
|
||||
<%@ page import="weaver.common.DateUtil" %>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
||||
<%
|
||||
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
if(user==null) {
|
||||
response.sendRedirect("/login/Login.jsp");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
String ry = request.getParameter("ry");
|
||||
String tbrq = request.getParameter("tbrq");
|
||||
// out.print("ry:"+ry+"</br>");
|
||||
// out.print("tbrq:"+tbrq+"</br>");
|
||||
String activeGroupId = "" ;
|
||||
String serialids = "";
|
||||
String serialid = "";
|
||||
String serial = "";
|
||||
String groupname = "";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(StringUtils.isNotBlank(ry)){
|
||||
activeGroupId = getUserActiveGroupId(ry);
|
||||
// out.print("activeGroupId:"+activeGroupId);
|
||||
if(StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql = " select serialids,groupname from kq_group where id = "+activeGroupId ;
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialids = Util.null2String(rs.getString("serialids"));
|
||||
groupname = Util.null2String(rs.getString("groupname"));
|
||||
}
|
||||
}
|
||||
|
||||
// out.print("serialids:"+serialids+"</br>");
|
||||
// out.print("groupname:"+groupname+"</br>");
|
||||
|
||||
if(StringUtils.isNotBlank(tbrq) && StringUtils.isNotBlank(activeGroupId)){
|
||||
String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" +
|
||||
" from kq_shiftschedule t\n" +
|
||||
" inner join kq_ShiftManagement k on k.id = t.serialid" +
|
||||
" where t.kqdate='"+tbrq+"' \n" +
|
||||
" and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" +
|
||||
" and t.resourceid = " + ry +
|
||||
" and (t.wfidstatus = 3 or t.wfidstatus is null )" +
|
||||
" order by kqdate ";
|
||||
// out.print("sql:"+sql+"</br>");
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
serialid = Util.null2String(rs.getString("serialid"));
|
||||
serial = Util.null2String(rs.getString("serial"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// out.print("serialid:"+serialid+"</br>");
|
||||
// out.print("serial:"+serial+"</br>");
|
||||
|
||||
jsonObject.put("groupid",activeGroupId);
|
||||
jsonObject.put("groupname",groupname);
|
||||
jsonObject.put("serialids",serialids);
|
||||
jsonObject.put("serialid",serialid);
|
||||
jsonObject.put("serial",serial);
|
||||
%>
|
||||
<%=jsonObject.toJSONString() %>
|
||||
|
||||
|
||||
<%!
|
||||
|
||||
public List<Map<String,Object>> getDt1UserDate(List<Map<String,String>> hrmList){
|
||||
List<Map<String,Object>> dt1List = new ArrayList<Map<String,Object>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
|
||||
Map<String,Object> dt1Map = new HashMap<String,Object>();
|
||||
dt1Map.put("id",userid);
|
||||
dt1Map.put("name",lastname);
|
||||
|
||||
List<Map<String,String>> specialobjList2 = new ArrayList<Map<String,String>>();
|
||||
Map<String,String> specialobjMap2 = new HashMap<String,String>();
|
||||
specialobjMap2.put("id",userid);
|
||||
specialobjMap2.put("name",lastname);
|
||||
specialobjList2.add(specialobjMap2);
|
||||
|
||||
Map<String,Object> valueMap2 = new HashMap<String,Object>();
|
||||
valueMap2.put("value",userid);
|
||||
valueMap2.put("specialobj",specialobjList2);
|
||||
dt1Map.put("value",valueMap2);
|
||||
dt1List.add(dt1Map);
|
||||
}
|
||||
return dt1List;
|
||||
}
|
||||
/***
|
||||
*
|
||||
* @param hrmList
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> getMainUserDate(List<Map<String,String>> hrmList){
|
||||
String userids = "";
|
||||
List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
|
||||
for(int i=0;i<hrmList.size();i++){
|
||||
Map<String,String> hrmMap = hrmList.get(i);
|
||||
String userid = Util.null2String(hrmMap.get("id"));
|
||||
String lastname = Util.null2String(hrmMap.get("lastname"));
|
||||
userids += StringUtils.isBlank(userids) ? userid : ","+userid ;
|
||||
|
||||
Map<String,String> specialobjMap = new HashMap<String,String>();
|
||||
specialobjMap.put("id",userid);
|
||||
specialobjMap.put("name",lastname);
|
||||
specialobjList.add(specialobjMap);
|
||||
}
|
||||
|
||||
Map<String,Object> valueMap = new HashMap<String,Object>();
|
||||
valueMap.put("value",userids);
|
||||
valueMap.put("specialobj",specialobjList);
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public List<Map<String,String>> queryListBySql(String sql){
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
rs.executeQuery(sql);
|
||||
String[] column = rs.getColumnName();
|
||||
while (rs.next()){
|
||||
map = new HashMap<String,String>();
|
||||
for(int i=0;i<column.length;i++){
|
||||
String value = rs.getString(column[i]);
|
||||
map.put(column[i],value);
|
||||
}
|
||||
if(!map.isEmpty() && map.size()>0){
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("queryListBySql-e:"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public String getUserActiveGroupId(String userid){
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = null;
|
||||
KQGroupComInfo kqGroupComInfo = null ;
|
||||
String activeGroupId = "";
|
||||
try{
|
||||
kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
kqGroupComInfo = new KQGroupComInfo();
|
||||
|
||||
Map<String, List<String>> groupMemberMap = getUserGroup();
|
||||
|
||||
String activeGroup = "";
|
||||
if(groupMemberMap.containsKey(userid)){
|
||||
List<String> groupIds = groupMemberMap.get(userid);
|
||||
bb.writeLog("groupIds:"+groupIds.size());
|
||||
|
||||
for(String i : groupIds){
|
||||
String isDelete = kqGroupComInfo.getIsdelete(i);
|
||||
if(!"1".equals(isDelete)) {
|
||||
String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate()));
|
||||
if (i.equals(currentGroupId)) {
|
||||
activeGroupId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog(e);
|
||||
}
|
||||
return activeGroupId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, List<String>> getUserGroup(){
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, List<String>> groupMemberMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String viewScope = "3";
|
||||
try {
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
Map<String, Object> groupParams = new HashMap<String, Object>();
|
||||
if("3".equals(viewScope)){
|
||||
groupParams.put("isNoAccount", "1");
|
||||
}
|
||||
rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams));
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("resourceid");
|
||||
String gid = rs.getString("groupid");
|
||||
if (!groupMemberMap.containsKey(id))
|
||||
groupMemberMap.put(id, new ArrayList<>());
|
||||
groupMemberMap.get(id).add(gid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return groupMemberMap;
|
||||
}
|
||||
|
||||
|
||||
%>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,900 @@
|
|||
package com.api.customization.kq.util;
|
||||
|
||||
import com.engine.kq.biz.KQTimesArrayComInfo;
|
||||
import com.engine.kq.enums.FlowReportTypeEnum;
|
||||
import com.engine.kq.enums.KqSplitFlowTypeEnum;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import com.engine.kq.wfset.bean.SplitBean;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
public class CustomLeaveUtil {
|
||||
public KQLog kqLog = new KQLog();
|
||||
|
||||
private static DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
private DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
||||
String isline = new BaseBean().getPropValue("qc3560103","isline");//换行
|
||||
|
||||
|
||||
public String format(double value) {
|
||||
// DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
||||
symbols.setDecimalSeparator('.');
|
||||
df.setMaximumFractionDigits(5);
|
||||
df.setDecimalFormatSymbols(symbols);
|
||||
return df.format(value);
|
||||
}
|
||||
|
||||
public List<SplitBean> getAllFlowData(Map<String,Object> flowMaps,String type){
|
||||
List<SplitBean> allSplitBeans = new ArrayList<>();
|
||||
allSplitBeans.addAll(getLeaveData(flowMaps,"",""));
|
||||
return allSplitBeans;
|
||||
}
|
||||
|
||||
public List<SplitBean> getAllFlowData(Map<String,Object> flowMaps,String belongdate,String type){
|
||||
List<SplitBean> allSplitBeans = new ArrayList<>();
|
||||
allSplitBeans.addAll(getLeaveData(flowMaps,belongdate));
|
||||
return allSplitBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的考勤数据
|
||||
* 请假,出差,公出,加班的
|
||||
* @param flowMaps
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public List<SplitBean> getAllFlowData(Map<String,Object> flowMaps,String fromDate,String toDate,String type){
|
||||
KqCustomFlowData kqCustomFlowData = new KqCustomFlowData();
|
||||
List<SplitBean> allSplitBeans = new ArrayList<>();
|
||||
|
||||
allSplitBeans.addAll(getLeaveData(flowMaps,fromDate,toDate));
|
||||
allSplitBeans.addAll(kqCustomFlowData.getEvectionData(flowMaps,fromDate,toDate));
|
||||
allSplitBeans.addAll(kqCustomFlowData.getOutData(flowMaps,fromDate,toDate));
|
||||
return allSplitBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请假相关的数据
|
||||
*/
|
||||
public List<SplitBean> getLeaveData(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
|
||||
String tablename = "select a.* from kq_flow_split_temp_leave a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
|
||||
|
||||
|
||||
String sqlWhere = "";
|
||||
if(fromDate.length() > 0 && toDate.length() > 0){
|
||||
sqlWhere += " and belongdate between '"+fromDate+"' and '"+toDate+"' ";
|
||||
}
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
tablename += sqlWhere;
|
||||
}
|
||||
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
leaveSql += sqlWhere;
|
||||
}
|
||||
List<SplitBean> splitBeans = new ArrayList<>();
|
||||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||||
|
||||
int[] initArrays = kqTimesArrayComInfo.getInitArr();
|
||||
|
||||
rs.execute(leaveSql);
|
||||
while(rs.next()){
|
||||
SplitBean splitBean = new SplitBean();
|
||||
String requestId= rs.getString("requestId");
|
||||
String resourceid= rs.getString("resourceid");
|
||||
String fromdate= rs.getString("fromdate");
|
||||
String belongdate= rs.getString("belongdate");
|
||||
String fromtime= rs.getString("fromtime");
|
||||
String todate= rs.getString("todate");
|
||||
String totime= rs.getString("totime");
|
||||
String newleavetype= rs.getString("newleavetype");
|
||||
String duration= rs.getString("duration");
|
||||
String durationrule= rs.getString("durationrule");
|
||||
String leavebackrequestid= Util.null2String(rs.getString("leavebackrequestid"));
|
||||
|
||||
String fromtimedb= rs.getString("fromtimedb");
|
||||
String totimedb= rs.getString("totimedb");
|
||||
|
||||
if(Util.getDoubleValue(duration) <= 0){
|
||||
//continue;
|
||||
}
|
||||
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
|
||||
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
|
||||
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.LEAVE.getFlowtype();
|
||||
String serial_signtype = "";
|
||||
String serial = "";
|
||||
String signtype = "";
|
||||
|
||||
|
||||
Map<String,String> infoMap = new HashMap<>();
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put(newleavetype, duration);
|
||||
infoMap.put("begintime", fromtime);
|
||||
infoMap.put("endtime", totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("durationrule", durationrule);
|
||||
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
|
||||
infoMap.put("ishalf", "true");
|
||||
}else{
|
||||
infoMap.put("ishalf", "false");
|
||||
}
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
|
||||
infoMap.put("newleavetype", newleavetype);
|
||||
infoMap.put("signtype", signtype);
|
||||
infoMap.put("serial", serial);
|
||||
infoMap.put("fromtimedb", fromtimedb);
|
||||
infoMap.put("totimedb", totimedb);
|
||||
|
||||
String key = resourceid+"|"+belongdate;
|
||||
if(flowMaps != null){
|
||||
if(flowMaps.get(key) != null){
|
||||
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
|
||||
initArrays = kqTimesArrayComInfo.getInitArr();
|
||||
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
|
||||
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
|
||||
//2025-05-21 如果存在跨天,那么可能会报错。加个校验
|
||||
if (toTimeIndex < fromTimeIndex){
|
||||
toTimeIndex += 1440;
|
||||
}
|
||||
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
|
||||
leavebackrequestid = leavebackrequestid.substring(1);
|
||||
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
|
||||
rs1.executeQuery(backSql);
|
||||
|
||||
while (rs1.next()){
|
||||
String back_fromtime = rs1.getString("fromtime");
|
||||
String back_totime = rs1.getString("totime");
|
||||
String back_duration= rs.getString("duration");
|
||||
if(Util.getDoubleValue(back_duration) <= 0){
|
||||
// continue;
|
||||
}
|
||||
if(back_fromtime.equalsIgnoreCase(fromtime)){
|
||||
//2025-05-21 如果存在跨天,那么可能会报错。加个校验
|
||||
if ((kqTimesArrayComInfo.getArrayindexByTimes(back_totime)) < (kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime))){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1440, -1);
|
||||
}else {
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
}
|
||||
}else{
|
||||
if ((kqTimesArrayComInfo.getArrayindexByTimes(back_totime)) < (kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime))){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1440, -1);
|
||||
}else {
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
List<List<String>> backLists = new ArrayList<>();
|
||||
List<String> backList = new ArrayList<>();
|
||||
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
|
||||
if(initArrays[i] == 1){
|
||||
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
|
||||
}else{
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
backList = new ArrayList<>();
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
}
|
||||
if(backLists != null && !backLists.isEmpty()){
|
||||
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
|
||||
for(int j = 0 ; j < backLists.size() ;j++){
|
||||
List<String> backListTmp = backLists.get(j);
|
||||
String back_tmp_fromtime = backListTmp.get(0);
|
||||
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put(newleavetype, duration);
|
||||
infoMap.put("begintime", back_tmp_fromtime);
|
||||
infoMap.put("endtime", back_tmp_totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("durationrule", durationrule);
|
||||
if("2".equals(durationrule)){
|
||||
infoMap.put("ishalf", "true");
|
||||
}
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
|
||||
infoMap.put("newleavetype", newleavetype);
|
||||
time_list_tmp.add(infoMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
|
||||
time_list_tmp.add(infoMap);
|
||||
}
|
||||
}else{
|
||||
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
|
||||
initArrays = kqTimesArrayComInfo.getInitArr();
|
||||
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
|
||||
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
|
||||
if (toTimeIndex < fromTimeIndex){
|
||||
toTimeIndex += 1440;
|
||||
}
|
||||
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
|
||||
leavebackrequestid = leavebackrequestid.substring(1);
|
||||
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
|
||||
rs1.executeQuery(backSql);
|
||||
|
||||
while (rs1.next()){
|
||||
String back_fromtime = rs1.getString("fromtime");
|
||||
String back_totime = rs1.getString("totime");
|
||||
if(back_fromtime.equalsIgnoreCase(fromtime)){
|
||||
if ((kqTimesArrayComInfo.getArrayindexByTimes(back_totime))<(kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime))){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1440, -1);
|
||||
|
||||
}else {
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
|
||||
}
|
||||
}else{
|
||||
if(back_fromtime.compareTo(back_totime) < 0){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<List<String>> backLists = new ArrayList<>();
|
||||
List<String> backList = new ArrayList<>();
|
||||
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
|
||||
if(initArrays[i] == 1){
|
||||
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
|
||||
}else{
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
backList = new ArrayList<>();
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
}
|
||||
if(backLists != null && !backLists.isEmpty()){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
for(int j = 0 ; j < backLists.size() ;j++){
|
||||
List<String> backListTmp = backLists.get(j);
|
||||
String back_tmp_fromtime = backListTmp.get(0);
|
||||
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put(newleavetype, duration);
|
||||
infoMap.put("begintime", back_tmp_fromtime);
|
||||
infoMap.put("endtime", back_tmp_totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("durationrule", durationrule);
|
||||
if("2".equals(durationrule)){
|
||||
infoMap.put("ishalf", "true");
|
||||
}
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
|
||||
infoMap.put("newleavetype", newleavetype);
|
||||
time_list.add(infoMap);
|
||||
}
|
||||
flowMaps.put(key, time_list);
|
||||
}
|
||||
}else{
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key, time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return splitBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请假相关的数据
|
||||
*/
|
||||
public List<SplitBean> getLeaveData(Map<String, Object> flowMaps,String kqdate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
|
||||
String tablename = "select a.* from kq_flow_split_temp_leave a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
|
||||
|
||||
|
||||
String sqlWhere = "";
|
||||
if(kqdate.length() > 0 ){
|
||||
sqlWhere += " and belongdate = '"+kqdate+"'";
|
||||
}
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
tablename += sqlWhere;
|
||||
}
|
||||
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
leaveSql += sqlWhere;
|
||||
}
|
||||
List<SplitBean> splitBeans = new ArrayList<>();
|
||||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||||
|
||||
int[] initArrays = kqTimesArrayComInfo.getInitArr();
|
||||
|
||||
rs.execute(leaveSql);
|
||||
while(rs.next()){
|
||||
SplitBean splitBean = new SplitBean();
|
||||
String requestId= rs.getString("requestId");
|
||||
String resourceid= rs.getString("resourceid");
|
||||
String fromdate= rs.getString("fromdate");
|
||||
String belongdate= rs.getString("belongdate");
|
||||
String fromtime= rs.getString("fromtime");
|
||||
String todate= rs.getString("todate");
|
||||
String totime= rs.getString("totime");
|
||||
String newleavetype= rs.getString("newleavetype");
|
||||
String duration= rs.getString("duration");
|
||||
String durationrule= rs.getString("durationrule");
|
||||
String leavebackrequestid= Util.null2String(rs.getString("leavebackrequestid"));
|
||||
|
||||
String fromtimedb= rs.getString("fromtimedb");
|
||||
String totimedb= rs.getString("totimedb");
|
||||
|
||||
if(Util.getDoubleValue(duration) <= 0){
|
||||
//continue;
|
||||
}
|
||||
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
|
||||
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
|
||||
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.LEAVE.getFlowtype();
|
||||
String serial_signtype = "";
|
||||
String serial = "";
|
||||
String signtype = "";
|
||||
|
||||
|
||||
Map<String,String> infoMap = new HashMap<>();
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put(newleavetype, duration);
|
||||
infoMap.put("begintime", fromtime);
|
||||
infoMap.put("endtime", totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("durationrule", durationrule);
|
||||
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
|
||||
infoMap.put("ishalf", "true");
|
||||
}else{
|
||||
infoMap.put("ishalf", "false");
|
||||
}
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
|
||||
infoMap.put("newleavetype", newleavetype);
|
||||
infoMap.put("signtype", signtype);
|
||||
infoMap.put("serial", serial);
|
||||
infoMap.put("fromtimedb", fromtimedb);
|
||||
infoMap.put("totimedb", totimedb);
|
||||
|
||||
String key = resourceid+"|"+belongdate;
|
||||
if(flowMaps != null){
|
||||
if(flowMaps.get(key) != null){
|
||||
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
|
||||
initArrays = kqTimesArrayComInfo.getInitArr();
|
||||
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
|
||||
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
|
||||
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
|
||||
leavebackrequestid = leavebackrequestid.substring(1);
|
||||
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
|
||||
rs1.executeQuery(backSql);
|
||||
|
||||
while (rs1.next()){
|
||||
String back_fromtime = rs1.getString("fromtime");
|
||||
String back_totime = rs1.getString("totime");
|
||||
String back_duration= rs.getString("duration");
|
||||
if(Util.getDoubleValue(back_duration) <= 0){
|
||||
// continue;
|
||||
}
|
||||
if(back_fromtime.equalsIgnoreCase(fromtime)){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
}else{
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
}
|
||||
}
|
||||
List<List<String>> backLists = new ArrayList<>();
|
||||
List<String> backList = new ArrayList<>();
|
||||
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
|
||||
if(initArrays[i] == 1){
|
||||
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
|
||||
}else{
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
backList = new ArrayList<>();
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
}
|
||||
if(backLists != null && !backLists.isEmpty()){
|
||||
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
|
||||
for(int j = 0 ; j < backLists.size() ;j++){
|
||||
List<String> backListTmp = backLists.get(j);
|
||||
String back_tmp_fromtime = backListTmp.get(0);
|
||||
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put(newleavetype, duration);
|
||||
infoMap.put("begintime", back_tmp_fromtime);
|
||||
infoMap.put("endtime", back_tmp_totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("durationrule", durationrule);
|
||||
if("2".equals(durationrule)){
|
||||
infoMap.put("ishalf", "true");
|
||||
}
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
|
||||
infoMap.put("newleavetype", newleavetype);
|
||||
time_list_tmp.add(infoMap);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
|
||||
time_list_tmp.add(infoMap);
|
||||
}
|
||||
}else{
|
||||
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
|
||||
initArrays = kqTimesArrayComInfo.getInitArr();
|
||||
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
|
||||
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
|
||||
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
|
||||
leavebackrequestid = leavebackrequestid.substring(1);
|
||||
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
|
||||
rs1.executeQuery(backSql);
|
||||
|
||||
while (rs1.next()){
|
||||
String back_fromtime = rs1.getString("fromtime");
|
||||
String back_totime = rs1.getString("totime");
|
||||
if(back_fromtime.equalsIgnoreCase(fromtime)){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
}else{
|
||||
if(back_fromtime.compareTo(back_totime) < 0){
|
||||
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<List<String>> backLists = new ArrayList<>();
|
||||
List<String> backList = new ArrayList<>();
|
||||
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
|
||||
if(initArrays[i] == 1){
|
||||
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
|
||||
}else{
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
backList = new ArrayList<>();
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!backList.isEmpty()){
|
||||
backLists.add(backList);
|
||||
}
|
||||
if(backLists != null && !backLists.isEmpty()){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
for(int j = 0 ; j < backLists.size() ;j++){
|
||||
List<String> backListTmp = backLists.get(j);
|
||||
String back_tmp_fromtime = backListTmp.get(0);
|
||||
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put(newleavetype, duration);
|
||||
infoMap.put("begintime", back_tmp_fromtime);
|
||||
infoMap.put("endtime", back_tmp_totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("durationrule", durationrule);
|
||||
if("2".equals(durationrule)){
|
||||
infoMap.put("ishalf", "true");
|
||||
}
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
|
||||
infoMap.put("newleavetype", newleavetype);
|
||||
time_list.add(infoMap);
|
||||
}
|
||||
flowMaps.put(key, time_list);
|
||||
}
|
||||
}else{
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key, time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return splitBeans;
|
||||
}
|
||||
/**
|
||||
* 获取请假相关的数据
|
||||
*/
|
||||
public void getLeaveDataNew(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> infoMap = new HashMap<>();
|
||||
|
||||
String backfields = " * ";
|
||||
String fromSql = "";
|
||||
String sqlWhere = "";
|
||||
String leaveTableName = new BaseBean().getPropValue("qc3560103","leaveTableName");
|
||||
String leaveWfid = new BaseBean().getPropValue("qc3560103","leaveWfid");
|
||||
|
||||
//重新写一下吧
|
||||
fromSql = " from (select distinct " +
|
||||
"u.*," +
|
||||
"u.requestid as req_requestid," +
|
||||
"a.managerid," +
|
||||
"a.managerstr," +
|
||||
"a.loginid," +
|
||||
"a.subcompanyid1 as asubcompanyid1," +
|
||||
"a.departmentid as adepartmentid," +
|
||||
"a.lastname " +
|
||||
"from (select a.qjrxm as resourceId," +
|
||||
// "a.departmentId as departmentId," +
|
||||
"a.newLeaveType as newLeaveType," +
|
||||
"a.fromDate as fromDate," +
|
||||
"a.fromTime as fromTime," +
|
||||
"a.toDate as toDate," +
|
||||
"a.toTime as toTime," +
|
||||
"a.duration as duration," +
|
||||
"a.requestid " +
|
||||
"from "+leaveTableName+" a) u " +
|
||||
"left join (select * from hrmresource a where 1 = 1) a on u.resourceid = a.id) f";
|
||||
sqlWhere = " where 1 = 1" +
|
||||
" and req_requestid > 0" +
|
||||
" and (fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' or" +
|
||||
" '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate)";
|
||||
String allSql = "select "+ backfields + fromSql+sqlWhere;
|
||||
kqLog.info("==getLeaveDataNew=="+allSql);
|
||||
rs.executeQuery(allSql);
|
||||
while(rs.next()){
|
||||
String fromDate_field = "fromDate";
|
||||
String fromTime_field = "fromTime";
|
||||
String toDate_field = "toDate";
|
||||
String toTime_field = "toTime";
|
||||
String rosource_field = "resourceid";
|
||||
|
||||
|
||||
//==zj 换成自定义字段
|
||||
String related_requestid = rs.getString("REQUESTSYNCID");
|
||||
String flow_fromDate = rs.getString(fromDate_field);
|
||||
String flow_toDate = rs.getString(toDate_field);
|
||||
String resourceid = rs.getString(rosource_field);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("flow_fromDate", flow_fromDate);
|
||||
infoMap.put("flow_toDate", flow_toDate);
|
||||
infoMap.put("requestid", related_requestid);
|
||||
infoMap.put("flowtype","leave");
|
||||
if (flowMaps.get(resourceid) == null){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(resourceid,time_list);
|
||||
}else {
|
||||
List<Map<String,String>> time_list = ( List<Map<String,String>>) flowMaps.get(resourceid);
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(resourceid,time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取销假相关的数据
|
||||
*/
|
||||
public void getLeaveBackDataNew(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> infoMap = new HashMap<>();
|
||||
|
||||
String backfields = " * ";
|
||||
String fromSql = "";
|
||||
String sqlWhere = "";
|
||||
String leaveTableName = new BaseBean().getPropValue("qc3560103","leaveBackTableName");
|
||||
String leaveWfid = new BaseBean().getPropValue("qc3560103","leaveBackWfid");
|
||||
|
||||
//重新写一下吧
|
||||
fromSql = " from (select distinct " +
|
||||
"u.*," +
|
||||
"u.requestid as req_requestid," +
|
||||
"a.managerid," +
|
||||
"a.managerstr," +
|
||||
"a.loginid," +
|
||||
"a.subcompanyid1 as asubcompanyid1," +
|
||||
"a.departmentid as adepartmentid," +
|
||||
"a.lastname " +
|
||||
"from (select a.resourceId as resourceId," +
|
||||
// "a.departmentId as departmentId," +
|
||||
"b.detail_fromDate as fromDate," +
|
||||
"b.detail_fromTime as fromTime," +
|
||||
"b.detail_toDate as toDate," +
|
||||
"b.detail_toTime as toTime," +
|
||||
"b.detail_duration as duration," +
|
||||
"a.requestid," +
|
||||
"a.leaverequestid as leavebackrequestid " +
|
||||
"from "+leaveTableName+" a left join "+leaveTableName+"_dt1 b on a.id = b.mainid) u " +
|
||||
"left join (select * from hrmresource a where 1 = 1) a on u.resourceid = a.id) f";
|
||||
sqlWhere = " where 1 = 1" +
|
||||
" and req_requestid > 0" +
|
||||
" and (fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' or" +
|
||||
" '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate)" ;
|
||||
String allSql = "select "+ backfields + fromSql+sqlWhere;
|
||||
kqLog.info("==getLeaveBackDataNew=="+allSql);
|
||||
rs.executeQuery(allSql);
|
||||
while(rs.next()){
|
||||
String fromDate_field = "fromDate";
|
||||
String fromTime_field = "fromTime";
|
||||
String toDate_field = "toDate";
|
||||
String toTime_field = "toTime";
|
||||
String rosource_field = "resourceid";
|
||||
String leavebackrequestid_field = "leavebackrequestid";
|
||||
|
||||
|
||||
//==zj 换成自定义字段
|
||||
String related_requestid = rs.getString("REQUESTSYNCID");
|
||||
String flow_fromDate = rs.getString(fromDate_field);
|
||||
String flow_fromTime = rs.getString(fromTime_field);
|
||||
String flow_toDate = rs.getString(toDate_field);
|
||||
String flow_toTime = rs.getString(toTime_field);
|
||||
String resourceid = rs.getString(rosource_field);
|
||||
String leavebackrequestid = rs.getString(leavebackrequestid_field);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("flow_fromDate", flow_fromDate);
|
||||
infoMap.put("flow_toDate", flow_toDate);
|
||||
//加下销假流程
|
||||
infoMap.put("leavebackrequestid", leavebackrequestid);
|
||||
|
||||
if (flowMaps.get(leavebackrequestid) == null){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(leavebackrequestid,time_list);
|
||||
}else {
|
||||
List<Map<String,String>> time_list = ( List<Map<String,String>>) flowMaps.get(leavebackrequestid);
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(leavebackrequestid,time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当天是否有请假
|
||||
* @param workFlowInfo
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public boolean isLeaveNew(Map<String, Object> workFlowInfo,String resourceid,String kqdate,Map<String, Object> workFlowInfoBackNew){
|
||||
List<Object> workFlow =Optional.ofNullable( (List<Object>) workFlowInfo.get(resourceid)).orElse(Collections.emptyList());
|
||||
boolean ishave = false;
|
||||
for (int i = 0; i < workFlow.size(); i++) {
|
||||
Map<String, Object> workFlowDetail = (Map<String, Object>) workFlow.get(i);
|
||||
String fromdatedb = Util.null2String(workFlowDetail.get("fromdatedb"));
|
||||
String todatedb = Util.null2String(workFlowDetail.get("todatedb"));
|
||||
String requestid = Util.null2String(workFlowDetail.get("requestid"));
|
||||
String flowtype = Util.null2String(workFlowDetail.get("flowtype"));
|
||||
if (kqdate.compareTo(fromdatedb) >= 0 && kqdate.compareTo(todatedb) <=0){
|
||||
ishave = true;
|
||||
if (ishave){
|
||||
//再看看是否有销假流程
|
||||
if (workFlowInfoBackNew != null){
|
||||
List<Object> workFlowBack = new ArrayList<>();
|
||||
String key = "";
|
||||
if ("leave".equals(flowtype)){
|
||||
key = resourceid;
|
||||
}else if ("out".equals(flowtype) || "evection".equals(flowtype)){
|
||||
key = resourceid+"|"+requestid;
|
||||
}
|
||||
workFlowBack = Optional.ofNullable((List<Object>) workFlowInfoBackNew.get(key))
|
||||
.orElse(Collections.emptyList());
|
||||
for (int j = 0; j < workFlowBack.size(); j++) {
|
||||
Map<String, Object> workFlowBackDetail = (Map<String, Object>) workFlowBack.get(j);
|
||||
String fromdateBackdb = Util.null2String(workFlowBackDetail.get("fromdatedb"));
|
||||
String todateBackdb = Util.null2String(workFlowBackDetail.get("todatedb"));
|
||||
if ( kqdate.compareTo(fromdateBackdb) >= 0 && kqdate.compareTo(todateBackdb) <=0){
|
||||
ishave = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ishave;
|
||||
}
|
||||
|
||||
/**
|
||||
* 出差校验
|
||||
* @param workFlowInfo
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public boolean isEcectionNew(Map<String, Object> workFlowInfo,String resourceid,String kqdate,Map<String, Object> workFlowInfoChangeNew){
|
||||
|
||||
List<Object> workFlow =Optional.ofNullable( (List<Object>) workFlowInfo.get(resourceid)).orElse(Collections.emptyList());
|
||||
boolean ishave = false;
|
||||
for (int i = 0; i < workFlow.size(); i++) {
|
||||
Map<String, Object> workFlowDetail = (Map<String, Object>) workFlow.get(i);
|
||||
String fromdatedb = Util.null2String(workFlowDetail.get("fromdatedb"));
|
||||
String todatedb = Util.null2String(workFlowDetail.get("todatedb"));
|
||||
String requestid = Util.null2String(workFlowDetail.get("requestid"));
|
||||
String flowtype = Util.null2String(workFlowDetail.get("flowtype"));
|
||||
if (kqdate.compareTo(fromdatedb) >= 0 && kqdate.compareTo(todatedb) <=0){
|
||||
ishave = true;
|
||||
if (workFlowInfoChangeNew != null){
|
||||
//这里兼容下考勤变更流程
|
||||
List<Object> workFlowBack = new ArrayList<>();
|
||||
String key = "";
|
||||
if ("leave".equals(flowtype)){
|
||||
key = resourceid;
|
||||
}else if ("out".equals(flowtype) || "evection".equals(flowtype)){
|
||||
key = resourceid+"|"+requestid;
|
||||
}
|
||||
workFlowBack = Optional.ofNullable((List<Object>) workFlowInfoChangeNew.get(key))
|
||||
.orElse(Collections.emptyList());
|
||||
for (int j = 0; j < workFlowBack.size(); j++) {
|
||||
ishave = false;
|
||||
//如果是出差或者外出流程的话,说明流程被更改,状态需要重置
|
||||
if ("out".equals(flowtype) || "evection".equals(flowtype)){
|
||||
ishave = false;
|
||||
}
|
||||
Map<String, Object> workFlowBackDetail = (Map<String, Object>) workFlowBack.get(j);
|
||||
String fromdateBackdb = Util.null2String(workFlowBackDetail.get("fromdatedb"));
|
||||
String todateBackdb = Util.null2String(workFlowBackDetail.get("todatedb"));
|
||||
if (("out".equals(flowtype) || "evection".equals(flowtype)) && kqdate.compareTo(fromdateBackdb) >= 0 && kqdate.compareTo(todateBackdb) <=0){
|
||||
ishave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ishave;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当天是否有考勤流程
|
||||
* @param workFlowInfo
|
||||
* @param resourceid
|
||||
* @return
|
||||
*/
|
||||
public boolean isKqFlowNew(Map<String, Object> workFlowInfo,String resourceid,String kqdate){
|
||||
|
||||
List<Object> workFlow =Optional.ofNullable( (List<Object>) workFlowInfo.get(resourceid)).orElse(Collections.emptyList());
|
||||
boolean ishave = false;
|
||||
for (int i = 0; i < workFlow.size(); i++) {
|
||||
Map<String, Object> workFlowDetail = (Map<String, Object>) workFlow.get(i);
|
||||
String fromdatedb = Util.null2String(workFlowDetail.get("fromdatedb"));
|
||||
String todatedb = Util.null2String(workFlowDetail.get("todatedb"));
|
||||
String flowtype = Util.null2String(workFlowDetail.get("flowtype"));
|
||||
if (kqdate.compareTo(fromdatedb) >= 0 && kqdate.compareTo(todatedb) <=0){
|
||||
ishave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ishave;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月份第一天和最后一天
|
||||
* @param kqMonth
|
||||
* @param isFirst
|
||||
* @return
|
||||
*/
|
||||
public String getMonthDay(String kqMonth,boolean isFirst){
|
||||
String monthDay = "";
|
||||
|
||||
try {
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
if (isFirst){
|
||||
YearMonth yearMonth = YearMonth.parse(kqMonth);
|
||||
monthDay = yearMonth.atDay(1).format(dateTimeFormatter);
|
||||
}else {
|
||||
YearMonth yearMonth = YearMonth.parse(kqMonth);
|
||||
monthDay = yearMonth.atEndOfMonth().format(dateTimeFormatter); // 返回当月的最后一天
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return monthDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当天是否有请假
|
||||
* @param workFlowInfo
|
||||
* @param resourceid
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public boolean isLeave(Map<String, Object> workFlowInfo,String resourceid,String date,KQTimesArrayComInfo kqTimesArrayComInfo){
|
||||
List<Object> workFlow = (List<Object>) workFlowInfo.get(resourceid+"|"+date);
|
||||
boolean ishave = false;
|
||||
for (int k = 0; k < workFlow.size(); k++) {
|
||||
Map<String, Object> workFlowDetail = (Map<String, Object>) workFlow.get(k);
|
||||
String begintime = Util.null2String(workFlowDetail.get("begintime"));
|
||||
String endtime = Util.null2String(workFlowDetail.get("endtime"));
|
||||
String flowType = Util.null2String(workFlowDetail.get("flowtype"));
|
||||
|
||||
int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime);
|
||||
int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime);
|
||||
if (beginIdx >= endIdx) {
|
||||
continue;
|
||||
}else {
|
||||
ishave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ishave;
|
||||
}
|
||||
|
||||
public String isLeave(Map<String, Object> workFlowInfo,String resourceid,String date,KQTimesArrayComInfo kqTimesArrayComInfo,String lastname,String warnMessage){
|
||||
List<Object> workFlow = (List<Object>) workFlowInfo.get(resourceid+"|"+date);
|
||||
boolean isLeave = false;
|
||||
boolean isEvection = false;
|
||||
boolean isOut= false;
|
||||
StringBuilder warnMessageBuilder = new StringBuilder(warnMessage);
|
||||
for (int k = 0; k < workFlow.size(); k++) {
|
||||
Map<String, Object> workFlowDetail = (Map<String, Object>) workFlow.get(k);
|
||||
String begintime = Util.null2String(workFlowDetail.get("begintime"));
|
||||
String endtime = Util.null2String(workFlowDetail.get("endtime"));
|
||||
String flowType = Util.null2String(workFlowDetail.get("flowtype"));
|
||||
|
||||
int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime);
|
||||
int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime);
|
||||
if (beginIdx >= endIdx) {
|
||||
continue;
|
||||
}else {
|
||||
// if (flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType()) && !isEvection){
|
||||
// isEvection = true;
|
||||
// warnMessageBuilder.append(lastname).append(",").append(date).append(",已有出差。").append("1".equals(isline) ? "\n" : "");
|
||||
// }else
|
||||
if (flowType.equals(FlowReportTypeEnum.LEAVE.getFlowType())&& !isLeave){
|
||||
isLeave = true;
|
||||
warnMessageBuilder.append(lastname).append(",").append(date).append(",已有请假。").append("1".equals(isline) ? "\n" : "");
|
||||
|
||||
}
|
||||
// else if (flowType.equals(FlowReportTypeEnum.OUT.getFlowType())&& !isOut){
|
||||
// isOut = true;
|
||||
// warnMessageBuilder.append(lastname).append(",").append(date).append(",已有外出。").append("1".equals(isline) ? "\n" : "");
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
kqLog.info("==warnMessage=="+warnMessage);
|
||||
warnMessage = warnMessageBuilder.toString();
|
||||
return warnMessage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 判断当天是否有请假
|
||||
* @param workFlowInfo
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public boolean isLeave(Map<String, Object> workFlowInfo,String key,KQTimesArrayComInfo kqTimesArrayComInfo){
|
||||
List<Object> workFlow = (List<Object>) workFlowInfo.get(key);
|
||||
boolean ishave = false;
|
||||
for (int k = 0; k < workFlow.size(); k++) {
|
||||
Map<String, Object> workFlowDetail = (Map<String, Object>) workFlow.get(k);
|
||||
String begintime = Util.null2String(workFlowDetail.get("begintime"));
|
||||
String endtime = Util.null2String(workFlowDetail.get("endtime"));
|
||||
int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime);
|
||||
int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime);
|
||||
if (beginIdx >= endIdx) {
|
||||
continue;
|
||||
}else {
|
||||
ishave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ishave;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
package com.api.customization.kq.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.kq.biz.KQAttProcSetComInfo;
|
||||
import com.engine.kq.biz.KQFlowActiontBiz;
|
||||
import com.engine.kq.enums.KqSplitFlowTypeEnum;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import com.engine.kq.wfset.bean.SplitBean;
|
||||
import com.engine.kq.wfset.util.KQFlowEvectionUtil;
|
||||
import com.engine.kq.wfset.util.KQFlowLeaveUtil;
|
||||
import com.engine.kq.wfset.util.KQFlowOutUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.workflow.WorkflowComInfo;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KqCustomAction extends BaseBean implements Action {
|
||||
private KQLog kqLog = new KQLog();
|
||||
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo request) {
|
||||
//e8 的状态标识
|
||||
int DEDUCTION = 0;
|
||||
int FREEZE = 1;
|
||||
int RELEASE = 2;
|
||||
int CUSTOM = 3;
|
||||
this.writeLog("KqFreezeVacationAction", "do action on request:" + request.getRequestid());
|
||||
String requestid = request.getRequestid();
|
||||
kqLog.info("do KqFreezeVacationAction on requestid:"+requestid);
|
||||
int requestidInt = Util.getIntValue(requestid, 0);
|
||||
|
||||
String workflowid = request.getWorkflowid();
|
||||
String formid = new WorkflowComInfo().getFormId(workflowid);
|
||||
KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo();
|
||||
int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1);
|
||||
|
||||
//解除限制吧
|
||||
// if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){
|
||||
// return Action.SUCCESS;
|
||||
// }
|
||||
|
||||
try {
|
||||
List<SplitBean> splitBeans = new ArrayList<SplitBean>();
|
||||
List<String> custome_field = Lists.newArrayList();
|
||||
Map<String,String> custome_map = Maps.newHashMap();
|
||||
Map<String,String> result = new HashMap<>();
|
||||
|
||||
KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz();
|
||||
ResourceComInfo rci = new ResourceComInfo();
|
||||
DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? ";
|
||||
rs.executeQuery(proc_set_sql, workflowid,formid);
|
||||
int kqtype = -1;
|
||||
String tableName = "";
|
||||
if(rs.next()){
|
||||
String proc_set_id = rs.getString("id");
|
||||
//得到这个考勤流程设置是否使用明细
|
||||
String usedetails = rs.getString("usedetail");
|
||||
kqtype = Util.getIntValue(rs.getString("field006"));
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if(requestidInt > 0){
|
||||
map.put("requestId", "and t.requestId = " + requestidInt);
|
||||
}
|
||||
|
||||
Map<String, String> sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map);
|
||||
|
||||
//这里兼容下多考勤类型流程
|
||||
if (kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){
|
||||
KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil();
|
||||
result = kqFlowLeaveUtil.handleKQLeaveAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci);
|
||||
}else if (kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){
|
||||
KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil();
|
||||
result = kqFlowEvectionUtil.handleKQEvectionAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci);
|
||||
}else if (kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){
|
||||
KQFlowOutUtil kqFlowOutUtil = new KQFlowOutUtil();
|
||||
result = kqFlowOutUtil.handleKQOutAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci);
|
||||
}
|
||||
if(!result.isEmpty()){
|
||||
String error = Util.null2String(result.get("message"));
|
||||
request.getRequestManager().setMessageid("666" + request.getRequestid() + "999");
|
||||
request.getRequestManager().setMessagecontent(error);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
//这里兼容下多考勤类型流程
|
||||
if (kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){
|
||||
tableName = "kq_flow_split_temp_leave";
|
||||
}else if (kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){
|
||||
tableName = "kq_flow_split_temp_evection";
|
||||
}else if (kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){
|
||||
tableName = "kq_flow_split_temp_out";
|
||||
}
|
||||
kqLog.info("KqCustomAction splitBeans:"+ JSON.toJSONString(splitBeans));
|
||||
String batchSql = "insert into "+tableName+ "("
|
||||
+ "requestid,workflowid,dataid,detailid,resourceid,fromdate,fromtime,"
|
||||
+ "todate,totime,newleavetype,duration,usedetail,durationrule,tablenamedb,fromdatedb,"
|
||||
+ "fromtimedb,todatedb,totimedb,durationdb,status,belongDate,D_Mins,serialid,"
|
||||
+ "changeType,subcompanyid,departmentid,jobtitle,companion,iscompanion"+getCustomField(custome_field,"field",null,
|
||||
custome_map)+")"+
|
||||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?"+getCustomField(custome_field,"param",null,
|
||||
custome_map)+") ";
|
||||
List<List> params = new ArrayList<List>();
|
||||
|
||||
String delSql = "delete from "+tableName+" where requestId=?";
|
||||
List<List> delparams = new ArrayList<List>();
|
||||
|
||||
for(SplitBean bean : splitBeans){
|
||||
List<Object> beanParams = new ArrayList<Object>();
|
||||
beanParams.add(bean.getRequestId());
|
||||
beanParams.add(bean.getWorkflowId());
|
||||
beanParams.add(bean.getDataId());
|
||||
beanParams.add(bean.getDetailId());
|
||||
beanParams.add(bean.getResourceId());
|
||||
beanParams.add(bean.getFromDate());
|
||||
beanParams.add(bean.getFromTime());
|
||||
beanParams.add(bean.getToDate());
|
||||
beanParams.add(bean.getToTime());
|
||||
beanParams.add(bean.getNewLeaveType());
|
||||
beanParams.add(Util.null2s(bean.getDuration(),"0"));
|
||||
beanParams.add(bean.getUsedetail());
|
||||
beanParams.add(bean.getDurationrule());
|
||||
beanParams.add(bean.getTablenamedb());
|
||||
beanParams.add(bean.getFromdatedb());
|
||||
beanParams.add(bean.getFromtimedb());
|
||||
beanParams.add(bean.getTodatedb());
|
||||
beanParams.add(bean.getTotimedb());
|
||||
beanParams.add(bean.getDurationDB());
|
||||
beanParams.add(bean.getStatus());
|
||||
beanParams.add(bean.getBelongDate());
|
||||
beanParams.add(bean.getD_Mins());
|
||||
beanParams.add(bean.getSerialid());
|
||||
beanParams.add(bean.getChangeType());
|
||||
beanParams.add(bean.getSubcompanyid());
|
||||
beanParams.add(bean.getDepartmentid());
|
||||
beanParams.add(bean.getJobtitle());
|
||||
beanParams.add(bean.getCompanion());
|
||||
beanParams.add(bean.getIscompanion());
|
||||
if(!custome_field.isEmpty()){
|
||||
getCustomField(custome_field, "value",beanParams,custome_map);
|
||||
}
|
||||
|
||||
params.add(beanParams);
|
||||
|
||||
List<Object> delParam = new ArrayList<Object>();
|
||||
delParam.add(bean.getRequestId());
|
||||
delparams.add(delParam);
|
||||
}
|
||||
if(!params.isEmpty()){
|
||||
boolean delOk = rs1.executeBatchSql(delSql, delparams);
|
||||
if(!delOk){
|
||||
request.getRequestManager().setMessageid("666" + request.getRequestid() + "999");
|
||||
request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params);
|
||||
kqLog.info("KqCustomAction删除数据失败:"+requestid);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
boolean isOk = rs1.executeBatchSql(batchSql, params);
|
||||
if(!isOk){
|
||||
request.getRequestManager().setMessageid("666" + request.getRequestid() + "999");
|
||||
request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params);
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}else{
|
||||
kqLog.info("KqCustomAction没有数据:"+requestid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
kqLog.info("KqCustomAction:"+e);
|
||||
request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222");
|
||||
request.getRequestManager().setMessagecontent("请假流程【KqCustomAction】报错,请联系管理员!");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 考勤流程中间表针对某个流程扩展字段
|
||||
* @param custome_field
|
||||
* @param key
|
||||
* @param beanParams
|
||||
* @param custome_map
|
||||
* @return
|
||||
*/
|
||||
public String getCustomField(List<String> custome_field, String key, List<Object> beanParams,
|
||||
Map<String, String> custome_map) {
|
||||
String fieldValue = "";
|
||||
if(!custome_field.isEmpty()){
|
||||
for(int i = 0 ; i < custome_field.size() ; i++){
|
||||
String tmp_value = Util.null2String(custome_field.get(i));
|
||||
if(tmp_value.length() > 0){
|
||||
if("field".equalsIgnoreCase(key)){
|
||||
fieldValue += ","+tmp_value;
|
||||
}else if("param".equalsIgnoreCase(key)){
|
||||
fieldValue += ",?";
|
||||
}else if("value".equalsIgnoreCase(key)){
|
||||
String value = custome_map.get(tmp_value);
|
||||
beanParams.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fieldValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,424 @@
|
|||
package com.api.customization.kq.util;
|
||||
|
||||
import com.engine.kq.enums.FlowReportTypeEnum;
|
||||
import com.engine.kq.enums.KqSplitFlowTypeEnum;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import com.engine.kq.wfset.bean.SplitBean;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KqCustomFlowData {
|
||||
private KQLog kqLog = new KQLog();
|
||||
|
||||
/**
|
||||
* 获取出差相关的数据
|
||||
*/
|
||||
public List<SplitBean> getEvectionData(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String tablename = "select a.* from kq_flow_split_temp_evection a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
|
||||
String sqlWhere = "";
|
||||
if(fromDate.length() > 0 && toDate.length() > 0){
|
||||
sqlWhere += " and belongdate between '"+fromDate+"' and '"+toDate+"' ";
|
||||
}
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
tablename += sqlWhere;
|
||||
}
|
||||
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
|
||||
|
||||
|
||||
|
||||
List<SplitBean> splitBeans = new ArrayList<>();
|
||||
rs.execute(leaveSql);
|
||||
while(rs.next()){
|
||||
SplitBean splitBean = new SplitBean();
|
||||
String requestId= rs.getString("requestId");
|
||||
String resourceid= rs.getString("resourceid");
|
||||
String fromdate= rs.getString("fromdate");
|
||||
String belongdate= rs.getString("belongdate");
|
||||
String fromtime= rs.getString("fromtime");
|
||||
String todate= rs.getString("todate");
|
||||
String totime= rs.getString("totime");
|
||||
String newleavetype= rs.getString("newleavetype");
|
||||
String duration= rs.getString("duration");
|
||||
String durationrule= rs.getString("durationrule");
|
||||
|
||||
splitBean.setRequestId(requestId);
|
||||
splitBean.setResourceId(resourceid);
|
||||
splitBean.setFromDate(fromdate);
|
||||
splitBean.setFromTime(fromtime);
|
||||
splitBean.setToDate(todate);
|
||||
splitBean.setToTime(totime);
|
||||
splitBean.setNewLeaveType(newleavetype);
|
||||
splitBean.setDuration(duration);
|
||||
splitBean.setDurationrule(durationrule);
|
||||
splitBeans.add(splitBean);
|
||||
|
||||
if(Util.getDoubleValue(duration) <= 0){
|
||||
continue;
|
||||
}
|
||||
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
|
||||
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
|
||||
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.EVECTION.getFlowtype();
|
||||
String serial_signtype = "";
|
||||
String serial = "";
|
||||
String signtype = "";
|
||||
|
||||
|
||||
Map<String,String> infoMap = new HashMap<>();
|
||||
infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration);
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put("begintime", fromtime);
|
||||
infoMap.put("endtime", totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("duration", duration);
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.EVECTION.getFlowType());
|
||||
infoMap.put("signtype", signtype);
|
||||
infoMap.put("serial", serial);
|
||||
|
||||
String key = resourceid+"|"+belongdate;
|
||||
if(flowMaps != null){
|
||||
if(flowMaps.get(key) != null){
|
||||
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
|
||||
time_list_tmp.add(infoMap);
|
||||
}else{
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key, time_list);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return splitBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公出相关的数据
|
||||
*/
|
||||
public List<SplitBean> getOutData(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String tablename = "select a.* from kq_flow_split_temp_out a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
|
||||
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
|
||||
String sqlWhere = "";
|
||||
if(fromDate.length() > 0 && toDate.length() > 0){
|
||||
sqlWhere += " and belongdate between '"+fromDate+"' and '"+toDate+"' ";
|
||||
}
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
tablename += sqlWhere;
|
||||
}
|
||||
List<SplitBean> splitBeans = new ArrayList<>();
|
||||
rs.execute(leaveSql);
|
||||
while(rs.next()){
|
||||
SplitBean splitBean = new SplitBean();
|
||||
String requestId= rs.getString("requestId");
|
||||
String resourceid= rs.getString("resourceid");
|
||||
String fromdate= rs.getString("fromdate");
|
||||
String belongdate= rs.getString("belongdate");
|
||||
String fromtime= rs.getString("fromtime");
|
||||
String todate= rs.getString("todate");
|
||||
String totime= rs.getString("totime");
|
||||
String newleavetype= rs.getString("newleavetype");
|
||||
String duration= rs.getString("duration");
|
||||
String durationrule= rs.getString("durationrule");
|
||||
|
||||
splitBean.setRequestId(requestId);
|
||||
splitBean.setResourceId(resourceid);
|
||||
splitBean.setFromDate(fromdate);
|
||||
splitBean.setFromTime(fromtime);
|
||||
splitBean.setToDate(todate);
|
||||
splitBean.setToTime(totime);
|
||||
splitBean.setNewLeaveType(newleavetype);
|
||||
splitBean.setDuration(duration);
|
||||
splitBean.setDurationrule(durationrule);
|
||||
splitBeans.add(splitBean);
|
||||
|
||||
if(Util.getDoubleValue(duration) <= 0){
|
||||
continue;
|
||||
}
|
||||
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
|
||||
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
|
||||
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.OUT.getFlowtype();
|
||||
String serial_signtype = "";
|
||||
String serial = "";
|
||||
String signtype = "";
|
||||
|
||||
|
||||
Map<String,String> infoMap = new HashMap<>();
|
||||
infoMap.put(FlowReportTypeEnum.officialBusiness.getFlowType(), duration);
|
||||
infoMap.put("requestId", requestId);
|
||||
infoMap.put("begintime", fromtime);
|
||||
infoMap.put("endtime", totime);
|
||||
infoMap.put("unitType", unitType);
|
||||
infoMap.put("duration", duration);
|
||||
infoMap.put("flowtype", FlowReportTypeEnum.OUT.getFlowType());
|
||||
infoMap.put("signtype", signtype);
|
||||
infoMap.put("serial", serial);
|
||||
|
||||
String key = resourceid+"|"+belongdate;
|
||||
if(flowMaps != null){
|
||||
if(flowMaps.get(key) != null){
|
||||
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
|
||||
time_list_tmp.add(infoMap);
|
||||
}else{
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key, time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
return splitBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 这里获取下考勤变更流程
|
||||
* @param flowMaps
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
*/
|
||||
public void getChangeData(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> infoMap = new HashMap<>();
|
||||
|
||||
String backfields = " * ";
|
||||
String fromSql = "";
|
||||
String sqlWhere = "";
|
||||
String changeTableName = new BaseBean().getPropValue("qc3560103","changeTableName");
|
||||
|
||||
//重新写一下吧
|
||||
fromSql = " from (select distinct " +
|
||||
"u.*," +
|
||||
"u.requestid as req_requestid," +
|
||||
"a.managerid," +
|
||||
"a.managerstr," +
|
||||
"a.loginid," +
|
||||
"a.subcompanyid1 as asubcompanyid1," +
|
||||
"a.departmentid as adepartmentid," +
|
||||
"a.lastname " +
|
||||
"from (select a.resourceId as resourceId," +
|
||||
// "a.departmentId as departmentId," +
|
||||
"b.detail_fromDate as fromDate," +
|
||||
"b.detail_toDate as toDate," +
|
||||
"b.detail_duration as duration," +
|
||||
"a.requestid," +
|
||||
"a.changerequestid as changerequestid " +
|
||||
"from "+changeTableName+" a left join "+changeTableName+"_dt1 b on a.id = b.mainid) u " +
|
||||
"left join (select * from hrmresource a where 1 = 1) a on u.resourceid = a.id) f";
|
||||
sqlWhere = " where 1 = 1" +
|
||||
" and req_requestid > 0" +
|
||||
" and (fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' or" +
|
||||
" '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate)" ;
|
||||
String allSql = "select "+ backfields + fromSql+sqlWhere;
|
||||
kqLog.info("==getChangeDataNew=="+allSql);
|
||||
rs.executeQuery(allSql);
|
||||
while(rs.next()){
|
||||
String fromDate_field = "fromDate";
|
||||
String toDate_field = "toDate";
|
||||
String rosource_field = "resourceid";
|
||||
String changerequestid_field = "changerequestid";
|
||||
|
||||
|
||||
//==zj 换成自定义字段
|
||||
String related_requestid = rs.getString("REQUESTSYNCID");
|
||||
String flow_fromDate = rs.getString(fromDate_field);
|
||||
String flow_toDate = rs.getString(toDate_field);
|
||||
String resourceid = rs.getString(rosource_field);
|
||||
String changerequestid = rs.getString(changerequestid_field);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("fromdatedb", flow_fromDate);
|
||||
infoMap.put("todatedb", flow_toDate);
|
||||
infoMap.put("requestid",related_requestid);
|
||||
|
||||
String key = resourceid+"|"+changerequestid;//记录的是改变哪个流程对应人员的考勤流程
|
||||
|
||||
if (flowMaps.get(key) == null){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key,time_list);
|
||||
}else {
|
||||
List<Map<String,String>> time_list = ( List<Map<String,String>>) flowMaps.get(key);
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key,time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取班次数据(获取原始表信息)
|
||||
* @param flowMaps
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
*/
|
||||
public void getShiftDataNew(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> infoMap = new HashMap<>();
|
||||
|
||||
String backfields = " * ";
|
||||
String fromSql = "";
|
||||
String sqlWhere = "";
|
||||
String shiftTableName = new BaseBean().getPropValue("qc3560103","shiftTableName");
|
||||
|
||||
//重新写一下吧
|
||||
fromSql = " from (select distinct " +
|
||||
"u.*," +
|
||||
"u.requestid as req_requestid," +
|
||||
"a.managerid," +
|
||||
"a.managerstr," +
|
||||
"a.loginid," +
|
||||
"a.subcompanyid1 as asubcompanyid1," +
|
||||
"a.departmentid as adepartmentid," +
|
||||
"a.lastname " +
|
||||
"from (select b.detail_resourceId as resourceId," +
|
||||
// "a.departmentId as departmentId," +
|
||||
"b.detail_fromDate as fromDate," +
|
||||
"b.detail_toDate as toDate," +
|
||||
"a.requestid " +
|
||||
"from "+shiftTableName+" a left join "+shiftTableName+"_dt1 b on a.id = b.mainid) u " +
|
||||
"left join (select * from hrmresource a where 1 = 1) a on u.resourceid = a.id) f "+
|
||||
"inner join workflow_requestbase r on r.requestid = u.requestid ";
|
||||
sqlWhere = " where r.currentnodetype in(1,2,3) " +
|
||||
" and req_requestid > 0" +
|
||||
" and (fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' or" +
|
||||
" '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate)" ;
|
||||
String allSql = "select "+ backfields + fromSql+sqlWhere;
|
||||
kqLog.info("==getShiftDataNew=="+allSql);
|
||||
new BaseBean().writeLog("==getShiftDataNew=="+allSql);
|
||||
rs.executeQuery(allSql);
|
||||
while(rs.next()){
|
||||
String fromDate_field = "fromDate";
|
||||
String toDate_field = "toDate";
|
||||
String rosource_field = "resourceid";
|
||||
|
||||
//==zj 换成自定义字段
|
||||
String flow_fromDate = rs.getString(fromDate_field);
|
||||
String flow_toDate = rs.getString(toDate_field);
|
||||
String resourceid = rs.getString(rosource_field);
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("fromdatedb", flow_fromDate);
|
||||
infoMap.put("todatedb", flow_toDate);
|
||||
infoMap.put("flowtype","shift");
|
||||
//加下销假流程
|
||||
|
||||
if (flowMaps.get(resourceid) == null){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(resourceid,time_list);
|
||||
}else {
|
||||
List<Map<String,String>> time_list = ( List<Map<String,String>>) flowMaps.get(resourceid);
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(resourceid,time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取出差流程数据(原始信息)
|
||||
* @param flowMaps
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
*/
|
||||
public void getEvectionDataNew(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> infoMap = new HashMap<>();
|
||||
String evectionTableName = new BaseBean().getPropValue("qc3560103","evectionTableName");
|
||||
|
||||
String tablename = "select a.* from kq_flow_split_temp_evection a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
|
||||
String sqlWhere = "";
|
||||
|
||||
if(fromDate.length() > 0 && toDate.length() > 0){
|
||||
sqlWhere += " and belongdate between '"+fromDate+"' and '"+toDate+"' ";
|
||||
}
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
tablename += sqlWhere;
|
||||
}
|
||||
|
||||
String leaveSql = "select distinct resourceid,requestid,fromDatedb,toDatedb from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
|
||||
|
||||
|
||||
rs.executeQuery(leaveSql);
|
||||
while(rs.next()){
|
||||
//==zj 换成自定义字段
|
||||
String requestid = rs.getString("requestid");
|
||||
String fromDatedb = rs.getString("fromDatedb");
|
||||
String toDatedb = rs.getString("toDatedb");
|
||||
String resourceid = rs.getString("resourceid");
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("fromdatedb", fromDatedb);
|
||||
infoMap.put("todatedb", toDatedb);
|
||||
infoMap.put("requestid", requestid);
|
||||
infoMap.put("flowtype","evection");
|
||||
String key = resourceid;
|
||||
|
||||
if (flowMaps.get(key) == null){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key,time_list);
|
||||
}else {
|
||||
List<Map<String,String>> time_list = ( List<Map<String,String>>) flowMaps.get(key);
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key,time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取外出流程数据(原始表信息)
|
||||
* @param flowMaps
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
*/
|
||||
public void getOutDataNew(Map<String, Object> flowMaps,String fromDate,String toDate){
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> infoMap = new HashMap<>();
|
||||
String outTableName = new BaseBean().getPropValue("qc3560103","outTableName");
|
||||
|
||||
String tablename = "select a.* from kq_flow_split_temp_out a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
|
||||
String sqlWhere = "";
|
||||
|
||||
if(fromDate.length() > 0 && toDate.length() > 0){
|
||||
sqlWhere += " and belongdate between '"+fromDate+"' and '"+toDate+"' ";
|
||||
}
|
||||
|
||||
if(sqlWhere.length() > 0){
|
||||
tablename += sqlWhere;
|
||||
}
|
||||
|
||||
String leaveSql = "select distinct resourceid,requestid,fromDatedb,toDatedb from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
|
||||
|
||||
|
||||
rs.executeQuery(leaveSql);
|
||||
while(rs.next()){
|
||||
//==zj 换成自定义字段
|
||||
String requestid = rs.getString("requestid");
|
||||
String fromDatedb = rs.getString("fromDatedb");
|
||||
String toDatedb = rs.getString("toDatedb");
|
||||
String resourceid = rs.getString("resourceid");
|
||||
infoMap = new HashMap<>();
|
||||
infoMap.put("fromdatedb", fromDatedb);
|
||||
infoMap.put("todatedb", toDatedb);
|
||||
infoMap.put("requestid", requestid);
|
||||
infoMap.put("flowtype","evection");
|
||||
String key = resourceid;
|
||||
|
||||
if (flowMaps.get(key) == null){
|
||||
List<Map<String,String>> time_list = new ArrayList<>();
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key,time_list);
|
||||
}else {
|
||||
List<Map<String,String>> time_list = ( List<Map<String,String>>) flowMaps.get(key);
|
||||
time_list.add(infoMap);
|
||||
flowMaps.put(key,time_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
package com.api.customization.kq.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.kq.biz.KQGroupBiz;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KqShiftScheduleRoleBiz;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KqMembersValidateUtil {
|
||||
|
||||
/**
|
||||
* 获取当前考勤组的人员开始生效日期
|
||||
* @param groupId
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getValidateFromData(String groupId, User user){
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
Map<String, List<Map<String, String>>> resultByResourceId = new HashMap<>();
|
||||
Map<String, String> validateFromMaps = new HashMap<>();
|
||||
Map<String, Integer> userIdLevelMap = new HashMap<>();
|
||||
try {
|
||||
RecordSet rs = new RecordSet();
|
||||
KQGroupComInfo kQGroupComInfo = new KQGroupComInfo();
|
||||
String status = "9";
|
||||
|
||||
List<String> managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue((user==null ? "" : ""+user.getUID()), groupId);
|
||||
String viewscope = "0";//0:总部 1:分部 2:部门 3:人员 4:我的下属
|
||||
int pageIndex = 0;//Util.getIntValue(Util.null2String(params.get("pageIndex")), 1);
|
||||
int pageSize = 0;//Util.getIntValue(Util.null2String(params.get("pageSize")), 20);
|
||||
|
||||
String sqlWhere = " ";
|
||||
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.validatefrom, t.validateto,t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid,t.type ";
|
||||
String sqlFrom = " from (SELECT distinct t.resourceid, t.validatefrom, t.validateto,t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid,t.type FROM ( \n" +
|
||||
" SELECT a.id AS resourceid, b.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type 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.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type 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.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type 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.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type 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.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type 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;
|
||||
// if (!managerRoleUserIdList.isEmpty()) {
|
||||
// String allUserIds = StringUtils.join(managerRoleUserIdList, ',');
|
||||
// sqlFrom += " and " + Util.getSubINClause(allUserIds, "t.resourceid", "in");
|
||||
// }
|
||||
String groupBy = " ";
|
||||
|
||||
String sql = backFields + sqlFrom + sqlWhere + groupBy;
|
||||
sql = " select " + sql;
|
||||
rs.executeQuery(sql);
|
||||
new BaseBean().writeLog("==zjValidateFromDatasql=="+sql);
|
||||
while (rs.next()) {
|
||||
String resourceId = Util.null2String(rs.getString("resourceid"));
|
||||
String validatefrom = Util.null2String(rs.getString("validatefrom"));
|
||||
validatefrom = "".equals(validatefrom) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validatefrom;
|
||||
String validateto = Util.null2String(rs.getString("validateto"));
|
||||
validateto = "".equals(validateto) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateto;
|
||||
String key = resourceId+"|validatefrom";
|
||||
int type = Util.getIntValue(rs.getString("type"));
|
||||
int oldType = userIdLevelMap.getOrDefault(key, 0);
|
||||
boolean needAdd = false;
|
||||
if (oldType == 0) { // 如果userIdLevelMap里面没有,就添加进去
|
||||
needAdd = true;
|
||||
} else {
|
||||
//1: 人力资源
|
||||
//2:分部
|
||||
//3:部门
|
||||
//5:岗位
|
||||
//6:所有人
|
||||
//优先级: 人力资源>部门>分部>岗位>所有人
|
||||
switch (type) {
|
||||
case 1:
|
||||
if(oldType == 1) {
|
||||
needAdd = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(oldType == 2 || oldType == 5 || oldType == 6) {
|
||||
needAdd = true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(oldType == 3 || oldType == 2 || oldType == 5 || oldType == 6) {
|
||||
needAdd = true;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if(oldType == 5 || oldType == 6) {
|
||||
needAdd = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(needAdd) {
|
||||
userIdLevelMap.put(key, type);
|
||||
validateFromMaps.put(key, validatefrom);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
new BaseBean().writeLog(e);
|
||||
}
|
||||
return validateFromMaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前日期是否可以修改排班
|
||||
* @param date
|
||||
* @param resourceId
|
||||
* @param isEdit
|
||||
* @param user
|
||||
* @param validateFromData
|
||||
* @return
|
||||
*/
|
||||
public boolean isHave(String date,String resourceId,String isEdit,User user,Map<String, String> validateFromData){
|
||||
boolean isNonEdit = false;
|
||||
String today = DateUtil.getCurrentDate();
|
||||
String validatefrom = Util.null2String(validateFromData.get(resourceId + "|validatefrom"));//人员开始生效日期
|
||||
//如果生效日期是当月还是可以修改
|
||||
new BaseBean().writeLog("==zjvalidateFromData=="+JSON.toJSONString(validateFromData));
|
||||
new BaseBean().writeLog("==validatefrom=="+JSON.toJSONString(validatefrom));
|
||||
if (!"".equals(validatefrom) && validatefrom.length()>=7
|
||||
&& (today.substring(0,7).compareTo(validatefrom.substring(0,7)) == 0)){
|
||||
return isNonEdit;
|
||||
}
|
||||
if (date.substring(0,7).compareTo(today.substring(0,7)) <= 0 && "1".equals(isEdit) && user.getUID()!=1){
|
||||
isNonEdit = true;
|
||||
}
|
||||
return isNonEdit;
|
||||
}
|
||||
|
||||
public boolean isHave(String fromdate,String toDate,String resourceId,String isEdit,User user,Map<String, String> validateFromData){
|
||||
boolean isNonEdit = false;
|
||||
String today = DateUtil.getCurrentDate();
|
||||
String todayMonth = DateUtil.getCurrentDate().substring(0,7);
|
||||
String validatefrom = Util.null2String(validateFromData.get(resourceId + "|validatefrom"));//人员开始生效日期
|
||||
String fromMonth = fromdate.substring(0,7);//开始月份
|
||||
String toMonth = toDate.substring(0,7);//结束月份
|
||||
//如果生效日期是当月,且修改开始日期和结束日期都是当月,那还是可以改的
|
||||
if (!"".equals(validatefrom)&&todayMonth.compareTo(validatefrom.substring(0,7))==0
|
||||
&& fromMonth.compareTo(todayMonth)==0
|
||||
&& toMonth.compareTo(todayMonth)==0){
|
||||
return isNonEdit;
|
||||
}
|
||||
boolean isNextMonth= isNextMonth(fromMonth, toMonth,todayMonth);
|
||||
if (!isNextMonth && "1".equals(isEdit) && user.getUID()!=1){
|
||||
isNonEdit = true;
|
||||
}
|
||||
return isNonEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前日期是否可以修改排班(批量删除用的)
|
||||
* @param month
|
||||
* @param resourceId
|
||||
* @param isEdit
|
||||
* @param user
|
||||
* @param validateFromData
|
||||
* @return
|
||||
*/
|
||||
public boolean isHaveDel(String month,String resourceId,String isEdit,User user,Map<String, String> validateFromData){
|
||||
boolean isNonEdit = false;
|
||||
String today = DateUtil.getCurrentDate();
|
||||
String todayMonth = DateUtil.getCurrentDate().substring(0,7);
|
||||
|
||||
String validatefrom = Util.null2String(validateFromData.get(resourceId + "|validatefrom"));//人员开始生效日期
|
||||
//如果生效日期是当月还是可以修改
|
||||
if (!"".equals(validatefrom) && validatefrom.length()>=7
|
||||
&& (todayMonth.compareTo(validatefrom.substring(0,7)) == 0)){
|
||||
return isNonEdit;
|
||||
}
|
||||
if (month.compareTo(todayMonth) <= 0 && "1".equals(isEdit) && user.getUID()!=1){
|
||||
isNonEdit = true;
|
||||
}
|
||||
return isNonEdit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isNextMonth(String fromMonth, String toMonth,String todayMonth) {
|
||||
boolean isNextMonth = false;
|
||||
if (fromMonth.compareTo(todayMonth) >0 && toMonth.compareTo(todayMonth)>0){
|
||||
isNextMonth = true;
|
||||
}
|
||||
return isNextMonth;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import com.engine.workflow.constant.PAResponseCode;
|
||||
import com.engine.workflow.entity.publicApi.PAResponseEntity;
|
||||
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
|
||||
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
|
||||
import com.wbi.util.Util;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CustomRequestUtil {
|
||||
public KQLog kqLog = new KQLog();
|
||||
public String wfId = new BaseBean().getPropValue("qc3189074","wfid");//流程id
|
||||
String tableDetailName = new BaseBean().getPropValue("qc3189074","tableDetailName");//排班流程明细表
|
||||
|
||||
/**
|
||||
* 新建流程
|
||||
* @param user
|
||||
* @param wfId
|
||||
* @param mainTable
|
||||
* @param detaiTable
|
||||
*/
|
||||
public Integer createRequest(User user, String wfId, JSONArray mainTable,JSONArray detaiTable) {
|
||||
new BaseBean().writeLog("==zj==(创建流程方法进入1111)");
|
||||
|
||||
int requestid = 0; //创建流程id
|
||||
try {
|
||||
WorkflowRequestOperatePA workflowRequestOperatePA= ServiceUtil.getService(WorkflowRequestOperatePAImpl.class);
|
||||
JSONObject requestJSON = new JSONObject();
|
||||
requestJSON.put("detailData",JSON.toJSONString(detaiTable));//明细表数据(非必填)
|
||||
requestJSON.put("mainData", JSON.toJSONString(mainTable));//主表数据(必填)
|
||||
requestJSON.put("otherParams", "");//其他参数,比如messageType,isnextflow,requestSecLevel,delReqFlowFaild(非必填)
|
||||
requestJSON.put("remark", "");//签字意见,默认值流程默认意见若未设置则为空(非必填)
|
||||
requestJSON.put("requestLevel", "");//紧急程度(非必填)
|
||||
requestJSON.put("requestName", "排班审批");//流程标题(必填)
|
||||
requestJSON.put("workflowId", wfId);//流程Id(必填)
|
||||
|
||||
PAResponseEntity resultEntity = workflowRequestOperatePA.doCreateRequest(user, WorkFlowUtil.parseRequestEntity(requestJSON));
|
||||
|
||||
boolean isSuccess = resultEntity.getCode() == PAResponseCode.SUCCESS;
|
||||
new BaseBean().writeLog("==zj==(创建流程失败信息)" + resultEntity.getErrMsg() + " | code: " + resultEntity.getCode());
|
||||
|
||||
requestid = 0;
|
||||
if (isSuccess){
|
||||
Object resultData = resultEntity.getData();
|
||||
if (resultData != null){
|
||||
JSONObject requestidData =JSONObject.parseObject(JSON.toJSONString(resultData)) ;
|
||||
requestid = requestidData.getInteger("requestid");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog("==zj==(创建流程异常)" + JSON.toJSONString(e));
|
||||
}
|
||||
|
||||
return requestid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交流程
|
||||
* @param user
|
||||
* @param requestId
|
||||
* @param mainTable
|
||||
*/
|
||||
public static Boolean submitRequest(User user, int requestId, JSONArray mainTable,JSONArray detaiTable) {
|
||||
WorkflowRequestOperatePA workflowRequestOperatePA= ServiceUtil.getService(WorkflowRequestOperatePAImpl.class);
|
||||
JSONObject requestJSON = new JSONObject();
|
||||
requestJSON.put("mainData",mainTable);//主表数据(非必填)
|
||||
requestJSON.put("detailData",detaiTable);//明细表数据(非必填)
|
||||
requestJSON.put("otherParams", "");//其他参数,比如messageType,isnextflow,requestSecLevel,delReqFlowFaild(非必填)
|
||||
requestJSON.put("remark", "");//签字意见,默认值流程默认意见若未设置则为空(非必填)
|
||||
requestJSON.put("requestId", requestId);//流程Id(必填)
|
||||
PAResponseEntity resultEntity = workflowRequestOperatePA.submitRequest(user, WorkFlowUtil.parseRequestEntity(requestJSON));
|
||||
boolean isSuccess = resultEntity.getCode() == PAResponseCode.SUCCESS;
|
||||
new BaseBean().writeLog("==zj==(提交流程信息)" + resultEntity.getErrMsg() + " | code: " + resultEntity.getCode());
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置主表数据
|
||||
* @param mainParam
|
||||
* @return
|
||||
*/
|
||||
public JSONArray setMainTable(Map<String, String> mainParam,Map<String,String> otherparam){
|
||||
JSONArray mainTable = new JSONArray();
|
||||
try{
|
||||
//提交人员信息
|
||||
String operaterId = Util.null2String(mainParam.get("operaterId")); //提交人员id
|
||||
String operaterSubCompany = Util.null2String(mainParam.get("operaterSubCompany")); //提交人员分部
|
||||
String operaterDepartment = Util.null2String(mainParam.get("operaterDepartment")); //提交人员部门
|
||||
String operaterJobTitle = Util.null2String(mainParam.get("operaterJobTitle")); //提交人员岗位
|
||||
String type = Util.null2String(mainParam.get("type")); //默认排班
|
||||
String scheduleResourceIds = Util.null2String(mainParam.get("scheduleResourceIds")); //被排班人员
|
||||
String kqMonth = Util.null2String(mainParam.get("kqMonth")); //排班月份
|
||||
String kqGroupId = Util.null2String(mainParam.get("kqGroupId"));//考勤组
|
||||
//把主表数据设置一下
|
||||
//创建人
|
||||
JSONObject mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","cjr");
|
||||
mainTablaDatas.put("fieldValue",operaterId);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//创建人分部
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","fb");
|
||||
mainTablaDatas.put("fieldValue",operaterSubCompany);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//创建人部门
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","cjrbm");
|
||||
mainTablaDatas.put("fieldValue",operaterDepartment);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//创建人岗位
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","cjrgw");
|
||||
mainTablaDatas.put("fieldValue",operaterJobTitle);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//申请类型,默认为排班
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","sqlx");
|
||||
mainTablaDatas.put("fieldValue",type);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//排班月份
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","pbyf");
|
||||
mainTablaDatas.put("fieldValue",kqMonth);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//被排班人员
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","pbmd");
|
||||
mainTablaDatas.put("fieldValue",scheduleResourceIds);
|
||||
mainTable.add(mainTablaDatas);
|
||||
//考勤组
|
||||
mainTablaDatas = new JSONObject();
|
||||
mainTablaDatas.put("fieldName","kqz");
|
||||
mainTablaDatas.put("fieldValue",kqGroupId);
|
||||
mainTable.add(mainTablaDatas);
|
||||
|
||||
}catch (Exception e){
|
||||
kqLog.info("==zj==(设置主表数据报错)" + e);
|
||||
}
|
||||
return mainTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置明细表数据
|
||||
* @param detailParam
|
||||
* @return
|
||||
*/
|
||||
public JSONArray setDetailTable(Map<String,List<List<Object>>> detailParam,Map<String,String> otherparam){
|
||||
JSONArray detailTable = new JSONArray();
|
||||
try {
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
int index = 0;
|
||||
JSONArray workflowRequestTableRecords = new JSONArray();
|
||||
JSONArray workflowRequestTableRecord = new JSONArray();
|
||||
JSONObject detailTableDatas = new JSONObject();
|
||||
//这里直接循环遍历每个人员
|
||||
Set keySet =detailParam.keySet(); //获取到所有值
|
||||
for(Object key : keySet ){
|
||||
//设置明细表数据
|
||||
String resourceid = Util.null2String(key);
|
||||
String subCompanyID = Util.null2String(resourceComInfo.getSubCompanyID(resourceid));
|
||||
String departmentID = Util.null2String(resourceComInfo.getDepartmentID(resourceid));
|
||||
String jobTitle = Util.null2String(resourceComInfo.getJobTitle(resourceid));//岗位id
|
||||
JSONObject workflowRequestTableRecordsData = new JSONObject();
|
||||
//2024-08-28 先改成固定值看看
|
||||
workflowRequestTableRecordsData.put("recordOrder",0);
|
||||
JSONArray workflowRequestTableFields = new JSONArray();
|
||||
List<List<Object>> Datas = detailParam.get(key);
|
||||
if (Datas.size() <= 0){
|
||||
//人员
|
||||
JSONObject workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","yg");
|
||||
workflowRequestTableFieldData.put("fieldValue",resourceid);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
|
||||
//部门
|
||||
workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","szbm");
|
||||
workflowRequestTableFieldData.put("fieldValue",departmentID);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
|
||||
//岗位
|
||||
workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","gw");
|
||||
workflowRequestTableFieldData.put("fieldValue",jobTitle);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
|
||||
}else {
|
||||
for (int i = 0; i < Datas.size(); i++) {
|
||||
List<Object> detailData = Datas.get(i);
|
||||
/*String resourceid =Util.null2String(detailData.get(0));//人员id*/
|
||||
/* String subCompanyID = Util.null2String(detailData.get(1));//分部id
|
||||
String departmentID = Util.null2String(detailData.get(2));//部门id*/
|
||||
/*String jobTitle = Util.null2String(detailData.get(3));//岗位id*/
|
||||
String kqdate = Util.null2String(detailData.get(4));//排班日期
|
||||
String serialId = Util.null2String(detailData.get(5));//排班id
|
||||
if ( i == 0){
|
||||
//刚开始先设置下排班人员基本信息
|
||||
//人员
|
||||
JSONObject workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","yg");
|
||||
workflowRequestTableFieldData.put("fieldValue",resourceid);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
|
||||
//部门
|
||||
workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","szbm");
|
||||
workflowRequestTableFieldData.put("fieldValue",departmentID);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
|
||||
//岗位
|
||||
workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","gw");
|
||||
workflowRequestTableFieldData.put("fieldValue",jobTitle);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
}
|
||||
//设置该员工当天班次
|
||||
if (kqdate.length() > 0){
|
||||
String[] split = kqdate.split("-");
|
||||
int num = Integer.parseInt(split[2]);
|
||||
|
||||
JSONObject workflowRequestTableFieldData = new JSONObject();
|
||||
workflowRequestTableFieldData.put("fieldName","bc"+num);
|
||||
workflowRequestTableFieldData.put("fieldValue",serialId);
|
||||
workflowRequestTableFields.add(workflowRequestTableFieldData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index +=1;
|
||||
workflowRequestTableRecordsData.put("workflowRequestTableFields",workflowRequestTableFields);
|
||||
workflowRequestTableRecords.add(workflowRequestTableRecordsData);
|
||||
|
||||
}
|
||||
//设置明细表名称
|
||||
detailTableDatas.put("tableDBName",tableDetailName);
|
||||
//设置明细表数据
|
||||
detailTableDatas.put("workflowRequestTableRecords",workflowRequestTableRecords);
|
||||
//是否删除所有明细
|
||||
if ("1".equals(otherparam.get("deleteAll"))){
|
||||
detailTableDatas.put("deleteAll","1");
|
||||
}
|
||||
detailTable.add(detailTableDatas);
|
||||
} catch (Exception e) {
|
||||
kqLog.info("==zj==(设置明细表数据报错)" + e);
|
||||
}
|
||||
return detailTable;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,491 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.kq.biz.KQGroupComInfo;
|
||||
import com.engine.kq.biz.KQShiftManagementComInfo;
|
||||
import com.engine.kq.biz.KqMembersValidateBiz;
|
||||
import com.engine.kq.cmd.shiftschedule.SaveShiftScheduleCmd;
|
||||
import com.engine.kq.log.KQLog;
|
||||
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.resource.ResourceComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CustomScheduleUtil {
|
||||
String openKqGroupId = Util.null2String(new BaseBean().getPropValue("qc3189074","openKqGroupId"));//启动新功能的考勤组
|
||||
/* List<String> openKqGroupList = Arrays.stream(openKqGroupId.split(","))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toList());*/
|
||||
|
||||
String wfid = new BaseBean().getPropValue("qc3189074","wfid");//排班流程id
|
||||
String tableName = new BaseBean().getPropValue("qc3189074","tableName");//排班流程主表
|
||||
String tableDetailName = new BaseBean().getPropValue("qc3189074","tableDetailName");//排班流程明细表
|
||||
public KQLog kqLog = new KQLog();
|
||||
|
||||
/**
|
||||
* 保存排班数据
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> save(Map<String, Object> dataParams, User user){
|
||||
|
||||
//必要的权限判断
|
||||
if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) {
|
||||
Map<String, Object> reusltMap = new HashMap<>();
|
||||
reusltMap.put("status", "-1");
|
||||
reusltMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
|
||||
return reusltMap;
|
||||
}
|
||||
|
||||
List<List<Object>> insertList =null;
|
||||
Map<String,List<List<Object>>> resourceData = new LinkedHashMap<>();//人员排班
|
||||
String groupId = "";
|
||||
String kqMonth = "";
|
||||
String resourceIds = "";
|
||||
try {
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
|
||||
|
||||
String data = Util.null2String(dataParams.get("data"));
|
||||
JSONObject jsonObj = JSON.parseObject(data);
|
||||
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
|
||||
KQShiftManagementComInfo kqShiftScheduleComInfo = new KQShiftManagementComInfo();
|
||||
ResourceComInfo rci = new ResourceComInfo();
|
||||
groupId = Util.null2String(jsonObj.get("groupId"));
|
||||
kqMonth = Util.null2String(jsonObj.get("kqMonth"));
|
||||
JSONArray datas = jsonObj.getJSONArray("datas");
|
||||
|
||||
List<Object> params = null;
|
||||
String delIds = "";
|
||||
|
||||
JSONObject resourceDataObj = null;
|
||||
JSONArray arrKqDataObj = null;
|
||||
JSONObject kqDataObj = null;
|
||||
|
||||
|
||||
if (datas.size() > 0){
|
||||
for(int i=0;i<datas.size();i++){
|
||||
|
||||
resourceDataObj = (JSONObject)datas.get(i);
|
||||
String resourceid = Util.null2String(resourceDataObj.get("resourceid"));//人员id
|
||||
String departmentID = resourceComInfo.getDepartmentID(resourceid);//部门id
|
||||
String subCompanyID = resourceComInfo.getSubCompanyID(resourceid);//分部id
|
||||
|
||||
String jobTitle = resourceComInfo.getJobTitle(resourceid);//岗位id
|
||||
|
||||
//给每个人员创建一个key,保存排班信息
|
||||
if (resourceData.get(resourceid) == null){
|
||||
insertList = new ArrayList<List<Object>>();
|
||||
}else {
|
||||
insertList = resourceData.get(resourceid);
|
||||
}
|
||||
arrKqDataObj = resourceDataObj.getJSONArray("kqdata");
|
||||
for(int j=0;arrKqDataObj!=null&&j<arrKqDataObj.size();j++) {
|
||||
kqDataObj = (JSONObject) arrKqDataObj.get(j);
|
||||
// 如果id为空,则代表原先是空白单元格
|
||||
String id = Util.null2String(kqDataObj.get("id"));
|
||||
String date = Util.null2String(kqDataObj.get("date"));
|
||||
if(!SaveShiftScheduleCmd.isDate(date)) {
|
||||
continue;
|
||||
}
|
||||
// 原先排班的班次id
|
||||
String oldSerialid = Util.null2String(kqDataObj.get("oldValue"));
|
||||
// 新班次id 如果 serialid是-999, oldValue是班次id,那么就是原先是有班次的,后面把班次删除了
|
||||
String serialid = Util.null2String(kqDataObj.get("serialid"));
|
||||
if(serialid.equals("-999"))serialid="";
|
||||
if (serialid.length() > 0){
|
||||
params = new ArrayList<Object>();
|
||||
params.add(resourceid);//排班人员
|
||||
params.add(subCompanyID);//排班人员分部
|
||||
params.add(departmentID);//排班人员部门
|
||||
params.add(jobTitle);//排班人员岗位
|
||||
params.add(date);//排班日期
|
||||
params.add(serialid);//排班班次id
|
||||
params.add(groupId);//排班考勤组
|
||||
insertList.add(params);
|
||||
}
|
||||
}
|
||||
//2024-08-28
|
||||
boolean flag = checkStatus(resourceid, groupId, kqMonth);
|
||||
if (flag){
|
||||
//只有有未审批数据的人才能提交
|
||||
resourceData.put(resourceid,insertList);
|
||||
resourceIds += resourceid+",";
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//没有数据就走全部人员
|
||||
ResourceUtil resourceUtil = new ResourceUtil();
|
||||
resourceData = resourceUtil.getAllResourceIds(kqMonth, groupId);
|
||||
Set<String> keySet =resourceData.keySet(); //获取到所有值
|
||||
for(String key : keySet ){
|
||||
//把排班人员获取下
|
||||
resourceIds += key +",";
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
kqLog.info("saveCustomScheduleError:" + e);
|
||||
}
|
||||
|
||||
if (resourceIds.length() > 0){
|
||||
resourceIds = resourceIds.substring(0,resourceIds.length()-1);
|
||||
}
|
||||
|
||||
new BaseBean().writeLog("resourceData:" + JSON.toJSONString(resourceData));
|
||||
if (resourceData.size() <= 0){
|
||||
Map<String, Object> reusltMap = new HashMap<>();
|
||||
reusltMap.put("status","-1");
|
||||
reusltMap.put("message","当前班次数据无变动,请修改保存后再提交");
|
||||
return reusltMap;
|
||||
}
|
||||
Map<String, Object> resultMap = submit(resourceData, kqMonth, groupId, user,resourceIds);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发排班流程
|
||||
* @param resourceData
|
||||
* @param kqMonth
|
||||
* @param kqGroupId
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Map<String,Object> submit(Map<String,List<List<Object>>> resourceData,String kqMonth,String kqGroupId,User user,String resourceIds){
|
||||
CustomRequestUtil customRequestUtil = new CustomRequestUtil();
|
||||
Map<String, String> mainParam = new HashMap<>();
|
||||
Map<String,Object> reusltMap = new HashMap<>();
|
||||
try {
|
||||
//处理主表,先获取下操作人员信息
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
String operaterId = JSON.toJSONString(user.getUID());//提交人id
|
||||
String operaterSubCompany = resourceComInfo.getSubCompanyID(operaterId);//提交人分部
|
||||
String operaterDepartment = resourceComInfo.getDepartmentID(operaterId);//提交人部门
|
||||
String operaterJobTitle = resourceComInfo.getJobTitle(operaterId);//提交人岗位
|
||||
String type = "0";
|
||||
|
||||
mainParam.put("operaterId",operaterId);
|
||||
mainParam.put("operaterSubCompany",operaterSubCompany);
|
||||
mainParam.put("operaterDepartment",operaterDepartment);
|
||||
mainParam.put("operaterJobTitle",operaterJobTitle);
|
||||
mainParam.put("type",type);
|
||||
mainParam.put("scheduleResourceIds",resourceIds);//被排班人员id
|
||||
mainParam.put("kqMonth",kqMonth);//排班月份
|
||||
mainParam.put("kqGroupId",kqGroupId);//排班考勤组
|
||||
|
||||
|
||||
int rejectRequestId = isHaveWf(kqMonth, kqGroupId,operaterId);
|
||||
//先判断当前有没有退回流程,有的话就用退回流程提交
|
||||
if (rejectRequestId > 0){
|
||||
Map<String, String> otherParam = new HashMap<>();
|
||||
otherParam.put("deleteAll","1");
|
||||
//主表数据
|
||||
JSONArray mainDatas = customRequestUtil.setMainTable(mainParam,otherParam);
|
||||
//处理明细表
|
||||
JSONArray detailDatas = customRequestUtil.setDetailTable(resourceData,otherParam);
|
||||
Boolean isSuccess = customRequestUtil.submitRequest(user, rejectRequestId, mainDatas, detailDatas);
|
||||
if (isSuccess){
|
||||
setStatus(resourceIds,kqMonth,"2",rejectRequestId,kqMonth);
|
||||
reusltMap.put("status","1");
|
||||
reusltMap.put("message","提交成功");
|
||||
return reusltMap;
|
||||
}
|
||||
}else {
|
||||
Map<String, String> otherParam = new HashMap<>();
|
||||
otherParam.put("deleteAll","0");
|
||||
//主表数据
|
||||
JSONArray mainDatas = customRequestUtil.setMainTable(mainParam,otherParam);
|
||||
//处理明细表
|
||||
JSONArray detailDatas = customRequestUtil.setDetailTable(resourceData,otherParam);
|
||||
|
||||
int requestId = customRequestUtil.createRequest(user, wfid, mainDatas, detailDatas);
|
||||
if (requestId > 0 ){
|
||||
//成功创建完流程,把标识改为审批中
|
||||
setStatus(resourceIds,kqMonth,"2",requestId,kqGroupId);
|
||||
reusltMap.put("status","1");
|
||||
reusltMap.put("message","提交成功");
|
||||
return reusltMap;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
kqLog.info("submitWorkFlowError:"+e);
|
||||
reusltMap.put("status","-1");
|
||||
reusltMap.put("message","提交报错");
|
||||
}
|
||||
reusltMap.put("status","-1");
|
||||
reusltMap.put("message","提交报错");
|
||||
return reusltMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前考勤组是否启用新功能
|
||||
* @param params
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> isOpen(Map<String, Object> params, User user){
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
String kqGroupId = Util.null2String(params.get("kqGroup"));
|
||||
boolean isHave = false;
|
||||
//==zj 换成建模表
|
||||
if (isOpenGroup(kqGroupId)){
|
||||
isHave = true;
|
||||
}
|
||||
//如果是系统管理员,还是用标准排班功能
|
||||
if (user.getUID() == 1){
|
||||
isHave = false;
|
||||
}
|
||||
resultMap.put("ishave",isHave);
|
||||
return resultMap;
|
||||
}
|
||||
public boolean isOpen(String groupId){
|
||||
boolean isHave = false;
|
||||
if (isOpenGroup(groupId)){
|
||||
isHave = true;
|
||||
}
|
||||
return isHave;
|
||||
}
|
||||
/**
|
||||
* 判断当前是否可以使用标准排班功能(针对启用新功能的考勤组)
|
||||
* @param params
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> isHave(Map<String, Object> params, User user){
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String kqGroupId = Util.null2String(params.get("kqGroup"));
|
||||
String kqMonth = Util.null2String(params.get("kqMonth"));
|
||||
|
||||
boolean isHave = true;
|
||||
//如果是非启动新功能的考勤组,则可以直接使用
|
||||
if (!isOpenGroup(kqGroupId) || user.getUID() == 1){
|
||||
resultMap.put("ishave",isHave);
|
||||
return resultMap;
|
||||
}
|
||||
//判断指定月份是否有在审批流程
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
|
||||
String sql = "select id from kq_flow_shiftschedule where groupid = "+kqGroupId+" and kqdate between '"+monthBeginDate+"' and '"+monthEndDate+"' and wfidstatus =2";
|
||||
sql += " and (isdelete is null or isdelete <> '1' or (isdelete='1' and wfidstatus='2'))";
|
||||
rs.executeQuery(sql);
|
||||
if (rs.next()){
|
||||
isHave = false;
|
||||
}
|
||||
resultMap.put("ishave",isHave);
|
||||
return resultMap;
|
||||
}
|
||||
/**
|
||||
* 判断当前人员数据审批状态
|
||||
* @param resoruceId
|
||||
* @param fromDate
|
||||
* @param kqGroupId
|
||||
* @return
|
||||
*/
|
||||
public String flowStatus(String resoruceId,String fromDate,String toDate,String kqGroupId){
|
||||
boolean flag = true;
|
||||
String status = "";
|
||||
String message = "未提交";
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
//未提交
|
||||
String sql = "select wfidstatus from kq_flow_shiftschedule where resourceid="+resoruceId+" and groupid = "+kqGroupId+" and kqdate between '"+fromDate+"' and '"+toDate+"'"+
|
||||
" and (isdelete is null or isdelete <> '1' or (isdelete='1' and wfidstatus='1')) and (wfidstatus='1') ";
|
||||
rs.executeQuery(sql);
|
||||
if (rs.next()){
|
||||
status = Util.null2String(rs.getString("wfidstatus"));
|
||||
flag = false;
|
||||
}
|
||||
|
||||
//审批中
|
||||
if (flag){
|
||||
sql = "select wfidstatus from kq_flow_shiftschedule where resourceid="+resoruceId+" and groupid = "+kqGroupId+" and kqdate between '"+fromDate+"' and '"+toDate+"'"+
|
||||
" and (isdelete is null or isdelete <> '1' or (isdelete='1' and wfidstatus='2')) and (wfidstatus='2') ";
|
||||
rs.executeQuery(sql);
|
||||
if (rs.next()){
|
||||
status = Util.null2String(rs.getString("wfidstatus"));
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//已审批
|
||||
if (flag){
|
||||
sql = "select wfidstatus from kq_flow_shiftschedule where resourceid="+resoruceId+" and groupid = "+kqGroupId+" and kqdate between '"+fromDate+"' and '"+toDate+"'"+
|
||||
" and (isdelete is null or isdelete <> '1' or (isdelete='1' and wfidstatus='3')) and (wfidstatus='3') ";
|
||||
rs.executeQuery(sql);
|
||||
if (rs.next()){
|
||||
status = Util.null2String(rs.getString("wfidstatus"));
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
switch (status){
|
||||
case "1":
|
||||
message = "未提交";
|
||||
break;
|
||||
case "2":
|
||||
message = "审批中";
|
||||
break;
|
||||
case "3":
|
||||
message = "已审批";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将状态进行修改
|
||||
* @param resourceIds
|
||||
* @param kqMonth
|
||||
*/
|
||||
public void setStatus(String resourceIds,String kqMonth,String status,int requestId,String groupId){
|
||||
RecordSet rs = new RecordSet();
|
||||
List<List> paramUpdates = new ArrayList<List>();
|
||||
List<Object> paramUpdate = null;
|
||||
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("groupId",groupId);
|
||||
params.put("isNoAccount","1");
|
||||
User user = new User();
|
||||
|
||||
Map<String, List<String>> validateResult = new KqMembersValidateBiz(params, user).getKqMembersValidateList();
|
||||
String[] resourceList = resourceIds.split(",");
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
try {
|
||||
//根据当前人员的生效日期范围进行修改
|
||||
for (int i = 0; i < resourceList.length; i++) {
|
||||
String upDateBegin = "";//变更开始日期
|
||||
String upDateEnd = "";//变更结束日期
|
||||
String resourceId = resourceList[i];
|
||||
List<String> validateList = validateResult.get(resourceId);
|
||||
String validateBegin= validateList.get(0);//人员生效开始日期
|
||||
String validateEnd = validateList.get(1);//人员生效结束日期
|
||||
if (validateBegin.compareTo(monthBeginDate) < 0){
|
||||
upDateBegin = monthBeginDate;
|
||||
}else {
|
||||
upDateBegin = validateBegin;
|
||||
}
|
||||
if (validateEnd.compareTo(monthEndDate) > 0){
|
||||
upDateEnd = monthEndDate;
|
||||
}else {
|
||||
upDateEnd = validateEnd;
|
||||
}
|
||||
//装入参数
|
||||
paramUpdate = new ArrayList<Object>();
|
||||
if ("2".equals(status)){
|
||||
paramUpdate.add(requestId);//流程id
|
||||
}
|
||||
paramUpdate.add(status);
|
||||
paramUpdate.add(resourceId);//人员id
|
||||
paramUpdate.add(upDateBegin);//变更开始日期
|
||||
paramUpdate.add(upDateEnd);//变更结束日期
|
||||
if ("1".equals(status)){
|
||||
paramUpdate.add(requestId);//流程id
|
||||
}
|
||||
paramUpdates.add(paramUpdate);
|
||||
}
|
||||
String updateSql = "";
|
||||
//==zj 2025-06-06 这里只改非删除数据的班次
|
||||
if ("2".equals(status)){
|
||||
updateSql = "update kq_flow_shiftschedule set wfid=?, wfidstatus = ? "+
|
||||
"where (isdelete is null or isdelete <> '1') and resourceid=? and kqdate between ? and ? and wfidstatus = 1 ";
|
||||
}else if ("1".equals(status)){
|
||||
updateSql = "update kq_flow_shiftschedule set wfidstatus = ? "+
|
||||
"where (isdelete is null or isdelete <> '1') and resourceid=? and kqdate between ? and ? and wfid=? and wfidstatus = 2 ";
|
||||
}
|
||||
rs.executeBatchSql(updateSql,paramUpdates);
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog("setStatusError:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前月份是否有退回的排班审批流程
|
||||
*/
|
||||
public int isHaveWf(String kqMonth,String kqGruopId,String resourceId){
|
||||
int requestId = 0;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sqlBase = "select a.cjr,a.requestid,a.kqz,a.pbyf from "+tableName + " a left join workflow_requestbase b on a.requestid = b.requestid ";
|
||||
String sqlWhere = "where currentnodetype = 0 and a.kqz="+kqGruopId+" and a.pbyf='"+kqMonth+"' and a.cjr='"+resourceId+"'";
|
||||
|
||||
rs.executeQuery(sqlBase+sqlWhere);
|
||||
if (rs.next()){
|
||||
requestId = rs.getInt("requestid");
|
||||
}
|
||||
new BaseBean().writeLog("是否有退回流程:"+sqlBase+sqlWhere);
|
||||
new BaseBean().writeLog("退回流程id:"+requestId);
|
||||
return requestId;
|
||||
}
|
||||
/**
|
||||
* 这里检测下当前人员月份的状态,只有未提交状态的才能提交
|
||||
* @param gruopId
|
||||
* @param kqMonth
|
||||
* @return
|
||||
*/
|
||||
public boolean checkStatus(String resourceId,String gruopId,String kqMonth){
|
||||
boolean flag = false;
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "select resourceid,kqdate,groupid from kq_flow_shiftschedule where wfidstatus=1 and groupid="+gruopId+" and kqdate between '"+monthBeginDate+"' and '"+monthEndDate+"' and resourceId="+resourceId;
|
||||
rs.executeQuery(sql);
|
||||
if (rs.next()){
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询建模表,判断当前考勤组是否使用新功能
|
||||
* @param groupid
|
||||
* @return
|
||||
*/
|
||||
public boolean isOpenGroup(String groupid){
|
||||
boolean isOpen = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "select * from uf_pbspkqzb";
|
||||
String where = " where EXISTS(" +
|
||||
"SELECT 1 " +
|
||||
"from STRING_SPLIT(CAST(kqz AS NVARCHAR(MAX)), ',') " +
|
||||
"WHERE value = "+groupid+")";
|
||||
rs.executeQuery(sql+where);
|
||||
if (rs.next()){
|
||||
isOpen = true;
|
||||
}
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前人员所在考勤组的生效日期范围
|
||||
* @param resourceIds
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getValidateMap(String resourceIds,String groupId){
|
||||
RecordSet rs = new RecordSet();
|
||||
Map<String, String> validateMap = new HashMap<>();
|
||||
String validatefrom = "";
|
||||
String validateto = "";
|
||||
String resourceid = "";
|
||||
//人员
|
||||
String sql = " SELECT distinct a.id AS resourceid, b.groupid,b.validatefrom as validatefrom, b.validateto as validateto, a.status FROM HrmResource a, kq_groupmember b, kq_group c " +
|
||||
" WHERE a.id=b.typevalue and b.type =1 and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1')" +
|
||||
" and a.id in ("+resourceIds+") and b.groupid="+groupId;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()) {
|
||||
resourceid = Util.null2String(rs.getString("resourceid"));
|
||||
validatefrom = Util.null2String(rs.getString("validatefrom"));
|
||||
validateto = Util.null2String(rs.getString("validateto"));
|
||||
validateMap.put(resourceid+"|validatefrom",validatefrom);
|
||||
validateMap.put(resourceid+"|validateto",validateto);
|
||||
}
|
||||
return validateMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.wbi.util.Util;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ResourceUtil {
|
||||
|
||||
/**
|
||||
* 获取所有人未提交的排班信息
|
||||
* @return
|
||||
*/
|
||||
public Map<String,List<List<Object>>> getAllResourceIds(String kqMonth,String groupId){
|
||||
CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
|
||||
Map<String,List<List<Object>>> resourceData = new LinkedHashMap<>();//人员排班
|
||||
|
||||
try {
|
||||
List<List<Object>> insertList =null;
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "select t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid from (SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( " +
|
||||
" 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 " +
|
||||
" WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" 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 " +
|
||||
" 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') " +
|
||||
" 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 " +
|
||||
" 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') " +
|
||||
" 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 " +
|
||||
" 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)))) " +
|
||||
" 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 " +
|
||||
" 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+" and t.status in(0,1,2,3) and t.loginid is not null and t.loginid<>'' and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) order by dsporder asc, lastname asc ";
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String resourceId = Util.null2String(rs.getString("resourceid"));
|
||||
List<List<Object>> shiftScheduleDatas = getShiftSchedule(groupId,resourceId,monthBeginDate,monthEndDate);
|
||||
boolean flag = customScheduleUtil.checkStatus(resourceId, groupId, kqMonth);
|
||||
if (flag){
|
||||
resourceData.put(resourceId,shiftScheduleDatas);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog("所有人员排班报错:" + JSON.toJSONString(e));
|
||||
}
|
||||
return resourceData;
|
||||
}
|
||||
|
||||
private List<List<Object>> getShiftSchedule(String groupid, String resourceid, String monthBeginDate,String monthEndDate){
|
||||
List<List<Object>> insertList = new ArrayList<>();
|
||||
try {
|
||||
|
||||
ArrayList<Object> data = null;
|
||||
String sql = "";
|
||||
RecordSet rs = new RecordSet();
|
||||
sql = " select id,resourceid,kqdate,serialid from kq_flow_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 kqdate = weaver.general.Util.null2String(rs.getString("kqdate"));
|
||||
String serialid = weaver.general.Util.null2String(rs.getString("serialid"));
|
||||
|
||||
data = new ArrayList<>();
|
||||
data.add(Integer.parseInt(resourceid));//人员
|
||||
data.add(0);//分部
|
||||
data.add(0);//部门
|
||||
data.add(0);//岗位
|
||||
data.add(kqdate);//排班日期
|
||||
data.add(serialid);//排班id
|
||||
insertList.add(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return insertList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import com.wbi.util.Util;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*排班流程归档操作
|
||||
*/
|
||||
public class ScheduleAction implements Action {
|
||||
KQLog log = new KQLog();
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
try {
|
||||
log.info("==ScheduleActionBegin==");
|
||||
|
||||
String tableName = new BaseBean().getPropValue("qc3189074","tableName");
|
||||
String tableDetailName = new BaseBean().getPropValue("qc3189074","tableDetailName");
|
||||
RecordSet rs = new RecordSet();
|
||||
CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
Map<String,Map<String,Object>> scheduleMap = new HashMap<>();
|
||||
|
||||
//获取当前日期和时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
String operateDate = now.format(dateFormatter); // 日期字符串
|
||||
String operateTime = now.format(timeFormatter); // 时间字符串
|
||||
//获取主表数据
|
||||
Map<String, String> mainDatas = new HashMap<>();
|
||||
Property[] properties = requestInfo.getMainTableInfo().getProperty();
|
||||
for (Property propertie : properties) {
|
||||
mainDatas.put(propertie.getName(), propertie.getValue());
|
||||
}
|
||||
//获取一些主表上的数据
|
||||
String kqMonth = Util.null2String(mainDatas.get("pbyf"));//排班月份
|
||||
String groupid = Util.null2String(mainDatas.get("kqz"));//排班考勤组
|
||||
String operateUser = Util.null2String(mainDatas.get("cjr"));//流程提交人
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
String resourceIds = Util.null2String(mainDatas.get("pbmd"));
|
||||
Map<String, String> validateMap = customScheduleUtil.getValidateMap(resourceIds, groupid);//获取排班人员考勤组有效期范围
|
||||
|
||||
//根据人员的有效开始日期和结束日期获取班次
|
||||
String sql = "select a.pbyf,a.kqz,b.* from "+ tableName+" a join "+ tableDetailName+" b " +
|
||||
"on a.id = b.mainid and a.requestid ="+requestid;
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
Map<String, Object> scheduleData = new HashMap<>();
|
||||
String resourceid = Util.null2String(rs.getString("yg"));//人员id
|
||||
String validatefrom = validateMap.get(resourceid + "|validatefrom");//人员开始生效日期
|
||||
String validateto = validateMap.get(resourceid + "|validateto");//人员开始结束日期
|
||||
if (validatefrom.compareTo(monthBeginDate) < 0){
|
||||
validatefrom = monthBeginDate;
|
||||
}
|
||||
if (validateto.compareTo(monthEndDate) > 0){
|
||||
validateto = monthEndDate;
|
||||
}
|
||||
|
||||
|
||||
LocalDate startDate = LocalDate.parse(validatefrom, dateFormatter);
|
||||
LocalDate endDate = LocalDate.parse(validateto, dateFormatter);
|
||||
scheduleData.put("validatefrom",validatefrom);
|
||||
scheduleData.put("validateto",validateto);
|
||||
scheduleData.put("groupid",groupid);
|
||||
|
||||
// 遍历一下该人员生效范围内班次
|
||||
List<List<String>> params = new ArrayList<>();
|
||||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
List<String> param = new ArrayList<>();
|
||||
String scheduleDate = date.format(dateFormatter);//排班日期
|
||||
int dayOfMonth = date.getDayOfMonth();
|
||||
String columnName = "bc" + dayOfMonth;
|
||||
String serialId = rs.getString(columnName);//班次id
|
||||
//没有排班就不装了
|
||||
if (serialId.length() <= 0)continue;
|
||||
//封装下排班所需参数
|
||||
param.add(resourceid);
|
||||
param.add(scheduleDate);
|
||||
param.add(serialId);
|
||||
param.add(groupid);
|
||||
param.add(requestid);
|
||||
param.add("3");
|
||||
//2025-03-27 加上操作日期和时间
|
||||
param.add(operateDate);
|
||||
param.add(operateTime);
|
||||
params.add(param);
|
||||
}
|
||||
scheduleData.put("datas",params);
|
||||
scheduleMap.put(resourceid,scheduleData);
|
||||
}
|
||||
//开始插入数据吧
|
||||
for (Map.Entry<String, Map<String,Object>> entry : scheduleMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Map<String,Object> shceduleData = entry.getValue();
|
||||
//先把人员排班范围内的班次删了
|
||||
String validatefrom = Util.null2String(shceduleData.get("validatefrom"));
|
||||
String validateto = Util.null2String(shceduleData.get("validateto"));
|
||||
List<List> params =(List<List>) shceduleData.get("datas");
|
||||
//直接做删除吧
|
||||
String delSql = "delete from kq_shiftschedule where resourceid=? and kqdate between ? and ?";
|
||||
rs.executeUpdate(delSql,key,validatefrom,validateto);
|
||||
|
||||
//2025-04-02 换个方式吧
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
List dataList = params.get(i);
|
||||
String resourceid_temp = Util.null2String(dataList.get(0));
|
||||
String scheduleDate_temp = Util.null2String(dataList.get(1));
|
||||
String serialId_temp = Util.null2String(dataList.get(2));
|
||||
String groupid_temp = Util.null2String(dataList.get(3));
|
||||
String requestid_temp = Util.null2String(dataList.get(4));
|
||||
String status_temp = Util.null2String(dataList.get(5));
|
||||
String operateDate_temp = Util.null2String(dataList.get(6));
|
||||
String operateTime_temp = Util.null2String(dataList.get(7));
|
||||
|
||||
//再把班次插入进去吧
|
||||
if ("2025-03-25".equals(scheduleDate_temp)){
|
||||
log.info("==参数=="+resourceid_temp+" | "+scheduleDate_temp+" | "+serialId_temp+" | "+groupid_temp+" | "+" | "+requestid_temp);
|
||||
}
|
||||
String inserSql = "insert into kq_shiftschedule(resourceid,kqdate,serialid,groupid,isdelete,wfid,wfidstatus,operateDate,operateTime,operateUser)"+
|
||||
"values(?,?,?,?,0,?,?,?,?,?)";
|
||||
boolean isInsert = rs.executeUpdate(inserSql, resourceid_temp, scheduleDate_temp, serialId_temp, groupid_temp, requestid_temp, status_temp, operateDate_temp, operateTime_temp, operateUser);
|
||||
log.info("==isInsert=="+isInsert);
|
||||
}
|
||||
|
||||
}
|
||||
//然后更改下状态
|
||||
String updateSql = "update kq_flow_shiftschedule set wfidstatus=3,operateDate=?,operateTime=? where wfid=?";
|
||||
boolean isUpdate = rs.executeUpdate(updateSql,operateDate,operateTime,requestid);
|
||||
log.info("==isUpdate=="+isUpdate);
|
||||
|
||||
//先用线程吧
|
||||
ThreadUtil threadUtil = new ThreadUtil(scheduleMap);
|
||||
Thread thread = new Thread(threadUtil);
|
||||
thread.start();
|
||||
log.info("==排班流程归档数据111=="+JSON.toJSONString(scheduleMap));
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog("执行报错:" + JSON.toJSONString(e));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.wbi.util.Util;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScheduleRejectAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
|
||||
String requestid = requestInfo.getRequestid();
|
||||
//获取主表数据
|
||||
Map<String, String> mainDatas = new HashMap<>();
|
||||
Property[] properties = requestInfo.getMainTableInfo().getProperty();
|
||||
for (Property propertie : properties) {
|
||||
mainDatas.put(propertie.getName(), propertie.getValue());
|
||||
}
|
||||
//获取主表排班月份
|
||||
String kqMonth = Util.null2String(mainDatas.get("pbyf"));
|
||||
String groupid = Util.null2String(mainDatas.get("kqz"));//排班考勤组
|
||||
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
//获取主表被排班人员
|
||||
String[] resourceIds = Util.null2String(mainDatas.get("pbmd")).split(",");
|
||||
|
||||
//把状态改为待提交
|
||||
customScheduleUtil.setStatus(mainDatas.get("pbmd"),kqMonth,"1",Integer.parseInt(requestid),groupid);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.engine.kq.biz.KQFormatData;
|
||||
import com.wbi.util.Util;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThreadUtil implements Runnable {
|
||||
Map<String,Map<String,Object>> scheduleMap;
|
||||
public ThreadUtil(Map<String,Map<String,Object>> scheduleMap) {
|
||||
this.scheduleMap = scheduleMap;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
for (Map.Entry<String, Map<String,Object>> entry : scheduleMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Map<String,Object> shceduleData = entry.getValue();
|
||||
String validatefrom = Util.null2String(shceduleData.get("validatefrom"));
|
||||
String validateto = Util.null2String(shceduleData.get("validateto"));
|
||||
LocalDate fromLocal = LocalDate.parse(validatefrom);
|
||||
LocalDate toLocal = LocalDate.parse(validateto);
|
||||
if(!toLocal.isBefore(fromLocal)){
|
||||
long betweenDays = toLocal.toEpochDay() - fromLocal.toEpochDay();
|
||||
for (int j = 0; j <= betweenDays; j++) {
|
||||
LocalDate curLocalDate = fromLocal.plusDays(j);
|
||||
String shiftDate = curLocalDate.format(dateFormatter);
|
||||
new KQFormatData().formatKqDateByLock(key, shiftDate,17);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.workflow.biz.freeNode.FreeNodeBiz;
|
||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
||||
import com.engine.workflow.entity.publicApi.WorkflowDetailTableInfoEntity;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.workflow.webservices.WorkflowRequestTableField;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
*
|
||||
* @Author Trump
|
||||
* @create 2021/11/9 14:21
|
||||
*/
|
||||
public class WorkFlowUtil {
|
||||
|
||||
/**
|
||||
* 《通用》转为Entity对象
|
||||
* @param requestJSON
|
||||
* @return
|
||||
*/
|
||||
public static ReqOperateRequestEntity parseRequestEntity(JSONObject requestJSON){
|
||||
ReqOperateRequestEntity entity = new ReqOperateRequestEntity();
|
||||
try {
|
||||
int workflowId = Util.getIntValue(requestJSON.getIntValue("workflowId"));
|
||||
int requestId = Util.getIntValue(requestJSON.getIntValue("requestId"));
|
||||
String requestName = Util.null2String(requestJSON.getString("requestName"));
|
||||
int userId = Util.getIntValue(requestJSON.getIntValue("userId"));
|
||||
int forwardFlag = Util.getIntValue(requestJSON.getIntValue("forwardFlag"));
|
||||
String forwardResourceIds = Util.null2String(requestJSON.getString("forwardResourceIds"));
|
||||
String mainData = Util.null2String(requestJSON.getString("mainData"));
|
||||
|
||||
if (!"".equals(mainData)) {
|
||||
try {
|
||||
List<WorkflowRequestTableField> mainDatas = JSONObject.parseArray(mainData, WorkflowRequestTableField.class);
|
||||
entity.setMainData(mainDatas);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String detailData = Util.null2String(requestJSON.getString("detailData"));
|
||||
if (!"".equals(detailData)) {
|
||||
try {
|
||||
List<WorkflowDetailTableInfoEntity> detailDatas = JSONObject.parseArray(detailData, WorkflowDetailTableInfoEntity.class);
|
||||
entity.setDetailData(detailDatas);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String remark = Util.null2String(requestJSON.getString("remark"));
|
||||
String requestLevel = Util.null2String(requestJSON.getString("requestLevel"));
|
||||
String otherParams = Util.null2String(requestJSON.getString("otherParams"));
|
||||
if (!"".equals(otherParams)) {
|
||||
try {
|
||||
Map<String,Object> otherParamsMap = (Map<String,Object>)JSONObject.parseObject(otherParams, Map.class);
|
||||
entity.setOtherParams(otherParamsMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
entity.setWorkflowId(workflowId);
|
||||
if (requestId > 0){
|
||||
entity.setRequestId(requestId);
|
||||
}
|
||||
//entity.setRequestId(requestId);
|
||||
entity.setRequestName(requestName);
|
||||
entity.setUserId(userId);
|
||||
entity.setRemark(remark);
|
||||
entity.setRequestLevel(requestLevel);
|
||||
entity.setForwardFlag(forwardFlag);
|
||||
entity.setForwardResourceIds(forwardResourceIds);
|
||||
entity.setClientIp(requestJSON.getString("ip"));
|
||||
int submitNodeId = Util.getIntValue(Util.null2String(requestJSON.getString("submitNodeId")));
|
||||
if (submitNodeId > 0 || FreeNodeBiz.isFreeNode(submitNodeId)) {
|
||||
entity.setSubmitNodeId(submitNodeId);
|
||||
entity.setEnableIntervenor("1".equals(Util.null2s(requestJSON.getString("enableIntervenor"), "1")));
|
||||
entity.setSignType(Util.getIntValue(Util.null2String(requestJSON.getString("SignType")), 0));
|
||||
entity.setIntervenorid(Util.null2String(requestJSON.getString("Intervenorid")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
new BaseBean().writeLog("WorkFlowCmd>> 流程数据异常:"+e);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.api.customization.qc3189074.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class dataBuildJob extends BaseCronJob {
|
||||
String requestId;
|
||||
|
||||
public String getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(String requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String tableName = new BaseBean().getPropValue("qc3189074","tableName");
|
||||
String tableDetailName = new BaseBean().getPropValue("qc3189074","tableDetailName");
|
||||
new BaseBean().writeLog("---dataBuildBegin--");
|
||||
RecordSet rs = new RecordSet();
|
||||
RecordSet rs1 = new RecordSet();
|
||||
List<List<Object>> lsParam = new ArrayList<>();
|
||||
|
||||
String sql = "select a.pbyf,a.kqz,b.* from "+ tableName+" a join "+ tableDetailName+" b " +
|
||||
"on a.id = b.mainid and a.requestid ="+getRequestId();
|
||||
new BaseBean().writeLog("dataBuildSql:" + JSON.toJSONString(sql));
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String kqMonth = rs.getString("pbyf");
|
||||
String kqgroupId = rs.getString("kqz");
|
||||
String resourceId = rs.getString("yg");
|
||||
String requestId = getRequestId();
|
||||
//先把这个人当月的排班删除掉
|
||||
delete(resourceId,kqMonth);
|
||||
|
||||
for (int i = 1; i <= 31 ; i++) {
|
||||
String scheduleDate = "";
|
||||
if (i<10){
|
||||
scheduleDate = kqMonth+"-0"+i;
|
||||
}else {
|
||||
scheduleDate = kqMonth+"-"+i;
|
||||
}
|
||||
String serialId = rs.getString("bc"+i);
|
||||
String insertSql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete,wfid,wfidstatus)"
|
||||
+"values(?,?,?,?,0,?,3)";
|
||||
rs1.executeUpdate(insertSql,scheduleDate,serialId,resourceId,kqgroupId,requestId);
|
||||
}
|
||||
}
|
||||
new BaseBean().writeLog("---dataBuildEnd--");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保一天只有一个班次
|
||||
* @param resourceId
|
||||
*/
|
||||
public void delete(String resourceId,String kqMonth){
|
||||
RecordSet rs = new RecordSet();
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
String delSql = "update kq_shiftschedule set isdelete = 1"+
|
||||
"where resourceid="+resourceId+" and kqdate between '"+monthBeginDate+"' and '"+monthEndDate+"'";
|
||||
rs.executeUpdate(delSql);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,653 @@
|
|||
package com.engine.kq.cmd.shiftschedule;
|
||||
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.customization.kq.util.CustomLeaveUtil;
|
||||
import com.api.customization.kq.util.KqCustomFlowData;
|
||||
import com.api.customization.kq.util.KqMembersValidateUtil;
|
||||
import com.api.customization.qc3189074.util.CustomScheduleUtil;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.biz.SimpleBizLogger;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.kq.bean.KqShiftscheduleOperateLog;
|
||||
import com.engine.kq.biz.*;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.conn.BatchRecordSet;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.Reminder.KQAutoCardTask;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
private String today = weaver.common.DateUtil.getCurrentDate();
|
||||
private SimpleBizLogger logger;
|
||||
public KQLog kqLog = new KQLog();
|
||||
|
||||
|
||||
// 添加日志功能
|
||||
private List<List<Object>> operateLogParams = new ArrayList<>();
|
||||
// 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id
|
||||
private List<Object> operateLogParam = null;
|
||||
|
||||
public ImportExcelCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
this.logger = new SimpleBizLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
String openKqGroupId = new BaseBean().getPropValue("qc3189074","openKqGroupId");
|
||||
CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
|
||||
Map<String, Object> retmap = new HashMap<String, Object>();
|
||||
RecordSet rs = new RecordSet();
|
||||
BatchRecordSet bRs = new BatchRecordSet();
|
||||
String sql = "";
|
||||
try {
|
||||
//必要的权限判断
|
||||
if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) {
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
|
||||
return retmap;
|
||||
}
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
|
||||
KQGroupBiz kqGroupBiz = new KQGroupBiz();
|
||||
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
|
||||
|
||||
String groupId = Util.null2String(params.get("groupId"));
|
||||
List<String> managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue(""+user.getUID(), groupId);
|
||||
|
||||
String filename = Util.null2String(params.get("filename"));
|
||||
String isEdit = Util.null2String(params.get("isEdit"));//是否来自编辑页面
|
||||
String kqMonth = Util.null2String(params.get("kqMonth"));//导入月份
|
||||
String monthBeginDate = weaver.common.DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = weaver.common.DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
|
||||
String newlogic = new BaseBean().getPropValue("qc3560103","newlogic");//新逻辑
|
||||
String oldlogic = new BaseBean().getPropValue("qc3560103","oldlogic");//旧逻辑
|
||||
String isline = new BaseBean().getPropValue("qc3560103","isline");//换行
|
||||
String warnMessage = "";
|
||||
|
||||
Map<String, String> validateFromData = new HashMap<>();
|
||||
KqMembersValidateUtil kqMembersValidateUtil = new KqMembersValidateUtil();
|
||||
|
||||
if ("1".equals(oldlogic)){
|
||||
//获取当前考勤组人员开始生效日期
|
||||
validateFromData = kqMembersValidateUtil.getValidateFromData(groupId, user);
|
||||
}
|
||||
|
||||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||||
|
||||
List lsColumn = null;
|
||||
List<List<Object>> paramInsert = new ArrayList<List<Object>>();
|
||||
List<List<Object>> paramUpdate = new ArrayList<List<Object>>();
|
||||
List<Object> param = null;
|
||||
List<List<Object>> lsFormatParams = new ArrayList<>();
|
||||
List<Object> formatParams = null;
|
||||
|
||||
List<List<Object>> delValidateParams = new ArrayList<>();
|
||||
List<Object> validateParams = null;
|
||||
|
||||
List<List<Object>> lscheckSerialParams = new ArrayList<>();
|
||||
List<Object> checkSerialParams = null;
|
||||
|
||||
//获取当前日期和时间和操作者
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
String operateDate = now.format(dateFormatter); // 日期字符串
|
||||
String operateTime = now.format(timeFormatter); // 时间字符串
|
||||
String operateUser = user.getUID()+""; // 操作人
|
||||
|
||||
Map<String,Object> mapShiftSchedule = new HashMap<>();
|
||||
Map<String,String> mapSerial = new HashMap<>();
|
||||
Map<String,String> mapGroupMembersWorkCode = new HashMap<>();
|
||||
Map<String,String> mapGroupMembersLastName = new HashMap<>();
|
||||
List<String> serialids=Util.splitString2List(kqGroupComInfo.getSerialids(groupId),",");
|
||||
if(!serialids.contains("-1"))serialids.add("-1");
|
||||
for(String serialid : serialids){
|
||||
if(serialid.equals("-1")){
|
||||
mapSerial.put(SystemEnv.getHtmlLabelName(26593, user.getLanguage()),serialid);
|
||||
}else{
|
||||
mapSerial.put(Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialid),""+user.getLanguage()),serialid);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("groupId",groupId);
|
||||
params.put("isNoAccount","1");
|
||||
List<String> kqGroupMembers = kqGroupBiz.getGroupMembers(params);
|
||||
|
||||
KqMembersValidateBiz kqMembersValidateBiz = new KqMembersValidateBiz();
|
||||
CustomLeaveUtil customLeaveUtil = new CustomLeaveUtil();
|
||||
KqCustomFlowData kqCustomFlowData = new KqCustomFlowData();
|
||||
|
||||
Map<String, List<String>> validateResult = new KqMembersValidateBiz(params, user).getKqMembersValidateList();
|
||||
Map<String, Object> workFlowInfo = new HashMap<>();//userid|date--工作流程
|
||||
Map<String, Object> workFlowInfoNew = new HashMap<>();//userid|date--请假流程
|
||||
Map<String, Object> workFlowInfoBackNew = new HashMap<>();//userid|date--销假流程
|
||||
Map<String, Object> shiftFlowInfoNew = new HashMap<>();//userid|date--调班流程
|
||||
Map<String, Object> evectionFlowInfoNew = new HashMap<>();//出差流程
|
||||
Map<String, Object> outFlowInfoNew = new HashMap<>();//公出流程
|
||||
Map<String, Object> changeFlowInfoNew = new HashMap<>();//变更流程
|
||||
//换个逻辑,如果当天有请假,那么不允许操作
|
||||
if ("1".equals(newlogic) && user.getUID()!=1){
|
||||
try {
|
||||
customLeaveUtil.getAllFlowData(workFlowInfo,monthBeginDate,monthEndDate,"1");
|
||||
customLeaveUtil.getLeaveDataNew(workFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
customLeaveUtil.getLeaveBackDataNew(workFlowInfoBackNew,monthBeginDate,monthEndDate);
|
||||
//增加调班流程
|
||||
kqCustomFlowData.getShiftDataNew(shiftFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
//增加出差流程
|
||||
kqCustomFlowData.getEvectionDataNew(evectionFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
//增加外出流程
|
||||
kqCustomFlowData.getOutDataNew(outFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
} catch (Exception e) {
|
||||
kqLog.writeLog("==ImportExcelCmdGetFlowError=="+e);
|
||||
}
|
||||
}
|
||||
kqLog.info("==impotSchedule==groupid"+groupId);
|
||||
kqLog.info("==workFlowInfo=="+JSON.toJSONString(workFlowInfo));
|
||||
kqLog.info("==workFlowInfoNew=="+JSON.toJSONString(workFlowInfoNew));
|
||||
kqLog.info("==workFlowInfoBackNew=="+JSON.toJSONString(workFlowInfoBackNew));
|
||||
kqLog.info("==evectionFlowInfoNew=="+JSON.toJSONString(evectionFlowInfoNew));
|
||||
kqLog.info("==outFlowInfoNew=="+JSON.toJSONString(outFlowInfoNew));
|
||||
List<String> excludeidList = new ArrayList<>();
|
||||
KqShiftscheduleOperateLog bean = null;
|
||||
boolean needChange = false;
|
||||
ResourceComInfo rci = new ResourceComInfo();
|
||||
if(!Util.null2String(kqGroupComInfo.getExcludecount(groupId)).equals("1")) {
|
||||
String excludeid = Util.null2String(kqGroupComInfo.getExcludeid(groupId));
|
||||
if (excludeid.length() > 0) {
|
||||
excludeidList = Util.splitString2List(excludeid,",");
|
||||
}
|
||||
}
|
||||
for(String resourceid : kqGroupMembers){
|
||||
// 排除无需考勤人员
|
||||
if(excludeidList != null && excludeidList.contains(resourceid)) {
|
||||
continue;
|
||||
}
|
||||
String workCode = Util.formatMultiLang(Util.null2String(resourceComInfo.getWorkcode(resourceid)),""+user.getLanguage());
|
||||
String lastName = Util.formatMultiLang(Util.null2String(resourceComInfo.getLastname(resourceid)),""+user.getLanguage());
|
||||
if(workCode.length()>0){
|
||||
mapGroupMembersWorkCode.put(workCode,resourceid);
|
||||
}else if(lastName.length()>0){
|
||||
mapGroupMembersLastName.put(lastName,resourceid);
|
||||
}
|
||||
}
|
||||
|
||||
String tableName = "";
|
||||
if ("1".equals(isEdit)){
|
||||
tableName = "kq_flow_shiftschedule";
|
||||
}else {
|
||||
tableName = "kq_shiftschedule";
|
||||
}
|
||||
sql = " select id, resourceid, kqdate, serialid from "+tableName+" where groupid=? and (isdelete is null or isdelete <> '1') ";
|
||||
rs.executeQuery(sql,groupId);
|
||||
while(rs.next()){
|
||||
mapShiftSchedule.put(rs.getString("kqdate")+"|"+rs.getString("resourceid"),Util.null2String(rs.getString("id"))+"#"+Util.null2String(rs.getString("serialid")));
|
||||
}
|
||||
|
||||
int firstRow = 6;
|
||||
int firstCol = 3;
|
||||
ImageFileManager manager = new ImageFileManager();
|
||||
manager.getImageFileInfoById(Util.getIntValue(filename));
|
||||
//Workbook workbook = WorkbookFactory.create(manager.getInputStream());
|
||||
Workbook workbook = new XSSFWorkbook(manager.getInputStream());
|
||||
for (int idx = 0; idx < workbook.getNumberOfSheets(); idx++) {
|
||||
Sheet sheet = workbook.getSheetAt(idx);
|
||||
if(sheet.getSheetName().indexOf("constraintDataSheet")>-1)continue;
|
||||
Row row = null;
|
||||
Cell cell = null;
|
||||
|
||||
row = sheet.getRow(firstRow);
|
||||
lsColumn = new ArrayList();
|
||||
for (int cellIndex = firstCol; cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
cell = row.getCell((short) cellIndex);
|
||||
lsColumn.add(Util.null2String(getCellValue(cell)).trim());
|
||||
}
|
||||
firstRow++;
|
||||
|
||||
for (int i = firstRow; firstRow<=sheet.getLastRowNum() && i <= sheet.getLastRowNum(); i++) {
|
||||
row = sheet.getRow(i);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
String workCode = Util.null2String(row.getCell(1));//编号
|
||||
String lastName = Util.null2String(row.getCell(2));//姓名
|
||||
if(workCode.length()==0 && lastName.length()==0){
|
||||
continue;
|
||||
}
|
||||
String resourceId = Util.null2String(mapGroupMembersWorkCode.get(workCode));//人员id
|
||||
if(resourceId.length()==0){
|
||||
resourceId = Util.null2String(mapGroupMembersLastName.get(lastName));//人员id
|
||||
}
|
||||
if(resourceId.length()==0)continue;
|
||||
if(!managerRoleUserIdList.isEmpty()) {
|
||||
if(!managerRoleUserIdList.contains(resourceId)) continue;
|
||||
}
|
||||
for (int cellIndex = firstCol; cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
cell = row.getCell((short) cellIndex);
|
||||
if (cell == null) continue;
|
||||
String serialId = "";
|
||||
String serialName = Util.null2String(getCellValue(cell)).trim();
|
||||
if(serialName.length()==0)continue;
|
||||
String kqdate = Util.null2String(lsColumn.get(cellIndex-firstCol));
|
||||
kqdate = kqdate.trim().replace(String.valueOf((char)10), "#");
|
||||
kqdate = kqdate.split("#")[0];
|
||||
if(!SaveShiftScheduleCmd.isDate(kqdate)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if(weaver.common.DateUtil.timeInterval(kqdate,today)>0)continue;//今天之前的无需处理
|
||||
serialId = Util.null2String(mapSerial.get(serialName));
|
||||
if(serialId.length()==0)continue;
|
||||
|
||||
String shiftScheduleValue = Util.null2String(mapShiftSchedule.get(kqdate+"|"+resourceId));
|
||||
String id = "";
|
||||
String oldSerialid = "";
|
||||
if(!"".equals(shiftScheduleValue)) {
|
||||
id = shiftScheduleValue.split("#")[0];
|
||||
oldSerialid = shiftScheduleValue.split("#")[1];
|
||||
}
|
||||
|
||||
// 如果超过了有效期,就不存储数据
|
||||
List<String> validateList = validateResult.get(resourceId);
|
||||
boolean isInRange = kqMembersValidateBiz.isInRange(kqdate, validateList);
|
||||
|
||||
if (!isInRange){
|
||||
continue;
|
||||
}
|
||||
// if(!isInRange && oldSerialid.length() > 0) {
|
||||
// validateParams = new ArrayList<>();
|
||||
// validateParams.add(resourceId);
|
||||
// validateParams.add(kqdate);
|
||||
// delValidateParams.add(validateParams);
|
||||
// lsFormatParams.add(validateParams);
|
||||
// bean = new KqShiftscheduleOperateLog(2,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceId),
|
||||
// kqdate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, "",user.getLanguage());
|
||||
// addLog(bean);
|
||||
// }
|
||||
|
||||
|
||||
if(id.length()>0 && !oldSerialid.equals(serialId) && oldSerialid.length() > 0){
|
||||
String isRest = kqShiftManagementComInfo.getIsRest(oldSerialid);
|
||||
String lastname = resourceComInfo.getLastname(resourceId);
|
||||
kqLog.info("==isRest=="+isRest+ " | "+oldSerialid + " | "+kqdate + " | "+resourceId);
|
||||
//如果当天有请假,不允许修改
|
||||
if ("1".equals(newlogic) && user.getUID()!=1){
|
||||
// if (workFlowInfo.get(resourceId+"|"+kqdate)!=null && user.getUID()!=1
|
||||
// && customLeaveUtil.isLeave(workFlowInfo,resourceId,kqdate,kqTimesArrayComInfo)){
|
||||
// String lastname = resourceComInfo.getLastname(resourceId);
|
||||
// warnMessage += lastname+","+kqdate+",已有请假。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//换成新逻辑吧,因为当天可能没有排班或者是休息班次,没有生成请假数据,所以不能通过标准生成的去判断
|
||||
if ("1".equals(isRest)){
|
||||
|
||||
int groupCount = queryGroupCountByMonth(resourceId,kqMonth);
|
||||
if(groupCount == 0){
|
||||
//校验请假
|
||||
if (customLeaveUtil.isLeaveNew(workFlowInfoNew,resourceId,kqdate,workFlowInfoBackNew)){
|
||||
warnMessage += lastname+","+kqdate+",已有请假。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
//校验出差
|
||||
// if (customLeaveUtil.isKqFlowNew(evectionFlowInfoNew,resourceId,kqdate)){
|
||||
// warnMessage += lastname+","+kqdate+",已有出差。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验公出
|
||||
// if (customLeaveUtil.isKqFlowNew(outFlowInfoNew,resourceId,kqdate)){
|
||||
// warnMessage += lastname+","+kqdate+",已有外出。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验调班
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceId,kqdate)){
|
||||
warnMessage += lastname+","+kqdate+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
if (workFlowInfo.get(resourceId+"|"+kqdate)!=null){
|
||||
warnMessage = customLeaveUtil.isLeave(workFlowInfo,resourceId,kqdate,kqTimesArrayComInfo,lastname,warnMessage);
|
||||
}
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceId,kqdate)){
|
||||
warnMessage += lastname+","+kqdate+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//如果排班月份为当前月份或之前月份,那么不能排班
|
||||
if ("1".equals(oldlogic)){
|
||||
boolean isNonEdit = kqMembersValidateUtil.isHave(kqdate, resourceId, isEdit, user, validateFromData);
|
||||
if (isNonEdit){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message","无法修改当前或者之前的月份,如需修改请联系超管");
|
||||
return retmap;
|
||||
}
|
||||
}
|
||||
|
||||
needChange = true;
|
||||
param = new ArrayList<Object>();
|
||||
param.add(serialId);
|
||||
param.add(operateDate);
|
||||
param.add(operateTime);
|
||||
param.add(operateUser);
|
||||
param.add("importExcel");
|
||||
|
||||
param.add(id);
|
||||
|
||||
// param.add(kqdate);
|
||||
// param.add(resourceId);
|
||||
// param.add(groupId);
|
||||
// param.add(oldSerialid);
|
||||
|
||||
|
||||
paramUpdate.add(param);
|
||||
bean = new KqShiftscheduleOperateLog(1, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceId),
|
||||
kqdate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(serialId) + "(id:" + serialId + ")"),user.getLanguage());
|
||||
addLog(bean);
|
||||
}else{
|
||||
if(!oldSerialid.equals(serialId)) {
|
||||
|
||||
//如果当天有请假,不允许修改
|
||||
|
||||
if ("1".equals(newlogic) && user.getUID()!=1){
|
||||
// if (workFlowInfo.get(resourceId+"|"+kqdate)!=null && user.getUID()!=1
|
||||
// && customLeaveUtil.isLeave(workFlowInfo,resourceId,kqdate,kqTimesArrayComInfo)){
|
||||
// String lastname = resourceComInfo.getLastname(resourceId);
|
||||
// warnMessage += lastname+","+kqdate+",已有请假。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//换成新逻辑吧,因为当天可能没有排班或者是休息班次,没有生成请假数据,所以不能通过标准生成的去判断
|
||||
String isRest = kqShiftManagementComInfo.getIsRest(serialId);
|
||||
if (true){
|
||||
String lastname = resourceComInfo.getLastname(resourceId);
|
||||
//插入的话还是用流程直接判断
|
||||
if ( user.getUID()!=1){
|
||||
|
||||
int groupCount = queryGroupCountByMonth(resourceId,kqMonth);
|
||||
if(groupCount == 0){
|
||||
|
||||
//校验请假
|
||||
if (customLeaveUtil.isLeaveNew(workFlowInfoNew,resourceId,kqdate,workFlowInfoBackNew)){
|
||||
warnMessage += lastname+","+kqdate+",已有请假。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
//校验出差
|
||||
// if (customLeaveUtil.isKqFlowNew(evectionFlowInfoNew,resourceId,kqdate)){
|
||||
// warnMessage += lastname+","+kqdate+",已有出差。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验公出
|
||||
// if (customLeaveUtil.isKqFlowNew(outFlowInfoNew,resourceId,kqdate)){
|
||||
// warnMessage += lastname+","+kqdate+",已有外出。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验调班
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceId,kqdate)){
|
||||
warnMessage += lastname+","+kqdate+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}else if (workFlowInfo.get(resourceId+"|"+kqdate)!=null && user.getUID()!=1){
|
||||
String lastname = resourceComInfo.getLastname(resourceId);
|
||||
warnMessage = customLeaveUtil.isLeave(workFlowInfo,resourceId,kqdate,kqTimesArrayComInfo,lastname,warnMessage);
|
||||
}
|
||||
|
||||
}
|
||||
//如果排班月份为当前月份或之前月份,那么不能排班
|
||||
if ("1".equals(oldlogic)){
|
||||
boolean isNonEdit = kqMembersValidateUtil.isHave(kqdate, resourceId, isEdit, user, validateFromData);
|
||||
if (isNonEdit){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message","无法修改当前或者之前的月份,如需修改请联系超管");
|
||||
return retmap;
|
||||
}
|
||||
}
|
||||
|
||||
needChange = true;
|
||||
param = new ArrayList<Object>();
|
||||
param.add(kqdate);
|
||||
param.add(serialId);
|
||||
param.add(resourceId);
|
||||
param.add(groupId);
|
||||
param.add(operateDate);
|
||||
param.add(operateTime);
|
||||
param.add(operateUser);
|
||||
param.add("importExcel");
|
||||
paramInsert.add(param);
|
||||
bean = new KqShiftscheduleOperateLog(0, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceId),
|
||||
kqdate, "", id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(serialId) + "(id:" + serialId + ")"), user.getLanguage());
|
||||
addLog(bean);
|
||||
}
|
||||
}
|
||||
if(needChange) {
|
||||
formatParams = new ArrayList<>();
|
||||
formatParams.add("importExcel");
|
||||
formatParams.add(resourceId);
|
||||
formatParams.add(kqdate);
|
||||
lsFormatParams.add(formatParams);
|
||||
|
||||
checkSerialParams = new ArrayList<>();
|
||||
checkSerialParams.add("importExcel");
|
||||
checkSerialParams.add(resourceId);
|
||||
checkSerialParams.add(kqdate);
|
||||
checkSerialParams.add(serialId);
|
||||
lscheckSerialParams.add(checkSerialParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (!"".equals(warnMessage)){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message",warnMessage);
|
||||
return retmap;
|
||||
|
||||
}
|
||||
|
||||
//2025-03-27 增加对应操作人信息,以及操作时间
|
||||
//2025-06-06 增加创建来源
|
||||
sql = " update "+tableName+" set serialid=?, isDelete=0,wfidstatus=1,operateDate=?,operateTime=?,operateUser=?,updateFrom=? where id = ? ";
|
||||
boolean isok4 = bRs.executeBatchSqlNew(sql,paramUpdate);
|
||||
new BaseBean().writeLog(idx+">>>isok4="+isok4+",paramUpdate="+ JSONObject.toJSONString(paramUpdate));
|
||||
// for (int i = 0; paramUpdate != null && i < paramUpdate.size(); i++) {
|
||||
// List<Object> update_params = paramUpdate.get(i);
|
||||
// String serialid = Util.null2String(update_params.get(0));
|
||||
// String id = Util.null2String(update_params.get(1));
|
||||
// boolean isUpdate = rs.executeUpdate(sql, serialid, operateDate, operateTime, operateUser,id);
|
||||
// new BaseBean().writeLog("==isUpdate=="+isUpdate);
|
||||
// }
|
||||
|
||||
sql = "insert into "+tableName+" (kqdate,serialid,resourceid,groupid,isDelete,wfidstatus,operateDate,operateTime,operateUser,updateFrom) values(?,?,?,?,0,1,?,?,?,?)";
|
||||
boolean isok3 = bRs.executeBatchSqlNew(sql,paramInsert);
|
||||
new BaseBean().writeLog(idx+">>>isok3="+isok3+",paramInsert="+JSONObject.toJSONString(paramInsert));
|
||||
// for (int i = 0; paramInsert != null && i < paramInsert.size(); i++) {
|
||||
// List<Object> insert_params = paramInsert.get(i);
|
||||
// String kqdate = Util.null2String(insert_params.get(0));
|
||||
// String serialid = Util.null2String(insert_params.get(1));
|
||||
// String resourceid = Util.null2String(insert_params.get(2));
|
||||
// String groupid = Util.null2String(insert_params.get(3));
|
||||
// rs.executeUpdate(sql, kqdate,serialid,resourceid,groupid,operateDate,operateTime,operateUser);
|
||||
// }
|
||||
}
|
||||
|
||||
// 删除一些有效期之后的排班
|
||||
// sql = " update "+tableName+" set isdelete =1,wfidstatus=3 where resourceid = ? and kqdate = ? and groupid = "+groupId;
|
||||
// boolean isok1 = bRs.executeBatchSqlNew(sql,lsFormatParams);
|
||||
// new BaseBean().writeLog("isok1="+isok1+",lsFormatParams="+JSONObject.toJSONString(lsFormatParams));
|
||||
// for (List<Object> delete_params : delValidateParams) {
|
||||
// String resourceid = Util.null2String(delete_params.get(0));
|
||||
// String kqdate = Util.null2String(delete_params.get(1));
|
||||
// rs.executeUpdate(sql, resourceid, kqdate);
|
||||
// }
|
||||
|
||||
//删除之前的排的班次,一天只能有一个班次
|
||||
sql = " update "+tableName+" set isdelete =1,wfidstatus=3,deleteFrom=? where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and groupid != "+groupId;
|
||||
boolean isok1 = bRs.executeBatchSqlNew(sql,lsFormatParams);
|
||||
kqLog.info("isok1="+isok1+",lsFormatParams="+JSONObject.toJSONString(lsFormatParams));
|
||||
// for (int i = 0; lsFormatParams != null && i < lsFormatParams.size(); i++) {
|
||||
// List<Object> delete_params = lsFormatParams.get(i);
|
||||
// String resourceid = Util.null2String(delete_params.get(0));
|
||||
// String kqdate = Util.null2String(delete_params.get(1));
|
||||
// rs.executeUpdate(sql, resourceid,kqdate);
|
||||
// }
|
||||
|
||||
sql = " update "+tableName+" set isdelete =1,wfidstatus=3,deleteFrom=? where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and serialid != ? ";
|
||||
boolean isok2 = bRs.executeBatchSqlNew(sql,lscheckSerialParams);
|
||||
kqLog.info("isok2="+isok2+",lscheckSerialParams="+JSONObject.toJSONString(lscheckSerialParams));
|
||||
// for (int i = 0; lscheckSerialParams != null && i < lscheckSerialParams.size(); i++) {
|
||||
// List<Object> check_params = lscheckSerialParams.get(i);
|
||||
// String resourceid = Util.null2String(check_params.get(0));
|
||||
// String kqdate = Util.null2String(check_params.get(1));
|
||||
// String serialid = Util.null2String(check_params.get(2));
|
||||
// rs.executeUpdate(sql, resourceid,kqdate,serialid);
|
||||
// }
|
||||
|
||||
sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)";
|
||||
bRs.executeBatchSqlNew(sql, operateLogParams);
|
||||
|
||||
new KQShiftScheduleComInfo().removeCache();
|
||||
|
||||
//刷新报表数据
|
||||
// sql = " insert into kq_format_pool (resourceid, kqdate) values (?,?)";
|
||||
// bRs.executeBatchSql(sql, lsFormatParams);
|
||||
new KQFormatBiz().format(lsFormatParams,16);
|
||||
|
||||
KQGroupComInfo kQGroupComInfo = new KQGroupComInfo();
|
||||
String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId);
|
||||
String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId);
|
||||
if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){
|
||||
//如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存
|
||||
KQAutoCardTask kqAutoCardTask = new KQAutoCardTask();
|
||||
kqAutoCardTask.initAutoCardTask(groupId);
|
||||
}
|
||||
|
||||
retmap.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
|
||||
new BaseBean().writeLog("==importScheduleError== 错误信息:" + ExceptionUtil.getMessage(e));
|
||||
new BaseBean().writeLog("==importScheduleError== 堆栈信息:\n" + ExceptionUtil.stacktraceToString(e)); }
|
||||
return retmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BizLogContext> getLogContexts() {
|
||||
return logger.getBizLogContexts();
|
||||
}
|
||||
|
||||
/**
|
||||
* /**
|
||||
* 获取excel单元格值
|
||||
*
|
||||
* @param cell 要读取的单元格对象
|
||||
* @return
|
||||
*/
|
||||
public String getCellValue(Cell cell) {
|
||||
String cellValue = "";
|
||||
if (cell == null)
|
||||
return "";
|
||||
switch (cell.getCellType()) {
|
||||
case BOOLEAN: // 得到Boolean对象的方法
|
||||
cellValue = String.valueOf(cell.getBooleanCellValue());
|
||||
break;
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式
|
||||
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
|
||||
cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式
|
||||
} else {
|
||||
cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字
|
||||
if (cellValue.endsWith(".0"))
|
||||
cellValue = cellValue.substring(0, cellValue.indexOf("."));
|
||||
}
|
||||
break;
|
||||
case FORMULA: // 读取公式
|
||||
cellValue = cell.getCellFormula();
|
||||
break;
|
||||
case STRING: // 读取String
|
||||
cellValue = cell.getStringCellValue();
|
||||
break;
|
||||
}
|
||||
|
||||
return cellValue;
|
||||
}
|
||||
|
||||
private void addLog(KqShiftscheduleOperateLog bean) {
|
||||
operateLogParam = new ArrayList<>();
|
||||
operateLogParam.add(bean.getOperatetype());
|
||||
operateLogParam.add(bean.getOperator());
|
||||
operateLogParam.add(bean.getKqgroupname());
|
||||
operateLogParam.add(bean.getChangeduser());
|
||||
operateLogParam.add(bean.getChangedshiftdate());
|
||||
operateLogParam.add(bean.getChangedshiftname());
|
||||
operateLogParam.add(bean.getKqshiftid());
|
||||
operateLogParams.add(operateLogParam);
|
||||
}
|
||||
|
||||
|
||||
public int queryGroupCountByMonth(String resourceid, String kqMonth) {
|
||||
int count = 0;
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(resourceid) && StringUtils.isNotBlank(kqMonth)){
|
||||
String sql =" SELECT distinct resourceid, groupid FROM ( " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.subcompanyid1 = b.typevalue AND b.type=2 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.jobtitle = b.typevalue AND b.type=5 " +
|
||||
" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " +
|
||||
" and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') ) t" +
|
||||
" where 1=1 "+
|
||||
" and t.status in (0,1,2,3) "+
|
||||
" and t.resourceid = "+resourceid+
|
||||
" and left(t.validateto,7)='"+kqMonth+"'";
|
||||
bb.writeLog("sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,534 @@
|
|||
package com.engine.kq.cmd.shiftschedule;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.customization.kq.util.CustomLeaveUtil;
|
||||
import com.api.customization.kq.util.KqCustomFlowData;
|
||||
import com.api.customization.kq.util.KqMembersValidateUtil;
|
||||
import com.api.customization.qc3189074.util.CustomScheduleUtil;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.biz.SimpleBizLogger;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.kq.bean.KqShiftscheduleOperateLog;
|
||||
import com.engine.kq.biz.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.BatchRecordSet;
|
||||
import weaver.conn.DBUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.Reminder.KQAutoCardTask;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SaveShiftScheduleCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
private SimpleBizLogger logger;
|
||||
|
||||
// 添加日志功能
|
||||
private List<List<Object>> operateLogParams = new ArrayList<>();
|
||||
// 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id
|
||||
private List<Object> operateLogParam = null;
|
||||
//启动新功能的考勤组
|
||||
public String openKqGroupId = new BaseBean().getPropValue("qc3189074","openKqGroupId");
|
||||
|
||||
|
||||
public SaveShiftScheduleCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
this.logger = new SimpleBizLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> retmap = new HashMap<String, Object>();
|
||||
RecordSet rs = new RecordSet();
|
||||
BatchRecordSet bRs = new BatchRecordSet();
|
||||
String today = DateUtil.getCurrentDate();
|
||||
String sql = "";
|
||||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||||
|
||||
try{
|
||||
//必要的权限判断
|
||||
if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) {
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
|
||||
return retmap;
|
||||
}
|
||||
String data = Util.null2String(params.get("data"));
|
||||
JSONObject jsonObj = JSON.parseObject(data);
|
||||
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
|
||||
KQShiftManagementComInfo kqShiftScheduleComInfo = new KQShiftManagementComInfo();
|
||||
ResourceComInfo rci = new ResourceComInfo();
|
||||
String groupId = Util.null2String(jsonObj.get("groupId"));
|
||||
String kqMonth = Util.null2String(jsonObj.get("kqMonth"));
|
||||
String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
|
||||
String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
|
||||
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
|
||||
|
||||
JSONArray datas = jsonObj.getJSONArray("datas");
|
||||
|
||||
String isEdit = Util.null2String(jsonObj.get("isEdit")); //是否来自编辑页面
|
||||
|
||||
String newlogic = new BaseBean().getPropValue("qc3560103","newlogic");//新逻辑
|
||||
String oldlogic = new BaseBean().getPropValue("qc3560103","oldlogic");//旧逻辑
|
||||
String isline = new BaseBean().getPropValue("qc3560103","isline");//换行
|
||||
String warnMessage = "";
|
||||
CustomLeaveUtil customLeaveUtil = new CustomLeaveUtil();
|
||||
KqCustomFlowData kqCustomFlowData = new KqCustomFlowData();
|
||||
Map<String, String> validateFromData = new HashMap<>();
|
||||
KqMembersValidateUtil kqMembersValidateUtil = new KqMembersValidateUtil();
|
||||
|
||||
//新逻辑需要的参数信息
|
||||
Map<String, Object> workFlowInfo = new HashMap<>();//userid|date--工作流程
|
||||
Map<String, Object> workFlowInfoNew = new HashMap<>();//userid|date--请假流程
|
||||
Map<String, Object> workFlowInfoBackNew = new HashMap<>();//userid|date--销假流程
|
||||
Map<String, Object> shiftFlowInfoNew = new HashMap<>();//userid|date--调班流程
|
||||
Map<String, Object> evectionFlowInfoNew = new HashMap<>();//出差流程
|
||||
Map<String, Object> outFlowInfoNew = new HashMap<>();//公出流程
|
||||
Map<String, Object> changeFlowInfoNew = new HashMap<>();//变更流程
|
||||
if ("1".equals(newlogic)){
|
||||
customLeaveUtil.getAllFlowData(workFlowInfo,monthBeginDate,monthEndDate,"1");
|
||||
customLeaveUtil.getLeaveDataNew(workFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
customLeaveUtil.getLeaveBackDataNew(workFlowInfoBackNew,monthBeginDate,monthEndDate);
|
||||
//增加调班流程
|
||||
kqCustomFlowData.getShiftDataNew(shiftFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
//增加出差流程
|
||||
kqCustomFlowData.getEvectionDataNew(evectionFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
//增加外出流程
|
||||
kqCustomFlowData.getOutDataNew(outFlowInfoNew,monthBeginDate,monthEndDate);
|
||||
}
|
||||
|
||||
//获取当前考勤组人员开始生效日期
|
||||
if ("1".equals(oldlogic)){
|
||||
validateFromData = kqMembersValidateUtil.getValidateFromData(groupId, user);
|
||||
}
|
||||
|
||||
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
List<List<Object>> paramInsert = new ArrayList<List<Object>>();
|
||||
List<List<Object>> paramUpdate = new ArrayList<List<Object>>();
|
||||
List<Object> params = null;
|
||||
String delIds = "";
|
||||
List<List<Object>> lsFormatParams = new ArrayList<>();
|
||||
List<Object> formatParams = null;
|
||||
List<List<Object>> lsDeleteParams = new ArrayList<>();
|
||||
List<Object> deleteParams = null;
|
||||
List<List<Object>> lscheckSerialParams = new ArrayList<>();
|
||||
List<Object> checkSerialParams = null;
|
||||
|
||||
JSONObject resourceDataObj = null;
|
||||
JSONArray arrKqDataObj = null;
|
||||
JSONObject kqDataObj = null;
|
||||
KqShiftscheduleOperateLog bean = null;
|
||||
for(int i=0;datas!=null&&i<datas.size();i++){
|
||||
resourceDataObj = (JSONObject)datas.get(i);
|
||||
String resourceid = Util.null2String(resourceDataObj.get("resourceid"));
|
||||
String lastname = resourceComInfo.getLastname(resourceid);
|
||||
int groupCount = queryGroupCountByMonth(resourceid,kqMonth);
|
||||
arrKqDataObj = resourceDataObj.getJSONArray("kqdata");
|
||||
for(int j=0;arrKqDataObj!=null&&j<arrKqDataObj.size();j++) {
|
||||
kqDataObj = (JSONObject) arrKqDataObj.get(j);
|
||||
// 如果id为空,则代表原先是空白单元格
|
||||
String id = Util.null2String(kqDataObj.get("id"));
|
||||
String date = Util.null2String(kqDataObj.get("date"));
|
||||
if(!SaveShiftScheduleCmd.isDate(date)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 原先排班的班次id
|
||||
String oldSerialid = Util.null2String(kqDataObj.get("oldValue"));
|
||||
// 新班次id 如果 serialid是-999, oldValue是班次id,那么就是原先是有班次的,后面把班次删除了
|
||||
String serialid = Util.null2String(kqDataObj.get("serialid"));
|
||||
if(serialid.equals("-999"))serialid="";
|
||||
boolean needChange = false;
|
||||
//if(weaver.common.DateUtil.timeInterval(date,today)>0)continue;//今天之前的无需处理
|
||||
if(id.length()>0){ // 更新
|
||||
if(serialid.length()==0 && oldSerialid.length() > 0){ //删除
|
||||
|
||||
String isRest = kqShiftManagementComInfo.getIsRest(oldSerialid);
|
||||
|
||||
if ("1".equals(newlogic) && user.getUID()!=1){
|
||||
//换成新逻辑吧,因为当天可能没有排班或者是休息班次,没有生成请假数据,所以不能通过标准生成的去判断
|
||||
if ("1".equals(isRest)){
|
||||
//校验请假
|
||||
|
||||
new BaseBean().writeLog("删除-groupCount:"+groupCount);
|
||||
if(groupCount == 0) {
|
||||
if (customLeaveUtil.isLeaveNew(workFlowInfoNew, resourceid, date, workFlowInfoBackNew)) {
|
||||
warnMessage += lastname + "," + date + ",已有请假。" + ("1".equals(isline) ? "\n" : "");
|
||||
}
|
||||
//校验出差
|
||||
// if (customLeaveUtil.isKqFlowNew(evectionFlowInfoNew,resourceid,date)){
|
||||
// warnMessage += lastname+","+date+",已有出差。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验公出
|
||||
// if (customLeaveUtil.isKqFlowNew(outFlowInfoNew, resourceid, date)) {
|
||||
// warnMessage += lastname + "," + date + ",已有外出。" + ("1".equals(isline) ? "\n" : "");
|
||||
// }
|
||||
//校验调班
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew, resourceid, date)) {
|
||||
warnMessage += lastname + "," + date + ",已有调班。" + ("1".equals(isline) ? "\n" : "");
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
if (workFlowInfo.get(resourceid+"|"+date)!=null){
|
||||
warnMessage = customLeaveUtil.isLeave(workFlowInfo,resourceid,date,kqTimesArrayComInfo,lastname,warnMessage);
|
||||
}
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceid,date)){
|
||||
warnMessage += lastname+","+date+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//如果排班月份为当前月份或之前月份,那么不能排班
|
||||
if ("1".equals(oldlogic)){
|
||||
boolean isNonEdit = kqMembersValidateUtil.isHave(date, resourceid,isEdit, user,validateFromData);
|
||||
if (isNonEdit){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message","无法修改当前或者之前的月份,如需修改请联系超管");
|
||||
return retmap;
|
||||
}
|
||||
}
|
||||
|
||||
if(delIds.length()>0) {
|
||||
delIds+=",";
|
||||
}
|
||||
delIds+=id;
|
||||
bean = new KqShiftscheduleOperateLog(2,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid),
|
||||
date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, "", user.getLanguage());
|
||||
addLog(bean);
|
||||
}else {
|
||||
if(!oldSerialid.equals(serialid) && oldSerialid.length() > 0) {
|
||||
String isRest = kqShiftManagementComInfo.getIsRest(oldSerialid);
|
||||
|
||||
if ("1".equals(newlogic) && user.getUID()!=1){
|
||||
//换成新逻辑吧,因为当天可能没有排班或者是休息班次,没有生成请假数据,所以不能通过标准生成的去判断
|
||||
if ("1".equals(isRest)){
|
||||
new BaseBean().writeLog("更新-groupCount:"+groupCount);
|
||||
if(groupCount == 0) {
|
||||
//校验请假
|
||||
if (customLeaveUtil.isLeaveNew(workFlowInfoNew,resourceid,date,workFlowInfoBackNew)){
|
||||
warnMessage += lastname+","+date+",已有请假。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
//校验出差
|
||||
// if (customLeaveUtil.isKqFlowNew(evectionFlowInfoNew,resourceid,date)){
|
||||
// warnMessage += lastname+","+date+",已有出差。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验公出
|
||||
// if (customLeaveUtil.isKqFlowNew(outFlowInfoNew,resourceid,date)){
|
||||
// warnMessage += lastname+","+date+",已有外出。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验调班
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceid,date)){
|
||||
warnMessage += lastname+","+date+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
if (workFlowInfo.get(resourceid+"|"+date)!=null){
|
||||
warnMessage = customLeaveUtil.isLeave(workFlowInfo,resourceid,date,kqTimesArrayComInfo,lastname,warnMessage);
|
||||
}
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceid,date)){
|
||||
warnMessage += lastname+","+date+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("1".equals(oldlogic)){
|
||||
//如果排班月份为当前月份或之前月份,那么不能排班
|
||||
boolean isNonEdit = kqMembersValidateUtil.isHave(date, resourceid,isEdit, user,validateFromData);
|
||||
if (isNonEdit){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message","无法修改当前或者之前的月份,如需修改请联系超管");
|
||||
return retmap;
|
||||
}
|
||||
}
|
||||
|
||||
needChange = true;
|
||||
params = new ArrayList<Object>();
|
||||
params.add(serialid);
|
||||
params.add(id);
|
||||
params.add(date);
|
||||
params.add(resourceid);
|
||||
params.add(groupId);
|
||||
params.add(oldSerialid);
|
||||
|
||||
paramUpdate.add(params);
|
||||
bean = new KqShiftscheduleOperateLog(1,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid),
|
||||
date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, ("-1".equals(serialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialid)+"(id:"+serialid+")"), user.getLanguage());
|
||||
addLog(bean);
|
||||
}
|
||||
}
|
||||
}else{ //新建
|
||||
if(serialid.length()==0)continue;
|
||||
if(!oldSerialid.equals(serialid)) {
|
||||
if ("1".equals(newlogic) && user.getUID()!=1){
|
||||
String isRest = kqShiftManagementComInfo.getIsRest(serialid);
|
||||
//换成新逻辑吧,因为当天可能没有排班或者是休息班次,没有生成请假数据,所以不能通过标准生成的去判断
|
||||
if ("1".equals(isRest)){
|
||||
|
||||
new BaseBean().writeLog("新增-groupCount:"+groupCount);
|
||||
if(groupCount == 0) {
|
||||
//校验请假
|
||||
if (customLeaveUtil.isLeaveNew(workFlowInfoNew,resourceid,date,workFlowInfoBackNew)){
|
||||
warnMessage += lastname+","+date+",已有请假。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
//校验出差
|
||||
// if (customLeaveUtil.isKqFlowNew(evectionFlowInfoNew,resourceid,date)){
|
||||
// warnMessage += lastname+","+date+",已有出差。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验公出
|
||||
// if (customLeaveUtil.isKqFlowNew(outFlowInfoNew,resourceid,date)){
|
||||
// warnMessage += lastname+","+date+",已有外出。"+("1".equals(isline)?"\n":"");
|
||||
// }
|
||||
//校验调班
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceid,date)){
|
||||
warnMessage += lastname+","+date+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
if (workFlowInfo.get(resourceid+"|"+date)!=null){
|
||||
warnMessage = customLeaveUtil.isLeave(workFlowInfo,resourceid,date,kqTimesArrayComInfo,lastname,warnMessage);
|
||||
}
|
||||
if (customLeaveUtil.isKqFlowNew(shiftFlowInfoNew,resourceid,date)){
|
||||
warnMessage += lastname+","+date+",已有调班。"+("1".equals(isline)?"\n":"");
|
||||
}
|
||||
}
|
||||
}
|
||||
//如果排班月份为当前月份或之前月份,那么不能排班
|
||||
if ("1".equals(oldlogic)){
|
||||
boolean isNonEdit = kqMembersValidateUtil.isHave(date, resourceid,isEdit, user,validateFromData);
|
||||
if (isNonEdit){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message","无法修改当前或者之前的月份,如需修改请联系超管");
|
||||
return retmap;
|
||||
}
|
||||
}
|
||||
|
||||
needChange = true;
|
||||
params = new ArrayList<Object>();
|
||||
params.add(date);
|
||||
params.add(serialid);
|
||||
params.add(resourceid);
|
||||
params.add(groupId);
|
||||
paramInsert.add(params);
|
||||
bean = new KqShiftscheduleOperateLog(0,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid),
|
||||
date, "", id, ("-1".equals(serialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialid)+"(id:"+serialid+")"), user.getLanguage());
|
||||
addLog(bean);
|
||||
}
|
||||
}
|
||||
if(needChange) {
|
||||
deleteParams = new ArrayList<>();
|
||||
deleteParams.add(resourceid);
|
||||
deleteParams.add(date);
|
||||
lsDeleteParams.add(deleteParams);
|
||||
|
||||
checkSerialParams = new ArrayList<>();
|
||||
checkSerialParams.add(resourceid);
|
||||
checkSerialParams.add(date);
|
||||
checkSerialParams.add(serialid);
|
||||
lscheckSerialParams.add(checkSerialParams);
|
||||
|
||||
if(DateUtil.timeInterval(date,today)>=0) {
|
||||
formatParams = new ArrayList<>();
|
||||
formatParams.add(resourceid);
|
||||
formatParams.add(date);
|
||||
lsFormatParams.add(formatParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!"".equals(warnMessage)){
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message",warnMessage);
|
||||
return retmap;
|
||||
}
|
||||
//zj
|
||||
CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
|
||||
boolean isopenGroup = customScheduleUtil.isOpenGroup(groupId);
|
||||
String tableName = "";
|
||||
if ("1".equals(isEdit)){
|
||||
tableName = "kq_flow_shiftschedule";
|
||||
}else {
|
||||
tableName = "kq_shiftschedule";
|
||||
}
|
||||
|
||||
|
||||
if (isopenGroup && "1".equals(isEdit) && (user.getUID() != 1)){
|
||||
sql = " update "+tableName+" set serialid=?,wfidstatus=1,isDelete=0 where id = ? ";
|
||||
}else {
|
||||
sql = " update "+tableName+" set serialid=?,wfidstatus=3,isDelete=0 where id = ? ";
|
||||
}
|
||||
for (int i = 0; paramUpdate != null && i < paramUpdate.size(); i++) {
|
||||
List<Object> update_params = paramUpdate.get(i);
|
||||
String serialid = Util.null2String(update_params.get(0));
|
||||
String id = Util.null2String(update_params.get(1));
|
||||
rs.executeUpdate(sql, serialid,id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//zj
|
||||
if (isopenGroup && "1".equals(isEdit) && (user.getUID() != 1)){
|
||||
sql = "insert into "+tableName+" (kqdate,serialid,resourceid,groupid,isDelete,wfidstatus) values(?,?,?,?,0,1)";
|
||||
}else {
|
||||
sql = "insert into kq_shiftschedule (kqdate,serialid,resourceid,groupid,isDelete) values(?,?,?,?,0)";
|
||||
}
|
||||
|
||||
for (int i = 0; paramInsert != null && i < paramInsert.size(); i++) {
|
||||
List<Object> insert_params = paramInsert.get(i);
|
||||
String kqdate = Util.null2String(insert_params.get(0));
|
||||
String serialid = Util.null2String(insert_params.get(1));
|
||||
String resourceid = Util.null2String(insert_params.get(2));
|
||||
String groupid = Util.null2String(insert_params.get(3));
|
||||
rs.executeUpdate(sql, kqdate, serialid, resourceid, groupid);
|
||||
}
|
||||
|
||||
if(delIds.length()>0){
|
||||
List sqlParams = new ArrayList();
|
||||
Object[] objects= DBUtil.transListIn(delIds,sqlParams);
|
||||
//==zj 如果是新功能,删除得批准后才能生效
|
||||
if (isopenGroup && "1".equals(isEdit) && (user.getUID() != 1)){
|
||||
sql = "update "+tableName+" set isdelete =1,wfidstatus=1 where id in("+objects[0]+") ";
|
||||
}else {
|
||||
sql = "update kq_shiftschedule set isdelete =1,wfidstatus=3 where id in("+objects[0]+") ";
|
||||
}
|
||||
|
||||
rs.executeUpdate(sql, sqlParams);
|
||||
}
|
||||
|
||||
//删除之前的排的班次,一天只能有一个班次
|
||||
sql = " update "+tableName+" set isdelete =1,wfidstatus=3 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and groupid != "+groupId;
|
||||
for (int i = 0; lsDeleteParams != null && i < lsDeleteParams.size(); i++) {
|
||||
List<Object> delete_params = lsDeleteParams.get(i);
|
||||
String resourceid = Util.null2String(delete_params.get(0));
|
||||
String kqdate = Util.null2String(delete_params.get(1));
|
||||
rs.executeUpdate(sql, resourceid,kqdate);
|
||||
}
|
||||
|
||||
sql = " update "+tableName+" set isdelete =1,wfidstatus=3 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and serialid != ? ";
|
||||
for (int i = 0; lscheckSerialParams != null && i < lscheckSerialParams.size(); i++) {
|
||||
List<Object> check_params = lscheckSerialParams.get(i);
|
||||
String resourceid = Util.null2String(check_params.get(0));
|
||||
String kqdate = Util.null2String(check_params.get(1));
|
||||
String serialid = Util.null2String(check_params.get(2));
|
||||
rs.executeUpdate(sql, resourceid,kqdate,serialid);
|
||||
}
|
||||
|
||||
sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)";
|
||||
bRs.executeBatchSqlNew(sql, operateLogParams);
|
||||
|
||||
new KQShiftScheduleComInfo().removeCache();
|
||||
|
||||
//刷新报表数据
|
||||
new KQFormatBiz().format(lsFormatParams,16);
|
||||
|
||||
KQGroupComInfo kQGroupComInfo = new KQGroupComInfo();
|
||||
String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId);
|
||||
String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId);
|
||||
if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){
|
||||
//如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存
|
||||
KQAutoCardTask kqAutoCardTask = new KQAutoCardTask();
|
||||
kqAutoCardTask.initAutoCardTask(groupId);
|
||||
}
|
||||
|
||||
retmap.put("status", "1");
|
||||
retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage()));
|
||||
}catch (Exception e) {
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
|
||||
writeLog(e);
|
||||
}
|
||||
CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
|
||||
return retmap;
|
||||
}
|
||||
|
||||
private void addLog(KqShiftscheduleOperateLog bean) {
|
||||
operateLogParam = new ArrayList<>();
|
||||
operateLogParam.add(bean.getOperatetype());
|
||||
operateLogParam.add(bean.getOperator());
|
||||
operateLogParam.add(bean.getKqgroupname());
|
||||
operateLogParam.add(bean.getChangeduser());
|
||||
operateLogParam.add(bean.getChangedshiftdate());
|
||||
operateLogParam.add(bean.getChangedshiftname());
|
||||
operateLogParam.add(bean.getKqshiftid());
|
||||
operateLogParams.add(operateLogParam);
|
||||
}
|
||||
|
||||
public static boolean isDate(String str) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
sdf.setLenient(false); // 严格匹配
|
||||
try {
|
||||
sdf.parse(str);
|
||||
return true;
|
||||
} catch (ParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BizLogContext> getLogContexts() {
|
||||
return logger.getBizLogContexts();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int queryGroupCountByMonth(String resourceid, String kqMonth) {
|
||||
int count = 0;
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(resourceid) && StringUtils.isNotBlank(kqMonth)){
|
||||
String sql =" SELECT distinct resourceid, groupid FROM ( " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.subcompanyid1 = b.typevalue AND b.type=2 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE a.jobtitle = b.typevalue AND b.type=5 " +
|
||||
" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " +
|
||||
" and (b.isdelete is null or b.isdelete <> '1') " +
|
||||
" UNION ALL " +
|
||||
" SELECT a.id AS resourceid, b.groupid, a.status,b.validateto FROM HrmResource a, kq_groupmember b " +
|
||||
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') ) t" +
|
||||
" where 1=1 "+
|
||||
" and t.status in (0,1,2,3) "+
|
||||
" and t.resourceid = "+resourceid+
|
||||
" and left(t.validateto,7)='"+kqMonth+"'";
|
||||
bb.writeLog("sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
if(rs.next()){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package weaver.interfaces.message;
|
||||
|
||||
import com.cloudstore.dev.api.bean.MessageBean;
|
||||
import com.cloudstore.dev.api.bean.MessageType;
|
||||
import com.cloudstore.dev.api.util.Util_Message;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.workflow.publicApi.WorkflowRequestTodoPA;
|
||||
import com.engine.workflow.publicApi.impl.WorkflowRequestListPAImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class SendTodoDataCron extends BaseCronJob {
|
||||
|
||||
public String code ;
|
||||
String userid ;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
private WorkflowRequestTodoPA getWorkflowTodoPA(){
|
||||
return (WorkflowRequestListPAImpl) ServiceUtil.getService(WorkflowRequestListPAImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
BaseBean bb = new BaseBean();
|
||||
WorkflowRequestTodoPA requestTodoPA = getWorkflowTodoPA();
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String where = "";
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
String userids = "'"+userid.replace(",", "','")+"'" ;
|
||||
where = " and id in("+userids+") ";
|
||||
}
|
||||
String sql = " select id from hrmresource where status in(0,1,2,3,4) " + where ;
|
||||
bb.writeLog("sql:"+sql);
|
||||
rs.execute(sql);
|
||||
while (rs.next()){
|
||||
String userid = rs.getString("id");
|
||||
list.add(userid);
|
||||
}
|
||||
bb.writeLog("list:"+list.size());
|
||||
if(StringUtils.isNotBlank(code)){
|
||||
int createrId = 1;
|
||||
MessageType messageType = MessageType.newInstance(Integer.valueOf(code)); // 消息来源(见文档第四点补充 必填)
|
||||
for (String userid : list){
|
||||
User user = new User(Integer.valueOf(userid));
|
||||
Map<String,String> conditions = new HashMap<String, String>();
|
||||
// conditions.put("doingStatus","5");
|
||||
|
||||
long toDoWorkflowRequestCount = requestTodoPA.getDoingWorkflowRequestCount(user, conditions, false, false);
|
||||
|
||||
if(toDoWorkflowRequestCount > 0){
|
||||
|
||||
Set<String> userIdList = new HashSet<>(); // 接收人id 必填
|
||||
userIdList.add(userid);
|
||||
String title = "审批提醒"; // 标题
|
||||
String context = "截至到目前你共有"+toDoWorkflowRequestCount+"条审批,请及时处理"; // 内容
|
||||
String linkUrl = "/spa/workflow/static/index.html#/main/workflow/listDoing"; // PC端链接
|
||||
String linkMobileUrl = "/spa/workflow/static4mobile/index.html#/center/doing?moduleid=1"; // 移动端链接
|
||||
try {
|
||||
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
|
||||
messageBean.setCreater(createrId);// 创建人id
|
||||
Util_Message.store(messageBean);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue