定时任务修改,数据同步修改
parent
a0bc0282f7
commit
3ced98f089
|
|
@ -16,6 +16,7 @@ import com.jfinal.plugin.activerecord.Record;
|
|||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -77,6 +78,30 @@ public class OrderEndService extends BaseService {
|
|||
paraList.add(customerId);
|
||||
}
|
||||
|
||||
return OrderEnd.dao.find(sql,paraList.toArray());
|
||||
}
|
||||
public List<OrderEnd> getOrderEndByTm(List<Date> dates) {
|
||||
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
String sql = "SELECT * FROM ORDER_END \n" +
|
||||
"WHERE 1 = 1 \n";
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dates)){
|
||||
sql += (" and DATE in (");
|
||||
|
||||
for (int i = 0; i < dates.size(); i++) {
|
||||
if (i > 0) {
|
||||
sql += (",");
|
||||
}
|
||||
sql += ("?");
|
||||
paraList.add(DateTimeUtil.sdf.get().format(dates.get(i)));
|
||||
}
|
||||
|
||||
|
||||
sql += (" )");
|
||||
}
|
||||
|
||||
|
||||
return OrderEnd.dao.find(sql,paraList.toArray());
|
||||
}
|
||||
public void initialize(){
|
||||
|
|
@ -151,6 +176,13 @@ public class OrderEndService extends BaseService {
|
|||
lists = getOrderEndByTm(tm,customerId);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(lists) && CollectionUtils.isNotEmpty(orderEnds)){
|
||||
List<Date> dates = orderEnds.stream().map(OrderEnd::getDate)
|
||||
.collect(toList());
|
||||
lists = getOrderEndByTm(dates);
|
||||
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(lists)){
|
||||
|
||||
if (CollectionUtils.isNotEmpty(lists)){
|
||||
|
|
|
|||
|
|
@ -472,6 +472,8 @@ public class OrderTempService extends BaseService {
|
|||
}
|
||||
if (stm != null && etm != null) {
|
||||
findSql += " AND CREATE_TIME BETWEEN ? AND ? \n";
|
||||
System.out.println("stm:" + stm);
|
||||
System.out.println("etm:" + etm);
|
||||
paraList.add(stm + STM_SUFFIX);
|
||||
paraList.add(etm + ETM_SUFFIX);
|
||||
} else if (tm != null) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class OrderEndJob implements Job {
|
|||
// 获取前一天的数据
|
||||
log.info("开始同步");
|
||||
LocalDate localDate = LocalDate.now().minusDays(1);
|
||||
OrderEndService.me.queryList(localDate.minusDays(60).toString(),localDate.toString()); // 最近60天的数据
|
||||
OrderEndService.me.queryList(localDate.minusDays(60).toString(),localDate.toString(),null); // 最近60天的数据
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.cowr.service.ssjygl.main.SvrCacheData;
|
|||
import com.cowr.service.ssjygl.truck.truckweightlimit.TruckWeightLimitService;
|
||||
import com.cowr.ssjygl.CacheData;
|
||||
import com.cowr.ssjygl.blacklist.BlacklistService;
|
||||
import com.cowr.ssjygl.order.orderend.OrderEndService;
|
||||
import com.cowr.ssjygl.truck.weightlimitmodifylog.TruckWeightLimitModifyLogService;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
|
|
@ -372,6 +373,10 @@ public class SyncTaskService {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是订单修改 就更新order_end表
|
||||
log.info("新增: " + list.size());
|
||||
updataOrderTemp(tablename, list); // 新增
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -442,6 +447,10 @@ public class SyncTaskService {
|
|||
return false;
|
||||
}
|
||||
|
||||
// 如果是订单修改 就更新order_end表
|
||||
log.info("修改: " + list.size());
|
||||
updataOrderTemp(tablename, list); // 修改
|
||||
|
||||
for (int i : ret) {
|
||||
// 必须是每条 sql 修改一条记录
|
||||
if (i != 1) {
|
||||
|
|
@ -472,6 +481,8 @@ public class SyncTaskService {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -601,6 +612,18 @@ public class SyncTaskService {
|
|||
|
||||
|
||||
// 过滤新增数据
|
||||
private void updataOrderTemp(String tablename, List<Record> list) {
|
||||
if ("order_temp".equals(tablename)) {
|
||||
// sn
|
||||
for (Record o : list) {
|
||||
String tm = o.getStr("create_time").split(" ")[0];
|
||||
String customerId = o.getStr("customer_id");
|
||||
log.info("order_end 同步数据: " + tm + " " + customerId);
|
||||
OrderEndService.me.queryList(tm,customerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Record> listFilter(String tablename, List<Record> list) {
|
||||
|
||||
List<Record> removeList = new ArrayList<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue