Переглянути джерело

归集数据分析 查询数据改造

wangzhe 2 роки тому
батько
коміт
d25b87b9da

+ 21 - 0
mybusiness/src/main/java/com/sooka/system/mapper/TUInterfaceinfoMapper.java

@@ -88,6 +88,13 @@ public interface TUInterfaceinfoMapper
      * @return 结果
      */
     public ImputationData imputationData(Map imputationData);
+    /**
+     * 安装年份查询【归集数据分析】
+     *
+     * @param imputationData 【归集数据分析】
+     * @return 结果
+     */
+    public ImputationData imputationDataLastUpdateTime(Map imputationData);
 
     /**
      * 按照月份查询【归集数据分析】
@@ -95,7 +102,21 @@ public interface TUInterfaceinfoMapper
      * @param imputationData 【归集数据分析】
      * @return 结果
      */
+    public List<Object> checkColumnExists(Map imputationData);
+    /**
+     * 按照月份查询【归集数据分析】
+     *
+     * @param imputationData 【归集数据分析】
+     * @return 结果
+     */
     public ImputationData imputationDataByMonth(Map imputationData);
+    /**
+     * 按照月份查询【归集数据分析】
+     *
+     * @param imputationData 【归集数据分析】
+     * @return 结果
+     */
+    public ImputationData imputationDataByMonthLastUpdateTime(Map imputationData);
 
     /**
      * 修改【接口数据条数】

+ 16 - 1
mybusiness/src/main/java/com/sooka/system/service/impl/TUInterfaceinfoServiceImpl.java

@@ -292,6 +292,7 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
 //        param.setNeedRefresh("1");
         //(164-57) t_guiji_gas_zenner_gas_purchase_center_infor - 归集-市燃气(真兰收费系统)-中心计费购气信息 - 237962 ms
         //(164-70) t_guiji_gas_zenner_meter_reading_infor - 归集-市燃气(真兰收费系统)-抄表信息 - 352968 ms
+        //t_guiji_naturalresources_qlrjbxx - 归集-市自然资源(不动产)-权利人基本信息 - updating database... id = 1de6752d-19c2-4010-9b61-9450a9d718b6
         List<TUInterfaceinfo> tuInterfaceinfoList = tUInterfaceinfoMapper.selectTUInterfaceinfoList(param);
         for (int i = 0; i < tuInterfaceinfoList.size(); i++) {
             TUInterfaceinfo tuInterfaceinfo = tuInterfaceinfoList.get(i);
@@ -312,8 +313,22 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
             map.put("month", month);
             map.put("tableName", tableName);
             System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
+            Map column = new HashMap();
+            column.put("tableSchema", tableName.contains("\\.") ? tableName.split("\\.")[0] : "thsjzt");//thgjj / thsjzt
+            column.put("tableName", tableName.contains("\\.") ? tableName.split("\\.")[1] : tableName);//thgjj.tgjj_gtjkrxx / t_guiji_gas_zenner_meter_reading_infor
+            column.put("columnName", "create_time");//create_time / LAST_UPDATE_TIME
+            System.out.println(column.get("tableSchema"));
+            System.out.println(column.get("tableName"));
+            System.out.println(column.get("columnName"));
+            List<Object> objectList = tUInterfaceinfoMapper.checkColumnExists(column);
+            System.out.println(objectList.size() + "=object");
             Date dateBegin = new Date();
-            ImputationData imputationData = tUInterfaceinfoMapper.imputationDataByMonth(map);
+            ImputationData imputationData;
+            if(objectList.size() != 0){
+                imputationData = tUInterfaceinfoMapper.imputationDataByMonth(map);
+            }else {
+                imputationData = tUInterfaceinfoMapper.imputationDataByMonthLastUpdateTime(map);
+            }
             Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
             ImputationData imputationDataInsert = new ImputationData();
             imputationDataInsert.setYear(year);

+ 30 - 2
mybusiness/src/main/java/com/util/StaticScheduleTask.java

@@ -81,8 +81,22 @@ public class StaticScheduleTask {
             map.put("month", month);
             map.put("tableName", tableName);
             System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
+            Map column = new HashMap();
+            column.put("tableSchema", tableName.contains("\\.") ? tableName.split("\\.")[0] : "thsjzt");//thgjj / thsjzt
+            column.put("tableName", tableName.contains("\\.") ? tableName.split("\\.")[1] : tableName);//thgjj.tgjj_gtjkrxx / t_guiji_gas_zenner_meter_reading_infor
+            column.put("columnName", "create_time");//create_time / LAST_UPDATE_TIME
+//            System.out.println(column.get("tableSchema"));
+//            System.out.println(column.get("tableName"));
+//            System.out.println(column.get("columnName"));
+            List<Object> objectList = tUInterfaceinfoMapper.checkColumnExists(column);
+            System.out.println(objectList.size() + "=object");
             Date dateBegin = new Date();
-            ImputationData imputationData = tUInterfaceinfoMapper.imputationDataByMonth(map);
+            ImputationData imputationData;
+            if(objectList.size() != 0){
+                imputationData = tUInterfaceinfoMapper.imputationDataByMonth(map);
+            }else {
+                imputationData = tUInterfaceinfoMapper.imputationDataByMonthLastUpdateTime(map);
+            }
             Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
             ImputationData imputationDataInsert = new ImputationData();
             imputationDataInsert.setYear(year);
@@ -121,8 +135,22 @@ public class StaticScheduleTask {
             map.put("year", year);
             map.put("tableName", tableName);
             System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
+            Map column = new HashMap();
+            column.put("tableSchema", tableName.contains("\\.") ? tableName.split("\\.")[0] : "thsjzt");//thgjj / thsjzt
+            column.put("tableName", tableName.contains("\\.") ? tableName.split("\\.")[1] : tableName);//thgjj.tgjj_gtjkrxx / t_guiji_gas_zenner_meter_reading_infor
+            column.put("columnName", "create_time");//create_time / LAST_UPDATE_TIME
+            System.out.println(column.get("tableSchema"));
+            System.out.println(column.get("tableName"));
+            System.out.println(column.get("columnName"));
+            List<Object> objectList = tUInterfaceinfoMapper.checkColumnExists(column);
+            System.out.println(objectList.size() + "=object");
             Date dateBegin = new Date();
-            ImputationData imputationData = tUInterfaceinfoMapper.imputationData(map);
+            ImputationData imputationData;
+            if(objectList.size() != 0){
+                imputationData = tUInterfaceinfoMapper.imputationData(map);
+            }else {
+                imputationData = tUInterfaceinfoMapper.imputationDataLastUpdateTime(map);
+            }
             Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
             ImputationData imputationDataInsert = new ImputationData();
             imputationDataInsert.setYear(year);

+ 22 - 0
mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml

@@ -233,10 +233,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	        (select count(id) decb from ${tableName} where year(create_time) = #{year} and month(create_time) = 12) l
         )
     </select>
+    <select id="imputationDataLastUpdateTime" parameterType="java.util.Map" resultType="ImputationData">
+        select * from(
+	        (select count(id) jan from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 1) a,
+	        (select count(id) feb from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 2) b,
+	        (select count(id) mar from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 3) c,
+	        (select count(id) apr from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 4) d,
+	        (select count(id) may from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 5) e,
+	        (select count(id) jun from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 6) f,
+	        (select count(id) jul from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 7) g,
+	        (select count(id) aug from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 8) h,
+	        (select count(id) sep from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 9) i,
+	        (select count(id) oct from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 10) j,
+	        (select count(id) nov from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 11) k,
+	        (select count(id) decb from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = 12) l
+        )
+    </select>
 
+    <select id="checkColumnExists" parameterType="java.util.Map" resultType="ImputationData">
+        select * from information_schema.columns where table_schema = '${tableSchema}' and table_name = '${tableName}' AND column_name = '${columnName}'
+    </select>
     <select id="imputationDataByMonth" parameterType="java.util.Map" resultType="ImputationData">
         select count(id) count from ${tableName} where year(create_time) = #{year} and month(create_time) = #{month}
     </select>
+    <select id="imputationDataByMonthLastUpdateTime" parameterType="java.util.Map" resultType="ImputationData">
+        select count(id) count from ${tableName} where year(LAST_UPDATE_TIME) = #{year} and month(LAST_UPDATE_TIME) = #{month}
+    </select>
 
     <update id="updateDataNum" parameterType="TUInterfaceinfo">
         update t_u_interfaceinfo_datanum set update_time = #{updateTime}, datanum = (select count(id) from ${tableName}) where id = #{id}