# Conflicts:
#	psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java
master
林颖晨 2 years ago
commit 564a5bddfb
  1. 6
      psdc-business/src/main/java/com/psdc/entity/PsdcDevice.java
  2. 11
      psdc-business/src/main/java/com/psdc/mapper/PsdcSceneMapper.java
  3. 9
      psdc-business/src/main/java/com/psdc/service/IPsdcSceneService.java
  4. 9
      psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java
  5. 17
      psdc-business/src/main/java/com/psdc/service/impl/PsdcSceneServiceImpl.java
  6. 15
      psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml
  7. 19
      psdc-business/src/main/resources/mapper/business/PsdcSceneMapper.xml
  8. 4
      psdc-ui/src/api/control/manual.js
  9. 82
      psdc-ui/src/views/control/manual/index.vue
  10. 216
      psdc-ui/src/views/system/cl/index.vue
  11. 58
      psdc-web/src/main/java/com/psdc/controller/manager/PsdcSceneController.java

@ -20,11 +20,15 @@ public class PsdcDevice {
/** 设备id */
@Excel(name = "设备Id", cellType = Excel.ColumnType.NUMERIC)
private Integer deviceId ;
/** 父设备Id */
private Integer parentId;
/** 用户id */
private Integer userId ;
/** 用户名称 */
@Excel(name = "用户名称")
private String userName ;
/** 设备是否可控 */
private Integer isControl;
/** 设备类型:1-监测设备,2-运行设备 */
private Integer deviceType ;
@ -49,6 +53,8 @@ public class PsdcDevice {
/** 启用时间 */
@Excel(name = "启用时间")
private String startTime ;
/** 设备模型 */
private String deviceModel;
/** 设备状态:1-未激活,2-禁用,3-在线,4-离线 */
private Integer deviceStatus ;

@ -17,11 +17,13 @@ public interface PsdcSceneMapper{
/**
* 通过ID查询单条数据
*
* @param undefinedId 主键
* @param sceneId 主键
* @return 实例对象
*/
PsdcScene queryById(Integer sceneId);
List<PsdcScene> sceneList(@Param(value = "userId") Long userId);
/**
* 新增数据
@ -41,7 +43,7 @@ public interface PsdcSceneMapper{
/**
* 通过主键删除数据
*
* @param undefinedId 主键
* @param sceneId 主键
* @return 影响行数
*/
int deleteById(Integer sceneId);
@ -76,7 +78,7 @@ public interface PsdcSceneMapper{
* @return
*/
List<SceneVo> querySceneByDeviceIdAndSceneName(@Param(value = "userId") Long userId,
@Param(value = "deviceId") Integer deviceId,
@Param(value = "deviceId") Integer deviceId,
@Param(value = "sceneName") String sceneName);
/**
@ -85,4 +87,7 @@ public interface PsdcSceneMapper{
* @return
*/
List<SceneVo> queryBySceneName(String sceneName);
List<SceneVo> findSceneByUserAndSceneName(@Param(value = "userId") Long userId,
@Param(value = "sceneName") String sceneName);
}

@ -14,7 +14,7 @@ public interface IPsdcSceneService {
/**
* 通过ID查询单条数据
*
* @param undefinedId 主键
* @param sceneId 主键
* @return 实例对象
*/
PsdcScene queryById(Integer sceneId);
@ -26,6 +26,9 @@ public interface IPsdcSceneService {
* @return 实例对象
*/
PsdcScene insert(PsdcScene psdcScene);
List<PsdcScene> sceneList();
/**
* 更新数据
*
@ -36,10 +39,12 @@ public interface IPsdcSceneService {
/**
* 通过主键删除数据
*
* @param undefinedId 主键
* @param sceneId 主键
* @return 是否成功
*/
boolean deleteById(Integer sceneId);
List<Map<String, Object>> getStrategyList();
List<SceneVo> findSceneByUserAndSceneName(Integer sceneId);
}

@ -154,9 +154,15 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService {
/**
* 控制设备启动停止
<<<<<<< HEAD
* @param deviceId 主键
* @param runStatus 状态
* @return 条数
=======
* @param deviceId
* @param runStatus
* @return
>>>>>>> d15c6d60ec068ceda12ba3aa1cf4c980940216a5
*/
@Override
public int controlDeviceStartAndStop(Integer deviceId, Integer runStatus, String controlBy, Integer controlMethod) {
@ -175,6 +181,9 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService {
psdcControlLogMapper.insert(new PsdcControlLog(deviceId, null, null, "设备启停", value, controlMethod, 3, "未找到该设备", controlBy));
throw new ControlException("控制失败,未找到该设备");
}
if (psdcDevice.getIsControl() != 2 ){
throw new ControlException("该设备无法控制,请联系管理员");
}
// TODO 发送MQTT指令

@ -43,7 +43,13 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService {
psdcSceneMapper.insert(psdcScene);
return psdcScene;
}
@Override
public List<PsdcScene> sceneList() {
Long userId = SecurityUtils.getUserId();
return psdcSceneMapper.sceneList(userId);
}
/**
* 更新数据
*
@ -58,7 +64,7 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService {
/**
* 通过主键删除数据
*
* @param undefinedId 主键
* @param sceneId 主键
* @return 是否成功
*/
public boolean deleteById(Integer sceneId){
@ -93,4 +99,11 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService {
.collect(Collectors.toList());
return collectList;
}
@Override
public List<SceneVo> findSceneByUserAndSceneName(Integer sceneId) {
Long userId = SecurityUtils.getUserId();
String sceneName = psdcSceneMapper.queryById(sceneId).getSceneName();
return psdcSceneMapper.findSceneByUserAndSceneName(userId, sceneName);
}
}

@ -3,10 +3,13 @@
<mapper namespace="com.psdc.mapper.PsdcDeviceMapper">
<resultMap type="com.psdc.entity.PsdcDevice" id="PsdcDeviceMap">
<result property="deviceId" column="device_id" />
<result property="parentId" column="parent_id" />
<result property="userId" column="user_id" />
<result property="deviceType" column="device_type" />
<result property="deviceModel" column="device_model" />
<result property="deviceSn" column="device_sn" />
<result property="deviceName" column="device_name" />
<result property="isControl" column="is_control" />
<result property="hardVersion" column="hard_version" />
<result property="softVersion" column="soft_version" />
<result property="deviceAddress" column="device_address" />
@ -37,7 +40,7 @@
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultMap="PsdcDeviceMap">
select device_id,
select device_id, parent_id, device_model, is_control,
user_id,
device_type,
device_sn,
@ -70,7 +73,7 @@
</select>
<select id="queryByUserId" resultMap="PsdcDeviceMap">
select device_id,
select device_id, parent_id, device_model, is_control,
user_id,
device_type,
device_sn,
@ -93,7 +96,7 @@
<!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="PsdcDeviceMap">
select
device_id,user_id,device_type,device_sn,device_name,hard_version,soft_version,device_address,start_time,device_status,device_runstatus,photo_url,create_by,create_time,update_by,update_time
device_id, parent_id, device_model, is_control, user_id, device_type,device_sn,device_name,hard_version,soft_version,device_address,start_time,device_status,device_runstatus,photo_url,create_by,create_time,update_by,update_time
from psdc_device
<where>
<if test="deviceId != null and deviceId != ''">
@ -205,16 +208,16 @@
<!--新增数据-->
<insert id="insert">
insert into psdc_device(user_id, device_type, device_sn, device_name, hard_version, soft_version,
insert into psdc_device(user_id, device_type, parent_id, device_model, is_control, device_sn, device_name, hard_version, soft_version,
device_address, start_time, device_status, device_runstatus, photo_url, create_by,
create_time, update_by, update_time)
values (#{userId}, #{deviceType}, #{deviceSn}, #{deviceName}, #{hardVersion}, #{softVersion}, #{deviceAddress},
values (#{userId}, #{deviceType}, #{deviceModel},#{parentId},#{isControl, #{deviceSn}, #{deviceName}, #{hardVersion}, #{softVersion}, #{deviceAddress},
#{startTime}, #{deviceStatus}, #{deviceRunstatus}, #{photoUrl}, #{createBy}, #{createTime}, #{updateBy},
#{updateTime})
</insert>
<insert id="saveDevicesData" parameterType="com.psdc.entity.PsdcDevice" useGeneratedKeys="true">
Insert into psdc_device(user_id, device_type, device_sn, device_name, hard_version, soft_version,
Insert into psdc_device(user_id, device_type, device_sn, parent_id, device_model, is_control, device_name, hard_version, soft_version,
device_address, start_time, device_status, device_runstatus, photo_url, create_by,
create_time, update_by, update_time)
Values

@ -31,6 +31,10 @@
where scene_id = #{sceneId}
</select>
<select id="sceneList" resultMap="PsdcSceneMap">
SELECT * FROM `psdc_scene` WHERE user_id = ${userId} Group By scene_name
</select>
<!--新增数据-->
<insert id="insert" keyProperty="UNDEFINED_ID" useGeneratedKeys="true">
insert into psdc_scene(scene_name,user_id,device_id,device_sn,scene_context,scene_key,scene_value)
@ -108,4 +112,19 @@
from psdc_scene ps left join psdc_device pd on ps.device_id = pd.device_id
where ps.scene_name like concat('%', #{sceneName}, '%')
</select>
<select id="findSceneByUserAndSceneName" resultMap="SceneVoMap">
Select ps.scene_id,ps.scene_name,ps.user_id,pd.device_name,ps.device_id,pd.device_sn,ps.scene_context,ps.scene_key,ps.scene_value
From psdc_scene ps
Left join sys_user su On su.user_id = ps.user_id
Left join psdc_device pd On pd.device_id = ps.device_id
<where>
<if test="userId != null and userId != ''">
And su.user_id = #{userId}
</if>
<if test="sceneName != null and sceneName != ''">
And ps.scene_name Like concat('%', #{sceneName}, '%')
</if>
</where>
</select>
</mapper>

@ -3,4 +3,8 @@ import request from '@/utils/request'
/** 获取设备*/
export function getDevice() {
return request.get('/control/manual/deviceStatusList')
}
/** 获取调控日志列表*/
export function getControlLogList(data) {
return request.post('/control/manual/controlLogList',data)
}

@ -126,13 +126,13 @@
<div class="dev_control_table">
<div class="control_header"><span>调控日志</span></div>
<div class="control_table">
<el-table :data="controlList">
<el-table :data="controlLogList" height="305px">
<el-table-column label="序号" align="center" width="50"/>
<el-table-column label="设备名称" align="center" prop="devName"/>
<el-table-column label="操作内容" align="center" prop="content" width="700"/>
<el-table-column label="操作时间" align="center" prop="time"/>
<el-table-column label="操作人员" align="center" prop="person"/>
<el-table-column label="操作结果" align="center" prop="result"></el-table-column>
<el-table-column label="设备名称" align="center" prop="deviceName"/>
<el-table-column label="操作内容" align="center" prop="controlValue" width="700"/>
<el-table-column label="操作时间" align="center" prop="createTime"/>
<el-table-column label="操作人员" align="center" prop="createBy"/>
<el-table-column label="操作结果" align="center" prop="controlResult"></el-table-column>
</el-table>
<el-pagination
v-model:current-page="currentPage"
@ -142,7 +142,7 @@
:disabled="disabled"
:background="background"
layout="total, sizes, prev, pager, next, jumper"
:total="controlList.length"
:total="tableLength"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
@ -167,10 +167,11 @@
import { Download } from '@element-plus/icons-vue' //element
import { ref,reactive,onMounted } from 'vue'
import { ElMessageBox } from 'element-plus'
import { getDevice } from '@/api/control/manual'
import { getDevice,getControlLogList } from '@/api/control/manual'
onMounted(()=>{
getDeviceFun();
getControlLogListFun();
})
/** 获取所有设备*/
@ -179,6 +180,13 @@ function getDeviceFun(){
getDevice().then((res)=>{
console.log(res.data)
deviceArr.value = res.data
for(let i = 0;i < res.data.length;i++){
if(res.data[i].deviceRunstatus == 1){
res.data[i].deviceRunstatus = '开启'
}else{
res.data[i].deviceRunstatus = '关闭'
}
}
})
}
@ -212,47 +220,36 @@ const onSubmit3 = () => {
}
/** 数据表格处理*/
const controlList = reactive([
{
devName:'11',
content:'22',
time:'33',
person:'44',
result:'55',
},
{
devName:'11',
content:'22',
time:'33',
person:'44',
result:'55',
},
{
devName:'11',
content:'22',
time:'33',
person:'44',
result:'55',
},
{
devName:'11',
content:'22',
time:'33',
person:'44',
result:'55',
}
])
const controlLogList = ref([])
const tableLength = ref()
const currentPage = ref(1)
const pageSize = ref(5)
const small = ref(false)
const background = ref(false)
const disabled = ref(false)
const handleSizeChange = (val) => {
console.log(`${val} items per page`)
getControlLogListFun()
}
const handleCurrentChange = (val) => {
console.log(`current page: ${val}`)
getControlLogListFun()
}
function getControlLogListFun(){
getControlLogList({
"deviceId": null,
"deviceName": null,
"deviceSn": null,
"controlKey": null,
"controlValue": null,
"controlResult": null,
"controlContext": null,
"pageNum": currentPage.value,
"pageSize": pageSize.value
}).then((res)=>{
tableLength.value = res.total
controlLogList.value = res.rows
})
}
/** 策略导入处理*/
const drawerIshow = ref(false)
@ -277,7 +274,7 @@ function confirmClick() {
height: 50%;
overflow-y: auto;
.dev_control_item{
width: 24.45%;
width: 24%;
height: 47%;
margin-right: 12px;
margin-bottom: 12px;
@ -396,5 +393,8 @@ function confirmClick() {
::v-deep .el-pager{
margin: 0 5px;
}
::v-deep .el-table--fit{
background-color: #2D3D88;
}
</style>

@ -1,16 +1,230 @@
<template>
<div class="app-container home">
<h1>策略管理</h1>
<el-row :gutter="20">
<el-col :span="24" :xs="24">
<el-form :model="queryParams" ref="queryRef" :inline="true" label-width="88px">
<el-form-item label="策略名称:" prop="name">
<el-select v-model="queryParams.week" placeholder="请选择" style="width: 240px">
<el-option label="策略一" value="null" />
<el-option label="策略二" value="one" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAdd">新增</el-button>
</el-col>
</el-row>
<div class="dev_control_table">
<el-table :data="timingList" height="500px">
<el-table-column label="序号" align="center" width="50"/>
<el-table-column label="策略名称" align="center" prop="name" width="200"/>
<el-table-column label="电磁锅炉进水温度" align="center" prop="DcTemIn"/>
<el-table-column label="电磁锅炉出水温度" align="center" prop="DcTemOut"/>
<el-table-column label="空气源热泵进水温度" align="center" prop="KqTemIn"/>
<el-table-column label="空气源热泵出水温度" align="center" prop="KqTemOut"/>
<el-table-column label="发热电缆温度" align="center" prop="DlTem"/>
<el-table-column label="操作" align="center" prop="handle">
<template v-slot="scope">
<el-button type="primary" size="small" icon="Edit" v-hasPermi="['system:cl:edit']">修改</el-button>
<el-button type="danger" size="small" :icon="Delete">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-model:current-page="currentPage"
v-model:page-size="pageSize"
:page-sizes="[5, 10, 20, 50]"
:small="small"
:disabled="disabled"
:background="background"
layout="total, sizes, prev, pager, next, jumper"
:total="timingList.length"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</el-col>
</el-row>
<!-- 新增对话框 -->
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
<el-form :model="timingForm" ref="userRef" label-width="88px">
<el-row>
<el-col :span="24">
<el-form-item label="策略名称:" prop="name">
<el-input v-model="timingForm.name" placeholder="请输入策略名称" maxlength="11" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电磁锅炉:" prop="DcTem" >
<el-input v-model="timingForm.DcTemIn" placeholder="进水温度" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电磁锅炉:" prop="DcTem" >
<el-input v-model="timingForm.DcTemOut" placeholder="出水温度" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="空气源热泵:" prop="KqTem" >
<el-input v-model="timingForm.KqTemIn" placeholder="进水温度" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="空气源热泵:" prop="DcTem" >
<el-input v-model="timingForm.KqTemOut" placeholder="出水温度" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="发热电缆:" prop="DlTem">
<el-input v-model="timingForm.DlTem" placeholder="温度" maxlength="11" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Index">
import {Delete} from '@element-plus/icons-vue'
import {ref,reactive,watch} from "vue";
/** 筛选处理 */
const dateRange = ref([]);
const data = reactive({
queryParams: {
name: '',
}
});
//
function handleQuery(){
}
//
function resetQuery(){
dateRange.value = []
}
/** 数据表格处理 */
const timingList = reactive([
{
name:'策略一',
DlTem:'22',
DcTemIn:'44',
DcTemOut:'55',
KqTemIn:'66',
KqTemOut:'77'
},
{
name:'策略二',
DlTem:'33',
DcTemIn:'55',
DcTemOut:'66',
KqTemIn:'77',
KqTemOut:'88'
}
])
const currentPage = ref(1)
const pageSize = ref(5)
const small = ref(false)
const background = ref(false)
const disabled = ref(false)
const handleSizeChange = (val) => {
console.log(`${val}`)
}
const handleCurrentChange = (val) => {
console.log(`${val}`)
}
/** 新增定时处理 */
const open = ref(false);
const title = ref();
const activeName = ref('1')
const timingForm = reactive({
name:'',
DlTem:'',
DcTemIn:'',
DcTemOut:'',
KqTemIn:'',
KqTemOut:''
})
// const watchTime = watch(()=> timingForm.executeTime, (val) => {
// // console.log(val.toLocaleString())
// let date = new Date(val)
// let hours = date.getHours()
// let minutes = date.getMinutes()
// let seconds = date.getSeconds()
// console.log(`${hours}:${minutes}:${seconds}`)
// })
function handleAdd() {
open.value = true;
title.value = "新增策略";
};
function submitForm() {
open.value = false;
};
function cancel() {
open.value = false;
};
const { queryParams } = toRefs(data);
</script>
<style scoped lang="scss">
.dev_control_table{
position: relative;
width: 100%;
min-height: 745px;
background-color: #2F3D8A;
}
::v-deep .el-button{
border-radius: 2px;
}
::v-deep .el-pagination{
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
}
::v-deep .el-pagination__total{
color: #f3ffff;
}
::v-deep .el-pagination__jump{
color: #f3ffff;
}
::v-deep .el-pager{
margin: 0 5px;
}
::v-deep .el-table .el-table__body-wrapper{
background-color: #2F3D8A;
}
::v-deep .el-form-item__content{
//display: flex;
}
</style>

@ -0,0 +1,58 @@
package com.psdc.controller.manager;
import com.psdc.core.controller.BaseController;
import com.psdc.core.domain.AjaxResult;
import com.psdc.core.page.TableDataInfo;
import com.psdc.entity.PsdcScene;
import com.psdc.entity.vo.SceneVo;
import com.psdc.service.IPsdcSceneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author戴仕崑
* @Projectpsdc
* @FilenamePsdcSceneCobtroller
* @Date2023/5/12 16:25
* @Version 1.0
*/
@RestController
@RequestMapping("/system/cl/index")
public class PsdcSceneController extends BaseController {
@Autowired
IPsdcSceneService psdcSceneService;
@PreAuthorize("@ss.hasPermi('system:cl:list')")
@RequestMapping(value = "/selMyscene", method = RequestMethod.GET)
public AjaxResult selMyscene() {
List<Map> maps = new ArrayList<>();
List<PsdcScene> list = psdcSceneService.sceneList();
for (PsdcScene dd : list){
Map<String, Object> map = new HashMap<>();
map.put("label", dd.getSceneName());
map.put("value", dd.getSceneId());
maps.add(map);
}
return AjaxResult.success("用户所属策略列表", maps);
}
@PreAuthorize("@ss.hasPermi('system:cl:list')")
@RequestMapping(value = "/list/{sceneId}", method = RequestMethod.GET)
public TableDataInfo list(@PathVariable(value = "sceneId", required = false) Integer sceneId) {
startPage();
List<SceneVo> list = psdcSceneService.findSceneByUserAndSceneName(sceneId);
return getDataTable(list);
}
}
Loading…
Cancel
Save