wzy před 2 týdny
rodič
revize
96677b6fa7

+ 10 - 0
mjava-siku/src/main/java/com/malk/siku/controller/SikuController.java

@@ -75,6 +75,16 @@ public class SikuController {
         return sikuService.saveBxReimbursement2(map);
     }
 
+    /**
+     * 预付退回导入
+     * @param map
+     * @return
+     */
+    @PostMapping("/saveRepayment")
+    public McR saveRepayment(@RequestBody Map map){
+        return sikuService.saveRepayment(map);
+    }
+
     /**
      * 采购单可用预算校验-停用
      * @param map

+ 2 - 0
mjava-siku/src/main/java/com/malk/siku/service/SikuService.java

@@ -34,4 +34,6 @@ public interface SikuService {
     void invoiceWriteBack7(Map map);
 
     void invoiceWriteBack8(Map map);
+
+    McR saveRepayment(Map map);
 }

+ 114 - 0
mjava-siku/src/main/java/com/malk/siku/service/impl/SikuServiceImpl.java

@@ -1999,6 +1999,120 @@ public class SikuServiceImpl implements SikuService {
                 .build(), YDConf.FORM_OPERATION.create);
     }
 
+    @Override
+    public McR saveRepayment(Map map) {
+        String formInstId = UtilMap.getString(map, "formInstId");
+
+        Map formData = ydClient.queryData(YDParam.builder()
+                .formInstanceId(formInstId)
+                .build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
+
+        String thbh = UtilMap.getString(formData, "serialNumberField_mkkmij3o");//退回编号
+
+        String type = UtilMap.getString(formData, "radioField_mkkmij3b");
+        String ssgssh = UtilMap.getString(formData, "textField_mmd6hio7");//所属公司税号
+
+        String sqrgh = UtilMap.getString(formData, "textField_mmwvodde");//申请人工号
+
+        Map employeeDetails = MkBxUtil.employeeDetails(UtilMap.map("employeeIds", Arrays.asList(sqrgh)));
+        String deptBusinessCode = "";
+        String empId = "";
+        if (Objects.nonNull(employeeDetails)){
+            List<Map> departments = UtilMap.getList(employeeDetails, "departments");
+            deptBusinessCode = UtilMap.getString(departments.get(0), "businessCode");
+
+            empId = sqrgh;
+        }else {
+            empId = "002";//默认沃洲洋
+            deptBusinessCode = "DI203800035494740082";//默认DI203800035494740082
+        }
+
+        if ("直接采购".equals(type)){
+            String cgbh = UtilMap.getString(formData, "textField_mn4fwdj5");//采购编号
+
+            List<Map> cgmxList = UtilMap.getList(formData, "tableField_mkkmij56");
+
+            for (Map cgmx : cgmxList) {
+                Double amt = UtilMap.getDouble(cgmx, "numberField_mn2wqvpp");//退回金额
+                if (amt == 0) continue;
+
+                int index = UtilMap.getInt(cgmx, "numberField_mn36ykxx");//索引
+                String thsy = UtilMap.getString(cgmx, "textareaField_mo2k0ien");//退回事由
+                String gysbh = UtilMap.getString(cgmx, "textField_mmbmohrb");//供应商编号
+
+                Map reimburseDetailInfo = MkBxUtil.reimburseDetailInfo(cgbh + "-" + index);
+
+                Map expense = ((List<Map>) UtilMap.getList(reimburseDetailInfo, "expenseList")).get(0);
+
+                String expenseCode = UtilMap.getString(expense, "code");//费用编码
+
+                Map noReceiptReturn = new HashMap();
+                noReceiptReturn.put("recordExpenseCode",expenseCode);
+                noReceiptReturn.put("recordDeductionAmount",new HashMap<String,Object>(){{put("currency","CNY");put("amount",amt);}});
+
+                Map body = new HashMap();
+                body.put("formCode",thbh + index);
+                body.put("repaymentName",thsy);
+                body.put("formSubTypeBizCode","FT212654855978767371");
+                body.put("submittedUserEmployeeId",empId);
+                body.put("coverEmployeeId",empId);
+                body.put("departmentBizCode",deptBusinessCode);
+                body.put("legalEntityBizCode",ssgssh);
+                body.put("repayAmount",new HashMap<String,Object>(){{put("currency","CNY");put("amount",amt);}});
+                body.put("repaymentDate",System.currentTimeMillis());
+                body.put("tradingPartnerBizCode",gysbh);
+                body.put("paymentType","BANK");
+                body.put("noReceiptReturnList",Arrays.asList(noReceiptReturn));
+                body.put("stagingFlag",false);
+
+                MkBxUtil.receiveRepayment(body);
+            }
+
+        }else {//需求采购
+            String xqbh = UtilMap.getString(formData, "textField_mn4fwdj4");//需求编号
+
+            List<Map> cgmxList = UtilMap.getList(formData, "tableField_mn2xmq2b");
+
+            for (Map cgmx : cgmxList) {
+                Double amt = UtilMap.getDouble(cgmx, "numberField_mn2xmq1p");//退回金额
+                if (amt == 0) continue;
+
+                int index = UtilMap.getInt(cgmx, "numberField_mn39fdfe");//索引
+                String thsy = UtilMap.getString(cgmx, "textareaField_mo2k0iep");//退回事由
+                String gysbh = UtilMap.getString(cgmx, "textField_mn2xmq27");//供应商编号
+
+                Map reimburseDetailInfo = MkBxUtil.reimburseDetailInfo(xqbh + "-" + index);
+
+                Map expense = ((List<Map>) UtilMap.getList(reimburseDetailInfo, "expenseList")).get(0);
+
+                String expenseCode = UtilMap.getString(expense, "code");//费用编码
+
+                Map noReceiptReturn = new HashMap();
+                noReceiptReturn.put("recordExpenseCode",expenseCode);
+                noReceiptReturn.put("recordDeductionAmount",new HashMap<String,Object>(){{put("currency","CNY");put("amount",amt);}});
+
+                Map body = new HashMap();
+                body.put("formCode",thbh + index);
+                body.put("repaymentName",thsy);
+                body.put("formSubTypeBizCode","FT212654855978767371");
+                body.put("submittedUserEmployeeId",empId);
+                body.put("coverEmployeeId",empId);
+                body.put("departmentBizCode",deptBusinessCode);
+                body.put("legalEntityBizCode",ssgssh);
+                body.put("repayAmount",new HashMap<String,Object>(){{put("currency","CNY");put("amount",amt);}});
+                body.put("repaymentDate",System.currentTimeMillis());
+                body.put("tradingPartnerBizCode",gysbh);
+                body.put("paymentType","BANK");
+                body.put("noReceiptReturnList",Arrays.asList(noReceiptReturn));
+                body.put("stagingFlag",false);
+
+                MkBxUtil.receiveRepayment(body);
+            }
+        }
+
+        return McR.success();
+    }
+
     private static String getMkStrValue(Map formData, String entityName) {
         Map title = UtilMap.getMap(formData, entityName);
         Map value = UtilMap.getMap(title, "value");

+ 10 - 0
mjava-siku/src/main/java/com/malk/siku/utils/MkBxUtil.java

@@ -161,6 +161,16 @@ public class MkBxUtil {
         return expenseCodes;
     }
 
+    //还款单写入接口
+    public static Map receiveRepayment(Object body){
+        log.info("body:{}",JSONObject.toJSONString(body));
+        Map result = (Map) JSONObject.parse(UtilHttp.doPost("https://" + host + "/api/openapi/receive/repayment", MkBxUtil.initTokenHeader(), null, body,(Map) null));
+
+        log.info("Result:{}",result);
+
+        return result;
+    }
+
     //费用类型查询
     public static String expenseTypeSearch(Object body){
         log.info("body:{}",JSONObject.toJSONString(body));