Compare commits

...

5 Commits

35 changed files with 1851 additions and 106 deletions

View File

@ -41,7 +41,7 @@ public class MqttAutoStart implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws MqttException {
if(false){
if(true){
// 创建MQTT客户端
MyMqttClient myMqttClient = new MyMqttClient(host, userName, password, clientId, timeOut, keepAlive);
logger.info("############## 1、mqtt 客户端创建完成##############");

View File

@ -1,17 +1,22 @@
package com.inspur.module.data.mqtt;
import com.fhs.common.utils.JsonUtils;
import com.inspur.framework.common.util.spring.SpringUtils;
import com.inspur.module.data.service.InfluxDBService;
import com.inspur.module.system.api.alarm.AlarmRulesApi;
import com.inspur.module.system.api.alarm.dto.AlarmRulesRespDTO;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayInfoDO;
import com.inspur.module.system.service.gatewayinfo.GatewayInfoService;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
import java.util.*;
/**
* @author lh
@ -81,48 +86,18 @@ public class MyMqttCallback implements MqttCallback {
//解析入库
try {
Map<String,Object> map = JsonUtils.parseJSON2Map(mqttMsg);
// JSONObject jsonObject = (JSONObject) JSON.parse(mqttMsg);
// JsonUtils.parseObject()
// String measurement = "phm_monitor_data_list";
// Map<String,String> tags = new TreeMap();
// tags.put("equ_id","S02-27-001");
// Map<String,Object> fields = new TreeMap();
// /** 进油温度 */
// fields.put("rPT1",jsonObject.get("rPT1") == null ? "" : jsonObject.get("rPT1"));
// /** 回油温度 */
// fields.put("rPT2",jsonObject.get("rPT2") == null ? "" : jsonObject.get("rPT2"));
// /** 4um颗粒度 */
// fields.put("iPM4",jsonObject.get("iPM4") == null ? "" : jsonObject.get("iPM4"));
// /** 6um颗粒度 */
// fields.put("iPM6",jsonObject.get("iPM6") == null ? "" : jsonObject.get("iPM6"));
// /** 14um颗粒度 */
// fields.put("iPM14",jsonObject.get("iPM14") == null ? "" : jsonObject.get("iPM14"));
// /** 21um颗粒度 */
// fields.put("iPM21",jsonObject.get("iPM21") == null ? "" : jsonObject.get("iPM21"));
// /** 进油压力 */
// fields.put("rSP1",jsonObject.get("rSP1") == null ? "" : jsonObject.get("rSP1"));
// /** 相对湿度 */
// fields.put("rRH",jsonObject.get("rRH") == null ? "" : jsonObject.get("rRH"));
// /** 粘度 */
// fields.put("rU",jsonObject.get("rU") == null ? "" : jsonObject.get("rU"));
// /** X1轴震动传感器 */
// fields.put("rX1",jsonObject.get("rX1") == null ? "" : jsonObject.get("rX1"));
// /** X2轴震动传感器 */
// fields.put("rX2",jsonObject.get("rX2") == null ? "" : jsonObject.get("rX2"));
// /** Y1轴震动传感器 */
// fields.put("rY1",jsonObject.get("rY1") == null ? "" : jsonObject.get("rY1"));
// /** Y2轴震动传感器 */
// fields.put("rY2",jsonObject.get("rY2") == null ? "" : jsonObject.get("rY2"));
// /** Z轴震动传感器 */
// fields.put("rZ",jsonObject.get("rZ") == null ? "" : jsonObject.get("rZ"));
// /** 油液密度 */
// fields.put("rp",jsonObject.get("rp") == null ? "" : jsonObject.get("rp"));
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String format = simpleDateFormat.format(new Date());
// fields.put("insertTime",format);
//
// InfluxDBService i = BeanUtils.getBean(InfluxDBService.class);
// i.insert(measurement,tags,fields);
String deviceName = (String) map.get("deviceName");
String deviceType = (String) map.get("deviceType");
String gatewayCode = deviceName.substring(0,17);
Map<String,Object> mapping = getGatewayMapping(gatewayCode);
String msgType = (String) mapping.get("msgType");
if(map.get("msgType") != null && msgType.equals(map.get("msgType"))){
process((String)mapping.get(deviceType),(String)mapping.get("equipId"),(Map<String,String>)mapping.get(deviceType + "_msg"),(Map<String,Object>)map.get("msg"));
}else{
logger.info("数据未存储!");
}
logger.info("接收的信息:"+ map.get("deviceName"));
} catch (Exception e) {
e.printStackTrace();
}
@ -154,4 +129,105 @@ public class MyMqttCallback implements MqttCallback {
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
logger.info("==========deliveryComplete={}==========", iMqttDeliveryToken.isComplete());
}
/**
* 获取网关相关映射
*/
private Map<String, Object> getGatewayMapping(String gatewayCode) {
GatewayInfoService gatewayInfoService = SpringUtils.getBean(GatewayInfoService.class);
GatewayInfoDO gatewayInfo = gatewayInfoService.getGatewayInfoByGatewayCode(gatewayCode);
//TODO 通过网关信息查询采集卡映射和参数映射
Map<String,Object> cardMapping = new HashMap<>();
cardMapping.put("equipId",gatewayInfo.getEquipId());
cardMapping.put("msgType","POST_TELEMETRY_REQUEST");
cardMapping.put("JCka1","gateway_current_data");
cardMapping.put("JCka2","gateway_hy_data");
cardMapping.put("PT100T16","gateway_temp_data");
cardMapping.put("JCZ163R","gateway_aclr_data");
cardMapping.put("FANUC","gateway_fanuc_data");
Map<String,String> paramMapping1 = new HashMap<>();
paramMapping1.put("CH0","chip_removal_1");
paramMapping1.put("Ch1","chip_removal_2");
cardMapping.put("JCka1_msg",paramMapping1);
Map<String,String> paramMapping2 = new HashMap<>();
paramMapping2.put("CH0","hy_1");
paramMapping2.put("Ch1","hy_2");
paramMapping2.put("Ch2","hy_3");
cardMapping.put("JCka2_msg",paramMapping2);
Map<String,String> paramMapping3 = new HashMap<>();
paramMapping3.put("T1","zn_temp");
paramMapping3.put("T2","z0_temp");
paramMapping3.put("T3","zp_temp");
paramMapping3.put("T4","cr1_temp");
paramMapping3.put("T5","cr2_temp");
paramMapping3.put("T6","xn_temp");
paramMapping3.put("T7","x0_temp");
paramMapping3.put("T8","xp_temp");
paramMapping3.put("T9","yn_temp");
paramMapping3.put("T10","y0_temp");
paramMapping3.put("T11","yp_temp");
cardMapping.put("PT100T16_msg",paramMapping3);
Map<String,String> paramMapping4 = new HashMap<>();
paramMapping4.put("XaR","x_aclr_rms");
paramMapping4.put("YaR","y_aclr_rms");
paramMapping4.put("ZaR","z_aclr_rms");
paramMapping4.put("XvR","x_speed_rms");
paramMapping4.put("YvR","y_speed_rms");
paramMapping4.put("ZvR","z_speed_rms");
paramMapping4.put("XdR","x_dis_rms");
paramMapping4.put("YdR","y_dis_rms");
paramMapping4.put("ZdR","z_dis_rms");
paramMapping4.put("XaP","x_aclr_peak");
paramMapping4.put("YaP","y_aclr_peak");
paramMapping4.put("ZaP","z_aclr_peak");
paramMapping4.put("XvP","x_speed_peak");
paramMapping4.put("YvP","y_speed_peak");
paramMapping4.put("ZvP","z_speed_peak");
paramMapping4.put("XdPP","x_dis_peak");
paramMapping4.put("YdPP","y_dis_peak");
paramMapping4.put("ZdPP","z_dis_peak");
cardMapping.put("JCZ163R_msg",paramMapping4);
Map<String,String> paramMapping5 = new HashMap<>();
paramMapping5.put("WorkTime","work_time");
paramMapping5.put("PowerTime","power_time");
paramMapping5.put("TotalProcess","total_process");
paramMapping5.put("ProcessNum","process_num");
cardMapping.put("FANUC_msg",paramMapping5);
return cardMapping;
}
private void process(String measurement,String equipId,Map<String,String> mapping,Map<String,Object> msg) {
InfluxDBService influxDBService = SpringUtils.getBean(InfluxDBService.class);
AlarmRulesApi alarmRulesApi = SpringUtils.getBean(AlarmRulesApi.class);
Map<String, Object> fields = new HashMap<>();
Map<String, String> tags = new HashMap<>();
tags.put("equip_id",equipId);
mapping.forEach((k,v)->{
if(msg.containsKey(k)){
fields.put(v,msg.get(k));
}
});
//报警过滤
List<AlarmRulesRespDTO> rules = alarmRulesApi.selectAlarmRulesListByCatch(equipId);
if(rules != null && rules.size() > 0){//报警规则过滤
int alarmNum = alarmRulesApi.alarmRulesFilter(fields, rules);
logger.info("本次产生报警{}条",alarmNum);
}
influxDBService.insert(measurement,tags, fields);
logger.info("数据已插入{}表中!",measurement);
}
}

View File

@ -23,45 +23,45 @@ public class DataProducerTask implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
Timer timer1 = new Timer();
timer1.schedule(new TimerTask() {
@Override
public void run() {
threadPoolTaskExecutor.execute(new Channel1DataProcess());
}
},1000,10000);
Timer timer2 = new Timer();
timer2.schedule(new TimerTask() {
@Override
public void run() {
threadPoolTaskExecutor.execute(new Channel2DataProcess());
}
},5000,10000);
Timer timer3 = new Timer();
timer3.schedule(new TimerTask() {
@Override
public void run() {
threadPoolTaskExecutor.execute(new Channel3DataProcess());
}
},10000,10000);
Timer timer4 = new Timer();
timer4.schedule(new TimerTask() {
@Override
public void run() {
threadPoolTaskExecutor.execute(new Channel4DataProcess());
}
},14000,10000);
Timer timer5 = new Timer();
timer5.schedule(new TimerTask() {
@Override
public void run() {
threadPoolTaskExecutor.execute(new Channel5DataProcess());
}
},19000,10000);
// Timer timer1 = new Timer();
// timer1.schedule(new TimerTask() {
// @Override
// public void run() {
// threadPoolTaskExecutor.execute(new Channel1DataProcess());
// }
// },1000,10000);
//
// Timer timer2 = new Timer();
// timer2.schedule(new TimerTask() {
// @Override
// public void run() {
// threadPoolTaskExecutor.execute(new Channel2DataProcess());
// }
// },5000,10000);
//
// Timer timer3 = new Timer();
// timer3.schedule(new TimerTask() {
// @Override
// public void run() {
// threadPoolTaskExecutor.execute(new Channel3DataProcess());
// }
// },10000,10000);
//
// Timer timer4 = new Timer();
// timer4.schedule(new TimerTask() {
// @Override
// public void run() {
// threadPoolTaskExecutor.execute(new Channel4DataProcess());
// }
// },14000,10000);
//
// Timer timer5 = new Timer();
// timer5.schedule(new TimerTask() {
// @Override
// public void run() {
// threadPoolTaskExecutor.execute(new Channel5DataProcess());
// }
// },19000,10000);
}
}

