Commit 0849373c by 徐高华

企微托管

parent 377f8a69
...@@ -122,5 +122,11 @@ public interface HaobanTimerApiService { ...@@ -122,5 +122,11 @@ public interface HaobanTimerApiService {
public void halfTimer(String wxEnterpriseId) ; public void halfTimer(String wxEnterpriseId) ;
/**
* 校验是否登录中
* @param params
*/
void openStaffTimer(String params) ;
} }
package com.gic.haoban.manage.service.dao.mapper; package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.api.dto.OpenStaffDTO;
import com.gic.haoban.manage.api.dto.OpenStaffListDTO; import com.gic.haoban.manage.api.dto.OpenStaffListDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO; import com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO;
...@@ -48,11 +46,14 @@ public interface OpenStaffMapper { ...@@ -48,11 +46,14 @@ public interface OpenStaffMapper {
List<StaffClerkRelationDTO> listOpenStaffByStore(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId, @Param("list")List<String> storeIdList); List<StaffClerkRelationDTO> listOpenStaffByStore(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId, @Param("list")List<String> storeIdList);
List<String> listAll(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId) ; List<TabOpenStaff> listAllOnline(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId) ;
List<String> listOpenStoreId(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId); List<String> listOpenStoreId(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId);
void updateStopTime(@Param("id") Long openStaffId, @Param("type") int type, @Param("time") int time); void updateStopTime(@Param("id") Long openStaffId, @Param("type") int type, @Param("time") int time);
int getNum(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId , @Param("status")int status) ; int getNum(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId")String enterpriseId , @Param("status")int status) ;
int updateByAutoLogin(@Param("id") Long openStaffId ,@Param("uuid") String uuid) ;
} }
\ No newline at end of file
...@@ -4,6 +4,8 @@ import java.io.Serializable; ...@@ -4,6 +4,8 @@ import java.io.Serializable;
public class QwOpenResultInitBO implements Serializable { public class QwOpenResultInitBO implements Serializable {
private boolean is_login ;
private String uuid ; private String uuid ;
private String qrcode ; private String qrcode ;
...@@ -12,6 +14,14 @@ public class QwOpenResultInitBO implements Serializable { ...@@ -12,6 +14,14 @@ public class QwOpenResultInitBO implements Serializable {
private String qrcode_data ; private String qrcode_data ;
public boolean isIs_login() {
return is_login;
}
public void setIs_login(boolean is_login) {
this.is_login = is_login;
}
public String getQrcode_data() { public String getQrcode_data() {
return qrcode_data; return qrcode_data;
} }
......
...@@ -20,4 +20,14 @@ public interface OpenStaffService { ...@@ -20,4 +20,14 @@ public interface OpenStaffService {
ServiceResponse<Page<OpenStaffListDTO>> page(OpenStaffPageQDTO qdto, BasePageInfo basePageInfo); ServiceResponse<Page<OpenStaffListDTO>> page(OpenStaffPageQDTO qdto, BasePageInfo basePageInfo);
List<String> listAllStaffId(String wxEnterpriseId) ; List<String> listAllStaffId(String wxEnterpriseId) ;
/**
* 自动登录 返回新的uuid
* @param openStaffId
* @param qwUserId
* @return
*/
String autoLogin(Long openStaffId , Long qwUserId) ;
void openStaffTimer();
} }
...@@ -7,7 +7,7 @@ import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMap ...@@ -7,7 +7,7 @@ import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMap
import com.gic.haoban.manage.service.dao.mapper.hm.WxUserAddLogMapper; import com.gic.haoban.manage.service.dao.mapper.hm.WxUserAddLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated; import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.hm.TabWxUserAddLog; import com.gic.haoban.manage.service.entity.hm.TabWxUserAddLog;
import com.gic.haoban.manage.service.service.QywxErrorLogService; import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.chat.GroupChatDataService; import com.gic.haoban.manage.service.service.chat.GroupChatDataService;
import com.gic.haoban.manage.service.util.DingUtils; import com.gic.haoban.manage.service.util.DingUtils;
import com.gic.haoban.manage.service.util.HBQwMonitorUtils; import com.gic.haoban.manage.service.util.HBQwMonitorUtils;
...@@ -16,16 +16,12 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -16,16 +16,12 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.joda.time.DateTime;
import org.redisson.api.RMap; import org.redisson.api.RMap;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.service.HaobanTimerApiService; import com.gic.haoban.manage.api.service.HaobanTimerApiService;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.ExternalMemberService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.chat.GroupChatService; import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService; import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService;
...@@ -56,6 +52,8 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService { ...@@ -56,6 +52,8 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
private WxUserAddLogMapper wxUserAddLogMapper ; private WxUserAddLogMapper wxUserAddLogMapper ;
@Autowired @Autowired
private HaobanCommonMQApiService haobanCommonMQApiService ; private HaobanCommonMQApiService haobanCommonMQApiService ;
@Autowired
private OpenStaffService openStaffService ;
@Override @Override
...@@ -178,4 +176,9 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService { ...@@ -178,4 +176,9 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
DingUtils.send("halfTimer告警,wxEnterpriseId="+wxEnterpriseId, null, false); DingUtils.send("halfTimer告警,wxEnterpriseId="+wxEnterpriseId, null, false);
log.info("结束单向数据={}",wxEnterpriseId); log.info("结束单向数据={}",wxEnterpriseId);
} }
@Override
public void openStaffTimer(String params) {
this.openStaffService.openStaffTimer() ;
}
} }
...@@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; ...@@ -30,6 +30,7 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 企微托管账号 * 企微托管账号
...@@ -200,6 +201,18 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService { ...@@ -200,6 +201,18 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
qwUserId = openStaff.getQwUserId(); qwUserId = openStaff.getQwUserId();
log.info("重新初始化"); log.info("重新初始化");
this.openStaffService.logout(openStaff.getUuid(), "重新初始化", 0, null); this.openStaffService.logout(openStaff.getUuid(), "重新初始化", 0, null);
// 自动登录
String newUuid = this.openStaffService.autoLogin(openStaff.getOpenStaffId(),openStaff.getQwUserId()) ;
if(null != newUuid) {
log.info("自动登录成功");
openStaff.setAuthTime(new Date());
openStaff.setStatusFlag(1);
openStaff.setUuid(newUuid);
openStaff.setLoginRemark("自动登录成功");
this.openStaffMapper.update(openStaff);
OpenStaffDTO dto = EntityUtil.changeEntityByJSON(OpenStaffDTO.class, openStaff);
return ServiceResponse.success(dto);
}
} }
if (null == openStaff) { if (null == openStaff) {
openStaff = new TabOpenStaff(); openStaff = new TabOpenStaff();
...@@ -207,7 +220,7 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService { ...@@ -207,7 +220,7 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
openStaff.setWxEnterpriseId(qdto.getWxEnterpriseId()); openStaff.setWxEnterpriseId(qdto.getWxEnterpriseId());
openStaff.setEnterpriseId(qdto.getEnterpriseId()); openStaff.setEnterpriseId(qdto.getEnterpriseId());
} }
ServiceResponse<QwOpenResultInitBO> resp = OpenUtils.init(qwUserId); ServiceResponse<QwOpenResultInitBO> resp = OpenUtils.init(qwUserId,true);
log.info("resp={}", JSONObject.toJSONString(resp)); log.info("resp={}", JSONObject.toJSONString(resp));
QwOpenResultInitBO init = resp.getResult(); QwOpenResultInitBO init = resp.getResult();
openStaff.setUuid(init.getUuid()); openStaff.setUuid(init.getUuid());
...@@ -276,13 +289,14 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService { ...@@ -276,13 +289,14 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
@Override @Override
public List<String> listAllOnlineStaff() { public List<String> listAllOnlineStaff() {
return this.openStaffMapper.listAll(null,null); return this.listAllOnlineStaff(null, null);
} }
@Override @Override
public List<String> listAllOnlineStaff(String wxEnterpriseId, String enterpriseId) { public List<String> listAllOnlineStaff(String wxEnterpriseId, String enterpriseId) {
return this.openStaffMapper.listAll(wxEnterpriseId,enterpriseId); List<TabOpenStaff> list = this.openStaffMapper.listAllOnline(wxEnterpriseId, enterpriseId);
return list.stream().map(o -> o.getStaffId()).collect(Collectors.toList());
} }
@Override @Override
......
...@@ -20,13 +20,13 @@ public class OpenUtils { ...@@ -20,13 +20,13 @@ public class OpenUtils {
private static final String openHost = "http://47.94.7.218:8089/wxwork/%s"; private static final String openHost = "http://47.94.7.218:8089/wxwork/%s";
public static ServiceResponse<QwOpenResultInitBO> init(Long qwUserId) { public static ServiceResponse<QwOpenResultInitBO> init(Long qwUserId, boolean qrcodeFlag) {
JSONObject initJson = new JSONObject(); JSONObject initJson = new JSONObject();
if (null != qwUserId) { if (null != qwUserId) {
initJson.put("vid", qwUserId); initJson.put("vid", qwUserId);
} }
String initStr = HttpClient.sendPostJSON(String.format(openHost, "init"), initJson.toJSONString(), "utf-8"); String initStr = HttpClient.sendPostJSON(String.format(openHost, "init"), initJson.toJSONString(), "utf-8");
logger.info("init={}", initStr); logger.info("企微初始化,req={},{}", initJson.toJSONString(), initStr);
QwOpenResultBO initResult = result(initStr); QwOpenResultBO initResult = result(initStr);
if (!initResult.isOk()) { if (!initResult.isOk()) {
return ServiceResponse.failure("9999", initResult.getErrmsg()); return ServiceResponse.failure("9999", initResult.getErrmsg());
...@@ -35,10 +35,16 @@ public class OpenUtils { ...@@ -35,10 +35,16 @@ public class OpenUtils {
String uuid = initBO.getUuid(); String uuid = initBO.getUuid();
// 设置回调 // 设置回调
setCallback(uuid); setCallback(uuid);
// 获取二维码 if (initBO.isIs_login()) {
ServiceResponse<QwOpenResultInitBO> response = getQrcode(uuid, initBO, 1); logger.info("客户端是登录中的={}", qwUserId);
if (!response.isSuccess()) { return ServiceResponse.success(initBO);
return response; }
if (qrcodeFlag) {
// 获取二维码
ServiceResponse<QwOpenResultInitBO> response = getQrcode(uuid, initBO, 1);
if (!response.isSuccess()) {
return response;
}
} }
return ServiceResponse.success(initBO); return ServiceResponse.success(initBO);
} }
...@@ -101,12 +107,31 @@ public class OpenUtils { ...@@ -101,12 +107,31 @@ public class OpenUtils {
} }
/** /**
* 自动登录
*
* @param uuid
*/
public static boolean autoLogin(String uuid) {
JSONObject json = new JSONObject();
json.put("uuid", uuid);
String backJson = HttpClient.sendPostJSON(String.format(openHost, "automaticLogin"), json.toJSONString(), "utf-8");
logger.info("自动登录={},uuid={}", backJson, uuid);
JSONObject resultJson = JSONObject.parseObject(backJson);
int errcode = resultJson.getIntValue("errcode");
if (errcode == 0) {
logger.info("自动登录成功={}");
return true;
}
return false;
}
/**
* 判断账号是否登录中 * 判断账号是否登录中
* *
* @param uuid * @param uuid
* @return * @return
*/ */
private static boolean isLogin(String uuid) { public static boolean isLogin(String uuid) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("uuid", uuid); json.put("uuid", uuid);
String backJson = HttpClient.sendPostJSON(String.format(openHost, "GetProfile"), json.toJSONString(), "utf-8"); String backJson = HttpClient.sendPostJSON(String.format(openHost, "GetProfile"), json.toJSONString(), "utf-8");
......
...@@ -111,6 +111,10 @@ ...@@ -111,6 +111,10 @@
where open_staff_id = #{id} where open_staff_id = #{id}
</update> </update>
<update id="updateByAutoLogin">
update tab_haoban_open_staff set uuid=#{uuid} , login_remark = '自动登录成功' where open_staff_id = #{id}
</update>
<delete id="deleteByPrimaryKey"> <delete id="deleteByPrimaryKey">
update tab_haoban_open_staff update tab_haoban_open_staff
set delete_flag = 1, set delete_flag = 1,
...@@ -229,8 +233,8 @@ ...@@ -229,8 +233,8 @@
and a.delete_flag = 0 and a.delete_flag = 0
</select> </select>
<select id="listAll" resultType="java.lang.String"> <select id="listAllOnline" resultMap="BaseResultMap">
select staff_id from tab_haoban_open_staff where select <include refid="Base_Column_List" /> from tab_haoban_open_staff where
status_flag = 1 and delete_flag = 0 status_flag = 1 and delete_flag = 0
<if test="null !=wxEnterpriseId"> <if test="null !=wxEnterpriseId">
and wx_enterprise_id = #{wxEnterpriseId} and wx_enterprise_id = #{wxEnterpriseId}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment