TDEngine服务上传

master
xins 2 years ago
parent 0605ded58f
commit 19400d5e2b

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hw</groupId>
<artifactId>hw-api</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-api-tdengine</artifactId>
<description>
hw-api-tdengine时序数据库模块api
</description>
<dependencies>
<!-- RuoYi Common Core-->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-core</artifactId>
</dependency>
</dependencies>
</project>

@ -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<List<Map<String, Object>>> getLatestDataByTags(@Validated @RequestBody TdSuperTableSelectVo tdSuperTableSelectVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("/tdengine/getHistoryData")
R<TdReturnDataVo> 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<List<Map<String, Object>>> getDeviceStatusList(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -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;
}

@ -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<TdField> 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<TdField> getSchemaFields() {
return schemaFields;
}
public void setSchemaFields(List<TdField> schemaFields) {
this.schemaFields = schemaFields;
}
}

@ -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;
}
}

@ -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 TdFieldsTdFieldsVodatatype
* @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<TdFieldsVo>
*/
public static List<TdFieldVo> batchConvertFields(List<TdField> fieldList) throws SQLException{
List<TdFieldVo> tdFieldsVoList = new ArrayList<>();
for(TdField tdField:fieldList){
tdFieldsVoList.add(convertField(tdField));
}
return tdFieldsVoList;
}
}

@ -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;
}

@ -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<Map<String, Object>> dataList;
}

@ -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<TdField> schemaFieldValues;
}

@ -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<TdField> schemaFieldValues;
}

@ -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
* timestamptimestamp
*
*
*/
@NotEmpty(message="schemeFields cannot be empty")
private List<TdField> schemaFields;
/**
* Schema
* TAGS
* TAGS
* TAGS 128 1 16 KB
*/
@NotEmpty(message="tagsFields cannot be empty")
private List<TdField> tagsFields;
/**
* 使
*/
private TdField field;
}

@ -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<TdField> tagsFieldValues;
/**
* schemaschema
*/
@NotEmpty(message="schemaFields cannot be empty",groups = InsertTdTable.class)
private List<TdField> schemaFields;
}

@ -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<RemoteTdEngineService> {
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<List<Map<String, Object>>> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo, String source) {
return R.fail("根据tags获取超级表最新数据失败:" + throwable.getMessage());
}
@Override
public R<TdReturnDataVo> 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<List<Map<String, Object>>> getDeviceStatusList(DeviceStatus queryDeviceStatus, String source) {
return R.fail("获取设备状态信息失败:" + throwable.getMessage());
}
};
}
}

@ -10,6 +10,7 @@
<modules> <modules>
<module>hw-api-system</module> <module>hw-api-system</module>
<module>hw-api-tdengine</module>
</modules> </modules>
<artifactId>hw-api</artifactId> <artifactId>hw-api</artifactId>

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>hw-common-core</artifactId> <artifactId>hw-common-core</artifactId>
<description> <description>
hw-common-core核心模块 hw-common-core核心模块
</description> </description>
@ -22,7 +22,7 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<!-- SpringCloud Loadbalancer --> <!-- SpringCloud Loadbalancer -->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
@ -113,6 +113,11 @@
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -2,7 +2,7 @@ package com.hw.common.core.constant;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
public class ServiceNameConstants public class ServiceNameConstants
@ -21,4 +21,9 @@ public class ServiceNameConstants
* serviceid * serviceid
*/ */
public static final String FILE_SERVICE = "hw-file"; public static final String FILE_SERVICE = "hw-file";
/**
* Tdengineserviceid
*/
public static final String TDENGINE_SERVICE = "hw-tdengine";
} }

@ -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<String, String> TDENGINE_KEY_TRANSFER_MAP = new HashMap<String, String>();
static {
TDENGINE_KEY_TRANSFER_MAP.put("value", "value1");
}
/**
*
*/
public static final List<String> ABNDON_FUNCTION_IDENTIFIERS = Arrays.asList("ts","value1","type");
public static final Map<String, String> DEVICE_DATA_COLUMN_MAP = new HashMap<String, String>();
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;
}
}

@ -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 tagjson
*/
JSON(11, "json");
// 性别值数组
public static final List<Integer> genderValueList = Arrays.stream(values()).map(DataTypeEnums::getDataCode).collect(Collectors.toList());
// 性别名数组
public static final List<String> genderNameList = Arrays.stream(values()).map(DataTypeEnums::getDataType).collect(Collectors.toList());
// 属性值与属性名Map
public static final Map<Integer, String> dataCodeTypeMap = Arrays.stream(values()).collect(
Collectors.toMap(
DataTypeEnums::getDataCode,
DataTypeEnums::getDataType
)
);
// 属性名与属性值Map
public static final Map<String, Integer> 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));
}
}

@ -0,0 +1,4 @@
package com.hw.common.core.validated.tdengine;
public interface AddTdSTableColumn {
}

@ -0,0 +1,4 @@
package com.hw.common.core.validated.tdengine;
public interface InsertTdTable {
}

@ -15,9 +15,13 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 175.27.215.92:8848 server-addr: 175.27.215.92:8848
namespace: jyhb
group: DEFAULT_GROUP
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 175.27.215.92:8848 server-addr: 175.27.215.92:8848
namespace: jyhb
group: DEFAULT_GROUP
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

