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
7c3fe4bc
Commit
7c3fe4bc
authored
Mar 25, 2021
by
cq990612
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码结构
parent
9e111695
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
35 deletions
+108
-35
WorkOrderChangeMapper.java
.../main/java/cn/wisenergy/mapper/WorkOrderChangeMapper.java
+2
-2
WorkOrderChangeMapper.xml
...apper/src/main/resources/mapper/WorkOrderChangeMapper.xml
+49
-26
WorkOrderChangeImpl.java
...n/java/cn/wisenergy/service/impl/WorkOrderChangeImpl.java
+57
-7
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/WorkOrderChangeMapper.java
View file @
7c3fe4bc
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.app.WorkOrderChange
;
import
cn.wisenergy.model.dto.OrderChangeLogMapperDto
;
import
cn.wisenergy.model.dto.WorkOrderChangeLogDto
;
import
cn.wisenergy.model.vo.OrderChangeLogVo
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
java.util.List
;
...
...
@@ -10,5 +10,5 @@ import java.util.List;
public
interface
WorkOrderChangeMapper
extends
BaseMapper
<
WorkOrderChange
>
{
List
<
WorkOrderChangeLogDto
>
getWorkOrderChangeLogDto
(
OrderChangeLog
V
o
vo
);
List
<
WorkOrderChangeLogDto
>
getWorkOrderChangeLogDto
(
OrderChangeLog
MapperDt
o
vo
);
}
wisenergy-mapper/src/main/resources/mapper/WorkOrderChangeMapper.xml
View file @
7c3fe4bc
...
...
@@ -5,33 +5,56 @@
<select
id=
"getWorkOrderChangeLogDto"
resultType=
"cn.wisenergy.model.dto.WorkOrderChangeLogDto"
>
select oc.change_date,CASE oc.content when 1 THEN '新增工单' when 2 THEN '删除工单' when 3 then '修改工单' end as 'content'
,oc.u1.name 'operator',d.dept_name,if(oc.project_id is null,t.name,p.project_name) 'project_name',
oc.work_day,u2.name 'user_name',oc.work_time,oc.des,oc.change_reason
from work_order_change oc LEFT JOIN work_dept d ON oc.dept_id = d.id
LEFT JOIN work_project p ON oc.project_id = p.id
LEFT JOIN work_type t ON oc.type = t.id
LEFT JOIN (SELECT id,name FROM work_user ) u1 ON u1.id =oc.operator_id
LEFT JOIN (SELECT id,name FROM work_user ) u2 ON u2.id =oc.user_id
<where>
<if
test=
"startDate !=null"
>
AND oc.change_date >= #{startDate}
</if>
<if
test=
"endDate !=null"
>
AND oc.change_date
<
= #{endDate}
</if>
<if
test=
"userName !=null"
>
AND (u2.name like concat('%',#{userName},'%')
OR u1.name like concat('%',#{userName},'%'))
</if>
<if
test=
"deptId !=null"
>
AND oc.dept_id = #{deptId}
</if>
<if
test=
"projectId !=null"
>
AND oc.projectId = #{projetId}
</if>
<if
test=
"type !=null"
>
AND oc.type = #{type}
,oc.u1.name 'operator',d.dept_name,if(oc.project_id is null,t.name,p.project_name) 'project_name',
oc.work_day,u2.name 'user_name',oc.work_time,oc.des,oc.change_reason
from work_order_change oc LEFT JOIN work_dept d ON oc.dept_id = d.id
LEFT JOIN work_project p ON oc.project_id = p.id
LEFT JOIN work_type t ON oc.type = t.id
LEFT JOIN (SELECT id,name FROM work_user ) u1 ON u1.id =oc.operator_id
LEFT JOIN (SELECT id,name FROM work_user ) u2 ON u2.id =oc.user_id
<where>
<if
test=
"startDate !=null"
>
AND oc.change_date >= #{startDate}
</if>
<if
test=
"endDate !=null"
>
AND oc.change_date
<
= #{endDate}
</if>
<if
test=
"userName !=null"
>
AND (u2.name like concat('%',#{userName},'%')
OR u1.name like concat('%',#{userName},'%'))
</if>
<if
test=
"projectIds !=null and projectIds.size>0"
>
AND oc.project_id IN
<foreach
collection=
"projectIds"
item=
"projectId"
separator=
","
open=
"("
close=
")"
>
#{projectId}
</foreach>
</if>
<if
test=
"types !=null and types.size>0"
>
OR (oc.type IN
<foreach
collection=
"types"
item=
"type"
separator=
","
open=
"("
close=
")"
>
#{type}
</foreach>
<if
test=
"deptIds !=null and deptIds.size>0"
>
AND oc.dept_id IN
<foreach
collection=
"deptIds"
item=
"deptId"
separator=
","
open=
"("
close=
")"
>
#{deptId}
</foreach>
</if>
<if
test=
"startDate !=null"
>
AND oc.change_date >= #{startDate}
</if>
<if
test=
"endDate !=null"
>
AND oc.change_date
<
= #{endDate}
</if>
<if
test=
"userName !=null"
>
AND (u2.name like concat('%',#{userName},'%')
OR u1.name like concat('%',#{userName},'%'))
</if>
)
</if>
</where>
</select>
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkOrderChangeImpl.java
View file @
7c3fe4bc
...
...
@@ -3,6 +3,9 @@ package cn.wisenergy.service.impl;
import
cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM
;
import
cn.wisenergy.common.utils.exception.BaseCustomException
;
import
cn.wisenergy.mapper.WorkOrderChangeMapper
;
import
cn.wisenergy.model.dto.DeptOfProjectAndOrderType
;
import
cn.wisenergy.model.dto.OrderChangeLogMapperDto
;
import
cn.wisenergy.model.dto.ProjectManagerDto
;
import
cn.wisenergy.model.dto.WorkOrderChangeLogDto
;
import
cn.wisenergy.model.enums.LevelEnum
;
import
cn.wisenergy.model.vo.OrderChangeLogVo
;
...
...
@@ -12,10 +15,15 @@ import cn.wisenergy.service.utils.UserRoleLevelUtils;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* @Authotr:陈奇
...
...
@@ -39,16 +47,58 @@ public class WorkOrderChangeImpl implements WorkOrderChangeService {
if
(
null
==
vo
||
null
==
vo
.
getUserId
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
UserRoleLevelUtils
.
getRankByUserAndLevelName
(
vo
.
getUserId
(),
LevelEnum
.
WORKORDER_CHANGERECORD
.
getLevelName
());
if
(
null
==
vo
.
getDeptId
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
PLEASESELECTADEPARTMENT
);
List
<
Integer
>
ranks
=
UserRoleLevelUtils
.
getRankByUserAndLevelName
(
vo
.
getUserId
(),
LevelEnum
.
WORKORDER_CHANGERECORD
.
getLevelName
());
List
<
Integer
>
projectIds
=
new
ArrayList
<>();
Set
<
Integer
>
deptIds
=
new
HashSet
<>();
Set
<
Integer
>
types
=
new
HashSet
<>();
OrderChangeLogMapperDto
mapperDto
=
new
OrderChangeLogMapperDto
();
List
<
DeptOfProjectAndOrderType
>
projectsAndTypes
=
workProjectService
.
getProjectOfFind
(
vo
.
getUserId
());
if
(
CollectionUtils
.
isEmpty
(
projectsAndTypes
))
{
return
null
;
}
// 分权限查询 TODO
if
(
null
==
vo
.
getProjectId
()
&&
null
==
vo
.
getType
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
PLEASESELECTANITEM
);
if
(
null
==
vo
.
getDeptId
())
{
for
(
DeptOfProjectAndOrderType
projectsAndType
:
projectsAndTypes
)
{
if
(!
CollectionUtils
.
isEmpty
(
projectsAndType
.
getProjectManagerDtos
()))
{
for
(
ProjectManagerDto
projectManagerDto
:
projectsAndType
.
getProjectManagerDtos
())
{
if
(
null
!=
projectManagerDto
.
getId
())
{
projectIds
.
add
(
projectManagerDto
.
getId
());
}
else
{
types
.
add
(
projectManagerDto
.
getType
());
deptIds
.
add
(
projectsAndType
.
getDeptId
());
}
}
}
}
}
else
if
(
null
==
vo
.
getProjectId
()
&&
null
==
vo
.
getType
())
{
for
(
DeptOfProjectAndOrderType
projectsAndType
:
projectsAndTypes
)
{
if
(
projectsAndType
.
getDeptId
().
equals
(
vo
.
getDeptId
()))
{
if
(!
CollectionUtils
.
isEmpty
(
projectsAndType
.
getProjectManagerDtos
()))
{
for
(
ProjectManagerDto
projectManagerDto
:
projectsAndType
.
getProjectManagerDtos
())
{
if
(
null
==
projectManagerDto
.
getId
())
{
types
.
add
(
projectManagerDto
.
getType
());
deptIds
.
add
(
projectsAndType
.
getDeptId
());
}
else
{
projectIds
.
add
(
projectManagerDto
.
getId
());
}
}
}
}
}
}
else
{
if
(
null
!=
vo
.
getProjectId
())
{
projectIds
.
add
(
vo
.
getProjectId
());
}
else
{
types
.
add
(
vo
.
getType
());
deptIds
.
add
(
vo
.
getDeptId
());
}
}
BeanUtils
.
copyProperties
(
mapperDto
,
vo
);
mapperDto
.
setProjectIds
(
projectIds
);
mapperDto
.
setDeptIds
(
new
ArrayList
<>(
deptIds
));
mapperDto
.
setTypes
(
new
ArrayList
<>(
types
));
PageHelper
.
startPage
(
vo
.
getPage
(),
vo
.
getPageSize
());
List
<
WorkOrderChangeLogDto
>
workOrderChangeLogDto
=
workOrderChangeMapper
.
getWorkOrderChangeLogDto
(
v
o
);
List
<
WorkOrderChangeLogDto
>
workOrderChangeLogDto
=
workOrderChangeMapper
.
getWorkOrderChangeLogDto
(
mapperDt
o
);
PageInfo
<
WorkOrderChangeLogDto
>
pageInfo
=
new
PageInfo
<>(
workOrderChangeLogDto
);
pageInfo
.
setList
(
workOrderChangeLogDto
);
return
pageInfo
;
...
...
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