Browse Source

[feat] 售后管理

修改仓库准备物料后端接口:新增校验子表数据方法、更新出库单详情数据方法、生成售后出库单方法、生成售后出库单详情方法。
售后维护设备出库详情新增 批量新增售后维护设备出库详情后端方法
dev
liuxiaoxu 3 weeks ago
parent
commit
e13ff7551e
  1. 6
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOutOrderDetailMapper.java
  2. 99
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java
  3. 110
      ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesOutOrderDetailMapper.xml
  4. 1
      ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseOutOrderMapper.xml

6
ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOutOrderDetailMapper.java

@ -74,4 +74,10 @@ public interface AftersalesOutOrderDetailMapper
* @return 结果 * @return 结果
*/ */
public int restoreAftersalesOutOrderDetailById(Long outOrderDetailId); public int restoreAftersalesOutOrderDetailById(Long outOrderDetailId);
/**
* 批量新增售后维护设备出库详情
* */
int insertBatchAftersalesOutOrderDetail(List<AftersalesOutOrderDetail> aftersalesOutOrderDetails);
} }

99
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.*;
import java.util.stream.Collectors; 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.core.redis.RedisCache;
import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils; 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.WarehouseInventoryInquiryMapper;
import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper;
@ -95,6 +100,12 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
@Autowired @Autowired
private QualityRefundsExchangesMapper refundsExchangesMapper; 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 @Override
public int updatePrepareMaterial(WarehouseOutOrder warehouseOutOrder) { public int updatePrepareMaterial(WarehouseOutOrder warehouseOutOrder) {
@ -216,19 +227,15 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
} }
//过滤掉准备出库数为0的数据,相当于本次不出库 //过滤掉准备出库数为0的数据,相当于本次不出库
List<WarehouseOutOrderDetail> filterOutOrderDetailList = warehouseOutOrderDetailList.stream().filter(item -> item.getPrepareOutOrderSum() != 0).collect(Collectors.toList()); List<WarehouseOutOrderDetail> filterOutOrderDetailList = warehouseOutOrderDetailList.stream().filter(item -> item.getPrepareOutOrderSum() != 0).collect(Collectors.toList());
for (WarehouseOutOrderDetail warehouseOutOrderDetail : filterOutOrderDetailList) {
warehouseOutOrderDetail.setUpdateBy(loginName); // 校验子表数据
warehouseOutOrderDetail.setUpdateTime(new Date()); checkWarehouseOutOrderDetailList(filterOutOrderDetailList, loginName,warehouseOutOrder);
warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark());
Integer prepareOutOrderSum = warehouseOutOrderDetail.getPrepareOutOrderSum();
Integer applyOutOrderSum = warehouseOutOrderDetail.getApplyOutOrderSum(); // 更新出库单详情数据
//准备出库数 必须等于 申请出库数 for (WarehouseOutOrderDetail detail : filterOutOrderDetailList) {
if (!Objects.equals(prepareOutOrderSum, applyOutOrderSum)){ int updateResult = outOrderDetailMapper.updateWarehouseOutOrderDetail(detail);
throw new BusinessException("准备出库数必须等于申请出库数"); if (updateResult <= 0) {
}
//更新数据库记录
int updateOutOrderDetail = outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail);
if (updateOutOrderDetail <= 0){
throw new BusinessException("更新出库单详情数据失败"); throw new BusinessException("更新出库单详情数据失败");
} }
} }
@ -245,12 +252,76 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
log.warn("出库单号为空:{}",warehouseOutOrder.getOutOrderCode()); log.warn("出库单号为空:{}",warehouseOutOrder.getOutOrderCode());
throw new BusinessException("更新销售出库单数据失败"); 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); int updateWarehouseOutOrderResult = warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder);
return updateWarehouseOutOrderResult; return updateWarehouseOutOrderResult;
} }
//检验出库单详情数据
private void checkWarehouseOutOrderDetailList(List<WarehouseOutOrderDetail> 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<WarehouseOutOrderDetail> filterOutOrderDetailList) {
String loginName = ShiroUtils.getLoginName();
List<AftersalesOutOrderDetail> 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);
}
/** /**
* 修改保存销售单-出库 * 修改保存销售单-出库
*/ */

110
ruoyi-admin/src/main/resources/mapper/aftersales/AftersalesOutOrderDetailMapper.xml

@ -178,6 +178,116 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<insert id="insertBatchAftersalesOutOrderDetail" parameterType="AftersalesOutOrderDetail" useGeneratedKeys="true" keyProperty="outOrderDetailId">
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
<foreach collection="list" item="item" index="index" separator=",">
(
#{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}
)
</foreach>
</insert>
<update id="updateAftersalesOutOrderDetail" parameterType="AftersalesOutOrderDetail"> <update id="updateAftersalesOutOrderDetail" parameterType="AftersalesOutOrderDetail">
update aftersales_out_order_detail update aftersales_out_order_detail
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">

1
ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseOutOrderMapper.xml

@ -82,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deliveryDate != null "> and delivery_date = #{deliveryDate}</if> <if test="deliveryDate != null "> and delivery_date = #{deliveryDate}</if>
and warehouse_order_type = "0" and warehouse_order_type = "0"
</where> </where>
order by create_time desc
</select> </select>

Loading…
Cancel
Save