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.
89 lines
3.2 KiB
Java
89 lines
3.2 KiB
Java
2 years ago
|
package com.engine.attendance.component.persongroup.cmd;
|
||
2 years ago
|
|
||
|
import com.engine.common.biz.AbstractCommonCommand;
|
||
|
import com.engine.common.entity.BizLogContext;
|
||
|
import com.engine.common.util.DbTools;
|
||
|
import com.engine.core.interceptor.CommandContext;
|
||
|
import com.google.common.collect.Lists;
|
||
|
import com.google.common.collect.Maps;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
import weaver.conn.RecordSet;
|
||
|
import weaver.general.Util;
|
||
|
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
|
||
|
@Slf4j
|
||
|
public class GetDatatableCmd extends AbstractCommonCommand<Map<String,Object>> {
|
||
|
@Override
|
||
|
public BizLogContext getLogContext() {
|
||
|
return null;
|
||
|
}
|
||
|
public GetDatatableCmd(Map<String,Object> params){
|
||
|
this.params=params;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Map<String, Object> execute(CommandContext commandContext) {
|
||
|
String tableName = Util.null2String(params.get("tableName"));
|
||
|
String startDate = Util.null2String(params.get("startDate"));
|
||
|
String endDate = Util.null2String(params.get("endDate"));
|
||
|
String pblx = Util.null2String(params.get("pblx"));
|
||
|
String pbdx = Util.null2String(params.get("pbdx"));
|
||
|
int total = Integer.valueOf(Util.null2String(params.get("total")));
|
||
|
int current = Integer.valueOf(Util.null2String(params.get("current")));
|
||
|
int pageSize = Integer.valueOf(Util.null2String(params.get("pageSize")));
|
||
|
RecordSet rs = new RecordSet();
|
||
|
Map<String, Object> resultMap = Maps.newHashMap();
|
||
|
String sql = "select id from "+tableName +" where pbtj=0 ";
|
||
|
List<Object> param = Lists.newArrayList();
|
||
|
|
||
|
String conditions = "";
|
||
|
if (!"".equals(startDate) && !"".equals(endDate)){
|
||
|
conditions += " and bcrq >= ? and bcrq<= ?";
|
||
|
param.add(startDate);
|
||
|
param.add(endDate);
|
||
|
}
|
||
|
// if (!"".equals(pblx)){
|
||
|
// conditions += " and dxlx = ?";
|
||
|
// param.add(pblx);
|
||
|
// }
|
||
|
if (!"".equals(pbdx)){
|
||
|
conditions += " and dxlx = ?";
|
||
|
param.add(pblx);
|
||
|
if ("0".equals(pblx)){
|
||
|
//人员
|
||
|
conditions += " and pbdxry = ?";
|
||
|
|
||
|
}else if ("1".equals(pblx)){
|
||
|
//人员分组
|
||
|
conditions += " and pbdxryfz = ?";
|
||
|
|
||
|
}else if ("2".equals(pblx)){
|
||
|
//部门
|
||
|
conditions += " and pbdxbm = ?";
|
||
|
|
||
|
}else if ("3".equals(pblx)){
|
||
|
//分部
|
||
|
conditions += " and pbdxfb = ?";
|
||
|
}
|
||
|
param.add(pbdx);
|
||
|
}
|
||
|
int startindex = (current-1)*pageSize;
|
||
|
String dbType = rs.getDBType();
|
||
|
if ("oracle".equals(dbType)){
|
||
|
|
||
|
}else {
|
||
|
sql = sql + conditions +" limit "+startindex+",1";
|
||
|
String queryDatatablesql = "select a.id as `key`,b.lastname,a.* from "+tableName +" a left join hrmresource b on a.pbdxry=b.id where a.id>=("+sql+") "+conditions+" limit "+pageSize;
|
||
|
log.info("queryDatatablesql : {}",queryDatatablesql);
|
||
|
param.addAll(param);
|
||
|
log.info("param : {}",param);
|
||
|
List<Map<String,Object>> dataTable = DbTools.getSqlToList(queryDatatablesql,param.toArray());
|
||
|
resultMap.put("data",dataTable);
|
||
|
}
|
||
|
|
||
|
return resultMap;
|
||
|
}
|
||
|
}
|