Compare commits

..

No commits in common. "374d6aba5ad2e29ab7b4988321bd5fc24dcb77ee" and "83707b5080fdcb19584a5717848c57f00fddfac4" have entirely different histories.

5 changed files with 20 additions and 73 deletions

View File

@ -48,7 +48,7 @@ public class ProductLevelController {
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", 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<PageData<ProductLevelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<ProductLevelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ProductLevelDTO> page = productLevelService.page(params); PageData<ProductLevelDTO> page = productLevelService.page(params);
@ -57,7 +57,7 @@ public class ProductLevelController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:info')") @PreAuthorize("@ex.hasAuthority('basic:productLevel:info')")
public Result<ProductLevelDTO> get(@PathVariable("id") Long id){ public Result<ProductLevelDTO> get(@PathVariable("id") Long id){
ProductLevelDTO data = productLevelService.get(id); ProductLevelDTO data = productLevelService.get(id);
@ -67,7 +67,7 @@ public class ProductLevelController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')") @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')")
public Result<Long> save(@RequestBody ProductLevelDTO dto){ public Result<Long> save(@RequestBody ProductLevelDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
@ -80,7 +80,7 @@ public class ProductLevelController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')") @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')")
public Result<Long> update(@RequestBody ProductLevelDTO dto){ public Result<Long> update(@RequestBody ProductLevelDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
@ -93,7 +93,7 @@ public class ProductLevelController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:delete')") @PreAuthorize("@ex.hasAuthority('basic:productLevel:delete')")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
@ -106,16 +106,11 @@ public class ProductLevelController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:export')") @PreAuthorize("@ex.hasAuthority('basic:productLevel:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ProductLevelDTO> list = productLevelService.list(params); List<ProductLevelDTO> list = productLevelService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ProductLevelExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, ProductLevelExcel.class);
} }
@PostMapping(value = "list")
@ApiOperation(value = "获取产品等级列表")
public List<ProductLevelDTO> list(){
return productLevelService.list();
}
} }

View File

@ -48,7 +48,7 @@ public class ScenesController {
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", 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<PageData<ScenesDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<ScenesDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ScenesDTO> page = scenesService.page(params); PageData<ScenesDTO> page = scenesService.page(params);
@ -57,7 +57,7 @@ public class ScenesController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:info')") @PreAuthorize("@ex.hasAuthority('basic:scenes:info')")
public Result<ScenesDTO> get(@PathVariable("id") Long id){ public Result<ScenesDTO> get(@PathVariable("id") Long id){
ScenesDTO data = scenesService.get(id); ScenesDTO data = scenesService.get(id);
@ -67,7 +67,7 @@ public class ScenesController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:save')") @PreAuthorize("@ex.hasAuthority('basic:scenes:save')")
public Result<Long> save(@RequestBody ScenesDTO dto){ public Result<Long> save(@RequestBody ScenesDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
@ -80,7 +80,7 @@ public class ScenesController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:update')") @PreAuthorize("@ex.hasAuthority('basic:scenes:update')")
public Result<Long> update(@RequestBody ScenesDTO dto){ public Result<Long> update(@RequestBody ScenesDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
@ -93,7 +93,7 @@ public class ScenesController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:delete')") @PreAuthorize("@ex.hasAuthority('basic:scenes:delete')")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
@ -106,17 +106,11 @@ public class ScenesController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:export')") @PreAuthorize("@ex.hasAuthority('basic:scenes:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ScenesDTO> list = scenesService.list(params); List<ScenesDTO> list = scenesService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ScenesExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, ScenesExcel.class);
} }
@PostMapping(value = "list")
@ApiOperation(value = "获取场景列表")
public List<ScenesDTO> list(){
return scenesService.list();
}
} }

View File

@ -18,7 +18,6 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
@ -50,6 +49,7 @@ public class WorkingTimeController {
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", 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<PageData<WorkingTimeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<WorkingTimeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<WorkingTimeDTO> page = workingTimeService.page(params); PageData<WorkingTimeDTO> page = workingTimeService.page(params);
@ -58,6 +58,7 @@ public class WorkingTimeController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
@PreAuthorize("@ex.hasAuthority('packing:workingTime:info')")
public Result<WorkingTimeDTO> get(@PathVariable("id") Long id){ public Result<WorkingTimeDTO> get(@PathVariable("id") Long id){
WorkingTimeDTO data = workingTimeService.get(id); WorkingTimeDTO data = workingTimeService.get(id);
@ -67,6 +68,7 @@ public class WorkingTimeController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
@PreAuthorize("@ex.hasAuthority('packing:workingTime:save')")
public Result<Long> save(@RequestBody WorkingTimeDTO dto){ public Result<Long> save(@RequestBody WorkingTimeDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
@ -79,6 +81,7 @@ public class WorkingTimeController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@PreAuthorize("@ex.hasAuthority('packing:workingTime:update')")
public Result<Long> update(@RequestBody WorkingTimeDTO dto){ public Result<Long> update(@RequestBody WorkingTimeDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
@ -91,6 +94,7 @@ public class WorkingTimeController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
@PreAuthorize("@ex.hasAuthority('packing:workingTime:delete')")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
@ -103,22 +107,16 @@ public class WorkingTimeController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
@PreAuthorize("@ex.hasAuthority('packing:workingTime:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<WorkingTimeDTO> list = workingTimeService.list(params); List<WorkingTimeDTO> list = workingTimeService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class);
} }
@PostMapping(value = "list")
@ApiOperation(value = "获取班次列表")
public List<WorkingTimeDTO> list(){
return workingTimeService.list();
}
@GetMapping("getOrderName") @GetMapping("getOrderName")
@ApiOperation("查询时间匹配的班次名称") @ApiOperation("查询时间匹配的班次名称")
// @ApiImplicitParam(name = "time", value = "时间", paramType = "query", required = true, dataTypeClass = LocalDateTime.class) public Result<String> getOrderName(@RequestBody LocalDateTime time){
public Result<String> getOrderName(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime time){
String orderName = workingTimeService.getOrderName(time); String orderName = workingTimeService.getOrderName(time);
return new Result<String>().ok(orderName); return new Result<String>().ok(orderName);

View File

@ -1,6 +1,5 @@
package com.cnbm.packing.dto; package com.cnbm.packing.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -29,11 +28,9 @@ public class WorkingTimeDTO implements Serializable {
private String orderName; private String orderName;
@ApiModelProperty(value = "班次开始时间, 0点 - 24点") @ApiModelProperty(value = "班次开始时间, 0点 - 24点")
@JsonFormat(pattern = "HH:mm:ss")
private LocalDateTime beginTime; private LocalDateTime beginTime;
@ApiModelProperty(value = "班次结束时间, 0点 - 24点") @ApiModelProperty(value = "班次结束时间, 0点 - 24点")
@JsonFormat(pattern = "HH:mm:ss")
private LocalDateTime endTime; private LocalDateTime endTime;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")

View File

@ -3,7 +3,6 @@ package com.cnbm.packing.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cnbm.admin.utils.BaseSupportUtils; import com.cnbm.admin.utils.BaseSupportUtils;
import com.cnbm.common.exception.RenException;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.service.impl.CrudServiceImpl;
@ -66,48 +65,11 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(WorkingTimeDTO dto) { public void save(WorkingTimeDTO dto) {
//验证时间段不重合
timeOverlap(dto);
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class); WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
BaseSupportUtils.setCommonField(entity); BaseSupportUtils.setCommonField(entity);
insert(entity); insert(entity);
} }
public void timeOverlap(WorkingTimeDTO newTime){
List<WorkingTimeDTO> 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(WorkingTimeDTO dto) { public void update(WorkingTimeDTO dto) {
@ -132,6 +94,7 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
@Override @Override
public String getOrderName(LocalDateTime time) { public String getOrderName(LocalDateTime time) {
LocalTime localTime = time.toLocalTime(); LocalTime localTime = time.toLocalTime();
List<WorkingTimeDTO> resultList = new ArrayList<>(); List<WorkingTimeDTO> resultList = new ArrayList<>();
List<WorkingTimeDTO> listAll = mapper.list(); List<WorkingTimeDTO> listAll = mapper.list();