Commit 8587a650 authored by 赵啸非's avatar 赵啸非

添加前端页面

parent 7e3317ff
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-tabs style="margin-left: 10px" v-model="activeName"> <el-tabs style="margin-left: 10px" v-model="activeName">
<el-tab-pane label="设备详情" name="deviceDetail"> <el-tab-pane label="设备详情" name="deviceDetail">
<view-show :form="viewInfo" :dict="dict" /> <view-show :form="viewInfo" :dict="dict" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="告警记录" name="alarmLog"> <el-tab-pane label="告警记录" name="alarmLog">
<alarm-list :queryIn="{ alarmDevice: form.id }" /> <alarm-list :queryIn="{ alarmDevice: form.id }" />
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
style="text-align: center; margin-left: -100px; margin-top: 10px" style="text-align: center; margin-left: -100px; margin-top: 10px"
> >
<el-button @click="deleteDevice()">删除设备</el-button> <el-button @click="deleteDevice()">删除设备</el-button>
<el-button type="primary" @click="updateDevice()">修改信息</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-drawer> </el-drawer>
...@@ -114,10 +113,22 @@ export default { ...@@ -114,10 +113,22 @@ export default {
this.open = false; this.open = false;
}, },
updateDevice() { deleteDevice() {
console.log("更新设备信息") console.log("删除设备信息");
this.$get("/device/delete", {
id: this.form.id,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("删除成功!");
this.open=false;
//this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
}, },
/**获取数据后弹框 */ /**获取数据后弹框 */
......
...@@ -260,7 +260,7 @@ export default { ...@@ -260,7 +260,7 @@ export default {
return ( return (
<device-switch <device-switch
confirm confirm
url="/device/save" url="/device/enable"
row={row} row={row}
onChange={this.statusChange} onChange={this.statusChange}
value={this.tableData.data} value={this.tableData.data}
......
...@@ -162,7 +162,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -162,7 +162,7 @@ public class MessageServiceImpl implements MessageService {
try { try {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json"); header.put(HEADER_CONTENT_TYPE, "application/json");
log.info("thirdParty httpUrl:{} req:{}",sendUrl,JSON.toJSONString(deviceReqApiReq)); log.info("thirdPartyUrl:{} req:{}",sendUrl,JSON.toJSONString(deviceReqApiReq));
resp = HttpUtil.doPost(sendUrl, header, JSON.toJSONString(deviceReqApiReq)); resp = HttpUtil.doPost(sendUrl, header, JSON.toJSONString(deviceReqApiReq));
return JSON.parseObject(resp, ApiResp.class); return JSON.parseObject(resp, ApiResp.class);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -122,7 +122,12 @@ public class DeviceReq implements Serializable { ...@@ -122,7 +122,12 @@ public class DeviceReq implements Serializable {
private Date defectsLiabilityPeriod; private Date defectsLiabilityPeriod;
/** /**
* 设备来源(默认为新设备) * 设备状态 (0.未激活,1.离线,2.在线)
*/
private Integer deviceStatus;
/**
* 设备来源(0.旧设备,1.新设备)
*/ */
private Integer source; private Integer source;
......
...@@ -37,10 +37,10 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -37,10 +37,10 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
/** /**
* 设备启用停用 * 设备启用停用
* @param deviceCode * @param id
* @param context * @param context
*/ */
void deviceEnabled(String deviceCode,Integer status,Context context); void deviceEnabled(Long id,Integer status,Context context);
void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update); void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update);
......
...@@ -75,8 +75,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -75,8 +75,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
throw new AppException("所属产品不能为空!"); throw new AppException("所属产品不能为空!");
} }
} }
super.validData(entity, context); super.validData(entity, context);
} }
...@@ -138,13 +136,21 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -138,13 +136,21 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
} }
@Override @Override
public void deviceEnabled(String deviceCode, Integer enabled, Context context) { public void deviceEnabled(Long id, Integer enabled, Context context) {
DeviceEntity deviceEntity = this.selectOne(new DeviceQuery().deviceCode(deviceCode)); DeviceEntity deviceEntity = this.get(id, context);
if (!ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!"); if (ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!");
deviceEntity.setEnabled(enabled); deviceEntity.setEnabled(enabled);
deviceEntity.setUpdateTime(new Date()); deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(getContextUserId(context)); deviceEntity.setUpdateUserId(getContextUserId(context));
this.update(deviceEntity, context); this.update(deviceEntity, context);
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (enabled == YesNoEnum.YES.getValue()) {
this.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ENABLED);
} else {
this.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.STOP);
}
} }
...@@ -208,9 +214,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -208,9 +214,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
public void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update) { public void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update) {
DeviceReq deviceReq = new DeviceReq(); DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity)); BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity));
deviceReq.setReceiveMethod(update.getValue()); deviceReq.setDeviceStatus(update.getValue());
deviceReq.setProductCode(productEntity.getProductCode()); deviceReq.setProductCode(productEntity.getProductCode());
//deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) if (!ObjectUtils.isEmpty(platformEntity.getSendUrl())
//&& platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue() //&& platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()
&& entity.getSwitchSend()) { && entity.getSwitchSend()) {
...@@ -293,7 +298,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -293,7 +298,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setDeviceCode(StrUtil.replace(entity.getDeviceCode(), ":", "-")); entity.setDeviceCode(StrUtil.replace(entity.getDeviceCode(), ":", "-"));
if (ObjectUtils.isEmpty(entity.getDeviceMac())) { if (ObjectUtils.isEmpty(entity.getDeviceMac())) {
entity.setDeviceMac(entity.getDeviceCode()); entity.setDeviceMac(entity.getDeviceCode());
}else{ } else {
entity.setDeviceMac(StrUtil.replace(entity.getDeviceMac(), ":", "-")); entity.setDeviceMac(StrUtil.replace(entity.getDeviceMac(), ":", "-"));
} }
...@@ -319,8 +324,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -319,8 +324,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setProductName(productEntity.getProductName()); entity.setProductName(productEntity.getProductName());
} }
} }
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
......
...@@ -168,18 +168,18 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -168,18 +168,18 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
* 设备启用停用 * 设备启用停用
*/ */
@PostMapping(value = "enable") @PostMapping(value = "enable")
public String deviceEnable(@RequestParam(value = "deviceCode") String deviceCode, @RequestParam(value = "status") Integer status) { public String deviceEnable(@RequestBody DeviceEntity deviceEntity) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
String busiDesc = this.getModuleDesc() + "设备启用停用"; String busiDesc = this.getModuleDesc() + "设备启用停用";
try { try {
this.service.active(deviceCode, getContext()); this.service.deviceEnabled(deviceEntity.getId(),deviceEntity.getEnabled(), getContext());
//this.init(request, response, null, model, getContext()); //this.init(request, response, null, model, getContext());
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model); jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
} catch (Exception e) { } catch (Exception e) {
log.error("设备激活消息", e); log.error("设备启用停用消息", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e)); jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
} }
...@@ -214,36 +214,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -214,36 +214,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, ""); jsonObject.put(KEY_RESULT_MSG, "");
try { try {
//设备基础统计
/*UserEntity userEntity = userService.get(getContext().getUser().getId());
if(userEntity == null){
throw new AppException("暂未登录!");
}
//登录名
model.put("loginName", userEntity.getRealName());
//最后登陆时间
model.put("LastLoginTime", userEntity.getLastLoginTime());
//供应商数量
model.put("supplierCount", supplierService.count(new SupplierQuery(),getContext()));
//工作人员数量
model.put("workmanCount", workmanService.count(new WorkmanQuery(), getContext()));
//房间数量
model.put("roomCount", roomService.count(new RoomQuery(), getContext()));
//设备数量
model.put("deviceCount", deviceService.count(new DeviceQuery(), getContext()));
//专家数量
model.put("specialistCount", specialistService.count(new SpecialistQuery(), getContext()));
//待办
List<ProjectEntity> list = this.service.pendTask(getContext());
model.put("pendList", list);
//统计信息
ProjectStat projectStat = this.service.projectStat(getContext());
model.put("projectStat", projectStat);
//查询当天项目情况
List<ProjectEntity> dayProjectList = this.service.getProjectByDay(null, getContext());
model.put("dayProjectList", dayProjectList);
this.init(request, response, null, model, getContext());*/
jsonObject.put(KEY_RESULT_DATA, model); jsonObject.put(KEY_RESULT_DATA, model);
recordSysLog(request, "首页统计 【成功】"); recordSysLog(request, "首页统计 【成功】");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -23,11 +23,10 @@ public class PlatformServiceImpl extends AbstractCRUDServiceImpl<PlatformDao, Pl ...@@ -23,11 +23,10 @@ public class PlatformServiceImpl extends AbstractCRUDServiceImpl<PlatformDao, Pl
if(!ObjectUtils.isEmpty(entity.getSendUrl())){ if(!ObjectUtils.isEmpty(entity.getSendUrl())){
//UrlValidator urlValidator = new UrlValidator(); if (!PatternPool.URL_HTTP.matcher(entity.getSendUrl()).find()) {
throw new AppException("URL不合法");
}
} }
super.validData(entity, context); super.validData(entity, context);
} }
} }
\ No newline at end of file
...@@ -454,6 +454,8 @@ siteCode|String|站点编号,来源基础服务平台|是|- ...@@ -454,6 +454,8 @@ siteCode|String|站点编号,来源基础服务平台|是|-
siteName|String|站点名称|是|- siteName|String|站点名称|是|-
homeUrl|String|首页地址|否|- homeUrl|String|首页地址|否|-
deviceRemark|String|备注|是|- deviceRemark|String|备注|是|-
deviceStatus|Integer|设备状态 (0.未激活,1.离线,2.在线)|是|默认0为激活
source|Integer|(0.旧设备,1.新设备)|是|默认1新设备
**请求样例:** **请求样例:**
``` ```
...@@ -489,7 +491,7 @@ data|object|数据对象|- ...@@ -489,7 +491,7 @@ data|object|数据对象|-
参数名称|类型|备注|必填|其它 参数名称|类型|备注|必填|其它
:------|:---|:---|:---|:--- :------|:---|:---|:---|:---
deviceCode|String|设备编码,如MAC地址|是|- deviceCode|String|设备编码,如MAC地址|是|-
messageType|String|消息类型|是|如heart_beat messageType|String|消息类型|是|如HEART_BEAT
timestamp|Long|时间戳|是|- timestamp|Long|时间戳|是|-
data|String|数据体,内容自行定义|否|- data|String|数据体,内容自行定义|否|-
...@@ -500,13 +502,13 @@ data|String|数据体,内容自行定义|否|- ...@@ -500,13 +502,13 @@ data|String|数据体,内容自行定义|否|-
{ {
"data":"{xxxx}", "data":"{xxxx}",
"deviceCode":"a1", "deviceCode":"a1",
"messageType":"heart_beat", "messageType":"HEART_BEAT",
"timestamp":1654656951795 "timestamp":1654656951795
}, },
{ {
"data":"{bbbbbb}", "data":"{bbbbbb}",
"deviceCode":"a2", "deviceCode":"a2",
"messageType":"heart_beat", "messageType":"HEART_BEAT",
"timestamp":1654656951795 "timestamp":1654656951795
} }
] ]
......
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