修改人员组织架构代码
parent
062b998ce5
commit
894e56b974
|
@ -113,7 +113,7 @@ public class Util extends weaver.general.Util {
|
|||
/**
|
||||
* 获取指定格式的当前时间
|
||||
*
|
||||
* @param format 格式化字符串
|
||||
* @param format 格式化字符串 yyyy-MM-dd
|
||||
* @return 指定格式日期的字符串
|
||||
*/
|
||||
public static String getTime(String format) {
|
||||
|
|
|
@ -64,6 +64,11 @@ public class ReadCsvUtil {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
throw new CustomerException("无法读取文件数据!", e);
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
return tableInfo;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ public class SftpConnectUtil extends ChannelSftp {
|
|||
File file = new File(localeFile);
|
||||
if (!file.exists()) {
|
||||
boolean mkdirs = file.getParentFile().mkdirs();
|
||||
if (!mkdirs) {
|
||||
if (!mkdirs && !file.getParentFile().exists()) {
|
||||
throw new CustomerException("无法创建目录(can not create dirs):[" + localeFile + "]");
|
||||
}
|
||||
} else {
|
||||
|
@ -177,7 +177,7 @@ public class SftpConnectUtil extends ChannelSftp {
|
|||
* @throws IOException IO异常
|
||||
*/
|
||||
public String downFileToSystemFilePath(String remoteFile, String localeFileName) throws IOException {
|
||||
return this.downFile(remoteFile, GCONST.getSysFilePath() + localeFileName);
|
||||
return this.downFile(remoteFile, GCONST.getSysFilePath() + "cus" + File.separatorChar + localeFileName);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
package weaver.youhong.ai.pcn.hrorganization.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import ebu7common.youhong.ai.csv.ReadCsvUtil;
|
||||
import ebu7common.youhong.ai.sftp.SftpConnectUtil;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Department;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Employee;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Position;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -21,18 +30,97 @@ public class OrganizationAsyncService {
|
|||
/**
|
||||
* csv文件数据
|
||||
*/
|
||||
public List<List<String>> getRemoteFileData(String fileName) {
|
||||
String userName = Util.getCusConfigValue("sftpUserName");
|
||||
String ipAddress = Util.getCusConfigValue("sftpIp");
|
||||
String sftpPort = Util.getCusConfigValue("sftpPort");
|
||||
private List<List<String>> getRemoteFileData(String fileName) {
|
||||
//String userName = Util.getCusConfigValue("sftpUserName");
|
||||
//String ipAddress = Util.getCusConfigValue("sftpIp");
|
||||
//String sftpPort = Util.getCusConfigValue("sftpPort");
|
||||
String userName = "HR Digital_PROD";
|
||||
String ipAddress = "58.246.33.86";
|
||||
String sftpPort = null;
|
||||
SftpConnectUtil sftpConnectUtil = new SftpConnectUtil(
|
||||
userName,
|
||||
GCONST.getRootPath() + "sftp" + File.separatorChar + "HR_Digital_PROD.pem",
|
||||
GCONST.getRootPath() + "ssl" + File.separatorChar + "HR_Digital_PROD.pem",
|
||||
null,
|
||||
ipAddress,
|
||||
Integer.parseInt(sftpPort), 1000 * 100);
|
||||
Integer.parseInt(sftpPort == null || "".equals(sftpPort) ? "22" : sftpPort), 1000 * 100);
|
||||
try {
|
||||
String localeFilePath = sftpConnectUtil.downFileToSystemFilePath(fileName, fileName + ".csv");
|
||||
List<List<String>> lists = ReadCsvUtil.readCsvFromPath(localeFilePath);
|
||||
Files.delete(Paths.get(localeFilePath));
|
||||
return lists;
|
||||
} catch (IOException e) {
|
||||
throw new CustomerException(Util.logStr("sftp下载文件[{}]出错!", fileName), e);
|
||||
} finally {
|
||||
sftpConnectUtil.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门数据
|
||||
*/
|
||||
public List<Employee> getEmployeeList() {
|
||||
List<Employee> dataList = new ArrayList<>();
|
||||
List<List<String>> employeeList = getRemoteFileData("HRIS_EmployeeExport" + "20221124");
|
||||
if (employeeList == null || employeeList.isEmpty()) {
|
||||
throw new CustomerException("获取人员数据信息失败!");
|
||||
}
|
||||
// 获取表头
|
||||
List<String> heard = employeeList.get(0);
|
||||
for (int i = 1; i < employeeList.size(); i++) {
|
||||
List<String> row = employeeList.get(i);
|
||||
for (int j = 0; j < row.size(); j++) {
|
||||
Employee employee = new Employee();
|
||||
employee.setValue(heard.get(j).replace(" ", "_").replace("-", "_"), row.get(j));
|
||||
dataList.add(employee);
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取部门数据
|
||||
*/
|
||||
public List<Department> getDepartmentList() {
|
||||
List<Department> dataList = new ArrayList<>();
|
||||
List<List<String>> departmentList = getRemoteFileData("HRIS_DepartmentExport" + "20221124");
|
||||
if (departmentList == null || departmentList.isEmpty()) {
|
||||
throw new CustomerException("获取部门数据信息失败!");
|
||||
}
|
||||
// 获取表头
|
||||
List<String> heard = departmentList.get(0);
|
||||
for (int i = 1; i < departmentList.size(); i++) {
|
||||
List<String> row = departmentList.get(i);
|
||||
for (int j = 0; j < row.size(); j++) {
|
||||
Department department = new Department();
|
||||
department.setValue(heard.get(j).replace(" ", "_").replace("-", "_"), row.get(j));
|
||||
dataList.add(department);
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取职位数据
|
||||
*/
|
||||
public List<Position> getPositionList() {
|
||||
List<Position> dataList = new ArrayList<>();
|
||||
List<List<String>> positionList = getRemoteFileData("HRIS_PositionExport" + "20221124");
|
||||
if (positionList == null || positionList.isEmpty()) {
|
||||
throw new CustomerException("获取职位数据信息失败!");
|
||||
}
|
||||
// 获取表头
|
||||
List<String> heard = positionList.get(0);
|
||||
for (int i = 1; i < positionList.size(); i++) {
|
||||
List<String> row = positionList.get(i);
|
||||
for (int j = 0; j < row.size(); j++) {
|
||||
Position position = new Position();
|
||||
position.setValue(heard.get(j).replace(" ", "_").replace("-", "_"), row.get(j));
|
||||
dataList.add(position);
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -72,7 +72,7 @@ public class SyncOrganizationForOtherAPI extends ToolUtil implements HrmSynServi
|
|||
getUnAsyncDepIdList();
|
||||
try {
|
||||
List<Department> departmentList = getOrganizationResult.getDepartmentList();
|
||||
Collections.sort(departmentList);
|
||||
//Collections.sort(departmentList);
|
||||
List<Map<String, Object>> synResultlist = new ArrayList<>();
|
||||
for (Department department : departmentList) {
|
||||
// 如果不启用就不执行
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package weaver.youhong.ai.pcn.hrorganization.wesmat.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author EBU7-dev1-ayh
|
||||
|
@ -8,12 +11,15 @@ import org.jetbrains.annotations.NotNull;
|
|||
* 部门实体类
|
||||
*/
|
||||
|
||||
|
||||
public class Department implements Comparable<Department> {
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public class Department {
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long DEPARTMENTID;
|
||||
private String DEPARTMENTID;
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
|
@ -23,10 +29,15 @@ public class Department implements Comparable<Department> {
|
|||
*/
|
||||
private Long PARENTDEPARTMENDID;
|
||||
|
||||
private String Company_Code_Company;
|
||||
|
||||
public Department() {
|
||||
}
|
||||
|
||||
|
||||
public String getValue(String fieldName) {
|
||||
if ("DEPARTMENTID".equals(fieldName)) {
|
||||
return String.valueOf(this.getDEPARTMENTID());
|
||||
return this.getDEPARTMENTID();
|
||||
}
|
||||
if ("DEPARTMENTNAME".equals(fieldName)) {
|
||||
return this.getDEPARTMENTNAME();
|
||||
|
@ -34,54 +45,25 @@ public class Department implements Comparable<Department> {
|
|||
if ("PARENTDEPARTMENDID".equals(fieldName)) {
|
||||
return String.valueOf(this.getPARENTDEPARTMENDID());
|
||||
}
|
||||
if ("Company_Code_Company".equals(fieldName)) {
|
||||
return getCompany_Code_Company();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Department() {
|
||||
public void setValue(String fieldName, String value) {
|
||||
if ("DEPARTMENTID".equals(fieldName)) {
|
||||
setDEPARTMENTID(value);
|
||||
}
|
||||
if ("DEPARTMENTNAME".equals(fieldName)) {
|
||||
setDEPARTMENTNAME(value);
|
||||
}
|
||||
if ("PARENTDEPARTMENDID".equals(fieldName)) {
|
||||
setPARENTDEPARTMENDID(Long.valueOf(value));
|
||||
}
|
||||
if ("Company_Code_Company".equals(fieldName)) {
|
||||
setCompany_Code_Company(value);
|
||||
}
|
||||
}
|
||||
|
||||
public Department(Long DEPARTMENTID, String DEPARTMENTNAME, Long PARENTDEPARTMENDID) {
|
||||
this.DEPARTMENTID = DEPARTMENTID;
|
||||
this.DEPARTMENTNAME = DEPARTMENTNAME;
|
||||
this.PARENTDEPARTMENDID = PARENTDEPARTMENDID;
|
||||
}
|
||||
|
||||
public Long getDEPARTMENTID() {
|
||||
return DEPARTMENTID;
|
||||
}
|
||||
|
||||
public void setDEPARTMENTID(Long DEPARTMENTID) {
|
||||
this.DEPARTMENTID = DEPARTMENTID;
|
||||
}
|
||||
|
||||
public String getDEPARTMENTNAME() {
|
||||
return DEPARTMENTNAME;
|
||||
}
|
||||
|
||||
public void setDEPARTMENTNAME(String DEPARTMENTNAME) {
|
||||
this.DEPARTMENTNAME = DEPARTMENTNAME;
|
||||
}
|
||||
|
||||
public Long getPARENTDEPARTMENDID() {
|
||||
return PARENTDEPARTMENDID;
|
||||
}
|
||||
|
||||
public void setPARENTDEPARTMENDID(Long PARENTDEPARTMENDID) {
|
||||
this.PARENTDEPARTMENDID = PARENTDEPARTMENDID;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Department{" +
|
||||
"DEPARTMENTID='" + DEPARTMENTID + '\'' +
|
||||
", DEPARTMENTNAME='" + DEPARTMENTNAME + '\'' +
|
||||
", PARENTDEPARTMENDID='" + PARENTDEPARTMENDID + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull Department o) {
|
||||
return new Long(this.PARENTDEPARTMENDID - o.getPARENTDEPARTMENDID()).intValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,52 @@ public class Employee implements Comparable<Employee> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setValue(String fieldName, String value) {
|
||||
if ("UserID".equals(fieldName)) {
|
||||
setUserID(Long.valueOf(null == value || "".equals(value) ? "-1" : value));
|
||||
}
|
||||
if ("FIRSTNAMEEN".equals(fieldName)) {
|
||||
setFIRSTNAMEEN(value);
|
||||
}
|
||||
if ("LASTNAMEEN".equals(fieldName)) {
|
||||
setLASTNAMEEN(value);
|
||||
}
|
||||
if ("USERNAMECN".equals(fieldName)) {
|
||||
setUSERNAMECN(value);
|
||||
}
|
||||
if ("USERCODE".equals(fieldName)) {
|
||||
setUSERCODE(value);
|
||||
}
|
||||
if ("JOBCODEID".equals(fieldName)) {
|
||||
setJOBCODEID(Long.valueOf(null == value || "".equals(value) ? "-1" : value));
|
||||
}
|
||||
if ("DEPARTMENTID".equals(fieldName)) {
|
||||
setDEPARTMENTID(Long.valueOf(null == value || "".equals(value) ? "-1" : value));
|
||||
}
|
||||
if ("DEPARTMENTNAME".equals(fieldName)) {
|
||||
setDEPARTMENTNAME(value);
|
||||
}
|
||||
if ("COSTCENTERCODE".equals(fieldName)) {
|
||||
setCOSTCENTERCODE(value);
|
||||
}
|
||||
if ("EMAIL".equals(fieldName)) {
|
||||
setEMAIL(value);
|
||||
}
|
||||
if ("ORGANIZATION".equals(fieldName)) {
|
||||
setORGANIZATION(value);
|
||||
}
|
||||
if ("MOBILENO".equals(fieldName)) {
|
||||
setMOBILENO(value);
|
||||
}
|
||||
if ("TEL".equals(fieldName)) {
|
||||
setTEL(value);
|
||||
}
|
||||
if ("Preferred_Name".equals(fieldName)) {
|
||||
setPreferred_Name(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Employee() {
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,27 @@ public class Position implements Comparable<Position> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setValue(String fieldName, String value) {
|
||||
if ("JOBCODEID".equals(fieldName)) {
|
||||
setJOBCODEID(Long.parseLong(null == value || "".equals(value) ? "-1" : value));
|
||||
}
|
||||
if ("JOBCODE".equals(fieldName)) {
|
||||
setJOBCODE(value);
|
||||
}
|
||||
if ("JOBFUNCTION".equals(fieldName)) {
|
||||
setJOBFUNCTION(value);
|
||||
}
|
||||
if ("SUPERIORJOBCODEID".equals(fieldName)) {
|
||||
setSUPERIORJOBCODEID(Long.parseLong(null == value || "".equals(value) ? "-1" : value));
|
||||
}
|
||||
if ("POSITIONOCCUPIED".equals(fieldName)) {
|
||||
setPOSITIONOCCUPIED(Long.parseLong(null == value || "".equals(value) ? "-1" : value));
|
||||
}
|
||||
if ("Company_Code".equals(fieldName)) {
|
||||
setCompany_Code(value);
|
||||
}
|
||||
}
|
||||
|
||||
public Position() {
|
||||
}
|
||||
|
||||
|
@ -129,4 +150,6 @@ public class Position implements Comparable<Position> {
|
|||
", Company_Code='" + Company_Code + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package weaver.youhong.ai.pcn.hrorganization.wesmat.result;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.config.SyncOrganizationConfig;
|
||||
import weaver.youhong.ai.pcn.hrorganization.service.OrganizationAsyncService;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Department;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Employee;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Position;
|
||||
|
@ -17,33 +15,26 @@ import java.util.List;
|
|||
|
||||
|
||||
public class GetOrganizationResult {
|
||||
private final OrganizationAsyncService organizationAsyncService = new OrganizationAsyncService();
|
||||
|
||||
/**
|
||||
* 获取员工数据
|
||||
*/
|
||||
public List<Employee> getEmployeeList() {
|
||||
SyncOrganizationConfig<Employee> employeeSyncOrganizationConfig = new SyncOrganizationConfig<>();
|
||||
List<Employee> dataList = employeeSyncOrganizationConfig.getDataList(employeeSyncOrganizationConfig.getEMPLOYEE_API_RUL());
|
||||
String jsonString = JSON.toJSON(dataList).toString();
|
||||
return (List<Employee>) JSONObject.parseArray(jsonString, Employee.class);
|
||||
return organizationAsyncService.getEmployeeList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门数据
|
||||
*/
|
||||
public List<Department> getDepartmentList() {
|
||||
SyncOrganizationConfig<Department> employeeSyncOrganizationConfig = new SyncOrganizationConfig<>();
|
||||
List<Department> dataList = employeeSyncOrganizationConfig.getDataList(employeeSyncOrganizationConfig.getDEPARTMENT_API_URL());
|
||||
String jsonString = JSON.toJSON(dataList).toString();
|
||||
return (List<Department>) JSONObject.parseArray(jsonString, Department.class);
|
||||
return organizationAsyncService.getDepartmentList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取职位数据
|
||||
*/
|
||||
public List<Position> getPositionList() {
|
||||
SyncOrganizationConfig<Position> employeeSyncOrganizationConfig = new SyncOrganizationConfig<>();
|
||||
List<Position> dataList = employeeSyncOrganizationConfig.getDataList(employeeSyncOrganizationConfig.getPOSITION_API_URL());
|
||||
String jsonString = JSON.toJSON(dataList).toString();
|
||||
return (List<Position>) JSONObject.parseArray(jsonString, Position.class);
|
||||
return organizationAsyncService.getPositionList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package youhong.ai.pcn;
|
||||
|
||||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import ebu7common.youhong.ai.sftp.SftpConnectUtil;
|
||||
import org.junit.Test;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Department;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Employee;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.model.Position;
|
||||
import weaver.youhong.ai.pcn.hrorganization.wesmat.result.GetOrganizationResult;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -41,10 +46,22 @@ public class TestOrganization extends BaseTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGeOrganizationData() {
|
||||
GetOrganizationResult getOrganizationResult = new GetOrganizationResult();
|
||||
List<Department> departmentList = getOrganizationResult.getDepartmentList();
|
||||
List<Employee> employeeList = getOrganizationResult.getEmployeeList();
|
||||
List<Position> positionList = getOrganizationResult.getPositionList();
|
||||
log.info(departmentList.size() + "::" + employeeList.size() + "::" + positionList.size());
|
||||
log.info(JSON.toJSONString(departmentList));
|
||||
log.info(JSON.toJSONString(employeeList));
|
||||
log.info(JSON.toJSONString(positionList));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStaticLog() {
|
||||
log.info("哈哈哈好的方式");
|
||||
log.info(this.getClass().getResource("/"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +127,5 @@ public class TestOrganization extends BaseTest {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue