Merge pull request 'develop' (#333) from develop into master
Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/333
This commit is contained in:
commit
e271261f01
@ -13,8 +13,11 @@ package com.xdadan.erp.web.emis;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@ -25,15 +28,18 @@ 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.StringUtils;
|
||||
import com.xdadan.erp.common.utils.poi.ExcelUtil;
|
||||
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
import com.xdadan.erp.emis.domain.EmisCountryArea;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.service.IEmisCountryAreaService;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
|
||||
/**
|
||||
* 国家大区表Controller
|
||||
@ -48,6 +54,9 @@ public class EmisCountryAreaController extends EmisBaseController
|
||||
@Autowired
|
||||
private IEmisCountryAreaService emisCountryAreaService;
|
||||
|
||||
@Autowired
|
||||
private EmisBaseService emisBaseService;
|
||||
|
||||
/**
|
||||
* 查询国家大区表列表
|
||||
*/
|
||||
@ -115,4 +124,72 @@ public class EmisCountryAreaController extends EmisBaseController
|
||||
{
|
||||
return toAjax(emisCountryAreaService.deleteEmisCountryAreaByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel草稿方式提交国家大区(名称->code)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('emis:emisCountryArea:draftSubmitCountryArea')")
|
||||
@PostMapping(value = "/draftSubmitCountryArea")
|
||||
public AjaxResult draftSubmitCountryArea(@RequestBody EmisCountryArea emisCountryArea)
|
||||
{
|
||||
JSONObject jObjOut = new JSONObject();
|
||||
String result = "success";
|
||||
String msg = "提交成功";
|
||||
try
|
||||
{
|
||||
if (emisCountryArea == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "参数不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountryArea.getName()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "区域名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountryArea.getNameEn()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "英文名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountryArea.getCountryCode()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家不能为空");
|
||||
}
|
||||
|
||||
// countryCode(查询emis_country):前端传的是国家名称 -> 转code回填到同字段
|
||||
EmisCountry country = emisBaseService.getCountryByName(emisCountryArea.getCountryCode());
|
||||
if (country == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家未找到: " + emisCountryArea.getCountryCode());
|
||||
}
|
||||
emisCountryArea.setCountryCode(country.getCode());
|
||||
emisCountryArea.setCountryName(country.getName());
|
||||
|
||||
emisCountryAreaService.insertEmisCountryArea(emisCountryArea);
|
||||
jObjOut.put("countryAreaDetail", emisCountryArea);
|
||||
}
|
||||
catch (EmisBizError ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
result = "fail";
|
||||
msg = ex.getErrorCode() + ":" + ex.getMessage();
|
||||
}
|
||||
catch (DuplicateKeyException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
result = "fail";
|
||||
msg = "数据重复";
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,10 +16,14 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
import com.xdadan.erp.emis.domain.EmisSite;
|
||||
import com.xdadan.erp.emis.domain.EmisContinent;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
import com.xdadan.erp.emis.service.IEmisContinentService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
@ -34,7 +38,6 @@ 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;
|
||||
@ -56,6 +59,12 @@ public class EmisCountryController extends EmisBaseController
|
||||
@Autowired
|
||||
private IEmisCountryService emisCountryService;
|
||||
|
||||
@Autowired
|
||||
private IEmisContinentService emisContinentService;
|
||||
|
||||
@Autowired
|
||||
private EmisBaseService emisBaseService;
|
||||
|
||||
/**
|
||||
* 查询国家列表
|
||||
*/
|
||||
@ -154,7 +163,104 @@ public class EmisCountryController extends EmisBaseController
|
||||
return toAjax(emisCountryService.deleteEmisCountryByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel草稿方式提交国家(name->code)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('emis:emisCountry:draftSubmitCountry')")
|
||||
@PostMapping(value = "/draftSubmitCountry")
|
||||
public AjaxResult draftSubmitCountry(@RequestBody EmisCountry emisCountry)
|
||||
{
|
||||
JSONObject jObjOut = new JSONObject();
|
||||
String result = "success";
|
||||
String msg = "提交成功";
|
||||
try
|
||||
{
|
||||
if (emisCountry == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "参数不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountry.getName()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountry.getNameEn()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "英文名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountry.getCode()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家代码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisCountry.getContinentId()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "continentId不能为空");
|
||||
}
|
||||
|
||||
// continentId(查询emis_continent):支持多个名称用逗号分隔,统一转换为逗号分隔code
|
||||
String[] continentParts = emisCountry.getContinentId().split(",");
|
||||
List<String> continentCodeList = new ArrayList<>();
|
||||
for (String part : continentParts)
|
||||
{
|
||||
String continentNameOrCode = part == null ? "" : part.trim();
|
||||
if (StringUtils.isEmpty(continentNameOrCode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
EmisContinent continentQuery = new EmisContinent();
|
||||
continentQuery.setName(continentNameOrCode);
|
||||
java.util.List<EmisContinent> continentList = emisContinentService.selectEmisContinentList(continentQuery);
|
||||
if (continentList == null || continentList.isEmpty())
|
||||
{
|
||||
// 兼容:如果本身传的就是code
|
||||
continentQuery = new EmisContinent();
|
||||
continentQuery.setCode(continentNameOrCode);
|
||||
continentList = emisContinentService.selectEmisContinentList(continentQuery);
|
||||
}
|
||||
if (continentList == null || continentList.isEmpty())
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
|
||||
"continent未找到: " + continentNameOrCode);
|
||||
}
|
||||
continentCodeList.add(String.valueOf(continentList.get(0).getId()));
|
||||
}
|
||||
if (continentCodeList.isEmpty())
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "continentId不能为空");
|
||||
}
|
||||
emisCountry.setContinentId(String.join(",", continentCodeList));
|
||||
|
||||
emisCountryService.insertEmisCountry(emisCountry);
|
||||
jObjOut.put("countryDetail", emisCountry);
|
||||
}
|
||||
catch (EmisBizError ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
result = "fail";
|
||||
msg = ex.getErrorCode() + ":" + ex.getMessage();
|
||||
}
|
||||
catch (DuplicateKeyException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
result = "fail";
|
||||
msg = "数据重复";
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
// main 方法保留占位,避免生成无用变量告警
|
||||
public static void main(String[] args) {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
System.out.println(new ArrayList<Integer>().size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,10 +14,15 @@ package com.xdadan.erp.web.emis;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
import com.xdadan.erp.emis.domain.EmisSite;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -29,7 +34,6 @@ 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;
|
||||
@ -37,6 +41,7 @@ import com.xdadan.erp.common.utils.poi.ExcelUtil;
|
||||
|
||||
import com.xdadan.erp.emis.domain.EmisDestination;
|
||||
import com.xdadan.erp.emis.service.IEmisDestinationService;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
|
||||
/**
|
||||
* 目的地Controller
|
||||
@ -51,6 +56,9 @@ public class EmisDestinationController extends EmisBaseController
|
||||
@Autowired
|
||||
private IEmisDestinationService emisDestinationService;
|
||||
|
||||
@Autowired
|
||||
private EmisBaseService emisBaseService;
|
||||
|
||||
/**
|
||||
* 查询目的地列表
|
||||
*/
|
||||
@ -184,4 +192,124 @@ public class EmisDestinationController extends EmisBaseController
|
||||
{
|
||||
return toAjax(emisDestinationService.deleteEmisDestinationByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel/草稿方式提交目的地(名称->code)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('emis:emisDestination:draftSubmitDestination')")
|
||||
@PostMapping(value = "/draftSubmitDestination")
|
||||
public AjaxResult draftSubmitDestination(@RequestBody EmisDestination emisDestination)
|
||||
{
|
||||
JSONObject jObjOut = new JSONObject();
|
||||
String result = "success";
|
||||
String msg = "提交成功";
|
||||
try
|
||||
{
|
||||
if (emisDestination == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "参数不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisDestination.getDestName()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "目的地名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisDestination.getDestCode()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "目的地编码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisDestination.getCountry()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisDestination.getSiteCode()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "网点代码不能为空");
|
||||
}
|
||||
if (emisDestination.getStatus() == null)
|
||||
{
|
||||
// 尝试从 params 里取(兼容前端传“启用/未启用”)
|
||||
Object raw = emisDestination.getParams() != null ? emisDestination.getParams().get("status") : null;
|
||||
if (raw == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
// country(查询emis_country):前端传国家名称 -> 转为国家代码写回country
|
||||
EmisCountry country = emisBaseService.getCountryByName(emisDestination.getCountry());
|
||||
if (country == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
|
||||
"国家未找到: " + emisDestination.getCountry());
|
||||
}
|
||||
emisDestination.setCountry(country.getCode());
|
||||
emisDestination.setCountryName(country.getName());
|
||||
|
||||
// status(启用状态 0-未启用 1-启用)
|
||||
Integer status = emisDestination.getStatus();
|
||||
if (status == null && emisDestination.getParams() != null)
|
||||
{
|
||||
Object raw = emisDestination.getParams().get("status");
|
||||
if (raw != null)
|
||||
{
|
||||
String s = String.valueOf(raw).trim();
|
||||
if ("启用".equals(s) || "1".equals(s))
|
||||
{
|
||||
status = 1;
|
||||
}
|
||||
else if ("未启用".equals(s) || "0".equals(s))
|
||||
{
|
||||
status = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态不正确/不能为空");
|
||||
}
|
||||
if (status != 0 && status != 1)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "启用状态不正确: " + status);
|
||||
}
|
||||
emisDestination.setStatus(status);
|
||||
|
||||
// siteCode(查询emis_site):前端传网点名称 -> 转为网点代码写回siteCode
|
||||
EmisSite site = emisBaseService.getSiteByName(emisDestination.getSiteCode());
|
||||
if (site == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
|
||||
"网点未找到: " + emisDestination.getSiteCode());
|
||||
}
|
||||
emisDestination.setSiteCode(site.getSiteCode());
|
||||
emisDestination.setSiteName(site.getSiteName());
|
||||
|
||||
emisDestinationService.insertEmisDestination(emisDestination);
|
||||
jObjOut.put("destDetail", emisDestination);
|
||||
}
|
||||
catch (EmisBizError ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
result = "fail";
|
||||
msg = ex.getErrorCode() + ":" + ex.getMessage();
|
||||
}
|
||||
catch (DuplicateKeyException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
result = "fail";
|
||||
msg = "数据重复";
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,14 @@ 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.EmisCountryArea;
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -28,7 +33,6 @@ 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;
|
||||
@ -36,7 +40,9 @@ import com.xdadan.erp.common.utils.StringUtils;
|
||||
import com.xdadan.erp.common.utils.poi.ExcelUtil;
|
||||
|
||||
import com.xdadan.erp.emis.domain.EmisRegion;
|
||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||
import com.xdadan.erp.emis.service.IEmisRegionService;
|
||||
import com.xdadan.erp.emis.service.IEmisCountryAreaService;
|
||||
|
||||
/**
|
||||
* 四级省市区镇表Controller
|
||||
@ -51,6 +57,12 @@ public class EmisRegionController extends EmisBaseController
|
||||
@Autowired
|
||||
private IEmisRegionService emisRegionService;
|
||||
|
||||
@Autowired
|
||||
private EmisBaseService emisBaseService;
|
||||
|
||||
@Autowired
|
||||
private IEmisCountryAreaService emisCountryAreaService;
|
||||
|
||||
/**
|
||||
* 查询四级省市区镇表列表
|
||||
*/
|
||||
@ -136,4 +148,100 @@ public class EmisRegionController extends EmisBaseController
|
||||
{
|
||||
return toAjax(emisRegionService.deleteEmisRegionByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿方式提交四级省市区镇表(name->code)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('emis:emisRegion:draftSubmitRegion')")
|
||||
@PostMapping(value = "/draftSubmitRegion")
|
||||
public AjaxResult draftSubmitRegion(@RequestBody EmisRegion emisRegion)
|
||||
{
|
||||
JSONObject jObjOut = new JSONObject();
|
||||
String result = "success";
|
||||
String msg = "提交成功";
|
||||
try
|
||||
{
|
||||
if (emisRegion == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "参数不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisRegion.getRegionCode()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "区域代码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisRegion.getRegionName()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "区域名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(emisRegion.getCountryCode()))
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家代码不能为空");
|
||||
}
|
||||
|
||||
// countryCode(查询emis_country):前端传国家名称 -> 转为国家 code
|
||||
EmisCountry country = emisBaseService.getCountryByName(emisRegion.getCountryCode());
|
||||
if (country == null)
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "国家未找到: " + emisRegion.getCountryCode());
|
||||
}
|
||||
emisRegion.setCountryCode(country.getCode());
|
||||
|
||||
// sendAreaName/areaName(查询emis_country_area):前端传 name -> 转为对应 id(Long)
|
||||
if (StringUtils.isNotBlank(emisRegion.getSendAreaName()))
|
||||
{
|
||||
String sendAreaName = emisRegion.getSendAreaName();
|
||||
EmisCountryArea sendAreaQuery = new EmisCountryArea();
|
||||
sendAreaQuery.setCountryCode(emisRegion.getCountryCode());
|
||||
sendAreaQuery.setName(sendAreaName);
|
||||
List<EmisCountryArea> sendAreaList = emisCountryAreaService.selectEmisCountryAreaList(sendAreaQuery);
|
||||
if (sendAreaList == null || sendAreaList.isEmpty())
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "寄件片区未找到: " + sendAreaName);
|
||||
}
|
||||
emisRegion.setSendAreaId(sendAreaList.get(0).getId());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(emisRegion.getAreaName()))
|
||||
{
|
||||
String areaName = emisRegion.getAreaName();
|
||||
EmisCountryArea areaQuery = new EmisCountryArea();
|
||||
areaQuery.setCountryCode(emisRegion.getCountryCode());
|
||||
areaQuery.setName(areaName);
|
||||
List<EmisCountryArea> areaList = emisCountryAreaService.selectEmisCountryAreaList(areaQuery);
|
||||
if (areaList == null || areaList.isEmpty())
|
||||
{
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "服务片区未找到: " + areaName);
|
||||
}
|
||||
emisRegion.setAreaId(areaList.get(0).getId());
|
||||
}
|
||||
|
||||
emisRegionService.insertEmisRegion(emisRegion);
|
||||
jObjOut.put("regionDetail", emisRegion);
|
||||
}
|
||||
catch (EmisBizError ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
result = "fail";
|
||||
msg = ex.getErrorCode() + ":" + ex.getMessage();
|
||||
}
|
||||
catch (DuplicateKeyException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
result = "fail";
|
||||
msg = "数据重复";
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user