Commit 8e976220 authored by 竹天卫's avatar 竹天卫

企業微信配置放在application.yml中

parent 19da2867
...@@ -150,6 +150,12 @@ ...@@ -150,6 +150,12 @@
<groupId>cn.afterturn</groupId> <groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId> <artifactId>easypoi-base</artifactId>
<version>4.1.0</version> <version>4.1.0</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jfree</groupId> <groupId>org.jfree</groupId>
...@@ -196,10 +202,14 @@ ...@@ -196,10 +202,14 @@
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<filtering>true</filtering> <filtering>true</filtering>
<includes> <!-- <includes>
<include>*.xlsx</include> <include>*.xlsx</include>
<include>*</include> <include>*.properties</include>
</includes> <include>*.xml</include>
</includes>-->
<excludes>
<exclude>*.yml</exclude>
</excludes>
</resource> </resource>
<resource> <resource>
<directory>src/main/resources/templates</directory> <directory>src/main/resources/templates</directory>
......
...@@ -34,6 +34,7 @@ import org.apache.commons.io.filefilter.FalseFileFilter; ...@@ -34,6 +34,7 @@ import org.apache.commons.io.filefilter.FalseFileFilter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -124,6 +125,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -124,6 +125,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
private IPrecipriceService iPrecipriceService; private IPrecipriceService iPrecipriceService;
@Resource @Resource
private EntityEnclosureMapper entityEnclosureMapper; private EntityEnclosureMapper entityEnclosureMapper;
@Value("${weixin.systemUrl}")
private static String systemUrl;
/** /**
* 委托分页 * 委托分页
* *
...@@ -345,7 +349,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -345,7 +349,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
} }
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!"+loginUser.getName()+"向您申请了一条委托,请前往\n" + String content="你好!"+loginUser.getName()+"向您申请了一条委托,请前往\n" +
Global.systemUrl+"进行评审。"; systemUrl+"进行评审。";
System.out.println("**************************content**********************"); System.out.println("**************************content**********************");
System.out.println(content); System.out.println(content);
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
...@@ -981,7 +985,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -981,7 +985,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
logsService.saveLog(SysLogs.ObjType.ENTRUST_LOG, entrust.getId(), "发送样品处理任务", null); logsService.saveLog(SysLogs.ObjType.ENTRUST_LOG, entrust.getId(), "发送样品处理任务", null);
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!您有一条新的样品处理任务,请前往\n"+Global.systemUrl +"进行接受。"; String content="你好!您有一条新的样品处理任务,请前往\n"+systemUrl +"进行接受。";
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
} else if (query.getIsAgree() == 2) { //驳回 } else if (query.getIsAgree() == 2) { //驳回
...@@ -1493,7 +1497,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1493,7 +1497,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
logsService.saveLog(SysLogs.ObjType.ENTRUST_LOG, entrust.getId(), "派发检测项目任务", null); logsService.saveLog(SysLogs.ObjType.ENTRUST_LOG, entrust.getId(), "派发检测项目任务", null);
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!您有一条新的样品检测任务,请前往\n" + String content="你好!您有一条新的样品检测任务,请前往\n" +
Global.systemUrl +"进行接受。"; systemUrl +"进行接受。";
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
return BaseResponse.okMsg("已派发检测项目任务"); return BaseResponse.okMsg("已派发检测项目任务");
} }
...@@ -2312,7 +2316,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -2312,7 +2316,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
} }
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!"+"委托单号"+entrust.getEntrustCode()+"已校核完成,请前往\n" + String content="你好!"+"委托单号"+entrust.getEntrustCode()+"已校核完成,请前往\n" +
Global.systemUrl +"进行查看。"; systemUrl +"进行查看。";
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
} }
......
...@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -64,6 +65,8 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment ...@@ -64,6 +65,8 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
private ISysUserMessageService userMessageService; private ISysUserMessageService userMessageService;
@Autowired @Autowired
private WeiXinService weiXinService; private WeiXinService weiXinService;
@Value("${weixin.systemUrl}")
private static String systemUrl;
/** /**
* 设备分页查询 * 设备分页查询
...@@ -315,7 +318,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment ...@@ -315,7 +318,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
if(expireDate.isEqual(nowDate) || expireDate.isBefore(nowDate)){ if(expireDate.isEqual(nowDate) || expireDate.isBefore(nowDate)){
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!名称:"+eq.getName()+",编号:"+eq.getCode()+"的设备近期需要进行设备检定,如果已经检定完毕请前往\n" + String content="你好!名称:"+eq.getName()+",编号:"+eq.getCode()+"的设备近期需要进行设备检定,如果已经检定完毕请前往\n" +
Global.systemUrl+"更新检定记录。"; systemUrl+"更新检定记录。";
System.out.println("**************************content**********************"); System.out.println("**************************content**********************");
System.out.println(content); System.out.println(content);
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
......
...@@ -203,7 +203,7 @@ public class PlanConsumablesPurchaseServiceImpl extends ServiceImpl<PlanConsumab ...@@ -203,7 +203,7 @@ public class PlanConsumablesPurchaseServiceImpl extends ServiceImpl<PlanConsumab
if (pep == null) { if (pep == null) {
return BaseResponse.errorMsg("数据错误!"); return BaseResponse.errorMsg("数据错误!");
} }
pep.setTechnicalIndex(query.getImplementation()); pep.setImplementation(query.getImplementation());
pep.setStatus(1); //采购完成 pep.setStatus(1); //采购完成
consumablesPurchaseMapper.updateById(pep); consumablesPurchaseMapper.updateById(pep);
return BaseResponse.okData("采购完成"); return BaseResponse.okData("采购完成");
......
...@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -74,6 +75,8 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i ...@@ -74,6 +75,8 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
private SysApprovalMapper sysApprovalMapper; private SysApprovalMapper sysApprovalMapper;
@Autowired @Autowired
private WeiXinService weiXinService; private WeiXinService weiXinService;
@Value("${weixin.systemUrl}")
private static String systemUrl;
/** /**
...@@ -416,7 +419,7 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i ...@@ -416,7 +419,7 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
if(st.getStockNum().compareTo(st.getLeastNum())<1){ if(st.getStockNum().compareTo(st.getLeastNum())<1){
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!标样名称:"+st.getName()+",代号:"+st.getCode()+"的标样数量小于设定的最小值,新增标样数量后请及时更新系统,如果已新增完毕请前往\n" + String content="你好!标样名称:"+st.getName()+",代号:"+st.getCode()+"的标样数量小于设定的最小值,新增标样数量后请及时更新系统,如果已新增完毕请前往\n" +
Global.systemUrl+"更新标样记录。"; systemUrl+"更新标样记录。";
System.out.println("**************************content**********************"); System.out.println("**************************content**********************");
System.out.println(content); System.out.println(content);
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
...@@ -427,7 +430,7 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i ...@@ -427,7 +430,7 @@ public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> i
if(expireDate.isEqual(nowDate) || expireDate.isBefore(nowDate)){ if(expireDate.isEqual(nowDate) || expireDate.isBefore(nowDate)){
//发送企业微信消息内容 //发送企业微信消息内容
String content="你好!标样名称:"+st.getName()+",代号:"+st.getCode()+"的标样即将过期,请尽快处理,如果已经处理,请前往\n" + String content="你好!标样名称:"+st.getName()+",代号:"+st.getCode()+"的标样即将过期,请尽快处理,如果已经处理,请前往\n" +
Global.systemUrl+"更新标样记录。"; systemUrl+"更新标样记录。";
System.out.println("**************************content**********************"); System.out.println("**************************content**********************");
System.out.println(content); System.out.println(content);
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
......
...@@ -20,6 +20,7 @@ import com.google.gson.Gson; ...@@ -20,6 +20,7 @@ import com.google.gson.Gson;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -33,6 +34,17 @@ public class WeiXinService { ...@@ -33,6 +34,17 @@ public class WeiXinService {
@Autowired @Autowired
RedisUtil redisUtil; RedisUtil redisUtil;
@Value("${weixin.corpId}")
private static String corpId;
@Value("${weixin.agentId}")
private static int agentId;
@Value("${weixin.agentSecret}")
private static String agentSecret;
final static String ACCESS_TOKEN = "ACCESS_TOKEN"; final static String ACCESS_TOKEN = "ACCESS_TOKEN";
final static String JSAPITICKET = "JSAPITICKET"; final static String JSAPITICKET = "JSAPITICKET";
...@@ -145,7 +157,7 @@ public class WeiXinService { ...@@ -145,7 +157,7 @@ public class WeiXinService {
if (!redisUtil.existsKey(ACCESS_TOKEN)) { if (!redisUtil.existsKey(ACCESS_TOKEN)) {
String param = "corpid=%s&corpsecret=%s"; String param = "corpid=%s&corpsecret=%s";
param = String.format(param, Global.corpId, Global.agentSecret); param = String.format(param, corpId, agentSecret);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param); JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
accessToken = jsonObject.getString("access_token"); accessToken = jsonObject.getString("access_token");
redisUtil.setString(ACCESS_TOKEN, accessToken, 7100); redisUtil.setString(ACCESS_TOKEN, accessToken, 7100);
...@@ -226,7 +238,7 @@ public class WeiXinService { ...@@ -226,7 +238,7 @@ public class WeiXinService {
//1.2必需 //1.2必需
message.setMsgtype("text"); message.setMsgtype("text");
message.setAgentid(Global.agentId); message.setAgentid(agentId);
Text text=new Text(); Text text=new Text();
text.setContent(content); text.setContent(content);
......
...@@ -33,11 +33,12 @@ public class WeiXinUtil { ...@@ -33,11 +33,12 @@ public class WeiXinUtil {
//获取jsapi_ticket的接口地址(GET) 限200(次/天) //获取jsapi_ticket的接口地址(GET) 限200(次/天)
public final static String jsapi_ticket_url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=ACCESSTOKEN"; public final static String jsapi_ticket_url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=ACCESSTOKEN";
@Value("${weixin.corpid}") @Value("${weixin.corpId}")
private String corpid; private static String corpId;
@Value("${weixin.corpsecret}") @Value("${weixin.agentId}")
private String corpsecret; private static int agentId;
@Value("${weixin.agentSecret}")
private static String agentSecret;
...@@ -367,7 +368,7 @@ public class WeiXinUtil { ...@@ -367,7 +368,7 @@ public class WeiXinUtil {
String nonceStr = UUID.randomUUID().toString(); // 必填,生成签名的随机串 String nonceStr = UUID.randomUUID().toString(); // 必填,生成签名的随机串
//System.out.println("nonceStr:"+nonceStr); //System.out.println("nonceStr:"+nonceStr);
String accessToken=WeiXinUtil.getAccessToken(Global.corpId, Global.agentSecret).getToken(); String accessToken=WeiXinUtil.getAccessToken(corpId, agentSecret).getToken();
String jsapi_ticket =getJsapiTicket(accessToken);// 必填,生成签名的H5应用调用企业微信JS接口的临时票据 String jsapi_ticket =getJsapiTicket(accessToken);// 必填,生成签名的H5应用调用企业微信JS接口的临时票据
//System.out.println("jsapi_ticket:"+jsapi_ticket); //System.out.println("jsapi_ticket:"+jsapi_ticket);
String timestamp = Long.toString(System.currentTimeMillis() / 1000); // 必填,生成签名的时间戳 String timestamp = Long.toString(System.currentTimeMillis() / 1000); // 必填,生成签名的时间戳
...@@ -391,7 +392,7 @@ public class WeiXinUtil { ...@@ -391,7 +392,7 @@ public class WeiXinUtil {
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }
ret.put("appId", Global.corpId); ret.put("appId", corpId);
ret.put("timestamp", timestamp); ret.put("timestamp", timestamp);
ret.put("nonceStr", nonceStr); ret.put("nonceStr", nonceStr);
ret.put("signature", signature); ret.put("signature", signature);
......
...@@ -37,3 +37,31 @@ mybatis-plus: ...@@ -37,3 +37,31 @@ mybatis-plus:
check-config-location: true check-config-location: true
type-aliases-package: cn.wise.sc.cement.business.entity.** type-aliases-package: cn.wise.sc.cement.business.entity.**
mapper-locations: classpath:/cn/wise/sc/cement/business/mapper/xml/*Mapper.xml mapper-locations: classpath:/cn/wise/sc/cement/business/mapper/xml/*Mapper.xml
weixin:
corpId: ww348f91b2573c1867
agentId: 1000002
agentIdPC: 1000003
agentSecret: gFa_7XvXtCaoeAYERzjRwwz_OTJkJfgBb8weOKjmI3o
agentSecretPC: itCLYcwl9ggA9VfZam_iz96Ikp9StDFfVr4Adb0yY7A
backUrl: https%3a%2f%2fccdcmtl.sinoma-tianjin.com%2flab-system
systemUrl: <a href=\"https://open.weixin.qq.com/connect/oauth2/authorize?appid="ww348f91b2573c1867"&redirect_uri="https%3a%2f%2fccdcmtl.sinoma-tianjin.com%2flab-system"%2f&response_type=code&scope=snsapi_base&state=#wechat_redirect\">物化检测流程" + "</a>,
...@@ -5,7 +5,7 @@ spring: ...@@ -5,7 +5,7 @@ spring:
application: tianjin-cement application: tianjin-cement
profiles: profiles:
# 启动命令加上 -Dspring.config.location={文件路径}\config\application.yml # 启动命令加上 -Dspring.config.location={文件路径}\config\application.yml
path: {文件夹路径}/config path: D:/idea_workspases/tianjin-cement/config
active: dev active: dev
datasource: datasource:
# 192.168.110.85 admin!@#123 # 192.168.110.85 admin!@#123
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment