|
@@ -0,0 +1,447 @@
|
|
|
|
|
+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.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;
|
|
|
|
|
+import com.malk.jiuyousimu.entity.reimbursement.CostMain;
|
|
|
|
|
+import com.malk.jiuyousimu.entity.reimbursement.TripDetail;
|
|
|
|
|
+import com.malk.jiuyousimu.entity.reimbursement.TripMain;
|
|
|
|
|
+import com.malk.jiuyousimu.service.DocumentService;
|
|
|
|
|
+import com.malk.jiuyousimu.service.KingDeeService;
|
|
|
|
|
+import com.malk.server.common.McR;
|
|
|
|
|
+import com.malk.service.dingtalk.*;
|
|
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+@Service
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class DocumentServiceImpl implements DocumentService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient ddClient;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Workflow ddClient_workflow;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Meeting ddClientMeeting;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Contacts ddClient_contacts;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Personnel ddClientPersonnel;
|
|
|
|
|
+ @Value("${dingtalk.appKey}")
|
|
|
|
|
+ private String APP_EKY;
|
|
|
|
|
+ @Value("${dingtalk.appSecret}")
|
|
|
|
|
+ private String APP_SECRET;
|
|
|
|
|
+ @Value("${dingtalk.agentId}")
|
|
|
|
|
+ private Long agentId;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KingDeeService kingDeeService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ DDService ddService;
|
|
|
|
|
+
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+
|
|
|
|
|
+ private static final Map<String,String> ALL_ENUM = new HashMap<>();
|
|
|
|
|
+ static {
|
|
|
|
|
+ ALL_ENUM.put("人民币","PRE001");
|
|
|
|
|
+ ALL_ENUM.put("美元","001");
|
|
|
|
|
+ ALL_ENUM.put("上海久有私募基金管理有限公司","100");
|
|
|
|
|
+ ALL_ENUM.put("上海久有川谷投资管理有限公司","114");
|
|
|
|
|
+ ALL_ENUM.put("现金", "01");
|
|
|
|
|
+ ALL_ENUM.put("银行转账", "02");
|
|
|
|
|
+ ALL_ENUM.put("网银", "03");
|
|
|
|
|
+ ALL_ENUM.put("现金支票", "JSFS02_SYS");
|
|
|
|
|
+ ALL_ENUM.put("转账支票", "JSFS03_SYS");
|
|
|
|
|
+ ALL_ENUM.put("信汇", "JSFS05_SYS");
|
|
|
|
|
+ ALL_ENUM.put("商业承兑汇票", "JSFS06_SYS");
|
|
|
|
|
+ ALL_ENUM.put("银行承兑汇票", "JSFS07_SYS");
|
|
|
|
|
+ ALL_ENUM.put("信用证", "JSFS08_SYS");
|
|
|
|
|
+ ALL_ENUM.put("应收票据背书", "JSFS09_SYS");
|
|
|
|
|
+ ALL_ENUM.put("内部利息结算", "JSFS10_SYS");
|
|
|
|
|
+ ALL_ENUM.put("票据退票", "JSFS12_SYS");
|
|
|
|
|
+ ALL_ENUM.put("集中结算", "JSFS21_SYS");
|
|
|
|
|
+ ALL_ENUM.put("保证金转货款", "JSFS22_SYS");
|
|
|
|
|
+ ALL_ENUM.put("微信", "JSFS31_SYS");
|
|
|
|
|
+ ALL_ENUM.put("支付宝", "JSFS32_SYS");
|
|
|
|
|
+ ALL_ENUM.put("供应链票据", "JSFS36_SYS");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 差旅费报销单
|
|
|
|
|
+ * @param processData 钉钉单据
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public McR saveTrip(Map processData) {
|
|
|
|
|
+ String userId = String.valueOf(processData.get("originatorUserId"));
|
|
|
|
|
+ String userDeptId = String.valueOf(processData.get("originatorDeptId"));
|
|
|
|
|
+ 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;
|
|
|
|
|
+// 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.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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ tripDetails.add(tripDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ mainData.put(name, e.get("value"));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ tripDetails.forEach(e->{
|
|
|
|
|
+ e.setFTravelStartSite(UtilMap.getString(mainData,"出发地"));
|
|
|
|
|
+ e.setFTravelEndSite(UtilMap.getString(mainData,"目的地"));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Save save = new Save();
|
|
|
|
|
+
|
|
|
|
|
+ TripMain tripMain = new TripMain();
|
|
|
|
|
+
|
|
|
|
|
+ tripMain.setFBillTypeID(new BillTypeID("0050569440d0b9d111e346dc2d05234a"));
|
|
|
|
|
+ tripMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"申请日期").substring(0,9)));
|
|
|
|
|
+ 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.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.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.setFEntity(tripDetails);
|
|
|
|
|
+
|
|
|
|
|
+ save.setModel(tripMain);
|
|
|
|
|
+ System.out.println(save);
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
|
|
|
|
|
+ //业务对象标识
|
|
|
|
|
+ String formId = "ER_ExpReimbursement_Travel";
|
|
|
|
|
+ //调用接口
|
|
|
|
|
+ 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();
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 费用报销
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public McR saveCost(Map processData) {
|
|
|
|
|
+ String userId = String.valueOf(processData.get("originatorUserId"));
|
|
|
|
|
+ String userDeptId = String.valueOf(processData.get("originatorDeptId"));
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ costDetails.add(costDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ mainData.put(name, e.get("value"));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ Save save = new Save();
|
|
|
|
|
+
|
|
|
|
|
+ CostMain costMain = new CostMain();
|
|
|
|
|
+
|
|
|
|
|
+ costMain.setFBillTypeID(new BillTypeID("000ffecf2c6f97f311e32b0998d51004"));
|
|
|
|
|
+ costMain.setFDATE(LocalDate.parse(UtilMap.getString(mainData,"申请日期").substring(0,9)));
|
|
|
|
|
+ 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.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.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.setFEntity(costDetails);
|
|
|
|
|
+
|
|
|
|
|
+ save.setModel(costMain);
|
|
|
|
|
+ System.out.println(save);
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
|
|
|
|
|
+ //业务对象标识
|
|
|
|
|
+ String formId = "ER_ExpReimbursement";
|
|
|
|
|
+ //调用接口
|
|
|
|
|
+ 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();
|
|
|
|
|
+ }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public McR savePayment(Map processData) {
|
|
|
|
|
+ String userId = String.valueOf(processData.get("originatorUserId"));
|
|
|
|
|
+ String userDeptId = String.valueOf(processData.get("originatorDeptId"));
|
|
|
|
|
+ List<Map> formComponentValues = (List<Map>) processData.get("formComponentValues");
|
|
|
|
|
+ Map<String, Object> mainData = new HashMap<>();
|
|
|
|
|
+ List<PaymentDetail> paymentDetails = 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());
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }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);
|
|
|
|
|
+
|
|
|
|
|
+ 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();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|