kettle优化
This commit is contained in:
parent
fdacd1b4ab
commit
863c66c140
|
|
@ -14,6 +14,7 @@ import com.ruoyi.kettle.mapper.XRepositoryMapper;
|
||||||
import com.ruoyi.kettle.tools.KettleUtil;
|
import com.ruoyi.kettle.tools.KettleUtil;
|
||||||
import com.ruoyi.kettle.tools.RedisStreamUtil;
|
import com.ruoyi.kettle.tools.RedisStreamUtil;
|
||||||
import com.ruoyi.system.service.IWechatApiService;
|
import com.ruoyi.system.service.IWechatApiService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -193,6 +194,9 @@ public class KettleJobServiceImpl implements IKettleJobService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runJobRightNow(Long id, String userId) {
|
public void runJobRightNow(Long id, String userId) {
|
||||||
|
if(userId.equals("1")){
|
||||||
|
userId="408";
|
||||||
|
}
|
||||||
KettleJob kettleJob = kettleJobMapper.selectKettleJobById(id);
|
KettleJob kettleJob = kettleJobMapper.selectKettleJobById(id);
|
||||||
if(kettleJob ==null){
|
if(kettleJob ==null){
|
||||||
log.error("作业不存在!");
|
log.error("作业不存在!");
|
||||||
|
|
@ -203,27 +207,27 @@ public class KettleJobServiceImpl implements IKettleJobService
|
||||||
log.error("资源库不存在!");
|
log.error("资源库不存在!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<String> userIdList = new ArrayList<>();
|
||||||
//更新一下状态
|
//更新一下状态
|
||||||
kettleJob.setJobStatus("运行中");
|
kettleJob.setJobStatus("运行中");
|
||||||
kettleJobMapper.updateKettleJob(kettleJob);
|
kettleJobMapper.updateKettleJob(kettleJob);
|
||||||
StringBuilder title = new StringBuilder(kettleJob.getJobName()).append(".kjb 执行结果:");
|
StringBuilder title = new StringBuilder(kettleJob.getJobName()).append(".kjb 执行结果:");
|
||||||
StringBuilder msg = new StringBuilder(kettleJob.getJobName()).append(".kjb 执行结果:");
|
StringBuilder msg = new StringBuilder(kettleJob.getJobName()).append(".kjb 描述:").append(kettleJob.getJobDescription());
|
||||||
try {
|
try {
|
||||||
kettleUtil.callJob(kettleJob,repository,null,null);
|
kettleUtil.callJob(kettleJob,repository,null,null);
|
||||||
kettleJob.setJobStatus("成功");
|
kettleJob.setJobStatus("成功");
|
||||||
kettleJob.setLastSucceedTime(DateUtils.getNowDate());
|
kettleJob.setLastSucceedTime(DateUtils.getNowDate());
|
||||||
kettleJobMapper.updateKettleJob(kettleJob);
|
kettleJobMapper.updateKettleJob(kettleJob);
|
||||||
title.append("成功!");
|
title.append("成功!");
|
||||||
msg.append("成功!");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
kettleJob.setJobStatus("异常");
|
kettleJob.setJobStatus("异常");
|
||||||
kettleJobMapper.updateKettleJob(kettleJob);
|
kettleJobMapper.updateKettleJob(kettleJob);
|
||||||
title.append("异常!");
|
title.append("异常!");
|
||||||
msg.append("异常!");
|
log.error(id+"的job执行失败:"+e.getMessage());
|
||||||
e.printStackTrace();
|
if(!userId.equals("408")){
|
||||||
|
userIdList.add("408");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<String> userIdList = new ArrayList<>();
|
|
||||||
userIdList.add(userId);
|
userIdList.add(userId);
|
||||||
Map<String, String> resultMap = wechatApiService.SendTextCardMessageToWechatUser(userIdList,title.toString(),msg.toString(),"http://report.bpsemi.cn:8081/it_war");
|
Map<String, String> resultMap = wechatApiService.SendTextCardMessageToWechatUser(userIdList,title.toString(),msg.toString(),"http://report.bpsemi.cn:8081/it_war");
|
||||||
log.info("job微信消息发送结果"+resultMap);
|
log.info("job微信消息发送结果"+resultMap);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.kettle.service.impl;
|
package com.ruoyi.kettle.service.impl;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -180,6 +181,10 @@ public class KettleTransServiceImpl implements IKettleTransService
|
||||||
if(repository==null){
|
if(repository==null){
|
||||||
return AjaxResult.error("资源库不存在!");
|
return AjaxResult.error("资源库不存在!");
|
||||||
}
|
}
|
||||||
|
File file=new File(repository.getBaseDir()+kettleTrans.getTransPath()+kettleTrans.getTransName()+".ktr");
|
||||||
|
if(!file.exists()){
|
||||||
|
return AjaxResult.error(file.getPath()+"未找到文件!");
|
||||||
|
}
|
||||||
//加入队列中,等待执行
|
//加入队列中,等待执行
|
||||||
redisStreamUtil.addKettleTrans(kettleTrans);
|
redisStreamUtil.addKettleTrans(kettleTrans);
|
||||||
//更新一下状态
|
//更新一下状态
|
||||||
|
|
@ -190,6 +195,9 @@ public class KettleTransServiceImpl implements IKettleTransService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runTransRightNow(Long id, String userId) {
|
public void runTransRightNow(Long id, String userId) {
|
||||||
|
if(userId.equals("1")){
|
||||||
|
userId="408";
|
||||||
|
}
|
||||||
KettleTrans kettleTrans = kettleTransMapper.selectKettleTransById(id);
|
KettleTrans kettleTrans = kettleTransMapper.selectKettleTransById(id);
|
||||||
if(kettleTrans ==null || kettleTrans.getId()==null){
|
if(kettleTrans ==null || kettleTrans.getId()==null){
|
||||||
log.error("转换不存在!:"+id);
|
log.error("转换不存在!:"+id);
|
||||||
|
|
@ -204,22 +212,23 @@ public class KettleTransServiceImpl implements IKettleTransService
|
||||||
kettleTrans.setTransStatus("运行中");
|
kettleTrans.setTransStatus("运行中");
|
||||||
kettleTransMapper.updateKettleTrans(kettleTrans);
|
kettleTransMapper.updateKettleTrans(kettleTrans);
|
||||||
StringBuilder title = new StringBuilder(kettleTrans.getTransName()).append(".ktr 执行结果:");
|
StringBuilder title = new StringBuilder(kettleTrans.getTransName()).append(".ktr 执行结果:");
|
||||||
StringBuilder msg = new StringBuilder(kettleTrans.getTransName()).append(".ktr 执行结果:");
|
StringBuilder msg = new StringBuilder(kettleTrans.getTransName()).append(":描述:").append(kettleTrans.getTransDescription());
|
||||||
|
List<String> userIdList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
kettleUtil.callTrans(kettleTrans,repository,null,null);
|
kettleUtil.callTrans(kettleTrans,repository,null,null);
|
||||||
kettleTrans.setTransStatus("成功");
|
kettleTrans.setTransStatus("成功");
|
||||||
kettleTrans.setLastSucceedTime(DateUtils.getNowDate());
|
kettleTrans.setLastSucceedTime(DateUtils.getNowDate());
|
||||||
kettleTransMapper.updateKettleTrans(kettleTrans);
|
kettleTransMapper.updateKettleTrans(kettleTrans);
|
||||||
title.append("成功!");
|
title.append("成功!");
|
||||||
msg.append("成功!");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
kettleTrans.setTransStatus("异常");
|
kettleTrans.setTransStatus("异常");
|
||||||
kettleTransMapper.updateKettleTrans(kettleTrans);
|
kettleTransMapper.updateKettleTrans(kettleTrans);
|
||||||
title.append("异常!");
|
title.append("异常!");
|
||||||
msg.append("异常!");
|
|
||||||
log.error(id+"的trans执行失败:"+e.getMessage());
|
log.error(id+"的trans执行失败:"+e.getMessage());
|
||||||
|
if(!userId.equals("408")){
|
||||||
|
userIdList.add("408");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<String> userIdList = new ArrayList<>();
|
|
||||||
userIdList.add(userId);
|
userIdList.add(userId);
|
||||||
Map<String, String> resultMap = wechatApiService.SendTextCardMessageToWechatUser(userIdList,title.toString(),msg.toString(),"http://report.bpsemi.cn:8081/it_war");
|
Map<String, String> resultMap = wechatApiService.SendTextCardMessageToWechatUser(userIdList,title.toString(),msg.toString(),"http://report.bpsemi.cn:8081/it_war");
|
||||||
log.info("trans微信消息发送结果"+resultMap);
|
log.info("trans微信消息发送结果"+resultMap);
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class RedisStreamUtil {
|
||||||
userId = String.valueOf(PermissionUtils.getPrincipalProperty("userId"));
|
userId = String.valueOf(PermissionUtils.getPrincipalProperty("userId"));
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.warn("定时任务执行的,默认发送给天宁吧408");
|
log.warn("定时任务执行的,默认发送给天宁吧408");
|
||||||
userId="454";
|
userId="408";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ public class RedisStreamUtil {
|
||||||
userId = String.valueOf(PermissionUtils.getPrincipalProperty("userId"));
|
userId = String.valueOf(PermissionUtils.getPrincipalProperty("userId"));
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.warn("定时任务执行的,默认发送给天宁吧408");
|
log.warn("定时任务执行的,默认发送给天宁吧408");
|
||||||
userId="454";
|
userId="408";
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(userId+"开始增加:job_"+jobId+"@"+userId+":::"+jobName);
|
log.info(userId+"开始增加:job_"+jobId+"@"+userId+":::"+jobName);
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'jobName',
|
field: 'jobName',
|
||||||
title: '作业名称'
|
title: '作业名称',
|
||||||
|
formatter: function(value, row, index) {
|
||||||
|
return value+".kjb";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'jobDescription',
|
field: 'jobDescription',
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'transName',
|
field: 'transName',
|
||||||
title: '转换名称'
|
title: '转换名称',
|
||||||
|
formatter: function(value, row, index) {
|
||||||
|
return value+".ktr";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'transDescription',
|
field: 'transDescription',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue