| | |
| | | package com.qianwen.smartman.modules.trace.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.mp.base.BaseServiceImpl; |
| | | import com.qianwen.core.mp.support.Condition; |
| | | import com.qianwen.core.mp.support.Query; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.modules.trace.convert.TraceFlowSettingsConvert; |
| | | import com.qianwen.smartman.modules.trace.convert.TraceRelatedWorkstationConvert; |
| | | import com.qianwen.smartman.modules.trace.entity.TraceFlowSettings; |
| | |
| | | import com.qianwen.smartman.modules.trace.vo.TraceFlowSettingsVO; |
| | | import com.qianwen.smartman.modules.trace.vo.TraceFlowSettingsWorkstationVO; |
| | | import com.qianwen.smartman.modules.trace.vo.TraceRelatedWorkstationVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/trace/service/impl/TraceFlowSettingsServiceImpl.class */ |
| | |
| | | private final TraceRelatedWorkstationMapper traceRelatedWorkstationMapper; |
| | | private final Long CURRENT_FLOW = 1L; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -910828604: |
| | | if (implMethodName.equals("getQualityMakerFlowId")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case -871043410: |
| | | if (implMethodName.equals("getTraceFlowSettingId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -307107987: |
| | | if (implMethodName.equals("getWorkstationGroupId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -75622813: |
| | | if (implMethodName.equals("getCode")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | 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/trace/entity/TraceFlowSettings") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getQualityMakerFlowId(); |
| | | }; |
| | | } |
| | | 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(); |
| | | }; |
| | | } |
| | | 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/trace/entity/TraceRelatedWorkstation") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getTraceFlowSettingId(); |
| | | }; |
| | | } |
| | | 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/trace/entity/TraceRelatedWorkstation") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getTraceFlowSettingId(); |
| | | }; |
| | | } |
| | | 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/trace/entity/TraceFlowSettings") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getWorkstationGroupId(); |
| | | }; |
| | | } |
| | | 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/trace/entity/TraceFlowSettings") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getWorkstationGroupId(); |
| | | }; |
| | | } |
| | | 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/trace/entity/TraceFlowSettings") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getCode(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public TraceFlowSettingsServiceImpl(final ITraceRelatedWorkstationService traceRelatedWorkstationService, final TraceRelatedWorkstationMapper traceRelatedWorkstationMapper) { |
| | | this.traceRelatedWorkstationService = traceRelatedWorkstationService; |
| | |
| | | TraceFlowSettingsVO traceFlowSettingsVO = traceFlowSettingsWorkstationVO.getTraceFlowSettingsVO(); |
| | | TraceFlowSettings traceFlowSettings = TraceFlowSettingsConvert.INSTANCE.convert(traceFlowSettingsVO); |
| | | if (Func.isEmpty(traceFlowSettingsVO.getId())) { |
| | | Integer maxSeq = list(Wrappers.<TraceFlowSettings>lambdaQuery() |
| | | .ne(Func.isNotEmpty(traceFlowSettingsVO.getId()), TraceFlowSettings::getId, traceFlowSettingsVO.getId()) |
| | | .eq(TraceFlowSettings::getWorkstationGroupId, traceFlowSettingsVO.getWorkstationGroupId())).stream().map(TraceFlowSettings::getFlowSeq).max(Integer::compare).orElse(-1); |
| | | /* |
| | | Integer maxSeq = (Integer) list((Wrapper) Wrappers.lambdaQuery().ne(Func.isNotEmpty(traceFlowSettingsVO.getId()), (v0) -> { |
| | | return v0.getId(); |
| | | }, traceFlowSettingsVO.getId()).eq((v0) -> { |
| | |
| | | return v0.getFlowSeq(); |
| | | }).max((v0, v1) -> { |
| | | return Integer.compare(v0, v1); |
| | | }).orElse(-1); |
| | | }).orElse(-1);*/ |
| | | traceFlowSettings.setFlowSeq(Integer.valueOf(maxSeq.intValue() + 1)); |
| | | } |
| | | checkSetting(traceFlowSettingsVO); |
| | |
| | | } |
| | | TraceFlowSettingsVO traceFlowSettingsVOReturn = TraceFlowSettingsConvert.INSTANCE.convert(traceFlowSettings); |
| | | List<TraceRelatedWorkstationVO> traceRelatedWorkstationVOS = traceFlowSettingsWorkstationVO.getTraceRelatedWorkstationVOList(); |
| | | this.traceRelatedWorkstationService.remove(Wrappers.<TraceRelatedWorkstation>lambdaQuery().eq(TraceRelatedWorkstation::getTraceFlowSettingId, traceFlowSettingsVOReturn.getId())); |
| | | /* |
| | | this.traceRelatedWorkstationService.remove((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getTraceFlowSettingId(); |
| | | }, traceFlowSettingsVOReturn.getId())); |
| | | }, traceFlowSettingsVOReturn.getId()));*/ |
| | | if (Func.isNotEmpty(traceRelatedWorkstationVOS)) { |
| | | List<TraceRelatedWorkstation> traceRelatedWorkstations = TraceRelatedWorkstationConvert.INSTANCE.convertVo(traceRelatedWorkstationVOS); |
| | | checkRelatedWorkstation(traceRelatedWorkstations); |
| | |
| | | |
| | | @Override // org.springblade.modules.trace.service.ITraceFlowSettingsService |
| | | public Boolean changeSort(List<TraceFlowSettingsVO> traceFlowSettingsVOList) { |
| | | List<TraceFlowSettings> collect = (List) traceFlowSettingsVOList.stream().map(t -> { |
| | | List<TraceFlowSettings> collect = traceFlowSettingsVOList.stream().map(t -> { |
| | | TraceFlowSettings traceFlowSettings = (TraceFlowSettings) getById(t.getId()); |
| | | traceFlowSettings.setFlowSeq(t.getFlowSeq()); |
| | | return traceFlowSettings; |
| | |
| | | public boolean remove(List<String> ids) { |
| | | List<Long> idList = Func.toLongList(ids); |
| | | idList.forEach(id -> { |
| | | long count = count(Wrappers.<TraceFlowSettings>lambdaQuery().eq(TraceFlowSettings::getQualityMakerFlowId, id).ne(TraceFlowSettings::getId, id)); |
| | | /* |
| | | long count = count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getQualityMakerFlowId(); |
| | | }, id)).ne((v0) -> { |
| | | return v0.getId(); |
| | | }, id)); |
| | | }, id));*/ |
| | | if (count > 0) { |
| | | throw new ServiceException(MessageUtils.message("cps.traceFlowSettings.ids.have.been.bound", new Object[0])); |
| | | } |
| | | }); |
| | | removeByIds(idList); |
| | | this.traceRelatedWorkstationService.remove(Wrappers.<TraceRelatedWorkstation>lambdaQuery().in(TraceRelatedWorkstation::getTraceFlowSettingId, idList)); |
| | | /* |
| | | this.traceRelatedWorkstationService.remove((Wrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getTraceFlowSettingId(); |
| | | }, idList)); |
| | | }, idList));*/ |
| | | return true; |
| | | } |
| | | |
| | | public void checkSetting(TraceFlowSettingsVO traceFlowSettingsVO) { |
| | | Long id = traceFlowSettingsVO.getId(); |
| | | long count = count(Wrappers.<TraceFlowSettings>lambdaQuery() |
| | | .ne(Func.isNotEmpty(id), TraceFlowSettings::getId, id) |
| | | .eq(TraceFlowSettings::getCode, traceFlowSettingsVO.getCode())); |
| | | /* |
| | | long count = count((Wrapper) Wrappers.lambdaQuery().ne(Func.isNotEmpty(id), (v0) -> { |
| | | return v0.getId(); |
| | | }, id).eq((v0) -> { |
| | | return v0.getCode(); |
| | | }, traceFlowSettingsVO.getCode())); |
| | | }, traceFlowSettingsVO.getCode()));*/ |
| | | if (count > 0) { |
| | | throw new ServiceException(MessageUtils.message("cps.traceFlowSettings.code.already.exists", new Object[0])); |
| | | } |
| | | if (FlowTypeEnum.ONLINE_STATION.getCode().equals(traceFlowSettingsVO.getFlowType()) && !TriggerEndFlowStyleEnum.SELF_FLOW.getCode().equals(traceFlowSettingsVO.getTriggerEndFlowStyle())) { |
| | | throw new ServiceException(MessageUtils.message("cps.trace.flow.settings.only.this.flow", new Object[0])); |
| | | } |
| | | List<Integer> flowSeqs = list(Wrappers.<TraceFlowSettings>lambdaQuery() |
| | | .ne(Func.isNotEmpty(traceFlowSettingsVO.getId()), TraceFlowSettings::getId, traceFlowSettingsVO.getId()) |
| | | .eq(TraceFlowSettings::getWorkstationGroupId, traceFlowSettingsVO.getWorkstationGroupId())) |
| | | .stream().map(TraceFlowSettings::getFlowSeq).filter(Func::isNotEmpty).collect(Collectors.toList()); |
| | | |
| | | /* |
| | | List<Integer> flowSeqs = (List) list((Wrapper) Wrappers.lambdaQuery().ne(Func.isNotEmpty(traceFlowSettingsVO.getId()), (v0) -> { |
| | | return v0.getId(); |
| | | }, traceFlowSettingsVO.getId()).eq((v0) -> { |
| | |
| | | return v0.getFlowSeq(); |
| | | }).filter((v0) -> { |
| | | return Func.isNotEmpty(v0); |
| | | }).collect(Collectors.toList()); |
| | | }).collect(Collectors.toList());*/ |
| | | if (flowSeqs.contains(traceFlowSettingsVO.getFlowSeq())) { |
| | | throw new ServiceException(MessageUtils.message("cps.traceFlowSettings.flowSeq.already.exists", new Object[0])); |
| | | } |
| | | } |
| | | |
| | | public void checkRelatedWorkstation(List<TraceRelatedWorkstation> traceRelatedWorkstations) { |
| | | Map<String, List<TraceRelatedWorkstation>> collect = (Map) traceRelatedWorkstations.stream().collect(Collectors.groupingBy(t -> { |
| | | Map<String, List<TraceRelatedWorkstation>> collect = traceRelatedWorkstations.stream().collect(Collectors.groupingBy(t -> { |
| | | return (t.getWorkstationId().longValue() + t.getWorkbenchId().longValue()) + t.getMachiningPosition(); |
| | | })); |
| | | collect.forEach(key, list -> { |
| | | collect.forEach((key, list) -> { |
| | | if (list.size() > 1) { |
| | | throw new ServiceException(MessageUtils.message("cps.relatedWorkstation.already.exists", new Object[0])); |
| | | } |