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
3a398dda
Commit
3a398dda
authored
Sep 25, 2025
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(jg):压力容器批量导入优化批量生产监管码
parent
940bb024
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
237 additions
and
5 deletions
+237
-5
TzsServiceFeignClient.java
.../amos/boot/module/jg/biz/feign/TzsServiceFeignClient.java
+9
-0
IdxBizJgRegisterInfoServiceImpl.java
.../jg/biz/service/impl/IdxBizJgRegisterInfoServiceImpl.java
+29
-1
SupervisoryCodeInfoMapper.java
...boot/module/ymt/api/mapper/SupervisoryCodeInfoMapper.java
+3
-3
IEquipmentCategoryService.java
...oot/module/ymt/api/service/IEquipmentCategoryService.java
+2
-0
IGenerateCodeService.java
...mos/boot/module/ymt/api/service/IGenerateCodeService.java
+6
-0
EquipmentCategoryMapper.xml
...api/src/main/resources/mapper/EquipmentCategoryMapper.xml
+1
-1
SupervisoryCodeInfoMapper.xml
...i/src/main/resources/mapper/SupervisoryCodeInfoMapper.xml
+11
-0
EquipmentCategoryController.java
...odule/ymt/biz/controller/EquipmentCategoryController.java
+13
-0
EquipmentCategoryServiceImpl.java
...le/ymt/biz/service/impl/EquipmentCategoryServiceImpl.java
+103
-0
GenerateCodeServiceImpl.java
.../module/ymt/biz/service/impl/GenerateCodeServiceImpl.java
+60
-0
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/feign/TzsServiceFeignClient.java
View file @
3a398dda
...
...
@@ -26,6 +26,15 @@ public interface TzsServiceFeignClient {
ResponseModel
<
Map
<
String
,
Object
>>
createCode
(
@RequestBody
Map
<
String
,
Object
>
map
);
/**
* 批量创建监管码-设备导入用
*
* @param map 请求体
* @return
*/
@RequestMapping
(
value
=
"/equipment-category/createSupervisoryCodeBatch"
,
method
=
RequestMethod
.
POST
)
ResponseModel
<
List
<
Map
<
String
,
String
>>>
createCodeBatch
(
@RequestBody
Map
<
String
,
Object
>
map
);
/**
* 创建监管码及96333
*
* @param paramMap 请求体
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/IdxBizJgRegisterInfoServiceImpl.java
View file @
3a398dda
...
...
@@ -4341,6 +4341,14 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
List
<
DictionarieValueModel
>
fillingMedium
=
Systemctl
.
dictionarieClient
.
dictValues
(
"FILLING_MEDIUM"
).
getResult
();
Map
<
String
,
Object
>
fillingMediumMap
=
fillingMedium
.
stream
().
collect
(
Collectors
.
toMap
(
DictionarieValueModel:
:
getDictDataValue
,
DictionarieValueModel:
:
getDictDataKey
));
Iterator
<
String
>
supervisoryCodeIterator
;
if
(
"his"
.
equals
(
equipInfoDto
.
getDataSource
()))
{
supervisoryCodeIterator
=
this
.
getSupervisoryCodeBatch
(
equipInfoDto
.
getPossession
(),
equipInfoDto
.
getEquCategoryCode
(),
equipInfoCylinderExcelDtoList
.
size
())
.
iterator
();
}
else
{
supervisoryCodeIterator
=
Collections
.
emptyIterator
();
}
equipInfoCylinderExcelDtoList
.
forEach
(
data
->
{
JgUseRegistrationEq
jgRelationEquip
=
new
JgUseRegistrationEq
();
if
(
"his"
.
equals
(
equipInfoDto
.
getDataSource
())
&&
"1"
.
equals
(
data
.
getWhetherVehicleCylinder
()))
{
...
...
@@ -4489,7 +4497,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
otherInfo
.
setRecDate
(
new
Date
());
otherInfo
.
setCylinderStampAttachment
(
cylinderStampAttachment
);
if
(
"his"
.
equals
(
equipInfoDto
.
getDataSource
()))
{
otherInfo
.
setSupervisoryCode
(
this
.
getSupervisoryCode
(
equipInfoDto
.
getPossession
(),
registerInfo
.
getEquCategory
()
));
otherInfo
.
setSupervisoryCode
(
supervisoryCodeIterator
.
next
(
));
}
otherInfo
.
setClaimStatus
(
"已认领"
);
otherInfoList
.
add
(
otherInfo
);
...
...
@@ -5128,6 +5136,26 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
.
orElse
(
""
);
}
/**
* 批量生成监管码
*/
public
List
<
String
>
getSupervisoryCodeBatch
(
String
possession
,
String
equCategory
,
int
batchSize
)
{
boolean
isXiXian
=
XI_XIAN
.
getCode
().
equals
(
possession
);
String
cityOrCountyCode
=
isXiXian
?
XIAN_YANG
.
getCode
()
:
possession
;
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"cityCode"
,
cityOrCountyCode
);
params
.
put
(
"isXiXian"
,
isXiXian
?
1
:
0
);
params
.
put
(
"equCategory"
,
equCategory
);
params
.
put
(
"countyCode"
,
cityOrCountyCode
);
params
.
put
(
"batchSize"
,
batchSize
);
return
Optional
.
ofNullable
(
tzsServiceFeignClient
.
createCodeBatch
(
params
).
getResult
())
.
map
(
list
->
list
.
stream
()
.
map
(
res
->
String
.
valueOf
(
res
.
get
(
"superviseCode"
)))
.
collect
(
Collectors
.
toList
()))
.
orElse
(
Collections
.
emptyList
());
}
// 注入依赖
private
void
injectDependencies
(
PressureVesselListener
listener
,
Map
<
String
,
Object
>
paramMap
)
{
listener
.
setIdxBizJgRegisterInfoService
(
idxBizJgRegisterInfoService
);
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/java/com/yeejoin/amos/boot/module/ymt/api/mapper/SupervisoryCodeInfoMapper.java
View file @
3a398dda
package
com
.
yeejoin
.
amos
.
boot
.
module
.
ymt
.
api
.
mapper
;
import
com.
baomidou.mybatisplus.core.mapper.
BaseMapper
;
import
com.
yeejoin.amos.boot.module.common.api.mapper.Custom
BaseMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.SupervisoryCodeInfo
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
...
...
@@ -12,9 +11,10 @@ import java.util.List;
* @author system_generator
* @date 2021-10-20
*/
public
interface
SupervisoryCodeInfoMapper
extends
BaseMapper
<
SupervisoryCodeInfo
>
{
public
interface
SupervisoryCodeInfoMapper
extends
Custom
BaseMapper
<
SupervisoryCodeInfo
>
{
void
updateStatus
(
@Param
(
"superviseCodeList"
)
List
<
String
>
superviseCodeList
);
void
updateStatusBySuperviseCode
(
String
superviseCode
);
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/java/com/yeejoin/amos/boot/module/ymt/api/service/IEquipmentCategoryService.java
View file @
3a398dda
...
...
@@ -23,6 +23,8 @@ public interface IEquipmentCategoryService {
Map
<
String
,
String
>
createSupervisorCode
(
Map
<
String
,
Object
>
map
);
List
<
Map
<
String
,
String
>>
createSupervisoryCodeBatch
(
Map
<
String
,
Object
>
map
);
List
<
LinkedHashMap
>
getTree
();
List
<
LinkedHashMap
>
creatTree
();
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/java/com/yeejoin/amos/boot/module/ymt/api/service/IGenerateCodeService.java
View file @
3a398dda
...
...
@@ -51,6 +51,12 @@ public interface IGenerateCodeService {
* @return 7位监管编码生成
*/
String
createSupervisoryCode
(
String
key
);
/**
* 监管编码生成(7位)-导入批量生成
* @param key key
* @return 7位监管编码生成
*/
List
<
String
>
createSupervisoryCodeBatch
(
String
key
,
int
batchSize
);
String
initCode
();
}
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/resources/mapper/EquipmentCategoryMapper.xml
View file @
3a398dda
...
...
@@ -735,7 +735,7 @@
v2.REC_DATE
FROM "idx_biz_jg_other_info" v1
LEFT JOIN "biz_jg_supervisory_code" v2 on v1.SUPERVISORY_CODE = v2.SUPERVISORY_CODE
WHERE v1."SUPERVISORY_CODE" ~ 'X3
1
' AND v1."CODE96333" ~ '^32'
WHERE v1."SUPERVISORY_CODE" ~ 'X3' AND v1."CODE96333" ~ '^32'
AND v2.create_status = '1'
ORDER BY v2."REC_DATE" DESC
</select>
...
...
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-api/src/main/resources/mapper/SupervisoryCodeInfoMapper.xml
View file @
3a398dda
...
...
@@ -12,4 +12,14 @@
<update
id=
"updateStatusBySuperviseCode"
>
update biz_jg_supervisory_code set status = '1' where supervisory_code = #{superviseCode}
</update>
<insert
id=
"insertBatchSomeColumn"
parameterType=
"java.util.List"
>
INSERT INTO biz_jg_supervisory_code
(sequence_nbr, supervisory_code, code96333, status, create_status)
VALUES
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(#{item.sequenceNbr}, #{item.supervisoryCode}, #{item.code96333}, #{item.status}, #{item.createStatus})
</foreach>
</insert>
</mapper>
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-ymt/amos-boot-module-ymt-biz/src/main/java/com/yeejoin/amos/boot/module/ymt/biz/controller/EquipmentCategoryController.java
View file @
3a398dda
...
...
@@ -276,6 +276,19 @@ public class EquipmentCategoryController extends BaseController {
}
/**
* 批量生成监管码-设备批量导入用
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/createSupervisoryCodeBatch"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"批量生成监管码"
,
notes
=
"生成监管码和96333码"
)
public
ResponseModel
<
Object
>
createSupervisoryCodeBatch
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
return
ResponseHelper
.
buildResponse
(
equipmentCategoryService
.
createSupervisoryCodeBatch
(
map
));
}
/**
* 修改数据状态是否显示编辑按钮
*
* @return
...
...
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/EquipmentCategoryServiceImpl.java
View file @
3a398dda
...
...
@@ -10,6 +10,7 @@ import com.google.common.collect.Lists;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil
;
import
com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory
;
import
com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao
;
import
com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto
;
...
...
@@ -35,6 +36,7 @@ import com.yeejoin.amos.component.feign.utils.FeignUtil;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.lucene.queryparser.classic.QueryParser
;
import
org.elasticsearch.action.search.SearchRequest
;
...
...
@@ -289,6 +291,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private
String
startCode
;
@Autowired
private
SnowflakeIdUtil
sequence
;
@Autowired
private
RedisUtils
redisUtils
;
// 一码通checkCode中redis key过期时间
private
long
time
=
300
l
;
...
...
@@ -467,6 +472,84 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return
codeMap
;
}
/**
* 批量生成监管码
*/
@Override
public
List
<
Map
<
String
,
String
>>
createSupervisoryCodeBatch
(
Map
<
String
,
Object
>
map
)
{
String
city
,
county
,
equipCategory
,
isNotXiXian
,
code96333
,
superviseCode
;
int
batchSize
=
1
;
// 获取对应行政区划
city
=
String
.
valueOf
(
map
.
get
(
"cityCode"
));
county
=
String
.
valueOf
(
map
.
get
(
"countyCode"
));
code96333
=
String
.
valueOf
(
map
.
get
(
"code96333"
));
superviseCode
=
String
.
valueOf
(
map
.
get
(
"superviseCode"
));
// 获取对应设备分类
equipCategory
=
String
.
valueOf
(
map
.
get
(
"equCategory"
));
if
(
"null"
.
equals
(
equipCategory
)
||
"null"
.
equals
(
city
)
||
"null"
.
equals
(
county
))
{
throw
new
BadRequest
(
"请求参数不全,请查看参数中是否携带 cityCode、countyCode、equCategory 三个参数及对应值"
);
}
isNotXiXian
=
Optional
.
ofNullable
(
map
.
get
(
"isXiXian"
)).
orElse
(
"0"
).
toString
();
batchSize
=
(
int
)
Optional
.
ofNullable
(
map
.
get
(
"batchSize"
)).
orElse
(
1
);
// 生成码
List
<
Map
<
String
,
String
>>
codeMapList
=
creatBatchCode
(
isNotXiXian
,
city
,
county
,
equipCategory
,
code96333
,
superviseCode
,
batchSize
);
if
(
ObjectUtils
.
isEmpty
(
codeMapList
))
{
throw
new
BadRequest
(
"该请求参数未生成监管码或96333码,请核对参数"
);
}
return
codeMapList
;
}
/**
* 批量生成监管码
*/
public
List
<
Map
<
String
,
String
>>
creatBatchCode
(
String
isNotXiXian
,
String
city
,
String
county
,
String
equipCategory
,
String
code96333
,
String
supervisionCode
,
int
batchSize
)
{
RLock
lock
=
redissonClient
.
getLock
(
LOCK_KEY
);
List
<
Map
<
String
,
String
>>
resultList
=
new
ArrayList
<>();
try
{
lock
.
lock
();
log
.
info
(
"加锁成功,开始生成 {} 条监管码"
,
batchSize
);
List
<
String
>
supervisorList
=
createSupervisoryCodeBatch
(
isNotXiXian
,
city
,
county
,
equipCategory
,
batchSize
);
if
(
CollectionUtils
.
isEmpty
(
supervisorList
))
{
throw
new
BadRequest
(
"未生成任何监管码,请检查参数"
);
}
String
equState
=
EquipmentCategoryEnum
.
CSZT
.
getCode
();
List
<
SupervisoryCodeInfo
>
supervisoryCodeInfoList
=
new
ArrayList
<>();
for
(
String
supervisorCode
:
supervisorList
)
{
SupervisoryCodeInfo
newInfo
=
new
SupervisoryCodeInfo
();
newInfo
.
setSupervisoryCode
(
supervisorCode
);
newInfo
.
setCode96333
(
code96333
);
newInfo
.
setCreateStatus
(
"INIT"
);
newInfo
.
setStatus
(
equState
);
newInfo
.
setSequenceNbr
(
sequence
.
nextId
());
supervisoryCodeInfoList
.
add
(
newInfo
);
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"superviseCode"
,
supervisorCode
);
resultMap
.
put
(
"code96333"
,
""
);
resultList
.
add
(
resultMap
);
}
supervisoryCodeInfoMapper
.
insertBatchSomeColumn
(
supervisoryCodeInfoList
,
500
);
log
.
info
(
"成功生成 {} 条监管码"
,
resultList
.
size
());
}
catch
(
Exception
e
)
{
log
.
error
(
"批量生成监管码失败"
,
e
);
throw
new
RuntimeException
(
"批量生成监管码失败: "
+
e
.
getMessage
(),
e
);
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
log
.
info
(
"释放锁"
);
}
}
return
resultList
;
}
@Override
public
List
<
LinkedHashMap
>
getTree
()
{
List
<
LinkedHashMap
>
result
=
(
List
<
LinkedHashMap
>)
redisUtils
.
get
(
REGULATOR_UNIT_TREE
);
...
...
@@ -888,6 +971,26 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
/**
* 批量生成监管码-设备批量导入使用
*
* @param city 行政区划市
* @param county 行政区划区
* @return 监管码
*/
public
List
<
String
>
createSupervisoryCodeBatch
(
String
isNotXiXian
,
String
city
,
String
county
,
String
equipCategory
,
int
batchSize
)
{
StringBuilder
supervisorCode
=
new
StringBuilder
();
String
division
=
null
;
if
(((
XIAN
.
equals
(
city
)
||
XIAN_YANG
.
equals
(
city
))
&&
"1"
.
equals
(
isNotXiXian
)))
{
division
=
"X"
;
}
else
{
Map
<
String
,
Object
>
divisionMap
=
equipmentCategoryMapper
.
getAdministrativeDivision
(
EquipmentCategoryEnum
.
XZQH
.
getCode
(),
county
);
division
=
ObjectUtils
.
isEmpty
(
divisionMap
)
?
equipmentCategoryMapper
.
getAdministrativeDivision
(
EquipmentCategoryEnum
.
XZQH
.
getCode
(),
city
).
get
(
"code"
).
toString
()
:
divisionMap
.
get
(
"code"
).
toString
();
}
supervisorCode
.
append
(
division
).
append
(
equipCategory
);
return
generateCodeService
.
createSupervisoryCodeBatch
(
String
.
valueOf
(
supervisorCode
),
batchSize
);
}
/**
* 生成96333电梯识别码
*
* @param prefix 电梯码前缀
...
...
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/GenerateCodeServiceImpl.java
View file @
3a398dda
...
...
@@ -105,6 +105,13 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
return
(
key
.
length
()
==
5
)
?
generateSupervisorySequence
(
key
)
:
"生成码规则不对!"
;
}
public
List
<
String
>
createSupervisoryCodeBatch
(
String
key
,
int
batchSize
)
{
if
(
key
==
null
||
key
.
length
()
!=
5
)
{
return
Collections
.
singletonList
(
"生成码规则不对!"
);
}
return
generateSupervisorySequenceBatch
(
key
,
batchSize
);
}
@Override
public
String
initCode
()
{
categoryOtherInfoMapper
.
selectSupervisorCodeMaxValue
().
forEach
(
vo
->
...
...
@@ -148,6 +155,59 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
}
/**
* 批量生成监管码
*
* @param sequenceKey Redis 中存储的序列 key
* @param batchSize 需要生成的数量
* @return 批量生成的顺序码列表
*/
public
List
<
String
>
generateSupervisorySequenceBatch
(
String
sequenceKey
,
int
batchSize
)
{
RLock
lock
=
redissonClient
.
getLock
(
LOCK_KEY_SUPERVISORY
);
try
{
boolean
locked
=
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
log
.
info
(
"尝试获取锁: {}"
,
locked
);
if
(
locked
)
{
ValueOperations
<
String
,
String
>
valueOps
=
redisTemplate
.
opsForValue
();
String
currentSequenceStr
=
valueOps
.
get
(
sequenceKey
);
// 如果为空,则初始化为0
long
currentSequence
=
(
currentSequenceStr
!=
null
)
?
Long
.
parseLong
(
currentSequenceStr
)
:
this
.
initRedis
(
sequenceKey
);
log
.
info
(
"获取《{}》当前顺序码:{}"
,
sequenceKey
,
currentSequence
);
List
<
String
>
results
=
new
ArrayList
<>(
batchSize
);
for
(
int
i
=
1
;
i
<=
batchSize
;
i
++)
{
long
nextSeq
=
currentSequence
+
i
;
String
formattedSequence
=
String
.
format
(
GenerateCodeServiceImpl
.
SUPERVISOR_SEQUENCE_TYPE
,
nextSeq
);
results
.
add
(
sequenceKey
+
"-"
+
formattedSequence
);
}
// 更新 Redis 里的最新顺序号
long
newSequence
=
currentSequence
+
batchSize
;
valueOps
.
set
(
sequenceKey
,
String
.
valueOf
(
newSequence
));
log
.
info
(
"更新《{}》顺序码到:{}"
,
sequenceKey
,
newSequence
);
return
results
;
}
else
{
throw
new
RuntimeException
(
"Failed to acquire lock for sequence generation"
);
}
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
throw
new
RuntimeException
(
"Thread interrupted while acquiring lock"
,
e
);
}
finally
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
log
.
info
(
"释放锁"
);
}
}
}
/**
* 监管码为空的话,初始化Redis
*
* @param sequenceKey key
...
...
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