完成数据大屏核心接口

This commit is contained in:
wenhui 2022-03-03 15:52:39 +08:00
parent f589308199
commit 09e2aa129c
4 changed files with 54 additions and 14 deletions

View File

@ -1,6 +1,5 @@
package com.xhpc.databigscreen.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -15,9 +14,8 @@ import lombok.NoArgsConstructor;
@Data
public class CoreParam {
@JsonProperty("tenantIds")
private String tenantIds;
private String areaCode;
private Integer areaCode;
private String chargingStationIds;
}

View File

@ -1,6 +1,7 @@
package com.xhpc.databigscreen.mapper;
import com.xhpc.databigscreen.pojo.XhpcChargingStation;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
@ -21,12 +22,17 @@ public interface XhpcChargingStationMapper {
int updateByPrimaryKey(XhpcChargingStation record);
/**
* query charging station infos of special tenant or all ones by tenant Id List
*
* @author WH
* @date 2022/2/28 17:50
* @since version-1.0
*/
List<Map<String, Object>> selectByTenantId(ArrayList<Long> tenantIdList);
List<Map<String, Object>> selectByTenantIdAndChargingStationId(@Param("tenantIdList") ArrayList<Long> tenantIdList, @Param("chargingStationId") Long chargingStationId);
/**
* @author WH
* @date 2022/3/3 15:20
* @since version-1.0
*/
List<Map<String, Object>> selectByTenantIdAndAreaCode(@Param("tenantIdStr") String tenantIdStr, @Param("areaCode") Integer areaCode);
}

View File

@ -39,11 +39,25 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
tenantIdList.add(tenantId);
}
}
List<Map<String, Object>> xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantId(tenantIdList);
List<Map<String, Object>> xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndChargingStationId(tenantIdList, null);
return R.ok(xhpcChargingStationList);
} else {
//query location info of special charging station of special tenant
String tenantIdStr = coreParam.getTenantIds();
ArrayList<Long> tenantIdList = new ArrayList<>();
long tenantId = Long.parseLong(tenantIdStr);
tenantIdList.add(tenantId);
String chargingStationIdStr = coreParam.getChargingStationIds();
long chargingStationId = Long.parseLong(chargingStationIdStr);
List<Map<String, Object>> xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndChargingStationId(tenantIdList, chargingStationId);
return R.ok(xhpcChargingStationList);
}
} else {
//query charging station infos of whole area
String tenantIdStr = coreParam.getTenantIds();
Integer areaCode = coreParam.getAreaCode();
List<Map<String, Object>> xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndAreaCode(tenantIdStr, areaCode);
return R.ok(xhpcChargingStationList);
}
}
return null;
}
}

View File

@ -51,12 +51,12 @@
from xhpc_charging_station
where charging_station_id = #{chargingStationId,jdbcType=BIGINT}
</select>
<select id="selectByTenantId" resultType="Map">
<select id="selectByTenantIdAndChargingStationId" resultType="Map">
SELECT
xhpc_charging_station.tenant_id tenantId,
xhpc_charging_station.chargingStationId,
xhpc_charging_station.charging_station_id chargingStationId,
xhpc_charging_station.`name`,
xhpc_charging_station.areaCode,
xhpc_charging_station.area_code areaCode,
xhpc_charging_station.longitude,
xhpc_charging_station.latitude
FROM
@ -64,12 +64,34 @@
WHERE
xhpc_charging_station.del_flag = 0
AND xhpc_charging_station.`status` = 0
<if test="list!=null and list.size()!=0">
<if test="tenantIdList!=null and tenantIdList.size()!=0">
AND xhpc_charging_station.tenant_id in
<foreach collection="list" separator="," open="(" close=")" item="tenantId">
<foreach collection="tenantIdList" separator="," open="(" close=")" item="tenantId">
#{tenantId}
</foreach>
</if>
<if test="chargingStationId!=null">
AND xhpc_charging_station.charging_station_id = #{chargingStationId}
</if>
</select>
<select id="selectByTenantIdAndAreaCode" resultType="map">
SELECT
xhpc_charging_station.tenant_id tenantId,
xhpc_charging_station.charging_station_id chargingStationId,
xhpc_charging_station.`name`,
xhpc_charging_station.area_code areaCode,
xhpc_charging_station.longitude,
xhpc_charging_station.latitude
FROM
xhpc_charging_station
WHERE
del_flag = 0
<if test="tenantIdStr!=null and tenantIdStr!='' ">
AND tenant_id = #{tenantIdStr}
</if>
<if test="areaCode != null and areaCode != '' ">
AND area_code = #{areaCode}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete