package com.by4cloud.platformx.device.controller;
|
|
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.collection.CollUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.by4cloud.platformx.common.core.util.R;
|
import com.by4cloud.platformx.common.log.annotation.SysLog;
|
import com.by4cloud.platformx.common.security.annotation.Inner;
|
import com.by4cloud.platformx.device.constant.MaxSizeContant;
|
import com.by4cloud.platformx.device.entity.MaxSize;
|
import com.by4cloud.platformx.device.service.JcMaxSizeService;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import org.springdoc.api.annotations.ParameterObject;
|
import org.springframework.http.HttpHeaders;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.Operation;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.validation.constraints.Max;
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 最大号表
|
*
|
* @author kdq
|
* @date 2025-03-25 16:24:34
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/jcMaxSize" )
|
@Tag(description = "jcMaxSize" , name = "最大号表管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class JcMaxSizeController {
|
|
private final JcMaxSizeService jcMaxSizeService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param jcMaxSize 最大号表
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('device_jcMaxSize_view')" )
|
public R getJcMaxSizePage(@ParameterObject Page page, @ParameterObject MaxSize jcMaxSize) {
|
LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery();
|
wrapper.like(StringUtils.isNotBlank(jcMaxSize.getBusinessName()),MaxSize::getBusinessName,jcMaxSize.getBusinessName());
|
wrapper.eq(MaxSize::getType,0);
|
return R.ok(jcMaxSizeService.page(page, wrapper));
|
}
|
|
@GetMapping("/getNum" )
|
public R getNum() {
|
String s = jcMaxSizeService.nextNo(MaxSizeContant.DEVICE_NUM);
|
String s1 = jcMaxSizeService.nextNo(MaxSizeContant.DEVICE_CLASS_NUM);
|
String s2 = jcMaxSizeService.nextNo(MaxSizeContant.CONTRACT_NUM);
|
System.out.println(s);
|
System.out.println(s1);
|
System.out.println(s2);
|
return null;
|
}
|
|
|
/**
|
* 通过id查询最大号表
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('device_jcMaxSize_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(jcMaxSizeService.getById(id));
|
}
|
|
/**
|
* 通过id查询最大号表
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/getByMasterId/{id}" )
|
public R getByMasterId(@PathVariable("id" ) Long id) {
|
MaxSize byId = jcMaxSizeService.getById(id);
|
LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery();
|
wrapper.eq(MaxSize::getSign,byId.getSign());
|
wrapper.ne(MaxSize::getType,0);
|
wrapper.orderByDesc(MaxSize::getDay);
|
return R.ok(jcMaxSizeService.list(wrapper));
|
}
|
|
|
/**
|
* 新增最大号表
|
* @param jcMaxSize 最大号表
|
* @return R
|
*/
|
@Operation(summary = "新增最大号表" , description = "新增最大号表" )
|
@SysLog("新增最大号表" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('device_jcMaxSize_add')" )
|
public R save(@RequestBody MaxSize jcMaxSize) {
|
LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery();
|
wrapper.eq(MaxSize::getSign,jcMaxSize.getSign());
|
wrapper.eq(MaxSize::getType,0);
|
List<MaxSize> list = jcMaxSizeService.list(wrapper);
|
if(list !=null && list.size()>0){
|
return R.failed("主键标识已存在");
|
}
|
return R.ok(jcMaxSizeService.save(jcMaxSize));
|
}
|
|
/**
|
* 修改最大号表
|
* @param jcMaxSize 最大号表
|
* @return R
|
*/
|
@Operation(summary = "修改最大号表" , description = "修改最大号表" )
|
@SysLog("修改最大号表" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('device_jcMaxSize_edit')" )
|
public R updateById(@RequestBody MaxSize jcMaxSize) {
|
LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery();
|
wrapper.eq(MaxSize::getSign,jcMaxSize.getSign());
|
wrapper.ne(MaxSize::getId,jcMaxSize.getId());
|
List<MaxSize> list = jcMaxSizeService.list(wrapper);
|
if(list !=null && list.size()>0){
|
return R.failed("主键标识重复");
|
}
|
return R.ok(jcMaxSizeService.updateById(jcMaxSize));
|
}
|
|
/**
|
* 通过id删除最大号表
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除最大号表" , description = "通过id删除最大号表" )
|
@SysLog("通过id删除最大号表" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('device_jcMaxSize_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(jcMaxSizeService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param jcMaxSize 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('device_jcMaxSize_export')" )
|
public List<MaxSize> export(MaxSize jcMaxSize,Long[] ids) {
|
return jcMaxSizeService.list(Wrappers.lambdaQuery(jcMaxSize).in(ArrayUtil.isNotEmpty(ids), MaxSize::getId, ids));
|
}
|
}
|