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
188135de
Commit
188135de
authored
Sep 03, 2025
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refeat(jyjc): 报检规则4.0开发
1.报检规则接口 2.3库类型数据变动消息处理器调整为观察者模式并调整流水
parent
9f86b7c3
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
338 additions
and
264 deletions
+338
-264
JyjcInspectionApplicationDto.java
...mos/boot/biz/common/dto/JyjcInspectionApplicationDto.java
+6
-0
TzsDataRefreshMessageDto.java
.../boot/module/common/api/dto/TzsDataRefreshMessageDto.java
+9
-1
TzsDataRefreshMessage.java
.../boot/module/common/api/entity/TzsDataRefreshMessage.java
+17
-0
JyAgencyClassifyEnum.java
...os/boot/module/common/api/enums/JyAgencyClassifyEnum.java
+25
-0
IDataRefreshDispatch.java
.../boot/module/common/api/service/IDataRefreshDispatch.java
+1
-1
DataRefreshDispatcher.java
...le/common/biz/refresh/dispatch/DataRefreshDispatcher.java
+24
-15
RefreshHandlerFactory.java
...ule/common/biz/refresh/factory/RefreshHandlerFactory.java
+4
-10
DataRefreshListener.java
...dule/common/biz/refresh/listener/DataRefreshListener.java
+9
-5
JyjcInspectionApplication.java
...oot/module/jyjc/api/entity/JyjcInspectionApplication.java
+11
-0
InspectionCompanyType.java
...mos/boot/module/jyjc/api/enums/InspectionCompanyType.java
+3
-2
OpenBizTypeEnumV2.java
...in/amos/boot/module/jyjc/api/enums/OpenBizTypeEnumV2.java
+3
-3
JyjcOpeningApplicationMapper.java
.../module/jyjc/api/mapper/JyjcOpeningApplicationMapper.java
+14
-0
InspectionEquipInfoModel.java
.../boot/module/jyjc/api/model/InspectionEquipInfoModel.java
+4
-1
JyjcInspectionApplicationModel.java
...module/jyjc/api/model/JyjcInspectionApplicationModel.java
+7
-0
JyjcOpeningApplicationMapper.xml
...rc/main/resources/mapper/JyjcOpeningApplicationMapper.xml
+30
-0
RuleActionHandler.java
...n/amos/boot/module/jyjc/biz/action/RuleActionHandler.java
+117
-215
EnableRuleDataPreparationService.java
.../event/rule/service/EnableRuleDataPreparationService.java
+26
-6
InspectionEquipInfo.java
...n/amos/boot/module/jyjc/biz/rule/InspectionEquipInfo.java
+6
-0
JyjcOpeningApplicationServiceImpl.java
...c/biz/service/impl/JyjcOpeningApplicationServiceImpl.java
+1
-1
TzBaseEnterpriseInfoMapper.java
...oot/module/ymt/api/mapper/TzBaseEnterpriseInfoMapper.java
+7
-0
TzBaseEnterpriseInfoMapper.xml
.../src/main/resources/mapper/TzBaseEnterpriseInfoMapper.xml
+14
-4
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/dto/JyjcInspectionApplicationDto.java
View file @
188135de
...
...
@@ -177,6 +177,12 @@ public class JyjcInspectionApplicationDto extends BaseModel {
@ApiModelProperty
(
value
=
"区县"
)
private
String
county
;
@ApiModelProperty
(
value
=
"电梯检测的维保单位(电梯检测批量报检使用)"
)
private
String
maintenanceUnitCode
;
@ApiModelProperty
(
value
=
"设备分类,大型游乐设施使用"
)
private
String
equipTag1
;
public
String
getProcessInstanceId
()
{
return
this
.
instanceId
!=
null
?
this
.
instanceId
:
this
.
processInstanceId
;
}
...
...
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/TzsDataRefreshMessageDto.java
View file @
188135de
...
...
@@ -17,7 +17,6 @@ public class TzsDataRefreshMessageDto extends BaseDto {
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"业务数据ID"
)
private
String
dataId
;
...
...
@@ -33,4 +32,13 @@ public class TzsDataRefreshMessageDto extends BaseDto {
@ApiModelProperty
(
value
=
"错误描述"
)
private
String
errorMsg
;
@ApiModelProperty
(
value
=
"成功处理的处理器类名"
)
private
String
successDistributionHandler
;
@ApiModelProperty
(
value
=
"总分发次数"
)
private
Integer
distributions
;
@ApiModelProperty
(
value
=
"分发失败次数"
)
private
Integer
failedDistributions
;
}
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/entity/TzsDataRefreshMessage.java
View file @
188135de
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.common.api.entity;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
...
...
@@ -51,4 +52,20 @@ public class TzsDataRefreshMessage extends BaseEntity {
*/
@TableField
(
"error_msg"
)
private
String
errorMsg
;
/**
* 分发次数
*/
@TableField
(
"distributions"
)
private
Integer
distributions
;
/**
* 分发失败次数
*/
@TableField
(
"failed_distributions"
)
private
Integer
failedDistributions
;
@ApiModelProperty
(
value
=
"成功处理的处理器类名"
)
@TableField
(
"success_distribution_handler"
)
private
String
successDistributionHandler
;
}
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/enums/JyAgencyClassifyEnum.java
0 → 100644
View file @
188135de
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
@AllArgsConstructor
@Getter
public
enum
JyAgencyClassifyEnum
{
/**
* 机构分类
*/
ZJJG
(
"自检机构(丙类)"
,
"JYJGFL_ZJJG"
),
SBGY
(
"省内公益机构"
,
"JYJGFL_SBGY"
),
SBDSF
(
"省内第三方机构"
,
"JYJGFL_SBDSF"
),
SWGY
(
"省外公益机构"
,
"JYJGFL_SWGY"
),
SWDSF
(
"省外第三方机构"
,
"JYJGFL_SWDSF"
);
private
final
String
name
;
private
final
String
code
;
}
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/service/IDataRefreshDispatch.java
View file @
188135de
...
...
@@ -6,5 +6,5 @@ import java.util.List;
public
interface
IDataRefreshDispatch
{
void
doDispatch
(
String
dataType
,
List
<
TzsDataRefreshMessage
>
messages
);
void
doDispatch
(
List
<
IDataRefreshHandler
>
dataRefreshHandlers
,
List
<
TzsDataRefreshMessage
>
messages
);
}
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/refresh/dispatch/DataRefreshDispatcher.java
View file @
188135de
...
...
@@ -3,11 +3,10 @@ package com.yeejoin.amos.boot.module.common.biz.refresh.dispatch;
import
com.yeejoin.amos.boot.module.common.api.entity.TzsDataRefreshMessage
;
import
com.yeejoin.amos.boot.module.common.api.service.IDataRefreshDispatch
;
import
com.yeejoin.amos.boot.module.common.api.service.IDataRefreshHandler
;
import
com.yeejoin.amos.boot.module.common.biz.constats.Constants
;
import
com.yeejoin.amos.boot.module.common.biz.refresh.factory.RefreshHandlerFactory
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.TzsDataRefreshMessageServiceImpl
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
...
...
@@ -19,35 +18,45 @@ import java.util.List;
@Slf4j
public
class
DataRefreshDispatcher
implements
IDataRefreshDispatch
{
private
final
RefreshHandlerFactory
refreshHandlerFactory
;
private
final
TzsDataRefreshMessageServiceImpl
refreshMessageService
;
@Override
@Async
public
void
doDispatch
(
String
dataType
,
List
<
TzsDataRefreshMessage
>
messages
)
{
IDataRefreshHandler
dataRefreshHandler
=
refreshHandlerFactory
.
getRefreshHandler
(
dataType
);
public
void
doDispatch
(
List
<
IDataRefreshHandler
>
dataRefreshHandlers
,
List
<
TzsDataRefreshMessage
>
messages
)
{
int
total
=
dataRefreshHandlers
.
size
();
dataRefreshHandlers
.
forEach
(
dataRefreshHandler
->
{
messages
.
forEach
(
message
->
{
try
{
message
.
setDistributions
(
total
);
dataRefreshHandler
.
doRefresh
(
message
);
markRefreshSuccess
(
message
);
markRefreshSuccess
(
message
,
dataRefreshHandler
);
}
catch
(
Exception
e
)
{
log
.
error
(
"三库数据刷新执行失败,消息内容:{}, 错误日志:{}"
,
message
,
e
.
getMessage
(),
e
);
message
.
setErrorMsg
(
e
.
getMessage
());
markRefreshFailure
(
message
);
log
.
error
(
"企业、设备、人员,总线分发处理变更数据失败,消息内容:{}, 错误日志:{}"
,
message
,
e
.
getMessage
(),
e
);
markRefreshFailure
(
message
,
dataRefreshHandler
,
e
);
}
});
});
}
private
static
String
buildErrorMsg
(
IDataRefreshHandler
dataRefreshHandler
,
TzsDataRefreshMessage
message
,
Exception
e
)
{
return
StringUtils
.
isEmpty
(
message
.
getErrorMsg
())
?
dataRefreshHandler
.
getClass
().
getSimpleName
()
+
"@"
+
e
.
getMessage
()
:
message
.
getErrorMsg
()
+
";"
+
dataRefreshHandler
.
getClass
().
getSimpleName
()
+
"@"
+
e
.
getMessage
();
}
private
void
markRefreshSuccess
(
TzsDataRefreshMessage
message
)
{
updateMessageStatus
(
message
,
Constants
.
REFRESH_STATUS_SUCCESS
);
private
void
markRefreshSuccess
(
TzsDataRefreshMessage
message
,
IDataRefreshHandler
dataRefreshHandler
)
{
message
.
setSuccessDistributionHandler
(
message
.
getSuccessDistributionHandler
()
==
null
?
dataRefreshHandler
.
getClass
().
getSimpleName
()
:
message
.
getSuccessDistributionHandler
()
+
";"
+
dataRefreshHandler
.
getClass
().
getSimpleName
());
updateMessageStatus
(
message
);
}
private
void
markRefreshFailure
(
TzsDataRefreshMessage
message
)
{
updateMessageStatus
(
message
,
Constants
.
REFRESH_STATUS_FAILURE
);
private
void
markRefreshFailure
(
TzsDataRefreshMessage
message
,
IDataRefreshHandler
dataRefreshHandler
,
Exception
e
)
{
message
.
setErrorMsg
(
buildErrorMsg
(
dataRefreshHandler
,
message
,
e
));
message
.
setFailedDistributions
(
message
.
getFailedDistributions
()
==
null
?
1
:
message
.
getFailedDistributions
()
+
1
);
updateMessageStatus
(
message
);
}
private
void
updateMessageStatus
(
TzsDataRefreshMessage
message
,
Integer
status
)
{
message
.
setStatus
(
status
);
private
void
updateMessageStatus
(
TzsDataRefreshMessage
message
)
{
message
.
setRecDate
(
new
Date
());
refreshMessageService
.
saveOrUpdate
(
message
);
}
...
...
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/refresh/factory/RefreshHandlerFactory.java
View file @
188135de
...
...
@@ -8,24 +8,18 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
@Component
@RequiredArgsConstructor
public
class
RefreshHandlerFactory
{
private
final
List
<
IDataRefreshHandler
>
handlers
;
private
final
Map
<
String
,
IDataRefreshHandler
>
handlerMap
=
new
ConcurrentHashMap
<>();
private
final
Map
<
String
,
List
<
IDataRefreshHandler
>
>
handlerMap
=
new
ConcurrentHashMap
<>();
public
IDataRefreshHandler
getRefreshHandler
(
String
dataType
)
{
return
handlerMap
.
computeIfAbsent
(
dataType
,
(
k
)
->
{
for
(
IDataRefreshHandler
handler
:
handlers
)
{
if
(
handler
.
supportType
().
equals
(
dataType
))
{
return
handler
;
}
}
throw
new
BadRequest
(
"not found refresh handler for "
+
dataType
);
});
public
List
<
IDataRefreshHandler
>
getRefreshHandler
(
String
dataType
)
{
return
handlerMap
.
computeIfAbsent
(
dataType
,
(
k
)
->
handlers
.
stream
().
filter
(
handler
->
handler
.
supportType
().
equals
(
dataType
)).
collect
(
Collectors
.
toList
()));
}
}
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/refresh/listener/DataRefreshListener.java
View file @
188135de
...
...
@@ -3,12 +3,13 @@ package com.yeejoin.amos.boot.module.common.biz.refresh.listener;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.common.api.entity.TzsDataRefreshMessage
;
import
com.yeejoin.amos.boot.module.common.api.service.IDataRefreshDispatch
;
import
com.yeejoin.amos.boot.module.common.api.service.IDataRefreshHandler
;
import
com.yeejoin.amos.boot.module.common.biz.constats.Constants
;
import
com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent
;
import
com.yeejoin.amos.boot.module.common.biz.refresh.factory.RefreshHandlerFactory
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.TzsDataRefreshMessageServiceImpl
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
...
...
@@ -18,7 +19,6 @@ import javax.annotation.PostConstruct;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
...
...
@@ -38,8 +38,9 @@ public class DataRefreshListener {
private
ExecutorService
executorService
;
@Autowired
private
Optional
<
IDataRefreshDispatch
>
dataRefreshService
;
private
final
IDataRefreshDispatch
dataRefreshService
;
private
final
RefreshHandlerFactory
refreshHandlerFactory
;
private
final
TzsDataRefreshMessageServiceImpl
tzsDataRefreshMessageService
;
...
...
@@ -69,10 +70,13 @@ public class DataRefreshListener {
private
void
processEvent
(
DataRefreshEvent
event
)
{
List
<
IDataRefreshHandler
>
handlers
=
refreshHandlerFactory
.
getRefreshHandler
(
event
.
getDataType
());
if
(!
handlers
.
isEmpty
())
{
// 1.记录 message
List
<
TzsDataRefreshMessage
>
messages
=
createMsg
(
event
);
// 2.调用更新处理-异步
dataRefreshService
.
ifPresent
(
service
->
service
.
doDispatch
(
event
.
getDataType
(),
messages
));
dataRefreshService
.
doDispatch
(
handlers
,
messages
);
}
}
public
List
<
TzsDataRefreshMessage
>
createMsg
(
DataRefreshEvent
event
)
{
...
...
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/entity/JyjcInspectionApplication.java
View file @
188135de
...
...
@@ -269,4 +269,15 @@ public class JyjcInspectionApplication extends BaseEntity {
@TableField
(
"plan_inspection_date"
)
private
LocalDate
planInspectionDate
;
/**
* 电梯检测的维保单位(电梯检测批量报检使用)
*/
@TableField
(
value
=
"maintenance_unit_code"
)
private
String
maintenanceUnitCode
;
/**
* 设备分类,大型游乐设施使用
*/
@TableField
(
value
=
"equip_tag1"
)
private
String
equipTag1
;
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/enums/InspectionCompanyType.java
View file @
188135de
...
...
@@ -15,8 +15,9 @@ public enum InspectionCompanyType {
*/
LEGAL
(
"legal"
,
"法定"
),
THIRD
(
"third"
,
"第3方"
),
DESIGNATED
(
"designated"
,
"定向单位"
),
ALL
(
"all"
,
"全部机构"
);
private
String
code
;
private
String
name
;
private
final
String
code
;
private
final
String
name
;
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/enums/OpenBizTypeEnumV2.java
View file @
188135de
...
...
@@ -21,12 +21,12 @@ public enum OpenBizTypeEnumV2 {
private
String
code
;
private
String
unitType
;
private
final
String
unitType
;
private
String
description
;
private
final
String
description
;
private
OpenBizTypeEnumV2
(
String
code
,
String
unitType
,
String
description
)
{
OpenBizTypeEnumV2
(
String
code
,
String
unitType
,
String
description
)
{
this
.
code
=
code
;
this
.
unitType
=
unitType
;
this
.
description
=
description
;
...
...
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/mapper/JyjcOpeningApplicationMapper.java
View file @
188135de
...
...
@@ -43,4 +43,18 @@ public interface JyjcOpeningApplicationMapper extends BaseMapper<JyjcOpeningAppl
List
<
InspectionCompanyPublicityDto
>
queryInspectionOrgListForBiz
();
List
<
JyjcOpeningApplicationVo
>
queryJyjcOpeningApplicationListByIds
(
List
<
String
>
ids
);
/**
* 查询指定机构分类的单位code列表集合
* @param agencyClassifies 机构分类
* @return 单位code列表集合
*/
List
<
String
>
selectUnitCodeListByAgencyClassify
(
@Param
(
"agencyClassifies"
)
List
<
String
>
agencyClassifies
);
/**
* 查询电梯检测的自检机构
* @param appSeq 申请表主键
* @return 发起单位自检机构 + 维保单位
*/
List
<
String
>
selectSelfDetectionUnitList
(
@Param
(
"appSeq"
)
Long
appSeq
);
}
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 @
188135de
...
...
@@ -38,9 +38,12 @@ public class InspectionEquipInfoModel implements Serializable {
@ApiModelProperty
(
value
=
"区县"
)
private
String
county
;
@ApiModelProperty
(
value
=
"主题
,
无需上送,由topic解析出来"
)
@ApiModelProperty
(
value
=
"主题
,
无需上送,由topic解析出来"
)
private
String
componentKey
;
@ApiModelProperty
(
value
=
"申请报检单位信用代码"
)
private
String
unitCode
;
@ApiModelProperty
(
value
=
"设备分类,大型游乐设施使用"
)
private
String
equipTag1
;
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/java/com/yeejoin/amos/boot/module/jyjc/api/model/JyjcInspectionApplicationModel.java
View file @
188135de
...
...
@@ -205,6 +205,13 @@ public class JyjcInspectionApplicationModel extends BaseModel {
@ApiModelProperty
(
value
=
"装置id"
)
private
String
projectContraptionId
;
@ApiModelProperty
(
value
=
"电梯检测的维保单位(电梯检测批量报检使用)"
)
private
String
maintenanceUnitCode
;
@ApiModelProperty
(
value
=
"设备分类,大型游乐设施使用"
)
private
String
equipTag1
;
public
String
getProcessInstanceId
()
{
return
this
.
instanceId
!=
null
?
this
.
instanceId
:
this
.
processInstanceId
;
}
...
...
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-api/src/main/resources/mapper/JyjcOpeningApplicationMapper.xml
View file @
188135de
...
...
@@ -131,4 +131,34 @@
#{id}
</foreach>
</select>
<select
id=
"selectUnitCodeListByAgencyClassify"
resultType=
"java.lang.String"
>
SELECT
distinct unit_code
FROM "tz_jyjc_opening_application"
where
status = '已完成'
and agencyClassify in
<foreach
collection=
"agencyClassifies"
separator=
","
open=
"("
close=
")"
item=
"agencyClassify"
>
#{agencyClassify}
</foreach>
</select>
<select
id=
"selectSelfDetectionUnitList"
resultType=
"java.lang.String"
>
SELECT
unit_code
from
tz_jyjc_opening_application
where
unit_code = (SELECT application_unit_code FROM "tz_jyjc_inspection_application" where sequence_nbr = #{appSeq})
and status = '已完成'
and open_biz_type = 'jc-sydw'
union all
SELECT
unit_code
from
tz_jyjc_opening_application
where
unit_code = (SELECT maintenance_unit_code FROM "tz_jyjc_inspection_application" where sequence_nbr = #{appSeq})
and status = '已完成'
and open_biz_type = 'jc-agw'
</select>
</mapper>
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 @
188135de
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jyjc
.
biz
.
action
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.enums.LicenceStateEnum
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jyjc.api.common.CommonConstants
;
import
com.yeejoin.amos.boot.module.common.api.entity.BaseEnterpriseCert
;
import
com.yeejoin.amos.boot.module.common.api.enums.JyAgencyClassifyEnum
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.BaseEnterpriseCertServiceImpl
;
import
com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationNoAcceptLog
;
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.OpenBizTypeEnumV2
;
import
com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcOpeningApplicationMapper
;
import
com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo
;
import
com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcInspectionApplicationNoAcceptLogServiceImpl
;
import
com.yeejoin.amos.boot.module.jyjc.biz.service.impl.RuleCommonServiceImpl
;
...
...
@@ -14,19 +18,17 @@ 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
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
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.core.rdbms.orm.entity.BaseEntity
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
...
...
@@ -36,69 +38,58 @@ import java.util.stream.Collectors;
*/
@Component
@Slf4j
@RequiredArgsConstructor
public
class
RuleActionHandler
{
private
final
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
;
private
final
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
;
private
final
RedissonClient
redissonClient
;
private
RedisUtils
redisUtils
;
private
RuleCommonServiceImpl
ruleCommonService
;
private
JyjcInspectionApplicationNoAcceptLogServiceImpl
noAcceptLogService
;
private
final
RedisUtils
redisUtils
;
private
final
RuleCommonServiceImpl
ruleCommonService
;
private
final
JyjcInspectionApplicationNoAcceptLogServiceImpl
noAcceptLogService
;
private
final
BaseEnterpriseCertServiceImpl
baseEnterpriseCertService
;
private
final
JyjcOpeningApplicationMapper
openingApplicationMapper
;
/**
* 省特检院等特殊公司code
*/
@Value
(
"${special.inspection.company.code:126100004352004822,12100000400001774F,91340100MA8QN8Q40G}"
)
private
String
specialInspectionCompanyCode
;
public
RuleActionHandler
(
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
,
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
,
RedissonClient
redissonClient
,
RedisUtils
redisUtils
,
RuleCommonServiceImpl
ruleCommonService
,
JyjcInspectionApplicationNoAcceptLogServiceImpl
noAcceptLogService
)
{
this
.
baseUnitLicenceMapper
=
baseUnitLicenceMapper
;
this
.
tzBaseEnterpriseInfoMapper
=
tzBaseEnterpriseInfoMapper
;
this
.
redissonClient
=
redissonClient
;
this
.
redisUtils
=
redisUtils
;
this
.
ruleCommonService
=
ruleCommonService
;
this
.
noAcceptLogService
=
noAcceptLogService
;
}
/**
* 规则回调方法-
首次提交的检验机构匹配
* 规则回调方法-
用户自选首次提交的检验机构匹配,可替换firstInspectionOrgMatchAction,由于规则修改太多,故新增一个
*
* @param bizObj 请求变量参数
* @param itemCode 核对项目编码,多个用逗号分割
* @param isMatchArea 是否进行属地过滤(检验检测机构的开通区域包含设备归属地市),true-过滤,false-不过滤
* @param defaultInspectionCode 默认的检验机构code,多个用逗号分割,
在按照属地匹配不上时,默认的
检验机构
* @param legalInspectionCodes
法定的检验机构code,多个用逗号分割,检验机构的最大集合-不为空
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、all-全部,默认都是legal-法定,预留需求变更点
* @param defaultInspectionCode 默认的检验机构code,多个用逗号分割,
定向规则使用此字段指定
检验机构
* @param legalInspectionCodes
预留机构名单,多个用逗号分割
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、
designated-定向单位、
all-全部,默认都是legal-法定,预留需求变更点
* @param isMatchItem 是否需要匹配核准代码:true-匹配; false-不匹配
* @param isMustAccept true-必须处理,false-可不予受理
* @param orgType jy-检验机构,jc-检测机构
*/
public
void
fi
lterInspectionOrgAction
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
Boolean
isMustAccept
)
{
log
.
info
(
"收到
首次提交的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{}, 检验机构类型: {},是否需要匹配核准代码:{},是否必须处理:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
);
public
void
fi
rstInspectionOrgMatchAction2
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
Boolean
isMustAccept
,
String
orgType
)
{
log
.
info
(
"收到
用户自选首次提交的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 预留检验机构code:{}, 检验机构类型: {},是否需要匹配核准代码:{},是否必须处理:{},检验机构类型:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
,
orgType
);
InspectionEquipInfo
inspectionEquipInfo
=
(
InspectionEquipInfo
)
bizObj
;
// 规则不支持或者的关系消息会重复故去重处理
RLock
lock
=
redissonClient
.
getLock
(
this
.
buildLockKey
(
"fi
lterInspectionOrgAction
"
,
inspectionEquipInfo
.
getUuid
()));
RLock
lock
=
redissonClient
.
getLock
(
this
.
buildLockKey
(
"fi
rstInspectionOrgMatchAction2
"
,
inspectionEquipInfo
.
getUuid
()));
try
{
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
if
(!
isLocked
)
{
log
.
warn
(
"规则回掉重复,消息将丢弃"
);
return
;
}
if
(
redisUtils
.
hasKey
(
this
.
buildRedisDataKey
(
"fi
lterInspectionOrgAction
"
,
inspectionEquipInfo
.
getUuid
())))
{
if
(
redisUtils
.
hasKey
(
this
.
buildRedisDataKey
(
"fi
rstInspectionOrgMatchAction2
"
,
inspectionEquipInfo
.
getUuid
())))
{
log
.
warn
(
"规则回掉重复,消息将丢弃"
);
return
;
}
redisUtils
.
set
(
this
.
buildRedisDataKey
(
"fi
lterInspectionOrgAction
"
,
inspectionEquipInfo
.
getUuid
()),
inspectionEquipInfo
.
getUuid
(),
3600
);
redisUtils
.
set
(
this
.
buildRedisDataKey
(
"fi
rstInspectionOrgMatchAction2
"
,
inspectionEquipInfo
.
getUuid
()),
inspectionEquipInfo
.
getUuid
(),
3600
);
// 1.获取所有的符合资质条件的单位许可信息
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
);
// 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测)
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForLegal
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
OpenBizTypeEnum
.
JY
.
getCode
(),
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
);
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
,
orgType
);
// 2.匹配过滤机构信息,区分检验还是检测
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForFirstCommit2
(
isMatchItem
,
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
orgType
,
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
,
inspectionCompanyType
);
// 3.如果当前机构为符合条件的自检机构则增加上(电梯检测才需要)
this
.
setSelfUnitIfDetection
(
orgType
,
inspectionEquipInfo
,
tzBaseEnterpriseInfoList
,
isMustAccept
);
// todo 4.tzBaseEnterpriseInfoList排序
ruleCommonService
.
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
}
catch
(
MqttException
|
InterruptedException
e
)
{
log
.
error
(
"首次提交的检验机构匹配动作执行失败: {}"
,
e
.
getMessage
());
log
.
error
(
"
用户自选
首次提交的检验机构匹配动作执行失败: {}"
,
e
.
getMessage
());
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
...
...
@@ -106,82 +97,85 @@ public class RuleActionHandler {
}
}
private
String
buildLockKey
(
String
type
,
String
uuid
)
{
return
String
.
format
(
"%s-%s"
,
type
,
uuid
);
private
void
setSelfUnitIfDetection
(
String
orgType
,
InspectionEquipInfo
inspectionEquipInfo
,
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
,
Boolean
isMustAccept
)
{
if
(
OpenBizTypeEnumV2
.
JC
.
getUnitType
().
equals
(
orgType
))
{
List
<
String
>
selfDetectionCodes
=
openingApplicationMapper
.
selectSelfDetectionUnitList
(
Long
.
parseLong
(
inspectionEquipInfo
.
getAppSeq
()));
List
<
TzBaseEnterpriseInfoDto
>
selfDetectionUnits
=
!
selfDetectionCodes
.
isEmpty
()
?
tzBaseEnterpriseInfoMapper
.
queryInspectionUnitListByUseUnitCode
(
selfDetectionCodes
)
:
new
ArrayList
<>();
setIsCanNoAccept
(
selfDetectionUnits
,
isMustAccept
);
tzBaseEnterpriseInfoList
.
addAll
(
selfDetectionUnits
);
}
private
String
buildRedisDataKey
(
String
type
,
String
uuid
)
{
return
String
.
format
(
"RECEIVED-UUID-RULE:%s-%s"
,
type
,
uuid
);
}
/**
* 规则回调方法-不予受理的检验机构匹配
* 规则回调方法-
用户自选
不予受理的检验机构匹配
*
* @param bizObj 请求变量参数
* @param itemCode 核对项目编码,多个用逗号分割
* @param isMatchArea 是否进行属地过滤(检验检测机构的开通区域包含设备归属地市),true-过滤,false-不过滤
* @param defaultInspectionCode 默认的检验机构code
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、all-全部,默认都是legal-法定,预留需求变更点
* @param legalInspectionCodes
法定的检验机构code,多个用逗号分割,检验机构的最大集合-不为空
* @param defaultInspectionCode 默认的检验机构code
,多个用逗号分割,定向规则使用此字段指定检验机构
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、
designated-定向单位、
all-全部,默认都是legal-法定,预留需求变更点
* @param legalInspectionCodes
预留检验机构code,多个用逗号分割
* @param isMustAccept true-必须处理,false-可不予受理
* @param orgType jy-检验机构,jc-检测机构
*/
public
void
noAcceptInspectionOrgMatchAction
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
String
legalInspectionCodes
,
Boolean
isMustAccept
)
{
log
.
info
(
"收到不予受理的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{}, 检验机构类型: {},是否需要匹配核准代码:{},是否必须处理:{}
"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
);
public
void
noAcceptInspectionOrgMatchAction
2
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
String
legalInspectionCodes
,
Boolean
isMustAccept
,
String
orgType
)
{
log
.
info
(
"收到不予受理的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{}, 检验机构类型: {},是否需要匹配核准代码:{},是否必须处理:{}
,公司类型:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
,
orgType
);
InspectionEquipInfo
inspectionEquipInfo
=
(
InspectionEquipInfo
)
bizObj
;
try
{
// 1.获取所有的符合资质条件的单位许可信息
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
);
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
,
orgType
);
// 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测)
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForNoAccept
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
OpenBizTypeEnum
.
JY
.
getCode
(),
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMustAccept
);
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForNoAccept2
(
isMatchItem
,
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
orgType
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMustAccept
);
// 3.如果当前机构为符合条件的自检机构则增加上(电梯检测才需要)
this
.
setSelfUnitIfDetection
(
orgType
,
inspectionEquipInfo
,
tzBaseEnterpriseInfoList
,
isMustAccept
);
// 4.去掉已经不予受理的单位,报检时该单位不能再进行接收报检信息(列表不显示)
this
.
removeNoAcceptUnit
(
tzBaseEnterpriseInfoList
,
inspectionEquipInfo
);
// todo 5.tzBaseEnterpriseInfoList排序
ruleCommonService
.
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
}
catch
(
MqttException
e
)
{
log
.
error
(
"Error publishing MQTT message: {}"
,
e
.
getMessage
());
}
}
private
List
<
TzBaseUnitLicence
>
getBaseUnitLicenceList
(
String
itemCode
,
Boolean
isMatchItem
)
{
List
<
TzBaseUnitLicence
>
tzBaseUnitLicences
;
private
void
removeNoAcceptUnit
(
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
,
InspectionEquipInfo
inspectionEquipInfo
)
{
// 本次报检已经不予受理的单位code
List
<
String
>
noAcceptUnitCodes
=
getNoAcceptHistoryUnit
(
inspectionEquipInfo
);
// 不予受理的单位去掉,目的下次不能在进行选择
matchEnterpriseInfos
.
removeIf
(
e
->
!
noAcceptUnitCodes
.
contains
(
e
.
getUseCode
()));
}
private
String
buildLockKey
(
String
type
,
String
uuid
)
{
return
String
.
format
(
"%s-%s"
,
type
,
uuid
);
}
private
String
buildRedisDataKey
(
String
type
,
String
uuid
)
{
return
String
.
format
(
"RECEIVED-UUID-RULE:%s-%s"
,
type
,
uuid
);
}
private
List
<
TzBaseUnitLicence
>
getBaseUnitLicenceList
(
String
itemCode
,
Boolean
isMatchItem
,
String
orgType
)
{
List
<
TzBaseUnitLicence
>
tzBaseUnitLicences
=
new
ArrayList
<>();
if
(
isMatchItem
&&
StringUtils
.
isNotEmpty
(
itemCode
))
{
tzBaseUnitLicences
=
baseUnitLicenceMapper
.
selectList
(
new
LambdaQueryWrapper
<
TzBaseUnitLicence
>()
.
select
(
TzBaseUnitLicence:
:
getUnitCode
)
.
select
(
TzBaseUnitLicence:
:
getUnitCode
,
BaseEntity:
:
getSequenceNbr
,
TzBaseUnitLicence:
:
getEnterpriseCertSeq
)
.
eq
(
TzBaseUnitLicence:
:
getLicenceType
,
LicenceTypeEnum
.
JY_JC
.
getCode
())
.
in
(
TzBaseUnitLicence:
:
getItemCode
,
Arrays
.
asList
(
itemCode
.
split
(
","
)))
.
ge
(
TzBaseUnitLicence:
:
getExpiryDate
,
LocalDate
.
now
()));
}
else
{
tzBaseUnitLicences
=
baseUnitLicenceMapper
.
selectList
(
new
LambdaQueryWrapper
<
TzBaseUnitLicence
>()
.
select
(
TzBaseUnitLicence:
:
getUnitCode
)
.
eq
(
TzBaseUnitLicence:
:
getLicenceType
,
LicenceTypeEnum
.
JY_JC
.
getCode
())
.
ge
(
TzBaseUnitLicence:
:
getExpiryDate
,
LocalDate
.
now
()));
.
ge
(
TzBaseUnitLicence:
:
getExpiryDate
,
LocalDate
.
now
())
.
eq
(
TzBaseUnitLicence:
:
getLicenceState
,
LicenceStateEnum
.
enabled
.
getValue
()));
}
if
(!
tzBaseUnitLicences
.
isEmpty
())
{
// 匹配单位类型的证书
List
<
String
>
certSeqs
=
baseEnterpriseCertService
.
list
(
new
LambdaQueryWrapper
<
BaseEnterpriseCert
>().
in
(
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
entity
.
BaseEntity
::
getSequenceNbr
,
tzBaseUnitLicences
.
stream
().
map
(
TzBaseUnitLicence:
:
getEnterpriseCertSeq
).
collect
(
Collectors
.
toList
())).
eq
(
BaseEnterpriseCert:
:
getUnitType
,
orgType
).
select
(
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
entity
.
BaseEntity
::
getSequenceNbr
)).
stream
().
map
(
e
->
String
.
valueOf
(
e
.
getSequenceNbr
())).
collect
(
Collectors
.
toList
());
// 返回符合核准项目且开通的项目且开通的单位类型能匹配上的资质
tzBaseUnitLicences
=
tzBaseUnitLicences
.
stream
().
filter
(
l
->
certSeqs
.
contains
(
l
.
getEnterpriseCertSeq
())).
collect
(
Collectors
.
toList
());
}
return
tzBaseUnitLicences
;
}
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForNoAccept2
(
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isCanNoAccept
)
{
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
ALL
.
getCode
()))
{
// 是否进行属地过滤
String
areaCode
=
isMatchArea
?
inspectionEquipInfo
.
getAreaCode
()
:
""
;
// 所有符合资质的单位code
Set
<
String
>
unitCodes
=
unitLicenceList
.
stream
().
map
(
TzBaseUnitLicence:
:
getUnitCode
).
collect
(
Collectors
.
toSet
());
// 按照资质 + 开通区域,进行单位的筛选
if
(!
unitCodes
.
isEmpty
())
{
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
unitCodes
),
areaCode
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
isCanNoAccept
);
}
// 未空时显示默认机构(兜底机构),只匹配开通的业务类型(检验还是检测)且不匹配开通区域且不可不予受理操作, 预留功能
if
(
matchEnterpriseInfos
.
isEmpty
()
&&
StringUtils
.
isNotEmpty
(
defaultInspectionCode
)
&&
!
defaultInspectionCode
.
equals
(
CommonConstants
.
NONE_DEFAULT_CODE
))
{
log
.
info
(
"将匹配兜底机构:{}"
,
defaultInspectionCode
);
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
Arrays
.
asList
(
defaultInspectionCode
.
split
(
","
))),
""
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
true
);
}
}
else
{
log
.
warn
(
"{}:待实现"
,
inspectionCompanyType
);
}
return
matchEnterpriseInfos
;
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForNoAccept2
(
Boolean
isMatchItem
,
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isCanNoAccept
)
{
return
getInspectionUnitListForFirstCommit2
(
isMatchItem
,
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
openBizType
,
defaultInspectionCode
,
legalInspectionCodes
,
isCanNoAccept
,
inspectionCompanyType
);
}
private
List
<
String
>
getNoAcceptHistoryUnit
(
InspectionEquipInfo
inspectionEquipInfo
)
{
...
...
@@ -192,68 +186,53 @@ public class RuleActionHandler {
return
acceptLogs
.
stream
().
map
(
JyjcInspectionApplicationNoAcceptLog:
:
getInspectionUnitCode
).
collect
(
Collectors
.
toList
());
}
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForNoAccept
(
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isCanNoAccept
)
{
// 是否进行属地过滤
String
areaCode
=
isMatchArea
?
inspectionEquipInfo
.
getAreaCode
()
:
""
;
// 所有符合单位的code
Set
<
String
>
unitCodes
=
unitLicenceList
.
stream
().
map
(
TzBaseUnitLicence:
:
getUnitCode
).
collect
(
Collectors
.
toSet
());
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
// 按照资质 + areaCode,进行设备单位的筛选
if
(!
unitCodes
.
isEmpty
())
{
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
unitCodes
),
areaCode
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
isCanNoAccept
);
}
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
THIRD
.
getCode
()))
{
// 第三方时需要去掉法定机构
log
.
info
(
"第三方检验机构开始匹配"
);
//目前规则配置的法定名单为陕西省内地市的法定机构
matchEnterpriseInfos
=
matchEnterpriseInfos
.
stream
().
filter
(
e
->
!
legalInspectionCodes
.
contains
(
e
.
getUseCode
())).
collect
(
Collectors
.
toList
());
// 还需要去掉定向的机构:陕西省、国机特种设备检验有限公司、中国特种设备检验检测研究院
matchEnterpriseInfos
=
matchEnterpriseInfos
.
stream
().
filter
(
c
->
!
specialInspectionCompanyCode
.
contains
(
c
.
getUseCode
())).
collect
(
Collectors
.
toList
());
log
.
info
(
"匹配到的第三方检验机构:{}"
,
matchEnterpriseInfos
);
// 未匹配到第三方机构时,返回指定的默认的法定机构, 默认及法定机构不进行开通区域的匹配
if
(
matchEnterpriseInfos
.
isEmpty
())
{
log
.
info
(
"按照资质、区域未匹配到第三方检验机构"
);
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
Arrays
.
asList
(
defaultInspectionCode
.
split
(
","
))),
""
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
true
);
}
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForFirstCommit2
(
Boolean
isMatchItem
,
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
Boolean
isMustAccept
,
String
inspectionCompanyType
)
{
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
ALL
.
getCode
()))
{
// 所有开通的检验检测机构
matchEnterpriseInfos
=
getInspectionUnitListForAll
(
isMatchItem
,
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
openBizType
,
isMustAccept
);
}
else
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
LEGAL
.
getCode
()))
{
// 法定时,机构为定义的法定机构 defaultInspectionCode
log
.
info
(
"法定检验机构开始匹配"
);
matchEnterpriseInfos
=
matchEnterpriseInfos
.
stream
().
filter
(
e
->
defaultInspectionCode
.
contains
(
e
.
getUseCode
())).
collect
(
Collectors
.
toList
());
log
.
info
(
"匹配到的法定检验机构:{}"
,
matchEnterpriseInfos
);
// 查询省内公益机构(省内法定机构)
matchEnterpriseInfos
=
getInspectionUnitListForLegal
(
isMatchItem
,
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
openBizType
,
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
);
}
else
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
DESIGNATED
.
getCode
()))
{
// 查询指定机构
matchEnterpriseInfos
=
getDesignatedUnitList
(
isMatchItem
,
defaultInspectionCode
,
isMatchArea
,
inspectionEquipInfo
,
openBizType
,
isMustAccept
,
unitLicenceList
);
}
else
{
log
.
warn
(
"未实现的检验机构名单类型:{}"
,
inspectionCompanyType
);
}
return
matchEnterpriseInfos
;
}
private
List
<
TzBaseEnterpriseInfoDto
>
get
InspectionUnitListForFirstCommit2
(
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
Boolean
isMustAccept
,
String
inspectionCompanyType
)
{
private
List
<
TzBaseEnterpriseInfoDto
>
get
DesignatedUnitList
(
Boolean
isMatchItem
,
String
defaultInspectionCode
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
Boolean
isMustAccept
,
List
<
TzBaseUnitLicence
>
unitLicenceList
)
{
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
ALL
.
getCode
()))
{
matchEnterpriseInfos
=
getInspectionUnitListForAll
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
openBizType
,
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
);
}
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
LEGAL
.
getCode
()))
{
// 目前未使用到可替换 firstInspectionOrgMatchAction 业务
matchEnterpriseInfos
=
getInspectionUnitListForLegal
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
openBizType
,
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
);
}
else
if
(
inspectionCompanyType
.
equals
(
InspectionCompanyType
.
THIRD
.
getCode
()))
{
// TODO 待实现
log
.
warn
(
"{}类型:未实现"
,
InspectionCompanyType
.
THIRD
.
getName
());
// 是否进行属地过滤
String
areaCode
=
isMatchArea
?
inspectionEquipInfo
.
getAreaCode
()
:
""
;
if
(
defaultInspectionCode
.
split
(
","
).
length
>
0
)
{
Set
<
String
>
unitCodes
=
unitLicenceList
.
stream
()
.
map
(
TzBaseUnitLicence:
:
getUnitCode
)
.
collect
(
Collectors
.
toSet
());
// 需要匹配核准项目时,将符合核准项目要求的单位code和指定的单位code取交集,否则直接符合指定的机构
List
<
String
>
designatedUnitMatch
=
isMatchItem
?
Arrays
.
stream
(
defaultInspectionCode
.
split
(
","
)).
filter
(
unitCodes:
:
contains
).
collect
(
Collectors
.
toList
())
:
Arrays
.
asList
(
defaultInspectionCode
.
split
(
","
));
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
designatedUnitMatch
,
areaCode
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
isMustAccept
);
}
return
matchEnterpriseInfos
;
}
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForLegal
(
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
Boolean
isCanNoAccept
)
{
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForLegal
(
Boolean
isMatchItem
,
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
Boolean
isCanNoAccept
)
{
// 是否进行属地过滤
String
areaCode
=
isMatchArea
?
inspectionEquipInfo
.
getAreaCode
()
:
""
;
// 所有符合单位的code
// 所有符合
资质
单位的code
Set
<
String
>
unitCodes
=
unitLicenceList
.
stream
()
.
map
(
TzBaseUnitLicence:
:
getUnitCode
)
.
collect
(
Collectors
.
toSet
());
// 将法定机构和符合资质要求的机构取交集
List
<
String
>
legalUnitCodes
=
Arrays
.
stream
(
legalInspectionCodes
.
split
(
","
)).
filter
(
unitCodes:
:
contains
).
collect
(
Collectors
.
toList
());
// 查询省内公益机构(法定机构)开通状态
List
<
String
>
legalInspectionCodeProvince
=
openingApplicationMapper
.
selectUnitCodeListByAgencyClassify
(
Collections
.
singletonList
(
JyAgencyClassifyEnum
.
SBGY
.
getCode
()));
// 需要匹配核准项目时:将法定机构和符合资质要求的机构取交集,否则直接取指定的机构
List
<
String
>
legalUnitCodes
=
isMatchItem
?
legalInspectionCodeProvince
.
stream
().
filter
(
unitCodes:
:
contains
).
collect
(
Collectors
.
toList
())
:
legalInspectionCodeProvince
;
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
// 按照资质 + areaCode,进行设备单位的筛选
if
(!
legalUnitCodes
.
isEmpty
())
{
...
...
@@ -261,27 +240,22 @@ public class RuleActionHandler {
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
isCanNoAccept
);
}
// 未匹配到法定机构
时,返回指定的默认的法定机构, 默认及法定机构不进行开通区域的匹配
// 未匹配到法定机构
if
(
matchEnterpriseInfos
.
isEmpty
())
{
log
.
info
(
"按照资质、区域未匹配到法定检验机构"
);
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
Arrays
.
asList
(
defaultInspectionCode
.
split
(
","
))),
""
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
isCanNoAccept
);
log
.
info
(
"按照资质、区域、属地,未匹配到法定检验机构"
);
}
return
matchEnterpriseInfos
;
}
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForAll
(
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
Boolean
isCanNoAccept
)
{
private
List
<
TzBaseEnterpriseInfoDto
>
getInspectionUnitListForAll
(
Boolean
isMatchItem
,
List
<
TzBaseUnitLicence
>
unitLicenceList
,
Boolean
isMatchArea
,
InspectionEquipInfo
inspectionEquipInfo
,
String
openBizType
,
Boolean
isCanNoAccept
)
{
// 是否进行属地过滤
String
areaCode
=
isMatchArea
?
inspectionEquipInfo
.
getAreaCode
()
:
""
;
// 所有符合单位的code
Set
<
String
>
unitCodes
=
unitLicenceList
.
stream
().
map
(
TzBaseUnitLicence:
:
getUnitCode
).
collect
(
Collectors
.
toSet
());
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
if
(!
unitCodes
.
isEmpty
())
{
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
unitCodes
),
areaCode
,
openBizType
);
// 不匹配核准项目时,不按照符合资质过滤,默认开通状态
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
isMatchItem
?
new
ArrayList
<>(
unitCodes
)
:
null
,
areaCode
,
openBizType
);
// 返回下一步是否可不予返回,供下一节点审核时显示判断是否显示不予受理按钮,在提交时数据会写入到主表:true-必须处理,false-可不予受理
this
.
setIsCanNoAccept
(
matchEnterpriseInfos
,
isCanNoAccept
);
}
return
matchEnterpriseInfos
;
}
...
...
@@ -289,77 +263,5 @@ public class RuleActionHandler {
matchEnterpriseInfos
.
forEach
(
m
->
m
.
setUseCodeAndName
(
m
.
getUseCode
()
+
"_"
+
isCanNoAccept
));
}
/**
* 规则回调方法-用户自选首次提交的检验机构匹配,可替换firstInspectionOrgMatchAction,由于规则修改太多,故新增一个
*
* @param bizObj 请求变量参数
* @param itemCode 核对项目编码,多个用逗号分割
* @param isMatchArea 是否进行属地过滤(检验检测机构的开通区域包含设备归属地市),true-过滤,false-不过滤
* @param defaultInspectionCode 默认的检验机构code,多个用逗号分割,在按照属地匹配不上时,默认的检验机构
* @param legalInspectionCodes 法定的检验机构code,多个用逗号分割,检验机构的最大集合-不为空
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、all-全部,默认都是legal-法定,预留需求变更点
* @param isMatchItem 是否需要匹配核准代码:true-匹配; false-不匹配
* @param isMustAccept true-必须处理,false-可不予受理
* @param orgType jy-检验机构,jc-检测机构
*/
public
void
firstInspectionOrgMatchAction2
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
legalInspectionCodes
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
Boolean
isMustAccept
,
String
orgType
)
{
log
.
info
(
"收到用户自选首次提交的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{}, 检验机构类型: {},是否需要匹配核准代码:{},是否必须处理:{},检验机构类型:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
,
orgType
);
InspectionEquipInfo
inspectionEquipInfo
=
(
InspectionEquipInfo
)
bizObj
;
// 规则不支持或者的关系消息会重复故去重处理
RLock
lock
=
redissonClient
.
getLock
(
this
.
buildLockKey
(
"firstInspectionOrgMatchAction2"
,
inspectionEquipInfo
.
getUuid
()));
try
{
boolean
isLocked
=
lock
.
tryLock
(
0
,
180
,
TimeUnit
.
SECONDS
);
if
(!
isLocked
)
{
log
.
warn
(
"规则回掉重复,消息将丢弃"
);
return
;
}
if
(
redisUtils
.
hasKey
(
this
.
buildRedisDataKey
(
"firstInspectionOrgMatchAction2"
,
inspectionEquipInfo
.
getUuid
())))
{
log
.
warn
(
"规则回掉重复,消息将丢弃"
);
return
;
}
redisUtils
.
set
(
this
.
buildRedisDataKey
(
"firstInspectionOrgMatchAction2"
,
inspectionEquipInfo
.
getUuid
()),
inspectionEquipInfo
.
getUuid
(),
3600
);
// 1.获取所有的符合资质条件的单位许可信息
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
);
// 2.匹配过滤机构信息,区分检验还是检测
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForFirstCommit2
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
orgType
,
defaultInspectionCode
,
legalInspectionCodes
,
isMustAccept
,
inspectionCompanyType
);
ruleCommonService
.
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
}
catch
(
MqttException
|
InterruptedException
e
)
{
log
.
error
(
"用户自选首次提交的检验机构匹配动作执行失败: {}"
,
e
.
getMessage
());
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
}
}
}
/**
* 规则回调方法-用户自选不予受理的检验机构匹配
*
* @param bizObj 请求变量参数
* @param itemCode 核对项目编码,多个用逗号分割
* @param isMatchArea 是否进行属地过滤(检验检测机构的开通区域包含设备归属地市),true-过滤,false-不过滤
* @param defaultInspectionCode 默认的检验机构code
* @param inspectionCompanyType 需要显示的单位类型:legal-法定、third-第3方、all-全部,默认都是legal-法定,预留需求变更点
* @param legalInspectionCodes 法定的检验机构code,多个用逗号分割,检验机构的最大集合-不为空
* @param isMustAccept true-必须处理,false-可不予受理
* @param orgType jy-检验机构,jc-检测机构
*/
public
void
noAcceptInspectionOrgMatchAction2
(
Object
bizObj
,
String
itemCode
,
Boolean
isMatchArea
,
String
defaultInspectionCode
,
String
inspectionCompanyType
,
Boolean
isMatchItem
,
String
legalInspectionCodes
,
Boolean
isMustAccept
,
String
orgType
)
{
log
.
info
(
"收到不予受理的检验机构匹配规则回调:请求变量参数:{},核对项目编码:{},是否进行属地过滤:{},默认的检验机构code:{}, 法定的检验机构code:{}, 检验机构类型: {},是否需要匹配核准代码:{},是否必须处理:{},公司类型:{}"
,
bizObj
,
itemCode
,
isMatchArea
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMatchItem
,
isMustAccept
,
orgType
);
InspectionEquipInfo
inspectionEquipInfo
=
(
InspectionEquipInfo
)
bizObj
;
try
{
// 1.获取所有的符合资质条件的单位许可信息
List
<
TzBaseUnitLicence
>
unitLicenceList
=
getBaseUnitLicenceList
(
itemCode
,
isMatchItem
);
// 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测)
List
<
TzBaseEnterpriseInfoDto
>
tzBaseEnterpriseInfoList
=
getInspectionUnitListForNoAccept2
(
unitLicenceList
,
isMatchArea
,
inspectionEquipInfo
,
orgType
,
defaultInspectionCode
,
legalInspectionCodes
,
inspectionCompanyType
,
isMustAccept
);
ruleCommonService
.
publishMqttMessage
(
inspectionEquipInfo
.
getComponentKey
(),
tzBaseEnterpriseInfoList
);
}
catch
(
MqttException
e
)
{
log
.
error
(
"Error publishing MQTT message: {}"
,
e
.
getMessage
());
}
}
}
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/event/rule/service/EnableRuleDataPreparationService.java
View file @
188135de
...
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jyjc.biz.event.rule.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil
;
import
com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationNoAcceptLog
;
import
com.yeejoin.amos.boot.module.jyjc.api.enums.JYJCTypeEnum
;
...
...
@@ -16,8 +17,10 @@ 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.entity.IdxBizJgProjectContraption
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -25,10 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
...
...
@@ -62,9 +62,21 @@ public class EnableRuleDataPreparationService {
private
final
IdxBizJgProjectContraptionMapper
jgProjectContraptionMapper
;
private
final
TzBaseEnterpriseInfoMapper
baseEnterpriseInfoMapper
;
@Value
(
"${rule.data.preparation.thread.number:2}"
)
private
int
threadNumber
;
/**
* 压力类设备种类
*/
private
static
final
List
<
String
>
PRESSURE_EQU_LIST
=
Arrays
.
asList
(
"8000"
,
"1000"
,
"2000"
);
/**
* 需要技术参数匹配报检的设备类别-目的提高执行速度
*/
private
static
final
List
<
String
>
NEED_TECH_PARAM_EQU_CATEGORY
=
Arrays
.
asList
(
"1100"
,
"2100"
);
public
void
onApplicationEvent
(
InspectionOrgRefreshEvent
event
)
{
int
queueIndex
=
Math
.
abs
(
event
.
getInspectionEquipInfoModel
().
getRecord
().
hashCode
())
%
threadNumber
;
...
...
@@ -122,10 +134,15 @@ public class EnableRuleDataPreparationService {
inspectionEquipInfo
.
setEquCategory
(
equipInfoModel
.
getEquCategory
());
inspectionEquipInfo
.
setEquList
(
equipInfoModel
.
getEquList
());
inspectionEquipInfo
.
setEquDefine
(
equipInfoModel
.
getEquDefine
());
inspectionEquipInfo
.
setTechParams
(
this
.
getTechParams
(
registrationInfo
));
inspectionEquipInfo
.
setTechParams
(
this
.
getTechParams
(
registrationInfo
,
equipInfoModel
));
// 是否球罐 0 1 转 boolean
inspectionEquipInfo
.
setIsBallValve
(!
"0"
.
equals
(
registrationInfo
.
getWhetherSphericalTank
()));
}
if
(
PRESSURE_EQU_LIST
.
contains
(
equipInfoModel
.
getEquList
()))
{
String
useCode
=
equipInfoModel
.
getUnitCode
();
TzBaseEnterpriseInfo
enterpriseInfo
=
baseEnterpriseInfoMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TzBaseEnterpriseInfo
>().
eq
(
TzBaseEnterpriseInfo:
:
getUseCode
,
useCode
).
select
(
BaseEntity:
:
getSequenceNbr
,
TzBaseEnterpriseInfo:
:
getRegulatoryLabels
));
inspectionEquipInfo
.
setManageLevel
(
enterpriseInfo
.
getRegulatoryLabels
());
}
inspectionEquipInfo
.
setAreaCode
(
ruleCommonService
.
getArea
(
equipInfoModel
.
getCity
(),
equipInfoModel
.
getCounty
()));
inspectionEquipInfo
.
setDistrictOrCountyCode
(
equipInfoModel
.
getCounty
());
inspectionEquipInfo
.
setComponentKey
(
equipInfoModel
.
getComponentKey
());
...
...
@@ -149,9 +166,12 @@ public class EnableRuleDataPreparationService {
}
private
Map
<
String
,
Object
>
getTechParams
(
RegistrationInfo
registrationInfo
)
{
private
Map
<
String
,
Object
>
getTechParams
(
RegistrationInfo
registrationInfo
,
InspectionEquipInfoModel
equipInfoModel
)
{
if
(
NEED_TECH_PARAM_EQU_CATEGORY
.
contains
(
equipInfoModel
.
getEquCategory
()))
{
return
applicationPushEventListener
.
populateEquipInfoWithTechParams
(
registrationInfo
.
getEquList
(),
registrationInfo
.
getRecord
());
}
return
new
HashMap
<>();
}
private
String
buildRequestType
(
InspectionEquipInfoModel
equipInfoModel
,
JyjcInspectionApplicationNoAcceptLog
jyjcInspectionApplicationNoAcceptLog
)
{
// 工作台发起申请
...
...
amos-boot-system-tzs/amos-boot-module-jyjc/amos-boot-module-jyjc-biz/src/main/java/com/yeejoin/amos/boot/module/jyjc/biz/rule/InspectionEquipInfo.java
View file @
188135de
...
...
@@ -63,4 +63,10 @@ public class InspectionEquipInfo implements Serializable {
@ApiModelProperty
(
value
=
"申请表主键"
)
private
String
appSeq
;
@ApiModelProperty
(
value
=
"企业管控级别,承压类使用"
)
private
String
manageLevel
;
@ApiModelProperty
(
value
=
"设备分类,大型游乐设施使用"
)
private
String
equipTag1
;
}
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/JyjcOpeningApplicationServiceImpl.java
View file @
188135de
...
...
@@ -1243,7 +1243,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
Set
<
String
>
unitCodes
=
unitLicenceList
.
stream
().
map
(
TzBaseUnitLicence:
:
getUnitCode
).
collect
(
Collectors
.
toSet
());
List
<
TzBaseEnterpriseInfoDto
>
matchEnterpriseInfos
=
new
ArrayList
<>();
// 按照资质 + areaCode,进行设备单位的筛选
if
(
unitCodes
.
size
()
>
0
)
{
if
(
!
unitCodes
.
isEmpty
()
)
{
matchEnterpriseInfos
=
tzBaseEnterpriseInfoMapper
.
getInspectionUnitListByCode
(
new
ArrayList
<>(
unitCodes
),
areaCode
,
openBizType
);
}
if
(
matchEnterpriseInfos
.
isEmpty
())
{
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/java/com/yeejoin/amos/boot/module/ymt/api/mapper/TzBaseEnterpriseInfoMapper.java
View file @
188135de
...
...
@@ -108,4 +108,11 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
List
<
Map
<
String
,
String
>>
getEnterInfoWithExport
(
@Param
(
"ids"
)
List
<
String
>
ids
);
/**
* 按照不带证件类型的的单位code,重新单位-检验检测业务专用
* @param list 单位code
* @return 单位列表
*/
List
<
TzBaseEnterpriseInfoDto
>
queryInspectionUnitListByUseUnitCode
(
List
<
String
>
list
);
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/resources/mapper/TzBaseEnterpriseInfoMapper.xml
View file @
188135de
...
...
@@ -266,15 +266,17 @@
</if>
group by info.use_code
</select>
<select
id=
"getInspectionUnitListByCode"
resultType=
"com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto"
>
<sql
id=
"unit-list-info"
>
SELECT
info.sequence_nbr,
info.use_code,
info.use_
unit_code as use_
code,
info.use_unit,
concat(info.use
_code,'_',info.use_unit) as useCodeAndName
concat(info.use_unit
_code,'_',info.use_unit) as useCodeAndName
FROM
tz_base_enterprise_info info
</sql>
<select
id=
"getInspectionUnitListByCode"
resultType=
"com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto"
>
<include
refid=
"unit-list-info"
/>
INNER JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
AND tjoa.status = '已完成'
and tjoa.open_biz_type = #{openBizType}
...
...
@@ -388,4 +390,12 @@
</if>
</where>
</select>
<select
id=
"queryInspectionUnitListByUseUnitCode"
resultType=
"com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto"
>
<include
refid=
"unit-list-info"
/>
where
info.use_code in
<foreach
collection=
"list"
item=
"item"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</select>
</mapper>
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