完成数据大屏用户活跃度接口

This commit is contained in:
wenhui 2022-03-09 15:46:36 +08:00
parent 172ee9a72b
commit a60fbda52a
9 changed files with 197 additions and 22 deletions

View File

@ -19,4 +19,16 @@ public class ConstantClass {
public static final String CHARGING_STATION_ID = "chargingStationId"; public static final String CHARGING_STATION_ID = "chargingStationId";
/**
* 用于数据大屏前端传递进来的参数功能判断
* <p>
* 分别为全国区域地点
*
* @date 2022/3/9 13:46
* @since version-1.0
*/
public static final Integer COUNTRY = 0;
public static final Integer AREA = 1;
public static final Integer POINT = 2;
} }

View File

@ -12,6 +12,13 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* Controller of data big screen
*
* @author WH
* @date 2022/3/9 10:44
* @since version-1.0
*/
@RestController @RestController
@RequestMapping("/big-screen") @RequestMapping("/big-screen")
public class XhpcDataBigScreenController extends BaseController { public class XhpcDataBigScreenController extends BaseController {
@ -19,16 +26,44 @@ public class XhpcDataBigScreenController extends BaseController {
@Resource @Resource
XhpcDataBigScreenService xhpcDataBigScreenService; XhpcDataBigScreenService xhpcDataBigScreenService;
@GetMapping("/core-locations") /**
public R<List<Map<String, Object>>> returnCoreLocation(CoreParam coreParam) { * Return user activation
*
* @author WH
* @date 2022/3/9 13:53
* @since version-1.0
*/
@GetMapping("/user-activation")
public R<Object> queryUserActivation(CoreParam coreParam) {
return xhpcDataBigScreenService.returnCoreLocation(coreParam); return xhpcDataBigScreenService.queryUserActivation(coreParam);
} }
/**
* Return a count of user total
*
* @author WH
* @date 2022/3/9 10:43
* @since version-1.0
*/
@GetMapping("/user-total-count") @GetMapping("/user-total-count")
public R<Object> queryUserTotalCount(CoreParam coreParam) { public R<Object> queryUserTotalCount(CoreParam coreParam) {
return xhpcDataBigScreenService.queryUserTotalCount(coreParam); return xhpcDataBigScreenService.queryUserTotalCount(coreParam);
} }
/**
* Core interface
* Return special info of charging station
*
* @author WH
* @date 2022/3/9 10:42
* @since version-1.0
*/
@GetMapping("/core-locations")
public R<List<Map<String, Object>>> returnCoreLocation(CoreParam coreParam) {
return xhpcDataBigScreenService.returnCoreLocation(coreParam);
}
} }

View File

@ -0,0 +1,21 @@
package com.xhpc.databigscreen.domain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 额外的条件参数类
*
* @author WH
* @date 2022/3/9 14:11
* @since version-1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class Condition extends CoreParam {
private String currentTime;
}

View File

@ -28,6 +28,6 @@ public interface XhpcAppUserMapper {
* @date 2022/3/4 10:37 * @date 2022/3/4 10:37
* @since version-1.0 * @since version-1.0
*/ */
Long selectTotalCountByTenantId(@Param("tenantIdList") List<String> tenantIdList); Long selectTotalCountByTenantIdAndCurrentTime(@Param("tenantIdList") List<String> tenantIdList, @Param("currentTime") String currentTime);
} }

View File

@ -26,6 +26,10 @@ public interface XhpcHistoryOrderMapper {
* @date 2022/3/4 15:32 * @date 2022/3/4 15:32
* @since version-1.0 * @since version-1.0
*/ */
Long selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(@Param("tenantIdList") List<String> tenantIdList, @Param("chargingStationIdList") List<Long> chargingStationIdList, @Param("userType") Integer userType); Long selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(
@Param("tenantIdList") List<String> tenantIdList,
@Param("chargingStationIdList") List<Long> chargingStationIdList,
@Param("userType") Integer userType,
@Param("currentTime") String currentTime);
} }

