package com.by4cloud.platformx.device.controller;
|
|
import cn.hutool.core.util.StrUtil;
|
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.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.util.SecurityUtils;
|
import com.by4cloud.platformx.device.constant.MaxSizeContant;
|
import com.by4cloud.platformx.device.entity.DeviceLeasingLedger;
|
import com.by4cloud.platformx.device.service.DeviceLeasingLedgerService;
|
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 java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 设备租赁台账
|
*
|
* @author syt
|
* @date 2025-03-27 09:30:29
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/deviceLeasingLedger" )
|
@Tag(description = "deviceLeasingLedger" , name = "设备租赁台账管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class DeviceLeasingLedgerController {
|
|
private final DeviceLeasingLedgerService deviceLeasingLedgerService;
|
private final JcMaxSizeService maxSizeService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param deviceLeasingLedger 设备租赁台账
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedger_view')" )
|
public R getDeviceLeasingLedgerPage(@ParameterObject Page page, @ParameterObject DeviceLeasingLedger deviceLeasingLedger) {
|
LambdaQueryWrapper<DeviceLeasingLedger> wrapper = Wrappers.lambdaQuery();
|
wrapper.like(StrUtil.isNotBlank(deviceLeasingLedger.getLedgerName()),DeviceLeasingLedger::getLedgerName,deviceLeasingLedger.getLedgerName());
|
wrapper.like(StrUtil.isNotBlank(deviceLeasingLedger.getContractCode()),DeviceLeasingLedger::getContractCode,deviceLeasingLedger.getContractCode());
|
wrapper.like(StrUtil.isNotBlank(deviceLeasingLedger.getLedgerCode()),DeviceLeasingLedger::getLedgerCode,deviceLeasingLedger.getLedgerCode());
|
wrapper.orderByDesc(DeviceLeasingLedger::getCreateTime);
|
return R.ok(deviceLeasingLedgerService.page(page, wrapper));
|
}
|
|
|
/**
|
* 通过id查询设备租赁台账
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedger_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(deviceLeasingLedgerService.getByIdDeep(id));
|
}
|
|
/**
|
* 新增设备租赁台账
|
* @param deviceLeasingLedger 设备租赁台账
|
* @return R
|
*/
|
@Operation(summary = "新增设备租赁台账" , description = "新增设备租赁台账" )
|
@SysLog("新增设备租赁台账" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedger_add')" )
|
public R save(@RequestBody DeviceLeasingLedger deviceLeasingLedger) {
|
deviceLeasingLedger.setLedgerCode(maxSizeService.nextNo(MaxSizeContant.LEDGER_CODE));
|
deviceLeasingLedger.setLesseeContractId(SecurityUtils.getUser().getCompId());
|
return deviceLeasingLedgerService.saveDeep(deviceLeasingLedger);
|
}
|
|
/**
|
* 修改设备租赁台账
|
* @param deviceLeasingLedger 设备租赁台账
|
* @return R
|
*/
|
@Operation(summary = "修改设备租赁台账" , description = "修改设备租赁台账" )
|
@SysLog("修改设备租赁台账" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedger_edit')" )
|
public R updateById(@RequestBody DeviceLeasingLedger deviceLeasingLedger) {
|
return R.ok(deviceLeasingLedgerService.updateById(deviceLeasingLedger));
|
}
|
|
/**
|
* 通过id删除设备租赁台账
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除设备租赁台账" , description = "通过id删除设备租赁台账" )
|
@SysLog("通过id删除设备租赁台账" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedger_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(deviceLeasingLedgerService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param deviceLeasingLedger 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('device_deviceLeasingLedger_export')" )
|
public List<DeviceLeasingLedger> export(DeviceLeasingLedger deviceLeasingLedger,Long[] ids) {
|
return deviceLeasingLedgerService.list(Wrappers.lambdaQuery(deviceLeasingLedger).in(ArrayUtil.isNotEmpty(ids), DeviceLeasingLedger::getId, ids));
|
}
|
|
/**
|
* 台账下拉
|
*/
|
@GetMapping("/getSelectList")
|
public R getSelectList() {
|
return R.ok(deviceLeasingLedgerService.getSelectList());
|
}
|
|
/**
|
* 根据台账获取设备下拉
|
*/
|
@GetMapping("/getDeviceSelectList/{ledgerId}")
|
public R getDeviceSelectList(@PathVariable("ledgerId")Long ledgerId) {
|
return R.ok(deviceLeasingLedgerService.getDeviceSelectList(ledgerId));
|
}
|
|
/**
|
* 台账中设备序列号下拉下拉
|
*/
|
@Operation(summary = "台账明细中设备序列号下拉",description = "台账明细中设备序列号下拉下拉")
|
@GetMapping("/getLedgerDeviceList/{deviceId}")
|
public R getLedgerDeviceList(@PathVariable("deviceId")Long deviceId) {
|
return R.ok(deviceLeasingLedgerService.getLedgerDeviceList(deviceId));
|
}
|
}
|