From e756af0f5bfd1addbd5d5c145441fb34aad91a28 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期三, 25 六月 2025 13:55:58 +0800 Subject: [PATCH] 同步工控网 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java | 204 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 175 insertions(+), 29 deletions(-) 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 c91c587..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 @@ -1,10 +1,16 @@ package org.jeecg.modules.dnc.service.impl; +import cn.hutool.core.util.StrUtil; import com.jeecg.weibo.exception.BusinessException; +import liquibase.pro.packaged.S; import org.jeecg.modules.dnc.dto.ComponentHierarchy; import org.jeecg.modules.dnc.dto.TransferPackage; 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; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -64,6 +70,48 @@ @Autowired private GuideCardBatchMapper guideCardBatchMapper; + @Autowired + private ISysUserService sysUserService; + + @Autowired + private IMdcProductionService mdcProductionService; + + @Autowired + private IProductPermissionService productPermissionService; + + @Autowired + private IProductDepartmentService productDepartmentService; + + @Autowired + private IComponentPermissionService componentPermissionService; + + @Autowired + private IComponentDepartmentService componentDepartmentService; + + @Autowired + private IPartsPermissionService partsPermissionService; + + @Autowired + private IPartsDepartmentService partsDepartmentService; + + @Autowired + private IProcessSpecVersionPermissionService processSpecVersionPermissionService; + + @Autowired + private IProcessSpecVersionDepartmentService processSpecVersionDepartmentService; + + @Autowired + private IProcessStreamPermissionService processStreamPermissionService; + + @Autowired + private IProcessionDepartmentService processionDepartmentService; + + @Autowired + private IWorkStepPermissionService workStepPermissionService; + + @Autowired + private IWorkStepDepartmentService workStepDepartmentService; + @Transactional(rollbackFor = Exception.class) public void importTransferPackage(TransferPackage transferPackage) { try { @@ -109,6 +157,12 @@ if (transferPackage.getTraceChain() != null&& transferPackage.getTraceChain().getTreePath() != null) { saveTreePath(transferPackage.getTraceChain().getTreePath()); + } + + //淇濆瓨鏉冮檺 + if (transferPackage.getTraceChain() != null&& + transferPackage.getTraceChain().getPermissionStreamNewList() != null) { + savePermissionStreamNewList(transferPackage.getTraceChain().getPermissionStreamNewList()); } // 淇濆瓨璁惧绫� @@ -170,8 +224,7 @@ productMapper.insert(product); logger.debug("浜у搧宸蹭繚瀛�: {}", product.getProductId()); } else { - productMapper.updateById(product); - logger.debug("浜у搧宸叉洿鏂�: {}", product.getProductId()); + logger.debug("浜у搧宸插瓨鍦�: {}", product.getProductId()); } } @@ -181,8 +234,7 @@ componentMapper.insert(component); logger.debug("閮ㄤ欢宸蹭繚瀛�: {}", component.getComponentId()); } else { - componentMapper.updateById(component); - logger.debug("閮ㄤ欢宸叉洿鏂�: {}", component.getComponentId()); + logger.debug("閮ㄤ欢宸插瓨鍦�: {}", component.getComponentId()); } } } @@ -192,8 +244,7 @@ partsMapper.insert(parts); logger.debug("闆朵欢宸蹭繚瀛�: {}", parts.getPartsId()); } else { - partsMapper.updateById(parts); - logger.debug("闆朵欢宸叉洿鏂�: {}", parts.getPartsId()); + logger.debug("闆朵欢宸插瓨鍦�: {}", parts.getPartsId()); } } @@ -202,8 +253,7 @@ psvMapper.insert(processSpec); logger.debug("宸ヨ壓瑙勭▼宸蹭繚瀛�: {}", processSpec.getId()); } else { - psvMapper.updateById(processSpec); - logger.debug("宸ヨ壓瑙勭▼宸叉洿鏂�: {}", processSpec.getId()); + logger.debug("宸ヨ壓瑙勭▼宸插瓨鍦�: {}", processSpec.getId()); } } @@ -212,8 +262,7 @@ processMapper.insert(process); logger.debug("宸ュ簭宸蹭繚瀛�: {}", process.getProcessId()); } else { - processMapper.updateById(process); - logger.debug("宸ュ簭宸叉洿鏂�: {}", process.getProcessId()); + logger.debug("宸ュ簭宸插瓨鍦�: {}", process.getProcessId()); } } @@ -222,8 +271,7 @@ workStepMapper.insert(workStep); logger.debug("宸ユ宸蹭繚瀛�: {}", workStep.getId()); } else { - workStepMapper.updateById(workStep); - logger.debug("宸ユ宸叉洿鏂�: {}", workStep.getId()); + logger.debug("宸ユ宸插瓨鍦�: {}", workStep.getId()); } } @@ -233,10 +281,115 @@ productMixMapper.insert(productMix); logger.debug("浜у搧缁勫悎宸蹭繚瀛�: {}", productMix.getId()); } else { - productMixMapper.updateById(productMix); - logger.debug("浜у搧缁勫悎宸叉洿鏂�: {}", productMix.getId()); + logger.debug("浜у搧缁勫悎宸插瓨鍦�: {}", productMix.getId()); } } + } + + private void savePermissionStreamNewList(List<PermissionStreamNew> permissionStreamNewList) { + for (PermissionStreamNew permissionStreamNew : permissionStreamNewList) { + if (permissionStreamNewMapper.selectById(permissionStreamNew.getId()) == null) { + if (permissionStreamNew.getUserId() != null) { + String id=sysUserService.getUserByName(permissionStreamNew.getUserId()).getId(); + if (id!=null){ + permissionStreamNew.setUserId(id); + } + } + if (permissionStreamNew.getDepartId() != null) { + MdcProduction mdcProduction=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()); + if (mdcProduction!=null){ + permissionStreamNew.setDepartId(mdcProduction.getId()); + } + } + permissionStreamNewMapper.insert(permissionStreamNew); + logger.debug("鏉冮檺宸蹭繚瀛�: {}", permissionStreamNew.getId()); + } + } + //鍒嗘壒娣诲姞浜у搧銆侀儴浠躲�侀浂浠躲�佸伐鑹鸿绋嬨�佸伐搴忋�佸伐姝ユ潈闄� + permissionStreamNewList.forEach(item -> { + switch (item.getBusinessType()){ + case "1": + if (StrUtil.isNotEmpty(item.getUserId())){ + ProductPermission productPermission = new ProductPermission(); + productPermission.setProductId(item.getBusinessId()); + productPermission.setUserId(item.getUserId()); + productPermissionService.save(productPermission); + }else { + ProductDepartment productDepartment = new ProductDepartment(); + productDepartment.setProductId(item.getBusinessId()); + productDepartment.setDepartId(item.getDepartId()); + productDepartmentService.save(productDepartment); + } + break; + case "2": + + if (StrUtil.isNotEmpty(item.getUserId())){ + ComponentPermission componentPermission = new ComponentPermission(); + componentPermission.setComponentId(item.getBusinessId()); + componentPermission.setUserId(item.getUserId()); + componentPermissionService.save(componentPermission); + }else { + ComponentDepartment componentDepartment = new ComponentDepartment(); + componentDepartment.setComponentId(item.getBusinessId()); + componentDepartment.setDepartId(item.getDepartId()); + componentDepartmentService.save(componentDepartment); + } + break; + case "3": + if (StrUtil.isNotEmpty(item.getUserId())){ + PartsPermission partsPermission = new PartsPermission(); + partsPermission.setPartsId(item.getBusinessId()); + partsPermission.setUserId(item.getUserId()); + partsPermissionService.save(partsPermission); + }else { + PartsDepartment partsDepartment = new PartsDepartment(); + partsDepartment.setPartsId(item.getBusinessId()); + partsDepartment.setDepartId(item.getDepartId()); + partsDepartmentService.save(partsDepartment); + } + break; + case "4": + if (StrUtil.isNotEmpty(item.getUserId())){ + ProcessSpecVersionPermission processSpecVersionPermission = new ProcessSpecVersionPermission(); + processSpecVersionPermission.setPsvId(item.getBusinessId()); + processSpecVersionPermission.setUserId(item.getUserId()); + processSpecVersionPermissionService.save(processSpecVersionPermission); + }else { + ProcessSpecVersionDepartment processSpecVersionDepartment = new ProcessSpecVersionDepartment(); + processSpecVersionDepartment.setPsvId(item.getBusinessId()); + processSpecVersionDepartment.setDepartId(item.getDepartId()); + processSpecVersionDepartmentService.save(processSpecVersionDepartment); + } + break; + case "5": + if (StrUtil.isNotEmpty(item.getUserId())){ + ProcessionPermission processionPermission = new ProcessionPermission(); + processionPermission.setProcessId(item.getBusinessId()); + processionPermission.setUserId(item.getUserId()); + processStreamPermissionService.save(processionPermission); + }else { + ProcessionDepartment processionDepartment = new ProcessionDepartment(); + processionDepartment.setProcessId(item.getBusinessId()); + processionDepartment.setDepartId(item.getDepartId()); + processionDepartmentService.save(processionDepartment); + } + break; + case "6": + if (StrUtil.isNotEmpty(item.getUserId())){ + WorkStepPermission workStepPermission = new WorkStepPermission(); + workStepPermission.setStepId(item.getBusinessId()); + workStepPermission.setUserId(item.getUserId()); + workStepPermissionService.save(workStepPermission); + }else { + WorkStepDepartment workStepDepartment = new WorkStepDepartment(); + workStepDepartment.setStepId(item.getBusinessId()); + workStepDepartment.setDepartId(item.getDepartId()); + workStepDepartmentService.save(workStepDepartment); + } + break; + default: + } + }); } private void saveDeviceManagement(DeviceManagement deviceManagement) { @@ -244,8 +397,7 @@ deviceManagementMapper.insert(deviceManagement); logger.debug("璁惧绫讳俊鎭凡淇濆瓨: {}", deviceManagement.getId()); } else { - deviceManagementMapper.updateById(deviceManagement); - logger.debug("璁惧绫讳俊鎭凡鏇存柊: {}", deviceManagement.getId()); + logger.debug("璁惧绫讳俊鎭凡瀛樺湪: {}", deviceManagement.getId()); } } @@ -254,8 +406,7 @@ deviceTypeMapper.insert(deviceType); logger.debug("璁惧绫诲凡淇濆瓨: {}", deviceType.getId()); } else { - deviceTypeMapper.updateById(deviceType); - logger.debug("璁惧绫诲凡鏇存柊: {}", deviceType.getId()); + logger.debug("璁惧绫诲凡瀛樺湪: {}", deviceType.getId()); } } @@ -264,9 +415,7 @@ docInfoMapper.insert(docInfo); logger.debug("鏂囨。宸蹭繚瀛�: {}", docInfo.getDocId()); } else { - docInfo.setDocDispatchStatus(5); - docInfoMapper.updateById(docInfo); - logger.debug("鏂囨。宸叉洿鏂�: {}", docInfo.getDocId()); + logger.debug("鏂囨。宸插瓨鍦�: {}", docInfo.getDocId()); } } @@ -275,8 +424,7 @@ docFileMapper.insert(docFile); logger.debug("鏂囨。鏂囦欢宸蹭繚瀛�: {}", docFile.getFileId()); } else { - docFileMapper.updateById(docFile); - logger.debug("鏂囨。鏂囦欢宸叉洿鏂�: {}", docFile.getFileId()); + logger.debug("鏂囨。鏂囦欢宸插瓨鍦�: {}", docFile.getFileId()); } } @@ -285,8 +433,7 @@ docRelativeMapper.insert(docRelative); logger.debug("鏂囨。瀵瑰簲鍏崇郴宸蹭繚瀛�: {}", docRelative.getId()); } else { - docRelativeMapper.updateById(docRelative); - logger.debug("鏂囨。瀵瑰簲鍏崇郴宸叉洿鏂�: {}", docRelative.getId()); + logger.debug("鏂囨。瀵瑰簲鍏崇郴宸插瓨鍦�: {}", docRelative.getId()); } } @@ -297,18 +444,17 @@ logger.debug("鍒�鍏峰凡淇濆瓨: {}", cutter.getId()); } else { cutterMapper.updateById(cutter); - logger.debug("鍒�鍏峰凡鏇存柊: {}", cutter.getId()); } } } private void saveGuideCardBatch(GuideCardBatch guideCardBatch) { if (guideCardBatchMapper.selectById(guideCardBatch.getId()) == null) { + guideCardBatch.setFlowStatus("1"); guideCardBatchMapper.insert(guideCardBatch); - logger.debug("绋嬪簭鍔犲伐纭琛ㄥ凡淇濆瓨: {}", guideCardBatch.getId()); + logger.debug("鍒�鐗囨壒娆″凡淇濆瓨: {}", guideCardBatch.getId()); } else { - guideCardBatchMapper.updateById(guideCardBatch); - logger.debug("绋嬪簭鍔犲伐纭琛ㄥ凡鏇存柊: {}", guideCardBatch.getId()); + logger.debug("鍒�鐗囨壒娆″凡瀛樺湪: {}", guideCardBatch.getId()); } } } -- Gitblit v1.9.3