Merge pull request 'demand: 特区地址管理增删改查接口' (#311) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/311
This commit is contained in:
heyu 2026-01-31 16:22:00 +08:00
commit fa50cc9b5a
6 changed files with 836 additions and 0 deletions

View File

@ -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: <p> 特区地址匹配管理 控制器 </p>
*/
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<EmisSpecialZoneAddressMatch> 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<EmisSpecialZoneAddressMatch> list = emisSpecialZoneAddressMatchService.selectEmisSpecialZoneAddressMatchList(emisSpecialZoneAddressMatch);
ExcelUtil<EmisSpecialZoneAddressMatch> util = new ExcelUtil<EmisSpecialZoneAddressMatch>(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);
}
}

View File

@ -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: <p> 特区地址匹配管理 实体类 </p>
*/
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;
}

View File

@ -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: <p> 特区地址匹配管理 Mapper 接口 </p>
* <span style='color:red'> Warning : This file is generate by ai tools,don't edit!!! </span>
*/
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 <p> 特区地址匹配管理 Mapper 接口 </p>
* @author heyu
* @date 2026-01-28 10:00:00
*/
public interface EmisSpecialZoneAddressMatchMapper extends BaseMapper<EmisSpecialZoneAddressMatch>
{
/**
* 主键查询
* @param id
* @return
*/
public EmisSpecialZoneAddressMatch selectEmisSpecialZoneAddressMatchById(Long id);
/**
* 查询列表
*
* @param emisSpecialZoneAddressMatch
* @return 集合
*/
public List<EmisSpecialZoneAddressMatch> 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);
}

View File

@ -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: <p> 特区地址匹配管理 服务类接口 </p>
*/
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<EmisSpecialZoneAddressMatch> 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);
}

View File

@ -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: <p> 特区地址匹配管理 实体类 </p>
*/
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<EmisSpecialZoneAddressMatch> 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<EmisRegion> 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<EmisRegion> 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);
}
}

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xdadan.erp.emis.mapper.EmisSpecialZoneAddressMatchMapper">
<resultMap type="EmisSpecialZoneAddressMatch" id="EmisSpecialZoneAddressMatchResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="countryCode" column="country_code" />
<result property="provinceCode" column="province_code" />
<result property="specialZoneName" column="special_zone_name" />
<result property="specialZoneTag" column="special_zone_tag" />
<!-- 通过关联查询返回国家名称和省份名称 -->
<association property="countryName" column="country_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectCountryNameByCode" fetchType="lazy"/>
<association property="provinceName" column="province_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectRegionNameByCode" fetchType="lazy"/>
</resultMap>
<sql id="selectEmisSpecialZoneAddressMatchVo">
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
</sql>
<select id="selectEmisSpecialZoneAddressMatchList" parameterType="EmisSpecialZoneAddressMatch" resultMap="EmisSpecialZoneAddressMatchResult">
<include refid="selectEmisSpecialZoneAddressMatchVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="countryCode != null and countryCode != ''"> and country_code = #{countryCode}</if>
<if test="provinceCode != null and provinceCode != ''"> and province_code = #{provinceCode}</if>
<if test="specialZoneName != null and specialZoneName != ''"> and special_zone_name like concat('%', #{specialZoneName}, '%')</if>
<if test="specialZoneTag != null and specialZoneTag != ''"> and special_zone_tag like concat('%', #{specialZoneTag}, '%')</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
<choose>
<when test="params.orderBy != null and params.orderBy != ''">
order by ${params.orderBy}
</when>
<otherwise>
order by create_time desc
</otherwise>
</choose>
</select>
<select id="checkUnique" parameterType="EmisSpecialZoneAddressMatch" resultType="int">
select count(1) from emis_special_zone_address_match
where del_flag='0'
and special_zone_tag = #{specialZoneTag}
<if test="id != null"> and id != #{id}</if>
limit 1
</select>
<select id="selectEmisSpecialZoneAddressMatchById" parameterType="Long" resultMap="EmisSpecialZoneAddressMatchResult">
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 a
where a.id = #{id} and a.del_flag='0'
</select>
<select id="selectByNormalizedAddress" parameterType="String" resultMap="EmisSpecialZoneAddressMatchResult">
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 a
where a.del_flag = '0'
and #{normalizedAddress} like concat('%', upper(replace(a.special_zone_tag, ' ', '')), '%')
limit 1
</select>
<insert id="insertEmisSpecialZoneAddressMatch" parameterType="EmisSpecialZoneAddressMatch" useGeneratedKeys="true" keyProperty="id">
insert into emis_special_zone_address_match
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="countryCode != null and countryCode != ''">country_code,</if>
<if test="provinceCode != null and provinceCode != ''">province_code,</if>
<if test="specialZoneName != null and specialZoneName != ''">special_zone_name,</if>
<if test="specialZoneTag != null and specialZoneTag != ''">special_zone_tag,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="countryCode != null and countryCode != ''">#{countryCode},</if>
<if test="provinceCode != null and provinceCode != ''">#{provinceCode},</if>
<if test="specialZoneName != null and specialZoneName != ''">#{specialZoneName},</if>
<if test="specialZoneTag != null and specialZoneTag != ''">#{specialZoneTag},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisSpecialZoneAddressMatch" parameterType="EmisSpecialZoneAddressMatch">
update emis_special_zone_address_match
<trim prefix="SET" suffixOverrides=",">
<if test="countryCode != null and countryCode != ''">country_code = #{countryCode},</if>
<if test="provinceCode != null and provinceCode != ''">province_code = #{provinceCode},</if>
<if test="specialZoneName != null and specialZoneName != ''">special_zone_name = #{specialZoneName},</if>
<if test="specialZoneTag != null and specialZoneTag != ''">special_zone_tag = #{specialZoneTag},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisSpecialZoneAddressMatchById" parameterType="Long">
update emis_special_zone_address_match set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisSpecialZoneAddressMatchByIds" parameterType="String">
update emis_special_zone_address_match set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>