diff --git a/src/com/customization/sskj/GetTabsCmdInter.java b/src/com/customization/sskj/GetTabsCmdInter.java new file mode 100644 index 0000000..67066af --- /dev/null +++ b/src/com/customization/sskj/GetTabsCmdInter.java @@ -0,0 +1,56 @@ +package com.customization.sskj; + +import com.customization.sskj.util.JobGroupUtil; +import com.engine.core.cfg.annotation.CommandDynamicProxy; +import com.engine.core.interceptor.AbstractCommandProxy; +import com.engine.core.interceptor.Command; +import com.engine.hrm.cmd.jobset.AddJobGroupCmd; +import com.engine.kq.cmd.reportdetial.GetTabsCmd; +import org.apache.commons.lang.StringUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 事假明细扩展tab + */ +@CommandDynamicProxy(target = GetTabsCmd.class, desc = "GetTabsCmd") +public class GetTabsCmdInter extends AbstractCommandProxy> { + + BaseBean basebean = new BaseBean(); + @Override + public Map execute(Command> command) { + + GetTabsCmd cmd = (GetTabsCmd) command; + User user = cmd.getUser(); + Map params = cmd.getParams(); + Map result = nextExecute(cmd); + + try { + String calLeaveId = basebean.getPropValue("project_sskj", "calLeaveId"); + String type = Util.null2String(params.get("type")); + if (("leaveType_"+calLeaveId).equals(type)) { + String status = Util.null2String(result.get("status")); + if ( status.equals("1")) { + Object tabsObj = result.get("tabs"); + if (tabsObj !=null & tabsObj != "") { + List> tabs = (List>) tabsObj; + Map temp = new HashMap<>(); + temp.put("key","3"); + temp.put("title", SystemEnv.getHtmlLabelName(10000,user.getLanguage())); + tabs.add(temp); + } + } + } + }catch (Exception e) { + basebean.writeLog("GetTabsCmdInter Exception: " + e); + } + + return result; + } +} diff --git a/src/com/engine/kq/biz/KQAttFlowSetBiz.java b/src/com/engine/kq/biz/KQAttFlowSetBiz.java new file mode 100644 index 0000000..9c551a7 --- /dev/null +++ b/src/com/engine/kq/biz/KQAttFlowSetBiz.java @@ -0,0 +1,1167 @@ +package com.engine.kq.biz; + +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.enums.OverTimeComputingModeEnum; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 考勤流程 设置类 + */ +public class KQAttFlowSetBiz { + + private KQLog kqLog = new KQLog(); + + BaseBean bb = new BaseBean(); + + public String getFieldInfo(Map attSetMap){ + String unionSql = ""; + if(attSetMap.isEmpty()){ + return ""; + } + String[][] fieldsRefect = KQAttFlowFieldsSetBiz.fieldsRefect; + String[] leavebackMainFields = KQAttFlowFieldsSetBiz.leavebackMainFields; + String[] cardMainFields = KQAttFlowFieldsSetBiz.cardMainFields; + String[] processchangeMainFields = KQAttFlowFieldsSetBiz.processchangeMainFields; + + String prefiex = "detail_"; + String mainPrefix = "a"; + String detailPrefix = "b"; + String allPrefix = "c"; + + String attId = Util.null2String(attSetMap.get("attId")); + int kqtype = Util.getIntValue(Util.null2String(attSetMap.get("kqtype")),0); + String usedetail = Util.null2String(attSetMap.get("usedetail")); + String tablename = Util.null2String(attSetMap.get("tablename")); + tablename = tablename+" "+mainPrefix; + String detailtablename = Util.null2String(attSetMap.get("detailtablename")); + detailtablename = detailtablename+" "+detailPrefix; + + String custome_sql = Util.null2String(attSetMap.get("custome_sql")); + + if(attId.length() > 0){ + String backfields = ""; + Map fieldidMap = new HashMap<>(); + Map fieldnameMap = new HashMap<>(); + Map backfieldMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String dbtype = rs.getDBType(); + String sql = "select a.field003 fieldid,a.field004 fieldname,b.field002 wffieldname from kq_att_proc_relation a left join kq_att_proc_fields b on a.field002=b.id where a.field001 = ? "; + rs.executeQuery(sql, attId); + while(rs.next()){ + String fieldid = Util.null2String(rs.getString("fieldid")); + String fieldname = Util.null2String(rs.getString("fieldname")); + String wffieldname = Util.null2String(rs.getString("wffieldname")); + if(Util.getIntValue(fieldid,0) <= 0){ + kqLog.info("getFieldInfo:考勤流程字段对应有误 :fieldid is null: :attId:"+attId); + break; + } + if("1".equalsIgnoreCase(usedetail)){ + if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype || KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() == kqtype + || KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype() == kqtype){ + }else{ + if(wffieldname.indexOf(prefiex) > -1){ + wffieldname = wffieldname.substring(prefiex.length()); + }else{ + kqLog.info("getFieldInfo:考勤流程字段对应有误 :usedetail wffieldname is error: :attId:"+attId); +// break; + } + } + } + String backfield = ""; + fieldidMap.put(wffieldname, fieldid); + fieldnameMap.put(wffieldname, fieldname); + if(KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() == kqtype){ + if(Arrays.asList(leavebackMainFields).contains(wffieldname)){ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + }else if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype){ + if(Arrays.asList(cardMainFields).contains(wffieldname)){ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + }else{ + if("detail_signtype".equalsIgnoreCase(wffieldname)){ + if("mysql".equalsIgnoreCase(dbtype)){ + backfield = "CAST("+detailPrefix+"."+fieldname +" as SIGNED) as "+wffieldname; + }else { + backfield = "cast("+detailPrefix+"."+fieldname +" as int) as "+wffieldname; + } + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + } + }else if(KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype() == kqtype){ + if(Arrays.asList(processchangeMainFields).contains(wffieldname)){ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + }else{ + if("1".equalsIgnoreCase(usedetail)){ + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == kqtype && "companion".equalsIgnoreCase(wffieldname)){ + if("oracle".equalsIgnoreCase(dbtype)||"postgresql".equalsIgnoreCase(dbtype)){ + backfield = "to_char("+detailPrefix+"."+fieldname +") as "+wffieldname; + }else if("mysql".equalsIgnoreCase(dbtype)){ + backfield = "CONVERT("+detailPrefix+"."+fieldname +", char ) as "+wffieldname; + }else { + backfield = "cast("+detailPrefix+"."+fieldname +" as varchar(max) ) as "+wffieldname; + } + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + }else{ + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == kqtype && "companion".equalsIgnoreCase(wffieldname)){ + if("oracle".equalsIgnoreCase(dbtype)||"postgresql".equalsIgnoreCase(dbtype)){ + backfield = "to_char("+mainPrefix+"."+fieldname +") as "+wffieldname; + }else if("mysql".equalsIgnoreCase(dbtype)){ + backfield = "CONVERT("+mainPrefix+"."+fieldname +", char ) as "+wffieldname; + }else { + backfield = "cast("+mainPrefix+"."+fieldname +" as varchar(max) ) as "+wffieldname; + } + }else{ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + } + } + } + if(!"".equalsIgnoreCase(wffieldname)){ + backfieldMap.put(wffieldname, backfield); + } + } + if(backfieldMap.isEmpty()){ + kqLog.info("getFieldInfo:考勤流程表字段对应為空 :attId:"+attId+":kqtype:"+kqtype); + return ""; + } + //TODO 这里需要改 + boolean isReflect = true; + String[] fieldsType = fieldsRefect[kqtype]; + for(int i = 0 ;i < fieldsType.length ;i++){ + String backfield = Util.null2String(backfieldMap.get(fieldsType[i])); + if(backfield.length() > 0){ + backfields += ","+backfieldMap.get(fieldsType[i]); + }else{ + kqLog.info("getFieldInfo:考勤流程表字段对应未找到 :attId:"+attId+":kqtype:"+kqtype+":fieldsType[i]:"+fieldsType[i]); + if(fieldsType[i].indexOf("duration") > -1){ + backfields += ", 0 as "+fieldsType[i]; + }else{ + backfields += ", '' as "+fieldsType[i]; + } + } + } + if(backfields.length() > 0){ + backfields = backfields.substring(1); + backfields += ","+mainPrefix+".requestid "; + } + if(KqSplitFlowTypeEnum.SHIFT.getFlowtype() == kqtype || KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() == kqtype + || KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype || KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype() == kqtype){ + if(KqSplitFlowTypeEnum.SHIFT.getFlowtype() == kqtype){ + unionSql = "select "+backfields+" from "+detailtablename; + }else{ + unionSql = "select "+backfields+" from "+tablename+" left join "+detailtablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" ; + if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype){ + unionSql = "select "+allPrefix+".* from ("+ "select "+backfields+" from "+tablename+" left join "+detailtablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" +") "+allPrefix+" where ("+custome_sql+")"; + } + } + }else{ + if("1".equalsIgnoreCase(usedetail)){ + unionSql = "select "+backfields+" from "+detailtablename+" left join "+tablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" ; + }else{ + unionSql = "select "+backfields+" from "+tablename; + } + } + } + return unionSql; + } + + /** + * + * @param kqtype + * @param user + * @param isMyKQ 是否来自我的考勤 + * @param params + * @return + */ + public String getFieldInfoByKQType(String kqtype, User user, String isMyKQ, + Map params){ + String workflowid =Util.null2String(params.get("workflowid")); + String custome_sql =Util.null2String(params.get("custome_sql")); + RecordSet rs = new RecordSet(); + List formids = new ArrayList<>(); + String unionSqls = ""; + String sql = "select * from kq_att_proc_set where field006= ?"; + if(workflowid.length() > 0 && Util.getIntValue(workflowid) > 0){ + sql += " and field001 = ? "; + rs.executeQuery(sql,kqtype,workflowid); + }else{ + rs.executeQuery(sql,kqtype); + } + while(rs.next()){ + Map attSetMap = new HashMap<>(); + String formid = Util.null2s(rs.getString("field002"),""); + String field005 = Util.null2s(rs.getString("field005"),""); + if(field005.equals("0")){ + continue; + } + //TODO 这里需要改 如果一个表单被多个表单使用的情况 +// if(formid.length() == 0){ +// continue; +// } +// if(formids.contains(formid)){ +// continue; +// }else{ +// formids.add(formid); +// } + String attId = Util.null2String(rs.getString("id")); + String usedetail = Util.null2String(rs.getString("usedetail")); + String tablename = Util.null2String(rs.getString("tablename")); + String detailtablename = Util.null2String(rs.getString("detailtablename")); + attSetMap.put("attId", attId); + attSetMap.put("kqtype", kqtype); + attSetMap.put("usedetail", usedetail); + attSetMap.put("tablename", tablename); + attSetMap.put("detailtablename", detailtablename); + attSetMap.put("custome_sql", custome_sql); + if("1".equalsIgnoreCase(usedetail)){ + if("".equalsIgnoreCase(detailtablename)){ + kqLog.info("getFieldInfoByKQType:考勤流程明细表单不存在 :attId:"+attId+":kqtype:"+kqtype); + continue; + } + }else { + if("".equalsIgnoreCase(tablename)){ + kqLog.info("getFieldInfoByKQType:考勤流程主表表单不存在 :attId:"+attId+":kqtype:"+kqtype); + continue; + } + } + String fieldSql = getFieldInfo(attSetMap); + + if(fieldSql.length() > 0){ + if(unionSqls.length() > 0){ + unionSqls += " union all "+ fieldSql; + }else{ + unionSqls += fieldSql; + } + } + } + + if(unionSqls.length() > 0){ + + String unionsql = ""; + if("1".equalsIgnoreCase(isMyKQ)){ + String hrmSql = " select * from hrmresource a where 1=1 "; + unionSqls = " select distinct u.*,w.currentnodetype,w.status as flowstatus,w.workflowid ,w.requestid as req_requestid,w.requestname,a.managerid,a.managerstr,a.loginid,a.subcompanyid1 as asubcompanyid1,a.departmentid as adepartmentid,a.lastname from (" +unionSqls+") u left join Workflow_Requestbase w on u.requestid = w.requestid left join ("+hrmSql+") a on u.resourceid = a.id "; + }else{ + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + String hrmSql = " select * from hrmresource a where 1=1 "+rightSql; + unionSqls = " select distinct u.*,w.currentnodetype,w.status as flowstatus,w.workflowid ,w.requestid as req_requestid,w.requestname,a.managerid,a.managerstr,a.loginid,a.subcompanyid1 as asubcompanyid1,a.departmentid as adepartmentid,a.lastname from (" +unionSqls+") u left join Workflow_Requestbase w on u.requestid = w.requestid left join ("+hrmSql+") a on u.resourceid = a.id "; + } + + } + return unionSqls; + } + + /** + * 拼接流程查询sql + * @param params + * @return + */ + public Map getFLowSql(Map params, User user){ + RecordSet rs = new RecordSet(); + Map sqlMap = new HashMap<>(); + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + String not_start_node = Util.null2String(params.get("not_start_node")); + String not_requestId =Util.null2String(params.get("not_requestId")); + String custome_sql =Util.null2String(params.get("custome_sql")); + String workflowid =Util.null2String(params.get("workflowid")); + + String fromSql = " "; + //req_requestid 表示只显示Workflow_Requestbase里有的数据 + String sqlWhere = " where 1=1 and req_requestid > 0 "; + + if(typeselect.length()==0){ + typeselect = "3"; + } + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + //不区分归档不归档 查所有 + boolean isAll = false; + if("3".equalsIgnoreCase(tabkey)){ + isAll = true; + } + if(kqtype > -1){ + if(isFinished){ + fromSql = getFinishedByKQType(""+kqtype,fromDate,toDate,user,isMyKQ); + }else { + fromSql = getFieldInfoByKQType(""+kqtype,user,isMyKQ,params); + } + } + if(fromSql.length() == 0){ + return sqlMap; + }else{ + fromSql = "from ("+fromSql+") f "; + } + + if(kqtype == 0){ + String newleavetype = Util.null2String(params.get("newleavetype")); + if(newleavetype.length() > 0){ + sqlWhere += " and newleavetype= "+newleavetype; + } + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and asubcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and adepartmentid in("+departmentId+") "; + } + + if(requestId.length() > 0){ + sqlWhere += " and requestId ="+requestId+""; + } + + if(not_requestId.length() > 0){ + sqlWhere += " and requestId not in("+not_requestId+")"; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(rs.getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + if(!isFinished){ + if (fromDate.length() > 0 && toDate.length() > 0){ + sqlWhere += " and ( fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate) "; + } + } + + if(isFinished){ + sqlWhere += " and (currentnodetype = '3') "; + }else{ + if(!isAll){ + sqlWhere += " and (currentnodetype is null or currentnodetype != '3') "; + } + } + if("1".equalsIgnoreCase(not_start_node)){ + sqlWhere += " and (currentnodetype != '0') "; + } + if(workflowid.length() > 0){ + sqlWhere += " and workflowid= "+workflowid; + } + if(custome_sql.length() > 0){ + sqlWhere += " and ("+custome_sql+") "; + } + if("1".equalsIgnoreCase(isMyKQ)){ + }else{ + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + String hrmSql = " select id from hrmresource a where 1=1 "+rightSql; + sqlWhere += " and resourceId in("+hrmSql+")"; + } + kqLog.info("buildFlowSetTableString"+kqtype+":流程明细sql输出下:fromSql:"+fromSql); + kqLog.info("buildFlowSetTableString"+kqtype+":流程明细sql输出下:sqlWhere:"+sqlWhere); + sqlMap.put("from", fromSql); + sqlMap.put("where", sqlWhere); + return sqlMap; + } + + + /** + * 获取归档后的考勤流程数据 + * @param kqtype + * @param fromDate + * @param toDate + * @param user + * @param isMyKQ 是否来自我的考勤 + * @return + */ + private String getFinishedByKQType(String kqtype, String fromDate, String toDate, User user, + String isMyKQ) { + boolean isLeave = false; + boolean isEvection = false; + boolean isOut = false; + String tableName = ""; + String fields = " distinct requestid,resourceid as resourceId,subcompanyid,departmentid,newleavetype,fromdatedb as fromDate,fromtimedb as fromTime,todatedb as toDate,totimedb as toTime,durationdb,durationrule,SUM(duration) as duration "; + switch (kqtype){ + case "0": + isLeave= true; + tableName = KqSplitFlowTypeEnum.LEAVE.getTablename(); + break; + case "1": + isEvection= true; + tableName = KqSplitFlowTypeEnum.EVECTION.getTablename(); + break; + case "2": + isOut= true; + tableName = KqSplitFlowTypeEnum.OUT.getTablename(); + break; + case "3": + tableName = KqSplitFlowTypeEnum.OVERTIME.getTablename(); + break; + default: + break; + } + if(tableName.length() == 0){ + kqLog.info("getFinishedByKQType:获取归档的考勤流程出问题了:kqtype:"+kqtype); + return ""; + } + if(isLeave){ + String back_table_name= KqSplitFlowTypeEnum.LEAVEBACK.getTablename(); + String table_name= KqSplitFlowTypeEnum.LEAVE.getTablename(); + String backSql = "select sum(duration) from "+back_table_name+" where "+back_table_name+".leavebackrequestid="+table_name+".requestid and "+back_table_name+".newleavetype="+table_name+".newleavetype and "+back_table_name+".resourceid="+table_name+".resourceid "; + if(fromDate.length() > 0 && toDate.length() > 0){ + if("1".equalsIgnoreCase(isMyKQ)){ + backSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + }else{ + backSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + } + + } + fields = " distinct requestid,resourceid as resourceId,subcompanyid,departmentid,newleavetype,fromdatedb as fromDate,fromtimedb as fromTime,todatedb as toDate,totimedb as toTime,durationdb,durationrule,SUM(duration) as duration," + + "("+backSql+") as backduraion "; + } + + String baseSql = " select "+fields+" from "+tableName+" where tablenamedb is not null and (status is null or status != 1) "; + if(fromDate.length() > 0 && toDate.length() > 0){ + if("1".equalsIgnoreCase(isMyKQ)){ + baseSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + }else{ + baseSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + } + } + baseSql += " GROUP BY requestid,resourceid,subcompanyid,departmentid,newleavetype,fromdatedb,fromtimedb,todatedb,totimedb,durationdb,durationrule "; + + String unionsql = " select u.*,w.currentnodetype,w.requestname,w.requestid as req_requestid,w.status as flowstatus,w.workflowid,a.managerid,a.managerstr,a.loginid,a.subcompanyid1 as asubcompanyid1,a.departmentid as adepartmentid,a.lastname from ("+baseSql+") u left join Workflow_Requestbase w on u.requestid = w.requestid left join hrmresource a on u.resourceid = a.id "; + return unionsql; + } + + /** + * 考勤报表明细 + * @param params + * @param user + * @return + */ + public String buildFlowSetTableString(Map params, User user){ + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String isMyKQ = Util.null2String(params.get("isMyKQ")); + if(!"1".equalsIgnoreCase(isMyKQ)){ + if(kqtype == 3){ + String tabkey = Util.null2String(params.get("tabKey")); + //加班的单独走一个列表显示 + if(OverTimeComputingModeEnum.FLOW.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeFlow(params,user); + }else if(OverTimeComputingModeEnum.FLOW2CARD.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeFlow2Card(params,user); + }else if(OverTimeComputingModeEnum.CARD.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeCard(params,user); + }else if(OverTimeComputingModeEnum.FLOWINCARD.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeFlowInCard(params,user); + } + } + } + + String backfields = " * "; + String fromSql = ""; + String sqlWhere = ""; + String tableString = ""; + String tabletype="none"; + String orderby = ""; + boolean isFinished = false; + String tabkey = Util.null2String(params.get("tabKey")); + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + String typeselect =Util.null2String(params.get("typeselect")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + + //在这里生成sql语句 + Map sqlMap = getFLowSql(params,user); + if(sqlMap.isEmpty()){ + //给个默认表 比如请假表,因为表结构都是一样的 + String tableName = KqSplitFlowTypeEnum.LEAVE.getTablename(); + fromSql = tableName; + sqlWhere = " where 1=2 "; + }else{ + fromSql = Util.null2String(sqlMap.get("from")); + sqlWhere = Util.null2String(sqlMap.get("where")); + } + + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"+column:newLeaveType"; + if(isFinished){ + fromTimePram = kqtype+"+0+"+user.getLanguage()+"+column:newLeaveType"+"+column:durationrule"; + } + String toTimePram = kqtype+"+1+"+user.getLanguage()+"+column:newLeaveType"; + if(isFinished){ + toTimePram = kqtype+"+1+"+user.getLanguage()+"+column:newLeaveType"+"+column:durationrule"; + } + + String otherPram = kqtype+"+column:durationrule+"+user.getLanguage(); + if(kqtype == 0){ + otherPram +="+column:newLeaveType+column:requestid+column:backduraion"; + } + + int languageId = user.getLanguage(); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = "cb9b9b02-a34c-4468-b871-08167bcaeb6c"; + + bb.writeLog("buildFlowSetTableString backfields: " + backfields); + bb.writeLog("buildFlowSetTableString fromSql: " + fromSql); + bb.writeLog("buildFlowSetTableString sqlwhere: " + sqlWhere); + bb.writeLog("buildFlowSetTableString orderby: " + orderby); + + tableString =" "+ +// " "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += " "; + if(kqtype == 0){ + tableString += " "; + } + tableString += " "; + if(isFinished){ + tableString += " "; + } + tableString +=" "+ + "
"; + + /*考勤二开--转事假start*/ + String calLeaveId = bb.getPropValue("project_sskj", "calLeaveId"); + bb.writeLog("buildFlowSetTableString calLeaveId: " + calLeaveId); + + String type = Util.null2String(params.get("type")); + bb.writeLog("buildFlowSetTableString type: " + type); + + String resourceId =Util.null2String(params.get("resourceId")); + bb.writeLog("buildFlowSetTableString resourceId: " + resourceId); + + if ( ("leaveType_"+calLeaveId).equals(type) && "3".equals(tabkey)) { + backfields = " a.resourceid, a.startdate, a.starttime, a.enddate, a.endtime, a.duration, b.lastname, b.departmentId "; + fromSql = " from uf_casleave a " + + " left join hrmresource b " + + " on b.id = a.resourceid "; + sqlWhere = " where a.resourceid = " + resourceId + " and a.startdate >='" + fromDate + "' and a.startdate <='" + toDate + "' and a.isdecu = 0"; + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + + } + bb.writeLog("-buildFlowSetTableString backfields: " + backfields); + bb.writeLog("-buildFlowSetTableString fromSql: " + fromSql); + bb.writeLog("-buildFlowSetTableString sqlwhere: " + sqlWhere); + bb.writeLog("-buildFlowSetTableString orderby: " + orderby); + /*考勤二开--转事假end*/ + + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + + /** + * 流程 生成加班明细 + * @param params + * @param user + * @return + */ + public String buildTableString4OvertimeFlow(Map params, User user){ + String dbType = new RecordSet().getDBType(); + String orgindbtype = new RecordSet().getOrgindbtype(); + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + if(typeselect.length()==0){ + typeselect = "3"; + } + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + + String overtimeTable = ""; + + if("oracle".equalsIgnoreCase(dbType)){ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,to_char(sum(duration_min)) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + if("jc".equalsIgnoreCase(orgindbtype)){ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,to_char(sum(cast(duration_min as NUMERIC))) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + } + }else if("postgresql".equalsIgnoreCase(dbType)){ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,sum(cast(duration_min as NUMERIC)) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + }else if("mysql".equalsIgnoreCase(dbType)) { + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,CONVERT (sum(duration_min), CHAR ) duration_min from kq_flow_overtime where computingmode=1 " + (belongdateWhere.length() == 0 ? "" : belongdateWhere) + " group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + }else{ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,convert(varchar,sum(cast(duration_min as NUMERIC))) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + } + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + kqLog.info(">>>>>>source:"+source+">>>>>resourceId:"+resourceId); + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + +// if (fromDate.length() > 0 && toDate.length() > 0){ +// sqlWhere += " 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 otherPram = user.getLanguage()+""; + + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"++column:durationrule"; + String toTimePram = kqtype+"+1+"+user.getLanguage()+"++column:durationrule"; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_Flow"); + String sql = "backfields>>>>"+backfields+">>>fromSql>>>"+fromSql+">>>sqlWhere>>>"+sqlWhere; + new BaseBean().writeLog("sql>>>>>>>>>"+sql); + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + /** + * 打卡+流程 生成加班明细 + * @param params + * @param user + */ + private String buildTableString4OvertimeFlow2Card(Map params, User user) { + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + if(typeselect.length()==0){ + typeselect = "3"; + } + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min,durationrule from kq_flow_overtime where computingmode = 2 "+(belongdateWhere.length() == 0 ? "" :belongdateWhere); + + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + + kqLog.info("buildTableString4OvertimeFlow2Card>>>>>>backfields:"+backfields+">>>>>fromSql:"+fromSql + +">>>>>sqlWhere:"+sqlWhere); + String otherPram = user.getLanguage()+""; + String timePram = "column:fromtimedb+column:todatedb+column:totimedb"; + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"++column:durationrule"; + String toTimePram = kqtype+"+1+"+user.getLanguage()+"++column:durationrule"; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_Flow2Card"); + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + /** + * 打卡 生成加班明细 + * @param params + * @param user + */ + private String buildTableString4OvertimeCard(Map params, User user) { + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + if(typeselect.length()==0){ + typeselect = "3"; + } + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,computingmode,paidLeaveEnable,expiringdate,duration_min from kq_flow_overtime where computingmode = 3 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere); + + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + kqLog.info(">>>>>>source:"+source+">>>>>resourceId:"+resourceId); + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + +// if (fromDate.length() > 0 && toDate.length() > 0){ +// sqlWhere += " 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 otherPram = user.getLanguage()+""; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_Card"); + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + /** + * 打卡+流程 取交集 生成加班明细 + * @param params + * @param user + */ + private String buildTableString4OvertimeFlowInCard(Map params, User user) { + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + if(typeselect.length()==0){ + typeselect = "3"; + } + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min,durationrule from kq_flow_overtime where computingmode = 4 "+(belongdateWhere.length() == 0 ? "" :belongdateWhere); + + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + + kqLog.info("KQ_OvertimeTotal_Detail_FlowInCard>>>>>>backfields:"+backfields+">>>>>fromSql:"+fromSql + +">>>>>sqlWhere:"+sqlWhere); + String otherPram = user.getLanguage()+""; + String timePram = "column:fromtime+column:todate+column:totime"; + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"++column:durationrule"; + String toTimePram = kqtype+"+1+"+user.getLanguage()+"++column:durationrule"; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_FlowInCard"); + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } +} diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java index a9f9052..5464f78 100644 --- a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -392,6 +392,9 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand casMap = new HashMap<>(); - rs.executeQuery(acqCasData); + rs.executeQuery(acqCasData, resourceId, kqDate.substring(0,7)); while ( rs.next()) { double qjsc = Util.getDoubleValue(Util.null2String(rs.getString("qjsc"))); String qjbid = Util.null2String(rs.getString("qjbid")); @@ -124,7 +167,24 @@ public class SskjUtil { } if (casMap != null && casMap.size() > 0) { String modCasSql = "update " + handleTabel + " set qjsc = ?, sfdk = ?, dklcid = ? where qjbid = ?"; + basebean.writeLog("modCasSql: " + modCasSql); + String modLeaveSql = "update uf_casleave set duration = ?, isdecu = ?, decuflowid = ? where id = ?"; + basebean.writeLog("modLeaveSql: " + modLeaveSql); + + String backField = ""; + if (changeType == 1) { + backField = "jrjbdkzsj"; + } else if (changeType == 2) { + backField = "psjbdkzsj"; + } else if (changeType == 3) { + backField = "zmjbdkzsj"; + } + basebean.writeLog("backField: " + backField); + + String modDecuSql = "update "+ split[0] +" set " + backField + " = ? where xm = ? and ny = ?"; + basebean.writeLog("modDecuSql: " + modDecuSql); + List modCasList = new ArrayList<>(); List tempList = new ArrayList(); for (String key : casMap.keySet()) { @@ -136,22 +196,31 @@ public class SskjUtil { tempList.add(key); tempList.add(requestid); modCasList.add(tempList); + tempDecu = tempDecu + qjsc; } else { tempList.add(Math.abs(temp)); tempList.add(0); tempList.add(key); tempList.add(requestid); modCasList.add(tempList); + tempDecu = tempDecu + duration; } } + basebean.writeLog("modCasList: " + modCasList); + basebean.writeLog("tempDecu: " + tempDecu); + if (modCasList != null && modCasList.size() > 0) { //修改转事假建模台账 - rs.executeBatchSql(modLeaveSql, modCasList); + boolean b = rs.executeBatchSql(modLeaveSql, modCasList); + basebean.writeLog("b: " + b); //修改转事假建模台账 - rs.executeBatchSql(modCasSql, modCasList); + boolean b1 = rs.executeBatchSql(modCasSql, modCasList); + basebean.writeLog("b1: " + b1); + //修改加班抵扣转事假 + boolean b2 = rs.executeUpdate(modDecuSql, tempDecu, resourceId, kqDate.substring(0, 7)); + basebean.writeLog("b2: " + b2); } - } return true; diff --git a/src/weaver/interfaces/sskj/job/DeductTrainTimesJob.java b/src/weaver/interfaces/sskj/job/DeductTrainTimesJob.java index 9a59e14..33c0c67 100644 --- a/src/weaver/interfaces/sskj/job/DeductTrainTimesJob.java +++ b/src/weaver/interfaces/sskj/job/DeductTrainTimesJob.java @@ -116,7 +116,7 @@ public class DeductTrainTimesJob extends BaseCronJob { SskjUtil sskjUtil = new SskjUtil(); String tableName = sskjUtil.getTableName(xm, pxsj); if (StringUtils.isNotBlank(tableName)) { - String acqOverTimeSql = "select count(*) as number from " + tableName + " where jbry = ? and belongdate = ? and kssj <='" + kssj + "' " + + String acqOverTimeSql = "select mainid from " + tableName + " where jbry = ? and lcgzrq = '"+pxsj+"' and kssj <='" + kssj + "' " + " and jssj >='" + jssj + "' "; String[] split = tableName.split("_dt"); String addTraNa = ""; @@ -127,23 +127,23 @@ public class DeductTrainTimesJob extends BaseCronJob { addLeaNa = split[0] + "_dt6"; addOverNa = split[0]; } - String addTrainSql = "insert into " + addTraNa + " (pxry, pxrq, kssj, jssj, pxsc) values (?,?,?,?,?)"; - String addLeaSql = "insert into " + addLeaNa + " (qjry, qjlx, qjrq, kssj, jssj, sfdk, qjbid, qjsc) values (?,?,?,?,?,?,?,?)"; - String acqOverSql = "select jbzsy from " + addOverNa + " where xm = ? and ny = ? "; - String addCaslLeaSql = "insert into uf_casleave (resourceid, kqdate, starttime, endtime, duration, isdecu, formmodeid, modedatacreater, modedatacreatertype, " + - " modedatacreatedate, modedatacreatetime, MODEUUID) values (?,?,?,?,?,?,?,?,?,?,?,?)"; + String addTrainSql = "insert into " + addTraNa + " (mainid, pxry, pxrq, kssj, jssj, pxsc) values (?,?,?,?,?,?)"; + String addLeaSql = "insert into " + addLeaNa + " (mainid, qjry, qjlx, qjrq, kssj, jssj, sfdk, qjbid, qjsc) values (?,?,?,?,?,?,?,?,?)"; + String acqOverSql = "select id, jbzsy from " + addOverNa + " where xm = ? and ny = '" + pxsj.substring(0, 7) + "'"; + String addCaslLeaSql = "insert into uf_casleave (resourceid, startdate, starttime, enddate, endtime, duration, isdecu, formmodeid, modedatacreater, modedatacreatertype, " + + " modedatacreatedate, modedatacreatetime, MODEUUID) values (?,?,?,?,?,?,?,?,?,?,?,?,?)"; String acqCasLeaveSql = "select id from kq_flow_split_leave where casleaveuuid = ?"; String acqModeIdSql = "select id from uf_casleave where MODEUUID = ?"; String modTrainSql = "update " + addOverNa + " set pxzsc = (select sum(pxsc) from " + addTraNa + " as dt_table where " + " dt_table.mainid = " + addOverNa + ".id ) where xm = ? and ny = ? "; String modOverSql = "update " + addOverNa + " set jbzsy = (psjbsy + zmjbsy + jrjbsy - pxzsc) where xm = ? and ny = ? "; - rs.executeQuery(acqOverTimeSql, xm, pxsj); + rs.executeQuery(acqOverTimeSql, xm); while (rs.next()) { - int number = Util.getIntValue(Util.null2String(rs.getString("number"))); - if (number > 0) { + int billid = Util.getIntValue(Util.null2String(rs.getString("mainid"))); + if (billid > 0) { //插入一条培训记录 - boolean b = rs2.executeUpdate(addTrainSql, xm, pxsj, kssj, jssj, ksh); + boolean b = rs2.executeUpdate(addTrainSql, billid, xm, pxsj, kssj, jssj, ksh); //重新计算主表培训总时长 if (b) { boolean b1 = rs2.executeUpdate(modTrainSql, xm, pxsj.substring(0, 7)); @@ -157,18 +157,23 @@ public class DeductTrainTimesJob extends BaseCronJob { } } //根据目前加班剩余时长来判断是否需要插入一条事假的数据 - rs2.executeQuery(acqOverSql, xm, pxsj.substring(0, 7)); + rs2.executeQuery(acqOverSql, xm); while (rs2.next()) { - double jbzsy = Util.getDoubleValue(Util.null2String(rs.getString("jbzsy"))); + int id = Util.getIntValue(Util.null2String(rs2.getString("id"))); + double jbzsy = Util.getDoubleValue(Util.null2String(rs2.getString("jbzsy"))); + + if (jbzsy<0.00) { + jbzsy = 0.00; + } double temp = ksh - jbzsy; - if (temp > 0) { + if (temp > 0 ) { Integer casleaveId = -1; //生成一条事假数据 String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd"); String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss"); String uuid = UUID.randomUUID().toString(); - boolean addFlag = rs.executeUpdate(addCaslLeaSql, xm, pxsj, kssj, jssj, ksh, 0, casLeaveModeId, 1, 0, modedatacreatedate, - uuid, modedatacreatetime); + boolean addFlag = rs.executeUpdate(addCaslLeaSql, xm, pxsj, kssj, pxsj, jssj, ksh, 0, casLeaveModeId, 1, 0, modedatacreatedate, modedatacreatetime, + uuid ); bb.writeLog("addFlag:" + addFlag); if (addFlag) { String billid = "-1"; @@ -179,9 +184,9 @@ public class DeductTrainTimesJob extends BaseCronJob { bb.writeLog("billid:" + billid); sskjUtil.modePerRecon(1, casLeaveModeId, billid); //记录事假台账 - rs.executeUpdate(addLeaSql, xm, calLeaveTypeId, pxsj, kssj, jssj, 0, casleaveId, temp); - } + boolean b = rs.executeUpdate(addLeaSql, id, xm, calLeaveTypeId, pxsj, kssj, jssj, 0, casleaveId, temp); + } } } }