|
|
@@ -1,14 +1,24 @@
|
|
|
package com.uas.platform.b2b.task;
|
|
|
|
|
|
import com.uas.platform.b2b.dao.CommunalLogDao;
|
|
|
+import com.uas.platform.b2b.dao.PurchaseNoticeDao;
|
|
|
+import com.uas.platform.b2b.dao.PurchaseOrderDao;
|
|
|
import com.uas.platform.b2b.model.CommunalLog;
|
|
|
+import com.uas.platform.core.util.HttpUtil;
|
|
|
+import org.apache.http.client.methods.HttpRequestBase;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.net.URI;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 每天定时更新发货提醒异常的数据
|
|
|
@@ -24,6 +34,12 @@ public class SendNoticeTask {
|
|
|
@Autowired
|
|
|
private CommunalLogDao communalLogDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ PurchaseNoticeDao purchaseNoticeDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PurchaseOrderDao purchaseOrderDao;
|
|
|
+
|
|
|
/**
|
|
|
* 时间格式
|
|
|
*/
|
|
|
@@ -60,4 +76,53 @@ public class SendNoticeTask {
|
|
|
jdbcTemplate.update(sql);
|
|
|
communalLogDao.save(new CommunalLog("更新发货提醒备料状态", "定时任务自动更新备料数据", "时间: " + sdf.format(new Date()), DEFAULT_ENUU));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天13点、19点、23点定时检测下发货提醒和订单索引
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 13,19,23 * * ? ")
|
|
|
+ public void checkIndex() throws Exception{
|
|
|
+ Date date = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.DATE,-1);
|
|
|
+ date = calendar.getTime();
|
|
|
+ List<Long> idsNotice = purchaseNoticeDao.findByDate(date);
|
|
|
+ calendar.add(Calendar.DATE,-4);
|
|
|
+ date = calendar.getTime();
|
|
|
+ List<Long> idsOrders = purchaseOrderDao.findByDate(date);
|
|
|
+ if (!CollectionUtils.isEmpty(idsNotice)) {
|
|
|
+ checkAndUpateAll("purc$notice",idsNotice);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(idsOrders)) {
|
|
|
+ checkAndUpateAll("purc$orders",idsOrders);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkAndUpateAll(String tableName,List<Long> ids) throws Exception{
|
|
|
+ List<Long> noExistIds = new ArrayList<>();
|
|
|
+ for (Long id :ids) {
|
|
|
+ String searchInfoUrl = "http://10.10.100.179:8081/search/object?tableName=" + tableName + "&id=";
|
|
|
+ HttpUtil.Response response = HttpUtil.sendGetRequest(searchInfoUrl + id, null);
|
|
|
+ if (StringUtils.isEmpty(response.getResponseText())) {
|
|
|
+ noExistIds.add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(noExistIds)) {
|
|
|
+ for (Long noExistId : noExistIds) {
|
|
|
+ String searchUpdateUrl ="http://10.10.100.179:8081/index/maintain?tableName=" + tableName + "&methodType=update&dataId=";
|
|
|
+ HttpRequestBase request = new HttpRequestBase() {
|
|
|
+ @Override
|
|
|
+ public String getMethod() {
|
|
|
+ return "GET";
|
|
|
+ }
|
|
|
+ };
|
|
|
+ request.addHeader("Authorization", "Basic YWRtaW46c2VsZWN0MTExKioq");
|
|
|
+ request.setURI(URI.create(searchUpdateUrl + noExistId));
|
|
|
+ HttpUtil.Response response = HttpUtil.sendHttpUriRequest(request);
|
|
|
+ System.out.println(noExistId + " " + response.getResponseText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|