Commit 517e7875 authored by 赵啸非's avatar 赵啸非

物联网1.0

parent 84e02b55
...@@ -166,12 +166,15 @@ CREATE TABLE mortals_xhx_alarm_config( ...@@ -166,12 +166,15 @@ CREATE TABLE mortals_xhx_alarm_config(
`alarmLevel` tinyint(2) NOT NULL COMMENT '告警级别,(0.危险,1.次要,2.一般)', `alarmLevel` tinyint(2) NOT NULL COMMENT '告警级别,(0.危险,1.次要,2.一般)',
`alarmPusW1ay` tinyint(2) NOT NULL COMMENT '推送方式,(0.不推送,1.短信)', `alarmPusW1ay` tinyint(2) NOT NULL COMMENT '推送方式,(0.不推送,1.短信)',
`isUse` tinyint(2) NOT NULL COMMENT '是否启用(0.不启动,1.启动)', `isUse` tinyint(2) NOT NULL COMMENT '是否启用(0.不启动,1.启动)',
`remark` varchar(2048) COMMENT '备注',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户', `updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间', `updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备告警配置'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备告警配置';
-- ---------------------------- -- ----------------------------
-- 短信发送记录表 -- 短信发送记录表
-- ---------------------------- -- ----------------------------
......
...@@ -23,6 +23,14 @@ export default { ...@@ -23,6 +23,14 @@ export default {
this.$router.go(-1); this.$router.go(-1);
}, },
// 开启、关闭
changePath(path) {
this.pageInfo.list = path + "/list";
this.pageInfo.del = path + "/delete";
this.pageInfo.add = path + "/add";
this.pageInfo.edit = path + "/edit";
this.pageInfo.view = path + "/view";
},
// 默认拉取数据 // 默认拉取数据
getData() { getData() {
......
...@@ -14,8 +14,7 @@ export default { ...@@ -14,8 +14,7 @@ export default {
}, },
watch: { watch: {
'$route'(route) { '$route'(route) {
// this.query = Object.assign({}, this.query, route.query); // this.query = Object.assign({}, this.query, route.query);
this.getData(); this.getData();
} }
}, },
...@@ -24,6 +23,17 @@ export default { ...@@ -24,6 +23,17 @@ export default {
clearTimeout(this.loadingTimer); clearTimeout(this.loadingTimer);
}, },
methods: { methods: {
test(){
console.log("test")
},
// 开启、关闭
changePath(path) {
this.pageInfo.list = path + "/list";
this.pageInfo.del = path + "/delete";
this.pageInfo.add = path + "/add";
this.pageInfo.edit = path + "/edit";
this.pageInfo.view = path + "/view";
},
beforeFecth() { beforeFecth() {
return Promise.resolve(); return Promise.resolve();
}, },
...@@ -242,7 +252,7 @@ export default { ...@@ -242,7 +252,7 @@ export default {
return this.$message.warning('请选中一条记录'); return this.$message.warning('请选中一条记录');
} }
this.$get(this.pageInfo.del, {id: id}) this.$get(this.pageInfo.del, { id: id })
.then(res => { .then(res => {
this.$message.success(res.msg) this.$message.success(res.msg)
// 更新数据 // 更新数据
...@@ -299,13 +309,13 @@ export default { ...@@ -299,13 +309,13 @@ export default {
open() { open() {
}, },
}, },
computed: { computed: {
tableConfig() { tableConfig() {
return Object.assign({}, this.defaultConfig, this.config) return Object.assign({}, this.defaultConfig, this.config)
}, },
pageInfo() { pageInfo() {
console.log(3333333+this.$route.path)
const urls = { // 操作所需的url地址,和url同路径 const urls = { // 操作所需的url地址,和url同路径
list: this.$route.path, list: this.$route.path,
edit: this.$route.path.replace('/list', '/edit'), edit: this.$route.path.replace('/list', '/edit'),
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
<slot name="table-search-left"></slot> <slot name="table-search-left"></slot>
<SearchForm <SearchForm
:search="config.search" :search="config.search"
v-if="isShowButton('notSearch')"
:table="data" :table="data"
:downloadUrl="config.downloadUrl" :downloadUrl="config.downloadUrl"
:areaSelect="config.areaSelect" :areaSelect="config.areaSelect"
...@@ -190,7 +191,7 @@ ...@@ -190,7 +191,7 @@
class="table-foot" class="table-foot"
v-if="!isShowButton('notPagination') ? false : data.pageInfo.totalResult" v-if="!isShowButton('notPagination') ? false : data.pageInfo.totalResult"
> >
<Pagination <Pagination style="float:left"
:total="data.pageInfo.totalResult" :total="data.pageInfo.totalResult"
:prePageResult="data.pageInfo.prePageResult" :prePageResult="data.pageInfo.prePageResult"
/> />
......
...@@ -3,17 +3,19 @@ ...@@ -3,17 +3,19 @@
<LayoutTable :data="tableData" :config="tableConfig"> <LayoutTable :data="tableData" :config="tableConfig">
</LayoutTable> </LayoutTable>
<dialog-show ref="dialogform" @ok="getData" /> <!-- <dialog-show ref="dialogform" @ok="getData" /> -->
<drawer-show ref="drawerform" @ok="getData" />
</div> </div>
</template> </template>
<script> <script>
/** 表单弹出框模式需引入 */ /** 表单弹出框模式需引入 */
import dialogShow from "./dialogshow"; import drawerShow from "./drawershow";
import table from "@/assets/mixins/table"; import table from "@/assets/mixins/table";
export default { export default {
name: "AlarmConfig", name: "AlarmConfig",
components: {dialogShow }, components: {drawerShow },
mixins: [table], mixins: [table],
created() { created() {
}, },
...@@ -21,7 +23,9 @@ ...@@ -21,7 +23,9 @@
/** 重写新增方法 */ /** 重写新增方法 */
toAdd(row) { toAdd(row) {
this.$refs.dialogform.add(row); //this.$refs.dialogform.add(row);
this.$refs.drawerform.add(row);
}, },
/** 重写编辑方法 */ /** 重写编辑方法 */
toEdit(row) { toEdit(row) {
......
...@@ -32,13 +32,13 @@ export default { ...@@ -32,13 +32,13 @@ export default {
console.log("pageInfo--before",this.pageInfo) console.log("pageInfo--before",this.pageInfo)
// this.changePath("/device/alarm/info") this.changePath("/device/alarm/info")
this.pageInfo.list = "/device/alarm/info/list"; // this.pageInfo.list = "/device/alarm/info/list";
this.pageInfo.del = "/device/alarm/info/delete"; // this.pageInfo.del = "/device/alarm/info/delete";
this.pageInfo.add = "/device/alarm/info/add"; // this.pageInfo.add = "/device/alarm/info/add";
this.pageInfo.edit = "/device/alarm/info/edit"; // this.pageInfo.edit = "/device/alarm/info/edit";
this.pageInfo.view = "/device/alarm/info/view"; // this.pageInfo.view = "/device/alarm/info/view";
console.log("pageInfo",this.pageInfo) console.log("pageInfo",this.pageInfo)
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
import form from "@/assets/mixins/formdialog"; import form from "@/assets/mixins/formdialog";
import viewShow from "./view"; import viewShow from "./view";
import alarmList from "./alarm/info/list"; import alarmList from "./alarm/info/list";
import moduleList from "./module/list"; import moduleList from "./module/use/list";
import ImageUpload from "@/components/ImageUpload"; import ImageUpload from "@/components/ImageUpload";
export default { export default {
mixins: [form], mixins: [form],
......
...@@ -31,23 +31,26 @@ ...@@ -31,23 +31,26 @@
:disabled="isExport" :disabled="isExport"
>导出</el-button >导出</el-button
> >
<el-tag slot="table-body-head" style="margin: 5px" type="success" <el-tag slot="table-head-left2" size="mini" style="margin-left: 20px"
>当前在线设备总计:{{ tableData.onlineCount }}</el-tag >设备总数:{{ tableData.totalCount }}</el-tag
> >
<el-tag slot="table-body-head" style="margin: 5px" type="danger" <el-tag slot="table-head-left2" size="mini" style="margin: 5px" type="success"
>当前离线设备总计:{{ tableData.offlineCount }}</el-tag >在线:{{ tableData.onlineCount }}</el-tag
> >
<el-tag <el-tag slot="table-head-left2" size="mini" style="margin: 5px" type="danger"
v-for="($label, $value) in tableData.offlineDeviceType" >离线:{{ tableData.offlineCount }}</el-tag
:key="$value"
:label="$value"
slot="table-body-head"
style="margin: 5px"
type="danger"
>{{ $value }}离线设备:{{ $label }}</el-tag
> >
<el-tag slot="table-head-left2" size="mini" style="margin: 5px" type="danger"
>停用:{{ tableData.stopCount }}</el-tag
>
<el-tag slot="table-head-left2" size="mini" style="margin: 5px" type="danger"
>未激活:{{ tableData.unActiveCount }}</el-tag
>
</LayoutTable> </LayoutTable>
<!-- 设备导入对话框 --> <!-- 设备导入对话框 -->
...@@ -268,29 +271,29 @@ export default { ...@@ -268,29 +271,29 @@ export default {
config: { config: {
getsocketData: null, getsocketData: null,
search: [ search: [
{ // {
name: "deviceNum", // name: "deviceNum",
type: "text", // type: "text",
label: "设备编号", // label: "设备编号",
}, // },
{ {
name: "deviceStatus", name: "deviceStatus",
type: "select", type: "select",
label: "状态", label: "状态",
}, },
{ // {
name: "porductId", // name: "porductId",
type: "select", // type: "select",
label: "产品类型", // label: "产品类型",
}, // },
], ],
columns: [ columns: [
{ type: "selection", width: 60 }, { type: "selection", width: 60 },
{ label: "设备名称", prop: "deviceName" }, { label: "设备名称", prop: "deviceName" },
{ label: "设备类型", prop: "porductId", formatter: this.formatter }, { label: "设备类型", prop: "productId", formatter: this.formatter },
{ label: "设备编码", prop: "deviceCode" }, { label: "设备编码", prop: "deviceCode" },
......
<template> <template>
<div class="page"> <div class="page">
<LayoutTable :data="tableData" :config="tableConfig"> <LayoutTable
</LayoutTable> :data="tableData"
notAdd
notDel
notSearch
:config="tableConfig"
>
</LayoutTable>
<dialog-show ref="dialogform" @ok="getData" /> <dialog-show ref="dialogform" @ok="getData" />
</div> </div>
</template> </template>
<script> <script>
/** 表单弹出框模式需引入 */ /** 表单弹出框模式需引入 */
import dialogShow from "./dialogshow"; import dialogShow from "./dialogshow";
import table from "@/assets/mixins/table"; import table from "@/assets/mixins/table";
export default { export default {
name: "DeviceModuleUse", name: "DeviceModuleUse",
components: {dialogShow }, props: {
mixins: [table], queryIn: {
created() { type: Object,
}, default: null,
methods: { },
},
/** 重写新增方法 */ components: { dialogShow },
toAdd(row) { mixins: [table],
this.$refs.dialogform.add(row); created() {
}, console.log("queryIn:", this.queryIn);
/** 重写编辑方法 */
toEdit(row) { //this.config.addQuery = { deviceId, deviceType };
this.$refs.dialogform.edit(row);
if (this.queryIn.deviceId) {
}, this.query = {};
/** 重写查看方法 */ this.query["deviceId"] = this.queryIn.deviceId;
// toView(row) { }
// this.$refs.dialogform.view(row);
// }, console.log("pageInfo--before", this.pageInfo);
}, // this.changePath("/device/alarm/info")
data() {
return { this.pageInfo.list = "/device/module/use/list";
config: { this.pageInfo.del = "/device/module/use/delete";
search: [ this.pageInfo.add = "/device/module/use/add";
], this.pageInfo.edit = "/device/module/use/edit";
columns: [ this.pageInfo.view = "/device/module/use/view";
{type: "selection", width: 60},
{ console.log("pageInfo", this.pageInfo);
label: "操作", },
width: 240, methods: {
formatter: row => { /** 重写新增方法 */
return ( toAdd(row) {
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} /> this.$refs.dialogform.add(row);
); },
} /** 重写编辑方法 */
} toEdit(row) {
] this.$refs.dialogform.edit(row);
} },
}; /** 重写查看方法 */
} // toView(row) {
// this.$refs.dialogform.view(row);
// },
},
data() {
return {
config: {
search: [],
columns: [
{ label: "模块名称", prop: "moduleName" },
// { label: "模块消息编码", prop: "moduleMsgCode" },
{
label: "设备名称",
prop: "deviceId",
formatter: this.formatterString,
},
{ label: "产品名称", prop: "platformAndProductName" },
{ label: "调用次数", prop: "useNum" },
],
},
}; };
},
};
</script> </script>
\ No newline at end of file
...@@ -148,7 +148,9 @@ ...@@ -148,7 +148,9 @@
label-class-name="labelClass" label-class-name="labelClass"
content-class-name="contentClass" content-class-name="contentClass"
> >
{{ form.devicePhotoPath }}
<ImageUpload v-model="form.devicePhotoPath" prePath="/file/preview" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item <el-descriptions-item
......
...@@ -145,6 +145,7 @@ public class DeviceApiController { ...@@ -145,6 +145,7 @@ public class DeviceApiController {
ServerInfo serverInfo = new ServerInfo(); ServerInfo serverInfo = new ServerInfo();
serverInfo.setHomeUrl(platformEntity.getHomeUrl()); serverInfo.setHomeUrl(platformEntity.getHomeUrl());
serverInfo.setServerUrl(platformEntity.getSendUrl()); serverInfo.setServerUrl(platformEntity.getSendUrl());
registerResp.setServiceInfo(serverInfo);
String content = EncryptUtil.myEnscrt(JSON.toJSONString(registerResp), 9, DES_STR, ENCRYPT_STR); String content = EncryptUtil.myEnscrt(JSON.toJSONString(registerResp), 9, DES_STR, ENCRYPT_STR);
deviceResp.setContent(content); deviceResp.setContent(content);
......
...@@ -7,116 +7,134 @@ import com.mortals.framework.annotation.Excel; ...@@ -7,116 +7,134 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.alarm.model.vo.AlarmConfigVo; import com.mortals.xhx.module.alarm.model.vo.AlarmConfigVo;
/** /**
* 设备告警配置实体对象 * 设备告警配置实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-01 * @date 2022-07-04
*/ */
public class AlarmConfigEntity extends AlarmConfigVo { public class AlarmConfigEntity extends AlarmConfigVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 产品 * 产品
*/ */
private Long productId; private Long productId;
/** /**
* 告警类型(0.离线) * 告警类型(0.离线)
*/ */
private Integer alarmType; private Integer alarmType;
/** /**
* 告警级别,(0.危险,1.次要,2.一般) * 告警级别,(0.危险,1.次要,2.一般)
*/ */
private Integer alarmLevel; private Integer alarmLevel;
/** /**
* 推送方式,(0.不推送,1.短信) * 推送方式,(0.不推送,1.短信)
*/ */
private Integer alarmPusW1ay; private Integer alarmPusW1ay;
/** /**
* 是否启用(0.不启动,1.启动) * 是否启用(0.不启动,1.启动)
*/ */
private Integer isUse; private Integer isUse;
/**
* 备注
*/
private String remark;
public AlarmConfigEntity(){} public AlarmConfigEntity(){}
/** /**
* 获取 产品 * 获取 产品
* @return Long * @return Long
*/ */
public Long getProductId(){ public Long getProductId(){
return productId; return productId;
} }
/** /**
* 设置 产品 * 设置 产品
* @param productId * @param productId
*/ */
public void setProductId(Long productId){ public void setProductId(Long productId){
this.productId = productId; this.productId = productId;
} }
/** /**
* 获取 告警类型(0.离线) * 获取 告警类型(0.离线)
* @return Integer * @return Integer
*/ */
public Integer getAlarmType(){ public Integer getAlarmType(){
return alarmType; return alarmType;
} }
/** /**
* 设置 告警类型(0.离线) * 设置 告警类型(0.离线)
* @param alarmType * @param alarmType
*/ */
public void setAlarmType(Integer alarmType){ public void setAlarmType(Integer alarmType){
this.alarmType = alarmType; this.alarmType = alarmType;
} }
/** /**
* 获取 告警级别,(0.危险,1.次要,2.一般) * 获取 告警级别,(0.危险,1.次要,2.一般)
* @return Integer * @return Integer
*/ */
public Integer getAlarmLevel(){ public Integer getAlarmLevel(){
return alarmLevel; return alarmLevel;
} }
/** /**
* 设置 告警级别,(0.危险,1.次要,2.一般) * 设置 告警级别,(0.危险,1.次要,2.一般)
* @param alarmLevel * @param alarmLevel
*/ */
public void setAlarmLevel(Integer alarmLevel){ public void setAlarmLevel(Integer alarmLevel){
this.alarmLevel = alarmLevel; this.alarmLevel = alarmLevel;
} }
/** /**
* 获取 推送方式,(0.不推送,1.短信) * 获取 推送方式,(0.不推送,1.短信)
* @return Integer * @return Integer
*/ */
public Integer getAlarmPusW1ay(){ public Integer getAlarmPusW1ay(){
return alarmPusW1ay; return alarmPusW1ay;
} }
/** /**
* 设置 推送方式,(0.不推送,1.短信) * 设置 推送方式,(0.不推送,1.短信)
* @param alarmPusW1ay * @param alarmPusW1ay
*/ */
public void setAlarmPusW1ay(Integer alarmPusW1ay){ public void setAlarmPusW1ay(Integer alarmPusW1ay){
this.alarmPusW1ay = alarmPusW1ay; this.alarmPusW1ay = alarmPusW1ay;
} }
/** /**
* 获取 是否启用(0.不启动,1.启动) * 获取 是否启用(0.不启动,1.启动)
* @return Integer * @return Integer
*/ */
public Integer getIsUse(){ public Integer getIsUse(){
return isUse; return isUse;
} }
/** /**
* 设置 是否启用(0.不启动,1.启动) * 设置 是否启用(0.不启动,1.启动)
* @param isUse * @param isUse
*/ */
public void setIsUse(Integer isUse){ public void setIsUse(Integer isUse){
this.isUse = isUse; this.isUse = isUse;
} }
/**
* 获取 备注
* @return String
*/
public String getRemark(){
return remark;
}
/**
* 设置 备注
* @param remark
*/
public void setRemark(String remark){
this.remark = remark;
}
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -124,7 +142,7 @@ public class AlarmConfigEntity extends AlarmConfigVo { ...@@ -124,7 +142,7 @@ public class AlarmConfigEntity extends AlarmConfigVo {
if (obj instanceof AlarmConfigEntity) { if (obj instanceof AlarmConfigEntity) {
AlarmConfigEntity tmp = (AlarmConfigEntity) obj; AlarmConfigEntity tmp = (AlarmConfigEntity) obj;
if (this.getId() == tmp.getId()) { if (this.getId() == tmp.getId()) {
return true; return true;
} }
} }
return false; return false;
...@@ -137,19 +155,22 @@ public class AlarmConfigEntity extends AlarmConfigVo { ...@@ -137,19 +155,22 @@ public class AlarmConfigEntity extends AlarmConfigVo {
sb.append(",alarmLevel:").append(getAlarmLevel()); sb.append(",alarmLevel:").append(getAlarmLevel());
sb.append(",alarmPusW1ay:").append(getAlarmPusW1ay()); sb.append(",alarmPusW1ay:").append(getAlarmPusW1ay());
sb.append(",isUse:").append(getIsUse()); sb.append(",isUse:").append(getIsUse());
sb.append(",remark:").append(getRemark());
return sb.toString(); return sb.toString();
} }
public void initAttrValue(){ public void initAttrValue(){
this.productId = null; this.productId = null;
this.alarmType = 0;
this.alarmType = 0; this.alarmLevel = null;
this.alarmLevel = null; this.alarmPusW1ay = 0;
this.alarmPusW1ay = 0; this.isUse = null;
this.isUse = null; this.remark = "";
} }
} }
\ No newline at end of file
...@@ -5,11 +5,15 @@ import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; ...@@ -5,11 +5,15 @@ import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.alarm.model.AlarmConfigEntity; import com.mortals.xhx.module.alarm.model.AlarmConfigEntity;
import com.mortals.xhx.module.alarm.service.AlarmConfigService; import com.mortals.xhx.module.alarm.service.AlarmConfigService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* *
* 设备告警配置 * 设备告警配置
...@@ -23,6 +27,8 @@ public class AlarmConfigController extends BaseCRUDJsonBodyMappingController<Ala ...@@ -23,6 +27,8 @@ public class AlarmConfigController extends BaseCRUDJsonBodyMappingController<Ala
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private ProductService productService;
public AlarmConfigController(){ public AlarmConfigController(){
super.setModuleDesc( "设备告警配置"); super.setModuleDesc( "设备告警配置");
...@@ -34,6 +40,9 @@ public class AlarmConfigController extends BaseCRUDJsonBodyMappingController<Ala ...@@ -34,6 +40,9 @@ public class AlarmConfigController extends BaseCRUDJsonBodyMappingController<Ala
this.addDict(model, "alarmLevel", paramService.getParamBySecondOrganize("AlarmConfig","alarmLevel")); this.addDict(model, "alarmLevel", paramService.getParamBySecondOrganize("AlarmConfig","alarmLevel"));
this.addDict(model, "alarmPusW1ay", paramService.getParamBySecondOrganize("AlarmConfig","alarmPusW1ay")); this.addDict(model, "alarmPusW1ay", paramService.getParamBySecondOrganize("AlarmConfig","alarmPusW1ay"));
this.addDict(model, "isUse", paramService.getParamBySecondOrganize("AlarmConfig","isUse")); this.addDict(model, "isUse", paramService.getParamBySecondOrganize("AlarmConfig","isUse"));
this.addDict(model, "productId", productService.find(new ProductEntity()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getProductName())));
super.init(model, context); super.init(model, context);
} }
......
package com.mortals.xhx.module.device.model.vo; package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceModuleUseEntity; import com.mortals.xhx.module.device.model.DeviceModuleUseEntity;
import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -9,6 +11,11 @@ import java.util.List; ...@@ -9,6 +11,11 @@ import java.util.List;
* @author zxfei * @author zxfei
* @date 2022-07-02 * @date 2022-07-02
*/ */
@Data
public class DeviceModuleUseVo extends BaseEntityLong { public class DeviceModuleUseVo extends BaseEntityLong {
/**
* 平台与产品名称
*/
private String platformAndProductName;
} }
\ No newline at end of file
package com.mortals.xhx.module.device.service.impl; package com.mortals.xhx.module.device.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceModuleDao; import com.mortals.xhx.module.device.dao.DeviceModuleDao;
import com.mortals.xhx.module.device.model.DeviceModuleEntity; import com.mortals.xhx.module.device.model.DeviceModuleEntity;
import com.mortals.xhx.module.device.service.DeviceModuleService; import com.mortals.xhx.module.device.service.DeviceModuleService;
import org.springframework.util.ObjectUtils;
import java.util.List;
/** /**
* DeviceModuleService * DeviceModuleService
* 设备模块信息 service实现 * 设备模块信息 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-07-02 * @date 2022-07-02
*/ */
@Service("deviceModuleService") @Service("deviceModuleService")
public class DeviceModuleServiceImpl extends AbstractCRUDServiceImpl<DeviceModuleDao, DeviceModuleEntity, Long> implements DeviceModuleService { public class DeviceModuleServiceImpl extends AbstractCRUDServiceImpl<DeviceModuleDao, DeviceModuleEntity, Long> implements DeviceModuleService {
} }
\ No newline at end of file
package com.mortals.xhx.module.device.service.impl; package com.mortals.xhx.module.device.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceModuleUseDao; import com.mortals.xhx.module.device.dao.DeviceModuleUseDao;
import com.mortals.xhx.module.device.model.DeviceModuleUseEntity; import com.mortals.xhx.module.device.model.DeviceModuleUseEntity;
import com.mortals.xhx.module.device.service.DeviceModuleUseService; import com.mortals.xhx.module.device.service.DeviceModuleUseService;
import org.springframework.util.ObjectUtils;
import java.util.List;
/** /**
* DeviceModuleUseService * DeviceModuleUseService
* 设备模块使用频率 service实现 * 设备模块使用频率 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-07-02 * @date 2022-07-02
*/ */
@Service("deviceModuleUseService") @Service("deviceModuleUseService")
public class DeviceModuleUseServiceImpl extends AbstractCRUDServiceImpl<DeviceModuleUseDao, DeviceModuleUseEntity, Long> implements DeviceModuleUseService { public class DeviceModuleUseServiceImpl extends AbstractCRUDServiceImpl<DeviceModuleUseDao, DeviceModuleUseEntity, Long> implements DeviceModuleUseService {
@Autowired
private PlatformService platformService;
@Autowired
private ProductService productService;
@Autowired
private DeviceService deviceService;
@Override
protected void findAfter(DeviceModuleUseEntity params, PageInfo pageInfo, Context context, List<DeviceModuleUseEntity> list) throws AppException {
list.stream().forEach(item -> {
DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceId().toString());
if (!ObjectUtils.isEmpty(deviceEntity)) {
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
item.setPlatformAndProductName(platformEntity.getPlatformName() + "/" + productEntity.getProductName());
}
}
});
super.findAfter(params, pageInfo, context, list);
}
} }
\ No newline at end of file
...@@ -240,8 +240,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -240,8 +240,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
Arrays.asList(ids).stream().forEach(id -> { Arrays.asList(ids).stream().forEach(id -> {
DeviceEntity deviceEntity = this.get(id, context); DeviceEntity deviceEntity = this.get(id, context);
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
TbQueueCallback callback = new TbQueueCallback() { TbQueueCallback callback = new TbQueueCallback() {
@Override @Override
public void onSuccess(TbQueueMsgMetadata metadata) { public void onSuccess(TbQueueMsgMetadata metadata) {
...@@ -293,4 +291,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -293,4 +291,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
} }
\ No newline at end of file
...@@ -11,6 +11,8 @@ import com.mortals.xhx.base.system.message.MessageService; ...@@ -11,6 +11,8 @@ import com.mortals.xhx.base.system.message.MessageService;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.busiz.rsp.ApiResp; import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum; import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders; import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader; import com.mortals.xhx.common.model.MessageHeader;
...@@ -30,6 +32,7 @@ import org.springframework.util.ObjectUtils; ...@@ -30,6 +32,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
...@@ -171,4 +174,20 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -171,4 +174,20 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return jsonObject.toJSONString(); return jsonObject.toJSONString();
} }
@Override
protected int doListAfter(DeviceEntity query, Map<String, Object> model, Context context) throws AppException {
//统计当前站点设备情况
if (!ObjectUtils.isEmpty(query.getSiteId())) {
List<DeviceEntity> deviceEntityList = this.service.find(query, context);
if (!ObjectUtils.isEmpty(deviceEntityList)) {
model.put("totalCount", deviceEntityList.size());
model.put("onlineCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()).count());
model.put("offlineCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue()).count());
model.put("stopCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() != DeviceStatusEnum.未激活.getValue() && f.getEnabled() == YesNoEnum.NO.getValue()).count());
model.put("unActiveCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()).count());
}
}
return super.doListAfter(query, model, context);
}
} }
\ No newline at end of file
package com.mortals.xhx.module.device.web; package com.mortals.xhx.module.device.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -35,6 +37,8 @@ public class DeviceModuleUseController extends BaseCRUDJsonBodyMappingController ...@@ -35,6 +37,8 @@ public class DeviceModuleUseController extends BaseCRUDJsonBodyMappingController
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private DeviceService deviceService;
public DeviceModuleUseController(){ public DeviceModuleUseController(){
super.setModuleDesc( "设备模块使用频率"); super.setModuleDesc( "设备模块使用频率");
...@@ -42,6 +46,7 @@ public class DeviceModuleUseController extends BaseCRUDJsonBodyMappingController ...@@ -42,6 +46,7 @@ public class DeviceModuleUseController extends BaseCRUDJsonBodyMappingController
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "deviceId", deviceService.find(new DeviceQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getDeviceName())));
super.init(model, context); super.init(model, context);
} }
......
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