IVController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. package com.malk.guyuan.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.malk.guyuan.server.model.McInvoiceDto;
  4. import com.malk.guyuan.server.model.McInvoiceKind;
  5. import com.malk.guyuan.server.tencent.TXYConf;
  6. import com.malk.guyuan.service.tencent.TXYInvoice;
  7. import com.malk.server.aliwork.YDConf;
  8. import com.malk.server.aliwork.YDParam;
  9. import com.malk.server.common.FilePath;
  10. import com.malk.server.common.McException;
  11. import com.malk.server.common.McR;
  12. import com.malk.service.aliwork.YDClient;
  13. import com.malk.service.aliwork.YDService;
  14. import com.malk.utils.*;
  15. import com.spire.pdf.PdfCompressionLevel;
  16. import com.spire.pdf.PdfDocument;
  17. import com.spire.pdf.PdfPageBase;
  18. import com.spire.pdf.exporting.PdfImageInfo;
  19. import com.spire.pdf.graphics.PdfBitmap;
  20. import com.tencentcloudapi.common.exception.TencentCloudSDKException;
  21. import lombok.SneakyThrows;
  22. import lombok.extern.slf4j.Slf4j;
  23. import net.coobird.thumbnailator.Thumbnails;
  24. import org.apache.commons.lang3.StringUtils;
  25. import org.apache.poi.util.IOUtils;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.bind.annotation.PostMapping;
  28. import org.springframework.web.bind.annotation.RequestBody;
  29. import org.springframework.web.bind.annotation.RequestMapping;
  30. import org.springframework.web.bind.annotation.RestController;
  31. import javax.servlet.http.HttpServletRequest;
  32. import java.io.ByteArrayInputStream;
  33. import java.io.ByteArrayOutputStream;
  34. import java.io.File;
  35. import java.io.InputStream;
  36. import java.net.URL;
  37. import java.util.*;
  38. import java.util.stream.Collectors;
  39. /**
  40. * 错误抛出与拦截详见CatchException
  41. */
  42. @Slf4j
  43. @RestController
  44. @RequestMapping
  45. public class IVController {
  46. @Autowired
  47. private TXYInvoice txyInvoice;
  48. @Autowired
  49. private YDClient ydClient;
  50. /// 优先获取字段, 新版本接口已支持字段返回
  51. private String findValue(List<Map<String, String>> infos, String... names) {
  52. for (String name : names) {
  53. Optional optional = infos.stream().filter(info -> info.get("Name").equals(name)).findAny();
  54. if (optional.isPresent()) {
  55. return String.valueOf(((Map) optional.get()).get("Value"));
  56. }
  57. }
  58. return "";
  59. }
  60. // 兼容历史配置, 格式 (谷元)
  61. private String guyuanNameRepalce(String name) {
  62. if (name.contains("谷元")) {
  63. return UtilString.replaceBracketIsWhole(name);
  64. } else {
  65. return UtilString.replaceBracketIsSemiangle(name);
  66. }
  67. }
  68. /// url压缩转base64
  69. @SneakyThrows
  70. private String imageUrlConvertBase64(String imageUrl) {
  71. ByteArrayOutputStream out = new ByteArrayOutputStream();
  72. // scale(比例), outputQuality(质量)
  73. Thumbnails.fromURLs(Arrays.asList(new URL(imageUrl))).scale(0.5f).outputQuality(0.25f).toOutputStream(out);
  74. InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
  75. //转换为base64
  76. byte[] bytes = IOUtils.toByteArray(inputStream);
  77. return Base64.getEncoder().encodeToString(bytes);
  78. }
  79. @Autowired
  80. private FilePath filePath;
  81. /// PDF压缩转base64
  82. @SneakyThrows
  83. private String pdfUrlConvertBase64(String pdfUrl) {
  84. String fileName = "tmp_" + new Date().getTime() + ".pdf";
  85. // 下载文件
  86. File file = UtilFile.mkdirIfNot(fileName, filePath.getPath().getTmp());
  87. UtilHttp.doDownload(pdfUrl, file);
  88. // PDF压缩
  89. PdfDocument doc = new PdfDocument(); // 创建PdfDocument类的对象
  90. doc.loadFromFile(file.getAbsolutePath()); // 加载PDF文档
  91. doc.getFileInfo().setIncrementalUpdate(false); // 禁用增量更新
  92. doc.setCompressionLevel(PdfCompressionLevel.Normal); // 将压缩级别设置为最佳
  93. // 遍历文档页面
  94. for (int i = 0; i < doc.getPages().getCount(); i++) {
  95. PdfPageBase page = doc.getPages().get(i); // 获取指定页面
  96. PdfImageInfo[] images = page.getImagesInfo(); // 获取每个页面的图像信息集合
  97. // 遍历集合中的所有项目
  98. if (images != null && images.length > 0)
  99. for (int j = 0; j < images.length; j++) {
  100. PdfImageInfo image = images[j]; // 获取指定图片
  101. PdfBitmap bp = new PdfBitmap(image.getImage());
  102. bp.setQuality(30); // 设置压缩质量
  103. page.replaceImage(j, bp); // 将原始图像替换为压缩图像
  104. }
  105. }
  106. // 将结果文档保存至另一个PDF文档中: 覆盖
  107. doc.saveToFile(file.getAbsolutePath());
  108. doc.close();
  109. // PDF转base64, 无需透出本地文件地址
  110. String base64 = UtilFile.fileToBase64(file.getAbsolutePath());
  111. // 删除临时PDF文件
  112. UtilFile.deleteFile(file.getAbsolutePath());
  113. return base64;
  114. }
  115. // prd 校验发票抬头, 购买方范围
  116. private void validateBuyer(String BuyerName, String tips) {
  117. List<String> corpNames = Arrays.asList(
  118. "谷元(上海)文化科技有限责任公司",
  119. "上海爱鱼文化传媒有限公司",
  120. "上海渔米可禧文化传媒有限公司",
  121. "上海巧豆文化传媒有限公司",
  122. "钰鸿文化创意(上海)有限公司",
  123. "上海攸元文化科技有限公司",
  124. "上海盈田演出经纪有限公司",
  125. "上海小蝠文化科技有限公司",
  126. "沐田居海(厦门)文化传媒有限公司",
  127. "北京元环文化科技有限责任公司",
  128. "厦门攸元文化科技有限公司",
  129. "厦门亨有文化科技有限公司",
  130. "厦门银雀思汀文化传媒有限公司",
  131. "上海渝泽信息科技有限公司",
  132. "厦门神谷飞流影视传媒有限公司",
  133. "厦门谷钛数字科技有限公司",
  134. "上海观情科技有限公司",
  135. "渔米可禧文化传媒(香港)有限公司");
  136. McException.assertAccessException(!corpNames.contains(BuyerName), tips + ", 购买方名称不合法!");
  137. }
  138. /**
  139. * 混票识别 [新版本]
  140. */
  141. @PostMapping("invoice-iv2")
  142. McR invoice_iv2(@RequestBody Map<String, String> data) throws TencentCloudSDKException {
  143. McException.assertParamException_Null(data, "url");
  144. String image = ydClient.convertTemporaryUrl(data.get("url"));
  145. log.info("混票识别, 免登地址, {}", image);
  146. // 非PDF, 且内存大于3M, 压缩后上传
  147. if (UtilMap.getFloat(data, "size") > 3.0f && !UtilMap.getBoolean(data, "isPdf")) {
  148. image = imageUrlConvertBase64(image);
  149. }
  150. if (UtilMap.getFloat(data, "size") > 6.0f && UtilMap.getBoolean(data, "isPdf")) {
  151. image = pdfUrlConvertBase64(image);
  152. }
  153. List<Map> invoices = (List<Map>) txyInvoice.doRecognizeGeneralInvoice(image).get("MixedInvoiceItems");
  154. List<McInvoiceDto> result = invoices.stream().map(item -> {
  155. Map prop = UtilMap.getMap(UtilMap.getMap(item, "SingleInvoiceInfos"), UtilMap.getString(item, "SubType"));
  156. // ppExt: 通用字段定义
  157. McInvoiceDto invoiceDto = McInvoiceDto.builder()
  158. .name(UtilMap.getString(item, "SubTypeDescription"))
  159. .kindName(UtilMap.getString(item, "TypeDescription"))
  160. .kind(UtilMap.getInt(item, "Type"))
  161. .code(UtilMap.getString(prop, "Code"))
  162. .serial(UtilMap.getString(prop, "Number"))
  163. .date(UtilString.replaceDateZH_cn(UtilMap.getString(prop, "Date")))
  164. .checkCode(UtilMap.getString(prop, "CheckCode"))
  165. // ppExt: 多明细行时, 优先取值合计 [全电票返回了subTotal字段, 但值为空]
  166. .amount(UtilNumber.setBigDecimal(UtilMap.getString_first(prop, "SubTotal", "Total")))
  167. .tax(UtilNumber.setBigDecimal(UtilMap.getString_first(prop, "SubTax", "Tax")))
  168. .excludingTax(UtilNumber.setBigDecimal(UtilMap.getString(prop, "PretaxAmount")))
  169. .buyerName(guyuanNameRepalce(UtilMap.getString(prop, "Buyer")))
  170. // ppExt: 中央非税未返回税号官方说明: 非税发票理论是没有税号的,图片中属于信用代码
  171. .buyerTaxId(UtilMap.getString(prop, "BuyerTaxID"))
  172. .sellerName(guyuanNameRepalce(UtilMap.getString_first(prop, "Seller", "Issuer"))) // 行程单: 填开单位
  173. .sellerTaxId(UtilMap.getString_first(prop, "SellerTaxID", "AgentCode")) // 行程单: 销售单位代号
  174. .passengerName(UtilMap.getString_first(prop, "Name", "UserName")) // 火车票, 行程单
  175. // 交通出行
  176. .seatType(UtilMap.getString(prop, "Seat"))
  177. .departureTime(UtilString.replaceDateZH_cn(UtilMap.getString(prop, "DateGetOn")) + " " + UtilMap.getString(prop, "TimeGetOn"))
  178. .departurePort(UtilMap.getString_first(prop, "StationGetOn", "Entrance", "Place")) // 火车票: 出发车站, 过路过桥费: 入口, 出租车: 发票所在地
  179. .arrivePort(UtilMap.getString_first(prop, "StationGetOff", "Exit")) // 行程单, 火车票: 到达车站, 过路过桥费: 出口
  180. .trainNo(UtilMap.getString_first(prop, "TrainNumber", "LicensePlate")) // 火车票: 车次, 出租车: 车牌号
  181. .insuranceCosts(UtilNumber.setBigDecimal((UtilMap.getString(prop, "Insurance")))) // 行程单: 保险费
  182. .fuelCosts(UtilNumber.setBigDecimal((UtilMap.getString(prop, "FuelSurcharge")))) // 行程单: 燃油附加费
  183. .constructionCosts(UtilNumber.setBigDecimal((UtilMap.getString(prop, "AirDevelopmentFund")))) // 行程单: 民航发展基金
  184. .build();
  185. // ppExt: 机票行程单, 行程与座位信息在明细内
  186. if ("机票行程单".equals(item.get("TypeDescription"))) {
  187. Map flight = (Map) UtilMap.getList(prop, "FlightItems").get(0);
  188. invoiceDto.setDepartureTime(UtilString.replaceDateZH_cn(UtilMap.getString(item, "DateGetOn")) + " " + UtilMap.getString(prop, "TimeGetOn"));
  189. invoiceDto.setDeparturePort(UtilMap.getString(flight, "StationGetOn"));
  190. invoiceDto.setArrivePort(UtilMap.getString(flight, "StationGetOff"));
  191. invoiceDto.setSeatType(UtilMap.getString(flight, "Seat"));
  192. }
  193. if ("出租车发票".equals(item.get("TypeDescription"))) {
  194. // 上下车时间
  195. invoiceDto.setDepartureTime(UtilMap.getString(prop, "TimeGetOn") + " ~ " + UtilMap.getString(prop, "TimeGetOff"));
  196. }
  197. return invoiceDto;
  198. }).collect(Collectors.toList());
  199. return McR.success(McInvoiceDto.formatResponse(result));
  200. }
  201. /**
  202. * 混票识别 [旧版本, 已废弃]
  203. */
  204. @PostMapping("invoice-iv")
  205. McR invoice_iv(@RequestBody Map<String, String> data) throws TencentCloudSDKException {
  206. McException.assertParamException_Null(data, "url");
  207. String image = ydClient.convertTemporaryUrl(data.get("url"));
  208. log.info("混票识别, 免登地址, {}", image);
  209. // 非PDF, 且内存大于3M, 压缩后上传
  210. if (UtilMap.getFloat(data, "size") > 3.0f && !UtilMap.getBoolean(data, "isPdf")) {
  211. image = imageUrlConvertBase64(image);
  212. }
  213. if (UtilMap.getFloat(data, "size") > 6.0f && UtilMap.getBoolean(data, "isPdf")) {
  214. image = pdfUrlConvertBase64(image);
  215. }
  216. // ppExt: 通用字段定义
  217. List<Map> invoices = (List<Map>) txyInvoice.doMixedInvoiceOCR(image).get("MixedInvoiceItems");
  218. List<McInvoiceDto> result = invoices.stream().map(item -> {
  219. String kind = TXYConf.TYPE_INVOICE.get(item.get("Type").toString());
  220. List<Map<String, String>> infos = (List<Map<String, String>>) item.get("SingleInvoiceInfos");
  221. McInvoiceDto.assertSuccess(item, kind); // 响应断言
  222. String invoiceName = findValue(infos, "发票名称");
  223. if (kind.equals("全电发票")) {
  224. kind = invoiceName.contains("增值税专用发票") ? "全电专用发票" : "全电普通发票";
  225. }
  226. if (kind.equals("增值税发票")) {
  227. kind = invoiceName.contains("增值税专用发票") ? "增值税专用发票" : "增值税普通发票";
  228. if (invoiceName.contains("增值税电子")) {
  229. kind = invoiceName.contains("专用发票") ? "增值税电子专用发票" : "增值税电子普通发票";
  230. }
  231. }
  232. McInvoiceDto invoiceDto = McInvoiceDto.builder()
  233. .name(invoiceName)
  234. .kindName(kind)
  235. .kind(McInvoiceKind.getKindCode(kind))
  236. .code(findValue(infos, "发票代码", "票据代码")) // 发票, 非税发票
  237. // 储存唯一ID [发票, 火车票, 行程单]
  238. .serial(findValue(infos, "发票号码", "编号", "电子客票号码", "票据号码").replace("No", "")) // 发票, 非税发票
  239. .date(findValue(infos, "开票日期").replace("年", "-").replace("月", "-").replace("日", ""))
  240. .checkCode(findValue(infos, "校验码"))
  241. .amount(UtilNumber.replaceCurrencyCHYToDecimal(findValue(infos, "小写金额", "价税合计(小写)", "合计金额", "票价", "金额"))) // 发票, 全电票, 行程单, 火车票, 过路过桥费
  242. .excludingTax(UtilNumber.replaceCurrencyCHYToDecimal(findValue(infos, "合计金额", "金额", "票价", "小写金额"))) // [ppExt: 多明细行时, 优先取值合计] 行程单, 火车票, 定额发票
  243. .tax(UtilNumber.replaceCurrencyCHYToDecimal(findValue(infos, "合计税额"))) // 增值税发票
  244. .buyerName(guyuanNameRepalce(findValue(infos, "购买方名称", "交款人"))) // 发票, 非税发票
  245. .buyerTaxId(findValue(infos, "购买方识别号", "购买方统一社会信用代码/纳税人识别号", "交款人统一社会信用代码")) // 发票, 全电票, 非税发票
  246. .sellerName(guyuanNameRepalce(findValue(infos, "销售方名称", "填开单位"))) // 行程单
  247. .sellerTaxId(findValue(infos, "销售方识别号", "销售方统一社会信用代码/纳税人识别号", "销售单位代号")) // 发票, 全电票, 行程单
  248. .passengerName(findValue(infos, "旅客姓名", "姓名")) // 行程单, 火车票
  249. .seatType(findValue(infos, "座位等级", "席别")) // 行程单, 火车票
  250. .departurePort(findValue(infos, "始发地", "出发站", "入口")) // 行程单, 火车票, 过路过桥费
  251. .arrivePort(findValue(infos, "目的地", "到达站", "出口")) // 行程单, 火车票, 过路过桥费
  252. .trainNo(findValue(infos, "航班号", "车次", "车牌号")) // 行程单, 火车票, 出租车
  253. .insuranceCosts(UtilNumber.setBigDecimal((findValue(infos, "保险费")))) // 行程单
  254. .fuelCosts(UtilNumber.setBigDecimal((findValue(infos, "燃油附加费")))) // 行程单
  255. .constructionCosts(UtilNumber.setBigDecimal((findValue(infos, "民航发展基金")))) // 行程单
  256. .build();
  257. // 价格不一致情况下, 通过合计返回
  258. if (!UtilNumber.equalBigDecimal(invoiceDto.getAmount(), invoiceDto.getExcludingTax().add(invoiceDto.getTax()))) {
  259. invoiceDto.setAmount(invoiceDto.getExcludingTax().add(invoiceDto.getTax()));
  260. }
  261. // 机票行程单
  262. if (kind.equals(McInvoiceKind.JP.getDesc())) {
  263. String date = findValue(infos, "日期").replace("年", "-").replace("月", "-").replace("日", " ");
  264. invoiceDto.setDepartureTime(date + " " + findValue(infos, "时间"));
  265. }
  266. // 火车票
  267. if (kind.equals(McInvoiceKind.HC.getDesc())) {
  268. invoiceDto.setDepartureTime(findValue(infos, "出发时间").replace("年", "-").replace("月", "-").replace("日", " "));
  269. }
  270. // 出租车
  271. if (kind.equals(McInvoiceKind.CZC.getDesc())) {
  272. String date = findValue(infos, "日期").replace("年", "-").replace("月", "-").replace("日", " ");
  273. invoiceDto.setDepartureTime(date + " " + findValue(infos, "上车"));
  274. }
  275. return invoiceDto;
  276. }).collect(Collectors.toList());
  277. return McR.success(McInvoiceDto.formatResponse(result));
  278. }
  279. /**
  280. * 发票查重, 验真
  281. */
  282. @PostMapping("invoice-va")
  283. McR invoice_va(@RequestBody Map data) {
  284. McException.assertParamException_Null(data, "param");
  285. List<McInvoiceDto> invoices = JSON.parseArray(JSON.toJSONString(data.get("param")), McInvoiceDto.class);
  286. log.info("发票查重, 验真, {}", invoices);
  287. invoices.forEach(UtilMc.consumerWithIndex((item, index) -> {
  288. McInvoiceDto dto = (McInvoiceDto) item;
  289. String invoiceNo = dto.getSerial(); // 唯一标识, 发票号码
  290. String serial = "第【" + (index + 1) + "】张发票";
  291. validateBuyer(dto.getBuyerName(), serial + "有疑问");
  292. McException.assertAccessException(StringUtils.isBlank(invoiceNo), serial + ", 识别结果为空, 请检查!");
  293. YDParam ydParam = YDParam.builder()
  294. .formUuid("FORM-W2A66Z910O9B3LP9C6IYUDPRVWY62DO0YHIILY")
  295. .searchFieldJson(JSON.toJSONString(UtilMap.map("radioField_liihyrtb, textField_liihyrt8", "否", invoiceNo)))
  296. .build();
  297. List<String> idList = (List<String>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form_id).getData();
  298. if (idList.size() > 0) {
  299. McException.exceptionAccess(serial + "已存在, 请勿重复提交!");
  300. }
  301. // prd 仅仅识别增值税普通发票
  302. if (dto.getName().contains("普通发票")) {
  303. String serialTips = serial + "有疑问";
  304. try {
  305. // ppExt: 识别与验真后抬头对比
  306. Map rsp = txyInvoice.doVatInvoiceVerifyNew(dto.getName(), dto.getCode(), invoiceNo, dto.getDate(), String.valueOf(dto.getAmount()), dto.getCheckCode(), String.valueOf(dto.getExcludingTax()), serialTips);
  307. Map invoice = (Map) rsp.get("Invoice");
  308. McException.assertAccessException(!dto.getBuyerName().equals(guyuanNameRepalce(invoice.get("BuyerName").toString())), serialTips + ", 购买方名称不匹配!");
  309. McException.assertAccessException(!dto.getBuyerTaxId().equals(invoice.get("BuyerTaxCode")), serialTips + ", 购买方税号不匹配!");
  310. McException.assertAccessException(!dto.getSellerName().equals(guyuanNameRepalce(invoice.get("SellerName").toString())), serialTips + ", 销售方名称不匹配!");
  311. McException.assertAccessException(!dto.getSellerTaxId().equals(invoice.get("SellerTaxCode")), serialTips + ", 销售方税号不匹配!");
  312. } catch (TencentCloudSDKException e) {
  313. log.error(e.getMessage(), e);
  314. // prd: 上传发票为假发票时,提示:该发票有疑问,请联系财务人员
  315. String message = e.getMessage();
  316. // ppExt: 已经是新版本接口, 过滤提示
  317. if (message.contains("温馨提示")) {
  318. message = message.split("温馨提示")[0];
  319. }
  320. if (message.contains("发票不存在")) {
  321. message = "有疑问,请联系财务人员";
  322. }
  323. McException.exceptionAccess(serial + message);
  324. }
  325. }
  326. }));
  327. return McR.success();
  328. }
  329. @Autowired
  330. private YDService ydService;
  331. /**
  332. * 发票状态更新: 服务注册
  333. */
  334. @PostMapping("invoice-up")
  335. McR invoice_va(HttpServletRequest request) {
  336. Map data = UtilServlet.getParamMap(request);
  337. log.info("发票状态更新: 服务注册, {}", data);
  338. String compId = UtilMap.getString(data, "compId");
  339. String status = UtilMap.getString(data, "status");
  340. // 读取关联表单
  341. List<String> associationForm = (List<String>) JSON.parse(UtilMap.getString(data, "multiAssociation"));
  342. List<String> formInstanceIds = new ArrayList<>();
  343. for (String record : associationForm) {
  344. // 解析关联表单
  345. List<Map> associationData = (List<Map>) JSON.parse(record);
  346. formInstanceIds.addAll(associationData.stream().map(form -> UtilMap.getString(form, "instanceId")).collect(Collectors.toList()));
  347. }
  348. // 宜搭批量更新
  349. Map update = UtilMap.map(compId, status);
  350. if (compId.equals("selectField_liihyrt6")) {
  351. update.put("radioField_liw7rb2q", "否"); // 提交后, 更新是否退回标识为否
  352. }
  353. // prd 9.10 更新报销单, 关联到发票:: ppExt 宜搭服务注册, 提交规则系统默认字段 [详见 YDService]
  354. ydService.operateData2(data, update, YDParam.builder()
  355. .formUuid("FORM-W2A66Z910O9B3LP9C6IYUDPRVWY62DO0YHIILY")
  356. .formInstanceIdList(formInstanceIds)
  357. .updateFormDataJson(JSON.toJSONString(update))
  358. .build(), YDConf.FORM_OPERATION.multi_update);
  359. return McR.success();
  360. }
  361. /**
  362. * 发票状态更新: 退回提交
  363. */
  364. @PostMapping("invoice-zy")
  365. McR invoice_zy(@RequestBody Map data) {
  366. log.info("发票状态更新: 退回提交, {}", data);
  367. List<String> pre_ids = (List<String>) data.get("pre_ids"); // 释放修改前
  368. List<String> cur_ids = (List<String>) data.get("cur_ids"); // 占用修改后
  369. // [前端调用添加] 退回为监听宜搭dom事件, 先执行接口调用, 才会校验宜搭必填, 过滤无效调用
  370. if (cur_ids.size() == 0) {
  371. return McR.success();
  372. }
  373. Map pre_update = (Map) data.get("pre_update");
  374. Map cur_update = (Map) data.get("cur_update");
  375. // 宜搭批量更新
  376. ydClient.operateData(YDParam.builder()
  377. .formUuid("FORM-W2A66Z910O9B3LP9C6IYUDPRVWY62DO0YHIILY")
  378. .formInstanceIdList(pre_ids)
  379. .updateFormDataJson(JSON.toJSONString(pre_update))
  380. .build(), YDConf.FORM_OPERATION.multi_update);
  381. ydClient.operateData(YDParam.builder()
  382. .formUuid("FORM-W2A66Z910O9B3LP9C6IYUDPRVWY62DO0YHIILY")
  383. .formInstanceIdList(cur_ids)
  384. .updateFormDataJson(JSON.toJSONString(cur_update))
  385. .build(), YDConf.FORM_OPERATION.multi_update);
  386. return McR.success();
  387. }
  388. @PostMapping("test")
  389. McR test() {
  390. // List<Map> process = (List<Map>) ydClient.queryData(YDParam.builder()
  391. // .formUuid("W2A66Z910O9B3LP9C6IYUDPRVWY62DO0YHIILY")
  392. // .formInstId("FINST-NGA66WA1FV4EB7QJC3OATA3EV8MK35Z9COEMLFR22")
  393. // .build(), YDConf.FORM_QUERY.retrieve_id).getData();
  394. List<Map> process = (List<Map>) ydClient.queryData(YDParam.builder()
  395. .formUuid("FORM-0IA66C71F6NBAETREO8DE9SSN43D3YIZ0AYILC")
  396. .searchFieldJson(JSON.toJSONString(UtilMap.map("textField_lmewsobs", "Y16668919W4E4FHQ6123ADDHB8XK3S709YEMLXWF")))
  397. .build(), YDConf.FORM_QUERY.retrieve_search_form).getData();
  398. return McR.success();
  399. }
  400. }