Bladeren bron

完成推送金蝶测试对接

fyz 1 maand geleden
bovenliggende
commit
df19e6ab9b

+ 41 - 5
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/controller/DLController.java

@@ -5,6 +5,7 @@ package com.malk.jiuyousimu.controller;
  */
 
 import com.malk.jiuyousimu.service.DeptService;
+import com.malk.jiuyousimu.service.DocumentService;
 import com.malk.jiuyousimu.service.PersonService;
 import com.malk.jiuyousimu.service.SupplierService;
 import com.malk.server.common.McException;
@@ -12,11 +13,14 @@ import com.malk.server.common.McR;
 import com.malk.server.common.McREnum;
 import com.malk.service.aliwork.YDClient;
 import com.malk.service.aliwork.YDService;
+import com.malk.service.dingtalk.DDClient;
+import com.malk.service.dingtalk.DDClient_Workflow;
 import com.malk.utils.UtilMap;
 import com.malk.utils.UtilServlet;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -39,23 +43,55 @@ public class DLController {
     @Autowired
     private SupplierService supplierService;
 
+    @Autowired
+    DocumentService documentService;
+    // 审批任务回调执行业务逻辑
+
+    @Autowired
+    private DDClient ddClient;
+
+    @Autowired
+    private DDClient_Workflow ddClient_workflow;
+
+    @Value("${dingtalk.appKey}")
+    private String APP_EKY;
+
+    @Value("${dingtalk.appSecret}")
+    private String APP_SECRET;
     @PostMapping(value = "testToken")
-    McR testToken() {
-        supplierService.testQuery();
+    McR testToken(@RequestParam("id") String processInstanceId) {
+        String token = ddClient.getAccessToken(APP_EKY, APP_SECRET);
+        Map processData = ddClient_workflow.getProcessInstanceId(token, processInstanceId);
+        documentService.saveCost(processData);
         return McR.success();
     }
 
+    @PostMapping(value = "testTrip")
+    McR testTrip(@RequestParam("id") String processInstanceId) {
+        String token = ddClient.getAccessToken(APP_EKY, APP_SECRET);
+        Map processData = ddClient_workflow.getProcessInstanceId(token, processInstanceId);
+        documentService.saveTrip(processData);
+        return McR.success();
+    }
     @PostMapping(value = "testGet")
     McR testGet(@RequestBody Map data) {
         personService.personCreate(UtilMap.getList(data,"list"));
         return McR.success();
     }
-    @PostMapping(value = "testDel")
+    @PostMapping(value = "testQuery")
     McR testDel(@RequestBody Map data) {
-        personService.personDelete(UtilMap.getList(data,"list"));
+//        personService.personDelete(UtilMap.getList(data,"list"));
+        supplierService.testQuery();
         return McR.success();
     }
-    @PostMapping(value = "testQuery")
+
+    @PostMapping(value = "testView")
+    McR testView(@RequestBody Map data) {
+//        personService.personDelete(UtilMap.getList(data,"list"));
+        supplierService.testView();
+        return McR.success();
+    }
+    @PostMapping(value = "testPush")
     McR testQuery(@RequestBody Map data) {
         supplierService.pushToOA();
 //        supplierService.accountPushToOA();

+ 10 - 6
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/delegate/DDDelegate.java

@@ -3,6 +3,7 @@ package com.malk.jiuyousimu.delegate;
 import com.malk.delegate.DDEvent;
 import com.malk.jiuyousimu.service.DeptService;
 import com.malk.jiuyousimu.service.DingTalkService;
+import com.malk.jiuyousimu.service.DocumentService;
 import com.malk.service.dingtalk.DDClient;
 import com.malk.service.dingtalk.DDClient_Workflow;
 import lombok.extern.slf4j.Slf4j;
@@ -26,7 +27,7 @@ import java.util.Map;
 public class DDDelegate implements DDEvent {
 
     @Autowired
-    DingTalkService dingTalkService;
+    DocumentService documentService;
     // 审批任务回调执行业务逻辑
 
     @Autowired
@@ -77,13 +78,16 @@ public class DDDelegate implements DDEvent {
             //支付申请
             String payment = "PROC-E14838E3-BDE9-42B7-BA02-8011AA88B955";
             //费用报销
-            String reimbursement = "PROC-15984B56-D500-4F37-A1E8-ED2B9CCC235A";
-            //付款申请
-//            String PAYMENT_APPLICATION = "PROC-82233BD3-A274-4B90-8710-97D9F9663634";
+            String cost = "PROC-A93433ED-DE3F-4F7D-B905-ADCF66F8C178";
+            //差旅报销
+            String trip = "PROC-15984B56-D500-4F37-A1E8-ED2B9CCC235A";
 
             if (payment.equals(processCode)){
-
-            }else if (reimbursement.equals(processCode)){
+                documentService.savePayment(processData);
+            }else if (cost.equals(processCode)){
+                documentService.saveCost(processData);
+            } else if (trip.equals(processCode)) {
+                documentService.saveTrip(processData);
             }
         }
     }

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

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

+ 2 - 0
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/entity/basic/Save.java

@@ -19,6 +19,8 @@ public class Save {
         private boolean IgnoreInterationFlag;
         private boolean IsControlPrecision;
         private boolean ValidateRepeatJson;*/
+        private String SubSystemId;
+        private boolean IsAutoAdjustField;
 
         //保存实体
         private Object model;

+ 3 - 0
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/entity/payment/PaymentDetail.java

@@ -45,4 +45,7 @@ public class PaymentDetail {
      */
     private FNumber FCOSTDEPARTMENTID;
 
+    private boolean FCostIncluded;
+
+    private FNumber FMATERIALID;
 }

+ 3 - 0
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/entity/payment/PaymentMain.java

@@ -68,6 +68,9 @@ public class PaymentMain {
      */
     private FNumber FPURCHASERID;
 
+    private String FBUSINESSTYPE;
+
+    private String FAP_Remark;
 
     private List<PaymentDetail> FEntityDetail;
 

+ 8 - 2
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/entity/reimbursement/CostMain.java

@@ -2,6 +2,7 @@ package com.malk.jiuyousimu.entity.reimbursement;
 
 import com.malk.jiuyousimu.entity.basic.BillTypeID;
 import com.malk.jiuyousimu.entity.basic.FNumber;
+import com.malk.jiuyousimu.entity.basic.FSTAFFNUMBER;
 import com.malk.jiuyousimu.entity.payment.PaymentDetail;
 import lombok.Data;
 
@@ -41,7 +42,7 @@ public class CostMain {
     /**
      * 申请人
      */
-    private FNumber FProposerID;
+    private FSTAFFNUMBER FProposerID;
 
     /**
      * 申请部门
@@ -88,7 +89,7 @@ public class CostMain {
     /**
      * 银行账号
      */
-    private String FRefundBankAccount;
+//    private FNumber FRefundBankAccount;
     /**
      * 开户银行
      */
@@ -97,6 +98,11 @@ public class CostMain {
      * 账户名称
      */
     private String FBankAccountNameT;
+    /**
+     * 银行账号
+     */
+
+    private String FBankAccountT;
     /**
      * 明细信息
      */

+ 29 - 0
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/entity/reimbursement/TripDetail.java

@@ -65,4 +65,33 @@ public class TripDetail {
      */
     private Double FExpenseAmount;
 
+    /**
+     * 机票
+     */
+    private Double FFlyAmount;
+
+    /**
+     * 市内交通费
+     */
+    private Double FCityTrafficFee;
+
+    /**
+     * 其他长途交通费
+     */
+    private Double FOtherTraAmount;
+
+    /**
+     * 住宿费
+     */
+    private Double FLodgingFee;
+
+    /**
+     * 出差补助
+     */
+    private Double FTravelSubsidy;
+
+    /**
+     * 其他费用
+     */
+    private Double FOtherExpense;
 }

+ 3 - 2
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/entity/reimbursement/TripMain.java

@@ -2,6 +2,7 @@ package com.malk.jiuyousimu.entity.reimbursement;
 
 import com.malk.jiuyousimu.entity.basic.BillTypeID;
 import com.malk.jiuyousimu.entity.basic.FNumber;
+import com.malk.jiuyousimu.entity.basic.FSTAFFNUMBER;
 import lombok.Data;
 
 import java.time.LocalDate;
@@ -40,7 +41,7 @@ public class TripMain {
     /**
      * 申请人
      */
-    private FNumber FProposerID;
+    private FSTAFFNUMBER FProposerID;
 
     /**
      * 申请部门
@@ -87,7 +88,7 @@ public class TripMain {
     /**
      * 银行账号
      */
-    private String FRefundBankAccount;
+    private String FBankAccountT;
     /**
      * 开户银行
      */

+ 321 - 188
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/service/Impl/DocumentServiceImpl.java

@@ -1,16 +1,12 @@
 package com.malk.jiuyousimu.service.Impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
-import com.malk.jiuyousimu.entity.basic.FNumber;
-import com.malk.jiuyousimu.entity.basic.BillTypeID;
+import com.malk.jiuyousimu.entity.basic.*;
 
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.kingdee.bos.webapi.entity.RepoRet;
 import com.kingdee.bos.webapi.sdk.K3CloudApi;
-import com.malk.jiuyousimu.entity.basic.Audit;
-import com.malk.jiuyousimu.entity.basic.Save;
-import com.malk.jiuyousimu.entity.basic.Submit;
 import com.malk.jiuyousimu.entity.payment.PaymentDetail;
 import com.malk.jiuyousimu.entity.payment.PaymentMain;
 import com.malk.jiuyousimu.entity.reimbursement.CostDetail;
@@ -86,6 +82,50 @@ public class DocumentServiceImpl implements DocumentService {
         ALL_ENUM.put("支付宝", "JSFS32_SYS");
         ALL_ENUM.put("供应链票据", "JSFS36_SYS");
     }
+    private static final Map<String,String> HISTORY_DEPTID2 = new HashMap<>();
+    static {
+        HISTORY_DEPTID2.put("BM000001", "老板");
+        HISTORY_DEPTID2.put("BM000002", "龙颖公司");
+        HISTORY_DEPTID2.put("BM000003", "投资部");
+        HISTORY_DEPTID2.put("BM000004", "市场部");
+        HISTORY_DEPTID2.put("BM000005", "大中台");
+        HISTORY_DEPTID2.put("BM000006", "投行部");
+        HISTORY_DEPTID2.put("BM000007", "行政人事部");
+        HISTORY_DEPTID2.put("BM000008", "财务部");
+        HISTORY_DEPTID2.put("BM000009", "国际部");
+        HISTORY_DEPTID2.put("BM000010", "中台风控部");
+        HISTORY_DEPTID2.put("BM000011", "通泰张江基地");
+        HISTORY_DEPTID2.put("BM000012", "宿州基地");
+        HISTORY_DEPTID2.put("BM000013", "兰州基地");
+        HISTORY_DEPTID2.put("BM000014", "盱眙基地");
+        HISTORY_DEPTID2.put("BM000015", "萧县基地");
+        HISTORY_DEPTID2.put("BM000016", "蚌埠基地");
+        HISTORY_DEPTID2.put("BM000017", "张家口基地");
+        HISTORY_DEPTID2.put("BM000018", "成都基地");
+        HISTORY_DEPTID2.put("BM000019", "培训部");
+        HISTORY_DEPTID2.put("BM000020", "统筹");
+        HISTORY_DEPTID2.put("BM000021", "总办");
+        HISTORY_DEPTID2.put("BM000022", "IT部");
+        HISTORY_DEPTID2.put("BM000023", "驾驶班");
+        HISTORY_DEPTID2.put("BM000024", "凤阳基地");
+        HISTORY_DEPTID2.put("BM000026", "定远基地");
+        HISTORY_DEPTID2.put("BM000027", "技术部");
+        HISTORY_DEPTID2.put("BM000028", "产业转化中心");
+    }
+    private static final Map<String,String> HISTORY_DEPTID = new HashMap<>();
+    static {
+        HISTORY_DEPTID.put("投资部", "BM000003");
+        HISTORY_DEPTID.put("行政人事部", "BM000007");
+        HISTORY_DEPTID.put("财务部", "BM000008");
+        HISTORY_DEPTID.put("兰州基地", "BM000013");
+        HISTORY_DEPTID.put("盱眙基地", "BM000014");
+        HISTORY_DEPTID.put("萧县基地", "BM000015");
+        HISTORY_DEPTID.put("张家口基地", "BM000017");
+        HISTORY_DEPTID.put("总办", "BM000021");
+        HISTORY_DEPTID.put("IT部", "BM000022");
+        HISTORY_DEPTID.put("市场运营管理部", "BM000028");
+        HISTORY_DEPTID.put("上海久有私募基金管理有限公司", "1069359193");
+    }
 
     /**
      * 差旅费报销单
@@ -97,58 +137,94 @@ public class DocumentServiceImpl implements DocumentService {
     public McR saveTrip(Map processData) {
         String userId = String.valueOf(processData.get("originatorUserId"));
         String userDeptId = String.valueOf(processData.get("originatorDeptId"));
+        String userDeptName = String.valueOf(processData.get("originatorDeptName"));
+
         List<Map> formComponentValues = (List<Map>) processData.get("formComponentValues");
         Map<String, Object> mainData = new HashMap<>();
         List<CostDetail> costDetails = new ArrayList<>();
         List<TripDetail> tripDetails = new ArrayList<>();
-        formComponentValues.forEach(e->{
-            String name = e.get("name").toString();
-            if ("TableField".equals(e.get("componentType"))) {
-                Object parse = JSON.parse(e.get("value").toString());
-                JSONArray jsonArray = JSON.parseArray(parse.toString());
-                for (int i = 0; i < jsonArray.size(); i++) {
-                    JSONObject jsonObject = (JSONObject) jsonArray.get(i);
-                    Object rowValue = jsonObject.get("rowValue");
-                    JSONArray array = JSON.parseArray(rowValue.toString());
-                    for (int i1 = 0; i1 < array.size(); i1++) {
-                        jsonObject = (JSONObject) array.get(i1);
-                        if ("差旅费信息".equals(jsonObject.get("label"))){
-                            if (jsonObject.containsKey("extendValue")){
-                                rowValue = jsonObject.get("extendValue");
-                                jsonObject = JSONObject.parseObject(rowValue.toString());
-                                rowValue = jsonObject.get("list");
-                                JSONArray array1 =  JSON.parseArray(rowValue.toString());
-                                for (int i2 = 0; i2 < array1.size(); i2++) {
-                                    jsonObject = (JSONObject) array1.get(i2);
-                                    if (jsonObject.containsKey("rowValue")){
-                                        rowValue = jsonObject.get("rowValue");
-                                        JSONArray array2 = JSON.parseArray(rowValue.toString());
-                                        TripDetail tripDetail = new TripDetail();
-                                        for (int l = 0; l < array2.size(); l++) {
-                                            jsonObject = (JSONObject) array2.get(l);
-                                            switch (jsonObject.get("label").toString()){
-                                                case "开始日期": tripDetail.setFTravelStartDate(jsonObject.get("value").toString().substring(0,9));break;
-                                                case "结束日期": tripDetail.setFTravelEndDate(jsonObject.get("value").toString().substring(0,9));break;
-                                                case "费用承担部门": tripDetail.setFExpenseDeptEntryID(new FNumber(UtilMap.getString(jsonObject,"value")));break;
-                                                case "科目编号": tripDetail.setFExpID(new FNumber(UtilMap.getString(jsonObject,"value")));break;
+        formComponentValues.forEach(e-> {
+            if (!"TextNote".equals(e.get("componentType"))){
+                String name = e.get("name").toString();
+                if ("TableField".equals(e.get("componentType")) && "差旅费信息".equals(name)) {
+                    Object parse = JSON.parse(e.get("value").toString());
+                    JSONArray jsonArray = JSON.parseArray(parse.toString());
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+                        if (jsonObject.containsKey("rowValue")){
+                            Object rowValue = jsonObject.get("rowValue");
+                            JSONArray array = JSON.parseArray(rowValue.toString());
+                            TripDetail tripDetail = new TripDetail();
+                            String type = "";
+                            for (int i1 = 0; i1 < array.size(); i1++) {
+                                jsonObject = (JSONObject) array.get(i1);
+                                String sonLabel = jsonObject.get("label").toString();
+                                if ("报销类别".equals(sonLabel)){
+                                    type = jsonObject.get("value").toString();
+                                }
+                            }
+                            for (int i1 = 0; i1 < array.size(); i1++) {
+                                jsonObject = (JSONObject) array.get(i1);
+                                String sonLabel = jsonObject.get("label").toString();
+                                if (jsonObject.containsKey("extendValue")){
+                                    rowValue = jsonObject.get("extendValue");
+                                }else {
+                                    rowValue = jsonObject;
+                                }
+                                Object parse1 = JSON.parse(rowValue.toString());
+                                if (parse1 instanceof JSONObject){
+                                    jsonObject = JSONObject.parseObject(rowValue.toString());
+                                } else if (parse1 instanceof JSONArray) {
+                                    jsonObject = (JSONObject) JSONObject.parseArray(rowValue.toString()).get(0);
+                                }
+                                switch (sonLabel){
+                                    case "开始日期":
+                                        tripDetail.setFTravelStartDate(jsonObject.get("value").toString().substring(0,10));
+                                        break;
+                                    case "结束日期":
+                                        tripDetail.setFTravelEndDate(jsonObject.get("value").toString().substring(0,10));
+                                        break;
+                                    case "费用承担部门":
+                                        if (HISTORY_DEPTID.containsKey(UtilMap.getString(jsonObject,"name"))){
+                                            tripDetail.setFExpenseDeptEntryID(new FNumber(HISTORY_DEPTID.get(UtilMap.getString(jsonObject,"name"))));
+                                        }else {
+                                            tripDetail.setFExpenseDeptEntryID(new FNumber(UtilMap.getString(jsonObject,"id")));
+                                        }
+                                        break;
+                                    case "金蝶科目编号":
+                                        tripDetail.setFExpID(new FNumber(UtilMap.getString(jsonObject, "value")));
+                                        break;
 //                                                case "税率": tripDetail.setFTaxRate(UtilMap.getDouble(jsonObject,"value"));break;
-                                                case "天数": tripDetail.setFDays(UtilMap.getString(jsonObject,"value"));break;
-                                                case "发票类型": tripDetail.setFInvoiceType(UtilMap.getString(jsonObject,"value"));break;
+                                    case "天数":
+                                        tripDetail.setFDays(UtilMap.getString(jsonObject, "value"));
+                                        break;
+                                    case "发票类型":
+                                        tripDetail.setFInvoiceType(UtilMap.getString(jsonObject, "label"));
+                                        break;
 //                                                case "税额": tripDetail.setFTaxAmt(UtilMap.getDouble(jsonObject,"value"));break;
 //                                                case "非税金额": tripDetail.setFTaxSubmitAmt(UtilMap.getDouble(jsonObject,"value"));break;
-                                                case "申请报销金额": tripDetail.setFExpenseAmount(UtilMap.getDouble(jsonObject,"value"));
-                                                tripDetail.setFTaxSubmitAmt(UtilMap.getDouble(jsonObject,"value"));break;
-                                            }
+                                    case "申请报销金额":
+                                        Double amt = UtilMap.getDouble(jsonObject, "value");
+                                        tripDetail.setFExpenseAmount(amt);
+                                        tripDetail.setFTaxSubmitAmt(amt);
+                                        if ("住宿费".equals(type)){
+                                            tripDetail.setFLodgingFee(amt);
+                                        } else if ("交通费".equals(type)) {
+                                            tripDetail.setFOtherTraAmount(amt);
+                                        } else if ("餐饮费".equals(type)) {
+                                            tripDetail.setFOtherExpense(amt);
+                                        } else if ("出差补助".equals(type)) {
+                                            tripDetail.setFTravelSubsidy(amt);
                                         }
-                                        tripDetails.add(tripDetail);
-                                    }
+                                        break;
                                 }
                             }
+                            tripDetails.add(tripDetail);
                         }
                     }
+                } else {
+                    mainData.put(name, e.get("value"));
                 }
-            }else {
-                mainData.put(name, e.get("value"));
             }
         });
         tripDetails.forEach(e->{
@@ -157,27 +233,34 @@ public class DocumentServiceImpl implements DocumentService {
         });
 
         Save save = new Save();
+        save.setSubSystemId("ER");
+        save.setIsAutoAdjustField(true);
 
         TripMain tripMain = new TripMain();
 
-        tripMain.setFBillTypeID(new BillTypeID("0050569440d0b9d111e346dc2d05234a"));
-        tripMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"申请日期").substring(0,9)));
+        tripMain.setFBillTypeID(new BillTypeID("CLFBX001_SYS"));
+        tripMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"申请日期").substring(0,10)));
         tripMain.setFCurrencyID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"币别"))));
         tripMain.setFOrgID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
         tripMain.setFCausa(UtilMap.getString(mainData,"报销事由"));
-        tripMain.setFProposerID(new FNumber(userId));
-        tripMain.setFRequestDeptID(new FNumber(userDeptId));
+        tripMain.setFProposerID(new FSTAFFNUMBER(userId));
+        if (HISTORY_DEPTID.containsKey(userDeptName)){
+            tripMain.setFRequestDeptID(new FNumber(HISTORY_DEPTID.get(userDeptName)));//正式
+            tripMain.setFExpenseDeptID(new FNumber(HISTORY_DEPTID.get(userDeptName)));
+        }else {
+            tripMain.setFRequestDeptID(new FNumber(userDeptId));//正式
+            tripMain.setFExpenseDeptID(new FNumber(userDeptId));
+        }
         tripMain.setFExpenseOrgId(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
-        tripMain.setFExpenseDeptID(new FNumber(userDeptId));
         tripMain.setFCONTACTUNITTYPE("BD_Empinfo");
         tripMain.setFCONTACTUNIT(new FNumber(userId));
-        tripMain.setFLocCurrencyID(new FNumber("1"));
-        tripMain.setFExchangeTypeID(new FNumber("1"));
+        tripMain.setFLocCurrencyID(new FNumber("PRE001"));
+        tripMain.setFExchangeTypeID(new FNumber("HLTX01_SYS"));
         tripMain.setFPayOrgId(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
         tripMain.setFPaySettlleTypeID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"结算方式"))));
-        tripMain.setFRefundBankAccount(UtilMap.getString(mainData,"银行开户行"));
-        tripMain.setFBankBranchT(UtilMap.getString(mainData,"账户名称"));
-        tripMain.setFBankAccountNameT(UtilMap.getString(mainData,"收款账号"));
+        tripMain.setFBankAccountT(UtilMap.getString(mainData,"收款账号"));
+        tripMain.setFBankBranchT(UtilMap.getString(mainData,"银行开户行"));
+        tripMain.setFBankAccountNameT(UtilMap.getString(mainData,"账户名称"));
         tripMain.setFEntity(tripDetails);
 
         save.setModel(tripMain);
@@ -226,77 +309,96 @@ public class DocumentServiceImpl implements DocumentService {
     public McR saveCost(Map processData) {
         String userId = String.valueOf(processData.get("originatorUserId"));
         String userDeptId = String.valueOf(processData.get("originatorDeptId"));
+        String userDeptName = String.valueOf(processData.get("originatorDeptName"));
+
         List<Map> formComponentValues = (List<Map>) processData.get("formComponentValues");
         Map<String, Object> mainData = new HashMap<>();
         List<CostDetail> costDetails = new ArrayList<>();
         formComponentValues.forEach(e->{
-            String name = e.get("name").toString();
-            if ("TableField".equals(e.get("componentType"))) {
-                Object parse = JSON.parse(e.get("value").toString());
-                JSONArray jsonArray = JSON.parseArray(parse.toString());
-                for (int i = 0; i < jsonArray.size(); i++) {
-                    JSONObject jsonObject = (JSONObject) jsonArray.get(i);
-                    Object rowValue = jsonObject.get("rowValue");
-                    JSONArray array = JSON.parseArray(rowValue.toString());
-                    for (int i1 = 0; i1 < array.size(); i1++) {
-                        jsonObject = (JSONObject) array.get(i1);
-                        if (jsonObject.containsKey("extendValue")){
-                            rowValue = jsonObject.get("extendValue");
-                            jsonObject = JSONObject.parseObject(rowValue.toString());
-                            rowValue = jsonObject.get("list");
-                            JSONArray array1 =  JSON.parseArray(rowValue.toString());
-                            for (int i2 = 0; i2 < array1.size(); i2++) {
-                                jsonObject = (JSONObject) array1.get(i2);
-                                if (jsonObject.containsKey("rowValue")){
-                                    rowValue = jsonObject.get("rowValue");
-                                    JSONArray array2 = JSON.parseArray(rowValue.toString());
-                                    CostDetail costDetail = new CostDetail();
-
-                                    for (int l = 0; l < array2.size(); l++) {
-                                        jsonObject = (JSONObject) array2.get(l);
-                                        switch (jsonObject.get("label").toString()){
-                                            case "费用日期": costDetail.setFPAYDATE(jsonObject.get("value").toString().substring(0,9));break;
-                                            case "费用承担部门": costDetail.setFExpenseDeptEntryID(new FNumber(UtilMap.getString(jsonObject,"value")));break;
-                                            case "科目编号": costDetail.setFExpID(new FNumber(UtilMap.getString(jsonObject,"value")));break;
-                                            case "税率": costDetail.setFTaxRate(UtilMap.getDouble(jsonObject,"value"));break;
-                                            case "发票类型": costDetail.setFInvoiceType(UtilMap.getString(jsonObject,"value"));break;
-                                            case "税额": costDetail.setFTaxAmt(UtilMap.getDouble(jsonObject,"value"));break;
-                                            case "非税金额": costDetail.setFTaxSubmitAmt(UtilMap.getDouble(jsonObject,"value"));break;
-                                            case "申请报销金额": costDetail.setFExpenseAmount(UtilMap.getDouble(jsonObject,"value"));break;
+            if (!"TextNote".equals(e.get("componentType"))){
+                String name = e.get("name").toString();
+                if ("TableField".equals(e.get("componentType"))) {
+                    Object parse = JSON.parse(e.get("value").toString());
+                    JSONArray jsonArray = JSON.parseArray(parse.toString());
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+                        if (jsonObject.containsKey("rowValue")){
+                            Object rowValue = jsonObject.get("rowValue");
+                            JSONArray array = JSON.parseArray(rowValue.toString());
+                            CostDetail costDetail = new CostDetail();
+                            for (int i1 = 0; i1 < array.size(); i1++) {
+                                jsonObject = (JSONObject) array.get(i1);
+                                String sonLabel = jsonObject.get("label").toString();
+                                if (jsonObject.containsKey("extendValue")){
+                                    rowValue = jsonObject.get("extendValue");
+                                }else {
+                                    rowValue = jsonObject;
+                                }
+                                Object parse1 = JSON.parse(rowValue.toString());
+                                if (parse1 instanceof JSONObject){
+                                    jsonObject = JSONObject.parseObject(rowValue.toString());
+                                } else if (parse1 instanceof JSONArray) {
+                                    jsonObject = (JSONObject) JSONObject.parseArray(rowValue.toString()).get(0);
+                                }
+                                switch (sonLabel){
+                                    case "费用日期": costDetail.setFPAYDATE(jsonObject.get("value").toString().substring(0,10));break;
+                                    case "费用承担部门":
+                                        if (HISTORY_DEPTID.containsKey(UtilMap.getString(jsonObject,"name"))){
+                                            costDetail.setFExpenseDeptEntryID(new FNumber(HISTORY_DEPTID.get(UtilMap.getString(jsonObject,"name"))));
+                                        }else {
+                                            costDetail.setFExpenseDeptEntryID(new FNumber(UtilMap.getString(jsonObject,"id")));
                                         }
-                                    }
-                                    costDetails.add(costDetail);
+                                        break;
+//                                    case "预算所属部门": costDetail.setFExpenseDeptEntryID(new FNumber("1069359193"));break;
+                                    case "金蝶科目编号": costDetail.setFExpID(new FNumber(UtilMap.getString(jsonObject,"value")));break;
+                                    case "税率": costDetail.setFTaxRate(UtilMap.getDouble(jsonObject,"value"));break;
+                                    case "发票类型": costDetail.setFInvoiceType(UtilMap.getString(jsonObject,"label"));break;
+                                    case "税额": costDetail.setFTaxAmt(UtilMap.getDouble(jsonObject,"value"));break;
+                                    case "非税金额": costDetail.setFTaxSubmitAmt(UtilMap.getDouble(jsonObject,"value"));break;
+                                    case "申请报销金额": costDetail.setFExpenseAmount(UtilMap.getDouble(jsonObject,"value"));break;
                                 }
                             }
+                            costDetails.add(costDetail);
                         }
                     }
+                }else {
+                    mainData.put(name, e.get("value"));
                 }
-            }else {
-                mainData.put(name, e.get("value"));
             }
         });
         Save save = new Save();
+        save.setSubSystemId("ER");
+        save.setIsAutoAdjustField(true);
 
         CostMain costMain = new CostMain();
 
-        costMain.setFBillTypeID(new BillTypeID("000ffecf2c6f97f311e32b0998d51004"));
-        costMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"申请日期").substring(0,9)));
+        costMain.setFBillTypeID(new BillTypeID("FYBXD001_SYS"));
+        costMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"申请日期").substring(0,10)));
         costMain.setFCurrencyID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"币别"))));
         costMain.setFOrgID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
         costMain.setFCausa(UtilMap.getString(mainData,"报销事由"));
-        costMain.setFProposerID(new FNumber(userId));
-        costMain.setFRequestDeptID(new FNumber(userDeptId));
+        costMain.setFProposerID(new FSTAFFNUMBER(userId));
+        if (HISTORY_DEPTID.containsKey(userDeptName)){
+            costMain.setFRequestDeptID(new FNumber(HISTORY_DEPTID.get(userDeptName)));//正式
+            costMain.setFExpenseDeptID(new FNumber(HISTORY_DEPTID.get(userDeptName)));
+        }else {
+            costMain.setFRequestDeptID(new FNumber(userDeptId));//正式
+            costMain.setFExpenseDeptID(new FNumber(userDeptId));
+        }
+//        costMain.setFProposerID(new FNumber("0062"));
+//        costMain.setFRequestDeptID(new FNumber("1069359193"));//测试
+//        costMain.setFExpenseDeptID(new FNumber("1069359193"));//测试
         costMain.setFExpenseOrgId(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
-        costMain.setFExpenseDeptID(new FNumber(userDeptId));
         costMain.setFCONTACTUNITTYPE("BD_Empinfo");
         costMain.setFCONTACTUNIT(new FNumber(userId));
-        costMain.setFLocCurrencyID(new FNumber("1"));
-        costMain.setFExchangeTypeID(new FNumber("1"));
+        costMain.setFLocCurrencyID(new FNumber("PRE001"));
+        costMain.setFExchangeTypeID(new FNumber("HLTX01_SYS"));
         costMain.setFPayOrgId(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
         costMain.setFPaySettlleTypeID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"结算方式"))));
-        costMain.setFRefundBankAccount(UtilMap.getString(mainData,"银行开户行"));
-        costMain.setFBankBranchT(UtilMap.getString(mainData,"账户名称"));
-        costMain.setFBankAccountNameT(UtilMap.getString(mainData,"收款账号"));
+//        costMain.setFRefundBankAccount(new FNumber(UtilMap.getString(mainData,"收款账号")));
+        costMain.setFBankAccountT(UtilMap.getString(mainData,"收款账号"));
+        costMain.setFBankBranchT(UtilMap.getString(mainData,"银行开户行"));
+        costMain.setFBankAccountNameT(UtilMap.getString(mainData,"账户名称"));
         costMain.setFEntity(costDetails);
 
         save.setModel(costMain);
@@ -345,103 +447,134 @@ public class DocumentServiceImpl implements DocumentService {
         List<Map> formComponentValues = (List<Map>) processData.get("formComponentValues");
         Map<String, Object> mainData = new HashMap<>();
         List<PaymentDetail> paymentDetails = new ArrayList<>();
+        PaymentMain paymentMain = new PaymentMain();
         formComponentValues.forEach(e->{
-            String name = e.get("name").toString();
-            if ("TableField".equals(e.get("componentType"))) {
-                Object parse = JSON.parse(e.get("value").toString());
-                JSONArray jsonArray = JSON.parseArray(parse.toString());
-                for (int i = 0; i < jsonArray.size(); i++) {
-                    JSONObject jsonObject = (JSONObject) jsonArray.get(i);
-                    Object rowValue = jsonObject.get("rowValue");
-                    JSONArray array = JSON.parseArray(rowValue.toString());
-                    for (int i1 = 0; i1 < array.size(); i1++) {
-                        jsonObject = (JSONObject) array.get(i1);
-                        if (jsonObject.containsKey("extendValue")){
-                            rowValue = jsonObject.get("extendValue");
-                            jsonObject = JSONObject.parseObject(rowValue.toString());
-                            rowValue = jsonObject.get("list");
-                            JSONArray array1 =  JSON.parseArray(rowValue.toString());
-                            for (int i2 = 0; i2 < array1.size(); i2++) {
-                                jsonObject = (JSONObject) array1.get(i2);
-                                if (jsonObject.containsKey("rowValue")){
-                                    rowValue = jsonObject.get("rowValue");
-                                    JSONArray array2 = JSON.parseArray(rowValue.toString());
-                                    PaymentDetail paymentDetail = new PaymentDetail();
-                                    paymentDetail.setFPriceQty(1);
-                                    for (int l = 0; l < array2.size(); l++) {
-                                        Map<String, Object> map = new HashMap<>();
-                                        jsonObject = (JSONObject) array2.get(l);
-
-                                        switch (jsonObject.get("label").toString()){
-                                            case "科目编号": paymentDetail.setFCOSTID(new FNumber(jsonObject.get("value").toString()));break;
-                                            case "税率": paymentDetail.setFEntryTaxRate(UtilMap.getDouble(jsonObject,"value"));break;
-                                            case "税额": paymentDetail.setFNoTaxAmountFor_D(UtilMap.getDouble(jsonObject,"value"));break;
-                                            case "金额(非税)": paymentDetail.setFALLAMOUNTFOR_D(UtilMap.getDouble(jsonObject,"value"));break;
-                                        }
-                                    }
-                                    paymentDetails.add(paymentDetail);
+            if (!"TextNote".equals(e.get("componentType"))) {
+                String name = e.get("name").toString();
+                if ("TableField".equals(e.get("componentType"))) {
+                    Object parse = JSON.parse(e.get("value").toString());
+                    JSONArray jsonArray = JSON.parseArray(parse.toString());
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+                        if (jsonObject.containsKey("rowValue")) {
+                            Object rowValue = jsonObject.get("rowValue");
+                            JSONArray array = JSON.parseArray(rowValue.toString());
+                            PaymentDetail paymentDetail = new PaymentDetail();
+                            for (int i1 = 0; i1 < array.size(); i1++) {
+                                jsonObject = (JSONObject) array.get(i1);
+                                String sonLabel = jsonObject.get("label").toString();
+                                if (jsonObject.containsKey("extendValue")) {
+                                    rowValue = jsonObject.get("extendValue");
+                                } else {
+                                    rowValue = jsonObject;
+                                }
+                                Object parse1 = JSON.parse(rowValue.toString());
+                                if (parse1 instanceof JSONObject) {
+                                    jsonObject = JSONObject.parseObject(rowValue.toString());
+                                } else if (parse1 instanceof JSONArray) {
+                                    jsonObject = (JSONObject) JSONObject.parseArray(rowValue.toString()).get(0);
+                                }
+                                switch (sonLabel) {
+                                    case "金蝶科目编号":
+                                        paymentDetail.setFCOSTID(new FNumber(jsonObject.get("value").toString()));
+                                        break;
+                                    case "税率":
+                                        paymentDetail.setFEntryTaxRate(UtilMap.getDouble(jsonObject, "value"));
+                                        break;
+                                    case "税额":
+                                        paymentDetail.setFNoTaxAmountFor_D(UtilMap.getDouble(jsonObject, "value"));
+                                        break;
+                                    case "金额(非税)":
+                                        paymentDetail.setFALLAMOUNTFOR_D(UtilMap.getDouble(jsonObject, "value"));
+                                        break;
                                 }
                             }
+                            paymentDetails.add(paymentDetail);
                         }
                     }
                 }
-            }else {
-                mainData.put(name, e.get("value"));
-            }
-        });
-        Save save = new Save();
-
-
-        PaymentMain paymentMain = new PaymentMain();
-        paymentMain.setFBillTypeID(new BillTypeID("YFD02_SYS"));
-        paymentMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"业务日期").substring(0,9)));
-        paymentMain.setFENDDATE_H(LocalDate.parse(UtilMap.getString(mainData,"付款到期日").substring(0,9)));
-        paymentMain.setFDOCUMENTSTATUS("A");//单据状态为创建
-        paymentMain.setFSUPPLIERID(new FNumber(UtilMap.getString(mainData,"供应商编号")));
-        paymentMain.setFCURRENCYID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"币别"))));
-        paymentMain.setFPAYORGID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
-        paymentMain.setFSETTLEORGID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
-        paymentMain.setFPURCHASEDEPTID(new FNumber(userDeptId));
-//        paymentMain.setFPURCHASERID(new FNumber());
-        paymentMain.setFEntityDetail(paymentDetails);
-
-        save.setModel(paymentMain);
-        System.out.println(save);
-
-        try{
-            K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
-            //业务对象标识
-            String formId = "AP_Payable";
-            //调用接口
-            String resultJson = client.save(formId,JSONObject.toJSONString(save));
-            //用于记录结果
-            Gson gson = new Gson();
-            //对返回结果进行解析和校验
-            RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
+                else if ("FormRelateField".equals(e.get("componentType"))) {
+                    JSONObject root = JSON.parseObject(UtilMap.getString(e,"extValue"));
 
-            if (kingDeeService.isTrue(repoRet)){
-                String id = repoRet.getResult().getId();
+                    // 获取 list 数组,并取第一个元素(假设只有一个)
+                    JSONArray list = root.getJSONArray("list");
+                    if (list == null || list.isEmpty()) {
+                        return;
+                    }
+                    JSONObject firstItem = list.getJSONObject(0);
 
-                Submit submit = new Submit();
-                submit.setIds(id);
-                //提交
-                String resultJson2 = client.submit(formId, JSONObject.toJSONString(submit));
-                RepoRet repoRet2 = gson.fromJson(resultJson2, RepoRet.class);
-                kingDeeService.isTrue(repoRet2);
+                    // 获取 rowValue 数组
+                    JSONArray rowValues = firstItem.getJSONArray("rowValue");
+                    if (rowValues == null) {
+                        return;
+                    }
 
-                if (kingDeeService.isTrue(repoRet2)){
-                    Audit audit = new Audit();
-                    audit.setIds(id);
-                    //审核
-                    String resultJson3 = client.audit(formId,JSONObject.toJSONString(audit));
-                    RepoRet repoRet3 = gson.fromJson(resultJson3, RepoRet.class);
-                    kingDeeService.isTrue(repoRet3);
+                    // 遍历查找 label 为 "供应商编号" 的项
+                    for (int i = 0; i < rowValues.size(); i++) {
+                        JSONObject field = rowValues.getJSONObject(i);
+                        String label = field.getString("label");
+                        if ("供应商编号".equals(label)) {
+                           paymentMain.setFSUPPLIERID(new FNumber(field.getString("value")));
+                        }
+                    }
+                }
+                else {
+                    mainData.put(name, e.get("value"));
                 }
             }
-        } catch (Exception e) {
-            McR.errorUnknown(e.getMessage());
-        }
+            });
+            Save save = new Save();
+
+            paymentMain.setFBUSINESSTYPE("FY");
+            paymentMain.setFBillTypeID(new BillTypeID("YFD02_SYS"));
+            paymentMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"业务日期").substring(0,10)));
+            paymentMain.setFENDDATE_H(LocalDate.parse(UtilMap.getString(mainData,"付款到期日").substring(0,10)));
+            paymentMain.setFDOCUMENTSTATUS("A");//单据状态为创建
+            paymentMain.setFCURRENCYID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"币别"))));
+            paymentMain.setFPAYORGID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
+            paymentMain.setFSETTLEORGID(new FNumber(UtilMap.getString(ALL_ENUM,UtilMap.getString(mainData,"所属公司主体"))));
+            paymentMain.setFPURCHASEDEPTID(new FNumber(userDeptId));
+            paymentMain.setFAP_Remark(UtilMap.getString(mainData,"备注"));
+//        paymentMain.setFPURCHASERID(new FNumber());
+            paymentMain.setFEntityDetail(paymentDetails);
+
+            save.setModel(paymentMain);
+            System.out.println(save);
+
+            try{
+                K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
+                //业务对象标识
+                String formId = "AP_Payable";
+                //调用接口
+                String resultJson = client.save(formId,JSONObject.toJSONString(save));
+                //用于记录结果
+                Gson gson = new Gson();
+                //对返回结果进行解析和校验
+                RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
+
+                if (kingDeeService.isTrue(repoRet)){
+                    String id = repoRet.getResult().getId();
+
+                    Submit submit = new Submit();
+                    submit.setIds(id);
+                    //提交
+                    String resultJson2 = client.submit(formId, JSONObject.toJSONString(submit));
+                    RepoRet repoRet2 = gson.fromJson(resultJson2, RepoRet.class);
+                    kingDeeService.isTrue(repoRet2);
+
+                    if (kingDeeService.isTrue(repoRet2)){
+                        Audit audit = new Audit();
+                        audit.setIds(id);
+                        //审核
+                        String resultJson3 = client.audit(formId,JSONObject.toJSONString(audit));
+                        RepoRet repoRet3 = gson.fromJson(resultJson3, RepoRet.class);
+                        kingDeeService.isTrue(repoRet3);
+                    }
+                }
+            } catch (Exception e) {
+                McR.errorUnknown(e.getMessage());
+            }
 
-        return McR.success();
+            return McR.success();
+        }
     }
-}

+ 27 - 3
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/service/Impl/SupplierServiceImpl.java

@@ -2,8 +2,11 @@ package com.malk.jiuyousimu.service.Impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
+import com.google.gson.Gson;
+import com.kingdee.bos.webapi.entity.RepoRet;
 import com.kingdee.bos.webapi.sdk.K3CloudApi;
 import com.malk.jiuyousimu.entity.basic.Query;
+import com.malk.jiuyousimu.entity.basic.View;
 import com.malk.jiuyousimu.service.KingDeeService;
 import com.malk.jiuyousimu.service.SupplierService;
 import com.malk.server.common.McR;
@@ -263,15 +266,36 @@ public class SupplierServiceImpl implements SupplierService {
     }
     @Override
     public void testQuery(){
-        String fieldKeys = "FSOCIALCRECODE";
+        String fieldKeys = "FBillTypeID,FBillNo,FBUSINESSTYPE";
         K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
         Query query = new Query();
-        query.setFormId("BD_Supplier");
+        query.setFormId("AP_Payable");
         query.setFieldKeys(fieldKeys);
         try {
             //调用接口
             List<List<Object>> billQuery = client.executeBillQuery(JSON.toJSONString(query));
-
+            System.out.println(billQuery.toString());
+            log.info(billQuery.toString());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+    @Override
+    public void testView(){
+        K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
+        View view = new View();
+        view.setNumber("FYBX20220223000001");
+        String formId = "ER_ExpReimbursement";
+        try {
+            String resultJson = client.view(formId, JSON.toJSONString(view));
+            Gson gson = new Gson();
+            //对返回结果进行解析和校验
+            RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
+            if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
+                System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
+            } else {
+                fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
+            }
         } catch (Exception e) {
             fail(e.getMessage());
         }

+ 2 - 0
mjava-jiuyousimu/src/main/java/com/malk/jiuyousimu/service/SupplierService.java

@@ -29,4 +29,6 @@ public interface SupplierService {
     McR accountPushToOA();
 
     void testQuery();
+
+    void testView();
 }

+ 1 - 1
mjava-jiuyousimu/src/main/resources/application-dev.yml

@@ -6,7 +6,7 @@ server:
 
 # condition
 spel:
-  scheduling: true        # 定时任务是否执行
+  scheduling: false        # 定时任务是否执行
   multiSource: false       # 是否多数据源配置
 
 spring: