Commit 4dbce8d7 authored by wanghao's avatar wanghao

1 给层单独设置 上电 断电 命令

parent c189bebc
...@@ -64,6 +64,14 @@ public class TStoreyInfoController extends BaseController ...@@ -64,6 +64,14 @@ public class TStoreyInfoController extends BaseController
return AjaxResult.success(tStoreyInfoService.queryByDepartmentId(fEquipmentId)); return AjaxResult.success(tStoreyInfoService.queryByDepartmentId(fEquipmentId));
} }
/**
* 给设备上电
*/
@GetMapping(value = "/powerOn")
public AjaxResult powerOn(TStoreyInfo tStoreyInfo) {
return tStoreyInfoService.powerOn(tStoreyInfo);
}
/** /**
* 获取老化层信息详细信息 * 获取老化层信息详细信息
*/ */
......
package com.zehong.system.service; package com.zehong.system.service;
import java.util.List; import java.util.List;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.system.domain.TStoreyInfo; import com.zehong.system.domain.TStoreyInfo;
/** /**
...@@ -37,6 +39,8 @@ public interface ITStoreyInfoService ...@@ -37,6 +39,8 @@ public interface ITStoreyInfoService
public List<TStoreyInfo> queryByDepartmentId(Long fDepartmentId); public List<TStoreyInfo> queryByDepartmentId(Long fDepartmentId);
public AjaxResult powerOn(TStoreyInfo tStoreyInfo);
/** /**
* 新增老化层信息 * 新增老化层信息
* *
......
...@@ -5,10 +5,16 @@ import java.util.Arrays; ...@@ -5,10 +5,16 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils; import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TEquipmentInfo; import com.zehong.system.domain.TEquipmentInfo;
import com.zehong.system.mapper.TEquipmentInfoMapper; import com.zehong.system.mapper.TEquipmentInfoMapper;
import com.zehong.system.modbus.util.Modbus4jUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TStoreyInfoMapper; import com.zehong.system.mapper.TStoreyInfoMapper;
...@@ -163,6 +169,40 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -163,6 +169,40 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return tStoreyInfoMapper.queryByDepartmentId(fEquipmentId); return tStoreyInfoMapper.queryByDepartmentId(fEquipmentId);
} }
/**
* 给设备上电
* @param tStoreyInfo t
* @return r
*/
@Override
public AjaxResult powerOn(TStoreyInfo tStoreyInfo) {
if(tStoreyInfo.getfEquipmentId() == null || tStoreyInfo.getfStoreyCode() == null) {
return AjaxResult.error("参数异常!!!");
}
TEquipmentInfo tEquipmentInfo = equipmentInfoMapper.selectTEquipmentInfoById(tStoreyInfo.getfEquipmentId());
String registerOffset = tStoreyInfo.getfStoreyCode().split("-")[1];
try {
ModbusMaster master = Modbus4jUtils.getMaster(tEquipmentInfo.getfPowerOutageIp(), tEquipmentInfo.getfPowerOutagePort());
Boolean aBoolean = Modbus4jUtils.readCoilStatus(master, 1, Integer.parseInt(registerOffset));
if(!aBoolean) {
Modbus4jUtils.writeCoil(master, 1, Integer.parseInt(registerOffset), true);
tStoreyInfo.setfStatus("1");
tStoreyInfo.setfAgingStartTime(new Date());
tStoreyInfoMapper.updateTStoreyInfo(tStoreyInfo);
}
return AjaxResult.success();
} catch (ModbusInitException | ModbusTransportException | ErrorResponseException e) {
throw new RuntimeException(e);
}
}
/** /**
* 新增老化层信息 * 新增老化层信息
* *
......
...@@ -59,3 +59,12 @@ export function exportStorey(query) { ...@@ -59,3 +59,12 @@ export function exportStorey(query) {
params: query params: query
}) })
} }
export function PowerOn(query) {
return request({
url: '/storey/PowerOn/',
method: 'get',
params: query
})
}
...@@ -100,6 +100,20 @@ ...@@ -100,6 +100,20 @@
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
>删除</el-button> >删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handlePowerOn(scope.row)"
>上电</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handlePowerOutage(scope.row)"
>断电</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -161,7 +175,7 @@ ...@@ -161,7 +175,7 @@
</template> </template>
<script> <script>
import { listStorey, getStorey, delStorey, addStorey, updateStorey, exportStorey } from "@/api/storey/storey"; import { listStorey, getStorey, delStorey, addStorey, updateStorey, exportStorey,PowerOn } from "@/api/storey/storey";
export default { export default {
name: "Info", name: "Info",
...@@ -309,6 +323,24 @@ export default { ...@@ -309,6 +323,24 @@ export default {
} }
} }
}); });
},
//上电
handlePowerOn(row) {
const fIp = row.fIp;
this.$confirm('是否确认给设备IP为"' + fIp + '"的设备上电?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return PowerOn(row);
}).then(() => {
this.getList();
this.msgSuccess("上电成功");
}).catch(() => {});
},
// 断电
handlePowerOutage(row) {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
......
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