|
|
@ -18,7 +18,12 @@ import com.ruoyi.quality.mapper.QualityOrderMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityOrderReportMapper; |
|
|
|
import com.ruoyi.quality.mapper.QualityOrderReportUnqualifiedMapper; |
|
|
|
import com.ruoyi.quality.service.IQualityOrderService; |
|
|
|
import com.ruoyi.system.domain.SysMakeOrder; |
|
|
|
import com.ruoyi.system.domain.SysSalesOrder; |
|
|
|
import com.ruoyi.system.mapper.SysMakeOrderMapper; |
|
|
|
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 lombok.extern.slf4j.Slf4j; |
|
|
@ -55,6 +60,16 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
@Autowired |
|
|
|
private ISysMakeOrderService sysMakeOrderService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysSalesOrderMapper salesOrderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ISysSalesOrderService salesOrderService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysMakeOrderMapper sysMakeOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisCache redisCache; |
|
|
|
|
|
|
@ -434,7 +449,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//设置委内加工费单价
|
|
|
|
warehouseStorageOrderDetail.setMakeInUnitPrice(qualityOrderDetail.getMakeInUnitPrice()); |
|
|
|
//设置品质已合格数
|
|
|
|
warehouseStorageOrderDetail.setQualityHasQualifiedNum(qualityOrderDetail.getQualityHasqualifiedNum()); |
|
|
|
warehouseStorageOrderDetail.setQualityHasQualifiedNum(qualityOrderDetail.getQualityQualifiedNum()); |
|
|
|
warehouseStorageOrderDetail.setMaterialNo(qualityOrderDetail.getMaterialNo()); |
|
|
|
warehouseStorageOrderDetail.setMaterialName(qualityOrderDetail.getMaterialName()); |
|
|
|
warehouseStorageOrderDetail.setMaterialBrand(qualityOrderDetail.getMaterialBrand()); |
|
|
@ -615,7 +630,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
//生产入库数
|
|
|
|
warehouseStorageOrderDetail.setMakeStorageNum(qualityOrderDetail.getMakeCompletionNum()); |
|
|
|
//设置品质已合格数
|
|
|
|
warehouseStorageOrderDetail.setQualityHasQualifiedNum(qualityOrderDetail.getQualityHasqualifiedNum()); |
|
|
|
warehouseStorageOrderDetail.setQualityHasQualifiedNum(qualityOrderDetail.getQualityQualifiedNum()); |
|
|
|
warehouseStorageOrderDetail.setMaterialNo(qualityOrderDetail.getMaterialNo()); |
|
|
|
warehouseStorageOrderDetail.setMaterialName(qualityOrderDetail.getMaterialName()); |
|
|
|
warehouseStorageOrderDetail.setMaterialBrand(qualityOrderDetail.getMaterialBrand()); |
|
|
@ -720,33 +735,97 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS |
|
|
|
/* |
|
|
|
* 入库-生产订单 |
|
|
|
* */ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int updateStorageMake(WarehouseStorageOrder warehouseStorageOrder) { |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
|
|
|
|
//假设全部入库
|
|
|
|
warehouseStorageOrder.setWarehouseStorageStatus("4"); |
|
|
|
warehouseStorageOrder.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
warehouseStorageOrder.setUpdateTime(new Date()); |
|
|
|
//记录一下入库时间
|
|
|
|
warehouseStorageOrder.setStorageTime(new Date()); |
|
|
|
String warehouseCode = warehouseStorageOrder.getWarehouseCode(); |
|
|
|
String warehouseName = warehouseStorageOrder.getWarehouseName(); |
|
|
|
if (StringUtils.isNotEmpty(warehouseCode)){ |
|
|
|
warehouseStorageOrder.setWarehouseCode(warehouseCode); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(warehouseName)){ |
|
|
|
warehouseStorageOrder.setWarehouseName(warehouseName); |
|
|
|
} |
|
|
|
|
|
|
|
List<WarehouseStorageOrderDetail> storageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
List<WarehouseStorageOrderDetail> warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); |
|
|
|
if (StringUtils.isEmpty(warehouseStorageOrderDetailList)){ |
|
|
|
log.warn("入库单详情数据为空:{}",warehouseStorageOrderDetailList); |
|
|
|
throw new BusinessException("入库单详情数据为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isEmpty(storageOrderDetailList)){ |
|
|
|
log.warn("入库单详情为空:{}",storageOrderDetailList); |
|
|
|
}else { |
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : storageOrderDetailList) { |
|
|
|
warehouseStorageOrderDetail.setWarehouseStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); |
|
|
|
WarehouseStorageOrderDetail tempStorageOrderDetail = new WarehouseStorageOrderDetail(); |
|
|
|
tempStorageOrderDetail.setMaterialNo(warehouseStorageOrderDetail.getMaterialNo()); |
|
|
|
tempStorageOrderDetail.setCustomerId(warehouseStorageOrderDetail.getCustomerId()); |
|
|
|
tempStorageOrderDetail.setWarehouseStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); |
|
|
|
WarehouseStorageOrderDetail storageOrderDetailFromData = storageOrderDetailMapper.selectWarehouseStorageMakeOrderByObject(tempStorageOrderDetail); |
|
|
|
if (storageOrderDetailFromData == null){ |
|
|
|
log.warn("数据库中入库单详情为空:{}",tempStorageOrderDetail); |
|
|
|
}else { |
|
|
|
storageOrderDetailMapper.updateWarehouseStorageMakeOrderDetailByObject(warehouseStorageOrderDetail); |
|
|
|
//入库数
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
//更新生产订单的数据
|
|
|
|
SysMakeOrder tempSysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(warehouseStorageOrder.getRelatedOrderCode()); |
|
|
|
tempSysMakeOrder.setEceiptNum(Long.valueOf(storageNum)); |
|
|
|
//设置生产状态为全部完成
|
|
|
|
tempSysMakeOrder.setMakeStatus("6"); |
|
|
|
int updateMakeOrderResult = sysMakeOrderService.updateByMakeNo(tempSysMakeOrder); |
|
|
|
if (updateMakeOrderResult <= 0){ |
|
|
|
throw new BusinessException("更新生产订单数据失败"); |
|
|
|
} |
|
|
|
|
|
|
|
//更新销售订单数据
|
|
|
|
SysSalesOrder sysSalesOrder = salesOrderMapper.selectSysSalesOrderBySalesOrderCode(tempSysMakeOrder.getSaleNo()); |
|
|
|
//设置为全部完成
|
|
|
|
sysSalesOrder.setMakeStatus("6"); |
|
|
|
//设置为待出货
|
|
|
|
sysSalesOrder.setDeliveryStatus("2"); |
|
|
|
int updateSalesOrderResult = salesOrderService.updateSysSalesOrderBySalesOrderCode(sysSalesOrder); |
|
|
|
if (updateSalesOrderResult <= 0){ |
|
|
|
throw new BusinessException("更新销售订单数据失败"); |
|
|
|
} |
|
|
|
|
|
|
|
return warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); |
|
|
|
|
|
|
|
// //更新生产单数据
|
|
|
|
// int updateMakeOrderResult = sysMakeOrderService.updateSysMakeOrderByWarehouseStorageOrder(warehouseStorageOrder, warehouseStorageOrderDetailList);
|
|
|
|
// if (updateMakeOrderResult <= 0){
|
|
|
|
// throw new BusinessException("更新生产订单失败,未影响任何行");
|
|
|
|
// }
|
|
|
|
|
|
|
|
for (WarehouseStorageOrderDetail warehouseStorageOrderDetail : warehouseStorageOrderDetailList) { |
|
|
|
//更新入库单详情的数据
|
|
|
|
warehouseStorageOrderDetail.setUpdateBy(loginName); |
|
|
|
warehouseStorageOrderDetail.setUpdateTime(new Date()); |
|
|
|
//更新已入库数
|
|
|
|
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("更新入库单失败,未影响任何行"); |
|
|
|
} |
|
|
|
return updateResult; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|