Переглянути джерело

新增任务发现第一条问题,推送微信通知代码

pull/381/head
wanjing 10 місяці тому
джерело
коміт
a1fda98826
8 змінених файлів з 116 додано та 10 видалено
  1. +1
    -2
      tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.6.sql
  2. +10
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java
  3. +22
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java
  4. +53
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/NoticeWeChatMiniProgramService.java
  5. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml
  6. +9
    -3
      tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml
  7. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml
  8. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml

+ 1
- 2
tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.6.sql Переглянути файл

@@ -16,8 +16,7 @@ create table th_user_authorize
update_user varchar(36) default '0' null comment '更新人',
update_time datetime null comment '更新时间',
mark tinyint unsigned default '1' not null comment '有效标识'
)
comment '用户授权表';
) comment '用户授权表';

-- 用户表
alter table tuoheng_freeway.th_user add authorize tinyint(1) default 1 not null comment '授权标识:1未授权 2授权' after status;

+ 10
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java Переглянути файл

@@ -15,14 +15,20 @@ public interface SystemConstant {
String PLATFORM_CODE = "gs";

/**
* 机场平台:获取航点文件坐标
* 高德url地址
*/
String API_AIRPORT_LOCATION = "/airportInterface/getLocationById";
String GAO_DE_URL = "https://restapi.amap.com/v3/geocode/regeo";

/**
* 高德url地址
* 推送微信消息
*/
String GAO_DE_URL = "https://restapi.amap.com/v3/geocode/regeo";
String API_WEIXIN_SEND_MESSAGE = "/telecomumale/miniprogram/weiXin/send/message";

/**
* 机场平台:获取航点文件坐标
*/
String API_AIRPORT_LOCATION = "/airportInterface/getLocationById";


/**
* 机场平台:获取机场列表接口

+ 22
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java Переглянути файл

@@ -1,5 +1,6 @@
package com.tuoheng.admin.service.third.dsp;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
@@ -62,6 +63,9 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
@Autowired
private IAccidentService accidentService;

@Autowired
private NoticeWeChatMiniProgramService noticeWeChatMiniProgramService;

/**
* 保存DSP回调数据
*
@@ -282,10 +286,27 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
return inspectionFile;
}).collect(Collectors.toList());

// 先判断是否第一次生成问题,通过问题表中是否有数据来判断
Integer count = inspectionFileMapper.selectCount(new LambdaQueryWrapper<InspectionFile>()
.eq(InspectionFile::getInspectionId, inspection.getId())
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode()));

Map<String, QuestionType> questionTypeMap = getStringQuestionTypeMap();

// 通知小程序
if (count <= 0) {
log.info("该任务第一次产生问题,通知小程序, inspectionId={}", inspection.getId());
// 该任务第一次产生问题,通知小程序
if (CollectionUtil.isNotEmpty(thirstyQuestionFiles) && thirstyQuestionFiles.size() > 0) {
InspectionFile inspectionFile = thirstyQuestionFiles.get(0);
QuestionType questionType = questionTypeMap.get(inspectionFile.getQuestionCode());
noticeWeChatMiniProgramService.notice(inspection, questionType);
}
}

log.info("批量插入问题图片数据");
CommonUtils.batchOperate((x) -> inspectionFileMapper.addBatch(x), thirstyQuestionFiles, 1000);


log.info("调用saveAccidentData方法保存应急记录数据...");

Boolean flag = this.saveAccidentData(thirstyQuestionFiles);

+ 53
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/NoticeWeChatMiniProgramService.java Переглянути файл

@@ -0,0 +1,53 @@
package com.tuoheng.admin.service.third.dsp;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.QuestionType;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class NoticeWeChatMiniProgramService {

/**
* 通知微信小程序
*
* @param inspection
* @param questionType
* @return
*/
@Transactional
public void notice(Inspection inspection, QuestionType questionType) {
log.info("任务发现第一个问题,推送给微信小程序:inspection:{}, questionType:{}", inspection.getId(), questionType);

String url = CommonConfig.wechatURL + SystemConstant.API_WEIXIN_SEND_MESSAGE;
JSONObject jsonObject = new JSONObject();
jsonObject.put("tenantId", inspection.getTenantId());
jsonObject.put("deptId", inspection.getDeptId());
jsonObject.put("inspectionId", inspection.getId());
jsonObject.put("questionName", inspection.getName());
jsonObject.put("questionDesc", questionType.getContent());
jsonObject.put("createTime", DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"));

log.info("任务发现第一个问题,推送给微信小程序:url:{}", url);
log.info("任务发现第一个问题,推送给微信小程序:jsonObject:{}", jsonObject);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
if (StringUtils.isEmpty(airPortStr)) {
log.info("任务发现第一个问题,推送给微信小程序:返回数据为空");
throw new com.aliyun.oss.ServiceException("微信小程序返回数据为空");
}
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
if (0 != jsonResult.getCode()) {
log.info("任务发现第一个问题,推送给微信小程序:返回失败,jsonResult:{}", jsonResult.getMsg());
throw new ServiceException("推送给微信小程序,返回失败");
}
log.info("任务发现第一个问题,推送给微信小程序:成功,inspection:{}, questionType:{}", inspection.getId(), questionType);
}
}

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-dev.yml Переглянути файл

@@ -146,6 +146,8 @@ tuoheng:
#airport配置地址
#airport-url: http://192.168.11.22:9060
airport-url: http://192.168.11.11:7011/airport/admin
#小程序配置地址
wechat-url: http://192.168.11.11:9119
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -155,6 +157,11 @@ tuoheng:
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_freeway/uploads/

wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4

+ 9
- 3
tuoheng-service/tuoheng-admin/src/main/resources/application-local.yml Переглянути файл

@@ -152,9 +152,9 @@ tuoheng:
#飞手平台地址
pilot-url: http://192.168.11.241:7011/pilot/web/
#airport配置地址
# airport-url: http://192.168.11.11:7011/airport/admin
# airport测试环境地址
airport-url: https://airport-test.t-aaron.com/airport/admin
airport-url: http://192.168.11.11:7011/airport/admin
#小程序配置地址
wechat-url: http://192.168.11.11:9119
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -164,6 +164,12 @@ tuoheng:
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_freeway/uploads/

wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg


#阿里云
aliyuncsVod:
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-prod.yml Переглянути файл

@@ -146,6 +146,8 @@ tuoheng:
pilot-url: https://pilot.t-aaron.com/pilot/web/
#airport配置地址
airport-url: https://airport.t-aaron.com/airport/admin
#小程序配置地址
wechat-url: https://freeway-miniprogram.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -155,6 +157,11 @@ tuoheng:
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_freeway/uploads/

wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/resources/application-test.yml Переглянути файл

@@ -146,6 +146,8 @@ tuoheng:
pilot-url: http://172.15.1.11:7011/pilot/web/
#airport配置地址
airport-url: https://airport-test.t-aaron.com/airport/admin
#小程序配置地址
wechat-url: https://freeway-miniprogram-test.t-aaron.com
# 文件配置
uploads:
#上传的服务器上的映射文件夹
@@ -155,6 +157,11 @@ tuoheng:
#静态资源实际存储路径
uploadFolder: /data/java/tuoheng_freeway/uploads/

wx:
appId: wx8e25cc4a7eec55c6
appSecret: ff104538eb568d0d99405638e35af8ad
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg

#阿里云
aliyuncsVod:
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4

Завантаження…
Відмінити
Зберегти