|
|
|
@ -1172,7 +1172,8 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (ProOrderWorkorder workOrder : workOrders) {
|
|
|
|
|
for (int m=0;m<workOrders.size();m++) {
|
|
|
|
|
ProOrderWorkorder workOrder = workOrders.get(m);
|
|
|
|
|
ProOrderWorkorderBatch batch = new ProOrderWorkorderBatch();
|
|
|
|
|
|
|
|
|
|
batch.setBatchId(IdUtils.fastSimpleUUID());
|
|
|
|
@ -1187,12 +1188,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
|
|
|
|
|
if(proOrderWorkorderBatch.getNewBatchQuantity() != null){
|
|
|
|
|
Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity();
|
|
|
|
|
if ("0".equals(workOrder.getParentOrder())) {
|
|
|
|
|
// 设置父工单数量
|
|
|
|
|
batch.setBatchQuantity(newBatchQuantity);
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
if(m==0){
|
|
|
|
|
// 设置子工单数量
|
|
|
|
|
batch.setBatchQuantity(newBatchQuantity * coefficient);
|
|
|
|
|
batch.setBatchQuantity(newBatchQuantity);
|
|
|
|
|
}else{
|
|
|
|
|
BigDecimal pQuantity = new BigDecimal(workOrders.get(m).getQuantitySplit());
|
|
|
|
|
BigDecimal cQuantity = new BigDecimal(workOrders.get(m-1).getQuantitySplit());
|
|
|
|
|
|
|
|
|
|
batch.setBatchQuantity(pQuantity.divide(cQuantity)
|
|
|
|
|
.multiply(new BigDecimal(newBatchQuantity)).longValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1202,7 +1207,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public int updateWorkOrderBatch(ProOrderWorkorderBatch proOrderWorkorderBatch) {
|
|
|
|
|
String workOrderCode = proOrderWorkorderBatch.getWorkorderCode();
|
|
|
|
@ -1211,24 +1216,10 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
String newBatchCode = proOrderWorkorderBatch.getNewBatchCode();
|
|
|
|
|
|
|
|
|
|
List<ProOrderWorkorder> workOrders = proOrderWorkorderMapper.selectWorkOrderIdByBatch(workOrderCode);
|
|
|
|
|
// 系数
|
|
|
|
|
Long coefficient = 1L;
|
|
|
|
|
if(workOrders.size()==2){
|
|
|
|
|
// 获取子母工单数量
|
|
|
|
|
Optional<Long> pQuantity = workOrders.stream().filter(item -> "0".equals(item.getParentOrder()))
|
|
|
|
|
.findFirst().map(ProOrderWorkorder::getQuantitySplit);
|
|
|
|
|
Optional<Long> cQuantity = workOrders.stream().filter(item -> !"0".equals(item.getParentOrder()))
|
|
|
|
|
.findFirst().map(ProOrderWorkorder::getQuantitySplit);
|
|
|
|
|
|
|
|
|
|
if (pQuantity.isPresent() && cQuantity.isPresent()) {
|
|
|
|
|
coefficient = cQuantity.get() / pQuantity.get();
|
|
|
|
|
}
|
|
|
|
|
}else if(workOrders.size()==3){
|
|
|
|
|
//TODO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (ProOrderWorkorder workOrder : workOrders) {
|
|
|
|
|
for (int m=0;m<workOrders.size();m++) {
|
|
|
|
|
ProOrderWorkorder workOrder = workOrders.get(m);
|
|
|
|
|
ProOrderWorkorderBatch batch = new ProOrderWorkorderBatch();
|
|
|
|
|
|
|
|
|
|
batch.setBatchId(IdUtils.fastSimpleUUID());
|
|
|
|
@ -1243,16 +1234,17 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
|
|
|
|
|
|
|
|
|
|
if(proOrderWorkorderBatch.getNewBatchQuantity() != null){
|
|
|
|
|
Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity();
|
|
|
|
|
if (newBatchQuantity == null) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if ("0".equals(workOrder.getParentOrder())) {
|
|
|
|
|
// 设置父工单数量
|
|
|
|
|
batch.setNewBatchQuantity(newBatchQuantity);
|
|
|
|
|
}else {
|
|
|
|
|
if(m==0){
|
|
|
|
|
// 设置子工单数量
|
|
|
|
|
batch.setNewBatchQuantity(newBatchQuantity * coefficient);
|
|
|
|
|
batch.setNewBatchQuantity(newBatchQuantity);
|
|
|
|
|
}else{
|
|
|
|
|
BigDecimal pQuantity = new BigDecimal(workOrders.get(m).getQuantitySplit());
|
|
|
|
|
BigDecimal cQuantity = new BigDecimal(workOrders.get(m-1).getQuantitySplit());
|
|
|
|
|
|
|
|
|
|
batch.setNewBatchQuantity(pQuantity.divide(cQuantity)
|
|
|
|
|
.multiply(new BigDecimal(newBatchQuantity)).longValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
count += proOrderWorkorderBatchMapper.updateWorkorderBatch(batch);
|
|
|
|
|