Browse Source

Merge branch 'develop' of gitadmin/tuoheng_telecomumale into release

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
07eb514d31
16 changed files with 174 additions and 32 deletions
  1. +14
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/config/common/CommonConfig.java
  2. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java
  3. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/User.java
  4. +43
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/wx/WxRequest.java
  5. +9
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java
  6. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml
  7. +6
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml
  8. +6
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml
  9. +6
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml
  10. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml
  11. +1
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/WxController.java
  12. +5
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/User.java
  13. +0
    -8
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/wx/request/PubMessageRequest.java
  14. +23
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/AuthorizeStatusEnum.java
  15. +1
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/UserAuthorizeEnum.java
  16. +41
    -18
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java

+ 14
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/config/common/CommonConfig.java View File

@@ -48,6 +48,11 @@ public class CommonConfig {
*/
public static String airportURL;

/**
* 小程序地址
*/
public static String minprogramUrl;

/**
* 小程序 appId
*/
@@ -170,4 +175,13 @@ public class CommonConfig {
airportURL = url;
}

/**
* 小程序url
* @param url
*/
@Value("${tuoheng.minprogram-url}")
public void minprogramUrl(String url) {
minprogramUrl = url;
}

}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java View File

@@ -70,4 +70,9 @@ public interface SystemConstant {
*/
String API_AIRPORT_LOCATION = "/api/airportInterface/getLocationById";

/**
* 小程序消息推送
*/
String MESSAGE_PUSH = "//weiXin/send/message";

}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/User.java View File

@@ -232,4 +232,9 @@ public class User implements Serializable {
*/
private Integer dataPermission;

/**
* 微信授权标识 1:未授权 2授权
*/
private Integer authorize;

}

+ 43
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/wx/WxRequest.java View File

@@ -0,0 +1,43 @@
package com.tuoheng.admin.request.wx;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* @Author ChengWang
* @Date 2023/6/26
*/
@Data
public class WxRequest {


/**
* 任务id
*/
private String inspectionId;

/**
* 问题id
*/
private String questionId;

/**
* 上报时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private String createTime;

/**
*问题标题
*/
private String InspectionName;

/**
* 问题描述
*/
private String questionDesc;
}

+ 9
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java View File

@@ -26,11 +26,11 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.*;
import java.util.stream.Collectors;

