Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
rpc-openplatform
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2ddd2a21
authored
Jan 08, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加数据生成类
1 parent
3fe033e8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
335 additions
and
120 deletions
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/CustomerActionStatistics.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/CustomerNetworkStatistics.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/ActivationDataMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/CustomerActionStatisticsMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/CustomerNetworkStatisticsMapper.java
rpc-openplatform-container/src/main/resources/META-INF/orm/ActivationDataMapper.xml
rpc-openplatform-container/src/main/resources/META-INF/orm/CustomerActionStatisticsMapper.xml
rpc-openplatform-container/src/main/resources/META-INF/orm/CustomerNetworkStatisticsMapper.xml
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateCustomerNetworkStatistic.java
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateDeviceActionDetailByCustomer.java
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateDeviceActionDetailByCustomer2.java
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateDeviceNetworkDetailByCustomer.java
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GeneratePlatformDevice.java
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/generate-device-network-detail-scheduler.sql
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/CustomerActionStatistics.java
View file @
2ddd2a2
...
@@ -13,11 +13,6 @@ package cn.com.glsx.openplatform.model;
...
@@ -13,11 +13,6 @@ package cn.com.glsx.openplatform.model;
*/
*/
public
class
CustomerActionStatistics
{
public
class
CustomerActionStatistics
{
/**
/**
* 在线设备数
*/
private
Integer
onlineNumber
;
/**
* id
* id
*/
*/
private
Integer
id
;
private
Integer
id
;
...
@@ -52,13 +47,10 @@ public class CustomerActionStatistics {
...
@@ -52,13 +47,10 @@ public class CustomerActionStatistics {
*/
*/
private
Integer
number
;
private
Integer
number
;
public
Integer
getOnlineNumber
()
{
/**
return
onlineNumber
;
* 在线设备数
}
*/
private
Integer
onlineNumber
;
public
void
setOnlineNumber
(
Integer
onlineNumber
)
{
this
.
onlineNumber
=
onlineNumber
;
}
public
Integer
getId
()
{
public
Integer
getId
()
{
return
id
;
return
id
;
...
@@ -116,17 +108,25 @@ public class CustomerActionStatistics {
...
@@ -116,17 +108,25 @@ public class CustomerActionStatistics {
this
.
number
=
number
;
this
.
number
=
number
;
}
}
public
Integer
getOnlineNumber
()
{
return
onlineNumber
;
}
public
void
setOnlineNumber
(
Integer
onlineNumber
)
{
this
.
onlineNumber
=
onlineNumber
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"CustomerActionStatistics{"
+
return
"CustomerActionStatistics{"
+
"onlineNumber="
+
onlineNumber
+
"id="
+
id
+
", id="
+
id
+
", customerId="
+
customerId
+
", customerId="
+
customerId
+
", customerName='"
+
customerName
+
'\''
+
", customerName='"
+
customerName
+
'\''
+
", deviceType='"
+
deviceType
+
'\''
+
", deviceType='"
+
deviceType
+
'\''
+
", type='"
+
type
+
'\''
+
", type='"
+
type
+
'\''
+
", statisticsTime='"
+
statisticsTime
+
'\''
+
", statisticsTime='"
+
statisticsTime
+
'\''
+
", number="
+
number
+
", number="
+
number
+
", onlineNumber="
+
onlineNumber
+
'}'
;
'}'
;
}
}
}
}
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/CustomerNetworkStatistics.java
View file @
2ddd2a2
...
@@ -47,6 +47,11 @@ public class CustomerNetworkStatistics {
...
@@ -47,6 +47,11 @@ public class CustomerNetworkStatistics {
*/
*/
private
Integer
onlineNumber
;
private
Integer
onlineNumber
;
/**
* 联网次数
*/
private
Integer
onlineCount
;
public
Integer
getId
()
{
public
Integer
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -103,6 +108,14 @@ public class CustomerNetworkStatistics {
...
@@ -103,6 +108,14 @@ public class CustomerNetworkStatistics {
this
.
onlineNumber
=
onlineNumber
;
this
.
onlineNumber
=
onlineNumber
;
}
}
public
Integer
getOnlineCount
()
{
return
onlineCount
;
}
public
void
setOnlineCount
(
Integer
onlineCount
)
{
this
.
onlineCount
=
onlineCount
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"CustomerNetworkStatistics{"
+
return
"CustomerNetworkStatistics{"
+
...
@@ -113,6 +126,7 @@ public class CustomerNetworkStatistics {
...
@@ -113,6 +126,7 @@ public class CustomerNetworkStatistics {
", type='"
+
type
+
'\''
+
", type='"
+
type
+
'\''
+
", statisticsTime='"
+
statisticsTime
+
'\''
+
", statisticsTime='"
+
statisticsTime
+
'\''
+
", onlineNumber="
+
onlineNumber
+
", onlineNumber="
+
onlineNumber
+
", onlineCount="
+
onlineCount
+
'}'
;
'}'
;
}
}
}
}
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/ActivationDataMapper.java
View file @
2ddd2a2
...
@@ -3,7 +3,6 @@ package cn.com.glsx.openplatform.mapper;
...
@@ -3,7 +3,6 @@ package cn.com.glsx.openplatform.mapper;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
cn.com.glsx.openplatform.model.ActivationData
;
import
cn.com.glsx.openplatform.model.ActivationData
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.model.ShipmentData
;
import
cn.com.glsx.openplatform.model.ShipmentData
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -17,7 +16,7 @@ import org.apache.ibatis.annotations.Param;
...
@@ -17,7 +16,7 @@ import org.apache.ibatis.annotations.Param;
*/
*/
@Mapper
@Mapper
public
interface
ActivationDataMapper
{
public
interface
ActivationDataMapper
{
List
<
ActivationData
>
ge
tActivationList
();
List
<
ActivationData
>
selec
tActivationList
();
int
countByDate
(
@Param
(
"startDate"
)
Date
startDate
,
@Param
(
"endDate"
)
Date
endDate
);
int
countByDate
(
@Param
(
"startDate"
)
Date
startDate
,
@Param
(
"endDate"
)
Date
endDate
);
...
@@ -28,8 +27,4 @@ public interface ActivationDataMapper {
...
@@ -28,8 +27,4 @@ public interface ActivationDataMapper {
List
<
String
>
selectDeviceTypeList
();
List
<
String
>
selectDeviceTypeList
();
List
<
ShipmentData
>
selectShipmentByType
(
@Param
(
"deviceType"
)
String
deviceType
);
List
<
ShipmentData
>
selectShipmentByType
(
@Param
(
"deviceType"
)
String
deviceType
);
int
updatePlatformDeviceActivation
(
@Param
(
"device"
)
PlatformDevice
device
,
@Param
(
"startTime"
)
Date
startTime
,
@Param
(
"endTime"
)
Date
endTime
,
@Param
(
"count"
)
int
count
);
}
}
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/CustomerActionStatisticsMapper.java
View file @
2ddd2a2
...
@@ -3,6 +3,7 @@ package cn.com.glsx.openplatform.mapper;
...
@@ -3,6 +3,7 @@ package cn.com.glsx.openplatform.mapper;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
cn.com.glsx.openplatform.model.CustomerActionStatistics
;
import
cn.com.glsx.openplatform.model.CustomerActionStatistics
;
import
cn.com.glsx.openplatform.model.DeviceNetworkDetail
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -19,12 +20,17 @@ import org.apache.ibatis.annotations.Param;
...
@@ -19,12 +20,17 @@ import org.apache.ibatis.annotations.Param;
public
interface
CustomerActionStatisticsMapper
{
public
interface
CustomerActionStatisticsMapper
{
List
<
String
>
selectMonthList
();
List
<
String
>
selectMonthList
();
List
<
PlatformDevice
>
selectPlatformDevice
(
@Param
(
"statistics"
)
CustomerActionStatistics
statistics
,
@Param
(
"endDate"
)
Date
endDate
);
List
<
DeviceNetworkDetail
>
selectDeviceFromDeviceNetworkDetail
(
@Param
(
"customerId"
)
Integer
customerId
,
@Param
(
"endDate"
)
Date
endDate
);
List
<
CustomerActionStatistics
>
selectByMonth
(
@Param
(
"month"
)
String
month
);
List
<
CustomerActionStatistics
>
selectByMonth
(
@Param
(
"month"
)
String
month
);
Integer
selectOnlineNumber
(
CustomerActionStatistics
actionStatistics
);
Integer
selectOnlineNumber
(
CustomerActionStatistics
actionStatistics
);
List
<
CustomerActionStatistics
>
selectByType
(
@Param
(
"type"
)
String
type
);
List
<
PlatformDevice
>
selectDeviceList
(
List
<
PlatformDevice
>
selectDeviceList
(
@Param
(
"actionStatistics"
)
CustomerActionStatistics
actionStatistics
,
@Param
(
"actionStatistics"
)
CustomerActionStatistics
actionStatistics
,
@Param
(
"endDate"
)
Date
endDate
,
@Param
(
"count"
)
Integer
count
);
@Param
(
"endDate"
)
Date
endDate
,
@Param
(
"count"
)
Integer
count
);
...
...
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/CustomerNetworkStatisticsMapper.java
View file @
2ddd2a2
...
@@ -3,6 +3,7 @@ package cn.com.glsx.openplatform.mapper;
...
@@ -3,6 +3,7 @@ package cn.com.glsx.openplatform.mapper;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
cn.com.glsx.openplatform.model.CustomerNetworkStatistics
;
import
cn.com.glsx.openplatform.model.CustomerNetworkStatistics
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -16,11 +17,22 @@ import org.apache.ibatis.annotations.Param;
...
@@ -16,11 +17,22 @@ import org.apache.ibatis.annotations.Param;
@Mapper
@Mapper
public
interface
CustomerNetworkStatisticsMapper
{
public
interface
CustomerNetworkStatisticsMapper
{
List
<
String
>
selectMonthList
();
List
<
CustomerNetworkStatistics
>
selectByMonth
(
@Param
(
"month"
)
String
month
);
List
<
PlatformDevice
>
selectPlatformDevice
(
@Param
(
"statistics"
)
CustomerNetworkStatistics
statistics
,
@Param
(
"endDate"
)
Date
endDate
);
List
<
CustomerNetworkStatistics
>
selectByDate
(
@Param
(
"startDate"
)
String
startDate
,
List
<
CustomerNetworkStatistics
>
selectByDate
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
@Param
(
"endDate"
)
String
endDate
);
List
<
CustomerNetworkStatistics
>
selectFromDeviceNetworkByDate
(
@Param
(
"startDate"
)
Date
startDate
,
//List<CustomerNetworkStatistics> selectFromDeviceNetworkByDate(
@Param
(
"endDate"
)
Date
endDate
);
// @Param("startDate") Date startDate,
// @Param("endDate") Date endDate);
List
<
CustomerNetworkStatistics
>
selectFromCustomerDeviceStatistics
();
int
deleteByPrimaryKey
(
Integer
id
);
int
deleteByPrimaryKey
(
Integer
id
);
...
...
rpc-openplatform-container/src/main/resources/META-INF/orm/ActivationDataMapper.xml
View file @
2ddd2a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<result
column=
"type"
jdbcType=
"TINYINT"
property=
"type"
/>
<result
column=
"type"
jdbcType=
"TINYINT"
property=
"type"
/>
</resultMap>
</resultMap>
<select
id=
"
ge
tActivationList"
resultType=
"cn.com.glsx.openplatform.model.ActivationData"
>
<select
id=
"
selec
tActivationList"
resultType=
"cn.com.glsx.openplatform.model.ActivationData"
>
select id, month, customer_id customerId, customer, num, type
select id, month, customer_id customerId, customer, num, type
from t_activation_data
from t_activation_data
order by month;
order by month;
...
@@ -66,16 +66,4 @@
...
@@ -66,16 +66,4 @@
</if>
</if>
</where>
</where>
</select>
</select>
<update
id=
"updatePlatformDeviceActivation"
>
update t_platform_device
set activat_time = from_unixtime(
#{startTime,jdbcType=TIMESTAMP}
+ floor(rand() * (#{endTime,jdbcType=TIMESTAMP} - #{startTime,jdbcType=TIMESTAMP}))
)
where customer_id = #{device.customerId,jdbcType=INTEGER}
and device_type = #{device.deviceType,jdbcType=VARCHAR}
order by rand()
limit #{count}
</update>
</mapper>
</mapper>
rpc-openplatform-container/src/main/resources/META-INF/orm/CustomerActionStatisticsMapper.xml
View file @
2ddd2a2
...
@@ -12,11 +12,12 @@
...
@@ -12,11 +12,12 @@
<result
column=
"type"
jdbcType=
"VARCHAR"
property=
"type"
/>
<result
column=
"type"
jdbcType=
"VARCHAR"
property=
"type"
/>
<result
column=
"statistics_time"
jdbcType=
"VARCHAR"
property=
"statisticsTime"
/>
<result
column=
"statistics_time"
jdbcType=
"VARCHAR"
property=
"statisticsTime"
/>
<result
column=
"number"
jdbcType=
"INTEGER"
property=
"number"
/>
<result
column=
"number"
jdbcType=
"INTEGER"
property=
"number"
/>
<result
column=
"online_number"
jdbcType=
"INTEGER"
property=
"onlineNumber"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
<!--@mbg.generated-->
id, customer_id, customer_name, device_type, `type`, statistics_time, number
id, customer_id, customer_name, device_type, `type`, statistics_time, number
, online_number
</sql>
</sql>
<select
id=
"selectMonthList"
resultType=
"java.lang.String"
>
<select
id=
"selectMonthList"
resultType=
"java.lang.String"
>
...
@@ -24,8 +25,40 @@
...
@@ -24,8 +25,40 @@
from t_customer_action_statistics
from t_customer_action_statistics
</select>
</select>
<select
id=
"selectPlatformDevice"
resultType=
"cn.com.glsx.openplatform.model.PlatformDevice"
>
select id, device_sn deviceSn, device_type deviceType, version, customer_id customerId,
user_id, activat_time activatTime, status, create_time createTime
from t_platform_device
<where>
<if
test=
"statistics.customerId != null"
>
and customer_id = #{statistics.customerId,jdbcType=INTEGER}
</if>
<if
test=
"endDate != null"
>
and activat_time
<
#{endDate,jdbcType=TIMESTAMP}
</if>
</where>
order by rand()
</select>
<select
id=
"selectDeviceFromDeviceNetworkDetail"
resultType=
"cn.com.glsx.openplatform.model.DeviceNetworkDetail"
>
select dnd.device_sn deviceSn, dnd.create_time creatreTime
from t_device_network_detail dnd
left join t_platform_device pd on pd.device_sn = dnd.device_sn
<where>
<if
test=
"customerId != null"
>
pd.customer_id = #{customerId,jdbcType=INTEGER}
</if>
<if
test=
"endDate != null"
>
and dnd.create_time
<
#{endDate,jdbcType=TIMESTAMP}
</if>
</where>
order by rand()
</select>
<select
id=
"selectByMonth"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByMonth"
resultMap=
"BaseResultMap"
>
select id, customer_id, customer_name, device_type, type, statistics_time, number
select id, customer_id, customer_name, device_type, type, statistics_time, number,
online_number
from t_customer_action_statistics
from t_customer_action_statistics
<where>
<where>
<if
test=
"month != null and month != ''"
>
<if
test=
"month != null and month != ''"
>
...
@@ -48,16 +81,6 @@
...
@@ -48,16 +81,6 @@
group by customer_id, statistics_time
group by customer_id, statistics_time
</select>
</select>
<select
id=
"selectByType"
resultMap=
"BaseResultMap"
>
select id, customer_id, customer_name, device_type, type, statistics_time, number
from t_customer_action_statistics
<where>
<if
test=
"type != null and type != ''"
>
and type = #{type,jdbcType=VARCHAR}
</if>
</where>
</select>
<select
id=
"selectDeviceList"
<select
id=
"selectDeviceList"
resultType=
"cn.com.glsx.openplatform.model.PlatformDevice"
>
resultType=
"cn.com.glsx.openplatform.model.PlatformDevice"
>
select id, device_sn deviceSn, device_type deviceType
select id, device_sn deviceSn, device_type deviceType
...
...
rpc-openplatform-container/src/main/resources/META-INF/orm/CustomerNetworkStatisticsMapper.xml
View file @
2ddd2a2
...
@@ -12,45 +12,90 @@
...
@@ -12,45 +12,90 @@
<result
column=
"type"
jdbcType=
"VARCHAR"
property=
"type"
/>
<result
column=
"type"
jdbcType=
"VARCHAR"
property=
"type"
/>
<result
column=
"statistics_time"
jdbcType=
"VARCHAR"
property=
"statisticsTime"
/>
<result
column=
"statistics_time"
jdbcType=
"VARCHAR"
property=
"statisticsTime"
/>
<result
column=
"online_number"
jdbcType=
"INTEGER"
property=
"onlineNumber"
/>
<result
column=
"online_number"
jdbcType=
"INTEGER"
property=
"onlineNumber"
/>
<result
column=
"online_count"
jdbcType=
"INTEGER"
property=
"onlineCount"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
<!--@mbg.generated-->
id, customer_id, customer_name, device_type, `type`, statistics_time, online_number
id, customer_id, customer_name, device_type, `type`, statistics_time, online_number
, online_count
</sql>
</sql>
<select
id=
"selectByDate"
resultMap=
"BaseResultMap"
>
<select
id=
"selectMonthList"
resultType=
"java.lang.String"
>
select id, customer_id, customer_name, device_type, statistics_time, online_number
select distinct statistics_time
from t_customer_device_statistics_new_doing_copy2 cns
from t_customer_network_statistics
</select>
<select
id=
"selectByMonth"
resultMap=
"BaseResultMap"
>
select id, customer_id, customer_name, device_type, statistics_time, online_number,
online_count
from t_customer_network_statistics cns
<where>
<where>
<if
test=
"startDate != null"
>
<if
test=
"month != null and month != ''"
>
and statistics_time >= #{startDate,jdbcType=VARCHAR}
and statistics_time = #{month,jdbcType=VARCHAR}
</if>
</where>
</select>
<select
id=
"selectPlatformDevice"
resultType=
"cn.com.glsx.openplatform.model.PlatformDevice"
>
select id, device_sn deviceSn, device_type deviceType, version version,
customer_id customerId, user_id userId, activat_time activatTime,
create_time createTime
from t_platform_device
<where>
<if
test=
"statistics.customerId != null"
>
and customer_id = #{statistics.customerId,jdbcType=INTEGER}
</if>
</if>
<if
test=
"endDate != null"
>
<if
test=
"endDate != null"
>
and
statistics_time
<
#{endDate,jdbcType=VARCHAR
}
and
activat_time
<
#{endDate,jdbcType=TIMESTAMP
}
</if>
</if>
and online_number > 0
</where>
</where>
order by rand()
limit #{statistics.onlineNumber,jdbcType=INTEGER}
</select>
</select>
<select
id=
"selectFromDeviceNetworkByDate"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByDate"
resultMap=
"BaseResultMap"
>
select pd.customer_id customerId, pc.customer_name customerName,
select id, customer_id, customer_name, device_type, statistics_time, online_number,
date_format(dnd.create_time, '%Y-%m') statisticsTime,
online_count
count(pd.device_sn) onlineNumber
from t_customer_network_statistics cns
from t_device_network_detail dnd
left join t_platform_device pd on pd.device_sn = dnd.device_sn
left join t_platform_customer pc on pc.id = pd.customer_id
<where>
<where>
<if
test=
"startDate != null"
>
<if
test=
"startDate != null"
>
and
dnd.create_time >= #{startDate,jdbcType=TIMESTAMP
}
and
statistics_time >= #{startDate,jdbcType=VARCHAR
}
</if>
</if>
<if
test=
"endDate != null"
>
<if
test=
"endDate != null"
>
and
dnd.create_time
<
#{endDate,jdbcType=TIMESTAMP
}
and
statistics_time
<
#{endDate,jdbcType=VARCHAR
}
</if>
</if>
</where>
</where>
group by pd.customer_id, statisticsTime
</select>
</select>
<!--<select id="selectFromDeviceNetworkByDate" resultMap="BaseResultMap">-->
<!-- select pd.customer_id customerId, pc.customer_name customerName,-->
<!-- date_format(dnd.create_time, '%Y-%m') statisticsTime,-->
<!-- count(pd.device_sn) onlineNumber-->
<!-- from t_device_network_detail dnd-->
<!-- left join t_platform_device pd on pd.device_sn = dnd.device_sn-->
<!-- left join t_platform_customer pc on pc.id = pd.customer_id-->
<!-- <where>-->
<!-- <if test="startDate != null">-->
<!-- and dnd.create_time >= #{startDate,jdbcType=TIMESTAMP}-->
<!-- </if>-->
<!-- <if test="endDate != null">-->
<!-- and dnd.create_time < #{endDate,jdbcType=TIMESTAMP}-->
<!-- </if>-->
<!-- </where>-->
<!-- group by pd.customer_id, statisticsTime-->
<!--</select>-->
<select
id=
"selectFromCustomerDeviceStatistics"
resultType=
"cn.com.glsx.openplatform.model.CustomerNetworkStatistics"
>
select customer_id customerId, customer_name customerName, device_type deviceType,
statistics_time statisticsTime, sum(online_number) onlineNumber,
sum(online_device_num) onlineDeviceNum
from t_customer_device_statistics
group by customer_id, statistics_time
</select>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
<!--@mbg.generated-->
<!--@mbg.generated-->
select
select
...
...
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateCustomerNetworkStatistic.java
View file @
2ddd2a2
package
cn
.
com
.
glsx
.
openplatform
;
//
package cn.com.glsx.openplatform;
//
import
java.util.Calendar
;
//
import java.util.Calendar;
import
java.util.Date
;
//
import java.util.Date;
import
java.util.List
;
//
import java.util.List;
import
cn.com.glsx.openplatform.mapper.CustomerNetworkStatisticsMapper
;
//
import cn.com.glsx.openplatform.mapper.CustomerNetworkStatisticsMapper;
import
cn.com.glsx.openplatform.model.CustomerNetworkStatistics
;
//
import cn.com.glsx.openplatform.model.CustomerNetworkStatistics;
import
cn.hutool.core.date.DateUtil
;
//
import cn.hutool.core.date.DateUtil;
import
org.junit.Test
;
//
import org.junit.Test;
import
org.junit.runner.RunWith
;
//
import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.context.SpringBootTest
;
//
import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
//
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
//
/**
/
//
**
* <p>Description:
//
* <p>Description:
* <p>Project: rpc-openplatform-container
//
* <p>Project: rpc-openplatform-container
*
//
*
* @author wbh
//
* @author wbh
* @date 2021-01-02
//
* @date 2021-01-02
*/
//
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
//
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
(
classes
=
Main
.
class
)
//
@SpringBootTest(classes = Main.class)
public
class
GenerateCustomerNetworkStatistic
{
//
public class GenerateCustomerNetworkStatistic {
@Autowired
//
@Autowired
private
CustomerNetworkStatisticsMapper
customerNetworkStatisticsMapper
;
//
private CustomerNetworkStatisticsMapper customerNetworkStatisticsMapper;
//
@Test
//
@Test
public
void
generateData
()
{
//
public void generateData() {
Date
startDate
=
DateUtil
.
parse
(
"2019-01-01"
,
"yyyy-MM-dd"
);
//
Date startDate = DateUtil.parse("2019-01-01", "yyyy-MM-dd");
Date
endDate
=
DateUtil
.
parse
(
"2021-01-01"
,
"yyyy-MM-dd"
);
//
Date endDate = DateUtil.parse("2021-01-01", "yyyy-MM-dd");
Calendar
calendar
=
Calendar
.
getInstance
();
//
Calendar calendar = Calendar.getInstance();
calendar
.
setTime
(
startDate
);
//
calendar.setTime(startDate);
calendar
.
add
(
Calendar
.
MONTH
,
1
);
//
calendar.add(Calendar.MONTH, 1);
Date
currentStartDate
=
startDate
;
//
Date currentStartDate = startDate;
Date
currentEndDate
=
calendar
.
getTime
();
//
Date currentEndDate = calendar.getTime();
while
(
currentStartDate
.
before
(
endDate
))
{
//
while (currentStartDate.before(endDate)) {
List
<
CustomerNetworkStatistics
>
statisticsList
=
this
.
customerNetworkStatisticsMapper
//
List<CustomerNetworkStatistics> statisticsList = this.customerNetworkStatisticsMapper
.
selectFromDeviceNetworkByDate
(
currentStartDate
,
currentEndDate
);
//
.selectFromDeviceNetworkByDate(currentStartDate, currentEndDate);
if
(!
statisticsList
.
isEmpty
())
{
//
if (!statisticsList.isEmpty()) {
this
.
customerNetworkStatisticsMapper
.
batchInsert
(
statisticsList
);
//
this.customerNetworkStatisticsMapper.batchInsert(statisticsList);
}
//
}
currentStartDate
=
currentEndDate
;
//
currentStartDate = currentEndDate;
calendar
.
add
(
Calendar
.
MONTH
,
1
);
//
calendar.add(Calendar.MONTH, 1);
currentEndDate
=
calendar
.
getTime
();
//
currentEndDate = calendar.getTime();
}
//
}
}
//
}
}
//
}
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateDeviceActionDetailByCustomer.java
View file @
2ddd2a2
This diff is collapsed.
Click to expand it.
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateDeviceActionDetailByCustomer2.java
0 → 100644
View file @
2ddd2a2
This diff is collapsed.
Click to expand it.
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GenerateDeviceNetworkDetailByCustomer.java
0 → 100644
View file @
2ddd2a2
package
cn
.
com
.
glsx
.
openplatform
;
import
java.io.BufferedWriter
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
cn.com.glsx.openplatform.mapper.CustomerNetworkStatisticsMapper
;
import
cn.com.glsx.openplatform.model.CustomerNetworkStatistics
;
import
cn.com.glsx.openplatform.model.DeviceNetworkDetail
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
/**
* <p>Description:
* <p>Project: rpc-openplatform-container
*
* @author wbh
* @date 2021-01-06
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Main
.
class
)
public
class
GenerateDeviceNetworkDetailByCustomer
{
@Autowired
private
CustomerNetworkStatisticsMapper
customerNetworkStatisticsMapper
;
private
BufferedWriter
deviceNetworkDetailWriter
;
/**
* 根据客户联网统计表 t_customer_network_statistics 生成设备联网明细表 t_device_network_detail 数据
*/
@Test
public
void
generateDeviceNetworkDetail
()
{
// 取出所有月份,按月存储数据
List
<
String
>
monthList
=
this
.
customerNetworkStatisticsMapper
.
selectMonthList
();
for
(
String
month
:
monthList
)
{
this
.
initDeviceNetworkDetailWriter
(
month
);
List
<
CustomerNetworkStatistics
>
networkStatisticsList
=
this
.
customerNetworkStatisticsMapper
.
selectByMonth
(
month
);
Date
startDate
=
DateUtil
.
parse
(
month
,
"yyyy-MM"
);
Date
endDate
=
DateUtil
.
offsetMonth
(
startDate
,
1
);
for
(
CustomerNetworkStatistics
networkStatistics
:
networkStatisticsList
)
{
List
<
PlatformDevice
>
deviceList
=
this
.
customerNetworkStatisticsMapper
.
selectPlatformDevice
(
networkStatistics
,
endDate
);
Integer
onlineCount
=
networkStatistics
.
getOnlineCount
();
if
(!
deviceList
.
isEmpty
())
{
this
.
addDeviceNetworkDetail
(
deviceList
,
startDate
,
onlineCount
);
}
}
this
.
closeDeviceNetworkDetailWriter
();
}
}
private
void
initDeviceNetworkDetailWriter
(
String
month
)
{
try
{
String
monthStr
=
month
.
replace
(
"-"
,
""
);
String
filename
=
String
.
format
(
"D:/data/device-network-detail-%s.sql"
,
monthStr
);
this
.
deviceNetworkDetailWriter
=
FileUtil
.
getWriter
(
filename
,
StandardCharsets
.
UTF_8
,
false
);
String
header
=
String
.
format
(
"insert into t_device_network_detail_%s (device_sn, create_time) values"
,
monthStr
);
this
.
deviceNetworkDetailWriter
.
write
(
header
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
private
void
closeDeviceNetworkDetailWriter
()
{
try
{
this
.
deviceNetworkDetailWriter
.
flush
();
this
.
deviceNetworkDetailWriter
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
private
void
addDeviceNetworkDetail
(
List
<
PlatformDevice
>
deviceList
,
Date
startDate
,
int
count
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
PlatformDevice
device
=
deviceList
.
get
(
i
%
deviceList
.
size
());
Date
activatTime
=
device
.
getActivatTime
();
Date
createTime
;
if
(
DateUtil
.
isSameMonth
(
startDate
,
activatTime
))
{
long
startMs
=
activatTime
.
getTime
();
long
endMs
=
DateUtil
.
dateNew
(
startDate
)
.
offset
(
DateField
.
MONTH
,
1
).
getTime
();
createTime
=
new
Date
(
RandomUtil
.
randomLong
(
startMs
,
endMs
));
}
else
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
startDate
);
int
day
=
RandomUtil
.
randomInt
(
DateUtil
.
dayOfMonth
(
startDate
),
calendar
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
int
hour
=
RandomUtil
.
randomInt
(
24
);
int
minute
=
RandomUtil
.
randomInt
(
60
);
int
second
=
RandomUtil
.
randomInt
(
60
);
createTime
=
DateUtil
.
dateNew
(
startDate
).
setField
(
DateField
.
DAY_OF_MONTH
,
day
)
.
setField
(
DateField
.
HOUR_OF_DAY
,
hour
)
.
setField
(
DateField
.
MINUTE
,
minute
)
.
setField
(
DateField
.
SECOND
,
second
);
}
DeviceNetworkDetail
networkDetail
=
new
DeviceNetworkDetail
();
networkDetail
.
setDeviceSn
(
device
.
getDeviceSn
());
networkDetail
.
setCreateTime
(
createTime
);
try
{
String
s
=
String
.
format
(
",\n('%s', '%s')"
,
networkDetail
.
getDeviceSn
(),
DateUtil
.
formatDateTime
(
networkDetail
.
getCreateTime
()));
this
.
deviceNetworkDetailWriter
.
write
(
s
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/GeneratePlatformDevice.java
View file @
2ddd2a2
...
@@ -37,7 +37,7 @@ public class GeneratePlatformDevice {
...
@@ -37,7 +37,7 @@ public class GeneratePlatformDevice {
private
ActivationDataMapper
activationDataMapper
;
private
ActivationDataMapper
activationDataMapper
;
@Autowired
@Autowired
private
PlatformDeviceMapper
d
eviceMapper
;
private
PlatformDeviceMapper
platformD
eviceMapper
;
private
BufferedWriter
platformDeviceWriter
;
private
BufferedWriter
platformDeviceWriter
;
...
@@ -45,6 +45,8 @@ public class GeneratePlatformDevice {
...
@@ -45,6 +45,8 @@ public class GeneratePlatformDevice {
private
static
final
Map
<
String
,
Integer
>
DEVICE_TYPE_MAP
=
new
HashMap
<>();
private
static
final
Map
<
String
,
Integer
>
DEVICE_TYPE_MAP
=
new
HashMap
<>();
private
int
currentId
=
874003
;
static
{
static
{
TYPE_MAP
.
put
((
byte
)
1
,
"通信模组"
);
TYPE_MAP
.
put
((
byte
)
1
,
"通信模组"
);
TYPE_MAP
.
put
((
byte
)
2
,
"核心板"
);
TYPE_MAP
.
put
((
byte
)
2
,
"核心板"
);
...
@@ -141,7 +143,9 @@ public class GeneratePlatformDevice {
...
@@ -141,7 +143,9 @@ public class GeneratePlatformDevice {
serialNumMap
.
put
(
serialDateStr
,
0
);
serialNumMap
.
put
(
serialDateStr
,
0
);
}
}
// 获取当天已经出货的量,作为起始序列号
// 获取当天已经出货的量,作为起始序列号
int
startSerialNum
=
serialNumMap
.
get
(
serialDateStr
)
+
1
;
//int startSerialNum = serialNumMap.get(serialDateStr) + 1;
int
startSerialNum
=
this
.
activationDataMapper
.
countByDate
(
serialDate
,
DateUtil
.
offsetDay
(
serialDate
,
1
))
+
1
;
int
endSerialNum
;
int
endSerialNum
;
int
randCount
=
goodsNum
>
5000
?
RandomUtil
.
randomInt
(
4000
,
5000
)
:
goodsNum
;
int
randCount
=
goodsNum
>
5000
?
RandomUtil
.
randomInt
(
4000
,
5000
)
:
goodsNum
;
// 计算终止序列号
// 计算终止序列号
...
@@ -171,7 +175,7 @@ public class GeneratePlatformDevice {
...
@@ -171,7 +175,7 @@ public class GeneratePlatformDevice {
private
void
initPlatformDeviceWriter
()
throws
IOException
{
private
void
initPlatformDeviceWriter
()
throws
IOException
{
this
.
platformDeviceWriter
=
Files
.
newBufferedWriter
(
this
.
platformDeviceWriter
=
Files
.
newBufferedWriter
(
Paths
.
get
(
"D:/data/platform-device.sql"
));
Paths
.
get
(
"D:/data/platform-device.sql"
));
this
.
platformDeviceWriter
.
write
(
"insert into t_platform_device (device_sn, device_type, version, customer_id, status, create_time, update_time, create_by, update_by) values"
);
this
.
platformDeviceWriter
.
write
(
"insert into t_platform_device (
id,
device_sn, device_type, version, customer_id, status, create_time, update_time, create_by, update_by) values"
);
}
}
private
void
closePlatformDeviceWriter
()
throws
IOException
{
private
void
closePlatformDeviceWriter
()
throws
IOException
{
...
@@ -190,6 +194,7 @@ public class GeneratePlatformDevice {
...
@@ -190,6 +194,7 @@ public class GeneratePlatformDevice {
DateUtil
.
dayOfMonth
(
serialDate
),
DateUtil
.
dayOfMonth
(
serialDate
),
serialNum
);
serialNum
);
PlatformDevice
device
=
new
PlatformDevice
();
PlatformDevice
device
=
new
PlatformDevice
();
device
.
setId
(
this
.
currentId
);
device
.
setDeviceSn
(
deviceSn
);
device
.
setDeviceSn
(
deviceSn
);
device
.
setDeviceType
(
shipmentData
.
getDeviceType
());
device
.
setDeviceType
(
shipmentData
.
getDeviceType
());
device
.
setVersion
(
shipmentData
.
getVersion
());
device
.
setVersion
(
shipmentData
.
getVersion
());
...
@@ -201,13 +206,16 @@ public class GeneratePlatformDevice {
...
@@ -201,13 +206,16 @@ public class GeneratePlatformDevice {
device
.
setCreateBy
(
0
);
device
.
setCreateBy
(
0
);
device
.
setUpdateBy
(
0
);
device
.
setUpdateBy
(
0
);
try
{
try
{
String
s
=
String
.
format
(
",\n('%s', '%s', '%s', %d, %d, '%s', '%s', %d, %d)"
,
String
s
=
String
.
format
(
",\n(%d, '%s', '%s', '%s', %d, %d, '%s', '%s', %d, %d)"
,
this
.
currentId
,
device
.
getDeviceSn
(),
device
.
getDeviceType
(),
device
.
getVersion
(),
device
.
getDeviceSn
(),
device
.
getDeviceType
(),
device
.
getVersion
(),
device
.
getCustomerId
(),
device
.
getStatus
(),
device
.
getCustomerId
(),
device
.
getStatus
(),
DateUtil
.
formatDateTime
(
device
.
getCreateTime
()),
DateUtil
.
formatDateTime
(
device
.
getCreateTime
()),
DateUtil
.
formatDateTime
(
device
.
getUpdateTime
()),
DateUtil
.
formatDateTime
(
device
.
getUpdateTime
()),
device
.
getCreateBy
(),
device
.
getUpdateBy
());
device
.
getCreateBy
(),
device
.
getUpdateBy
());
this
.
platformDeviceMapper
.
insertSelective
(
device
);
this
.
platformDeviceWriter
.
write
(
s
);
this
.
platformDeviceWriter
.
write
(
s
);
this
.
currentId
++;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -217,7 +225,7 @@ public class GeneratePlatformDevice {
...
@@ -217,7 +225,7 @@ public class GeneratePlatformDevice {
@Test
@Test
public
void
generateDeviceActivationData
()
throws
Exception
{
public
void
generateDeviceActivationData
()
throws
Exception
{
//查询数据库
//查询数据库
List
<
ActivationData
>
activationList
=
activationDataMapper
.
ge
tActivationList
();
List
<
ActivationData
>
activationList
=
activationDataMapper
.
selec
tActivationList
();
for
(
ActivationData
activationData
:
activationList
)
{
for
(
ActivationData
activationData
:
activationList
)
{
activationData
.
setTypeName
(
TYPE_MAP
.
get
(
activationData
.
getType
()));
activationData
.
setTypeName
(
TYPE_MAP
.
get
(
activationData
.
getType
()));
String
month
=
activationData
.
getMonth
();
String
month
=
activationData
.
getMonth
();
...
...
rpc-openplatform-container/src/test/java/cn/com/glsx/openplatform/generate-device-network-detail-scheduler.sql
0 → 100644
View file @
2ddd2a2
File mode changed
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment