diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/constant/ConstantClass.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/constant/ConstantClass.java index 6951cc94..8da714f8 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/constant/ConstantClass.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/constant/ConstantClass.java @@ -19,4 +19,16 @@ public class ConstantClass { public static final String CHARGING_STATION_ID = "chargingStationId"; + /** + * 用于数据大屏,前端传递进来的参数功能判断 + *

+ * 分别为:全国、区域、地点 + * + * @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; + } diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/controller/XhpcDataBigScreenController.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/controller/XhpcDataBigScreenController.java index b5e0d76d..08b9513e 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/controller/XhpcDataBigScreenController.java +++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/controller/XhpcDataBigScreenController.java @@ -12,6 +12,13 @@ import javax.annotation.Resource; import java.util.List; import java.util.Map; +/** + * Controller of data big screen + * + * @author WH + * @date 2022/3/9 10:44 + * @since version-1.0 + */ @RestController @RequestMapping("/big-screen") public class XhpcDataBigScreenController extends BaseController { @@ -19,16 +26,44 @@ public class XhpcDataBigScreenController extends BaseController { @Resource XhpcDataBigScreenService xhpcDataBigScreenService; - @GetMapping("/core-locations") - public R>> returnCoreLocation(CoreParam coreParam) { + /** + * Return user activation + * + * @author WH + * @date 2022/3/9 13:53 + * @since version-1.0 + */ + @GetMapping("/user-activation") + public R 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") public R queryUserTotalCount(CoreParam 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>> returnCoreLocation(CoreParam coreParam) { + + return xhpcDataBigScreenService.returnCoreLocation(coreParam); + } + } diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/domain/Condition.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/domain/Condition.java new file mode 100644 index 00000000..fa71d70e --- /dev/null +++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/domain/Condition.java @@ -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; + +} diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcAppUserMapper.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcAppUserMapper.java index 3ea2c2e1..b2f816bf 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcAppUserMapper.java +++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcAppUserMapper.java @@ -28,6 +28,6 @@ public interface XhpcAppUserMapper { * @date 2022/3/4 10:37 * @since version-1.0 */ - Long selectTotalCountByTenantId(@Param("tenantIdList") List tenantIdList); + Long selectTotalCountByTenantIdAndCurrentTime(@Param("tenantIdList") List tenantIdList, @Param("currentTime") String currentTime); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcHistoryOrderMapper.java index 19f95bd2..0acdf0c7 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/mapper/XhpcHistoryOrderMapper.java @@ -26,6 +26,10 @@ public interface XhpcHistoryOrderMapper { * @date 2022/3/4 15:32 * @since version-1.0 */ - Long selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(@Param("tenantIdList") List tenantIdList, @Param("chargingStationIdList") List chargingStationIdList, @Param("userType") Integer userType); + Long selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime( + @Param("tenantIdList") List tenantIdList, + @Param("chargingStationIdList") List chargingStationIdList, + @Param("userType") Integer userType, + @Param("currentTime") String currentTime); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/XhpcDataBigScreenService.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/XhpcDataBigScreenService.java index 994f5dc8..19e7baf7 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/XhpcDataBigScreenService.java +++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/XhpcDataBigScreenService.java @@ -31,4 +31,13 @@ public interface XhpcDataBigScreenService { */ R queryUserTotalCount(CoreParam coreParam); + /** + * query activation of user + * + * @author WH + * @date 2022/3/9 13:54 + * @since version-1.0 + */ + R queryUserActivation(CoreParam coreParam); + } diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/impl/XhpcDataBigScreenServiceImpl.java b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/impl/XhpcDataBigScreenServiceImpl.java index f728df90..f8ca7f7c 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/impl/XhpcDataBigScreenServiceImpl.java +++ b/xhpc-modules/xhpc-data-big-screen/src/main/java/com/xhpc/databigscreen/service/impl/XhpcDataBigScreenServiceImpl.java @@ -2,6 +2,7 @@ package com.xhpc.databigscreen.service.impl; import com.xhpc.common.constant.ConstantClass; import com.xhpc.common.core.domain.R; +import com.xhpc.common.util.MyDateUtil; import com.xhpc.common.util.UserTypeUtil; import com.xhpc.databigscreen.domain.CoreParam; import com.xhpc.databigscreen.mapper.XhpcAppUserMapper; @@ -103,19 +104,19 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService { tenantIdArray = tenantIdsStr.split(","); tenantIdList = Arrays.stream(tenantIdArray).collect(Collectors.toList()); //get user count of c client - Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); + Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null); List chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList); //(0 C端用户 1 流量方用户 2社区用户 3B端用户) - Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); - Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); + 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 { //get user count of c client - Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); + Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantIdAndCurrentTime(tenantIdList, null); List chargingStationIdList = xhpcChargingStationMapper.selectChargingStationIds(tenantIdList); //(0 C端用户 1 流量方用户 2社区用户 3B端用户) - Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); - Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); + 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); } //query charging station infos of whole area @@ -130,9 +131,9 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService { for (Map chargingStation : xhpcChargingStationList) { chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID)); } - Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); - Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); - Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); + 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); @@ -140,9 +141,9 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService { for (Map chargingStation : xhpcChargingStationList) { chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID)); } - Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); - Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); - Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); + 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: @@ -158,9 +159,95 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService { for (Map chargingStation : xhpcChargingStationList) { chargingStationIdList.add((Long) chargingStation.get(ConstantClass.CHARGING_STATION_ID)); } - Long appUserCount = xhpcAppUserMapper.selectTotalCountByTenantId(tenantIdList); - Long communityUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.COMMUNIT_TYPE); - Long customerUserCount = xhpcHistoryOrderMapper.selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserType(tenantIdList, chargingStationIdList, UserTypeUtil.CUSTOMERS_TYPE); + 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 { + return R.fail("传入的参数有误"); + } + default: + R.fail("param type is invalid"); + break; + } + return null; + } + + @Override + public R queryUserActivation(CoreParam coreParam) { + + String tenantIdsStr = null; + List> xhpcChargingStationList = null; + List 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 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 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 chargingStationIdList = new ArrayList<>(); + for (Map 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 chargingStationIdList = new ArrayList<>(); + for (Map 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 chargingStationIdList = new ArrayList<>(); + for (Map 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 { return R.fail("传入的参数有误"); diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcAppUserMapper.xml b/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcAppUserMapper.xml index 45a8cd25..522bfe0b 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcAppUserMapper.xml +++ b/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcAppUserMapper.xml @@ -37,7 +37,7 @@ from xhpc_app_user where app_user_id = #{appUserId,jdbcType=BIGINT} - SELECT count(phone) FROM @@ -53,6 +53,9 @@ #{tenantId} + + and create_time =]]> DATE_ADD(#{currentTime},INTERVAL -3 MONTH) + ) AS a diff --git a/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 15ebf644..2ff7f888 100644 --- a/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-data-big-screen/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -77,7 +77,8 @@ from xhpc_history_order where history_order_id = #{historyOrderId,jdbcType=BIGINT} - SELECT count(user_id) FROM @@ -103,6 +104,9 @@ AND source = #{userType} + + and create_time =]]> DATE_ADD(#{currentTime},INTERVAL -3 MONTH) + ) AS a