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