fix:修改入库单据问题

main
HuangHuiKang 1 week ago
parent 623c14fd99
commit a3634e88dd

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.erp.enums.stock;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Getter
public enum ErpStockInApproveActionEnum {
SUBMIT("SUBMIT"),
APPROVE("APPROVE"),
REJECT("REJECT"),
AUTO_APPROVE("AUTO_APPROVE");
private final String actionType;
}

@ -27,6 +27,11 @@
<artifactId>yudao-module-erp-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-infra-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
@ -76,4 +81,4 @@
</dependencies>
</project>
</project>

@ -30,9 +30,6 @@ public class ErpStockInSaveReqVO {
@Schema(description = "经办人编号", example = "1888")
private Long stockUserId;
@Schema(description = "是否需要审核", example = "true")
private Boolean needAudit;
@Schema(description = "审核人编号", example = "1888")
private Long auditUserId;

@ -529,10 +529,16 @@ public class ErpProductServiceImpl implements ErpProductService {
Map<Long, ErpProductUnitDO> unitMap = productUnitService.getProductUnitMap(
convertSet(list, ErpProductDO::getUnitId));
return BeanUtils.toBean(list, ErpProductRespVO.class, product -> {
MapUtils.findAndThen(categoryMap, product.getCategoryId(),
category -> product.setCategoryName(category.getName()));
MapUtils.findAndThen(subCategoryMap, product.getSubCategoryId(),
subCategory -> product.setSubCategoryName(subCategory.getName()));
MapUtils.findAndThen(categoryMap, product.getCategoryId(), category -> {
product.setCategoryName(category.getName());
if (product.getCategoryType() == null) {
product.setCategoryType(category.getType());
}
});
MapUtils.findAndThen(subCategoryMap, product.getSubCategoryId(), subCategory -> {
product.setSubCategoryName(subCategory.getName());
product.setCategoryType(subCategory.getType());
});
MapUtils.findAndThen(unitMap, product.getUnitId(),
unit -> product.setUnitName(unit.getName()));
if (Boolean.TRUE.equals(product.getDeleted())) {

@ -25,12 +25,14 @@ import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper;
import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO;
import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus;
import cn.iocoder.yudao.module.erp.enums.stock.ErpStockInApproveActionEnum;
import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum;
import cn.iocoder.yudao.module.erp.service.mold.MoldBrandService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
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.user.AdminUserApi;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -72,11 +74,6 @@ import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_LOC
@Validated
public class ErpStockInServiceImpl implements ErpStockInService {
private static final String ACTION_SUBMIT = "SUBMIT";
private static final String ACTION_APPROVE = "APPROVE";
private static final String ACTION_REJECT = "REJECT";
private static final String ACTION_AUTO_APPROVE = "AUTO_APPROVE";
@Resource
private ErpStockInMapper stockInMapper;
@Resource
@ -101,6 +98,8 @@ public class ErpStockInServiceImpl implements ErpStockInService {
private WarehouseAreaService warehouseAreaService;
@Resource
private AdminUserApi adminUserApi;
@Resource
private ConfigApi configApi;
@Override
@Transactional(rollbackFor = Exception.class)
@ -117,7 +116,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
throw exception(STOCK_IN_NO_EXISTS);
}
boolean needAudit = !Boolean.FALSE.equals(createReqVO.getNeedAudit());
boolean needAudit = needAudit();
Integer status = needAudit ? ErpAuditStatus.DRAFT.getStatus() : ErpAuditStatus.APPROVE.getStatus();
ErpStockInDO stockIn = BeanUtils.toBean(createReqVO, ErpStockInDO.class, in -> in
.setNo(no)
@ -131,7 +130,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
if (!needAudit) {
applyStockInEffect(stockIn, stockInItems, null);
createApproveRecord(stockIn.getId(), ACTION_AUTO_APPROVE, null,
createApproveRecord(stockIn.getId(), ErpStockInApproveActionEnum.AUTO_APPROVE, null,
ErpAuditStatus.APPROVE.getStatus(), null, "无需审核,系统自动入库");
}
return stockIn.getId();
@ -154,7 +153,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
adminUserApi.validateUser(updateReqVO.getAuditUserId());
}
List<ErpStockInItemDO> stockInItems = validateStockInItems(updateReqVO.getItems(), updateReqVO.getInType());
boolean needAudit = !Boolean.FALSE.equals(updateReqVO.getNeedAudit());
boolean needAudit = needAudit();
ErpStockInDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockInDO.class, in -> in
.setNeedAudit(needAudit)
.setTotalCount(getSumValue(stockInItems, ErpStockInItemDO::getCount, BigDecimal::add))
@ -215,7 +214,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
if (updateCount == 0) {
throw exception(STOCK_IN_SUBMIT_FAIL_STATUS);
}
createApproveRecord(stockIn.getId(), ACTION_SUBMIT, fromStatus,
createApproveRecord(stockIn.getId(), ErpStockInApproveActionEnum.SUBMIT, fromStatus,
ErpAuditStatus.PROCESS.getStatus(), auditUserId, submitReqVO.getRemark());
}
@ -248,7 +247,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
}
Long targetUserId = NumberUtils.parseLong(stockIn.getCreator());
createApproveRecord(stockIn.getId(), ErpAuditStatus.APPROVE.getStatus().equals(auditReqVO.getStatus())
? ACTION_APPROVE : ACTION_REJECT,
? ErpStockInApproveActionEnum.APPROVE : ErpStockInApproveActionEnum.REJECT,
fromStatus, auditReqVO.getStatus(), targetUserId, auditReqVO.getRemark());
}
@ -329,7 +328,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
boolean approve, Integer bizType) {
stockInItems.forEach(stockInItem -> {
BigDecimal count = approve ? stockInItem.getCount() : stockInItem.getCount().negate();
if (Objects.equals(stockIn.getInType(), "妯″叿鍏ュ簱")) {
if (Objects.equals(stockIn.getInType(), "模具入库")) {
MoldBrandDO moldDO = moldBrandService.getMoldBrand(stockInItem.getMoldSetId());
Integer recordBizType = bizType != null ? bizType
: (approve ? ErpStockRecordBizTypeEnum.OTHER_IN.getType()
@ -360,11 +359,15 @@ public class ErpStockInServiceImpl implements ErpStockInService {
return true;
}
private void createApproveRecord(Long stockInId, String actionType, Integer fromStatus,
private boolean needAudit() {
return !"0".equals(configApi.getConfigValueByCategoryAndKey("biz", "isAudit"));
}
private void createApproveRecord(Long stockInId, ErpStockInApproveActionEnum action, Integer fromStatus,
Integer toStatus, Long targetUserId, String remark) {
stockInApproveRecordMapper.insert(ErpStockInApproveRecordDO.builder()
.stockInId(stockInId)
.actionType(actionType)
.actionType(action.getActionType())
.fromStatus(fromStatus)
.toStatus(toStatus)
.targetUserId(targetUserId)
@ -374,7 +377,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
private List<ErpStockInItemDO> validateStockInItems(List<ErpStockInSaveReqVO.Item> list, String inType) {
validateWarehouseAreas(list);
if (Objects.equals(inType, "妯″叿鍏ュ簱")) {
if (Objects.equals(inType, "模具入库")) {
List<MoldBrandDO> moldList = moldBrandService.validMoldList(convertSet(list, ErpStockInSaveReqVO.Item::getMoldSetId));
Map<Long, MoldBrandDO> moldMap = convertMap(moldList, MoldBrandDO::getId);
Map<Long, ErpWarehouseDO> warehouseMap = convertMap(
@ -466,4 +469,3 @@ public class ErpStockInServiceImpl implements ErpStockInService {
}
}
}

@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.erp.service.mold.MoldService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -47,6 +48,10 @@ import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
@Validated
public class ErpStockOutServiceImpl implements ErpStockOutService {
private static final String AUDIT_CONFIG_CATEGORY = "biz";
private static final String AUDIT_CONFIG_KEY = "isAudit";
private static final String AUDIT_CONFIG_DISABLE_VALUE = "0";
@Resource
private ErpStockOutMapper stockOutMapper;
@Resource
@ -67,6 +72,8 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
private ErpCustomerService customerService;
@Resource
private ErpStockRecordService stockRecordService;
@Resource
private ConfigApi configApi;
@Override
@ -83,8 +90,10 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
}
// 2.1 插入出库单
boolean needAudit = needAudit();
Integer status = needAudit ? ErpAuditStatus.PROCESS.getStatus() : ErpAuditStatus.APPROVE.getStatus();
ErpStockOutDO stockOut = BeanUtils.toBean(createReqVO, ErpStockOutDO.class, in -> in
.setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())
.setNo(no).setStatus(status)
.setTotalCount(getSumValue(stockOutItems, ErpStockOutItemDO::getCount, BigDecimal::add))
.setTotalPrice(getSumValue(stockOutItems, ErpStockOutItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)));
stockOutMapper.insert(stockOut);
@ -96,6 +105,9 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
// moldDO.setStatus(ErpAuditStatus.PROCESS.getStatus()); // 未审核
// moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class));
// }
if (!needAudit) {
operateStockOutEffect(stockOut, stockOutItems, true, ErpAuditStatus.APPROVE.getStatus());
}
return stockOut.getId();
}
@ -137,6 +149,11 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
}
List<ErpStockOutItemDO> stockOutItems = stockOutItemMapper.selectListByOutId(id);
operateStockOutEffect(stockOut, stockOutItems, approve, status);
}
private void operateStockOutEffect(ErpStockOutDO stockOut, List<ErpStockOutItemDO> stockOutItems,
boolean approve, Integer status) {
stockOutItems.forEach(stockOutItem -> {
BigDecimal count = approve ? stockOutItem.getCount().negate() : stockOutItem.getCount();
if (Objects.equals(stockOut.getOutType(), "模具出库")) {
@ -166,6 +183,10 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
}
}
private boolean needAudit() {
return !AUDIT_CONFIG_DISABLE_VALUE.equals(configApi.getConfigValueByCategoryAndKey(AUDIT_CONFIG_CATEGORY, AUDIT_CONFIG_KEY));
}
private List<ErpStockOutItemDO> validateStockOutItems(List<ErpStockOutSaveReqVO.Item> list,String outType) {
if (Objects.equals(outType, "模具出库")) {
List<MoldBrandDO> moldList = moldBrandService.validMoldList(
@ -293,4 +314,4 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
}
}
}

@ -15,4 +15,6 @@ public interface ConfigApi {
*/
String getConfigValueByKey(String key);
String getConfigValueByCategoryAndKey(String category, String key);
}

@ -25,4 +25,10 @@ public class ConfigApiImpl implements ConfigApi {
return config != null ? config.getValue() : null;
}
@Override
public String getConfigValueByCategoryAndKey(String category, String key) {
ConfigDO config = configService.getConfigByCategoryAndKey(category, key);
return config != null ? config.getValue() : null;
}
}

@ -14,6 +14,10 @@ public interface ConfigMapper extends BaseMapperX<ConfigDO> {
return selectOne(ConfigDO::getConfigKey, key);
}
default ConfigDO selectByCategoryAndKey(String category, String key) {
return selectOne(ConfigDO::getCategory, category, ConfigDO::getConfigKey, key);
}
default PageResult<ConfigDO> selectPage(ConfigPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ConfigDO>()
.likeIfPresent(ConfigDO::getName, reqVO.getName())

@ -52,6 +52,8 @@ public interface ConfigService {
*/
ConfigDO getConfigByKey(String key);
ConfigDO getConfigByCategoryAndKey(String category, String key);
/**
*
*

@ -74,6 +74,11 @@ public class ConfigServiceImpl implements ConfigService {
return configMapper.selectByKey(key);
}
@Override
public ConfigDO getConfigByCategoryAndKey(String category, String key) {
return configMapper.selectByCategoryAndKey(category, key);
}
@Override
public PageResult<ConfigDO> getConfigPage(ConfigPageReqVO pageReqVO) {
return configMapper.selectPage(pageReqVO);

@ -158,10 +158,10 @@ public class MoldOperateServiceImpl implements MoldOperateService {
moldOperate.setDeviceId(deviceLedgerDO.getId());
moldOperate.setDeviceName(deviceLedgerDO.getDeviceName());
moldOperate.setLineId(lineId);
OrganizationDO organizationDO = organizationMapper.selectById(lineId);
if (organizationDO != null) {
moldOperate.setLineName(organizationDO.getName());
}
// OrganizationDO organizationDO = organizationMapper.selectById(lineId);
// if (organizationDO != null) {
// moldOperate.setLineName(organizationDO.getName());
// }
}

Loading…
Cancel
Save