From 4bac61c3fb3420caf48397d741f7f02c22f0fe08 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期一, 23 六月 2025 13:23:54 +0800 Subject: [PATCH] 工控网 新增设备结构树指派产品结构树功能 新增定型后续操作 增加解析涉密网传输解析,增加封装定型后nc文件与程序加工确认表 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java | 17 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java | 8 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java | 6 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java | 28 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java | 36 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java | 154 +++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml | 5 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java | 53 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepPackageStrategy.java | 43 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java | 17 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java | 19 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java | 316 +++++++++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/DataPackageStrategy.java | 13 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessPackageStrategy.java | 42 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java | 213 +++++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java | 134 ++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java | 252 +++++++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java | 133 ++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java | 12 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java | 30 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java | 30 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/constant/DncPassLogPassType.java | 39 + 22 files changed, 1,586 insertions(+), 14 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/constant/DncPassLogPassType.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/constant/DncPassLogPassType.java new file mode 100644 index 0000000..bbc9d2a --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/constant/DncPassLogPassType.java @@ -0,0 +1,39 @@ +package org.jeecg.modules.dnc.constant; + +public enum DncPassLogPassType { + //NC鏂囦欢 + DOCUMENT("01", "nc鏂囦欢"), + //nc鏂囦欢 + NCFILE("02", "NC鏂囦欢"), + //浜у搧缁撴瀯鏍� + PRODUCTSTRUCTURE("03", "浜у搧缁撴瀯鏍�"), + //绋嬪簭鍔犲伐纭琛� + PROGRAMPROCESSING("04", "绋嬪簭鍔犲伐纭琛�"); + + private String code; + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + DncPassLogPassType() { + } + + DncPassLogPassType(String code, String name) { + this.code = code; + this.name = name; + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java index c91e823..8c424bd 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java @@ -38,6 +38,18 @@ } /** + * 鑾峰彇鍏ㄩ儴浜у搧鏍戯紙鍖呮嫭璁惧绫讳笌nc鏂囦欢锛� + * @return + */ + @AutoLog(value = "鑾峰彇鍏ㄩ儴浜у搧鏍�") + @ApiOperation(value = "鑾峰彇鍏ㄩ儴浜у搧鏍�", notes = "鑾峰彇鍏ㄩ儴浜у搧鏍�") + @GetMapping(value = "/getAllTree") + public Result<?> getAllTree() { + List<ProductMix> productMixList = iProductMixService.getProductMixTree(); + return Result.OK(productMixList); + } + + /** * 鑾峰彇鍏蜂綋灞傜骇瀹炰綋 * @param id,type * @return diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java index a81c856..36aefc6 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java @@ -6,5 +6,22 @@ import org.jeecg.modules.dnc.entity.ProductMix; public interface ProductMixMapper extends BaseMapper<ProductMix> { + @Select("SELECT * FROM nc_product_mix WHERE id = #{productId} AND tree_type = 1") + ProductMix findByProductId(@Param("productId") String productId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{componentId} AND tree_type = 2") + ProductMix findByComponentId(@Param("componentId") String componentId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{partsId} AND tree_type = 3") + ProductMix findByPartsId(@Param("partsId") String partsId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{operationId} AND tree_type = 4") + ProductMix findByOperationId(@Param("operationId") String operationId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{processId} AND tree_type = 5") + ProductMix findByProcessId(@Param("operationId") String processId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{worksiteId} AND tree_type = 6") + ProductMix findByWorksiteId(@Param("operationId") String worksiteId); } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/DataPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/DataPackageStrategy.java new file mode 100644 index 0000000..b736527 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/DataPackageStrategy.java @@ -0,0 +1,13 @@ +package org.jeecg.modules.dnc.service; + +import org.jeecg.modules.dnc.dto.TransferPackage; + +// 鏁版嵁灏佽绛栫暐鎺ュ彛 +public interface DataPackageStrategy { + /** + * 灏佽涓氬姟鏁版嵁涓轰紶杈撳寘 + * @param id 涓氬姟瀹炰綋ID锛堝伐搴廔D鎴栧伐姝D锛� + * @return 灏佽濂界殑浼犺緭鍖� + */ + TransferPackage packageData(String id); +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java index d6d8a13..e78a076 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java @@ -12,6 +12,23 @@ //鑾峰彇灏佽浜у搧缁撴瀯鏍� public List<ProductMix> getTree(); - //妯℃嫙鐢熸垚浜у搧缁撴瀯鏍� + /** + * 鏌ヨ瀵瑰簲id鐨勬墍鏈夌埗绾�(鏉冮檺鍒嗛厤浣跨敤) + * @param id + * @return + */ + List<ProductMix> getParentList(String id); + /** + * 鏌ヨ瀵瑰簲id鐨勬墍鏈夊瓙鑺傜偣(鏉冮檺鍒嗛厤浣跨敤) + * @param id + * @return + */ + List<ProductMix> getChildrenList(String id); + + /** + * 鏌ヨ浜у搧缁撴瀯鏍戯紙鍖呮嫭璁惧绫讳笌nc鏂囦欢锛� + * @return + */ + List<ProductMix> getProductMixTree(); } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java index 2334052..3ddf601 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java @@ -8,6 +8,7 @@ import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.*; import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysUserService; import org.slf4j.Logger; @@ -295,9 +296,9 @@ } } if (permissionStreamNew.getDepartId() != null) { - String id=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()).getId(); - if (id!=null){ - permissionStreamNew.setDepartId(id); + MdcProduction mdcProduction=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()); + if (mdcProduction!=null){ + permissionStreamNew.setDepartId(mdcProduction.getId()); } } permissionStreamNewMapper.insert(permissionStreamNew); @@ -449,6 +450,7 @@ private void saveGuideCardBatch(GuideCardBatch guideCardBatch) { if (guideCardBatchMapper.selectById(guideCardBatch.getId()) == null) { + guideCardBatch.setFlowStatus("1"); guideCardBatchMapper.insert(guideCardBatch); logger.debug("鍒�鐗囨壒娆″凡淇濆瓨: {}", guideCardBatch.getId()); } else { diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java new file mode 100644 index 0000000..46cfe99 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataPackageService.java @@ -0,0 +1,36 @@ +package org.jeecg.modules.dnc.service.impl; + +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.service.DataPackageStrategy; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +@Service +public class DataPackageService { + + private final Map<TransferPackage.DataType, DataPackageStrategy> strategies; + + @Autowired + public DataPackageService(List<DataPackageStrategy> strategyList) { + strategies = new EnumMap<>(TransferPackage.DataType.class); + strategyList.forEach(strategy -> { + if (strategy instanceof ProcessPackageStrategy) { + strategies.put(TransferPackage.DataType.PROCESS, strategy); + } else if (strategy instanceof WorkStepPackageStrategy) { + strategies.put(TransferPackage.DataType.WORKSTEP, strategy); + } + }); + } + + public TransferPackage packageData(TransferPackage.DataType type, String id) { + DataPackageStrategy strategy = strategies.get(type); + if (strategy == null) { + throw new IllegalArgumentException("涓嶆敮鎸佺殑鏁版嵁绫诲瀷: " + type); + } + return strategy.packageData(id); + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java index 1d4b5c3..586e458 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java @@ -62,6 +62,36 @@ @Autowired private IDocRelativeService docRelativeService; + @Autowired + private DataPackageService dataPackageService; + + public String exportData(TransferPackage.DataType type, String id,String fileName) { + // 1. 鑾峰彇灏佽鏁版嵁 + TransferPackage transferPackage = dataPackageService.packageData(type, id); + + // 2. 鍘嬬缉灞傜骇缁撴瀯 + compressHierarchy(transferPackage); + + // 3. JSON搴忓垪鍖� + String json = JsonUtils.toJson(transferPackage); + +// // 4. 鍘嬬缉鍔犲瘑 +// byte[] compressed = CompressionUtils.gzipCompress(json.getBytes(StandardCharsets.UTF_8)); +// byte[] encrypted = securityService.encrypt(compressed); + //鏆傛椂涓嶅姞瀵� + byte[] compressed = json.getBytes(StandardCharsets.UTF_8); + + // 5. 鐢熸垚鏂囦欢 + Path filePath = Paths.get(ferryPath,fileName); + try { + Files.createDirectories(filePath.getParent()); + Files.write(filePath, compressed); + return filePath.toString(); + } catch (IOException e) { + throw new RuntimeException("鏂囦欢鍐欏叆澶辫触", e); + } + } + public TransferPackage importData(String filePath) { diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java new file mode 100644 index 0000000..1180bdf --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java @@ -0,0 +1,213 @@ +package org.jeecg.modules.dnc.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.ComponentHierarchy; +import org.jeecg.modules.dnc.dto.ProcessTraceChain; +import org.jeecg.modules.dnc.entity.*; +import org.jeecg.modules.dnc.mapper.*; +import org.jeecg.modules.dnc.service.IPermissionStreamNewService; +import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +@Service +public class FullHierarchyTraceService { + @Autowired + private ProductMixMapper productMixMapper; + @Autowired + private ProductInfoMapper productMapper; + @Autowired + private ComponentInfoMapper componentMapper; + @Autowired + private PartsInfoMapper partsMapper; + @Autowired + private ProcessSpecVersionMapper psvMapper; + @Autowired + private ProcessStreamMapper processMapper; + @Autowired + private WorkStepMapper workStepMapper; + @Autowired + private DeviceTypeMapper deviceTypeMapper; + @Autowired + private DeviceManagementMapper deviceManagementMapper; + @Autowired + private DocInfoMapper docInfoMapper; + @Autowired + private DocFileMapper docFileMapper; + @Autowired + private CutterMapper cutterMapper; + @Autowired + private GuideCardBatchMapper guideCardBatchMapper; + + public ProcessTraceChain traceFromProcess(DocRelative docRelative) { + ProcessTraceChain chain = initChainWithDocInfo(docRelative); + DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId()); + chain.setDeviceType(deviceType); + + if (isProcessType(deviceType)) { + chain.setDeviceManagement(deviceManagementMapper.selectById(deviceType.getDeviceManagementId())); + traceProcessChain(chain, deviceType.getAttributionId()); + } + + completeChainWithProductInfo(chain); + List<ProductMix> productMixList=buildFullTreePath(chain); + chain.setTreePath(productMixList); + return chain; + } + + public ProcessTraceChain traceFromWorkStep(DocRelative docRelative) { + ProcessTraceChain chain = initChainWithDocInfo(docRelative); + DeviceType deviceType = deviceTypeMapper.selectById(docRelative.getAttributionId()); + chain.setDeviceType(deviceType); + + if (isWorkSiteType(deviceType)) { + chain.setDeviceManagement(deviceManagementMapper.selectById(deviceType.getDeviceManagementId())); + traceWorkStepChain(chain, deviceType.getAttributionId()); + } + + completeChainWithProductInfo(chain); + List<ProductMix> productMixList=buildFullTreePath(chain); + chain.setTreePath(productMixList); + return chain; + } + + private ProcessTraceChain initChainWithDocInfo(DocRelative docRelative) { + ProcessTraceChain chain = ProcessTraceChain.builder().docRelative(docRelative).build(); + Optional.ofNullable(docInfoMapper.selectById(docRelative.getDocId())) + .ifPresent(doc -> { + chain.setDocInfo(doc); + chain.setDocFile(docFileMapper.selectById(doc.getPublishFileId())); + chain.setCutterList(getCuttersByDocId(doc.getDocId())); + getLatestGuideCardBatch(doc.getDocId()).ifPresent(chain::setGuideCardBatch); + }); + return chain; + } + + private List<Cutter> getCuttersByDocId(String docId) { + return cutterMapper.selectList(new QueryWrapper<Cutter>().eq("doc_id", docId)); + } + + private Optional<GuideCardBatch> getLatestGuideCardBatch(String docId) { + List<GuideCardBatch> batches = guideCardBatchMapper.selectList( + new QueryWrapper<GuideCardBatch>() + .eq("doc_id", docId) + .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)")); + return CollectionUtils.isEmpty(batches) ? Optional.empty() : Optional.of(batches.get(0)); + } + + private boolean isProcessType(DeviceType deviceType) { + return deviceType != null && + Objects.equals(deviceType.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode()); + } + + private boolean isWorkSiteType(DeviceType deviceType) { + return deviceType != null && + Objects.equals(deviceType.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode()); + } + + private void traceProcessChain(ProcessTraceChain chain, String processId) { + ProcessStream process = processMapper.selectById(processId); + if (process == null) return; + + chain.setProcess(process); + if (process.getPsvId() != null) { + ProcessSpecVersion psv = psvMapper.selectById(process.getPsvId()); + chain.setProcessSpec(psv); + if (psv != null && psv.getPartsId() != null) { + PartsInfo parts = partsMapper.selectById(psv.getPartsId()); + chain.setParts(parts); + if (parts != null && parts.getComponentId() != null) { + chain.setComponentHierarchy(traceComponentHierarchy(parts.getComponentId())); + } + } + } else if (process.getComponentId() != null) { + chain.setComponentHierarchy(traceComponentHierarchy(process.getComponentId())); + } + } + + private void traceWorkStepChain(ProcessTraceChain chain, String workStepId) { + WorkStep workStep = workStepMapper.selectById(workStepId); + if (workStep == null) return; + + chain.setWorkStep(workStep); + traceProcessChain(chain, workStep.getProcessId()); + } + + private ComponentHierarchy traceComponentHierarchy(String componentId) { + ComponentHierarchy hierarchy = new ComponentHierarchy(); + ComponentInfo current = componentMapper.selectById(componentId); + + while (current != null) { + hierarchy.addComponentToTop(current); + + if (current.getParentId() == null || current.getParentId().isEmpty()) { + Optional.ofNullable(current.getProductId()) + .map(productMapper::selectById) + .ifPresent(hierarchy::setRootProduct); + break; + } + + current = componentMapper.selectById(current.getParentId()); + } + + return hierarchy; + } + + private void completeChainWithProductInfo(ProcessTraceChain chain) { + Optional.ofNullable(chain.getComponentHierarchy()) + .map(ComponentHierarchy::getComponents) + .filter(components -> !components.isEmpty()) + .map(components -> components.get(0)) + .map(ComponentInfo::getProductId) + .map(productMapper::selectById) + .ifPresent(chain::setProduct); + } + + private List<ProductMix> buildFullTreePath(ProcessTraceChain chain) { + List<ProductMix> path = new ArrayList<>(); + + Optional.ofNullable(chain.getProduct()) + .map(ProductInfo::getProductId) + .map(productMixMapper::findByProductId) + .ifPresent(path::add); + + Optional.ofNullable(chain.getComponentHierarchy()) + .map(ComponentHierarchy::getComponentsFromTop) + .ifPresent(components -> components.stream() + .map(ComponentInfo::getComponentId) + .map(productMixMapper::findByComponentId) + .filter(Objects::nonNull) + .forEach(path::add)); + + Optional.ofNullable(chain.getParts()) + .map(PartsInfo::getPartsId) + .map(productMixMapper::findByPartsId) + .ifPresent(path::add); + + Optional.ofNullable(chain.getProcessSpec()) + .map(ProcessSpecVersion::getId) + .map(productMixMapper::findByOperationId) + .ifPresent(path::add); + + Optional.ofNullable(chain.getProcess()) + .map(ProcessStream::getProcessId) + .map(productMixMapper::findByProcessId) + .ifPresent(path::add); + + Optional.ofNullable(chain.getWorkStep()) + .map(WorkStep::getId) + .map(productMixMapper::findByWorksiteId) + .ifPresent(path::add); + + return path; + } + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessPackageStrategy.java new file mode 100644 index 0000000..b6cdfd5 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessPackageStrategy.java @@ -0,0 +1,42 @@ +package org.jeecg.modules.dnc.service.impl; + +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.entity.DeviceType; +import org.jeecg.modules.dnc.entity.DocRelative; +import org.jeecg.modules.dnc.entity.ProcessStream; +import org.jeecg.modules.dnc.mapper.DeviceTypeMapper; +import org.jeecg.modules.dnc.mapper.DocRelativeMapper; +import org.jeecg.modules.dnc.mapper.ProcessStreamMapper; +import org.jeecg.modules.dnc.service.DataPackageStrategy; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ProcessPackageStrategy implements DataPackageStrategy { + @Autowired + private ProcessStreamMapper processMapper; + @Autowired + private DeviceTypeMapper deviceTypeMapper; + @Autowired + private FullHierarchyTraceService traceService; + @Autowired + private DocRelativeMapper docRelativeMapper; + + @Override + public TransferPackage packageData(String relativeId) { + DocRelative docRelative=docRelativeMapper.selectById(relativeId); + DeviceType deviceType=deviceTypeMapper.selectById(docRelative.getAttributionId()); + if (deviceType!=null&&deviceType.getAttributionType().equals(DocAttributionTypeEnum.PROCESS.getCode())) { + ProcessStream process = processMapper.selectById(deviceType.getAttributionId()); + if (process == null) { + throw new IllegalArgumentException("璁惧绫诲搴旂殑宸ュ簭涓嶅瓨鍦�: " + deviceType.getDeviceManagementId()); + } + } + return TransferPackage.builder() + .dataType(TransferPackage.DataType.PROCESS) + .docRelative(docRelative) + .traceChain(traceService.traceFromProcess(docRelative)) + .build(); + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java index 2d4824d..ef68867 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java @@ -1,17 +1,19 @@ package org.jeecg.modules.dnc.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.shiro.SecurityUtils; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.dnc.entity.ProductMix; +import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.ProductMixMapper; -import org.jeecg.modules.dnc.service.IPermissionStreamNewService; -import org.jeecg.modules.dnc.service.IProductMixService; +import org.jeecg.modules.dnc.service.*; import org.jeecg.modules.dnc.utils.TreeBuilder; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; @Service public class ProductMixServiceImpl extends ServiceImpl<ProductMixMapper, ProductMix> implements IProductMixService { @@ -19,6 +21,21 @@ @Autowired private IPermissionStreamNewService permissionStreamNewService; + @Autowired + @Lazy + private IDeviceTypeService deviceTypeService; + + @Autowired + @Lazy + private IDeviceManagementService deviceManagementService; + + @Autowired + @Lazy + private IDocInfoService docInfoService; + + @Autowired + @Lazy + private IDocRelativeService docRelativeService; /** * 榛樿缁撴瀯鏍戞煡璇� * @return @@ -48,4 +65,135 @@ result.sort(Comparator.comparing(ProductMix::getCreateTime, Comparator.nullsLast(Date::compareTo))); return result; } + + @Override + public List<ProductMix> getParentList(String id) { + List<ProductMix> parentList = new ArrayList<>(); + // 1. 鏍规嵁ID鏌ヨ褰撳墠鑺傜偣 + ProductMix current = this.getById(id); + if (current == null) { + return parentList; // 鑺傜偣涓嶅瓨鍦ㄦ椂杩斿洖绌哄垪琛� + } + // 2. 浠庡綋鍓嶈妭鐐瑰紑濮嬪悜涓婃煡鎵剧埗鑺傜偣 + Long parentId = current.getParentId(); + while ( parentId != 0L) { + ProductMix parent = this.getById(parentId.toString()); + if (parent == null) { + break; + } + parentList.add(parent); + parentId = parent.getParentId(); + } + + return parentList; + } + + @Override + public List<ProductMix> getChildrenList(String id) { + List<ProductMix> childrenList = new ArrayList<>(); + ProductMix current = this.getById(id); + if (current == null) { + return childrenList; + } + + // 浣跨敤闃熷垪杩涜BFS + Queue<ProductMix> queue = new LinkedList<>(); + queue.add(current); // 鍔犲叆褰撳墠鑺傜偣浣滀负璧风偣 + + // 璁板綍宸茶闂妭鐐圭殑ID锛岄伩鍏嶅惊鐜紩鐢� + Set<String> visited = new HashSet<>(); + visited.add(id); // 璧峰鑺傜偣宸茶闂� + + while (!queue.isEmpty()) { + ProductMix node = queue.poll(); + // 璺宠繃璧峰鑺傜偣锛堝嵆浼犲叆鐨勮妭鐐癸級锛屼笉鍔犲叆缁撴灉鍒楄〃 + if (!node.getId().toString().equals(id)) { + childrenList.add(node); + } + + // 鏌ヨ褰撳墠鑺傜偣鐨勭洿鎺ュ瓙鑺傜偣 + List<ProductMix> directChildren = this.lambdaQuery().eq(ProductMix::getParentId, node.getId()).list(); + if (directChildren != null && !directChildren.isEmpty()) { + for (ProductMix child : directChildren) { + String childId = child.getId().toString(); + // 濡傛灉璇ュ瓙鑺傜偣杩樻湭璁块棶杩� + if (!visited.contains(childId)) { + visited.add(childId); + queue.add(child); + } + // 鍚﹀垯蹇界暐锛岄伩鍏嶅惊鐜紩鐢ㄥ鑷寸殑姝诲惊鐜� + } + } + } + return childrenList; + } + + /** + * 鏌ヨ浜у搧缁撴瀯鏍戯紙鍖呮嫭璁惧绫讳笌nc鏂囦欢锛� + * @return + */ + @Override + public List<ProductMix> getProductMixTree() { + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + List<ProductMix> rawData = new ArrayList<>(); + if (loginUser.getUsername().equals("admin")) { + //涓嶉渶瑕佹潈闄愯繃婊� + rawData = permissionStreamNewService.loadProductMixAll(loginUser.getId()); + } else { + //闇�瑕佹潈闄愯繃婊� + String productIds = loginUser.getProductionIds(); + if (productIds != null && !productIds.isEmpty()) { + List<String> productIdList = Arrays.asList(productIds.split(",")); + rawData = permissionStreamNewService.loadProductMix(loginUser.getId(), productIdList); + } + } + List<Long> ids = rawData.stream() + .filter(p -> p.getType() != null) + .filter(productMix -> productMix.getType() == 5 || productMix.getType() == 6) + .map(ProductMix::getId) + .collect(Collectors.toList()); + if (ids.isEmpty()) { + return rawData; + } + //杩囨护璁惧绫诲叧鑱斾俊鎭� + List<DeviceType> deviceTypeList = deviceTypeService.list(new QueryWrapper<DeviceType>() + .in("attribution_id", ids)); + List<ProductMix> productMixList = new ArrayList<>(); + deviceTypeList.forEach(item->{ + ProductMix productMix = new ProductMix(); + productMix.setId(Long.parseLong(item.getId())); + productMix.setParentId(Long.parseLong(item.getAttributionId())); + DeviceManagement deviceManagement=deviceManagementService.getById(item.getDeviceManagementId()); + productMix.setTreeCode(deviceManagement.getDeviceManagementCode()); + productMix.setTreeName(deviceManagement.getDeviceManagementName()); + productMix.setType(7); + productMixList.add(productMix); + }); + rawData.addAll(productMixList); + //杩囨护鏂囨。鍏宠仈淇℃伅 + List<String> deviceTypeIds = deviceTypeList.stream().map(DeviceType::getId).collect(Collectors.toList()); + List<DocRelative> relativeList = docRelativeService.list(new QueryWrapper<DocRelative>() + .in("attribution_id", deviceTypeIds)); + List<ProductMix> docList = new ArrayList<>(); + relativeList.forEach(item->{ + ProductMix productMix = new ProductMix(); + productMix.setId(Long.parseLong(item.getId())); + productMix.setParentId(Long.parseLong(item.getAttributionId())); + DocInfo docInfo = docInfoService.getById(item.getDocId()); + productMix.setTreeCode(docInfo.getDocSuffix()); + productMix.setTreeName(docInfo.getDocName()); + productMix.setType(99); + docList.add(productMix); + }); + rawData.addAll(docList); + TreeBuilder builder = new TreeBuilder(); + TreeBuilder.CleanResult cleanResult = builder.preprocessData(rawData); + List<ProductMix> sorted = builder.topologicalSort( + cleanResult.getValidNodes(), + cleanResult.getNodeMap() + ); + List<ProductMix> result =builder.assembleTree(sorted, cleanResult.getNodeMap()); + result.sort(Comparator.comparing(ProductMix::getCreateTime, Comparator.nullsLast(Date::compareTo))); + return result; + } } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepPackageStrategy.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepPackageStrategy.java new file mode 100644 index 0000000..8c9c1b8 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepPackageStrategy.java @@ -0,0 +1,43 @@ +package org.jeecg.modules.dnc.service.impl; + +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.entity.DeviceType; +import org.jeecg.modules.dnc.entity.DocRelative; +import org.jeecg.modules.dnc.entity.WorkStep; +import org.jeecg.modules.dnc.mapper.DeviceTypeMapper; +import org.jeecg.modules.dnc.mapper.DocRelativeMapper; +import org.jeecg.modules.dnc.mapper.WorkStepMapper; +import org.jeecg.modules.dnc.service.DataPackageStrategy; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class WorkStepPackageStrategy implements DataPackageStrategy { + @Autowired + private WorkStepMapper workStepMapper; + @Autowired + private FullHierarchyTraceService traceService; + @Autowired + private DeviceTypeMapper deviceTypeMapper; + @Autowired + private DocRelativeMapper docRelativeMapper; + + @Override + public TransferPackage packageData(String relativeId) { + DocRelative docRelative=docRelativeMapper.selectById(relativeId); + DeviceType deviceType=deviceTypeMapper.selectById(docRelative.getAttributionId()); + if (deviceType!=null&&deviceType.getAttributionType().equals(DocAttributionTypeEnum.WORKSITE.getCode())) { + WorkStep workStep = workStepMapper.selectById(deviceType.getAttributionId()); + if (workStep == null) { + throw new IllegalArgumentException("璁惧绫诲搴旂殑宸ユ涓嶅瓨鍦�: " + deviceType.getDeviceManagementId()); + } + } + return TransferPackage.builder() + .dataType(TransferPackage.DataType.WORKSTEP) + .docRelative(docRelative) + .traceChain(traceService.traceFromWorkStep(docRelative)) + .build(); + } +} + diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java new file mode 100644 index 0000000..d952b71 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java @@ -0,0 +1,53 @@ +package org.jeecg.modules.dncFlow.adapter; + +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import org.jeecg.modules.dncFlow.service.StreamTarget; + +public class AssignEquipmentFileStreamAdapter implements StreamTarget { + private final AssignEquipmentFileStream file; + + public AssignEquipmentFileStreamAdapter(AssignEquipmentFileStream file) { + this.file = file; + } + + @Override + public void setProductId(String productId) { + file.setProductId(productId); + } + + @Override + public void setComponentId(String componentId) { + file.setComponentId(componentId); + } + + @Override + public void setPartsId(String partsId) { + file.setPartsId(partsId); + } + + @Override + public void setProcessId(String processId) { + file.setProcessId(processId); + } + + @Override + public void setPsvId(String psvId) { + file.setPsvId(psvId); + } + + @Override + public void setStepId(String stepId) { + file.setStepId(stepId); + } + + @Override + public void setDeviceTypeId(String deviceTypeId) { + file.setDeviceTypeId(deviceTypeId); + } + + @Override + public String getAttributionId() { + return file.getAttributionId(); + } + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java new file mode 100644 index 0000000..5b57491 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java @@ -0,0 +1,252 @@ +package org.jeecg.modules.dncFlow.controller; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.dnc.entity.DeviceManagement; +import org.jeecg.modules.dnc.entity.DeviceType; +import org.jeecg.modules.dnc.entity.DocInfo; +import org.jeecg.modules.dnc.entity.DocRelative; +import org.jeecg.modules.dnc.service.IDeviceManagementService; +import org.jeecg.modules.dnc.service.IDeviceTypeService; +import org.jeecg.modules.dnc.service.IDocInfoService; +import org.jeecg.modules.dnc.service.IDocRelativeService; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; + +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.jeecg.common.aspect.annotation.AutoLog; + + /** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Api(tags="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲") +@RestController +@RequestMapping("/dncFlow/assignEquipmentFileStream") +@Slf4j +public class AssignEquipmentFileStreamController extends JeecgController<AssignEquipmentFileStream, IAssignEquipmentFileStreamService> { + @Autowired + private IAssignEquipmentFileStreamService assignEquipmentFileStreamService; + + @Autowired + private IDeviceTypeService deviceTypeService; + + @Autowired + private IDeviceManagementService deviceManagementService; + + @Autowired + private IDocRelativeService docRelativeService; + + @Autowired + private IDocInfoService docInfoService; + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param assignEquipmentFileStream + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鍒嗛〉鍒楄〃鏌ヨ") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鍒嗛〉鍒楄〃鏌ヨ", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<AssignEquipmentFileStream>> queryPageList(AssignEquipmentFileStream assignEquipmentFileStream, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper<AssignEquipmentFileStream> queryWrapper = QueryGenerator.initQueryWrapper(assignEquipmentFileStream, req.getParameterMap()); + Page<AssignEquipmentFileStream> page = new Page<AssignEquipmentFileStream>(pageNo, pageSize); + IPage<AssignEquipmentFileStream> pageList = assignEquipmentFileStreamService.page(page, queryWrapper); + return Result.OK(pageList); + } + + + /** + * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� + * @param assignEquipmentFileStream + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�") + @PostMapping(value = "savaFlow") + public Result<?> saveAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream){ + return assignEquipmentFileStreamService.saveAssignEquipmentFileStream(assignEquipmentFileStream); + } + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param assignEquipmentFileStreamVo + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鑺傜偣瀹℃牳") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鑺傜偣瀹℃牳", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鑺傜偣瀹℃牳") + @PostMapping(value = "audit") + public Result<?> auditAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){ + return assignEquipmentFileStreamService.auditAssignEquipmentFileStream(assignEquipmentFileStreamVo); + } + + /** + * 娣诲姞 + * + * @param assignEquipmentFileStream + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娣诲姞") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娣诲姞", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娣诲姞") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:add") + @PostMapping(value = "/add") + public Result<String> add(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) { + assignEquipmentFileStreamService.save(assignEquipmentFileStream); + return Result.OK("娣诲姞鎴愬姛锛�"); + } + + /** + * 鏌ヨ瀹$鍩烘湰淇℃伅 + * @param id + * @return + */ + @ApiOperation(value = "鏌ヨ瀹$鍩烘湰淇℃伅", notes = "鏌ヨ瀹$鍩烘湰淇℃伅") + @GetMapping(value = "/selectVoById") + public Result<?> selectVoById(@RequestParam(name="id") String id){ + List<AssignEquipmentFileStream> list = assignEquipmentFileStreamService.list(new QueryWrapper<AssignEquipmentFileStream>().eq("id", id)); + if (!list.isEmpty()){ + list.forEach(item->{ + DeviceType deviceType = deviceTypeService.getById(item.getDeviceTypeId()); + if (deviceType!=null){ + DeviceManagement deviceManagement = deviceManagementService.getById(deviceType.getDeviceManagementId()); + if (deviceManagement!=null){ + item.setDeviceTypeName(deviceManagement.getDeviceManagementName()); + } + } + DocRelative docRelative=docRelativeService.getById(item.getDocId()); + if (docRelative!=null){ + DocInfo docInfo = docInfoService.getById(docRelative.getDocId()); + item.setDocName(docInfo.getDocName()); + } + + }); + return Result.OK(list); + } + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + + /** + * 缂栬緫 + * + * @param assignEquipmentFileStream + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-缂栬緫") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-缂栬緫", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-缂栬緫") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result<String> edit(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) { + assignEquipmentFileStreamService.updateById(assignEquipmentFileStream); + return Result.OK("缂栬緫鎴愬姛!"); + } + + /** + * 閫氳繃id鍒犻櫎 + * + * @param id + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鍒犻櫎") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鍒犻櫎", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鍒犻櫎") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:delete") + @DeleteMapping(value = "/delete") + public Result<String> delete(@RequestParam(name="id",required=true) String id) { + assignEquipmentFileStreamService.removeById(id); + return Result.OK("鍒犻櫎鎴愬姛!"); + } + + /** + * 鎵归噺鍒犻櫎 + * + * @param ids + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鎵归噺鍒犻櫎") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鎵归噺鍒犻櫎", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鎵归噺鍒犻櫎") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.assignEquipmentFileStreamService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); + } + + /** + * 閫氳繃id鏌ヨ + * + * @param id + * @return + */ + //@AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鏌ヨ") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鏌ヨ", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鏌ヨ") + @GetMapping(value = "/queryById") + public Result<AssignEquipmentFileStream> queryById(@RequestParam(name="id",required=true) String id) { + AssignEquipmentFileStream assignEquipmentFileStream = assignEquipmentFileStreamService.getById(id); + if(assignEquipmentFileStream==null) { + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + return Result.OK(assignEquipmentFileStream); + } + + /** + * 瀵煎嚭excel + * + * @param request + * @param assignEquipmentFileStream + */ + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, AssignEquipmentFileStream assignEquipmentFileStream) { + return super.exportXls(request, assignEquipmentFileStream, AssignEquipmentFileStream.class, "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲"); + } + + /** + * 閫氳繃excel瀵煎叆鏁版嵁 + * + * @param request + * @param response + * @return + */ + //@RequiresPermissions("nc_assign_equipment_file_stream:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, AssignEquipmentFileStream.class); + } + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java new file mode 100644 index 0000000..6fb3a6f --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java @@ -0,0 +1,133 @@ +package org.jeecg.modules.dncFlow.entity; + +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Data +@TableName("nc_assign_equipment_file_stream") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="nc_assign_equipment_file_stream瀵硅薄", description="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲") +public class AssignEquipmentFileStream implements Serializable { + private static final long serialVersionUID = 1L; + + /**涓婚敭*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "涓婚敭") + private String id; + /**璁惧ID*/ + @Excel(name = "璁惧ID", width = 15) + @ApiModelProperty(value = "璁惧ID") + @Dict(dictTable = "mdc_equipment", dicCode = "id", dicText = "equipment_id") + private String equipmentId; + /**璁惧鏂囨。ID*/ + @Excel(name = "璁惧鏂囨。ID", width = 15) + @ApiModelProperty(value = "璁惧鏂囨。ID") + @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name") + private String equipmentDocId; + /**璁惧鏂囦欢ID*/ + @Excel(name = "璁惧鏂囦欢ID", width = 15) + @ApiModelProperty(value = "璁惧鏂囦欢ID") + private String equipmentFileId; + /**浜у搧ID*/ + @Excel(name = "浜у搧ID", width = 15) + @ApiModelProperty(value = "浜у搧ID") + @Dict(dictTable = "nc_product_info", dicCode = "product_id", dicText = "product_name") + private String productId; + /**閮ㄤ欢ID*/ + @Excel(name = "閮ㄤ欢ID", width = 15) + @ApiModelProperty(value = "閮ㄤ欢ID") + @Dict(dictTable = "nc_component_info", dicCode = "component_id", dicText = "component_name") + private String componentId; + /**闆朵欢ID*/ + @Excel(name = "闆朵欢ID", width = 15) + @ApiModelProperty(value = "闆朵欢ID") + @Dict(dictTable = "nc_parts_info", dicCode = "parts_id", dicText = "parts_name") + private String partsId; + /**宸ヨ壓瑙勭▼鐗堟湰ID*/ + @Excel(name = "宸ヨ壓瑙勭▼鐗堟湰ID", width = 15) + @ApiModelProperty(value = "宸ヨ壓瑙勭▼鐗堟湰ID") + @Dict(dictTable = "nc_process_spec_version", dicCode = "id", dicText = "process_spec_version_name") + private String psvId; + /**宸ュ簭ID*/ + @Excel(name = "宸ュ簭ID", width = 15) + @ApiModelProperty(value = "宸ュ簭ID") + @Dict(dictTable = "nc_process_stream", dicCode = "process_id", dicText = "process_name") + private String processId; + /**宸ユID*/ + @Excel(name = "宸ユID", width = 15) + @ApiModelProperty(value = "宸ユID") + @Dict(dictTable = "nc_work_step", dicCode = "id", dicText = "step_name") + private String stepId; + /**璁惧绫籌D*/ + @Excel(name = "璁惧绫籌D", width = 15) + @ApiModelProperty(value = "璁惧绫籌D") + private String deviceTypeId; + /**浜у搧鏂囨。id*/ + @Excel(name = "浜у搧鏂囨。id", width = 15) + @ApiModelProperty(value = "浜у搧鏂囨。id") + @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name") + private String docId; + /**鎸囨淳鍘熷洜*/ + @Excel(name = "鎸囨淳鍘熷洜", width = 15) + @ApiModelProperty(value = "鎸囨淳鍘熷洜") + private String applyReason; + /**瀹℃牳绫诲瀷*/ + @Excel(name = "瀹℃牳绫诲瀷", width = 15) + @ApiModelProperty(value = "瀹℃牳绫诲瀷") + private String auditType; + /**瀹℃牳鎰忚*/ + @Excel(name = "瀹℃牳鎰忚", width = 15) + @ApiModelProperty(value = "瀹℃牳鎰忚") + private String auditReason; + /**鍒涘缓浜�*/ + @ApiModelProperty(value = "鍒涘缓浜�") + private String createBy; + /**鍒涘缓鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "鍒涘缓鏃ユ湡") + private Date createTime; + /**鏇存柊浜�*/ + @ApiModelProperty(value = "鏇存柊浜�") + private String updateBy; + /**鏇存柊鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "鏇存柊鏃ユ湡") + private Date updateTime; + /**鎵�灞為儴闂�*/ + @ApiModelProperty(value = "鎵�灞為儴闂�") + private String sysOrgCode; + + /**璁惧绫诲悕绉�*/ + private transient String deviceTypeName; + + /**浜у搧鏂囦欢鍚嶇О*/ + private transient String docName; + + /**鎵�灞瀒d*/ + private transient String attributionId; + + /**鎵�灞瀟ype*/ + private transient String attributionType; +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java new file mode 100644 index 0000000..09093de --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.dncFlow.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +public interface AssignEquipmentFileStreamMapper extends BaseMapper<AssignEquipmentFileStream> { + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml new file mode 100644 index 0000000..429b990 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper"> + +</mapper> diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java new file mode 100644 index 0000000..99be2f7 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java @@ -0,0 +1,30 @@ +package org.jeecg.modules.dncFlow.service; + +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +public interface IAssignEquipmentFileStreamService extends IService<AssignEquipmentFileStream> { + + /** + * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� + * @param assignEquipmentFileStream + * @return + */ + Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream); + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param assignEquipmentFileStreamVo + * @return + */ + Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo); + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java new file mode 100644 index 0000000..68972da --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java @@ -0,0 +1,316 @@ +package org.jeecg.modules.dncFlow.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.dnc.constant.DncPassLogPassType; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.entity.*; +import org.jeecg.modules.dnc.exception.ExceptionCast; +import org.jeecg.modules.dnc.response.ActivitiCode; +import org.jeecg.modules.dnc.response.CommonCode; +import org.jeecg.modules.dnc.response.DocumentCode; +import org.jeecg.modules.dnc.response.UcenterCode; +import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.dnc.service.impl.FileFerryService; +import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dnc.utils.date.DateUtil; +import org.jeecg.modules.dnc.utils.file.FileUtilS; +import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import org.jeecg.modules.dncFlow.entity.DispatchFile; +import org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper; +import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; +import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; +import org.jeecg.modules.flowable.apithird.service.FlowCommonService; +import org.jeecg.modules.flowable.service.IFlowDefinitionService; +import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.mdc.service.IMdcEquipmentService; +import org.jeecg.modules.system.service.IMdcProductionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.transaction.NoTransactionException; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import javax.annotation.Resource; +import java.io.File; +import java.util.*; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Service("IAssignEquipmentFileStreamService") +public class AssignEquipmentFileStreamServiceImpl extends ServiceImpl<AssignEquipmentFileStreamMapper, AssignEquipmentFileStream> implements IAssignEquipmentFileStreamService , FlowCallBackServiceI { + + @Autowired + private IDocInfoService docInfoService; + @Autowired + private IDocFileService docFileService; + @Autowired + private IMdcEquipmentService mdcEquipmentService; + @Autowired + private IGuideCardBatchService iGuideCardBatchService; + @Resource + private FlowCommonService flowCommonService; + @Resource + private IFlowDefinitionService flowDefinitionService; + @Autowired + private IFlowTaskService flowTaskService; + @Autowired + private TaskService taskService; + @Autowired + private IFlowMyBusinessService flowMyBusinessService; + @Autowired + private IDocRelativeService docRelativeService; + @Autowired + private IDeviceTypeService deviceTypeService; + @Autowired + private PermissionService permissionService; + /** + * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� + * @param assignEquipmentFileStream + * @return + */ + @Override + public Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream){ + //鍙傛暟鏍¢獙 + checkParam(assignEquipmentFileStream); + //鑾峰彇璁惧 + MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); + if(equipment==null){ + return Result.error("鏈彂鐜拌璁惧"); + } + //鑾峰彇璁惧鏂囨。淇℃伅 + DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId()); + if(docInfo==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囨。"); + } + //鑾峰彇璁惧鏂囦欢淇℃伅 + DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId()); + if(docFile==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囦欢"); + } + //鑾峰彇浜у搧鏂囨。淇℃伅 + DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId()); + //鑾峰彇瀵瑰簲璁惧绫� + DeviceType deviceType = deviceTypeService.getById(docRelative.getAttributionId()); + if(deviceType!=null){ + assignEquipmentFileStream.setDeviceTypeId(deviceType.getId()); + assignEquipmentFileStream.setAttributionId(deviceType.getAttributionId()); + assignEquipmentFileStream.setAttributionType(deviceType.getAttributionType().toString()); + PermissionStreamNew permissionStreamNew=permissionService.getPermissionStreams(assignEquipmentFileStream); + if(permissionStreamNew==null){ + return Result.error("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔�"); + } + } + DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId()); + if(productDocInfo==null){ + return Result.error("鏈彂鐜拌浜у搧缁撴瀯鏍戝搴旀枃妗�"); + } + //鑾峰彇浜у搧鏂囨。淇℃伅瀵瑰簲鏈�鏂扮▼搴忓姞宸ョ‘璁よ〃 + List<GuideCardBatch> batches = iGuideCardBatchService.list( + new QueryWrapper<GuideCardBatch>() + .eq("doc_id", productDocInfo.getDocId()) + .eq("flow_status", GuideCardBatchEnum.COMPLETE.getCode()) + .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)")); + if(CollectionUtils.isEmpty(batches)){ + return Result.error("璇ユ枃妗e搴旂殑绋嬪簭鍔犲伐纭琛ㄥ鎵规湭閫氳繃锛屼笉鑳借繘琛屽崌鐗�"); + } + this.save(assignEquipmentFileStream); + System.out.println("璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲锛�" + assignEquipmentFileStream.getId()); + flowCommonService.initActBusiness("璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲:"+docInfo.getDocName()+"->"+productDocInfo.getDocName(), + assignEquipmentFileStream.getId(), "IAssignEquipmentFileStreamService", "nc_assign_equipment_file_stream", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", assignEquipmentFileStream.getId()); + variables.put("organization", assignEquipmentFileStream.getApplyReason()); + variables.put("comment", assignEquipmentFileStream.getApplyReason()); + variables.put("proofreading",true); + Result result= flowDefinitionService.startProcessInstanceByKey("nc_assign_equipment_file_stream", variables); + if (!result.isSuccess()) { + super.removeById(assignEquipmentFileStream.getId()); + } + return result; + } + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param assignEquipmentFileStreamVo + * @return + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){ + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + try { + // 鍙傛暟鏍¢獙 + if (!ValidateUtil.validateString(assignEquipmentFileStreamVo.getTaskId()) || !ValidateUtil.validateString(assignEquipmentFileStreamVo.getDataId())) { + return Result.error(CommonCode.INVALID_PARAM.toString()); + } + String userId = user.getId(); + assignEquipmentFileStreamVo.setAssignee(user.getUsername()); + if (!ValidateUtil.validateString(userId)) { + return Result.error(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST.toString()); + } + + // 鏁版嵁鏌ヨ + AssignEquipmentFileStream assignEquipmentFileStream = this.getById(assignEquipmentFileStreamVo.getDataId()); + if (assignEquipmentFileStream == null) { + return Result.error(CommonCode.INVALID_PARAM.toString()); + } + //鑾峰彇璁惧 + MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); + if(equipment==null){ + return Result.error("鏈彂鐜拌璁惧"); + } + //鑾峰彇璁惧鏂囨。淇℃伅 + DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId()); + if(docInfo==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囨。"); + } + //鑾峰彇璁惧鏂囦欢淇℃伅 + DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId()); + if(docFile==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囦欢"); + } + //鑾峰彇浜у搧鏂囨。淇℃伅 + DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId()); + DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId()); + if(productDocInfo==null){ + return Result.error("鏈彂鐜拌浜у搧缁撴瀯鏍戝搴旀枃妗�"); + } + //鑾峰彇璁惧 + MdcEquipment mdcEquipment =mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); + if (mdcEquipment==null){ + return Result.error("鏈彂鐜拌璁惧"); + } + // 2. 鏌ヨ娴佺▼涓氬姟璁板綍锛堝鐞嗙┖缁撴灉锛� + List<FlowMyBusiness> businessList = flowMyBusinessService.list( + new QueryWrapper<FlowMyBusiness>() + .eq("process_instance_id", assignEquipmentFileStreamVo.getInstanceId()) + ); + if (businessList.isEmpty()) { + return Result.error("娴佺▼璁板綍涓嶅瓨鍦�"); + } + FlowMyBusiness flowMyBusiness = businessList.get(0); + + // 3. 鏍¢獙鐢ㄦ埛鏄惁涓哄�欓�夊鐞嗕汉 + List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); + if (todoUsers == null || !todoUsers.contains(user.getUsername())) { + return Result.error("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔�"); + } + + // 4. 璁ら浠诲姟锛堝鐞嗗凡琚棰嗙殑鎯呭喌锛� + String taskId = flowMyBusiness.getTaskId(); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if (task == null) { + return Result.error("浠诲姟涓嶅瓨鍦ㄦ垨宸插畬鎴�"); + } + if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { + return Result.error("浠诲姟宸茶浠栦汉璁ら"); + } + taskService.claim(taskId, user.getUsername()); + + // 璁剧疆娴佺▼鍙橀噺 + Map<String, Object> values = new HashMap<>(); + values.put("dataId", assignEquipmentFileStream.getId()); + values.put("assignee", userId); + values.put("comment", assignEquipmentFileStreamVo.getComment()); + values.put("organization", assignEquipmentFileStreamVo.getComment()); + assignEquipmentFileStreamVo.setValues(values); + // 瀹屾垚娴佺▼浠诲姟 + Result result = flowTaskService.complete(assignEquipmentFileStreamVo); + if (result.isSuccess()) { + this.updateById(assignEquipmentFileStream); + if (assignEquipmentFileStreamVo.getAuditType().equals("1")) { + //1.浜у搧缁撴瀯鏍憂c鏂囦欢杩涜鍗囩増 + DocFile productDocFile = new DocFile(); + productDocFile.setDocId(productDocInfo.getDocId()); + productDocFile.setFileName(docFile.getFileName()); + productDocFile.setFileEncodeName(docFile.getFileEncodeName()); + productDocFile.setFilePath(docFile.getFilePath()); + productDocFile.setFileSize(docFile.getFileSize()); + productDocFile.setFileSuffix(docFile.getFileSuffix()); + docFileService.addDocFile(productDocFile); + productDocInfo.setPublishVersion(productDocFile.getDocVersion()); + productDocInfo.setPublishFileId(productDocFile.getFileId()); + docInfoService.updateById(productDocInfo); + } + } else { + return result; + } + return Result.OK("鎿嶄綔鎴愬姛"); + } catch (Exception e) { + try { + TransactionStatus transactionStatus = TransactionAspectSupport.currentTransactionStatus(); + if (!transactionStatus.isCompleted()) { + transactionStatus.setRollbackOnly(); + } + } catch (NoTransactionException ex) { + // 蹇界暐鏃犱簨鍔$殑寮傚父 + } + log.error("瀹℃牳澶辫触", e); + return Result.error("鎿嶄綔澶辫触锛�" + e.getMessage()); + } + } + + + //浼犲弬楠岃瘉 + public boolean checkParam(AssignEquipmentFileStream assignEquipmentFileStream) { + if (assignEquipmentFileStream == null) { + ExceptionCast.cast(CommonCode.INVALID_PARAM); + } + if (!ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getDocId()) + || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentFileId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentDocId())) { + ExceptionCast.cast(CommonCode.INVALID_PARAM); + } + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = user.getId(); + if (!ValidateUtil.validateString(userId)) { + ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); + } + return true; + } + + @Override + public void afterFlowHandle(FlowMyBusiness business) { + business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 + business.getValues();//鍓嶇浼犺繘鏉ョ殑鍙傛暟 + business.getActStatus(); + } + + @Override + public Object getBusinessDataById(String dataId) { + return this.getById(dataId); + } + + @Override + public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { + return null; + } + + @Override + public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { + //涓氬姟鏄惁骞查娴佺▼锛屼笟鍔″共棰勶紝娴佺▼骞查锛屾寚瀹氫汉鍛樿繘琛屽鐞� + return null; + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java index 90326a7..a771833 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java @@ -13,16 +13,21 @@ import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.dnc.entity.DocInfo; -import org.jeecg.modules.dnc.entity.PermissionStreamNew; +import org.jeecg.modules.dnc.constant.DncPassLogPassType; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.mapper.DocInfoMapper; import org.jeecg.modules.dnc.request.DocInfoQueryRequest; import org.jeecg.modules.dnc.response.ActivitiCode; import org.jeecg.modules.dnc.response.CommonCode; import org.jeecg.modules.dnc.response.UcenterCode; -import org.jeecg.modules.dnc.service.IDocInfoService; +import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.dnc.service.impl.FileFerryService; import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dnc.utils.date.DateUtil; +import org.jeecg.modules.dnc.utils.file.FileUtilS; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.mapper.DispatchFileMapper; import org.jeecg.modules.dncFlow.service.IDispatchFileService; @@ -35,14 +40,23 @@ import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.flowable.service.IHisWorkTaskService; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysUserRoleService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.*; /** @@ -68,13 +82,29 @@ @Autowired private IFlowMyBusinessService flowMyBusinessService; @Autowired - private DocInfoMapper docInfoMapper; - @Autowired private ISysUserRoleService sysUserRoleService; @Autowired private PermissionService permissionService; @Autowired private IHisWorkTaskService hisWorkTaskService; + @Autowired + private IDeviceTypeService deviceTypeService; + @Autowired + private IDeviceManagementService deviceManagementService; + @Autowired + private IDncPassLogService dncPassLogService; + @Autowired + private IDocFileService docFileService; + @Autowired + private IDocRelativeService docRelativeService; + @Autowired + @Lazy + private FileFerryService ferryService; + @Value("${deploy.secretFolder}") + private String secretFolder; //宸ユ帶缃戜紶杈搉c鏂囦欢澶� + @Value("${fileHomePath}") + private String fileHomePath; + /** * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� * @param dispatchFile @@ -380,9 +410,13 @@ @Override public Result<?> submitProccess(DispatchFile dispatchFile) { checkParam(dispatchFile); - super.save(dispatchFile); //鑾峰彇鏂囦欢淇℃伅 DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId()); + PermissionStreamNew permissionStreams = getPermissionStreams(dispatchFile); + if (permissionStreams==null){ + return Result.error("鐢ㄦ埛娌℃湁鏉冮檺"); + } + super.save(dispatchFile); flowCommonService.initActBusiness(docInfo.getDocName()+"."+docInfo.getDocSuffix()+"鏂囦欢杩涜瀹氬瀷", dispatchFile.getId(), "IDispatchFileService", "process_rf27duhy", null); Map<String, Object> variables = new HashMap<>(); @@ -417,7 +451,7 @@ return values; } - private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) { + private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) throws IOException { if (StrUtil.isNotBlank(dispatchFileFlowTaskVo.getProofreadStatus())) { switch (dispatchFileFlowTaskVo.getProofreadStatus()) { case "1": @@ -448,9 +482,95 @@ if (dispatchFileFlowTaskVo.getStereotype() != null && dispatchFileFlowTaskVo.getStereotype()) { dispatchFile.setCurrentNode("5"); docInfo.setDocDispatchStatus(5); + //瀹氬瀷閫氳繃 + DeviceType deviceType=deviceTypeService.getById(dispatchFile.getDeviceTypeId()); + DeviceManagement deviceManagement=deviceManagementService.getById(deviceType.getDeviceManagementId()); + DocFile docFile=docFileService.getById(dispatchFile.getFileId()); + DocRelative docRelative=docRelativeService.getOne(new QueryWrapper<DocRelative>().eq("doc_id",docInfo.getDocId()) + .eq("attribution_id",dispatchFile.getAttributionId()).eq("attribution_type",dispatchFile.getAttributionType())); + handleFileProcessing(docFile,deviceManagement,secretFolder); + handleProductTree(docInfo,docRelative,deviceManagement); } } + + //灏佽澶勭悊鏂囦欢 + private void handleFileProcessing(DocFile docFile, DeviceManagement deviceManagement, String secretFolder) throws IOException { + if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { + DncPassLog passInfoTxt = new DncPassLog(); + Date dateFirst = DateUtil.getNow(); + passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/ + //浼戠湢 500姣 + DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + int fileNc =0; + if (dncPassLog !=null) { + fileNc = dncPassLog.getSequenceNumber() + 1; + } else { + fileNc = 1; + } + //澶勭悊鏂囦欢鍚嶇О 鏂囦欢璺緞 + String sequenceNc = String.format("%06d",fileNc); + DncPassLog passInfoNc = new DncPassLog(); + passInfoNc.setSequenceNumber(fileNc); + passInfoNc.setSequenceOrder(sequenceNc); + passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + passInfoNc.setPassType(DncPassLogPassType.NCFILE.getCode()); + passInfoNc.setPassName(docFile.getFileName()); + try { + Thread.sleep(1000); + Date date = new Date(); + passInfoNc.setCreateTime(date); + System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + dncPassLogService.save(passInfoNc); + // 4. 鎵ц鏂囦欢鎿嶄綔,鍚庣紑涓篘C + Path source = Paths.get(fileHomePath+docFile.getFilePath(), docFile.getFileEncodeName()); + String destFileName = "10A" + DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc + "_" + deviceManagement.getDeviceManagementCode()+".NC"; + Path destination = Paths.get(secretFolder, destFileName); + Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); + } + } + + /** + * 澶勭悊瀵瑰簲浜у搧缁撴瀯鏍戙�乶c鏂囦欢銆佸垁鍏峰垪琛ㄣ�佺▼搴忓姞宸ョ‘璁よ〃灏佽 + * @param docInfo + */ + private void handleProductTree(DocInfo docInfo, DocRelative docRelative, DeviceManagement deviceManagement) { + /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/ + //浼戠湢 500姣 + DncPassLog passInfoTxt = new DncPassLog(); + Date dateFirst = DateUtil.getNow(); + passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + int fileTxt = 0, fileNc =0; + if (dncPassLog !=null) { + fileTxt = dncPassLog.getSequenceNumber() + 1; + } else { + fileTxt = 1; + } + String sequence = String.format("%06d",fileTxt); + passInfoTxt.setSequenceNumber(fileTxt); + passInfoTxt.setCreateTime(dateFirst); + passInfoTxt.setSequenceOrder(sequence); + System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME)); + passInfoTxt.setPassType(DncPassLogPassType.PRODUCTSTRUCTURE.getCode()); + dncPassLogService.save(passInfoTxt); + String fileName="10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY); + if (Objects.equals(docInfo.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode())){ + //宸ュ簭瀵瑰簲璁惧绫� + String filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry"); + System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath); + }else { + //宸ユ瀵瑰簲璁惧绫� + String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry"); + System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath); + } + } + + //浼犲弬楠岃瘉 public boolean checkParam(DispatchFile dispatchFile) { if (dispatchFile == null) { diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java index 1f4ef4d..368f645 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java @@ -7,8 +7,10 @@ import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.response.ActivitiCode; import org.jeecg.modules.dnc.service.IDeviceTypeService; +import org.jeecg.modules.dncFlow.adapter.AssignEquipmentFileStreamAdapter; import org.jeecg.modules.dncFlow.adapter.AssignFileStreamAdapter; import org.jeecg.modules.dncFlow.adapter.DispatchFileAdapter; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; import org.jeecg.modules.dncFlow.entity.AssignFileStream; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.handler.*; @@ -51,6 +53,10 @@ return processInternal(new AssignFileStreamAdapter(stream), stream.getAttributionType()); } + public PermissionStreamNew getPermissionStreams(AssignEquipmentFileStream stream) { + return processInternal(new AssignEquipmentFileStreamAdapter(stream), stream.getAttributionType()); + } + private PermissionStreamNew processInternal(StreamTarget target, String attributionType) { LoginUser user = getCurrentUser(); String resolvedId = resolveAttributionId(target.getAttributionId()); diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java new file mode 100644 index 0000000..c9a9ef9 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.dncFlow.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; +import org.jeecgframework.poi.excel.annotation.Excel; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Data +@ApiModel(value="璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲--璇锋眰鍙傛暟") +public class AssignEquipmentFileStreamVo extends FlowTaskVo { + /** + * taskIds + */ + private String taskIds; + + /**瀹℃牳绫诲瀷*/ + @Excel(name = "瀹℃牳绫诲瀷", width = 15) + @ApiModelProperty(value = "瀹℃牳绫诲瀷") + private String auditType; + +} -- Gitblit v1.9.3