合并development代码到master #1

Merged
cuizhibin merged 21 commits from development into master 2025-08-11 09:25:53 +08:00
4 changed files with 283 additions and 0 deletions
Showing only changes of commit 01455720be - Show all commits

View File

@ -0,0 +1,70 @@
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;
import java.time.LocalDate;
/**
* @author Bear.G
* @date 2025/1/8/周三 18:00
* @description 设备采购申请请求VO
*/
@Data
@ApiModel(value = "EquipmentProcurementApplyReq", description = "设备采购申请请求")
public class EquipmentProcurementApplyReq {
@ApiModelProperty("设备ID")
@NotBlank(message = "设备ID不能为空")
private String equipmentId;
@ApiModelProperty("设备名称")
@NotBlank(message = "设备名称不能为空")
private String equipmentName;
@ApiModelProperty("设备类型")
@NotBlank(message = "设备类型不能为空")
private String equipmentType;
@ApiModelProperty("设备型号")
private String equipmentModel;
@ApiModelProperty("品牌")
private String brand;
@ApiModelProperty("供应商名称")
private String supplierName;
@ApiModelProperty("预算金额")
@NotNull(message = "预算金额不能为空")
private BigDecimal budgetAmount;
@ApiModelProperty("数量")
@NotNull(message = "数量不能为空")
private Integer quantity;
@ApiModelProperty("紧急程度LOW-低NORMAL-普通HIGH-高URGENT-紧急")
@NotBlank(message = "紧急程度不能为空")
private String urgencyLevel;
@ApiModelProperty("申请原因")
@NotBlank(message = "申请原因不能为空")
private String applyReason;
@ApiModelProperty("技术要求")
private String technicalRequirements;
@ApiModelProperty("业务合理性说明")
private String businessJustification;
@ApiModelProperty("预期交付日期")
private LocalDate expectedDeliveryDate;
@ApiModelProperty("采购类型NEW_PURCHASE-新采购REPLACEMENT-更换UPGRADE-升级")
@NotBlank(message = "采购类型不能为空")
private String procurementType;
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dite.znpt.domain.vo.EquipmentApprovalListReq;
import com.dite.znpt.domain.vo.EquipmentApprovalReq;
import com.dite.znpt.domain.vo.EquipmentApprovalResp;
import com.dite.znpt.domain.vo.EquipmentProcurementApplyReq;
/**
* @author Bear.G
@ -41,4 +42,19 @@ public interface EquipmentApprovalService {
* 获取审批统计信息
*/
Object getApprovalStats();
/**
* 提交采购申请
*/
void submitProcurementApplication(EquipmentProcurementApplyReq req);
/**
* 获取我的采购申请
*/
IPage<EquipmentApprovalResp> getMyProcurementApplications(EquipmentApprovalListReq req);
/**
* 撤回采购申请
*/
void withdrawProcurementApplication(String approvalId);
}

View File

