实现点击确认收货后直接入库
This commit is contained in:
parent
2dec48a83f
commit
5ed374f06f
|
@ -0,0 +1,160 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 收货请求参数(扩展版,包含完整设备信息)
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "收货请求参数", description = "收货请求参数,包含收货信息和设备信息")
|
||||
public class ReceiptRequest {
|
||||
|
||||
// 收货特有信息
|
||||
@NotBlank(message = "收货时间不能为空")
|
||||
@ApiModelProperty("收货时间")
|
||||
private String receiptTime;
|
||||
|
||||
@NotBlank(message = "收货人不能为空")
|
||||
@ApiModelProperty("收货人")
|
||||
private String receiptPerson;
|
||||
|
||||
@NotNull(message = "收货数量不能为空")
|
||||
@ApiModelProperty("收货数量")
|
||||
private Integer receiptQuantity;
|
||||
|
||||
@ApiModelProperty("收货备注")
|
||||
private String receiptRemark;
|
||||
|
||||
@NotBlank(message = "外观检查结果不能为空")
|
||||
@ApiModelProperty("外观检查结果")
|
||||
private String appearanceCheck;
|
||||
|
||||
@NotBlank(message = "功能测试结果不能为空")
|
||||
@ApiModelProperty("功能测试结果")
|
||||
private String functionTest;
|
||||
|
||||
@NotBlank(message = "包装完整性不能为空")
|
||||
@ApiModelProperty("包装完整性")
|
||||
private String packageIntegrity;
|
||||
|
||||
@NotBlank(message = "配件完整性不能为空")
|
||||
@ApiModelProperty("配件完整性")
|
||||
private String accessoryIntegrity;
|
||||
|
||||
@NotBlank(message = "检查结果不能为空")
|
||||
@ApiModelProperty("检查结果")
|
||||
private String checkResult;
|
||||
|
||||
@ApiModelProperty("检查备注")
|
||||
private String checkRemark;
|
||||
|
||||
@NotBlank(message = "入库位置不能为空")
|
||||
@ApiModelProperty("入库位置")
|
||||
private String storageLocation;
|
||||
|
||||
@NotBlank(message = "库管员不能为空")
|
||||
@ApiModelProperty("库管员")
|
||||
private String storageManager;
|
||||
|
||||
// 设备基本信息(从采购数据继承)
|
||||
@ApiModelProperty("设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@ApiModelProperty("设备类型")
|
||||
private String equipmentType;
|
||||
|
||||
@ApiModelProperty("设备序列号")
|
||||
private String equipmentSn;
|
||||
|
||||
@ApiModelProperty("品牌")
|
||||
private String brand;
|
||||
|
||||
@ApiModelProperty("配置规格/参数")
|
||||
private String specification;
|
||||
|
||||
@ApiModelProperty("资产编号")
|
||||
private String assetCode;
|
||||
|
||||
// 采购信息(从采购数据继承)
|
||||
@ApiModelProperty("采购订单号")
|
||||
private String purchaseOrder;
|
||||
|
||||
@ApiModelProperty("供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
@ApiModelProperty("采购价格")
|
||||
private BigDecimal purchasePrice;
|
||||
|
||||
@ApiModelProperty("采购时间")
|
||||
private String purchaseTime;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("总价")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
// 入库信息
|
||||
@ApiModelProperty("入库时间")
|
||||
private String inStockTime;
|
||||
|
||||
@ApiModelProperty("物理位置")
|
||||
private String physicalLocation;
|
||||
|
||||
@ApiModelProperty("位置状态")
|
||||
private String locationStatus;
|
||||
|
||||
@ApiModelProperty("负责人")
|
||||
private String responsiblePerson;
|
||||
|
||||
@ApiModelProperty("库存条码")
|
||||
private String inventoryBarcode;
|
||||
|
||||
// 状态信息
|
||||
@ApiModelProperty("设备状态")
|
||||
private String equipmentStatus;
|
||||
|
||||
@ApiModelProperty("使用状态")
|
||||
private String useStatus;
|
||||
|
||||
@ApiModelProperty("健康状态")
|
||||
private String healthStatus;
|
||||
|
||||
@ApiModelProperty("收货状态")
|
||||
private String receiptStatus;
|
||||
|
||||
// 其他管理信息
|
||||
@ApiModelProperty("折旧方法")
|
||||
private String depreciationMethod;
|
||||
|
||||
@ApiModelProperty("折旧年限")
|
||||
private Integer depreciationYears;
|
||||
|
||||
@ApiModelProperty("残值")
|
||||
private BigDecimal salvageValue;
|
||||
|
||||
@ApiModelProperty("当前净值")
|
||||
private BigDecimal currentNetValue;
|
||||
|
||||
// 系统字段
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private String updateTime;
|
||||
}
|
|
@ -6,6 +6,7 @@ import com.dite.znpt.domain.entity.EquipmentEntity;
|
|||
import com.dite.znpt.domain.vo.EquipmentListReq;
|
||||
import com.dite.znpt.domain.vo.EquipmentReq;
|
||||
import com.dite.znpt.domain.vo.EquipmentResp;
|
||||
import com.dite.znpt.domain.vo.ReceiptRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -53,6 +54,11 @@ public interface EquipmentService extends IService<EquipmentEntity> {
|
|||
*/
|
||||
Object getProcurementStats();
|
||||
|
||||
/**
|
||||
* 确认收货并自动入库
|
||||
*/
|
||||
void receiveGoodsAndStockIn(String equipmentId, ReceiptRequest req);
|
||||
|
||||
/**
|
||||
* 导出采购记录
|
||||
*/
|
||||
|
|
|
@ -23,9 +23,13 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.dite.znpt.domain.vo.ReceiptRequest;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -840,4 +844,69 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
|
||||
log.info("批量设备盘库执行成功,处理设备数量: {}", equipmentIds.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void receiveGoodsAndStockIn(String equipmentId, ReceiptRequest req) {
|
||||
log.info("开始处理设备收货和入库,设备ID: {}", equipmentId);
|
||||
log.info("收货请求数据: {}", req);
|
||||
|
||||
// 1. 查找采购记录
|
||||
EquipmentEntity procurementRecord = this.getById(equipmentId);
|
||||
if (procurementRecord == null) {
|
||||
throw new ServiceException("采购记录不存在");
|
||||
}
|
||||
|
||||
log.info("找到采购记录: {}", procurementRecord);
|
||||
|
||||
// 2. 更新现有设备记录(而不是创建新记录)
|
||||
EquipmentEntity equipment = new EquipmentEntity();
|
||||
equipment.setEquipmentId(equipmentId);
|
||||
|
||||
// 设置收货相关信息
|
||||
if (StringUtils.hasText(req.getReceiptTime())) {
|
||||
try {
|
||||
equipment.setInStockTime(LocalDateTime.parse(req.getReceiptTime()));
|
||||
} catch (Exception e) {
|
||||
log.warn("解析收货时间失败,使用当前时间: {}", req.getReceiptTime());
|
||||
equipment.setInStockTime(LocalDateTime.now());
|
||||
}
|
||||
} else {
|
||||
equipment.setInStockTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
// 设置入库位置信息
|
||||
if (StringUtils.hasText(req.getStorageLocation())) {
|
||||
equipment.setPhysicalLocation(req.getStorageLocation());
|
||||
}
|
||||
if (StringUtils.hasText(req.getStorageManager())) {
|
||||
equipment.setResponsiblePerson(req.getStorageManager());
|
||||
}
|
||||
|
||||
// 设置状态信息
|
||||
equipment.setLocationStatus("in_stock");
|
||||
equipment.setEquipmentStatus("normal");
|
||||
equipment.setUseStatus("0");
|
||||
equipment.setHealthStatus("good");
|
||||
|
||||
// 设置库存条码
|
||||
if (StringUtils.hasText(req.getInventoryBarcode())) {
|
||||
equipment.setInventoryBarcode(req.getInventoryBarcode());
|
||||
} else if (StringUtils.hasText(procurementRecord.getInventoryBarcode())) {
|
||||
equipment.setInventoryBarcode(procurementRecord.getInventoryBarcode());
|
||||
}
|
||||
|
||||
// 设置系统字段
|
||||
equipment.setUpdateTime(LocalDateTime.now());
|
||||
equipment.setUpdateBy(StpUtil.getLoginIdAsString());
|
||||
|
||||
// 3. 更新设备记录
|
||||
boolean success = this.updateById(equipment);
|
||||
if (!success) {
|
||||
throw new ServiceException("更新设备记录失败");
|
||||
}
|
||||
|
||||
log.info("设备收货和入库完成,设备ID: {}, 入库时间: {}, 位置: {}",
|
||||
equipmentId, equipment.getInStockTime(), equipment.getPhysicalLocation());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, ProjectEntity
|
|||
QueryWrapper<ContractEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("contract_code", req.getProjectOrigin());
|
||||
ContractEntity contractEntity = contractMapper.selectOne(queryWrapper);
|
||||
contractEntity.setProjectId(entity.getProjectId());
|
||||
contractMapper.updateById(contractEntity);
|
||||
for (ProjectInitTaskReq taskReq : req.getTasks()) {
|
||||
ProjectTaskEntity taskEntity = BeanUtil.copyProperties(taskReq, ProjectTaskEntity.class);
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import com.dite.znpt.domain.vo.ReceiptRequest;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -139,4 +140,15 @@ public class EquipmentController {
|
|||
public Result<?> getProcurementStats(){
|
||||
return Result.ok(equipmentService.getProcurementStats());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "确认收货并自动入库", httpMethod = "POST")
|
||||
@PostMapping("/procurement/receipt/{equipmentId}")
|
||||
public Result<?> receiveGoods(@PathVariable String equipmentId, @Validated @RequestBody ReceiptRequest req) {
|
||||
log.info("=== 设备收货接口被调用 ===");
|
||||
log.info("设备ID: {}", equipmentId);
|
||||
log.info("收货数据: {}", req);
|
||||
|
||||
equipmentService.receiveGoodsAndStockIn(equipmentId, req);
|
||||
return Result.ok("收货成功,设备已自动入库");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue