|
@@ -0,0 +1,71 @@
|
|
|
|
|
+package com.malk.eastar.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.malk.eastar.service.AitableService;
|
|
|
|
|
+import com.malk.eastar.service.DDCoreClient;
|
|
|
|
|
+import com.malk.server.common.McException;
|
|
|
|
|
+import com.malk.server.common.McR;
|
|
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/aitable")
|
|
|
|
|
+public class AitableController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AitableService aitableService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDCoreClient ddCoreClient;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新建商机
|
|
|
|
|
+ * @param data
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/newOpportunity")
|
|
|
|
|
+ McR createNewOpportunity(@RequestBody JSONObject data) {
|
|
|
|
|
+ log.info("新建商机, {}", data);
|
|
|
|
|
+ McException.assertParamException_Null(data, "yidaInstanceId");
|
|
|
|
|
+ String yidaInstanceId = UtilMap.getString(data, "yidaInstanceId"); //宜搭实例ID
|
|
|
|
|
+ String yidaProjectCode = UtilMap.getString(data, "yidaProjectCode"); //项目编号
|
|
|
|
|
+ String yidaProjectName = UtilMap.getString(data, "yidaProjectName"); //项目名称
|
|
|
|
|
+ String yidaOrderCompletionRate = UtilMap.getString(data, "yidaOrderCompletionRate"); //成单情况
|
|
|
|
|
+ String yidaEstimatedOrderDate = UtilMap.getString(data, "yidaEstimatedOrderDate"); //预计成单日期
|
|
|
|
|
+ String yidaOrderAmount = UtilMap.getString(data, "yidaOrderAmount"); //预计项目金额
|
|
|
|
|
+ String yidaCustomerName = UtilMap.getString(data, "yidaCustomerName"); //客户
|
|
|
|
|
+ String yidaBusinessUserId = UtilMap.getString(data, "yidaBusinessUserId"); //业务
|
|
|
|
|
+ Map<String,Object> fields = new HashMap<>();
|
|
|
|
|
+ try {
|
|
|
|
|
+ fields.put("zP1nHJs",yidaProjectCode); //项目编号 - S1【基础】
|
|
|
|
|
+ fields.put("P3XtfD8",yidaProjectName); //项目名称 - S1【基础】
|
|
|
|
|
+ fields.put("KDAelfq",yidaOrderCompletionRate); //成单情况【商机进度】
|
|
|
|
|
+ fields.put("m34IbuX",Long.parseLong(yidaEstimatedOrderDate)); //预计成单日期 - S1~2【商机进度】
|
|
|
|
|
+ fields.put("MYBeHPG",yidaOrderAmount); //订单金额 - S2~3【销售数据】
|
|
|
|
|
+ JSONObject bidirectionalLink = new JSONObject();
|
|
|
|
|
+ String[] linkedRecordIds = new String[]{aitableService.querySys1CustomerIdByName(yidaCustomerName)};
|
|
|
|
|
+ bidirectionalLink.put("linkedRecordIds",linkedRecordIds);
|
|
|
|
|
+ fields.put("F7zdGI6",bidirectionalLink); //客户公司名 - S1【基础】
|
|
|
|
|
+ JSONArray user = new JSONArray();
|
|
|
|
|
+ JSONObject unionId = new JSONObject();
|
|
|
|
|
+ unionId.put("unionId",ddCoreClient.getUnionIdByUserId(yidaBusinessUserId));
|
|
|
|
|
+ user.add(unionId);
|
|
|
|
|
+ fields.put("Iz0yaro",JSONObject.toJSONString(user)); //业务 - S1【人事】
|
|
|
|
|
+ String aitableId = aitableService.addSys1SaleData(fields);
|
|
|
|
|
+ return McR.success(aitableId);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return McR.error("400",e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|