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
f4cc4a94
Commit
f4cc4a94
authored
Sep 13, 2021
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
脚本修改
parent
ff3db551
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
313 additions
and
39 deletions
+313
-39
CodeInfoEnum.java
.../com/yeejoin/amos/boot/biz/common/utils/CodeInfoEnum.java
+64
-0
DynamicEnumUtils.java
.../yeejoin/amos/boot/biz/common/utils/DynamicEnumUtils.java
+185
-0
LatentDangerController.java
...os/patrol/business/controller/LatentDangerController.java
+0
-1
LatentDangerNormalParam.java
...n/amos/patrol/business/param/LatentDangerNormalParam.java
+15
-0
LatentDangerPatrolItemParam.java
...os/patrol/business/param/LatentDangerPatrolItemParam.java
+2
-2
LatentDangerServiceImpl.java
...patrol/business/service/impl/LatentDangerServiceImpl.java
+34
-35
RemoteWorkFlowService.java
...join/amos/patrol/common/remote/RemoteWorkFlowService.java
+1
-1
jcs-1.0.0.0.xml
...ystem-jcs/src/main/resources/db/changelog/jcs-1.0.0.0.xml
+12
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/CodeInfoEnum.java
0 → 100644
View file @
f4cc4a94
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
utils
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
public
enum
CodeInfoEnum
{
LOCK
(
1L
,
1L
,
"LOCK_TYPE"
,
"LOCK"
),
UNLOCK
(
1L
,
2L
,
"LOCK_TYPE"
,
"LOCK"
);
public
Long
classId
;
public
Long
infoId
;
public
String
classCode
;
public
String
infoCode
;
CodeInfoEnum
(
Long
classId
,
Long
infoId
,
String
classCode
,
String
infoCode
)
{
this
.
classId
=
classId
;
this
.
infoId
=
infoId
;
this
.
classCode
=
classCode
;
this
.
infoCode
=
infoCode
;
}
public
static
CodeInfoEnum
getByInfoId
(
Long
infoId
)
{
return
CodeInfoEnum
.
valueOf
(
infoId
+
""
);
}
public
static
List
getByClassId
(
Long
classId
)
{
return
Arrays
.
stream
(
CodeInfoEnum
.
values
()).
filter
(
item
->
item
.
classId
.
equals
(
classId
)).
collect
(
Collectors
.
toList
());
}
public
static
CodeInfoEnum
getByClassCodeAndInfoCode
(
String
classCode
,
String
infoCode
)
{
Optional
opt
=
Arrays
.
stream
(
CodeInfoEnum
.
values
()).
filter
(
item
->
item
.
classCode
.
equals
(
classCode
)
&&
item
.
infoCode
.
equals
(
infoCode
)).
findFirst
();
return
(
CodeInfoEnum
)
opt
.
orElse
(
null
);
}
@Override
public
String
toString
()
{
return
"CodeInfoEnum{"
+
"classId="
+
classId
+
", infoId="
+
infoId
+
", classCode='"
+
classCode
+
'\''
+
", infoCode='"
+
infoCode
+
'\''
+
'}'
;
}
}
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DynamicEnumUtils.java
0 → 100644
View file @
f4cc4a94
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
utils
;
import
sun.reflect.ConstructorAccessor
;
import
sun.reflect.FieldAccessor
;
import
sun.reflect.ReflectionFactory
;
import
java.lang.reflect.AccessibleObject
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
DynamicEnumUtils
{
private
static
ReflectionFactory
reflectionFactory
=
ReflectionFactory
.
getReflectionFactory
();
private
static
void
setFailsafeFieldValue
(
Field
field
,
Object
target
,
Object
value
)
throws
NoSuchFieldException
,
IllegalAccessException
{
// 反射访问私有变量
field
.
setAccessible
(
true
);
/**
* 接下来,我们将字段实例中的修饰符更改为不再是final,
* 从而使反射允许我们修改静态final字段。
*/
Field
modifiersField
=
Field
.
class
.
getDeclaredField
(
"modifiers"
);
modifiersField
.
setAccessible
(
true
);
int
modifiers
=
modifiersField
.
getInt
(
field
);
// 去掉修饰符int中的最后一位
modifiers
&=
~
Modifier
.
FINAL
;
modifiersField
.
setInt
(
field
,
modifiers
);
FieldAccessor
fa
=
reflectionFactory
.
newFieldAccessor
(
field
,
false
);
fa
.
set
(
target
,
value
);
}
private
static
void
blankField
(
Class
<?>
enumClass
,
String
fieldName
)
throws
NoSuchFieldException
,
IllegalAccessException
{
for
(
Field
field
:
Class
.
class
.
getDeclaredFields
())
{
if
(
field
.
getName
().
contains
(
fieldName
))
{
AccessibleObject
.
setAccessible
(
new
Field
[]{
field
},
true
);
setFailsafeFieldValue
(
field
,
enumClass
,
null
);
break
;
}
}
}
private
static
void
cleanEnumCache
(
Class
<?>
enumClass
)
throws
NoSuchFieldException
,
IllegalAccessException
{
blankField
(
enumClass
,
"enumConstantDirectory"
);
// Sun (Oracle?!?) JDK 1.5/6
blankField
(
enumClass
,
"enumConstants"
);
// IBM JDK
}
private
static
ConstructorAccessor
getConstructorAccessor
(
Class
<?>
enumClass
,
Class
<?>[]
additionalParameterTypes
)
throws
NoSuchMethodException
{
Class
<?>[]
parameterTypes
=
new
Class
[
additionalParameterTypes
.
length
+
2
];
parameterTypes
[
0
]
=
String
.
class
;
parameterTypes
[
1
]
=
int
.
class
;
System
.
arraycopy
(
additionalParameterTypes
,
0
,
parameterTypes
,
2
,
additionalParameterTypes
.
length
);
return
reflectionFactory
.
newConstructorAccessor
(
enumClass
.
getDeclaredConstructor
(
parameterTypes
));
}
private
static
Object
makeEnum
(
Class
<?>
enumClass
,
String
value
,
int
ordinal
,
Class
<?>[]
additionalTypes
,
Object
[]
additionalValues
)
throws
Exception
{
Object
[]
parms
=
new
Object
[
additionalValues
.
length
+
2
];
parms
[
0
]
=
value
;
parms
[
1
]
=
Integer
.
valueOf
(
ordinal
);
System
.
arraycopy
(
additionalValues
,
0
,
parms
,
2
,
additionalValues
.
length
);
return
enumClass
.
cast
(
getConstructorAccessor
(
enumClass
,
additionalTypes
).
newInstance
(
parms
));
}
/**
* 将枚举实例添加到作为参数提供的枚举类中
*
* @param enumType 要修改的枚举类型
* @param enumName 添加的枚举类型名字
* @param additionalTypes 枚举类型参数类型列表
* @param additionalValues 枚举类型参数值列表
* @param <T>
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
extends
Enum
<?>>
void
addEnum
(
Class
<
T
>
enumType
,
String
enumName
,
Class
<?>[]
additionalTypes
,
Object
[]
additionalValues
)
{
// 0. 检查类型
if
(!
Enum
.
class
.
isAssignableFrom
(
enumType
))
{
throw
new
RuntimeException
(
"class "
+
enumType
+
" is not an instance of Enum"
);
}
// 1. 在枚举类中查找“$values”持有者并获取以前的枚举实例
Field
valuesField
=
null
;
Field
[]
fields
=
enumType
.
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
if
(
field
.
getName
().
contains
(
"$VALUES"
))
{
valuesField
=
field
;
break
;
}
}
AccessibleObject
.
setAccessible
(
new
Field
[]{
valuesField
},
true
);
try
{
// 2. 将他拷贝到数组
T
[]
previousValues
=
(
T
[])
valuesField
.
get
(
enumType
);
List
<
T
>
values
=
new
ArrayList
<
T
>(
Arrays
.
asList
(
previousValues
));
// 3. 创建新的枚举项
T
newValue
=
(
T
)
makeEnum
(
enumType
,
enumName
,
values
.
size
(),
additionalTypes
,
additionalValues
);
// 4. 添加新的枚举项
values
.
add
(
newValue
);
// 5. 设定拷贝的数组,到枚举类型
setFailsafeFieldValue
(
valuesField
,
null
,
values
.
toArray
((
T
[])
Array
.
newInstance
(
enumType
,
0
)));
// 6. 清楚枚举的缓存
cleanEnumCache
(
enumType
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
(),
e
);
}
}
public
static
void
main
(
String
[]
args
)
{
//
synchronized
(
CodeInfoEnum
.
class
)
{
addEnum
(
CodeInfoEnum
.
class
,
"3"
,
new
Class
[]{
Long
.
class
,
Long
.
class
,
String
.
class
,
String
.
class
},
new
Object
[]{
2L
,
3L
,
"ActiveStatus"
,
"Active"
});
addEnum
(
CodeInfoEnum
.
class
,
"4"
,
new
Class
[]{
Long
.
class
,
Long
.
class
,
String
.
class
,
String
.
class
},
new
Object
[]{
2L
,
4L
,
"ActiveStatus"
,
"Inactive"
});
addEnum
(
CodeInfoEnum
.
class
,
"5"
,
new
Class
[]{
Long
.
class
,
Long
.
class
,
String
.
class
,
String
.
class
},
new
Object
[]{
3L
,
5L
,
"Optype"
,
"OP1"
});
addEnum
(
CodeInfoEnum
.
class
,
"6"
,
new
Class
[]{
Long
.
class
,
Long
.
class
,
String
.
class
,
String
.
class
},
new
Object
[]{
3L
,
6L
,
"Optype"
,
"OP2"
});
addEnum
(
CodeInfoEnum
.
class
,
"7"
,
new
Class
[]{
Long
.
class
,
Long
.
class
,
String
.
class
,
String
.
class
},
new
Object
[]{
3L
,
7L
,
"Optype"
,
"OP3"
});
addEnum
(
CodeInfoEnum
.
class
,
"8"
,
new
Class
[]{
Long
.
class
,
Long
.
class
,
String
.
class
,
String
.
class
},
new
Object
[]{
3L
,
8L
,
"Optype"
,
"OP4"
});
}
CodeInfoEnum
codeInfoEnum
=
CodeInfoEnum
.
valueOf
(
"5"
);
System
.
out
.
println
(
codeInfoEnum
);
// Run a few tests just to show it works OK.
System
.
out
.
println
(
Arrays
.
deepToString
(
CodeInfoEnum
.
values
()));
System
.
out
.
println
(
"============================打印所有枚举(包括固定的和动态的),可以将数据库中保存的CIC以枚举的形式加载到JVM"
);
for
(
CodeInfoEnum
codeInfo
:
CodeInfoEnum
.
values
())
{
System
.
out
.
println
(
codeInfo
.
toString
());
}
System
.
out
.
println
(
"============================通过codeId找到的枚举,用于PO转VO的处理"
);
CodeInfoEnum
activeStatus_Active
=
CodeInfoEnum
.
getByInfoId
(
3L
);
System
.
out
.
println
(
activeStatus_Active
);
System
.
out
.
println
(
"============================通过ClassId找到的枚举列表"
);
List
<
CodeInfoEnum
>
activeStatusEnumList
=
CodeInfoEnum
.
getByClassId
(
3L
);
for
(
CodeInfoEnum
codeInfo
:
activeStatusEnumList
)
{
System
.
out
.
println
(
codeInfo
);
}
System
.
out
.
println
(
"============================通过ClassCode和InfoCode获取枚举,用于导入验证CIC合法性"
);
CodeInfoEnum
toGetActiveStatus_Active
=
CodeInfoEnum
.
getByClassCodeAndInfoCode
(
"ActiveStatus"
,
"Active"
);
System
.
out
.
println
(
toGetActiveStatus_Active
);
System
.
out
.
println
(
"============================通过ClassCode和InfoCode获取枚举,输入不存在的Code,则返回NULL"
);
CodeInfoEnum
toGetActiveStatus_miss
=
CodeInfoEnum
.
getByClassCodeAndInfoCode
(
"ActiveStatus"
,
"MISS"
);
System
.
out
.
println
(
toGetActiveStatus_miss
);
}
}
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/controller/LatentDangerController.java
View file @
f4cc4a94
...
...
@@ -56,7 +56,6 @@ public class LatentDangerController extends AbstractBaseController {
@PostMapping
(
value
=
"/normal/save"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
public
CommonResponse
saveNormal
(
@ApiParam
(
value
=
"隐患对象"
,
required
=
true
)
@RequestBody
LatentDangerNormalParam
latentDangerParam
)
{
CommonResponse
commonResponse
=
new
CommonResponse
();
try
{
AgencyUserModel
user
=
getUserInfo
();
if
(
ObjectUtils
.
isEmpty
(
user
))
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/param/LatentDangerNormalParam.java
View file @
f4cc4a94
...
...
@@ -47,4 +47,19 @@ public class LatentDangerNormalParam {
* 建筑名称
*/
private
String
structureName
;
/**
* 隐患地址经度
*/
private
String
longitude
;
/**
* 隐患地址纬度
*/
private
String
latitude
;
/**
* 业务类型(不同业务创建的隐患以此区分)
*/
private
String
bizType
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/param/LatentDangerPatrolItemParam.java
View file @
f4cc4a94
...
...
@@ -44,9 +44,9 @@ public class LatentDangerPatrolItemParam {
private
String
instanceKey
;
/*
/*
*
* 隐患名称
*
*
/
*/
private
String
name
;
private
String
limitDate
;
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/service/impl/LatentDangerServiceImpl.java
View file @
f4cc4a94
package
com
.
yeejoin
.
amos
.
patrol
.
business
.
service
.
impl
;
import
static
org
.
typroject
.
tyboot
.
core
.
foundation
.
context
.
RequestContext
.
getProduct
;
import
java.net.InetAddress
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -106,6 +77,34 @@ import com.yeejoin.amos.patrol.dao.entity.PointClassify;
import
com.yeejoin.amos.patrol.exception.YeeException
;
import
com.yeejoin.amos.patrol.feign.RemoteSecurityService
;
import
com.yeejoin.amos.patrol.mqtt.WebMqttComponent
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
java.net.InetAddress
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
org
.
typroject
.
tyboot
.
core
.
foundation
.
context
.
RequestContext
.
getProduct
;
@Service
(
"latentDangerService"
)
public
class
LatentDangerServiceImpl
implements
ILatentDangerService
{
...
...
@@ -540,14 +539,14 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
@Override
public
CommonResponse
list
(
String
toke
,
String
product
,
String
appKey
,
LatentDangerListParam
latentDangerListParam
,
AgencyUserModel
user
,
String
loginOrgCode
,
String
deptId
)
{
JSONObject
respBody
;
Date
startDate
=
new
Date
();
Date
startDate
=
new
Date
();
if
(
latentDangerListParam
.
getIsHandle
())
{
respBody
=
remoteWorkFlowService
.
completedPageTask
(
user
.
getUserName
(),
latentDangerListParam
.
getBelongType
());
}
else
{
respBody
=
remoteWorkFlowService
.
pageTask
(
user
.
getUserId
(),
latentDangerListParam
.
getBelongType
());
}
Date
endDate
=
new
Date
();
logger
.
info
(
"-------------------------工作流列表时间"
+
(
endDate
.
getTime
()-
startDate
.
getTime
()));
Date
endDate
=
new
Date
();
logger
.
info
(
"-------------------------工作流列表时间"
+
(
endDate
.
getTime
()
-
startDate
.
getTime
()));
JSONArray
taskJsonList
=
respBody
.
getJSONArray
(
"data"
);
List
<
JSONObject
>
taskList
=
JSONObject
.
parseArray
(
taskJsonList
.
toJSONString
(),
JSONObject
.
class
);
List
<
String
>
bussinessKeys
=
new
ArrayList
<>();
...
...
@@ -720,9 +719,9 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
}
@Override
public
CommonResponse
detail
(
String
id
,
String
userId
,
boolean
isFinish
)
{
public
CommonResponse
detail
(
String
id
,
String
userId
,
boolean
isFinish
)
{
JSONObject
jsonObject
;
if
(
isFinish
==
true
){
if
(
isFinish
){
jsonObject
=
remoteWorkFlowService
.
queryFinishTaskDetail
(
id
);
}
else
{
jsonObject
=
remoteWorkFlowService
.
queryTaskDetail
(
id
);
...
...
@@ -1172,7 +1171,7 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
String
departmentName
,
DangerExecuteSubmitDto
executeSubmitDto
,
RoleBo
role
)
{
JSONObject
executeJson
=
remoteWorkFlowService
.
excute
(
param
.
getTaskId
(),
executeTypeEnum
.
getRequestBody
());
JSONObject
executeJson
=
remoteWorkFlowService
.
ex
e
cute
(
param
.
getTaskId
(),
executeTypeEnum
.
getRequestBody
());
if
(
executeJson
==
null
)
{
executeSubmitDto
.
setIsOk
(
false
);
executeSubmitDto
.
setMsg
(
"执行失败"
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/common/remote/RemoteWorkFlowService.java
View file @
f4cc4a94
...
...
@@ -173,7 +173,7 @@ public class RemoteWorkFlowService {
// return json;
// }
public
JSONObject
excute
(
String
taskId
,
String
requestBody
)
{
public
JSONObject
ex
e
cute
(
String
taskId
,
String
requestBody
)
{
Map
<
String
,
String
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"taskId"
,
taskId
);
Map
<
String
,
String
>
headerMap
=
Maps
.
newHashMap
();
...
...
amos-boot-system-jcs/src/main/resources/db/changelog/jcs-1.0.0.0.xml
View file @
f4cc4a94
...
...
@@ -163,7 +163,13 @@
</changeSet>
<changeSet
author=
"litengwei"
id=
"2021-09-01-litengwei-1"
>
<preConditions
onFail=
"MARK_RAN"
>
<tableExists
tableName=
"cb_data_dictionary"
/>
<!-- <sqlCheck expectedResult="0">select count(*) from cb_data_dictionary where sequence_nbr between 1152 and-->
<!-- 1166</sqlCheck>-->
<not>
<primaryKeyExists
primaryKeyName=
"sequence_nbr"
tableName=
"cb_data_dictionary"
/>
</not>
</preConditions>
<comment>
add data cb_data_dictionary
</comment>
<sql>
...
...
@@ -187,6 +193,9 @@
<changeSet
author=
"litengwei"
id=
"2021-09-01-litengwei-2"
>
<preConditions
onFail=
"MARK_RAN"
>
<tableExists
tableName=
"jc_alert_form"
/>
<not>
<primaryKeyExists
primaryKeyName=
"sequence_nbr"
tableName=
"jc_alert_form"
/>
</not>
</preConditions>
<comment>
add data jc_alert_form
</comment>
<sql>
...
...
@@ -270,6 +279,9 @@
<changeSet
author=
"chenhao"
id=
"2021-09-06-chenhao-1"
>
<preConditions
onFail=
"MARK_RAN"
>
<tableExists
tableName=
"cb_data_dictionary"
/>
<not>
<primaryKeyExists
primaryKeyName=
"sequence_nbr"
tableName=
"cb_data_dictionary"
/>
</not>
</preConditions>
<comment>
insert data cb_data_dictionary
</comment>
<sql>
...
...
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