|
@@ -65,6 +65,9 @@ public class InformationReportingController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SubscribeMessagesService subscribeMessagesService;
|
|
private SubscribeMessagesService subscribeMessagesService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WxController wxController;
|
|
|
|
|
+
|
|
|
@Value("${wx.app_id}")
|
|
@Value("${wx.app_id}")
|
|
|
private String appID;
|
|
private String appID;
|
|
|
|
|
|
|
@@ -74,18 +77,18 @@ public class InformationReportingController {
|
|
|
@Value("${wx.template_id}")
|
|
@Value("${wx.template_id}")
|
|
|
private String template_id;
|
|
private String template_id;
|
|
|
|
|
|
|
|
- private String access_token = "";
|
|
|
|
|
|
|
+ private WxController access_token_inf = new WxController();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 信息上传
|
|
* 信息上传
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/add")
|
|
@PostMapping("/add")
|
|
|
- public CommonResult<String> add(@Valid @RequestBody InformationReportingVO staffEntity) throws IOException{
|
|
|
|
|
|
|
+ public CommonResult<String> add(@Valid @RequestBody InformationReportingVO staffEntity) throws IOException {
|
|
|
|
|
|
|
|
String product = StringUtils.join(Arrays.asList(staffEntity.getBProduct()), ',');
|
|
String product = StringUtils.join(Arrays.asList(staffEntity.getBProduct()), ',');
|
|
|
staffEntity.setProduct(product);
|
|
staffEntity.setProduct(product);
|
|
|
|
|
|
|
|
- if (staffEntity.getBFile().length != 0){
|
|
|
|
|
|
|
+ if (staffEntity.getBFile().length != 0) {
|
|
|
String file = StringUtils.join(Arrays.asList(staffEntity.getBFile()), ',');
|
|
String file = StringUtils.join(Arrays.asList(staffEntity.getBFile()), ',');
|
|
|
staffEntity.setFile(file);
|
|
staffEntity.setFile(file);
|
|
|
}
|
|
}
|
|
@@ -102,6 +105,8 @@ public class InformationReportingController {
|
|
|
//String openid = getOpenId(staffEntity.getCode());
|
|
//String openid = getOpenId(staffEntity.getCode());
|
|
|
String openid = getOpenidByCode(staffEntity.getCode());
|
|
String openid = getOpenidByCode(staffEntity.getCode());
|
|
|
|
|
|
|
|
|
|
+ System.out.println("add方法里从wx拿到的openid:"+ openid);
|
|
|
|
|
+
|
|
|
reporting.setOpenid(openid);
|
|
reporting.setOpenid(openid);
|
|
|
|
|
|
|
|
boolean flag = informationReportingService.save(reporting);
|
|
boolean flag = informationReportingService.save(reporting);
|
|
@@ -145,7 +150,7 @@ public class InformationReportingController {
|
|
|
@AdminLoginCheck
|
|
@AdminLoginCheck
|
|
|
@DeleteMapping("/close")
|
|
@DeleteMapping("/close")
|
|
|
public CommonResult<String> close(@RequestHeader("admin_token") String adminToken,
|
|
public CommonResult<String> close(@RequestHeader("admin_token") String adminToken,
|
|
|
- @RequestBody CloseReporting reporting) {
|
|
|
|
|
|
|
+ @RequestBody CloseReporting reporting) {
|
|
|
|
|
|
|
|
InformationReporting reporting1 = new InformationReporting();
|
|
InformationReporting reporting1 = new InformationReporting();
|
|
|
reporting1.setId(reporting.getItemId());
|
|
reporting1.setId(reporting.getItemId());
|
|
@@ -162,9 +167,8 @@ public class InformationReportingController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author Astrid Wang
|
|
* @author Astrid Wang
|
|
|
- *
|
|
|
|
|
|
|
+ * <p>
|
|
|
* 有效
|
|
* 有效
|
|
|
- *
|
|
|
|
|
*/
|
|
*/
|
|
|
@AdminLoginCheck
|
|
@AdminLoginCheck
|
|
|
@DeleteMapping("/valid")
|
|
@DeleteMapping("/valid")
|
|
@@ -182,7 +186,14 @@ public class InformationReportingController {
|
|
|
|
|
|
|
|
//向方法传入openid、ps、title
|
|
//向方法传入openid、ps、title
|
|
|
String ps = reporting.getPs();
|
|
String ps = reporting.getPs();
|
|
|
- String a = send(openid,ps,"项目有效");
|
|
|
|
|
|
|
+ if (ps.equals("")) {
|
|
|
|
|
+ String a = send(openid, "无备注", "项目有效");
|
|
|
|
|
+ System.out.println("备注为:" + ps);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ String a = send(openid, ps, "项目有效");
|
|
|
|
|
+ System.out.println("备注为:" + ps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//System.out.println(ps);
|
|
//System.out.println(ps);
|
|
|
//System.out.println(a);
|
|
//System.out.println(a);
|
|
@@ -206,14 +217,13 @@ public class InformationReportingController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author Astrid Wang
|
|
* @author Astrid Wang
|
|
|
- *
|
|
|
|
|
|
|
+ * <p>
|
|
|
* 失效
|
|
* 失效
|
|
|
- *
|
|
|
|
|
*/
|
|
*/
|
|
|
@AdminLoginCheck
|
|
@AdminLoginCheck
|
|
|
@DeleteMapping("/invalid")
|
|
@DeleteMapping("/invalid")
|
|
|
public CommonResult<String> invalid(@RequestHeader("admin_token") String adminToken,
|
|
public CommonResult<String> invalid(@RequestHeader("admin_token") String adminToken,
|
|
|
- @RequestBody ValidReporting reporting) {
|
|
|
|
|
|
|
+ @RequestBody ValidReporting reporting) {
|
|
|
|
|
|
|
|
/*//根据 项目id 查询 openid
|
|
/*//根据 项目id 查询 openid
|
|
|
QueryWrapper<SubscribeMessages> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<SubscribeMessages> queryWrapper = new QueryWrapper<>();
|
|
@@ -233,7 +243,14 @@ public class InformationReportingController {
|
|
|
|
|
|
|
|
//向方法传入openid、ps、title
|
|
//向方法传入openid、ps、title
|
|
|
String ps = reporting.getPs();
|
|
String ps = reporting.getPs();
|
|
|
- String a = send(openid,ps,"项目失效");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (ps.equals("")) {
|
|
|
|
|
+ String a = send(openid, "无备注", "项目无效");
|
|
|
|
|
+ System.out.println("备注为:" + ps);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ String a = send(openid, ps, "项目无效");
|
|
|
|
|
+ System.out.println("备注为:" + ps);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//System.out.println(ps);
|
|
//System.out.println(ps);
|
|
|
//System.out.println(a);
|
|
//System.out.println(a);
|
|
@@ -254,44 +271,24 @@ public class InformationReportingController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 获取access_token
|
|
|
|
|
- //@Scheduled(cron = "0 59 0/1 * * ?") // 每1小时59分,执行一次刷新access_token
|
|
|
|
|
- public void getAccessToken() {
|
|
|
|
|
-
|
|
|
|
|
- String url = "https://api.weixin.qq.com/cgi-bin/token?" +
|
|
|
|
|
- "grant_type=client_credential" +
|
|
|
|
|
- "&appid=" + appID +
|
|
|
|
|
- "&secret=" + secret;
|
|
|
|
|
-
|
|
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
-
|
|
|
|
|
- ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
|
|
|
|
|
- JSONObject objParam = JSON.parseObject(responseEntity.getBody());
|
|
|
|
|
-
|
|
|
|
|
- for (Map.Entry<String, Object> entry : objParam.entrySet()) {
|
|
|
|
|
- Object o = entry.getValue();
|
|
|
|
|
- if (o instanceof String) {
|
|
|
|
|
- if (entry.getKey().equals("access_token")) {
|
|
|
|
|
- access_token = (String) entry.getValue();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 小程序订阅消息
|
|
* 小程序订阅消息
|
|
|
*/
|
|
*/
|
|
|
- public String send(String openid,String ps,String title){
|
|
|
|
|
|
|
+ public String send(String openid, String ps, String title) {
|
|
|
|
|
|
|
|
// access_token是存在有效期的,过期就刷新
|
|
// access_token是存在有效期的,过期就刷新
|
|
|
- if (access_token.equals("")) {
|
|
|
|
|
- getAccessToken();
|
|
|
|
|
|
|
+ if (access_token_inf.access_token.equals("")) {
|
|
|
|
|
+ wxController.getAccessToken();
|
|
|
|
|
+// getAccessToken();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ System.out.println("订阅消息接口里的access_token_inf: " + wxController.access_token);
|
|
|
|
|
+
|
|
|
JSONObject message = new JSONObject();
|
|
JSONObject message = new JSONObject();
|
|
|
message.put("touser", openid);
|
|
message.put("touser", openid);
|
|
|
message.put("template_id", template_id);
|
|
message.put("template_id", template_id);
|
|
|
- message.put("page", "index");
|
|
|
|
|
|
|
+ //message.put("page", "");
|
|
|
message.put("miniprogram_state", "formal");
|
|
message.put("miniprogram_state", "formal");
|
|
|
message.put("lang", "zh_CN");
|
|
message.put("lang", "zh_CN");
|
|
|
|
|
|
|
@@ -300,26 +297,28 @@ public class InformationReportingController {
|
|
|
// 审核结果
|
|
// 审核结果
|
|
|
JSONObject thing1 = new JSONObject();
|
|
JSONObject thing1 = new JSONObject();
|
|
|
thing1.put("value", title);//变为title
|
|
thing1.put("value", title);//变为title
|
|
|
|
|
+
|
|
|
// 备注
|
|
// 备注
|
|
|
JSONObject thing5 = new JSONObject();
|
|
JSONObject thing5 = new JSONObject();
|
|
|
thing5.put("value", ps);
|
|
thing5.put("value", ps);
|
|
|
|
|
|
|
|
// 审核结果
|
|
// 审核结果
|
|
|
- data.put("thing1",thing1);
|
|
|
|
|
|
|
+ data.put("thing1", thing1);
|
|
|
// 备注
|
|
// 备注
|
|
|
- data.put("thing5",thing5);
|
|
|
|
|
|
|
+ data.put("thing5", thing5);
|
|
|
|
|
|
|
|
message.put("data", data);
|
|
message.put("data", data);
|
|
|
System.out.println(message);
|
|
System.out.println(message);
|
|
|
- return HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+access_token, message);
|
|
|
|
|
|
|
+ return HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + access_token_inf.access_token, message);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String getOpenId(String code) throws IOException {
|
|
public String getOpenId(String code) throws IOException {
|
|
|
|
|
|
|
|
// access_token是存在有效期的,过期就刷新
|
|
// access_token是存在有效期的,过期就刷新
|
|
|
- if (access_token.equals("")) {
|
|
|
|
|
- getAccessToken();
|
|
|
|
|
|
|
+ if (access_token_inf.access_token.equals("")) {
|
|
|
|
|
+ wxController.getAccessToken();
|
|
|
}
|
|
}
|
|
|
|
|
+ System.out.println("access_token_inf: " + wxController.access_token);
|
|
|
// 构造请求URL
|
|
// 构造请求URL
|
|
|
//String requestUrl = OPENID_URL + "?appid=" + appID + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code";
|
|
//String requestUrl = OPENID_URL + "?appid=" + appID + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code";
|
|
|
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code";
|
|
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code";
|
|
@@ -357,6 +356,7 @@ public class InformationReportingController {
|
|
|
|
|
|
|
|
public String getOpenidByCode(String code) {
|
|
public String getOpenidByCode(String code) {
|
|
|
//页面获取openId接口
|
|
//页面获取openId接口
|
|
|
|
|
+
|
|
|
String getopenid_url = "https://api.weixin.qq.com/sns/jscode2session";
|
|
String getopenid_url = "https://api.weixin.qq.com/sns/jscode2session";
|
|
|
|
|
|
|
|
|
|
|