数据接口与网关管理功能

This commit is contained in:
zhangjunwen 2024-08-29 17:52:31 +08:00
parent 9d0e13cdf8
commit f31fac25e3
16 changed files with 656 additions and 53 deletions

View File

@ -2,9 +2,12 @@ package com.inspur.framework.common.util.date;
import cn.hutool.core.date.LocalDateTimeUtil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
* 时间工具类
@ -146,4 +149,12 @@ public class DateUtils {
return LocalDateTimeUtil.isSameDay(date, LocalDateTime.now().minusDays(1));
}
public static String tranUTC2LocalDateTime(String utcTimeString) throws ParseException {
SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置UTC时区
Date utcDate = utcFormat.parse(utcTimeString); // 解析UTC时间
SimpleDateFormat localFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
localFormat.setTimeZone(TimeZone.getDefault()); // 设置为系统默认时区
return localFormat.format(utcDate); // 转换为系统时区时间
}
}

View File

@ -21,47 +21,41 @@ public class BannerApplicationRunner implements ApplicationRunner {
ThreadUtil.execute(() -> {
ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 保证输出到结尾
log.info("\n----------------------------------------------------------\n\t" +
"项目启动成功!\n\t" +
"接口文档: \t{} \n\t" +
"开发文档: \t{} \n\t" +
"视频教程: \t{} \n" +
"----------------------------------------------------------",
"https://doc.iocoder.cn/api-doc/",
"https://doc.iocoder.cn",
"https://t.zsxq.com/02Yf6M7Qn");
"智能机床系统" + "项目启动成功!" +
"\n----------------------------------------------------------");
// 数据报表
if (isNotPresent("com.inspur.module.report.framework.security.config.SecurityConfiguration")) {
System.out.println("[报表模块 imt-module-report - 已禁用][参考 https://doc.iocoder.cn/report/ 开启]");
}
// 工作流
if (isNotPresent("com.inspur.module.bpm.framework.flowable.config.BpmFlowableConfiguration")) {
System.out.println("[工作流模块 imt-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
}
// 商城系统
if (isNotPresent("com.inspur.module.trade.framework.web.config.TradeWebConfiguration")) {
System.out.println("[商城系统 imt-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]");
}
// ERP 系统
if (isNotPresent("com.inspur.module.erp.framework.web.config.ErpWebConfiguration")) {
System.out.println("[ERP 系统 imt-module-erp - 已禁用][参考 https://doc.iocoder.cn/erp/build/ 开启]");
}
// CRM 系统
if (isNotPresent("com.inspur.module.crm.framework.web.config.CrmWebConfiguration")) {
System.out.println("[CRM 系统 imt-module-crm - 已禁用][参考 https://doc.iocoder.cn/crm/build/ 开启]");
}
// 微信公众号
if (isNotPresent("com.inspur.module.mp.framework.mp.config.MpConfiguration")) {
System.out.println("[微信公众号 imt-module-mp - 已禁用][参考 https://doc.iocoder.cn/mp/build/ 开启]");
}
// 支付平台
if (isNotPresent("com.inspur.module.pay.framework.pay.config.PayConfiguration")) {
System.out.println("[支付系统 imt-module-pay - 已禁用][参考 https://doc.iocoder.cn/pay/build/ 开启]");
}
// AI 大模型
if (isNotPresent("com.inspur.module.ai.framework.web.config.AiWebConfiguration")) {
System.out.println("[AI 大模型 imt-module-ai - 已禁用][参考 https://doc.iocoder.cn/ai/build/ 开启]");
}
// if (isNotPresent("com.inspur.module.report.framework.security.config.SecurityConfiguration")) {
// System.out.println("[报表模块 imt-module-report - 已禁用][参考 https://doc.iocoder.cn/report/ 开启]");
// }
// // 工作流
// if (isNotPresent("com.inspur.module.bpm.framework.flowable.config.BpmFlowableConfiguration")) {
// System.out.println("[工作流模块 imt-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
// }
// // 商城系统
// if (isNotPresent("com.inspur.module.trade.framework.web.config.TradeWebConfiguration")) {
// System.out.println("[商城系统 imt-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]");
// }
// // ERP 系统
// if (isNotPresent("com.inspur.module.erp.framework.web.config.ErpWebConfiguration")) {
// System.out.println("[ERP 系统 imt-module-erp - 已禁用][参考 https://doc.iocoder.cn/erp/build/ 开启]");
// }
// // CRM 系统
// if (isNotPresent("com.inspur.module.crm.framework.web.config.CrmWebConfiguration")) {
// System.out.println("[CRM 系统 imt-module-crm - 已禁用][参考 https://doc.iocoder.cn/crm/build/ 开启]");
// }
// // 微信公众号
// if (isNotPresent("com.inspur.module.mp.framework.mp.config.MpConfiguration")) {
// System.out.println("[微信公众号 imt-module-mp - 已禁用][参考 https://doc.iocoder.cn/mp/build/ 开启]");
// }
// // 支付平台
// if (isNotPresent("com.inspur.module.pay.framework.pay.config.PayConfiguration")) {
// System.out.println("[支付系统 imt-module-pay - 已禁用][参考 https://doc.iocoder.cn/pay/build/ 开启]");
// }
// // AI 大模型
// if (isNotPresent("com.inspur.module.ai.framework.web.config.AiWebConfiguration")) {
// System.out.println("[AI 大模型 imt-module-ai - 已禁用][参考 https://doc.iocoder.cn/ai/build/ 开启]");
// }
});
}

