Commit 2ddd2a21 by tyfanchz

增加数据生成类

1 parent 3fe033e8
......@@ -13,11 +13,6 @@ package cn.com.glsx.openplatform.model;
*/
public class CustomerActionStatistics {
/**
* 在线设备数
*/
private Integer onlineNumber;
/**
* id
*/
private Integer id;
......@@ -52,13 +47,10 @@ public class CustomerActionStatistics {
*/
private Integer number;
public Integer getOnlineNumber() {
return onlineNumber;
}
public void setOnlineNumber(Integer onlineNumber) {
this.onlineNumber = onlineNumber;
}
/**
* 在线设备数
*/
private Integer onlineNumber;
public Integer getId() {
return id;
......@@ -116,17 +108,25 @@ public class CustomerActionStatistics {
this.number = number;
}
public Integer getOnlineNumber() {
return onlineNumber;
}
public void setOnlineNumber(Integer onlineNumber) {
this.onlineNumber = onlineNumber;
}
@Override
public String toString() {
return "CustomerActionStatistics{" +
"onlineNumber=" + onlineNumber +
", id=" + id +
"id=" + id +
", customerId=" + customerId +
", customerName='" + customerName + '\'' +
", deviceType='" + deviceType + '\'' +
", type='" + type + '\'' +
", statisticsTime='" + statisticsTime + '\'' +
", number=" + number +
", onlineNumber=" + onlineNumber +
'}';
}
}
......@@ -47,6 +47,11 @@ public class CustomerNetworkStatistics {
*/
private Integer onlineNumber;
/**
* 联网次数
*/
private Integer onlineCount;
public Integer getId() {
return id;
}
......@@ -103,6 +108,14 @@ public class CustomerNetworkStatistics {
this.onlineNumber = onlineNumber;
}
public Integer getOnlineCount() {
return onlineCount;
}
public void setOnlineCount(Integer onlineCount) {
this.onlineCount = onlineCount;
}
@Override
public String toString() {
return "CustomerNetworkStatistics{" +
......@@ -113,6 +126,7 @@ public class CustomerNetworkStatistics {
", type='" + type + '\'' +
", statisticsTime='" + statisticsTime + '\'' +
", onlineNumber=" + onlineNumber +
", onlineCount=" + onlineCount +
'}';
}
}
......@@ -3,7 +3,6 @@ package cn.com.glsx.openplatform.mapper;
import java.util.Date;
import java.util.List;
import cn.com.glsx.openplatform.model.ActivationData;
import cn.com.glsx.openplatform.model.PlatformDevice;
import cn.com.glsx.openplatform.model.ShipmentData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -17,7 +16,7 @@ import org.apache.ibatis.annotations.Param;
*/
@Mapper
public interface ActivationDataMapper {
List<ActivationData> getActivationList();
List<ActivationData> selectActivationList();
int countByDate(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
......@@ -28,8 +27,4 @@ public interface ActivationDataMapper {
List<String> selectDeviceTypeList();
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);
}
......@@ -3,6 +3,7 @@ package cn.com.glsx.openplatform.mapper;
import java.util.Date;
import java.util.List;
import cn.com.glsx.openplatform.model.CustomerActionStatistics;
import cn.com.glsx.openplatform.model.DeviceNetworkDetail;
import cn.com.glsx.openplatform.model.PlatformDevice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -19,12 +20,17 @@ import org.apache.ibatis.annotations.Param;
public interface CustomerActionStatisticsMapper {
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);
Integer selectOnlineNumber(CustomerActionStatistics actionStatistics);
List<CustomerActionStatistics> selectByType(@Param("type") String type);
List<PlatformDevice> selectDeviceList(
@Param("actionStatistics") CustomerActionStatistics actionStatistics,
@Param("endDate") Date endDate, @Param("count") Integer count);
......
......@@ -3,6 +3,7 @@ package cn.com.glsx.openplatform.mapper;
import java.util.Date;
import java.util.List;
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.Param;
......@@ -16,11 +17,22 @@ import org.apache.ibatis.annotations.Param;
@Mapper
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,
@Param("endDate") String endDate);
List<CustomerNetworkStatistics> selectFromDeviceNetworkByDate(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
//List<CustomerNetworkStatistics> selectFromDeviceNetworkByDate(
// @Param("startDate") Date startDate,
// @Param("endDate") Date endDate);
List<CustomerNetworkStatistics> selectFromCustomerDeviceStatistics();
int deleteByPrimaryKey(Integer id);
......
......@@ -13,7 +13,7 @@
<result column="type" jdbcType="TINYINT" property="type"/>
</resultMap>
<select id="getActivationList" resultType="cn.com.glsx.openplatform.model.ActivationData">
<select id="selectActivationList" resultType="cn.com.glsx.openplatform.model.ActivationData">
select id, month, customer_id customerId, customer, num, type
from t_activation_data
order by month;
......@@ -66,16 +66,4 @@
</if>
</where>
</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>
......@@ -12,11 +12,12 @@
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="statistics_time" jdbcType="VARCHAR" property="statisticsTime"/>
<result column="number" jdbcType="INTEGER" property="number"/>
<result column="online_number" jdbcType="INTEGER" property="onlineNumber"/>
</resultMap>
<sql id="Base_Column_List">
<!--@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>
<select id="selectMonthList" resultType="java.lang.String">
......@@ -24,8 +25,40 @@
from t_customer_action_statistics
</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 &lt; #{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 &lt; #{endDate,jdbcType=TIMESTAMP}
</if>
</where>
order by rand()
</select>
<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
<where>
<if test="month != null and month != ''">
......@@ -48,16 +81,6 @@
group by customer_id, statistics_time
</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"
resultType="cn.com.glsx.openplatform.model.PlatformDevice">
select id, device_sn deviceSn, device_type deviceType
......
......@@ -12,45 +12,90 @@
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="statistics_time" jdbcType="VARCHAR" property="statisticsTime"/>
<result column="online_number" jdbcType="INTEGER" property="onlineNumber"/>
<result column="online_count" jdbcType="INTEGER" property="onlineCount"/>
</resultMap>
<sql id="Base_Column_List">
<!--@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>
<select id="selectByDate" resultMap="BaseResultMap">
select id, customer_id, customer_name, device_type, statistics_time, online_number
from t_customer_device_statistics_new_doing_copy2 cns
<select id="selectMonthList" resultType="java.lang.String">
select distinct statistics_time
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>
<if test="startDate != null">
and statistics_time >= #{startDate,jdbcType=VARCHAR}
<if test="month != null and month != ''">
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 test="endDate != null">
and statistics_time &lt; #{endDate,jdbcType=VARCHAR}
and activat_time &lt; #{endDate,jdbcType=TIMESTAMP}
</if>
and online_number > 0
</where>
order by rand()
limit #{statistics.onlineNumber,jdbcType=INTEGER}
</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
<select id="selectByDate" resultMap="BaseResultMap">
select id, customer_id, customer_name, device_type, statistics_time, online_number,
online_count
from t_customer_network_statistics cns
<where>
<if test="startDate != null">
and dnd.create_time >= #{startDate,jdbcType=TIMESTAMP}
and statistics_time >= #{startDate,jdbcType=VARCHAR}
</if>
<if test="endDate != null">
and dnd.create_time &lt; #{endDate,jdbcType=TIMESTAMP}
and statistics_time &lt; #{endDate,jdbcType=VARCHAR}
</if>
</where>
group by pd.customer_id, statisticsTime
</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 &lt; #{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">
<!--@mbg.generated-->
select
......
package cn.com.glsx.openplatform;
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.hutool.core.date.DateUtil;
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-02
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class GenerateCustomerNetworkStatistic {
@Autowired
private CustomerNetworkStatisticsMapper customerNetworkStatisticsMapper;
@Test
public void generateData() {
Date startDate = DateUtil.parse("2019-01-01", "yyyy-MM-dd");
Date endDate = DateUtil.parse("2021-01-01", "yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(Calendar.MONTH, 1);
Date currentStartDate = startDate;
Date currentEndDate = calendar.getTime();
while (currentStartDate.before(endDate)) {
List<CustomerNetworkStatistics> statisticsList = this.customerNetworkStatisticsMapper
.selectFromDeviceNetworkByDate(currentStartDate, currentEndDate);
if (!statisticsList.isEmpty()) {
this.customerNetworkStatisticsMapper.batchInsert(statisticsList);
}
currentStartDate = currentEndDate;
calendar.add(Calendar.MONTH, 1);
currentEndDate = calendar.getTime();
}
}
}
//package cn.com.glsx.openplatform;
//
//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.hutool.core.date.DateUtil;
//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-02
// */
//@RunWith(SpringJUnit4ClassRunner.class)
//@SpringBootTest(classes = Main.class)
//public class GenerateCustomerNetworkStatistic {
// @Autowired
// private CustomerNetworkStatisticsMapper customerNetworkStatisticsMapper;
//
// @Test
// public void generateData() {
// Date startDate = DateUtil.parse("2019-01-01", "yyyy-MM-dd");
// Date endDate = DateUtil.parse("2021-01-01", "yyyy-MM-dd");
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(startDate);
// calendar.add(Calendar.MONTH, 1);
// Date currentStartDate = startDate;
// Date currentEndDate = calendar.getTime();
// while (currentStartDate.before(endDate)) {
// List<CustomerNetworkStatistics> statisticsList = this.customerNetworkStatisticsMapper
// .selectFromDeviceNetworkByDate(currentStartDate, currentEndDate);
// if (!statisticsList.isEmpty()) {
// this.customerNetworkStatisticsMapper.batchInsert(statisticsList);
// }
// currentStartDate = currentEndDate;
// calendar.add(Calendar.MONTH, 1);
// currentEndDate = calendar.getTime();
// }
// }
//}
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();
}
}
}
}
......@@ -37,7 +37,7 @@ public class GeneratePlatformDevice {
private ActivationDataMapper activationDataMapper;
@Autowired
private PlatformDeviceMapper deviceMapper;
private PlatformDeviceMapper platformDeviceMapper;
private BufferedWriter platformDeviceWriter;
......@@ -45,6 +45,8 @@ public class GeneratePlatformDevice {
private static final Map<String, Integer> DEVICE_TYPE_MAP = new HashMap<>();
private int currentId = 874003;
static {
TYPE_MAP.put((byte) 1, "通信模组");
TYPE_MAP.put((byte) 2, "核心板");
......@@ -141,7 +143,9 @@ public class GeneratePlatformDevice {
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 randCount = goodsNum > 5000 ? RandomUtil.randomInt(4000, 5000) : goodsNum;
// 计算终止序列号
......@@ -171,7 +175,7 @@ public class GeneratePlatformDevice {
private void initPlatformDeviceWriter() throws IOException {
this.platformDeviceWriter = Files.newBufferedWriter(
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 {
......@@ -190,6 +194,7 @@ public class GeneratePlatformDevice {
DateUtil.dayOfMonth(serialDate),
serialNum);
PlatformDevice device = new PlatformDevice();
device.setId(this.currentId);
device.setDeviceSn(deviceSn);
device.setDeviceType(shipmentData.getDeviceType());
device.setVersion(shipmentData.getVersion());
......@@ -201,13 +206,16 @@ public class GeneratePlatformDevice {
device.setCreateBy(0);
device.setUpdateBy(0);
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.getCustomerId(), device.getStatus(),
DateUtil.formatDateTime(device.getCreateTime()),
DateUtil.formatDateTime(device.getUpdateTime()),
device.getCreateBy(), device.getUpdateBy());
this.platformDeviceMapper.insertSelective(device);
this.platformDeviceWriter.write(s);
this.currentId++;
} catch (IOException e) {
e.printStackTrace();
}
......@@ -217,7 +225,7 @@ public class GeneratePlatformDevice {
@Test
public void generateDeviceActivationData() throws Exception {
//查询数据库
List<ActivationData> activationList = activationDataMapper.getActivationList();
List<ActivationData> activationList = activationDataMapper.selectActivationList();
for (ActivationData activationData : activationList) {
activationData.setTypeName(TYPE_MAP.get(activationData.getType()));
String month = activationData.getMonth();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!