|
|
@ -33,6 +33,7 @@ import com.epmet.constant.CustomerAgencyConstant; |
|
|
|
import com.epmet.constant.OrgInfoConstant; |
|
|
|
import com.epmet.constant.RoleKeyConstants; |
|
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
|
import com.epmet.dao.CustomerDepartmentDao; |
|
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
@ -93,7 +94,8 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private IcBuildingDao icBuildingDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CustomerDepartmentDao customerDepartmentDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
@ -152,10 +154,19 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
originalEntity.setCode(formDTO.getCode()); |
|
|
|
originalEntity.setContacts(formDTO.getContacts()); |
|
|
|
originalEntity.setMobile(formDTO.getMobile()); |
|
|
|
if(StringUtils.isNotBlank(formDTO.getAreaCode())&&formDTO.getAreaCode().equals(originalEntity.getAreaCode())){ |
|
|
|
if (StringUtils.isNotBlank(formDTO.getAreaCode()) && !formDTO.getAreaCode().equals(originalEntity.getAreaCode())) { |
|
|
|
CustomerAgencyEntity parent = customerAgencyDao.selectById(originalEntity.getPid()); |
|
|
|
//如果修改了areaCode。
|
|
|
|
customerAgencyDao.updateSubAgencyAreaCode(originalEntity.getCustomerId(),originalEntity.getAreaCode(),formDTO.getUserId()); |
|
|
|
if(StringUtils.isNotBlank(originalEntity.getAreaCode())){ |
|
|
|
//如果原来这个组织有area_code再去更新,没有其实应该按照pids去更新。
|
|
|
|
// customerAgencyDao.updateSubAgencyAreaCode(originalEntity.getCustomerId(), originalEntity.getAreaCode(), formDTO.getUserId());
|
|
|
|
customerAgencyDao.updateSubAgencyAreaCodeById(originalEntity.getCustomerId(), originalEntity.getId(), formDTO.getUserId()); |
|
|
|
//网格的
|
|
|
|
customerGridDao.updateSubGridAreaCode(originalEntity.getCustomerId(), originalEntity.getId(), formDTO.getUserId()); |
|
|
|
//部门的
|
|
|
|
customerDepartmentDao.updateSubDeptAreaCode(originalEntity.getCustomerId(), originalEntity.getAreaCode(), formDTO.getUserId()); |
|
|
|
} |
|
|
|
|
|
|
|
//判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码
|
|
|
|
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) { |
|
|
|
//校验areaCode是否被使用过
|
|
|
@ -166,6 +177,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg()); |
|
|
|
} |
|
|
|
originalEntity.setAreaCode(formDTO.getAreaCode()); |
|
|
|
originalEntity.setParentAreaCode(parent.getAreaCode()); |
|
|
|
}else{ |
|
|
|
//如果选择的是other,需要自定义一个编码
|
|
|
|
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO(); |
|
|
@ -177,7 +189,11 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg()); |
|
|
|
} |
|
|
|
originalEntity.setAreaCode(addAreaCodeResult.getData()); |
|
|
|
originalEntity.setParentAreaCode(parent.getAreaCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
customerGridDao.updateGridAreaCode(originalEntity.getId(),formDTO.getAreaCode()); |
|
|
|
customerDepartmentDao.updateDeptAreaCode(originalEntity.getId(),formDTO.getAreaCode()); |
|
|
|
} |
|
|
|
|
|
|
|
//1:更新当前组织信息
|
|
|
@ -314,19 +330,19 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
if (null != entity && StringUtils.isNotBlank(entity.getAreaCode())) { |
|
|
|
switch (entity.getLevel()) { |
|
|
|
case CustomerAgencyConstant.PROVINCE_LEVEL: |
|
|
|
agencysResultDTO.setAreaName(null == entity.getProvince() ? StrConstant.EPMETY_STR : entity.getProvince()); |
|
|
|
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getProvince()) ? entity.getProvince():entity.getOrganizationName()); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.CITY_LEVEL: |
|
|
|
agencysResultDTO.setAreaName(null == entity.getCity() ? StrConstant.EPMETY_STR : entity.getCity()); |
|
|
|
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getCity()) ? entity.getCity():entity.getOrganizationName()); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.DISTRICT: |
|
|
|
agencysResultDTO.setAreaName(null == entity.getDistrict() ? StrConstant.EPMETY_STR : entity.getDistrict()); |
|
|
|
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getDistrict()) ? entity.getDistrict():entity.getOrganizationName()); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.STREET_LEVEL: |
|
|
|
agencysResultDTO.setAreaName(null == entity.getStreet() ? StrConstant.EPMETY_STR : entity.getStreet()); |
|
|
|
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getStreet()) ? entity.getStreet():entity.getOrganizationName()); |
|
|
|
break; |
|
|
|
case CustomerAgencyConstant.COMMUNITY_LEVEL: |
|
|
|
agencysResultDTO.setAreaName(null == entity.getCommunity() ? StrConstant.EPMETY_STR : entity.getCommunity()); |
|
|
|
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getCommunity()) ? entity.getCommunity():entity.getOrganizationName()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR); |
|
|
|