|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.service.Impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.landray.kmss.sys.organization.webservice.in.ISysSynchroSetOrgWebService;
|
|
|
@@ -86,7 +87,7 @@ public class SyncOrgElementsBaseInfoServiceImpl implements SyncOrgElementsBaseIn
|
|
|
private JSONArray getOrgJsonData(String type){
|
|
|
JSONArray resultArray = new JSONArray();
|
|
|
// 《组织》 数据对象
|
|
|
- SqlRowList orgs = baseDao.queryForRowSet("select row_number() over (order by or_id) rn, case when nvl(or_landrayid,' ')=' ' then to_char(or_id) else or_landrayid end or_id,or_code,or_name,or_subof ,or_parentname,or_headmancode,or_headmanname,or_path, (select or_headmanname from hrorg ho where ho.or_id=hr.or_subof) as superleader from hrorg hr order by or_id");
|
|
|
+ SqlRowList orgs = baseDao.queryForRowSet("select row_number() over (order by or_id) rn, case when nvl(or_landrayid,' ')=' ' then to_char(or_id) else or_landrayid end or_id,or_code,or_name,or_subof ,or_parentname,or_headmancode,or_headmanname,or_path, (select case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end from hrorg ho left join employee on ho.or_headmancode=em_code where ho.or_id=hr.or_subof) as superleader,or_statuscode,or_landraysubid,to_char(or_subof) or_subof,case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end emid from hrorg hr left join employee on hr.or_headmancode=em_code order by or_id");
|
|
|
while (orgs.next()) {
|
|
|
JSONObject orgObj = new JSONObject();
|
|
|
orgObj.put("id", orgs.getGeneralString("or_id")); // 唯一标识 (不允许为空)
|
|
|
@@ -97,16 +98,23 @@ public class SyncOrgElementsBaseInfoServiceImpl implements SyncOrgElementsBaseIn
|
|
|
orgObj.put("order", orgs.getGeneralString("rn")); // 排序号 (可为空)
|
|
|
orgObj.put("keyword", ""); // 关键字 (内容格式不限制,可为空)
|
|
|
if ("详情".equals(type)) {
|
|
|
- orgObj.put("parent", orgs.getGeneralString("or_parentname")); // 父组织 (可为空)
|
|
|
- orgObj.put("thisleader", orgs.getGeneralString("or_headmanname")); // 组织架构领导 (可为空)
|
|
|
+ String landraysubid = orgs.getObject("or_landraysubid") == null ? orgs.getGeneralString("or_subof") : orgs.getGeneralString("or_landraysubid");
|
|
|
+ orgObj.put("parent", landraysubid); // 父组织 (可为空)
|
|
|
+ orgObj.put("thisleader", orgs.getGeneralString("emid")); // 组织架构领导 (可为空)
|
|
|
orgObj.put("memo", orgs.getGeneralString("or_path")); // 组织架构说明 (可为空)
|
|
|
orgObj.put("superleader", orgs.getGeneralString("superleader")); // 组织上级上级领导 (可为空)
|
|
|
- orgObj.put("isAvailable", true); // 是否有效,该属性决定该组织架构是否删除
|
|
|
+ String statuscode = orgs.getObject("or_statuscode") == null ? "" : orgs.getGeneralString(
|
|
|
+ "or_statuscode");
|
|
|
+ if ("AUDITED".equals(statuscode)) {
|
|
|
+ orgObj.put("isAvailable", true); // 是否有效,该属性决定该部门架构是否删除
|
|
|
+ }else {
|
|
|
+ orgObj.put("isAvailable", false);
|
|
|
+ }
|
|
|
}
|
|
|
resultArray.add(orgObj); // 组织机构
|
|
|
}
|
|
|
// 《部门》 数据对象
|
|
|
- SqlRowList depts = baseDao.queryForRowSet("select row_number() over (order by dp_level) rn,case when nvl(dp_landrayid,' ')=' ' then to_char(dp_id) else Dp_Landrayid end dp_id, dp_code, dp_name, dp_status, dp_headmancode, dp_headmanname, dp_subof, dp_isleaf, dp_parentdpname, dp_level,(select dp_headmanname from department dp where dp_statuscode='AUDITED' and dp.dp_id=dept.dp_subof) as superleader from department dept where dp_statuscode='AUDITED' order by dp_level");
|
|
|
+ SqlRowList depts = baseDao.queryForRowSet("select row_number() over (order by dp_level) rn,case when nvl(dp_landrayid,' ')=' ' then to_char(dp_id) else Dp_Landrayid end dp_id, dp_code, dp_name, dp_status, dp_headmancode, dp_headmanname, dp_subof, dp_isleaf, dp_parentdpname, dp_level,(select case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end from department dp left join employee on em_code=dp.dp_headmancode where dp.dp_id=dept.dp_subof) as superleader,dp_statuscode,dp_landraysubid,to_char(dp_subof) dp_subof,case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end em_id from department dept left join employee on em_code=dept.dp_headmancode order by dp_level");
|
|
|
while (depts.next()) {
|
|
|
JSONObject deptObj = new JSONObject();
|
|
|
deptObj.put("id", depts.getGeneralString("dp_id")); // 唯一标识 (不允许为空)
|
|
|
@@ -117,19 +125,25 @@ public class SyncOrgElementsBaseInfoServiceImpl implements SyncOrgElementsBaseIn
|
|
|
deptObj.put("order", depts.getGeneralString("rn")); // 排序号 (可为空)
|
|
|
deptObj.put("keyword", ""); // 关键字 (内容格式不限制,可为空)
|
|
|
if ("详情".equals(type)) {
|
|
|
- deptObj.put("parent", depts.getGeneralString("dp_parentdpname")); // 父部门 (可为空)
|
|
|
- deptObj.put("thisleader", depts.getGeneralString("dp_headmanname")); // 部门架构领导 (可为空)
|
|
|
+ String landraysubid = orgs.getObject("dp_landraysubid") == null ? orgs.getGeneralString("dp_subof") : orgs.getGeneralString("dp_landraysubid");
|
|
|
+ deptObj.put("parent", landraysubid); // 父部门 (可为空)
|
|
|
+ deptObj.put("thisleader", depts.getGeneralString("em_id")); // 部门架构领导 (可为空)
|
|
|
int level = depts.getGeneralInt("dp_level");
|
|
|
String memo = depts.getGeneralInt("or_path") == 0 ? "不是末级部门,部门层级" + level : "是末级部门,部门层级" + level;
|
|
|
deptObj.put("memo", memo); // 部门架构说明 (可为空)
|
|
|
deptObj.put("superleader", depts.getGeneralString("superleader")); // 部门上级领导 (可为空)
|
|
|
- deptObj.put("isAvailable", true); // 是否有效,该属性决定该部门架构是否删除
|
|
|
+ String statuscode = depts.getObject("dp_statuscode") == null ? "" : depts.getGeneralString("dp_statuscode");
|
|
|
+ if ("AUDITED".equals(statuscode)) {
|
|
|
+ deptObj.put("isAvailable", true); // 是否有效,该属性决定该部门架构是否删除
|
|
|
+ }else {
|
|
|
+ deptObj.put("isAvailable", false);
|
|
|
+ }
|
|
|
}
|
|
|
resultArray.add(deptObj); // 部门
|
|
|
}
|
|
|
|
|
|
// 《岗位》 数据对象
|
|
|
- SqlRowList posts = baseDao.queryForRowSet("select row_number() over (order by jo_level) rn,jo_id joid,case when nvl(jo_landrayid,' ')=' ' then to_char(jo_id) else jo_landrayid end jo_id, jo_code, jo_name, jo_orgid, jo_orgname, jo_headmancode, jo_headmanname , jo_subof, jo_parentname, jo_level, jo_emptype from job where jo_statuscode='AUDITED' order by jo_level");
|
|
|
+ SqlRowList posts = baseDao.queryForRowSet("select row_number() over (order by jo_level) rn,jo_id joid,case when nvl(jo_landrayid,' ')=' ' then to_char(jo_id) else jo_landrayid end jo_id, jo_code, jo_name, jo_orgid, jo_orgname, jo_headmancode, jo_headmanname , to_char(jo_subof) jo_subof, jo_parentname, jo_level, jo_emptype,jo_statuscode,jo_landraysubid,case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end emid from job left join employee on em_code=jo_headmancode order by jo_level");
|
|
|
while (posts.next()) {
|
|
|
JSONObject postObj = new JSONObject();
|
|
|
postObj.put("id", posts.getGeneralString("jo_id")); // 唯一标识 (不允许为空)
|
|
|
@@ -140,28 +154,34 @@ public class SyncOrgElementsBaseInfoServiceImpl implements SyncOrgElementsBaseIn
|
|
|
postObj.put("order", posts.getGeneralString("rn")); // 排序号 (可为空)
|
|
|
postObj.put("keyword", ""); // 关键字 (内容格式不限制,可为空)
|
|
|
if ("详情".equals(type)) {
|
|
|
- postObj.put("parent", posts.getGeneralString("jo_parentname")); // 父部门 (可为空)
|
|
|
- postObj.put("thisleader", posts.getGeneralString("jo_headmanname")); // 部门架构领导 (可为空)
|
|
|
+ String landraysubid = orgs.getObject("jo_landraysubid") == null ? orgs.getGeneralString("jo_subof") : orgs.getGeneralString("jo_landraysubid");
|
|
|
+ postObj.put("parent", landraysubid); // 父部门 (可为空)
|
|
|
+ postObj.put("thisleader", posts.getGeneralString("emid")); // 部门架构领导 (可为空)
|
|
|
int level = posts.getGeneralInt("jo_level");
|
|
|
String memo = posts.getObject("jo_orgname") == null ? "岗位层级" + level : "所属组织" + posts.getGeneralString("jo_orgname") + ",岗位层级" + level;
|
|
|
postObj.put("memo", memo); // 岗位架构说明 (可为空)
|
|
|
- List<String> data = baseDao.query("select case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) " +
|
|
|
- "else em_landrayemid end em_id from employee where em_class<>'离职' and nvl(em_islandray,0)=-1 " +
|
|
|
- "and (em_landrayjoid='" + posts.getString("jo_id")+"' or em_defaulthsid="+posts.getGeneralInt("joid")+")", String.class);
|
|
|
- String[] persons =new String[]{};
|
|
|
+ List<String> data = baseDao.queryForList("select case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end from employee where em_class<>'离职' and nvl(em_islandray,0)=-1 and em_defaulthsid="+posts.getGeneralInt("joid"), String.class);
|
|
|
+
|
|
|
+ JSONArray persons=null;
|
|
|
if (data != null && data.size() > 0) {
|
|
|
- persons = data.toArray(new String[data.size()]);
|
|
|
+ persons =JSONArray.parseArray(JSON.toJSONString(data));
|
|
|
|
|
|
}
|
|
|
postObj.put("persons", persons); // 岗位包含人员 (可为空)
|
|
|
- postObj.put("isAvailable", true); // 是否有效,该属性决定该岗位是否删除
|
|
|
+ String statuscode = posts.getObject("jo_statuscode") == null ? "" : posts.getGeneralString(
|
|
|
+ "jo_statuscode");
|
|
|
+ if ("AUDITED".equals(statuscode)) {
|
|
|
+ postObj.put("isAvailable", true); // 是否有效,该属性决定该部门架构是否删除
|
|
|
+ }else {
|
|
|
+ postObj.put("isAvailable", false);
|
|
|
+ }
|
|
|
}
|
|
|
resultArray.add(postObj); // 岗位
|
|
|
}
|
|
|
|
|
|
|
|
|
// 《人员》 数据对象
|
|
|
- SqlRowList persons = baseDao.queryForRowSet("select rn,em_id emid,case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end em_id,em_code,em_name,em_password,em_mobile, em_email,em_cardcode,em_departmentcode,em_depart,em_position,em_defaulthsid from (select row_number() over (order by em_id) rn,em_id,em_code,em_name,em_password,em_mobile, em_email,em_cardcode,em_departmentcode,em_depart,em_position,em_defaulthsid,em_landrayemid from employee where em_class<>'离职' and nvl(em_islandray,0)=-1 order by em_id) where rn<=10");
|
|
|
+ SqlRowList persons = baseDao.queryForRowSet("select row_number() over (order by em_id) rn,em_id emid,case when nvl(em_landrayemid,' ')=' ' then to_char(em_id) else em_landrayemid end em_id,em_code,em_name,em_password,em_mobile, em_email,em_cardcode,em_departmentcode,em_depart,em_position,em_defaulthsid,em_landrayemid,em_class,case when nvl(dp_landrayid,' ')=' ' then to_char(dp_id) else Dp_Landrayid end dp_id from employee left join department on em_departmentcode=dp_code where nvl(em_islandray,0)=-1 order by em_id");
|
|
|
while (persons.next()) {
|
|
|
JSONObject personObj = new JSONObject();
|
|
|
// 唯一标识 (不允许为空)
|
|
|
@@ -173,15 +193,19 @@ public class SyncOrgElementsBaseInfoServiceImpl implements SyncOrgElementsBaseIn
|
|
|
personObj.put("order", persons.getGeneralString("rn")); // 排序号 (可为空)
|
|
|
personObj.put("keyword", persons.getGeneralString("em_name")); // 关键字 (内容格式不限制,可为空)
|
|
|
if ("详情".equals(type)) {
|
|
|
- personObj.put("isAvailable", true); // 是否有效,该属性决定该人员是否删除
|
|
|
+ String statuscode = persons.getObject("em_class") == null ? "" : persons.getGeneralString("em_class");
|
|
|
+ if ("离职".equals(statuscode)) {
|
|
|
+ personObj.put("isAvailable", false); // 是否有效,该属性决定该部门架构是否删除
|
|
|
+ }else {
|
|
|
+ personObj.put("isAvailable", true);
|
|
|
+ }
|
|
|
personObj.put("memo", persons.getGeneralString("rn")); // 人员说明 (可为空)
|
|
|
- personObj.put("parent", persons.getGeneralString("em_depart")); // 所在部门 (可为空)
|
|
|
+ personObj.put("parent", persons.getGeneralString("dp_id")); // 所在部门 (可为空)
|
|
|
List<String> data =
|
|
|
- baseDao.query("select case when nvl(jo_landrayid,' ')=' ' then to_char(jo_id) else jo_landrayid end from empsjobs left join job on job_id=jo_id where emp_id=" + persons.getGeneralInt("emid"), String.class);
|
|
|
- String[] jobs =new String[]{};
|
|
|
+ baseDao.queryForList("select case when nvl(jo_landrayid,' ')=' ' then to_char(jo_id) else jo_landrayid end from empsjobs left join job on job_id=jo_id where emp_id=" + persons.getGeneralInt("emid"), String.class);
|
|
|
+ JSONArray jobs=null;
|
|
|
if (data != null && data.size() > 0) {
|
|
|
- data.add(persons.getGeneralString("jo_landrayid"));
|
|
|
- jobs = data.toArray(new String[data.size()]);
|
|
|
+ jobs =JSONArray.parseArray(JSON.toJSONString(data));
|
|
|
|
|
|
}
|
|
|
personObj.put("posts", jobs); // 所属岗位
|
|
|
@@ -242,6 +266,8 @@ public class SyncOrgElementsBaseInfoServiceImpl implements SyncOrgElementsBaseIn
|
|
|
JSONArray orgJsonData = getOrgJsonData("详情");
|
|
|
// 将组织数据设置到组织架构信息接入上下文
|
|
|
setOrgContext.setOrgJsonData(orgJsonData.toString());
|
|
|
+ logger.info(orgJsonData.toString());
|
|
|
+ logger.info(setOrgContext.toString());
|
|
|
try {
|
|
|
// 调用 WebService 接口,并接收请求返回的数据
|
|
|
SysSynchroSetResult result = syncOrgElements(setOrgContext);
|