Compare commits
2 Commits
facf7a8f51
...
5e21feb414
Author | SHA1 | Date |
---|---|---|
|
5e21feb414 | |
|
524faa18a5 |
|
@ -1,135 +1,219 @@
|
|||
package com.dite.znpt.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.dite.znpt.domain.AuditableEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/7/23/周三 17:26
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("equipment")
|
||||
@ApiModel(value="EquipmentEntity对象", description="设备信息表")
|
||||
public class EquipmentEntity extends AuditableEntity implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6665040704562461286L;
|
||||
|
||||
@ApiModelProperty("设备id")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String equipmentId;
|
||||
|
||||
@ApiModelProperty("资产编号")
|
||||
private String assetCode;
|
||||
|
||||
@ApiModelProperty("设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@ApiModelProperty("设备类型")
|
||||
private String equipmentType;
|
||||
|
||||
@ApiModelProperty("设备状态,枚举:EquipmentStatusEnum")
|
||||
private String equipmentStatus;
|
||||
|
||||
@ApiModelProperty("使用状态,0-空闲中,1-使用中")
|
||||
private String useStatus;
|
||||
|
||||
@ApiModelProperty("设备序列号")
|
||||
private String equipmentSn;
|
||||
|
||||
@ApiModelProperty("品牌")
|
||||
private String brand;
|
||||
|
||||
@ApiModelProperty("配置规格/参数")
|
||||
private String specification;
|
||||
|
||||
@ApiModelProperty("位置状态")
|
||||
private String locationStatus;
|
||||
|
||||
@ApiModelProperty("设备当前物理位置")
|
||||
private String physicalLocation;
|
||||
|
||||
@ApiModelProperty("负责人")
|
||||
private String responsiblePerson;
|
||||
|
||||
@ApiModelProperty("健康状态")
|
||||
private String healthStatus;
|
||||
|
||||
@ApiModelProperty("采购时间")
|
||||
private LocalDateTime purchaseTime;
|
||||
|
||||
@ApiModelProperty("入库时间")
|
||||
private LocalDateTime inStockTime;
|
||||
|
||||
@ApiModelProperty("启用时间")
|
||||
private LocalDateTime activationTime;
|
||||
|
||||
@ApiModelProperty("预计报废时间")
|
||||
private LocalDateTime expectedScrapTime;
|
||||
|
||||
@ApiModelProperty("实际报废时间")
|
||||
private LocalDateTime actualScrapTime;
|
||||
|
||||
@ApiModelProperty("状态变更时间")
|
||||
private LocalDateTime statusChangeTime;
|
||||
|
||||
@ApiModelProperty("采购订单")
|
||||
private String purchaseOrder;
|
||||
|
||||
@ApiModelProperty("供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
@ApiModelProperty("采购价格")
|
||||
private BigDecimal purchasePrice;
|
||||
|
||||
@ApiModelProperty("当前净值")
|
||||
private BigDecimal currentNetValue;
|
||||
|
||||
@ApiModelProperty("折旧方法")
|
||||
private String depreciationMethod;
|
||||
|
||||
@ApiModelProperty("折旧年限")
|
||||
private Integer depreciationYears;
|
||||
|
||||
@ApiModelProperty("残值")
|
||||
private BigDecimal salvageValue;
|
||||
|
||||
@ApiModelProperty("保修截止日期")
|
||||
private LocalDateTime warrantyExpireDate;
|
||||
|
||||
@ApiModelProperty("上次维护日期")
|
||||
private LocalDateTime lastMaintenanceDate;
|
||||
|
||||
@ApiModelProperty("下次维护日期")
|
||||
private LocalDateTime nextMaintenanceDate;
|
||||
|
||||
@ApiModelProperty("维护人员")
|
||||
private String maintenancePerson;
|
||||
|
||||
@ApiModelProperty("库存条码")
|
||||
private String inventoryBarcode;
|
||||
|
||||
@ApiModelProperty("资产备注")
|
||||
private String assetRemark;
|
||||
|
||||
@ApiModelProperty("当前使用记录id")
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String useRecordId;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 1代表删除)")
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private String delFlag;
|
||||
}
|
||||
package com.dite.znpt.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.dite.znpt.domain.AuditableEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/7/23/周三 17:26
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("equipment")
|
||||
@ApiModel(value="EquipmentEntity对象", description="设备信息表")
|
||||
public class EquipmentEntity extends AuditableEntity implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -6665040704562461286L;
|
||||
|
||||
@ApiModelProperty("设备id")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String equipmentId;
|
||||
|
||||
@ApiModelProperty("资产编号")
|
||||
private String assetCode;
|
||||
|
||||
@ApiModelProperty("设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@ApiModelProperty("设备类型")
|
||||
private String equipmentType;
|
||||
|
||||
@ApiModelProperty("设备状态,枚举:EquipmentStatusEnum")
|
||||
private String equipmentStatus;
|
||||
|
||||
@ApiModelProperty("使用状态,0-空闲中,1-使用中")
|
||||
private String useStatus;
|
||||
|
||||
@ApiModelProperty("设备序列号")
|
||||
private String equipmentSn;
|
||||
|
||||
@ApiModelProperty("品牌")
|
||||
private String brand;
|
||||
|
||||
@ApiModelProperty("配置规格/参数")
|
||||
private String specification;
|
||||
|
||||
@ApiModelProperty("位置状态")
|
||||
private String locationStatus;
|
||||
|
||||
@ApiModelProperty("设备当前物理位置")
|
||||
private String physicalLocation;
|
||||
|
||||
@ApiModelProperty("负责人")
|
||||
private String responsiblePerson;
|
||||
|
||||
@ApiModelProperty("健康状态")
|
||||
private String healthStatus;
|
||||
|
||||
@ApiModelProperty("采购时间")
|
||||
private LocalDateTime purchaseTime;
|
||||
|
||||
@ApiModelProperty("入库时间")
|
||||
private LocalDateTime inStockTime;
|
||||
|
||||
@ApiModelProperty("启用时间")
|
||||
private LocalDateTime activationTime;
|
||||
|
||||
@ApiModelProperty("预计报废时间")
|
||||
private LocalDateTime expectedScrapTime;
|
||||
|
||||
@ApiModelProperty("实际报废时间")
|
||||
private LocalDateTime actualScrapTime;
|
||||
|
||||
@ApiModelProperty("状态变更时间")
|
||||
private LocalDateTime statusChangeTime;
|
||||
|
||||
@ApiModelProperty("采购订单")
|
||||
private String purchaseOrder;
|
||||
|
||||
@ApiModelProperty("供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
// 移除采购价格字段,使用单价和总价替代
|
||||
// @ApiModelProperty("采购价格")
|
||||
// private BigDecimal purchasePrice;
|
||||
|
||||
@ApiModelProperty("当前净值")
|
||||
private BigDecimal currentNetValue;
|
||||
|
||||
@ApiModelProperty("折旧方法")
|
||||
private String depreciationMethod;
|
||||
|
||||
@ApiModelProperty("折旧年限")
|
||||
private Integer depreciationYears;
|
||||
|
||||
@ApiModelProperty("残值")
|
||||
private BigDecimal salvageValue;
|
||||
|
||||
@ApiModelProperty("保修截止日期")
|
||||
private LocalDateTime warrantyExpireDate;
|
||||
|
||||
@ApiModelProperty("上次维护日期")
|
||||
private LocalDateTime lastMaintenanceDate;
|
||||
|
||||
@ApiModelProperty("下次维护日期")
|
||||
private LocalDateTime nextMaintenanceDate;
|
||||
|
||||
@ApiModelProperty("维护人员")
|
||||
private String maintenancePerson;
|
||||
|
||||
@ApiModelProperty("库存条码")
|
||||
private String inventoryBarcode;
|
||||
|
||||
@ApiModelProperty("资产备注")
|
||||
private String assetRemark;
|
||||
|
||||
@ApiModelProperty("次户号")
|
||||
private String accountNumber;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
// 移除备用状态字段,使用现有的 location_status 字段
|
||||
// @ApiModelProperty("备用状态")
|
||||
// private String spareStatus;
|
||||
|
||||
@ApiModelProperty("盘点依据")
|
||||
private String inventoryBasis;
|
||||
|
||||
@ApiModelProperty("动态记录")
|
||||
private String dynamicRecord;
|
||||
|
||||
// 移除认证状态字段,使用现有的 health_status 字段
|
||||
// @ApiModelProperty("认证状态")
|
||||
// private String certificationStatus;
|
||||
|
||||
@ApiModelProperty("使用部门/人")
|
||||
private String usingDepartment;
|
||||
|
||||
@ApiModelProperty("领用时间")
|
||||
private LocalDateTime borrowingTime;
|
||||
|
||||
@ApiModelProperty("归还时间")
|
||||
private LocalDateTime returnTime;
|
||||
|
||||
@ApiModelProperty("出库时间")
|
||||
private LocalDateTime outStockTime;
|
||||
|
||||
@ApiModelProperty("总使用时间")
|
||||
private String totalUsageTime;
|
||||
|
||||
@ApiModelProperty("折旧率")
|
||||
private BigDecimal depreciationRate;
|
||||
|
||||
@ApiModelProperty("折旧方法说明")
|
||||
private String depreciationMethodDesc;
|
||||
|
||||
@ApiModelProperty("发票")
|
||||
private String invoice;
|
||||
|
||||
@ApiModelProperty("发票状态")
|
||||
private String invoiceStatus;
|
||||
|
||||
@ApiModelProperty("附件")
|
||||
private String attachments;
|
||||
|
||||
@ApiModelProperty("照片")
|
||||
private String photos;
|
||||
|
||||
@ApiModelProperty("条码")
|
||||
private String barcode;
|
||||
|
||||
@ApiModelProperty("导入人")
|
||||
private String importer;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态1")
|
||||
private String inventoryTimeStatus1;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态2")
|
||||
private String inventoryTimeStatus2;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态3")
|
||||
private String inventoryTimeStatus3;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态1")
|
||||
private String inventoryCheckTimeStatus1;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态2")
|
||||
private String inventoryCheckTimeStatus2;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态3")
|
||||
private String inventoryCheckTimeStatus3;
|
||||
|
||||
@ApiModelProperty("当前使用记录id")
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String useRecordId;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 1代表删除)")
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private String delFlag;
|
||||
}
|
||||
|
|
|
@ -67,9 +67,30 @@ public class EquipmentListReq implements Serializable {
|
|||
@ApiModelProperty("供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
@ApiModelProperty("采购订单号")
|
||||
private String purchaseOrder;
|
||||
|
||||
@ApiModelProperty("维护人员")
|
||||
private String maintenancePerson;
|
||||
|
||||
@ApiModelProperty("次户号")
|
||||
private String accountNumber;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private java.math.BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
private java.math.BigDecimal totalPrice;
|
||||
|
||||
@ApiModelProperty("盘点依据")
|
||||
private String inventoryBasis;
|
||||
|
||||
@ApiModelProperty("动态记录")
|
||||
private String dynamicRecord;
|
||||
|
||||
@ApiModelProperty("库存条码")
|
||||
private String inventoryBarcode;
|
||||
|
||||
|
@ -131,14 +152,17 @@ public class EquipmentListReq implements Serializable {
|
|||
private LocalDateTime updateTimeEnd;
|
||||
|
||||
@ApiModelProperty("当前页码")
|
||||
private Integer page = 1;
|
||||
private Integer pageNum;
|
||||
|
||||
@ApiModelProperty("每页大小")
|
||||
private Integer pageSize = 10;
|
||||
private Integer pageSize;
|
||||
|
||||
@ApiModelProperty("排序字段")
|
||||
private String orderBy;
|
||||
|
||||
@ApiModelProperty("排序方向")
|
||||
private String orderDirection = "desc";
|
||||
private String orderDirection;
|
||||
|
||||
@ApiModelProperty("页码")
|
||||
private Integer page;
|
||||
}
|
||||
|
|
|
@ -99,8 +99,9 @@ public class EquipmentReq implements Serializable {
|
|||
@Size(max = 200, message = "供应商名称长度不能超过200个字")
|
||||
private String supplierName;
|
||||
|
||||
@ApiModelProperty("采购价格")
|
||||
private BigDecimal purchasePrice;
|
||||
// 移除采购价格字段,使用单价和总价替代
|
||||
// @ApiModelProperty("采购价格")
|
||||
// private BigDecimal purchasePrice;
|
||||
|
||||
@ApiModelProperty("当前净值")
|
||||
private BigDecimal currentNetValue;
|
||||
|
@ -134,4 +135,102 @@ public class EquipmentReq implements Serializable {
|
|||
@ApiModelProperty("资产备注")
|
||||
@Size(max = 1000, message = "资产备注长度不能超过1000个字")
|
||||
private String assetRemark;
|
||||
|
||||
@ApiModelProperty("次户号")
|
||||
private String accountNumber;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
// 移除备用状态字段,使用现有的 location_status 字段
|
||||
// @ApiModelProperty("备用状态")
|
||||
// private String spareStatus;
|
||||
|
||||
@ApiModelProperty("盘点依据")
|
||||
private String inventoryBasis;
|
||||
|
||||
@ApiModelProperty("动态记录")
|
||||
private String dynamicRecord;
|
||||
|
||||
// 移除认证状态字段,使用现有的 health_status 字段
|
||||
// @ApiModelProperty("认证状态")
|
||||
// private String certificationStatus;
|
||||
|
||||
@ApiModelProperty("使用部门/人")
|
||||
@Size(max = 200, message = "使用部门/人长度不能超过200个字")
|
||||
private String usingDepartment;
|
||||
|
||||
@ApiModelProperty("领用时间")
|
||||
private LocalDateTime borrowingTime;
|
||||
|
||||
@ApiModelProperty("归还时间")
|
||||
private LocalDateTime returnTime;
|
||||
|
||||
@ApiModelProperty("出库时间")
|
||||
private LocalDateTime outStockTime;
|
||||
|
||||
@ApiModelProperty("总使用时间")
|
||||
@Size(max = 100, message = "总使用时间长度不能超过100个字")
|
||||
private String totalUsageTime;
|
||||
|
||||
@ApiModelProperty("折旧率")
|
||||
private BigDecimal depreciationRate;
|
||||
|
||||
@ApiModelProperty("折旧方法说明")
|
||||
@Size(max = 500, message = "折旧方法说明长度不能超过500个字")
|
||||
private String depreciationMethodDesc;
|
||||
|
||||
@ApiModelProperty("发票")
|
||||
@Size(max = 100, message = "发票长度不能超过100个字")
|
||||
private String invoice;
|
||||
|
||||
@ApiModelProperty("发票状态")
|
||||
@Size(max = 50, message = "发票状态长度不能超过50个字")
|
||||
private String invoiceStatus;
|
||||
|
||||
@ApiModelProperty("附件")
|
||||
@Size(max = 500, message = "附件长度不能超过500个字")
|
||||
private String attachments;
|
||||
|
||||
@ApiModelProperty("照片")
|
||||
@Size(max = 500, message = "照片长度不能超过500个字")
|
||||
private String photos;
|
||||
|
||||
@ApiModelProperty("条码")
|
||||
@Size(max = 100, message = "条码长度不能超过100个字")
|
||||
private String barcode;
|
||||
|
||||
@ApiModelProperty("导入人")
|
||||
@Size(max = 100, message = "导入人长度不能超过100个字")
|
||||
private String importer;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态1")
|
||||
@Size(max = 100, message = "盘库时间/状态1长度不能超过100个字")
|
||||
private String inventoryTimeStatus1;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态2")
|
||||
@Size(max = 100, message = "盘库时间/状态2长度不能超过100个字")
|
||||
private String inventoryTimeStatus2;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态3")
|
||||
@Size(max = 100, message = "盘库时间/状态3长度不能超过100个字")
|
||||
private String inventoryTimeStatus3;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态1")
|
||||
@Size(max = 100, message = "盘点时间/状态1长度不能超过100个字")
|
||||
private String inventoryCheckTimeStatus1;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态2")
|
||||
@Size(max = 100, message = "盘点时间/状态2长度不能超过100个字")
|
||||
private String inventoryCheckTimeStatus2;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态3")
|
||||
@Size(max = 100, message = "盘点时间/状态3长度不能超过100个字")
|
||||
private String inventoryCheckTimeStatus3;
|
||||
}
|
||||
|
|
|
@ -98,8 +98,9 @@ public class EquipmentResp implements Serializable {
|
|||
@ApiModelProperty("供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
@ApiModelProperty("采购价格")
|
||||
private BigDecimal purchasePrice;
|
||||
// 移除采购价格字段,使用单价和总价替代
|
||||
// @ApiModelProperty("采购价格")
|
||||
// private BigDecimal purchasePrice;
|
||||
|
||||
@ApiModelProperty("当前净值")
|
||||
private BigDecimal currentNetValue;
|
||||
|
@ -131,6 +132,95 @@ public class EquipmentResp implements Serializable {
|
|||
@ApiModelProperty("资产备注")
|
||||
private String assetRemark;
|
||||
|
||||
@ApiModelProperty("次户号")
|
||||
private String accountNumber;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
// 移除备用状态字段,使用现有的 location_status 字段
|
||||
// @ApiModelProperty("备用状态")
|
||||
// private String spareStatus;
|
||||
|
||||
// @ApiModelProperty("备用状态描述")
|
||||
// private String spareStatusLabel;
|
||||
|
||||
@ApiModelProperty("盘点依据")
|
||||
private String inventoryBasis;
|
||||
|
||||
@ApiModelProperty("动态记录")
|
||||
private String dynamicRecord;
|
||||
|
||||
// 移除认证状态字段,使用现有的 health_status 字段
|
||||
// @ApiModelProperty("认证状态")
|
||||
// private String certificationStatus;
|
||||
|
||||
// @ApiModelProperty("认证状态描述")
|
||||
// private String certificationStatusLabel;
|
||||
|
||||
@ApiModelProperty("使用部门/人")
|
||||
private String usingDepartment;
|
||||
|
||||
@ApiModelProperty("领用时间")
|
||||
private LocalDateTime borrowingTime;
|
||||
|
||||
@ApiModelProperty("归还时间")
|
||||
private LocalDateTime returnTime;
|
||||
|
||||
@ApiModelProperty("出库时间")
|
||||
private LocalDateTime outStockTime;
|
||||
|
||||
@ApiModelProperty("总使用时间")
|
||||
private String totalUsageTime;
|
||||
|
||||
@ApiModelProperty("折旧率")
|
||||
private BigDecimal depreciationRate;
|
||||
|
||||
@ApiModelProperty("折旧方法说明")
|
||||
private String depreciationMethodDesc;
|
||||
|
||||
@ApiModelProperty("发票")
|
||||
private String invoice;
|
||||
|
||||
@ApiModelProperty("发票状态")
|
||||
private String invoiceStatus;
|
||||
|
||||
@ApiModelProperty("附件")
|
||||
private String attachments;
|
||||
|
||||
@ApiModelProperty("照片")
|
||||
private String photos;
|
||||
|
||||
@ApiModelProperty("条码")
|
||||
private String barcode;
|
||||
|
||||
@ApiModelProperty("导入人")
|
||||
private String importer;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态1")
|
||||
private String inventoryTimeStatus1;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态2")
|
||||
private String inventoryTimeStatus2;
|
||||
|
||||
@ApiModelProperty("盘库时间/状态3")
|
||||
private String inventoryTimeStatus3;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态1")
|
||||
private String inventoryCheckTimeStatus1;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态2")
|
||||
private String inventoryCheckTimeStatus2;
|
||||
|
||||
@ApiModelProperty("盘点时间/状态3")
|
||||
private String inventoryCheckTimeStatus3;
|
||||
|
||||
@ApiModelProperty("项目id")
|
||||
private String projectId;
|
||||
|
||||
|
|
|
@ -7,15 +7,69 @@ import com.dite.znpt.domain.vo.EquipmentListReq;
|
|||
import com.dite.znpt.domain.vo.EquipmentReq;
|
||||
import com.dite.znpt.domain.vo.EquipmentResp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设备服务接口
|
||||
* @author Bear.G
|
||||
* @date 2025/7/23/周三 17:39
|
||||
* @description
|
||||
*/
|
||||
public interface EquipmentService extends IService<EquipmentEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询设备信息
|
||||
*/
|
||||
IPage<EquipmentResp> page(EquipmentListReq req);
|
||||
|
||||
/**
|
||||
* 查询设备详情
|
||||
*/
|
||||
EquipmentResp detail(String equipmentId);
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
*/
|
||||
void save(EquipmentReq req);
|
||||
|
||||
/**
|
||||
* 修改设备
|
||||
*/
|
||||
void update(String equipmentId, EquipmentReq req);
|
||||
|
||||
/**
|
||||
* 删除设备
|
||||
*/
|
||||
void deleteById(String equipmentId);
|
||||
|
||||
/**
|
||||
* 批量删除设备
|
||||
*/
|
||||
void batchDelete(List<String> equipmentIds);
|
||||
|
||||
/**
|
||||
* 获取采购统计信息
|
||||
*/
|
||||
Object getProcurementStats();
|
||||
|
||||
/**
|
||||
* 导出采购记录
|
||||
*/
|
||||
byte[] exportProcurement(EquipmentListReq req);
|
||||
|
||||
/**
|
||||
* 分页查询设备采购记录
|
||||
*/
|
||||
IPage<EquipmentResp> procurementPage(EquipmentListReq req);
|
||||
|
||||
/**
|
||||
* 新增设备采购记录
|
||||
*/
|
||||
void saveProcurement(EquipmentReq req);
|
||||
|
||||
/**
|
||||
* 修改设备采购记录
|
||||
*/
|
||||
void updateProcurement(String equipmentId, EquipmentReq req);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.converts.EquipmentConverts;
|
||||
// 移除EquipmentConverts导入,使用手动转换
|
||||
import com.dite.znpt.domain.entity.EquipmentEntity;
|
||||
import com.dite.znpt.domain.vo.EquipmentListReq;
|
||||
import com.dite.znpt.domain.vo.EquipmentReq;
|
||||
|
@ -22,8 +22,11 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -38,12 +41,14 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
public IPage<EquipmentResp> page(EquipmentListReq req) {
|
||||
log.info("开始执行设备分页查询,请求参数: {}", req);
|
||||
|
||||
// 创建分页对象
|
||||
Page<EquipmentEntity> page = new Page<>(req.getPage(), req.getPageSize());
|
||||
// 创建分页对象,处理null值
|
||||
Integer pageNum = req.getPage() != null ? req.getPage() : (req.getPageNum() != null ? req.getPageNum() : 1);
|
||||
Integer pageSize = req.getPageSize() != null ? req.getPageSize() : 10;
|
||||
Page<EquipmentEntity> page = new Page<>(pageNum, pageSize);
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<EquipmentEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(EquipmentEntity::getDelFlag, "0");
|
||||
// 不需要手动添加 del_flag 条件,@TableLogic 注解会自动处理
|
||||
|
||||
// 添加搜索条件并记录日志
|
||||
int conditionCount = 0;
|
||||
|
@ -136,6 +141,60 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
conditionCount++;
|
||||
}
|
||||
|
||||
// 新增字段查询条件
|
||||
if (StringUtils.hasText(req.getUsingDepartment())) {
|
||||
queryWrapper.like(EquipmentEntity::getUsingDepartment, req.getUsingDepartment());
|
||||
log.info("添加使用部门/人查询条件: {}", req.getUsingDepartment());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getInvoice())) {
|
||||
queryWrapper.like(EquipmentEntity::getInvoice, req.getInvoice());
|
||||
log.info("添加发票查询条件: {}", req.getInvoice());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getBarcode())) {
|
||||
queryWrapper.like(EquipmentEntity::getBarcode, req.getBarcode());
|
||||
log.info("添加条码查询条件: {}", req.getBarcode());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getImporter())) {
|
||||
queryWrapper.like(EquipmentEntity::getImporter, req.getImporter());
|
||||
log.info("添加导入人查询条件: {}", req.getImporter());
|
||||
conditionCount++;
|
||||
}
|
||||
|
||||
// 新增采购相关字段查询条件
|
||||
if (StringUtils.hasText(req.getAccountNumber())) {
|
||||
queryWrapper.like(EquipmentEntity::getAccountNumber, req.getAccountNumber());
|
||||
log.info("添加次户号查询条件: {}", req.getAccountNumber());
|
||||
conditionCount++;
|
||||
}
|
||||
if (req.getQuantity() != null) {
|
||||
queryWrapper.eq(EquipmentEntity::getQuantity, req.getQuantity());
|
||||
log.info("添加数量查询条件: {}", req.getQuantity());
|
||||
conditionCount++;
|
||||
}
|
||||
if (req.getUnitPrice() != null) {
|
||||
queryWrapper.eq(EquipmentEntity::getUnitPrice, req.getUnitPrice());
|
||||
log.info("添加单价查询条件: {}", req.getUnitPrice());
|
||||
conditionCount++;
|
||||
}
|
||||
if (req.getTotalPrice() != null) {
|
||||
queryWrapper.eq(EquipmentEntity::getTotalPrice, req.getTotalPrice());
|
||||
log.info("添加总价查询条件: {}", req.getTotalPrice());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getInventoryBasis())) {
|
||||
queryWrapper.like(EquipmentEntity::getInventoryBasis, req.getInventoryBasis());
|
||||
log.info("添加盘点依据查询条件: {}", req.getInventoryBasis());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getDynamicRecord())) {
|
||||
queryWrapper.like(EquipmentEntity::getDynamicRecord, req.getDynamicRecord());
|
||||
log.info("添加动态记录查询条件: {}", req.getDynamicRecord());
|
||||
conditionCount++;
|
||||
}
|
||||
|
||||
// 时间范围查询
|
||||
if (req.getPurchaseTimeStart() != null) {
|
||||
queryWrapper.ge(EquipmentEntity::getPurchaseTime, req.getPurchaseTimeStart());
|
||||
|
@ -278,9 +337,9 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
break;
|
||||
case "purchase_price":
|
||||
if ("desc".equals(orderDirection)) {
|
||||
queryWrapper.orderByDesc(EquipmentEntity::getPurchasePrice);
|
||||
queryWrapper.orderByDesc(EquipmentEntity::getTotalPrice);
|
||||
} else {
|
||||
queryWrapper.orderByAsc(EquipmentEntity::getPurchasePrice);
|
||||
queryWrapper.orderByAsc(EquipmentEntity::getTotalPrice);
|
||||
}
|
||||
break;
|
||||
case "update_time":
|
||||
|
@ -333,7 +392,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(EquipmentReq req) {
|
||||
EquipmentEntity entity = EquipmentConverts.INSTANCE.toEquipmentEntity(req);
|
||||
EquipmentEntity entity = convertToEntity(req);
|
||||
if (getByEquipmentSn(entity.getEquipmentSn()) != null) {
|
||||
throw new ServiceException(Message.EQUIPMENT_SN_EXIST);
|
||||
}
|
||||
|
@ -356,7 +415,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
if (!equipment.getEquipmentSn().equals(req.getEquipmentSn()) && getByEquipmentSn(req.getEquipmentSn()) != null) {
|
||||
throw new ServiceException(Message.EQUIPMENT_SN_EXIST);
|
||||
}
|
||||
EquipmentEntity entity = EquipmentConverts.INSTANCE.toEquipmentEntity(req);
|
||||
EquipmentEntity entity = convertToEntity(req);
|
||||
entity.setEquipmentId(equipmentId);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
@ -371,6 +430,91 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
this.removeById(equipmentId);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void batchDelete(List<String> equipmentIds) {
|
||||
if (equipmentIds == null || equipmentIds.isEmpty()) {
|
||||
throw new ServiceException("设备ID列表不能为空");
|
||||
}
|
||||
this.removeByIds(equipmentIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] exportProcurement(EquipmentListReq req) {
|
||||
// 这里可以实现导出功能,返回Excel文件的字节数组
|
||||
// 暂时返回空数组,实际项目中需要实现具体的导出逻辑
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 将EquipmentReq转换为EquipmentEntity
|
||||
*/
|
||||
private EquipmentEntity convertToEntity(EquipmentReq req) {
|
||||
EquipmentEntity entity = new EquipmentEntity();
|
||||
entity.setAssetCode(req.getAssetCode());
|
||||
entity.setEquipmentName(req.getEquipmentName());
|
||||
entity.setEquipmentModel(req.getEquipmentModel());
|
||||
entity.setEquipmentType(req.getEquipmentType());
|
||||
entity.setEquipmentStatus(req.getEquipmentStatus());
|
||||
entity.setUseStatus(req.getUseStatus());
|
||||
entity.setEquipmentSn(req.getEquipmentSn());
|
||||
entity.setBrand(req.getBrand());
|
||||
entity.setSpecification(req.getSpecification());
|
||||
entity.setLocationStatus(req.getLocationStatus());
|
||||
entity.setPhysicalLocation(req.getPhysicalLocation());
|
||||
entity.setResponsiblePerson(req.getResponsiblePerson());
|
||||
entity.setHealthStatus(req.getHealthStatus());
|
||||
entity.setPurchaseTime(req.getPurchaseTime());
|
||||
entity.setInStockTime(req.getInStockTime());
|
||||
entity.setActivationTime(req.getActivationTime());
|
||||
entity.setExpectedScrapTime(req.getExpectedScrapTime());
|
||||
entity.setActualScrapTime(req.getActualScrapTime());
|
||||
entity.setStatusChangeTime(req.getStatusChangeTime());
|
||||
entity.setPurchaseOrder(req.getPurchaseOrder());
|
||||
entity.setSupplierName(req.getSupplierName());
|
||||
entity.setCurrentNetValue(req.getCurrentNetValue());
|
||||
entity.setDepreciationMethod(req.getDepreciationMethod());
|
||||
entity.setDepreciationYears(req.getDepreciationYears());
|
||||
entity.setSalvageValue(req.getSalvageValue());
|
||||
entity.setWarrantyExpireDate(req.getWarrantyExpireDate());
|
||||
entity.setLastMaintenanceDate(req.getLastMaintenanceDate());
|
||||
entity.setNextMaintenanceDate(req.getNextMaintenanceDate());
|
||||
entity.setMaintenancePerson(req.getMaintenancePerson());
|
||||
entity.setInventoryBarcode(req.getInventoryBarcode());
|
||||
entity.setAssetRemark(req.getAssetRemark());
|
||||
|
||||
// 新增采购相关字段
|
||||
entity.setAccountNumber(req.getAccountNumber());
|
||||
entity.setQuantity(req.getQuantity());
|
||||
entity.setUnitPrice(req.getUnitPrice());
|
||||
entity.setTotalPrice(req.getTotalPrice());
|
||||
entity.setInventoryBasis(req.getInventoryBasis());
|
||||
entity.setDynamicRecord(req.getDynamicRecord());
|
||||
|
||||
// 新增字段转换
|
||||
entity.setUsingDepartment(req.getUsingDepartment());
|
||||
entity.setBorrowingTime(req.getBorrowingTime());
|
||||
entity.setReturnTime(req.getReturnTime());
|
||||
entity.setOutStockTime(req.getOutStockTime());
|
||||
entity.setTotalUsageTime(req.getTotalUsageTime());
|
||||
entity.setDepreciationRate(req.getDepreciationRate());
|
||||
entity.setDepreciationMethodDesc(req.getDepreciationMethodDesc());
|
||||
entity.setInvoice(req.getInvoice());
|
||||
entity.setInvoiceStatus(req.getInvoiceStatus());
|
||||
entity.setAttachments(req.getAttachments());
|
||||
entity.setPhotos(req.getPhotos());
|
||||
entity.setBarcode(req.getBarcode());
|
||||
entity.setImporter(req.getImporter());
|
||||
entity.setInventoryTimeStatus1(req.getInventoryTimeStatus1());
|
||||
entity.setInventoryTimeStatus2(req.getInventoryTimeStatus2());
|
||||
entity.setInventoryTimeStatus3(req.getInventoryTimeStatus3());
|
||||
entity.setInventoryCheckTimeStatus1(req.getInventoryCheckTimeStatus1());
|
||||
entity.setInventoryCheckTimeStatus2(req.getInventoryCheckTimeStatus2());
|
||||
entity.setInventoryCheckTimeStatus3(req.getInventoryCheckTimeStatus3());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为响应对象
|
||||
*/
|
||||
|
@ -402,7 +546,6 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
resp.setStatusChangeTime(entity.getStatusChangeTime());
|
||||
resp.setPurchaseOrder(entity.getPurchaseOrder());
|
||||
resp.setSupplierName(entity.getSupplierName());
|
||||
resp.setPurchasePrice(entity.getPurchasePrice());
|
||||
resp.setCurrentNetValue(entity.getCurrentNetValue());
|
||||
resp.setDepreciationMethod(entity.getDepreciationMethod());
|
||||
resp.setDepreciationYears(entity.getDepreciationYears());
|
||||
|
@ -413,9 +556,261 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
resp.setMaintenancePerson(entity.getMaintenancePerson());
|
||||
resp.setInventoryBarcode(entity.getInventoryBarcode());
|
||||
resp.setAssetRemark(entity.getAssetRemark());
|
||||
|
||||
// 新增采购相关字段
|
||||
resp.setAccountNumber(entity.getAccountNumber());
|
||||
resp.setQuantity(entity.getQuantity());
|
||||
resp.setUnitPrice(entity.getUnitPrice());
|
||||
resp.setTotalPrice(entity.getTotalPrice());
|
||||
resp.setInventoryBasis(entity.getInventoryBasis());
|
||||
resp.setDynamicRecord(entity.getDynamicRecord());
|
||||
|
||||
// 新增字段转换
|
||||
resp.setUsingDepartment(entity.getUsingDepartment());
|
||||
resp.setBorrowingTime(entity.getBorrowingTime());
|
||||
resp.setReturnTime(entity.getReturnTime());
|
||||
resp.setOutStockTime(entity.getOutStockTime());
|
||||
resp.setTotalUsageTime(entity.getTotalUsageTime());
|
||||
resp.setDepreciationRate(entity.getDepreciationRate());
|
||||
resp.setDepreciationMethodDesc(entity.getDepreciationMethodDesc());
|
||||
resp.setInvoice(entity.getInvoice());
|
||||
resp.setInvoiceStatus(entity.getInvoiceStatus());
|
||||
resp.setAttachments(entity.getAttachments());
|
||||
resp.setPhotos(entity.getPhotos());
|
||||
resp.setBarcode(entity.getBarcode());
|
||||
resp.setImporter(entity.getImporter());
|
||||
resp.setInventoryTimeStatus1(entity.getInventoryTimeStatus1());
|
||||
resp.setInventoryTimeStatus2(entity.getInventoryTimeStatus2());
|
||||
resp.setInventoryTimeStatus3(entity.getInventoryTimeStatus3());
|
||||
resp.setInventoryCheckTimeStatus1(entity.getInventoryCheckTimeStatus1());
|
||||
resp.setInventoryCheckTimeStatus2(entity.getInventoryCheckTimeStatus2());
|
||||
resp.setInventoryCheckTimeStatus3(entity.getInventoryCheckTimeStatus3());
|
||||
|
||||
resp.setCreateTime(entity.getCreateTime());
|
||||
resp.setUpdateTime(entity.getUpdateTime());
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
// 采购管理相关方法实现
|
||||
@Override
|
||||
public IPage<EquipmentResp> procurementPage(EquipmentListReq req) {
|
||||
log.info("开始执行设备采购记录分页查询,请求参数: {}", req);
|
||||
|
||||
// 创建分页对象,处理null值
|
||||
Integer pageNum = req.getPage() != null ? req.getPage() : (req.getPageNum() != null ? req.getPageNum() : 1);
|
||||
Integer pageSize = req.getPageSize() != null ? req.getPageSize() : 10;
|
||||
Page<EquipmentEntity> page = new Page<>(pageNum, pageSize);
|
||||
|
||||
// 构建查询条件,参考设备分页查询的逻辑
|
||||
LambdaQueryWrapper<EquipmentEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// 不需要手动添加 del_flag 条件,@TableLogic 注解会自动处理
|
||||
|
||||
// 添加搜索条件并记录日志
|
||||
int conditionCount = 0;
|
||||
|
||||
if (StringUtils.hasText(req.getEquipmentName())) {
|
||||
queryWrapper.like(EquipmentEntity::getEquipmentName, req.getEquipmentName());
|
||||
log.info("添加设备名称查询条件: {}", req.getEquipmentName());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getEquipmentType())) {
|
||||
queryWrapper.eq(EquipmentEntity::getEquipmentType, req.getEquipmentType());
|
||||
log.info("添加设备类型查询条件: {}", req.getEquipmentType());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getEquipmentStatus())) {
|
||||
queryWrapper.eq(EquipmentEntity::getEquipmentStatus, req.getEquipmentStatus());
|
||||
log.info("添加设备状态查询条件: {}", req.getEquipmentStatus());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getEquipmentSn())) {
|
||||
queryWrapper.like(EquipmentEntity::getEquipmentSn, req.getEquipmentSn());
|
||||
log.info("添加设备序列号查询条件: {}", req.getEquipmentSn());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getAssetCode())) {
|
||||
queryWrapper.like(EquipmentEntity::getAssetCode, req.getAssetCode());
|
||||
log.info("添加资产编号查询条件: {}", req.getAssetCode());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getBrand())) {
|
||||
queryWrapper.like(EquipmentEntity::getBrand, req.getBrand());
|
||||
log.info("添加品牌查询条件: {}", req.getBrand());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getLocationStatus())) {
|
||||
queryWrapper.eq(EquipmentEntity::getLocationStatus, req.getLocationStatus());
|
||||
log.info("添加位置状态查询条件: {}", req.getLocationStatus());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getHealthStatus())) {
|
||||
queryWrapper.eq(EquipmentEntity::getHealthStatus, req.getHealthStatus());
|
||||
log.info("添加健康状态查询条件: {}", req.getHealthStatus());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getResponsiblePerson())) {
|
||||
queryWrapper.like(EquipmentEntity::getResponsiblePerson, req.getResponsiblePerson());
|
||||
log.info("添加负责人查询条件: {}", req.getResponsiblePerson());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getPhysicalLocation())) {
|
||||
queryWrapper.like(EquipmentEntity::getPhysicalLocation, req.getPhysicalLocation());
|
||||
log.info("添加物理位置查询条件: {}", req.getPhysicalLocation());
|
||||
conditionCount++;
|
||||
}
|
||||
|
||||
// 添加采购相关的搜索条件
|
||||
if (StringUtils.hasText(req.getPurchaseOrder())) {
|
||||
queryWrapper.like(EquipmentEntity::getPurchaseOrder, req.getPurchaseOrder());
|
||||
log.info("添加采购订单查询条件: {}", req.getPurchaseOrder());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getSupplierName())) {
|
||||
queryWrapper.like(EquipmentEntity::getSupplierName, req.getSupplierName());
|
||||
log.info("添加供应商查询条件: {}", req.getSupplierName());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getAccountNumber())) {
|
||||
queryWrapper.like(EquipmentEntity::getAccountNumber, req.getAccountNumber());
|
||||
log.info("添加次户号查询条件: {}", req.getAccountNumber());
|
||||
conditionCount++;
|
||||
}
|
||||
if (req.getQuantity() != null) {
|
||||
queryWrapper.eq(EquipmentEntity::getQuantity, req.getQuantity());
|
||||
log.info("添加数量查询条件: {}", req.getQuantity());
|
||||
conditionCount++;
|
||||
}
|
||||
if (req.getUnitPrice() != null) {
|
||||
queryWrapper.eq(EquipmentEntity::getUnitPrice, req.getUnitPrice());
|
||||
log.info("添加单价查询条件: {}", req.getUnitPrice());
|
||||
conditionCount++;
|
||||
}
|
||||
if (req.getTotalPrice() != null) {
|
||||
queryWrapper.eq(EquipmentEntity::getTotalPrice, req.getTotalPrice());
|
||||
log.info("添加总价查询条件: {}", req.getTotalPrice());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getInventoryBasis())) {
|
||||
queryWrapper.like(EquipmentEntity::getInventoryBasis, req.getInventoryBasis());
|
||||
log.info("添加盘点依据查询条件: {}", req.getInventoryBasis());
|
||||
conditionCount++;
|
||||
}
|
||||
if (StringUtils.hasText(req.getDynamicRecord())) {
|
||||
queryWrapper.like(EquipmentEntity::getDynamicRecord, req.getDynamicRecord());
|
||||
log.info("添加动态记录查询条件: {}", req.getDynamicRecord());
|
||||
conditionCount++;
|
||||
}
|
||||
|
||||
log.info("总共添加了 {} 个查询条件", conditionCount);
|
||||
|
||||
// 按采购时间倒序排列
|
||||
queryWrapper.orderByDesc(EquipmentEntity::getPurchaseTime);
|
||||
|
||||
// 执行查询
|
||||
IPage<EquipmentEntity> result = this.page(page, queryWrapper);
|
||||
|
||||
// 转换为响应对象
|
||||
List<EquipmentResp> records = result.getRecords().stream()
|
||||
.map(this::convertToResp)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 创建新的分页结果
|
||||
Page<EquipmentResp> respPage = new Page<>(result.getCurrent(), result.getSize(), result.getTotal());
|
||||
respPage.setRecords(records);
|
||||
|
||||
log.info("设备采购记录分页查询完成,总记录数: {}", result.getTotal());
|
||||
return respPage;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void saveProcurement(EquipmentReq req) {
|
||||
log.info("开始新增设备采购记录,请求参数: {}", req);
|
||||
|
||||
// 验证采购订单号唯一性
|
||||
if (StringUtils.hasText(req.getPurchaseOrder())) {
|
||||
LambdaQueryWrapper<EquipmentEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(EquipmentEntity::getPurchaseOrder, req.getPurchaseOrder());
|
||||
long count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new ServiceException("采购订单号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 设置采购相关的时间字段
|
||||
if (req.getPurchaseTime() == null) {
|
||||
req.setPurchaseTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
// 转换为实体并保存
|
||||
EquipmentEntity entity = convertToEntity(req);
|
||||
this.save(entity);
|
||||
|
||||
log.info("设备采购记录新增成功,设备ID: {}", entity.getEquipmentId());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateProcurement(String equipmentId, EquipmentReq req) {
|
||||
log.info("开始修改设备采购记录,设备ID: {}, 请求参数: {}", equipmentId, req);
|
||||
|
||||
// 检查设备是否存在
|
||||
EquipmentEntity existingEntity = this.getById(equipmentId);
|
||||
if (existingEntity == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
|
||||
// 验证采购订单号唯一性(排除当前设备)
|
||||
if (StringUtils.hasText(req.getPurchaseOrder())) {
|
||||
LambdaQueryWrapper<EquipmentEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(EquipmentEntity::getPurchaseOrder, req.getPurchaseOrder())
|
||||
.ne(EquipmentEntity::getEquipmentId, equipmentId);
|
||||
long count = this.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new ServiceException("采购订单号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为实体并更新
|
||||
EquipmentEntity entity = convertToEntity(req);
|
||||
entity.setEquipmentId(equipmentId);
|
||||
this.updateById(entity);
|
||||
|
||||
log.info("设备采购记录修改成功,设备ID: {}", equipmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProcurementStats() {
|
||||
log.info("开始获取采购统计信息");
|
||||
|
||||
// 统计采购总金额
|
||||
LambdaQueryWrapper<EquipmentEntity> priceWrapper = new LambdaQueryWrapper<>();
|
||||
priceWrapper.isNotNull(EquipmentEntity::getTotalPrice);
|
||||
List<EquipmentEntity> priceEntities = this.list(priceWrapper);
|
||||
double totalAmount = priceEntities.stream()
|
||||
.mapToDouble(entity -> entity.getTotalPrice() != null ? entity.getTotalPrice().doubleValue() : 0)
|
||||
.sum();
|
||||
|
||||
// 统计供应商数量
|
||||
LambdaQueryWrapper<EquipmentEntity> supplierWrapper = new LambdaQueryWrapper<>();
|
||||
supplierWrapper.isNotNull(EquipmentEntity::getSupplierName)
|
||||
.groupBy(EquipmentEntity::getSupplierName);
|
||||
long supplierCount = this.count(supplierWrapper);
|
||||
|
||||
// 统计采购设备数量
|
||||
LambdaQueryWrapper<EquipmentEntity> equipmentWrapper = new LambdaQueryWrapper<>();
|
||||
equipmentWrapper.isNotNull(EquipmentEntity::getPurchaseOrder);
|
||||
long equipmentCount = this.count(equipmentWrapper);
|
||||
|
||||
// 构建统计结果
|
||||
java.util.Map<String, Object> stats = new java.util.HashMap<>();
|
||||
stats.put("totalAmount", totalAmount);
|
||||
stats.put("supplierCount", supplierCount);
|
||||
stats.put("equipmentCount", equipmentCount);
|
||||
stats.put("averageAmount", equipmentCount > 0 ? totalAmount / equipmentCount : 0);
|
||||
|
||||
log.info("采购统计信息获取完成,总金额: {}, 供应商数: {}, 设备数: {}", totalAmount, supplierCount, equipmentCount);
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,6 +10,7 @@
|
|||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>core</module>
|
||||
<module>web</module>
|
||||
|
@ -50,4 +51,5 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -24,6 +26,8 @@ import javax.annotation.Resource;
|
|||
@RequestMapping("/equipment")
|
||||
public class EquipmentController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EquipmentController.class);
|
||||
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
|
||||
|
@ -60,4 +64,48 @@ public class EquipmentController {
|
|||
equipmentService.deleteById(equipmentId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询设备采购记录", httpMethod = "GET")
|
||||
@GetMapping("/procurement/page")
|
||||
public PageResult<EquipmentResp> procurementPage(EquipmentListReq req) {
|
||||
log.info("=== 设备采购记录查询接口被调用 ===");
|
||||
log.info("接收到的请求参数: {}", req);
|
||||
log.info("设备名称: {}", req.getEquipmentName());
|
||||
log.info("设备类型: {}", req.getEquipmentType());
|
||||
log.info("供应商名称: {}", req.getSupplierName());
|
||||
log.info("采购订单号: {}", req.getPurchaseOrder());
|
||||
log.info("次户号: {}", req.getAccountNumber());
|
||||
log.info("数量: {}", req.getQuantity());
|
||||
log.info("单价: {}", req.getUnitPrice());
|
||||
log.info("总价: {}", req.getTotalPrice());
|
||||
log.info("盘点依据: {}", req.getInventoryBasis());
|
||||
log.info("动态记录: {}", req.getDynamicRecord());
|
||||
log.info("页码: {}", req.getPage());
|
||||
log.info("每页大小: {}", req.getPageSize());
|
||||
log.info("排序字段: {}", req.getOrderBy());
|
||||
log.info("排序方向: {}", req.getOrderDirection());
|
||||
|
||||
IPage<EquipmentResp> page = equipmentService.procurementPage(req);
|
||||
return PageResult.ok(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增设备采购记录", httpMethod = "POST")
|
||||
@PostMapping("/procurement")
|
||||
public Result<?> addProcurement(@Validated @RequestBody EquipmentReq req){
|
||||
equipmentService.saveProcurement(req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改设备采购记录", httpMethod = "PUT")
|
||||
@PutMapping("/procurement/{equipmentId}")
|
||||
public Result<?> editProcurement(@PathVariable String equipmentId, @Validated @RequestBody EquipmentReq req){
|
||||
equipmentService.updateProcurement(equipmentId, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取采购统计信息", httpMethod = "GET")
|
||||
@GetMapping("/procurement/stats")
|
||||
public Result<?> getProcurementStats(){
|
||||
return Result.ok(equipmentService.getProcurementStats());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue