|
|
|
@ -2,14 +2,18 @@ package com.weaver.seconddev.cockpit.cmd;
|
|
|
|
|
|
|
|
|
|
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
|
|
|
|
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
|
|
|
|
import com.weaver.seconddev.cockpit.util.CommonUtils;
|
|
|
|
|
import com.weaver.seconddev.cockpit.util.DatabaseUtils;
|
|
|
|
|
import com.weaver.seconddev.cockpit.util.JucailinCockpitUtils;
|
|
|
|
|
import com.weaver.teams.domain.user.SimpleEmployee;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -217,6 +221,13 @@ public class CockpitUserDataCmd {
|
|
|
|
|
List<Map<String, Object>> customList = getCustomType(employee, tenantKey);
|
|
|
|
|
recordMap.put("customType", customList);
|
|
|
|
|
|
|
|
|
|
String employeeId2 = String.valueOf(paramMap.get("userid"));
|
|
|
|
|
if (StringUtils.isNotBlank(employeeId2)) {
|
|
|
|
|
employeeId = employeeId2;
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> changeList = getEmpChangeData(employeeId, tenantKey);
|
|
|
|
|
recordMap.put("changeList", changeList);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("PortalPerformanceInfoCmd :" + e);
|
|
|
|
@ -238,6 +249,10 @@ public class CockpitUserDataCmd {
|
|
|
|
|
Long SubCompanyId = employee.getDepartment().getSubCompanyId();
|
|
|
|
|
log.error("CockpitUserDataCmd-test-SubCompanyId:" + SubCompanyId);
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
Date hireDate = employee.getHiredate();
|
|
|
|
|
log.error("hireDate:" + sdf.format(hireDate));
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -291,4 +306,202 @@ public class CockpitUserDataCmd {
|
|
|
|
|
return recordList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getEmpChangeData(String employeeId, String tenantKey) {
|
|
|
|
|
List<Map<String, Object>> changeList = new ArrayList<Map<String, Object>>();
|
|
|
|
|
String groupId = "weaver-ebuilder-form-service";
|
|
|
|
|
String sourceType = "LOGIC";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
//入职
|
|
|
|
|
Map<String, Object> hireMap = getEmployeeHireData(employeeId, tenantKey, groupId, sourceType);
|
|
|
|
|
if (hireMap != null && hireMap.size() > 0) {
|
|
|
|
|
changeList.add(hireMap);
|
|
|
|
|
}
|
|
|
|
|
//变更
|
|
|
|
|
List<Map<String, Object>> changeDataList = getEmployeeChangeData(employeeId, tenantKey, groupId, sourceType);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(changeDataList)) {
|
|
|
|
|
changeList.addAll(changeDataList);
|
|
|
|
|
}
|
|
|
|
|
// //离职
|
|
|
|
|
// Map<String,Object> departMap = getEmployeeDepartData(employeeId,tenantKey,groupId,sourceType);
|
|
|
|
|
// if(departMap !=null && departMap.size()>0){
|
|
|
|
|
// changeList.add(departMap);
|
|
|
|
|
// }
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("getEmpChangeData:" + e);
|
|
|
|
|
}
|
|
|
|
|
return changeList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
*
|
|
|
|
|
* @param employeeId
|
|
|
|
|
* @param tenantKey
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getEmployeeHireData(String employeeId, String tenantKey, String groupId, String sourceType) {
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
try {
|
|
|
|
|
String hiredate = "";
|
|
|
|
|
String dataSql = " select date_format(a.hiredate,'%Y-%m-%d') hiredate " +
|
|
|
|
|
" from eteams.employee a " +
|
|
|
|
|
" where a.id = ? " +
|
|
|
|
|
" and a.tenant_key = ? " +
|
|
|
|
|
" and a.status = 'normal' " +
|
|
|
|
|
" and a.type = 'inside'" +
|
|
|
|
|
" and delete_type = 0";
|
|
|
|
|
|
|
|
|
|
log.error("getuserIfo--dataSql:" + dataSql);
|
|
|
|
|
List<String> strlist = new ArrayList<>(100);
|
|
|
|
|
strlist.add(employeeId + "");
|
|
|
|
|
strlist.add(tenantKey);
|
|
|
|
|
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
|
|
|
|
|
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlparam);
|
|
|
|
|
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
|
|
|
|
Map<String, Object> recordMap = recordList.get(0);
|
|
|
|
|
hiredate = CommonUtils.null2String(recordMap.get("hiredate"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(hiredate)) {
|
|
|
|
|
map.put("changedate", hiredate);
|
|
|
|
|
map.put("operator_type", "entry");
|
|
|
|
|
map.put("operator_type_name", "入职");
|
|
|
|
|
map.put("data_type", "");
|
|
|
|
|
map.put("data_value", "");
|
|
|
|
|
map.put("change_id", "");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("getEmployeeHireData:" + e);
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public Map<String,Object> getEmployeeDepartData(Long employeeId,String tenantKey,String groupId,String sourceType){
|
|
|
|
|
//
|
|
|
|
|
// Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
// try {
|
|
|
|
|
// String hiredate = "";
|
|
|
|
|
// String dataSql =" select t.change_id,k.change_date,k.operator_type \n" +
|
|
|
|
|
// " from hrm_empchange_user t \n" +
|
|
|
|
|
// " inner join hrm_empchange k on k.id = t.change_id \n" +
|
|
|
|
|
// " where t.employeeid = ? \n" +
|
|
|
|
|
// " and t.delete_type = 0 \n" +
|
|
|
|
|
// " and t.tenant_key = ? " +
|
|
|
|
|
// " and k.delete_type = 0 \n" +
|
|
|
|
|
// " and k.tenant_key = ? " +
|
|
|
|
|
// " and k.batch_status = 2 \n" +
|
|
|
|
|
// " and k.operator_type = 'dismiss' ";
|
|
|
|
|
//
|
|
|
|
|
// log.error("getuserIfo--dataSql:" + dataSql);
|
|
|
|
|
// List<String> strlist = new ArrayList<>(100);
|
|
|
|
|
// strlist.add(employeeId + "");
|
|
|
|
|
// strlist.add(tenantKey);
|
|
|
|
|
// List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
|
|
|
|
|
// Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlparam);
|
|
|
|
|
// List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(recordList)) {
|
|
|
|
|
// Map<String, Object> recordMap = recordList.get(0);
|
|
|
|
|
// change_date = CommonUtils.null2String(recordMap.get("change_date"));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (StringUtils.isNotBlank(hiredate)) {
|
|
|
|
|
// map.put("changedate", hiredate);
|
|
|
|
|
// map.put("operator_type", "entry");
|
|
|
|
|
// map.put("operator_type_name", "入职");
|
|
|
|
|
// map.put("data_type", "");
|
|
|
|
|
// map.put("data_value", "");
|
|
|
|
|
// map.put("change_id", "");
|
|
|
|
|
// }
|
|
|
|
|
// }catch (Exception e){
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// log.error("getEmployeeHireData:"+e);
|
|
|
|
|
// }
|
|
|
|
|
// return map;
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getEmployeeChangeData(String employeeId, String tenantKey, String groupId, String sourceType) {
|
|
|
|
|
List<Map<String, Object>> changeList = new ArrayList<Map<String, Object>>();
|
|
|
|
|
try {
|
|
|
|
|
String dataSql = " select t.change_id,date_format(k.change_date,'%Y-%m-%d') change_date,k.operator_type,p.data_type,p.data_value \n" +
|
|
|
|
|
" from eteams.hrm_empchange_user t\n" +
|
|
|
|
|
" inner join eteams.hrm_empchange k on k.id = t.change_id\n" +
|
|
|
|
|
" inner join eteams.hrm_empchange_userdetail p on p.change_id = t.CHANGE_ID\n" +
|
|
|
|
|
" where t.employeeid = ?\n" +
|
|
|
|
|
" and length(p.data_value)>0\n" +
|
|
|
|
|
" and k.batch_status = 2' \n" +
|
|
|
|
|
" and t.delete_type = 0 \n" +
|
|
|
|
|
" and t.tenant_key = ? \n" +
|
|
|
|
|
" and p.delete_type = 0 \n" +
|
|
|
|
|
" and p.tenant_key = ? \n" +
|
|
|
|
|
" and k.delete_type = 0 \n" +
|
|
|
|
|
" and k.tenant_key = ? " +
|
|
|
|
|
" and p.data_type in('newDepartment','newPosition','newSuperior','changeStatus')\n " +
|
|
|
|
|
" order by k.change_date \n";
|
|
|
|
|
|
|
|
|
|
log.error("getuserIfo--dataSql:" + dataSql);
|
|
|
|
|
List<String> strlist = new ArrayList<>(100);
|
|
|
|
|
strlist.add(employeeId + "");
|
|
|
|
|
strlist.add(tenantKey);
|
|
|
|
|
strlist.add(tenantKey);
|
|
|
|
|
strlist.add(tenantKey);
|
|
|
|
|
List<SqlParamEntity> sqlparam = databaseUtils.getSqlParamEntity(strlist);
|
|
|
|
|
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlparam);
|
|
|
|
|
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
|
|
|
|
for (int i = 0; i < recordList.size(); i++) {
|
|
|
|
|
Map<String, Object> recordMap = recordList.get(i);
|
|
|
|
|
String operator_type = String.valueOf(recordMap.get("operator_type"));
|
|
|
|
|
String operator_type_name = "";
|
|
|
|
|
|
|
|
|
|
if ("trial".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "试用";
|
|
|
|
|
} else if ("hire".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "转正";
|
|
|
|
|
} else if ("extend".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "续签";
|
|
|
|
|
} else if ("redeploy".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "调动";
|
|
|
|
|
} else if ("dismiss".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "离职";
|
|
|
|
|
} else if ("retire".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "退休";
|
|
|
|
|
} else if ("quit".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "解聘";
|
|
|
|
|
} else if ("rehire".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "返聘";
|
|
|
|
|
} else if ("custom".equals(operator_type)) {
|
|
|
|
|
operator_type_name = "变更";
|
|
|
|
|
}
|
|
|
|
|
recordMap.put("operator_type_name", operator_type_name);
|
|
|
|
|
String data_type = String.valueOf(recordMap.get("data_type"));
|
|
|
|
|
String data_type_name = "";
|
|
|
|
|
String data_value = String.valueOf(recordMap.get("data_value"));
|
|
|
|
|
String data_value_name = "";
|
|
|
|
|
if ("newDepartment".equals(data_type)) {
|
|
|
|
|
data_type_name = "部门";
|
|
|
|
|
} else if ("newPosition".equals(data_type)) {
|
|
|
|
|
data_type_name = "岗位";
|
|
|
|
|
} else if ("newSuperior".equals(data_type)) {
|
|
|
|
|
data_type_name = "上级";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recordMap.put("data_type_name", data_type_name);
|
|
|
|
|
recordMap.put("data_value_name", data_value_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("getEmpChangeData:" + e);
|
|
|
|
|
}
|
|
|
|
|
return changeList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|