@ -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

@ -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/
#<!-- 当前使用的 账套ID(即数据中心id) -->
X-KDApi-AcctID =657953112be3c4
#<!-- 第三方系统登录授权的 应用ID -->
X-KDApi-AppID=265686_SY0M09lvzkp/18wG4/RBRa1GRs2V2pls
#<!-- 第三方系统登录授权的 应用密钥 -->
X-KDApi-AppSec =317a6730c9ec4fafa757ca4a3499d059
#<!-- 第三方系统登录授权的 集成用户名称 -->
X-KDApi-UserName =张铭潇
#<!-- 账套语系默认2052 -->
X-KDApi-LCID=2052
#<!-- 服务Url地址(私有云必须配置金蝶云星空产品地址K3Cloud/结尾。若为公有云则必须置空)-->
X-KDApi-ServerUrl=http://1.15.183.55/k3cloud/

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hw</groupId>
<artifactId>hw-modules</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-modules-jindie</artifactId>
<description>
hw-modules-jindie金蝶ERP对接模块
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.kingdee.bos</groupId>
<artifactId>k3cloud-webapi-sdk</artifactId>
<version>8.0.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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);
}
}
}

@ -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" +
" ''-' `'-' `-..-' ");
}
}

@ -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);
}
}

@ -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;
}
}

@ -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<String, Object> map = new HashMap<>();
map = new Gson().fromJson(para, map.getClass());
SaveResult sRet = api.save("BD_Customer", new SaveParam<Map>(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<String, Object> map = new HashMap<>();
map = new Gson().fromJson(para2, map.getClass());
SaveResult sRet = api.save("BD_Customer", new SaveParam<Map>(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<String> 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<String> 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<String> 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<BdCustomer> 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<String> 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<Map<String, Object>> 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<Map<String, Object>> 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));
}
}

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/

@ -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}

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/hw-jindie" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.hw" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hw</groupId>
<artifactId>hw-modules</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-modules-tdengine</artifactId>
<description>
hw-modules-tdengine 时序数据库处理模块
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-swagger</artifactId>
</dependency>
<!-- TDengine -->
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-api-tdengine</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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" +
" ''-' `'-' `-..-' ");
}
}

@ -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<TdField> schemaFields = tdSuperTableVo.getSchemaFields();
//标签字段对象集合
List<TdField> tagsFields = tdSuperTableVo.getTagsFields();
try {
//将Schema字段对象和标签字段对象转换为创建表的字段Vo类对象集合
List<TdFieldVo> schemaFieldsVos = TdFieldVo.batchConvertFields(schemaFields);
List<TdFieldVo> 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<TdField> 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<TdField> 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<Map < String, Map < String, Object>>>
* @param: tdSelectDto
* @description tagsname
* @author xins
* @date 2023-08-29 14:51
*/
@InnerAuth
@PostMapping("/getLatestDataByTags")
public R<List<Map<String, Object>>> 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<DeviceStatus> deviceStatuses = this.deviceStatusService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Map<Long, List<DeviceStatus>> 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<Map<String,Object>> 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<List<Map<String, Object>>> getDeviceStatusList(@RequestBody DeviceStatus queryDeviceStatus) {
try {
List<Map<String,Object>> 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());
}
}
}

@ -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<DeviceStatus>
*/
List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus deviceStatus);
/**
* @param: deviceStatus
* @description 线
* @author xins
* @date 2023-09-05 11:43
* @return List<DeviceStatus>
*/
List<Map<String, Object>> getLastOnlineDevices(DeviceStatus deviceStatus);
/**
* @param: deviceStatus
* @description
* @author xins
* @date 2023-09-05 11:43
* @return List<DeviceStatus>
*/
List<Map<String, Object>> getDeviceStatusList(DeviceStatus deviceStatus);
}

@ -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<TdFieldVo> schemaFields,
@Param("tagsFields") List<TdFieldVo> 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<TdField> 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<TdField> schemaFields);
/**
* @return List<Map < Object>>
* @param: tdSelectDto
* @description
* @author xins
* @date 2023-08-29 10:43
*/
List<Map<String, Object>> getLatestData(TdSelectDto tdSelectDto);
/**
* @return List<Map < Object>>
* @param: tdSelectDto
* @description tagsname
* select last_row()
* @author xins
* @date 2023-08-29 14:42
*/
List<Map<String, Object>> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo);
/**
* @return List<Map < Object>>
* @param: tdSelectDto
* @description
* @author xins
* @date 2023-08-29 15:50
*/
List<Map<String, Object>> getHistoryData(TdHistorySelectDto tdHistorySelectDto);
int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto);
// /**
// * 检查表是否存在
// * @param dataBaseName
// * @param tableName 可以为超级表名或普通表名
// * @return
// */
// Integer checkTableExists(@Param("dataBaseName") String dataBaseName, @Param("tableName")String tableName);
//
// List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);
//
// List<Map<String, Object>> getAggregateData(SelectVisualDto selectVisualDto);
// void addTagForSuperTable(@Param("superTableName") String superTableName,
// @Param("fieldsVo") FieldsVo fieldsVo);
//
// void dropTagForSuperTable(@Param("superTableName") String superTableName,
// @Param("fieldsVo") FieldsVo fieldsVo);
}

@ -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<DeviceStatus>
*/
public List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus);
/**
* @return List<Map<String, Object>>
* @param: DeviceStatus
* @description 线
* @author xins
* @date 2023-09-05 13:23
*/
public List<Map<String, Object>> getLastOnlineDevices(DeviceStatus queryDeviceStatus);
/**
* @return List<Map<String, Object>>
* @param: DeviceStatus
* @description
* @author xins
* @date 2023-09-05 13:23
*/
public List<Map<String, Object>> getDeviceStatusList(DeviceStatus queryDeviceStatus);
}

@ -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<TdFieldVo> schemaFields, List<TdFieldVo> 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<TdField> 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<TdField> schemaFields) throws Exception;
/**
* @param: tdSelectDto
* @description
* @author xins
* @date 2023-08-29 11:28
* @return List<Map<Object>>
*/
public List<Map<String, Object>> getLatestData(TdSelectDto tdSelectDto) throws Exception;
/**
* @return List<Map<String, Object>>
* @param: tdSelectDto
* @description tagsname
* * select last_row()
* @author xins
* @date 2023-08-29 14:47
*/
public List<Map<String, Object>> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo);
/**
* @param: tdHistorySelectDto
* @description
* @author xins
* @date 2023-08-29 15:52
* @return List<Map<Object>>
*/
public List<Map<String, Object>> 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<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);
//
// List<Map<String, Object>> getAggregateData(SelectVisualDto selectVisualDto);
}

@ -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<DeviceStatus>
* @param: DeviceStatus
* @description 线
* @author xins
* @date 2023-09-05 13:23
*/
@Override
public List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus) {
Map<String, Object> 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<DeviceStatus> deviceStatuses = deviceStatusMapper.getOnlineDevicesGroupByDay(queryDeviceStatus);
return deviceStatuses;
}
/**
* @return List<Map<String, Object>>
* @param: DeviceStatus
* @description 线
* @author xins
* @date 2023-09-05 13:23
*/
@Override
public List<Map<String, Object>> getLastOnlineDevices(DeviceStatus queryDeviceStatus) {
Map<String, Object> params = queryDeviceStatus.getParams();
params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME);
params.put("superTableName", TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
List<Map<String, Object>> deviceStatusMap = deviceStatusMapper.getLastOnlineDevices(queryDeviceStatus);
List<Map<String, Object>> filterMaps = new ArrayList<>();
//tdengine在select时row会带着括号需要将括号过滤掉
for (Map<String, Object> latestMap : deviceStatusMap) {
Map<String, Object> 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<Map<String, Object>>
* @param: DeviceStatus
* @description
* @author xins
* @date 2023-09-05 13:23
*/
@Override
public List<Map<String, Object>> getDeviceStatusList(DeviceStatus queryDeviceStatus) {
Map<String, Object> params = queryDeviceStatus.getParams();
params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME);
params.put("tableName", TdEngineConstants.getDeviceStatusTableName(queryDeviceStatus.getDeviceId()));
List<Map<String, Object>> deviceStatusMap = deviceStatusMapper.getDeviceStatusList(queryDeviceStatus);
return deviceStatusMap;
}
}

