8 changed files with 213 additions and 47 deletions
@ -1,10 +1,14 @@
|
||||
package org.springblade.ftpdemo.service; |
||||
|
||||
import java.io.FileNotFoundException; |
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* @author laifeng |
||||
* @since 2022/11/27 |
||||
*/ |
||||
public interface Method { |
||||
void upMethod(String readFile, String upSrc,String tableName) throws Exception; |
||||
String creatFile(); |
||||
void upMethod(String readFile, String upSrc,String tableName,String operationName) throws Exception; |
||||
|
||||
Boolean creatIdentificationUpFile(Integer type,String yyyyMMdd,String yyyyMMddToday) throws IOException; |
||||
} |
||||
|
@ -1,32 +0,0 @@
|
||||
package org.springblade.ftpdemo.task; |
||||
|
||||
import org.springblade.ftpdemo.entity.NbmsEntApply; |
||||
import org.springblade.ftpdemo.service.NbmsEntApplyServcie; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 三、 标识解析企业主体信息上报 |
||||
* @author laifeng |
||||
* @since 2022/11/29 |
||||
*/ |
||||
@Component |
||||
@EnableScheduling |
||||
@AllArgsConstructor |
||||
public class IdentificationUp { |
||||
private final NbmsEntApplyServcie service; |
||||
|
||||
@Scheduled(cron = "0 0/5 * * * ?") |
||||
public void refreshAliDeviceStatus() { |
||||
|
||||
// 查询昨日新增注册
|
||||
List<NbmsEntApply> list = service.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2) |
||||
.eq(NbmsEntApply::getApplyType, 1) |
||||
.eq(NbmsEntApply::getApplyStep,4) |
||||
.list(); |
||||
} |
||||
} |
@ -0,0 +1,76 @@
|
||||
package org.springblade.ftpdemo.task; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.ftpdemo.service.Method; |
||||
import org.springblade.ftpdemo.service.NbmsEntApplyServcie; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 三、 标识解析企业主体信息上报 |
||||
* |
||||
* @author laifeng |
||||
* @since 2022/11/29 |
||||
*/ |
||||
@Component |
||||
@EnableScheduling |
||||
@AllArgsConstructor |
||||
public class IdentificationUpTask { |
||||
private final NbmsEntApplyServcie nbmsEntApplyServcie; |
||||
private final Method method; |
||||
|
||||
@Scheduled(cron = "0 0/1 * * * ?") |
||||
public void refreshAliDeviceStatus() { |
||||
// 检测新增并上传
|
||||
packMethod(0); |
||||
// 检测更新并上传
|
||||
packMethod(1); |
||||
|
||||
} |
||||
|
||||
private void packMethod(Integer type) { |
||||
// 时间格式化
|
||||
Date now = DateUtil.now(); |
||||
Date date = DateUtil.minusDays(now, 1); |
||||
String yyyyMMdd = DateUtil.format(date, "yyyyMMdd"); |
||||
String yyyyMMddToday = DateUtil.format(now, "yyyyMMdd"); |
||||
Boolean temp = false; |
||||
|
||||
try { |
||||
temp = method.creatIdentificationUpFile(type, yyyyMMdd, yyyyMMddToday); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
// 如果没有生成文件,可直接结束
|
||||
if (!temp) { |
||||
return; |
||||
} |
||||
|
||||
|
||||
String fileName = "d://aaa//test.txt"; |
||||
// 要上传的目录
|
||||
String upSrc = "/001/" + yyyyMMdd; |
||||
// 表名(文件名的一部分)
|
||||
String tableName = "SDQN-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); |
||||
} |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue