From 46e8af542c02d801bea9fa8cf8f55974dcfa8554 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 30 十二月 2025 11:03:00 +0800
Subject: [PATCH] 更改头部
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java | 317 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 228 insertions(+), 89 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
index 1c04f71..756854a 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -1,5 +1,7 @@
package com.doumee.service.business.impl;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -23,6 +25,11 @@
import com.doumee.core.haikang.model.param.respose.OrgOrUserAddResponse;
import com.doumee.core.haikang.model.param.respose.OrgUpdateFailureResponse;
import com.doumee.core.haikang.service.HKService;
+import com.doumee.core.jiandaoyun.api.arch.DeptApiClient;
+import com.doumee.core.jiandaoyun.constants.HttpConstant;
+import com.doumee.core.jiandaoyun.model.dept.DeptEntityModel;
+import com.doumee.core.wms.model.response.WmsBaseDataResponse;
+import com.doumee.core.wms.model.response.WmsBaseResponse;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
@@ -39,7 +46,6 @@
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.CompanyService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
-import com.taobao.api.ApiException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
@@ -169,8 +175,8 @@
OrgEditRequest request = (getOrgHkEditModel(company));
BaseResponse result = HKService.editOrg(request);
if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
- //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
- return true;
+ //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
+ return true;
}
return false;
}
@@ -180,7 +186,7 @@
request.setIndexCodes(new String[]{company.getHkId()});
BaseResponse<List<OrgUpdateFailureResponse>> result = HKService.delBatchOrg(request);
if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
- //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
+ //澶勭悊鏂板鎴愬姛鐨勬暟鎹紝淇敼娴峰悍鍚屾鐘舵��
if(result.getData()!=null && result.getData().size()==0){
return true;
}
@@ -292,7 +298,7 @@
if(company.getId() == null|| StringUtils.isBlank(company.getName())){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
- if(company.getType()!=null && !(company.getType() ==0 || company.getType() ==1)){
+ if(company.getType()!=null && !(company.getType() ==-1 || company.getType() ==0 || company.getType() ==1)){
throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝缁勭粐绫诲瀷涓嶆纭紝璇锋寜瑕佹眰濉啓~");
}
//鏌ヨ鍚嶇О涓嶈兘閲嶅
@@ -333,14 +339,14 @@
//鏇存柊鐨刢ompanyPath
String newName = model.getCompanyNamePath().replace(model.getName(),company.getName());
companyMapper.update(null,new UpdateWrapper<Company>().lambda()
- .setSql("company_name_path=REPLACE(company_name_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
- .setSql("hk_company_path=REPLACE(hk_company_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
+ .setSql("company_name_path=REPLACE(company_name_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
+ .setSql("hk_company_path=REPLACE(hk_company_path,'"+ model.getCompanyNamePath()+"','"+newName+"')")
.likeRight(Company::getCompanyPath,model.getCompanyPath()));
//涓嬪彂娴峰悍瀹夐槻骞冲彴
if(StringUtils.isNotBlank(model.getHkId())){
- if(!editHkOrg(company)){
- throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯");
- }
+ if(!editHkOrg(company)){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
}else{//濡傛灉娌℃湁涓嬪彂杩囷紝鐩存帴鏂板缓瀹夐槻骞冲彴缁勭粐
if(!addHkOrg(company)){
throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝缁勭粐鍚屾涓嬪彂澶辫触锛岃绋嶅悗閲嶈瘯");
@@ -786,37 +792,45 @@
// org_dept_remove 閮ㄩ棬鍒犻櫎 {"timeStamp":"1758785817760","eventId":"47e289f334e041719ed354052da474de","deptId":[1040735458]}
@Override
- public void ddPushCompanyInfo(String eventType, JSONObject eventData) throws ApiException {
- JSONArray jsonArray = eventData.getJSONArray("deptId");
- if(jsonArray.isEmpty()){
- return;
- }
- if(eventType.equals("org_dept_remove")){
- //鍒犻櫎瀵瑰簲閮ㄩ棬淇℃伅
- List<Long> deptIdList = new ArrayList<>();
- for (int i = 0; i < jsonArray.size(); i++) {
- Long deptId = jsonArray.getLong(i);
- deptIdList.add(deptId);
+ public void ddPushCompanyInfo(String eventType, JSONObject eventData) {
+ try {
+ JSONArray jsonArray = eventData.getJSONArray("deptId");
+ if(jsonArray.isEmpty()){
+ return;
}
- if(CollectionUtils.isNotEmpty(deptIdList)){
- syncDelCompany(deptIdList);
- }
- }else if(eventType.equals("org_dept_create")||eventType.equals("org_dept_modify")){
- for (int i = 0; i < jsonArray.size(); i++) {
- Company company = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
- .eq(Company::getIsdeleted,Constants.ZERO)
- .eq(Company::getErpId,jsonArray.getLong(i))
- );
- OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = dingTalk.syncDepartmentInfo(jsonArray.getLong(i));
-
-
- if(Objects.isNull(company)){
- getAddCompanyModel(deptGetResponse,company);
- }else{
- getUpdateCompanyModel(deptGetResponse,company);
+ if(eventType.equals("org_dept_remove")){
+ //鍒犻櫎瀵瑰簲閮ㄩ棬淇℃伅
+ List<Long> deptIdList = new ArrayList<>();
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Long deptId = jsonArray.getLong(i);
+ deptIdList.add(deptId);
+ }
+ if(CollectionUtils.isNotEmpty(deptIdList)){
+ syncDelCompany(deptIdList);
+ }
+ }else if(eventType.equals("org_dept_create")||eventType.equals("org_dept_modify")){
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Company company = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
+ .eq(Company::getIsdeleted,Constants.ZERO)
+ .eq(Company::getErpId,jsonArray.getLong(i))
+ );
+ OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = dingTalk.syncDepartmentInfo(jsonArray.getLong(i));
+ Company param = new Company();
+ param.setName(deptGetResponse.getName());
+ param.setErpId(deptGetResponse.getDeptId().toString());
+ param.setErpParentId(deptGetResponse.getParentId().toString());
+ if(Objects.isNull(company)){
+ param.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+ getAddCompanyModel(param);
+ }else{
+ getUpdateCompanyModel(param,company);
+ }
}
}
+ }catch (Exception e){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鏁版嵁鍚屾澶辫触");
}
+
}
private void doHkDeleteOrg(List<Integer> delIds,List<String> delHkIds, Date date) {
@@ -852,34 +866,106 @@
}
@Override
- public String syncDDCompany() throws ApiException {
- List<OapiV2DepartmentGetResponse.DeptGetResponse> list = dingTalk.syncAllDDDepartmentList();
- if(list !=null && list.size()>0){
- List<Company> addList = new ArrayList<>();
- List<Company> updateList = new ArrayList<>();
- List<Long> delIds = new ArrayList<>();//淇敼涓轰娇鐢ㄩ拤閽塱d erpId
- List<Company> allList = companyMapper.selectList(new QueryWrapper<Company>().lambda().eq(Company::getType,Constants.ONE));
- dealCompanyChangeList(list,addList,updateList,delIds,allList);
- if(delIds.size()>0){
- syncDelCompany(delIds);
+ public String syncDDCompany() {
+ try {
+ List<OapiV2DepartmentGetResponse.DeptGetResponse> list = dingTalk.syncAllDDDepartmentList();
+ if(list !=null && list.size()>0){
+ List<Company> addList = new ArrayList<>();
+ List<Company> updateList = new ArrayList<>();
+ List<Long> delIds = new ArrayList<>();//淇敼涓轰娇鐢ㄩ拤閽塱d erpId
+ List<Company> allList = companyMapper.selectList(new QueryWrapper<Company>().lambda()
+ .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE));
+ dealCompanyChangeList(list,addList,updateList,delIds,allList);
+ if(delIds.size()>0){
+ syncDelCompany(delIds);
+ }
+ return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+updateList.size()+"銆戞潯锛屽垹闄ゃ��"+delIds.size()+"銆戞潯";
+ }else{
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁涓虹┖锛�");
}
- return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+updateList.size()+"銆戞潯锛屽垹闄ゃ��"+delIds.size()+"銆戞潯";
- }else{
- throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁涓虹┖锛�");
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁寮傚父锛�");
}
}
+ @Override
+ public String syncJdyCompany() {
+ //{
+ // "dept_no": 1,//鏁板瓧 1 涓烘牴閮ㄩ棬缂栧彿銆�
+ // "has_child": true
+ //}
+ DeptApiClient deptApiClient = new DeptApiClient(HttpConstant.API_KEY, HttpConstant.HOST);
+ try {
+ Map<String, Object> result = deptApiClient.deptList(1,true,deptApiClient.getDefaultVersion());
+ if(result!=null && result.get("departments")!=null ){
+ TypeReference<List<DeptEntityModel>> typeReference = new TypeReference<List<DeptEntityModel>>(){};
+ Object obj = result.get("departments");
+ List<DeptEntityModel> list = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(obj), typeReference.getType());
+ if(list !=null && list.size()>0){
+ List<Company> addList = new ArrayList<>();
+ List<Company> updateList = new ArrayList<>();
+ List<Long> delIds = new ArrayList<>();//淇敼涓轰娇鐢ㄩ拤閽塱d erpId
+ List<Company> allList = companyMapper.selectList(new QueryWrapper<Company>().lambda()
+ .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE));
+ dealCompanyChangeListJdy(list,addList,updateList,delIds,allList);
+ if(delIds.size()>0){
+ syncDelCompany(delIds);
+ }
+ return "鍚屾鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+updateList.size()+"銆戞潯锛屽垹闄ゃ��"+delIds.size()+"銆戞潯";
+ }else{
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾閽夐拤鏁版嵁涓虹┖锛�");
+ }
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鍚屾鏁版嵁寮傚父锛�");
+ }
+ return null;
+ }
+
+ private void dealCompanyChangeListJdy(List<DeptEntityModel> list, List<Company> addList, List<Company> updateList, List<Long> delIds, List<Company> allList) {
+ Date date = new Date();
+ for(DeptEntityModel respone : list){
+ Company param = new Company();
+ param.setName(respone.getName());
+ param.setErpId(respone.getDept_no().toString());
+ param.setErpParentId(respone.getParent_no() !=null?respone.getParent_no() .toString():null);
+ param.setSortnum(respone.getSeq()!=null?respone.getSeq().intValue():null);//榛樿鏈�涓婇潰
+ //鏍规嵁erpid鏌ヨ浼佷笟淇℃伅锛屽垽鏂槸鏂板杩樻槸鏇存柊
+ Company company = findCompanyByERPId(allList,respone.getDept_no().toString());
+ if(company == null){
+ //濡傛灉鏄柊澧�
+ //灏佽鏂板缁勭粐瀵硅薄鏁版嵁
+ addList.add(getAddCompanyModel(param));
+ }else{
+ updateList.add(getUpdateCompanyModel(param,company));
+ }
+ }
+ if(allList!=null && allList.size()>0){
+ for(Company c : allList){
+ if(!isCompanyDeletedJdy(c,list)){
+ delIds.add(Long.valueOf(c.getErpId()));
+ }
+ }
+ }
+ }
private void dealCompanyChangeList(List<OapiV2DepartmentGetResponse.DeptGetResponse> list, List<Company> addList, List<Company> updateList, List<Long> delIds, List<Company> allList) {
Date date = new Date();
for(OapiV2DepartmentGetResponse.DeptGetResponse respone : list){
+ Company param = new Company();
+ param.setName(respone.getName());
+ param.setErpId(respone.getDeptId().toString());
+ param.setErpParentId(respone.getParentId().toString());
+ param.setSortnum(respone.getOrder().intValue());//榛樿鏈�涓婇潰
//鏍规嵁erpid鏌ヨ浼佷笟淇℃伅锛屽垽鏂槸鏂板杩樻槸鏇存柊
Company company = findCompanyByERPId(allList,respone.getDeptId().toString());
if(company == null){
//濡傛灉鏄柊澧�
//灏佽鏂板缁勭粐瀵硅薄鏁版嵁
- addList.add(getAddCompanyModel(respone,new Company()));
+ addList.add(getAddCompanyModel(param));
}else{
- updateList.add(getUpdateCompanyModel(respone,company));
+ updateList.add(getUpdateCompanyModel(param,company));
}
}
if(allList!=null && allList.size()>0){
@@ -894,21 +980,20 @@
/**
* 鏁寸悊閽夐拤鍚屾 鏂板缁勭粐瀵硅薄
- * @param deptGetResponse
* @return
*/
- private Company getAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company) {
- return syncDDAddCompanyModel(deptGetResponse,company);
+ private Company getAddCompanyModel(Company param ) {
+ return syncDDAddCompanyModel(param);
}
/**
* 鏁寸悊閽夐拤鍚屾 鏂板 闇�瑕佷慨鏀圭殑缁勭粐瀵硅薄
- * @param deptGetResponse
+ * @param param
* @param company
* @return
*/
- private Company getUpdateCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse, Company company) {
- return syncDDEditCompanyModel(deptGetResponse,company);
+ private Company getUpdateCompanyModel(Company param, Company company) {
+ return syncDDEditCompanyModel(param,company);
}
@@ -937,36 +1022,50 @@
}
return false;
}
+ private boolean isCompanyDeletedJdy(Company c, List<DeptEntityModel> list) {
+ for(DeptEntityModel m : list){
+ if(StringUtils.equals(c.getErpId(),m.getDept_no().toString())){
+ return true;
+ }
+ }
+ return false;
+ }
/**
* 鏁寸悊 閽夐拤鍚屾鐨� 缁勭粐淇℃伅
- * @param deptGetResponse
- * @param company
+ * @param param
* @return
*/
- public Company syncDDAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){
- company = new Company();
+ public Company syncDDAddCompanyModel(Company param ){
+ Company company = new Company();
company.setCreateDate(new Date());
company.setIsdeleted(Constants.ZERO);
company.setStatus(Constants.ZERO);
- company.setName(deptGetResponse.getName());
- company.setErpId(deptGetResponse.getDeptId().toString());
- company.setErpParentId(deptGetResponse.getParentId().toString());
- company.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+// company.setName(deptGetResponse.getName());
+// company.setErpId(deptGetResponse.getDeptId().toString());
+// company.setErpParentId(deptGetResponse.getParentId().toString());
+// company.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+ company.setName(param.getName());
+ company.setErpId(param.getErpId() );
+ company.setErpParentId(param.getErpParentId());
+ company.setSortnum(param.getSortnum());//榛樿鏈�涓婇潰
company.setType(Constants.ONE);
String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode();
+ Company root =getRootCompanyModel(rootOrgId);
company.setCompanyPath(company.getId()+"/");//鍚嶇О璺緞
company.setCompanyNamePath(company.getName());//鍚嶇О璺緞
company.setHkParentId(rootOrgId);
String idPath = "";
- if(StringUtils.isNotBlank(company.getErpParentId()) && !StringUtils.equals(company.getErpParentId(),Constants.ONE+"")){
+ if(StringUtils.isNotBlank(company.getErpParentId())){
Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId())
.eq(Company::getIsdeleted,Constants.ZERO).last(" limit 1 "));
if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){
- throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅涓嶅瓨鍦▇");
+ //鐖剁骇涓嶅瓨鍦ㄧ殑锛岀洿鎺ユ寕鍦ㄦ牴缁勭粐涓�
+ parent = root;
+// throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅涓嶅瓨鍦▇");
}
// if(StringUtils.isBlank(parent.getHkId())){
// throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅灏氭湭鍚屾涓嬪彂鎴愬姛~");
@@ -982,6 +1081,7 @@
company.setHkParentId(parent.getHkId());
company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/");
company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName());
+ company.setParentId(parent.getId());
}
company.setHkCompanyPath(company.getCompanyNamePath());
company.setCreateDate(new Date());
@@ -995,62 +1095,103 @@
companyMapper.insert(company);
company.setHkId(UUID.randomUUID().toString().replace("-",""));
+ Company com = new Company();
+ com.setId(company.getId());
+ com.setCompanyPath(idPath+company.getId()+"/");
+ companyMapper.updateById(com);
//涓嬪彂娴峰悍瀹夐槻骞冲彴
- Boolean issueStatus = addHkOrg(company);
+ /* Boolean issueStatus = addHkOrg(company);
Company com = new Company();
com.setId(company.getId());
com.setHkId(issueStatus?company.getHkId():null);
com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO);
- com.setCompanyPath(idPath+company.getId()+"/");
- companyMapper.updateById(com);
+ companyMapper.updateById(com);*/
return company;
}
+ /**
+ * 鍐呯疆鏍圭粍缁�
+ * @param rootOrgId
+ * @return
+ */
+ private Company getRootCompanyModel(String rootOrgId) {
+ Company root = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
+ .eq(Company::getIsdeleted,Constants.ZERO)
+ .isNull(Company::getParentId)
+ .last(" limit 1 "));
+ if(root== null){
+ String name =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_NAME).getCode();
+ name =StringUtils.defaultString(name,"鏍圭粍缁�");
+ root = new Company();
+ root.setCreateDate(new Date());
+ root.setEditDate(new Date());
+ root.setName(name);
+ root.setType(-1);
+ root.setHkId(rootOrgId);
+ root.setHkStatus(Constants.ONE);
+ root.setIsdeleted(Constants.ZERO);
+ root.setStatus(Constants.ZERO);
+ root.setHkCompanyPath(rootOrgId+"/");
+ root.setCompanyNamePath(root.getName());
+ root.setHkDate(new Date());
+ root.setRemark("榛樿鏍圭粍缁�");
+ companyMapper.insert(root);
+ root.setCompanyPath(root.getId()+"/");
+ companyMapper.updateById(root);
+ }
+ return root;
- public Company syncDDEditCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){
- company.setErpParentId(deptGetResponse.getParentId().toString());
+ }
+
+
+ public Company syncDDEditCompanyModel(Company param,Company company){
+ company.setErpParentId(param.getErpParentId().toString());
+ String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode();
+ Company root =getRootCompanyModel(rootOrgId);
String idPath = "";
- if(StringUtils.isNotBlank(company.getErpParentId()) && !StringUtils.equals(company.getErpParentId(),Constants.ONE+"")){
- Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId())
- .eq(Company::getIsdeleted,Constants.ZERO).last("limit 1 "));
+ if(StringUtils.isNotBlank(company.getErpParentId())){
+ Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda()
+ .eq(Company::getErpId,company.getErpParentId())
+ .eq(Company::getType,Constants.ONE)
+ .eq(Company::getIsdeleted,Constants.ZERO)
+ .last("limit 1 "));
if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){
- throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鐖剁骇缁勭粐淇℃伅涓嶅瓨鍦▇");
+ parent =root;
}
- if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){
+ /* if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){
if(!Constants.equalsInteger(company.getType(),parent.getType())){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝缁勭粐淇℃伅閿欒");
}
}else if(Objects.isNull(parent.getType())){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝缁勭粐淇℃伅閿欒");
- }
+ }*/
idPath = parent.getCompanyPath();
company.setHkParentId(parent.getHkId());
company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/");
company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName());
+ company.setParentId(parent.getId());
}
- company.setName(deptGetResponse.getName());
- company.setErpId(deptGetResponse.getDeptId().toString());
- company.setErpParentId(deptGetResponse.getParentId().toString());
- company.setSortnum(deptGetResponse.getOrder().intValue());//榛樿鏈�涓婇潰
+ company.setName(param.getName());
+ company.setErpId(param.getErpId());
+ company.setSortnum(param.getSortnum());//榛樿鏈�涓婇潰
company.setEditDate(new Date());
- company.setHkCompanyPath(company.getCompanyNamePath());
+// company.setHkCompanyPath(company.getCompanyNamePath());
company.setHkStatus(Constants.ZERO);
company.setStatus(Constants.ZERO);
- company.setSortnum(deptGetResponse.getOrder().intValue());
company.setHkDate(company.getCreateDate());
company.setEditDate(company.getCreateDate());
company.setEditor(company.getCreator());
company.setPinyin(Constants.getChinesePingyin(company.getName()));
companyMapper.updateById(company);
//涓嬪彂娴峰悍瀹夐槻骞冲彴
- Boolean issueStatus = editHkOrg(company);
+ /* Boolean issueStatus = editHkOrg(company);
Company com = new Company();
com.setId(company.getId());
com.setHkId(issueStatus?company.getHkId():null);
com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO);
com.setCompanyPath(idPath+company.getId()+"/");
- companyMapper.updateById(com);
+ companyMapper.updateById(com);*/
return company;
}
@@ -1076,7 +1217,5 @@
doHkDeleteOrg(delIds,delHKIds,new Date());
}
}
-
-
}
--
Gitblit v1.9.3