package com.example.sso.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.example.sso.dao.File; import com.example.sso.util.V5utils; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController public class DingDanJieShuHouYiChang { @PostMapping("/dingdanjieshuhouyichang") public String dingdanjieshuhouyichang(@RequestBody JSONObject datas) throws Exception { log.info("数据 " + datas); JSONObject jsonObject = new JSONObject(); jsonObject.put("app_id", "68215c6cbaccd58c66796bc5"); jsonObject.put("entry_id", "68218467de8bbe9eed3850e0"); jsonObject.put("is_start_trigger", true); jsonObject.put("transaction_id", "transaction_id"); JSONObject data = new JSONObject(); String fields = ""; String relatedBusiness = ""; String followedAgents = ""; String relatedCallSheet = ""; String relatedWebchats = ""; String phone = datas.getString("phone"); String _id = datas.getString("_id"); String customerId = datas.getString("customerId"); String user = datas.getString("user"); JSONArray jsonArray1 = datas.getJSONArray("fields"); if (jsonArray1 != null && jsonArray1.size() != 0){ fields = jsonArray1.toJSONString(); } String createTime = datas.getString("createTime"); Integer createTimestamp = datas.getInteger("createTimestamp"); String action = datas.getString("action"); String stepName = datas.getString("stepName"); String businessNumber = datas.getString("businessNumber"); String priority = datas.getString("priority"); String category = datas.getString("category"); JSONArray jsonArray2 = datas.getJSONArray("relatedBusiness"); if (jsonArray2 != null && jsonArray2.size() != 0){ relatedBusiness = jsonArray2.toJSONString(); } String createUser = datas.getString("createUser"); String createMode = datas.getString("createMode"); String visitorId = datas.getString("visitorId"); JSONArray jsonArray3 = datas.getJSONArray("followedAgents"); if (jsonArray3 != null && jsonArray3.size() != 0){ followedAgents = jsonArray3.toJSONString(); } JSONArray jsonArray4 = datas.getJSONArray("relatedCallSheet"); if (jsonArray4 != null && jsonArray4.size() != 0){ relatedCallSheet = jsonArray4.toJSONString(); } JSONArray jsonArray5 = datas.getJSONArray("relatedWebchats"); if (jsonArray5 != null && jsonArray5.size() != 0){ relatedWebchats = jsonArray5.toJSONString(); } String flowInfo = datas.getString("flowInfo"); JSONArray stepFields = datas.getJSONArray("stepFields"); for (Object o :stepFields ){ JSONObject test = (JSONObject) o; String name = test.getString("name"); if (name.equals("出租车车牌号")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("cph", xm ); } if (name.equals("司机姓名")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("sjxm", xm ); } if (name.equals("司机服务监督卡号")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("jdkh", xm ); } if (name.equals("司机电话")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("sjdh", xm ); } if (name.equals("fsfz")){ JSONObject xm = new JSONObject(); xm.put("value", Integer.parseInt(test.getString("value"))); data.put("fsfz", xm ); } if (name.equals("详细描述")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("xxms", xm ); } if (name.equals("详细描述图片上传")){ JSONObject xm = new JSONObject(); // String string = test.getString("value"); JSONArray jsonArray = new JSONArray(); JSONArray value = test.getJSONArray("value"); for (Object o1 : value) { JSONObject testa = (JSONObject) o1; String string = testa.getString("value"); String file = File.filedingdanjieshuhouyiyang(string); jsonArray.add(file); } xm.put("value", jsonArray); data.put("pic", xm); } if (name.equals("白龙马订单号")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("blmddh", xm ); } if (name.equals("客服处理人")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("kfclr", xm ); } if (name.equals("当前状态")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("now_state", xm ); } if (name.equals("备注")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("bz", xm ); } if (name.equals("机构")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("jg", xm ); } if (name.equals("分司")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("fs", xm ); } if (name.equals("车队")){ JSONObject xm = new JSONObject(); xm.put("value", test.getString("value")); data.put("cd", xm ); } } JSONObject fields1 = new JSONObject(); fields1.put("value", fields); data.put("fields", fields1 ); JSONObject relatedBusiness1 = new JSONObject(); relatedBusiness1.put("value", relatedBusiness); data.put("relatedbusiness", relatedBusiness1 ); JSONObject followedAgents1 = new JSONObject(); followedAgents1.put("value", followedAgents); data.put("followedagents", followedAgents1 ); JSONObject relatedCallSheet1 = new JSONObject(); relatedCallSheet1.put("value", relatedCallSheet); data.put("relatedcallsheet", relatedCallSheet1 ); JSONObject relatedWebchats1 = new JSONObject(); relatedWebchats1.put("value", relatedWebchats); data.put("relatedwebchats", relatedWebchats1 ); JSONObject phone1 = new JSONObject(); phone1.put("value", phone); data.put("phone", phone1 ); JSONObject id = new JSONObject(); id.put("value", _id); data.put("id", id ); JSONObject customerId1 = new JSONObject(); customerId1.put("value", customerId); data.put("customerid", customerId1 ); JSONObject user1 = new JSONObject(); user1.put("value", user); data.put("user", user1 ); JSONObject createTime1 = new JSONObject(); createTime1.put("value", createTime); data.put("createtime", createTime1 ); JSONObject createTimestamp1 = new JSONObject(); createTimestamp1.put("value", createTimestamp); data.put("createtimestamp", createTimestamp1 ); JSONObject action1 = new JSONObject(); action1.put("value", action); data.put("action", action1 ); JSONObject stepName1 = new JSONObject(); stepName1.put("value", stepName); data.put("stepname", stepName1 ); JSONObject businessNumber1 = new JSONObject(); businessNumber1.put("value", businessNumber); data.put("businessnumber", businessNumber1 ); JSONObject priority1 = new JSONObject(); priority1.put("value", priority); data.put("priority", priority1 ); JSONObject category1 = new JSONObject(); category1.put("value", category); data.put("category", category1 ); JSONObject createUser1 = new JSONObject(); createUser1.put("value", createUser); data.put("createuser", createUser1 ); JSONObject createMode1 = new JSONObject(); createMode1.put("value", createMode); data.put("createmode", createMode1 ); JSONObject visitorId1 = new JSONObject(); visitorId1.put("value", visitorId); data.put("visitorid", visitorId1 ); JSONObject flowInfo1 = new JSONObject(); flowInfo1.put("value", flowInfo); data.put("flowinfo", flowInfo1 ); jsonObject.put("data", data); String jsonString = jsonObject.toJSONString(); V5utils.add(jsonString); return "200"; } }