From f31fac25e399b50c6b41d6c47930b098c0f8471f Mon Sep 17 00:00:00 2001 From: zhangjunwen Date: Thu, 29 Aug 2024 17:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E4=B8=8E?= =?UTF-8?q?=E7=BD=91=E5=85=B3=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/common/util/date/DateUtils.java | 11 +++ .../banner/core/BannerApplicationRunner.java | 72 +++++++------- .../src/main/resources/banner.txt | 21 ++-- .../admin/query/DataQueryController.java | 44 +++++++++ .../module/data/service/DataQueryService.java | 70 +++++++++++++ .../data/service/IDataQueryService.java | 20 ++++ .../system/enums/ErrorCodeConstants.java | 2 + .../gatewayinfo/GatewayInfoController.java | 99 +++++++++++++++++++ .../gatewayinfo/vo/GatewayInfoPageReqVO.java | 23 +++++ .../gatewayinfo/vo/GatewayInfoRespVO.java | 62 ++++++++++++ .../gatewayinfo/vo/GatewayInfoSaveReqVO.java | 47 +++++++++ .../dataobject/gatewayinfo/GatewayInfoDO.java | 70 +++++++++++++ .../mysql/gatewayinfo/GatewayInfoMapper.java | 28 ++++++ .../gatewayinfo/GatewayInfoService.java | 56 +++++++++++ .../gatewayinfo/GatewayInfoServiceImpl.java | 81 +++++++++++++++ imt-ui/src/utils/dict.js | 3 + 16 files changed, 656 insertions(+), 53 deletions(-) create mode 100644 imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java create mode 100644 imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java create mode 100644 imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayInfoController.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoPageReqVO.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoRespVO.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/gatewayinfo/GatewayInfoMapper.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoService.java create mode 100644 imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java diff --git a/imt-server/imt-framework/imt-common/src/main/java/com/inspur/framework/common/util/date/DateUtils.java b/imt-server/imt-framework/imt-common/src/main/java/com/inspur/framework/common/util/date/DateUtils.java index ded7c33..1de7c19 100644 --- a/imt-server/imt-framework/imt-common/src/main/java/com/inspur/framework/common/util/date/DateUtils.java +++ b/imt-server/imt-framework/imt-common/src/main/java/com/inspur/framework/common/util/date/DateUtils.java @@ -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); // 转换为系统时区时间 + } } diff --git a/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/java/com/inspur/framework/banner/core/BannerApplicationRunner.java b/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/java/com/inspur/framework/banner/core/BannerApplicationRunner.java index 510e21f..b90fc67 100644 --- a/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/java/com/inspur/framework/banner/core/BannerApplicationRunner.java +++ b/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/java/com/inspur/framework/banner/core/BannerApplicationRunner.java @@ -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/ 开启]"); +// } }); } diff --git a/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/resources/banner.txt b/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/resources/banner.txt index f76dc07..77d03f3 100644 --- a/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/resources/banner.txt +++ b/imt-server/imt-framework/imt-spring-boot-starter-web/src/main/resources/banner.txt @@ -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-' +***************智能机床系统启动中*************** -.__ __. ______ .______ __ __ _______ -| \ | | / __ \ | _ \ | | | | / _____| -| \| | | | | | | |_) | | | | | | | __ -| . ` | | | | | | _ < | | | | | | |_ | -| |\ | | `--' | | |_) | | `--' | | |__| | -|__| \__| \______/ |______/ \______/ \______| - -███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ -████╗ ██║██╔═══██╗ ██╔══██╗██║ ██║██╔════╝ -██╔██╗ ██║██║ ██║ ██████╔╝██║ ██║██║ ███╗ -██║╚██╗██║██║ ██║ ██╔══██╗██║ ██║██║ ██║ -██║ ╚████║╚██████╔╝ ██████╔╝╚██████╔╝╚██████╔╝ -╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java new file mode 100644 index 0000000..587e5ba --- /dev/null +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/controller/admin/query/DataQueryController.java @@ -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> getData(String equipId, String startTime, String endTime, Integer pageSize, Integer pageNum){ + Map resMap = new HashMap<>(); + try { + resMap = dataQueryService.selectDataListByPages(equipId,startTime,endTime,pageSize,pageNum); + } catch (ParseException e) { + e.printStackTrace(); + return CommonResult.error(800,"时间格式错误"); + } + return success(resMap); + } + +} diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java new file mode 100644 index 0000000..bc96156 --- /dev/null +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/DataQueryService.java @@ -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 selectDataListByPages(String equipId,String startTime,String endTime, Integer pageSize, Integer pageNum) throws ParseException { + Map resMap = new HashMap<>(); + //TODO 分页查找条数,根据设备id、表名、时间范围、页码、每页条数 + List> 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> 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())); + } +} diff --git a/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java new file mode 100644 index 0000000..7b2194f --- /dev/null +++ b/imt-server/imt-module-data/imt-module-data-biz/src/main/java/com/inspur/module/data/service/IDataQueryService.java @@ -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 selectDataListByPages(String equipId,String startTime,String endTime,Integer pageSize,Integer pageNum) throws ParseException; + +} diff --git a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java index 757d11c..859f661 100644 --- a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java +++ b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java @@ -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, "机床网关信息不存在"); } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayInfoController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayInfoController.java new file mode 100644 index 0000000..e2ea745 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/GatewayInfoController.java @@ -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 createGatewayInfo(@Valid @RequestBody GatewayInfoSaveReqVO createReqVO) { + return success(gatewayInfoService.createGatewayInfo(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新机床网关信息") + @PreAuthorize("@ss.hasPermission('imt:gateway-info:update')") + public CommonResult 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 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 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> getGatewayInfoPage(@Valid GatewayInfoPageReqVO pageReqVO) { + PageResult 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 list = gatewayInfoService.getGatewayInfoPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "机床网关信息.xls", "数据", GatewayInfoRespVO.class, + BeanUtils.toBean(list, GatewayInfoRespVO.class)); + } + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoPageReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoPageReqVO.java new file mode 100644 index 0000000..33266b9 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoPageReqVO.java @@ -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; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoRespVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoRespVO.java new file mode 100644 index 0000000..f6bb1c4 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoRespVO.java @@ -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; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java new file mode 100644 index 0000000..ce01345 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java @@ -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; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java new file mode 100644 index 0000000..4ec6b1f --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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:停机) + *

