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
6f798a50
Commit
6f798a50
authored
May 23, 2024
by
李秀明
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop_dl' into develop_dl
parents
c403cf5a
fb16570d
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
1102 additions
and
75 deletions
+1102
-75
Equipment.java
...java/com/yeejoin/equipmanage/common/entity/Equipment.java
+9
-0
EquipmentCategory.java
.../yeejoin/equipmanage/common/entity/EquipmentCategory.java
+25
-0
WlSpareEquipment.java
...m/yeejoin/equipmanage/common/entity/WlSpareEquipment.java
+141
-0
EquipTypeImgAmountVO.java
...in/equipmanage/common/entity/vo/EquipTypeImgAmountVO.java
+3
-0
WlSpareEquipmentExportVo.java
...quipmanage/common/entity/vo/WlSpareEquipmentExportVo.java
+66
-0
BillContentEnum.java
...com/yeejoin/equipmanage/common/enums/BillContentEnum.java
+2
-1
SingleEnum.java
...java/com/yeejoin/equipmanage/common/enums/SingleEnum.java
+22
-0
EquipmentDate.java
...java/com/yeejoin/equipmanage/common/vo/EquipmentDate.java
+11
-0
EquipmentController.java
...m/yeejoin/equipmanage/controller/EquipmentController.java
+12
-0
EquipmentDetailController.java
...oin/equipmanage/controller/EquipmentDetailController.java
+8
-0
WlSpareEquipmentController.java
...in/equipmanage/controller/WlSpareEquipmentController.java
+241
-0
WlSpareEquipmentMapper.java
...om/yeejoin/equipmanage/mapper/WlSpareEquipmentMapper.java
+19
-0
IEquipmentService.java
...va/com/yeejoin/equipmanage/service/IEquipmentService.java
+3
-0
WlSpareEquipmentService.java
.../yeejoin/equipmanage/service/WlSpareEquipmentService.java
+35
-0
BuildingServiceImpl.java
...yeejoin/equipmanage/service/impl/BuildingServiceImpl.java
+15
-17
EquipmentServiceImpl.java
...eejoin/equipmanage/service/impl/EquipmentServiceImpl.java
+37
-0
FireFightingSystemServiceImpl.java
...uipmanage/service/impl/FireFightingSystemServiceImpl.java
+21
-0
WlSpareEquipmentServiceImpl.java
...equipmanage/service/impl/WlSpareEquipmentServiceImpl.java
+329
-0
FireFightingSystemMapper.xml
...ip/src/main/resources/mapper/FireFightingSystemMapper.xml
+5
-7
WlSpareEquipmentMapper.xml
...quip/src/main/resources/mapper/WlSpareEquipmentMapper.xml
+46
-0
消防装备备品备件导入模板.xlsx
...ystem-equip/src/main/resources/template/消防装备备品备件导入模板.xlsx
+0
-0
KafkaConsumerService.java
.../com/yeejoin/amos/message/kafka/KafkaConsumerService.java
+50
-50
application-dev.properties
...ils-message/src/main/resources/application-dev.properties
+2
-0
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/Equipment.java
View file @
6f798a50
...
...
@@ -110,4 +110,13 @@ public class Equipment extends BaseEntity {
*/
@TableField
(
value
=
"clean_type"
)
private
String
cleanType
=
"0"
;
@TableField
(
exist
=
false
)
private
Long
equipCategoryId
;
// 装备分类id
@TableField
(
exist
=
false
)
private
String
equipCategoryName
;
// 装备分类名称
@TableField
(
exist
=
false
)
private
String
equipCategoryCode
;
// 装备分类编码
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/EquipmentCategory.java
View file @
6f798a50
...
...
@@ -100,4 +100,29 @@ public class EquipmentCategory extends BaseEntity implements TreeNode<EquipmentC
public
int
compareTo
(
EquipmentCategory
o
)
{
return
getId
().
compareTo
(
o
.
getId
());
}
public
void
addCountToParent
()
{
if
(
parentId
!=
0
)
{
EquipmentCategory
parent
=
findParent
(
this
);
if
(
parent
!=
null
)
{
parent
.
setCount
(
parent
.
getCount
()
+
this
.
getCount
());
parent
.
addCountToParent
();
}
}
}
private
EquipmentCategory
findParent
(
EquipmentCategory
node
)
{
for
(
EquipmentCategory
child
:
children
)
{
if
(
child
.
getId
().
equals
(
node
.
getParentId
()))
{
return
child
;
}
else
{
EquipmentCategory
parent
=
findParent
(
child
);
if
(
parent
!=
null
)
{
return
parent
;
}
}
}
return
null
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/WlSpareEquipment.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
common
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.yeejoin.equipmanage.common.entity.publics.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
"wl_spare_equipment"
)
@ApiModel
(
value
=
"WlSpareEquipment对象"
,
description
=
"设备平台备品备件管理"
)
public
class
WlSpareEquipment
extends
BaseEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@TableField
(
"name"
)
private
String
name
;
// 装备名称
@TableField
(
"equip_model_id"
)
private
Long
equipModelId
;
// 装备定义id
@TableField
(
"equip_model_name"
)
private
String
equipModelName
;
// 装备定义名称
@TableField
(
"equip_model_code"
)
private
String
equipModelCode
;
// 装备定义编码
@TableField
(
"equip_category_id"
)
private
Long
equipCategoryId
;
// 装备分类id
@TableField
(
"equip_category_name"
)
private
String
equipCategoryName
;
// 装备分类名称
@TableField
(
"equip_category_code"
)
private
String
equipCategoryCode
;
// 装备分类编码
@TableField
(
"stock_num"
)
private
Float
stockNum
;
// 库存数量
@TableField
(
"manufacturer"
)
private
String
manufacturer
;
// 生产厂家
@TableField
(
"manufacturer_id"
)
private
Long
manufacturerId
;
// 生产厂家id
@TableField
(
"standard"
)
private
String
standard
;
// 规格
@TableField
(
"brand"
)
private
String
brand
;
// 品牌
@TableField
(
"production_date"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
Date
productionDate
;
// 生产日期
@TableField
(
"purchase_date"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
Date
purchaseDate
;
// 采购日期
@TableField
(
"warehouse_structure_id"
)
private
Long
warehouseStructureId
;
// 存储位置id
@TableField
(
"warehouse_structure_code"
)
private
String
warehouseStructureCode
;
// 存储位置code
@TableField
(
"warehouse_structure"
)
private
String
warehouseStructure
;
// 存储位置
@TableField
(
"position"
)
private
String
position
;
// 存储位置详情描述
@TableField
(
"unit"
)
private
String
unit
;
// 计量单位
@TableField
(
"unit_id"
)
private
Long
unitId
;
// 计量单位id
@TableField
(
"remark"
)
private
String
remark
;
// 备注
@TableField
(
"biz_org_name"
)
private
String
bizOrgName
;
// 机构名称
@TableField
(
"biz_org_code"
)
private
String
bizOrgCode
;
// 机构编码
@TableField
(
"single"
)
private
Integer
single
;
// 管理方式(默认单件)
@TableField
(
"is_delete"
)
private
Boolean
isDelete
=
false
;
// 是否删除 0-否 1-是
@TableField
(
exist
=
false
)
private
List
<
UploadFile
>
img
;
@TableField
(
exist
=
false
)
private
List
<
UploadFile
>
video
;
@TableField
(
exist
=
false
)
private
List
<
UploadFile
>
certification
;
@TableField
(
exist
=
false
)
private
List
<
UploadFile
>
instruction
;
@TableField
(
exist
=
false
)
private
List
<
EquProperty
>
equPropertyList
;
@TableField
(
exist
=
false
)
private
List
<
UploadFile
>
quality
;
@TableField
(
exist
=
false
)
private
List
<
UploadFile
>
operation
;
@TableField
(
exist
=
false
)
private
String
agencyId
;
@TableField
(
exist
=
false
)
private
Integer
pageNum
;
@TableField
(
exist
=
false
)
private
Integer
pageSize
;
@TableField
(
exist
=
false
)
private
String
equipmentClassificationCode
;
@TableField
(
exist
=
false
)
private
String
industryCode
;
@TableField
(
exist
=
false
)
private
String
code
;
// 装备定义code筛选字段
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/vo/EquipTypeImgAmountVO.java
View file @
6f798a50
...
...
@@ -79,4 +79,7 @@ public class EquipTypeImgAmountVO {
@ApiModelProperty
(
value
=
"日常运维"
)
private
String
equip
;
@ApiModelProperty
(
value
=
"系统IDs"
)
private
String
systemId
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/vo/WlSpareEquipmentExportVo.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
common
.
entity
.
vo
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
WlSpareEquipmentExportVo
{
@Excel
(
name
=
"装备名称"
)
@ExcelProperty
(
value
=
"装备名称"
,
index
=
0
)
private
String
name
;
// 装备名称
@Excel
(
name
=
"装备编码(从装备定义中获取)"
)
@ExcelProperty
(
value
=
"装备编码(从装备定义中获取)"
,
index
=
1
)
private
String
equipModelCode
;
@Excel
(
name
=
"管理方式(单项管理/批量管理)"
)
@ExcelProperty
(
value
=
"管理方式(单项管理/批量管理)"
,
index
=
2
)
private
String
single
;
@Excel
(
name
=
"数量"
)
@ExcelProperty
(
value
=
"数量"
,
index
=
3
)
private
Float
stockNum
;
// 库存数量
@Excel
(
name
=
"计量单位"
)
@ExcelProperty
(
value
=
"计量单位"
,
index
=
4
)
private
String
unit
;
// 计量单位
@Excel
(
name
=
"规格型号"
)
@ExcelProperty
(
value
=
"规格型号"
,
index
=
5
)
private
String
standard
;
// 规格型号
@Excel
(
name
=
"品牌"
)
@ExcelProperty
(
value
=
"品牌"
,
index
=
6
)
private
String
brand
;
// 品牌
@Excel
(
name
=
"生产厂家名称"
)
@ExcelProperty
(
value
=
"生产厂家名称"
,
index
=
7
)
private
String
manufacturer
;
// 生产厂家
@Excel
(
name
=
"存放位置(建筑或房间编码)"
)
@ExcelProperty
(
value
=
"存放位置(建筑或房间编码)"
,
index
=
8
)
private
String
warehouseStructure
;
// 存储位置
@Excel
(
name
=
"位置信息"
)
@ExcelProperty
(
value
=
"位置信息"
,
index
=
9
)
private
String
position
;
// 存储位置详情描述
@Excel
(
name
=
"生产日期"
)
@ExcelProperty
(
value
=
"生产日期"
,
index
=
10
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
Date
productionDate
;
// 生产日期
@Excel
(
name
=
"采购日期"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@ExcelProperty
(
value
=
"采购日期"
,
index
=
11
)
private
Date
purchaseDate
;
// 采购日期
@Excel
(
name
=
"备注"
)
@ExcelProperty
(
value
=
"备注"
,
index
=
12
)
private
String
remark
;
// 备注
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/BillContentEnum.java
View file @
6f798a50
...
...
@@ -4,7 +4,8 @@ public enum BillContentEnum {
ZB
(
"1"
,
"装备"
,
"equipment"
),
CL
(
"2"
,
"车辆"
,
"car"
),
MHYJ
(
"3"
,
"灭火药剂"
,
"extinguishing "
),
RY
(
"4"
,
"人员"
,
"people"
);
RY
(
"4"
,
"人员"
,
"people"
),
BPBJ
(
"1"
,
"备品备件"
,
"spareEquipment"
);
private
String
name
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/SingleEnum.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
common
.
enums
;
public
enum
SingleEnum
{
PLGL
(
"批量管理"
,
0
),
DXGL
(
"单项管理"
,
1
);
SingleEnum
(
String
name
,
Integer
key
)
{
this
.
name
=
name
;
this
.
key
=
key
;
}
private
String
name
;
private
Integer
key
;
public
String
getName
()
{
return
name
;
}
public
Integer
getKey
()
{
return
key
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/vo/EquipmentDate.java
View file @
6f798a50
...
...
@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.common.vo;
import
com.yeejoin.equipmanage.common.entity.EquipmentDetail
;
import
com.yeejoin.equipmanage.common.entity.EquipmentSpecific
;
import
com.yeejoin.equipmanage.common.entity.WlSpareEquipment
;
/**
* 消防设备
...
...
@@ -13,6 +14,16 @@ public class EquipmentDate {
private
EquipmentDetail
equipmentDetail
;
private
WlSpareEquipment
spareEquipment
;
public
WlSpareEquipment
getSpareEquipment
()
{
return
spareEquipment
;
}
public
void
setSpareEquipment
(
WlSpareEquipment
spareEquipment
)
{
this
.
spareEquipment
=
spareEquipment
;
}
public
EquipmentSpecific
getEquipmentSpecific
()
{
return
equipmentSpecific
;
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/EquipmentController.java
View file @
6f798a50
...
...
@@ -599,6 +599,18 @@ public class EquipmentController extends AbstractBaseController {
return
iEquipmentService
.
listByCategoryId
(
categoryId
);
}
/**
* 装备分类定义数据API【全量】
*
* @return
*/
@RequestMapping
(
value
=
"/equipList"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"装备分类定义数据API【全量】"
,
notes
=
"装备分类定义数据API【全量】"
)
public
List
<
Equipment
>
categoryList
()
{
return
iEquipmentService
.
categoryList
();
}
@RequestMapping
(
value
=
"/listLike/{code}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"列表分页查询"
,
notes
=
"列表分页查询"
)
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/EquipmentDetailController.java
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -127,6 +128,9 @@ public class EquipmentDetailController extends AbstractBaseController {
@Value
(
"${iot.code.prefix.have.used:20210003,20210004,20210005}"
)
private
String
haveUsedIotPrefix
;
@Autowired
private
WlSpareEquipmentService
wlSpareEquipmentService
;
/**
* 新增
*
...
...
@@ -190,6 +194,10 @@ public class EquipmentDetailController extends AbstractBaseController {
}
EquipmentDetailController
controllerProxy
=
SpringUtils
.
getBean
(
EquipmentDetailController
.
class
);
controllerProxy
.
refreshCount
(
vo
.
getBizOrgCode
());
WlSpareEquipment
spareEquipment
=
equipmentDate
.
getSpareEquipment
();
if
(
ObjectUtil
.
isNotEmpty
(
spareEquipment
)
&&
ObjectUtil
.
isNotEmpty
(
spareEquipment
.
getId
()))
{
wlSpareEquipmentService
.
subtractNum
(
spareEquipment
.
getId
(),
Float
.
valueOf
(
vo
.
getNum
()));
}
return
date
;
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/WlSpareEquipmentController.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
controller
;
import
cn.afterturn.easypoi.excel.ExcelImportUtil
;
import
cn.afterturn.easypoi.excel.entity.ImportParams
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.biz.common.excel.ExcelUtil
;
import
com.yeejoin.equipmanage.common.entity.EquipmentCategory
;
import
com.yeejoin.equipmanage.common.entity.WlSpareEquipment
;
import
com.yeejoin.equipmanage.common.entity.vo.WlSpareEquipmentExportVo
;
import
com.yeejoin.equipmanage.common.enums.SingleEnum
;
import
com.yeejoin.equipmanage.common.utils.CommonResponseUtil
;
import
com.yeejoin.equipmanage.common.utils.StringUtil
;
import
com.yeejoin.equipmanage.mapper.WlSpareEquipmentMapper
;
import
com.yeejoin.equipmanage.service.IEquipmentCategoryService
;
import
com.yeejoin.equipmanage.service.WlSpareEquipmentService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.util.UriUtils
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@Api
(
tags
=
"设备平台备品备件管理api"
)
@RequestMapping
(
value
=
"/wl-spare-equipment"
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
class
WlSpareEquipmentController
extends
BaseController
{
@Autowired
WlSpareEquipmentService
wlSpareEquipmentService
;
@Autowired
WlSpareEquipmentMapper
wlSpareEquipmentMapper
;
@Autowired
IEquipmentCategoryService
equipmentCategoryService
;
@Value
(
"${equipment.hierarchy}"
)
private
String
hierarchy
;
@RequestMapping
(
value
=
"/saveOrUpdateSpareEquipment"
,
method
=
RequestMethod
.
POST
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增/编辑"
,
notes
=
"新增/编辑"
)
public
ResponseModel
<
WlSpareEquipment
>
saveOrUpdateSpareEquipment
(
@RequestBody
WlSpareEquipment
wlSpareEquipment
)
{
WlSpareEquipment
data
=
wlSpareEquipmentService
.
saveOrUpdateSpareEquipment
(
wlSpareEquipment
,
getSelectedOrgInfo
());
return
CommonResponseUtil
.
success
(
data
);
}
@RequestMapping
(
value
=
"/deleteByIds"
,
method
=
RequestMethod
.
DELETE
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"DELETE"
,
value
=
"删除"
,
notes
=
"删除"
)
public
ResponseModel
deleteByIds
(
@RequestBody
List
<
Long
>
ids
)
{
wlSpareEquipmentService
.
deleteByIds
(
ids
);
return
CommonResponseUtil
.
success
();
}
@RequestMapping
(
value
=
"/getById"
,
method
=
RequestMethod
.
GET
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"详情"
,
notes
=
"详情"
)
public
ResponseModel
<
WlSpareEquipment
>
getById
(
@RequestParam
Long
id
)
{
ReginParams
selectedOrgInfo
=
getSelectedOrgInfo
();
WlSpareEquipment
wlSpareEquipment
=
wlSpareEquipmentService
.
getById
(
id
);
wlSpareEquipment
.
setAgencyId
(
selectedOrgInfo
.
getPersonIdentity
().
getCompanyId
());
return
CommonResponseUtil
.
success
(
wlSpareEquipment
);
}
@RequestMapping
(
value
=
"/listByPage"
,
method
=
RequestMethod
.
POST
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"列表分页查询"
,
notes
=
"列表分页查询"
)
public
ResponseModel
listByPage
(
@RequestBody
WlSpareEquipment
wlSpareEquipment
)
{
String
[]
result
=
hierarchy
.
split
(
","
);
Map
<
Integer
,
Integer
>
map
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
{
map
.
put
(
i
,
Integer
.
valueOf
(
result
[
i
]));
}
if
(
StringUtil
.
isNotEmpty
(
wlSpareEquipment
.
getEquipmentClassificationCode
()))
{
QueryWrapper
<
EquipmentCategory
>
equipmentCategoryQueryWrapper
=
new
QueryWrapper
<>();
equipmentCategoryQueryWrapper
.
eq
(
"code"
,
wlSpareEquipment
.
getEquipmentClassificationCode
());
equipmentCategoryQueryWrapper
.
eq
(
"industry_code"
,
wlSpareEquipment
.
getIndustryCode
());
List
<
EquipmentCategory
>
equipmentCategoryList
=
equipmentCategoryService
.
list
(
equipmentCategoryQueryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
equipmentCategoryList
))
{
throw
new
RuntimeException
(
"装备定义code有误"
);
}
EquipmentCategory
equipmentCategory
=
equipmentCategoryList
.
get
(
0
);
int
inhierarchy
=
1
;
int
flag
=
0
;
for
(
int
i
=
0
;
i
<
result
.
length
+
1
;
i
++)
{
//进来先判断是否默认就是空,如果为空第一层
if
(
equipmentCategory
.
getParentId
()
==
null
)
{
//判断是否是最下面的子节点
if
(
i
>=
4
)
{
inhierarchy
=
8
;
}
else
{
inhierarchy
=
map
.
get
(
i
);
}
flag
=
i
;
break
;
}
else
{
//查找到循环几次为空
equipmentCategory
=
equipmentCategoryService
.
getById
(
equipmentCategory
.
getParentId
());
}
}
if
(
flag
==
0
)
{
String
classificationCode
=
wlSpareEquipment
.
getEquipmentClassificationCode
().
replaceAll
(
"0+$"
,
""
);
return
CommonResponseUtil
.
success
(
wlSpareEquipmentService
.
listByPage
(
wlSpareEquipment
,
new
Page
<>(
wlSpareEquipment
.
getPageNum
(),
wlSpareEquipment
.
getPageSize
()),
inhierarchy
,
classificationCode
));
}
else
{
String
classificationCode
=
wlSpareEquipment
.
getEquipmentClassificationCode
().
replaceAll
(
"0+$"
,
""
);
return
CommonResponseUtil
.
success
(
wlSpareEquipmentService
.
listByPage
(
wlSpareEquipment
,
new
Page
<>(
wlSpareEquipment
.
getPageNum
(),
wlSpareEquipment
.
getPageSize
()),
inhierarchy
,
classificationCode
.
length
()
%
2
==
0
?
classificationCode
:
classificationCode
+
"0"
));
}
}
Page
<
WlSpareEquipment
>
wlSpareEquipmentPage
=
wlSpareEquipmentService
.
listByPage
(
wlSpareEquipment
,
new
Page
<>(
wlSpareEquipment
.
getPageNum
(),
wlSpareEquipment
.
getPageSize
()),
0
,
null
);
return
CommonResponseUtil
.
success
(
wlSpareEquipmentPage
);
}
/**
* 下载模板
*
* @return
* @Since 2021-3-10
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/downTemplate"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"下载模板"
,
notes
=
"下载模板"
)
public
void
downTemplate
(
HttpServletResponse
response
)
{
// 使用ClassPathResource加载模板文件
try
(
InputStream
inputStream
=
new
ClassPathResource
(
"template/消防装备备品备件导入模板.xlsx"
).
getInputStream
())
{
// 对文件名进行URL编码
String
encodedFilename
=
UriUtils
.
encode
(
"消防装备备品备件导入模板.xlsx"
,
StandardCharsets
.
UTF_8
);
// 设置响应的内容类型为Excel文件的MIME类型
response
.
setContentType
(
String
.
valueOf
(
MediaType
.
parseMediaType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)));
// 设置Content-Disposition头信息,指定文件名
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
encodedFilename
);
// 将输入流的内容复制到响应的输出流
byte
[]
buffer
=
new
byte
[
1024
];
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
buffer
))
!=
-
1
)
{
response
.
getOutputStream
().
write
(
buffer
,
0
,
bytesRead
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"数据导出"
,
notes
=
"数据导出"
)
@PostMapping
(
value
=
"/export"
)
public
void
export
(
HttpServletResponse
response
,
@RequestBody
WlSpareEquipment
dto
)
{
LambdaQueryWrapper
<
WlSpareEquipment
>
lambda
=
new
LambdaQueryWrapper
<>();
lambda
.
eq
(
WlSpareEquipment:
:
getIsDelete
,
false
);
lambda
.
ne
(
WlSpareEquipment:
:
getStockNum
,
0
);
List
<
WlSpareEquipment
>
wlSpareEquipments
=
wlSpareEquipmentMapper
.
selectList
(
lambda
);
List
<
WlSpareEquipmentExportVo
>
exportList
=
new
ArrayList
<>();
wlSpareEquipments
.
forEach
(
item
->
{
WlSpareEquipmentExportVo
exportVo
=
new
WlSpareEquipmentExportVo
();
BeanUtils
.
copyProperties
(
item
,
exportVo
,
"single"
);
exportVo
.
setSingle
(
SingleEnum
.
DXGL
.
getKey
().
equals
(
item
.
getSingle
())
?
"单项管理"
:
"批量管理"
);
exportList
.
add
(
exportVo
);
});
ExcelUtil
.
createTemplate
(
response
,
"消防装备备品备件"
,
"备品备件信息"
,
exportList
,
WlSpareEquipmentExportVo
.
class
,
null
,
false
);
}
/**
* 设备信息导入
*
* @return
*/
@PostMapping
(
value
=
"/uploadList"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"导入"
,
notes
=
"导入"
)
public
ResponseModel
uploadList
(
MultipartFile
file
)
{
try
{
// 设置导入参数
ImportParams
params
=
new
ImportParams
();
params
.
setTitleRows
(
0
);
// 标题行数
params
.
setHeadRows
(
1
);
// 表头行数
// 导入数据
List
<
WlSpareEquipmentExportVo
>
list
=
ExcelImportUtil
.
importExcel
(
file
.
getInputStream
(),
WlSpareEquipmentExportVo
.
class
,
params
);
// 处理导入的数据,例如保存到数据库中
wlSpareEquipmentService
.
saveImportBatch
(
list
,
getSelectedOrgInfo
());
// JSON.toJSONString(list)
return
CommonResponseUtil
.
success
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
CommonResponseUtil
.
failure
(
"导入失败"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
CommonResponseUtil
.
success
();
}
/**
* 获取装备类型和统计值
*
* @throws Exception
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"获取装备类型和统计值"
,
notes
=
"获取装备类型和统计值"
)
@GetMapping
(
value
=
"/getEquipmentTypeAndCount/tree"
)
public
ResponseModel
getEquipmentTypeAndCount
(
@RequestParam
(
required
=
false
)
String
bizOrgCode
)
throws
Exception
{
if
(
StrUtil
.
isEmpty
(
bizOrgCode
))
{
bizOrgCode
=
getSelectedOrgInfo
().
getPersonIdentity
().
getCompanyBizOrgCode
();
}
return
CommonResponseUtil
.
success
(
wlSpareEquipmentService
.
getEquipmentTypeAndCount
(
bizOrgCode
));
}
@RequestMapping
(
value
=
"/countSpareEquip"
,
method
=
RequestMethod
.
GET
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"卡片数量统计"
,
notes
=
"卡片数量统计"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
countSpareEquip
(
@RequestParam
(
required
=
false
)
String
bizOrgCode
)
{
if
(
StrUtil
.
isEmpty
(
bizOrgCode
))
{
bizOrgCode
=
getSelectedOrgInfo
().
getPersonIdentity
().
getCompanyBizOrgCode
();
}
Map
<
String
,
Object
>
resultMap
=
wlSpareEquipmentService
.
countSpareEquip
(
bizOrgCode
);
return
CommonResponseUtil
.
success
(
resultMap
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/mapper/WlSpareEquipmentMapper.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.equipmanage.common.entity.WlSpareEquipment
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Map
;
public
interface
WlSpareEquipmentMapper
extends
BaseMapper
<
WlSpareEquipment
>
{
Page
<
WlSpareEquipment
>
listByPage
(
@Param
(
"page"
)
Page
page
,
@Param
(
"dto"
)
WlSpareEquipment
dto
,
@Param
(
"hierarchy"
)
int
hierarchy
,
@Param
(
"codeHead"
)
String
codeHead
);
Map
<
String
,
Object
>
countSpareEquip
(
@Param
(
"bizOrgCode"
)
String
bizOrgCode
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IEquipmentService.java
View file @
6f798a50
...
...
@@ -128,4 +128,7 @@ public interface IEquipmentService extends IService<Equipment> {
EquipmentVo
getEquipBySpecific
(
Long
equipmentSpecificId
);
List
<
Equipment
>
getAllByCode
(
String
id
);
List
<
Equipment
>
categoryList
();
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/WlSpareEquipmentService.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.equipmanage.common.entity.EquipmentCategory
;
import
com.yeejoin.equipmanage.common.entity.WlSpareEquipment
;
import
com.yeejoin.equipmanage.common.entity.vo.WlSpareEquipmentExportVo
;
import
com.yeejoin.equipmanage.common.vo.EquipmentDate
;
import
java.util.List
;
import
java.util.Map
;
public
interface
WlSpareEquipmentService
{
/**
* 新增/编辑
*/
WlSpareEquipment
saveOrUpdateSpareEquipment
(
WlSpareEquipment
wlSpareEquipment
,
ReginParams
reginParams
);
/**
* 删除
*/
int
deleteByIds
(
List
<
Long
>
ids
);
WlSpareEquipment
getById
(
Long
id
);
Page
<
WlSpareEquipment
>
listByPage
(
WlSpareEquipment
dto
,
Page
page
,
int
hierarchy
,
String
codeHead
);
void
saveImportBatch
(
List
<
WlSpareEquipmentExportVo
>
list
,
ReginParams
reginParams
);
void
subtractNum
(
Long
id
,
Float
num
);
List
<
EquipmentCategory
>
getEquipmentTypeAndCount
(
String
bizOrgCode
);
Map
<
String
,
Object
>
countSpareEquip
(
String
bizOrgCode
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/BuildingServiceImpl.java
View file @
6f798a50
...
...
@@ -710,25 +710,23 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
@Override
public
List
<
PointTreeVo
>
getBuildTreeNot
(
String
bizOrgCode
)
{
List
<
PointTreeVo
>
responses
=
this
.
baseMapper
.
getBuildList
(
bizOrgCode
,
null
);
List
<
PointTreeVo
>
treeList
=
new
ArrayList
<>();
List
<
PointTreeVo
>
responses
=
this
.
baseMapper
.
getBuildList
(
bizOrgCode
,
null
);
Map
<
Long
,
PointTreeVo
>
nodeMap
=
responses
.
parallelStream
().
collect
(
Collectors
.
toMap
(
PointTreeVo:
:
getSequenceNbr
,
t
->
t
));
List
<
PointTreeVo
>
treeList
=
responses
.
parallelStream
()
.
filter
(
node
->
node
.
getParentId
()
==
null
||
node
.
getParentId
()
==
-
1
)
.
map
(
node
->
buildTree
(
node
,
nodeMap
))
.
collect
(
Collectors
.
toList
());
return
treeList
;
}
for
(
PointTreeVo
tree
:
responses
)
{
if
(
tree
.
getParentId
()
==
null
||
tree
.
getParentId
()
==
-
1
)
{
treeList
.
add
(
tree
);
}
for
(
PointTreeVo
treeNode
:
responses
)
{
if
(
tree
.
getSequenceNbr
().
equals
(
treeNode
.
getParentId
()))
{
if
(
tree
.
getChildren
()
==
null
)
{
tree
.
setChildren
(
new
ArrayList
<>());
}
tree
.
getChildren
().
add
(
treeNode
);
}
}
private
PointTreeVo
buildTree
(
PointTreeVo
node
,
Map
<
Long
,
PointTreeVo
>
nodeMap
)
{
if
(
node
.
getChildren
()
==
null
)
{
node
.
setChildren
(
new
ArrayList
<>());
}
return
treeList
;
nodeMap
.
values
().
parallelStream
()
.
filter
(
childNode
->
childNode
.
getParentId
().
equals
(
node
.
getSequenceNbr
()))
.
forEach
(
childNode
->
node
.
getChildren
().
add
(
buildTree
(
childNode
,
nodeMap
)));
return
node
;
}
@Override
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EquipmentServiceImpl.java
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
@@ -18,6 +19,7 @@ import com.yeejoin.equipmanage.service.IEquipmentDetailService;
import
com.yeejoin.equipmanage.service.IEquipmentIndexService
;
import
com.yeejoin.equipmanage.service.IEquipmentService
;
import
com.yeejoin.equipmanage.service.IUnitService
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -347,6 +349,41 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
}
@Override
public
List
<
Equipment
>
categoryList
()
{
List
<
Equipment
>
list
=
this
.
list
();
Map
<
String
,
List
<
EquipmentIndex
>>
equipmentIndexMap
=
iEquipmentIndexService
.
list
().
stream
()
.
collect
(
Collectors
.
groupingBy
(
EquipmentIndex:
:
getEquipmentId
));
Map
<
Long
,
Unit
>
unitMap
=
iUnitService
.
list
().
stream
().
collect
(
Collectors
.
toMap
(
Unit:
:
getId
,
t
->
t
));
Map
<
Long
,
EquipmentCategory
>
categoryMap
=
equipmentCategoryMapper
.
selectList
(
null
).
stream
().
collect
(
Collectors
.
toMap
(
EquipmentCategory:
:
getId
,
t
->
t
));
for
(
Equipment
equipment
:
list
)
{
List
<
EquipmentIndex
>
quotaList
=
equipmentIndexMap
.
get
(
equipment
.
getId
().
toString
());
List
<
EquProperty
>
properList
=
new
ArrayList
<
EquProperty
>();
if
(
CollUtil
.
isNotEmpty
(
quotaList
))
{
for
(
EquipmentIndex
equipmentIndex
:
quotaList
)
{
EquProperty
equProperty
=
new
EquProperty
();
equProperty
.
setEquipmentIndexId
(
equipmentIndex
.
getId
());
equProperty
.
setPerfQuotaName
(
equipmentIndex
.
getPerfQuotaName
());
equProperty
.
setEquipmentIndexName
(
equipmentIndex
.
getPerfQuotaName
());
equProperty
.
setGroupName
(
equipmentIndex
.
getGroupName
());
equProperty
.
setValue
(
equipmentIndex
.
getPerfValue
());
equProperty
.
setUnitName
(
equipmentIndex
.
getUnitName
());
equProperty
.
setEquipmentIndexKey
(
equipmentIndex
.
getPerfQuotaDefinitionId
());
properList
.
add
(
equProperty
);
}
}
EquipmentCategory
equipmentCategory
=
categoryMap
.
get
(
equipment
.
getCategoryId
());
if
(
ObjectUtils
.
isNotEmpty
(
equipmentCategory
))
{
equipment
.
setEquipCategoryId
(
equipmentCategory
.
getId
());
equipment
.
setEquipCategoryCode
(
equipmentCategory
.
getCode
());
equipment
.
setEquipCategoryName
(
equipmentCategory
.
getName
());
}
equipment
.
setEquPropertyList
(
properList
);
equipment
.
setUnit
(
unitMap
.
get
(
equipment
.
getUnitId
()));
}
return
list
;
}
@Override
public
EquipmentAppVO
getEquipmentAppMessage
(
String
qrCode
)
{
EquipmentAppVO
equipmentApp
=
new
EquipmentAppVO
();
//设备信息参数
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/FireFightingSystemServiceImpl.java
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -1010,11 +1011,31 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
IPage
<
EquipTypeImgAmountVO
>
list
=
fireFightingSystemMapper
.
getColaCategoryAmountEquList
(
equipTypeAmountPage
.
getPage
(),
hierarchy
,
codeHead
,
equipTypeAmountPage
);
ArrayList
<
String
>
systemIds
=
new
ArrayList
<>();
list
.
getRecords
().
forEach
(
x
->
{
if
(!
x
.
getEqtype
().
startsWith
(
"4"
)
&&
StringUtil
.
isNotEmpty
(
x
.
getAmount
()))
{
x
.
setAmount
(
x
.
getAmount
().
split
(
"\\."
)[
0
]);
}
if
(
StringUtil
.
isNotEmpty
(
x
.
getSystemId
()))
{
List
<
String
>
systemId
=
Arrays
.
asList
(
x
.
getSystemId
().
split
(
","
));
systemIds
.
addAll
(
systemId
);
}
});
if
(
CollUtil
.
isNotEmpty
(
systemIds
))
{
LambdaQueryWrapper
<
FireFightingSystemEntity
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
FireFightingSystemEntity:
:
getId
,
systemIds
);
List
<
FireFightingSystemEntity
>
fireSystemList
=
fireFightingSystemMapper
.
selectList
(
wrapper
);
Map
<
String
,
String
>
systemNameMap
=
fireSystemList
.
stream
().
collect
(
Collectors
.
toMap
(
t
->
t
.
getId
().
toString
(),
FireFightingSystemEntity:
:
getName
));
list
.
getRecords
().
parallelStream
().
forEach
(
item
->
{
if
(
StringUtil
.
isNotEmpty
(
item
.
getSystemId
()))
{
ArrayList
<
String
>
systemNames
=
new
ArrayList
<>();
List
<
String
>
systemIdList
=
Arrays
.
asList
(
item
.
getSystemId
().
split
(
","
));
systemIdList
.
parallelStream
().
forEach
(
id
->
systemNames
.
add
(
systemNameMap
.
getOrDefault
(
id
,
""
)));
String
join
=
String
.
join
(
","
,
systemNames
);
item
.
setSystemName
(
join
);
}
});
}
return
list
;
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/WlSpareEquipmentServiceImpl.java
0 → 100644
View file @
6f798a50
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.ObjectUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Sequence
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.equipmanage.common.entity.*
;
import
com.yeejoin.equipmanage.common.entity.vo.WlSpareEquipmentExportVo
;
import
com.yeejoin.equipmanage.common.enums.BillContentEnum
;
import
com.yeejoin.equipmanage.common.enums.FileTypeEnum
;
import
com.yeejoin.equipmanage.common.enums.SingleEnum
;
import
com.yeejoin.equipmanage.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.equipmanage.mapper.UnitMapper
;
import
com.yeejoin.equipmanage.mapper.WarehouseStructureMapper
;
import
com.yeejoin.equipmanage.mapper.WlSpareEquipmentMapper
;
import
com.yeejoin.equipmanage.service.*
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
public
class
WlSpareEquipmentServiceImpl
extends
ServiceImpl
<
WlSpareEquipmentMapper
,
WlSpareEquipment
>
implements
WlSpareEquipmentService
{
@Autowired
WlSpareEquipmentMapper
wlSpareEquipmentMapper
;
@Autowired
IEquipmentCategoryService
iEquipmentCategoryService
;
@Value
(
"${equipment.type}"
)
String
equipmentCategoryLeftTypeCode
;
@Autowired
private
Sequence
sequence
;
@Autowired
private
IUploadFileService
iUploadFileService
;
@Autowired
private
EquipmentServiceImpl
equipmentService
;
@Autowired
private
EquipmentCategoryMapper
equipmentCategoryMapper
;
@Autowired
IManufacturerInfoService
iManufacturerInfoService
;
@Autowired
WarehouseStructureMapper
warehouseStructureMapper
;
@Autowired
UnitMapper
unitMapper
;
@Override
public
WlSpareEquipment
saveOrUpdateSpareEquipment
(
WlSpareEquipment
wlSpareEquipment
,
ReginParams
reginParams
)
{
wlSpareEquipment
.
setBizOrgName
(
reginParams
.
getPersonIdentity
().
getCompanyName
());
wlSpareEquipment
.
setBizOrgCode
(
reginParams
.
getPersonIdentity
().
getCompanyBizOrgCode
());
WarehouseStructure
warehouseStructure
=
warehouseStructureMapper
.
selectById
(
wlSpareEquipment
.
getWarehouseStructureId
());
wlSpareEquipment
.
setWarehouseStructureCode
(
warehouseStructure
.
getCode
());
if
(
ObjectUtils
.
isEmpty
(
wlSpareEquipment
.
getId
()))
{
wlSpareEquipmentMapper
.
insert
(
wlSpareEquipment
);
}
else
{
wlSpareEquipmentMapper
.
updateById
(
wlSpareEquipment
);
QueryWrapper
<
UploadFile
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
lambda
().
eq
(
UploadFile:
:
getObjectType
,
BillContentEnum
.
BPBJ
.
getKey
())
.
eq
(
UploadFile:
:
getObjectId
,
wlSpareEquipment
.
getId
());
iUploadFileService
.
remove
(
queryWrapper
);
}
saveUploadFile
(
wlSpareEquipment
);
return
wlSpareEquipment
;
}
/**
* 插入文件信息
*/
private
void
saveUploadFile
(
WlSpareEquipment
wlSpareEquipment
)
{
List
<
UploadFile
>
fileList
=
new
ArrayList
<>();
fileList
.
addAll
(
fillFileList
(
wlSpareEquipment
.
getImg
(),
wlSpareEquipment
.
getId
(),
FileTypeEnum
.
image
.
toString
()));
fileList
.
addAll
(
fillFileList
(
wlSpareEquipment
.
getVideo
(),
wlSpareEquipment
.
getId
(),
FileTypeEnum
.
video
.
toString
()));
fileList
.
addAll
(
fillFileList
(
wlSpareEquipment
.
getCertification
(),
wlSpareEquipment
.
getId
(),
FileTypeEnum
.
certificate
.
toString
()));
fileList
.
addAll
(
fillFileList
(
wlSpareEquipment
.
getInstruction
(),
wlSpareEquipment
.
getId
(),
FileTypeEnum
.
instruction
.
toString
()));
fileList
.
addAll
(
fillFileList
(
wlSpareEquipment
.
getQuality
(),
wlSpareEquipment
.
getId
(),
FileTypeEnum
.
quality
.
toString
()));
fileList
.
addAll
(
fillFileList
(
wlSpareEquipment
.
getOperation
(),
wlSpareEquipment
.
getId
(),
FileTypeEnum
.
operation
.
toString
()));
iUploadFileService
.
saveBatch
(
fileList
);
}
private
List
<
UploadFile
>
fillFileList
(
List
<
UploadFile
>
list
,
Long
id
,
String
type
)
{
if
(
list
==
null
)
{
return
new
ArrayList
<
UploadFile
>();
}
list
.
forEach
(
item
->
{
item
.
setUrl
(
item
.
getUrl
());
item
.
setId
(
sequence
.
nextId
());
item
.
setFileType
(
type
);
item
.
setObjectType
(
BillContentEnum
.
BPBJ
.
getKey
());
item
.
setObjectId
(
id
);
});
return
list
;
}
@Override
public
int
deleteByIds
(
List
<
Long
>
ids
)
{
LambdaUpdateWrapper
<
WlSpareEquipment
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
// 设置更新条件,例如:根据主键 id 列表进行更新
updateWrapper
.
in
(
WlSpareEquipment:
:
getId
,
ids
);
// 设置更新内容,例如:将字段 field1 的值更新为 newValue
updateWrapper
.
set
(
WlSpareEquipment:
:
getIsDelete
,
true
);
return
wlSpareEquipmentMapper
.
update
(
null
,
updateWrapper
);
}
@Override
public
WlSpareEquipment
getById
(
Long
id
)
{
WlSpareEquipment
wlSpareEquipment
=
wlSpareEquipmentMapper
.
selectById
(
id
);
wlSpareEquipment
.
setImg
(
getEquipFileList
(
id
,
FileTypeEnum
.
image
.
toString
()));
wlSpareEquipment
.
setVideo
(
getEquipFileList
(
id
,
FileTypeEnum
.
video
.
toString
()));
wlSpareEquipment
.
setCertification
(
getEquipFileList
(
id
,
FileTypeEnum
.
certificate
.
toString
()));
wlSpareEquipment
.
setInstruction
(
getEquipFileList
(
id
,
FileTypeEnum
.
instruction
.
toString
()));
wlSpareEquipment
.
setQuality
(
getEquipFileList
(
id
,
FileTypeEnum
.
quality
.
toString
()));
wlSpareEquipment
.
setOperation
(
getEquipFileList
(
id
,
FileTypeEnum
.
operation
.
toString
()));
return
wlSpareEquipment
;
}
private
List
<
UploadFile
>
getEquipFileList
(
Long
id
,
String
type
)
{
List
<
UploadFile
>
list
=
iUploadFileService
.
list
(
new
QueryWrapper
<
UploadFile
>().
eq
(
"object_id"
,
id
)
.
eq
(
"object_type"
,
BillContentEnum
.
BPBJ
.
getKey
()).
eq
(
"file_type"
,
type
));
list
.
forEach
(
item
->
{
item
.
setUrl
(
item
.
getUrl
());
});
return
list
;
}
@Override
public
Page
<
WlSpareEquipment
>
listByPage
(
WlSpareEquipment
dto
,
Page
page
,
int
hierarchy
,
String
codeHead
)
{
return
wlSpareEquipmentMapper
.
listByPage
(
page
,
dto
,
hierarchy
,
codeHead
);
}
@Override
public
void
saveImportBatch
(
List
<
WlSpareEquipmentExportVo
>
list
,
ReginParams
reginParams
)
{
List
<
String
>
equipModelCodeList
=
new
ArrayList
<>();
List
<
String
>
warehouseStructureList
=
new
ArrayList
<>();
List
<
String
>
unitList
=
new
ArrayList
<>();
list
.
stream
().
forEach
(
item
->
{
if
(
StrUtil
.
isEmpty
(
item
.
getEquipModelCode
()))
{
throw
new
BadRequest
(
"装备编码(从装备定义中获取)项不能为空"
);
}
equipModelCodeList
.
add
(
item
.
getEquipModelCode
());
warehouseStructureList
.
add
(
item
.
getWarehouseStructure
());
unitList
.
add
(
item
.
getUnit
());
});
// 装备定义数据
LambdaQueryWrapper
<
Equipment
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
Equipment:
:
getCode
,
equipModelCodeList
);
List
<
Equipment
>
equipmentList
=
equipmentService
.
list
(
wrapper
);
// 装备定义
Map
<
String
,
Equipment
>
equipmentMap
=
new
HashMap
<>();
// 装备分类IDs
List
<
Long
>
equipCategoryIds
=
new
ArrayList
<>();
equipmentList
.
stream
().
forEach
(
item
->
{
equipmentMap
.
put
(
item
.
getCode
(),
item
);
equipCategoryIds
.
add
(
item
.
getCategoryId
());
});
// 装备分类数据
LambdaQueryWrapper
<
EquipmentCategory
>
categoryWrapper
=
new
LambdaQueryWrapper
<>();
categoryWrapper
.
in
(
EquipmentCategory:
:
getId
,
equipCategoryIds
);
Map
<
Long
,
EquipmentCategory
>
categoryMap
=
equipmentCategoryMapper
.
selectList
(
categoryWrapper
).
stream
().
collect
(
Collectors
.
toMap
(
EquipmentCategory:
:
getId
,
t
->
t
));
// 生产厂家数据
List
<
ManufacturerInfo
>
manufacturerInfos
=
iManufacturerInfoService
.
list
();
Map
<
String
,
ManufacturerInfo
>
manufacturerMap
=
manufacturerInfos
.
stream
().
collect
(
Collectors
.
toMap
(
ManufacturerInfo:
:
getName
,
t
->
t
));
// 存放位置
LambdaQueryWrapper
<
WarehouseStructure
>
warehouseLambda
=
new
LambdaQueryWrapper
<>();
warehouseLambda
.
in
(
WarehouseStructure:
:
getCode
,
warehouseStructureList
);
Map
<
String
,
WarehouseStructure
>
structureMap
=
warehouseStructureMapper
.
selectList
(
warehouseLambda
).
stream
().
collect
(
Collectors
.
toMap
(
WarehouseStructure:
:
getCode
,
t
->
t
));
// 单位
LambdaQueryWrapper
<
Unit
>
unitLambda
=
new
LambdaQueryWrapper
<>();
unitLambda
.
in
(
Unit:
:
getName
,
unitList
);
unitLambda
.
groupBy
(
Unit:
:
getName
);
Map
<
String
,
Long
>
unitMap
=
unitMapper
.
selectList
(
unitLambda
).
stream
().
collect
(
Collectors
.
toMap
(
Unit:
:
getName
,
Unit:
:
getId
));
List
<
WlSpareEquipment
>
saveList
=
new
ArrayList
<>();
list
.
forEach
(
item
->
{
Equipment
equipment
=
equipmentMap
.
get
(
item
.
getEquipModelCode
());
EquipmentCategory
equipmentCategory
=
categoryMap
.
get
(
equipment
.
getCategoryId
());
ManufacturerInfo
manufacturerInfo
=
manufacturerMap
.
get
(
item
.
getManufacturer
());
WarehouseStructure
warehouseStructure
=
structureMap
.
get
(
item
.
getWarehouseStructure
());
Long
unitId
=
unitMap
.
get
(
item
.
getUnit
());
WlSpareEquipment
wlSpareEquipment
=
new
WlSpareEquipment
();
BeanUtils
.
copyProperties
(
item
,
wlSpareEquipment
);
if
(
ObjectUtils
.
isNotEmpty
(
equipment
))
{
wlSpareEquipment
.
setEquipModelId
(
equipment
.
getId
());
wlSpareEquipment
.
setEquipModelName
(
equipment
.
getName
());
}
if
(
ObjectUtils
.
isNotEmpty
(
equipmentCategory
))
{
wlSpareEquipment
.
setEquipCategoryId
(
equipmentCategory
.
getId
());
wlSpareEquipment
.
setEquipCategoryCode
(
equipmentCategory
.
getCode
());
wlSpareEquipment
.
setEquipCategoryName
(
equipmentCategory
.
getName
());
}
if
(
ObjectUtils
.
isNotEmpty
(
manufacturerInfo
))
{
wlSpareEquipment
.
setManufacturerId
(
manufacturerInfo
.
getId
());
}
if
(
ObjectUtils
.
isNotEmpty
(
warehouseStructure
))
{
wlSpareEquipment
.
setWarehouseStructureId
(
warehouseStructure
.
getId
());
wlSpareEquipment
.
setWarehouseStructure
(
warehouseStructure
.
getName
());
wlSpareEquipment
.
setWarehouseStructureCode
(
warehouseStructure
.
getCode
());
}
wlSpareEquipment
.
setBizOrgName
(
reginParams
.
getPersonIdentity
().
getCompanyName
());
wlSpareEquipment
.
setBizOrgCode
(
reginParams
.
getPersonIdentity
().
getCompanyBizOrgCode
());
wlSpareEquipment
.
setSingle
(
SingleEnum
.
DXGL
.
getName
().
equals
(
item
.
getSingle
())
?
SingleEnum
.
DXGL
.
getKey
()
:
SingleEnum
.
PLGL
.
getKey
());
wlSpareEquipment
.
setUnitId
(
unitId
);
saveList
.
add
(
wlSpareEquipment
);
});
this
.
saveBatch
(
saveList
);
}
@Override
public
void
subtractNum
(
Long
id
,
Float
num
)
{
synchronized
(
id
.
toString
())
{
WlSpareEquipment
wlSpareEquipment
=
this
.
getById
(
id
);
if
(
num
>
wlSpareEquipment
.
getStockNum
())
{
throw
new
BadRequest
(
"使用数量大于备品备件库存数量"
);
}
wlSpareEquipment
.
setStockNum
(
wlSpareEquipment
.
getStockNum
()
-
num
);
this
.
updateById
(
wlSpareEquipment
);
}
}
@Override
public
List
<
EquipmentCategory
>
getEquipmentTypeAndCount
(
String
bizOrgCode
)
{
return
refreshEquipmentTypeAndCount
(
bizOrgCode
);
}
public
List
<
EquipmentCategory
>
refreshEquipmentTypeAndCount
(
String
bizOrgCode
)
{
List
<
EquipmentCategory
>
responseList
=
this
.
typeList
();
if
(
responseList
==
null
||
responseList
.
size
()
<
1
)
{
return
null
;
}
List
<
EquipmentCategory
>
equipmentTypeList
=
responseList
.
stream
()
.
filter
(
i
->
!
i
.
getCode
().
startsWith
(
"2"
)
&&
"2"
.
equals
(
i
.
getIndustryCode
()))
.
filter
(
m
->
!
m
.
getCode
().
startsWith
(
"9306"
)
&&
"2"
.
equals
(
m
.
getIndustryCode
()))
.
collect
(
Collectors
.
toList
());
List
<
EquipmentCategory
>
list
=
typeListTree
(
equipmentTypeList
,
bizOrgCode
);
return
list
;
}
public
List
<
EquipmentCategory
>
typeList
()
{
return
iEquipmentCategoryService
.
getEquipmentCategoryList
(
Integer
.
valueOf
(
equipmentCategoryLeftTypeCode
));
}
public
List
<
EquipmentCategory
>
typeListTree
(
List
<
EquipmentCategory
>
equipmentCategorys
,
String
bizOrgCode
)
{
LambdaQueryWrapper
<
WlSpareEquipment
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
WlSpareEquipment:
:
getIsDelete
,
0
);
queryWrapper
.
gt
(
WlSpareEquipment:
:
getStockNum
,
0
);
queryWrapper
.
likeRight
(
WlSpareEquipment:
:
getBizOrgCode
,
bizOrgCode
);
List
<
WlSpareEquipment
>
wlSpareEquipments
=
wlSpareEquipmentMapper
.
selectList
(
queryWrapper
);
Map
<
Long
,
Integer
>
resultMap
=
wlSpareEquipments
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
WlSpareEquipment:
:
getEquipCategoryId
,
Collectors
.
summingInt
(
e
->
1
)));
List
<
EquipmentCategory
>
list
=
new
ArrayList
<>();
Map
<
String
,
List
<
EquipmentCategory
>>
tmpMap
=
new
HashMap
<
String
,
List
<
EquipmentCategory
>>();
equipmentCategorys
.
forEach
(
action
->
{
action
.
setCount
(
Double
.
parseDouble
(
resultMap
.
getOrDefault
(
action
.
getId
(),
0
)
+
""
));
if
(
action
.
getParentId
()
==
null
)
{
list
.
add
(
action
);
}
else
{
if
(
tmpMap
.
get
(
action
.
getParentId
().
toString
())
==
null
)
{
ArrayList
<
EquipmentCategory
>
tmplist
=
new
ArrayList
<
EquipmentCategory
>();
tmplist
.
add
(
action
);
tmpMap
.
put
(
action
.
getParentId
().
toString
(),
tmplist
);
}
else
{
if
(!
tmpMap
.
get
(
action
.
getParentId
().
toString
()).
contains
(
action
))
{
tmpMap
.
get
(
action
.
getParentId
().
toString
()).
add
(
action
);
}
}
}
});
getChildren
(
list
,
tmpMap
);
list
.
forEach
(
this
::
accumulateCount
);
List
<
EquipmentCategory
>
collect
=
list
.
stream
().
filter
(
t
->
t
.
getCount
()
>
0
).
collect
(
Collectors
.
toList
());
return
collect
;
}
public
int
accumulateCount
(
EquipmentCategory
node
)
{
int
totalCount
=
(
int
)
Math
.
round
(
node
.
getCount
());
for
(
EquipmentCategory
child
:
node
.
getChildren
())
{
totalCount
+=
accumulateCount
(
child
);
}
node
.
setCount
((
double
)
totalCount
);
return
totalCount
;
}
private
void
getChildren
(
List
<
EquipmentCategory
>
list
,
Map
<
String
,
List
<
EquipmentCategory
>>
tmpMap
)
{
for
(
EquipmentCategory
equipmentCategory
:
list
)
{
if
(
tmpMap
.
get
(
equipmentCategory
.
getId
().
toString
())
!=
null
&&
tmpMap
.
get
(
equipmentCategory
.
getId
().
toString
()).
size
()
>
0
)
{
List
<
EquipmentCategory
>
equipcliss
=
tmpMap
.
get
(
equipmentCategory
.
getId
().
toString
());
equipmentCategory
.
setHasLowerClassification
(
true
);
equipmentCategory
.
setChildren
(
equipcliss
);
getChildren
(
equipcliss
,
tmpMap
);
}
}
}
@Override
public
Map
<
String
,
Object
>
countSpareEquip
(
String
bizOrgCode
)
{
return
wlSpareEquipmentMapper
.
countSpareEquip
(
bizOrgCode
);
}
}
amos-boot-system-equip/src/main/resources/mapper/FireFightingSystemMapper.xml
View file @
6f798a50
...
...
@@ -2101,7 +2101,7 @@
<select
id=
"getColaCategoryAmountEquList"
resultMap=
"CategoryAmountList"
>
select * from (
SELECT
wles.id,
wles.qr_code,
...
...
@@ -2113,8 +2113,7 @@
concat_ws('-',wlws.full_name,wled.area) as full_name,
wlws.name as belongBuildName,
wlun.NAME unitName,
(SELECT GROUP_CONCAT(fem.name) FROM `f_fire_fighting_system` fem WHERE find_in_set(fem.id,wles.system_id))
as systemName,
wles.system_id as systemId,
wlsd.amount,
wlsd.id as stockDetailId,
'equipment' as type,
...
...
@@ -2195,13 +2194,12 @@
<if
test=
"equipTypeAmountPage.iotCode!=null and equipTypeAmountPage.iotCode!=''"
>
AND wles.iot_code LIKE CONCAT('%',#{equipTypeAmountPage.iotCode},'%')
</if>
)s1 WHERE 1=1
<if
test=
"equipTypeAmountPage.warehouseStructureName!=null and equipTypeAmountPage.warehouseStructureName!=''"
>
AND
s1.full_name
LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%')
AND
concat_ws('-',wlws.full_name,wled.area)
LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%')
</if>
<if
test=
"equipTypeAmountPage.bizOrgCode!=null and equipTypeAmountPage.bizOrgCode!=''"
>
AND
s1.bizOrgC
ode LIKE CONCAT(#{equipTypeAmountPage.bizOrgCode},'%')
AND
wles.biz_org_c
ode LIKE CONCAT(#{equipTypeAmountPage.bizOrgCode},'%')
</if>
order by createDate DESC
</select>
...
...
amos-boot-system-equip/src/main/resources/mapper/WlSpareEquipmentMapper.xml
0 → 100644
View file @
6f798a50
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.yeejoin.equipmanage.mapper.WlSpareEquipmentMapper"
>
<select
id=
"listByPage"
resultType=
"com.yeejoin.equipmanage.common.entity.WlSpareEquipment"
>
SELECT
*
FROM wl_spare_equipment
<where>
is_delete = 0
AND stock_num > 0
<if
test=
"dto.bizOrgCode != null and dto.bizOrgCode != ''"
>
AND `biz_org_code` LIKE concat(#{dto.bizOrgCode}, '%')
</if>
<if
test=
"dto.name != null and dto.name != ''"
>
AND `name` LIKE CONCAT('%', #{dto.name}, '%')
</if>
<if
test=
"dto.code != null and dto.code != ''"
>
AND `equip_model_code` LIKE concat('%', #{dto.code}, '%')
</if>
<if
test=
"codeHead != null and codeHead != ''"
>
AND LEFT (equip_model_code, #{hierarchy}) = #{codeHead}
</if>
<if
test=
"dto.manufacturerId != null"
>
AND manufacturer_id = #{dto.manufacturerId}
</if>
<if
test=
"dto.warehouseStructureId != null"
>
AND warehouse_structure_id = #{dto.warehouseStructureId}
</if>
</where>
ORDER BY create_date DESC
</select>
<select
id=
"countSpareEquip"
resultType=
"java.util.Map"
>
select
sum(stock_num) AS spareEquipNum
FROM
wl_spare_equipment
<where>
is_delete = 0
<if
test=
"bizOrgCode != '' and bizOrgCode != null"
>
AND `biz_org_code` LIKE concat(#{bizOrgCode}, '%')
</if>
</where>
</select>
</mapper>
amos-boot-system-equip/src/main/resources/template/消防装备备品备件导入模板.xlsx
0 → 100644
View file @
6f798a50
File added
amos-boot-utils/amos-boot-utils-message/src/main/java/com/yeejoin/amos/message/kafka/KafkaConsumerService.java
View file @
6f798a50
...
...
@@ -40,33 +40,33 @@ public class KafkaConsumerService {
@Value
(
"classpath:/json/commonMessage.json"
)
private
Resource
commonMessage
;
/**
* 批量消费kafka消息
* Kafka消息转emq
*
* @param consumerRecords messages
* @param ack ack
*/
@KafkaListener
(
id
=
"consumerSingle"
,
groupId
=
"zhTestGroup"
,
topics
=
"#{'${kafka.topics}'.split(',')}"
)
public
void
listen1
(
List
<
ConsumerRecord
<
String
,
String
>>
consumerRecords
,
Acknowledgment
ack
)
{
try
{
for
(
ConsumerRecord
<
String
,
String
>
consumerRecord
:
consumerRecords
)
{
Optional
<?>
kafkaMessage
=
Optional
.
ofNullable
(
consumerRecord
.
value
());
if
(
kafkaMessage
.
isPresent
())
{
JSONObject
messageObj
=
JSONObject
.
fromObject
(
kafkaMessage
.
get
());
if
(
messageObj
.
has
(
TOPIC
))
{
emqKeeper
.
getMqttClient
().
publish
(
messageObj
.
optString
(
TOPIC
),
messageObj
.
getJSONObject
(
DATA
).
toString
()
.
getBytes
(
StandardCharsets
.
UTF_8
),
0
,
false
);
}
log
.
info
(
"kafka消费zhTestGroup消息{}"
,
messageObj
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"kafka失败,当前失败的批次: data:{}, {}"
,
consumerRecords
,
e
);
}
finally
{
ack
.
acknowledge
();
}
}
//
/**
//
* 批量消费kafka消息
//
* Kafka消息转emq
//
*
//
* @param consumerRecords messages
//
* @param ack ack
//
*/
//
@KafkaListener(id = "consumerSingle", groupId = "zhTestGroup", topics = "#{'${kafka.topics}'.split(',')}")
//
public void listen1(List<ConsumerRecord<String, String>> consumerRecords, Acknowledgment ack) {
//
try {
//
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
//
Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
//
if (kafkaMessage.isPresent()) {
//
JSONObject messageObj = JSONObject.fromObject(kafkaMessage.get());
//
if (messageObj.has(TOPIC)) {
//
emqKeeper.getMqttClient().publish(messageObj.optString(TOPIC), messageObj.getJSONObject(DATA).toString()
//
.getBytes(StandardCharsets.UTF_8), 0, false);
//
}
//
log.info("kafka消费zhTestGroup消息{}", messageObj);
//
}
//
}
//
} catch (Exception e) {
//
log.error("kafka失败,当前失败的批次: data:{}, {}", consumerRecords, e);
//
} finally {
//
ack.acknowledge();
//
}
//
}
/**
* 批量消费kafka消息
...
...
@@ -244,29 +244,29 @@ public class KafkaConsumerService {
// }
/
//
**
//
* 消费单条消息,topics 可以监听多个topic,如:topics = {"topic1", "topic2"}
//
*
//
* @param message 消息
//
*/
//@KafkaListener(id = "consumerSingle", groupId = "zhTestGroup
", topics = "#{'${kafka.topics}'.split(',')}", concurrency = "2")
//
public void consumerSingle(String message, Acknowledgment ack) {
//
JSONObject messageObj = JSONObject.fromObject(message);
//
try {
//
String topic = null;
//
JSONObject data = null;
//
if (messageObj.has("topic")) {
//
topic = messageObj.getString("topic");
//
data = messageObj.getJSONObject("data");
//
emqKeeper.getMqttClient().publish(topic, data.toString().getBytes(StandardCharsets.UTF_8), 0, false);
//
ack.acknowledge();
//
log.info("消息转发成功" + messageObj);
//
}
//
} catch (Exception e) {
//
log.error("消息转发失败" + e.getMessage(), e);
//
}
//
}
//
/**
* 消费单条消息,topics 可以监听多个topic,如:topics = {"topic1", "topic2"}
*
* @param message 消息
*/
@KafkaListener
(
id
=
"consumerSingle"
,
groupId
=
"${kafka.station.groupId}
"
,
topics
=
"#{'${kafka.topics}'.split(',')}"
,
concurrency
=
"2"
)
public
void
consumerSingle
(
String
message
,
Acknowledgment
ack
)
{
JSONObject
messageObj
=
JSONObject
.
fromObject
(
message
);
try
{
String
topic
=
null
;
JSONObject
data
=
null
;
if
(
messageObj
.
has
(
"topic"
))
{
topic
=
messageObj
.
getString
(
"topic"
);
data
=
messageObj
.
getJSONObject
(
"data"
);
emqKeeper
.
getMqttClient
().
publish
(
topic
,
data
.
toString
().
getBytes
(
StandardCharsets
.
UTF_8
),
0
,
false
);
ack
.
acknowledge
();
log
.
info
(
"消息转发成功"
+
messageObj
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"消息转发失败"
+
e
.
getMessage
(),
e
);
}
}
///**
// * 省级消息转发
...
...
amos-boot-utils/amos-boot-utils-message/src/main/resources/application-dev.properties
View file @
6f798a50
...
...
@@ -114,3 +114,5 @@ kafka.auto-startup=false
#浜嬩欢鍛婅瀵规帴Kafka涓婚
queue.kafka.eventAlarm.topics
=
JKXT2BP-GJ-Topic-site
kafka.station.groupId
=
shaoxing
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