| | |
| | | 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; |
| | |
| | | saveTreePath(transferPackage.getTraceChain().getTreePath()); |
| | | } |
| | | |
| | | //保存权限 |
| | | if (transferPackage.getTraceChain() != null&& |
| | | transferPackage.getTraceChain().getPermissionStreamNewList() != null) { |
| | | savePermissionStreamNewList(transferPackage.getTraceChain().getPermissionStreamNewList()); |
| | | } |
| | | |
| | | // 保存设备类 |
| | | if (transferPackage.getTraceChain() != null&& |
| | | transferPackage.getTraceChain().getDeviceManagement() != null) { |
| | |
| | | productMapper.insert(product); |
| | | logger.debug("产品已保存: {}", product.getProductId()); |
| | | } else { |
| | | productMapper.updateById(product); |
| | | logger.debug("产品已更新: {}", product.getProductId()); |
| | | logger.debug("产品已存在: {}", product.getProductId()); |
| | | } |
| | | } |
| | | |
| | |
| | | componentMapper.insert(component); |
| | | logger.debug("部件已保存: {}", component.getComponentId()); |
| | | } else { |
| | | componentMapper.updateById(component); |
| | | logger.debug("部件已更新: {}", component.getComponentId()); |
| | | logger.debug("部件已存在: {}", component.getComponentId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | partsMapper.insert(parts); |
| | | logger.debug("零件已保存: {}", parts.getPartsId()); |
| | | } else { |
| | | partsMapper.updateById(parts); |
| | | logger.debug("零件已更新: {}", parts.getPartsId()); |
| | | logger.debug("零件已存在: {}", parts.getPartsId()); |
| | | } |
| | | } |
| | | |
| | |
| | | psvMapper.insert(processSpec); |
| | | logger.debug("工艺规程已保存: {}", processSpec.getId()); |
| | | } else { |
| | | psvMapper.updateById(processSpec); |
| | | logger.debug("工艺规程已更新: {}", processSpec.getId()); |
| | | logger.debug("工艺规程已存在: {}", processSpec.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | processMapper.insert(process); |
| | | logger.debug("工序已保存: {}", process.getProcessId()); |
| | | } else { |
| | | processMapper.updateById(process); |
| | | logger.debug("工序已更新: {}", process.getProcessId()); |
| | | logger.debug("工序已存在: {}", process.getProcessId()); |
| | | } |
| | | } |
| | | |
| | |
| | | workStepMapper.insert(workStep); |
| | | logger.debug("工步已保存: {}", workStep.getId()); |
| | | } else { |
| | | workStepMapper.updateById(workStep); |
| | | logger.debug("工步已更新: {}", workStep.getId()); |
| | | logger.debug("工步已存在: {}", workStep.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | deviceManagementMapper.insert(deviceManagement); |
| | | logger.debug("设备类信息已保存: {}", deviceManagement.getId()); |
| | | } else { |
| | | deviceManagementMapper.updateById(deviceManagement); |
| | | logger.debug("设备类信息已更新: {}", deviceManagement.getId()); |
| | | logger.debug("设备类信息已存在: {}", deviceManagement.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | deviceTypeMapper.insert(deviceType); |
| | | logger.debug("设备类已保存: {}", deviceType.getId()); |
| | | } else { |
| | | deviceTypeMapper.updateById(deviceType); |
| | | logger.debug("设备类已更新: {}", deviceType.getId()); |
| | | logger.debug("设备类已存在: {}", deviceType.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | docInfoMapper.insert(docInfo); |
| | | logger.debug("文档已保存: {}", docInfo.getDocId()); |
| | | } else { |
| | | docInfoMapper.updateById(docInfo); |
| | | logger.debug("文档已更新: {}", docInfo.getDocId()); |
| | | logger.debug("文档已存在: {}", docInfo.getDocId()); |
| | | } |
| | | } |
| | | |
| | |
| | | docFileMapper.insert(docFile); |
| | | logger.debug("文档文件已保存: {}", docFile.getFileId()); |
| | | } else { |
| | | docFileMapper.updateById(docFile); |
| | | logger.debug("文档文件已更新: {}", docFile.getFileId()); |
| | | logger.debug("文档文件已存在: {}", docFile.getFileId()); |
| | | } |
| | | } |
| | | |
| | |
| | | docRelativeMapper.insert(docRelative); |
| | | logger.debug("文档对应关系已保存: {}", docRelative.getId()); |
| | | } else { |
| | | docRelativeMapper.updateById(docRelative); |
| | | logger.debug("文档对应关系已更新: {}", docRelative.getId()); |
| | | logger.debug("文档对应关系已存在: {}", docRelative.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | } |