FormulaUtils.java 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  1. package com.mixsmart.utils;
  2. import cn.hutool.core.date.DatePattern;
  3. import cn.hutool.core.date.DateTime;
  4. import cn.hutool.log.StaticLog;
  5. import com.alibaba.fastjson.JSON;
  6. import com.alibaba.fastjson.JSONArray;
  7. import com.alibaba.fastjson.JSONObject;
  8. import com.alibaba.fastjson.annotation.JSONField;
  9. import com.jfireel.expression.Expression;
  10. import org.apache.commons.lang.math.NumberUtils;
  11. import org.apache.http.*;
  12. import org.apache.http.client.HttpClient;
  13. import org.apache.http.client.entity.UrlEncodedFormEntity;
  14. import org.apache.http.client.methods.HttpGet;
  15. import org.apache.http.client.methods.HttpPost;
  16. import org.apache.http.entity.StringEntity;
  17. import org.apache.http.impl.client.HttpClientBuilder;
  18. import org.apache.http.impl.client.HttpClients;
  19. import org.apache.http.message.BasicNameValuePair;
  20. import org.apache.http.util.EntityUtils;
  21. import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
  22. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  23. import org.apache.poi.ss.usermodel.*;
  24. import java.awt.Color;
  25. import org.jfree.chart.ChartFactory;
  26. import org.jfree.chart.ChartPanel;
  27. import org.jfree.chart.ChartUtils;
  28. import org.jfree.chart.JFreeChart;
  29. import org.jfree.chart.axis.NumberAxis;
  30. import org.jfree.chart.axis.NumberTickUnit;
  31. import org.jfree.chart.plot.PlotOrientation;
  32. import org.jfree.chart.plot.ValueMarker;
  33. import org.jfree.chart.plot.XYPlot;
  34. import org.jfree.chart.renderer.xy.XYSplineRenderer;
  35. import org.jfree.chart.title.TextTitle;
  36. import org.jfree.data.xy.XYSeries;
  37. import org.jfree.data.xy.XYSeriesCollection;
  38. import org.jsoup.Jsoup;
  39. import org.jsoup.nodes.Document;
  40. import org.jsoup.nodes.Element;
  41. import org.jsoup.select.Elements;
  42. import org.springblade.common.utils.BaseUtils;
  43. import org.springblade.common.utils.SnowFlakeUtil;
  44. import org.springblade.core.tool.utils.*;
  45. import org.springblade.manager.bean.TableInfo;
  46. import org.springblade.manager.dto.*;
  47. import org.springblade.manager.entity.Formula;
  48. import org.springblade.manager.entity.WbsTreeContract;
  49. import org.springblade.manager.formula.NodeTable;
  50. import org.springblade.manager.formula.impl.CompositeDataAccess;
  51. import org.springblade.manager.formula.impl.TableElementConverter;
  52. import org.springblade.manager.utils.FileUtils;
  53. import org.springblade.manager.vo.BaseInfo;
  54. import org.springblade.manager.vo.InterimPaymentCertificate;
  55. import org.springblade.manager.vo.MeterTree;
  56. import org.springblade.manager.vo.WbsFormElementVO;
  57. import org.springframework.core.annotation.AnnotationUtils;
  58. import reactor.core.publisher.Mono;
  59. import java.awt.*;
  60. import java.awt.Font;
  61. import java.awt.Shape;
  62. import java.awt.geom.Ellipse2D;
  63. import java.io.*;
  64. import java.lang.reflect.Field;
  65. import java.nio.charset.StandardCharsets;
  66. import java.security.MessageDigest;
  67. import java.security.NoSuchAlgorithmException;
  68. import java.util.*;
  69. import java.util.List;
  70. import java.util.concurrent.ThreadLocalRandom;
  71. import java.util.concurrent.atomic.AtomicInteger;
  72. import java.util.function.Function;
  73. import java.util.regex.Matcher;
  74. import java.util.regex.Pattern;
  75. import java.util.stream.Collectors;
  76. import java.util.stream.IntStream;
  77. import java.util.stream.Stream;
  78. import static java.util.regex.Pattern.*;
  79. /**
  80. * @author yangyj
  81. * @Date 2022/7/14 15:55
  82. * @description TODO
  83. */
  84. public class FormulaUtils {
  85. public static final String ELE_CODE_REG= "(?<=E\\[)[^]]+(?=])";
  86. public static final Pattern P = Pattern.compile(ELE_CODE_REG);
  87. /**元素标识*/
  88. public final static String E="E";
  89. /*确定各个元素在计算时的步长,算法:step=最长单元格数/当前元素单元格数*/
  90. public static LinkedHashMap<String,FormData> step(List<FormData> ele){
  91. LinkedHashMap<String,FormData> fdMap =new LinkedHashMap<>();
  92. FormData maxFormData = Collections.max(ele, Comparator.comparingInt((FormData ef)->ef.getValues().size()));
  93. FormData minFormData = Collections.min(ele, Comparator.comparingInt((FormData ef)->ef.getValues().size()));
  94. if (maxFormData.getValues().size() != minFormData.getValues().size()) {
  95. int baseLength = maxFormData.getValues().size();
  96. for (FormData formData : ele) {
  97. formData.setStep(baseLength / formData.getValues().size());
  98. }
  99. }
  100. ele.forEach(e->{
  101. fdMap.put(e.getCode(),e);
  102. });
  103. return fdMap;
  104. }
  105. /*确定公式执行环境变量*/
  106. public static List<LocalVariable> slice2Local(String f, LinkedHashMap<String,FormData> fdMap, TableElementConverter tec){
  107. CompositeDataAccess cda = new CompositeDataAccess(fdMap);
  108. List<LocalVariable> local= new ArrayList<>();
  109. while (cda.hasNext()){
  110. LinkedHashMap<String,ElementData> tip= cda.next();
  111. Map<String, Object> variable = new HashMap<>(tec.constantMap);
  112. @SuppressWarnings("unchecked")
  113. Map<String,Object> em= (Map<String, Object>) variable.computeIfAbsent(E, k->new HashMap<>());
  114. int index= new ArrayList<>(tip.values()).get(0).getIndex();
  115. for(Map.Entry<String,ElementData> se:tip.entrySet()){
  116. Object value=se.getValue().getValue();
  117. if(CustomFunction.isNumber(value)){
  118. if(StringUtils.isDouble(value)||f.contains("/")){
  119. em.put(se.getKey(),Double.parseDouble(value.toString()));
  120. }else{
  121. em.put(se.getKey(),StringUtils.handleObj2Integer(value));
  122. }
  123. }else{
  124. em.put(se.getKey(),StringUtils.handleNull(value).replaceAll("[ ]+","").trim());
  125. }
  126. }
  127. local.add(new LocalVariable(index,f,variable));
  128. }
  129. return local;
  130. }
  131. public static void putEle(String f,List<FormData> ele,Map<String, Object> currentMap,FormData fd){
  132. @SuppressWarnings("unchecked")
  133. Map<String,Object> em = (Map<String, Object>) currentMap.computeIfAbsent(E,(k)-> new HashMap<>());
  134. /*如果输入输出元素都是1对1*/
  135. if(f.split("[/+\\-*]").length>1&&ele.stream().map(e->e.getCoordsList().size()).max(Comparator.comparingInt(e->e)).orElse(1)==1&&fd.getCoordsList().size()==1){
  136. ele.forEach(e->{
  137. Object value=e.getValues().get(0).getValue();
  138. if(CustomFunction.isNumber(value)){
  139. if(StringUtils.isDouble(value)||f.contains("/")){
  140. em.put(e.getCode(), Double.parseDouble(value.toString()));
  141. }else{
  142. em.put(e.getCode(),StringUtils.handleObj2Integer(value));
  143. }
  144. }else{
  145. em.put(e.getCode(),value);
  146. }
  147. });
  148. }else{
  149. ele.forEach(e-> em.put(e.getCode(),e.getRawValue()));
  150. }
  151. }
  152. public static final Random RD = new Random();
  153. public static Map<String,Object> triangleSquare(Object ranges){
  154. Map<String,Object> map =new HashMap<>();
  155. if(StringUtils.isEmpty(ranges)){
  156. //z的默认取值范围
  157. ranges="(0,15)";
  158. }
  159. Matcher m = RegexUtils.matcher("(\\-?\\d+)(\\D)(\\+?\\d+)",ranges.toString());
  160. if(m.find()) {
  161. int min = StringUtils.handObj2Integer(m.group(1));
  162. int max = StringUtils.handObj2Integer(m.group(3));
  163. Integer[] r = pythagorean(min, max);
  164. map.put("X", String.valueOf(r[0]));
  165. map.put("Y", String.valueOf(r[1]));
  166. map.put("Z", String.valueOf(r[2]));
  167. }
  168. return map;
  169. }
  170. /* public static void main(String[] args) {
  171. IntStream.range(0,10).boxed().forEach(i->{
  172. System.out.println(triangleSquare("-5,5"));
  173. });
  174. }*/
  175. /**
  176. * @Description 字符串相似度
  177. * @Param [s1, s2]
  178. * @return double
  179. * @Author yangyj
  180. * @Date 2023.04.12 18:01
  181. **/
  182. public static double getJaccardSimilarity(String s1, String s2) {
  183. Set<Character> set1 = new HashSet<>();
  184. Set<Character> set2 = new HashSet<>();
  185. for (char c : s1.toCharArray()) {
  186. set1.add(c);
  187. }
  188. for (char c : s2.toCharArray()) {
  189. set2.add(c);
  190. }
  191. Set<Character> intersection = new HashSet<>(set1);
  192. intersection.retainAll(set2);
  193. Set<Character> union = new HashSet<>(set1);
  194. union.addAll(set2);
  195. return (double) intersection.size() / union.size();
  196. }
  197. public static Double similarity(String s1,String s2){
  198. return getJaccardSimilarity(parseItemName(s1),parseItemName(s2));
  199. }
  200. /**
  201. * result[0]^2+result[1]^2=result[2]^2 result[] 元素均为正整数
  202. */
  203. public static Integer[] pythagorean(Integer min,Integer max){
  204. Integer[] result = null;
  205. List<Integer[]> list = new ArrayList<>();
  206. for(int i=1;i<=max;i++){
  207. for(int j=1;j<=max;j++){
  208. double tmp = Math.sqrt(Math.pow(i,2)+Math.pow(j,2));
  209. int z= (int) Math.round(tmp);
  210. if(min<z&&z<=max){
  211. Integer[] arr = new Integer[]{RD.nextBoolean()?i:-i,RD.nextBoolean()?j:-j,z};
  212. list.add(arr);
  213. }
  214. }
  215. }
  216. if(ListUtils.isNotEmpty(list)){
  217. Random rm = new Random();
  218. result = list.get(rm.nextInt(list.size()));
  219. }
  220. return result;
  221. }
  222. /*public static void main(String[] args) {
  223. FormData fd = new FormData();
  224. fd.setEName("1111");
  225. List<ElementData> list = new ArrayList<>();
  226. list.add(new ElementData(1,1,1));
  227. test(fd);
  228. System.out.println(fd.getEName());
  229. }*/
  230. /**写人元素数据,每个元素都是一个集合,每页的单元格数量乘以页数就是总长度*/
  231. public static void write(FormData fd, Object data){
  232. write(fd,data,false);
  233. }
  234. public static void write(FormData fd, Object data,Boolean nullOrBlank ){
  235. if(Func.isEmpty(fd.getValues())){
  236. /*无定位信息不写入*/
  237. return;
  238. }
  239. try {
  240. /*一个单元格且存在多张,全部设置为自动拓展 20230816*/
  241. if(fd.getCoordsList().size()==1&&fd.getValues().size()>1&&fd.getFormula()!=null){
  242. fd.getFormula().setOutm(Formula.FULL);
  243. }
  244. /*写入前清空内容*/
  245. fd.getValues().forEach(t->t.setValue(null));
  246. if(data instanceof List){
  247. List<Object> values = (List<Object>) data;
  248. if(!nullOrBlank){
  249. /*不包含空白内容*/
  250. values=values.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
  251. }
  252. if(values.size()>fd.getValues().size()){
  253. if(fd.getCoordsList().size()==1){
  254. /*元素只绑定了一个单元格的情况*/
  255. if(values.stream().filter(CustomFunction::containsZH).anyMatch(e->e.toString().contains("\n"))){
  256. fd.getValues().get(0).setValue(values.stream().filter(Objects::nonNull).map(Object::toString).collect(Collectors.joining()));
  257. }else{
  258. /*日期类型的元素只获取最后一个非空*/
  259. if(StringUtils.isEquals(4,fd.getEType())){
  260. fd.getValues().get(0).setValue(values.stream().filter(StringUtils::isNotEmpty).reduce((first, second) -> second).orElse(null));
  261. }else if(values.stream().filter(StringUtils::isNotEmpty).distinct().count()==1L){
  262. /*如果输入元素全是是一样的内容,则输入出元素则每个单元格也写入一样的内容*/
  263. values.stream().filter(StringUtils::isNotEmpty).findFirst().ifPresent(t->{
  264. for(int n=0;n<fd.getValues().size();n++){
  265. fd.getValues().get(n).setValue(t);
  266. }
  267. });
  268. }else{
  269. fd.getValues().get(0).setValue(values.stream().map(StringUtils::handleNull).collect(Collectors.joining("、")));
  270. }
  271. }
  272. }else{
  273. for(int n=0;n<fd.getValues().size();n++){
  274. fd.getValues().get(n).setValue(values.get(n));
  275. }
  276. List<Object> overList=values.stream().skip(fd.getValues().size()).collect(Collectors.toList());
  277. List<Coords> coordsList = fd.getCoordsList();
  278. int addPage=(int)Math.ceil((double)overList.size()/(double)coordsList.size());
  279. fd.setAddPages(addPage);
  280. ElementData last =fd.getValues().get(fd.getValues().size()-1);
  281. int indexBase=last.getIndex()+1;
  282. List<ElementData> addList= new ArrayList<>();
  283. for(int i=0;i<addPage;i++){
  284. for(int j=0;j<coordsList.size();j++){
  285. /*超页就尽管写进去,格式化阶段再加表*/
  286. Coords coords = coordsList.get(j);
  287. Object v=null;
  288. int st=i*coordsList.size()+j;
  289. if(st<overList.size()){
  290. v= overList.get(st);
  291. }
  292. addList.add(new ElementData(indexBase+i,last.getGroupId(),v,coords.getX(),coords.getY()));
  293. }
  294. }
  295. fd.getValues().addAll(addList);
  296. }
  297. }else{
  298. for (int n = 0; n < values.size(); n++) {
  299. fd.getValues().get(n).setValue(values.get(n));
  300. }
  301. }
  302. }else{
  303. if(Formula.FULL.equals(fd.getFormula().getOutm())){
  304. /*填充策略*/
  305. fd.getValues().forEach(e->e.setValue(data));
  306. }else{
  307. fd.getValues().get(0).setValue(data);
  308. }
  309. }
  310. fd.setUpdate(1);
  311. }catch (Exception e){
  312. e.printStackTrace();
  313. }
  314. }
  315. public static final String TBN_FN="TBN";
  316. /*把模型类转换成共识配置选项*/
  317. public static List<WbsFormElementVO> toElementVos(Class<?> clazz) {
  318. List<WbsFormElementVO> vos =new ArrayList<>();
  319. try {
  320. Field tbnField = clazz.getField(TBN_FN);
  321. String TBN = (String) tbnField.get(null);
  322. for (Field field : clazz.getDeclaredFields()) {
  323. JSONField jf = field.getAnnotation(JSONField.class);
  324. if (jf != null) {
  325. WbsFormElementVO vo = new WbsFormElementVO();
  326. vo.setEName(jf.label());
  327. vo.setTableElementKey(TBN+ StringPool.COLON +jf.name());
  328. vo.setInitTableName(TBN);
  329. vo.setId(BaseUtils.str2Long(vo.getTableElementKey()));
  330. vos.add(vo);
  331. }
  332. }
  333. }catch (Exception e){
  334. e.printStackTrace();
  335. }
  336. return vos;
  337. }
  338. public static String getEleKey(Class<?> clazz, String fieldName){
  339. try {
  340. Field field = clazz.getDeclaredField(fieldName);
  341. String TBN = (String) clazz.getField(TBN_FN).get(null);
  342. JSONField jf = AnnotationUtils.findAnnotation(field, JSONField.class);
  343. if (jf != null) {
  344. return TBN+StringPool.COLON+jf.name();
  345. }
  346. } catch (Exception e) {
  347. e.printStackTrace();
  348. }
  349. return StringPool.EMPTY;
  350. }
  351. /*获取指定模型的页码元素*/
  352. public static String getPageCode(Class<?> clazz){
  353. return getEleKey(clazz,"pageCount");
  354. }
  355. /*根据数据模型实例生成带数据的元素,用于修改*/
  356. public static <T> LinkedHashMap<String,FormData> toFormDataMap(T bean){
  357. LinkedHashMap<String,FormData> result = new LinkedHashMap<>();
  358. if(bean!=null){
  359. try {
  360. @SuppressWarnings("unchecked")
  361. Map<String,String> map= JSON.parseObject(JSON.toJSONString(bean),Map.class);
  362. Class<?> clazz=bean.getClass();
  363. String TBN = (String) clazz.getField(TBN_FN).get(null);
  364. for (Field field : clazz.getDeclaredFields()) {
  365. JSONField jf = field.getAnnotation(JSONField.class);
  366. if (jf != null) {
  367. FormData fd = new FormData();
  368. fd.setCode(TBN+ StringPool.COLON +jf.name());
  369. fd.setEName(jf.label());
  370. fd.getValues().add(new ElementData(0,0,map.get(fd.getKey()),0,0));
  371. fd.getCoordsList().add(new Coords("0","0"));
  372. result.put(fd.getCode(),fd);
  373. }
  374. }
  375. }catch (Exception e){
  376. e.printStackTrace();
  377. }
  378. }
  379. return result;
  380. }
  381. /*根据数据模型建立空元素,待写入数据*/
  382. public static <T> LinkedHashMap<String,FormData> toFormDataMap(Class<T> clazz){
  383. LinkedHashMap<String,FormData> result = new LinkedHashMap<>();
  384. try {
  385. String TBN = (String) clazz.getField(TBN_FN).get(null);
  386. for (Field field : clazz.getDeclaredFields()) {
  387. JSONField jf = field.getAnnotation(JSONField.class);
  388. if (jf != null) {
  389. FormData fd = new FormData();
  390. fd.setCode(TBN+ StringPool.COLON +jf.name());
  391. fd.setEName(jf.label());
  392. fd.getCoordsList().add(new Coords("0","0"));
  393. result.put(fd.getCode(),fd);
  394. }
  395. }
  396. }catch (Exception e){
  397. e.printStackTrace();
  398. }
  399. return result;
  400. }
  401. /*把结果数据回写到元素*/
  402. public static<T>void put2FormData( LinkedHashMap<String,FormData> fdm,Map<String,Function<List<T>,List<Object>>> functionMap,List<T> dataList){
  403. fdm.values().stream()
  404. .filter(fd -> functionMap.containsKey(fd.getCode()))
  405. .forEach(fd -> {
  406. List<Object> raw = functionMap.get(fd.getCode()).apply(dataList);
  407. raw.stream().map(ElementData::new).forEach(fd.getValues()::add);
  408. });
  409. }
  410. /*根据数据模型对象,生成数据集合按字段获取数据的函数*/
  411. public static <T> Map<String, Function<List<T>, List<Object>>> fieldDataFcMap(Class<?> clazz) {
  412. Map<String, Function<T, Object>> fieldMap = functionMapBuilder(clazz);
  413. Map<String, Function<List<T>, List<Object>>> functionMap = new HashMap<>();
  414. for (Map.Entry<String, Function<T, Object>> functionEntry : fieldMap.entrySet()) {
  415. Function<List<T>, List<Object>> mapper = list -> list.stream().map(functionEntry.getValue()).collect(Collectors.toList());
  416. functionMap.put(functionEntry.getKey(), mapper);
  417. }
  418. return functionMap;
  419. }
  420. /*数据模型按字段生成内容获取函数*/
  421. public static <T> Map<String,Function<T,Object>> functionMapBuilder(Class<?> clazz){
  422. Map<String, Function<T, Object>> functionMap = new HashMap<>();
  423. try {
  424. String tbn=clazz.getField(TBN_FN).get(null).toString();
  425. for (Field field : clazz.getDeclaredFields()) {
  426. JSONField jf = field.getAnnotation(JSONField.class);
  427. if(jf!=null) {
  428. /*ordinal<=100的情况下才会生成动态行字段输出函数*/
  429. if(jf.ordinal()<=100) {
  430. String key = tbn + StringPool.COLON + jf.name();
  431. String fieldName = field.getName();
  432. Function<T, Object> function = getFunction(clazz, fieldName);
  433. functionMap.put(key, function);
  434. }
  435. }
  436. }
  437. }catch (Exception e){
  438. e.printStackTrace();
  439. }
  440. return functionMap;
  441. }
  442. private static <T> Function<T, Object> getFunction(Class<?> clazz, String fieldName) {
  443. return certificate -> {
  444. try {
  445. Field field = clazz.getDeclaredField(fieldName);
  446. field.setAccessible(true);
  447. return field.get(certificate);
  448. } catch (Exception e) {
  449. e.printStackTrace();
  450. return null;
  451. }
  452. };
  453. }
  454. /*list转TreeNode*/
  455. public static <K,T> Map<K, TreeNode<T>> list2TreeNode(Function<TreeNode<T>,K> keyMapper,List<T> list,Function<T,TreeNode<T>> fc,Function<TreeNode<T>,K> classifier){
  456. Map<K, TreeNode<T>> mTreeMap = new HashMap<>();
  457. if (Func.isNotEmpty(list)) {
  458. for (T mt : list) {
  459. try {
  460. TreeNode<T> treeNode = fc.apply(mt);
  461. mTreeMap.put(keyMapper.apply(treeNode), treeNode);
  462. }catch (Exception e){
  463. e.printStackTrace();
  464. }
  465. }
  466. Map<K, List<TreeNode<T>>> group = mTreeMap.values().stream().collect(Collectors.groupingBy(classifier));
  467. group.forEach((k, v) -> {
  468. TreeNode<T> parent = mTreeMap.get(k);
  469. if (parent != null) {
  470. v = v.stream().sorted(Comparator.comparingInt(TreeNode::getSort)).collect(Collectors.toList());
  471. parent.setChildren(v);
  472. v.forEach(e -> e.setParent(parent));
  473. }
  474. });
  475. }
  476. return mTreeMap;
  477. }
  478. /*TreeNode 排序*/
  479. public static <T> void treeNodeSort(int base,TreeNode<T> top){
  480. top.setSort(base);
  481. if(top.hasChildren()){
  482. for(TreeNode<T> child:top.getChildren()){
  483. child.setSort(base++);
  484. }
  485. }
  486. }
  487. /*回溯标记*/
  488. public static <T> void treeNodeChecked( TreeNode<T> tmp){
  489. int loop = 10;
  490. do{
  491. if(tmp.isChecked()) {
  492. /*已经检出则停止循环*/
  493. loop=0;
  494. }else{
  495. tmp.setChecked(true);
  496. tmp=tmp.getParent();
  497. }
  498. }while (tmp!=null&&loop-->0);
  499. }
  500. /*获取层级链*/
  501. public static <T> List<T> treeNodeChains( TreeNode<T> tmp){
  502. List<T> result = new ArrayList<>();
  503. int loop = 10;
  504. do{
  505. /*不包括顶层*/
  506. if(tmp.getParentId()!=0L) {
  507. result.add(tmp.getValue());
  508. }
  509. tmp=tmp.getParent();
  510. }while (tmp!=null&&loop-->0);
  511. Collections.reverse(result);
  512. return result;
  513. }
  514. /**从元素名称中解析项目名称,细化项目匹配用*/
  515. public static String parseItemName(String eName){
  516. if (StringUtils.isEmpty(eName)) {
  517. return eName;
  518. }
  519. String str = eName.replaceAll("\\s", "");
  520. Pattern pattern = compile("[((][^\\u4e00-\\u9fa5]+[))]|_+");
  521. String[] candidate = pattern.split(str);
  522. /*非中文非罗马数字1到10*/
  523. String regex = "[^\\u4e00-\\u9fa5\\u2160-\\u2169))((]+";
  524. Pattern p = compile(regex);
  525. return Arrays.stream(candidate)
  526. .filter(s -> !isContainKeywords(s))
  527. .map(s -> filterString(s, p))
  528. .collect(Collectors.joining());
  529. }
  530. /*A15检查内容专用*/
  531. public static String checkItemName(String eName){
  532. if (StringUtils.isEmpty(eName)) {
  533. return eName;
  534. }
  535. /*分割字符串,选取第一个匹配的子串*/
  536. String str = eName.replaceAll("\\s", "");
  537. Pattern pattern = compile("[((][^\\u4e00-\\u9fa5]+[))]|_+");
  538. String[] candidate = pattern.split(str);
  539. String regex = "[^\\u4e00-\\u9fa5]+";
  540. return Arrays.stream(candidate).map(s->s.replaceAll(regex,"")).distinct().filter(StringUtils::isNotEmpty).filter(s->!isContainKeywords2(s)).findFirst().orElse("");
  541. }
  542. private static String filterString(String s, Pattern p) {
  543. s=s.replaceAll("【[^【】]+】","");
  544. Matcher matcher = p.matcher(s);
  545. return matcher.replaceAll("").replaceAll(getRegex(), "").replaceAll("(设计|合格).*","");
  546. }
  547. private static String getRegex() {
  548. return "(在合格标准内|满足设计要求|质量评定|评定|判定|项目|总数|抽测|实测|偏差|尺量|关键|一般)";
  549. }
  550. private static boolean isContainKeywords(String s) {
  551. List<String> keywords = Arrays.asList( ":", "个","附录","抽查","测","求","小于","大于","检查","仪","按","不","各","记录","且","规定","值或实","≤","≥","平均");
  552. return keywords.stream().anyMatch(s::contains);
  553. }
  554. private static boolean isContainKeywords2(String s) {
  555. List<String> keywords = Arrays.asList( "项目");
  556. return keywords.stream().anyMatch(s::contains);
  557. }
  558. /**回归·测试变量*/
  559. public static List<String> itemNames =Arrays.asList(
  560. ""
  561. ,"压 实 度 (%)下路床 特重、极重交通荷载等级 设计值"
  562. ,"1△_压 实 度 (%)_下路床_轻、中及重交通 荷载等级_0.3m~0.8m_≧96_≧95_≧94_实测值或实测偏差值"
  563. ,"1△_压 实 度 (%)_下路提_轻、中及重交通 荷载等级_&gt;1.5m_≧93_≧92_≧90_实测值或实测偏差值"
  564. ,"1△_压 实 度 (%)_上路提_轻、中及重交通 荷载等级_0.8m~1.5m_≧94_≧94_≧93_实测值或实测偏差值"
  565. ,"压 实 度 (%)下路提 轻、中及重交通荷载等级 设计值"
  566. ,"压 实 度 (%)下路床 特重、极重交通荷载等级 合格率"
  567. ,"压 实 度 (%)下路提 轻、中及重交通荷载等级\t合格率"
  568. ,"5△_保护层 厚度 (mm)_基础、锚碇、墩台身、墩柱_±10_实测值或实测偏差值"
  569. ,"钢筋骨架尺寸宽、高或直径 (mm)_尺量:按骨架总数30%抽测_±5_实测值或实测偏差值"
  570. ,"钢筋骨架尺寸长 (mm)_±10_尺量:按骨架总数30%抽测_实测值或实测偏差值"
  571. , "受力钢筋间距 (mm)同排 梁、板、拱肋及拱上建筑 设计值"
  572. ,"受力钢筋间距 (mm)同排 梁、板、拱肋及拱上建筑 合格率"
  573. ," 箍筋、构造钢筋、螺旋筋间距(mm) 设计值"
  574. ,"箍筋、构造钢筋、螺旋筋间距(mm) 合格率"
  575. ,"实测项目_桩位 (mm)_群桩_≤100_质量评定_合格判定"
  576. ,"实测项目_桩位 (mm)_群桩_≤100_实测值或实测偏差值"
  577. ,"实测项目_桩位 (mm)_排架桩_实测值或实测偏差值"
  578. ,"实测项目_桩位 (mm)_排架桩_质量评定_合格判定"
  579. ,"实测项目_桩位 (mm)_群桩_≤100_质量评定_合格率(%)"
  580. ,"实测项目_桩位 (mm)_排架桩_质量评定_合格率(%)"
  581. ,"3△_支座高程(mm)_满足设计要求;设 计未要求时±5_水准仪:测每支座中心线_实测值或实测偏差值"
  582. ,"基底承载力(KPa)_不小于设计_直观或动力触探试验_实测值或实测偏差值"
  583. ,"实 测 项 目_花卉数量_满足设计要求_实测值或实测偏差值"
  584. ,"实 测 项 目_2△_草坪、草本地被覆盖率(%)_取弃土场绿 地_≥90_实测值或实测偏差值"
  585. ,"轴线偏位(mm)_全站仪:20m检查3点_实测值或实测偏差值"
  586. ,"1△_基材混合物喷射厚度(mm)_设计厚度±10_实测值或实测偏差值"
  587. ,"1△_混凝土强度 (MPA)_在合格标准内_按附录D检查_实测值或实测偏差值"
  588. ,"边坡坡度_不陡于设计值_水准仪:每200m测2点,且不少于5点_实测值或实测偏差值"
  589. ,"几何尺寸(mm)_±50_尺量:长、宽、高、壁厚各2点_实测值或实测偏差值"
  590. ,"4△_桩长(mm)_不小于设计_查施工记录_实测值或偏差值"
  591. ,"单桩每延米喷粉 (浆)量_不小于设计_查施工记录_实测值或偏差值"
  592. ,"搭接宽度(mm)_≥150【纵向】_尺量:抽查2%_实测值或实测偏差值",
  593. "搭接宽度(mm)_≥50(横向)_尺量:抽查2%_实测值或实测偏差值"
  594. ,"竖直度(mm)_挖孔桩_0.5%桩长,且≤200_铅锤线:每桩检测_实测值或实测偏差值"
  595. , "2△_压浆压力值 (Mpa)_满足施工技术 规范规定_查油压表读书;每管道检查_实测值或实测偏差值"
  596. , "基底承载力(KPa)_不小于设计_实测值或实测偏差值"
  597. ,"1△_受力钢筋间距 (mm)_两排以上间距_±5_实测值或实测偏差值"
  598. ,"1△梁(板)长度 (mm)_±5_实测值或实测偏差值"
  599. ,"墙面平整度(mm)_施工缝、变形缝处≤20_实测值或实测偏差值"
  600. ,"基底承载力(KPa)_不小于设计_实测值或实测偏差值"
  601. ,"1△_拱部超挖(mm)_Ⅱ、Ⅲ、Ⅳ级围岩(中硬岩 、软岩)_平均150,最大250_实测值或实测偏差值"
  602. ,"实 测 项 目_关键项目_压实度(%)_上路堤_轻、中及重交通荷载等级_0.8~1.5m_≥94_≥94_≥93_检查情况 (实测值)"
  603. );
  604. /*
  605. public static void main(String[] args) {
  606. itemNames.stream().map(FormulaUtils::parseItemName).forEach(System.out::println);
  607. //itemNames.stream().map(FormulaUtils::checkItemName).forEach(System.out::println);
  608. }
  609. */
  610. public static Object getValue(Cell cell) {
  611. if (cell != null) {
  612. switch (cell.getCellTypeEnum()) {
  613. case STRING:
  614. return cell.getStringCellValue() == null ? null : cell.getStringCellValue().trim();
  615. case NUMERIC:
  616. HSSFDataFormatter dataFormatter = new HSSFDataFormatter();
  617. return dataFormatter.formatCellValue(cell);
  618. case BOOLEAN:
  619. return cell.getBooleanCellValue();
  620. case ERROR:
  621. return cell.getErrorCellValue();
  622. case FORMULA:
  623. try {
  624. return cell.getStringCellValue();
  625. } catch (IllegalStateException e) {
  626. return cell.getNumericCellValue();
  627. }
  628. default:
  629. cell.setCellType(CellType.STRING);
  630. return cell.getStringCellValue() == null ? null : cell.getStringCellValue().trim();
  631. }
  632. }
  633. return null;
  634. }
  635. public static List<ElementData> getElementDataList(String coords,String values){
  636. if(StringUtils.isNotEmpty(coords,values)){
  637. List<Coords> coordsList = Stream.of(coords).flatMap(s -> Arrays.stream(s.split(";"))).map(s -> {
  638. String[] xy = s.split("_");
  639. return new Coords(xy[1], xy[0]);
  640. }).collect(Collectors.toList());
  641. return str2ElementData(values,coordsList,null,null);
  642. }
  643. return Collections.emptyList();
  644. }
  645. public static List<ElementData> str2ElementData(String pg, List<Coords> coordsList ,String code,Integer index){
  646. List<ElementData> eds = new ArrayList<>();
  647. if(StringUtils.isNotEmpty(pg)&&ListUtils.isNotEmpty(coordsList)) {
  648. if(code==null){
  649. code="code";
  650. }
  651. if(index==null){
  652. index=1;
  653. }
  654. String[] val = pg.split("☆");
  655. Map<String, Object> tmpMap = new LinkedHashMap<>();
  656. for (String s : val) {
  657. String[] t = s.split("_\\^_");
  658. String[] c = t[1].split("_");
  659. tmpMap.put(StringUtils.join(code, 0, index, Func.toInt(c[1]), Func.toInt(c[0]), StringPool.AT), t[0]);
  660. }
  661. for (Coords c : coordsList) {
  662. Object data = null;
  663. String key = StringUtils.join(code, 0, index, c.getX(), c.getY(), StringPool.AT);
  664. if (tmpMap.containsKey(key)) {
  665. data = tmpMap.get(key);
  666. }
  667. eds.add(new ElementData(index, 0, data, c.getX(), c.getY()));
  668. }
  669. }
  670. return eds;
  671. }
  672. /**
  673. * @Description Poi 动态执行公式 测试
  674. * @Param [url]
  675. * @Author yangyj
  676. * @Date 2023.05.05 14:28
  677. **/
  678. public static void evaluateFormulaCell(String url) {
  679. try {
  680. url="C:/Users/yangyj/Desktop/test.xlsx";
  681. Workbook workbook = WorkbookFactory.create(new File(url));
  682. Sheet sheet = workbook.getSheetAt(0);
  683. Cell cell = sheet.getRow(0).getCell(0);
  684. FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
  685. CellType cellType = evaluator.evaluateFormulaCellEnum(cell);
  686. if (cellType == CellType.NUMERIC) {
  687. double value = cell.getNumericCellValue();
  688. System.out.println("公式计算结果:" + value);
  689. } else if (cellType == CellType.STRING) {
  690. String value = cell.getStringCellValue();
  691. System.out.println("公式计算结果:" + value);
  692. }
  693. cell.setCellFormula("B1+C1+D1");
  694. evaluator.clearAllCachedResultValues();
  695. cellType = evaluator.evaluateFormulaCellEnum(cell);
  696. if (cellType == CellType.NUMERIC) {
  697. double value = cell.getNumericCellValue();
  698. System.out.println("公式计算结果:" + value);
  699. } else if (cellType == CellType.STRING) {
  700. String value = cell.getStringCellValue();
  701. System.out.println("公式计算结果:" + value);
  702. }
  703. }catch (IOException | InvalidFormatException e){
  704. e.printStackTrace();
  705. }
  706. }
  707. public static Map<String, String> getElementCell(String uri){
  708. return getElementCell(uri,null,null);
  709. }
  710. public static Map<String, String> getElementCell(String uri,String key) {
  711. return getElementCell(uri,key,null);
  712. }
  713. public static Map<String, String> getElementCell(String uri,String key,Document document) {
  714. try {
  715. String filter=" [keyname]";
  716. if(Func.isNotBlank(key)){
  717. filter="[keyname^="+key+"__]";
  718. }
  719. if(document==null){
  720. InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(uri);
  721. document=Jsoup.parse(IoUtil.readToString(inputStreamByUrl));
  722. }
  723. Map<String,String> result= document
  724. .select("table").first()
  725. .select(filter).stream()
  726. .map(d -> d.attr("keyname")).filter(StringUtils::isNotEmpty).map(e -> e.split("__"))
  727. .collect(
  728. Collectors.toMap(
  729. b -> b[0],
  730. b -> b[1],
  731. (v1, v2) -> v1 + ";" + v2
  732. )
  733. );
  734. if(result.size()>0){
  735. for(Map.Entry<String,String> entry:result.entrySet()){
  736. entry.setValue(FormulaUtils.coordsSorted(entry.getValue()));
  737. }
  738. }
  739. return result;
  740. }catch (Exception e){
  741. e.printStackTrace();
  742. return new HashMap<>();
  743. }
  744. }
  745. public static Map<String, String> getElementExcelCoords(String uri){
  746. return getElementExcelCoords(uri,null,null);
  747. }
  748. public static Map<String, String> getElementExcelCoords(Document document){
  749. return getElementExcelCoords(null,null,document);
  750. }
  751. public static Map<String, String> getElementExcelCoords(String uri,String key,Document document){
  752. try {
  753. String filter=" [keyname]";
  754. if(Func.isNotBlank(key)){
  755. filter="[keyname^="+key+"__]";
  756. }
  757. if(document==null){
  758. InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(uri);
  759. document=Jsoup.parse(IoUtil.readToString(inputStreamByUrl));
  760. }
  761. Map<String,String> result= document
  762. .select("table").first()
  763. .select(filter).stream()
  764. .filter(d -> Func.isNotEmpty(d.attr("keyname"))).filter(StringUtils::isNotEmpty).map(e ->new String[]{e.attr("keyname").split("__")[0],e.attr("y1")+"_"+e.attr("x1")})
  765. .collect(
  766. Collectors.toMap(
  767. b -> b[0],
  768. b -> b[1],
  769. (v1, v2) -> v1 + ";" + v2
  770. )
  771. );
  772. if(result.size()>0){
  773. for(Map.Entry<String,String> entry:result.entrySet()){
  774. entry.setValue(FormulaUtils.coordsSorted(entry.getValue()));
  775. }
  776. }
  777. return result;
  778. }catch (Exception e){
  779. e.printStackTrace();
  780. return new HashMap<>();
  781. }
  782. }
  783. /*解析html里的电签关键字*/
  784. public static Map<String,String> getESignMap(Document document){
  785. Map<String,String> result = new HashMap<>();
  786. if(document!=null) {
  787. Elements list = document.getElementsByAttribute("dqid");
  788. if (list != null && !list.isEmpty()) {
  789. list.stream().forEach(e -> {
  790. String dqid = e.attr("dqid");
  791. int y1=0;
  792. int x1=0;
  793. if (!e.hasAttr("y1") && !e.hasAttr("x1")&&e.children().size()>0) {
  794. Element element = e.children().get(0);
  795. y1 = Func.toInt(element.attr("y1"));
  796. x1 = Func.toInt(element.attr("x1"));
  797. }else {
  798. y1 = Func.toInt(e.attr("y1"));
  799. x1 = Func.toInt(e.attr("x1"));
  800. }
  801. result.put(y1+"_"+x1,dqid);
  802. });
  803. }
  804. }
  805. return result;
  806. }
  807. public static List<ElementData> setScale(Integer scale, List<ElementData> data){
  808. if(scale==null){
  809. scale=StringUtils.getScale(data.stream().map(ElementData::getValue).filter(StringUtils::isDouble).collect(Collectors.toList()));
  810. }
  811. Integer finalScale = scale;
  812. return data.stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2StringZero(e.getValue(),finalScale));}}).collect(Collectors.toList());
  813. }
  814. /**
  815. * @Description 定位信息排序
  816. * @Param [coords]
  817. * @return java.lang.String
  818. * @Author yangyj
  819. * @Date 2023.07.11 15:39
  820. **/
  821. public static String coordsSorted(String coords){
  822. if(StringUtils.isNotEmpty(coords)){
  823. List<String> dataList=Arrays.asList(coords.split(";"));
  824. if(dataList.size()>2){
  825. LinkedList<Integer> list=dataList.stream().map(e->e.split("_")[1]).distinct().map(Integer::parseInt).sorted(Comparator.comparingInt(e->e)).collect(Collectors.toCollection(LinkedList::new));
  826. if(list.getLast()-list.getFirst()>list.size()-1){
  827. coords=dataList.stream()
  828. .sorted(Comparator.comparingInt((String str) -> Integer.parseInt(str.split("_")[1]))
  829. .thenComparingInt(str -> Integer.parseInt(str.split("_")[0])))
  830. .collect(Collectors.joining(";"));
  831. }
  832. }
  833. }
  834. return coords;
  835. }
  836. public static String coordsSorted2(String coords){
  837. if(StringUtils.isNotEmpty(coords)){
  838. List<String> dataList=Arrays.asList(coords.split(";"));
  839. if(dataList.size()>2){
  840. /*判断分区:根据行列长度*/
  841. List<Integer> row =dataList.stream().map(e->e.split("_")[0]).distinct().map(Integer::parseInt).collect(Collectors.toList());
  842. List<Integer> column=dataList.stream().map(e->e.split("_")[1]).distinct().map(Integer::parseInt).collect(Collectors.toList());
  843. if(row.size()>=column.size()){
  844. /*纵向*/
  845. if(column.size()>1){
  846. List<List<Integer>> consecutiveGroups = IntStream.range(0, column.size())
  847. .boxed()
  848. .collect(Collectors.collectingAndThen(
  849. Collectors.groupingBy(
  850. i -> i - column.get(i),
  851. LinkedHashMap::new,
  852. Collectors.mapping(column::get, Collectors.toList())
  853. ),
  854. map -> new ArrayList<>(map.values())
  855. ));
  856. }
  857. }
  858. /* 确定区内方向:*/
  859. }
  860. }
  861. return coords;
  862. }
  863. /* public static void main(String[] args) {
  864. List<Integer> column = Arrays.asList(1, 2, 3, 5, 6, 7, 9, 11, 17);
  865. List<List<Integer>> consecutiveGroups = IntStream.range(0, column.size())
  866. .boxed()
  867. .collect(Collectors.collectingAndThen(
  868. Collectors.groupingBy(
  869. i -> i - column.get(i),
  870. LinkedHashMap::new,
  871. Collectors.mapping(column::get, Collectors.toList())
  872. ),
  873. map -> new ArrayList<>(map.values())
  874. ));
  875. AtomicInteger i = new AtomicInteger(column.get(0));
  876. List<List<Integer>> consecutiveGroups2= new ArrayList<>(column.stream().collect(Collectors.groupingBy(e -> e - i.getAndSet(e) > 1, LinkedHashMap::new, Collectors.toList())).values());
  877. System.out.println();
  878. }*/
  879. public static List<Object> slice(List<LocalVariable> local, String formula){
  880. int min =0;
  881. List<Object> result = new ArrayList<>();
  882. try {
  883. pretreatment(local,formula);
  884. List<Object> r= local.stream().map(e-> {
  885. /*所有依赖元素的内容必须非空才进行计算,否则返回空值*/
  886. return e.hasEmptyElementValue()?"": Expression.parse(e.getFormula()).calculate(e.getCurrentMap()).toString();
  887. }).collect(Collectors.toList());
  888. if(CollectionUtil.isNotEmpty(r)&&r.stream().anyMatch(StringUtils::isNotEmpty)){
  889. result.addAll(r);
  890. }
  891. }catch (Exception e){
  892. StaticLog.error("公式:{},执行出错",formula);
  893. }
  894. return result;
  895. }
  896. public static void pretreatment(List<LocalVariable> local,String formula){
  897. formula=StringUtils.removeMultiSpace(formula);
  898. if(formula.contains("LIST")){
  899. Matcher m=RegexUtils.matcher("\\(([^)]*)\\)/LIST",formula);
  900. while (m.find()){
  901. List<String> codes=getCodeList(m.group(1).replaceAll("[+-]",","));
  902. local=local.stream().peek(e->{
  903. @SuppressWarnings("unckecked")
  904. Map<String,Object> map = (Map<String, Object>) e.getCurrentMap().getOrDefault("E",new HashMap<>());
  905. int listSize=(int)codes.stream().filter(c->StringUtils.isNotEmpty(map.get(c))).count();
  906. if(listSize<=0||listSize>codes.size()){
  907. listSize=codes.size();
  908. }
  909. map.put("LIST",listSize);
  910. }).collect(Collectors.toList());
  911. }
  912. }
  913. }
  914. /**从方法参数中获取全部code*/
  915. public static List<String> getCodeList(String param){
  916. List<String> list = new ArrayList<>();
  917. if(StringUtils.isNotEmpty(param)){
  918. Arrays.stream(param.split(",")).forEach(s->{
  919. list.add(s.replaceAll("[E\\[\\]']",""));
  920. });
  921. }
  922. return list;
  923. }
  924. /**从时间段中获取最后一个日期*/
  925. static final String RANGE_DATE_REG="^\\[(\\d{4}[年.\\-]\\d{2}[月.\\-]\\d{2}[日]?),\\s+(\\d{4}[年.\\-]\\d{2}[月.\\-]\\d{2}[日]?)]$";
  926. public static String range2end(String t){
  927. if(t!=null&&Pattern.matches(RANGE_DATE_REG,t)){
  928. t=t.replaceAll("^\\[|]$","").split(",")[1].trim();
  929. }
  930. return t;
  931. }
  932. public static List<String> duration2date(String duration){
  933. try {
  934. if (duration != null && Pattern.matches(RANGE_DATE_REG, duration)) {
  935. return Arrays.stream(duration.replaceAll("^\\[|]$", "").split(",")).map(String::trim).map(s -> new DateTime(s).toString(DatePattern.NORM_DATE_PATTERN)).collect(Collectors.toList());
  936. }
  937. return Collections.singletonList(new DateTime(duration).toString(DatePattern.NORM_DATE_PATTERN));
  938. }catch (Exception e){
  939. return Collections.singletonList(new DateTime().toString(DatePattern.NORM_DATE_PATTERN));
  940. }
  941. }
  942. public static FormData createFormDataFast(String name,String code,String values,String coords){
  943. if(StringUtils.isNotEmpty(code,name)){
  944. if(StringUtils.isNotEmpty(coords)) {
  945. /*定位信息存在才合法*/
  946. List<Coords> coordsList = Stream.of(coords).flatMap(s -> Arrays.stream(s.split(";"))).map(s -> {
  947. String[] xy = s.split("_");
  948. return new Coords(xy[1], xy[0]);
  949. }).collect(Collectors.toList());
  950. List<ElementData> eds = new ArrayList<>();
  951. if (StringUtils.isNotEmpty(values)) {
  952. String[] pages = values.split(";;");
  953. for (int index = 0; index < pages.length; index++) {
  954. String pg = pages[index];
  955. if (Func.isNotBlank(pg)) {
  956. String[] val = pg.split("☆");
  957. Map<String, Object> tmpMap = new LinkedHashMap<>();
  958. for (String s : val) {
  959. String[] t = s.split("_\\^_");
  960. String[] c = t[1].split("_");
  961. tmpMap.put(StringUtils.join(code, 0, index, Func.toInt(c[1]), Func.toInt(c[0]), StringPool.AT), t[0]);
  962. }
  963. for (Coords c : coordsList) {
  964. Object data = null;
  965. String key = StringUtils.join(code, 0, index, c.getX(), c.getY(), StringPool.AT);
  966. if (tmpMap.containsKey(key)) {
  967. data = tmpMap.get(key);
  968. }
  969. eds.add(new ElementData(index, 0, data, c.getX(), c.getY()));
  970. }
  971. }
  972. }
  973. } else {
  974. eds = coordsList.stream().map(c -> new ElementData(0, 0, null, c.getX(), c.getY())).collect(Collectors.toList());
  975. }
  976. FormData one = new FormData(code, eds, null, coords);
  977. one.setEName(name);
  978. /*备份原始数据,用于更新比较*/
  979. one.init();
  980. return one;
  981. }
  982. }
  983. return null;
  984. }
  985. public static void mainT(String[] args) throws IOException {
  986. XYSeries series = new XYSeries("Data Series");
  987. series.add(10.2, 1.82);
  988. series.add(11.9, 1.86);
  989. series.add(15.9, 1.87);
  990. series.add(19.3, 1.85);
  991. series.add(20.3, 1.80);
  992. XYSeriesCollection dataset = new XYSeriesCollection();
  993. dataset.addSeries(series);
  994. JFreeChart chart = ChartFactory.createXYLineChart(
  995. "测试散点图", // 标题
  996. "X", // 横轴标题
  997. "Y", // 纵轴标题
  998. dataset, // 数据集
  999. PlotOrientation.VERTICAL, // 图表方向
  1000. true, // 是否显示图例
  1001. false, // 是否生成工具提示
  1002. false // 是否生成URL链接
  1003. );
  1004. // 设置字体
  1005. Font titleFont = new Font("SimSun", Font.PLAIN, 18); // 指定使用宋体字体
  1006. Font axisFont = new Font("SimSun", Font.PLAIN, 12); // 指定使用宋体字体
  1007. // 设置标题字体
  1008. TextTitle title = chart.getTitle();
  1009. title.setFont(titleFont);
  1010. XYPlot plot = (XYPlot) chart.getPlot();
  1011. XYSplineRenderer renderer = new XYSplineRenderer();
  1012. plot.setRenderer(renderer);
  1013. plot.setBackgroundPaint(Color.WHITE);
  1014. // Set the line stroke and shape for the renderer
  1015. renderer.setSeriesStroke(0, new BasicStroke(2.0f));
  1016. Shape circle = new Ellipse2D.Double(-3, -3, 6, 6);
  1017. renderer.setSeriesShape(0, circle);
  1018. renderer.setSeriesPaint(0, Color.BLUE);
  1019. // 自定义 X 轴刻度
  1020. NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
  1021. domainAxis.setTickUnit(new NumberTickUnit(5)); // 设置刻度间隔
  1022. domainAxis.setRange(0.0, 25); // 设置轴的范围
  1023. // 自定义 Y 轴刻度
  1024. NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  1025. rangeAxis.setTickUnit(new NumberTickUnit(0.01)); // 设置刻度间隔
  1026. rangeAxis.setRange(1.79, 1.90); // 设置轴的范围
  1027. // 添加横杠
  1028. for(int i=175;i<190;i++){
  1029. ValueMarker marker = new ValueMarker((double) i /100);
  1030. marker.setPaint(Color.BLUE); // 横杠的颜色
  1031. plot.addRangeMarker(marker);
  1032. }
  1033. ChartPanel chartPanel = new ChartPanel(chart);
  1034. chartPanel.setPreferredSize(new Dimension(500, 400));
  1035. // 保存图表为图片
  1036. int width = 800;
  1037. int height = 600;
  1038. ChartUtils.saveChartAsPNG(new File("C:/Users/yangyj/Desktop/Swap_space/poi_statistics.png"), chart, width, height);
  1039. }
  1040. /**字符串sha256映射*/
  1041. public static String sha256(String input) {
  1042. try {
  1043. MessageDigest digest = MessageDigest.getInstance("SHA-256");
  1044. byte[] encodedHash = digest.digest(input.getBytes(StandardCharsets.UTF_8));
  1045. StringBuilder hexString = new StringBuilder();
  1046. for (byte b : encodedHash) {
  1047. String hex = Integer.toHexString(0xff & b);
  1048. if (hex.length() == 1) {
  1049. hexString.append('0');
  1050. }
  1051. hexString.append(hex);
  1052. }
  1053. return hexString.toString();
  1054. } catch (NoSuchAlgorithmException e) {
  1055. e.printStackTrace();
  1056. }
  1057. return "";
  1058. }
  1059. /**根据步长获取字符*/
  1060. public static String getEveryNthChar(String input, int step) {
  1061. StringBuilder result = new StringBuilder();
  1062. for (int i = 0; i < input.length(); i += step) {
  1063. result.append(input.charAt(i));
  1064. }
  1065. return result.toString();
  1066. }
  1067. /**最大循环次数*/
  1068. public static int MAX_LOOP=20;
  1069. /**
  1070. * @Description 当前提交表单数据公式执行最小影响元素范围
  1071. * @Param [curTableNames:当前提交页面对应表编号, processFds:当前工序包含的所有元素]
  1072. * @Author yangyj
  1073. * @Date 2023.10.09 15:26
  1074. **/
  1075. public static List<FormData> registerFd(List<String> curTableNames, List<FormData> processFds){
  1076. Map<Boolean,List<FormData>> group = processFds.stream().collect(Collectors.partitioningBy(e->curTableNames.contains(e.getTableName())));
  1077. List<FormData> curFormDatas =group.get(true);
  1078. /*提交叶包含元素*/
  1079. List<FormData> initiator= new ArrayList<>(curFormDatas);
  1080. List<FormData> other=group.get(false);
  1081. /*当前提交页元素影响到的元素都要重新执行公式*/
  1082. pick(curFormDatas,other,curFormDatas,fds->fds.stream().map(FormData::getCode).collect(Collectors.toSet()));
  1083. /*当前提交页的元素公式依赖加载*/
  1084. pick(initiator,other,curFormDatas,fds->fds.stream().filter(f->f.executable()&&f.getFormula().getRely()!=null).flatMap(f->f.getFormula().getRelyList().stream()).collect(Collectors.toSet()));
  1085. return curFormDatas;
  1086. }
  1087. /**
  1088. * @Description 调训符合条件的元素
  1089. * @Param [initiator 初始集合, other 待选集合, curFormDatas 结果集, function:挑选方法]
  1090. * @Author yangyj
  1091. * @Date 2023.10.12 14:53
  1092. **/
  1093. public static void pick(List<FormData> initiator,List<FormData> other,List<FormData> curFormDatas ,Function<List<FormData>,Set<String>> function){
  1094. List<FormData> curFormDatasAdd=new ArrayList<>(initiator);
  1095. int loop=0;
  1096. do{
  1097. loop++;
  1098. Set<String> codeSet= function.apply(curFormDatasAdd);
  1099. Map<Boolean,List<FormData>> groupTmp = other.stream().collect(Collectors.partitioningBy(e->codeSet.contains(e.getCode())));
  1100. curFormDatasAdd=groupTmp.get(true);
  1101. if(curFormDatasAdd.isEmpty()){
  1102. loop=MAX_LOOP;
  1103. }else{
  1104. curFormDatas.addAll(curFormDatasAdd);
  1105. }
  1106. other=groupTmp.get(false);
  1107. }while (!other.isEmpty()&&loop<MAX_LOOP);
  1108. }
  1109. /**最小加载页面,只要包含当前提交元素的页面都需要加载*/
  1110. public static Map<String,List<Long>> relatedPages(List<FormData> curFormDatas ,List<NodeTable> tableAll){
  1111. Set<String> initTableNames= curFormDatas.stream().map(FormData::getTableName).collect(Collectors.toSet());
  1112. return tableAll.stream().filter(e->initTableNames.contains(e.getInitTableName())).collect(Collectors.groupingBy(NodeTable::getInitTableName,Collectors.mapping(NodeTable::getPKeyId,Collectors.toList())));
  1113. }
  1114. /*比较两组单元格内容是否一样*/
  1115. public static boolean compareElementDataList(List<ElementData> before ,List<ElementData> cur){
  1116. if(Func.isNotEmpty(before)&&Func.isNotEmpty(cur)&&before.size()==cur.size()){
  1117. String sa= before.stream().map(ElementData::stringValue).collect(Collectors.joining());
  1118. String sc= cur.stream().map(ElementData::stringValue).collect(Collectors.joining());
  1119. return sa.equals(sc);
  1120. }
  1121. return false;
  1122. }
  1123. /**分割treeCode*/
  1124. public static List<String> treeCodeSplit(String treeCode){
  1125. List<String> result = new ArrayList<>();
  1126. if(Func.isNotBlank(treeCode)){
  1127. /*字符总长度*/
  1128. int max =treeCode.length()-3,
  1129. /*累计字符长度字符*/
  1130. sum=0,
  1131. /*第几次循环*/
  1132. count=0;
  1133. do{
  1134. result.add(treeCode.substring(0, sum+=Math.min(3,++count)));
  1135. }while (sum<max&&count<MAX_LOOP);
  1136. }
  1137. return result;
  1138. }
  1139. /* public static void main(String[] args) {
  1140. System.out.println(milestone("k8+120.23"));
  1141. }*/
  1142. /*从测点名称中获取里程*/
  1143. public static Double milestone(String s){
  1144. Pattern pattern=Pattern.compile("(?i)K(\\d+)\\+([\\d.]+)");
  1145. Matcher matcher = pattern.matcher(s);
  1146. if(matcher.find()){
  1147. return Double.parseDouble(matcher.group(1))*1000+ Double.parseDouble(matcher.group(2));
  1148. }
  1149. return null;
  1150. }
  1151. public static void sort( List<FormData> list,int n){
  1152. /*System.out.println("剩余计算次数:"+n+"次");*/
  1153. if(move(list)&&n>0){
  1154. sort(list,--n);
  1155. }
  1156. }
  1157. public static Boolean move( List<FormData> list){
  1158. for(int i=0;i<list.size();i++){
  1159. FormData f=list.get(i);
  1160. Matcher m =P.matcher(f.getFormula().getFormula());
  1161. List<String> cp = new ArrayList<>();
  1162. while (m.find()){
  1163. cp.add(m.group());
  1164. }
  1165. Map<Boolean,List<FormData>> map= list.stream().skip(i+1).collect(Collectors.partitioningBy(e->cp.contains(e.getCode())));
  1166. List<FormData> match =map.get(true);
  1167. if(CollectionUtil.isNotEmpty(match)){
  1168. for(FormData r:match){
  1169. list.remove(r);
  1170. }
  1171. list.addAll(0,match);
  1172. return true;
  1173. }
  1174. }
  1175. return false;
  1176. }
  1177. public static void relyParse(Formula f){
  1178. if(Func.isNotBlank(f.getFormula())){
  1179. List<String> l = new ArrayList<>();
  1180. Matcher m = P.matcher(f.getFormula());
  1181. while (m.find()){
  1182. String tmp =m.group().replaceAll("'","");
  1183. String cp=tmp;
  1184. if(tmp.indexOf(StringPool.COLON)!=tmp.lastIndexOf(StringPool.COLON)){
  1185. tmp=tmp.substring(tmp.indexOf(":")+1);
  1186. /*移除跨节点标识*/
  1187. f.setFormula(f.getFormula().replace(cp,tmp));
  1188. }
  1189. l.add(tmp);
  1190. }
  1191. if(l.size()>0){
  1192. f.setRely(String.join(",", l));
  1193. }else{
  1194. f.setRely("");
  1195. }
  1196. }
  1197. }
  1198. /*复制表页*/
  1199. public static WbsTreeContract copyPage(WbsTreeContract origin){
  1200. WbsTreeContract target = new WbsTreeContract();
  1201. BeanUtil.copy(origin, target);
  1202. target.setPKeyId(SnowFlakeUtil.getId());
  1203. target.setCreateTime(new Date());
  1204. String nodeName = origin.getNodeName();
  1205. String[] oldName = nodeName.split("__");
  1206. if (oldName.length>1) {
  1207. nodeName = oldName[0] + "__" + (Integer.parseInt(oldName[1]) + 1);
  1208. } else {
  1209. nodeName = nodeName + "__" + 1;
  1210. }
  1211. target.setNodeName(nodeName);
  1212. target.setIsCopeTab(2);
  1213. target.setIsTabPdf(1); // pdf 不能预览
  1214. target.setIsBussShow(1); // 是否隐藏表
  1215. target.setTabFileType(1);//没有上传附件
  1216. target.setPdfUrl("");
  1217. return target;
  1218. }
  1219. public static String recovery(List<ElementData> dataList) {
  1220. if (Func.isNotEmpty(dataList)) {
  1221. return dataList.stream().filter(e -> !e.isEmpty()).map(e -> e.stringValue() + "_^_" + e.getY() + "_" + e.getX()).collect(Collectors.joining("☆"));
  1222. }
  1223. return "";
  1224. }
  1225. private static final Map<Character, Integer> CHINESE_TO_ARABIC = new HashMap<>();
  1226. static {
  1227. CHINESE_TO_ARABIC.put('零', 0);
  1228. CHINESE_TO_ARABIC.put('一', 1);
  1229. CHINESE_TO_ARABIC.put('二', 2);
  1230. CHINESE_TO_ARABIC.put('三', 3);
  1231. CHINESE_TO_ARABIC.put('四', 4);
  1232. CHINESE_TO_ARABIC.put('五', 5);
  1233. CHINESE_TO_ARABIC.put('六', 6);
  1234. CHINESE_TO_ARABIC.put('七', 7);
  1235. CHINESE_TO_ARABIC.put('八', 8);
  1236. CHINESE_TO_ARABIC.put('九', 9);
  1237. CHINESE_TO_ARABIC.put('十', 10);
  1238. CHINESE_TO_ARABIC.put('百', 100);
  1239. CHINESE_TO_ARABIC.put('千', 1000);
  1240. CHINESE_TO_ARABIC.put('万', 10000);
  1241. }
  1242. public static int chineseToArabic(String chineseNumber) {
  1243. int result = 0;
  1244. int multiplier = 1;
  1245. for (int i = chineseNumber.length() - 1; i >= 0; i--) {
  1246. char c = chineseNumber.charAt(i);
  1247. if (CHINESE_TO_ARABIC.containsKey(c)) {
  1248. int value = CHINESE_TO_ARABIC.get(c);
  1249. if(value!=0&&value%10==0&&i!=0){
  1250. multiplier=value;
  1251. }else{
  1252. result=result+value*multiplier;
  1253. }
  1254. } else {
  1255. throw new IllegalArgumentException("Invalid Chinese numeral: " + c);
  1256. }
  1257. }
  1258. return result;
  1259. }
  1260. /*public static void main(String[] args) {
  1261. *//* System.out.println(chineseToArabic("二十九"));
  1262. System.out.println(chineseToArabic("一"));
  1263. System.out.println(chineseToArabic("十一"));*//*
  1264. System.out.println(chineseToArabic("十"));
  1265. *//* System.out.println(chineseToArabic("一百二十"));
  1266. System.out.println(chineseToArabic("一百二十二"));
  1267. System.out.println(chineseToArabic("一百零二"));*//*
  1268. }*/
  1269. /*获取引用code的元素*/
  1270. public static Stream<FormData> beRelyFrom( Map<String, FormData> formDataMap ,String code){
  1271. return formDataMap.values().stream().filter(e->e.executable()&& code.equals(e.getFormula().getRely()));
  1272. }
  1273. /*根据code查找元素 */
  1274. public static Optional<FormData> elementFindByCode( Map<String, FormData> formDataMap ,String code){
  1275. return formDataMap.values().stream().filter(e->code.equals(e.getCode())).findAny();
  1276. }
  1277. public static List<TableInfo> getTableInfoList(JSONArray dataArray) {
  1278. if (dataArray != null && !dataArray.isEmpty()) {
  1279. List<TableInfo> result = new ArrayList<>();
  1280. for (int m = 0; m < dataArray.size(); m++) {
  1281. TableInfo tableInfo = new TableInfo();
  1282. com.alibaba.fastjson.JSONObject dataInfo2 = dataArray.getJSONObject(m);
  1283. //
  1284. tableInfo.setContractId(dataInfo2.getString("contractId"));
  1285. tableInfo.setPkeyId(dataInfo2.getString("pkeyId"));
  1286. tableInfo.setProjectId(dataInfo2.getString("projectId"));
  1287. //huangjn 填报的类型,施工或监理
  1288. tableInfo.setClassify(dataInfo2.getString("classify"));
  1289. //设置首件信息
  1290. setFirstData(dataInfo2, tableInfo);
  1291. //设置日志信息
  1292. setTheLogData(dataInfo2, tableInfo);
  1293. dataInfo2.fluentRemove("contractId")
  1294. .fluentRemove("pkeyId")
  1295. .fluentRemove("p_key_id")
  1296. .fluentRemove("projectId")
  1297. .fluentRemove("classify")
  1298. .fluentRemove("pickerKey")
  1299. .fluentRemove("id")
  1300. .fluentRemove("isFirst")
  1301. .fluentRemove("firstNodeId")
  1302. .fluentRemove("isTheLog")
  1303. .fluentRemove("theLogId")
  1304. .fluentRemove("linkTabIds")
  1305. .fluentRemove("recordTime")
  1306. .fluentRemove("businessId")
  1307. .fluentRemove("sourceUrl")
  1308. .fluentRemove("pdfUrl")
  1309. .fluentRemove("firstFileName")
  1310. .fluentRemove("");
  1311. // 计算数据
  1312. LinkedHashMap<String, List<String>> dataMap = dataInfo2.keySet().stream().filter(e -> e.contains("__")).collect(Collectors.groupingBy(e -> e.split("__")[0], LinkedHashMap<String, List<String>>::new, Collectors.toList()));
  1313. LinkedHashMap<String, String> dataMap2 = new LinkedHashMap<>();
  1314. // 字段组合
  1315. for (String k : dataMap.keySet()) {
  1316. if (dataMap.get(k).size() > 1 && !dataMap.get(k).contains("000Z")) {
  1317. String[] ziduan = dataMap.get(k).toArray(new String[]{});
  1318. String temp = "";
  1319. for (int i = 0; i < ziduan.length - 1; i++) {
  1320. for (int j = 0; j < ziduan.length - i - 1; j++) {
  1321. Integer tr = Integer.parseInt((ziduan[j].split("__")[1]).split("_")[0]);
  1322. Integer td = Integer.parseInt(ziduan[j].split("__")[1].split("_")[1]);
  1323. Integer tr_1 = Integer.parseInt(ziduan[j + 1].split("__")[1].split("_")[0]);
  1324. Integer td_1 = Integer.parseInt(ziduan[j + 1].split("__")[1].split("_")[1]);
  1325. if (tr > tr_1 && td.equals(td_1)) { //纵向排序
  1326. temp = ziduan[j];
  1327. ziduan[j] = ziduan[j + 1];
  1328. ziduan[j + 1] = temp;
  1329. }
  1330. }
  1331. }
  1332. String lastStr = dataInfo2.getString(ziduan[0]) + "_^_" + ziduan[0].split("__")[1];
  1333. for (int i = 1; i < ziduan.length; i++) {
  1334. String keyData = dataInfo2.getString(ziduan[i]);
  1335. if (org.apache.commons.lang.StringUtils.isNotEmpty(keyData) && !keyData.equals("")) {
  1336. lastStr += "☆" + dataInfo2.getString(ziduan[i]) + "_^_" + ziduan[i].split("__")[1];
  1337. }
  1338. }
  1339. dataMap2.put(k, lastStr);
  1340. } else {
  1341. String dataVal = dataInfo2.getString(dataMap.get(k).get(0));
  1342. if (org.apache.commons.lang.StringUtils.isNotEmpty(dataVal)) {
  1343. if (dataVal.contains("Ljava")) {
  1344. Object o = dataInfo2.get(dataMap.get(k).get(0));
  1345. dataVal = JSON.toJSONString(o).replace("\"", "");
  1346. }
  1347. dataMap2.put(k, dataVal + "_^_" + dataMap.get(k).get(0).split("__")[1]);
  1348. }
  1349. }
  1350. }
  1351. dataInfo2.put("p_key_id", tableInfo.getPkeyId());
  1352. dataInfo2.put("classify",tableInfo.getClassify());
  1353. dataInfo2.put("contractId",tableInfo.getContractId());
  1354. dataInfo2.put("projectId",tableInfo.getProjectId());
  1355. tableInfo.setDataMap(dataMap2);
  1356. result.add(tableInfo);
  1357. }
  1358. return result;
  1359. }
  1360. return null;
  1361. }
  1362. public static void setFirstData(com.alibaba.fastjson.JSONObject dataInfo2, TableInfo tableInfo) {
  1363. //huangjn 判断是否是首件
  1364. if (dataInfo2.containsKey("isFirst")) {
  1365. tableInfo.setIsFirst(dataInfo2.getString("isFirst"));
  1366. }
  1367. //huangjn 判断是否是首件
  1368. //首件资料绑定的节点
  1369. if (dataInfo2.containsKey("firstNodeId")) {
  1370. tableInfo.setFirstNodeId(dataInfo2.getString("firstNodeId"));
  1371. }
  1372. //首件ID(编辑时有值,新增时为空)
  1373. if (dataInfo2.containsKey("firstId")) {
  1374. tableInfo.setFirstId(dataInfo2.getString("firstId"));
  1375. }
  1376. //源文件
  1377. if (dataInfo2.containsKey("sourceUrl")) {
  1378. tableInfo.setSourceUrl(dataInfo2.getString("sourceUrl"));
  1379. }
  1380. //pdfUrl
  1381. if (dataInfo2.containsKey("pdfUrl")) {
  1382. tableInfo.setPdfUrl(dataInfo2.getString("pdfUrl"));
  1383. }
  1384. //文件名称
  1385. if (dataInfo2.containsKey("firstFileName")) {
  1386. tableInfo.setFirstFileName(dataInfo2.getString("firstFileName"));
  1387. }
  1388. //关联的信息
  1389. if (dataInfo2.containsKey("linkProcessList")) {
  1390. tableInfo.setLinkProcessList(dataInfo2.getJSONArray("linkProcessList"));
  1391. }
  1392. }
  1393. public static void setTheLogData(JSONObject dataInfo2, TableInfo tableInfo) {
  1394. //huangjn 判断是否是日志
  1395. if (dataInfo2.containsKey("isTheLog")) {
  1396. tableInfo.setIsTheLog(dataInfo2.getString("isTheLog"));
  1397. }
  1398. //huangjn 判断是否是日志
  1399. //huangjn 日志ID
  1400. if (dataInfo2.containsKey("theLogId")) {
  1401. tableInfo.setTheLogId(dataInfo2.getString("theLogId"));
  1402. }
  1403. //huangjn 日志ID
  1404. //huangjn 日志勾选的工序
  1405. if (dataInfo2.containsKey("linkTabIds")) {
  1406. tableInfo.setLinkTabIds(dataInfo2.getJSONArray("linkTabIds"));
  1407. }
  1408. //huangjn 日志勾选的工序
  1409. //huangjn 日志所选时间
  1410. if (dataInfo2.containsKey("recordTime")) {
  1411. tableInfo.setRecordTime(dataInfo2.getString("recordTime"));
  1412. }
  1413. //huangjn 日志所选时间
  1414. //huangjn 每份填报数据的id,目前日志专用
  1415. if (dataInfo2.containsKey("id")) {
  1416. tableInfo.setBusinessId(dataInfo2.getString("id"));
  1417. }
  1418. //huangjn 每份填报数据的id,目前日志专用
  1419. }
  1420. }