@ -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,31 +29,32 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
@Autowired
private DatabaseUtils databaseUtils ;
@Autowired
private IEtFormDatasetService etFormDataSetService ;
@Override
public boolean checkIsNotBlackList ( String userName , String mobile , String email , String identity ) {
boolean flag = false ;
String sql = "" ;
if ( StringUtils . isNotBlank ( identity ) ) {
sql = "select id from uf_jcl_ryhmd where zjhm = '" + identity + "' and IS_DELETE = 0 and delete_type = 0 and TENANT_KEY = 't7n9jpeaoa' " ;
log . error ( "queryLeaderPdByYear.sql:{}" , sql ) ;
} else {
if ( StringUtils . isNotBlank ( userName ) ) {
if ( StringUtils . isNotBlank ( mobile ) ) {
sql = "select id from uf_jcl_ryhmd where xm = '" + userName + "' and lxdh = '" + mobile + "' and IS_DELETE = 0 and delete_type = 0 and TENANT_KEY = 't7n9jpeaoa' " ;
log . error ( "queryLeaderPdByYear.sql:{}" , sql ) ;
} else {
sql = "select id from uf_jcl_ryhmd where xm = '" + userName + "' and yx = '" + email + "' and IS_DELETE = 0 and delete_type = 0 and TENANT_KEY = 't7n9jpeaoa' " ;
log . error ( "queryLeaderPdByYear.sql:{}" , sql ) ;
boolean flag = false ;
String sql = "" ;
if ( StringUtils . isNotBlank ( identity ) ) {
sql = "select id from uf_jcl_ryhmd where zjhm = '" + identity + "' and IS_DELETE = 0 and delete_type = 0 and TENANT_KEY = 't7n9jpeaoa' " ;
log . error ( "queryLeaderPdByYear.sql:{}" , sql ) ;
} else {
if ( StringUtils . isNotBlank ( userName ) ) {
if ( StringUtils . isNotBlank ( mobile ) ) {
sql = "select id from uf_jcl_ryhmd where xm = '" + userName + "' and lxdh = '" + mobile + "' and IS_DELETE = 0 and delete_type = 0 and TENANT_KEY = 't7n9jpeaoa' " ;
log . error ( "queryLeaderPdByYear.sql:{}" , sql ) ;
} else {
sql = "select id from uf_jcl_ryhmd where xm = '" + userName + "' and yx = '" + email + "' and IS_DELETE = 0 and delete_type = 0 and TENANT_KEY = 't7n9jpeaoa' " ;
log . error ( "queryLeaderPdByYear.sql:{}" , sql ) ;
}
}
}
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 ) ;
if ( CollectionUtils . isNotEmpty ( recordList ) ) {
log . error ( "queryLeaderPdByYear.recordList:{}" , recordList ) ;
if ( CollectionUtils . isNotEmpty ( recordList ) ) {
flag = true ;
}
return flag ;
@ -56,10 +66,66 @@ public class EmployeeRelationServiceImpl implements EmployeeRelationService {
String xm = String . valueOf ( map . get ( "xm" ) ) ;
String df = String . valueOf ( map . get ( "df" ) ) ;
String dj = String . valueOf ( map . get ( "dj" ) ) ;
log . error ( "updateLeaderDaInfo.map:{}" , map ) ;
String sql = "update uf_jcl_gbkhba set ndzhjxkhdf = '" + df + "',ndzhjxkhdj ='" + dj + "' where nd = '" + khny . substring ( 0 , 4 ) + "' and bkhr = '" + xm + "' " ;
log . error ( "updateLeaderDaInfo.sql:{}" , sql ) ;
log . error ( "updateLeaderDaInfo.map:{}" , map ) ;
String sql = "update uf_jcl_gbkhba set ndzhjxkhdf = '" + df + "',ndzhjxkhdj ='" + dj + "' where nd = '" + khny . substring ( 0 , 4 ) + "' and bkhr = '" + xm + "' " ;
log . error ( "updateLeaderDaInfo.sql:{}" , sql ) ;
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 ) ;
log . error ( "updateEmployeeDjInfo.rs:{}" , rs ) ;
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 ) ; //归还到连接池 }
}
}
}
}