Commit 3b57605c authored by 赵啸非's avatar 赵啸非

修改同步用户

parent d416bc8a
......@@ -2409,7 +2409,7 @@ data|object|数据对象|-
### 工作人员密码修改
**请求URL:** workman/change/password
**请求URL:** workman/person/change/password
**请求方式:** POST
......
......@@ -134,6 +134,39 @@
this.$refs.drawerform.view(row);
},
activeDevice(row) {
this.$post("/device/active", {
deviceCode: row.deviceCode,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("激活设备成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
// 操作菜单状态
changeStatus(row, column) {
return (
<device-switch
confirm
url="/device/enable"
row={row}
onChange={this.statusChange}
value={this.tableData.data}
onInput={(data) => {
this.tableData.data = data;
}}
/>
);
},
statusChange() {
this.$store.dispatch('login');
},
},
data() {
return {
......@@ -179,14 +212,44 @@
{label: "设备状态 ", prop: "deviceStatus",formatter: this.formatter},
{label: "启用状态 ", prop: "enabled",formatter: this.formatter},
{
prop: "enabled",
align: "center",
label: "启用/停用",
width: 100,
formatter: this.changeStatus,
},
{
label: "操作",
width: 240,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
<div>
<span> </span>
{row.deviceStatus === 0 ? (
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.activeDevice(row);
}}
>
激活
</el-button>
) : (
""
)}
<span> </span>
<table-buttons
noAdd
row={row}
onEdit={this.toEdit}
onView={this.toView}
onDel={this.toDel}
/>
</div>
);
}
}
......
......@@ -133,6 +133,38 @@
toView(row) {
this.$refs.drawerform.view(row);
},
activeDevice(row) {
this.$post("/device/active", {
deviceCode: row.deviceCode,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("激活设备成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
// 操作菜单状态
changeStatus(row, column) {
return (
<device-switch
confirm
url="/device/enable"
row={row}
onChange={this.statusChange}
value={this.tableData.data}
onInput={(data) => {
this.tableData.data = data;
}}
/>
);
},
statusChange() {
this.$store.dispatch('login');
},
},
data() {
......@@ -185,7 +217,31 @@
width: 240,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
<div>
<span> </span>
{row.deviceStatus === 0 ? (
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.activeDevice(row);
}}
>
激活
</el-button>
) : (
""
)}
<span> </span>
<table-buttons
noAdd
row={row}
onEdit={this.toEdit}
onView={this.toView}
onDel={this.toDel}
/>
</div>
);
}
}
......
......@@ -2,9 +2,12 @@ package com.mortals.xhx.module.device.service.impl;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.code.EnabledEnum;
import com.mortals.xhx.common.pdu.LoginForm;
import com.mortals.xhx.common.pdu.device.DeviceReq;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.module.device.model.DeviceQuery;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,6 +18,11 @@ import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* DeviceService
......@@ -53,8 +61,8 @@ public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, Device
deviceReq.setSiteName("宜宾市民中心");
deviceReq.setLeadingOfficial(entity.getLeadingOfficial());
deviceReq.setLeadingOfficialTelephone(entity.getLeadingOfficialTelephone());
deviceReq.setDeviceStatus(0);
deviceReq.setSource(1);
deviceReq.setDeviceStatus(entity.getDeviceStatus());
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token);
log.info("添加结果:{}", JSON.toJSONString(rest));
}
......@@ -64,15 +72,71 @@ public class DeviceServiceImpl extends AbstractCRUDServiceImpl<DeviceDao, Device
protected void updateAfter(DeviceEntity entity, Context context) throws AppException {
super.updateAfter(entity, context);
//todo 通知设备管理系统
String token = getToken();
DeviceReq deviceReq = new DeviceReq();
deviceReq.setReceiveMethod(2);
deviceReq.setDeviceName(entity.getDeviceName());
deviceReq.setDeviceCode(entity.getDeviceCode());
deviceReq.setProductCode(entity.getProductCode());
deviceReq.setIp(entity.getIp());
deviceReq.setPort(entity.getPort());
deviceReq.setSiteId(1L);
deviceReq.setSiteCode("511500000000-0001");
deviceReq.setSiteName("宜宾市民中心");
deviceReq.setLeadingOfficial(entity.getLeadingOfficial());
deviceReq.setLeadingOfficialTelephone(entity.getLeadingOfficialTelephone());
deviceReq.setSource(1);
deviceReq.setDeviceStatus(entity.getDeviceStatus());
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token);
log.info("更新结果:{}", JSON.toJSONString(rest));
}
@Override
public void active(String deviceCode, Context context) {
DeviceEntity deviceEntity = this.selectOne(new DeviceQuery().deviceCode(deviceCode));
if (ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!");
if (deviceEntity.getDeviceStatus() > DeviceStatusEnum.未激活.getValue())
throw new AppException("当前设备已激活!");
deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue());
deviceEntity.setEnabled(EnabledEnum.启用.getValue());
this.getDao().update(deviceEntity);
String token = getToken();
DeviceReq deviceReq = new DeviceReq();
deviceReq.setReceiveMethod(4);
deviceReq.setDeviceCode(deviceCode);
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token);
log.info("激活结果:{}", JSON.toJSONString(rest));
}
@Override
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.getDao().update(deviceEntity);
String token = getToken();
DeviceReq deviceReq = new DeviceReq();
deviceReq.setReceiveMethod(5);
deviceReq.setDeviceCode(deviceEntity.getDeviceCode());
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token);
log.info("激活结果:{}", JSON.toJSONString(rest));
}
@Override
public void deviceEnabled(Long id, Integer status, Context context) {
protected void removeBefore(Long[] ids, Context context) throws AppException {
super.removeBefore(ids, context);
String token = getToken();
List<DeviceEntity> deviceEntities = this.get(ids, context);
for (DeviceEntity entity : deviceEntities) {
DeviceReq deviceReq = new DeviceReq();
deviceReq.setReceiveMethod(3);
deviceReq.setDeviceCode(entity.getDeviceCode());
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token);
log.info("删除结果:{}", JSON.toJSONString(rest));
}
}
......
......@@ -88,7 +88,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
Map<String, Object> model = new HashMap<>();
String busiDesc = this.getModuleDesc() + "设备";
try {
//this.service.deviceEnabled(deviceEntity.getId(), deviceEntity.getEnabled(), getContext());
this.service.deviceEnabled(deviceEntity.getId(), deviceEntity.getEnabled(), getContext());
recordSysLog(request, busiDesc + EnabledEnum.getByValue(deviceEntity.getEnabled()).getDesc() + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
......
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