update code

dev_xd
lijun 2024-12-14 22:48:31 +08:00
parent 05c15aeb9a
commit 234f32caad
12 changed files with 887 additions and 31 deletions

View File

@ -0,0 +1,157 @@
import request from "@/utils/request";
import dayjs from 'dayjs'
const groupByAll = (data) => {
return new Promise((resolve) => {
return request({
url: "/manage/greenCarbonData/groupByAll",
method: "get",
params: data,
}).then((d) => {
let tmps=(d.data||[]).map(it=>{
it.sumEmissionReduction=(it.sumEstimateValue||0)-(it.sumPracticalValue||0);
it.emissionReduction=(it.estimateValue||0)-(it.practicalValue||0);
return it;
})
let sumEmissionReduction=0;
let sumEstimateValue=0;
let sumPracticalValue=0;
let emissionReduction=0;
let estimateValue=0;
let practicalValue=0;
tmps.forEach(it=>{
sumEmissionReduction+=(it.sumEmissionReduction||0);
sumEstimateValue+=(it.sumEstimateValue||0);
sumPracticalValue+=(it.sumPracticalValue||0);
emissionReduction+=(it.emissionReduction||0);
estimateValue+=(it.estimateValue||0);
practicalValue+=(it.practicalValue||0);
});
tmps.push({
factorType:0,
sumEmissionReduction:sumEmissionReduction,
sumEstimateValue:sumEstimateValue,
sumPracticalValue:sumPracticalValue,
emissionReduction:emissionReduction,
estimateValue:estimateValue,
practicalValue:practicalValue
})
resolve(tmps)
});
});
};
const groupCurrentMonth = (data) => {
return new Promise((resolve) => {
return request({
url: "/manage/greenCarbonData/groupCurrentMonth",
method: "get",
params: data,
}).then(d=>{
let tmps=(d.data||[]).map(it=>{
it.emissionReduction=(it.estimateValue||0)-(it.practicalValue||0);
return it;
})
let emissionReduction=0;
let estimateValue=0;
let practicalValue=0;
tmps.forEach(it=>{
emissionReduction+=(it.emissionReduction||0);
estimateValue+=(it.estimateValue||0);
practicalValue+=(it.practicalValue||0);
});
tmps.push({
factorType:0,
emissionReduction:emissionReduction,
estimateValue:estimateValue,
practicalValue:practicalValue
})
resolve(tmps)
});
});
};
const getGroupData=(tmps,data,factorType,dataType)=>{
let titles=[];
let res=[];
let dt=dayjs(data.createTime);
for(let i=0;i<12;i++){
let date=dt.add(i,"month");
let year=date.$y;
let month=date.$M+1;
titles.push(month+"月");
let objs=tmps.filter(it=>(it.factorType==factorType||factorType==0)&& it.comId==year && it.projectId==month);
let val=null;
if(objs.length>0){
if(dataType==1){
val=objs[0].estimateValue/1000.0
}
if(dataType==2){
val=objs[0].practicalValue/1000.0
}
if(dataType==3){
val=((objs[0].estimateValue||0) - (val=objs[0].practicalValue||0))/1000.0
}
}
res.push(val);
}
return {
titles:titles,
datas:res
}
}
const groupByYearMonth = (data) => {
return new Promise((resolve) => {
return request({
url: "/manage/greenCarbonData/groupByYearMonth",
method: "get",
params: data,
}).then(d=>{
let tmps=d.data||[];
let buildData={
//预估
estimate: getGroupData(tmps,data,1,1),
//实际
practical:getGroupData(tmps,data,1,2),
//减排
emissionReduction:getGroupData(tmps,data,1,3),
};
let oilData={
//预估
estimate: getGroupData(tmps,data,2,1),
//实际
practical:getGroupData(tmps,data,2,2),
//减排
emissionReduction:getGroupData(tmps,data,2,3),
};
let powerData={
//预估
estimate: getGroupData(tmps,data,3,1),
//实际
practical:getGroupData(tmps,data,3,2),
//减排
emissionReduction:getGroupData(tmps,data,3,3),
};
let totalData={
//预估
estimate: getGroupData(tmps,data,0,1),
//实际
practical:getGroupData(tmps,data,0,2),
//减排
emissionReduction:getGroupData(tmps,data,0,3),
};
resolve({
buildData:buildData,
oilData:oilData,
powerData:powerData,
totalData:totalData,
})
});
});
};
export default {
groupByAll,
groupCurrentMonth,
groupByYearMonth,
};

View File