/**
@@ -79,6 +79,9 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
@Autowired
private DeliverStreamingService deliverStreamingService;

@Autowired
private RestTemplate restTemplate;

/**
* 保存DSP回调数据
*
@@ -298,6 +301,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
log.info("调用saveAccidentData方法保存应急记录数据...");
Boolean result = this.saveAccidentData(thirstyQuestionFiles);
log.info("预警数据入库完成,result={}",result);

}
//释放通道
if (4 == inspection.getAnalyseStatus() || 5 == inspection.getAnalyseStatus() || 6 == inspection.getAnalyseStatus()) {
@@ -313,6 +317,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
return JsonResult.success();
}


/**
* 应急记录数据入库
*

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml View File

@@ -158,6 +158,8 @@ tuoheng:
pilot-url: http://192.168.11.11:7011/pilot/web/
#airport配置地址
airport-url: http://192.168.11.22:9060
#微信小程序地址
minprogram-url: http://192.168.11.11:9151
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -166,6 +168,11 @@ tuoheng:
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_telecomumale/uploads/
#城管小程序
wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:

+ 6
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml View File

@@ -170,6 +170,8 @@ tuoheng:
pilot-url: http://192.168.11.241:7011/pilot/web/
#airport配置地址
airport-url: http://192.168.11.22:9060
#微信小程序地址
minprogram-url: https://telecomumale-miniprogram-test.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -178,6 +180,10 @@ tuoheng:
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_telecomumale/uploads/
wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:

+ 6
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml View File

@@ -159,6 +159,8 @@ tuoheng:
pilot-url: https://pilot.t-aaron.com/pilot/web/
#airport配置地址
airport-url: https://airport.t-aaron.com
#微信小程序地址
minprogram-url: https://telecomumale-miniprogram.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -167,6 +169,10 @@ tuoheng:
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_telecomumale/uploads/
wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:

+ 6
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml View File

@@ -159,6 +159,8 @@ tuoheng:
pilot-url: http://172.15.1.11:7011/pilot/web/
#airport配置地址
airport-url: https://airport-test.t-aaron.com
#微信小程序地址
minprogram-url: https://telecomumale-miniprogram-test.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -167,6 +169,10 @@ tuoheng:
staticAccessPath: /**
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_telecomumale/uploads/
wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml View File

@@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="salt" column="salt" />
<result property="intro" column="intro" />
<result property="status" column="status" />
<result property="authorize" column="authorize" />
<result property="note" column="note" />
<result property="sort" column="sort" />
<result property="loginNum" column="login_num" />
@@ -46,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

<sql id="selectUserVo">
id, tenant_id, code, realname, nickname, gender, avatar, mobile, email, birthday, dept_id, province_code, city_code, district_code, street_code, address, city_name,
username, password, driver_type, driver_code, salt, intro, status, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time,
username, password, driver_type, driver_code, salt, intro, status, authorize, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time,
role_id, data_permission, client_id, mark
</sql>


+ 1
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/WxController.java View File

@@ -1,6 +1,7 @@
package com.tuoheng.miniprogram.controller;

import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.miniprogram.dao.UserMapper;
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest;
import com.tuoheng.miniprogram.service.IWxService;
import lombok.extern.slf4j.Slf4j;

+ 5
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/User.java View File

@@ -236,4 +236,9 @@ public class User implements Serializable {
*/
private Integer dataPermission;

/**
* 微信授权标识 1:未授权 2授权
*/
private Integer authorize;

}

+ 0
- 8
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/wx/request/PubMessageRequest.java View File

@@ -1,8 +0,0 @@
package com.tuoheng.miniprogram.entity.wx.request;

/**
* @Author ChengWang
* @Date 2023/6/26
*/
public class PubMessageRequest {
}

+ 23
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/AuthorizeStatusEnum.java View File

@@ -0,0 +1,23 @@
package com.tuoheng.miniprogram.enums;

import lombok.Getter;

/**
* 任务状态枚举
*/
public enum AuthorizeStatusEnum {
//1未授权 2授权
AUTHORIZE_DOWN(1,"未授权"),
AUTHORIZE_ON(2,"授权");

AuthorizeStatusEnum(int code, String description){
this.code = code;
this.description = description;
}

@Getter
private int code;

@Getter
private String description;
}

+ 1
- 1
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/UserAuthorizeEnum.java View File

@@ -6,7 +6,7 @@ public enum UserAuthorizeEnum {
OPEN_ID_IS_NULL(10002, "openId为空");

/**
* 码
* 标识
*/
private Integer code;


+ 41
- 18
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java View File

@@ -9,11 +9,15 @@ import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import com.tuoheng.miniprogram.dao.UserAuthorizeMapper;
import com.tuoheng.miniprogram.dao.UserMapper;
import com.tuoheng.miniprogram.entity.User;
import com.tuoheng.miniprogram.entity.UserAuthorize;
import com.tuoheng.miniprogram.entity.dto.TemplateMinDto;
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest;
import com.tuoheng.miniprogram.enums.AuthorizeStatusEnum;
import com.tuoheng.miniprogram.enums.MarkEnum;
import com.tuoheng.miniprogram.enums.UserAuthorizeEnum;
import com.tuoheng.miniprogram.enums.UserCodeEnum;
import com.tuoheng.miniprogram.param.WxSendMessageParam;
import com.tuoheng.miniprogram.service.IWxService;
import com.tuoheng.miniprogram.utils.CurrentUserUtil;
@@ -40,6 +44,9 @@ public class WxServiceImpl implements IWxService {
@Autowired
private UserAuthorizeMapper userAuthorizeMapper;

@Autowired
private UserMapper userMapper;

private static String accessToken;

private static long expiresTime;
@@ -52,30 +59,46 @@ public class WxServiceImpl implements IWxService {
*/
@Override
public JsonResult openid(String code) {
String userId = CurrentUserUtil.getUserId();
String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret);
String openid = JSONObject.parseObject(openidResult).getString("openid");
String unionid = JSONObject.parseObject(openidResult).getString("unionid");
UserAuthorize userAuthorize = new UserAuthorize();
if(StringUtils.isNotEmpty(openid)){
//查询出来openId数据入库
userAuthorize.setOpenId(openid);
}else {
if(StringUtils.isEmpty(openid)){
log.error("获取openid失败:",openidResult);
return JsonResult.error("获取openid失败");
}
if(StringUtils.isNotEmpty(unionid)){
userAuthorize.setUnionId(unionid);
//根据当前登录用户id查询授权表是否存在一条授权数据
UserAuthorize beforeUserAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery()
.eq(UserAuthorize::getUserId, userId)
.eq(UserAuthorize::getMark, MarkEnum.VALID.getCode()));
if(ObjectUtil.isNull(beforeUserAuthorize)){
UserAuthorize userAuthorize = new UserAuthorize();
if(StringUtils.isNotEmpty(openid)){
//查询出来openId数据入库
userAuthorize.setOpenId(openid);
}
userAuthorize.setCreateTime(DateUtils.now());
if(StringUtils.isNotEmpty(userId)){
userAuthorize.setCreateUser(userId);
}
int result = userAuthorizeMapper.insert(userAuthorize);

if(result<=0){
return JsonResult.error("授权数据入库失败");
}
}
userAuthorize.setCreateTime(DateUtils.now());
if(StringUtils.isNotEmpty(CurrentUserUtil.getUserId())){
userAuthorize.setCreateUser(CurrentUserUtil.getUserId());
//关联登录用户,已经做过授权 修改授权标识
User user = CurrentUserUtil.getUserInfo();
if(ObjectUtil.isEmpty(user)){
return JsonResult.error(UserCodeEnum.USER_IS_NULL.getCode(),UserCodeEnum.USER_IS_NULL.getMsg());
}
int result = userAuthorizeMapper.insert(userAuthorize);
if(result<=0){
return JsonResult.error("授权数据入库失败");
user.setAuthorize(AuthorizeStatusEnum.AUTHORIZE_ON.getCode());
user.setUpdateTime(DateUtils.now());
user.setUpdateUser(userId);
int count = userMapper.updateById(user);
if(count <= 0){
return JsonResult.error("用户授权标识更新失败");
}
return JsonResult.success(openid);
return JsonResult.success();
}

/**
@@ -124,10 +147,10 @@ public class WxServiceImpl implements IWxService {
.eq(UserAuthorize::getUserId, userId)
.eq(UserAuthorize::getMark, MarkEnum.VALID.getCode()));
if(ObjectUtil.isNull(userAuthorize)){
return JsonResult.success(UserAuthorizeEnum.UNAUTHORIZED.getCode(),UserAuthorizeEnum.UNAUTHORIZED.getMsg());
return JsonResult.error(UserAuthorizeEnum.UNAUTHORIZED.getCode(),UserAuthorizeEnum.UNAUTHORIZED.getMsg());
}
if(StringUtils.isEmpty(userAuthorize.getOpenId())){
return JsonResult.success(UserAuthorizeEnum.OPEN_ID_IS_NULL.getCode(),UserAuthorizeEnum.OPEN_ID_IS_NULL.getMsg());
return JsonResult.error(UserAuthorizeEnum.OPEN_ID_IS_NULL.getCode(),UserAuthorizeEnum.OPEN_ID_IS_NULL.getMsg());
}
String openId = userAuthorize.getOpenId();
RestTemplate restTemplate = new RestTemplate();

Loading…
Cancel
Save