zss
18 小时以前 40946ba6c24a0318f14cbed603f0ed9cad1da853
Merge remote-tracking branch 'origin/jtwy' into jtwy
已修改2个文件
86 ■■■■■ 文件已修改
src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
@@ -8,6 +8,7 @@
import com.ruoyi.procurementrecord.dto.ProcurementPageDto;
import com.ruoyi.procurementrecord.dto.ProcurementPageDtoCopy;
import com.ruoyi.procurementrecord.service.ProcurementRecordService;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.service.ISalesLedgerProductService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +42,8 @@
    private ISalesLedgerProductService salesLedgerProductService;
    @Autowired
    private ProcurementRecordService procurementRecordService;
    @Autowired
    private StockUtils stockUtils;
    /**
     * 查询产品信息列表
     */
@@ -55,13 +58,14 @@
            if (item.getFutureTicketsAmount().compareTo(BigDecimal.ZERO) == 0) {
                item.setFutureTicketsAmount(item.getTaxInclusiveTotalPrice());
            }
            ProcurementPageDto procurementDto = new ProcurementPageDto();
            procurementDto.setSalesLedgerProductId(item.getId());
            procurementDto.setProductCategory(item.getProductCategory());
            IPage<ProcurementPageDtoCopy> result = procurementRecordService.listPageCopyByProduction(new Page<>(1,-1), procurementDto);
            if(result.getRecords().size()>0) {
                ProcurementPageDtoCopy procurementDtoCopy = result.getRecords().get(0);
                if (item.getQuantity().compareTo(procurementDtoCopy.getInboundNum0()) >= 0 && item.getApproveStatus() == 0) {
//            ProcurementPageDto procurementDto = new ProcurementPageDto();
//            procurementDto.setSalesLedgerProductId(item.getId());
//            procurementDto.setProductCategory(item.getProductCategory());
//            IPage<ProcurementPageDtoCopy> result = procurementRecordService.listPageCopyByProduction(new Page<>(1,-1), procurementDto);
            BigDecimal stockQuantity = stockUtils.getStockQuantity(item.getProductModelId()).get("stockQuantity");
            if(stockQuantity != null) {
//                ProcurementPageDtoCopy procurementDtoCopy = result.getRecords().get(0);
                if (item.getQuantity().compareTo(stockQuantity) >= 0 && item.getApproveStatus() == 0) {
                    item.setApproveStatus(1);
                    salesLedgerProductService.addOrUpdateSalesLedgerProduct(item);
                }
src/main/java/com/ruoyi/sales/controller/ShipmentApprovalController.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
@@ -60,41 +61,60 @@
    @ApiOperation("发货审批,更新发货审批状态")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult update(@RequestBody ShipmentApproval req) {
        //  查询发货审批
        ShipmentApproval shipmentApproval = shipmentApprovalMapper.selectById(req.getId());
        if (shipmentApproval == null) {
            return AjaxResult.error("发货审批不存在");
        }
        //  更新发货审批状态
        shipmentApproval.setApproveStatus(req.getApproveStatus());
        boolean update = shipmentApprovalService.updateById(shipmentApproval);
        if(update){
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(shipmentApproval.getSalesLedgerProductId());
            salesLedgerProduct.setApproveStatus(req.getApproveStatus());
            salesLedgerProductService.updateById(salesLedgerProduct);
            if(req.getApproveStatus()==3){
                ProcurementRecordStorage procurementRecordStorage = procurementRecordStorageService.getOne(new LambdaQueryWrapper<ProcurementRecordStorage>()
                        .eq(ProcurementRecordStorage::getSalesLedgerProductId, req.getSalesLedgerProductId()));
                if(procurementRecordStorage==null){
                    return AjaxResult.error("采购记录不存在");
                }
                //发货审批通过,生产该订单出库记录
                ProcurementRecordOutAdd procurementRecordOutAdd = new ProcurementRecordOutAdd();
                procurementRecordOutAdd.setId(procurementRecordStorage.getId());
                procurementRecordOutAdd.setSalesLedgerProductId(Math.toIntExact(salesLedgerProduct.getId()));
                procurementRecordOutAdd.setType(2);
                procurementRecordOutAdd.setUserId(Math.toIntExact(getUserId()));
                procurementRecordOutAdd.setQuantity(String.valueOf(salesLedgerProduct.getQuantity()));
                //获取当前时间
                LocalDate now = LocalDate.now();
                procurementRecordOutAdd.setTime(now.toString());
                procurementRecordOutService.stockout(procurementRecordOutAdd);
            }
        if (!update) {
            //  事务回滚
            throw new ServiceException("发货审批更新失败");
        }
        return update ? AjaxResult.success() : AjaxResult.error();
        //  查询关联的销售台账产品
        SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(shipmentApproval.getSalesLedgerProductId());
        if (salesLedgerProduct == null) {
            //  抛异常事务回滚
            throw new ServiceException("销售台账不存在,审批回滚");
        }
        //  同步更新销售台账产品的审批状态
        salesLedgerProduct.setApproveStatus(req.getApproveStatus());
        salesLedgerProductService.updateById(salesLedgerProduct);
        //  审批通过
        if (req.getApproveStatus() == 3) {
            // 查询采购入库记录
            LambdaQueryWrapper<ProcurementRecordStorage> lambdaQueryWrapper = new LambdaQueryWrapper<ProcurementRecordStorage>()
                    .eq(ProcurementRecordStorage::getSalesLedgerProductId, req.getSalesLedgerProductId());
            ProcurementRecordStorage procurementRecordStorage = procurementRecordStorageService.getOne(lambdaQueryWrapper);
            if (procurementRecordStorage == null) {
                // 保证前面的修改全部回滚
                throw new ServiceException("采购记录不存在,审批回滚");
            }
            //  生成出库记录
            ProcurementRecordOutAdd procurementRecordOutAdd = new ProcurementRecordOutAdd();
            procurementRecordOutAdd.setId(procurementRecordStorage.getId());
            procurementRecordOutAdd.setSalesLedgerProductId(Math.toIntExact(salesLedgerProduct.getId()));
            procurementRecordOutAdd.setType(2);
            procurementRecordOutAdd.setUserId(Math.toIntExact(getUserId()));
            procurementRecordOutAdd.setQuantity(salesLedgerProduct.getQuantity().toPlainString());
            procurementRecordOutAdd.setTime(LocalDate.now().toString());
            procurementRecordOutService.stockout(procurementRecordOutAdd);
        }
        return AjaxResult.success();
    }
    /**
     * 导出发货信息管理
     */