Commit e9ce0c6b by 宋祥

1.组织机构和工人管理逻辑关联

parent 6d41ed2b
......@@ -15,6 +15,8 @@ import com.baosight.hpjx.hp.xs.tools.HPXSTools;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.ObjectUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
......@@ -22,7 +24,9 @@ import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
......@@ -84,10 +88,15 @@ public class ServiceHPPZ013 extends ServiceBase {
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Long> ids = ObjectUtils.listKey(resultRows, "id");
// 数据校验
this.checkSaveData(resultRows);
// 查询数据
List<HPPZ013> dbPz023s = HPPZTools.HpPz013.list(ids);
// 写入数据
this.saveData(resultRows);
List<HPPZ01301> fPz013s = this.saveData(resultRows);
// 清理和新增关系
this.delAndAddMember(dbPz023s, fPz013s);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
......@@ -120,7 +129,8 @@ public class ServiceHPPZ013 extends ServiceBase {
*
* @param resultRows
*/
private void saveData(List<Map> resultRows) throws Exception {
private List<HPPZ01301> saveData(List<Map> resultRows) throws Exception {
List<HPPZ01301> fPz01301s = new ArrayList<>();
for (Map resultRow : resultRows) {
HPPZ01301 fPz01301 = new HPPZ01301();
fPz01301.fromMap(resultRow);
......@@ -131,7 +141,9 @@ public class ServiceHPPZ013 extends ServiceBase {
} else {
this.modify(fPz01301);
}
fPz01301s.add(fPz01301);
}
return fPz01301s;
}
/**
......@@ -165,28 +177,6 @@ public class ServiceHPPZ013 extends ServiceBase {
fPz01301.setUserId(userId);
fPz01301.setDeleteFlag(CommonConstant.YesNo.NO_0);
DaoUtils.insert(HPPZ013.INSERT, fPz01301);
// 添加到组织机构
this.insertOrgMember(fPz01301);
}
/**
* 用户关联组织
*
* @param fPz01301
*/
private void insertOrgMember(HPPZ01301 fPz01301) {
Map inInfoRowMap = new HashMap();
inInfoRowMap.put("loginName", fPz01301.getUserId());
inInfoRowMap.put("userId", fPz01301.getUserId());
inInfoRowMap.put("orgId", fPz01301.getGroupCode());
EiInfo inInfo = new EiInfo();
inInfo.addBlock(EiConstant.resultBlock).addRow(inInfoRowMap);
inInfo.set(EiConstant.serviceName, "XSOG0801");
inInfo.set(EiConstant.methodName, "insertUserByOrgId");
EiInfo outInfo = XLocalManager.call(inInfo);
if (outInfo.getStatus() < 0) {
throw new PlatException(outInfo.getMsg());
}
}
/**
......@@ -208,14 +198,17 @@ public class ServiceHPPZ013 extends ServiceBase {
public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<HPPZ013> fPz013s = new ArrayList<>();
for (Map resultRow : resultRows) {
HPPZ013 fPz013 = new HPPZ013();
HPPZ01301 fPz013 = new HPPZ01301();
fPz013.fromMap(resultRow);
fPz013.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.update(HPPZ013.DELETE, fPz013);
// 从组织机构删除
this.deleteOrgMember(fPz013);
fPz013s.add(fPz013);
}
// 从组织机构删除
this.deleteOrgMember(fPz013s);
// 刷新数据
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
......@@ -226,23 +219,77 @@ public class ServiceHPPZ013 extends ServiceBase {
}
/**
* 用户删除组织
* 删除和新增组织机构关系
*
* @param delPz013s
* @param addPz01301s
*/
private void delAndAddMember(List<HPPZ013> delPz013s, List<HPPZ01301> addPz01301s) {
// 删除用工关系
this.deleteOrgMember(delPz013s);
// 重新添加组织机构关系
this.insertOrgMember(addPz01301s);
}
/**
* 用户关联组织
*
* @param fPz013
* @param addPz01301s
*/
private void deleteOrgMember(HPPZ013 fPz013) {
private void insertOrgMember(List<HPPZ01301> addPz01301s) {
if (CollectionUtils.isEmpty(addPz01301s)) {
return;
}
List<Map> addRelations = new ArrayList<>();
for (HPPZ01301 addPz01301 : addPz01301s) {
Map inInfoRowMap = new HashMap();
inInfoRowMap.put("loginName", addPz01301.getUserId());
inInfoRowMap.put("userId", addPz01301.getUserId());
inInfoRowMap.put("orgId", addPz01301.getGroupCode());
addRelations.add(inInfoRowMap);
}
EiInfo inInfo = new EiInfo();
inInfo.set("inqu_status-0-parentOrgId", fPz013.getGroupCode());
inInfo.set("result-0-userId", fPz013.getUserId());
inInfo.set("result-0-loginName", fPz013.getUserId());
inInfo.set("result-0-orgId", fPz013.getGroupCode());
inInfo.set("result-0-orgEname", fPz013.getGroupCode());
// serviceName:XSOrgManage,methodName:deleteRelationBetweenUserAndOrg
inInfo.addBlock(EiConstant.resultBlock).setRows(addRelations);
inInfo.set(EiConstant.serviceName, "XSOG0801");
inInfo.set(EiConstant.methodName, "deleteUserByOrgId");
inInfo.set(EiConstant.methodName, "insertUserByOrgId");
EiInfo outInfo = XLocalManager.call(inInfo);
if (outInfo.getStatus() < 0) {
throw new PlatException(outInfo.getMsg());
}
}
/**
* 用户删除组织
*
* @param delPz013s
*/
private void deleteOrgMember(List<HPPZ013> delPz013s) {
if (CollectionUtils.isEmpty(delPz013s)) {
return;
}
List<Map> delRelations = new ArrayList<>();
for (HPPZ013 delPz013 : delPz013s) {
String groupCode = delPz013.getGroupCode();
if (StringUtils.isBlank(groupCode)) {
continue;
}
Map deleteMap = new HashMap();
deleteMap.put("userId", delPz013.getUserId());
deleteMap.put("loginName", delPz013.getUserId());
deleteMap.put("orgId", delPz013.getGroupCode());
deleteMap.put("orgEname", delPz013.getGroupCode());
delRelations.add(deleteMap);
}
if (CollectionUtils.isEmpty(delRelations)) {
return;
}
EiInfo inInfo = new EiInfo();
inInfo.set("list", delRelations);
// serviceName:XSOrgManage,methodName:deleteRelationBetweenUserAndOrg
inInfo.set(EiConstant.serviceId, "S_XS_91");
EiInfo outInfo = XServiceManager.call(inInfo);
if (outInfo.getStatus() < 0) {
throw new PlatException(outInfo.getMsg());
}
}
}
......@@ -84,6 +84,9 @@
</sql>
<sql id="customCondition">
<isNotEmpty prepend=" AND " property="ids">
ID IN <iterate close=")" open="(" conjunction="," property="ids">#ids[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="gender">
USER_ID IN (SELECT LOGIN_NAME FROM ${platSchema}.XS_USER WHERE COMPANY_CODE = #companyCode# AND GENDER = #gender# )
</isNotEmpty>
......@@ -187,11 +190,16 @@
<update id="clearGroup">
UPDATE ${hpjxSchema}.T_HPPZ013
SET
FACTORY_CODE = '',
FACTORY_NAME = '',
GROUP_TYPE = '',
GROUP_CODE = '',
GROUP_NAME = '',
<include refid="updateRevise"/>
WHERE GROUP_CODE = #groupCode#
<isNotEmpty prepend=" AND " property="userId">
USER_ID = #userId#
</isNotEmpty>
</update>
<!-- 清空生产厂区 -->
......@@ -205,6 +213,9 @@
GROUP_NAME = '',
<include refid="updateRevise"/>
WHERE FACTORY_CODE = #factoryCode#
<isNotEmpty prepend=" AND " property="userId">
USER_ID = #userId#
</isNotEmpty>
</update>
<select id="queryComboBox" parameterClass="java.util.HashMap"
......
......@@ -6,11 +6,17 @@ import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.pz.domain.*;
import com.baosight.hpjx.hp.pz.domain.HPPZ004;
import com.baosight.hpjx.hp.pz.domain.HPPZ006;
import com.baosight.hpjx.hp.pz.domain.HPPZ007;
import com.baosight.hpjx.hp.pz.domain.HPPZ009;
import com.baosight.hpjx.hp.pz.domain.HPPZ011;
import com.baosight.hpjx.hp.pz.domain.HPPZ013;
import com.baosight.hpjx.hp.pz.domain.HPPZ015;
import com.baosight.hpjx.hp.pz.domain.HPPZ015A;
import com.baosight.hpjx.hp.sc.domain.HPSC001;
import com.baosight.hpjx.hp.sc.domain.HPSC002;
import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.pz.domain.*;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.ObjectUtils;
......@@ -553,15 +559,30 @@ public class HPPZTools {
}
/**
* @param ids
* @return
*/
public static List<HPPZ013> list(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("ids", ids);
return DaoBase.getInstance().query(HPPZ013.QUERY, queryMap);
}
/**
* 清空生产部门关系
*
* @param orgId
* @param userId
* @return
*/
public static void clearGroup(String orgId) {
public static void clearGroup(String orgId, String userId) {
AssertUtils.isNull(orgId, "组织机构ID不能为空");
Map queryMap = new HashMap();
queryMap.put("groupCode", orgId);
queryMap.put("userId", userId);
DaoUtils.update(HPSqlConstant.HPPZ013.CLEAR_GROUP, queryMap);
}
......@@ -569,12 +590,14 @@ public class HPPZTools {
* 清空厂区关系
*
* @param orgId
* @param userId
* @return
*/
public static void clearFactory(String orgId) {
public static void clearFactory(String orgId, String userId) {
AssertUtils.isNull(orgId, "组织机构ID不能为空");
Map queryMap = new HashMap();
queryMap.put("factoryCode", orgId);
queryMap.put("userId", userId);
DaoUtils.update(HPSqlConstant.HPPZ013.CLEAR_FACTORY, queryMap);
}
......
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