diff --git a/sql/demo.sql b/sql/demo.sql index fa5b76b..aaf50ac 100644 --- a/sql/demo.sql +++ b/sql/demo.sql @@ -1,54 +1,3 @@ --- 表名: collect_info --- 描述: 收集信息 - -CREATE TABLE collect_info -( - id INTEGER PRIMARY KEY AUTOINCREMENT, -- 自增主键 id - name TEXT, -- 生产线id - lon REAL, -- 经度 - lat REAL, -- 纬度 - create_time TEXT -- 创建时间,格式 'YYYY-MM-DD HH:MM:SS' -); - --- 插入 30 条测试数据 --- 数据规则说明: --- 1. 生产线名称依次为 '生产线1' ~ '生产线30' --- 2. 经度从 116.397128 起,每条记录递增 0.1 --- 3. 纬度从 39.916527 起,每条记录递增 0.1 --- 4. 创建时间从 '2023-01-01 08:00:00' 起,每条记录递增 5 分钟 - -INSERT INTO collect_info (name, lon, lat, create_time) -VALUES ('生产线1', 116.397128, 39.916527, '2023-01-01 08:00:00'), - ('生产线2', 116.497128, 40.016527, '2023-01-01 08:05:00'), - ('生产线3', 116.597128, 40.116527, '2023-01-01 08:10:00'), - ('生产线4', 116.697128, 40.216527, '2023-01-01 08:15:00'), - ('生产线5', 116.797128, 40.316527, '2023-01-01 08:20:00'), - ('生产线6', 116.897128, 40.416527, '2023-01-01 08:25:00'), - ('生产线7', 116.997128, 40.516527, '2023-01-01 08:30:00'), - ('生产线8', 117.097128, 40.616527, '2023-01-01 08:35:00'), - ('生产线9', 117.197128, 40.716527, '2023-01-01 08:40:00'), - ('生产线10', 117.297128, 40.816527, '2023-01-01 08:45:00'), - ('生产线11', 117.397128, 40.916527, '2023-01-01 08:50:00'), - ('生产线12', 117.497128, 41.016527, '2023-01-01 08:55:00'), - ('生产线13', 117.597128, 41.116527, '2023-01-01 09:00:00'), - ('生产线14', 117.697128, 41.216527, '2023-01-01 09:05:00'), - ('生产线15', 117.797128, 41.316527, '2023-01-01 09:10:00'), - ('生产线16', 117.897128, 41.416527, '2023-01-01 09:15:00'), - ('生产线17', 117.997128, 41.516527, '2023-01-01 09:20:00'), - ('生产线18', 118.097128, 41.616527, '2023-01-01 09:25:00'), - ('生产线19', 118.197128, 41.716527, '2023-01-01 09:30:00'), - ('生产线20', 118.297128, 41.816527, '2023-01-01 09:35:00'), - ('生产线21', 118.397128, 41.916527, '2023-01-01 09:40:00'), - ('生产线22', 118.497128, 42.016527, '2023-01-01 09:45:00'), - ('生产线23', 118.597128, 42.116527, '2023-01-01 09:50:00'), - ('生产线24', 118.697128, 42.216527, '2023-01-01 09:55:00'), - ('生产线25', 118.797128, 42.316527, '2023-01-01 10:00:00'), - ('生产线26', 118.897128, 42.416527, '2023-01-01 10:05:00'), - ('生产线27', 118.997128, 42.516527, '2023-01-01 10:10:00'), - ('生产线28', 119.097128, 42.616527, '2023-01-01 10:15:00'), - ('生产线29', 119.197128, 42.716527, '2023-01-01 10:20:00'), - ('生产线30', 119.297128, 42.816527, '2023-01-01 10:25:00'); - -- 创建 sys_user 表 CREATE TABLE IF NOT EXISTS sys_user ( diff --git a/src/main/java/com/qyft/gd/controller/directive/DirectiveController.java b/src/main/java/com/qyft/gd/controller/directive/DirectiveController.java new file mode 100644 index 0000000..61ba590 --- /dev/null +++ b/src/main/java/com/qyft/gd/controller/directive/DirectiveController.java @@ -0,0 +1,36 @@ +package com.qyft.gd.controller.directive; + +import com.qyft.gd.model.dto.directive.DirectiveDto; +import com.qyft.gd.service.DirectiveService; +import com.qyft.gd.system.common.result.Result; +import com.qyft.gd.system.service.UserService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 指令控制器 + */ +@Tag(name = "指令") +@RestController +@RequestMapping("/api/directive") +@RequiredArgsConstructor +@Slf4j +public class DirectiveController { + + @Resource + private DirectiveService directiveService; + + @Operation(summary = "发送指令") + @PostMapping("/sendDirective") + public Result sendDirective(@RequestBody DirectiveDto dto) { + directiveService.sendDirective(dto); + return Result.success(); + } +} \ No newline at end of file diff --git a/src/main/java/com/qyft/gd/enums/DirectiveTypeEnum.java b/src/main/java/com/qyft/gd/enums/DirectiveTypeEnum.java new file mode 100644 index 0000000..d709b57 --- /dev/null +++ b/src/main/java/com/qyft/gd/enums/DirectiveTypeEnum.java @@ -0,0 +1,32 @@ +package com.qyft.gd.enums; + +import cn.hutool.core.util.StrUtil; + +public enum DirectiveTypeEnum { + ADD("add", "抬起托盘"); + + private final String typeCode; + private final String typeName; + DirectiveTypeEnum(String typeCode, String typeName) { + this.typeCode = typeCode; + this.typeName = typeName; + } + + public String typeCode() { + return typeCode; + } + public String typeName() { + return typeName; + } + + public static String getByCode(String code) { + if (StrUtil.isNotBlank(code)) { + for (DirectiveTypeEnum item : DirectiveTypeEnum.values()) { + if (item.typeCode().equals(code.trim())) { + return item.typeCode(); + } + } + } + return null; + } +} diff --git a/src/main/java/com/qyft/gd/model/dto/directive/DirectiveDto.java b/src/main/java/com/qyft/gd/model/dto/directive/DirectiveDto.java new file mode 100644 index 0000000..6ed7642 --- /dev/null +++ b/src/main/java/com/qyft/gd/model/dto/directive/DirectiveDto.java @@ -0,0 +1,16 @@ +package com.qyft.gd.model.dto.directive; + +import com.qyft.gd.enums.DirectiveTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(name = "指令数据") +@Data +public class DirectiveDto { + + @Schema(description = "指令类型") + private DirectiveTypeEnum type; + + @Schema(description = "指令配置") + private String option; +} diff --git a/src/main/java/com/qyft/gd/service/DirectiveService.java b/src/main/java/com/qyft/gd/service/DirectiveService.java new file mode 100644 index 0000000..5af682b --- /dev/null +++ b/src/main/java/com/qyft/gd/service/DirectiveService.java @@ -0,0 +1,9 @@ +package com.qyft.gd.service; + + +import com.qyft.gd.model.dto.directive.DirectiveDto; + +public interface DirectiveService { + + void sendDirective(DirectiveDto dto); +} diff --git a/src/main/java/com/qyft/gd/service/impl/DirectiveServiceImpl.java b/src/main/java/com/qyft/gd/service/impl/DirectiveServiceImpl.java new file mode 100644 index 0000000..114734a --- /dev/null +++ b/src/main/java/com/qyft/gd/service/impl/DirectiveServiceImpl.java @@ -0,0 +1,18 @@ +package com.qyft.gd.service.impl; + +import com.qyft.gd.model.dto.directive.DirectiveDto; +import com.qyft.gd.service.DirectiveService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +/** + * 指令实现类 + */ +@Service +@RequiredArgsConstructor +public class DirectiveServiceImpl implements DirectiveService { + @Override + public void sendDirective(DirectiveDto dto) { + // 发送指令 + } +}