27 changed files with 870 additions and 11 deletions
@ -0,0 +1,74 @@ |
|||||
|
package com.buildics.oviphone.back.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.buildics.oviphone.back.common.exception.BusinessException; |
||||
|
import com.buildics.oviphone.back.common.response.PageResponse; |
||||
|
import com.buildics.oviphone.back.common.response.ResponseCode; |
||||
|
import com.buildics.oviphone.back.configurator.interceptor.AccessRequired; |
||||
|
import com.buildics.oviphone.back.dto.company.CompanySearchParams; |
||||
|
import com.buildics.oviphone.back.dto.device.DevicePageSearchParam; |
||||
|
import com.buildics.oviphone.back.service.DeviceService; |
||||
|
import com.buildics.oviphone.back.vo.company.CompanyPageDTO; |
||||
|
import com.buildics.oviphone.back.vo.device.DevicePageDTO; |
||||
|
import io.swagger.v3.oas.annotations.Hidden; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.RequestHeader; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author jwy-style |
||||
|
* |
||||
|
*/ |
||||
|
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
|
||||
|
//@AccessRequired //注解标识是否需要验证token
|
||||
|
@RequestMapping("/device") //http请求路径映射
|
||||
|
@Tag(name = "DeviceController",description = "设备管理的相关接口") |
||||
|
@SuppressWarnings("unchecked") |
||||
|
public class DeviceController { |
||||
|
|
||||
|
private static Logger logger = LoggerFactory.getLogger(DeviceController.class); |
||||
|
|
||||
|
@Autowired |
||||
|
private DeviceService deviceService; |
||||
|
|
||||
|
|
||||
|
|
||||
|
@AccessRequired |
||||
|
@Operation(summary = "获取设备列表") |
||||
|
@RequestMapping(value = "/getListPage",method = RequestMethod.GET) |
||||
|
public PageResponse<IPage<DevicePageDTO>> getListPage( |
||||
|
@Parameter(name="LoginName",description="登录名",required=true,schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName, |
||||
|
@Parameter(name="AccessToken",description="鉴权token",required=true) @RequestHeader(required=true) String AccessToken, |
||||
|
@Parameter(name="UserId",description="用户ID",required=true,schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId, |
||||
|
@Parameter(name="CompanyId",description="所属企业ID",required=false,schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId, |
||||
|
// @Parameter(name="LoginCompanyId",description="登录用户的企业ID",required=false,schema = @Schema(defaultValue = "1") @RequestHeader(required=false) Long LoginCompanyId,
|
||||
|
@Parameter(name="LanguageType",description="语言类型 0:中文 1:英文 2:日文",required=true,schema = @Schema(defaultValue = "0")) @RequestHeader(required=true) Integer LanguageType, |
||||
|
@Parameter(name="UTCOffset",description="格林威治时间与本地时间的差值,单位是分钟,比如东八区是 -480",required=true,schema = @Schema(defaultValue = "-480")) @RequestHeader(required=true) Integer UTCOffset, |
||||
|
DevicePageSearchParam pageSearchParam |
||||
|
) throws BusinessException { |
||||
|
|
||||
|
pageSearchParam.setUserId(UserId); |
||||
|
|
||||
|
PageResponse<IPage<DevicePageDTO>> pageResponse = new PageResponse<IPage<DevicePageDTO>>(); |
||||
|
try{ |
||||
|
pageResponse.setData(deviceService.getListPage(pageSearchParam, CompanyId, UserId, LanguageType, UTCOffset)); |
||||
|
pageResponse.setCode(ResponseCode.SUCCESS); |
||||
|
pageResponse.setMsg("success"); |
||||
|
}catch (Exception e){ |
||||
|
logger.error("查询列表报错",e); |
||||
|
pageResponse.setCode(ResponseCode.SERVER_ERROR); |
||||
|
pageResponse.setMsg(ResponseCode.SERVER_ERROR_MSG); |
||||
|
} |
||||
|
return pageResponse; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.buildics.oviphone.back.dao.auto; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.buildics.oviphone.back.model.DeviceInfo; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* Mapper 接口 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jwy |
||||
|
* @since |
||||
|
*/ |
||||
|
public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.buildics.oviphone.back.dao.auto; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.buildics.oviphone.back.model.UserBuildingRelation; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 用户楼宇关系表 Mapper 接口 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author jwy |
||||
|
* @since |
||||
|
*/ |
||||
|
public interface UserBuildingRelationMapper extends BaseMapper<UserBuildingRelation> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.buildics.oviphone.back.dao.ex; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.buildics.oviphone.back.dao.auto.BasicUserMapper; |
||||
|
import com.buildics.oviphone.back.dao.auto.DeviceInfoMapper; |
||||
|
import com.buildics.oviphone.back.dto.device.DevicePageSearchParam; |
||||
|
import com.buildics.oviphone.back.dto.user.OptUserParam; |
||||
|
import com.buildics.oviphone.back.dto.user.PageSearchParam; |
||||
|
import com.buildics.oviphone.back.vo.device.DevicePageDTO; |
||||
|
import com.buildics.oviphone.back.vo.user.UserInfoVO; |
||||
|
import com.buildics.oviphone.back.vo.user.UserPageDTO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface DeviceInfoMapperExt extends DeviceInfoMapper { |
||||
|
|
||||
|
IPage<DevicePageDTO> getListPage(Page<?> page, @Param("params") DevicePageSearchParam pageSearchParam); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
package com.buildics.oviphone.back.dao.ex; |
||||
|
|
||||
|
import com.buildics.oviphone.back.dao.auto.UserBuildingRelationMapper; |
||||
|
import com.buildics.oviphone.back.vo.building.BindedBuildingVO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface UserBuildingRelationMapperExt extends UserBuildingRelationMapper { |
||||
|
|
||||
|
List<BindedBuildingVO> getBindedBuilding(Long sourceUserId); |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
<?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.buildics.oviphone.back.dao.auto.DeviceInfoMapper"> |
||||
|
|
||||
|
<!-- 通用查询映射结果 --> |
||||
|
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.DeviceInfo"> |
||||
|
<id column="id" property="id" /> |
||||
|
<result column="device_id" property="deviceId" /> |
||||
|
<result column="device_sn" property="deviceSn" /> |
||||
|
<result column="type_id" property="typeId" /> |
||||
|
<result column="wsclient_id" property="wsclientId" /> |
||||
|
<result column="space_id" property="spaceId" /> |
||||
|
<result column="device_name" property="deviceName" /> |
||||
|
<result column="remark" property="remark" /> |
||||
|
<result column="building_id" property="buildingId" /> |
||||
|
<result column="asset_id" property="assetId" /> |
||||
|
<result column="flag" property="flag" /> |
||||
|
<result column="company_id" property="companyId" /> |
||||
|
<result column="created_by" property="createdBy" /> |
||||
|
<result column="created_timestamp" property="createdTimestamp" /> |
||||
|
<result column="updated_by" property="updatedBy" /> |
||||
|
<result column="updated_timestamp" property="updatedTimestamp" /> |
||||
|
<result column="project_id" property="projectId" /> |
||||
|
<result column="floor_id" property="floorId" /> |
||||
|
<result column="flood_flag" property="floodFlag" /> |
||||
|
<result column="administrator_id" property="administratorId" /> |
||||
|
<result column="sensor_id" property="sensorId" /> |
||||
|
<result column="sensor_maker_id" property="sensorMakerId" /> |
||||
|
<result column="sensor_status" property="sensorStatus" /> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 通用查询结果列 --> |
||||
|
<sql id="Base_Column_List"> |
||||
|
id, device_id, device_sn, type_id, wsclient_id, space_id, device_name, remark, building_id, asset_id, flag, company_id, created_by, created_timestamp, updated_by, updated_timestamp, project_id, floor_id, flood_flag, administrator_id, sensor_id, sensor_maker_id, sensor_status |
||||
|
</sql> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,17 @@ |
|||||
|
<?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.buildics.oviphone.back.dao.auto.UserBuildingRelationMapper"> |
||||
|
|
||||
|
<!-- 通用查询映射结果 --> |
||||
|
<resultMap id="BaseResultMap" type="com.buildics.oviphone.back.model.UserBuildingRelation"> |
||||
|
<result column="user_id" property="userId" /> |
||||
|
<result column="building_id" property="buildingId" /> |
||||
|
<result column="create_time" property="createTime" /> |
||||
|
</resultMap> |
||||
|
|
||||
|
<!-- 通用查询结果列 --> |
||||
|
<sql id="Base_Column_List"> |
||||
|
user_id, building_id, create_time |
||||
|
</sql> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,95 @@ |
|||||
|
<?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.buildics.oviphone.back.dao.ex.DeviceInfoMapperExt"> |
||||
|
|
||||
|
<select id="getListPage" resultType="com.buildics.oviphone.back.vo.device.DevicePageDTO"> |
||||
|
select |
||||
|
basic_building.name as buildingName,basic_floor.name as floorName,basic_space.name as spaceName, |
||||
|
basic_monitoring_asset.symbol as assetSymbol,type.name as typeName, |
||||
|
device_info.id as id, device_info.device_id as deviceId, device_info.device_sn as deviceSn, device_info.type_id as typeId,type.device_category_id as categoryId, |
||||
|
device_info.device_name as deviceName, basic_monitoring_asset.equipment_id as assetId, device_info.company_id as companyId, |
||||
|
device_info.flood_flag,device_info.administrator_id, device_info.sensor_id,device_info.sensor_maker_id,device_info.sensor_status, |
||||
|
basic_space.space_id as spaceId, basic_building.building_id as buildingId, device_info.remark as remark, device_info.flag as flag, |
||||
|
device_info.project_id as projectId, basic_floor.floor_id as floorId, device_info.wsclient_id as wsclientId, |
||||
|
type.device_category_id |
||||
|
from |
||||
|
device_info |
||||
|
left join basic_project on device_info.project_id = basic_project.id |
||||
|
left join basic_monitoring_asset on device_info.asset_id = basic_monitoring_asset.equipment_id |
||||
|
left join basic_space on basic_monitoring_asset.space_id = basic_space.space_id |
||||
|
left join basic_floor on basic_space.floor_id = basic_floor.floor_id |
||||
|
left join basic_building on basic_floor.building_id = basic_building.building_id |
||||
|
left join type on device_info.type_id = type.id |
||||
|
left join device_category on type.device_category_id = device_category.id |
||||
|
left join device_alert_config dac on device_info.id=dac.device_config_id and dac.flag = 0 |
||||
|
<if test="params.targetIdValue != null "> |
||||
|
left join target_id_check tic on dac.id = tic.alert_config_id |
||||
|
</if> |
||||
|
<where> |
||||
|
<if test="params.deviceId != null and params.deviceId != ''"> |
||||
|
and device_info.device_id like concat('%', #{params.deviceId}, '%') |
||||
|
</if> |
||||
|
<if test="params.deviceSn != null and params.deviceSn != ''"> |
||||
|
and device_info.device_sn like concat('%', #{params.deviceSn}, '%') |
||||
|
</if> |
||||
|
<if test="params.typeId != null and params.typeId != ''"> |
||||
|
and device_info.type_id = #{params.typeId} |
||||
|
</if> |
||||
|
<if test="params.categoryId != null and params.categoryId != ''"> |
||||
|
and device_category_id = #{params.categoryId} |
||||
|
</if> |
||||
|
<if test="params.deviceName != null and params.deviceName != ''"> |
||||
|
and device_info.device_name like concat('%', #{params.deviceName}, '%') |
||||
|
</if> |
||||
|
<if test="params.assetSymbol != null "> |
||||
|
and basic_monitoring_asset.symbol like concat('%', #{params.assetSymbol}, '%') |
||||
|
</if> |
||||
|
<if test="params.spaceId != null "> |
||||
|
and basic_space.space_id = #{params.spaceId} |
||||
|
</if> |
||||
|
<if test="params.buildingId != null "> |
||||
|
and basic_building.building_id = #{params.buildingId} |
||||
|
</if> |
||||
|
<if test="params.projectId != null "> |
||||
|
and device_info.project_id = #{params.projectId} |
||||
|
</if> |
||||
|
<if test="params.floorId != null "> |
||||
|
and basic_floor.floor_id = #{params.floorId} |
||||
|
</if> |
||||
|
<if test="params.targetIdValue != null "> |
||||
|
and tic.target_id_value = #{params.targetIdValue} |
||||
|
</if> |
||||
|
<if test="params.deviceCategoryId != null "> |
||||
|
and type.device_category_id = #{params.deviceCategoryId} |
||||
|
</if> |
||||
|
<if test="params.companyIds != null and params.companyIds != ''"> |
||||
|
and device_info.company_id in (#{params.companyIds}) |
||||
|
</if> |
||||
|
<if test="params.companyIdList != null and params.companyIdList.size() > 0"> |
||||
|
and device_info.company_id in |
||||
|
<foreach collection="params.companyIdList" item="companyId" open="(" separator="," close=")"> |
||||
|
#{companyId} |
||||
|
</foreach> |
||||
|
</if> |
||||
|
<if test="params.bindBuildingIdList != null and params.bindBuildingIdList.size() > 0"> |
||||
|
and basic_building.building_id in |
||||
|
<foreach collection="params.bindBuildingIdList" item="bindBuildingId" open="(" separator="," close=")"> |
||||
|
#{bindBuildingId} |
||||
|
</foreach> |
||||
|
</if> |
||||
|
<if test="params.typeIdList != null and params.typeIdList.size() > 0"> |
||||
|
and device_info.type_id in |
||||
|
<foreach collection="params.typeIdList" item="typeId" open="(" separator="," close=")"> |
||||
|
#{typeId} |
||||
|
</foreach> |
||||
|
</if> |
||||
|
and device_info.flag = 0 |
||||
|
|
||||
|
</where> |
||||
|
<if test="params.orderBy != null"> |
||||
|
order by ${params.orderBy} ${params.orderMode} |
||||
|
</if> |
||||
|
|
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,20 @@ |
|||||
|
<?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.buildics.oviphone.back.dao.ex.UserBuildingRelationMapperExt"> |
||||
|
|
||||
|
<select id="getBindedBuilding" resultType="com.buildics.oviphone.back.vo.building.BindedBuildingVO"> |
||||
|
SELECT |
||||
|
b.building_id, |
||||
|
b.name AS buildingName, |
||||
|
b.address, |
||||
|
b.udf_building_id |
||||
|
FROM |
||||
|
user_building_relation ubr |
||||
|
INNER JOIN |
||||
|
basic_building b ON ubr.building_id = b.building_id |
||||
|
WHERE |
||||
|
ubr.user_id = #{userId} AND b.flag != 1 |
||||
|
AND b.flag = 0 |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,70 @@ |
|||||
|
package com.buildics.oviphone.back.dto.device; |
||||
|
|
||||
|
import com.buildics.oviphone.back.dto.BaseSearchParams; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author Mr.zhc |
||||
|
* @time 2022年7月27日12:06:35 |
||||
|
*/ |
||||
|
@Setter |
||||
|
@Getter |
||||
|
public class DevicePageSearchParam extends BaseSearchParams{ |
||||
|
|
||||
|
@Schema(description ="Binded building IDs", hidden = true) |
||||
|
private List<Long> bindBuildingIdList; |
||||
|
|
||||
|
@Schema(description ="type IDs", hidden = true) |
||||
|
private List<Long> typeIdList; |
||||
|
|
||||
|
@Schema(description = "Device SN", example = "2738967") |
||||
|
private String deviceSn; |
||||
|
|
||||
|
@Schema(description = "Device type ID", example = "2738967") |
||||
|
private Long typeId; |
||||
|
|
||||
|
@Schema(description = "Device category ID", example = "1") |
||||
|
private Long categoryId; |
||||
|
|
||||
|
@Schema(description = "Device ID", example = "2738967") |
||||
|
private String deviceId; |
||||
|
|
||||
|
@Schema(description = "Device ID", example = "[2738967]", hidden = true) |
||||
|
private List<String> deviceIdList; |
||||
|
|
||||
|
@Schema(description = "Device name", example = "Device 1") |
||||
|
private String deviceName; |
||||
|
|
||||
|
@Schema(description = "Project ID", example = "1") |
||||
|
private Long projectId; |
||||
|
|
||||
|
@Schema(description = "Building ID", example = "1") |
||||
|
private Long buildingId; |
||||
|
|
||||
|
@Schema(description = "Floor ID", example = "1") |
||||
|
private Long floorId; |
||||
|
|
||||
|
@Schema(description = "Space ID", example = "1") |
||||
|
private Long spaceId; |
||||
|
|
||||
|
@Schema(description = "Asset symbol", example = "asset-01") |
||||
|
private String assetSymbol; |
||||
|
|
||||
|
@Schema(description = "Target ID value", example = "33") |
||||
|
private Integer targetIdValue; |
||||
|
|
||||
|
@Schema(description = "Device category ID", example = "12", title = "Device category ID") |
||||
|
private Long deviceCategoryId; |
||||
|
|
||||
|
@Schema(description = "order by [what]", example = "deviceId,deviceName,symbol") |
||||
|
private String orderBy; |
||||
|
|
||||
|
@Schema(description = "order mode", example = "desc,asc") |
||||
|
private String orderMode = "asc"; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
package com.buildics.oviphone.back.model; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import lombok.ToString; |
||||
|
import lombok.experimental.Accessors; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ToString |
||||
|
@Accessors(chain = true) |
||||
|
@TableName("device_info") |
||||
|
@Schema(description = "") |
||||
|
public class DeviceInfo implements Serializable { |
||||
|
|
||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||
|
@Schema(description = "") |
||||
|
private Integer id; |
||||
|
|
||||
|
|
||||
|
@TableField("device_id") |
||||
|
@Schema(description = "") |
||||
|
private String deviceId; |
||||
|
|
||||
|
@TableField("device_sn") |
||||
|
@Schema(description = "用于记录SN,当SN与deviceId不同时使用") |
||||
|
private String deviceSn; |
||||
|
|
||||
|
@TableField("type_id") |
||||
|
@Schema(description = "") |
||||
|
private Integer typeId; |
||||
|
|
||||
|
@TableField("wsclient_id") |
||||
|
@Schema(description = "") |
||||
|
private Integer wsclientId; |
||||
|
|
||||
|
@TableField("space_id") |
||||
|
@Schema(description = "空间ID") |
||||
|
private Long spaceId; |
||||
|
|
||||
|
@TableField("device_name") |
||||
|
@Schema(description = "设备名称") |
||||
|
private String deviceName; |
||||
|
|
||||
|
@TableField("remark") |
||||
|
@Schema(description = "备注信息") |
||||
|
private String remark; |
||||
|
|
||||
|
@TableField("building_id") |
||||
|
@Schema(description = "楼宇ID") |
||||
|
private Long buildingId; |
||||
|
|
||||
|
@TableField("asset_id") |
||||
|
@Schema(description = "资产ID") |
||||
|
private Long assetId; |
||||
|
|
||||
|
@TableField("flag") |
||||
|
@Schema(description = "") |
||||
|
private Integer flag; |
||||
|
|
||||
|
@TableField("company_id") |
||||
|
@Schema(description = "公司ID") |
||||
|
private Long companyId; |
||||
|
|
||||
|
@TableField("created_by") |
||||
|
@Schema(description = "") |
||||
|
private Long createdBy; |
||||
|
|
||||
|
@TableField("created_timestamp") |
||||
|
@Schema(description = "") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createdTimestamp; |
||||
|
|
||||
|
@TableField("updated_by") |
||||
|
@Schema(description = "") |
||||
|
private Long updatedBy; |
||||
|
|
||||
|
@TableField("updated_timestamp") |
||||
|
@Schema(description = "") |
||||
|
private Long updatedTimestamp; |
||||
|
|
||||
|
@TableField("project_id") |
||||
|
@Schema(description = "项目ID") |
||||
|
private Long projectId; |
||||
|
|
||||
|
@TableField("floor_id") |
||||
|
@Schema(description = "楼宇ID") |
||||
|
private Long floorId; |
||||
|
|
||||
|
@TableField("flood_flag") |
||||
|
@Schema(description = "洪水接口是否通知标志 (0:不通知, 1:通知)") |
||||
|
private Integer floodFlag; |
||||
|
|
||||
|
@TableField("administrator_id") |
||||
|
@Schema(description = "传感器管理者代码 (实证团体代码,需保留前导0,例: 36859)") |
||||
|
private String administratorId; |
||||
|
|
||||
|
@TableField("sensor_id") |
||||
|
@Schema(description = "传感器ID (管理者代码5位 + 管理编号5位,例: 1234567890)") |
||||
|
private String sensorId; |
||||
|
|
||||
|
@TableField("sensor_maker_id") |
||||
|
@Schema(description = "传感器厂商代码 (例: 001)") |
||||
|
private String sensorMakerId; |
||||
|
|
||||
|
@TableField("sensor_status") |
||||
|
@Schema(description = "传感器固有状态 (0001=传感器异常, 0010=处理部异常, 1000=维护中, 其他由厂商定义)") |
||||
|
private String sensorStatus; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
package com.buildics.oviphone.back.model; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import lombok.ToString; |
||||
|
import lombok.experimental.Accessors; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
@ToString |
||||
|
@Accessors(chain = true) |
||||
|
@TableName("user_building_relation") |
||||
|
@Schema(description = "用户楼宇关系表") |
||||
|
public class UserBuildingRelation implements Serializable { |
||||
|
|
||||
|
|
||||
|
@TableField("user_id") |
||||
|
@Schema(description = "") |
||||
|
private Long userId; |
||||
|
|
||||
|
@TableField("building_id") |
||||
|
@Schema(description = "") |
||||
|
private Long buildingId; |
||||
|
|
||||
|
@TableField("create_time") |
||||
|
@Schema(description = "") |
||||
|
private Long createTime; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
package com.buildics.oviphone.back.vo.building; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author Mr.Jiang |
||||
|
* @time 2022年7月21日 下午8:50:31 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BindedBuildingVO { |
||||
|
|
||||
|
@Schema(description = "Building ID (unique identifier, not applicable for new entries)", example = "2738967") |
||||
|
private Long buildingId; |
||||
|
|
||||
|
@Schema(description = "Building name", example = "testBuilding1", required = true) |
||||
|
private String buildingName; |
||||
|
|
||||
|
@Schema(description = "Address", example = "日本我孙子市", required = true) |
||||
|
private String address; |
||||
|
|
||||
|
@Schema(description = "User-defined building ID", example = "123AAA6", required = true) |
||||
|
private String udfBuildingId; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
package com.buildics.oviphone.back.vo.building; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author Mr.Jiang |
||||
|
* @time 2022年7月21日 下午8:50:31 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BuildingPageVO{ |
||||
|
|
||||
|
@Schema(description = "Building ID (unique identifier, not applicable for new entries)", example = "2738967") |
||||
|
private Long buildingId; |
||||
|
|
||||
|
@Schema(description = "Company ID", example = "2738967") |
||||
|
private Long companyId; |
||||
|
|
||||
|
@Schema(description = "Company name", example = "testCompany1", required = true) |
||||
|
private String companyName; |
||||
|
|
||||
|
@Schema(description = "Building name", example = "testBuilding1", required = true) |
||||
|
private String buildingName; |
||||
|
|
||||
|
@Schema(description = "Address", example = "日本我孙子市", required = true) |
||||
|
private String address; |
||||
|
|
||||
|
@Schema(description = "User-defined building ID", example = "123AAA6", required = true) |
||||
|
private String udfBuildingId; |
||||
|
|
||||
|
@Schema(description ="Autodesk Cloud BIM Model Key", example = "123AAA6", required = true) |
||||
|
private String buildingBucket; |
||||
|
|
||||
|
@Schema(description ="Custom floor info", example = "[]", required = true) |
||||
|
private String floorInfoList; |
||||
|
|
||||
|
@Schema(description ="Building image number", example = "2") |
||||
|
private Integer thumbnailNum; |
||||
|
|
||||
|
@Schema(description ="displayed on the 2d3d, 0-yes, 1-no", example = "1") |
||||
|
private Integer showSwitch2d3d; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,87 @@ |
|||||
|
package com.buildics.oviphone.back.vo.device; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author Mr.Jiang |
||||
|
* @time 2022年7月21日 下午8:50:31 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DevicePageDTO { |
||||
|
|
||||
|
private Long id; |
||||
|
|
||||
|
private String deviceId; |
||||
|
|
||||
|
private String deviceSn; |
||||
|
|
||||
|
private Long typeId; |
||||
|
|
||||
|
private Long categoryId; |
||||
|
|
||||
|
private String typeName; |
||||
|
|
||||
|
private Long wsclientId; |
||||
|
|
||||
|
private Long spaceId; |
||||
|
|
||||
|
private String spaceName; |
||||
|
|
||||
|
private String deviceName; |
||||
|
|
||||
|
private String remark; |
||||
|
|
||||
|
private Long buildingId; |
||||
|
|
||||
|
private String buildingName; |
||||
|
|
||||
|
private Long assetId; |
||||
|
|
||||
|
private String assetSymbol; |
||||
|
|
||||
|
private Integer flag; |
||||
|
|
||||
|
private Long companyId; |
||||
|
|
||||
|
private Long createdBy; |
||||
|
|
||||
|
private Long createdTimestamp; |
||||
|
|
||||
|
private Long updatedBy; |
||||
|
|
||||
|
private Long updatedTimestamp; |
||||
|
|
||||
|
private Long projectId; |
||||
|
|
||||
|
private Long floorId; |
||||
|
|
||||
|
private String floorName; |
||||
|
|
||||
|
private String targetId; |
||||
|
|
||||
|
private String targetIdValue; |
||||
|
|
||||
|
|
||||
|
@Schema(description = "Device Category ID", example = "5") |
||||
|
private Long deviceCategoryId; |
||||
|
|
||||
|
@Schema(description = "Device Category Name", example = "Dajin") |
||||
|
private String deviceCategoryName; |
||||
|
|
||||
|
@Schema(description = "洪水接口是否通知标志,0-不通知,1-通知", example = "1") |
||||
|
private Integer floodFlag; |
||||
|
|
||||
|
@Schema(description = "传感器管理者代码", example = "36859") |
||||
|
private String administratorId; |
||||
|
|
||||
|
@Schema(description = "传感器ID", example = "1234567890") |
||||
|
private String sensorId; |
||||
|
|
||||
|
@Schema(description = "传感器厂商代码", example = "001") |
||||
|
private String sensorMakerId; |
||||
|
|
||||
|
@Schema(description = "传感器固有状态", example = "0070") |
||||
|
private String sensorStatus; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.buildics.oviphone.back.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.buildics.oviphone.back.dto.device.DevicePageSearchParam; |
||||
|
import com.buildics.oviphone.back.vo.company.CompanyPageDTO; |
||||
|
import com.buildics.oviphone.back.vo.device.DevicePageDTO; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author jwy-style |
||||
|
* |
||||
|
*/ |
||||
|
public interface DeviceService { |
||||
|
|
||||
|
IPage<DevicePageDTO> getListPage(DevicePageSearchParam pageSearchParam, Long companyId, Long userId, Integer languageType, Integer utcOffset); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,101 @@ |
|||||
|
package com.buildics.oviphone.back.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.buildics.oviphone.back.common.language.msg.MsgLanguageChange; |
||||
|
import com.buildics.oviphone.back.dao.ex.BasicCompanyMapperExt; |
||||
|
import com.buildics.oviphone.back.dao.ex.BasicUserMapperExt; |
||||
|
import com.buildics.oviphone.back.dao.ex.DeviceInfoMapperExt; |
||||
|
import com.buildics.oviphone.back.dto.company.CompanySearchParams; |
||||
|
import com.buildics.oviphone.back.dto.device.DevicePageSearchParam; |
||||
|
import com.buildics.oviphone.back.service.CompanyService; |
||||
|
import com.buildics.oviphone.back.service.DeviceService; |
||||
|
import com.buildics.oviphone.back.service.common.CommonOpt; |
||||
|
import com.buildics.oviphone.back.util.async.OptAsync; |
||||
|
import com.buildics.oviphone.back.vo.company.CompanyPageDTO; |
||||
|
import com.buildics.oviphone.back.vo.device.DevicePageDTO; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author jwy-style |
||||
|
* |
||||
|
*/ |
||||
|
@Service |
||||
|
public class DeviceServiceImpl implements DeviceService { |
||||
|
|
||||
|
private static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class); |
||||
|
|
||||
|
@Value("${wgbt.type.id}") |
||||
|
private List<Long> wgbtTypeIdList; |
||||
|
|
||||
|
@Autowired |
||||
|
private OptAsync optAsync; |
||||
|
@Autowired |
||||
|
private MsgLanguageChange msgLanguageChange; |
||||
|
@Autowired |
||||
|
private BasicCompanyMapperExt basicCompanyMapperExt; |
||||
|
@Autowired |
||||
|
private CommonOpt commonOpt; |
||||
|
@Autowired |
||||
|
private DeviceInfoMapperExt deviceInfoMapperExt; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public IPage<DevicePageDTO> getListPage(DevicePageSearchParam pageSearchParam, Long companyId, |
||||
|
Long userId, Integer languageType, Integer uTCOffset) { |
||||
|
|
||||
|
pageSearchParam.setTypeIdList(wgbtTypeIdList); |
||||
|
|
||||
|
if (StringUtils.isBlank(pageSearchParam.getCompanyIds())) { |
||||
|
pageSearchParam.setCompanyIdList(Arrays.asList(companyId)); |
||||
|
} else { |
||||
|
pageSearchParam.setCompanyIdList(commonOpt.filterCompanyIds(companyId, pageSearchParam.getCompanyIds())); |
||||
|
} |
||||
|
|
||||
|
if (pageSearchParam.getOrderBy()!=null){ |
||||
|
switch (pageSearchParam.getOrderBy()){ |
||||
|
case "device_name": |
||||
|
pageSearchParam.setOrderBy("device_name"); |
||||
|
break; |
||||
|
case "device_id": |
||||
|
pageSearchParam.setOrderBy("deviceId"); |
||||
|
break; |
||||
|
case "symbol": |
||||
|
pageSearchParam.setOrderBy("assetSymbol"); |
||||
|
break; |
||||
|
default: |
||||
|
pageSearchParam.setOrderBy(null); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
pageSearchParam.setBindBuildingIdList(commonOpt.getBindBuildingIdList(userId)); |
||||
|
|
||||
|
Page<DevicePageDTO> page = new Page<>( |
||||
|
pageSearchParam.getPageNum() == null ? 1 : pageSearchParam.getPageNum(), |
||||
|
pageSearchParam.getPageSize() == null ? 20 : pageSearchParam.getPageSize()); |
||||
|
IPage<DevicePageDTO> resultList = deviceInfoMapperExt.getListPage(page, pageSearchParam); |
||||
|
|
||||
|
if (CollectionUtils.isNotEmpty(resultList.getRecords())) { |
||||
|
for (DevicePageDTO devicePageDTO : resultList.getRecords()) { |
||||
|
if (null != devicePageDTO.getDeviceCategoryId()) { |
||||
|
devicePageDTO.setDeviceCategoryName(msgLanguageChange.getParameterMapByCode(languageType, "category_" + devicePageDTO.getDeviceCategoryId())); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return resultList; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue