Commit 6d41ed2b by 宋祥

1.删除组织时逻辑错误修正

parent 67529a31
......@@ -12,6 +12,8 @@ import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.xs.domain.Org;
import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.iplat4j.common.ed.domain.TEDCM01;
import com.baosight.iplat4j.core.data.dao.DaoFactory;
import com.baosight.iplat4j.core.ei.EiBlock;
......@@ -197,12 +199,6 @@ public class ServiceXSOG0801 extends ServiceBase {
for (int i = 0; i < deleteList.size(); ++i) {
inInfo.getBlock(EiConstant.resultBlock).getRow(i).put("orgId", orgId);
// 清空组织机构下面人员的工人关系
Org org = HPXSTools.XsOrg.get(orgId);
// 校验是否存在进行中的任务
this.checkExistsTask(org.getOrgId(), org.getOrgCname(), org.getOrgType());
// 清除用工关系
clearHp013(org.getOrgId(), org.getOrgType());
}
call.set("list", inInfo.getBlock(EiConstant.resultBlock).getRows());
call.set(EiConstant.serviceId, "S_XS_91");
......@@ -327,62 +323,86 @@ public class ServiceXSOG0801 extends ServiceBase {
return outInfo;
}
/**
* 删除组织机构
*
* @param inInfo
* @return
*/
public EiInfo deleteOrgByEname(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.resultBlock);
List rows = block.getRows();
rows.forEach((m) -> {
Map row = (Map)m;
row.put("recRevisor", UserSession.getLoginName());
});
EiInfo call = new EiInfo();
call.set("list", rows);
call.set(EiConstant.serviceId, "S_XS_88");
EiInfo result = XServiceManager.call(call);
if (result.getStatus() > 0) {
for(int i = 0; i < rows.size(); ++i) {
Map param = (Map)rows.get(i);
List orgs = this.dao.query("XSOG01.queryOrgInfo", param);
for(int j = 0; j < orgs.size(); ++j) {
Map memberMap = new HashMap();
memberMap.put("orgId", ((Map)orgs.get(j)).get("orgId"));
this.dao.delete("XSOG02.deleteRelationByOrgId", memberMap);
try {
List<Map> rows = inInfo.getBlock(EiConstant.resultBlock).getRows();
rows.forEach((row) -> {
row.put("recRevisor", UserSession.getLoginName());
String orgId = MapUtils.getString(row, "orgEname");
// 清空组织机构下面人员的工人关系
Org org = HPXSTools.XsOrg.get(orgId);
// 校验是否存在进行中的任务
this.checkExistsTask(org.getOrgId(), org.getOrgCname(), org.getOrgType());
// 清除用工关系
clearHp013(org.getOrgId(), org.getOrgType());
});
EiInfo call = new EiInfo();
call.set("list", rows);
call.set(EiConstant.serviceId, "S_XS_88");
inInfo = XServiceManager.call(call);
if (inInfo.getStatus() > 0) {
for (int i = 0; i < rows.size(); ++i) {
Map param = (Map) rows.get(i);
List orgs = this.dao.query("XSOG01.queryOrgInfo", param);
for (int j = 0; j < orgs.size(); ++j) {
Map memberMap = new HashMap();
memberMap.put("orgId", ((Map) orgs.get(j)).get("orgId"));
this.dao.delete("XSOG02.deleteRelationByOrgId", memberMap);
}
}
}
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "删除失败");
}
return result;
return inInfo;
}
/**
* 删除组织及子节点
*
* @param inInfo
* @return
*/
public EiInfo deleteOrgAndChildrenById(EiInfo inInfo) {
EiBlock block = inInfo.getBlock(EiConstant.resultBlock);
Map idMap = new HashMap();
int sum = 0;
for(int i = 0; i < block.getRowCount(); ++i) {
String orgId = block.getCell(i, "orgId").toString();
Map orgIdMap = new HashMap();
orgIdMap.put("orgId", orgId);
List orgIdChildList = this.dao.query("XSOG01.queryOrgChild", orgIdMap);
for (int j = 0; j < orgIdChildList.size(); ++j) {
Map childMap = ((Map) orgIdChildList.get(j));
String childOrgId = childMap.get("ORG_ID").toString();
String childOrgName = childMap.get("ORG_CNAME").toString();
String childOrgType = childMap.get("ORG_TYPE").toString();
// 校验是否存在进行中的任务
this.checkExistsTask(childOrgId, childOrgName, childOrgType);
idMap.put("orgId", childOrgId);
idMap.put("recRevisor", UserSession.getLoginName());
idMap.put("recReviseTime", DateUtils.curDateTimeStr14());
this.dao.update("XSOG01.deleteOrg", idMap);
Map memberMap = new HashMap();
memberMap.put("orgId", ((Map) orgIdChildList.get(j)).get("ORG_ID"));
this.dao.delete("XSOG02.deleteRelationByOrgId", memberMap);
// 清除用工关系
clearHp013(childOrgId, childOrgType);
++sum;
try {
List<Map> rows = inInfo.getBlock(EiConstant.resultBlock).getRows();
Map idMap = new HashMap();
int sum = 0;
for (int i = 0; i < rows.size(); ++i) {
String orgId = rows.get(i).get("orgId").toString();
Map orgIdMap = new HashMap();
orgIdMap.put("orgId", orgId);
List orgIdChildList = this.dao.query("XSOG01.queryOrgChild", orgIdMap);
for (int j = 0; j < orgIdChildList.size(); ++j) {
Map childMap = ((Map) orgIdChildList.get(j));
String childOrgId = childMap.get("ORG_ID").toString();
String childOrgName = childMap.get("ORG_CNAME").toString();
String childOrgType = childMap.get("ORG_TYPE").toString();
// 校验是否存在进行中的任务
this.checkExistsTask(childOrgId, childOrgName, childOrgType);
idMap.put("orgId", childOrgId);
idMap.put("recRevisor", UserSession.getLoginName());
idMap.put("recReviseTime", DateUtils.curDateTimeStr14());
this.dao.update("XSOG01.deleteOrg", idMap);
Map memberMap = new HashMap();
memberMap.put("orgId", ((Map) orgIdChildList.get(j)).get("ORG_ID"));
this.dao.delete("XSOG02.deleteRelationByOrgId", memberMap);
// 清除用工关系
clearHp013(childOrgId, childOrgType);
++sum;
}
}
inInfo.setMsg("删除[" + sum + "]条记录成功");
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "删除失败");
}
inInfo.setMsg("删除[" + sum + "]条记录成功");
return inInfo;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment