Merge pull request 'yanyang' (#34) from yanyang into master
Reviewed-on: #34
This commit is contained in:
commit
374d6aba5a
@ -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<PageData<ProductLevelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<ProductLevelDTO> 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<ProductLevelDTO> 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<Long> 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<Long> 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<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<ProductLevelDTO> list = productLevelService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, list, ProductLevelExcel.class);
|
||||
}
|
||||
|
||||
@PostMapping(value = "list")
|
||||
@ApiOperation(value = "获取产品等级列表")
|
||||
public List<ProductLevelDTO> list(){
|
||||
return productLevelService.list();
|
||||
}
|
||||
}
|
@ -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<PageData<ScenesDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<ScenesDTO> 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<ScenesDTO> 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<Long> 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<Long> 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<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<ScenesDTO> list = scenesService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, list, ScenesExcel.class);
|
||||
}
|
||||
|
||||
@PostMapping(value = "list")
|
||||
@ApiOperation(value = "获取场景列表")
|
||||
public List<ScenesDTO> list(){
|
||||
return scenesService.list();
|
||||
}
|
||||
|
||||
}
|
@ -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<PageData<WorkingTimeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<WorkingTimeDTO> page = workingTimeService.page(params);
|
||||
|
||||
@ -58,7 +58,6 @@ public class WorkingTimeController {
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("信息")
|
||||
@PreAuthorize("@ex.hasAuthority('packing:workingTime:info')")
|
||||
public Result<WorkingTimeDTO> 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<Long> 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<Long> 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<String, Object> params, HttpServletResponse response) throws Exception {
|
||||
List<WorkingTimeDTO> list = workingTimeService.list(params);
|
||||
|
||||
ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class);
|
||||
}
|
||||
|
||||
@PostMapping(value = "list")
|
||||
@ApiOperation(value = "获取班次列表")
|
||||
public List<WorkingTimeDTO> list(){
|
||||
return workingTimeService.list();
|
||||
}
|
||||
|
||||
@GetMapping("getOrderName")
|
||||
@ApiOperation("查询时间匹配的班次名称")
|
||||
public Result<String> getOrderName(@RequestBody LocalDateTime time){
|
||||
// @ApiImplicitParam(name = "time", value = "时间", paramType = "query", required = true, dataTypeClass = LocalDateTime.class)
|
||||
public Result<String> getOrderName(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime time){
|
||||
String orderName = workingTimeService.getOrderName(time);
|
||||
|
||||
return new Result<String>().ok(orderName);
|
||||
|
@ -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 = "备注")
|
||||
|
@ -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<WorkingTimeMapper
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(WorkingTimeDTO dto) {
|
||||
//验证时间段不重合
|
||||
timeOverlap(dto);
|
||||
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
|
||||
BaseSupportUtils.setCommonField(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
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(WorkingTimeDTO dto) {
|
||||
@ -94,7 +132,6 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
|
||||
|
||||
@Override
|
||||
public String getOrderName(LocalDateTime time) {
|
||||
|
||||
LocalTime localTime = time.toLocalTime();
|
||||
List<WorkingTimeDTO> resultList = new ArrayList<>();
|
||||
List<WorkingTimeDTO> listAll = mapper.list();
|
||||
|
Ladataan…
Viittaa uudesa ongelmassa
Block a user