Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
9c095163
Commit
9c095163
authored
May 06, 2025
by
李松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加建筑、设备导出接口
parent
b48930f0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
323 additions
and
0 deletions
+323
-0
pom.xml
amos-boot-utils/amos-boot-utils-adpter/pom.xml
+13
-0
AdpterController.java
.../com/yeejoin/amos/adpter/controller/AdpterController.java
+15
-0
AreaExcelModel.java
...in/java/com/yeejoin/amos/adpter/model/AreaExcelModel.java
+36
-0
DeviceExcelModel.java
.../java/com/yeejoin/amos/adpter/model/DeviceExcelModel.java
+87
-0
AdpterService.java
...n/java/com/yeejoin/amos/adpter/service/AdpterService.java
+80
-0
area.sql
...ls/amos-boot-utils-adpter/src/main/resources/sql/area.sql
+34
-0
device.sql
.../amos-boot-utils-adpter/src/main/resources/sql/device.sql
+58
-0
No files found.
amos-boot-utils/amos-boot-utils-adpter/pom.xml
View file @
9c095163
...
...
@@ -46,6 +46,19 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.2.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
5.2.3
</version>
<!-- 使用最新稳定版本 -->
</dependency>
<!-- 对于 Excel OOXML (xlsx) 格式支持 -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
5.2.3
</version>
</dependency>
</dependencies>
<build>
...
...
amos-boot-utils/amos-boot-utils-adpter/src/main/java/com/yeejoin/amos/adpter/controller/AdpterController.java
View file @
9c095163
...
...
@@ -8,9 +8,11 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Map
;
...
...
@@ -56,4 +58,16 @@ public class AdpterController {
adpterService
.
executeSqlFile
(
request
,
response
,
dbHost
,
port
,
dbName
,
userName
,
dbPwd
,
file
);
}
@ApiOperation
(
value
=
"区域信息"
)
@RequestMapping
(
value
=
"/areaExcel"
,
method
=
RequestMethod
.
POST
)
public
void
export
(
HttpServletResponse
response
,
@RequestParam
(
value
=
"type"
,
required
=
false
)
String
type
)
throws
IOException
{
adpterService
.
areaExcel
(
response
);
}
@ApiOperation
(
value
=
"设备信息信息"
)
@RequestMapping
(
value
=
"/deviceExcel"
,
method
=
RequestMethod
.
POST
)
public
void
deviceExcel
(
HttpServletResponse
response
,
String
gatewayId
)
throws
IOException
{
adpterService
.
deviceExcel
(
response
,
gatewayId
);
}
}
\ No newline at end of file
amos-boot-utils/amos-boot-utils-adpter/src/main/java/com/yeejoin/amos/adpter/model/AreaExcelModel.java
0 → 100644
View file @
9c095163
package
com
.
yeejoin
.
amos
.
adpter
.
model
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.SuperBuilder
;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public
class
AreaExcelModel
{
@ExcelProperty
(
value
=
"编码"
,
index
=
0
)
private
String
code
;
@ExcelProperty
(
value
=
"上级编码"
,
index
=
1
)
private
String
parentCode
;
@ExcelProperty
(
value
=
"类型"
,
index
=
2
)
private
String
type
;
@ExcelProperty
(
value
=
"区域名称"
,
index
=
3
)
private
String
name
;
@ExcelProperty
(
value
=
"火灾危险性类别"
,
index
=
4
)
private
String
category
;
@ExcelProperty
(
value
=
"最低耐火等级"
,
index
=
5
)
private
String
level
;
@ExcelProperty
(
value
=
"防火分区"
,
index
=
6
)
private
String
partition
;
}
amos-boot-utils/amos-boot-utils-adpter/src/main/java/com/yeejoin/amos/adpter/model/DeviceExcelModel.java
0 → 100644
View file @
9c095163
package
com
.
yeejoin
.
amos
.
adpter
.
model
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.SuperBuilder
;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public
class
DeviceExcelModel
{
@ExcelProperty
(
value
=
"网关设备"
,
index
=
0
)
private
String
gatewayDevice
;
@ExcelProperty
(
value
=
"测点类型"
,
index
=
1
)
private
String
pointType
;
@ExcelProperty
(
value
=
"数据类型"
,
index
=
2
)
private
String
pointDataType
;
@ExcelProperty
(
value
=
"告警配置"
,
index
=
3
)
private
String
alarmConfig
;
@ExcelProperty
(
value
=
"位置编码"
,
index
=
4
)
private
String
areaCode
;
@ExcelProperty
(
value
=
"地址"
,
index
=
5
)
private
String
address
;
@ExcelProperty
(
value
=
"测点名称"
,
index
=
6
)
private
String
pointName
;
@ExcelProperty
(
value
=
"物联指标"
,
index
=
7
)
private
String
iotProperName
;
@ExcelProperty
(
value
=
"编码"
,
index
=
8
)
private
String
deviceCode
;
@ExcelProperty
(
value
=
"设备类型"
,
index
=
9
)
private
String
deviceType
;
@ExcelProperty
(
value
=
"设备名称"
,
index
=
10
)
private
String
deviceName
;
@ExcelProperty
(
value
=
"规格型号"
,
index
=
11
)
private
String
specs
;
@ExcelProperty
(
value
=
"生产日期"
,
index
=
12
)
private
String
productionDate
;
@ExcelProperty
(
value
=
"投运日期"
,
index
=
13
)
private
String
useDate
;
@ExcelProperty
(
value
=
"生产厂家"
,
index
=
14
)
private
String
manufacturer
;
@ExcelProperty
(
value
=
"维保周期"
,
index
=
15
)
private
String
mainDate
;
@ExcelProperty
(
value
=
"报废年限"
,
index
=
16
)
private
String
scraplife
;
@ExcelProperty
(
value
=
"质保期限"
,
index
=
17
)
private
String
period
;
@ExcelProperty
(
value
=
"所属系统"
,
index
=
18
)
private
String
system
;
@ExcelProperty
(
value
=
"经度"
,
index
=
19
)
private
String
longitude
;
@ExcelProperty
(
value
=
"纬度"
,
index
=
20
)
private
String
latitude
;
@ExcelProperty
(
value
=
"所在位置"
,
index
=
21
)
private
String
location
;
@ExcelProperty
(
value
=
"数量"
,
index
=
22
)
private
String
deviceNum
;
@ExcelProperty
(
value
=
"设备状态"
,
index
=
23
)
private
String
deviceState
;
}
amos-boot-utils/amos-boot-utils-adpter/src/main/java/com/yeejoin/amos/adpter/service/AdpterService.java
View file @
9c095163
package
com
.
yeejoin
.
amos
.
adpter
.
service
;
import
com.alibaba.excel.EasyExcel
;
import
com.yeejoin.amos.adpter.model.AreaExcelModel
;
import
com.yeejoin.amos.adpter.model.DeviceExcelModel
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.jdbc.RuntimeSqlException
;
import
org.apache.ibatis.jdbc.ScriptRunner
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -52,6 +57,12 @@ public class AdpterService {
@Value
(
"${goal.jdbc.ip.buss}"
)
String
goalJdbcBuss
;
@Value
(
"${source.jdbc.ip.dataview}"
)
String
dataView
;
@Value
(
"${goal.jdbc.ip.dlbuss}"
)
String
dlBuss
;
String
driver
=
"com.mysql.cj.jdbc.Driver"
;
@Value
(
"${yeejoin.user}"
)
...
...
@@ -507,4 +518,73 @@ public class AdpterService {
return
flag
;
}
public
void
areaExcel
(
HttpServletResponse
response
)
throws
IOException
{
Resource
resource
=
new
ClassPathResource
(
"sql/area.sql"
);
String
sql
=
new
String
(
Files
.
readAllBytes
(
resource
.
getFile
().
toPath
()));
List
<
Map
<
String
,
Object
>>
list
=
query
(
dlBuss
,
sql
);
ArrayList
<
AreaExcelModel
>
areaExcelModels
=
new
ArrayList
<>();
list
.
forEach
(
a
->
{
AreaExcelModel
areaExcelModel
=
new
AreaExcelModel
();
areaExcelModel
.
setCategory
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"category"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"category"
)));
areaExcelModel
.
setCode
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"code"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"code"
)));
areaExcelModel
.
setParentCode
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"parentCode"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"parentCode"
)));
areaExcelModel
.
setType
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"type"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"type"
)));
areaExcelModel
.
setName
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"name"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"name"
)));
areaExcelModel
.
setLevel
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"level"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"level"
)));
areaExcelModel
.
setPartition
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"partition"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"partition"
)));
areaExcelModels
.
add
(
areaExcelModel
);
});
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"区域信息"
,
"UTF-8"
)
+
".xlsx"
);
response
.
setHeader
(
"content-Type"
,
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
try
(
ServletOutputStream
outputStream
=
response
.
getOutputStream
())
{
EasyExcel
.
write
(
outputStream
).
head
(
AreaExcelModel
.
class
).
sheet
(
"Sheet1"
).
doWrite
(
areaExcelModels
);
}
catch
(
IOException
e
)
{
log
.
error
(
"dynamicExportSPTemplateExcel error:"
,
e
);
}
}
public
void
deviceExcel
(
HttpServletResponse
response
,
String
gatewayId
)
throws
IOException
{
Resource
resource
=
new
ClassPathResource
(
"sql/device.sql"
);
String
replace
=
new
String
(
Files
.
readAllBytes
(
resource
.
getFile
().
toPath
()));
String
sql
=
replace
.
replace
(
"#{gatewayId}"
,
gatewayId
);
List
<
Map
<
String
,
Object
>>
list
=
query
(
dlBuss
,
sql
);
ArrayList
<
DeviceExcelModel
>
deviceList
=
new
ArrayList
<>();
list
.
forEach
(
a
->
{
DeviceExcelModel
model
=
new
DeviceExcelModel
();
model
.
setGatewayDevice
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"gatewayDevice"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"gatewayDevice"
)));
model
.
setPointType
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"pointType"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"pointType"
)));
model
.
setPointDataType
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"pointDataType"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"pointDataType"
)));
model
.
setAlarmConfig
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"alarmConfig"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"alarmConfig"
)));
model
.
setAreaCode
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"areaCode"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"areaCode"
)));
model
.
setAddress
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"address"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"address"
)));
model
.
setPointName
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"pointName"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"pointName"
)));
model
.
setIotProperName
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"iotProperName"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"iotProperName"
)));
model
.
setDeviceCode
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"deviceCode"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"deviceCode"
)));
model
.
setDeviceType
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"deviceType"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"deviceType"
)));
model
.
setDeviceName
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"deviceName"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"deviceName"
)));
model
.
setSpecs
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"specs"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"specs"
)));
model
.
setUseDate
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"useDate"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"useDate"
)));
model
.
setManufacturer
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"manufacturer"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"manufacturer"
)));
model
.
setMainDate
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"mainDate"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"mainDate"
)));
model
.
setScraplife
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"scraplife"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"scraplife"
)));
model
.
setPeriod
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"period"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"period"
)));
model
.
setSystem
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"system"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"system"
)));
model
.
setLongitude
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"longitude"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"longitude"
)));
model
.
setLatitude
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"latitude"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"latitude"
)));
model
.
setLocation
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"location"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"location"
)));
model
.
setDeviceNum
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"deviceNum"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"deviceNum"
)));
model
.
setDeviceState
(
ObjectUtils
.
isEmpty
(
a
.
get
(
"deviceState"
))
?
""
:
String
.
valueOf
(
a
.
get
(
"deviceState"
)));
deviceList
.
add
(
model
);
});
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"设备信息"
,
"UTF-8"
)
+
".xlsx"
);
response
.
setHeader
(
"content-Type"
,
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
try
(
ServletOutputStream
outputStream
=
response
.
getOutputStream
())
{
EasyExcel
.
write
(
outputStream
).
head
(
DeviceExcelModel
.
class
).
sheet
(
"Sheet1"
).
doWrite
(
deviceList
);
}
catch
(
IOException
e
)
{
log
.
error
(
"dynamicExportSPTemplateExcel error:"
,
e
);
}
}
}
amos-boot-utils/amos-boot-utils-adpter/src/main/resources/sql/area.sql
0 → 100644
View file @
9c095163
SELECT
a
.
*
,
MAX
(
CASE
WHEN
i
.
field_label
like
'%面积%'
THEN
i
.
field_value
END
)
area
,
MAX
(
CASE
WHEN
i
.
field_label
like
'%耐火%'
THEN
i
.
field_value
END
)
level
FROM
(
SELECT
t
.
id
,
t
.
`code`
code
,
t
.
`name`
name
,
t1
.
`code`
parentCode
,
CASE
WHEN
t
.
`name`
LIKE
'%区域%'
OR
t
.
`name`
LIKE
'%场%'
THEN
'区域'
WHEN
t
.
`name`
LIKE
'%层%'
or
t
.
`name`
like
'%屋顶%'
THEN
'楼层'
WHEN
t
.
`name`
LIKE
'%室%'
OR
t
.
`name`
LIKE
'%间%'
OR
t
.
`name`
LIKE
'%房%'
THEN
'房间'
ELSE
'建筑'
END
type
FROM
wl_warehouse_structure
t
LEFT
JOIN
wl_warehouse_structure
t1
ON
t
.
parent_id
=
t1
.
id
)
a
,
wl_form_instance
i
WHERE
i
.
instance_id
=
a
.
id
group
by
a
.
id
amos-boot-utils/amos-boot-utils-adpter/src/main/resources/sql/device.sql
0 → 100644
View file @
9c095163
SELECT
a
.
*
from
(
SELECT
'网关名称'
AS
gatewayDevice
,
case
when
temp
.
DATA_TYPE
=
'int'
then
'遥测'
else
'遥信'
end
as
pointType
,
temp
.
DATA_TYPE
as
pointDataType
,
'告警配置'
AS
alarmConfig
,
wws
.
`code`
AS
areaCode
,
wws
.
`name`
AS
areaName
,
wws
.
full_name
AS
areaFullName
,
temp
.
ADDRESS
AS
address
,
temp
.
`NAME`
AS
pointName
,
temp
.
FIELD_NAME
,
temp
.
equipment_index_name
AS
iotProperName
,
temp
.
equipment_index_key
,
wes
.
`code`
AS
deviceCode
,
wed
.
equipment_name
AS
deviceType
,
wes
.
`name`
AS
deviceName
,
wed
.
standard
AS
specs
,
wed
.
production_date
AS
productionDate
,
wed
.
delivery_date
AS
useDate
,
wmf
.
`name`
AS
manufacturer
,
we
.
maintenance_cycle
AS
mainDate
,
we
.
expiry_date
AS
scraplife
,
wes
.
warranty_period
AS
period
,
ffs
.
`name`
AS
`system`
FROM
(
SELECT
gdp
.
DATA_TYPE
,
gdp
.
PRODUCT_KEY
,
gdp
.
DEVICE_CODE
,
gdp
.
`NAME`
,
gdp
.
FIELD_NAME
,
gdp
.
ADDRESS
,
esi
.
iot_code
,
esi
.
equipment_index_key
,
esi
.
equipment_specific_id
,
esi
.
equipment_index_name
FROM
iot_gateway_device_property
gdp
LEFT
JOIN
(
SELECT
iot_code
,
equipment_index_key
,
equipment_index_name
,
equipment_specific_id
FROM
wl_equipment_specific_index
GROUP
BY
iot_code
,
equipment_specific_id
,
equipment_index_key
,
equipment_index_name
)
esi
ON
CONCAT
(
gdp
.
PRODUCT_KEY
,
gdp
.
DEVICE_CODE
)
=
esi
.
iot_code
AND
gdp
.
FIELD_NAME
=
esi
.
equipment_index_key
WHERE
gdp
.
GATEWAY_ID
=
#
{
gatewayId
}
and
gdp
.
ADDRESS
IS
NOT
NULL
)
temp
LEFT
JOIN
wl_equipment_specific
wes
ON
wes
.
id
=
temp
.
equipment_specific_id
LEFT
JOIN
wl_equipment_detail
wed
ON
wed
.
id
=
wes
.
equipment_detail_id
LEFT
JOIN
wl_equipment
we
ON
we
.
id
=
wed
.
equipment_id
LEFT
JOIN
wl_warehouse_structure
wws
ON
wws
.
id
=
wes
.
warehouse_structure_id
LEFT
JOIN
f_fire_fighting_system
ffs
ON
ffs
.
id
=
wes
.
system_id
LEFT
JOIN
wl_manufacturer_info
wmf
ON
wmf
.
id
=
wed
.
manufacturer_id
ORDER
BY
CAST
(
temp
.
ADDRESS
AS
DECIMAL
)
ASC
)
a
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment