|
|
@ -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<WarehouseOutOrderDetail> 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<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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存销售单-出库 |
|
|
|
*/ |
|
|
|