Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
work_service
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
work_service
Commits
24c72689
Commit
24c72689
authored
Jan 27, 2021
by
cq990612
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码结构
parent
01f4ef8f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
49 deletions
+74
-49
BASE_RESP_CODE_ENUM.java
...wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
+1
-0
RESP_CODE_ENUM.java
...a/cn/wisenergy/common/utils/exception/RESP_CODE_ENUM.java
+1
-0
WorkTimeOrderServiceImpl.java
...a/cn/wisenergy/service/impl/WorkTimeOrderServiceImpl.java
+68
-38
WorkTimeOrderController.java
...rgy/web/admin/controller/app/WorkTimeOrderController.java
+4
-11
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
View file @
24c72689
...
...
@@ -61,6 +61,7 @@ public enum BASE_RESP_CODE_ENUM {
NOT_MANAGER_TYPE
(
"642"
,
"没有可以管理的类型项目"
),
;
/**
* 错误编码
...
...
wisenergy-common/src/main/java/cn/wisenergy/common/utils/exception/RESP_CODE_ENUM.java
View file @
24c72689
...
...
@@ -29,6 +29,7 @@ public enum RESP_CODE_ENUM {
QUERY_WORK_ORDER_LISt_FAIL
(
"1021"
,
"获取工单列表失败"
),
AUDIT_WORK_ORDER_FAIL
(
"1022"
,
"审核工单失败"
),
QUERY_USER_INFO_FAIL
(
"1023"
,
"获取用户信息失败"
)
;
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkTimeOrderServiceImpl.java
View file @
24c72689
...
...
@@ -156,9 +156,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
public
List
<
WorkTimeOrderDto
>
add
(
@RequestBody
CreateWorkOrderDto
dto
)
{
log
.
info
(
"WorkTimeOrderServiceImpl[]add[]input.param.CreateWorkOrderDto:{}"
+
dto
);
if
(
null
==
dto
||
CollectionUtils
.
isEmpty
(
dto
.
getWorkTimeOrders
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM
_IS_NULL
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_INFO
_IS_NULL
);
}
// 1.检查工单
this
.
checkWorkOrderInfo
(
dto
.
getWorkTimeOrders
());
...
...
@@ -179,6 +178,10 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
@Override
public
List
<
WorkTimeOrderDto
>
addTest
(
CreateWorkOrderDto
createWorkOrderDto
)
{
log
.
info
(
"WorkTimeOderServiceImpl[]addTest[]input.param.creatWorkOrderDto"
+
createWorkOrderDto
);
if
(
null
==
createWorkOrderDto
||
CollectionUtils
.
isEmpty
(
createWorkOrderDto
.
getWorkTimeOrders
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_INFO_IS_NULL
);
}
List
<
WorkTimeOrderDto
>
workTimeOrders
=
createWorkOrderDto
.
getWorkTimeOrders
();
Date
date
=
new
Date
();
WorkSubmitAdopt
workSubmitAdopt
=
workSubmitAdoptService
.
getById
(
1
);
...
...
@@ -192,7 +195,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
timeNotEight
(
0
,
workTimeOrders
);
int
totalTime
=
0
;
int
size
=
0
;
List
<
Integer
>
typeList
=
new
ArrayList
<>();
for
(
WorkTimeOrderDto
dto
:
workTimeOrders
)
{
// 3.判断工单是否合法
...
...
@@ -212,11 +214,11 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
}
if
(
1
!=
type
&&
2
!=
type
)
{
dto
.
setManagerName
(
workUserService
.
getById
(
workTypeService
.
getByDeptId
(
workUserService
.
getById
(
dto
.
getUserId
()).
getDeptId
()).
get
(
0
).
getManagerId
()).
getName
());
}
dto
.
setStatus
(
1
);
if
(
3
==
type
||
4
==
type
)
{
size
++;
dto
.
setStatus
(
2
);
}
dto
.
setIsOvertime
(
0
);
...
...
@@ -243,10 +245,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
BeanUtils
.
copyProperties
(
workTimeOrder
,
dto
);
}
int
status
=
1
;
if
(
size
==
typeList
.
size
())
{
status
=
2
;
}
int
status
=
statusYes
(
workTimeOrders
.
get
(
0
).
getUserId
(),
workTimeOrders
.
get
(
0
).
getWorkDay
());
WorkCollect
workCollect
=
workCollectService
.
getByUserIdAndWorkDay
(
workTimeOrders
.
get
(
0
).
getUserId
(),
workTimeOrders
.
get
(
0
).
getWorkDay
());
if
(
null
==
workCollect
)
{
workCollect
=
new
WorkCollect
();
...
...
@@ -278,41 +277,59 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
public
List
<
WorkTimeOrderDto
>
update
(
CreateWorkOrderDto
dto
)
{
log
.
info
(
"WorkTimeOrderServiceImpl[]update[]input.param.CreateWorkOrderDto:{}"
+
dto
);
if
(
null
==
dto
||
CollectionUtils
.
isEmpty
(
dto
.
getWorkTimeOrders
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM
_IS_NULL
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_INFO
_IS_NULL
);
}
List
<
WorkTimeOrderDto
>
workTimeOrders
=
dto
.
getWorkTimeOrders
();
// 判断是否超过8小时
//
1.
判断是否超过8小时
int
count
=
0
;
List
<
WorkTimeOrder
>
byDayToDto
=
getByDayToDto
(
workTimeOrders
.
get
(
0
).
getUserId
(),
workTimeOrders
.
get
(
0
).
getWorkDay
());
// 判断是否重复填报
for
(
WorkTimeOrder
workTimeOrder
:
byDayToDto
)
{
if
(
3
==
workTimeOrder
.
getStatus
())
{
continue
;
}
count
+=
workTimeOrder
.
getWorkTime
();
}
timeNotEight
(
count
,
workTimeOrders
);
int
totalTime
=
0
;
// 2.判断是否重复填报
isRepeat
(
workTimeOrders
);
for
(
WorkTimeOrder
orderDto
:
byDayToDto
)
{
if
(
2
==
orderDto
.
getStatus
()
||
5
==
orderDto
.
getStatus
())
{
count
+=
orderDto
.
getWorkTime
();
for
(
WorkTimeOrderDto
workTimeOrder
:
workTimeOrders
)
{
if
(
orderDto
.
getType
().
equals
(
workTimeOrder
.
getType
())
)
{
if
(
1
==
orderDto
.
getType
()
||
2
==
orderDto
.
getType
()
&&
orderDto
.
getProjectId
().
equals
(
workTimeOrder
.
getProjectId
()
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_ALREADY_COMMIT
)
;
for
(
WorkTimeOrder
orderDto
:
byDayToDto
)
{
// 过滤表中已经被驳回的
if
(
3
==
orderDto
.
getStatus
(
))
{
continue
;
}
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_ALREADY_COMMIT
);
totalTime
+=
orderDto
.
getWorkTime
();
// 如果类型不相同
if
(!
workTimeOrder
.
getType
().
equals
(
orderDto
.
getType
()))
{
continue
;
}
// 类型相同projectId不同
if
(
null
!=
workTimeOrder
.
getProjectId
()
&&
null
!=
orderDto
.
getProjectId
()
||
!
workTimeOrder
.
getProjectId
().
equals
(
orderDto
.
getProjectId
()))
{
continue
;
}
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_ALREADY_COMMIT
);
}
totalTime
+=
workTimeOrder
.
getWorkTime
();
}
// 判断是否超过8小时
timeNotEight
(
count
,
workTimeOrders
);
List
<
WorkTimeOrderDto
>
workTimeOrderDtos
=
reSubmit
(
workTimeOrders
);
// 更新collect表
int
status
=
statusYes
(
workTimeOrders
.
get
(
0
).
getUserId
(),
workTimeOrderDtos
.
get
(
0
).
getWorkDay
());
WorkCollect
workCollect
=
new
WorkCollect
();
BeanUtils
.
copyProperties
(
workTimeOrders
.
get
(
0
),
workCollect
);
workCollect
.
setTotalTime
(
totalTime
);
workCollect
.
setStatus
(
status
);
workCollectService
.
update
(
workCollect
);
// 更新数据
return
reSubmit
(
workTimeOrders
)
;
return
workTimeOrderDtos
;
}
// 判断填写工时单是否重复
private
void
isRepeat
(
List
<
WorkTimeOrderDto
>
list
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
...
...
@@ -321,8 +338,8 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
i
+
1
;
j
<
size
;
j
++)
{
if
(
list
.
get
(
i
).
getType
().
equals
(
list
.
get
(
j
).
getType
()))
{
if
(
1
==
list
.
get
(
i
).
getType
()
||
2
==
list
.
get
(
i
).
getType
()
&&
list
.
get
(
i
).
getProjectId
().
equals
(
list
.
get
(
j
).
getProjectId
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_ALREADY_COMMIT
)
;
if
(
null
!=
list
.
get
(
i
).
getProjectId
()
&&
null
!=
list
.
get
(
j
).
getProjectId
()
&&
list
.
get
(
i
).
getProjectId
().
equals
(
list
.
get
(
j
).
getProjectId
()))
{
continue
;
}
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_ALREADY_COMMIT
);
}
...
...
@@ -498,7 +515,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
WORK_ORDER_INFO_IS_NULL
);
}
workCollect
.
setStatus
(
3
);
workCollect
.
setTotalTime
(
0
);
return
workCollectService
.
update
(
workCollect
);
}
...
...
@@ -758,8 +774,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
workTimeOrderDto
.
setTypeName
(
getTypeName
(
workTimeOrderDto
.
getType
()));
// 获取部门id
Integer
deptIdByUserId
=
workUserDeptService
.
getDeptIdByUserId
(
workTimeOrder
.
getUserId
());
workTimeOrder
.
setDeptId
(
deptIdByUserId
);
Date
workDay
=
workTimeOrder
.
getWorkDay
();
// 默认正常工时
...
...
@@ -771,11 +785,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
if
(
0
==
iRow
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
UPDATE_DATA_FAIL
);
}
WorkCollect
workCollect
=
new
WorkCollect
();
BeanUtils
.
copyProperties
(
workTimeOrder
,
workCollect
);
workCollect
.
setStatus
(
1
);
workCollect
.
setTotalTime
(
workTimeOrder
.
getWorkTime
());
workCollectService
.
update
(
workCollect
);
}
return
workTimeOrders
;
}
...
...
@@ -912,4 +921,25 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
return
map
.
get
(
type
);
}
// 判断当天是否全部审批通过
private
int
statusYes
(
Integer
userId
,
Date
workDay
)
{
int
status
=
1
;
int
size
=
0
;
List
<
WorkTimeOrder
>
workTimeOrderDtos
=
workTimeOrderMapper
.
getByDay
(
userId
,
workDay
);
for
(
WorkTimeOrder
dto
:
workTimeOrderDtos
)
{
if
(
2
==
dto
.
getStatus
()
||
5
==
dto
.
getStatus
())
{
size
++;
}
if
(
3
==
dto
.
getStatus
())
{
status
=
3
;
}
}
if
(
size
==
workTimeOrderDtos
.
size
())
{
status
=
2
;
}
return
status
;
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/WorkTimeOrderController.java
View file @
24c72689
package
cn
.
wisenergy
.
web
.
admin
.
controller
.
app
;
import
cn.wisenergy.common.utils.DateUtil
;
import
cn.wisenergy.common.utils.exception.BaseCustomException
;
import
cn.wisenergy.common.utils.exception.CustomException
;
import
cn.wisenergy.common.utils.exception.RESP_CODE_ENUM
;
import
cn.wisenergy.common.utils.exception.Result
;
...
...
@@ -54,9 +55,7 @@ public class WorkTimeOrderController extends BaseController {
@PostMapping
(
value
=
"/add"
)
public
Result
<
List
<
WorkTimeOrderDto
>>
add
(
@RequestBody
CreateWorkOrderDto
dto
)
{
log
.
info
(
"WorkTimeOrderController[]add[]input.param"
+
dto
);
if
(
null
==
dto
||
CollectionUtils
.
isEmpty
(
dto
.
getWorkTimeOrders
()))
{
throw
new
CustomException
(
RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
List
<
WorkTimeOrderDto
>
workOrderList
=
workTimeOrderService
.
add
(
dto
);
return
getResult
(
workOrderList
);
}
...
...
@@ -66,9 +65,6 @@ public class WorkTimeOrderController extends BaseController {
@PutMapping
(
value
=
"/update"
)
public
Result
<
List
<
WorkTimeOrderDto
>>
update
(
@RequestBody
CreateWorkOrderDto
dto
)
{
log
.
info
(
"WorkTimeOrderController[]update[]input.param"
+
dto
);
if
(
null
==
dto
||
CollectionUtils
.
isEmpty
(
dto
.
getWorkTimeOrders
()))
{
throw
new
CustomException
(
RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
List
<
WorkTimeOrderDto
>
updateData
=
workTimeOrderService
.
update
(
dto
);
return
getResult
(
updateData
);
}
...
...
@@ -171,12 +167,9 @@ public class WorkTimeOrderController extends BaseController {
@ApiOperation
(
value
=
"工时填报(测试)"
,
notes
=
"工时填报(测试)"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
(
name
=
"dto"
,
value
=
"创建工单dto"
,
dataType
=
"CreateWorkOrderDto"
)
@PostMapping
(
value
=
"/add
test
"
)
public
Result
<
List
<
WorkTimeOrderDto
>>
add
Test
(
@RequestBody
CreateWorkOrderDto
dto
)
{
@PostMapping
(
value
=
"/add
Order
"
)
public
Result
<
List
<
WorkTimeOrderDto
>>
add
Order
(
@RequestBody
CreateWorkOrderDto
dto
)
{
log
.
info
(
"WorkTimeOrderController[]addTest[]input.param"
+
dto
);
if
(
CollectionUtils
.
isEmpty
(
dto
.
getWorkTimeOrders
()))
{
throw
new
CustomException
(
RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
List
<
WorkTimeOrderDto
>
workTimeOrderDtos
=
workTimeOrderService
.
addTest
(
dto
);
return
getResult
(
workTimeOrderDtos
);
...
...
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