Răsfoiți Sursa

更换产值统计源

ximinghao 1 săptămână în urmă
părinte
comite
0ee0b2c2e3

+ 5 - 0
ExternalService/src/main/java/com/skyversation/xjcy/service/AlyPhoneMessageSendService.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.aliyun.dysmsapi20170525.Client;
 import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
 import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
+import com.aliyun.tea.TeaUnretryableException;
 import com.aliyun.teaopenapi.models.Config;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -58,6 +59,10 @@ public class AlyPhoneMessageSendService{
         try {
             SendSmsResponse sendSmsResponse = createClient().sendSms(sendSmsRequest);
             return sendSmsResponse.getStatusCode() == 200;
+        }catch (TeaUnretryableException e){
+            e.printStackTrace();
+            System.out.println(e.getLastRequest());
+            return false;
         } catch (Exception e) {
             e.printStackTrace();
             return false;

+ 1 - 1
application.yml

@@ -2,6 +2,6 @@
 app:
   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"}}'
+      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"}}'
   oauth:
     role-config: '{"ENTERPRISE_ROLE":[{"roleId":"40","serviceId":"11","comment":"企业用户权限,pc端"},{"roleId":"44","serviceId":"12","comment":"企业用户权限,wx小程序端"}],"INIT_ROLE":[{"roleId":"41","serviceId":"11","comment":"普通游客权限,pc端"},{"roleId":"45","serviceId":"12","comment":"普通游客权限,wx小程序端"},{"roleId":"48","serviceId":"2","comment":"徐泾一般用户,dms"}]}'

+ 120 - 0
src/main/java/com/skyversation/xjcy/bean/P18EnterpriseEconomic.java

@@ -0,0 +1,120 @@
+package com.skyversation.xjcy.bean;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+public class P18EnterpriseEconomic implements FromJSON {
+    /** 主键(UUID) */
+    private String id;
+
+    /** 年月 */
+    @JSONField(format = "yyyy-MM")
+    private LocalDateTime cYearMonth;
+
+    /** 企业名称 */
+    private String cEnterpriseName;
+
+    /** 企业信用代码 */
+    private String cEnterpriseCode;
+
+    /** 1.税收总收入(单位:万元) */
+    private BigDecimal cSszsr;
+
+    /** 1.1 区级税收收入(单位:万元) */
+    private BigDecimal cQjsssr;
+
+    /** 1.2 区级产业税收(单位:万元) */
+    private BigDecimal cQjcyss;
+
+    /** 2.规模以上工业总产值(单位:万元) */
+    private BigDecimal cGsgyzcz;
+
+    /** 3.战略性新兴产业(制造业)产值(单位:万元) */
+    private BigDecimal cZlxxxcycz;
+
+    /** 4.规上软信业营收(软件和信息技术服务业)(单位:万元) */
+    private BigDecimal cGsrxyys;
+
+    /** 5.规上科技服务业营收(单位:万元) */
+    private BigDecimal cGskjfwyys;
+
+    /** 6.规上交运业营收(交通运输、仓储和邮政业)(单位:万元) */
+    private BigDecimal cGsjyyysZf;
+
+    /** 7.规上人力资源服务业营收(单位:万元) */
+    private BigDecimal cGsrlzyfwyys;
+
+    /** 8.规上会展业营收(单位:万元) */
+    private BigDecimal cGshzyys;
+
+    /** 9.规上广告业营收(单位:万元) */
+    private BigDecimal cGsggyys;
+
+    /** 10.规上文化、体育和娱乐业营收(单位:万元) */
+    private BigDecimal cGswhtyhylyys;
+
+    /** 11.社会消费品零售总额(单位:万元) */
+    private BigDecimal cShxfplsze;
+
+    /** 12.商品销售总额(单位:万元) */
+    private BigDecimal cSpxsze;
+
+    /** 13.餐饮业营业额(单位:万元) */
+    private BigDecimal cCyyyye;
+
+    /** 14.住宿业营业额(单位:万元) */
+    private BigDecimal cZsyyye;
+
+    /** 15.建筑业总产值(单位:万元) */
+    private BigDecimal cJzyzcz;
+
+    /** 16. 全社会固定资产投资(单位:万元) */
+    private BigDecimal cQshgdzctz;
+
+    /** 16.1 工业投资(单位:万元) */
+    private BigDecimal cGytz;
+
+    /** 16.2 房地产投资(单位:万元) */
+    private BigDecimal cFdctz;
+
+    /** 16.3 基础设施投资(单位:万元) */
+    private BigDecimal cJcsstz;
+
+    /** 17.外贸进出口(单位:万元) */
+    private BigDecimal cWmjck;
+
+    /** 18.实到外资(单位:万美元) */
+    private BigDecimal cSdwz;
+
+    /** 19.房地产业税收总收入(单位:万元) */
+    private BigDecimal cFdcysszsr;
+
+    /** 20.区级房地产业税收(单位:万元) */
+    private BigDecimal cQjfdcyss;
+
+    /** 21.新增有效纳税户数(个) */
+    private Integer cXzyxnsh;
+
+    /** 22.高质量企业数量(税收1万以上)(个) */
+    private Integer cGzlqysl;
+
+    /** 23.引大引强引实(个) */
+    private Integer cYdyqys;
+
+    /** 24.合同外资(单位:万美元) */
+    private BigDecimal cHtwz;
+
+    /** 25.总部企业(个) */
+    private Integer cZbqy;
+
+    /** 26.工业及楼宇租售面积(万平方米) */
+    private BigDecimal cGyjlyzsmj;
+
+    /** 其他服务业(单位:万元) */
+    private BigDecimal cQtfwy;
+
+}

+ 1 - 0
src/main/java/com/skyversation/xjcy/dms/DMSColumn.java

@@ -21,6 +21,7 @@ public class DMSColumn {
     public static String ENTERPRISE_PRODUCT = "ENTERPRISE_PRODUCT";
     public static String ENTERPRISE_PURCHASE = "ENTERPRISE_PURCHASE";
     public static String INDUSTRIAL_MANAGE = "INDUSTRIAL_MANAGE";
+    public static String P18_ENTERPRISE_ECONOMIC = "P18_ENTERPRISE_ECONOMIC";
     
     @Getter
     private String id;

+ 9 - 0
src/main/java/com/skyversation/xjcy/dms/DMSQuery.java

@@ -93,6 +93,15 @@ public enum DMSQuery {
         public DMSQueryRequest preRequest(LocalDate now) {
             return new DMSQueryRequest();
         }
+    },
+    THIS_YEAR_P18_ENTERPRISE_ECONOMIC(DMSColumn.P18_ENTERPRISE_ECONOMIC, P18EnterpriseEconomic.class) {
+        @Override
+        public DMSQueryRequest preRequest(LocalDate now) {
+            DMSQueryRequest request = new DMSQueryRequest();
+            String year = now.getYear() + "";
+            request.addWhere("c_year_month", "2", "%"+year);
+            return request;
+        }
     };
 
     private final String column;

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

@@ -118,7 +118,7 @@ public class DataCountService {
         long now = System.currentTimeMillis();
         long last = lastStartTime.get();
 
-        if (now - last < INTERVAL_MILLIS) {
+        if (now - last < INTERVAL_MILLIS&&cacheBuildData!=null&&cacheParkData!=null||cacheTownData!=null) {
             return;
         }
 
@@ -179,6 +179,7 @@ public class DataCountService {
         List<Order> allOrder = dmsService.query(authService.getTokenOfServiceAccount(), DMSQuery.ORDER, Order.class, now);
         List<LeaseDetail> lastLeaseDetail = dmsService.query(authService.getTokenOfServiceAccount(), DMSQuery.LAST_LEASE_DETAIL, LeaseDetail.class, now);
         List<LeaseDetail> lastYearLease = dmsService.query(authService.getTokenOfServiceAccount(), DMSQuery.LAST_YEAR_LEASE_DETAIL, LeaseDetail.class, now);
+        List<P18EnterpriseEconomic> needP18EnterpriseEconomic = dmsService.query(authService.getTokenOfServiceAccount(), DMSQuery.THIS_YEAR_P18_ENTERPRISE_ECONOMIC, P18EnterpriseEconomic.class, now);
         //处理一下拿到的数据,建一建索引
         Map<String, List<EnterpriseEconomic>> enterpriseEconomicMap = new HashMap<>();
         inDateEnterpriseEconomic.forEach(e -> {
@@ -208,13 +209,15 @@ public class DataCountService {
                 ))
                 .values());
 
+        Map<String,BigDecimal> p18EnterpriseEconomicMap = mergeP118EnterpriseEconomicMap(needP18EnterpriseEconomic);
+
         //楼宇/企业/企业经济数据遍历,全镇级/产业园级/楼栋级一并处理
 
         //遍历并计算企业相关的结果
         countEnterprise(allEnterprise, enterpriseEconomicMap, now);
 
         //遍历计算产业园相关
-        countIndustrialPark(allIndustrialPark);
+        countIndustrialPark(allIndustrialPark,p18EnterpriseEconomicMap);
 
         //企呼我应
         countOrder(allOrder);
@@ -231,6 +234,41 @@ public class DataCountService {
         cacheBuildData = tempCacheBuildData;
     }
 
+
+    /**
+     * 合并18项经济指标数据为营收数据,按企业合并
+     * @param needP18EnterpriseEconomic 18项经济指标数据
+     * @return 企业编码->营收数据
+     */
+    private Map<String, BigDecimal> mergeP118EnterpriseEconomicMap(List<P18EnterpriseEconomic> needP18EnterpriseEconomic) {
+        return needP18EnterpriseEconomic.stream()
+                .collect(Collectors.groupingBy(P18EnterpriseEconomic::getCEnterpriseCode))
+                .entrySet()
+                .stream()
+                .collect(Collectors.toMap(
+                        Map.Entry::getKey,
+                        e -> e.getValue().stream()
+                                .map(this::getRevenue)
+                                .reduce(BigDecimal::add)
+                                .orElse(BigDecimal.ZERO)
+                ));
+    }
+
+    /**
+     * 获取营收数据
+     */
+    private BigDecimal getRevenue(P18EnterpriseEconomic p18){
+        return mergeAll(
+                p18.getCGsjyyysZf(),
+                p18.getCGsrxyys(),
+                p18.getCGsrlzyfwyys(),
+                p18.getCGshzyys(),
+                p18.getCGskjfwyys(),
+                p18.getCGswhtyhylyys(),
+                p18.getCQtfwy()
+        );
+    }
+
     private void countHistoryData(List<Enterprise> allEnterprise, List<IndustrialPark> allIndustrialPark, List<LeaseDetail> lastYearLease, LocalDate now) {
         //历史企业总数统计
         //历史数据,所以不论企业现状如何
@@ -287,7 +325,7 @@ public class DataCountService {
     }
 
 
-    private void countIndustrialPark(List<IndustrialPark> allIndustrialPark) {
+    private void countIndustrialPark(List<IndustrialPark> allIndustrialPark, Map<String, BigDecimal> p18EnterpriseEconomicMap) {
         //简单统计并按父级编码建映射
         simpleCountPark(allIndustrialPark);
         Map<EnterpriseLevel, Map<String, Integer>> enterPriceLevelCountByPark = new HashMap<>();
@@ -310,6 +348,7 @@ public class DataCountService {
             int enterPriceGsCount = 0;
             Set<String> inParkEnterpriseCode = new HashSet<>();
             List<String> aliveEnterprise = new ArrayList<>();
+            List<String> gsEnterprise = new ArrayList<>();
             int usedRoomCount = 0;
 
             allBuild = buildMap.get(parkCode);
@@ -418,6 +457,7 @@ public class DataCountService {
                         allGsProductByYtdThisYear = allGsProductByYtdThisYear.add(ytdThisYear.product);
                         allGsProductByYtdLastYear = allGsProductByYtdLastYear.add(ytdLastYear.product);
 
+                        gsEnterprise.add(enterpriseCode);
                     }
 
                     aliveEnterprise.add(enterpriseCode);
@@ -454,15 +494,14 @@ public class DataCountService {
             parkDataCount.put("enterPriseIndustry", enterPriceIndustryCount);
 
             JSONArray topRevenue = new JSONArray();
-            List<String> sortedEnterprise = aliveEnterprise.stream().sorted((a, b) -> {
-                BigDecimal ar = economicCountBy12Month.get(a).revenue;
-                BigDecimal br = economicCountBy12Month.get(b).revenue;
-                return ar.compareTo(br) * -1;
-            }).limit(10).collect(Collectors.toList());
+            List<String> sortedEnterprise = gsEnterprise
+                    .stream()
+                    .sorted(Comparator.comparing(p18EnterpriseEconomicMap::get,Comparator.nullsFirst(BigDecimal::compareTo)).reversed())
+                    .limit(10).collect(Collectors.toList());
             for (String enterPriseCode : sortedEnterprise) {
                 JSONObject outPut = new JSONObject();
                 Enterprise enterPrice = aliveEnterpriseMap.get(enterPriseCode);
-                BigDecimal product = economicCountBy12Month.get(enterPriseCode).product;
+                BigDecimal product =nullToZero( p18EnterpriseEconomicMap.get(enterPriseCode));
                 outPut.put("enterPriceCode", enterPriseCode);
                 outPut.put("enterPriceName", enterPrice.getCEnterpriseName());
                 if (product.compareTo(BigDecimal.ZERO)==0){
@@ -793,5 +832,15 @@ public class DataCountService {
         return cacheBuildData.get(buildCode);
     }
 
+    private static BigDecimal nullToZero(BigDecimal value){
+        return value == null ? BigDecimal.ZERO : value;
+    }
+    private static BigDecimal mergeAll(BigDecimal...  values){
+        return Arrays.stream(values)
+                .map(DataCountService::nullToZero)
+                .reduce(BigDecimal::add)
+                .orElse(BigDecimal.ZERO);
+    }
+
 
 }

+ 4 - 1
src/main/resources/application.yml

@@ -28,7 +28,7 @@ app:
     #    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"}}'
+      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"}}'
   oauth:
     login-name: ${DMS_LOGIN_NAME:user_hj}
     password: ${DMS_PASSWORD:Hj@123456}
@@ -79,6 +79,9 @@ app:
     message:
       mode: ${PHONE_MESSAGE_MODE:external}
   execute-startup-tasks: false
+  external:
+    service:
+#      url: ${EXTERNAL_SERVICE_URL:http://127.0.0.1:10022/xjcy-external}
 #  wechat:
 #    appid: ${XJCY_WECHAT_APPID:wx125843453562c86c}
 #    secret-key: ${XJCY_WECHAT_SECRET:6028cc345cfdbc76224d750a13519762}