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

添加前端页面

parent 7e3317ff
......@@ -9,7 +9,7 @@
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-tabs style="margin-left: 10px" v-model="activeName">
<el-tab-pane label="设备详情" name="deviceDetail">
<view-show :form="viewInfo" :dict="dict" />
<view-show :form="viewInfo" :dict="dict" />
</el-tab-pane>
<el-tab-pane label="告警记录" name="alarmLog">
<alarm-list :queryIn="{ alarmDevice: form.id }" />
......@@ -22,7 +22,6 @@
style="text-align: center; margin-left: -100px; margin-top: 10px"
>
<el-button @click="deleteDevice()">删除设备</el-button>
<el-button type="primary" @click="updateDevice()">修改信息</el-button>
</el-form-item>
</el-form>
</el-drawer>
......@@ -114,10 +113,22 @@ export default {
this.open = false;
},
updateDevice() {
console.log("更新设备信息")
deleteDevice() {
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 {
return (
<device-switch
confirm
url="/device/save"
url="/device/enable"
row={row}
onChange={this.statusChange}
value={this.tableData.data}
......
......@@ -162,7 +162,7 @@ public class MessageServiceImpl implements MessageService {
try {
Map<String, String> header = new HashMap<>();
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));
return JSON.parseObject(resp, ApiResp.class);
} catch (Exception e) {
......
......@@ -122,7 +122,12 @@ public class DeviceReq implements Serializable {
private Date defectsLiabilityPeriod;
/**
* 设备来源(默认为新设备)
* 设备状态 (0.未激活,1.离线,2.在线)
*/
private Integer deviceStatus;
/**
* 设备来源(0.旧设备,1.新设备)
*/
private Integer source;
......
......@@ -37,10 +37,10 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
/**
* 设备启用停用
* @param deviceCode
* @param id
* @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);
......
......@@ -75,8 +75,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
throw new AppException("所属产品不能为空!");
}
}
super.validData(entity, context);
}
......@@ -138,13 +136,21 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
}
@Override
public void deviceEnabled(String deviceCode, Integer enabled, Context context) {
DeviceEntity deviceEntity = this.selectOne(new DeviceQuery().deviceCode(deviceCode));
if (!ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!");
public void deviceEnabled(Long id, Integer enabled, Context context) {
DeviceEntity deviceEntity = this.get(id, context);
if (ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!");
deviceEntity.setEnabled(enabled);
deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(getContextUserId(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
public void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update) {
DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity));
deviceReq.setReceiveMethod(update.getValue());
deviceReq.setDeviceStatus(update.getValue());
deviceReq.setProductCode(productEntity.getProductCode());
//deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl())
//&& platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()
&& entity.getSwitchSend()) {
......@@ -293,7 +298,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setDeviceCode(StrUtil.replace(entity.getDeviceCode(), ":", "-"));
if (ObjectUtils.isEmpty(entity.getDeviceMac())) {
entity.setDeviceMac(entity.getDeviceCode());
}else{
} else {
entity.setDeviceMac(StrUtil.replace(entity.getDeviceMac(), ":", "-"));
}
......@@ -319,8 +324,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setProductName(productEntity.getProductName());
}
}
super.saveBefore(entity, context);
}
......
......@@ -168,18 +168,18 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
* 设备启用停用
*/
@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();
Map<String, Object> model = new HashMap<>();
String busiDesc = this.getModuleDesc() + "设备启用停用";
try {
this.service.active(deviceCode, getContext());
this.service.deviceEnabled(deviceEntity.getId(),deviceEntity.getEnabled(), getContext());
//this.init(request, response, null, model, getContext());
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
} catch (Exception e) {
log.error("设备激活消息", e);
log.error("设备启用停用消息", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
......@@ -214,36 +214,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "");
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);
recordSysLog(request, "首页统计 【成功】");
} catch (Exception e) {
......
......@@ -23,11 +23,10 @@ public class PlatformServiceImpl extends AbstractCRUDServiceImpl<PlatformDao, Pl
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);
}
}
\ No newline at end of file
......@@ -454,6 +454,8 @@ siteCode|String|站点编号,来源基础服务平台|是|-
siteName|String|站点名称|是|-
homeUrl|String|首页地址|否|-
deviceRemark|String|备注|是|-
deviceStatus|Integer|设备状态 (0.未激活,1.离线,2.在线)|是|默认0为激活
source|Integer|(0.旧设备,1.新设备)|是|默认1新设备
**请求样例:**
```
......@@ -489,7 +491,7 @@ data|object|数据对象|-
参数名称|类型|备注|必填|其它
:------|:---|:---|:---|:---
deviceCode|String|设备编码,如MAC地址|是|-
messageType|String|消息类型|是|如heart_beat
messageType|String|消息类型|是|如HEART_BEAT
timestamp|Long|时间戳|是|-
data|String|数据体,内容自行定义|否|-
......@@ -500,13 +502,13 @@ data|String|数据体,内容自行定义|否|-
{
"data":"{xxxx}",
"deviceCode":"a1",
"messageType":"heart_beat",
"messageType":"HEART_BEAT",
"timestamp":1654656951795
},
{
"data":"{bbbbbb}",
"deviceCode":"a2",
"messageType":"heart_beat",
"messageType":"HEART_BEAT",
"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