Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datacollector
Overview
Overview
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
chenweisong
datacollector
Commits
cbca00c9
Commit
cbca00c9
authored
Mar 14, 2020
by
chenweisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
ee6e03cf
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
458 additions
and
1834 deletions
+458
-1834
ActivitiApplication.java
src/main/java/com/keymobile/ActivitiApplication.java
+0
-1
ProcessCtrl.java
src/main/java/com/keymobile/activiti/api/ProcessCtrl.java
+0
-499
ProcessFormExcelCtrl.java
...java/com/keymobile/activiti/api/ProcessFormExcelCtrl.java
+0
-45
StandardModelCtrl.java
...in/java/com/keymobile/activiti/api/StandardModelCtrl.java
+0
-75
FeignClientConfig.java
...n/java/com/keymobile/activiti/conf/FeignClientConfig.java
+0
-22
MongoDBConfig.java
src/main/java/com/keymobile/activiti/conf/MongoDBConfig.java
+0
-63
RedisClusterConfig.java
.../java/com/keymobile/activiti/conf/RedisClusterConfig.java
+0
-154
RedisConfig.java
src/main/java/com/keymobile/activiti/conf/RedisConfig.java
+0
-44
SecurityConfig.java
...main/java/com/keymobile/activiti/conf/SecurityConfig.java
+0
-74
WirteStandardAttrListener.java
...eymobile/activiti/listener/WirteStandardAttrListener.java
+0
-24
FormExcelFile.java
...main/java/com/keymobile/activiti/model/FormExcelFile.java
+0
-35
StandardModelFile.java
.../java/com/keymobile/activiti/model/StandardModelFile.java
+0
-34
FormExcelFileRepository.java
...ymobile/activiti/persistence/FormExcelFileRepository.java
+0
-12
StandardModelFileRepository.java
...ile/activiti/persistence/StandardModelFileRepository.java
+0
-9
ProtalRemoteService.java
...va/com/keymobile/activiti/remote/ProtalRemoteService.java
+0
-15
ActivityDemoServiceImpl.java
...m/keymobile/activiti/service/ActivityDemoServiceImpl.java
+0
-25
GroupDataStandardServiceImpl.java
...mobile/activiti/service/GroupDataStandardServiceImpl.java
+0
-49
FormExcelFileService.java
...le/activiti/service/formService/FormExcelFileService.java
+0
-83
StandardModelFileService.java
...ctiviti/service/formService/StandardModelFileService.java
+0
-56
Page.java
src/main/java/com/keymobile/activiti/utils/Page.java
+0
-29
ActivitiController.java
...m/keymobile/rest/activiti/modeler/ActivitiController.java
+84
-83
ModelEditorJsonRestResource.java
...le/rest/activiti/modeler/ModelEditorJsonRestResource.java
+1
-1
ModelSaveRestResource.java
...eymobile/rest/activiti/modeler/ModelSaveRestResource.java
+1
-1
StencilsetRestResource.java
...ymobile/rest/activiti/modeler/StencilsetRestResource.java
+1
-1
ActivitiConfig.java
...n/java/com/keymobile/rest/common/conf/ActivitiConfig.java
+1
-1
AssignmentConstant.java
...om/keymobile/rest/common/constant/AssignmentConstant.java
+7
-9
TemplateConstant.java
.../com/keymobile/rest/common/constant/TemplateConstant.java
+3
-0
UserConstant.java
...java/com/keymobile/rest/common/constant/UserConstant.java
+7
-0
DateUtil.java
src/main/java/com/keymobile/rest/common/utils/DateUtil.java
+179
-177
ExcelController.java
...n/java/com/keymobile/rest/controller/ExcelController.java
+32
-34
TaskController.java
...in/java/com/keymobile/rest/controller/TaskController.java
+42
-42
UserController.java
...in/java/com/keymobile/rest/controller/UserController.java
+2
-8
AssignmentDao.java
src/main/java/com/keymobile/rest/dao/AssignmentDao.java
+1
-3
DataInfoDao.java
src/main/java/com/keymobile/rest/dao/DataInfoDao.java
+1
-1
ProcessInfoDao.java
src/main/java/com/keymobile/rest/dao/ProcessInfoDao.java
+4
-4
TemplateDao.java
src/main/java/com/keymobile/rest/dao/TemplateDao.java
+2
-2
Assignment.java
src/main/java/com/keymobile/rest/model/Assignment.java
+9
-9
Process.java
src/main/java/com/keymobile/rest/model/Process.java
+7
-1
ProcessInfo.java
src/main/java/com/keymobile/rest/model/ProcessInfo.java
+10
-1
User.java
src/main/java/com/keymobile/rest/model/User.java
+0
-4
AssignmentService.java
...in/java/com/keymobile/rest/service/AssignmentService.java
+26
-27
DataInfoService.java
...main/java/com/keymobile/rest/service/DataInfoService.java
+6
-6
ProcessInfoService.java
...n/java/com/keymobile/rest/service/ProcessInfoService.java
+11
-11
TemplateService.java
...main/java/com/keymobile/rest/service/TemplateService.java
+10
-10
UserService.java
src/main/java/com/keymobile/rest/service/UserService.java
+4
-3
application-test.yml
src/main/resources/application-test.yml
+5
-36
bootstrap.yml
src/main/resources/bootstrap.yml
+0
-9
ProcessTest.java
src/test/java/com/keymobile/ProcessTest.java
+2
-2
No files found.
src/main/java/com/keymobile/ActivitiApplication.java
View file @
cbca00c9
...
...
@@ -9,7 +9,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@SpringBootApplication
//@EnableFeignClients
@EnableAutoConfiguration
(
exclude
=
{
org
.
springframework
.
boot
.
autoconfigure
.
security
.
servlet
.
SecurityAutoConfiguration
.
class
,
org
.
activiti
.
spring
.
boot
.
SecurityAutoConfiguration
.
class
})
public
class
ActivitiApplication
extends
SpringBootServletInitializer
{
...
...
src/main/java/com/keymobile/activiti/api/ProcessCtrl.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
api
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
org.activiti.bpmn.model.BpmnModel
;
import
org.activiti.engine.HistoryService
;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.TaskService
;
import
org.activiti.engine.history.HistoricActivityInstance
;
import
org.activiti.engine.history.HistoricProcessInstance
;
import
org.activiti.engine.history.HistoricProcessInstanceQuery
;
import
org.activiti.engine.history.HistoricTaskInstance
;
import
org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity
;
import
org.activiti.engine.impl.pvm.PvmTransition
;
import
org.activiti.engine.impl.pvm.process.ActivityImpl
;
import
org.activiti.engine.repository.Deployment
;
import
org.activiti.engine.repository.DeploymentBuilder
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.Comment
;
import
org.activiti.engine.task.Task
;
import
org.activiti.image.ProcessDiagramGenerator
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.keymobile.activiti.remote.ProtalRemoteService
;
import
com.keymobile.activiti.service.formService.FormExcelFileService
;
import
com.keymobile.activiti.utils.DateUtil
;
import
com.keymobile.activiti.utils.Page
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
path
=
"/rest/process"
)
public
class
ProcessCtrl
{
@Autowired
private
RepositoryService
repositoryService
;
@Autowired
private
RuntimeService
runtimeService
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
HistoryService
historyService
;
@Autowired
private
ProcessEngineConfigurationImpl
processEngineConfiguration
;
@Autowired
private
FormExcelFileService
formExcelFileService
;
// @Autowired
// private ProtalRemoteService protalService;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
ProcessCtrl
.
class
);
@ApiOperation
(
value
=
"根据roleId获取用户"
)
@PostMapping
(
value
=
"/getUsersByRoleId"
)
public
List
<
Map
<
String
,
Object
>>
getUsersByRoleId
(
@RequestParam
String
roleId
)
{
// Page page = protalService.getUsersByRoleId(roleId, 1, 100);
// return page.getContent();
return
null
;
}
@ApiOperation
(
value
=
"部署流程"
)
@PostMapping
(
value
=
"/deployment"
)
public
String
deloymentProcess
(
@RequestParam
MultipartFile
file
)
{
String
message
=
null
;
String
fileName
=
file
.
getOriginalFilename
();
try
{
DeploymentBuilder
deployBuilder
=
repositoryService
.
createDeployment
();
if
(
fileName
.
endsWith
(
".bpmn"
))
{
Deployment
deployment
=
deployBuilder
.
addInputStream
(
fileName
,
file
.
getInputStream
()).
deploy
();
logger
.
info
(
deployment
.
getName
());
logger
.
info
(
deployment
.
getId
());
logger
.
info
(
deployment
.
getDeploymentTime
().
toString
());
message
=
"部署流程成功"
;
}
else
{
message
=
"上传文件格式不是bpmn"
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"部署流程发生未知错误"
;
}
/**Deployment deployment = repositoryService.createDeployment().
addClasspathResource(processName).deploy();*/
return
message
;
}
@ApiOperation
(
value
=
"获取流程定义列表"
)
@PostMapping
(
value
=
"/getProcessDefList"
)
public
List
<
Map
<
String
,
Object
>>
getProcessDefList
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
ProcessDefinition
>
processDefList
=
repositoryService
.
createProcessDefinitionQuery
()
.
orderByProcessDefinitionVersion
().
asc
()
//按照版本的升序排列
.
list
();
for
(
ProcessDefinition
processDef
:
processDefList
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
processDef
.
getId
());
map
.
put
(
"proDefId"
,
processDef
.
getDeploymentId
());
map
.
put
(
"name"
,
processDef
.
getName
());
map
.
put
(
"key"
,
processDef
.
getKey
());
map
.
put
(
"version"
,
processDef
.
getVersion
());
if
(
processDef
.
isSuspended
())
{
map
.
put
(
"status"
,
"停用"
);
}
else
{
map
.
put
(
"status"
,
"启用"
);
}
result
.
add
(
map
);
}
return
result
;
}
@ApiOperation
(
value
=
"根据流程定义id获取流程实例"
)
@PostMapping
(
value
=
"/getProInstsByProId"
)
public
List
<
Map
<
String
,
Object
>>
getProInstsByProId
(
@RequestParam
String
procDefId
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
//创建历史流程实例,查询对象
HistoricProcessInstanceQuery
historicProcessInstanceQuery
=
historyService
.
createHistoricProcessInstanceQuery
();
historicProcessInstanceQuery
.
processDefinitionId
(
procDefId
);
List
<
HistoricProcessInstance
>
list
=
historicProcessInstanceQuery
.
list
();
for
(
HistoricProcessInstance
historicProcessInstance
:
list
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"proceDefId"
,
historicProcessInstance
.
getProcessDefinitionId
());
map
.
put
(
"proceInstId"
,
historicProcessInstance
.
getId
());
map
.
put
(
"bussinessKey"
,
historicProcessInstance
.
getBusinessKey
());
map
.
put
(
"startTime"
,
DateUtil
.
formatDate
(
historicProcessInstance
.
getStartTime
(),
"yyyy-MM-dd HH:mm:ss"
));
if
(
historicProcessInstance
.
getEndTime
()
!=
null
)
{
map
.
put
(
"endTime"
,
DateUtil
.
formatDate
(
historicProcessInstance
.
getEndTime
(),
"yyyy-MM-dd HH:mm:ss"
));
}
else
{
map
.
put
(
"endTime"
,
""
);
}
map
.
put
(
"runTime"
,
historicProcessInstance
.
getDurationInMillis
());
result
.
add
(
map
);
}
return
result
;
}
@ApiOperation
(
value
=
"发起流程并提交标准"
)
@PostMapping
(
value
=
"/startProcessAndSubmit"
)
public
String
startProcess
(
@RequestParam
String
processKey
,
@RequestParam
String
inputUser
,
@RequestParam
String
standModelId
)
{
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
""
);
ProcessInstance
pi
=
null
;
try
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
variables
.
put
(
"inputUser"
,
inputUser
);
//启动流程
pi
=
runtimeService
.
startProcessInstanceByKey
(
processKey
,
variables
);
//保存流程实例id和标准模板信息
formExcelFileService
.
saveFormExcelFile
(
pi
.
getId
(),
standModelId
,
inputUser
);
//根据流程实例id和发起流程用户获取当前任务
Task
resultTask
=
taskService
.
createTaskQuery
().
processInstanceId
(
pi
.
getId
()).
taskInvolvedUser
(
inputUser
).
singleResult
();
//直接提交标准到下个节点
taskService
.
claim
(
resultTask
.
getId
(),
inputUser
);
//保存审批意见
taskService
.
addComment
(
resultTask
.
getId
(),
pi
.
getId
(),
""
);
//审批任务
taskService
.
complete
(
resultTask
.
getId
());
logger
.
info
(
"流程启动成功,流程id:"
+
pi
.
getId
()
+
",当前任务id:"
+
resultTask
.
getId
());
message
.
append
(
"流程启动成功,流程id:"
).
append
(
pi
.
getId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
.
append
(
"流程启动发生未知错误"
);
}
return
message
.
toString
();
}
@ApiOperation
(
value
=
"获取待办任务列表"
)
@PostMapping
(
value
=
"/getTaskListByUser"
)
public
List
<
Map
<
String
,
Object
>>
getTaskListByUser
(
@RequestParam
String
user
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Task
>
resultTask
=
taskService
.
createTaskQuery
().
taskInvolvedUser
(
user
).
list
();
for
(
Task
task
:
resultTask
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"taskId"
,
task
.
getId
());
map
.
put
(
"name"
,
task
.
getName
());
map
.
put
(
"createTime"
,
DateUtil
.
formatDate
(
task
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
map
.
put
(
"processInstanceId"
,
task
.
getProcessInstanceId
());
result
.
add
(
map
);
}
return
result
;
}
@ApiOperation
(
value
=
"根据任务id查询当前节点信息"
)
@PostMapping
(
value
=
"/getProcessEntityByTaskId"
)
public
Map
<
String
,
Object
>
getProcessEntityByTaskId
(
@RequestParam
String
taskId
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
Task
task
=
taskService
.
createTaskQuery
()
// 创建任务查询
.
taskId
(
taskId
)
// 根据任务id查询
.
singleResult
();
resultMap
.
put
(
"name"
,
task
.
getName
());
resultMap
.
put
(
"taskDefKey"
,
task
.
getTaskDefinitionKey
());
//判断是否是审批节点
if
(
task
.
getTaskDefinitionKey
().
indexOf
(
"applyTask"
)
>=
0
)
{
resultMap
.
put
(
"isApplyNode"
,
"1"
);
}
else
{
resultMap
.
put
(
"isApplyNode"
,
"0"
);
}
//判断是否需要动态添加参与者
//添加意见征集节点需要添加参与者
if
(
task
.
getTaskDefinitionKey
().
indexOf
(
"selectStandardApartment"
)
>=
0
||
task
.
getTaskDefinitionKey
().
indexOf
(
"commentCollction"
)
>=
0
)
{
resultMap
.
put
(
"needAssignee"
,
"1"
);
}
else
{
resultMap
.
put
(
"needAssignee"
,
"0"
);
}
//判断是否需要上传excel文件
if
(
task
.
getTaskDefinitionKey
().
indexOf
(
"writeStandardAttr"
)
>=
0
)
{
resultMap
.
put
(
"needUploadExcel"
,
"1"
);
}
else
{
resultMap
.
put
(
"needUploadExcel"
,
"0"
);
}
return
resultMap
;
}
@ApiOperation
(
value
=
"审批任务"
)
@PostMapping
(
value
=
"/completeTask"
)
public
String
completeTask
(
@RequestParam
String
taskId
,
@RequestParam
String
user
,
@RequestParam
(
value
=
"result"
,
required
=
false
)
String
result
,
@RequestParam
(
value
=
"assignees"
,
required
=
false
)
String
assignees
,
@RequestParam
String
processInstanceId
,
@RequestParam
(
value
=
"comment"
,
required
=
false
)
String
comment
,
@RequestParam
(
value
=
"file"
,
required
=
false
)
MultipartFile
file
)
{
String
message
=
null
;
try
{
if
(
StringUtils
.
isBlank
(
comment
))
{
comment
=
""
;
}
//根据任务id获取当前任务信息
Task
task
=
taskService
.
createTaskQuery
()
// 创建任务查询
.
taskId
(
taskId
)
// 根据任务id查询
.
singleResult
();
Map
<
String
,
Object
>
vars
=
new
HashMap
<>();
//如果是意见征集环节,设置征集人
if
(
task
.
getTaskDefinitionKey
().
indexOf
(
"commentCollction"
)
>=
0
)
{
if
(
StringUtils
.
isNotBlank
(
assignees
))
{
String
[]
commentUsers
=
assignees
.
split
(
","
);
vars
.
put
(
"commentUsers"
,
Arrays
.
asList
(
commentUsers
));
}
}
//认领任务
//taskService.claim(taskId, user);
taskService
.
setAssignee
(
taskId
,
user
);
//保存审批意见
taskService
.
addComment
(
taskId
,
processInstanceId
,
comment
);
//如果需要动态设置参与者
if
(
StringUtils
.
isNotBlank
(
assignees
))
{
vars
.
put
(
"writeStandardAssignees"
,
assignees
);
}
//如果需要审批结果
if
(
StringUtils
.
isNotBlank
(
result
))
{
vars
.
put
(
"_ACTIVITI_SKIP_EXPRESSION_ENABLED"
,
true
);
vars
.
put
(
"sign"
,
result
);
}
taskService
.
complete
(
taskId
,
vars
);
//如果需要修改excel
if
(
file
!=
null
)
{
formExcelFileService
.
updateFormExcelFile
(
processInstanceId
,
assignees
,
file
);
}
message
=
"审批成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"审批失败"
;
}
return
message
;
}
@ApiOperation
(
value
=
"获取审批详情"
)
@PostMapping
(
value
=
"/getTaskDetail"
)
public
List
<
Map
<
String
,
Object
>>
getTaskDetail
(
@RequestParam
String
processInstanceId
)
{
List
<
Map
<
String
,
Object
>>
details
=
new
ArrayList
<>();
List
<
HistoricTaskInstance
>
htiList
=
historyService
.
createHistoricTaskInstanceQuery
()
//历史任务表查询
.
processInstanceId
(
processInstanceId
)
//使用流程实例ID查询
.
orderByTaskCreateTime
().
asc
()
//根据任务创建时间进行排序
.
list
();
for
(
HistoricTaskInstance
hti
:
htiList
)
{
Map
<
String
,
Object
>
detail
=
new
HashMap
<>();
//获取任务id
String
taskId
=
hti
.
getId
();
//根据任务id去comment表获取批注信息
List
<
Comment
>
comments
=
taskService
.
getTaskComments
(
taskId
);
//comment不为空
if
(!
comments
.
isEmpty
())
{
detail
.
put
(
"taskName"
,
hti
.
getName
());
detail
.
put
(
"assignee"
,
hti
.
getAssignee
());
detail
.
put
(
"comment"
,
comments
.
get
(
0
).
getFullMessage
());
detail
.
put
(
"startTime"
,
DateUtil
.
formatDate
(
hti
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
detail
.
put
(
"endTime"
,
DateUtil
.
formatDate
(
hti
.
getEndTime
(),
"yyyy-MM-dd HH:mm:ss"
));
details
.
add
(
detail
);
}
}
return
details
;
}
@ApiOperation
(
value
=
"启用流程,activeProInst:是否级联启用所有流程实例,0:否,1:是"
)
@PostMapping
(
value
=
"/acticeProcessDef"
)
public
String
activeProcessDef
(
@RequestParam
String
processKey
,
@RequestParam
String
activeProInst
)
{
String
message
=
null
;
try
{
if
(
"1"
.
equals
(
processKey
))
{
repositoryService
.
activateProcessDefinitionByKey
(
processKey
,
true
,
null
);
}
else
{
repositoryService
.
activateProcessDefinitionByKey
(
processKey
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"启用流程发生未知错误"
;
}
return
message
;
}
@ApiOperation
(
value
=
"停用流程,suspendProInst:是否级联停用所有流程实例,0:否,1:是"
)
@PostMapping
(
value
=
"/suspendProcessDef"
)
public
String
suspendPrpcessDef
(
@RequestParam
String
processKey
,
@RequestParam
String
suspendProInst
)
{
String
message
=
null
;
try
{
if
(
"1"
.
equals
(
suspendProInst
))
{
repositoryService
.
suspendProcessDefinitionByKey
(
processKey
,
true
,
null
);
}
else
{
repositoryService
.
suspendProcessDefinitionByKey
(
processKey
);
}
message
=
"流程已停用"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"停用流程发生未知错误"
;
}
return
message
;
}
@ApiOperation
(
value
=
"生成流程图"
)
@GetMapping
(
value
=
"/queryProImg"
)
@ResponseBody
public
void
queryProImg
(
@RequestParam
String
processDefId
,
HttpServletResponse
response
)
{
List
<
String
>
names
=
repositoryService
.
getDeploymentResourceNames
(
processDefId
);
String
imageName
=
null
;
for
(
String
name
:
names
)
{
if
(
name
.
indexOf
(
".png"
)
>=
0
)
{
imageName
=
name
;
}
}
if
(
imageName
!=
null
)
{
InputStream
is
=
repositoryService
.
getResourceAsStream
(
processDefId
,
imageName
);
try
(
ByteArrayOutputStream
output
=
new
ByteArrayOutputStream
())
{
byte
[]
buffer
=
new
byte
[
1024
*
4
];
int
n
=
0
;
while
(-
1
!=
(
n
=
is
.
read
(
buffer
)))
{
output
.
write
(
buffer
,
0
,
n
);
}
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
response
.
getOutputStream
().
write
(
output
.
toByteArray
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
//获取历史流程实例
//HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
//根据流程定义获取输入流
//InputStream is = repositoryService.getProcessDiagram(processInstance.getProcessDefinitionId());
/**String pngPath = "D:\\demo2"+System.currentTimeMillis()+".png";
File file = new File(pngPath);
try(FileOutputStream fos = new FileOutputStream(file)){
BufferedImage bi = ImageIO.read(is);
if(!file.exists()) {
file.createNewFile();
}
ImageIO.write(bi, "png", fos);
}catch(Exception e) {
e.printStackTrace();
}*/
logger
.
info
(
"图片生成成功"
);
}
@ApiOperation
(
value
=
"生成流程高亮图"
)
@GetMapping
(
value
=
"/queryProHighLightImg"
)
@ResponseBody
public
void
queryProHighLightImg
(
@RequestParam
String
processInstanceId
,
HttpServletResponse
response
)
{
//获取历史流程实例
HistoricProcessInstance
processInstance
=
historyService
.
createHistoricProcessInstanceQuery
().
processInstanceId
(
processInstanceId
).
singleResult
();
//获取流程图
BpmnModel
bpmnModel
=
repositoryService
.
getBpmnModel
(
processInstance
.
getProcessDefinitionId
());
ProcessDiagramGenerator
diagramGenerator
=
processEngineConfiguration
.
getProcessDiagramGenerator
();
ProcessDefinitionEntity
definitionEntity
=
(
ProcessDefinitionEntity
)
repositoryService
.
getProcessDefinition
(
processInstance
.
getProcessDefinitionId
());
List
<
HistoricActivityInstance
>
highLightedActivitList
=
historyService
.
createHistoricActivityInstanceQuery
().
processInstanceId
(
processInstanceId
).
list
();
//高亮环节id集合
List
<
String
>
highLightedActivitis
=
new
ArrayList
<>();
//高亮线路id集合
List
<
String
>
highLightedFlows
=
getHighLightedFlows
(
definitionEntity
,
highLightedActivitList
);
for
(
HistoricActivityInstance
tempActivity
:
highLightedActivitList
)
{
String
activityId
=
tempActivity
.
getActivityId
();
highLightedActivitis
.
add
(
activityId
);
}
//配置字体
InputStream
imageStream
=
diagramGenerator
.
generateDiagram
(
bpmnModel
,
"png"
,
highLightedActivitis
,
highLightedFlows
,
"宋体"
,
"微软雅黑"
,
"黑体"
,
null
,
2.0
);
/**String pngPath = "D:\\highLight2"+System.currentTimeMillis()+".png";
File file = new File(pngPath);
try(FileOutputStream fos = new FileOutputStream(file)){
BufferedImage bi = ImageIO.read(imageStream);
if(!file.exists()) {
file.createNewFile();
}
ImageIO.write(bi, "png", fos);
}catch(Exception e) {
e.printStackTrace();
}*/
try
(
ByteArrayOutputStream
output
=
new
ByteArrayOutputStream
())
{
byte
[]
buffer
=
new
byte
[
1024
*
4
];
int
n
=
0
;
while
(-
1
!=
(
n
=
imageStream
.
read
(
buffer
)))
{
output
.
write
(
buffer
,
0
,
n
);
}
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
response
.
getOutputStream
().
write
(
output
.
toByteArray
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
logger
.
info
(
"生成高亮图片成功"
);
}
private
List
<
String
>
getHighLightedFlows
(
ProcessDefinitionEntity
processDefinitionEntity
,
List
<
HistoricActivityInstance
>
historicActivityInstances
)
{
List
<
String
>
highFlows
=
new
ArrayList
<>();
// 用以保存高亮的线flowId
for
(
int
i
=
0
;
i
<
historicActivityInstances
.
size
()
-
1
;
i
++)
{
// 对历史流程节点进行遍历
ActivityImpl
activityImpl
=
processDefinitionEntity
.
findActivity
(
historicActivityInstances
.
get
(
i
)
.
getActivityId
());
// 得到节点定义的详细信息
List
<
ActivityImpl
>
sameStartTimeNodes
=
new
ArrayList
<>();
// 用以保存后需开始时间相同的节点
ActivityImpl
sameActivityImpl1
=
processDefinitionEntity
.
findActivity
(
historicActivityInstances
.
get
(
i
+
1
)
.
getActivityId
());
// 将后面第一个节点放在时间相同节点的集合里
sameStartTimeNodes
.
add
(
sameActivityImpl1
);
for
(
int
j
=
i
+
1
;
j
<
historicActivityInstances
.
size
()
-
1
;
j
++)
{
HistoricActivityInstance
activityImpl1
=
historicActivityInstances
.
get
(
j
);
// 后续第一个节点
HistoricActivityInstance
activityImpl2
=
historicActivityInstances
.
get
(
j
+
1
);
// 后续第二个节点
if
(
activityImpl1
.
getStartTime
().
equals
(
activityImpl2
.
getStartTime
()))
{
// 如果第一个节点和第二个节点开始时间相同保存
ActivityImpl
sameActivityImpl2
=
processDefinitionEntity
.
findActivity
(
activityImpl2
.
getActivityId
());
sameStartTimeNodes
.
add
(
sameActivityImpl2
);
}
else
{
// 有不相同跳出循环
break
;
}
}
List
<
PvmTransition
>
pvmTransitions
=
activityImpl
.
getOutgoingTransitions
();
// 取出节点的所有出去的线
for
(
PvmTransition
pvmTransition
:
pvmTransitions
)
{
// 对所有的线进行遍历
ActivityImpl
pvmActivityImpl
=
(
ActivityImpl
)
pvmTransition
.
getDestination
();
// 如果取出的线的目标节点存在时间相同的节点里,保存该线的id,进行高亮显示
if
(
sameStartTimeNodes
.
contains
(
pvmActivityImpl
))
{
highFlows
.
add
(
pvmTransition
.
getId
());
}
}
}
return
highFlows
;
}
}
src/main/java/com/keymobile/activiti/api/ProcessFormExcelCtrl.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
api
;
import
java.net.URLEncoder
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.activiti.service.formService.FormExcelFileService
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
path
=
"/rest/processForm"
)
public
class
ProcessFormExcelCtrl
{
@Autowired
private
FormExcelFileService
formExcelFileService
;
@ApiOperation
(
value
=
"根据流程实例id获取关联的表单excel详情"
)
@PostMapping
(
value
=
"/getFormExcelFileByProInstId"
)
public
Map
<
String
,
Object
>
getFormExcelFileByProInstId
(
@RequestParam
String
processInstId
)
{
return
formExcelFileService
.
getFormExcelFileByProInstId
(
processInstId
);
}
@ApiOperation
(
value
=
"根据流程实例id查看关联表单excel内容"
)
@GetMapping
(
value
=
"/getFileContent"
)
@ResponseBody
public
void
getFileContent
(
@RequestParam
String
processInstId
,
HttpServletResponse
response
)
throws
Exception
{
Map
<
String
,
Object
>
result
=
formExcelFileService
.
getFormExcelFileByProInstId
(
processInstId
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment;fileName="
+
URLEncoder
.
encode
(
result
.
get
(
"name"
).
toString
(),
"UTF-8"
));
response
.
getOutputStream
().
write
(
formExcelFileService
.
getFormExcelContentByProInstId
(
processInstId
));
}
}
src/main/java/com/keymobile/activiti/api/StandardModelCtrl.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
api
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.keymobile.activiti.model.StandardModelFile
;
import
com.keymobile.activiti.service.formService.StandardModelFileService
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
path
=
"/rest/standardModel"
)
public
class
StandardModelCtrl
{
@Autowired
private
StandardModelFileService
standModelService
;
@ApiOperation
(
value
=
"上传模板文件(excelType(0和1): 0:数据标准 1:指标标准)"
)
@PostMapping
(
value
=
"/uploadModelFile"
)
public
String
uploadModelFile
(
@RequestParam
MultipartFile
file
,
@RequestParam
(
value
=
"id"
,
required
=
false
)
String
id
,
@RequestParam
String
uploader
,
@RequestParam
String
excelType
)
throws
Exception
{
StandardModelFile
standFile
=
null
;
if
(
StringUtils
.
isBlank
(
id
))
{
standFile
=
new
StandardModelFile
();
standFile
.
setName
(
file
.
getOriginalFilename
());
standFile
.
setFileType
(
file
.
getContentType
());
standFile
.
setContent
(
file
.
getBytes
());
standFile
.
setLastUpdater
(
uploader
);
standFile
.
setSize
(
file
.
getSize
());
standFile
.
setContentType
(
excelType
);
}
else
{
standFile
=
standModelService
.
getById
(
id
);
standFile
.
setName
(
file
.
getOriginalFilename
());
standFile
.
setFileType
(
file
.
getContentType
());
standFile
.
setContent
(
file
.
getBytes
());
standFile
.
setLastUpdater
(
uploader
);
standFile
.
setSize
(
file
.
getSize
());
standFile
.
setContentType
(
excelType
);
}
return
standModelService
.
saveOrUpdateModel
(
standFile
);
}
@ApiOperation
(
value
=
"获取所有模板文件"
)
@PostMapping
(
value
=
"/getAllModelFile"
)
public
List
<
Map
<
String
,
Object
>>
getAllModelFile
()
throws
Exception
{
return
standModelService
.
getAllStandardModel
();
}
@ApiOperation
(
value
=
"查看文件内容"
)
@GetMapping
(
value
=
"/getFileContent"
)
@ResponseBody
public
void
getFileContent
(
@RequestParam
String
id
,
HttpServletResponse
response
)
throws
Exception
{
StandardModelFile
standFile
=
standModelService
.
getById
(
id
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment;fileName="
+
URLEncoder
.
encode
(
standFile
.
getName
(),
"UTF-8"
));
response
.
getOutputStream
().
write
(
standFile
.
getContent
());
}
}
src/main/java/com/keymobile/activiti/conf/FeignClientConfig.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
conf
;
import
feign.auth.BasicAuthRequestInterceptor
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
//@Configuration
public
class
FeignClientConfig
{
@Value
(
"${security.authUser}"
)
private
String
authUser
;
@Value
(
"${security.authPwd}"
)
private
String
authPwd
;
@Bean
public
BasicAuthRequestInterceptor
getBasicAuthRequestInterceptor
()
{
return
new
BasicAuthRequestInterceptor
(
authUser
,
authPwd
);
}
}
\ No newline at end of file
src/main/java/com/keymobile/activiti/conf/MongoDBConfig.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
conf
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.config.AbstractMongoConfiguration
;
import
org.springframework.data.mongodb.core.SimpleMongoDbFactory
;
import
org.springframework.data.mongodb.gridfs.GridFsTemplate
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoClientOptions
;
import
com.mongodb.MongoClientURI
;
import
com.mongodb.client.MongoDatabase
;
import
com.mongodb.client.gridfs.GridFSBucket
;
import
com.mongodb.client.gridfs.GridFSBuckets
;
@Configuration
public
class
MongoDBConfig
extends
AbstractMongoConfiguration
{
@Value
(
"${mongodb.uri}"
)
private
String
host
;
@Value
(
"${mongodb.database}"
)
private
String
database
;
@Value
(
"${mongodb.username}"
)
private
String
user
;
@Value
(
"${mongodb.password}"
)
private
String
pswd
;
@Value
(
"${mongodb.maxConnectionIdleTime}"
)
private
Integer
maxConnectionIdleTime
=
60000
;
@Override
protected
String
getDatabaseName
()
{
return
database
;
}
@Bean
public
MongoDbFactory
mongoDbFactory
()
{
return
new
SimpleMongoDbFactory
(
this
.
mongoClient
(),
this
.
getDatabaseName
());
}
@Bean
public
GridFsTemplate
gridFsTemplate
()
throws
Exception
{
return
new
GridFsTemplate
(
mongoDbFactory
(),
mappingMongoConverter
());
}
@Bean
public
GridFSBucket
getGridFSBuckets
()
{
MongoDatabase
db
=
mongoDbFactory
().
getDb
();
return
GridFSBuckets
.
create
(
db
);
}
@Override
public
MongoClient
mongoClient
()
{
String
uri
=
String
.
format
(
"mongodb://%s:%s@%s/%s"
,
user
,
pswd
,
host
,
database
);
MongoClientOptions
.
Builder
builder
=
new
MongoClientOptions
.
Builder
();
builder
.
maxConnectionIdleTime
(
maxConnectionIdleTime
);
MongoClientURI
clientURI
=
new
MongoClientURI
(
uri
,
builder
);
return
new
MongoClient
(
clientURI
);
}
}
src/main/java/com/keymobile/activiti/conf/RedisClusterConfig.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
conf
;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisClusterConfiguration;
//import org.springframework.data.redis.connection.RedisNode;
//import org.springframework.data.redis.connection.RedisPassword;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//import org.springframework.session.data.redis.config.ConfigureRedisAction;
//import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
//import redis.clients.jedis.JedisPoolConfig;
//
//import java.util.HashSet;
//import java.util.Set;
//
///**
// * Created by Administrator on 2019/2/28.
// */
//@EnableRedisHttpSession
//@Configuration
public
class
RedisClusterConfig
{
//
// @Value("${spring.redis.cluster.nodes}")
// private String clusterNodes;
// @Value("${spring.redis.cluster.max-redirects}")
// private int maxRedirects;
// @Value("${spring.redis.password}")
// private String password;
// @Value("${spring.redis.timeout}")
// private int timeout;
// @Value("${spring.redis.maxIdle}")
// private int maxIdle;
// @Value("${spring.redis.maxTotal}")
// private int maxTotal;
// @Value("${spring.redis.maxWaitMillis}")
// private int maxWaitMillis;
// @Value("${spring.redis.minEvictableIdleTimeMillis}")
// private int minEvictableIdleTimeMillis;
// @Value("${spring.redis.numTestsPerEvictionRun}")
// private int numTestsPerEvictionRun;
// @Value("${spring.redis.timeBetweenEvictionRunsMillis}")
// private int timeBetweenEvictionRunsMillis;
// @Value("${spring.redis.testOnBorrow}")
// private boolean testOnBorrow;
// @Value("${spring.redis.testWhileIdle}")
// private boolean testWhileIdle;
//
// @Bean
// public JedisPoolConfig getJedisPoolConfig() {
// JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
// // 最大空闲数
// jedisPoolConfig.setMaxIdle(maxIdle);
// // 连接池的最大数据库连接数
// jedisPoolConfig.setMaxTotal(maxTotal);
// // 最大建立连接等待时间
// jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
// // 逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
// jedisPoolConfig.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
// // 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
// jedisPoolConfig.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
// // 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
// jedisPoolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
// // 是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个
// jedisPoolConfig.setTestOnBorrow(testOnBorrow);
// // 在空闲时检查有效性, 默认false
// jedisPoolConfig.setTestWhileIdle(testWhileIdle);
// return jedisPoolConfig;
// }
//
// /**
// * Redis集群的配置
// * @return RedisClusterConfiguration
// * @throws
// */
// @Bean
// public RedisClusterConfiguration redisClusterConfiguration(){
// RedisClusterConfiguration redisClusterConfiguration = new RedisClusterConfiguration();
// //Set<RedisNode> clusterNodes
// String[] serverArray = clusterNodes.split(",");
// Set<RedisNode> nodes = new HashSet<RedisNode>();
// for(String ipPort:serverArray){
// String[] ipAndPort = ipPort.split(":");
// nodes.add(new RedisNode(ipAndPort[0].trim(),Integer.valueOf(ipAndPort[1])));
// }
// redisClusterConfiguration.setClusterNodes(nodes);
// redisClusterConfiguration.setMaxRedirects(maxRedirects);
// redisClusterConfiguration.setPassword(RedisPassword.of(password));
// return redisClusterConfiguration;
// }
//
// /**
// * @param
// * @return
// * @Description:redis连接工厂类
// * @date 2018/10/25 19:45
// */
// @Bean
// public JedisConnectionFactory jedisConnectionFactory() {
// if (clusterNodes.split(",").length == 1) {
// //非多节点集群
// JedisConnectionFactory factory = new JedisConnectionFactory();
// factory.setHostName(clusterNodes.split(":")[0]);
// factory.setPort(Integer.valueOf(clusterNodes.split(":")[1]));
// factory.setPassword(password);
// factory.setTimeout(timeout);
// return factory;
// } else {
// //集群模式
// JedisConnectionFactory factory = new JedisConnectionFactory(redisClusterConfiguration(),getJedisPoolConfig());
// factory.setDatabase(0);
// factory.setTimeout(timeout);
// factory.setUsePool(true);
// return factory;
// }
// }
//
// /**
// * 实例化 RedisTemplate 对象
// *
// * @return
// */
// @Bean
// public RedisTemplate<String, Object> redisTemplate() {
// RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
// initDomainRedisTemplate(redisTemplate);
// return redisTemplate;
// }
//
// /**
// * 设置数据存入 redis 的序列化方式,并开启事务
// * 使用默认的序列化会导致key乱码
// *
// */
// private void initDomainRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
// //如果不配置Serializer,那么存储的时候缺省使用String,如果用User类型存储,那么会提示错误User can't cast to String!
// redisTemplate.setKeySerializer(new StringRedisSerializer());
// //这个地方有一个问题,这种序列化器会将value序列化成对象存储进redis中,如果
// //你想取出value,然后进行自增的话,这种序列化器是不可以的,因为对象不能自增;
// //需要改成StringRedisSerializer序列化器。
// redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
// redisTemplate.setEnableTransactionSupport(false);
// redisTemplate.setConnectionFactory(jedisConnectionFactory());
// }
//
// @Bean
// public static ConfigureRedisAction configureRedisAction(){
// return ConfigureRedisAction.NO_OP;
// }
//
}
src/main/java/com/keymobile/activiti/conf/RedisConfig.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
conf
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* redis配置类
*/
//@Configuration
//@AutoConfigureAfter(RedisAutoConfiguration.class)
public
class
RedisConfig
{
// @Bean
// RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
//
// RedisTemplate<String, Object> template = new RedisTemplate<>();
// template.setConnectionFactory(redisConnectionFactory);
//
// //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
// Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Object.class);
//
// ObjectMapper mapper = new ObjectMapper();
// mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
// serializer.setObjectMapper(mapper);
//
// template.setValueSerializer(serializer);
// //使用StringRedisSerializer来序列化和反序列化redis的key值
// template.setKeySerializer(new StringRedisSerializer());
// template.setHashKeySerializer(new StringRedisSerializer());
// template.setHashValueSerializer(serializer);
// template.afterPropertiesSet();
// return template;
// }
}
src/main/java/com/keymobile/activiti/conf/SecurityConfig.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
conf
;
import
javax.sql.DataSource
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
private
static
final
String
usersQuery
=
"select concat(user_id, ':', id, ':', disname), `password`, true from p_user where user_id = ?"
;
private
static
final
String
rolesQuery
=
"select t1.user_id, concat(concat(\"ROLE_\", t1.author_name), ':', GROUP_CONCAT(COALESCE(t2.domain_id, '*'))) as role_name\n"
+
"from \n"
+
"(select a.user_id, d.author_name\n"
+
"from p_user a, p_user_group g, p_group_role b, p_author_role c, p_author d\n"
+
"where a.user_id = g.user_id and g.group_id = b.group_id and b.role_id = c.role_id and c.author_id = d.author_id\n"
+
"and a.user_id = substring_index(?, \":\", 1)) t1\n"
+
"left join\n"
+
"(select a.user_id, c.domain_id\n"
+
"from p_user a, p_user_domain b, p_domain c\n"
+
"where a.user_id = b.user_id and b.domain_id = c.domain_id) t2\n"
+
"on t1.user_id = t2.user_id\n"
+
"group by t1.author_name"
;
@Autowired
private
DataSource
dataSource
;
@Value
(
"${security.permit}"
)
private
boolean
permit
=
true
;
@Autowired
public
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
jdbcAuthentication
().
usersByUsernameQuery
(
usersQuery
).
authoritiesByUsernameQuery
(
rolesQuery
)
.
dataSource
(
dataSource
).
passwordEncoder
(
new
SHA1PasswordEncoder
());
}
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
if
(
permit
)
http
.
httpBasic
().
and
().
authorizeRequests
().
anyRequest
().
permitAll
();
else
{
http
.
httpBasic
().
and
().
authorizeRequests
().
antMatchers
(
"/loginlog/save"
).
permitAll
()
.
anyRequest
().
authenticated
();
}
http
.
csrf
().
disable
();
http
.
headers
().
frameOptions
().
disable
();
}
class
SHA1PasswordEncoder
implements
PasswordEncoder
{
@Override
public
String
encode
(
CharSequence
charSequence
)
{
return
DigestUtils
.
sha1Hex
(
charSequence
.
toString
());
}
@Override
public
boolean
matches
(
CharSequence
charSequence
,
String
s
)
{
return
DigestUtils
.
sha1Hex
(
charSequence
.
toString
()).
equals
(
s
);
}
}
}
src/main/java/com/keymobile/activiti/listener/WirteStandardAttrListener.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
listener
;
import
java.util.Arrays
;
import
org.activiti.engine.delegate.DelegateTask
;
import
org.activiti.engine.delegate.TaskListener
;
public
class
WirteStandardAttrListener
implements
TaskListener
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Override
public
void
notify
(
DelegateTask
delegateTask
)
{
Object
obj
=
delegateTask
.
getVariable
(
"writeStandardAssignees"
);
if
(
obj
!=
null
)
{
String
assignees
=
obj
.
toString
();
delegateTask
.
addCandidateUsers
(
Arrays
.
asList
(
assignees
.
split
(
","
)));
}
}
}
src/main/java/com/keymobile/activiti/model/FormExcelFile.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.keymobile.activiti.utils.DateUtil
;
import
lombok.Data
;
/**
* 流程表单excel文件信息表
*/
@Data
@Document
(
collection
=
"ProcessFormExcelFile"
)
public
class
FormExcelFile
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
// 主键
private
String
id
;
private
String
processInstId
;
//流程实例id
private
String
name
;
// 文件名称
private
String
contentType
;
// 文件类型
private
String
fileType
;
// 文件后缀格式
private
long
size
;
private
String
lastUpdateTime
=
DateUtil
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdater
;
private
byte
[]
content
;
// 文件内容
private
String
path
;
// 文件路径
}
src/main/java/com/keymobile/activiti/model/StandardModelFile.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.keymobile.activiti.utils.DateUtil
;
import
lombok.Data
;
/**
* 标准模板文件表
*/
@Data
@Document
(
collection
=
"StandardModelFile"
)
public
class
StandardModelFile
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
// 主键
private
String
id
;
private
String
name
;
// 文件名称
private
String
contentType
;
// 文件类型
private
String
fileType
;
// 文件后缀格式
private
long
size
;
private
String
lastUpdateTime
=
DateUtil
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdater
;
private
byte
[]
content
;
// 文件内容
private
String
path
;
// 文件路径
}
src/main/java/com/keymobile/activiti/persistence/FormExcelFileRepository.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
persistence
;
import
java.util.Optional
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.keymobile.activiti.model.FormExcelFile
;
public
interface
FormExcelFileRepository
extends
MongoRepository
<
FormExcelFile
,
String
>{
public
Optional
<
FormExcelFile
>
findByProcessInstId
(
String
processInstId
);
}
src/main/java/com/keymobile/activiti/persistence/StandardModelFileRepository.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
persistence
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.keymobile.activiti.model.StandardModelFile
;
public
interface
StandardModelFileRepository
extends
MongoRepository
<
StandardModelFile
,
String
>{
}
src/main/java/com/keymobile/activiti/remote/ProtalRemoteService.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
remote
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.keymobile.activiti.utils.Page
;
//@FeignClient(value = "portal")
public
interface
ProtalRemoteService
{
@GetMapping
(
value
=
"/role/roleusers"
)
public
Page
getUsersByRoleId
(
@RequestParam
(
"id"
)
String
id
,
@RequestParam
(
"pageNumber"
)
int
pageNumber
,
@RequestParam
(
"pageSize"
)
int
pageSize
);
}
src/main/java/com/keymobile/activiti/service/ActivityDemoServiceImpl.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
service
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.activiti.engine.delegate.DelegateExecution
;
import
org.springframework.stereotype.Service
;
@Service
public
class
ActivityDemoServiceImpl
{
public
void
updateBizStatus
(
DelegateExecution
execution
,
String
status
)
{
String
bizId
=
execution
.
getProcessBusinessKey
();
//根据业务id自行处理业务表
System
.
out
.
println
(
"业务表["
+
bizId
+
"]状态更改成功,状态更改为:"
+
status
);
}
public
List
<
String
>
findUsersForSL
(
DelegateExecution
execution
){
return
Arrays
.
asList
(
"zhangkb"
,
"kaibin"
);
}
public
List
<
String
>
findUsersForSP
(
DelegateExecution
execution
){
return
Arrays
.
asList
(
"zhangkc"
,
"kaicheng"
);
}
}
src/main/java/com/keymobile/activiti/service/GroupDataStandardServiceImpl.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
service
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.activiti.engine.delegate.DelegateExecution
;
import
org.springframework.stereotype.Service
;
@Service
public
class
GroupDataStandardServiceImpl
{
public
List
<
String
>
findAssigneesForProcess
(
DelegateExecution
execution
,
String
groupsString
)
{
System
.
out
.
println
(
groupsString
);
String
[]
groups
=
groupsString
.
split
(
","
);
return
this
.
getAssignessByGroup
(
groups
);
}
private
List
<
String
>
getAssignessByGroup
(
String
[]
groups
)
{
List
<
String
>
assignees
=
new
ArrayList
<>();
for
(
String
group
:
groups
)
{
if
(
"group1"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group2"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group3"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group4"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group5"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group6"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group7"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
if
(
"group8"
.
equals
(
group
))
{
assignees
.
addAll
(
Arrays
.
asList
(
"root"
));
}
}
return
assignees
;
}
}
src/main/java/com/keymobile/activiti/service/formService/FormExcelFileService.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
service
.
formService
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.keymobile.activiti.model.FormExcelFile
;
import
com.keymobile.activiti.model.StandardModelFile
;
import
com.keymobile.activiti.persistence.FormExcelFileRepository
;
import
com.keymobile.activiti.persistence.StandardModelFileRepository
;
@Service
public
class
FormExcelFileService
{
@Autowired
private
FormExcelFileRepository
formExcelFileRepository
;
@Autowired
private
StandardModelFileRepository
standModelRepository
;
//根据流程实例id获取表单excel文件详情
public
Map
<
String
,
Object
>
getFormExcelFileByProInstId
(
String
proInstId
){
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Optional
<
FormExcelFile
>
formFile
=
formExcelFileRepository
.
findByProcessInstId
(
proInstId
);
if
(
formFile
.
isPresent
())
{
result
.
put
(
"id"
,
formFile
.
get
().
getId
());
result
.
put
(
"processInstId"
,
formFile
.
get
().
getProcessInstId
());
result
.
put
(
"name"
,
formFile
.
get
().
getName
());
result
.
put
(
"lastUpdateTime"
,
formFile
.
get
().
getLastUpdateTime
());
result
.
put
(
"lastUpdater"
,
formFile
.
get
().
getLastUpdater
());
}
return
result
;
}
//根据流程实例id获取表单excel的内容
public
byte
[]
getFormExcelContentByProInstId
(
String
proInstId
)
{
Optional
<
FormExcelFile
>
formFile
=
formExcelFileRepository
.
findByProcessInstId
(
proInstId
);
if
(
formFile
.
isPresent
())
{
return
formFile
.
get
().
getContent
();
}
else
{
return
null
;
}
}
//保存或者修改表单excel表
public
String
saveOrUpdateFormExcelFile
(
FormExcelFile
file
)
{
file
=
formExcelFileRepository
.
save
(
file
);
return
file
.
getId
();
}
//保存流程实例id对应的excel文件
public
void
saveFormExcelFile
(
String
processInstId
,
String
standardModelId
,
String
inputUser
)
{
//根据模板id查询模板信息
Optional
<
StandardModelFile
>
standModelFile
=
standModelRepository
.
findById
(
standardModelId
);
if
(
standModelFile
.
isPresent
())
{
FormExcelFile
formFile
=
new
FormExcelFile
();
formFile
.
setProcessInstId
(
processInstId
);
formFile
.
setName
(
standModelFile
.
get
().
getName
());
formFile
.
setLastUpdater
(
inputUser
);
formFile
.
setContent
(
standModelFile
.
get
().
getContent
());
//设置表单excel的格式
formFile
.
setContentType
(
standModelFile
.
get
().
getContentType
());
formExcelFileRepository
.
save
(
formFile
);
}
}
//保存流程流转过程上传的excel文件
public
void
updateFormExcelFile
(
String
processInstId
,
String
assignee
,
MultipartFile
file
)
throws
Exception
{
Optional
<
FormExcelFile
>
formFileOpt
=
formExcelFileRepository
.
findByProcessInstId
(
processInstId
);
if
(
formFileOpt
.
isPresent
())
{
FormExcelFile
formFile
=
formFileOpt
.
get
();
formFile
.
setProcessInstId
(
processInstId
);
formFile
.
setName
(
file
.
getOriginalFilename
());
formFile
.
setLastUpdater
(
assignee
);
formFile
.
setContent
(
file
.
getBytes
());
formExcelFileRepository
.
save
(
formFile
);
}
}
}
src/main/java/com/keymobile/activiti/service/formService/StandardModelFileService.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
service
.
formService
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.activiti.model.StandardModelFile
;
import
com.keymobile.activiti.persistence.StandardModelFileRepository
;
@Service
public
class
StandardModelFileService
{
@Autowired
private
StandardModelFileRepository
standModelRepository
;
//获取所有模板文件
public
List
<
Map
<
String
,
Object
>>
getAllStandardModel
(){
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
StandardModelFile
>
modelFile
=
standModelRepository
.
findAll
();
for
(
StandardModelFile
file
:
modelFile
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
file
.
getId
());
map
.
put
(
"name"
,
file
.
getName
());
map
.
put
(
"updateTime"
,
file
.
getLastUpdateTime
());
map
.
put
(
"updater"
,
file
.
getLastUpdater
());
result
.
add
(
map
);
}
return
result
;
}
//根据id获取模板信息
public
StandardModelFile
getById
(
String
id
)
{
Optional
<
StandardModelFile
>
result
=
standModelRepository
.
findById
(
id
);
return
result
.
get
();
}
//根据id获取模板文件内容
public
byte
[]
getContentById
(
String
id
)
{
Optional
<
StandardModelFile
>
result
=
standModelRepository
.
findById
(
id
);
if
(
result
.
isPresent
())
{
return
result
.
get
().
getContent
();
}
else
{
return
null
;
}
}
//保存或者修改模板文件
public
String
saveOrUpdateModel
(
StandardModelFile
file
)
{
file
=
standModelRepository
.
save
(
file
);
return
file
.
getId
();
}
}
src/main/java/com/keymobile/activiti/utils/Page.java
deleted
100644 → 0
View file @
ee6e03cf
package
com
.
keymobile
.
activiti
.
utils
;
import
java.util.List
;
import
java.util.Map
;
public
class
Page
{
private
List
<
Map
<
String
,
Object
>>
content
;
private
Long
totalElements
;
public
Page
()
{};
public
void
setTotalElements
(
Long
totalElements
)
{
this
.
totalElements
=
totalElements
;
}
public
Long
getTotalElements
()
{
return
totalElements
;
}
public
List
<
Map
<
String
,
Object
>>
getContent
()
{
return
content
;
}
public
void
setContent
(
List
<
Map
<
String
,
Object
>>
content
)
{
this
.
content
=
content
;
}
}
src/main/java/com/keymobile/activiti/modeler/ActivitiController.java
→
src/main/java/com/keymobile/
rest/
activiti/modeler/ActivitiController.java
View file @
cbca00c9
package
com
.
keymobile
.
activiti
.
modeler
;
package
com
.
keymobile
.
rest
.
activiti
.
modeler
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -8,6 +8,7 @@ import java.util.Map;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.keymobile.rest.common.utils.DateUtil
;
import
org.activiti.bpmn.converter.BpmnXMLConverter
;
import
org.activiti.bpmn.model.BpmnModel
;
import
org.activiti.editor.constants.ModelDataJsonConstants
;
...
...
@@ -26,17 +27,16 @@ import org.springframework.web.bind.annotation.RestController;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.keymobile.activiti.utils.DateUtil
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
path
=
"/model"
)
public
class
ActivitiController
{
@Autowired
private
RepositoryService
repositoryService
;
@Autowired
private
RepositoryService
repositoryService
;
/**
* 创建模型
*/
...
...
@@ -69,85 +69,85 @@ public class ActivitiController {
System
.
out
.
println
(
"创建模型失败:"
);
}
}
@ApiOperation
(
value
=
"修改model"
)
@GetMapping
(
value
=
"/update"
)
public
void
update
(
@RequestParam
String
modelId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
response
.
sendRedirect
(
request
.
getContextPath
()
+
"/modeler.html?modelId="
+
modelId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
@GetMapping
(
value
=
"/update"
)
public
void
update
(
@RequestParam
String
modelId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
response
.
sendRedirect
(
request
.
getContextPath
()
+
"/modeler.html?modelId="
+
modelId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@ApiOperation
(
value
=
"获取流程设计的model列表"
)
@PostMapping
(
value
=
"/getProcessModelList"
)
public
List
<
Map
<
String
,
Object
>>
getProcessModelList
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Model
>
list
=
repositoryService
.
createModelQuery
().
list
();
for
(
Model
model
:
list
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
model
.
getId
());
map
.
put
(
"name"
,
model
.
getName
());
map
.
put
(
"key"
,
model
.
getKey
());
map
.
put
(
"deploymentId"
,
model
.
getDeploymentId
());
map
.
put
(
"createTime"
,
DateUtil
.
formatDate
(
model
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
map
.
put
(
"lastUpdateTime"
,
DateUtil
.
formatDate
(
model
.
getLastUpdateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
result
.
add
(
map
);
}
return
result
;
}
@ApiOperation
(
value
=
"发布模型为流程定义"
)
@PostMapping
(
value
=
"/deploymentModelToProcess"
)
public
String
deploymentModelToProcess
(
@RequestParam
String
modelId
)
{
String
message
=
null
;
//获取模型
try
{
Model
modelData
=
repositoryService
.
getModel
(
modelId
);
byte
[]
bytes
=
repositoryService
.
getModelEditorSource
(
modelData
.
getId
());
if
(
bytes
==
null
)
{
return
"模型数据为空,请先设计流程并成功保存,再进行发布。"
;
}
JsonNode
modelNode
=
new
ObjectMapper
().
readTree
(
bytes
);
BpmnModel
model
=
new
BpmnJsonConverter
().
convertToBpmnModel
(
modelNode
);
if
(
model
.
getProcesses
().
size
()==
0
)
{
return
"数据模型不符要求,请至少设计一条主线流程。"
;
}
byte
[]
bpmnBytes
=
new
BpmnXMLConverter
().
convertToXML
(
model
);
//发布流程
String
processName
=
modelData
.
getName
()
+
".bpmn"
;
Deployment
deployment
=
repositoryService
.
createDeployment
()
.
name
(
modelData
.
getName
())
.
addString
(
processName
,
new
String
(
bpmnBytes
,
"UTF-8"
))
.
deploy
();
modelData
.
setDeploymentId
(
deployment
.
getId
());
repositoryService
.
saveModel
(
modelData
);
message
=
"发布模型为流程定义成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"发布模型为流程定义出错"
;
}
return
message
;
}
@ApiOperation
(
value
=
"删除流程设计model"
)
@DeleteMapping
(
value
=
"/deleteProcessModel"
)
public
String
deleteProcessModel
(
@RequestParam
String
modelId
)
{
String
message
=
null
;
try
{
repositoryService
.
deleteModel
(
modelId
);
message
=
"删除模板成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"删除设计模板发生未知错误"
;
}
return
message
;
}
@PostMapping
(
value
=
"/getProcessModelList"
)
public
List
<
Map
<
String
,
Object
>>
getProcessModelList
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Model
>
list
=
repositoryService
.
createModelQuery
().
list
();
for
(
Model
model
:
list
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
model
.
getId
());
map
.
put
(
"name"
,
model
.
getName
());
map
.
put
(
"key"
,
model
.
getKey
());
map
.
put
(
"deploymentId"
,
model
.
getDeploymentId
());
map
.
put
(
"createTime"
,
DateUtil
.
formatDate
(
model
.
getCreateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
map
.
put
(
"lastUpdateTime"
,
DateUtil
.
formatDate
(
model
.
getLastUpdateTime
(),
"yyyy-MM-dd HH:mm:ss"
));
result
.
add
(
map
);
}
return
result
;
}
@ApiOperation
(
value
=
"发布模型为流程定义"
)
@PostMapping
(
value
=
"/deploymentModelToProcess"
)
public
String
deploymentModelToProcess
(
@RequestParam
String
modelId
)
{
String
message
=
null
;
//获取模型
try
{
Model
modelData
=
repositoryService
.
getModel
(
modelId
);
byte
[]
bytes
=
repositoryService
.
getModelEditorSource
(
modelData
.
getId
());
if
(
bytes
==
null
)
{
return
"模型数据为空,请先设计流程并成功保存,再进行发布。"
;
}
JsonNode
modelNode
=
new
ObjectMapper
().
readTree
(
bytes
);
BpmnModel
model
=
new
BpmnJsonConverter
().
convertToBpmnModel
(
modelNode
);
if
(
model
.
getProcesses
().
size
()
==
0
)
{
return
"数据模型不符要求,请至少设计一条主线流程。"
;
}
byte
[]
bpmnBytes
=
new
BpmnXMLConverter
().
convertToXML
(
model
);
//发布流程
String
processName
=
modelData
.
getName
()
+
".bpmn"
;
Deployment
deployment
=
repositoryService
.
createDeployment
()
.
name
(
modelData
.
getName
())
.
addString
(
processName
,
new
String
(
bpmnBytes
,
"UTF-8"
))
.
deploy
();
modelData
.
setDeploymentId
(
deployment
.
getId
());
repositoryService
.
saveModel
(
modelData
);
message
=
"发布模型为流程定义成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"发布模型为流程定义出错"
;
}
return
message
;
}
@ApiOperation
(
value
=
"删除流程设计model"
)
@DeleteMapping
(
value
=
"/deleteProcessModel"
)
public
String
deleteProcessModel
(
@RequestParam
String
modelId
)
{
String
message
=
null
;
try
{
repositoryService
.
deleteModel
(
modelId
);
message
=
"删除模板成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
message
=
"删除设计模板发生未知错误"
;
}
return
message
;
}
}
\ No newline at end of file
src/main/java/com/keymobile/activiti/modeler/ModelEditorJsonRestResource.java
→
src/main/java/com/keymobile/
rest/
activiti/modeler/ModelEditorJsonRestResource.java
View file @
cbca00c9
...
...
@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
keymobile
.
activiti
.
modeler
;
package
com
.
keymobile
.
rest
.
activiti
.
modeler
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
...
...
src/main/java/com/keymobile/activiti/modeler/ModelSaveRestResource.java
→
src/main/java/com/keymobile/
rest/
activiti/modeler/ModelSaveRestResource.java
View file @
cbca00c9
...
...
@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
keymobile
.
activiti
.
modeler
;
package
com
.
keymobile
.
rest
.
activiti
.
modeler
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
...
...
src/main/java/com/keymobile/activiti/modeler/StencilsetRestResource.java
→
src/main/java/com/keymobile/
rest/
activiti/modeler/StencilsetRestResource.java
View file @
cbca00c9
...
...
@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
keymobile
.
activiti
.
modeler
;
package
com
.
keymobile
.
rest
.
activiti
.
modeler
;
import
org.activiti.engine.ActivitiException
;
import
org.apache.commons.io.IOUtils
;
...
...
src/main/java/com/keymobile/
activiti
/conf/ActivitiConfig.java
→
src/main/java/com/keymobile/
rest/common
/conf/ActivitiConfig.java
View file @
cbca00c9
package
com
.
keymobile
.
activiti
.
conf
;
package
com
.
keymobile
.
rest
.
common
.
conf
;
import
org.activiti.spring.SpringProcessEngineConfiguration
;
import
org.activiti.spring.boot.ProcessEngineConfigurationConfigurer
;
...
...
src/main/java/com/keymobile/rest/common/constant/AssignmentConstant.java
View file @
cbca00c9
...
...
@@ -2,17 +2,15 @@ package com.keymobile.rest.common.constant;
public
interface
AssignmentConstant
{
int
KIND_RECORD
=
1
;
int
KIND_AUDIT
=
2
;
int
TYPE_AUTO
=
2
;
int
TYPE_MANUAL
=
1
;
int
STATUS_RELEASED
=
2
;
int
STATUS_UNRELEASED
=
1
;
int
STATUS_COMPLETED
=
3
;
int
AUDIT_NEED
=
1
;
int
AUDIT_NO_NEED
=
2
;
int
NEED_AUDIT
=
1
;
int
NO_NEED_AUDIT
=
2
;
// 报送频度 按年 按年 按周 按月 按日 自动推送
int
FREQ_YEAR
=
1
;
int
FREQ_WEEK
=
2
;
int
FREQ_MONTH
=
3
;
int
FREQ_DAY
=
4
;
}
src/main/java/com/keymobile/rest/common/constant/TemplateConstant.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
common
.
constant
;
public
interface
TemplateConstant
{
}
src/main/java/com/keymobile/rest/common/constant/UserConstant.java
0 → 100644
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
common
.
constant
;
public
interface
UserConstant
{
int
ROLE_NORMAL
=
1
;
int
ROLE_AUDIT
=
2
;
int
ROLE_MANAGER
=
3
;
}
src/main/java/com/keymobile/
activiti
/utils/DateUtil.java
→
src/main/java/com/keymobile/
rest/common
/utils/DateUtil.java
View file @
cbca00c9
package
com
.
keymobile
.
activiti
.
utils
;
package
com
.
keymobile
.
rest
.
common
.
utils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
...
...
@@ -11,180 +11,182 @@ import java.util.Date;
* 日期工具类, 继承org.apache.commons.lang.time.DateUtils类
*/
public
class
DateUtil
extends
org
.
apache
.
commons
.
lang3
.
time
.
DateUtils
{
private
static
final
String
PARSE_PATTERN_DD
=
"yyyy-MM-dd"
;
private
static
final
String
PARSE_PATTERN_SS
=
"yyyy-MM-dd HH:mm:ss"
;
private
static
String
[]
parsePatterns
=
{
PARSE_PATTERN_DD
,
PARSE_PATTERN_SS
,
"yyyy-MM-dd HH:mm"
,
"yyyy/MM/dd"
,
"yyyy/MM/dd HH:mm:ss"
,
"yyyy/MM/dd HH:mm"
};
/**
* 得到当前日期字符串 格式(yyyy-MM-dd)
*/
public
static
String
getDate
()
{
return
getDate
(
PARSE_PATTERN_DD
);
}
/**
* 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:parse_pattern_dd "HH:mm:ss" "E"
*/
public
static
String
getDate
(
String
pattern
)
{
return
DateFormatUtils
.
format
(
new
Date
(),
pattern
);
}
/**
* 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:parse_pattern_dd "HH:mm:ss" "E"
*/
public
static
String
formatDate
(
Date
date
,
Object
...
pattern
)
{
String
formatDate
=
null
;
if
(
pattern
!=
null
&&
pattern
.
length
>
0
)
{
formatDate
=
DateFormatUtils
.
format
(
date
,
pattern
[
0
].
toString
());
}
else
{
formatDate
=
DateFormatUtils
.
format
(
date
,
PARSE_PATTERN_DD
);
}
return
formatDate
;
}
/**
* 得到日期时间字符串,转换格式(parse_pattern_ss)
*/
public
static
String
formatDateTime
(
Date
date
)
{
return
formatDate
(
date
,
PARSE_PATTERN_SS
);
}
/**
* 得到当前时间字符串 格式(HH:mm:ss)
*/
public
static
String
getTime
()
{
return
formatDate
(
new
Date
(),
"HH:mm:ss"
);
}
/**
* 得到当前日期和时间字符串 格式(parse_pattern_ss)
*/
public
static
String
getDateTime
()
{
return
formatDate
(
new
Date
(),
PARSE_PATTERN_SS
);
}
/**
* 得到当前年份字符串 格式(yyyy)
*/
public
static
String
getYear
()
{
return
formatDate
(
new
Date
(),
"yyyy"
);
}
/**
* 得到当前月份字符串 格式(MM)
*/
public
static
String
getMonth
()
{
return
formatDate
(
new
Date
(),
"MM"
);
}
/**
* 得到当天字符串 格式(dd)
*/
public
static
String
getDay
()
{
return
formatDate
(
new
Date
(),
"dd"
);
}
/**
* 得到当前星期字符串 格式(E)星期几
*/
public
static
String
getWeek
()
{
return
formatDate
(
new
Date
(),
"E"
);
}
/**
* 日期型字符串转化为日期 格式
* { parse_pattern_dd, parse_pattern_ss, "yyyy-MM-dd HH:mm",
* "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm" }
*/
public
static
Date
parseDate
(
Object
str
)
{
if
(
str
==
null
){
return
null
;
}
try
{
return
parseDate
(
str
.
toString
(),
parsePatterns
);
}
catch
(
ParseException
e
)
{
return
null
;
}
}
/**
* 获取过去的天数
* @param date
* @return
*/
public
static
long
pastDays
(
Date
date
)
{
long
t
=
new
Date
().
getTime
()-
date
.
getTime
();
return
t
/(
24
*
60
*
60
*
1000
);
}
public
static
Date
getDateStart
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)+
" 00:00:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
public
static
Date
getDateEnd
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)
+
" 23:59:59"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
//得到上班时间
public
static
Date
getDateStartWork
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)+
" 09:00:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
//得到下班时间
public
static
Date
getDateEndWork
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)
+
" 17:30:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
/* 获取传值日期之前几天的日期
* @param date 需要转换的日期 date 可以为NULL 此条件下则获取当前日期
* @param after 天数
* @param xFormat 转换字符串类型 (可以为NULL)
* @return
*/
public
static
Date
getBeforeCountDate
(
Date
date
,
int
before
)
{
date
=
date
==
null
?
new
Date
()
:
date
;
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
before
);
return
calendar
.
getTime
();
}
private
static
final
String
PARSE_PATTERN_DD
=
"yyyy-MM-dd"
;
private
static
final
String
PARSE_PATTERN_SS
=
"yyyy-MM-dd HH:mm:ss"
;
private
static
String
[]
parsePatterns
=
{
PARSE_PATTERN_DD
,
PARSE_PATTERN_SS
,
"yyyy-MM-dd HH:mm"
,
"yyyy/MM/dd"
,
"yyyy/MM/dd HH:mm:ss"
,
"yyyy/MM/dd HH:mm"
};
/**
* 得到当前日期字符串 格式(yyyy-MM-dd)
*/
public
static
String
getDate
()
{
return
getDate
(
PARSE_PATTERN_DD
);
}
/**
* 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:parse_pattern_dd "HH:mm:ss" "E"
*/
public
static
String
getDate
(
String
pattern
)
{
return
DateFormatUtils
.
format
(
new
Date
(),
pattern
);
}
/**
* 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:parse_pattern_dd "HH:mm:ss" "E"
*/
public
static
String
formatDate
(
Date
date
,
Object
...
pattern
)
{
String
formatDate
=
null
;
if
(
pattern
!=
null
&&
pattern
.
length
>
0
)
{
formatDate
=
DateFormatUtils
.
format
(
date
,
pattern
[
0
].
toString
());
}
else
{
formatDate
=
DateFormatUtils
.
format
(
date
,
PARSE_PATTERN_DD
);
}
return
formatDate
;
}
/**
* 得到日期时间字符串,转换格式(parse_pattern_ss)
*/
public
static
String
formatDateTime
(
Date
date
)
{
return
formatDate
(
date
,
PARSE_PATTERN_SS
);
}
/**
* 得到当前时间字符串 格式(HH:mm:ss)
*/
public
static
String
getTime
()
{
return
formatDate
(
new
Date
(),
"HH:mm:ss"
);
}
/**
* 得到当前日期和时间字符串 格式(parse_pattern_ss)
*/
public
static
String
getDateTime
()
{
return
formatDate
(
new
Date
(),
PARSE_PATTERN_SS
);
}
/**
* 得到当前年份字符串 格式(yyyy)
*/
public
static
String
getYear
()
{
return
formatDate
(
new
Date
(),
"yyyy"
);
}
/**
* 得到当前月份字符串 格式(MM)
*/
public
static
String
getMonth
()
{
return
formatDate
(
new
Date
(),
"MM"
);
}
/**
* 得到当天字符串 格式(dd)
*/
public
static
String
getDay
()
{
return
formatDate
(
new
Date
(),
"dd"
);
}
/**
* 得到当前星期字符串 格式(E)星期几
*/
public
static
String
getWeek
()
{
return
formatDate
(
new
Date
(),
"E"
);
}
/**
* 日期型字符串转化为日期 格式
* { parse_pattern_dd, parse_pattern_ss, "yyyy-MM-dd HH:mm",
* "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm" }
*/
public
static
Date
parseDate
(
Object
str
)
{
if
(
str
==
null
)
{
return
null
;
}
try
{
return
parseDate
(
str
.
toString
(),
parsePatterns
);
}
catch
(
ParseException
e
)
{
return
null
;
}
}
/**
* 获取过去的天数
*
* @param date
* @return
*/
public
static
long
pastDays
(
Date
date
)
{
long
t
=
new
Date
().
getTime
()
-
date
.
getTime
();
return
t
/
(
24
*
60
*
60
*
1000
);
}
public
static
Date
getDateStart
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)
+
" 00:00:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
public
static
Date
getDateEnd
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)
+
" 23:59:59"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
//得到上班时间
public
static
Date
getDateStartWork
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)
+
" 09:00:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
//得到下班时间
public
static
Date
getDateEndWork
(
Date
date
)
{
if
(
date
==
null
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
PARSE_PATTERN_SS
);
try
{
date
=
sdf
.
parse
(
formatDate
(
date
,
PARSE_PATTERN_DD
)
+
" 17:30:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
/* 获取传值日期之前几天的日期
* @param date 需要转换的日期 date 可以为NULL 此条件下则获取当前日期
* @param after 天数
* @param xFormat 转换字符串类型 (可以为NULL)
* @return
*/
public
static
Date
getBeforeCountDate
(
Date
date
,
int
before
)
{
date
=
date
==
null
?
new
Date
()
:
date
;
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
before
);
return
calendar
.
getTime
();
}
}
src/main/java/com/keymobile/rest/controller/ExcelController.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
controller
;
import
com.google.common.collect.ImmutableMap
;
import
com.keymobile.rest.common.bean.ApiResponse
;
import
com.keymobile.rest.model.*
;
import
com.keymobile.rest.service.
Excel
Service
;
import
com.keymobile.rest.service.
Job
InfoService
;
import
com.keymobile.rest.service.
Template
Service
;
import
com.keymobile.rest.service.
Process
InfoService
;
import
com.keymobile.rest.service.UserService
;
import
com.keymobile.rest.vo.RecordDataForm
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.activiti.engine.*
;
import
org.activiti.engine.task.Task
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -21,12 +19,12 @@ import java.util.List;
@RequestMapping
(
path
=
"/api/excel"
)
public
class
ExcelController
{
// @Autowired
// private RecordDataService recordDataService;
@Autowired
private
RecordDataService
recordData
Service
;
private
TemplateService
template
Service
;
@Autowired
private
ExcelService
excelService
;
@Autowired
private
JobInfoService
jobInfoService
;
private
ProcessInfoService
processInfoService
;
@Autowired
private
UserService
userService
;
@Autowired
...
...
@@ -36,39 +34,39 @@ public class ExcelController {
@ApiOperation
(
value
=
"填写补录数据"
)
@PostMapping
(
value
=
"/excel/saveData"
)
public
ApiResponse
saveRecordData
(
@RequestBody
RecordDataForm
form
)
{
User
curUser
=
userService
.
getNormalUser
();
Template
template
=
excelService
.
get
(
form
.
getExcelId
());
ProcessInfo
processInfo
=
jobInfoService
.
findByExcelIdAndUserId
(
form
.
getExcelId
(),
curUser
.
getId
());
DataInfo
dataInfo
;
if
(
form
.
getDataId
()
!=
null
)
{
dataInfo
=
recordDataService
.
update
(
form
);
}
else
{
form
.
setProcessInfo
(
processInfo
);
dataInfo
=
recordDataService
.
save
(
form
);
}
Assignment
assignment
=
template
.
getAssignment
();
String
processId
=
assignment
.
getProcessId
();
// 发起人把流程发送到下一个人
List
<
Task
>
taskList
=
taskService
.
createTaskQuery
().
processInstanceId
(
processId
)
.
taskAssignee
(
curUser
.
getUsername
()).
list
();
Task
task
=
taskList
.
get
(
0
);
User
judge
=
userService
.
getAudit
();
taskService
.
complete
(
task
.
getId
(),
ImmutableMap
.
of
(
"judgeId"
,
judge
.
getUsername
()));
return
ApiResponse
.
ok
(
dataInfo
.
getId
()
);
//
User curUser = userService.getNormalUser();
//
Template template = excelService.get(form.getExcelId());
//
ProcessInfo processInfo = jobInfoService.findByExcelIdAndUserId(form.getExcelId(), curUser.getId());
//
DataInfo dataInfo;
//
if (form.getDataId() != null) {
//
dataInfo = recordDataService.update(form);
//
} else {
//
form.setProcessInfo(processInfo);
//
dataInfo = recordDataService.save(form);
//
}
//
Assignment assignment = template.getAssignment();
//
String processId = assignment.getProcessId();
//
// 发起人把流程发送到下一个人
//
List<Task> taskList = taskService.createTaskQuery().processInstanceId(processId)
//
.taskAssignee(curUser.getUsername()).list();
//
Task task = taskList.get(0);
//
User judge = userService.getAudit();
//
taskService.complete(task.getId(), ImmutableMap.of("judgeId", judge.getUsername()));
return
ApiResponse
.
ok
();
}
@ApiOperation
(
value
=
"传excelId过来,获取用户填写的数据"
)
@PostMapping
(
value
=
"/excel/getData"
)
public
ApiResponse
getRecordData
(
@RequestParam
long
excelId
)
{
User
curUser
=
userService
.
getNormalUser
();
ProcessInfo
processInfo
=
job
InfoService
.
findByExcelIdAndUserId
(
excelId
,
curUser
.
getId
());
List
<
DataInfo
>
dataInfoList
=
processInfo
.
getDataInfoList
();
if
(
dataInfoList
.
size
()
>
0
)
{
return
ApiResponse
.
ok
(
dataInfoList
.
get
(
0
));
}
else
{
// ProcessInfo processInfo = process
InfoService.findByExcelIdAndUserId(excelId, curUser.getId());
//
//
List<DataInfo> dataInfoList = processInfo.getDataInfoList();
//
if (dataInfoList.size() > 0) {
//
return ApiResponse.ok(dataInfoList.get(0));
//
} else {
return
ApiResponse
.
ok
();
}
//
}
}
}
src/main/java/com/keymobile/rest/controller/TaskController.java
View file @
cbca00c9
...
...
@@ -7,9 +7,9 @@ import com.keymobile.rest.model.Template;
import
com.keymobile.rest.model.Assignment
;
import
com.keymobile.rest.model.ProcessInfo
;
import
com.keymobile.rest.model.User
;
import
com.keymobile.rest.service.
Excel
Service
;
import
com.keymobile.rest.service.
Job
InfoService
;
import
com.keymobile.rest.service.
Job
Service
;
import
com.keymobile.rest.service.
Template
Service
;
import
com.keymobile.rest.service.
Process
InfoService
;
import
com.keymobile.rest.service.
Assignment
Service
;
import
com.keymobile.rest.service.UserService
;
import
com.keymobile.rest.vo.ExcelForm
;
import
com.keymobile.rest.vo.JobForm
;
...
...
@@ -41,11 +41,11 @@ public class TaskController {
@Autowired
private
ManagementService
managementService
;
@Autowired
private
JobService
job
Service
;
private
AssignmentService
assignment
Service
;
@Autowired
private
ExcelService
excel
Service
;
private
TemplateService
template
Service
;
@Autowired
private
JobInfoService
job
InfoService
;
private
ProcessInfoService
process
InfoService
;
@Autowired
private
UserService
userService
;
@Autowired
...
...
@@ -63,9 +63,9 @@ public class TaskController {
String
orderBy
=
"descending"
;
//
String
propBy
=
"id"
;
// groupBy
if
(
name
!=
null
)
{
taskList
=
job
Service
.
findAllByName
(
name
,
pageNo
,
pageSize
,
orderBy
,
propBy
);
taskList
=
assignment
Service
.
findAllByName
(
name
,
pageNo
,
pageSize
,
orderBy
,
propBy
);
}
else
{
taskList
=
job
Service
.
findAll
(
pageNo
,
pageSize
,
orderBy
,
propBy
);
taskList
=
assignment
Service
.
findAll
(
pageNo
,
pageSize
,
orderBy
,
propBy
);
}
return
ApiResponse
.
ok
(
ImmutableMap
.
of
(
"list"
,
taskList
.
getContent
(),
"total"
,
taskList
.
getTotalElements
()));
}
...
...
@@ -73,7 +73,7 @@ public class TaskController {
@ApiOperation
(
value
=
"查看活动"
)
@PostMapping
(
value
=
"/get"
)
public
ApiResponse
get
(
@RequestParam
@ApiParam
(
required
=
true
,
name
=
"taskId"
,
value
=
"活动id"
)
Long
taskId
)
{
Assignment
assignment
=
job
Service
.
get
(
taskId
);
Assignment
assignment
=
assignment
Service
.
get
(
taskId
);
TwinkleValidator
.
notNull
(
assignment
,
"活动不存在"
);
return
ApiResponse
.
ok
(
assignment
);
}
...
...
@@ -93,18 +93,18 @@ public class TaskController {
for
(
Task
task
:
tasks
)
{
String
processId
=
task
.
getProcessInstanceId
();
Assignment
assignment
=
job
Service
.
findByProcessId
(
processId
);
if
(
assignment
!=
null
&&
assignment
.
getStatus
()
!=
Assignment
.
STATUS_COMPLETED
)
{
Assignment
assignment
=
assignment
Service
.
findByProcessId
(
processId
);
//
if (assignment != null && assignment.getStatus() != Assignment.STATUS_COMPLETED) {
if
(
task
.
getTaskDefinitionKey
().
equals
(
"addData"
))
{
assignment
.
setKind
(
Assignment
.
KIND_RECORD
);
//
assignment.setKind(Assignment.KIND_RECORD);
}
else
{
assignment
.
setKind
(
Assignment
.
KIND_AUDIT
);
//
assignment.setKind(Assignment.KIND_AUDIT);
}
assignmentList
.
add
(
assignment
);
}
//
}
}
return
ApiResponse
.
ok
(
assignmentList
);
return
ApiResponse
.
ok
();
}
...
...
@@ -117,20 +117,20 @@ public class TaskController {
// 创建人
User
manager
=
userService
.
getManager
();
form
.
setUser
(
manager
);
Assignment
assignment
=
job
Service
.
save
(
form
);
Assignment
assignment
=
assignment
Service
.
save
(
form
);
// 新建excel实例
List
<
ExcelForm
>
excelFormList
=
form
.
getExcels
();
excelFormList
.
forEach
(
excelForm
->
{
TwinkleValidator
.
notEmpty
(
excelForm
.
getUserIds
(),
"补录人不能为空"
);
excelForm
.
setAssignment
(
assignment
);
Template
template
=
excel
Service
.
save
(
excelForm
);
Template
template
=
template
Service
.
save
(
excelForm
);
// 新建补录人员任务关联
String
[]
userIds
=
excelForm
.
getUserIds
().
split
(
","
);
List
<
Long
>
userIdList
=
Arrays
.
asList
(
userIds
).
stream
().
map
(
Long:
:
parseLong
).
collect
(
Collectors
.
toList
());
List
<
User
>
userList
=
userService
.
findAllByIdIn
(
userIdList
);
TwinkleValidator
.
notLessThan
(
userList
.
size
(),
1
,
"补录人员不存在"
);
userList
.
forEach
(
user
->
{
job
InfoService
.
save
(
user
,
template
);
process
InfoService
.
save
(
user
,
template
);
});
});
return
ApiResponse
.
ok
(
assignment
.
getId
());
...
...
@@ -140,27 +140,27 @@ public class TaskController {
@PostMapping
(
value
=
"/update"
)
public
ApiResponse
updateTask
(
@RequestBody
JobForm
form
)
{
TwinkleValidator
.
isFalse
((
form
.
getId
()
==
null
&&
form
.
getId
()
<=
0
),
"活动id不能为空"
);
Assignment
assignment
=
job
Service
.
get
(
form
.
getId
());
Assignment
assignment
=
assignment
Service
.
get
(
form
.
getId
());
TwinkleValidator
.
notNull
(
assignment
,
"活动不存在"
);
int
status
=
assignment
.
getStatus
();
TwinkleValidator
.
isFalse
(
status
!=
Assignment
.
STATUS_UNRELEASED
,
"活动已经发起"
);
//
int status = assignment.getStatus();
//
TwinkleValidator.isFalse(status != Assignment.STATUS_UNRELEASED, "活动已经发起");
TwinkleValidator
.
notEmpty
(
form
.
getName
(),
"名称不能为空"
);
TwinkleValidator
.
notNull
(
form
.
getType
(),
"类型不能为空"
);
TwinkleValidator
.
isFalse
((
form
.
getExcels
()
==
null
||
form
.
getExcels
().
size
()
==
0
),
"补录模板不能为空"
);
assignment
.
setType
(
form
.
getType
());
assignment
.
setRemark
(
form
.
getRemark
());
assignment
.
setName
(
form
.
getName
());
job
Service
.
update
(
assignment
);
assignment
Service
.
update
(
assignment
);
// 新建excel实例
List
<
ExcelForm
>
excelFormList
=
form
.
getExcels
();
excelFormList
.
forEach
(
excelForm
->
{
Template
template
=
excel
Service
.
get
(
excelForm
.
getId
());
Template
template
=
template
Service
.
get
(
excelForm
.
getId
());
TwinkleValidator
.
notNull
(
template
,
"模板不存在"
);
template
.
setName
(
excelForm
.
getName
());
template
.
setConfig
(
excelForm
.
getConfig
());
template
.
setRemark
(
excelForm
.
getRemark
());
template
.
setDataAt
(
excelForm
.
getDataAt
());
excel
Service
.
update
(
template
);
template
Service
.
update
(
template
);
});
return
ApiResponse
.
ok
(
assignment
.
getId
());
}
...
...
@@ -168,7 +168,7 @@ public class TaskController {
@ApiOperation
(
value
=
"手动发起活动"
)
@PostMapping
(
value
=
"/start"
)
public
ApiResponse
startTask
(
@RequestParam
Long
taskId
)
{
Assignment
assignment
=
job
Service
.
get
(
taskId
);
Assignment
assignment
=
assignment
Service
.
get
(
taskId
);
TwinkleValidator
.
notNull
(
assignment
,
"活动不存在"
);
// 部署补录流程
Deployment
deploy
=
repositoryService
...
...
@@ -185,8 +185,8 @@ public class TaskController {
variables
.
put
(
"managerId"
,
inputUser
);
//启动流程
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
processDefinition
.
getKey
(),
variables
);
assignment
.
setProcessId
(
processInstance
.
getId
());
job
Service
.
update
(
assignment
);
//
assignment.setProcessId(processInstance.getId());
assignment
Service
.
update
(
assignment
);
// 发起人把流程发送到下一个人
Task
resultTask
=
taskService
.
createTaskQuery
().
processInstanceId
(
processInstance
.
getId
()).
taskInvolvedUser
(
inputUser
).
singleResult
();
...
...
@@ -196,7 +196,7 @@ public class TaskController {
TwinkleValidator
.
notLessThan
(
templateList
.
size
(),
1
,
"补录模板不存在"
);
Template
template
=
templateList
.
get
(
0
);
List
<
ProcessInfo
>
processInfoList
=
jobInfoService
.
findAllByExcel
Id
(
template
.
getId
());
List
<
ProcessInfo
>
processInfoList
=
processInfoService
.
findAllByTemplate
Id
(
template
.
getId
());
TwinkleValidator
.
notLessThan
(
processInfoList
.
size
(),
1
,
"补录人员不存在"
);
taskService
.
complete
(
resultTask
.
getId
(),
ImmutableMap
.
of
(
"userId"
,
processInfoList
.
get
(
0
).
getUser
().
getUsername
()));
return
ApiResponse
.
ok
();
...
...
@@ -206,16 +206,16 @@ public class TaskController {
@ApiOperation
(
value
=
"审核通过活动"
)
@PostMapping
(
value
=
"/pass"
)
public
ApiResponse
passTask
(
@RequestParam
Long
taskId
)
{
Assignment
assignment
=
job
Service
.
get
(
taskId
);
Assignment
assignment
=
assignment
Service
.
get
(
taskId
);
// 完结活动, 流程跑完
User
judge
=
userService
.
getAudit
();
List
<
Task
>
taskList
=
taskService
.
createTaskQuery
().
processInstanceId
(
assignment
.
getProcessId
())
.
taskAssignee
(
judge
.
getUsername
()).
list
();
TwinkleValidator
.
notLessThan
(
taskList
.
size
(),
1
,
"启动失败"
);
Task
task
=
taskList
.
get
(
0
);
taskService
.
complete
(
task
.
getId
(),
ImmutableMap
.
of
(
"pass"
,
"true"
));
assignment
.
setStatus
(
Assignment
.
STATUS_COMPLETED
);
job
Service
.
update
(
assignment
);
//
List<Task> taskList = taskService.createTaskQuery().processInstanceId(assignment.getProcessId())
//
.taskAssignee(judge.getUsername()).list();
//
TwinkleValidator.notLessThan(taskList.size(), 1, "启动失败");
//
Task task = taskList.get(0);
//
taskService.complete(task.getId(), ImmutableMap.of("pass", "true"));
//
assignment.setStatus(Assignment.STATUS_COMPLETED);
assignment
Service
.
update
(
assignment
);
return
ApiResponse
.
ok
();
}
...
...
@@ -223,14 +223,14 @@ public class TaskController {
@ApiOperation
(
value
=
"审核驳回活动"
)
@PostMapping
(
value
=
"/reject"
)
public
ApiResponse
rejectTask
(
@RequestParam
Long
taskId
)
{
Assignment
assignment
=
job
Service
.
get
(
taskId
);
Assignment
assignment
=
assignment
Service
.
get
(
taskId
);
// 完结活动, 流程跑完
User
judge
=
userService
.
getAudit
();
List
<
Task
>
taskList
=
taskService
.
createTaskQuery
().
processInstanceId
(
assignment
.
getProcessId
())
.
taskAssignee
(
judge
.
getUsername
()).
list
();
TwinkleValidator
.
notLessThan
(
taskList
.
size
(),
1
,
"启动失败"
);
Task
task
=
taskList
.
get
(
0
);
taskService
.
complete
(
task
.
getId
(),
ImmutableMap
.
of
(
"pass"
,
"false"
));
//
List<Task> taskList = taskService.createTaskQuery().processInstanceId(assignment.getProcessId())
//
.taskAssignee(judge.getUsername()).list();
//
TwinkleValidator.notLessThan(taskList.size(), 1, "启动失败");
//
Task task = taskList.get(0);
//
taskService.complete(task.getId(), ImmutableMap.of("pass", "false"));
return
ApiResponse
.
ok
();
}
...
...
src/main/java/com/keymobile/rest/controller/UserController.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
controller
;
import
com.google.common.collect.ImmutableMap
;
import
com.keymobile.activiti.service.formService.FormExcelFileService
;
import
com.keymobile.rest.common.bean.ApiResponse
;
import
com.keymobile.rest.model.*
;
import
com.keymobile.rest.service.*
;
import
com.keymobile.rest.vo.*
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.activiti.engine.*
;
import
org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.activiti.engine.task.Task
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -28,8 +22,8 @@ public class UserController {
@ApiOperation
(
value
=
"获取补录人员列表"
)
@PostMapping
(
value
=
"/user/list"
)
public
ApiResponse
getUserList
()
{
List
<
User
>
userList
=
userService
.
findAllByRole
(
User
.
ROLE_NORMAL
);
return
ApiResponse
.
ok
(
userList
);
//
List<User> userList = userService.findAllByRole(User.ROLE_NORMAL);
return
ApiResponse
.
ok
(
null
);
}
...
...
src/main/java/com/keymobile/rest/dao/
Job
Dao.java
→
src/main/java/com/keymobile/rest/dao/
Assignment
Dao.java
View file @
cbca00c9
...
...
@@ -5,11 +5,9 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
Job
Dao
extends
JpaRepository
<
Assignment
,
Long
>
{
public
interface
Assignment
Dao
extends
JpaRepository
<
Assignment
,
Long
>
{
Page
<
Assignment
>
findAll
(
Pageable
pageable
);
Page
<
Assignment
>
findAllByNameLike
(
String
valueOf
,
Pageable
pageable
);
Assignment
findByProcessId
(
String
pid
);
}
src/main/java/com/keymobile/rest/dao/
RecordData
Dao.java
→
src/main/java/com/keymobile/rest/dao/
DataInfo
Dao.java
View file @
cbca00c9
...
...
@@ -3,7 +3,7 @@ package com.keymobile.rest.dao;
import
com.keymobile.rest.model.DataInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
RecordData
Dao
extends
JpaRepository
<
DataInfo
,
Long
>
{
public
interface
DataInfo
Dao
extends
JpaRepository
<
DataInfo
,
Long
>
{
...
...
src/main/java/com/keymobile/rest/dao/
Job
InfoDao.java
→
src/main/java/com/keymobile/rest/dao/
Process
InfoDao.java
View file @
cbca00c9
...
...
@@ -5,13 +5,13 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
java.util.List
;
public
interface
Job
InfoDao
extends
JpaRepository
<
ProcessInfo
,
Long
>
{
public
interface
Process
InfoDao
extends
JpaRepository
<
ProcessInfo
,
Long
>
{
List
<
ProcessInfo
>
findAllBy
Excel
Id
(
long
eid
);
List
<
ProcessInfo
>
findAllBy
Template
Id
(
long
eid
);
List
<
ProcessInfo
>
findAllByUserId
(
long
uid
);
void
deleteAllBy
Excel
Id
(
long
eid
);
void
deleteAllBy
Template
Id
(
long
eid
);
ProcessInfo
findBy
Excel
IdAndUserId
(
long
eid
,
long
uid
);
ProcessInfo
findBy
Template
IdAndUserId
(
long
eid
,
long
uid
);
}
src/main/java/com/keymobile/rest/dao/
Excel
Dao.java
→
src/main/java/com/keymobile/rest/dao/
Template
Dao.java
View file @
cbca00c9
...
...
@@ -5,11 +5,11 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
java.util.List
;
public
interface
Excel
Dao
extends
JpaRepository
<
Template
,
Long
>
{
public
interface
Template
Dao
extends
JpaRepository
<
Template
,
Long
>
{
List
<
Template
>
findAllByIdIn
(
List
<
Long
>
ids
);
List
<
Template
>
findAllBy
JobId
(
long
ji
d
);
List
<
Template
>
findAllBy
AssignmentId
(
long
assignmentI
d
);
}
src/main/java/com/keymobile/rest/model/Assignment.java
View file @
cbca00c9
...
...
@@ -21,7 +21,6 @@ import java.util.List;
@Entity
public
class
Assignment
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
long
id
;
...
...
@@ -33,26 +32,27 @@ public class Assignment implements Serializable {
private
int
type
;
@Column
(
nullable
=
false
)
private
int
status
;
@Column
(
nullable
=
false
)
private
int
needAudit
;
@Column
private
String
remark
;
// 报送频度 按年 按年 按周 按月 按日 自动推送
@Column
(
name
=
"start_at"
)
private
Timestamp
startAt
;
/*
频度
*/
@Column
private
int
freq
;
@Column
(
nullable
=
false
,
name
=
"create_at"
)
@CreationTimestamp
private
Timestamp
createAt
;
@OneToMany
(
fetch
=
FetchType
.
EAGER
,
mappedBy
=
"
job
"
)
@OneToMany
(
fetch
=
FetchType
.
EAGER
,
mappedBy
=
"
assignment
"
)
private
List
<
Template
>
templateList
;
/*
发送人
*/
@ManyToOne
private
User
user
;
}
src/main/java/com/keymobile/rest/model/Process.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
model
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
@@ -22,8 +23,13 @@ public class Process implements Serializable {
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
long
id
;
// activiti运行中的流程实例id
/*
activiti运行中的流程实例id
*/
@Column
(
name
=
"process_id"
)
private
String
processId
;
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@JsonIgnore
private
Assignment
assignment
;
}
src/main/java/com/keymobile/rest/model/ProcessInfo.java
View file @
cbca00c9
...
...
@@ -27,13 +27,22 @@ public class ProcessInfo implements Serializable {
@CreationTimestamp
private
Timestamp
createAt
;
/*
补录模板
*/
@OneToOne
private
Template
template
;
/*
补录人员
*/
@OneToOne
private
User
user
;
@OneToMany
(
mappedBy
=
"jobInfo"
,
fetch
=
FetchType
.
EAGER
)
/*
补录数据
*/
@OneToMany
(
mappedBy
=
"processInfo"
,
fetch
=
FetchType
.
EAGER
)
List
<
DataInfo
>
dataInfoList
;
}
src/main/java/com/keymobile/rest/model/User.java
View file @
cbca00c9
...
...
@@ -13,10 +13,6 @@ import java.io.Serializable;
@Entity
public
class
User
implements
Serializable
{
public
static
int
ROLE_NORMAL
=
1
;
public
static
int
ROLE_AUDIT
=
2
;
public
static
int
ROLE_MANAGER
=
3
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
long
id
;
...
...
src/main/java/com/keymobile/rest/service/
Job
Service.java
→
src/main/java/com/keymobile/rest/service/
Assignment
Service.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.
activiti
.utils.DateUtil
;
import
com.keymobile.rest.dao.
Job
Dao
;
import
com.keymobile.
rest.common
.utils.DateUtil
;
import
com.keymobile.rest.dao.
Assignment
Dao
;
import
com.keymobile.rest.model.Assignment
;
import
com.keymobile.rest.vo.JobForm
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -12,70 +12,69 @@ import org.springframework.data.domain.Sort;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
@Service
public
class
Job
Service
{
public
class
Assignment
Service
{
@Autowired
private
JobDao
job
Dao
;
private
AssignmentDao
assignment
Dao
;
public
Assignment
get
(
long
id
)
{
return
job
Dao
.
getOne
(
id
);
return
assignment
Dao
.
getOne
(
id
);
}
public
Assignment
update
(
Assignment
assignment
)
{
return
job
Dao
.
save
(
assignment
);
return
assignment
Dao
.
save
(
assignment
);
}
public
Assignment
save
(
Assignment
assignment
)
{
return
job
Dao
.
save
(
assignment
);
return
assignment
Dao
.
save
(
assignment
);
}
public
Assignment
save
(
JobForm
form
)
{
Assignment
assignment
=
new
Assignment
();
Timestamp
now
=
Timestamp
.
valueOf
(
DateUtil
.
getDateTime
());
assignment
.
setCreateAt
(
now
);
assignment
.
setStatus
(
Assignment
.
STATUS_UNRELEASED
);
assignment
.
setAudit
(
Assignment
.
AUDIT_NEED
);
assignment
.
setName
(
form
.
getName
());
assignment
.
setType
(
form
.
getType
());
if
(
form
.
getType
()
==
Assignment
.
TYPE_AUTO
)
{
Timestamp
startAt
;
try
{
startAt
=
Timestamp
.
valueOf
(
form
.
getStartAt
());
}
catch
(
Exception
e
)
{
startAt
=
Timestamp
.
valueOf
(
LocalDateTime
.
now
());
}
assignment
.
setStartAt
(
startAt
);
}
//
assignment.setStatus(Assignment.STATUS_UNRELEASED);
//
assignment.setAudit(Assignment.AUDIT_NEED);
//
assignment.setName(form.getName());
//
assignment.setType(form.getType());
//
if (form.getType() == Assignment.TYPE_AUTO) {
//
Timestamp startAt;
//
try {
//
startAt = Timestamp.valueOf(form.getStartAt());
//
} catch (Exception e) {
//
startAt = Timestamp.valueOf(LocalDateTime.now());
//
}
//
assignment.setStartAt(startAt);
//
}
assignment
.
setUser
(
form
.
getUser
());
assignment
=
job
Dao
.
save
(
assignment
);
assignment
=
assignment
Dao
.
save
(
assignment
);
return
assignment
;
}
public
Assignment
findByProcessId
(
String
pid
)
{
return
jobDao
.
findByProcessId
(
pid
)
;
return
null
;
}
public
Page
<
Assignment
>
findAll
(
int
pageNo
,
int
pageSize
)
{
Pageable
pageable
=
convert
(
pageNo
,
pageSize
);
return
job
Dao
.
findAll
(
pageable
);
return
assignment
Dao
.
findAll
(
pageable
);
}
public
Page
<
Assignment
>
findAllByName
(
String
name
,
int
pageNo
,
int
pageSize
)
{
Pageable
pageable
=
convert
(
pageNo
,
pageSize
);
return
job
Dao
.
findAllByNameLike
((
"%"
+
name
+
"%"
),
pageable
);
return
assignment
Dao
.
findAllByNameLike
((
"%"
+
name
+
"%"
),
pageable
);
}
public
Page
<
Assignment
>
findAll
(
int
pageNo
,
int
pageSize
,
String
orderBy
,
String
propBy
)
{
Pageable
pageable
=
convert
(
pageNo
,
pageSize
,
orderBy
,
propBy
);
return
job
Dao
.
findAll
(
pageable
);
return
assignment
Dao
.
findAll
(
pageable
);
}
public
Page
<
Assignment
>
findAllByName
(
String
name
,
int
pageNo
,
int
pageSize
,
String
orderBy
,
String
propBy
)
{
Pageable
pageable
=
convert
(
pageNo
,
pageSize
,
orderBy
,
propBy
);
return
job
Dao
.
findAllByNameLike
((
"%"
+
name
+
"%"
),
pageable
);
return
assignment
Dao
.
findAllByNameLike
((
"%"
+
name
+
"%"
),
pageable
);
}
private
Pageable
convert
(
int
pageNo
,
int
pageSize
,
String
orderBy
,
String
propBy
)
{
...
...
src/main/java/com/keymobile/rest/service/
RecordData
Service.java
→
src/main/java/com/keymobile/rest/service/
DataInfo
Service.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.
activiti
.utils.DateUtil
;
import
com.keymobile.
rest.common
.utils.DateUtil
;
import
com.keymobile.rest.dao.*
;
import
com.keymobile.rest.model.DataInfo
;
import
com.keymobile.rest.vo.RecordDataForm
;
...
...
@@ -10,13 +10,13 @@ import org.springframework.stereotype.Service;
import
java.sql.Timestamp
;
@Service
public
class
RecordData
Service
{
public
class
DataInfo
Service
{
@Autowired
private
RecordDataDao
recordData
Dao
;
private
DataInfoDao
dataInfo
Dao
;
public
DataInfo
get
(
long
id
)
{
return
recordData
Dao
.
getOne
(
id
);
return
dataInfo
Dao
.
getOne
(
id
);
}
public
DataInfo
save
(
RecordDataForm
form
)
{
...
...
@@ -25,13 +25,13 @@ public class RecordDataService {
data
.
setProcessInfo
(
form
.
getProcessInfo
());
Timestamp
now
=
Timestamp
.
valueOf
(
DateUtil
.
getDateTime
());
data
.
setCreateAt
(
now
);
data
=
recordData
Dao
.
save
(
data
);
data
=
dataInfo
Dao
.
save
(
data
);
return
data
;
}
public
DataInfo
update
(
RecordDataForm
form
)
{
DataInfo
data
=
this
.
get
(
form
.
getDataId
());
data
=
recordData
Dao
.
save
(
data
);
data
=
dataInfo
Dao
.
save
(
data
);
return
data
;
}
}
src/main/java/com/keymobile/rest/service/
Job
InfoService.java
→
src/main/java/com/keymobile/rest/service/
Process
InfoService.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.
activiti
.utils.DateUtil
;
import
com.keymobile.
rest.common
.utils.DateUtil
;
import
com.keymobile.rest.dao.*
;
import
com.keymobile.rest.model.Template
;
import
com.keymobile.rest.model.ProcessInfo
;
...
...
@@ -12,10 +12,10 @@ import java.sql.Timestamp;
import
java.util.List
;
@Service
public
class
Job
InfoService
{
public
class
Process
InfoService
{
@Autowired
private
JobInfoDao
job
InfoDao
;
private
ProcessInfoDao
process
InfoDao
;
public
ProcessInfo
save
(
User
user
,
Template
template
)
{
ProcessInfo
info
=
new
ProcessInfo
();
...
...
@@ -23,23 +23,23 @@ public class JobInfoService {
info
.
setUser
(
user
);
Timestamp
now
=
Timestamp
.
valueOf
(
DateUtil
.
getDateTime
());
info
.
setCreateAt
(
now
);
info
=
job
InfoDao
.
save
(
info
);
info
=
process
InfoDao
.
save
(
info
);
return
info
;
}
public
List
<
ProcessInfo
>
findAllBy
Excel
Id
(
long
eid
)
{
return
jobInfoDao
.
findAllByExcel
Id
(
eid
);
public
List
<
ProcessInfo
>
findAllBy
Template
Id
(
long
eid
)
{
return
processInfoDao
.
findAllByTemplate
Id
(
eid
);
}
public
ProcessInfo
findBy
Excel
IdAndUserId
(
long
eid
,
long
uid
)
{
return
jobInfoDao
.
findByExcel
IdAndUserId
(
eid
,
uid
);
public
ProcessInfo
findBy
Template
IdAndUserId
(
long
eid
,
long
uid
)
{
return
processInfoDao
.
findByTemplate
IdAndUserId
(
eid
,
uid
);
}
public
List
<
ProcessInfo
>
findByUserId
(
long
uid
)
{
return
job
InfoDao
.
findAllByUserId
(
uid
);
return
process
InfoDao
.
findAllByUserId
(
uid
);
}
public
void
deleteAllBy
Excel
Id
(
long
eid
)
{
jobInfoDao
.
deleteAllByExcel
Id
(
eid
);
public
void
deleteAllBy
Template
Id
(
long
eid
)
{
processInfoDao
.
deleteAllByTemplate
Id
(
eid
);
}
}
src/main/java/com/keymobile/rest/service/
Excel
Service.java
→
src/main/java/com/keymobile/rest/service/
Template
Service.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.
activiti
.utils.DateUtil
;
import
com.keymobile.
rest.common
.utils.DateUtil
;
import
com.keymobile.rest.dao.*
;
import
com.keymobile.rest.model.Template
;
import
com.keymobile.rest.vo.ExcelForm
;
...
...
@@ -11,10 +11,10 @@ import java.sql.Timestamp;
import
java.util.List
;
@Service
public
class
Excel
Service
{
public
class
Template
Service
{
@Autowired
private
ExcelDao
excel
Dao
;
private
TemplateDao
template
Dao
;
public
Template
save
(
ExcelForm
form
)
{
Template
template
=
new
Template
();
...
...
@@ -25,27 +25,27 @@ public class ExcelService {
template
.
setAssignment
(
form
.
getAssignment
());
Timestamp
now
=
Timestamp
.
valueOf
(
DateUtil
.
getDateTime
());
template
.
setCreateAt
(
now
);
template
=
excel
Dao
.
save
(
template
);
template
=
template
Dao
.
save
(
template
);
return
template
;
}
public
Template
get
(
long
id
)
{
return
excel
Dao
.
getOne
(
id
);
return
template
Dao
.
getOne
(
id
);
}
public
void
update
(
Template
template
)
{
excel
Dao
.
save
(
template
);
template
Dao
.
save
(
template
);
}
public
List
<
Template
>
findAllByIdIn
(
List
<
Long
>
ids
)
{
return
excel
Dao
.
findAllByIdIn
(
ids
);
return
template
Dao
.
findAllByIdIn
(
ids
);
}
public
List
<
Template
>
findAllBy
JobId
(
long
ji
d
)
{
return
excelDao
.
findAllByJobId
(
ji
d
);
public
List
<
Template
>
findAllBy
AssignmentId
(
long
assignmentI
d
)
{
return
templateDao
.
findAllByAssignmentId
(
assignmentI
d
);
}
public
void
saveAll
(
List
<
Template
>
templateList
)
{
excel
Dao
.
saveAll
(
templateList
);
template
Dao
.
saveAll
(
templateList
);
}
}
src/main/java/com/keymobile/rest/service/UserService.java
View file @
cbca00c9
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.rest.common.constant.UserConstant
;
import
com.keymobile.rest.dao.UserDao
;
import
com.keymobile.rest.model.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,19 +23,19 @@ public class UserService {
}
public
User
getAudit
()
{
List
<
User
>
userList
=
userDao
.
findAllByRole
(
User
.
ROLE_AUDIT
);
List
<
User
>
userList
=
userDao
.
findAllByRole
(
User
Constant
.
ROLE_AUDIT
);
User
user
=
userList
.
get
(
0
);
return
user
;
}
public
User
getNormalUser
()
{
List
<
User
>
userList
=
userDao
.
findAllByRole
(
User
.
ROLE_NORMAL
);
List
<
User
>
userList
=
userDao
.
findAllByRole
(
User
Constant
.
ROLE_NORMAL
);
User
user
=
userList
.
get
(
0
);
return
user
;
}
public
User
getManager
()
{
List
<
User
>
userList
=
userDao
.
findAllByRole
(
User
.
ROLE_MANAGER
);
List
<
User
>
userList
=
userDao
.
findAllByRole
(
User
Constant
.
ROLE_MANAGER
);
User
user
=
userList
.
get
(
0
);
return
user
;
}
...
...
src/main/resources/application-test.yml
View file @
cbca00c9
mongodb
:
uri
:
127.0.0.1:27017
database
:
dev0
username
:
root
password
:
dataPlatform
maxConnectionIdleTime
:
600000
spring
:
application
:
name
:
activiti
jpa
:
show-sql
:
true
database-platform
:
org.hibernate.dialect.MySQL5Dialect
#
hibernate:
#
ddl-auto: update
hibernate
:
ddl-auto
:
update
datasource
:
url
:
jdbc:mysql://47.105.193.165:3306/
test
?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
url
:
jdbc:mysql://47.105.193.165:3306/
dev0
?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username
:
root
password
:
123456
hikari
:
...
...
@@ -23,10 +16,6 @@ spring:
multipart
:
max-file-size
:
20Mb
max-request-size
:
100Mb
# session:
# store-type: redis
# redis:
# namespace: dataplatformtst
redis
:
host
:
127.0.0.1
port
:
6379
...
...
@@ -35,29 +24,9 @@ spring:
server
:
port
:
8110
#eureka:
# client:
# registerWithEureka: true
# region: default
# registryFetchIntervalSeconds: 5
# serviceUrl:
# defaultZone: http://192.168.0.13:9081/eureka/
# enabled: true
# instance:
# prefer-ip-address: true
# hostname: 192.168.0.13
app
:
active-process
:
RecordStandardProcess.bpmn
swagger2
:
host
:
localhost:8110
# host: 47.105.236.43/activiti
security
:
permit
:
true
authUser
:
root
authPwd
:
pwd
\ No newline at end of file
# host: 47.105.236.43/activiti
\ No newline at end of file
src/main/resources/bootstrap.yml
deleted
100644 → 0
View file @
ee6e03cf
spring
:
application
:
name
:
activiti
profiles
:
active
:
test
cloud
:
config
:
uri
:
http://localhost:8082
\ No newline at end of file
src/test/java/com/keymobile/ProcessTest.java
View file @
cbca00c9
package
com
.
keymobile
;
import
com.keymobile.rest.service.
Job
Service
;
import
com.keymobile.rest.service.
Assignment
Service
;
import
org.activiti.engine.*
;
import
org.activiti.engine.history.HistoricProcessInstance
;
import
org.activiti.engine.history.HistoricProcessInstanceQuery
;
...
...
@@ -18,7 +18,7 @@ import java.util.List;
public
class
ProcessTest
{
@Resource
private
JobService
job
Service
;
private
AssignmentService
assignment
Service
;
@Resource
private
RepositoryService
repositoryService
;
@Resource
...
...
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