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
ac183461
Commit
ac183461
authored
Mar 27, 2023
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
d017cd08
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
40 deletions
+36
-40
AmosMqttListener.java
...n/amos/boot/module/tzs/biz/listener/AmosMqttListener.java
+3
-1
EquipmentCategoryServiceImpl.java
...le/tzs/biz/service/impl/EquipmentCategoryServiceImpl.java
+33
-39
No files found.
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/listener/AmosMqttListener.java
View file @
ac183461
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.tzs.biz.listener;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -12,6 +13,7 @@ import org.typroject.tyboot.component.emq.EmqxListener;
* @author Administrator
*/
@Component
@Slf4j
public
class
AmosMqttListener
extends
EmqxListener
{
@Autowired
...
...
@@ -19,7 +21,7 @@ public class AmosMqttListener extends EmqxListener {
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
mqttMessage
)
{
System
.
out
.
println
(
topic
+
"已收到:准备生成监管码或96333电梯识别码"
);
log
.
info
(
topic
+
"已收到:准备生成监管码或96333电梯识别码"
);
byte
[]
payload
=
mqttMessage
.
getPayload
();
String
str
=
new
String
(
payload
);
String
msg
=
JSON
.
parse
(
str
).
toString
();
...
...
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/EquipmentCategoryServiceImpl.java
View file @
ac183461
...
...
@@ -21,6 +21,7 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.feign.PrivilegeFeginService;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
...
...
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
* @date 2021-10-20
*/
@Service
@Slf4j
public
class
EquipmentCategoryServiceImpl
extends
BaseService
<
EquipmentCategoryDto
,
EquipmentCategory
,
EquipmentCategoryMapper
>
implements
IEquipmentCategoryService
{
@Autowired
...
...
@@ -67,6 +69,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private
static
final
String
PROVINCE
=
"PROVINCE"
;
private
static
final
String
CITY
=
"CITY"
;
private
static
final
String
REGION
=
"REGION"
;
//西安行政区划code
private
static
final
String
XIAN
=
"610100"
;
//判断行政区划查询市还是区
private
static
final
String
END_CODE
=
"0000"
;
/**
...
...
@@ -118,7 +124,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String
companyCode
=
object
.
getString
(
"companyCode"
);
for
(
Map
map
:
mapList
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
equipmentCategoryMapper
.
getCategoryCount
(
map
.
get
(
"code"
).
toString
(),
level
,
orgCode
,
companyCode
);
Map
<
String
,
Object
>
map1
=
equipmentCategoryMapper
.
getCategoryCount
(
map
.
get
(
"code"
).
toString
(),
level
,
orgCode
,
companyCode
);
resultMap
.
put
(
"name"
,
map
.
get
(
"name"
));
resultMap
.
put
(
"image"
,
map
.
get
(
"image"
));
resultMap
.
put
(
"waitClaim"
,
map1
.
get
(
"waitClaim"
));
...
...
@@ -139,10 +145,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
@Override
public
int
createSupervisorCode
(
Map
<
String
,
Object
>
map
,
String
record
)
{
String
city
=
null
;
String
county
=
null
;
String
equipCategory
=
null
;
String
equipList
=
null
;
String
city
,
county
,
equipCategory
,
equipList
;
if
(
ObjectUtils
.
isEmpty
(
record
))
{
//获取对应城市、区县值
city
=
map
.
get
(
"CITY"
).
toString
();
...
...
@@ -152,10 +155,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
equipList
=
map
.
get
(
"EQU_LIST"
).
toString
();
}
else
{
EquInfoDto
equInfoDto
=
categoryOtherInfoMapper
.
selectEquipInfo
(
record
);
if
(
"6035"
.
equals
(
equInfoDto
.
getStatus
()))
{
//判断这条数据是否已经有电梯96333码和监管码
//如果都有则直接返回
if
(
ObjectUtils
.
isEmpty
(
equInfoDto
.
getSupervisor
())
||
ObjectUtils
.
isEmpty
(
equInfoDto
.
getCode
()))
{
//判断这条数据认领状态是否为已认领(6035),且是否已经有电梯96333码和监管码
//如果都满足则直接返回不做生成码操作
if
(
ObjectUtils
.
isEmpty
(
equInfoDto
)
&&
"6035"
.
equals
(
equInfoDto
.
getStatus
())
&&
(
ObjectUtils
.
isEmpty
(
equInfoDto
.
getSupervisor
())
||
ObjectUtils
.
isEmpty
(
equInfoDto
.
getCode
())))
{
city
=
equInfoDto
.
getCity
();
county
=
equInfoDto
.
getCounty
();
equipCategory
=
equInfoDto
.
getEquipCategory
();
...
...
@@ -163,9 +165,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
else
{
return
0
;
}
}
else
{
return
0
;
}
}
//生成码
Map
<
String
,
String
>
codeMap
;
...
...
@@ -174,9 +173,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if
(
ObjectUtils
.
isEmpty
(
codeMap
))
{
return
0
;
}
else
{
System
.
out
.
println
(
record
+
"已生成对应监管码或96333电梯识别码"
);
}
log
.
info
(
record
+
"已生成对应监管码或96333电梯识别码"
);
return
categoryOtherInfoMapper
.
updateSupervisorCode
(
codeMap
.
get
(
"supervisorCode"
),
codeMap
.
get
(
"elevatorCode"
),
record
);
}
...
...
@@ -184,13 +182,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public
List
<
LinkedHashMap
>
getTree
()
{
List
<
LinkedHashMap
>
result
=
(
List
<
LinkedHashMap
>)
redisUtils
.
get
(
REGULATOR_UNIT_TREE
);
//判断redis是否存在管辖机构树
if
(!
ObjectUtils
.
isEmpty
(
result
))
{
// 有直接返回
return
result
;
}
else
{
// 没有则去调用平台fegin接口生成并存储redis
return
creatTree
();
}
return
!
ObjectUtils
.
isEmpty
(
result
)
?
result
:
creatTree
();
}
@Override
...
...
@@ -233,7 +225,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return
ObjectUtils
.
isEmpty
(
list
)
?
getProvinceList
(
level
)
:
list
;
}
else
if
(!
ObjectUtils
.
isEmpty
(
parentId
))
{
String
regionCode
=
parentId
.
split
(
"_"
)[
0
];
Map
<
String
,
Object
>
map
=
regionCode
.
endsWith
(
"0000"
)
?
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
CITY
)
:
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
REGION
);
//regionCode以0000结果查询市、否则查询区
Map
<
String
,
Object
>
map
=
regionCode
.
endsWith
(
END_CODE
)
?
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
CITY
)
:
(
Map
<
String
,
Object
>)
redisUtils
.
get
(
REGION
);
if
(
ObjectUtils
.
isEmpty
(
map
))
{
map
=
getRegionList
();
}
...
...
@@ -245,17 +238,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
public
Map
<
String
,
Object
>
getRegionList
()
{
//查询省下所有的行政区划市,封装并存入redis
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
List
<
LinkedHashMap
>
cityList
;
FeignClientResult
tree
=
privilegeFeginService
.
getTree
();
List
<
LinkedHashMap
>
result
=
(
List
<
LinkedHashMap
>)
tree
.
getResult
();
//获取陕西省regionCode
String
regionCode
=
((
List
<
LinkedHashMap
>)
privilegeFeginService
.
getProvince
(
"1"
).
getResult
()).
get
(
0
).
get
(
"regionCode"
).
toString
();
cityList
=
deleteTreeData
(
result
,
regionCode
);
Map
<
String
,
Object
>
cityMap
=
new
HashMap
<>();
cityMap
.
put
(
regionCode
,
cityList
);
map1
.
put
(
regionCode
,
cityList
);
redisUtils
.
set
(
CITY
,
cityMap
);
//查询市下所有的行政区划区,封装并存入redis
if
(!
ObjectUtils
.
isEmpty
(
cityList
))
{
List
<
LinkedHashMap
>
region
=
(
List
<
LinkedHashMap
>)
privilegeFeginService
.
getTree
().
getResult
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
...
...
@@ -286,6 +281,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return
equipmentCategoryMapper
.
getCategoryAndDefineByRecord
(
record
);
}
/**
* 获取行政区划以市或区的list集合
*
* @param result 需要删除的源数据
* @param type 匹配行政区划的regionCode,获取市则需要传省的regionCode,获取区则需要传市的regionCode
* @return 对应市或区的list集合
*/
private
List
<
LinkedHashMap
>
deleteTreeData
(
List
<
LinkedHashMap
>
result
,
String
type
)
{
Iterator
it
=
result
.
iterator
();
List
<
LinkedHashMap
>
list
=
new
ArrayList
<>();
...
...
@@ -320,12 +322,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//查询对应record对应数据
CategoryOtherInfo
otherInfo
=
categoryOtherInfoMapper
.
selectOne
(
new
QueryWrapper
<
CategoryOtherInfo
>().
eq
(
"RECORD"
,
record
));
if
(!
ObjectUtils
.
isEmpty
(
otherInfo
))
{
//判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
if
(!
ObjectUtils
.
isEmpty
(
otherInfo
.
getSupervisoryCode
()))
{
supervisorCode
=
new
StringBuilder
(
otherInfo
.
getSupervisoryCode
());
}
else
{
//生成对应监管码
if
(!
ObjectUtils
.
isEmpty
(
supervisor
))
{
if
(
supervisor
.
getSupervisoryCode
()
!=
null
)
{
if
(!
ObjectUtils
.
isEmpty
(
supervisor
)
&&
supervisor
.
getSupervisoryCode
()
!=
null
)
{
//获取补零位长度
String
supervisoryCode
=
supervisor
.
getSupervisoryCode
().
substring
(
6
);
long
num
=
Long
.
valueOf
(
supervisoryCode
)
+
1
;
...
...
@@ -340,20 +342,17 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
else
{
supervisorCode
.
append
(
EquipmentCategoryEnum
.
JGM
.
getCode
());
}
}
else
{
supervisorCode
.
append
(
EquipmentCategoryEnum
.
JGM
.
getCode
());
}
}
}
else
{
supervisorCode
=
null
;
}
StringBuilder
elevatorCode
=
new
StringBuilder
();
//判断是否是否需要生成96333电梯码
if
(
EquipmentClassifityEnum
.
DT
.
getCode
().
equals
(
equipList
)
&&
!
"610100"
.
equals
(
city
))
{
if
(!
ObjectUtils
.
isEmpty
(
otherInfo
)
&&
ObjectUtils
.
isEmpty
(
otherInfo
.
getCode
()))
{
List
<
CategoryOtherInfo
>
codeList
=
categoryOtherInfoMapper
.
selectList
(
new
QueryWrapper
<
CategoryOtherInfo
>().
eq
(
"CODE96333"
,
otherInfo
.
getCode
()));
if
(
ObjectUtils
.
isEmpty
(
otherInfo
.
getCode
())
||
ObjectUtils
.
isEmpty
(
codeList
))
{
//判断是否是否需要生成96333电梯码
、这个record对应的otherInfo不为空
if
(
EquipmentClassifityEnum
.
DT
.
getCode
().
equals
(
equipList
)
&&
!
XIAN
.
equals
(
city
)
&&
!
ObjectUtils
.
isEmpty
(
otherInfo
))
{
if
(!
ObjectUtils
.
isEmpty
(
otherInfo
.
getCode
()))
{
elevatorCode
.
append
(
new
StringBuilder
(
otherInfo
.
getCode
()));
}
else
{
//生成生成96333电梯码前缀
Map
<
String
,
Object
>
elevatorMap
=
equipmentCategoryMapper
.
getAdministrativeDivision
(
EquipmentCategoryEnum
.
XZQHDT
.
getCode
(),
county
);
String
elevator
=
ObjectUtils
.
isEmpty
(
elevatorMap
)
?
equipmentCategoryMapper
.
getAdministrativeDivision
(
EquipmentCategoryEnum
.
XZQHDT
.
getCode
(),
city
).
get
(
"code"
).
toString
()
:
elevatorMap
.
get
(
"code"
).
toString
();
...
...
@@ -361,8 +360,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//获取行政区划区县、市是否存在历史96333电梯码
CategoryOtherInfo
elevatorOtherInfo
=
categoryOtherInfoMapper
.
selectElevatorCode
(
elevatorCode
.
toString
());
//生成对应96333电梯码
if
(!
ObjectUtils
.
isEmpty
(
elevatorOtherInfo
))
{
if
(
elevatorOtherInfo
.
getCode
()
!=
null
)
{
if
(!
ObjectUtils
.
isEmpty
(
elevatorOtherInfo
)
&&
elevatorOtherInfo
.
getCode
()
!=
null
)
{
//获取补零位长度
String
elevatorCode1
=
elevatorOtherInfo
.
getCode
().
substring
(
2
);
long
num
=
Long
.
valueOf
(
elevatorCode1
)
+
1
;
...
...
@@ -377,10 +375,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
else
{
elevatorCode
.
append
(
EquipmentCategoryEnum
.
CSM
.
getCode
());
}
}
else
{
elevatorCode
.
append
(
EquipmentCategoryEnum
.
CSM
.
getCode
());
}
}
}
}
if
(
ObjectUtils
.
isEmpty
(
supervisorCode
)
&&
ObjectUtils
.
isEmpty
(
elevatorCode
))
{
...
...
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