|
|
|
@ -1,6 +1,12 @@
|
|
|
|
|
package com.weaver.seconddev.jcl.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
|
|
import com.weaver.ebuilder.datasource.api.conn.RecordDataSource;
|
|
|
|
|
import com.weaver.ebuilder.datasource.api.conn.WeaverConnection;
|
|
|
|
|
import com.weaver.ebuilder.form.client.entity.field.FieldsQueryDto;
|
|
|
|
|
import com.weaver.ebuilder.form.client.entity.field.ModuleField;
|
|
|
|
|
import com.weaver.ebuilder.form.client.service.emobile.IEtFormDatasetService;
|
|
|
|
|
import com.weaver.ebuilder.teams.etform.org.bean.EBSimpleEmployee;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.controller.EmployeeRelationController;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.service.EmployeeRelationService;
|
|
|
|
|
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
|
|
|
@ -10,6 +16,9 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.sql.CallableStatement;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.sql.Types;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -20,6 +29,8 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DatabaseUtils databaseUtils;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IEtFormDatasetService etFormDataSetService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -40,7 +51,6 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
|
|
|
|
|
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(rs);
|
|
|
|
|
log.error("queryLeaderPdByYear.recordList:{}", recordList);
|
|
|
|
@ -62,4 +72,60 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
|
|
|
|
|
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
|
|
|
|
|
log.error("updateEmployeeDjInfo.rs:{}", rs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getTableColumnsOfTableName(String tableSchema,String tableName) {
|
|
|
|
|
String sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS\n" +
|
|
|
|
|
"WHERE TABLE_SCHEMA = '" + tableSchema + "' AND TABLE_NAME = '" + tableName + "' ";
|
|
|
|
|
log.error("getTableColumnsOfTableName.sql:{}", sql);
|
|
|
|
|
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
|
|
|
|
|
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(rs);
|
|
|
|
|
log.error("getTableColumnsOfTableName.recordList:{}", recordList);
|
|
|
|
|
return recordList;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public List<ModuleField> getTableColumns(String tableName) {
|
|
|
|
|
//todo (500报错)
|
|
|
|
|
Long aLong = Long.valueOf(tableName);
|
|
|
|
|
FieldsQueryDto fieldsQueryDto = new FieldsQueryDto();
|
|
|
|
|
fieldsQueryDto.setObjId(aLong);
|
|
|
|
|
EBSimpleEmployee employee = new EBSimpleEmployee();
|
|
|
|
|
employee.setEmployeeId("1081920975146483713");
|
|
|
|
|
employee.setTenantKey("t7n9jpeaoa");
|
|
|
|
|
fieldsQueryDto.setEbSimpleEmployee(employee);
|
|
|
|
|
List<ModuleField> fields = etFormDataSetService.getFields(fieldsQueryDto);
|
|
|
|
|
log.error("getTableColumns.fields:{}", fields);
|
|
|
|
|
return fields;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GetTableAlterStatements() {
|
|
|
|
|
//1.获取连接池实例
|
|
|
|
|
com.weaver.ebuilder.datasource.api.conn.ConnectionPool pool = com.weaver.ebuilder.datasource.api.conn.ConnectionPool.getInstanse();
|
|
|
|
|
log.error("GetTableAlterStatements.pool:{}", pool);
|
|
|
|
|
//2.从连接池获取WeaverConnection对象
|
|
|
|
|
WeaverConnection conn = pool.getConnection(3L);
|
|
|
|
|
log.error("GetTableAlterStatements.conn:{}", conn);
|
|
|
|
|
String dbtype = pool.getDbtype();
|
|
|
|
|
log.error("GetTableAlterStatements.dbtype:{}", dbtype);
|
|
|
|
|
try {
|
|
|
|
|
//3.调用存储过程(需声明两个OUT参数:flag和msg)
|
|
|
|
|
CallableStatement cstmt = conn.prepareCall("{call存储过程名(?, ?, ?, ?, ?)}");
|
|
|
|
|
log.error("GetTableAlterStatements.cstmt:{}", cstmt);
|
|
|
|
|
//输入参数设置 cstmt.setString(1, "参数值");
|
|
|
|
|
cstmt.registerOutParameter(2, Types.INTEGER); // flag OUT cstmt.registerOutParameter(3, Types.VARCHAR); // msg OUT //执行存储过程 cstmt.execute();
|
|
|
|
|
//获取输出参数 int flag = cstmt.getInt(2);
|
|
|
|
|
String msg = cstmt.getString(3);
|
|
|
|
|
if("mysql".equals(dbtype)){
|
|
|
|
|
//.....
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("存储过程调用异常", e);
|
|
|
|
|
} finally {
|
|
|
|
|
//4.释放连接(必须显式释放)
|
|
|
|
|
if (conn != null) {
|
|
|
|
|
pool.releaseConnection(3L, conn); //归还到连接池 }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|