@ -4,11 +4,13 @@ import project from './project'
import weather from './weather' import weather from './weather'
import detail from './detail' import detail from './detail'
import dict from './dict' import dict from './dict'
import greenCarbon from './greenCarbon'
export default { export default {
http:axios, http:axios,
downFile:download, downFile:download,
project, project,
weather, weather,
detail, detail,
dict dict,
greenCarbon
} }

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xml:space="preserve">
<g transform="matrix(1 0 0 1 540 540)" id="7e597b96-e20c-460b-8139-75c72d5b54b0" >
<rect style="stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke" x="-540" y="-540" rx="0" ry="0" width="1080" height="1080" />
</g>
<g transform="matrix(1 0 0 1 540 540)" id="0efec865-77d6-48e6-b9a3-7a8833b9c564" >
</g>
<g transform="matrix(0.73 0 0 0.98 421.96 576.65)" >
<path style="stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill-rule: nonzero; opacity: 1;" transform=" translate(-511.99, -512)" d="M 568.618695 342.954495 L 820.171262 2.381529 L 482.496301 2.381529 L 203.814391 547.450347 L 410.806546 547.306882 L 222.565344 1021.618471 L 818.564447 343.02622699999995 z M 796.054696 352.753194" stroke-linecap="round" />
</g>
<g transform="matrix(0.61 0 0 0.61 728.16 373.78)" >
<path style="stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill-rule: nonzero; opacity: 1;" transform=" translate(-511.99, -512)" d="M 568.618695 342.954495 L 820.171262 2.381529 L 482.496301 2.381529 L 203.814391 547.450347 L 410.806546 547.306882 L 222.565344 1021.618471 L 818.564447 343.02622699999995 z M 796.054696 352.753194" stroke-linecap="round" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -10,7 +10,7 @@
<div class="survey_content"> <div class="survey_content">
<div class="survey_content_img"> <div class="survey_content_img">
<div class="oil-data"> <div class="oil-data">
<div class="led-number an1">2222L</div> <div class="led-number an1">{{ leftOilData[0] }}L</div>
<div class="oil-title">施工用油</div> <div class="oil-title">施工用油</div>
</div> </div>
@ -41,7 +41,7 @@
<div class="chart-bg power-chart1"> <div class="chart-bg power-chart1">
<div class="chart-proc"></div> <div class="chart-proc"></div>
<div class="data-top"> <div class="data-top">
<div class="chart-data led-number">2999339</div> <div class="chart-data led-number">{{ leftPowerData[0] }}</div>
<div class="chart-unit">kW</div> <div class="chart-unit">kW</div>
</div> </div>
<div class="data-bottom"> <div class="data-bottom">
@ -51,9 +51,9 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<div class="chart-bg power-chart2"> <div class="chart-bg power-chart2">
<div class="chart-proc" style="height:60%;"></div> <div class="chart-proc" :style="'height:'+leftPowerData[3]+'%'"></div>
<div class="data-top"> <div class="data-top">
<div class="chart-data led-number">2999339</div> <div class="chart-data led-number">{{ (leftPowerData[1]/1000.0).toFixed(1) }}</div>
<div class="chart-unit">(T CO₂)</div> <div class="chart-unit">(T CO₂)</div>
</div> </div>
<div class="data-bottom"> <div class="data-bottom">
@ -63,9 +63,9 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<div class="chart-bg power-chart3"> <div class="chart-bg power-chart3">
<div class="chart-proc" style="height:40%;"></div> <div class="chart-proc" :style="'height:'+leftPowerData[4]+'%;'"></div>
<div class="data-top"> <div class="data-top">
<div class="chart-data led-number">2999339</div> <div class="chart-data led-number">{{ (leftPowerData[2]/1000.0).toFixed(1) }}</div>
<div class="chart-unit">(T CO₂)</div> <div class="chart-unit">(T CO₂)</div>
</div> </div>
<div class="data-bottom"> <div class="data-bottom">
@ -87,7 +87,7 @@
碳排放预估总量(T CO₂) 碳排放预估总量(T CO₂)
</div> </div>
<div class="td-number"> <div class="td-number">
<people-number :number="225566.1" unit=""></people-number> <people-number :number="(totalData[0]/1000.0).toFixed(1)" unit=""></people-number>
</div> </div>
</div> </div>
</el-col> </el-col>
@ -98,7 +98,7 @@
碳排放监测累计总量(T CO₂) 碳排放监测累计总量(T CO₂)
</div> </div>
<div class="td-number"> <div class="td-number">
<people-number :number="225566.9" unit=""></people-number> <people-number :number="(totalData[1]/1000.0).toFixed(1)" unit=""></people-number>
</div> </div>
</div> </div>
</el-col> </el-col>
@ -109,7 +109,7 @@
当月碳排放监测量(T CO₂) 当月碳排放监测量(T CO₂)
</div> </div>
<div class="td-number"> <div class="td-number">
<people-number :number="225566.9" unit=""></people-number> <people-number :number="(totalData[2]/1000.0).toFixed(1)" unit=""></people-number>
</div> </div>
</div> </div>
</el-col> </el-col>
@ -136,10 +136,16 @@
</el-col> </el-col>
<el-col :span="6" class="h100"> <el-col :span="6" class="h100">
<module-one-1-1 label="建材排放趋势"> <module-one-1-1 label="建材排放趋势">
<my-chart :key="chartKey" id="right-build-chart" width="100%" height="100%"
:render="renderChart6"></my-chart>
</module-one-1-1> </module-one-1-1>
<module-one-1-1 label="用油排放趋势"> <module-one-1-1 label="用油排放趋势">
<my-chart :key="chartKey" id="right-oil-chart" width="100%" height="100%"
:render="renderChart7"></my-chart>
</module-one-1-1> </module-one-1-1>
<module-one-1-1 label="用电排放趋势"> <module-one-1-1 label="用电排放趋势">
<my-chart :key="chartKey" id="right-power-chart" width="100%" height="100%"
:render="renderChart8"></my-chart>
</module-one-1-1> </module-one-1-1>
</el-col> </el-col>
</div> </div>
@ -157,6 +163,12 @@ export default {
prjImgs: [], prjImgs: [],
selProject: null, selProject: null,
prjInfo: {}, prjInfo: {},
allData: [],
curMonthData: [],
yearMonthData: {},
leftOilData: [0, 0, 0, 0],
leftPowerData:[0,0,0,40,60],
totalData:[0,0,0],
} }
}, },
mounted() { mounted() {
@ -184,12 +196,72 @@ export default {
this.prjInfo = d.data || {}; this.prjInfo = d.data || {};
this.prjImgs = (this.prjInfo?.setting?.orgImage || '').split(",").filter(d => d); this.prjImgs = (this.prjInfo?.setting?.orgImage || '').split(",").filter(d => d);
}); });
this.loadData();
},
loadData() {
let projectId = this.selProject.id;
let comId = this.selProject.comId;
let ajax = [
this.$api.greenCarbon.groupByAll({
projectId: projectId,
comId: comId
}),
this.$api.greenCarbon.groupCurrentMonth({
projectId: projectId,
comId: comId,
createTime: this.$dt(new Date()).format("YYYY-MM-01"),
updateTime: this.$dt(new Date()).endOf("month").format("YYYY-MM-DD")
}),
this.$api.greenCarbon.groupByYearMonth({
projectId: projectId,
comId: comId,
createTime: this.$dt(new Date()).add(-11, "month").format("YYYY-MM-01"),
updateTime: this.$dt(new Date()).endOf("month").format("YYYY-MM-DD")
}),
];
this.$api.http.all(ajax).then(res => {
console.log(res)
this.allData = res[0];
this.curMonthData = res[1];
this.yearMonthData = res[2];
let tmps = this.allData.filter(it => it.factorType == 2);
this.leftOilData = tmps.length > 0 ? [
tmps[0].practicalValue,
tmps[0].sumPracticalValue,
tmps[0].sumEmissionReduction,
(Math.round(tmps[0].sumEstimateValue / 10000) + 1) * 10,
] : [0, 0, 0, 0];
tmps = this.allData.filter(it => it.factorType == 3);
this.leftPowerData=tmps.length>0?[
tmps[0].practicalValue,
tmps[0].sumPracticalValue,
tmps[0].sumEmissionReduction,
tmps[0].sumEstimateValue==0?0:tmps[0].sumPracticalValue*100/tmps[0].sumEstimateValue,
tmps[0].sumEstimateValue==0?0:tmps[0].sumEmissionReduction*100/tmps[0].sumEstimateValue,
]:[0,0,0,0,0];
tmps = this.allData.filter(it => it.factorType == 0);
this.totalData[0]=tmps.length>0?tmps[0].sumEstimateValue:0;
this.totalData[1]=tmps.length>0?tmps[0].sumPracticalValue:0;
tmps=this.curMonthData.filter(it=>it.factorType==0);
this.totalData[2]=tmps.length>0?tmps[0].emissionReduction:0
this.chartKey++;
});
}, },
renderChart1() { renderChart1() {
let tmps = this.allData.filter(it => it.factorType == 1);
let datas = tmps.length > 0 ? [tmps[0].sumPracticalValue, tmps[0].sumEmissionReduction] : [0, 0];
let is1K = this.$dpi() == "1K"; let is1K = this.$dpi() == "1K";
let is2K = this.$dpi() == "2K"; let is2K = this.$dpi() == "2K";
let option = { let option = {
color: ['#ff9f1a', '#00a4e6'], color: ['#ff9f1a', '#00a4e6'],
tooltip: {
trigger: "item",
valueFormatter: (v) => { return v + 'T CO₂' },
textStyle: {
fontSize: is1K ? 12 : is2K ? 14 : 24
},
},
legend: { legend: {
bottom: is1K ? '0%' : is2K ? '10%' : '10%', bottom: is1K ? '0%' : is2K ? '10%' : '10%',
left: 'center', left: 'center',
@ -214,7 +286,7 @@ export default {
borderWidth: 2 borderWidth: 2
}, },
label: { label: {
formatter: ["{b|{b}}", "{c|{c}\nT CO₂}"].join("\n"),//"{b|b}\n{c|c T CO2}", formatter: ["{b|{b}}", "{c|{c}\nT CO₂}"].join("\n"),
rich: { rich: {
b: { b: {
color: '#fff', color: '#fff',
@ -234,9 +306,8 @@ export default {
show: true show: true
}, },
data: [ data: [
{ value: 1048, name: '碳排放' }, { value: (datas[0] / 1000.0).toFixed(1), name: '碳排放' },
{ value: 735, name: '碳减排' }, { value: (datas[1] / 1000.0).toFixed(1), name: '碳减排' },
] ]
} }
] ]
@ -252,7 +323,7 @@ export default {
type: 'gauge', type: 'gauge',
startAngle: 180, startAngle: 180,
endAngle: 0, endAngle: 0,
max: 6000, max: this.leftOilData[3],
center: ['50%', '90%'], center: ['50%', '90%'],
radius: '120%', radius: '120%',
itemStyle: { itemStyle: {
@ -310,7 +381,7 @@ export default {
}, },
data: [ data: [
{ {
value: 4000, value: (this.leftOilData[1] / 1000.0).toFixed(1),
name: '碳排放(T CO₂)' name: '碳排放(T CO₂)'
} }
] ]
@ -328,7 +399,7 @@ export default {
type: 'gauge', type: 'gauge',
startAngle: 180, startAngle: 180,
endAngle: 0, endAngle: 0,
max: 6000, max: this.leftOilData[3],
center: ['50%', '90%'], center: ['50%', '90%'],
radius: '120%', radius: '120%',
itemStyle: { itemStyle: {
@ -386,7 +457,7 @@ export default {
}, },
data: [ data: [
{ {
value: 4000, value: (this.leftOilData[2] / 1000.0).toFixed(1),
name: '碳减排(T CO₂)' name: '碳减排(T CO₂)'
} }
] ]
@ -396,8 +467,19 @@ export default {
return option; return option;
}, },
renderChart4() { renderChart4() {
let sum=(objs)=>{
let res=0;
objs.forEach(it=>{
res+=(it||0);
});
return res;
}
let is1K = this.$dpi() == "1K"; let is1K = this.$dpi() == "1K";
let is2K = this.$dpi() == "2K"; let is2K = this.$dpi() == "2K";
let datas=[0,0,0];
datas[0]=this.yearMonthData.buildData?sum(this.yearMonthData.buildData.emissionReduction.datas):0;
datas[1]=this.yearMonthData.oilData?sum(this.yearMonthData.oilData.emissionReduction.datas):0;
datas[2]=this.yearMonthData.powerData?sum(this.yearMonthData.powerData.emissionReduction.datas):0;
let option = { let option = {
legend: { legend: {
@ -411,6 +493,13 @@ export default {
fontSize: is1K ? 14 : is2K ? 20 : 30, fontSize: is1K ? 14 : is2K ? 20 : 30,
} }
}, },
tooltip: {
trigger: "item",
valueFormatter: (v) => { return v + 'T CO₂' },
textStyle: {
fontSize: is1K ? 12 : is2K ? 14 : 24
},
},
color: ['#C060F6', '#5087EC', '#FFBB3A'], color: ['#C060F6', '#5087EC', '#FFBB3A'],
series: [ series: [
{ {
@ -424,9 +513,9 @@ export default {
borderWidth: 2 borderWidth: 2
}, },
data: [ data: [
{ value: 40000, name: '电力' }, { value: datas[2].toFixed(1), name: '电力' },
{ value: 38888, name: '建材' }, { value: datas[0].toFixed(1), name: '建材' },
{ value: 32222, name: '油耗' }, { value: datas[1].toFixed(1), name: '油耗' },
], ],
label: { label: {
overflow: 'none', overflow: 'none',
@ -457,7 +546,467 @@ export default {
let is1K = this.$dpi() == "1K"; let is1K = this.$dpi() == "1K";
let is2K = this.$dpi() == "2K"; let is2K = this.$dpi() == "2K";
let option = { let option = {
grid: {
left: "5%",
right: "5%",
bottom: "0%",
top: "15%",
containLabel: true,
},
tooltip: {
trigger: "axis",
valueFormatter: (v) => { return v?v:'- ' + 'T CO₂' },
textStyle: {
fontSize: is1K ? 12 : is2K ? 14 : 24
},
},
legend: {
top: is1K ? '0%' : is2K ? '0%' : '0%',
left: 'center',
itemWidth: is1K ? 25 : is2K ? 30 : 40,
itemHeight: is1K ? 14 : is2K ? 20 : 20,
itemGap: is1K ? 20 : is2K ? 30 : 40,
textStyle: {
color: "#fff",
fontSize: is1K ? 14 : is2K ? 20 : 30,
}
},
calculable: true,
xAxis: [
{
type: "category",
boundaryGap: false,
data: this.yearMonthData?.totalData?.emissionReduction?.titles||[],
axisLabel: {
fontSize: is1K ? 12 : is2K ? 14 : 24,
color: "#a2c8f9"
},
splitLine: {
lineStyle: {
opacity: 0.1
}
}
},
],
yAxis: [
{
type: "value",
axisLabel: {
formatter: '{value}T CO₂',
color: "#2ec2b3",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
splitLine: {
lineStyle: {
opacity: 0.1
}
},
},
],
series: [
{
name: '碳预估',
type: "line",
smooth: true,
label: {
show: true,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7ddff2",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7ddff2", opacity: 0.1 } },
},
data: this.yearMonthData?.totalData?.estimate?.datas||[],
},
{
name: '碳排放',
type: "line",
smooth: true,
label: {
show: true,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#006594",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#006594", opacity: 0.1 } },
},
data: this.yearMonthData?.totalData?.practical?.datas||[],
},
{
name: '碳减排',
type: "line",
smooth: true,
label: {
show: true,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7db800",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7db800", opacity: 0.1 } },
},
data: this.yearMonthData?.totalData?.emissionReduction?.datas||[],
},
],
};
return option;
},
renderChart6() {
let is1K = this.$dpi() == "1K";
let is2K = this.$dpi() == "2K";
let option = {
grid: {
left: "5%",
right: "5%",
bottom: "0%",
top: "15%",
containLabel: true,
},
tooltip: {
trigger: "axis",
valueFormatter: (v) => { return v?v:' - ' + 'T CO₂' },
textStyle: {
fontSize: is1K ? 12 : is2K ? 14 : 24
},
},
legend: {
top: is1K ? '0%' : is2K ? '0%' : '0%',
left: 'center',
itemWidth: is1K ? 25 : is2K ? 30 : 40,
itemHeight: is1K ? 14 : is2K ? 20 : 20,
itemGap: is1K ? 20 : is2K ? 30 : 40,
textStyle: {
color: "#fff",
fontSize: is1K ? 14 : is2K ? 20 : 30,
}
},
calculable: true,
xAxis: [
{
type: "category",
boundaryGap: false,
data: this.yearMonthData?.buildData?.emissionReduction?.titles||[],
axisLabel: {
fontSize: is1K ? 12 : is2K ? 14 : 24,
color: "#a2c8f9"
},
splitLine: {
lineStyle: {
opacity: 0.1
}
}
},
],
yAxis: [
{
type: "value",
axisLabel: {
formatter: '{value}T CO₂',
color: "#2ec2b3",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
splitLine: {
lineStyle: {
opacity: 0.1
}
},
},
],
series: [
{
name: '碳预估',
type: "bar",
smooth: true,
label: {
show: false,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7ddff2",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7ddff2", opacity: 0.1 } },
},
data:this.yearMonthData?.buildData?.estimate?.datas||[],
},
{
name: '碳排放',
type: "bar",
smooth: true,
label: {
show: false,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#006594",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#006594", opacity: 0.1 } },
},
data: this.yearMonthData?.buildData?.practical?.datas||[],
},
{
name: '碳减排',
type: "bar",
smooth: true,
label: {
show: false,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7db800",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7db800", opacity: 0.1 } },
},
data: this.yearMonthData?.buildData?.emissionReduction?.datas||[],
},
],
};
return option;
},
renderChart7() {
let is1K = this.$dpi() == "1K";
let is2K = this.$dpi() == "2K";
let option = {
grid: {
left: "5%",
right: "5%",
bottom: "0%",
top: "15%",
containLabel: true,
},
tooltip: {
trigger: "axis",
valueFormatter: (v) => { return v?v:' - ' + 'T CO₂' },
textStyle: {
fontSize: is1K ? 12 : is2K ? 14 : 24
},
},
legend: {
top: is1K ? '0%' : is2K ? '0%' : '0%',
left: 'center',
itemWidth: is1K ? 25 : is2K ? 30 : 40,
itemHeight: is1K ? 14 : is2K ? 20 : 20,
itemGap: is1K ? 20 : is2K ? 30 : 40,
textStyle: {
color: "#fff",
fontSize: is1K ? 14 : is2K ? 20 : 30,
}
},
calculable: true,
xAxis: [
{
type: "category",
boundaryGap: false,
data: this.yearMonthData?.oilData?.emissionReduction?.titles||[],
axisLabel: {
fontSize: is1K ? 12 : is2K ? 14 : 24,
color: "#a2c8f9"
},
splitLine: {
lineStyle: {
opacity: 0.1
}
}
},
],
yAxis: [
{
type: "value",
axisLabel: {
formatter: '{value}T CO₂',
color: "#2ec2b3",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
splitLine: {
lineStyle: {
opacity: 0.1
}
},
},
],
series: [
{
name: '碳预估',
type: "line",
smooth: true,
label: {
show: true,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7ddff2",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7ddff2", opacity: 0.1 } },
},
data: this.yearMonthData?.oilData?.estimate?.datas||[],
},
{
name: '碳排放',
type: "line",
smooth: true,
label: {
show: true,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#006594",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#006594", opacity: 0.1 } },
},
data: this.yearMonthData?.oilData?.practical?.datas||[],
},
{
name: '碳减排',
type: "line",
smooth: true,
label: {
show: true,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7db800",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7db800", opacity: 0.1 } },
},
data: this.yearMonthData?.oilData?.emissionReduction?.datas||[],
},
],
};
return option;
},
renderChart8() {
let is1K = this.$dpi() == "1K";
let is2K = this.$dpi() == "2K";
let option = {
grid: {
left: "5%",
right: "5%",
bottom: "0%",
top: "15%",
containLabel: true,
},
tooltip: {
trigger: "axis",
valueFormatter: (v) => { return v?v:' - ' + 'T CO₂' },
textStyle: {
fontSize: is1K ? 12 : is2K ? 14 : 24
},
},
legend: {
top: is1K ? '0%' : is2K ? '0%' : '0%',
left: 'center',
itemWidth: is1K ? 25 : is2K ? 30 : 40,
itemHeight: is1K ? 14 : is2K ? 20 : 20,
itemGap: is1K ? 20 : is2K ? 30 : 40,
textStyle: {
color: "#fff",
fontSize: is1K ? 14 : is2K ? 20 : 30,
}
},
calculable: true,
xAxis: [
{
type: "category",
boundaryGap: false,
data: this.yearMonthData?.powerData?.emissionReduction?.titles||[],
axisLabel: {
fontSize: is1K ? 12 : is2K ? 14 : 24,
color: "#a2c8f9"
},
splitLine: {
lineStyle: {
opacity: 0.1
}
}
},
],
yAxis: [
{
type: "value",
axisLabel: {
formatter: '{value}T CO₂',
color: "#2ec2b3",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
splitLine: {
lineStyle: {
opacity: 0.1
}
},
},
],
series: [
{
name: '碳预估',
type: "bar",
smooth: true,
label: {
show: false,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7ddff2",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7ddff2", opacity: 0.1 } },
},
data:this.yearMonthData?.powerData?.estimate?.datas||[],
},
{
name: '碳排放',
type: "bar",
smooth: true,
label: {
show: false,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#006594",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#006594", opacity: 0.1 } },
},
data: this.yearMonthData?.powerData?.practical?.datas||[],
},
{
name: '碳减排',
type: "bar",
smooth: true,
label: {
show: false,
color: "#4DAAFC",
fontSize: is1K ? 12 : is2K ? 14 : 24
},
lineStyle: {
color: "#7db800",
},
itemStyle: {
normal: { areaStyle: { type: "default", color: "#7db800", opacity: 0.1 } },
},
data: this.yearMonthData?.powerData?.emissionReduction?.datas||[],
},
],
}; };
return option; return option;
} }
@ -1029,6 +1578,7 @@ export default {
.el-col { .el-col {
&.et-chart1 { &.et-chart1 {
position: relative; position: relative;
.time-img { .time-img {
position: absolute; position: absolute;
width: 400px; width: 400px;

View File

@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.yanzhu.common.core.annotation.Excel; import com.yanzhu.common.core.annotation.Excel;
import com.yanzhu.common.core.web.domain.BaseEntity; import com.yanzhu.common.core.web.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
* green_carbon_data * green_carbon_data
@ -34,11 +35,11 @@ public class GreenCarbonData extends BaseEntity
/** 预估使用数量 */ /** 预估使用数量 */
@Excel(name = "预估使用数量") @Excel(name = "预估使用数量")
private Long estimateValue; private BigDecimal estimateValue;
/** 实际使用量 */ /** 实际使用量 */
@Excel(name = " 实际使用量") @Excel(name = " 实际使用量")
private Long practicalValue; private BigDecimal practicalValue;
/** 状态 */ /** 状态 */
@Excel(name = "状态") @Excel(name = "状态")
@ -51,6 +52,25 @@ public class GreenCarbonData extends BaseEntity
private Long factorType; private Long factorType;
private Date dataDate; private Date dataDate;
private BigDecimal sumEstimateValue;
private BigDecimal sumPracticalValue;
public BigDecimal getSumEstimateValue() {
return sumEstimateValue;
}
public void setSumEstimateValue(BigDecimal sumEstimateValue) {
this.sumEstimateValue = sumEstimateValue;
}
public BigDecimal getSumPracticalValue() {
return sumPracticalValue;
}
public void setSumPracticalValue(BigDecimal sumPracticalValue) {
this.sumPracticalValue = sumPracticalValue;
}
public Long getFactorType() { public Long getFactorType() {
return factorType; return factorType;
} }
@ -113,21 +133,21 @@ public class GreenCarbonData extends BaseEntity
{ {
return itemId; return itemId;
} }
public void setEstimateValue(Long estimateValue) public void setEstimateValue(BigDecimal estimateValue)
{ {
this.estimateValue = estimateValue; this.estimateValue = estimateValue;
} }
public Long getEstimateValue() public BigDecimal getEstimateValue()
{ {
return estimateValue; return estimateValue;
} }
public void setPracticalValue(Long practicalValue) public void setPracticalValue(BigDecimal practicalValue)
{ {
this.practicalValue = practicalValue; this.practicalValue = practicalValue;
} }
public Long getPracticalValue() public BigDecimal getPracticalValue()
{ {
return practicalValue; return practicalValue;
} }

View File

@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.yanzhu.common.core.annotation.Excel; import com.yanzhu.common.core.annotation.Excel;
import com.yanzhu.common.core.web.domain.BaseEntity; import com.yanzhu.common.core.web.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
@ -49,7 +50,7 @@ public class GreenCarbonItem extends BaseEntity
/** 碳排放因子 */ /** 碳排放因子 */
@Excel(name = "碳排放因子") @Excel(name = "碳排放因子")
private Long carbonFactor; private BigDecimal carbonFactor;
@Excel(name = "说明") @Excel(name = "说明")
private String remark; private String remark;
@ -137,12 +138,12 @@ public class GreenCarbonItem extends BaseEntity
{ {
return unit; return unit;
} }
public void setCarbonFactor(Long carbonFactor) public void setCarbonFactor(BigDecimal carbonFactor)
{ {
this.carbonFactor = carbonFactor; this.carbonFactor = carbonFactor;
} }
public Long getCarbonFactor() public BigDecimal getCarbonFactor()
{ {
return carbonFactor; return carbonFactor;
} }

View File

@ -63,4 +63,16 @@ public interface GreenCarbonDataMapper
* *
*/ */
List<GreenCarbonData> groupByFactorType(GreenCarbonData greenCarbonData); List<GreenCarbonData> groupByFactorType(GreenCarbonData greenCarbonData);
/**
*
*/
List<GreenCarbonData> groupByAll(GreenCarbonData where);
/**
*
*/
List<GreenCarbonData> groupCurrentMonth(GreenCarbonData where);
/**
* 12
*/
List<GreenCarbonData> groupByYearMonth(GreenCarbonData where);
} }

View File

@ -12,6 +12,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="itemId" column="item_id" /> <result property="itemId" column="item_id" />
<result property="estimateValue" column="estimate_value" /> <result property="estimateValue" column="estimate_value" />
<result property="practicalValue" column="practical_value" /> <result property="practicalValue" column="practical_value" />
<result property="sumEstimateValue" column="sum_estimate_value" />
<result property="sumPracticalValue" column="sum_practical_value" />
<result property="state" column="state" /> <result property="state" column="state" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="isDel" column="is_del" /> <result property="isDel" column="is_del" />
@ -66,6 +68,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
GROUP BY g.carbon_factor_type GROUP BY g.carbon_factor_type
</select> </select>
<select id="groupByAll" parameterType="GreenCarbonData" resultMap="GreenCarbonDataResult">
select gi.carbon_factor_type factor_type,sum(gd.estimate_value*gi.carbon_factor) sum_estimate_value,sum(gd.practical_value*gi.carbon_factor) sum_practical_value,
sum(gd.estimate_value) estimate_value,sum(gd.practical_value) practical_value
from green_carbon_data gd,green_carbon_item gi
where gd.item_id=gi.id
<if test="comId != null "> and gd.com_id = #{comId}</if>
<if test="projectId != null "> and gd.project_id = #{projectId}</if>
group by gi.carbon_factor_type
</select>
<select id="groupCurrentMonth" parameterType="GreenCarbonData" resultMap="GreenCarbonDataResult">
select gi.carbon_factor_type factor_type,sum(gd.estimate_value*gi.carbon_factor) estimate_value,sum(gd.practical_value*gi.carbon_factor) practical_value
from green_carbon_data gd,green_carbon_item gi
where gd.item_id=gi.id
<if test="comId != null "> and gd.com_id = #{comId}</if>
<if test="projectId != null "> and gd.project_id = #{projectId}</if>
<if test="createTime != null "> and date(gd.data_date) &gt;= date(#{createTime})</if>
<if test="updateTime != null "> and date(gd.data_date) &lt;= date(#{updateTime})</if>
group by gi.carbon_factor_type
</select>
<select id="groupByYearMonth" parameterType="GreenCarbonData" resultMap="GreenCarbonDataResult">
select gi.carbon_factor_type factor_type,year(gd.data_date) com_id,MONTH(gd.data_date) project_id,sum(gd.estimate_value*gi.carbon_factor) estimate_value,sum(gd.practical_value*gi.carbon_factor) practical_value
from green_carbon_data gd,green_carbon_item gi
where gd.item_id=gi.id
<if test="comId != null "> and gd.com_id = #{comId}</if>
<if test="projectId != null "> and gd.project_id = #{projectId}</if>
<if test="createTime != null "> and date(gd.data_date) &gt;= date(#{createTime})</if>
<if test="updateTime != null "> and date(gd.data_date) &lt;= date(#{updateTime})</if>
group by gi.carbon_factor_type,year(gd.data_date),MONTH(gd.data_date)
</select>
<select id="selectGreenCarbonDataById" parameterType="Long" resultMap="GreenCarbonDataResult"> <select id="selectGreenCarbonDataById" parameterType="Long" resultMap="GreenCarbonDataResult">
<include refid="selectGreenCarbonDataVo"/> <include refid="selectGreenCarbonDataVo"/>
where gd.id = #{id} where gd.id = #{id}

View File

@ -49,6 +49,36 @@ public class GreenCarbonDataController extends BaseController
List<GreenCarbonData> list = greenCarbonDataService.selectGreenCarbonDataList(greenCarbonData); List<GreenCarbonData> list = greenCarbonDataService.selectGreenCarbonDataList(greenCarbonData);
return getDataTable(list); return getDataTable(list);
} }
/**
*
*/
@RequiresPermissions("manage:greenCarbonData:list")
@GetMapping("/groupByAll")
public AjaxResult groupByAll(GreenCarbonData where){
List<GreenCarbonData> list = greenCarbonDataService.groupByAll(where);
return AjaxResult.success(list);
}
/**
*
*/
@RequiresPermissions("manage:greenCarbonData:list")
@GetMapping("/groupCurrentMonth")
public AjaxResult groupCurrentMonth(GreenCarbonData where){
List<GreenCarbonData> list = greenCarbonDataService.groupCurrentMonth(where);
return AjaxResult.success(list);
}
/**
* 12
*/
@RequiresPermissions("manage:greenCarbonData:list")
@GetMapping("/groupByYearMonth")
public AjaxResult groupByYearMonth(GreenCarbonData where){
List<GreenCarbonData> list = greenCarbonDataService.groupByYearMonth(where);
return AjaxResult.success(list);
}
/** /**
* *
*/ */
@ -124,6 +154,8 @@ public class GreenCarbonDataController extends BaseController
return toAjax(greenCarbonDataService.updateGreenCarbonData(greenCarbonData)); return toAjax(greenCarbonDataService.updateGreenCarbonData(greenCarbonData));
} }
/** /**
* *
*/ */

View File

@ -62,4 +62,16 @@ public interface IGreenCarbonDataService
* *
*/ */
List<GreenCarbonData> groupByFactorType(GreenCarbonData greenCarbonData); List<GreenCarbonData> groupByFactorType(GreenCarbonData greenCarbonData);
/**
*
*/
List<GreenCarbonData> groupByAll(GreenCarbonData where);
/**
*
*/
List<GreenCarbonData> groupCurrentMonth(GreenCarbonData where);
/**
* 12
*/
List<GreenCarbonData> groupByYearMonth(GreenCarbonData where);
} }

View File

@ -104,4 +104,25 @@ public class GreenCarbonDataServiceImpl implements IGreenCarbonDataService
public List<GreenCarbonData> groupByFactorType(GreenCarbonData greenCarbonData) { public List<GreenCarbonData> groupByFactorType(GreenCarbonData greenCarbonData) {
return greenCarbonDataMapper.groupByFactorType(greenCarbonData); return greenCarbonDataMapper.groupByFactorType(greenCarbonData);
} }
/**
*
*/
@Override
public List<GreenCarbonData> groupByAll(GreenCarbonData where) {
return greenCarbonDataMapper.groupByAll(where);
}
/**
*
*/
@Override
public List<GreenCarbonData> groupCurrentMonth(GreenCarbonData where) {
return greenCarbonDataMapper.groupCurrentMonth(where);
}
/**
* 12
*/
@Override
public List<GreenCarbonData> groupByYearMonth(GreenCarbonData where) {
return greenCarbonDataMapper.groupByYearMonth(where);
}
} }

View File

@ -308,6 +308,7 @@ function handleExport() {
} }
data.projectId=userStore.currentProId; data.projectId=userStore.currentProId;
data.compId=userStore.currentComId; data.compId=userStore.currentComId;
queryParams.value.projectId=data.projectId;
getList(); getList();
getProjectList(); getProjectList();
</script> </script>