|
|
@ -2,15 +2,24 @@ package com.ruoyi.quality.service.impl; |
|
|
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.quality.domain.QualityRefundsExchangesDetail; |
|
|
|
import com.ruoyi.quality.domain.QualityRefundsExchangesUnqualified; |
|
|
|
import com.ruoyi.quality.mapper.QualityRefundsExchangesDetailMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityRefundsExchangesUnqualifiedMapper; |
|
|
|
import com.ruoyi.storehouse.domain.WarehousingInInfo; |
|
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; |
|
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; |
|
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; |
|
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -36,6 +45,21 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan |
|
|
|
@Autowired |
|
|
|
private QualityRefundsExchangesDetailMapper refundsExchangesDetailMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QualityRefundsExchangesUnqualifiedMapper unqualifiedMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseStorageOrderMapper warehouseStorageOrderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseStorageOrderDetailMapper warehouseStorageOrderDetailMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseStorageOrderDetailMapper storageOrderDetailMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisCache redisCache; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询品质管理退换货单 |
|
|
|
* |
|
|
@ -70,36 +94,111 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan |
|
|
|
public int insertQualityRefundsExchanges(QualityRefundsExchanges qualityRefundsExchanges) |
|
|
|
{ |
|
|
|
|
|
|
|
String refundsExchangesCode = qualityRefundsExchanges.getRefundsExchangesCode(); |
|
|
|
String refundsExchangesCode = redisCache.generateBillNo("THH"); |
|
|
|
qualityRefundsExchanges.setRefundsExchangesCode(refundsExchangesCode); |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(refundsExchangesCode)){ |
|
|
|
log.warn("退换货单号为空:{}",refundsExchangesCode); |
|
|
|
} |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
int exchangeSum = 0; |
|
|
|
List<QualityRefundsExchangesDetail> refundsExchangesDetails = qualityRefundsExchanges.getRefundsExchangesDetails(); |
|
|
|
if (StringUtils.isEmpty(refundsExchangesDetails)){ |
|
|
|
log.warn("物料数据为空:{}",qualityRefundsExchanges.getRefundsExchangesDetails()); |
|
|
|
log.warn("物料数据为空:{}",qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
} |
|
|
|
for (QualityRefundsExchangesDetail tempDetail : refundsExchangesDetails) { |
|
|
|
QualityRefundsExchangesDetail refundsExchangesDetail = new QualityRefundsExchangesDetail(); |
|
|
|
refundsExchangesDetail.setRefundsExchangesCode(refundsExchangesCode); |
|
|
|
refundsExchangesDetail.setDeliveryInspectionTime(qualityRefundsExchanges.getDeliveryInspectionTime()); |
|
|
|
refundsExchangesDetail.setQualityRemark(qualityRefundsExchanges.getQualityRemark()); |
|
|
|
refundsExchangesDetail.setMaterialNo(tempDetail.getMaterialNo()); |
|
|
|
refundsExchangesDetail.setMaterialName(tempDetail.getMaterialName()); |
|
|
|
refundsExchangesDetail.setMaterialBrand(tempDetail.getMaterialBrand()); |
|
|
|
refundsExchangesDetail.setMaterialDescribe(tempDetail.getMaterialDescribe()); |
|
|
|
refundsExchangesDetail.setMaterialPhotourl(tempDetail.getMaterialPhotourl()); |
|
|
|
refundsExchangesDetail.setMaterialType(tempDetail.getMaterialType()); |
|
|
|
refundsExchangesDetail.setMaterialProcessMethod(tempDetail.getMaterialProcessMethod()); |
|
|
|
refundsExchangesDetail.setMaterialUnit(tempDetail.getMaterialUnit()); |
|
|
|
refundsExchangesDetail.setCreateBy(loginName); |
|
|
|
refundsExchangesDetail.setCreateTime(new Date()); |
|
|
|
refundsExchangesDetailMapper.insertQualityRefundsExchangesDetail(refundsExchangesDetail); |
|
|
|
tempDetail.setRefundsExchangesCode(refundsExchangesCode); |
|
|
|
tempDetail.setDeliveryInspectionTime(qualityRefundsExchanges.getDeliveryInspectionTime()); |
|
|
|
tempDetail.setQualityRemark(qualityRefundsExchanges.getQualityRemark()); |
|
|
|
tempDetail.setQualityUnqualifiedNum(tempDetail.getRefundsExchangesNum()); |
|
|
|
|
|
|
|
exchangeSum += tempDetail.getRefundsExchangesNum(); |
|
|
|
tempDetail.setCreateBy(loginName); |
|
|
|
tempDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
refundsExchangesDetailMapper.insertQualityRefundsExchangesDetail(tempDetail); |
|
|
|
List<QualityRefundsExchangesUnqualified> unqualifiedList = tempDetail.getRefundsExchangesUnqualifieds(); |
|
|
|
if(StringUtils.isEmpty(unqualifiedList)){ |
|
|
|
log.warn("不合格分类数据为空:{}",tempDetail.getRefundsExchangesCode()); |
|
|
|
}else{ |
|
|
|
for (QualityRefundsExchangesUnqualified unqualified: unqualifiedList) { |
|
|
|
unqualified.setRefundsExchangesCode(refundsExchangesCode); |
|
|
|
unqualified.setMaterialNo(tempDetail.getMaterialNo()); |
|
|
|
unqualified.setMaterialName(tempDetail.getMaterialName()); |
|
|
|
unqualified.setCreateBy(loginName); |
|
|
|
unqualified.setCreateTime(DateUtils.getNowDate()); |
|
|
|
unqualifiedMapper.insertQualityRefundsExchangesUnqualified(unqualified); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
qualityRefundsExchanges.setMaterialTotal(refundsExchangesDetails.size()); |
|
|
|
qualityRefundsExchanges.setNumTotal(exchangeSum); |
|
|
|
qualityRefundsExchanges.setCreateBy(loginName); |
|
|
|
qualityRefundsExchanges.setCreateTime(DateUtils.getNowDate()); |
|
|
|
qualityRefundsExchanges.setQualityReturnNode("1"); |
|
|
|
qualityRefundsExchanges.setRefundsExchangesStatus("0"); |
|
|
|
|
|
|
|
|
|
|
|
// 生成入库单
|
|
|
|
WarehouseStorageOrder warehouseStorageOrder = generateWarehouseStorageOrder(qualityRefundsExchanges); |
|
|
|
warehouseStorageOrder.setWarehouseStorageCode(redisCache.generateBillNo("RK")); |
|
|
|
warehouseStorageOrderMapper.insertWarehouseStorageOrder(warehouseStorageOrder); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetails = createWarehouseStorageDetail(qualityRefundsExchanges,warehouseStorageOrder.getWarehouseStorageCode()); |
|
|
|
warehouseStorageOrderMapper.batchWarehouseStorageOrderDetail(warehouseStorageOrderDetails); |
|
|
|
|
|
|
|
qualityRefundsExchanges.setQualityWarehouseStatus("0"); |
|
|
|
qualityRefundsExchanges.setInStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); |
|
|
|
qualityRefundsExchangesMapper.insertQualityRefundsExchanges(qualityRefundsExchanges); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
// 生成退换货入库单对象
|
|
|
|
public WarehouseStorageOrder generateWarehouseStorageOrder(QualityRefundsExchanges qualityRefundsExchanges){ |
|
|
|
WarehouseStorageOrder warehouseStorageOrder = new WarehouseStorageOrder(); |
|
|
|
warehouseStorageOrder.setRelatedOrderCode(qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("2"); |
|
|
|
warehouseStorageOrder.setWarehouseStorageType("3"); |
|
|
|
warehouseStorageOrder.setWarehouseOrderType("2"); |
|
|
|
warehouseStorageOrder.setWarehouseDeptType("0"); |
|
|
|
warehouseStorageOrder.setWarehouseQualityStatus("2"); |
|
|
|
warehouseStorageOrder.setActualArrivedNum(qualityRefundsExchanges.getNumTotal()); |
|
|
|
warehouseStorageOrder.setNotifyArrivedNum(qualityRefundsExchanges.getNumTotal()); |
|
|
|
warehouseStorageOrder.setStorageNum(qualityRefundsExchanges.getNumTotal()); |
|
|
|
warehouseStorageOrder.setQualityQualifiedNum(0); |
|
|
|
warehouseStorageOrder.setQualityUnqualifiedNum(qualityRefundsExchanges.getNumTotal()); |
|
|
|
warehouseStorageOrder.setDeliveryInspectionTime(qualityRefundsExchanges.getDeliveryInspectionTime()); |
|
|
|
warehouseStorageOrder.setQualityTime(qualityRefundsExchanges.getDeliveryInspectionTime()); |
|
|
|
warehouseStorageOrder.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
warehouseStorageOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
return warehouseStorageOrder; |
|
|
|
} |
|
|
|
// 生成退换货入库单详情对象
|
|
|
|
public List<WarehouseStorageOrderDetail> createWarehouseStorageDetail(QualityRefundsExchanges qualityRefundsExchanges,String warehouseStorageCode){ |
|
|
|
List<WarehouseStorageOrderDetail> detailList = new ArrayList<>(); |
|
|
|
List<QualityRefundsExchangesDetail> exchangesDetails = qualityRefundsExchanges.getRefundsExchangesDetails(); |
|
|
|
if(StringUtils.isEmpty(exchangesDetails)){ |
|
|
|
log.warn("退换货详情物料数据为空:{}",qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
}else { |
|
|
|
for (QualityRefundsExchangesDetail exchangeDetail:exchangesDetails) { |
|
|
|
WarehouseStorageOrderDetail warehouseStorageOrderDetail = new WarehouseStorageOrderDetail(); |
|
|
|
warehouseStorageOrderDetail.setWarehouseStorageCode(warehouseStorageCode); |
|
|
|
warehouseStorageOrderDetail.setRelatedOrderCode(qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
warehouseStorageOrderDetail.setWarehouseStorageStatus("2"); |
|
|
|
warehouseStorageOrderDetail.setWarehouseStorageType("3"); |
|
|
|
warehouseStorageOrderDetail.setWarehouseOrderType("2"); |
|
|
|
warehouseStorageOrderDetail.setWarehouseDeptType("0"); |
|
|
|
warehouseStorageOrderDetail.setMaterialNo(exchangeDetail.getMaterialNo()); |
|
|
|
warehouseStorageOrderDetail.setMaterialName(exchangeDetail.getMaterialName()); |
|
|
|
warehouseStorageOrderDetail.setMaterialType(exchangeDetail.getMaterialType()); |
|
|
|
warehouseStorageOrderDetail.setMaterialPhotourl(exchangeDetail.getMaterialPhotourl()); |
|
|
|
warehouseStorageOrderDetail.setMaterialBrand(exchangeDetail.getMaterialBrand()); |
|
|
|
warehouseStorageOrderDetail.setMaterialUnit(exchangeDetail.getMaterialUnit()); |
|
|
|
warehouseStorageOrderDetail.setMaterialDescribe(exchangeDetail.getMaterialDescribe()); |
|
|
|
warehouseStorageOrderDetail.setMaterialProcessMethod(exchangeDetail.getMaterialProcessMethod()); |
|
|
|
warehouseStorageOrderDetail.setMaterialDeptType("0"); |
|
|
|
warehouseStorageOrderDetail.setRefundsExchangesNum(exchangeDetail.getRefundsExchangesNum()); |
|
|
|
warehouseStorageOrderDetail.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
warehouseStorageOrderDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
detailList.add(warehouseStorageOrderDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
return detailList; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 修改品质管理退换货单 |
|
|
|
* |
|
|
@ -192,24 +291,40 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan |
|
|
|
if (StringUtils.isEmpty(refundsExchangesDetails)){ |
|
|
|
log.warn("退款换货单[{}]无关联的物料详情信息", qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
} |
|
|
|
|
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrderDetailMapper.selectStorageOrderDetailListByCode(qualityRefundsExchanges.getInStorageCode()); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("退款换货单[{}]无关联的入库单详情信息", qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
} |
|
|
|
int updateRows = 0; |
|
|
|
for (QualityRefundsExchangesDetail refundsExchangesDetail : refundsExchangesDetails) { |
|
|
|
refundsExchangesDetail.setRefundsExchangesCode(qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
refundsExchangesDetail.setDeliveryInspectionTime(qualityRefundsExchanges.getDeliveryInspectionTime()); |
|
|
|
refundsExchangesDetail.setQualityRemark(qualityRefundsExchanges.getQualityRemark()); |
|
|
|
|
|
|
|
refundsExchangesDetail.setUpdateBy(loginName); |
|
|
|
refundsExchangesDetail.setUpdateTime(new Date()); |
|
|
|
refundsExchangesDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
|
|
for (WarehouseStorageOrderDetail storageOrderDetail:warehouseStorageOrderDetailList) { |
|
|
|
if(storageOrderDetail.getMaterialNo().equals(refundsExchangesDetail.getMaterialNo())){ |
|
|
|
storageOrderDetail.setSupplierCode(refundsExchangesDetail.getSupplierCode()); |
|
|
|
storageOrderDetail.setSupplierName(refundsExchangesDetail.getSupplierName()); |
|
|
|
storageOrderDetail.setSupplierAddress(refundsExchangesDetail.getSupplierAddress()); |
|
|
|
storageOrderDetail.setCustomerContact(refundsExchangesDetail.getCustomerContact()); |
|
|
|
storageOrderDetail.setContactNumber(refundsExchangesDetail.getContactNumber()); |
|
|
|
storageOrderDetail.setUpdateBy(loginName); |
|
|
|
storageOrderDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
warehouseStorageOrderDetailMapper.updateWarehouseStorageOrderDetail(storageOrderDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
//更新数据库记录
|
|
|
|
updateRows += refundsExchangesDetailMapper.updateQualityRefundsExchangesDetail(refundsExchangesDetail); |
|
|
|
|
|
|
|
} |
|
|
|
qualityRefundsExchanges.setQualityPurchaseStatus("1"); |
|
|
|
qualityRefundsExchanges.setUpdateBy(loginName); |
|
|
|
qualityRefundsExchanges.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
qualityRefundsExchangesMapper.updateQualityRefundsExchanges(qualityRefundsExchanges); |
|
|
|
return updateRows; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存入库前退货-确认供应商 |
|
|
|
* 保存入库前退货-确认收货 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int updateBeforeConfirmDelivery(QualityRefundsExchanges qualityRefundsExchanges) { |
|
|
@ -224,12 +339,28 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan |
|
|
|
for (QualityRefundsExchangesDetail refundsExchangesDetail : refundsExchangesDetails) { |
|
|
|
refundsExchangesDetail.setRefundsExchangesCode(qualityRefundsExchanges.getRefundsExchangesCode()); |
|
|
|
refundsExchangesDetail.setUpdateBy(loginName); |
|
|
|
refundsExchangesDetail.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
refundsExchangesDetail.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
int purchaseStatus = Integer.parseInt(refundsExchangesDetail.getQualityDeliveryStatus()); |
|
|
|
refundsExchangesDetail.setQualityPurchaseStatus(String.valueOf((purchaseStatus+2))); |
|
|
|
//更新数据库记录
|
|
|
|
updateRows += refundsExchangesDetailMapper.updateQualityRefundsExchangesDetail(refundsExchangesDetail); |
|
|
|
|
|
|
|
} |
|
|
|
boolean allStatusZero = refundsExchangesDetails.stream() |
|
|
|
.allMatch(detail -> "0".equals(detail.getQualityDeliveryStatus())); |
|
|
|
boolean hasStatusOne = refundsExchangesDetails.stream() |
|
|
|
.anyMatch(detail -> "1".equals(detail.getQualityDeliveryStatus())); |
|
|
|
boolean allStatusTwo = refundsExchangesDetails.stream() |
|
|
|
.allMatch(detail -> "2".equals(detail.getQualityDeliveryStatus())); |
|
|
|
if(allStatusZero){ |
|
|
|
qualityRefundsExchanges.setQualityPurchaseStatus("2"); |
|
|
|
}else if(hasStatusOne){ |
|
|
|
qualityRefundsExchanges.setQualityPurchaseStatus("3"); |
|
|
|
}else if(allStatusTwo){ |
|
|
|
qualityRefundsExchanges.setQualityPurchaseStatus("4"); |
|
|
|
} |
|
|
|
qualityRefundsExchanges.setUpdateBy(loginName); |
|
|
|
qualityRefundsExchanges.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
qualityRefundsExchangesMapper.updateQualityRefundsExchanges(qualityRefundsExchanges); |
|
|
|
return updateRows; |
|
|
|
} |
|
|
|
|
|
|
|