Browse Source

20220318LWBS

master
zy_Java 3 years ago
parent
commit
1d59bb9c73
  1. 7
      ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java
  2. 5
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/TaskDto.java
  3. 2
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/UserDto.java
  4. 2
      ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/WxOfficialDao.java
  5. 2
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java
  6. 2
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/TaskService.java
  7. 15
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java
  8. 4
      ptos_tall/src/main/java/com/ccsens/ptos_tall/util/PtOsConstant.java
  9. 4
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java
  10. 13
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java
  11. 2
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/Constant.java

7
ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java

@ -25,8 +25,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
/**
* @author
@ -48,9 +46,10 @@ public class WxUserController {
@ApiImplicitParams({
})
@RequestMapping(value="createQrCode",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
public JsonResponse<UserVo.AttentionOfficial> createQrCode(String equipmentId, String appId, String secret) {
public JsonResponse<UserVo.AttentionOfficial> createQrCode(String equipmentId, String appId, String secret,Byte type) {
type = type == null ? 0 : type;
log.info("生成二维码:{}",equipmentId);
UserVo.AttentionOfficial qrCodeUrl = wxUserService.createQrCode(equipmentId, appId, secret);
UserVo.AttentionOfficial qrCodeUrl = wxUserService.createQrCode(equipmentId, appId, secret, type);
return JsonResponse.newInstance().ok(qrCodeUrl);
}

5
ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/TaskDto.java

@ -31,6 +31,11 @@ public class TaskDto {
private Integer pageNum = 1;
@ApiModelProperty("每页几条信息")
private Integer pageSize = 10;
@ApiModelProperty("任务id")
private String taskId;
@ApiModelProperty("任务所属的服务code")
private String businessCode;
}
}

2
ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/UserDto.java

@ -73,6 +73,6 @@ public class UserDto {
@ApiModel("公众号的设备id")
public static class Official{
@ApiModelProperty("设备id")
private Long appId;
private String appId;
}
}

2
ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/WxOfficialDao.java

@ -25,5 +25,5 @@ public interface WxOfficialDao extends WxOfficialMapper {
* @param userId 用户ID
* @return 关注状态 则未关注
*/
UserVo.UserOfficial getUserOfficial(@Param("appId") Long appId, @Param("userId") Long userId);
UserVo.UserOfficial getUserOfficial(@Param("appId") String appId, @Param("userId") Long userId);
}

2
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java

