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.

1320 lines
65 KiB
Java

10 months ago
package com.engine.jucailinkq.common.util;
2 years ago
10 months ago
import com.engine.jucailinkq.attendance.attendanceanalysis.cmd.getclockInpoint.biz.AbstractAdjustClockPointAction;
import com.engine.jucailinkq.attendance.component.persongroup.commonutil.PersongroupCommonUtil;
import com.engine.jucailinkq.attendance.enums.ApplicableOrganizationEnum;
import com.engine.jucailinkq.attendance.enums.CheckBoxEnum;
import com.engine.jucailinkq.attendance.enums.PersonGroupListTypeEnum;
import com.engine.jucailinkq.attendance.workflow.enums.WorkFlowTypeEnum;
10 months ago
import com.engine.jucailinkq.common.exception.AttendanceRunTimeException;
1 year ago
import com.google.common.collect.Lists;
10 months ago
import com.google.common.collect.Maps;
2 years ago
import com.google.common.collect.Sets;
2 years ago
import lombok.extern.slf4j.Slf4j;
import weaver.conn.RecordSetTrans;
2 years ago
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
1 year ago
import weaver.soa.workflow.request.*;
2 years ago
7 months ago
import java.time.ZoneOffset;
1 year ago
import java.util.*;
2 years ago
import java.util.stream.Collectors;
2 years ago
@Slf4j
public class CommonUtil {
/**
* insertsql
* @param tableName
* @param map
* @return
*/
1 year ago
public static boolean makeInsertSql(String tableName, Map<String,Object> map){
2 years ago
String insertSql = "insert into "+tableName;
String key = "(";
String value = "(";
1 year ago
List<Object> dataList = Lists.newArrayList();
2 years ago
for (Map.Entry<String,Object> e : map.entrySet()){
1 year ago
if (e.getValue() != null && !"".equals(e.getValue())){
key = key + e.getKey() +",";
value = value + "?" +",";
12 months ago
// if (e.getKey().endsWith("date")){
// LocalDateTime localDateTime = DateUtil.getTime(String.valueOf(e.getValue()));
// long datelong = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
// dataList.add(new Date(datelong));
// }else {
1 year ago
dataList.add(e.getValue());
12 months ago
// }
1 year ago
}
2 years ago
}
key = key.substring(0,key.length()-1) + ")";
value = value.substring(0,value.length()-1)+")";
insertSql = insertSql + key +" values "+value;
10 months ago
log.debug("makeInsertSql : [{}]",insertSql);
log.debug("needInsertDate: [{}]",dataList);
1 year ago
return DbTools.update(insertSql,dataList);
2 years ago
}
2 years ago
/**
* updatesql
* @param tableName
* @param map
* @param condition
* @return
*/
public static String makeUpdateSql(String tableName, Map<String,Object> map,Map<String,Object> condition){
String updateSql = "update "+tableName+" set ";
for (Map.Entry<String,Object> e : map.entrySet()){
if (e.getValue() !=null && !"".equals(e.getValue()) && !e.getKey().equals("id")){
2 years ago
updateSql = updateSql + e.getKey()+"='"+e.getValue().toString()+"',";
}
}
updateSql = updateSql.substring(0,updateSql.length()-1) + " where 1=1";
for (Map.Entry<String,Object> e : condition.entrySet()){
updateSql = updateSql + " and "+ e.getKey()+"='"+e.getValue()+"'";
}
10 months ago
log.debug("makeUpdateSql : [{}]",updateSql);
2 years ago
return updateSql;
}
2 years ago
1 year ago
/**
*
* @param dataList
* @param tableName
* @return
*/
public static boolean insertBatch(List<Map<String,Object>> dataList, String tableName){
String sql = "insert into "+tableName;
String key = "(";
String value = "(";
for (Map.Entry<String,Object> data : dataList.get(0).entrySet()){
key = key + data.getKey() +",";
value = value + "?,";
}
key = key.substring(0,key.length()-1) + ")";
value = value.substring(0,value.length()-1)+")";
sql = sql + key +" values "+value;
10 months ago
log.debug("insertBatch sql :"+sql);
1 year ago
List<List> insertDataList = Lists.newArrayList();
for (Map<String,Object> dataMap : dataList){
ArrayList<Object> list = new ArrayList<>();
for (Map.Entry<String,Object> entry : dataMap.entrySet()){
list.add(entry.getValue());
}
insertDataList.add(list);
}
10 months ago
log.debug("insertBatch : [{}]",insertDataList);
1 year ago
return DbTools.updateBatch(sql,insertDataList);
}
11 months ago
/**
* id---
* @param resourceId
* @param modeId
* @param date
11 months ago
* @return
*/
public static Set<String> getDataIds(String resourceId,String modeId,String date){
2 years ago
1 year ago
String sql = "select dxlx,dataid,dx from uf_jcl_syzz where modeid=?";
2 years ago
List<Map<String,Object>> organizationList = DbTools.getSqlToList(sql,modeId);
sql = "select id,departmentid,subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql,resourceId);
Set<String> dataIds = Sets.newHashSet();
Map<String, List<Map<String,Object>>> organizationListGroupBydxlx = organizationList.stream().collect(Collectors.groupingBy(e ->e.get("dxlx").toString()));
//对象类型为人员
List<Map<String,Object>> personOrganizationList = organizationListGroupBydxlx.get("0");
//对象类型为人员组织
List<Map<String,Object>> personGroupOrganizationList = organizationListGroupBydxlx.get("1");
//对象类型为部门
List<Map<String,Object>> departmentOrganizationList = organizationListGroupBydxlx.get("2");
//对象类型为分部
List<Map<String,Object>> subCompanyOrganizationList = organizationListGroupBydxlx.get("3");
if (personOrganizationList != null){
for (Map<String,Object> personOrganization :personOrganizationList){
String dx = Util.null2String(personOrganization.get("dx"));
String ids = dx.split("-")[0];
if (ids.equals(resourceId)){
dataIds.add(Util.null2String(personOrganization.get("dataid")));
}
}
}
1 year ago
if (personGroupOrganizationList != null && dataIds.size() ==0){
Map<String,List<Map<String,Object>>> personBelongGroup = ExtensionClassHolder.getPersonBelongGroupThreadLocal();
Set<String> personnelGroupIds = null;
if (personBelongGroup == null){
Set<String> personGroupIds = personGroupOrganizationList.stream().map(e -> Util.null2String(e.get("dx")).split("-")[0]).collect(Collectors.toSet());
sql = "select mainid,empid,filters,bdate,edate,sqltj from uf_ryqz_dt1 where mainid in ("+String.join(",",personGroupIds)+")";
log.debug("query personGroupData : {}",sql);
List<Map<String,Object>> personGroupData = DbTools.getSqlToList(sql);
personnelGroupIds = PersongroupCommonUtil.getPersonnelGroupingByPerson(personGroupData,resourceId,date);
}else {
List<Map<String,Object>> personnelGroups = personBelongGroup.get(resourceId) == null? Lists.newArrayList():personBelongGroup.get(resourceId);
if (date != null && !date.equals("")){
personnelGroups = personnelGroups.stream().filter(e->(Util.null2String(e.get("bdate")).equals("") || DateUtil.getTime(e.get("bdate").toString()).compareTo(DateUtil.getTime(date))<=0) &&
(Util.null2String(e.get("edate")).equals("") || DateUtil.getTime(e.get("edate").toString()).compareTo(DateUtil.getTime(date))>=0)).collect(Collectors.toList());
}
personnelGroupIds = personnelGroups.stream().map(e->e.get("mainid").toString()).collect(Collectors.toSet());
}
10 months ago
log.debug("personnelGroupIds : {}",personnelGroupIds);
1 year ago
for (Map<String,Object> personGroupOrganization :personGroupOrganizationList){
String personnelGroupId = Util.null2String(personGroupOrganization.get("dx")).split("-")[0];
if (personnelGroupIds.contains(personnelGroupId)){
dataIds.add(Util.null2String(personGroupOrganization.get("dataid")));
}
}
}
2 years ago
try {
1 year ago
if (departmentOrganizationList != null && dataIds.size() ==0){
2 years ago
String deptid = Util.null2String(departMentMap.get("departmentid"));
String pdeptids = "";
Map<String,String> petDepart = ExtensionClassHolder.getPetDepartMentThreadLocal();
if (petDepart != null){
pdeptids = petDepart.get(deptid);
}
if (pdeptids == null || pdeptids.equals("")){
pdeptids = new DepartmentComInfo().getAllParentDepartId(Util.null2String(departMentMap.get("departmentid")), pdeptids);
pdeptids = deptid + pdeptids;
}
10 months ago
log.debug("pdeptids : [{}]",pdeptids);
2 years ago
for (Map<String,Object> departmentOrganization :departmentOrganizationList){
String dx = Util.null2String(departmentOrganization.get("dx"));
String ids = dx.split("-")[0];
for (String pdeptid : pdeptids.split(",")){
if (pdeptid.equals(ids)){
dataIds.add(Util.null2String(departmentOrganization.get("dataid")));
}
}
}
}
}catch (Exception e){
log.error("catch error :{}",e);
}
1 year ago
if (subCompanyOrganizationList != null && dataIds.size() ==0){
2 years ago
String subCompanyId = Util.null2String(departMentMap.get("subcompanyid1"));
for (Map<String,Object> subCompanyOrganization :subCompanyOrganizationList){
String dx = Util.null2String(subCompanyOrganization.get("dx"));
String ids = dx.split("-")[0];
if (ids.equals(subCompanyId)){
dataIds.add(Util.null2String(subCompanyOrganization.get("dataid")));
}
}
}
10 months ago
log.debug("dataIds : {}",dataIds);
11 months ago
return dataIds;
}
/**
11 months ago
* id
11 months ago
* @param resourceId
* @param modeId
* @param date
11 months ago
* @return
*/
public static Set<String> getAllDataIds(String resourceId,String modeId,String date){
11 months ago
String sql = "select dxlx,dataid,dx from uf_jcl_syzz where modeid=?";
List<Map<String,Object>> organizationList = DbTools.getSqlToList(sql,modeId);
sql = "select id,departmentid,subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql,resourceId);
Set<String> dataIds = Sets.newHashSet();
Map<String, List<Map<String,Object>>> organizationListGroupBydxlx = organizationList.stream().collect(Collectors.groupingBy(e ->e.get("dxlx").toString()));
//对象类型为人员
List<Map<String,Object>> personOrganizationList = organizationListGroupBydxlx.get("0");
//对象类型为人员组织
List<Map<String,Object>> personGroupOrganizationList = organizationListGroupBydxlx.get("1");
//对象类型为部门
List<Map<String,Object>> departmentOrganizationList = organizationListGroupBydxlx.get("2");
//对象类型为分部
List<Map<String,Object>> subCompanyOrganizationList = organizationListGroupBydxlx.get("3");
if (personOrganizationList != null){
for (Map<String,Object> personOrganization :personOrganizationList){
String dx = Util.null2String(personOrganization.get("dx"));
String ids = dx.split("-")[0];
if (ids.equals(resourceId)){
dataIds.add(Util.null2String(personOrganization.get("dataid")));
}
}
}
if (personGroupOrganizationList != null){
Map<String,List<Map<String,Object>>> personBelongGroup = ExtensionClassHolder.getPersonBelongGroupThreadLocal();
Set<String> personnelGroupIds = null;
if (personBelongGroup == null){
Set<String> personGroupIds = personGroupOrganizationList.stream().map(e -> Util.null2String(e.get("dx")).split("-")[0]).collect(Collectors.toSet());
sql = "select mainid,empid,filters,bdate,edate,sqltj from uf_ryqz_dt1 where mainid in ("+String.join(",",personGroupIds)+")";
log.debug("query personGroupData : {}",sql);
List<Map<String,Object>> personGroupData = DbTools.getSqlToList(sql);
personnelGroupIds = PersongroupCommonUtil.getPersonnelGroupingByPerson(personGroupData,resourceId,date);
}else {
List<Map<String,Object>> personnelGroups = personBelongGroup.get(resourceId) == null? Lists.newArrayList():personBelongGroup.get(resourceId);
if (date != null && !date.equals("")){
personnelGroups = personnelGroups.stream().filter(e->(Util.null2String(e.get("bdate")).equals("") || DateUtil.getTime(e.get("bdate").toString()).compareTo(DateUtil.getTime(date))<=0) &&
(Util.null2String(e.get("edate")).equals("") || DateUtil.getTime(e.get("edate").toString()).compareTo(DateUtil.getTime(date))>=0)).collect(Collectors.toList());
}
personnelGroupIds = personnelGroups.stream().map(e->e.get("mainid").toString()).collect(Collectors.toSet());
}
10 months ago
log.debug("personnelGroupIds : {}",personnelGroupIds);
11 months ago
for (Map<String,Object> personGroupOrganization :personGroupOrganizationList){
String personnelGroupId = Util.null2String(personGroupOrganization.get("dx")).split("-")[0];
if (personnelGroupIds.contains(personnelGroupId)){
dataIds.add(Util.null2String(personGroupOrganization.get("dataid")));
}
}
}
try {
if (departmentOrganizationList != null){
String deptid = Util.null2String(departMentMap.get("departmentid"));
String pdeptids = "";
Map<String,String> petDepart = ExtensionClassHolder.getPetDepartMentThreadLocal();
if (petDepart != null){
pdeptids = petDepart.get(deptid);
}
if (pdeptids == null || pdeptids.equals("")){
pdeptids = new DepartmentComInfo().getAllParentDepartId(Util.null2String(departMentMap.get("departmentid")), pdeptids);
pdeptids = deptid + pdeptids;
}
10 months ago
log.debug("pdeptids : [{}]",pdeptids);
11 months ago
for (Map<String,Object> departmentOrganization :departmentOrganizationList){
String dx = Util.null2String(departmentOrganization.get("dx"));
String ids = dx.split("-")[0];
for (String pdeptid : pdeptids.split(",")){
if (pdeptid.equals(ids)){
dataIds.add(Util.null2String(departmentOrganization.get("dataid")));
}
}
}
}
}catch (Exception e){
log.error("catch error :{}",e);
}
if (subCompanyOrganizationList != null){
String subCompanyId = Util.null2String(departMentMap.get("subcompanyid1"));
for (Map<String,Object> subCompanyOrganization :subCompanyOrganizationList){
String dx = Util.null2String(subCompanyOrganization.get("dx"));
String ids = dx.split("-")[0];
if (ids.equals(subCompanyId)){
dataIds.add(Util.null2String(subCompanyOrganization.get("dataid")));
}
}
}
10 months ago
log.debug("dataIds : {}",dataIds);
2 years ago
return dataIds;
}
public static boolean ifContainStr(String fatherStr,String sonStr,String mark){
for (String pdeptid : fatherStr.split(mark)){
1 year ago
if (pdeptid.equals(sonStr)){
2 years ago
return true;
}
}
return false;
}
1 year ago
/**
* requestInfomap
* @param requestInfo
* @return
*/
public static HashMap<String,String> getMainTableInfo(RequestInfo requestInfo){
HashMap<String,String> mainMap = new HashMap<String,String>();
Property[] properties = requestInfo.getMainTableInfo().getProperty();// 获取表单主字段信息
1 year ago
1 year ago
for (int i = 0; i < properties.length; i++) {
String name = properties[i].getName();// 主字段名称
String value = Util.null2String(properties[i].getValue());// 主字段对应的值
mainMap.put(name, value);
}
1 year ago
mainMap.put("id",String.valueOf(requestInfo.getRequestManager().getBillid()));
1 year ago
return mainMap;
}
/**
* requestInfomap
* @param requestInfo
* @return
*/
public static HashMap<String,String> getMainTableInfo(RequestInfo requestInfo, WorkFlowTypeEnum workFlowTypeEnum){
String sql = "select a.yszdm id,a.lczdm name,b.lclx from uf_jcl_kq_kqlcsz_dt1 a left join uf_jcl_kq_kqlcsz b on a.mainid=b.id where lclx=?";
Map<String,Object> mappingMap = DbTools.getSqlToMapList(sql,workFlowTypeEnum.getKey());
HashMap<String,String> mainMap = new HashMap<String,String>();
HashMap<String,String> resultMap = new HashMap<String,String>();
Property[] properties = requestInfo.getMainTableInfo().getProperty();// 获取表单主字段信息
for (int i = 0; i < properties.length; i++) {
String name = properties[i].getName();// 主字段名称
String value = Util.null2String(properties[i].getValue());// 主字段对应的值
mainMap.put(name, value);
}
mainMap.put("id",String.valueOf(requestInfo.getRequestManager().getBillid()));
if (mappingMap.size() != 0){
resultMap.putAll(mainMap);
for (Map.Entry<String,Object> entry :mappingMap.entrySet()){
if (entry.getValue()!=null && !"".equals(entry.getValue())){
resultMap.put(entry.getKey(),mainMap.get(entry.getValue()));
}else {
resultMap.put(entry.getKey(),mainMap.get(entry.getKey()));
}
}
return resultMap;
}else {
return mainMap;
}
}
1 year ago
/**
*
* @param request
* @return
*/
public static List<Map<String, String>> getDetailTableInfo(RequestInfo request, int index) {
// 获取明细的信息
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
DetailTable[] detailtables = request.getDetailTableInfo().getDetailTable();// 获取明细表数据
if (detailtables.length > index) {
DetailTable dt = detailtables[index];// 获取明细表 0代表明细表1
10 months ago
log.debug("getDetailTableInfo :[{}]",dt.getTableDBName());
1 year ago
Row[] rows = dt.getRow();// 获取明细表中所有行的信息
for (int i = 0; i < rows.length; i++) {
Row row = rows[i];// 获取具体行信息
Cell[] cells = row.getCell();// 获取具体行所有列的信息
Map<String, String> map = new HashMap<String, String>();
for (int j = 0; j < cells.length; j++) {
Cell cell = cells[j];
String name = cell.getName().toLowerCase();// 获取字段名
String value = cell.getValue();// 获取具体的值
map.put(name, value);
}
1 year ago
map.put("id",row.getId());
1 year ago
list.add(map);
}
}
1 year ago
return list;
}
/**
*
* @param request
* @return
*/
public static List<Map<String, String>> getDetailTableInfo(RequestInfo request, int index,WorkFlowTypeEnum workFlowTypeEnum) {
String queryTable = "uf_jcl_kq_kqlcsz_dt2";
if (workFlowTypeEnum == WorkFlowTypeEnum.ASKFORLEAVE || workFlowTypeEnum == WorkFlowTypeEnum.BATCH_ASKFORLEAVE){
if (index == 1){
//明细表2
queryTable = "uf_jcl_kq_kqlcsz_dt3";
}
}
String sql = "select a.yszdm,a.lczdm,a.lczdszb from "+queryTable+" a left join uf_jcl_kq_kqlcsz b on a.mainid=b.id where lclx=?";
List<Map<String,Object>> mappingList = DbTools.getSqlToList(sql,workFlowTypeEnum.getKey());
String tableName = null;
for (Map<String,Object> map:mappingList){
if (map.get("lczdszb") != null && !map.get("lczdszb").equals("")){
tableName= map.get("lczdszb").toString();
break;
}
}
List<Map<String, String>> detailDataList = null;
List<Map<String, String>> resultList = Lists.newArrayList();
if (tableName == null || !tableName.contains("_dt")){
detailDataList = getDetailTableInfo(request,index);
}else {
int detailIndex = Integer.valueOf(tableName.substring(tableName.length()-1,tableName.length()));
detailDataList = getDetailTableInfo(request,detailIndex-1);
}
Map<String,Object> mappingMap = mappingList.stream().collect(Collectors.toMap(e->Util.null2String(e.get("yszdm")),e->e.get("lczdm")));
if (mappingMap.size() != 0){
for (Map<String, String> detailData:detailDataList){
Map<String, String> resultMap = Maps.newHashMap();
resultMap.putAll(resultMap);
for (Map.Entry<String,Object> entry :mappingMap.entrySet()){
if (entry.getValue()!=null && !"".equals(entry.getValue())){
resultMap.put(entry.getKey(),detailData.get(entry.getValue()));
}else {
resultMap.put(entry.getKey(),detailData.get(entry.getKey()));
}
}
resultList.add(resultMap);
}
return resultList;
}else {
return detailDataList;
}
}
/**
*
*/
public static String getDetailTableInfoTableName(String tableName, int index,WorkFlowTypeEnum workFlowTypeEnum){
String queryTable = "uf_jcl_kq_kqlcsz_dt2";
if (workFlowTypeEnum == WorkFlowTypeEnum.ASKFORLEAVE || workFlowTypeEnum == WorkFlowTypeEnum.BATCH_ASKFORLEAVE){
if (index == 1){
//明细表2
queryTable = "uf_jcl_kq_kqlcsz_dt3";
}
}
String sql = "select a.yszdm,a.lczdm,a.lczdszb from "+queryTable+" a left join uf_jcl_kq_kqlcsz b on a.mainid=b.id where lclx=?";
List<Map<String,Object>> mappingList = DbTools.getSqlToList(sql,workFlowTypeEnum.getKey());
for (Map<String,Object> map:mappingList){
if (map.get("lczdszb") != null && !map.get("lczdszb").equals("")){
tableName= map.get("lczdszb").toString();
break;
}
}
return tableName;
}
/**
* iddataIdmodeId
* @param dataId
* @param modeId
* @return
*/
public static List<String> getEmpIds(String dataId,String modeId) {
List<String> empIdList = new ArrayList<>();
String sql = "select dxlx,aqjb,dx from uf_jcl_syzz where modeid=? and dataid = ?";
//适用组织所有值集合
List<Map<String,Object>> organizationList = DbTools.getSqlToListKeySmallLetter(sql,modeId, dataId);
//分组
List<Map<String, String>> empIdInfos = new ArrayList<>();
List<Map<String, String>> empGroupIdInfos = new ArrayList<>();
List<Map<String, String>> depIdInfos = new ArrayList<>();
List<Map<String, String>> subCompanyIdInfos = new ArrayList<>();
for (Map<String,Object> organization : organizationList){
String id = Util.null2String(organization.get("dx")).split("-")[0];
String securityLevel = Util.null2String(organization.get("aqjb"));
String[] securityLevelArr = securityLevel.split("-");
String minSecurityLevel = securityLevel.substring(0, 1).equals("-") ? "" : securityLevelArr[0];
String maxSecurityLevel = "";
if (securityLevelArr.length == 1 && !securityLevelArr[0].equals(minSecurityLevel)) {
maxSecurityLevel = securityLevelArr[0];
} else if (securityLevelArr.length == 2) {
maxSecurityLevel = securityLevelArr[1];
}
if (ApplicableOrganizationEnum.PERSONNEL.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
empIdInfos.add(infoItem);
}else if (ApplicableOrganizationEnum.PERSONNEL_GROUP.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
empGroupIdInfos.add(infoItem);
}else if (ApplicableOrganizationEnum.DEPARTMENT.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
depIdInfos.add(infoItem);
}else if (ApplicableOrganizationEnum.SUBCOMPANY.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
subCompanyIdInfos.add(infoItem);
}
}
//人员类型
10 months ago
log.debug("empIdInfos : " + empIdInfos);
for (Map<String, String> map : empIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息
String querySql = "select * from hrmresource where id = " + id;
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
Map<String,Object> data = DbTools.getSqlToMap(querySql);
10 months ago
log.debug("querySql : " + querySql);
if (data.size() > 0) {
empIdList.add(id);
}
}
//人员分组类型
10 months ago
log.debug("empGroupIdInfos : " + empGroupIdInfos);
for (Map<String, String> map : empGroupIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//获取分组包含人员id
10 months ago
Set<String> empIdsByGroup = getEmpGroupUserIds(id);
10 months ago
log.debug("empGroupId : " + id + ", empIdsByGroup : " + empIdsByGroup);
//查询目标人员信息
if (empIdsByGroup.size() > 0) {
String querySql = "select * from hrmresource where id in ("+String.join(",",empIdsByGroup)+")";
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
List<Map<String,Object>> datas = DbTools.getSqlToListKeySmallLetter(querySql);
10 months ago
log.debug("querySql : " + querySql);
if (datas.size() > 0) {
10 months ago
log.debug("datas.size : " + datas.size());
datas.forEach(f -> empIdList.add(f.get("id").toString()));
}
}
}
//部门类型
10 months ago
log.debug("depIdInfos : " + depIdInfos);
for (Map<String, String> map : depIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息
String querySql = "select * from hrmresource where departmentid = " + id;
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
List<Map<String,Object>> datas = DbTools.getSqlToListKeySmallLetter(querySql);
10 months ago
log.debug("querySql : " + querySql);
if (datas.size() > 0) {
10 months ago
log.debug("datas.size : " + datas.size());
datas.forEach(f -> empIdList.add(f.get("id").toString()));
}
}
//分部类型
10 months ago
log.debug("subCompanyIdInfos : " + subCompanyIdInfos);
for (Map<String, String> map : subCompanyIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息
String querySql = "select * from hrmresource where subcompanyid1 = " + id;
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
List<Map<String,Object>> datas = DbTools.getSqlToListKeySmallLetter(querySql);
10 months ago
log.debug("querySql : " + querySql);
if (datas.size() > 0) {
10 months ago
log.debug("datas.size : " + datas.size());
datas.forEach(f -> empIdList.add(f.get("id").toString()));
}
}
return empIdList;
}
/**
* iddataIdmodeId
* >>>1234
* @param dataId
* @param modeId
* @return
*/
public static Map<String, Integer> getEmpIdWithPriority(String dataId,String modeId) {
Map<String, Integer> empMap = new HashMap<>();
String sql = "select dxlx,aqjb,dx from uf_jcl_syzz where modeid=? and dataid = ?";
//适用组织所有值集合
List<Map<String,Object>> organizationList = DbTools.getSqlToListKeySmallLetter(sql,modeId, dataId);
//分组
List<Map<String, String>> empIdInfos = new ArrayList<>();
List<Map<String, String>> empGroupIdInfos = new ArrayList<>();
List<Map<String, String>> depIdInfos = new ArrayList<>();
List<Map<String, String>> subCompanyIdInfos = new ArrayList<>();
for (Map<String,Object> organization : organizationList){
String id = Util.null2String(organization.get("dx")).split("-")[0];
String securityLevel = Util.null2String(organization.get("aqjb"));
String[] securityLevelArr = securityLevel.split("-");
String minSecurityLevel = securityLevel.substring(0, 1).equals("-") ? "" : securityLevelArr[0];
String maxSecurityLevel = "";
if (securityLevelArr.length == 1 && !securityLevelArr[0].equals(minSecurityLevel)) {
maxSecurityLevel = securityLevelArr[0];
} else if (securityLevelArr.length == 2) {
maxSecurityLevel = securityLevelArr[1];
}
if (ApplicableOrganizationEnum.PERSONNEL.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
empIdInfos.add(infoItem);
}else if (ApplicableOrganizationEnum.PERSONNEL_GROUP.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
empGroupIdInfos.add(infoItem);
}else if (ApplicableOrganizationEnum.DEPARTMENT.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
depIdInfos.add(infoItem);
}else if (ApplicableOrganizationEnum.SUBCOMPANY.getKey().equals(organization.get("dxlx"))){
Map<String,String> infoItem = new HashMap<>();
infoItem.put("id", id);
infoItem.put("minSecurityLevel", minSecurityLevel);
infoItem.put("maxSecurityLevel", maxSecurityLevel);
subCompanyIdInfos.add(infoItem);
}
}
//人员类型
log.debug("empIdInfos : " + empIdInfos);
for (Map<String, String> map : empIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息
String querySql = "select * from hrmresource where id = " + id;
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
Map<String,Object> data = DbTools.getSqlToMap(querySql);
log.debug("querySql : " + querySql);
if (data.size() > 0) {
empMap.put(id, 1);
}
}
//人员分组类型
log.debug("empGroupIdInfos : " + empGroupIdInfos);
for (Map<String, String> map : empGroupIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//获取分组包含人员id
Set<String> empIdsByGroup = getEmpGroupUserIds(id);
log.debug("empGroupId : " + id + ", empIdsByGroup : " + empIdsByGroup);
//查询目标人员信息
if (empIdsByGroup.size() > 0) {
String querySql = "select * from hrmresource where id in ("+String.join(",",empIdsByGroup)+")";
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
List<Map<String,Object>> datas = DbTools.getSqlToListKeySmallLetter(querySql);
log.debug("querySql : " + querySql);
if (datas.size() > 0) {
log.debug("datas.size : " + datas.size());
datas.forEach(f -> {
empMap.putIfAbsent(f.get("id").toString(), 2);
});
}
}
}
//部门类型
log.debug("depIdInfos : " + depIdInfos);
for (Map<String, String> map : depIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息
String querySql = "select * from hrmresource where departmentid = " + id;
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
List<Map<String,Object>> datas = DbTools.getSqlToListKeySmallLetter(querySql);
log.debug("querySql : " + querySql);
if (datas.size() > 0) {
log.debug("datas.size : " + datas.size());
datas.forEach(f -> {
empMap.putIfAbsent(f.get("id").toString(), 3);
});
}
}
//分部类型
log.debug("subCompanyIdInfos : " + subCompanyIdInfos);
for (Map<String, String> map : subCompanyIdInfos) {
String id = map.get("id");
String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息
String querySql = "select * from hrmresource where subcompanyid1 = " + id;
if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel;
}
if (!maxSecurityLevel.equals("")) {
querySql = querySql + " and seclevel <= " +maxSecurityLevel;
}
List<Map<String,Object>> datas = DbTools.getSqlToListKeySmallLetter(querySql);
log.debug("querySql : " + querySql);
if (datas.size() > 0) {
log.debug("datas.size : " + datas.size());
datas.forEach(f -> {
empMap.putIfAbsent(f.get("id").toString(), 4);
});
}
}
return empMap;
}
/**
*
* @param empGroupId
* @return id
*/
10 months ago
public static Set<String> getEmpGroupUserIds(String empGroupId){
String sql = "select b.mainid,b.empid,b.filters,b.bdate,b.edate,a.list_type,b.sqltj from uf_ryqz a left join uf_ryqz_dt1 b on a.id=b.mainid where mainid = " + empGroupId;
List<Map<String,Object>> personGroupDataList = DbTools.getSqlToListKeySmallLetter(sql);
10 months ago
Set<String> empIdList = Sets.newHashSet();
for (Map<String,Object> personGroupData :personGroupDataList){
String id = Util.null2String(personGroupData.get("mainid"));
String empid = Util.null2String(personGroupData.get("empid"));
String filters = Util.null2String(personGroupData.get("filters"));
String list_type = Util.null2String(personGroupData.get("list_type"));
String sqltj = Util.null2String(personGroupData.get("sqltj"));
if ("0".equals(list_type) && !"".equals(empid)){
//人员清单
empIdList.add(empid);
}else if ("1".equals(list_type) && !"".equals(filters)){
//条件清单
sql = "select id,seclevel from hrmresource where 1=1 ";
10 months ago
filters = filters.replace("","and");
filters = filters.replace("","or");
if (filters.contains("field")){
10 months ago
sql = "select a.id,a.seclevel from hrmresource a left join cus_fielddata b on a.id=b.id where scope='HrmCustomFieldByInfoType' and "+filters;
}else {
sql = sql+ " and "+filters;
}
10 months ago
log.debug("getPersonnelGroupingByPerson filter sql : {}",sql);
List<Map<String,Object>> dataList = DbTools.getSqlToListKeySmallLetter(sql);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
String seclevel = Util.null2String(dataMap.get("seclevel"));
empIdList.add(hrmId);
}
}else if ("2".equals(list_type) && !"".equals(sqltj)){
8 months ago
sqltj = Utils.converSQL(sqltj);
log.info("getPersonnelGroupingByPerson sqltj : [{}]",sqltj);
List<Map<String,Object>> dataList = DbTools.getSqlToList(sqltj);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
empIdList.add(hrmId);
}
}
}
return empIdList;
}
1 year ago
/**
* id-
* @param empGroupId id
* @return
*/
public static Map<String, Object> getEmpGroupUserInfo(String empGroupId){
String sql = "select b.mainid,b.empid,b.filters,b.bdate,b.edate,a.list_type,b.sqltj from uf_ryqz a left join uf_ryqz_dt1 b on a.id=b.mainid where mainid = " + empGroupId;
List<Map<String,Object>> personGroupDataList = DbTools.getSqlToListKeySmallLetter(sql);
Map<String, Object> empGroupUserInfo = new HashMap<>();
Map<String, Object> forceTimeItem = null;
List<Map<String, Object>> forceTimeItemList = null;
for (Map<String,Object> personGroupData :personGroupDataList){
String id = Util.null2String(personGroupData.get("mainid"));
String empid = Util.null2String(personGroupData.get("empid"));
String bdate = Util.null2String(personGroupData.get("bdate"));
String edate = Util.null2String(personGroupData.get("edate"));
String filters = Util.null2String(personGroupData.get("filters"));
String list_type = Util.null2String(personGroupData.get("list_type"));
String sqltj = Util.null2String(personGroupData.get("sqltj"));
if ("0".equals(list_type) && !"".equals(empid)){
//人员清单
empGroupUserInfo.put("listType", PersonGroupListTypeEnum.PERSON.getKey());
forceTimeItem = new HashMap<>();
forceTimeItem.put("startDate", bdate);
forceTimeItem.put("endDate", edate);
empGroupUserInfo.put(empid, forceTimeItem);
}else if ("1".equals(list_type) && !"".equals(filters)){
empGroupUserInfo.put("listType", PersonGroupListTypeEnum.CONDITION.getKey());
//条件清单
sql = "select id,seclevel from hrmresource where 1=1 ";
10 months ago
filters = filters.replace("","and");
filters = filters.replace("","or");
if (filters.contains("field")){
10 months ago
sql = "select a.id,a.seclevel from hrmresource a left join cus_fielddata b on a.id=b.id where scope='HrmCustomFieldByInfoType' and "+filters;
}else {
sql = sql+ " and "+filters;
}
10 months ago
log.debug("getPersonnelGroupingByPerson filter sql : {}",sql);
List<Map<String,Object>> dataList = DbTools.getSqlToListKeySmallLetter(sql);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
String seclevel = Util.null2String(dataMap.get("seclevel"));
if (empGroupUserInfo.get(hrmId) == null) {
forceTimeItemList = new ArrayList<>();
forceTimeItem = new HashMap<>();
forceTimeItem.put("startDate", bdate);
forceTimeItem.put("endDate", edate);
forceTimeItemList.add(forceTimeItem);
empGroupUserInfo.put(hrmId, forceTimeItemList);
} else {
List<Map<String, Object>> existForceTimeItemList = (List<Map<String, Object>>) empGroupUserInfo.get(hrmId);
forceTimeItem = new HashMap<>();
forceTimeItem.put("startDate", bdate);
forceTimeItem.put("endDate", edate);
existForceTimeItemList.add(forceTimeItem);
empGroupUserInfo.put(hrmId, existForceTimeItemList);
}
}
}else if ("2".equals(list_type) && !"".equals(sqltj)){
empGroupUserInfo.put("listType", PersonGroupListTypeEnum.SQLCONDITION.getKey());
8 months ago
sqltj = Utils.converSQL(sqltj);
log.info("getPersonnelGroupingByPerson sqltj : [{}]",sqltj);
List<Map<String,Object>> dataList = DbTools.getSqlToList(sqltj);
log.info("dataList_size :{}",dataList.size());
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
if (empGroupUserInfo.get(hrmId) == null) {
forceTimeItemList = new ArrayList<>();
forceTimeItem = new HashMap<>();
forceTimeItem.put("startDate", bdate);
forceTimeItem.put("endDate", edate);
forceTimeItemList.add(forceTimeItem);
empGroupUserInfo.put(hrmId, forceTimeItemList);
} else {
List<Map<String, Object>> existForceTimeItemList = (List<Map<String, Object>>) empGroupUserInfo.get(hrmId);
forceTimeItem = new HashMap<>();
forceTimeItem.put("startDate", bdate);
forceTimeItem.put("endDate", edate);
existForceTimeItemList.add(forceTimeItem);
empGroupUserInfo.put(hrmId, existForceTimeItemList);
}
}
}
}
return empGroupUserInfo;
}
/**
* 使
* @return
*/
public static List<String> getJqInfoWithAmount() {
List<String> jqIdList = new ArrayList<>();
//来自假期额度
String sql1 = "select * from uf_jcl_kq_jqed where gzzt = 0";
List<Map<String,Object>> data1 = DbTools.getSqlToList(sql1);
for (Map<String, Object> map : data1) {
jqIdList.add(Util.null2String(map.get("jb")));
}
//来自加班类型的考勤项目中关联的假期类型
String sql2 = "select * from uf_jcl_kq_kqxm where xmlx = 4 and jbzdzjqye = 1";
List<Map<String,Object>> data2 = DbTools.getSqlToList(sql2);
for (Map<String, Object> map : data2) {
String jqId = Util.null2String(map.get("zrdjb"));
if (!"".equals(jqId)) {
jqIdList.add(jqId);
}
}
jqIdList = jqIdList.stream().distinct().collect(Collectors.toList());
return jqIdList;
}
/**
11 months ago
*
* @param userId
* @param date
* @return
*/
11 months ago
public static String getRqlx(String userId,String date){
String modeId = Utils.getFormmodeIdMap().get("uf_jcl_kq_rlmc");
Set<String> calendarSetIdsSets = CommonUtil.getDataIds(userId,modeId,DateUtil.getCurrentDate());
10 months ago
log.debug("getRqlx calendarSetIdsSets : [{}]",calendarSetIdsSets);
String rqlx = "";
if (calendarSetIdsSets.size() > 0){
String sql = "select rqlx from uf_jcl_kq_rlxx where rlmc=? and rq=?";
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql,calendarSetIdsSets.toArray()[0],date);
if (dataList.size() > 0){
rqlx = dataList.get(0).get("rqlx").toString();
}else {
sql = "select subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql,userId);
String subcompanyid1 = departMentMap.get("subcompanyid1").toString();
rqlx = Utils.getDefaultDateType(subcompanyid1,date);
}
}else {
String sql = "select subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql,userId);
String subcompanyid1 = departMentMap.get("subcompanyid1").toString();
rqlx = Utils.getDefaultDateType(subcompanyid1,date);
}
return rqlx;
}
11 months ago
/**
*
* @param userId
* @param year
* @return
*/
public static List<Map<String,Object>> getYearCalendarList(String userId,String year){
String modeId = Utils.getFormmodeIdMap().get("uf_jcl_kq_rlmc");
Set<String> calendarSetIdsSets = CommonUtil.getDataIds(userId,modeId,DateUtil.getCurrentDate());
10 months ago
log.debug("getRqlx calendarSetIdsSets : [{}]",calendarSetIdsSets);
11 months ago
List<Map<String,Object>> resultList = Lists.newArrayList();
if (calendarSetIdsSets.size() > 0){
String sql = "select rqlx,rq from uf_jcl_kq_rlxx where rlmc=? and nd=?";
11 months ago
resultList = DbTools.getSqlToList(sql,calendarSetIdsSets.toArray()[0],year);
if (resultList.size() == 0){
sql = "select subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql,userId);
String subcompanyid1 = departMentMap.get("subcompanyid1").toString();
resultList = Utils.getDefaultDateList(subcompanyid1,year);
}
}else {
String sql = "select subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql,userId);
String subcompanyid1 = departMentMap.get("subcompanyid1").toString();
resultList = Utils.getDefaultDateList(subcompanyid1,year);
}
return resultList;
}
/**
*
* @param classId
* @return
*/
public static String ifrestByClass(String classId){
String sql = "select id,sfxx from uf_jcl_kq_bcxx where id = ?";
List<Map<String,Object>> list = DbTools.getSqlToList(sql,classId);
if (list.size() > 0){
return Util.null2String(list.get(0).get("sfxx")).equals("") ?CheckBoxEnum.UNCHECKED.getValue() : Util.null2String(list.get(0).get("sfxx"));
}else {
return CheckBoxEnum.UNCHECKED.getKey();
}
}
/**
* id
* @return
*/
public static Map<String, String> empIdToNameInfo(List<String> empIds) {
Map<String, String> resultMap = new HashMap<>();
String sql = "select id,lastname from hrmresource";
if (empIds != null && empIds.size() > 0) {
sql = sql + " where id in (" + String.join(",", empIds) + ")";
}
List<Map<String,Object>> list = DbTools.getSqlToList(sql);
for (Map<String, Object> map : list) {
resultMap.put(map.get("id").toString(), Util.null2String(map.get("lastname")));
}
return resultMap;
}
/**
* id
* @return
*/
public static Map<String, String> subCompanyIdToNameInfo() {
Map<String, String> resultMap = new HashMap<>();
String sql = "select id,subcompanyname from hrmsubcompany";
List<Map<String,Object>> list = DbTools.getSqlToList(sql);
for (Map<String, Object> map : list) {
resultMap.put(map.get("id").toString(), Util.null2String(map.get("subcompanyname")));
}
return resultMap;
}
/**
* id
* @return
*/
public static Map<String, String> depIdToNameInfo() {
Map<String, String> resultMap = new HashMap<>();
String sql = "select id,departmentname from hrmdepartment";
List<Map<String,Object>> list = DbTools.getSqlToList(sql);
for (Map<String, Object> map : list) {
resultMap.put(map.get("id").toString(), Util.null2String(map.get("departmentname")));
}
return resultMap;
}
/**
* id
* @return
*/
public static Map<String, String> kqxmIdToNameInfo() {
Map<String, String> resultMap = new HashMap<>();
String sql = "select id,mc from uf_jcl_kq_kqxm";
List<Map<String,Object>> list = DbTools.getSqlToList(sql);
for (Map<String, Object> map : list) {
resultMap.put(map.get("id").toString(), Util.null2String(map.get("mc")));
}
return resultMap;
}
10 months ago
/**
*
*/
public static void initExtensionClassHolder(){
10 months ago
String sql = "select id,jkdzlwj,jkdzsxlx,zt,zhsx,jkdzdybc from uf_jcl_kq_ywdmjc where zt=0";
10 months ago
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql);
10 months ago
sql = "select a.id,b.csmc,b.csz from uf_jcl_kq_ywdmjc a left join uf_jcl_kq_ywdmjc_dt1 b on a.id=b.mainid where a.zt=0";
Map<String,List<Map<String,Object>>> detailDataGroupMap = DbTools.getSqlToList(sql).stream().collect(Collectors.groupingBy(e->e.get("id").toString()));
10 months ago
try {
/**
*
*/
10 months ago
List<AbstractAdjustClockPointAction> adjustClockPointAction = Lists.newArrayList();
10 months ago
List<Map<String,Object>> adjustClockPointActionResultList = dataList.stream().filter(e->"0".equals(e.get("jkdzsxlx"))).sorted(Comparator.comparing(e->Integer.valueOf(e.get("zhsx").toString()))).collect(Collectors.toList());
for (Map<String,Object> adjustClockPointActionMap:adjustClockPointActionResultList){
String classPath = adjustClockPointActionMap.get("jkdzlwj").toString();
10 months ago
AbstractAdjustClockPointAction action = (AbstractAdjustClockPointAction)Class.forName(classPath).newInstance();
action.setApplyClasses(Util.null2String(adjustClockPointActionMap.get("jkdzdybc")));
List<Map<String,Object>> detailDataList = detailDataGroupMap.get(adjustClockPointActionMap.get("id"));
if (detailDataList != null && detailDataList.size() > 0){
Map<String,String> paramMap = Maps.newHashMap();
for (Map<String,Object> detailData:detailDataList){
paramMap.put(Util.null2String(detailData.get("csmc")),Util.null2String(detailData.get("csz")));
}
action.setParams(paramMap);
}
10 months ago
adjustClockPointAction.add(action);
}
ExtensionClassHolder.setAdjustClockPointAction(adjustClockPointAction);
/**
*
*/
sql = "select csm id,csz name from uf_jcl_kq_globalset where zt=0";
Map<String,Object> globalMap = DbTools.getSqlToMapList(sql);
ExtensionClassHolder.setGlobalSetMap(globalMap);
/**
*
*/
ExtensionClassHolder.setPersonBelongGroupThreadLocal(PersongroupCommonUtil.getAllpersonBelongGroup());
/**
*
*/
initPersonInfromation();
10 months ago
}catch (Exception e){
log.error("initExtensionClassHolder fail");
throw new AttendanceRunTimeException("初始化扩展类失败");
}
}
/**
*
*/
public static void initPersonInfromation(){
/**
*
*/
try {
String sql = "select id,departmentid,subcompanyid1 from hrmresource";
List<Map<String,Object>> hrmresourceList = DbTools.getSqlToList(sql);
Map<String,Map<String,Object>> hrmresourceInformationMap = Maps.newHashMap();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
Map<String,String> departInfo = Maps.newHashMap();
for (Map<String,Object> map :hrmresourceList){
String pdeptids = departInfo.get(Util.null2String(map.get("departmentid")));
if (pdeptids == null || pdeptids.equals("")){
pdeptids="";
pdeptids = departmentComInfo.getAllParentDepartId(Util.null2String(map.get("departmentid")), pdeptids);
pdeptids = Util.null2String(map.get("departmentid")) + pdeptids;
departInfo.put(Util.null2String(map.get("departmentid")),pdeptids);
}
map.put("pdeptids",pdeptids);
hrmresourceInformationMap.put(map.get("id").toString(),map);
}
ExtensionClassHolder.setPersonInformationThreadLocal(hrmresourceInformationMap);
ExtensionClassHolder.setPetDepartMentThreadLocal(departInfo);
}catch (Exception e){
log.error("initPersonInfromation fail");
throw new AttendanceRunTimeException("初始化人员信息失败");
}
}
10 months ago
/**
*
* @param itemMap
* @param bdlx
* @return
*/
public static Map<String,Object> assembleAskForOrEvectionItem(Map<String,Object> itemMap,String bdlx){
List<Map<String,Object>> sonItems = (List<Map<String,Object>>)itemMap.get("sonItems");
String workfor = Utils.getWorkFor(bdlx);
if (sonItems != null && sonItems.size() > 0){
for (Map<String,Object> sonItem:sonItems){
String zysd = Util.null2String(sonItem.get("zysd"));
if (zysd.equals(workfor)){
return sonItem;
}
10 months ago
}
}
return null;
}
/**
* @param empId id
* @param date
* @return
*/
public static List<Map<String,Object>> getAttendanceItemsByEmpIdDate(String empId, String date) {
String modeId = Utils.getFormmodeIdMap().get("uf_jcl_kq_kqfa");
Map<String,Object> resultMap = Maps.newHashMap();
String sql = "select dxlx,dataid,dx from uf_jcl_syzz where modeid=?";
List<Map<String,Object>> organizationList = DbTools.getSqlToList(sql,modeId);
sql = "select id,departmentid,subcompanyid1 from hrmresource where id =?";
Map<String,Object> departMentMap = DbTools.getSqlToMap(sql, empId);
Set<String> dataIds = Sets.newHashSet();
Map<String, List<Map<String,Object>>> organizationListGroupBydxlx = organizationList.stream().collect(Collectors.groupingBy(e ->e.get("dxlx").toString()));
//对象类型为人员
List<Map<String,Object>> personOrganizationList = organizationListGroupBydxlx.get("0");
//对象类型为人员组织
List<Map<String,Object>> personGroupOrganizationList = organizationListGroupBydxlx.get("1");
//对象类型为部门
List<Map<String,Object>> departmentOrganizationList = organizationListGroupBydxlx.get("2");
//对象类型为分部
List<Map<String,Object>> subCompanyOrganizationList = organizationListGroupBydxlx.get("3");
if (personOrganizationList != null){
for (Map<String,Object> personOrganization :personOrganizationList){
String dx = Util.null2String(personOrganization.get("dx"));
String ids = dx.split("-")[0];
if (ids.equals(empId)){
dataIds.add(Util.null2String(personOrganization.get("dataid")));
}
}
}
try {
if (departmentOrganizationList != null){
String deptid = Util.null2String(departMentMap.get("departmentid"));
String pdeptids = "";
pdeptids = new DepartmentComInfo().getAllParentDepartId(Util.null2String(departMentMap.get("departmentid")), pdeptids);
pdeptids = deptid + pdeptids;
for (Map<String,Object> departmentOrganization :departmentOrganizationList){
String dx = Util.null2String(departmentOrganization.get("dx"));
String ids = dx.split("-")[0];
for (String pdeptid : pdeptids.split(",")){
if (pdeptid.equals(ids)){
dataIds.add(Util.null2String(departmentOrganization.get("dataid")));
}
}
}
}
}catch (Exception e){
log.error("catch error :{}",e);
}
if (subCompanyOrganizationList != null){
String subCompanyId = Util.null2String(departMentMap.get("subcompanyid1"));
for (Map<String,Object> subCompanyOrganization :subCompanyOrganizationList){
String dx = Util.null2String(subCompanyOrganization.get("dx"));
String ids = dx.split("-")[0];
if (ids.equals(subCompanyId)){
dataIds.add(Util.null2String(subCompanyOrganization.get("dataid")));
}
}
}
if (personGroupOrganizationList != null){
Set<String> personGroupIds = personGroupOrganizationList.stream().map(e -> Util.null2String(e.get("dx")).split("-")[0]).collect(Collectors.toSet());
sql = "select mainid,empid,filters,sqltj,bdate,edate from uf_ryqz_dt1 where mainid in ("+String.join(",",personGroupIds)+")";
List<Map<String,Object>> personGroupData = DbTools.getSqlToList(sql);
Set<String> personnelGroupIds = PersongroupCommonUtil.getPersonnelGroupingByPerson(personGroupData, empId,date);
for (Map<String,Object> personGroupOrganization :personGroupOrganizationList){
String personnelGroupId = Util.null2String(personGroupOrganization.get("dx")).split("-")[0];
if (personnelGroupIds.contains(personnelGroupId)){
dataIds.add(Util.null2String(personGroupOrganization.get("dataid")));
}
}
}
//收集通用考勤项目
sql = "select id keyid,mc kqxm,a.* from uf_jcl_kq_kqxm a where tyxm=1 and (xmzt is null or xmzt <> '0')";
List<Map<String,Object>> attendanceItems = DbTools.getSqlToList(sql);
//收集目标人员适用考勤方案中的考勤项目
if (dataIds.size() > 0){
sql = "select b.id keyid,b.mc kqxm,c.mc famc,b.* from uf_jcl_kq_kqfa_dt1 a left join uf_jcl_kq_kqxm b on a.kqxm=b.id left join uf_jcl_kq_kqfa c on a.mainid=c.id " +
"where mainid in ("+String.join(",",dataIds)+") and (b.xmzt is null or b.xmzt <> '0') " +
"and c.zt = 0 and (c.sxrq0 is null or c.sxrq0 <= ?) and (c.sxrq1 is null or c.sxrq1 >= ?)";
attendanceItems.addAll(DbTools.getSqlToList(sql, date, date));
}
return attendanceItems;
}
10 months ago
/**
*
* @param empDateList id
* @param status
* @return
*/
public static String updateAttendanceResultInfoStatus(List<Map<String, String>> empDateList, String status) {
String errorMessage = "";
List<String> empIdList = empDateList.stream().filter(f-> !"".equals(Util.null2String(f.get("empId")))).map(f->f.get("empId")).collect(Collectors.toList());
Map<String, String> empNameInfo = empIdToNameInfo(empIdList);
String empId = "";
String cqDate = "";
String sql = "update uf_jcl_kq_cqjg set sjzt = ? where ygid = ? and rq = ?";
for (Map<String, String> empDateInfo : empDateList) {
empId = Util.null2String(empDateInfo.get("empId"));
cqDate = Util.null2String(empDateInfo.get("cqDate"));
if (!"".equals(empId) && !"".equals(cqDate)) {
if (!DbTools.update(sql, status, empId, cqDate)) {
errorMessage = errorMessage + empNameInfo.getOrDefault(empId, empId) + "," + cqDate + "出勤结果数据状态更新失败;";
}
}
}
return errorMessage;
}
7 months ago
/**
*
* @param departEmployeeList
* @return
*/
public static Map<String,Object> getDepartEmployeeMap(List<Map<String,Object>> departEmployeeList){
Map<String,List<Map<String,Object>>> group = departEmployeeList.stream().collect(Collectors.groupingBy(e -> Util.null2String(e.get("resourceid"))));
Map<String,Object> resultMap = Maps.newHashMap();
for (Map.Entry<String,List<Map<String,Object>>> entry: group.entrySet()){
String userid = entry.getKey();
List<Map<String,Object>> list = entry.getValue();
if (list.size() > 1){
list = list.stream().sorted(Comparator.comparing(e->DateUtil.getTime(e.get("changedate").toString()).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
}
if (list.size() > 0 && Util.null2String(list.get(list.size()-1).get("type_n")).equals("5")){
resultMap.put(userid,list.get(list.size()-1).get("changedate"));
}
}
return resultMap;
}
2 years ago
}