development #3
|
@ -180,6 +180,12 @@ public class EquipmentEntity extends AuditableEntity implements Serializable {
|
||||||
@ApiModelProperty("采购状态,NOT_STARTED-未开始,PENDING_APPROVAL-待审批,APPROVED-已通过,REJECTED-已拒绝,COMPLETED-已完成")
|
@ApiModelProperty("采购状态,NOT_STARTED-未开始,PENDING_APPROVAL-待审批,APPROVED-已通过,REJECTED-已拒绝,COMPLETED-已完成")
|
||||||
private String procurementStatus;
|
private String procurementStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("收货状态,NOT_RECEIVED-未收货,PARTIALLY_RECEIVED-部分收货,RECEIVED-已收货")
|
||||||
|
private String receiptStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("支付状态,NOT_PAID-未支付,PARTIALLY_PAID-部分支付,PAID-已支付")
|
||||||
|
private String paymentStatus;
|
||||||
|
|
||||||
@ApiModelProperty("附件")
|
@ApiModelProperty("附件")
|
||||||
private String attachments;
|
private String attachments;
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,15 @@ public class EquipmentResp implements Serializable {
|
||||||
@ApiModelProperty("采购状态,NOT_STARTED-未开始,PENDING_APPROVAL-待审批,APPROVED-已通过,REJECTED-已拒绝,COMPLETED-已完成")
|
@ApiModelProperty("采购状态,NOT_STARTED-未开始,PENDING_APPROVAL-待审批,APPROVED-已通过,REJECTED-已拒绝,COMPLETED-已完成")
|
||||||
private String procurementStatus;
|
private String procurementStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("收货状态,NOT_RECEIVED-未收货,PARTIALLY_RECEIVED-部分收货,RECEIVED-已收货")
|
||||||
|
private String receiptStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("支付状态,NOT_PAID-未支付,PARTIALLY_PAID-部分支付,PAID-已支付")
|
||||||
|
private String paymentStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("审批状态,PENDING-待审批,APPROVED-已通过,REJECTED-已拒绝")
|
||||||
|
private String approvalStatus;
|
||||||
|
|
||||||
// 移除备用状态字段,使用现有的 location_status 字段
|
// 移除备用状态字段,使用现有的 location_status 字段
|
||||||
// @ApiModelProperty("备用状态")
|
// @ApiModelProperty("备用状态")
|
||||||
// private String spareStatus;
|
// private String spareStatus;
|
||||||
|
|
|
@ -18,6 +18,12 @@ import java.math.BigDecimal;
|
||||||
@ApiModel(value = "收货请求参数", description = "收货请求参数,包含收货信息和设备信息")
|
@ApiModel(value = "收货请求参数", description = "收货请求参数,包含收货信息和设备信息")
|
||||||
public class ReceiptRequest {
|
public class ReceiptRequest {
|
||||||
|
|
||||||
|
@ApiModelProperty("设备序列号(收货时自动生成)")
|
||||||
|
private String equipmentSn;
|
||||||
|
|
||||||
|
@ApiModelProperty("库存条码(收货时自动生成)")
|
||||||
|
private String inventoryBarcode;
|
||||||
|
|
||||||
// 收货特有信息
|
// 收货特有信息
|
||||||
@NotBlank(message = "收货时间不能为空")
|
@NotBlank(message = "收货时间不能为空")
|
||||||
@ApiModelProperty("收货时间")
|
@ApiModelProperty("收货时间")
|
||||||
|
@ -75,9 +81,6 @@ public class ReceiptRequest {
|
||||||
@ApiModelProperty("设备类型")
|
@ApiModelProperty("设备类型")
|
||||||
private String equipmentType;
|
private String equipmentType;
|
||||||
|
|
||||||
@ApiModelProperty("设备序列号")
|
|
||||||
private String equipmentSn;
|
|
||||||
|
|
||||||
@ApiModelProperty("品牌")
|
@ApiModelProperty("品牌")
|
||||||
private String brand;
|
private String brand;
|
||||||
|
|
||||||
|
@ -122,9 +125,6 @@ public class ReceiptRequest {
|
||||||
@ApiModelProperty("负责人")
|
@ApiModelProperty("负责人")
|
||||||
private String responsiblePerson;
|
private String responsiblePerson;
|
||||||
|
|
||||||
@ApiModelProperty("库存条码")
|
|
||||||
private String inventoryBarcode;
|
|
||||||
|
|
||||||
// 状态信息
|
// 状态信息
|
||||||
@ApiModelProperty("设备状态")
|
@ApiModelProperty("设备状态")
|
||||||
private String equipmentStatus;
|
private String equipmentStatus;
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.dite.znpt.enums;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付状态枚举
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2025-01-08
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum PaymentStatusEnum {
|
||||||
|
NOT_PAID("NOT_PAID", "未支付"),
|
||||||
|
PARTIALLY_PAID("PARTIALLY_PAID", "部分支付"),
|
||||||
|
PAID("PAID", "已支付");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
PaymentStatusEnum(String code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PaymentStatusEnum getByCode(String code) {
|
||||||
|
for (PaymentStatusEnum e : PaymentStatusEnum.values()) {
|
||||||
|
if (e.code.equals(code)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescByCode(String code) {
|
||||||
|
PaymentStatusEnum e = getByCode(code);
|
||||||
|
return null == e ? null : e.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JSONObject> listAll() {
|
||||||
|
List<JSONObject> list = new ArrayList<>(PaymentStatusEnum.values().length);
|
||||||
|
for (PaymentStatusEnum e : PaymentStatusEnum.values()) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.set(e.code, e.desc);
|
||||||
|
list.add(jsonObject);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.dite.znpt.enums;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货状态枚举
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
* @date 2025-01-08
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum ReceiptStatusEnum {
|
||||||
|
NOT_RECEIVED("NOT_RECEIVED", "未收货"),
|
||||||
|
PARTIALLY_RECEIVED("PARTIALLY_RECEIVED", "部分收货"),
|
||||||
|
RECEIVED("RECEIVED", "已收货");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
ReceiptStatusEnum(String code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReceiptStatusEnum getByCode(String code) {
|
||||||
|
for (ReceiptStatusEnum e : ReceiptStatusEnum.values()) {
|
||||||
|
if (e.code.equals(code)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescByCode(String code) {
|
||||||
|
ReceiptStatusEnum e = getByCode(code);
|
||||||
|
return null == e ? null : e.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<JSONObject> listAll() {
|
||||||
|
List<JSONObject> list = new ArrayList<>(ReceiptStatusEnum.values().length);
|
||||||
|
for (ReceiptStatusEnum e : ReceiptStatusEnum.values()) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.set(e.code, e.desc);
|
||||||
|
list.add(jsonObject);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -478,6 +478,15 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||||
// 设置采购状态字段
|
// 设置采购状态字段
|
||||||
resp.setProcurementStatus(entity.getProcurementStatus());
|
resp.setProcurementStatus(entity.getProcurementStatus());
|
||||||
|
|
||||||
|
// 设置收货状态和支付状态字段
|
||||||
|
resp.setReceiptStatus(entity.getReceiptStatus());
|
||||||
|
resp.setPaymentStatus(entity.getPaymentStatus());
|
||||||
|
|
||||||
|
// 设置审批状态(根据采购状态推断)
|
||||||
|
// 这里需要注入 EquipmentApprovalService 来获取审批状态
|
||||||
|
// 暂时根据采购状态推断,后续通过关联查询获取
|
||||||
|
resp.setApprovalStatus(getApprovalStatus(entity.getEquipmentId(), entity.getProcurementStatus()));
|
||||||
|
|
||||||
// 新增字段转换
|
// 新增字段转换
|
||||||
resp.setUsingDepartment(entity.getUsingDepartment());
|
resp.setUsingDepartment(entity.getUsingDepartment());
|
||||||
resp.setBorrowingTime(entity.getBorrowingTime());
|
resp.setBorrowingTime(entity.getBorrowingTime());
|
||||||
|
@ -505,6 +514,34 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备的审批状态
|
||||||
|
*/
|
||||||
|
private String getApprovalStatus(String equipmentId, String procurementStatus) {
|
||||||
|
try {
|
||||||
|
// 根据采购状态推断审批状态
|
||||||
|
if (procurementStatus == null) {
|
||||||
|
return "PENDING_APPROVAL";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (procurementStatus) {
|
||||||
|
case "PENDING_APPROVAL":
|
||||||
|
return "PENDING";
|
||||||
|
case "APPROVED":
|
||||||
|
return "APPROVED";
|
||||||
|
case "REJECTED":
|
||||||
|
return "REJECTED";
|
||||||
|
case "COMPLETED":
|
||||||
|
return "APPROVED"; // 已完成表示之前已审批通过
|
||||||
|
default:
|
||||||
|
return "PENDING_APPROVAL";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("获取设备审批状态失败,设备ID: {}, 错误: {}", equipmentId, e.getMessage());
|
||||||
|
return "PENDING_APPROVAL"; // 出错时返回待审批状态
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 采购管理相关方法实现
|
// 采购管理相关方法实现
|
||||||
@Override
|
@Override
|
||||||
public IPage<EquipmentResp> procurementPage(EquipmentListReq req) {
|
public IPage<EquipmentResp> procurementPage(EquipmentListReq req) {
|
||||||
|
@ -866,7 +903,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||||
// 设置收货相关信息
|
// 设置收货相关信息
|
||||||
if (StringUtils.hasText(req.getReceiptTime())) {
|
if (StringUtils.hasText(req.getReceiptTime())) {
|
||||||
try {
|
try {
|
||||||
equipment.setInStockTime(LocalDateTime.parse(req.getReceiptTime()));
|
equipment.setInStockTime(LocalDateTime.parse(req.getReceiptTime().replace(" ", "T")));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("解析收货时间失败,使用当前时间: {}", req.getReceiptTime());
|
log.warn("解析收货时间失败,使用当前时间: {}", req.getReceiptTime());
|
||||||
equipment.setInStockTime(LocalDateTime.now());
|
equipment.setInStockTime(LocalDateTime.now());
|
||||||
|
@ -875,7 +912,17 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||||
equipment.setInStockTime(LocalDateTime.now());
|
equipment.setInStockTime(LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置入库位置信息
|
// 设置收货状态为已收货
|
||||||
|
equipment.setReceiptStatus("RECEIVED");
|
||||||
|
|
||||||
|
// 设置采购状态为已完成(而不是已收货)
|
||||||
|
equipment.setProcurementStatus("COMPLETED");
|
||||||
|
|
||||||
|
// 设置设备状态为库存中
|
||||||
|
equipment.setLocationStatus("in_stock");
|
||||||
|
equipment.setUseStatus("0"); // 空闲中
|
||||||
|
|
||||||
|
// 设置其他收货相关字段
|
||||||
if (StringUtils.hasText(req.getStorageLocation())) {
|
if (StringUtils.hasText(req.getStorageLocation())) {
|
||||||
equipment.setPhysicalLocation(req.getStorageLocation());
|
equipment.setPhysicalLocation(req.getStorageLocation());
|
||||||
}
|
}
|
||||||
|
@ -883,30 +930,44 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||||
equipment.setResponsiblePerson(req.getStorageManager());
|
equipment.setResponsiblePerson(req.getStorageManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置状态信息
|
// 记录收货人信息到资产备注中
|
||||||
equipment.setLocationStatus("in_stock");
|
if (StringUtils.hasText(req.getReceiptPerson())) {
|
||||||
equipment.setEquipmentStatus("normal");
|
String currentRemark = procurementRecord.getAssetRemark();
|
||||||
equipment.setUseStatus("0");
|
String receiptInfo = String.format("收货人:%s,收货时间:%s",
|
||||||
equipment.setHealthStatus("good");
|
req.getReceiptPerson(),
|
||||||
|
req.getReceiptTime() != null ? req.getReceiptTime() : LocalDateTime.now().toString());
|
||||||
|
|
||||||
|
if (StringUtils.hasText(currentRemark)) {
|
||||||
|
equipment.setAssetRemark(currentRemark + ";" + receiptInfo);
|
||||||
|
} else {
|
||||||
|
equipment.setAssetRemark(receiptInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置设备序列号(如果收货时生成了新的)
|
||||||
|
if (StringUtils.hasText(req.getEquipmentSn())) {
|
||||||
|
equipment.setEquipmentSn(req.getEquipmentSn());
|
||||||
|
}
|
||||||
|
|
||||||
// 设置库存条码
|
// 设置库存条码
|
||||||
if (StringUtils.hasText(req.getInventoryBarcode())) {
|
if (StringUtils.hasText(req.getInventoryBarcode())) {
|
||||||
equipment.setInventoryBarcode(req.getInventoryBarcode());
|
equipment.setInventoryBarcode(req.getInventoryBarcode());
|
||||||
} else if (StringUtils.hasText(procurementRecord.getInventoryBarcode())) {
|
|
||||||
equipment.setInventoryBarcode(procurementRecord.getInventoryBarcode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置系统字段
|
// 设置更新时间和操作人
|
||||||
equipment.setUpdateTime(LocalDateTime.now());
|
equipment.setUpdateTime(LocalDateTime.now());
|
||||||
equipment.setUpdateBy(StpUtil.getLoginIdAsString());
|
equipment.setUpdateBy(StpUtil.getLoginIdAsString());
|
||||||
|
|
||||||
|
log.info("准备更新设备记录,设备ID: {}, 收货状态: {}, 采购状态: {}",
|
||||||
|
equipmentId, equipment.getReceiptStatus(), equipment.getProcurementStatus());
|
||||||
|
|
||||||
// 3. 更新设备记录
|
// 3. 更新设备记录
|
||||||
boolean success = this.updateById(equipment);
|
boolean updateResult = this.updateById(equipment);
|
||||||
if (!success) {
|
if (!updateResult) {
|
||||||
throw new ServiceException("更新设备记录失败");
|
throw new ServiceException("更新设备记录失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("设备收货和入库完成,设备ID: {}, 入库时间: {}, 位置: {}",
|
log.info("设备收货和入库成功,设备ID: {}, 收货状态: {}, 采购状态: {}",
|
||||||
equipmentId, equipment.getInStockTime(), equipment.getPhysicalLocation());
|
equipmentId, equipment.getReceiptStatus(), equipment.getProcurementStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://39.99.201.243:3306/znpt_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://39.99.201.243:3306/test01?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
username: root
|
username: root
|
||||||
password: BUw8YW6%@^8q
|
password: BUw8YW6%@^8q
|
||||||
druid:
|
druid:
|
||||||
|
|
Loading…
Reference in New Issue