wzy 2 ヶ月 前
コミット
3d27e7bfbf

+ 27 - 0
mjava-jinlun/src/main/java/com/malk/jinlun/schedule/JinlunTask.java

@@ -0,0 +1,27 @@
+package com.malk.jinlun.schedule;
+
+import com.malk.jinlun.service.JinlunService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+/**
+ * @EnableScheduling 开启定时任务 [配置参考McScheduleTask]
+ */
+@Slf4j
+@Configuration
+@EnableScheduling
+@ConditionalOnProperty(name = {"enable.scheduling"})
+public class JinlunTask {
+    @Autowired
+    private JinlunService jinlunService;
+
+    //定时同步物料
+    @Scheduled(cron = "")
+    public void syncMaterial(){
+        jinlunService.syncMaterial();
+    }
+}

+ 2 - 0
mjava-jinlun/src/main/java/com/malk/jinlun/service/JinlunService.java

@@ -2,4 +2,6 @@ package com.malk.jinlun.service;
 
 public interface JinlunService {
     void test() throws Exception;
+
+    void syncMaterial();
 }

+ 39 - 0
mjava-jinlun/src/main/java/com/malk/jinlun/service/impl/JinlunServiceImpl.java

@@ -6,6 +6,7 @@ import com.kingdee.bos.webapi.sdk.K3CloudApi;
 import com.malk.jinlun.config.KDWebApiConf;
 import com.malk.jinlun.entity.BillQuery;
 import com.malk.jinlun.service.JinlunService;
+import com.malk.utils.UtilMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -45,6 +46,44 @@ public class JinlunServiceImpl implements JinlunService {
         System.out.println("111");
     }
 
+    @Override
+    public void syncMaterial() {
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("BD_MATERIAL");
+        billQuery.setFieldKeys("FNumber,FName,F_Sl_xingnengid,F_Sl_cihuaid,FErpClsID,F_Sl_xingzhuangid,F_Sl_ducengid,F_Sl_ischongciid,F_Sl_chihuaguige,F_Sl_midu,F_Sl_guige,F_Sl_weight,F_Sl_ischeck,F_Sl_qianguige,F_Sl_cixiangchang,F_NLD_gongyi,F_Sl_biaomianji,FMaterialGroup,FCategoryID,FVOLUME,FBaseUnitId");
+        List<Map> filterString = new ArrayList<>();
+        //
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FCreateDate","93","2025-09-15 00:00:00","","","0"));//创建时间等于XX
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+        billQuery.setStartRow(startRow);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+
+            result.addAll((List<Map>)JSONObject.parse(s));
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+        System.out.println("111");
+    }
+
     private IdentifyInfo initIden(){
         //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
         //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。

+ 5 - 0
mjava-jinlun/src/test/java/com/malk/jinlun/DdTest.java

@@ -23,4 +23,9 @@ public class DdTest {
 
     }
 
+    @Test
+    public void test2() {
+        jinlunService.syncMaterial();
+    }
+
 }