| | |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.redis.cache.BladeRedis; |
| | | import com.qianwen.core.tool.api.ResultCode; |
| | | import com.qianwen.core.tool.utils.DigestUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.modules.cps.enums.AppEnum; |
| | |
| | | import com.qianwen.smartman.modules.cps.vo.ConfigVO; |
| | | import com.qianwen.smartman.modules.cps.vo.InitSettingVO; |
| | | import com.qianwen.smartman.modules.system.dto.LicenseDetailDTO; |
| | | import com.qianwen.smartman.modules.system.entity.Application; |
| | | import com.qianwen.smartman.modules.system.service.IApplicationService; |
| | | import com.qianwen.smartman.modules.visual.entity.VisualConfig; |
| | | import com.qianwen.smartman.modules.visual.service.IVisualConfigService; |
| | |
| | | private final ThreadPoolTaskExecutor taskExecutor; |
| | | private final Environment environment; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -75622813: |
| | | if (implMethodName.equals("getCode")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 643007317: |
| | | if (implMethodName.equals("getDomainUrl")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | switch (z) { |
| | | case false: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Application") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getDomainUrl(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Application") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getCode(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Application") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getCode(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public InitServiceImpl(final InitMapper initMapper, final ConfigVO configVO, final TdengineMapper tdengineMapper, final DataSource dataSource, final IInitBusinessService initBusinessService, final BladeRedis bladeRedis, final IVisualConfigService visualConfigService, final IApplicationService applicationService, final ThreadPoolTaskExecutor taskExecutor, final Environment environment) { |
| | | this.initMapper = initMapper; |
| | |
| | | @Override // org.springblade.modules.cps.service.IInitService |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean initSystem(InitSettingVO initSettingVO) { |
| | | try { |
| | | if (!initSettingVO.getPassword().equals(initSettingVO.getConfirmPassword())) { |
| | | throw new ServiceException(MessageUtils.message("init.system.inconsistent.password", new Object[0])); |
| | | } |
| | |
| | | runner.runScript(new FileReader(file)); |
| | | FileUtils.copyToFile(new ClassPathResource("sql" + File.separator + this.configVO.getType() + File.separator + "xxl_job.sql").getInputStream(), file); |
| | | runner.runScript(new FileReader(file)); |
| | | List<Integer> appIds = (List) initSettingVO.getAppList().stream().sorted().collect(Collectors.toList()); |
| | | List<Integer> appIds = initSettingVO.getAppList().stream().sorted().collect(Collectors.toList()); |
| | | for (Integer appId : appIds) { |
| | | Future<?> asyncResult = this.taskExecutor.submit(() -> { |
| | | try { |
| | |
| | | } |
| | | IoUtil.close(conn); |
| | | return true; |
| | | }catch(Exception ex) { |
| | | log.error("初始化系统失败",ex); |
| | | throw new ServiceException(ResultCode.FAILURE,ex); |
| | | } |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.IInitService |
| | |
| | | List<String> list = new ArrayList<>(); |
| | | list.addAll(applicationCodes); |
| | | list.add("HMI"); |
| | | |
| | | this.applicationService.remove(Wrappers.<Application>lambdaQuery().notIn(Application::getCode, list)); |
| | | /* |
| | | this.applicationService.remove((Wrapper) Wrappers.lambdaQuery().notIn((v0) -> { |
| | | return v0.getCode(); |
| | | }, list)); |
| | | initSettingVO.getApplicationList().forEach(k, v -> { |
| | | this.applicationService.update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().set((v0) -> { |
| | | return v0.getDomainUrl(); |
| | | }, v)).eq((v0) -> { |
| | | return v0.getCode(); |
| | | }, k)); |
| | | Application::getDomainUrl |
| | | */ |
| | | initSettingVO.getApplicationList().forEach((k, v) -> { |
| | | this.applicationService.update(Wrappers.<Application>lambdaUpdate().set(Application::getDomainUrl, v).eq(Application::getCode, k)); |
| | | }); |
| | | } |
| | | System.setProperty("blade.system.need_init", FmsConstant.MANUAL); |