Browse Source

试验-接入成渝第三方接口开发
1、质检-节点附件排序功能问题处理

LHB 20 hours ago
parent
commit
bd3b9dc384

+ 7 - 2
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/TrialCyAccessoriesClientImpl.java

@@ -17,6 +17,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author LHB
@@ -40,13 +41,16 @@ public class TrialCyAccessoriesClientImpl implements TrialCyAccessoriesClient {
     @Override
     public List<JSONObject> getTrialFilePdfRecord(String primaryKeyId, List<Integer> list) {
         //获取id
-        List<String> trialFilePdfRecord = trialSelfInspectionRecordMapper.getTrialFilePdfRecord(primaryKeyId, list);
+        List<Map<String,Object>> trialFilePdfRecord = trialSelfInspectionRecordMapper.getTrialFilePdfRecord(primaryKeyId, list);
+        //
+        List<String> recordIds = trialFilePdfRecord.stream().map(f -> f.get("record_id").toString()).collect(Collectors.toList());
+        Map<String,Integer> map = trialFilePdfRecord.stream().collect(Collectors.toMap(f -> f.get("record_id").toString(), f -> Integer.valueOf(f.get("sort").toString())));
 
         if (CollectionUtil.isNotEmpty(trialFilePdfRecord)) {
 
             List<JSONObject> result = new ArrayList<>();
             if (CollectionUtil.isNotEmpty(trialFilePdfRecord)) {
-                List<Map<String,Object>> list1 = trialCyFinishTestReportService.selectViewList(trialFilePdfRecord);
+                List<Map<String,Object>> list1 = trialCyFinishTestReportService.selectViewList(recordIds);
                 if (CollectionUtil.isNotEmpty(list1)) {
                     list1.forEach(f -> {
                         String[] split = f.get("assembleFile").toString().split("/");
@@ -58,6 +62,7 @@ public class TrialCyAccessoriesClientImpl implements TrialCyAccessoriesClient {
                         jsonObject.put("domainPdfUrl", f.get("assembleFile"));
                         jsonObject.put("tabId", primaryKeyId);
                         jsonObject.put("extension", "pdf");
+                        jsonObject.put("sort", map.get(f.get("id").toString()) == null ? 9999 : map.get(f.get("id").toString()));
                         //是否为试验关联的附件
                         jsonObject.put("isTrial", true);
                         result.add(jsonObject);

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.java

@@ -46,6 +46,6 @@ public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfIns
     @Select("select self_id from u_trial_self_quality_project where quality_node_id = #{pKeyId}")
     List<String> selectTrialIdByNodeId(Long pKeyId);
 
-    List<String> getTrialFilePdfRecord(@Param("nodeId") String nodeId,
+    List<Map<String,Object>> getTrialFilePdfRecord(@Param("nodeId") String nodeId,
                                                    @Param("types") List<Integer> types);
 }

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml

@@ -108,8 +108,8 @@
             </if>
         </where>
     </select>
-    <select id="getTrialFilePdfRecord" resultType="java.lang.String">
-        select record_id from u_trial_file_pdf_record where node_id = #{nodeId} and `type` in
+    <select id="getTrialFilePdfRecord" resultType="java.util.Map">
+        select record_id,IFNULL(sort,9999) sort from u_trial_file_pdf_record where node_id = #{nodeId} and `type` in
        <foreach collection="types" item="type" open="(" close=")" separator=",">
            #{type}
        </foreach>

+ 9 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TableFileController.java

@@ -297,6 +297,15 @@ public class TableFileController extends BladeController {
                 for (TableFile file : list) {
                     file.setSort(i++);
                 }
+
+                //获取type为空的数据
+                List<TableFile> collect1 = list.stream().filter(f -> f.getType() == null).collect(Collectors.toList());
+                for (TableFile tableFile : collect1) {
+                    String sql = "update u_trial_file_pdf_record set sort = " + tableFile.getSort() + " where record_id = " + tableFile.getId()
+                            + " and node_id = " + vo.getPKeyId();
+                    jdbcTemplate.update(sql);
+                }
+                //修改
             }
             tableFileService.updateBatchById(list);
         }

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -1489,6 +1489,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 voList.add(vo);
             }
         }
+        voList.stream().filter(f -> CollectionUtil.isNotEmpty(f.getFileList())).forEach(f -> {
+            f.setFileList(f.getFileList().stream().sorted(Comparator.comparing(TableFile::getSort)).collect(Collectors.toList()));
+        });
         return voList;
     }