Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
58f2f538
Commit
58f2f538
authored
Jul 02, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.报检规则3.0优化增加开关可控制是否启用报检规则
2.代码优化
parent
01fb0bc7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
568 additions
and
188 deletions
+568
-188
CategoryEnum.java
...yeejoin/amos/boot/module/jyjc/api/enums/CategoryEnum.java
+1
-1
JYJCTypeEnum.java
...yeejoin/amos/boot/module/jyjc/api/enums/JYJCTypeEnum.java
+8
-7
InspectionEquipInfoModel.java
.../boot/module/jyjc/api/model/InspectionEquipInfoModel.java
+3
-0
RuleActionHandler.java
...n/amos/boot/module/jyjc/biz/action/RuleActionHandler.java
+13
-27
InspectionRuleEnableConfig.java
...ot/module/jyjc/biz/config/InspectionRuleEnableConfig.java
+61
-0
InspectionOrgRefreshEvent.java
...boot/module/jyjc/biz/event/InspectionOrgRefreshEvent.java
+25
-0
TouchRuleEvent.java
...ejoin/amos/boot/module/jyjc/biz/event/TouchRuleEvent.java
+24
-0
DisableRuleDataPreparationListener.java
...iz/event/listener/DisableRuleDataPreparationListener.java
+93
-0
EnableRuleDataPreparationListener.java
...biz/event/listener/EnableRuleDataPreparationListener.java
+206
-0
TouchRuleEventListener.java
...odule/jyjc/biz/event/listener/TouchRuleEventListener.java
+68
-0
InspectionOrgRefreshListener.java
...odule/jyjc/biz/listener/InspectionOrgRefreshListener.java
+15
-145
RuleCommonServiceImpl.java
...t/module/jyjc/biz/service/impl/RuleCommonServiceImpl.java
+39
-2
application-dev.properties
...le-jyjc-biz/src/main/resources/application-dev.properties
+11
-2
TzBaseEnterpriseInfoMapper.xml
.../src/main/resources/mapper/TzBaseEnterpriseInfoMapper.xml
+1
-4
No files found.
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/enums/CategoryEnum.java
View file @
58f2f538
...
...
@@ -13,7 +13,7 @@ import java.util.Set;
@Getter
@AllArgsConstructor
public
enum
CategoryEnum
{
DETECTION
(
"detection"
,
JYJCTypeEnum
.
AQFJY
,
JYJCTypeEnum
.
DTJC
),
DETECTION
(
"detection"
,
JYJCTypeEnum
.
DTJC
),
FIRST_INSPECTION
(
"firstinspect"
,
JYJCTypeEnum
.
DQJY
,
JYJCTypeEnum
.
SCJY
),
SUPERVISE
(
"supervise"
,
JYJCTypeEnum
.
WXJDJY
,
JYJCTypeEnum
.
GZJDJY
,
JYJCTypeEnum
.
AZJDJY
);
...
...
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/enums/JYJCTypeEnum.java
View file @
58f2f538
...
...
@@ -14,17 +14,18 @@ public enum JYJCTypeEnum {
/**
* 检验检测类型
*/
AQFJY
(
"AQFJY"
,
"安全阀校验"
),
DTJC
(
"DTJC"
,
"电梯检测"
),
DQJY
(
"DQJY"
,
"定期检验"
),
SCJY
(
"SCJY"
,
"首次检验"
),
WXJDJY
(
"WXJDJY"
,
"维修监督检验"
),
GZJDJY
(
"GZJDJY"
,
"改造监督检验"
),
AZJDJY
(
"AZJDJY"
,
"安装监督检验"
);
DTJC
(
"DTJC"
,
"电梯检测"
,
"jc"
),
DQJY
(
"DQJY"
,
"定期检验"
,
"jy"
),
SCJY
(
"SCJY"
,
"首次检验"
,
"jy"
),
WXJDJY
(
"WXJDJY"
,
"维修监督检验"
,
"jy"
),
GZJDJY
(
"GZJDJY"
,
"改造监督检验"
,
"jy"
),
AZJDJY
(
"AZJDJY"
,
"安装监督检验"
,
"jy"
);
private
final
String
code
;
private
final
String
name
;
private
final
String
bizType
;
public
static
JYJCTypeEnum
of
(
String
code
)
{
for
(
JYJCTypeEnum
e
:
JYJCTypeEnum
.
values
())
{
if
(
e
.
getCode
().
equals
(
code
))
{
...
...
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/model/InspectionEquipInfoModel.java
View file @
58f2f538
...
...
@@ -22,4 +22,7 @@ public class InspectionEquipInfoModel implements Serializable {
@ApiModelProperty
(
value
=
"申请表主键"
)
private
String
appSeq
;
@ApiModelProperty
(
value
=
"主题,无需上送,由topic解析出来"
)
private
String
componentKey
;
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/action/RuleActionHandler.java
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
action
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.InspectionCompanyType
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.LicenceTypeEnum
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.OpenBizTypeEnum
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.TopicEnum
;
import
com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo
;
import
com.yeejoin.amos.boot.module.jyjc.biz.service.impl.RuleCommonServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseUnitLicence
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseUnitLicenceMapper
;
import
com.yeejoin.amos.component.rule.config.RuleConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
...
...
@@ -21,7 +18,6 @@ import org.redisson.api.RLock;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
...
...
@@ -39,11 +35,11 @@ import java.util.stream.Collectors;
@Slf4j
public
class
RuleActionHandler
{
private
final
EmqKeeper
emqKeeper
;
private
final
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
;
private
final
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
;
private
final
RedissonClient
redissonClient
;
private
RedisUtils
redisUtils
;
private
RuleCommonServiceImpl
ruleCommonService
;
/**
* 省特检院等特殊公司code
...
...
@@ -52,13 +48,15 @@ public class RuleActionHandler {
private
String
specialInspectionCompanyCode
;
public
RuleActionHandler
(
EmqKeeper
emqKeeper
,
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
,
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
,
RedissonClient
redissonClient
,
RedisUtils
redisUtils
)
{
this
.
emqKeeper
=
emqKeeper
;
public
RuleActionHandler
(
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
,
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
,
RedissonClient
redissonClient
,
RedisUtils
redisUtils
,
RuleCommonServiceImpl
ruleCommonService
)
{
this
.
baseUnitLicenceMapper
=
baseUnitLicenceMapper
;
this
.
tzBaseEnterpriseInfoMapper
=
tzBaseEnterpriseInfoMapper
;
this
.
redissonClient
=
redissonClient
;
this
.
redisUtils
=
redisUtils
;
this
.
ruleCommonService
=
ruleCommonService
;
}
/**
...
...
@@ -71,10 +69,10 @@ public class RuleActionHandler {
* @param legalInspectionCodes 法定的检验机构code,多个用逗号分割,检验机构的最大集合-不为空
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、all-全部,默认都是legal-法定,预留需求变更点
* @param isMatchItem 是否需要匹配核准代码:true-匹配; false-不匹配
* @param isMustAccept true-必须处理,false-可不予受理
* @param isMustAccept
true-必须处理,false-可不予受理
*/
public
void
filterInspectionOrgAction
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
Boolean
isMustAccept
)
{
log
.
info
(
"收到首次提交的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{},
法定的检验机构code
: {},是否需要匹配核准代码:{},是否必须处理:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
);
log
.
info
(
"收到首次提交的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{},
检验机构类型
: {},是否需要匹配核准代码:{},是否必须处理:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
);
InspectionEquipInfo
inspectionEquipInfo
=
(
InspectionEquipInfo
)
bizObj
;
// 规则不支持或者的关系消息会重复故去重处理
RLock
lock
=
redissonClient
.
getLock
(
this
.
buildLockKey
(
"filterInspectionOrgAction"
,
inspectionEquipInfo
.
getUuid
()));
...
...
@@ -93,7 +91,7 @@ public class RuleActionHandler {
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
);
// 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测)
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForFirstCommit
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
OpenBizTypeEnum
.
JY
.
getCode
(),
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
);
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
ruleCommonService
.
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
}
catch
(
MqttException
|
InterruptedException
e
)
{
log
.
error
(
"首次提交的检验机构匹配动作执行失败: {}"
,
e
.
getMessage
());
}
finally
{
...
...
@@ -121,17 +119,17 @@ public class RuleActionHandler {
* @param defaultInspectionCode 默认的检验机构code
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、all-全部,默认都是legal-法定,预留需求变更点
* @param legalInspectionCodes 法定的检验机构code,多个用逗号分割,检验机构的最大集合-不为空
* @param isMustAccept true-必须处理,false-可不予受理
* @param isMustAccept
true-必须处理,false-可不予受理
*/
public
void
noAcceptInspectionOrgMatchAction
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
String
legalInspectionCodes
,
Boolean
isMustAccept
)
{
log
.
info
(
"收到不予受理的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{},
法定的检验机构code
: {},是否需要匹配核准代码:{},是否必须处理:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
);
log
.
info
(
"收到不予受理的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{},
检验机构类型
: {},是否需要匹配核准代码:{},是否必须处理:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
);
InspectionEquipInfo
inspectionEquipInfo
=
(
InspectionEquipInfo
)
bizObj
;
try
{
// 1.获取所有的符合资质条件的单位许可信息
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
);
// 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测)
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForNoAccept
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
OpenBizTypeEnum
.
JY
.
getCode
(),
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMustAccept
);
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
ruleCommonService
.
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
}
catch
(
MqttException
e
)
{
log
.
error
(
"Error publishing MQTT message: {}"
,
e
.
getMessage
());
}
...
...
@@ -218,21 +216,9 @@ public class RuleActionHandler {
}
private
void
setIsCanNoAccept
(
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
,
Boolean
isCanNoAccept
)
{
matchEnterpriseInfos
.
forEach
(
m
->
{
m
.
setUseCodeAndName
(
m
.
getUseCode
()
+
"_"
+
isCanNoAccept
);
});
matchEnterpriseInfos
.
forEach
(
m
->
m
.
setUseCodeAndName
(
m
.
getUseCode
()
+
"_"
+
isCanNoAccept
));
}
private
void
publishMqttMessage
(
String
componentKey
,
Object
message
)
throws
MqttException
{
log
.
info
(
"报检规则推送到web主题:{}:,消息内容为:{}"
,
String
.
format
(
TopicEnum
.
INSPECTION_LIST_PUSH
.
getTopic
(),
componentKey
),
JSON
.
toJSONString
(
message
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
String
.
format
(
TopicEnum
.
INSPECTION_LIST_PUSH
.
getTopic
(),
componentKey
),
JSON
.
toJSONString
(
message
).
getBytes
(),
RuleConfig
.
DEFAULT_QOS
,
false
);
}
catch
(
MqttException
e
)
{
log
.
error
(
"Error publishing MQTT message: {}"
,
e
.
getMessage
());
throw
e
;
}
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/config/InspectionRuleEnableConfig.java
0 → 100644
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Field
;
/**
* 各检验检测类型是否启用规则,默认不启用
* @author Administrator
*/
@Component
@ConfigurationProperties
(
prefix
=
"inspection.rule.enabled"
)
@Data
public
class
InspectionRuleEnableConfig
{
/**
* 定期检验是否启用规则:true-启用,false-不启用
*/
private
Boolean
DQJY
;
/**
* 首次检验是否启用规则:true-启用,false-不启用
*/
private
Boolean
SCJY
;
/**
* 维修监督检验是否启用规则:true-启用,false-不启用
*/
private
Boolean
WXJDJY
;
/**
* 改造监督检验是否启用规则:true-启用,false-不启用
*/
private
Boolean
GZJDJY
;
/**
* 安装监督检验是否启用规则:true-启用,false-不启用
*/
private
Boolean
AZJDJY
;
/**
* 电梯检测是否启用规则:true-启用,false-不启用
*/
private
Boolean
DTJC
;
public
Object
getValueByFieldName
(
String
fieldName
){
Field
field
=
null
;
try
{
field
=
this
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
return
field
.
get
(
this
);
}
catch
(
NoSuchFieldException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
}
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/event/InspectionOrgRefreshEvent.java
0 → 100644
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
event
;
import
com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel
;
import
lombok.Getter
;
import
org.springframework.context.ApplicationEvent
;
/**
* @author Administrator
*/
@Getter
public
class
InspectionOrgRefreshEvent
extends
ApplicationEvent
{
private
InspectionEquipInfoModel
inspectionEquipInfoModel
;
/**
* Create a new {@code ApplicationEvent}.
*
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
*/
public
InspectionOrgRefreshEvent
(
Object
source
,
InspectionEquipInfoModel
inspectionEquipInfoModel
)
{
super
(
source
);
this
.
inspectionEquipInfoModel
=
inspectionEquipInfoModel
;
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/event/TouchRuleEvent.java
0 → 100644
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
event
;
import
com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo
;
import
lombok.Getter
;
import
org.springframework.context.ApplicationEvent
;
/**
* @author Administrator
*/
@Getter
public
class
TouchRuleEvent
extends
ApplicationEvent
{
private
InspectionEquipInfo
inspectionEquipInfo
;
/**
* Create a new {@code ApplicationEvent}.
*
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
*/
public
TouchRuleEvent
(
Object
source
,
InspectionEquipInfo
inspectionEquipInfo
)
{
super
(
source
);
this
.
inspectionEquipInfo
=
inspectionEquipInfo
;
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/event/listener/DisableRuleDataPreparationListener.java
0 → 100644
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
event
.
listener
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.JYJCTypeEnum
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.OpenBizTypeEnum
;
import
com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel
;
import
com.yeejoin.amos.boot.module.jyjc.biz.config.InspectionRuleEnableConfig
;
import
com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionOrgRefreshEvent
;
import
com.yeejoin.amos.boot.module.jyjc.biz.service.impl.RuleCommonServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* 不启用规则时,业务处理
* @author Administrator
*/
@Component
@Slf4j
public
class
DisableRuleDataPreparationListener
implements
ApplicationListener
<
InspectionOrgRefreshEvent
>
{
private
InspectionRuleEnableConfig
inspectionRuleEnableConfig
;
private
RuleCommonServiceImpl
ruleCommonService
;
private
RedisUtils
redisUtils
;
public
DisableRuleDataPreparationListener
(
InspectionRuleEnableConfig
inspectionRuleEnableConfig
,
RuleCommonServiceImpl
ruleCommonService
,
RedisUtils
redisUtils
)
{
this
.
inspectionRuleEnableConfig
=
inspectionRuleEnableConfig
;
this
.
ruleCommonService
=
ruleCommonService
;
this
.
redisUtils
=
redisUtils
;
}
@Override
public
void
onApplicationEvent
(
InspectionOrgRefreshEvent
event
)
{
InspectionEquipInfoModel
equipInfoModel
=
event
.
getInspectionEquipInfoModel
();
String
componentKey
=
equipInfoModel
.
getComponentKey
();
// 规则不启用时业务处理
if
(!
this
.
getEnableConfig
(
equipInfoModel
.
getInspectionType
()))
{
log
.
warn
(
"检验类型:{},未启用规则,将返回全部数据"
,
equipInfoModel
.
getInspectionType
());
this
.
responseForPublisher
(
componentKey
,
this
.
getAllInspectionOrgList
(
equipInfoModel
));
}
}
/**
* 按照检验类型判断是否启用, 不配置时默认不启用
*
* @param inspectionType 检验类型枚举 @see JYJCTypeEnum
* @return true-启用规则,false-不启用
*/
private
boolean
getEnableConfig
(
String
inspectionType
)
{
return
inspectionRuleEnableConfig
.
getValueByFieldName
(
inspectionType
)
==
null
?
false
:
(
Boolean
)
inspectionRuleEnableConfig
.
getValueByFieldName
(
inspectionType
);
}
private
void
responseForPublisher
(
String
componentKey
,
List
<
TzBaseEnterpriseInfoDto
>
allInspectionOrgList
)
{
try
{
ruleCommonService
.
publishMqttMessage
(
componentKey
,
allInspectionOrgList
);
}
catch
(
MqttException
e
)
{
log
.
error
(
"规则不启用时,推送订阅者全部检验检测或者检验机构时失败:{}"
,
e
.
getMessage
());
}
}
private
List
<
TzBaseEnterpriseInfoDto
>
getAllInspectionOrgList
(
InspectionEquipInfoModel
equipInfoModel
)
{
// 提升性能,数据缓存1分钟
String
redisKey
=
this
.
getInspectionOrgListRedisKey
(
equipInfoModel
.
getInspectionType
());
if
(
redisUtils
.
hasKey
(
redisKey
))
{
return
(
List
<
TzBaseEnterpriseInfoDto
>)
redisUtils
.
get
(
redisKey
);
}
else
{
List
<
TzBaseEnterpriseInfoDto
>
allInspectionOrgList
=
ruleCommonService
.
getInspectionUnitList
(
this
.
getBizTypeByInspectionType
(
equipInfoModel
.
getInspectionType
()));
// 设置为必须处理,前端不再显示《不予处理》按钮
ruleCommonService
.
setIsCanNoAccept
(
allInspectionOrgList
,
true
);
// 将对象直接存储到缓存,避免 JSON 序列化和反序列化
redisUtils
.
set
(
redisKey
,
allInspectionOrgList
,
60
);
return
allInspectionOrgList
;
}
}
private
String
getInspectionOrgListRedisKey
(
String
inspectionType
)
{
return
String
.
format
(
"%s:%s"
,
"inspection.rule.org.data"
,
inspectionType
);
}
private
String
getBizTypeByInspectionType
(
String
inspectionType
)
{
JYJCTypeEnum
jyjcTypeEnum
=
JYJCTypeEnum
.
of
(
inspectionType
);
if
(
jyjcTypeEnum
!=
null
)
{
return
jyjcTypeEnum
.
getBizType
();
}
return
OpenBizTypeEnum
.
JY
.
getCode
();
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/event/listener/EnableRuleDataPreparationListener.java
0 → 100644
View file @
58f2f538
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/event/listener/TouchRuleEventListener.java
0 → 100644
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
event
.
listener
;
import
com.yeejoin.amos.boot.module.jyjc.biz.event.TouchRuleEvent
;
import
com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
com.yeejoin.amos.feign.rule.Rule
;
import
com.yeejoin.amos.feign.rule.model.FactBaseModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
static
com
.
alibaba
.
fastjson
.
JSON
.
toJSONString
;
/**
* @author Administrator
*/
@Component
@Slf4j
public
class
TouchRuleEventListener
implements
ApplicationListener
<
TouchRuleEvent
>
{
private
AmosRequestContext
amosRequestContext
;
@Value
(
"${inspection.rule.project-name:报检规则}"
)
private
String
ruleName
;
public
TouchRuleEventListener
(
AmosRequestContext
amosRequestContext
)
{
this
.
amosRequestContext
=
amosRequestContext
;
}
@Override
public
void
onApplicationEvent
(
TouchRuleEvent
event
)
{
this
.
touchRuleWithApi
(
event
.
getInspectionEquipInfo
());
}
private
void
touchRuleWithApi
(
InspectionEquipInfo
inspectionEquipInfo
)
{
if
(
log
.
isInfoEnabled
())
{
log
.
info
(
"发送规则的消息对象:{}"
,
toJSONString
(
inspectionEquipInfo
));
}
try
{
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
HashMap
<
String
,
byte
[]>
factMap
=
new
HashMap
<>();
List
<
Object
>
factList
=
new
ArrayList
<>();
factList
.
add
(
inspectionEquipInfo
);
for
(
Object
fact
:
factList
)
{
factMap
.
put
(
fact
.
getClass
().
getName
(),
toJSONString
(
fact
).
getBytes
());
}
FactBaseModel
factBaseModel
=
new
FactBaseModel
();
factBaseModel
.
setFactMap
(
factMap
);
factBaseModel
.
setPackageId
(
ruleName
+
"/"
+
inspectionEquipInfo
.
getBizType
());
factBaseModel
.
setProcessIds
(
null
);
if
(
log
.
isInfoEnabled
())
{
log
.
info
(
"发送规则的消息对象:{},\n变量对象:{}"
,
toJSONString
(
factBaseModel
),
toJSONString
(
factBaseModel
));
}
Rule
.
ruleClient
.
fireRule
(
factBaseModel
);
}
catch
(
Exception
e
)
{
log
.
error
(
"调用规则触发获取报检规则失败"
,
e
);
}
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/listener/InspectionOrgRefreshListener.java
View file @
58f2f538
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/service/impl/RuleCommonServiceImpl.java
View file @
58f2f538
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.sun.org.apache.regexp.internal.RE
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.TopicEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.UseInfoMapper
;
import
com.yeejoin.amos.component.rule.config.RuleConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @author Administrator
*/
@Component
@Slf4j
public
class
RuleCommonServiceImpl
{
private
UseInfoMapper
useInfoMapper
;
private
TzBaseEnterpriseInfoMapper
enterpriseInfoMapper
;
private
final
EmqKeeper
emqKeeper
;
/**
* 特殊独立的区县
*/
private
static
final
String
[]
EXCLUSION_CITY_REGIONS
=
{
"610403"
,
"610581"
};
public
RuleCommonServiceImpl
(
UseInfoMapper
useInfoMapper
)
{
public
RuleCommonServiceImpl
(
UseInfoMapper
useInfoMapper
,
TzBaseEnterpriseInfoMapper
enterpriseInfoMapper
,
EmqKeeper
emqKeeper
)
{
this
.
useInfoMapper
=
useInfoMapper
;
this
.
enterpriseInfoMapper
=
enterpriseInfoMapper
;
this
.
emqKeeper
=
emqKeeper
;
}
public
String
getArea
(
String
record
)
{
String
getArea
(
String
record
)
{
UseInfo
equipUseInfo
=
useInfoMapper
.
selectOne
(
Wrappers
.<
UseInfo
>
lambdaQuery
().
select
(
UseInfo:
:
getCity
,
UseInfo:
:
getCounty
).
eq
(
UseInfo:
:
getRecord
,
record
));
if
(
equipUseInfo
==
null
)
{
return
""
;
...
...
@@ -68,4 +84,25 @@ public class RuleCommonServiceImpl {
return
equipUseInfo
.
getCounty
();
}
public
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitList
(
String
openBizType
)
{
return
enterpriseInfoMapper
.
getInspectionUnitList
(
openBizType
);
}
public
void
publishMqttMessage
(
String
componentKey
,
Object
message
)
throws
MqttException
{
log
.
info
(
"报检规则推送到web主题:{}:,消息内容为:{}"
,
String
.
format
(
TopicEnum
.
INSPECTION_LIST_PUSH
.
getTopic
(),
componentKey
),
JSON
.
toJSONString
(
message
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
String
.
format
(
TopicEnum
.
INSPECTION_LIST_PUSH
.
getTopic
(),
componentKey
),
JSON
.
toJSONString
(
message
).
getBytes
(),
RuleConfig
.
DEFAULT_QOS
,
false
);
}
catch
(
MqttException
e
)
{
log
.
error
(
"Error publishing MQTT message: {}"
,
e
.
getMessage
());
throw
e
;
}
}
public
void
setIsCanNoAccept
(
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
,
Boolean
isCanNoAccept
)
{
matchEnterpriseInfos
.
forEach
(
m
->
{
m
.
setUseCodeAndName
(
m
.
getUseCode
()
+
"_"
+
isCanNoAccept
);
});
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/resources/application-dev.properties
View file @
58f2f538
...
...
@@ -58,4 +58,13 @@ rule.definition.local-ip=172.16.3.20
spring.kafka.bootstrap-servers
=
172.16.10.243:9092
spring.kafka.security.protocol
=
SASL_PLAINTEXT
spring.kafka.properties.sasl.mechanism
=
PLAIN
\ No newline at end of file
spring.kafka.properties.sasl.mechanism
=
PLAIN
#定期检验是否启用规则:true-启用,false-不启用
inspection.rule.enabled.DQJY
=
true
#安装监督检验是否启用规则:true-启用,false-不启用
inspection.rule.enabled.AZJDJY
=
true
#改造监督检验是否启用规则:true-启用,false-不启用
inspection.rule.enabled.GZJDJY
=
true
#维修监督检验是否启用规则:true-启用,false-不启用
inspection.rule.enabled.WXJDJY
=
true
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/resources/mapper/TzBaseEnterpriseInfoMapper.xml
View file @
58f2f538
...
...
@@ -177,9 +177,7 @@
info.sequence_nbr,
info.use_code,
info.use_unit,
concat(info.use_code,'_',info.use_unit) as useCodeAndName,
info.use_contact,
info.contact_phone
concat(info.use_code,'_',info.use_unit) as useCodeAndName
FROM
tz_base_enterprise_info info
INNER JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
...
...
@@ -194,7 +192,6 @@
<if
test=
"city != null and city != ''"
>
and tjoa.detection_region like concat('%',#{city},'%')
</if>
group by info.use_code
</select>
<select
id=
"selectBySeq"
resultType=
"com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo"
>
select * from tz_base_enterprise_info where sequence_nbr = #{sequenceNbr}
...
...
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