ZrTask.java
4.3 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.chinagas.modules.job.task;
import com.chinagas.api.fksb.RemoteFksbService;
import com.chinagas.api.mcsb.RemoteMcsbService;
import com.chinagas.api.system.RemoteDataSyncService;
import com.chinagas.common.core.constants.Constants;
import com.chinagas.common.core.domain.R;
import com.chinagas.common.security.utils.SecurityUtils;
import com.chinagas.modules.job.mapper.SysJobMapper;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Random;
/**
* @ClassName ZrTask
* @Author lidengwei
* @Description TODO
* @CreateTime 2022/10/13 16:08
*/
@Component("ZrTask")
public class ZrTask {
@Autowired
private RemoteDataSyncService dataSyncService;
@Autowired
private RemoteMcsbService mcsbService;
@Autowired
private RemoteFksbService fksbService;
@Autowired
private SysJobMapper sysJobMapper;
public void syncOrgData(String ifacecode) throws JobExecutionException, IOException {
R<Integer> res = dataSyncService.dataSync(ifacecode);
if(Constants.FAIL.equals(res.getCode())){
throw new JobExecutionException(res.getMsg());
}
}
/**
* 定时修改密码
*/
public void syncUpdatePassword(){
String randomString = generateRandomString(12);
sysJobMapper.updateUserPassword(SecurityUtils.encryptPassword(randomString));
}
private static final String LOWER_CASE = "abcdefghijklmnopqrstuvwxyz";
private static final String UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String DIGITS = "0123456789";
private static final String SPECIAL_CHARACTERS = "!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?";
public static String generateRandomString(int length) {
StringBuilder sb = new StringBuilder(length);
Random random = new Random();
// 确保至少包含一个小写字母、大写字母、数字和特殊字符
sb.append(getRandomChar(LOWER_CASE, random));
sb.append(getRandomChar(UPPER_CASE, random));
sb.append(getRandomChar(DIGITS, random));
sb.append(getRandomChar(SPECIAL_CHARACTERS, random));
// 填充剩余的字符
for (int i = 4; i < length; i++) {
String charSet = LOWER_CASE + UPPER_CASE + DIGITS + SPECIAL_CHARACTERS;
char nextChar = getRandomChar(charSet, random);
// 避免连续的字符
if (i > 0 && sb.charAt(i - 1) == nextChar) {
do {
nextChar = getRandomChar(charSet, random);
} while (sb.charAt(i - 1) == nextChar);
}
sb.append(nextChar);
}
// 打乱顺序以避免连续的字符
shuffle(sb, random);
return sb.toString();
}
private static char getRandomChar(String charSet, Random random) {
int index = random.nextInt(charSet.length());
return charSet.charAt(index);
}
private static void shuffle(StringBuilder sb, Random random) {
for (int i = sb.length() - 1; i > 0; i--) {
int j = random.nextInt(i + 1);
char temp = sb.charAt(i);
sb.setCharAt(i, sb.charAt(j));
sb.setCharAt(j, temp);
}
}
// //读取财务报表excel文件
// public void readMcsbExcel() throws JobExecutionException {
// R<Integer> res = mcsbService.readMcsbExcel();
// if(Constants.FAIL.equals(res.getCode())){
// throw new JobExecutionException(res.getMsg());
// }
// }
//
// //读取非控股公司指标报表excel文件
// public void readFksbExcel() throws JobExecutionException {
// R<Integer> res = fksbService.readFksbExcel();
// if(Constants.FAIL.equals(res.getCode())){
// throw new JobExecutionException(res.getMsg());
// }
// }
// public void ysEntitySync() throws JobExecutionException{
// R<Integer> res = dataSyncService.ysEntitySync();
// if(Constants.FAIL.equals(res.getCode())){
// throw new JobExecutionException(res.getMsg());
// }
// }
// public void sendFestivalMsg(){
// remoteCustomerService.sendFestivalMsg();
// }
//
// public void sendBirthdayMsg(){
// remoteCustomerService.sendBirthdayMsg();
// }
}