Przeglądaj źródła

修复一些问题

ximinghao 1 miesiąc temu
rodzic
commit
780c517c5a

+ 60 - 46
src/main/java/com/skyversation/xjcy/computer/EnterpriseHealthComputerV2.java

@@ -89,17 +89,18 @@ public class EnterpriseHealthComputerV2 {
             result.healthItems = checkHealthItems(result);
         }
     }
+
     public List<JSONObject> getUpdateJSON() {
-        if (results.isEmpty())compute();
+        if (results.isEmpty()) compute();
         List<JSONObject> updateJSON = new ArrayList<>();
-        for (Result result : results){
+        for (Result result : results) {
             String sourceCQyfx = result.enterprise.getCQyfx();
-            Set<HealthItem> sourceHealth =  HealthItem.fromDmsData(sourceCQyfx);
+            Set<HealthItem> sourceHealth = HealthItem.fromDmsData(sourceCQyfx);
             Set<HealthItem> targetHealth = result.healthItems;
-            if (!sourceHealth.equals(targetHealth)){
+            if (!sourceHealth.equals(targetHealth)) {
                 JSONObject jsonObject = new JSONObject();
                 jsonObject.put("id", result.enterprise.getId());
-                jsonObject.put("cQyfx", HealthItem.toDmsData(targetHealth));
+                jsonObject.put("c_qyfx", HealthItem.toDmsData(targetHealth));
                 updateJSON.add(jsonObject);
             }
         }
@@ -169,7 +170,7 @@ public class EnterpriseHealthComputerV2 {
             //租约过期或即将过期(30天)
             if (endTimes.values()
                     .stream()
-                    .anyMatch(endTime -> endTime.isBefore(LocalDate.now().minusDays(30)))
+                    .anyMatch(endTime -> endTime.isBefore(LocalDate.now().plusDays(30)))
             ) {
                 healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_LEASE_EXPIRED);
             }
@@ -185,42 +186,50 @@ public class EnterpriseHealthComputerV2 {
         try {
             lawsuit = JSONObject.parseObject(lawsuitStr);
             try {
-                JSONArray justiciaryCases = lawsuit.getJSONObject("司法案件").getJSONArray("table");
-                List<JSONObject> justiciaryCaseList = new ArrayList<>();
-                for (int i = 0; i < justiciaryCases.size(); i++) {
-                    JSONObject justiciaryCase = justiciaryCases.getJSONObject(i);
-                    justiciaryCaseList.add(justiciaryCase);
-                }
-                List<JSONObject> passiveCases = justiciaryCaseList.stream()
-                        .filter(justiciaryCase -> Optional.ofNullable(justiciaryCase.getString("案件身份")).orElse("").contains("被告"))
-                        .collect(Collectors.toList());
-                List<JSONObject> passiveCaseCountLastYear = passiveCases.stream()
-                        .filter(passiveCase -> {
-                            String date = passiveCase.getString("进程日期");
-                            if (date != null && date.length() >= 10) {
-                                LocalDate processDate = LocalDate.parse(date.substring(0, 10));
-                                return processDate.isAfter(LocalDate.now().minusYears(1));
-                            } else {
-                                return false;
-                            }
-                        }).collect(Collectors.toList());
-                double maxAmount = passiveCaseCountLastYear.stream()
-                        .mapToDouble(passiveCase -> parseAmount(passiveCase.getString("案件金额(元)")))
-                        .max().orElse(0);
-                if (maxAmount > 2000000) {
-                    healthItems.add(HealthItem.RED_HIGH_RISK_LARGE_LAWSUIT);
-                } else if (maxAmount > 500000) {
-                    healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_MIDDLE_LAWSUIT);
-                } else {
-                    healthItems.add(HealthItem.YELLOW_GENERAL_RISK_SMALL_LAWSUIT);
+                JSONObject judicialCaseObj = lawsuit.getJSONObject("司法案件");
+                if (judicialCaseObj != null) {
+                    JSONArray justiciaryCases = judicialCaseObj.getJSONArray("table");
+                    if (justiciaryCases != null && !justiciaryCases.isEmpty()) {
+                        List<JSONObject> justiciaryCaseList = new ArrayList<>();
+                        for (int i = 0; i < justiciaryCases.size(); i++) {
+                            JSONObject justiciaryCase = justiciaryCases.getJSONObject(i);
+                            justiciaryCaseList.add(justiciaryCase);
+                        }
+                        List<JSONObject> passiveCases = justiciaryCaseList.stream()
+                                .filter(justiciaryCase -> Optional.ofNullable(justiciaryCase.getString("案件身份")).orElse("").contains("被告"))
+                                .collect(Collectors.toList());
+                        List<JSONObject> passiveCaseCountLastYear = passiveCases.stream()
+                                .filter(passiveCase -> {
+                                    String date = passiveCase.getString("进程日期");
+                                    if (date != null && date.length() >= 10) {
+                                        LocalDate processDate = LocalDate.parse(date.substring(0, 10));
+                                        return processDate.isAfter(LocalDate.now().minusYears(1));
+                                    } else {
+                                        return false;
+                                    }
+                                }).collect(Collectors.toList());
+                        double maxAmount = passiveCaseCountLastYear.stream()
+                                .mapToDouble(passiveCase -> parseAmount(passiveCase.getString("案件金额(元)")))
+                                .max().orElse(0);
+                        if (maxAmount > 2000000) {
+                            healthItems.add(HealthItem.RED_HIGH_RISK_LARGE_LAWSUIT);
+                        } else if (maxAmount > 500000) {
+                            healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_MIDDLE_LAWSUIT);
+                        } else {
+                            healthItems.add(HealthItem.YELLOW_GENERAL_RISK_SMALL_LAWSUIT);
+                        }
+                    }
                 }
             } catch (JSONException ignore) {
             }
             //股权冻结
             try {
-                JSONArray equityFreeze = lawsuit.getJSONObject("股权冻结").getJSONArray("table");
-                if (!equityFreeze.isEmpty()) {
-                    healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_EQUITY_FREEZE);
+                JSONObject equityFreezeObj = lawsuit.getJSONObject("股权冻结");
+                if (equityFreezeObj != null) {
+                    JSONArray equityFreeze = equityFreezeObj.getJSONArray("table");
+                    if (equityFreeze != null && !equityFreeze.isEmpty()) {
+                        healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_EQUITY_FREEZE);
+                    }
                 }
             } catch (JSONException ignore) {
 
@@ -238,15 +247,20 @@ public class EnterpriseHealthComputerV2 {
             JSONObject operationalRisk = JSONObject.parseObject(operationalRiskStr);
             try {
                 //股权质押
-                JSONArray stockFreeze = operationalRisk.getJSONObject("司法案件").getJSONArray("table");
-                double stockFreezeAmount = 0;
-                for (int i = 0; i < stockFreeze.size(); i++) {
-                    JSONObject stockFreezeItem = stockFreeze.getJSONObject(i);
-                    String amountStr = stockFreezeItem.getString("质押股份市值(元)");
-                    stockFreezeAmount += parseMonetaryValue(amountStr);
-                }
-                if (stockFreezeAmount >= 30000000){
-                    healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_EQUITY_FREEZE);
+                JSONObject judicialCaseObj = operationalRisk.getJSONObject("司法案件");
+                if (judicialCaseObj != null) {
+                    JSONArray stockFreeze = judicialCaseObj.getJSONArray("table");
+                    if (stockFreeze != null && !stockFreeze.isEmpty()) {
+                        double stockFreezeAmount = 0;
+                        for (int i = 0; i < stockFreeze.size(); i++) {
+                            JSONObject stockFreezeItem = stockFreeze.getJSONObject(i);
+                            String amountStr = stockFreezeItem.getString("质押股份市值(元)");
+                            stockFreezeAmount += parseMonetaryValue(amountStr);
+                        }
+                        if (stockFreezeAmount >= 30000000) {
+                            healthItems.add(HealthItem.ORANGE_MEDIUM_RISK_EQUITY_FREEZE);
+                        }
+                    }
                 }
 
             } catch (JSONException ignore) {

+ 1 - 1
src/main/java/com/skyversation/xjcy/computer/EnterpriseLevelComputer.java

@@ -230,7 +230,7 @@ public class EnterpriseLevelComputer {
             if (!Objects.equals(persistedLevelConverted, calculatedLevel)) {
                 JSONObject updateData = new JSONObject();
                 updateData.put("id", enterprise.getId());
-                updateData.put("level", EnterpriseLevel.toPersistedCode(calculatedLevel));
+                updateData.put("company_level", EnterpriseLevel.toPersistedCode(calculatedLevel));
                 needUpdates.add(updateData);
             }
         }

+ 1 - 1
src/main/java/com/skyversation/xjcy/service/DataCountService.java

@@ -443,7 +443,7 @@ public class DataCountService {
                     isGsqy = "2".equals(enterprise.getIsGsqy());
                     nationalIndustryCode = enterprise.getCNationalIndustryCode();
 
-                    EnterpriseLevel.ofJsonValue(enterprise.getCompanyLevel()).ifPresent(level -> {
+                    Optional.ofNullable(EnterpriseLevel.codeOf(enterprise.getCompanyLevel())).ifPresent(level -> {
                         Map<String, Integer> map = enterPriceLevelCountByPark.get(level);
                         map.put(industrialPark.getCResourceName(), map.get(industrialPark.getCResourceName()) + 1);
                     });

+ 2 - 2
src/main/resources/application.yml

@@ -25,7 +25,7 @@ app:
   count-cache-length: ${COUNT_CACHE_LENGTH:500000}
   execute-startup-tasks: ${EXECUTE_STARTUP_TASKS:false}
   dms:
-    #    path: http://127.0.0.1:10081/dms
+#    path: http://127.0.0.1:10081/dms
     path: ${DMS_PATH:http://121.43.55.7:10081/dms}
     column:
       data: '{"INDUSTRIAL_PARK":{"id":"1580","modelId":"1525"},"ENTERPRISE":{"id":"1593","modelId":"1537"},"ENTERPRISE_ECONOMIC":{"id":"1594","modelId":"1538"},"ORDER":{"id":"1587","modelId":"1531"},"LEASE_DETAIL":{"id":"1574","modelId":"1520"},"INVESTMENT_TARGET":{"id":"1578","modelId":"1523"},"CLUE":{"id":"1576","modelId":"1521"},"CLUE_FOLLOW":{"id":"1577","modelId":"1522"},"ENTERPRISE_HEALTH":{"id":"1643","modelId":"1643"},"WECHAT_ARTICLE":{"id":"1599","modelId":"1544"},"MESSAGE":{"id":"1646","modelId":"1649"},"USER":{"id":"1579","modelId":"1524"},"MESSAGE_TARGET":{"id":"1661","modelId":"1671"},"LCXM":{"id":"1660","modelId":"1669"},"INSPECTION_TASK":{"id":"1616","modelId":"1576"},"ENTERPRISE_PRODUCT":{"id":"1592","modelId":"1536"},"ENTERPRISE_PURCHASE":{"id":"1591","modelId":"1535"},"INDUSTRIAL_MANAGE":{"id":"1645","modelId":"1647"},"P18_ENTERPRISE_ECONOMIC":{"id":"1745","modelId":"1796"},"ENTERPRISE_HONOR":{"id":"1720","modelId":"1758"},"ENTERPRISE_BRANCH":{"id":"1721","modelId":"1759"},"ENTERPRISE_CONTROLLED_COMPANY":{"id":"1722","modelId":"1760"},"ENTERPRISE_EXTERNAL_INVESTMENT":{"id":"1723","modelId":"1761"}}'
@@ -69,7 +69,7 @@ spring:
       on-profile: "dev"
 app:
   dms:
-    path: http://121.43.55.7:10081/dms
+    path: http://127.0.0.1:10081/dms
   wechat:
     api-base-url: http://42.121.218.163:1234/weixin
     mode: ${WECHAT_MODE:external}