@ -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<TdFieldVo> schemaFields, List<TdFieldVo> 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<TdField> 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<TdField> schemaFields) throws Exception {
this.tdEngineMapper.insertTable(databaseName, tableName, schemaFields);
}
/**
* @return List<Map < Object>>
* @param: tdSelectDto
* @description
* @author xins
* @date 2023-08-29 11:28
*/
@Override
public List<Map<String, Object>> getLatestData(TdSelectDto tdSelectDto) throws Exception {
List<Map<String, Object>> latestMaps = this.tdEngineMapper.getLatestData(tdSelectDto);
List<Map<String, Object>> filterMaps = new ArrayList<>();
// String i18nKey = "tdengine_supertable1_";
String i18nKey = "";//todo国际化看在哪处理
/**
* last(*)keylast(key),key
*/
for (Map<String, Object> latestMap : latestMaps) {
Map<String, Object> 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<Map < String, Object>>
* @param: tdSelectDto
* @description tagsname
* * select last_row()
* @author xins
* @date 2023-08-29 14:47
*/
@Override
public List<Map<String, Object>> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo) {
List<Map<String, Object>> 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<String, Map<String, Object>> tagsMap = new HashMap<>();
// for (Map<String, Object> latestMap : latestMaps) {
// Map<String, Object> 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<Map < Object>>
* @param: tdHistorySelectDto
* @description
* @author xins
* @date 2023-08-29 15:52
*/
@Override
public List<Map<String, Object>> 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<Map<String, Object>> 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<Fields> schemaFields = superTableDto.getSchemaFields();
// //从入参对象获取标签字段对象集合
// List<Fields> 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<FieldsVo> schemaFieldsVoList = FieldsVo.fieldsTranscoding(schemaFields);
// List<FieldsVo> tagsFieldsVoList = FieldsVo.fieldsTranscoding(tagsFields);
// //创建超级表
// this.createSuperTable(schemaFieldsVoList, tagsFieldsVoList, dataBaseName, superTableName);
// log.info("create {} super table success", superTableName);
// }
//
//
// /**
// * @param tagsSelectDao
// * @return
// */
// @Override
//
//
//
// @Override
// public List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto) {
// List<Map<String, Object>> maps = this.tdEngineMapper.getRealtimeData(selectVisualDto);
// return maps;
// }
//
// @Override
// public List<Map<String, Object>> getAggregateData(SelectVisualDto selectVisualDto) {
// List<Map<String, Object>> maps = this.tdEngineMapper.getAggregateData(selectVisualDto);
// return maps;
// }
}

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/

@ -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}

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/hw-tdengine" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.hw" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.tdengine.mapper.DeviceStatusMapper">
<select id="getOnlineDevicesGroupByDay" parameterType="com.hw.tdengine.api.domain.DeviceStatus" resultType="com.hw.tdengine.api.domain.DeviceStatus" >
select timetruncate(ts,1d) ts,devicetype,onlinestatus,deviceid from #{params.databaseName}.#{params.superTableName}
where onlinestatus=1
<if test="startTime!= null and endTime != null and startTime!= 0 and endTime != 0">
and ts BETWEEN #{startTime} AND #{endTime}
</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
group by timetruncate(ts,1d),devicetype,onlinestatus,deviceid
</select>
<select id="getLastOnlineDevices" parameterType="com.hw.tdengine.api.domain.DeviceStatus" resultType="java.util.Map" >
select <foreach item="item" collection="schemaFields" separator=","
index="">last_row(${item.fieldName})</foreach>,last_row(deviceid) from #{params.databaseName}.#{params.superTableName}
<where>
<if test="endTime!= null and endTime != 0">
and ts &lt;= #{endTime}
</if>
</where>
group by deviceid
</select>
<select id="getDeviceStatusList" parameterType="com.hw.tdengine.api.domain.DeviceStatus" resultType="java.util.Map" >
select ts,onlinestatus from #{params.databaseName}.#{params.tableName}
<where>
<if test="startTime!= null and startTime != 0">
and ts &gt; #{startTime}
</if>
<if test="endTime!= null and endTime != 0">
and ts &lt; #{endTime}
</if>
<if test="onlineStatus!= null">
and onlinestatus = #{onlineStatus}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,329 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.tdengine.mapper.TdEngineMapper">
<update id="createDatabase" parameterType="String">
create database if not exists #{databaseName}
</update>
<update id="createSuperTable">
create table if not exists #{databaseName}.#{superTableName}
(${firstFieldName} timestamp,
<!--tdEngine不支持动态fields里的数据类型只能使用choose-->
<foreach item="item" collection="schemaFields" separator=","
index="">
<if test="item.fieldName != null and item.fieldName != ''">
${item.fieldName}
</if>
<if test="item.dataType != null and item.dataType != ''">
<choose>
<when test="item.dataType == 'timestamp'">
timestamp
</when>
<when test="item.dataType == 'tinyint'">
tinyint
</when>
<when test="item.dataType == 'smallint'">
smallint
</when>
<when test="item.dataType == 'int'">
int
</when>
<when test="item.dataType == 'bigint'">
bigint
</when>
<when test="item.dataType == 'float'">
float
</when>
<when test="item.dataType == 'double'">
double
</when>
<when test="item.dataType == 'binary'">
binary
</when>
<when test="item.dataType == 'nchar'">
nchar
</when>
<when test="item.dataType == 'bool'">
bool
</when>
<when test="item.dataType == 'json'">
json
</when>
</choose>
</if>
<if test="item.size != null">
(#{item.size})
</if>
</foreach>
) tags
<!--tdEngine不支持动态tags里的数据类型只能使用choose-->
<foreach item="item" collection="tagsFields" separator=","
open="(" close=")" index="">
<if test="item.fieldName != null and item.fieldName != ''">
${item.fieldName}
</if>
<if test="item.dataType != null and item.dataType != ''">
<choose>
<when test="item.dataType == 'timestamp'">
timestamp
</when>
<when test="item.dataType == 'int'">
int
</when>
<when test="item.dataType == 'bigint'">
bigint
</when>
<when test="item.dataType == 'float'">
float
</when>
<when test="item.dataType == 'double'">
double
</when>
<when test="item.dataType == 'binary'">
binary
</when>
<when test="item.dataType == 'smallint'">
smallint
</when>
<when test="item.dataType == 'tinyint'">
tinyint
</when>
<when test="item.dataType == 'bool'">
bool
</when>
<when test="item.dataType == 'nchar'">
nchar
</when>
<when test="item.dataType == 'json'">
json
</when>
</choose>
</if>
<if test="item.size != null">
(#{item.size})
</if>
</foreach>
</update>
<update id="createTable">
create table if not exists #{databaseName}.#{tableName}
using #{databaseName}.#{superTableName}
<foreach item="item" collection="tagsFieldValues" separator=","
open="(" close=")" index="">${item.fieldName}</foreach>
tags
<foreach item="item" collection="tagsFieldValues" separator=","
open="(" close=")" index="">#{item.fieldValue}</foreach>
</update>
<update id="addSuperTableColumn">
ALTER STABLE #{databaseName}.#{superTableName} ADD COLUMN
<if test="addFieldsVo.fieldName != null and addFieldsVo.fieldName != ''">
${addFieldsVo.fieldName}
</if>
<if test="addFieldsVo.dataType != null and addFieldsVo.dataType != ''">
<choose>
<when test="addFieldsVo.dataType == 'timestamp'">
timestamp
</when>
<when test="addFieldsVo.dataType == 'int'">
int
</when>
<when test="addFieldsVo.dataType == 'bigint'">
bigint
</when>
<when test="addFieldsVo.dataType == 'float'">
float
</when>
<when test="addFieldsVo.dataType == 'double'">
double
</when>
<when test="addFieldsVo.dataType == 'binary'">
binary
</when>
<when test="addFieldsVo.dataType == 'smallint'">
smallint
</when>
<when test="addFieldsVo.dataType == 'tinyint'">
tinyint
</when>
<when test="addFieldsVo.dataType == 'bool'">
bool
</when>
<when test="addFieldsVo.dataType == 'nchar'">
nchar
</when>
<when test="addFieldsVo.dataType == 'json'">
json
</when>
</choose>
</if>
<if test="addFieldsVo.size != null">
(#{addFieldsVo.size})
</if>
</update>
<update id="modifySuperTableColumn">
ALTER STABLE #{databaseName}.#{superTableName} modify COLUMN
<if test="modifyFieldsVo.fieldName != null and modifyFieldsVo.fieldName != '' and modifyFieldsVo.size != null">
${modifyFieldsVo.fieldName} nchar(#{modifyFieldsVo.size})
</if>
</update>
<update id="dropSuperTableColumn">
ALTER STABLE #{databaseName}.#{superTableName} DROP COLUMN
<if test="dropField.fieldName != null and dropField.fieldName != ''">
${dropField.fieldName}
</if>
</update>
<update id="alterTableTag">
ALTER TABLE #{databaseName}.#{tableName} SET TAG #{tagName}=${tagValue};
</update>
<!-- 需要提前建表。如果用插入记录时自动建表则会有概率出现问题:设备上报的属性值跟定义的属性值不同的情况-->
<insert id="insertTable">
<!--不要换行tdengine有时候解析会有问题-->
insert into #{databaseName}.#{tableName} <foreach item="item" collection="schemaFields" separator=","
open="(" close=")" index="">${item.fieldName}</foreach> values <foreach item="item" collection="schemaFields" separator=","
open="(" close=")" index="">#{item.fieldValue}</foreach>
<!--insert into db_scene_1.t_device_2
(
ts
,
rssi
,
alias
,
value1
,
voltage
)
values
(
1689816999999,-80.1,
'u_1'
,
-25.6
,
3.76
)-->
</insert>
<!--适用于设备监测页面可以getLatestDataByTags通过tag监控单元ID来获取最新信息先根据监控单元获取设备信息再根据设备来获取最新的数据-->
<select id="getLatestData" parameterType="com.hw.tdengine.api.domain.TdSelectDto"
resultType="java.util.Map">
select
<foreach item="item" collection="schemaFieldValues" separator=","
index="">last(${item.fieldName})</foreach>
from #{databaseName}.#{tableName}
</select>
<!--适用于设备汇总页面,先分页获取设备信息,再获取所有此物模型下的最新信息(冗余,但每页只获取一次,不需要每个设备都获取一次
也可以用select last_row()-->
<select id="getLatestDataByTags" parameterType="com.hw.tdengine.api.domain.TdSelectDto"
resultType="java.util.Map">
select * from (select
<foreach item="item" collection="schemaFieldValues" separator=","
index="">last(${item.fieldName})</foreach>, last(devicecode),last(devicename), last(deviceid),last(devicemodeid),last(ts) from #{databaseName}.#{superTableName}
<where>
<if test="firstFieldName != null and firstFieldName != '' and
startTime!= null ">
and ${firstFieldName} &gt;= #{startTime}
</if>
<if test="firstFieldName != null and firstFieldName != '' and
endTime != 0">
and ${firstFieldName} &lt;= #{endTime}
</if>
<if test="deviceName != null and deviceName != ''">
AND devicename like '%${deviceName}%'
</if>
<if test="deviceCode != null and deviceCode != ''">
AND devicecode like '%${deviceCode}%'
</if>
</where>
group by ${groupByTagsName})
<if test="offset != null and limit != 0 ">
LIMIT #{offset},#{limit}
</if>
</select>
<select id="getHistoryData" parameterType="com.hw.tdengine.api.domain.TdSelectDto" resultType="java.util.Map" >
SELECT * FROM #{databaseName}.#{tableName}
<where>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
startTime!= 0 ">
and ${firstFieldName} &gt;= #{startTime}
</if>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
endTime != 0">
and ${firstFieldName} &lt;= #{endTime}
</if>
</where>
<!--由于此处orderby是用${orderByFieldName},而不是用#${orderByFieldName}这样就会用sql注入风险所以加上choose和判断条件-->
<choose>
<when test="(orderByFieldName=='ts') and (sort=='desc' or sort=='asc')">
order by ${orderByFieldName} ${sort}
</when>
</choose>
<if test="offset != null and limit != 0 ">
LIMIT #{offset},#{limit}
</if>
</select>
<select id="getCountOfHistoryData" parameterType="com.hw.tdengine.api.domain.TdSelectDto" resultType="int" >
SELECT count(*) FROM #{databaseName}.#{tableName}
<where>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
startTime!= 0 ">
and ${firstFieldName} &gt;= #{startTime}
</if>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
endTime != 0">
and ${firstFieldName} &lt;= #{endTime}
</if>
</where>
</select>
<select id="getOnlineDevicesByDay" parameterType="com.hw.tdengine.api.domain.DeviceStatus" resultType="com.hw.tdengine.api.domain.DeviceStatus" >
select timetruncate(ts,1d) ts,devicetype,onlinestatus,devicecode from #{params.databaseName}.#{params.superTableName}
where onlinestatus=1
<if test="{params.beginTime}!= null and {params.endTime} != null">
and ts BETWEEN #{params.beginTime} AND #{params.endTime}
</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
group by timetruncate(ts,1d),devicetype,onlinestatus,devicecode
order by ts
</select>
<!--
<select id="checkTableExists" resultType="java.lang.Integer">
SELECT COUNT(0) FROM #{dataBaseName}.#{tableName}
</select>
<select id="getRealtimeData" resultType="java.util.Map" parameterType="">
SELECT #{fieldName},ts
FROM #{dataBaseName}.#{tableName} LIMIT #{num}
</select>
<select id="getAggregateData" resultType="java.util.Map" parameterType="">
SELECT #{aggregate}(${fieldName})
FROM #{dataBaseName}.#{tableName} WHERE ts BETWEEN #{startTime} AND #{endTime} interval(${interval}) LIMIT #{num}
</select>-->
</mapper>

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hw</groupId>
<artifactId>hw-modules</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-modules-wms</artifactId>
<description>
hw-modules-wms仓储模块
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-swagger</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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" +
" ''-' `'-' `-..-' ");
}
}

@ -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<WmsRawOutstock> 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<WmsRawOutstock> list = wmsRawOutstockService.selectWmsRawOutstockList(wmsRawOutstock);
ExcelUtil<WmsRawOutstock> util = new ExcelUtil<WmsRawOutstock>(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));
}
}

