From cb7dc557b080256478bbcb364fb5c26080961465 Mon Sep 17 00:00:00 2001 From: yanyang Date: Thu, 28 Dec 2023 15:33:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductLevelController.java | 47 +++++++++++++++--- .../packing/controller/ScenesController.java | 49 ++++++++++++++++--- .../controller/WorkingTimeController.java | 47 +++++++++++++++--- .../service/ProductLevelServiceBiz.java | 6 ++- .../packing/service/ScenesServiceBiz.java | 7 ++- .../service/WorkingTimeServiceBiz.java | 5 ++ .../impl/ProductLevelServiceBizImpl.java | 20 ++++++++ .../service/impl/ScenesServiceBizImpl.java | 18 +++++++ .../impl/WorkingTimeServiceBizImpl.java | 25 +++++++++- .../resources/mapper/ProductLevelMapper.xml | 1 + .../main/resources/mapper/ScenesMapper.xml | 1 + .../resources/mapper/WorkingTimeMapper.xml | 1 + 12 files changed, 200 insertions(+), 27 deletions(-) diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/ProductLevelController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/ProductLevelController.java index 85ce24c..001ec7f 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/controller/ProductLevelController.java +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/ProductLevelController.java @@ -1,5 +1,6 @@ package com.cnbm.packing.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.cnbm.admin.annotation.LogOperation; import com.cnbm.common.constant.Constant; import com.cnbm.common.page.PageData; @@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils; import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.ProductLevelDTO; +import com.cnbm.packing.entity.ProductLevel; import com.cnbm.packing.excel.ProductLevelExcel; +import com.cnbm.packing.mapper.ProductLevelMapper; import com.cnbm.packing.service.ProductLevelServiceBiz; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -39,6 +43,8 @@ import java.util.Map; public class ProductLevelController { @Autowired private ProductLevelServiceBiz productLevelService; + @Autowired + private ProductLevelMapper productLevelMapper; @GetMapping("page") @ApiOperation("分页") @@ -69,26 +75,51 @@ public class ProductLevelController { @ApiOperation("保存") @LogOperation("保存") // @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')") - public Result save(@RequestBody ProductLevelDTO dto){ + public Result save(@RequestBody ProductLevelDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - productLevelService.save(dto); - - return new Result().ok(dto.getId()); + //验证编码是否重名 + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq(ProductLevel.CODE, dto.getCode()); + if(productLevelMapper.selectCount(wrapper1)!= 0){ + return new Result().error(1,"编码重复"); + } + //验证名称是否重名 + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq(ProductLevel.PRODUCT_LEVEL, dto.getProductLevel()); + if(productLevelMapper.selectCount(wrapper2)!= 0){ + return new Result().error(1,"名称重复"); + } + else { + return new Result().ok(productLevelService.add(dto)); + } } @PutMapping @ApiOperation("修改") @LogOperation("修改") // @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')") - public Result update(@RequestBody ProductLevelDTO dto){ + public Result update(@RequestBody ProductLevelDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - productLevelService.update(dto); - - return new Result().ok(dto.getId()); + //验证编码是否重名 + ProductLevelDTO entity = productLevelService.get(dto.getId()); + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq(ProductLevel.CODE, dto.getCode()); + if(entity.getCode()!=dto.getCode() && productLevelMapper.selectCount(wrapper1)!= 0){ + return new Result().error(1,"编码重复"); + } + //验证名称是否重名 + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq(ProductLevel.PRODUCT_LEVEL, dto.getProductLevel()); + if(entity.getProductLevel()!=dto.getProductLevel() && productLevelMapper.selectCount(wrapper2)!= 0){ + return new Result().error(1,"名称重复"); + } + else { + return new Result().ok(productLevelService.edit(dto)); + } } @DeleteMapping diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/ScenesController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/ScenesController.java index b0531e2..8abd27a 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/controller/ScenesController.java +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/ScenesController.java @@ -1,5 +1,6 @@ package com.cnbm.packing.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.cnbm.admin.annotation.LogOperation; import com.cnbm.common.constant.Constant; import com.cnbm.common.page.PageData; @@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils; import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.ScenesDTO; +import com.cnbm.packing.entity.Scenes; import com.cnbm.packing.excel.ScenesExcel; +import com.cnbm.packing.mapper.ScenesMapper; import com.cnbm.packing.service.ScenesServiceBiz; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -39,6 +43,8 @@ import java.util.Map; public class ScenesController { @Autowired private ScenesServiceBiz scenesService; + @Autowired + private ScenesMapper scenesMapper; @GetMapping("page") @ApiOperation("分页") @@ -69,26 +75,53 @@ public class ScenesController { @ApiOperation("保存") @LogOperation("保存") // @PreAuthorize("@ex.hasAuthority('basic:scenes:save')") - public Result save(@RequestBody ScenesDTO dto){ + public Result save(@RequestBody ScenesDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - scenesService.save(dto); - - return new Result().ok(dto.getId()); + //验证编码是否重名 + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq(Scenes.CODE, dto.getCode()); + if(scenesMapper.selectCount(wrapper1)!= 0){ + return new Result().error(1,"编码重复"); + } + //验证名称是否重名 + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq(Scenes.SCENES_NAME, dto.getScenesName()); + System.out.println(scenesMapper.selectCount(wrapper2)); + if(scenesMapper.selectCount(wrapper2)!= 0){ + return new Result().error(1,"名称重复"); + } + else { + return new Result().ok(scenesService.add(dto)); + } } @PutMapping @ApiOperation("修改") @LogOperation("修改") // @PreAuthorize("@ex.hasAuthority('basic:scenes:update')") - public Result update(@RequestBody ScenesDTO dto){ + public Result update(@RequestBody ScenesDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - scenesService.update(dto); - - return new Result().ok(dto.getId()); + //验证编码是否重名 + ScenesDTO entity = scenesService.get(dto.getId()); + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq(Scenes.CODE, dto.getCode()); + if(entity.getCode()!=dto.getCode() && scenesMapper.selectCount(wrapper1)!= 0){ + return new Result().error(1,"编码重复"); + } + //验证名称是否重名 + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq(Scenes.SCENES_NAME, dto.getScenesName()); + System.out.println(scenesMapper.selectCount(wrapper2)); + if(entity.getScenesName()!=dto.getScenesName() && scenesMapper.selectCount(wrapper2)!= 0){ + return new Result().error(1,"名称重复"); + } + else { + return new Result().ok(scenesService.edit(dto)); + } } @DeleteMapping diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java index 77adc6a..5a049ba 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/WorkingTimeController.java @@ -1,5 +1,6 @@ package com.cnbm.packing.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.cnbm.admin.annotation.LogOperation; import com.cnbm.common.constant.Constant; import com.cnbm.common.page.PageData; @@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils; import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.UpdateGroup; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.WorkingTimeDTO; +import com.cnbm.packing.entity.WorkingTime; import com.cnbm.packing.excel.WorkingTimeExcel; +import com.cnbm.packing.mapper.WorkingTimeMapper; import com.cnbm.packing.service.WorkingTimeServiceBiz; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -41,6 +45,8 @@ import java.util.Map; public class WorkingTimeController { @Autowired private WorkingTimeServiceBiz workingTimeService; + @Autowired + private WorkingTimeMapper workingTimeMapper; @GetMapping("page") @ApiOperation("分页") @@ -68,25 +74,50 @@ public class WorkingTimeController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - public Result save(@RequestBody WorkingTimeDTO dto){ + public Result save(@RequestBody WorkingTimeDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - workingTimeService.save(dto); - - return new Result().ok(dto.getId()); + //验证编码是否重名 + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq(WorkingTime.CODE, dto.getCode()); + if(workingTimeMapper.selectCount(wrapper1)!= 0){ + return new Result().error(1,"编码重复"); + } + //验证名称是否重名 + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq(WorkingTime.ORDER_NAME, dto.getOrderName()); + if(workingTimeMapper.selectCount(wrapper2)!= 0){ + return new Result().error(1,"名称重复"); + } + else { + return new Result().ok(workingTimeService.add(dto)); + } } @PutMapping @ApiOperation("修改") @LogOperation("修改") - public Result update(@RequestBody WorkingTimeDTO dto){ + public Result update(@RequestBody WorkingTimeDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - workingTimeService.update(dto); - - return new Result().ok(dto.getId()); + //验证编码是否重名 + WorkingTimeDTO entity = workingTimeService.get(dto.getId()); + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq(WorkingTime.CODE, dto.getCode()); + if(entity.getCode()!=dto.getCode() && workingTimeMapper.selectCount(wrapper1)!= 0){ + return new Result().error(1,"编码重复"); + } + //验证名称是否重名 + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.eq( WorkingTime.ORDER_NAME, dto.getOrderName()); + if(entity.getOrderName()!=dto.getOrderName() && workingTimeMapper.selectCount(wrapper2)!= 0){ + return new Result().error(1,"名称重复"); + } + else { + return new Result().ok(workingTimeService.edit(dto)); + } } @DeleteMapping diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/ProductLevelServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/ProductLevelServiceBiz.java index 85f2934..8ad5e9d 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/ProductLevelServiceBiz.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/ProductLevelServiceBiz.java @@ -2,6 +2,7 @@ package com.cnbm.packing.service; import com.cnbm.common.page.PageData; import com.cnbm.common.service.CrudService; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.ProductLevelDTO; import com.cnbm.packing.entity.ProductLevel; @@ -27,5 +28,8 @@ public interface ProductLevelServiceBiz extends CrudService list(); - + + IdVo add(ProductLevelDTO dto); + + IdVo edit(ProductLevelDTO dto); } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/ScenesServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/ScenesServiceBiz.java index 4fff1e4..dc7db8c 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/ScenesServiceBiz.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/ScenesServiceBiz.java @@ -2,6 +2,7 @@ package com.cnbm.packing.service; import com.cnbm.common.page.PageData; import com.cnbm.common.service.CrudService; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.ScenesDTO; import com.cnbm.packing.entity.Scenes; @@ -22,10 +23,14 @@ public interface ScenesServiceBiz extends CrudService { void save(ScenesDTO dto); + IdVo add(ScenesDTO dto); + void update(ScenesDTO dto); + IdVo edit(ScenesDTO dto); + void delete(Long[] ids); List list(); - + } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java index eac4247..f9f92ce 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/WorkingTimeServiceBiz.java @@ -2,6 +2,7 @@ package com.cnbm.packing.service; import com.cnbm.common.page.PageData; import com.cnbm.common.service.CrudService; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.WorkingTimeDTO; import com.cnbm.packing.dto.WorkingTimeDTO; import com.cnbm.packing.entity.WorkingTime; @@ -31,4 +32,8 @@ public interface WorkingTimeServiceBiz extends CrudService list(); String getOrderName(LocalDateTime time); + + IdVo add(WorkingTimeDTO dto); + + IdVo edit(WorkingTimeDTO dto); } \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/impl/ProductLevelServiceBizImpl.java b/ym-packing/src/main/java/com/cnbm/packing/service/impl/ProductLevelServiceBizImpl.java index 4be3850..9c31606 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/impl/ProductLevelServiceBizImpl.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/impl/ProductLevelServiceBizImpl.java @@ -6,6 +6,7 @@ import com.cnbm.admin.utils.BaseSupportUtils; import com.cnbm.common.page.PageData; import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.utils.ConvertUtils; +import com.cnbm.packing.dto.IdVo; import com.cnbm.packing.dto.ProductLevelDTO; import com.cnbm.packing.entity.ProductLevel; import com.cnbm.packing.mapper.ProductLevelMapper; @@ -64,6 +65,16 @@ public class ProductLevelServiceBizImpl extends CrudServiceImpl dtoList = list(); LocalTime newBeginTime = newTime.getBeginTime().toLocalTime(); @@ -115,6 +127,18 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl select * from t_product_level + where valid = 1 order by id asc diff --git a/ym-packing/src/main/resources/mapper/ScenesMapper.xml b/ym-packing/src/main/resources/mapper/ScenesMapper.xml index 375fa9f..6ade3a7 100644 --- a/ym-packing/src/main/resources/mapper/ScenesMapper.xml +++ b/ym-packing/src/main/resources/mapper/ScenesMapper.xml @@ -17,6 +17,7 @@ diff --git a/ym-packing/src/main/resources/mapper/WorkingTimeMapper.xml b/ym-packing/src/main/resources/mapper/WorkingTimeMapper.xml index d8704e4..d396872 100644 --- a/ym-packing/src/main/resources/mapper/WorkingTimeMapper.xml +++ b/ym-packing/src/main/resources/mapper/WorkingTimeMapper.xml @@ -19,6 +19,7 @@ -- 2.45.2