Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
self-service
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
self-service
Commits
f40f0336
Commit
f40f0336
authored
Jun 21, 2023
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备管理导入模板
parent
4cdbd23e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
24 deletions
+55
-24
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
.../main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
+10
-4
sst-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
...java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
+37
-0
sst-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+8
-20
No files found.
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
View file @
f40f0336
...
@@ -9,8 +9,10 @@ import com.mortals.xhx.feign.IFeign;
...
@@ -9,8 +9,10 @@ import com.mortals.xhx.feign.IFeign;
import
feign.hystrix.FallbackFactory
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -77,8 +79,8 @@ public interface IDeviceFeign extends IFeign {
...
@@ -77,8 +79,8 @@ public interface IDeviceFeign extends IFeign {
@PostMapping
(
value
=
"/notify/downMsg"
)
@PostMapping
(
value
=
"/notify/downMsg"
)
Rest
<
String
>
downMsg
(
@RequestBody
DeviceNotifyPdu
deviceNotifyPdu
);
Rest
<
String
>
downMsg
(
@RequestBody
DeviceNotifyPdu
deviceNotifyPdu
);
@PostMapping
(
value
=
"/device/
downloadTemplate"
)
@PostMapping
(
value
=
"/device/
importData"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
void
downloadTemplate
(
);
String
importData
(
@RequestPart
MultipartFile
file
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
}
}
...
@@ -122,9 +124,13 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
...
@@ -122,9 +124,13 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
}
}
@Override
@Override
public
void
downloadTemplate
()
{
public
String
importData
(
MultipartFile
file
,
String
authorization
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"code"
,
-
1
);
jsonObject
.
put
(
"msg"
,
"暂时无法导入设备,请稍后再试!"
);
return
jsonObject
.
toJSONString
();
}
}
};
};
}
}
}
}
...
...
sst-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
View file @
f40f0336
...
@@ -15,5 +15,42 @@ import java.util.List;
...
@@ -15,5 +15,42 @@ import java.util.List;
*/
*/
@Data
@Data
public
class
DeviceVo
extends
BaseEntityLong
{
public
class
DeviceVo
extends
BaseEntityLong
{
/**
* 唯一标识
*/
private
String
token
;
/**
* 平台编码
*/
private
String
platformCode
;
/**
* 是否通知第三方
*/
private
Boolean
switchSend
=
true
;
/**
* 设备图片附件
*/
@Excel
(
name
=
"设备图片"
,
type
=
Excel
.
Type
.
IMPORT
,
cellType
=
Excel
.
ColumnType
.
IMAGE
)
@JSONField
(
deserialize
=
false
,
serialize
=
false
)
@JsonIgnore
private
PictureData
picObj
;
/** 主键ID,主键,自增长列表 */
private
List
<
Long
>
idList
;
/**
* 产品列表
*/
private
List
<
Long
>
productIdList
;
private
List
<
Integer
>
deviceStatusList
;
}
}
\ No newline at end of file
sst-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
f40f0336
...
@@ -32,6 +32,7 @@ import org.springframework.beans.BeanUtils;
...
@@ -32,6 +32,7 @@ import org.springframework.beans.BeanUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -323,7 +324,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
...
@@ -323,7 +324,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
Context
context
=
this
.
getContext
();
Context
context
=
this
.
getContext
();
String
busiDesc
=
"保存"
+
this
.
getModuleDesc
();
String
busiDesc
=
"保存"
+
this
.
getModuleDesc
();
int
code
=
1
;
int
code
=
1
;
try
{
try
{
Rest
<
RespData
<
DevicePdu
>>
rest
=
deviceFeign
.
save
(
devicePdu
,
authorization
);
Rest
<
RespData
<
DevicePdu
>>
rest
=
deviceFeign
.
save
(
devicePdu
,
authorization
);
...
@@ -332,6 +333,9 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
...
@@ -332,6 +333,9 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
model
.
put
(
"entity"
,
rest
.
getData
().
getData
());
model
.
put
(
"entity"
,
rest
.
getData
().
getData
());
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】 [id:"
+
devicePdu
.
getId
()
+
"]"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】 [id:"
+
devicePdu
.
getId
()
+
"]"
);
}
else
{
code
=
-
1
;
model
.
put
(
"message_info"
,
rest
.
getMsg
());
}
}
}
catch
(
Exception
var9
)
{
}
catch
(
Exception
var9
)
{
...
@@ -397,26 +401,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
...
@@ -397,26 +401,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
}
}
@PostMapping
({
"m/downloadTemplate"
})
@PostMapping
({
"m/importData"
})
public
void
mdownloadTemplate
()
{
public
String
importData
(
MultipartFile
file
,
@RequestHeader
(
"Authorization"
)
String
authorization
)
{
try
{
deviceFeign
.
downloadTemplate
();
}
catch
(
Exception
var4
)
{
this
.
doException
(
this
.
request
,
"导出模板异常"
,
new
HashMap
(),
var4
);
}
return
deviceFeign
.
importData
(
file
,
authorization
);
}
}
// @PostMapping({"downloadTemplate"})
// public void downloadTemplate() {
// try {
// Class<DeviceEntity> tClass = ReflectUtils.getClassGenricType(this.getClass(), 1);
// ExcelUtil<DeviceEntity, Long> util = new ExcelUtil(tClass);
// byte[] data = util.importTemplateExcel("模板数据");
// this.responseStream(this.response, data, "template.xlsx");
// } catch (Exception var4) {
// this.doException(this.request, "导出模板异常", new HashMap(), var4);
// }
//
// }
}
}
\ 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