From 4231df84d514b0c4565160e283e9e5f5947a61c5 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Fri, 30 Jan 2026 09:47:07 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20=20=20=E7=89=B9=E5=8C=BA=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E7=AE=A1=E7=90=86=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...EmisSpecialZoneAddressMatchController.java | 178 +++++++++++ .../domain/EmisSpecialZoneAddressMatch.java | 55 ++++ .../EmisSpecialZoneAddressMatchMapper.java | 87 ++++++ .../IEmisSpecialZoneAddressMatchService.java | 94 ++++++ ...misSpecialZoneAddressMatchServiceImpl.java | 287 ++++++++++++++++++ .../EmisSpecialZoneAddressMatchMapper.xml | 135 ++++++++ 6 files changed, 836 insertions(+) create mode 100644 emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSpecialZoneAddressMatchController.java create mode 100644 emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisSpecialZoneAddressMatch.java create mode 100644 emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSpecialZoneAddressMatchMapper.java create mode 100644 emis-biz/src/main/java/com/xdadan/erp/emis/service/IEmisSpecialZoneAddressMatchService.java create mode 100644 emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSpecialZoneAddressMatchServiceImpl.java create mode 100644 emis-biz/src/main/resources/mapper/EmisSpecialZoneAddressMatchMapper.xml diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSpecialZoneAddressMatchController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSpecialZoneAddressMatchController.java new file mode 100644 index 000000000..ac426b5f2 --- /dev/null +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisSpecialZoneAddressMatchController.java @@ -0,0 +1,178 @@ +/** + * @Project: emis + * @Title: EmisSpecialZoneAddressMatchController.java + * @author heyu + * @date 2026-01-28 10:00:00 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

特区地址匹配管理 控制器

+ */ + +package com.xdadan.erp.web.emis; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.alibaba.fastjson.JSONObject; +import com.xdadan.erp.emis.domain.exception.EmisBizError; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.xdadan.erp.common.annotation.Log; +import com.xdadan.erp.common.core.controller.BaseController; +import com.xdadan.erp.common.core.domain.AjaxResult; +import com.xdadan.erp.common.core.page.TableDataInfo; +import com.xdadan.erp.common.enums.BusinessType; +import com.xdadan.erp.common.utils.poi.ExcelUtil; + +import com.xdadan.erp.emis.domain.EmisSpecialZoneAddressMatch; +import com.xdadan.erp.emis.service.IEmisSpecialZoneAddressMatchService; + +/** + * 特区地址匹配管理Controller + * + * @author heyu + * @date 2026-01-28 10:00:00 + */ +@RestController +@RequestMapping("/emis/emisSpecialZoneAddressMatch") +public class EmisSpecialZoneAddressMatchController extends BaseController +{ + @Autowired + private IEmisSpecialZoneAddressMatchService emisSpecialZoneAddressMatchService; + + /** + * 查询特区地址匹配管理列表 + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:list')") + @GetMapping("/list") + public TableDataInfo list(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + startPage(); + List list = emisSpecialZoneAddressMatchService.selectEmisSpecialZoneAddressMatchList(emisSpecialZoneAddressMatch); + return getDataTable(list); + } + + /** + * 导出特区地址匹配管理列表 + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:export')") + @Log(title = "特区地址匹配管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + List list = emisSpecialZoneAddressMatchService.selectEmisSpecialZoneAddressMatchList(emisSpecialZoneAddressMatch); + ExcelUtil util = new ExcelUtil(EmisSpecialZoneAddressMatch.class); + util.exportExcel(response, list, "特区地址匹配管理数据"); + } + + /** + * 获取特区地址匹配管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(emisSpecialZoneAddressMatchService.selectEmisSpecialZoneAddressMatchById(id)); + } + + /** + * 新增特区地址匹配管理 + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:add')") + @Log(title = "特区地址匹配管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + try { + return toAjax(emisSpecialZoneAddressMatchService.insertEmisSpecialZoneAddressMatch(emisSpecialZoneAddressMatch)); + } catch (EmisBizError e) { + return AjaxResult.error(e.getMessage()); + } catch (Exception ex) { + ex.printStackTrace(); + return AjaxResult.error("操作异常:" + ex.getMessage()); + } + } + + /** + * 修改特区地址匹配管理 + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:edit')") + @Log(title = "特区地址匹配管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + try { + return toAjax(emisSpecialZoneAddressMatchService.updateEmisSpecialZoneAddressMatch(emisSpecialZoneAddressMatch)); + } catch (EmisBizError e) { + return AjaxResult.error(e.getMessage()); + } catch (Exception ex) { + ex.printStackTrace(); + return AjaxResult.error("操作异常:" + ex.getMessage()); + } + } + + /** + * 删除特区地址匹配管理(仅支持单个删除) + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:remove')") + @Log(title = "特区地址匹配管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{id}") + public AjaxResult remove(@PathVariable("id") Long id) + { + return toAjax(emisSpecialZoneAddressMatchService.deleteEmisSpecialZoneAddressMatchById(id)); + } + + /** + * 草稿提交特区地址匹配管理 + */ + @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:draftSubmit')") + @Log(title = "特区地址匹配管理", businessType = BusinessType.INSERT) + @PostMapping("/draftSubmit") + public AjaxResult draftSubmitSpecialZone(@RequestBody EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + JSONObject jObjOut = new JSONObject(); + String result = "success"; + String msg = "保存成功"; + try { + emisSpecialZoneAddressMatchService.draftSubmitSpecialZone(emisSpecialZoneAddressMatch); + jObjOut.put("emisSpecialZoneAddressMatch", emisSpecialZoneAddressMatch); + } + catch (EmisBizError ex) { + ex.printStackTrace(); + result = "fail"; + msg = ex.getErrorCode() + ":" + ex.getMessage(); + } + catch (Exception ex) { + result = "fail"; + ex.printStackTrace(); + msg = "系统异常:" + ex.getMessage(); + if (ex instanceof EmisBizError) { + msg = ((EmisBizError) ex).getErrorCode() + ":" + ex.getMessage(); + } + } + jObjOut.put("result", result); + jObjOut.put("msg", msg); + return AjaxResult.success("成功", jObjOut); + } + + /** + * 按地址匹配特区标签 + * + */ +// @PreAuthorize("@ss.hasPermi('emis:emisSpecialZoneAddressMatch:matchByAddress')") + @GetMapping("/matchByAddress") + public AjaxResult matchByAddress(String address) + { + EmisSpecialZoneAddressMatch matched = emisSpecialZoneAddressMatchService.matchByAddress(address); + return AjaxResult.success(matched); + } +} diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisSpecialZoneAddressMatch.java b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisSpecialZoneAddressMatch.java new file mode 100644 index 000000000..4a47fd4ca --- /dev/null +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/EmisSpecialZoneAddressMatch.java @@ -0,0 +1,55 @@ +/** + * @Project: emis + * @Title: EmisSpecialZoneAddressMatch.java + * @author heyu + * @date 2026-01-28 10:00:00 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

特区地址匹配管理 实体类

+ */ + +package com.xdadan.erp.emis.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.xdadan.erp.common.annotation.Excel; +import com.xdadan.erp.common.core.domain.BaseEntity; +import lombok.Data; + + +/** + * @ClassName EmisSpecialZoneAddressMatch + * @Description 特区地址匹配管理 + * @author heyu + * @date 2026-01-28 10:00:00 + */ +@Data +public class EmisSpecialZoneAddressMatch extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /* id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /* 国家代码 */ + private String countryCode; + + /* 省份代码 */ + private String provinceCode; + + /* 特区名称 */ + private String specialZoneName; + + /* 特区标签 */ + private String specialZoneTag; + + // 查询返回字段 + /* 国家名称 */ + private String countryName; + + /* 省份名称 */ + private String provinceName; + + +} diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSpecialZoneAddressMatchMapper.java b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSpecialZoneAddressMatchMapper.java new file mode 100644 index 000000000..178a8b903 --- /dev/null +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSpecialZoneAddressMatchMapper.java @@ -0,0 +1,87 @@ +/** + * @Project: emis + * @Title: EmisSpecialZoneAddressMatchMapper.java + * @author heyu + * @date 2026-01-28 10:00:00 + * @Copyright: ShangHai Doitinfo 2022 All rights reserved. + * @version v1.0 + * @Description:

特区地址匹配管理 Mapper 接口

+ * Warning : This file is generate by ai tools,don't edit!!! + */ +package com.xdadan.erp.emis.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.xdadan.erp.emis.domain.EmisSpecialZoneAddressMatch; +/** + * @ClassName EmisSpecialZoneAddressMatchMapper + * @Description

特区地址匹配管理 Mapper 接口

+ * @author heyu + * @date 2026-01-28 10:00:00 + */ +public interface EmisSpecialZoneAddressMatchMapper extends BaseMapper +{ + /** + * 主键查询 + * @param id + * @return + */ + public EmisSpecialZoneAddressMatch selectEmisSpecialZoneAddressMatchById(Long id); + + /** + * 查询列表 + * + * @param emisSpecialZoneAddressMatch + * @return 集合 + */ + public List selectEmisSpecialZoneAddressMatchList(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch); + + /** + * 检查是否重复 + * + * @param emisSpecialZoneAddressMatch + * @return 数量 + */ + public int checkUnique(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch); + + + /** + * 新增 + * + * @param emisSpecialZoneAddressMatch + * @return + */ + public int insertEmisSpecialZoneAddressMatch(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch); + + /** + * 修改 + * + * @param emisSpecialZoneAddressMatch + * @return + */ + public int updateEmisSpecialZoneAddressMatch(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch); + + /** + * 删除 + * + * @param id 主键 + * @return 结果 + */ + public int deleteEmisSpecialZoneAddressMatchById(Long id); + + /** + * 批量删除 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmisSpecialZoneAddressMatchByIds(Long[] ids); + + /** + * 按标准化后的地址匹配特区标签(去空格+转大写,判断地址串是否包含标签串) + * + * @param normalizedAddress 标准化后的地址(已去空格并转大写) + * @return 匹配到的记录,未匹配返回 null + */ + public EmisSpecialZoneAddressMatch selectByNormalizedAddress(String normalizedAddress); +} diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/IEmisSpecialZoneAddressMatchService.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/IEmisSpecialZoneAddressMatchService.java new file mode 100644 index 000000000..231541521 --- /dev/null +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/IEmisSpecialZoneAddressMatchService.java @@ -0,0 +1,94 @@ +/** + * @Project: emis + * @Title: IEmisSpecialZoneAddressMatchService.java + * @author heyu + * @date 2026-01-28 10:00:00 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

特区地址匹配管理 服务类接口

+ */ +package com.xdadan.erp.emis.service; + +import java.util.List; +import com.xdadan.erp.emis.domain.EmisSpecialZoneAddressMatch; + +/** + * @ClassName IEmisSpecialZoneAddressMatchService + * @Description 特区地址匹配管理 + * @author heyu + * @date 2026-01-28 10:00:00 + */ +public interface IEmisSpecialZoneAddressMatchService +{ + /** + * 主键查询 + * @param id + * @return + */ + public EmisSpecialZoneAddressMatch selectEmisSpecialZoneAddressMatchById(Long id); + + /** + * 查询特区地址匹配管理列表 + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 特区地址匹配管理集合 + */ + public List selectEmisSpecialZoneAddressMatchList(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch); + + + /** + * 检查是否重复 + * + * @param emisSpecialZoneAddressMatch + * @return 数量 + */ + public int checkUnique(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch); + + /** + * 新增特区地址匹配管理 + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 结果 + */ + public int insertEmisSpecialZoneAddressMatch(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) throws com.xdadan.erp.emis.domain.exception.EmisBizError; + + /** + * 修改特区地址匹配管理 + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 结果 + */ + public int updateEmisSpecialZoneAddressMatch(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) throws com.xdadan.erp.emis.domain.exception.EmisBizError; + + /** + * 批量删除特区地址匹配管理 + * + * @param ids 需要删除的特区地址匹配管理主键集合 + * @return 结果 + */ + public int deleteEmisSpecialZoneAddressMatchByIds(Long[] ids); + + /** + * 删除特区地址匹配管理信息 + * + * @param id 特区地址匹配管理主键 + * @return 结果 + */ + public int deleteEmisSpecialZoneAddressMatchById(Long id); + + /** + * 草稿提交特区地址匹配管理(前端传countryName、provinceName,转换为code后保存) + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 结果 + */ + public int draftSubmitSpecialZone(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) throws com.xdadan.erp.emis.domain.exception.EmisBizError; + + /** + * 按地址匹配特区标签(去空格+转大写后做等值匹配) + * + * @param address 前端传入的地址 + * @return 匹配到的记录,未匹配返回 null + */ + public EmisSpecialZoneAddressMatch matchByAddress(String address); +} diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSpecialZoneAddressMatchServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSpecialZoneAddressMatchServiceImpl.java new file mode 100644 index 000000000..c2ad483a6 --- /dev/null +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSpecialZoneAddressMatchServiceImpl.java @@ -0,0 +1,287 @@ +/** + * @Project: emis + * @Title: EmisSpecialZoneAddressMatchServiceImpl.java + * @author heyu + * @date 2026-01-28 10:00:00 + * @Copyright: ShangHai Duta 2022 All rights reserved. + * @version v1.0 + * @Description:

特区地址匹配管理 实体类

+ */ + +package com.xdadan.erp.emis.service.impl; + +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xdadan.erp.emis.domain.EmisSpecialZoneAddressMatch; +import com.xdadan.erp.emis.domain.EmisCountry; +import com.xdadan.erp.emis.domain.EmisRegion; +import com.xdadan.erp.emis.mapper.EmisSpecialZoneAddressMatchMapper; +import com.xdadan.erp.emis.mapper.EmisRegionMapper; +import com.xdadan.erp.emis.service.IEmisSpecialZoneAddressMatchService; +import com.xdadan.erp.emis.service.EmisBaseService; +import com.xdadan.erp.emis.domain.exception.EmisBizError; +import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType; + +/** + * 特区地址匹配管理Service业务层处理 + * + * @author heyu + * @date 2026-01-28 10:00:00 + */ +@Service +public class EmisSpecialZoneAddressMatchServiceImpl implements IEmisSpecialZoneAddressMatchService +{ + @Autowired + private EmisSpecialZoneAddressMatchMapper emisSpecialZoneAddressMatchMapper; + + @Autowired + private EmisBaseService emisBaseService; + + + @Autowired + private EmisRegionMapper emisRegionMapper; + + /** + * 查询特区地址匹配管理 + * + * @param id 特区地址匹配管理主键 + * @return 特区地址匹配管理 + */ + @Override + public EmisSpecialZoneAddressMatch selectEmisSpecialZoneAddressMatchById(Long id) + { + return emisSpecialZoneAddressMatchMapper.selectEmisSpecialZoneAddressMatchById(id); + } + + /** + * 查询特区地址匹配管理列表 + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 特区地址匹配管理 + */ + @Override + public List selectEmisSpecialZoneAddressMatchList(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + return emisSpecialZoneAddressMatchMapper.selectEmisSpecialZoneAddressMatchList(emisSpecialZoneAddressMatch); + } + + /** + * 检查是否重复 + * + * @param emisSpecialZoneAddressMatch + * @return 数量 + */ + @Override + public int checkUnique(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) + { + return emisSpecialZoneAddressMatchMapper.checkUnique(emisSpecialZoneAddressMatch); + } + + /** + * 新增特区地址匹配管理 + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 结果 + */ + @Override + public int insertEmisSpecialZoneAddressMatch(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) throws EmisBizError + { + // 验证必填项 + validateRequiredFields(emisSpecialZoneAddressMatch); + + // 检查specialZoneTag是否唯一 + if (checkUnique(emisSpecialZoneAddressMatch) > 0) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区标签已存在,不能重复"); + } + + return emisSpecialZoneAddressMatchMapper.insertEmisSpecialZoneAddressMatch(emisSpecialZoneAddressMatch); + } + + /** + * 修改特区地址匹配管理 + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 结果 + */ + @Override + public int updateEmisSpecialZoneAddressMatch(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) throws EmisBizError + { + // 验证必填项 + validateRequiredFields(emisSpecialZoneAddressMatch); + + // 检查specialZoneTag是否唯一 + if (checkUnique(emisSpecialZoneAddressMatch) > 0) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区标签已存在,不能重复"); + } + + return emisSpecialZoneAddressMatchMapper.updateEmisSpecialZoneAddressMatch(emisSpecialZoneAddressMatch); + } + + /** + * 批量删除特区地址匹配管理 + * + * @param ids 需要删除的特区地址匹配管理主键 + * @return 结果 + */ + @Override + public int deleteEmisSpecialZoneAddressMatchByIds(Long[] ids) + { + return emisSpecialZoneAddressMatchMapper.deleteEmisSpecialZoneAddressMatchByIds(ids); + } + + /** + * 删除特区地址匹配管理信息 + * + * @param id 特区地址匹配管理主键 + * @return 结果 + */ + @Override + public int deleteEmisSpecialZoneAddressMatchById(Long id) + { + return emisSpecialZoneAddressMatchMapper.deleteEmisSpecialZoneAddressMatchById(id); + } + + /** + * 验证必填项 + */ + private void validateRequiredFields(EmisSpecialZoneAddressMatch data) throws EmisBizError + { + if (StringUtils.isBlank(data.getCountryCode())) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家代码不能为空"); + } + if (StringUtils.isBlank(data.getProvinceCode())) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "省份代码不能为空"); + } + if (StringUtils.isBlank(data.getSpecialZoneName())) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区名称不能为空"); + } + if (StringUtils.isBlank(data.getSpecialZoneTag())) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区标签不能为空"); + } + } + + /** + * 转换国家名称到代码 + */ + private void convertCountryNameToCode(EmisSpecialZoneAddressMatch data) throws EmisBizError + { + if (StringUtils.isNotBlank(data.getCountryCode())) + { + // 如果已有代码,验证代码是否存在 + EmisCountry country = emisBaseService.getCountryByCode(data.getCountryCode()); + if (country == null) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家代码不存在:" + data.getCountryCode()); + } + } + else if (StringUtils.isNotBlank(data.getCountryName())) + { + // 根据名称查找国家 + EmisCountry country = emisBaseService.getCountryByName(data.getCountryName()); + if (country != null) + { + data.setCountryCode(country.getCode()); + } + else + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家不存在:" + data.getCountryName()); + } + } + } + + /** + * 转换省份名称到代码 + */ + private void convertProvinceNameToCode(EmisSpecialZoneAddressMatch data) throws EmisBizError + { + if (StringUtils.isNotBlank(data.getProvinceCode())) + { + // 如果已有代码,验证代码是否存在 + EmisRegion region = new EmisRegion(); + region.setRegionCode(data.getProvinceCode()); + region.setRegionType(1); // 1-省 + List regionList = emisRegionMapper.selectEmisRegionList(region); + if (regionList == null || regionList.size() == 0) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "省份代码不存在:" + data.getProvinceCode()); + } + } + else if (StringUtils.isNotBlank(data.getProvinceName())) + { + // 根据名称查找省份 + EmisRegion region = new EmisRegion(); + region.setRegionName(data.getProvinceName()); + region.setRegionType(1); // 1-省 + if (StringUtils.isNotBlank(data.getCountryCode())) + { + region.setCountryCode(data.getCountryCode()); + } + List regionList = emisRegionMapper.selectEmisRegionList(region); + if (regionList != null && regionList.size() > 0) + { + data.setProvinceCode(regionList.get(0).getRegionCode()); + } + else + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "省份不存在:" + data.getProvinceName()); + } + } + } + + /** + * 草稿提交特区地址匹配管理(前端传countryName、provinceName,转换为code后保存) + * + * @param emisSpecialZoneAddressMatch 特区地址匹配管理 + * @return 结果 + */ + @Override + public int draftSubmitSpecialZone(EmisSpecialZoneAddressMatch emisSpecialZoneAddressMatch) throws EmisBizError + { + // 验证必填项 + if (StringUtils.isBlank(emisSpecialZoneAddressMatch.getSpecialZoneName())) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区名称不能为空"); + } + if (StringUtils.isBlank(emisSpecialZoneAddressMatch.getSpecialZoneTag())) + { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区标签不能为空"); + } + + // 转换国家名称到代码 + convertCountryNameToCode(emisSpecialZoneAddressMatch); + + // 转换省份名称到代码 + convertProvinceNameToCode(emisSpecialZoneAddressMatch); + + // 检查specialZoneTag是否唯一 + if (checkUnique(emisSpecialZoneAddressMatch) > 0) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "特区标签已存在,不能重复"); + } + + return emisSpecialZoneAddressMatchMapper.insertEmisSpecialZoneAddressMatch(emisSpecialZoneAddressMatch); + } + + @Override + public EmisSpecialZoneAddressMatch matchByAddress(String address) + { + if (StringUtils.isBlank(address)) + { + return null; + } + + // 去掉所有空白字符并统一转大写 + String normalizedAddress = address.replaceAll("\\s+", "").toUpperCase(); + if (StringUtils.isBlank(normalizedAddress)) + { + return null; + } + + return emisSpecialZoneAddressMatchMapper.selectByNormalizedAddress(normalizedAddress); + } +} diff --git a/emis-biz/src/main/resources/mapper/EmisSpecialZoneAddressMatchMapper.xml b/emis-biz/src/main/resources/mapper/EmisSpecialZoneAddressMatchMapper.xml new file mode 100644 index 000000000..ecc763209 --- /dev/null +++ b/emis-biz/src/main/resources/mapper/EmisSpecialZoneAddressMatchMapper.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + select id, country_code, province_code, special_zone_name, special_zone_tag, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_special_zone_address_match + + + + + + + + + + + + insert into emis_special_zone_address_match + + id, + country_code, + province_code, + special_zone_name, + special_zone_tag, + remark, + del_flag, + create_by, + create_time, + update_by, + update_time, + create_site, + update_site, + + + #{id}, + #{countryCode}, + #{provinceCode}, + #{specialZoneName}, + #{specialZoneTag}, + #{remark}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{createSite}, + #{updateSite}, + + + + + update emis_special_zone_address_match + + country_code = #{countryCode}, + province_code = #{provinceCode}, + special_zone_name = #{specialZoneName}, + special_zone_tag = #{specialZoneTag}, + remark = #{remark}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + create_site = #{createSite}, + update_site = #{updateSite}, + + where id = #{id} + + + + update emis_special_zone_address_match set del_flag='1' where id = #{id} + + + + update emis_special_zone_address_match set del_flag='1' where id in + + #{id} + + +