View File

@ -1,17 +1,10 @@
芋道源码 http://www.iocoder.cn
Application Version: ${imt.info.version}
Spring Boot Version: ${spring-boot.version}
___ __ __ _____
|_ _| | \/ | |_ _|
| | | |\/| | | |
|___| |_|__|_| _|_|_
_|"""""|_|"""""|_|"""""|
"`-0-0-'"`-0-0-'"`-0-0-'
***************智能机床系统启动中***************
.__ __. ______ .______ __ __ _______
| \ | | / __ \ | _ \ | | | | / _____|
| \| | | | | | | |_) | | | | | | | __
| . ` | | | | | | _ < | | | | | | |_ |
| |\ | | `--' | | |_) | | `--' | | |__| |
|__| \__| \______/ |______/ \______/ \______|
███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
████╗ ██║██╔═══██╗ ██╔══██╗██║ ██║██╔════╝
██╔██╗ ██║██║ ██║ ██████╔╝██║ ██║██║ ███╗
██║╚██╗██║██║ ██║ ██╔══██╗██║ ██║██║ ██║
██║ ╚████║╚██████╔╝ ██████╔╝╚██████╔╝╚██████╔╝
╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝

View File

@ -0,0 +1,44 @@
package com.inspur.module.data.controller.admin.query;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.module.data.service.IDataQueryService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import static com.inspur.framework.common.pojo.CommonResult.success;
/**
* 数据查询控制器
* @Author zhangjunwen
* @create 2024/8/29
*/
@RestController
@RequestMapping("/data/query")
public class DataQueryController {
@Resource
private IDataQueryService dataQueryService;
@GetMapping("/list")
@Operation(summary = "获取/查询网关数据列表")
@PreAuthorize("@ss.hasPermission('data:query:list')")
public CommonResult<Map<String, Object>> getData(String equipId, String startTime, String endTime, Integer pageSize, Integer pageNum){
Map<String,Object> resMap = new HashMap<>();
try {
resMap = dataQueryService.selectDataListByPages(equipId,startTime,endTime,pageSize,pageNum);
} catch (ParseException e) {
e.printStackTrace();
return CommonResult.error(800,"时间格式错误");
}
return success(resMap);
}
}

View File

@ -0,0 +1,70 @@
package com.inspur.module.data.service;
import com.inspur.framework.common.util.date.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author zhangjunwen
* @create 2024/8/28
*/
@Service
@Validated
@Slf4j
public class DataQueryService implements IDataQueryService{
@Autowired
private InfluxDBService influxDBService;
@Override
public Map<String, Object> selectDataListByPages(String equipId,String startTime,String endTime, Integer pageSize, Integer pageNum) throws ParseException {
Map<String, Object> resMap = new HashMap<>();
//TODO 分页查找条数根据设备id表名时间范围页码每页条数
List<Map<String, Object>> dataList = queryDataByTime("data", equipId, startTime, endTime, pageNum, pageSize);
//TODO 时间需要将查询到的UTC时间转为系统时间北京时间
DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z");
//TODO 查询数据总条数
long total = countDataList("data", "value", equipId, startTime, endTime);
resMap.put("data", dataList);
resMap.put("total", total);
return resMap;
}
private List<Map<String, Object>> queryDataByTime(String tableName, String equipId, String beginTime, String endTime, Integer pageNum, Integer pageSize) {
StringBuilder sql = new StringBuilder("select * from ")
.append("\"").append(tableName).append("\"")
.append(" where equip_id = '").append(equipId).append("'");
if(beginTime != null){
sql.append(" and time >= '").append(beginTime).append("'");
}
if(endTime != null){
sql.append(" and time <= '").append(endTime).append("'");
}
sql.append(" order by time desc ")
.append(" limit ").append(pageSize)
.append(" offset ").append((pageNum - 1) * pageSize);
// .append(" tz('Asia/Shanghai')");
return influxDBService.queryResultProcess(influxDBService.query(sql.toString()));
}
private long countDataList(String tableName,String field, String equipId, String beginTime, String endTime){
StringBuilder sql = new StringBuilder("select count(").append(field).append(") from ")
.append("\"").append(tableName).append("\"")
.append(" where equip_id = '").append(equipId).append("'");
if(beginTime != null){
sql.append(" and time >= '").append(beginTime).append("'");
}
if(endTime != null){
sql.append(" and time <= '").append(endTime).append("'");
}
return influxDBService.countResultProcess(influxDBService.query(sql.toString()));
}
}

View File

@ -0,0 +1,20 @@
package com.inspur.module.data.service;
import java.text.ParseException;
import java.util.Map;
/**
* 数据查询服务接口
* @Author zhangjunwen
* @create 2024/8/28
*/
public interface IDataQueryService {
/**
* 分页查询数据
* @param pageSize 每页大小
* @param pageNum 当前页码
*/
Map<String, Object> selectDataListByPages(String equipId,String startTime,String endTime,Integer pageSize,Integer pageNum) throws ParseException;
}

View File

@ -167,4 +167,6 @@ public interface ErrorCodeConstants {
ErrorCode CUSTOMER_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床客户信息");
ErrorCode EQUIP_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床信息");
// ========== 设备管理模块 ==========
ErrorCode GATEWAY_INFO_NOT_EXISTS = new ErrorCode(1_002_029_000, "机床网关信息不存在");
}

View File

@ -0,0 +1,99 @@
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.GatewayInfoDO;
import com.inspur.module.system.service.gatewayinfo.GatewayInfoService;
@Tag(name = "管理后台 - 机床网关信息")
@RestController
@RequestMapping("/imt/gateway-info")
@Validated
public class GatewayInfoController {
@Resource
private GatewayInfoService gatewayInfoService;
@PostMapping("/create")
@Operation(summary = "创建机床网关信息")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:create')")
public CommonResult<String> createGatewayInfo(@Valid @RequestBody GatewayInfoSaveReqVO createReqVO) {
return success(gatewayInfoService.createGatewayInfo(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新机床网关信息")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:update')")
public CommonResult<Boolean> updateGatewayInfo(@Valid @RequestBody GatewayInfoSaveReqVO updateReqVO) {
gatewayInfoService.updateGatewayInfo(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床网关信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:gateway-info:delete')")
public CommonResult<Boolean> deleteGatewayInfo(@RequestParam("id") String id) {
gatewayInfoService.deleteGatewayInfo(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得机床网关信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:query')")
public CommonResult<GatewayInfoRespVO> getGatewayInfo(@RequestParam("id") String id) {
GatewayInfoDO gatewayInfo = gatewayInfoService.getGatewayInfo(id);
return success(BeanUtils.toBean(gatewayInfo, GatewayInfoRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得机床网关信息分页")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:query')")
public CommonResult<PageResult<GatewayInfoRespVO>> getGatewayInfoPage(@Valid GatewayInfoPageReqVO pageReqVO) {
PageResult<GatewayInfoDO> pageResult = gatewayInfoService.getGatewayInfoPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, GatewayInfoRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出机床网关信息 Excel")
@PreAuthorize("@ss.hasPermission('imt:gateway-info:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportGatewayInfoExcel(@Valid GatewayInfoPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<GatewayInfoDO> list = gatewayInfoService.getGatewayInfoPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "机床网关信息.xls", "数据", GatewayInfoRespVO.class,
BeanUtils.toBean(list, GatewayInfoRespVO.class));
}
}

View File

@ -0,0 +1,23 @@
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 GatewayInfoPageReqVO extends PageParam {
@Schema(description = "机床网关名称", example = "李四")
private String gatewayName;
@Schema(description = "机床网关型号")
private String gatewayModel;
@Schema(description = "状态0正常1异常2停机", example = "2")
private Integer status;
}

View File

@ -0,0 +1,62 @@
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.*;
import com.inspur.framework.excel.core.annotations.DictFormat;
import com.inspur.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 机床网关信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class GatewayInfoRespVO {
@Schema(description = "机床网关id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11429")
@ExcelProperty("机床网关id")
private String gatewayId;
@Schema(description = "机床网关名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@ExcelProperty("机床网关名称")
private String gatewayName;
@Schema(description = "机床网关型号")
@ExcelProperty("机床网关型号")
private String gatewayModel;
@Schema(description = "机床网关生产厂商")
@ExcelProperty("机床网关生产厂商")
private String gatewayMfg;
@Schema(description = "机床网关位置")
@ExcelProperty("机床网关位置")
private String gatewayLocation;
@Schema(description = "固件版本")
@ExcelProperty("固件版本")
private String firmwareVersion;
@Schema(description = "ip地址")
@ExcelProperty("ip地址")
private String ipAddress;
@Schema(description = "规格参数")
@ExcelProperty("规格参数")
private String gatewaySpn;
@Schema(description = "状态0正常1异常2停机", example = "2")
@ExcelProperty(value = "状态0正常1异常2停机", converter = DictConvert.class)
@DictFormat("gateway_status") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer status;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "网关图片路径")
@ExcelProperty("网关图片路径")
private String gatewayPicPath;
}

View File

@ -0,0 +1,47 @@
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 GatewayInfoSaveReqVO {
@Schema(description = "机床网关id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11429")
private String gatewayId;
@Schema(description = "机床网关名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotEmpty(message = "机床网关名称不能为空")
private String gatewayName;
@Schema(description = "机床网关型号")
private String gatewayModel;
@Schema(description = "机床网关生产厂商")
private String gatewayMfg;
@Schema(description = "机床网关位置")
private String gatewayLocation;
@Schema(description = "固件版本")
private String firmwareVersion;
@Schema(description = "ip地址")
private String ipAddress;
@Schema(description = "规格参数")
private String gatewaySpn;
@Schema(description = "状态0正常1异常2停机", example = "2")
private Integer status;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "网关图片路径")
private String gatewayPicPath;
}

View File

@ -0,0 +1,70 @@
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_info")
@KeySequence("imt_gateway_info_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GatewayInfoDO extends BaseDO {
/**
* 机床网关id
*/
@TableId(type = IdType.ASSIGN_UUID)
private String gatewayId;
/**
* 机床网关名称
*/
private String gatewayName;
/**
* 机床网关型号
*/
private String gatewayModel;
/**
* 机床网关生产厂商
*/
private String gatewayMfg;
/**
* 机床网关位置
*/
private String gatewayLocation;
/**
* 固件版本
*/
private String firmwareVersion;
/**
* ip地址
*/
private String ipAddress;
/**
* 规格参数
*/
private String gatewaySpn;
/**
* 状态0正常1异常2停机
* <p>
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 网关图片路径
*/
private String gatewayPicPath;
}

View File

@ -0,0 +1,28 @@
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.GatewayInfoDO;
import org.apache.ibatis.annotations.Mapper;
import com.inspur.module.system.controller.admin.gatewayinfo.vo.*;
/**
* 机床网关信息 Mapper
*
* @author zjw
*/
@Mapper
public interface GatewayInfoMapper extends BaseMapperX<GatewayInfoDO> {
default PageResult<GatewayInfoDO> selectPage(GatewayInfoPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<GatewayInfoDO>()
.likeIfPresent(GatewayInfoDO::getGatewayName, reqVO.getGatewayName())
.eqIfPresent(GatewayInfoDO::getGatewayModel, reqVO.getGatewayModel())
.eqIfPresent(GatewayInfoDO::getStatus, reqVO.getStatus())
.orderByDesc(GatewayInfoDO::getGatewayId));
}
}

View File

@ -0,0 +1,56 @@
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.GatewayInfoDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
/**
* 机床网关信息 Service 接口
*
* @author zjw
*/
public interface GatewayInfoService {
/**
* 创建机床网关信息
*
* @param createReqVO 创建信息
* @return 编号
*/
String createGatewayInfo(@Valid GatewayInfoSaveReqVO createReqVO);
/**
* 更新机床网关信息
*
* @param updateReqVO 更新信息
*/
void updateGatewayInfo(@Valid GatewayInfoSaveReqVO updateReqVO);
/**
* 删除机床网关信息
*
* @param id 编号
*/
void deleteGatewayInfo(String id);
/**
* 获得机床网关信息
*
* @param id 编号
* @return 机床网关信息
*/
GatewayInfoDO getGatewayInfo(String id);
/**
* 获得机床网关信息分页
*
* @param pageReqVO 分页查询
* @return 机床网关信息分页
*/
PageResult<GatewayInfoDO> getGatewayInfoPage(GatewayInfoPageReqVO pageReqVO);
}

View File

@ -0,0 +1,81 @@
package com.inspur.module.system.service.gatewayinfo;
import com.inspur.framework.tenant.core.aop.TenantIgnore;
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.GatewayInfoDO;
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.GatewayInfoMapper;
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 GatewayInfoServiceImpl implements GatewayInfoService {
@Resource
private GatewayInfoMapper gatewayInfoMapper;
@Override
public String createGatewayInfo(GatewayInfoSaveReqVO createReqVO) {
createReqVO.setStatus(0);//默认正常
// 插入
GatewayInfoDO gatewayInfo = BeanUtils.toBean(createReqVO, GatewayInfoDO.class);
gatewayInfoMapper.insert(gatewayInfo);
// 返回
return gatewayInfo.getGatewayId();
}
@Override
public void updateGatewayInfo(GatewayInfoSaveReqVO updateReqVO) {
// 校验存在
validateGatewayInfoExists(updateReqVO.getGatewayId());
// 更新
GatewayInfoDO updateObj = BeanUtils.toBean(updateReqVO, GatewayInfoDO.class);
gatewayInfoMapper.updateById(updateObj);
}
@Override
public void deleteGatewayInfo(String id) {
// 校验存在
validateGatewayInfoExists(id);
// 删除
gatewayInfoMapper.deleteById(id);
}
private void validateGatewayInfoExists(String id) {
if (gatewayInfoMapper.selectById(id) == null) {
throw exception(GATEWAY_INFO_NOT_EXISTS);
}
}
@Override
@TenantIgnore
public GatewayInfoDO getGatewayInfo(String id) {
return gatewayInfoMapper.selectById(id);
}
@Override
@TenantIgnore
public PageResult<GatewayInfoDO> getGatewayInfoPage(GatewayInfoPageReqVO pageReqVO) {
return gatewayInfoMapper.selectPage(pageReqVO);
}
}

View File

@ -11,6 +11,9 @@ export const DICT_TYPE = {
TERMINAL: 'terminal',
//========== imt 模块 ==========
MACHINE_TYPE: "machine_type",
INDUSTRY_TYPE: "industry_type",
GATEWAY_STATUS: "gateway_status",
MACHINE_TYPE: 'machine_type',
INDUSTRY_TYPE: 'industry_type',
EQUIP_STATUS: 'equip_status',