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
a240198c
Commit
a240198c
authored
Mar 09, 2020
by
chenweisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
367302b4
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
67 additions
and
69 deletions
+67
-69
IndexCtrl.java
src/main/java/com/keymobile/rest/ctrl/IndexCtrl.java
+17
-15
JobInfoDao.java
src/main/java/com/keymobile/rest/dao/JobInfoDao.java
+4
-4
Excel.java
src/main/java/com/keymobile/rest/model/Excel.java
+1
-6
Job.java
src/main/java/com/keymobile/rest/model/Job.java
+8
-10
JobInfo.java
src/main/java/com/keymobile/rest/model/JobInfo.java
+5
-7
RecordData.java
src/main/java/com/keymobile/rest/model/RecordData.java
+5
-5
ExcelService.java
src/main/java/com/keymobile/rest/service/ExcelService.java
+4
-0
JobInfoService.java
src/main/java/com/keymobile/rest/service/JobInfoService.java
+11
-11
JobService.java
src/main/java/com/keymobile/rest/service/JobService.java
+1
-1
ExcelForm.java
src/main/java/com/keymobile/rest/vo/ExcelForm.java
+4
-1
JobForm.java
src/main/java/com/keymobile/rest/vo/JobForm.java
+3
-5
application-test.yml
src/main/resources/application-test.yml
+3
-3
ProcessTest.java
src/test/java/com/keymobile/ProcessTest.java
+1
-1
No files found.
src/main/java/com/keymobile/rest/ctrl/IndexCtrl.java
View file @
a240198c
...
...
@@ -34,7 +34,7 @@ public class IndexCtrl {
@Autowired
private
RecordDataService
recordDataService
;
@Autowired
private
RecordInfoService
record
InfoService
;
private
JobInfoService
job
InfoService
;
@Autowired
private
UserService
userService
;
@Autowired
...
...
@@ -100,8 +100,7 @@ public class IndexCtrl {
public
ApiResponse
createTask
(
@RequestBody
JobForm
form
)
{
TwinkleValidator
.
notEmpty
(
form
.
getName
(),
"名称不能为空"
);
TwinkleValidator
.
notNull
(
form
.
getType
(),
"类型不能为空"
);
TwinkleValidator
.
notLessThan
(
form
.
getExcels
().
size
(),
1
,
"补录模板不能为空"
);
TwinkleValidator
.
notEmpty
(
form
.
getUserIds
(),
"补录人不能为空"
);
TwinkleValidator
.
isFalse
((
form
.
getExcels
()
==
null
||
form
.
getExcels
().
size
()
==
0
),
"补录模板不能为空"
);
// 创建人
User
manager
=
userService
.
getManager
();
form
.
setUser
(
manager
);
...
...
@@ -109,15 +108,16 @@ public class IndexCtrl {
// 新建excel实例
List
<
ExcelForm
>
excelFormList
=
form
.
getExcels
();
excelFormList
.
forEach
(
excelForm
->
{
TwinkleValidator
.
notEmpty
(
excelForm
.
getUserIds
(),
"补录人不能为空"
);
excelForm
.
setJob
(
job
);
Excel
excel
=
excelService
.
save
(
excelForm
);
// 新建补录人员任务关联
String
[]
userIds
=
f
orm
.
getUserIds
().
split
(
","
);
String
[]
userIds
=
excelF
orm
.
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
->
{
record
InfoService
.
save
(
user
,
excel
);
job
InfoService
.
save
(
user
,
excel
);
});
});
return
ApiResponse
.
ok
(
job
.
getId
());
...
...
@@ -126,12 +126,14 @@ public class IndexCtrl {
@ApiOperation
(
value
=
"修改收数"
)
@PostMapping
(
value
=
"/task/update"
)
public
ApiResponse
updateTask
(
@RequestBody
JobForm
form
)
{
TwinkleValidator
.
notEmpty
(
form
.
getName
(),
"名称不能为空"
);
TwinkleValidator
.
notNull
(
form
.
getType
(),
"类型不能为空"
);
TwinkleValidator
.
notLessThan
(
form
.
getExcels
().
size
(),
1
,
"补录模板不能为空"
);
TwinkleValidator
.
notNull
(
form
.
getId
(),
"收数id不能为空"
);
TwinkleValidator
.
isFalse
((
form
.
getId
()
==
null
&&
form
.
getId
()
<=
0
),
"收数id不能为空"
);
Job
job
=
jobService
.
get
(
form
.
getId
());
TwinkleValidator
.
notNull
(
job
,
"收数不存在"
);
int
status
=
job
.
getStatus
();
TwinkleValidator
.
isFalse
(
status
!=
Job
.
STATUS_UNRELEASED
,
"收数已经发起"
);
TwinkleValidator
.
notEmpty
(
form
.
getName
(),
"名称不能为空"
);
TwinkleValidator
.
notNull
(
form
.
getType
(),
"类型不能为空"
);
TwinkleValidator
.
isFalse
((
form
.
getExcels
()
==
null
||
form
.
getExcels
().
size
()
==
0
),
"补录模板不能为空"
);
job
.
setType
(
form
.
getType
());
job
.
setRemark
(
form
.
getRemark
());
job
.
setName
(
form
.
getName
());
...
...
@@ -145,7 +147,7 @@ public class IndexCtrl {
excel
.
setConfig
(
excelForm
.
getConfig
());
excel
.
setRemark
(
excelForm
.
getRemark
());
excel
.
setDataAt
(
excelForm
.
getDataAt
());
recordInfoService
.
deleteAllByExcelId
(
excel
.
getId
()
);
excelService
.
update
(
excel
);
});
return
ApiResponse
.
ok
(
job
.
getId
());
}
...
...
@@ -171,18 +173,18 @@ public class IndexCtrl {
//启动流程
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
processDefinition
.
getKey
(),
variables
);
job
.
setProcessId
(
processInstance
.
getId
());
jobService
.
update
(
job
);
// 发起人把流程发送到下一个人
Task
resultTask
=
taskService
.
createTaskQuery
().
processInstanceId
(
processInstance
.
getId
()).
taskInvolvedUser
(
inputUser
).
singleResult
();
// 根据收数查找需要填写的人 目前只支持一人
List
<
Excel
>
excelList
=
excelService
.
findAllByJobId
(
taskId
);
List
<
Excel
>
excelList
=
job
.
getExcelList
(
);
TwinkleValidator
.
notLessThan
(
excelList
.
size
(),
1
,
"补录模板不存在"
);
Excel
excel
=
excelList
.
get
(
0
);
List
<
RecordInfo
>
recordInfoList
=
record
InfoService
.
findAllByExcelId
(
excel
.
getId
());
TwinkleValidator
.
notLessThan
(
record
InfoList
.
size
(),
1
,
"补录人员不存在"
);
taskService
.
complete
(
resultTask
.
getId
(),
ImmutableMap
.
of
(
"userId"
,
record
InfoList
.
get
(
0
).
getUser
().
getUsername
()));
List
<
JobInfo
>
jobInfoList
=
job
InfoService
.
findAllByExcelId
(
excel
.
getId
());
TwinkleValidator
.
notLessThan
(
job
InfoList
.
size
(),
1
,
"补录人员不存在"
);
taskService
.
complete
(
resultTask
.
getId
(),
ImmutableMap
.
of
(
"userId"
,
job
InfoList
.
get
(
0
).
getUser
().
getUsername
()));
return
ApiResponse
.
ok
();
}
...
...
src/main/java/com/keymobile/rest/dao/
Record
InfoDao.java
→
src/main/java/com/keymobile/rest/dao/
Job
InfoDao.java
View file @
a240198c
package
com
.
keymobile
.
rest
.
dao
;
import
com.keymobile.rest.model.
Record
Info
;
import
com.keymobile.rest.model.
Job
Info
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
RecordInfoDao
extends
JpaRepository
<
Record
Info
,
Long
>
{
public
interface
JobInfoDao
extends
JpaRepository
<
Job
Info
,
Long
>
{
List
<
Record
Info
>
findAllByExcelId
(
long
eid
);
List
<
Job
Info
>
findAllByExcelId
(
long
eid
);
List
<
Record
Info
>
findAllByUserId
(
long
uid
);
List
<
Job
Info
>
findAllByUserId
(
long
uid
);
void
deleteAllByExcelId
(
long
eid
);
...
...
src/main/java/com/keymobile/rest/model/Excel.java
View file @
a240198c
...
...
@@ -42,12 +42,7 @@ public class Excel implements Serializable {
@CreationTimestamp
private
Timestamp
createAt
;
// 级别游离关联, 当加载的时候急加载这个对象
@ManyToOne
(
cascade
=
CascadeType
.
DETACH
,
fetch
=
FetchType
.
EAGER
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@JsonIgnore
private
Job
job
;
@OneToMany
@JsonIgnore
private
List
<
RecordInfo
>
recordInfoList
;
}
src/main/java/com/keymobile/rest/model/Job.java
View file @
a240198c
...
...
@@ -30,9 +30,8 @@ public class Job implements Serializable {
public
static
int
STATUS_UNRELEASED
=
1
;
public
static
int
STATUS_COMPLETED
=
3
;
public
static
int
JUDGE_NEED
=
2
;
public
static
int
JUDGE_NO_NEED
=
1
;
public
static
int
AUDIT_NEED
=
1
;
public
static
int
AUDIT_NO_NEED
=
2
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
@@ -41,19 +40,18 @@ public class Job implements Serializable {
@Column
(
nullable
=
false
)
private
String
name
;
@Column
@Column
(
nullable
=
false
)
private
int
type
=
1
;
@Column
@Column
(
nullable
=
false
)
private
int
status
=
1
;
@Column
private
int
judge
=
2
;
@Column
(
nullable
=
false
)
private
int
audit
=
1
;
@Column
private
String
remark
;
@Column
(
name
=
"process_id"
)
private
String
processId
;
...
...
@@ -65,8 +63,8 @@ public class Job implements Serializable {
@CreationTimestamp
private
Timestamp
createAt
;
@OneToMany
(
fetch
=
FetchType
.
EAGER
)
@
JoinTable
(
name
=
"excel"
,
joinColumns
=
{
@JoinColumn
(
name
=
"job_id"
)},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"id"
)}
)
@
OneToMany
(
fetch
=
FetchType
.
EAGER
,
mappedBy
=
"job"
)
private
List
<
Excel
>
excelList
;
@ManyToOne
...
...
src/main/java/com/keymobile/rest/model/
Record
Info.java
→
src/main/java/com/keymobile/rest/model/
Job
Info.java
View file @
a240198c
...
...
@@ -20,25 +20,23 @@ import java.util.List;
@AllArgsConstructor
@Data
@Entity
public
class
Record
Info
implements
Serializable
{
public
class
Job
Info
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
long
id
;
@Column
(
name
=
"create_at"
,
nullable
=
false
,
columnDefinition
=
"DATETIME COMMENT '创建时间'"
)
@CreationTimestamp
private
Timestamp
createAt
;
@OneToMany
@JsonIgnore
List
<
RecordData
>
recordDataList
;
@ManyToOne
@OneToOne
private
Excel
excel
;
@OneToOne
private
User
user
;
@OneToMany
(
mappedBy
=
"jobInfo"
,
fetch
=
FetchType
.
EAGER
)
List
<
RecordData
>
recordDataList
;
}
src/main/java/com/keymobile/rest/model/RecordData.java
View file @
a240198c
package
com
.
keymobile
.
rest
.
model
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
...
...
@@ -24,12 +25,11 @@ public class RecordData implements Serializable {
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
long
id
;
@Column
(
name
=
"create_at"
,
nullable
=
false
,
columnDefinition
=
"DATETIME COMMENT '创建时间'"
)
@Column
(
name
=
"create_at"
,
nullable
=
false
)
@CreationTimestamp
private
Timestamp
createAt
;
@ManyToOne
private
RecordInfo
recordInfo
;
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@JsonIgnore
private
JobInfo
jobInfo
;
}
src/main/java/com/keymobile/rest/service/ExcelService.java
View file @
a240198c
...
...
@@ -33,6 +33,10 @@ public class ExcelService {
return
excelDao
.
getOne
(
id
);
}
public
void
update
(
Excel
excel
)
{
excelDao
.
save
(
excel
);
}
public
List
<
Excel
>
findAllByIdIn
(
List
<
Long
>
ids
)
{
return
excelDao
.
findAllByIdIn
(
ids
);
}
...
...
src/main/java/com/keymobile/rest/service/
Record
InfoService.java
→
src/main/java/com/keymobile/rest/service/
Job
InfoService.java
View file @
a240198c
...
...
@@ -3,7 +3,7 @@ package com.keymobile.rest.service;
import
com.keymobile.activiti.utils.DateUtil
;
import
com.keymobile.rest.dao.*
;
import
com.keymobile.rest.model.Excel
;
import
com.keymobile.rest.model.
Record
Info
;
import
com.keymobile.rest.model.
Job
Info
;
import
com.keymobile.rest.model.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -12,30 +12,30 @@ import java.sql.Timestamp;
import
java.util.List
;
@Service
public
class
Record
InfoService
{
public
class
Job
InfoService
{
@Autowired
private
RecordInfoDao
record
InfoDao
;
private
JobInfoDao
job
InfoDao
;
public
Record
Info
save
(
User
user
,
Excel
excel
)
{
RecordInfo
info
=
new
Record
Info
();
public
Job
Info
save
(
User
user
,
Excel
excel
)
{
JobInfo
info
=
new
Job
Info
();
info
.
setExcel
(
excel
);
info
.
setUser
(
user
);
Timestamp
now
=
Timestamp
.
valueOf
(
DateUtil
.
getDateTime
());
info
.
setCreateAt
(
now
);
info
=
record
InfoDao
.
save
(
info
);
info
=
job
InfoDao
.
save
(
info
);
return
info
;
}
public
List
<
Record
Info
>
findAllByExcelId
(
long
eid
)
{
return
record
InfoDao
.
findAllByExcelId
(
eid
);
public
List
<
Job
Info
>
findAllByExcelId
(
long
eid
)
{
return
job
InfoDao
.
findAllByExcelId
(
eid
);
}
public
List
<
Record
Info
>
findByUserId
(
long
uid
)
{
return
record
InfoDao
.
findAllByUserId
(
uid
);
public
List
<
Job
Info
>
findByUserId
(
long
uid
)
{
return
job
InfoDao
.
findAllByUserId
(
uid
);
}
public
void
deleteAllByExcelId
(
long
eid
)
{
record
InfoDao
.
deleteAllByExcelId
(
eid
);
job
InfoDao
.
deleteAllByExcelId
(
eid
);
}
}
src/main/java/com/keymobile/rest/service/JobService.java
View file @
a240198c
...
...
@@ -32,7 +32,7 @@ public class JobService {
Timestamp
now
=
Timestamp
.
valueOf
(
DateUtil
.
getDateTime
());
job
.
setCreateAt
(
now
);
job
.
setStatus
(
Job
.
STATUS_UNRELEASED
);
job
.
set
Judge
(
Job
.
JUDGE
_NEED
);
job
.
set
Audit
(
Job
.
AUDIT
_NEED
);
job
.
setName
(
form
.
getName
());
job
.
setType
(
form
.
getType
());
if
(
form
.
getType
()
==
Job
.
TYPE_AUTO
)
{
...
...
src/main/java/com/keymobile/rest/vo/ExcelForm.java
View file @
a240198c
...
...
@@ -19,6 +19,9 @@ public class ExcelForm {
@ApiModelProperty
(
name
=
"id"
,
value
=
"表格id,修改的时候需要用到"
)
private
Long
id
;
@ApiModelProperty
(
required
=
true
,
name
=
"userIds"
,
value
=
"补录人员ids, 用逗号隔开"
)
private
String
userIds
;
@ApiModelProperty
(
name
=
"remark"
,
value
=
"表格名称"
,
required
=
true
)
private
String
name
;
...
...
@@ -28,7 +31,7 @@ public class ExcelForm {
@ApiModelProperty
(
name
=
"remark"
,
value
=
"表格描述"
)
private
String
remark
;
@ApiModelProperty
(
name
=
"dataAt"
,
value
=
"数据开始"
,
required
=
true
)
@ApiModelProperty
(
name
=
"dataAt"
,
value
=
"数据开始"
,
required
=
true
,
example
=
"1"
)
private
Integer
dataAt
;
@JsonIgnore
...
...
src/main/java/com/keymobile/rest/vo/JobForm.java
View file @
a240198c
...
...
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
...
...
@@ -22,8 +23,8 @@ public class JobForm {
@ApiModelProperty
(
name
=
"remark"
,
value
=
"收数描述"
)
private
String
remark
;
@ApiModelProperty
(
required
=
true
,
name
=
"type"
,
value
=
"收数类型 1手动 2自动"
)
private
int
type
=
1
;
@ApiModelProperty
(
required
=
true
,
name
=
"type"
,
value
=
"收数类型 1手动 2自动"
,
example
=
"1"
)
private
Integer
type
;
// @ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间")
@JsonIgnore
...
...
@@ -32,9 +33,6 @@ public class JobForm {
@ApiModelProperty
(
required
=
true
,
name
=
"excels"
,
value
=
"新建的模板配置数组"
)
private
List
<
ExcelForm
>
excels
;
@ApiModelProperty
(
required
=
true
,
name
=
"userIds"
,
value
=
"补录人员ids, 用逗号隔开"
)
private
String
userIds
;
@JsonIgnore
private
User
user
;
}
src/main/resources/application-test.yml
View file @
a240198c
...
...
@@ -11,8 +11,8 @@ spring:
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
username
:
root
...
...
@@ -52,7 +52,7 @@ app:
active-process
:
RecordStandardProcess.bpmn
swagger2
:
host
:
localhost:8110
#
host: localhost:8110
host
:
47.105.236.43/activiti
...
...
src/test/java/com/keymobile/ProcessTest.java
View file @
a240198c
...
...
@@ -51,7 +51,7 @@ public class ProcessTest {
// .complete("32502");
}
@Test
//
@Test
public
void
zhuguan
()
{
// try {
...
...
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