diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java index 0050a1b..9acc17b 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java @@ -7,14 +7,13 @@ import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; 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.ThDeviceReport; import com.ruoyi.project.oil.service.IOilThDeviceService; +import com.ruoyi.project.oil.service.ThDeviceReportMonthService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.time.LocalDate; import java.time.format.DateTimeFormatter; @@ -30,6 +29,9 @@ public class OilStatisticsController extends BaseController { @Autowired private IOilThDeviceService oilThDeviceService; + @Autowired + private ThDeviceReportMonthService thDeviceReportMonthService; + @GetMapping(value = "/getDeviceList/{id}") public TableDataInfo getDeviceList(@PathVariable("id") Long id) { startPage(); @@ -95,4 +97,21 @@ public class OilStatisticsController extends BaseController { LocalDate lastMonthDate = date.minus(1, ChronoUnit.MONTHS); return lastMonthDate.format(formatter); } + + @GetMapping("/getDeviceReportMonthList") + public TableDataInfo getDeviceReportMonthList(Long deptId, String year, String month, int pageNum, int pageSize) { + Page page = PageHelper.startPage(pageNum, pageSize); + List> 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)); + } } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/domain/ThDeviceReportMonth.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/domain/ThDeviceReportMonth.java new file mode 100644 index 0000000..429e1ed --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/domain/ThDeviceReportMonth.java @@ -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; + } +} \ No newline at end of file diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java new file mode 100644 index 0000000..18ba25a --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMonthMapper.java @@ -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> selectThDeviceReportMonthList(@Param("deptId") Long deptId, @Param("year") String year, @Param("month") String month); + + /** + * 更新 + */ + int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth); +} + + + + diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java new file mode 100644 index 0000000..991a009 --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/ThDeviceReportMonthService.java @@ -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> selectThDeviceReportMonthList(Long deptId, String year, String month); + + /** + * 更新 + */ + int updateThDeviceReportMonth(ThDeviceReportMonth thDeviceReportMonth); +} diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java new file mode 100644 index 0000000..1dae0ed --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/ThDeviceReportMonthServiceImpl.java @@ -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> selectThDeviceReportMonthList(Long deptId, String year, String month) { +// return thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month); + List> result = new ArrayList<>(); + List> list = thDeviceReportMonthMapper.selectThDeviceReportMonthList(deptId, year, month); + for (Map map : list) { + Map 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(); + } +} + + + + diff --git a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml new file mode 100644 index 0000000..bbc2981 --- /dev/null +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + 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 + + + + + + update th_device_report_month1 + + avg_value = #{avgValue}, + + where id = #{id} + + diff --git a/ruoyi-ui/src/api/statistics/monthData.js b/ruoyi-ui/src/api/statistics/monthData.js new file mode 100644 index 0000000..083eba4 --- /dev/null +++ b/ruoyi-ui/src/api/statistics/monthData.js @@ -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', + }) +} diff --git a/ruoyi-ui/src/components/DeptTree/index.vue b/ruoyi-ui/src/components/DeptTree/index.vue index feb707f..0578f4b 100644 --- a/ruoyi-ui/src/components/DeptTree/index.vue +++ b/ruoyi-ui/src/components/DeptTree/index.vue @@ -8,6 +8,11 @@ placeholder="请选择组织部门" @select="handleDeptSelect" /> + + + {{ child.deptName }} + + @@ -15,18 +20,25 @@ import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import to from "@/utils/await-to.js"; -import { listDept} from "@/api/system/dept"; +import { listDept } from "@/api/system/dept"; export default { name: "DeptTree", components: { Treeselect, }, + props: { + showQuickGroup: { + type: Boolean, + default: false, + }, + }, data() { return { deptId: "", // 部门树数据 deptList: [], + firstChildList: [], normalizer(node) { return { id: node.deptId, @@ -56,11 +68,14 @@ export default { // this.$message.error("默认企业配置错误,请配置sys.user.defaultFactoryId"); // } // }, + quickSelect(child) { + this.deptId = child.deptId; + this.$emit("deptChange", child); + }, async initDeptList() { const [err, response] = await to( listDept({ deptName: undefined, - }) ); if (err) { @@ -71,7 +86,8 @@ export default { if (response.code === 200) { this.deptList = this.handleTree(response.data, "deptId"); this.deptId = this.deptList[0].deptId; - this.$emit("deptChange", this.deptList[0]); + this.firstChildList = this.deptList[0].children; + this.$emit("deptChange", this.deptList[0]); } else { console.error(response); this.$message.error(response.msg); @@ -85,4 +101,14 @@ export default { }; - + diff --git a/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue b/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue new file mode 100644 index 0000000..e680b86 --- /dev/null +++ b/ruoyi-ui/src/views/dataStatistics/monthData/create-report.vue @@ -0,0 +1,221 @@ + + + + + diff --git a/ruoyi-ui/src/views/dataStatistics/monthData/data-detail.vue b/ruoyi-ui/src/views/dataStatistics/monthData/data-detail.vue new file mode 100644 index 0000000..fc939fc --- /dev/null +++ b/ruoyi-ui/src/views/dataStatistics/monthData/data-detail.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/ruoyi-ui/src/views/dataStatistics/monthData/data-overview.vue b/ruoyi-ui/src/views/dataStatistics/monthData/data-overview.vue new file mode 100644 index 0000000..6d31b59 --- /dev/null +++ b/ruoyi-ui/src/views/dataStatistics/monthData/data-overview.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/ruoyi-ui/src/views/dataStatistics/monthData/index.vue b/ruoyi-ui/src/views/dataStatistics/monthData/index.vue index 8f70b71..e69de29 100644 --- a/ruoyi-ui/src/views/dataStatistics/monthData/index.vue +++ b/ruoyi-ui/src/views/dataStatistics/monthData/index.vue @@ -1,30 +0,0 @@ - - - \ No newline at end of file diff --git a/ruoyi-ui/src/views/dataStatistics/realtime/search-bar.vue b/ruoyi-ui/src/views/dataStatistics/realtime/search-bar.vue index 382aba6..2ce708e 100644 --- a/ruoyi-ui/src/views/dataStatistics/realtime/search-bar.vue +++ b/ruoyi-ui/src/views/dataStatistics/realtime/search-bar.vue @@ -1,24 +1,21 @@ @@ -36,13 +33,6 @@ export default { // chooseDept:null, deptId: "", dateValue: [], - normalizer(node) { - return { - id: node.deptId, - label: node.deptName, - children: node.children, - }; - }, }; }, mounted() { @@ -64,8 +54,8 @@ export default { ]; }, handleRadioDeptChange(value) { - this.deptId = value - this.emitChange(); + this.deptId = value; + this.emitChange(); }, handleDeptChange(value) { this.deptId = value.deptId;