|
|
@ -21,6 +21,7 @@ import com.ruoyi.system.mapper.SysUserMapper; |
|
|
|
import com.ruoyi.system.service.ISysMakeorderPickDetailService; |
|
|
|
import com.ruoyi.system.service.ISysMakeorderPickService; |
|
|
|
import com.ruoyi.system.service.ISysRoleService; |
|
|
|
import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; |
|
|
|
import com.ruoyi.warehouse.service.IWarehouseOutOrderService; |
|
|
|
import org.activiti.engine.TaskService; |
|
|
|
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl; |
|
|
@ -31,6 +32,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -70,6 +72,9 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService |
|
|
|
@Autowired |
|
|
|
private BizTodoItemMapper todoItemMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IWarehouseOutOrderService warehouseOutOrderService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询生产领料单 |
|
|
|
* |
|
|
@ -179,17 +184,44 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService |
|
|
|
sysMakeorderPick.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
|
|
|
//保留领料单数不为空的数据
|
|
|
|
List<SysMakeorderPickDetail> filterPickDetails = pickDetails.stream().filter(details -> details.getPickNum() != null&& details.getPickNum() > 0).collect(Collectors.toList()); |
|
|
|
List<SysMakeorderPickDetail> filterPickDetails = pickDetails.stream() |
|
|
|
.filter(details -> details.getPickNum() != null&& details.getPickNum() > 0) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isEmpty(filterPickDetails)){ |
|
|
|
throw new BusinessException("领料数不能全为空!"); |
|
|
|
} |
|
|
|
//合并相同料号数据,合计该物料总领料数
|
|
|
|
List<SysMakeorderPickDetail> mergedDetails = pickDetails.stream() |
|
|
|
.collect(Collectors.groupingBy(SysMakeorderPickDetail::getMaterialNo)) |
|
|
|
.values().stream() |
|
|
|
.map(group -> { |
|
|
|
// 取第一个对象
|
|
|
|
SysMakeorderPickDetail tempPickDetail = group.get(0); |
|
|
|
BigDecimal storageNum = tempPickDetail.getStorageNum(); |
|
|
|
// 计算领料数的总和
|
|
|
|
long totalPickupQuantity = group.stream() |
|
|
|
.mapToLong(SysMakeorderPickDetail::getPickNum) |
|
|
|
.sum(); |
|
|
|
SysMakeorderPickDetail pickDetail = new SysMakeorderPickDetail(); |
|
|
|
pickDetail.setMaterialNo(tempPickDetail.getMaterialNo()); |
|
|
|
pickDetail.setStorageNum(storageNum); |
|
|
|
pickDetail.setPickNum(totalPickupQuantity); |
|
|
|
return pickDetail; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//遍历合并后数据,查看总领料数是否大于可用库存数
|
|
|
|
for (SysMakeorderPickDetail pickDetail: mergedDetails) { |
|
|
|
if(pickDetail.getPickNum()>pickDetail.getStorageNum().longValue()){ |
|
|
|
throw new BusinessException("物料" +pickDetail.getMaterialNo() + "总领料数超出可用库存数,请检查"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Integer enterpriseSum = (int) filterPickDetails.stream() |
|
|
|
.mapToLong(SysMakeorderPickDetail::getPickNum) |
|
|
|
.sum(); |
|
|
|
|
|
|
|
sysMakeorderPick.setEnterpriseSum(enterpriseSum); |
|
|
|
sysMakeorderPick.setMaterialSum(filterPickDetails.size()); |
|
|
|
sysMakeorderPick.setMaterialSum(mergedDetails.size()); |
|
|
|
|
|
|
|
for (SysMakeorderPickDetail pickDetail:filterPickDetails) { |
|
|
|
if(pickDetail.getPickNum()>pickDetail.getStorageNum().intValue()){ |
|
|
@ -213,8 +245,8 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int id = sysMakeorderPickMapper.insertSysMakeorderPick(sysMakeorderPick); |
|
|
|
return id; |
|
|
|
int insertResult = sysMakeorderPickMapper.insertSysMakeorderPick(sysMakeorderPick); |
|
|
|
return insertResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -306,6 +338,9 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService |
|
|
|
if(processIsFinish){ |
|
|
|
// 审核状态-审核通过
|
|
|
|
makeorderPick.setAuditStatus("1"); |
|
|
|
//如果领料单审核通过,生成出库单
|
|
|
|
SysMakeorderPickVo makeorderPickVo = sysMakeorderPickMapper.selectSysMakeorderPickById(makeorderPick.getId()); |
|
|
|
warehouseOutOrderService.generateWarehouseOutOrderByMakeorderPick(makeorderPickVo); |
|
|
|
} |
|
|
|
sysMakeorderPickMapper.updateSysMakeorderPick(makeorderPick); |
|
|
|
return processInstance; |
|
|
|