+ */ + private Integer status; + /** + * 备注 + */ + private String remark; + /** + * 网关图片路径 + */ + private String gatewayPicPath; + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/gatewayinfo/GatewayInfoMapper.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/gatewayinfo/GatewayInfoMapper.java new file mode 100644 index 0000000..a1f877d --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/gatewayinfo/GatewayInfoMapper.java @@ -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 { + + default PageResult selectPage(GatewayInfoPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(GatewayInfoDO::getGatewayName, reqVO.getGatewayName()) + .eqIfPresent(GatewayInfoDO::getGatewayModel, reqVO.getGatewayModel()) + .eqIfPresent(GatewayInfoDO::getStatus, reqVO.getStatus()) + .orderByDesc(GatewayInfoDO::getGatewayId)); + } + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoService.java new file mode 100644 index 0000000..14fa70d --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoService.java @@ -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 getGatewayInfoPage(GatewayInfoPageReqVO pageReqVO); + +} diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java new file mode 100644 index 0000000..6041756 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java @@ -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 getGatewayInfoPage(GatewayInfoPageReqVO pageReqVO) { + return gatewayInfoMapper.selectPage(pageReqVO); + } + +} diff --git a/imt-ui/src/utils/dict.js b/imt-ui/src/utils/dict.js index 21c7122..4a26850 100644 --- a/imt-ui/src/utils/dict.js +++ b/imt-ui/src/utils/dict.js @@ -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',