Browse Source

更改信息

master
李世鹏 2 years ago
parent
commit
25fd48e30c
  1. 31
      src/main/java/com/example/upsecuritydata/service/impl/MethodImpl.java
  2. 30
      src/main/java/com/example/upsecuritydata/task/IdentificationUpTask.java
  3. 62
      src/main/java/com/example/upsecuritydata/task/TestTask.java

31
src/main/java/com/example/upsecuritydata/service/impl/MethodImpl.java

@ -2,6 +2,7 @@ package com.example.upsecuritydata.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.upsecuritydata.cache.CodeCache;
@ -117,13 +118,26 @@ public class MethodImpl implements Method {
.lt(NbmsEntApply::getUpdateDate, yyyyMMddToday)
.list();
}
// 全量操作
if (type == 2) {
list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
.eq(NbmsEntApply::getApplyType, 1)
.eq(NbmsEntApply::getApplyStep, 4)
.list();
}
// 创建输出流
FileOutputStream stream = new FileOutputStream(Constant.localNotEncryFileNamePath);
if (CollUtil.isNotEmpty(list)) {
for (NbmsEntApply nbmsEnapply : list) {
companyCode = nbmsEnapply.getEntPrefix();
companyName = nbmsEnapply.getOrgName();
level = "4";
List<String> split = StrUtil.split(companyCode, ".");
if ("000000".equals(split.get(2))) {
level = "4";
} else {
level = "5";
}
accessProvince = nbmsEnapply.getOrgAddrProvince();
accessProvince = CodeCache.codeMap.get(accessProvince);
@ -160,9 +174,9 @@ public class MethodImpl implements Method {
@Override
public Boolean creatForUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException {
String companyName; // 标识解析节点经营主体名称
String startIP = "223.99.228.240";
String endIP = "223.99.228.240";
String position = "中国山东省济南市自由贸易试验区济南片区颖秀路2299号";
String startIP = "112.6.110.61";
String endIP = "112.6.110.61";
String position = "山东省济宁市济宁宁化大数据中心";
List<NbmsEnprefix> list = null;
if (type == 0) {
list = enprefixService.query()
@ -229,6 +243,13 @@ public class MethodImpl implements Method {
.lt(NbmsEntApply::getUpdateDate, yyyyMMddToday)
.list();
}
// 全量操作
if (type == 2) {
list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
.eq(NbmsEntApply::getApplyType, 1)
.eq(NbmsEntApply::getApplyStep, 4)
.list();
}
// 创建输出流
FileOutputStream stream = new FileOutputStream(Constant.localNotEncryFileNamePath);
if (CollUtil.isNotEmpty(list)) {
@ -253,7 +274,7 @@ public class MethodImpl implements Method {
companyType = judge(nbmsEnapply.getOrgNature());
serviceProfession = categoryB;
String template = companyCode + "|" + companyName + "|" + "|" + accessProvince + "|" + accessCity + "|" + registerTime + "|" + categoryA + "|" + categoryB + "|" + companyType + "|" + serviceProfession + "\n";
String template = companyCode + "|" + companyName + "|" + accessProvince + "|" + accessCity + "|" + registerTime + "|" + categoryA + "|" + categoryB + "|" + companyType + "|" + serviceProfession + "\n";
byte[] bytes = template.getBytes();
stream.write(bytes);
}

30
src/main/java/com/example/upsecuritydata/task/IdentificationUpTask.java

@ -7,8 +7,6 @@ import com.example.upsecuritydata.util.Constant;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
@ -90,8 +88,10 @@ public class IdentificationUpTask {
String logName = "";
if (type == 0) {
logName = "新增";
} else {
} else if (type == 1) {
logName = "更新";
} else {
logName = "全量";
}
XxlJobHelper.log("表1:昨日无" + logName + "数据日志!");
return;
@ -107,11 +107,14 @@ public class IdentificationUpTask {
if (type == 0) {
// 操作类型为新增
operationName = "-add.bin";
}
if (type == 1) {
} else if (type == 1) {
// 操作类型为更新
operationName = "-update.bin";
} else {
// 操作类型为全量上传
operationName = "-all.bin";
}
try {
method.upMethod(fileName, upSrc, tableName, operationName);
} catch (Exception e) {
@ -142,8 +145,10 @@ public class IdentificationUpTask {
String logName = "";
if (type == 0) {
logName = "新增";
} else {
} else if (type == 1) {
logName = "更新";
} else {
logName = "全量";
}
XxlJobHelper.log("表2:昨日无" + logName + "数据日志!");
return;
@ -162,6 +167,9 @@ public class IdentificationUpTask {
if (type == 1) {
// 操作类型为更新
operationName = "-update.bin";
} else if (type == 2) {
// 操作类型为全量
operationName = "-all.bin";
}
try {
method.upMethod(fileName, upSrc, tableName, operationName);
@ -192,8 +200,10 @@ public class IdentificationUpTask {
String logName = "";
if (type == 0) {
logName = "新增";
} else {
} else if (type == 1) {
logName = "更新";
} else {
logName = "全量";
}
XxlJobHelper.log("表3:昨日无" + logName + "数据日志!");
return;
@ -209,10 +219,12 @@ public class IdentificationUpTask {
if (type == 0) {
// 操作类型为新增
operationName = "-add.bin";
}
if (type == 1) {
} else if (type == 1) {
// 操作类型为更新
operationName = "-update.bin";
} else {
// 操作类型为全量
operationName = "-all.bin";
}
try {
method.upMethod(fileName, upSrc, tableName, operationName);

62
src/main/java/com/example/upsecuritydata/task/TestTask.java

@ -29,12 +29,7 @@ public class TestTask {
public void refreshAliDeviceStatus() throws Exception {
StopWatch stopWatch = new StopWatch("task");
stopWatch.start();
// String yesterday = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd");
// String yesterday = "20230215";
// method.creatSixUpFileAndUp(yesterday);
// threePackMethod(0);
fivePackMethod(0);
fivePackMethod(2);
stopWatch.stop();
double seconds = stopWatch.getTotalTimeSeconds();
@ -84,6 +79,51 @@ public class TestTask {
}
}
private void fourPackMethod(Integer type) {
// 时间格式化
Date date = DateUtil.yesterday();
String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
Boolean temp = false;
try {
temp = method.creatForUpFile(type, yyyyMMdd, yyyyMMddToday);
} catch (IOException e) {
throw new RuntimeException(e);
}
// 如果没有生成文件,可直接结束
if (!temp) {
String logName = "";
if (type == 0) {
logName = "新增";
} else {
logName = "更新";
}
XxlJobHelper.log("表2:昨日无" + logName + "数据日志!");
return;
}
String fileName = Constant.localNotEncryFileNamePath;
// 要上传的目录
String upSrc = "/002/" + yyyyMMdd;
// 表名(文件名的一部分)
String tableName = "ZLXT-basic_identification_ip-";
String operationName = "";
if (type == 0) {
// 操作类型为新增
operationName = "-add.bin";
}
if (type == 1) {
// 操作类型为更新
operationName = "-update.bin";
}
try {
method.upMethod(fileName, upSrc, tableName, operationName);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 标识注册企业主体信息上报
*
@ -106,8 +146,10 @@ public class TestTask {
String logName = "";
if (type == 0) {
logName = "新增";
} else {
} else if (type == 1) {
logName = "更新";
} else {
logName = "全量";
}
XxlJobHelper.log("表3:昨日无" + logName + "数据日志!");
return;
@ -123,10 +165,12 @@ public class TestTask {
if (type == 0) {
// 操作类型为新增
operationName = "-add.bin";
}
if (type == 1) {
} else if (type == 1) {
// 操作类型为更新
operationName = "-update.bin";
} else {
// 操作类型为全量
operationName = "-all.bin";
}
try {
method.upMethod(fileName, upSrc, tableName, operationName);

Loading…
Cancel
Save