@ -8,7 +8,9 @@ import com.dite.znpt.domain.mapper.EquipmentApprovalMapper;
import com.dite.znpt.domain.vo.EquipmentApprovalListReq;
import com.dite.znpt.domain.vo.EquipmentApprovalReq;
import com.dite.znpt.domain.vo.EquipmentApprovalResp;
import com.dite.znpt.domain.vo.EquipmentProcurementApplyReq;
import com.dite.znpt.service.EquipmentApprovalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@ -25,6 +27,7 @@ import java.util.stream.Collectors;
* @date 2025/1/8/周三 17:55
* @description 设备审批服务实现类
*/
@Slf4j
@Service
public class EquipmentApprovalServiceImpl implements EquipmentApprovalService {
@ -138,38 +141,61 @@ public class EquipmentApprovalServiceImpl implements EquipmentApprovalService {
* 添加查询条件
*/
private void addQueryConditions(LambdaQueryWrapper<EquipmentApprovalEntity> wrapper, EquipmentApprovalListReq req) {
log.info("开始构建查询条件,请求参数: {}", req);
// 添加搜索条件并记录日志
int conditionCount = 0;
if (StringUtils.hasText(req.getEquipmentName())) {
wrapper.like(EquipmentApprovalEntity::getEquipmentName, req.getEquipmentName());
log.info("添加设备名称查询条件: {}", req.getEquipmentName());
conditionCount++;
}
if (StringUtils.hasText(req.getApplicantName())) {
wrapper.like(EquipmentApprovalEntity::getApplicantName, req.getApplicantName());
log.info("添加申请人查询条件: {}", req.getApplicantName());
conditionCount++;
}
if (StringUtils.hasText(req.getBusinessType())) {
wrapper.eq(EquipmentApprovalEntity::getBusinessType, req.getBusinessType());
log.info("添加业务类型查询条件: {}", req.getBusinessType());
conditionCount++;
}
if (StringUtils.hasText(req.getApprovalStatus())) {
wrapper.eq(EquipmentApprovalEntity::getApprovalStatus, req.getApprovalStatus());
log.info("添加审批状态查询条件: {}", req.getApprovalStatus());
conditionCount++;
}
if (StringUtils.hasText(req.getApplyTimeStart())) {
wrapper.ge(EquipmentApprovalEntity::getApplyTime, req.getApplyTimeStart());
log.info("添加申请时间开始查询条件: {}", req.getApplyTimeStart());
conditionCount++;
}
if (StringUtils.hasText(req.getApplyTimeEnd())) {
wrapper.le(EquipmentApprovalEntity::getApplyTime, req.getApplyTimeEnd());
log.info("添加申请时间结束查询条件: {}", req.getApplyTimeEnd());
conditionCount++;
}
if (StringUtils.hasText(req.getApprovalTimeStart())) {
wrapper.ge(EquipmentApprovalEntity::getApprovalTime, req.getApprovalTimeStart());
log.info("添加审批时间开始查询条件: {}", req.getApprovalTimeStart());
conditionCount++;
}
if (StringUtils.hasText(req.getApprovalTimeEnd())) {
wrapper.le(EquipmentApprovalEntity::getApprovalTime, req.getApprovalTimeEnd());
log.info("添加审批时间结束查询条件: {}", req.getApprovalTimeEnd());
conditionCount++;
}
log.info("查询条件构建完成,共添加 {} 个条件", conditionCount);
// 排序
wrapper.orderByDesc(EquipmentApprovalEntity::getCreateTime);
}
@ -196,4 +222,110 @@ public class EquipmentApprovalServiceImpl implements EquipmentApprovalService {
return respPage;
}
@Override
public void submitProcurementApplication(EquipmentProcurementApplyReq req) {
log.info("开始提交采购申请,请求参数: {}", req);
// 创建审批实体
EquipmentApprovalEntity entity = new EquipmentApprovalEntity();
// 设置基本信息
entity.setEquipmentId(req.getEquipmentId()); // 添加设备ID
entity.setEquipmentName(req.getEquipmentName());
entity.setEquipmentType(req.getEquipmentType());
entity.setEquipmentModel(req.getEquipmentModel());
entity.setBrand(req.getBrand());
entity.setSupplierName(req.getSupplierName());
entity.setPurchasePrice(req.getBudgetAmount());
entity.setTotalPrice(req.getBudgetAmount().multiply(new java.math.BigDecimal(req.getQuantity())));
entity.setQuantity(req.getQuantity());
// 设置申请信息
entity.setApplicantName(getCurrentUserName()); // 获取当前用户名
entity.setApplicantId(getCurrentUserId()); // 获取当前用户ID
entity.setApplyTime(LocalDateTime.now());
entity.setApplyReason(req.getApplyReason());
// 设置业务类型和审批状态
entity.setBusinessType("PROCUREMENT");
entity.setApprovalStatus("PENDING");
// 设置扩展字段如果有的话
// entity.setProcurementType(req.getProcurementType());
// entity.setUrgencyLevel(req.getUrgencyLevel());
// entity.setTechnicalRequirements(req.getTechnicalRequirements());
// entity.setBusinessJustification(req.getBusinessJustification());
// entity.setExpectedDeliveryDate(req.getExpectedDeliveryDate());
// 保存到数据库
equipmentApprovalMapper.insert(entity);
log.info("采购申请提交成功审批ID: {}", entity.getApprovalId());
}
@Override
public IPage<EquipmentApprovalResp> getMyProcurementApplications(EquipmentApprovalListReq req) {
log.info("开始获取我的采购申请,请求参数: {}", req);
// 创建分页对象
Integer pageNum = req.getPage() != null ? req.getPage() : 1;
Integer pageSize = req.getPageSize() != null ? req.getPageSize() : 10;
Page<EquipmentApprovalEntity> page = new Page<>(pageNum, pageSize);
LambdaQueryWrapper<EquipmentApprovalEntity> wrapper = new LambdaQueryWrapper<>();
// 只查询当前用户的申请
wrapper.eq(EquipmentApprovalEntity::getApplicantId, getCurrentUserId());
wrapper.eq(EquipmentApprovalEntity::getBusinessType, "PROCUREMENT");
// 添加查询条件
addQueryConditions(wrapper, req);
IPage<EquipmentApprovalEntity> result = equipmentApprovalMapper.selectPage(page, wrapper);
return convertToRespPage(result);
}
@Override
public void withdrawProcurementApplication(String approvalId) {
log.info("开始撤回采购申请审批ID: {}", approvalId);
EquipmentApprovalEntity entity = equipmentApprovalMapper.selectById(approvalId);
if (entity == null) {
throw new RuntimeException("审批记录不存在");
}
// 检查是否是当前用户的申请
if (!entity.getApplicantId().equals(getCurrentUserId())) {
throw new RuntimeException("只能撤回自己的申请");
}
// 检查状态是否可以撤回
if (!"PENDING".equals(entity.getApprovalStatus())) {
throw new RuntimeException("只能撤回待审批状态的申请");
}
// 更新状态为已撤回
entity.setApprovalStatus("WITHDRAWN");
equipmentApprovalMapper.updateById(entity);
log.info("采购申请撤回成功审批ID: {}", approvalId);
}
/**
* 获取当前用户名
*/
private String getCurrentUserName() {
// TODO: 从安全上下文获取当前用户名
return "当前用户";
}
/**
* 获取当前用户ID
*/
private String getCurrentUserId() {
// TODO: 从安全上下文获取当前用户ID
return "current_user_id";
}
}

View File

@ -6,6 +6,7 @@ import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.vo.EquipmentApprovalListReq;
import com.dite.znpt.domain.vo.EquipmentApprovalReq;
import com.dite.znpt.domain.vo.EquipmentApprovalResp;
import com.dite.znpt.domain.vo.EquipmentProcurementApplyReq;
import com.dite.znpt.service.EquipmentApprovalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -34,6 +35,21 @@ public class EquipmentApprovalController {
@ApiOperation(value = "分页查询待审批的设备采购申请", httpMethod = "GET")
@GetMapping("/pending")
public PageResult<EquipmentApprovalResp> getPendingApprovals(EquipmentApprovalListReq req) {
log.info("=== 设备审批待审批查询接口被调用 ===");
log.info("接收到的请求参数: {}", req);
log.info("设备名称: {}", req.getEquipmentName());
log.info("申请人: {}", req.getApplicantName());
log.info("业务类型: {}", req.getBusinessType());
log.info("审批状态: {}", req.getApprovalStatus());
log.info("申请时间开始: {}", req.getApplyTimeStart());
log.info("申请时间结束: {}", req.getApplyTimeEnd());
log.info("审批时间开始: {}", req.getApprovalTimeStart());
log.info("审批时间结束: {}", req.getApprovalTimeEnd());
log.info("页码: {}", req.getPage());
log.info("每页大小: {}", req.getPageSize());
log.info("排序字段: {}", req.getOrderBy());
log.info("排序方向: {}", req.getOrderDirection());
IPage<EquipmentApprovalResp> page = equipmentApprovalService.getPendingApprovals(req);
return PageResult.ok(page.getRecords(), page.getTotal());
}
@ -41,6 +57,21 @@ public class EquipmentApprovalController {
@ApiOperation(value = "分页查询已审批的设备采购申请", httpMethod = "GET")
@GetMapping("/approved")
public PageResult<EquipmentApprovalResp> getApprovedApprovals(EquipmentApprovalListReq req) {
log.info("=== 设备审批已审批查询接口被调用 ===");
log.info("接收到的请求参数: {}", req);
log.info("设备名称: {}", req.getEquipmentName());
log.info("申请人: {}", req.getApplicantName());
log.info("业务类型: {}", req.getBusinessType());
log.info("审批状态: {}", req.getApprovalStatus());
log.info("申请时间开始: {}", req.getApplyTimeStart());
log.info("申请时间结束: {}", req.getApplyTimeEnd());
log.info("审批时间开始: {}", req.getApprovalTimeStart());
log.info("审批时间结束: {}", req.getApprovalTimeEnd());
log.info("页码: {}", req.getPage());
log.info("每页大小: {}", req.getPageSize());
log.info("排序字段: {}", req.getOrderBy());
log.info("排序方向: {}", req.getOrderDirection());
IPage<EquipmentApprovalResp> page = equipmentApprovalService.getApprovedApprovals(req);
return PageResult.ok(page.getRecords(), page.getTotal());
}
@ -70,4 +101,38 @@ public class EquipmentApprovalController {
public Result<?> getApprovalStats() {
return Result.ok(equipmentApprovalService.getApprovalStats());
}
@ApiOperation(value = "提交采购申请", httpMethod = "POST")
@PostMapping("/procurement/apply")
public Result<?> submitProcurementApplication(@Validated @RequestBody EquipmentProcurementApplyReq req) {
log.info("=== 提交采购申请接口被调用 ===");
log.info("接收到的请求参数: {}", req);
log.info("设备名称: {}", req.getEquipmentName());
log.info("设备类型: {}", req.getEquipmentType());
log.info("预算金额: {}", req.getBudgetAmount());
log.info("申请原因: {}", req.getApplyReason());
equipmentApprovalService.submitProcurementApplication(req);
return Result.ok();
}
@ApiOperation(value = "获取我的采购申请", httpMethod = "GET")
@GetMapping("/procurement/my-applications")
public PageResult<EquipmentApprovalResp> getMyProcurementApplications(EquipmentApprovalListReq req) {
log.info("=== 获取我的采购申请接口被调用 ===");
log.info("接收到的请求参数: {}", req);
IPage<EquipmentApprovalResp> page = equipmentApprovalService.getMyProcurementApplications(req);
return PageResult.ok(page.getRecords(), page.getTotal());
}
@ApiOperation(value = "撤回采购申请", httpMethod = "POST")
@PostMapping("/procurement/{approvalId}/withdraw")
public Result<?> withdrawProcurementApplication(@PathVariable String approvalId) {
log.info("=== 撤回采购申请接口被调用 ===");
log.info("审批ID: {}", approvalId);
equipmentApprovalService.withdrawProcurementApplication(approvalId);
return Result.ok();
}
}