@ -17,7 +17,7 @@ public interface IWxUserService {
* @param secret secret
* @return 返回二维码路径
*/
UserVo.AttentionOfficial createQrCode(String equipmentId, String appId, String secret);
UserVo.AttentionOfficial createQrCode(String equipmentId, String appId, String secret, Byte type);
/**
* 关注公众号并登录

2
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/TaskService.java

@ -79,6 +79,8 @@ public class TaskService implements ITaskService {
try {
JSONObject object1 = (JSONObject) object;
queryTask = object1.toJavaObject(TaskVo.QueryTask.class);
queryTask.setBusinessCode(business.getCode());
queryTask.setBusinessUrl(business.getUrl());
allTask.add(queryTask);
}catch (Exception e){
log.error("项目转换失败"+e);

15
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java

@ -12,8 +12,11 @@ import com.ccsens.ptos_tall.persist.dao.SysUserDao;
import com.ccsens.ptos_tall.persist.dao.WxOfficialDao;
import com.ccsens.ptos_tall.persist.mapper.WxOfficialUserMapper;
import com.ccsens.ptos_tall.util.PtOsConstant;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.RedisKeyManager;
import com.ccsens.util.RedisUtil;
import com.ccsens.util.WebConstant;
import com.ccsens.util.exception.BaseException;
import com.ccsens.wechatutil.bean.dto.wxmini.NoticeDto;
import com.ccsens.wechatutil.bean.dto.wxofficial.WxQrCodeDto;
import com.ccsens.wechatutil.bean.po.WxOauth2UserInfo;
@ -54,7 +57,7 @@ public class WxUserService implements IWxUserService {
private RedisUtil redisUtil;
@Override
public UserVo.AttentionOfficial createQrCode(String equipmentId, String appId, String secret) {
public UserVo.AttentionOfficial createQrCode(String equipmentId, String appId, String secret,Byte type) {
//如果设备id不为空则查找设备对应的公众号的信息
if(StrUtil.isNotBlank(equipmentId)){
//通过设备id查找公众号信息
@ -71,7 +74,7 @@ public class WxUserService implements IWxUserService {
}
//生成二维码
String eventKey = UUID.randomUUID().toString();
WxQrCodeVo.QrCodeUrl url = OfficialQrCodeUtil.send(new WxQrCodeDto.Create(7*24*60*60L, OfficialQrCodeUtil.QR_STR_SCENE,
WxQrCodeVo.QrCodeUrl url = OfficialQrCodeUtil.send(new WxQrCodeDto.Create(7*24*60*60L, type == 0 ? OfficialQrCodeUtil.QR_STR_SCENE : OfficialQrCodeUtil.QR_LIMIT_STR_SCENE,
null, eventKey), appId, secret);
String qrCodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + url.getTicket();
UserVo.AttentionOfficial attentionOfficial = new UserVo.AttentionOfficial();
@ -120,10 +123,16 @@ public class WxUserService implements IWxUserService {
tokenBean.setId(userSign.getUserId());
tokenBean.setPhone(userSign.getPhone());
tokenBean.setAvatarUrl(userSign.getAvatarUrl());
log.info("生成token成功");
//根据eventKey更新redis内的用户关注信息
String key = PtOsConstant.OFFICIAL_EVENT_KEY + notice.getEventKey();
String eventKey = notice.getEventKey();
if (notice.getEventKey().startsWith(PtOsConstant.EVENT_KEY_PREFIX)) {
eventKey = eventKey.substring(PtOsConstant.EVENT_KEY_PREFIX.length());
}
String key = PtOsConstant.OFFICIAL_EVENT_KEY + eventKey;
long seconds = 60L * 100L;
redisUtil.set(key,tokenBean,seconds);
log.info("存reids--key:{}",key);
break;
case "unsubscribe":
//用openId查找用户

4
ptos_tall/src/main/java/com/ccsens/ptos_tall/util/PtOsConstant.java

@ -17,8 +17,10 @@ public class PtOsConstant {
/**是否发送验证码 0不发送 1发送*/
public static final String SMS_CODE = "1";
/**公众号登录的eventKey*/
/**Redis--公众号登录的eventKey*/
public static final String OFFICIAL_EVENT_KEY = "Official_";
/**首次关注公众号回调的eventKey前缀*/
public static final String EVENT_KEY_PREFIX = "qrscene_";
/**默认公众号appId*/
public static final String DEFAULT_APP_ID = "wxb3be21dcd7912555";
/**默认公众号secret*/

4
tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java

@ -84,9 +84,9 @@ public class TaskController {
@ApiOperation(value = "查看用户所有的任务", notes = "")
@RequestMapping(value = "/allTask", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<TallTaskVo.QueryTask>> queryAllTask(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto<TallTaskDto.QueryAllTask> params) {
public JsonResponse<List<TallTaskVo.QueryTask>> queryAllTask(HttpServletRequest request, @ApiParam @Validated @RequestBody TallTaskDto.QueryAllTask params) {
log.info("查看用户所有的任务:{}",params);
List<TallTaskVo.QueryTask> queryTasks = tallService.queryAllTask(params.getParam());
List<TallTaskVo.QueryTask> queryTasks = tallService.queryAllTask(params);
log.info("返回用户所有的任务");
return JsonResponse.newInstance().ok(queryTasks);
}

13
tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java

@ -48,7 +48,7 @@ public class TallTaskDto {
@Data
@ApiModel("分期查看定期任务")
public static class PageQueryRegularTask{
@NotNull(message = "角色id不能为空")
// @NotNull(message = "角色id不能为空")
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("项目id")
@ -69,7 +69,9 @@ public class TallTaskDto {
@ApiModelProperty("任务所属的服务code")
private String businessCode;
@ApiModelProperty("触发类型 0翻页查找 1双击小红点触发")
private int triggerType = 1;
private int triggerType = 0;
@ApiModelProperty("服务codes")
private List<String> codes;
}
@Data
@ -79,7 +81,7 @@ public class TallTaskDto {
private Long userId;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("codes")
@ApiModelProperty("服务codes")
private List<String> codes;
@ApiModelProperty("时间基准点 默认当前")
private Long timeNode = System.currentTimeMillis();
@ -91,5 +93,10 @@ public class TallTaskDto {
private Integer pageNum = 1;
@ApiModelProperty("每页几条信息")
private Integer pageSize = 10;
@ApiModelProperty("任务id")
private String taskId;
@ApiModelProperty("任务所属的服务code")
private String businessCode;
}
}

2
tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/Constant.java

@ -8,6 +8,8 @@ public class Constant {
/**域内gateway请求前缀*/
public static final String GATEWAY_URL = "http://101.201.226.163/gateway/";
/**tall-查询所有任务的接口路径*/
public static final String QUERY_ALL_TASK = "ptostall/task/allTask";
/**tall-请求的用户信息的接口路径*/
public static final String TALL_USER_TOKEN = "ptostall/users/businessToken";
/**tall-获取accessToken*/

Loading…
Cancel
Save