This commit is contained in:
gongjiale 2024-09-12 13:26:48 +08:00
commit 0334f6649f
13 changed files with 648 additions and 60 deletions

View File

@ -7,14 +7,13 @@ import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.oil.domain.ThDeviceReportMonth;
import com.ruoyi.project.oil.domain.monitor.ThDevice; import com.ruoyi.project.oil.domain.monitor.ThDevice;
import com.ruoyi.project.oil.domain.monitor.ThDeviceReport; import com.ruoyi.project.oil.domain.monitor.ThDeviceReport;
import com.ruoyi.project.oil.service.IOilThDeviceService; import com.ruoyi.project.oil.service.IOilThDeviceService;
import com.ruoyi.project.oil.service.ThDeviceReportMonthService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -30,6 +29,9 @@ public class OilStatisticsController extends BaseController {
@Autowired @Autowired
private IOilThDeviceService oilThDeviceService; private IOilThDeviceService oilThDeviceService;
@Autowired
private ThDeviceReportMonthService thDeviceReportMonthService;
@GetMapping(value = "/getDeviceList/{id}") @GetMapping(value = "/getDeviceList/{id}")
public TableDataInfo getDeviceList(@PathVariable("id") Long id) { public TableDataInfo getDeviceList(@PathVariable("id") Long id) {
startPage(); startPage();
@ -95,4 +97,21 @@ public class OilStatisticsController extends BaseController {
LocalDate lastMonthDate = date.minus(1, ChronoUnit.MONTHS); LocalDate lastMonthDate = date.minus(1, ChronoUnit.MONTHS);
return lastMonthDate.format(formatter); return lastMonthDate.format(formatter);
} }
@GetMapping("/getDeviceReportMonthList")
public TableDataInfo getDeviceReportMonthList(Long deptId, String year, String month, int pageNum, int pageSize) {
Page<Object> page = PageHelper.startPage(pageNum, pageSize);
List<Map<String, Object>> result = thDeviceReportMonthService.selectThDeviceReportMonthList(deptId, year, month);
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setRows(result);
rspData.setMsg("查询成功");
rspData.setTotal(page.getTotal());
return rspData;
}
@PostMapping("/updateDeviceReportMonth")
public AjaxResult updateDeviceReportMonth(@RequestBody ThDeviceReportMonth thDeviceReportMonth) {
return toAjax(thDeviceReportMonthService.updateThDeviceReportMonth(thDeviceReportMonth));
}
} }

View File

@ -0,0 +1,125 @@
package com.ruoyi.project.oil.domain;
import java.io.Serializable;
/**
* 设备月表
* @TableName TH_DEVICE_REPORT_MONTH1
*/
public class ThDeviceReportMonth implements Serializable {
/**
* 设备编号
*/
private String sn;
/**
*
*/
private Long id;
/**
*
*/
private Long deptId;
/**
*
*/
private String year;
/**
*
*/
private String month;
/**
* 设备平均值
*/
private String avgValue;
private static final long serialVersionUID = 1L;
/**
* 设备编号
*/
public String getSn() {
return sn;
}
/**
* 设备编号
*/
public void setSn(String sn) {
this.sn = sn;
}
/**
*
*/
public Long getId() {
return id;
}
/**
*
*/
public void setId(Long id) {
this.id = id;
}
/**
*
*/
public Long getDeptId() {
return deptId;
}
/**
*
*/
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
/**
*
*/
public String getYear() {
return year;
}
/**
*
*/
public void setYear(String year) {
this.year = year;
}
/**
*
*/
public String getMonth() {
return month;
}
/**
*
*/
public void setMonth(String month) {
this.month = month;
}
/**
* 设备平均值
*/
public String getAvgValue() {
return avgValue;
}
/**
* 设备平均值
*/
public void setAvgValue(String avgValue) {
this.avgValue = avgValue;
}
}

View File

@ -0,0 +1,32 @@
package com.ruoyi.project.oil.mapper;
import com.ruoyi.project.oil.domain.ThDeviceReportMonth;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author Lenovo
* @description 针对表TH_DEVICE_REPORT_MONTH(设备月表)的数据库操作Mapper
* @createDate 2024-09-11 13:44:21
* @Entity com.ruoyi.project.oil.domain.ThDeviceReportMonth
*/
public interface ThDeviceReportMonthMapper {
/**
* 查询列表
*/
@MapKey("deptId")
List<Map<String, Object>> selectThDeviceReportMonthList(@Param("deptId") Long deptId, @Param("year") String year, @Param("month") String month);
/**
* 更新
*/
int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth);
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.project.oil.service;
import com.ruoyi.project.oil.domain.ThDeviceReportMonth;
import java.util.List;
import java.util.Map;
/**
* @author Lenovo
* @description 针对表TH_DEVICE_REPORT_MONTH1(设备月表)的数据库操作Service
* @createDate 2024-09-11 13:44:21
*/
public interface ThDeviceReportMonthService {
/**
* 查询列表
*/
List<Map<String, Object>> selectThDeviceReportMonthList(Long deptId, String year, String month);
/**
* 更新
*/
int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth);
}

View File

@ -0,0 +1,60 @@
package com.ruoyi.project.oil.service.impl;
import com.ruoyi.project.oil.domain.ThDeviceReportMonth;
import com.ruoyi.project.oil.mapper.ThDeviceReportMonthMapper;
import com.ruoyi.project.oil.service.ThDeviceReportMonthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Lenovo
* @description 针对表TH_DEVICE_REPORT_MONTH1(设备月表)的数据库操作Service实现
* @createDate 2024-09-11 13:44:21
*/
@Service
public class ThDeviceReportMonthServiceImpl implements ThDeviceReportMonthService {
@Autowired
private ThDeviceReportMonthMapper thDeviceReportMonthMapper;
@Override
public List<Map<String, Object>> selectThDeviceReportMonthList(Long deptId, String year, String month) {
// return thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month);
List<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> list = thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month);
for (Map<String, Object> map : list) {
Map<String, Object> lowerCaseMap = new HashMap<>();
for (String key : map.keySet()) {
lowerCaseMap.put(toLowerCaseCamelCase(key.toLowerCase()), map.get(key));
}
result.add(lowerCaseMap);
}
return result;
}
@Override
public int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth) {
return thDeviceReportMonthMapper.updateThDeviceReportMonth(thDeviceReportMonth);
}
public static String toLowerCaseCamelCase(String input) {
StringBuilder output = new StringBuilder();
String[] words = input.split("_");
output.append(words[0]);
for (int i = 1; i < words.length; i++) {
output.append(Character.toUpperCase(words[i].charAt(0)));
output.append(words[i].substring(1).toLowerCase());
}
return output.toString();
}
}

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.oil.mapper.ThDeviceReportMonthMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.project.oil.domain.ThDeviceReportMonth">
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="id" column="id" jdbcType="DECIMAL"/>
<result property="deptId" column="dept_id" jdbcType="DECIMAL"/>
<result property="year" column="year" jdbcType="VARCHAR"/>
<result property="month" column="month" jdbcType="VARCHAR"/>
<result property="avgValue" column="avg_value" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
select m.sn,
m.id,
m.dept_id,
m.year,
m.month,
m.avg_value,
p.dept_name,
p.ancestors,
pp.dept_name as "gangqu"
from th_device_report_month1 m
left join sys_dept p on m.dept_id = p.dept_id
left join sys_dept pp on p.parent_id = pp.dept_id
</sql>
<select id="selectThDeviceReportMonthList" parameterType="map" resultType="map">
<include refid="Base_Column_List"/>
WHERE m.dept_id IN (
SELECT dept_id
FROM sys_dept START WITH dept_id = #{deptId}
CONNECT BY PRIOR dept_id = parent_id
)
<if test="year != null and year != ''">
AND m.year = #{year}
</if>
<if test="month != null and month != ''">
AND m.month = #{month}
</if>
ORDER BY m.dept_id, m.year, m.month ASC
</select>
<update
id="updateThDeviceReportMonth"
parameterType="com.ruoyi.project.oil.domain.ThDeviceReportMonth"
>
update th_device_report_month1
<set>
<if test="avgValue != null and avgValue != ''">avg_value = #{avgValue},</if>
</set>
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,17 @@
import request from '@/utils/request'
export function getDeviceReportMonthList(params) {
return request({
url: '/statistics/getDeviceReportMonthList',
params: params,
method: 'get',
})
}
export function updateDeviceReportMonth(params) {
return request({
url: '/statistics/updateDeviceReportMonth',
data: params,
method: 'post',
})
}

View File

@ -8,6 +8,11 @@
placeholder="请选择组织部门" placeholder="请选择组织部门"
@select="handleDeptSelect" @select="handleDeptSelect"
/> />
<el-button-group v-if="showQuickGroup">
<el-button v-for="child in firstChildList" :key="child.deptName" plain @click="quickSelect(child)">
{{ child.deptName }}
</el-button>
</el-button-group>
</div> </div>
</template> </template>
@ -22,11 +27,18 @@ export default {
components: { components: {
Treeselect, Treeselect,
}, },
props: {
showQuickGroup: {
type: Boolean,
default: false,
},
},
data() { data() {
return { return {
deptId: "", deptId: "",
// //
deptList: [], deptList: [],
firstChildList: [],
normalizer(node) { normalizer(node) {
return { return {
id: node.deptId, id: node.deptId,
@ -56,11 +68,14 @@ export default {
// this.$message.error(",sys.user.defaultFactoryId"); // this.$message.error(",sys.user.defaultFactoryId");
// } // }
// }, // },
quickSelect(child) {
this.deptId = child.deptId;
this.$emit("deptChange", child);
},
async initDeptList() { async initDeptList() {
const [err, response] = await to( const [err, response] = await to(
listDept({ listDept({
deptName: undefined, deptName: undefined,
}) })
); );
if (err) { if (err) {
@ -71,6 +86,7 @@ export default {
if (response.code === 200) { if (response.code === 200) {
this.deptList = this.handleTree(response.data, "deptId"); this.deptList = this.handleTree(response.data, "deptId");
this.deptId = this.deptList[0].deptId; this.deptId = this.deptList[0].deptId;
this.firstChildList = this.deptList[0].children;
this.$emit("deptChange", this.deptList[0]); this.$emit("deptChange", this.deptList[0]);
} else { } else {
console.error(response); console.error(response);
@ -85,4 +101,14 @@ export default {
}; };
</script> </script>
<style scoped></style> <style scoped>
.dept-tree {
width: 100%;
display: flex;
flex-direction: column;
align-items: flex-start;
.el-button-group {
margin-top: 5px;
}
}
</style>

View File

@ -0,0 +1,221 @@
<template>
<div class="create-report">
<el-row :gutter="10">
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px">
<dept-tree @deptChange="handleDeptChange" :showQuickGroup="true" />
</el-col>
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px">
<!-- 月份选择 格式化为 2024-7 -->
<el-date-picker
v-model="dateValue"
type="month"
format="yyyy-M"
value-format="yyyy-M"
placeholder="选择月份"
@change="handleDateChange"
>
</el-date-picker>
</el-col>
</el-row>
<el-row :gutter="10">
<el-table
:data="tableData"
style="width: 100%"
border
:max-height="tableHeight"
v-loading="loading"
>
<el-table-column prop="gangqu" label="归属港区" />
<el-table-column prop="deptName" label="归属企业" />
<el-table-column prop="deptId" label="部门编码" />
<el-table-column prop="year" label="年份" />
<el-table-column prop="month" label="月份" />
<el-table-column prop="avgValue" label="平均值">
<template slot-scope="scope">
<div @dblclick="changeAvgValue(scope.$index, scope.row)">
<span v-show="!scope.row.enable_edit">{{
scope.row.avgValue
}}</span>
<el-input
:ref="'changeAvgValue' + scope.$index"
@blur="changeAvgValueBlur(scope.$index, scope.row)"
@keyup.enter.native="$event.target.blur"
clearable
v-show="scope.row.enable_edit"
size="mini"
v-model="scope.row.avgValue"
placeholder="请输入内容"
></el-input>
</div>
</template>
</el-table-column>
</el-table>
<div class="page-ele">
<el-pagination
layout="sizes, prev, pager, next, total"
:total="total"
:page-size="pageSize"
:page-sizes="[10, 20, 30, 40]"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
>
</el-pagination>
</div>
</el-row>
</div>
</template>
<script>
import DeptTree from "@/components/DeptTree/index.vue";
import {
getDeviceReportMonthList,
updateDeviceReportMonth,
} from "@/api/statistics/monthData.js";
export default {
name: "CreateReport",
components: {
DeptTree,
},
data() {
return {
deptId: "",
dateValue: "",
pageNum: 1,
pageSize: 10,
total: 0,
tableData: [],
loading: false,
oldValue: "",
};
},
created() {
this.initDate();
},
computed: {
tableHeight() {
return window.innerHeight - 300;
},
},
methods: {
handleDeptChange(value) {
this.deptId = value.deptId;
this.queryData();
},
handleDateChange(value) {
this.queryData();
},
handleCurrentChange(val) {
this.pageNum = val;
this.queryData();
},
handleSizeChange(val) {
this.pageSize = val;
this.queryData();
},
initDate() {
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
this.dateValue = `${year}-${month}`;
},
changeAvgValue(index, row) {
this.$set(row, "enable_edit", true);
this.oldValue = row.avgValue;
this.$nextTick(() => {
this.$refs["changeAvgValue" + index].focus();
});
},
changeAvgValueBlur(index, row) {
this.$set(row, "enable_edit", false);
if (row.avgValue === "") {
this.$message.error("平均值不能为空");
this.queryData();
return;
}
if (isNaN(row.avgValue)) {
this.$message.error("平均值必须为数字");
this.queryData();
return;
}
if (row.avgValue < 0) {
this.$message.error("平均值不能小于0");
this.queryData();
return;
}
if (this.oldValue === row.avgValue) {
return;
}
this.$confirm(`是否修改数据?${this.oldValue}${row.avgValue}`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
const params = {
id: row.id,
avgValue: row.avgValue,
};
updateDeviceReportMonth(params)
.then((res) => {
if (res.code !== 200) {
this.$message.error("修改失败");
} else {
this.$message({
type: "success",
message: "修改成功!",
});
}
})
.catch((error) => {
console.error(error);
this.$message.error("修改失败");
})
.finally(() => {
this.queryData();
});
})
.catch(() => {
row.avgValue = this.oldValue;
this.$message({
type: "info",
message: "取消修改",
});
});
// this.tableData[index].enable_edit = !this.tableData[index].enable_edit;
// this.tableData = [...this.tableData];
},
queryData() {
this.loading = true;
const params = {
deptId: this.deptId,
year: this.dateValue.split("-")[0],
month: this.dateValue.split("-")[1],
pageNum: this.pageNum,
pageSize: this.pageSize,
};
getDeviceReportMonthList(params)
.then((res) => {
if (res.code === 200) {
this.tableData = res.rows;
this.total = res.total;
}
})
.finally(() => {
this.loading = false;
});
},
},
};
</script>
<style scoped>
.create-report {
min-height: 50vh;
}
.page-ele {
margin-top: 10px;
text-align: right;
}
</style>

View File

@ -0,0 +1,23 @@
<template>
<div>
<h2>DataDetail</h2>
</div>
</template>
<script>
export default {
name: 'DataDetail',
data() {
return {
}
},
created() {
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,23 @@
<template>
<div>
<h2>DataOverview</h2>
</div>
</template>
<script>
export default {
name: 'DataOverview',
data() {
return {
}
},
created() {
},
}
</script>
<style scoped>
</style>

View File

@ -1,30 +0,0 @@
<template>
<div class="comparison-wrapper">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="报表生成" name="first"></el-tab-pane>
<el-tab-pane label="数据总览" name="second">配置管理</el-tab-pane>
<el-tab-pane label="数据详情" name="third">角色管理</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
export default {
data() {
return {
activeName: 'second'
};
},
methods: {
handleClick(tab, event) {
console.log(tab, event);
}
}
};
</script>
<style scoped>
.comparison-wrapper {
padding: 20px;
height: 100%;
}
</style>

View File

@ -1,24 +1,21 @@
<template> <template>
<div class="data-monitor"> <div class="data-monitor">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px"> <el-col :span="10" style="margin-top: 10px; margin-bottom: 10px">
<dept-tree @deptChange="handleDeptChange" /> <dept-tree @deptChange="handleDeptChange" :showQuickGroup="true" />
</el-col> </el-col>
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px"> <el-col :span="6" style="margin-top: 10px; margin-bottom: 10px">
<!-- 时间范围选择 --> <!-- 时间范围选择 -->
<el-date-picker v-model="dateValue" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" <el-date-picker
:default-time="['00:00:00', '23:59:59']" @change="handleDateChange"> v-model="dateValue"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
@change="handleDateChange"
>
</el-date-picker> </el-date-picker>
</el-col> </el-col>
<el-col>
<el-radio-group v-model="deptId" @change="handleRadioDeptChange">
<el-radio-button :label="229">青岛港</el-radio-button>
<el-radio-button :label="230">日照港</el-radio-button>
<el-radio-button :label="231">烟台港</el-radio-button>
<el-radio-button :label="232">渤海湾港</el-radio-button>
</el-radio-group>
</el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
@ -36,13 +33,6 @@ export default {
// chooseDept:null, // chooseDept:null,
deptId: "", deptId: "",
dateValue: [], dateValue: [],
normalizer(node) {
return {
id: node.deptId,
label: node.deptName,
children: node.children,
};
},
}; };
}, },
mounted() { mounted() {
@ -64,7 +54,7 @@ export default {
]; ];
}, },
handleRadioDeptChange(value) { handleRadioDeptChange(value) {
this.deptId = value this.deptId = value;
this.emitChange(); this.emitChange();
}, },
handleDeptChange(value) { handleDeptChange(value) {