|
@@ -199,13 +199,55 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
Map<String, Object> reData = new HashMap<>();
|
|
|
//获取表单数据
|
|
|
List<Map<String, Object>> mapList = baseMapper.getBussDataInfo(linkId);
|
|
|
- //表单没有保存过
|
|
|
- if (mapList == null || mapList.size() == 0){
|
|
|
- return R.data(null);
|
|
|
+ //表单保存过才获取数据
|
|
|
+ if (mapList != null && mapList.size() > 0){
|
|
|
+ reData = mapList.stream().collect(
|
|
|
+ Collectors.toMap(map1 -> (String) map1.get("tableKey"),
|
|
|
+ map2 -> map2.get("tableValue")));
|
|
|
+ }
|
|
|
+ //需要自动生成的字典集合,项目名称197
|
|
|
+ List<Integer> buildDict = Arrays.asList(197);
|
|
|
+ //获取当前表单
|
|
|
+ AgreementLinkTable linkTable = linkTableService.getById(linkId);
|
|
|
+ //获取当前表单配置字典
|
|
|
+ List<WbsFormElement> tableElement = baseMapper.getTableElement(Arrays.asList(linkTable.getTableId()));
|
|
|
+ Map<Integer, List<WbsFormElement>> map = tableElement.stream().collect(Collectors.groupingBy(WbsFormElement::getDynamicDict));
|
|
|
+ List<Integer> list = tableElement.stream().map(l -> l.getDynamicDict()).collect(Collectors.toList());
|
|
|
+ //获取当前表单内需要自动生成的字典
|
|
|
+ list.retainAll(buildDict);
|
|
|
+ //如果配置字典中包含需要自动生成的数据,才去执行
|
|
|
+ if (list.size() > 0) {
|
|
|
+ Document doc = null;
|
|
|
+ try {
|
|
|
+ doc = Jsoup.parse(new File(linkTable.getHtmlUrl()), "utf-8");
|
|
|
+// doc = Jsoup.parse(new File("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html"), "utf-8");
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new ServiceException("解析表单html出错");
|
|
|
+ }
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ //因为当前配置的key不会重复,所以直接转map
|
|
|
+ Map<String,String> tableKeys = new HashMap<>();
|
|
|
+ table.getElementsByAttribute("id").stream().forEach(l -> {
|
|
|
+ String s = l.attr("id");
|
|
|
+ if (s.contains("__")) {
|
|
|
+ String[] s1 = s.split("__");
|
|
|
+ tableKeys.put(s1[0], s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (Integer dict : list) {
|
|
|
+ //解析当前所有的位置
|
|
|
+ String eKey = map.get(dict).get(0).getEKey();
|
|
|
+ String key = tableKeys.get(eKey);
|
|
|
+ //根据字典设置表单值
|
|
|
+ switch (dict){
|
|
|
+ case 197 :
|
|
|
+ //项目名称
|
|
|
+ String projectName = jdbcTemplate.queryForObject("select project_name from m_project_info where id = " + linkTable.getProjectId(), String.class);
|
|
|
+ reData.put(key,projectName);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- reData = mapList.stream().collect(
|
|
|
- Collectors.toMap(map1 -> (String) map1.get("tableKey"),
|
|
|
- map2 -> map2.get("tableValue")));
|
|
|
return R.data(reData);
|
|
|
}
|
|
|
|