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
9132b65d
Commit
9132b65d
authored
Mar 28, 2024
by
KeYong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop_dl_bugfix' of…
Merge branch 'develop_dl_bugfix' of
http://36.40.66.175:5000/station/YeeAmosFireAutoSysRoot
into develop_dl_bugfix
parents
7256fc0f
2bb2b669
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
657 additions
and
242 deletions
+657
-242
DataAuth.java
.../main/java/com/yeejoin/amos/fas/annotations/DataAuth.java
+22
-0
SsoTokenController.java
...join/amos/fas/business/controller/SsoTokenController.java
+0
-60
AlarmServiceImpl.java
...join/amos/fas/business/service/impl/AlarmServiceImpl.java
+4
-3
ContingencyInstanceImpl.java
...os/fas/business/service/impl/ContingencyInstanceImpl.java
+7
-0
ContingencyInstanceInfoServiceImpl.java
...ness/service/impl/ContingencyInstanceInfoServiceImpl.java
+6
-0
ContingencyPlanServiceImpl.java
...fas/business/service/impl/ContingencyPlanServiceImpl.java
+8
-1
EmergencyTaskServiceImpl.java
...s/fas/business/service/impl/EmergencyTaskServiceImpl.java
+7
-0
EquipmentFireEquipmentServiceImpl.java
...iness/service/impl/EquipmentFireEquipmentServiceImpl.java
+8
-1
EquipmentServiceImpl.java
.../amos/fas/business/service/impl/EquipmentServiceImpl.java
+5
-0
EquipmentSpecificServiceImpl.java
...s/business/service/impl/EquipmentSpecificServiceImpl.java
+6
-0
FireEquipServiceImpl.java
.../amos/fas/business/service/impl/FireEquipServiceImpl.java
+6
-0
HandlerMqttMessageImpl.java
...mos/fas/business/service/impl/HandlerMqttMessageImpl.java
+13
-45
PlanVisual3dServiceImpl.java
...os/fas/business/service/impl/PlanVisual3dServiceImpl.java
+26
-1
RiskSourceServiceImpl.java
...amos/fas/business/service/impl/RiskSourceServiceImpl.java
+28
-0
View3dServiceImpl.java
...oin/amos/fas/business/service/impl/View3dServiceImpl.java
+5
-0
CommonUtils.java
.../java/com/yeejoin/amos/fas/business/util/CommonUtils.java
+43
-0
RandomUtil.java
...n/java/com/yeejoin/amos/fas/business/util/RandomUtil.java
+0
-22
SSLClient.java
...in/java/com/yeejoin/amos/fas/business/util/SSLClient.java
+0
-80
PermissionInterceptor.java
.../yeejoin/amos/fas/interceptors/PermissionInterceptor.java
+355
-0
PermissionInterceptorContext.java
...n/amos/fas/interceptors/PermissionInterceptorContext.java
+38
-0
PermissionInterceptorContextModel.java
...s/fas/interceptors/PermissionInterceptorContextModel.java
+25
-0
YeeAmosFireAutoSysStart.java
...c/main/java/com/yeejoin/amos/YeeAmosFireAutoSysStart.java
+13
-3
application-dev.properties
...utoSysStart/src/main/resources/application-dev.properties
+9
-3
application-docker.properties
...SysStart/src/main/resources/application-docker.properties
+1
-1
application-test.properties
...toSysStart/src/main/resources/application-test.properties
+1
-1
bizMessage.xml
...eAutoSysStart/src/main/resources/db/mapper/bizMessage.xml
+1
-1
dbTemplate_alarm.xml
...ysStart/src/main/resources/db/mapper/dbTemplate_alarm.xml
+13
-13
logback.xml
YeeAmosFireAutoSysStart/src/main/resources/logback.xml
+7
-7
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/annotations/DataAuth.java
0 → 100644
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
annotations
;
import
java.lang.annotation.*
;
/**
* @author DELL
*
* 注解需要数据权限过滤的mapper。
* interfacePath对应为平台菜单管理中菜单组件(全局唯一)。
*/
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
DataAuth
{
/**
* 菜单组件
* @return
*/
String
interfacePath
();
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/SsoTokenController.java
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
business
.
controller
;
import
com.yeejoin.amos.fas.business.util.JSONUtil
;
import
com.yeejoin.amos.fas.business.util.SSLClient
;
import
com.yeejoin.amos.fas.core.util.CommonResponseUtil2
;
import
com.yeejoin.amos.fas.core.util.ResponseModel
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/api/sso"
)
@Api
(
tags
=
"获取isdp的tokenAPI"
)
public
class
SsoTokenController
{
@Value
(
"${sso.client.id}"
)
private
String
clientId
;
@Value
(
"${sso.client.secret}"
)
private
String
clientSecret
;
@Value
(
"${sso.login.client}"
)
private
String
loginClient
;
@Value
(
"${sso.client.url}"
)
private
String
clientUrl
;
@Value
(
"${sso.login.type}"
)
private
String
loginType
;
@Autowired
private
SSLClient
sslClient
;
/**
* 获取tokenAPI
*/
@ApiOperation
(
value
=
"获取token"
,
notes
=
"获取token"
)
@GetMapping
(
value
=
"/getSsoToken"
,
produces
=
"application/json;charset=UTF-8"
)
public
ResponseModel
getSsoToken
(
@RequestParam
(
value
=
"username"
)
String
username
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"client_id"
,
clientId
);
params
.
put
(
"client_secret"
,
clientSecret
);
params
.
put
(
"loginClient"
,
loginClient
);
params
.
put
(
"login_type"
,
loginType
);
params
.
put
(
"username"
,
username
);
String
message
=
JSONUtil
.
toJson
(
params
);
String
result
=
sslClient
.
doPost
(
clientUrl
,
message
,
"utf-8"
);
return
CommonResponseUtil2
.
success
(
result
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/AlarmServiceImpl.java
View file @
9132b65d
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.fas.business.service.impl;
import
java.util.HashMap
;
import
java.util.List
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
...
...
@@ -15,12 +16,12 @@ import com.yeejoin.amos.fas.core.util.StringUtil;
@Service
(
"alarmService"
)
public
class
AlarmServiceImpl
implements
IAlarmService
{
@Autowired
AlarmMapper
alarmMapper
;
@Override
public
Page
<
HashMap
<
String
,
Object
>>
queryAlarmPage
(
CommonPageInfoParam
param
)
{
public
Page
<
HashMap
<
String
,
Object
>>
queryAlarmPage
(
CommonPageInfoParam
param
)
{
long
total
=
alarmMapper
.
countAlarmData
(
param
);
List
<
HashMap
<
String
,
Object
>>
content
=
alarmMapper
.
getAlarmSingleMapperPage
(
param
);
Page
<
HashMap
<
String
,
Object
>>
result
=
new
PageImpl
<>(
content
,
param
,
total
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyInstanceImpl.java
View file @
9132b65d
...
...
@@ -30,6 +30,7 @@ import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import
com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance
;
import
com.yeejoin.amos.fas.dao.entity.Equipment
;
import
com.yeejoin.amos.fas.datasync.bo.ContingencyOriginalDataSyncBo
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
org.apache.commons.lang3.ArrayUtils
;
...
...
@@ -123,6 +124,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Value
(
"${plan.instance.personImg}"
)
private
String
personImg
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Autowired
ContingencyAction
contingencyAction
;
...
...
@@ -537,6 +540,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
return
true
;
}
EmergencyTaskContentVo
vo
=
mustTasks
.
get
(
0
);
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
Integer
count
=
contingencyPlanInstanceMapper
.
getPlanInstanceByRunState
(
vo
.
getStepCode
(),
batchNo
);
if
(
0
==
count
)
{
return
true
;
...
...
@@ -694,6 +699,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Override
public
String
getInstanceIdByBatchNOAndCategory
(
String
type
,
String
name
,
String
batchNo
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
contingencyPlanInstanceMapper
.
getInstanceIdByBatchNOAndCategory
(
type
,
name
,
batchNo
);
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyInstanceInfoServiceImpl.java
View file @
9132b65d
...
...
@@ -7,8 +7,10 @@ import com.yeejoin.amos.fas.business.vo.ContingencyInstanceInfoVO;
import
com.yeejoin.amos.fas.business.vo.ContingencyPlanInstanceVO
;
import
com.yeejoin.amos.fas.core.util.DateUtil
;
import
com.yeejoin.amos.fas.dao.entity.ContingencyInstanceInfo
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -21,6 +23,8 @@ public class ContingencyInstanceInfoServiceImpl implements ContingencyInstanceIn
@Autowired
private
ContingencyInstanceInfoMapper
contingencyInstanceInfoMapper
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Override
...
...
@@ -62,6 +66,8 @@ public class ContingencyInstanceInfoServiceImpl implements ContingencyInstanceIn
public
Boolean
addDisposalDetails
(
ContingencyInstanceInfo
contingencyInstanceInfo
)
{
contingencyInstanceInfo
.
setIsDelete
(
false
);
contingencyInstanceInfo
.
setCreateDate
(
DateUtil
.
getDateNow
());
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
contingencyInstanceInfoMapper
.
addDisposalDetails
(
contingencyInstanceInfo
);
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyPlanServiceImpl.java
View file @
9132b65d
...
...
@@ -24,6 +24,7 @@ import com.yeejoin.amos.fas.dao.entity.*;
import
com.yeejoin.amos.fas.datasync.bo.PlanDetailSyncBo
;
import
com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -92,6 +93,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Value
(
"${spring.application.name}"
)
private
String
serviceName
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Autowired
private
ContingencyInstanceInfoMapper
contingencyInstanceInfoMapper
;
...
...
@@ -243,7 +246,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
instanceInfo
.
setName
(
detail
.
getPlanName
());
instanceInfo
.
setOrgCode
(
detail
.
getOrgCode
());
instanceInfo
.
setPosition
(
equipmentSpecific
.
getPosition
());
contingencyInstanceInfoService
.
addDisposalDetails
(
instanceInfo
);
result
.
setMessage
(
ReserveEnum
.
RUN
.
getText
());
result
.
setBatchNo
(
batchNo
);
...
...
@@ -336,6 +339,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Override
public
List
<
HashMap
<
String
,
Object
>>
getBatchNoByCode
(
String
code
)
{
List
<
HashMap
<
String
,
Object
>>
list
=
new
ArrayList
<>();
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
String
idByCode
=
equipmentSpecificMapper
.
getIdByCode
(
code
);
if
(
StringUtils
.
isEmpty
(
idByCode
))
{
return
list
;
...
...
@@ -879,6 +884,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
page
.
setCurrent
(
1
);
start
=
0
;
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
ContingencyPlanInstanceVO
>
list
=
contingencyInstanceInfoMapper
.
getTaskActionPage
((
int
)
start
,
size
,
batchNo
,
type
,
runState
,
updateDate
,
roleList
);
list
.
stream
().
forEach
(
e
->{
if
(
ObjectUtils
.
isEmpty
(
e
.
getCreateUser
()))
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/EmergencyTaskServiceImpl.java
View file @
9132b65d
...
...
@@ -21,6 +21,7 @@ import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import
com.yeejoin.amos.fas.dao.entity.EmergencyRelation
;
import
com.yeejoin.amos.fas.dao.entity.EmergencyRelationTree
;
import
com.yeejoin.amos.fas.dao.entity.EmergencyTaskContent
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -72,6 +73,8 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
@Value
(
"${station.name}"
)
private
String
stationName
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Override
public
Page
<
EmergencyTaskContent
>
list
(
Long
obligationId
,
CommonPageable
pageable
)
{
...
...
@@ -99,6 +102,8 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
@Override
public
String
getRolesByUserId
(
String
userId
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
String
>
list
=
emergencyTaskMapper
.
roleCodes
(
userId
);
String
roleCodes
=
String
.
join
(
","
,
list
);
return
roleCodes
;
...
...
@@ -195,6 +200,8 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
@Override
public
List
<
EmergencyTaskContentVo
>
getMustTaskList
(
String
stepCode
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
emergencyTaskMapper
.
getMustTaskList
(
stepCode
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/EquipmentFireEquipmentServiceImpl.java
View file @
9132b65d
...
...
@@ -18,6 +18,7 @@ import com.yeejoin.amos.fas.common.enums.SqlKeyWordEnum;
import
com.yeejoin.amos.fas.dao.entity.Equipment
;
import
com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment
;
import
com.yeejoin.amos.fas.dao.entity.PlanMessage
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -54,6 +55,8 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
private
static
final
String
TYPE
=
"or"
;
private
static
final
String
VALUE
=
"true"
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
// 停运本极对端换流器
private
static
final
int
stepIndex
=
9
;
...
...
@@ -114,7 +117,7 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
@Override
public
Object
automaticExecute
(
String
equipmentId
,
String
equipCode
,
String
equipSpeCode
,
String
type
,
String
indexKeys
,
String
value
)
{
Map
<
String
,
Object
>
map
=
null
;
if
(
StringUtils
.
isBlank
(
equipCode
)){
return
false
;
}
...
...
@@ -186,6 +189,8 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
}
List
<
PlanStepJsonVO
>
result
=
JSONObject
.
parseArray
(
json
,
PlanStepJsonVO
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
result
))
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
// 获取电力设备id及batchNo
Map
<
String
,
Object
>
map
=
planOperationRecordMapper
.
getLatestFireEquipId
();
String
fireEquipId
=
String
.
valueOf
(
map
.
get
(
"fireEquipId"
));
...
...
@@ -225,6 +230,8 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
return
planMessage
;
}).
collect
(
Collectors
.
toList
());
for
(
PlanMessage
message
:
messages
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
int
count
=
planMessageMapper
.
getPlanMessageCount
(
String
.
valueOf
(
map
.
get
(
"batchNo"
)),
index
,
message
.
getIndexCreateTime
());
if
(
0
<
count
)
{
continue
;
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/EquipmentServiceImpl.java
View file @
9132b65d
...
...
@@ -20,6 +20,7 @@ import com.yeejoin.amos.fas.core.util.query.BaseQuerySpecification;
import
com.yeejoin.amos.fas.dao.dto.EquipmentDTO
;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
...
...
@@ -94,6 +95,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
@Value
(
"${server.servlet.context-path}"
)
private
String
fireAutoSys
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
...
...
@@ -189,6 +192,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
public
List
<
Map
<
String
,
Object
>>
bindFireEqumt
(
Long
equipmentId
,
List
<
EquipmentFireEquipment
>
list
)
throws
Exception
{
List
<
Map
<
String
,
Object
>>
resultList
=
new
ArrayList
<>();
for
(
EquipmentFireEquipment
equipmentFireEquipment
:
list
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
EquipmentSpecific
equip
=
equipmentSpecificMapper
.
getSpecificById
(
equipmentFireEquipment
.
getFireEquipmentId
());
int
num
=
equipmentSpecificMapper
.
getOneByQrcode
(
equip
.
getQrCode
());
if
(
0
<
num
)
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/EquipmentSpecificServiceImpl.java
View file @
9132b65d
...
...
@@ -16,7 +16,9 @@ import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import
com.yeejoin.amos.fas.dao.entity.EquipmentSpecific
;
import
com.yeejoin.amos.fas.dao.entity.Fmea
;
import
com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -37,6 +39,8 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
IEquipmentCategoryService
categoryService
;
@Autowired
FmeaEquipmentPointMapper
equipmentPointMapper
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Override
public
List
<
FmeaEquipmentPoint
>
upDateEquimentPoint
(
FmeaBindParam
fmeaBindParam
)
{
...
...
@@ -61,6 +65,8 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
public
Map
<
String
,
Object
>
getAssoEquips
(
Long
fmeaId
,
int
pageNumber
,
int
pageSize
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
pageNumber
=
pageNumber
*
pageSize
;
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
FmeaEquipmentPoint
>
fmeas
=
equipmentPointMapper
.
getOneByFmeaId
(
fmeaId
);
List
<
Long
>
indexIds
=
new
ArrayList
<>();
if
(
0
<
fmeas
.
size
())
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/FireEquipServiceImpl.java
View file @
9132b65d
...
...
@@ -14,7 +14,9 @@ import com.yeejoin.amos.fas.business.vo.FireStationVo;
import
com.yeejoin.amos.fas.common.enums.EquipClassifyEnum
;
import
com.yeejoin.amos.fas.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.response.CommonPage
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.stereotype.Service
;
...
...
@@ -43,6 +45,8 @@ public class FireEquipServiceImpl implements IFireEquipService {
@Autowired
private
IEquipManageFeign
equipManageFeign
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
public
String
[]
delete
(
String
[]
idArray
)
throws
Exception
{
// for (String id : idArray) {
...
...
@@ -128,6 +132,8 @@ public class FireEquipServiceImpl implements IFireEquipService {
Object
returnEntity
=
null
;
FireEquipmentType
fireEquipmentType
=
FireEquipmentType
.
valueOf
(
type
);
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
switch
(
fireEquipmentType
)
{
case
pool:
Object
obj
=
equipManageFeign
.
findByInstanceId
(
id
).
get
(
"result"
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/HandlerMqttMessageImpl.java
View file @
9132b65d
...
...
@@ -28,6 +28,7 @@ import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum;
import
com.yeejoin.amos.fas.core.util.StringUtil
;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
com.yeejoin.amos.fas.datasync.bo.ContingencyOriginalDataSyncBo
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -79,7 +80,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Value
(
"${integrated3Dtype}"
)
private
String
integrated3Dtype
;
@Value
(
"${plan.dynamic.execut.topic}"
)
private
String
planDynamicExecutTopic
;
...
...
@@ -142,7 +143,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Value
(
"${autoSys.fire.pool.index_key}"
)
private
String
firePoolIndexKey
;
@Value
(
"${plan.index}"
)
private
String
planIndex
;
...
...
@@ -161,6 +162,8 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Value
(
"${rocket-plan-topic}"
)
private
String
rocketTopic
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Override
public
void
handlerMqttMessage
(
String
topic
,
String
data
)
{
...
...
@@ -171,6 +174,8 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
log
.
info
(
"========data==========: "
+
JSON
.
toJSONString
(
data
));
EquipmentSpecificIndexVo
equipmentSpecificIndex
=
JSONObject
.
parseObject
(
topicEntity
.
getMessage
(),
EquipmentSpecificIndexVo
.
class
);
Long
eqSpecId
=
equipmentSpecificIndex
.
getEquipmentSpecificId
();
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
EquipmentSpecificForRiskVo
equipmentSpecific
=
equipmentSpecificMapper
.
getOneById
(
eqSpecId
);
log
.
info
(
"========equipmentSpecific==========: "
+
JSON
.
toJSONString
(
equipmentSpecific
));
if
(
ObjectUtils
.
isEmpty
(
equipmentSpecific
))
{
...
...
@@ -206,9 +211,11 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
String
title
=
String
.
format
(
"/%s/%s"
,
serviceName
,
"data/refresh/indexStatus"
);
webMqttComponent
.
publish
(
title
,
msg
);
}
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
Equipment
equipment
=
topicEntity
.
getEquipment
()
==
null
?
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
eqSpecId
)
:
topicEntity
.
getEquipment
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
...
...
@@ -266,7 +273,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
refreshFireSafety
(
equipmentSpecific
.
getOrgCode
());
String
monitorData
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
stationName
,
"data/refresh/monitorData"
);
webMqttComponent
.
publish
(
monitorData
,
JSON
.
toJSONString
(
view3dService
.
getEquipStatusList
(
equipmentSpecific
.
getOrgCode
())));
}
else
{
// 监测数据逻辑
log
.
info
(
"(监测)Message type is: "
+
specificIndexType
);
...
...
@@ -339,6 +346,8 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
private
void
startPlan
(
Equipment
equipment
,
Toke
toke
,
Long
fireEquipmentId
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
PlanDetailVo
planDetailVo
=
planDetailMapper
.
getPlanDetailByEquipmentId
(
equipment
.
getId
());
//3d页面打开且存在预案,套用之前数字源码启动逻辑 进行预案的启动
...
...
@@ -382,47 +391,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
return
true
;
}
/**
* <pre>
* @Description: rpn, rpni值修改
* </pre>
*
* @MethodName:
* @Param: [fmeaId]
* @Return: void
* @Throws
* @Author keyong
* @Date 2020/11/16 18:26
*/
public
void
updateFmeaRpn
(
long
fmeaId
)
{
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
BigDecimal
oidValue
=
new
BigDecimal
(
fmea
.
getOidValue
());
BigDecimal
sidValue
=
new
BigDecimal
(
fmea
.
getSidValue
());
BigDecimal
didValue
=
new
BigDecimal
(
fmea
.
getDidValue
());
// 计算rpni
BigDecimal
rpni
=
oidValue
.
multiply
(
sidValue
).
multiply
(
didValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
rpn
;
if
(
fmea
.
getNewEvaluationOid
()
==
null
)
{
EvaluationModel
evaluationModel
=
this
.
getEvaluationModel
(
fmeaId
);
if
(
evaluationModel
!=
null
)
{
// 已经绑定点位或者巡检点项且匹配到风险模型,则更新为计算后的结果
BigDecimal
newOidValue
=
new
BigDecimal
(
evaluationModel
.
getCoefficient
());
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
fmea
.
setNewEvaluationOid
(
evaluationModel
.
getId
());
}
else
{
// 未绑定点位或者巡检点项或者匹配不到风险模型,则更新为rpn与rpni一致
fmea
.
setNewEvaluationOid
(
fmea
.
getEvaluationOid
());
rpn
=
rpni
;
}
}
else
{
BigDecimal
newOidValue
=
new
BigDecimal
(
fmea
.
getNewOidValue
());
rpn
=
newOidValue
.
multiply
(
sidValue
).
multiply
(
didValue
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
fmea
.
setRpni
(
rpni
);
fmea
.
setRpn
(
rpn
);
// 更新fmea
fmeaMapper
.
updateRpn
(
fmea
);
}
@Override
public
void
subscribeTopic
()
{
// 若登录系统则订阅装备数据
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/PlanVisual3dServiceImpl.java
View file @
9132b65d
...
...
@@ -25,6 +25,7 @@ import com.yeejoin.amos.fas.core.util.CommonResponse;
import
com.yeejoin.amos.fas.core.util.CommonResponseUtil
;
import
com.yeejoin.amos.fas.core.util.ResponseModel
;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
...
...
@@ -119,6 +120,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Value
(
"${aurora.push.switch}"
)
private
Boolean
auroraPushSwitch
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Autowired
JcsFeign
jcsFeign
;
...
...
@@ -239,6 +243,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
public
String
getNewestBatchNo
()
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
planOperationRecordMapper
.
getNewestBatchNo
();
}
...
...
@@ -284,6 +290,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
if
(!
ObjectUtils
.
isEmpty
(
instancesList
))
{
Map
<
String
,
Object
>
msgContext
=
new
HashMap
<>(
1
);
msgContext
.
put
(
"content"
,
instancesList
);
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
ContingencyOriginalData
contingencyOriginalData
=
contingencyOriginalDataDao
.
findByBatchNo
(
batchNo
);
ContingencyInstanceInfoVO
infoVO
=
contingencyInstanceInfoMapper
.
selectDisposalDetails
(
batchNo
);
if
(!
ObjectUtils
.
isEmpty
(
infoVO
.
getPosition
()))
{
...
...
@@ -578,6 +586,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
status
=
"1"
;
}
int
total
=
0
;
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
if
(
ObjectUtils
.
isEmpty
(
status
))
{
total
=
contingencyInstanceInfoMapper
.
selectCountTaskActionPage
(
type
,
null
,
roleModelList
,
disposalId
);
}
else
{
...
...
@@ -592,6 +602,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
page
.
setCurrent
(
1
);
start
=
0
;
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
ContingencyPlanInstanceVO
>
list
=
contingencyInstanceInfoMapper
.
selectTaskActionPage
((
int
)
start
,
size
,
type
,
status
,
roleModelList
,
disposalId
);
page
.
setRecords
(
list
);
page
.
setTotal
(
total
);
...
...
@@ -607,6 +619,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
// 根据当前用户预案角色、未执行动作 (dataType = 2 查询所有)
status
=
"1"
;
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
contingencyInstanceInfoMapper
.
getTaskActionList
(
type
,
status
,
batchNo
);
}
...
...
@@ -691,6 +705,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
public
boolean
updateStatusById
(
String
id
,
Boolean
runStatus
)
{
if
(
runStatus
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
// 按钮去除
ContingencyPlanInstance
instance
=
contingencyPlanInstanceMapper
.
getMessageById
(
id
);
ContingencyPlanInstance
contingencyPlanInstance
=
deleteButton
(
instance
);
...
...
@@ -721,8 +737,12 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
if
(
runStatus
)
{
ContingencyPlanInstance
instance
=
contingencyPlanInstanceMapper
.
getMessageById
(
id
);
ContingencyPlanInstance
contingencyPlanInstance
=
deleteButton
(
instance
);
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
bool
=
contingencyPlanInstanceMapper
.
updateTaskStatusById
(
id
,
contingencyPlanInstance
.
getContent
(),
runStatus
,
userName
,
userId
,
img
,
PlanReplyMessageEnum
.
TEXT
.
getCode
(),
roleNames
);
}
else
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
bool
=
contingencyPlanInstanceMapper
.
updateTaskStatusById
(
id
,
null
,
runStatus
,
userName
,
userId
,
img
,
PlanReplyMessageEnum
.
TEXT
.
getCode
(),
roleNames
);
}
...
...
@@ -730,6 +750,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
if
(
redisTemplate
.
hasKey
(
"planTask"
))
{
redisTemplate
.
delete
(
"planTask"
);
String
planTask
=
""
;
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
ContingencyPlanInstance
instance
=
contingencyPlanInstanceMapper
.
getMessageById
(
id
);
List
<
ContingencyPlanInstanceVO
>
list
=
this
.
getTaskActionList
(
instance
.
getBatchNo
(),
1
);
if
(
0
<
list
.
size
())
{
...
...
@@ -769,7 +791,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
}
private
List
<
String
>
getUserIds
(
String
roleCode
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
planOperationRecordMapper
.
getArraysUserIds
(
roleCode
);
}
...
...
@@ -780,6 +803,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
public
String
getLastBatchNo
()
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
planOperationRecordMapper
.
getLastBatchNo
();
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
9132b65d
...
...
@@ -42,6 +42,7 @@ import com.yeejoin.amos.fas.core.util.StringUtil;
import
com.yeejoin.amos.fas.dao.entity.*
;
import
com.yeejoin.amos.fas.datasync.bo.ContingencyOriginalDataSyncBo
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.slf4j.Logger
;
...
...
@@ -180,6 +181,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired
private
PlanDetailMapper
planDetailMapper
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
public
static
String
cacheKeyForCanBeRunning
()
{
return
Redis
.
genKey
(
CacheType
.
ERASABLE
.
name
(),
"CONTINGENCYRUNING"
);
}
...
...
@@ -468,6 +472,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public
List
<
FmeaEquipmentPoint
>
bindFireEquiment
(
FmeaBindParam
fmeaBindParam
)
{
Long
fmeaId
=
fmeaBindParam
.
getFmeaId
();
Long
importantEquipId
=
fmeaBindParam
.
getImportantEquipmentId
();
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
Long
>
equipmentPointIds
=
fmeaEquipmentPointMapper
.
listEquipmentPointIdsByEquipmentId
(
fmeaBindParam
.
getEquipmentId
());
if
(!
CollectionUtils
.
isEmpty
(
equipmentPointIds
))
{
fmeaEquipmentPointMapper
.
deleteByFmeaIdAndEquipmentPointIds
(
fmeaId
,
importantEquipId
,
equipmentPointIds
);
...
...
@@ -495,6 +501,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
FmeaPointInputitem
>
bindPointInputitem
(
FmeaBindParam
fmeaBindParam
)
{
Long
fmeaId
=
fmeaBindParam
.
getFmeaId
();
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
Long
>
pointInputitemIds
=
fmeaPointInputitemMapper
.
listPointInputitemIdsByPointId
(
fmeaBindParam
.
getPointId
());
List
<
FmeaPointInputitem
>
fmeaList
=
fmeaPointInputitemMapper
.
listFmeaByFmeaId
(
fmeaId
);
if
(!
CollectionUtils
.
isEmpty
(
pointInputitemIds
))
{
...
...
@@ -561,6 +569,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo
.
setEquipmentCode
(
equipment
.
getCode
());
contingencyRo
.
setEquipmentOrgCode
(
equipment
.
getOrgCode
());
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
Map
cameraInfo
=
impAndFireEquipMapper
.
queryForCamera
(
String
.
valueOf
(
equipment
.
getId
()));
//查询重点设备关联视频点位,暂不处理
if
(
cameraInfo
!=
null
)
{
...
...
@@ -589,6 +599,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
// 获取遥信指标,暂不处理 ---20201111 code = 设备编码iot_code-指标项name_key
List
<
Map
>
points
=
fireEquipPointMapper
.
getPointsByEquipmentIdAndType
(
equipment
.
getId
(),
"SWITCH"
);
//物联属性指标 and 为true或false
HashMap
<
String
,
Integer
>
telesignallingMap
=
new
HashMap
<>();
...
...
@@ -1088,6 +1100,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Equipment
equipment
=
null
;
if
(
fireEquipment
!=
null
)
{
deviceData
.
setCode
(
fireEquipment
.
getCode
());
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
equipment
=
impAndFireEquipMapper
.
queryImpEqumtByFireEquipmt
(
deviceData
.
getFireEquimentId
());
if
(
equipment
!=
null
)
{
deviceData
.
setMonitor
(
equipment
.
getName
());
...
...
@@ -1446,6 +1460,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
*/
@Override
public
void
notifyFmeaFromUpdate
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
String
nofityType
,
String
userName
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
if
(
fmea
==
null
)
{
return
;
...
...
@@ -1490,6 +1506,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
msgParamBo
.
setNotifyType
(
nofityType
);
jpushMsgBo
=
this
.
getJushMessageInfo
(
msgParamBo
);
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
//1.3更新fmea
fmeaMapper
.
updateRpn
(
fmea
);
//2.计算上级风险值(风险点及父节点)
...
...
@@ -1557,6 +1575,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public
void
notifyFmeaFromAbnormal
(
String
toke
,
String
product
,
String
appKey
,
Long
fmeaId
,
String
notifyType
,
String
userName
,
String
relationName
,
String
checkStatus
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
Fmea
fmea
=
fmeaMapper
.
getById
(
fmeaId
);
if
(
fmea
==
null
)
{
return
;
...
...
@@ -1643,6 +1663,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
else
{
return
;
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
Fmea
>
fmeas
=
fmeaMapper
.
listByRiskSourceId
(
riskSourceId
);
if
(
CollectionUtils
.
isEmpty
(
fmeas
))
{
//fema全部删除
BigDecimal
resetValue
=
new
BigDecimal
(
"0"
);
...
...
@@ -1664,6 +1686,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
if
(
rpnValueBo
.
isEmpty
())
{
return
;
}
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
Fmea
caluFmea
=
fmeaMapper
.
getById
(
fmeaId
);
Integer
rpnDiffer
=
0
;
if
(
caluFmea
!=
null
)
{
...
...
@@ -1684,6 +1708,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource
.
setRiskLevelId
(
newRiskLevel
.
getId
());
String
changeType
=
RpnUtils
.
calChangeTypeByLevel
(
oldRiskLevel
.
getLevel
(),
newRiskLevel
.
getLevel
());
riskSource
.
setFlickerFrequency
(
RpnUtils
.
calRiskPointFrequency
(
rpn
,
rpni
,
changeType
));
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
//1.更新fmea对应风险点rpn、rpni、level
riskSourceMapper
.
updateRpn
(
riskSource
);
//2.记录风险点rpn变化流水
...
...
@@ -1814,6 +1840,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource
.
setRpni
(
null
);
riskSource
.
setRiskLevelId
(
null
);
}
else
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
List
<
Fmea
>
fmeas
=
fmeaMapper
.
listByRiskSourceIds
(
ids
);
RpnCalculationBo
rpnValueBo
=
RpnUtils
.
calRpnAndRpni
(
fmeas
);
if
(
rpnValueBo
.
isEmpty
())
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/View3dServiceImpl.java
View file @
9132b65d
...
...
@@ -37,6 +37,7 @@ import com.yeejoin.amos.fas.dao.entity.RiskLevel;
import
com.yeejoin.amos.fas.dao.entity.RiskSource
;
import
com.yeejoin.amos.fas.dao.entity.SafetyIndexChangeLog
;
import
com.yeejoin.amos.fas.exception.YeeException
;
import
com.yeejoin.amos.fas.interceptors.PermissionInterceptorContext
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -84,6 +85,8 @@ public class View3dServiceImpl implements IView3dService {
@Value
(
"${param.system.online.date}"
)
private
String
onLineDate
;
@Value
(
"${auth-key-auth-enabled:}"
)
private
String
authKey
;
@Autowired
private
IDataRefreshService
iDataRefreshService
;
...
...
@@ -501,6 +504,8 @@ public class View3dServiceImpl implements IView3dService {
@Override
public
List
<
SafetyExecuteBo
>
getEquipStatusList
(
String
orgCode
)
{
// 权限处理
PermissionInterceptorContext
.
setDataAuthRule
(
authKey
);
return
view3dMapper
.
getEquipStatusTop5
(
orgCode
);
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/util/CommonUtils.java
0 → 100644
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
business
.
util
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.Objects
;
import
java.util.function.BiConsumer
;
public
class
CommonUtils
{
/**
* 带索引foreach
*
* @param <T>
* @param startIndex 开始遍历的索引
* @param elements 集合
* @param action
*/
public
static
<
T
>
void
forEach
(
int
startIndex
,
Iterable
<?
extends
T
>
elements
,
BiConsumer
<
Integer
,
?
super
T
>
action
)
{
Objects
.
requireNonNull
(
elements
);
Objects
.
requireNonNull
(
action
);
if
(
startIndex
<
0
)
{
startIndex
=
0
;
}
int
index
=
0
;
for
(
T
element
:
elements
)
{
index
++;
if
(
index
<=
startIndex
)
{
continue
;
}
action
.
accept
(
index
-
1
,
element
);
}
}
public
static
Object
getFiledValueByName
(
String
filedName
,
Object
o
)
throws
InvocationTargetException
,
IllegalAccessException
,
NoSuchMethodException
{
String
firstLetter
=
filedName
.
substring
(
0
,
1
).
toUpperCase
();
String
getterName
=
"get"
+
firstLetter
+
filedName
.
substring
(
1
);
Method
method
;
method
=
o
.
getClass
().
getMethod
(
getterName
,
new
Class
[]{});
Object
value
=
method
.
invoke
(
o
,
new
Object
[]{});
return
value
;
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/util/RandomUtil.java
View file @
9132b65d
...
...
@@ -19,26 +19,4 @@ public class RandomUtil {
}
return
newDate
+
result
;
}
/**
* @param resourceType 资源类型
* @param companyCode 单位编号
* @Description Random存在性能问题可能造成线程阻塞问题,使
* 用性能更加卓越的threadLocalRandom(线程安全的单例模式)生成随机数
* 四位随机数无法保证不可重复性,如果对不可重复要求高,请使用其他工具
* @Author songLei
* @Return String
* @Date 2020/12/18 11:49
*/
public
static
String
buildNo
(
String
resourceType
,
String
companyCode
)
{
threadLocalRandom
=
ThreadLocalRandom
.
current
();
int
num
=
threadLocalRandom
.
nextInt
(
1000
,
9999
);
return
resourceType
+
companyCode
+
num
;
}
public
static
String
buildNo
()
{
threadLocalRandom
=
ThreadLocalRandom
.
current
();
int
num
=
threadLocalRandom
.
nextInt
(
1000
,
9999
);
return
String
.
valueOf
(
num
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/util/SSLClient.java
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
business
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.conn.ClientConnectionManager
;
import
org.apache.http.conn.scheme.Scheme
;
import
org.apache.http.conn.scheme.SchemeRegistry
;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.stereotype.Component
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
@Slf4j
@Component
public
class
SSLClient
extends
DefaultHttpClient
{
public
SSLClient
()
throws
Exception
{
super
();
//传输协议需要根据自己的判断
SSLContext
ctx
=
SSLContext
.
getInstance
(
"TLSv1.2"
);
X509TrustManager
tm
=
new
X509TrustManager
()
{
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
};
ctx
.
init
(
null
,
new
TrustManager
[]{
tm
},
null
);
SSLSocketFactory
ssf
=
new
SSLSocketFactory
(
ctx
,
SSLSocketFactory
.
ALLOW_ALL_HOSTNAME_VERIFIER
);
ClientConnectionManager
ccm
=
this
.
getConnectionManager
();
SchemeRegistry
sr
=
ccm
.
getSchemeRegistry
();
sr
.
register
(
new
Scheme
(
"https"
,
443
,
ssf
));
}
public
String
doPost
(
String
url
,
String
map
,
String
charset
)
{
org
.
apache
.
http
.
client
.
HttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
try
{
httpClient
=
new
SSLClient
();
httpPost
=
new
HttpPost
(
url
);
//设置参数
httpPost
.
addHeader
(
"Accept"
,
"application/json"
);
httpPost
.
addHeader
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
StringEntity
stringEntity
=
new
StringEntity
(
map
);
stringEntity
.
setContentEncoding
(
"UTF-8"
);
stringEntity
.
setContentType
(
"application/json"
);
httpPost
.
setEntity
(
stringEntity
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
{
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
return
result
;
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/interceptors/PermissionInterceptor.java
0 → 100644
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
interceptors
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.toolkit.PluginUtils
;
import
com.google.common.collect.Maps
;
import
com.yeejoin.amos.fas.annotations.DataAuth
;
import
com.yeejoin.amos.fas.business.util.CommonUtils
;
import
com.yeejoin.amos.fas.business.vo.ReginParams
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.PermissionDataruleModel
;
import
net.sf.jsqlparser.JSQLParserException
;
import
net.sf.jsqlparser.expression.operators.conditional.AndExpression
;
import
net.sf.jsqlparser.parser.CCJSqlParserUtil
;
import
net.sf.jsqlparser.schema.Table
;
import
net.sf.jsqlparser.statement.select.PlainSelect
;
import
net.sf.jsqlparser.statement.select.Select
;
import
net.sf.jsqlparser.statement.select.SubSelect
;
import
org.apache.ibatis.executor.Executor
;
import
org.apache.ibatis.executor.statement.StatementHandler
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
org.apache.ibatis.plugin.*
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.apache.ibatis.reflection.SystemMetaObject
;
import
org.apache.ibatis.session.ResultHandler
;
import
org.apache.ibatis.session.RowBounds
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.stream.Collectors
;
@Component
@Intercepts
({
@Signature
(
type
=
Executor
.
class
,
method
=
"query"
,
args
=
{
MappedStatement
.
class
,
Object
.
class
,
RowBounds
.
class
,
ResultHandler
.
class
}),
@Signature
(
type
=
StatementHandler
.
class
,
method
=
"prepare"
,
args
=
{
Connection
.
class
,
Integer
.
class
})})
public
class
PermissionInterceptor
implements
Interceptor
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PermissionInterceptor
.
class
);
@Autowired
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
private
String
falseCondition
=
" 1=2"
;
@Override
public
Object
intercept
(
Invocation
invocation
)
throws
Throwable
{
StatementHandler
statementHandler
=
PluginUtils
.
realTarget
(
invocation
.
getTarget
());
MetaObject
metaObject
=
SystemMetaObject
.
forObject
(
statementHandler
);
MappedStatement
mappedStatement
=
(
MappedStatement
)
metaObject
.
getValue
(
"delegate.mappedStatement"
);
String
dataAuthRule
=
PermissionInterceptorContext
.
getDataAuthRule
();
// 被拦截方法
Method
method
=
getTargetDataAuthMethod
(
mappedStatement
);
DataAuth
dataAuth
=
getTargetDataAuthAnnotation
(
mappedStatement
);
// 没有DataAuth定义注解或注解为空的跳过及没有手动指定使用数据规则的跳过
if
((
null
==
dataAuth
||
ValidationUtil
.
isEmpty
(
dataAuth
.
interfacePath
()))
&&
ValidationUtil
.
isEmpty
(
dataAuthRule
))
{
PermissionInterceptorContext
.
clean
();
return
invocation
.
proceed
();
}
if
(!
ValidationUtil
.
isEmpty
(
dataAuth
)){
dataAuthRule
=
!
ValidationUtil
.
isEmpty
(
dataAuthRule
)
?
dataAuthRule
:
dataAuth
.
interfacePath
();
}
ReginParams
reginParam
=
JSON
.
parseObject
(
redisTemplate
.
opsForValue
().
get
(
"biz_"
+
RequestContext
.
getExeUserId
()
+
RequestContext
.
getToken
()),
ReginParams
.
class
);
// 用户数据权限配置信息
Map
<
String
,
List
<
PermissionDataruleModel
>>
dataAuthorization
=
null
;
if
(!
ValidationUtil
.
isEmpty
(
reginParam
)
&&
!
ValidationUtil
.
isEmpty
(
reginParam
.
getUserModel
()))
{
dataAuthorization
=
Privilege
.
permissionDataruleClient
.
queryByUser
(
reginParam
.
getUserModel
().
getUserId
(),
dataAuthRule
).
getResult
();
}
BoundSql
boundSql
=
(
BoundSql
)
metaObject
.
getValue
(
"delegate.boundSql"
);
String
sql
=
boundSql
.
getSql
();
// 将权限规则拼接到原始sql
try
{
sql
=
processSelectSql
(
sql
,
dataAuthorization
,
reginParam
,
boundSql
);
}
catch
(
Exception
e
)
{
PermissionInterceptorContext
.
clean
(
dataAuthRule
);
logger
.
debug
(
e
.
getMessage
());
}
metaObject
.
setValue
(
"delegate.boundSql.sql"
,
sql
);
PermissionInterceptorContext
.
clean
(
dataAuthRule
);
return
invocation
.
proceed
();
}
@Override
public
Object
plugin
(
Object
target
)
{
if
(
target
instanceof
StatementHandler
)
{
return
Plugin
.
wrap
(
target
,
this
);
}
return
target
;
}
@Override
public
void
setProperties
(
Properties
properties
)
{
}
/**
* 获取当前执行语句对应mapper方法的DataAuth注解
*
* @param mappedStatement
* @return
* @throws ClassNotFoundException
*/
private
DataAuth
getTargetDataAuthAnnotation
(
MappedStatement
mappedStatement
)
throws
ClassNotFoundException
{
if
(
ValidationUtil
.
isEmpty
(
getTargetDataAuthMethod
(
mappedStatement
)))
{
return
null
;
}
return
getTargetDataAuthMethod
(
mappedStatement
).
getAnnotation
(
DataAuth
.
class
);
}
/**
* 获取当前添加数据权限DataAuth的执行语句对应mapper方法
*
* @param mappedStatement
* @return
* @throws ClassNotFoundException
*/
private
Method
getTargetDataAuthMethod
(
MappedStatement
mappedStatement
)
throws
ClassNotFoundException
{
String
id
=
mappedStatement
.
getId
();
String
className
=
id
.
substring
(
0
,
id
.
lastIndexOf
(
"."
));
String
methodName
=
id
.
substring
(
id
.
lastIndexOf
(
"."
)
+
1
);
final
Class
<?>
cls
=
Class
.
forName
(
className
);
final
Method
[]
methods
=
cls
.
getMethods
();
for
(
Method
method
:
methods
)
{
// TODO 后续重载方法需要优化
if
(
method
.
getName
().
equals
(
methodName
)
&&
method
.
isAnnotationPresent
(
DataAuth
.
class
))
{
return
method
;
}
}
return
null
;
}
/**
* 处理select语句
*
* @param sql 原始SQL
* @param dataAuthorization 数据校验规则
* @param reginParams 用户登录信息
*/
private
String
processSelectSql
(
String
sql
,
Map
<
String
,
List
<
PermissionDataruleModel
>>
dataAuthorization
,
ReginParams
reginParams
,
BoundSql
boundSql
)
throws
JSQLParserException
{
String
replaceSql
=
null
;
Select
select
=
(
Select
)
CCJSqlParserUtil
.
parse
(
sql
);
PlainSelect
selectBody
=
(
PlainSelect
)
select
.
getSelectBody
();
String
mainTable
=
null
;
if
(
selectBody
.
getFromItem
()
instanceof
Table
)
{
mainTable
=
((
Table
)
selectBody
.
getFromItem
()).
getName
().
replace
(
"`"
,
""
);
}
else
if
(
selectBody
.
getFromItem
()
instanceof
SubSelect
)
{
String
subSelectStr
=
(((
SubSelect
)
selectBody
.
getFromItem
()).
getSelectBody
().
toString
());
replaceSql
=
processSelectSql
(
CCJSqlParserUtil
.
parse
(
subSelectStr
).
toString
(),
dataAuthorization
,
reginParams
,
boundSql
);
if
(!
ValidationUtil
.
isEmpty
(
replaceSql
))
{
sql
=
CCJSqlParserUtil
.
parse
(
sql
).
toString
().
replace
(
subSelectStr
,
replaceSql
);
return
sql
;
}
}
String
mainTableAlias
=
ValidationUtil
.
isEmpty
(
selectBody
.
getFromItem
().
getAlias
())
?
mainTable
:
selectBody
.
getFromItem
().
getAlias
().
getName
();
String
authSql
;
if
(
ValidationUtil
.
isEmpty
(
dataAuthorization
))
{
authSql
=
falseCondition
;
}
else
{
// 过滤没有配置数据权限的用户组
Map
<
String
,
List
<
PermissionDataruleModel
>>
nonEmptyDataAuthorization
=
dataAuthorization
.
entrySet
().
stream
().
filter
(
map
->
!
ValidationUtil
.
isEmpty
(
map
.
getValue
())).
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
));
// 没有配置数据权限直接返回 false 条件
if
(
ValidationUtil
.
isEmpty
(
nonEmptyDataAuthorization
))
{
authSql
=
falseCondition
;
}
else
{
// 解析数据权限sql
authSql
=
parseDataAuthorization
(
nonEmptyDataAuthorization
,
reginParams
,
mainTableAlias
,
boundSql
);
}
}
// 替换数据权限
if
(!
ValidationUtil
.
isEmpty
(
authSql
))
{
if
(
ValidationUtil
.
isEmpty
(
selectBody
.
getWhere
()))
{
selectBody
.
setWhere
(
CCJSqlParserUtil
.
parseCondExpression
(
authSql
));
}
else
{
AndExpression
andExpr
=
new
AndExpression
(
selectBody
.
getWhere
(),
CCJSqlParserUtil
.
parseCondExpression
(
authSql
));
selectBody
.
setWhere
(
andExpr
);
}
}
else
{
return
null
;
}
return
selectBody
.
toString
();
}
/**
* 处理select语句
*
* @param sql 原始SQL
* @param authSql 数据校验规则
*/
// private String processSelectSql2(String sql, String authSql) throws JSQLParserException {
// String replaceSql = null;
// Select select = (Select) CCJSqlParserUtil.parse(sql);
// String mainTable = null;
// PlainSelect selectBody = (PlainSelect) select.getSelectBody();
// if (selectBody.getFromItem() instanceof Table) {
// mainTable = ((Table) selectBody.getFromItem()).getName().replace("`", "");
// } else if (selectBody.getFromItem() instanceof SubSelect) {
// replaceSql = processSelectSql(sql, authSql);
// }
// if (!ValidationUtil.isEmpty(replaceSql)) {
// sql = sql.replace(((SubSelect) selectBody.getFromItem()).getSelectBody().toString(), replaceSql);
// }
// String mainTableAlias = mainTable;
// mainTableAlias = ValidationUtil.isEmpty(selectBody.getFromItem().getAlias()) ?
// ((Table) selectBody.getFromItem()).getName() : selectBody.getFromItem().getAlias().getName();
//
// // 替换数据权限
// if (!ValidationUtil.isEmpty(authSql)) {
// if (ValidationUtil.isEmpty(selectBody.getWhere())) {
// selectBody.setWhere(CCJSqlParserUtil.parseCondExpression(authSql));
// } else {
// AndExpression andExpr = new AndExpression(selectBody.getWhere(), CCJSqlParserUtil.parseCondExpression(authSql));
// selectBody.setWhere(andExpr);
// }
// }
// return selectBody.toString();
// }
/**
* 解析数据权限
*
* @param dataAuthorization
*/
private
String
parseDataAuthorization
(
Map
<
String
,
List
<
PermissionDataruleModel
>>
dataAuthorization
,
ReginParams
reginParam
,
String
mainTableAlias
,
BoundSql
boundSql
)
{
StringBuilder
sb
=
new
StringBuilder
();
if
(!
ValidationUtil
.
isEmpty
(
dataAuthorization
))
{
sb
.
append
(
"("
);
CommonUtils
.
forEach
(
0
,
dataAuthorization
.
entrySet
(),
(
index
,
item
)
->
{
List
<
PermissionDataruleModel
>
ruleList
=
item
.
getValue
();
StringBuilder
sb1
=
new
StringBuilder
();
if
(!
ValidationUtil
.
isEmpty
(
ruleList
))
{
if
(
index
>
0
)
{
// 多个用户组的数据权限取并集
sb
.
append
(
" OR "
);
}
sb1
.
append
(
"("
);
CommonUtils
.
forEach
(
0
,
ruleList
,
(
i
,
rule
)
->
{
String
appendStr
=
parseRule2Sql
(
rule
,
reginParam
,
mainTableAlias
,
boundSql
);
if
(
ValidationUtil
.
isEmpty
(
appendStr
))
{
return
;
}
sb1
.
append
(
appendStr
);
if
(
i
<
ruleList
.
size
()
-
1
)
{
// 同一用户组内的数据权限取交集
sb1
.
append
(
" AND "
);
}
});
sb1
.
append
(
")"
);
sb
.
append
(
sb1
);
}
});
sb
.
append
(
")"
);
}
return
sb
.
toString
();
}
/**
* 解析数据权限规则为sql语句
*
* @param rule
* @param reginParam
*/
private
String
parseRule2Sql
(
PermissionDataruleModel
rule
,
ReginParams
reginParam
,
String
mainTableAlias
,
BoundSql
boundSql
)
{
String
authSql
;
String
ruleCondition
=
rule
.
getRuleConditions
();
try
{
if
(
ruleCondition
.
contains
(
"_"
))
{
// 左模糊"%_"、右模糊"_%"、模糊"%_%"
if
(
ruleCondition
.
contains
(
"%"
))
{
authSql
=
mainTableAlias
+
"."
+
rule
.
getRuleColumn
()
+
" like '"
+
ruleCondition
.
replace
(
"_"
,
getRuleValue
(
rule
,
reginParam
,
boundSql
))
+
"'"
;
}
else
{
// 包含
authSql
=
mainTableAlias
+
"."
+
rule
.
getRuleColumn
()
+
" like '%"
+
getRuleValue
(
rule
,
reginParam
,
boundSql
)
+
"%'"
;
}
}
else
{
// =; >; >=; <; <=; !=
authSql
=
mainTableAlias
+
"."
+
rule
.
getRuleColumn
()
+
rule
.
getRuleConditions
()
+
"'"
+
getRuleValue
(
rule
,
reginParam
,
boundSql
)
+
"'"
;
}
}
catch
(
Exception
e
)
{
logger
.
debug
(
e
.
getMessage
());
return
null
;
}
return
authSql
;
}
private
String
getRuleValue
(
PermissionDataruleModel
rule
,
ReginParams
reginParam
,
BoundSql
boundSql
)
throws
IllegalAccessException
,
NoSuchMethodException
,
InvocationTargetException
{
String
ruleValue
=
rule
.
getRuleValue
();
// 从登录信息中获取参数值
if
(
ruleValue
.
startsWith
(
"#{"
)
&&
ruleValue
.
endsWith
(
"}"
))
{
String
attrName
=
ruleValue
.
substring
(
2
,
ruleValue
.
length
()
-
1
);
// TODO 根据 attrName(deptCode,compCode等) 从登录信息的不同对象里取值
ruleValue
=
(
String
)
CommonUtils
.
getFiledValueByName
(
attrName
,
reginParam
.
getCompany
());
}
// 从查询参数中获取参数值
if
(
ruleValue
.
startsWith
(
"${"
)
&&
ruleValue
.
endsWith
(
"}"
))
{
Map
<
String
,
Object
>
map
;
if
(
boundSql
.
getParameterObject
()
instanceof
Map
)
{
map
=
(
Map
<
String
,
Object
>)
boundSql
.
getParameterObject
();
}
else
{
map
=
Bean
.
BeantoMap
(
boundSql
.
getParameterObject
());
}
String
attrName
=
ruleValue
.
substring
(
2
,
ruleValue
.
length
()
-
1
);
ruleValue
=
ValidationUtil
.
isEmpty
(
map
.
get
(
attrName
))
?
""
:
map
.
get
(
attrName
).
toString
();
}
// 从查询参数中获取json字段参数值
if
(
rule
.
getRuleColumn
().
contains
(
"->"
))
{
Map
<
String
,
Object
>
map
;
Map
<
String
,
Object
>
map2
=
Maps
.
newHashMap
();
if
(
boundSql
.
getParameterObject
()
instanceof
Map
)
{
map
=
(
Map
<
String
,
Object
>)
boundSql
.
getParameterObject
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
if
(
entry
.
getValue
()
instanceof
Map
)
{
map2
.
putAll
((
Map
<?
extends
String
,
?>)
entry
.
getValue
());
}
}
map
.
putAll
(
map2
);
}
else
{
map
=
Bean
.
BeantoMap
(
boundSql
.
getParameterObject
());
}
if
(
map
.
containsKey
(
ruleValue
))
{
ruleValue
=
ValidationUtil
.
isEmpty
(
map
.
get
(
ruleValue
))
?
falseCondition
:
map
.
get
(
ruleValue
).
toString
();
}
}
return
ruleValue
;
}
}
\ No newline at end of file
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/interceptors/PermissionInterceptorContext.java
0 → 100644
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
interceptors
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
PermissionInterceptorContext
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PermissionInterceptorContext
.
class
);
private
static
ThreadLocal
<
PermissionInterceptorContextModel
>
requestContext
=
ThreadLocal
.
withInitial
(
PermissionInterceptorContextModel:
:
new
);
private
static
PermissionInterceptorContextModel
getPermissionInterceptorContext
()
{
return
requestContext
.
get
();
}
public
static
String
getDataAuthRule
()
{
return
getPermissionInterceptorContext
().
getDataAuthRule
();
}
public
static
void
setDataAuthRule
(
String
dataAuthRule
)
{
getPermissionInterceptorContext
().
setDataAuthRule
(
dataAuthRule
);
}
public
static
void
clean
()
{
if
(
requestContext
!=
null
)
{
logger
.
info
(
"PermissionInterceptorContext clean RestThreadLocal......Begin"
);
requestContext
.
remove
();
logger
.
info
(
"PermissionInterceptorContext clean RestThreadLocal......Done"
);
}
}
public
static
void
clean
(
String
info
)
{
if
(
requestContext
!=
null
)
{
logger
.
info
(
"......"
+
info
+
"......PermissionInterceptorContext clean RestThreadLocal......Begin"
);
requestContext
.
remove
();
logger
.
info
(
"......"
+
info
+
"......PermissionInterceptorContext clean RestThreadLocal......Done"
);
}
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/interceptors/PermissionInterceptorContextModel.java
0 → 100644
View file @
9132b65d
package
com
.
yeejoin
.
amos
.
fas
.
interceptors
;
import
java.io.Serializable
;
/**
*
*/
public
class
PermissionInterceptorContextModel
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
dataAuthRule
;
public
String
getDataAuthRule
()
{
return
dataAuthRule
;
}
public
void
setDataAuthRule
(
String
dataAuthRule
)
{
this
.
dataAuthRule
=
dataAuthRule
;
}
public
void
clean
()
{
this
.
dataAuthRule
=
null
;
}
}
YeeAmosFireAutoSysStart/src/main/java/com/yeejoin/amos/YeeAmosFireAutoSysStart.java
View file @
9132b65d
...
...
@@ -3,6 +3,8 @@ package com.yeejoin.amos;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.URISyntaxException
;
import
java.security.SecureRandom
;
import
java.util.Collections
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.slf4j.Logger
;
...
...
@@ -22,7 +24,10 @@ import org.springframework.context.ApplicationContextAware;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.data.jpa.repository.config.EnableJpaAuditing
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
...
...
@@ -71,9 +76,14 @@ public class YeeAmosFireAutoSysStart implements ApplicationContextAware {
*/
public
static
void
main
(
String
[]
args
)
{
log
.
info
(
"start Service.........."
);
ApplicationContext
context
=
SpringApplication
.
run
(
YeeAmosFireAutoSysStart
.
class
,
args
);
Environment
env
=
context
.
getEnvironment
();
String
appName
=
env
.
getProperty
(
"spring.application.name"
);
SpringApplication
application
=
new
SpringApplication
(
YeeAmosFireAutoSysStart
.
class
);
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
int
randomClientId
=
new
SecureRandom
().
nextInt
(
65536
-
1024
)
+
1024
;
environment
.
getPropertySources
().
addFirst
(
new
MapPropertySource
(
"securityRandomSource"
,
Collections
.
singletonMap
(
"security-random-int"
,
randomClientId
)));
application
.
setEnvironment
(
environment
);
application
.
run
();
String
appName
=
environment
.
getProperty
(
"spring.application.name"
);
log
.
info
(
"\n----------------------------------------------------------\n\t"
+
"Application {} is running!\n"
...
...
YeeAmosFireAutoSysStart/src/main/resources/application-dev.properties
View file @
9132b65d
#DB properties:
spring.datasource.url
=
jdbc:mysql://172.16.11.201:3306/dl_business
_v3.0.1.3_pyh_0510
?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.url
=
jdbc:mysql://172.16.11.201:3306/dl_business?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username
=
root
spring.datasource.password
=
ENC(ymcOoS7xaghkc/E5jSK3Yi9Zz42LWTls9jVGpYgsRTqLxPpXfqkIXAtXHwCSPOcw)
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
...
...
@@ -21,8 +21,8 @@ amos.system.user.product=STUDIO_APP_WEB
eureka.client.serviceUrl.defaultZone
:
http://${spring.security.user.name}:${spring.security.user.password}@172.16.11.201:10001/eureka/
eureka.instance.prefer-ip-address
=
true
management.security.enabled
=
true
management.endpoint.health.show-details
=
always
management.endpoints.web.exposure.include
=
*
eureka.instance.health-check-url-path
=
/actuator/health
eureka.instance.metadata-map.management.context-path
=
${server.servlet.context-path}/actuator
eureka.instance.status-page-url-path
=
/actuator/info
...
...
@@ -55,7 +55,7 @@ file.readUrl=http://172.16.11.201:8085/file/getFile?in=
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${
random.int[1024,65536]
}
emqx.client-id
=
${spring.application.name}-${
security-random-int
}
emqx.broker
=
tcp://172.16.11.201:1883
emqx.client-user-name
=
admin
emqx.client-password
=
ENC(IWhwMSgko6moJ+JDuh5cq41ixOfhyyiaoRiOCw5Iv3f+YAO8Ib5KpWattlT6h57p)
...
...
@@ -112,3 +112,9 @@ sso.client.secret=6t5oDDKhEODXa++UNUxxLHSF5kVqECq6j+wahtCbv8c=
sso.login.type
=
server_auth
sso.login.client
=
dce
sso.client.url
=
https://198.87.103.88:30443/oauth2/oauth/rest_token
# MyBatis \u914D\u7F6E
mybatis.interceptor.enabled
=
true
mybatis.configuration.log-impl
=
org.apache.ibatis.logging.stdout.StdOutImpl
# \u542F\u7528\u8BA4\u8BC1
auth-key-auth-enabled
=
auth-enabled
YeeAmosFireAutoSysStart/src/main/resources/application-docker.properties
View file @
9132b65d
...
...
@@ -42,7 +42,7 @@ file.readUrl=http://172.16.11.201:8085/file/getFile?in=
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${
random.int[1024,65536]
}
emqx.client-id
=
${spring.application.name}-${
security-random-int
}
emqx.broker
=
tcp://172.16.11.201:1883
emqx.user-name
=
admin
emqx.password
=
ENC(vlnMOpNNk7wWAcVgqh/C61LOajZY3f1XOFZEqcJ774SdtZeKnOCoNL3u4idRVr+S)
...
...
YeeAmosFireAutoSysStart/src/main/resources/application-test.properties
View file @
9132b65d
...
...
@@ -42,7 +42,7 @@ file.readUrl=http://172.16.11.201:8085/file/getFile?in=
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${
random.int[1024,65536]
}
emqx.client-id
=
${spring.application.name}-${
security-random-int
}
emqx.broker
=
tcp://172.16.11.201:1883
emqx.user-name
=
admin
emqx.password
=
ENC(JcSMTcnJjJsR/wlfW4MqxYnTVVxymsc7iZN3l+gRadRsplNeScSxFa3gbCv30oDt)
...
...
YeeAmosFireAutoSysStart/src/main/resources/db/mapper/bizMessage.xml
View file @
9132b65d
...
...
@@ -39,7 +39,7 @@
WHERE
1=1
<if
test=
"time!=null"
>
and TO_DAYS(m.time) = TO_DAYS(
'#{time}'
)
and TO_DAYS(m.time) = TO_DAYS(
#{time}
)
</if>
<if
test=
"type!=null"
>
...
...
YeeAmosFireAutoSysStart/src/main/resources/db/mapper/dbTemplate_alarm.xml
View file @
9132b65d
...
...
@@ -6,19 +6,19 @@
<select
id=
"countPageData"
resultType=
"long"
>
<!-- SELECT
count(a.id) AS total_num
FROM `f_alarm` a
inner join
FROM `f_alarm` a
inner join
(
select
b.fire_equipment_id,c.`name` as protectObj,d.*
from
from
f_equipment_fire_equipment b,f_equipment c, f_fire_equipment d
where
where
c.id = b.equipment_id and d.id = b.fire_equipment_id
<if test="productArea!=null"> and d.production_area = #{productArea} </if>
<if test="protectObj!=null"> and c.id = #{protectObj} </if>
<if test="name!=null"> and d.name like concat(concat("%",#{name}),"%")</if>
) sa on sa.id = a.fire_equipment_id
) sa on sa.id = a.fire_equipment_id
<trim prefix="WHERE" prefixOverrides="AND ">
<if test="beginDate!=null"> and a.alarm_time >= #{beginDate} </if>
<if test="endDate!=null"> and a.alarm_time <![CDATA[<=]]> #{endDate} </if>
...
...
@@ -39,7 +39,7 @@
<!--分页查询 -->
<select
id=
"getAlarmMapperPage"
resultType=
"java.util.HashMap"
>
<!-- SELECT
a.id,
a.id,
sa.code,
sa.equip_code as equipCode,
sa.name,
...
...
@@ -52,19 +52,19 @@
a.status AS status,
a.recovery_date AS recoveryDate
FROM `f_alarm` a
FROM `f_alarm` a
inner join
(
select
b.fire_equipment_id,c.`name` as protectObj,d.production_area as prodArea,d.*
from
from
f_equipment_fire_equipment b,f_equipment c, f_fire_equipment d
where
where
c.id = b.equipment_id and d.id = b.fire_equipment_id
<if test="productArea!=null"> and d.production_area = #{productArea} </if>
<if test="protectObj!=null"> and c.id = #{protectObj} </if>
<if test="name!=null"> and d.name like concat(concat("%",#{name}),"%")</if>
) sa on sa.id = a.fire_equipment_id
) sa on sa.id = a.fire_equipment_id
<trim prefix="WHERE" prefixOverrides="AND ">
<if test="beginDate!=null"> and a.alarm_time >= #{beginDate} </if>
<if test="endDate!=null"> and a.alarm_time <![CDATA[<=]]> #{endDate} </if>
...
...
@@ -72,7 +72,7 @@
order by a.id
<choose>
<when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
</choose> -->
</select>
...
...
@@ -120,8 +120,8 @@
left join wl_warehouse_structure wws on wlsd.warehouse_structure_id = wws.source_id
left join wl_equipment_detail wled on wles.equipment_detail_id = wled.id
) d
WHERE
1=1
AND
d.fireEquipmentName IS NOT NULL
WHERE
d.fireEquipmentName IS NOT NULL
<if
test=
"protectObj !=null and protectObj != '' "
>
and d.fireEquipmentName like concat(concat("%",#{protectObj}),"%")
</if>
<if
test=
"beginDate!=null"
>
and d.createDate >= #{beginDate}
</if>
<if
test=
"endDate!=null"
>
and d.createDate
<![CDATA[<=]]>
#{endDate}
</if>
...
...
YeeAmosFireAutoSysStart/src/main/resources/logback.xml
View file @
9132b65d
...
...
@@ -33,15 +33,15 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger
name=
"com.apache.ibatis"
level=
"
DEBUG
"
/>
<logger
name=
"org.mybatis"
level=
"
DEBUG
"
/>
<logger
name=
"java.sql.Connection"
level=
"
DEBUG
"
/>
<logger
name=
"java.sql.Statement"
level=
"
DEBUG
"
/>
<logger
name=
"java.sql.PreparedStatement"
level=
"
DEBUG
"
/>
<logger
name=
"org.springframework"
level=
"
DEBUG
"
/>
<logger
name=
"com.apache.ibatis"
level=
"
INFO
"
/>
<logger
name=
"org.mybatis"
level=
"
INFO
"
/>
<logger
name=
"java.sql.Connection"
level=
"
INFO
"
/>
<logger
name=
"java.sql.Statement"
level=
"
INFO
"
/>
<logger
name=
"java.sql.PreparedStatement"
level=
"
INFO
"
/>
<logger
name=
"org.springframework"
level=
"
INFO
"
/>
<!-- 日志输出级别 -->
<root
level=
"
DEBUG
"
>
<root
level=
"
INFO
"
>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
...
...
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