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 26bd3c72
authored
Jan 05, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]设备导入
1 parent
0cb2c14c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
214 additions
and
0 deletions
rpc-openplatform-api/pom.xml
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/PlatformDevice.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/service/DeviceMgrService.java
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/vo/DeviceImportVo.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformCustomerMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformDeviceMapper.java
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/service/DeviceMgrServiceImpl.java
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformCustomerMapper.xml
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformDeviceMapper.xml
rpc-openplatform-api/pom.xml
View file @
26bd3c7
...
@@ -77,6 +77,26 @@
...
@@ -77,6 +77,26 @@
<groupId>
org.springframework
</groupId>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
<artifactId>
spring-web
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.glsx.poi
</groupId>
<artifactId>
glsx-poi-jar
</artifactId>
<version>
2.0.0-SNAPSHOT
</version>
<exclusions>
<!-- 拉取版本不对???-->
<exclusion>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml-schemas
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/model/PlatformDevice.java
View file @
26bd3c7
...
@@ -39,6 +39,12 @@ public class PlatformDevice implements Serializable {
...
@@ -39,6 +39,12 @@ public class PlatformDevice implements Serializable {
private
String
deviceType
;
private
String
deviceType
;
/**
/**
* 版本号
*/
@Column
(
name
=
"version"
)
private
String
version
;
/**
* 客户id t_platform_customer表的id
* 客户id t_platform_customer表的id
*/
*/
@Column
(
name
=
"customer_id"
)
@Column
(
name
=
"customer_id"
)
...
@@ -192,6 +198,14 @@ public class PlatformDevice implements Serializable {
...
@@ -192,6 +198,14 @@ public class PlatformDevice implements Serializable {
this
.
customerName
=
customerName
;
this
.
customerName
=
customerName
;
}
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"PlatformDevice{"
+
return
"PlatformDevice{"
+
...
...
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/service/DeviceMgrService.java
View file @
26bd3c7
package
cn
.
com
.
glsx
.
openplatform
.
service
;
package
cn
.
com
.
glsx
.
openplatform
.
service
;
import
cn.com.glsx.openplatform.vo.DeviceImportVo
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
cn.com.glsx.openplatform.vo.R
;
import
cn.com.glsx.openplatform.vo.R
;
import
cn.hutool.db.Page
;
import
cn.hutool.db.Page
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -53,4 +55,12 @@ public interface DeviceMgrService {
...
@@ -53,4 +55,12 @@ public interface DeviceMgrService {
* @return
* @return
*/
*/
List
<
Map
<
String
,
Integer
>>
getDeviceAccessTrendList
();
List
<
Map
<
String
,
Integer
>>
getDeviceAccessTrendList
();
/**
* 导入设备
*
* @param list 入参
* @return
*/
Map
<
String
,
Object
>
importDevice
(
Collection
<
DeviceImportVo
>
list
);
}
}
rpc-openplatform-api/src/main/java/cn/com/glsx/openplatform/vo/DeviceImportVo.java
0 → 100644
View file @
26bd3c7
package
cn
.
com
.
glsx
.
openplatform
.
vo
;
import
com.glsx.poi.util.ExcelAnnotation
;
import
java.io.Serializable
;
/**
* @author zhouhaibao
* @date 2021/1/5 9:57
*/
public
class
DeviceImportVo
implements
Serializable
{
@ExcelAnnotation
(
"SN"
)
private
String
deviceSn
;
@ExcelAnnotation
(
"类型"
)
private
String
deviceType
;
@ExcelAnnotation
(
"客户"
)
private
String
customerName
;
@ExcelAnnotation
(
"版本号"
)
private
String
version
;
private
Integer
customerId
;
public
String
getDeviceSn
()
{
return
deviceSn
;
}
public
void
setDeviceSn
(
String
deviceSn
)
{
this
.
deviceSn
=
deviceSn
;
}
public
String
getDeviceType
()
{
return
deviceType
;
}
public
void
setDeviceType
(
String
deviceType
)
{
this
.
deviceType
=
deviceType
;
}
public
String
getCustomerName
()
{
return
customerName
;
}
public
void
setCustomerName
(
String
customerName
)
{
this
.
customerName
=
customerName
;
}
public
Integer
getCustomerId
()
{
return
customerId
;
}
public
void
setCustomerId
(
Integer
customerId
)
{
this
.
customerId
=
customerId
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
}
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformCustomerMapper.java
View file @
26bd3c7
...
@@ -39,4 +39,6 @@ public interface PlatformCustomerMapper extends OreMapper<PlatformCustomer> {
...
@@ -39,4 +39,6 @@ public interface PlatformCustomerMapper extends OreMapper<PlatformCustomer> {
int
updateByCustomerId
(
@Param
(
"id"
)
int
id
,
@Param
(
"password"
)
String
password
);
int
updateByCustomerId
(
@Param
(
"id"
)
int
id
,
@Param
(
"password"
)
String
password
);
Integer
updateStatusByCustomerId
(
@Param
(
"id"
)
Integer
id
,
@Param
(
"status"
)
Integer
status
);
Integer
updateStatusByCustomerId
(
@Param
(
"id"
)
Integer
id
,
@Param
(
"status"
)
Integer
status
);
List
<
PlatformCustomer
>
getByCustomerName
(
String
customerName
);
}
}
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/mapper/PlatformDeviceMapper.java
View file @
26bd3c7
...
@@ -42,4 +42,8 @@ public interface PlatformDeviceMapper extends OreMapper<PlatformDevice> {
...
@@ -42,4 +42,8 @@ public interface PlatformDeviceMapper extends OreMapper<PlatformDevice> {
int
getDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
int
getDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
int
getacticveDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
int
getacticveDeviceCountByCustomerId
(
@Param
(
"customerId"
)
int
customerId
,
@Param
(
"deviceTypeStr"
)
String
deviceTypeStr
);
void
insertBatchDevice
(
List
<
PlatformDevice
>
platformDevices
);
PlatformDevice
findBySn
(
@Param
(
"deviceSn"
)
String
deviceSn
);
}
}
\ No newline at end of file
\ No newline at end of file
rpc-openplatform-container/src/main/java/cn/com/glsx/openplatform/service/DeviceMgrServiceImpl.java
View file @
26bd3c7
...
@@ -2,20 +2,29 @@ package cn.com.glsx.openplatform.service;
...
@@ -2,20 +2,29 @@ package cn.com.glsx.openplatform.service;
import
cn.com.glsx.openplatform.mapper.PlatformCustomerMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformCustomerMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformDeviceMapper
;
import
cn.com.glsx.openplatform.mapper.PlatformDeviceMapper
;
import
cn.com.glsx.openplatform.model.PlatformCustomer
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.model.PlatformDevice
;
import
cn.com.glsx.openplatform.vo.DeviceImportVo
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
cn.com.glsx.openplatform.vo.DeviceVo
;
import
cn.com.glsx.openplatform.vo.R
;
import
cn.com.glsx.openplatform.vo.R
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.db.Page
;
import
cn.hutool.db.Page
;
import
com.alibaba.dubbo.config.annotation.Service
;
import
com.alibaba.dubbo.config.annotation.Service
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.mysql.jdbc.StringUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
@Service
public
class
DeviceMgrServiceImpl
implements
DeviceMgrService
{
public
class
DeviceMgrServiceImpl
implements
DeviceMgrService
{
...
@@ -63,6 +72,80 @@ public class DeviceMgrServiceImpl implements DeviceMgrService {
...
@@ -63,6 +72,80 @@ public class DeviceMgrServiceImpl implements DeviceMgrService {
return
deviceMapper
.
getDeviceAccessTrendList
(
getStatisticStartTime
(),
getStatisticEndTime
());
return
deviceMapper
.
getDeviceAccessTrendList
(
getStatisticStartTime
(),
getStatisticEndTime
());
}
}
@Override
public
Map
<
String
,
Object
>
importDevice
(
Collection
<
DeviceImportVo
>
list
)
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
checkDevice
(
list
,
objectMap
);
List
<
DeviceImportVo
>
deviceImportVos
=
(
List
<
DeviceImportVo
>)
objectMap
.
get
(
"data"
);
if
(
CollectionUtils
.
isNotEmpty
(
deviceImportVos
))
{
List
<
PlatformDevice
>
platformDevices
=
deviceImportVos
.
stream
().
map
(
index
->
{
PlatformDevice
stockInfo
=
new
PlatformDevice
();
BeanUtils
.
copyProperties
(
index
,
stockInfo
);
return
stockInfo
;
}
).
collect
(
Collectors
.
toList
());
deviceMapper
.
insertBatchDevice
(
platformDevices
);
objectMap
.
put
(
"successCount"
,
deviceImportVos
.
size
());
}
}
else
{
objectMap
.
put
(
"errorMessage"
,
"导入列表的数据为空"
);
}
return
objectMap
;
}
private
void
checkDevice
(
Collection
<
DeviceImportVo
>
list
,
Map
<
String
,
Object
>
objectMap
)
{
List
<
DeviceImportVo
>
deviceImportVoArrayList
=
new
ArrayList
<>();
List
<
String
>
errorMessagelist
=
new
ArrayList
<>();
int
rownum
=
1
;
List
<
String
>
deviceTypeList
=
deviceMapper
.
getDeviceTypeList
();
for
(
DeviceImportVo
deviceImportVo
:
list
)
{
String
deviceSn
=
deviceImportVo
.
getDeviceSn
();
String
deviceType
=
deviceImportVo
.
getDeviceType
();
String
customerName
=
deviceImportVo
.
getCustomerName
();
String
version
=
deviceImportVo
.
getVersion
();
rownum
++;
if
(
StringUtils
.
isNullOrEmpty
(
deviceSn
))
{
errorMessagelist
.
add
(
"第"
+
rownum
+
"行设备号为空"
);
continue
;
}
else
{
PlatformDevice
platformDevice
=
deviceMapper
.
findBySn
(
deviceSn
);
if
(
platformDevice
!=
null
){
errorMessagelist
.
add
(
"设备号"
+
deviceSn
+
"已经在库里面存在"
);
continue
;
}
}
if
(
StringUtils
.
isNullOrEmpty
(
deviceType
))
{
errorMessagelist
.
add
(
"设备号"
+
deviceSn
+
"的设备类型为空"
);
continue
;
}
else
{
if
(!
deviceTypeList
.
contains
(
deviceType
)){
errorMessagelist
.
add
(
"设备号"
+
deviceSn
+
"的设备类型不存在"
);
continue
;
}
}
if
(
StringUtils
.
isNullOrEmpty
(
version
))
{
errorMessagelist
.
add
(
"设备号"
+
deviceSn
+
"的版本号为空"
);
continue
;
}
if
(
StringUtils
.
isNullOrEmpty
(
customerName
))
{
errorMessagelist
.
add
(
"设备号"
+
deviceSn
+
"的设备类型为空"
);
continue
;
}
else
{
List
<
PlatformCustomer
>
byCustomerName
=
customerMapper
.
getByCustomerName
(
customerName
);
if
(
CollectionUtils
.
isNotEmpty
(
byCustomerName
)){
deviceImportVo
.
setCustomerId
(
byCustomerName
.
get
(
0
).
getId
());
}
else
{
errorMessagelist
.
add
(
"设备号"
+
deviceSn
+
"的客户在系统未查到"
);
continue
;
}
}
deviceImportVoArrayList
.
add
(
deviceImportVo
);
}
objectMap
.
put
(
"data"
,
deviceImportVoArrayList
);
objectMap
.
put
(
"errorMessage"
,
errorMessagelist
);
}
private
Date
getStatisticStartTime
()
{
private
Date
getStatisticStartTime
()
{
return
DateUtil
.
offsetDay
(
DateUtil
.
beginOfDay
(
new
Date
()),
-
31
);
return
DateUtil
.
offsetDay
(
DateUtil
.
beginOfDay
(
new
Date
()),
-
31
);
...
...
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformCustomerMapper.xml
View file @
26bd3c7
...
@@ -254,4 +254,10 @@
...
@@ -254,4 +254,10 @@
from t_platform_customer
from t_platform_customer
where id = #{appId,jdbcType=INTEGER}
where id = #{appId,jdbcType=INTEGER}
</select>
</select>
<select
id=
"getByCustomerName"
resultMap=
"BaseResultMap"
>
select *
from t_platform_customer
where customer_name=#{customerName}
</select>
</mapper>
</mapper>
rpc-openplatform-container/src/main/resources/META-INF/orm/PlatformDeviceMapper.xml
View file @
26bd3c7
...
@@ -24,6 +24,13 @@
...
@@ -24,6 +24,13 @@
id, device_sn, device_type, customer_id, activat_time, `status`, create_time, update_time,
id, device_sn, device_type, customer_id, activat_time, `status`, create_time, update_time,
create_by, update_by, remark
create_by, update_by, remark
</sql>
</sql>
<insert
id=
"insertBatchDevice"
parameterType=
"java.util.List"
>
insert into t_platform_device (device_sn,device_type,customer_id,activat_time,status,create_time,update_time,create_by,update_by,version)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.deviceSn},#{item.deviceType},#{item.customerId},now(),1,now(),now(),0,0,#{item.version})
</foreach>
</insert>
<select
id=
"getDeviceMgrList"
parameterType=
"cn.com.glsx.openplatform.vo.DeviceVo"
<select
id=
"getDeviceMgrList"
parameterType=
"cn.com.glsx.openplatform.vo.DeviceVo"
resultMap=
"BaseResultMap"
>
resultMap=
"BaseResultMap"
>
...
@@ -156,4 +163,9 @@
...
@@ -156,4 +163,9 @@
and tpd.status != 9
and tpd.status != 9
order by tpd.activat_time desc
order by tpd.activat_time desc
</select>
</select>
<select
id=
"findBySn"
resultType=
"cn.com.glsx.openplatform.model.PlatformDevice"
>
select *
from t_platform_device
where device_sn=#{deviceSn}
</select>
</mapper>
</mapper>
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