View File

@ -31,4 +31,13 @@ public interface XhpcDataBigScreenService {
*/ */
R<Object> queryUserTotalCount(CoreParam coreParam); R<Object> queryUserTotalCount(CoreParam coreParam);
/**
* query activation of user
*
* @author WH
* @date 2022/3/9 13:54
* @since version-1.0
*/
R<Object> queryUserActivation(CoreParam coreParam);
} }

View File

@ -2,6 +2,7 @@ package com.xhpc.databigscreen.service.impl;
import com.xhpc.common.constant.ConstantClass; import com.xhpc.common.constant.ConstantClass;
import com.xhpc.common.core.domain.R; import com.xhpc.common.core.domain.R;
import com.xhpc.common.util.MyDateUtil;
import com.xhpc.common.util.UserTypeUtil; import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.databigscreen.domain.CoreParam; import com.xhpc.databigscreen.domain.CoreParam;
import com.xhpc.databigscreen.mapper.XhpcAppUserMapper; import com.xhpc.databigscreen.mapper.XhpcAppUserMapper;
@ -103,19 +104,19 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
tenantIdArray = tenantIdsStr.split(","); tenantIdArray = tenantIdsStr.split(",");
tenantIdList = Arrays.stream(tenantIdArray).collect(Collectors.toList()); tenantIdList = Arrays.stream(tenantIdArray).collect(Collectors.toList());
//get user count of c client //get user count of c client
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
List<Long> chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList); List<Long> chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList);
//0 C端用户 1 流量方用户 2社区用户 3B端用户 //0 C端用户 1 流量方用户 2社区用户 3B端用户
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount); return R.ok(appUserCount + communityUserCount + customerUserCount);
} else { } else {
//get user count of c client //get user count of c client
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
List<Long> chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList); List<Long> chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList);
//0 C端用户 1 流量方用户 2社区用户 3B端用户 //0 C端用户 1 流量方用户 2社区用户 3B端用户
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount); return R.ok(appUserCount + communityUserCount + customerUserCount);
} }
//query charging station infos of whole area //query charging station infos of whole area
@ -130,9 +131,9 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
for (Map<String, Object> chargingStation : xhpcChargingStationList) { for (Map<String, Object> chargingStation : xhpcChargingStationList) {
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID)); chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
} }
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount); return R.ok(appUserCount + communityUserCount + customerUserCount);
} else { } else {
xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndAreaCode(tenantIdList, areaCode); xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndAreaCode(tenantIdList, areaCode);
@ -140,9 +141,9 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
for (Map<String, Object> chargingStation : xhpcChargingStationList) { for (Map<String, Object> chargingStation : xhpcChargingStationList) {
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID)); chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
} }
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount); return R.ok(appUserCount + communityUserCount + customerUserCount);
} }
case 2: case 2:
@ -158,9 +159,95 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
for (Map<String, Object> chargingStation : xhpcChargingStationList) { for (Map<String, Object> chargingStation : xhpcChargingStationList) {
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID)); chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
} }
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount);
} else {
return R.fail("传入的参数有误");
}
default:
R.fail("param type is invalid");
break;
}
return null;
}
@Override
public R<Object> queryUserActivation(CoreParam coreParam) {
String tenantIdsStr = null;
List<Map<String, Object>> xhpcChargingStationList = null;
List<String> tenantIdList = null;
String[] tenantIdArray = null;
String currentTime = MyDateUtil.getCurrentDateStrInYyyyMmDdHhMmSsFormat();
//judge care param function
switch (coreParam.getParamType()) {
case 0:
tenantIdsStr = coreParam.getTenantIds();
if (!"".equals(tenantIdsStr) && tenantIdsStr != null) {
tenantIdArray = tenantIdsStr.split(",");
tenantIdList = Arrays.stream(tenantIdArray).collect(Collectors.toList());
//get user count of c client
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, currentTime);
List<Long> chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList);
//0 C端用户 1 流量方用户 2社区用户 3B端用户
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, currentTime);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, currentTime);
return R.ok(appUserCount + communityUserCount + customerUserCount);
} else {
//get user count of c client
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, currentTime);
List<Long> chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList);
//0 C端用户 1 流量方用户 2社区用户 3B端用户
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, currentTime);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, currentTime);
return R.ok(appUserCount + communityUserCount + customerUserCount);
}
//query charging station infos of whole area
case 1:
Integer areaCode = coreParam.getAreaCode();
tenantIdsStr = coreParam.getTenantIds();
if (!"".equals(tenantIdsStr) && tenantIdsStr != null) {
tenantIdArray = tenantIdsStr.split(",");
tenantIdList = Arrays.stream(tenantIdArray).collect(Collectors.toList());
xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndAreaCode(tenantIdList, areaCode);
ArrayList<Long> chargingStationIdList = new ArrayList<>();
for (Map<String, Object> chargingStation : xhpcChargingStationList) {
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
}
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount);
} else {
xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndAreaCode(tenantIdList, areaCode);
ArrayList<Long> chargingStationIdList = new ArrayList<>();
for (Map<String, Object> chargingStation : xhpcChargingStationList) {
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
}
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount);
}
case 2:
//query location info of special charging station of special tenant
tenantIdsStr = coreParam.getTenantIds();
if (!"".equals(tenantIdsStr) && tenantIdsStr != null) {
tenantIdArray = tenantIdsStr.split(",");
tenantIdList = Arrays.stream(tenantIdArray).collect(Collectors.toList());
String chargingStationIdStr = coreParam.getChargingStationIds();
long chargingStationId = Long.parseLong(chargingStationIdStr);
xhpcChargingStationList = xhpcChargingStationMapper.selectByTenantIdAndChargingStationId(tenantIdList, chargingStationId);
ArrayList<Long> chargingStationIdList = new ArrayList<>();
for (Map<String, Object> chargingStation : xhpcChargingStationList) {
chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID));
}
Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null);
Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE, null);
Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE, null);
return R.ok(appUserCount + communityUserCount + customerUserCount); return R.ok(appUserCount + communityUserCount + customerUserCount);
} else { } else {
return R.fail("传入的参数有误"); return R.fail("传入的参数有误");

View File

@ -37,7 +37,7 @@
from xhpc_app_user from xhpc_app_user
where app_user_id = #{appUserId,jdbcType=BIGINT} where app_user_id = #{appUserId,jdbcType=BIGINT}
</select> </select>
<select id="selectTotalCountByTenantId" resultType="java.lang.Long"> <select id="selectTotalCountByTenantIdAndCurrentTime" resultType="java.lang.Long">
SELECT SELECT
count(phone) count(phone)
FROM FROM
@ -53,6 +53,9 @@
#{tenantId} #{tenantId}
</foreach> </foreach>
</if> </if>
<if test="currentTime!=null and currentTime!='' ">
and create_time <![CDATA[>=]]> DATE_ADD(#{currentTime},INTERVAL -3 MONTH)
</if>
</where> </where>
) AS a ) AS a
</select> </select>

View File

@ -77,7 +77,8 @@
from xhpc_history_order from xhpc_history_order
where history_order_id = #{historyOrderId,jdbcType=BIGINT} where history_order_id = #{historyOrderId,jdbcType=BIGINT}
</select> </select>
<select id="selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType" resultType="java.lang.Long"> <select id="selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime"
resultType="java.lang.Long">
SELECT SELECT
count(user_id) count(user_id)
FROM FROM
@ -103,6 +104,9 @@
<if test="userType!=null"> <if test="userType!=null">
AND source = #{userType} AND source = #{userType}
</if> </if>
<if test="currentTime!=null and currentTime!='' ">
and create_time <![CDATA[>=]]> DATE_ADD(#{currentTime},INTERVAL -3 MONTH)
</if>
) AS a ) AS a
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">