From 3c576e6d52d3daa0c870894f2fcac11c1f07e1b4 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Wed, 25 Mar 2026 17:57:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?demand:=20=20=20=20=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=9B=AE=E7=9A=84=E5=9C=B0/=E5=9B=BD?= =?UTF-8?q?=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/web/emis/EmisCountryController.java | 118 ++++++++++++++- .../web/emis/EmisDestinationController.java | 136 +++++++++++++++++- 2 files changed, 244 insertions(+), 10 deletions(-) diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryController.java index 251dcf99c..f386235e4 100644 --- a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryController.java +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryController.java @@ -1,11 +1,11 @@ -/** +/** * @Project: emis * @Title: EmisCountryController.java * @author linfso * @date 2023-11-16 16:18:40 * @Copyright: ShangHai Duta 2022 All rights reserved. - * @version v1.0 + * @version v1.0 * @Description:
国家 控制器
*/ @@ -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; @@ -45,7 +48,7 @@ import com.xdadan.erp.emis.service.IEmisCountryService; /** * 国家Controller - * + * * @author linfso * @date 2023-11-16 16:18:40 */ @@ -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目的地 控制器
*/ @@ -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,10 +41,11 @@ 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 - * + * * @author linfso * @date 2024-01-10 02:53:35 */ @@ -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); + } } From 326a913b4c36ce422b4255d1af4e5373853cd791 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Thu, 26 Mar 2026 15:17:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?demand:=20=20=20=20=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=89=87=E5=8C=BA/=E7=9C=81=E5=B8=82?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/emis/EmisCountryAreaController.java | 85 ++++++++++++- .../erp/web/emis/EmisRegionController.java | 116 +++++++++++++++++- 2 files changed, 193 insertions(+), 8 deletions(-) diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryAreaController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryAreaController.java index 56600a496..6409aec8c 100644 --- a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryAreaController.java +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisCountryAreaController.java @@ -1,11 +1,11 @@ -/** +/** * @Project: emis * @Title: EmisCountryAreaController.java * @author linfso * @date 2023-11-16 16:18:40 * @Copyright: ShangHai Duta 2022 All rights reserved. - * @version v1.0 + * @version v1.0 * @Description:国家大区表 控制器
*/ @@ -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,19 +28,22 @@ 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 - * + * * @author linfso * @date 2023-11-16 16:18:40 */ @@ -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); + } } diff --git a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisRegionController.java b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisRegionController.java index 2a4f7e4ef..0217568cf 100644 --- a/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisRegionController.java +++ b/emis-biz-web/src/main/java/com/xdadan/erp/web/emis/EmisRegionController.java @@ -1,11 +1,11 @@ -/** +/** * @Project: emis * @Title: EmisRegionController.java * @author linfso * @date 2023-11-16 16:18:40 * @Copyright: ShangHai Duta 2022 All rights reserved. - * @version v1.0 + * @version v1.0 * @Description:四级省市区镇表 控制器
*/ @@ -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,11 +40,13 @@ 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 - * + * * @author linfso * @date 2023-11-16 16:18:40 */ @@ -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