Commit 2669b6b6 authored by mcb's avatar mcb

commit

parent 2d72b7b0
package com.jz.common.enums;
/**
* 任务树类型
*
* @author Bellamy
* @since 2021-01-04 14:30:23
*/
public enum TaskTreeTypeEnum {
/**
* 离线同步
*/
SYNC("SYNC", "01"),
/**
* 实时同步
*/
SSTB("SSTB", "02"),
/**
* 数据开发
*/
SJKF("SJKF", "03"),
/**
* SHELL
*/
SHELL("SHELL", "04"),
/**
* SQL
*/
SQL("SQL", "05"),
;
private String code;
private String value;
private TaskTreeTypeEnum(String code, String value) {
this.code = code;
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static TaskTreeTypeEnum get(String code) {
if (code == null) {
return null;
}
for (TaskTreeTypeEnum status : values()) {
if (status.getCode().equalsIgnoreCase(code)) {
return status;
}
}
return null;
}
}
......@@ -166,6 +166,10 @@ public class DmpRealtimeSyncInfo implements Serializable {
@ApiModelProperty(value = "scriptJson")
private String scriptJson;
@ApiModelProperty(value = "任务名称")
private String name;
public Integer getId() {
return id;
}
......@@ -421,4 +425,12 @@ public class DmpRealtimeSyncInfo implements Serializable {
public void setScriptJson(String scriptJson) {
this.scriptJson = scriptJson;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.jz.agent.service.DmpDsAgentService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.enums.DelFlagEnum;
import com.jz.common.enums.TaskTreeTypeEnum;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
......@@ -96,6 +97,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired
private DmpDevelopTaskHistoryMapper dmpDevelopTaskHistoryMapper;
@Autowired
private DmpRealtimeSyncInfoDao dmpRealtimeSyncInfoDao;
@Autowired
private RedisTemplate redisTemplate;
......@@ -893,8 +897,29 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
tree.setIsEnable("1");
tree.setDataStatus("1");
int len = dmpNavigationTreeDao.insert(tree);
if (len > 0)
return JsonResult.ok();
if (len > 0) {
if (TaskTreeTypeEnum.SYNC.getValue().equals(newSynchTaskReq.getType())) {
DmpDevelopTask dmpDevelopTask = new DmpDevelopTask();
dmpDevelopTask.setTreeId(tree.getId());
dmpDevelopTask.setVersion("1.0");
dmpDevelopTask.setCreateTime(new Date());
dmpDevelopTask.setCreateUserId(SessionUtils.getCurrentUserId());
dmpDevelopTask.setDataStatus(DelFlagEnum.NO.getValue());
dmpDevelopTask.setName(tree.getName());
dmpDevelopTaskDao.insert(dmpDevelopTask);
return JsonResult.ok(dmpDevelopTask);
} else if (TaskTreeTypeEnum.SSTB.getValue().equals(newSynchTaskReq.getType())) {
DmpRealtimeSyncInfo dmpRealtimeSyncInfo = new DmpRealtimeSyncInfo();
dmpRealtimeSyncInfo.setTreeId(String.valueOf(tree.getId()));
dmpRealtimeSyncInfo.setVersion("1.0");
dmpRealtimeSyncInfo.setCrePerson(SessionUtils.getCurrentUserId());
dmpRealtimeSyncInfo.setCreateTime(new Date());
dmpRealtimeSyncInfo.setProjectId(newSynchTaskReq.getProjectId());
dmpRealtimeSyncInfo.setName(tree.getName());
dmpRealtimeSyncInfoDao.insert(dmpRealtimeSyncInfo);
return JsonResult.ok(dmpRealtimeSyncInfo);
}
}
return JsonResult.error();
}
......@@ -908,15 +933,14 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
*/
@Override
public JsonResult getDataPreview(OfflineDataPreview req) throws Exception {
List<Map<String, List<Object>>> data1 = new ArrayList<>();
List<Object> listHeard = new ArrayList<>();
List<Map> tableData = new ArrayList<>();
Map returnData = new HashMap();
if (req.getParams() == null || req.getParams().size() == 0) {
throw new RuntimeException("请求参数不能为空!");
}
for (SynchTableColumnsReq str : req.getParams()) {
for (int m = 0; m < req.getParams().size(); m++) {
SynchTableColumnsReq str = req.getParams().get(m);
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
......@@ -928,7 +952,10 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//只展示第一张表数据
if (m > 0) {
break;
}
//创建jdbc,获取数据源数据预览
DmpAgentResult rst = dmpDsAgentServiceImp.previewData(dsInfo, str.getTargetTableName());
if (!rst.getCode().val().equals("200")) {
......@@ -936,9 +963,32 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
} else {
//成功,包含表字段和行数据
Map<String, List<Object>> returnList = (Map<String, List<Object>>) JSONObject.parse(rst.getMessage());
if (returnList != null && returnList.size() > 0) {
List<Object> header = returnList.get("header"); //表头 字段
listHeard.addAll(header);
listHeard.addAll(header); //拼接每张表头
List<List<Object>> columnData = Collections.singletonList(returnList.get("result"));//行数据
List<Object> rowData = columnData.get(0);
for (int i = 0; i < rowData.size(); i++) {//表所有数据
List<Object> row = (List<Object>) rowData.get(i); //每行数据
Map colKeyValue = new LinkedHashMap();
for (int j = 0; j < header.size(); j++) { //表头
for (int h = 0; h < row.size(); h++) {
if (j == h) {
System.out.print(header.get(j) + " " + row.get(h));
colKeyValue.put(header.get(j), row.get(h));
break;
}
}
}
tableData.add(colKeyValue);
}
}
/* if (returnList != null && returnList.size() > 0) {
List<Object> header = returnList.get("header"); //表头 字段
listHeard.addAll(header); //拼接每张表头
List<List<Object>> columnData = Collections.singletonList(returnList.get("result"));//行数据
for (int i = 0; i < columnData.size(); i++) {
List<Object> rowData = columnData.get(i);
......@@ -946,22 +996,23 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
map1.put("value", rowData);
data1.add(map1);
}
}
}*/
}
}
/* //两张表字段横向拼接展示 ,data1所有表的数据
if (data1.size() > 0 && data1 != null) {
for (int i = 0; i < data1.size(); i++) {
Map mapa = data1.get(i);
List<List<Object>> lista = (List<List<Object>>) mapa.get("value");
List<List<Object>> reData = new ArrayList<>();
List<List<Object>> lista = (List<List<Object>>) mapa.get("value"); //遍历第i个表数据
List<List<Object>> reData = new ArrayList<>(); //每次循环将数据添加进去
int c = ++i;
for (int a = 0; a < lista.size(); a++) {
for (int a = 0; a < lista.size(); a++) {//遍历第i个表数据
List<Object> obj1 = lista.get(a);
if (c < data1.size()) {
Map mapb = data1.get(c);
List<List<Object>> listb = (List<List<Object>>) mapb.get("value");
for (int b = 0; b < listb.size(); b++) {
for (int b = 0; b < listb.size(); b++) { //遍历第i+1个表数据
List<Object> obj2 = listb.get(b);
if (a == b) {
obj1.addAll(obj2);
......@@ -974,9 +1025,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
mapa.put("value", reData);
}
}
*/
returnData.put("header", listHeard);
returnData.put("rowDatas", data1.get(0));
returnData.put("rowDatas", tableData);
return JsonResult.ok(returnData);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment