2023年6月22日 修改定时任务,

This commit is contained in:
bai 2023-06-22 00:18:47 +08:00
parent 873e0e3179
commit 553b68ae45
2 changed files with 100 additions and 30 deletions

View File

@ -79,25 +79,26 @@ public class SyncTFwdtBkjxtkpj extends BaseSync {
isAll = Boolean.parseBoolean(isAllStr);
}
}
// if(param.containsKey("nowDay")){
// String nowDayStr = (String)param.get("nowDay");
// if(StringUtils.isNotBlank(nowDayStr)){
// now = DateUtil.parse(nowDayStr, "yyyy-MM-dd");
// }
// }
if(param.containsKey("nowDay")){
String nowDayStr = (String)param.get("nowDay");
if(StringUtils.isNotBlank(nowDayStr)){
now = DateUtil.parse(nowDayStr, "yyyy-MM-dd");
}
}
}
//查询数据
Date date = new Date();//获取当前时间
Date date = now;//获取当前时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);//当前时间前去一天
QueryWrapper<TFwdtBkjxtkpj> queryWrapper = new QueryWrapper<>();
// queryWrapper.like("timestamps", DateUtils.formatDate(calendar.getTime(),"yyyy-MM-dd"));//增量数据
String nowStr = DateUtils.formatDate(calendar.getTime(),"yyyy-MM-dd");
if(!isAll){
queryWrapper.apply("trunc(timestamps,'dd') = to_date('"+DateUtils.formatDate(calendar.getTime(),"yyyy-MM-dd")+"','yyyy-mm-dd')");
// queryWrapper.between("timestamps","to_date('"+nowStr+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS')","to_date('"+nowStr+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS')");
queryWrapper.apply("timestamps between to_date('"+nowStr+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS') and to_date('"+nowStr+" 23:59:59', 'yyyy-MM-dd HH24:MI:SS')");
}
List<TFwdtBkjxtkpj> inDataList = tfwdtBkjxtkpjService.list(queryWrapper);
List<Xxhbbkjxtkpj> outDataList = Lists.newArrayList();
@ -105,6 +106,10 @@ public class SyncTFwdtBkjxtkpj extends BaseSync {
//清洗数据
inDataList.forEach(x -> outDataList.add(BeanUtil.toBean(x, Xxhbbkjxtkpj.class)));
QueryWrapper<Xxhbbkjxtkpj> xxhbbkjxtkpjQw = new QueryWrapper<>();
//xxhbbkjxtkpjQw.between("timestamps","str_to_date('"+nowStr+"', '%Y-%m-%d')","str_to_date('"+nowStr+"', '%Y-%m-%d')");
xxhbbkjxtkpjQw.apply("timestamps between str_to_date('"+nowStr+"', '%Y-%m-%d') and str_to_date('"+nowStr+"', '%Y-%m-%d')");
xxhbbkjxtkpjService.remove(xxhbbkjxtkpjQw);
//保存到胃
xxhbbkjxtkpjService.syncList(outDataList,false);

View File

@ -2,9 +2,11 @@ package org.jeecg.modules.kc.grab.SynchronizationService;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.kc.grab.SynchronizationService.base.BaseSync;
import org.jeecg.modules.kc.grab.exports.entity.TJwXsxkb;
import org.jeecg.modules.kc.grab.exports.service.ITJwXsxkbService;
@ -45,29 +47,90 @@ public class SyncTJwXsxkb extends BaseSync {
public void run(Map<String, Object> param){
QueryWrapper eqw = new QueryWrapper();
QueryWrapper dqw = new QueryWrapper();
boolean isDelete = true;
DateTime now = DateTime.now();
String startDate = "";
String endDate = "";
boolean isAll = false;
boolean isScope = false;
boolean isToday = false;
if(param != null){
if(Boolean.parseBoolean((String)param.get("isToday"))){
//如果是今天模式
String nowStr = DateTime.now().toDateStr();
eqw.apply("TIMESTAMPS >= to_date('"+nowStr+"', 'yyyy-MM-dd')");
eqw.apply("TIMESTAMPS < to_date('"+nowStr+"','yyyy-MM-dd')");
dqw.apply("TIMESTAMPS >= str_to_date('"+nowStr+"', 'yyyy-MM-dd')");
dqw.apply("TIMESTAMPS < str_to_date('"+nowStr+"','yyyy-MM-dd')");
isDelete = false;
} else if (Boolean.parseBoolean((String)param.get("isScope"))) {
//按照范围查询
String startDate = (String)param.get("startDate");
String endDate = (String)param.get("endDate");
eqw.apply("TIMESTAMPS >= to_date('"+startDate+"', 'yyyy-MM-dd')");
eqw.apply("TIMESTAMPS < to_date('"+endDate+"','yyyy-MM-dd')");
dqw.apply("TIMESTAMPS >= str_to_date('"+startDate+"', 'yyyy-MM-dd')");
dqw.apply("TIMESTAMPS < str_to_date('"+endDate+"','yyyy-MM-dd')");
isDelete = false;
} else if (Boolean.parseBoolean((String)param.get("isAll"))) {
//全部
if(param.containsKey("isAll")){
String isAllStr = (String)param.get("isAll");
if(StringUtils.isNotBlank(isAllStr)){
isAll = Boolean.parseBoolean(isAllStr);
}
}
if(param.containsKey("now")){
String keyStr = (String)param.get("now");
if(StringUtils.isNotBlank(keyStr)){
now = DateUtil.parse(keyStr, "yyyy-MM-dd");
}
}
if(param.containsKey("isScope")){//按照范围
String isScopeStr = (String)param.get("isScope");
if(StringUtils.isNotBlank(isScopeStr)){
isScope = Boolean.parseBoolean(isScopeStr);
if(isScope){
isAll = false;
startDate = (String)param.get("startDate");
endDate = (String)param.get("endDate");
}
}
}
}
if(!isAll){
//范围
if(isScope && StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate) ){
//按范围查询
// eqw.between("timestamps","to_date('"+startDate+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS')","to_date('"+endDate+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS')");
// dqw.between("timestamps","str_to_date('"+startDate+"', '%Y-%m-%d')","str_to_date('"+endDate+"', '%Y-%m-%d')");
eqw.apply("timestamps between to_date('"+startDate+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS') and to_date('"+endDate+" 23:59:59', 'yyyy-MM-dd HH24:MI:SS')");
dqw.apply("timestamps between str_to_date('"+startDate+"', '%Y-%m-%d') and str_to_date('"+endDate+"', '%Y-%m-%d')");
// eqw.apply("TIMESTAMPS >= to_date('"+startDate+"', 'yyyy-MM-dd')");
// eqw.apply("TIMESTAMPS < to_date('"+endDate+"','yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS >= str_to_date('"+startDate+"', 'yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS < str_to_date('"+endDate+"','yyyy-MM-dd')");
}else{
//按天
String nowStr = DateTime.now().toDateStr();
// eqw.between("timestamps","to_date('"+nowStr+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS')","to_date('"+nowStr+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS')");
// dqw.between("timestamps","str_to_date('"+nowStr+"', '%Y-%m-%d')","str_to_date('"+nowStr+"', '%Y-%m-%d')");
eqw.apply("timestamps between to_date('"+nowStr+" 00:00:00', 'yyyy-MM-dd HH24:MI:SS') and to_date('"+nowStr+" 23:59:59', 'yyyy-MM-dd HH24:MI:SS')");
dqw.apply("timestamps between str_to_date('"+nowStr+"', '%Y-%m-%d') and str_to_date('"+nowStr+"', '%Y-%m-%d')");
// eqw.apply("TIMESTAMPS >= to_date('"+nowStr+"', 'yyyy-MM-dd')");
// eqw.apply("TIMESTAMPS < to_date('"+nowStr+"','yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS >= str_to_date('"+nowStr+"', 'yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS < str_to_date('"+nowStr+"','yyyy-MM-dd')");
}
}
// boolean isDelete = true;
// if(param != null){
// if(Boolean.parseBoolean((String)param.get("isToday"))){
// //如果是今天模式
// String nowStr = DateTime.now().toDateStr();
// eqw.apply("TIMESTAMPS >= to_date('"+nowStr+"', 'yyyy-MM-dd')");
// eqw.apply("TIMESTAMPS < to_date('"+nowStr+"','yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS >= str_to_date('"+nowStr+"', 'yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS < str_to_date('"+nowStr+"','yyyy-MM-dd')");
// isDelete = false;
// } else if (Boolean.parseBoolean((String)param.get("isScope"))) {
// //按照范围查询
// String startDate = (String)param.get("startDate");
// String endDate = (String)param.get("endDate");
// eqw.apply("TIMESTAMPS >= to_date('"+startDate+"', 'yyyy-MM-dd')");
// eqw.apply("TIMESTAMPS < to_date('"+endDate+"','yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS >= str_to_date('"+startDate+"', 'yyyy-MM-dd')");
// dqw.apply("TIMESTAMPS < str_to_date('"+endDate+"','yyyy-MM-dd')");
// isDelete = false;
// } else if (Boolean.parseBoolean((String)param.get("isAll"))) {
// //全部
// }
// }
//查询数据
List<TJwXsxkb> inDataList = expService.list(eqw);
List<Xxhbxsxkb> outDataList = Lists.newArrayList();
@ -79,7 +142,9 @@ public class SyncTJwXsxkb extends BaseSync {
int syncnum=0;
String errorMessage = "";
try {
impService.syncList(outDataList);
//删除数据
// impService.remove(dqw);
impService.syncList(outDataList,dqw,true);
syncnum = outDataList.size();
}catch (Exception e){
e.printStackTrace();