|
|
@ -161,13 +161,14 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
|
|
|
|
//当前客户开启了area_code_switch参数:open: 选择地区编码必填;closed: 无需选择地区编码
|
|
|
|
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) { |
|
|
|
CustomerAgencyEntity parent = customerAgencyDao.selectById(originalEntity.getPid()); |
|
|
|
if (null != parent) { |
|
|
|
//开关开启后,areaCode必填
|
|
|
|
String originalAreaCode = originalEntity.getAreaCode(); |
|
|
|
checkEditAgencyFormDTO(formDTO,originalAreaCode); |
|
|
|
checkEditAgencyFormDTO(formDTO, originalEntity); |
|
|
|
// 1、之前当前组织没有编码,本次修改设置了编码
|
|
|
|
// 2、之前已经有编码,本次修改为了其他编码
|
|
|
|
if (StringUtils.isNotBlank(formDTO.getAreaCode()) && !formDTO.getAreaCode().equals(originalAreaCode)) { |
|
|
|
CustomerAgencyEntity parent = customerAgencyDao.selectById(originalEntity.getPid()); |
|
|
|
String newAreaCode = getAgencyNewAreaCode(formDTO, parent); |
|
|
|
originalEntity.setAreaCode(newAreaCode); |
|
|
|
originalEntity.setParentAreaCode(parent.getAreaCode()); |
|
|
@ -179,6 +180,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
updateSubOrg(originalEntity.getCustomerId(), formDTO, originalAreaCode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//1:更新当前组织信息
|
|
|
|
if (customerAgencyDao.updateById(originalEntity) < NumConstant.ONE) { |
|
|
@ -306,7 +308,9 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
* 如果当前客户开启了areaCode,校验参数逼单 |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
private void checkEditAgencyFormDTO(EditAgencyFormDTO formDTO,String originalAreaCode) { |
|
|
|
private void checkEditAgencyFormDTO(EditAgencyFormDTO formDTO,CustomerAgencyEntity originalEntity) { |
|
|
|
//根组织不允许修改
|
|
|
|
if (StringUtils.isNotBlank(originalEntity.getPid()) && !NumConstant.ZERO_STR.equals(originalEntity.getPid())) { |
|
|
|
if (StringUtils.isBlank(formDTO.getAreaCode())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "area_code_switch is open areaCode不能为空", "组织区划不能为空"); |
|
|
|
} |
|
|
@ -314,13 +318,14 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "area_code_switch is open parentAreaCode不能为空", "请先设置上级组织的组织区划"); |
|
|
|
} |
|
|
|
//如果当前组织已经使用了自定义编码,不允许在选择其他。
|
|
|
|
if (StringUtils.isNotBlank(originalAreaCode) |
|
|
|
&& originalAreaCode.contains("UD") |
|
|
|
if (StringUtils.isNotBlank(originalEntity.getAreaCode()) |
|
|
|
&& originalEntity.getAreaCode().contains("UD") |
|
|
|
&& StringUtils.isNotBlank(formDTO.getAreaCode()) |
|
|
|
&& "other".equals(formDTO.getAreaCode())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "自定义编码不允许修改", "自定义组织区划代码不允许修改"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
@ -384,27 +389,6 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
agencysResultDTO.setCode(entity.getCode()); |
|
|
|
agencysResultDTO.setContacts(entity.getContacts()); |
|
|
|
agencysResultDTO.setMobile(entity.getMobile()); |
|
|
|
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 start
|
|
|
|
if (null != entity) { |
|
|
|
if (null == entity.getPids() || "".equals(entity.getPids())) { |
|
|
|
agencysResultDTO.setRootlevel(entity.getLevel()); |
|
|
|
} else { |
|
|
|
String id = Arrays.asList(entity.getPids().split(":")).get(0); |
|
|
|
CustomerAgencyEntity rootEntity = customerAgencyDao.selectById(id); |
|
|
|
if (null != rootEntity) { |
|
|
|
agencysResultDTO.setRootlevel(rootEntity.getLevel()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 end
|
|
|
|
//2:查询本机关的所有上级机关,按自上而下层级顺序
|
|
|
|
if (null == entity.getPids()) { |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
return new Result<AgencysResultDTO>().ok(agencysResultDTO); |
|
|
|
} |
|
|
|
List<String> listStr = Arrays.asList(entity.getPids().split(":")); |
|
|
|
parentList = customerAgencyDao.selectPAgencyById(listStr); |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
agencysResultDTO.setAreaCodeSwitch(customerOrgParameterService.getAreaCodeSwitch(entity.getCustomerId())); |
|
|
|
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR); |
|
|
|
agencysResultDTO.setAreaCode(StringUtils.isNotBlank(entity.getAreaCode())?entity.getAreaCode():StrConstant.EPMETY_STR); |
|
|
@ -430,13 +414,30 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
} |
|
|
|
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 start
|
|
|
|
if (null != entity) { |
|
|
|
if (null == entity.getPids() || "".equals(entity.getPids())) { |
|
|
|
agencysResultDTO.setRootlevel(entity.getLevel()); |
|
|
|
} else { |
|
|
|
String id = Arrays.asList(entity.getPids().split(":")).get(0); |
|
|
|
CustomerAgencyEntity rootEntity = customerAgencyDao.selectById(id); |
|
|
|
if (null != rootEntity) { |
|
|
|
agencysResultDTO.setRootlevel(rootEntity.getLevel()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//2021.5.26 sun 添加当前组织对应客户的根组织级别返参 end
|
|
|
|
//2:查询本机关的所有上级机关,按自上而下层级顺序
|
|
|
|
if (StringUtils.isBlank(entity.getPids())) { |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
return new Result<AgencysResultDTO>().ok(agencysResultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
String m="1234"; |
|
|
|
System.out.println(m.equals("1234") ? "yes" : "no"); |
|
|
|
List<String> listStr = Arrays.asList(entity.getPids().split(":")); |
|
|
|
parentList = customerAgencyDao.selectPAgencyById(listStr); |
|
|
|
agencysResultDTO.setParentList(parentList); |
|
|
|
return new Result<AgencysResultDTO>().ok(agencysResultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|