diff --git a/hw-api/hw-api-tdengine/pom.xml b/hw-api/hw-api-tdengine/pom.xml new file mode 100644 index 00000000..ddeb7b41 --- /dev/null +++ b/hw-api/hw-api-tdengine/pom.xml @@ -0,0 +1,28 @@ + + + + com.hw + hw-api + 3.6.3 + + 4.0.0 + + hw-api-tdengine + + + hw-api-tdengine时序数据库模块api + + + + + + + com.hw + hw-common-core + + + + + diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java new file mode 100644 index 00000000..54a7acaa --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java @@ -0,0 +1,66 @@ +package com.hw.tdengine.api; + +import com.hw.common.core.constant.SecurityConstants; +import com.hw.common.core.constant.ServiceNameConstants; +import com.hw.common.core.domain.R; +import com.hw.common.core.validated.tdengine.AddTdSTableColumn; +import com.hw.common.core.validated.tdengine.InsertTdTable; +import com.hw.tdengine.api.domain.*; +import com.hw.tdengine.api.factory.RemoteTdEngineFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; + +import java.util.List; +import java.util.Map; + +@FeignClient(contextId = "remoteTdEngineService", value = ServiceNameConstants.TDENGINE_SERVICE, fallbackFactory = RemoteTdEngineFallbackFactory.class) +public interface RemoteTdEngineService { + + @PostMapping("/tdengine/createDatabase") + R createDataBase(@RequestBody String databaseName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/createSuperTable") + R createSuperTable(@Validated @RequestBody TdSuperTableVo tdSuperTableVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/createTable") + R createTable(@Validated @RequestBody TdTableVo tdTableVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/addSuperTableColumn") + R addSuperTableColumn(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/modifySuperTableColumn") + R modifySuperTableColumn(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/dropSuperTableColumn") + R dropColumnForSuperTable(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/alterTableTag") + public R alterTableTag(@Validated @RequestBody AlterTagVo alterTagVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/insertTable") + R insertTable(@Validated(InsertTdTable.class) @RequestBody TdTableVo tdTableVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getLatestData") + R getLatestData(@Validated @RequestBody TdSelectDto tdSelectDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getLatestDataByTags") + R>> getLatestDataByTags(@Validated @RequestBody TdSuperTableSelectVo tdSuperTableSelectVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getHistoryData") + R getHistoryData(@Validated @RequestBody TdHistorySelectDto tdHistorySelectDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getCountOfHistoryData") + R getCountOfHistoryData(@Validated @RequestBody TdHistorySelectDto tdHistorySelectDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getOnlineDevicesGroupByDay") + R getOnlineDevicesGroupByDay(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getLastOnlineDevices") + R getLastOnlineDevices(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/tdengine/getDeviceStatusList") + R>> getDeviceStatusList(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/AlterTagVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/AlterTagVo.java new file mode 100644 index 00000000..e893304f --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/AlterTagVo.java @@ -0,0 +1,33 @@ +package com.hw.tdengine.api.domain; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Description: 更新子表tag实体类 + * @ClassName: AlterTagVo + * @Author : xins + * @Date :2023-08-30 10:56 + * @Version :1.0 + */ +@Data +public class AlterTagVo { + + //数据库名称 + @NotBlank(message="databaseName cannot be empty") + private String databaseName; + + //子表名称 + @NotBlank(message="tableName cannot be empty") + private String tableName; + + @NotBlank(message="tagName cannot be empty") + private String tagName; + + @NotNull(message="tagValue cannot be empty") + private Object tagValue; + + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/DeviceStatus.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/DeviceStatus.java new file mode 100644 index 00000000..b0aefc48 --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/DeviceStatus.java @@ -0,0 +1,104 @@ +package com.hw.tdengine.api.domain; + +import com.hw.common.core.web.domain.BaseEntity; + +import java.util.List; + +/** + * @Description: 设备状态对象 + * @ClassName: DeviceStatus + * @Author : xins + * @Date :2023-09-05 11:35 + * @Version :1.0 + */ +public class DeviceStatus extends BaseEntity { + + private Long ts; + + private Long deviceId; + + private String deviceCode; + + private Integer deviceType; + + private Integer onlineStatus; + + private Long sceneId; + + private Long startTime; + private Long endTime; + + private List schemaFields; + + public Long getTs() { + return ts; + } + + public void setTs(Long ts) { + this.ts = ts; + } + + public Long getDeviceId() { + return deviceId; + } + + public void setDeviceId(Long deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceCode() { + return deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public Integer getDeviceType() { + return deviceType; + } + + public void setDeviceType(Integer deviceType) { + this.deviceType = deviceType; + } + + public Integer getOnlineStatus() { + return onlineStatus; + } + + public void setOnlineStatus(Integer onlineStatus) { + this.onlineStatus = onlineStatus; + } + + public Long getSceneId() { + return sceneId; + } + + public void setSceneId(Long sceneId) { + this.sceneId = sceneId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getSchemaFields() { + return schemaFields; + } + + public void setSchemaFields(List schemaFields) { + this.schemaFields = schemaFields; + } +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdField.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdField.java new file mode 100644 index 00000000..683f6f1e --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdField.java @@ -0,0 +1,40 @@ +package com.hw.tdengine.api.domain; + +import com.hw.common.core.enums.DataTypeEnums; +import lombok.Data; + +/** + * @ClassName: TdField + * @Author : xins + * @Date :2023-08-28 9:47 + * @Description: TDengine filed,建表的字段实体类 + * @Version :1.0 + */ +@Data +public class TdField { + + //字段名称 + private String fieldName; + + //字段值 + private Object fieldValue; + + //字段数据类型code + private Integer dataTypeCode; + + //字段数据类型 + private String dataType; + + //字段字节大小 + private Integer size; + + public TdField() { + } + + public TdField(String fieldName, Integer dataTypeCode, Integer size) { + this.fieldName = fieldName; + this.dataTypeCode = dataTypeCode; + this.dataType = DataTypeEnums.dataCodeTypeMap.get(dataTypeCode); + this.size = size; + } +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdFieldVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdFieldVo.java new file mode 100644 index 00000000..2f73e9fb --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdFieldVo.java @@ -0,0 +1,68 @@ +package com.hw.tdengine.api.domain; + +import com.hw.common.core.enums.DataTypeEnums; +import org.apache.commons.lang3.StringUtils; +import org.springframework.validation.annotation.Validated; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description: Tdengine 创建表的字段实体类 + * @ClassName: TdFieldsVo + * @Author : xins + * @Date :2023-08-28 14:34 + * @Version :1.0 + */ +public class TdFieldVo { + private static final long serialVersionUID = 1L; + + private String fieldName; + + private String dataType; + + private Integer size; + + + public TdFieldVo(String fieldName, Integer dataTypeCode, Integer size) { + this.fieldName = fieldName; + this.dataType = DataTypeEnums.dataCodeTypeMap.get(dataTypeCode); + this.size = size; + } + + /** + * @description 将TdFields转换为创建表的实体类TdFieldsVo,主要是datatype转换 + * @author xins + * @date 2023-08-28 14:40 + * @param field + * @return TdFieldsVo + */ + public static TdFieldVo convertField(@Validated TdField field) throws SQLException { + String fieldName = field.getFieldName(); + Integer datatypeCode = field.getDataTypeCode(); + Integer size = field.getSize(); + if(StringUtils.isBlank(fieldName) || datatypeCode == null){ + throw new SQLException("fieldname and datatype cannot be null"); + } + TdFieldVo tdFieldsVo = new TdFieldVo(fieldName, datatypeCode, size); + return tdFieldsVo; + } + + + /** + * @description 批量转换创建表的字段 + * @author xins + * @date 2023-08-28 14:58 + * @param fieldList + * @return List + */ + public static List batchConvertFields(List fieldList) throws SQLException{ + List tdFieldsVoList = new ArrayList<>(); + for(TdField tdField:fieldList){ + tdFieldsVoList.add(convertField(tdField)); + } + return tdFieldsVoList; + } + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdHistorySelectDto.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdHistorySelectDto.java new file mode 100644 index 00000000..bc3f756d --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdHistorySelectDto.java @@ -0,0 +1,40 @@ +package com.hw.tdengine.api.domain; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class TdHistorySelectDto { + + //数据库名称 + @NotBlank(message="databaseName cannot be empty") + private String databaseName; + + //子表名称 + @NotBlank(message="tableName cannot be empty") + private String tableName; + + //控制输出条数 + private int limit; + + //指定从第几条之后输出(例如:limit 2,5,输出第3行到第7行的数据) + private int offset; + + /** + * 第一个字段,数据类型必须是timestamp + */ + private String firstFieldName; + + //过滤条件:开始时间 + private long startTime; + + //过滤条件:结束时间 + private long endTime; + + //排序字段 + private String orderByFieldName; + + //排序方式 + private String sort; +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdReturnDataVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdReturnDataVo.java new file mode 100644 index 00000000..07a01ddd --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdReturnDataVo.java @@ -0,0 +1,13 @@ +package com.hw.tdengine.api.domain; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class TdReturnDataVo { + + public int count; + public List> dataList; +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSelectDto.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSelectDto.java new file mode 100644 index 00000000..fd885fd8 --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSelectDto.java @@ -0,0 +1,35 @@ +package com.hw.tdengine.api.domain; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * @Description: TDengine查询数据入参数据传输对象 + * @ClassName: TdSelectDto + * @Author : xins + * @Date :2023-08-29 10:39 + * @Version :1.0 + */ +@Data +public class TdSelectDto { + + //数据库名称 + @NotBlank(message="databaseName cannot be empty") + private String databaseName; + + //子表名称 + @NotBlank(message="tableName cannot be empty") + private String tableName; + + //超级表名称 + private String superTableName; + + //tags名称 + private String tagsName; + + private List schemaFieldValues; + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSuperTableSelectVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSuperTableSelectVo.java new file mode 100644 index 00000000..c923b119 --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSuperTableSelectVo.java @@ -0,0 +1,52 @@ +package com.hw.tdengine.api.domain; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * @Description: 用于查询超级表最新数据 + * @ClassName: TdSuperTableSelectVo + * @Author : xins + * @Date :2023-09-16 13:48 + * @Version :1.0 + */ +@Data +public class TdSuperTableSelectVo { + //数据库名称 + @NotBlank(message="databaseName cannot be empty") + private String databaseName; + + //超级表名称 + @NotBlank(message="superTableName cannot be empty") + private String superTableName; + + //group by tags名称 + @NotBlank(message="groupByTagsName cannot be empty") + private String groupByTagsName; + + //控制输出条数 + private int limit; + + //指定从第几条之后输出(例如:limit 2,5,输出第3行到第7行的数据) + private int offset; + + /** + * 第一个字段,数据类型必须是timestamp + */ + private String firstFieldName; + + //过滤条件:开始时间 + private long startTime; + + //过滤条件:结束时间 + private long endTime; + + private String deviceCode; + + private String deviceName; + + private List schemaFieldValues; + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSuperTableVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSuperTableVo.java new file mode 100644 index 00000000..499b5391 --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdSuperTableVo.java @@ -0,0 +1,57 @@ +package com.hw.tdengine.api.domain; + +import com.hw.common.core.validated.tdengine.AddTdSTableColumn; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * @ClassDescription: 创建超级表需要的入参的实体类 + * @ClassName: TdSuperTableVo + * @Author: xins + * @Date: 2023-08-28 09:30:45 + * @Version 1.0 + */ +@Data +public class TdSuperTableVo { + + //数据库名称 + @NotEmpty(message="databaseName cannot be empty",groups = AddTdSTableColumn.class) + private String databaseName; + + //超级表名称 + @NotEmpty(message="supertableName cannot be empty",groups = AddTdSTableColumn.class) + private String superTableName; + + /** + * 第一个字段,数据类型必须是timestamp + */ + private String firstFieldName; + + /** + * 超级表的表结构Schema,根据物模型创建 + * 第一列必须为时间戳timestamp,也就是第一个字段的数据类型必须是timestamp + * 字符相关数据类型必须指定大小 + * 字段名称和字段数据类型不能为空 + */ + @NotEmpty(message="schemeFields cannot be empty") + private List schemaFields; + + + /** + * 超级表的标签字段Schema,采集点的静态属性,可以作为子表在超级表里的标识 + * TAGS 列名不能与其他列名相同。 + * TAGS 列名不能为预留关键字。 + * TAGS 最多允许 128 个,至少 1 个,总长度不超过 16 KB。 + */ + @NotEmpty(message="tagsFields cannot be empty") + private List tagsFields; + + + /** + * 字段信息对象,超级表添加列时使用该属性 + */ + private TdField field; + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableVo.java new file mode 100644 index 00000000..045a25bf --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableVo.java @@ -0,0 +1,42 @@ +package com.hw.tdengine.api.domain; + +import com.hw.common.core.validated.tdengine.InsertTdTable; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * @Description: 子表实体类 + * @ClassName: TdTableVo + * @Author : xins + * @Date :2023-08-28 15:45 + * @Version :1.0 + */ +@Data +public class TdTableVo { + + //数据库名称 + @NotEmpty(message="databaseName cannot be empty",groups = InsertTdTable.class) + private String databaseName; + + //超级表名称 + @NotEmpty(message="supertableName cannot be empty") + private String superTableName; + + //子表名称 + @NotEmpty(message="tableName cannot be empty",groups = InsertTdTable.class) + private String tableName; + + /** + * 子表的标签字段的值,创建子表时标签字段值的数据类型要与超级表的对应上 + */ + private List tagsFieldValues; + + /** + * 子表的schema字段的值,掺入子表时schema字段值的数据类型要与超级表的对应上 + */ + @NotEmpty(message="schemaFields cannot be empty",groups = InsertTdTable.class) + private List schemaFields; + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java new file mode 100644 index 00000000..b82c4a6b --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java @@ -0,0 +1,107 @@ +package com.hw.tdengine.api.factory; + +import com.alibaba.fastjson2.JSONObject; +import com.hw.common.core.domain.R; +import com.hw.tdengine.api.RemoteTdEngineService; +import com.hw.tdengine.api.domain.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; + +/** + * @Description: TDengine服务降级处理 + * @ClassName: RemoteTdEngineFallbackFactory + * @Author : xins + * @Date :2023-09-01 14:14 + * @Version :1.0 + */ +@Component +public class RemoteTdEngineFallbackFactory implements FallbackFactory { + + private static final Logger log = LoggerFactory.getLogger(RemoteTdEngineFallbackFactory.class); + + @Override + public RemoteTdEngineService create(Throwable throwable) { + return new RemoteTdEngineService() { + @Override + public R createDataBase(String databaseName, String source) { + return R.fail("创建数据库失败:" + throwable.getMessage()); + } + + @Override + public R createSuperTable(TdSuperTableVo tdSuperTableVo, String source) { + return R.fail("创建超级表失败:" + throwable.getMessage()); + } + + @Override + public R createTable(TdTableVo tdTableVo, String source) { + return R.fail("创建子表失败:" + throwable.getMessage()); + } + + @Override + public R addSuperTableColumn(TdSuperTableVo tdSuperTableVo, String source) { + return R.fail("添加超级表Column失败:" + throwable.getMessage()); + } + + @Override + public R modifySuperTableColumn(TdSuperTableVo tdSuperTableVo, String source) { + return R.fail("修改超级表Column失败:" + throwable.getMessage()); + } + + @Override + public R dropColumnForSuperTable(TdSuperTableVo tdSuperTableVo, String source) { + return R.fail("删除超级表Column失败:" + throwable.getMessage()); + } + + @Override + public R alterTableTag(AlterTagVo alterTagVo, String source) { + return R.fail("修改子表tag值失败:" + throwable.getMessage()); + } + + @Override + public R insertTable(TdTableVo tdTableVo, String source) { + return R.fail("插入数据失败:" + throwable.getMessage()); + } + + @Override + public R getLatestData(TdSelectDto tdSelectDto, String source) { + return R.fail("获取子表最新数据失败:" + throwable.getMessage()); + } + + @Override + public R>> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo, String source) { + return R.fail("根据tags获取超级表最新数据失败:" + throwable.getMessage()); + } + + @Override + public R getHistoryData(TdHistorySelectDto tdHistorySelectDto, String source) { + return R.fail("获取历史数据失败:" + throwable.getMessage()); + } + + @Override + public R getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto, String source) { + return R.fail("获取历史数据数量失败:" + throwable.getMessage()); + } + + @Override + public R getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus, String source) { + return R.fail("获取设备状态失败:" + throwable.getMessage()); + } + + @Override + public R getLastOnlineDevices(DeviceStatus queryDeviceStatus, String source) { + return R.fail("获取最近设备状态失败:" + throwable.getMessage()); + } + + @Override + public R>> getDeviceStatusList(DeviceStatus queryDeviceStatus, String source) { + return R.fail("获取设备状态信息失败:" + throwable.getMessage()); + } + + }; + } +} diff --git a/hw-api/hw-api-tdengine/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/hw-api/hw-api-tdengine/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..e1a853bb --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.hw.tdengine.api.factory.RemoteTdEngineFallbackFactory diff --git a/hw-api/pom.xml b/hw-api/pom.xml index 649a6045..da4265be 100644 --- a/hw-api/pom.xml +++ b/hw-api/pom.xml @@ -10,6 +10,7 @@ hw-api-system + hw-api-tdengine hw-api diff --git a/hw-common/hw-common-core/pom.xml b/hw-common/hw-common-core/pom.xml index 3fdeb41e..59e37dc3 100644 --- a/hw-common/hw-common-core/pom.xml +++ b/hw-common/hw-common-core/pom.xml @@ -10,7 +10,7 @@ 4.0.0 hw-common-core - + hw-common-core核心模块 @@ -22,7 +22,7 @@ org.springframework.cloud spring-cloud-starter-openfeign - + org.springframework.cloud @@ -113,6 +113,11 @@ swagger-annotations + + org.projectlombok + lombok + + diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/ServiceNameConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/ServiceNameConstants.java index 9e21c915..a66809aa 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/ServiceNameConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/ServiceNameConstants.java @@ -2,7 +2,7 @@ package com.hw.common.core.constant; /** * 服务名称 - * + * * @author ruoyi */ public class ServiceNameConstants @@ -21,4 +21,9 @@ public class ServiceNameConstants * 文件服务的serviceid */ public static final String FILE_SERVICE = "hw-file"; + + /** + * Tdengine服务的serviceid + */ + public static final String TDENGINE_SERVICE = "hw-tdengine"; } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/TdEngineConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/TdEngineConstants.java new file mode 100644 index 00000000..dd4c5699 --- /dev/null +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/TdEngineConstants.java @@ -0,0 +1,134 @@ +package com.hw.common.core.constant; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: TdEngine服务常量 + * @ClassName: TdEngineConstants + * @Author : xins + * @Date :2023-09-05 9:47 + * @Version :1.0 + */ +public class TdEngineConstants { + + public static final String DEFAULT_FIRST_FIELD_NAME = "ts";//timestamp格式首字段,必须 + + public static final String DEFAULT_ORDER_BY_MODE = "desc";//默认排序方式,逆序 + + public static final String PAYLOAD_TS = "timestamp";//协议上传ts的key + + public static final String PAYLOAD_PARAM = "param";//协议上传的param key + + public static final String PAYLOAD_DATATYPE = "datatype";//协议上传数据数据类型的key + public static final String PAYLOAD_DATAVALUE = "datavalue";//协议上传数据的key + + public static final String PAYLOAD_DEVICE_CODE = "uid";//协议上传设备编号的key + + public static final String PAYLOAD_DEVICE_DATA_TYPE_IMAGE = "image";//协议上传图片的key + + public static final String PAYLOAD_DEVICE_DATA_TYPE_TYPE = "type";//协议上传图片类型的key + public static final String PAYLOAD_DEVICE_DATA_TYPE_TYPE_FIRSET_UPPER = "Type";//协议上传图片类型的key + +// public static final String DEFAULT_DB_NAME_PREFIX = "db_scene_";//数据库名称前缀 + + public static final String DEFAULT_SUPER_TABLE_NAME_PREFIX = "st_devicemode_";//超级表名称前缀 + public static final String DEFAULT_TABLE_NAME_PREFIX = "t_device_";//数据表名称前缀 + + public static final String DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME= "st_ds";//设备状态超级表名称 + public static final String DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX = "t_ds_";//设备状态数据表名称前缀 + + public static final String PLATFORM_DB_NAME = "db_hwsaas";//全局数据库名称 + + public static final String ST_TAG_DEVICECODE = "devicecode"; + public static final int ST_TAG_DEVICECODE_TYPE = 10; + public static final int ST_TAG_DEVICECODE_SIZE=50; + + public static final String ST_TAG_DEVICENAME = "devicename"; + + public static final String ST_TAG_DEVICETYPE = "devicetype"; + public static final String ST_TAG_ONLINESTATUS = "onlinestatus"; + public static final int ST_TAG_DEVICENAME_TYPE = 10; + public static final int ST_TAG_DEVICENAME_SIZE=200; + + public static final String ST_TAG_DEVICEID = "deviceid"; + public static final int ST_TAG_DEVICEID_TYPE = 2; + + public static final String ST_TAG_DEVICEMODEID = "devicemodeid"; + public static final int ST_TAG_DEVICEMODEID_TYPE = 2; + + public static final String ST_TAG_MONITORUNITID = "monitorunitid"; + + public static final String ST_TAG_SCENEID = "sceneid"; + + public static final int ST_TAG_MONITORUNITID_TYPE = 2; + + /** + * 需要转换的key + */ + public static final Map TDENGINE_KEY_TRANSFER_MAP = new HashMap(); + + static { + TDENGINE_KEY_TRANSFER_MAP.put("value", "value1"); + } + + /** + * 禁止的功能标识符 + */ + public static final List ABNDON_FUNCTION_IDENTIFIERS = Arrays.asList("ts","value1","type"); + + public static final Map DEVICE_DATA_COLUMN_MAP = new HashMap(); + + static { + DEVICE_DATA_COLUMN_MAP.put(ST_TAG_DEVICECODE, "设备编号"); + DEVICE_DATA_COLUMN_MAP.put(ST_TAG_DEVICENAME, "设备名称"); + DEVICE_DATA_COLUMN_MAP.put(DEFAULT_FIRST_FIELD_NAME, "时间"); + } + + /** + * @return String + * @param: sceneId + * @description 获取数据库名称 + * @author xins + * @date 2023-09-05 9:42 + */ + public static String getDatabaseName() { + return PLATFORM_DB_NAME; + } + + /** + * @param: deviceModeId + * @description 获取超级表名称 + * @author xins + * @date 2023-09-16 14:42 + * @return String + */ + public static String getSuperTableName(Long deviceModeId) { + return DEFAULT_SUPER_TABLE_NAME_PREFIX + deviceModeId; + } + + /** + * @param: deviceId + * @return String + * @description 获取设备数据子表名称 + * @author xins + * @date 2023-09-05 9:42 + */ + public static String getDeviceDataTableName(Long deviceId) { + return DEFAULT_TABLE_NAME_PREFIX + deviceId; + } + + /** + * @param: deviceId + * @return String + * @description 获取设备状态信息数据子表名称 + * @author xins + * @date 2023-09-05 9:42 + */ + public static String getDeviceStatusTableName(Long deviceId) { + return DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX + deviceId; + } + +} diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/enums/DataTypeEnums.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/enums/DataTypeEnums.java new file mode 100644 index 00000000..2d352d72 --- /dev/null +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/enums/DataTypeEnums.java @@ -0,0 +1,115 @@ +package com.hw.common.core.enums; + + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public enum DataTypeEnums { + + /** + * 时间戳。缺省精度毫秒,可支持微秒和纳秒 + */ + TIMESTAMP(1,"timestamp"), + + /** + * 整型,范围 [-2^31, 2^31-1] + */ + INT(2, "int"), + + /** + * 长整型,范围 [-2^63, 2^63-1] + */ + BIGINT(3, "bigint"), + + /** + * 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] + */ + FLOAT(4, "float"), + + /** + * 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] + */ + DOUBLE(5, "double"), + + /** + * 记录单字节字符串,建议只用于处理 ASCII 可见字符,最大长度16000,中文等多字节字符需使用 NCHAR + */ + BINARY(6, "binary"), + + /** + * 短整型, 范围 [-32768, 32767] + */ + SMALLINT(7, "smallint"), + + /** + * 单字节整型,范围 [-128, 127] + */ + TINYINT(8, "tinyint"), + + /** + * 布尔型,{true, false} + */ + BOOL(9, "bool"), + + /** + * 记录包含多字节字符在内的字符串,如中文字符。 + * 每个 NCHAR 字符占用 4 字节的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 \'。 + * NCHAR 使用时须指定字符串大小,类型为 NCHAR(10) 的列表示此列的字符串最多存储 10 个 NCHAR 字符。 + * 如果用户字符串长度超出声明长度,将会报错。最大长度4093 + */ + NCHAR(10, "nchar"), + + + /** + * json数据类型 只有tag类型可以是json格式 + */ + JSON(11, "json"); + + // 性别值数组 + public static final List genderValueList = Arrays.stream(values()).map(DataTypeEnums::getDataCode).collect(Collectors.toList()); + + // 性别名数组 + public static final List genderNameList = Arrays.stream(values()).map(DataTypeEnums::getDataType).collect(Collectors.toList()); + + // 属性值与属性名Map + public static final Map dataCodeTypeMap = Arrays.stream(values()).collect( + Collectors.toMap( + DataTypeEnums::getDataCode, + DataTypeEnums::getDataType + ) + ); + + // 属性名与属性值Map + public static final Map dataTypeCodeMap = Arrays.stream(values()).collect( + Collectors.toMap( + DataTypeEnums::getDataType, + DataTypeEnums::getDataCode + ) + ); + + // 性别值 + private final Integer dataCode; + + // 性别名 + private final String dataType; + + DataTypeEnums(Integer dataCode, String dataType) { + this.dataCode = dataCode; + this.dataType = dataType; + } + + public Integer getDataCode() { + return dataCode; + } + + public String getDataType() { + return dataType; + } + + + public static void main(String[] args) { + System.out.println(dataCodeTypeMap.get(1)); + } +} diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/validated/tdengine/AddTdSTableColumn.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/validated/tdengine/AddTdSTableColumn.java new file mode 100644 index 00000000..2877c5b8 --- /dev/null +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/validated/tdengine/AddTdSTableColumn.java @@ -0,0 +1,4 @@ +package com.hw.common.core.validated.tdengine; + +public interface AddTdSTableColumn { +} diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/validated/tdengine/InsertTdTable.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/validated/tdengine/InsertTdTable.java new file mode 100644 index 00000000..79c26cf2 --- /dev/null +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/validated/tdengine/InsertTdTable.java @@ -0,0 +1,4 @@ +package com.hw.common.core.validated.tdengine; + +public interface InsertTdTable { +} diff --git a/hw-modules/hw-gen/src/main/resources/bootstrap.yml b/hw-modules/hw-gen/src/main/resources/bootstrap.yml index b509e365..c50ece62 100644 --- a/hw-modules/hw-gen/src/main/resources/bootstrap.yml +++ b/hw-modules/hw-gen/src/main/resources/bootstrap.yml @@ -15,9 +15,13 @@ spring: discovery: # 服务注册地址 server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP config: # 配置中心地址 server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP # 配置文件格式 file-extension: yml # 共享配置 diff --git a/hw-modules/hw-jindie/install-jindie-jar.bat b/hw-modules/hw-jindie/install-jindie-jar.bat new file mode 100644 index 00000000..6baf4b8a --- /dev/null +++ b/hw-modules/hw-jindie/install-jindie-jar.bat @@ -0,0 +1,2 @@ +call mvn install:install-file -Dfile=D:\IdeaProjects\HwMes\hw-modules\hw-jindie\k3cloud-webapi-sdk8.0.6.jar -DgroupId=com.kingdee.bos -DartifactId=k3cloud-webapi-sdk -Dversion=8.0.6 -Dpackaging=jar +@pause \ No newline at end of file diff --git a/hw-modules/hw-jindie/k3cloud-webapi-sdk8.0.6.jar b/hw-modules/hw-jindie/k3cloud-webapi-sdk8.0.6.jar new file mode 100644 index 00000000..7847a054 Binary files /dev/null and b/hw-modules/hw-jindie/k3cloud-webapi-sdk8.0.6.jar differ diff --git a/hw-modules/hw-jindie/kdwebapi.properties b/hw-modules/hw-jindie/kdwebapi.properties new file mode 100644 index 00000000..4d9f21d1 --- /dev/null +++ b/hw-modules/hw-jindie/kdwebapi.properties @@ -0,0 +1,19 @@ +#X-KDApi-AcctID =6304ba61219bf5 +#X-KDApi-AppID=225649_7ZbM6dDO0qrVXXUKX/Xs09wH2u5d4rLE +#X-KDApi-AppSec =2bb1d972f3574a46aebee03cdc80aeae +#X-KDApi-UserName =demo +#X-KDApi-LCID=2052 +#X-KDApi-ServerUrl=https://apiexp.open.kingdee.com/k3cloud/ + +# +X-KDApi-AcctID =657953112be3c4 +# +X-KDApi-AppID=265686_SY0M09lvzkp/18wG4/RBRa1GRs2V2pls +# +X-KDApi-AppSec =317a6730c9ec4fafa757ca4a3499d059 +# +X-KDApi-UserName =张铭潇 +# +X-KDApi-LCID=2052 +# +X-KDApi-ServerUrl=http://1.15.183.55/k3cloud/ diff --git a/hw-modules/hw-jindie/pom.xml b/hw-modules/hw-jindie/pom.xml new file mode 100644 index 00000000..2fcb0624 --- /dev/null +++ b/hw-modules/hw-jindie/pom.xml @@ -0,0 +1,115 @@ + + + + com.hw + hw-modules + 3.6.3 + + 4.0.0 + + hw-modules-jindie + + + hw-modules-jindie金蝶ERP对接模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.hw + hw-common-datasource + + + + + com.hw + hw-common-datascope + + + + + com.hw + hw-common-log + + + + + com.hw + hw-common-swagger + + + + com.kingdee.bos + k3cloud-webapi-sdk + 8.0.6 + + + junit + junit + + + com.google.code.gson + gson + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/Main.java b/hw-modules/hw-jindie/src/main/java/com/hw/Main.java new file mode 100644 index 00000000..0dcc1da8 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/Main.java @@ -0,0 +1,19 @@ +package com.hw; + +// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`, +// then press Enter. You can now see whitespace characters in your code. +public class Main { + public static void main(String[] args) { + // Press Alt+Enter with your caret at the highlighted text to see how + // IntelliJ IDEA suggests fixing it. + System.out.printf("Hello and welcome!"); + + // Press Shift+F10 or click the green arrow button in the gutter to run the code. + for (int i = 1; i <= 5; i++) { + + // Press Shift+F9 to start debugging your code. We have set one breakpoint + // for you, but you can always add more by pressing Ctrl+F8. + System.out.println("i = " + i); + } + } +} \ No newline at end of file diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/HwJindieApplication.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/HwJindieApplication.java new file mode 100644 index 00000000..c2c95b2e --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/HwJindieApplication.java @@ -0,0 +1,34 @@ +package com.hw.jindie; + +import com.hw.common.security.annotation.EnableCustomConfig; +import com.hw.common.security.annotation.EnableRyFeignClients; +import com.hw.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 系统模块 + * + * @author ruoyi + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@SpringBootApplication +public class HwJindieApplication +{ + public static void main(String[] args) + { + SpringApplication.run(HwJindieApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 金蝶ERP对接模块启动成功 ლ(´ڡ`ლ)゙ \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/common/SeqHelper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/common/SeqHelper.java new file mode 100644 index 00000000..e949f05b --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/common/SeqHelper.java @@ -0,0 +1,22 @@ +package com.hw.jindie.common; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class SeqHelper { + static long seq = 0L; + static int mod = 10000; + + public SeqHelper() { + } + + public static long genSeq() { + return ++seq; + } + + public static String genNumber(String pre) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMHHmmss"); + String id = sdf.format(new Date()); + return pre == null ? id + (genSeq() + (long)mod) : pre + id + (genSeq() + (long)mod); + } +} diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/test/BdCustomer.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/test/BdCustomer.java new file mode 100644 index 00000000..4b8f65a1 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/test/BdCustomer.java @@ -0,0 +1,50 @@ +package com.hw.jindie.test; + +public class BdCustomer { + long CustID; + String FNumber; + String FName; + Long msterID; + + public long getCustID() { + return CustID; + } + + public void setCustID(long custID) { + CustID = custID; + } + + public String getFNumber() { + return FNumber; + } + + public void setFNumber(String FNumber) { + this.FNumber = FNumber; + } + + public String getFName() { + return FName; + } + + public void setFName(String FName) { + this.FName = FName; + } + + public String getFShortName() { + return FShortName; + } + + public void setFShortName(String FShortName) { + this.FShortName = FShortName; + } + + String FShortName; + + public Long getMsterID() { + return msterID; + } + + public void setMsterID(Long msterID) { + this.msterID = msterID; + } +} diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/test/BdCustomerTest.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/test/BdCustomerTest.java new file mode 100644 index 00000000..be2c04fc --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/test/BdCustomerTest.java @@ -0,0 +1,237 @@ +package com.hw.jindie.test; + +import static org.junit.Assert.fail; + +import java.util.*; + +import com.google.gson.JsonObject; +import com.kingdee.bos.webapi.entity.*; +import com.kingdee.bos.webapi.sdk.K3CloudApi; +import com.google.gson.Gson; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; +import com.hw.jindie.common.SeqHelper; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class BdCustomerTest { + static String FNumber = SeqHelper.genNumber("BC"); + static String FNumber2 = SeqHelper.genNumber("BC"); + static String FName = "aukh_" + UUID.randomUUID().toString(); + static String FShortName = "aukh_" + UUID.randomUUID().toString(); + static K3CloudApi api = new K3CloudApi(); + + + /* 本接口用于实现客户 (BD_Customer) 的保存功能 */ + @Test + public void atestSaveCustomer() throws Exception { + String para = "{\"FName\": "+"\""+FName+"\""+",\"FNumber\": "+"\""+FNumber+"\""+",\"FCreateOrgId\": {\"FNumber\": \"100\"},\"FUseOrgId\": {\"FNumber\": \"100\"},\"FCOUNTRY\": { \"FNumber\": \"China\"},\"FINVOICETITLE\": \"zzl\",\"FCustTypeId\": { \"FNumber\": \"KHLB001_SYS\"},\"FTRADINGCURRID\": { \"FNumber\": \"PRE001\"},\"FInvoiceType\": \"1\",\"FTaxType\": { \"FNumber\": \"SFL02_SYS\"},\"FPriority\": 1,\"FTaxRate\": { \"FNumber\": \"SL02_SYS\"},\"FISCREDITCHECK\": true,\"FIsTrade\": true }"; + Map map = new HashMap<>(); + map = new Gson().fromJson(para, map.getClass()); + SaveResult sRet = api.save("BD_Customer", new SaveParam(map)); + Gson gson = new Gson(); + if (sRet.isSuccessfully()) { + System.out.printf("客户保存接口: %s%n", gson.toJson(sRet.getResult())); + } else { + fail("客户保存接口: " + gson.toJson(sRet.getResult())); + } + } + + /* 本接口用于实现客户 (BD_Customer) 的保存功能 */ + @Test + public void btestSaveCustomer2() throws Exception { + String para2 = "{\"FName\": \"zzl\",\"FNumber\": "+"\""+FNumber2+"\""+",\"FCreateOrgId\": {\"FNumber\": \"100\"},\"FUseOrgId\": {\"FNumber\": \"100\"},\"FCOUNTRY\": { \"FNumber\": \"China\"},\"FINVOICETITLE\": \"zzl\",\"FCustTypeId\": { \"FNumber\": \"KHLB001_SYS\"},\"FTRADINGCURRID\": { \"FNumber\": \"PRE001\"},\"FInvoiceType\": \"1\",\"FTaxType\": { \"FNumber\": \"SFL02_SYS\"},\"FPriority\": 1,\"FTaxRate\": { \"FNumber\": \"SL02_SYS\"},\"FISCREDITCHECK\": true,\"FIsTrade\": true }"; + Map map = new HashMap<>(); + map = new Gson().fromJson(para2, map.getClass()); + SaveResult sRet = api.save("BD_Customer", new SaveParam(map),InvokeMode.Syn); + Gson gson = new Gson(); + if (sRet.isSuccessfully()) { + System.out.printf("客户保存接口: %s%n", gson.toJson(sRet.getResult())); + } else { + fail("客户保存接口: " + gson.toJson(sRet.getResult())); + } + } + + /*本接口用于实现客户 (BD_Customer) 的提交功能*/ + @Test + public void ctestSubmitCustomer() throws Exception { + OperateParam para = new OperateParam(); + List Numbers = Arrays.asList(FNumber);; + para.setNumbers(Numbers); + OperatorResult result = api.submit("BD_Customer", para); + Gson gson = new Gson(); + if (result.getResult().getResponseStatus().isIsSuccess()) { + System.out.printf("客户提交接口: %s%n", gson.toJson(result.getResult())); + } else { + fail("客户提交接口:" + gson.toJson(result.getResult())); + } + + } + + /*本接口用于实现客户 (BD_Customer) 的审核功能*/ + @Test + public void dtestauditCustomer() throws Exception { + OperateParam para = new OperateParam(); + List Numbers = Arrays.asList(FNumber);; + para.setNumbers(Numbers); + OperatorResult result = api.audit("BD_Customer", para ); + Gson gson = new Gson(); + if (result.getResult().getResponseStatus().isIsSuccess()) { + System.out.printf("客户审核接口: %s%n", gson.toJson(result.getResult())); + } else { + fail("客户审核接口: " + gson.toJson(result.getResult().getResponseStatus())); + } + + } + + /*本接口用于实现客户 (BD_Customer) 的反审核功能*/ + @Test + public void etestunauditCustomer() throws Exception { + OperateParam para = new OperateParam(); + List Numbers = Arrays.asList(FNumber); + para.setNumbers(Numbers); + OperatorResult result = api.unAudit("BD_Customer", para); + Gson gson = new Gson(); + if (result.getResult().getResponseStatus().isIsSuccess()) { + + System.out.printf("客户反审核接口: %s%n", gson.toJson(result.getResult())); + } else { + fail("客户反审核接口: " + gson.toJson(result.getResult().getResponseStatus())); + } + } + + + /*本接口用于实现客户 (BD_Customer) 的禁用功能*/ + @Test + public void ftestForbidCustomer() throws Exception { + JsonObject jsonData = new JsonObject(); + jsonData.addProperty("Numbers", FNumber); + String result = api.excuteOperation("BD_Customer","Forbid", jsonData.toString()); + Gson gson = new Gson(); + RepoRet repoRet = gson.fromJson(result, RepoRet.class); + if (repoRet.getResult().getResponseStatus().isIsSuccess()) { + + System.out.printf("客户禁用接口: %s%n", gson.toJson(repoRet.getResult())); + } else { + fail("客户禁用接口: " + gson.toJson(repoRet.getResult().getResponseStatus())); + } + } + + /*本接口用于实现客户 (BD_Customer) 的反禁用功能*/ + @Test + public void gtestenableCustomer() throws Exception { + JsonObject jsonData = new JsonObject(); + jsonData.addProperty("Numbers", FNumber); + String result = api.excuteOperation("BD_Customer","enable", jsonData.toString()); + Gson gson = new Gson(); + RepoRet repoRet = gson.fromJson(result, RepoRet.class); + if (repoRet.getResult().getResponseStatus().isIsSuccess()) { + + System.out.printf("客户反禁用接口: %s%n", gson.toJson(repoRet.getResult())); + } else { + fail("客户反禁用接口: %s%n "+ gson.toJson(repoRet.getResult().getResponseStatus())); + } + } + + /*本接口用于实现客户 (BD_Customer) 的查看功能*/ + @Test + public void htestviewCustomer() throws Exception { + OperateParam para = new OperateParam(); + para.setNumber(FNumber); + OperatorResult result = api.view("BD_Customer", para); + Gson gson = new Gson(); + if (result.getResult().getResponseStatus().isIsSuccess()) { + System.out.printf("客户查看接口: %s%n", gson.toJson(result.getResult())); + } else { + fail("客户查看接口: " + gson.toJson(result.getResult())); + } + } + + /*本接口用于实现客户 (BD_Customer) 的查看功能*/ + @Test + public void htestviewCustomer2() throws Exception { + OperateParam para = new OperateParam(); + para.setNumber(FNumber); + OperatorResult result = api.view("BD_Customer", para, BdCustomer.class); + Gson gson = new Gson(); + System.out.printf("result: %s%n", gson.toJson(result)); + if (result.getResult().getResponseStatus().isIsSuccess()) { + System.out.printf("客户查看接口: %s%n", gson.toJson(result.getResult())); + } else { + fail("客户查看接口: " + gson.toJson(result.getResult())); + } + } + + /*本接口用于实现客户 (BD_Customer)的单据查询功能*/ + @Test + public void itestQueryCustomer() throws Exception { + QueryParam para = new QueryParam(); + para.setFormId("BD_Customer"); + para.setFieldKeys("FNumber,FName,"); + para.setFilterString("Fnumber=\'"+FNumber+"\'"); + Gson gson = new Gson(); + List result = api.executeBillQuery(para,BdCustomer.class); + System.out.println("客户单据查询接口: " + gson.toJson(result)); + + + } + + /*本接口用于实现客户 (BD_Customer) 的删除功能*/ + @Test + public void jtestdeleteCustomer() throws Exception { + OperateParam para = new OperateParam(); + List Numbers = Arrays.asList(FNumber); + para.setNumbers(Numbers); + OperatorResult result = api.delete("BD_Customer",para); + Gson gson = new Gson(); + if (result.getResult().getResponseStatus().isIsSuccess()) { + System.out.printf("客户删除接口: %s%n", gson.toJson(result.getResult())); + } else { + fail("客户删除接口: " + gson.toJson(result.getResult().getResponseStatus())); + } + } + + /*本接口用于实现客户 (BD_Customer) 的批量提交功能*/ + @Test + public void kbatchsaveCustomer() throws Exception { + String para = "[{\"FName\": "+"\""+"aukh_" + UUID.randomUUID().toString()+"\""+",\"FNumber\": "+"\""+SeqHelper.genNumber("KH")+"\""+",\"FCreateOrgId\": {\"FNumber\": \"100\"},\"FUseOrgId\": {\"FNumber\": \"100\"},\"FCOUNTRY\": {\"FNumber\": \"China\"},\"FINVOICETITLE\": \"zzl\",\"FCustTypeId\": {\"FNumber\": \"KHLB001_SYS\"},\"FTRADINGCURRID\": {\"FNumber\": \"PRE001\"},\"FInvoiceType\": \"1\",\"FTaxType\": {\"FNumber\": \"SFL02_SYS\"},\"FPriority\": 1,\"FTaxRate\": {\"FNumber\": \"SL02_SYS\"},\"FISCREDITCHECK\": true,\"FIsTrade\": true},{\"FName\": "+"\""+"auwl_" + UUID.randomUUID().toString()+"\""+",\"FNumber\": "+"\""+SeqHelper.genNumber("KH")+"\""+",\"FCreateOrgId\": {\"FNumber\": \"100\"},\"FUseOrgId\": {\"FNumber\": \"100\"},\"FCOUNTRY\": {\"FNumber\": \"China\"},\"FINVOICETITLE\": \"zzl\",\"FCustTypeId\": {\"FNumber\": \"KHLB001_SYS\"},\"FTRADINGCURRID\": {\"FNumber\": \"PRE001\"},\"FInvoiceType\": \"1\",\"FTaxType\": {\"FNumber\": \"SFL02_SYS\"},\"FPriority\": 1,\"FTaxRate\": {\"FNumber\": \"SL02_SYS\"},\"FISCREDITCHECK\": true,\"FIsTrade\": true}]"; + // 批量保存客户信息 + List> list = new ArrayList<>(); + list = new Gson().fromJson(para, list.getClass()); + SaveResult sRet = api.batchSave("BD_Customer", new BatchSave<>(list)); + Gson gson = new Gson(); + if (sRet.isSuccessfully()) { + System.out.printf("客户批量保存接口: %s%n", gson.toJson(sRet.getResult())); + } else { + fail("客户保存接口: " + gson.toJson(sRet.getResult())); + } + } + + /*本接口用于实现客户 (BD_Customer) 的批量提交功能2*/ + @Test + public void lbatchsaveCustomer2() throws Exception { + String para = "[{\"FName\": "+"\""+"aukh_" + UUID.randomUUID().toString()+"\""+",\"FNumber\": "+"\""+SeqHelper.genNumber("KH")+"\""+",\"FCreateOrgId\": {\"FNumber\": \"100\"},\"FUseOrgId\": {\"FNumber\": \"100\"},\"FCOUNTRY\": {\"FNumber\": \"China\"},\"FINVOICETITLE\": \"zzl\",\"FCustTypeId\": {\"FNumber\": \"KHLB001_SYS\"},\"FTRADINGCURRID\": {\"FNumber\": \"PRE001\"},\"FInvoiceType\": \"1\",\"FTaxType\": {\"FNumber\": \"SFL02_SYS\"},\"FPriority\": 1,\"FTaxRate\": {\"FNumber\": \"SL02_SYS\"},\"FISCREDITCHECK\": true,\"FIsTrade\": true}]"; + // 批量保存客户信息(传请求模式) + List> list = new ArrayList<>(); + list = new Gson().fromJson(para, list.getClass()); + SaveResult sRet = api.batchSave("BD_Customer", new BatchSave<>(list),InvokeMode.Syn); + Gson gson = new Gson(); + if (sRet.isSuccessfully()) { + System.out.printf("客户批量保存接口: %s%n", gson.toJson(sRet.getResult())); + } else { + fail("客户保存接口: " + gson.toJson(sRet.getResult())); + } + } + + /*本接口用于获取账套信息*/ + @Test + public void ngetDataCenters() throws Exception { + List datacenter = api.getDataCenters(); + Gson gson = new Gson(); + System.out.printf("或则环境账套信息:%s%n",gson.toJson(datacenter)); + + + } + +} diff --git a/hw-modules/hw-jindie/src/main/resources/banner.txt b/hw-modules/hw-jindie/src/main/resources/banner.txt new file mode 100644 index 00000000..fbd45f53 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ _ + (_) | | + _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___ +| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ +| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | | +|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_| + __/ | __/ | + |___/ |___/ \ No newline at end of file diff --git a/hw-modules/hw-jindie/src/main/resources/bootstrap.yml b/hw-modules/hw-jindie/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..a6ccdc58 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 7303 + +# Spring +spring: + application: + # 应用名称 + name: hw-jindie + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP + config: + # 配置中心地址 + server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/hw-modules/hw-jindie/src/main/resources/logback.xml b/hw-modules/hw-jindie/src/main/resources/logback.xml new file mode 100644 index 00000000..c6be9e6a --- /dev/null +++ b/hw-modules/hw-jindie/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/hw-modules/hw-tdengine/pom.xml b/hw-modules/hw-tdengine/pom.xml new file mode 100644 index 00000000..6e568379 --- /dev/null +++ b/hw-modules/hw-tdengine/pom.xml @@ -0,0 +1,106 @@ + + + + com.hw + hw-modules + 3.6.3 + + 4.0.0 + + hw-modules-tdengine + + + hw-modules-tdengine 时序数据库处理模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.hw + hw-common-datasource + + + + + com.hw + hw-common-datascope + + + + + com.hw + hw-common-log + + + + + com.hw + hw-common-swagger + + + + + com.taosdata.jdbc + taos-jdbcdriver + 3.1.0 + + + com.hw + hw-api-tdengine + 3.6.3 + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/HwTdengineApplication.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/HwTdengineApplication.java new file mode 100644 index 00000000..0d4f6a5b --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/HwTdengineApplication.java @@ -0,0 +1,34 @@ +package com.hw.tdengine; + +import com.hw.common.security.annotation.EnableCustomConfig; +import com.hw.common.security.annotation.EnableRyFeignClients; +import com.hw.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 系统模块 + * + * @author xins + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@SpringBootApplication +public class HwTdengineApplication +{ + public static void main(String[] args) + { + SpringApplication.run(HwTdengineApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 时序数据库模块启动成功 ლ(´ڡ`ლ)゙ \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java new file mode 100644 index 00000000..d696f10c --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java @@ -0,0 +1,483 @@ +package com.hw.tdengine.controller; + +import com.hw.common.core.domain.R; +import com.hw.common.core.validated.tdengine.AddTdSTableColumn; +import com.hw.common.core.validated.tdengine.InsertTdTable; +import com.hw.common.security.annotation.InnerAuth; +import com.hw.tdengine.api.domain.*; +import com.hw.tdengine.service.IDeviceStatusService; +import com.hw.tdengine.service.ITdEngineService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.UncategorizedSQLException; +import org.springframework.validation.annotation.Validated; +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; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @ClassDescription: TdEngine Controller + * @ClassName: TdEngineController + * @Author: xins + * @Date: 2023-08-25 16:38:44 + * @Version 1.0 + */ +@RestController +@RequestMapping("/tdengine") +public class TdEngineController { + + @Autowired + private ITdEngineService tdEngineService; + + @Autowired + private IDeviceStatusService deviceStatusService; + + private static final Logger log = LoggerFactory.getLogger(TdEngineController.class); + + /* @description 创建数据库 + * @author xins + * @date 2023-08-28 11:38 + * @param databaseName + * @return R + */ + @InnerAuth + @PostMapping("/createDatabase") + public R createDataBase(@RequestBody() String databaseName) { + try { + //调用创建数据库方法 + this.tdEngineService.createDatabase(databaseName); + log.info("successfully created database " + databaseName); + return R.ok("successfully created database " + databaseName); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /* * @description:创建超级表 + * @author xins + * @date 2023-08-28 11:41 + * @param tdSuperTableVo + * @return R + */ + @InnerAuth + @PostMapping("/createSuperTable") + public R createSuperTable(@Validated @RequestBody TdSuperTableVo tdSuperTableVo) { + //数据库名称 + String databaseName = tdSuperTableVo.getDatabaseName(); + //超级表名称 + String superTableName = tdSuperTableVo.getSuperTableName(); + //第一个字段名称 + String firstFieldName = tdSuperTableVo.getFirstFieldName(); + //schema列字段(超级表结构)对象集合 + List schemaFields = tdSuperTableVo.getSchemaFields(); + //标签字段对象集合 + List tagsFields = tdSuperTableVo.getTagsFields(); + + try { + //将Schema字段对象和标签字段对象转换为创建表的字段Vo类对象集合 + List schemaFieldsVos = TdFieldVo.batchConvertFields(schemaFields); + List tagsFieldsVos = TdFieldVo.batchConvertFields(tagsFields); + this.tdEngineService.createSuperTable(databaseName, superTableName, firstFieldName, schemaFieldsVos, tagsFieldsVos); + log.info("successfully created superTable " + superTableName); + return R.ok("successfully created superTable " + superTableName); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R + * @param: tableDto + * @description 创建子表 + * @author xins + * @date 2023-08-28 16:17 + */ + @InnerAuth + @PostMapping("/createTable") + public R createTable(@Validated @RequestBody TdTableVo tdTableVo) { + try { + String databaseName = tdTableVo.getDatabaseName(); + String superTableName = tdTableVo.getSuperTableName(); + String tableName = tdTableVo.getTableName(); + List tagsFieldValues = tdTableVo.getTagsFieldValues(); + this.tdEngineService.createTable(databaseName, superTableName, tableName, tagsFieldValues); + log.info("successfully created table " + tableName); + return R.ok("successfully created table " + tableName); + } catch (Exception e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + log.error(ex.getMessage()); + } + log.error(message); + return R.fail(message); + } + } + + + /** + * @return R + * @param: tdSuperTableVo + * @description 超级表增加列 + * @author xins + * @date 2023-08-28 17:55 + */ + @InnerAuth + @PostMapping("/addSuperTableColumn") + public R addSuperTableColumn(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo) { + String databaseName = tdSuperTableVo.getDatabaseName(); + String superTableName = tdSuperTableVo.getSuperTableName(); + TdField addTdField = tdSuperTableVo.getField(); + try { + TdFieldVo addFieldVo = TdFieldVo.convertField(addTdField); + this.tdEngineService.addSuperTableColumn(databaseName, superTableName, addFieldVo); + log.info("successfully added column for superTable " + superTableName); + return R.ok("successfully added column for superTable " + superTableName); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R + * @param: tdSuperTableVo + * @description 超级表增加列 + * @author xins + * @date 2023-08-28 17:55 + */ + @InnerAuth + @PostMapping("/modifySuperTableColumn") + public R modifySuperTableColumn(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo) { + String databaseName = tdSuperTableVo.getDatabaseName(); + String superTableName = tdSuperTableVo.getSuperTableName(); + TdField modifyTdField = tdSuperTableVo.getField(); + try { + TdFieldVo modifyTdFieldVo = TdFieldVo.convertField(modifyTdField); + this.tdEngineService.modifySuperTableColumn(databaseName, superTableName, modifyTdFieldVo); + log.info("successfully modified column for superTable {} " , superTableName); + return R.ok("successfully modified column for superTable " + superTableName); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + + /** + * @return R + * @param: tdSuperTableVo + * @description 超级表删除列 + * @author xins + * @date 2023-08-28 17:56 + */ + @InnerAuth + @PostMapping("/dropSuperTableColumn") + public R dropColumnForSuperTable(@Validated(AddTdSTableColumn.class) @RequestBody TdSuperTableVo tdSuperTableVo) { + String databaseName = tdSuperTableVo.getDatabaseName(); + String superTableName = tdSuperTableVo.getSuperTableName(); + TdField dropField = tdSuperTableVo.getField(); + + try { +// TdFieldVo dropFieldVo = TdFieldVo.convertField(dropField); + this.tdEngineService.dropSuperTableColumn(databaseName, superTableName, dropField); + log.info("successfully droped column of superTable " + superTableName); + return R.ok("successfully droped column of superTable " + superTableName); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R + * @param: alterTagVo + * @description 修改子表tag值 + * @author xins + * @date 2023-08-30 11:17 + */ + @InnerAuth + @PostMapping("/alterTableTag") + public R alterTableTag(@Validated @RequestBody AlterTagVo alterTagVo) { + String databaseName = alterTagVo.getDatabaseName(); + String tableName = alterTagVo.getTableName(); + String tagName = alterTagVo.getTagName(); + Object tagValue = alterTagVo.getTagValue(); + + try { + this.tdEngineService.alterTableTag(databaseName, tableName, tagName, tagValue); + log.info("successfully altered tag " + tagName + " value to " + tagValue + " of tableName"); + return R.ok("successfully altered tag " + tagName + " value to " + tagValue + " of tableName"); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R + * @param: tdTableVo + * @description 插入数据 + * @author xins + * @date 2023-08-29 10:04 + */ + @InnerAuth + @PostMapping("/insertTable") + public R insertTable(@Validated(InsertTdTable.class) @RequestBody TdTableVo tdTableVo) { + try { + String databaseName = tdTableVo.getDatabaseName(); + String tableName = tdTableVo.getTableName(); + List schemaFields = tdTableVo.getSchemaFields(); + + this.tdEngineService.insertTable(databaseName, tableName, schemaFields); + log.info("success for insert table " + databaseName + "." + tableName); + return R.ok(); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R + * @param: tdSelectDto + * @description 获取某个子表最新一条数据 + * @author xins + * @date 2023-08-29 11:26 + */ + @InnerAuth + @PostMapping("/getLatestData") + public R getLatestData(@Validated @RequestBody TdSelectDto tdSelectDto) { + try { + return R.ok(this.tdEngineService.getLatestData(tdSelectDto)); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R>> + * @param: tdSelectDto + * @description 根据tagsname获取超级表最新信息 + * @author xins + * @date 2023-08-29 14:51 + */ + @InnerAuth + @PostMapping("/getLatestDataByTags") + public R>> getLatestDataByTags(@Validated @RequestBody TdSuperTableSelectVo tdSelectDto) { + try { + return R.ok(this.tdEngineService.getLatestDataByTags(tdSelectDto)); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + + /** + * @param tdHistorySelectDto + * @return R + * @MethodDescription 可视化数据 返回格式,时间,数值列 + * 历史数据 SELECT voltage ,ts FROM test.meters where ts between '2017-07-14 02:40:00.000' and '2017-07-14 02:40:00.001' LIMIT [topnums] + * ts > now - 24h; + * 实时数据 select col from table LIMIT [topnums] + * 聚合数据 select [avg/max/sum/count..](col) from table where ts between '2017-07-14 02:40:00.000' and '2017-07-14 02:40:00.001' group by col LIMIT [topnums] + */ + @InnerAuth + @PostMapping("/getHistoryData") + public R getHistoryData(@Validated @RequestBody TdHistorySelectDto tdHistorySelectDto) { + try { +// if (selectVisualDto.getType() == 0) {//查询历史 +// return R.ok(this.tdEngineService.getHistoryData(selectVisualDto)); +// }else if(selectVisualDto.getType() == 1) {//查询实时 +// return R.ok(this.tdEngineService.getRealtimeData(selectVisualDto)); +// }else {//查询聚合 +// return R.ok(this.tdEngineService.getAggregateData(selectVisualDto)); +// } + int count = this.tdEngineService.getCountOfHistoryData(tdHistorySelectDto); + TdReturnDataVo returnDataVo = new TdReturnDataVo(); + returnDataVo.setCount(count); + returnDataVo.setDataList(this.tdEngineService.getHistoryData(tdHistorySelectDto)); + return R.ok(returnDataVo); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + /** + * @return R + * @param: queryDeviceStatus + * @description 获取每天在线设备信息 + * @author xins + * @date 2023-08-29 11:26 + */ + @InnerAuth + @PostMapping("/getOnlineDevicesGroupByDay") + public R getOnlineDevicesGroupByDay(@RequestBody DeviceStatus queryDeviceStatus) { + try { + List deviceStatuses = this.deviceStatusService.getOnlineDevicesGroupByDay(queryDeviceStatus); + Map> deviceStatusMap = deviceStatuses.stream() + .collect(Collectors.groupingBy(DeviceStatus::getDeviceId)); + return R.ok(deviceStatusMap); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + + /** + * @return R + * @param: queryDeviceStatus + * @description 获取最近一次在线设备信息 + * @author xins + * @date 2023-08-29 11:26 + */ + @InnerAuth + @PostMapping("/getLastOnlineDevices") + public R getLastOnlineDevices(@RequestBody DeviceStatus queryDeviceStatus) { + try { + List> deviceStatusMapList = this.deviceStatusService.getLastOnlineDevices(queryDeviceStatus); + return R.ok(deviceStatusMapList); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + + + /** + * @return R + * @param: tdSelectDto + * @description 获取最近一次在线设备信息 + * @author xins + * @date 2023-08-29 11:26 + */ + @InnerAuth + @PostMapping("/getDeviceStatusList") + public R>> getDeviceStatusList(@RequestBody DeviceStatus queryDeviceStatus) { + try { + List> deviceStatusMapList = this.deviceStatusService.getDeviceStatusList(queryDeviceStatus); + return R.ok(deviceStatusMapList); + } catch (UncategorizedSQLException e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + } + log.error(message); + return R.fail(message); + } catch (Exception e) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + } + +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/DeviceStatusMapper.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/DeviceStatusMapper.java new file mode 100644 index 00000000..1651f2af --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/DeviceStatusMapper.java @@ -0,0 +1,44 @@ +package com.hw.tdengine.mapper; + +import com.hw.tdengine.api.domain.DeviceStatus; + +import java.util.List; +import java.util.Map; + +/** + * @Description:TDengine设备状态信息交互接口 + * @ClassName: DeviceStatusMapper + * @Author : xins + * @Date :2023-09-05 13:20 + * @Version :1.0 + */ +public interface DeviceStatusMapper { + + /** + * @param: deviceStatus + * @description 获取每天在线设备列表 + * @author xins + * @date 2023-09-05 11:43 + * @return List + */ + List getOnlineDevicesGroupByDay(DeviceStatus deviceStatus); + + /** + * @param: deviceStatus + * @description 获取最近的在线设备列表 + * @author xins + * @date 2023-09-05 11:43 + * @return List + */ + List> getLastOnlineDevices(DeviceStatus deviceStatus); + + /** + * @param: deviceStatus + * @description 获取设备状态信息列表 + * @author xins + * @date 2023-09-05 11:43 + * @return List + */ + List> getDeviceStatusList(DeviceStatus deviceStatus); + +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java new file mode 100644 index 00000000..87fd769a --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java @@ -0,0 +1,177 @@ +package com.hw.tdengine.mapper; + +import com.hw.tdengine.api.domain.*; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @ClassDescription:TDengine数据库交互接口 + * @ClassName: TdEngineMapper + * @Author: thinglinks + * @Date: 2021-12-27 14:52:34 + * @Version 1.0 + */ +public interface TdEngineMapper { + + /** + * @param databaseName + * @description 创建数据库 + * @author xins + * @date 2023-08-28 13:16 + */ + void createDatabase(String databaseName); + + /** + * @param databaseName + * @param superTableName + * @param firstFieldName + * @param schemaFields + * @param tagsFields + * @description 创建超级表 + * @author xins + * @date 2023-08-28 11:09 + */ + void createSuperTable(@Param("databaseName") String databaseName, + @Param("superTableName") String superTableName, + @Param("firstFieldName") String firstFieldName, + @Param("schemaFields") List schemaFields, + @Param("tagsFields") List tagsFields + ); + + /** + * @param: databaseName + * @param: superTableName + * @param: tableName + * @param: tagsFieldValues + * @description 创建子表 + * @author xins + * @date 2023-08-28 15:58 + */ + void createTable(@Param("databaseName") String databaseName, + @Param("superTableName") String superTableName, + @Param("tableName") String tableName, + @Param("tagsFieldValues") List tagsFieldValues); + + + /** + * @param: databaseName + * @param: superTableName + * @param: addFieldsVo + * @description 增加超级表的列 + * @author xins + * @date 2023-08-28 17:11 + */ + void addSuperTableColumn(@Param("databaseName") String databaseName, + @Param("superTableName") String superTableName, + @Param("addFieldsVo") TdFieldVo addFieldsVo); + + /** + * @param: databaseName + * @param: superTableName + * @param: modifyFieldsVo + * @description 修改超级表列宽(只适用于nchar类型) + * @author xins + * @date 2023-10-11 9:01 + + */ + void modifySuperTableColumn(@Param("databaseName") String databaseName, + @Param("superTableName") String superTableName, + @Param("modifyFieldsVo") TdFieldVo modifyFieldsVo); + + /** + * @param: databaseName + * @param: superTableName + * @param: dropFieldsVo + * @description 删除超级表的列 + * @author xins + * @date 2023-08-28 17:11 + */ + void dropSuperTableColumn(@Param("databaseName") String databaseName, + @Param("superTableName") String superTableName, + @Param("dropField") TdField dropField); + + + /** + * @param: databaseName + * @param: tableName + * @param: tagName + * @param: tagValue + * @description 修改子表的tagValue + * @author xins + * @date 2023-08-30 11:02 + */ + void alterTableTag(@Param("databaseName") String databaseName, + @Param("tableName") String tableName, + @Param("tagName") String tagName, + @Param("tagValue") Object tagValue + ); + + + /** + * @param: databaseName + * @param: tableName + * @param: schemaFields + * @description 插入数据 + * @author xins + * @date 2023-08-29 10:03 + */ + void insertTable(@Param("databaseName") String databaseName, + @Param("tableName") String tableName, + @Param("schemaFields") List schemaFields); + + + /** + * @return List> + * @param: tdSelectDto + * @description 查询具体某个子表最新数据,适用于设备监测页面,先根据监控单元获取设备信息,再根据设备来获取最新的数据 + * @author xins + * @date 2023-08-29 10:43 + */ + List> getLatestData(TdSelectDto tdSelectDto); + + /** + * @return List> + * @param: tdSelectDto + * @description 根据tagsname获取超级表最新信息,适用于设备汇总页面,先分页获取设备信息,再获取所有此物模型下的最新信息(冗余,但每页只获取一次,不需要每个设备都获取一次 + * 如果需要根据时间周期获取最新的数据,则需要用select last_row() + * @author xins + * @date 2023-08-29 14:42 + */ + List> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo); + + + /** + * @return List> + * @param: tdSelectDto + * @description 获取历史数据 + * @author xins + * @date 2023-08-29 15:50 + */ + List> getHistoryData(TdHistorySelectDto tdHistorySelectDto); + + int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto); + +// /** +// * 检查表是否存在 +// * @param dataBaseName +// * @param tableName 可以为超级表名或普通表名 +// * @return +// */ +// Integer checkTableExists(@Param("dataBaseName") String dataBaseName, @Param("tableName")String tableName); + + +// +// List> getRealtimeData(SelectVisualDto selectVisualDto); +// +// List> getAggregateData(SelectVisualDto selectVisualDto); + + + // void addTagForSuperTable(@Param("superTableName") String superTableName, +// @Param("fieldsVo") FieldsVo fieldsVo); +// +// void dropTagForSuperTable(@Param("superTableName") String superTableName, +// @Param("fieldsVo") FieldsVo fieldsVo); + +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/IDeviceStatusService.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/IDeviceStatusService.java new file mode 100644 index 00000000..7565c3e1 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/IDeviceStatusService.java @@ -0,0 +1,36 @@ +package com.hw.tdengine.service; + +import com.hw.tdengine.api.domain.DeviceStatus; + +import java.util.List; +import java.util.Map; + +public interface IDeviceStatusService { + + /** + * @param: DeviceStatus + * @description 获取时间范围内每天的在线设备 + * @author xins + * @date 2023-09-05 13:23 + * @return List + */ + public List getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus); + + /** + * @return List> + * @param: DeviceStatus + * @description 获取某个事件前最新的在线设备 + * @author xins + * @date 2023-09-05 13:23 + */ + public List> getLastOnlineDevices(DeviceStatus queryDeviceStatus); + + /** + * @return List> + * @param: DeviceStatus + * @description 获取设备状态信息列表 + * @author xins + * @date 2023-09-05 13:23 + */ + public List> getDeviceStatusList(DeviceStatus queryDeviceStatus); +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java new file mode 100644 index 00000000..0c2e219a --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java @@ -0,0 +1,142 @@ +package com.hw.tdengine.service; + +import com.hw.tdengine.api.domain.*; + +import java.util.List; +import java.util.Map; + +/** + * @InterfaceName: ITdEngineService + * @Author : xins + * @Date :2023-08-28 13:14 + * @Description: TdEngineService接口 + * @Version :1.0 + */ +public interface ITdEngineService { + + /** + * @param databaseName + * @description:创建数据库 + * @author xins + * @date 2023-08-28 11:32 + */ + public void createDatabase(String databaseName) throws Exception; + + /** + * @param databaseName + * @param superTableName + * @param firstFieldName + * @param schemaFields + * @param tagsFields + * @description 创建超级表 + * @author xins + * @date 2023-08-28 13:18 + */ + public void createSuperTable(String databaseName, String superTableName, String firstFieldName, List schemaFields, List tagsFields) throws Exception; + + /** + * @param: databaseName + * @param: superTableName + * @param: tableName + * @param: tagsFieldValues + * @description 创建子表 + * @author xins + * @date 2023-08-28 16:16 + */ + public void createTable(String databaseName, String superTableName, String tableName, List tagsFieldValues) throws Exception; + + /** + * @param: databaseName + * @param: superTableName + * @param: addFieldsVo + * @description 增加超级表的列 + * @author xins + * @date 2023-08-28 17:12 + */ + + public void addSuperTableColumn(String databaseName,String superTableName, TdFieldVo addFieldsVo) throws Exception; + + /** + * @param: databaseName + * @param: superTableName + * @param: modifyFieldsVo + * @description 修改超级表列宽(只适用于nchar类型) + * @author xins + * @date 2023-10-11 9:02 + */ + public void modifySuperTableColumn(String databaseName, String superTableName, TdFieldVo modifyFieldsVo) throws Exception; + + /** + * @param: databaseName + * @param: superTableName + * @param: dropFieldsVo + * @description 删除超级表的列 + * @author xins + * @date 2023-08-28 17:13 + */ + public void dropSuperTableColumn(String databaseName,String superTableName, TdField dropField) throws Exception; + + /** + * @param: databaseName + * @param: tableName + * @param: tagName + * @param: tagValue + * @description 修改子表的tagValue + * @author xins + * @date 2023-08-30 11:03 + */ + public void alterTableTag(String databaseName,String tableName,String tagName,Object tagValue); + /** + * @param: databaseName + * @param: tableName + * @param: schemaFields + * @description 插入数据 + * @author xins + * @date 2023-08-29 10:10 + */ + public void insertTable(String databaseName,String tableName,List schemaFields) throws Exception; + + /** + * @param: tdSelectDto + * @description 获取某个子表最新一条数据 + * @author xins + * @date 2023-08-29 11:28 + * @return List> + */ + public List> getLatestData(TdSelectDto tdSelectDto) throws Exception; + + /** + * @return List> + * @param: tdSelectDto + * @description 根据tagsname获取超级表最新信息,适用于设备汇总页面,先分页获取设备信息,再获取所有此物模型下的最新信息(冗余,但每页只获取一次,不需要每个设备都获取一次 + * * 如果需要根据时间周期获取最新的数据,则需要用select last_row() + * @author xins + * @date 2023-08-29 14:47 + */ + public List> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo); + + /** + * @param: tdHistorySelectDto + * @description 获取历史数据 + * @author xins + * @date 2023-08-29 15:52 + * @return List> + */ + public List> getHistoryData(TdHistorySelectDto tdHistorySelectDto); + + /** + * @param: tdHistorySelectDto + * @description 获取历史数据总数量 + * @author xins + * @date 2023-09-25 16:20 + * @return int + */ + public int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto); + + +// void initSTableFrame(String msg) throws Exception; + +// List> getRealtimeData(SelectVisualDto selectVisualDto); +// +// List> getAggregateData(SelectVisualDto selectVisualDto); +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/DeviceStatusServiceImpl.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/DeviceStatusServiceImpl.java new file mode 100644 index 00000000..c5c922a3 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/DeviceStatusServiceImpl.java @@ -0,0 +1,99 @@ +package com.hw.tdengine.service.impl; + +import com.hw.common.core.constant.TdEngineConstants; +import com.hw.tdengine.api.domain.DeviceStatus; +import com.hw.tdengine.mapper.DeviceStatusMapper; +import com.hw.tdengine.service.IDeviceStatusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * @Description: 设备状态信息业务服务 + * @ClassName: DeviceStatusServiceImpl + * @Author : xins + * @Date :2023-09-05 13:27 + * @Version :1.0 + */ +@Service +public class DeviceStatusServiceImpl implements IDeviceStatusService { + + @Autowired + private DeviceStatusMapper deviceStatusMapper; + + /** + * @return List + * @param: DeviceStatus + * @description 获取时间范围内每天的在线设备 + * @author xins + * @date 2023-09-05 13:23 + */ + @Override + public List getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus) { + + Map params = queryDeviceStatus.getParams(); + params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME); + params.put("superTableName", TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME); +// DeviceStatus queryDeviceStatus = new DeviceStatus(); +// params.put("beginTime", beginTime); +// params.put("endTime", endTime); +// queryDeviceStatus.setParams(params); +// if (sceneId != null) { +// queryDeviceStatus.setSceneId(sceneId); +// } + + List deviceStatuses = deviceStatusMapper.getOnlineDevicesGroupByDay(queryDeviceStatus); + + return deviceStatuses; + } + + + /** + * @return List> + * @param: DeviceStatus + * @description 获取某个事件前最新的在线设备 + * @author xins + * @date 2023-09-05 13:23 + */ + @Override + public List> getLastOnlineDevices(DeviceStatus queryDeviceStatus) { + + Map params = queryDeviceStatus.getParams(); + params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME); + params.put("superTableName", TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME); + List> deviceStatusMap = deviceStatusMapper.getLastOnlineDevices(queryDeviceStatus); + List> filterMaps = new ArrayList<>(); + + //tdengine,在select时row会带着括号,需要将括号过滤掉 + for (Map latestMap : deviceStatusMap) { + Map filterMap = latestMap.entrySet() + .stream() + .filter(entry -> entry.getValue() != null) + .collect(HashMap::new, (m, v) -> + m.put(v.getKey().substring(v.getKey().indexOf("(") + 1, + v.getKey().indexOf(")")), v.getValue()), HashMap::putAll); + filterMaps.add(filterMap); + } + + return filterMaps; + } + + + /** + * @return List> + * @param: DeviceStatus + * @description 获取设备状态信息列表 + * @author xins + * @date 2023-09-05 13:23 + */ + @Override + public List> getDeviceStatusList(DeviceStatus queryDeviceStatus) { + Map params = queryDeviceStatus.getParams(); + params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME); + params.put("tableName", TdEngineConstants.getDeviceStatusTableName(queryDeviceStatus.getDeviceId())); + List> deviceStatusMap = deviceStatusMapper.getDeviceStatusList(queryDeviceStatus); + return deviceStatusMap; + } + +} diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java new file mode 100644 index 00000000..e25621a5 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java @@ -0,0 +1,314 @@ +package com.hw.tdengine.service.impl; + +import com.hw.tdengine.api.domain.*; +import com.hw.tdengine.mapper.TdEngineMapper; +import com.hw.tdengine.service.ITdEngineService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * @ClassDescription: TdEngine业务实现逻辑 + * @ClassName: TdEngineServiceImpl + * @Author: xins + * @Date: 2023-08-25 15:55:50 + * @Version 1.0 + */ +@Service +//@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) +public class TdEngineServiceImpl implements ITdEngineService { + private static final String DEFAULT_FIRST_FIELD_NAME = "ts"; + + @Autowired + private TdEngineMapper tdEngineMapper; + +// @Autowired +// private RedisService redisService; + + /** + * @param databaseName + * @description:创建数据库 + * @author xins + * @date 2023-08-28 11:32 + */ + @Override + public void createDatabase(String databaseName) throws Exception { + this.tdEngineMapper.createDatabase(databaseName); + } + + /** + * @param databaseName + * @param superTableName + * @param firstFieldName + * @param schemaFields + * @param tagsFields + * @description 创建超级表 + * @author xins + * @date 2023-08-28 13:18 + */ + @Override + public void createSuperTable(String databaseName, String superTableName, String firstFieldName, List schemaFields, List tagsFields) throws Exception { + if (StringUtils.isBlank(firstFieldName)) { + firstFieldName = DEFAULT_FIRST_FIELD_NAME; + } + this.tdEngineMapper.createSuperTable(databaseName, superTableName, firstFieldName, schemaFields, tagsFields); + } + + /** + * @param: databaseName + * @param: superTableName + * @param: tableName + * @param: tagsFieldValues + * @description 创建子表 + * @author xins + * @date 2023-08-28 16:16 + */ + @Override + public void createTable(String databaseName, String superTableName, String tableName, List tagsFieldValues) throws Exception { + this.tdEngineMapper.createTable(databaseName, superTableName, tableName, tagsFieldValues); + + } + + + /** + * @param: databaseName + * @param: superTableName + * @param: addFieldsVo + * @description 增加超级表的列 + * @author xins + * @date 2023-08-28 17:12 + */ + @Override + public void addSuperTableColumn(String databaseName, String superTableName, TdFieldVo addFieldsVo) throws Exception { + this.tdEngineMapper.addSuperTableColumn(databaseName, superTableName, addFieldsVo); + } + + /** + * @param: databaseName + * @param: superTableName + * @param: modifyFieldsVo + * @description 修改超级表列宽(只适用于nchar类型) + * @author xins + * @date 2023-10-11 9:02 + */ + @Override + public void modifySuperTableColumn(String databaseName, String superTableName, TdFieldVo modifyFieldsVo) throws Exception { + this.tdEngineMapper.modifySuperTableColumn(databaseName, superTableName, modifyFieldsVo); + } + + + /** + * @param: databaseName + * @param: superTableName + * @param: dropFieldsVo + * @description 删除超级表的列 + * @author xins + * @date 2023-08-28 17:13 + */ + public void dropSuperTableColumn(String databaseName, String superTableName, TdField dropField) throws Exception { + this.tdEngineMapper.dropSuperTableColumn(databaseName, superTableName, dropField); + } + + /** + * @param: databaseName + * @param: tableName + * @param: tagName + * @param: tagValue + * @description 修改子表的tagValue + * @author xins + * @date 2023-08-30 11:03 + */ + @Override + public void alterTableTag(String databaseName, String tableName, String tagName, Object tagValue) { + this.tdEngineMapper.alterTableTag(databaseName, tableName, tagName, tagValue); + } + + /** + * @param: databaseName + * @param: tableName + * @param: schemaFields + * @description 插入数据 + * @author xins + * @date 2023-08-29 10:10 + */ + @Override + public void insertTable(String databaseName, String tableName, List schemaFields) throws Exception { + this.tdEngineMapper.insertTable(databaseName, tableName, schemaFields); + } + + /** + * @return List> + * @param: tdSelectDto + * @description 查询具体某个子表最新数据,适用于设备监测页面,先根据监控单元获取设备信息,再根据设备来获取最新的数据 + * @author xins + * @date 2023-08-29 11:28 + */ + @Override + public List> getLatestData(TdSelectDto tdSelectDto) throws Exception { + List> latestMaps = this.tdEngineMapper.getLatestData(tdSelectDto); + + List> filterMaps = new ArrayList<>(); + +// String i18nKey = "tdengine_supertable1_"; + String i18nKey = "";//todo:国际化看在哪处理 + /** + * 由于通过last(*)获取则获取的key为last(key),所以需要以下过滤,需要获取括号中间的真正key + */ + for (Map latestMap : latestMaps) { + Map filterMap = latestMap.entrySet() + .stream() + .filter(entry -> entry.getValue() != null) + .collect(HashMap::new, (m, v) -> + m.put(i18nKey + v.getKey().substring(v.getKey().indexOf("(") + 1, + v.getKey().indexOf(")")), v.getValue()), HashMap::putAll); + filterMaps.add(filterMap); + } + return filterMaps; + } + + /** + * @return List> + * @param: tdSelectDto + * @description 根据tagsname获取超级表最新信息,适用于设备汇总页面,先分页获取设备信息,再获取所有此物模型下的最新信息(冗余,但每页只获取一次,不需要每个设备都获取一次 + * * 如果需要根据时间周期获取最新的数据,则需要用select last_row() + * @author xins + * @date 2023-08-29 14:47 + */ + @Override + public List> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo) { + List> latestMaps = this.tdEngineMapper.getLatestDataByTags(tdSuperTableSelectVo); + latestMaps.replaceAll(latestMap -> { + return latestMap.entrySet() + .stream() + .filter(entry -> entry.getValue() != null) + .collect(HashMap::new, (m, v) -> + m.put(v.getKey().substring(v.getKey().indexOf("(") + 1, + v.getKey().indexOf(")")), v.getValue()), HashMap::putAll); + }); + // Map> tagsMap = new HashMap<>(); +// for (Map latestMap : latestMaps) { +// Map filterMap = latestMap.entrySet() +// .stream() +// .filter(entry -> entry.getValue() != null) +// .collect(HashMap::new, (m, v) -> +// m.put(v.getKey().substring(v.getKey().indexOf("(") + 1, +// v.getKey().indexOf(")")), v.getValue()), HashMap::putAll); +// tagsMap.put(filterMap.get(tdSuperTableSelectVo.getTagsName()).toString(), filterMap); +// } + return latestMaps; + } + + + /** + * @return List> + * @param: tdHistorySelectDto + * @description 获取历史数据 + * @author xins + * @date 2023-08-29 15:52 + */ + @Override + public List> getHistoryData(TdHistorySelectDto tdHistorySelectDto) { +// if (StringUtils.isBlank(tdHistorySelectDto.getOrderByFieldName())) { +// tdHistorySelectDto.setOrderByFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); +// } +// if (StringUtils.isBlank(tdHistorySelectDto.getOrderByMode())) { +// tdHistorySelectDto.setOrderByMode(TdEngineConstants.DEFAULT_ORDER_BY_MODE); +// } + + List> historyDataMaps = this.tdEngineMapper.getHistoryData(tdHistorySelectDto); + + return historyDataMaps; + } + + /** + * @param: tdHistorySelectDto + * @description 获取历史数据总数量 + * @author xins + * @date 2023-09-25 16:20 + * @return int + */ + @Override + public int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto){ + int count = this.tdEngineMapper.getCountOfHistoryData(tdHistorySelectDto); + return count; + } +// +// /** +// * 检查数据库表是否存在 +// * +// * @param dataBaseName 数据库名 +// * @param tableName tableName 可以为超级表名或普通表名 +// * @return +// */ +// public boolean checkTableExists(String dataBaseName, String tableName) throws Exception { +// try { +// Integer count = tdEngineMapper.checkTableExists(dataBaseName, tableName); +// return count == 1; +// } catch (Exception e) { +// log.warn("{},{} 数据库表不存在", dataBaseName, tableName); +// return false; +// } +// } +// +// @Override +// public void initSTableFrame(String msg) throws Exception { +// final SuperTableDto superTableDto = JSONObject.toJavaObject(JSONObject.parseObject(msg), SuperTableDto.class); +// //从入参对象获取列字段(超级表结构)对象集合 +// List schemaFields = superTableDto.getSchemaFields(); +// //从入参对象获取标签字段对象集合 +// List tagsFields = superTableDto.getTagsFields(); +// //从入参获取数据库名称 +// String dataBaseName = superTableDto.getDataBaseName(); +// //从入参获取超级表名称 +// String superTableName = superTableDto.getSuperTableName(); +// final boolean tableExists = this.checkTableExists(dataBaseName, superTableName); +// if (tableExists) { +// log.info("超级表{}已存在", superTableName); +// return; +// } +// //获取列字段对象集合的第一个对象的字段数据类型 +// DataTypeEnum dataType = schemaFields.get(0).getDataType(); +// //如果该数据类型不是时间戳,打印和返回报错信息 +// if (dataType == null || !"timestamp".equals(dataType.getDataType())) { +// log.error("invalid operation: first column must be timestamp"); +// return; +// } +// //将列字段对象集合和标签字段对象集合转码为字段Vo类对象集合 +// List schemaFieldsVoList = FieldsVo.fieldsTranscoding(schemaFields); +// List tagsFieldsVoList = FieldsVo.fieldsTranscoding(tagsFields); +// //创建超级表 +// this.createSuperTable(schemaFieldsVoList, tagsFieldsVoList, dataBaseName, superTableName); +// log.info("create {} super table success", superTableName); +// } +// + +// +// /** +// * @param tagsSelectDao +// * @return +// */ +// @Override + +// +// + +// +// @Override +// public List> getRealtimeData(SelectVisualDto selectVisualDto) { +// List> maps = this.tdEngineMapper.getRealtimeData(selectVisualDto); +// return maps; +// } +// +// @Override +// public List> getAggregateData(SelectVisualDto selectVisualDto) { +// List> maps = this.tdEngineMapper.getAggregateData(selectVisualDto); +// return maps; +// } + +} diff --git a/hw-modules/hw-tdengine/src/main/resources/banner.txt b/hw-modules/hw-tdengine/src/main/resources/banner.txt new file mode 100644 index 00000000..fbd45f53 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ _ + (_) | | + _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___ +| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ +| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | | +|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_| + __/ | __/ | + |___/ |___/ \ No newline at end of file diff --git a/hw-modules/hw-tdengine/src/main/resources/bootstrap.yml b/hw-modules/hw-tdengine/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..5119aeb0 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 7302 + +# Spring +spring: + application: + # 应用名称 + name: hw-tdengine + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP + config: + # 配置中心地址 + server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/hw-modules/hw-tdengine/src/main/resources/logback.xml b/hw-modules/hw-tdengine/src/main/resources/logback.xml new file mode 100644 index 00000000..147e3988 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/DeviceStatusMapper.xml b/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/DeviceStatusMapper.xml new file mode 100644 index 00000000..c197ee35 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/DeviceStatusMapper.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + diff --git a/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml b/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml new file mode 100644 index 00000000..dd81aa81 --- /dev/null +++ b/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml @@ -0,0 +1,329 @@ + + + + + + create database if not exists #{databaseName} + + + + create table if not exists #{databaseName}.#{superTableName} + (${firstFieldName} timestamp, + + + + ${item.fieldName} + + + + + timestamp + + + tinyint + + + smallint + + + int + + + bigint + + + float + + + double + + + binary + + + nchar + + + bool + + + json + + + + + + (#{item.size}) + + + ) tags + + + + ${item.fieldName} + + + + + timestamp + + + int + + + bigint + + + float + + + double + + + binary + + + smallint + + + tinyint + + + bool + + + nchar + + + json + + + + + (#{item.size}) + + + + + + create table if not exists #{databaseName}.#{tableName} + using #{databaseName}.#{superTableName} + ${item.fieldName} + tags + #{item.fieldValue} + + + + + + ALTER STABLE #{databaseName}.#{superTableName} ADD COLUMN + + ${addFieldsVo.fieldName} + + + + + timestamp + + + int + + + bigint + + + float + + + double + + + binary + + + smallint + + + tinyint + + + bool + + + nchar + + + json + + + + + (#{addFieldsVo.size}) + + + + + + + ALTER STABLE #{databaseName}.#{superTableName} modify COLUMN + + ${modifyFieldsVo.fieldName} nchar(#{modifyFieldsVo.size}) + + + + + + + + ALTER STABLE #{databaseName}.#{superTableName} DROP COLUMN + + ${dropField.fieldName} + + + + + ALTER TABLE #{databaseName}.#{tableName} SET TAG #{tagName}=${tagValue}; + + + + + + + insert into #{databaseName}.#{tableName} ${item.fieldName} values #{item.fieldValue} + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hw-modules/hw-wms/pom.xml b/hw-modules/hw-wms/pom.xml new file mode 100644 index 00000000..83210c96 --- /dev/null +++ b/hw-modules/hw-wms/pom.xml @@ -0,0 +1,100 @@ + + + + com.hw + hw-modules + 3.6.3 + + 4.0.0 + + hw-modules-wms + + + hw-modules-wms仓储模块 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.hw + hw-common-datasource + + + + + com.hw + hw-common-datascope + + + + + com.hw + hw-common-log + + + + + com.hw + hw-common-swagger + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/HwWmsApplication.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/HwWmsApplication.java new file mode 100644 index 00000000..169e6bcc --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/HwWmsApplication.java @@ -0,0 +1,34 @@ +package com.hw.wms; + +import com.hw.common.security.annotation.EnableCustomConfig; +import com.hw.common.security.annotation.EnableRyFeignClients; +import com.hw.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 系统模块 + * + * @author xins + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@SpringBootApplication +public class HwWmsApplication +{ + public static void main(String[] args) + { + SpringApplication.run(HwWmsApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 仓储模块启动成功 ლ(´ڡ`ლ)゙ \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsRawOutstockController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsRawOutstockController.java new file mode 100644 index 00000000..647ed333 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsRawOutstockController.java @@ -0,0 +1,105 @@ +package com.hw.wms.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.hw.common.log.annotation.Log; +import com.hw.common.log.enums.BusinessType; +import com.hw.common.security.annotation.RequiresPermissions; +import com.hw.wms.domain.WmsRawOutstock; +import com.hw.wms.service.IWmsRawOutstockService; +import com.hw.common.core.web.controller.BaseController; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.core.utils.poi.ExcelUtil; +import com.hw.common.core.web.page.TableDataInfo; + +/** + * 原材料出库记录Controller + * + * @author xs + * @date 2023-12-20 + */ +@RestController +@RequestMapping("/rawoutstock") +public class WmsRawOutstockController extends BaseController +{ + @Autowired + private IWmsRawOutstockService wmsRawOutstockService; + + /** + * 查询原材料出库记录列表 + */ + @RequiresPermissions("wms:rawoutstock:list") + @GetMapping("/list") + public TableDataInfo list(WmsRawOutstock wmsRawOutstock) + { + startPage(); + List list = wmsRawOutstockService.selectWmsRawOutstockList(wmsRawOutstock); + return getDataTable(list); + } + + /** + * 导出原材料出库记录列表 + */ + @RequiresPermissions("wms:rawoutstock:export") + @Log(title = "原材料出库记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, WmsRawOutstock wmsRawOutstock) + { + List list = wmsRawOutstockService.selectWmsRawOutstockList(wmsRawOutstock); + ExcelUtil util = new ExcelUtil(WmsRawOutstock.class); + util.exportExcel(response, list, "原材料出库记录数据"); + } + + /** + * 获取原材料出库记录详细信息 + */ + @RequiresPermissions("wms:rawoutstock:query") + @GetMapping(value = "/{rawOutstockId}") + public AjaxResult getInfo(@PathVariable("rawOutstockId") Long rawOutstockId) + { + return success(wmsRawOutstockService.selectWmsRawOutstockByRawOutstockId(rawOutstockId)); + } + + /** + * 新增原材料出库记录 + */ + @RequiresPermissions("wms:rawoutstock:add") + @Log(title = "原材料出库记录", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody WmsRawOutstock wmsRawOutstock) + { + return toAjax(wmsRawOutstockService.insertWmsRawOutstock(wmsRawOutstock)); + } + + /** + * 修改原材料出库记录 + */ + @RequiresPermissions("wms:rawoutstock:edit") + @Log(title = "原材料出库记录", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody WmsRawOutstock wmsRawOutstock) + { + return toAjax(wmsRawOutstockService.updateWmsRawOutstock(wmsRawOutstock)); + } + + /** + * 删除原材料出库记录 + */ + @RequiresPermissions("wms:rawoutstock:remove") + @Log(title = "原材料出库记录", businessType = BusinessType.DELETE) + @DeleteMapping("/{rawOutstockIds}") + public AjaxResult remove(@PathVariable Long[] rawOutstockIds) + { + return toAjax(wmsRawOutstockService.deleteWmsRawOutstockByRawOutstockIds(rawOutstockIds)); + } +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java new file mode 100644 index 00000000..f3a1bfe3 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java @@ -0,0 +1,354 @@ +package com.hw.wms.domain; + +import java.util.List; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 原材料出库记录对象 wms_raw_outstock + * + * @author xs + * @date 2023-12-20 + */ +public class WmsRawOutstock extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 原材料出库记录ID */ + private Long rawOutstockId; + + /** 任务编号;移库时必须 */ + @Excel(name = "任务编号;移库时必须") + private String taskCode; + + /** 仓库ID;领料时需要保存 */ + @Excel(name = "仓库ID;领料时需要保存") + private Long warehouseId; + + /** 库位编码;移库和合库时需要保存 */ + @Excel(name = "库位编码;移库和合库时需要保存") + private String locationCode; + + /** 工单ID,关联pd_base_order_info的order_id */ + @Excel(name = "工单ID,关联pd_base_order_info的order_id") + private Long orderId; + + /** 计划ID,关联pd_base_plan_info的plan_id */ + @Excel(name = "计划ID,关联pd_base_plan_info的plan_id") + private Long planId; + + /** 计划明细ID,关联pd_base_plan_detail的plan_detail_id */ + @Excel(name = "计划明细ID,关联pd_base_plan_detail的plan_detail_id") + private Long planDetailId; + + /** 所属工位,关联pd_base_station_info的station_id */ + @Excel(name = "所属工位,关联pd_base_station_info的station_id") + private Long stationId; + + /** 成品ID,关联物料表物料id */ + @Excel(name = "成品ID,关联物料表物料id") + private Long productId; + + /** 操作类型(0自动,1手动,2强制,3调度) */ + @Excel(name = "操作类型(0自动,1手动,2强制,3调度)") + private String operationType; + + /** 任务类型(1生产领料,2移库出库,3合库出库,9其他领料) */ + @Excel(name = "任务类型(1生产领料,2移库出库,3合库出库,9其他领料)") + private String taskType; + + /** 申请原因 */ + @Excel(name = "申请原因") + private String applyReason; + + /** 审核原因 */ + @Excel(name = "审核原因") + private String auditReason; + + /** 审核状态(0待审核,1审核通过,2审核未通过) */ + @Excel(name = "审核状态(0待审核,1审核通过,2审核未通过)") + private String auditStatus; + + /** 执行状态(0待执行,1执行中,2执行完成) */ + @Excel(name = "执行状态(0待执行,1执行中,2执行完成)") + private String executeStatus; + + /** 申请人 */ + @Excel(name = "申请人") + private String applyBy; + + /** 申请时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date applyDate; + + /** 审核人 */ + @Excel(name = "审核人") + private String auditBy; + + /** 审核时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date auditDate; + + /** 最后更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date updateDate; + + /** 执行开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "执行开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date beginTime; + + /** 执行结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "执行结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 原材料出库记录明细信息 */ + private List wmsRawOutstockDetailList; + + public void setRawOutstockId(Long rawOutstockId) + { + this.rawOutstockId = rawOutstockId; + } + + public Long getRawOutstockId() + { + return rawOutstockId; + } + public void setTaskCode(String taskCode) + { + this.taskCode = taskCode; + } + + public String getTaskCode() + { + return taskCode; + } + public void setWarehouseId(Long warehouseId) + { + this.warehouseId = warehouseId; + } + + public Long getWarehouseId() + { + return warehouseId; + } + public void setLocationCode(String locationCode) + { + this.locationCode = locationCode; + } + + public String getLocationCode() + { + return locationCode; + } + public void setOrderId(Long orderId) + { + this.orderId = orderId; + } + + public Long getOrderId() + { + return orderId; + } + public void setPlanId(Long planId) + { + this.planId = planId; + } + + public Long getPlanId() + { + return planId; + } + public void setPlanDetailId(Long planDetailId) + { + this.planDetailId = planDetailId; + } + + public Long getPlanDetailId() + { + return planDetailId; + } + public void setStationId(Long stationId) + { + this.stationId = stationId; + } + + public Long getStationId() + { + return stationId; + } + public void setProductId(Long productId) + { + this.productId = productId; + } + + public Long getProductId() + { + return productId; + } + public void setOperationType(String operationType) + { + this.operationType = operationType; + } + + public String getOperationType() + { + return operationType; + } + public void setTaskType(String taskType) + { + this.taskType = taskType; + } + + public String getTaskType() + { + return taskType; + } + public void setApplyReason(String applyReason) + { + this.applyReason = applyReason; + } + + public String getApplyReason() + { + return applyReason; + } + public void setAuditReason(String auditReason) + { + this.auditReason = auditReason; + } + + public String getAuditReason() + { + return auditReason; + } + public void setAuditStatus(String auditStatus) + { + this.auditStatus = auditStatus; + } + + public String getAuditStatus() + { + return auditStatus; + } + public void setExecuteStatus(String executeStatus) + { + this.executeStatus = executeStatus; + } + + public String getExecuteStatus() + { + return executeStatus; + } + public void setApplyBy(String applyBy) + { + this.applyBy = applyBy; + } + + public String getApplyBy() + { + return applyBy; + } + public void setApplyDate(Date applyDate) + { + this.applyDate = applyDate; + } + + public Date getApplyDate() + { + return applyDate; + } + public void setAuditBy(String auditBy) + { + this.auditBy = auditBy; + } + + public String getAuditBy() + { + return auditBy; + } + public void setAuditDate(Date auditDate) + { + this.auditDate = auditDate; + } + + public Date getAuditDate() + { + return auditDate; + } + public void setUpdateDate(Date updateDate) + { + this.updateDate = updateDate; + } + + public Date getUpdateDate() + { + return updateDate; + } + public void setBeginTime(Date beginTime) + { + this.beginTime = beginTime; + } + + public Date getBeginTime() + { + return beginTime; + } + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + + public List getWmsRawOutstockDetailList() + { + return wmsRawOutstockDetailList; + } + + public void setWmsRawOutstockDetailList(List wmsRawOutstockDetailList) + { + this.wmsRawOutstockDetailList = wmsRawOutstockDetailList; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("rawOutstockId", getRawOutstockId()) + .append("taskCode", getTaskCode()) + .append("warehouseId", getWarehouseId()) + .append("locationCode", getLocationCode()) + .append("orderId", getOrderId()) + .append("planId", getPlanId()) + .append("planDetailId", getPlanDetailId()) + .append("stationId", getStationId()) + .append("productId", getProductId()) + .append("operationType", getOperationType()) + .append("taskType", getTaskType()) + .append("applyReason", getApplyReason()) + .append("auditReason", getAuditReason()) + .append("auditStatus", getAuditStatus()) + .append("executeStatus", getExecuteStatus()) + .append("applyBy", getApplyBy()) + .append("applyDate", getApplyDate()) + .append("auditBy", getAuditBy()) + .append("auditDate", getAuditDate()) + .append("updateBy", getUpdateBy()) + .append("updateDate", getUpdateDate()) + .append("beginTime", getBeginTime()) + .append("endTime", getEndTime()) + .append("wmsRawOutstockDetailList", getWmsRawOutstockDetailList()) + .toString(); + } +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java new file mode 100644 index 00000000..b70f1902 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java @@ -0,0 +1,298 @@ +package com.hw.wms.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 原材料出库记录明细对象 wms_raw_outstock_detail + * + * @author xs + * @date 2023-12-20 + */ +public class WmsRawOutstockDetail extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 原材料出库记录明细ID */ + private Long rawOutstockDetailId; + + /** 原材料出库ID */ + @Excel(name = "原材料出库ID") + private Long rawOutstockId; + + /** 库位编码 */ + @Excel(name = "库位编码") + private String locationCode; + + /** 物料条码 */ + @Excel(name = "物料条码") + private String materialBarcode; + + /** 物料ID */ + @Excel(name = "物料ID") + private Long materialId; + + /** 批次;扫描条码时,从打印条码记录表中获取 */ + @Excel(name = "批次;扫描条码时,从打印条码记录表中获取") + private String instockBatch; + + /** 生产日期;扫描条码时,从打印条码记录表中获取 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "生产日期;扫描条码时,从打印条码记录表中获取", width = 30, dateFormat = "yyyy-MM-dd") + private Date materialProductionDate; + + /** 计划数量 */ + @Excel(name = "计划数量") + private BigDecimal planAmount; + + /** 出库数量 */ + @Excel(name = "出库数量") + private BigDecimal outstockAmount; + + /** 执行状态(0待执行,1执行中,2执行完成) */ + @Excel(name = "执行状态(0待执行,1执行中,2执行完成)") + private String executeStatus; + + /** 同步ERP状态(0:失败,1成功) */ + @Excel(name = "同步ERP状态(0:失败,1成功)") + private String erpStatus; + + /** 出库人 */ + @Excel(name = "出库人") + private String outstockPerson; + + /** 出库时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "出库时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date outstockTime; + + /** 出库方式( 0:PC出库 1:手持出库 2:AGV出库 ) */ + @Excel(name = "出库方式", readConverterExp = "0=:PC出库,1=:手持出库,2=:AGV出库") + private String outstockWay; + + /** 使用机台名称;出库扫描条码时,从打印条码记录表中获取 */ + @Excel(name = "使用机台名称;出库扫描条码时,从打印条码记录表中获取") + private String machineName; + + /** 质检状态(0:待质检,1:合格,2:NG) */ + @Excel(name = "质检状态(0:待质检,1:合格,2:NG)") + private String qualityStatus; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createDate; + + /** 最后更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date updateDate; + + /** 每托数量 */ + @Excel(name = "每托数量") + private BigDecimal stackAmount; + + public void setRawOutstockDetailId(Long rawOutstockDetailId) + { + this.rawOutstockDetailId = rawOutstockDetailId; + } + + public Long getRawOutstockDetailId() + { + return rawOutstockDetailId; + } + public void setRawOutstockId(Long rawOutstockId) + { + this.rawOutstockId = rawOutstockId; + } + + public Long getRawOutstockId() + { + return rawOutstockId; + } + public void setLocationCode(String locationCode) + { + this.locationCode = locationCode; + } + + public String getLocationCode() + { + return locationCode; + } + public void setMaterialBarcode(String materialBarcode) + { + this.materialBarcode = materialBarcode; + } + + public String getMaterialBarcode() + { + return materialBarcode; + } + public void setMaterialId(Long materialId) + { + this.materialId = materialId; + } + + public Long getMaterialId() + { + return materialId; + } + public void setInstockBatch(String instockBatch) + { + this.instockBatch = instockBatch; + } + + public String getInstockBatch() + { + return instockBatch; + } + public void setMaterialProductionDate(Date materialProductionDate) + { + this.materialProductionDate = materialProductionDate; + } + + public Date getMaterialProductionDate() + { + return materialProductionDate; + } + public void setPlanAmount(BigDecimal planAmount) + { + this.planAmount = planAmount; + } + + public BigDecimal getPlanAmount() + { + return planAmount; + } + public void setOutstockAmount(BigDecimal outstockAmount) + { + this.outstockAmount = outstockAmount; + } + + public BigDecimal getOutstockAmount() + { + return outstockAmount; + } + public void setExecuteStatus(String executeStatus) + { + this.executeStatus = executeStatus; + } + + public String getExecuteStatus() + { + return executeStatus; + } + public void setErpStatus(String erpStatus) + { + this.erpStatus = erpStatus; + } + + public String getErpStatus() + { + return erpStatus; + } + public void setOutstockPerson(String outstockPerson) + { + this.outstockPerson = outstockPerson; + } + + public String getOutstockPerson() + { + return outstockPerson; + } + public void setOutstockTime(Date outstockTime) + { + this.outstockTime = outstockTime; + } + + public Date getOutstockTime() + { + return outstockTime; + } + public void setOutstockWay(String outstockWay) + { + this.outstockWay = outstockWay; + } + + public String getOutstockWay() + { + return outstockWay; + } + public void setMachineName(String machineName) + { + this.machineName = machineName; + } + + public String getMachineName() + { + return machineName; + } + public void setQualityStatus(String qualityStatus) + { + this.qualityStatus = qualityStatus; + } + + public String getQualityStatus() + { + return qualityStatus; + } + public void setCreateDate(Date createDate) + { + this.createDate = createDate; + } + + public Date getCreateDate() + { + return createDate; + } + public void setUpdateDate(Date updateDate) + { + this.updateDate = updateDate; + } + + public Date getUpdateDate() + { + return updateDate; + } + public void setStackAmount(BigDecimal stackAmount) + { + this.stackAmount = stackAmount; + } + + public BigDecimal getStackAmount() + { + return stackAmount; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("rawOutstockDetailId", getRawOutstockDetailId()) + .append("rawOutstockId", getRawOutstockId()) + .append("locationCode", getLocationCode()) + .append("materialBarcode", getMaterialBarcode()) + .append("materialId", getMaterialId()) + .append("instockBatch", getInstockBatch()) + .append("materialProductionDate", getMaterialProductionDate()) + .append("planAmount", getPlanAmount()) + .append("outstockAmount", getOutstockAmount()) + .append("executeStatus", getExecuteStatus()) + .append("erpStatus", getErpStatus()) + .append("outstockPerson", getOutstockPerson()) + .append("outstockTime", getOutstockTime()) + .append("outstockWay", getOutstockWay()) + .append("machineName", getMachineName()) + .append("qualityStatus", getQualityStatus()) + .append("createBy", getCreateBy()) + .append("createDate", getCreateDate()) + .append("updateBy", getUpdateBy()) + .append("updateDate", getUpdateDate()) + .append("stackAmount", getStackAmount()) + .toString(); + } +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java new file mode 100644 index 00000000..77dd77d7 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java @@ -0,0 +1,87 @@ +package com.hw.wms.mapper; + +import java.util.List; +import com.hw.wms.domain.WmsRawOutstock; +import com.hw.wms.domain.WmsRawOutstockDetail; + +/** + * 原材料出库记录Mapper接口 + * + * @author xs + * @date 2023-12-20 + */ +public interface WmsRawOutstockMapper +{ + /** + * 查询原材料出库记录 + * + * @param rawOutstockId 原材料出库记录主键 + * @return 原材料出库记录 + */ + public WmsRawOutstock selectWmsRawOutstockByRawOutstockId(Long rawOutstockId); + + /** + * 查询原材料出库记录列表 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 原材料出库记录集合 + */ + public List selectWmsRawOutstockList(WmsRawOutstock wmsRawOutstock); + + /** + * 新增原材料出库记录 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 结果 + */ + public int insertWmsRawOutstock(WmsRawOutstock wmsRawOutstock); + + /** + * 修改原材料出库记录 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 结果 + */ + public int updateWmsRawOutstock(WmsRawOutstock wmsRawOutstock); + + /** + * 删除原材料出库记录 + * + * @param rawOutstockId 原材料出库记录主键 + * @return 结果 + */ + public int deleteWmsRawOutstockByRawOutstockId(Long rawOutstockId); + + /** + * 批量删除原材料出库记录 + * + * @param rawOutstockIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWmsRawOutstockByRawOutstockIds(Long[] rawOutstockIds); + + /** + * 批量删除原材料出库记录明细 + * + * @param rawOutstockIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWmsRawOutstockDetailByRawOutstockIds(Long[] rawOutstockIds); + + /** + * 批量新增原材料出库记录明细 + * + * @param wmsRawOutstockDetailList 原材料出库记录明细列表 + * @return 结果 + */ + public int batchWmsRawOutstockDetail(List wmsRawOutstockDetailList); + + + /** + * 通过原材料出库记录主键删除原材料出库记录明细信息 + * + * @param rawOutstockId 原材料出库记录ID + * @return 结果 + */ + public int deleteWmsRawOutstockDetailByRawOutstockId(Long rawOutstockId); +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java new file mode 100644 index 00000000..1ebdbe97 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawOutstockService.java @@ -0,0 +1,61 @@ +package com.hw.wms.service; + +import java.util.List; +import com.hw.wms.domain.WmsRawOutstock; + +/** + * 原材料出库记录Service接口 + * + * @author xs + * @date 2023-12-20 + */ +public interface IWmsRawOutstockService +{ + /** + * 查询原材料出库记录 + * + * @param rawOutstockId 原材料出库记录主键 + * @return 原材料出库记录 + */ + public WmsRawOutstock selectWmsRawOutstockByRawOutstockId(Long rawOutstockId); + + /** + * 查询原材料出库记录列表 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 原材料出库记录集合 + */ + public List selectWmsRawOutstockList(WmsRawOutstock wmsRawOutstock); + + /** + * 新增原材料出库记录 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 结果 + */ + public int insertWmsRawOutstock(WmsRawOutstock wmsRawOutstock); + + /** + * 修改原材料出库记录 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 结果 + */ + public int updateWmsRawOutstock(WmsRawOutstock wmsRawOutstock); + + /** + * 批量删除原材料出库记录 + * + * @param rawOutstockIds 需要删除的原材料出库记录主键集合 + * @return 结果 + */ + public int deleteWmsRawOutstockByRawOutstockIds(Long[] rawOutstockIds); + + /** + * 删除原材料出库记录信息 + * + * @param rawOutstockId 原材料出库记录主键 + * @return 结果 + */ + public int deleteWmsRawOutstockByRawOutstockId(Long rawOutstockId); +} diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java new file mode 100644 index 00000000..0dc53551 --- /dev/null +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java @@ -0,0 +1,131 @@ +package com.hw.wms.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.ArrayList; +import com.hw.common.core.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import com.hw.wms.domain.WmsRawOutstockDetail; +import com.hw.wms.mapper.WmsRawOutstockMapper; +import com.hw.wms.domain.WmsRawOutstock; +import com.hw.wms.service.IWmsRawOutstockService; + +/** + * 原材料出库记录Service业务层处理 + * + * @author xs + * @date 2023-12-20 + */ +@Service +public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService +{ + @Autowired + private WmsRawOutstockMapper wmsRawOutstockMapper; + + /** + * 查询原材料出库记录 + * + * @param rawOutstockId 原材料出库记录主键 + * @return 原材料出库记录 + */ + @Override + public WmsRawOutstock selectWmsRawOutstockByRawOutstockId(Long rawOutstockId) + { + return wmsRawOutstockMapper.selectWmsRawOutstockByRawOutstockId(rawOutstockId); + } + + /** + * 查询原材料出库记录列表 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 原材料出库记录 + */ + @Override + public List selectWmsRawOutstockList(WmsRawOutstock wmsRawOutstock) + { + return wmsRawOutstockMapper.selectWmsRawOutstockList(wmsRawOutstock); + } + + /** + * 新增原材料出库记录 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 结果 + */ + @Transactional + @Override + public int insertWmsRawOutstock(WmsRawOutstock wmsRawOutstock) + { + int rows = wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock); + insertWmsRawOutstockDetail(wmsRawOutstock); + return rows; + } + + /** + * 修改原材料出库记录 + * + * @param wmsRawOutstock 原材料出库记录 + * @return 结果 + */ + @Transactional + @Override + public int updateWmsRawOutstock(WmsRawOutstock wmsRawOutstock) + { + wmsRawOutstockMapper.deleteWmsRawOutstockDetailByRawOutstockId(wmsRawOutstock.getRawOutstockId()); + insertWmsRawOutstockDetail(wmsRawOutstock); + return wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock); + } + + /** + * 批量删除原材料出库记录 + * + * @param rawOutstockIds 需要删除的原材料出库记录主键 + * @return 结果 + */ + @Transactional + @Override + public int deleteWmsRawOutstockByRawOutstockIds(Long[] rawOutstockIds) + { + wmsRawOutstockMapper.deleteWmsRawOutstockDetailByRawOutstockIds(rawOutstockIds); + return wmsRawOutstockMapper.deleteWmsRawOutstockByRawOutstockIds(rawOutstockIds); + } + + /** + * 删除原材料出库记录信息 + * + * @param rawOutstockId 原材料出库记录主键 + * @return 结果 + */ + @Transactional + @Override + public int deleteWmsRawOutstockByRawOutstockId(Long rawOutstockId) + { + wmsRawOutstockMapper.deleteWmsRawOutstockDetailByRawOutstockId(rawOutstockId); + return wmsRawOutstockMapper.deleteWmsRawOutstockByRawOutstockId(rawOutstockId); + } + + /** + * 新增原材料出库记录明细信息 + * + * @param wmsRawOutstock 原材料出库记录对象 + */ + public void insertWmsRawOutstockDetail(WmsRawOutstock wmsRawOutstock) + { + List wmsRawOutstockDetailList = wmsRawOutstock.getWmsRawOutstockDetailList(); + Long rawOutstockId = wmsRawOutstock.getRawOutstockId(); + if (StringUtils.isNotNull(wmsRawOutstockDetailList)) + { + List list = new ArrayList(); + for (WmsRawOutstockDetail wmsRawOutstockDetail : wmsRawOutstockDetailList) + { + wmsRawOutstockDetail.setRawOutstockId(rawOutstockId); + list.add(wmsRawOutstockDetail); + } + if (list.size() > 0) + { + wmsRawOutstockMapper.batchWmsRawOutstockDetail(list); + } + } + } +} diff --git a/hw-modules/hw-wms/src/main/resources/banner.txt b/hw-modules/hw-wms/src/main/resources/banner.txt new file mode 100644 index 00000000..fbd45f53 --- /dev/null +++ b/hw-modules/hw-wms/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ _ + (_) | | + _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___ +| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ +| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | | +|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_| + __/ | __/ | + |___/ |___/ \ No newline at end of file diff --git a/hw-modules/hw-wms/src/main/resources/bootstrap.yml b/hw-modules/hw-wms/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..900e86ba --- /dev/null +++ b/hw-modules/hw-wms/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +# Tomcat +server: + port: 7304 + +# Spring +spring: + application: + # 应用名称 + name: hw-wms + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP + config: + # 配置中心地址 + server-addr: 175.27.215.92:8848 + namespace: jyhb + group: DEFAULT_GROUP + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/hw-modules/hw-wms/src/main/resources/logback.xml b/hw-modules/hw-wms/src/main/resources/logback.xml new file mode 100644 index 00000000..cd8503b5 --- /dev/null +++ b/hw-modules/hw-wms/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml new file mode 100644 index 00000000..af243aa8 --- /dev/null +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select raw_outstock_id, task_code, warehouse_id, location_code, order_id, plan_id, plan_detail_id, station_id, product_id, operation_type, task_type, apply_reason, audit_reason, audit_status, execute_status, apply_by, apply_date, audit_by, audit_date, update_by, update_date, begin_time, end_time from wms_raw_outstock + + + + + + + + insert into wms_raw_outstock + + task_code, + warehouse_id, + location_code, + order_id, + plan_id, + plan_detail_id, + station_id, + product_id, + operation_type, + task_type, + apply_reason, + audit_reason, + audit_status, + execute_status, + apply_by, + apply_date, + audit_by, + audit_date, + update_by, + update_date, + begin_time, + end_time, + + + #{taskCode}, + #{warehouseId}, + #{locationCode}, + #{orderId}, + #{planId}, + #{planDetailId}, + #{stationId}, + #{productId}, + #{operationType}, + #{taskType}, + #{applyReason}, + #{auditReason}, + #{auditStatus}, + #{executeStatus}, + #{applyBy}, + #{applyDate}, + #{auditBy}, + #{auditDate}, + #{updateBy}, + #{updateDate}, + #{beginTime}, + #{endTime}, + + + + + update wms_raw_outstock + + task_code = #{taskCode}, + warehouse_id = #{warehouseId}, + location_code = #{locationCode}, + order_id = #{orderId}, + plan_id = #{planId}, + plan_detail_id = #{planDetailId}, + station_id = #{stationId}, + product_id = #{productId}, + operation_type = #{operationType}, + task_type = #{taskType}, + apply_reason = #{applyReason}, + audit_reason = #{auditReason}, + audit_status = #{auditStatus}, + execute_status = #{executeStatus}, + apply_by = #{applyBy}, + apply_date = #{applyDate}, + audit_by = #{auditBy}, + audit_date = #{auditDate}, + update_by = #{updateBy}, + update_date = #{updateDate}, + begin_time = #{beginTime}, + end_time = #{endTime}, + + where raw_outstock_id = #{rawOutstockId} + + + + delete from wms_raw_outstock where raw_outstock_id = #{rawOutstockId} + + + + delete from wms_raw_outstock where raw_outstock_id in + + #{rawOutstockId} + + + + + delete from wms_raw_outstock_detail where raw_outstock_id in + + #{rawOutstockId} + + + + + delete from wms_raw_outstock_detail where raw_outstock_id = #{rawOutstockId} + + + + insert into wms_raw_outstock_detail( raw_outstock_detail_id, raw_outstock_id, location_code, material_barcode, material_id, instock_batch, material_production_Date, plan_amount, outstock_amount, execute_status, erp_status, outstock_person, outstock_time, outstock_way, machine_name, quality_status, create_by, create_date, update_by, update_date, stack_amount) values + + ( #{item.rawOutstockDetailId}, #{item.rawOutstockId}, #{item.locationCode}, #{item.materialBarcode}, #{item.materialId}, #{item.instockBatch}, #{item.materialProductionDate}, #{item.planAmount}, #{item.outstockAmount}, #{item.executeStatus}, #{item.erpStatus}, #{item.outstockPerson}, #{item.outstockTime}, #{item.outstockWay}, #{item.machineName}, #{item.qualityStatus}, #{item.createBy}, #{item.createDate}, #{item.updateBy}, #{item.updateDate}, #{item.stackAmount}) + + + \ No newline at end of file diff --git a/hw-modules/pom.xml b/hw-modules/pom.xml index 04ffcb22..eba69f32 100644 --- a/hw-modules/pom.xml +++ b/hw-modules/pom.xml @@ -14,6 +14,9 @@ hw-job hw-file hw-ems + hw-jindie + hw-tdengine + hw-wms hw-modules diff --git a/pom.xml b/pom.xml index 099ee899..6ec6930a 100644 --- a/pom.xml +++ b/pom.xml @@ -206,6 +206,13 @@ ${hw.version} + + + com.hw + hw-api-tdengine + ${hw.version} + + @@ -282,4 +289,4 @@ - \ No newline at end of file +