添加设备id 分批执行任务

master
bynt 1 year ago
parent 7a6f804ab5
commit 9754183e1a

@ -50,6 +50,9 @@ public class NewPlatFormRecordTask {
@Value("${platform.url}")
private String url;
@Value("${platform.workId}")
private Integer workId;
private DateTime beginTime;
private final AdPlatformService adPlatformService;
@ -71,17 +74,27 @@ public class NewPlatFormRecordTask {
DateTime date = DateUtil.date();
if (CollUtil.isNotEmpty(platform.getTagStr())) {
String tagStr = platform.getTagStr().get(0);
List<String> tagList = platform.getTagStr();
if (tagStr.contains(StrPool.DASHED)) {
Integer value = DeliveryPlatformEnum.getValue
(tagStr.substring(0, tagStr.indexOf(StrPool.DASHED)));
// 当前设备使用哪些tag
if (workId != null && workId < Integer.SIZE) {
tagList = tagList.stream().filter(letter -> workId ==
(letter.hashCode() & Integer.MAX_VALUE) % 3).collect(Collectors.toList());
if (CollUtil.isEmpty(tagList)) {
continue;
}
}
// 偏移十分钟
DateTime offsetMinute = ObjectUtil.isNull(beginTime) ?
DateUtil.offsetMinute(date, -9) :
DateUtil.offsetMinute(beginTime, -9);
DateUtil.offsetMinute(beginTime, -9);
beginTime = offsetMinute;
log.info("================ the begin time as {} end time as {} ================", offsetMinute, date);
List<PlateFormDTO> dtoList = backDataEntityService.queryNewPlateFormDTO
(CharSequenceUtil.NULL.toUpperCase(), "__IMEI__", offsetMinute, date, platform.getTagStr(), value);
(CharSequenceUtil.NULL.toUpperCase(), "__IMEI__", offsetMinute, date, tagList, value);
log.info("================ the dto list as {} ================", dtoList.size());
if (CollUtil.isNotEmpty(dtoList)) {
// tag进行分组

@ -53,6 +53,9 @@ public class PlatFormRecordTask {
@Value("${platform.url}")
private String url;
@Value("${platform.workId}")
private Integer workId;
private DateTime beginTime;
private final AdPlatformService adPlatformService;
@ -76,9 +79,19 @@ public class PlatFormRecordTask {
DateTime date = DateUtil.date();
if (CollUtil.isNotEmpty(platform.getTagStr())) {
String tagStr = platform.getTagStr().get(0);
List<String> tagList = platform.getTagStr();
if (tagStr.contains(StrPool.DASHED)) {
Integer value = DeliveryPlatformEnum.getValue
(tagStr.substring(0, tagStr.indexOf(StrPool.DASHED)));
// 当前设备使用哪些tag
if (workId != null && workId < Integer.SIZE) {
tagList = tagList.stream().filter(letter -> workId ==
(letter.hashCode() & Integer.MAX_VALUE) % 3).collect(Collectors.toList());
if (CollUtil.isEmpty(tagList)) {
continue;
}
}
// 偏移十分钟
DateTime offsetMinute = ObjectUtil.isNull(beginTime) ?
DateUtil.offsetMinute(date, -10) :
@ -86,7 +99,7 @@ public class PlatFormRecordTask {
beginTime = offsetMinute;
log.info("================ the begin time as {} end time as {} ================", offsetMinute, date);
List<PlateFormDTO> dtoList = backDataEntityService.queryPlateFormDTO
(CharSequenceUtil.EMPTY, "__IMEI__", offsetMinute, date, platform.getTagStr(), value);
(CharSequenceUtil.EMPTY, "__IMEI__", offsetMinute, date, tagList, value);
log.info("================ the dto list as {} ================", dtoList.size());
if (CollUtil.isNotEmpty(dtoList)) {
// tag进行分组

@ -0,0 +1,187 @@
package com.baiyee.adcallback.tools;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class TxtUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(TxtUtils.class);
/**
* txt
* @param inputStream
* @return
* @throws IOException
*/
public static List<String> txtParseList(InputStream inputStream) throws IOException {
List<String> list = new ArrayList<>();
BufferedReader d = new BufferedReader(new InputStreamReader(inputStream));
try {
String count;
while((count = d.readLine()) != null){
String u = count.toUpperCase();
list.add(u);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | txtParseList ==========未找到文件");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | txtParseList ==========解析失败!!");
e.printStackTrace();
}finally {
d.close();
}
return list;
}
/**
* txt
* @param url
* update
* @return
* @throws IOException
*/
public static List<String> txtParseListVyUrl(String url) throws IOException {
List<String> list = new ArrayList<>();
InputStream inputStream = new FileInputStream(url) ;
BufferedReader d = new BufferedReader(new InputStreamReader(inputStream));
try {
String count;
while((count = d.readLine()) != null){
String u = CharSequenceUtil.cleanBlank(count.toUpperCase());
list.add(u);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | txtParseList ==========未找到文件");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | txtParseList ==========解析失败!!");
e.printStackTrace();
}finally {
d.close();
}
return list;
}
/**
* csv
* @param inputStream
* @return
* @throws IOException
*/
public static List<String> csvParseList(InputStream inputStream) throws IOException {
List<String> list = new ArrayList<>();
BufferedReader d = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder builder = new StringBuilder();
try {
String count;
while((count = d.readLine()) != null){
String u = count.toUpperCase();
builder.append(u+",");
}
log.error("========== [builder.toString] =========="+builder.toString());
if (builder!=null){
String str= builder.toString();
String[] split = str.split(",");
for (String sp : split) {
list.add(sp);
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | csvParseList ==========未找到文件");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | csvParseList ==========解析失败!!");
e.printStackTrace();
}finally {
d.close();
}
return list;
}
/**
* csv
* @param url
* @return
* @throws IOException
*/
public static List<String> csvParseListByUrl(String url) throws IOException {
List<String> list = new ArrayList<>();
InputStream inputStream = new FileInputStream(new File(url)) ;
BufferedReader d = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder builder = new StringBuilder();
try {
String count;
while((count = d.readLine()) != null){
String u = count.toUpperCase();
builder.append(u+",");
}
log.error("========== [builder.toString] =========="+builder.toString());
if (builder!=null){
String str= builder.toString();
String[] split = str.split(",");
for (String sp : split) {
list.add(sp);
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | csvParseList ==========未找到文件");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
log.info("TxtUtils | csvParseList ==========解析失败!!");
e.printStackTrace();
}finally {
d.close();
}
return list;
}
/**
* Object[] Java Bean
* @param objectArray
* @param clazz Bean
* @param <T>
* @return
*/
@SneakyThrows
public static <T> T objectArrayToBean(Object[] objectArray, Class<T> clazz) {
if (objectArray == null || objectArray.length == 0){
return null;
}
Class<?>[] tClass = null;
Constructor<?>[] constructors = clazz.getConstructors();
for (int i = 0; i < constructors.length; i++){
Constructor<?> constructor = constructors[i];
Class<?>[] parameterTypes = constructor.getParameterTypes();
if (parameterTypes.length == objectArray.length){
tClass = parameterTypes;
break;
}
}
return clazz.getConstructor(tClass).newInstance(objectArray);
}
}

@ -233,6 +233,7 @@ spring:
platform:
authToken: JI8AeA7POKsdGcBC
url: http://8.130.96.163:8866/api/taskImei/callback/add
workId: 32
tf:
source:

@ -227,6 +227,7 @@ spring:
platform:
authToken: nqJpVSf3UcrEcVIH
url: https://baiyee.vip/api/taskImei/callback/add
workId: 32
tf:
source:

Loading…
Cancel
Save