Commit 72c63261 authored by wanghao's avatar wanghao

1 传送带 ip 和 端口号维护

2 上料  下料时 判断 传送带 是否有东西
parent 973cb17c
package com.zehong.web.controller.equipment;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.ConveyorBeltIpMaintain;
import com.zehong.system.service.IConveyorBeltIpMaintainService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 传送带IP维护Controller
*
* @author zehong
* @date 2025-11-11
*/
@RestController
@RequestMapping("/conveyorBeltIp/maintain")
public class ConveyorBeltIpMaintainController extends BaseController
{
@Resource
private IConveyorBeltIpMaintainService conveyorBeltIpMaintainService;
/**
* 查询传送带IP维护列表
*/
@GetMapping("/list")
public TableDataInfo list(ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
startPage();
List<ConveyorBeltIpMaintain> list = conveyorBeltIpMaintainService.selectConveyorBeltIpMaintainList(conveyorBeltIpMaintain);
return getDataTable(list);
}
/**
* 导出传送带IP维护列表
*/
@GetMapping("/export")
public AjaxResult export(ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
List<ConveyorBeltIpMaintain> list = conveyorBeltIpMaintainService.selectConveyorBeltIpMaintainList(conveyorBeltIpMaintain);
ExcelUtil<ConveyorBeltIpMaintain> util = new ExcelUtil<ConveyorBeltIpMaintain>(ConveyorBeltIpMaintain.class);
return util.exportExcel(list, "传送带IP维护数据");
}
/**
* 获取传送带IP维护详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return AjaxResult.success(conveyorBeltIpMaintainService.selectConveyorBeltIpMaintainById(id));
}
/**
* 新增传送带IP维护
*/
@PostMapping
public AjaxResult add(@RequestBody ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
return toAjax(conveyorBeltIpMaintainService.insertConveyorBeltIpMaintain(conveyorBeltIpMaintain));
}
/**
* 修改传送带IP维护
*/
@PutMapping
public AjaxResult edit(@RequestBody ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
return toAjax(conveyorBeltIpMaintainService.updateConveyorBeltIpMaintain(conveyorBeltIpMaintain));
}
/**
* 删除传送带IP维护
*/
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(conveyorBeltIpMaintainService.deleteConveyorBeltIpMaintainByIds(ids));
}
}
......@@ -126,4 +126,8 @@ public class Constants
* 资源映射路径 前缀
*/
public static final String RESOURCE_PREFIX = "/profile";
public static final String FEED_CONVEYOR_IP_AND_PORT = "feedConveyorIpAndPort";
public static final String OUT_LET_BELT_IP_AND_PORT = "outletBeltIpAndPort";
}
package com.zehong.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 传送带IP维护对象 t_conveyor_belt_ip_maintain
*
* @author zehong
* @date 2025-11-11
*/
public class ConveyorBeltIpMaintain extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Integer id;
/** 传送带IP地址(IPv4格式) */
@Excel(name = "传送带IP地址", readConverterExp = "I=Pv4格式")
private String ip;
/** 端口号 */
private String port;
/** 取值时的业务标识key */
@Excel(name = "取值时的业务标识key")
private String fetchKey;
/** 传送带描述信息 */
@Excel(name = "传送带描述信息")
private String conveyorDesc;
public void setId(Integer id)
{
this.id = id;
}
public Integer getId()
{
return id;
}
public void setIp(String ip)
{
this.ip = ip;
}
public String getIp()
{
return ip;
}
public void setFetchKey(String fetchKey)
{
this.fetchKey = fetchKey;
}
public String getFetchKey()
{
return fetchKey;
}
public void setConveyorDesc(String conveyorDesc)
{
this.conveyorDesc = conveyorDesc;
}
public String getConveyorDesc()
{
return conveyorDesc;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("ip", getIp())
.append("fetchKey", getFetchKey())
.append("conveyorDesc", getConveyorDesc())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.ConveyorBeltIpMaintain;
/**
* 传送带IP维护Mapper接口
*
* @author zehong
* @date 2025-11-11
*/
public interface ConveyorBeltIpMaintainMapper
{
/**
* 查询传送带IP维护
*
* @param id 传送带IP维护ID
* @return 传送带IP维护
*/
public ConveyorBeltIpMaintain selectConveyorBeltIpMaintainById(Integer id);
/**
* 查询传送带IP维护列表
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 传送带IP维护集合
*/
public List<ConveyorBeltIpMaintain> selectConveyorBeltIpMaintainList(ConveyorBeltIpMaintain conveyorBeltIpMaintain);
/**
* 新增传送带IP维护
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 结果
*/
public int insertConveyorBeltIpMaintain(ConveyorBeltIpMaintain conveyorBeltIpMaintain);
public ConveyorBeltIpMaintain selectConfig(String fetchKey);
/**
* 修改传送带IP维护
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 结果
*/
public int updateConveyorBeltIpMaintain(ConveyorBeltIpMaintain conveyorBeltIpMaintain);
/**
* 删除传送带IP维护
*
* @param id 传送带IP维护ID
* @return 结果
*/
public int deleteConveyorBeltIpMaintainById(Integer id);
/**
* 批量删除传送带IP维护
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteConveyorBeltIpMaintainByIds(Integer[] ids);
}
......@@ -205,10 +205,10 @@ public class Modbus4jUtils {
* @throws ModbusTransportException
* @throws ErrorResponseException
*/
public static boolean[] getRoboticArmExitConveyorData() {
public static boolean[] getRoboticArmExitConveyorData(String ip, int port) {
ModbusMaster master = null;
try {
master = getMaster("192.168.1.12", 503);
master = getMaster(ip, port);
boolean[] booleans = readDiscreteInputs(master, 1, 0, 2);
if(master != null) {
......
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.ConveyorBeltIpMaintain;
/**
* 传送带IP维护Service接口
*
* @author zehong
* @date 2025-11-11
*/
public interface IConveyorBeltIpMaintainService
{
/**
* 查询传送带IP维护
*
* @param id 传送带IP维护ID
* @return 传送带IP维护
*/
public ConveyorBeltIpMaintain selectConveyorBeltIpMaintainById(Integer id);
/**
* 查询传送带IP维护列表
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 传送带IP维护集合
*/
public List<ConveyorBeltIpMaintain> selectConveyorBeltIpMaintainList(ConveyorBeltIpMaintain conveyorBeltIpMaintain);
/**
* 根据键名查询参数配置信息
*
* @param configKey 参数键名
* @return 参数键值
*/
public String selectConfigByKey(String configKey);
/**
* 新增传送带IP维护
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 结果
*/
public int insertConveyorBeltIpMaintain(ConveyorBeltIpMaintain conveyorBeltIpMaintain);
/**
* 修改传送带IP维护
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 结果
*/
public int updateConveyorBeltIpMaintain(ConveyorBeltIpMaintain conveyorBeltIpMaintain);
/**
* 批量删除传送带IP维护
*
* @param ids 需要删除的传送带IP维护ID
* @return 结果
*/
public int deleteConveyorBeltIpMaintainByIds(Integer[] ids);
/**
* 删除传送带IP维护信息
*
* @param id 传送带IP维护ID
* @return 结果
*/
public int deleteConveyorBeltIpMaintainById(Integer id);
}
package com.zehong.system.service.impl;
import com.zehong.common.constant.Constants;
import com.zehong.common.core.redis.RedisCache;
import com.zehong.common.core.text.Convert;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.ConveyorBeltIpMaintain;
import com.zehong.system.domain.SysConfig;
import com.zehong.system.mapper.ConveyorBeltIpMaintainMapper;
import com.zehong.system.service.IConveyorBeltIpMaintainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 传送带IP维护Service业务层处理
*
* @author zehong
* @date 2025-11-11
*/
@Service
public class ConveyorBeltIpMaintainServiceImpl implements IConveyorBeltIpMaintainService
{
@Resource
private ConveyorBeltIpMaintainMapper conveyorBeltIpMaintainMapper;
@Autowired
private RedisCache redisCache;
/**
* 查询传送带IP维护
*
* @param id 传送带IP维护ID
* @return 传送带IP维护
*/
@Override
public ConveyorBeltIpMaintain selectConveyorBeltIpMaintainById(Integer id)
{
return conveyorBeltIpMaintainMapper.selectConveyorBeltIpMaintainById(id);
}
/**
* 查询传送带IP维护列表
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 传送带IP维护
*/
@Override
public List<ConveyorBeltIpMaintain> selectConveyorBeltIpMaintainList(ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
return conveyorBeltIpMaintainMapper.selectConveyorBeltIpMaintainList(conveyorBeltIpMaintain);
}
/**
* 查询参数键名是否存在
*
* @param configKey 参数键名
* @return 结果
*/
@Override
public String selectConfigByKey(String configKey) {
String configValue = Convert.toStr(redisCache.getCacheObject(configKey));
if (StringUtils.isNotEmpty(configValue))
{
return configValue;
}
ConveyorBeltIpMaintain conveyorBeltIpMaintain = conveyorBeltIpMaintainMapper.selectConfig(configKey);
if (conveyorBeltIpMaintain != null)
{
String retConfig = conveyorBeltIpMaintain.getIp() + ":" + conveyorBeltIpMaintain.getPort();
redisCache.setCacheObject(configKey, retConfig);
return retConfig;
}
return StringUtils.EMPTY;
}
/**
* 新增传送带IP维护
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 结果
*/
@Override
public int insertConveyorBeltIpMaintain(ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
conveyorBeltIpMaintain.setCreateTime(DateUtils.getNowDate());
return conveyorBeltIpMaintainMapper.insertConveyorBeltIpMaintain(conveyorBeltIpMaintain);
}
/**
* 修改传送带IP维护
*
* @param conveyorBeltIpMaintain 传送带IP维护
* @return 结果
*/
@Override
public int updateConveyorBeltIpMaintain(ConveyorBeltIpMaintain conveyorBeltIpMaintain)
{
conveyorBeltIpMaintain.setUpdateTime(DateUtils.getNowDate());
return conveyorBeltIpMaintainMapper.updateConveyorBeltIpMaintain(conveyorBeltIpMaintain);
}
/**
* 批量删除传送带IP维护
*
* @param ids 需要删除的传送带IP维护ID
* @return 结果
*/
@Override
public int deleteConveyorBeltIpMaintainByIds(Integer[] ids)
{
return conveyorBeltIpMaintainMapper.deleteConveyorBeltIpMaintainByIds(ids);
}
/**
* 删除传送带IP维护信息
*
* @param id 传送带IP维护ID
* @return 结果
*/
@Override
public int deleteConveyorBeltIpMaintainById(Integer id)
{
return conveyorBeltIpMaintainMapper.deleteConveyorBeltIpMaintainById(id);
}
}
......@@ -10,6 +10,7 @@ import java.util.List;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.zehong.common.constant.Constants;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.redis.RedisCache;
import com.zehong.common.utils.DateUtils;
......@@ -20,13 +21,13 @@ import com.zehong.system.domain.TTrayInfo;
import com.zehong.system.mapper.*;
import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.netty.handler.NettyUdpServerHandler;
import com.zehong.system.service.IConveyorBeltIpMaintainService;
import com.zehong.system.service.websocket.RobotArmWebSocketHandler;
import com.zehong.system.task.CheckPowerOnCommandEvent;
import com.zehong.system.task.PowerOffCommandEvent;
import com.zehong.system.udp.UdpCommandSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
......@@ -77,6 +78,9 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
@Resource
private PalletDeviceBindingMapper palletDeviceBindingMapper;
@Resource
private IConveyorBeltIpMaintainService iConveyorBeltIpMaintainService;
@Resource
private RedisCache redisCache;
private SocketAddress getRobotAddress() {
......@@ -97,28 +101,45 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
if (cacheObject != null) {
priority = (String) cacheObject;
}
// 1. 处理待执行的上料指令
List<RobotArmCommand> loadingCommands =
robotArmCommandMapper.selectPendingLoadingCommands();
if (!loadingCommands.isEmpty() && "priority".equals(priority)) {
// 传送带检测先去掉
boolean[] roboticArmEntryConveyorData = Modbus4jUtils.getRoboticArmEntryConveyorData();
log.info("机械臂入口 conveyor 0状态: " + roboticArmEntryConveyorData[0]);
log.info("机械臂入口 conveyor 1状态: " + roboticArmEntryConveyorData[1]);
if(roboticArmEntryConveyorData[1]) {
sendCommand(loadingCommands.get(0), "LOAD");
return;
String feedConveyorIpAndPort = iConveyorBeltIpMaintainService.selectConfigByKey(Constants.FEED_CONVEYOR_IP_AND_PORT);
String feedIp ;
int feedPort ;
if (StringUtils.isNotBlank(feedConveyorIpAndPort)) {
String[] split = feedConveyorIpAndPort.split(":");
feedIp = split[0];
feedPort = Integer.parseInt(split[1]);
// 1. 处理待执行的上料指令
List<RobotArmCommand> loadingCommands =
robotArmCommandMapper.selectPendingLoadingCommands();
if (!loadingCommands.isEmpty() && "priority".equals(priority)) {
// 传送带检测先去掉
boolean[] roboticArmEntryConveyorData = Modbus4jUtils.getRoboticArmExitConveyorData(feedIp,feedPort);
log.info("机械臂入口 conveyor 0状态: " + roboticArmEntryConveyorData[0]);
log.info("机械臂入口 conveyor 1状态: " + roboticArmEntryConveyorData[1]);
if(roboticArmEntryConveyorData[1]) {
sendCommand(loadingCommands.get(0), "LOAD");
return;
}
}
}
// 2. 处理待执行的下料指令
List<RobotArmCommand> unloadingCommands =
robotArmCommandMapper.selectPendingUnloadingCommands();
if (!unloadingCommands.isEmpty() && "unloading".equals(priority)) {
boolean[] roboticArmExitConveyorData = Modbus4jUtils.getRoboticArmExitConveyorData();
if(roboticArmExitConveyorData[1]) {
log.info("开始处理下料指令: {}", unloadingCommands.get(0));
sendCommand(unloadingCommands.get(0), "UNLOAD");
String outLetBeltIpAndPort = iConveyorBeltIpMaintainService.selectConfigByKey(Constants.OUT_LET_BELT_IP_AND_PORT);
String outLetBeltIp;
int outLetBeltPort;
if (StringUtils.isNotBlank(outLetBeltIpAndPort)) {
String[] split = outLetBeltIpAndPort.split(":");
outLetBeltIp = split[0];
outLetBeltPort = Integer.parseInt(split[1]);
// 2. 处理待执行的下料指令
List<RobotArmCommand> unloadingCommands =
robotArmCommandMapper.selectPendingUnloadingCommands();
if (!unloadingCommands.isEmpty() && "unloading".equals(priority)) {
boolean[] roboticArmExitConveyorData = Modbus4jUtils.getRoboticArmExitConveyorData(outLetBeltIp,outLetBeltPort);
if(roboticArmExitConveyorData[1]) {
log.info("开始处理下料指令: {}", unloadingCommands.get(0));
sendCommand(unloadingCommands.get(0), "UNLOAD");
}
}
}
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.ConveyorBeltIpMaintainMapper">
<resultMap type="ConveyorBeltIpMaintain" id="ConveyorBeltIpMaintainResult">
<result property="id" column="f_id" />
<result property="ip" column="f_ip" />
<result property="port" column="f_port" />
<result property="fetchKey" column="f_fetch_key" />
<result property="conveyorDesc" column="f_conveyor_desc" />
<result property="createTime" column="f_create_time" />
<result property="updateTime" column="f_update_time" />
</resultMap>
<sql id="selectConveyorBeltIpMaintainVo">
select f_id, f_ip, f_port,f_fetch_key, f_conveyor_desc, f_create_time, f_update_time from t_conveyor_belt_ip_maintain
</sql>
<select id="selectConveyorBeltIpMaintainList" parameterType="ConveyorBeltIpMaintain" resultMap="ConveyorBeltIpMaintainResult">
<include refid="selectConveyorBeltIpMaintainVo"/>
<where>
<if test="ip != null and ip != ''"> and f_ip = #{ip}</if>
<if test="port != null and port != ''"> and f_port = #{port}</if>
<if test="fetchKey != null and fetchKey != ''"> and f_fetch_key = #{fetchKey}</if>
<if test="conveyorDesc != null and conveyorDesc != ''"> and f_conveyor_desc = #{conveyorDesc}</if>
<if test="createTime != null "> and f_create_time = #{createTime}</if>
<if test="updateTime != null "> and f_update_time = #{updateTime}</if>
</where>
</select>
<select id="selectConveyorBeltIpMaintainById" parameterType="Integer" resultMap="ConveyorBeltIpMaintainResult">
<include refid="selectConveyorBeltIpMaintainVo"/>
where f_id = #{id}
</select>
<select id="selectConfig" parameterType="string" resultMap="ConveyorBeltIpMaintainResult">
<include refid="selectConveyorBeltIpMaintainVo"></include>
where f_fetch_key = #{fetchKey}
</select>
<insert id="insertConveyorBeltIpMaintain" parameterType="ConveyorBeltIpMaintain" useGeneratedKeys="true" keyProperty="id">
insert into t_conveyor_belt_ip_maintain
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ip != null and ip != ''">f_ip,</if>
<if test="port != null and port != ''">f_port,</if>
<if test="fetchKey != null and fetchKey != ''">f_fetch_key,</if>
<if test="conveyorDesc != null">f_conveyor_desc,</if>
<if test="createTime != null">f_create_time,</if>
<if test="updateTime != null">f_update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ip != null and ip != ''">#{ip},</if>
<if test="port != null and port != ''">#{port},</if>
<if test="fetchKey != null and fetchKey != ''">#{fetchKey},</if>
<if test="conveyorDesc != null">#{conveyorDesc},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateConveyorBeltIpMaintain" parameterType="ConveyorBeltIpMaintain">
update t_conveyor_belt_ip_maintain
<trim prefix="SET" suffixOverrides=",">
<if test="ip != null and ip != ''">f_ip = #{ip},</if>
<if test="port != null and port != ''">f_port = #{port},</if>
<if test="fetchKey != null and fetchKey != ''">f_fetch_key = #{fetchKey},</if>
<if test="conveyorDesc != null">f_conveyor_desc = #{conveyorDesc},</if>
<if test="createTime != null">f_create_time = #{createTime},</if>
<if test="updateTime != null">f_update_time = #{updateTime},</if>
</trim>
where f_id = #{id}
</update>
<delete id="deleteConveyorBeltIpMaintainById" parameterType="Integer">
delete from t_conveyor_belt_ip_maintain where f_id = #{id}
</delete>
<delete id="deleteConveyorBeltIpMaintainByIds" parameterType="String">
delete from t_conveyor_belt_ip_maintain where f_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询传送带IP维护列表
export function listMaintain(query) {
return request({
url: '/conveyorBeltIp/maintain/list',
method: 'get',
params: query
})
}
// 查询传送带IP维护详细
export function getMaintain(id) {
return request({
url: '/conveyorBeltIp/maintain/' + id,
method: 'get'
})
}
// 新增传送带IP维护
export function addMaintain(data) {
return request({
url: '/conveyorBeltIp/maintain',
method: 'post',
data: data
})
}
// 修改传送带IP维护
export function updateMaintain(data) {
return request({
url: '/conveyorBeltIp/maintain',
method: 'put',
data: data
})
}
// 删除传送带IP维护
export function delMaintain(id) {
return request({
url: '/conveyorBeltIp/maintain/' + id,
method: 'delete'
})
}
// 导出传送带IP维护
export function exportMaintain(query) {
return request({
url: '/conveyorBeltIp/maintain/export',
method: 'get',
params: query
})
}
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="IP地址" prop="ip">
<el-input
v-model="queryParams.ip"
placeholder="请输入IP地址"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="业务标识key" prop="fetchKey">
<el-input
v-model="queryParams.fetchKey"
placeholder="业务标识key"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="maintainList" @selection-change="handleSelectionChange">
<el-table-column label="IP地址" align="center" prop="ip" />
<el-table-column label="端口号" align="center" prop="port" />
<el-table-column label="取值时的业务标识key" align="center" prop="fetchKey" />
<el-table-column label="传送带描述信息" align="center" prop="conveyorDesc" />
<el-table-column label="记录创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="记录更新时间" align="center" prop="updateTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改传送带IP维护对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="传送带IP地址" prop="ip">
<el-input v-model="form.ip" placeholder="请输入传送带IP地址" />
</el-form-item>
<el-form-item label="取值时的业务标识key" prop="fetchKey">
<el-input v-model="form.fetchKey" placeholder="请输入取值时的业务标识key" />
</el-form-item>
<el-form-item label="传送带描述信息" prop="conveyorDesc">
<el-input v-model="form.conveyorDesc" placeholder="请输入传送带描述信息" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listMaintain, getMaintain, delMaintain, addMaintain, updateMaintain, exportMaintain } from "@/api/conveyorBeltIpMaintain/conveyorBeltIpMaintain";
export default {
name: "Maintain",
components: {
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 传送带IP维护表格数据
maintainList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
ip: null,
fetchKey: null,
conveyorDesc: null,
createTime: null,
updateTime: null
},
// 表单参数
form: {},
// 表单校验
rules: {
ip: [
{ required: true, message: "传送带IP地址不能为空", trigger: "blur" }
],
fetchKey: [
{ required: true, message: "取值时的业务标识key不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询传送带IP维护列表 */
getList() {
this.loading = true;
listMaintain(this.queryParams).then(response => {
this.maintainList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
ip: null,
fetchKey: null,
conveyorDesc: null,
createTime: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加传送带IP维护";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getMaintain(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改传送带IP维护";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateMaintain(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addMaintain(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除传送带IP维护编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delMaintain(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有传送带IP维护数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return exportMaintain(queryParams);
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
}
}
};
</script>
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