344 lines
14 KiB
Java
344 lines
14 KiB
Java
package com.api.kq.browser.service.impl;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.api.browser.bean.ListHeadBean;
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
import com.api.browser.bean.SearchConditionOption;
|
|
import com.api.browser.bean.SplitTableBean;
|
|
import com.api.browser.bean.SplitTableColBean;
|
|
import com.api.browser.service.BrowserService;
|
|
import com.api.browser.util.BoolAttr;
|
|
import com.api.browser.util.BrowserConstant;
|
|
import com.api.browser.util.BrowserDataType;
|
|
import com.api.browser.util.ConditionFactory;
|
|
import com.api.browser.util.ConditionType;
|
|
import com.api.browser.util.SplitTableUtil;
|
|
import com.api.browser.util.SqlUtils;
|
|
import com.engine.kq.biz.KQGroupMemberComInfo;
|
|
import com.engine.kq.log.KQLog;
|
|
import com.engine.kq.util.TransMethod;
|
|
import weaver.common.DateUtil;
|
|
import weaver.conn.RecordSet;
|
|
import weaver.general.Util;
|
|
import weaver.hrm.moduledetach.ManageDetachComInfo;
|
|
import weaver.systeminfo.SystemEnv;
|
|
import weaver.systeminfo.systemright.CheckSubCompanyRight;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 考勤组浏览按钮
|
|
* type : KQGroup
|
|
*/
|
|
public class KQGroupBrowserService extends BrowserService {
|
|
|
|
private KQLog kqLog = new KQLog();
|
|
|
|
@Override
|
|
public Map<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
|
|
String advance = Util.null2String(params.get("advance"));
|
|
if("".equals(advance) || "0".equals(advance))
|
|
return getBasicData(params);
|
|
return getAdvanceData(params);
|
|
}
|
|
|
|
private Map<String, Object> getBasicData(Map<String, Object> params) throws Exception {
|
|
kqLog.info("params:::::::::::"+ JSON.toJSONString(params));
|
|
|
|
CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
|
|
ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
|
|
boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
boolean isBindGroup = "1".equals(Util.null2String(params.get("isBindGroup"))); // 0:未绑定考勤组; 1:绑定了考勤组
|
|
|
|
String groupname = Util.null2String(params.get("groupname"));
|
|
String kqtype = Util.null2String(params.get("kqtype"));
|
|
String sqlWhere = Util.null2String(params.get("sqlWhere"));
|
|
String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') ";
|
|
|
|
if(isBindGroup) {
|
|
String resourceId = Util.null2String(params.get("resourceId"));
|
|
String fromDate = Util.null2String(params.get("fromDate"));
|
|
if(fromDate.length() == 0){
|
|
fromDate = DateUtil.getCurrentDate();
|
|
}
|
|
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
|
String groupIds = kqGroupMemberComInfo.getKQGroupIds(resourceId, fromDate);
|
|
if(!"".equals(groupIds)) {
|
|
kqtype = "2";
|
|
sqlwhere += " and id in("+groupIds+") ";
|
|
} else {
|
|
sqlwhere = " where 1=2 ";
|
|
}
|
|
}
|
|
|
|
if(!groupname.equals("")){
|
|
sqlwhere += " and groupname like '%";
|
|
sqlwhere += Util.fromScreen2(groupname,user.getLanguage());
|
|
sqlwhere += "%'";
|
|
}
|
|
|
|
if(!kqtype.equals("")){
|
|
sqlwhere += " and kqtype ="+kqtype;
|
|
}
|
|
|
|
if(hrmdetachable){
|
|
int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(),"HrmKQGroup:Add");
|
|
String subcompanyids = "";
|
|
if(user.getUID() != 1){
|
|
for(int i=0;arrSubcompanyids!=null&&i<arrSubcompanyids.length;i++){
|
|
if(subcompanyids.length()>0)subcompanyids+=",";
|
|
subcompanyids += arrSubcompanyids[i];
|
|
}
|
|
if(subcompanyids.length() > 0 ){
|
|
sqlwhere += " and subcompanyid in("+subcompanyids+")";
|
|
}else{
|
|
sqlwhere += " and 1=2 ";
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!sqlWhere.equals("")){
|
|
sqlwhere += " and "+sqlWhere;
|
|
}
|
|
|
|
sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere);
|
|
// 设置好搜索条件
|
|
String backFields = " id ,groupname, kqtype ";
|
|
String fromSql = " kq_group ";
|
|
|
|
String sql = "select "+backFields+" from "+fromSql+" "+sqlwhere;
|
|
kqLog.info("sql:::::::::"+sql);
|
|
|
|
List<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
|
|
cols.add(new SplitTableColBean("true","id"));
|
|
cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(388700, user.getLanguage()),"groupname","groupname").setIsInputCol(BoolAttr.TRUE).setShowType(1));
|
|
cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(388704,user.getLanguage()),"kqtype","kqtype","com.engine.kq.util.TransMethod.getKQTypeName",""+user.getLanguage()).setShowType(0));
|
|
|
|
SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols);
|
|
apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean));
|
|
return apidatas;
|
|
}
|
|
|
|
private Map<String, Object> getAdvanceData(Map<String, Object> params) throws Exception {
|
|
CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
|
|
ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
|
|
boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
String groupname = Util.null2String(params.get("groupname"));
|
|
String kqtype = Util.null2String(params.get("kqtype"));
|
|
String sqlWhere = Util.null2String(params.get("sqlWhere"));
|
|
String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') ";
|
|
if(!groupname.equals("")){
|
|
sqlwhere += " and groupname like '%";
|
|
sqlwhere += Util.fromScreen2(groupname,user.getLanguage());
|
|
sqlwhere += "%'";
|
|
}
|
|
|
|
if(!kqtype.equals("")){
|
|
sqlwhere += " and kqtype ="+kqtype;
|
|
}
|
|
|
|
if(!sqlWhere.equals("")){
|
|
sqlwhere += " and "+sqlWhere;
|
|
}
|
|
|
|
if(hrmdetachable){
|
|
int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(),"HrmKQGroup:Add");
|
|
String subcompanyids = "";
|
|
if(user.getUID() != 1){
|
|
for(int i=0;arrSubcompanyids!=null&&i<arrSubcompanyids.length;i++){
|
|
if(subcompanyids.length()>0)subcompanyids+=",";
|
|
subcompanyids += arrSubcompanyids[i];
|
|
}
|
|
if(subcompanyids.length() > 0 ){
|
|
sqlwhere += " and subcompanyid in("+subcompanyids+")";
|
|
}else{
|
|
sqlwhere += " and 1=2 ";
|
|
}
|
|
}
|
|
}
|
|
|
|
sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere);
|
|
// 设置好搜索条件
|
|
String backFields = " id,id as id1,id as id2,groupname,subcompanyid,kqtype,excludeid,signintype,ipscope,locationcheck,locationcheckscope,wificheck,isdelete ";
|
|
String fromSql = " kq_group ";
|
|
|
|
List<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
|
|
cols.add(new SplitTableColBean("true","id"));
|
|
cols.add(new SplitTableColBean("30%",SystemEnv.getHtmlLabelName(388700, user.getLanguage()),"groupname","groupname", "com.engine.kq.util.TransMethod.getKQGroupName", "column:id+++" + user.getLanguage()).setIsInputCol(BoolAttr.TRUE).setShowType(1));
|
|
cols.add(new SplitTableColBean("20%",SystemEnv.getHtmlLabelName(1859, user.getLanguage()),"id1",null, "com.engine.kq.util.TransMethod.getGroupUserCount"));
|
|
cols.add(new SplitTableColBean("20%",SystemEnv.getHtmlLabelName(63,user.getLanguage()),"kqtype","kqtype","com.engine.kq.util.TransMethod.getKQTypeName",""+user.getLanguage()).setShowType(0));
|
|
cols.add(new SplitTableColBean("30%",SystemEnv.getHtmlLabelName(27961, user.getLanguage()),"id2",null, "com.engine.kq.util.TransMethod.getKQGroupDetial", "column:kqtype+"+user.getLanguage()));
|
|
|
|
SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols);
|
|
apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean));
|
|
return apidatas;
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Object> getBrowserConditionInfo(Map<String, Object> params) throws Exception {
|
|
String advance = Util.null2String(params.get("advance"));
|
|
if("".equals(advance) || "0".equals(advance))
|
|
return getBasicBrowserConditionInfo(params);
|
|
return getAdvanceBrowserConditionInfo(params);
|
|
}
|
|
|
|
public Map<String, Object> getBasicBrowserConditionInfo(Map<String, Object> params) throws Exception {
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
List<SearchConditionItem> conditions = new ArrayList<SearchConditionItem>();
|
|
apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions);
|
|
|
|
ConditionFactory conditionFactory = new ConditionFactory(user);
|
|
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388700, "groupname", true));
|
|
|
|
List<SearchConditionOption> options = new ArrayList<SearchConditionOption>();
|
|
options.add(new SearchConditionOption("",""));
|
|
options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(389127, user.getLanguage())));
|
|
options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(389128, user.getLanguage())));
|
|
options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(389129, user.getLanguage())));
|
|
conditions.add(conditionFactory.createCondition(ConditionType.SELECT, 388704, "kqtype", options));
|
|
|
|
return apidatas;
|
|
}
|
|
|
|
public Map<String, Object> getAdvanceBrowserConditionInfo(Map<String, Object> params) throws Exception {
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
List<SearchConditionItem> conditions = new ArrayList<SearchConditionItem>();
|
|
apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions);
|
|
|
|
ConditionFactory conditionFactory = new ConditionFactory(user);
|
|
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388700, "groupname"));
|
|
|
|
List<SearchConditionOption> options = new ArrayList<SearchConditionOption>();
|
|
options.add(new SearchConditionOption("",""));
|
|
options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(389127, user.getLanguage())));
|
|
options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(389128, user.getLanguage())));
|
|
options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(389129, user.getLanguage())));
|
|
conditions.add(conditionFactory.createCondition(ConditionType.SELECT, 388704, "kqtype", options));
|
|
|
|
return apidatas;
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Object> getMultBrowserDestData(Map<String, Object> params) throws Exception {
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
List<Map<String,Object>> datas = new ArrayList<Map<String,Object>>();
|
|
String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS));
|
|
if(user==null||"".equals(selectids)){
|
|
return apidatas;
|
|
}
|
|
TransMethod transMethod = new TransMethod();
|
|
RecordSet recordSet = new RecordSet();
|
|
String tempSql = " select id,groupname, kqtype from kq_group where 1=1 and (isdelete is null or isdelete <> '1') and id in ("+selectids+") ";
|
|
recordSet.executeQuery(tempSql);
|
|
while (recordSet.next()){
|
|
String kqtype = Util.null2String(recordSet.getString("kqtype"));
|
|
String kqtypeShow = transMethod.getKQTypeName(kqtype,""+user.getLanguage());
|
|
|
|
Map<String,Object> item = new HashMap<String,Object>();
|
|
item.put("id", recordSet.getString("id"));
|
|
item.put("groupname", Util.null2String(recordSet.getString("groupname")));
|
|
item.put("kqtype", kqtypeShow);
|
|
datas.add(item);
|
|
}
|
|
List<ListHeadBean> tableHeadColumns = new ArrayList<ListHeadBean>();
|
|
tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE));
|
|
tableHeadColumns.add(new ListHeadBean("groupname","",1,BoolAttr.TRUE));
|
|
tableHeadColumns.add(new ListHeadBean("kqtype","",0));
|
|
|
|
apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns);
|
|
apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas);
|
|
apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid());
|
|
return apidatas;
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Object> browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
String isBindGroup=Util.null2s(request.getParameter("isBindGroup"),"");
|
|
|
|
String outSqlWhere=Util.null2s(request.getParameter("sqlWhere"),"");
|
|
String groupname=Util.null2s(request.getParameter("q"),"");
|
|
String includeAll=Util.null2s(request.getParameter("includeAll"),"");
|
|
RecordSet rs=new RecordSet();
|
|
String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') ";
|
|
if("1".equals(isBindGroup)) {
|
|
String resourceId=Util.null2s(request.getParameter("resourceId"),"");
|
|
String fromDate=Util.null2s(request.getParameter("fromDate"),"");
|
|
if(fromDate.length() == 0){
|
|
fromDate = DateUtil.getCurrentDate();
|
|
}
|
|
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
|
String groupIds = kqGroupMemberComInfo.getKQGroupIds(resourceId, fromDate);
|
|
if(!"".equals(groupIds)) {
|
|
sqlwhere += " and id in("+groupIds+") and kqType=2 ";
|
|
} else {
|
|
sqlwhere = " where 1=2 ";
|
|
}
|
|
} else {
|
|
sqlwhere += " and kqType <>3 ";
|
|
}
|
|
//String groupids = getSettedGroupIds();
|
|
// if(groupids.length()>0 && "".equals(includeAll)){
|
|
// sqlwhere+=" and id not in ( "+groupids+" ) ";
|
|
// }
|
|
if(!groupname.equals("")){
|
|
sqlwhere += " and groupname like '%";
|
|
sqlwhere += Util.fromScreen2(groupname,user.getLanguage());
|
|
sqlwhere += "%'";
|
|
}
|
|
|
|
if(!outSqlWhere.equals("")){
|
|
sqlwhere += " and "+outSqlWhere;
|
|
}
|
|
// 设置好搜索条件
|
|
String backFields = " id ,groupname, kqtype ";
|
|
String fromSql = " kq_group ";
|
|
String sql = "select "+backFields+" from "+fromSql+sqlwhere;
|
|
|
|
rs.executeQuery(sql);
|
|
List<Map<String,String>> datas = new ArrayList<Map<String,String>>();
|
|
while(rs.next()){
|
|
Map<String,String> item = new HashMap<String,String>();
|
|
item.put("id", Util.null2String(rs.getString("id")));
|
|
String name = Util.null2String(rs.getString("groupname"));
|
|
item.put("name", name);
|
|
datas.add(item);
|
|
}
|
|
apidatas.put("datas",datas);
|
|
return apidatas;
|
|
}
|
|
|
|
/**
|
|
* 获取已经设置过加班规则得考勤组ids
|
|
* @return
|
|
*/
|
|
private String getSettedGroupIds(){
|
|
RecordSet rs = new RecordSet();
|
|
String settedGroupIds = "";
|
|
try{
|
|
rs.executeQuery("select groupids from kq_OvertimeRules where isdelete is null or isdelete <>'1'");
|
|
while(rs.next()){
|
|
String groupids = Util.null2String(rs.getString("groupids"));
|
|
if(groupids.length()>0){
|
|
if(settedGroupIds.length()>0)settedGroupIds+=",";
|
|
settedGroupIds+=groupids;
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
rs.writeLog(e);
|
|
}
|
|
return settedGroupIds;
|
|
}
|
|
}
|