NhIVController.java 24 KB

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