EntmicroFollowServiceTest.java
4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package cn.com.glsx.entmicro.service;
import cn.com.glsx.entmicro.Main;
import cn.com.glsx.entmicro.entity.EntmicroCustomerFollow;
import cn.com.glsx.entmicro.mapper.EntmicroCustomerFollowMapper;
import cn.com.glsx.entmicro.model.request.GetStaffFollowCustomerRequest;
import cn.com.glsx.entmicro.service.cache.RedisCacheService;
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.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Lichongyuan
* @Description:
* @date 2021/11/5 11:44
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class EntmicroFollowServiceTest {
@Autowired
private EntmicroFollowService entmicroFollowService;
@Resource
private EntmicroCustomerFollowMapper entmicroCustomerFollowMapper;
@Resource
private SyncCustomerService syncCustomerService;
@Resource
private RedisCacheService redisCacheService;
@Test
public void insert() {
List<EntmicroCustomerFollow> customerFollowRelations = new ArrayList<>();
EntmicroCustomerFollow entmicroCustomerFollow = new EntmicroCustomerFollow();
entmicroCustomerFollow.setAddWay(2);
entmicroCustomerFollow.setStaffId(19);
entmicroCustomerFollow.setCustomerId(829);
entmicroCustomerFollow.setDelFlag((byte)0);
customerFollowRelations.add(entmicroCustomerFollow);
EntmicroCustomerFollow entmicroCustomerFollow1 = new EntmicroCustomerFollow();
entmicroCustomerFollow1.setAddWay(3);
entmicroCustomerFollow1.setStaffId(18);
entmicroCustomerFollow1.setDelFlag((byte)0);
entmicroCustomerFollow1.setCustomerId(855);
customerFollowRelations.add(entmicroCustomerFollow1);
entmicroFollowService.insert(customerFollowRelations);
}
@Test
public void getStaffFollowCustomerTest(){
GetStaffFollowCustomerRequest request = new GetStaffFollowCustomerRequest();
request.setMerchantId(44211425);
request.setCustomerPhone("17750020170");
request.setStaffUserIdList(Arrays.asList("wo-ZewEAAAdWCWU-E6ti-_EDYp4yq5Ow","wo-ZewEAAAZTCCHRHzUWt2SjOJNFnm7w"));
System.out.println(entmicroFollowService.getStaffFollowCustomer(request));
}
@Test
public void selectCustomerFollowRemarkTest(){
List<Integer> merchantIdList = null;
List<Map<String, Object>> maps = entmicroCustomerFollowMapper.selectCustomerFollowRemark(new Date(), merchantIdList);
System.out.println("===============" + maps);
}
@Test
public void syncCustomerRemarkToCdpTest() throws ParseException {
// redisCacheService.deleteCache("sync_customer_remark_to_cdp_cache");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = format.parse("2024-01-31 01:00:01");
redisCacheService.setCache("sync_customer_remark_to_cdp_cache", parse, 60 * 60 * 24 * 7L);
syncCustomerService.syncCustomerRemarkToCdp();
}
@Test
public void cacheTest(){
Date date = new Date();
System.out.println("1===========" + date);
redisCacheService.setCache("sync_customer_remark_to_cdp_cache",date);
Object cache = redisCacheService.getCache("sync_customer_remark_to_cdp_cache");
date = (Date)cache;
System.out.println("2===========" + date);
redisCacheService.deleteCache("sync_customer_remark_to_cdp_cache");
}
public static void main(String[] args) {
String regular = ".*?-.*?-.*";
String filter = "^(.*?-[^-]*-[^-])-.*$";
Pattern compile = Pattern.compile(regular);
List<String> list = Arrays.asList("3-23B甘女士(租户)","3-23B甘女士(租户)","2-1-21E(业主父亲)","12-7A 郑圆(业主)","16-2-7A 郑圆(业主)","业主父亲");
for (String data : list) {
// System.out.println(string);
Matcher matcher = compile.matcher(data);
boolean x = matcher.find();
String string = data.replaceAll("^(.*?)(?:-[^-]*)$", "$1");
// string = string.replaceAll(".*-(.*)", "$1");
System.out.println(data + x + ": " + string);
}
}
}