@ -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<WmsRawOutstockDetail> 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<WmsRawOutstockDetail> getWmsRawOutstockDetailList()
{
return wmsRawOutstockDetailList;
}
public void setWmsRawOutstockDetailList(List<WmsRawOutstockDetail> 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();
}
}

@ -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();
}
}

@ -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<WmsRawOutstock> 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<WmsRawOutstockDetail> wmsRawOutstockDetailList);
/**
*
*
* @param rawOutstockId ID
* @return
*/
public int deleteWmsRawOutstockDetailByRawOutstockId(Long rawOutstockId);
}

@ -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<WmsRawOutstock> 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);
}

@ -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<WmsRawOutstock> 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<WmsRawOutstockDetail> wmsRawOutstockDetailList = wmsRawOutstock.getWmsRawOutstockDetailList();
Long rawOutstockId = wmsRawOutstock.getRawOutstockId();
if (StringUtils.isNotNull(wmsRawOutstockDetailList))
{
List<WmsRawOutstockDetail> list = new ArrayList<WmsRawOutstockDetail>();
for (WmsRawOutstockDetail wmsRawOutstockDetail : wmsRawOutstockDetailList)
{
wmsRawOutstockDetail.setRawOutstockId(rawOutstockId);
list.add(wmsRawOutstockDetail);
}
if (list.size() > 0)
{
wmsRawOutstockMapper.batchWmsRawOutstockDetail(list);
}
}
}
}

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/

