提交 fbf8ebfe 编写于 作者: ibizdev's avatar ibizdev

ibiz4j 发布系统代码 [ibiz-task,任务调度]

上级 05eda1d3
...@@ -14,6 +14,10 @@ services: ...@@ -14,6 +14,10 @@ services:
memory: 400M memory: 400M
mode: replicated mode: replicated
replicas: 1 replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes: volumes:
- "nfs:/app/file" - "nfs:/app/file"
......
...@@ -20,18 +20,17 @@ ...@@ -20,18 +20,17 @@
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名--> <!--日志文件输出的文件名-->
<FileNamePattern>${LOG_PATH}/ibztask.%d{yyyy-MM-dd}.log</FileNamePattern> <FileNamePattern>${LOG_PATH}/ibztask.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件最大的大小-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数--> <!--日志文件保留天数-->
<MaxHistory>30</MaxHistory> <MaxHistory>30</MaxHistory>
</rollingPolicy> </rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern> <pattern>${LOG_PATTERN}</pattern>
</encoder> </encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>100MB</MaxFileSize>
</triggeringPolicy>
</appender> </appender>
<!-- 日志输出级别 --> <!-- 日志输出级别 -->
<root level="INFO"> <root level="INFO">
......
...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils; ...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils;
@Service("JobsInfoServiceImpl") @Service("JobsInfoServiceImpl")
public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> implements IJobsInfoService { public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> implements IJobsInfoService {
@Autowired
@Lazy
IJobsInfoService proxyService;
protected int batchSize = 500; protected int batchSize = 500;
...@@ -152,7 +149,7 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i ...@@ -152,7 +149,7 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
if (null == et) { if (null == et) {
return false; return false;
} else { } else {
return checkKey(et) ? proxyService.update(et) : proxyService.create(et); return checkKey(et) ? getProxyService().update(et) : getProxyService().create(et);
} }
} }
...@@ -169,10 +166,10 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i ...@@ -169,10 +166,10 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
return true; return true;
} }
...@@ -190,10 +187,10 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i ...@@ -190,10 +187,10 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
} }
...@@ -259,6 +256,10 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i ...@@ -259,6 +256,10 @@ public class JobsInfoServiceImpl extends ServiceImpl<JobsInfoMapper, JobsInfo> i
public IJobsInfoService getProxyService() {
return cn.ibizlab.util.security.SpringContextHolder.getBean(this.getClass());
}
} }
......
...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils; ...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils;
@Service("JobsLockServiceImpl") @Service("JobsLockServiceImpl")
public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> implements IJobsLockService { public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> implements IJobsLockService {
@Autowired
@Lazy
IJobsLockService proxyService;
protected int batchSize = 500; protected int batchSize = 500;
...@@ -136,7 +133,7 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i ...@@ -136,7 +133,7 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i
if (null == et) { if (null == et) {
return false; return false;
} else { } else {
return checkKey(et) ? proxyService.update(et) : proxyService.create(et); return checkKey(et) ? getProxyService().update(et) : getProxyService().create(et);
} }
} }
...@@ -153,10 +150,10 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i ...@@ -153,10 +150,10 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
return true; return true;
} }
...@@ -174,10 +171,10 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i ...@@ -174,10 +171,10 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
} }
...@@ -226,6 +223,10 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i ...@@ -226,6 +223,10 @@ public class JobsLockServiceImpl extends ServiceImpl<JobsLockMapper, JobsLock> i
public IJobsLockService getProxyService() {
return cn.ibizlab.util.security.SpringContextHolder.getBean(this.getClass());
}
} }
......
...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils; ...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils;
@Service("JobsLogServiceImpl") @Service("JobsLogServiceImpl")
public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> implements IJobsLogService { public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> implements IJobsLogService {
@Autowired
@Lazy
IJobsLogService proxyService;
protected int batchSize = 500; protected int batchSize = 500;
...@@ -136,7 +133,7 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl ...@@ -136,7 +133,7 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl
if (null == et) { if (null == et) {
return false; return false;
} else { } else {
return checkKey(et) ? proxyService.update(et) : proxyService.create(et); return checkKey(et) ? getProxyService().update(et) : getProxyService().create(et);
} }
} }
...@@ -153,10 +150,10 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl ...@@ -153,10 +150,10 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
return true; return true;
} }
...@@ -174,10 +171,10 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl ...@@ -174,10 +171,10 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
} }
...@@ -226,6 +223,10 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl ...@@ -226,6 +223,10 @@ public class JobsLogServiceImpl extends ServiceImpl<JobsLogMapper, JobsLog> impl
public IJobsLogService getProxyService() {
return cn.ibizlab.util.security.SpringContextHolder.getBean(this.getClass());
}
} }
......
...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils; ...@@ -48,9 +48,6 @@ import org.springframework.util.StringUtils;
@Service("JobsRegistryServiceImpl") @Service("JobsRegistryServiceImpl")
public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, JobsRegistry> implements IJobsRegistryService { public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, JobsRegistry> implements IJobsRegistryService {
@Autowired
@Lazy
IJobsRegistryService proxyService;
protected int batchSize = 500; protected int batchSize = 500;
...@@ -136,7 +133,7 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job ...@@ -136,7 +133,7 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job
if (null == et) { if (null == et) {
return false; return false;
} else { } else {
return checkKey(et) ? proxyService.update(et) : proxyService.create(et); return checkKey(et) ? getProxyService().update(et) : getProxyService().create(et);
} }
} }
...@@ -153,10 +150,10 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job ...@@ -153,10 +150,10 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
return true; return true;
} }
...@@ -174,10 +171,10 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job ...@@ -174,10 +171,10 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job
} }
} }
if (create.size() > 0) { if (create.size() > 0) {
proxyService.createBatch(create); getProxyService().createBatch(create);
} }
if (update.size() > 0) { if (update.size() > 0) {
proxyService.updateBatch(update); getProxyService().updateBatch(update);
} }
} }
...@@ -226,6 +223,10 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job ...@@ -226,6 +223,10 @@ public class JobsRegistryServiceImpl extends ServiceImpl<JobsRegistryMapper, Job
public IJobsRegistryService getProxyService() {
return cn.ibizlab.util.security.SpringContextHolder.getBean(this.getClass());
}
} }
......
...@@ -261,6 +261,7 @@ ...@@ -261,6 +261,7 @@
<version>${baomidou-jobs.version}</version> <version>${baomidou-jobs.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
...@@ -346,8 +347,6 @@ ...@@ -346,8 +347,6 @@
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -14,6 +14,10 @@ services: ...@@ -14,6 +14,10 @@ services:
memory: 400M memory: 400M
mode: replicated mode: replicated
replicas: 1 replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes: volumes:
- "nfs:/app/file" - "nfs:/app/file"
......
...@@ -13,6 +13,7 @@ import org.springframework.boot.ApplicationRunner; ...@@ -13,6 +13,7 @@ import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
...@@ -25,58 +26,55 @@ import java.util.*; ...@@ -25,58 +26,55 @@ import java.util.*;
@ConditionalOnProperty( name = "ibiz.enablePermissionValid", havingValue = "true") @ConditionalOnProperty( name = "ibiz.enablePermissionValid", havingValue = "true")
public class PermissionSyncJob implements ApplicationRunner { public class PermissionSyncJob implements ApplicationRunner {
@Autowired
@Lazy
private IBZUAAFeignClient client;
@Value("${ibiz.systemid:ibztask}") @Value("${ibiz.systemid:ibztask}")
private String systemId; private String systemId;
@Value("${ibiz.systemname:ibztask}") @Value("${ibiz.systemname:ibztask}")
private String systemName; private String systemName;
@Autowired @Autowired
@Lazy @Lazy
IBZLiteFeignClient liteFeignClient; private IBZUAAFeignClient uaaClient;
@Autowired
@Lazy
IBZLiteFeignClient liteClient;
@Override @Override
public void run(ApplicationArguments args) { public void run(ApplicationArguments args) {
try { try {
Thread.sleep(10000); Thread.sleep(10000);
InputStream permission = this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力 InputStream permission = this.getClass().getResourceAsStream("/permission/systemResource.json"); //权限资源
String permissionResult = IOUtils.toString(permission,"UTF-8"); if (!ObjectUtils.isEmpty(permission)) {
JSONObject system= new JSONObject(); String strPermission = IOUtils.toString(permission, "UTF-8");
system.put("pssystemid",systemId); JSONObject system = new JSONObject() {{
system.put("pssystemname",systemName); put("pssystemid", systemId);
system.put("sysstructure",JSONObject.parseObject(permissionResult)); put("pssystemname", systemName);
system.put("md5check",DigestUtils.md5DigestAsHex(permissionResult.getBytes())); put("sysstructure", JSONObject.parseObject(strPermission));
if(client.syncSysAuthority(system)) { put("md5check", DigestUtils.md5DigestAsHex(strPermission.getBytes()));
log.info("向[UAA]同步系统资源成功"); }};
}else{ if (uaaClient.syncSysAuthority(system)) {
log.error("向[UAA]同步系统资源失败"); log.info("向[uaa]同步系统资源成功");
} else {
log.error("向[uaa]同步系统资源失败");
}
} }
} } catch (Exception ex) {
catch (Exception ex) { log.error("向[uaa]同步系统资源失败,请检查[uaa]服务是否正常运行! {}", ex.getMessage());
log.error(String.format("向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]",ex));
} }
try { try {
InputStream sysModel = this.getClass().getResourceAsStream("/sysmodel/ibztask.json"); //获取当前系统所有实体资源能力 InputStream model = this.getClass().getResourceAsStream("/sysmodel/ibztask.json"); //系统模型
String strSysModel = IOUtils.toString(sysModel,"UTF-8"); if (!ObjectUtils.isEmpty(model)) {
if(liteFeignClient.syncSysModel(JSONObject.parseObject(strSysModel))) { String strModel = IOUtils.toString(model, "UTF-8");
log.info("向[lite]同步系统模型成功"); if (liteClient.syncSysModel(JSONObject.parseObject(strModel))) {
}else{ log.info("向[lite]同步模型成功");
log.error("向[lite]同步系统模型失败"); } else {
log.error("向[lite]同步模型失败");
}
} }
} catch (Exception ex) {
log.error("向[lite]同步系统模型失败,请检查[lite]服务是否正常运行! {}", ex.getMessage());
} }
catch (Exception ex) {
log.error(String.format("向[lite]同步系统模型失败,请检查[lite]服务是否正常! [%s]",ex));
}
} }
} }
\ No newline at end of file
...@@ -107,3 +107,4 @@ server: ...@@ -107,3 +107,4 @@ server:
min-response-size: 10240 min-response-size: 10240
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册