kongdeqiang
2025-03-24 18d187869d098a2893d79acdadc7d7a99aad28e6
fix: 更新设备项目表和项目子表接口
11个文件已修改
1个文件已添加
291 ■■■■ 已修改文件
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/Device.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandPlan.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandSub.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandTotal.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/vo/DemandPlanVo.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceClassController.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceController.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandTotalController.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/DeviceDemandPlanService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceDemandPlanServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/Device.java
@@ -75,6 +75,10 @@
    @Column(columnDefinition="int comment '库存数'")
    private Integer num;
    @Schema(description = "备注")
    @Column(columnDefinition="VARCHAR(64) comment '备注'")
    private String remark;
    @Column(
            columnDefinition = "varchar(100) comment '名称'"
    )
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandPlan.java
@@ -1,5 +1,6 @@
package com.by4cloud.platformx.device.entity;
import com.by4cloud.platformx.common.data.mybatis.BaseModel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -20,7 +21,7 @@
@Data
@Entity
@Table(appliesTo = "device_demand_plan", comment = "设备需求计划主表")
public class DeviceDemandPlan extends DeviceBaseModel<DeviceDemandPlan>{
public class DeviceDemandPlan extends BaseModel<DeviceDemandPlan> {
    @Schema(description = "设备编码")
    @Column(columnDefinition="VARCHAR(64) comment '设备编码'")
    private String number;
@@ -30,7 +31,7 @@
    @Schema(description = "联系人")
    @Column(columnDefinition="VARCHAR(64) comment '联系人'")
    private String contacts;
    @Schema(description = "申报状态")
    @Schema(description = "申报状态 0申请中,1二级单位审核拒绝  2二级单位审核通过 3集团审核拒绝 4集团审核通过")
    @Column(columnDefinition="int comment '申报状态'")
    private Integer status;
    @Schema(description = "申报类型")
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandSub.java
@@ -19,8 +19,11 @@
@Table(appliesTo = "device_demand_sub", comment = "设备需求计划设备子表")
public class DeviceDemandSub extends DeviceBaseModel<DeviceDemandSub>{
    @Schema(description = "项目表id")
    @Column(columnDefinition="int comment '项目表id'")
    private Integer totalId;
    @Column(columnDefinition="long comment '项目表id'")
    private Long totalId;
    @Schema(description = "设备表id")
    @Column(columnDefinition="long comment '设备表id'")
    private Long deviceId;
    @Schema(description = "设备编码")
    @Column(columnDefinition="VARCHAR(64) comment '设备编码'")
    private String number;
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandTotal.java
@@ -1,11 +1,14 @@
package com.by4cloud.platformx.device.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.annotations.Table;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.List;
/**
 * @author kdq
@@ -33,4 +36,8 @@
    @Schema(description = "投资必要性")
    @Column(columnDefinition="VARCHAR(64) comment '投资必要性'")
    private String necessity;
    @Transient
    @TableField(exist = false)
    private List<DeviceDemandSub> subList;
}
platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/vo/DemandPlanVo.java
New file
@@ -0,0 +1,18 @@
package com.by4cloud.platformx.device.entity.vo;
import com.by4cloud.platformx.device.entity.DeviceDemandPlan;
import com.by4cloud.platformx.device.entity.DeviceDemandTotal;
import lombok.Data;
/**
 * @author kdq
 * @version 1.0.0
 * @ClassName DemandPlanVo.java
 * @Description TODO
 * @createTime 2025年03月13日 16:28:00
 */
@Data
public class DemandPlanVo {
    private DeviceDemandPlan plan;
    private DeviceDemandTotal total;
}
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceClassController.java
@@ -4,11 +4,13 @@
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.conditions.query.QueryWrapper;
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.entity.DeviceClass;
import com.by4cloud.platformx.device.entity.DeviceInventory;
import com.by4cloud.platformx.device.service.DeviceClassService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
@@ -49,7 +51,7 @@
    @PreAuthorize("@pms.hasPermission('platformx_deviceClass_view')" )
    public R getDeviceClassPage(@ParameterObject Page page, @ParameterObject DeviceClass deviceClass) {
        LambdaQueryWrapper<DeviceClass> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StrUtil.isNotBlank(deviceClass.getName()),DeviceClass::getName,deviceClass.getName());
        wrapper.like(StrUtil.isNotBlank(deviceClass.getName()),DeviceClass::getName,deviceClass.getName());
        wrapper.eq(StrUtil.isNotBlank(deviceClass.getNumber()),DeviceClass::getNumber,deviceClass.getNumber());
        return R.ok(deviceClassService.page(page, wrapper));
    }
@@ -99,6 +101,12 @@
        if(deviceClass.getParentId()==null){
            return R.failed("上级分类未选择!");
        }
        QueryWrapper<DeviceClass> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(DeviceClass::getNumber,deviceClass.getNumber());
        List<DeviceClass> list = deviceClassService.list(wrapper);
        if(list!=null&&list.size()>0){
            return R.failed("该编号已存在");
        }
        deviceClass.setPId(deviceClass.getParentId().longValue());
        return R.ok(deviceClassService.save(deviceClass));
    }
@@ -116,6 +124,15 @@
        if(deviceClass.getParentId()==null){
            return R.failed("上级分类未选择!");
        }
        QueryWrapper<DeviceClass> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(DeviceClass::getNumber,deviceClass.getNumber());
        List<DeviceClass> list = deviceClassService.list(wrapper);
        if(list!=null&&list.size()>0){
            DeviceClass deviceClass1 = list.get(0);
            if(!deviceClass1.getId().equals(deviceClass.getId())){
                return R.failed("已存在该序列号,请重新添加");
            }
        }
        deviceClass.setPId(deviceClass.getParentId().longValue());
        return R.ok(deviceClassService.updateById(deviceClass));
    }
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceController.java
@@ -4,6 +4,8 @@
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.conditions.query.QueryWrapper;
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.admin.api.entity.SysDeptRelation;
@@ -11,6 +13,8 @@
import com.by4cloud.platformx.common.log.annotation.SysLog;
import com.by4cloud.platformx.common.security.util.SecurityUtils;
import com.by4cloud.platformx.device.entity.Device;
import com.by4cloud.platformx.device.entity.DeviceInventory;
import com.by4cloud.platformx.device.service.DeviceInventoryService;
import com.by4cloud.platformx.device.service.DeviceService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
@@ -39,6 +43,7 @@
public class DeviceController {
    private final  DeviceService deviceService;
    private final DeviceInventoryService inventoryService;
    /**
     * 分页查询
@@ -54,7 +59,14 @@
        wrapper.eq(Device::getReqStatus,1);
        wrapper.like(StrUtil.isNotBlank(device.getNumber()),Device::getNumber,device.getNumber());
        wrapper.like(StrUtil.isNotBlank(device.getName()),Device::getName,device.getName());
        return R.ok(deviceService.page(page, wrapper));
        Page<Device> page1 = deviceService.page(page, wrapper);
        for (Device device1 : page1.getRecords()) {
            QueryWrapper<DeviceInventory> wrapper1 = new QueryWrapper<>();
            wrapper1.lambda().eq(DeviceInventory::getDeviceId,device1.getId());
            long count = inventoryService.count(wrapper1);
            device1.setNum(Integer.parseInt(count+""));
        }
        return R.ok(page1);
    }
    /**
     * 分页查询
@@ -71,6 +83,16 @@
        wrapper.like(StrUtil.isNotBlank(device.getNumber()),Device::getNumber,device.getNumber());
        wrapper.like(StrUtil.isNotBlank(device.getName()),Device::getName,device.getName());
        return R.ok(deviceService.page(page, wrapper));
    }
    @Operation(summary = "根据设备分类获取设备" , description = "根据设备分类获取设备" )
    @GetMapping("/getByClassId" )
    public R getByClassId(@ParameterObject Device device) {
        LambdaQueryWrapper<Device> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Device::getReqStatus,1);
        wrapper.eq(Device::getClassId,device.getClassId());
        wrapper.like(StrUtil.isNotBlank(device.getName()),Device::getName,device.getName());
        return R.ok(deviceService.list(wrapper));
    }
@@ -93,20 +115,34 @@
    @Operation(summary = "审批通过" , description = "审批通过" )
    @PostMapping("/pass" )
    public R passById(@RequestBody Device device) {
        if(StringUtils.isBlank(device.getNumber())){
            return R.failed("请填写设备编号");
        }
        QueryWrapper<Device> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(Device::getNumber,device.getNumber());
        List<Device> list = deviceService.list(wrapper);
        if(list !=null && list.size()>0){
            Device device1 = list.get(0);
            if(!device1.getId().equals(device.getId())){
                return R.failed("已存在该编号");
            }
        }
        device.setReqStatus(1);
        deviceService.updateById(device);
        return R.ok();
    }
    /**
     * 审批拒绝
     * @param id id
     * @return R
     */
    @Operation(summary = "审批拒绝" , description = "审批拒绝" )
    @GetMapping("/kill/{id}" )
    public R killById(@PathVariable("id" ) Long id) {
        Device byId = deviceService.getById(id);
    @GetMapping("/kill" )
    public R killById(@ParameterObject Device device) {
        Device byId = deviceService.getById(device.getId());
        byId.setReqStatus(2);
        if(StringUtils.isNotBlank(device.getRemark())){
            byId.setRemark(device.getRemark());
        }
        deviceService.updateById(byId);
        return R.ok();
    }
@@ -119,11 +155,32 @@
    @Operation(summary = "新增出租设备清单表" , description = "新增出租设备清单表" )
    @SysLog("新增出租设备清单表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('platformx_device_add')" )
    public R save(@RequestBody Device device) {
        if(device.getReqStatus() == 0){
            device.setReqCompId(SecurityUtils.getUser().getDeptId());
            return R.ok(deviceService.save(device));
        }
        if(StringUtils.isBlank(device.getNumber())){
            return R.failed("请填写设备编号");
        }
        QueryWrapper<Device> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(Device::getNumber,device.getNumber());
        List<Device> list = deviceService.list(wrapper);
        if(list !=null && list.size()>0){
            return R.failed("已存在该编号");
        }
        return R.ok(deviceService.save(device));
    }
    /**
     * 三级单位新增设备清单
     * @param device 三级单位新增设备清单
     * @return R
     */
    @Operation(summary = "三级单位新增设备清单" , description = "三级单位新增设备清单" )
    @SysLog("新增出租设备清单表" )
    @PostMapping("/childAdd")
    public R childAdd(@RequestBody Device device) {
        device.setReqStatus(0);
        return R.ok(deviceService.save(device));
    }
@@ -137,6 +194,15 @@
    @PutMapping
    @PreAuthorize("@pms.hasPermission('platformx_device_edit')" )
    public R updateById(@RequestBody Device device) {
        QueryWrapper<Device> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(Device::getNumber,device.getNumber());
        List<Device> list = deviceService.list(wrapper);
        if(list !=null && list.size()>0){
            Device device1 = list.get(0);
            if(!device1.getId().equals(device.getId())){
                return R.failed("已存在该编号");
            }
        }
        return R.ok(deviceService.updateById(device));
    }
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java
@@ -43,12 +43,11 @@
     * @param deviceDemandPlan 设备需求计划主表
     * @return
     */
    @Operation(summary = "分页查询" , description = "分页查询" )
    @Operation(summary = "本单位分页查询" , description = "本单位分页查询" )
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('platformx_deviceDemandPlan_view')" )
    public R getDeviceDemandPlanPage(@ParameterObject Page page, @ParameterObject DeviceDemandPlan deviceDemandPlan) {
        LambdaQueryWrapper<DeviceDemandPlan> wrapper = Wrappers.lambdaQuery();
        return R.ok(deviceDemandPlanService.page(page, wrapper));
        return R.ok(deviceDemandPlanService.pageByScope(page, wrapper));
    }
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandTotalController.java
@@ -3,11 +3,15 @@
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.conditions.query.QueryWrapper;
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.entity.DeviceDemandPlan;
import com.by4cloud.platformx.device.entity.DeviceDemandSub;
import com.by4cloud.platformx.device.entity.DeviceDemandTotal;
import com.by4cloud.platformx.device.service.DeviceDemandSubService;
import com.by4cloud.platformx.device.service.DeviceDemandTotalService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
@@ -36,6 +40,7 @@
public class DeviceDemandTotalController {
    private final  DeviceDemandTotalService deviceDemandTotalService;
    private final DeviceDemandSubService deviceDemandSubService;
    /**
     * 分页查询
@@ -61,8 +66,29 @@
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('platformx_deviceDemandTotal_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(deviceDemandTotalService.getById(id));
        DeviceDemandTotal demandTotal = deviceDemandTotalService.getById(id);
        QueryWrapper<DeviceDemandSub> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(DeviceDemandSub::getTotalId,demandTotal.getId());
        List<DeviceDemandSub> list = deviceDemandSubService.list(wrapper);
        demandTotal.setSubList(list);
        return R.ok(demandTotal);
    }
    /**
     * 通过id查询设备需求计划项目子表
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询" , description = "通过id查询" )
    @GetMapping("/getByPlanId/{id}" )
    public R getByPlanId(@PathVariable("id" ) Long id) {
        QueryWrapper<DeviceDemandTotal> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(DeviceDemandTotal::getPlanId,id);
        return R.ok(deviceDemandTotalService.list(wrapper));
    }
    /**
     * 新增设备需求计划项目子表
@@ -72,9 +98,17 @@
    @Operation(summary = "新增设备需求计划项目子表" , description = "新增设备需求计划项目子表" )
    @SysLog("新增设备需求计划项目子表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('platformx_deviceDemandTotal_add')" )
    public R save(@RequestBody DeviceDemandTotal deviceDemandTotal) {
        return R.ok(deviceDemandTotalService.save(deviceDemandTotal));
        if(deviceDemandTotal.getPlanId()==null){
            return R.failed("计划id必传");
        }
        deviceDemandTotalService.save(deviceDemandTotal);
        List<DeviceDemandSub> subList = deviceDemandTotal.getSubList();
        for (DeviceDemandSub deviceDemandSub : subList) {
            deviceDemandSub.setTotalId(deviceDemandTotal.getId());
            deviceDemandSubService.save(deviceDemandSub);
        }
        return R.ok("添加成功");
    }
    /**
@@ -87,21 +121,54 @@
    @PutMapping
    @PreAuthorize("@pms.hasPermission('platformx_deviceDemandTotal_edit')" )
    public R updateById(@RequestBody DeviceDemandTotal deviceDemandTotal) {
        List<DeviceDemandSub> subList = deviceDemandTotal.getSubList();
        QueryWrapper<DeviceDemandSub> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(DeviceDemandSub::getTotalId,deviceDemandTotal.getId());
        List<DeviceDemandSub> list = deviceDemandSubService.list(wrapper);
        deviceDemandSubService.removeBatchByIds(list);
        for (DeviceDemandSub deviceDemandSub : subList) {
            deviceDemandSub.setTotalId(deviceDemandTotal.getId());
            deviceDemandSubService.save(deviceDemandSub);
        }
        return R.ok(deviceDemandTotalService.updateById(deviceDemandTotal));
    }
    /**
     * 通过id删除设备需求计划项目子表
     * @param ids id列表
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id删除设备需求计划项目子表" , description = "通过id删除设备需求计划项目子表" )
    @SysLog("通过id删除设备需求计划项目子表" )
    @DeleteMapping
    @PreAuthorize("@pms.hasPermission('platformx_deviceDemandTotal_del')" )
    public R removeById(@RequestBody Long[] ids) {
        return R.ok(deviceDemandTotalService.removeBatchByIds(CollUtil.toList(ids)));
    @GetMapping("/deleteById/{id}")
    public R deleteById(@PathVariable("id" ) Long id) {
        DeviceDemandTotal byId = deviceDemandTotalService.getById(id);
        if(byId != null){
            deviceDemandTotalService.removeById(id);
            QueryWrapper<DeviceDemandSub> wrapper = new QueryWrapper<>();
            wrapper.lambda()
                    .eq(DeviceDemandSub::getTotalId,byId.getId());
            List<DeviceDemandSub> list = deviceDemandSubService.list(wrapper);
            deviceDemandSubService.removeBatchByIds(list);
        }else {
            return R.failed("未查询到该项目");
    }
        return R.ok();
    }
//    /**
//     * 通过id删除设备需求计划项目子表
//     * @param ids id列表
//     * @return R
//     */
//    @Operation(summary = "通过id删除设备需求计划项目子表" , description = "通过id删除设备需求计划项目子表" )
//    @SysLog("通过id删除设备需求计划项目子表" )
//    @DeleteMapping
//    @PreAuthorize("@pms.hasPermission('platformx_deviceDemandTotal_del')" )
//    public R removeById(@RequestBody Long[] ids) {
//        return R.ok(deviceDemandTotalService.removeBatchByIds(CollUtil.toList(ids)));
//    }
    /**
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java
@@ -3,6 +3,8 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
@@ -34,7 +36,7 @@
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DeviceInventoryController {
    private final DeviceInventoryService DeviceInventoryService;
    private final DeviceInventoryService deviceInventoryService;
    /**
     * 分页查询
@@ -46,7 +48,10 @@
    @GetMapping("/page" )
    public R getDeviceInventoryPage(@ParameterObject Page page, @ParameterObject DeviceInventory deviceInventory) {
        LambdaQueryWrapper<DeviceInventory> wrapper = Wrappers.lambdaQuery();
        return R.ok(DeviceInventoryService.page(page, wrapper));
        wrapper.like(StringUtils.isNotBlank(deviceInventory.getDeviceNumber()),DeviceInventory::getDeviceNumber,deviceInventory.getDeviceNumber());
        wrapper.like(StringUtils.isNotBlank(deviceInventory.getSerialNo()),DeviceInventory::getSerialNo,deviceInventory.getSerialNo());
        wrapper.like(StringUtils.isNotBlank(deviceInventory.getName()),DeviceInventory::getName,deviceInventory.getName());
        return R.ok(deviceInventoryService.page(page, wrapper));
    }
@@ -58,30 +63,59 @@
    @Operation(summary = "通过id查询" , description = "通过id查询" )
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(DeviceInventoryService.getById(id));
        return R.ok(deviceInventoryService.getById(id));
    }
    /**
     * 新增库存流水表
     * @param DeviceInventory 库存表
     * @param deviceInventory 库存表
     * @return R
     */
    @Operation(summary = "新增库存表" , description = "新增库存表" )
    @SysLog("新增库存流水表" )
    @PostMapping
    public R save(@RequestBody DeviceInventory DeviceInventory) {
        return R.ok(DeviceInventoryService.save(DeviceInventory));
    public R save(@RequestBody DeviceInventory deviceInventory) {
        if(deviceInventory.getDeviceId()==null){
            return R.failed("请选择设备清单");
        }
        if(deviceInventory.getSerialNo()==null){
            return R.failed("请填写设备序列号");
        }
        QueryWrapper<DeviceInventory> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(DeviceInventory::getDeviceId,deviceInventory.getDeviceId())
                .eq(DeviceInventory::getSerialNo,deviceInventory.getSerialNo());
        List<DeviceInventory> list = deviceInventoryService.list(wrapper);
        if(list !=null && list.size()>0){
            return R.failed("已存在该序列号,请重新添加");
        }
        return R.ok(deviceInventoryService.save(deviceInventory));
    }
    /**
     * 修改库存表
     * @param DeviceInventory 库存表
     * @param deviceInventory 库存表
     * @return R
     */
    @SysLog("修改库存表" )
    @PutMapping
    public R updateById(@RequestBody DeviceInventory DeviceInventory) {
        return R.ok(DeviceInventoryService.updateById(DeviceInventory));
    public R updateById(@RequestBody DeviceInventory deviceInventory) {
        if(deviceInventory.getDeviceId()==null){
            return R.failed("请选择设备清单");
        }
        if(deviceInventory.getSerialNo()==null){
            return R.failed("请填写设备序列号");
        }
        QueryWrapper<DeviceInventory> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(DeviceInventory::getDeviceId,deviceInventory.getDeviceId())
                .eq(DeviceInventory::getSerialNo,deviceInventory.getSerialNo());
        List<DeviceInventory> list = deviceInventoryService.list(wrapper);
        if(list !=null && list.size()>0){
            DeviceInventory deviceInventory1 = list.get(0);
            if(!deviceInventory1.getId().equals(deviceInventory.getId())){
                return R.failed("已存在该序列号,请重新添加");
            }
        }
        return R.ok(deviceInventoryService.updateById(deviceInventory));
    }
    /**
@@ -93,7 +127,7 @@
    @SysLog("通过id删除库存流水表" )
    @DeleteMapping
    public R removeById(@RequestBody Long[] ids) {
        return R.ok(DeviceInventoryService.removeBatchByIds(CollUtil.toList(ids)));
        return R.ok(deviceInventoryService.removeBatchByIds(CollUtil.toList(ids)));
    }
@@ -107,6 +141,6 @@
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('platformx_DeviceInventory_export')" )
    public List<DeviceInventory> export(DeviceInventory deviceInventory,Long[] ids) {
        return DeviceInventoryService.list(Wrappers.lambdaQuery(deviceInventory).in(ArrayUtil.isNotEmpty(ids), DeviceInventory::getId, ids));
        return deviceInventoryService.list(Wrappers.lambdaQuery(deviceInventory).in(ArrayUtil.isNotEmpty(ids), DeviceInventory::getId, ids));
    }
}
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/DeviceDemandPlanService.java
@@ -1,8 +1,9 @@
package com.by4cloud.platformx.device.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.by4cloud.platformx.common.data.mybatis.IIService;
import com.by4cloud.platformx.device.entity.DeviceDemandPlan;
public interface DeviceDemandPlanService extends IService<DeviceDemandPlan> {
public interface DeviceDemandPlanService extends IIService<DeviceDemandPlan> {
}
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/DeviceDemandPlanServiceImpl.java
@@ -1,9 +1,13 @@
package com.by4cloud.platformx.device.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.by4cloud.platformx.common.data.datascope.DataScope;
import com.by4cloud.platformx.device.entity.DeviceDemandPlan;
import com.by4cloud.platformx.device.mapper.DeviceDemandPlanMapper;
import com.by4cloud.platformx.device.service.DeviceDemandPlanService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
 * 设备需求计划主表