Browse Source

Merge remote-tracking branch 'origin/dev' into dev

LHB 2 days ago
parent
commit
f076133b39

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

@@ -2974,7 +2974,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public R importTree(MultipartFile file, Long pkeyId) throws IOException {
         //最高节点
         WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, pkeyId));
@@ -3143,10 +3142,11 @@ 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) {
-                    String progressStr = String.format("%.2f", ((double) i / size) * 100);
-                    bladeRedis.set("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), progressStr);
+                    if(size-i>=1){
+                        String progressStr = String.format("%.2f", ((double) i/ size)*100);
+                        bladeRedis.set("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), progressStr);
+                    }
                     i++;
-                    //新增
                     //单位工程:如果没有被处理过,说明需要新增
                     if (!dto.getIsUnit()) {
                         //检测是否已经存在,如果存在,就不需要新增了
@@ -3447,29 +3447,28 @@ 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 {
-            bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
         }
+//        catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        }
     }
 
     @Override