|
|
@ -1,6 +1,6 @@ |
|
|
|
package com.ruoyi.warehouse.service.impl; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
@ -10,33 +10,33 @@ import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.erp.domain.ErpDevelopModifyorder; |
|
|
|
import com.ruoyi.erp.domain.ErpMaterial; |
|
|
|
import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper; |
|
|
|
import com.ruoyi.erp.mapper.ErpMaterialMapper; |
|
|
|
import com.ruoyi.purchase.domain.PurchaseOrderChild; |
|
|
|
import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper; |
|
|
|
import com.ruoyi.quality.domain.QualityOrder; |
|
|
|
import com.ruoyi.quality.domain.QualityOrderDetail; |
|
|
|
import com.ruoyi.quality.domain.QualityOrderReport; |
|
|
|
import com.ruoyi.quality.domain.QualityOrderReportUnqualified; |
|
|
|
import com.ruoyi.quality.domain.QualityRefundsExchanges; |
|
|
|
import com.ruoyi.quality.mapper.QualityOrderDetailMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityOrderMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityOrderReportMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityOrderReportUnqualifiedMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityRefundsExchangesMapper; |
|
|
|
import com.ruoyi.quality.service.IQualityOrderService; |
|
|
|
import com.ruoyi.system.domain.OutsourceStorageDetail; |
|
|
|
import com.ruoyi.system.domain.SysMakeOrder; |
|
|
|
import com.ruoyi.system.domain.SysSalesOrder; |
|
|
|
import com.ruoyi.system.domain.SysSalesOrderChild; |
|
|
|
import com.ruoyi.system.mapper.OutsourceStorageDetailMapper; |
|
|
|
import com.ruoyi.system.mapper.SysMakeOrderMapper; |
|
|
|
import com.ruoyi.system.mapper.SysSalesOrderChildMapper; |
|
|
|
import com.ruoyi.system.mapper.SysSalesOrderMapper; |
|
|
|
import com.ruoyi.system.service.ISysMakeOrderService; |
|
|
|
import com.ruoyi.system.service.ISysSalesOrderService; |
|
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; |
|
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; |
|
|
|
import com.ruoyi.warehouse.domain.*; |
|
|
|
import com.ruoyi.warehouse.mapper.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.activiti.editor.language.json.converter.util.CollectionUtils; |
|
|
|
import org.apache.avalon.framework.service.ServiceException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; |
|
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; |
|
|
|
import com.ruoyi.warehouse.service.IWarehouseStorageOrderService; |
|
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -85,6 +85,26 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
@Autowired |
|
|
|
private ErpDevelopModifyorderMapper developModifyorderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseInventoryInquiryMapper warehouseInventoryInquiryMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseInventoryInquiryDetailMapper inventoryInquiryDetailMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PurchaseOrderChildMapper purchaseOrderChildMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ErpMaterialMapper erpMaterialMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseInventoryReportDamageChildMapper damageChildMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OutsourceStorageDetailMapper outsourceStorageDetailMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QualityRefundsExchangesMapper exchangesMapper; |
|
|
|
/** |
|
|
|
* 查询仓库入库单 |
|
|
|
* |
|
|
@ -119,7 +139,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
{ |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
List<WarehouseStorageOrderDetail> storageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(storageOrderDetailList)){ |
|
|
@ -154,7 +174,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
{ |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
|
|
List<WarehouseStorageOrderDetail> storageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
|
|
|
@ -194,7 +214,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("1"); |
|
|
|
warehouseStorageOrder.setWarehouseEmployee(loginName); |
|
|
|
//设置暂存时间
|
|
|
|
warehouseStorageOrder.setTemporaryTime(new Date()); |
|
|
|
warehouseStorageOrder.setTemporaryTime(DateUtils.getNowDate()); |
|
|
|
updateWarehouseStorageOrderDetails(warehouseStorageOrder); |
|
|
|
|
|
|
|
int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); |
|
|
@ -258,6 +278,48 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 委外订单,委外入库单品质完成后,更新委外入库单,后续进行入库操作 |
|
|
|
* */ |
|
|
|
@Override |
|
|
|
public int updateWarehouseStorageOrderByOutQualityOrder(QualityOrder qualityOrder, List<QualityOrderDetail> qualityOrderDetailList) { |
|
|
|
|
|
|
|
WarehouseStorageOrder warehouseStorageOrder = new WarehouseStorageOrder(); |
|
|
|
|
|
|
|
warehouseStorageOrder.setWarehouseStorageCode(qualityOrder.getInStorageCode()); |
|
|
|
//入库状态 为待入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("2"); |
|
|
|
//品质状态
|
|
|
|
warehouseStorageOrder.setWarehouseQualityStatus(qualityOrder.getQualityStatus()); |
|
|
|
//设置品质时间
|
|
|
|
warehouseStorageOrder.setQualityTime(qualityOrder.getDeliveryInspectionTime()); |
|
|
|
//设置品质合格数
|
|
|
|
warehouseStorageOrder.setQualityQualifiedNum(qualityOrder.getQualityQualifiedNum()); |
|
|
|
//设置品质不合格数
|
|
|
|
warehouseStorageOrder.setQualityUnqualifiedNum(qualityOrder.getQualityUnqualifiedNum()); |
|
|
|
//设置交检时间
|
|
|
|
warehouseStorageOrder.setDeliveryInspectionTime(qualityOrder.getDeliveryInspectionTime()); |
|
|
|
|
|
|
|
for (QualityOrderDetail qualityOrderDetail : qualityOrderDetailList) { |
|
|
|
WarehouseStorageOrderDetail storageOrderDetail = new WarehouseStorageOrderDetail(); |
|
|
|
storageOrderDetail.setWarehouseStorageCode(qualityOrder.getInStorageCode()); |
|
|
|
storageOrderDetail.setQualityQualifiedNum(qualityOrderDetail.getQualityQualifiedNum()); |
|
|
|
//更新品质已合格数
|
|
|
|
storageOrderDetail.setQualityHasQualifiedNum(qualityOrderDetail.getQualityQualifiedNum()); |
|
|
|
storageOrderDetail.setMaterialNo(qualityOrderDetail.getMaterialNo()); |
|
|
|
storageOrderDetail.setSupplierCode(qualityOrderDetail.getSupplierCode()); |
|
|
|
|
|
|
|
int updateStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetailByCode(storageOrderDetail); |
|
|
|
if (updateStorageOrderDetailResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单详情失败,未影响任何行"); |
|
|
|
} |
|
|
|
} |
|
|
|
int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrderByCode(warehouseStorageOrder); |
|
|
|
if (updateResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单失败,未影响任何行"); |
|
|
|
} |
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 入库-采购单(采购入库) 旧版弃用 |
|
|
|
* */ |
|
|
@ -269,9 +331,9 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(new Date()); |
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("入库单详情数据为空:{}",warehouseStorageOrderDetailList); |
|
|
@ -343,7 +405,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//插入暂收不合格数
|
|
|
|
warehouseStorageOrder.setTemporaryUnqualifiedNum(Math.max(0, actualArriveNum - temporaryQualifiedNum)); |
|
|
|
//设置暂存时间
|
|
|
|
warehouseStorageOrder.setTemporaryTime(new Date()); |
|
|
|
warehouseStorageOrder.setTemporaryTime(DateUtils.getNowDate()); |
|
|
|
int updateDetailResult = updateTemporaryPurchaseDetails(warehouseStorageOrder); |
|
|
|
if (updateDetailResult != warehouseStorageOrder.getWarehouseStorageOrderDetailList().size()) { |
|
|
|
throw new BusinessException("更新入库单明细记录失败"); |
|
|
@ -374,6 +436,153 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存暂收-委外单(委外入库) |
|
|
|
* */ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int temporaryOutsourceSave(WarehouseStorageOrder warehouseStorageOrder) { |
|
|
|
|
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//改变状态为已暂收
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("1"); |
|
|
|
//设置品质状态,为待品质
|
|
|
|
warehouseStorageOrder.setWarehouseQualityStatus("0"); |
|
|
|
warehouseStorageOrder.setWarehouseEmployee(loginName); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
|
|
|
|
|
|
|
|
int actualArriveNum = 0; |
|
|
|
//检查填写的实际到货数是否有空值
|
|
|
|
boolean hasActualArriveNumNull = warehouseStorageOrderDetailList.stream() |
|
|
|
.anyMatch(item -> item.getActualArriveNum() == null); |
|
|
|
if (hasActualArriveNumNull) { |
|
|
|
throw new BusinessException("存在实际到货数为空,请检查!"); |
|
|
|
} |
|
|
|
|
|
|
|
//入库单主表的实际到货数为子表的合计
|
|
|
|
actualArriveNum = warehouseStorageOrderDetailList.stream().mapToInt(WarehouseStorageOrderDetail::getActualArriveNum).sum(); |
|
|
|
|
|
|
|
int temporaryQualifiedNum = 0; |
|
|
|
//检查填写的品质合格数是否有空值
|
|
|
|
boolean hasTemporaryQualifiedNumNull = warehouseStorageOrderDetailList.stream() |
|
|
|
.anyMatch(item -> item.getTemporaryQualifiedNum() == null); |
|
|
|
if (hasTemporaryQualifiedNumNull) { |
|
|
|
throw new BusinessException("存在品质合格数为空,请检查!"); |
|
|
|
} |
|
|
|
//入库单主表的暂收合格数为子表的合计
|
|
|
|
temporaryQualifiedNum = warehouseStorageOrderDetailList.stream().mapToInt(WarehouseStorageOrderDetail::getTemporaryQualifiedNum).sum(); |
|
|
|
|
|
|
|
if (actualArriveNum < temporaryQualifiedNum) { |
|
|
|
throw new BusinessException("暂收合格数不能大于实际到货数"); |
|
|
|
} |
|
|
|
|
|
|
|
//插入实际到货数
|
|
|
|
warehouseStorageOrder.setActualArrivedNum(actualArriveNum); |
|
|
|
//插入暂收合格数
|
|
|
|
warehouseStorageOrder.setTemporaryQualifiedNum(temporaryQualifiedNum); |
|
|
|
//插入暂收不合格数
|
|
|
|
warehouseStorageOrder.setTemporaryUnqualifiedNum(Math.max(0, actualArriveNum - temporaryQualifiedNum)); |
|
|
|
//设置暂存时间
|
|
|
|
warehouseStorageOrder.setTemporaryTime(DateUtils.getNowDate()); |
|
|
|
int updateDetailResult = updateTemporaryPurchaseDetails(warehouseStorageOrder); |
|
|
|
if (updateDetailResult != warehouseStorageOrder.getWarehouseStorageOrderDetailList().size()) { |
|
|
|
throw new BusinessException("更新入库单明细记录失败"); |
|
|
|
} |
|
|
|
int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); |
|
|
|
if (updateResult <= 0) { |
|
|
|
throw new BusinessException("更新入库单主记录失败"); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
qualityOrderService.insertQualityOrderByOutsourceStorageOrder(warehouseStorageOrder, warehouseStorageOrder.getWarehouseStorageOrderDetailList()); |
|
|
|
} catch (Exception e) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
log.error("生成品质单时发生错误", e); |
|
|
|
throw new BusinessException("生成品质单时发生错误"); |
|
|
|
} |
|
|
|
|
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存 入库-委外单(委外入库) |
|
|
|
* */ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int updateOutsourceStorageSave(WarehouseStorageOrder warehouseStorageOrder) { |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("入库单详情数据为空:{}",warehouseStorageOrderDetailList); |
|
|
|
throw new BusinessException("入库单详情数据为空"); |
|
|
|
} |
|
|
|
//入库数
|
|
|
|
Integer storageNum = 0; |
|
|
|
|
|
|
|
// 检查storageNum是否含有null值
|
|
|
|
boolean hasThisStorageNumNull = warehouseStorageOrderDetailList.stream() |
|
|
|
.anyMatch(item -> item.getStorageNum() == null); |
|
|
|
|
|
|
|
if (hasThisStorageNumNull) { |
|
|
|
throw new BusinessException("存在入库数为空,请检查!"); |
|
|
|
} |
|
|
|
// 计算各个字段的总和
|
|
|
|
storageNum = warehouseStorageOrderDetailList.stream() |
|
|
|
.mapToInt(WarehouseStorageOrderDetail::getStorageNum) |
|
|
|
.sum(); |
|
|
|
|
|
|
|
//插入主表入库数量
|
|
|
|
warehouseStorageOrder.setStorageNum(storageNum); |
|
|
|
|
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//更新已入库数
|
|
|
|
warehouseStorageOrderDetail.setHasStorageNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
int updateWarehouseStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
if (updateWarehouseStorageOrderDetailResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单详情失败,未影响任何行"); |
|
|
|
} |
|
|
|
OutsourceStorageDetail tempOut = new OutsourceStorageDetail(); |
|
|
|
tempOut.setWarehouseStorageCode(warehouseStorageOrderDetail.getWarehouseStorageCode()); |
|
|
|
tempOut.setMaterialNo(warehouseStorageOrderDetail.getMaterialNo()); |
|
|
|
List<OutsourceStorageDetail> outStorageDetails = outsourceStorageDetailMapper.selectOutsourceStorageDetailList(tempOut); |
|
|
|
OutsourceStorageDetail updateDetail = outStorageDetails.get(0); |
|
|
|
updateDetail.setTakenMaterial(new BigDecimal(warehouseStorageOrderDetail.getHasStorageNum())); |
|
|
|
updateDetail.setUpdateBy(loginName); |
|
|
|
updateDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
int outUpdateResult = outsourceStorageDetailMapper.updateOutsourceStorageDetail(updateDetail); |
|
|
|
if(outUpdateResult<=0){ |
|
|
|
throw new BusinessException("更新委外入库单详情失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
WarehouseStorageOrderDetail storageOrderDetail = storageOrderDetailMapper.selectWarehouseStorageOrderDetailById(warehouseStorageOrderDetail.getWarehouseStorageDetailId()); |
|
|
|
int inventoryInquiryResult = createWarehouseInventoryInquiry(storageOrderDetail); |
|
|
|
if (inventoryInquiryResult <= 0){ |
|
|
|
throw new BusinessException("更新/新增库存查询失败,未影响任何行"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//更新入库单的数据
|
|
|
|
int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); |
|
|
|
|
|
|
|
if (updateResult <= 0){ |
|
|
|
log.warn("更新入库单失败,未影响任何行"); |
|
|
|
} |
|
|
|
return updateResult; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改保存 入库-采购单(采购入库) |
|
|
@ -388,9 +597,9 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(new Date()); |
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("入库单详情数据为空:{}",warehouseStorageOrderDetailList); |
|
|
@ -400,14 +609,14 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//入库数
|
|
|
|
Integer storageNum = 0; |
|
|
|
|
|
|
|
// 检查storageNum是否含有null值
|
|
|
|
// 检查storageNum是否含有null值
|
|
|
|
boolean hasThisStorageNumNull = warehouseStorageOrderDetailList.stream() |
|
|
|
.anyMatch(item -> item.getStorageNum() == null); |
|
|
|
|
|
|
|
if (hasThisStorageNumNull) { |
|
|
|
throw new BusinessException("存在入库数为空,请检查!"); |
|
|
|
} |
|
|
|
// 计算各个字段的总和
|
|
|
|
// 计算各个字段的总和
|
|
|
|
storageNum = warehouseStorageOrderDetailList.stream() |
|
|
|
.mapToInt(WarehouseStorageOrderDetail::getStorageNum) |
|
|
|
.sum(); |
|
|
@ -423,12 +632,18 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//更新已入库数
|
|
|
|
warehouseStorageOrderDetail.setHasStorageNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
int updateWarehouseStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
if (updateWarehouseStorageOrderDetailResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单详情失败,未影响任何行"); |
|
|
|
}else{ |
|
|
|
WarehouseStorageOrderDetail storageOrderDetail = storageOrderDetailMapper.selectWarehouseStorageOrderDetailById(warehouseStorageOrderDetail.getWarehouseStorageDetailId()); |
|
|
|
int inventoryInquiryResult = createWarehouseInventoryInquiry(storageOrderDetail); |
|
|
|
if (inventoryInquiryResult <= 0){ |
|
|
|
throw new BusinessException("更新/新增库存查询失败,未影响任何行"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -451,7 +666,168 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 生成/修改库存查询
|
|
|
|
public int createWarehouseInventoryInquiry(WarehouseStorageOrderDetail warehouseStorageOrderDetail){ |
|
|
|
String materialNo = warehouseStorageOrderDetail.getMaterialNo(); |
|
|
|
String correlationCode = warehouseStorageOrderDetail.getRelatedOrderCode(); |
|
|
|
String warehouseStorageType = warehouseStorageOrderDetail.getWarehouseStorageType(); |
|
|
|
if(warehouseStorageType.equals("0")) { |
|
|
|
// 新增采购入库库存历史记录
|
|
|
|
List<PurchaseOrderChild> purchaseOrderChild = purchaseOrderChildMapper.selectPurchaseOrderChildByOrderCode(warehouseStorageOrderDetail.getRelatedOrderCode()); |
|
|
|
for (PurchaseOrderChild child : purchaseOrderChild) { |
|
|
|
if(child.getMaterialCode().equals(materialNo)){ |
|
|
|
int storageNum = warehouseStorageOrderDetail.getStorageNum(); |
|
|
|
WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); |
|
|
|
inquiryDetail = generateInquiryDetailByPurchaseChild(child,storageNum); |
|
|
|
inquiryDetail.setInventoryHistoricalType("0"); |
|
|
|
// if (correlationCode.startsWith("QG")) {
|
|
|
|
//// 有无归属分类
|
|
|
|
// }
|
|
|
|
inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(warehouseStorageType.equals("2")){//新增委内入库库存历史记录
|
|
|
|
WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); |
|
|
|
inquiryDetail = createMakeInOrderInquiryDetail(warehouseStorageOrderDetail); |
|
|
|
inquiryDetail.setInventoryHistoricalType("1"); |
|
|
|
inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); |
|
|
|
}else if(warehouseStorageType.equals("4")){//新增委外入库库存历史记录
|
|
|
|
WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); |
|
|
|
inquiryDetail = createMakeInOrderInquiryDetail(warehouseStorageOrderDetail); |
|
|
|
inquiryDetail.setInventoryHistoricalType("2"); |
|
|
|
inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); |
|
|
|
} |
|
|
|
//查询该物料报损数,更新库存查询报损数
|
|
|
|
List<WarehouseInventoryReportDamageChild> damageChildren = damageChildMapper.selectWarehouseInventoryReportDamageChildByMaterialNo(materialNo); |
|
|
|
BigDecimal scrapSum = BigDecimal.ZERO; |
|
|
|
if(StringUtils.isNotEmpty(damageChildren)){ |
|
|
|
for (WarehouseInventoryReportDamageChild damageChild:damageChildren) { |
|
|
|
BigDecimal scrapNum = damageChild.getActualScrapQuantity(); |
|
|
|
scrapSum = scrapSum.add(scrapSum); |
|
|
|
} |
|
|
|
} |
|
|
|
// 存在库存查询记录,更新可用库存数
|
|
|
|
if(warehouseInventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo)!=null){ |
|
|
|
WarehouseInventoryInquiry inventoryInquiry = warehouseInventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); |
|
|
|
// 增加可用库存数
|
|
|
|
Integer storage = warehouseStorageOrderDetail.getStorageNum(); |
|
|
|
BigDecimal storagenum = BigDecimal.valueOf(storage); |
|
|
|
BigDecimal avaliableStorage = inventoryInquiry.getAvailableStockNum(); |
|
|
|
avaliableStorage = avaliableStorage.add(storagenum); |
|
|
|
inventoryInquiry.setAvailableStockNum(avaliableStorage); |
|
|
|
inventoryInquiry.setReportDamageNum(scrapSum); |
|
|
|
// 设置历史总数
|
|
|
|
if(warehouseStorageOrderDetail.getWarehouseStorageType().equals("0")){ |
|
|
|
BigDecimal historicalNum = getHistoricalTotalFromQualityOrder(warehouseStorageOrderDetail); |
|
|
|
BigDecimal historicalTotal = inventoryInquiry.getHistoricalTotal(); |
|
|
|
historicalTotal = historicalTotal.add(historicalNum); |
|
|
|
inventoryInquiry.setHistoricalTotal(historicalTotal); |
|
|
|
}else{ |
|
|
|
BigDecimal historicalNum = BigDecimal.valueOf(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
BigDecimal historicalTotal = inventoryInquiry.getHistoricalTotal(); |
|
|
|
historicalTotal = historicalTotal.add(historicalNum); |
|
|
|
inventoryInquiry.setHistoricalTotal(historicalTotal); |
|
|
|
} |
|
|
|
inventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
inventoryInquiry.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
return warehouseInventoryInquiryMapper.updateWarehouseInventoryInquiry(inventoryInquiry); |
|
|
|
}else{ |
|
|
|
WarehouseInventoryInquiry inventoryInquiry = new WarehouseInventoryInquiry(); |
|
|
|
inventoryInquiry.setMaterialNo(materialNo); |
|
|
|
inventoryInquiry.setMaterialName(warehouseStorageOrderDetail.getMaterialName()); |
|
|
|
inventoryInquiry.setMaterialPhotourl(warehouseStorageOrderDetail.getMaterialPhotourl()); |
|
|
|
inventoryInquiry.setMaterialBrand(warehouseStorageOrderDetail.getMaterialBrand()); |
|
|
|
inventoryInquiry.setMaterialDescribe(warehouseStorageOrderDetail.getMaterialDescribe()); |
|
|
|
inventoryInquiry.setMaterialUnit(warehouseStorageOrderDetail.getMaterialUnit()); |
|
|
|
inventoryInquiry.setMaterialType(warehouseStorageOrderDetail.getMaterialType()); |
|
|
|
inventoryInquiry.setMaterialProcessMethod(warehouseStorageOrderDetail.getMaterialProcessMethod()); |
|
|
|
Integer storage = warehouseStorageOrderDetail.getStorageNum(); |
|
|
|
BigDecimal storagenum = BigDecimal.valueOf(storage); |
|
|
|
// 设置历史总数
|
|
|
|
if(warehouseStorageOrderDetail.getWarehouseStorageType().equals("0")){ |
|
|
|
BigDecimal historicalNum = getHistoricalTotalFromQualityOrder(warehouseStorageOrderDetail); |
|
|
|
inventoryInquiry.setHistoricalTotal(historicalNum); |
|
|
|
}else{ |
|
|
|
inventoryInquiry.setHistoricalTotal(storagenum); |
|
|
|
} |
|
|
|
inventoryInquiry.setAvailableStockNum(storagenum); |
|
|
|
inventoryInquiry.setReportDamageNum(scrapSum); |
|
|
|
|
|
|
|
ErpMaterial material = erpMaterialMapper.selectErpMaterialByMaterialNo(materialNo); |
|
|
|
inventoryInquiry.setMaterialUseStatus(material.getUseStatus()); |
|
|
|
inventoryInquiry.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
inventoryInquiry.setCreateTime(DateUtils.getNowDate()); |
|
|
|
inventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
inventoryInquiry.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
return warehouseInventoryInquiryMapper.insertWarehouseInventoryInquiry(inventoryInquiry); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 生成采购订单库存历史记录
|
|
|
|
public WarehouseInventoryInquiryDetail generateInquiryDetailByPurchaseChild(PurchaseOrderChild child,int storageNum){ |
|
|
|
WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); |
|
|
|
inquiryDetail.setMaterialNo(child.getMaterialCode()); |
|
|
|
inquiryDetail.setMaterialName(child.getMaterialName()); |
|
|
|
inquiryDetail.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
inquiryDetail.setMaterialPhotourl(child.getMaterialPhotourl()); |
|
|
|
inquiryDetail.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
inquiryDetail.setMaterialType(child.getMaterialType()); |
|
|
|
inquiryDetail.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
inquiryDetail.setInventoryAttributionCode(child.getPurchasePlanCorrelationCode()); |
|
|
|
inquiryDetail.setSupplierCode(child.getSupplierCode()); |
|
|
|
inquiryDetail.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
|
|
inquiryDetail.setPurchaseOrderCode(child.getPurchaseOrderCode()); |
|
|
|
// 库存归属单号
|
|
|
|
BigDecimal realStorageNum = BigDecimal.valueOf(storageNum); |
|
|
|
inquiryDetail.setAvailableStockNum(realStorageNum); |
|
|
|
inquiryDetail.setPurchasePriceIncludesTax(child.getMaterialRealRmbSum()); |
|
|
|
inquiryDetail.setPurchasePriceExcludingTax(child.getMaterialRealNoRmbSum()); |
|
|
|
inquiryDetail.setInventoryIncreaseDecrease("1"); |
|
|
|
inquiryDetail.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
inquiryDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
inquiryDetail.setInventoryHistoricalTime(DateUtils.getNowDate()); |
|
|
|
return inquiryDetail; |
|
|
|
} |
|
|
|
|
|
|
|
//生成委内(委外)入库库存历史记录
|
|
|
|
public WarehouseInventoryInquiryDetail createMakeInOrderInquiryDetail(WarehouseStorageOrderDetail warehouseStorageOrderDetail){ |
|
|
|
WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); |
|
|
|
inquiryDetail.setMaterialNo(warehouseStorageOrderDetail.getMaterialNo()); |
|
|
|
inquiryDetail.setMaterialName(warehouseStorageOrderDetail.getMaterialName()); |
|
|
|
inquiryDetail.setMaterialType(warehouseStorageOrderDetail.getMaterialType()); |
|
|
|
inquiryDetail.setMaterialPhotourl(warehouseStorageOrderDetail.getMaterialPhotourl()); |
|
|
|
inquiryDetail.setMaterialUnit(warehouseStorageOrderDetail.getMaterialUnit()); |
|
|
|
inquiryDetail.setMaterialDescribe(warehouseStorageOrderDetail.getMaterialDescribe()); |
|
|
|
inquiryDetail.setMaterialBrand(warehouseStorageOrderDetail.getMaterialBrand()); |
|
|
|
inquiryDetail.setMaterialProcessMethod(warehouseStorageOrderDetail.getMaterialProcessMethod()); |
|
|
|
BigDecimal storagenum = BigDecimal.ZERO; |
|
|
|
if(warehouseStorageOrderDetail.getStorageNum()!=null){ |
|
|
|
storagenum = BigDecimal.valueOf(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
} |
|
|
|
inquiryDetail.setAvailableStockNum(storagenum); |
|
|
|
inquiryDetail.setInventoryIncreaseDecrease("1"); |
|
|
|
inquiryDetail.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
inquiryDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
inquiryDetail.setInventoryHistoricalTime(DateUtils.getNowDate()); |
|
|
|
return inquiryDetail; |
|
|
|
} |
|
|
|
|
|
|
|
// 根据入库单(采购订单)关联品质单获取历史总数(已到货数-品质不合格数)(采购总数-退换货数)
|
|
|
|
public BigDecimal getHistoricalTotalFromQualityOrder(WarehouseStorageOrderDetail warehouseStorageOrderDetail){ |
|
|
|
BigDecimal historicalTotal = BigDecimal.ZERO; |
|
|
|
QualityOrderDetail tempDetail = new QualityOrderDetail(); |
|
|
|
tempDetail.setInStorageCode(warehouseStorageOrderDetail.getWarehouseStorageCode()); |
|
|
|
tempDetail.setMaterialNo(warehouseStorageOrderDetail.getMaterialNo()); |
|
|
|
|
|
|
|
QualityOrderDetail qualityOrderDetail = qualityOrderDetailMapper.selectQualityOrderDetailByStorageCodeAndno(tempDetail); |
|
|
|
Integer actualArriveNum = qualityOrderDetail.getActualArriveNum(); |
|
|
|
Integer qualityUnqualifiedNum = qualityOrderDetail.getQualityUnqualifiedNum(); |
|
|
|
|
|
|
|
historicalTotal = BigDecimal.valueOf(actualArriveNum) |
|
|
|
.subtract(BigDecimal.valueOf(qualityUnqualifiedNum)); |
|
|
|
return historicalTotal; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 修改保存入库-采购单(仓库入库) |
|
|
|
*/ |
|
|
@ -463,9 +839,9 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(new Date()); |
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("入库单详情数据为空:{}",warehouseStorageOrderDetailList); |
|
|
@ -498,12 +874,18 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//更新已入库数
|
|
|
|
warehouseStorageOrderDetail.setHasStorageNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
int updateWarehouseStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
if (updateWarehouseStorageOrderDetailResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单详情失败,未影响任何行"); |
|
|
|
}else{ |
|
|
|
WarehouseStorageOrderDetail storageOrderDetail = storageOrderDetailMapper.selectWarehouseStorageOrderDetailById(warehouseStorageOrderDetail.getWarehouseStorageDetailId()); |
|
|
|
int inventoryInquiryResult = createWarehouseInventoryInquiry(storageOrderDetail); |
|
|
|
if (inventoryInquiryResult <= 0){ |
|
|
|
throw new BusinessException("更新/新增库存查询失败,未影响任何行"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -555,8 +937,8 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
warehouseStorageOrder.setQualityUnqualifiedNum(tempQualityOrder.getQualityUnqualifiedNum()); |
|
|
|
warehouseStorageOrder.setQualityQualifiedNum(tempQualityOrder.getQualityQualifiedNum()); |
|
|
|
warehouseStorageOrder.setCreateBy(loginName); |
|
|
|
warehouseStorageOrder.setQualityTime(new Date()); |
|
|
|
warehouseStorageOrder.setCreateTime(new Date()); |
|
|
|
warehouseStorageOrder.setQualityTime(DateUtils.getNowDate()); |
|
|
|
warehouseStorageOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
//设置委内完成数总价
|
|
|
|
warehouseStorageOrder.setMakeInTotalPrice(tempQualityOrder.getMakeInTotalPrice()); |
|
|
|
//插入入库单详情数据
|
|
|
@ -584,7 +966,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
warehouseStorageOrderDetail.setMaterialType(qualityOrderDetail.getMaterialType()); |
|
|
|
warehouseStorageOrderDetail.setMaterialUnit(qualityOrderDetail.getMaterialUnit()); |
|
|
|
warehouseStorageOrderDetail.setCreateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setCreateTime(new Date()); |
|
|
|
warehouseStorageOrderDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
storageOrderDetailMapper.insertWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
} |
|
|
|
|
|
|
@ -603,9 +985,9 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(new Date()); |
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
String warehouseCode = warehouseStorageOrder.getWarehouseCode(); |
|
|
|
String warehouseName = warehouseStorageOrder.getWarehouseName(); |
|
|
|
if (StringUtils.isNotEmpty(warehouseCode)){ |
|
|
@ -647,12 +1029,18 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//更新已入库数
|
|
|
|
warehouseStorageOrderDetail.setHasStorageNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
int updateWarehouseStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
if (updateWarehouseStorageOrderDetailResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单详情失败,未影响任何行"); |
|
|
|
}else{ |
|
|
|
WarehouseStorageOrderDetail storageOrderDetail = storageOrderDetailMapper.selectWarehouseStorageOrderDetailById(warehouseStorageOrderDetail.getWarehouseStorageDetailId()); |
|
|
|
int inventoryInquiryResult = createWarehouseInventoryInquiry(storageOrderDetail); |
|
|
|
if (inventoryInquiryResult <= 0){ |
|
|
|
throw new BusinessException("更新/新增库存查询失败,未影响任何行"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//更新入库单的数据
|
|
|
@ -717,7 +1105,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//插入暂收不合格数
|
|
|
|
warehouseStorageOrder.setTemporaryUnqualifiedNum(Math.max(0, actualArriveNum - temporaryQualifiedNum)); |
|
|
|
//设置暂存时间
|
|
|
|
warehouseStorageOrder.setTemporaryTime(new Date()); |
|
|
|
warehouseStorageOrder.setTemporaryTime(DateUtils.getNowDate()); |
|
|
|
int updateDetailResult = updateTemporaryPurchaseDetails(warehouseStorageOrder); |
|
|
|
if (updateDetailResult != warehouseStorageOrder.getWarehouseStorageOrderDetailList().size()) { |
|
|
|
throw new BusinessException("更新入库单明细记录失败"); |
|
|
@ -760,8 +1148,8 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
warehouseStorageOrder.setQualityUnqualifiedNum(tempQualityOrder.getQualityUnqualifiedNum()); |
|
|
|
warehouseStorageOrder.setQualityQualifiedNum(tempQualityOrder.getQualityQualifiedNum()); |
|
|
|
warehouseStorageOrder.setCreateBy(loginName); |
|
|
|
warehouseStorageOrder.setQualityTime(new Date()); |
|
|
|
warehouseStorageOrder.setCreateTime(new Date()); |
|
|
|
warehouseStorageOrder.setQualityTime(DateUtils.getNowDate()); |
|
|
|
warehouseStorageOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
//插入入库单详情数据
|
|
|
|
for (QualityOrderDetail qualityOrderDetail : qualityOrderDetailList) { |
|
|
|
|
|
|
@ -787,7 +1175,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
warehouseStorageOrderDetail.setMaterialType(qualityOrderDetail.getMaterialType()); |
|
|
|
warehouseStorageOrderDetail.setMaterialUnit(qualityOrderDetail.getMaterialUnit()); |
|
|
|
warehouseStorageOrderDetail.setCreateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setCreateTime(new Date()); |
|
|
|
warehouseStorageOrderDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
storageOrderDetailMapper.insertWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
} |
|
|
|
|
|
|
@ -814,7 +1202,11 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
if (actualArriveNum < temporaryQualifiedNum){ |
|
|
|
throw new BusinessException("暂收合格数要小于等于实际到货数"); |
|
|
|
} |
|
|
|
updateResultDetails += storageOrderDetailMapper.updateWarehouseStorageOrderDetailByObject(detail); |
|
|
|
if(detail.getWarehouseStorageType()!=null&&detail.getWarehouseStorageType().equals("4")){ |
|
|
|
updateResultDetails += storageOrderDetailMapper.updateWarehouseStorageOrderDetail(detail); |
|
|
|
}else { |
|
|
|
updateResultDetails += storageOrderDetailMapper.updateWarehouseStorageOrderDetailByObject(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
return updateResultDetails; |
|
|
|
} |
|
|
@ -890,9 +1282,9 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(new Date()); |
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
String warehouseCode = warehouseStorageOrder.getWarehouseCode(); |
|
|
|
String warehouseName = warehouseStorageOrder.getWarehouseName(); |
|
|
|
if (StringUtils.isNotEmpty(warehouseCode)){ |
|
|
@ -956,7 +1348,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
sysSalesOrderChild.setMaterialCode(warehouseStorageOrderDetail.getMaterialNo()); |
|
|
|
sysSalesOrderChild.setFinishNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
sysSalesOrderChild.setUpdateBy(loginName); |
|
|
|
sysSalesOrderChild.setUpdateTime(new Date()); |
|
|
|
sysSalesOrderChild.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
int updateSalesOrderChildResult = salesOrderChildMapper.updateSysSalesOrderChildByCodeAndQuoteId(sysSalesOrderChild); |
|
|
|
if (updateSalesOrderChildResult <= 0){ |
|
|
|
throw new BusinessException("更新销售订单子表数据失败"); |
|
|
@ -973,7 +1365,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(new Date()); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//更新已入库数
|
|
|
|
warehouseStorageOrderDetail.setHasStorageNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
int updateWarehouseStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
@ -991,6 +1383,84 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 入库-退换货订单(入库前退货) |
|
|
|
* */ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int updateRefundsExchangeStorage(WarehouseStorageOrder warehouseStorageOrder) { |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
|
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(DateUtils.getNowDate()); |
|
|
|
String warehouseCode = warehouseStorageOrder.getWarehouseCode(); |
|
|
|
String warehouseName = warehouseStorageOrder.getWarehouseName(); |
|
|
|
if (StringUtils.isNotEmpty(warehouseCode)){ |
|
|
|
warehouseStorageOrder.setWarehouseCode(warehouseCode); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(warehouseName)){ |
|
|
|
warehouseStorageOrder.setWarehouseName(warehouseName); |
|
|
|
} |
|
|
|
|
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("入库单详情数据为空:{}",warehouseStorageOrderDetailList); |
|
|
|
throw new BusinessException("入库单详情数据为空"); |
|
|
|
} |
|
|
|
|
|
|
|
//入库数
|
|
|
|
Integer storageNum = 0; |
|
|
|
|
|
|
|
// 检查storageNum是否含有null值
|
|
|
|
boolean hasThisStorageNumNull = warehouseStorageOrderDetailList.stream() |
|
|
|
.anyMatch(item -> item.getStorageNum() == null); |
|
|
|
|
|
|
|
if (hasThisStorageNumNull) { |
|
|
|
throw new BusinessException("存在入库数为空,请检查!"); |
|
|
|
} |
|
|
|
// 计算各个字段的总和
|
|
|
|
storageNum = warehouseStorageOrderDetailList.stream() |
|
|
|
.mapToInt(WarehouseStorageOrderDetail::getStorageNum) |
|
|
|
.sum(); |
|
|
|
|
|
|
|
//插入主表入库数量
|
|
|
|
warehouseStorageOrder.setStorageNum(storageNum); |
|
|
|
|
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
//更新已入库数
|
|
|
|
warehouseStorageOrderDetail.setHasStorageNum(warehouseStorageOrderDetail.getStorageNum()); |
|
|
|
int updateWarehouseStorageOrderDetailResult = storageOrderDetailMapper.updateWarehouseStorageOrderDetail(warehouseStorageOrderDetail); |
|
|
|
if (updateWarehouseStorageOrderDetailResult <= 0){ |
|
|
|
throw new BusinessException("更新仓库入库单详情失败,未影响任何行"); |
|
|
|
} |
|
|
|
} |
|
|
|
//更新入库单的数据
|
|
|
|
int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); |
|
|
|
|
|
|
|
if (updateResult <= 0){ |
|
|
|
log.warn("更新入库单失败,未影响任何行"); |
|
|
|
} |
|
|
|
QualityRefundsExchanges tempExchanges = new QualityRefundsExchanges(); |
|
|
|
tempExchanges.setInStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); |
|
|
|
List<QualityRefundsExchanges> qualityRefundsExchanges = exchangesMapper.selectQualityRefundsExchangesList(tempExchanges); |
|
|
|
if(qualityRefundsExchanges.size()<=0){ |
|
|
|
throw new BusinessException("未找到关联退换货订单!"); |
|
|
|
} |
|
|
|
QualityRefundsExchanges updateExchanges = qualityRefundsExchanges.get(0); |
|
|
|
updateExchanges.setRefundsExchangesStatus("1"); |
|
|
|
int updateExchangeResult = exchangesMapper.updateQualityRefundsExchanges(updateExchanges); |
|
|
|
if(updateExchangeResult<=0){ |
|
|
|
throw new BusinessException("更新退换货订单入库状态失败!"); |
|
|
|
} |
|
|
|
return updateResult; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 删除仓库入库单对象 |
|
|
|
* |
|
|
|