diff --git a/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cDestinationController.java b/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cDestinationController.java index 6850c89..ef734e2 100644 --- a/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cDestinationController.java +++ b/emis-oms-biz-web/src/main/java/com/xdadan/erp/oms/web/Oms2cDestinationController.java @@ -90,5 +90,27 @@ public class Oms2cDestinationController extends BaseController } + /** + * 根据客户信息获取寄件网点 + * @param province + * @return + */ + @GetMapping("/getSendSite") + @JacksonFilter(include= {"siteCode","siteName", + },value= EmisDestination.class,type= JacksonFilter.JscksonFilterType.RESPONSE) + public AjaxResult getSendSite(String country, String lineCode, String province, String city, String county, String address) + { + if(StringUtils.isAnyEmpty(province)){ + return AjaxResult.error("参数错误,省份不能为空!"); + } + EmisDestination dest = emisDestinationService.calcSendSite(country,lineCode,province,city,county,address); + if(dest==null){ + return AjaxResult.error("联系客户,收件地不在服务范围!"); + }else{ + return AjaxResult.success("获取成功",dest); + } + + } + } diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisCountryArea.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisCountryArea.java index 6a80402..12aacfb 100644 --- a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisCountryArea.java +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/domain/EmisCountryArea.java @@ -23,6 +23,7 @@ import lombok.Data; @Data public class EmisCountryArea extends BaseEntity { + private static final long serialVersionUID = 1L; /* 区域序号 */ @@ -35,6 +36,13 @@ public class EmisCountryArea extends BaseEntity private String countryCode; /* 国际名称 */ private String countryName; + /* 服务网点 */ + private String siteCode; + + // 扩展字段 +// 服务网点名称 + private String siteName; + } diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/IEmisDestinationService.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/IEmisDestinationService.java index 087b190..564afb0 100644 --- a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/IEmisDestinationService.java +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/IEmisDestinationService.java @@ -47,12 +47,15 @@ public interface IEmisDestinationService */ public EmisDestination calcDestSite(String country,String lineCode,String province,String city,String county,String address); - /** - * 新增目的地 - * - * @param emisDestination 目的地 - * @return 结果 - */ + public EmisDestination calcSendSite(String country,String lineCode, String province, String city, String county, String address); + + + /** + * 新增目的地 + * + * @param emisDestination 目的地 + * @return 结果 + */ public int insertEmisDestination(EmisDestination emisDestination); /** diff --git a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/impl/EmisDestinationServiceImpl.java b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/impl/EmisDestinationServiceImpl.java index f6bd68a..f72ac1d 100644 --- a/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/impl/EmisDestinationServiceImpl.java +++ b/emis-oms-biz/src/main/java/com/xdadan/erp/oms/service/impl/EmisDestinationServiceImpl.java @@ -13,15 +13,20 @@ package com.xdadan.erp.oms.service.impl; import java.util.List; import cn.hutool.core.collection.CollectionUtil; +import com.xdadan.erp.oms.domain.EmisCountryArea; import com.xdadan.erp.oms.domain.EmisRegion; +import com.xdadan.erp.oms.mapper.EmisCountryAreaMapper; import com.xdadan.erp.oms.mapper.EmisRegionMapper; +import com.xdadan.erp.oms.service.IEmisCountryAreaService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xdadan.erp.oms.domain.EmisDestination; import com.xdadan.erp.oms.mapper.EmisDestinationMapper; import com.xdadan.erp.oms.service.IEmisDestinationService; +import org.springframework.util.CollectionUtils; -/** + /** * 目的地Service业务层处理 * * @author linfso @@ -36,6 +41,9 @@ public class EmisDestinationServiceImpl implements IEmisDestinationService @Autowired private EmisRegionMapper emisRegionMapper; + @Autowired + private EmisCountryAreaMapper emisCountryAreaMapper; + /** * 查询目的地 * @@ -60,8 +68,81 @@ public class EmisDestinationServiceImpl implements IEmisDestinationService return emisDestinationMapper.selectEmisDestinationList(emisDestination); } + + public EmisRegion getRegionByCode(String code){ + + EmisRegion queryRegion = new EmisRegion(); + queryRegion.setRegionCode(code); + + List list=emisRegionMapper.selectEmisRegionList(queryRegion); + if(!CollectionUtils.isEmpty(list)){ + return list.get(0); + } + + return null; + + } + /** * 计算目的地 + * @param country + * @param lineCode + * @param province + * @param city + * @param county + * @param address + * @return + */ + public EmisDestination calcDestSite(String country,String lineCode, String province, String city, String county, String address) { + + EmisDestination destination=null; + // 获取 areaId + Long areaId = null; + + // 根据区获取目的地 + if(!StringUtils.isEmpty(county)) { + EmisRegion regionCounty = getRegionByCode(county); + if (regionCounty != null) { + areaId = regionCounty.getAreaId(); + } + } + + + // 根据城市获取目的地 + if( (areaId==null || areaId==0) && !StringUtils.isEmpty(city)) { + EmisRegion regionCity = getRegionByCode(city); + if (regionCity != null) { + areaId = regionCity.getAreaId(); + } + } + + // 根据省获取目的地 + if((areaId==null || areaId==0) && !StringUtils.isEmpty(province)){ + EmisRegion regionProvice= getRegionByCode(province); + if(regionProvice!=null){ + areaId=regionProvice.getAreaId(); + } + } + + // 根据大区获取目的网点 + if(areaId!=null && areaId>0) { + EmisDestination queryEmisDestination = new EmisDestination(); + queryEmisDestination.setCountryAreaId(areaId); + queryEmisDestination.setStatus(1); + List destinationList = emisDestinationMapper.selectEmisDestinationList(queryEmisDestination); + if (!CollectionUtil.isEmpty(destinationList)) { + destination=destinationList.get(0); + } + } + + return destination; + + + } + + + /** + * 计算寄件网点 * @param lineCode * @param province * @param city @@ -70,42 +151,50 @@ public class EmisDestinationServiceImpl implements IEmisDestinationService * @return */ @Override - public EmisDestination calcDestSite(String country,String lineCode, String province, String city, String county, String address) { + public EmisDestination calcSendSite(String country,String lineCode, String province, String city, String county, String address) { - // 目前只根据目的省份获取目的地 + EmisDestination destination=null; // 获取 areaId Long areaId = null; - EmisRegion queryEmisRegion = new EmisRegion(); - queryEmisRegion.setRegionCode(province); - List regionList= emisRegionMapper.selectEmisRegionList(queryEmisRegion); - if(!CollectionUtil.isEmpty(regionList)){ - areaId = regionList.get(0).getAreaId(); - country = regionList.get(0).getCountryCode(); - // 根据大区获取目的网点 - EmisDestination queryEmisDestination = new EmisDestination(); - queryEmisDestination.setCountryAreaId(areaId); - queryEmisDestination.setStatus(1); - List destinationList=emisDestinationMapper.selectEmisDestinationList(queryEmisDestination); - if(!CollectionUtil.isEmpty(destinationList)){ - return destinationList.get(0); + // 根据区获取目的地 + if(!StringUtils.isEmpty(county)) { + EmisRegion regionCounty = getRegionByCode(county); + if (regionCounty != null) { + areaId = regionCounty.getAreaId(); } - else{ - // 根据国家查询 - queryEmisDestination = new EmisDestination(); - queryEmisDestination.setCountry(country); - queryEmisDestination.setStatus(1); - destinationList=emisDestinationMapper.selectEmisDestinationList(queryEmisDestination); - if(!CollectionUtil.isEmpty(destinationList)){ - return destinationList.get(0); - } + } + + + // 根据城市获取目的地 + if( (areaId==null || areaId==0) && !StringUtils.isEmpty(city)) { + EmisRegion regionCity = getRegionByCode(city); + if (regionCity != null) { + areaId = regionCity.getAreaId(); + } + } + + // 根据省获取目的地 + if((areaId==null || areaId==0) && !StringUtils.isEmpty(province)){ + EmisRegion regionProvice= getRegionByCode(province); + if(regionProvice!=null){ + areaId=regionProvice.getAreaId(); + } + } + + // 根据大区获取服务网点 + if(areaId!=null && areaId>0) { + EmisCountryArea emisCountryArea =emisCountryAreaMapper.selectEmisCountryAreaById(areaId); + if(emisCountryArea!=null){ + EmisDestination emisDestination = new EmisDestination(); + emisDestination.setSiteCode(emisCountryArea.getSiteCode()); + emisDestination.setSiteName(emisCountryArea.getSiteName()); } } - - return null; + return destination; } diff --git a/emis-oms-biz/src/main/resources/mapper/EmisCountryAreaMapper.xml b/emis-oms-biz/src/main/resources/mapper/EmisCountryAreaMapper.xml index 822902a..b8f8c2d 100644 --- a/emis-oms-biz/src/main/resources/mapper/EmisCountryAreaMapper.xml +++ b/emis-oms-biz/src/main/resources/mapper/EmisCountryAreaMapper.xml @@ -10,23 +10,26 @@ + - + - select id, name, name_en, country_code, country_name, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_country_area + select id, name, name_en, country_code, country_name, site_code, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_country_area + + - + insert into emis_country_area id, @@ -54,6 +78,7 @@ name_en, country_code, country_name, + site_code, remark, tenant_id, del_flag, @@ -70,6 +95,7 @@ #{nameEn}, #{countryCode}, #{countryName}, + #{siteCode}, #{remark}, #{tenantId}, #{delFlag}, @@ -89,6 +115,7 @@ name_en = #{nameEn}, country_code = #{countryCode}, country_name = #{countryName}, + site_code = #{siteCode}, remark = #{remark}, tenant_id = #{tenantId}, del_flag = #{delFlag},