View File

@ -185,4 +185,7 @@ public interface ErrorCodeConstants {
ErrorCode EQUIP_ALARM_DATA_NOT_EXISTS = new ErrorCode(1_002_030_001, "机床报警数据不存在");
ErrorCode ALARM_DATA_NOT_EXISTS = new ErrorCode(1_002_030_002, "机床参数报警记录不存在");
ErrorCode GATEWAY_CARD_INFO_NOT_EXISTS = new ErrorCode(1_002_030_003, "机床网关采集卡不存在");
ErrorCode GATEWAY_CARD_PARAMS_NOT_EXISTS = new ErrorCode(1_002_030_004, "机床网关参数不存在");
}

View File

@ -0,0 +1,95 @@
package com.inspur.module.system.controller.admin.gatewayinfo;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.pojo.CommonResult.success;
import com.inspur.framework.excel.core.util.ExcelUtils;
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
import com.inspur.module.system.service.gatewayinfo.GatewayCardInfoService;
@Tag(name = "管理后台 - 机床网关采集卡")
@RestController
@RequestMapping("/imt/gateway-card-info")
@Validated
public class GatewayCardInfoController {
@Resource
private GatewayCardInfoService gatewayCardInfoService;
@PostMapping("/create")
@Operation(summary = "创建机床网关采集卡")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<String> createGatewayCardInfo(@Valid @RequestBody GatewayCardInfoSaveReqVO createReqVO) {
return success(gatewayCardInfoService.createGatewayCardInfo(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新机床网关采集卡")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<Boolean> updateGatewayCardInfo(@Valid @RequestBody GatewayCardInfoSaveReqVO updateReqVO) {
gatewayCardInfoService.updateGatewayCardInfo(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床网关采集卡")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<Boolean> deleteGatewayCardInfo(@RequestParam("id") String id) {
gatewayCardInfoService.deleteGatewayCardInfo(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得机床网关采集卡")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<GatewayCardInfoRespVO> getGatewayCardInfo(@RequestParam("id") String id) {
GatewayCardInfoDO gatewayCardInfo = gatewayCardInfoService.getGatewayCardInfo(id);
return success(BeanUtils.toBean(gatewayCardInfo, GatewayCardInfoRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得机床网关采集卡分页")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<PageResult<GatewayCardInfoRespVO>> getGatewayCardInfoPage(@Valid GatewayCardInfoPageReqVO pageReqVO) {
PageResult<GatewayCardInfoDO> pageResult = gatewayCardInfoService.getGatewayCardInfoPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, GatewayCardInfoRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出机床网关采集卡 Excel")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
@ApiAccessLog(operateType = EXPORT)
public void exportGatewayCardInfoExcel(@Valid GatewayCardInfoPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<GatewayCardInfoDO> list = gatewayCardInfoService.getGatewayCardInfoPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "机床网关采集卡.xls", "数据", GatewayCardInfoRespVO.class,
BeanUtils.toBean(list, GatewayCardInfoRespVO.class));
}
}

View File

@ -0,0 +1,106 @@
package com.inspur.module.system.controller.admin.gatewayinfo;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import java.util.stream.Collectors;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.pojo.CommonResult.success;
import com.inspur.framework.excel.core.util.ExcelUtils;
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO;
import com.inspur.module.system.service.gatewayinfo.GatewayCardParamsService;
@Tag(name = "管理后台 - 机床网关采集卡参数")
@RestController
@RequestMapping("/imt/gateway-card-params")
@Validated
public class GatewayCardParamsController {
@Resource
private GatewayCardParamsService gatewayCardParamsService;
@PostMapping("/create")
@Operation(summary = "创建机床网关采集卡参数")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<String> createGatewayCardParams(@Valid @RequestBody GatewayCardParamsSaveReqVO createReqVO) {
return success(gatewayCardParamsService.createGatewayCardParams(createReqVO));
}
@PostMapping("/submit")
@Operation(summary = "更新机床网关采集卡参数")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<Boolean> submitGatewayCardParams(@Valid @RequestBody List<GatewayCardParamsSaveReqVO> paramsList) {
List<GatewayCardParamsSaveReqVO> createLists = paramsList.stream().filter(param -> param.getChannelId() == null).collect(Collectors.toList());
List<GatewayCardParamsSaveReqVO> updateLists = paramsList.stream().filter(param -> param.getChannelId() != null).collect(Collectors.toList());
return success(gatewayCardParamsService.batchCreateGatewayCardParams(createLists) & gatewayCardParamsService.batchUpdateGatewayCardParams(updateLists));
}
@PutMapping("/update")
@Operation(summary = "更新机床网关采集卡参数")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<Boolean> updateGatewayCardParams(@Valid @RequestBody GatewayCardParamsSaveReqVO updateReqVO) {
gatewayCardParamsService.updateGatewayCardParams(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床网关采集卡参数")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<Boolean> deleteGatewayCardParams(@RequestParam("id") String id) {
gatewayCardParamsService.deleteGatewayCardParams(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得机床网关采集卡参数")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<GatewayCardParamsRespVO> getGatewayCardParams(@RequestParam("id") String id) {
GatewayCardParamsDO gatewayCardParams = gatewayCardParamsService.getGatewayCardParams(id);
return success(BeanUtils.toBean(gatewayCardParams, GatewayCardParamsRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得机床网关采集卡参数分页")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<PageResult<GatewayCardParamsRespVO>> getGatewayCardParamsPage(@Valid GatewayCardParamsPageReqVO pageReqVO) {
PageResult<GatewayCardParamsDO> pageResult = gatewayCardParamsService.getGatewayCardParamsPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, GatewayCardParamsRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出机床网关采集卡参数 Excel")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
@ApiAccessLog(operateType = EXPORT)
public void exportGatewayCardParamsExcel(@Valid GatewayCardParamsPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<GatewayCardParamsDO> list = gatewayCardParamsService.getGatewayCardParamsPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "机床网关采集卡参数.xls", "数据", GatewayCardParamsRespVO.class,
BeanUtils.toBean(list, GatewayCardParamsRespVO.class));
}
}

View File

@ -0,0 +1,32 @@
package com.inspur.module.system.controller.admin.gatewayinfo.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.inspur.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 机床网关采集卡分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class GatewayCardInfoPageReqVO extends PageParam {
@Schema(description = "网关id")
private String gatewayId;
@Schema(description = "机床设备id")
private String equipId;
@Schema(description = "采集卡类型")
private String cardType;
@Schema(description = "采集卡名称")
private String cardName;
@Schema(description = "采集卡与influxdb映射表名")
private String cardTableMapping;
@Schema(description = "采集卡消息类型")
private String msgType;
}

View File

@ -0,0 +1,41 @@
package com.inspur.module.system.controller.admin.gatewayinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 机床网关采集卡 Response VO")
@Data
@ExcelIgnoreUnannotated
public class GatewayCardInfoRespVO {
@Schema(description = "采集卡id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("采集卡id")
private String cardId;
@Schema(description = "网关id")
@ExcelProperty("网关id")
private String gatewayId;
@Schema(description = "机床设备id")
@ExcelProperty("机床设备id")
private String equipId;
@Schema(description = "采集卡类型")
@ExcelProperty("采集卡类型")
private String cardType;
@Schema(description = "采集卡名称")
@ExcelProperty("采集卡名称")
private String cardName;
@Schema(description = "采集卡与influxdb映射表名")
@ExcelProperty("采集卡与influxdb映射表名")
private String cardTableMapping;
@Schema(description = "采集卡消息类型")
@ExcelProperty("采集卡消息类型")
private String msgType;
}

View File

@ -0,0 +1,33 @@
package com.inspur.module.system.controller.admin.gatewayinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 机床网关采集卡新增/修改 Request VO")
@Data
public class GatewayCardInfoSaveReqVO {
@Schema(description = "采集卡id", requiredMode = Schema.RequiredMode.REQUIRED)
private String cardId;
@Schema(description = "网关id")
private String gatewayId;
@Schema(description = "机床设备id")
private String equipId;
@Schema(description = "采集卡类型")
private String cardType;
@Schema(description = "采集卡名称")
private String cardName;
@Schema(description = "采集卡与influxdb映射表名")
private String cardTableMapping;
@Schema(description = "采集卡消息类型")
private String msgType;
}

View File

@ -0,0 +1,29 @@
package com.inspur.module.system.controller.admin.gatewayinfo.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.inspur.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 机床网关采集卡参数分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class GatewayCardParamsPageReqVO extends PageParam {
@Schema(description = "机床设备id")
private String equipId;
@Schema(description = "网关id")
private String gatewayId;
@Schema(description = "所属采集卡id")
private String cardId;
@Schema(description = "通道名称")
private String channelName;
@Schema(description = "参数映射名称")
private String paramMappingName;
}

View File

@ -0,0 +1,37 @@
package com.inspur.module.system.controller.admin.gatewayinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 机床网关采集卡参数 Response VO")
@Data
@ExcelIgnoreUnannotated
public class GatewayCardParamsRespVO {
@Schema(description = "采集卡通道id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("采集卡通道id")
private String channelId;
@Schema(description = "机床设备id")
@ExcelProperty("机床设备id")
private String equipId;
@Schema(description = "网关id")
@ExcelProperty("网关id")
private String gatewayId;
@Schema(description = "所属采集卡id")
@ExcelProperty("所属采集卡id")
private String cardId;
@Schema(description = "通道名称")
@ExcelProperty("通道名称")
private String channelName;
@Schema(description = "参数映射名称")
@ExcelProperty("参数映射名称")
private String paramMappingName;
}

View File

@ -0,0 +1,30 @@
package com.inspur.module.system.controller.admin.gatewayinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 机床网关采集卡参数新增/修改 Request VO")
@Data
public class GatewayCardParamsSaveReqVO {
@Schema(description = "采集卡通道id", requiredMode = Schema.RequiredMode.REQUIRED)
private String channelId;
@Schema(description = "机床设备id")
private String equipId;
@Schema(description = "网关id")
private String gatewayId;
@Schema(description = "所属采集卡id")
private String cardId;
@Schema(description = "通道名称")
private String channelName;
@Schema(description = "参数映射名称")
private String paramMappingName;
}

View File

@ -0,0 +1,53 @@
package com.inspur.module.system.dal.dataobject.gatewayinfo;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
/**
* 机床网关采集卡 DO
*
* @author zjw
*/
@TableName("imt_gateway_card_info")
@KeySequence("imt_gateway_card_info_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GatewayCardInfoDO extends BaseDO {
/**
* 采集卡id
*/
@TableId(type = IdType.ASSIGN_UUID)
private String cardId;
/**
* 网关id
*/
private String gatewayId;
/**
* 机床设备id
*/
private String equipId;
/**
* 采集卡类型
*/
private String cardType;
/**
* 采集卡名称
*/
private String cardName;
/**
* 采集卡与influxdb映射表名
*/
private String cardTableMapping;
/**
* 采集卡消息类型
*/
private String msgType;
}

View File

@ -0,0 +1,49 @@
package com.inspur.module.system.dal.dataobject.gatewayinfo;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
/**
* 机床网关采集卡参数 DO
*
* @author 管理员
*/
@TableName("imt_gateway_card_params")
@KeySequence("imt_gateway_card_params_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GatewayCardParamsDO extends BaseDO {
/**
* 采集卡通道id
*/
@TableId(type = IdType.ASSIGN_UUID)
private String channelId;
/**
* 机床设备id
*/
private String equipId;
/**
* 网关id
*/
private String gatewayId;
/**
* 所属采集卡id
*/
private String cardId;
/**
* 通道名称
*/
private String channelName;
/**
* 参数映射名称
*/
private String paramMappingName;
}

View File

@ -0,0 +1,31 @@
package com.inspur.module.system.dal.mysql.gatewayinfo;
import java.util.*;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
import org.apache.ibatis.annotations.Mapper;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
/**
* 机床网关采集卡 Mapper
*
* @author zjw
*/
@Mapper
public interface GatewayCardInfoMapper extends BaseMapperX<GatewayCardInfoDO> {
default PageResult<GatewayCardInfoDO> selectPage(GatewayCardInfoPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<GatewayCardInfoDO>()
.eqIfPresent(GatewayCardInfoDO::getGatewayId, reqVO.getGatewayId())
.eqIfPresent(GatewayCardInfoDO::getEquipId, reqVO.getEquipId())
.eqIfPresent(GatewayCardInfoDO::getCardType, reqVO.getCardType())
.eqIfPresent(GatewayCardInfoDO::getCardName, reqVO.getCardName())
.eqIfPresent(GatewayCardInfoDO::getCardTableMapping, reqVO.getCardTableMapping())
.eqIfPresent(GatewayCardInfoDO::getMsgType, reqVO.getMsgType())
.orderByDesc(GatewayCardInfoDO::getCardId));
}
}

View File

@ -0,0 +1,30 @@
package com.inspur.module.system.dal.mysql.gatewayinfo;
import java.util.*;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO;
import org.apache.ibatis.annotations.Mapper;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
/**
* 机床网关采集卡参数 Mapper
*
* @author 管理员
*/
@Mapper
public interface GatewayCardParamsMapper extends BaseMapperX<GatewayCardParamsDO> {
default PageResult<GatewayCardParamsDO> selectPage(GatewayCardParamsPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<GatewayCardParamsDO>()
.eqIfPresent(GatewayCardParamsDO::getEquipId, reqVO.getEquipId())
.eqIfPresent(GatewayCardParamsDO::getGatewayId, reqVO.getGatewayId())
.eqIfPresent(GatewayCardParamsDO::getCardId, reqVO.getCardId())
.likeIfPresent(GatewayCardParamsDO::getChannelName, reqVO.getChannelName())
.likeIfPresent(GatewayCardParamsDO::getParamMappingName, reqVO.getParamMappingName())
.orderByDesc(GatewayCardParamsDO::getChannelId));
}
}

View File

@ -38,4 +38,9 @@ public interface GatewayInfoMapper extends BaseMapperX<GatewayInfoDO> {
* 根据id查询网关信息
*/
public GatewayInfoDO selectGatewayById(@Param("id") String id);
/**
* 根据网关编号查询网关信息
*/
public GatewayInfoDO selectGatewayByGatewayCode(@Param("gatewayCode") String gatewayCode);
}

View File

@ -0,0 +1,55 @@
package com.inspur.module.system.service.gatewayinfo;
import java.util.*;
import javax.validation.*;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
/**
* 机床网关采集卡 Service 接口
*
* @author zjw
*/
public interface GatewayCardInfoService {
/**
* 创建机床网关采集卡
*
* @param createReqVO 创建信息
* @return 编号
*/
String createGatewayCardInfo(@Valid GatewayCardInfoSaveReqVO createReqVO);
/**
* 更新机床网关采集卡
*
* @param updateReqVO 更新信息
*/
void updateGatewayCardInfo(@Valid GatewayCardInfoSaveReqVO updateReqVO);
/**
* 删除机床网关采集卡
*
* @param id 编号
*/
void deleteGatewayCardInfo(String id);
/**
* 获得机床网关采集卡
*
* @param id 编号
* @return 机床网关采集卡
*/
GatewayCardInfoDO getGatewayCardInfo(String id);
/**
* 获得机床网关采集卡分页
*
* @param pageReqVO 分页查询
* @return 机床网关采集卡分页
*/
PageResult<GatewayCardInfoDO> getGatewayCardInfoPage(GatewayCardInfoPageReqVO pageReqVO);
}

View File

@ -0,0 +1,74 @@
package com.inspur.module.system.service.gatewayinfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.util.object.BeanUtils;
import com.inspur.module.system.dal.mysql.gatewayinfo.GatewayCardInfoMapper;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.*;
/**
* 机床网关采集卡 Service 实现类
*
* @author zjw
*/
@Service
@Validated
public class GatewayCardInfoServiceImpl implements GatewayCardInfoService {
@Resource
private GatewayCardInfoMapper gatewayCardInfoMapper;
@Override
public String createGatewayCardInfo(GatewayCardInfoSaveReqVO createReqVO) {
// 插入
GatewayCardInfoDO gatewayCardInfo = BeanUtils.toBean(createReqVO, GatewayCardInfoDO.class);
gatewayCardInfoMapper.insert(gatewayCardInfo);
// 返回
return gatewayCardInfo.getGatewayId();
}
@Override
public void updateGatewayCardInfo(GatewayCardInfoSaveReqVO updateReqVO) {
// 校验存在
validateGatewayCardInfoExists(updateReqVO.getGatewayId());
// 更新
GatewayCardInfoDO updateObj = BeanUtils.toBean(updateReqVO, GatewayCardInfoDO.class);
gatewayCardInfoMapper.updateById(updateObj);
}
@Override
public void deleteGatewayCardInfo(String id) {
// 校验存在
validateGatewayCardInfoExists(id);
// 删除
gatewayCardInfoMapper.deleteById(id);
}
private void validateGatewayCardInfoExists(String id) {
if (gatewayCardInfoMapper.selectById(id) == null) {
throw exception(GATEWAY_CARD_INFO_NOT_EXISTS);
}
}
@Override
public GatewayCardInfoDO getGatewayCardInfo(String id) {
return gatewayCardInfoMapper.selectById(id);
}
@Override
public PageResult<GatewayCardInfoDO> getGatewayCardInfoPage(GatewayCardInfoPageReqVO pageReqVO) {
return gatewayCardInfoMapper.selectPage(pageReqVO);
}
}

View File

@ -0,0 +1,65 @@
package com.inspur.module.system.service.gatewayinfo;
import java.util.*;
import javax.validation.*;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
/**
* 机床网关采集卡参数 Service 接口
*
* @author 管理员
*/
public interface GatewayCardParamsService {
/**
* 创建机床网关采集卡参数
*
* @param createReqVO 创建信息
* @return 编号
*/
String createGatewayCardParams(@Valid GatewayCardParamsSaveReqVO createReqVO);
/**
* 批量更新机床网关采集卡参数
*/
boolean batchCreateGatewayCardParams(List<GatewayCardParamsSaveReqVO> paramsList);
/**
* 更新机床网关采集卡参数
*
* @param updateReqVO 更新信息
*/
void updateGatewayCardParams(@Valid GatewayCardParamsSaveReqVO updateReqVO);
/**
* 批量更新机床网关采集卡参数
*/
boolean batchUpdateGatewayCardParams(List<GatewayCardParamsSaveReqVO> paramsList);
/**
* 删除机床网关采集卡参数
*
* @param id 编号
*/
void deleteGatewayCardParams(String id);
/**
* 获得机床网关采集卡参数
*
* @param id 编号
* @return 机床网关采集卡参数
*/
GatewayCardParamsDO getGatewayCardParams(String id);
/**
* 获得机床网关采集卡参数分页
*
* @param pageReqVO 分页查询
* @return 机床网关采集卡参数分页
*/
PageResult<GatewayCardParamsDO> getGatewayCardParamsPage(GatewayCardParamsPageReqVO pageReqVO);
}

View File

@ -0,0 +1,97 @@
package com.inspur.module.system.service.gatewayinfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.util.object.BeanUtils;
import com.inspur.module.system.dal.mysql.gatewayinfo.GatewayCardParamsMapper;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.*;
/**
* 机床网关采集卡参数 Service 实现类
*
* @author 管理员
*/
@Service
@Validated
public class GatewayCardParamsServiceImpl implements GatewayCardParamsService {
@Resource
private GatewayCardParamsMapper gatewayCardParamsMapper;
@Override
public String createGatewayCardParams(GatewayCardParamsSaveReqVO createReqVO) {
// 插入
GatewayCardParamsDO gatewayCardParams = BeanUtils.toBean(createReqVO, GatewayCardParamsDO.class);
gatewayCardParamsMapper.insert(gatewayCardParams);
// 返回
return gatewayCardParams.getChannelId();
}
/**
* 批量更新机床网关采集卡参数
*/
@Override
public boolean batchCreateGatewayCardParams(List<GatewayCardParamsSaveReqVO> paramsList){
if(paramsList.isEmpty()){
return true;
}
List<GatewayCardParamsDO> gatewayCardParamsList = BeanUtils.toBean(paramsList, GatewayCardParamsDO.class);
return gatewayCardParamsMapper.insertBatch(gatewayCardParamsList);
}
@Override
public void updateGatewayCardParams(GatewayCardParamsSaveReqVO updateReqVO) {
// 校验存在
validateGatewayCardParamsExists(updateReqVO.getChannelId());
// 更新
GatewayCardParamsDO updateObj = BeanUtils.toBean(updateReqVO, GatewayCardParamsDO.class);
gatewayCardParamsMapper.updateById(updateObj);
}
/**
* 批量更新机床网关采集卡参数
*/
public boolean batchUpdateGatewayCardParams(List<GatewayCardParamsSaveReqVO> paramsList){
if (paramsList.isEmpty()){
return true;
}
List<GatewayCardParamsDO> gatewayCardParamsList = BeanUtils.toBean(paramsList, GatewayCardParamsDO.class);
return gatewayCardParamsMapper.updateBatch(gatewayCardParamsList);
}
@Override
public void deleteGatewayCardParams(String id) {
// 校验存在
validateGatewayCardParamsExists(id);
// 删除
gatewayCardParamsMapper.deleteById(id);
}
private void validateGatewayCardParamsExists(String id) {
if (gatewayCardParamsMapper.selectById(id) == null) {
throw exception(GATEWAY_CARD_PARAMS_NOT_EXISTS);
}
}
@Override
public GatewayCardParamsDO getGatewayCardParams(String id) {
return gatewayCardParamsMapper.selectById(id);
}
@Override
public PageResult<GatewayCardParamsDO> getGatewayCardParamsPage(GatewayCardParamsPageReqVO pageReqVO) {
return gatewayCardParamsMapper.selectPage(pageReqVO);
}
}

View File

@ -53,4 +53,8 @@ public interface GatewayInfoService {
*/
PageResult<GatewayInfoDO> getGatewayInfoPage(GatewayInfoPageReqVO pageReqVO);
/**
* 根据机床网关编号获取机床网关信息
*/
GatewayInfoDO getGatewayInfoByGatewayCode(String gatewayCode);
}

View File

@ -87,4 +87,13 @@ public class GatewayInfoServiceImpl implements GatewayInfoService {
return new PageResult<>(page.getRecords(), page.getTotal());
}
/**
* 根据机床网关编号获取机床网关信息
*/
@Override
@TenantIgnore
public GatewayInfoDO getGatewayInfoByGatewayCode(String gatewayCode){
return gatewayInfoMapper.selectGatewayByGatewayCode(gatewayCode);
}
}

View File

@ -44,10 +44,10 @@
where igi.gateway_id = #{id} and igi.deleted = '0'
</select>
<!-- <select id="selectAlarmDataByRulesId" parameterType="String" resultMap="AlarmDataResult">-->
<!-- <include refid="selectAlarmDataVo"/>-->
<!-- where ad.alarm_rules_id = #{alarmRulesId}-->
<!-- and ad.status = 0-->
<!-- and ad.deleted = '0'-->
<!-- </select>-->
<select id="selectGatewayByGatewayCode" parameterType="String" resultMap="GatewayInfoResult">
<include refid="selectGatewayInfoVo"/>
where igi.gateway_code = #{gatewayCode}
and igi.status = 0
and igi.deleted = '0'
</select>
</mapper>

View File

@ -315,12 +315,12 @@ imt:
customer: E77DF18BE109F454A5CD319E44BF5177
data:
mqtt:
host: tcp://47.105.46.242:1883
clientId: phm_zfipc
host: tcp://117.73.2.117:1883
clientId: imt
topics: printer/top/# #符号“#”是代表以 printer/top 开头的所有子主题
topic1: monitor_data #单个topic
userName: inspur
password: inspur
topic1: iipwg/jc #单个topic
userName: jc
password: Y123456a
timeOut: 10
keepAlive: 20
Qos: 1

View File

@ -14,7 +14,7 @@ VUE_CLI_BABEL_TRANSPILE_MODULES = true
VUE_APP_TENANT_ENABLE = true
# 验证码的开关
VUE_APP_CAPTCHA_ENABLE = true
VUE_APP_CAPTCHA_ENABLE = false
# 文档的开关
VUE_APP_DOC_ENABLE = true

View File

@ -14,7 +14,7 @@ VUE_CLI_BABEL_TRANSPILE_MODULES = true
VUE_APP_TENANT_ENABLE = true
# 验证码的开关
VUE_APP_CAPTCHA_ENABLE = true
VUE_APP_CAPTCHA_ENABLE = false
# 文档的开关
VUE_APP_DOC_ENABLE = true

View File

@ -16,7 +16,7 @@ VUE_APP_APP_NAME ='yudao-admin'
VUE_APP_TENANT_ENABLE = true
# 验证码的开关
VUE_APP_CAPTCHA_ENABLE = true
VUE_APP_CAPTCHA_ENABLE = false
# 文档的开关
VUE_APP_DOC_ENABLE = false

View File

@ -16,7 +16,7 @@ PUBLIC_PATH = 'http://static.yudao.iocoder.cn/'
VUE_APP_TENANT_ENABLE = true
# 验证码的开关
VUE_APP_CAPTCHA_ENABLE = true
VUE_APP_CAPTCHA_ENABLE = false
# 文档的开关
VUE_APP_DOC_ENABLE = false

View File

@ -0,0 +1,53 @@
import request from "@/utils/request";
// 创建机床网关采集卡
export function createGatewayCardInfo(data) {
return request({
url: "/imt/gateway-card-info/create",
method: "post",
data: data,
});
}
// 更新机床网关采集卡
export function updateGatewayCardInfo(data) {
return request({
url: "/imt/gateway-card-info/update",
method: "put",
data: data,
});
}
// 删除机床网关采集卡
export function deleteGatewayCardInfo(id) {
return request({
url: "/imt/gateway-card-info/delete?id=" + id,
method: "delete",
});
}
// 获得机床网关采集卡
export function getGatewayCardInfo(id) {
return request({
url: "/imt/gateway-card-info/get?id=" + id,
method: "get",
});
}
// 获得机床网关采集卡分页
export function getGatewayCardInfoPage(params) {
return request({
url: "/imt/gateway-card-info/page",
method: "get",
params,
});
}
// 导出机床网关采集卡 Excel
export function exportGatewayCardInfoExcel(params) {
return request({
url: "/imt/gateway-card-info/export-excel",
method: "get",
params,
responseType: "blob",
});
}

View File

@ -0,0 +1,62 @@
import request from "@/utils/request";
// 创建机床网关采集卡参数
export function createGatewayCardParams(data) {
return request({
url: "/imt/gateway-card-params/create",
method: "post",
data: data,
});
}
// 更新机床网关采集卡参数
export function updateGatewayCardParams(data) {
return request({
url: "/imt/gateway-card-params/update",
method: "put",
data: data,
});
}
//提交机床网关采集卡参数
export function submitGatewayCardParams(data) {
return request({
url: "/imt/gateway-card-params/submit",
method: "post",
data: data,
});
}
// 删除机床网关采集卡参数
export function deleteGatewayCardParams(id) {
return request({
url: "/imt/gateway-card-params/delete?id=" + id,
method: "delete",
});
}
// 获得机床网关采集卡参数
export function getGatewayCardParams(id) {
return request({
url: "/imt/gateway-card-params/get?id=" + id,
method: "get",
});
}
// 获得机床网关采集卡参数分页
export function getGatewayCardParamsPage(params) {
return request({
url: "/imt/gateway-card-params/page",
method: "get",
params,
});
}
// 导出机床网关采集卡参数 Excel
export function exportGatewayCardParamsExcel(params) {
return request({
url: "/imt/gateway-card-params/export-excel",
method: "get",
params,
responseType: "blob",
});
}

View File

@ -31,6 +31,8 @@ export const DICT_TYPE = {
FAULT_TYPE: "fault_type",
MAINTENANCE_RESULT_TYPE: "maintenance_result_type",
ALARM_TYPE: "equip_alarm_type",
CARD_TYPE: "card_type",
MSG_TYPE: "msg_type",
// ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX: "system_user_sex",
SYSTEM_MENU_TYPE: "system_menu_type",
@ -69,8 +71,8 @@ export const DICT_TYPE = {
BPM_PROCESS_INSTANCE_RESULT: "bpm_process_instance_result",
BPM_TASK_ASSIGN_SCRIPT: "bpm_task_assign_script",
BPM_OA_LEAVE_TYPE: "bpm_oa_leave_type",
BPM_TASK_CANDIDATE_STRATEGY: 'bpm_task_candidate_strategy',
BPM_TASK_STATUS: 'bpm_task_status',
BPM_TASK_CANDIDATE_STRATEGY: "bpm_task_candidate_strategy",
BPM_TASK_STATUS: "bpm_task_status",
// ========== PAY 模块 ==========
PAY_CHANNEL_WECHAT_VERSION: "pay_channel_wechat_version", // 微信渠道版本

View File

@ -0,0 +1,441 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="45%"
v-dialogDrag
append-to-body
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="100px"
>
<el-col :span="12">
<el-form-item
label="机床设备"
prop="equipId"
>
<span class="item-content">{{ this.gatewayInfo.customerName + "-" + this.gatewayInfo.modelName + "-" + this.gatewayInfo.equipNo }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="网关"
prop="gatewayId"
>
<span class="item-content">{{ this.gatewayInfo.gatewayName }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="采集卡类型"
prop="cardType"
>
<el-select
v-model="formData.cardType"
placeholder="请选择采集卡类型"
style="width:100%"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.CARD_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="采集卡名称"
prop="cardName"
>
<el-input
v-model="formData.cardName"
placeholder="请输入采集卡名称"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="映射表名"
prop="cardTableMapping"
>
<el-input
v-model="formData.cardTableMapping"
placeholder="请输入采集卡映射表名"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="消息类型"
prop="msgType"
>
<el-select
v-model="formData.msgType"
placeholder="请选择采集卡消息类型"
style="width:100%"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.MSG_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-form>
<div class="add-table">
<el-button
class="mb10"
size="mini"
type="primary"
@click="addTableRow"
> </el-button>
<el-form
:model="paramsForm"
ref="paramsForm"
:rules="paramsRules"
:inline="false"
size="small"
>
<el-table
:data="paramsForm.paramsList"
stripe
highlight-current-row
border
ref="addTableRowRef"
>
<el-table-column
type="index"
label="序号"
align="center"
width="50"
></el-table-column>
<el-table-column
prop="channelName"
label="通道名称"
align="center"
>
<template slot-scope="scope">
<el-form-item
:prop="'paramsList['+scope.$index+'].channelName'"
:rules="paramsRules.channelName"
>
<el-input v-model="scope.row.channelName" />
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="paramMappingName"
label="参数映射"
align="center"
>
<template slot-scope="scope">
<el-form-item
:prop="'paramsList['+scope.$index+'].paramMappingName'"
:rules="paramsRules.paramMappingName"
>
<el-input v-model="scope.row.paramMappingName" />
</el-form-item>
</template>
</el-table-column>
<!-- <el-table-column
align="center"
v-for="(item,index) in dataList"
:prop="item.code"
:label="item.name"
:key="index"
>
<template slot-scope="scope">
<el-input v-model="scope.row[item.code]"></el-input>
</template>
</el-table-column> -->
<el-table-column
label="操作"
width="120"
align="center"
>
<template slot-scope="scope">
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDeleteRow(scope.$index,paramsForm.paramsList)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</div>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
:disabled="formLoading"
> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as GatewayCardInfoApi from "@/api/system/gatewayinfo/card";
import * as GatewayCardParamsApi from "@/api/system/gatewayinfo/params";
export default {
name: "GatewayCardInfoForm",
components: {},
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
cardId: undefined,
gatewayId: undefined,
equipId: undefined,
cardType: undefined,
cardName: undefined,
cardTableMapping: undefined,
msgType: undefined,
},
//
formRules: {
cardType: [
{
required: true,
message: "网关采集卡类型不能为空",
trigger: "blur",
},
],
cardName: [
{
required: true,
message: "网关采集卡名称不能为空",
trigger: "blur",
},
{
max: 50,
message: "网关采集卡名称长度不能超过50个字符",
trigger: "blur",
},
],
cardTableMapping: [
{
required: true,
message: "映射表名不能为空",
trigger: "blur",
},
{
max: 60,
message: "映射表名长度不能超过60个字符",
trigger: "blur",
},
],
msgType: [
{
required: true,
message: "消息类型不能为空",
trigger: "blur",
},
],
paramsList: {
channelName: [
{
required: true,
message: "通道名称不能为空",
trigger: "blur",
},
{
max: 30,
message: "通道名称长度不能超过30个字符",
trigger: "blur",
},
],
paramMappingName: [
{
required: true,
message: "参数映射名称不能为空",
trigger: "blur",
},
{
max: 50,
message: "参数映射名称长度不能超过50个字符",
trigger: "blur",
},
],
},
},
//
paramsRules: {
channelName: [
{
required: true,
message: "通道名称不能为空",
trigger: "blur",
},
{
max: 30,
message: "通道名称长度不能超过30个字符",
trigger: "blur",
},
],
paramMappingName: [
{
required: true,
message: "参数映射名称不能为空",
trigger: "blur",
},
{
max: 50,
message: "参数映射名称长度不能超过50个字符",
trigger: "blur",
},
],
},
gatewayInfo: {},
dataList: [],
paramsForm: {
paramsList: [],
},
};
},
methods: {
addTableRow() {
var addObj = {
channelName: "",
paramMappingName: "",
};
// this.dataList.forEach((el) => {
// addObj[el.code] = "";
// });
this.paramsForm.paramsList.push(addObj);
// this.paramsList.push(this.rowObj);
setTimeout(() => {
this.$refs.addTableRowRef.setCurrentRow(addObj);
}, 10);
},
handleDeleteRow(index, rows) {
//
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
if (rows[index].id) {
//
}
rows.splice(index, 1);
this.$message({
type: "success",
message: "删除成功!",
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
/** 打开弹窗 */
async open(id, row, expandRow) {
this.dialogVisible = true;
this.reset();
//
this.formData.equipId = row.equipId;
this.formData.gatewayId = row.gatewayId;
this.gatewayInfo = row;
//
if (id) {
this.gatewayInfo = expandRow;
this.formLoading = true;
try {
const res = await GatewayCardInfoApi.getGatewayCardInfo(id);
this.formData = res.data;
this.dialogTitle = "修改机床网关采集卡信息";
} finally {
this.formLoading = false;
}
}
this.dialogTitle = "新增机床网关采集卡信息";
},
/** 提交按钮 */
async submitForm() {
console.log("paramsList", this.paramsList);
//
await this.$refs["formRef"].validate();
await this.$refs["paramsForm"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.cardId) {
await GatewayCardInfoApi.updateGatewayCardInfo(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit("success");
return;
}
//
const cardInfo = await GatewayCardInfoApi.createGatewayCardInfo(data);
const cardId = cardInfo.data;
//
if (this.paramsForm.paramsList) {
this.paramsForm.paramsList.forEach((e) => {
e.equipId = this.formData.equipId;
e.gatewayId = this.formData.gatewayId;
e.cardId = cardId;
});
await GatewayCardParamsApi.submitGatewayCardParams(
this.paramsForm.paramsList
);
}
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit("success");
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
cardId: undefined,
gatewayId: undefined,
equipId: undefined,
cardType: undefined,
cardName: undefined,
cardTableMapping: undefined,
msgType: undefined,
};
(this.paramsForm = {
paramsList: [],
}),
this.resetForm("formRef");
},
},
};
</script>
<style scoped>
.item-content {
color: yellowgreen;
}
</style>

View File

@ -4,7 +4,7 @@
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="45%"
width="50%"
v-dialogDrag
append-to-body
>
@ -37,6 +37,37 @@
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="网关所属设备"
prop="equipId"
label-width="110px"
>
<!-- <el-input
v-model="formData.equipId"
placeholder="请输入网关生产厂商"
/> -->
<el-cascader
v-model="formData.equipId"
:options="equipCascader"
:props="{ value: 'id',label: 'name',children: 'children'}"
clearable
@change="cascaderChange"
style="width:100%"
></el-cascader>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="网关编号"
prop="gatewayCode"
>
<el-input
v-model="formData.gatewayCode"
placeholder="请输入网关编号"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="网关生产厂商"
@ -150,6 +181,7 @@
<script>
import * as GatewayInfoApi from "@/api/system/gatewayinfo/gatewayinfo";
import ImageUpload from "@/components/ImageUpload";
import { getEquipCascader } from "@/api/system/equip/equipInfo";
export default {
name: "GatewayInfoForm",
components: {
@ -181,14 +213,62 @@ export default {
formRules: {
gatewayName: [
{ required: true, message: "机床网关名称不能为空", trigger: "blur" },
{
max: 30,
message: "机床网关名称长度不能超过25个字符",
trigger: "blur",
},
],
gatewayModel: [
{ required: true, message: "机床网关名称不能为空", trigger: "blur" },
{ required: true, message: "机床网关型号不能为空", trigger: "blur" },
{
max: 30,
message: "机床网关型号长度不能超过30个字符",
trigger: "blur",
},
],
equipId: [
{
required: true,
message: "机床网关所属设备不能为空",
trigger: "blur",
},
],
gatewayCode: [
{ required: true, message: "机床网关编号不能为空", trigger: "blur" },
{
max: 30,
message: "机床网关编号长度不能超过30个字符",
trigger: "blur",
},
],
},
equipCascader: [],
cascaderValue: [],
};
},
created() {
this.getEquipList();
},
methods: {
cascaderChange(value) {
if (value.length > 0) {
this.formData.equipId = value[1];
} else {
this.formData.equipId = null;
}
},
getEquipList() {
getEquipCascader().then((res) => {
// console.log("equip:", res);
res.forEach((item) => {
if (item.children == null) {
item.disabled = true;
}
});
this.equipCascader = res;
});
},
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;

View File

@ -101,7 +101,102 @@
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
@expand-change="tableExpandChange"
>
<el-table-column
type="expand"
align="center"
>
<template slot-scope="scope">
<el-card>
<!-- 操作工具栏 -->
<el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<!-- <el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="addTableRow(scope.row)"
v-hasPermi="['imt:gateway-info:create']"
>新增采集卡及参数</el-button> -->
<span style="font-weight:700;font-size:18px">{{ scope.row.gatewayName + "采集卡信息" }}</span>
</el-col>
</el-row>
<el-table
v-loading="cardLoading"
:data="cardList"
>
<el-table-column
label="序号"
type="index"
align="center"
/>
<el-table-column
label="采集卡名称"
prop="cardName"
align="center"
/>
<el-table-column
label="采集卡型号"
prop="cardType"
align="center"
/>
<el-table-column
label="采集卡映射表名"
prop="cardTableMapping"
align="center"
/>
<el-table-column
label="消息类型"
prop="msgType"
align="center"
/>
<el-table-column
label="操作"
width="120"
align="center"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="openCardForm(scope.row.cardId,scope.row)"
v-hasPermi="['imt:gateway-info:create']"
>修改</el-button>
</template>
</el-table-column>
</el-table>
<pagination
:hide-on-single-page="true"
:total="cardTotal"
:page.sync="cardQueryParams.pageNo"
:limit.sync="cardQueryParams.pageSize"
@pagination="getCardList(scope.row.gatewayId)"
/>
</el-card>
</template>
</el-table-column>
<el-table-column
label="客户名"
align="center"
prop="customerName"
/>
<el-table-column
label="设备型号"
align="center"
prop="modelName"
/>
<el-table-column
label="设备编号"
align="center"
prop="equipNo"
/>
<el-table-column
label="机床网关名称"
align="center"
@ -154,7 +249,7 @@
align="center"
prop="remark"
/>
<el-table-column
<!-- <el-table-column
label="网关图片路径"
align="center"
prop="gatewayPicPath"
@ -165,13 +260,20 @@
style="display: block; width: 100px; height: 100px; margin: 0 auto"
/>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="openCardForm(null,scope.row)"
v-hasPermi="['imt:gateway-info:create']"
>新增采集卡</el-button>
<el-button
size="mini"
type="text"
@ -202,16 +304,25 @@
ref="formRef"
@success="getList"
/>
<!--新增网关采集卡信息-->
<GatewayCardForm
ref="cardFormRef"
@success="getList"
/>
</div>
</template>
<script>
import * as GatewayInfoApi from "@/api/system/gatewayinfo/gatewayinfo";
import * as GatewayCardInfoApi from "@/api/system/gatewayinfo/card";
import * as GatewayCardParamsApi from "@/api/system/gatewayinfo/params";
import GatewayInfoForm from "./GatewayInfoForm.vue";
import GatewayCardForm from "./GatewayCardForm.vue";
export default {
name: "GatewayInfo",
components: {
GatewayInfoForm,
GatewayCardForm,
},
data() {
return {
@ -223,6 +334,7 @@ export default {
showSearch: true,
//
total: 0,
cardTotal: 0,
//
list: [],
//
@ -239,12 +351,53 @@ export default {
gatewayModel: null,
status: null,
},
cardQueryParams: {
pageNo: 1,
pageSize: 10,
gatewayId: null,
},
cardList: [
{
cardName: "iipzbc18jc00p0003ka1",
cardType: "JCka1",
cardTableMapping: "current",
msgType: "POST_TELEMETRY_REQUEST",
},
],
cardLoading: false,
expandGateway: {},
};
},
created() {
this.getList();
},
methods: {
tableExpandChange(row, e) {
if (e.length != 0) {
console.log("展开数据:", row);
console.log("展开数据e", e);
this.expandGateway = row;
this.cardLoading = true;
//
this.getCardList(row.gatewayId);
}
},
async getCardList(id) {
try {
this.cardQueryParams.gatewayId = id;
this.cardLoading = true;
const res = await GatewayCardInfoApi.getGatewayCardInfoPage(
this.cardQueryParams
);
this.cardList = res.data.list;
this.cardTotal = res.data.total;
} finally {
this.cardLoading = false;
}
},
openCardForm(id, row) {
this.$refs["cardFormRef"].open(id, row, this.expandGateway);
},
/** 查询列表 */
async getList() {
try {