|
@ -68,64 +68,21 @@ import static javax.xml.bind.JAXBIntrospector.getValue; |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("v1/wechat") |
|
|
@RequestMapping("v1/wechat") |
|
|
public class WechatRest { |
|
|
public class WechatRest { |
|
|
static final long APP_LOGIN_CODE_TIME_LIMIT = 300L; |
|
|
|
|
|
private static final String WX_URL_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"; |
|
|
|
|
|
private static final String WX_URL_MESSAGE_SEND = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN"; |
|
|
|
|
|
private static final String WX_URL_MESSAGE_BIZ_SEND ="https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token=ACCESS_TOKEN"; |
|
|
|
|
|
private static final String APP_ID="wx1d44e0fcd110351a"; |
|
|
|
|
|
private static final String APP_ID_BIZ="wxc64c6cf0a06880e5"; |
|
|
|
|
|
private static final String APPSECRET="4764e32722a7d98656dea6afd9405701"; |
|
|
|
|
|
private static final String APPSECRETBIZ="eb3a0794da05f12a94c92134030246f1"; |
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
WechatService wechatService; |
|
|
WechatService wechatService; |
|
|
@Autowired |
|
|
|
|
|
private CsmCashReportMapper csmCashReportMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ReportInventoryDayGatherMapper reportInventoryDayGatherMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
MessagePushLogService messagePushLogService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
StockDayRest stockDayRest; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
com.yxt.supervise.report.ds.system.systemMapper systemMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
CrmMapper crmMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
ProjectDailyService projectDailyService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
RedisUtil redisUtil; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
WarehouseMapper warehouseMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
RmsMapper rmsMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
ImgMessagesLogMapper imgMessagesLogMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
RiskMessagesLogMapper riskMessagesLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("token") |
|
|
@ApiOperation("token") |
|
|
@GetMapping(value = "token") |
|
|
@GetMapping(value = "token") |
|
|
public String wechate(String signature,String timestamp,String nonce,String echostr){ |
|
|
public String wechate(String signature,String timestamp,String nonce,String echostr){ |
|
|
String token=""; |
|
|
return wechatService.wechate(signature,timestamp,nonce,echostr); |
|
|
if (signature != null && WeixinCheckoutUtil.checkSignature(signature, timestamp, nonce)) { |
|
|
|
|
|
token=wechatService.push(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return token; |
|
|
|
|
|
} |
|
|
} |
|
|
@GetMapping(value = "authGet",produces = "text/plain;charset=utf-8") |
|
|
@GetMapping(value = "authGet",produces = "text/plain;charset=utf-8") |
|
|
public String authGet(@RequestParam(name = "signature", required = false) String signature, |
|
|
public String authGet(@RequestParam(name = "signature", required = false) String signature, |
|
|
@RequestParam(name = "timestamp", required = false) String timestamp, |
|
|
@RequestParam(name = "timestamp", required = false) String timestamp, |
|
|
@RequestParam(name = "nonce", required = false) String nonce, |
|
|
@RequestParam(name = "nonce", required = false) String nonce, |
|
|
@RequestParam(name = "echostr", required = false) String echostr) { |
|
|
@RequestParam(name = "echostr", required = false) String echostr) { |
|
|
|
|
|
return wechatService.authGet(signature,timestamp,nonce,echostr); |
|
|
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) { |
|
|
|
|
|
throw new IllegalArgumentException("请求参数非法,请核实!"); |
|
|
|
|
|
} |
|
|
|
|
|
if (WeixinCheckoutUtil.checkSignature( signature, timestamp, nonce)) { |
|
|
|
|
|
return echostr; |
|
|
|
|
|
} |
|
|
|
|
|
return "非法请求"; |
|
|
|
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
|
* 回款审核 |
|
|
* 回款审核 |
|
@ -134,76 +91,7 @@ public class WechatRest { |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/collectionSendMessage/{projectSid}/{orderDate}") |
|
|
@PostMapping("/collectionSendMessage/{projectSid}/{orderDate}") |
|
|
public void collectionSendMessage(@PathVariable String projectSid,@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
public void collectionSendMessage(@PathVariable String projectSid,@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
CsmCashReportVo csmCashReportVo=csmCashReportMapper.getCsmCashReport(orderDate); |
|
|
wechatService.collectionSendMessage(projectSid,orderDate); |
|
|
List<String> user= crmMapper.suerList(projectSid); |
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
SysUser sysUser=systemMapper.getAppletOpenidByUsersid(u); |
|
|
|
|
|
if(null!=sysUser){ |
|
|
|
|
|
if(com.yxt.common.base.utils.StringUtils.isNotNull(sysUser.getAppletOpenid())){ |
|
|
|
|
|
openIds.add(sysUser.getAppletOpenid()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
ProjectDaily projectDaily=projectDailyService.fetchByProjectAndDay(projectSid,orderDate); |
|
|
|
|
|
// 模板参数
|
|
|
|
|
|
Map<String, String> sendMag = new HashMap<String, String>(); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
String templateId = "BT6BHEojCmgWNTcpz1raHNIpJEEISP1E134btP51p_8"; |
|
|
|
|
|
//微信的基础accessToken
|
|
|
|
|
|
String accessToken=getAccessToken(APP_ID_BIZ,APPSECRETBIZ); |
|
|
|
|
|
String wxUrl = WX_URL_MESSAGE_SEND.replace("ACCESS_TOKEN", accessToken); |
|
|
|
|
|
String pa=""; |
|
|
|
|
|
JSONObject jsonObject=new JSONObject(); |
|
|
|
|
|
List<MessageOpenidDto> list=new ArrayList<>(); |
|
|
|
|
|
for(String openId:openIds){ |
|
|
|
|
|
MessageOpenidDto dto=new MessageOpenidDto(); |
|
|
|
|
|
dto.setOpenId(openId); |
|
|
|
|
|
list.add(dto); |
|
|
|
|
|
// sendMag.put("time1", new Template(csmCashReportVo.getReportDate()));
|
|
|
|
|
|
// sendMag.put("thing2", new Template("36524每日回款审核报告"));
|
|
|
|
|
|
// sendMag.put("thing3", new Template("赵丽晓"));
|
|
|
|
|
|
sendMag.put("time1", csmCashReportVo.getReportDate()); |
|
|
|
|
|
sendMag.put("thing2", "36524每日回款审核报告"); |
|
|
|
|
|
sendMag.put("thing3", "赵丽晓"); |
|
|
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
|
|
//云眼
|
|
|
|
|
|
// miniprogram.put("appid","wx11565021714ba796");
|
|
|
|
|
|
//云仓
|
|
|
|
|
|
miniprogram.put("appid","wx05604ce2a8bede05");//wx65c2b78fd1452eeb
|
|
|
|
|
|
miniprogram.put("pagepath","pages/index/auditReport?dataDate="+csmCashReportVo.getDataDate()+"&"+"companyName="+csmCashReportVo.getCompanyName()); |
|
|
|
|
|
pa=miniprogram.get("pagepath"); |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
//拼接base参数
|
|
|
|
|
|
Map<String, Object> sendBody = new HashMap<>(); |
|
|
|
|
|
sendBody.put("miniprogram",miniprogram); |
|
|
|
|
|
sendBody.put("touser", openId); // openId
|
|
|
|
|
|
sendBody.put("url", ""); // 点击模板信息跳转地址
|
|
|
|
|
|
sendBody.put("topcolor", "#FF0000"); // 顶色
|
|
|
|
|
|
sendBody.put("data", sendMag); // 模板参数
|
|
|
|
|
|
sendBody.put("template_id", templateId);// 模板Id
|
|
|
|
|
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(wxUrl, sendBody, String.class); |
|
|
|
|
|
jsonObject = JSONObject.parseObject(forEntity.getBody()); |
|
|
|
|
|
} |
|
|
|
|
|
// 0
|
|
|
|
|
|
String messageCode = jsonObject.getString("errcode"); |
|
|
|
|
|
// 2431260672639467520
|
|
|
|
|
|
String msgId = jsonObject.getString("msgid"); |
|
|
|
|
|
System.out.println("messageCode : " + messageCode + ", msgId: " +msgId); |
|
|
|
|
|
//推送消息之后保存消息日志
|
|
|
|
|
|
MessagePushLogDto logDto=new MessagePushLogDto(); |
|
|
|
|
|
logDto.setContent(sendMag); |
|
|
|
|
|
logDto.setMessageTime(csmCashReportVo.getDataDate()); |
|
|
|
|
|
logDto.setPagepath(pa); |
|
|
|
|
|
// logDto.setMessageOpenids(list);
|
|
|
|
|
|
ThreadUtil.execute(() -> { |
|
|
|
|
|
try { |
|
|
|
|
|
messagePushLogService.save(logDto); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
//return forEntity.getBody();
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -213,77 +101,7 @@ public class WechatRest { |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/inventorySendMessage/{orderDate}") |
|
|
@PostMapping("/inventorySendMessage/{orderDate}") |
|
|
public void inventorySendMessage(@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
public void inventorySendMessage(@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
List<String>user= crmMapper.suerList("983eefd8-6109-4e8e-bc1b-71e16e644170"); |
|
|
wechatService.inventorySendMessage(orderDate); |
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
openIds.add(systemMapper.getOpenId(u)); |
|
|
|
|
|
} |
|
|
|
|
|
ReportInventoryDayGatherVo csmCashReportVo=reportInventoryDayGatherMapper.getReportInventoryDayGather(orderDate); |
|
|
|
|
|
// 模板参数
|
|
|
|
|
|
Map<String, Template> sendMag = new HashMap<String, Template>(); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
String templateId = "BT6BHEojCmgWNTcpz1raHNIpJEEISP1E134btP51p_8"; |
|
|
|
|
|
//微信的基础accessToken
|
|
|
|
|
|
String accessToken=getAccessToken(APP_ID_BIZ,APPSECRETBIZ); |
|
|
|
|
|
System.out.println("accessToken"+accessToken); |
|
|
|
|
|
String wxUrl = WX_URL_MESSAGE_SEND.replace("ACCESS_TOKEN", accessToken); |
|
|
|
|
|
// List<String> openIds=new ArrayList<>();
|
|
|
|
|
|
// openIds.add("oGdho60xVtWEXUks7nYEAn0tGlDE");
|
|
|
|
|
|
// openIds.add("oGdho66394A-4-NyumcJ1MEaT8Lo");
|
|
|
|
|
|
// openIds.add("oGdho68CArVhC_-7ELkG-jX21ruk");
|
|
|
|
|
|
// openIds.add("oGdho6yYB47f52HVk2NqirrFbRRk");
|
|
|
|
|
|
// openIds.add("oGdho6-12-ioAKeLhVUDYPucbDb4");
|
|
|
|
|
|
// openIds.add("oGdho668Hew45t0xfBJC84TNGVzI");
|
|
|
|
|
|
// openIds.add("oGdho624Cr3j_iZBj-0_HayKLNc4");
|
|
|
|
|
|
// openIds.add("oGdho6-LvwNY6KylgMlEG0C_JMmQ");
|
|
|
|
|
|
String pa=""; |
|
|
|
|
|
JSONObject jsonObject=new JSONObject(); |
|
|
|
|
|
List<MessageOpenidDto> list=new ArrayList<>(); |
|
|
|
|
|
for(String openId:openIds){ |
|
|
|
|
|
MessageOpenidDto dto=new MessageOpenidDto(); |
|
|
|
|
|
dto.setOpenId(openId); |
|
|
|
|
|
list.add(dto); |
|
|
|
|
|
sendMag.put("time1", new Template(csmCashReportVo.getOrderDate())); |
|
|
|
|
|
sendMag.put("thing2", new Template("36524质物库存汇总")); |
|
|
|
|
|
sendMag.put("thing3", new Template("赵丽晓")); |
|
|
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
|
|
//云眼
|
|
|
|
|
|
// miniprogram.put("appid","wx11565021714ba796");
|
|
|
|
|
|
//云仓
|
|
|
|
|
|
miniprogram.put("appid","wx05604ce2a8bede05");//wx65c2b78fd1452eeb
|
|
|
|
|
|
miniprogram.put("pagepath","pages/index/demoReportKc?orderDate="+csmCashReportVo.getOrderDate()); |
|
|
|
|
|
pa=miniprogram.get("pagepath"); |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
//拼接base参数
|
|
|
|
|
|
Map<String, Object> sendBody = new HashMap<>(); |
|
|
|
|
|
sendBody.put("miniprogram",miniprogram); |
|
|
|
|
|
sendBody.put("touser", openId); // openId
|
|
|
|
|
|
sendBody.put("url", ""); // 点击模板信息跳转地址
|
|
|
|
|
|
sendBody.put("topcolor", "#FF0000"); // 顶色
|
|
|
|
|
|
sendBody.put("data", sendMag); // 模板参数
|
|
|
|
|
|
sendBody.put("template_id", templateId);// 模板Id
|
|
|
|
|
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(wxUrl, sendBody, String.class); |
|
|
|
|
|
jsonObject = JSONObject.parseObject(forEntity.getBody()); |
|
|
|
|
|
} |
|
|
|
|
|
// 0
|
|
|
|
|
|
String messageCode = jsonObject.getString("errcode"); |
|
|
|
|
|
// 2431260672639467520
|
|
|
|
|
|
String msgId = jsonObject.getString("msgid"); |
|
|
|
|
|
System.out.println("messageCode : " + messageCode + ", msgId: " +msgId); |
|
|
|
|
|
//推送消息之后保存消息日志
|
|
|
|
|
|
// MessagePushLogDto logDto=new MessagePushLogDto();
|
|
|
|
|
|
// logDto.setContent(sendMag);
|
|
|
|
|
|
// logDto.setMessageTime(csmCashReportVo.getReportTime());
|
|
|
|
|
|
// logDto.setPagepath(pa);
|
|
|
|
|
|
// logDto.setMessageOpenidDtos(list);
|
|
|
|
|
|
// ThreadUtil.execute(() -> {
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// messagePushLogService.save(logDto);
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
//return forEntity.getBody();
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -293,24 +111,7 @@ public class WechatRest { |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/SendMessage/{projectSid}/{orderDate}") |
|
|
@PostMapping("/SendMessage/{projectSid}/{orderDate}") |
|
|
public void sendMessage(@PathVariable("projectSid") String projectSid,@PathVariable("orderDate") String orderDate){ |
|
|
public void sendMessage(@PathVariable("projectSid") String projectSid,@PathVariable("orderDate") String orderDate){ |
|
|
RespMessReturn r=new RespMessReturn(); |
|
|
wechatService.sendMessage(projectSid,orderDate); |
|
|
// List<String> user= crmMapper.suerList(projectSid);
|
|
|
|
|
|
List<String> user= getUser(projectSid,"1"); |
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
String sysUser=systemMapper.getOpenId(u); |
|
|
|
|
|
if(null!=sysUser) { |
|
|
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotNull(sysUser)) { |
|
|
|
|
|
openIds.add(sysUser); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
ProjectDaily projectDaily=projectDailyService.fetchByProjectAndDay(projectSid,orderDate); |
|
|
|
|
|
// ProjectInfo projectInfo =crmMapper.getProjectNameBySid(projectSid);
|
|
|
|
|
|
ProjectInfo projectInfo=crmMapper.selectOne(new QueryWrapper<ProjectInfo>().eq("sid",projectSid)); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
r= SuperviseWxMessSender.jgsjzlSend(projectInfo.getRegulatoryLeader(),openIds,projectSid,projectDaily.getProjectName(),projectDaily.getReportTime()); |
|
|
|
|
|
System.out.println(r); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -320,30 +121,7 @@ public class WechatRest { |
|
|
*/ |
|
|
*/ |
|
|
@GetMapping("/shMessage") |
|
|
@GetMapping("/shMessage") |
|
|
public void shMessage(@RequestParam("shSid") String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
public void shMessage(@RequestParam("shSid") String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
//String messSid=riskMessagesLogMapper.getRiskByCode();
|
|
|
wechatService.shMessage(shSid,riskSid); |
|
|
RespMessReturn r=new RespMessReturn(); |
|
|
|
|
|
String projectSid=crmMapper.ProjectSidByshSid(shSid); |
|
|
|
|
|
List<String> user= getUser(projectSid,"2"); |
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
List<String> mobiles=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
SysUser sysUser=systemMapper.getAppletOpenidByUsersid(u); |
|
|
|
|
|
if(null!=sysUser) { |
|
|
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotNull(sysUser.getOpenId())) { |
|
|
|
|
|
openIds.add(sysUser.getOpenId()); |
|
|
|
|
|
mobiles.add(sysUser.getMobile()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String shName=warehouseMapper.getNameBySid(shSid); |
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
RiskAlarm riskAlarm=rmsMapper.getRiskByMessSid(riskSid); |
|
|
|
|
|
String name =cl(riskAlarm.getContent()); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
//sendVerificationCode(name,mobiles,"030404");
|
|
|
|
|
|
System.out.println("推送中"); |
|
|
|
|
|
r= SuperviseWxMessSender.jkSend(openIds,projectSid,riskSid,name,shName,riskSid,ft.format(new Date())); |
|
|
|
|
|
System.out.println(r); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -353,213 +131,27 @@ public class WechatRest { |
|
|
*/ |
|
|
*/ |
|
|
@GetMapping("/secureMessage") |
|
|
@GetMapping("/secureMessage") |
|
|
public void secureMessage(@RequestParam("shSid") String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
public void secureMessage(@RequestParam("shSid") String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
//String messSid=riskMessagesLogMapper.getRiskByCode();
|
|
|
wechatService.secureMessage(shSid,riskSid); |
|
|
RespMessReturn r=new RespMessReturn(); |
|
|
|
|
|
// List<UserProject> user= crmMapper.users(shSid);
|
|
|
|
|
|
String projectSid=crmMapper.ProjectSidByshSid(shSid); |
|
|
|
|
|
List<String> user= getUser(projectSid,"3"); |
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
List<String> mobiles=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
SysUser sysUser=systemMapper.getAppletOpenidByUsersid(u); |
|
|
|
|
|
if(null!=sysUser) { |
|
|
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotNull(sysUser.getOpenId())) { |
|
|
|
|
|
openIds.add(sysUser.getOpenId()); |
|
|
|
|
|
mobiles.add(sysUser.getMobile()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String shName=warehouseMapper.getNameBySid(shSid); |
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
RiskAlarm riskAlarm=rmsMapper.getRiskByMessSid(riskSid); |
|
|
|
|
|
String name =cl(riskAlarm.getContent()); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
//sendVerificationCode(name,mobiles,"030404");
|
|
|
|
|
|
System.out.println("推送中"); |
|
|
|
|
|
r= SuperviseWxMessSender.secureSend(openIds,projectSid,riskSid,name,shName,riskSid,ft.format(new Date())); |
|
|
|
|
|
System.out.println(r); |
|
|
|
|
|
} |
|
|
} |
|
|
@Test |
|
|
|
|
|
public String cl (String w){ |
|
|
|
|
|
String a=""; |
|
|
|
|
|
//String w="[Device(name=东北角的摄像头, serialNumber=L28475439, status=断网), Device(name=111, serialNumber=L28475439, status=断网), Device(name=22, serialNumber=L28475439, status=断网), Device(name=33, serialNumber=L28475439, status=断网),Device(name=东北角的摄像头, serialNumber=L28475439, status=断网),Device(name=东北角的摄像头, serialNumber=L28475439, status=断网),Device(name=东北角的摄像头, serialNumber=L28475439, status=断网),Device(name=东北角的摄像头, serialNumber=L28475439, status=断网)]";
|
|
|
|
|
|
String st=w.substring(1, (w.length() - 1)); |
|
|
|
|
|
String [] str2 = st.split("Device"); |
|
|
|
|
|
// List<Device> list=new ArrayList<>();
|
|
|
|
|
|
for (int i = 0; i < str2.length; i++) { |
|
|
|
|
|
String item = str2[i]; |
|
|
|
|
|
if(com.yxt.common.base.utils.StringUtils.isNotEmpty(item)){ |
|
|
|
|
|
// Device device=new Device();
|
|
|
|
|
|
String [] str3 = item.split(", "); |
|
|
|
|
|
// device.setName(str3[0].substring(6));
|
|
|
|
|
|
// device.setSerialNumber(str3[1].substring(13));
|
|
|
|
|
|
// device.setStatus(str3[2].substring(7,str3[2].length()-1));
|
|
|
|
|
|
String name=str3[0].substring(6); |
|
|
|
|
|
if(StringUtils.isEmpty(a)){ |
|
|
|
|
|
a=a+name; |
|
|
|
|
|
}else { |
|
|
|
|
|
a=a+","+name; |
|
|
|
|
|
} |
|
|
|
|
|
// list.add(device);
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(a.length()>=20){ |
|
|
|
|
|
a=a.substring(0,19)+"…"; |
|
|
|
|
|
} |
|
|
|
|
|
System.out.println(a.length()); |
|
|
|
|
|
System.out.println(a); |
|
|
|
|
|
|
|
|
|
|
|
return a; |
|
|
/** |
|
|
} |
|
|
* 图片对比消息推送 |
|
|
|
|
|
* @param shSid |
|
|
|
|
|
* @param riskSid |
|
|
|
|
|
*/ |
|
|
@GetMapping("/shImgMessage") |
|
|
@GetMapping("/shImgMessage") |
|
|
public void shImgMessage(@RequestParam("shSid") String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
public void shImgMessage(@RequestParam("shSid") String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
//String messSid=imgMessagesLogMapper.getImgRiskByCode();
|
|
|
wechatService.shImgMessage(shSid,riskSid); |
|
|
RespMessReturn r=new RespMessReturn(); |
|
|
|
|
|
String projectSid=crmMapper.ProjectSidByshSid(shSid); |
|
|
|
|
|
List<String> user= getUser(projectSid,"4"); |
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
List<String> mobiles=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
SysUser sysUser=systemMapper.getAppletOpenidByUsersid(u); |
|
|
|
|
|
if(null!=sysUser) { |
|
|
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotNull(sysUser.getOpenId())) { |
|
|
|
|
|
openIds.add(sysUser.getOpenId()); |
|
|
|
|
|
mobiles.add(sysUser.getMobile()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String name=warehouseMapper.getNameBySid(shSid); |
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
//sendVerificationCode(name,mobiles,"030405");
|
|
|
|
|
|
r= SuperviseWxMessSender.jkImgSend("赵丽晓",openIds,projectSid,riskSid,name,riskSid,ft.format(new Date())); |
|
|
|
|
|
System.out.println(r); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 系统异常消息 |
|
|
|
|
|
* @param shSid |
|
|
|
|
|
* @param riskSid |
|
|
|
|
|
*/ |
|
|
@GetMapping("/sysErrMessage") |
|
|
@GetMapping("/sysErrMessage") |
|
|
public void sysErrMessage(@RequestParam("shSid")String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
public void sysErrMessage(@RequestParam("shSid")String shSid,@RequestParam("riskSid") String riskSid){ |
|
|
//String messSid=imgMessagesLogMapper.getImgRiskByCode();
|
|
|
wechatService.sysErrMessage(shSid,riskSid); |
|
|
RespMessReturn r=new RespMessReturn(); |
|
|
|
|
|
// List<UserProject> user= getUser(shSid);
|
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
List<String> mobiles=new ArrayList<>(); |
|
|
|
|
|
openIds.add("oGdho60xVtWEXUks7nYEAn0tGlDE"); |
|
|
|
|
|
mobiles.add("15932270269"); |
|
|
|
|
|
openIds.add("oGdho66394A-4-NyumcJ1MEaT8Lo"); |
|
|
|
|
|
mobiles.add("18603312020"); |
|
|
|
|
|
openIds.add("oGdho615_xBMYYwftEjjBlC6p2uE"); |
|
|
|
|
|
mobiles.add("13513219196"); |
|
|
|
|
|
openIds.add("oGdho6yYB47f52HVk2NqirrFbRRk"); |
|
|
|
|
|
mobiles.add("13513211777"); |
|
|
|
|
|
openIds.add("oGdho668Hew45t0xfBJC84TNGVzI"); |
|
|
|
|
|
mobiles.add("13623307393"); |
|
|
|
|
|
openIds.add("oGdho68CArVhC_-7ELkG-jX21ruk"); |
|
|
|
|
|
mobiles.add("13131170271"); |
|
|
|
|
|
openIds.add("oGdho69VxJil_NRxv9StYVpQg58U"); |
|
|
|
|
|
mobiles.add("13333113292"); |
|
|
|
|
|
openIds.add("oGdho66Wy-Or1UeqoNHU1YL5yAEM"); |
|
|
|
|
|
mobiles.add("19933133338"); |
|
|
|
|
|
// for(UserProject u:user){
|
|
|
|
|
|
// SysUser sysUser=systemMapper.getAppletOpenidByUsersid(u.getUserSid());
|
|
|
|
|
|
// if(null!=sysUser) {
|
|
|
|
|
|
// if (com.yxt.common.base.utils.StringUtils.isNotNull(sysUser.getAppletOpenid())) {
|
|
|
|
|
|
// openIds.add(sysUser.getAppletOpenid());
|
|
|
|
|
|
// mobiles.add(sysUser.getMobile());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
String projectSid=crmMapper.ProjectSidByshSid(shSid); |
|
|
|
|
|
String name=warehouseMapper.getNameBySid(shSid); |
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
//sendVerificationCode(name,mobiles,"030405");
|
|
|
|
|
|
r= SuperviseWxMessSender.sysErrSend(openIds,riskSid,name,shSid,riskSid,ft.format(new Date())); |
|
|
|
|
|
System.out.println(r); |
|
|
|
|
|
} |
|
|
|
|
|
public List<String> getUser(String projectSid,String templateSid){ |
|
|
|
|
|
List<UserProject>list=crmMapper.getAllByProjectSid(projectSid); |
|
|
|
|
|
List<String> users=new ArrayList<>(); |
|
|
|
|
|
for (UserProject userProject:list){ |
|
|
|
|
|
int count=crmMapper.countByUserProjectSid(userProject.getSid(),templateSid); |
|
|
|
|
|
if(count>0){ |
|
|
|
|
|
users.add(userProject.getUserSid()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return users; |
|
|
|
|
|
} |
|
|
|
|
|
public ResultBean sendVerificationCode(String shName, List<String> users,String type) { |
|
|
|
|
|
ResultBean rb = new ResultBean().fireFail(); |
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
for (String mobile : users) { |
|
|
|
|
|
String codeRedis = redisUtil.get(""+mobile); |
|
|
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotEmpty(codeRedis)) { |
|
|
|
|
|
//查看请求间隔,默认是一分钟,小于一分钟继续等待,超过一分钟发送短信
|
|
|
|
|
|
String sendTime = codeRedis.substring(4); |
|
|
|
|
|
long diffSecond = (date.getTime() - Long.parseLong(sendTime)) / 1000; |
|
|
|
|
|
if (diffSecond < 60) { |
|
|
|
|
|
return ResultBean.fireFail().setMsg("请等待一分钟后再次重试!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String content=""; |
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
if(type.equals("030404")){ |
|
|
|
|
|
content= "仓库异常提醒:" + shName + "仓库监控设备于" + ft.format(new Date()) + "发生异常,请及时处理。"; |
|
|
|
|
|
}else if(type.equals("030405")){ |
|
|
|
|
|
content = "仓库异常提醒:" + shName + "仓库货物于" + ft.format(new Date()) + "发生图片比对异常,请及时处理。"; |
|
|
|
|
|
} |
|
|
|
|
|
// String res = "1";
|
|
|
|
|
|
|
|
|
|
|
|
String res = com.yxt.supervise.report.biz.util.MsgWs.SendWaitWorkMsg(mobile, content); |
|
|
|
|
|
if (res.equals("1")) { |
|
|
|
|
|
System.out.println("发送消息"); |
|
|
|
|
|
redisUtil.set(""+mobile,""+date.getTime(), APP_LOGIN_CODE_TIME_LIMIT); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// String res = "1";
|
|
|
|
|
|
return ResultBean.fireSuccess().setMsg("发送短信验证码成功"); |
|
|
|
|
|
} |
|
|
|
|
|
public ResultBean wwww(String shName, List<String> users,String type) { |
|
|
|
|
|
String e="http://IP+Port/utf8/SingleCallByTts.aspx?CorpID=*&Pwd=*&Mobile=*&Content=*&TtsCode=*& ShowNumber="; |
|
|
|
|
|
ResultBean rb = new ResultBean().fireFail(); |
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
for (String mobile : users) { |
|
|
|
|
|
String codeRedis = redisUtil.get(""+mobile); |
|
|
|
|
|
if (com.yxt.common.base.utils.StringUtils.isNotEmpty(codeRedis)) { |
|
|
|
|
|
//查看请求间隔,默认是一分钟,小于一分钟继续等待,超过一分钟发送短信
|
|
|
|
|
|
String sendTime = codeRedis.substring(4); |
|
|
|
|
|
long diffSecond = (date.getTime() - Long.parseLong(sendTime)) / 1000; |
|
|
|
|
|
if (diffSecond < 60) { |
|
|
|
|
|
return ResultBean.fireFail().setMsg("请等待一分钟后再次重试!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
String content=""; |
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
|
|
|
|
|
if(type.equals("030404")){ |
|
|
|
|
|
content= "仓库异常提醒:" + shName + "仓库监控设备于" + ft.format(new Date()) + "发生异常,请及时处理。"; |
|
|
|
|
|
}else if(type.equals("030405")){ |
|
|
|
|
|
content = "仓库异常提醒:" + shName + "仓库货物于" + ft.format(new Date()) + "发生图片比对异常,请及时处理。"; |
|
|
|
|
|
} |
|
|
|
|
|
// String res = "1";
|
|
|
|
|
|
|
|
|
|
|
|
String res = com.yxt.supervise.report.biz.util.MsgWs.SendWaitWorkMsg(mobile, content); |
|
|
|
|
|
if (res.equals("1")) { |
|
|
|
|
|
System.out.println("发送消息"); |
|
|
|
|
|
redisUtil.set(""+mobile,""+date.getTime(), APP_LOGIN_CODE_TIME_LIMIT); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// String res = "1";
|
|
|
|
|
|
return ResultBean.fireSuccess().setMsg("发送短信验证码成功"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getAccessToken(String appId,String appsecret) throws Exception { |
|
|
|
|
|
String url = WX_URL_ACCESS_TOKEN.replace("APPID", appId).replace("APPSECRET", appsecret); |
|
|
|
|
|
RestTemplate restTemplate=new RestTemplate(); |
|
|
|
|
|
String re= restTemplate.getForObject(url,String.class); |
|
|
|
|
|
JSONObject jsonObject= JSONObject.parseObject(re); |
|
|
|
|
|
System.out.println(jsonObject); |
|
|
|
|
|
String at=jsonObject.getString("access_token"); |
|
|
|
|
|
return at; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -569,108 +161,11 @@ public class WechatRest { |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/sendMessages") |
|
|
@PostMapping("/sendMessages") |
|
|
public void sendMessages(@PathVariable("projectSid") String projectSid,@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
public void sendMessages(@PathVariable("projectSid") String projectSid,@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
ReportStockDay reportStockDay=stockDayRest.getDayGather(projectSid,orderDate).getData(); |
|
|
wechatService.sendMessages(projectSid,orderDate); |
|
|
List <String> user= crmMapper.suerList(projectSid); |
|
|
|
|
|
List<String> openIds=new ArrayList<>(); |
|
|
|
|
|
for(String u:user){ |
|
|
|
|
|
String id=systemMapper.getOpenIdByStatus(u); |
|
|
|
|
|
openIds.add(id); |
|
|
|
|
|
} |
|
|
|
|
|
CsmCashReportVo csmCashReportVo=csmCashReportMapper.getCsmCashReport(orderDate); |
|
|
|
|
|
// 模板参数
|
|
|
|
|
|
Map<String, Template> sendMag = new HashMap<String, Template>(); |
|
|
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
|
|
String templateId = "jvfjnNpuT_4rfhiV1aWW31qK31-CnICoIAp5Bgco8hw"; |
|
|
|
|
|
//微信的基础accessToken
|
|
|
|
|
|
String accessToken=getAccessToken(APP_ID_BIZ,APPSECRETBIZ); |
|
|
|
|
|
String wxUrl = WX_URL_MESSAGE_SEND.replace("ACCESS_TOKEN", accessToken); |
|
|
|
|
|
JSONObject jsonObject=new JSONObject(); |
|
|
|
|
|
String pa=""; |
|
|
|
|
|
List<MessageOpenidDto> list=new ArrayList<>(); |
|
|
|
|
|
for(String openId:openIds){ |
|
|
|
|
|
MessageOpenidDto dto=new MessageOpenidDto(); |
|
|
|
|
|
dto.setOpenId(openId); |
|
|
|
|
|
list.add(dto); |
|
|
|
|
|
sendMag.put("time1", new Template(reportStockDay.getReportTime())); |
|
|
|
|
|
sendMag.put("thing2", new Template("质物库存汇总("+reportStockDay.getProjectName()+")")); |
|
|
|
|
|
sendMag.put("thing3", new Template("赵丽晓")); |
|
|
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
|
|
miniprogram.put("appid","wx05604ce2a8bede05"); |
|
|
|
|
|
miniprogram.put("pagepath","pages/index/InventorySummary?orderDate="+reportStockDay.getOrderDate()+"&"+"projectSid="+reportStockDay.getProjectSid()); |
|
|
|
|
|
pa=miniprogram.get("pagepath"); |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
//拼接base参数
|
|
|
|
|
|
Map<String, Object> sendBody = new HashMap<>(); |
|
|
|
|
|
sendBody.put("miniprogram",miniprogram); |
|
|
|
|
|
sendBody.put("touser", openId); // openId
|
|
|
|
|
|
sendBody.put("page", ""); // 点击模板信息跳转地址
|
|
|
|
|
|
//sendBody.put("topcolor", "#FF0000"); // 顶色
|
|
|
|
|
|
sendBody.put("data", sendMag); // 模板参数
|
|
|
|
|
|
sendBody.put("template_id", templateId);// 模板Id
|
|
|
|
|
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(wxUrl, sendBody, String.class); |
|
|
|
|
|
jsonObject = JSONObject.parseObject(forEntity.getBody()); |
|
|
|
|
|
System.out.println(sendBody); |
|
|
|
|
|
} |
|
|
|
|
|
System.out.println(sendMag); |
|
|
|
|
|
// 0
|
|
|
|
|
|
String messageCode = jsonObject.getString("errcode"); |
|
|
|
|
|
// 2431260672639467520
|
|
|
|
|
|
String msgId = jsonObject.getString("msgid"); |
|
|
|
|
|
System.out.println("messageCode : " + messageCode + ", msgId: " +msgId); |
|
|
|
|
|
//return forEntity.getBody();
|
|
|
|
|
|
} |
|
|
|
|
|
public String getAccessTokenBiz(String appId,String appsecret) throws Exception { |
|
|
|
|
|
String url = WX_URL_ACCESS_TOKEN.replace("APPID", appId).replace("APPSECRET", appsecret); |
|
|
|
|
|
RestTemplate restTemplate=new RestTemplate(); |
|
|
|
|
|
String re= restTemplate.getForObject(url,String.class); |
|
|
|
|
|
JSONObject jsonObject= JSONObject.parseObject(re); |
|
|
|
|
|
String at=jsonObject.getString("access_token"); |
|
|
|
|
|
return at; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping("/subscribe") |
|
|
@PostMapping("/subscribe") |
|
|
public ResultBean subscribe() throws AesException, IOException, SAXException, ParserConfigurationException { |
|
|
public ResultBean subscribe() throws AesException, IOException, SAXException, ParserConfigurationException { |
|
|
ResultBean rb =new ResultBean(); |
|
|
return wechatService.subscribe(); |
|
|
//
|
|
|
|
|
|
// 第三方回复公众平台
|
|
|
|
|
|
//
|
|
|
|
|
|
// 需要加密的明文
|
|
|
|
|
|
String encodingAesKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG"; |
|
|
|
|
|
String token = "pamtest"; |
|
|
|
|
|
String timestamp = "1409304348"; |
|
|
|
|
|
String nonce = "xxxxxx"; |
|
|
|
|
|
String appId = "wxb11529c136998cb6"; |
|
|
|
|
|
String replyMsg = " 中文<xml><ToUserName><![CDATA[oia2TjjewbmiOUlr6X-1crbLOvLw]]></ToUserName><FromUserName><![CDATA[gh_7f083739789a]]></FromUserName><CreateTime>1407743423</CreateTime><MsgType><![CDATA[video]]></MsgType><Video><MediaId><![CDATA[eYJ1MbwPRJtOvIEabaxHs7TX2D-HV71s79GUxqdUkjm6Gs2Ed1KF3ulAOA9H1xG0]]></MediaId><Title><![CDATA[testCallBackReplyVideo]]></Title><Description><![CDATA[testCallBackReplyVideo]]></Description></Video></xml>"; |
|
|
|
|
|
|
|
|
|
|
|
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); |
|
|
|
|
|
String mingwen = pc.encryptMsg(replyMsg, timestamp, nonce); |
|
|
|
|
|
System.out.println("加密后: " + mingwen); |
|
|
|
|
|
|
|
|
|
|
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
|
|
|
|
|
DocumentBuilder db = dbf.newDocumentBuilder(); |
|
|
|
|
|
StringReader sr = new StringReader(mingwen); |
|
|
|
|
|
InputSource is = new InputSource(sr); |
|
|
|
|
|
Document document = db.parse(is); |
|
|
|
|
|
|
|
|
|
|
|
Element root = document.getDocumentElement(); |
|
|
|
|
|
NodeList nodelist1 = root.getElementsByTagName("Encrypt"); |
|
|
|
|
|
NodeList nodelist2 = root.getElementsByTagName("MsgSignature"); |
|
|
|
|
|
|
|
|
|
|
|
String encrypt = nodelist1.item(0).getTextContent(); |
|
|
|
|
|
String msgSignature = nodelist2.item(0).getTextContent(); |
|
|
|
|
|
|
|
|
|
|
|
String format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>"; |
|
|
|
|
|
String fromXML = String.format(format, encrypt); |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
// 公众平台发送消息给第三方,第三方处理
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
// 第三方收到公众号平台发送的消息
|
|
|
|
|
|
String result2 = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML); |
|
|
|
|
|
System.out.println("解密后明文: " + result2); |
|
|
|
|
|
|
|
|
|
|
|
//pc.verifyUrl(null, null, null, null);
|
|
|
|
|
|
return rb.success().setData("成功"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|