|
|
@@ -16,10 +16,18 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.search.b2b.service.SearchService.Table_name;
|
|
|
+import com.uas.search.console.b2b.SystemProperties;
|
|
|
+import com.uas.search.console.b2b.core.util.ContextUtils;
|
|
|
+import com.uas.search.console.b2b.model.PurchaseInquiryItemSimpleInfo;
|
|
|
+import com.uas.search.console.b2b.model.PurchaseInquiryMouldSimpleInfo;
|
|
|
+import com.uas.search.console.b2b.model.PurchaseTenderSimpleInfo;
|
|
|
+import com.uas.search.console.b2b.model.SaleQuotationSimpleInfo;
|
|
|
import com.uas.search.console.b2b.schedule.model.TaskInformation;
|
|
|
import com.uas.search.console.b2b.schedule.service.TaskService;
|
|
|
import com.uas.search.console.b2b.service.UpdateVirtualColumnService;
|
|
|
+import com.uas.search.console.b2b.support.RealTimeUpdateMonitor;
|
|
|
import com.uas.search.console.b2b.util.ClassAndTableNameUtils;
|
|
|
+import com.uas.search.console.b2b.util.SearchConstants.DataSourceQualifier;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/schedule")
|
|
|
@@ -39,8 +47,8 @@ public class ScheduleController {
|
|
|
throws ClassNotFoundException, NotSerializableException, IOException {
|
|
|
Table_name table = Table_name.valueOf(tableName.toUpperCase());
|
|
|
if (table != Table_name.PURC$INQUIRYMOULD && table != Table_name.PURC$INQUIRYITEMS
|
|
|
- && table != Table_name.PURC$TENDER) {
|
|
|
- return "不支持更新虚拟列overdue索引:" + tableName;
|
|
|
+ && table != Table_name.PURC$TENDER && table != Table_name.SALE$QUOTATION) {
|
|
|
+ return "不支持更新虚拟列索引:" + tableName;
|
|
|
}
|
|
|
Map<String, Class<?>> map = new HashMap<>();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(fields);
|
|
|
@@ -54,10 +62,22 @@ public class ScheduleController {
|
|
|
return message;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/tasks")
|
|
|
+ @RequestMapping("/delete")
|
|
|
@ResponseBody
|
|
|
- public List<TaskInformation> allTaskInformations() {
|
|
|
- return taskService.allTaskInformations();
|
|
|
+ public List<TaskInformation> delete(@RequestParam(required = true) List<String> titles) {
|
|
|
+ return taskService.delete(titles);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/deleteAll")
|
|
|
+ @ResponseBody
|
|
|
+ public List<TaskInformation> deleteAll() {
|
|
|
+ return taskService.deleteAll();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/all")
|
|
|
+ @ResponseBody
|
|
|
+ public List<TaskInformation> all() {
|
|
|
+ return taskService.all();
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/start")
|
|
|
@@ -87,4 +107,65 @@ public class ScheduleController {
|
|
|
return taskService.isStopped();
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/init")
|
|
|
+ @ResponseBody
|
|
|
+ public String init() throws NotSerializableException, ClassNotFoundException, IOException {
|
|
|
+ startTask();
|
|
|
+ return "已初始化";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开启定时任务
|
|
|
+ *
|
|
|
+ * @throws IOException
|
|
|
+ * @throws ClassNotFoundException
|
|
|
+ * @throws NotSerializableException
|
|
|
+ */
|
|
|
+ private void startTask() throws NotSerializableException, ClassNotFoundException, IOException {
|
|
|
+ SystemProperties systemProperties = ContextUtils.getBean(SystemProperties.class);
|
|
|
+ if (systemProperties.isTaskAutoStart()) {
|
|
|
+ UpdateVirtualColumnService updateVirtualColumnService = ContextUtils
|
|
|
+ .getBean(UpdateVirtualColumnService.class);
|
|
|
+ // 需更新的虚拟列 定时更新采购询价单明细虚拟列索引
|
|
|
+ Map<String, Class<?>> purchaseInquiryItemFields = new HashMap<>();
|
|
|
+ purchaseInquiryItemFields.put("overdue", Short.class);
|
|
|
+ purchaseInquiryItemFields.put("invalid", Short.class);
|
|
|
+ updateVirtualColumnService.newDailyTask(PurchaseInquiryItemSimpleInfo.class, purchaseInquiryItemFields,
|
|
|
+ systemProperties.getDailyTaskHour(), systemProperties.getDailyTaskMinute(),
|
|
|
+ systemProperties.getDailyTaskSecond());
|
|
|
+
|
|
|
+ // 定时更新主动报价单虚拟列索引
|
|
|
+ Map<String, Class<?>> saleQuotationFields = new HashMap<>();
|
|
|
+ saleQuotationFields.put("overdue", Short.class);
|
|
|
+ updateVirtualColumnService.newDailyTask(SaleQuotationSimpleInfo.class, saleQuotationFields,
|
|
|
+ systemProperties.getDailyTaskHour(), systemProperties.getDailyTaskMinute(),
|
|
|
+ systemProperties.getDailyTaskSecond());
|
|
|
+
|
|
|
+ // 需更新的虚拟列 定时更新模具询价单虚拟列索引
|
|
|
+ Map<String, Class<?>> inquiryMouldFields = new HashMap<>();
|
|
|
+ inquiryMouldFields.put("overdue", Short.class);
|
|
|
+ updateVirtualColumnService.newDailyTask(PurchaseInquiryMouldSimpleInfo.class, inquiryMouldFields,
|
|
|
+ systemProperties.getDailyTaskHour(), systemProperties.getDailyTaskMinute(),
|
|
|
+ systemProperties.getDailyTaskSecond());
|
|
|
+
|
|
|
+ // 定时更新招标单虚拟列索引
|
|
|
+ Map<String, Class<?>> purchaseTenderFields = new HashMap<>();
|
|
|
+ purchaseTenderFields.put("overdue", Short.class);
|
|
|
+ purchaseTenderFields.put("result", Short.class);
|
|
|
+ updateVirtualColumnService.newDailyTask(PurchaseTenderSimpleInfo.class, purchaseTenderFields,
|
|
|
+ systemProperties.getDailyTaskHour(), systemProperties.getDailyTaskMinute(),
|
|
|
+ systemProperties.getDailyTaskSecond());
|
|
|
+
|
|
|
+ // 定时监控实时更新异常情况
|
|
|
+ new RealTimeUpdateMonitor(DataSourceQualifier.PLATFORMB2B_DATASOURCE).newTask();
|
|
|
+ new RealTimeUpdateMonitor(DataSourceQualifier.PLATFORMMANAGER_DATASOURCE).newTask();
|
|
|
+
|
|
|
+ // 开启定时任务
|
|
|
+ TaskService taskService = ContextUtils.getBean(TaskService.class);
|
|
|
+ if (!taskService.isStopped()) {
|
|
|
+ taskService.stop();
|
|
|
+ }
|
|
|
+ taskService.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|