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 d868750..b0d2dcd 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 @@ -48,7 +48,7 @@ public class ProductLevelController { @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) }) - @PreAuthorize("@ex.hasAuthority('basic:productLevel:page')") +// @PreAuthorize("@ex.hasAuthority('basic:productLevel:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = productLevelService.page(params); @@ -57,7 +57,7 @@ public class ProductLevelController { @GetMapping("{id}") @ApiOperation("信息") - @PreAuthorize("@ex.hasAuthority('basic:productLevel:info')") +// @PreAuthorize("@ex.hasAuthority('basic:productLevel:info')") public Result get(@PathVariable("id") Long id){ ProductLevelDTO data = productLevelService.get(id); @@ -67,7 +67,7 @@ public class ProductLevelController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')") +// @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')") public Result save(@RequestBody ProductLevelDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -80,7 +80,7 @@ public class ProductLevelController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')") +// @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')") public Result update(@RequestBody ProductLevelDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -93,7 +93,7 @@ public class ProductLevelController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @PreAuthorize("@ex.hasAuthority('basic:productLevel:delete')") +// @PreAuthorize("@ex.hasAuthority('basic:productLevel:delete')") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -106,11 +106,16 @@ public class ProductLevelController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @PreAuthorize("@ex.hasAuthority('basic:productLevel:export')") +// @PreAuthorize("@ex.hasAuthority('basic:productLevel:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = productLevelService.list(params); ExcelUtils.exportExcelToTarget(response, null, list, ProductLevelExcel.class); } + @PostMapping(value = "list") + @ApiOperation(value = "获取产品等级列表") + public List list(){ + return productLevelService.list(); + } } \ No newline at end of file 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 9885282..2d0fed6 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 @@ -48,7 +48,7 @@ public class ScenesController { @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) }) - @PreAuthorize("@ex.hasAuthority('basic:scenes:page')") +// @PreAuthorize("@ex.hasAuthority('basic:scenes:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = scenesService.page(params); @@ -57,7 +57,7 @@ public class ScenesController { @GetMapping("{id}") @ApiOperation("信息") - @PreAuthorize("@ex.hasAuthority('basic:scenes:info')") +// @PreAuthorize("@ex.hasAuthority('basic:scenes:info')") public Result get(@PathVariable("id") Long id){ ScenesDTO data = scenesService.get(id); @@ -67,7 +67,7 @@ public class ScenesController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @PreAuthorize("@ex.hasAuthority('basic:scenes:save')") +// @PreAuthorize("@ex.hasAuthority('basic:scenes:save')") public Result save(@RequestBody ScenesDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -80,7 +80,7 @@ public class ScenesController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @PreAuthorize("@ex.hasAuthority('basic:scenes:update')") +// @PreAuthorize("@ex.hasAuthority('basic:scenes:update')") public Result update(@RequestBody ScenesDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -93,7 +93,7 @@ public class ScenesController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @PreAuthorize("@ex.hasAuthority('basic:scenes:delete')") +// @PreAuthorize("@ex.hasAuthority('basic:scenes:delete')") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -106,11 +106,17 @@ public class ScenesController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @PreAuthorize("@ex.hasAuthority('basic:scenes:export')") +// @PreAuthorize("@ex.hasAuthority('basic:scenes:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = scenesService.list(params); ExcelUtils.exportExcelToTarget(response, null, list, ScenesExcel.class); } + @PostMapping(value = "list") + @ApiOperation(value = "获取场景列表") + public List list(){ + return scenesService.list(); + } + } \ No newline at end of file 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 3af148d..1f8cff5 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 @@ -18,6 +18,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -49,7 +50,6 @@ public class WorkingTimeController { @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) }) - @PreAuthorize("@ex.hasAuthority('packing:workingTime:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = workingTimeService.page(params); @@ -58,7 +58,6 @@ public class WorkingTimeController { @GetMapping("{id}") @ApiOperation("信息") - @PreAuthorize("@ex.hasAuthority('packing:workingTime:info')") public Result get(@PathVariable("id") Long id){ WorkingTimeDTO data = workingTimeService.get(id); @@ -68,7 +67,6 @@ public class WorkingTimeController { @PostMapping @ApiOperation("保存") @LogOperation("保存") - @PreAuthorize("@ex.hasAuthority('packing:workingTime:save')") public Result save(@RequestBody WorkingTimeDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); @@ -81,7 +79,6 @@ public class WorkingTimeController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - @PreAuthorize("@ex.hasAuthority('packing:workingTime:update')") public Result update(@RequestBody WorkingTimeDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); @@ -94,7 +91,6 @@ public class WorkingTimeController { @DeleteMapping @ApiOperation("删除") @LogOperation("删除") - @PreAuthorize("@ex.hasAuthority('packing:workingTime:delete')") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -107,16 +103,22 @@ public class WorkingTimeController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @PreAuthorize("@ex.hasAuthority('packing:workingTime:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = workingTimeService.list(params); ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class); } + @PostMapping(value = "list") + @ApiOperation(value = "获取班次列表") + public List list(){ + return workingTimeService.list(); + } + @GetMapping("getOrderName") @ApiOperation("查询时间匹配的班次名称") - public Result getOrderName(@RequestBody LocalDateTime time){ +// @ApiImplicitParam(name = "time", value = "时间", paramType = "query", required = true, dataTypeClass = LocalDateTime.class) + public Result getOrderName(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime time){ String orderName = workingTimeService.getOrderName(time); return new Result().ok(orderName); diff --git a/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java b/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java index 23ac5e8..34e6bb8 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java +++ b/ym-packing/src/main/java/com/cnbm/packing/dto/WorkingTimeDTO.java @@ -1,5 +1,6 @@ package com.cnbm.packing.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -28,9 +29,11 @@ public class WorkingTimeDTO implements Serializable { private String orderName; @ApiModelProperty(value = "班次开始时间, 0点 - 24点") + @JsonFormat(pattern = "HH:mm:ss") private LocalDateTime beginTime; @ApiModelProperty(value = "班次结束时间, 0点 - 24点") + @JsonFormat(pattern = "HH:mm:ss") private LocalDateTime endTime; @ApiModelProperty(value = "备注") diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java b/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java index 389c244..d9e035d 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/impl/WorkingTimeServiceBizImpl.java @@ -3,6 +3,7 @@ package com.cnbm.packing.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.cnbm.admin.utils.BaseSupportUtils; +import com.cnbm.common.exception.RenException; import com.cnbm.common.page.PageData; import com.cnbm.common.service.impl.CrudServiceImpl; @@ -65,11 +66,48 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl dtoList = list(); + LocalTime newBeginTime = newTime.getBeginTime().toLocalTime(); + LocalTime newEndTime = newTime.getEndTime().toLocalTime(); + //不跨天 + if(newBeginTime.isBefore(newEndTime)) { + for(WorkingTimeDTO oldTime: dtoList) { + LocalTime beginTime = oldTime.getBeginTime().toLocalTime(); + LocalTime endTime = oldTime.getEndTime().toLocalTime(); + //不重叠算法:A.end< B.start || A.start > B.end + if(! (newEndTime.isBefore(beginTime)|| newBeginTime.isAfter(endTime))){ + throw new RenException("班次时间重合"); + } + } + } + //跨天 + else{ + //是否存在跨天班次 + long count = dtoList.stream().filter(e->e.getBeginTime().toLocalTime().isAfter(e.getEndTime().toLocalTime())).count(); + if(count>0){ + throw new RenException("班次时间重合"); + } + else{ + for(WorkingTimeDTO oldTime: dtoList) { + LocalTime beginTime = oldTime.getBeginTime().toLocalTime(); + LocalTime endTime = oldTime.getEndTime().toLocalTime(); + //不重叠算法:A.end< B.start || A.start > B.end + if(! (newEndTime.isBefore(beginTime)|| newBeginTime.isAfter(endTime))){ + throw new RenException("班次时间重合"); + } + } + } + } + } + @Override @Transactional(rollbackFor = Exception.class) public void update(WorkingTimeDTO dto) { @@ -94,7 +132,6 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl resultList = new ArrayList<>(); List listAll = mapper.list();