提交整改
parent
ed1d3cfb75
commit
208fe7f81f
|
@ -14,7 +14,9 @@ public enum MessageTypeEnum {
|
||||||
CLFYSP("50", "材料封样审批"),
|
CLFYSP("50", "材料封样审批"),
|
||||||
QYFSSP("60", "取样复试审批"),
|
QYFSSP("60", "取样复试审批"),
|
||||||
GCSPCSBL("70", "办理工程审批超时提醒"),
|
GCSPCSBL("70", "办理工程审批超时提醒"),
|
||||||
GCSPCSCS("80", "抄送工程审批超时提醒");
|
GCSPCSCS("80", "抄送工程审批超时提醒"),
|
||||||
|
YHZGCSGZ("90", "隐患整改超时通知"),
|
||||||
|
YHFJCSGZ("100", "隐患复检超时通知");
|
||||||
|
|
||||||
//工作流审批由ProcDefKey组成
|
//工作流审批由ProcDefKey组成
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
|
@ -9,6 +9,8 @@ public enum TemplateMessageEnum {
|
||||||
|
|
||||||
TROUBLE_SUBMIT("f3saBGJCnUAjXHw1KooxEQOOiKEHlQxLIK-sPDgoL_E", "隐患整改通知"),
|
TROUBLE_SUBMIT("f3saBGJCnUAjXHw1KooxEQOOiKEHlQxLIK-sPDgoL_E", "隐患整改通知"),
|
||||||
TROUBLE_HANDLE("6mGOWPXS3l5a5fzXd9GIV9_IkEfZmeJ_6G2P_SQkWnU", "隐患处理完成通知"),
|
TROUBLE_HANDLE("6mGOWPXS3l5a5fzXd9GIV9_IkEfZmeJ_6G2P_SQkWnU", "隐患处理完成通知"),
|
||||||
|
ROUBLE_EXPIRED_ZG("f3saBGJCnUAjXHw1KooxESpSdHMrh5liznpsbWZV8oA", "隐患整改超时通知"),
|
||||||
|
ROUBLE_EXPIRED_FJ("f3saBGJCnUAjXHw1KooxESpSdHMrh5liznpsbWZV8oA", "隐患复检超时通知"),
|
||||||
APPLY_DEFAULT("KY7oAHgqFxUSaE3ByxFJfv_0U3LnSWfgUCwV-CZyEdo", "系统流程审批提醒"),
|
APPLY_DEFAULT("KY7oAHgqFxUSaE3ByxFJfv_0U3LnSWfgUCwV-CZyEdo", "系统流程审批提醒"),
|
||||||
APPLY_EXPIRED_MY("MUAXGjyaNE-maYn6XSNycRfZfPtdVTxubqlT8lHcYqw", "办理流程审批超时提醒"),
|
APPLY_EXPIRED_MY("MUAXGjyaNE-maYn6XSNycRfZfPtdVTxubqlT8lHcYqw", "办理流程审批超时提醒"),
|
||||||
APPLY_EXPIRED_COPY("MUAXGjyaNE-maYn6XSNyceRFN9h8nfIjKvyZTOLnKDE", "抄送流程审批超时提醒");
|
APPLY_EXPIRED_COPY("MUAXGjyaNE-maYn6XSNyceRFN9h8nfIjKvyZTOLnKDE", "抄送流程审批超时提醒");
|
||||||
|
|
|
@ -38,6 +38,16 @@ public interface TaskMapper {
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> findDaysAwaitClfyList();
|
public List<Map<String, Object>> findDaysAwaitClfyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询超时1天未整改的隐患数据
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> findDaysAwaitYhzgList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询超时1天未复检的隐患数据
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> findDaysAwaitYhfjList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询流程用户
|
* 根据条件查询流程用户
|
||||||
* @param businessKey 流程归属表单
|
* @param businessKey 流程归属表单
|
||||||
|
|
|
@ -37,6 +37,16 @@ public interface ITaskService {
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> findDaysAwaitClfyList();
|
public List<Map<String, Object>> findDaysAwaitClfyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询超时1天未整改的隐患数据
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> findDaysAwaitYhzgList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询超时1天未复检的隐患数据
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> findDaysAwaitYhfjList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询流程用户
|
* 根据条件查询流程用户
|
||||||
* @param businessKey 流程归属表单
|
* @param businessKey 流程归属表单
|
||||||
|
|
|
@ -61,6 +61,22 @@ public class ITaskServiceImpl implements ITaskService {
|
||||||
return taskMapper.findDaysAwaitClfyList();
|
return taskMapper.findDaysAwaitClfyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询超时1天未整改的隐患数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> findDaysAwaitYhzgList(){
|
||||||
|
return taskMapper.findDaysAwaitYhzgList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询超时1天未复检的隐患数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> findDaysAwaitYhfjList(){
|
||||||
|
return taskMapper.findDaysAwaitYhfjList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询流程用户
|
* 根据条件查询流程用户
|
||||||
* @param businessKey 流程归属表单
|
* @param businessKey 流程归属表单
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -113,7 +112,7 @@ public class FlowTaskExpiredTask {
|
||||||
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
||||||
if (lock) {*/
|
if (lock) {*/
|
||||||
try {
|
try {
|
||||||
log.info("劫持锁...{}...开始执行::工程审批超时提醒定时任务...{}");
|
log.info("劫持锁...{}...开始执行::举牌验收超时提醒定时任务...{}");
|
||||||
List<WxMpTemplateMessage> list = new ArrayList<>();
|
List<WxMpTemplateMessage> list = new ArrayList<>();
|
||||||
List<Map<String, Object>> flowList = taskService.findDaysAwaitJpysList();
|
List<Map<String, Object>> flowList = taskService.findDaysAwaitJpysList();
|
||||||
for(Map<String, Object> dataMap:flowList){
|
for(Map<String, Object> dataMap:flowList){
|
||||||
|
@ -157,7 +156,7 @@ public class FlowTaskExpiredTask {
|
||||||
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
||||||
if (lock) {*/
|
if (lock) {*/
|
||||||
try {
|
try {
|
||||||
log.info("劫持锁...{}...开始执行::工程审批超时提醒定时任务...{}");
|
log.info("劫持锁...{}...开始执行::实测实量超时提醒定时任务...{}");
|
||||||
List<WxMpTemplateMessage> list = new ArrayList<>();
|
List<WxMpTemplateMessage> list = new ArrayList<>();
|
||||||
List<Map<String, Object>> flowList = taskService.findDaysAwaitScslList();
|
List<Map<String, Object>> flowList = taskService.findDaysAwaitScslList();
|
||||||
for(Map<String, Object> dataMap:flowList){
|
for(Map<String, Object> dataMap:flowList){
|
||||||
|
@ -201,7 +200,7 @@ public class FlowTaskExpiredTask {
|
||||||
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
||||||
if (lock) {*/
|
if (lock) {*/
|
||||||
try {
|
try {
|
||||||
log.info("劫持锁...{}...开始执行::工程审批超时提醒定时任务...{}");
|
log.info("劫持锁...{}...开始执行::取样复试超时提醒定时任务...{}");
|
||||||
List<WxMpTemplateMessage> list = new ArrayList<>();
|
List<WxMpTemplateMessage> list = new ArrayList<>();
|
||||||
List<Map<String, Object>> flowList = taskService.findDaysAwaitQyfsList();
|
List<Map<String, Object>> flowList = taskService.findDaysAwaitQyfsList();
|
||||||
for(Map<String, Object> dataMap:flowList){
|
for(Map<String, Object> dataMap:flowList){
|
||||||
|
@ -245,7 +244,7 @@ public class FlowTaskExpiredTask {
|
||||||
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
||||||
if (lock) {*/
|
if (lock) {*/
|
||||||
try {
|
try {
|
||||||
log.info("劫持锁...{}...开始执行::工程审批超时提醒定时任务...{}");
|
log.info("劫持锁...{}...开始执行::材料封样超时提醒定时任务...{}");
|
||||||
List<WxMpTemplateMessage> list = new ArrayList<>();
|
List<WxMpTemplateMessage> list = new ArrayList<>();
|
||||||
List<Map<String, Object>> flowList = taskService.findDaysAwaitClfyList();
|
List<Map<String, Object>> flowList = taskService.findDaysAwaitClfyList();
|
||||||
for(Map<String, Object> dataMap:flowList){
|
for(Map<String, Object> dataMap:flowList){
|
||||||
|
@ -277,6 +276,104 @@ public class FlowTaskExpiredTask {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从Flowable中查询超时数据进行消息提醒
|
||||||
|
* 分布式锁::quartz.task.flowTaskExpiredTask.notifyExpiredData
|
||||||
|
* 由程序定时调用 JiangYuQi
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void notifyYhzgExpiredData() {
|
||||||
|
/**String key = "quartz.task.flowTaskExpiredTask.notifyExpiredData";
|
||||||
|
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
||||||
|
if (lock) {*/
|
||||||
|
try {
|
||||||
|
log.info("劫持锁...{}...开始执行::隐患整改超时提醒定时任务...{}");
|
||||||
|
List<WxMpTemplateMessage> list = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> flowList = taskService.findDaysAwaitYhzgList();
|
||||||
|
for(Map<String, Object> dataMap:flowList){
|
||||||
|
String projectId = Convert.toStr(dataMap.get("projectId"));
|
||||||
|
String projectName = Convert.toStr(dataMap.get("projectName"));
|
||||||
|
String lordsentuser = Convert.toStr(dataMap.get("lordsentuser"));
|
||||||
|
String minNickTime = Convert.toStr(dataMap.get("minNickTime"));
|
||||||
|
Integer infotype = Convert.toInt(dataMap.get("infotype"));
|
||||||
|
String handlePath = infotype==0?"security":"quality";
|
||||||
|
String infoTypeName = infotype==0?"安全隐患":"安全隐患";
|
||||||
|
String total = Convert.toStr(dataMap.get("total"));
|
||||||
|
//模板数据
|
||||||
|
WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
|
||||||
|
.toUser(this.getMsgId(lordsentuser))
|
||||||
|
.miniProgram(new WxMpTemplateMessage.MiniProgram(WechatAccountConfig.getWxAppId(), "/pageage/project_problemmodify/"+handlePath+"/list/index?barProId="+projectId))
|
||||||
|
.templateId(TemplateMessageEnum.ROUBLE_EXPIRED_ZG.getId()).build();
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("thing7", projectName));
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("character_string2", total));
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("const10", infoTypeName));
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("const9", minNickTime));
|
||||||
|
list.add(templateMessage);
|
||||||
|
}
|
||||||
|
this.send(list,"EXPIRED_"+ MessageTypeEnum.YHZGCSGZ.getCode()+"_"+System.currentTimeMillis());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("任务执行异常...{}...::::结束执行...{}", e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
/**finally {
|
||||||
|
log.info("释放锁...{}", key);
|
||||||
|
redisLock.unlock(key);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
log.info("尝试劫持锁失败...{}", key);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从Flowable中查询超时数据进行消息提醒
|
||||||
|
* 分布式锁::quartz.task.flowTaskExpiredTask.notifyExpiredData
|
||||||
|
* 由程序定时调用 JiangYuQi
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void notifyYhfjExpiredData() {
|
||||||
|
/**String key = "quartz.task.flowTaskExpiredTask.notifyExpiredData";
|
||||||
|
boolean lock = redisLock.tryLock(key, Constants.REDIS_LOCK, TimeUnit.SECONDS);
|
||||||
|
if (lock) {*/
|
||||||
|
try {
|
||||||
|
log.info("劫持锁...{}...开始执行::隐患复检超时提醒定时任务...{}");
|
||||||
|
List<WxMpTemplateMessage> list = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> flowList = taskService.findDaysAwaitYhzgList();
|
||||||
|
for(Map<String, Object> dataMap:flowList){
|
||||||
|
String projectId = Convert.toStr(dataMap.get("projectId"));
|
||||||
|
String projectName = Convert.toStr(dataMap.get("projectName"));
|
||||||
|
String rechecksenduser = Convert.toStr(dataMap.get("rechecksenduser"));
|
||||||
|
String minNickTime = Convert.toStr(dataMap.get("minNickTime"));
|
||||||
|
Integer infotype = Convert.toInt(dataMap.get("infotype"));
|
||||||
|
String handlePath = infotype==0?"security":"quality";
|
||||||
|
String infoTypeName = infotype==0?"安全隐患":"安全隐患";
|
||||||
|
String total = Convert.toStr(dataMap.get("total"));
|
||||||
|
//模板数据
|
||||||
|
WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
|
||||||
|
.toUser(this.getMsgId(rechecksenduser))
|
||||||
|
.miniProgram(new WxMpTemplateMessage.MiniProgram(WechatAccountConfig.getWxAppId(), "/pageage/project_problemmodify/"+handlePath+"/list/index?barProId="+projectId))
|
||||||
|
.templateId(TemplateMessageEnum.ROUBLE_EXPIRED_FJ.getId()).build();
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("thing7", projectName));
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("character_string2", total));
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("const10", infoTypeName));
|
||||||
|
templateMessage.addWxMpTemplateData(new WxMpTemplateData("const9", minNickTime));
|
||||||
|
list.add(templateMessage);
|
||||||
|
}
|
||||||
|
this.send(list,"EXPIRED_"+ MessageTypeEnum.YHFJCSGZ.getCode()+"_"+System.currentTimeMillis());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("任务执行异常...{}...::::结束执行...{}", e.getMessage());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
/**finally {
|
||||||
|
log.info("释放锁...{}", key);
|
||||||
|
redisLock.unlock(key);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
log.info("尝试劫持锁失败...{}", key);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询微信用户列表
|
* 查询微信用户列表
|
||||||
* @param userName
|
* @param userName
|
||||||
|
|
|
@ -41,6 +41,56 @@
|
||||||
ORDER BY spc.project_id
|
ORDER BY spc.project_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!--查询超时未整改的隐患数据-->
|
||||||
|
<select id="findDaysAwaitYhzgList" resultType="Map">
|
||||||
|
SELECT
|
||||||
|
spc.projectid AS projectId,
|
||||||
|
sp.projectName,
|
||||||
|
spc.infotype,
|
||||||
|
spc.lordsentuser,
|
||||||
|
min(date(spc.nickedtime)) as minNickTime,
|
||||||
|
count(1) AS total
|
||||||
|
FROM
|
||||||
|
smz_ssp_problemmodify spc
|
||||||
|
LEFT JOIN sur_project sp ON sp.id = spc.projectid
|
||||||
|
WHERE
|
||||||
|
spc.checkstate in (0, 3)
|
||||||
|
AND spc.isdel = 0
|
||||||
|
AND spc.nickedtime < DATE_SUB(NOW(), INTERVAL 1 DAY)
|
||||||
|
GROUP BY
|
||||||
|
spc.projectid,
|
||||||
|
sp.projectName,
|
||||||
|
spc.infotype,
|
||||||
|
spc.lordsentuser
|
||||||
|
ORDER BY
|
||||||
|
spc.projectid
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--查询超时未复检的隐患数据-->
|
||||||
|
<select id="findDaysAwaitYhfjList" resultType="Map">
|
||||||
|
SELECT
|
||||||
|
spc.projectid AS projectId,
|
||||||
|
sp.projectName,
|
||||||
|
spc.infotype,
|
||||||
|
spc.rechecksenduser,
|
||||||
|
min(date(spc.nickedtime)) as minNickTime,
|
||||||
|
count(1) AS total
|
||||||
|
FROM
|
||||||
|
smz_ssp_problemmodify spc
|
||||||
|
LEFT JOIN sur_project sp ON sp.id = spc.projectid
|
||||||
|
WHERE
|
||||||
|
spc.checkstate = 1
|
||||||
|
AND spc.isdel = 0
|
||||||
|
AND spc.nickedtime < DATE_SUB(NOW(), INTERVAL 1 DAY)
|
||||||
|
GROUP BY
|
||||||
|
spc.projectid,
|
||||||
|
sp.projectName,
|
||||||
|
spc.infotype,
|
||||||
|
spc.rechecksenduser
|
||||||
|
ORDER BY
|
||||||
|
spc.projectid
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="findFlowTaskUsers" resultType="com.ruoyi.common.core.domain.entity.SysUser">
|
<select id="findFlowTaskUsers" resultType="com.ruoyi.common.core.domain.entity.SysUser">
|
||||||
select su.* from sys_user su
|
select su.* from sys_user su
|
||||||
left join sur_project_userinfo spu on spu.user_id = su.user_id
|
left join sur_project_userinfo spu on spu.user_id = su.user_id
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,10 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-content">
|
<div class="app-content">
|
||||||
<el-row style="margin-top: 40%" v-if="errorVisible || successVisible">
|
<el-row style="padding-top: 150px">
|
||||||
<el-col :sm="24" :lg="24" v-if="successVisible">
|
<el-col :sm="24" :lg="24" v-if="successVisible">
|
||||||
<el-result icon="success" title="公众号消息授权成功">
|
<el-result icon="success" title="公众号消息授权成功">
|
||||||
<template slot="extra">
|
<template slot="extra">
|
||||||
<el-button type="primary" size="medium" round>返回小程序</el-button>
|
<el-button type="primary" size="medium" round @click="colse"
|
||||||
|
>返回小程序</el-button
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-result>
|
</el-result>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -15,33 +17,47 @@
|
||||||
subTitle="请关注公众号并进行网页授权"
|
subTitle="请关注公众号并进行网页授权"
|
||||||
>
|
>
|
||||||
<template slot="extra">
|
<template slot="extra">
|
||||||
<el-button type="primary" size="medium" round>返回小程序</el-button>
|
<el-button type="primary" size="medium" round @click="colse"
|
||||||
|
>返回小程序</el-button
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-result>
|
</el-result>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :sm="24" :lg="24" v-if="!errorVisible && !successVisible">
|
||||||
|
<el-result
|
||||||
|
icon="info"
|
||||||
|
title="公众号消息授权页面"
|
||||||
|
>
|
||||||
|
</el-result>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from "js-cookie";
|
||||||
import { authorize, wxBinding } from "@/api/wxsetting/wxAuth";
|
import { wxBinding } from "@/api/wxsetting/wxAuth";
|
||||||
|
import jweixin from "@/assets/js/jweixin-1.3.2";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "build",
|
name: "build",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
uId: null,
|
userOpenId: "",
|
||||||
errorVisible: false,
|
errorVisible: false,
|
||||||
successVisible: false,
|
successVisible: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.uId = Cookies.get("userOpenId") || this.getQueryString("userOpenId");
|
this.userOpenId = this.getQueryString("userOpenId") || "";
|
||||||
if (!this.uId) {
|
console.log("userOpenId...1{}", this.userOpenId);
|
||||||
|
if (this.userOpenId == "") {
|
||||||
|
this.userOpenId = Cookies.get("userOpenId") || "";
|
||||||
|
console.log("userOpenId...2{}", this.userOpenId);
|
||||||
|
}
|
||||||
|
if (this.userOpenId == "") {
|
||||||
this.errorVisible = true;
|
this.errorVisible = true;
|
||||||
} else {
|
} else {
|
||||||
Cookies.set("userOpenId",uId);
|
|
||||||
this.wechatLogin();
|
this.wechatLogin();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -50,59 +66,81 @@ export default {
|
||||||
// 处理微信授权登录
|
// 处理微信授权登录
|
||||||
//let rd = this.getQueryString("rd") || "";
|
//let rd = this.getQueryString("rd") || "";
|
||||||
let code = this.getQueryString("code") || "";
|
let code = this.getQueryString("code") || "";
|
||||||
|
let state = this.getQueryString("state") || "";
|
||||||
|
console.log("code...{}", code, state);
|
||||||
// token === '' && openId != '' 只要这种情况,未绑定账号
|
// token === '' && openId != '' 只要这种情况,未绑定账号
|
||||||
if (code != "") {
|
if (code == "" || state == "") {
|
||||||
// 绑定账号
|
Cookies.set("userOpenId", this.userOpenId);
|
||||||
console.log("接口返回===>", code, this.uId);
|
console.log("我要去登录了===>");
|
||||||
this.saveBinding(uId, code);
|
|
||||||
} else {
|
|
||||||
const hrefUrl = window.location.href;
|
const hrefUrl = window.location.href;
|
||||||
// 如果绑定了,返回成功
|
// 如果绑定了,返回成功
|
||||||
console.log("我要去登录了===>");
|
window.location =
|
||||||
window.location = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe6fd9ad863ac09bf&response_type=code&scope=snsapi_base&redirect_uri="+encodeURIComponent(hrefUrl)+"&state=STATE#wechat_redirect";
|
"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe6fd9ad863ac09bf&response_type=code&scope=snsapi_userinfo&redirect_uri=" +
|
||||||
|
encodeURIComponent(hrefUrl) +
|
||||||
|
"&state=STATE#wechat_redirect";
|
||||||
|
} else {
|
||||||
|
// 绑定账号
|
||||||
|
this.saveBinding(this.userOpenId, code);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveBinding(uId, openId) {
|
saveBinding(userOpenId, code) {
|
||||||
|
if (!userOpenId || !code) {
|
||||||
|
this.errorVisible = true;
|
||||||
|
this.successVisible = false;
|
||||||
|
} else {
|
||||||
/**
|
/**
|
||||||
* uId 小程序openId
|
* uId 小程序openId
|
||||||
* openId 公众号openId
|
* openId 公众号openId
|
||||||
*/
|
*/
|
||||||
wxBinding({ openId: uId, code: code }).then((response) => {
|
wxBinding({ openId: userOpenId, code: code })
|
||||||
|
.then((response) => {
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
this.successVisible = true;
|
this.successVisible = true;
|
||||||
} else {
|
} else {
|
||||||
this.errorVisible = true;
|
this.errorVisible = true;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.errorVisible = true;
|
||||||
|
this.successVisible = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
colse() {
|
colse() {
|
||||||
if (typeof WeixinJSBridge == "undefined") {
|
// if (typeof WeixinJSBridge == "undefined") {
|
||||||
if (document.addEventListener) {
|
// if (document.addEventListener) {
|
||||||
document.addEventListener("WeixinJSBridgeReady", weixin_ClosePage, false);
|
// document.addEventListener("WeixinJSBridgeReady", weixin_ClosePage, false);
|
||||||
} else if (document.attachEvent) {
|
// } else if (document.attachEvent) {
|
||||||
document.attachEvent("WeixinJSBridgeReady", weixin_ClosePage);
|
// document.attachEvent("WeixinJSBridgeReady", weixin_ClosePage);
|
||||||
document.attachEvent("onWeixinJSBridgeReady", weixin_ClosePage);
|
// document.attachEvent("onWeixinJSBridgeReady", weixin_ClosePage);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
WeixinJSBridge.call("closeWindow");
|
// WeixinJSBridge.call("closeWindow");
|
||||||
}
|
// }
|
||||||
|
wx.miniProgram.navigateTo({url: '/pages/xiangmugaikuang/index?showUser=true'})
|
||||||
},
|
},
|
||||||
weixin_ClosePage() {
|
weixin_ClosePage() {
|
||||||
//关闭微信浏览器
|
//关闭微信浏览器
|
||||||
WeixinJSBridge.call("closeWindow");
|
//WeixinJSBridge.call("closeWindow");
|
||||||
},
|
},
|
||||||
getQueryString(paramName) {
|
getQueryString(paramName) {
|
||||||
|
console.log("paramName===>", paramName);
|
||||||
if (window.location.href.indexOf("?") == -1) return "";
|
if (window.location.href.indexOf("?") == -1) return "";
|
||||||
let searchString = window.location.href.split("?")[1];
|
let searchString = window.location.href.split("?")[1];
|
||||||
let i,
|
let i,
|
||||||
val,
|
val,
|
||||||
params = searchString.split("&");
|
params = searchString.split("&");
|
||||||
|
console.log("window.params===>", params);
|
||||||
for (i = 0; i < params.length; i++) {
|
for (i = 0; i < params.length; i++) {
|
||||||
val = params[i].split("=");
|
val = params[i].split("=");
|
||||||
if (val[0] == paramName) {
|
if (val[0] == paramName) {
|
||||||
|
if (val[1] == "undefined" || val[1] == "null") {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
return val[1];
|
return val[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -120,7 +158,7 @@ export default {
|
||||||
color: #ffffff !important;
|
color: #ffffff !important;
|
||||||
}
|
}
|
||||||
.el-result__subtitle p {
|
.el-result__subtitle p {
|
||||||
color: red !important;
|
color: #f2777a !important;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
.el-result__extra {
|
.el-result__extra {
|
||||||
|
@ -129,4 +167,7 @@ export default {
|
||||||
.el-result__extra button {
|
.el-result__extra button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.el-result .icon-info{
|
||||||
|
fill: #409eff !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信openId绑定
|
* 微信openId绑定
|
||||||
|
@ -111,6 +113,11 @@ public class WxAuthController extends BaseController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostMapping("/binding")
|
@PostMapping("/binding")
|
||||||
public AjaxResult binding(@Validated @RequestBody WxBindingVo vo) throws Exception {
|
public AjaxResult binding(@Validated @RequestBody WxBindingVo vo) throws Exception {
|
||||||
|
String key="wxAuth_binding_"+vo.getCode();
|
||||||
|
Object obj = redisCache.getCacheObject(key);
|
||||||
|
if(obj!=null){
|
||||||
|
return success();
|
||||||
|
}
|
||||||
/*当用户同意授权后,会回调所设置的url并把authorization code传过来,
|
/*当用户同意授权后,会回调所设置的url并把authorization code传过来,
|
||||||
然后用这个code获得access token,其中也包含用户的openid等信息*/
|
然后用这个code获得access token,其中也包含用户的openid等信息*/
|
||||||
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = new WxMpOAuth2AccessToken();
|
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = new WxMpOAuth2AccessToken();
|
||||||
|
@ -128,7 +135,9 @@ public class WxAuthController extends BaseController {
|
||||||
SysUserOpenid sysUserOpenid = sysUserOpenidService.selectSysUserOpenidByOpenId(vo.getOpenId());
|
SysUserOpenid sysUserOpenid = sysUserOpenidService.selectSysUserOpenidByOpenId(vo.getOpenId());
|
||||||
if(sysUserOpenid!=null){
|
if(sysUserOpenid!=null){
|
||||||
sysUserOpenid.setMsgOpenId(openId);
|
sysUserOpenid.setMsgOpenId(openId);
|
||||||
return toAjax(sysUserOpenidService.updateSysUserOpenid(sysUserOpenid));
|
sysUserOpenidService.updateSysUserOpenid(sysUserOpenid);
|
||||||
|
redisCache.setCacheObject(key,vo.getCode(),5, TimeUnit.MINUTES);
|
||||||
|
return success();
|
||||||
}
|
}
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
log.error("【微信网页授权】{}", e);
|
log.error("【微信网页授权】{}", e);
|
||||||
|
|
|
@ -643,7 +643,7 @@ public class WeChatMessageServiceImpl {
|
||||||
/**
|
/**
|
||||||
* 模板消息开关
|
* 模板消息开关
|
||||||
*/
|
*/
|
||||||
private boolean wxSwitch=false;
|
private boolean wxSwitch=true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送模板消息
|
* 推送模板消息
|
||||||
|
@ -663,7 +663,7 @@ public class WeChatMessageServiceImpl {
|
||||||
message.setToUser(toUser);
|
message.setToUser(toUser);
|
||||||
wxMpService.getTemplateMsgService().sendTemplateMsg(message);
|
wxMpService.getTemplateMsgService().sendTemplateMsg(message);
|
||||||
//5分钟内不推送相同类型的消息
|
//5分钟内不推送相同类型的消息
|
||||||
redisCache.setCacheObject(key,false,1, TimeUnit.MINUTES);
|
redisCache.setCacheObject(key,false,5, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue