| | |
| | | package com.qianwen.smartman.modules.cps.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | import com.google.common.collect.Lists; |
| | | 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.cache.RegionCache; |
| | | import com.qianwen.smartman.common.constant.CraftConstant; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.common.collect.Lists; |
| | | import com.qianwen.core.mp.service.impl.BladeServiceImpl; |
| | | import com.qianwen.core.tool.support.Kv; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.core.tool.utils.RandomType; |
| | | import com.qianwen.core.tool.utils.StringUtil; |
| | | import com.qianwen.smartman.common.constant.CraftConstant; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.modules.cps.convert.CraftRoutingConvert; |
| | | import com.qianwen.smartman.modules.cps.convert.ProductConvert; |
| | | import com.qianwen.smartman.modules.cps.convert.ProductionCraftProcessConvert; |
| | |
| | | import com.qianwen.smartman.modules.cps.vo.VersionProcessAddVO; |
| | | import com.qianwen.smartman.modules.system.service.IBasCoderuleService; |
| | | 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/CraftRoutingServiceImpl.class */ |
| | | public class CraftRoutingServiceImpl extends BladeServiceImpl<CraftRoutingMapper, CraftRouting> implements ICraftRoutingService { |
| | | private static final Logger log = LoggerFactory.getLogger(CraftRoutingServiceImpl.class); |
| | | private final IProductionCraftVersionService craftVersionService; |
| | |
| | | this.basCodeRuleService = basCodeRuleService; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public CraftRoutingVO saveRouting(CraftRoutingAddVO vo) { |
| | | CraftRouting craftRouting = saveCraftRouting(vo); |
| | | return CraftRoutingConvert.INSTANCE.convert(craftRouting); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public List<CraftRoutingVO> listCraftRouting(SearchVO vo) { |
| | | Wrapper<CraftRouting> wrapper = getWrapper(vo); |
| | | return this.baseMapper.listCraftRouting(Func.isBlank(wrapper.getSqlSegment()) ? null : wrapper); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public CraftRoutingDetailVO detailCraft(Long id) { |
| | | CraftRoutingDetailVO vo = new CraftRoutingDetailVO(); |
| | | setProduce(vo, id); |
| | |
| | | return vo; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean deleteCraft(Long id) { |
| | | boolean flag = removeById(id); |
| | | |
| | | // .select(new SFunction[] { ProductionCraftVersion::getId }) |
| | | List<Long> versionIds = this.craftVersionService.listObjs(Wrappers.<ProductionCraftVersion>lambdaQuery(ProductionCraftVersion.class) |
| | | |
| | | List<Long> versionIds = this.craftVersionService.listObjs(Wrappers.<ProductionCraftVersion>lambdaQuery() |
| | | .select(ProductionCraftVersion::getId) |
| | | .eq(ProductionCraftVersion::getCraftId, id), c -> Long.valueOf((c instanceof BigDecimal) ? ((BigDecimal)c).longValue() : ((Long)c).longValue())); |
| | | /* |
| | |
| | | return Boolean.valueOf(flag && this.versionLineService.remove(Wrappers.<CraftVersionLine>lambdaQuery().eq(CraftVersionLine::getCraftId, id))); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public Boolean updateCraft(CraftRoutingUpdateVO vo) { |
| | | validNameExist(vo.getId(), vo.getName()); |
| | | CraftRouting routing = CraftRoutingConvert.INSTANCE.convert(vo); |
| | | return Boolean.valueOf(updateById(routing)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean copyCraftVersion(ProductionCraftVersionCopyVO vo) { |
| | | Integer type = vo.getType(); |
| | | if (CraftConstant.COPY_TYPE_PRODUCT.equals(type)) { |
| | | CraftRouting routing = (CraftRouting) getOne((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).eq((v0) -> { |
| | | return v0.getProductId(); |
| | | }, vo.getProductId())); |
| | | CraftRouting routing = getOne(Wrappers.lambdaQuery(CraftRouting.class).eq(CraftRouting::getProductId, vo.getProductId())); |
| | | if (Func.isNull(routing)) { |
| | | return Boolean.valueOf(copyProductNewCraft(vo)); |
| | | } |
| | |
| | | return Boolean.valueOf(copyCraftNewVersion(vo, vo.getCraftId())); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public List<ProductionCraftVersionVO> listFixedVersionByProduction(Long productionId) { |
| | | CraftRouting craft = (CraftRouting) getOne((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).eq((v0) -> { |
| | | return v0.getProductId(); |
| | | }, productionId)); |
| | | CraftRouting craft = getOne(Wrappers.lambdaQuery(CraftRouting.class).eq(CraftRouting::getProductId, productionId)); |
| | | if (Func.isNull(craft)) { |
| | | return Lists.newArrayList(); |
| | | } |
| | | return this.craftVersionService.listFixed(craft.getId()); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public CraftRoutingDetailVO getCraftByProduction(Long production) { |
| | | CraftRouting craft = (CraftRouting) getOne((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).eq((v0) -> { |
| | | return v0.getProductId(); |
| | | }, production)); |
| | | CraftRouting craft = getOne(Wrappers.lambdaQuery(CraftRouting.class).eq(CraftRouting::getProductId, production)); |
| | | if (Func.isNull(craft)) { |
| | | return null; |
| | | } |
| | | return detailCraft(craft.getId()); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public List<CraftRoutingVO> listNotBandCraft() { |
| | | return CraftRoutingConvert.INSTANCE.convert(list((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).isNull((v0) -> { |
| | | return v0.getProductId(); |
| | | }))); |
| | | return CraftRoutingConvert.INSTANCE.convert(list(Wrappers.lambdaQuery(CraftRouting.class).isNull(CraftRouting::getProductId))); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public Boolean craftBindProduction(Long productionId, Long craftId) { |
| | | return update(Wrappers.lambdaUpdate(CraftRouting.class).set(CraftRouting::getProductId, productionId).eq(CraftRouting::getId, craftId)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public Boolean craftUnbindProduction(Long craftId) { |
| | | return update(Wrappers.lambdaUpdate(CraftRouting.class).set(CraftRouting::getProductId, null).eq(CraftRouting::getId, craftId)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICraftRoutingService |
| | | @Override |
| | | public List<ProductVO> notBandProduct(Long craftId) { |
| | | List<Product> products = this.productService.notBandProduct(craftId); |
| | | return ProductConvert.INSTANCE.convert(products); |
| | |
| | | }, processIds)).stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getVersionProcessId(); |
| | | })); |
| | | Map<Long, List<ProductionCraftProcessRelatedTool>> processToolMap = (Map) this.relatedToolService.list(Wrappers.lambdaQuery(ProductionCraftProcessRelatedTool.class).in((v0) -> { |
| | | Map<Long, List<ProductionCraftProcessRelatedTool>> processToolMap = this.relatedToolService.list(Wrappers.lambdaQuery(ProductionCraftProcessRelatedTool.class).in((v0) -> { |
| | | return v0.getVersionProcessId(); |
| | | }, processIds)).stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getVersionProcessId(); |
| | | })); |
| | | Map<Long, List<ProductionCraftProcessFile>> processFileMap = (Map) this.processFileService.list(Wrappers.lambdaQuery(ProductionCraftProcessFile.class).in((v0) -> { |
| | | Map<Long, List<ProductionCraftProcessFile>> processFileMap = this.processFileService.list(Wrappers.lambdaQuery(ProductionCraftProcessFile.class).in((v0) -> { |
| | | return v0.getVersionProcessId(); |
| | | }, processIds)).stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getVersionProcessId(); |
| | | })); |
| | | List<VersionProcessAddVO> collect = (List) processList.stream().filter(c -> { |
| | | List<VersionProcessAddVO> collect = processList.stream().filter(c -> { |
| | | return Func.isNull(c.getMainSequenceId()) && Func.notNull(c.getProcessId()); |
| | | }).map(process -> { |
| | | return getVersionProcessAddVO(processFixtureMap, processToolMap, processFileMap, process); |
| | | }).collect(Collectors.toList()); |
| | | List<ProductionCraftProcess> list = (List) processList.stream().filter(c2 -> { |
| | | List<ProductionCraftProcess> list = processList.stream().filter(c2 -> { |
| | | return Func.notNull(c2.getMainSequenceId()) || Func.isNull(c2.getProcessId()); |
| | | }).collect(Collectors.toList()); |
| | | List<ParallelProVO> parallelProcessList = Lists.newArrayList(); |
| | |
| | | proVO.setXCoordinate(l12.getXCoordinate()); |
| | | proVO.setYCoordinate(l12.getYCoordinate()); |
| | | proVO.setHeight(l12.getHeight()); |
| | | List<VersionProcessAddVO> vos = (List) list.stream().filter(l2 -> { |
| | | List<VersionProcessAddVO> vos = list.stream().filter(l2 -> { |
| | | return l12.getId().equals(l2.getMainSequenceId()); |
| | | }).map(process2 -> { |
| | | return getVersionProcessAddVO(processFixtureMap, processToolMap, processFileMap, process2); |
| | |
| | | VersionProcessAddVO processAddVO = ProductionCraftProcessConvert.INSTANCE.convertAdd(process); |
| | | List<ProductionCraftProcessRelatedFixture> fixtures = processFixtureMap.get(process.getId()); |
| | | if (Func.isNotEmpty(fixtures)) { |
| | | List<ProductionCraftProcessRelatedFixtureVO> fixtureAddList = (List) fixtures.stream().map(c -> { |
| | | List<ProductionCraftProcessRelatedFixtureVO> fixtureAddList = fixtures.stream().map(c -> { |
| | | return new ProductionCraftProcessRelatedFixtureVO().setFixtureId(c.getFixtureId()).setVersionProcessId(c.getVersionProcessId()).setFixtureCode(c.getFixtureCode()).setFixtureName(c.getFixtureName()).setFixtureGroupName(c.getFixtureGroupName()); |
| | | }).collect(Collectors.toList()); |
| | | processAddVO.setFixtures(fixtureAddList); |
| | | } |
| | | List<ProductionCraftProcessFile> files = processFileMap.get(process.getId()); |
| | | if (Func.isNotEmpty(files)) { |
| | | List<ProductionCraftProcessFileVO> fileAddList = (List) files.stream().map(c2 -> { |
| | | List<ProductionCraftProcessFileVO> fileAddList = files.stream().map(c2 -> { |
| | | return new ProductionCraftProcessFileVO().setFileName(c2.getFileName()).setObjectKey(c2.getObjectKey()).setContentType(c2.getContentType()).setLink(c2.getLink()).setFileSize(c2.getFileSize()).setUploadTime(c2.getUploadTime()).setVersionProcessId(c2.getVersionProcessId()); |
| | | }).collect(Collectors.toList()); |
| | | processAddVO.setFiles(fileAddList); |
| | | } |
| | | List<ProductionCraftProcessRelatedTool> tools = processToolMap.get(process.getId()); |
| | | if (Func.isNotEmpty(tools)) { |
| | | List<ProductionCraftProcessRelatedToolVO> toolAddList = (List) tools.stream().map(c3 -> { |
| | | List<ProductionCraftProcessRelatedToolVO> toolAddList = tools.stream().map(c3 -> { |
| | | return new ProductionCraftProcessRelatedToolVO().setToolId(c3.getToolId()).setVersionProcessId(c3.getVersionProcessId()).setToolCode(c3.getToolCode()).setToolCategoryName(c3.getToolCategoryName()).setToolModelName(c3.getToolModelName()); |
| | | }).collect(Collectors.toList()); |
| | | processAddVO.setTools(toolAddList); |
| | |
| | | } |
| | | |
| | | private void validNameExist(Long id, String name) { |
| | | long count = count((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).ne(Func.isNotEmpty(id), (v0) -> { |
| | | return v0.getId(); |
| | | }, id).eq((v0) -> { |
| | | return v0.getName(); |
| | | }, name)); |
| | | long count = count(Wrappers.lambdaQuery(CraftRouting.class).ne(Func.isNotEmpty(id), CraftRouting::getId, id).eq(CraftRouting::getName, name)); |
| | | ThrowFun.isTrue(count > 0).throwMessage(MessageUtils.message("cps.craft.name.exist", new Object[0])); |
| | | } |
| | | } |