#3178759 人员入职、人员异动 接口开发

Z浙江泰鸿万立科技股份有限公司
dxfeng 10 months ago
parent 17378da9d4
commit 117dfe32d2

@ -4,15 +4,14 @@ import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import weaver.interfaces.thwl.action.sdk.AddRequest;
import weaver.interfaces.thwl.action.sdk.ArtemisUtil;
import weaver.interfaces.thwl.action.sdk.OrgInfoRequest;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@ -47,7 +46,6 @@ public class PersonSingleAddAction implements Action {
String mobile = "";
String certificateNum = "";
String workCode = "";
String departmentCode = "";
if (rs.next()) {
departmentId = rs.getString("departmentid");
lastName = rs.getString("lastname");
@ -58,22 +56,16 @@ public class PersonSingleAddAction implements Action {
workCode = rs.getString("workcode");
}
rs.executeQuery("select departmentcode from hrmdepartment where id = ? ", departmentId);
if (rs.next()) {
departmentCode = rs.getString("departmentcode");
}
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
String departmentMark = departmentComInfo.getDepartmentmark(departmentId);
String departmentCode = departmentComInfo.getDepartmentCode(departmentId);
if (StringUtils.isBlank(departmentCode)) {
requestInfo.getRequestManager().setMessagecontent("未获取到当前人员的部门编号,请确认");
return Action.FAILURE_AND_CONTINUE;
}
ArrayList<String> codeList = new ArrayList<>();
codeList.add(departmentCode);
OrgInfoRequest orgInfoRequest = new OrgInfoRequest();
orgInfoRequest.setOrgIndexCodes(codeList);
// 获取组织唯一标识
String orgIndexCode = ArtemisUtil.getOrgIndexCode(orgInfoRequest);
String orgIndexCode = ArtemisUtil.getOrgIndexCode(departmentMark, departmentCode, 1, 10);
if (StringUtils.isBlank(orgIndexCode)) {
requestInfo.getRequestManager().setMessagecontent("未获取到当前人员部门的组织唯一标识码,请确认");
return Action.FAILURE_AND_CONTINUE;

@ -29,9 +29,11 @@ public class ArtemisUtil {
*/
private static final String APP_SECRET = new BaseBean().getPropValue("artemisSdk", "appSecret");
private static BaseBean baseBean = new BaseBean();
/**
* config
*
* @return
*/
private static ArtemisConfig getConfig() {
@ -44,6 +46,7 @@ public class ArtemisUtil {
/**
*
*
* @param addRequest
* @throws Exception
*/
@ -56,9 +59,11 @@ public class ArtemisUtil {
String body = JSON.toJSONString(addRequest);
String response = ArtemisHttpUtil.doPostStringArtemis(getConfig(), path, body, null, null, "application/json");
JSONObject jsonObject = JSON.parseObject(response);
baseBean.writeLog("body==" + body);
baseBean.writeLog("response==" + response);
String code = jsonObject.getString("code");
String msg = jsonObject.getString("msg");
if ("0".equals(code) && "SUCCESS".equals(msg)) {
if ("0".equals(code) && "SUCCESS".equalsIgnoreCase(msg)) {
return;
}
throw new RuntimeException(msg);
@ -66,6 +71,7 @@ public class ArtemisUtil {
/**
*
*
* @param updateRequest
* @throws Exception
*/
@ -77,10 +83,12 @@ public class ArtemisUtil {
};
String body = JSON.toJSONString(updateRequest);
String response = ArtemisHttpUtil.doPostStringArtemis(getConfig(), path, body, null, null, "application/json");
baseBean.writeLog("body==" + body);
baseBean.writeLog("response==" + response);
JSONObject jsonObject = JSON.parseObject(response);
String code = jsonObject.getString("code");
String msg = jsonObject.getString("msg");
if ("0".equals(code) && "SUCCESS".equals(msg)) {
if ("0".equals(code) && "SUCCESS".equalsIgnoreCase(msg)) {
return;
}
throw new RuntimeException(msg);
@ -90,33 +98,50 @@ public class ArtemisUtil {
/**
*
*
* @param orgInfo
* @param departmentMark
* @param departmentCode
* @param pageNo
* @param pageSize
* @return
* @throws Exception
*/
public static String getOrgIndexCode(OrgInfoRequest orgInfo) throws Exception {
public static String getOrgIndexCode(String departmentMark, String departmentCode, int pageNo, int pageSize) throws Exception {
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", "/artemis/api/resource/v1/org/orgIndexCodes/orgInfo");
put("https://", "/artemis/api/resource/v2/org/advance/orgList");
}
};
String body = JSON.toJSONString(orgInfo);
OrgListRequest orgListRequest = new OrgListRequest();
orgListRequest.setOrgName(departmentMark);
orgListRequest.setPageNo(pageNo);
orgListRequest.setPageSize(pageSize);
String body = JSON.toJSONString(orgListRequest);
String response = ArtemisHttpUtil.doPostStringArtemis(getConfig(), path, body, null, null, "application/json");
String orgIndexCode = "";
baseBean.writeLog("departmentCode==" + departmentCode + ",body==" + body);
baseBean.writeLog("response==" + response);
JSONObject jsonObject = JSON.parseObject(response);
String code = jsonObject.getString("code");
String msg = jsonObject.getString("msg");
if ("0".equals(code) && "SUCCESS".equals(msg)) {
if ("0".equals(code) && "SUCCESS".equalsIgnoreCase(msg)) {
JSONObject data = jsonObject.getJSONObject("data");
JSONArray list = data.getJSONArray("list");
int total = data.getIntValue("total");
if (total > 0) {
JSONObject info = list.getJSONObject(0);
orgIndexCode = info.getString("orgIndexCode");
// 遍历List 通过部门编号获取组织代码
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
JSONObject item = list.getJSONObject(i);
if (departmentCode.equals(item.getString("organizationCode"))) {
return item.getString("orgIndexCode");
}
}
// 当前页未匹配到,获取下一页的数据匹配
return getOrgIndexCode(departmentMark, departmentCode, pageNo + 1, pageSize);
}
// 未匹配到,返回空
return "";
} else {
throw new RuntimeException(msg);
}
return orgIndexCode;
}
@ -135,11 +160,13 @@ public class ArtemisUtil {
};
String body = JSON.toJSONString(personInfoRequest);
String response = ArtemisHttpUtil.doPostStringArtemis(getConfig(), path, body, null, null, "application/json");
baseBean.writeLog("body==" + body);
baseBean.writeLog("response==" + response);
String personId = "";
JSONObject jsonObject = JSON.parseObject(response);
String code = jsonObject.getString("code");
String msg = jsonObject.getString("msg");
if ("0".equals(code) && "SUCCESS".equals(msg)) {
if ("0".equals(code) && "SUCCESS".equalsIgnoreCase(msg)) {
JSONObject data = jsonObject.getJSONObject("data");
JSONArray list = data.getJSONArray("list");
int total = data.getIntValue("total");

@ -1,20 +0,0 @@
package weaver.interfaces.thwl.action.sdk;
import java.util.ArrayList;
/**
* @author:dxfeng
* @createTime: 2024/08/14
* @version: 1.0
*/
public class OrgInfoRequest {
private ArrayList<String> orgIndexCodes;
public ArrayList<String> getOrgIndexCodes() {
return orgIndexCodes;
}
public void setOrgIndexCodes(ArrayList<String> orgIndexCodes) {
this.orgIndexCodes = orgIndexCodes;
}
}

@ -0,0 +1,89 @@
package weaver.interfaces.thwl.action.sdk;
import weaver.workflow.ruleDesign.Expressions;
import java.util.ArrayList;
public class OrgListRequest {
private String orgName;
private String orgIndexCodes;
private Integer pageNo;
private Integer pageSize;
private String parentOrgIndexCodes;
private Boolean isSubOrg;
private ArrayList<Expressions> expressions;
private String orderBy;
private String orderType;
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public String getOrgIndexCodes() {
return orgIndexCodes;
}
public void setOrgIndexCodes(String orgIndexCodes) {
this.orgIndexCodes = orgIndexCodes;
}
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getParentOrgIndexCodes() {
return parentOrgIndexCodes;
}
public void setParentOrgIndexCodes(String parentOrgIndexCodes) {
this.parentOrgIndexCodes = parentOrgIndexCodes;
}
public Boolean getIsSubOrg() {
return isSubOrg;
}
public void setIsSubOrg(Boolean isSubOrg) {
this.isSubOrg = isSubOrg;
}
public ArrayList<Expressions> getExpressions() {
return expressions;
}
public void setExpressions(ArrayList<Expressions> expressions) {
this.expressions = expressions;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
}

@ -7,11 +7,13 @@ import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.interfaces.thwl.action.sdk.ArtemisUtil;
import weaver.interfaces.thwl.action.sdk.OrgInfoRequest;
import weaver.interfaces.thwl.action.sdk.PersonInfoRequest;
import weaver.interfaces.thwl.action.sdk.UpdateRequest;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
@ -40,13 +42,10 @@ public class PersonSyncUpdateJob extends BaseCronJob {
String ydryxm = item.get("ydryxm");
String drgzbm = item.get("drgzbm");
String departmentCode = departmentComInfo.getDepartmentCode(drgzbm);
ArrayList<String> codeList = new ArrayList<>();
codeList.add(departmentCode);
OrgInfoRequest orgInfoRequest = new OrgInfoRequest();
orgInfoRequest.setOrgIndexCodes(codeList);
String departmentMark = departmentComInfo.getDepartmentmark(drgzbm);
// 获取组织唯一标识
String orgIndexCode = ArtemisUtil.getOrgIndexCode(orgInfoRequest);
String orgIndexCode = ArtemisUtil.getOrgIndexCode(departmentMark,departmentCode,1,10);
// 获取人员ID
String workCode = resourceComInfo.getWorkcode(ydryxm);

Loading…
Cancel
Save