From f454a355436ed587574ed80e4b86cd7c16042cf0 Mon Sep 17 00:00:00 2001 From: chenfang Date: Fri, 13 Oct 2023 08:37:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E5=93=81=E5=9F=BA=E6=9C=AC=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20=20=20=E5=AF=BC=E5=85=A5=E4=BB=A3=E7=A0=81=E5=8F=8A?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/wms/enums/ErrorCodeConstants.java | 3 - .../accountcalendar/ErrorCodeConstants.java | 2 +- .../enums/areabasic/ErrorCodeConstants.java | 5 +- .../wms/enums/bom/ErrorCodeConstants.java | 8 + .../businesstype/ErrorCodeConstants.java | 24 ++ .../wms/enums/carrier/ErrorCodeConstants.java | 19 ++ .../enums/itembasic/ErrorCodeConstants.java | 16 +- .../enums/workstation/ErrorCodeConstants.java | 2 +- .../AccountcalendarController.java | 38 ++- .../vo/AccountcalendarImportExcelVo.java | 59 ++++ .../areabasic/AreabasicController.java | 39 ++- .../areabasic/vo/AreabasicImportExcelVo.java | 58 ++++ .../wms/controller/bom/BomController.java | 37 ++- .../controller/bom/vo/BomImportExcelVo.java | 61 +++++ .../businesstype/BusinesstypeController.java | 74 +++-- .../businesstype/vo/BusinesstypeBaseVO.java | 13 +- .../vo/BusinesstypeImportExcelVo.java | 48 ++++ .../controller/carrier/CarrierController.java | 70 +++-- .../carrier/vo/CarrierImportExcelVo.java | 29 ++ .../itembasic/ItembasicController.java | 67 +++-- .../AccountcalendarConvert.java | 7 +- .../convert/areabasic/AreabasicConvert.java | 7 +- .../module/wms/convert/bom/BomConvert.java | 10 +- .../businesstype/BusinesstypeConvert.java | 14 +- .../wms/convert/carrier/CarrierConvert.java | 14 +- .../AccountcalendarMapper.java | 4 + .../dal/mysql/areabasic/AreabasicMapper.java | 4 + .../module/wms/dal/mysql/bom/BomMapper.java | 10 +- .../businesstype/BusinesstypeMapper.java | 10 +- .../wms/dal/mysql/carrier/CarrierMapper.java | 9 +- .../AccountcalendarService.java | 6 +- .../AccountcalendarServiceImpl.java | 80 +++++- .../service/areabasic/AreabasicService.java | 6 +- .../areabasic/AreabasicServiceImpl.java | 115 +++++++- .../module/wms/service/bom/BomService.java | 15 +- .../wms/service/bom/BomServiceImpl.java | 152 +++++++++-- .../businesstype/BusinesstypeService.java | 15 +- .../businesstype/BusinesstypeServiceImpl.java | 167 ++++++++++-- .../wms/service/carrier/CarrierService.java | 15 +- .../service/carrier/CarrierServiceImpl.java | 128 +++++++-- .../service/itembasic/ItembasicService.java | 6 +- .../itembasic/ItembasicServiceImpl.java | 254 +++++++++--------- .../workstation/WorkstationServiceImpl.java | 2 +- 43 files changed, 1365 insertions(+), 357 deletions(-) create mode 100644 win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/businesstype/ErrorCodeConstants.java create mode 100644 win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/carrier/ErrorCodeConstants.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/vo/AccountcalendarImportExcelVo.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/vo/AreabasicImportExcelVo.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/vo/BomImportExcelVo.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeImportExcelVo.java create mode 100644 win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/vo/CarrierImportExcelVo.java diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java index 253a752b..266173c8 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/ErrorCodeConstants.java @@ -21,8 +21,6 @@ public interface ErrorCodeConstants { ErrorCode TRANSACTIONTYPE_NOT_EXISTS = new ErrorCode(1_049_000_000, "事务类型不存在"); - ErrorCode BUSINESSTYPE_NOT_EXISTS = new ErrorCode(1_050_000_000, "业务类型不存在"); - ErrorCode DOCUMENTSETTING_NOT_EXISTS = new ErrorCode(1_051_000_000, "单据设置不存在"); ErrorCode REQUESTSETTING_NOT_EXISTS = new ErrorCode(1_052_000_000, "申请设置不存在"); @@ -33,7 +31,6 @@ public interface ErrorCodeConstants { ErrorCode OWNER_NOT_EXISTS = new ErrorCode(1_055_000_000, "货主不存在"); - ErrorCode CARRIER_NOT_EXISTS = new ErrorCode(1_056_000_000, "承运商不存在"); ErrorCode SHIFT_NOT_EXISTS = new ErrorCode(1_057_000_000, "班次不存在"); diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/accountcalendar/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/accountcalendar/ErrorCodeConstants.java index 166bb2f1..9a8ccad8 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/accountcalendar/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/accountcalendar/ErrorCodeConstants.java @@ -10,5 +10,5 @@ import com.win.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { ErrorCode ACCOUNTCALENDAR_NOT_EXISTS = new ErrorCode(1_043_000_000, "账期日历不存在"); - + ErrorCode AVAIABLE_NOT_EXISTS = new ErrorCode(1_043_000_001, "是否可用不存在"); } diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/areabasic/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/areabasic/ErrorCodeConstants.java index 5e97ab8f..dc16072e 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/areabasic/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/areabasic/ErrorCodeConstants.java @@ -10,5 +10,8 @@ import com.win.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { ErrorCode AREABASIC_NOT_EXISTS = new ErrorCode(1_035_000_000, "库区不存在"); - + ErrorCode CODE_EXISTS = new ErrorCode(1_035_000_001, "code已存在"); + ErrorCode WAREHOUSE_CODE_EXISTS = new ErrorCode(1_035_000_002, "仓库代码不存在"); + ErrorCode IS_FUNCTIONAL_EXISTS = new ErrorCode(1_035_000_003, "是否是功能区不存在"); + ErrorCode AVAIABLE_NOT_EXISTS = new ErrorCode(1_035_000_004, "是否可用不存在"); } diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/bom/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/bom/ErrorCodeConstants.java index 658cf55e..8b3a26d2 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/bom/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/bom/ErrorCodeConstants.java @@ -10,5 +10,13 @@ import com.win.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { ErrorCode BOM_NOT_EXISTS = new ErrorCode(1_022_000_000, "物料清单不存在"); + ErrorCode PRODUCT_ITEMCODE_NOT_EXISTS = new ErrorCode(1_022_000_001, "父物料代码不存在"); + ErrorCode PRODUCT_ITEMCODE_EXISTS = new ErrorCode(1_022_000_002, "父物料代码已存在"); + ErrorCode COMPONENT_UOM_NOT_EXISTS = new ErrorCode(1_022_000_003, "子物料计量单位不存在"); + ErrorCode AVAIABLE_NOT_EXISTS = new ErrorCode(1_022_000_004, "是否可用不存在"); + ErrorCode COMPONENT_ITEM_CODE_NOT_EXISTS = new ErrorCode(1_022_000_005, "子物料代码不存在"); + ErrorCode COMPONENT_QTY_EXISTS = new ErrorCode(1_022_000_006, "子物料数量不存在"); + ErrorCode PROCESS_CODE_NOT_EXISTS = new ErrorCode(1_022_000_007, "工序代码不存在"); + } diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/businesstype/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/businesstype/ErrorCodeConstants.java new file mode 100644 index 00000000..532bf40d --- /dev/null +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/businesstype/ErrorCodeConstants.java @@ -0,0 +1,24 @@ +package com.win.module.wms.enums.businesstype; + +import com.win.framework.common.exception.ErrorCode; + +/** + * System 错误码枚举类 + * + * system 系统,使用 1-002-000-000 段 + */ +public interface ErrorCodeConstants { + + ErrorCode BUSINESSTYPE_NOT_EXISTS = new ErrorCode(1_050_000_000, "业务类型不存在"); + ErrorCode CODE_NOT_EXISTS = new ErrorCode(1_050_000_001, "code不存在"); + ErrorCode CODE_EXISTS = new ErrorCode(1_050_000_002, "code已存在"); + ErrorCode NAME_NOT_EXISTS = new ErrorCode(1_050_000_003, "名称不存在"); + ErrorCode ITEM_TYPES_NOT_EXISTS = new ErrorCode(1_050_000_004, "可用物品类型范围不存在"); + ErrorCode ITEM_STATUSES_ITEM_CODE_NOT_EXISTS = new ErrorCode(1_050_000_005, "可用物品状态范围不存在"); + ErrorCode OUT_TRANSACTION_TYPE_NOT_EXISTS = new ErrorCode(1_050_000_006, "出库事务类型不存在"); + ErrorCode IN_TRANSACTION_TYPE_NOT_EXISTS = new ErrorCode(1_050_000_007, "入库事务类型不存在"); + ErrorCode USE_ON_THE_WAY__NOT_EXISTS = new ErrorCode(1_050_000_007, "是否使用在途库不存在"); + ErrorCode AVAILABLE_NOT_EXISTS = new ErrorCode(1_050_000_007, "是否可用不存在"); + + +} diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/carrier/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/carrier/ErrorCodeConstants.java new file mode 100644 index 00000000..02dbfec5 --- /dev/null +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/carrier/ErrorCodeConstants.java @@ -0,0 +1,19 @@ +package com.win.module.wms.enums.carrier; + +import com.win.framework.common.exception.ErrorCode; + +/** + * System 错误码枚举类 + * + * system 系统,使用 1-002-000-000 段 + */ +public interface ErrorCodeConstants { + + ErrorCode CARRIER_NOT_EXISTS = new ErrorCode(1_056_000_000, "承运商不存在"); + ErrorCode CODE_NOT_EXISTS = new ErrorCode(1_056_000_001, "code不存在"); + ErrorCode CODE_EXISTS = new ErrorCode(1_056_000_002, "code已存在"); + ErrorCode SHORTNAME_NOT_EXISTS = new ErrorCode(1_056_000_003, "名称不存在"); + ErrorCode AVAILABLE_NOT_EXISTS = new ErrorCode(1_056_000_007, "是否可用不存在"); + + +} diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/itembasic/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/itembasic/ErrorCodeConstants.java index f78257dc..197b30db 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/itembasic/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/itembasic/ErrorCodeConstants.java @@ -10,7 +10,19 @@ import com.win.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { ErrorCode ITEMBASIC_NOT_EXISTS = new ErrorCode(1_020_000_000, "物品基本信息不存在"); - ErrorCode ITEMBASIC_NOT_RIGHT = new ErrorCode(1_020_000_001, "物品基本信息不正确"); - ErrorCode CODE_NOT_ONLY = new ErrorCode(1_020_000_002, "code已存在"); + ErrorCode CODE_NOT_EXISTS = new ErrorCode(1_020_000_001, "物品基本信息不正确"); + ErrorCode CODE_EXISTS = new ErrorCode(1_020_000_002, "code已存在"); + ErrorCode STATUS_NOT_EXISTS = new ErrorCode(1_020_000_003, "状态不存在"); + ErrorCode UOM_NOT_EXISTS = new ErrorCode(1_020_000_004, "计量单位不存在"); + ErrorCode IS_STDPACK_NOT_EXISTS = new ErrorCode(1_020_000_005, "是否标包不存在"); + ErrorCode ENABLE_BUY_NOT_EXISTS = new ErrorCode(1_020_000_006, "可采购不存在"); + ErrorCode ENABLE_MAKE_NOT_EXISTS = new ErrorCode(1_020_000_007, "可制造不存在"); + ErrorCode ENABLE_OUTSOURING_NOT_EXISTS = new ErrorCode(1_020_000_008, "可委外加工不存在"); + ErrorCode IS_RECYCLED_NOT_EXISTS = new ErrorCode(1_020_000_009, "回收件不存在"); + ErrorCode IS_PHANTOM_NOT_EXISTS = new ErrorCode(1_020_000_010, "虚零件不存在"); + ErrorCode ABC_CLASS_NOT_EXISTS = new ErrorCode(1_020_000_011, "ABC类不存在"); + ErrorCode TYPE_NOT_EXISTS = new ErrorCode(1_020_000_012, "类型不存在"); + ErrorCode VALIDITY_DAYS_NOT_EXISTS = new ErrorCode(1_020_000_013, "有效天数不存在"); + ErrorCode AVAIABLE_NOT_EXISTS = new ErrorCode(1_020_000_014, "是否可用不存在"); } diff --git a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/workstation/ErrorCodeConstants.java b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/workstation/ErrorCodeConstants.java index 50e0ec45..5437cf01 100644 --- a/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/workstation/ErrorCodeConstants.java +++ b/win-module-wms/win-module-wms-api/src/main/java/com/win/module/wms/enums/workstation/ErrorCodeConstants.java @@ -11,7 +11,7 @@ public interface ErrorCodeConstants { ErrorCode WORKSTATION_NOT_EXISTS = new ErrorCode(1_040_000_000, "工位不存在"); - ErrorCode WORKSTATION_NOT_RIGHT = new ErrorCode(1_040_000_001, "工位信息填写不正确"); + ErrorCode CODE_NOT_EXISTS = new ErrorCode(1_040_000_001, "code不存在"); ErrorCode CODE_EXISTS = new ErrorCode(1_040_000_002, "code已存在"); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/AccountcalendarController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/AccountcalendarController.java index f9d1a076..1e16e148 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/AccountcalendarController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/AccountcalendarController.java @@ -2,25 +2,28 @@ package com.win.module.wms.controller.accountcalendar; import com.win.framework.common.pojo.CommonResult; import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.wms.controller.accountcalendar.vo.*; import com.win.module.wms.convert.accountcalendar.AccountcalendarConvert; import com.win.module.wms.dal.dataobject.accountcalendar.AccountcalendarDO; +import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.service.accountcalendar.AccountcalendarService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; -import java.util.List; +import java.util.*; import static com.win.framework.common.pojo.CommonResult.success; import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -96,4 +99,35 @@ public class AccountcalendarController { ExcelUtils.write(response, "账期日历.xls", "数据", AccountcalendarExcelVO.class, datas); } + @GetMapping("/get-import-template") + @Operation(summary = "获得导入账期日历模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList( +// AccountcalendarImportExcelVo.builder().year("1").month("2").descriiption("描述").beginTime(LocalDateTime.now()).endTime(LocalDateTime.now()) +// .converttotime(LocalDateTime.now()).available("TRUE").activeTime(LocalDateTime.now()).expireTime(LocalDateTime.now()).remark("备注").build() + ); + Map mapDropDown = new HashMap<>(); + String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(6, available); + // 输出 + ExcelUtils.write(response, "账期日历导入模板.xls", "账期日历列表", AccountcalendarImportExcelVo.class, list,mapDropDown); + } + + @PostMapping("/import") + @Operation(summary = "导入账期日历") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('wms:accountcalendar:import')") + public void importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + List list = ExcelUtils.read(file, AccountcalendarImportExcelVo.class); + List errorList = accountcalendarService.importAccountcalendarList(list, mode, updatePart); + ExcelUtils.write(response, "账期日历导入错误数据.xls", "错误列表", AccountcalendarImportExcelVo.class, errorList); + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/vo/AccountcalendarImportExcelVo.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/vo/AccountcalendarImportExcelVo.java new file mode 100644 index 00000000..64118e3d --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/accountcalendar/vo/AccountcalendarImportExcelVo.java @@ -0,0 +1,59 @@ +package com.win.module.wms.controller.accountcalendar.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class AccountcalendarImportExcelVo { + + @ExcelProperty("年") + private String year; + + @ExcelProperty("月") + private String month; + + @ExcelProperty("描述") + private String descriiption; + + @ExcelProperty("开始时间") + @ColumnWidth(value = 16) + private LocalDateTime beginTime; + + @ExcelProperty("结束时间") + @ColumnWidth(value = 16) + private LocalDateTime endTime; + + @ExcelProperty("转换生效时间") + @ColumnWidth(value = 16) + private LocalDateTime converttotime; + + @ExcelProperty(value = "是否可用", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String available; + + @ExcelProperty("生效时间") + @ColumnWidth(value = 16) + private LocalDateTime activeTime; + + @ExcelProperty("失效时间") + @ColumnWidth(value = 16) + private LocalDateTime expireTime; + + @ExcelProperty("备注") + private String remark; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/AreabasicController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/AreabasicController.java index 759e3767..90bb4951 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/AreabasicController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/AreabasicController.java @@ -2,25 +2,28 @@ package com.win.module.wms.controller.areabasic; import com.win.framework.common.pojo.CommonResult; import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.wms.controller.areabasic.vo.*; import com.win.module.wms.convert.areabasic.AreabasicConvert; import com.win.module.wms.dal.dataobject.areabasic.AreabasicDO; +import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.service.areabasic.AreabasicService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; -import java.util.List; +import java.util.*; import static com.win.framework.common.pojo.CommonResult.success; import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -96,4 +99,36 @@ public class AreabasicController { ExcelUtils.write(response, "库区.xls", "数据", AreabasicExcelVO.class, datas); } + @GetMapping("/get-import-template") + @Operation(summary = "获得导入库区模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList(); + Map mapDropDown = new HashMap<>(); + String[] type = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.WAREHOUSE_TYPE); + mapDropDown.put(4, type); + String[] isFunctional = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(5, isFunctional); + String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(6, available); + // 输出 + ExcelUtils.write(response, "库区导入模板.xls", "库区列表", AreabasicImportExcelVo.class, list,mapDropDown); + } + + @PostMapping("/import") + @Operation(summary = "导入库区") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('wms:areabasic:import')") + public void importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + List list = ExcelUtils.read(file, AreabasicImportExcelVo.class); + List errorList = areabasicService.importAreabasicList(list, mode, updatePart); + ExcelUtils.write(response, "库区导入错误数据.xls", "错误列表", AreabasicImportExcelVo.class, errorList); + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/vo/AreabasicImportExcelVo.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/vo/AreabasicImportExcelVo.java new file mode 100644 index 00000000..164480f8 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/areabasic/vo/AreabasicImportExcelVo.java @@ -0,0 +1,58 @@ +package com.win.module.wms.controller.areabasic.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class AreabasicImportExcelVo { + + @ExcelProperty("代码") + private String code; + + @ExcelProperty("名称") + private String name; + + @ExcelProperty("描述") + private String description; + + @ExcelProperty("仓库代码") + private String warehouseCode; + + @ExcelProperty(value = "类型", converter = DictConvert.class) + @DictFormat(DictTypeConstants.WAREHOUSE_TYPE) + private String type; + + @ExcelProperty(value = "是否是功能区", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String isFunctional; + + @ExcelProperty(value = "是否可用", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String available; + + @ExcelProperty("生效时间") + @ColumnWidth(value = 16) + private LocalDateTime activeTime; + + @ExcelProperty("失效时间") + @ColumnWidth(value = 16) + private LocalDateTime expireTime; + + @ExcelProperty("备注") + private String remark; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/BomController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/BomController.java index e691aab5..39187bac 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/BomController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/BomController.java @@ -2,25 +2,28 @@ package com.win.module.wms.controller.bom; import com.win.framework.common.pojo.CommonResult; import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.wms.controller.bom.vo.*; import com.win.module.wms.convert.bom.BomConvert; import com.win.module.wms.dal.dataobject.bom.BomDO; +import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.service.bom.BomService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; -import java.util.List; +import java.util.*; import static com.win.framework.common.pojo.CommonResult.success; import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -96,4 +99,34 @@ public class BomController { ExcelUtils.write(response, "物料清单.xls", "数据", BomExcelVO.class, datas); } + @GetMapping("/get-import-template") + @Operation(summary = "获得导入物料清单模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList(); + Map mapDropDown = new HashMap<>(); + String[] componentUom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); + mapDropDown.put(2, componentUom); + String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(7, available); + // 输出 + ExcelUtils.write(response, "物料清单导入模板.xls", "物料清单列表", BomImportExcelVo.class, list,mapDropDown); + } + + @PostMapping("/import") + @Operation(summary = "导入物料清单") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('wms:areabasic:import')") + public void importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + List list = ExcelUtils.read(file, BomImportExcelVo.class); + List errorList = bomService.importBomList(list, mode, updatePart); + ExcelUtils.write(response, "物料清单导入错误数据.xls", "错误列表", BomImportExcelVo.class, errorList); + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/vo/BomImportExcelVo.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/vo/BomImportExcelVo.java new file mode 100644 index 00000000..a753a392 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/bom/vo/BomImportExcelVo.java @@ -0,0 +1,61 @@ +package com.win.module.wms.controller.bom.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class BomImportExcelVo { + + @ExcelProperty("父物料代码") + private String productItemCode; + + @ExcelProperty("子物料代码") + private String componentItemCode; + + @ExcelProperty(value = "子物料计量单位", converter = DictConvert.class) + @DictFormat(DictTypeConstants.UOM) + private String componentUom; + + @ExcelProperty("子物料数量") + private BigDecimal componentQty; + + @ExcelProperty("工序代码") + private String processCode; + + @ExcelProperty("版本") + private String version; + + @ExcelProperty("层级") + private String layer; + + @ExcelProperty(value = "是否可用", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String available; + + @ExcelProperty("生效时间") + @ColumnWidth(value = 16) + private LocalDateTime activeTime; + + @ExcelProperty("失效时间") + @ColumnWidth(value = 16) + private LocalDateTime expireTime; + + @ExcelProperty("备注") + private String remark; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/BusinesstypeController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/BusinesstypeController.java index a590a7a5..a7581987 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/BusinesstypeController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/BusinesstypeController.java @@ -1,32 +1,32 @@ package com.win.module.wms.controller.businesstype; -import com.win.module.wms.controller.businesstype.vo.*; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import com.win.framework.common.pojo.PageResult; import com.win.framework.common.pojo.CommonResult; -import static com.win.framework.common.pojo.CommonResult.success; - +import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; - import com.win.framework.operatelog.core.annotations.OperateLog; -import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; - import com.win.module.wms.controller.businesstype.vo.*; -import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; import com.win.module.wms.convert.businesstype.BusinesstypeConvert; +import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; +import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.service.businesstype.BusinesstypeService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.*; + +import static com.win.framework.common.pojo.CommonResult.success; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Tag(name = "管理后台 - 业务类型") @RestController @@ -99,4 +99,36 @@ public class BusinesstypeController { ExcelUtils.write(response, "业务类型.xls", "数据", BusinesstypeExcelVO.class, datas); } + @GetMapping("/get-import-template") + @Operation(summary = "获得导入业务类型模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList(); + Map mapDropDown = new HashMap<>(); + String[] itemTypes = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_TYPE); + mapDropDown.put(2, itemTypes); + String[] itemStatuses = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_STATUS); + mapDropDown.put(3, itemStatuses); + String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(7, available); + // 输出 + ExcelUtils.write(response, "业务类型导入模板.xls", "业务类型列表", BusinesstypeImportExcelVo.class, list,mapDropDown); + } + + @PostMapping("/import") + @Operation(summary = "导入业务类型") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('wms:areabasic:import')") + public void importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + List list = ExcelUtils.read(file, BusinesstypeImportExcelVo.class); + List errorList = businesstypeService.importBusinesstypeList(list, mode, updatePart); + ExcelUtils.write(response, "业务类型导入错误数据.xls", "错误列表", BusinesstypeImportExcelVo.class, errorList); + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeBaseVO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeBaseVO.java index 99d35d6e..a73af08f 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeBaseVO.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeBaseVO.java @@ -1,16 +1,12 @@ package com.win.module.wms.controller.businesstype.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import javax.validation.constraints.*; +import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** @@ -23,7 +19,6 @@ public class BusinesstypeBaseVO { @Schema(description = "id", example = "id") private Long id; - @Schema(description = "代码", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "代码不能为空") private String code; diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeImportExcelVo.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeImportExcelVo.java new file mode 100644 index 00000000..c1fff088 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/businesstype/vo/BusinesstypeImportExcelVo.java @@ -0,0 +1,48 @@ +package com.win.module.wms.controller.businesstype.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class BusinesstypeImportExcelVo { + + @ExcelProperty("代码") + private String code; + + @ExcelProperty("名称") + private String name; + + @ExcelProperty(value = "可用物品类型范围", converter = DictConvert.class) + @DictFormat(DictTypeConstants.ITEM_TYPE) + private String itemTypes; + + @ExcelProperty(value = "可用物品状态范围", converter = DictConvert.class) + @DictFormat(DictTypeConstants.ITEM_STATUS) + private String itemStatuses; + + @ExcelProperty(value = "出库事务类型") + private String outTransactionType; + + @ExcelProperty(value = "入库事务类型") + private String inTransactionType; + + @ExcelProperty(value = "是否在途库区", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String onTheWayArea; + + @ExcelProperty(value = "是否可用", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String available; + +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/CarrierController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/CarrierController.java index 2be61af2..df5f9eea 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/CarrierController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/CarrierController.java @@ -1,32 +1,32 @@ package com.win.module.wms.controller.carrier; -import com.win.module.wms.controller.carrier.vo.*; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import com.win.framework.common.pojo.PageResult; import com.win.framework.common.pojo.CommonResult; -import static com.win.framework.common.pojo.CommonResult.success; - +import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; - import com.win.framework.operatelog.core.annotations.OperateLog; -import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; - import com.win.module.wms.controller.carrier.vo.*; -import com.win.module.wms.dal.dataobject.carrier.CarrierDO; import com.win.module.wms.convert.carrier.CarrierConvert; +import com.win.module.wms.dal.dataobject.carrier.CarrierDO; +import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.service.carrier.CarrierService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.*; + +import static com.win.framework.common.pojo.CommonResult.success; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Tag(name = "管理后台 - 承运商") @RestController @@ -99,4 +99,32 @@ public class CarrierController { ExcelUtils.write(response, "承运商.xls", "数据", CarrierExcelVO.class, datas); } + @GetMapping("/get-import-template") + @Operation(summary = "获得导入承运商模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList(); + Map mapDropDown = new HashMap<>(); + String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(2, available); + // 输出 + ExcelUtils.write(response, "承运商导入模板.xls", "承运商列表", CarrierImportExcelVo.class, list,mapDropDown); + } + + @PostMapping("/import") + @Operation(summary = "导入承运商") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('wms:areabasic:import')") + public void importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + List list = ExcelUtils.read(file, CarrierImportExcelVo.class); + List errorList = carrierService.importCarrierList(list, mode, updatePart); + ExcelUtils.write(response, "承运商导入错误数据.xls", "错误列表", CarrierImportExcelVo.class, errorList); + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/vo/CarrierImportExcelVo.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/vo/CarrierImportExcelVo.java new file mode 100644 index 00000000..9b557796 --- /dev/null +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/carrier/vo/CarrierImportExcelVo.java @@ -0,0 +1,29 @@ +package com.win.module.wms.controller.carrier.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; +import com.win.module.wms.enums.DictTypeConstants; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class CarrierImportExcelVo { + + @ExcelProperty("代码") + private String code; + + @ExcelProperty("简称") + private String shortName; + + @ExcelProperty(value = "是否可用", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TRUE_FALSE) + private String available; +} diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itembasic/ItembasicController.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itembasic/ItembasicController.java index be3fddec..ce43f262 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itembasic/ItembasicController.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itembasic/ItembasicController.java @@ -3,10 +3,12 @@ package com.win.module.wms.controller.itembasic; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.win.framework.common.pojo.CommonResult; import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.system.api.user.AdminUserApi; import com.win.module.system.api.user.dto.AdminUserRespDTO; +import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.controller.itembasic.vo.*; import com.win.module.wms.convert.itembasic.ItembasicConvert; import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; @@ -25,15 +27,12 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import java.util.*; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.common.pojo.CommonResult.success; import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.CODE_NOT_ONLY; +import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.CODE_EXISTS; @Tag(name = "管理后台 - 物品基本信息") @RestController @@ -74,7 +73,7 @@ public class ItembasicController { if(!(null == itembasicMapper.selectOne(queryWrapper))){ ItembasicDO itembasicDO = itembasicMapper.selectOne(queryWrapper); if(itembasicDO.getCode().equals(vo.getCode()) && !itembasicDO.getId().equals(vo.getId())){ - throw exception(CODE_NOT_ONLY); + throw exception(CODE_EXISTS); } } } @@ -131,26 +130,62 @@ public class ItembasicController { List list = itembasicService.getItembasicList(exportReqVO); // 导出 Excel List datas = ItembasicConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "物品基本信息.xls", "数据", ItembasicExcelVO.class, datas); + ExcelUtils.write(response, "物品基本信息.xlsx", "数据", ItembasicExcelVO.class, datas); } @GetMapping("/get-import-template") - @Operation(summary = "获得导入用户模板") + @Operation(summary = "获得导入物品基本信息模板") public void importTemplate(HttpServletResponse response) throws IOException { // 手动创建导出 demo List list = Arrays.asList( - ItembasicImportExcelVo.builder().code("code").name("name").desc1("描述1").desc2("描述2").status("ENABLE").uom("EA").altUom("EA") - .isStdPack("TRUE'").enableBuy("TRUE").enableMake("TRUE").enableOutsourcing("TRUE") - .isRecycled("TRUE").isPhantom("TRUE").abcClass("A").type("OTS").category("DEFAULT").itemGroup("DEFAULT") - .color("DEFAULT").configuration("DEFAULT").project("项目").eqLevel("DEFAULT").validityDays(1).available("TRUE") - .activeTime(LocalDateTime.now()).expireTime(LocalDateTime.now()).remark("备注").build() +// ItembasicImportExcelVo.builder().code("code").name("name").desc1("描述1").desc2("描述2").status("ENABLE").uom("EA").altUom("EA") +// .isStdPack("TRUE'").enableBuy("TRUE").enableMake("TRUE").enableOutsourcing("TRUE") +// .isRecycled("TRUE").isPhantom("TRUE").abcClass("A").type("OTS").category("DEFAULT").itemGroup("DEFAULT") +// .color("DEFAULT").configuration("DEFAULT").project("项目").eqLevel("DEFAULT").validityDays(1).available("TRUE") +// .activeTime(LocalDateTime.now()).expireTime(LocalDateTime.now()).remark("备注").build() ); + Map mapDropDown = new HashMap<>(); + String[] status = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_STATUS); + mapDropDown.put(4, status); + String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); + mapDropDown.put(5, uom); + String[] altUom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); + mapDropDown.put(6, altUom); + String[] isStdPack = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(7, isStdPack); + String[] enableBuy = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(8, enableBuy); + String[] enableMake = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(9, enableMake); + String[] enableOutsourcing = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(10, enableOutsourcing); + String[] isRecycled = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(11, isRecycled); + String[] isPhantom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(12, isPhantom); + String[] abcClass = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ABC_CLASS); + mapDropDown.put(13, abcClass); + String[] type = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_TYPE); + mapDropDown.put(14, type); + String[] category = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_CATEGORY); + mapDropDown.put(15, category); + String[] itemGroup = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_GROUP); + mapDropDown.put(16, itemGroup); + String[] color = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_COLOR); + mapDropDown.put(17, color); + String[] configuration = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.ITEM_CONFIGURATION); + mapDropDown.put(18, configuration); + String[] eqLevel = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.EQ_LEVEL); + mapDropDown.put(20, eqLevel); + String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); + mapDropDown.put(22, available); + // 输出 - ExcelUtils.write(response, "用户导入模板.xls", "用户列表", ItembasicImportExcelVo.class, list); + ExcelUtils.write(response, "物品基本信息导入模板.xls", "物品基本信息列表", ItembasicImportExcelVo.class, list,mapDropDown); } @PostMapping("/import") - @Operation(summary = "导入用户") + @Operation(summary = "导入物品基本信息") @Parameters({ @Parameter(name = "file", description = "Excel 文件", required = true), @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), @@ -163,7 +198,7 @@ public class ItembasicController { @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { List list = ExcelUtils.read(file, ItembasicImportExcelVo.class); List errorList = itembasicService.importUserList(list, mode, updatePart); - ExcelUtils.write(response, "用户导入错误数据.xls", "错误列表", ItembasicImportExcelVo.class, errorList); + ExcelUtils.write(response, "物品基本信息导入错误数据.xls", "错误列表", ItembasicImportExcelVo.class, errorList); } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/accountcalendar/AccountcalendarConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/accountcalendar/AccountcalendarConvert.java index d4676415..0fde6b44 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/accountcalendar/AccountcalendarConvert.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/accountcalendar/AccountcalendarConvert.java @@ -1,10 +1,7 @@ package com.win.module.wms.convert.accountcalendar; import com.win.framework.common.pojo.PageResult; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarCreateReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarExcelVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarRespVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarUpdateReqVO; +import com.win.module.wms.controller.accountcalendar.vo.*; import com.win.module.wms.dal.dataobject.accountcalendar.AccountcalendarDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -27,6 +24,8 @@ public interface AccountcalendarConvert { AccountcalendarRespVO convert(AccountcalendarDO bean); + AccountcalendarDO convert(AccountcalendarImportExcelVo bean); + List convertList(List list); PageResult convertPage(PageResult page); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/areabasic/AreabasicConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/areabasic/AreabasicConvert.java index 1496c1e1..5d4c1a38 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/areabasic/AreabasicConvert.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/areabasic/AreabasicConvert.java @@ -1,10 +1,7 @@ package com.win.module.wms.convert.areabasic; import com.win.framework.common.pojo.PageResult; -import com.win.module.wms.controller.areabasic.vo.AreabasicCreateReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicExcelVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicRespVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicUpdateReqVO; +import com.win.module.wms.controller.areabasic.vo.*; import com.win.module.wms.dal.dataobject.areabasic.AreabasicDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -27,6 +24,8 @@ public interface AreabasicConvert { AreabasicRespVO convert(AreabasicDO bean); + AreabasicDO convert(AreabasicImportExcelVo bean); + List convertList(List list); PageResult convertPage(PageResult page); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/bom/BomConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/bom/BomConvert.java index 03b9fe1c..4c1e6c17 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/bom/BomConvert.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/bom/BomConvert.java @@ -1,16 +1,16 @@ package com.win.module.wms.convert.bom; -import java.util.*; - import com.win.framework.common.pojo.PageResult; - +import com.win.module.wms.controller.bom.vo.BomImportExcelVo; import com.win.module.wms.controller.bom.vo.BomCreateReqVO; import com.win.module.wms.controller.bom.vo.BomExcelVO; import com.win.module.wms.controller.bom.vo.BomRespVO; import com.win.module.wms.controller.bom.vo.BomUpdateReqVO; +import com.win.module.wms.dal.dataobject.bom.BomDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; -import com.win.module.wms.dal.dataobject.bom.BomDO; + +import java.util.List; /** * 物料清单 Convert @@ -28,6 +28,8 @@ public interface BomConvert { BomRespVO convert(BomDO bean); + BomDO convert(BomImportExcelVo bean); + List convertList(List list); PageResult convertPage(PageResult page); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/businesstype/BusinesstypeConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/businesstype/BusinesstypeConvert.java index c8e415f6..01a48a05 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/businesstype/BusinesstypeConvert.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/businesstype/BusinesstypeConvert.java @@ -1,16 +1,12 @@ package com.win.module.wms.convert.businesstype; -import java.util.*; - import com.win.framework.common.pojo.PageResult; - -import com.win.module.wms.controller.businesstype.vo.BusinesstypeCreateReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeExcelVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeRespVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeUpdateReqVO; +import com.win.module.wms.controller.businesstype.vo.*; +import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; -import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; + +import java.util.List; /** * 业务类型 Convert @@ -28,6 +24,8 @@ public interface BusinesstypeConvert { BusinesstypeRespVO convert(BusinesstypeDO bean); + BusinesstypeDO convert(BusinesstypeImportExcelVo bean); + List convertList(List list); PageResult convertPage(PageResult page); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/carrier/CarrierConvert.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/carrier/CarrierConvert.java index 82f41d2e..ec3ea1f5 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/carrier/CarrierConvert.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/carrier/CarrierConvert.java @@ -1,16 +1,12 @@ package com.win.module.wms.convert.carrier; -import java.util.*; - import com.win.framework.common.pojo.PageResult; - -import com.win.module.wms.controller.carrier.vo.CarrierCreateReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierExcelVO; -import com.win.module.wms.controller.carrier.vo.CarrierRespVO; -import com.win.module.wms.controller.carrier.vo.CarrierUpdateReqVO; +import com.win.module.wms.controller.carrier.vo.*; +import com.win.module.wms.dal.dataobject.carrier.CarrierDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; -import com.win.module.wms.dal.dataobject.carrier.CarrierDO; + +import java.util.List; /** * 承运商 Convert @@ -28,6 +24,8 @@ public interface CarrierConvert { CarrierRespVO convert(CarrierDO bean); + CarrierDO convert(CarrierImportExcelVo bean); + List convertList(List list); PageResult convertPage(PageResult page); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/accountcalendar/AccountcalendarMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/accountcalendar/AccountcalendarMapper.java index 219bfe78..36b303d1 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/accountcalendar/AccountcalendarMapper.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/accountcalendar/AccountcalendarMapper.java @@ -18,6 +18,10 @@ import java.util.List; @Mapper public interface AccountcalendarMapper extends BaseMapperX { + default AccountcalendarDO selectByYear(String year) { + return selectOne(AccountcalendarDO::getYear, year); + } + default PageResult selectPage(AccountcalendarPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(AccountcalendarDO::getYear, reqVO.getYear()) diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/areabasic/AreabasicMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/areabasic/AreabasicMapper.java index 5ff16971..a41ddc04 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/areabasic/AreabasicMapper.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/areabasic/AreabasicMapper.java @@ -18,6 +18,10 @@ import java.util.List; @Mapper public interface AreabasicMapper extends BaseMapperX { + default AreabasicDO selectByCode(String code) { + return selectOne(AreabasicDO::getCode, code); + } + default PageResult selectPage(AreabasicPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(AreabasicDO::getCode, reqVO.getCode()) diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/bom/BomMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/bom/BomMapper.java index 4ecb0f50..f933c5e9 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/bom/BomMapper.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/bom/BomMapper.java @@ -1,15 +1,15 @@ package com.win.module.wms.dal.mysql.bom; -import java.util.*; - import com.win.framework.common.pojo.PageResult; -import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; import com.win.module.wms.controller.bom.vo.BomExportReqVO; import com.win.module.wms.controller.bom.vo.BomPageReqVO; import com.win.module.wms.dal.dataobject.bom.BomDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 物料清单 Mapper * @@ -18,6 +18,10 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface BomMapper extends BaseMapperX { + default BomDO selectByProductItemCode(String productItemCode){ + return selectOne(BomDO::getExtraProperties, productItemCode); + } + default PageResult selectPage(BomPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(BomDO::getProductItemCode, reqVO.getProductItemCode()) diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/businesstype/BusinesstypeMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/businesstype/BusinesstypeMapper.java index 5d6ef232..fd6c1c32 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/businesstype/BusinesstypeMapper.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/businesstype/BusinesstypeMapper.java @@ -1,15 +1,15 @@ package com.win.module.wms.dal.mysql.businesstype; -import java.util.*; - import com.win.framework.common.pojo.PageResult; -import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; import com.win.module.wms.controller.businesstype.vo.BusinesstypeExportReqVO; import com.win.module.wms.controller.businesstype.vo.BusinesstypePageReqVO; import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 业务类型 Mapper * @@ -18,6 +18,9 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface BusinesstypeMapper extends BaseMapperX { + default BusinesstypeDO selectByCode(String code){ + return selectOne(BusinesstypeDO::getCode, code); + }; default PageResult selectPage(BusinesstypePageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(BusinesstypeDO::getCode, reqVO.getCode()) @@ -72,4 +75,5 @@ public interface BusinesstypeMapper extends BaseMapperX { .orderByDesc(BusinesstypeDO::getId)); } + } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/carrier/CarrierMapper.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/carrier/CarrierMapper.java index 33dc1d2d..17f195a7 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/carrier/CarrierMapper.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/mysql/carrier/CarrierMapper.java @@ -1,15 +1,15 @@ package com.win.module.wms.dal.mysql.carrier; -import java.util.*; - import com.win.framework.common.pojo.PageResult; -import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; import com.win.module.wms.controller.carrier.vo.CarrierExportReqVO; import com.win.module.wms.controller.carrier.vo.CarrierPageReqVO; import com.win.module.wms.dal.dataobject.carrier.CarrierDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 承运商 Mapper * @@ -68,4 +68,7 @@ public interface CarrierMapper extends BaseMapperX { .orderByDesc(CarrierDO::getId)); } + default CarrierDO selectByCode(String code){ + return selectOne(CarrierDO::getCode, code); + }; } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarService.java index 1f88514b..1f4ecd80 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarService.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarService.java @@ -1,10 +1,7 @@ package com.win.module.wms.service.accountcalendar; import com.win.framework.common.pojo.PageResult; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarCreateReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarExportReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarPageReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarUpdateReqVO; +import com.win.module.wms.controller.accountcalendar.vo.*; import com.win.module.wms.dal.dataobject.accountcalendar.AccountcalendarDO; import javax.validation.Valid; @@ -72,4 +69,5 @@ public interface AccountcalendarService { */ List getAccountcalendarList(AccountcalendarExportReqVO exportReqVO); + List importAccountcalendarList(List accountcalendarImportExcelVos, Integer mode, boolean updatePart); } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarServiceImpl.java index 5125e1b8..0ecb01a0 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/accountcalendar/AccountcalendarServiceImpl.java @@ -1,22 +1,28 @@ package com.win.module.wms.service.accountcalendar; +import cn.hutool.core.collection.CollUtil; +import com.google.common.annotations.VisibleForTesting; +import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.PageResult; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarCreateReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarExportReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarPageReqVO; -import com.win.module.wms.controller.accountcalendar.vo.AccountcalendarUpdateReqVO; +import com.win.framework.datapermission.core.util.DataPermissionUtils; +import com.win.module.wms.controller.accountcalendar.vo.*; import com.win.module.wms.convert.accountcalendar.AccountcalendarConvert; import com.win.module.wms.dal.dataobject.accountcalendar.AccountcalendarDO; import com.win.module.wms.dal.mysql.accountcalendar.AccountcalendarMapper; import org.springframework.stereotype.Service; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; import static com.win.module.wms.enums.accountcalendar.ErrorCodeConstants.ACCOUNTCALENDAR_NOT_EXISTS; +import static com.win.module.wms.enums.accountcalendar.ErrorCodeConstants.AVAIABLE_NOT_EXISTS; + /** * 账期日历 Service 实现类 @@ -34,6 +40,7 @@ public class AccountcalendarServiceImpl implements AccountcalendarService { public Long createAccountcalendar(AccountcalendarCreateReqVO createReqVO) { // 插入 AccountcalendarDO accountcalendar = AccountcalendarConvert.INSTANCE.convert(createReqVO); + validateAccountcalendarForCreateOrUpdate(null,createReqVO.getAvailable()); accountcalendarMapper.insert(accountcalendar); // 返回 return accountcalendar.getId(); @@ -42,7 +49,7 @@ public class AccountcalendarServiceImpl implements AccountcalendarService { @Override public void updateAccountcalendar(AccountcalendarUpdateReqVO updateReqVO) { // 校验存在 - validateAccountcalendarExists(updateReqVO.getId()); + validateAccountcalendarForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getAvailable()); // 更新 AccountcalendarDO updateObj = AccountcalendarConvert.INSTANCE.convert(updateReqVO); accountcalendarMapper.updateById(updateObj); @@ -56,12 +63,6 @@ public class AccountcalendarServiceImpl implements AccountcalendarService { accountcalendarMapper.deleteById(id); } - private void validateAccountcalendarExists(Long id) { - if (accountcalendarMapper.selectById(id) == null) { - throw exception(ACCOUNTCALENDAR_NOT_EXISTS); - } - } - @Override public AccountcalendarDO getAccountcalendar(Long id) { return accountcalendarMapper.selectById(id); @@ -82,4 +83,61 @@ public class AccountcalendarServiceImpl implements AccountcalendarService { return accountcalendarMapper.selectList(exportReqVO); } + public List importAccountcalendarList(List importAccountcalendars, Integer mode, boolean updatePart) { + if (CollUtil.isEmpty(importAccountcalendars)) { + throw exception(USER_IMPORT_LIST_IS_EMPTY); + } + List errorList = new ArrayList<>(); + importAccountcalendars.forEach(importAccountcalendar -> { + // 校验,判断是否有不符合的原因 + try { + if(mode == 2){ + validateAccountcalendarForCreateOrUpdate(null,importAccountcalendar.getAvailable()); + } + } catch (ServiceException ex) { + errorList.add(importAccountcalendar); + return; + } + // 判断如果不存在,在进行插入 + AccountcalendarDO existAccountcalendar = new AccountcalendarDO(); + if (existAccountcalendar == null&& mode != 3) { + accountcalendarMapper.insert(AccountcalendarConvert.INSTANCE.convert(importAccountcalendar)); + } + else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新 + AccountcalendarDO accountcalendarDO = AccountcalendarConvert.INSTANCE.convert(importAccountcalendar); + accountcalendarDO.setId(existAccountcalendar.getId()); + accountcalendarMapper.updateById(accountcalendarDO); + } + }); + //错误不为空并非部分更新,手工回滚 + if(!errorList.isEmpty() && !updatePart) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return errorList; + } + + private void validateAccountcalendarForCreateOrUpdate(Long id,String available) { + // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 + DataPermissionUtils.executeIgnore(() -> { + validateAccountcalendarExists(id); + //校验是否可用为空 + validateAvailableExists(available); + }); + } + @VisibleForTesting + private void validateAccountcalendarExists(Long id) { + if (id == null) { + return; + } + AccountcalendarDO accountcalendar = accountcalendarMapper.selectById(id); + if (accountcalendar == null) { + throw exception(ACCOUNTCALENDAR_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateAvailableExists(String available) { + if (available.isEmpty()) { + throw exception(AVAIABLE_NOT_EXISTS); + } + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicService.java index 83ed8b2c..815521f4 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicService.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicService.java @@ -1,10 +1,7 @@ package com.win.module.wms.service.areabasic; import com.win.framework.common.pojo.PageResult; -import com.win.module.wms.controller.areabasic.vo.AreabasicCreateReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicExportReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicPageReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicUpdateReqVO; +import com.win.module.wms.controller.areabasic.vo.*; import com.win.module.wms.dal.dataobject.areabasic.AreabasicDO; import javax.validation.Valid; @@ -72,4 +69,5 @@ public interface AreabasicService { */ List getAreabasicList(AreabasicExportReqVO exportReqVO); + List importAreabasicList(List areabasics, Integer mode, Boolean updatePart); } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicServiceImpl.java index 1865745a..2e05a956 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/areabasic/AreabasicServiceImpl.java @@ -1,22 +1,27 @@ package com.win.module.wms.service.areabasic; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.google.common.annotations.VisibleForTesting; +import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.PageResult; -import com.win.module.wms.controller.areabasic.vo.AreabasicCreateReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicExportReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicPageReqVO; -import com.win.module.wms.controller.areabasic.vo.AreabasicUpdateReqVO; +import com.win.framework.datapermission.core.util.DataPermissionUtils; +import com.win.module.wms.controller.areabasic.vo.*; import com.win.module.wms.convert.areabasic.AreabasicConvert; import com.win.module.wms.dal.dataobject.areabasic.AreabasicDO; import com.win.module.wms.dal.mysql.areabasic.AreabasicMapper; import org.springframework.stereotype.Service; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.win.module.wms.enums.areabasic.ErrorCodeConstants.AREABASIC_NOT_EXISTS; +import static com.win.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; +import static com.win.module.wms.enums.areabasic.ErrorCodeConstants.*; /** * 库区 Service 实现类 @@ -25,13 +30,14 @@ import static com.win.module.wms.enums.areabasic.ErrorCodeConstants.AREABASIC_NO */ @Service @Validated -public class AreabasicServiceImpl implements com.win.module.wms.service.areabasic.AreabasicService { +public class AreabasicServiceImpl implements AreabasicService { @Resource private AreabasicMapper areabasicMapper; @Override public Long createAreabasic(AreabasicCreateReqVO createReqVO) { + validateAreabasicForCreateOrUpdate(null,createReqVO.getCode(),createReqVO.getWarehouseCode(),createReqVO.getIsFunctional(),createReqVO.getAvailable()); // 插入 AreabasicDO areabasic = AreabasicConvert.INSTANCE.convert(createReqVO); areabasicMapper.insert(areabasic); @@ -42,7 +48,7 @@ public class AreabasicServiceImpl implements com.win.module.wms.service.areabasi @Override public void updateAreabasic(AreabasicUpdateReqVO updateReqVO) { // 校验存在 - validateAreabasicExists(updateReqVO.getId()); + validateAreabasicForCreateOrUpdate(null,updateReqVO.getCode(),updateReqVO.getWarehouseCode(),updateReqVO.getIsFunctional(),updateReqVO.getAvailable()); // 更新 AreabasicDO updateObj = AreabasicConvert.INSTANCE.convert(updateReqVO); areabasicMapper.updateById(updateObj); @@ -56,12 +62,6 @@ public class AreabasicServiceImpl implements com.win.module.wms.service.areabasi areabasicMapper.deleteById(id); } - private void validateAreabasicExists(Long id) { - if (areabasicMapper.selectById(id) == null) { - throw exception(AREABASIC_NOT_EXISTS); - } - } - @Override public AreabasicDO getAreabasic(Long id) { return areabasicMapper.selectById(id); @@ -82,4 +82,93 @@ public class AreabasicServiceImpl implements com.win.module.wms.service.areabasi return areabasicMapper.selectList(exportReqVO); } + @Override + public List importAreabasicList(List areabasics, Integer mode, Boolean updatePart) { + if (CollUtil.isEmpty(areabasics)) { + throw exception(USER_IMPORT_LIST_IS_EMPTY); + } + List errorList = new ArrayList<>(); + areabasics.forEach(areabasic -> { + // 校验,判断是否有不符合的原因 + try { + if(mode == 2){ + validateAreabasicForCreateOrUpdate(null,areabasic.getCode(),areabasic.getWarehouseCode(),areabasic.getIsFunctional(),areabasic.getAvailable()); + } + } catch (ServiceException ex) { + errorList.add(areabasic); + return; + } + // 判断如果不存在,在进行插入 + AreabasicDO existAccountcalendar = areabasicMapper.selectByCode(areabasic.getCode()); + if (existAccountcalendar == null&& mode != 3) { + areabasicMapper.insert(AreabasicConvert.INSTANCE.convert(areabasic)); + } + else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新 + AreabasicDO accountcalendarDO = AreabasicConvert.INSTANCE.convert(areabasic); + accountcalendarDO.setId(existAccountcalendar.getId()); + areabasicMapper.updateById(accountcalendarDO); + } + }); + //错误不为空并非部分更新,手工回滚 + if(!errorList.isEmpty() && !updatePart) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return errorList; + } + private void validateAreabasicForCreateOrUpdate(Long id,String code,String warehouseCode,String isFunctional,String available) { + // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 + DataPermissionUtils.executeIgnore(() -> { + validateAreabasicExists(id); + // 校验code唯一 + validateCodeExists(id,code); + }); + } + @VisibleForTesting + private void validateAreabasicExists(Long id) { + if (id == null) { + return; + } + AreabasicDO areabasic = areabasicMapper.selectById(id); + if (areabasic == null) { + throw exception(AREABASIC_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateCodeExists(Long id,String code) { + if (code.isEmpty()) { + throw exception(CODE_EXISTS); + } + if (StrUtil.isBlank(code)) { + return; + } + AreabasicDO areabasic = areabasicMapper.selectByCode(code); + if (areabasic == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的用户 + if (id == null) { + throw exception(CODE_EXISTS); + } + if (!areabasic.getId().equals(id)) { + throw exception(CODE_EXISTS); + } + } + @VisibleForTesting + private void validateWarehouseCodeExists(String warehouseCode) { + if (warehouseCode.isEmpty()) { + throw exception(WAREHOUSE_CODE_EXISTS); + } + } + @VisibleForTesting + private void validateIsFunctionalExists(String isFunctional) { + if (isFunctional.isEmpty()) { + throw exception(IS_FUNCTIONAL_EXISTS); + } + } + @VisibleForTesting + private void validateAvailableExists(String available) { + if (available.isEmpty()) { + throw exception(AVAIABLE_NOT_EXISTS); + } + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomService.java index d6822d67..3536e18e 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomService.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomService.java @@ -1,14 +1,12 @@ package com.win.module.wms.service.bom; -import java.util.*; -import javax.validation.*; - -import com.win.module.wms.controller.bom.vo.BomCreateReqVO; -import com.win.module.wms.controller.bom.vo.BomExportReqVO; -import com.win.module.wms.controller.bom.vo.BomPageReqVO; -import com.win.module.wms.controller.bom.vo.BomUpdateReqVO; -import com.win.module.wms.dal.dataobject.bom.BomDO; import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.bom.vo.*; +import com.win.module.wms.dal.dataobject.bom.BomDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** * 物料清单 Service 接口 @@ -71,4 +69,5 @@ public interface BomService { */ List getBomList(BomExportReqVO exportReqVO); + List importBomList(List boms, Integer mode, Boolean updatePart); } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java index aa8672a5..b02028fa 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java @@ -1,23 +1,28 @@ package com.win.module.wms.service.bom; -import com.win.module.wms.controller.bom.vo.BomCreateReqVO; -import com.win.module.wms.controller.bom.vo.BomExportReqVO; -import com.win.module.wms.controller.bom.vo.BomPageReqVO; -import com.win.module.wms.controller.bom.vo.BomUpdateReqVO; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; - -import com.win.module.wms.dal.dataobject.bom.BomDO; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.google.common.annotations.VisibleForTesting; +import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.PageResult; - +import com.win.framework.datapermission.core.util.DataPermissionUtils; +import com.win.module.wms.controller.bom.vo.*; import com.win.module.wms.convert.bom.BomConvert; +import com.win.module.wms.dal.dataobject.bom.BomDO; import com.win.module.wms.dal.mysql.bom.BomMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.win.module.wms.enums.bom.ErrorCodeConstants.BOM_NOT_EXISTS; +import static com.win.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; +import static com.win.module.wms.enums.bom.ErrorCodeConstants.*; /** * 物料清单 Service 实现类 @@ -33,6 +38,9 @@ public class BomServiceImpl implements BomService { @Override public Long createBom(BomCreateReqVO createReqVO) { + validateBomForCreateOrUpdate(null,createReqVO.getProductItemCode(),createReqVO.getComponentItemCode(),createReqVO.getComponentUom(),createReqVO.getComponentQty(), + createReqVO.getProcessCode(),createReqVO.getAvailable()); + // 插入 BomDO bom = BomConvert.INSTANCE.convert(createReqVO); bomMapper.insert(bom); @@ -43,7 +51,9 @@ public class BomServiceImpl implements BomService { @Override public void updateBom(BomUpdateReqVO updateReqVO) { // 校验存在 - validateBomExists(updateReqVO.getId()); + validateBomForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getProductItemCode(),updateReqVO.getComponentItemCode(),updateReqVO.getComponentUom(), + updateReqVO.getComponentQty(),updateReqVO.getProcessCode(),updateReqVO.getAvailable()); + // 更新 BomDO updateObj = BomConvert.INSTANCE.convert(updateReqVO); bomMapper.updateById(updateObj); @@ -57,12 +67,6 @@ public class BomServiceImpl implements BomService { bomMapper.deleteById(id); } - private void validateBomExists(Long id) { - if (bomMapper.selectById(id) == null) { - throw exception(BOM_NOT_EXISTS); - } - } - @Override public BomDO getBom(Long id) { return bomMapper.selectById(id); @@ -83,4 +87,112 @@ public class BomServiceImpl implements BomService { return bomMapper.selectList(exportReqVO); } + @Override + public List importBomList(List boms, Integer mode, Boolean updatePart) { + if (CollUtil.isEmpty(boms)) { + throw exception(USER_IMPORT_LIST_IS_EMPTY); + } + List errorList = new ArrayList<>(); + boms.forEach(bom -> { + // 校验,判断是否有不符合的原因 + try { + if(mode == 2){ + validateBomForCreateOrUpdate(null,bom.getProductItemCode(),bom.getComponentItemCode(),bom.getComponentUom(),bom.getComponentQty(),bom.getProcessCode(),bom.getAvailable()); + } + } catch (ServiceException ex) { + errorList.add(bom); + return; + } + // 判断如果不存在,在进行插入 + BomDO existAccountcalendar = bomMapper.selectByProductItemCode(bom.getProductItemCode()); + if (existAccountcalendar == null&& mode != 3) { + bomMapper.insert(BomConvert.INSTANCE.convert(bom)); + } + else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新 + BomDO bomDO = BomConvert.INSTANCE.convert(bom); + bomDO.setId(existAccountcalendar.getId()); + bomMapper.updateById(bomDO); + } + }); + //错误不为空并非部分更新,手工回滚 + if(!errorList.isEmpty() && !updatePart) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return errorList; + } + + private void validateBomForCreateOrUpdate(Long id,String productItemCode,String componentItemCode, + String componentUom,BigDecimal componentQty,String processCode,String available) { + // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 + DataPermissionUtils.executeIgnore(() -> { + validateBomExists(id); + // 校验code唯一 + validateProductItemCodeExists(id,productItemCode); + validateComponentUomExists(componentUom); + validateAvailableExists(available); + validateComponentItemCodeExists(componentItemCode); + validateComponentQtyExists(componentQty); + validateProcessCodeExists(processCode); + }); + } + @VisibleForTesting + private void validateBomExists(Long id) { + if (id == null) { + return; + } + BomDO bom = bomMapper.selectById(id); + if (bom == null) { + throw exception(BOM_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateProductItemCodeExists(Long id,String productItemCode) { + if (productItemCode.isEmpty()) { + throw exception(PRODUCT_ITEMCODE_NOT_EXISTS); + } + if (StrUtil.isBlank(productItemCode)) { + return; + } + BomDO bom = bomMapper.selectByProductItemCode(productItemCode); + if (bom == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的用户 + if (id == null) { + throw exception(PRODUCT_ITEMCODE_EXISTS); + } + if (!bom.getId().equals(id)) { + throw exception(PRODUCT_ITEMCODE_EXISTS); + } + } + @VisibleForTesting + private void validateComponentUomExists(String componentUom) { + if (componentUom.isEmpty()) { + throw exception(COMPONENT_UOM_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateAvailableExists(String available) { + if (available.isEmpty()) { + throw exception(AVAIABLE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateComponentItemCodeExists(String componentItemCode) { + if (componentItemCode.isEmpty()) { + throw exception(COMPONENT_ITEM_CODE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateComponentQtyExists(BigDecimal componentQty) { + if (componentQty == null) { + throw exception(COMPONENT_QTY_EXISTS); + } + } + @VisibleForTesting + private void validateProcessCodeExists(String processCode) { + if (processCode.isEmpty()) { + throw exception(PROCESS_CODE_NOT_EXISTS); + } + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeService.java index 30e0efbf..496a662a 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeService.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeService.java @@ -1,14 +1,12 @@ package com.win.module.wms.service.businesstype; -import java.util.*; -import javax.validation.*; - -import com.win.module.wms.controller.businesstype.vo.BusinesstypeCreateReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeExportReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypePageReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeUpdateReqVO; -import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.businesstype.vo.*; +import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** * 业务类型 Service 接口 @@ -71,4 +69,5 @@ public interface BusinesstypeService { */ List getBusinesstypeList(BusinesstypeExportReqVO exportReqVO); + List importBusinesstypeList(List businesstypes, Integer mode, Boolean updatePart); } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeServiceImpl.java index 83f237c4..af61f281 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/businesstype/BusinesstypeServiceImpl.java @@ -1,23 +1,27 @@ package com.win.module.wms.service.businesstype; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeCreateReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeExportReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypePageReqVO; -import com.win.module.wms.controller.businesstype.vo.BusinesstypeUpdateReqVO; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; - -import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.google.common.annotations.VisibleForTesting; +import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.PageResult; - +import com.win.framework.datapermission.core.util.DataPermissionUtils; +import com.win.module.wms.controller.businesstype.vo.*; import com.win.module.wms.convert.businesstype.BusinesstypeConvert; +import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; import com.win.module.wms.dal.mysql.businesstype.BusinesstypeMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.win.module.wms.enums.ErrorCodeConstants.*; +import static com.win.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; +import static com.win.module.wms.enums.businesstype.ErrorCodeConstants.*; /** * 业务类型 Service 实现类 @@ -33,6 +37,9 @@ public class BusinesstypeServiceImpl implements BusinesstypeService { @Override public Long createBusinesstype(BusinesstypeCreateReqVO createReqVO) { + validateBusinesstypeForCreateOrUpdate(null,createReqVO.getCode(),createReqVO.getName() + ,createReqVO.getItemTypes(),createReqVO.getItemStatuses(),createReqVO.getOutTransactionType() + ,createReqVO.getInTransactionType(),createReqVO.getOnTheWayArea(),createReqVO.getAvailable()); // 插入 BusinesstypeDO businesstype = BusinesstypeConvert.INSTANCE.convert(createReqVO); businesstypeMapper.insert(businesstype); @@ -42,6 +49,9 @@ public class BusinesstypeServiceImpl implements BusinesstypeService { @Override public void updateBusinesstype(BusinesstypeUpdateReqVO updateReqVO) { + validateBusinesstypeForCreateOrUpdate(null,updateReqVO.getCode(),updateReqVO.getName() + ,updateReqVO.getItemTypes(),updateReqVO.getItemStatuses(),updateReqVO.getOutTransactionType() + ,updateReqVO.getInTransactionType(),updateReqVO.getOnTheWayArea(),updateReqVO.getAvailable()); // 校验存在 validateBusinesstypeExists(updateReqVO.getId()); // 更新 @@ -57,12 +67,6 @@ public class BusinesstypeServiceImpl implements BusinesstypeService { businesstypeMapper.deleteById(id); } - private void validateBusinesstypeExists(Long id) { - if (businesstypeMapper.selectById(id) == null) { - throw exception(BUSINESSTYPE_NOT_EXISTS); - } - } - @Override public BusinesstypeDO getBusinesstype(Long id) { return businesstypeMapper.selectById(id); @@ -83,4 +87,129 @@ public class BusinesstypeServiceImpl implements BusinesstypeService { return businesstypeMapper.selectList(exportReqVO); } + @Override + public List importBusinesstypeList(List businesstypes, Integer mode, Boolean updatePart) { + if (CollUtil.isEmpty(businesstypes)) { + throw exception(USER_IMPORT_LIST_IS_EMPTY); + } + List errorList = new ArrayList<>(); + businesstypes.forEach(businesstype -> { + // 校验,判断是否有不符合的原因 + try { + if(mode == 2){ + validateBusinesstypeForCreateOrUpdate(null,businesstype.getCode(),businesstype.getName() + ,businesstype.getItemTypes(),businesstype.getItemStatuses(),businesstype.getOutTransactionType() + ,businesstype.getInTransactionType(),businesstype.getOnTheWayArea(),businesstype.getAvailable()); + } + } catch (ServiceException ex) { + errorList.add(businesstype); + return; + } + // 判断如果不存在,在进行插入 + BusinesstypeDO existAccountcalendar = businesstypeMapper.selectByCode(businesstype.getCode()); + if (existAccountcalendar == null&& mode != 3) { + businesstypeMapper.insert(BusinesstypeConvert.INSTANCE.convert(businesstype)); + } + else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新 + BusinesstypeDO businesstypeDO = BusinesstypeConvert.INSTANCE.convert(businesstype); + businesstypeDO.setId(existAccountcalendar.getId()); + businesstypeMapper.updateById(businesstypeDO); + } + }); + //错误不为空并非部分更新,手工回滚 + if(!errorList.isEmpty() && !updatePart) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return errorList; + } + + private void validateBusinesstypeForCreateOrUpdate(Long id, String code, String name, String itemTypes, + String itemStatuses, String outTransactionType, + String inTransactionType,String onTheWayArea,String available) { + // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 + DataPermissionUtils.executeIgnore(() -> { + validateBusinesstypeExists(id); + // 校验code唯一 + validateCodeExists(id,code); + validateNameExists(name); + validateItemTypesExists(itemTypes); + validateItemStatusesExists(itemStatuses); + validateOutTransactionTypeExists(outTransactionType); + validateInTransactionTypeExists(inTransactionType); + validateOnTheWayAreaExists(onTheWayArea); + validateAvailableExists(available); + }); + } + @VisibleForTesting + private void validateBusinesstypeExists(Long id) { + if (id == null) { + return; + } + BusinesstypeDO businesstype = businesstypeMapper.selectById(id); + if (businesstype == null) { + throw exception(BUSINESSTYPE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateCodeExists(Long id,String code) { + if (code.isEmpty()) { + throw exception(CODE_NOT_EXISTS); + } + if (StrUtil.isBlank(code)) { + return; + } + BusinesstypeDO businesstype = businesstypeMapper.selectByCode(code); + if (businesstype == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的用户 + if (id == null) { + throw exception(CODE_EXISTS); + } + if (!businesstype.getId().equals(id)) { + throw exception(CODE_EXISTS); + } + } + @VisibleForTesting + private void validateNameExists(String name) { + if (name.isEmpty()) { + throw exception(NAME_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateItemTypesExists(String itemTypes) { + if (itemTypes.isEmpty()) { + throw exception(ITEM_TYPES_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateItemStatusesExists(String itemStatuses) { + if (itemStatuses.isEmpty()) { + throw exception(ITEM_STATUSES_ITEM_CODE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateOutTransactionTypeExists(String outTransactionType) { + if (outTransactionType.isEmpty()) { + throw exception(OUT_TRANSACTION_TYPE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateInTransactionTypeExists(String inTransactionType) { + if (inTransactionType.isEmpty()) { + throw exception(IN_TRANSACTION_TYPE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateOnTheWayAreaExists(String onTheWayArea) { + if (onTheWayArea.isEmpty()) { + throw exception(USE_ON_THE_WAY__NOT_EXISTS); + } + } + @VisibleForTesting + private void validateAvailableExists(String available) { + if (available.isEmpty()) { + throw exception(AVAILABLE_NOT_EXISTS); + } + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierService.java index 7e508ba9..e2614c32 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierService.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierService.java @@ -1,14 +1,12 @@ package com.win.module.wms.service.carrier; -import java.util.*; -import javax.validation.*; - -import com.win.module.wms.controller.carrier.vo.CarrierCreateReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierExportReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierPageReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierUpdateReqVO; -import com.win.module.wms.dal.dataobject.carrier.CarrierDO; import com.win.framework.common.pojo.PageResult; +import com.win.module.wms.controller.carrier.vo.*; +import com.win.module.wms.dal.dataobject.carrier.CarrierDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** * 承运商 Service 接口 @@ -71,4 +69,5 @@ public interface CarrierService { */ List getCarrierList(CarrierExportReqVO exportReqVO); + List importCarrierList(List carriers, Integer mode, Boolean updatePart); } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierServiceImpl.java index 94d9921f..88583d9d 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/carrier/CarrierServiceImpl.java @@ -1,23 +1,29 @@ package com.win.module.wms.service.carrier; -import com.win.module.wms.controller.carrier.vo.CarrierCreateReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierExportReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierPageReqVO; -import com.win.module.wms.controller.carrier.vo.CarrierUpdateReqVO; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; - -import com.win.module.wms.dal.dataobject.carrier.CarrierDO; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.google.common.annotations.VisibleForTesting; +import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.PageResult; - +import com.win.framework.datapermission.core.util.DataPermissionUtils; +import com.win.module.wms.controller.carrier.vo.*; import com.win.module.wms.convert.carrier.CarrierConvert; +import com.win.module.wms.dal.dataobject.carrier.CarrierDO; import com.win.module.wms.dal.mysql.carrier.CarrierMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.win.module.wms.enums.ErrorCodeConstants.*; +import static com.win.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; +import static com.win.module.wms.enums.businesstype.ErrorCodeConstants.AVAILABLE_NOT_EXISTS; +import static com.win.module.wms.enums.carrier.ErrorCodeConstants.*; + /** * 承运商 Service 实现类 @@ -33,6 +39,7 @@ public class CarrierServiceImpl implements CarrierService { @Override public Long createCarrier(CarrierCreateReqVO createReqVO) { + validateCarrierForCreateOrUpdate(null,createReqVO.getCode(),createReqVO.getShortName(),createReqVO.getAvailable()); // 插入 CarrierDO carrier = CarrierConvert.INSTANCE.convert(createReqVO); carrierMapper.insert(carrier); @@ -43,7 +50,8 @@ public class CarrierServiceImpl implements CarrierService { @Override public void updateCarrier(CarrierUpdateReqVO updateReqVO) { // 校验存在 - validateCarrierExists(updateReqVO.getId()); + validateCarrierForCreateOrUpdate(null,updateReqVO.getCode(),updateReqVO.getShortName(),updateReqVO.getAvailable()); + // 更新 CarrierDO updateObj = CarrierConvert.INSTANCE.convert(updateReqVO); carrierMapper.updateById(updateObj); @@ -57,12 +65,6 @@ public class CarrierServiceImpl implements CarrierService { carrierMapper.deleteById(id); } - private void validateCarrierExists(Long id) { - if (carrierMapper.selectById(id) == null) { - throw exception(CARRIER_NOT_EXISTS); - } - } - @Override public CarrierDO getCarrier(Long id) { return carrierMapper.selectById(id); @@ -83,4 +85,90 @@ public class CarrierServiceImpl implements CarrierService { return carrierMapper.selectList(exportReqVO); } + @Override + public List importCarrierList(List carriers, Integer mode, Boolean updatePart) { + if (CollUtil.isEmpty(carriers)) { + throw exception(USER_IMPORT_LIST_IS_EMPTY); + } + List errorList = new ArrayList<>(); + carriers.forEach(carrier -> { + // 校验,判断是否有不符合的原因 + try { + if(mode == 2){ + validateCarrierForCreateOrUpdate(null,carrier.getCode(),carrier.getShortName(),carrier.getAvailable()); + } + } catch (ServiceException ex) { + errorList.add(carrier); + return; + } + // 判断如果不存在,在进行插入 + CarrierDO existAccountcalendar = carrierMapper.selectByCode(carrier.getCode()); + if (existAccountcalendar == null&& mode != 3) { + carrierMapper.insert(CarrierConvert.INSTANCE.convert(carrier)); + } + else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新 + CarrierDO carrierDo = CarrierConvert.INSTANCE.convert(carrier); + carrierDo.setId(existAccountcalendar.getId()); + carrierMapper.updateById(carrierDo); + } + }); + //错误不为空并非部分更新,手工回滚 + if(!errorList.isEmpty() && !updatePart) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + return errorList; + } + + private void validateCarrierForCreateOrUpdate(Long id, String code, String shortName,String available) { + // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 + DataPermissionUtils.executeIgnore(() -> { + validateCarrierExists(id); + // 校验code唯一 + validateCodeExists(id,code); + validateShortNameExists(shortName); + validateAvailableExists(available); + }); + } + @VisibleForTesting + private void validateCarrierExists(Long id) { + if (id == null) { + return; + } + CarrierDO carrier = carrierMapper.selectById(id); + if (carrier == null) { + throw exception(CARRIER_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateCodeExists(Long id,String code) { + if (code.isEmpty()) { + throw exception(CODE_NOT_EXISTS); + } + if (StrUtil.isBlank(code)) { + return; + } + CarrierDO carrier = carrierMapper.selectByCode(code); + if (carrier == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的用户 + if (id == null) { + throw exception(CODE_EXISTS); + } + if (!carrier.getId().equals(id)) { + throw exception(CODE_EXISTS); + } + } + @VisibleForTesting + private void validateShortNameExists(String shortName) { + if (shortName.isEmpty()) { + throw exception(SHORTNAME_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateAvailableExists(String available) { + if (available.isEmpty()) { + throw exception(AVAILABLE_NOT_EXISTS); + } + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicService.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicService.java index df6bc571..24a29a02 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicService.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicService.java @@ -70,10 +70,10 @@ public interface ItembasicService { List getItembasicList(ItembasicExportReqVO exportReqVO); /** - * 批量导入用户 + * 批量导入物品基本信息 * - * @param importUsers 导入用户列表 - * @param isUpdateSupport 是否支持更新 + * @param importItembasics 导入物品基本信息列表 + * @param updatePart 是否支持更新 * @return 导入结果 */ List importUserList(List importItembasics, Integer mode,boolean updatePart); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java index 14165585..05eb8142 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java @@ -2,6 +2,7 @@ package com.win.module.wms.service.itembasic; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.google.common.annotations.VisibleForTesting; import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.PageResult; import com.win.framework.datapermission.core.util.DataPermissionUtils; @@ -14,12 +15,13 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY; -import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.ITEMBASIC_NOT_EXISTS; -import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.ITEMBASIC_NOT_RIGHT; +import static com.win.module.wms.enums.itembasic.ErrorCodeConstants.*; import static com.win.module.wms.enums.workstation.ErrorCodeConstants.CODE_EXISTS; /** @@ -46,20 +48,9 @@ public class ItembasicServiceImpl implements ItembasicService { @Override public void updateItembasic(ItembasicUpdateReqVO updateReqVO) { // 校验存在 - validateItembasicExists(updateReqVO.getId()); - codeExists(null,updateReqVO.getCode()); - statusExists(updateReqVO.getStatus()); - uomExists(updateReqVO.getUom()); - isStdPackExists(updateReqVO.getIsStdPack()); - enableBuyExists(updateReqVO.getEnableBuy()); - enableMakeExists(updateReqVO.getEnableMake()); - enableOutsouringExists(updateReqVO.getEnableOutsourcing()); - isRecycledExists(updateReqVO.getIsRecycled()); - isPhantomExists(updateReqVO.getIsPhantom()); - abcClassExists(updateReqVO.getAbcClass()); - typeExists(updateReqVO.getType()); - validityDaysExists(updateReqVO.getValidityDays()); - availableExists(updateReqVO.getAvailable()); + validateItembasicForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getCode(),updateReqVO.getStatus(),updateReqVO.getUom(),updateReqVO.getIsStdPack(),updateReqVO.getEnableBuy() + ,updateReqVO.getEnableMake(),updateReqVO.getEnableOutsourcing(),updateReqVO.getIsRecycled(),updateReqVO.getIsPhantom(),updateReqVO.getAbcClass(),updateReqVO.getType() + ,updateReqVO.getValidityDays(),updateReqVO.getAvailable()); // 更新 ItembasicDO updateObj = ItembasicConvert.INSTANCE.convert(updateReqVO); itembasicMapper.updateById(updateObj); @@ -68,107 +59,11 @@ public class ItembasicServiceImpl implements ItembasicService { @Override public void deleteItembasic(Long id) { // 校验存在 - validateItembasicExists(id); - // 删除 - itembasicMapper.deleteById(id); - } - - private void validateItembasicExists(Long id) { - if (itembasicMapper.selectById(id) == null) { + if(itembasicMapper.selectById(999) == null){ throw exception(ITEMBASIC_NOT_EXISTS); } - } - - private void codeExists(Long id,String code) { - if (code.isEmpty()) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - if (StrUtil.isBlank(code)) { - return; - } - ItembasicDO itembasic = itembasicMapper.selectByCode(code); - if (itembasic == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的用户 - if (id == null) { - throw exception(CODE_EXISTS); - } - if (!itembasic.getId().equals(id)) { - throw exception(CODE_EXISTS); - } - } - - private void statusExists(String status) { - if (status.isEmpty()) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void uomExists(String uom) { - if (uom.isEmpty()) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void isStdPackExists(String stdPack) { - if (stdPack == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void enableBuyExists(String enableBuy) { - if (enableBuy == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void enableMakeExists(String enableMark) { - if (enableMark == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void enableOutsouringExists(String enblOutsouring) { - if (enblOutsouring == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void isRecycledExists(String isRecycled) { - if (isRecycled == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void isPhantomExists(String isPhantom) { - if (isPhantom == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void abcClassExists(String abcClass) { - if (abcClass.isEmpty()) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void typeExists(String type) { - if (type.isEmpty()) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void validityDaysExists(Integer validityDays) { - if (validityDays == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } - } - - private void availableExists(String available) { - if (available == null) { - throw exception(ITEMBASIC_NOT_RIGHT); - } + // 删除 + itembasicMapper.deleteById(id); } @Override @@ -200,7 +95,10 @@ public class ItembasicServiceImpl implements ItembasicService { // 校验,判断是否有不符合的原因 try { if(mode == 2){ - validateUserForCreateOrUpdate(null,importItembasic.getCode()); + validateItembasicForCreateOrUpdate(null,importItembasic.getCode(),importItembasic.getStatus(),importItembasic.getUom(),importItembasic.getIsStdPack() + ,importItembasic.getEnableBuy(),importItembasic.getEnableMake(),importItembasic.getEnableOutsourcing() + ,importItembasic.getIsRecycled(),importItembasic.getIsPhantom(),importItembasic.getAbcClass() + ,importItembasic.getType(),importItembasic.getValidityDays(),importItembasic.getAvailable()); } } catch (ServiceException ex) { errorList.add(importItembasic); @@ -224,12 +122,128 @@ public class ItembasicServiceImpl implements ItembasicService { return errorList; } - private void validateUserForCreateOrUpdate(Long id,String code) { + + private void validateItembasicForCreateOrUpdate(Long id,String code,String status,String uom,String isStdPack,String enableBuy,String enableMake, + String enableOutsouring,String isRecycled, String isPhantom,String abcClass,String type,Integer validityDays,String available) { // 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确 DataPermissionUtils.executeIgnore(() -> { + validateItembasicExists(id); // 校验code唯一 - codeExists(id,code); + validateCodeExists(id,code); + validateStatusExists(status); + validateUomExists(uom); + validateIsStdPackExists(isStdPack); + validateEnableBuyExists(enableMake); + validateEnableMakeExists(enableBuy); + validateEnableOutsouringExists(enableOutsouring); + validateIsRecycledExists(isRecycled); + validateIsPhantomExists(isPhantom); + validateAbcClassExists(abcClass); + validateTypeExists(type); + validateValidityDaysExists(validityDays); + validateAvailableExists(available); }); } - + @VisibleForTesting + private void validateItembasicExists(Long id) { + if (id == null) { + return; + } + ItembasicDO itembasic = itembasicMapper.selectById(id); + if (itembasic == null) { + throw exception(ITEMBASIC_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateCodeExists(Long id,String code) { + if (code.isEmpty()) { + throw exception(CODE_NOT_EXISTS); + } + if (StrUtil.isBlank(code)) { + return; + } + ItembasicDO itembasic = itembasicMapper.selectByCode(code); + if (itembasic == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的用户 + if (id == null) { + throw exception(CODE_EXISTS); + } + if (!itembasic.getId().equals(id)) { + throw exception(CODE_EXISTS); + } + } + @VisibleForTesting + private void validateStatusExists(String status) { + if (status.isEmpty()) { + throw exception(STATUS_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateUomExists(String uom) { + if (uom.isEmpty()) { + throw exception(UOM_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateIsStdPackExists(String stdPack) { + if (stdPack == null) { + throw exception(IS_STDPACK_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateEnableBuyExists(String enableBuy) { + if (enableBuy == null) { + throw exception(ENABLE_BUY_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateEnableMakeExists(String enableMark) { + if (enableMark == null) { + throw exception(ENABLE_MAKE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateEnableOutsouringExists(String enblOutsouring) { + if (enblOutsouring == null) { + throw exception(ENABLE_OUTSOURING_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateIsRecycledExists(String isRecycled) { + if (isRecycled == null) { + throw exception(IS_RECYCLED_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateIsPhantomExists(String isPhantom) { + if (isPhantom == null) { + throw exception(IS_PHANTOM_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateAbcClassExists(String abcClass) { + if (abcClass.isEmpty()) { + throw exception(ABC_CLASS_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateTypeExists(String type) { + if (type.isEmpty()) { + throw exception(TYPE_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateValidityDaysExists(Integer validityDays) { + if (validityDays == null) { + throw exception(VALIDITY_DAYS_NOT_EXISTS); + } + } + @VisibleForTesting + private void validateAvailableExists(String available) { + if (available == null) { + throw exception(AVAIABLE_NOT_EXISTS); + } + } } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/workstation/WorkstationServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/workstation/WorkstationServiceImpl.java index 1c6a572a..5e03089f 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/workstation/WorkstationServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/workstation/WorkstationServiceImpl.java @@ -137,7 +137,7 @@ public class WorkstationServiceImpl implements WorkstationService { private void codeExists(Long id, String code) { if (code.isEmpty()) { - throw exception(WORKSTATION_NOT_RIGHT); + throw exception(CODE_EXISTS); } if (StrUtil.isBlank(code)) { return;