ecology-kq/src/com/api/kq/browser/service/impl/ShiftBrowser4FlowService.java

142 lines
5.9 KiB
Java

package com.api.kq.browser.service.impl;
import com.alibaba.fastjson.JSON;
import com.api.browser.bean.SearchConditionItem;
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.ConditionFactory;
import com.api.browser.util.ConditionType;
import com.api.browser.util.SplitTableUtil;
import com.api.browser.util.SqlUtils;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.entity.KQGroupEntity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.engine.kq.log.KQLog;
import weaver.common.DateUtil;
import weaver.general.Util;
import weaver.systeminfo.SystemEnv;
/**
* 排班考勤流程使用的班次浏览按钮
* type : kqshift
*/
public class ShiftBrowser4FlowService extends BrowserService {
private KQLog kqLog = new KQLog();
@Override
public Map<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
kqLog.info("params:::::::::::"+JSON.toJSONString(params));
Map<String, Object> apidatas = new HashMap<String, Object>();
String serial = Util.null2String(params.get("serial"));
String resourceId = Util.null2String(params.get("resourceId"));
boolean isBindGroup = "1".equals(Util.null2String(params.get("isBindGroup"))); // 0:未绑定考勤组; 1:绑定了考勤组
String fromDate = Util.null2String(params.get("fromDate"));
if(fromDate.length() == 0){
fromDate = DateUtil.getCurrentDate();
}
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') ";
if(!serial.equals("")){
sqlwhere += " and serial like '%";
sqlwhere += Util.fromScreen2(serial,user.getLanguage());
sqlwhere += "%'";
}
KQGroupEntity kQGroupEntity = null;
if(isBindGroup) {
String groupId = Util.null2String(params.get("groupId"));
if("".equals(groupId)) { // 绑定了考勤组,但是没有填写考勤组数据的话,返回空
sqlwhere = " where 1=2 ";
} else {
kQGroupEntity = getUserKQGroupInfo(groupId);
}
} else {
kQGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(resourceId,fromDate,true);
}
if(kQGroupEntity == null){
sqlwhere = " where 1=2 ";
}else{
writeLog("kQGroupEntity:"+JSON.toJSONString(kQGroupEntity));
String kqtype = kQGroupEntity.getKqtype();
if ("2".equalsIgnoreCase(kqtype)) {
String serialids = kQGroupEntity.getSerialids();
if (serialids.length() > 0) {
sqlwhere += " and ( "+Util.getSubINClause(serialids, "id", "in")+" or id = -1 )";
}else{
sqlwhere += " and (1=2 or or id = -1)";
}
}else{
sqlwhere = " where 1=2 ";
}
}
sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere);
// 设置好搜索条件
String backFields = " id ,id as aliasid,serial ";
String fromSql = " kq_ShiftManagement_view ";
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(125818, user.getLanguage()),"serial","serial").setIsInputCol(BoolAttr.TRUE));
cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(27961,user.getLanguage()),"aliasid","aliasid","com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit.getShiftOnOffWorkSections",user.getLanguage()+"").setIsInputCol(BoolAttr.FALSE));
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 {
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, 125818, "serial", true));
return apidatas;
}
private KQGroupEntity getUserKQGroupInfo(String groupid) {
KQGroupEntity kqGroupEntity = null;
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
try {
if (groupid.length() > 0) {
kqGroupEntity = new KQGroupEntity();
kqGroupEntity.setId(groupid);
kqGroupEntity.setGroupname(kqGroupComInfo.getGroupname(groupid));
kqGroupEntity.setExcludeid(kqGroupComInfo.getExcludeid(groupid));
kqGroupEntity.setSubcompanyid(kqGroupComInfo.getSubcompanyid(groupid));
kqGroupEntity.setKqtype(kqGroupComInfo.getKqtype(groupid));
kqGroupEntity.setSerialids(kqGroupComInfo.getSerialids(groupid));
kqGroupEntity.setWeekday(kqGroupComInfo.getWeekday(groupid));
kqGroupEntity.setSignstart(kqGroupComInfo.getSignstart(groupid));
kqGroupEntity.setWorkhour(kqGroupComInfo.getWorkhour(groupid));
kqGroupEntity.setIsdelete(kqGroupComInfo.getIsdelete(groupid));
kqGroupEntity.setSignintype(kqGroupComInfo.getSignintype(groupid));
kqGroupEntity.setIpscope(kqGroupComInfo.getIpscope(groupid));
kqGroupEntity.setLocationcheck(kqGroupComInfo.getLocationcheck(groupid));
kqGroupEntity.setLocationcheckscope(kqGroupComInfo.getLocationcheckscope(groupid));
kqGroupEntity.setWificheck(kqGroupComInfo.getWificheck(groupid));
kqGroupEntity.setOutsidesign(kqGroupComInfo.getOutsidesign(groupid));
kqGroupEntity.setOutsignapprove(kqGroupComInfo.getOutsignApprove(groupid));
kqGroupEntity.setCalmethod(kqGroupComInfo.getCalmethod(groupid));
kqGroupEntity.setLocationshowaddress(kqGroupComInfo.getLocationshowaddress(groupid));
}
} catch (Exception e) {
}
return kqGroupEntity;
}
}