Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JeeSpringCloud
Commits
d3ad3768
Commit
d3ad3768
authored
Nov 12, 2018
by
Huang
Browse files
no commit message
parent
b6becbcd
Changes
393
Show whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 393+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/jeespring/modules/act/utils/ProcessDefCache.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.util.List
;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.apache.commons.lang3.ObjectUtils
;
import
com.jeespring.common.utils.CacheUtils
;
import
com.jeespring.common.utils.SpringContextHolder
;
/**
* 流程定义缓存
* @author JeeSpring
* @version 2013-12-05
*/
public
class
ProcessDefCache
{
private
static
final
String
ACT_CACHE
=
"actCache"
;
private
static
final
String
ACT_CACHE_PD_ID_
=
"pd_id_"
;
/**
* 获得流程定义对象
* @param procDefId
* @return
*/
public
static
ProcessDefinition
get
(
String
procDefId
)
{
ProcessDefinition
pd
=
(
ProcessDefinition
)
CacheUtils
.
get
(
ACT_CACHE
,
ACT_CACHE_PD_ID_
+
procDefId
);
if
(
pd
==
null
)
{
RepositoryService
repositoryService
=
SpringContextHolder
.
getBean
(
RepositoryService
.
class
);
// pd = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pd);
pd
=
repositoryService
.
createProcessDefinitionQuery
().
processDefinitionId
(
procDefId
).
singleResult
();
if
(
pd
!=
null
)
{
CacheUtils
.
put
(
ACT_CACHE
,
ACT_CACHE_PD_ID_
+
procDefId
,
pd
);
}
}
return
pd
;
}
/**
* 获得流程定义的所有活动节点
* @param procDefId
* @return
*/
public
static
List
<
ActivityImpl
>
getActivitys
(
String
procDefId
)
{
ProcessDefinition
pd
=
get
(
procDefId
);
if
(
pd
!=
null
)
{
return
((
ProcessDefinitionEntity
)
pd
).
getActivities
();
}
return
null
;
}
/**
* 获得流程定义活动节点
* @param procDefId
* @param activityId
* @return
*/
public
static
ActivityImpl
getActivity
(
String
procDefId
,
String
activityId
)
{
ProcessDefinition
pd
=
get
(
procDefId
);
if
(
pd
!=
null
)
{
List
<
ActivityImpl
>
list
=
getActivitys
(
procDefId
);
if
(
list
!=
null
){
for
(
ActivityImpl
activityImpl
:
list
)
{
if
(
activityId
.
equals
(
activityImpl
.
getId
())){
return
activityImpl
;
}
}
}
}
return
null
;
}
/**
* 获取流程定义活动节点名称
* @param procDefId
* @param activityId
* @return
*/
@SuppressWarnings
(
"deprecation"
)
public
static
String
getActivityName
(
String
procDefId
,
String
activityId
)
{
ActivityImpl
activity
=
getActivity
(
procDefId
,
activityId
);
if
(
activity
!=
null
)
{
return
ObjectUtils
.
toString
(
activity
.
getProperty
(
"name"
));
}
return
null
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/act/utils/ProcessDefUtils.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.act.utils
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
org.activiti.engine.ProcessEngine
;
import
org.activiti.engine.delegate.Expression
;
import
org.activiti.engine.impl.RepositoryServiceImpl
;
import
org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior
;
import
org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.activiti.engine.impl.el.FixedValue
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
org.activiti.engine.impl.task.TaskDefinition
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.log4j.Logger
;
/**
* 流程定义相关操作的封装
* @author bluejoe2008@gmail.com
*/
public
abstract
class
ProcessDefUtils
{
public
static
ActivityImpl
getActivity
(
ProcessEngine
processEngine
,
String
processDefId
,
String
activityId
)
{
ProcessDefinitionEntity
pde
=
getProcessDefinition
(
processEngine
,
processDefId
);
return
(
ActivityImpl
)
pde
.
findActivity
(
activityId
);
}
public
static
ProcessDefinitionEntity
getProcessDefinition
(
ProcessEngine
processEngine
,
String
processDefId
)
{
return
(
ProcessDefinitionEntity
)
((
RepositoryServiceImpl
)
processEngine
.
getRepositoryService
()).
getDeployedProcessDefinition
(
processDefId
);
}
public
static
void
grantPermission
(
ActivityImpl
activity
,
String
assigneeExpression
,
String
candidateGroupIdExpressions
,
String
candidateUserIdExpressions
)
throws
Exception
{
TaskDefinition
taskDefinition
=
((
UserTaskActivityBehavior
)
activity
.
getActivityBehavior
()).
getTaskDefinition
();
taskDefinition
.
setAssigneeExpression
(
assigneeExpression
==
null
?
null
:
new
FixedValue
(
assigneeExpression
));
FieldUtils
.
writeField
(
taskDefinition
,
"candidateUserIdExpressions"
,
ExpressionUtils
.
stringToExpressionSet
(
candidateUserIdExpressions
),
true
);
FieldUtils
.
writeField
(
taskDefinition
,
"candidateGroupIdExpressions"
,
ExpressionUtils
.
stringToExpressionSet
(
candidateGroupIdExpressions
),
true
);
Logger
.
getLogger
(
ProcessDefUtils
.
class
).
info
(
String
.
format
(
"granting previledges for [%s, %s, %s] on [%s, %s]"
,
assigneeExpression
,
candidateGroupIdExpressions
,
candidateUserIdExpressions
,
activity
.
getProcessDefinition
().
getKey
(),
activity
.
getProperty
(
"name"
)));
}
/**
* 实现常见类型的expression的包装和转换
*
* @author bluejoe2008@gmail.com
*
*/
public
static
class
ExpressionUtils
{
public
static
Expression
stringToExpression
(
ProcessEngineConfigurationImpl
conf
,
String
expr
)
{
return
conf
.
getExpressionManager
().
createExpression
(
expr
);
}
public
static
Expression
stringToExpression
(
String
expr
)
{
return
new
FixedValue
(
expr
);
}
public
static
Set
<
Expression
>
stringToExpressionSet
(
String
exprs
)
{
Set
<
Expression
>
set
=
new
LinkedHashSet
<
Expression
>();
for
(
String
expr
:
exprs
.
split
(
";"
))
{
set
.
add
(
stringToExpression
(
expr
));
}
return
set
;
}
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/act/utils/PropertyType.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.util.Date
;
/**
* 属性数据类型
* @author JeeSpring
* @version 2013-11-03
*/
public
enum
PropertyType
{
S
(
String
.
class
),
I
(
Integer
.
class
),
L
(
Long
.
class
),
F
(
Float
.
class
),
N
(
Double
.
class
),
D
(
Date
.
class
),
SD
(
java
.
sql
.
Date
.
class
),
B
(
Boolean
.
class
);
private
Class
<?>
clazz
;
private
PropertyType
(
Class
<?>
clazz
)
{
this
.
clazz
=
clazz
;
}
public
Class
<?>
getValue
()
{
return
clazz
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/act/utils/Variable.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.utils
;
import
java.util.Map
;
import
org.apache.commons.beanutils.ConvertUtils
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.utils.StringUtils
;
/**
* 流程变量对象
* @author JeeSpring
* @version 2013-11-03
*/
public
class
Variable
{
private
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
private
String
keys
;
private
String
values
;
private
String
types
;
public
Variable
(){
}
public
Variable
(
Map
<
String
,
Object
>
map
){
this
.
map
=
map
;
}
public
String
getKeys
()
{
return
keys
;
}
public
void
setKeys
(
String
keys
)
{
this
.
keys
=
keys
;
}
public
String
getValues
()
{
return
values
;
}
public
void
setValues
(
String
values
)
{
this
.
values
=
values
;
}
public
String
getTypes
()
{
return
types
;
}
public
void
setTypes
(
String
types
)
{
this
.
types
=
types
;
}
@JsonIgnore
public
Map
<
String
,
Object
>
getVariableMap
()
{
ConvertUtils
.
register
(
new
DateConverter
(),
java
.
util
.
Date
.
class
);
if
(
StringUtils
.
isBlank
(
keys
))
{
return
map
;
}
String
[]
arrayKey
=
keys
.
split
(
","
);
String
[]
arrayValue
=
values
.
split
(
","
);
String
[]
arrayType
=
types
.
split
(
","
);
for
(
int
i
=
0
;
i
<
arrayKey
.
length
;
i
++)
{
String
key
=
arrayKey
[
i
];
String
value
=
arrayValue
[
i
];
String
type
=
arrayType
[
i
];
Class
<?>
targetType
=
Enum
.
valueOf
(
PropertyType
.
class
,
type
).
getValue
();
Object
objectValue
=
ConvertUtils
.
convert
(
value
,
targetType
);
map
.
put
(
key
,
objectValue
);
}
return
map
;
}
public
Map
<
String
,
Object
>
getMap
()
{
return
map
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/act/web/ActModelController.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.web
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.act.service.ActModelService
;
/**
* 流程模型相关Controller
* @author JeeSpring
* @version 2013-11-03
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/act/model"
)
public
class
ActModelController
extends
AbstractBaseController
{
@Autowired
private
ActModelService
actModelService
;
/**
* 流程模型列表
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
modelList
(
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
org
.
activiti
.
engine
.
repository
.
Model
>
page
=
actModelService
.
modelList
(
new
Page
<
org
.
activiti
.
engine
.
repository
.
Model
>(
request
,
response
),
category
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"category"
,
category
);
return
"modules/act/actModelList"
;
}
/**
* 创建模型
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"create"
,
method
=
RequestMethod
.
GET
)
public
String
create
(
Model
model
)
{
return
"modules/act/actModelCreate"
;
}
/**
* 创建模型
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"create"
,
method
=
RequestMethod
.
POST
)
public
void
create
(
String
name
,
String
key
,
String
description
,
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
org
.
activiti
.
engine
.
repository
.
Model
modelData
=
actModelService
.
create
(
name
,
key
,
description
,
category
);
response
.
sendRedirect
(
request
.
getContextPath
()
+
"/act/process-editor/modeler.jsp?modelId="
+
modelData
.
getId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"创建模型失败:"
,
e
);
}
}
/**
* 根据Model部署流程
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"deploy"
)
public
String
deploy
(
String
id
,
RedirectAttributes
redirectAttributes
)
{
String
message
=
actModelService
.
deploy
(
id
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
message
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 导出model的xml文件
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"export"
)
public
void
export
(
String
id
,
HttpServletResponse
response
)
{
actModelService
.
export
(
id
,
response
);
}
/**
* 更新Model分类
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"updateCategory"
)
public
String
updateCategory
(
String
id
,
String
category
,
RedirectAttributes
redirectAttributes
)
{
actModelService
.
updateCategory
(
id
,
category
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"设置成功,模块ID="
+
id
);
return
"redirect:"
+
adminPath
+
"/act/model"
;
}
/**
* 删除Model
* @param id
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"act:model:edit"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
String
id
,
RedirectAttributes
redirectAttributes
)
{
actModelService
.
delete
(
id
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"删除成功,模型ID="
+
id
);
return
"redirect:"
+
adminPath
+
"/act/model"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/act/web/ActProcessController.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.web
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.xml.stream.XMLStreamException
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.act.service.ActProcessService
;
/**
* 流程定义相关Controller
* @author JeeSpring
* @version 2013-11-03
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/act/process"
)
public
class
ActProcessController
extends
AbstractBaseController
{
@Autowired
private
ActProcessService
actProcessService
;
/**
* 流程定义列表
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
processList
(
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
/*
* 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
*/
Page
<
Object
[]>
page
=
actProcessService
.
processList
(
new
Page
<
Object
[]>(
request
,
response
),
category
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"category"
,
category
);
return
"modules/act/actProcessList"
;
}
/**
* 运行中的实例列表
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"running"
)
public
String
runningList
(
String
procInsId
,
String
procDefKey
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
ProcessInstance
>
page
=
actProcessService
.
runningList
(
new
Page
<
ProcessInstance
>(
request
,
response
),
procInsId
,
procDefKey
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"procInsId"
,
procInsId
);
model
.
addAttribute
(
"procDefKey"
,
procDefKey
);
return
"modules/act/actProcessRunningList"
;
}
/**
* 读取资源,通过部署ID
* @param processDefinitionId 流程定义ID
* @param processInstanceId 流程实例ID
* @param resourceType 资源类型(xml|image)
* @param response
* @throws Exception
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"resource/read"
)
public
void
resourceRead
(
String
procDefId
,
String
proInsId
,
String
resType
,
HttpServletResponse
response
)
throws
Exception
{
InputStream
resourceAsStream
=
actProcessService
.
resourceRead
(
procDefId
,
proInsId
,
resType
);
byte
[]
b
=
new
byte
[
1024
];
int
len
=
-
1
;
while
((
len
=
resourceAsStream
.
read
(
b
,
0
,
1024
))
!=
-
1
)
{
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
}
/**
* 部署流程
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"/deploy"
,
method
=
RequestMethod
.
GET
)
public
String
deploy
(
Model
model
)
{
return
"modules/act/actProcessDeploy"
;
}
/**
* 部署流程 - 保存
* @param file
* @return
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"/deploy"
,
method
=
RequestMethod
.
POST
)
public
String
deploy
(
@Value
(
"#{APP_PROP['activiti.export.diagram.path']}"
)
String
exportDir
,
String
category
,
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
String
fileName
=
file
.
getOriginalFilename
();
if
(
StringUtils
.
isBlank
(
fileName
)){
redirectAttributes
.
addFlashAttribute
(
"message"
,
"请选择要部署的流程文件"
);
}
else
{
String
message
=
actProcessService
.
deploy
(
exportDir
,
category
,
file
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
message
);
}
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 设置流程分类
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"updateCategory"
)
public
String
updateCategory
(
String
procDefId
,
String
category
,
RedirectAttributes
redirectAttributes
)
{
actProcessService
.
updateCategory
(
procDefId
,
category
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 挂起、激活流程实例
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"update/{state}"
)
public
String
updateState
(
@PathVariable
(
"state"
)
String
state
,
String
procDefId
,
RedirectAttributes
redirectAttributes
)
{
String
message
=
actProcessService
.
updateState
(
state
,
procDefId
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
message
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 将部署的流程转换为模型
* @param procDefId
* @param redirectAttributes
* @return
* @throws UnsupportedEncodingException
* @throws XMLStreamException
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"convert/toModel"
)
public
String
convertToModel
(
String
procDefId
,
RedirectAttributes
redirectAttributes
)
throws
UnsupportedEncodingException
,
XMLStreamException
{
org
.
activiti
.
engine
.
repository
.
Model
modelData
=
actProcessService
.
convertToModel
(
procDefId
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"转换模型成功,模型ID="
+
modelData
.
getId
());
return
"redirect:"
+
adminPath
+
"/act/model"
;
}
/**
* 导出图片文件到硬盘
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"export/diagrams"
)
@ResponseBody
public
List
<
String
>
exportDiagrams
(
@Value
(
"#{APP_PROP['activiti.export.diagram.path']}"
)
String
exportDir
)
throws
IOException
{
List
<
String
>
files
=
actProcessService
.
exportDiagrams
(
exportDir
);;
return
files
;
}
/**
* 删除部署的流程,级联删除流程实例
* @param deploymentId 流程部署ID
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
String
deploymentId
)
{
actProcessService
.
deleteDeployment
(
deploymentId
);
return
"redirect:"
+
adminPath
+
"/act/process"
;
}
/**
* 删除流程实例
* @param procInsId 流程实例ID
* @param reason 删除原因
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"deleteProcIns"
)
public
String
deleteProcIns
(
String
procInsId
,
String
reason
,
RedirectAttributes
redirectAttributes
)
{
if
(
StringUtils
.
isBlank
(
reason
)){
addMessage
(
redirectAttributes
,
"请填写删除原因"
);
}
else
{
actProcessService
.
deleteProcIns
(
procInsId
,
reason
);
addMessage
(
redirectAttributes
,
"删除流程实例成功,实例ID="
+
procInsId
);
}
return
"redirect:"
+
adminPath
+
"/act/process/running/"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/act/web/ActTaskController.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.act.web
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.act.entity.Act
;
import
com.jeespring.modules.act.service.ActTaskService
;
import
com.jeespring.modules.act.utils.ActUtils
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 流程个人任务相关Controller
* @author JeeSpring
* @version 2013-11-03
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/act/task"
)
public
class
ActTaskController
extends
AbstractBaseController
{
@Autowired
private
ActTaskService
actTaskService
;
/**
* 获取待办列表
* @param act procDefKey 流程定义标识
* @return
*/
@RequestMapping
(
value
=
{
"todo"
,
""
})
public
String
todoList
(
Act
act
,
HttpServletResponse
response
,
Model
model
)
throws
Exception
{
List
<
Act
>
list
=
actTaskService
.
todoList
(
act
);
model
.
addAttribute
(
"list"
,
list
);
if
(
UserUtils
.
getPrincipal
().
isMobileLogin
()){
return
renderString
(
response
,
list
);
}
return
"modules/act/actTaskTodoList"
;
}
/**
* 获取已办任务
* @param act page
* @param act procDefKey 流程定义标识
* @return
*/
@RequestMapping
(
value
=
"historic"
)
public
String
historicList
(
Act
act
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
throws
Exception
{
Page
<
Act
>
page
=
new
Page
<
Act
>(
request
,
response
);
page
=
actTaskService
.
historicList
(
page
,
act
);
model
.
addAttribute
(
"page"
,
page
);
if
(
UserUtils
.
getPrincipal
().
isMobileLogin
()){
return
renderString
(
response
,
page
);
}
return
"modules/act/actTaskHistoricList"
;
}
/**
* 获取流转历史列表
* @param act procInsId 流程实例
* @param startAct 开始活动节点名称
* @param endAct 结束活动节点名称
*/
@RequestMapping
(
value
=
"histoicFlow"
)
public
String
histoicFlow
(
Act
act
,
String
startAct
,
String
endAct
,
Model
model
){
if
(
StringUtils
.
isNotBlank
(
act
.
getProcInsId
())){
List
<
Act
>
histoicFlowList
=
actTaskService
.
histoicFlowList
(
act
.
getProcInsId
(),
startAct
,
endAct
);
model
.
addAttribute
(
"histoicFlowList"
,
histoicFlowList
);
}
return
"modules/act/actTaskHistoricFlow"
;
}
/**
* 获取流程列表
* @param category 流程分类
*/
@RequestMapping
(
value
=
"process"
)
public
String
processList
(
String
category
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
Object
[]>
page
=
new
Page
<
Object
[]>(
request
,
response
);
page
=
actTaskService
.
processList
(
page
,
category
);
model
.
addAttribute
(
"page"
,
page
);
model
.
addAttribute
(
"category"
,
category
);
return
"modules/act/actTaskProcessList"
;
}
/**
* 获取流程表单
* @param act taskId 任务ID
* @param act taskName 任务名称
* @param act taskDefKey 任务环节标识
* @param act procInsId 流程实例ID
* @param act procDefId 流程定义ID
*/
@RequestMapping
(
value
=
"form"
)
public
String
form
(
Act
act
,
HttpServletRequest
request
,
Model
model
){
// 获取流程XML上的表单KEY
String
formKey
=
actTaskService
.
getFormKey
(
act
.
getProcDefId
(),
act
.
getTaskDefKey
());
// 获取流程实例对象
if
(
act
.
getProcInsId
()
!=
null
){
act
.
setProcIns
(
actTaskService
.
getProcIns
(
act
.
getProcInsId
()));
}
return
"redirect:"
+
ActUtils
.
getFormUrl
(
formKey
,
act
);
// // 传递参数到视图
// model.addAttribute("act", act);
// model.addAttribute("formUrl", formUrl);
// return "modules/act/actTaskForm";
}
/**
* 启动流程
* @param act procDefKey 流程定义KEY
* @param act businessTable 业务表表名
* @param act businessId 业务表编号
*/
@RequestMapping
(
value
=
"start"
)
@ResponseBody
public
String
start
(
Act
act
,
String
table
,
String
id
,
Model
model
)
throws
Exception
{
actTaskService
.
startProcess
(
act
.
getProcDefKey
(),
act
.
getBusinessId
(),
act
.
getBusinessTable
(),
act
.
getTitle
());
return
"true"
;
//adminPath + "/act/task";
}
/**
* 签收任务
* @param act taskId 任务ID
*/
@RequestMapping
(
value
=
"claim"
)
@ResponseBody
public
String
claim
(
Act
act
)
{
String
userId
=
UserUtils
.
getUser
().
getLoginName
();
//ObjectUtils.toString(UserUtils.getUser().getId());
actTaskService
.
claim
(
act
.
getTaskId
(),
userId
);
return
"true"
;
//adminPath + "/act/task";
}
/**
* 完成任务
* @param act taskId 任务ID
* @param act procInsId 流程实例ID,如果为空,则不保存任务提交意见
* @param act comment 任务提交意见的内容
* @param act vars 任务流程变量,如下
* vars.keys=flag,pass
* vars.values=1,true
* vars.types=S,B @see com.thinkgem.jeesite.modules.act.utils.PropertyType
*/
@RequestMapping
(
value
=
"complete"
)
@ResponseBody
public
String
complete
(
Act
act
)
{
actTaskService
.
complete
(
act
.
getTaskId
(),
act
.
getProcInsId
(),
act
.
getComment
(),
act
.
getVars
().
getVariableMap
());
return
"true"
;
//adminPath + "/act/task";
}
/**
* 读取带跟踪的图片
*/
@RequestMapping
(
value
=
"trace/photo/{procDefId}/{execId}"
)
public
void
tracePhoto
(
@PathVariable
(
"procDefId"
)
String
procDefId
,
@PathVariable
(
"execId"
)
String
execId
,
HttpServletResponse
response
)
throws
Exception
{
InputStream
imageStream
=
actTaskService
.
tracePhoto
(
procDefId
,
execId
);
// 输出资源内容到相应对象
byte
[]
b
=
new
byte
[
1024
];
int
len
;
while
((
len
=
imageStream
.
read
(
b
,
0
,
1024
))
!=
-
1
)
{
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
}
/**
* 输出跟踪流程信息
*
* @param proInsId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping
(
value
=
"trace/info/{proInsId}"
)
public
List
<
Map
<
String
,
Object
>>
traceInfo
(
@PathVariable
(
"proInsId"
)
String
proInsId
)
throws
Exception
{
List
<
Map
<
String
,
Object
>>
activityInfos
=
actTaskService
.
traceProcess
(
proInsId
);
return
activityInfos
;
}
/**
* 显示流程图
@RequestMapping(value = "processPic")
public void processPic(String procDefId, HttpServletResponse response) throws Exception {
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
String diagramResourceName = procDef.getDiagramResourceName();
InputStream imageStream = repositoryService.getResourceAsStream(procDef.getDeploymentId(), diagramResourceName);
byte[] b = new byte[1024];
int len = -1;
while ((len = imageStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}*/
/**
* 获取跟踪信息
@RequestMapping(value = "processMap")
public String processMap(String procDefId, String proInstId, Model model)
throws Exception {
List<ActivityImpl> actImpls = new ArrayList<ActivityImpl>();
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery().processDefinitionId(procDefId)
.singleResult();
ProcessDefinitionImpl pdImpl = (ProcessDefinitionImpl) processDefinition;
String processDefinitionId = pdImpl.getId();// 流程标识
ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
.getDeployedProcessDefinition(processDefinitionId);
List<ActivityImpl> activitiList = def.getActivities();// 获得当前任务的所有节点
List<String> activeActivityIds = runtimeService.getActiveActivityIds(proInstId);
for (String activeId : activeActivityIds) {
for (ActivityImpl activityImpl : activitiList) {
String id = activityImpl.getId();
if (activityImpl.isScope()) {
if (activityImpl.getActivities().size() > 1) {
List<ActivityImpl> subAcList = activityImpl
.getActivities();
for (ActivityImpl subActImpl : subAcList) {
String subid = subActImpl.getId();
System.out.println("subImpl:" + subid);
if (activeId.equals(subid)) {// 获得执行到那个节点
actImpls.add(subActImpl);
break;
}
}
}
}
if (activeId.equals(id)) {// 获得执行到那个节点
actImpls.add(activityImpl);
System.out.println(id);
}
}
}
model.addAttribute("procDefId", procDefId);
model.addAttribute("proInstId", proInstId);
model.addAttribute("actImpls", actImpls);
return "modules/act/actTaskMap";
}*/
/**
* 删除任务
* @param taskId 流程实例ID
* @param reason 删除原因
*/
@RequiresPermissions
(
"act:process:edit"
)
@RequestMapping
(
value
=
"deleteTask"
)
public
String
deleteTask
(
String
taskId
,
String
reason
,
RedirectAttributes
redirectAttributes
)
{
if
(
StringUtils
.
isBlank
(
reason
)){
addMessage
(
redirectAttributes
,
"请填写删除原因"
);
}
else
{
actTaskService
.
deleteTask
(
taskId
,
reason
);
addMessage
(
redirectAttributes
,
"删除任务成功,任务ID="
+
taskId
);
}
return
"redirect:"
+
adminPath
+
"/act/task"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/activeMQ/Email.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.activeMQ
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
/**
* 消息生产者.
* @author 黄炳桂 516821420@qq.com
* @version v.0.1
* @date 2016年8月23日
*/
public
class
Email
extends
AbstractBaseEntity
<
Email
>
{
private
String
toMailAddr
;
private
String
subject
;
private
String
message
;
public
String
getToMailAddr
()
{
return
toMailAddr
;
}
public
void
setToMailAddr
(
String
toMailAddr
)
{
this
.
toMailAddr
=
toMailAddr
;
}
public
String
getSubject
()
{
return
subject
;
}
public
void
setSubject
(
String
subject
)
{
this
.
subject
=
subject
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/activeMQ/JeeSpringConsumer.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.activeMQ
;
import
com.jeespring.common.utils.SendMailUtil
;
import
org.springframework.jms.annotation.JmsListener
;
import
org.springframework.messaging.handler.annotation.SendTo
;
import
org.springframework.stereotype.Component
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* 消息消费者.
* @author 黄炳桂 516821420@qq.com
* @version v.0.1
* @date 2016年8月23日
*/
@Component
public
class
JeeSpringConsumer
{
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
// 使用JmsListener配置消费者监听的队列,其中text是接收到的消息
@JmsListener
(
destination
=
JeeSpringProducer
.
ActiveMQQueueKeySendMailList
)
public
void
receiveQueue
(
List
<
String
>
list
)
{
String
toMailAddr
=
list
.
get
(
0
);
String
subject
=
list
.
get
(
1
);
String
message
=
list
.
get
(
2
);
SendMailUtil
.
sendCommonMail
(
toMailAddr
,
subject
,
message
);
}
@JmsListener
(
destination
=
JeeSpringProducer
.
ActiveMQQueueKeySendMailObject
)
public
void
receiveQueue
(
Email
email
)
{
SendMailUtil
.
sendCommonMail
(
email
.
getToMailAddr
(),
email
.
getSubject
(),
email
.
getMessage
());
}
// 使用JmsListener配置消费者监听的队列,其中text是接收到的消息
@JmsListener
(
destination
=
JeeSpringProducer
.
ActiveMQQueueKey
)
public
void
receiveQueue
(
String
text
)
{
System
.
out
.
println
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActiveMQ Consumer :"
+
JeeSpringProducer
.
ActiveMQQueueKey
+
":收到的报文为:"
+
text
);
}
// 使用JmsListener配置消费者监听的队列,其中text是接收到的消息
@JmsListener
(
destination
=
JeeSpringProducer
.
ActiveMQQueueKeyA
)
public
void
receiveQueueA
(
String
text
)
{
System
.
out
.
println
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActiveMQ Consumer :"
+
JeeSpringProducer
.
ActiveMQQueueKeyA
+
":收到的报文为:"
+
text
);
}
// 使用JmsListener配置消费者监听的队列,其中text是接收到的消息
@JmsListener
(
destination
=
JeeSpringProducer
.
ActiveMQQueueKeyB
)
@SendTo
(
"jeespring.out.queue"
)
public
String
receiveQueueB
(
String
text
)
{
System
.
out
.
println
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActiveMQ Consumer :"
+
JeeSpringProducer
.
ActiveMQQueueKeyA
+
"收到的报文为:"
+
text
);
return
"return message:"
+
text
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/activeMQ/JeeSpringProducer.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.activeMQ
;
import
com.jeespring.common.redis.RedisUtils
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.apache.xmlbeans.impl.xb.xsdschema.Public
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jms.annotation.JmsListener
;
import
org.springframework.jms.core.JmsMessagingTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.jms.Destination
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 消息生产者.
* @author 黄炳桂 516821420@qq.com
* @version v.0.1
* @date 2016年8月23日
*/
@Service
public
class
JeeSpringProducer
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
RedisUtils
.
class
);
public
static
final
String
ActiveMQQueueKeySendMailList
=
"JeeSpring.ActiveMQ.queue.sendmaillist"
;
public
static
final
String
ActiveMQQueueKeySendMailObject
=
"JeeSpring.ActiveMQ.queue.sendmailobject"
;
public
static
final
String
ActiveMQQueueKey
=
"JeeSpring.ActiveMQ.queue"
;
public
static
final
String
ActiveMQQueueKeyA
=
"JeeSpring.ActiveMQ.queueA"
;
public
static
final
String
ActiveMQQueueKeyB
=
"JeeSpring.ActiveMQ.queueB"
;
public
static
String
RUN_MESSAGE
=
"ActvieMQ连接异常,请开启ActvieMQ服务."
;
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
// 也可以注入JmsTemplate,JmsMessagingTemplate对JmsTemplate进行了封装
@Autowired
private
JmsMessagingTemplate
jmsTemplate
;
// 发送消息,destination是发送到的队列,message是待发送的消息
public
void
sendMessage
(
Destination
destination
,
List
<
String
>
list
){
try
{
jmsTemplate
.
convertAndSend
(
destination
,
list
);
}
catch
(
Exception
e
){
logger
.
error
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActvieMQ:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
}
public
void
sendMessage
(
Destination
destination
,
Email
email
){
try
{
jmsTemplate
.
convertAndSend
(
destination
,
email
);
}
catch
(
Exception
e
){
logger
.
error
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActvieMQ:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
}
public
void
sendMessage
(
Destination
destination
,
String
message
){
try
{
jmsTemplate
.
convertAndSend
(
destination
,
message
);
}
catch
(
Exception
e
){
logger
.
error
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActvieMQ:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
}
public
void
sendMessageA
(
final
String
message
){
try
{
Destination
destinationA
=
new
ActiveMQQueue
(
JeeSpringProducer
.
ActiveMQQueueKeyA
);
jmsTemplate
.
convertAndSend
(
destinationA
,
message
);
}
catch
(
Exception
e
){
logger
.
error
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActvieMQ:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
}
public
void
sendMessageB
(
final
String
message
){
try
{
Destination
destinationB
=
new
ActiveMQQueue
(
JeeSpringProducer
.
ActiveMQQueueKeyA
);
jmsTemplate
.
convertAndSend
(
destinationB
,
message
);
}
catch
(
Exception
e
){
logger
.
error
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActvieMQ:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
}
@JmsListener
(
destination
=
"jeespring.out.queue"
)
public
void
consumerMessage
(
String
text
){
System
.
out
.
println
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"ActvieMQ:从out.queue队列收到的回复报文为:"
+
text
);
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/activeMQ/JeeSpringProducerRestController.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.activeMQ
;
import
com.jeespring.common.utils.SendMailUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.jms.Destination
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* ActiveMQController
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@RestController
@RequestMapping
(
value
=
"rest/mq/producer"
)
@Api
(
value
=
"ActiveMQ队列任务云接口"
,
description
=
"ActiveMQ队列任务云接口"
)
public
class
JeeSpringProducerRestController
{
@Autowired
private
JeeSpringProducer
jeeSpringProducer
;
@RequestMapping
(
value
=
{
"sendMessage"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"ActiveMQ队列云发送信息(Content-Type为text/html)"
,
notes
=
"ActiveMQ队列云发送信息(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"message"
,
value
=
"信息"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
public
void
sendMessage
(
@RequestParam
(
required
=
false
)
String
message
){
Destination
destination
=
new
ActiveMQQueue
(
JeeSpringProducer
.
ActiveMQQueueKey
);
jeeSpringProducer
.
sendMessage
(
destination
,
message
);
}
@RequestMapping
(
value
=
{
"sendMail"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"ActiveMQ队列云发送邮件(Content-Type为text/html)"
,
notes
=
"ActiveMQ队列云发送邮件(Content-Type为text/html)"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"toMailAddr"
,
value
=
"接收邮件"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"subject"
,
value
=
"邮件主题"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"message"
,
value
=
"邮件内容"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
})
public
void
sendMail
(
@RequestParam
(
required
=
false
)
String
toMailAddr
,
@RequestParam
(
required
=
false
)
String
subject
,
@RequestParam
(
required
=
false
)
String
message
)
{
List
<
String
>
list
=
new
ArrayList
();
list
.
add
(
toMailAddr
);
list
.
add
(
subject
);
list
.
add
(
message
);
Destination
destination
=
new
ActiveMQQueue
(
JeeSpringProducer
.
ActiveMQQueueKeySendMailList
);
jeeSpringProducer
.
sendMessage
(
destination
,
list
);
}
@RequestMapping
(
value
=
{
"sendMailObject"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"ActiveMQ队列云发送邮件(Content-Type为text/html)"
,
notes
=
"ActiveMQ队列云发送邮件(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"email"
,
value
=
"email信息{toMailAddr,subject,message}"
,
required
=
false
,
dataType
=
"Email"
,
paramType
=
"query"
)
public
void
sendMailObject
(
Email
email
)
{
Destination
destination
=
new
ActiveMQQueue
(
JeeSpringProducer
.
ActiveMQQueueKeySendMailObject
);
jeeSpringProducer
.
sendMessage
(
destination
,
email
);
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/aop/AOPService.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.aop
;
import
com.jeespring.common.utils.SendMailUtil
;
import
com.jeespring.modules.activeMQ.Email
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* JeeSpring AOP
* @author 黄炳桂 516821420@qq.com
* @version v.0.1
* @date 2016年8月23日
*/
@Aspect
@Component
public
class
AOPService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
AOPService
.
class
);
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
// defined aop pointcut
//@Pointcut("execution(* com.company.project.modules.*.*(..))")
//@Pointcut("execution(* com.company.project.modules..*.*(..))")
/*任意公共方法的执行:
execution(public * *(..))
任何一个以“set”开始的方法的执行:
execution(* set*(..))
AccountService 接口的任意方法的执行:
execution(* com.xyz.service.AccountService.*(..))
定义在service包里的任意方法的执行:
execution(* com.xyz.service.*.*(..))
定义在service包和所有子包里的任意类的任意方法的执行:
execution(* com.xyz.service..*.*(..))
定义在pointcutexp包和所有子包里的JoinPointObjP2类的任意方法的执行:
execution(* com.test.spring.aop.pointcutexp..JoinPointObjP2.*(..))
最靠近(..)的为方法名,靠近.*(..))的为类名或者接口名,如上例的JoinPointObjP2.*(..))*/
@Pointcut
(
"execution(* com.company.project.modules.*.*.*.*(..))"
)
public
void
controllerLog
()
{
}
// log all of controller
@Before
(
"controllerLog()"
)
public
void
before
(
JoinPoint
joinPoint
)
{
//System.out.println("AOP Before:"+joinPoint.getSignature().getDeclaringType() + ",method:" + joinPoint.getSignature().getName()
//+ ",params:" + Arrays.asList(joinPoint.getArgs()));
logger
.
debug
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"AOP Before:"
+
joinPoint
.
getSignature
().
getDeclaringType
()
+
",method:"
+
joinPoint
.
getSignature
().
getName
());
/*Email email=new Email();
email.setToMailAddr("516821420@qq.com");
email.setSubject("JeeSpring");
email.setMessage("JeeSpring AOP!");
SendMailUtil.sendCommonMail(email.getToMailAddr(),email.getSubject(),email.getMessage());*/
}
/*@Around("controllerLog()")
public void around(ProceedingJoinPoint pjp) throws Throwable{
pjp.proceed();
}*/
// result of return
@AfterReturning
(
pointcut
=
"controllerLog()"
,
returning
=
"retVal"
)
public
void
after
(
JoinPoint
joinPoint
,
Object
retVal
)
{
//System.out.println("AOP AfterReturning:"+retVal);
logger
.
debug
(
dateFormat
.
format
(
new
Date
())
+
" | "
+
"AOP AfterReturning:Object"
);
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/baiduface/rest/FaceRecognitionRestController.java
deleted
100644 → 0
View file @
b6becbcd
package
com.jeespring.modules.baiduface.rest
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jeespring.common.utils.GsonUtils
;
import
com.jeespring.common.utils.HttpUtil
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.web.Result
;
import
com.jeespring.common.web.ResultFactory
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 人脸识别Controller
* @author 唐继涛
* @version 2018-7-13
*/
@RestController
@RequestMapping
(
value
=
"/rest/face"
)
@Api
(
value
=
"face百度人脸识别API接口"
,
description
=
"face百度人脸识别API接口"
)
public
class
FaceRecognitionRestController
extends
AbstractBaseController
{
//设置APPID/AK/SK
public
static
final
String
APP_ID
=
"11483847"
;
public
static
final
String
API_KEY
=
"Hn5zrGgRe5WWiXV1GcWYirFT"
;
public
static
final
String
SECRET_KEY
=
"vlzV3XEvuc1zGa9cfi5PpdRuFlfz08gu"
;
public
String
id
=
null
;
@RequestMapping
(
value
=
{
"match"
},
method
=
{
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"人脸对比(Content-Type为application/json)"
,
notes
=
"人脸对比(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"String"
,
value
=
"人脸对比"
,
dataType
=
"String"
)
public
String
match
(
@RequestBody
String
imgStr
)
{
// 请求url
String
url
=
"https://aip.baidubce.com/rest/2.0/face/v3/match"
;
//百度人脸对比的API
try
{
// String str = this.getUser(userId);
List
<
Map
<
String
,
Object
>>
images
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
map1
.
put
(
"image"
,
imgStr
);
map1
.
put
(
"image_type"
,
"BASE64"
);
map1
.
put
(
"face_type"
,
"LIVE"
);
map1
.
put
(
"quality_control"
,
"LOW"
);
map1
.
put
(
"liveness_control"
,
"NORMAL"
);
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map2
.
put
(
"image"
,
imgStr
);
map2
.
put
(
"image_type"
,
"BASE64"
);
map2
.
put
(
"face_type"
,
"LIVE"
);
map2
.
put
(
"quality_control"
,
"LOW"
);
map2
.
put
(
"liveness_control"
,
"NORMAL"
);
images
.
add
(
map1
);
images
.
add
(
map2
);
String
param
=
GsonUtils
.
toJson
(
images
);
String
token
=
FaceRecognitionRestController
.
getAuth
();
String
result
=
HttpUtil
.
post
(
url
,
token
,
"application/json"
,
param
);
System
.
out
.
println
(
result
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@RequestMapping
(
value
=
{
"search"
},
method
=
{
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"人脸搜索(Content-Type为application/json)"
,
notes
=
"人脸搜索(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"String"
,
value
=
"人脸搜索"
,
dataType
=
"String"
)
public
Result
search
(
@RequestBody
String
imgStr
)
{
// 请求url
String
url
=
"https://aip.baidubce.com/rest/2.0/face/v3/search"
;
//百度人脸搜索的API
Result
result
=
ResultFactory
.
getSuccessResult
();
try
{
String
Str
=
this
.
GroupGetlist
();
//调用百度查询用户组的API接口,将查询返回的数据接收。
JSONObject
baiJsonObject
=
JSONObject
.
parseObject
(
Str
);
//将数据转换为json对象类型的数据。
String
str
=
baiJsonObject
.
getJSONObject
(
"result"
).
getString
(
"group_id_list"
).
replace
(
"\""
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"image"
,
imgStr
);
map
.
put
(
"liveness_control"
,
"NORMAL"
);
map
.
put
(
"group_id_list"
,
str
);
map
.
put
(
"image_type"
,
"BASE64"
);
map
.
put
(
"quality_control"
,
"LOW"
);
String
param
=
GsonUtils
.
toJson
(
map
);
//调用百度的人脸检测API获取百度API返回的数据。
String
token
=
FaceRecognitionRestController
.
getAuth
();
String
baiDuResult
=
HttpUtil
.
post
(
url
,
token
,
"application/json"
,
param
);
JSONObject
returnResult
=
JSONObject
.
parseObject
(
baiDuResult
);
//将百度返回的数据转为json对象类型的数据。
String
user
=
returnResult
.
getJSONObject
(
"result"
).
getString
(
"user_list"
).
replace
(
"\""
,
""
).
replace
(
"["
,
""
)
.
replace
(
"]"
,
""
).
replace
(
"{"
,
""
).
replace
(
"}"
,
""
);
String
[]
userList
=
user
.
split
(
","
);
//根据逗号分隔用户信息。
JSONArray
jsonArray
=
(
JSONArray
)
JSONArray
.
toJSON
(
userList
);
//将字符串数组转为json 数组类型的。
String
[]
scoreList
=
((
String
)
jsonArray
.
get
(
0
)).
split
(
":"
);
//获取json数组第一条数据然后根据:分隔。
JSONArray
json
=
(
JSONArray
)
JSONArray
.
toJSON
(
scoreList
);
//获取百度返回user_list数据的score评分。
String
scoreString
=
String
.
valueOf
(
json
.
get
(
1
));
//将分数值转成string类型的。
Double
score
=
Double
.
parseDouble
(
scoreString
);
//将string类型的转换成double。
//判断分数值
if
(
score
>=
80
){
result
=
ResultFactory
.
getSuccessResult
(
"检测成功!"
);
}
else
{
result
=
ResultFactory
.
getErrorResult
(
"检测失败,请重新扫描!!"
);
}
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@RequestMapping
(
value
=
{
"add"
},
method
=
{
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"人脸注册(Content-Type为application/json)"
,
notes
=
"人脸注册(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"String"
,
value
=
"人脸注册"
,
dataType
=
"String"
)
public
Result
add
(
@RequestBody
String
imgStr
,
String
userId
)
{
// 请求url
String
url
=
"https://aip.baidubce.com/rest/2.0/face/v3/faceset/user/add"
;
//百度添加到人脸库的API
Result
result
=
ResultFactory
.
getSuccessResult
();
try
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"image"
,
imgStr
);
map
.
put
(
"group_id"
,
"测试人脸库"
);
map
.
put
(
"user_id"
,
11
);
map
.
put
(
"user_info"
,
"测试"
);
map
.
put
(
"liveness_control"
,
"NORMAL"
);
map
.
put
(
"image_type"
,
"BASE64"
);
map
.
put
(
"quality_control"
,
"NORMAL"
);
String
param
=
GsonUtils
.
toJson
(
map
);
String
token
=
FaceRecognitionRestController
.
getAuth
();
String
baiDuResult
=
HttpUtil
.
post
(
url
,
token
,
"application/json"
,
param
);
if
(
baiDuResult
.
contains
(
"SUCCESS"
))
{
result
=
ResultFactory
.
getSuccessResult
(
"注册成功!"
);
}
else
{
result
=
ResultFactory
.
getErrorResult
(
"注册失败!"
);
}
return
result
;
}
catch
(
Exception
e
)
{
logger
.
info
(
e
.
toString
());
}
return
null
;
}
/**
* 组列表查询
*/
private
String
GroupGetlist
()
{
// 请求url
String
url
=
"https://aip.baidubce.com/rest/2.0/face/v3/faceset/group/getlist"
;
try
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"start"
,
0
);
map
.
put
(
"length"
,
100
);
String
param
=
GsonUtils
.
toJson
(
map
);
String
token
=
FaceRecognitionRestController
.
getAuth
();
String
result
=
HttpUtil
.
post
(
url
,
token
,
"application/json"
,
param
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 获取API访问token
* 该token有一定的有效期,需要自行管理,当失效时需重新获取.
* @return assess_token 示例:
* "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567"
*/
public
static
String
getAuth
()
{
// 获取token地址
String
authHost
=
"https://aip.baidubce.com/oauth/2.0/token?"
;
String
getAccessTokenUrl
=
authHost
// 1. grant_type为固定参数
+
"grant_type=client_credentials"
// 2. 官网获取的 API Key
+
"&client_id="
+
API_KEY
// 3. 官网获取的 Secret Key
+
"&client_secret="
+
SECRET_KEY
;
try
{
URL
realUrl
=
new
URL
(
getAccessTokenUrl
);
// 打开和URL之间的连接
HttpURLConnection
connection
=
(
HttpURLConnection
)
realUrl
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
connection
.
connect
();
// 获取所有响应头字段
Map
<
String
,
List
<
String
>>
map
=
connection
.
getHeaderFields
();
// 遍历所有的响应头字段
for
(
String
key
:
map
.
keySet
())
{
System
.
err
.
println
(
key
+
"--->"
+
map
.
get
(
key
));
}
// 定义 BufferedReader输入流来读取URL的响应
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
result
=
""
;
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
;
}
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
String
access_token
=
jsonObject
.
getString
(
"access_token"
);
System
.
out
.
print
(
access_token
);
return
access_token
;
}
catch
(
Exception
e
)
{
System
.
err
.
printf
(
"获取token失败!"
);
e
.
printStackTrace
(
System
.
err
);
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
// new FaceSpot().getAuth();
getAuth
();
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/cms.txt
deleted
100644 → 0
View file @
b6becbcd
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/dao/ArticleDao.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.dao
;
import
java.util.List
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.cms.entity.Article
;
import
com.jeespring.modules.cms.entity.Category
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 文章DAO接口
* @author JeeSpring
* @version 2013-8-23
*/
@Mapper
public
interface
ArticleDao
extends
InterfaceBaseDao
<
Article
>
{
public
List
<
Article
>
findByIdIn
(
String
[]
ids
);
// {
// return find("from Article where id in (:p1)", new Parameter(new Object[]{ids}));
// }
public
int
updateHitsAddOne
(
String
id
);
// {
// return update("update Article set hits=hits+1 where id = :p1", new Parameter(id));
// }
public
int
updateExpiredWeight
(
Article
article
);
public
List
<
Category
>
findStats
(
Category
category
);
// {
// return update("update Article set weight=0 where weight > 0 and weightDate < current_timestamp()");
// }
}
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/dao/ArticleDataDao.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.cms.entity.ArticleData
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 文章DAO接口
* @author JeeSpring
* @version 2013-8-23
*/
@Mapper
public
interface
ArticleDataDao
extends
InterfaceBaseDao
<
ArticleData
>
{
}
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/dao/CategoryDao.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.dao
;
import
java.util.List
;
import
java.util.Map
;
import
com.jeespring.common.persistence.TreeDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.cms.entity.Category
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 栏目DAO接口
* @author JeeSpring
* @version 2013-8-23
*/
@Mapper
public
interface
CategoryDao
extends
TreeDao
<
Category
>
{
public
List
<
Category
>
findModule
(
Category
category
);
// public List<Category> findByParentIdsLike(Category category);
// {
// return find("from Category where parentIds like :p1", new Parameter(parentIds));
// }
public
List
<
Category
>
findByModule
(
String
module
);
// {
// return find("from Category where delFlag=:p1 and (module='' or module=:p2) order by site.id, sort",
// new Parameter(Category.DEL_FLAG_NORMAL, module));
// }
public
List
<
Category
>
findByParentId
(
String
parentId
,
String
isMenu
);
// {
// return find("from Category where delFlag=:p1 and parent.id=:p2 and inMenu=:p3 order by site.id, sort",
// new Parameter(Category.DEL_FLAG_NORMAL, parentId, isMenu));
// }
public
List
<
Category
>
findByParentIdAndSiteId
(
Category
entity
);
public
List
<
Map
<
String
,
Object
>>
findStats
(
String
sql
);
// {
// return find("from Category where delFlag=:p1 and parent.id=:p2 and site.id=:p3 order by site.id, sort",
// new Parameter(Category.DEL_FLAG_NORMAL, parentId, siteId));
// }
//public List<Category> findByIdIn(String[] ids);
// {
// return find("from Category where id in (:p1)", new Parameter(new Object[]{ids}));
// }
//public List<Category> find(Category category);
// @Query("select distinct c from Category c, Role r, User u where c in elements (r.categoryList) and r in elements (u.roleList)" +
// " and c.delFlag='" + Category.DEL_FLAG_NORMAL + "' and r.delFlag='" + Role.DEL_FLAG_NORMAL +
// "' and u.delFlag='" + User.DEL_FLAG_NORMAL + "' and u.id=?1 or (c.user.id=?1 and c.delFlag='" + Category.DEL_FLAG_NORMAL +
// "') order by c.site.id, c.sort")
// public List<Category> findByUserId(Long userId);
}
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/dao/CommentDao.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.cms.entity.Comment
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 评论DAO接口
* @author JeeSpring
* @version 2013-8-23
*/
@Mapper
public
interface
CommentDao
extends
InterfaceBaseDao
<
Comment
>
{
}
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/dao/GuestbookDao.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.cms.entity.Guestbook
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 留言DAO接口
* @author JeeSpring
* @version 2013-8-23
*/
@Mapper
public
interface
GuestbookDao
extends
InterfaceBaseDao
<
Guestbook
>
{
}
JeeSpringCloud/src/main/java/com/jeespring/modules/cms/dao/LinkDao.java
deleted
100644 → 0
View file @
b6becbcd
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package
com.jeespring.modules.cms.dao
;
import
java.util.List
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
com.jeespring.modules.cms.entity.Link
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 链接DAO接口
* @author JeeSpring
* @version 2013-8-23
*/
@Mapper
public
interface
LinkDao
extends
InterfaceBaseDao
<
Link
>
{
public
List
<
Link
>
findByIdIn
(
String
[]
ids
);
// {
// return find("front Like where id in (:p1)", new Parameter(new Object[]{ids}));
// }
public
int
updateExpiredWeight
(
Link
link
);
// {
// return update("update Link set weight=0 where weight > 0 and weightDate < current_timestamp()");
// }
// public List<Link> fjindListByEntity();
}
Prev
1
…
8
9
10
11
12
13
14
15
16
…
20
Next
Write
Preview
Supports
Markdown
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