From cdfa3d41a2e9cbc3019d9c244ca30b09f2de6f20 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期六, 20 四月 2024 15:25:37 +0800
Subject: [PATCH] 工作调度
---
server/dmvisit_admin/src/main/java/com/doumee/task/ScheduleTool.java | 206 ++++++++++++++++++++++++++++++++++-----------------
1 files changed, 138 insertions(+), 68 deletions(-)
diff --git a/server/dmvisit_admin/src/main/java/com/doumee/task/ScheduleTool.java b/server/dmvisit_admin/src/main/java/com/doumee/task/ScheduleTool.java
index 9369302..87a1866 100644
--- a/server/dmvisit_admin/src/main/java/com/doumee/task/ScheduleTool.java
+++ b/server/dmvisit_admin/src/main/java/com/doumee/task/ScheduleTool.java
@@ -1,26 +1,25 @@
package com.doumee.task;
-import com.doumee.biz.system.SystemDictDataBiz;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
+import com.doumee.config.DataSyncConfig;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.utils.Constants;
+import com.doumee.service.business.InterfaceLogService;
+import com.doumee.service.business.MemberService;
+import com.doumee.service.business.impl.hksync.*;
+import com.doumee.service.business.impl.hksync.ferp.HkSyncOrgUserToHKServiceImpl;
+import com.doumee.service.business.impl.hksync.fhk.HkSyncVehicleFromHKServiceImpl;
+import com.doumee.service.business.impl.hksync.fhk.HkSyncVisitFromHKServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
-import java.io.IOException;
-import java.net.URI;
import java.util.Date;
-import java.util.Map;
/**
- * 瀹氭椂浠诲姟
+ * 瀹氭椂浠诲姟锛堝簾寮冿級
* @author jiangping
* @date 2021-10-10 14:40:35
* https://www.bejson.com/othertools/cron/ cron 琛ㄨ揪寮忕敓鎴愬湴鍧�
@@ -29,74 +28,145 @@
@EnableScheduling
public class ScheduleTool {
-
@Autowired
- private SystemDictDataBiz systemDictDataBiz;
+ private HkSyncParkServiceImpl hkSyncParkService;
+ @Autowired
+ private HkSyncImgServiceImpl hkSyncImgService;
+ @Autowired
+ private HkSyncEmpowerServiceImpl hkSyncEmpowerService;
+ @Autowired
+ private HkSyncOrgUserToHKServiceImpl hkSyncOrgUserService;
+ @Autowired
+ private HkSyncVisitFromHKServiceImpl hkSyncVisitFromHKService;
+ @Autowired
+ private HkSyncVehicleFromHKServiceImpl hkSyncVehicleFromHKService;
+ @Autowired
+ private HkSyncVisitServiceImpl hkSyncVisitService;
+ @Autowired
+ private MemberService memberService;
+ @Autowired
+ private InterfaceLogService interfaceLogService;
/**
* 鏄惁寮�鍙戣��
*/
- @Value("${timing}")
- private Boolean timing;
-
+ @Autowired
+ private DataSyncConfig dataSyncConfig;
/**
- * 缂撳瓨鐪佸競鍖�
+ * 姣忓垎閽熸媺鍙栦竴娆′粖鏃ョ殑璁垮棰勭害鏁版嵁
* @throws Exception
*/
- @Scheduled(fixedDelay=24*60*60*1000)
- public void cacheCampus() throws Exception {
+ @Scheduled(cron= "0 0 23 * * ?")
+ public void syncVehicleUpdateData() throws Exception {
+ hkSyncVehicleFromHKService.syncVehicleUpdateData(new Date(System.currentTimeMillis()-24*60*60*1000));
}
- /**
- * 姣忓ぉ鍑屾櫒閲嶇疆鎵�鏈夎鍗昪ode绫诲垵濮嬪��
- * @throws Exception
- */
- @Scheduled(cron="0 0 0 * * ?")
- public void resetOrderCodes() throws Exception {
- }
-
-
-
/**
- * 鍙戦�乬et璇锋眰
- * @param url 璇锋眰URL
- * @param param 璇锋眰鍙傛暟 key:value url鎼哄甫鍙傛暟 鎴栬�呮棤鍙傚彲涓嶅~
- * @return
+ * 姣忓垎閽熸媺鍙栦竴娆′粖鏃ョ殑璁垮棰勭害鏁版嵁
+ * @throws Exception
*/
- public String doGet(String url, Map<String, String> param) {
- // 鍒涘缓Httpclient瀵硅薄
- CloseableHttpClient httpclient = HttpClients.createDefault();
- String resultString = "";
- CloseableHttpResponse response = null;
- try {
- // 鍒涘缓uri
- URIBuilder builder = new URIBuilder(url);
- if (param != null) {
- for (String key : param.keySet()) {
- builder.addParameter(key, param.get(key));
- }
- }
- URI uri = builder.build();
- // 鍒涘缓http GET璇锋眰
- HttpGet httpGet = new HttpGet(uri);
- // 鎵ц璇锋眰
- response = httpclient.execute(httpGet);
- // 鍒ゆ柇杩斿洖鐘舵�佹槸鍚︿负200
- if (response.getStatusLine().getStatusCode() == 200) {
- resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (response != null) {
- response.close();
- }
- httpclient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ @Scheduled(fixedRate= 30*1000)
+ public void syncVistAppointData() throws Exception {
+ if(Constants.DEALING_FROM_HK_VISIT){
+ return ;
}
- return resultString;
+ try {
+ Constants.DEALING_FROM_HK_VISIT =true;
+ hkSyncVisitFromHKService.syncVistAppointData(new Date());
+ Constants.DEALING_FROM_HK_VISIT =false;
+ }catch (Exception e){
+// throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝娴峰悍鍚屾鏁版嵁澶辫触~");
+ }finally {
+ Constants.DEALING_FROM_HK_VISIT =false;
+ }
}
+ /**
+ * 姣�10鍒嗛挓鎷夊彇涓�娆℃渶鏂拌瀹㈢櫥璁扮姸鎬侊紙棰勭害鎴愬姛鍜屽凡鐧昏锛�
+ * @throws Exception
+ */
+ @Scheduled(fixedRate= 10*60*1000)
+ public void syncVisitOuttimeStatus() throws Exception {
+ hkSyncVisitService.getOutTimeVisitRecord();
+ }
+ /**
+ * 涓嬭浇娴峰悍绯荤粺鍥剧墖鏁版嵁
+ * @throws Exception
+ */
+ @Scheduled(fixedRate= 60*1000)
+ public void downloadHkImg() throws Exception {
+ if(dataSyncConfig.getNeedDealImg()!=null && dataSyncConfig.getNeedDealImg()){
+ hkSyncImgService.downHKImgs(0);
+ }
+ }
+ /**
+ * 瀹氭椂鍚屾缁勭粐淇℃伅鍒版捣搴风郴缁�
+ * @throws Exception
+ */
+ @Scheduled(fixedRate= 60*1000)
+ public void syncOrgData() {
+ if(Constants.formatIntegerNum(dataSyncConfig.getOrgUserDataOrigin()) == DataSyncConfig.origin.erp){
+ //濡傛灉鏄疎RP绯荤粺鍚屾涓嬪彂
+ hkSyncOrgUserService.syncOrgData();
+ }
+ }
+ /**
+ * 瀹氭椂鍚屾鐢ㄦ埛淇℃伅鍒版捣搴风郴缁�
+ * @throws Exception
+ */
+ @Scheduled(fixedRate= 60*1000)
+ public void syncUserData() {
+ if(Constants.formatIntegerNum(dataSyncConfig.getOrgUserDataOrigin()) == DataSyncConfig.origin.erp) {
+ //濡傛灉鏄疎RP绯荤粺鍚屾涓嬪彂
+ hkSyncOrgUserService.syncUserData();
+ }
+ }
+ /**
+ * 瀹氭椂鍚屾鐢宠閫氳繃鐨勮瀹㈡暟鎹埌娴峰悍绯荤粺
+ * @throws Exception
+ */
+ @Scheduled(fixedRate= 60*1000)
+ public void syncVisitData() {
+ hkSyncVisitService.syncVisitData();
+ }
+ /* *//**
+ * 瀹氭椂鍚屾鍐呴儴浜哄憳鎺堟潈鍒版捣搴风郴缁�
+ * @throws Exception
+ *//*
+ @Scheduled(fixedRate= 3*1000)
+ public void syncEmpowerData() {
+ hkSyncEmpowerService.syncEmpowerData();
+ }
+ *//**
+ * 瀹氭椂鏌ヨ浜哄憳涓嬪彂娴峰悍缁撴灉锛堜换鍔℃槸鍚﹀凡涓嬭浇缁撴潫锛�
+ * @throws Exception
+ *//*
+ @Scheduled(fixedRate= 60*1000)
+ public void syncEmpowerResultData() {
+ hkSyncEmpowerService.syncEmpowerResultData();
+ }
+ */
+ /**
+ * 瀹氭椂鏌ヨ浜哄憳瀹為檯涓嬪彂鏉冮檺缁撴灉锛屾槸鍚﹀凡缁忎笅杞芥垚鍔�
+ * @throws Exception
+ *//*
+ @Scheduled(fixedRate= 60*1000)
+ public void syncEmpowerDetailData() {
+ hkSyncEmpowerService.syncEmpowerDetailData();
+ }*/
+
+ /**
+ * 瀹氭椂鍐荤粨鍐呴儴浜哄憳
+ */
+// @Scheduled(fixedRate= 60*1000)
+ public void memberFreeze() {
+ memberService.memberFreeze();
+ }
+ /**
+ * 姣忓ぉ娓呯悊瓒呰繃涓�鍛ㄧ殑鎺ュ彛鏃ュ織鏁版嵁锛堟竻闄ゅ拰瀹夐槻骞冲彴瀵规帴鐨勬帴鍙f暟鎹級
+ * @throws Exception
+ */
+ @Scheduled(cron= "0 0 23 * * ?")
+ public void clearThreeMonthLog() throws Exception {
+ interfaceLogService.clearThreeMonthLog();
+ }
}
--
Gitblit v1.9.3