|
|
|
@ -61,6 +61,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -170,6 +171,11 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
@Override |
|
|
|
|
@Transactional(readOnly = false, rollbackFor = Exception.class) |
|
|
|
|
public List<ZyPlanProcess> syncProductBaseProcess(ZyPlanProcess zyPlanProcess) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//重新同步数据,先删除之前已同步数据
|
|
|
|
|
this.delSyncData(zyPlanProcess); |
|
|
|
|
|
|
|
|
|
int count = this.count(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId())); |
|
|
|
|
//生产计划工序表没有对应工序时,说明没有制定过该产品的生产工序计划,先把该产品对应的基本工序数据插入到生产计划工序表
|
|
|
|
|
if (count == 0) { |
|
|
|
@ -187,17 +193,16 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
//产品基本工序
|
|
|
|
|
List<ZyProductProcess> productProcessesList = iZyProductProcessService.list(new LambdaQueryWrapper<ZyProductProcess>() |
|
|
|
|
.eq(ZyProductProcess::getProductId, zyProduct.getId())); |
|
|
|
|
|
|
|
|
|
if (!ObjectUtils.isEmpty(productProcessesList)) { |
|
|
|
|
List<ZyPlanProcess> saveList = new LinkedList<>(); |
|
|
|
|
productProcessesList.forEach(o -> { |
|
|
|
|
ZyPlanProcess en = new ZyPlanProcess(); |
|
|
|
|
en.setProcessId(o.getProcessId()); |
|
|
|
|
ZyProcess zyProcess = iZyProcessService.getById(o.getProcessId()); |
|
|
|
|
en.setProcessName(zyProcess.getProcessName()); |
|
|
|
|
en.setProcessName(StringUtils.isNotBlank(zyProcess.getProcessName()) ? zyProcess.getProcessName() : ""); |
|
|
|
|
en.setPlanId(zyPlanProcess.getPlanId()); |
|
|
|
|
en.setTotalMachine(zyProcess.getTotalMachine()); |
|
|
|
|
en.setTotalMaunal(zyProcess.getTotalMaunal()); |
|
|
|
|
en.setTotalMachine(!ObjectUtils.isEmpty(zyProcess.getTotalMachine()) ? zyProcess.getTotalMachine() : 0); |
|
|
|
|
en.setTotalMaunal(!ObjectUtils.isEmpty(zyProcess.getTotalMaunal()) ? zyProcess.getTotalMaunal() : 0); |
|
|
|
|
saveList.add(en); |
|
|
|
|
}); |
|
|
|
|
this.saveBatch(saveList); |
|
|
|
@ -246,6 +251,18 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(readOnly = false, rollbackFor = Exception.class) |
|
|
|
|
public void delSyncData(ZyPlanProcess zyPlanProcess) { |
|
|
|
|
List<ZyPlanProcess> planProcessList = this.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(planProcessList)) { |
|
|
|
|
List<String> collect = Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).stream().map(ZyPlanProcess::getProcessId).collect(Collectors.toList()); |
|
|
|
|
iZyPlanProcessFabricService.remove(new LambdaQueryWrapper<ZyPlanProcessFabric>().in(ZyPlanProcessFabric::getPlanProcessId, collect)); |
|
|
|
|
iZyPlanProcessAccessoriesService.remove(new LambdaQueryWrapper<ZyPlanProcessAccessories>().in(ZyPlanProcessAccessories::getPlanProcessId, collect)); |
|
|
|
|
this.remove(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void saveBatchAccessoriesByProcessIdList(List<ZyPlanProcess> planProcessList) { |
|
|
|
|
Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).forEach(e -> { |
|
|
|
|
List<ZyProcessAccessories> accessoriesList = this.iZyProcessAccessoriesService.list(new LambdaQueryWrapper<ZyProcessAccessories>() |
|
|
|
@ -265,21 +282,39 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void saveBatchFabricByProcessIdList(List<ZyPlanProcess> planProcessList) { |
|
|
|
|
Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).forEach(e -> { |
|
|
|
|
List<ZyProcessFabric> fabricList = this.iZyProcessFabricService.list(new LambdaQueryWrapper<ZyProcessFabric>() |
|
|
|
|
.eq(ZyProcessFabric::getProcessId, e.getProcessId())); |
|
|
|
|
List<ZyPlanProcessFabric> list = new LinkedList<>(); |
|
|
|
|
Optional.ofNullable(fabricList).orElse(new ArrayList<>()).forEach(obj -> { |
|
|
|
|
ZyPlanProcessFabric en = new ZyPlanProcessFabric(); |
|
|
|
|
en.setPlanProcessId(e.getProcessId()); |
|
|
|
|
en.setPlanId(e.getPlanId()); |
|
|
|
|
en.setFabricId(obj.getFabricId()); |
|
|
|
|
ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId()); |
|
|
|
|
en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : ""); |
|
|
|
|
list.add(en); |
|
|
|
|
|
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(planProcessList)) { |
|
|
|
|
planProcessList.forEach(e -> { |
|
|
|
|
List<ZyProcessFabric> fabricList = this.iZyProcessFabricService.list(new LambdaQueryWrapper<ZyProcessFabric>() |
|
|
|
|
.eq(ZyProcessFabric::getProcessId, e.getProcessId())); |
|
|
|
|
List<ZyPlanProcessFabric> list = new LinkedList<>(); |
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(fabricList)) { |
|
|
|
|
fabricList.forEach(obj -> { |
|
|
|
|
ZyPlanProcessFabric en = new ZyPlanProcessFabric(); |
|
|
|
|
en.setPlanProcessId(e.getProcessId()); |
|
|
|
|
en.setPlanId(e.getPlanId()); |
|
|
|
|
en.setFabricId(obj.getFabricId()); |
|
|
|
|
ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId()); |
|
|
|
|
en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : ""); |
|
|
|
|
list.add(en); |
|
|
|
|
}); |
|
|
|
|
iZyPlanProcessFabricService.saveBatch(list); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
iZyPlanProcessFabricService.saveBatch(list); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Optional.ofNullable(planProcessList).orElse(null).forEach(e -> {
|
|
|
|
|
// Optional.ofNullable(fabricList).orElse(null).forEach(obj -> {
|
|
|
|
|
// ZyPlanProcessFabric en = new ZyPlanProcessFabric();
|
|
|
|
|
// en.setPlanProcessId(e.getProcessId());
|
|
|
|
|
// en.setPlanId(e.getPlanId());
|
|
|
|
|
// en.setFabricId(obj.getFabricId());
|
|
|
|
|
// ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId());
|
|
|
|
|
// en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : "");
|
|
|
|
|
// list.add(en);
|
|
|
|
|
// });
|
|
|
|
|
// iZyPlanProcessFabricService.saveBatch(list);
|
|
|
|
|
// });
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|