commit
This commit is contained in:
@@ -433,12 +433,13 @@ public class SiteReserveController {
|
||||
if(StrUtil.isBlank(siteId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
DateTime todayDate = DateUtil.date();//今天
|
||||
Date nextWeekDate = DateUtil.offsetDay(todayDate, 7); // 往后 7 天
|
||||
List<DateTime> fullDateList = DateUtil.rangeToList(todayDate, nextWeekDate, DateField.DAY_OF_MONTH);
|
||||
|
||||
//查询场地
|
||||
ActivitySiteInfo siteInfo = siteInfoService.fetch(siteId);
|
||||
|
||||
DateTime todayDate = DateUtil.date();//今天
|
||||
Date nextWeekDate = DateUtil.offsetDay(todayDate, siteInfo.getOpenDayNum() != null ? siteInfo.getOpenDayNum() : 7); // 往后 7 天
|
||||
List<DateTime> fullDateList = DateUtil.rangeToList(todayDate, nextWeekDate, DateField.DAY_OF_MONTH);
|
||||
|
||||
List<NutMap> openHours = siteInfo.getOpen_hours();
|
||||
List<Integer> weekNumList = openHours.stream().map(o -> o.getInt("weekNum")).distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -97,4 +97,10 @@ public class ActivitySiteInfo {
|
||||
@Comment("排序编号")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer sortNum;
|
||||
|
||||
@Column
|
||||
@Comment("开放天数段")
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Default("7")
|
||||
private Integer openDayNum;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.sys.models.Sys_wechat_msg;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.http.Http;
|
||||
import org.nutz.http.Sender;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
@@ -29,23 +32,13 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class MsgApi {
|
||||
|
||||
private static final String APP_ID = "D333FB41-BB5A-DDBE-34E8-EF50CC1D9BD0";
|
||||
private static final String APP_SECRET = "018C4A25-888C-C9DF-BDC3-AEE843B4B00D";
|
||||
private static final String USER_ID = "52900";
|
||||
private static final int SCHOOL_CODE = 5;
|
||||
private static final String APP_ID = "MSG65700580";
|
||||
private static final String APP_SECRET = "NmNiMDI1ZWEzMTE3ZGMxMWMwNGNjNTE1OTkxMDViOTk";
|
||||
private static final String TOKEN_NAME = "hhu_msg_token";
|
||||
private static final String DOMAIN = "http://202.119.114.95";
|
||||
private static final String GET_TOKEN_URL = "/api/token";
|
||||
private static final String SEND_URL = "/api/send";
|
||||
|
||||
//通讯渠道 不想获取 写死
|
||||
private List<NutMap> channels = new ArrayList<>() {{
|
||||
add(NutMap.NEW().addv("toolid", "wechat_pri").addv("toolname", "智能通道"));
|
||||
add(NutMap.NEW().addv("toolid", "wechat_enterprise").addv("toolname", "微信企业号"));
|
||||
add(NutMap.NEW().addv("toolid", "webmail").addv("toolname", "电子邮件"));
|
||||
add(NutMap.NEW().addv("toolid", "mobile").addv("toolname", "移动电话"));
|
||||
}};
|
||||
|
||||
private static final String DOMAIN = "https://msg.hhu.edu.cn";
|
||||
private static final String GET_TOKEN_URL = "/msg/getThirdAPIToken";
|
||||
private static final String SEND_URL = "/message/sendMessageApi";
|
||||
private static final String SEND_SMS_URL = "/message/sendMessageBySMSApi";
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
@@ -63,44 +56,84 @@ public class MsgApi {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean sendMsg(String msgContent, List<String> receivers){
|
||||
Assert.notBlank(msgContent);
|
||||
Assert.notEmpty(receivers);
|
||||
|
||||
List<Map<String, String>> tousers = receivers.stream().map(v -> Map.of("type", "User", "userId", v,"name",v)).collect(Collectors.toList());
|
||||
|
||||
String token = getMsgToken();
|
||||
|
||||
NutMap bodyMap = new NutMap() {{
|
||||
addv("token", token);
|
||||
addv("msgtitle", "智慧工会");
|
||||
addv("msgContent", msgContent);
|
||||
addv("msgType", "1");
|
||||
addv("sendStatus", "1");
|
||||
addv("sendChannel", "IntelligenceMode");
|
||||
addv("sendMode", "normal");
|
||||
addv("receivers", Json.toJson(tousers));
|
||||
}};
|
||||
log.info(Json.toJson(bodyMap));
|
||||
String url = DOMAIN + SEND_URL;
|
||||
|
||||
String content = Http.post(url, bodyMap, Sender.Default_Read_Timeout);
|
||||
NutMap contentMap = Json.fromJson(NutMap.class, content);
|
||||
log.info("成功》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
log.info(Json.toJson(contentMap));
|
||||
if (contentMap.getString("rspCode").equals("000000")) {
|
||||
log.info("消息发送,发送内容" + Json.toJson(bodyMap));
|
||||
} else {
|
||||
log.error("消息发送失败,发送内容" + Json.toJson(bodyMap));
|
||||
// throw new RuntimeException("消息发送失败");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sms
|
||||
*
|
||||
* @param msgContent 消息内容
|
||||
* @param receivers 接收人工号/手机号
|
||||
*/
|
||||
public void sendMsg(String msgContent, List<String> receivers) {
|
||||
public void sendSmsMsg(String msgContent, List<String> receivers) {
|
||||
Assert.notBlank(msgContent);
|
||||
Assert.notEmpty(receivers);
|
||||
|
||||
List<Map<String, String>> tousers = receivers.stream().map(v -> Map.of("touser", v)).collect(Collectors.toList());
|
||||
Sql sql = Sqls.create("select username as name,mobile from sys_user where loginname in (@loginname) and mobile is not null and mobile != ''");
|
||||
sql.setParam("loginname",receivers);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
List<NutMap> tousers = sql.getList(NutMap.class);
|
||||
|
||||
NutMap bodyMap = new NutMap() {{
|
||||
addv("fromuser", USER_ID);
|
||||
addv("content", msgContent);
|
||||
addv("type", "text");
|
||||
addv("priority", "1");
|
||||
addv("tools", List.of(Map.of("tool", "mobile")));
|
||||
addv("tousers", tousers);
|
||||
}};
|
||||
log.info("成功》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
log.info(Json.toJson(bodyMap));
|
||||
String url = DOMAIN + SEND_URL + "?appid=%s&tokenid=%s&schoolcode=%s".formatted(APP_ID, getMsgToken(), SCHOOL_CODE);
|
||||
List<NutMap> users = new ArrayList<>();
|
||||
|
||||
//String content = "";
|
||||
String content = Http.post(url, Map.of("message", Json.toJson(bodyMap)), Sender.Default_Read_Timeout);
|
||||
NutMap contentMap = Json.fromJson(NutMap.class, content);
|
||||
for (NutMap touser : tousers) {
|
||||
users.add(NutMap.NEW().addv("mobile",touser.getString("mobile").trim()).addv("name",touser.getString("name")));
|
||||
}
|
||||
|
||||
Sys_wechat_msg wechatMsg = new Sys_wechat_msg();
|
||||
wechatMsg.setRequestContent(Json.toJson(bodyMap));
|
||||
wechatMsg.setResponseContent(content);
|
||||
dao.insert(wechatMsg);
|
||||
String token = getMsgToken();
|
||||
|
||||
if (contentMap.getString("retcode").equals("0")) {
|
||||
log.info("短信发送,发送内容" + Json.toJson(bodyMap));
|
||||
} else {
|
||||
log.error("短信发送失败,发送内容" + Json.toJson(bodyMap));
|
||||
throw new RuntimeException("短信发送失败");
|
||||
List<List<NutMap>> split = ListUtil.split(users, 5);
|
||||
for (List<NutMap> splitUsers : split) {
|
||||
NutMap bodyMap = new NutMap() {{
|
||||
addv("token", token);
|
||||
addv("msgContent", msgContent);
|
||||
addv("receivers", Json.toJson(splitUsers));
|
||||
}};
|
||||
log.info("成功》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||
log.info(Json.toJson(bodyMap));
|
||||
String url = DOMAIN + SEND_SMS_URL;
|
||||
|
||||
String content = Http.post(url, bodyMap, Sender.Default_Read_Timeout);
|
||||
NutMap contentMap = Json.fromJson(NutMap.class, content);
|
||||
|
||||
if (contentMap.getString("rspCode").equals("1")) {
|
||||
log.info("短信发送,发送内容" + Json.toJson(bodyMap));
|
||||
} else {
|
||||
log.error("短信发送失败,发送内容" + Json.toJson(bodyMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,14 +146,13 @@ public class MsgApi {
|
||||
String token = redisService.get(TOKEN_NAME);
|
||||
if (StrUtil.isBlank(token)) {
|
||||
Map<String, Object> params = new HashMap<String, Object>() {{
|
||||
put("appid", APP_ID);
|
||||
put("appsecret", APP_SECRET);
|
||||
put("schoolcode", SCHOOL_CODE);
|
||||
put("appId", APP_ID);
|
||||
put("appPassword", APP_SECRET);
|
||||
}};
|
||||
String content = Http.get(DOMAIN + GET_TOKEN_URL, params, Sender.Default_Conn_Timeout).getContent();
|
||||
NutMap contentMap = Json.fromJson(NutMap.class, content);
|
||||
if (contentMap.getString("retcode").equals("0")) {
|
||||
String access_token = contentMap.getString("access_token");
|
||||
if (contentMap.getString("rspCode").equals("000000")) {
|
||||
String access_token = contentMap.getAs("resultData", NutMap.class).getString("token");
|
||||
redisService.setex(TOKEN_NAME, 3600, access_token);
|
||||
} else {
|
||||
throw new RuntimeException("获取短信接口token异常!!!");
|
||||
|
||||
@@ -138,12 +138,7 @@ public class MsgNotifyServiceImpl extends ViServiceImpl<MsgNotify> implements Ms
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (sendTypes.contains("msg")) {
|
||||
msgApi.sendMsg(content, receivers);
|
||||
}
|
||||
if (sendTypes.contains("WeChat")) {
|
||||
msgApi.sendMsg(content, receivers);
|
||||
}
|
||||
msgApi.sendMsg(content, receivers);
|
||||
}
|
||||
}.start();
|
||||
|
||||
|
||||
@@ -139,13 +139,14 @@ layout("/mobile/platform.html"){
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="calendar-right">
|
||||
<div class="calendar-right">
|
||||
<van-icon size="16" color="white" name="arrow-down" @click="calendarVisible=true"></van-icon>
|
||||
<van-calendar class="top_pop" v-model="calendarVisible" color="#246fb4" position="top" @confirm="onConfirm"
|
||||
:default-date="selectDate?.toDate()"
|
||||
:formatter="calendarFormatter"
|
||||
:first-day-of-week="1"
|
||||
title="选择开始日期"></van-calendar>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
@@ -277,8 +278,11 @@ layout("/mobile/platform.html"){
|
||||
}
|
||||
}
|
||||
},
|
||||
calendarFormatter() {
|
||||
calendarFormatter(day) {
|
||||
return (day) => {
|
||||
if(!this.allowDayList.includes(moment(day.date).format('YYYY-MM-DD'))) {
|
||||
day.type = 'disabled'
|
||||
}
|
||||
return day
|
||||
}
|
||||
}
|
||||
@@ -304,6 +308,7 @@ layout("/mobile/platform.html"){
|
||||
onConfirm(date) {
|
||||
this.selectDate = moment(date)
|
||||
this.setWeekList(this.selectDate)
|
||||
this.getAllowTime()
|
||||
this.calendarVisible = false
|
||||
},
|
||||
setWeekList(startDate) {
|
||||
|
||||
@@ -111,8 +111,11 @@ layout("/layouts/platform.html"){
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="create_username" label="创建人">
|
||||
<!--<el-form-item prop="create_username" label="创建人">
|
||||
<el-input readonly v-model="formData.create_username" type="text"></el-input>
|
||||
</el-form-item>-->
|
||||
<el-form-item prop="openDayNum" label="开放天数段">
|
||||
<el-input placeholder="请输入开放天数段" v-model="formData.openDayNum" type="number"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@@ -369,6 +372,7 @@ layout("/layouts/platform.html"){
|
||||
sexLimit: 0,
|
||||
notApplyTimeList: [],
|
||||
reserveTarget: 2,
|
||||
openDayNum: 7,
|
||||
},
|
||||
pageForm: {
|
||||
searchName: "name",
|
||||
@@ -390,6 +394,7 @@ layout("/layouts/platform.html"){
|
||||
openWeekTime: [{required: true, message: '请选择预约时间', trigger: ['blur', 'change']}],
|
||||
reserveTarget: [{required: true, message: '请选择面向对象', trigger: ['blur', 'change']}],
|
||||
maxNum: [{required: true, message: '请输入容纳人数', trigger: ['blur', 'change']}],
|
||||
openDayNum: [{required: true, message: '请输入开放天数段', trigger: ['blur', 'change']}],
|
||||
},
|
||||
|
||||
setUpTimeDialog: false,
|
||||
@@ -537,6 +542,7 @@ layout("/layouts/platform.html"){
|
||||
sexLimit: '0',
|
||||
notApplyTimeList: [],
|
||||
reserveTarget: 2,
|
||||
openDayNum: 7,
|
||||
}
|
||||
this.$refs.guava.edit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user