Merge branch 'master' of http://git.hchbox.com/yuyou/client into master
开发代码暂存 # Conflicts: # src/main/java/com/yuyou/openapi/openapi/task/ABDownTask.java # src/main/resources/application.ymlmaster
commit
e40590e73e
@ -0,0 +1,9 @@
|
||||
package com.yuyou.openapi.openapi.consts;
|
||||
|
||||
public class SpecialCityConst {
|
||||
|
||||
/**
|
||||
* 装修客户手机匹配 随机列表
|
||||
*/
|
||||
public static final String[] SPECIAL_RANDOM_CITYS = {"重庆","杭州","宁波","舟山","绍兴","金华","嘉兴","昆明","拉萨","天津","成都","绵阳","南充","宜宾","上海","吉安","苏州","无锡","南通","泰州","淮安","连云港","镇江","南京","长沙","武汉","南阳","三亚","贵阳","广州","深圳","佛山","惠州","东莞","珠海","中山","清远","福州","北京","芜湖","合肥","六安","安庆"};
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.yuyou.openapi.openapi.dao;
|
||||
|
||||
import com.yuyou.openapi.openapi.model.dataobject.PhonesDO;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 数据层调用接口
|
||||
*/
|
||||
@Repository
|
||||
public interface PhonesRepository extends JpaRepository<PhonesDO,Long> {
|
||||
|
||||
@Query(value = "SELECT r.city FROM `tb_phones` p LEFT JOIN `tb_regions` r ON p.region_id = r.id WHERE p.number = :number", nativeQuery = true)
|
||||
String findByNumber(@Param("number") String number);
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.yuyou.openapi.openapi.dao;
|
||||
|
||||
import com.yuyou.openapi.openapi.model.dataobject.XmjMessageDO;
|
||||
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 javax.transaction.Transactional;
|
||||
import java.util.Date;
|
||||
|
||||
@Repository
|
||||
public interface XmjMessageRepository extends JpaRepository<XmjMessageDO, Long> {
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query("update XmjMessageDO t set t.sendStatus = ?1,t.pushTime=?2 where t.recId = ?3")
|
||||
Integer updateSendStatus(Integer sendStatus, Date time,Long recId);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.yuyou.openapi.openapi.dao;
|
||||
|
||||
import com.yuyou.openapi.openapi.model.dataobject.YHMessageDO;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 YHMessageRepository extends JpaRepository<YHMessageDO, Long>{
|
||||
@Modifying
|
||||
@Query("update YHMessageDO t set t.sendStatus = ?1 where t.recId = ?2")
|
||||
void updateSendStatus(Integer sendStatus, Long recId);
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.yuyou.openapi.openapi.model.dataobject;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* AB表单数据层映射类
|
||||
* @version 1.0
|
||||
* @date 2020/8/6
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "tb_phones")
|
||||
@Entity
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class PhonesDO {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 号码段
|
||||
*/
|
||||
@Column(name = "number")
|
||||
private Integer number;
|
||||
|
||||
/**
|
||||
* 运营商 1移动 2联通 3电信
|
||||
*/
|
||||
@Column(name = "type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 区域表ID
|
||||
*/
|
||||
@Column(name = "region_id")
|
||||
private Integer regionId;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.yuyou.openapi.openapi.model.dataobject;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Table(name = "tb_regions")
|
||||
@Entity
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class ReginsDO {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@Column(name = "province")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@Column(name = "city")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 邮编
|
||||
*/
|
||||
@Column(name = "zip_code")
|
||||
private String zipCode;
|
||||
|
||||
/**
|
||||
* 区域ID
|
||||
*/
|
||||
@Column(name = "area_code")
|
||||
private String areaCode;
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Copyright (C), 2012 - 2018, qyx
|
||||
* FileName: LuoshiMessageDO
|
||||
* Author: 钱昱欣
|
||||
* Date: 2020/10/22 2:49 PM
|
||||
* Description: TODO
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 钱昱欣 2020/10/22 v1.0 创建此文件
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "yh_message")
|
||||
@Entity
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class YHMessageDO {
|
||||
|
||||
@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,35 @@
|
||||
package com.yuyou.openapi.openapi.model.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class XmjMessageDTO extends ABMessageDTO{
|
||||
|
||||
/**
|
||||
* 话单详细信息,有可能是为空的
|
||||
*/
|
||||
private List<ChatMsg> messages;
|
||||
|
||||
|
||||
/**
|
||||
* 这里对于详细的话单信息进行解析
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ChatMsg {
|
||||
|
||||
private Long talkTime;
|
||||
|
||||
private Integer talkerType;
|
||||
|
||||
private String message;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.yuyou.openapi.openapi.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.yuyou.openapi.openapi.model.vo.data.DetailInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小麦君
|
||||
* @author zt 2021-3-4 15:34:45
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ABClientXMJMessageVO extends ABClientBaseVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 详细的数据实体
|
||||
*/
|
||||
@JsonProperty(value = "data")
|
||||
private List<DetailInfo> data;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.yuyou.openapi.openapi.model.vo.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zzt
|
||||
* @date 2021/3/4 15:39
|
||||
*/
|
||||
@Data
|
||||
public class DetailInfo {
|
||||
|
||||
|
||||
// "data": [
|
||||
// {
|
||||
// "start_time": 1607003187354,
|
||||
// "act_name": "5rWL6K+VNA==",
|
||||
// "mobile": "MTMzNDY2NDc1OTU=",
|
||||
// "messages": [
|
||||
// {
|
||||
// "talkTime": 1607003198000,
|
||||
// "talkerType": 1,
|
||||
// "message": ""
|
||||
// },
|
||||
// {
|
||||
// "talkTime": 1607003198000,
|
||||
// "talkerType": 2,
|
||||
// "message": "喂-你好"
|
||||
// },
|
||||
// {
|
||||
// "talkTime": 1607003201000,
|
||||
// "talkerType": 1,
|
||||
// "message": "您好。"
|
||||
// },
|
||||
// {
|
||||
// "talkTime": 1607003201000,
|
||||
// "talkerType": 2,
|
||||
// "message": "你好,我这边是老端说险,老端说险是专业解决健康保障问题平台,值此平台5周年活动,我们针对关注健康的客户,免费赠险价值470元双人体检套餐一份。您有兴趣了解一下吗"
|
||||
// },
|
||||
// {
|
||||
// "talkTime": 1607003220000,
|
||||
// "talkerType": 1,
|
||||
// "message": "没有。"
|
||||
// },
|
||||
// {
|
||||
// "talkTime": 1607003220000,
|
||||
// "talkerType": 2,
|
||||
// "message": "那不好意思,打扰您了,祝您生活愉快,再见。"
|
||||
// }
|
||||
// ],
|
||||
// "client_type": 1,
|
||||
// "rec_id": 8471351
|
||||
// }
|
||||
// ]
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "start_time")
|
||||
private Long startTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "act_name")
|
||||
private String actName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "messages")
|
||||
private List<MessageInfo> messages;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "client_type")
|
||||
private Integer clientType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "rec_id")
|
||||
private Long recId;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.yuyou.openapi.openapi.model.vo.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zzt
|
||||
* @date 2021/3/4 15:39
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class MessageInfo {
|
||||
|
||||
|
||||
// "messages": [
|
||||
// {
|
||||
// "talkTime": 1607003198000,
|
||||
// "talkerType": 1,
|
||||
// "message": ""
|
||||
// },
|
||||
// {
|
||||
// "talkTime": 1607003198000,
|
||||
// "talkerType": 2,
|
||||
// "message": "喂-你好"
|
||||
// }
|
||||
// ]
|
||||
|
||||
/**
|
||||
* 谈话时间
|
||||
*/
|
||||
@JsonProperty(value = "talkTime")
|
||||
private Long talkTime;
|
||||
|
||||
/**
|
||||
* 谈话类型
|
||||
*/
|
||||
@JsonProperty(value = "talkerType")
|
||||
private Integer talkerType;
|
||||
|
||||
/**
|
||||
* 谈话内容
|
||||
*
|
||||
*/
|
||||
@JsonProperty(value = "message")
|
||||
private String message;
|
||||
}
|
@ -1,16 +1,174 @@
|
||||
package com.yuyou.openapi.openapi;
|
||||
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.yuyou.openapi.openapi.dao.PhonesRepository;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* SpringBoot测试基类
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
public class OpenapiApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
* 测试批量插入数据
|
||||
*/
|
||||
@Test
|
||||
public void testBatchInsert1(){
|
||||
|
||||
@Data
|
||||
class Regions{
|
||||
private String id;
|
||||
private String province;
|
||||
private String city;
|
||||
private String zip_code;
|
||||
private String area_code;
|
||||
}
|
||||
|
||||
String sql = "INSERT INTO `tb_regions` (id,province,city,zip_code,area_code) VALUES (?, ?, ?, ?, ?)";
|
||||
|
||||
|
||||
List<String> list = FileUtil.readLines("D:\\apk整理\\Phone-Number-Range-master\\phone2.sql", Charset.defaultCharset());
|
||||
|
||||
List<Regions> reList = Lists.newArrayList();
|
||||
|
||||
list.forEach(
|
||||
each->{
|
||||
String left = StringUtils.substringAfter(each, "(");
|
||||
String right = StringUtils.substringBefore(left, ")");
|
||||
String s = right.replaceAll("\'", "");
|
||||
String[] split = s.split(",");
|
||||
if (split.length == 5){
|
||||
Regions regions = new Regions();
|
||||
regions.setId(split[0]);
|
||||
regions.setProvince(split[1]);
|
||||
regions.setCity(split[2]);
|
||||
regions.setZip_code(split[3]);
|
||||
regions.setArea_code(split[4]);
|
||||
reList.add(regions);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
int[] ints = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {
|
||||
preparedStatement.setInt(1,Integer.valueOf(reList.get(i).getId()));
|
||||
preparedStatement.setString(2,reList.get(i).getProvince());
|
||||
preparedStatement.setString(3,reList.get(i).getCity());
|
||||
preparedStatement.setString(4,reList.get(i).getZip_code());
|
||||
preparedStatement.setString(5,reList.get(i).getArea_code());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return reList.size();
|
||||
}
|
||||
});
|
||||
|
||||
log.info("受影响的行数为: {}", ints.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试批量插入数据
|
||||
*/
|
||||
@Test
|
||||
public void testBatchInsert2(){
|
||||
|
||||
// String sql = FileUtil.readString("D:\\apk整理\\Phone-Number-Range-master\\phone2.sql", Charset.defaultCharset());
|
||||
|
||||
@Data
|
||||
class Phones{
|
||||
private String id;
|
||||
private String number;
|
||||
private String type;
|
||||
private String region_id;
|
||||
}
|
||||
|
||||
String sql = "INSERT INTO `tb_phones` (id,number,type,region_id)VALUES (?, ?, ?, ?)";
|
||||
|
||||
|
||||
List<String> list = FileUtil.readLines("D:\\apk整理\\Phone-Number-Range-master\\phones1.sql", Charset.defaultCharset());
|
||||
|
||||
List<Phones> reList = Lists.newArrayList();
|
||||
|
||||
list.forEach(
|
||||
each->{
|
||||
String left = StringUtils.substringAfter(each, "(");
|
||||
String right = StringUtils.substringBefore(left, ")");
|
||||
String s = right.replaceAll("\'", "");
|
||||
String[] split = s.split(",");
|
||||
if (split.length == 4){
|
||||
Phones phones = new Phones();
|
||||
phones.setId(split[0]);
|
||||
phones.setNumber(split[1]);
|
||||
phones.setType(split[2]);
|
||||
phones.setRegion_id(split[3]);
|
||||
reList.add(phones);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
int[] ints = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {
|
||||
preparedStatement.setInt(1,Integer.valueOf(reList.get(i).getId().trim()));
|
||||
preparedStatement.setInt(2,Integer.valueOf(reList.get(i).getNumber().trim()));
|
||||
preparedStatement.setInt(3,Integer.valueOf(reList.get(i).getType().trim()));
|
||||
preparedStatement.setInt(4,Integer.valueOf(reList.get(i).getRegion_id().trim()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return reList.size();
|
||||
}
|
||||
});
|
||||
|
||||
log.info("受影响的行数为: {}", ints.length);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private PhonesRepository phonesRepository;
|
||||
|
||||
/**
|
||||
* 测试手机号段匹配地区属性
|
||||
*/
|
||||
@Test
|
||||
public void testMatchArea(){
|
||||
String phone = "18958049294";
|
||||
|
||||
if (phone.length() == 11 ){
|
||||
String substring = StringUtils.substring(phone, 0, phone.length() - 4);
|
||||
System.out.println(phonesRepository.findByNumber(substring)); // 1300018
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue