fix:修改仓库出入库单据审核流程

main
HuangHuiKang 4 days ago
parent 3c8384751e
commit 9baafe4755

@ -35,6 +35,8 @@ import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
import cn.iocoder.yudao.module.erp.service.warehousearea.WarehouseAreaService;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -103,6 +105,8 @@ public class ErpStockInServiceImpl implements ErpStockInService {
@Resource
private AdminUserApi adminUserApi;
@Resource
private PermissionApi permissionApi;
@Resource
private ConfigApi configApi;
@Override
@ -249,7 +253,8 @@ public class ErpStockInServiceImpl implements ErpStockInService {
throw exception(STOCK_IN_AUDIT_FAIL_STATUS);
}
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
if (!Objects.equals(stockIn.getAuditUserId(), loginUserId)) {
boolean adminCanAudit = permissionApi.hasAnyRoles(loginUserId, RoleCodeEnum.SUPER_ADMIN.getCode());
if (!Objects.equals(stockIn.getAuditUserId(), loginUserId) && !adminCanAudit) {
throw exception(STOCK_IN_AUDIT_FAIL_USER);
}
if (!ErpAuditStatus.APPROVE.getStatus().equals(auditReqVO.getStatus())
@ -369,7 +374,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
Integer recordBizType = bizType != null ? bizType
: (approve ? ErpStockRecordBizTypeEnum.getTypeByName(stockIn.getInType())
: ErpStockRecordBizTypeEnum.getTypeByName(stockIn.getInType(), 10));
stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO(
stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO(
stockInItem.getProductId(), productDO.getCategoryId(), productDO.getCategoryType(), stockInItem.getWarehouseId(),
stockInItem.getAreaId(), stockInItem.getAreaName(), count,
recordBizType, stockInItem.getInId(), stockInItem.getId(), stockIn.getNo(), stockIn.getInTime()));

@ -35,7 +35,9 @@ import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
import cn.iocoder.yudao.module.erp.service.warehousearea.WarehouseAreaService;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -92,6 +94,8 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
private AdminUserApi adminUserApi;
@Resource
private ConfigApi configApi;
@Resource
private PermissionApi permissionApi;
@Override
@Transactional(rollbackFor = Exception.class)
@ -241,10 +245,14 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
if (!ErpAuditStatus.PROCESS.getStatus().equals(stockOut.getStatus())) {
throw exception(STOCK_OUT_AUDIT_FAIL_STATUS);
}
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
if (!Objects.equals(stockOut.getAuditUserId(), loginUserId)) {
boolean adminCanSubmit = permissionApi.hasAnyRoles(loginUserId, RoleCodeEnum.SUPER_ADMIN.getCode());
if (!Objects.equals(stockOut.getAuditUserId(), loginUserId) && !adminCanSubmit) {
throw exception(STOCK_OUT_AUDIT_FAIL_USER);
}
if (!ErpAuditStatus.APPROVE.getStatus().equals(auditReqVO.getStatus())
&& !ErpAuditStatus.UN_APPROVE.getStatus().equals(auditReqVO.getStatus())) {
throw exception(STOCK_OUT_AUDIT_FAIL_RESULT);

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.service.stock.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -14,6 +15,7 @@ import java.time.LocalDateTime;
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ErpStockRecordCreateReqBO {
/**
@ -54,7 +56,7 @@ public class ErpStockRecordCreateReqBO {
/**
*
*/
@NotNull(message = "业务类型不能为空")
// @NotNull(message = "业务类型不能为空")
private Integer bizType;
/**
*
@ -87,20 +89,20 @@ public class ErpStockRecordCreateReqBO {
this(productId, categoryId, categoryType, warehouseId, null, null, count, bizType, bizId, bizItemId, bizNo, recordTime);
}
public ErpStockRecordCreateReqBO(Long productId, Long categoryId, Integer categoryType, Long warehouseId,
Long areaId, String areaName, BigDecimal count, Integer bizType, Long bizId,
Long bizItemId, String bizNo, LocalDateTime recordTime) {
this.productId = productId;
this.categoryId = categoryId;
this.categoryType = categoryType;
this.warehouseId = warehouseId;
this.areaId = areaId;
this.areaName = areaName;
this.count = count;
this.bizType = bizType;
this.bizId = bizId;
this.bizItemId = bizItemId;
this.bizNo = bizNo;
this.recordTime = recordTime;
}
// public ErpStockRecordCreateReqBO(Long productId, Long categoryId, Integer categoryType, Long warehouseId,
// Long areaId, String areaName, BigDecimal count, Integer bizType, Long bizId,
// Long bizItemId, String bizNo, LocalDateTime recordTime) {
// this.productId = productId;
// this.categoryId = categoryId;
// this.categoryType = categoryType;
// this.warehouseId = warehouseId;
// this.areaId = areaId;
// this.areaName = areaName;
// this.count = count;
// this.bizType = bizType;
// this.bizId = bizId;
// this.bizItemId = bizItemId;
// this.bizNo = bizNo;
// this.recordTime = recordTime;
// }
}

@ -14,7 +14,6 @@ public enum RoleCodeEnum {
SUPER_ADMIN("super_admin", "超级管理员"),
TENANT_ADMIN("tenant_admin", "租户管理员"),
CRM_ADMIN("crm_admin", "CRM 管理员"); // CRM 系统专用
;
/**
*

Loading…
Cancel
Save