|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.wlyy.service.app.talk;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@ -7,6 +8,10 @@ import java.util.*;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -19,6 +24,7 @@ import com.yihu.wlyy.entity.discussion.WlyyTalkGroupMember;
|
|
|
import com.yihu.wlyy.repository.discussion.DiscussionGroupDao;
|
|
|
import com.yihu.wlyy.repository.discussion.DiscussionGroupMemberDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
@ -32,6 +38,8 @@ public class TalkGroupService extends BaseService {
|
|
|
DiscussionGroupMemberDao discussionGroupMemberDao;
|
|
|
@Autowired
|
|
|
JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
DoctorDao doctorDao;
|
|
|
|
|
|
/**
|
|
|
* 讨论组保存
|
|
@ -49,7 +57,7 @@ public class TalkGroupService extends BaseService {
|
|
|
*
|
|
|
* @param members
|
|
|
*/
|
|
|
public void saveMembers(List<WlyyTalkGroupMember> members){
|
|
|
public void saveMembers(List<WlyyTalkGroupMember> members) {
|
|
|
discussionGroupMemberDao.save(members);
|
|
|
}
|
|
|
|
|
@ -191,22 +199,22 @@ public class TalkGroupService extends BaseService {
|
|
|
* @param groups
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> getTalkGroupsSing(String[] groups){
|
|
|
String params = "";
|
|
|
public List<Map<String, Object>> getTalkGroupsSing(String[] groups) {
|
|
|
String params = "";
|
|
|
List<String> paramList = new ArrayList<>();
|
|
|
|
|
|
for(int i = 0; i < groups.length ; i++){
|
|
|
params += (i == 0?"?":",?");
|
|
|
for (int i = 0; i < groups.length; i++) {
|
|
|
params += (i == 0 ? "?" : ",?");
|
|
|
}
|
|
|
paramList.addAll(Arrays.asList(groups));
|
|
|
paramList.addAll(Arrays.asList(groups));
|
|
|
|
|
|
String sqlgp = "select group_code,member_code from wlyy_talk_group_member where group_code in (" + params + ") and type = 2";
|
|
|
String sqlgpm = "select member_code from wlyy_talk_group_member where group_code in (" + params + ") and type = 2";
|
|
|
String sqlQu = "select * from wlyy_quota_result where qkdoctor_code in (" + sqlgpm+ ") and quato_code = '1' and level1_type = '1'";
|
|
|
String sqlQuSum = "select a.group_code,sum(ifnull(b.result,0)) sign from ("+ sqlgp +") a left join (" + sqlQu+ ") b on a.member_code = b.qkdoctor_code group by a.group_code ";
|
|
|
String sqlQu = "select * from wlyy_quota_result where qkdoctor_code in (" + sqlgpm + ") and quato_code = '1' and level1_type = '1'";
|
|
|
String sqlQuSum = "select a.group_code,sum(ifnull(b.result,0)) sign from (" + sqlgp + ") a left join (" + sqlQu + ") b on a.member_code = b.qkdoctor_code group by a.group_code ";
|
|
|
|
|
|
return jdbcTemplate.queryForList(sqlQuSum,paramList.toArray());
|
|
|
return jdbcTemplate.queryForList(sqlQuSum, paramList.toArray());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -225,7 +233,7 @@ public class TalkGroupService extends BaseService {
|
|
|
* @param groupCode
|
|
|
* @return
|
|
|
*/
|
|
|
public WlyyTalkGroup findTalkGroup(String groupCode){
|
|
|
public WlyyTalkGroup findTalkGroup(String groupCode) {
|
|
|
return discussionGroupDao.findByCode(groupCode);
|
|
|
}
|
|
|
|
|
@ -279,12 +287,12 @@ public class TalkGroupService extends BaseService {
|
|
|
List<WlyyTalkGroup> result = new ArrayList<>();
|
|
|
//查询语句
|
|
|
String sqlIn = " select tg.* from wlyy_talk_group tg where tg.code in ("
|
|
|
+ " select tgm.group_code "
|
|
|
+ " from "
|
|
|
+ " (select * from wlyy_talk_group_member where member_code = ?) tgm "
|
|
|
+ " inner join "
|
|
|
+ " (select * from wlyy_talk_group_member where member_code = ?) tgmm "
|
|
|
+ " on tgm.group_code = tgmm.group_code )";
|
|
|
+ " select tgm.group_code "
|
|
|
+ " from "
|
|
|
+ " (select * from wlyy_talk_group_member where member_code = ?) tgm "
|
|
|
+ " inner join "
|
|
|
+ " (select * from wlyy_talk_group_member where member_code = ?) tgmm "
|
|
|
+ " on tgm.group_code = tgmm.group_code )";
|
|
|
//查询
|
|
|
result = jdbcTemplate.query(sqlIn, new Object[]{memberFirst, memberSencond}, new RowMapper<WlyyTalkGroup>() {
|
|
|
@Override
|
|
@ -316,8 +324,54 @@ public class TalkGroupService extends BaseService {
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public long getDoctorTalkGroupCount(String doctor){
|
|
|
public long getDoctorTalkGroupCount(String doctor) {
|
|
|
return discussionGroupMemberDao.countByMemberCode(doctor);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取以上一对一聊天
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getOneToOneIm(String doctor) throws UnsupportedEncodingException {
|
|
|
JSONArray result = null;
|
|
|
JSONArray resultArray = new JSONArray();
|
|
|
String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
|
|
|
+ "statistic/getchatlist.im";
|
|
|
String json = HttpUtil.sendGet(url, "uid=" + doctor);
|
|
|
if(!StringUtils.isEmpty(json)) {
|
|
|
result = new JSONArray(json);
|
|
|
}
|
|
|
|
|
|
if (result != null && result.length() > 0) {
|
|
|
for (int i = 0; i < result.length(); i++) {
|
|
|
JSONObject obj = result.getJSONObject(i);
|
|
|
if (obj.getInt("msg_type") == 1) {
|
|
|
JSONObject objRe = new JSONObject();
|
|
|
Doctor fromDoctor = doctorDao.findByCode(obj.getString("peer_uid"));
|
|
|
|
|
|
if(fromDoctor == null){
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
objRe.put("uid",obj.getString("uid"));
|
|
|
objRe.put("fromUid",obj.getString("peer_uid"));
|
|
|
objRe.put("fromName",fromDoctor.getName());
|
|
|
objRe.put("fromLevel",fromDoctor.getLevel());
|
|
|
objRe.put("lastContentType",obj.getInt("last_content_type"));
|
|
|
objRe.put("lastContent",new String(obj.getString("last_content").getBytes(),"utf-8"));
|
|
|
objRe.put("newMsgCount",obj.getInt("new_msg_count"));
|
|
|
objRe.put("lastMsgTime",obj.getLong("timestamp"));
|
|
|
|
|
|
resultArray.put(objRe);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resultArray;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|