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.device.constant.MaxSizeContant;
|
import com.by4cloud.platformx.device.entity.DeviceDemandPlan;
|
import com.by4cloud.platformx.device.entity.InvestmentPlan;
|
import com.by4cloud.platformx.device.service.DeviceDemandPlanService;
|
import com.by4cloud.platformx.device.service.InvestmentPlanService;
|
import com.by4cloud.platformx.device.service.JcMaxSizeService;
|
import com.by4cloud.platformx.device.util.NumUtils;
|
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 kdq
|
* @date 2025-03-28 11:06:50
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/investmentPlan" )
|
@Tag(description = "investmentPlan" , name = "年度投资计划主表管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class InvestmentPlanController {
|
|
private final InvestmentPlanService investmentPlanService;
|
private final DeviceDemandPlanService deviceDemandPlanService;
|
private final JcMaxSizeService maxSizeService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param investmentPlan 年度投资计划主表
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('device_investmentPlan_view')" )
|
public R getInvestmentPlanPage(@ParameterObject Page page, @ParameterObject InvestmentPlan investmentPlan) {
|
LambdaQueryWrapper<InvestmentPlan> wrapper = Wrappers.lambdaQuery();
|
wrapper.eq(investmentPlan.getYear()!=null,InvestmentPlan::getYear,investmentPlan.getYear());
|
wrapper.like(StringUtils.isNotBlank(investmentPlan.getName()),InvestmentPlan::getName,investmentPlan.getName());
|
return R.ok(investmentPlanService.page(page, wrapper));
|
}
|
|
|
/**
|
* 通过id查询年度投资计划主表
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('device_investmentPlan_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(investmentPlanService.getById(id));
|
}
|
|
/**
|
* 新增年度投资计划主表
|
* @param investmentPlan 年度投资计划主表
|
* @return R
|
*/
|
@Operation(summary = "新增年度投资计划主表" , description = "新增年度投资计划主表" )
|
@SysLog("新增年度投资计划主表" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('device_investmentPlan_add')" )
|
public R save(@RequestBody InvestmentPlan investmentPlan) {
|
investmentPlan.setNumber(maxSizeService.nextNo(MaxSizeContant.TZPLAN_NUM));
|
investmentPlanService.save(investmentPlan);
|
|
return R.ok();
|
}
|
|
/**
|
* 修改年度投资计划主表
|
* @param investmentPlan 年度投资计划主表
|
* @return R
|
*/
|
@Operation(summary = "修改年度投资计划主表" , description = "修改年度投资计划主表" )
|
@SysLog("修改年度投资计划主表" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('device_investmentPlan_edit')" )
|
public R updateById(@RequestBody InvestmentPlan investmentPlan) {
|
return R.ok(investmentPlanService.updateById(investmentPlan));
|
}
|
|
/**
|
* 通过id删除年度投资计划主表
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除年度投资计划主表" , description = "通过id删除年度投资计划主表" )
|
@SysLog("通过id删除年度投资计划主表" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('device_investmentPlan_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(investmentPlanService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param investmentPlan 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('device_investmentPlan_export')" )
|
public List<InvestmentPlan> export(InvestmentPlan investmentPlan,Long[] ids) {
|
return investmentPlanService.list(Wrappers.lambdaQuery(investmentPlan).in(ArrayUtil.isNotEmpty(ids), InvestmentPlan::getId, ids));
|
}
|
}
|