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
1b614da7
Commit
1b614da7
authored
Aug 23, 2023
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.机器人
parent
19c5eb98
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
315 additions
and
555 deletions
+315
-555
BaseEnterpriseMqTtlListener.java
...le/elevator/biz/listener/BaseEnterpriseMqTtlListener.java
+0
-0
CarcylUnitInspectMqTtlListener.java
...elevator/biz/listener/CarcylUnitInspectMqTtlListener.java
+5
-8
PlatformUserTopicMessage.java
...odule/elevator/biz/listener/PlatformUserTopicMessage.java
+5
-11
PrivilegeCompanyUpdateAddListener.java
...vator/biz/listener/PrivilegeCompanyUpdateAddListener.java
+22
-26
StartPlatformTokenService.java
.../elevator/biz/service/impl/StartPlatformTokenService.java
+11
-31
TzBaseEnterpriseInfoServiceImpl.java
...tor/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+0
-0
application.properties
...odule-96333-biz/src/main/resources/application.properties
+1
-5
StartPlatformTokenService.java
...odule/app/biz/service/impl/StartPlatformTokenService.java
+11
-22
TzBaseEnterpriseInfoServiceImpl.java
...app/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+6
-45
application.properties
...-module-app-biz/src/main/resources/application.properties
+1
-5
StartPlatformTokenService.java
.../cylinder/biz/service/impl/StartPlatformTokenService.java
+9
-28
TzBaseEnterpriseInfoServiceImpl.java
...der/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+0
-0
application.properties
...le-cylinder-biz/src/main/resources/application.properties
+1
-5
PrivilegeCompanyUpdateAddListener.java
.../jczs/biz/listener/PrivilegeCompanyUpdateAddListener.java
+4
-7
StartPlatformTokenService.java
...dule/jczs/biz/service/impl/StartPlatformTokenService.java
+11
-31
TzBaseEnterpriseInfoServiceImpl.java
...czs/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+0
-0
application.properties
...module-jczs-biz/src/main/resources/application.properties
+1
-5
BaseEnterpriseMqTtlListener.java
.../module/tcm/biz/listener/BaseEnterpriseMqTtlListener.java
+0
-0
CarcylUnitInspectMqTtlListener.java
...dule/tcm/biz/listener/CarcylUnitInspectMqTtlListener.java
+75
-81
PlatformUserTopicMessage.java
...oot/module/tcm/biz/listener/PlatformUserTopicMessage.java
+5
-11
PrivilegeCompanyUpdateAddListener.java
...e/tcm/biz/listener/PrivilegeCompanyUpdateAddListener.java
+22
-25
application.properties
...-module-tcm-biz/src/main/resources/application.properties
+1
-5
BaseEnterpriseMqTtlListener.java
.../module/ymt/biz/listener/BaseEnterpriseMqTtlListener.java
+5
-8
CarcylUnitInspectMqTtlListener.java
...dule/ymt/biz/listener/CarcylUnitInspectMqTtlListener.java
+75
-81
PlatformUserTopicMessage.java
...oot/module/ymt/biz/listener/PlatformUserTopicMessage.java
+5
-11
PrivilegeCompanyUpdateAddListener.java
...e/ymt/biz/listener/PrivilegeCompanyUpdateAddListener.java
+22
-26
StartPlatformTokenService.java
...odule/ymt/biz/service/impl/StartPlatformTokenService.java
+10
-30
TzBaseEnterpriseInfoServiceImpl.java
...ymt/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+6
-43
application.properties
...-module-ymt-biz/src/main/resources/application.properties
+1
-5
No files found.
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/java/com/yeejoin/amos/boot/module/elevator/biz/listener/BaseEnterpriseMqTtlListener.java
View file @
1b614da7
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/java/com/yeejoin/amos/boot/module/elevator/biz/listener/CarcylUnitInspectMqTtlListener.java
View file @
1b614da7
...
...
@@ -6,6 +6,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.yeejoin.amos.boot.module.elevator.biz.service.impl.StartPlatformTokenService
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -36,16 +37,14 @@ public class CarcylUnitInspectMqTtlListener extends EmqxListener {
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appkey
;
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${org.filter.group.seq}"
)
private
Long
groupSeq
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
...
...
@@ -56,9 +55,7 @@ public class CarcylUnitInspectMqTtlListener extends EmqxListener {
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
FeignClientResult
<
List
<
ApplicationModel
>>
aResult
=
Privilege
.
applicationClient
.
queryAgencyApplications
();
List
<
ApplicationModel
>
aList
=
aResult
.
getResult
();
List
<
String
>
appCodes
=
aList
.
stream
().
filter
(
i
->
"监管端,企业端"
.
indexOf
(
i
.
getAppName
())
!=
-
1
)
...
...
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/java/com/yeejoin/amos/boot/module/elevator/biz/listener/PlatformUserTopicMessage.java
View file @
1b614da7
...
...
@@ -5,18 +5,16 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.elevator.api.service.IEquipmentCategoryService
;
import
com.yeejoin.amos.boot.module.elevator.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.elevator.flc.api.service.IRegUnitInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
@Component
...
...
@@ -40,11 +38,6 @@ public class PlatformUserTopicMessage extends EmqxListener {
@Autowired
RedisUtils
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appKey
;
@Autowired
IEquipmentCategoryService
equipmentCategoryService
;
...
...
@@ -52,11 +45,12 @@ public class PlatformUserTopicMessage extends EmqxListener {
@Autowired
IRegUnitInfoService
regUnitInfoService
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
{
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
message
.
toString
());
JSONObject
result
=
jsonObject
.
getJSONObject
(
"result"
);
JSONObject
dataResult
=
result
.
getJSONObject
(
"result"
);
...
...
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/java/com/yeejoin/amos/boot/module/elevator/biz/listener/PrivilegeCompanyUpdateAddListener.java
View file @
1b614da7
...
...
@@ -5,10 +5,10 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.yeejoin.amos.boot.module.elevator.api.entity.TzBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.elevator.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.elevator.biz.service.impl.TzBaseEnterpriseInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.elevator.biz.utils.RedisUtil
;
import
com.yeejoin.amos.boot.module.elevator.flc.api.feign.AccessFeignService
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -16,14 +16,15 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.Map
;
@Component
@Slf4j
...
...
@@ -40,11 +41,8 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appKey
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
s
,
MqttMessage
message
)
throws
Exception
{
...
...
@@ -58,15 +56,13 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
//判断库中业务tz_base_enterprise_info是否存在
QueryWrapper
<
TzBaseEnterpriseInfo
>
queryWrapper
=
new
QueryWrapper
<
TzBaseEnterpriseInfo
>();
queryWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
queryWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
TzBaseEnterpriseInfo
tzBaseEnterprisePrivilegeInfo
=
tzBaseEnterpriseInfoService
.
getOne
(
queryWrapper
);
if
(!
ValidationUtil
.
isEmpty
(
tzBaseEnterprisePrivilegeInfo
))
{
if
(!
ValidationUtil
.
isEmpty
(
tzBaseEnterprisePrivilegeInfo
))
{
accessFeignService
.
updateSyncCompanyState
(
object
.
getString
(
"sequence_nbr"
));
return
;
}
...
...
@@ -95,14 +91,14 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
//业务表更新条件构造器
UpdateWrapper
<
TzBaseEnterpriseInfo
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
updateWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
String
regCode
=
object
.
getString
(
"reg_code"
);
CompanyModel
supervisePrivilegeCompanyModel
;
if
(!
ValidationUtil
.
isEmpty
(
regCode
))
{
supervisePrivilegeCompanyModel
=
Privilege
.
companyClient
.
queryByCompanyCode
(
regCode
).
getResult
();
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
supervisePrivilegeCompanyModel
=
Privilege
.
companyClient
.
queryByCompanyCode
(
"610000"
).
getResult
();
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
...
...
@@ -120,37 +116,37 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
tzBaseEnterpriseInfo
.
setSuperviseOrgCode
(
supervisePrivilegeCompanyModel
.
getOrgCode
());
tzBaseEnterpriseInfo
.
setSuperviseOrgName
(
supervisePrivilegeCompanyModel
.
getCompanyName
());
if
(
ValidationUtil
.
isEmpty
(
tzBaseEnterpriseInfo
.
getUnitType
()))
{
if
(
ValidationUtil
.
isEmpty
(
tzBaseEnterpriseInfo
.
getUnitType
()))
{
tzBaseEnterpriseInfo
.
setUnitType
(
""
);
}
try
{
if
(
tzBaseEnterprisePrivilegeInfo
==
null
)
{
if
(
tzBaseEnterprisePrivilegeInfo
==
null
)
{
tzBaseEnterpriseInfoService
.
save
(
tzBaseEnterpriseInfo
);
accessFeignService
.
updateSyncCompanyState
(
object
.
getString
(
"sequence_nbr"
));
return
;
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"【"
+
object
.
getString
(
"unit_name"
)
+
"】许可信息同步【失败】:"
+
e
.
getMessage
());
}
}
public
Map
<
String
,
CompanyModel
>
getCompanyInfoMap
(
Collection
companyModels
,
Map
<
String
,
CompanyModel
>
map
)
{
if
(
companyModels
==
null
)
{
public
Map
<
String
,
CompanyModel
>
getCompanyInfoMap
(
Collection
companyModels
,
Map
<
String
,
CompanyModel
>
map
)
{
if
(
companyModels
==
null
)
{
return
map
;
}
Iterator
iter
=
companyModels
.
iterator
();
while
(
iter
.
hasNext
())
{
while
(
iter
.
hasNext
())
{
String
json
=
JSON
.
toJSONString
(
iter
.
next
());
CompanyModel
companyModel
=
JSON
.
parseObject
(
json
,
CompanyModel
.
class
);
CompanyModel
companyModel
=
JSON
.
parseObject
(
json
,
CompanyModel
.
class
);
String
code
=
companyModel
.
getCompanyCode
();
if
(
code
.
length
()
>=
6
)
{
if
(
code
.
length
()
>=
6
)
{
code
=
code
.
substring
(
0
,
6
);
}
map
.
put
(
code
,
companyModel
);
getCompanyInfoMap
(
companyModel
.
getChildren
(),
map
);
map
.
put
(
code
,
companyModel
);
getCompanyInfoMap
(
companyModel
.
getChildren
(),
map
);
}
return
map
;
}
...
...
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/java/com/yeejoin/amos/boot/module/elevator/biz/service/impl/StartPlatformTokenService.java
View file @
1b614da7
package
com
.
yeejoin
.
amos
.
boot
.
module
.
elevator
.
biz
.
service
.
impl
;
import
com.yeejoin.amos.boot.module.elevator.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.yeejoin.amos.boot.module.elevator.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
@Service
public
class
StartPlatformTokenService
{
@Value
(
"${admin.product}"
)
String
product
;
@Value
(
"${admin.appkey}"
)
String
appkey
;
@Value
(
"${admin.user}"
)
String
user
;
@Value
(
"${admin.password}"
)
String
password
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
AmosRequestContext
amosRequestContext
;
@Autowired
AmosRequestContext
amosRequestContext
;
public
void
getToken
()
{
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appkey
);
String
token
=
amosRequestContext
.
getToken
();
System
.
out
.
println
(
"token:"
+
token
);
RequestContext
.
setToken
(
token
);
redisUtil
.
set
(
"platform_token"
,
token
);
}
public
void
getToken
()
{
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
}
}
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/java/com/yeejoin/amos/boot/module/elevator/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
1b614da7
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-96333/amos-boot-module-96333-biz/src/main/resources/application.properties
View file @
1b614da7
...
...
@@ -124,11 +124,7 @@ tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \uFFFD\uFFFD\uFFFD\u06BA\u0172\uFFFD\uFFFD\uFFFD\uFFFD\u00FB\uFFFDid\uFFFD\uFFFD\u01BD\u0328userId\uFFFD\uFFFD
tzs.wechat.test.userId
=
3393279
admin.product
=
AMOS-SERVICE-ADMIN
admin.appkey
=
AMOS_ADMIN
admin.user
=
admin_tzs
admin.password
=
a1234560
admin.product.web
=
AMOS-WEB-ADMIN
amos.secret.key
=
qazknife4j.production=false
knife4j.production
=
false
...
...
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/service/impl/StartPlatformTokenService.java
View file @
1b614da7
package
com
.
yeejoin
.
amos
.
boot
.
module
.
app
.
biz
.
service
.
impl
;
import
com.yeejoin.amos.boot.module.app.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.yeejoin.amos.boot.module.app.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
@Service
public
class
StartPlatformTokenService
{
@Value
(
"${amos.system.user.product}"
)
String
product
;
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.system.user.app-key}"
)
String
appkey
;
@Autowired
AmosRequestContext
amosRequestContext
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
AmosRequestContext
amosRequestContext
;
public
void
getToken
()
{
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appkey
);
String
token
=
amosRequestContext
.
getToken
();
System
.
out
.
println
(
"token:"
+
token
);
RequestContext
.
setToken
(
token
);
redisUtil
.
set
(
"platform_token"
,
token
);
}
public
void
getToken
()
{
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
}
}
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
1b614da7
...
...
@@ -64,15 +64,6 @@ public class TzBaseEnterpriseInfoServiceImpl
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${admin.product}"
)
String
product
;
@Value
(
"${admin.product.web}"
)
String
webProduct
;
@Value
(
"${admin.appkey}"
)
String
appkey
;
@Autowired
private
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
;
...
...
@@ -87,34 +78,20 @@ public class TzBaseEnterpriseInfoServiceImpl
RegUnitInfoServiceImpl
regUnitInfoService
;
@Autowired
private
IBaseUnitLicenceService
iBaseUnitLicenceService
;
@Autowired
private
SpeUseUnitServiceImpl
speUseUnitService
;
@Autowired
private
AccessFeignService
accessFeignService
;
@Autowired
private
ITzBaseEnterpriseInfoService
tzBaseEnterpriseInfoService
;
@Autowired
DataDictionaryServiceImpl
iDataDictionaryService
;
@Autowired
RegUnitInfoMapper
regUnitInfoMapper
;
@Value
(
"${tzs.admin.name:tzs_admin}"
)
private
String
tzsAdminName
;
@Value
(
"${tzs.admin.pwd:a1234567}"
)
private
String
tzsAdminPwd
;
@Value
(
"${redis.cache.failure.time}"
)
private
Long
redisRegionTimeSecond
;
/**机器人用户token缓存key */
public
static
final
String
TZS_USER_TOKEN
=
"TZS_USER_TOKEN"
;
/**
* 企业管理员变更缓存key前缀
*/
...
...
@@ -122,6 +99,9 @@ public class TzBaseEnterpriseInfoServiceImpl
@Autowired
private
EquipmentCategoryServiceImpl
equipmentCategoryService
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
List
<
EquEnterDto
>
getInfo
(
String
sequenceNbr
)
{
return
tzBaseEnterpriseInfoMapper
.
getInfo
(
sequenceNbr
);
...
...
@@ -315,9 +295,7 @@ public class TzBaseEnterpriseInfoServiceImpl
@Override
public
String
syncEnterpriseInfo
()
{
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
List
<
TzBaseEnterpriseInfo
>
baseEnterpriseInfoList
=
new
ArrayList
<>();
...
...
@@ -540,16 +518,11 @@ public class TzBaseEnterpriseInfoServiceImpl
return
String
.
join
(
","
,
res
);
}
@Override
public
Map
<
String
,
Object
>
adminInfoUpdate
(
Map
<
String
,
Object
>
map
)
{
//每一个企业只有一个管理员,所以当前登录用户即管理员用户
AgencyUserModel
me
=
Privilege
.
agencyUserClient
.
getme
().
getResult
();
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
webProduct
);
//获取机器人的token,获取不到则去登录
if
(
ObjectUtils
.
isEmpty
(
redisUtil
.
get
(
TZS_USER_TOKEN
)))
{
loginCtiUser
();
}
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
TZS_USER_TOKEN
)));
platformTokenService
.
getToken
();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
if
(!
ObjectUtils
.
isEmpty
(
me
))
{
RegUnitInfo
regUnitInfo
=
new
RegUnitInfo
();
...
...
@@ -574,18 +547,6 @@ public class TzBaseEnterpriseInfoServiceImpl
return
resultMap
;
}
//机器人用户登录
private
void
loginCtiUser
()
{
String
passwd
=
DesUtil
.
encode
(
tzsAdminPwd
,
"qaz"
);
IdPasswordAuthModel
loninData
=
new
IdPasswordAuthModel
();
loninData
.
setLoginId
(
tzsAdminName
);
loninData
.
setPassword
(
passwd
);
FeignClientResult
loginResult
=
Privilege
.
authClient
.
idpassword
(
loninData
);
if
(
loginResult
.
getStatus
()
==
200
)
{
HashMap
resultMap
=
(
HashMap
)
loginResult
.
getResult
();
redisUtil
.
set
(
TZS_USER_TOKEN
,
resultMap
.
get
(
"token"
).
toString
(),
redisRegionTimeSecond
);
}
}
public
void
setSpeUseUnitState
(
int
state
,
SpeUseUnit
speUseUnit
){
...
...
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/resources/application.properties
View file @
1b614da7
...
...
@@ -124,11 +124,7 @@ tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \uFFFD\uFFFD\uFFFD\u06BA\u0172\uFFFD\uFFFD\uFFFD\uFFFD\u00FB\uFFFDid\uFFFD\uFFFD\u01BD\u0328userId\uFFFD\uFFFD
tzs.wechat.test.userId
=
3393279
admin.product
=
AMOS-SERVICE-ADMIN
admin.appkey
=
AMOS_ADMIN
admin.user
=
admin_tzs
admin.password
=
a1234560
admin.product.web
=
AMOS-WEB-ADMIN
amos.secret.key
=
qazknife4j.production=false
knife4j.production
=
false
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/biz/service/impl/StartPlatformTokenService.java
View file @
1b614da7
...
...
@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.cylinder.biz.service.impl;
import
com.yeejoin.amos.boot.module.cylinder.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
...
...
@@ -11,34 +10,16 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
@Service
public
class
StartPlatformTokenService
{
@Value
(
"${admin.product}"
)
String
product
;
@Value
(
"${admin.appkey}"
)
String
appkey
;
@Value
(
"${admin.user}"
)
String
user
;
@Value
(
"${admin.password}"
)
String
password
;
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Autowired
AmosRequestContext
amosRequestContext
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
AmosRequestContext
amosRequestContext
;
public
void
getToken
()
{
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appkey
);
String
token
=
amosRequestContext
.
getToken
();
System
.
out
.
println
(
"token:"
+
token
);
RequestContext
.
setToken
(
token
);
redisUtil
.
set
(
"platform_token"
,
token
);
}
public
void
getToken
()
{
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
}
}
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
1b614da7
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/resources/application.properties
View file @
1b614da7
...
...
@@ -124,11 +124,7 @@ tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \uFFFD\uFFFD\uFFFD\u06BA\u0172\uFFFD\uFFFD\uFFFD\uFFFD\u00FB\uFFFDid\uFFFD\uFFFD\u01BD\u0328userId\uFFFD\uFFFD
tzs.wechat.test.userId
=
3393279
admin.product
=
AMOS-SERVICE-ADMIN
admin.appkey
=
AMOS_ADMIN
admin.user
=
admin_tzs
admin.password
=
a1234560
admin.product.web
=
AMOS-WEB-ADMIN
amos.secret.key
=
qazknife4j.production=false
knife4j.production
=
false
...
...
amos-boot-system-tzs/amos-boot-module-jczs/amos-boot-module-jczs-biz/src/main/java/com/yeejoin/amos/boot/module/jczs/biz/listener/PrivilegeCompanyUpdateAddListener.java
View file @
1b614da7
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.yeejoin.amos.boot.module.jczs.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.jczs.biz.service.impl.TzBaseEnterpriseInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.jczs.api.entity.TzBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.jczs.biz.utils.RedisUtil
;
...
...
@@ -40,11 +41,9 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@
Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
St
ring
appKey
;
@
Autowired
St
artPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
s
,
MqttMessage
message
)
throws
Exception
{
...
...
@@ -58,9 +57,7 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
//判断库中业务tz_base_enterprise_info是否存在
QueryWrapper
<
TzBaseEnterpriseInfo
>
queryWrapper
=
new
QueryWrapper
<
TzBaseEnterpriseInfo
>();
...
...
amos-boot-system-tzs/amos-boot-module-jczs/amos-boot-module-jczs-biz/src/main/java/com/yeejoin/amos/boot/module/jczs/biz/service/impl/StartPlatformTokenService.java
View file @
1b614da7
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jczs
.
biz
.
service
.
impl
;
import
com.yeejoin.amos.boot.module.jczs.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.yeejoin.amos.boot.module.jczs.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
@Service
public
class
StartPlatformTokenService
{
@Value
(
"${admin.product}"
)
String
product
;
@Value
(
"${admin.appkey}"
)
String
appkey
;
@Value
(
"${admin.user}"
)
String
user
;
@Value
(
"${admin.password}"
)
String
password
;
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Autowired
AmosRequestContext
amosRequestContext
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
AmosRequestContext
amosRequestContext
;
public
void
getToken
()
{
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appkey
);
String
token
=
amosRequestContext
.
getToken
();
System
.
out
.
println
(
"token:"
+
token
);
RequestContext
.
setToken
(
token
);
redisUtil
.
set
(
"platform_token"
,
token
);
}
public
void
getToken
()
{
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
}
}
amos-boot-system-tzs/amos-boot-module-jczs/amos-boot-module-jczs-biz/src/main/java/com/yeejoin/amos/boot/module/jczs/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
1b614da7
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-jczs/amos-boot-module-jczs-biz/src/main/resources/application.properties
View file @
1b614da7
...
...
@@ -122,11 +122,7 @@ tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \uFFFD\uFFFD\uFFFD\u06BA\u0172\uFFFD\uFFFD\uFFFD\uFFFD\u00FB\uFFFDid\uFFFD\uFFFD\u01BD\u0328userId\uFFFD\uFFFD
tzs.wechat.test.userId
=
3393279
admin.product
=
AMOS-SERVICE-ADMIN
admin.appkey
=
AMOS_ADMIN
admin.user
=
admin_tzs
admin.password
=
a1234560
admin.product.web
=
AMOS-WEB-ADMIN
amos.secret.key
=
qazknife4j.production=false
knife4j.production
=
false
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/listener/BaseEnterpriseMqTtlListener.java
View file @
1b614da7
This diff is collapsed.
Click to expand it.
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/listener/CarcylUnitInspectMqTtlListener.java
View file @
1b614da7
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tcm
.
biz
.
listener
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.tcm.biz.utils.DesUtil
;
import
com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.ApplicationModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @Description: mqtt监听服务
...
...
@@ -33,78 +31,74 @@ import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public
class
CarcylUnitInspectMqTtlListener
extends
EmqxListener
{
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appkey
;
@Autowired
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${org.filter.group.seq}"
)
private
Long
groupSeq
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
System
.
out
.
println
(
message
);
JSONObject
object
=
null
;
try
{
object
=
JSONObject
.
parseObject
(
message
.
toString
());
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
FeignClientResult
<
List
<
ApplicationModel
>>
aResult
=
Privilege
.
applicationClient
.
queryAgencyApplications
();
List
<
ApplicationModel
>
aList
=
aResult
.
getResult
();
List
<
String
>
appCodes
=
aList
.
stream
().
filter
(
i
->
"监管端,企业端"
.
indexOf
(
i
.
getAppName
())
!=
-
1
)
.
map
(
i
->
i
.
getAppCode
()).
collect
(
Collectors
.
toList
());
@Value
(
"${org.filter.group.seq}"
)
private
Long
groupSeq
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
System
.
out
.
println
(
message
);
JSONObject
object
=
null
;
try
{
object
=
JSONObject
.
parseObject
(
message
.
toString
());
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
platformTokenService
.
setRequestContext
();
FeignClientResult
<
List
<
ApplicationModel
>>
aResult
=
Privilege
.
applicationClient
.
queryAgencyApplications
();
List
<
ApplicationModel
>
aList
=
aResult
.
getResult
();
List
<
String
>
appCodes
=
aList
.
stream
().
filter
(
i
->
"监管端,企业端"
.
indexOf
(
i
.
getAppName
())
!=
-
1
)
.
map
(
i
->
i
.
getAppCode
()).
collect
(
Collectors
.
toList
());
String
uuid
=
object
.
getString
(
"id"
);
Long
id
=
Long
.
valueOf
(
uuid
.
replaceAll
(
"-"
,
""
).
hashCode
());
FeignClientResult
<
CompanyModel
>
cResult
=
Privilege
.
companyClient
.
seleteOne
(
id
);
if
(
cResult
.
getResult
()
==
null
)
{
CompanyModel
companyModel
=
new
CompanyModel
();
companyModel
.
setCompanyName
(
object
.
getString
(
"inspect_unit_name"
));
companyModel
.
setParentId
(
0L
);
companyModel
.
setLevel
(
"company"
);
companyModel
.
setSequenceNbr
(
id
);
companyModel
.
setCompanyCode
(
object
.
getString
(
"org_unit_name"
));
companyModel
.
setCompanyType
(
"检验单位"
);
Privilege
.
companyClient
.
create
(
companyModel
);
}
Long
id
=
Long
.
valueOf
(
uuid
.
replaceAll
(
"-"
,
""
).
hashCode
());
FeignClientResult
<
CompanyModel
>
cResult
=
Privilege
.
companyClient
.
seleteOne
(
id
);
if
(
cResult
.
getResult
()
==
null
)
{
CompanyModel
companyModel
=
new
CompanyModel
();
companyModel
.
setCompanyName
(
object
.
getString
(
"inspect_unit_name"
));
companyModel
.
setParentId
(
0L
);
companyModel
.
setLevel
(
"company"
);
companyModel
.
setSequenceNbr
(
id
);
companyModel
.
setCompanyCode
(
object
.
getString
(
"org_unit_name"
));
companyModel
.
setCompanyType
(
"检验单位"
);
Privilege
.
companyClient
.
create
(
companyModel
);
}
String
unitCode
=
object
.
getString
(
"org_unit_name"
);
if
(
unitCode
==
null
||
unitCode
.
length
()
<
6
)
{
log
.
error
(
"公司统一信用代码长度不够6位"
);
throw
new
Exception
(
"公司统一信用代码长度不够6位"
);
}
String
userName
=
unitCode
.
substring
(
unitCode
.
length
()
-
6
,
unitCode
.
length
());
FeignClientResult
<
AgencyUserModel
>
uResult
=
Privilege
.
agencyUserClient
.
queryByUserName
(
userName
);
if
(
uResult
.
getResult
()
==
null
)
{
AgencyUserModel
userModel
=
new
AgencyUserModel
();
userModel
.
setUserName
(
userName
);
userModel
.
setRealName
(
userName
);
userModel
.
setPassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
userModel
.
setRePassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
// userModel.setMobile(vo.getPhoneNo());
userModel
.
setLockStatus
(
"UNLOCK"
);
FeignClientResult
<
List
<
RoleModel
>>
list
=
Privilege
.
roleClient
.
queryRoleList
(
"检验单位"
,
"admin"
);
Map
<
Long
,
List
<
Long
>>
orgRoles
=
new
HashMap
<>();
List
<
Long
>
roleIds
=
new
ArrayList
<>();
roleIds
.
add
(
list
.
getResult
().
get
(
0
).
getSequenceNbr
());
orgRoles
.
put
(
id
,
roleIds
);
userModel
.
setAppCodes
(
appCodes
);
userModel
.
setOrgRoleSeqs
(
orgRoles
);
FeignClientResult
<
AgencyUserModel
>
userResult
=
Privilege
.
agencyUserClient
.
create
(
userModel
);
String
[]
userIds
=
{
userResult
.
getResult
().
getUserId
()};
String
unitCode
=
object
.
getString
(
"org_unit_name"
);
if
(
unitCode
==
null
||
unitCode
.
length
()
<
6
)
{
log
.
error
(
"公司统一信用代码长度不够6位"
);
throw
new
Exception
(
"公司统一信用代码长度不够6位"
);
}
String
userName
=
unitCode
.
substring
(
unitCode
.
length
()
-
6
,
unitCode
.
length
());
FeignClientResult
<
AgencyUserModel
>
uResult
=
Privilege
.
agencyUserClient
.
queryByUserName
(
userName
);
if
(
uResult
.
getResult
()
==
null
)
{
AgencyUserModel
userModel
=
new
AgencyUserModel
();
userModel
.
setUserName
(
userName
);
userModel
.
setRealName
(
userName
);
userModel
.
setPassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
userModel
.
setRePassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
// userModel.setMobile(vo.getPhoneNo());
userModel
.
setLockStatus
(
"UNLOCK"
);
FeignClientResult
<
List
<
RoleModel
>>
list
=
Privilege
.
roleClient
.
queryRoleList
(
"检验单位"
,
"admin"
);
Map
<
Long
,
List
<
Long
>>
orgRoles
=
new
HashMap
<>();
List
<
Long
>
roleIds
=
new
ArrayList
<>();
roleIds
.
add
(
list
.
getResult
().
get
(
0
).
getSequenceNbr
());
orgRoles
.
put
(
id
,
roleIds
);
userModel
.
setAppCodes
(
appCodes
);
userModel
.
setOrgRoleSeqs
(
orgRoles
);
FeignClientResult
<
AgencyUserModel
>
userResult
=
Privilege
.
agencyUserClient
.
create
(
userModel
);
String
[]
userIds
=
{
userResult
.
getResult
().
getUserId
()};
// if (groupSeq != null) {
// Privilege.groupUserClient.create(groupSeq, Arrays.asList(userIds));
// }
}
}
}
}
}
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/listener/PlatformUserTopicMessage.java
View file @
1b614da7
...
...
@@ -5,16 +5,15 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.tcm.api.service.IEquipmentCategoryService
;
import
com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.tcm.flc.api.service.IRegUnitInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
...
...
@@ -39,23 +38,18 @@ public class PlatformUserTopicMessage extends EmqxListener {
@Autowired
RedisUtils
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appKey
;
@Autowired
IEquipmentCategoryService
equipmentCategoryService
;
@Autowired
IRegUnitInfoService
regUnitInfoService
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
{
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
setRequestContext
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
message
.
toString
());
JSONObject
result
=
jsonObject
.
getJSONObject
(
"result"
);
JSONObject
dataResult
=
result
.
getJSONObject
(
"result"
);
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/listener/PrivilegeCompanyUpdateAddListener.java
View file @
1b614da7
...
...
@@ -5,10 +5,10 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.tcm.biz.service.impl.TzBaseEnterpriseInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil
;
import
com.yeejoin.amos.boot.module.tcm.flc.api.feign.AccessFeignService
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -16,14 +16,16 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.Map
;
@Component
@Slf4j
...
...
@@ -40,11 +42,8 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appKey
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
s
,
MqttMessage
message
)
throws
Exception
{
...
...
@@ -58,15 +57,13 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
setRequestContext
();
//判断库中业务tz_base_enterprise_info是否存在
QueryWrapper
<
TzBaseEnterpriseInfo
>
queryWrapper
=
new
QueryWrapper
<
TzBaseEnterpriseInfo
>();
queryWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
queryWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
TzBaseEnterpriseInfo
tzBaseEnterprisePrivilegeInfo
=
tzBaseEnterpriseInfoService
.
getOne
(
queryWrapper
);
if
(!
ValidationUtil
.
isEmpty
(
tzBaseEnterprisePrivilegeInfo
))
{
if
(!
ValidationUtil
.
isEmpty
(
tzBaseEnterprisePrivilegeInfo
))
{
accessFeignService
.
updateSyncCompanyState
(
object
.
getString
(
"sequence_nbr"
));
return
;
}
...
...
@@ -95,14 +92,14 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
//业务表更新条件构造器
UpdateWrapper
<
TzBaseEnterpriseInfo
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
updateWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
String
regCode
=
object
.
getString
(
"reg_code"
);
CompanyModel
supervisePrivilegeCompanyModel
;
if
(!
ValidationUtil
.
isEmpty
(
regCode
))
{
supervisePrivilegeCompanyModel
=
Privilege
.
companyClient
.
queryByCompanyCode
(
regCode
).
getResult
();
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
supervisePrivilegeCompanyModel
=
Privilege
.
companyClient
.
queryByCompanyCode
(
"610000"
).
getResult
();
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
...
...
@@ -120,37 +117,37 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
tzBaseEnterpriseInfo
.
setSuperviseOrgCode
(
supervisePrivilegeCompanyModel
.
getOrgCode
());
tzBaseEnterpriseInfo
.
setSuperviseOrgName
(
supervisePrivilegeCompanyModel
.
getCompanyName
());
if
(
ValidationUtil
.
isEmpty
(
tzBaseEnterpriseInfo
.
getUnitType
()))
{
if
(
ValidationUtil
.
isEmpty
(
tzBaseEnterpriseInfo
.
getUnitType
()))
{
tzBaseEnterpriseInfo
.
setUnitType
(
""
);
}
try
{
if
(
tzBaseEnterprisePrivilegeInfo
==
null
)
{
if
(
tzBaseEnterprisePrivilegeInfo
==
null
)
{
tzBaseEnterpriseInfoService
.
save
(
tzBaseEnterpriseInfo
);
accessFeignService
.
updateSyncCompanyState
(
object
.
getString
(
"sequence_nbr"
));
return
;
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"【"
+
object
.
getString
(
"unit_name"
)
+
"】许可信息同步【失败】:"
+
e
.
getMessage
());
}
}
public
Map
<
String
,
CompanyModel
>
getCompanyInfoMap
(
Collection
companyModels
,
Map
<
String
,
CompanyModel
>
map
)
{
if
(
companyModels
==
null
)
{
public
Map
<
String
,
CompanyModel
>
getCompanyInfoMap
(
Collection
companyModels
,
Map
<
String
,
CompanyModel
>
map
)
{
if
(
companyModels
==
null
)
{
return
map
;
}
Iterator
iter
=
companyModels
.
iterator
();
while
(
iter
.
hasNext
())
{
while
(
iter
.
hasNext
())
{
String
json
=
JSON
.
toJSONString
(
iter
.
next
());
CompanyModel
companyModel
=
JSON
.
parseObject
(
json
,
CompanyModel
.
class
);
CompanyModel
companyModel
=
JSON
.
parseObject
(
json
,
CompanyModel
.
class
);
String
code
=
companyModel
.
getCompanyCode
();
if
(
code
.
length
()
>=
6
)
{
if
(
code
.
length
()
>=
6
)
{
code
=
code
.
substring
(
0
,
6
);
}
map
.
put
(
code
,
companyModel
);
getCompanyInfoMap
(
companyModel
.
getChildren
(),
map
);
map
.
put
(
code
,
companyModel
);
getCompanyInfoMap
(
companyModel
.
getChildren
(),
map
);
}
return
map
;
}
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/resources/application.properties
View file @
1b614da7
...
...
@@ -132,11 +132,7 @@ tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \uFFFD\uFFFD\uFFFD\u06BA\u0172\uFFFD\uFFFD\uFFFD\uFFFD\u00FB\uFFFDid\uFFFD\uFFFD\u01BD\u0328userId\uFFFD\uFFFD
tzs.wechat.test.userId
=
3393279
admin.product
=
AMOS-SERVICE-ADMIN
admin.appkey
=
AMOS_ADMIN
admin.user
=
admin_tzs
admin.password
=
a1234560
admin.product.web
=
AMOS-WEB-ADMIN
amos.secret.key
=
qazknife4j.production=false
knife4j.production
=
false
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/listener/BaseEnterpriseMqTtlListener.java
View file @
1b614da7
...
...
@@ -11,6 +11,7 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
com.yeejoin.amos.boot.module.ymt.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.DesUtil
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.RedisUtil
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
...
...
@@ -44,11 +45,6 @@ public class BaseEnterpriseMqTtlListener extends EmqxListener {
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appkey
;
@Autowired
RedisUtil
redisUtil
;
...
...
@@ -58,6 +54,9 @@ public class BaseEnterpriseMqTtlListener extends EmqxListener {
@Value
(
"${org.filter.group.seq}"
)
private
Long
groupSeq
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
System
.
out
.
println
(
message
);
...
...
@@ -67,9 +66,7 @@ public class BaseEnterpriseMqTtlListener extends EmqxListener {
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
FeignClientResult
<
List
<
ApplicationModel
>>
aResult
=
Privilege
.
applicationClient
.
queryAgencyApplications
();
List
<
ApplicationModel
>
aList
=
aResult
.
getResult
();
// List<String> appCodes = aList.stream().filter(i -> "监管端,企业端".indexOf(i.getAppName()) != -1)
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/listener/CarcylUnitInspectMqTtlListener.java
View file @
1b614da7
package
com
.
yeejoin
.
amos
.
boot
.
module
.
ymt
.
biz
.
listener
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.ymt.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.DesUtil
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.RedisUtil
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.ApplicationModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @Description: mqtt监听服务
...
...
@@ -33,78 +31,74 @@ import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public
class
CarcylUnitInspectMqTtlListener
extends
EmqxListener
{
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appkey
;
@Autowired
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${org.filter.group.seq}"
)
private
Long
groupSeq
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
System
.
out
.
println
(
message
);
JSONObject
object
=
null
;
try
{
object
=
JSONObject
.
parseObject
(
message
.
toString
());
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
FeignClientResult
<
List
<
ApplicationModel
>>
aResult
=
Privilege
.
applicationClient
.
queryAgencyApplications
();
List
<
ApplicationModel
>
aList
=
aResult
.
getResult
();
List
<
String
>
appCodes
=
aList
.
stream
().
filter
(
i
->
"监管端,企业端"
.
indexOf
(
i
.
getAppName
())
!=
-
1
)
.
map
(
i
->
i
.
getAppCode
()).
collect
(
Collectors
.
toList
());
@Value
(
"${org.filter.group.seq}"
)
private
Long
groupSeq
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
System
.
out
.
println
(
message
);
JSONObject
object
=
null
;
try
{
object
=
JSONObject
.
parseObject
(
message
.
toString
());
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
platformTokenService
.
getToken
();
FeignClientResult
<
List
<
ApplicationModel
>>
aResult
=
Privilege
.
applicationClient
.
queryAgencyApplications
();
List
<
ApplicationModel
>
aList
=
aResult
.
getResult
();
List
<
String
>
appCodes
=
aList
.
stream
().
filter
(
i
->
"监管端,企业端"
.
indexOf
(
i
.
getAppName
())
!=
-
1
)
.
map
(
i
->
i
.
getAppCode
()).
collect
(
Collectors
.
toList
());
String
uuid
=
object
.
getString
(
"id"
);
Long
id
=
Long
.
valueOf
(
uuid
.
replaceAll
(
"-"
,
""
).
hashCode
());
FeignClientResult
<
CompanyModel
>
cResult
=
Privilege
.
companyClient
.
seleteOne
(
id
);
if
(
cResult
.
getResult
()
==
null
)
{
CompanyModel
companyModel
=
new
CompanyModel
();
companyModel
.
setCompanyName
(
object
.
getString
(
"inspect_unit_name"
));
companyModel
.
setParentId
(
0L
);
companyModel
.
setLevel
(
"company"
);
companyModel
.
setSequenceNbr
(
id
);
companyModel
.
setCompanyCode
(
object
.
getString
(
"org_unit_name"
));
companyModel
.
setCompanyType
(
"检验单位"
);
Privilege
.
companyClient
.
create
(
companyModel
);
}
Long
id
=
Long
.
valueOf
(
uuid
.
replaceAll
(
"-"
,
""
).
hashCode
());
FeignClientResult
<
CompanyModel
>
cResult
=
Privilege
.
companyClient
.
seleteOne
(
id
);
if
(
cResult
.
getResult
()
==
null
)
{
CompanyModel
companyModel
=
new
CompanyModel
();
companyModel
.
setCompanyName
(
object
.
getString
(
"inspect_unit_name"
));
companyModel
.
setParentId
(
0L
);
companyModel
.
setLevel
(
"company"
);
companyModel
.
setSequenceNbr
(
id
);
companyModel
.
setCompanyCode
(
object
.
getString
(
"org_unit_name"
));
companyModel
.
setCompanyType
(
"检验单位"
);
Privilege
.
companyClient
.
create
(
companyModel
);
}
String
unitCode
=
object
.
getString
(
"org_unit_name"
);
if
(
unitCode
==
null
||
unitCode
.
length
()
<
6
)
{
log
.
error
(
"公司统一信用代码长度不够6位"
);
throw
new
Exception
(
"公司统一信用代码长度不够6位"
);
}
String
userName
=
unitCode
.
substring
(
unitCode
.
length
()
-
6
,
unitCode
.
length
());
FeignClientResult
<
AgencyUserModel
>
uResult
=
Privilege
.
agencyUserClient
.
queryByUserName
(
userName
);
if
(
uResult
.
getResult
()
==
null
)
{
AgencyUserModel
userModel
=
new
AgencyUserModel
();
userModel
.
setUserName
(
userName
);
userModel
.
setRealName
(
userName
);
userModel
.
setPassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
userModel
.
setRePassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
// userModel.setMobile(vo.getPhoneNo());
userModel
.
setLockStatus
(
"UNLOCK"
);
FeignClientResult
<
List
<
RoleModel
>>
list
=
Privilege
.
roleClient
.
queryRoleList
(
"检验单位"
,
"admin"
);
Map
<
Long
,
List
<
Long
>>
orgRoles
=
new
HashMap
<>();
List
<
Long
>
roleIds
=
new
ArrayList
<>();
roleIds
.
add
(
list
.
getResult
().
get
(
0
).
getSequenceNbr
());
orgRoles
.
put
(
id
,
roleIds
);
userModel
.
setAppCodes
(
appCodes
);
userModel
.
setOrgRoleSeqs
(
orgRoles
);
FeignClientResult
<
AgencyUserModel
>
userResult
=
Privilege
.
agencyUserClient
.
create
(
userModel
);
String
[]
userIds
=
{
userResult
.
getResult
().
getUserId
()};
String
unitCode
=
object
.
getString
(
"org_unit_name"
);
if
(
unitCode
==
null
||
unitCode
.
length
()
<
6
)
{
log
.
error
(
"公司统一信用代码长度不够6位"
);
throw
new
Exception
(
"公司统一信用代码长度不够6位"
);
}
String
userName
=
unitCode
.
substring
(
unitCode
.
length
()
-
6
,
unitCode
.
length
());
FeignClientResult
<
AgencyUserModel
>
uResult
=
Privilege
.
agencyUserClient
.
queryByUserName
(
userName
);
if
(
uResult
.
getResult
()
==
null
)
{
AgencyUserModel
userModel
=
new
AgencyUserModel
();
userModel
.
setUserName
(
userName
);
userModel
.
setRealName
(
userName
);
userModel
.
setPassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
userModel
.
setRePassword
(
DesUtil
.
encode
(
userName
,
secretKey
));
// userModel.setMobile(vo.getPhoneNo());
userModel
.
setLockStatus
(
"UNLOCK"
);
FeignClientResult
<
List
<
RoleModel
>>
list
=
Privilege
.
roleClient
.
queryRoleList
(
"检验单位"
,
"admin"
);
Map
<
Long
,
List
<
Long
>>
orgRoles
=
new
HashMap
<>();
List
<
Long
>
roleIds
=
new
ArrayList
<>();
roleIds
.
add
(
list
.
getResult
().
get
(
0
).
getSequenceNbr
());
orgRoles
.
put
(
id
,
roleIds
);
userModel
.
setAppCodes
(
appCodes
);
userModel
.
setOrgRoleSeqs
(
orgRoles
);
FeignClientResult
<
AgencyUserModel
>
userResult
=
Privilege
.
agencyUserClient
.
create
(
userModel
);
String
[]
userIds
=
{
userResult
.
getResult
().
getUserId
()};
// if (groupSeq != null) {
// Privilege.groupUserClient.create(groupSeq, Arrays.asList(userIds));
// }
}
}
}
}
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/listener/PlatformUserTopicMessage.java
View file @
1b614da7
...
...
@@ -5,16 +5,15 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.ymt.api.service.IEquipmentCategoryService
;
import
com.yeejoin.amos.boot.module.ymt.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.ymt.flc.api.service.IRegUnitInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
...
...
@@ -39,23 +38,18 @@ public class PlatformUserTopicMessage extends EmqxListener {
@Autowired
RedisUtils
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appKey
;
@Autowired
IEquipmentCategoryService
equipmentCategoryService
;
@Autowired
IRegUnitInfoService
regUnitInfoService
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
{
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
message
.
toString
());
JSONObject
result
=
jsonObject
.
getJSONObject
(
"result"
);
JSONObject
dataResult
=
result
.
getJSONObject
(
"result"
);
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/listener/PrivilegeCompanyUpdateAddListener.java
View file @
1b614da7
...
...
@@ -5,10 +5,10 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo
;
import
com.yeejoin.amos.boot.module.ymt.biz.service.impl.StartPlatformTokenService
;
import
com.yeejoin.amos.boot.module.ymt.biz.service.impl.TzBaseEnterpriseInfoServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.RedisUtil
;
import
com.yeejoin.amos.boot.module.ymt.flc.api.feign.AccessFeignService
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -16,14 +16,15 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.Map
;
@Component
@Slf4j
...
...
@@ -40,11 +41,8 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.system.user.product:AMOS_STUDIO_WEB}"
)
String
product
;
@Value
(
"${amos.system.user.app-key:AMOS_STUDIO}"
)
String
appKey
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Override
public
void
processMessage
(
String
s
,
MqttMessage
message
)
throws
Exception
{
...
...
@@ -58,15 +56,13 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公司同步消息解析失败"
);
}
RequestContext
.
setAppKey
(
appKey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
//判断库中业务tz_base_enterprise_info是否存在
QueryWrapper
<
TzBaseEnterpriseInfo
>
queryWrapper
=
new
QueryWrapper
<
TzBaseEnterpriseInfo
>();
queryWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
queryWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
TzBaseEnterpriseInfo
tzBaseEnterprisePrivilegeInfo
=
tzBaseEnterpriseInfoService
.
getOne
(
queryWrapper
);
if
(!
ValidationUtil
.
isEmpty
(
tzBaseEnterprisePrivilegeInfo
))
{
if
(!
ValidationUtil
.
isEmpty
(
tzBaseEnterprisePrivilegeInfo
))
{
accessFeignService
.
updateSyncCompanyState
(
object
.
getString
(
"sequence_nbr"
));
return
;
}
...
...
@@ -95,14 +91,14 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
//业务表更新条件构造器
UpdateWrapper
<
TzBaseEnterpriseInfo
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
updateWrapper
.
eq
(
"use_code"
,
object
.
getString
(
"unit_code"
));
String
regCode
=
object
.
getString
(
"reg_code"
);
CompanyModel
supervisePrivilegeCompanyModel
;
if
(!
ValidationUtil
.
isEmpty
(
regCode
))
{
supervisePrivilegeCompanyModel
=
Privilege
.
companyClient
.
queryByCompanyCode
(
regCode
).
getResult
();
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
supervisePrivilegeCompanyModel
=
Privilege
.
companyClient
.
queryByCompanyCode
(
"610000"
).
getResult
();
if
(
ValidationUtil
.
isEmpty
(
supervisePrivilegeCompanyModel
))
{
...
...
@@ -120,37 +116,37 @@ public class PrivilegeCompanyUpdateAddListener extends EmqxListener {
tzBaseEnterpriseInfo
.
setSuperviseOrgCode
(
supervisePrivilegeCompanyModel
.
getOrgCode
());
tzBaseEnterpriseInfo
.
setSuperviseOrgName
(
supervisePrivilegeCompanyModel
.
getCompanyName
());
if
(
ValidationUtil
.
isEmpty
(
tzBaseEnterpriseInfo
.
getUnitType
()))
{
if
(
ValidationUtil
.
isEmpty
(
tzBaseEnterpriseInfo
.
getUnitType
()))
{
tzBaseEnterpriseInfo
.
setUnitType
(
""
);
}
try
{
if
(
tzBaseEnterprisePrivilegeInfo
==
null
)
{
if
(
tzBaseEnterprisePrivilegeInfo
==
null
)
{
tzBaseEnterpriseInfoService
.
save
(
tzBaseEnterpriseInfo
);
accessFeignService
.
updateSyncCompanyState
(
object
.
getString
(
"sequence_nbr"
));
return
;
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"【"
+
object
.
getString
(
"unit_name"
)
+
"】许可信息同步【失败】:"
+
e
.
getMessage
());
}
}
public
Map
<
String
,
CompanyModel
>
getCompanyInfoMap
(
Collection
companyModels
,
Map
<
String
,
CompanyModel
>
map
)
{
if
(
companyModels
==
null
)
{
public
Map
<
String
,
CompanyModel
>
getCompanyInfoMap
(
Collection
companyModels
,
Map
<
String
,
CompanyModel
>
map
)
{
if
(
companyModels
==
null
)
{
return
map
;
}
Iterator
iter
=
companyModels
.
iterator
();
while
(
iter
.
hasNext
())
{
while
(
iter
.
hasNext
())
{
String
json
=
JSON
.
toJSONString
(
iter
.
next
());
CompanyModel
companyModel
=
JSON
.
parseObject
(
json
,
CompanyModel
.
class
);
CompanyModel
companyModel
=
JSON
.
parseObject
(
json
,
CompanyModel
.
class
);
String
code
=
companyModel
.
getCompanyCode
();
if
(
code
.
length
()
>=
6
)
{
if
(
code
.
length
()
>=
6
)
{
code
=
code
.
substring
(
0
,
6
);
}
map
.
put
(
code
,
companyModel
);
getCompanyInfoMap
(
companyModel
.
getChildren
(),
map
);
map
.
put
(
code
,
companyModel
);
getCompanyInfoMap
(
companyModel
.
getChildren
(),
map
);
}
return
map
;
}
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/service/impl/StartPlatformTokenService.java
View file @
1b614da7
package
com
.
yeejoin
.
amos
.
boot
.
module
.
ymt
.
biz
.
service
.
impl
;
import
com.yeejoin.amos.boot.module.ymt.biz.utils.RedisUtil
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
@Service
public
class
StartPlatformTokenService
{
@Value
(
"${admin.product}"
)
String
product
;
@Value
(
"${admin.appkey}"
)
String
appkey
;
@Value
(
"${admin.user}"
)
String
user
;
@Value
(
"${admin.password}"
)
String
password
;
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Autowired
AmosRequestContext
amosRequestContext
;
@Autowired
RedisUtil
redisUtil
;
@Autowired
AmosRequestContext
amosRequestContext
;
public
void
getToken
()
{
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appkey
);
String
token
=
amosRequestContext
.
getToken
();
System
.
out
.
println
(
"token:"
+
token
);
RequestContext
.
setToken
(
token
);
redisUtil
.
set
(
"platform_token"
,
token
);
}
public
void
getToken
()
{
RequestContext
.
setProduct
(
amosRequestContext
.
getProduct
());
RequestContext
.
setAppKey
(
amosRequestContext
.
getAppKey
());
RequestContext
.
setToken
(
amosRequestContext
.
getToken
());
}
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
1b614da7
...
...
@@ -41,7 +41,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
...
...
@@ -63,15 +62,6 @@ public class TzBaseEnterpriseInfoServiceImpl
@Autowired
RedisUtil
redisUtil
;
@Value
(
"${admin.product}"
)
String
product
;
@Value
(
"${admin.product.web}"
)
String
webProduct
;
@Value
(
"${admin.appkey}"
)
String
appkey
;
@Autowired
private
TzBaseEnterpriseInfoMapper
tzBaseEnterpriseInfoMapper
;
...
...
@@ -84,8 +74,6 @@ public class TzBaseEnterpriseInfoServiceImpl
@Autowired
RegUnitInfoServiceImpl
regUnitInfoService
;
@Autowired
private
IBaseUnitLicenceService
iBaseUnitLicenceService
;
@Autowired
private
SpeUseUnitServiceImpl
speUseUnitService
;
...
...
@@ -94,29 +82,23 @@ public class TzBaseEnterpriseInfoServiceImpl
private
AccessFeignService
accessFeignService
;
@Autowired
private
ITzBaseEnterpriseInfoService
tzBaseEnterpriseInfoService
;
@Autowired
DataDictionaryServiceImpl
iDataDictionaryService
;
@Autowired
RegUnitInfoMapper
regUnitInfoMapper
;
@Value
(
"${tzs.admin.name:tzs_admin}"
)
private
String
tzsAdminName
;
@Value
(
"${tzs.admin.pwd:a1234567}"
)
private
String
tzsAdminPwd
;
@Autowired
StartPlatformTokenService
platformTokenService
;
@Value
(
"${redis.cache.failure.time}"
)
private
Long
redisRegionTimeSecond
;
/**机器人用户token缓存key */
public
static
final
String
TZS_USER_TOKEN
=
"TZS_USER_TOKEN"
;
/**
* 企业管理员变更缓存key前缀
*/
private
final
String
adminChange
=
"ADMIN_CHANGE_"
;
@Autowired
private
EquipmentCategoryServiceImpl
equipmentCategoryService
;
...
...
@@ -313,9 +295,7 @@ public class TzBaseEnterpriseInfoServiceImpl
@Override
public
String
syncEnterpriseInfo
()
{
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
"platform_token"
)));
platformTokenService
.
getToken
();
List
<
TzBaseEnterpriseInfo
>
baseEnterpriseInfoList
=
new
ArrayList
<>();
...
...
@@ -538,16 +518,11 @@ public class TzBaseEnterpriseInfoServiceImpl
return
String
.
join
(
","
,
res
);
}
@Override
public
Map
<
String
,
Object
>
adminInfoUpdate
(
Map
<
String
,
Object
>
map
)
{
//每一个企业只有一个管理员,所以当前登录用户即管理员用户
AgencyUserModel
me
=
Privilege
.
agencyUserClient
.
getme
().
getResult
();
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setProduct
(
webProduct
);
//获取机器人的token,获取不到则去登录
if
(
ObjectUtils
.
isEmpty
(
redisUtil
.
get
(
TZS_USER_TOKEN
)))
{
loginCtiUser
();
}
RequestContext
.
setToken
(
String
.
valueOf
(
redisUtil
.
get
(
TZS_USER_TOKEN
)));
platformTokenService
.
getToken
();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
if
(!
ObjectUtils
.
isEmpty
(
me
))
{
RegUnitInfo
regUnitInfo
=
new
RegUnitInfo
();
...
...
@@ -572,18 +547,6 @@ public class TzBaseEnterpriseInfoServiceImpl
return
resultMap
;
}
//机器人用户登录
private
void
loginCtiUser
()
{
String
passwd
=
DesUtil
.
encode
(
tzsAdminPwd
,
"qaz"
);
IdPasswordAuthModel
loninData
=
new
IdPasswordAuthModel
();
loninData
.
setLoginId
(
tzsAdminName
);
loninData
.
setPassword
(
passwd
);
FeignClientResult
loginResult
=
Privilege
.
authClient
.
idpassword
(
loninData
);
if
(
loginResult
.
getStatus
()
==
200
)
{
HashMap
resultMap
=
(
HashMap
)
loginResult
.
getResult
();
redisUtil
.
set
(
TZS_USER_TOKEN
,
resultMap
.
get
(
"token"
).
toString
(),
redisRegionTimeSecond
);
}
}
public
void
setSpeUseUnitState
(
int
state
,
SpeUseUnit
speUseUnit
){
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/resources/application.properties
View file @
1b614da7
...
...
@@ -122,11 +122,7 @@ tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \uFFFD\uFFFD\uFFFD\u06BA\u0172\uFFFD\uFFFD\uFFFD\uFFFD\u00FB\uFFFDid\uFFFD\uFFFD\u01BD\u0328userId\uFFFD\uFFFD
tzs.wechat.test.userId
=
3393279
admin.product
=
AMOS-SERVICE-ADMIN
admin.appkey
=
AMOS_ADMIN
admin.user
=
admin_tzs
admin.password
=
a1234560
admin.product.web
=
AMOS-WEB-ADMIN
amos.secret.key
=
qazknife4j.production=false
knife4j.production
=
false
...
...
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