@ -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}

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/hw-wms" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.hw" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.wms.mapper.WmsRawOutstockMapper">
<resultMap type="WmsRawOutstock" id="WmsRawOutstockResult">
<result property="rawOutstockId" column="raw_outstock_id" />
<result property="taskCode" column="task_code" />
<result property="warehouseId" column="warehouse_id" />
<result property="locationCode" column="location_code" />
<result property="orderId" column="order_id" />
<result property="planId" column="plan_id" />
<result property="planDetailId" column="plan_detail_id" />
<result property="stationId" column="station_id" />
<result property="productId" column="product_id" />
<result property="operationType" column="operation_type" />
<result property="taskType" column="task_type" />
<result property="applyReason" column="apply_reason" />
<result property="auditReason" column="audit_reason" />
<result property="auditStatus" column="audit_status" />
<result property="executeStatus" column="execute_status" />
<result property="applyBy" column="apply_by" />
<result property="applyDate" column="apply_date" />
<result property="auditBy" column="audit_by" />
<result property="auditDate" column="audit_date" />
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="beginTime" column="begin_time" />
<result property="endTime" column="end_time" />
</resultMap>
<resultMap id="WmsRawOutstockWmsRawOutstockDetailResult" type="WmsRawOutstock" extends="WmsRawOutstockResult">
<collection property="wmsRawOutstockDetailList" notNullColumn="sub_raw_outstock_detail_id" javaType="java.util.List" resultMap="WmsRawOutstockDetailResult" />
</resultMap>
<resultMap type="WmsRawOutstockDetail" id="WmsRawOutstockDetailResult">
<result property="rawOutstockDetailId" column="sub_raw_outstock_detail_id" />
<result property="rawOutstockId" column="sub_raw_outstock_id" />
<result property="locationCode" column="sub_location_code" />
<result property="materialBarcode" column="sub_material_barcode" />
<result property="materialId" column="sub_material_id" />
<result property="instockBatch" column="sub_instock_batch" />
<result property="materialProductionDate" column="sub_material_production_Date" />
<result property="planAmount" column="sub_plan_amount" />
<result property="outstockAmount" column="sub_outstock_amount" />
<result property="executeStatus" column="sub_execute_status" />
<result property="erpStatus" column="sub_erp_status" />
<result property="outstockPerson" column="sub_outstock_person" />
<result property="outstockTime" column="sub_outstock_time" />
<result property="outstockWay" column="sub_outstock_way" />
<result property="machineName" column="sub_machine_name" />
<result property="qualityStatus" column="sub_quality_status" />
<result property="createBy" column="sub_create_by" />
<result property="createDate" column="sub_create_date" />
<result property="updateBy" column="sub_update_by" />
<result property="updateDate" column="sub_update_date" />
<result property="stackAmount" column="sub_stack_amount" />
</resultMap>
<sql id="selectWmsRawOutstockVo">
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
</sql>
<select id="selectWmsRawOutstockList" parameterType="WmsRawOutstock" resultMap="WmsRawOutstockResult">
<include refid="selectWmsRawOutstockVo"/>
<where>
<if test="taskCode != null and taskCode != ''"> and task_code = #{taskCode}</if>
<if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
<if test="locationCode != null and locationCode != ''"> and location_code = #{locationCode}</if>
<if test="orderId != null "> and order_id = #{orderId}</if>
<if test="planId != null "> and plan_id = #{planId}</if>
<if test="planDetailId != null "> and plan_detail_id = #{planDetailId}</if>
<if test="stationId != null "> and station_id = #{stationId}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="operationType != null and operationType != ''"> and operation_type = #{operationType}</if>
<if test="taskType != null and taskType != ''"> and task_type = #{taskType}</if>
<if test="applyReason != null and applyReason != ''"> and apply_reason = #{applyReason}</if>
<if test="auditReason != null and auditReason != ''"> and audit_reason = #{auditReason}</if>
<if test="auditStatus != null and auditStatus != ''"> and audit_status = #{auditStatus}</if>
<if test="executeStatus != null and executeStatus != ''"> and execute_status = #{executeStatus}</if>
<if test="applyBy != null and applyBy != ''"> and apply_by = #{applyBy}</if>
<if test="applyDate != null "> and apply_date = #{applyDate}</if>
<if test="auditBy != null and auditBy != ''"> and audit_by = #{auditBy}</if>
<if test="auditDate != null "> and audit_date = #{auditDate}</if>
<if test="updateDate != null "> and update_date = #{updateDate}</if>
<if test="beginTime != null "> and begin_time = #{beginTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
</where>
</select>
<select id="selectWmsRawOutstockByRawOutstockId" parameterType="Long" resultMap="WmsRawOutstockWmsRawOutstockDetailResult">
select a.raw_outstock_id, a.task_code, a.warehouse_id, a.location_code, a.order_id, a.plan_id, a.plan_detail_id, a.station_id, a.product_id, a.operation_type, a.task_type, a.apply_reason, a.audit_reason, a.audit_status, a.execute_status, a.apply_by, a.apply_date, a.audit_by, a.audit_date, a.update_by, a.update_date, a.begin_time, a.end_time,
b.raw_outstock_detail_id as sub_raw_outstock_detail_id, b.raw_outstock_id as sub_raw_outstock_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.material_id as sub_material_id, b.instock_batch as sub_instock_batch, b.material_production_Date as sub_material_production_Date, b.plan_amount as sub_plan_amount, b.outstock_amount as sub_outstock_amount, b.execute_status as sub_execute_status, b.erp_status as sub_erp_status, b.outstock_person as sub_outstock_person, b.outstock_time as sub_outstock_time, b.outstock_way as sub_outstock_way, b.machine_name as sub_machine_name, b.quality_status as sub_quality_status, b.create_by as sub_create_by, b.create_date as sub_create_date, b.update_by as sub_update_by, b.update_date as sub_update_date, b.stack_amount as sub_stack_amount
from wms_raw_outstock a
left join wms_raw_outstock_detail b on b.raw_outstock_id = a.raw_outstock_id
where a.raw_outstock_id = #{rawOutstockId}
</select>
<insert id="insertWmsRawOutstock" parameterType="WmsRawOutstock" useGeneratedKeys="true" keyProperty="rawOutstockId">
insert into wms_raw_outstock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskCode != null and taskCode != ''">task_code,</if>
<if test="warehouseId != null">warehouse_id,</if>
<if test="locationCode != null">location_code,</if>
<if test="orderId != null">order_id,</if>
<if test="planId != null">plan_id,</if>
<if test="planDetailId != null">plan_detail_id,</if>
<if test="stationId != null">station_id,</if>
<if test="productId != null">product_id,</if>
<if test="operationType != null">operation_type,</if>
<if test="taskType != null">task_type,</if>
<if test="applyReason != null">apply_reason,</if>
<if test="auditReason != null">audit_reason,</if>
<if test="auditStatus != null">audit_status,</if>
<if test="executeStatus != null">execute_status,</if>
<if test="applyBy != null">apply_by,</if>
<if test="applyDate != null">apply_date,</if>
<if test="auditBy != null">audit_by,</if>
<if test="auditDate != null">audit_date,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateDate != null">update_date,</if>
<if test="beginTime != null">begin_time,</if>
<if test="endTime != null">end_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskCode != null and taskCode != ''">#{taskCode},</if>
<if test="warehouseId != null">#{warehouseId},</if>
<if test="locationCode != null">#{locationCode},</if>
<if test="orderId != null">#{orderId},</if>
<if test="planId != null">#{planId},</if>
<if test="planDetailId != null">#{planDetailId},</if>
<if test="stationId != null">#{stationId},</if>
<if test="productId != null">#{productId},</if>
<if test="operationType != null">#{operationType},</if>
<if test="taskType != null">#{taskType},</if>
<if test="applyReason != null">#{applyReason},</if>
<if test="auditReason != null">#{auditReason},</if>
<if test="auditStatus != null">#{auditStatus},</if>
<if test="executeStatus != null">#{executeStatus},</if>
<if test="applyBy != null">#{applyBy},</if>
<if test="applyDate != null">#{applyDate},</if>
<if test="auditBy != null">#{auditBy},</if>
<if test="auditDate != null">#{auditDate},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateDate != null">#{updateDate},</if>
<if test="beginTime != null">#{beginTime},</if>
<if test="endTime != null">#{endTime},</if>
</trim>
</insert>
<update id="updateWmsRawOutstock" parameterType="WmsRawOutstock">
update wms_raw_outstock
<trim prefix="SET" suffixOverrides=",">
<if test="taskCode != null and taskCode != ''">task_code = #{taskCode},</if>
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="locationCode != null">location_code = #{locationCode},</if>
<if test="orderId != null">order_id = #{orderId},</if>
<if test="planId != null">plan_id = #{planId},</if>
<if test="planDetailId != null">plan_detail_id = #{planDetailId},</if>
<if test="stationId != null">station_id = #{stationId},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="operationType != null">operation_type = #{operationType},</if>
<if test="taskType != null">task_type = #{taskType},</if>
<if test="applyReason != null">apply_reason = #{applyReason},</if>
<if test="auditReason != null">audit_reason = #{auditReason},</if>
<if test="auditStatus != null">audit_status = #{auditStatus},</if>
<if test="executeStatus != null">execute_status = #{executeStatus},</if>
<if test="applyBy != null">apply_by = #{applyBy},</if>
<if test="applyDate != null">apply_date = #{applyDate},</if>
<if test="auditBy != null">audit_by = #{auditBy},</if>
<if test="auditDate != null">audit_date = #{auditDate},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateDate != null">update_date = #{updateDate},</if>
<if test="beginTime != null">begin_time = #{beginTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
</trim>
where raw_outstock_id = #{rawOutstockId}
</update>
<delete id="deleteWmsRawOutstockByRawOutstockId" parameterType="Long">
delete from wms_raw_outstock where raw_outstock_id = #{rawOutstockId}
</delete>
<delete id="deleteWmsRawOutstockByRawOutstockIds" parameterType="String">
delete from wms_raw_outstock where raw_outstock_id in
<foreach item="rawOutstockId" collection="array" open="(" separator="," close=")">
#{rawOutstockId}
</foreach>
</delete>
<delete id="deleteWmsRawOutstockDetailByRawOutstockIds" parameterType="String">
delete from wms_raw_outstock_detail where raw_outstock_id in
<foreach item="rawOutstockId" collection="array" open="(" separator="," close=")">
#{rawOutstockId}
</foreach>
</delete>
<delete id="deleteWmsRawOutstockDetailByRawOutstockId" parameterType="Long">
delete from wms_raw_outstock_detail where raw_outstock_id = #{rawOutstockId}
</delete>
<insert id="batchWmsRawOutstockDetail">
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
<foreach item="item" index="index" collection="list" separator=",">
( #{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})
</foreach>
</insert>
</mapper>

@ -14,6 +14,9 @@
<module>hw-job</module> <module>hw-job</module>
<module>hw-file</module> <module>hw-file</module>
<module>hw-ems</module> <module>hw-ems</module>
<module>hw-jindie</module>
<module>hw-tdengine</module>
<module>hw-wms</module>
</modules> </modules>
<artifactId>hw-modules</artifactId> <artifactId>hw-modules</artifactId>

@ -206,6 +206,13 @@
<version>${hw.version}</version> <version>${hw.version}</version>
</dependency> </dependency>
<!-- tdegine接口 -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-api-tdengine</artifactId>
<version>${hw.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -282,4 +289,4 @@
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
</project> </project>

Loading…
Cancel
Save