Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
personnelManager
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
personnelManager
Commits
c960df7b
提交
c960df7b
authored
9月 24, 2020
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
项目完善
上级
e4bcff1b
显示空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
427 行增加
和
37 行删除
+427
-37
PersonnelmanagerApplication.java
...example/personnelmanager/PersonnelmanagerApplication.java
+13
-0
CustomJwtAuthenticationFilter.java
...on/authencation/filter/CustomJwtAuthenticationFilter.java
+17
-16
BeanConfig.java
...om/example/personnelmanager/common/config/BeanConfig.java
+13
-0
DateCenterJsonUtil.java
...ple/personnelmanager/common/utils/DateCenterJsonUtil.java
+115
-0
DateCenterUtil.java
...example/personnelmanager/common/utils/DateCenterUtil.java
+41
-0
HttpClientUtil.java
...example/personnelmanager/common/utils/HttpClientUtil.java
+64
-0
TaskExecutePool.java
...xample/personnelmanager/common/utils/TaskExecutePool.java
+30
-0
JwtController.java
...om/example/personnelmanager/controller/JwtController.java
+3
-3
PeopleController.java
...example/personnelmanager/controller/PeopleController.java
+0
-6
People.java
...main/java/com/example/personnelmanager/entity/People.java
+7
-3
PeoplePost.java
.../java/com/example/personnelmanager/entity/PeoplePost.java
+0
-1
Post.java
src/main/java/com/example/personnelmanager/entity/Post.java
+0
-1
EducationalExperienceServiceImpl.java
...anager/service/impl/EducationalExperienceServiceImpl.java
+1
-0
OrganizationNodeServiceImpl.java
...nnelmanager/service/impl/OrganizationNodeServiceImpl.java
+25
-0
PeoplePostServiceImpl.java
.../personnelmanager/service/impl/PeoplePostServiceImpl.java
+39
-4
PeopleServiceImpl.java
...mple/personnelmanager/service/impl/PeopleServiceImpl.java
+39
-1
PostServiceImpl.java
...xample/personnelmanager/service/impl/PostServiceImpl.java
+16
-1
application-prod.yml
src/main/resources/application-prod.yml
+2
-0
application.yml
src/main/resources/application.yml
+2
-1
没有找到文件。
src/main/java/com/example/personnelmanager/PersonnelmanagerApplication.java
浏览文件 @
c960df7b
package
com
.
example
.
personnelmanager
;
import
com.example.personnelmanager.common.utils.DateCenterUtil
;
import
com.example.personnelmanager.common.utils.SpringUtils
;
import
com.example.personnelmanager.dao.SimpleJpaRepositoryImpl
;
import
gnu.io.CommPortIdentifier
;
import
org.springframework.boot.SpringApplication
;
...
...
@@ -8,9 +10,11 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.springframework.data.jpa.repository.config.EnableJpaAuditing
;
import
org.springframework.data.jpa.repository.config.EnableJpaRepositories
;
import
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
...
...
@@ -32,8 +36,17 @@ import javax.persistence.EntityListeners;
@EnableJpaRepositories
(
repositoryBaseClass
=
SimpleJpaRepositoryImpl
.
class
)
public
class
PersonnelmanagerApplication
extends
SpringBootServletInitializer
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
PersonnelmanagerApplication
.
class
,
args
);
System
.
out
.
println
(
"程序运行成功"
);
DateCenterUtil
dateCenterUtil
=
SpringUtils
.
getBean
(
"dateCenterUtil"
);
dateCenterUtil
.
sendDateToCenter
();
}
@Bean
public
OpenEntityManagerInViewFilter
openEntityManagerInViewFilter
()
{
return
new
OpenEntityManagerInViewFilter
();
}
}
src/main/java/com/example/personnelmanager/common/authencation/filter/CustomJwtAuthenticationFilter.java
浏览文件 @
c960df7b
...
...
@@ -74,24 +74,25 @@ public class CustomJwtAuthenticationFilter extends
@Override
public
Authentication
attemptAuthentication
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
AuthenticationException
{
// JwtAuthencationToken authRequest ;
// User userByJwt;
// //如果请求头中没有jwt凭证的话说明不应该使用该类进行验证,直接报错
// if (!StringUtils.isEmpty(request.getHeader(JWT_KEY))) {
// //通过请求头获取jwt凭证中的用户信息
// userByJwt = getuserbyjwt(request);
// authRequest = new JwtAuthencationToken(
// userByJwt.getUsername().trim());
// //为用于验证的用户注入session信息
// setDetails(request, authRequest);
// //进行验证
// return getAuthenticationManager().authenticate(authRequest);
// } else {
// throw new GlobalException("未设置token");
// }
JwtAuthencationToken
authRequest
;
authRequest
=
new
JwtAuthencationToken
(
"admin"
);
User
userByJwt
;
//如果请求头中没有jwt凭证的话说明不应该使用该类进行验证,直接报错
if
(!
StringUtils
.
isEmpty
(
request
.
getHeader
(
JWT_KEY
)))
{
//通过请求头获取jwt凭证中的用户信息
userByJwt
=
getuserbyjwt
(
request
);
authRequest
=
new
JwtAuthencationToken
(
userByJwt
.
getUsername
().
trim
());
//为用于验证的用户注入session信息
setDetails
(
request
,
authRequest
);
//进行验证
return
getAuthenticationManager
().
authenticate
(
authRequest
);
}
else
{
throw
new
GlobalException
(
"未设置token"
);
}
//以下为测试代码
// JwtAuthencationToken authRequest ;
// authRequest = new JwtAuthencationToken("admin");
// return getAuthenticationManager().authenticate(authRequest);
}
...
...
src/main/java/com/example/personnelmanager/common/config/BeanConfig.java
浏览文件 @
c960df7b
package
com
.
example
.
personnelmanager
.
common
.
config
;
import
org.springframework.boot.web.servlet.MultipartConfigFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
javax.servlet.MultipartConfigElement
;
import
javax.validation.Validation
;
import
javax.validation.Validator
;
import
javax.validation.ValidatorFactory
;
...
...
@@ -39,4 +41,15 @@ public class BeanConfig {
return
new
BCryptPasswordEncoder
();
}
@Bean
public
MultipartConfigElement
multipartConfigElement
()
{
MultipartConfigFactory
factory
=
new
MultipartConfigFactory
();
//单个文件最大
factory
.
setMaxFileSize
(
"20480KB"
);
//KB,MB
/// 设置总上传数据总大小
factory
.
setMaxRequestSize
(
"1024000KB"
);
return
factory
.
createMultipartConfig
();
}
}
src/main/java/com/example/personnelmanager/common/utils/DateCenterJsonUtil.java
0 → 100644
浏览文件 @
c960df7b
package
com
.
example
.
personnelmanager
.
common
.
utils
;
import
com.example.personnelmanager.entity.OrganizationNode
;
import
com.example.personnelmanager.entity.People
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* @author HuangXiahao
* @version V1.0
* @class DateCenterJsonUtil
* @packageName com.example.personnelmanager.common.utils
**/
@Component
public
class
DateCenterJsonUtil
{
/**
* 将List<people>生成Json字符串
* Json结构
* {
* "tableId": 1308221225377472514,
* "primaryKeyName": "people_id",
* "data": [
* {
* "primaryKeyValue": 1,
* "dataMap": {
* "name": "黄某",
* "age": "24",
* "birthday":"2020-08-17 13:48:21",
* "delete_tag": 0 ,
* "id_card_number":"3333333333333333",
* "post_id":"39",
* "node_id":"11",
* "icon":"124.70.194.194:13245/images/009bc8c1-fc4a-46a5-a7c0-23b67e26a631.jpg"
* }
* }
* ]
* }
* @param allPeople
* @return
*/
public
String
initAllPeopleJsonStr
(
List
<
People
>
allPeople
){
JsonObject
jsonObject
=
new
JsonObject
();
jsonObject
.
addProperty
(
"tableId"
,
1308221225377472514L
);
jsonObject
.
addProperty
(
"primaryKeyName"
,
"people_id"
);
JsonArray
jsonElements
=
new
JsonArray
();
allPeople
.
forEach
(
people
->
{
JsonObject
jsonElementPeople
=
new
JsonObject
();
jsonElementPeople
.
addProperty
(
"primaryKeyValue"
,
people
.
getPeopleId
());
JsonObject
jsonElementPeopleData
=
new
JsonObject
();
jsonElementPeopleData
.
addProperty
(
"name"
,
people
.
getName
());
jsonElementPeopleData
.
addProperty
(
"age"
,
people
.
getAge
());
if
(
people
.
getBirthday
()!=
null
){
jsonElementPeopleData
.
addProperty
(
"birthday"
,
DateFormatUtil
.
DEFAULT_ON_SECOND_FORMAT
.
format
(
people
.
getBirthday
().
toEpochMilli
()));
}
if
(
people
.
getIdCardNumber
()!=
null
){
jsonElementPeopleData
.
addProperty
(
"id_card_number"
,
people
.
getIdCardNumber
());
}
if
(
people
.
getPeoplePosts
()!=
null
&&
people
.
getPeoplePosts
().
size
()>
0
){
jsonElementPeopleData
.
addProperty
(
"post_id"
,
people
.
getPeoplePosts
().
get
(
0
).
getPost
().
getPostId
());
jsonElementPeopleData
.
addProperty
(
"node_id"
,
people
.
getPeoplePosts
().
get
(
0
).
getPost
().
getOrganizationNode
().
getNodeId
());
}
jsonElementPeopleData
.
addProperty
(
"delete_tag"
,
people
.
getDeleteTag
());
jsonElementPeopleData
.
addProperty
(
"icon"
,
people
.
getIcon
());
jsonElementPeople
.
add
(
"dataMap"
,
jsonElementPeopleData
);
jsonElements
.
add
(
jsonElementPeople
);
});
jsonObject
.
add
(
"data"
,
jsonElements
);
return
jsonObject
.
toString
();
}
/**
* 将List<OrganizationNode>生成Json字符串
* Json结构
* {
* "tableId": 1308221225377472514,
* "primaryKeyName": "people_id",
* "data": [
* {
* "primaryKeyValue": 1,
* "dataMap": {
* "node_id":1
* "name": "开发部",
* "parent_node": "1",
* "delete_tag":"0",
* }
* }
* ]
* }
* @param allNode
* @return
*/
public
String
initAllOrganizationNodeJsonStr
(
List
<
OrganizationNode
>
allNode
){
JsonObject
jsonObject
=
new
JsonObject
();
jsonObject
.
addProperty
(
"tableId"
,
1308222142906638337L
);
jsonObject
.
addProperty
(
"primaryKeyName"
,
"node_id"
);
JsonArray
jsonElements
=
new
JsonArray
();
allNode
.
forEach
(
node
->
{
JsonObject
jsonElementPeople
=
new
JsonObject
();
jsonElementPeople
.
addProperty
(
"primaryKeyValue"
,
node
.
getNodeId
());
JsonObject
jsonElementPeopleData
=
new
JsonObject
();
jsonElementPeopleData
.
addProperty
(
"name"
,
node
.
getNodeName
());
jsonElementPeopleData
.
addProperty
(
"parent_node"
,
node
.
getParentNode
());
jsonElementPeopleData
.
addProperty
(
"delete_tag"
,
node
.
getDeleteTag
());
jsonElementPeople
.
add
(
"dataMap"
,
jsonElementPeopleData
);
jsonElements
.
add
(
jsonElementPeople
);
});
jsonObject
.
add
(
"data"
,
jsonElements
);
return
jsonObject
.
toString
();
}
}
src/main/java/com/example/personnelmanager/common/utils/DateCenterUtil.java
0 → 100644
浏览文件 @
c960df7b
package
com
.
example
.
personnelmanager
.
common
.
utils
;
import
com.example.personnelmanager.dao.OrganizationNodeRepository
;
import
com.example.personnelmanager.dao.PeopleRepository
;
import
com.example.personnelmanager.entity.OrganizationNode
;
import
com.example.personnelmanager.entity.People
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
/**
* @author HuangXiahao
* @version V1.0
* @class DateCenterUtil
* @packageName com.example.personnelmanager.common.utils
**/
@Component
public
class
DateCenterUtil
{
@Autowired
PeopleRepository
peopleRepository
;
@Autowired
OrganizationNodeRepository
organizationNodeRepository
;
@Autowired
HttpClientUtil
httpClientUtil
;
@Autowired
DateCenterJsonUtil
jsonUtil
;
public
void
sendDateToCenter
(){
// 将数据库中的人员数据存放到数据中心
List
<
People
>
allPeople
=
peopleRepository
.
findAll
();
httpClientUtil
.
post
(
"http://124.70.194.194:8090/opt/data"
,
jsonUtil
.
initAllPeopleJsonStr
(
allPeople
),
"utf-8"
);
// 将数据库中的部门信息存放到数据中心
List
<
OrganizationNode
>
allNode
=
organizationNodeRepository
.
findAll
();
httpClientUtil
.
post
(
"http://124.70.194.194:8090/opt/data"
,
jsonUtil
.
initAllOrganizationNodeJsonStr
(
allNode
),
"utf-8"
);
};
}
src/main/java/com/example/personnelmanager/common/utils/HttpClientUtil.java
浏览文件 @
c960df7b
...
...
@@ -105,6 +105,7 @@ public class HttpClientUtil {
return
result
;
}
public
String
delete
(
String
url
,
List
<
NameValuePair
>
param
,
String
encode
)
{
HttpDeleteWithBody
delete
=
new
HttpDeleteWithBody
(
url
);
String
result
;
...
...
@@ -234,6 +235,69 @@ public class HttpClientUtil {
return
result
;
}
public
String
put
(
String
url
,
String
param
,
String
encode
)
{
String
result
=
null
;
HttpPut
post
=
new
HttpPut
(
url
);
CloseableHttpResponse
response
=
null
;
try
{
if
(!
StringUtils
.
isEmpty
(
param
))
{
StringEntity
stringEntity
=
new
StringEntity
(
param
,
"utf-8"
);
if
(
post
.
getHeaders
(
HttpHeaders
.
CONTENT_TYPE
).
length
<
1
)
{
post
.
setHeader
(
HttpHeaders
.
CONTENT_TYPE
,
"application/json"
);
}
post
.
setEntity
(
stringEntity
);
}
CallBackThread
callBackThread
=
new
CallBackThread
(
post
);
callBackThread
.
start
();
try
{
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
response
=
callBackThread
.
response
;
if
(
response
==
null
)
{
callBackThread
.
interrupt
();
}
if
(
callBackThread
.
message
==
null
||
callBackThread
.
message
==
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
)
{
try
{
if
(
post
!=
null
)
{
post
.
abort
();
post
.
releaseConnection
();
}
if
(
response
!=
null
)
{
if
(
response
.
getEntity
()
!=
null
)
{
EntityUtils
.
consumeQuietly
(
response
.
getEntity
());
}
response
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
throw
new
NullPointerException
(
"请求接口出现错误"
);
}
else
{
result
=
ResponseEntityUtil
.
entityToString
(
response
,
encode
);
}
}
catch
(
IOException
e
){
throw
new
GlobalException
(
"请求接口出现错误"
);
}
finally
{
try
{
if
(
post
!=
null
)
{
post
.
abort
();
post
.
releaseConnection
();
}
if
(
response
!=
null
)
{
if
(
response
.
getEntity
()
!=
null
)
{
EntityUtils
.
consumeQuietly
(
response
.
getEntity
());
}
response
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
result
;
}
public
String
get
(
String
url
,
String
encode
)
{
HttpGet
get
=
new
HttpGet
(
url
);
...
...
src/main/java/com/example/personnelmanager/common/utils/TaskExecutePool.java
0 → 100644
浏览文件 @
c960df7b
package
com
.
example
.
personnelmanager
.
common
.
utils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.task.AsyncTaskExecutor
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* @program: bserver-parent
* @description: TaskExecutePool,
* @EnableAsync:开启异步处理
* @author: LiuJie
* @create: 2019-05-20 16:01
**/
@Configuration
public
class
TaskExecutePool
{
@Bean
public
ExecutorService
executorService
()
{
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
return
executorService
;
}
}
\ No newline at end of file
src/main/java/com/example/personnelmanager/controller/JwtController.java
浏览文件 @
c960df7b
...
...
@@ -46,15 +46,15 @@ public class JwtController {
try
{
saveFile
(
jsonObject
.
getString
(
"publicKey"
));
Map
result
=
new
HashMap
();
result
.
put
(
"msg"
,
"上传成功"
);
result
.
put
(
"code"
,
"200"
);
result
.
put
(
"msg"
,
"
上传成功"
);
result
.
put
(
"code"
,
200
);
logger
.
info
(
"公钥信息保存成功"
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Map
result
=
new
HashMap
();
result
.
put
(
"msg"
,
"接收签名信息失败"
);
result
.
put
(
"code"
,
"500"
);
result
.
put
(
"code"
,
500
);
result
.
put
(
"data"
,
"接收签名信息失败"
+
ExceptionMessage
.
getStackTraceInfo
(
e
));
logger
.
info
(
"公钥信息接收成功"
);
return
result
;
...
...
src/main/java/com/example/personnelmanager/controller/PeopleController.java
浏览文件 @
c960df7b
...
...
@@ -92,16 +92,10 @@ public class PeopleController {
people
.
setSex
(
sex
);
people
.
setPhone
(
phone
);
people
.
setIdCardNumber
(
idCardNumber
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
birthdayYear
=
idCardNumber
.
substring
(
6
,
10
);
String
birthdayMonth
=
idCardNumber
.
substring
(
10
,
12
);
String
birthdayDay
=
idCardNumber
.
substring
(
12
,
14
);
people
.
setBirthday
(
simpleDateFormat
.
parse
(
birthdayYear
+
birthdayMonth
+
birthdayDay
).
toInstant
());
people
.
setEntryTime
(
Instant
.
now
());
peopleService
.
addEntity
(
people
);
}
}
return
new
ResultObj
(
"成功"
);
}
...
...
src/main/java/com/example/personnelmanager/entity/People.java
浏览文件 @
c960df7b
...
...
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import
io.swagger.models.auth.In
;
import
lombok.Data
;
import
lombok.ToString
;
import
org.apache.commons.lang.builder.ToStringBuilder
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.hibernate.annotations.Where
;
...
...
@@ -26,7 +27,7 @@ import java.util.List;
@DynamicInsert
@DynamicUpdate
@Table
(
name
=
"people"
)
@ToString
(
exclude
=
{
"enterprise"
})
@ToString
(
exclude
=
{
"enterprise"
,
"certificates"
,
"peoplePosts"
,
"becomeRegularWorkerInformations"
,
"workExperiences"
,
"leaveInformations"
,
"jobTransferInformations"
,
"titles"
,
"urgents"
,
"educationalExperiences"
,
"contracts"
,
"certificates"
})
@JsonIgnoreProperties
(
value
={
"hibernateLazyInitializer"
,
"handler"
,
"fieldHandler"
,
"enterprise"
})
@EntityListeners
(
AuditingEntityListener
.
class
)
@Where
(
clause
=
"delete_tag = 0"
)
...
...
@@ -34,7 +35,7 @@ public class People {
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"people_id"
,
columnDefinition
=
"bigint comment'人员编号' "
)
@Column
(
name
=
"people_id"
,
columnDefinition
=
"bigint comment
'人员编号' "
)
private
Long
peopleId
;
@NotNull
(
groups
=
{
GroupSave
.
class
},
message
=
"姓名不能为空"
)
...
...
@@ -200,5 +201,8 @@ public class People {
return
0.00
;
}
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
);
}
}
src/main/java/com/example/personnelmanager/entity/PeoplePost.java
浏览文件 @
c960df7b
...
...
@@ -9,7 +9,6 @@ import lombok.Data;
import
lombok.ToString
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
javax.persistence.*
;
...
...
src/main/java/com/example/personnelmanager/entity/Post.java
浏览文件 @
c960df7b
...
...
@@ -25,7 +25,6 @@ import java.time.Instant;
@Table
(
name
=
"post"
)
@JsonIgnoreProperties
(
value
={
"hibernateLazyInitializer"
,
"handler"
,
"fieldHandler"
,
"enterprise"
,
"organizationNode.posts"
})
@EntityListeners
(
AuditingEntityListener
.
class
)
@Where
(
clause
=
"delete_tag = 0"
)
public
class
Post
{
@Id
...
...
src/main/java/com/example/personnelmanager/service/impl/EducationalExperienceServiceImpl.java
浏览文件 @
c960df7b
...
...
@@ -35,6 +35,7 @@ public class EducationalExperienceServiceImpl implements EducationalExperienceSe
@Override
public
EducationalExperience
addEntity
(
EducationalExperience
educationalExperience
)
{
UserDetail
userDetails
=
AuthenticationUtils
.
getAuthentication
();
educationalExperience
.
setEnterprise
(
userDetails
.
getEnterprise
());
EducationalExperience
save
=
educationalExperienceRepository
.
save
(
educationalExperience
);
return
save
;
}
...
...
src/main/java/com/example/personnelmanager/service/impl/OrganizationNodeServiceImpl.java
浏览文件 @
c960df7b
...
...
@@ -2,6 +2,8 @@ package com.example.personnelmanager.service.impl;
import
com.example.personnelmanager.common.exception.GlobalException
;
import
com.example.personnelmanager.common.utils.AuthenticationUtils
;
import
com.example.personnelmanager.common.utils.DateCenterJsonUtil
;
import
com.example.personnelmanager.common.utils.HttpClientUtil
;
import
com.example.personnelmanager.dao.OrganizationNodeRepository
;
import
com.example.personnelmanager.dao.PostRepository
;
import
com.example.personnelmanager.entity.OrganizationNode
;
...
...
@@ -20,6 +22,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
java.util.concurrent.ExecutorService
;
import
java.util.function.BiConsumer
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -39,6 +42,15 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
@Autowired
PostRepository
postRepository
;
@Autowired
DateCenterJsonUtil
dateCenterJsonUtil
;
@Autowired
HttpClientUtil
httpClientUtil
;
@Autowired
ExecutorService
executorService
;
@Override
public
OrganizationNode
addEntity
(
OrganizationNode
organizationNode
)
{
UserDetail
userDetails
=
AuthenticationUtils
.
getAuthentication
();
...
...
@@ -53,6 +65,9 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
}
organizationNode
.
setEnterprise
(
userDetails
.
getEnterprise
());
OrganizationNode
save
=
organizationNodeRepository
.
save
(
organizationNode
);
executorService
.
submit
(()
->
{
httpClientUtil
.
post
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllOrganizationNodeJsonStr
(
Arrays
.
asList
(
save
)),
"utf-8"
);
});
return
save
;
}
...
...
@@ -80,6 +95,7 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
organizationNodeListVo
->
Optional
.
ofNullable
(
nodeCollect
.
get
(
organizationNodeListVo
.
getParentNode
())),
OrganizationNodeListVo:
:
addChildNode
);
return
organizationNodeListVos1
;
}
...
...
@@ -148,6 +164,10 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
}
}
OrganizationNode
after
=
organizationNodeRepository
.
save
(
organizationNode
);
//向数据中心修改旧的数据
executorService
.
submit
(()
->
{
httpClientUtil
.
put
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllOrganizationNodeJsonStr
(
Arrays
.
asList
(
after
)),
"utf-8"
);
});
return
after
;
}
...
...
@@ -170,10 +190,15 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
if
(
one
.
getParentNode
()==
0L
){
throw
new
GlobalException
(
"根结点不能被删除"
);
}
one
.
setDeleteTag
(
1
);
//删除节点以及所有子节点
organizationNodeRepository
.
deleteorganizationNode
(
id
);
//删除所有被删除节点下的岗位
postRepository
.
deletePostByNodeId
(
id
);
//向数据中心修改旧的数据
executorService
.
submit
(()
->
{
httpClientUtil
.
put
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllOrganizationNodeJsonStr
(
Arrays
.
asList
(
one
)),
"utf-8"
);
});
return
true
;
}
...
...
src/main/java/com/example/personnelmanager/service/impl/PeoplePostServiceImpl.java
浏览文件 @
c960df7b
package
com
.
example
.
personnelmanager
.
service
.
impl
;
import
com.example.personnelmanager.common.exception.GlobalException
;
import
com.example.personnelmanager.common.utils.DateCenterJsonUtil
;
import
com.example.personnelmanager.common.utils.HttpClientUtil
;
import
com.example.personnelmanager.dao.PeoplePostRepository
;
import
com.example.personnelmanager.dao.PeopleRepository
;
import
com.example.personnelmanager.entity.*
;
import
com.example.personnelmanager.entity.commonEntity.CustomPage
;
import
com.example.personnelmanager.service.JobTransferInformationService
;
...
...
@@ -12,10 +15,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.security.core.parameters.P
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.ExecutorService
;
/**
* @author HuangXiahao
...
...
@@ -29,8 +35,20 @@ import java.util.Optional;
@Service
public
class
PeoplePostServiceImpl
implements
PeoplePostService
{
@Autowired
DateCenterJsonUtil
dateCenterJsonUtil
;
@Autowired
HttpClientUtil
httpClientUtil
;
@Autowired
ExecutorService
executorService
;
final
PeoplePostRepository
peoplePostRepository
;
@Autowired
PeopleRepository
peopleRepository
;
final
JobTransferInformationService
jobTransferInformationService
;
public
PeoplePostServiceImpl
(
PeoplePostRepository
peoplePostRepository
,
JobTransferInformationService
jobTransferInformationService
)
{
...
...
@@ -40,11 +58,19 @@ public class PeoplePostServiceImpl implements PeoplePostService {
@Override
public
PeoplePost
addEntity
(
PeoplePost
peoplePost
)
{
Page
list
=
getPage
(
peoplePost
,
new
CustomPage
().
getPageable
());
//查询用的
PeoplePost
psSelect
=
new
PeoplePost
();
psSelect
.
setPeople
(
peoplePost
.
getPeople
());
Page
list
=
getPage
(
psSelect
,
new
CustomPage
().
getPageable
());
if
(
list
.
getContent
().
size
()>
0
){
throw
new
GlobalException
(
"该人员已经在该岗位上"
);
//该位置由一对多变成了一对一 由于前端时间有限 本项目没有设置VO 先不改
throw
new
GlobalException
(
"该人员已经有岗位上"
);
}
return
peoplePostRepository
.
save
(
peoplePost
);
PeoplePost
save
=
peoplePostRepository
.
save
(
peoplePost
);
executorService
.
submit
(()
->
{
httpClientUtil
.
put
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllPeopleJsonStr
(
Arrays
.
asList
(
peopleRepository
.
getOne
(
save
.
getPeople
().
getPeopleId
()))),
"utf-8"
);
});
return
save
;
}
@Override
...
...
@@ -61,7 +87,12 @@ public class PeoplePostServiceImpl implements PeoplePostService {
@Override
public
PeoplePost
update
(
PeoplePost
peoplePost
)
{
return
peoplePostRepository
.
save
(
peoplePost
);
PeoplePost
save
=
peoplePostRepository
.
save
(
peoplePost
);
executorService
.
submit
(()
->
{
httpClientUtil
.
put
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllPeopleJsonStr
(
Arrays
.
asList
(
peopleRepository
.
getOne
(
save
.
getPeople
().
getPeopleId
()))),
"utf-8"
);
});
return
save
;
}
@Override
...
...
@@ -86,8 +117,12 @@ public class PeoplePostServiceImpl implements PeoplePostService {
@Override
public
Specification
<
PeoplePost
>
specificationBuild
(
PeoplePost
peoplePost
)
{
PredicateBuilder
<
PeoplePost
>
and
=
Specifications
.
and
();
if
(
peoplePost
.
getPeople
()!=
null
){
and
.
eq
(
"people"
,
peoplePost
.
getPeople
().
getPeopleId
());
}
if
(
peoplePost
.
getPost
()!=
null
){
and
.
eq
(
"post"
,
peoplePost
.
getPost
());
}
return
and
.
build
();
}
...
...
src/main/java/com/example/personnelmanager/service/impl/PeopleServiceImpl.java
浏览文件 @
c960df7b
...
...
@@ -3,6 +3,8 @@ package com.example.personnelmanager.service.impl;
import
com.example.personnelmanager.common.exception.GlobalException
;
import
com.example.personnelmanager.common.utils.AuthenticationUtils
;
import
com.example.personnelmanager.common.utils.DateCalculationUtil
;
import
com.example.personnelmanager.common.utils.DateCenterJsonUtil
;
import
com.example.personnelmanager.common.utils.HttpClientUtil
;
import
com.example.personnelmanager.dao.PeopleRepository
;
import
com.example.personnelmanager.entity.*
;
import
com.example.personnelmanager.entity.vo.PeopleVo
;
...
...
@@ -23,9 +25,13 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.StringUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.ExecutorService
;
/**
* @author HuangXiahao
...
...
@@ -50,6 +56,15 @@ public class PeopleServiceImpl implements PeopleService {
@Autowired
BecomeRegularWorkerService
becomeRegularWorkerService
;
@Autowired
DateCenterJsonUtil
dateCenterJsonUtil
;
@Autowired
HttpClientUtil
httpClientUtil
;
@Autowired
ExecutorService
executorService
;
@Override
public
People
addEntity
(
People
people
)
{
UserDetail
userDetails
=
AuthenticationUtils
.
getAuthentication
();
...
...
@@ -64,11 +79,26 @@ public class PeopleServiceImpl implements PeopleService {
}
else
{
people
.
setJobStatus
(
"在职"
);
}
if
(
people
.
getIdCardNumber
()!=
null
){
try
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
birthdayYear
=
people
.
getIdCardNumber
().
substring
(
6
,
10
);
String
birthdayMonth
=
people
.
getIdCardNumber
().
substring
(
10
,
12
);
String
birthdayDay
=
people
.
getIdCardNumber
().
substring
(
12
,
14
);
people
.
setBirthday
(
simpleDateFormat
.
parse
(
birthdayYear
+
birthdayMonth
+
birthdayDay
).
toInstant
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
if
(
people
.
getBirthday
()!=
null
){
people
.
setAge
((
int
)
DateCalculationUtil
.
twoTimeYearCalculation
(
people
.
getBirthday
(),
Instant
.
now
()));
}
people
.
setEnterprise
(
userDetails
.
getEnterprise
());
People
save
=
peopleRepository
.
save
(
people
);
//向数据中心插入新的数据
executorService
.
submit
(()
->
{
httpClientUtil
.
post
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllPeopleJsonStr
(
Arrays
.
asList
(
save
)),
"utf-8"
);
});
return
save
;
}
...
...
@@ -98,6 +128,10 @@ public class PeopleServiceImpl implements PeopleService {
people
.
setAge
((
int
)
DateCalculationUtil
.
twoTimeYearCalculation
(
people
.
getBirthday
(),
Instant
.
now
()));
}
People
after
=
peopleRepository
.
save
(
people
);
//向数据中心修改旧的数据
executorService
.
submit
(()
->
{
httpClientUtil
.
put
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllPeopleJsonStr
(
Arrays
.
asList
(
after
)),
"utf-8"
);
});
return
after
;
}
...
...
@@ -118,7 +152,11 @@ public class PeopleServiceImpl implements PeopleService {
}
People
people
=
byId
.
get
();
people
.
setDeleteTag
(
1
);
peopleRepository
.
save
(
people
);
People
after
=
peopleRepository
.
save
(
people
);
//向数据中心修改旧的数据
executorService
.
submit
(()
->
{
httpClientUtil
.
put
(
"http://124.70.194.194:8090/opt/data"
,
dateCenterJsonUtil
.
initAllPeopleJsonStr
(
Arrays
.
asList
(
after
)),
"utf-8"
);
});
return
true
;
}
...
...
src/main/java/com/example/personnelmanager/service/impl/PostServiceImpl.java
浏览文件 @
c960df7b
...
...
@@ -4,10 +4,12 @@ import com.example.personnelmanager.common.exception.GlobalException;
import
com.example.personnelmanager.common.utils.AuthenticationUtils
;
import
com.example.personnelmanager.dao.PostRepository
;
import
com.example.personnelmanager.entity.OrganizationNode
;
import
com.example.personnelmanager.entity.PeoplePost
;
import
com.example.personnelmanager.entity.Post
;
import
com.example.personnelmanager.entity.UserDetail
;
import
com.example.personnelmanager.entity.vo.PostVo
;
import
com.example.personnelmanager.service.OrganizationNodeService
;
import
com.example.personnelmanager.service.PeoplePostService
;
import
com.example.personnelmanager.service.PostService
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
...
...
@@ -15,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.security.core.parameters.P
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
...
...
@@ -39,6 +43,9 @@ public class PostServiceImpl implements PostService {
@Autowired
OrganizationNodeService
organizationNodeService
;
@Autowired
PeoplePostService
peoplePostService
;
@Override
public
Post
addEntity
(
Post
post
)
{
UserDetail
userDetails
=
AuthenticationUtils
.
getAuthentication
();
...
...
@@ -90,13 +97,21 @@ public class PostServiceImpl implements PostService {
}
@Override
@Transactional
public
Boolean
delete
(
Long
id
)
{
Optional
<
Post
>
byId
=
postRepository
.
findById
(
id
);
if
(!
byId
.
isPresent
())
{
throw
new
GlobalException
(
"不存在需要被删除的
工作地点
"
);
throw
new
GlobalException
(
"不存在需要被删除的
岗位
"
);
}
Post
post
=
byId
.
get
();
post
.
setDeleteTag
(
1
);
//构建查询条件
PeoplePost
peoplePost
=
new
PeoplePost
();
peoplePost
.
setPost
(
post
);
List
<
PeoplePost
>
list
=
peoplePostService
.
getList
(
peoplePost
);
list
.
forEach
(
p
->{
peoplePostService
.
delete
(
p
.
getId
());
});
postRepository
.
save
(
post
);
return
true
;
}
...
...
src/main/resources/application-prod.yml
浏览文件 @
c960df7b
...
...
@@ -7,6 +7,8 @@ file:
imagePath
:
/opt/jar/workbench/personnel/image/
otherDir
:
/opt/jar/workbench/personnel/other/
jwtFilePath
:
/opt/jar/workbench/personnel/other/rsa
server
:
serverAddress
:
124.70.194.194:${server.port}
center
:
ip
:
124.70.194.194
...
...
src/main/resources/application.yml
浏览文件 @
c960df7b
...
...
@@ -9,6 +9,7 @@ spring:
active
:
prod
datasource
:
url
:
jdbc:mysql://124.70.194.194:3306/PersonnelManager?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8
# url: jdbc:mysql://124.70.194.194:3306/personnelManagerTest?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8
password
:
root
username
:
canal
driver-class-name
:
com.mysql.jdbc.Driver
...
...
@@ -23,7 +24,7 @@ spring:
database
:
mysql
properties
:
hibernate
:
enable_lazy_load_no_trans
=true:jooq
:
enable_lazy_load_no_trans
:
true
sql-dialect
:
MySQL5Dialect
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论