package com.qianwen.smartman.modules.cps.service.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import java.lang.invoke.SerializedLambda; import java.math.BigDecimal; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.qianwen.smartman.common.constant.CommonGroupConstant; import com.qianwen.smartman.common.constant.CraftConstant; import com.qianwen.smartman.common.utils.MessageUtils; import com.qianwen.core.log.exception.ServiceException; import com.qianwen.core.mp.service.impl.BladeServiceImpl; import com.qianwen.core.tool.utils.Func; import com.qianwen.core.tool.utils.StringUtil; import com.qianwen.smartman.modules.cps.convert.ProductionCraftVersionConvert; import com.qianwen.smartman.modules.cps.dto.CraftVersionDTO; import com.qianwen.smartman.modules.cps.dto.VersionLineDTO; import com.qianwen.smartman.modules.cps.entity.CommonGroup; import com.qianwen.smartman.modules.cps.entity.CraftVersionLine; import com.qianwen.smartman.modules.cps.entity.ProductionCraftProcess; import com.qianwen.smartman.modules.cps.entity.ProductionCraftProcessRelatedFixture; import com.qianwen.smartman.modules.cps.entity.ProductionCraftVersion; import com.qianwen.smartman.modules.cps.enums.ProcessTypeEnum; import com.qianwen.smartman.modules.cps.enums.ProductionCraftStatusEnum; import com.qianwen.smartman.modules.cps.mapper.ProductionCraftVersionMapper; import com.qianwen.smartman.modules.cps.service.ICommonGroupService; import com.qianwen.smartman.modules.cps.service.ICraftVersionLineService; import com.qianwen.smartman.modules.cps.service.IProductionCraftProcessRelatedFixtureService; import com.qianwen.smartman.modules.cps.service.IProductionCraftProcessService; import com.qianwen.smartman.modules.cps.service.IProductionCraftVersionService; import com.qianwen.smartman.modules.cps.utils.ThrowFun; import com.qianwen.smartman.modules.cps.vo.CraftVersionAddVO; import com.qianwen.smartman.modules.cps.vo.CraftVersionLineVO; import com.qianwen.smartman.modules.cps.vo.ProductionCraftVersionEditVO; import com.qianwen.smartman.modules.cps.vo.ProductionCraftVersionVO; import com.qianwen.smartman.modules.system.service.IBasCoderuleService; import com.qianwen.smartman.modules.system.service.ICodeGeneratorService; import com.qianwen.smartman.modules.tpm.enums.MetaTypeEnum; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/service/impl/ProductionCraftVersionServiceImpl.class */ public class ProductionCraftVersionServiceImpl extends BladeServiceImpl implements IProductionCraftVersionService { private static final Logger log = LoggerFactory.getLogger(ProductionCraftVersionServiceImpl.class); private final ICodeGeneratorService codeGeneratorService; private final IProductionCraftProcessService craftProcessService; private final IBasCoderuleService basCodeRuleService; private final ICraftVersionLineService versionLineService; private final ICommonGroupService groupService; private final IProductionCraftProcessRelatedFixtureService relatedFixtureService; private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { String implMethodName = lambda.getImplMethodName(); boolean z = true; switch (implMethodName.hashCode()) { case -1416707747: if (implMethodName.equals("getVersionId")) { z = true; break; } break; case -983652454: if (implMethodName.equals("getEditionStatus")) { z = true; break; } break; case -75308287: if (implMethodName.equals("getName")) { z = true; break; } break; case 98245393: if (implMethodName.equals("getId")) { z = true; break; } break; case 2061868837: if (implMethodName.equals("getCraftId")) { z = false; break; } break; } switch (z) { case false: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftVersionLine") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getCraftId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getCraftId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getCraftId(); }; } break; case true: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftProcess") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getVersionId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftVersionLine") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getVersionId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftVersionLine") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getVersionId(); }; } break; case true: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { return (v0) -> { return v0.getName(); }; } break; case true: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { return (v0) -> { return v0.getEditionStatus(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { return (v0) -> { return v0.getEditionStatus(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { return (v0) -> { return v0.getEditionStatus(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { return (v0) -> { return v0.getEditionStatus(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { return (v0) -> { return v0.getEditionStatus(); }; } break; case true: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } break; } throw new IllegalArgumentException("Invalid lambda deserialization"); } public ProductionCraftVersionServiceImpl(final ICodeGeneratorService codeGeneratorService, final IProductionCraftProcessService craftProcessService, final IBasCoderuleService basCodeRuleService, final ICraftVersionLineService versionLineService, final ICommonGroupService groupService, final IProductionCraftProcessRelatedFixtureService relatedFixtureService) { this.codeGeneratorService = codeGeneratorService; this.craftProcessService = craftProcessService; this.basCodeRuleService = basCodeRuleService; this.versionLineService = versionLineService; this.groupService = groupService; this.relatedFixtureService = relatedFixtureService; } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService public List listVersion(Long id) { return this.baseMapper.listVersion(id); } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService public CraftVersionLineVO detailVersion(Long id) { CraftVersionDTO dto = this.baseMapper.detailVersion(id); VersionLineDTO line = this.versionLineService.getVersionLine(id); CraftVersionLineVO vo = ProductionCraftVersionConvert.INSTANCE.convert(dto); vo.setGroupId(line.getGroupId()); vo.setGroupName(line.getName()); vo.setGroupCode(line.getCode()); List processList = this.craftProcessService.listProcessByVersion(id); vo.setProcessList(processList); return vo; } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService @Transactional(rollbackFor = {Exception.class}) public ProductionCraftVersionVO saveCraftVersion(Long craftId, CraftVersionAddVO vo) { ProductionCraftVersion craftVersion = saveVersion(craftId, vo); saveCraftVersionLine(craftId, craftVersion.getId(), vo.getGroupIds()); return ProductionCraftVersionConvert.INSTANCE.convert(craftVersion); } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService @Transactional(rollbackFor = {Exception.class}) public Boolean removeVersion(List ids) { validEditionStatus(ids); boolean flag = removeBatchByIds(ids); List processIds = this.craftProcessService.listObjs((Wrapper) Wrappers.lambdaQuery(ProductionCraftProcess.class).select(new SFunction[]{(v0) -> { return v0.getId(); }}).in((v0) -> { return v0.getVersionId(); }, ids), c -> { return Long.valueOf(c instanceof BigDecimal ? ((BigDecimal) c).longValue() : ((Long) c).longValue()); }); if (Func.isNotEmpty(processIds)) { flag = flag && this.craftProcessService.removeVersionProcess(processIds).booleanValue(); } return Boolean.valueOf(flag); } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService @Transactional(rollbackFor = {Exception.class}) public Boolean updateVersion(ProductionCraftVersionEditVO vo) { Long versionId = vo.getId(); Long craftId = vo.getCraftId(); ProductionCraftVersion version = (ProductionCraftVersion) getById(versionId); boolean flag = ProductionCraftStatusEnum.FINALIZED.getStatus().equals(version.getEditionStatus()); ThrowFun.isTrue(flag).throwMessage(MessageUtils.message("cps.production.craft.version.has.been.finalized.can.not.edit", new Object[0])); if (!version.getName().equals(vo.getName())) { boolean existCodeRule = this.basCodeRuleService.isExistCodeRule(MetaTypeEnum.PRODUCTION_CRAFT_VERSION.getCode()); ThrowFun.isTrue(existCodeRule).throwMessage(MessageUtils.message("cps.production.craft.version.coding.rule.exists.can.not.edit", new Object[0])); } validNameExist(craftId, versionId, vo.getName()); version.setName(vo.getName()); version.setDescription(vo.getDescription()); this.versionLineService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery(CraftVersionLine.class).eq((v0) -> { return v0.getVersionId(); }, versionId)).eq((v0) -> { return v0.getCraftId(); }, craftId)); List versionLines = (List) vo.getGroupIds().stream().map(c -> { return new CraftVersionLine().setVersionId(versionId).setCraftId(craftId).setGroupId(c); }).collect(Collectors.toList()); boolean batch = this.versionLineService.saveBatch(versionLines); return Boolean.valueOf(updateById(version) && batch); } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService @Transactional(rollbackFor = {Exception.class}) public Boolean fixVersion(Long id) { List processList = this.craftProcessService.listProcessByVersion(id); ThrowFun.isTrue(Func.isEmpty(processList)).throwMessage(MessageUtils.message("cps.production.craft.version.has.no.process.and.can.not.fix.version", new Object[0])); List lineList = this.versionLineService.list((Wrapper) Wrappers.lambdaQuery(CraftVersionLine.class).eq((v0) -> { return v0.getVersionId(); }, id)); List groupIds = (List) lineList.stream().map((v0) -> { return v0.getGroupId(); }).collect(Collectors.toList()); List commonGroups = this.groupService.listByIds(groupIds); boolean fmsBeltline = commonGroups.stream().anyMatch(c -> { return CommonGroupConstant.FMS_BELTLINE.equals(c.getGroupTag()); }); if (CraftConstant.ONE.equals(Integer.valueOf(processList.size()))) { if (fmsBeltline) { validProcessMeets(processList); validProcessBindTray(processList); } return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate(ProductionCraftVersion.class).set((v0) -> { return v0.getEditionStatus(); }, ProductionCraftStatusEnum.FINALIZED.getStatus())).eq((v0) -> { return v0.getId(); }, id))); } List parallelProcessList = (List) processList.stream().filter(pl -> { return pl.getMainSequenceId() == null; }).collect(Collectors.toList()); boolean sortNull = parallelProcessList.stream().anyMatch(c2 -> { return Func.isNull(c2.getSort()); }); ThrowFun.isTrue(sortNull).throwMessage(MessageUtils.message("cps.production.craft.version.has.no.process.and.can.not.fix.version", new Object[0])); Map> map = (Map) parallelProcessList.stream().collect(Collectors.groupingBy((v0) -> { return v0.getSort(); })); if (map.size() != parallelProcessList.size()) { throw new ServiceException(MessageUtils.message("cps.production.craft.process.same.sort", new Object[0])); } if (fmsBeltline) { boolean match = processList.stream().anyMatch(pl2 -> { return Func.notNull(pl2.getMainSequenceId()); }); ThrowFun.isTrue(match).throwMessage(MessageUtils.message("cps.production.craft.process.beltline.not.fix", new Object[0])); validProcessMeets(processList); validProcessBindTray(processList); } return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate(ProductionCraftVersion.class).set((v0) -> { return v0.getEditionStatus(); }, ProductionCraftStatusEnum.FINALIZED.getStatus())).eq((v0) -> { return v0.getId(); }, id))); } private void validProcessMeets(List processList) { ProductionCraftProcess firstProcess = processList.get(0); if (!Func.isNull(firstProcess)) { Integer processType = firstProcess.getProcessType(); boolean flag = ProcessTypeEnum.LOADING.getType().equals(processType); ThrowFun.isTrue(!flag).throwMessage(MessageUtils.message("cps.craft.version.process.loading", new Object[0])); } if (processList.size() > CraftConstant.ONE.intValue()) { ProductionCraftProcess lastProcess = processList.get(processList.size() - 1); if (!Func.isNull(lastProcess)) { Integer processType2 = lastProcess.getProcessType(); boolean flag2 = ProcessTypeEnum.LOADING.getType().equals(processType2); ThrowFun.isTrue(!flag2).throwMessage(MessageUtils.message("cps.craft.version.process.loading", new Object[0])); } for (int i = 0; i < processList.size() - 1; i++) { ProductionCraftProcess currentProcess = processList.get(i); Integer currentProcessType = currentProcess.getProcessType(); ProductionCraftProcess nextProcess = processList.get(i + 1); Integer nextProcessType = nextProcess.getProcessType(); boolean flag3 = (ProcessTypeEnum.LOADING.getType().equals(currentProcessType) || ProcessTypeEnum.LOADING.getType().equals(nextProcessType)) ? false : true; if (flag3) { boolean sameFixture = this.craftProcessService.useSameFixture(currentProcess, nextProcess); String message = StringUtil.format(MessageUtils.message("cps.craft.version.process.not.same.fixture", new Object[0]), new Object[]{currentProcess.getProcessName(), nextProcess.getProcessName()}); ThrowFun.isTrue(!sameFixture).throwMessage(message); } } } } private void validProcessBindTray(List processList) { List processIds = (List) processList.stream().filter(pl -> { return pl.getProcessId() != null; }).map((v0) -> { return v0.getId(); }).collect(Collectors.toList()); Map> processMap = this.relatedFixtureService.getMapBindFixture(processIds); boolean allProBfBt = processList.stream().filter(pl2 -> { return pl2.getProcessId() != null; }).allMatch(process -> { return validProcessBind(process.getId(), processMap); }); ThrowFun.isTrue(!allProBfBt).throwMessage(MessageUtils.message("cps.fix.version.process.bind.fixture", new Object[0])); } private boolean validProcessBind(Long processId, Map> processMap) { List fixtures = processMap.get(processId); if (Func.isEmpty(fixtures)) { return false; } List fixtureIds = (List) fixtures.stream().map((v0) -> { return v0.getFixtureId(); }).collect(Collectors.toList()); int fixtureSize = fixtures.size(); int bindTray = this.relatedFixtureService.getFixtureBindTray(fixtureIds); return fixtureSize == bindTray; } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService public Boolean cancelFixVersion(Long id) { return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate(ProductionCraftVersion.class).set((v0) -> { return v0.getEditionStatus(); }, ProductionCraftStatusEnum.DEFAULT.getStatus())).eq((v0) -> { return v0.getId(); }, id))); } @Override // org.springblade.modules.cps.service.IProductionCraftVersionService public List listFixed(Long craftId) { List list = list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery(ProductionCraftVersion.class).eq((v0) -> { return v0.getCraftId(); }, craftId)).eq((v0) -> { return v0.getEditionStatus(); }, ProductionCraftStatusEnum.FINALIZED.getStatus())); return ProductionCraftVersionConvert.INSTANCE.convert(list); } private void validEditionStatus(List ids) { List editionStatus = listObjs((Wrapper) Wrappers.lambdaQuery(ProductionCraftVersion.class).select(new SFunction[]{(v0) -> { return v0.getEditionStatus(); }}).in((v0) -> { return v0.getId(); }, ids), c -> { return Integer.valueOf(c instanceof BigDecimal ? ((BigDecimal) c).intValue() : ((Integer) c).intValue()); }); boolean edition = editionStatus.stream().anyMatch(c2 -> { return ProductionCraftStatusEnum.FINALIZED.getStatus().equals(c2); }); ThrowFun.isTrue(edition).throwMessage(MessageUtils.message("cps.production.craft.version.has.been.finalized.can.not.delete", new Object[0])); } private ProductionCraftVersion saveVersion(Long craftId, CraftVersionAddVO vo) { if (Func.isBlank(vo.getName())) { vo.setCraftId(craftId); String name = this.codeGeneratorService.getGeneratorCode(vo, MetaTypeEnum.PRODUCTION_CRAFT_VERSION.getCode()); log.info("工艺版本生成的名称:{}", name); vo.setName(name); } validNameExist(craftId, null, vo.getName()); ProductionCraftVersion craftVersion = new ProductionCraftVersion().setName(vo.getName()).setDescription(vo.getDescription()).setCraftId(craftId).setEditionStatus(ProductionCraftStatusEnum.DEFAULT.getStatus()); save(craftVersion); return craftVersion; } private void saveCraftVersionLine(Long craftId, Long version, List groupIds) { List lineList = (List) groupIds.stream().map(groupId -> { return new CraftVersionLine().setCraftId(craftId).setVersionId(version).setGroupId(groupId); }).collect(Collectors.toList()); this.versionLineService.saveBatch(lineList); } private void validNameExist(Long craft, Long id, String name) { long count = count((Wrapper) Wrappers.lambdaQuery(ProductionCraftVersion.class).eq(Func.isNotEmpty(craft), (v0) -> { return v0.getCraftId(); }, craft).ne(Func.isNotEmpty(id), (v0) -> { return v0.getId(); }, id).eq((v0) -> { return v0.getName(); }, name)); ThrowFun.isTrue(count > 0).throwMessage(MessageUtils.message("cps.production.craft.version.name.is.exist", new Object[0])); } }