Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
ac201701
Commit
ac201701
authored
Aug 11, 2021
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.公共权限处理
2.维保任务app
parent
44109e93
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
347 additions
and
386 deletions
+347
-386
ReginParams.java
...java/com/yeejoin/amos/boot/biz/common/bo/ReginParams.java
+62
-17
OrderByEnum.java
...om/yeejoin/amos/maintenance/common/enums/OrderByEnum.java
+79
-0
PlanTaskController.java
...s/maintenance/business/controller/PlanTaskController.java
+37
-67
PlanTaskServiceImpl.java
...aintenance/business/service/impl/PlanTaskServiceImpl.java
+2
-38
IPlanTaskService.java
.../maintenance/business/service/intfc/IPlanTaskService.java
+3
-1
PlanTaskPageParamUtil.java
...amos/maintenance/business/util/PlanTaskPageParamUtil.java
+1
-1
Permission.java
...m/yeejoin/amos/maintenance/core/framework/Permission.java
+13
-0
PermissionAspect.java
...oin/amos/maintenance/core/framework/PermissionAspect.java
+148
-151
dbTemplate_plan_task.xml
...nce/src/main/resources/db/mapper/dbTemplate_plan_task.xml
+2
-111
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/bo/ReginParams.java
View file @
ac201701
...
...
@@ -10,18 +10,61 @@ import java.io.Serializable;
* @author Dell
* **/
public
class
ReginParams
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
CompanyBo
company
;
private
RoleBo
role
;
private
DepartmentBo
department
;
//用户基本信息
private
AgencyUserModel
userModel
;
private
PersonIdentity
personIdentity
;
public
static
class
PersonIdentity
{
private
String
identityType
;
private
String
personName
;
private
String
companyId
;
public
PersonIdentity
(
String
identityType
,
String
personName
,
String
companyId
){
this
.
identityType
=
identityType
;
this
.
personName
=
personName
;
this
.
companyId
=
companyId
;
}
public
String
getIdentityType
()
{
return
identityType
;
}
public
void
setIdentityType
(
String
identityType
)
{
this
.
identityType
=
identityType
;
}
public
String
getPersonName
()
{
return
personName
;
}
public
void
setPersonName
(
String
personName
)
{
this
.
personName
=
personName
;
}
public
String
getCompanyId
()
{
return
companyId
;
}
public
void
setCompanyId
(
String
companyId
)
{
this
.
companyId
=
companyId
;
}
}
public
PersonIdentity
getPersonIdentity
()
{
return
personIdentity
;
}
public
void
setPersonIdentity
(
PersonIdentity
personIdentity
)
{
this
.
personIdentity
=
personIdentity
;
}
@Deprecated
private
String
token
;
public
CompanyBo
getCompany
()
{
return
company
;
}
...
...
@@ -46,19 +89,21 @@ public class ReginParams implements Serializable {
this
.
department
=
department
;
}
public
AgencyUserModel
getUserModel
()
{
return
userModel
;
}
public
AgencyUserModel
getUserModel
()
{
return
userModel
;
}
public
void
setUserModel
(
AgencyUserModel
userModel
)
{
this
.
userModel
=
userModel
;
}
public
void
setUserModel
(
AgencyUserModel
userModel
)
{
this
.
userModel
=
userModel
;
}
@Deprecated
public
String
getToken
()
{
return
token
;
}
public
String
getToken
()
{
return
token
;
}
@Deprecated
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-maintenance-api/src/main/java/com/yeejoin/amos/maintenance/common/enums/OrderByEnum.java
0 → 100644
View file @
ac201701
package
com
.
yeejoin
.
amos
.
maintenance
.
common
.
enums
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author DELL
* 维保任务排序
*/
public
enum
OrderByEnum
{
/**
* 维保任务排序
*/
TIME_DESC
(
"时间倒序"
,
"1"
,
"beginTime desc"
),
TIME_ASC
(
"时间正序"
,
"2"
,
"beginTime asc"
),
PLAN_TASK_NUM_ASC
(
"计划维保设施数正序"
,
"3"
,
"taskPlanNum asc"
),
PLAN_TASK_NUM_DESC
(
"计划维保设施数倒序"
,
"4"
,
"taskPlanNum desc"
),
FINISH_NUM_DESC
(
"完成数倒序"
,
"5"
,
"finishNum desc"
),
FINISH_NUM_ASC
(
"完成数正序"
,
"6"
,
"finishNum asc"
);
/**
* 名字
*/
private
String
name
;
/**
* 编号
*/
private
String
code
;
/**
* 条件
*/
private
String
oderBy
;
public
String
getOderBy
()
{
return
oderBy
;
}
public
void
setOderBy
(
String
oderBy
)
{
this
.
oderBy
=
oderBy
;
}
OrderByEnum
(
String
name
,
String
code
,
String
oderBy
)
{
this
.
code
=
code
;
this
.
name
=
name
;
this
.
oderBy
=
oderBy
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
static
List
<
Map
<
String
,
Object
>>
getEnumList
()
{
return
Arrays
.
stream
(
OrderByEnum
.
values
()).
map
(
e
->
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
e
.
getCode
(),
e
.
getName
());
return
map
;
}).
collect
(
Collectors
.
toList
());
}
public
static
OrderByEnum
getEumByCode
(
String
code
)
throws
Exception
{
Optional
<
OrderByEnum
>
op
=
Arrays
.
stream
(
OrderByEnum
.
values
()).
filter
(
e
->
e
.
getCode
().
equals
(
code
)).
findFirst
();
return
op
.
orElseThrow
(()->
new
Exception
(
"非法的条件"
));
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/controller/PlanTaskController.java
View file @
ac201701
package
com
.
yeejoin
.
amos
.
maintenance
.
business
.
controller
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
...
...
@@ -32,14 +8,11 @@ import com.yeejoin.amos.maintenance.business.param.PlanTaskPageParam;
import
com.yeejoin.amos.maintenance.business.service.intfc.IPlanTaskService
;
import
com.yeejoin.amos.maintenance.business.service.intfc.IPointService
;
import
com.yeejoin.amos.maintenance.business.service.intfc.IRouteService
;
import
com.yeejoin.amos.maintenance.business.util.CommonResponse
;
import
com.yeejoin.amos.maintenance.business.util.CommonResponseUtil
;
import
com.yeejoin.amos.maintenance.business.util.FileHelper
;
import
com.yeejoin.amos.maintenance.business.util.PlanTaskPageParamUtil
;
import
com.yeejoin.amos.maintenance.business.util.Toke
;
import
com.yeejoin.amos.maintenance.business.util.*
;
import
com.yeejoin.amos.maintenance.business.vo.CodeOrderVo
;
import
com.yeejoin.amos.maintenance.business.vo.PlanTaskVo
;
import
com.yeejoin.amos.maintenance.business.vo.PointInputItemVo
;
import
com.yeejoin.amos.maintenance.common.enums.OrderByEnum
;
import
com.yeejoin.amos.maintenance.common.enums.PlanTaskDetailStatusEnum
;
import
com.yeejoin.amos.maintenance.common.enums.PlanTaskFinishStatusEnum
;
import
com.yeejoin.amos.maintenance.common.enums.TaskIsOrderEnum
;
...
...
@@ -51,10 +24,21 @@ import com.yeejoin.amos.maintenance.dao.entity.Point;
import
com.yeejoin.amos.maintenance.dao.entity.PointClassify
;
import
com.yeejoin.amos.maintenance.exception.YeeException
;
import
com.yeejoin.amos.maintenance.feign.RemoteSecurityService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@RestController
@RequestMapping
(
value
=
"/api/planTask"
)
...
...
@@ -73,6 +57,7 @@ public class PlanTaskController extends AbstractBaseController {
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
private
String
loginOrgCode
;
/**
* 计划执行查询
...
...
@@ -483,54 +468,39 @@ public class PlanTaskController extends AbstractBaseController {
/**
* 查询任务列表
*
* @param
queryRequests
* @param
* @return
*/
@Permission
@ApiOperation
(
value
=
"
根据用户条件查询所有计划任务(<font color='blue'>手机app</font>)"
,
notes
=
"根据用户条件查询所有计划任务(<font color='blue'>手机app</font>)
"
)
@RequestMapping
(
value
=
"/queryPlanTask"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POS
T
)
@Permission
(
isPersonIdentity
=
true
)
@ApiOperation
(
value
=
"
维保任务查询-mobile"
,
notes
=
"根据用户条件查询所有计划任务
"
)
@RequestMapping
(
value
=
"/queryPlanTask"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
GE
T
)
public
CommonResponse
qryLoginUserPlanTask
(
@ApiParam
(
value
=
"查询条件"
,
required
=
false
)
@RequestBody
(
required
=
false
)
List
<
CommonRequest
>
queryRequests
,
@ApiParam
(
value
=
"分页参数"
,
required
=
false
,
defaultValue
=
"current=0&pageSize=10或pageNumber0&pageSize=10"
)
CommonPageable
pageable
)
{
@ApiParam
(
value
=
"人员"
)
@RequestParam
(
value
=
"userId"
,
required
=
false
)
Long
userId
,
@ApiParam
(
value
=
"开始日期"
)
@RequestParam
(
value
=
"startTime"
)
String
startTime
,
@ApiParam
(
value
=
"结束日期"
)
@RequestParam
(
value
=
"endTime"
)
String
endTime
,
@ApiParam
(
value
=
"维保状态"
)
@RequestParam
(
value
=
"finishStatus"
,
required
=
false
)
Integer
finishStatus
,
@ApiParam
(
value
=
"排序条件"
)
@RequestParam
(
value
=
"orderBy"
)
String
orderBy
,
@ApiParam
(
value
=
"业主单位"
)
@RequestParam
(
value
=
"companyId"
,
required
=
false
)
String
companyId
,
@ApiParam
(
value
=
"当前页"
)
@RequestParam
(
value
=
"pageNumber"
)
int
current
,
@ApiParam
(
value
=
"页大小"
)
@RequestParam
(
value
=
"pageSize"
)
int
size
)
throws
Exception
{
HashMap
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
ReginParams
reginParams
=
getSelectedOrgInfo
();
String
loginOrgCode
=
getLoginOrgCode
(
reginParams
);
params
=
PlanTaskPageParamUtil
.
fillPlanTask
(
queryRequests
,
params
);
Map
<
String
,
Object
>
authMap
=
Bean
.
BeantoMap
(
reginParams
.
getPersonIdentity
());
params
.
putAll
(
authMap
);
params
.
put
(
"companyId"
,
companyId
);
params
.
put
(
"orgCode"
,
loginOrgCode
);
params
.
put
(
"pageSize"
,
pageable
.
getPageSize
());
params
.
put
(
"offset"
,
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
if
(
ObjectUtils
.
isEmpty
(
params
.
get
(
"orderBy"
)))
{
params
.
put
(
"orderBy"
,
"beginTime desc"
);
}
if
(
params
.
get
(
"orderBy"
).
toString
().
contains
(
"taskPlanNum"
))
{
params
.
put
(
"orderBy"
,
params
.
get
(
"orderBy"
)
+
",beginTime asc"
);
}
params
.
put
(
"userId"
,
userId
);
params
.
put
(
"startTime"
,
startTime
);
params
.
put
(
"endTime"
,
endTime
);
params
.
put
(
"finishStatus"
,
finishStatus
);
params
.
put
(
"orderBy"
,
OrderByEnum
.
getEumByCode
(
orderBy
).
getOderBy
());
CommonPageable
pageable
=
new
CommonPageable
(
current
,
size
);
try
{
Page
page
=
planTaskService
.
getPlanTasks
(
getToken
(),
getProduct
(),
getAppKey
(),
params
);
List
<
Map
<
String
,
Object
>>
li
=
page
.
getContent
();
List
<
Map
<
String
,
Object
>>
li1
=
new
ArrayList
<>();
if
(
li
!=
null
&&
li
.
size
()
>
0
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
for
(
Map
<
String
,
Object
>
msg
:
li
)
{
String
[]
userIds
=
msg
.
get
(
"userId"
).
toString
().
split
(
","
);
for
(
String
userId
:
userIds
)
{
msg
.
put
(
"userId"
,
userId
);
}
if
(
msg
.
get
(
"checkDate"
)
!=
null
)
msg
.
put
(
"checkDate"
,
sdf
.
format
(
sdf
.
parse
(
msg
.
get
(
"checkDate"
).
toString
())));
li1
.
add
(
msg
);
}
}
Page
<
Map
<
String
,
Object
>>
pd
=
new
PageImpl
<>(
li1
,
page
.
getPageable
(),
page
.
getTotalElements
());
return
CommonResponseUtil
.
success
(
pd
);
return
CommonResponseUtil
.
success
(
planTaskService
.
getPlanTasks
(
params
,
pageable
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
CommonResponseUtil
.
failure
(
e
.
getMessage
());
}
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/service/impl/PlanTaskServiceImpl.java
View file @
ac201701
...
...
@@ -566,50 +566,14 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
public
Page
<
HashMap
<
String
,
Object
>>
getPlanTasks
(
String
toke
,
String
product
,
String
appKey
,
HashMap
<
String
,
Object
>
params
)
{
CommonPageable
pageParam
=
new
CommonPageable
();
public
Page
<
HashMap
<
String
,
Object
>>
getPlanTasks
(
HashMap
<
String
,
Object
>
params
,
CommonPageable
pageParam
)
{
List
<
HashMap
<
String
,
Object
>>
content
=
Lists
.
newArrayList
();
long
total
=
planTaskMapper
.
getPlanTasksCount
(
params
);
if
(
total
==
0
)
{
return
new
PageImpl
<>(
content
,
pageParam
,
total
);
}
content
=
planTaskMapper
.
getPlanTasks
(
params
);
if
(!
CollectionUtils
.
isEmpty
(
content
))
{
Set
<
String
>
userIds
=
Sets
.
newHashSet
();
content
.
forEach
(
e
->
{
String
userId
=
e
.
get
(
"userId"
).
toString
();
if
(
StringUtil
.
isNotEmpty
(
userId
))
{
userIds
.
add
(
userId
);
}
});
List
<
AgencyUserModel
>
userModelList
=
remoteSecurityService
.
listUserByUserIds
(
toke
,
product
,
appKey
,
Joiner
.
on
(
","
).
join
(
userIds
));
Map
<
String
,
String
>
userModelMap
=
userModelList
.
stream
().
collect
(
Collectors
.
toMap
(
AgencyUserModel:
:
getUserId
,
AgencyUserModel:
:
getRealName
,
(
k1
,
k2
)
->
k2
));
List
<
String
>
userNames
=
new
ArrayList
<>();
content
.
forEach
(
e
->
{
userNames
.
clear
();
List
<
String
>
userIds1
=
Arrays
.
asList
(
e
.
get
(
"userId"
).
toString
().
split
(
","
));
for
(
String
userId
:
userIds1
)
{
userNames
.
add
(
userModelMap
.
get
(
userId
));
}
userNames
.
remove
(
null
);
if
(
userNames
!=
null
&&
userNames
.
size
()
>
0
)
{
e
.
put
(
"executiveName"
,
Joiner
.
on
(
","
).
join
(
userNames
));
}
else
{
e
.
put
(
"executiveName"
,
" "
);
}
/*e.put("beginTime",new Date().getTime());
e.put("endTime",new Date().getTime());*/
});
return
new
PageImpl
<>(
content
,
pageParam
,
total
);
}
return
null
;
return
new
PageImpl
<>(
content
,
pageParam
,
total
);
}
@Override
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/service/intfc/IPlanTaskService.java
View file @
ac201701
...
...
@@ -9,6 +9,7 @@ import com.yeejoin.amos.maintenance.business.entity.mybatis.CheckChkExListBo;
import
com.yeejoin.amos.maintenance.business.vo.CodeOrderVo
;
import
com.yeejoin.amos.maintenance.business.vo.LeavePlanTaskVo
;
import
com.yeejoin.amos.maintenance.business.vo.PlanTaskVo
;
import
com.yeejoin.amos.maintenance.core.common.request.CommonPageable
;
import
org.springframework.data.domain.Page
;
import
com.yeejoin.amos.maintenance.business.param.CheckPtListPageParam
;
...
...
@@ -76,9 +77,10 @@ public interface IPlanTaskService {
/**
* 天剑查询假话任务信息
* @param params
* @param page
* @return
*/
Page
<
HashMap
<
String
,
Object
>>
getPlanTasks
(
String
toke
,
String
product
,
String
appKey
,
HashMap
<
String
,
Object
>
params
);
Page
<
HashMap
<
String
,
Object
>>
getPlanTasks
(
HashMap
<
String
,
Object
>
params
,
CommonPageable
page
);
/**
* 根据计划任务Id获取计划任务信息
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/util/PlanTaskPageParamUtil.java
View file @
ac201701
...
...
@@ -59,7 +59,7 @@ public class PlanTaskPageParamUtil {
for
(
int
i
=
0
;
i
<
queryRequests
.
size
();
i
++){
String
name
=
queryRequests
.
get
(
i
).
getName
();
String
type
=
queryRequests
.
get
(
i
).
getType
();
if
(
type
!=
null
&&
type
!=
""
){
if
(
type
!=
null
&&
!
""
.
equals
(
type
)
){
if
(!
QueryOperatorEnum
.
ORDER_BY
.
getName
().
equals
(
type
))
{
params
.
put
(
name
,
queryRequests
.
get
(
i
).
getValue
());
}
else
if
(
QueryOperatorEnum
.
ORDER_BY
.
getName
().
equals
(
type
))
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/core/framework/Permission.java
View file @
ac201701
...
...
@@ -6,9 +6,22 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* @author DELL
*/
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
Permission
{
/**
* value
* @return
*/
String
value
()
default
""
;
/**
* 是否进行人员校验
* @return
*/
boolean
isPersonIdentity
()
default
false
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/core/framework/PermissionAspect.java
View file @
ac201701
package
com
.
yeejoin
.
amos
.
maintenance
.
core
.
framework
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.biz.common.bo.CompanyBo
;
...
...
@@ -37,140 +17,157 @@ import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
com.yeejoin.amos.maintenance.exception.PermissionException
;
import
com.yeejoin.amos.maintenance.feign.RemoteSecurityService
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Aspect
@Component
@ResponseBody
public
class
PermissionAspect
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PermissionAspect
.
class
);
@Autowired
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
// 前置通知,在方法执行之前
@Before
(
value
=
"@annotation(com.yeejoin.amos.maintenance.core.framework.Permission)"
)
public
void
PermissionCheck
(
JoinPoint
joinPoint
)
throws
PermissionException
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
logger
.
info
(
"======开始权限校验======"
);
// 用户token
String
token
=
request
.
getHeader
(
"token"
);
token
=
ObjectUtils
.
isEmpty
(
token
)
?
request
.
getHeader
(
"X-Access-Token"
)
:
token
;
String
product
=
request
.
getHeader
(
"product"
);
String
appKey
=
request
.
getHeader
(
"appKey"
);
logger
.
info
(
"用户token:"
+
token
);
RequestContext
.
setToken
(
token
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appKey
);
if
(!
TokenOperation
.
refresh
(
token
))
{
throw
new
PermissionException
(
"登录信息失效,请重新登录"
);
}
if
(
joinPoint
.
getSignature
().
getName
().
equals
(
"saveCurCompany"
))
{
return
;
}
FeignClientResult
feignClientResult
;
AgencyUserModel
userModel
=
null
;
try
{
feignClientResult
=
Privilege
.
agencyUserClient
.
getme
();
userModel
=
(
AgencyUserModel
)
feignClientResult
.
getResult
();
}
catch
(
InnerInvokException
e
)
{
e
.
printStackTrace
();
}
String
userId
=
null
;
ReginParams
regionParam
=
new
ReginParams
();
if
(
userModel
!=
null
){
userId
=
userModel
.
getUserId
();
Map
<
Long
,
List
<
RoleModel
>>
orgRoles
=
userModel
.
getOrgRoles
();
List
<
RoleModel
>
roleModels
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
orgRoles
))
{
for
(
Map
.
Entry
<
Long
,
List
<
RoleModel
>>
entry
:
orgRoles
.
entrySet
())
{
roleModels
=
entry
.
getValue
();
break
;
}
}
ReginParams
reginParams
=
JSON
.
parseObject
(
redisTemplate
.
opsForValue
().
get
(
buildKey
(
userModel
.
getUserId
(),
token
)),
ReginParams
.
class
);
if
(
reginParams
==
null
&&
userModel
.
getCompanys
().
size
()
>
0
){
CompanyModel
companyModel
=
userModel
.
getCompanys
().
get
(
0
);
List
<
DepartmentModel
>
deptList
=
remoteSecurityService
.
getDepartmentTreeByCompanyId
(
token
,
product
,
appKey
,
companyModel
.
getSequenceNbr
().
toString
());
if
(
deptList
.
size
()
>
0
){
CompanyBo
companyBo
=
convertCompanyModelToBo
(
companyModel
);
DepartmentBo
departmentBo
=
convertDepartmentModelToBo
(
deptList
.
get
(
0
));
regionParam
.
setCompany
(
companyBo
);
regionParam
.
setDepartment
(
departmentBo
);
if
(!
ObjectUtils
.
isEmpty
(
roleModels
)){
regionParam
.
setRole
(
convertRoleModelToBo
(
roleModels
.
get
(
0
)));
}
}
else
{
if
(!
ObjectUtils
.
isEmpty
(
userModel
.
getOrgRoles
())
&&
!
ObjectUtils
.
isEmpty
(
companyModel
)
&&
userModel
.
getOrgRoles
().
get
(
companyModel
.
getSequenceNbr
()).
size
()
>
0
){
RoleModel
role
=
userModel
.
getOrgRoles
().
get
(
companyModel
.
getSequenceNbr
()).
get
(
0
);
RoleBo
roleBo
=
new
RoleBo
();
BeanUtils
.
copyProperties
(
role
,
roleBo
);
regionParam
.
setRole
(
roleBo
);
}
}
redisTemplate
.
opsForValue
().
set
(
buildKey
(
userId
,
token
),
JSONObject
.
toJSONString
(
regionParam
));
}
}
}
private
DepartmentBo
convertDepartmentModelToBo
(
DepartmentModel
departmentModel
){
DepartmentBo
departmentBo
=
new
DepartmentBo
();
if
(
departmentModel
!=
null
)
{
departmentBo
.
setCompanySeq
(
departmentModel
.
getCompanySeq
());
departmentBo
.
setDepartmentDesc
(
departmentModel
.
getDepartmentDesc
());
departmentBo
.
setDepartmentName
(
departmentModel
.
getDepartmentName
());
departmentBo
.
setLevel
(
departmentModel
.
getLevel
());
departmentBo
.
setOrgCode
(
departmentModel
.
getOrgCode
());
departmentBo
.
setParentId
(
departmentModel
.
getParentId
());
departmentBo
.
setDeptOrgCode
(
departmentModel
.
getDeptOrgCode
());
departmentBo
.
setSequenceNbr
(
departmentModel
.
getSequenceNbr
());
}
return
departmentBo
;
}
/**
* Model 转 Bo
*/
private
CompanyBo
convertCompanyModelToBo
(
CompanyModel
companyModel
){
CompanyBo
companyBo
=
new
CompanyBo
();
if
(
companyModel
!=
null
)
{
companyBo
.
setAddress
(
companyModel
.
getAddress
());
companyBo
.
setCompanyName
(
companyModel
.
getCompanyName
());
companyBo
.
setCompanyOrgCode
(
Integer
.
parseInt
(
companyModel
.
getCompanyOrgCode
().
toString
()));
companyBo
.
setEmail
(
companyModel
.
getEmail
());
companyBo
.
setLandlinePhone
(
companyModel
.
getLandlinePhone
());
companyBo
.
setLongitude
(
companyModel
.
getLongitude
());
companyBo
.
setLatitude
(
companyModel
.
getLatitude
());
companyBo
.
setLevel
(
companyModel
.
getLevel
());
companyBo
.
setOrgCode
(
companyModel
.
getOrgCode
());
companyBo
.
setSequenceNbr
(
companyModel
.
getSequenceNbr
());
companyBo
.
setParentId
(
companyModel
.
getParentId
());
}
return
companyBo
;
}
private
RoleBo
convertRoleModelToBo
(
RoleModel
roleModel
)
{
RoleBo
roleBo
=
new
RoleBo
();
if
(
roleModel
!=
null
){
roleBo
.
setRoleName
(
roleModel
.
getRoleName
());
roleBo
.
setRoleType
(
roleModel
.
getRoleType
());
roleBo
.
setSequenceNbr
(
roleModel
.
getSequenceNbr
());
}
return
roleBo
;
}
//redi缓存选择的用户信息
private
String
buildKey
(
String
userId
,
String
token
)
{
return
"region_"
+
userId
+
"_"
+
token
;
}
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PermissionAspect
.
class
);
@Autowired
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
@Before
(
value
=
"@annotation(Permission) && @annotation(permission)"
)
public
void
PermissionCheck
(
JoinPoint
joinPoint
,
Permission
permission
)
throws
PermissionException
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
logger
.
info
(
"======开始权限校验======"
);
String
token
=
request
.
getHeader
(
"token"
);
token
=
ObjectUtils
.
isEmpty
(
token
)
?
request
.
getHeader
(
"X-Access-Token"
)
:
token
;
String
product
=
request
.
getHeader
(
"product"
);
String
appKey
=
request
.
getHeader
(
"appKey"
);
RequestContext
.
setToken
(
token
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appKey
);
if
(!
TokenOperation
.
refresh
(
token
))
{
throw
new
PermissionException
(
"登录信息失效,请重新登录"
);
}
FeignClientResult
feignClientResult
;
AgencyUserModel
userModel
=
null
;
try
{
feignClientResult
=
Privilege
.
agencyUserClient
.
getme
();
userModel
=
(
AgencyUserModel
)
feignClientResult
.
getResult
();
}
catch
(
InnerInvokException
e
)
{
throw
new
PermissionException
(
"用户信息校验失败"
);
}
if
(
userModel
==
null
)
{
throw
new
PermissionException
(
"用户信息校验失败"
);
}
String
name
=
""
;
String
companyId
=
""
;
String
type
=
""
;
if
(
permission
.
isPersonIdentity
())
{
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
JSONObject
result
=
new
JSONObject
();
name
=
result
.
get
(
"name"
).
toString
();
companyId
=
result
.
get
(
"companyId"
).
toString
();
type
=
result
.
get
(
"type"
).
toString
();
}
ReginParams
regionParam
=
new
ReginParams
();
String
userId
=
userModel
.
getUserId
();
Map
<
Long
,
List
<
RoleModel
>>
orgRoles
=
userModel
.
getOrgRoles
();
ReginParams
reginParams
=
JSON
.
parseObject
(
redisTemplate
.
opsForValue
().
get
(
buildKey
(
userModel
.
getUserId
(),
token
)),
ReginParams
.
class
);
if
(
reginParams
==
null
&&
userModel
.
getCompanys
().
size
()
>
0
)
{
CompanyModel
companyModel
=
userModel
.
getCompanys
().
get
(
0
);
List
<
DepartmentModel
>
deptList
=
remoteSecurityService
.
getDepartmentTreeByCompanyId
(
token
,
product
,
appKey
,
companyModel
.
getSequenceNbr
().
toString
());
regionParam
.
setPersonIdentity
(
new
ReginParams
.
PersonIdentity
(
type
,
name
,
companyId
));
if
(
deptList
.
size
()
>
0
)
{
CompanyBo
companyBo
=
convertCompanyModelToBo
(
companyModel
);
DepartmentBo
departmentBo
=
convertDepartmentModelToBo
(
deptList
.
get
(
0
));
regionParam
.
setCompany
(
companyBo
);
regionParam
.
setDepartment
(
departmentBo
);
if
(!
ObjectUtils
.
isEmpty
(
orgRoles
)
&&
!
orgRoles
.
get
(
departmentBo
.
getSequenceNbr
()).
isEmpty
())
{
regionParam
.
setRole
(
convertRoleModelToBo
(
orgRoles
.
get
(
departmentBo
.
getSequenceNbr
()).
get
(
0
)));
}
}
else
{
if
(!
ObjectUtils
.
isEmpty
(
userModel
.
getOrgRoles
())
&&
!
ObjectUtils
.
isEmpty
(
companyModel
)
&&
userModel
.
getOrgRoles
().
get
(
companyModel
.
getSequenceNbr
()).
size
()
>
0
)
{
RoleModel
role
=
userModel
.
getOrgRoles
().
get
(
companyModel
.
getSequenceNbr
()).
get
(
0
);
RoleBo
roleBo
=
new
RoleBo
();
BeanUtils
.
copyProperties
(
role
,
roleBo
);
regionParam
.
setRole
(
roleBo
);
}
}
redisTemplate
.
opsForValue
().
set
(
buildKey
(
userId
,
token
),
JSONObject
.
toJSONString
(
regionParam
));
}
}
private
DepartmentBo
convertDepartmentModelToBo
(
DepartmentModel
departmentModel
)
{
DepartmentBo
departmentBo
=
new
DepartmentBo
();
if
(
departmentModel
!=
null
)
{
departmentBo
.
setCompanySeq
(
departmentModel
.
getCompanySeq
());
departmentBo
.
setDepartmentDesc
(
departmentModel
.
getDepartmentDesc
());
departmentBo
.
setDepartmentName
(
departmentModel
.
getDepartmentName
());
departmentBo
.
setLevel
(
departmentModel
.
getLevel
());
departmentBo
.
setOrgCode
(
departmentModel
.
getOrgCode
());
departmentBo
.
setParentId
(
departmentModel
.
getParentId
());
departmentBo
.
setDeptOrgCode
(
departmentModel
.
getDeptOrgCode
());
departmentBo
.
setSequenceNbr
(
departmentModel
.
getSequenceNbr
());
}
return
departmentBo
;
}
/**
* Model 转 Bo
*/
private
CompanyBo
convertCompanyModelToBo
(
CompanyModel
companyModel
)
{
CompanyBo
companyBo
=
new
CompanyBo
();
if
(
companyModel
!=
null
)
{
companyBo
.
setAddress
(
companyModel
.
getAddress
());
companyBo
.
setCompanyName
(
companyModel
.
getCompanyName
());
companyBo
.
setCompanyOrgCode
(
companyModel
.
getCompanyOrgCode
());
companyBo
.
setEmail
(
companyModel
.
getEmail
());
companyBo
.
setLandlinePhone
(
companyModel
.
getLandlinePhone
());
companyBo
.
setLongitude
(
companyModel
.
getLongitude
());
companyBo
.
setLatitude
(
companyModel
.
getLatitude
());
companyBo
.
setLevel
(
companyModel
.
getLevel
());
companyBo
.
setOrgCode
(
companyModel
.
getOrgCode
());
companyBo
.
setSequenceNbr
(
companyModel
.
getSequenceNbr
());
companyBo
.
setParentId
(
companyModel
.
getParentId
());
}
return
companyBo
;
}
private
RoleBo
convertRoleModelToBo
(
RoleModel
roleModel
)
{
RoleBo
roleBo
=
new
RoleBo
();
if
(
roleModel
!=
null
)
{
roleBo
.
setRoleName
(
roleModel
.
getRoleName
());
roleBo
.
setRoleType
(
roleModel
.
getRoleType
());
roleBo
.
setSequenceNbr
(
roleModel
.
getSequenceNbr
());
}
return
roleBo
;
}
/**
* redis缓存选择的用户信息
*
* @param userId userId
* @param token token
* @return String
*/
private
String
buildKey
(
String
userId
,
String
token
)
{
return
"region_"
+
userId
+
"_"
+
token
;
}
}
amos-boot-system-maintenance/src/main/resources/db/mapper/dbTemplate_plan_task.xml
View file @
ac201701
...
...
@@ -179,14 +179,13 @@
a.beginTime,
a.endTime,
a.checkDate,
a.finshNum,
a.fin
i
shNum,
a.taskPlanNum,
a.finishStatus,
a.batchNo,
a.userId executiveName,
a.userName,
a.userDept
<!-- (SELECT GROUP_CONCAT(`name`) FROM s_user where find_in_set(id,a.userId)>0 ORDER BY `id`) AS executiveName -->
FROM
(
SELECT
...
...
@@ -213,7 +212,6 @@
pt.id batchNo,
pt.route_id,
pt.point_num taskPlanNum,
pt.finish_num finshNum,
pt.user_name userName,
pt.user_dept userDept
FROM
...
...
@@ -222,20 +220,10 @@
) a
<where>
<if
test=
"userId != null and userId > 0 "
>
and find_in_set(#{userId},a.userId)>0
</if>
<if
test=
"routeId != null and userId > 0 "
>
and a.route_id = #{routeId}
</if>
<if
test=
"checkDate != null and checkDate != '' "
>
and a.beginTime
<![CDATA[<=]]>
#{checkDate} and a.endTime
<![CDATA[>=]]>
#{checkDate}
</if>
<if
test=
"finishStatus != null"
>
and a.finishStatus = #{finishStatus}
</if>
<if
test=
"orgCode != null and orgCode !=''"
>
and (a.OrgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.OrgCode= #{orgCode} )
</if>
<choose>
<when
test=
"departmentId != null and departmentId != 0 "
>
and a.userDept like concat('%', #{departmentId}, '%')
</when>
<!-- <when test="departmentId == -1 and ids != null">and a.userId in-->
<!-- <foreach item="item" collection="ids" separator="," open="(" close=")" index="index">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
<if
test=
"startTime != null and startTime != '' and endTime != null and endTime != '' "
>
AND (
...
...
@@ -256,36 +244,6 @@
AND a.endTime
<![CDATA[>=]]>
#{endTime}
)
)
</if>
<if
test=
"query != null and query != '' "
>
<if
test=
"queryType != null and queryType != 'executiveName' and queryType != 'plan' "
>
AND EXISTS (
SELECT
1
FROM
p_point pp
LEFT JOIN p_route_point rp ON rp.point_id = pp.id
LEFT JOIN p_route r ON r.id = rp.route_id
where a.route_id = r.id
<if
test=
"queryType == null or queryType == '' or queryType == 'all' "
>
AND CONCAT(pp.name, ',',r.name, ',', pp.point_no,a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
<if
test=
"queryType != null and queryType == 'route' "
>
AND r.name LIKE concat('%', #{query}, '%')
</if>
<if
test=
"queryType != null and queryType == 'point' "
>
AND CONCAT(pp.name, ',', pp.point_no) LIKE concat('%', #{query}, '%')
</if>
)
</if>
<if
test=
"queryType != null and queryType == 'executiveName' "
>
AND a.userName LIKE concat('%', #{query}, '%')
</if>
<if
test=
"queryType != null and queryType == 'plan' "
>
AND CONCAT(a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
</if>
</where>
<if
test=
"orderBy != null and orderBy != '' "
>
order by ${orderBy}
</if>
...
...
@@ -299,50 +257,17 @@
FROM
(
SELECT
pt.id planTaskId,
pt.org_code OrgCode,
p. NAME taskName,
pt. STATUS,
pt.user_id userId,
date_format(
pt.begin_time,
'%Y-%m-%d %H:%i:%s'
) beginTime,
date_format(
pt.end_time,
'%Y-%m-%d %H:%i:%s'
) endTime,
date_format( pt.check_date, '%Y-%m-%d %H:%i:%s' ) checkDate,
pt.finish_num finishNum,
pt.finish_status finishStatus,
pt.id batchNo,
pt.route_id,
pt.point_num taskPlanNum,
pt.finish_num finshNum,
pt.user_name userName,
pt.user_dept userDept
pt.id
FROM
p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id
) a
<where>
<if
test=
"userId != null and userId > 0 "
>
and find_in_set(#{userId},a.userId)>0
</if>
<if
test=
"routeId != null and userId > 0 "
>
and a.route_id = #{routeId}
</if>
<if
test=
"checkDate != null and checkDate != '' "
>
and a.beginTime
<![CDATA[<=]]>
#{checkDate} and a.endTime
<![CDATA[>=]]>
#{checkDate}
</if>
<if
test=
"finishStatus != null"
>
and a.finishStatus = #{finishStatus}
</if>
<if
test=
"orgCode != null and orgCode !=''"
>
and (a.OrgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.OrgCode= #{orgCode} )
</if>
<choose>
<when
test=
"departmentId != null and departmentId!= 0 "
>
and a.userDept like concat('%', #{departmentId}, '%')
</when>
<!-- <when test="departmentId == -1 and ids != null">and a.userId in-->
<!-- <foreach item="item" collection="ids" separator="," open="(" close=")" index="index">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
<if
test=
"startTime != null and startTime != '' and endTime != null and endTime != '' "
>
AND (
(
...
...
@@ -362,43 +287,9 @@
AND a.endTime
<![CDATA[>=]]>
#{endTime}
)
)
</if>
<if
test=
"query != null and query != '' "
>
<if
test=
"queryType != null and queryType != 'executiveName' and queryType != 'plan' "
>
AND EXISTS (
SELECT
1
FROM
p_point pp
LEFT JOIN p_route_point rp ON rp.point_id = pp.id
LEFT JOIN p_route r ON r.id = rp.route_id
where a.route_id = r.id
<if
test=
"queryType == null or queryType == '' or queryType == 'all' "
>
AND CONCAT(pp.name, ',',r.name, ',', pp.point_no,a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
<if
test=
"queryType != null and queryType == 'route' "
>
AND r.name LIKE concat('%', #{query}, '%')
</if>
<if
test=
"queryType != null and queryType == 'point' "
>
AND CONCAT(pp.name, ',', pp.point_no) LIKE concat('%', #{query}, '%')
</if>
)
</if>
<if
test=
"queryType != null and queryType == 'executiveName' "
>
AND a.userName LIKE concat('%', #{query}, '%')
</if>
<if
test=
"queryType != null and queryType == 'plan' "
>
AND CONCAT(a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
</if>
</where>
</select>
<select
id=
"queryPlanTaskById"
resultType=
"Map"
>
SELECT
a.planTaskId,
...
...
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