You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-develop/src/com/engine/kq/biz/KQFlowDataBiz.java

862 lines
33 KiB
Java

package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.wfset.bean.SplitBean;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
/**
*
*/
public class KQFlowDataBiz {
private String resourceid;
private String fromDate;
private String toDate;
private String fromTime;
private String toTime;
private String belongDate;
private String newLeaveType;
private String orderby_sql;
public KQFlowDataBiz(FlowDataParamBuilder build){
this.resourceid = build.resourceid;
this.fromDate = build.fromDate;
this.toDate = build.toDate;
this.fromTime = build.fromTime;
this.toTime = build.toTime;
this.belongDate = build.belongDate;
this.newLeaveType = build.newLeaveType;
this.orderby_sql = build.orderby_sql;
}
/**
*
*
* @param flowMaps
* @param isAll truefalse
* @return
*/
public List<SplitBean> getAllFlowData(Map<String,Object> flowMaps,boolean isAll){
List<SplitBean> allSplitBeans = new ArrayList<>();
Map<String,String> flowDeductCard = getFlowDeductCard();
allSplitBeans.addAll(getEvectionData(flowMaps,flowDeductCard));
allSplitBeans.addAll(getOutData(flowMaps,flowDeductCard));
allSplitBeans.addAll(getLeaveData(flowMaps,flowDeductCard));
if(isAll){
allSplitBeans.addAll(getOverTimeData(flowMaps));
}
allSplitBeans.addAll(getOtherData(flowMaps));
return allSplitBeans;
}
/**
*
*/
public Map<String,String> getFlowDeductCard() {
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
Map<String,String> flowDeductCard = new HashMap<>();
String flowDeductCardSql = "select * from kq_flow_deduct_card t where 1=1 and (isclear is null or isclear<>1) ";
String sqlWhere = sqlFlowCardParamWhere();
if(sqlWhere.length() > 0){
flowDeductCardSql += sqlWhere;
}
rs.execute(flowDeductCardSql);
while(rs.next()){
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String signtype= rs.getString("signtype");
String serialnumber= rs.getString("serialnumber");
String flowtype= rs.getString("flowtype");
String key = requestId+"_"+resourceid+"_"+flowtype;
String serial_signtype = serialnumber+"_"+signtype;
if(flowDeductCard.containsKey(key)){
String tmpSignType = Util.null2String(flowDeductCard.get(key));
flowDeductCard.put(key, tmpSignType+","+serial_signtype);
}else{
flowDeductCard.put(key, serial_signtype);
}
}
return flowDeductCard;
}
/**
*
*/
public List<SplitBean> getLeaveData(Map<String, Object> flowMaps,
Map<String, String> flowDeductCard){
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String tablename = "select * from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" where requestsyncid > 0 ";
// String tablename = "select a.* from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String sqlWhere = sqlParamWhere();
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.executeQuery(tablename);
new BaseBean().writeLog("==leaveSql=="+tablename);
while(rs.next()){
new BaseBean().writeLog("==zj1==");
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"));
new BaseBean().writeLog("==zj2==");
String fromtimedb= rs.getString("fromtimedb");
String totimedb= rs.getString("totimedb");
String repeatType = Util.null2String(rs.getString("repeat_type"));
String repeatLate = Util.null2String(rs.getString("repeat_late"));
String repeatEarly = Util.null2String(rs.getString("repeat_early"));
if(Util.getDoubleValue(duration) <= 0){
if(repeatType.length() > 0){
//哺乳假的不需要时长
}else{
// continue;
}
}
new BaseBean().writeLog("==zj3==");
//计算规则 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 = "";
if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){
serial_signtype = Util.null2String(flowDeductCard.get(card_key));
if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){
serial = serial_signtype.split("_")[0];
signtype = serial_signtype.split("_")[1];
}
}
new BaseBean().writeLog("==zj4==");
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);
infoMap.put("repeatType", repeatType);
infoMap.put("repeatLate", repeatLate);
infoMap.put("repeatEarly", repeatEarly);
String key = resourceid+"|"+belongdate;
String keyRepeat = resourceid+"|"+belongdate+"|repeat";
new BaseBean().writeLog("==flowMaps=="+ JSON.toJSONString(flowMaps));
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");
if(repeatType.length() > 0){
//如果是哺乳假似的重复校验,不需要考虑时间
back_fromtime = fromtime;
back_totime = 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, -1);
}else{
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -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);
infoMap.put("repeatType", repeatType);
infoMap.put("repeatLate", repeatLate);
infoMap.put("repeatEarly", repeatEarly);
time_list_tmp.add(infoMap);
}
if(repeatType.length() > 0) {
if (flowMaps.containsKey(keyRepeat)) {
List<Map<String,String>> time_list_tmp1 = (List<Map<String,String>>)flowMaps.get(keyRepeat);
time_list_tmp1.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(repeatType.length() > 0){
//如果是哺乳假似的重复校验,不需要考虑时间
back_fromtime = fromtime;
back_totime = totime;
}
if(back_fromtime.equalsIgnoreCase(fromtime)){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -1);
}else{
if(back_fromtime.compareTo(back_totime) < 0){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -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);
infoMap.put("repeatType", repeatType);
infoMap.put("repeatLate", repeatLate);
infoMap.put("repeatEarly", repeatEarly);
time_list.add(infoMap);
}
flowMaps.put(key, time_list);
if(repeatType.length() > 0){
//单独存一份哺乳假的重复校验
flowMaps.put(keyRepeat, time_list);
}
}
}else{
new BaseBean().writeLog("==infoMap=="+JSON.toJSONString(infoMap));
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
if(repeatType.length() > 0){
//单独存一份哺乳假的重复校验
flowMaps.put(keyRepeat, time_list);
}
}
}
}
}
return splitBeans;
}
/**
*
*/
public List<SplitBean> getEvectionData(Map<String, Object> flowMaps,
Map<String, String> flowDeductCard){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.EVECTION.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String sqlWhere = sqlParamWhere();
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<>();
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 = "";
if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){
serial_signtype = Util.null2String(flowDeductCard.get(card_key));
if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){
serial = serial_signtype.split("_")[0];
signtype = serial_signtype.split("_")[1];
}
}
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("durationrule", durationrule);
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
infoMap.put("ishalf", "true");
}else{
infoMap.put("ishalf", "false");
}
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,
Map<String, String> flowDeductCard){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.OUT.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String sqlWhere = sqlParamWhere();
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<>();
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 = "";
if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){
serial_signtype = Util.null2String(flowDeductCard.get(card_key));
if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){
serial = serial_signtype.split("_")[0];
signtype = serial_signtype.split("_")[1];
}
}
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("durationrule", durationrule);
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
infoMap.put("ishalf", "true");
}else{
infoMap.put("ishalf", "false");
}
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;
}
/**
*
*/
public List<SplitBean> getOverTimeData(Map<String,Object> flowMaps){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
tablename += sqlWhere;
}
String leaveSql = "select * from ("+tablename+") t where 1=1 ";
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
if(orderby_sql.length() > 0){
leaveSql = leaveSql+orderby_sql;
}
rs.execute(leaveSql);
while(rs.next()){
SplitBean splitBean = new SplitBean();
String dataid= rs.getString("dataid");
String detailid= rs.getString("detailid");
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 changetype= rs.getString("changetype");
String d_mins= rs.getString("d_mins");
String overtime_type= rs.getString("overtime_type");
String fromdatedb= rs.getString("fromdatedb");
String fromtimedb= rs.getString("fromtimedb");
String todatedb= rs.getString("todatedb");
String totimedb= rs.getString("totimedb");
splitBean.setDataId(dataid);
splitBean.setDetailId(detailid);
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);
splitBean.setChangeType(Util.getIntValue(changetype));
splitBean.setD_Mins(Util.getDoubleValue(d_mins));
splitBean.setOvertime_type(overtime_type);
splitBean.setFromdatedb(fromdatedb);
splitBean.setFromtimedb(fromtimedb);
splitBean.setTodatedb(todatedb);
splitBean.setTotimedb(totimedb);
splitBeans.add(splitBean);
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
unitType = "2".equalsIgnoreCase(durationrule)?"1":"2";
Map<String,String> infoMap = new HashMap<>();
infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
infoMap.put("duration", duration);
infoMap.put("flowtype", FlowReportTypeEnum.OVERTIME.getFlowType());
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> getOtherData(Map<String,Object> flowMaps){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.OTHER.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
tablename += sqlWhere;
}
String leaveSql = "select * from ("+tablename+") t where 1=1 ";
if(sqlWhere.length() > 0){
leaveSql += 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);
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
Map<String,String> infoMap = new HashMap<>();
infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
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 ruleid
* @return true
*/
public static boolean leaveTypeUsed(String ruleid){
KQFlowDataBiz kqFlowDataBiz = new FlowDataParamBuilder().newLeaveTypeParam(ruleid).build();
List<SplitBean> splitBeans = kqFlowDataBiz.getLeaveData(null, new HashMap<>());
if(!splitBeans.isEmpty()){
return true;
}else{
return false;
}
}
/**
*
* @return
*/
private String sqlParamWhere() {
String sqlWhere = "";
if(resourceid.length() > 0){
sqlWhere += " and resourceid in ( "+resourceid+" )";
}
if(fromDate.length() > 0 && toDate.length() > 0){
sqlWhere += " and ( fromdate between '"+fromDate+"' and '"+toDate+"' or todate between '"+fromDate+"' and '"+toDate+"' )";
}else{
if(fromDate.length() > 0){
sqlWhere += " and fromdate between '"+fromDate+"' and '"+fromDate+"' ";
}
if(toDate.length() > 0){
sqlWhere += " and todate between '"+toDate+"' and '"+toDate+"' ";
}
}
if(belongDate.length() > 0){
sqlWhere += " and belongdate = '"+belongDate+"' ";
}
if(fromTime.length() > 0){
sqlWhere += " and fromtime >= '"+fromTime+"' ";
}
if(toTime.length() > 0){
sqlWhere += " and totime <= '"+toTime+"' ";
}
if(newLeaveType.length() > 0){
sqlWhere += " and newleavetype in ( "+newLeaveType+" )";
}
return sqlWhere;
}
private String sqlFlowCardParamWhere() {
String sqlWhere = "";
if(resourceid.length() > 0){
sqlWhere += " and resourceid in ( "+resourceid+" )";
}
if(fromDate.length() > 0 && toDate.length() > 0){
sqlWhere += " and ( fromdate between '"+fromDate+"' and '"+toDate+"' or todate between '"+fromDate+"' and '"+toDate+"' )";
}else{
if(fromDate.length() > 0){
sqlWhere += " and fromdate between '"+fromDate+"' and '"+fromDate+"' ";
}
if(toDate.length() > 0){
sqlWhere += " and todate between '"+toDate+"' and '"+toDate+"' ";
}
}
if(belongDate.length() > 0){
sqlWhere += " and belongdate = '"+belongDate+"' ";
}
if(fromTime.length() > 0){
sqlWhere += " and fromtime >= '"+fromTime+"' ";
}
if(toTime.length() > 0){
sqlWhere += " and totime <= '"+toTime+"' ";
}
return sqlWhere;
}
/**
* Builder
*/
public static class FlowDataParamBuilder {
private String resourceid = "";
private String fromDate = "";
private String toDate = "";
private String fromTime = "";
private String toTime = "";
private String belongDate = "";
/**
*
*/
private String newLeaveType = "";
private String orderby_sql = "";
public FlowDataParamBuilder() {
this.resourceid = "";
//初始化的时候需要把其他参数先清空下
this.fromDate = "";
this.toDate = "";
this.fromTime = "";
this.toTime = "";
this.newLeaveType = "";
this.belongDate = "";
this.orderby_sql = "";
}
//成员方法返回其自身,所以可以链式调用
public FlowDataParamBuilder resourceidParam(final String resourceid) {
this.resourceid = resourceid;
return this;
}
public FlowDataParamBuilder fromDateParam(final String fromDate) {
this.fromDate = fromDate;
return this;
}
public FlowDataParamBuilder toDateParam(final String toDate) {
this.toDate = toDate;
return this;
}
public FlowDataParamBuilder fromTimeParam(final String fromTime) {
this.fromTime = fromTime;
return this;
}
public FlowDataParamBuilder toTimeParam(final String toTime) {
this.toTime = toTime;
return this;
}
public FlowDataParamBuilder newLeaveTypeParam(final String newLeaveType) {
this.newLeaveType = newLeaveType;
return this;
}
public FlowDataParamBuilder belongDateParam(final String belongDate) {
this.belongDate = belongDate;
return this;
}
public FlowDataParamBuilder orderby_sqlParam(final String orderby_sql) {
this.orderby_sql = orderby_sql;
return this;
}
//Builder的build方法返回外部类的实例
public KQFlowDataBiz build() {
return new KQFlowDataBiz(this);
}
}
}