|
|
@ -136,22 +136,18 @@ public class WechatRest { |
|
|
|
System.out.println("messageCode : " + messageCode + ", msgId: " +msgId); |
|
|
|
//return forEntity.getBody();
|
|
|
|
} |
|
|
|
//仓库库存日报推送
|
|
|
|
|
|
|
|
/** |
|
|
|
* 36524质物库存汇总 |
|
|
|
* @param orderDate |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
@PostMapping("/inventorySendMessage/{orderDate}") |
|
|
|
public void inventorySendMessage(@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
|
ReportInventoryDayGatherVo csmCashReportVo=reportInventoryDayGatherMapper.getReportInventoryDayGather(orderDate); |
|
|
|
// openId代表一个唯一微信用户,即微信消息的接收人
|
|
|
|
// String openId="otnrM57kui-WCUmRtChhb1HguOgw";
|
|
|
|
//郭
|
|
|
|
// String openId="otnrM544hxIgkMOfaDU8VpJhj_6k";
|
|
|
|
//刘
|
|
|
|
//String openId ="otnrM5ySvUo7ZZc4qafWzM9eyKBk";
|
|
|
|
//聂总
|
|
|
|
// otnrM521f8KcCsRfL2Jj4Tk8np1g
|
|
|
|
// 模板参数
|
|
|
|
Map<String, Template> sendMag = new HashMap<String, Template>(); |
|
|
|
// 公众号的模板id(也有相应的接口可以查询到)
|
|
|
|
// String templateId = "Zu4eXonKeUGuNuN9D3NKIEHU7PfqPA3uBfrc-lV0kIs";
|
|
|
|
String templateId = "BT6BHEojCmgWNTcpz1raHNIpJEEISP1E134btP51p_8"; |
|
|
|
//微信的基础accessToken
|
|
|
|
String accessToken=getAccessToken(APP_ID_BIZ,APPSECRETBIZ); |
|
|
@ -174,6 +170,72 @@ public class WechatRest { |
|
|
|
sendMag.put("thing2", new Template("36524质物库存汇总")); |
|
|
|
sendMag.put("thing3", new Template("赵丽晓")); |
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
//云眼
|
|
|
|
//miniprogram.put("appid","wx11565021714ba796");
|
|
|
|
//云仓
|
|
|
|
miniprogram.put("appid","wx65c2b78fd1452eeb"); |
|
|
|
miniprogram.put("pagepath","pages/index/inventoryReport?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();
|
|
|
|
} |
|
|
|
@PostMapping("/HcsmSendMessage/{orderDate}") |
|
|
|
public void HcsmSendMessage(@PathVariable("orderDate") String orderDate) throws Exception { |
|
|
|
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); |
|
|
|
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"); |
|
|
|
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("瀚川商贸库存汇总")); |
|
|
|
sendMag.put("thing3", new Template("赵丽晓")); |
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
miniprogram.put("appid","wx11565021714ba796"); |
|
|
|
miniprogram.put("pagepath","pages/index/inventoryReport?orderDate="+csmCashReportVo.getOrderDate()); |
|
|
|
pa=miniprogram.get("pagepath"); |
|
|
|