소스 검색

折线图单位

da-xian 1 주 전
부모
커밋
0447ab53cb

+ 65 - 9
src/main/java/com/bowintek/smartsearch/services/impl/FactWellServiceImpl.java

@@ -4,10 +4,7 @@ import com.bowintek.smartsearch.mapper.cquery.FactWellCQuery;
 import com.bowintek.smartsearch.services.service.FactWellService;
 import com.bowintek.smartsearch.util.multipdb.DBTypeEnum;
 import com.bowintek.smartsearch.util.multipdb.SwitchDataSource;
-import com.bowintek.smartsearch.vo.FactWell.FactWellGroupList;
-import com.bowintek.smartsearch.vo.FactWell.FactWellResult;
-import com.bowintek.smartsearch.vo.FactWell.FactWellTime;
-import com.bowintek.smartsearch.vo.FactWell.FactWellTimeResult;
+import com.bowintek.smartsearch.vo.FactWell.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -24,7 +21,7 @@ public class FactWellServiceImpl implements FactWellService {
     @Override
     @SwitchDataSource(DBTypeEnum.POSTGRE)
     public FactWellResult getFactWellList(String wellId, String timeType){
-        if(wellId==null) return FactWellResult.gen(new ArrayList<>(), null, wellId);
+        if(wellId==null) return FactWellResult.gen(new ArrayList<>(), null, null, wellId);
         //当前只有月份计算方式
         return getMonthShowInList(wellId, null, null);
     }
@@ -64,6 +61,7 @@ public class FactWellServiceImpl implements FactWellService {
 
         List<FactWellGroupList> rtnList = factWellCQuery
                 .getMonthShowInList(wellId, dateToDayString(startTime), dateToDayString(endTime));
+//        List<FactWellUnit> unitList = setUnit(rtnList);
 
         //补充列表数据
         List<String> monthList = new ArrayList<>();
@@ -77,7 +75,7 @@ public class FactWellServiceImpl implements FactWellService {
         }
 
         return FactWellResult.gen(supplementList(wellId, monthList, rtnList),
-                Arrays.stream((new FactWellTimeResult[]{timeResult})).toList(), wellId);
+                Arrays.stream((new FactWellTimeResult[]{timeResult})).toList(), null, wellId);
     }
 
     @Override
@@ -104,6 +102,7 @@ public class FactWellServiceImpl implements FactWellService {
 
         List<FactWellGroupList> rtnList = factWellCQuery
                 .getDayGroupList(wellId, dateToDayString(startTime), dateToDayString(endTime));
+        List<FactWellUnit> unitList = setUnit(rtnList);
 
         //补充列表数据
         List<String> dayList = new ArrayList<>();
@@ -116,7 +115,7 @@ public class FactWellServiceImpl implements FactWellService {
             time = calendarTime.getTime();
         }
 
-        return FactWellResult.gen(supplementList(wellId, dayList, rtnList), timeList, wellId);
+        return FactWellResult.gen(supplementList(wellId, dayList, rtnList), timeList, unitList, wellId);
     }
 
     public FactWellResult getMonthGroupList(String wellId, Date startTime, Date endTime){
@@ -135,6 +134,7 @@ public class FactWellServiceImpl implements FactWellService {
 
         List<FactWellGroupList> rtnList = factWellCQuery
                 .getMonthGroupList(wellId, dateToDayString(startTime), dateToDayString(endTime));
+        List<FactWellUnit> unitList = setUnit(rtnList);
 
         //补充列表数据
         List<String> monthList = new ArrayList<>();
@@ -147,7 +147,7 @@ public class FactWellServiceImpl implements FactWellService {
             time = calendarTime.getTime();
         }
 
-        return FactWellResult.gen(supplementList(wellId, monthList, rtnList), timeList, wellId);
+        return FactWellResult.gen(supplementList(wellId, monthList, rtnList), timeList, unitList, wellId);
     }
 
     public FactWellResult getYearGroupList(String wellId, Date startTime, Date endTime){
@@ -166,6 +166,7 @@ public class FactWellServiceImpl implements FactWellService {
 
         List<FactWellGroupList> rtnList = factWellCQuery
                 .getYearGroupList(wellId, dateToDayString(startTime), dateToDayString(endTime));
+        List<FactWellUnit> unitList = setUnit(rtnList);
 
         //补充列表数据
         List<String> monthList = new ArrayList<>();
@@ -178,7 +179,7 @@ public class FactWellServiceImpl implements FactWellService {
             time = calendarTime.getTime();
         }
 
-        return FactWellResult.gen(supplementList(wellId, monthList, rtnList), timeList, wellId);
+        return FactWellResult.gen(supplementList(wellId, monthList, rtnList), timeList, unitList, wellId);
     }
 
     public List<FactWellTimeResult> getTimeLimitList(String wellId){
@@ -292,4 +293,59 @@ public class FactWellServiceImpl implements FactWellService {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
         return sdf.format(time);
     }
+
+    public List<FactWellUnit> setUnit(List<FactWellGroupList> list){
+        List<FactWellUnit> units = new ArrayList<>();
+        int listSize = list.size();
+
+        if(list.stream().filter(x->x.getGas()>10000).count() == listSize){
+            list.forEach(item->{
+                item.setGas(item.getGas()/10000);
+            });
+            units.add(new FactWellUnit("gas", "万立方米"));
+        }else{
+            units.add(new FactWellUnit("gas", "立方米"));
+        }
+
+        if(list.stream().filter(x->x.getOil()>10000).count() == listSize){
+            list.forEach(item->{
+                item.setOil(item.getOil()/10000);
+            });
+            units.add(new FactWellUnit("oil", "万吨"));
+        }else{
+            units.add(new FactWellUnit("oil", "吨"));
+        }
+
+        if(list.stream().filter(x->x.getWater()>10000).count() == listSize){
+            list.forEach(item->{
+                item.setWater(item.getWater()/10000);
+            });
+            units.add(new FactWellUnit("water", "万吨"));
+        }else{
+            units.add(new FactWellUnit("water", "吨"));
+        }
+
+        if(list.stream().filter(x->x.getFluid()>10000).count() == listSize){
+            list.forEach(item->{
+                item.setFluid(item.getFluid()/10000);
+            });
+            units.add(new FactWellUnit("fluid", "万吨"));
+        }else{
+            units.add(new FactWellUnit("fluid", "吨"));
+        }
+
+        if(list.stream().filter(x->x.getVol()>10000).count() == listSize){
+            list.forEach(item->{
+                item.setOil(item.getVol()/10000);
+            });
+            units.add(new FactWellUnit("vol", "万吨"));
+        }else{
+            units.add(new FactWellUnit("vol", "吨"));
+        }
+
+        units.add(new FactWellUnit("watercut", "%"));
+
+        return units;
+    }
+
 }

+ 3 - 1
src/main/java/com/bowintek/smartsearch/vo/FactWell/FactWellResult.java

@@ -8,12 +8,14 @@ import java.util.List;
 public class FactWellResult {
     private List<FactWellGroupList> rows;
     private List<FactWellTimeResult> timeList;
+    List<FactWellUnit> unitList;
     private String wellId;
 
-    public static FactWellResult gen(List<FactWellGroupList> rows, List<FactWellTimeResult> timeList, String wellId){
+    public static FactWellResult gen(List<FactWellGroupList> rows, List<FactWellTimeResult> timeList, List<FactWellUnit> unitList, String wellId){
         FactWellResult obj = new FactWellResult();
         obj.setRows(rows);
         obj.setTimeList(timeList);
+        obj.setUnitList(unitList);
         obj.setWellId(wellId);
         return obj;
     }

+ 13 - 0
src/main/java/com/bowintek/smartsearch/vo/FactWell/FactWellUnit.java

@@ -0,0 +1,13 @@
+package com.bowintek.smartsearch.vo.FactWell;
+
+import lombok.Data;
+
+@Data
+public class FactWellUnit {
+    private String name;
+    private String unit;
+    public FactWellUnit(String name, String unit){
+        this.name = name;
+        this.unit = unit;
+    }
+}

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

@@ -6,7 +6,7 @@ server:
 spring:
   web:
     resources:
-      static-locations: file:D:/我的文件/博颖项目/华北油田AI检索/smartsearch/src/main/resources/static/
+      static-locations: file:D:/Work/Project/smartsearch/src/main/resources/static/
   datasource:
     name: practice_db
     type: com.alibaba.druid.pool.DruidDataSource
@@ -146,4 +146,4 @@ appconfig:
     client_id: 2d4a5b3c-dc6c-4231-914c-ca1a4d3a134b
     client_secret: e2afdc026c4e745714d2f3b2a2e393686c11f66f
 
-  hdfshelperurl: http://localhost:8078/hdfshelper/
+  hdfshelperurl: http://localhost:8080/hdfshelper/

+ 12 - 12
src/main/resources/mapping/cquery/FactWellCQuery.xml

@@ -13,11 +13,11 @@
         FROM (  SELECT  wd.well_id,
                         TO_CHAR(wd.prod_date , 'YYYY-MM-DD') prod_time_str,
                         COALESCE(wd.gas_prod_daily, 0)      gas_prod_daily,
-                        COALESCE(wd.oil_prod_daily, 0)/10000      oil_prod_daily,
-                        COALESCE(wd.fluid_prod_daily, 0)/10000      fluid_prod_daily,
-                        COALESCE(wd.water_prod_daily, 0)/10000      water_prod_daily,
+                        COALESCE(wd.oil_prod_daily, 0)      oil_prod_daily,
+                        COALESCE(wd.fluid_prod_daily, 0)      fluid_prod_daily,
+                        COALESCE(wd.water_prod_daily, 0)      water_prod_daily,
                         COALESCE(wd.water_cut, 0)      water_cut,
-                        COALESCE(wd.inj_vol_daily)/10000  inj_vol_daily
+                        COALESCE(wd.inj_vol_daily)  inj_vol_daily
                 FROM by_dwr.fact_dwr_pc_pro_well_vol_d wd
                 WHERE wd.prod_date <![CDATA[ >= ]]> to_date(#{startDay},'YYYY-MM-DD')
                     and wd.prod_date <![CDATA[ <= ]]> to_date(#{endDay},'YYYY-MM-DD')
@@ -84,11 +84,11 @@
         FROM (  SELECT wm.well_id,
                     to_char(to_date(CONCAT(wm.prod_date,'-01'), 'YYYY-MM-DD'), 'YYYY年MM月') prod_time_str,
                     COALESCE(wm.gas_prod_mon, 0) gas_prod_mon,
-                    COALESCE(wm.oil_prod_mon, 0)/10000 oil_prod_mon,
-                    COALESCE(wm.water_prod_mon, 0)/10000 water_prod_mon,
-                    COALESCE(wm.fluid_prod_mon, 0)/10000 fluid_prod_mon,
+                    COALESCE(wm.oil_prod_mon, 0) oil_prod_mon,
+                    COALESCE(wm.water_prod_mon, 0) water_prod_mon,
+                    COALESCE(wm.fluid_prod_mon, 0) fluid_prod_mon,
                     COALESCE(wm.water_cut_ratio_m, 0) water_cut_ratio_m,
-                    COALESCE(wm.inj_vol_mon, 0)/10000 inj_vol_mon
+                    COALESCE(wm.inj_vol_mon, 0) inj_vol_mon
                 FROM by_dwr.fact_dwr_pc_pro_well_vol_m wm
                 WHERE wm.prod_date is not null
                     and to_date(CONCAT(wm.prod_date,'-01'), 'YYYY-MM-DD')  <![CDATA[ >= ]]> to_date(#{startDay},'YYYY-MM-DD')
@@ -112,11 +112,11 @@
         FROM (  SELECT wm.well_id,
                     SUBSTRING(prod_date, 1, 4) prod_time_str,
                     COALESCE(wm.gas_prod_year, 0) gas_prod_year,
-                    COALESCE(wm.oil_prod_year, 0)/10000 oil_prod_year,
-                    COALESCE(wm.water_prod_year, 0)/10000 water_prod_year,
-                    COALESCE(wm.fluid_prod_year, 0)/10000 fluid_prod_year,
+                    COALESCE(wm.oil_prod_year, 0) oil_prod_year,
+                    COALESCE(wm.water_prod_year, 0) water_prod_year,
+                    COALESCE(wm.fluid_prod_year, 0) fluid_prod_year,
                     COALESCE(wm.water_cut_ratio_y, 0) water_cut_ratio_y,
-                    COALESCE(wm.inj_vol_year, 0)/10000 inj_vol_year
+                    COALESCE(wm.inj_vol_year, 0) inj_vol_year
                 FROM by_dwr.fact_dwr_pc_pro_well_vol_m wm
                 WHERE wm.prod_date is not null
                     and to_date(CONCAT(wm.prod_date,'-01'), 'YYYY-MM-DD')  <![CDATA[ >= ]]> to_date(#{startDay},'YYYY-MM-DD')

+ 2 - 2
target/classes/application.yml

@@ -6,7 +6,7 @@ server:
 spring:
   web:
     resources:
-      static-locations: file:D:/我的文件/博颖项目/华北油田AI检索/smartsearch/src/main/resources/static/
+      static-locations: file:D:/Work/Project/smartsearch/src/main/resources/static/
   datasource:
     name: practice_db
     type: com.alibaba.druid.pool.DruidDataSource
@@ -146,4 +146,4 @@ appconfig:
     client_id: 2d4a5b3c-dc6c-4231-914c-ca1a4d3a134b
     client_secret: e2afdc026c4e745714d2f3b2a2e393686c11f66f
 
-  hdfshelperurl: http://localhost:8078/hdfshelper/
+  hdfshelperurl: http://localhost:8080/hdfshelper/

+ 18 - 9
vue/src/components/basic/chart/chart-prod-dynamics.vue

@@ -53,7 +53,7 @@
     <div class="echarts-total">
       <span style="font-weight: bold;padding-right: 10px">统计区间:</span>
       <template v-for="(it) in getTotals()">
-        <span :style="{color: it.color, fontWeight: 'bold'}">{{it.name}}</span>&nbsp;:&nbsp;{{it.total!=null? parseFloat( it.total).toFixed(3):0}}{{it.unit}} &nbsp;&nbsp;&nbsp;&nbsp;
+        <span :style="{color: it.color, fontWeight: 'bold'}">{{it.name}}</span>&nbsp;:&nbsp;{{it.total!=null? parseFloat( it.total).toFixed(3):0}}({{it.unit}}) &nbsp;&nbsp;&nbsp;&nbsp;
       </template>
     </div>
     <div class="echart" :id="('chart-'+id)" :style="getChartStyle()"></div>
@@ -82,7 +82,14 @@
         hovered : false,
         height : 130,
         datas : [],
-        timeList : [] as any
+        timeList : [] as any,
+        typeOptions: [{label:'产油量', leiLabel:'累产油量', value:'oil', unit:'万吨', color: '#ec1e27'},
+                      {label:'产水量', leiLabel:'累产水量', value:'water', unit:'万吨', color: '#00B0F0'},
+                      {label:'产液量', leiLabel:'累产液量', value:'fluid', unit:'万吨', color: '#60080e'},
+                      {label:'产气量', leiLabel:'累产气量', value:'gas', unit:'立方米', color: '#ffc800'},
+                      {label:'含水率', leiLabel:'含水率', value:'watercut', unit:'%', color: '#322eda'},
+                      {label:'注水量', leiLabel:'累注水量', value:'vol', unit:'万吨', color: '#42f03e'}
+                    ] as any
       }
     },
     setup(props, context){
@@ -135,6 +142,14 @@
         if(this.timeList.length==0 && result.timeList) this.timeList = result.timeList;
         this.initTimeLimit();
 
+        if(result.unitList){
+          this.typeOptions.map(x=>{
+            const unitItem = result.unitList.find(unit=>unit.name==x.value);
+            x.unit = unitItem.unit;
+          })
+        }
+        //console.log("this.typeOptions", this.typeOptions, result.unitList)
+
         console.log("onFinish",result);
         this.getTotals();
         this.readerChart();
@@ -175,13 +190,7 @@
           {label:'年', value:'year'}];
       },
       getTypeOptions:function (){
-        return [{label:'产油量', leiLabel:'累产油量', value:'oil', unit:'(万吨)', color: '#ec1e27'},
-          {label:'产水量', leiLabel:'累产水量', value:'water', unit:'(万吨)', color: '#00B0F0'},
-          {label:'产液量', leiLabel:'累产液量', value:'fluid', unit:'(万吨)', color: '#60080e'},
-          {label:'产气量', leiLabel:'累产气量', value:'gas', unit:'(立方米)', color: '#ffc800'},
-          {label:'含水率', leiLabel:'含水率', value:'watercut', unit:'(%)', color: '#322eda'},
-          {label:'注水量', leiLabel:'累注水量', value:'vol', unit:'(万吨)', color: '#42f03e'}
-        ];
+        return this.typeOptions;
       },
       getTypes:function (){
         return this.getTypeOptions().filter((item) => {