refactor(biz): 重构采购退料和销售发货功能
This commit is contained in:
parent
70c8bebf0e
commit
2fd6b57e09
@ -155,4 +155,17 @@ public class PurReceiptDetailRespVO {
|
||||
@ExcelProperty("单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)")
|
||||
private String billType;
|
||||
|
||||
@Schema(description = "仓库名称", example = "王五")
|
||||
@ExcelProperty("仓库名称")
|
||||
private String storeHouseName;
|
||||
|
||||
@Schema(description = "仓库id", example = "2172")
|
||||
@ExcelProperty("仓库id")
|
||||
private Long storeHouseId;
|
||||
|
||||
@Schema(description = "仓库编码", example = "王五")
|
||||
@ExcelProperty("仓库编码")
|
||||
private String storeHouseCd;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public class PurReturnPageReqVO extends PageParam {
|
||||
private String supplierName;
|
||||
|
||||
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
|
||||
private String purStatus;
|
||||
private String returnStatus;
|
||||
|
||||
@Schema(description = "采购入库单主表id", example = "3872")
|
||||
private Integer purReceiptId;
|
||||
|
||||
@ -43,7 +43,7 @@ public class PurReturnRespVO {
|
||||
|
||||
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
|
||||
@ExcelProperty("单据状态(1 已创建 2 已确认 )")
|
||||
private String purStatus;
|
||||
private String returnStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
@ -74,6 +74,6 @@ public class PurReturnRespVO {
|
||||
private String billType;
|
||||
|
||||
@Schema(description = "采购退料单子表列表")
|
||||
private List<PurReturnDetailRespVO> returnDetailList;
|
||||
private List<PurReturnDetailRespVO> items;
|
||||
|
||||
}
|
||||
|
||||
@ -2,8 +2,10 @@ package com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailSaveReqVO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 采购退料单主新增/修改 Request VO")
|
||||
@Data
|
||||
@ -25,7 +27,7 @@ public class PurReturnSaveReqVO {
|
||||
private String supplierName;
|
||||
|
||||
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
|
||||
private String purStatus;
|
||||
private String returnStatus;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
@ -48,4 +50,7 @@ public class PurReturnSaveReqVO {
|
||||
@Schema(description = "单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)", example = "2")
|
||||
private String billType;
|
||||
|
||||
@Schema(description = "采购退料单子表列表")
|
||||
private List<PurReturnDetailSaveReqVO> items;
|
||||
|
||||
}
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
@Schema(description = "管理后台 - 采购退料单子 Response VO")
|
||||
@Data
|
||||
@ -125,7 +124,7 @@ public class PurReturnDetailRespVO {
|
||||
|
||||
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
|
||||
@ExcelProperty("单据状态(1 已创建 2 已确认 )")
|
||||
private String purStatus;
|
||||
private String returnStatus;
|
||||
|
||||
@Schema(description = "采购入库单主表id", example = "3872")
|
||||
@ExcelProperty("采购入库单主表id")
|
||||
@ -147,4 +146,10 @@ public class PurReturnDetailRespVO {
|
||||
@ExcelProperty("单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)")
|
||||
private String billType;
|
||||
|
||||
// 入库时间
|
||||
@Schema(description = "入库时间")
|
||||
@ExcelProperty("入库时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime inStorageTime;
|
||||
|
||||
}
|
||||
|
||||
@ -53,10 +53,10 @@ public class SaleDeliveryDetailSaveReqVO {
|
||||
|
||||
private String unit;
|
||||
|
||||
private BigDecimal stockQty;
|
||||
|
||||
private Integer stockBag;
|
||||
|
||||
private String inventBillNo;
|
||||
|
||||
private BigDecimal yardQty;
|
||||
|
||||
private Integer packQty;
|
||||
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class PurReturnDO extends BaseDO {
|
||||
/**
|
||||
* 单据状态(1 已创建 2 已确认 )
|
||||
*/
|
||||
private String purStatus;
|
||||
private String returnStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ -55,7 +55,7 @@ public class PurReturnDO extends BaseDO {
|
||||
/**
|
||||
* 采购入库单主表id
|
||||
*/
|
||||
private Integer purReceiptId;
|
||||
private Long purReceiptId;
|
||||
/**
|
||||
* 采购入库单号
|
||||
*/
|
||||
@ -63,7 +63,7 @@ public class PurReturnDO extends BaseDO {
|
||||
/**
|
||||
* 退料人id
|
||||
*/
|
||||
private Integer returnEmpId;
|
||||
private Long returnEmpId;
|
||||
/**
|
||||
* 退料人名称
|
||||
*/
|
||||
|
||||
@ -83,4 +83,8 @@ public class SaleDeliveryDetailDO extends BaseDO {
|
||||
|
||||
private String inventBillNo;
|
||||
|
||||
private BigDecimal yardQty;
|
||||
|
||||
private Integer packQty;
|
||||
|
||||
}
|
||||
|
||||
@ -87,6 +87,9 @@ public interface PurReceiptDetailMapper extends BaseMapperX<PurReceiptDetailDO>
|
||||
.selectAs(PurReceiptDO::getReceiptEmpId, PurReceiptDetailRespVO::getReceiptEmpId)
|
||||
.selectAs(PurReceiptDO::getReceiptEmpName, PurReceiptDetailRespVO::getReceiptEmpName)
|
||||
.selectAs(PurReceiptDO::getBillType, PurReceiptDetailRespVO::getBillType)
|
||||
.selectAs(PurReceiptDO::getStoreHouseName, PurReceiptDetailRespVO::getStoreHouseName)
|
||||
.selectAs(PurReceiptDO::getStoreHouseId, PurReceiptDetailRespVO::getStoreHouseId)
|
||||
.selectAs(PurReceiptDO::getStoreHouseCd, PurReceiptDetailRespVO::getStoreHouseCd)
|
||||
// LEFT JOIN 主表
|
||||
.leftJoin(PurReceiptDO.class, PurReceiptDO::getId, PurReceiptDetailDO::getPurReceiptId)
|
||||
// 查询条件 - 子表
|
||||
@ -96,6 +99,8 @@ public interface PurReceiptDetailMapper extends BaseMapperX<PurReceiptDetailDO>
|
||||
.eq(pageReqVO.getMaterialId() != null, PurReceiptDetailDO::getMaterialId, pageReqVO.getMaterialId())
|
||||
.like(pageReqVO.getMaterialCode() != null, PurReceiptDetailDO::getMaterialCode, pageReqVO.getMaterialCode())
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getMaterialName()), PurReceiptDetailDO::getMaterialName, pageReqVO.getMaterialName())
|
||||
// (t.receipt_qty - t.return_qty) > 0
|
||||
.apply("t.receipt_qty - t.return_qty > 0")
|
||||
// 查询条件 - 主表
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getPurReceiptNo()), PurReceiptDO::getPurReceiptNo, pageReqVO.getPurReceiptNo())
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getSupplierName()), PurReceiptDO::getSupplierName, pageReqVO.getSupplierName())
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturn;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnPageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturn.PurReturnDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.*;
|
||||
|
||||
/**
|
||||
* 采购退料单主 Mapper
|
||||
@ -23,7 +21,7 @@ public interface PurReturnMapper extends BaseMapperX<PurReturnDO> {
|
||||
.betweenIfPresent(PurReturnDO::getReceiptDate, reqVO.getReceiptDate())
|
||||
.eqIfPresent(PurReturnDO::getSupplierId, reqVO.getSupplierId())
|
||||
.likeIfPresent(PurReturnDO::getSupplierName, reqVO.getSupplierName())
|
||||
.eqIfPresent(PurReturnDO::getPurStatus, reqVO.getPurStatus())
|
||||
.eqIfPresent(PurReturnDO::getReturnStatus, reqVO.getReturnStatus())
|
||||
.eqIfPresent(PurReturnDO::getPurReceiptId, reqVO.getPurReceiptId())
|
||||
.eqIfPresent(PurReturnDO::getPurReceiptNo, reqVO.getPurReceiptNo())
|
||||
.eqIfPresent(PurReturnDO::getTwmStorageId, reqVO.getTwmStorageId())
|
||||
@ -31,4 +29,11 @@ public interface PurReturnMapper extends BaseMapperX<PurReturnDO> {
|
||||
.orderByDesc(PurReturnDO::getId));
|
||||
}
|
||||
|
||||
default String selectMaxPurReturnNo() {
|
||||
PurReturnDO purReturnDO = selectOne(new LambdaQueryWrapperX<PurReturnDO>()
|
||||
.select(PurReturnDO::getPurReturnNo)
|
||||
.orderByDesc(PurReturnDO::getId)
|
||||
.last("LIMIT 1"));
|
||||
return purReturnDO == null ? null : purReturnDO.getPurReturnNo();
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,8 @@ import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturndetail.PurRe
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购退料单子 Mapper
|
||||
*
|
||||
@ -60,7 +62,7 @@ public interface PurReturnDetailMapper extends BaseMapperX<PurReturnDetailDO> {
|
||||
.selectAs(PurReturnDO::getReceiptDate, PurReturnDetailRespVO::getReceiptDate)
|
||||
.selectAs(PurReturnDO::getSupplierId, PurReturnDetailRespVO::getSupplierId)
|
||||
.selectAs(PurReturnDO::getSupplierName, PurReturnDetailRespVO::getSupplierName)
|
||||
.selectAs(PurReturnDO::getPurStatus, PurReturnDetailRespVO::getPurStatus)
|
||||
.selectAs(PurReturnDO::getReturnStatus, PurReturnDetailRespVO::getReturnStatus)
|
||||
.selectAs(PurReturnDO::getPurReceiptId, PurReturnDetailRespVO::getPurReceiptId)
|
||||
.selectAs(PurReturnDO::getPurReceiptNo, PurReturnDetailRespVO::getPurReceiptNo)
|
||||
.selectAs(PurReturnDO::getReturnEmpId, PurReturnDetailRespVO::getReturnEmpId)
|
||||
@ -80,7 +82,7 @@ public interface PurReturnDetailMapper extends BaseMapperX<PurReturnDetailDO> {
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getStoreHouseName()), PurReturnDetailDO::getStoreHouseName, pageReqVO.getStoreHouseName())
|
||||
// 查询条件 - 主表
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getSupplierName()), PurReturnDO::getSupplierName, pageReqVO.getSupplierName())
|
||||
.eq(pageReqVO.getPurStatus() != null, PurReturnDO::getPurStatus, pageReqVO.getPurStatus())
|
||||
.eq(pageReqVO.getPurStatus() != null, PurReturnDO::getReturnStatus, pageReqVO.getPurStatus())
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getPurReceiptNo()), PurReturnDO::getPurReceiptNo, pageReqVO.getPurReceiptNo())
|
||||
.like(StringUtils.isNotBlank(pageReqVO.getReturnEmpName()), PurReturnDO::getReturnEmpName, pageReqVO.getReturnEmpName())
|
||||
.eq(pageReqVO.getBillType() != null, PurReturnDO::getBillType, pageReqVO.getBillType())
|
||||
@ -88,5 +90,14 @@ public interface PurReturnDetailMapper extends BaseMapperX<PurReturnDetailDO> {
|
||||
|
||||
return selectJoinPage(pageReqVO, PurReturnDetailRespVO.class, wrapper);
|
||||
}
|
||||
// 根据主表的ID删除子表的数据
|
||||
default void deletePurReturnDetailByPurReturnId(Integer purReturnId) {
|
||||
delete(new LambdaQueryWrapperX<PurReturnDetailDO>().eq(PurReturnDetailDO::getPurReturnId, purReturnId));
|
||||
}
|
||||
|
||||
default List<PurReturnDetailDO> selectListByPurReturnId(Integer purReturnId) {
|
||||
return selectList(new LambdaQueryWrapperX<PurReturnDetailDO>().eq(PurReturnDetailDO::getPurReturnId, purReturnId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,23 +1,39 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.service.purreturn;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.util.CodeGenerateUtils;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnPageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnRespVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailRespVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreceiptdetail.PurReceiptDetailDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturn.PurReturnDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturndetail.PurReturnDetailDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.rawstorageinventory.RawStorageInventoryDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.rawstoragelog.RawStorageLogDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.supplier.SupplierDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreceiptdetail.PurReceiptDetailMapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturn.PurReturnMapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturndetail.PurReturnDetailMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.rawstorageinventory.RawStorageInventoryMapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.service.rawstorageinventory.RawStorageInventoryService;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.service.rawstoragelog.RawStorageLogService;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.service.supplier.SupplierService;
|
||||
import com.ningxia.yunxi.chemmes.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.ningxia.yunxi.chemmes.module.system.service.user.AdminUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.ningxia.yunxi.chemmes.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* 采购退料单主 Service 实现类
|
||||
@ -26,38 +42,138 @@ import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceE
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class PurReturnServiceImpl implements PurReturnService {
|
||||
|
||||
@Resource
|
||||
private PurReturnMapper purReturnMapper;
|
||||
private final PurReturnMapper purReturnMapper;
|
||||
|
||||
private final PurReturnDetailMapper purReturnDetailMapper;
|
||||
|
||||
private final AdminUserService adminUserService;
|
||||
|
||||
private final PurReceiptDetailMapper purreceiptDetailMapper;
|
||||
|
||||
private final RawStorageInventoryService rawStorageInventoryService;
|
||||
|
||||
private final RawStorageInventoryMapper rawStorageInventoryMapper;
|
||||
|
||||
private final SupplierService supplierService;
|
||||
|
||||
private final RawStorageLogService rawStorageLogService;
|
||||
|
||||
@Resource
|
||||
private PurReturnDetailMapper purReturnDetailMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer createPurReturn(PurReturnSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
// 插入主表
|
||||
PurReturnDO purReturn = BeanUtils.toBean(createReqVO, PurReturnDO.class);
|
||||
Long userId = getLoginUserId();
|
||||
AdminUserDO adminUserDO = adminUserService.getUser(userId);
|
||||
purReturn.setReturnEmpId(adminUserDO.getId());
|
||||
purReturn.setReturnEmpName(adminUserDO.getUsername());
|
||||
purReturn.setPurReturnNo(generateBillNo());
|
||||
purReturnMapper.insert(purReturn);
|
||||
saveDetails(createReqVO, purReturn.getId());
|
||||
if ("2".equals(createReqVO.getReturnStatus())) {
|
||||
processReturn(purReturn);
|
||||
}
|
||||
|
||||
// 返回
|
||||
return purReturn.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePurReturn(PurReturnSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePurReturnExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PurReturnDO updateObj = BeanUtils.toBean(updateReqVO, PurReturnDO.class);
|
||||
purReturnMapper.updateById(updateObj);
|
||||
private void saveDetails(PurReturnSaveReqVO createReqVO, Integer purReturn) {
|
||||
// 插入子表
|
||||
for (PurReturnDetailSaveReqVO detailReqVO : createReqVO.getItems()) {
|
||||
PurReturnDetailDO detail = BeanUtils.toBean(detailReqVO, PurReturnDetailDO.class);
|
||||
detail.setPurReturnId(purReturn);
|
||||
detail.setId(null);
|
||||
purReturnDetailMapper.insert(detail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePurReturn(PurReturnSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePurReturnExists(updateReqVO.getId());
|
||||
// 更新主表
|
||||
PurReturnDO updateObj = BeanUtils.toBean(updateReqVO, PurReturnDO.class);
|
||||
Long userId = getLoginUserId();
|
||||
AdminUserDO adminUserDO = adminUserService.getUser(userId);
|
||||
updateObj.setReturnEmpId(userId);
|
||||
updateObj.setReturnEmpName(adminUserDO.getUsername());
|
||||
purReturnMapper.updateById(updateObj);
|
||||
|
||||
// 删除原有子表数据
|
||||
purReturnDetailMapper.deletePurReturnDetailByPurReturnId(updateReqVO.getId());
|
||||
|
||||
// 插入新子表数据
|
||||
saveDetails(updateReqVO, updateReqVO.getId());
|
||||
if ("2".equals(updateReqVO.getReturnStatus())) {
|
||||
processReturn(updateObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processReturn(PurReturnDO purReturnDO) {
|
||||
List<PurReturnDetailDO> purReturnDetailDOS = purReturnDetailMapper.selectListByPurReturnId(purReturnDO.getId());
|
||||
SupplierDO supplier = supplierService.getSupplier(purReturnDO.getSupplierId());
|
||||
for (PurReturnDetailDO purReturnDetailDO : purReturnDetailDOS) {
|
||||
PurReceiptDetailDO purReceiptDetailDO = purreceiptDetailMapper.selectById(purReturnDetailDO.getPurReceiptDetailId());
|
||||
RawStorageInventoryDO rawStorageInventory = rawStorageInventoryMapper.selectOne(new LambdaQueryWrapper<RawStorageInventoryDO>().eq(RawStorageInventoryDO::getInventBillNo, purReturnDetailDO.getInventBillNo()));
|
||||
rawStorageInventory.setYardQty(rawStorageInventory.getYardQty().subtract(purReturnDetailDO.getReturnQty()));
|
||||
purReceiptDetailDO.setReturnQty(purReceiptDetailDO.getReturnQty().add(purReturnDetailDO.getReturnQty()));
|
||||
purreceiptDetailMapper.updateById(purReceiptDetailDO);
|
||||
//twm_raw_storage_log 插入
|
||||
RawStorageLogDO rawStorageLog = new RawStorageLogDO();
|
||||
// rawStorageLog.setStockId();
|
||||
rawStorageLog.setStatus("2");
|
||||
rawStorageLog.setStoreHouseId(purReturnDetailDO.getStoreHouseId());
|
||||
rawStorageLog.setStoreAreaId(purReturnDetailDO.getStoreAreaId());
|
||||
rawStorageLog.setStoreHouseCd(purReturnDetailDO.getStoreHouseCd());
|
||||
rawStorageLog.setStoreHouseName(purReturnDetailDO.getStoreHouseName());
|
||||
rawStorageLog.setStoreAreCd(purReturnDetailDO.getStoreAreCd());
|
||||
rawStorageLog.setStoreAreaName(purReturnDetailDO.getStoreAreaName());
|
||||
rawStorageLog.setMaterialId(purReturnDetailDO.getMaterialId());
|
||||
rawStorageLog.setMatName(purReturnDetailDO.getMaterialName());
|
||||
rawStorageLog.setMatCode(purReturnDetailDO.getMaterialCode());
|
||||
rawStorageLog.setSpec(purReturnDetailDO.getSpec());
|
||||
rawStorageLog.setUnit(purReturnDetailDO.getUnit());
|
||||
rawStorageLog.setLotNo(purReturnDetailDO.getLotNo());
|
||||
rawStorageLog.setOperatorQty(purReturnDetailDO.getReturnQty());
|
||||
rawStorageLog.setOperatorType("2");
|
||||
rawStorageLog.setBusinessType("23");
|
||||
// rawStorageLog.setStorageAft();
|
||||
// rawStorageLog.setStorageBef();
|
||||
// rawStorageLog.setStockItemId();
|
||||
// rawStorageLog.setDpstNo();
|
||||
rawStorageLog.setSupplierNo(supplier.getSupplierNo());
|
||||
rawStorageLog.setSupplierName(purReturnDO.getSupplierName());
|
||||
rawStorageLog.setSupplierId(purReturnDO.getSupplierId());
|
||||
// rawStorageLog.setPurQty();
|
||||
rawStorageLog.setBillDate(LocalDate.now());
|
||||
rawStorageLog.setOperatorId(purReturnDO.getReturnEmpId());
|
||||
rawStorageLog.setOperatorName(purReturnDO.getReturnEmpName());
|
||||
rawStorageLog.setRelarionNo(purReturnDO.getPurReturnNo());
|
||||
rawStorageLog.setRelarionId(purReturnDO.getId());
|
||||
rawStorageLog.setRelarionDetailId(purReturnDetailDO.getId());
|
||||
rawStorageLog.setInventBillNo(purReturnDetailDO.getInventBillNo());
|
||||
rawStorageLogService.saveRawStorageLog(rawStorageLog);
|
||||
rawStorageInventoryMapper.updateById(rawStorageInventory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deletePurReturn(Integer id) {
|
||||
// 校验存在
|
||||
validatePurReturnExists(id);
|
||||
// 删除
|
||||
purReturnMapper.deleteById(id);
|
||||
purReturnDetailMapper.deletePurReturnDetailByPurReturnId(id);
|
||||
|
||||
}
|
||||
|
||||
private void validatePurReturnExists(Integer id) {
|
||||
@ -90,7 +206,11 @@ public class PurReturnServiceImpl implements PurReturnService {
|
||||
|
||||
// 转换子表数据
|
||||
List<PurReturnDetailRespVO> detailRespVOList = BeanUtils.toBean(detailList, PurReturnDetailRespVO.class);
|
||||
respVO.setReturnDetailList(detailRespVOList);
|
||||
for (PurReturnDetailRespVO purReturnDetailRespVO : detailRespVOList) {
|
||||
PurReceiptDetailDO purReceiptDetailDO = purreceiptDetailMapper.selectById(purReturnDetailRespVO.getPurReceiptDetailId());
|
||||
purReturnDetailRespVO.setInStorageTime(purReceiptDetailDO.getCreateTime());
|
||||
}
|
||||
respVO.setItems(detailRespVOList);
|
||||
|
||||
return respVO;
|
||||
}
|
||||
@ -100,4 +220,11 @@ public class PurReturnServiceImpl implements PurReturnService {
|
||||
return purReturnMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// 生成单号
|
||||
private String generateBillNo() {
|
||||
String maxPurReturnNo = purReturnMapper.selectMaxPurReturnNo();
|
||||
return CodeGenerateUtils.generateBillNo("SCT", maxPurReturnNo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -165,13 +165,6 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
|
||||
List<SaleDeliveryDetailDO> detailList = saleDeliveryDetailMapper.selectBySaleDeliveryId(id);
|
||||
// 转换为子表VO列表
|
||||
saleDeliveryVO.setDetailList(BeanUtils.toBean(detailList, SaleDeliveryDetailSaveReqVO.class));
|
||||
for (SaleDeliveryDetailSaveReqVO saleDeliveryDetailSaveReqVO : saleDeliveryVO.getDetailList()) {
|
||||
ProStorageInventoryDO storageInventoryDO = proStorageInventoryMapper.selectById(saleDeliveryDetailSaveReqVO.getTwmStorageDetailId());
|
||||
if (storageInventoryDO != null) {
|
||||
saleDeliveryDetailSaveReqVO.setStockQty(storageInventoryDO.getYardQty());
|
||||
saleDeliveryDetailSaveReqVO.setStockBag(storageInventoryDO.getPackQty());
|
||||
}
|
||||
}
|
||||
return saleDeliveryVO;
|
||||
}
|
||||
|
||||
@ -217,7 +210,8 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
|
||||
// 存入 proStorageLogService
|
||||
for (SaleDeliveryDetailDO saleDeliveryDetailDO : detailList) {
|
||||
ProStorageLogDO proStorageLogDO = ProStorageLogDO.builder()
|
||||
.stockId(saleDeliveryDetailDO.getId())
|
||||
// .stockId(saleDeliveryDetailDO.getId())
|
||||
// .stockItemId(saleDeliveryDetailDO.getId())
|
||||
.description("销售出库")
|
||||
.status("2")
|
||||
.storeHouseId(saleDeliveryDetailDO.getStoreHouseId())
|
||||
@ -235,7 +229,6 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
|
||||
.operatorQty(saleDeliveryDetailDO.getDeliveriedQty())
|
||||
.operatorType("2")
|
||||
.businessType("21")
|
||||
.stockItemId(saleDeliveryDetailDO.getId())
|
||||
.billDate(LocalDate.now())
|
||||
.operatorId(saleDelivery.getDeliveryEmpId())
|
||||
.operatorName(saleDelivery.getDeliveryEmpName())
|
||||
@ -272,8 +265,8 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
|
||||
}
|
||||
|
||||
BigDecimal deliveriedQty = detail.getDeliveriedQty() != null ? detail.getDeliveriedQty() : BigDecimal.ZERO;
|
||||
if (inventory.getUseQty().compareTo(deliveriedQty) < 0) {
|
||||
throw exception("库存不足:当前可用数量[" + inventory.getUseQty() + "] < 发货数量[" + deliveriedQty + "]");
|
||||
if (inventory.getYardQty().compareTo(deliveriedQty) < 0) {
|
||||
throw exception("库存不足:当前可用数量[" + inventory.getYardQty() + "] < 发货数量[" + deliveriedQty + "]");
|
||||
}
|
||||
|
||||
inventory.setUseQty(inventory.getUseQty().subtract(deliveriedQty));
|
||||
|
||||
@ -6,7 +6,7 @@ export interface PurReturnVO {
|
||||
receiptDate: localdate
|
||||
supplierId: number
|
||||
supplierName: string
|
||||
purStatus: string
|
||||
returnStatus: string
|
||||
remark: string
|
||||
purReceiptId: number
|
||||
purReceiptNo: string
|
||||
|
||||
@ -7,8 +7,6 @@ export {}
|
||||
declare global {
|
||||
const DICT_TYPE: typeof import('@/utils/dict')['DICT_TYPE']
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const ElMessage: typeof import('element-plus/es')['ElMessage']
|
||||
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import * as PurReceiptApi from '@/api/biz/purreceipt'
|
||||
import * as PurReceiptDetailApi from '@/api/biz/purreceiptdetail'
|
||||
import Dialog from '@/components/Dialog/src/Dialog.vue'
|
||||
import Pagination from '@/components/Pagination/index.vue'
|
||||
|
||||
@ -117,7 +117,7 @@ const queryParams = reactive({
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await PurReceiptApi.getPurReceiptPage(queryParams)
|
||||
const data = await PurReceiptDetailApi.getPurReceiptDetailPage(queryParams)
|
||||
receiptList.value = data.list || []
|
||||
total.value = data.total || 0
|
||||
} finally {
|
||||
@ -170,6 +170,7 @@ const handleSave = () => {
|
||||
// 转换数据格式
|
||||
const selectData = selectedRows.map(row => ({
|
||||
id: row.id,
|
||||
purReceiptDetailId: row.id,
|
||||
purReceiptNo: row.purReceiptNo,
|
||||
billType: row.billType,
|
||||
receiptDate: row.receiptDate,
|
||||
@ -180,11 +181,17 @@ const handleSave = () => {
|
||||
returnedQty: row.returnedQty || 0,
|
||||
spec: row.spec,
|
||||
storeHouseName: row.storeHouseName,
|
||||
storeHouseId: row.storeHouseId,
|
||||
storeHouseCd: row.storeHouseCd,
|
||||
storeAreaId: row.storeAreaId,
|
||||
storeAreCd: row.storeAreCd,
|
||||
storeAreaName: row.storeAreaName,
|
||||
unit: row.unit,
|
||||
supplierId: row.supplierId,
|
||||
materialId: row.materialId,
|
||||
purReceiptId: row.purReceiptId,
|
||||
lotNo: row.lotNo,
|
||||
inventBillNo: row.inventBillNo,
|
||||
}))
|
||||
|
||||
emit('select', selectData)
|
||||
|
||||
@ -51,8 +51,8 @@
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="单据状态" prop="purStatus">
|
||||
<el-select v-model="formData.purStatus" disabled class="!w-full">
|
||||
<el-form-item label="单据状态" prop="returnStatus">
|
||||
<el-select v-model="formData.returnStatus" disabled class="!w-full">
|
||||
<el-option label="已创建" value="1" />
|
||||
<el-option label="已确认" value="2" />
|
||||
</el-select>
|
||||
@ -128,19 +128,10 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="批次号" prop="lotNo" min-width="100px" align="center">
|
||||
<template #default="scope">
|
||||
<el-input
|
||||
v-model="scope.row.lotNo"
|
||||
placeholder="请输入"
|
||||
:disabled="formType === 'detail'"
|
||||
class="!w-120px"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="批次号" prop="lotNo" min-width="100px" align="center" />
|
||||
<el-table-column label="仓储名称" prop="storeHouseName" min-width="120px" align="center" />
|
||||
<el-table-column label="库区名称" prop="storeAreaName" min-width="120px" align="center" />
|
||||
<el-table-column label="入库日期" prop="receiptDate" min-width="100px" align="center" />
|
||||
<el-table-column label="入库日期" prop="inStorageTime" min-width="100px" align="center" :formatter="dateFormatter2" />
|
||||
<el-table-column label="单位" prop="unit" min-width="60px" align="center" :formatter="getUnitName" />
|
||||
<el-table-column label="操作" min-width="80px" align="center">
|
||||
<template #default="scope">
|
||||
@ -159,7 +150,6 @@
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleSave"
|
||||
@ -169,9 +159,11 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleConfirm"
|
||||
:disabled="formLoading || formData.purStatus === '2'"
|
||||
:disabled="formLoading || formData.returnStatus === '2'"
|
||||
v-if="formType !== 'detail'"
|
||||
>确认</el-button>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
@ -185,8 +177,8 @@ import Dialog from '@/components/Dialog/src/Dialog.vue'
|
||||
import PurReceiptSelectDialog from './PurReceiptSelectDialog.vue'
|
||||
import * as PurReturnApi from '@/api/biz/purreturn'
|
||||
import * as SupplierApi from '@/api/biz/supplier'
|
||||
import * as PurReceiptApi from '@/api/biz/purreceipt'
|
||||
import { getUnitName } from '@/utils/dict'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
@ -207,7 +199,7 @@ const formData = reactive({
|
||||
receiptDate: new Date().toISOString().split('T')[0],
|
||||
supplierId: undefined,
|
||||
supplierName: undefined,
|
||||
purStatus: '1',
|
||||
returnStatus: '1',
|
||||
remark: undefined,
|
||||
purReceiptId: undefined,
|
||||
purReceiptNo: undefined,
|
||||
@ -251,12 +243,7 @@ const open = async (type: string, id?: number) => {
|
||||
const data = await PurReturnApi.getPurReturn(id)
|
||||
Object.assign(formData, data)
|
||||
// 加载明细数据
|
||||
detailList.value = data?.items || data?.detailList || []
|
||||
// 设置供应商名称
|
||||
const supplier = supplierOptions.value.find(s => s.id === formData.supplierId)
|
||||
if (supplier) {
|
||||
formData.supplierName = supplier.supplierName
|
||||
}
|
||||
detailList.value = data.items || []
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
@ -339,6 +326,9 @@ const handleSave = async () => {
|
||||
|
||||
formLoading.value = true
|
||||
|
||||
// 保存时强制设置 returnStatus = 1
|
||||
formData.returnStatus = '1'
|
||||
|
||||
const data = {
|
||||
...formData,
|
||||
items: detailList.value,
|
||||
@ -381,7 +371,7 @@ const handleConfirm = async () => {
|
||||
|
||||
formLoading.value = true
|
||||
|
||||
formData.purStatus = '2'
|
||||
formData.returnStatus = '2'
|
||||
const data = {
|
||||
...formData,
|
||||
items: detailList.value,
|
||||
@ -409,7 +399,7 @@ const resetForm = () => {
|
||||
receiptDate: new Date().toISOString().split('T')[0],
|
||||
supplierId: undefined,
|
||||
supplierName: undefined,
|
||||
purStatus: '1',
|
||||
returnStatus: '1',
|
||||
remark: undefined,
|
||||
purReceiptId: undefined,
|
||||
purReceiptNo: undefined,
|
||||
@ -419,7 +409,6 @@ const resetForm = () => {
|
||||
billType: '3',
|
||||
})
|
||||
detailList.value = []
|
||||
purReceiptOptions.value = []
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
|
||||
@ -47,9 +47,9 @@
|
||||
class="!w-200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="单据状态" prop="purStatus">
|
||||
<el-form-item label="单据状态" prop="returnStatus">
|
||||
<el-select
|
||||
v-model="queryParams.purStatus"
|
||||
v-model="queryParams.returnStatus"
|
||||
placeholder="请选择单据状态"
|
||||
clearable
|
||||
class="!w-150px"
|
||||
@ -98,10 +98,10 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="退料单号" align="center" prop="purReturnNo" />
|
||||
<el-table-column label="供应商" align="center" prop="supplierName" width="300px" />
|
||||
<el-table-column label="单据状态" align="center" prop="purStatus" >
|
||||
<el-table-column label="单据状态" align="center" prop="returnStatus" >
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.purStatus === '1'" class="text-blue">已创建</span>
|
||||
<span v-else-if="scope.row.purStatus === '2'" class="text-green">已确认</span>
|
||||
<span v-if="scope.row.returnStatus === '1'" class="text-blue">已创建</span>
|
||||
<span v-else-if="scope.row.returnStatus === '2'" class="text-green">已确认</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -115,7 +115,7 @@
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['biz:pur-return:update']"
|
||||
v-if="scope.row.purStatus === '1' "
|
||||
v-if="scope.row.returnStatus === '1' "
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
@ -124,7 +124,7 @@
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['biz:pur-return:delete']"
|
||||
v-if="scope.row.purStatus === '1' "
|
||||
v-if="scope.row.returnStatus === '1' "
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
@ -241,10 +241,6 @@ const getDetailList = async (id: number) => {
|
||||
}
|
||||
// 后端返回的数据中,明细在items字段中
|
||||
detailList.value = data?.items || data || []
|
||||
// 将主信息中的仓储名称和库区名称填充到每个明细项中
|
||||
detailList.value.forEach(item => {
|
||||
item.storeHouseName = mainInfo.value.storeHouseName
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('获取退料物料详情失败:', error)
|
||||
detailList.value = []
|
||||
|
||||
@ -128,8 +128,8 @@
|
||||
<el-table-column label="仓库" prop="warehouse" min-width="150px" align="center" />
|
||||
<el-table-column label="库区" prop="warehouseArea" min-width="150px" align="center" />
|
||||
<el-table-column label="批次号" prop="batchNo" min-width="150px" align="center" />
|
||||
<el-table-column label="库存数量" prop="stockQty" min-width="150px" align="center" />
|
||||
<el-table-column label="库存袋数" prop="stockBag" min-width="150px" align="center" />
|
||||
<el-table-column label="库存数量" prop="yardQty" min-width="150px" align="center" />
|
||||
<el-table-column label="库存袋数" prop="packQty" min-width="150px" align="center" />
|
||||
<el-table-column label="单袋规格" prop="bagSpec" min-width="150px" align="center" />
|
||||
<el-table-column label="发货袋数" prop="deliveriedBag" min-width="120px" align="center" />
|
||||
<el-table-column label="发货数量" prop="deliveriedQty" min-width="120px" align="center" />
|
||||
@ -254,8 +254,8 @@ const open = async (id: number) => {
|
||||
warehouse: item.storeHouseName || '',
|
||||
warehouseArea: item.storeAreaName || '',
|
||||
batchNo: item.lotNo || '',
|
||||
stockQty: item.stockQty || '',
|
||||
stockBag: item.stockBag || '',
|
||||
yardQty: item.yardQty || '',
|
||||
packQty: item.packQty || '',
|
||||
bagSpec: item.bagSpec || '',
|
||||
deliveriedBag: item.deliveriedBagQty || item.deliveriedBag || '',
|
||||
deliveriedQty: item.deliveriedQty || '',
|
||||
|
||||
@ -169,14 +169,14 @@
|
||||
{{ scope.row.batchNo }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存数量" prop="stockQty" min-width="150px" align="center">
|
||||
<el-table-column label="库存数量" prop="yardQty" min-width="150px" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.stockQty }}
|
||||
{{ scope.row.yardQty }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存袋数" prop="stockBag" min-width="150px" align="center">
|
||||
<el-table-column label="库存袋数" prop="packQty" min-width="150px" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.stockBag }}
|
||||
{{ scope.row.packQty }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单袋规格" prop="bagSpec" min-width="150px" align="center">
|
||||
@ -505,8 +505,9 @@ const open = async (type: string, id?: number) => {
|
||||
deliveriedBag: item.deliveriedBagQty || '',
|
||||
deliveriedQty: item.deliveriedQty || '',
|
||||
remark: item.remark || '',
|
||||
stockQty: item.stockQty || '',
|
||||
stockBag: item.stockBag || '',
|
||||
yardQty: item.yardQty || item.stockQty || '',
|
||||
packQty: item.packQty || item.stockBag || '',
|
||||
inventBillNo: item.inventBillNo || '',
|
||||
}))
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
@ -698,6 +699,8 @@ const handleInventorySelect = (data: any[]) => {
|
||||
deliveriedQty: '', // 发货数量
|
||||
remark: '', // 备注
|
||||
inventBillNo: inventory.inventBillNo, // 库存单号
|
||||
packQty: inventory.packQty || 0, // 库存袋数
|
||||
yardQty: inventory.yardQty || 0, // 库存数量
|
||||
})
|
||||
}
|
||||
// 如果已存在,不做处理
|
||||
@ -835,6 +838,8 @@ const submitForm = async () => {
|
||||
deliveriedQty: item.deliveriedQty,
|
||||
remark: item.remark,
|
||||
inventBillNo: item.inventBillNo,
|
||||
packQty: item.packQty || 0,
|
||||
yardQty: item.yardQty || 0,
|
||||
// 库存单号
|
||||
}))
|
||||
|
||||
@ -888,6 +893,8 @@ const submitAudit = async () => {
|
||||
deliveriedQty: item.deliveriedQty,
|
||||
remark: item.remark,
|
||||
inventBillNo: item.inventBillNo,
|
||||
packQty: item.packQty || '',
|
||||
yardQty: item.yardQty || '',
|
||||
// 库存单号
|
||||
}))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user