TBxYDController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. package com.malk.poc.controller;
  2. /**
  3. * 错误抛出与拦截详见 CatchException
  4. */
  5. import com.alibaba.fastjson.JSON;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.malk.poc.service.AWClint;
  8. import com.malk.poc.service.AWYDClient;
  9. import com.malk.delegate.McDelegate;
  10. import com.malk.server.aliwork.YDConf;
  11. import com.malk.server.aliwork.YDParam;
  12. import com.malk.server.common.McException;
  13. import com.malk.server.common.McR;
  14. import com.malk.server.dingtalk.DDConf;
  15. import com.malk.server.teambition.TBConf;
  16. import com.malk.service.aliwork.YDClient;
  17. import com.malk.service.aliwork.YDService;
  18. import com.malk.service.teambition.TBClient;
  19. import com.malk.utils.UtilExcel;
  20. import com.malk.utils.UtilMap;
  21. import com.malk.utils.UtilServlet;
  22. import lombok.extern.slf4j.Slf4j;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.*;
  25. import javax.servlet.http.HttpServletRequest;
  26. import javax.servlet.http.HttpServletResponse;
  27. import java.util.*;
  28. @Slf4j
  29. @RestController
  30. @RequestMapping
  31. public class TBxYDController {
  32. @Autowired
  33. private AWClint awClint;
  34. /**
  35. * 交付物审批回调
  36. */
  37. @PostMapping("approved")
  38. McR approve(HttpServletRequest request) {
  39. Map<String, ?> data = UtilServlet.getParamMap(request);
  40. log.info("交付物审批回调, {}", data);
  41. McException.assertParamException_Null(data, "projectId, taskId, creatorId, approve");
  42. awClint.approved(data);
  43. return McR.success();
  44. }
  45. /**
  46. * 检查项check回调
  47. */
  48. @PostMapping("checked")
  49. McR check(HttpServletRequest request) {
  50. Map<String, ?> data = UtilServlet.getParamMap(request);
  51. log.info("检查项check回调, {}", data);
  52. McException.assertParamException_Null(data, "taskId, formInstId");
  53. awClint.checked(data);
  54. return McR.success();
  55. }
  56. /**
  57. * 选项卡渲染获取详情
  58. */
  59. @PostMapping("load-check")
  60. public Map details(String taskId) {
  61. log.info("选项卡渲染, {}", taskId);
  62. String result = UtilMap.getString(awClint.doCheck(taskId, true), "result");
  63. String strJson = "{\"version\":\"1.0.0\",\"template\":{\"status\":\"#variables.status#\",\"toolbar\":[{\"label\":\"成功\",\"type\":\"text\",\"visible\":\"#variables.isDetailVisible#\",\"payload\":\"#variables.detailURL#\"}]},\"data\":[{\"itemId\":\"61b80257e1fe2200410c8ecd\",\"avatarUrl\":\"\",\"title\":\"xxxxx\",\"description\":\"\"}],\"variables\":{\"userId\":\"5bdc085d60bcef000146634f\",\"taskId\":\"\",\"status\":\"\",\"primaryLabel\":\"详情\",\"itemURL\":\"\",\"detailURL\":\"\",\"createURL\":\"\",\"createPlanTimeLabel\":\"\",\"createPlanTimeURL\":\"\",\"editURL\":\"\",\"removeURL\":\"\",\"isItemVisible\":true,\"isDetailVisible\":true,\"isCreatePlanTimeVisible\":true,\"isPrimaryVisible\":true,\"isEditVisible\":true,\"isRemoveVisible\":true}}";
  64. strJson = strJson.replace("xxxxx", result);
  65. return (Map) JSON.parse(strJson);
  66. }
  67. /**
  68. * 自定义审批字段模板渲染
  69. */
  70. @GetMapping("field-template")
  71. public List<Map> template(String nonce, long timestamp, String appId, String sign, String organizationId, String projectId) {
  72. log.info("自定义审批字段模板渲染, {}, {}, {}, {}, {}, {}", nonce, new Date(timestamp), appId, sign, organizationId, projectId);
  73. List<Map> templateIds = new ArrayList<>();
  74. templateIds.add(UtilMap.map("id, title, payload", "FORM-FBC1A390B4C348089020C763938A6F54RUNY", "交付物审批", UtilMap.map("templateId", "FORM-FBC1A390B4C348089020C763938A6F54RUNY")));
  75. templateIds.add(UtilMap.map("id, title, payload", "FORM-F6B54810EBA84F7AA9AC82EE1D8AE4D3GPKR", "预检项确认", UtilMap.map("templateId", "FORM-F6B54810EBA84F7AA9AC82EE1D8AE4D3GPKR")));
  76. return templateIds;
  77. }
  78. /**
  79. * 检查项发起
  80. */
  81. @PostMapping("do-check")
  82. McR doCheck(String taskId) {
  83. log.info("检查项发起, {}", taskId);
  84. return McR.success(awClint.doCheck(taskId, false));
  85. }
  86. /**
  87. * 交付物审批
  88. */
  89. @PostMapping("do-approve")
  90. McR doApprove(HttpServletRequest request) {
  91. Map<String, ?> data = UtilServlet.getParamMap(request);
  92. log.info("交付物审批, {}", data);
  93. Map formData = awClint.doApprove(data, UtilMap.getBoolean(data, "isChange"));
  94. return McR.success(formData);
  95. }
  96. /**
  97. * 交付物变更发起
  98. */
  99. @PostMapping("change-approve")
  100. McR changeApprove(HttpServletRequest request) {
  101. Map<String, ?> data = UtilServlet.getParamMap(request);
  102. log.info("交付物变更发起, {}", data);
  103. // prd 618 通过任务扩展按钮变更情况, 提交后再触发审批回写
  104. if (UtilMap.getBoolean(data, "isChange")) {
  105. awClint.changeApprove(UtilMap.getString(data, "taskId"), UtilMap.getString(data, "formInstId"), UtilMap.getString(data, "title"));
  106. }
  107. return McR.success();
  108. }
  109. /**
  110. * 通过模板创建项目
  111. */
  112. @PostMapping("project/create")
  113. McR createProject(@RequestBody JSONObject data) {
  114. // Map<String, ?> data = UtilServlet.getParamMap(request);
  115. log.info("通过模板创建项目, {}", data);
  116. McException.assertParamException_Null(data, "projectCode");
  117. String templateId = UtilMap.getString(data, "templateId");
  118. if (data.containsKey("manual")) {
  119. awClint.createProject(UtilMap.getString(data, "projectCode"), templateId);
  120. } else {
  121. // ppExt: 宜搭数据创建后, 以及客户系统同步到主数据有时间差, 做延迟代理 10s
  122. mcDelegate.setTimeout(() -> {
  123. awClint.createProject(UtilMap.getString(data, "projectCode"), templateId);
  124. }, 10000);
  125. }
  126. return McR.success();
  127. }
  128. /**
  129. * 分配项目角色
  130. */
  131. @PostMapping("project/role")
  132. McR updateRoleProject(@RequestBody JSONObject data) {
  133. // Map<String, ?> data = UtilServlet.getParamMap(request);
  134. log.info("分配项目角色, {}", data);
  135. McException.assertParamException_Null(data, "projectId", "trNode");
  136. List<String> trNodes = data.getJSONArray("trNode").toJavaList(String.class);
  137. awClint.updateProjectRole(UtilMap.getString(data, "projectId"), trNodes, UtilMap.getString(data, "production"), UtilMap.getString(data, "version"));
  138. return McR.success();
  139. }
  140. /**
  141. * 创建紧急任务
  142. */
  143. @PostMapping("task/create")
  144. McR createTaskForIpd(@RequestBody JSONObject data) {
  145. log.info("创建任务, {}", data);
  146. McException.assertParamException_Null(data, "formInstId");
  147. awClint.createTask(data.getString("formInstId"));
  148. return McR.success();
  149. }
  150. /**
  151. * 删除前后置依赖
  152. */
  153. @PostMapping("project/remove/dependencies")
  154. McR removeDependencies(HttpServletRequest request) {
  155. Map<String, ?> data = UtilServlet.getParamMap(request);
  156. log.info("删除前后置依赖, {}", data);
  157. McException.assertParamException_Null(data, "projectId", "trNode");
  158. awClint.removeDependencies(UtilMap.getString(data, "projectId"), (List<String>) JSON.parse(UtilMap.getString(data, "trNode")));
  159. return McR.success();
  160. }
  161. /**
  162. * 手动触发, 同步项目主数据
  163. */
  164. @PostMapping("project/sync")
  165. McR syncProject() {
  166. awClint.syncProject(null);
  167. return McR.success();
  168. }
  169. /**
  170. * 手动触发, 同步预检项
  171. */
  172. @PostMapping("check/sync")
  173. McR syncCheck(int type) {
  174. awClint.syncCheckList(type);
  175. return McR.success();
  176. }
  177. /**
  178. * 项目主数据增量更新
  179. */
  180. @PostMapping("project/update")
  181. McR updateProject(HttpServletRequest request) {
  182. Map<String, ?> data = UtilServlet.getParamMap(request);
  183. log.info("项目主数据增量更新, {}", data);
  184. // ppExt: 宜搭数据创建后, 以及客户系统同步到主数据有时间差, 做延迟代理 10s
  185. mcDelegate.setTimeout(() -> {
  186. // 多项目变更(项目成员变更) ppExt: 自动化通过公式获取子表字段,接口取不到。目前先通过传递实例ID,进行查询
  187. if (data.containsKey("formInstId")) {
  188. Map formData = ydClient.queryData(YDParam.builder()
  189. .formInstanceId(UtilMap.getString(data, "formInstId"))
  190. .build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
  191. for (Map row : (List<Map>) UtilMap.getList(formData, "tableField_lqovv8at")) {
  192. awClint.updateProject(UtilMap.getString(row, "textField_lqovv8ax"));
  193. }
  194. }
  195. // 单项目变更(项目号变更)
  196. if (data.containsKey("projectCode")) {
  197. awClint.updateProject(UtilMap.getString(data, "projectCode"));
  198. }
  199. }, 10000);
  200. return McR.success();
  201. }
  202. /**
  203. * 手动触发, 同步CRM基线数据
  204. */
  205. @PostMapping("crm/sync")
  206. McR syncCRM(HttpServletRequest request) {
  207. Map<String, ?> data = UtilServlet.getParamMap(request);
  208. log.info("同步CRM基线数据, {}", data);
  209. if (data.containsKey("projectId")) {
  210. awClint.syncBaseLineForCRM(UtilMap.getString(data, "projectId"));
  211. } else {
  212. awClint.syncBaseLineForCRM();
  213. }
  214. return McR.success();
  215. }
  216. /**
  217. * 手动触发, 批量修改项目角色
  218. */
  219. @PostMapping("batch/update")
  220. McR batchUpdate(HttpServletRequest request) {
  221. Map<String, ?> data = UtilServlet.getParamMap(request);
  222. log.info("批量修改项目角色, {}", data);
  223. McException.assertParamException_Null(data, "fieldName, preName, modifyName");
  224. String fieldName = UtilMap.getString(data, "fieldName");
  225. String preName = UtilMap.getString(data, "preName");
  226. String modifyName = UtilMap.getString(data, "modifyName");
  227. awClint.batchUpdate(fieldName, preName, modifyName, UtilMap.getString(data, "projectId"));
  228. return McR.success();
  229. }
  230. /// todo workspace/sync //手动触发, 知识库权限矩阵同步
  231. /**
  232. * 知识库版本管理
  233. */
  234. @PostMapping("approve/version")
  235. McR approveVersion(HttpServletRequest request) {
  236. Map<String, ?> data = UtilServlet.getParamMap(request);
  237. log.info("知识库版本管理, {}", data);
  238. McException.assertParamException_Null(data, "taskId", "pCode");
  239. awClint.approveVersion(UtilMap.getString(data, "taskId"), UtilMap.getString(data, "pCode"));
  240. return McR.success();
  241. }
  242. /**
  243. * 获取主数据产品列表
  244. */
  245. @GetMapping("product/list")
  246. Map getProductList(@RequestParam Map param) {
  247. String projectId = UtilMap.getString(param, "projectId");
  248. String q = UtilMap.getString(param, "q");
  249. List result = awClint.getProductList(projectId, q);
  250. return UtilMap.map("options", result);
  251. }
  252. /**
  253. * 获取主数据产品版本
  254. */
  255. @GetMapping("product/version")
  256. Map getProductVersionList(@RequestParam Map param) {
  257. String projectId = UtilMap.getString(param, "projectId");
  258. String q = UtilMap.getString(param, "q");
  259. String objectId = UtilMap.getString(param, "objectId");
  260. List result = awClint.getProductList(projectId, q, objectId);
  261. return UtilMap.map("options", result);
  262. }
  263. /**
  264. * 检查项导出, 全部检查项左关联已提交数据
  265. */
  266. @PostMapping("check-list/export")
  267. void exportCheckList(@RequestBody Map data, HttpServletResponse response) {
  268. log.info("检查项导出, {}", data);
  269. McException.assertParamException_Null(data, "pCode", "proType");
  270. List<Map> dataList = awClint.exportCheckList(UtilMap.getString(data, "pCode"), UtilMap.getString(data, "proType"));
  271. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, UtilMap.getString(data, "pCode") + " 技术检查项目", "templates_checked_list.xlsx");
  272. }
  273. /************************************* 宜搭结构化 *************************************/
  274. @Autowired
  275. private AWYDClient awydClient;
  276. /// 产品型号、产品版本、客户、专项需求 todo 非文本导出异常兼容, Can not find 'Converter' support class ArrayList.
  277. private void _multiSelectCompatibility(List<Map> dataList) {
  278. List<String> compIds = Arrays.asList("multiSelectField_lw678e43", "multiSelectField_m11u62on", "multiSelectField_m0afm8pc", "multiSelectField_lticsrqp");
  279. for (Map map : dataList) {
  280. for (String compId : compIds) {
  281. if (compId.startsWith("multiSelectField_")) {
  282. map.put(compId, String.join(",", UtilMap.getList(map, compId)));
  283. continue;
  284. }
  285. }
  286. }
  287. }
  288. /**
  289. * 项目需求子表导出
  290. */
  291. @PostMapping("pro-req/export")
  292. void exportProjectRequirements(@RequestBody Map data, HttpServletResponse response) {
  293. log.info("项目需求子表导出, {}", JSON.toJSONString(data));
  294. McException.assertParamException_Null(data, "dataList", "fileName");
  295. List<Map> dataList = UtilMap.getList(data, "dataList");
  296. this._multiSelectCompatibility(dataList);
  297. String fileName = UtilMap.getString(data, "fileName"); // 需求维护
  298. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_project_requirements.xlsx");
  299. }
  300. /**
  301. * 项目需求子表导入
  302. */
  303. @PostMapping("pro-req/import")
  304. McR importProjectRequirements(@RequestBody Map data, HttpServletResponse response) {
  305. log.info("项目需求子表导入, {}", JSON.toJSONString(data));
  306. McException.assertParamException_Null(data, "charter", "dataList", "fileName");
  307. Map result = awydClient.checkImportData_projectRequirements(UtilMap.getString(data, "charter"), UtilMap.getList(data, "dataList"), UtilMap.getBoolean(data, "isSubmit"));
  308. List<Map> dataList = UtilMap.getList(result, "dataList");
  309. if (UtilMap.getBoolean(result, "isSuccess")) {
  310. return McR.success(dataList);
  311. }
  312. this._multiSelectCompatibility(dataList);
  313. String fileName = UtilMap.getString(data, "fileName"); // 需求维护
  314. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_project_requirements_exception.xlsx");
  315. return McR.errorAccess("数据校验失败");
  316. }
  317. /**
  318. * 项目需求审批通过
  319. */
  320. @PostMapping("pro-req/approve")
  321. McR approveProjectRequirements(HttpServletRequest request) {
  322. Map<String, ?> data = UtilServlet.getParamMap(request);
  323. log.info("项目需求审批通过, {}", JSON.toJSONString(data));
  324. McException.assertParamException_Null(data, "pCode", "instanceId", "userId");
  325. awydClient.dealApprovedData_projectRequirements(UtilMap.getString(data, "pCode"), UtilMap.getString(data, "instanceId"), data);
  326. return McR.success();
  327. }
  328. /**
  329. * 覆盖项目需求档案需求列表 tmp
  330. */
  331. @Deprecated
  332. @PostMapping("pro-req/archive")
  333. McR archiveProjectRequirements(HttpServletRequest request) {
  334. Map<String, ?> data = UtilServlet.getParamMap(request);
  335. log.info("覆盖项目需求档案需求列表, {}", JSON.toJSONString(data));
  336. McException.assertParamException_Null(data, "pCode", "instanceId");
  337. awydClient.archiveProjectRequirements(UtilMap.getString(data, "pCode"), UtilMap.getString(data, "instanceId"));
  338. return McR.success();
  339. }
  340. /**
  341. * 项目规格子表导出
  342. */
  343. @PostMapping("pro-spec/export")
  344. void exportProjectSpecification(@RequestBody Map data, HttpServletResponse response) {
  345. log.info("项目规格子表导出, {}", JSON.toJSONString(data));
  346. McException.assertParamException_Null(data, "dataList", "fileName");
  347. List<Map> dataList = UtilMap.getList(data, "dataList");
  348. this._multiSelectCompatibility(dataList);
  349. String fileName = UtilMap.getString(data, "fileName"); // 规格维护
  350. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_project_specification.xlsx");
  351. }
  352. /**
  353. * 项目规格子表导入
  354. */
  355. @PostMapping("pro-spec/import")
  356. McR importProjectSpecification(@RequestBody Map data, HttpServletResponse response) {
  357. log.info("项目规格子表导入, {}", JSON.toJSONString(data));
  358. McException.assertParamException_Null(data, "charter", "dataList", "fileName", "prList");
  359. Map result = awydClient.checkImportData_projectSpecification(UtilMap.getString(data, "charter"), UtilMap.getList(data, "dataList"), UtilMap.getList(data, "prList"), UtilMap.getBoolean(data, "isSubmit"));
  360. List<Map> dataList = UtilMap.getList(result, "dataList");
  361. if (UtilMap.getBoolean(result, "isSuccess")) {
  362. return McR.success(dataList);
  363. }
  364. this._multiSelectCompatibility(dataList);
  365. String fileName = UtilMap.getString(data, "fileName"); // 需求维护
  366. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_project_specification_exception.xlsx");
  367. return McR.errorAccess("数据校验失败");
  368. }
  369. /**
  370. * 项目规格审批通过
  371. */
  372. @PostMapping("pro-spec/approve")
  373. McR approveProjectSpecification(HttpServletRequest request) {
  374. Map<String, ?> data = UtilServlet.getParamMap(request);
  375. log.info("项规格审批通过, {}", JSON.toJSONString(data));
  376. McException.assertParamException_Null(data, "instanceId");
  377. awydClient.dealApprovedData_projectSpecification(UtilMap.getString(data, "instanceId"), data);
  378. return McR.success();
  379. }
  380. /**
  381. * 测试规格子表导出
  382. */
  383. @PostMapping("test-spec/export")
  384. void exportTestSpecification(@RequestBody Map data, HttpServletResponse response) {
  385. log.info("测试规格子表导出, {}", JSON.toJSONString(data));
  386. McException.assertParamException_Null(data, "dataList", "fileName");
  387. List<Map> dataList = UtilMap.getList(data, "dataList");
  388. this._multiSelectCompatibility(dataList);
  389. String fileName = UtilMap.getString(data, "fileName"); // 测试规格维护
  390. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_test_specification.xlsx");
  391. }
  392. /**
  393. * 测试规格子表导入
  394. */
  395. @PostMapping("test-spec/import")
  396. McR importTESTSpecification(@RequestBody Map data, HttpServletResponse response) {
  397. log.info("测试规格子表导入, {}", JSON.toJSONString(data));
  398. McException.assertParamException_Null(data, "charter", "dataList", "fileName", "prList");
  399. Map result = awydClient.checkImportData_testSpecification(UtilMap.getString(data, "charter"), UtilMap.getList(data, "dataList"), UtilMap.getList(data, "prList"), UtilMap.getBoolean(data, "isSubmit"));
  400. List<Map> dataList = UtilMap.getList(result, "dataList");
  401. if (UtilMap.getBoolean(result, "isSuccess")) {
  402. return McR.success(dataList);
  403. }
  404. this._multiSelectCompatibility(dataList);
  405. String fileName = UtilMap.getString(data, "fileName"); // 需求维护
  406. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_test_specification_exception.xlsx");
  407. return McR.errorAccess("数据校验失败");
  408. }
  409. /**
  410. * 测试规格审批通过
  411. */
  412. @PostMapping("test-spec/approve")
  413. McR approveTestSpecification(HttpServletRequest request) {
  414. Map<String, ?> data = UtilServlet.getParamMap(request);
  415. log.info("测试格审批通过, {}", JSON.toJSONString(data));
  416. McException.assertParamException_Null(data, "instanceId");
  417. awydClient.dealApprovedData_testSpecification(UtilMap.getString(data, "instanceId"), data);
  418. return McR.success();
  419. }
  420. /**
  421. * 测规格需求书子表导出
  422. */
  423. @PostMapping("test-req/export")
  424. void exportTestRequirements(@RequestBody Map data, HttpServletResponse response) {
  425. log.info("项目需求子表导出, {}", JSON.toJSONString(data));
  426. McException.assertParamException_Null(data, "dataList", "fileName");
  427. List<Map> dataList = UtilMap.getList(data, "dataList");
  428. this._multiSelectCompatibility(dataList);
  429. String fileName = UtilMap.getString(data, "fileName"); // 需求维护
  430. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, "templates_project_requirements_test.xlsx");
  431. }
  432. /**
  433. * 提供verifier数据读取服务
  434. */
  435. @GetMapping("verifier/sync")
  436. McR syncVerifier(@RequestParam String projectCode, String productCode, String productVersion) {
  437. Map result = awydClient.syncVerifier(projectCode, productCode, productVersion);
  438. log.info("syncVerifier, {}, {}, {}", projectCode, productCode, productVersion);
  439. return McR.success(result);
  440. }
  441. /**
  442. * 提供verifier数据读取服务
  443. */
  444. @PostMapping("verifier/back")
  445. McR backVerifier(@RequestBody Map data) {
  446. log.info("backVerifier, {}", data);
  447. McException.assertParamException_Null(data, "code", "data");
  448. awydClient.backVerifier(data);
  449. return McR.success();
  450. }
  451. /**
  452. * 导出 [0909 作废版本1.0]
  453. */
  454. @PostMapping("export")
  455. void export(@RequestBody Map data, HttpServletResponse response) {
  456. List<Map> dataList = UtilMap.getList(data, "dataList");
  457. String fileName = UtilMap.getString(data, "fileName");
  458. String tempFileName = UtilMap.getString(data, "tempFileName");
  459. UtilExcel.exportMapAndListByTemplate(response, dataList, Map.class, fileName, tempFileName);
  460. }
  461. /**
  462. * 导入前处理 [0909 作废版本1.0]
  463. */
  464. @PostMapping("beforeImportData")
  465. McR beforeImportData(@RequestBody Map data, HttpServletResponse response) {
  466. Map result = awydClient.checkImportData(data);
  467. Boolean flag = UtilMap.getBoolean(result, "flag");
  468. List<Map> resultData = UtilMap.getList(result, "data");
  469. if (flag) {
  470. return McR.success(resultData);
  471. } else {
  472. String fileName = "异常";
  473. String tempFileName = "templates_xqwh_result.xlsx";
  474. UtilExcel.exportMapAndListByTemplate(response, resultData, Map.class, fileName, tempFileName);
  475. return null;
  476. }
  477. }
  478. //////// test ////////
  479. @Autowired
  480. private TBClient tbClient;
  481. @Autowired
  482. private TBConf tbConf;
  483. @Autowired
  484. private DDConf ddConf;
  485. @GetMapping("t/task")
  486. McR task(String taskId) {
  487. log.info("taskId, {}", taskId);
  488. List<Map> tList = tbClient.queryTaskDetail(taskId, "", "");
  489. return McR.success(tList);
  490. }
  491. @GetMapping("t/template")
  492. McR template(String name) {
  493. List<Map> tList = tbClient.templateSearch(null, name);
  494. return McR.success(tList);
  495. }
  496. @Autowired
  497. private YDClient ydClient;
  498. @Autowired
  499. private YDService ydService;
  500. @Autowired
  501. private McDelegate mcDelegate;
  502. @GetMapping("test")
  503. McR test(HttpServletRequest request) {
  504. Map<String, ?> data = UtilServlet.getParamMap(request);
  505. log.info("test, {}", data);
  506. // awClint.taskLevelValidate(UtilMap.map("projectId, taskId", "659376ba950780b816c33d3b, 66116073ea68df0235b30bef"));
  507. // try {
  508. // Map body = TBConf.assembleCustomFieldName(AWServer.TASK_TRANSMIT, "已下达");
  509. // tbClient.updateTaskCustomField("659a681d44ade3345fdc0d39", tbConf.getOperatorId(), body);
  510. // } catch (McException e) {
  511. // log.error(e.getMessage(), e);
  512. // }
  513. awClint.test();
  514. // awydClient.test();
  515. // ydClient.operateData(YDParam.builder()
  516. // .formInstanceId("9d204da7-b01e-4bd9-a673-acb9b64b0e61")
  517. // .updateFormDataJson(JSON.toJSONString(UtilMap.map("radioField_lu9yf7vg", "否")))
  518. // .useLatestVersion(true)
  519. // .build(), YDConf.FORM_OPERATION.update);
  520. return McR.success();
  521. }
  522. @GetMapping("tmp")
  523. McR tmp(String programIds) {
  524. // awClint.tmp();
  525. // List<String> tags = tbClient.queryProjectTag("66c763a2a86f837e07c418e9", tbConf.getOperatorId());
  526. // tags.add("111");
  527. return McR.success();
  528. }
  529. }