Commit 919aface authored by xulihui's avatar xulihui

第三方施工汇总分析

parent e72c8afb
package com.zehong.web.controller.thirdbuild;
import java.util.List;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -120,11 +122,21 @@ public class TConGasProInforController extends BaseController
/**
* 企业端上传第三方施工
* @param fConGasProInforId 第三方施工id
* @param fConGasProInforId 第三方施工 id
* @return
*/
@GetMapping("/entReportConGasProInfo")
public AjaxResult entReportConGasProInfo(Long fConGasProInforId){
return toAjax(tConGasProInforService.entReportConGasProInfo(fConGasProInforId));
}
/**
* 第三方施工统计分析
*/
@GetMapping("/summaryAnalysis")
public AjaxResult summaryAnalysis(TConGasProInfor tConGasProInfor)
{
List<Map<String, Object>> list = tConGasProInforService.summaryAnalysis(tConGasProInfor);
return AjaxResult.success(list);
}
}
......@@ -29,6 +29,8 @@ public interface TConGasProIncMapper
*/
public List<TConGasProInc> selectTConGasProIncList(TConGasProInc tConGasProInc);
public List<TConGasProInc> selectTConGasProIncListStatistics(TConGasProInc tConGasProInc);
/**
* 查询第三方施工-涉气第三方施工意外事件列表 - 导出
*
......
......@@ -27,6 +27,8 @@ public interface ITConGasProIncService
*/
public List<TConGasProInc> selectTConGasProIncList(TConGasProInc tConGasProInc);
public List<TConGasProInc> selectTConGasProIncListStatistics(TConGasProInc tConGasProInc);
/**
* 查询第三方施工-涉气第三方施工意外事件列表-导出
*
......
......@@ -80,4 +80,11 @@ public interface ITConGasProInforService
* @return
*/
int entReportConGasProInfo(Long fConGasProInforId);
/**
* 第三方施工统计分析
* @param tConGasProInfor 查询条件
* @return 统计结果
*/
java.util.List<java.util.Map<String, Object>> summaryAnalysis(TConGasProInfor tConGasProInfor);
}
......@@ -73,6 +73,20 @@ public class TConGasProIncServiceImpl implements ITConGasProIncService
return tConGasProIncMapper.selectTConGasProIncList(tConGasProInc);
}
@Override
public List<TConGasProInc> selectTConGasProIncListStatistics(TConGasProInc tConGasProInc)
{
SysRole sysRole = SecurityUtils.getLoginUser().getUser().getRoles().get(0);
// 不是超级管理员也不是企业
if (sysRole.getRoleId() == 3) {
tConGasProInc.setEntUploadState("1");
}
return tConGasProIncMapper.selectTConGasProIncListStatistics(tConGasProInc);
}
/**
* 查询第三方施工-涉气第三方施工意外事件列表
*
......
......@@ -8,10 +8,12 @@ import com.zehong.common.utils.*;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.SysSetting;
import com.zehong.system.domain.TConGasProInfor;
import com.zehong.system.domain.TConGasProInc;
import com.zehong.system.domain.TPipeOldPlanProcess;
import com.zehong.system.domain.vo.TConGasProInforVo;
import com.zehong.system.mapper.TConGasProInforMapper;
import com.zehong.system.service.ISysSettingService;
import com.zehong.system.service.ITConGasProIncService;
import com.zehong.system.service.ITConGasProInforService;
import com.zehong.system.service.ITSerialNumberInfoService;
import org.slf4j.Logger;
......@@ -22,14 +24,11 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.Year;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* 第三方施工-涉气第三方施工项目档案Service业务层处理
* 第三方施工 - 涉气第三方施工项目档案 Service 业务层处理
*
* @author zehong
* @date 2024-06-26
......@@ -51,6 +50,9 @@ public class TConGasProInforServiceImpl implements ITConGasProInforService
@Resource
private GovernmentDataUtil governmentDataUtil;
@Resource
private ITConGasProIncService tConGasProIncService;
/**
* 查询第三方施工-涉气第三方施工项目档案
*
......@@ -196,4 +198,80 @@ public class TConGasProInforServiceImpl implements ITConGasProInforService
tConGasProInforMapper.updateEntUploadStateById("1",new Date(),fConGasProInforId);
return 1;
}
/**
* 第三方施工统计分析
* @param tConGasProInfor 查询条件
* @return 统计结果
*/
@Override
public List<Map<String, Object>> summaryAnalysis(TConGasProInfor tConGasProInfor) {
// 处理年份查询条件
if (StringUtils.isNotEmpty(tConGasProInfor.getfUpdateTime())) {
String year = tConGasProInfor.getfUpdateTime().substring(0, 4);
tConGasProInfor.setfUpdateTime(year + "-01-01 00:00:00");
}
// 查询所有符合条件的数据
List<TConGasProInfor> allData = tConGasProInforMapper.selectTConGasProInforList(tConGasProInfor);
// 按企业分组统计
Map<String, List<TConGasProInfor>> groupedByCompany = allData.stream()
.collect(Collectors.groupingBy(TConGasProInfor::getfCompanyInfoId));
List<Map<String, Object>> result = new ArrayList<>();
for (Map.Entry<String, List<TConGasProInfor>> entry : groupedByCompany.entrySet()) {
String companyId = entry.getKey();
List<TConGasProInfor> companyData = entry.getValue();
Map<String, Object> stat = new HashMap<>();
stat.put("fCompanyInfoId", companyId);
// 施工数
stat.put("constructionCount", companyData.size());
// 报备数 (fReportFlag=1)
long reportCount = companyData.stream()
.filter(item -> "1".equals(item.getfReportFlag()))
.count();
stat.put("reportCount", reportCount);
// 旁站监督数 (fGasCompanyStationNo 或 fGasCompanyStationName 或 fGasCompanyStationPhone 有值)
long supervisionCount = companyData.stream()
.filter(item -> StringUtils.isNotEmpty(item.getfGasCompanyStationNo())
|| StringUtils.isNotEmpty(item.getfGasCompanyStationName())
|| StringUtils.isNotEmpty(item.getfGasCompanyStationPhone()))
.count();
stat.put("supervisionCount", supervisionCount);
result.add(stat);
}
// 统计意外事件数据
try {
TConGasProInc incQuery = new TConGasProInc();
incQuery.setfCompanyInfoId(tConGasProInfor.getfCompanyInfoId());
incQuery.setfUpdateTime(tConGasProInfor.getfUpdateTime());
List<TConGasProInc> incData = tConGasProIncService.selectTConGasProIncListStatistics(incQuery);
// 按企业分组统计意外事件
Map<String, Long> incCountByCompany = incData.stream()
.collect(Collectors.groupingBy(TConGasProInc::getfCompanyInfoId, Collectors.counting()));
// 将意外事件数量添加到结果中
for (Map<String, Object> stat : result) {
String companyId = (String) stat.get("fCompanyInfoId");
stat.put("accidentCount", incCountByCompany.getOrDefault(companyId, 0L));
}
} catch (Exception e) {
log.error("统计意外事件数据异常", e);
// 如果意外事件统计失败,设置为 0
for (Map<String, Object> stat : result) {
stat.put("accidentCount", 0L);
}
}
return result;
}
}
......@@ -61,6 +61,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by f_update_time desc
</select>
<select id="selectTConGasProIncListStatistics" parameterType="TConGasProInc" resultMap="TConGasProIncResult">
SELECT *
FROM
t_con_gas_pro_inc inc
<where>
<if test="fTitle != null and fTitle != ''"> and inc.f_title like concat('%', #{fTitle}, '%')</if>
<if test="fDescription != null and fDescription != ''"> and inc.f_description = #{fDescription}</if>
<if test="fOccurrenctTime != null and fOccurrenctTime != ''"> and inc.f_occurrenct_time = #{fOccurrenctTime}</if>
<if test="fAttachment != null and fAttachment != ''"> and inc.f_attachment = #{fAttachment}</if>
<if test="fRemark != null and fRemark != ''"> and inc.f_remark = #{fRemark}</if>
<if test="fUpdateTime != null and fUpdateTime != ''"> and DATE_FORMAT(inc.f_update_time, '%Y') = DATE_FORMAT(#{fUpdateTime}, '%Y')</if>
<if test="fCompanyInfoId != null and fCompanyInfoId != ''"> and inc.f_company_info_id = #{fCompanyInfoId}</if>
<if test="entUploadState != null and entUploadState != ''"> and inc.f_ent_upload_state = #{entUploadState}</if>
<if test="govUploadState != null and govUploadState != ''"> and inc.f_gov_upload_state = #{govUploadState}</if>
</where>
order by f_update_time desc
</select>
<select id="exportTConGasProInforList" parameterType="TConGasProInc" resultMap="TConGasProIncResult">
<include refid="selectTConGasProIncVo"/>
<where>
......
......@@ -146,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fPipePress != null and fPipePress != ''"> and f_pipe_press = #{fPipePress}</if>
<if test="entUploadState != null and entUploadState != ''"> and f_ent_upload_state = #{entUploadState}</if>
<if test="fCompanyInfoId != null and fCompanyInfoId != ''"> and f_company_info_id = #{fCompanyInfoId}</if>
<if test="fUpdateTime != null and fUpdateTime != ''"> and DATE_FORMAT(f_update_time, '%Y') = DATE_FORMAT(#{fUpdateTime}, '%Y')</if>
</where>
order by f_update_time desc
</select>
......
......@@ -76,3 +76,12 @@ export function conGasProInfoList(query) {
params: query
})
}
// 第三方施工统计分析
export function summaryAnalysis(query) {
return request({
url: '/third/project/summaryAnalysis',
method: 'get',
params: query
})
}
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px">
<el-form-item label="年份" prop="year">
<el-date-picker
v-model="queryParams.year"
type="year"
value-format="yyyy"
placeholder="选择年份"
style="width: 200px"
@change="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button type="primary" icon="el-icon-download" size="mini" @click="report">上报</el-button>
</el-form-item>
</el-form>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>第三方施工汇总分析</span>
</div>
<div class="chart-container">
<div ref="chart" class="echarts"></div>
</div>
</el-card>
</div>
</template>
<script>
import { summaryAnalysis } from "@/api/thirdbuild/project";
import { enterpriseLists } from "@/api/regulation/info";
export default {
name: "SummaryAnalysis",
data() {
return {
queryParams: {
year: new Date().getFullYear().toString()
},
chartData: [],
enterprises: [],
chartInstance: null
};
},
created() {
this.getEnterpriseLists();
},
mounted() {
this.$nextTick(() => {
this.initChart();
this.getList();
});
window.addEventListener('resize', this.handleResize);
},
beforeDestroy() {
if (this.chartInstance) {
this.chartInstance.dispose();
}
window.removeEventListener('resize', this.handleResize);
},
methods: {
getEnterpriseLists() {
const param = {};
enterpriseLists(param).then(response => {
this.enterprises = response.rows;
this.getList();
});
},
getList() {
if (!this.queryParams.year) {
this.queryParams.year = new Date().getFullYear().toString();
}
// 将年份转换为完整的日期格式传递给后端
const params = {
...this.queryParams,
fUpdateTime: this.queryParams.year + '-01-01 00:00:00'
};
summaryAnalysis(params).then(response => {
this.chartData = response.data || [];
this.updateChart();
});
},
handleQuery() {
this.getList();
},
resetQuery() {
this.resetForm("queryForm");
this.queryParams.year = new Date().getFullYear().toString();
this.getList();
},
initChart() {
this.chartInstance = this.$echarts.init(this.$refs.chart);
this.updateChart();
},
updateChart() {
if (!this.chartInstance) return;
const enterpriseNames = this.enterprises.map(item => item.enterpriseName);
const constructionCounts = [];
const reportCounts = [];
const supervisionCounts = [];
const accidentCounts = [];
this.enterprises.forEach(enterprise => {
const enterpriseData = this.chartData.find(item => item.fCompanyInfoId === enterprise.enterpriseId);
constructionCounts.push(enterpriseData ? enterpriseData.constructionCount : 0);
reportCounts.push(enterpriseData ? enterpriseData.reportCount : 0);
supervisionCounts.push(enterpriseData ? enterpriseData.supervisionCount : 0);
accidentCounts.push(enterpriseData ? enterpriseData.accidentCount : 0);
});
const option = {
title: {
text: `${this.queryParams.year}年第三方施工统计分析`,
left: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: ['施工数', '报备数', '旁站监督数', '发生意外情况数'],
top: '30px'
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
top: '80px'
},
xAxis: {
type: 'category',
data: enterpriseNames,
axisLabel: {
interval: 0,
rotate: 30
}
},
yAxis: {
type: 'value',
name: '数量'
},
series: [
{
name: '施工数',
type: 'bar',
data: constructionCounts,
itemStyle: {
color: '#5470c6'
}
},
{
name: '报备数',
type: 'bar',
data: reportCounts,
itemStyle: {
color: '#91cc75'
}
},
{
name: '旁站监督数',
type: 'bar',
data: supervisionCounts,
itemStyle: {
color: '#fac858'
}
},
{
name: '发生意外情况数',
type: 'bar',
data: accidentCounts,
itemStyle: {
color: '#ee6666'
}
}
]
};
this.chartInstance.setOption(option);
},
handleResize() {
if (this.chartInstance) {
this.chartInstance.resize();
}
},
report(row){
this.$confirm('是否确认上报未主动报备的第三方施工企业', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
//暂无接口
}).then(() => {
this.msgSuccess("上报成功");
}).catch(() => {});
},
}
};
</script>
<style scoped lang="scss">
.box-card {
margin-top: 20px;
}
.chart-container {
width: 100%;
height: 600px;
.echarts {
width: 100%;
height: 100%;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment