Browse Source
Merge pull request 'master' (#51) from master into V3
Merge pull request 'master' (#51) from master into V3
Reviewed-on: http://git.lrdaiot.cn:9000/thing/thing_api/pulls/51qingyuan_dev_new
11 changed files with 257 additions and 6 deletions
-
4common/tskv/src/main/java/com/thing/common/tskv/service/LatestNativeSQL.java
-
8common/tskv/src/main/java/com/thing/common/tskv/service/TsKvNativeSQL.java
-
58modules/carbon-track/src/main/java/com/thing/carbontrack/dict/controller/IotCarbonUnitDictController.java
-
27modules/carbon-track/src/main/java/com/thing/carbontrack/dict/dto/IotCarbonUnitDictDTO.java
-
14modules/carbon-track/src/main/java/com/thing/carbontrack/dict/dto/IotCarbonUnitDto.java
-
32modules/carbon-track/src/main/java/com/thing/carbontrack/dict/entity/IotCarbonUnitDictEntity.java
-
16modules/carbon-track/src/main/java/com/thing/carbontrack/dict/mapper/IotCarbonUnitDictMapper.java
-
22modules/carbon-track/src/main/java/com/thing/carbontrack/dict/service/IotCarbonUnitDictService.java
-
65modules/carbon-track/src/main/java/com/thing/carbontrack/dict/service/impl/IotCarbonUnitDictServiceImpl.java
-
2modules/thing/src/main/java/com/thing/device/source/service/IotThingSourceService.java
-
15modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java
@ -0,0 +1,58 @@ |
|||||
|
package com.thing.carbontrack.dict.controller; |
||||
|
|
||||
|
import com.thing.carbontrack.dict.dto.IotCarbonUnitDto; |
||||
|
import com.thing.carbontrack.dict.service.IotCarbonUnitDictService; |
||||
|
import com.thing.common.core.web.response.Result; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 计量单位字典 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2024-09-23 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("v2/carbonDict") |
||||
|
@Tag(name="计量单位字典") |
||||
|
@RequiredArgsConstructor |
||||
|
public class IotCarbonUnitDictController { |
||||
|
|
||||
|
private final IotCarbonUnitDictService iotCarbonUnitDictService; |
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping("list") |
||||
|
@Operation(summary="一级结构列表") |
||||
|
public Result<List<String>> getList(){ |
||||
|
List<String> info = iotCarbonUnitDictService.getList(); |
||||
|
return new Result< List<String>>().ok(info); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("listByPName") |
||||
|
@Operation(summary="二级结构列表") |
||||
|
public Result<List<String>> listByPName(@RequestParam String pName){ |
||||
|
List<String> info = iotCarbonUnitDictService.listByPName(pName); |
||||
|
return new Result< List<String>>().ok(info); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping("listInfo") |
||||
|
@Operation(summary="树结构列表") |
||||
|
public Result<List<IotCarbonUnitDto>> listInfo(){ |
||||
|
List<IotCarbonUnitDto> info = iotCarbonUnitDictService.listInfo(); |
||||
|
return new Result< List<IotCarbonUnitDto>>().ok(info); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
package com.thing.carbontrack.dict.dto; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 计量单位字典 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2024-09-23 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Schema(description = "计量单位字典") |
||||
|
public class IotCarbonUnitDictDTO implements Serializable { |
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
private Long id; |
||||
|
private String pName; |
||||
|
private String pCode; |
||||
|
private String cName; |
||||
|
private String cCode; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.thing.carbontrack.dict.dto; |
||||
|
|
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class IotCarbonUnitDto { |
||||
|
|
||||
|
private String pNAME; |
||||
|
|
||||
|
private List<String> cList; |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package com.thing.carbontrack.dict.entity; |
||||
|
|
||||
|
import com.mybatisflex.annotation.Id; |
||||
|
import com.mybatisflex.annotation.Table; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import lombok.experimental.Accessors; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 计量单位字典 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2024-09-23 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Accessors(chain = true) |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@Table("iot_carbon_unit_dict") |
||||
|
public class IotCarbonUnitDictEntity implements Serializable { |
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@Id |
||||
|
private Long id; |
||||
|
private String pName; |
||||
|
private String pCode; |
||||
|
private String cName; |
||||
|
private String cCode; |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.thing.carbontrack.dict.mapper; |
||||
|
|
||||
|
import com.thing.carbontrack.dict.entity.IotCarbonUnitDictEntity; |
||||
|
import com.thing.common.orm.mapper.PowerBaseMapper; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 计量单位字典 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2024-09-23 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface IotCarbonUnitDictMapper extends PowerBaseMapper<IotCarbonUnitDictEntity> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package com.thing.carbontrack.dict.service; |
||||
|
|
||||
|
import com.thing.carbontrack.dict.dto.IotCarbonUnitDto; |
||||
|
import com.thing.carbontrack.dict.entity.IotCarbonUnitDictEntity; |
||||
|
import com.thing.common.orm.service.IBaseService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 计量单位字典 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2024-09-23 |
||||
|
*/ |
||||
|
public interface IotCarbonUnitDictService extends IBaseService<IotCarbonUnitDictEntity> { |
||||
|
|
||||
|
List<String> getList(); |
||||
|
|
||||
|
List<String> listByPName(String pName); |
||||
|
|
||||
|
List<IotCarbonUnitDto> listInfo(); |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
package com.thing.carbontrack.dict.service.impl; |
||||
|
|
||||
|
import com.mybatisflex.core.query.QueryColumn; |
||||
|
import com.mybatisflex.core.query.QueryWrapper; |
||||
|
import com.thing.carbontrack.dict.dto.IotCarbonUnitDto; |
||||
|
import com.thing.carbontrack.dict.entity.IotCarbonUnitDictEntity; |
||||
|
import com.thing.carbontrack.dict.mapper.IotCarbonUnitDictMapper; |
||||
|
import com.thing.carbontrack.dict.service.IotCarbonUnitDictService; |
||||
|
import com.thing.common.orm.service.impl.BaseServiceImpl; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import static com.mybatisflex.core.query.QueryMethods.distinct; |
||||
|
|
||||
|
/** |
||||
|
* 计量单位字典 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2024-09-23 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class IotCarbonUnitDictServiceImpl extends BaseServiceImpl<IotCarbonUnitDictMapper, IotCarbonUnitDictEntity> implements IotCarbonUnitDictService { |
||||
|
|
||||
|
@Override |
||||
|
public QueryWrapper getWrapper(Map<String, Object> params){ |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public List<String> getList() { |
||||
|
QueryColumn pName = new QueryColumn("p_name"); |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.select(distinct(pName)) |
||||
|
.from("iot_carbon_unit_dict"); |
||||
|
return this.listAs(wrapper,String.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<String> listByPName(String pName) { |
||||
|
QueryColumn cName = new QueryColumn("c_name"); |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.select(distinct(cName)) |
||||
|
.from("iot_carbon_unit_dict"); |
||||
|
wrapper.eq("p_name",pName); |
||||
|
return this.listAs(wrapper,String.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<IotCarbonUnitDto> listInfo() { |
||||
|
List<IotCarbonUnitDto> resultList = new ArrayList<>(); |
||||
|
List<String> pNames = this.getList(); |
||||
|
pNames.forEach(temp->{ |
||||
|
IotCarbonUnitDto dto = new IotCarbonUnitDto(); |
||||
|
dto.setPNAME(temp); |
||||
|
dto.setCList(this.listByPName(temp)); |
||||
|
resultList.add(dto); |
||||
|
}); |
||||
|
return resultList; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue