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
91744783
Commit
91744783
authored
Sep 08, 2023
by
xixinzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
车辆赋码方式修改
parent
46712f86
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
216 additions
and
13 deletions
+216
-13
EquipQrDateDto.java
...yeejoin/equipmanage/common/entity/dto/EquipQrDateDto.java
+29
-0
CalculationRulesEnum.java
...eejoin/equipmanage/common/enums/CalculationRulesEnum.java
+51
-0
UpdateQrCodeAction.java
...va/com/yeejoin/equipmanage/action/UpdateQrCodeAction.java
+102
-0
CarPropertyMapper.java
...ava/com/yeejoin/equipmanage/mapper/CarPropertyMapper.java
+1
-1
CarPropertyJob.java
...n/java/com/yeejoin/equipmanage/quartz/CarPropertyJob.java
+19
-2
ICarService.java
...ain/java/com/yeejoin/equipmanage/service/ICarService.java
+6
-1
CarServiceImpl.java
.../com/yeejoin/equipmanage/service/impl/CarServiceImpl.java
+4
-6
CarPropertyMapper.xml
...tem-equip/src/main/resources/mapper/CarPropertyMapper.xml
+4
-3
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/dto/EquipQrDateDto.java
0 → 100644
View file @
91744783
package
com
.
yeejoin
.
equipmanage
.
common
.
entity
.
dto
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author DELL
*/
@Data
public
class
EquipQrDateDto
{
/**
* 类型
*/
private
String
type
;
/**
* 对比属性
*/
private
String
contrast
;
/**
* 需要赋码判断的数据
*/
private
List
<
Map
<
String
,
String
>>
data
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/enums/CalculationRulesEnum.java
0 → 100644
View file @
91744783
package
com
.
yeejoin
.
equipmanage
.
common
.
enums
;
/**
* 赋码计算规则
* @author DELL
*/
public
enum
CalculationRulesEnum
{
EQ
(
"eq"
,
"等于"
),
NE
(
"ne"
,
"不等于"
),
GT
(
"gt"
,
"大于"
),
GE
(
"ge"
,
"大于等于"
),
LT
(
"lt"
,
"小于"
),
LE
(
"le"
,
"小于等于"
);
private
String
code
;
private
String
type
;
CalculationRulesEnum
(
String
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
static
CalculationRulesEnum
getEnum
(
String
code
)
{
CalculationRulesEnum
calculationRulesEnum
=
null
;
for
(
CalculationRulesEnum
type:
CalculationRulesEnum
.
values
())
{
if
(
type
.
getCode
().
equals
(
code
))
{
calculationRulesEnum
=
type
;
break
;
}
}
return
calculationRulesEnum
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/action/UpdateQrCodeAction.java
0 → 100644
View file @
91744783
package
com
.
yeejoin
.
equipmanage
.
action
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.JsonObject
;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
import
com.yeejoin.amos.component.rule.RuleMethod
;
import
com.yeejoin.equipmanage.common.entity.dto.EquipQrDateDto
;
import
com.yeejoin.equipmanage.common.enums.CalculationRulesEnum
;
import
com.yeejoin.equipmanage.common.utils.DateUtils
;
import
com.yeejoin.equipmanage.service.ICarService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
/**
* 赋码动作
* @author DELL
*/
@Component
@RuleActionBean
(
beanLabel
=
"动态预案"
)
@Slf4j
public
class
UpdateQrCodeAction
{
@Autowired
private
ICarService
carService
;
private
final
String
CAR_ID
=
"carId"
;
@RuleMethod
(
methodLabel
=
"更新码"
,
project
=
"车辆更新码颜色"
)
public
void
updateCarQrCode
(
@MethodParam
(
paramLabel
=
"判断值"
)
String
value
,
@MethodParam
(
paramLabel
=
"赋码颜色"
)
String
color
,
@MethodParam
(
paramLabel
=
"判断对象"
)
Object
equipQrDateDto
,
@MethodParam
(
paramLabel
=
"是否启用"
)
Boolean
enable
,
@MethodParam
(
paramLabel
=
"计算规则"
)
String
rule
)
{
if
(
Boolean
.
TRUE
.
equals
(
enable
))
{
EquipQrDateDto
equipQrDateDtoN
=
JSONObject
.
parseObject
(
equipQrDateDto
.
toString
(),
EquipQrDateDto
.
class
);
List
<
Map
<
String
,
String
>>
data
=
equipQrDateDtoN
.
getData
();
String
contrast
=
equipQrDateDtoN
.
getContrast
();
if
(!
CollectionUtils
.
isEmpty
(
data
))
{
List
<
String
>
collect
=
data
.
stream
().
map
(
map
->
{
try
{
String
carId
=
null
;
String
s
=
map
.
get
(
contrast
).
replace
(
"T"
,
" "
);
Date
date
=
DateUtils
.
longStr2Date
(
s
);
int
i
=
DateUtils
.
dateBetween
(
date
,
new
Date
());
CalculationRulesEnum
anEnum
=
CalculationRulesEnum
.
getEnum
(
rule
);
switch
(
anEnum
)
{
case
EQ:
if
(
i
==
Integer
.
parseInt
(
value
))
{
carId
=
String
.
valueOf
(
map
.
get
(
CAR_ID
));
}
break
;
case
GT:
if
(
i
>
Integer
.
parseInt
(
value
))
{
carId
=
String
.
valueOf
(
map
.
get
(
CAR_ID
));
}
break
;
case
GE:
if
(
i
>=
Integer
.
parseInt
(
value
))
{
carId
=
String
.
valueOf
(
map
.
get
(
CAR_ID
));
}
break
;
case
LE:
if
(
i
<=
Integer
.
parseInt
(
value
))
{
carId
=
String
.
valueOf
(
map
.
get
(
CAR_ID
));
}
break
;
case
LT:
if
(
i
<
Integer
.
parseInt
(
value
))
{
carId
=
String
.
valueOf
(
map
.
get
(
CAR_ID
));
}
break
;
case
NE:
if
(
i
!=
Integer
.
parseInt
(
value
))
{
carId
=
String
.
valueOf
(
map
.
get
(
CAR_ID
));
}
break
;
default
:
break
;
}
return
carId
;
}
catch
(
ParseException
e
)
{
log
.
error
(
"日期转换失败"
);
e
.
printStackTrace
();
return
null
;
}
}).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
carService
.
updateCarQrCode
(
collect
,
color
);
}
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/mapper/CarPropertyMapper.java
View file @
91744783
...
...
@@ -37,6 +37,6 @@ public interface CarPropertyMapper extends BaseMapper<CarProperty> {
Map
<
String
,
Object
>
getCarPropertyByCarIds
(
List
<
Long
>
carIds
);
List
<
Map
<
String
,
Object
>>
selectIndexByTime
(
String
carStartIndexKey
);
List
<
Map
<
String
,
String
>>
selectIndexByTime
(
String
carStartIndexKey
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/quartz/CarPropertyJob.java
View file @
91744783
package
com
.
yeejoin
.
equipmanage
.
quartz
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.equipmanage.common.entity.dto.EquipQrDateDto
;
import
com.yeejoin.equipmanage.service.ICarService
;
import
com.yeejoin.equipmanage.service.impl.CarServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -8,6 +10,9 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
/**
* 定时监控车辆相关指标
* @author xxz
...
...
@@ -20,13 +25,25 @@ public class CarPropertyJob {
@Autowired
private
ICarService
carService
;
@Autowired
private
RuleTrigger
ruleTrigger
;
/**
* 车辆赋红码。定时查询车辆启停更新时间,
*/
@Scheduled
(
cron
=
"${update.car.qrCode}"
)
public
void
UpdateCarQrCode
(){
public
void
UpdateCarQrCode
()
{
carService
.
updateCarStartStatus
();
List
<
Map
<
String
,
String
>>
list
=
carService
.
updateCarStartStatus
();
EquipQrDateDto
equipQrDateDto
=
new
EquipQrDateDto
();
equipQrDateDto
.
setContrast
(
"updateDate"
);
equipQrDateDto
.
setType
(
"car"
);
equipQrDateDto
.
setData
(
list
);
try
{
ruleTrigger
.
publish
(
equipQrDateDto
,
"中心配置赋码规则/update-qr-code"
,
null
);
}
catch
(
Exception
e
)
{
log
.
error
(
"调用规则失败: {}"
,
e
.
getMessage
());
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/ICarService.java
View file @
91744783
...
...
@@ -211,7 +211,12 @@ public interface ICarService extends IService<Car> {
/**
* 查询车辆启动状态,赋码
*/
void
updateCarStartStatus
();
List
<
Map
<
String
,
String
>>
updateCarStartStatus
();
/**
* 赋码
*/
void
updateCarQrCode
(
List
<
String
>
carIds
,
String
status
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/CarServiceImpl.java
View file @
91744783
...
...
@@ -1969,14 +1969,12 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
}
@Override
public
void
updateCarStartStatus
()
{
List
<
Map
<
String
,
Object
>>
list
=
carPropertyMapper
.
selectIndexByTime
(
CAR_START_INDEX_KEY
);
List
<
String
>
carIds
=
list
.
stream
().
map
(
o
->
String
.
valueOf
(
o
.
get
(
"carId"
))).
collect
(
Collectors
.
toList
());
// 近七天未启动赋红码
updateCarQrCode
(
carIds
,
"2"
);
public
List
<
Map
<
String
,
String
>>
updateCarStartStatus
()
{
return
carPropertyMapper
.
selectIndexByTime
(
CAR_START_INDEX_KEY
);
}
private
void
updateCarQrCode
(
List
<
String
>
carIds
,
String
status
)
{
@Override
public
void
updateCarQrCode
(
List
<
String
>
carIds
,
String
status
)
{
carMapper
.
updateStatusByIds
(
carIds
,
status
);
}
}
amos-boot-system-equip/src/main/resources/mapper/CarPropertyMapper.xml
View file @
91744783
...
...
@@ -100,12 +100,13 @@
<select
id=
"selectIndexByTime"
resultType=
"map"
>
SELECT
car_id carId
car_id carId,
update_date updateDate
FROM
wl_car_property
WHERE
equipment_index_key = #{carStartIndexKey} AND `value` IS NOT NULL
AND
DATE_SUB(CURDATE( ), INTERVAL 7 DAY ) > update_date
equipment_index_key = #{carStartIndexKey} AND `value` IS NOT NULL
-- AND
DATE_SUB(CURDATE( ), INTERVAL 7 DAY ) > update_date
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment