| | |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnSaleProductMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnManagement; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.*; |
| | |
| | | private QualityInspectMapper qualityInspectMapper; |
| | | private ShippingInfoMapper shippingInfoMapper; |
| | | private ShippingInfoServiceImpl shippingInfoService; |
| | | private ReturnSaleProductMapper returnSaleProductMapper; |
| | | private ReturnManagementMapper returnManagementMapper; |
| | | |
| | | |
| | | private StockUtils stockUtils; |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<SalesLedgerProduct> selectSalesLedgerProductList(SalesLedgerProduct salesLedgerProduct) { |
| | | // LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | // queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedgerProduct.getSalesLedgerId()) |
| | | // .eq(SalesLedgerProduct::getType, salesLedgerProduct.getType()); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectSalesLedgerProductList(salesLedgerProduct); |
| | | if(!CollectionUtils.isEmpty(salesLedgerProducts)){ |
| | | salesLedgerProducts.forEach(item -> { |
| | |
| | | if (processRoute == null) { |
| | | return R.fail("请先设置工艺路线"); |
| | | } |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomId(processRoute.getBomId()); |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomId(processRoute.getBomId(),false); |
| | | if (productStructureDtos.isEmpty()) { |
| | | return R.fail("请先设置产品结构"); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String cancelDelivery(SalesLedgerProduct salesLedgerProduct) { |
| | | List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new QueryWrapper<ShippingInfo>() |
| | | .lambda() |
| | | .eq(ShippingInfo::getSalesLedgerProductId, salesLedgerProduct.getId()) |
| | | .in(ShippingInfo::getStatus, "已发货", "发货中")); |
| | | if(CollectionUtils.isEmpty(shippingInfos)){ |
| | | throw new RuntimeException("没有可取消的发货信息"); |
| | | } |
| | | shippingInfos.forEach(item -> { |
| | | item.setStatus("已撤销"); |
| | | shippingInfoMapper.updateById(item); |
| | | }); |
| | | List<ReturnSaleProduct> returnSaleProducts = returnSaleProductMapper.selectList(new LambdaQueryWrapper<ReturnSaleProduct>() |
| | | .eq(ReturnSaleProduct::getReturnSaleLedgerProductId, salesLedgerProduct.getId()) |
| | | .eq(ReturnSaleProduct::getStatus, 1)); |
| | | if(CollectionUtils.isEmpty(returnSaleProducts)){ |
| | | throw new RuntimeException("没有可取消的退货信息"); |
| | | } |
| | | returnSaleProducts.forEach(item -> { |
| | | item.setStatus(2); |
| | | returnSaleProductMapper.updateById(item); |
| | | }); |
| | | List<ReturnManagement> returnManagements = returnManagementMapper.selectList(new QueryWrapper<ReturnManagement>() |
| | | .lambda() |
| | | .in(ReturnManagement::getId, returnSaleProducts.stream().map(ReturnSaleProduct::getReturnManagementId).collect(Collectors.toSet()))); |
| | | if(CollectionUtils.isEmpty(returnManagements)){ |
| | | throw new RuntimeException("没有可取消的退货信息"); |
| | | } |
| | | returnManagements.forEach(item -> { |
| | | item.setStatus(2); |
| | | returnManagementMapper.updateById(item); |
| | | }); |
| | | return "撤销成功"; |
| | | } |
| | | } |