|
@@ -1130,31 +1130,39 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
private void updateRecordNoOrReportNo(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
|
|
private void updateRecordNoOrReportNo(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
|
|
JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
|
|
JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
|
|
//获取第一张表的数据 编号以第一张表为准
|
|
//获取第一张表的数据 编号以第一张表为准
|
|
- JSONObject jsonObject = dataArray.getJSONObject(0);
|
|
|
|
- String pkeyId = jsonObject.getString("pkeyId");
|
|
|
|
- String sql = "select * from m_wbs_tree_private where p_key_id =" + pkeyId;
|
|
|
|
- WbsTreePrivate table = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
|
- String fileUrl = table.getHtmlUrl();
|
|
|
|
- try {
|
|
|
|
- InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
|
- String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
|
- htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
|
- Document doc = Jsoup.parse(htmlString);
|
|
|
|
- // 查找所有具有 placeholderxx 属性的元素
|
|
|
|
- //表类型 1,9=记录表 2,10=报告单
|
|
|
|
- if(table.getTableType() == 9 || table.getTableType() == 1){
|
|
|
|
- //记录表 以第一张表为准
|
|
|
|
- this.updateRecordNoOrReportNo(dto, jsonObject, doc, "记录编 号:", "record_no");
|
|
|
|
- this.updateRecordNoOrReportNo(dto, jsonObject, doc, "记录编号:", "record_no");
|
|
|
|
- }else if(table.getTableType() == 10 || table.getTableType() == 2){
|
|
|
|
- //报告单
|
|
|
|
- this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
|
|
|
|
- //:不一样 一个中文一个英文
|
|
|
|
- this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error(e.getMessage());
|
|
|
|
- }
|
|
|
|
|
|
+ List<JSONObject> dataList = dataArray.toJavaList(JSONObject.class);
|
|
|
|
+ // 根据 type 字段进行分组
|
|
|
|
+ Map<String, List<JSONObject>> groupedByType = dataList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(jsonObject -> jsonObject.getString("type")));
|
|
|
|
+ for (Map.Entry<String, List<JSONObject>> entry : groupedByType.entrySet()) {
|
|
|
|
+ List<JSONObject> jsonObjects = groupedByType.get(entry.getKey());
|
|
|
|
+ JSONObject jsonObject = jsonObjects.get(0);
|
|
|
|
+ String pkeyId = jsonObject.getString("pkeyId");
|
|
|
|
+ String sql = "select * from m_wbs_tree_private where p_key_id =" + pkeyId;
|
|
|
|
+ WbsTreePrivate table = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
|
+ String fileUrl = table.getHtmlUrl();
|
|
|
|
+ try {
|
|
|
|
+ InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ // 查找所有具有 placeholderxx 属性的元素
|
|
|
|
+ //表类型 1,9=记录表 2,10=报告单
|
|
|
|
+ if(table.getTableType() == 9 || table.getTableType() == 1){
|
|
|
|
+ //记录表 以第一张表为准
|
|
|
|
+ this.updateRecordNoOrReportNo(dto, jsonObject, doc, "记录编 号:", "record_no");
|
|
|
|
+ this.updateRecordNoOrReportNo(dto, jsonObject, doc, "记录编号:", "record_no");
|
|
|
|
+ }else if(table.getTableType() == 10 || table.getTableType() == 2){
|
|
|
|
+ //报告单
|
|
|
|
+ this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
|
|
|
|
+ // :不一样 一个中文一个英文
|
|
|
|
+ this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|