|
|
@@ -0,0 +1,111 @@
|
|
|
+package com.malk.suodisi.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.common.McException;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import com.malk.server.dingtalk.DDConf;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.suodisi.server.XYR;
|
|
|
+import com.malk.utils.UtilDateTime;
|
|
|
+import com.malk.utils.UtilHttp;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
+import com.malk.utils.UtilServlet;
|
|
|
+import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
+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.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 错误抛出与拦截详见 CatchException
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/xy")
|
|
|
+public class XYController {
|
|
|
+
|
|
|
+ final static String XY_sys = "XYDING";
|
|
|
+ final static String XY_secure = "51d7cbff-806f-4bc9-aca8-7a26fdd6327c";
|
|
|
+
|
|
|
+ private static Map<Integer, String> DD_category = new HashMap<>();
|
|
|
+
|
|
|
+ static {
|
|
|
+ DD_category.put(0, "钉钉,宜搭");
|
|
|
+ DD_category.put(1, "钉钉,待办");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getXyUrl(String path) {
|
|
|
+ return "https://xyapiuat.xiangyu.cn/xmxyg/todo/epi" + path;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建象屿统一待办
|
|
|
+ * - prd
|
|
|
+ * 1. 待办创建, 更新均需要传递全部参数 (目前仅会校验审批时间不能小于历史数据)
|
|
|
+ * 2. 接收人存在多人时, 统一待办会自动拆分为多个 (待办中心以 业务单据号 + 用户域账号)
|
|
|
+ *
|
|
|
+ * @param category 待办分类
|
|
|
+ * @param optType 操作类型:1待办、2已办、3待阅
|
|
|
+ * @param busNo 业务单据号
|
|
|
+ * @param title 待办标题
|
|
|
+ * @param currentStatus 待办进度
|
|
|
+ * @param pcUrl 待办PC端地址
|
|
|
+ * @param appUrl 待办移动端地址
|
|
|
+ * @param createDateTime 创建时间
|
|
|
+ * @param creator 创建人域账号(钉钉工号)
|
|
|
+ * @param creatorName 创建人姓名
|
|
|
+ * @param receivers 接收人姓名
|
|
|
+ * @param receiverNames 接收人域账号(钉钉工号)
|
|
|
+ * @param keywords 关键字字段
|
|
|
+ */
|
|
|
+ private void syncXyTodo(String category, int optType, String busNo, String title, String currentStatus, String pcUrl, String appUrl,
|
|
|
+ String createDateTime, String creator, String creatorName, String receivers, String receiverNames, List<String> keywords) {
|
|
|
+
|
|
|
+ Map body = UtilMap.map("sysCode, secureCode, busType, optType, isSupportBatch, receiveDateTime", XY_sys, XY_secure, category, optType, false, UtilDateTime.formatDateTime(new Date()));
|
|
|
+ body.putAll(UtilMap.map("busNo, title, currentStatus, pcUrl, appUrl, createDateTime", busNo, title, currentStatus, pcUrl, appUrl, createDateTime));
|
|
|
+ body.putAll(UtilMap.map("creator, creatorName, receivers, receiverNames, keywords", creator, creatorName, receivers, receiverNames, keywords));
|
|
|
+
|
|
|
+ XYR r = (XYR) UtilHttp.doPost(getXyUrl("/push"), null, body, XYR.class);
|
|
|
+
|
|
|
+ log.info("创建统一待办, {}", r);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 宜搭待办
|
|
|
+ */
|
|
|
+ @PostMapping("/sync")
|
|
|
+ McR sdsUpdate(HttpServletRequest request) {
|
|
|
+
|
|
|
+ Map data = UtilServlet.getParamMap(request);
|
|
|
+ log.info("宜搭待办, {}", JSON.toJSONString(data));
|
|
|
+ int optType = UtilMap.getInt(data, "optType");
|
|
|
+ String busNo = UtilMap.getString(data, "busNo");
|
|
|
+ String title = UtilMap.getString(data, "title");
|
|
|
+ String currentStatus = UtilMap.getString(data, "currentStatus");
|
|
|
+ String pcUrl = UtilMap.getString(data, "pcUrl");
|
|
|
+ String appUrl = UtilMap.getString(data, "appUrl");
|
|
|
+ String createDateTime = UtilDateTime.formatDateTime(new Date(UtilMap.getLong(data, "createDateTime")));
|
|
|
+ String creator = UtilMap.getString(data, "creator");
|
|
|
+ String creatorName = UtilMap.getString(data, "creatorName");
|
|
|
+ String receivers = UtilMap.getString(data, "receivers");
|
|
|
+ String receiverNames = UtilMap.getString(data, "receiverNames");
|
|
|
+ String keywords = UtilMap.getString(data, "keywords");
|
|
|
+
|
|
|
+ syncXyTodo(DD_category.get(0), optType, busNo, title, currentStatus, pcUrl, appUrl, createDateTime,creator , creatorName,receivers, receiverNames, Arrays.asList(keywords));
|
|
|
+
|
|
|
+ // Todo 查询宜搭审批记录, 完成回调, 完成更新
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|