Sfoglia il codice sorgente

天气台账jsoup版本问题和超时,资料填报资料排序

qianxb 1 anno fa
parent
commit
a35368970f

+ 1 - 0
blade-service/blade-business/pom.xml

@@ -153,6 +153,7 @@
         <dependency>
             <groupId>org.jsoup</groupId>
             <artifactId>jsoup</artifactId>
+            <version>1.10.2</version>
         </dependency>
 
     </dependencies>

+ 11 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/WeatherInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.hankcs.hanlp.dictionary.py.Pinyin;
 import com.hankcs.hanlp.dictionary.py.PinyinDictionary;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.jsoup.Connection;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -209,11 +210,17 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
                 if (duration.toDays() > 0){
                     List<WeatherInfo> list = new ArrayList<>();
                     Map<String, Map<String, String>> weatherMap = null;
+                    if (projectContractArea.getCounty().length() <= 1){
+                        continue;
+                    }
                     List<Pinyin> py = PinyinDictionary.convertToPinyin(projectContractArea.getCounty().substring(0, projectContractArea.getCounty().length() - 1));
                     StringBuilder county = new StringBuilder();
                     for (int i = 0; i < py.size(); i++) {
                         county.append(py.get(i).getPinyinWithoutTone());
                     }
+                    if (projectContractArea.getCity().length() <= 1){
+                        continue;
+                    }
                     List<Pinyin> py2 = PinyinDictionary.convertToPinyin(projectContractArea.getCity().substring(0, projectContractArea.getCity().length() - 1));
                     StringBuilder city = new StringBuilder();
                     for (int i = 0; i < py2.size(); i++) {
@@ -252,7 +259,10 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
         Map<String,Map<String,String>> map = new HashMap<>();
         Document document = null;
         try {
-            document = Jsoup.connect(html).get();
+            System.out.println(html);
+            Connection connect = Jsoup.connect(html);
+            connect.timeout(20000);
+            document = connect.get();
             Element body = document.body();
             Elements table = body.getElementsByTag("table");
             Elements trs = table.select("tr");

+ 30 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -20,7 +20,9 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 @RestController
 @AllArgsConstructor
@@ -36,6 +38,33 @@ public class WbsTreeContractController extends BladeController {
     @ApiOperation(value = "查询当前节点下所有元素表信息", notes = "传入节点primaryKeyId、type、合同段id、项目id")
     public R searchNodeAllTable(String primaryKeyId, String type, String contractId, String projectId) {
         List<AppWbsTreeContractVO> list = iWbsTreeContractService.searchNodeAllTable(primaryKeyId, type, contractId, projectId);
+        boolean flag = false;
+        Set<Long> l1 = new HashSet<>();
+        for (AppWbsTreeContractVO vo : list) {
+            if (vo.getNodeName().contains("_PL_")){
+                l1.add(vo.getId());
+                flag = true;
+            }
+        }
+        if (flag){
+            for (Long aLong : l1) {
+                List<AppWbsTreeContractVO> vos = new ArrayList<>();
+                for (AppWbsTreeContractVO vo : list) {
+                    if (aLong.equals(vo.getId())){
+                        vos.add(vo);
+                    }
+                }
+                list = list.stream().filter(l -> {
+                    if (l.getId().equals(aLong)){
+                        return false;
+                    }else {
+                        return true;
+                    }
+                }).collect(Collectors.toList());
+                vos = vos.stream().sorted(Comparator.comparing(AppWbsTreeContractVO::getPKeyId)).collect(Collectors.toList());
+                list.addAll(vos);
+            }
+        }
         if (list.size() > 0) {
             list.stream().forEach(l->{
                 if (StringUtils.isNotBlank(l.getHtmlUrl())){