[新增功能](master): 新加一个土拨鼠AB单推送接口

master
土豆兄弟 4 years ago
parent ba3e65c96b
commit 2a7212a6e9

@ -168,6 +168,23 @@ public class ABClient {
CommonResponse.createBySuccess() : CommonResponse.createByErrorMessage("调用失败请重试");
}
/**
* AB -
*
* @return
*/
@PostMapping("/api/req/taginfo/tuboshu")
@ResponseBody
public CommonResponse getDBTagInfoTuBoShu(@RequestBody ABClientInterMessageVO vo) {
// 记录日志
log.info("====== [ tuboshu request comming, request content is {} ] ======", vo.toString());
// 转换实体类映射
List<ABMessageDTO> dtos = ABMessageConverter.convertABMessageDTOFromVO(vo);
// 调用业务处理接口 返回校验成功的结果
return abClientService.recordAndSendABClientMsgTuBoShu(dtos) ?
CommonResponse.createBySuccess() : CommonResponse.createByErrorMessage("调用失败请重试");
}
/**
* AB -
*
@ -295,7 +312,7 @@ public class ABClient {
*/
@PostMapping("/api/resend")
@ResponseBody
public CommonResponse reSend(@RequestParam String startPushTime, @RequestParam String endPushTime){
public CommonResponse reSend(@RequestParam String startPushTime, @RequestParam String endPushTime,@RequestParam(required= false) String actName){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null;
Date endDate = null;
@ -305,7 +322,7 @@ public class ABClient {
} catch (ParseException e) {
log.error("parse error! error msg is : {} ", e.getMessage(),e);
}
List<ABMessageDTO> dtos = abMessageService.queryUnSendMessage(startDate, endDate);
List<ABMessageDTO> dtos = abMessageService.queryUnSendMessage(startDate, endDate, actName);
if (CollectionUtils.isEmpty(dtos)){
return CommonResponse.createByErrorMessage("error");
}

@ -2,22 +2,32 @@ package com.yuyou.openapi.openapi.common;
/**
* FileName: ResponseCode
* Author: x
* Date: 2019/12/11 20:30
* Description: Response ->
* History:
* <author> <time> <version> <desc>
* x 2019/12/11 v 1.0
* @author q
*/
public enum ResponseCode {
/**
*
*/
SUCCESS(0,"SUCCESS"),
/**
*
*/
ERROR(1,"ERROR"),
// 请求参数校验
/**
*
*/
ILLEGAL_ARGUMENT(1,"请求参数格式错误"),
EMPTY_ARGUMENT(1,"请求参数为空"),
// 请求结果性的错误
/**
*
*/
DECRYPT_ERROR(1,"解密错误,请联系我");
private final int code;

@ -21,4 +21,8 @@ public interface ABMessageRepository extends JpaRepository<ABMessageDO,Long> {
@Query("from ABMessageDO a where a.pushTime >= ?1 and a.pushTime < ?2 and a.sendStatus = ?3 ")
List<ABMessageDO> findAllByPushTimeAndSendStatus(Date startPushTime, Date endPushTime, Integer sendStatus);
@Query("from ABMessageDO a where a.startTime >= ?1 and a.startTime < ?2 and a.actName = ?3 ")
List<ABMessageDO> findAllByPushTimeAndActName(Date startPushTime, Date endPushTime, String actName);
}

@ -0,0 +1,31 @@
package com.yuyou.openapi.openapi.dao;
import com.yuyou.openapi.openapi.model.dataobject.TuBoShuMessageDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: LuoshiMessageRepository
* Author:
* Date: 2020/10/22 2:52 PM
* Description: TODO
* History:
* <author> <time> <version> <desc>
* 2020/10/22 v1.0
*/
@Repository
public interface TuBoShuMessageRepository extends JpaRepository<TuBoShuMessageDO, Long>{
@Modifying
@Query("update TuBoShuMessageDO t set t.sendStatus = ?1 where t.recId = ?2")
void updateSendStatus(Integer sendStatus, Long recId);
@Query("from TuBoShuMessageDO a where a.pushTime >= ?1 and a.pushTime < ?2 and a.sendStatus = ?3 ")
List<TuBoShuMessageDO> findAllByPushTimeAndSendStatus(Date startPushTime, Date endPushTime, Integer sendStatus);
}

@ -6,6 +6,9 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: LuoshiMessageRepository
@ -21,5 +24,8 @@ public interface YHMessageRepository extends JpaRepository<YHMessageDO, Long>{
@Modifying
@Query("update YHMessageDO t set t.sendStatus = ?1 where t.recId = ?2")
void updateSendStatus(Integer sendStatus, Long recId);
@Query("from YHMessageDO a where a.pushTime >= ?1 and a.pushTime < ?2 and a.sendStatus = ?3 ")
List<YHMessageDO> findAllByPushTimeAndSendStatus(Date startPushTime, Date endPushTime, Integer sendStatus);
}

@ -253,6 +253,22 @@ public class ABMessageConverter {
return abMessageDOs;
}
/**
* DTODO
* @param dtos
* @return
*/
public static List<TuBoShuMessageDO> convertTuBoShuABMessageDOFromDTO(List<ABMessageDTO> dtos) {
if (CollectionUtils.isEmpty(dtos)) {
return null;
}
List<TuBoShuMessageDO> abMessageDOs = new ArrayList<>();
dtos.forEach(each -> {
abMessageDOs.add(convertTuBoShuMessageDOFromDTO(each));
});
return abMessageDOs;
}
/**
@ -633,6 +649,36 @@ public class ABMessageConverter {
return qiZhuangMessageDO;
}
/**
* Luoshi DTODO
* @param abMessageDTO
* @return
*/
public static TuBoShuMessageDO convertTuBoShuMessageDOFromDTO(ABMessageDTO abMessageDTO) {
TuBoShuMessageDO tuBoShuMessageDO = new TuBoShuMessageDO();
if (abMessageDTO == null) {
return tuBoShuMessageDO;
}
BeanUtils.copyProperties(abMessageDTO, tuBoShuMessageDO);
tuBoShuMessageDO.setPushTime(DateUtils.date(abMessageDTO.getTimestamp()));
tuBoShuMessageDO.setStartTime(DateUtils.date(abMessageDTO.getStartTime()));
try{
tuBoShuMessageDO.setRecId(Long.valueOf(abMessageDTO.getRecId()));
}catch (Exception e){
log.error("String convert Long type Error.", e);
}
// AES加密
try {
String encryptedMobile = SecurityService.encrypt(abMessageDTO.getMobile(), SecurityConstants.PHONE);
tuBoShuMessageDO.setPnum(encryptedMobile);
} catch (Exception e) {
log.error("Encrypt Mobile raise Error, recId = {}, error is :", abMessageDTO.getRecId(), e);
tuBoShuMessageDO.setPnum(abMessageDTO.getMobile());
}
return tuBoShuMessageDO;
}

@ -0,0 +1,81 @@
package com.yuyou.openapi.openapi.model.dataobject;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
/**
* liehe AB
* @version 1.0
* @date 2020/8/6
*/
@Data
@Table(name = "tuboshu_message")
@Entity
@EntityListeners(AuditingEntityListener.class)
public class TuBoShuMessageDO {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
@Column(name = "gmt_create")
@CreatedDate
private Date gmtCreate;
@Column(name = "gmt_modified")
@LastModifiedDate
private Date gmtModified;
/**
* id
*/
@Column(name = "rec_id")
private Long recId;
/**
*
*/
@Column(name = "pnum")
private String pnum;
/**
*
*/
@Column(name = "act_name")
private String actName;
/**
*
*/
@Column(name = "start_time")
private Date startTime;
/**
* (1:A,2:B,3:C,4:D,5:E,6:F)
*/
@Column(name = "client_type")
private Integer clientType;
/**
* id
*/
@Column(name = "app_id")
private String appId;
/**
*
*/
@Column(name = "push_time")
private Date pushTime;
/**
* 0 0 - 1 -
*/
@Column(name = "send_status")
private Integer sendStatus = 0;
}

@ -0,0 +1,89 @@
package com.yuyou.openapi.openapi.model.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* Copyright (C), 2012 - 2018, qyx
* FileName: LuoshiMessageCovDTO
* Author:
* Date: 2020/10/22 2:55 PM
* Description: TODO
* History:
* <author> <time> <version> <desc>
* 2020/10/22 v1.0
*/
/**
*
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TuBoShuMessageCovDTO {
/**
* ID
*/
@JSONField(name = "app_id")
private String appId;
/**
*
*/
@JSONField(name = "timestamp")
private Long timestamp;
/**
* : sha1(app_id=AppId&nonce_str=time_stamp)
*/
@JSONField(name = "signature")
private String signature;
/**
* json
*/
@JSONField(name = "data")
private List<TuBoshuData> data;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TuBoshuData {
/**
* poneNum Base64
*/
@JSONField(name = "info")
private String info;
/**
*
*/
@JSONField(name = "time")
private Long time;
/**
* Base64
*/
@JSONField(name = "subType")
@JsonIgnore
private String actName;
/**
* ABA-1B-2
*/
@JSONField(name = "type")
private Integer type;
/**
*
*/
@JSONField(name = "city")
private String city;
}
}

@ -23,4 +23,7 @@ public class QiZhuangDTO {
@JSONField(name = "time")
@JsonIgnore
private Long time;
@JSONField(name = "src")
private String src;
}

@ -0,0 +1,26 @@
package com.yuyou.openapi.openapi.model.pojo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TuBoShuDTO {
@JsonIgnore
private String recId;
@JSONField(name = "mobile")
private Long mobile;
@JSONField(name = "city")
private String city;
@JSONField(name = "time")
@JsonIgnore
private Long time;
}

@ -179,4 +179,12 @@ public interface ABClientService {
* @return |
*/
boolean recordAndSendABClientMsgQiZhuang(List<ABMessageDTO> dtos);
/**
*
* @param dtos
* @return |
*/
boolean recordAndSendABClientMsgTuBoShu(List<ABMessageDTO> dtos);
}

@ -72,10 +72,16 @@ public interface ABMessageService {
*/
boolean updateSendWxFansSatus(Long recId, boolean sucess);
/**
* -
*/
boolean updateSendTuBoShuSatus(Long recId, boolean sucess);
/**
*
*/
List<ABMessageDTO> queryUnSendMessage(Date startPushTime, Date endPushTime);
List<ABMessageDTO> queryUnSendMessage(Date startPushTime, Date endPushTime, String actName);
/**
*

@ -57,6 +57,9 @@ public class ABClientServiceImpl implements ABClientService {
@Autowired
private QiZhuangMessageRepository qiZhuangMessageRepository;
@Autowired
private TuBoShuMessageRepository tuBoShuMessageRepository;
@Autowired
private YHMessageRepository yhMessageRepository;
@ -330,6 +333,25 @@ public class ABClientServiceImpl implements ABClientService {
return Boolean.TRUE;
}
@Override
public boolean recordAndSendABClientMsgTuBoShu(List<ABMessageDTO> dtos) {
if (CollectionUtils.isEmpty(dtos)) {
log.error("Param dtos is empty");
return Boolean.FALSE;
}
// 调用接口进行入库
List<TuBoShuMessageDO> abMessageDOS = ABMessageConverter.convertTuBoShuABMessageDOFromDTO(dtos);
List<TuBoShuMessageDO> dos = tuBoShuMessageRepository.saveAll(abMessageDOS);
if (CollectionUtils.isEmpty(dos)){
log.error("========== [insert data error , please check .] ==========");
return Boolean.FALSE;
}
// 调用异步任务进行转发AB单 - 这里是这有一条数据
// 返回处理结果
abDownTask.doRunTuBoShuTask(dtos);
return Boolean.TRUE;
}
@Override

@ -179,6 +179,11 @@ public class ABClientServiceProxy implements ABClientService {
return abClientService.recordAndSendABClientMsgQiZhuang(dtos);
}
@Override
public boolean recordAndSendABClientMsgTuBoShu(List<ABMessageDTO> dtos) {
return abClientService.recordAndSendABClientMsgTuBoShu(dtos);
}
/**
*
* @param base64Value

@ -1,5 +1,6 @@
package com.yuyou.openapi.openapi.service.impl;
import com.google.common.collect.Lists;
import com.yuyou.openapi.openapi.common.security.SecurityConstants;
import com.yuyou.openapi.openapi.common.security.SecurityService;
import com.yuyou.openapi.openapi.dao.*;
@ -7,6 +8,7 @@ import com.yuyou.openapi.openapi.exception.SecretException;
import com.yuyou.openapi.openapi.model.dataobject.ABMessageDO;
import com.yuyou.openapi.openapi.model.dto.ABMessageDTO;
import com.yuyou.openapi.openapi.service.ABMessageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -49,6 +51,9 @@ public class ABMessageServiceImpl implements ABMessageService {
@Autowired
private HeXiaoXiangMessageRepository heXiaoXiangMessageRepository;
@Autowired
private TuBoShuMessageRepository tuBoShuMessageRepository;
@Autowired
private XmjMessageRepository xmjMessageRepository;
@ -207,11 +212,31 @@ public class ABMessageServiceImpl implements ABMessageService {
return Boolean.TRUE;
}
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public boolean updateSendTuBoShuSatus(Long recId, boolean sucess) {
if (recId == null) {
return Boolean.FALSE;
}
if (sucess) {
tuBoShuMessageRepository.updateSendStatus(1, recId);
}else {
tuBoShuMessageRepository.updateSendStatus(0, recId);
}
return Boolean.TRUE;
}
@Override
public List<ABMessageDTO> queryUnSendMessage(Date startPushTime, Date endPushTime) {
public List<ABMessageDTO> queryUnSendMessage(Date startPushTime, Date endPushTime, String actName) {
List<ABMessageDO> abMessageDOList = Lists.newArrayList();
if (StringUtils.isNotBlank(actName)){
abMessageDOList = abMessageRepository.findAllByPushTimeAndActName(startPushTime, endPushTime, actName);
}else{
abMessageDOList = abMessageRepository.findAllByPushTimeAndSendStatus(startPushTime, endPushTime, 0);
}
List<ABMessageDO> abMessageDOList = abMessageRepository.findAllByPushTimeAndSendStatus(startPushTime, endPushTime, 0);
List<ABMessageDTO> abMessageDTOList = new ArrayList<>();

@ -197,6 +197,16 @@ public class ABDownTask {
private String qiJiaUrl;
@Value("${ab.tbs.appId}")
private String tbsAppid;
@Value("${ab.tbs.url}")
private String tbsUrl;
@Value("${ab.tbs.secretKey}")
private String tbsSecret;
/**
* ,
*
@ -582,6 +592,8 @@ public class ABDownTask {
qiZhuangDTO.setCity(SpecialCityConst.SPECIAL_RANDOM_CITYS[RandomUtil.randomInt(0, 42)].trim());
}
}
// 标识
qiZhuangDTO.setSrc("bxxx-18cs");
// 单条记录Id
qiZhuangDTO.setRecId(item.getRecId());
return qiZhuangDTO;
@ -625,6 +637,106 @@ public class ABDownTask {
return Boolean.TRUE;
}
/**
* ,
*
*/
@Async(value = "abTaskExecutor")
public void doRunTuBoShuTask(List<ABMessageDTO> messageDTOList){
Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start running, task name is {} ] ======", "doRunTuBoShuTask");
runTuBoShuTask(messageDTOList);
Long endMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "doRunTuBoShuTask", (endMilliSecond-satrtMilliSecond));
}
/**
*
*
* @return
*/
private boolean runTuBoShuTask(List<ABMessageDTO> messageDTOList){
int count = 0; // 设置请求失败计数
// 对特殊情况进行过滤,只要AB单的用户,且字段加密规则要重新进行制定
List<ABMessageDTO> collect = messageDTOList.stream()
.filter(item -> (1 == item.getClientType()) || 2 == item.getClientType())
.map(item -> {
// pno通配
String reverse = StringUtils.reverse(item.getMobile());
item.setMobile(reverse);
// startTime 通配下游到秒
Long startTime = item.getStartTime();
if (startTime != null && startTime.toString().length() == 13) {
item.setStartTime(startTime / 1000);
}
return item;
})
.collect(Collectors.toList());
List<TuBoShuMessageCovDTO.TuBoshuData> data = new ArrayList<>();
// 进行转换
collect.forEach(
each->{
TuBoShuMessageCovDTO.TuBoshuData tuBoshuData = new TuBoShuMessageCovDTO.TuBoshuData();
tuBoshuData.setInfo(each.getMobile());
tuBoshuData.setType(each.getClientType());
tuBoshuData.setTime(each.getStartTime());
tuBoshuData.setActName(each.getActName());
String pno = Base64.decodeStr(StringUtils.reverse(each.getMobile()));
// 匹配城市
if (pno.length() == 11) {
String substring = StringUtils.substring(pno, 0, pno.length() - 4);
String matchCity = phonesRepository.findByNumber(substring);
if (StringUtils.isNotBlank(matchCity)) {
tuBoshuData.setCity(matchCity.trim());
} else {
// 查不到随机给一个城市
tuBoshuData.setCity(SpecialCityConst.SPECIAL_RANDOM_CITYS[RandomUtil.randomInt(0, 42)].trim());
}
}
data.add(tuBoshuData);
}
);
// 数据实体进行映射转换 - 目前是只有一条给
TuBoShuMessageCovDTO tuBoShuMessageCovDTO = new TuBoShuMessageCovDTO();
// 进行设置
if (!CollectionUtils.isEmpty(data)){
tuBoShuMessageCovDTO.setData(data);
}
// 补充其他的下游请求字段
long time = System.currentTimeMillis() / 1000;
tuBoShuMessageCovDTO.setTimestamp(time);
tuBoShuMessageCovDTO.setAppId(tbsAppid);
tuBoShuMessageCovDTO.setSignature(SecureUtil.sha1("app_id="+ tbsAppid +"&timestamp="+ time + "&secret=" + tbsSecret));
// 数据实体转成Json 不忽略空kv 有序
String jsonStr = JSON.toJSONString(tuBoShuMessageCovDTO);
log.info("========== [ready send json is {} ] =============", jsonStr);
// 请求的响应处理
// todo 失败重发请求3次
while (count <= 3){
// 调用HTTP请求发送数据
HttpResponse httpResponse = sendTBSReq(jsonStr);
if (httpResponse.isOk() && httpResponse.body().contains("success")){
log.info("========== [request success, response is {} ] ==========", httpResponse.body());
break;
}else{
count ++;
log.error("========== [request fail, response is {} ] ==========", httpResponse.body());
}
}
if (count > 3) {
return Boolean.FALSE;
}
collect.forEach(
// FIXME: 2020/8/12 0012 可能会造成更新失败,检查更新语句
each -> abMessageService.updateSendTuBoShuSatus(Long.valueOf(each.getRecId()), Boolean.TRUE)
);
return Boolean.TRUE;
}
/**
*
*
@ -1475,6 +1587,16 @@ public class ABDownTask {
return httpResponse;
}
private HttpResponse sendTBSReq(String json) {
HttpResponse httpResponse = HttpRequest
.post(tbsUrl)
.body(json)
.execute();
return httpResponse;
}
/**
* ABMessageDTOLieheMessage
* @param

@ -1,6 +1,6 @@
spring:
profiles:
active: prod
active: stg
# 序列化忽略null的k-v配置
jackson:
default-property-inclusion: non_null
@ -9,7 +9,8 @@ spring:
show-sql: true
open-in-view: false
database-platform: org.hibernate.dialect.MySQLDialect
logging:
config: classpath:logback.xml
---
# 端口
server:
@ -78,10 +79,14 @@ ab:
url: http://www.huameiou.com:18877/api/users/receiveinfo
secretKey: 3F0716E9EA9246D0A9C5B2BA1B3ADB4E
qj:
url: http://dev-callback-tapi-lsq.devops.qizuang.com/v1/order
token_addr: http://dev-callback-tapi-lsq.devops.qizuang.com/v1/gettoken
akey: mPMRhJIX4xWAUgxc
ckey: jTuMccC8qkc49hUK
url: https://tapi.qizuang.com/v1/order
token_addr: https://tapi.qizuang.com/v1/gettoken
akey: 4sZIqVrtV2M5GdX6
ckey: ul93ewgrysGNDDyV
tbs:
appId: 9c32209b14214929bc1ba07b8b4d7b47
url: http://erp.tobosu.cn/channel/pullOrder/pushOrderFromChannel
secretKey: dd638eedc970b468e5e0002179e59e77
---
# 端口
@ -149,14 +154,16 @@ ab:
qj:
url: https://tapi.qizuang.com/v1/order
token_addr: https://tapi.qizuang.com/v1/gettoken
akey: mPMRhJIX4xWAUgxc
ckey: jTuMccC8qkc49hUK
akey: 4sZIqVrtV2M5GdX6
ckey: ul93ewgrysGNDDyV
mohang:
appId: TZRamCan
url: http://175.27.191.107:8080//highseas/api/tz
secretKey: 77ea829b727913a87f8aa461b392dbb5
logging:
config: classpath:logback.xml
tbs:
appId: 9c32209b14214929bc1ba07b8b4d7b47
url: http://erp.tobosu.cn/channel/pullOrder/pushOrderFromChannel
secretKey: dd638eedc970b468e5e0002179e59e77
---
# 端口
@ -224,9 +231,13 @@ ab:
qj:
url: https://tapi.qizuang.com/v1/order
token_addr: https://tapi.qizuang.com/v1/gettoken
akey: mPMRhJIX4xWAUgxc
ckey: jTuMccC8qkc49hUK
akey: 4sZIqVrtV2M5GdX6
ckey: ul93ewgrysGNDDyV
mohang:
appId: TZRamCan
url: http://175.27.191.107:8080//highseas/api/tz
secretKey: 77ea829b727913a87f8aa461b392dbb5
secretKey: 77ea829b727913a87f8aa461b392dbb5
tbs:
appId: 9c32209b14214929bc1ba07b8b4d7b47
url: http://erp.tobosu.cn/channel/pullOrder/pushOrderFromChannel
secretKey: dd638eedc970b468e5e0002179e59e77

@ -37,7 +37,7 @@
<root level="INFO">
<!-- TODO prod 环境去掉std -->
<!--<appender-ref ref="stdAppender"/>-->
<appender-ref ref="fileAppender"/>
<appender-ref ref="stdAppender"/>
<!-- <appender-ref ref="fileAppender"/>-->
</root>
</configuration>

@ -3,7 +3,13 @@ package com.yuyou.openapi.openapi;
import cn.hutool.core.io.FileUtil;
import com.google.common.collect.Lists;
import com.yuyou.openapi.openapi.common.security.SecurityConstants;
import com.yuyou.openapi.openapi.common.security.SecurityService;
import com.yuyou.openapi.openapi.dao.ABMessageRepository;
import com.yuyou.openapi.openapi.dao.PhonesRepository;
import com.yuyou.openapi.openapi.dao.TuBoShuMessageRepository;
import com.yuyou.openapi.openapi.exception.SecretException;
import com.yuyou.openapi.openapi.model.dataobject.TuBoShuMessageDO;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -18,6 +24,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.nio.charset.Charset;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -32,6 +40,9 @@ public class OpenapiApplicationTest {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private ABMessageRepository abMessageRepository;
/**
*
*/
@ -170,4 +181,27 @@ public class OpenapiApplicationTest {
System.out.println(phonesRepository.findByNumber(substring)); // 1300018
}
}
@Autowired
private TuBoShuMessageRepository tuBoShuMessageRepository;
@Test
public void testRePush() throws Exception{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = simpleDateFormat.parse("2021-04-08 00:00:00");
Date parse1 = simpleDateFormat.parse("2021-04-09 00:00:00");
List<TuBoShuMessageDO> list = tuBoShuMessageRepository.findAllByPushTimeAndSendStatus(parse, parse1, 0);
list.forEach(
each->{
try{
System.out.println(SecurityService.decrypt(each.getPnum(), SecurityConstants.PHONE));
}catch (SecretException e){
e.printStackTrace();
}
}
);
System.out.println("1");
}
}

@ -6,9 +6,13 @@ import com.yuyou.openapi.openapi.common.security.SecurityConstants;
import com.yuyou.openapi.openapi.common.security.SecurityService;
import com.yuyou.openapi.openapi.dao.LuoshiMessageRepository;
import com.yuyou.openapi.openapi.dao.QiZhuangMessageRepository;
import com.yuyou.openapi.openapi.dao.TuBoShuMessageRepository;
import com.yuyou.openapi.openapi.dao.YHMessageRepository;
import com.yuyou.openapi.openapi.exception.SecretException;
import com.yuyou.openapi.openapi.model.dataobject.LuoshiMessageDO;
import com.yuyou.openapi.openapi.model.dataobject.QiZhuangMessageDO;
import com.yuyou.openapi.openapi.model.dataobject.TuBoShuMessageDO;
import com.yuyou.openapi.openapi.model.dataobject.YHMessageDO;
import com.yuyou.openapi.openapi.model.dto.ABMessageDTO;
import com.yuyou.openapi.openapi.task.ABDownTask;
import org.junit.Test;
@ -107,4 +111,86 @@ public class RepushTest extends OpenapiApplicationTest{
Thread.sleep(60*60*1000);
}
@Autowired
private TuBoShuMessageRepository tuBoShuMessageRepository;
@Test
public void testRePushTuBoShu() throws Exception{
// 查出需要的AB单
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = simpleDateFormat.parse("2021-4-17 00:00:00");
Date endDate = simpleDateFormat.parse("2021-4-18 00:00:00");
List<TuBoShuMessageDO> result = tuBoShuMessageRepository.findAllByPushTimeAndSendStatus(startDate, endDate, 0);
// Map<String, List<LuoshiMessageDO>> collect = result.stream().collect(Collectors.groupingBy(LuoshiMessageDO::getActName));
List<ABMessageDTO> messageDTOList = new ArrayList<>();
result.forEach(
each ->{
ABMessageDTO abMessageDTO = new ABMessageDTO();
BeanUtil.copyProperties(each, abMessageDTO);
try {
abMessageDTO.setMobile(SecurityService.decrypt(each.getPnum(), SecurityConstants.PHONE));
} catch (SecretException e) {
e.printStackTrace();
}
messageDTOList.add(abMessageDTO);
}
);
List<List<ABMessageDTO>> partition = Lists.partition(messageDTOList, 100);
partition.forEach(
one-> abDownTask.doRunTuBoShuTask(one)
);
Thread.sleep(60*60*1000);
}
@Autowired
private YHMessageRepository yhMessageRepository;
@Test
public void testRePushYHXiaoKeBao() throws Exception{
// 查出需要的AB单
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = simpleDateFormat.parse("2021-4-20 00:00:00");
Date endDate = simpleDateFormat.parse("2021-4-21 00:00:00");
List<YHMessageDO> result = yhMessageRepository.findAllByPushTimeAndSendStatus(startDate, endDate, 0);
// Map<String, List<LuoshiMessageDO>> collect = result.stream().collect(Collectors.groupingBy(LuoshiMessageDO::getActName));
List<ABMessageDTO> messageDTOList = new ArrayList<>();
result.forEach(
each ->{
ABMessageDTO abMessageDTO = new ABMessageDTO();
BeanUtil.copyProperties(each, abMessageDTO);
try {
abMessageDTO.setMobile(SecurityService.decrypt(each.getPnum(), SecurityConstants.PHONE));
} catch (SecretException e) {
e.printStackTrace();
}
messageDTOList.add(abMessageDTO);
}
);
List<List<ABMessageDTO>> partition = Lists.partition(messageDTOList, 100);
partition.forEach(
one-> abDownTask.doRunYHTask(one)
);
Thread.sleep(60*60*1000);
}
}

@ -1,6 +1,7 @@
package com.yuyou.openapi.openapi;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
@ -18,6 +19,8 @@ import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class SimpleTest {
@ -55,6 +58,16 @@ public class SimpleTest {
);
}
@Test
public void test() throws Exception{
List<String> list = Files.readAllLines(Paths.get("H:\\1\\1.txt"));
List<String> list1 = Files.readAllLines(Paths.get("H:\\1\\2.txt"));
Set<String> collect = list.stream().filter(list1::contains).collect(Collectors.toSet());
FileUtil.writeLines(collect, "H:\\1\\3.txt", "utf-8");
}
@Test
public void testTag(){
String a = "网易有道课-数学-罗实";
@ -103,4 +116,7 @@ public class SimpleTest {
}

Loading…
Cancel
Save