From e13ff7551e6cbc9e070c3d8b5ae9c1dabbc4390d Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Wed, 6 Nov 2024 13:38:25 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=94=AE=E5=90=8E=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93=E5=87=86=E5=A4=87?= =?UTF-8?q?=E7=89=A9=E6=96=99=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=A1=E9=AA=8C=E5=AD=90=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E6=B3=95=E3=80=81=E6=9B=B4=E6=96=B0=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8D=95=E8=AF=A6=E6=83=85=E6=95=B0=E6=8D=AE=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=80=81=E7=94=9F=E6=88=90=E5=94=AE=E5=90=8E=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8D=95=E6=96=B9=E6=B3=95=E3=80=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=87=BA=E5=BA=93=E5=8D=95=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E3=80=82=20=E5=94=AE=E5=90=8E=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E8=AE=BE=E5=A4=87=E5=87=BA=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=89=B9=E9=87=8F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=94=AE=E5=90=8E=E7=BB=B4=E6=8A=A4=E8=AE=BE=E5=A4=87=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E8=AF=A6=E6=83=85=E5=90=8E=E7=AB=AF=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AftersalesOutOrderDetailMapper.java | 6 + .../impl/WarehouseOutOrderServiceImpl.java | 99 +++++++++++++--- .../AftersalesOutOrderDetailMapper.xml | 110 ++++++++++++++++++ .../warehouse/WarehouseOutOrderMapper.xml | 1 + 4 files changed, 202 insertions(+), 14 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOutOrderDetailMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOutOrderDetailMapper.java index 660374cd..7a93f0ed 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOutOrderDetailMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOutOrderDetailMapper.java @@ -74,4 +74,10 @@ public interface AftersalesOutOrderDetailMapper * @return 结果 */ public int restoreAftersalesOutOrderDetailById(Long outOrderDetailId); + + /** + * 批量新增售后维护设备出库详情 + * */ + int insertBatchAftersalesOutOrderDetail(List aftersalesOutOrderDetails); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java index 3480711b..0cd82f3b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java @@ -4,6 +4,10 @@ import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; +import com.ruoyi.aftersales.domain.AftersalesOutOrder; +import com.ruoyi.aftersales.domain.AftersalesOutOrderDetail; +import com.ruoyi.aftersales.mapper.AftersalesOutOrderDetailMapper; +import com.ruoyi.aftersales.mapper.AftersalesOutOrderMapper; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; @@ -25,6 +29,7 @@ import com.ruoyi.warehouse.mapper.WarehouseInventoryInquiryDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseInventoryInquiryMapper; import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; @@ -95,6 +100,12 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService @Autowired private QualityRefundsExchangesMapper refundsExchangesMapper; + @Autowired + private AftersalesOutOrderMapper aftersalesOutOrderMapper; + + @Autowired + private AftersalesOutOrderDetailMapper aftersalesOutOrderDetailMapper; + /** * 查询仓库出库单 * @@ -200,7 +211,7 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService /** * 修改保存销售单-准备物料 * */ - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public int updatePrepareMaterial(WarehouseOutOrder warehouseOutOrder) { @@ -216,19 +227,15 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService } //过滤掉准备出库数为0的数据,相当于本次不出库 List filterOutOrderDetailList = warehouseOutOrderDetailList.stream().filter(item -> item.getPrepareOutOrderSum() != 0).collect(Collectors.toList()); - for (WarehouseOutOrderDetail warehouseOutOrderDetail : filterOutOrderDetailList) { - warehouseOutOrderDetail.setUpdateBy(loginName); - warehouseOutOrderDetail.setUpdateTime(new Date()); - warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark()); - Integer prepareOutOrderSum = warehouseOutOrderDetail.getPrepareOutOrderSum(); - Integer applyOutOrderSum = warehouseOutOrderDetail.getApplyOutOrderSum(); - //准备出库数 必须等于 申请出库数 - if (!Objects.equals(prepareOutOrderSum, applyOutOrderSum)){ - throw new BusinessException("准备出库数必须等于申请出库数"); - } - //更新数据库记录 - int updateOutOrderDetail = outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); - if (updateOutOrderDetail <= 0){ + + // 校验子表数据 + checkWarehouseOutOrderDetailList(filterOutOrderDetailList, loginName,warehouseOutOrder); + + + // 更新出库单详情数据 + for (WarehouseOutOrderDetail detail : filterOutOrderDetailList) { + int updateResult = outOrderDetailMapper.updateWarehouseOutOrderDetail(detail); + if (updateResult <= 0) { throw new BusinessException("更新出库单详情数据失败"); } } @@ -245,12 +252,76 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService log.warn("出库单号为空:{}",warehouseOutOrder.getOutOrderCode()); throw new BusinessException("更新销售出库单数据失败"); } + //生成售后出库单 + int insertAftersalesOutOrderResult = buildAftersalesOutOrder(warehouseOutOrder); + if (insertAftersalesOutOrderResult <= 0){ + throw new BusinessException("生成售后出库单失败"); + } + //生成售后出库单详情 + int insertAftersalesOutOrderDetailResult = buildAftersalesOutOrderDetail(filterOutOrderDetailList); + if (insertAftersalesOutOrderDetailResult <= 0){ + throw new BusinessException("生成售后出库单详情失败"); + } int updateWarehouseOutOrderResult = warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); return updateWarehouseOutOrderResult; } + //检验出库单详情数据 + private void checkWarehouseOutOrderDetailList(List details, String loginName, WarehouseOutOrder warehouseOutOrder) { + for (WarehouseOutOrderDetail detail : details) { + detail.setUpdateBy(loginName); + detail.setUpdateTime(new Date()); + detail.setRemark(warehouseOutOrder.getRemark()); + + Integer prepareOutOrderSum = detail.getPrepareOutOrderSum(); + Integer applyOutOrderSum = detail.getApplyOutOrderSum(); + + if (prepareOutOrderSum == null || applyOutOrderSum == null) { + throw new BusinessException("准备出库数或申请出库数不能为空"); + } + + if (!Objects.equals(prepareOutOrderSum, applyOutOrderSum)) { + throw new BusinessException("准备出库数必须等于申请出库数"); + } + } + } + + + + //生成售后出库单详情 + private int buildAftersalesOutOrderDetail(List filterOutOrderDetailList) { + String loginName = ShiroUtils.getLoginName(); + List aftersalesOutOrderDetails = new ArrayList<>(); + for (WarehouseOutOrderDetail warehouseOutOrderDetail : filterOutOrderDetailList) { + AftersalesOutOrderDetail aftersalesOutOrderDetail = new AftersalesOutOrderDetail(); + BeanUtils.copyProperties(warehouseOutOrderDetail,aftersalesOutOrderDetail); + aftersalesOutOrderDetail.setCreateBy(loginName); + aftersalesOutOrderDetail.setCreateTime(new Date()); + aftersalesOutOrderDetails.add(aftersalesOutOrderDetail); + + } + return aftersalesOutOrderDetailMapper.insertBatchAftersalesOutOrderDetail(aftersalesOutOrderDetails); + + } + + //生成售后出库单 + private int buildAftersalesOutOrder(WarehouseOutOrder warehouseOutOrder) { + + AftersalesOutOrder aftersalesOutOrder = new AftersalesOutOrder(); + + String loginName = ShiroUtils.getLoginName(); + warehouseOutOrder.setCreateBy(loginName); + warehouseOutOrder.setCreateTime(new Date()); + //更改出库状态为 第一次维护设备信息 + warehouseOutOrder.setWarehouseOutStatus("1"); + BeanUtils.copyProperties(warehouseOutOrder,aftersalesOutOrder); + return aftersalesOutOrderMapper.insertAftersalesOutOrder(aftersalesOutOrder); + + } + + /** * 修改保存销售单-出库 */ diff --git a/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesOutOrderDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesOutOrderDetailMapper.xml index 5277b8f7..6c5938b6 100644 --- a/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesOutOrderDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesOutOrderDetailMapper.xml @@ -178,6 +178,116 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + insert into aftersales_out_order_detail ( + out_order_code, + make_no, + warehouse_out_status, + related_order_code, + sales_order_code, + warehouse_order_type, + out_make_code, + requisitioning_code, + warehouse_out_type, + business_name, + aftersales_name, + warehouse_name, + shipping_device_id, + material_no, + material_name, + material_type, + material_photoUrl, + material_brand, + material_unit, + material_describe, + material_process_method, + material_model, + material_specification, + material_sum, + enterprise_sum, + make_num, + out_order_sum, + has_out_order_sum, + apply_out_order_sum, + prepare_out_order_sum, + actual_out_order_sum, + out_order_name, + out_order_time, + supplier_code, + supplier_name, + customer_id, + customer_name, + plan_delivery_time, + delivery_date, + delivery_condition, + apply_name, + delivery_address, + delivery_name, + delivery_number, + remark, + create_by, + create_time, + update_by, + update_time + ) values + + ( + #{item.outOrderCode}, + #{item.makeNo}, + #{item.warehouseOutStatus}, + #{item.relatedOrderCode}, + #{item.salesOrderCode}, + #{item.warehouseOrderType}, + #{item.outMakeCode}, + #{item.requisitioningCode}, + #{item.warehouseOutType}, + #{item.businessName}, + #{item.aftersalesName}, + #{item.warehouseName}, + #{item.shippingDeviceId}, + #{item.materialNo}, + #{item.materialName}, + #{item.materialType}, + #{item.materialPhotourl}, + #{item.materialBrand}, + #{item.materialUnit}, + #{item.materialDescribe}, + #{item.materialProcessMethod}, + #{item.materialModel}, + #{item.materialSpecification}, + #{item.materialSum}, + #{item.enterpriseSum}, + #{item.makeNum}, + #{item.outOrderSum}, + #{item.hasOutOrderSum}, + #{item.applyOutOrderSum}, + #{item.prepareOutOrderSum}, + #{item.actualOutOrderSum}, + #{item.outOrderName}, + #{item.outOrderTime}, + #{item.supplierCode}, + #{item.supplierName}, + #{item.customerId}, + #{item.customerName}, + #{item.planDeliveryTime}, + #{item.deliveryDate}, + #{item.deliveryCondition}, + #{item.applyName}, + #{item.deliveryAddress}, + #{item.deliveryName}, + #{item.deliveryNumber}, + #{item.remark}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime} + ) + + + + + update aftersales_out_order_detail diff --git a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseOutOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseOutOrderMapper.xml index 5204a59b..8af5804d 100644 --- a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseOutOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseOutOrderMapper.xml @@ -82,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and delivery_date = #{deliveryDate} and warehouse_order_type = "0" + order by create_time desc