@ -54,7 +54,7 @@ public class ChatDayUtils {
log . error ( "startDate:" + startDate ) ;
log . error ( "startDate:" + startDate ) ;
log . error ( "endDate:" + endDate ) ;
log . error ( "endDate:" + endDate ) ;
Long cid = employee . getCid ( ) ;
Long cid = employee . getCid ( ) ;
log . error ( " getChatGroup --cid:"+ cid ) ;
log . error ( " ChatDayUtils --cid:"+ cid ) ;
Long employeeId = employee . getEmployeeId ( ) ;
Long employeeId = employee . getEmployeeId ( ) ;
Map < String , Object > json = new HashMap < String , Object > ( ) ;
Map < String , Object > json = new HashMap < String , Object > ( ) ;
@ -66,6 +66,8 @@ public class ChatDayUtils {
log . error ( "json:" + JSON . toJSONString ( json ) ) ;
log . error ( "json:" + JSON . toJSONString ( json ) ) ;
dataMap . put ( "json" , JSON . toJSONString ( json ) ) ;
Request request = new Request ( ) ;
Request request = new Request ( ) ;
request . setUrl ( "/user-profile/dailySingleSession" ) ;
request . setUrl ( "/user-profile/dailySingleSession" ) ;
request . setParamsMap ( json ) ;
request . setParamsMap ( json ) ;
@ -73,9 +75,12 @@ public class ChatDayUtils {
log . error ( "request:" + request . toString ( ) ) ;
log . error ( "request:" + request . toString ( ) ) ;
Response response = oaRest . executeIm ( request ) ;
Response response = oaRest . executeIm ( request ) ;
log . error ( "getChat Group --isSuccess"+ response . isSuccess ( ) ) ;
log . error ( "getChat Day --isSuccess"+ response . isSuccess ( ) ) ;
if ( response . isSuccess ( ) ) {
if ( response . isSuccess ( ) ) {
dataMap . put ( "isSuccess" , "1" ) ;
String data = response . getData ( ) ;
String data = response . getData ( ) ;
dataMap . put ( "data" , data ) ;
if ( StringUtils . isNotBlank ( data ) ) {
if ( StringUtils . isNotBlank ( data ) ) {
JSONObject dataJson = JSONObject . parseObject ( data ) ;
JSONObject dataJson = JSONObject . parseObject ( data ) ;
JSONObject actionMsg = dataJson . getJSONObject ( "actionMsg" ) ;
JSONObject actionMsg = dataJson . getJSONObject ( "actionMsg" ) ;
@ -85,10 +90,14 @@ public class ChatDayUtils {
JSONObject dataObject = dataJson . getJSONObject ( "data" ) ;
JSONObject dataObject = dataJson . getJSONObject ( "data" ) ;
if ( dataObject . containsKey ( "data" ) ) {
if ( dataObject . containsKey ( "data" ) ) {
JSONArray dataArray = dataObject . getJSONArray ( "data" ) ;
JSONArray dataArray = dataObject . getJSONArray ( "data" ) ;
log . error ( "getChatDay--dataArray" + dataArray . size ( ) ) ;
for ( int i = 0 ; i < dataArray . size ( ) ; i + + ) {
for ( int i = 0 ; i < dataArray . size ( ) ; i + + ) {
JSONObject dataInfo = dataArray . getJSONObject ( i ) ;
JSONObject dataInfo = dataArray . getJSONObject ( i ) ;
String userid = dataInfo . getString ( "userid" ) ;
String userid = dataInfo . getString ( "userid" ) ;
String amount = dataInfo . getString ( "amount" ) ;
String amount = dataInfo . getString ( "amount" ) ;
log . error ( "getChatDay--userid" + userid + " amount:" + amount ) ;
String sql = " select id from " + tablename + " where ry=? and tenant_key=? and delete_type=0 " ;
String sql = " select id from " + tablename + " where ry=? and tenant_key=? and delete_type=0 " ;
List < SqlParamEntity > sqlparam = new ArrayList < SqlParamEntity > ( ) ;
List < SqlParamEntity > sqlparam = new ArrayList < SqlParamEntity > ( ) ;
@ -105,8 +114,10 @@ public class ChatDayUtils {
Map < String , Object > result = databaseUtils . executeForQuery ( sourceType , groupId , sql , sqlparam ) ;
Map < String , Object > result = databaseUtils . executeForQuery ( sourceType , groupId , sql , sqlparam ) ;
List < Map < String , Object > > recordList = databaseUtils . getDataSourceList ( result ) ;
List < Map < String , Object > > recordList = databaseUtils . getDataSourceList ( result ) ;
if ( ! recordList . isEmpty ( ) ) {
if ( ! recordList . isEmpty ( ) ) {
log . error ( "getChatDay--!isEmpty" ) ;
updateChatDayDate ( userid , amount , sourceType , groupId , tenant_key , tablename ) ;
updateChatDayDate ( userid , amount , sourceType , groupId , tenant_key , tablename ) ;
} else {
} else {
log . error ( "getChatDay--isEmpty" ) ;
insertChatDayDate ( userid , amount , employeeId , sourceType , groupId , tenant_key , tablename ) ;
insertChatDayDate ( userid , amount , employeeId , sourceType , groupId , tenant_key , tablename ) ;
}
}
}
}
@ -114,6 +125,8 @@ public class ChatDayUtils {
}
}
}
}
}
}
} else {
dataMap . put ( "isSuccess" , "0" ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
e . printStackTrace ( ) ;
@ -132,30 +145,23 @@ public class ChatDayUtils {
* @param tenant_key
* @param tenant_key
* /
* /
public void insertChatDayDate ( String userid , String amount , long employeeId , String sourceType , String groupId , String tenant_key , String tablename ) {
public void insertChatDayDate ( String userid , String amount , long employeeId , String sourceType , String groupId , String tenant_key , String tablename ) {
String code = "" ;
try {
try {
long generate = IdGenerator . generate ( ) ;
long generate = IdGenerator . generate ( ) ;
log . error ( "insertChatDayDate-generate:" + generate + " userid:" + userid + " amount" + amount + " employeeId:" + employeeId ) ;
String sql = " insert into " + tablename + "(id,ry,amount,form_data_id,data_index,create_time,update_time,tenant_key,is_delete,creator,delete_type) " +
String sql = " insert into " + tablename + "(id,ry,amount,form_data_id,data_index,create_time,update_time,tenant_key,is_delete,creator,delete_type) " +
" values (" + generate + "," + userid + ",'" + amount + "'," + generate + ",0,now(),now(),'" + tenant_key + "',0," + employeeId + ",0)" ;
" values (" + generate + "," + userid + ",'" + amount + "'," + generate + ",0,now(),now(),'" + tenant_key + "',0," + employeeId + ",0)" ;
log . error ( "insertChatDayDate-sql:" + sql ) ;
log . error ( "insertChatDayDate-sql:" + sql ) ;
Map < String , Object > result = databaseUtils . execute ( sourceType , groupId , sql ) ;
Map < String , Object > result = databaseUtils . execute ( sourceType , groupId , sql ) ;
if ( result . containsKey ( "code" ) ) {
Iterator < Map . Entry < String , Object > > iterator = result . entrySet ( ) . iterator ( ) ;
code = String . valueOf ( result . get ( "code" ) ) ;
while ( iterator . hasNext ( ) ) {
Map . Entry < String , Object > next = iterator . next ( ) ;
log . error ( "insertChatDayDate--key=" + next . getKey ( ) + " value=" + String . valueOf ( next . getValue ( ) ) ) ;
}
List < Map < String , Object > > recordList = databaseUtils . getDataSourceList ( result ) ;
for ( int i = 0 ; i < recordList . size ( ) ; i + + ) {
Map < String , Object > map = recordList . get ( i ) ;
for ( String key : map . keySet ( ) ) {
System . out . println ( "insertChatDayDate222--key= " + key + " and value= " + String . valueOf ( map . get ( key ) ) ) ;
}
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
e . printStackTrace ( ) ;
log . error ( "insertChatDayDate:" + e ) ;
log . error ( "insertChatDayDate:" + e ) ;
code = "-100" ;
}
}
}
}
@ -167,10 +173,11 @@ public class ChatDayUtils {
* @param groupId
* @param groupId
* @param tenant_key
* @param tenant_key
* /
* /
public void updateChatDayDate ( String userid , String amount , String sourceType , String groupId , String tenant_key , String tablename ) {
public String updateChatDayDate ( String userid , String amount , String sourceType , String groupId , String tenant_key , String tablename ) {
String code = "" ;
try {
try {
String sql = " update " + tablename + " set amount=?,update_time=now() where ry = ? and tenant_key= ? and delete_type=0 " ;
String sql = " update " + tablename + " set amount=?,update_time=now() where ry = ? and tenant_key= ? and delete_type=0 " ;
log . error ( "insertChatDayDate-sql:" + sql ) ;
log . error ( "insertChatDayDate-sql:" + sql + " amount:" + amount + " userid:" + userid ) ;
List < SqlParamEntity > sqlparam = new ArrayList < SqlParamEntity > ( ) ;
List < SqlParamEntity > sqlparam = new ArrayList < SqlParamEntity > ( ) ;
SqlParamEntity sqlParamEntity = new SqlParamEntity ( ) ;
SqlParamEntity sqlParamEntity = new SqlParamEntity ( ) ;
@ -189,23 +196,17 @@ public class ChatDayUtils {
sqlparam . add ( sqlParamEntity ) ;
sqlparam . add ( sqlParamEntity ) ;
Map < String , Object > result = databaseUtils . executeForQuery ( sourceType , groupId , sql , sqlparam ) ;
Map < String , Object > result = databaseUtils . executeForQuery ( sourceType , groupId , sql , sqlparam ) ;
Iterator < Map . Entry < String , Object > > iterator = result . entrySet ( ) . iterator ( ) ;
if ( result . containsKey ( "code" ) ) {
while ( iterator . hasNext ( ) ) {
code = String . valueOf ( result . get ( "code" ) ) ;
Map . Entry < String , Object > next = iterator . next ( ) ;
log . error ( "insertChatDayDate--key=" + next . getKey ( ) + " value=" + String . valueOf ( next . getValue ( ) ) ) ;
}
}
List < Map < String , Object > > recordList = databaseUtils . getDataSourceList ( result ) ;
for ( int i = 0 ; i < recordList . size ( ) ; i + + ) {
Map < String , Object > map = recordList . get ( i ) ;
for ( String key : map . keySet ( ) ) {
System . out . println ( "insertChatDayDate222--key= " + key + " and value= " + String . valueOf ( map . get ( key ) ) ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
e . printStackTrace ( ) ;
log . error ( "insertChatDayDate:" + e ) ;
log . error ( "insertChatDayDate:" + e ) ;
code = "-100" ;
}
}
return code ;
}
}
}
}