Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
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
station
YeeAmosFireAutoSysRoot
Commits
4460a9de
Commit
4460a9de
authored
Jun 15, 2020
by
xinglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预案人员测试
parent
a72a725a
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
242 additions
and
62 deletions
+242
-62
ContingencyAction.java
...m/yeejoin/amos/fas/business/action/ContingencyAction.java
+82
-51
FasConstant.java
.../com/yeejoin/amos/fas/business/constants/FasConstant.java
+5
-0
CommonController.java
...eejoin/amos/fas/business/controller/CommonController.java
+0
-2
View3dController.java
...eejoin/amos/fas/business/controller/View3dController.java
+13
-0
DutyModeServerFallback.java
...ejoin/amos/fas/business/feign/DutyModeServerFallback.java
+4
-0
IDutyModeServer.java
.../com/yeejoin/amos/fas/business/feign/IDutyModeServer.java
+8
-4
RemoteSecurityService.java
...eejoin/amos/fas/business/feign/RemoteSecurityService.java
+0
-2
FireCarServiceImpl.java
...in/amos/fas/business/service/impl/FireCarServiceImpl.java
+6
-3
View3dServiceImpl.java
...oin/amos/fas/business/service/impl/View3dServiceImpl.java
+10
-0
IView3dService.java
...ejoin/amos/fas/business/service/intfc/IView3dService.java
+2
-0
HttpUtil.java
...ain/java/com/yeejoin/amos/fas/business/util/HttpUtil.java
+109
-0
application-dev.properties
...utoSysStart/src/main/resources/application-dev.properties
+1
-0
application-docker.properties
...SysStart/src/main/resources/application-docker.properties
+1
-0
application-test.properties
...toSysStart/src/main/resources/application-test.properties
+1
-0
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyAction.java
View file @
4460a9de
...
...
@@ -11,7 +11,13 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.fas.business.feign.IDutyModeServer
;
import
com.yeejoin.amos.fas.business.util.HttpUtil
;
import
com.yeejoin.amos.fas.core.util.CommonResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -28,6 +34,10 @@ import com.yeejoin.amos.fas.business.service.model.ContingencyRo;
import
com.yeejoin.amos.fas.business.util.StringUtil
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance
;
import
com.yeejoin.amos.fas.dao.entity.FireStrength
;
import
org.springframework.util.ObjectUtils
;
import
static
com
.
yeejoin
.
amos
.
fas
.
business
.
constants
.
FasConstant
.*;
import
static
com
.
yeejoin
.
amos
.
fas
.
business
.
constants
.
FasConstant
.
staticOrgCode
;
@Component
public
class
ContingencyAction
implements
CustomerAction
{
...
...
@@ -41,17 +51,20 @@ public class ContingencyAction implements CustomerAction {
@Autowired
private
FireStengthService
fireStrengthService
;
// private RestTemplate restTemplate = new RestTemplate();
// private RestTemplate restTemplate = new RestTemplate();
// @Value("${bussunis.domain}")
// private String bussunisDomain ;
// @Value("${bussunis.domain}")
// private String bussunisDomain ;
@Autowired
private
IRiskSourceService
riskSourceService
;
@Autowired
private
IDutyModeServer
dutyModeServer
;
private
static
Map
<
String
,
String
>
OPERATE_RECORD_ID
=
new
HashMap
<>();
private
static
Map
<
String
,
Map
<
String
,
String
>>
stringStringMap
=
new
HashMap
<>();
private
static
Map
<
String
,
Map
<
String
,
String
>>
stringStringMap
=
new
HashMap
<>();
static
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
...
...
@@ -64,51 +77,69 @@ public class ContingencyAction implements CustomerAction {
put("F1", "F1");
}};
*/
/**
* 预案文件中值为和数据字典中的对应关系
* 消防
F1 消防队长 fireLeader
F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6
运维
S1 值班长 dutyLeader
S2 副值班长 deputyDutyLeader
B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6
A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
*
F1 消防队长 fireLeader
*
F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
*
FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6
*
运维
*
S1 值班长 dutyLeader
*
S2 副值班长 deputyDutyLeader
*
B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6
*
A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
*/
p
rivate
Map
<
String
,
String
>
getStrengthMap
(
String
batchNo
)
{
p
ublic
Map
<
String
,
String
>
getStrengthMap
(
String
batchNo
)
{
Map
<
String
,
String
>
returnMap
=
stringStringMap
.
get
(
batchNo
);
Map
<
String
,
String
>
returnMap
=
stringStringMap
.
get
(
batchNo
);
if
(
CollectionUtils
.
isEmpty
(
returnMap
))
{
stringStringMap
=
new
HashMap
<>();
returnMap
=
new
HashMap
<>();
Date
now
=
new
Date
(
);
String
time
=
sdf
.
format
(
now
);
List
<
FireStrength
>
strengths
=
fireStrengthService
.
queryForStrengthList
(
time
);
// List<FireStrength> strengths = iStrengthRepository.queryForStrengthList(time
);
if
(!
CollectionUtils
.
isEmpty
(
strengths
))
{
for
(
FireStrength
fireStrength
:
strengths
)
{
String
name
=
returnMap
.
get
(
fireStrength
.
getPosition
())
;
if
(
StringUtil
.
isNotEmpty
(
name
))
{
returnMap
.
put
(
fireStrength
.
getPosition
(),
name
+
"、"
+
fireStrength
.
getUsername
(
));
}
else
{
returnMap
.
put
(
fireStrength
.
getPosition
(),
fireStrength
.
getUsername
());
}
}
Date
curDate
=
new
Date
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"dutyDate"
,
curDate
);
//CommonResponse commonResponse = dutyModeServer.dutyListByDate(appKey, product, token, staticOrgCode, param.toJSONString()
);
String
result
=
HttpUtil
.
appendPostJson
(
"duty/dutyListByDate"
,
param
.
toJSONString
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
JSONArray
dataList
=
(
JSONArray
)
jsonObject
.
get
(
"dataList"
);
if
(!
ObjectUtils
.
isEmpty
(
dataList
))
{
Map
<
String
,
String
>
finalReturnMap
=
returnMap
;
dataList
.
forEach
(
x
->
{
JSONObject
obj
=
(
JSONObject
)
x
;
String
name
=
obj
.
getString
(
"position"
);
if
(
StringUtil
.
isNotEmpty
(
name
))
{
finalReturnMap
.
put
(
name
,
name
+
"、"
+
obj
.
getString
(
"dutyName"
));
}
else
{
finalReturnMap
.
put
(
name
,
obj
.
getString
(
"dutyName"
));
}
}
);
}
stringStringMap
.
put
(
batchNo
,
returnMap
);
// Date now = new Date();
// String time = sdf.format(now);
// List<FireStrength> strengths = iStrengthRepository.queryForStrengthList(time);
// if (!CollectionUtils.isEmpty(strengths))
// {
// for (FireStrength fireStrength : strengths)
// {
// String name = returnMap.get(fireStrength.getPosition());
// if (StringUtil.isNotEmpty(name))
// {
// returnMap.put(fireStrength.getPosition(), name + "、" + fireStrength.getUsername());
// }else
// {
// returnMap.put(fireStrength.getPosition(), fireStrength.getUsername());
// }
// }
// }
stringStringMap
.
put
(
batchNo
,
returnMap
);
}
return
returnMap
;
}
...
...
@@ -176,7 +207,7 @@ public class ContingencyAction implements CustomerAction {
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
stopSnapshop
(
contingencyRo
);
//转换content中的变量
content
=
instedParams
(
content
,
contingencyRo
);
content
=
instedParams
(
content
,
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
...
...
@@ -207,7 +238,7 @@ public class ContingencyAction implements CustomerAction {
//转换智能辅助中的变量
content
=
instedParams
(
content
,
contingencyRo
);
content
=
instedParams
(
content
,
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
...
...
@@ -241,7 +272,7 @@ public class ContingencyAction implements CustomerAction {
Method
getMethod
=
null
;
try
{
for
(
Field
field
:
fields
)
{
if
(
field
.
getName
().
equals
(
"serialVersionUID"
))
if
(
field
.
getName
().
equals
(
"serialVersionUID"
))
continue
;
String
fileNameInMethod
=
String
.
valueOf
(
field
.
getName
().
charAt
(
0
)).
toUpperCase
()
+
field
.
getName
().
substring
(
1
);
getMethod
=
contingencyRo
.
getClass
().
getMethod
(
"get"
+
fileNameInMethod
);
...
...
@@ -272,7 +303,7 @@ public class ContingencyAction implements CustomerAction {
stopSnapshop
(
contingencyRo
);
//转换content中的变量
tips
=
instedParams
(
tips
,
contingencyRo
);
tips
=
instedParams
(
tips
,
contingencyRo
);
BubbleTipResult
result
=
new
BubbleTipResult
();
...
...
@@ -295,14 +326,14 @@ public class ContingencyAction implements CustomerAction {
this
.
sendcmd
(
"fromws"
,
"optionArea"
,
""
,
result
);
sendButton
(
contingencyRo
.
getBatchNo
(),
contingencyPlanId
,
contingencyRo
.
getEquipmentId
(),
actionName
,
buttonJson
);
sendButton
(
contingencyRo
.
getBatchNo
(),
contingencyPlanId
,
contingencyRo
.
getEquipmentId
(),
actionName
,
buttonJson
);
}
private
boolean
sendButton
(
String
batchNo
,
String
contingencyPlanId
,
String
equipmentId
,
String
actionName
,
String
buttonJson
)
{
private
boolean
sendButton
(
String
batchNo
,
String
contingencyPlanId
,
String
equipmentId
,
String
actionName
,
String
buttonJson
)
{
// String url = bussunisDomain+ "/api/risksource/contingency/setup";
// String url = bussunisDomain+ "/api/risksource/contingency/setup";
ObjectMapper
objectMapper
=
new
ObjectMapper
();
//Map<String,Object> map = new HashMap<>();
...
...
@@ -317,8 +348,8 @@ public class ContingencyAction implements CustomerAction {
*/
try
{
Map
button
=
objectMapper
.
readValue
(
buttonJson
,
Map
.
class
);
Map
operateInstance
=
(
Map
)
((
List
)
button
.
get
(
"operate"
)).
get
(
0
);
Map
button
=
objectMapper
.
readValue
(
buttonJson
,
Map
.
class
);
Map
operateInstance
=
(
Map
)
((
List
)
button
.
get
(
"operate"
)).
get
(
0
);
// map.put("batchNo",batchNo);
// map.put("actionName",actionName);
// map.put("equipmentId",equipmentId);
...
...
@@ -336,8 +367,8 @@ public class ContingencyAction implements CustomerAction {
contingencyDeviceStatus
.
setStepCode
(
String
.
valueOf
(
button
.
get
(
"stepCode"
)));
contingencyDeviceStatus
.
setStepState
(
String
.
valueOf
(
operateInstance
.
get
(
"stepState"
)));
riskSourceService
.
queryContingencyDeviceStatus
(
contingencyDeviceStatus
);
//HttpEntity<Map> entity = new HttpEntity<>(map);
// restTemplate.exchange(url, HttpMethod.POST,entity,Map.class);
//HttpEntity<Map> entity = new HttpEntity<>(map);
// restTemplate.exchange(url, HttpMethod.POST,entity,Map.class);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -362,7 +393,7 @@ public class ContingencyAction implements CustomerAction {
stopSnapshop
(
contingencyRo
);
//转换content中的变量
tips
=
instedParams
(
tips
,
contingencyRo
);
tips
=
instedParams
(
tips
,
contingencyRo
);
BubbleTipResult
result1
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap2
=
new
HashMap
<>();
...
...
@@ -430,7 +461,7 @@ public class ContingencyAction implements CustomerAction {
BubbleTipResult
result
=
new
BubbleTipResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
//转换content中的变量
content
=
instedParams
(
content
,
contingencyRo
);
content
=
instedParams
(
content
,
contingencyRo
);
tempmap1
.
put
(
"content"
,
content
);
tempmap1
.
put
(
"messageType"
,
messageType
);
//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/constants/FasConstant.java
View file @
4460a9de
...
...
@@ -46,4 +46,9 @@ public class FasConstant {
public
static
final
String
RISK_SOURCE_STATUS_ANOMALY
=
"ANOMALY"
;
//风险点状态-正常
public
static
final
String
PLAN_SOURCE_TYPE
=
"plan_source_type"
;
//预案资源类型
public
static
final
String
ALL_POINT
=
"all"
;
public
static
String
appKey
=
""
;
public
static
String
product
=
""
;
public
static
String
token
=
""
;
public
static
String
staticOrgCode
=
""
;
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/CommonController.java
View file @
4460a9de
...
...
@@ -174,6 +174,4 @@ public class CommonController extends BaseController {
List
<
AgencyUserModel
>
users
=
commonService
.
getAllUser
(
getToken
(),
getProduct
(),
getAppKey
(),
compCode
);
return
CommonResponseUtil
.
success
(
users
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/View3dController.java
View file @
4460a9de
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -27,6 +28,8 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
static
com
.
yeejoin
.
amos
.
fas
.
business
.
constants
.
FasConstant
.*;
@RestController
@RequestMapping
(
"/api/view3d"
)
@Api
(
tags
=
"全景监控api"
)
...
...
@@ -151,6 +154,10 @@ public class View3dController extends BaseController {
public
CommonResponse
getStatisticsDuty
(){
ReginParams
reginParams
=
getSelectedOrgInfo
();
String
orgCode
=
this
.
getOrgCode
(
reginParams
);
appKey
=
getAppKey
();
product
=
getProduct
();
staticOrgCode
=
orgCode
;
token
=
getToken
();
return
view3dService
.
getStatisticsDuty
(
getAppKey
(),
getProduct
(),
orgCode
);
}
...
...
@@ -249,4 +256,10 @@ public class View3dController extends BaseController {
public
CommonResponse
listPointsByRegion
(
@PathVariable
Long
regionId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"all"
)
String
type
){
return
CommonResponseUtil
.
success
(
view3dService
.
listPointsByRegionId
(
regionId
,
type
));
}
@ApiOperation
(
value
=
"预案人员测试方法"
,
notes
=
"预案人员测试方法"
)
@GetMapping
(
value
=
"dutyListByDate"
)
public
Map
<
String
,
String
>
getDutyListByDate
(){
return
view3dService
.
getDutyListByDate
();
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/feign/DutyModeServerFallback.java
View file @
4460a9de
...
...
@@ -10,4 +10,8 @@ public class DutyModeServerFallback implements IDutyModeServer{
return
CommonResponseUtil
.
failure
(
"fegin调用失败!!!"
);
}
@Override
public
CommonResponse
dutyListByDate
(
String
appKey
,
String
product
,
String
token
,
String
orgCode
,
String
param
)
{
return
CommonResponseUtil
.
failure
(
"fegin调用失败!!!"
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/feign/IDutyModeServer.java
View file @
4460a9de
...
...
@@ -2,10 +2,7 @@ package com.yeejoin.amos.fas.business.feign;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.*
;
import
com.yeejoin.amos.fas.core.util.CommonResponse
;
...
...
@@ -19,4 +16,11 @@ public interface IDutyModeServer {
@RequestHeader
(
name
=
"orgCode"
,
required
=
true
)
String
orgCode
,
@RequestBody
String
param
);
@RequestMapping
(
value
=
"/duty/dutyListByDate"
,
method
=
RequestMethod
.
POST
,
consumes
=
"application/json"
)
public
CommonResponse
dutyListByDate
(
@RequestHeader
(
name
=
"appKey"
,
required
=
true
)
String
appKey
,
@RequestHeader
(
name
=
"product"
,
required
=
true
)
String
product
,
@RequestHeader
(
name
=
"token"
,
required
=
true
)
String
token
,
@RequestHeader
(
name
=
"orgCode"
,
required
=
true
)
String
orgCode
,
@RequestBody
String
param
);
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/feign/RemoteSecurityService.java
View file @
4460a9de
...
...
@@ -56,8 +56,6 @@ public class RemoteSecurityService {
return
userModel
;
}
//部门id获取部门信息
public
DepartmentModel
getDepartmentByDeptId
(
String
toke
,
String
product
,
String
appKey
,
String
deparmentId
)
{
if
(
deparmentId
==
null
||
deparmentId
.
equals
(
""
))
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/FireCarServiceImpl.java
View file @
4460a9de
...
...
@@ -19,6 +19,7 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.google.common.base.Joiner
;
...
...
@@ -104,9 +105,11 @@ public class FireCarServiceImpl implements IFireCarService {
if
(!
CollectionUtils
.
isEmpty
(
deptIds
)){
List
<
DepartmentModel
>
depts
=
remoteSecurityService
.
listDepartmentByDeptIds
(
toke
,
product
,
appKey
,
Joiner
.
on
(
","
).
join
(
deptIds
));
Map
<
Long
,
String
>
deptMap
=
depts
.
stream
().
collect
(
Collectors
.
toMap
(
DepartmentModel:
:
getSequenceNbr
,
DepartmentModel:
:
getDepartmentName
));
content
.
forEach
(
e
->
{
e
.
put
(
"departmentName"
,
deptMap
.
get
(
Long
.
valueOf
(
e
.
get
(
"dept_id"
).
toString
())));
});
if
(!
ObjectUtils
.
isEmpty
(
deptMap
)){
content
.
forEach
(
e
->
{
e
.
put
(
"departmentName"
,
deptMap
.
get
(
Long
.
valueOf
(
e
.
get
(
"dept_id"
).
toString
())));
});
}
}
}
Page
<
HashMap
<
String
,
Object
>>
result
=
new
PageImpl
<
HashMap
<
String
,
Object
>>(
content
,
param
,
total
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/View3dServiceImpl.java
View file @
4460a9de
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.yeejoin.amos.fas.business.action.ContingencyAction
;
import
com.yeejoin.amos.fas.business.bo.BindPointBo
;
import
com.yeejoin.amos.fas.business.bo.CheckErrorBo
;
import
com.yeejoin.amos.fas.business.bo.RiskPointRpnChangeBo
;
...
...
@@ -47,6 +48,8 @@ import java.text.SimpleDateFormat;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
yeejoin
.
amos
.
fas
.
business
.
constants
.
FasConstant
.
token
;
/**
* @author DELL
*/
...
...
@@ -616,6 +619,13 @@ public class View3dServiceImpl implements IView3dService {
return
pointList
;
}
@Override
public
Map
<
String
,
String
>
getDutyListByDate
()
{
ContingencyAction
contingencyAction
=
new
ContingencyAction
();
Map
<
String
,
String
>
f1
=
contingencyAction
.
getStrengthMap
(
"F1"
);
return
f1
;
}
private
List
<
Map
<
String
,
Object
>>
getPointsByRegionIds
(
List
<
Long
>
ids
){
return
view3dMapper
.
getAllPointInRegions
(
ids
);
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IView3dService.java
View file @
4460a9de
...
...
@@ -173,4 +173,6 @@ public interface IView3dService {
* @return list
*/
List
<
Map
<
String
,
Object
>>
listPointsByRegionId
(
Long
regionId
,
String
type
);
Map
<
String
,
String
>
getDutyListByDate
();
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/util/HttpUtil.java
0 → 100644
View file @
4460a9de
package
com
.
yeejoin
.
amos
.
fas
.
business
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.*
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.client.RestTemplate
;
import
static
com
.
yeejoin
.
amos
.
fas
.
business
.
constants
.
FasConstant
.*;
@Component
public
class
HttpUtil
{
private
ObjectMapper
objectMapper
=
new
ObjectMapper
();
private
static
String
dutyUrl
;
@Value
(
"${DutyMode.dutyUrl}"
)
public
void
setDutyUrl
(
String
dutyUrl
)
{
HttpUtil
.
dutyUrl
=
dutyUrl
;
}
public
static
String
doGet
(
String
url
)
{
SimpleClientHttpRequestFactory
requestFactory
=
new
SimpleClientHttpRequestFactory
();
requestFactory
.
setConnectTimeout
(
2000
);
RestTemplate
restTemplate
=
new
RestTemplate
(
requestFactory
);
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setContentType
(
MediaType
.
TEXT_HTML
);
httpHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
(
httpHeaders
);
ResponseEntity
<
String
>
response
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
response
.
getBody
());
return
jsonObject
.
toString
();
}
public
static
String
PostJson
(
String
url
,
String
json
)
{
SimpleClientHttpRequestFactory
requestFactory
=
new
SimpleClientHttpRequestFactory
();
requestFactory
.
setConnectTimeout
(
2000
);
RestTemplate
restTemplate
=
new
RestTemplate
(
requestFactory
);
HttpHeaders
headers
=
new
HttpHeaders
();
HttpMethod
method
=
HttpMethod
.
POST
;
// 以表单的方式提交
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
headers
.
add
(
"X-From-Service"
,
"true"
);
//将请求头部和参数合成一个请求
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
json
,
headers
);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity
<
String
>
response
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
String
.
class
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
response
.
getBody
());
return
jsonObject
.
toString
();
}
public
static
String
doPostJson
(
String
url
,
String
json
)
{
if
(
ObjectUtils
.
isEmpty
(
url
)){
url
=
dutyUrl
;
}
SimpleClientHttpRequestFactory
requestFactory
=
new
SimpleClientHttpRequestFactory
();
requestFactory
.
setConnectTimeout
(
2000
);
RestTemplate
restTemplate
=
new
RestTemplate
(
requestFactory
);
HttpHeaders
headers
=
new
HttpHeaders
();
HttpMethod
method
=
HttpMethod
.
POST
;
// 以表单的方式提交
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
headers
.
set
(
"appKey"
,
appKey
);
headers
.
set
(
"product"
,
product
);
headers
.
set
(
"token"
,
token
);
headers
.
set
(
"orgCode"
,
staticOrgCode
);
headers
.
set
(
"X-Access-Token"
,
token
);
//将请求头部和参数合成一个请求
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
json
,
headers
);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity
<
String
>
response
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
String
.
class
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
response
.
getBody
());
return
jsonObject
.
toString
();
}
public
static
String
appendPostJson
(
String
suffix
,
String
json
)
{
String
url
=
dutyUrl
+
suffix
;
SimpleClientHttpRequestFactory
requestFactory
=
new
SimpleClientHttpRequestFactory
();
requestFactory
.
setConnectTimeout
(
2000
);
RestTemplate
restTemplate
=
new
RestTemplate
(
requestFactory
);
HttpHeaders
headers
=
new
HttpHeaders
();
HttpMethod
method
=
HttpMethod
.
POST
;
// 以表单的方式提交
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
headers
.
set
(
"appKey"
,
appKey
);
headers
.
set
(
"product"
,
product
);
headers
.
set
(
"token"
,
token
);
headers
.
set
(
"orgCode"
,
staticOrgCode
);
headers
.
set
(
"X-Access-Token"
,
token
);
//将请求头部和参数合成一个请求
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
json
,
headers
);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity
<
String
>
response
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
String
.
class
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
response
.
getBody
());
return
jsonObject
.
toString
();
}
}
YeeAmosFireAutoSysStart/src/main/resources/application-dev.properties
View file @
4460a9de
...
...
@@ -58,6 +58,7 @@ emqx.password=a123456
Push.fegin.name
=
APPMESSAGEPUSHSERVICE-36
dutyMode.fegin.name
=
AMOSDUTYMODE
DutyMode.dutyUrl
=
http://172.16.11.36:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load
=
true
...
...
YeeAmosFireAutoSysStart/src/main/resources/application-docker.properties
View file @
4460a9de
...
...
@@ -59,6 +59,7 @@ emqx.password=a123456
Push.fegin.name
=
AMOS-PUSH
dutyMode.fegin.name
=
AMOS-DUTY
DutyMode.dutyUrl
=
http://172.16.11.36:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load
=
true
...
...
YeeAmosFireAutoSysStart/src/main/resources/application-test.properties
View file @
4460a9de
...
...
@@ -59,6 +59,7 @@ emqx.password=a123456
Push.fegin.name
=
PPMESSAGEPUSHSERVICE15
dutyMode.fegin.name
=
AMOS-DUTY
DutyMode.dutyUrl
=
http://172.16.11.36:10005/
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load
=
true
...
...
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