lfx 4 days ago
parent
commit
9eea07e6ca
29 changed files with 1876 additions and 0 deletions
  1. 84 0
      mjava-xiding/pom.xml
  2. 17 0
      mjava-xiding/src/main/java/com/malk/xiding/XiDingApplication.java
  3. 24 0
      mjava-xiding/src/main/java/com/malk/xiding/config/KDWebApiConf.java
  4. 34 0
      mjava-xiding/src/main/java/com/malk/xiding/config/KDWebApiConfig.java
  5. 17 0
      mjava-xiding/src/main/java/com/malk/xiding/controller/JinlunController.java
  6. 26 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/Audit.java
  7. 18 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/BillQuery.java
  8. 25 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/ContactModel.java
  9. 10 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/CustomerContactEntry.java
  10. 63 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/CustomerModel.java
  11. 15 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/FNumber.java
  12. 15 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/FSTAFFNUMBER.java
  13. 7 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/Model.java
  14. 57 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/SaleOrderEntry.java
  15. 17 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/SaleOrderFinance.java
  16. 24 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/SaleOrderModel.java
  17. 26 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/Save.java
  18. 22 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/Submit.java
  19. 24 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/UnAudit.java
  20. 14 0
      mjava-xiding/src/main/java/com/malk/xiding/entity/View.java
  21. 59 0
      mjava-xiding/src/main/java/com/malk/xiding/schedule/JinlunTask.java
  22. 15 0
      mjava-xiding/src/main/java/com/malk/xiding/service/JinlunTaskService.java
  23. 822 0
      mjava-xiding/src/main/java/com/malk/xiding/service/impl/JinlunTaskServiceImpl.java
  24. 65 0
      mjava-xiding/src/main/resources/application-dev.yml
  25. 43 0
      mjava-xiding/src/main/resources/application-prod.yml
  26. 15 0
      mjava-xiding/src/main/resources/application.yml
  27. 61 0
      mjava-xiding/src/main/resources/logback-spring.xml
  28. 223 0
      mjava-xiding/src/test/java/com/malk/xiding/DdTest.java
  29. 34 0
      mjava-xiding/src/test/java/com/malk/xiding/JdTest.java

+ 84 - 0
mjava-xiding/pom.xml

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.7.18</version> <!-- 使用最新的稳定版或其他适用版本 -->
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+    <groupId>com.malk.xiding</groupId>
+    <artifactId>mjava-xiding</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.malk</groupId>
+            <artifactId>base</artifactId>
+            <version>1.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.example</groupId>
+            <artifactId>k3cloud</artifactId>
+            <version>8.0.6</version>
+        </dependency>
+        <dependency>
+            <groupId>com.example</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <finalName>xiding</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <executable>true</executable>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 17 - 0
mjava-xiding/src/main/java/com/malk/xiding/XiDingApplication.java

@@ -0,0 +1,17 @@
+package com.malk.xiding;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication(scanBasePackages = {"com.malk"})
+@EnableScheduling
+public class XiDingApplication {
+    public static void main(String[] args) {
+        try {
+            SpringApplication.run(XiDingApplication.class,args);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+}

+ 24 - 0
mjava-xiding/src/main/java/com/malk/xiding/config/KDWebApiConf.java

@@ -0,0 +1,24 @@
+package com.malk.xiding.config;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+@ConfigurationProperties(prefix = "kingdee")
+@Slf4j
+public class KDWebApiConf {
+
+    private String XKDApiAcctID;
+
+    private String XKDApiUserName;
+
+    private String XKDApiAppID;
+
+    private String XKDApiAppSec;
+
+    private String XKDApiServerUrl;
+
+}

+ 34 - 0
mjava-xiding/src/main/java/com/malk/xiding/config/KDWebApiConfig.java

@@ -0,0 +1,34 @@
+package com.malk.xiding.config;
+
+import com.kingdee.bos.webapi.entity.IdentifyInfo;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+public class KDWebApiConfig {
+    private Properties properties = new Properties();
+
+    public KDWebApiConfig(String filePath) throws IOException {
+        try (FileInputStream input = new FileInputStream(filePath)) {
+            properties.load(input);
+        }
+    }
+
+    public String getProperty(String key) {
+        return properties.getProperty(key);
+    }
+
+    public static void main(String[] args) {
+        try {
+            KDWebApiConfig config = new KDWebApiConfig("mjava-jinlun/src/main/resources/application-dev.yml");
+            System.out.println("AcctID: " + config.getProperty("X-KDApi-AcctID"));
+            // 打印其他属性...
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+
+}

+ 17 - 0
mjava-xiding/src/main/java/com/malk/xiding/controller/JinlunController.java

@@ -0,0 +1,17 @@
+package com.malk.xiding.controller;
+
+import com.malk.server.common.McR;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@RestController
+public class JinlunController {
+
+    @GetMapping("/test")
+    public McR test(){
+        return McR.success("111");
+    }
+
+}

+ 26 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/Audit.java

@@ -0,0 +1,26 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class Audit {
+    private int CreateOrgId;
+
+    private List<String> Numbers;
+
+    private String Ids;
+
+    private String InterationFlags;
+
+    private int UseOrgId;
+
+    private String NetworkCtrl;
+
+    private Boolean IsVerifyProcInst;
+
+    private String IgnoreInterationFlag;
+
+    private Boolean UseBatControlTimes;
+}

+ 18 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/BillQuery.java

@@ -0,0 +1,18 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class BillQuery {
+    private String FormId;
+    private String FieldKeys;
+    private List<Map> FilterString;
+    private String OrderString;
+    private int TopRowCount;
+    private int StartRow;
+    private int Limit;
+    private String SubSystemId;
+}

+ 25 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/ContactModel.java

@@ -0,0 +1,25 @@
+package com.malk.xiding.entity;
+
+import com.malk.utils.UtilMap;
+import lombok.Data;
+
+@Data
+public class ContactModel extends Model{
+    private String FName;//联系人名称
+
+    private FNumber FCustId;//客户编号
+
+    private String FMobile;//移动电话
+
+    private FNumber Fex;//性别
+
+    private String FPost;//职务
+
+    private String FTel;//固定电话
+
+    private String FFax;//传真
+
+    private String FEmail;//邮箱
+
+    private String FCompanyType;//类型:BD_Customer:客户,BD_Supplier:供应商
+}

+ 10 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/CustomerContactEntry.java

@@ -0,0 +1,10 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class CustomerContactEntry {
+    private String FNUMBER1;//地点编码
+
+    private String FNAME1;//地点名称
+}

+ 63 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/CustomerModel.java

@@ -0,0 +1,63 @@
+package com.malk.xiding.entity;
+
+import com.malk.utils.UtilMap;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CustomerModel extends Model{
+    private int FCUSTID;
+
+    private String FName;//客户名称
+
+    private String FShortName;//简称
+
+    private FNumber FCOUNTRY;//国家
+
+    private FNumber FGroup;//客户分组
+
+    private String F_VMKV_Combo;//客户等级
+
+    private FNumber FCustTypeId;//客类别
+
+    private String FDescription;//备注
+
+    private FNumber FSALDEPTID;//销售部门
+
+    private FNumber FSELLER;//销售员
+
+    private FSTAFFNUMBER F_VMKV_Base1;//跟单员
+
+    private String F_VMKV_Combo1;//订单要求
+
+    private FNumber FRECCONDITIONID;//收款条件
+
+    private FNumber FTRADINGCURRID;//结算币别
+
+    private FNumber FSETTLETYPEID;//结算方式
+
+    private FNumber FTaxRate;//税率
+
+    private FNumber FTaxType;//税分类
+
+    private String FInvoiceType;//发票类型
+
+    private Boolean FISCREDITCHECK;//启用信用管理
+
+    private String FINVOICEBANKACCOUNT;//银行账号
+
+    private String FINVOICETITLE;//发票抬头
+
+    private String FTAXREGISTERCODE;//纳税登记号
+
+    private String FINVOICEBANKNAME;//开户银行
+
+    private String FSOCIALCRECODE;//统一社会信用代码
+
+    private String FINVOICETEL;//开票联系电话
+
+    private String FINVOICEADDRESS;//开票通讯地址
+
+    private List<CustomerContactEntry> FT_BD_CUSTCONTACT;//地址信息
+}

+ 15 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/FNumber.java

@@ -0,0 +1,15 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class FNumber {
+    public FNumber() {
+    }
+
+    public FNumber(String FNumber) {
+        this.FNumber = FNumber;
+    }
+
+    private String FNumber;
+}

+ 15 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/FSTAFFNUMBER.java

@@ -0,0 +1,15 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class FSTAFFNUMBER {
+    public FSTAFFNUMBER() {
+    }
+
+    public FSTAFFNUMBER(String FSTAFFNUMBER) {
+        this.FSTAFFNUMBER = FSTAFFNUMBER;
+    }
+
+    private String FSTAFFNUMBER;
+}

+ 7 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/Model.java

@@ -0,0 +1,7 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class Model {
+}

+ 57 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/SaleOrderEntry.java

@@ -0,0 +1,57 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class SaleOrderEntry {
+    private FNumber FMaterialId;//物料编码
+    private String F_Sl_XSTYPE;//产品类别
+
+    private FNumber FUnitID;//销售单位
+    private double FQty;//销售数量
+    private FNumber FPriceUnitId;//计价单位
+    private double FPriceUnitQty;//计价数量
+//    private double FPrice;
+    private double FTaxPrice;//含税单价
+
+    private boolean FIsFree;//是否赠品
+
+    private double FEntryTaxRate;//税率
+
+    /*private double FTaxAmount_LC;
+    private double FAmount_LC;
+    private double FAllAmount_LC;*/
+
+    private String FDeliveryDate;
+
+    /*private FNumber FStockFNumber;
+    private FNumber FSettleOrgIds;
+    private String FOwnerTypeId;
+    private FNumber FOwnerId;*/
+    private String FEntryNote;
+
+    private double F_VMKV_MPPRICE;//报价价格
+    private String F_VMKV_SCCQ1;//生产厂区
+/*    private double F_WMVJ_Decimal;
+    private double F_WMVJ_Amount;
+    private double F_WMVJ_Qty;
+    private boolean F_WMVJ_CheckBox;*/
+
+    private String F_VMKV_JSYQ;//技术要求
+    private String F_NLD_BR;//剩磁(Br)
+    private String F_NLD_Hcj;//内禀矫顽力(Hcj)
+    private String F_NLD_Hcb;//磁感矫顽力(Hcb)
+    private String F_NLD_BH;//最大磁能积(BH)max
+    private String F_NLD_Hk;//方形度Hk/Hcj
+    private String F_VMKV_GXYQ;//公差要求
+
+    private boolean FDeliveryControl;//控制发货数量
+    private double FDeliveryMaxQty;//发货上限
+    private double FDeliveryMinQty;//发货下限
+
+    private String F_WGR_Combo_qtr;//产品质量等级
+    private String F_NLD_khwl;//客户物料编码
+    private FNumber F_Sl_salexingnengid;//客户性能
+
+    String F_Sl_Attachment;//订单图纸附件
+}

+ 17 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/SaleOrderFinance.java

@@ -0,0 +1,17 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class SaleOrderFinance {
+    private FNumber FSettleCurrId;//结算币别
+
+    private FNumber FRecConditionId ;//收款条件
+
+    private FNumber FSettleModeId;//结算方式
+
+    private boolean FIsIncludedTax;//是否含税
+
+    private boolean FIsPriceExcludeTax;//价外税
+
+}

+ 24 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/SaleOrderModel.java

@@ -0,0 +1,24 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SaleOrderModel extends Model{
+    private int FID;
+    private FNumber FBillTypeID;//单据类型
+    private String FDate;//日期
+    private String F_NLD_DDTYPE ;//订单类型
+    private String F_WGR_Combo_re5 ;//订单要求
+    private FNumber FCustId;//客户
+    private FNumber FSalerId;//销售员
+    private FSTAFFNUMBER F_Sl_gendanyuan;//跟单员
+    private FNumber FHeadDeliveryWay;//交货方式
+    private String FBusinessType;//业务类型
+    private FNumber FHEADLOCID;//交货地点
+    private String FNote;//备注
+    private String F_Sl_customerbillno;//客户订单号
+    private SaleOrderFinance FSaleOrderFinance;//财务信息
+    private List<SaleOrderEntry> FSaleOrderEntry;//订单明细
+}

+ 26 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/Save.java

@@ -0,0 +1,26 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class Save {
+        //默认为空 需要时选择性赋值
+        private List<String> NeedUpDateFields;
+        /*private List<String> NeedReturnFields;
+        private boolean IsDeleteEntry;
+        private String SubSystemId;
+        private boolean IsVerifyBaseDataField;
+        private boolean IsEntryBatchFill;
+        private boolean ValidateFlag;
+        private boolean NumberSearch;
+        private boolean IsAutoAdjustField;
+        private String InterationFlags;
+        private boolean IgnoreInterationFlag;
+        private boolean IsControlPrecision;
+        private boolean ValidateRepeatJson;*/
+
+        //保存实体
+        private Model Model;
+}

+ 22 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/Submit.java

@@ -0,0 +1,22 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class Submit {
+    private int CreateOrgId;
+
+    private List<String> Numbers;
+
+    private String Ids;
+
+    private int SelectedPostId;
+
+    private int UseOrgId;
+
+    private Boolean NetworkCtrl;
+
+    private Boolean IgnoreInterationFlag;
+}

+ 24 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/UnAudit.java

@@ -0,0 +1,24 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UnAudit {
+    private int CreateOrgId;
+
+    private List<String> Numbers;
+
+    private String Ids;
+
+    private String InterationFlags;
+
+    private int UseOrgId;
+
+    private String NetworkCtrl;
+
+    private Boolean IsVerifyProcInst;
+
+    private String IgnoreInterationFlag;
+}

+ 14 - 0
mjava-xiding/src/main/java/com/malk/xiding/entity/View.java

@@ -0,0 +1,14 @@
+package com.malk.xiding.entity;
+
+import lombok.Data;
+
+@Data
+public class View {
+    private int CreateOrgId;
+
+    private String Number;
+
+    private String Id;
+
+    private Boolean IsSortBySeq;
+}

+ 59 - 0
mjava-xiding/src/main/java/com/malk/xiding/schedule/JinlunTask.java

@@ -0,0 +1,59 @@
+package com.malk.xiding.schedule;
+
+import com.malk.xiding.service.JinlunTaskService;
+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 JinlunTaskService jinlunTaskService;
+
+    //定时同步物料
+    @Scheduled(cron = "0 0 0 * * ?")
+    public void syncMaterial(){
+        jinlunTaskService.syncMaterial();
+    }
+
+    //定时同步销售出库单
+    @Scheduled(cron = "0 1 0 * * ?")
+    public void syncSaleOut(){
+        jinlunTaskService.syncSaleOut();
+    }
+
+    //定时同步收款单
+    @Scheduled(cron = "0 2 0 * * ?")
+    public void syncReceipt(){
+        jinlunTaskService.syncReceipt();
+    }
+
+    //定时同步应收单
+    @Scheduled(cron = "0 3 0 * * ?")
+    public void syncReceivable(){
+        jinlunTaskService.syncReceivable();
+    }
+
+    //定时同步销售退货单
+    @Scheduled(cron = "0 4 0 * * ?")
+    public void syncSaleReturn(){
+        jinlunTaskService.syncSaleReturn();
+    }
+
+    //定时同步性能
+    @Scheduled(cron = "0 5 0 * * ?")
+    public void syncXingneng(){
+        jinlunTaskService.syncXingneng();
+    }
+
+}

+ 15 - 0
mjava-xiding/src/main/java/com/malk/xiding/service/JinlunTaskService.java

@@ -0,0 +1,15 @@
+package com.malk.xiding.service;
+
+public interface JinlunTaskService {
+    void syncMaterial();
+
+    void syncSaleOut();
+
+    void syncReceipt();
+
+    void syncReceivable();
+
+    void syncSaleReturn();
+
+    void syncXingneng();
+}

+ 822 - 0
mjava-xiding/src/main/java/com/malk/xiding/service/impl/JinlunTaskServiceImpl.java

@@ -0,0 +1,822 @@
+package com.malk.xiding.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kingdee.bos.webapi.entity.IdentifyInfo;
+import com.kingdee.bos.webapi.sdk.K3CloudApi;
+import com.malk.utils.UtilMap;
+import com.malk.xiding.config.KDWebApiConf;
+import com.malk.xiding.entity.BillQuery;
+import com.malk.xiding.service.JinlunTaskService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class JinlunTaskServiceImpl implements JinlunTaskService {
+    @Autowired
+    private KDWebApiConf kdWebApiConf;
+
+    @Override
+    public void syncMaterial() {
+        log.info("开始同步物料数据");
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+        List<Map> materialList = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("BD_MATERIAL");
+        billQuery.setFieldKeys("FNumber,FName,F_Sl_xingnengid.FName,F_Sl_cihuaid.FName,FSpecification,FErpClsID,F_Sl_xingzhuangid.FName,F_Sl_ducengid.FName,F_Sl_ischongciid.FName,F_Sl_chihuaguige,F_Sl_midu,F_Sl_guige,F_Sl_weight,F_Sl_ischeck,F_Sl_qianguige,F_Sl_cixiangchang,F_NLD_gongyi.FName,F_Sl_biaomianji,FMaterialGroup.FName,FCategoryID.FName,FVOLUME,FBaseUnitId.FName,FSaleUnitId.FName,FSalePriceUnitId.FName");
+        List<Map> filterString = new ArrayList<>();
+
+        //审核日期为昨天至今天
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","420","2024-10-20 00:00:00","","","0"));//审核日期年=XX
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
+
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            result = (List<Map>)JSONObject.parse(s);
+            materialList.addAll(result);
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+        for (Map map : materialList) {
+            Map data = new HashMap();
+            data.put("ShortText1757932581400",UtilMap.getString(map,"FName"));//物料名称
+            data.put("ShortText1757932557449",UtilMap.getString(map,"FNumber"));//物料编码
+            data.put("ShortText1757932601205",UtilMap.getString(map,"F_Sl_xingnengid.FName"));//性能
+            data.put("ShortText1757932616477",UtilMap.getString(map,"F_Sl_cihuaid.FName"));//磁化方向
+            data.put("ShortText1757932652570",UtilMap.getString(map,"F_Sl_xingzhuangid.FName"));//形状
+            data.put("ShortText1757932660567",UtilMap.getString(map,"F_Sl_ducengid.FName"));//镀层
+            data.put("Dropdown1757932715739",UtilMap.getString(map,"F_Sl_ischongciid.FName"));//是否充磁
+            data.put("ShortText1757932699628",UtilMap.getString(map,"F_Sl_chihuaguige"));//磁化规格
+            data.put("Number1757932755471",UtilMap.getDouble(map,"F_Sl_midu"));//密度(g/mm³)
+            data.put("ShortText1757932739089",UtilMap.getString(map,"F_Sl_guige"));//尺寸规格
+            data.put("Number1757932746124",UtilMap.getDouble(map,"F_Sl_weight"));//单重(kg)
+            data.put("Logic1757932804393",UtilMap.getBoolean(map,"F_Sl_ischeck"));//是否需要检验
+            data.put("ShortText1757932821074",UtilMap.getString(map,"F_Sl_qianguige"));//带前后缀规格
+            data.put("Number1757932837126",UtilMap.getDouble(map,"F_Sl_cixiangchang"));//磁向长
+            data.put("ShortText1757932874077",UtilMap.getString(map,"F_NLD_gongyi.FName"));//工序
+            data.put("Number1757932881710",UtilMap.getDouble(map,"F_Sl_biaomianji"));//表面积
+            data.put("ShortText1760342223781",UtilMap.getString(map,"FSpecification"));//规格型号
+            data.put("ShortText1757933029016",UtilMap.getString(map,"FMaterialGroup.FName"));//物料分组
+            data.put("ShortText1757933017962",UtilMap.getString(map,"FCategoryID.FName"));//存货类别
+
+            String fErpClsID = UtilMap.getString(map, "FErpClsID");
+            String wlsx = "";
+            switch (fErpClsID){
+                case "10":wlsx = "资产";break;
+                case "9":wlsx = "配置";break;
+                case "2":wlsx = "自制";break;
+                case "11":wlsx = "费用";break;
+                case "12":wlsx = "模型";break;
+                case "5":wlsx = "虚拟";break;
+                case "7":wlsx = "一次性";break;
+                case "13":wlsx = "产品系列";break;
+                case "3":wlsx = "委外";break;
+                case "4":wlsx = "特征";break;
+                case "6":wlsx = "服务";break;
+                case "1":wlsx = "原材料";break;
+
+            }
+            data.put("ShortText1757933048314",wlsx);//物料属性
+
+            data.put("Number1757933060744",UtilMap.getDouble(map,"FVOLUME"));//体积
+            data.put("ShortText1757933079170",UtilMap.getString(map,"FBaseUnitId.FName"));//基本单位
+            data.put("Text1760411136055",UtilMap.getString(map,"FSaleUnitId.FName"));//销售单位
+            data.put("Text1760411137275",UtilMap.getString(map,"FSalePriceUnitId.FName"));//销售计价单位
+
+            String schemaCode = "WL";
+
+//            //查询是否存在
+//            Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1757932557449", UtilMap.getString(map,"FNumber")), 0, 1, null);
+//
+//            Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
+//
+//            int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
+//
+//            if (totalElements > 0) {
+//                //云枢更新物料
+//                Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
+//
+//                String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
+//
+//                data.put("id",bizObjectId);
+//
+//                Map result3 = cpClient.updateCpBo(schemaCode, data,null);
+//            }else {
+//                //云枢新增物料
+//                Map result3 = cpClient.createCpBo(schemaCode, data,null);
+//            }
+        }
+    }
+
+    @Override
+    public void syncSaleOut() {
+        log.info("开始同步销售出库单数据");
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+        List<Map> saleOutList = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("SAL_OUTSTOCK");
+        billQuery.setFieldKeys("FBillNo,FBillTypeID.FName,FDate,FSettleCurrID.FName,FCustomerID.FName,FCustomerID.FShortName,FCustomerID.FNumber,FHeadLocationID.FName,FMaterialID.FNumber,FMaterialID.FName,FMaterialID.FSpecification,FMaterialID.F_Sl_ducengid,F_VMKV_Text_WLZT,FPriceUnitQty,FRealQty,FUnitID.FName,FPriceUnitId.FName,FAuxUnitID.FName,FAuxUnitQty,FIsFree,FPrice,FTaxPrice,FEntryTaxRate,FAmount,FAllAmount,FDiscount,FEntrynote");
+        List<Map> filterString = new ArrayList<>();
+
+        //审核日期为昨天至今天
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","420","2025-10-20 00:00:00","","","0"));//审核日期年=XX
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
+
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            result = (List<Map>)JSONObject.parse(s);
+            saleOutList.addAll(result);
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+
+        List<Map<String,Object>> dataList = new ArrayList<>();
+
+        for (Map saleOut : saleOutList) {
+            Map data = new HashMap();
+
+            data.put("ShortText1760153678207",UtilMap.getString(saleOut,"FBillNo"));//单据编号
+            data.put("ShortText1760153685839",UtilMap.getString(saleOut,"FBillTypeID.FName"));//单据类型
+            data.put("Date1760153694040",UtilMap.getString(saleOut, "FDate").replace("T"," "));//日期
+            data.put("ShortText1760153691233",UtilMap.getString(saleOut,"FSettleCurrID.FName"));//结算币别
+            data.put("ShortText1760153707273",UtilMap.getString(saleOut,"FCustomerID.FName"));//客户名称
+            data.put("ShortText1760153714871",UtilMap.getString(saleOut,"FCustomerID.FShortName"));//客户简称
+            data.put("ShortText1768439848740",UtilMap.getString(saleOut,"FCustomerID.FNumber"));//客户简称
+            data.put("ShortText1760153722192",UtilMap.getString(saleOut,"FHeadLocationID.FName"));//交货地点
+
+            List<Map> entry = new ArrayList<>();
+            Map entryMap = new HashMap();
+            entryMap.put("Number1760153738400",UtilMap.getString(saleOut,"FMaterialID.FNumber"));//物料编码
+            entryMap.put("ShortText1760153773163",UtilMap.getString(saleOut,"FMaterialID.FNumber"));//物料编码
+            entryMap.put("Text1760153778635",UtilMap.getString(saleOut,"FMaterialID.FName"));//物料名称
+            entryMap.put("Text1760153786986",UtilMap.getString(saleOut,"FMaterialID.FSpecification"));//规格型号
+            entryMap.put("ShortText1762245895776",UtilMap.getString(saleOut,"FMaterialID.F_Sl_ducengid"));//镀锌
+            entryMap.put("Text1762245901183",UtilMap.getString(saleOut,"F_VMKV_Text_WLZT"));//物料状态
+
+            entryMap.put("Number1760153811668",UtilMap.getDouble(saleOut,"FPriceUnitQty"));//计价数量
+            Double sfsl = UtilMap.getDouble(saleOut, "FRealQty");
+            entryMap.put("Number1760153958907", sfsl);//实发数量
+            entryMap.put("Text1760153793403",UtilMap.getString(saleOut,"FPriceUnitId.FName"));//计价单位
+            String kcdw = UtilMap.getString(saleOut, "FUnitID.FName");
+            entryMap.put("ShortText1762508609328", kcdw);//库存单位
+            entryMap.put("Text1762508629987",UtilMap.getString(saleOut,"FAuxUnitID.FName"));//库存辅单位
+            Double kcfdwsl = UtilMap.getDouble(saleOut, "FAuxUnitQty");
+            entryMap.put("Number1762508641763", kcfdwsl);//库存辅单位数量
+            entryMap.put("Logic1760171983887",UtilMap.getBoolean(saleOut,"FIsFree"));//是否赠品
+            entryMap.put("Number1760153991898",UtilMap.getDouble(saleOut,"FPrice"));//单价
+            entryMap.put("Number1760154006703",UtilMap.getDouble(saleOut,"FTaxPrice"));//计价单价
+            entryMap.put("Number1762225120251",UtilMap.getDouble(saleOut,"FEntryTaxRate"));//税率
+            entryMap.put("Number1760154034052",UtilMap.getDouble(saleOut,"FAmount"));//金额
+            entryMap.put("Number1760154039959",UtilMap.getDouble(saleOut,"FAllAmount"));//价税合计
+            entryMap.put("Number1760154058940",UtilMap.getDouble(saleOut,"FDiscount"));//折扣额
+            entryMap.put("ShortText1760154066042",UtilMap.getString(saleOut,"FEntrynote"));//备注
+
+            if ("Pcs".equals(kcdw)){
+                entryMap.put("Number1762509492431",sfsl);//数量
+                entryMap.put("Number1762509515885",kcfdwsl);//重量
+            }else {
+                entryMap.put("Number1762509492431",0);//数量
+                entryMap.put("Number1762509515885",sfsl);//重量
+            }
+
+            entry.add(entryMap);
+
+            data.put("Sheet1760153734916",entry);
+
+            dataList.add(data);
+        }
+
+        //处理同一出库单多个明细
+        List<Map<String, Object>> list = mergeListMap(dataList, "ShortText1760153678207", "Sheet1760153734916");
+
+        for (Map<String, Object> map : list) {
+            String schemaCode = "XSCKD";
+            //查询是否存在
+//            Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1760153678207", UtilMap.getString(map, "ShortText1760153678207")), 0, 1, null);
+//
+//            Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
+//
+//            int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
+//
+//            List<Map> items = (List<Map>) map.get("Sheet1760153734916");
+//            if (totalElements > 0) {
+//                //云枢更新销售出库单
+//                Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
+//
+//                Map map1 = UtilMap.getMap(content, "data");
+//                List<Map> list1 = UtilMap.getList(map1, "Sheet1760153734916");
+//
+//                for (int i = 0; i < items.size(); i++) {
+//                    items.get(i).put("rowStatus", "Modified");
+//                    items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
+//                }
+//
+//                items.forEach(item -> item.put("rowStatus", "Modified"));
+//
+//                String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
+//
+//                map.put("id",bizObjectId);
+//
+//                Map result3 = cpClient.updateCpBo(schemaCode, map,null);
+//            }else {
+//                //云枢新增销售出库单
+//                items.forEach(item -> item.put("rowStatus", "added"));
+//                Map result3 = cpClient.createCpBo(schemaCode, map,null);
+//            }
+        }
+    }
+
+    @Override
+    public void syncReceipt() {
+        log.info("开始同步收款单数据");
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+        List<Map> receiptList = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("AR_RECEIVEBILL");
+        billQuery.setFieldKeys("FBillNo,FBillTypeID.FName,FPAYUNITTYPE,FDate,FPAYUNIT.FName,FCURRENCYID.FName,FRECEIVEAMOUNTFOR_H,FREALRECAMOUNTFOR,F_VMKV_Combo,FSALEERID.FName,F_VMKV_Base_83g.FName,FSETTLETYPEID,FSETTLETYPEID.FName,FPURPOSEID.FName,FACCOUNTID.FNumber,FACCOUNTID.FName,FRECTOTALAMOUNTFOR,FREALRECAMOUNTFOR_D,FCOMMENT");
+        List<Map> filterString = new ArrayList<>();
+
+        //审核日期为昨天至今天
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","420","2025-10-20 00:00:00","","","0"));//审核日期年=XX
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FNumber","67","35","","","0"));//物料编码等于XX
+
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            result = (List<Map>)JSONObject.parse(s);
+            receiptList.addAll(result);
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+
+        List<Map<String,Object>> dataList = new ArrayList<>();
+
+        for (Map receipt : receiptList) {
+            Map data = new HashMap();
+
+            data.put("ShortText1760585125989",UtilMap.getString(receipt,"FBillNo"));//单据编号
+            data.put("ShortText1760585107833",UtilMap.getString(receipt,"FBillTypeID.FName"));//单据类型
+            data.put("Date1760585187315",UtilMap.getString(receipt, "FDate").replace("T"," "));//业务日期
+            data.put("Text1760585197637",UtilMap.getString(receipt,"FSALEERID.FName"));//销售员
+            data.put("ShortText1760585145727",UtilMap.getString(receipt,"F_VMKV_Base_83g.FName"));//跟单员
+            data.put("ShortText1760585132200",UtilMap.getString(receipt,"FPAYUNIT.FName"));//付款单位
+
+            String FPAYUNITTYPE = UtilMap.getString(receipt, "FPAYUNITTYPE");
+            String FPAYUNITTYPE_VALUE = "";
+            switch (FPAYUNITTYPE){
+                case "BD_Supplier" : FPAYUNITTYPE_VALUE = "供应商";break;
+                case "BD_Customer" : FPAYUNITTYPE_VALUE = "客户";break;
+                case "BD_Department" : FPAYUNITTYPE_VALUE = "部门";break;
+                case "BD_Empinfo" : FPAYUNITTYPE_VALUE = "员工";break;
+                case "FIN_OTHERS" : FPAYUNITTYPE_VALUE = "其他往来单位";break;
+                case "ORG_Organizations" : FPAYUNITTYPE_VALUE = "组织机构";break;
+                case "BD_BANK" : FPAYUNITTYPE_VALUE = "银行";break;
+                default:break;
+            }
+            data.put("ShortText1760585114989", FPAYUNITTYPE_VALUE);//付款单位类型
+
+            data.put("ShortText1760585150625",UtilMap.getString(receipt,"FCURRENCYID.FName"));//币别
+
+            String F_VMKV_Combo = UtilMap.getString(receipt, "F_VMKV_Combo");
+            String F_VMKV_Combo_VALUE = "";
+            switch (F_VMKV_Combo){
+                case "ART" : F_VMKV_Combo_VALUE = "佳丰";break;
+                case "JLCC" : F_VMKV_Combo_VALUE = "金轮";break;
+                case "NOT" : F_VMKV_Combo_VALUE = "暂不确定";break;
+                default:break;
+            }
+            data.put("ShortText1760585157387", F_VMKV_Combo_VALUE);//佳丰/金轮
+
+            data.put("Number1760585167781",UtilMap.getDouble(receipt,"FRECEIVEAMOUNTFOR_H"));//应收金额
+            data.put("Number1760585178357",UtilMap.getDouble(receipt,"FREALRECAMOUNTFOR"));//实收金额
+
+            List<Map> entry = new ArrayList<>();
+            Map entryMap = new HashMap();
+            entryMap.put("ShortText1760585209233",UtilMap.getString(receipt,"FSETTLETYPEID.FName"));//结算方式
+            entryMap.put("ShortText1760585224298",UtilMap.getString(receipt,"FPURPOSEID.FName"));//收款用途
+            entryMap.put("ShortText1760585384491",UtilMap.getString(receipt,"FACCOUNTID.FNumber"));//我方银行账户
+            entryMap.put("Text1760585393271",UtilMap.getString(receipt,"FACCOUNTID.FName"));//我方账户名称
+            entryMap.put("Number1760585235219",UtilMap.getDouble(receipt,"FRECTOTALAMOUNTFOR"));//应收金额
+            entryMap.put("Number1760585242849",UtilMap.getDouble(receipt,"FREALRECAMOUNTFOR_D"));//实收金额
+            entryMap.put("ShortText1760585258640",UtilMap.getString(receipt,"FCOMMENT"));//备注
+
+            entry.add(entryMap);
+
+            data.put("Sheet1760585205663",entry);
+
+            dataList.add(data);
+        }
+
+        //处理同一收款单多个明细
+        List<Map<String, Object>> list = mergeListMap(dataList, "ShortText1760585125989", "Sheet1760585205663");
+
+        for (Map<String, Object> map : list) {
+            String schemaCode = "SKD";
+            //查询是否存在
+//            Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1760585125989", UtilMap.getString(map, "ShortText1760585125989")), 0, 1, null);
+//
+//            Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
+//
+//            int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
+//
+//            List<Map> items = (List<Map>) map.get("Sheet1760585205663");
+//            if (totalElements > 0) {
+//                //云枢更新收款单
+//                Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
+//
+//                Map map1 = UtilMap.getMap(content, "data");
+//                List<Map> list1 = UtilMap.getList(map1, "Sheet1760585205663");
+//
+//                for (int i = 0; i < items.size(); i++) {
+//                    items.get(i).put("rowStatus", "Modified");
+//                    items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
+//                }
+//
+//                items.forEach(item -> item.put("rowStatus", "Modified"));
+//
+//                String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
+//
+//                map.put("id",bizObjectId);
+//
+//                Map result3 = cpClient.updateCpBo(schemaCode, map,null);
+//            }else {
+//                //云枢新增收款单
+//                items.forEach(item -> item.put("rowStatus", "added"));
+//                Map result3 = cpClient.createCpBo(schemaCode, map,null);
+//            }
+        }
+    }
+
+    @Override
+    public void syncReceivable() {
+        log.info("开始同步应收单数据");
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+        List<Map> receiptList = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("AR_receivable");
+        billQuery.setFieldKeys("FBillTypeID.FName,FBillNo,FCUSTOMERID.FName,FSALEERID.FName,F_VMKV_Base_qtr.FName,FSetAccountType,FCURRENCYID.FName,FDate,FENDDATE_H,FPayConditon.FName,FALLAMOUNTFOR,FEntityDetail_FEntryID,FMATERIALID.FNumber,FMATERIALID.FName,FMATERIALID.F_Sl_xingnengid,FPRICEUNITID.FName,FPriceQty,FStockUnitId.FName,FStockQty,FSalUnitId.FName,FSalQty,FTaxPrice,FPrice,FEntryTaxRate,FNoTaxAmountFor_D,FTAXAMOUNTFOR_D,FALLAMOUNTFOR_D,FIsFree,FLot.FName,FRECEIVEAMOUNT,FComment");
+        List<Map> filterString = new ArrayList<>();
+
+        //审核日期为昨天至今天
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","39","2025-10-14 00:00:00","","","0"));//审核日期大于等于XX
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","16","2025-10-16 00:00:00","","","0"));//审核日期小于等于XX
+
+
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FAPPROVEDATE","420","2025-10-21 00:00:00","","","0"));//审核日期年=XX
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDATE","420","2025-10-21 00:00:00","","","0"));//业务日期年=XX
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            result = (List<Map>)JSONObject.parse(s);
+            receiptList.addAll(result);
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+
+        List<Map<String,Object>> dataList = new ArrayList<>();
+
+        for (Map receipt : receiptList) {
+            Map data = new HashMap();
+
+            data.put("ShortText1760602123650",UtilMap.getString(receipt,"FBillNo"));//发票号码
+            data.put("ShortText1760602106521",UtilMap.getString(receipt,"FBillTypeID.FName"));//单据类型
+            data.put("Date1760602205733",UtilMap.getString(receipt, "FDate").replace("T"," "));//业务日期
+            data.put("ShortText1760602136864",UtilMap.getString(receipt,"FSALEERID.FName"));//销售员
+            data.put("Text1760602141164",UtilMap.getString(receipt,"F_VMKV_Base_qtr.FName"));//跟单员
+            data.put("ShortText1760602119316",UtilMap.getString(receipt,"FCUSTOMERID.FName"));//客户
+
+            String FSetAccountType = UtilMap.getString(receipt, "FSetAccountType");
+            String FSetAccountType_VALUE = "";
+            switch (FSetAccountType){
+                case "1" : FSetAccountType_VALUE = "业务应收";break;
+                case "3" : FSetAccountType_VALUE = "财务应收";break;
+                case "2" : FSetAccountType_VALUE = "暂估应收";break;
+                default:break;
+            }
+
+            data.put("ShortText1760602147441", FSetAccountType_VALUE);//立账类型
+
+            data.put("ShortText1760602218380",UtilMap.getString(receipt,"FPayConditon.FName"));//收款条件
+            data.put("ShortText1760602197718",UtilMap.getString(receipt,"FCURRENCYID.FName"));//币别
+            data.put("Number1760602528131",UtilMap.getDouble(receipt,"FALLAMOUNTFOR"));//价税合计
+            data.put("Date1760602209998",UtilMap.getString(receipt,"FENDDATE_H").replace("T"," "));//到期日
+
+            List<Map> entry = new ArrayList<>();
+            Map entryMap = new HashMap();
+            entryMap.put("ShortText1760605881791",UtilMap.getString(receipt,"FEntityDetail_FEntryID"));//分录ID
+            entryMap.put("ShortText1760602287318",UtilMap.getString(receipt,"FMATERIALID.FNumber"));//物料编码
+            entryMap.put("Text1760602292846",UtilMap.getString(receipt,"FMATERIALID.FName"));//物料名称
+            entryMap.put("Text1760602314150",UtilMap.getString(receipt,"FMATERIALID.F_Sl_xingnengid"));//性能
+            String jjdw = UtilMap.getString(receipt, "FPRICEUNITID.FName");
+            entryMap.put("Text1760602299878", jjdw);//计价单位
+            Double jjsl = UtilMap.getDouble(receipt, "FPriceQty");
+            entryMap.put("Number1760602320518", jjsl);//计价数量
+            String kcdw = UtilMap.getString(receipt, "FStockUnitId.FName");
+            entryMap.put("Text1762914941284", kcdw);//库存单位
+            Double kcsl = UtilMap.getDouble(receipt, "FStockQty");
+            entryMap.put("Number1762914960910", kcsl);//库存数量
+            String xsdw = UtilMap.getString(receipt, "FSalUnitId.FName");
+            entryMap.put("Text1762914943634", xsdw);//销售单位
+            Double xssl = UtilMap.getDouble(receipt, "FSalQty");
+            entryMap.put("Number1762914972786", xssl);//销售数量
+            entryMap.put("Number1760602330651",UtilMap.getDouble(receipt,"FTaxPrice"));//含税单价
+            entryMap.put("Number1760602338551",UtilMap.getDouble(receipt,"FPrice"));//单价
+            entryMap.put("Number1760602343876",UtilMap.getDouble(receipt,"FEntryTaxRate"));//税率
+            entryMap.put("Number1760602347414",UtilMap.getDouble(receipt,"FNoTaxAmountFor_D"));//不含税金额
+            entryMap.put("Number1760602354115",UtilMap.getDouble(receipt,"FTAXAMOUNTFOR_D"));//税额
+            entryMap.put("Number1760602359012",UtilMap.getDouble(receipt,"FALLAMOUNTFOR_D"));//价税合计
+            entryMap.put("Logic1760602369561",UtilMap.getString(receipt,"FIsFree"));//是否赠品
+
+            entryMap.put("ShortText1760602387059",UtilMap.getString(receipt,"FLot.FName"));//批号
+            entryMap.put("Number1760602396337",UtilMap.getDouble(receipt,"FRECEIVEAMOUNT"));//已结算金额
+            entryMap.put("Text1760602391849",UtilMap.getString(receipt,"FComment"));//备注
+
+            double sl = 0.0;
+            double zl = 0.0;
+            if ("Pcs".equals(jjdw)) {
+                sl = jjsl;
+                if ("Kg".equals(xsdw)) {
+                    zl = kcsl;
+                }
+            }else {
+                zl = jjsl;
+                if ("Pcs".equals(kcdw)) {
+                    sl = kcsl;
+                }
+            }
+
+            entryMap.put("Number1762915279108", sl);//数量
+            entryMap.put("Number1762915289424", zl);//重量
+
+            entry.add(entryMap);
+
+            data.put("Sheet1760602277185",entry);
+
+            dataList.add(data);
+        }
+
+        //处理同一收款单多个明细
+        List<Map<String, Object>> list = mergeListMap(dataList, "ShortText1760602123650", "Sheet1760602277185");
+
+        for (Map<String, Object> map : list) {
+            String schemaCode = "YSD";
+            //查询是否存在
+//            Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1760602123650", UtilMap.getString(map, "ShortText1760602123650")), 0, 1, null);
+//
+//            Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
+//
+//            int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
+//
+//            List<Map> items = (List<Map>) map.get("Sheet1760602277185");
+//            if (totalElements > 0) {
+//                //云枢更新应收单
+//                Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
+//
+//                Map map1 = UtilMap.getMap(content, "data");
+//                List<Map> list1 = UtilMap.getList(map1, "Sheet1760602277185");
+//
+//                for (int i = 0; i < items.size(); i++) {
+//                    items.get(i).put("rowStatus", "Modified");
+//                    items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
+//                }
+//
+//                items.forEach(item -> item.put("rowStatus", "Modified"));
+//
+//                String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
+//
+//                map.put("id",bizObjectId);
+//
+//                Map result3 = cpClient.updateCpBo(schemaCode, map,null);
+//            }else {
+//                //云枢新增应收单
+//                items.forEach(item -> item.put("rowStatus", "added"));
+//                Map result3 = cpClient.createCpBo(schemaCode, map,null);
+//            }
+        }
+    }
+
+    @Override
+    public void syncSaleReturn() {
+        log.info("开始同步销售退货单数据");
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+        List<Map> saleReturnList = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("SAL_RETURNSTOCK");
+        billQuery.setFieldKeys("FBillTypeID.FName,FBillNo,FDate,FRetcustId.FName,FSettleCurrId.FName,FHeadNote,FEntity_FEntryID,FMaterialId.FNumber,FMaterialId.FName,FMaterialId.FSpecification,FMaterialId.F_Sl_xingnengid,FMustqty,FRealQty,FPriceUnitId.FName,FPriceUnitQty,FPrice,FTaxPrice,FIsFree,FEntryTaxRate,FAmount,FEntryTaxAmount,FAllAmount,FReturnType.FDataValue,FStockId.FName,FDeliveryDate,FNote,FLot.FName");
+        List<Map> filterString = new ArrayList<>();
+
+        //审核日期为昨天至今天
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FApproveDate","265",1,"","","0"));//审核日期在今天之前N天以后
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FAPPROVEDATE","420","2025-10-21 00:00:00","","","0"));//审核日期年=XX
+//        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDATE","420","2025-10-21 00:00:00","","","0"));//业务日期年=XX
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            result = (List<Map>)JSONObject.parse(s);
+            saleReturnList.addAll(result);
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+
+        List<Map<String,Object>> dataList = new ArrayList<>();
+
+        for (Map receipt : saleReturnList) {
+            Map data = new HashMap();
+
+            data.put("ShortText1761032880442",UtilMap.getString(receipt,"FBillNo"));//单据编号
+            data.put("ShortText1761032890399",UtilMap.getString(receipt,"FBillTypeID.FName"));//单据类型
+            data.put("Date1761032895713",UtilMap.getString(receipt, "FDate").replace("T"," "));//日期
+            data.put("ShortText1761032899575",UtilMap.getString(receipt,"FRetcustId.FName"));//退货客户
+            data.put("ShortText1761032904895",UtilMap.getString(receipt,"FSettleCurrId.FName"));//结算币别
+            data.put("ShortText1761032937812",UtilMap.getString(receipt,"FHeadNote"));//退货备注
+
+            List<Map> entry = new ArrayList<>();
+            Map entryMap = new HashMap();
+            entryMap.put("ShortText1761033279692",UtilMap.getString(receipt,"FEntity_FEntryID"));//分录ID
+            entryMap.put("ShortText1761032968041",UtilMap.getString(receipt,"FMaterialId.FNumber"));//物料编码
+            entryMap.put("Text1761032973000",UtilMap.getString(receipt,"FMaterialId.FName"));//物料名称
+            entryMap.put("ShortText1761033477673",UtilMap.getString(receipt,"FMaterialId.F_Sl_xingnengid"));//性能
+            entryMap.put("ShortText1761032979494",UtilMap.getString(receipt,"FMaterialId.FSpecification"));//规格型号
+            entryMap.put("Number1761032987168",UtilMap.getDouble(receipt,"FMustqty"));//应退数量
+            entryMap.put("Number1761032997394",UtilMap.getDouble(receipt,"FRealQty"));//实退数量
+            entryMap.put("ShortText1761033008702",UtilMap.getString(receipt,"FPriceUnitId.FName"));//计价单位
+            entryMap.put("Number1761033960104",UtilMap.getDouble(receipt,"FPriceUnitQty"));//计价数量
+            entryMap.put("Number1761033026518",UtilMap.getDouble(receipt,"FTaxPrice"));//含税单价
+            entryMap.put("Number1761033015285",UtilMap.getDouble(receipt,"FPrice"));//单价
+            entryMap.put("Number1761033046672",UtilMap.getDouble(receipt,"FEntryTaxRate"));//税率
+            entryMap.put("Number1761033064064",UtilMap.getDouble(receipt,"FAmount"));//金额
+            entryMap.put("Number1761033076151",UtilMap.getDouble(receipt,"FEntryTaxAmount"));//税额
+            entryMap.put("Number1761033079296",UtilMap.getDouble(receipt,"FAllAmount"));//价税合计
+            entryMap.put("Logic1761033036005",UtilMap.getBoolean(receipt,"FIsFree"));//是否赠品
+            entryMap.put("ShortText1761033090318",UtilMap.getString(receipt,"FReturnType.FDataValue"));//退货类型
+            entryMap.put("ShortText1761033099990",UtilMap.getString(receipt,"FStockId.FName"));//仓库
+            entryMap.put("Date1761033104411",UtilMap.getString(receipt,"FDeliveryDate").replace("T"," "));//退货日期
+            entryMap.put("Text1761033119394",UtilMap.getString(receipt,"FLot.FName"));//批号
+            entryMap.put("ShortText1761033111040",UtilMap.getString(receipt,"FNote"));//备注
+
+            entry.add(entryMap);
+
+            data.put("Sheet1761032958852",entry);
+
+            dataList.add(data);
+        }
+
+        //处理同一收款单多个明细
+        List<Map<String, Object>> list = mergeListMap(dataList, "ShortText1761032880442", "Sheet1761032958852");
+
+        for (Map<String, Object> map : list) {
+            String schemaCode = "XSTHD";
+            //查询是否存在
+//            Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1761032880442", UtilMap.getString(map, "ShortText1761032880442")), 0, 1, null);
+//
+//            Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
+//
+//            int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
+//
+//            List<Map> items = (List<Map>) map.get("Sheet1761032958852");
+//            if (totalElements > 0) {
+//                //云枢更新销售出库单
+//                Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
+//
+//                Map map1 = UtilMap.getMap(content, "data");
+//                List<Map> list1 = UtilMap.getList(map1, "Sheet1761032958852");
+//
+//                for (int i = 0; i < items.size(); i++) {
+//                    items.get(i).put("rowStatus", "Modified");
+//                    items.get(i).put("id", (UtilMap.getString(list1.get(i),"id")));//子表实例id
+//                }
+//
+//                items.forEach(item -> item.put("rowStatus", "Modified"));
+//
+//                String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
+//
+//                map.put("id",bizObjectId);
+//
+//                Map result3 = cpClient.updateCpBo(schemaCode, map,null);
+//            }else {
+//                //云枢新增销售出库单
+//                items.forEach(item -> item.put("rowStatus", "added"));
+//                Map result3 = cpClient.createCpBo(schemaCode, map,null);
+//            }
+        }
+    }
+
+    @Override
+    public void syncXingneng() {
+        log.info("开始同步性能数据");
+        K3CloudApi client = new K3CloudApi(initIden());
+
+        List<Map> result = new ArrayList<>();
+        List<Map> materialList = new ArrayList<>();
+
+        int startRow = 0;
+        int limit = 2000;
+
+        BillQuery billQuery = new BillQuery();
+        billQuery.setFormId("Sl_xingneng");
+        billQuery.setFieldKeys("FNumber,FName,Fmiduqty");
+        List<Map> filterString = new ArrayList<>();
+
+        //修改日期为昨天至今天 数据状态等于已审核
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FModifyDate","265",1,"","","0"));//修改日期在今天之前N天以后
+        filterString.add(UtilMap.map("FieldName, Compare, Value, Left, Right, Logic","FDocumentStatus","105","C","","","0"));//数据状态等于XX
+
+        billQuery.setFilterString(filterString);
+        billQuery.setLimit(limit);
+
+        do {
+            billQuery.setStartRow(startRow);
+            String s = null;
+
+            try {
+                s = client.billQuery(JSONObject.toJSONString(billQuery));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            result = (List<Map>)JSONObject.parse(s);
+            materialList.addAll(result);
+
+            startRow += limit;
+        }while (result.size() == limit);
+
+        for (Map map : materialList) {
+            Map data = new HashMap();
+            data.put("ShortText1763692732585",UtilMap.getString(map,"FName"));//名称
+            data.put("ShortText1763692732107",UtilMap.getString(map,"FNumber"));//性能
+            data.put("Number1763692741479",UtilMap.getDouble(map,"Fmiduqty"));//性能
+
+            String schemaCode = "XN";
+
+            //查询是否存在
+//            Map result2 = cpClient.getCpBoList(schemaCode, UtilMap.map("queryFilterType, propertyCode, propertyValue", "Eq", "ShortText1763692732107", UtilMap.getString(map,"FNumber")), 0, 1, null);
+//
+//            Map bizObjectPage = UtilMap.getMap(UtilMap.getMap(result2, "data"),"bizObjectPage");
+//
+//            int totalElements = UtilMap.getInt(bizObjectPage, "totalElements");
+//
+//            if (totalElements > 0) {
+//                //云枢更新性能
+//                Map content = ((List<Map>) UtilMap.getList(bizObjectPage, "content")).get(0);
+//
+//                String bizObjectId = UtilMap.getString(content,"bizObjectId");//主表实例id
+//
+//                data.put("id",bizObjectId);
+//
+//                Map result3 = cpClient.updateCpBo(schemaCode, data,null);
+//            }else {
+//                //云枢新增性能
+//                Map result3 = cpClient.createCpBo(schemaCode, data,null);
+//            }
+        }
+    }
+
+    private IdentifyInfo initIden(){
+        //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
+        //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
+        //读取配置,初始化SDK
+        IdentifyInfo iden = new IdentifyInfo();
+        iden.setUserName(kdWebApiConf.getXKDApiUserName());
+        iden.setAppId(kdWebApiConf.getXKDApiAppID());
+        iden.setdCID(kdWebApiConf.getXKDApiAcctID());
+        iden.setAppSecret(kdWebApiConf.getXKDApiAppSec());
+        iden.setServerUrl(kdWebApiConf.getXKDApiServerUrl());
+
+        return iden;
+    }
+
+    public static List<Map<String, Object>> mergeListMap(List<Map<String, Object>> originalList,String key,String list) {
+        // 使用 Map 来临时存储合并后的结果,key 为 code,value 为合并后的 Map
+        Map<String, Map<String, Object>> mergedMap = new HashMap<>();
+
+        for (Map<String, Object> item : originalList) {
+            String code = (String) item.get(key);
+            @SuppressWarnings("unchecked")
+            List<Map<String, Object>> details = (List<Map<String, Object>>) item.get(list);
+
+            if (mergedMap.containsKey(code)) {
+                // 如果已存在该 code,只合并 details
+                Map<String, Object> existingItem = mergedMap.get(code);
+                @SuppressWarnings("unchecked")
+                List<Map<String, Object>> existingDetails = (List<Map<String, Object>>) existingItem.get(list);
+                existingDetails.addAll(details);
+            } else {
+                // 如果不存在该 key,保存整个 Map(包括其他 key)
+                // 但需要深拷贝 list,避免后续修改影响原始数据
+                Map<String, Object> newItem = new HashMap<>();
+                for (Map.Entry<String, Object> entry : item.entrySet()) {
+                    if ("details".equals(entry.getKey())) {
+                        // 深拷贝 details 列表
+                        @SuppressWarnings("unchecked")
+                        List<Map<String, Object>> originalDetails = (List<Map<String, Object>>) entry.getValue();
+                        newItem.put(entry.getKey(), new ArrayList<>(originalDetails));
+                    } else {
+                        newItem.put(entry.getKey(), entry.getValue());
+                    }
+                }
+                mergedMap.put(code, newItem);
+            }
+        }
+
+        // 转换回 List
+        return new ArrayList<>(mergedMap.values());
+    }
+
+
+}

+ 65 - 0
mjava-xiding/src/main/resources/application-dev.yml

@@ -0,0 +1,65 @@
+server:
+  port: 9036
+  servlet:
+    context-path: /jinlun
+
+spring:
+  datasource:
+    url: jdbc:mysql://192.168.0.12:3306/cloudpivot?serverTimezone=GMT%2B8
+    username: root
+    password: test123456!@#$%
+    driver-class-name: com.mysql.cj.jdbc.Driver
+
+enable:
+  scheduling: false
+logging:
+  config: classpath:logback-spring.xml
+  path: d:\\jinlun_cloudpure\logs\
+  level:
+    com.malk.*: debug
+
+# dingtalk
+dingtalk:
+  agentId: 3366214854
+  appKey: dingntvkzjzxdx8h2m1s
+  appSecret: YfaV5mYOL4F--P8P_G9aD8DP_a8_IgM6dBILsSaTb4LeUZYSntacol55O1tJuqcU
+  corpId: ding923faa53d9d45937acaaa37764f94726
+  aesKey:
+  token:
+  operator: 344749020127590108
+
+# teambition
+teambition:
+  AppID: 68ef594a7e7b5487e864f1ca
+  AppSecret: cOHex1jvPDLucx1KHDzAcG34rUdpInSg
+  TenantId: 61e7fd84ba45dcd4761d31f5
+  OperatorId: 68b7ec4b03fae569a6cfdbfd   # TBManager
+
+#云枢
+cloudpivot:
+  grant_type: client_credentials
+  client_id: xclient
+  client_secret: 0a417ecce58c31b32364ce19ca8fcd15
+  redirect_uri: http://192.168.0.12/api/
+  operator_user_id: 8ac194c0811240a6b483ebc86aeb9147
+
+kingdee:
+# 第三方系统登录授权的账套ID
+  X-KDApi-AcctID: 66816d8a115ffc
+  # 第三方系统登录授权的用户
+  X-KDApi-UserName: Administrator
+  # 第三方系统登录授权的应用ID
+  X-KDApi-AppID: 295561_7e1I0bHHVqGaSZxJ7Z4pVxxs7L5bxMMI
+  # 第三方系统登录授权的应用密钥
+  X-KDApi-AppSec: 0f51467e39764b548ec3d75159dfbd2b
+  # 服务Url地址(公有云统一走网关sdk底层已处理,无需传X-KDApi-ServerUrl,下面这行需要注释)
+  X-KDApi-ServerUrl: http://192.168.0.87/k3Cloud/
+  # 账套语系,默认2052
+  # X-KDApi-LCID: 2052
+  # 组织编码,启用多组织时配置对应的组织编码才有效
+  # X-KDApi-OrgNum: 100
+  # 允许的最大连接延时,单位为秒
+  # X-KDApi-ConnectTimeout: 120
+  # 允许的最大读取延时,单位为秒
+  # X-KDApi-RequestTimeout: 120
+

+ 43 - 0
mjava-xiding/src/main/resources/application-prod.yml

@@ -0,0 +1,43 @@
+server:
+  port: 9036
+  servlet:
+    context-path: /xiding
+
+enable:
+  scheduling: true
+logging:
+  config: classpath:logback-spring.xml
+  path: /home/server/xiding/logs/
+  level:
+    com.malk.*: info
+
+# dingtalk
+dingtalk:
+  agentId: 3366214854
+  appKey: dingntvkzjzxdx8h2m1s
+  appSecret: YfaV5mYOL4F--P8P_G9aD8DP_a8_IgM6dBILsSaTb4LeUZYSntacol55O1tJuqcU
+  corpId: ding923faa53d9d45937acaaa37764f94726
+  aesKey:
+  token:
+  operator: 344749020127590108
+
+kingdee:
+  # 第三方系统登录授权的账套ID
+  X-KDApi-AcctID: 637c62165f7aeb
+  # 第三方系统登录授权的用户
+  X-KDApi-UserName: kingdee
+  # 第三方系统登录授权的应用ID
+  X-KDApi-AppID: 403553_61eu06Dp0PCa4eVow4SqVZXK1MXcXsqv
+  # 第三方系统登录授权的应用密钥
+  X-KDApi-AppSec: b22899204846cf9aff16201fa18147
+  # 服务Url地址(公有云统一走网关sdk底层已处理,无需传X-KDApi-ServerUrl,下面这行需要注释)
+  X-KDApi-ServerUrl: http://192.168.0.87/k3Cloud/
+  # 账套语系,默认2052
+  # X-KDApi-LCID: 2052
+  # 组织编码,启用多组织时配置对应的组织编码才有效
+  # X-KDApi-OrgNum: 100
+  # 允许的最大连接延时,单位为秒
+  # X-KDApi-ConnectTimeout: 120
+  # 允许的最大读取延时,单位为秒
+  # X-KDApi-RequestTimeout: 120
+

+ 15 - 0
mjava-xiding/src/main/resources/application.yml

@@ -0,0 +1,15 @@
+spring:
+  profiles:
+    active: prod
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 100MB
+  http:
+    enabled: false
+
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  global-config:
+    db-config:
+      id-type: auto

+ 61 - 0
mjava-xiding/src/main/resources/logback-spring.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false" scan="false" scanPeriod="60 seconds">
+    <springProperty scope="context" name="LOG_HOME" source="logging.path" defaultValue="d:\\jianhui_cloudpure\logs\"/>
+    <property name="FileNamePattern" value="${LOG_HOME}%d{yyyyMM}/%d{dd}"/>
+
+    <!-- 定义控制台输出 -->
+    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %-5level - %logger{50} - %msg%n</pattern>
+        </layout>
+    </appender>
+
+    <appender name="appLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 指定日志文件的名称 -->
+        <!--<file>${FileNamePattern}/info.log</file>-->
+
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${FileNamePattern}/info-%i.log</fileNamePattern>
+            <MaxHistory>30</MaxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <MaxFileSize>30MB</MaxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [ %thread ] - [ %-5level ] [ %logger{50} : %line ] - %msg%n</pattern>
+        </layout>
+    </appender>
+
+    <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
+        <discriminator>
+            <Key>processid</Key>
+            <DefaultValue>sys</DefaultValue>
+        </discriminator>
+        <sift>
+            <appender name="FILE-${processid}"
+                      class="ch.qos.logback.core.rolling.RollingFileAppender">
+                <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+                    <FileNamePattern>
+                        ${FileNamePattern}/${processid}.log
+                    </FileNamePattern>
+                </rollingPolicy>
+                <layout class="ch.qos.logback.classic.PatternLayout">
+                    <Pattern>
+                        %d{yyyyMMdd:HH:mm:ss.SSS} [%thread] %-5level %msg%n
+                    </Pattern>
+                </layout>
+            </appender>
+        </sift>
+    </appender>
+
+
+    <!-- 日志输出级别 -->
+    <logger name="org.springframework" level="debug"  additivity="false"/>
+    <logger name="com.malk.connecter" level="debug"/>
+    <root level="INFO">
+        <appender-ref ref="stdout"/>
+        <appender-ref ref="appLogAppender"/>
+        <appender-ref ref="SIFT"/>
+    </root>
+</configuration>

+ 223 - 0
mjava-xiding/src/test/java/com/malk/xiding/DdTest.java

@@ -0,0 +1,223 @@
+package com.malk.xiding;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.kingdee.bos.webapi.entity.IdentifyInfo;
+import com.kingdee.bos.webapi.entity.RepoRet;
+import com.kingdee.bos.webapi.sdk.K3CloudApi;
+import com.malk.xiding.config.KDWebApiConf;
+import com.malk.xiding.entity.*;
+import com.malk.xiding.service.JinlunTaskService;
+import com.malk.server.common.McR;
+import com.malk.utils.UtilHttp;
+import com.malk.utils.UtilMap;
+import com.malk.utils.UtilToken;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.util.*;
+
+@Slf4j
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class DdTest {
+    @Autowired
+    private KDWebApiConf kdWebApiConf;
+
+    @Autowired
+    private JinlunTaskService jinlunTaskService;
+
+    @Test
+    public void test2() {
+        jinlunTaskService.syncMaterial();
+    }
+
+    @Test
+    public void test4() {
+        jinlunTaskService.syncSaleOut();
+    }
+
+    @Test
+    public void test5() {
+        jinlunTaskService.syncReceipt();
+    }
+
+    @Test
+    public void test6() {
+        jinlunTaskService.syncReceivable();
+    }
+    @Test
+    public void test7() {
+        jinlunTaskService.syncSaleReturn();
+    }
+
+    @Test
+    public void test8() {
+        try {
+            String filePath = "C:\\Users\\EDY\\Pictures\\4.png"; // 替换为你的文件路径
+
+            // 1. 读取文件为字节数组
+            byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));
+
+            // 2. 转换为Base64字符串
+            String base64String = Base64.getEncoder().encodeToString(fileBytes);
+
+            System.out.println("Base64编码结果:");
+            System.out.println(base64String);
+
+
+            K3CloudApi client = new K3CloudApi(initIden());
+
+
+
+            Map map = new HashMap();
+            map.put("FileName", "4.png");//文件名
+            map.put("FormId", "SAL_SaleOrder");//表单id
+            map.put("IsLast", true);//是否最后一次上传
+            map.put("InterId", "104784");//单据内码
+//            map.put("Entrykey", "");//单据体标识
+//            map.put("EntryinterId", "-1");//分录内码
+            map.put("BillNO", "S301-251118005");//单据编号
+//        map.put("AliasFileName", "test");
+//        map.put("FileId", "");
+            map.put("SendByte", base64String);//文件字节数组转base64后的字符串
+
+            String resultJson = client.attachmentUpload(JSONObject.toJSONString(map));
+
+            Map parse = (Map) JSONObject.parse(resultJson);
+
+            Map map1 = UtilMap.getMap(parse, "Result");
+
+            String fileId = UtilMap.getString(map1, "FileId");
+
+            System.out.println(fileId);
+
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Test
+    public void test10(){
+        try {
+            String acctID = "66816d8a115ffc";
+            String username = "Administrator";
+            String appId = "295561_7e1I0bHHVqGaSZxJ7Z4pVxxs7L5bxMMI";
+            String appSec = "0f51467e39764b548ec3d75159dfbd2b";
+            String timestamp = System.currentTimeMillis()/1000 + "";
+
+            String[] arr = {acctID,username,appId,appSec,timestamp};
+
+            Arrays.sort(arr, (a, b) -> a.compareTo(b));
+
+            System.out.println("排序结果:");
+
+            for (String s : arr) {
+                System.out.println(s);
+            }
+
+
+            String str = String.join("", arr);
+
+            // 1. 创建 MessageDigest 实例,指定 SHA-256 算法
+            MessageDigest digest = MessageDigest.getInstance("SHA-256");
+
+            // 2. 输入字符串转换为字节数组,并计算哈希值
+            byte[] hashBytes = digest.digest(str.getBytes(StandardCharsets.UTF_8));
+
+            // 3. 将字节数组转换为十六进制字符串
+            StringBuilder hexString = new StringBuilder();
+            for (byte b : hashBytes) {
+                String hex = Integer.toHexString(0xff & b);
+                if (hex.length() == 1) {
+                    hexString.append('0'); // 补零
+                }
+                hexString.append(hex);
+            }
+
+            // 4. 输出结果
+            System.out.println("SHA-256 哈希值: " + hexString.toString());
+        }catch (Exception e){
+            throw new RuntimeException(e);
+        }
+
+
+    }
+
+    @Test
+    public void test11(){
+//        String input = "RElSRV82NjdmODEyMmJkYzM0NDUyYWMyYjM3Mjg5NTAzYjhhMjEucG5n";
+        String input = "RElSRV9iNWViMTdlZTA1NTI0OTU1YmM3MjM3YWEyMzU5OTY5MDIucG5n";
+        String s = new String(Base64.getUrlDecoder().decode(input), StandardCharsets.UTF_8);
+
+        System.out.println(s);
+
+    }
+
+    @Test
+    public void test12() {
+        jinlunTaskService.syncXingneng();
+    }
+
+
+    private IdentifyInfo initIden(){
+        //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
+        //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
+        //读取配置,初始化SDK
+        IdentifyInfo iden = new IdentifyInfo();
+        iden.setUserName(kdWebApiConf.getXKDApiUserName());
+        iden.setAppId(kdWebApiConf.getXKDApiAppID());
+        iden.setdCID(kdWebApiConf.getXKDApiAcctID());
+        iden.setAppSecret(kdWebApiConf.getXKDApiAppSec());
+        iden.setServerUrl(kdWebApiConf.getXKDApiServerUrl());
+
+        return iden;
+    }
+
+
+
+    @Test
+    public void test3() {
+        testGetAccessToken();
+
+        testGetAccessToken();
+    }
+
+    @Test
+    public void testGetAccessToken(){
+        String accessToken = UtilToken.get("invalid-token-cloudpivot");
+
+        if (StringUtils.isNotBlank(accessToken)) {
+            log.info(accessToken);
+        } else {
+            Map<String,Object> params = new HashMap();
+            params.put("grant_type","client_credentials");
+            params.put("client_id","xclient");
+            params.put("client_secret","0a417ecce58c31b32364ce19ca8fcd15");
+
+            String s = UtilHttp.doPost("http://192.168.0.12/api/oauth/token", null, params, new HashMap());
+
+            Map result = (Map) JSONObject.parse(s);
+
+            accessToken = "bearer" + UtilMap.getString(result, "access_token");
+
+            long expiresIn = UtilMap.getLong(result, "expires_in") * 1000;
+
+            UtilToken.put("invalid-token-cloudpivot", accessToken, expiresIn);
+
+            log.info(accessToken);
+        }
+
+    }
+
+}

+ 34 - 0
mjava-xiding/src/test/java/com/malk/xiding/JdTest.java

@@ -0,0 +1,34 @@
+package com.malk.xiding;
+
+import com.kingdee.bos.webapi.entity.IdentifyInfo;
+import com.malk.xiding.config.KDWebApiConf;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@Slf4j
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class JdTest {
+
+    @Autowired
+    private KDWebApiConf kdWebApiConf;
+
+    private IdentifyInfo initIden(){
+        //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
+        //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
+        //读取配置,初始化SDK
+        IdentifyInfo iden = new IdentifyInfo();
+        iden.setUserName(kdWebApiConf.getXKDApiUserName());
+        iden.setAppId(kdWebApiConf.getXKDApiAppID());
+        iden.setdCID(kdWebApiConf.getXKDApiAcctID());
+        iden.setAppSecret(kdWebApiConf.getXKDApiAppSec());
+        iden.setServerUrl(kdWebApiConf.getXKDApiServerUrl());
+
+        return iden;
+    }
+
+
+}