|
@ -4,13 +4,18 @@ import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
|
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
|
|
import com.ruoyi.system.domain.SysMakeOrder; |
|
|
import com.ruoyi.system.domain.SysMakeorderPickDetail; |
|
|
import com.ruoyi.system.domain.SysMakeorderPickDetail; |
|
|
import com.ruoyi.system.domain.SysMakeorderPickVo; |
|
|
import com.ruoyi.system.domain.SysMakeorderPickVo; |
|
|
|
|
|
import com.ruoyi.system.domain.SysSalesOrder; |
|
|
|
|
|
import com.ruoyi.system.mapper.SysMakeOrderMapper; |
|
|
import com.ruoyi.system.mapper.SysMakeorderPickDetailMapper; |
|
|
import com.ruoyi.system.mapper.SysMakeorderPickDetailMapper; |
|
|
import com.ruoyi.system.mapper.SysMakeorderPickMapper; |
|
|
import com.ruoyi.system.mapper.SysMakeorderPickMapper; |
|
|
|
|
|
import com.ruoyi.system.mapper.SysSalesOrderMapper; |
|
|
import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; |
|
|
import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
@ -21,6 +26,7 @@ import com.ruoyi.warehouse.domain.WarehouseOutOrder; |
|
|
import com.ruoyi.warehouse.service.IWarehouseOutOrderService; |
|
|
import com.ruoyi.warehouse.service.IWarehouseOutOrderService; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 仓库出库单Service业务层处理 |
|
|
* 仓库出库单Service业务层处理 |
|
@ -44,6 +50,12 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysMakeorderPickDetailMapper makeorderPickDetailMapper; |
|
|
private SysMakeorderPickDetailMapper makeorderPickDetailMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysMakeOrderMapper sysMakeOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysSalesOrderMapper sysSalesOrderMapper; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private RedisCache redisCache; |
|
|
private RedisCache redisCache; |
|
|
|
|
|
|
|
@ -238,7 +250,7 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService |
|
|
SysMakeorderPickVo tempSysMakeorderPickVo = sysMakeorderPickMapper.selectSysMakeorderPickById(sysMakeorderPickVo.getId()); |
|
|
SysMakeorderPickVo tempSysMakeorderPickVo = sysMakeorderPickMapper.selectSysMakeorderPickById(sysMakeorderPickVo.getId()); |
|
|
if (tempSysMakeorderPickVo == null){ |
|
|
if (tempSysMakeorderPickVo == null){ |
|
|
log.warn("生产领料单数据为空:{}",sysMakeorderPickVo.getId()); |
|
|
log.warn("生产领料单数据为空:{}",sysMakeorderPickVo.getId()); |
|
|
throw new RuntimeException("生产领料单数据为空:" + sysMakeorderPickVo.getId()); |
|
|
throw new BusinessException("生产领料单数据为空:" + sysMakeorderPickVo.getId()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String outOrderCode = redisCache.generateBillNo("CK"); |
|
|
String outOrderCode = redisCache.generateBillNo("CK"); |
|
@ -259,7 +271,7 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService |
|
|
int insertResult = warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder); |
|
|
int insertResult = warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder); |
|
|
if (insertResult <= 0){ |
|
|
if (insertResult <= 0){ |
|
|
log.warn("添加出库单信息失败"); |
|
|
log.warn("添加出库单信息失败"); |
|
|
throw new RuntimeException("添加出库单信息失败"); |
|
|
throw new BusinessException("添加出库单信息失败"); |
|
|
} |
|
|
} |
|
|
//生成出库单详情相关信息
|
|
|
//生成出库单详情相关信息
|
|
|
generateWarehouseOutOrder(sysMakeorderPickVo, tempSysMakeorderPickVo, outOrderCode); |
|
|
generateWarehouseOutOrder(sysMakeorderPickVo, tempSysMakeorderPickVo, outOrderCode); |
|
@ -304,4 +316,73 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService |
|
|
outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail); |
|
|
outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* 生产单-出库 |
|
|
|
|
|
* */ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
@Override |
|
|
|
|
|
public int updateMakeOutWarehouse(WarehouseOutOrder warehouseOutOrder) { |
|
|
|
|
|
|
|
|
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
|
|
// 参数校验
|
|
|
|
|
|
if (warehouseOutOrder == null || StringUtils.isEmpty(warehouseOutOrder.getMakeNo())) { |
|
|
|
|
|
throw new BusinessException("更新出库单信息失败:缺少必要参数"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
warehouseOutOrder.setUpdateBy(loginName); |
|
|
|
|
|
warehouseOutOrder.setUpdateTime(new Date()); |
|
|
|
|
|
//表面已出库
|
|
|
|
|
|
warehouseOutOrder.setWarehouseOutStatus("7"); |
|
|
|
|
|
warehouseOutOrder.setOutOrderTime(new Date()); |
|
|
|
|
|
warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); |
|
|
|
|
|
|
|
|
|
|
|
//更新生产订单信息
|
|
|
|
|
|
SysMakeOrder sysMakeOrder = new SysMakeOrder(); |
|
|
|
|
|
sysMakeOrder.setMakeNo(warehouseOutOrder.getMakeNo()); |
|
|
|
|
|
sysMakeOrder.setUpdateBy(loginName); |
|
|
|
|
|
sysMakeOrder.setUpdateTime(new Date()); |
|
|
|
|
|
//表示生产中
|
|
|
|
|
|
sysMakeOrder.setMakeStatus("4"); |
|
|
|
|
|
|
|
|
|
|
|
int updateMakeOrderResult = sysMakeOrderMapper.updateByMakeNo(sysMakeOrder); |
|
|
|
|
|
if (updateMakeOrderResult <= 0){ |
|
|
|
|
|
log.warn("更新生产订单信息失败"); |
|
|
|
|
|
throw new BusinessException("更新生产订单信息失败"); |
|
|
|
|
|
} |
|
|
|
|
|
//根据生产订单号查询数据库中生产订单的销售订单号
|
|
|
|
|
|
SysMakeOrder tempSysMakeOrder = sysMakeOrderMapper.selectSaleNoByMakeNo(warehouseOutOrder.getMakeNo()); |
|
|
|
|
|
if (tempSysMakeOrder == null || StringUtils.isEmpty(tempSysMakeOrder.getSaleNo())) { |
|
|
|
|
|
throw new BusinessException("无法找到与生产订单关联的销售订单"); |
|
|
|
|
|
} |
|
|
|
|
|
//更新销售订单信息
|
|
|
|
|
|
SysSalesOrder sysSalesOrder = new SysSalesOrder(); |
|
|
|
|
|
sysSalesOrder.setSalesOrderCode(tempSysMakeOrder.getSaleNo()); |
|
|
|
|
|
sysSalesOrder.setUpdateBy(loginName); |
|
|
|
|
|
sysSalesOrder.setUpdateTime(new Date()); |
|
|
|
|
|
//表示生产中
|
|
|
|
|
|
sysSalesOrder.setMakeStatus("4"); |
|
|
|
|
|
int updateSalesOrderResult = sysSalesOrderMapper.updateSysSalesOrderBySalesOrderCode(sysSalesOrder); |
|
|
|
|
|
if (updateSalesOrderResult <= 0){ |
|
|
|
|
|
log.warn("更新销售订单信息失败"); |
|
|
|
|
|
throw new BusinessException("更新销售订单信息失败"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<WarehouseOutOrderDetail> warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); |
|
|
|
|
|
if (CollectionUtils.isEmpty(warehouseOutOrderDetailList)){ |
|
|
|
|
|
log.warn("保存生产单出库,物料列表信息为空:{}",warehouseOutOrder); |
|
|
|
|
|
}else { |
|
|
|
|
|
int updateRows = 0; |
|
|
|
|
|
for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { |
|
|
|
|
|
warehouseOutOrderDetail.setUpdateBy(loginName); |
|
|
|
|
|
warehouseOutOrderDetail.setUpdateTime(new Date()); |
|
|
|
|
|
warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark()); |
|
|
|
|
|
//更新数据库记录
|
|
|
|
|
|
updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); |
|
|
|
|
|
} |
|
|
|
|
|
return updateRows; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|