实现设备中心模块手动新增设备
This commit is contained in:
parent
023455be47
commit
8fe29807a8
|
@ -0,0 +1,24 @@
|
|||
package com.dite.znpt.converts;
|
||||
|
||||
import com.dite.znpt.domain.entity.EquipmentEntity;
|
||||
import com.dite.znpt.domain.vo.EquipmentReq;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.NullValuePropertyMappingStrategy;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 设备信息转换器
|
||||
* @author Bear.G
|
||||
* @date 2025/1/1
|
||||
*/
|
||||
@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
|
||||
public interface EquipmentConverts {
|
||||
EquipmentConverts INSTANCE = Mappers.getMapper(EquipmentConverts.class);
|
||||
|
||||
/**
|
||||
* 将EquipmentReq转换为EquipmentEntity
|
||||
* @param req 设备请求对象
|
||||
* @return 设备实体对象
|
||||
*/
|
||||
EquipmentEntity toEquipmentEntity(EquipmentReq req);
|
||||
}
|
|
@ -8,6 +8,8 @@ import javax.validation.constraints.NotBlank;
|
|||
import javax.validation.constraints.Size;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -22,7 +24,7 @@ public class EquipmentReq implements Serializable {
|
|||
|
||||
@ApiModelProperty("设备名称")
|
||||
@NotBlank(message = "设备名称不能为空")
|
||||
@Size(max = 100, message = "设备名称长度不能超过100个字")
|
||||
@Size(max = 200, message = "设备名称长度不能超过200个字")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty("设备类型, 枚举:EquipmentTypeEnum")
|
||||
|
@ -31,11 +33,105 @@ public class EquipmentReq implements Serializable {
|
|||
|
||||
@ApiModelProperty("设备型号")
|
||||
@NotBlank(message = "设备型号不能为空")
|
||||
@Size(max = 50, message = "设备型号长度不能超过50个字")
|
||||
@Size(max = 200, message = "设备型号长度不能超过200个字")
|
||||
private String equipmentModel;
|
||||
|
||||
@ApiModelProperty("设备SN")
|
||||
@NotBlank(message = "设备SN不能为空")
|
||||
@Size(max = 50, message = "设备SN长度不能超过50个字")
|
||||
@Size(max = 100, message = "设备SN长度不能超过100个字")
|
||||
private String equipmentSn;
|
||||
|
||||
@ApiModelProperty("资产编号")
|
||||
@Size(max = 50, message = "资产编号长度不能超过50个字")
|
||||
private String assetCode;
|
||||
|
||||
@ApiModelProperty("品牌")
|
||||
@Size(max = 100, message = "品牌长度不能超过100个字")
|
||||
private String brand;
|
||||
|
||||
@ApiModelProperty("配置规格/参数")
|
||||
@Size(max = 500, message = "配置规格长度不能超过500个字")
|
||||
private String specification;
|
||||
|
||||
@ApiModelProperty("设备状态,枚举:EquipmentStatusEnum")
|
||||
private String equipmentStatus;
|
||||
|
||||
@ApiModelProperty("使用状态,0-空闲中,1-使用中")
|
||||
private String useStatus;
|
||||
|
||||
@ApiModelProperty("位置状态")
|
||||
private String locationStatus;
|
||||
|
||||
@ApiModelProperty("设备当前物理位置")
|
||||
@Size(max = 200, message = "物理位置长度不能超过200个字")
|
||||
private String physicalLocation;
|
||||
|
||||
@ApiModelProperty("负责人")
|
||||
@Size(max = 100, message = "负责人长度不能超过100个字")
|
||||
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("采购订单")
|
||||
@Size(max = 100, message = "采购订单长度不能超过100个字")
|
||||
private String purchaseOrder;
|
||||
|
||||
@ApiModelProperty("供应商名称")
|
||||
@Size(max = 200, message = "供应商名称长度不能超过200个字")
|
||||
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("维护人员")
|
||||
@Size(max = 100, message = "维护人员长度不能超过100个字")
|
||||
private String maintenancePerson;
|
||||
|
||||
@ApiModelProperty("库存条码")
|
||||
@Size(max = 100, message = "库存条码长度不能超过100个字")
|
||||
private String inventoryBarcode;
|
||||
|
||||
@ApiModelProperty("资产备注")
|
||||
@Size(max = 1000, message = "资产备注长度不能超过1000个字")
|
||||
private String assetRemark;
|
||||
}
|
||||
|
|
|
@ -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.Converts;
|
||||
import com.dite.znpt.converts.EquipmentConverts;
|
||||
import com.dite.znpt.domain.entity.EquipmentEntity;
|
||||
import com.dite.znpt.domain.vo.EquipmentListReq;
|
||||
import com.dite.znpt.domain.vo.EquipmentReq;
|
||||
|
@ -333,7 +333,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(EquipmentReq req) {
|
||||
EquipmentEntity entity = Converts.INSTANCE.toEquipmentUseRecordEntity(req);
|
||||
EquipmentEntity entity = EquipmentConverts.INSTANCE.toEquipmentEntity(req);
|
||||
if (getByEquipmentSn(entity.getEquipmentSn()) != null) {
|
||||
throw new ServiceException(Message.EQUIPMENT_SN_EXIST);
|
||||
}
|
||||
|
@ -356,7 +356,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 = Converts.INSTANCE.toEquipmentUseRecordEntity(req);
|
||||
EquipmentEntity entity = EquipmentConverts.INSTANCE.toEquipmentEntity(req);
|
||||
entity.setEquipmentId(equipmentId);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue