فهرست منبع

导入实时性

cr 2 روز پیش
والد
کامیت
8ab6e7aaf3

+ 20 - 19
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -3212,9 +3212,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 String sqlList1 = "Select parent_id,node_name,p_id from m_wbs_tree_contract where contract_id=" + wbsTreeContractRoot.getContractId() + " and wbs_id=" + wbsTreeContractRoot.getWbsId() + " and is_deleted=0";
                 List<WbsTreeContract> WbsTreeContractList = jdbcTemplate.query(sqlList1, new BeanPropertyRowMapper<>(WbsTreeContract.class));
                 for (ImportTreeDto dto : list) {
-                    double v = ((double) i/ size) * 100;
-                    if(v<100){
-                        String progressStr = String.format("%.2f", v);
+                    if(i!=size){
+                        String progressStr = String.format("%.2f", ((double) i/ size));
                         bladeRedis.set("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), progressStr);
                     }
                     i++;
@@ -3518,27 +3517,29 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                     e.printStackTrace();
                 }
             }
-            if(!insertList.isEmpty()){
-                int x=insertList.size()/5;
-                int y=0;
-                boolean flag=true;
-                while (flag){
-                    y++;
-                    Thread.sleep(5000);
-                    Integer importSize=baseMapper.selectImportSize(importId);
-                    if(importSize==insertList.size()||y==x){
-                       flag=false;
-                   }
-                }
-            }
+//            if(!insertList.isEmpty()){
+//                int x=insertList.size()/5;
+//                int y=0;
+//                boolean flag=true;
+//                while (flag){
+//                    y++;
+//                    Thread.sleep(5000);
+//                    Integer importSize=baseMapper.selectImportSize(importId);
+//                    if(importSize==insertList.size()||y==x){
+//                       flag=false;
+//                   }
+//                }
+//            }
             bladeRedis.setEx("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), "100",7L);
             return R.success("新增了" + insertList.size() + "个节点" + "," + String.join(",", updateList) + "节点编号已被修改");
         } catch (IOException e) {
             bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
             return R.fail("文件处理失败: " + e.getMessage());
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        }finally {
+        }
+//        catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        }
+        finally {
             bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
         }
     }