Commit 6794ea5f by wuchao

新版本

parent 5a242cd6
package com.chenyang.nse.bussiness.bean;
import com.ghca.fastjson.JSONArray;
import com.ghca.fastjson.JSONObject;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.service.core.impl.DataSystemServiceImpl;
import com.chenyang.nse.bussiness.tools.es.ElasticSearchUtil;
import com.chenyang.nse.bussiness.tools.string.AesTool;
import com.chenyang.nse.bussiness.tools.utils.GHCAUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import org.frameworkset.elasticsearch.client.ClientInterface;
public class CacheElasticSearchThread implements Runnable {
private final DataSystemServiceImpl dataSystemService;
private final TCoreDatasystem coreDataSystem;
private final CountDownLatch countDownLatch;
public CacheElasticSearchThread(DataSystemServiceImpl dataSystemService, TCoreDatasystem coreDataSystem, CountDownLatch countDownLatch) {
this.dataSystemService = dataSystemService;
this.coreDataSystem = coreDataSystem;
this.countDownLatch = countDownLatch;
}
public void run() {
DataBase dataBase = new DataBase();
dataBase.setDatasystemid(this.coreDataSystem.getId());
dataBase.setDbType(this.coreDataSystem.getDbtype());
dataBase.setIp_port(this.coreDataSystem.getDbip() + ":" + this.coreDataSystem.getDbport());
boolean exist = false;
for(DataBase base : DataCache.dataList) {
if (base.getDatasystemid().equals(this.coreDataSystem.getId())) {
exist = true;
dataBase = base;
break;
}
}
if (!exist) {
DataCache.dataList.add(dataBase);
}
ClientInterface clientInterface = GHCAUtils.getInstance().connectToES(this.coreDataSystem.getDbip(), this.coreDataSystem.getDbport(), this.coreDataSystem.getUsername(), AesTool.decrypt(this.coreDataSystem.getPassword(), "ghca"));
try {
String indices = ElasticSearchUtil.getIndices(clientInterface);
JSONArray jsonArray = JSONObject.parseArray(indices);
Iterator<Object> iterator = jsonArray.iterator();
List<Schema> schemaList = new ArrayList();
while(iterator.hasNext()) {
JSONObject jsonObject = (JSONObject)iterator.next();
String index = jsonObject.getString("index");
Schema schema = new Schema(index);
schemaList.add(schema);
String mapping = ElasticSearchUtil.getMapping(clientInterface, index);
JSONObject jsonObjectMapping = JSONObject.parseObject(mapping);
JSONObject jsonObjectType = jsonObjectMapping.getJSONObject(index).getJSONObject("mappings");
Set<String> keySet = jsonObjectType.keySet();
List<Table> tableList = new ArrayList();
schema.setTableList(tableList);
for(String tableName : keySet) {
Table table = new Table(tableName, index);
tableList.add(table);
Set<String> fields = ElasticSearchUtil.getFields(clientInterface, index, tableName);
List<Column> columnList = new ArrayList();
table.setColumnList(columnList);
Column column = new Column("_id", index, tableName);
column.setPrimarykey("1");
columnList.add(column);
for(String field : fields) {
Column columnTemp = new Column(field, index, tableName);
columnList.add(columnTemp);
}
}
}
dataBase.setSchemaList(schemaList);
dataBase.easyCache = new DBEasyCache(dataBase);
dataBase.easyCache.init();
} finally {
clientInterface.getClient().close();
}
}
}
package com.chenyang.nse.bussiness.bean;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.service.core.impl.DataSystemServiceImpl;
import com.chenyang.nse.bussiness.tools.jdbc.JdbcTool;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;
public class CacheHiveTDH implements Runnable {
public static final int SCHEMA_BATCH_SIZE = 1;
public static final int TABLE_BATCH_SIZE = 1000;
public static final int PAGE_SIZE = 50000;
private DataSystemServiceImpl dataSystemService;
private TCoreDatasystem datasystem;
private CountDownLatch cdl;
public CacheHiveTDH(DataSystemServiceImpl dataSystemService, TCoreDatasystem datasystem, CountDownLatch cdl) {
this.dataSystemService = dataSystemService;
this.datasystem = datasystem;
this.cdl = cdl;
}
public void run() {
Connection connection = null;
Statement statement = null;
Connection connection2 = null;
Statement statement2 = null;
try {
DataBase dataBase = new DataBase();
dataBase.setDatasystemid(this.datasystem.getId());
dataBase.setDbType(this.datasystem.getDbtype());
dataBase.setIp_port(this.datasystem.getDbip() + ":" + this.datasystem.getDbport());
boolean exist = false;
for(DataBase base : DataCache.dataList) {
if (base.getDatasystemid().equals(this.datasystem.getId())) {
exist = true;
dataBase = base;
break;
}
}
if (!exist) {
DataCache.dataList.add(dataBase);
}
connection = this.dataSystemService.getConnection(this.datasystem.getId());
statement = connection.createStatement();
long totalStart = System.currentTimeMillis();
List<Schema> schemaList = this.getSchema(statement);
int schemaSize = schemaList.size();
int loop = (int)Math.ceil((double)1.0F * (double)schemaSize / (double)1.0F);
List<List<Schema>> schemaSubs = new ArrayList();
for(int i = 0; i < loop; ++i) {
int fromIndex = i * 1;
int toIndex = (i + 1) * 1;
if (fromIndex > schemaSize) {
fromIndex = schemaSize;
}
if (toIndex > schemaSize) {
toIndex = schemaSize;
}
List<Schema> schemaSub = schemaList.subList(fromIndex, toIndex);
schemaSubs.add(schemaSub);
}
connection2 = this.dataSystemService.getConnection(this.datasystem.getId());
statement2 = connection2.createStatement();
Statement finalStatement = statement2;
schemaSubs.stream().forEach((item) -> {
try {
this.cacheSchema(finalStatement, item);
} catch (SQLException throwables) {
throwables.printStackTrace();
}
});
dataBase.setSchemaList(schemaList);
dataBase.easyCache = new DBEasyCache(dataBase);
dataBase.easyCache.init();
} catch (Throwable e) {
e.printStackTrace();
} finally {
try {
JdbcTool.closeConnection(connection);
if (statement != null) {
statement.close();
}
JdbcTool.closeConnection(connection2);
if (statement2 != null) {
statement2.close();
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
this.cdl.countDown();
System.out.println("hiveTDH结束缓存");
}
}
public List<Schema> getSchema(Statement statement) throws SQLException {
List<Schema> schemas = new ArrayList();
String sql = "show databases";
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()) {
Schema schema = new Schema(resultSet.getString("DATABASE_NAME"));
schemas.add(schema);
}
resultSet.close();
return schemas;
}
private void cacheSchema(Statement statement, List<Schema> schemaSub) throws SQLException {
List<Table> tableList = new ArrayList();
List<Column> columns = new ArrayList();
long start1 = System.currentTimeMillis();
List<Table> tableListTemp = this.getTables(statement, schemaSub);
tableList.addAll(tableListTemp);
int tableSize = tableListTemp.size();
int loop = (int)Math.ceil((double)1.0F * (double)tableSize / (double)1000.0F);
for(int j = 0; j < loop; ++j) {
int fromIndexTable = j * 1000;
int toIndexTable = (j + 1) * 1000;
if (fromIndexTable > tableSize) {
fromIndexTable = tableSize;
}
if (toIndexTable > tableSize) {
toIndexTable = tableSize;
}
List<Table> tableSub = tableList.subList(fromIndexTable, toIndexTable);
long start3 = System.currentTimeMillis();
List<Column> columnsTemp = this.getColumns(statement, schemaSub, tableSub);
columns.addAll(columnsTemp);
long e = System.currentTimeMillis();
}
long start5 = System.currentTimeMillis();
Map<String, Schema> schemasMap = new HashMap();
Map<String, Table> tablesMap = new HashMap();
for(Schema schema : schemaSub) {
schemasMap.put(schema.getName(), schema);
}
for(Table table : tableList) {
String key = this.getSchemaTableId(table.getSchema(), table.getName());
tablesMap.put(key, table);
((Schema)schemasMap.get(table.getSchema())).getTableList().add(table);
}
for(Column column : columns) {
String key = this.getSchemaTableId(column.getSchema(), column.getTable());
try {
((Table)tablesMap.get(key)).getColumnList().add(column);
} catch (Exception var19) {
System.out.println(key);
}
}
long end1 = System.currentTimeMillis();
System.out.println("hiveTDH schema:" + tableSize + " tables 用时:" + (end1 - start1) / 1000L);
}
public String getSchemaTableId(String schemaName, String tableName) {
return schemaName + "--->" + tableName;
}
private List<Table> getTables(Statement statement, List<Schema> schemas) throws SQLException {
String schemasWhere = String.join("','", (Iterable)schemas.stream().filter((x) -> x != null && x.getName().length() > 0).map((x) -> x.getName()).collect(Collectors.toList()));
List<Table> tables = new ArrayList();
int pageNum = 1;
int pageSize = 50000;
while(true) {
int offset = (pageNum - 1) * pageSize;
String sql = "SELECT database_name, table_name FROM SYSTEM.tables_v WHERE database_name in ('" + schemasWhere + "') limit " + offset + " , " + pageSize;
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()) {
String schema = resultSet.getString("database_name");
Table table = new Table(resultSet.getString("table_name"), schema);
tables.add(table);
}
if (resultSet.getRow() < pageSize) {
return tables;
}
resultSet.close();
++pageNum;
}
}
private List<Column> getColumns(Statement statement, List<Schema> schemas, List<Table> tables) throws SQLException {
int pageNum = 1;
int pageSize = 50000;
String schemasWhere = String.join("','", (Iterable)schemas.stream().filter((x) -> x != null && x.getName().length() > 0).map((x) -> x.getName()).collect(Collectors.toList()));
String tablesWhere = String.join("','", (Iterable)tables.stream().filter((x) -> x != null && x.getName().length() > 0).map((x) -> x.getName()).collect(Collectors.toList()));
List<Column> columns = new ArrayList(50000);
while(true) {
int offset = (pageNum - 1) * pageSize;
String sql = "SELECT column_id, column_name, column_type, table_name, database_name, commentstring, default_value, nullable, unique_constraint, column_length, column_scale FROM SYSTEM.columns_v where database_name in( '" + schemasWhere + "') and table_name in ('" + tablesWhere + "') ORDER BY column_id limit " + offset + " , " + pageSize;
ResultSet resultSet = statement.executeQuery(sql);
resultSet.setFetchSize(50000);
Column column = null;
while(resultSet.next()) {
column = new Column();
String schema = resultSet.getString("database_name");
String table = resultSet.getString("table_name");
column.setColumnName(resultSet.getString("column_name"));
column.setSchema(schema);
column.setTable(table);
Object scale = resultSet.getObject("column_scale");
String remark = resultSet.getString("commentstring");
columns.add(column);
}
if (resultSet.getRow() < pageSize) {
return columns;
}
resultSet.close();
++pageNum;
}
}
}
package com.chenyang.nse.bussiness.bean;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.service.core.impl.DataSystemServiceImpl;
import com.chenyang.nse.bussiness.tools.string.AesTool;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoIterable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import org.bson.Document;
public class CacheMongodb implements Runnable {
private DataSystemServiceImpl dataSystemService;
private TCoreDatasystem datasystem;
private CountDownLatch cdl;
public CacheMongodb(DataSystemServiceImpl dataSystemService, TCoreDatasystem datasystem, CountDownLatch cdl) {
this.dataSystemService = dataSystemService;
this.datasystem = datasystem;
this.cdl = cdl;
}
public void run() {
DataBase dataBase = new DataBase();
dataBase.setDatasystemid(this.datasystem.getId());
dataBase.setDbType(this.datasystem.getDbtype());
dataBase.setIp_port(this.datasystem.getDbip() + ":" + this.datasystem.getDbport());
boolean exist = false;
for(DataBase base : DataCache.dataList) {
if (base.getDatasystemid().equals(this.datasystem.getId())) {
exist = true;
dataBase = base;
break;
}
}
if (!exist) {
DataCache.dataList.add(dataBase);
}
String ip = this.datasystem.getDbip();
String port = this.datasystem.getDbport();
String username = this.datasystem.getUsername();
String passwd = this.datasystem.getPassword();
String databaseName = this.datasystem.getDbservername();
try {
MongoClient client;
if (username != null && !"".equals(username)) {
passwd = !"1".equals(this.datasystem.getFlag()) && !"4".equals(this.datasystem.getFlag()) ? this.datasystem.getPassword() : AesTool.decrypt(this.datasystem.getPassword(), "ghca");
client = this.connect(databaseName, username, passwd, ip, Integer.valueOf(port), true);
} else {
client = this.connect(databaseName, username, passwd, ip, Integer.valueOf(port), false);
}
List<String> dblist = client.getDatabaseNames();
List<Schema> schemas = new ArrayList();
for(String dbname : dblist) {
MongoDatabase db = client.getDatabase(dbname);
Schema schema = new Schema(dbname);
List<Table> tables = new ArrayList();
MongoIterable<String> colls = db.listCollectionNames();
MongoCursor<String> mongoCursor = colls.iterator();
while(mongoCursor.hasNext()) {
String coll = (String)mongoCursor.next();
if (!coll.contains("system")) {
List<Column> columns = this.findAllColumns(client, dbname, coll);
Table table = new Table(coll, dbname);
table.setColumnList(columns);
tables.add(table);
}
}
schema.setTableList(tables);
schemas.add(schema);
}
dataBase.setSchemaList(schemas);
dataBase.easyCache = new DBEasyCache(dataBase);
dataBase.easyCache.init();
} catch (Exception e) {
e.printStackTrace();
}
}
public MongoClient connect(String databaseName, String username, String passwd, String ip, int port, boolean auth) throws Exception {
MongoClient client = null;
if (auth) {
MongoCredential credential = MongoCredential.createCredential(username, databaseName, passwd.toCharArray());
ServerAddress addr = new ServerAddress(ip, port);
client = new MongoClient(addr, Arrays.asList(credential));
} else {
client = new MongoClient(ip, port);
}
return client;
}
public List<Column> findAllColumns(MongoClient client, String schema, String collectionName) throws Exception {
List<Column> columns = new ArrayList();
MongoDatabase db = null;
db = client.getDatabase(schema);
MongoCollection<Document> collection = db.getCollection(collectionName);
Set<String> columnSet = new HashSet();
for(Document doc : findAll(collection)) {
for(Map.Entry<String, Object> entrySet : doc.entrySet()) {
if (entrySet.getValue() instanceof Document) {
this.analysisDocument((String)entrySet.getKey(), (Document)entrySet.getValue(), columnSet);
} else {
columnSet.add(entrySet.getKey());
}
}
}
for(String s : columnSet) {
Column column = new Column();
column.setColumnName(s);
column.setTable(collectionName);
column.setSchema(schema);
columns.add(column);
}
return columns;
}
public void analysisDocument(String prefix, Document document, Set<String> columnSet) {
for(Map.Entry<String, Object> entrySet : document.entrySet()) {
if (entrySet.getValue() instanceof Document) {
this.analysisDocument(prefix + "." + (String)entrySet.getKey(), (Document)entrySet.getValue(), columnSet);
} else {
columnSet.add(prefix + "." + (String)entrySet.getKey());
}
}
}
public static List<Document> findAll(MongoCollection<Document> collection) {
List<Document> results = new ArrayList();
FindIterable<Document> iterables = collection.find();
MongoCursor<Document> cursor = iterables.iterator();
while(cursor.hasNext()) {
results.add(cursor.next());
}
return results;
}
public static void main(String[] args) {
TCoreDatasystem datasystem = new TCoreDatasystem();
datasystem.setDbip("192.168.2.127");
datasystem.setDbport("27017");
datasystem.setServername("db1");
datasystem.setUsername("db1");
datasystem.setPassword("db1");
CountDownLatch cdl = new CountDownLatch(1);
(new CacheMongodb((DataSystemServiceImpl)null, datasystem, cdl)).run();
}
}
package com.chenyang.nse.bussiness.bean;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.entity.vo.ComboboxVO;
import com.chenyang.nse.bussiness.entity.vo.DBTableVO;
import com.chenyang.nse.bussiness.entity.vo.maskingtask.ColumnInfoVO;
import com.chenyang.nse.bussiness.service.core.impl.DataSystemServiceImpl;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
public class CacheThread implements Runnable {
private DataSystemServiceImpl dataSystemService;
private TCoreDatasystem datasystem;
private CountDownLatch cdl;
public CacheThread(DataSystemServiceImpl dataSystemService, TCoreDatasystem datasystem, CountDownLatch cdl) {
this.dataSystemService = dataSystemService;
this.datasystem = datasystem;
this.cdl = cdl;
}
public CacheThread(DataSystemServiceImpl dataSystemService, TCoreDatasystem datasystem) {
this.dataSystemService = dataSystemService;
this.datasystem = datasystem;
}
public void run() {
try {
DataBase dataBase = new DataBase();
dataBase.setDatasystemid(this.datasystem.getId());
dataBase.setDbType(this.datasystem.getDbtype());
dataBase.setIp_port(this.datasystem.getDbip() + ":" + this.datasystem.getDbport());
boolean exist = false;
for(DataBase base : DataCache.dataList) {
if (base.getDatasystemid().equals(this.datasystem.getId())) {
exist = true;
dataBase = base;
break;
}
}
if (!exist) {
DataCache.dataList.add(dataBase);
}
Connection conn = null;
if (!this.datasystem.getDbtype().equals("KAFKA")) {
conn = this.dataSystemService.getConnection(this.datasystem.getId());
List<ComboboxVO> shemas = this.dataSystemService.querySchema_new(this.datasystem, conn);
List<Schema> schemaList = new ArrayList();
for(ComboboxVO schemaObj : shemas) {
Schema schema = new Schema(schemaObj.getValue());
schemaList.add(schema);
List<DBTableVO> tables = this.dataSystemService.queryTablename_new(this.datasystem, schemaObj.getValue(), conn);
List<Table> tableList = new ArrayList();
schema.setTableList(tableList);
for(DBTableVO tableObj : tables) {
Table table = new Table(tableObj.getTablename(), schemaObj.getValue());
tableList.add(table);
List<ColumnInfoVO> columns = this.dataSystemService.queryColumnInfo_new(conn, schemaObj.getValue(), tableObj.getTablename());
List<Column> columnList = new ArrayList();
table.setColumnList(columnList);
for(ColumnInfoVO columnObj : columns) {
Column column = new Column(columnObj.getColumnname(), schemaObj.getValue(), tableObj.getTablename());
column.setPrimarykey(columnObj.getPrimarykey());
columnList.add(column);
}
}
}
dataBase.setSchemaList(schemaList);
dataBase.easyCache = new DBEasyCache(dataBase);
dataBase.easyCache.init();
if (conn != null) {
conn.close();
}
}
} catch (Throwable e) {
e.printStackTrace();
} finally {
this.cdl.countDown();
}
}
public void cacheImmediately() {
try {
DataBase dataBase = new DataBase();
dataBase.setDatasystemid(this.datasystem.getId());
dataBase.setIp_port(this.datasystem.getDbip() + ":" + this.datasystem.getDbport());
boolean exist = false;
for(DataBase base : DataCache.dataList) {
if (base.getDatasystemid().equals(this.datasystem.getId())) {
;
}
}
if (!exist) {
DataCache.dataList.add(dataBase);
}
Connection conn = this.dataSystemService.getConnection(this.datasystem.getId());
List<ComboboxVO> shemas = this.dataSystemService.querySchema_new(this.datasystem, conn);
List<Schema> schemaList = new ArrayList();
for(ComboboxVO schemaObj : shemas) {
Schema schema = new Schema(schemaObj.getValue());
schemaList.add(schema);
List<DBTableVO> tables = this.dataSystemService.queryTablename_new(this.datasystem, schemaObj.getValue(), conn);
List<Table> tableList = new ArrayList();
schema.setTableList(tableList);
for(DBTableVO tableObj : tables) {
Table table = new Table(tableObj.getTablename(), schemaObj.getValue());
tableList.add(table);
List<ColumnInfoVO> columns = this.dataSystemService.queryColumnInfo_new(conn, schemaObj.getValue(), tableObj.getTablename());
List<Column> columnList = new ArrayList();
table.setColumnList(columnList);
for(ColumnInfoVO columnObj : columns) {
Column column = new Column(columnObj.getColumnname(), schemaObj.getValue(), tableObj.getTablename());
column.setPrimarykey(columnObj.getPrimarykey());
columnList.add(column);
}
}
}
dataBase.setSchemaList(schemaList);
dataBase.easyCache = new DBEasyCache(dataBase);
dataBase.easyCache.init();
if (conn != null) {
conn.close();
}
} catch (Throwable e) {
e.printStackTrace();
}
}
public TCoreDatasystem getDatasystem() {
return this.datasystem;
}
public void setDatasystem(TCoreDatasystem datasystem) {
this.datasystem = datasystem;
}
public CountDownLatch getCdl() {
return this.cdl;
}
public void setCdl(CountDownLatch cdl) {
this.cdl = cdl;
}
}
package com.chenyang.nse.bussiness.bean;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDatasystem;
import com.chenyang.nse.bussiness.entity.vo.ComboboxVO;
import com.chenyang.nse.bussiness.entity.vo.DBTableVO;
import com.chenyang.nse.bussiness.entity.vo.maskingtask.ColumnInfoVO;
import com.chenyang.nse.bussiness.service.core.impl.DataSystemServiceImpl;
import com.chenyang.nse.bussiness.tools.string.AesTool;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import util.JdbcCacheUtil;
public class CacheThreadImmediately extends Thread {
private DataSystemServiceImpl dataSystemService;
private TCoreDatasystem datasystem;
public CacheThreadImmediately(DataSystemServiceImpl dataSystemService, TCoreDatasystem datasystem) {
this.dataSystemService = dataSystemService;
this.datasystem = datasystem;
}
public void run() {
this.cacheImmediately();
}
public void cacheImmediately() {
try {
DataBase dataBase = new DataBase();
dataBase.setDatasystemid(this.datasystem.getId());
dataBase.setDbType(this.datasystem.getDbtype());
dataBase.setIp_port(this.datasystem.getDbip() + ":" + this.datasystem.getDbport());
dataBase.setDbType(this.datasystem.getDbtype());
boolean exist = false;
for(DataBase base : DataCache.dataList) {
if (base.getDatasystemid().equals(this.datasystem.getId())) {
;
}
}
if (!exist) {
DataCache.dataList.add(dataBase);
}
Connection conn = null;
if (!"ES".equals(this.datasystem.getDbtype())) {
conn = this.dataSystemService.getConnection(this.datasystem.getId());
} else {
String content = "{\n \"ip_port\": \"" + this.datasystem.getDbip() + ":" + this.datasystem.getDbport() + "\",\n \"url\": \"http://" + this.datasystem.getDbip() + ":" + this.datasystem.getDbport() + "/\",\n \"username\": \"" + this.datasystem.getUsername() + "\",\n \"password\": \"" + AesTool.decrypt(this.datasystem.getPassword(), "ghca") + "\",\n \"dbType\": \"es\"\n}";
JdbcCacheUtil.initData(content);
}
List<ComboboxVO> shemas = this.dataSystemService.querySchema_new(this.datasystem, conn);
List<Schema> schemaList = new ArrayList();
for(ComboboxVO schemaObj : shemas) {
Schema schema = new Schema(schemaObj.getValue());
schemaList.add(schema);
List<DBTableVO> tables = this.dataSystemService.queryTablename_new(this.datasystem, schemaObj.getValue(), conn);
List<Table> tableList = new ArrayList();
schema.setTableList(tableList);
for(DBTableVO tableObj : tables) {
Table table = new Table(tableObj.getTablename(), schemaObj.getValue());
tableList.add(table);
List<ColumnInfoVO> columns = this.dataSystemService.queryColumnInfo_new(conn, schemaObj.getValue(), tableObj.getTablename());
List<Column> columnList = new ArrayList();
table.setColumnList(columnList);
for(ColumnInfoVO columnObj : columns) {
Column column = new Column(columnObj.getColumnname(), schemaObj.getValue(), tableObj.getTablename());
column.setPrimarykey(columnObj.getPrimarykey());
columnList.add(column);
}
}
}
dataBase.setSchemaList(schemaList);
dataBase.easyCache = new DBEasyCache(dataBase);
dataBase.easyCache.init();
if (conn != null) {
conn.close();
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
package com.chenyang.nse.bussiness.ccoresdf;
import com.chenyang.nse.bussiness.local.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.ApplicationArguments;
import org.springframework.stereotype.Component;
@Component
public class CcoreSDFRunner {
@Autowired
@Qualifier("CCoreSDFTestServiceImpl")
private TestService service;
public void run(ApplicationArguments args) throws Exception {
this.service.test();
}
}
package com.chenyang.nse.bussiness.ccoresdf;
import com.chenyang.nse.bussiness.ccore.CcoreSDF;
import com.chenyang.nse.bussiness.service.key.impl.KeyManagerServiceImpl;
import com.chenyang.nse.bussiness.tools.spring.SpringUtil;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.codec.Hex;
public class CcoreSDFUtil {
static int COMPUTE_ID = 257;
static byte[] pucIV = new byte[]{49, 50, 51, 52, 53, 54, 55, 56, 49, 50, 51, 52, 53, 54, 55, 56};
public static CcoreSDF.ECCCipher eccCipher = getECCCipher();
static String password;
public static byte[] getPucRandom(int len) {
Session session = null;
byte[] pucRandom;
try {
session = openCCore();
if (session.success) {
pucRandom = new byte[len];
long ret = 0L;
ret = CcoreSDF.GenerateRandom(session.phSessionHandle[0], (long)len, pucRandom);
if (ret != 0L) {
System.out.printf("GenerateRandom error ret = 0x%08x ", ret);
byte[] var11 = longToBytes(ret);
return var11;
}
byte[] var5 = pucRandom;
return var5;
}
pucRandom = null;
} finally {
closeCCore(session);
}
return pucRandom;
}
public static String getEncrypt(byte[] pucRandom) {
Session session = null;
Object pucEncData;
try {
session = openCCore();
if (session.success) {
byte[] pucEncData1 = new byte[pucRandom.length];
long[] puiEncDataLength = new long[1];
long phKeyHandleOne = getPhKeyHandle(session, eccCipher);
CcoreSDF.Encrypt(session.phSessionHandle[0], phKeyHandleOne, (long)COMPUTE_ID, pucIV, pucRandom, (long)pucRandom.length, pucEncData1, puiEncDataLength);
CcoreSDF.DestroyKey(session.phSessionHandle[0], phKeyHandleOne);
String var6 = Hex.encodeToString(pucEncData1);
return var6;
}
pucEncData = null;
} finally {
closeCCore(session);
}
return (String)pucEncData;
}
public static String getDecrypt(byte[] pucEncData) {
Session session = null;
Object pucData;
try {
session = openCCore();
if (session.success) {
byte[] pucDataNew = new byte[pucEncData.length];
long[] puiDataLength = new long[1];
long phKeyHandleOne = getPhKeyHandle(session, eccCipher);
CcoreSDF.Decrypt(session.phSessionHandle[0], phKeyHandleOne, (long)COMPUTE_ID, pucIV, pucEncData, (long)pucEncData.length, pucDataNew, puiDataLength);
CcoreSDF.DestroyKey(session.phSessionHandle[0], phKeyHandleOne);
String var6 = Hex.encodeToString(pucDataNew);
return var6;
}
pucData = null;
} finally {
closeCCore(session);
}
return (String)pucData;
}
private static byte[] longToBytes(long x) {
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.putLong(x);
return buffer.array();
}
private static Map<String, String> getParams() {
return ((KeyManagerServiceImpl)SpringUtil.getBean(KeyManagerServiceImpl.class)).showKeyParams("4");
}
private static CcoreSDF.ECCCipher getECCCipher() {
CcoreSDF.ECCCipher eccCipher = new CcoreSDF.ECCCipher();
Map<String, String> props = getParams();
String x = (String)props.get("ecccipherx");
String y = (String)props.get("eccciphery");
String M = (String)props.get("ecccipherm");
String C = (String)props.get("ecccipherc");
String L = (String)props.get("ecccipherl");
eccCipher.x = stringReplaceByte(x.replaceAll(" ", "").split(","));
eccCipher.y = stringReplaceByte(y.replaceAll(" ", "").split(","));
eccCipher.M = stringReplaceByte(M.replaceAll(" ", "").split(","));
eccCipher.C = stringReplaceByte(C.replaceAll(" ", "").split(","));
eccCipher.L = Long.parseLong(L);
password = (String)props.get("cphpwd");
return eccCipher;
}
static Session openCCore() {
long ret = 0L;
Session session = new Session();
ret = CcoreSDF.OpenDevice(session.phDeviceHandle);
if (ret != 0L) {
System.out.printf("OpenDevice error ret = 0x%08x ", ret);
return session;
} else {
ret = CcoreSDF.OpenSession(session.phDeviceHandle[0], session.phSessionHandle);
if (ret != 0L) {
System.out.printf("OpenSession error ret = 0x%08x ", ret);
return session;
} else {
session.success = true;
return session;
}
}
}
static Boolean closeCCore(Session session) {
if (session == null) {
return false;
} else {
CcoreSDF.CloseSession(session.phSessionHandle[0]);
CcoreSDF.CloseDevice(session.phDeviceHandle[0]);
return true;
}
}
private static byte[] stringReplaceByte(String[] strings) {
int length = strings.length;
byte[] bytes = new byte[strings.length];
for(int i = 0; i < length; ++i) {
int a = Integer.parseInt(strings[i]);
bytes[i] = (byte)a;
}
return bytes;
}
private static long getPhKeyHandle(Session session, CcoreSDF.ECCCipher pucKeyCPECC) {
long[] phKeyHandle = new long[1];
long ret = CcoreSDF.GetPrivateKeyAccessRight(session.phSessionHandle[0], 1L, password, (long)password.length());
if (ret != 0L) {
System.out.printf("eeGetPrivateKeyAccessRight error ret = 0x%08x ", ret);
return ret;
} else {
ret = CcoreSDF.ImportKeyWithISK_ECC(session.phSessionHandle[0], 1L, pucKeyCPECC, phKeyHandle);
if (ret != 0L) {
System.out.printf("ImportKeyWithISK_ECC error ret = 0x%08x ", ret);
return ret;
} else {
return phKeyHandle[0];
}
}
}
public static void main(String[] args) {
long ret = 0L;
CcoreSDF.ECCCipher pucKeyCPECC = new CcoreSDF.ECCCipher();
pucKeyCPECC.C = new byte[128];
long[] phKeyHandle = new long[1];
Session session = openCCore();
ret = CcoreSDF.GenerateKeyWithIPK_ECC(session.phSessionHandle[0], 1L, 128L, pucKeyCPECC, phKeyHandle);
if (ret != 0L) {
System.out.printf("GenerateKeyWithIPK_ECC error ret = 0x%08x ", ret);
} else {
System.out.println(" GenerateKeyWithIPK_ECC pucKeyCPECC.x:");
System.out.printf(Arrays.toString(pucKeyCPECC.x));
System.out.println("\n\n");
System.out.println("\n GenerateKeyWithIPK_ECC pucKeyCPECC.y:");
System.out.printf(Arrays.toString(pucKeyCPECC.y));
System.out.println("\n\n");
System.out.println(" GenerateKeyWithIPK_ECC pucKeyCPECC.M:");
System.out.printf(Arrays.toString(pucKeyCPECC.M));
System.out.println("\n\n");
System.out.printf("\n GenerateKeyWithIPK_ECC pucKeyCPECC.L:%d\n", pucKeyCPECC.L);
System.out.println("\n\n");
System.out.println("\n GenerateKeyWithIPK_ECC pucKeyCPECC.C:");
System.out.printf(Arrays.toString(pucKeyCPECC.C));
}
}
static class Session {
long[] phDeviceHandle = new long[1];
long[] phSessionHandle = new long[1];
Boolean success = false;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.chenyang.nse.bussiness.controller.console;
import com.chenyang.nse.bussiness.entity.cache.LoginUser;
import com.chenyang.nse.bussiness.entity.orm.table.base.TBaseButton;
import com.chenyang.nse.bussiness.entity.orm.table.console.TConsoleLog;
import com.chenyang.nse.bussiness.entity.vo.ResultVO;
import com.chenyang.nse.bussiness.service.console.ButtonService;
import com.chenyang.nse.bussiness.service.console.OperationService;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/console/button"})
public class ButtonController {
@Autowired
private ButtonService buttonService;
@Autowired
private OperationService operationService;
@RequestMapping({"/checkNameExit"})
@ResponseBody
public ResultVO checkNameExit(String addmenuid, String buttonname, String operatename, HttpServletRequest request, HttpServletResponse response, Model model) {
boolean result = this.buttonService.checkNameExit(addmenuid, buttonname);
String message = this.buttonService.checkUrlExit(operatename);
ResultVO vo = new ResultVO(message, result);
return vo;
}
@RequestMapping({"/checkNameExitEdit"})
@ResponseBody
public ResultVO checkNameExitEdit(String addmenuid, String buttonname, String operatename, String oldbutton, String oldurl, HttpServletRequest request, HttpServletResponse response, Model model) {
ResultVO vo = null;
if (oldbutton.equals(buttonname) && oldurl.equals(operatename)) {
vo = new ResultVO("1", false);
} else if (!oldbutton.equals(buttonname) && oldurl.equals(operatename)) {
boolean result = this.buttonService.checkNameExit(addmenuid, buttonname);
vo = new ResultVO("1", result);
} else if (oldbutton.equals(buttonname) && !oldurl.equals(operatename)) {
String message = this.buttonService.checkUrlExit(operatename);
vo = new ResultVO(message, false);
} else {
boolean result = this.buttonService.checkNameExit(addmenuid, buttonname);
String message = this.buttonService.checkUrlExit(operatename);
vo = new ResultVO(message, result);
}
return vo;
}
@RequestMapping({"/add"})
public void add(String addmenuid, String flag, TBaseButton button, HttpServletRequest request, HttpServletResponse response, Model model) {
button.setMenuid(addmenuid);
button.setCreatetime(new Date());
button.setFlag(flag);
TConsoleLog record = new TConsoleLog();
if (null == button.getId()) {
record.setLogmessage("增加按钮");
} else {
record.setLogmessage("修改按钮");
}
this.buttonService.save(button);
LoginUser loginUser = (LoginUser)request.getSession().getAttribute("loginUser");
String username = loginUser.getTsysUser().getUsername();
record.setModule("菜单管理");
record.setOperationtime(new Date());
record.setUser(username);
record.setOperationObject(button.getButtonname());
this.operationService.add(record);
}
@RequestMapping({"/querybuttonbyid"})
@ResponseBody
public TBaseButton queryButtonById(String id, HttpServletRequest request, HttpServletResponse response, Model model) {
TBaseButton tBaseButton = this.buttonService.queryButtonById(id);
return tBaseButton;
}
@RequestMapping({"/removebutton"})
@ResponseBody
public void removebutton(String id, String menuname, HttpServletRequest request, HttpServletResponse response, Model model) {
this.buttonService.deletebutton(id);
TConsoleLog record = new TConsoleLog();
LoginUser loginUser = (LoginUser)request.getSession().getAttribute("loginUser");
String username = loginUser.getTsysUser().getUsername();
record.setModule("菜单管理");
record.setLogmessage("删除按钮");
record.setOperationtime(new Date());
record.setUser(username);
record.setOperationObject(menuname);
this.operationService.add(record);
}
}
package com.chenyang.nse.bussiness.controller.core;
import cn.hutool.core.bean.BeanUtil;
import com.chenyang.nse.bussiness.commmon.json.RespHelper;
import com.chenyang.nse.bussiness.commmon.json.Response;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreDataScope;
import com.chenyang.nse.bussiness.entity.orm.table.core.TCoreSensitiveLevel;
import com.chenyang.nse.bussiness.entity.orm.table.core.fieldscope.TCoreCategoryLevelLog;
import com.chenyang.nse.bussiness.entity.vo.TCoreCatagoryLevelLogVO;
import com.chenyang.nse.bussiness.service.core.DataScopeService;
import com.chenyang.nse.bussiness.service.core.ITcoreCatacoryLevelLogService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/core/catagorylevellog"})
public class CatagoryLevelLogController {
@Autowired
private DataScopeService dataScopeService;
@Autowired
private ITcoreCatacoryLevelLogService tcoreCatacoryLevelLogService;
@ResponseBody
@RequestMapping({"/getlevellog"})
public Response<List<TCoreCatagoryLevelLogVO>> getlevellog(@RequestBody Map<String, Object> params) {
List<TCoreCatagoryLevelLogVO> result = new ArrayList();
List<TCoreCategoryLevelLog> tCoreCategoryLevelLogs = this.tcoreCatacoryLevelLogService.queryAll(params);
tCoreCategoryLevelLogs.forEach((item) -> {
TCoreCatagoryLevelLogVO vo = new TCoreCatagoryLevelLogVO();
BeanUtil.copyProperties(item, vo, new String[0]);
String categoryids = vo.getCategoryid();
if (StringUtils.isNotBlank(categoryids)) {
String[] split = categoryids.split(",");
List<TCoreDataScope> tCoreDataScopeList = new ArrayList();
for(int i = 0; i < split.length; ++i) {
TCoreDataScope tCoreDataScope = new TCoreDataScope();
String scope_id = split[i];
Map<String, String> scopenamemap = this.dataScopeService.queryScopeById(scope_id);
tCoreDataScope.setScope_id(scope_id);
tCoreDataScope.setScope_name((String)scopenamemap.get("scope_name"));
tCoreDataScopeList.add(tCoreDataScope);
}
vo.setTCoreDataScopeList(tCoreDataScopeList);
}
if (StringUtils.isNotBlank(vo.getLevelid())) {
TCoreSensitiveLevel tCoreSensitiveLevel = new TCoreSensitiveLevel();
tCoreSensitiveLevel.setSensitive_id(vo.getLevelid());
Map<String, String> scopenamemap = this.dataScopeService.queryScopelevelById(vo.getLevelid());
tCoreSensitiveLevel.setSensitive_name((String)scopenamemap.get("sensitive_name"));
vo.setTCoreSensitiveLevel(tCoreSensitiveLevel);
}
result.add(vo);
});
return RespHelper.<List<TCoreCatagoryLevelLogVO>>successResp(result);
}
}
package com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class CDataAdapter extends XmlAdapter<String, String> {
public String marshal(String str) throws Exception {
return "<![CDATA[" + str + "]]>";
}
public String unmarshal(String str) throws Exception {
return str;
}
}
package com.chenyang.nse.bussiness.engine.infa.powercenter961.simplesubdata;
import com.chenyang.nse.bussiness.commmon.ApplicationConstants;
import com.chenyang.nse.bussiness.engine.infa.InfoProperty;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.CONFIG;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.FOLDER;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.MAPPING;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.POWERMART;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.REPOSITORY;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.SOURCE;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.TARGET;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.WORKFLOW;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata.Configutil;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata.Folderutil;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata.Powermartutil;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata.Repositoryutil;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MappingBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MappingPramaBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.SourceBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.TargetBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.WorkflowBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubtool.ToObjutil;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class ChildSeCollectiveUtil {
public void seChildMethod(String taskname, String repositoryName, String dataBaseType, String foldername, String owner, String shaerd, String group, List<SourceBean> sb, List<TargetBean> tb, String mappingname, List<MappingBean> mb, String workflowname, InfoProperty tengine, List<WorkflowBean> wb, List<MappingPramaBean> paramList, String paramfilepath) throws Exception {
new POWERMART();
Powermartutil pu = new Powermartutil();
POWERMART powermart = pu.getPowermart();
new REPOSITORY();
Repositoryutil ru = new Repositoryutil();
REPOSITORY repository = ru.getREPOSITORY(repositoryName, dataBaseType);
new FOLDER();
Folderutil fu = new Folderutil();
FOLDER folder = fu.getFolder(foldername, owner, shaerd, group);
ChildSeSourceUtil gsu = new ChildSeSourceUtil();
if (sb != null && sb.size() > 0) {
new ArrayList();
List<SOURCE> gtu = gsu.getSeChildSource(sb);
if (gtu != null && gtu.size() > 0) {
for(int i = 0; i < gtu.size(); ++i) {
folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(gtu.get(i));
}
}
}
ChildSeTargetUtil gtu = new ChildSeTargetUtil();
if (tb != null && tb.size() > 0) {
new ArrayList();
List<TARGET> var32 = gtu.getSeChildTarget(tb);
if (var32 != null && var32.size() > 0) {
for(int i = 0; i < var32.size(); ++i) {
folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(var32.get(i));
}
}
}
ChildSeMappingUtil mgu = new ChildSeMappingUtil();
if (mb != null && mb.size() > 0) {
new MAPPING();
MAPPING var34 = mgu.getSeChildMapping(mappingname, mb, paramList);
folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(var34);
}
new CONFIG();
Configutil cu = new Configutil();
CONFIG var35 = cu.getConfig();
folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(var35);
ChildSeWorkflowUtil gwf = new ChildSeWorkflowUtil();
if (wb != null && wb.size() > 0) {
new WORKFLOW();
WORKFLOW alllist = gwf.getSeChildWorkflow(mappingname, workflowname, tengine.getInteservicename(), tengine.getDomainname(), wb, paramfilepath);
folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(alllist);
}
repository.getFOLDER().add(folder);
powermart.getREPOSITORY().add(repository);
List<Object> alllist = new ArrayList();
alllist.add(powermart);
OutputStream f = null;
OutputStream var37 = new FileOutputStream(ApplicationConstants.exefile_path + taskname + ".xml");
ToObjutil.marshal("com.chenyang.nse.bussiness.xmlbean", alllist, var37, "");
}
}
package com.chenyang.nse.bussiness.engine.infa.powercenter961.simplesubdata;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.ASSOCIATEDSOURCEINSTANCE;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.CONNECTOR;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.ERPINFO;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.INSTANCE;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.MAPPING;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.MAPPINGVARIABLE;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.TABLEATTRIBUTE;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.TARGETLOADORDER;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.TRANSFORMATION;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.TRANSFORMFIELD;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MappingBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MappingPramaBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubtool.StringUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ChildSeMappingUtil {
public MAPPING getSeChildMapping(String mappingname, List<MappingBean> mb, List<MappingPramaBean> paramList) throws Exception {
MAPPING mapping = new MAPPING();
mapping.setDESCRIPTION("");
mapping.setISVALID("YES");
mapping.setNAME(mappingname);
mapping.setOBJECTVERSION("1");
mapping.setVERSIONNUMBER("1");
if (mb != null && mb.size() > 0) {
for(int i = 0; i < mb.size(); ++i) {
mapping.getTRANSFORMATION().add(this.getTRANSFORMATIONXml(((MappingBean)mb.get(i)).getSq_name(), ((MappingBean)mb.get(i)).getCb().getNameList(), ((MappingBean)mb.get(i)).getCb().getMappingTypeList(), ((MappingBean)mb.get(i)).getCb().getMappingPrecisionList(), ((MappingBean)mb.get(i)).getMappingsql()));
}
}
if (mb != null && mb.size() > 0) {
for(int i = 0; i < mb.size(); ++i) {
for(INSTANCE instance : this.getConvertTableInfoToINSTANCE(((MappingBean)mb.get(i)).getSq_name(), ((MappingBean)mb.get(i)).getSource_name(), ((MappingBean)mb.get(i)).getTarget_name(), ((MappingBean)mb.get(i)).getSourcedbname())) {
mapping.getINSTANCE().add(instance);
}
}
}
if (mb != null && mb.size() > 0) {
for(int i = 0; i < mb.size(); ++i) {
for(CONNECTOR connector : this.getConvertTableInfoToCONNECTOR(((MappingBean)mb.get(i)).getCb().getNameList(), ((MappingBean)mb.get(i)).getSq_name(), ((MappingBean)mb.get(i)).getSource_name(), ((MappingBean)mb.get(i)).getTarget_name())) {
mapping.getCONNECTOR().add(connector);
}
}
}
if (mb != null && mb.size() > 0) {
for(int i = 0; i < mb.size(); ++i) {
TARGETLOADORDER targetloadorder = new TARGETLOADORDER();
targetloadorder.setORDER(i + 1 + "");
targetloadorder.setTARGETINSTANCE("MAPPING");
mapping.getTARGETLOADORDER().add(targetloadorder);
}
}
if (paramList != null && paramList.size() > 0) {
for(int i = 0; i < paramList.size(); ++i) {
MAPPINGVARIABLE mappingvariable = new MAPPINGVARIABLE();
mappingvariable.setAGGFUNCTION("MAX");
mappingvariable.setDATATYPE(((MappingPramaBean)paramList.get(i)).getDatatype());
mappingvariable.setISEXPRESSIONVARIABLE("NO");
mappingvariable.setISPARAM("NO");
mappingvariable.setNAME(((MappingPramaBean)paramList.get(i)).getName());
mappingvariable.setPRECISION(((MappingPramaBean)paramList.get(i)).getPrecision());
mappingvariable.setSCALE(((MappingPramaBean)paramList.get(i)).getScale());
mappingvariable.setUSERDEFINED("YES");
mapping.getMAPPINGVARIABLE().add(mappingvariable);
}
}
ERPINFO erpinfo = new ERPINFO();
mapping.getERPINFO().add(erpinfo);
return mapping;
}
public TRANSFORMATION getTRANSFORMATIONXml(String sq_name, List<String> columnList, List<String> dataTypeList, List<String> lengthList, String mappingsql) {
TRANSFORMATION transformation = new TRANSFORMATION();
transformation.setDESCRIPTION("");
transformation.setNAME(sq_name);
transformation.setOBJECTVERSION("1");
transformation.setREUSABLE("NO");
transformation.setTYPE("Source Qualifier");
transformation.setVERSIONNUMBER("1");
for(TRANSFORMFIELD transformfield : this.getTransformfield(columnList, dataTypeList, lengthList)) {
transformation.getTRANSFORMFIELD().add(transformfield);
}
for(TABLEATTRIBUTE tableattribute : this.getTableattribute(mappingsql)) {
transformation.getTABLEATTRIBUTE().add(tableattribute);
}
return transformation;
}
public List<TRANSFORMFIELD> getTransformfield(List<String> columnList, List<String> dataTypeList, List<String> lengthList) {
List<TRANSFORMFIELD> transformfield = new ArrayList();
for(int i = 0; i < columnList.size(); ++i) {
TRANSFORMFIELD tran = new TRANSFORMFIELD();
tran.setDATATYPE((String)dataTypeList.get(i));
tran.setDEFAULTVALUE("");
tran.setDESCRIPTION("");
tran.setNAME(StringUtil.null2String(columnList.get(i)));
tran.setPICTURETEXT("");
tran.setPORTTYPE("INPUT/OUTPUT");
tran.setPRECISION((String)lengthList.get(i));
if ("date/time".equals(dataTypeList.get(i))) {
tran.setSCALE("9");
} else {
tran.setSCALE("0");
}
transformfield.add(tran);
}
return transformfield;
}
public List<TABLEATTRIBUTE> getTableattribute(String mappingsql) {
List<TABLEATTRIBUTE> tableattributeList = new ArrayList();
String[] tableattributeStr = new String[]{"Sql Query@" + mappingsql, "User Defined Join", "Source Filter@", "Number Of Sorted Ports@0", "Tracing Level@Normal", "Select Distinct@NO", "Is Partitionable@NO", "Pre SQL", "Post SQL", "Output is deterministic@NO", "Output is repeatable@Never"};
for(int i = 0; i < tableattributeStr.length; ++i) {
TABLEATTRIBUTE tableattribute = new TABLEATTRIBUTE();
String[] tmpStr = tableattributeStr[i].split("@");
tableattribute.setNAME(tmpStr[0]);
if (tmpStr.length > 1) {
tableattribute.setVALUE(tmpStr[1]);
} else {
tableattribute.setVALUE("");
}
tableattributeList.add(tableattribute);
}
return tableattributeList;
}
public List<INSTANCE> getConvertTableInfoToINSTANCE(String sq_name, String sourcename, String targetname, String sourcedbname) {
List<INSTANCE> instanceList = new ArrayList();
INSTANCE first_instance = new INSTANCE();
first_instance.setDESCRIPTION("");
first_instance.setNAME(targetname);
first_instance.setTRANSFORMATIONNAME(targetname);
first_instance.setTRANSFORMATIONTYPE("Target Definition");
first_instance.setTYPE("TARGET");
instanceList.add(first_instance);
INSTANCE second_instance = new INSTANCE();
second_instance.setDBDNAME(sourcedbname);
second_instance.setDESCRIPTION("");
second_instance.setNAME(sourcename);
second_instance.setTRANSFORMATIONNAME(sourcename);
second_instance.setTRANSFORMATIONTYPE("Source Definition");
second_instance.setTYPE("SOURCE");
instanceList.add(second_instance);
INSTANCE fou_instance = new INSTANCE();
fou_instance.setDESCRIPTION("");
fou_instance.setNAME(sq_name);
fou_instance.setREUSABLE("NO");
fou_instance.setTRANSFORMATIONNAME(sq_name);
fou_instance.setTRANSFORMATIONTYPE("Source Qualifier");
fou_instance.setTYPE("TRANSFORMATION");
ASSOCIATEDSOURCEINSTANCE associatedsourceinstance = new ASSOCIATEDSOURCEINSTANCE();
associatedsourceinstance.setNAME(sourcename);
fou_instance.getASSOCIATEDSOURCEINSTANCE().add(associatedsourceinstance);
instanceList.add(fou_instance);
return instanceList;
}
public List<CONNECTOR> getConvertTableInfoToCONNECTOR(List<String> columnList, String sq_name, String sourcename, String targetname) throws Exception {
List mappingConnectorlist = new ArrayList();
new HashMap();
List<String> list = new ArrayList();
for(int i = 0; i < columnList.size(); ++i) {
if (!list.contains(columnList.get(i))) {
CONNECTOR connectOr = new CONNECTOR();
connectOr.setFROMFIELD((String)columnList.get(i));
connectOr.setFROMINSTANCE(sourcename);
connectOr.setFROMINSTANCETYPE("Source Definition");
connectOr.setTOFIELD((String)columnList.get(i));
connectOr.setTOINSTANCE(sq_name);
connectOr.setTOINSTANCETYPE("Source Qualifier");
mappingConnectorlist.add(connectOr);
}
}
for(int i = 0; i < columnList.size(); ++i) {
CONNECTOR connectOr = new CONNECTOR();
connectOr.setFROMFIELD((String)columnList.get(i));
connectOr.setFROMINSTANCE(sq_name);
connectOr.setFROMINSTANCETYPE("Source Qualifier");
connectOr.setTOFIELD((String)columnList.get(i));
connectOr.setTOINSTANCE(targetname);
connectOr.setTOINSTANCETYPE("Target Definition");
mappingConnectorlist.add(connectOr);
}
return mappingConnectorlist;
}
}
package com.chenyang.nse.bussiness.kms.controller;
import com.chenyang.nse.bussiness.kms.service.KmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping({"kms"})
public class ChallengeCodeController {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
protected KmsService kmsService;
@RequestMapping({"challengecode"})
public String challengeCode() throws Exception {
return this.kmsService.obtainChallengeCode();
}
}
package com.chenyang.nse.bussiness.service.console;
import com.chenyang.nse.bussiness.entity.orm.table.base.TBaseButton;
import com.chenyang.nse.bussiness.entity.orm.table.base.TBaseRole;
import java.util.List;
public interface ButtonService {
boolean checkNameExit(String menuid, String buttonname);
void save(TBaseButton button);
List<String> queryDistinctMenuId();
List<TBaseButton> queryButtonByParentId(String parentid);
TBaseButton queryButtonById(String id);
void deletebutton(String id);
String checkUrlExit(String url);
List<TBaseButton> queryButtonCRUDByRoleids(List<TBaseRole> roleids);
List<TBaseButton> queryButtonNotCRUDByRoleids(List<TBaseRole> roleids);
}
package com.chenyang.nse.bussiness.service.console.impl;
import com.chenyang.nse.bussiness.dao.table.base.TBaseButtonDao;
import com.chenyang.nse.bussiness.entity.orm.table.base.TBaseButton;
import com.chenyang.nse.bussiness.entity.orm.table.base.TBaseRole;
import com.chenyang.nse.bussiness.service.console.ButtonService;
import com.chenyang.nse.bussiness.tools.string.StringTool;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@Transactional
public class ButtonServiceImpl implements ButtonService {
@Autowired
private TBaseButtonDao tBaseButtonDao;
public boolean checkNameExit(String menuid, String buttonname) {
Criterion cmenuid = Restrictions.eq("menuid", menuid);
Criterion cbuttonname = Restrictions.eq("buttonname", buttonname);
long count = this.tBaseButtonDao.count(new Criterion[]{cmenuid, cbuttonname});
return count > 0L;
}
public void save(TBaseButton button) {
if (button.getId() == null) {
button.setId(StringTool.getTablePrimaryKey());
this.tBaseButtonDao.save(button);
} else {
this.tBaseButtonDao.saveOrUpdate(button);
}
}
public List<String> queryDistinctMenuId() {
List<String> list = this.tBaseButtonDao.getDistinctMenuId();
return list;
}
public List<TBaseButton> queryButtonByParentId(String parentid) {
Criterion cpid = Restrictions.eq("menuid", parentid);
return this.tBaseButtonDao.queryAll(new Criterion[]{cpid});
}
public TBaseButton queryButtonById(String id) {
Criterion ctid = Restrictions.eq("id", id);
return id != null ? (TBaseButton)this.tBaseButtonDao.queryUnique(new Criterion[]{ctid}) : null;
}
public void deletebutton(String id) {
this.tBaseButtonDao.removeById(id);
}
public String checkUrlExit(String url) {
List<TBaseButton> urllist = this.tBaseButtonDao.queryAll(new Criterion[]{Restrictions.eq("operatename", url)});
return urllist.size() > 0 ? "0" : "1";
}
public List<TBaseButton> queryButtonCRUDByRoleids(List<TBaseRole> roleids) {
List<String> roles = new ArrayList();
for(TBaseRole role : roleids) {
roles.add(role.getId());
}
return this.tBaseButtonDao.queryButtonCRUDByRoleids(roles);
}
public List<TBaseButton> queryButtonNotCRUDByRoleids(List<TBaseRole> roleids) {
List<String> roles = new ArrayList();
for(TBaseRole role : roleids) {
roles.add(role.getId());
}
return this.tBaseButtonDao.queryButtonNotCRUDByRoleids(roles);
}
}
package com.chenyang.nse.bussiness.service.key.impl;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.chenyang.nse.bussiness.ccore.CcoreSDF;
import org.apache.commons.lang3.StringUtils;
public class CcoreSdfParam {
static long ret = 0L;
static long[] phDeviceHandle = new long[1];
static long[] phSessionHandle = new long[1];
public static Map<String, String> createParam(String pucPassword) {
HashMap<String, String> map = new HashMap(16);
System.out.println("\n///////// OpenDevice /////////");
ret = CcoreSDF.OpenDevice(phDeviceHandle);
if (ret != 0L) {
System.out.printf("OpenDevice error ret = 0x%08x ", ret);
return null;
} else {
System.out.println("OpenDevice phDeviceHandle = " + phDeviceHandle[0]);
System.out.println("\n///////// OpenSession /////////");
ret = CcoreSDF.OpenSession(phDeviceHandle[0], phSessionHandle);
if (ret != 0L) {
System.out.printf("OpenSession error ret = 0x%08x ", ret);
return null;
} else {
System.out.println("OpenSession phSessionHandle = " + phSessionHandle[0]);
System.out.println("\n///////// GenerateRandom /////////");
byte[] pucRandom = new byte[16];
System.out.println("开始生成第1次秘钥明文:");
ret = CcoreSDF.GenerateRandom(phSessionHandle[0], 16L, pucRandom);
if (ret != 0L) {
System.out.printf("GenerateRandom error ret = 0x%08x ", ret);
return null;
} else {
System.out.println("pucRandom:");
for(byte b : pucRandom) {
System.out.printf("%02x ", b);
}
System.out.printf("\n\n");
System.out.println("第1次秘钥明文生成结束。\n\n");
long[] phKeyHandle = new long[1];
System.out.println("\n///////// GenerateKeyWithIPK_ECC /////////");
CcoreSDF.ECCCipher pucKeyCPECC = new CcoreSDF.ECCCipher();
pucKeyCPECC.C = new byte[128];
ret = CcoreSDF.GenerateKeyWithIPK_ECC(phSessionHandle[0], 1L, 128L, pucKeyCPECC, phKeyHandle);
if (ret != 0L) {
System.out.printf("GenerateKeyWithIPK_ECC error ret = 0x%08x ", ret);
return null;
} else {
System.out.println(" GenerateKeyWithIPK_ECC pucKeyCPECC.x:");
for(byte b : pucKeyCPECC.x) {
System.out.printf("%02x ", b);
}
System.out.printf("\r\n");
String pucKeyCPECCX = Arrays.toString(pucKeyCPECC.x);
System.out.println(" 打印GenerateKeyWithIPK_ECC pucKeyCPECC.x:" + pucKeyCPECCX);
System.out.printf("\r\n");
System.out.println("\n GenerateKeyWithIPK_ECC pucKeyCPECC.y:");
for(byte b : pucKeyCPECC.y) {
System.out.printf("%02x ", b);
}
System.out.printf("\r\n");
String pucKeyCPECCY = Arrays.toString(pucKeyCPECC.y);
System.out.println(" 打印GenerateKeyWithIPK_ECC pucKeyCPECC.y:" + pucKeyCPECCY);
System.out.printf("\r\n");
System.out.println(" GenerateKeyWithIPK_ECC pucKeyCPECC.M:");
for(byte b : pucKeyCPECC.M) {
System.out.printf("%02x ", b);
}
System.out.printf("\r\n");
String pucKeyCPECCM = Arrays.toString(pucKeyCPECC.M);
System.out.println(" 打印GenerateKeyWithIPK_ECC pucKeyCPECC.m:" + pucKeyCPECCM);
System.out.printf("\r\n");
System.out.printf("\n GenerateKeyWithIPK_ECC pucKeyCPECC.L:%d\n", pucKeyCPECC.L);
System.out.printf("\r\n");
System.out.println("\n GenerateKeyWithIPK_ECC pucKeyCPECC.C:");
for(byte b : pucKeyCPECC.C) {
System.out.printf("%02x ", b);
}
System.out.printf("\r\n");
String pucKeyCPECCC = Arrays.toString(pucKeyCPECC.C);
System.out.println(" 打印GenerateKeyWithIPK_ECC pucKeyCPECC.C:" + pucKeyCPECCC);
System.out.println("\nGenerateKeyWithIPK_ECC phKeyHandle = " + phKeyHandle[0]);
ret = CcoreSDF.GetPrivateKeyAccessRight(phSessionHandle[0], 1L, StringUtils.isEmpty(pucPassword) ? "11111111" : pucPassword, 8L);
if (ret != 0L) {
System.out.printf("eeGetPrivateKeyAccessRight error ret = 0x%08x ", ret);
return null;
} else {
System.out.println("\n///////// ImportKeyWithISK_ECC /////////");
ret = CcoreSDF.ImportKeyWithISK_ECC(phSessionHandle[0], 1L, pucKeyCPECC, phKeyHandle);
if (ret != 0L) {
System.out.printf("ImportKeyWithISK_ECC error ret = 0x%08x ", ret);
return null;
} else {
System.out.println("\nImportKeyWithISK_ECC phKeyHandle = " + phKeyHandle[0]);
map.put("ecccipherbits", "0L");
map.put("ecccipherx", pucKeyCPECCX.replace("[", "").replace("]", ""));
map.put("eccciphery", pucKeyCPECCY.replace("[", "").replace("]", ""));
map.put("ecccipherm", pucKeyCPECCM.replace("[", "").replace("]", ""));
map.put("ecccipherc", pucKeyCPECCC.replace("[", "").replace("]", ""));
map.put("ecccipherl", String.valueOf(pucKeyCPECC.L));
CcoreSDF.CloseSession(phSessionHandle[0]);
return map;
}
}
}
}
}
}
}
public static boolean testCcoreSDF() {
System.out.println("\n///////// OpenDevice /////////");
ret = CcoreSDF.OpenDevice(phDeviceHandle);
if (ret != 0L) {
System.out.printf("OpenDevice error ret = 0x%08x ", ret);
return false;
} else {
System.out.println("OpenDevice phDeviceHandle = " + phDeviceHandle[0]);
System.out.println("\n///////// OpenSession /////////");
ret = CcoreSDF.OpenSession(phDeviceHandle[0], phSessionHandle);
if (ret != 0L) {
System.out.printf("OpenSession error ret = 0x%08x ", ret);
return false;
} else {
System.out.println("OpenSession phSessionHandle = " + phSessionHandle[0]);
System.out.println("\n///////// GenerateRandom /////////");
byte[] pucRandom = new byte[16];
System.out.println("开始生成第1次秘钥明文:");
ret = CcoreSDF.GenerateRandom(phSessionHandle[0], 16L, pucRandom);
if (ret != 0L) {
System.out.printf("GenerateRandom error ret = 0x%08x ", ret);
return false;
} else {
CcoreSDF.CloseSession(phSessionHandle[0]);
return true;
}
}
}
}
}
package com.chenyang.nse.bussiness.tools.dmp;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class ChannelFileReader {
private FileInputStream fileIn;
private ByteBuffer byteBuf;
private long fileLength;
private int arraySize;
private byte[] array;
public ChannelFileReader(String fileName, int arraySize) throws IOException {
this.fileIn = new FileInputStream(fileName);
this.fileLength = this.fileIn.getChannel().size();
this.arraySize = arraySize;
this.byteBuf = ByteBuffer.allocate(arraySize);
}
public int read() throws IOException {
FileChannel fileChannel = this.fileIn.getChannel();
int bytes = fileChannel.read(this.byteBuf);
if (bytes != -1) {
this.array = new byte[bytes];
this.byteBuf.flip();
this.byteBuf.get(this.array);
this.byteBuf.clear();
return bytes;
} else {
return -1;
}
}
public void close() throws IOException {
this.fileIn.close();
this.array = null;
}
public byte[] getArray() {
return this.array;
}
public long getFileLength() {
return this.fileLength;
}
public static void main(String[] args) throws IOException {
ChannelFileReader reader = new ChannelFileReader("/home/zfh/movie.mkv", 65536);
long start = System.nanoTime();
while(reader.read() != -1) {
}
long end = System.nanoTime();
reader.close();
System.out.println("ChannelFileReader: " + (end - start));
}
}
package com.chenyang.nse.bussiness.tools.redis;
import java.util.HashMap;
import java.util.Map;
public class CacheUtil {
public static Map<String, Object> cacheManager = new HashMap();
public static void put(String key, Object value) {
cacheManager.put(key, value);
}
public static Object getCacheValue(String key) {
return cacheManager.get(key);
}
public static void delCacheValue(String key) {
cacheManager.remove(key);
}
}
package com.chenyang.nse.bussiness.webtools.tools.redis;
import cn.hutool.core.util.ObjectUtil;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Component;
@Component("webtoolsCacheUtil")
public class CacheUtil {
public static Map<String, Object> cacheManager = new HashMap();
public static void put(String key, Object value) {
cacheManager.put(key, value);
}
public static Object getCacheValue(String key) {
return cacheManager.get(key);
}
public static void delCacheValue(String key) {
cacheManager.remove(key);
}
public static boolean exists(final String key) {
return !ObjectUtil.isEmpty(getCacheValue(key));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sql>
<select id="getDistinctMenuid">
select DISTINCT menuid from t_base_button
</select>
</sql>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论