用户新增 age, birthday, and sex
parent
926a1fc891
commit
29d03cb87f
|
|
@ -171,5 +171,18 @@ public class UserCO extends ClientObject {
|
|||
// 入职状态
|
||||
@ApiModelProperty(value = "入职状态")
|
||||
private Integer employmentFlag;
|
||||
|
||||
|
||||
// 年龄
|
||||
@ApiModelProperty(value = "年龄")
|
||||
private Integer age;
|
||||
|
||||
//生日
|
||||
@ApiModelProperty(value = "生日")
|
||||
private String birthday;
|
||||
|
||||
// 性别
|
||||
@ApiModelProperty(value = "性别")
|
||||
private String sex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,14 @@ public class UserE extends BaseE {
|
|||
private final String defaultPassword = "Aa12345678";
|
||||
|
||||
private final String publicKey = "0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee";
|
||||
// 年龄
|
||||
private Integer age;
|
||||
|
||||
//生日
|
||||
private String birthday;
|
||||
|
||||
// 性别
|
||||
private String sex;
|
||||
|
||||
|
||||
public void initAdd(Long tenantId, UserE userE) {
|
||||
|
|
@ -144,7 +152,7 @@ public class UserE extends BaseE {
|
|||
userE.setTenantId(!ObjectUtils.isEmpty(userE.getTenantId())? userE.getTenantId() : tenantId);
|
||||
userE.setCorpinfoId(!ObjectUtils.isEmpty(userE.getCorpinfoId())? userE.getCorpinfoId() : tenantId);
|
||||
userE.setEmploymentFlag(1);
|
||||
userE.setPassword("Aa@123456789");
|
||||
userE.setPassword(defaultPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,284 @@
|
|||
package com.zcloud.basic.info.domain.utils;
|
||||
|
||||
|
||||
import com.jcraft.jsch.*;
|
||||
import com.zcloud.gbscommon.utils.Tools;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author zhangyue
|
||||
* @date 2025/10/31 16:08
|
||||
*/
|
||||
@Configuration
|
||||
|
||||
public class Smb {
|
||||
|
||||
|
||||
public static String host;
|
||||
public static Integer port;
|
||||
public static String user;
|
||||
public static String password;
|
||||
public static String basePath;
|
||||
|
||||
@Value("${smb.host}")
|
||||
public void setHostPath(String hostProperties) {
|
||||
host = hostProperties;
|
||||
}
|
||||
|
||||
@Value("${smb.port}")
|
||||
public void setPortPath(Integer portProperties) {
|
||||
port = portProperties;
|
||||
}
|
||||
|
||||
@Value("${smb.user}")
|
||||
public void setUserPath(String userProperties) {
|
||||
user = userProperties;
|
||||
}
|
||||
|
||||
@Value("${smb.password}")
|
||||
public void setPasswordPath(String passwordProperties) {
|
||||
password = passwordProperties;
|
||||
}
|
||||
|
||||
@Value("${smb.basePath}")
|
||||
public void setBasePath(String basePathProperties) {
|
||||
basePath = basePathProperties;
|
||||
}
|
||||
|
||||
|
||||
public static void sshSftp(MultipartFile file, String fileName, String path) throws Exception {
|
||||
System.out.println("开始上传文件...--------------------");
|
||||
Session session = null;
|
||||
Channel channel = null;
|
||||
JSch jsch = new JSch();
|
||||
if (port <= 0) {
|
||||
// 连接服务器,采用默认端口
|
||||
session = jsch.getSession(user, host);
|
||||
} else {
|
||||
// 采用指定的端口连接服务器
|
||||
session = jsch.getSession(user, host, port);
|
||||
}
|
||||
|
||||
// 如果服务器连接不上,则抛出异常
|
||||
if (session == null) {
|
||||
throw new Exception("session is null");
|
||||
}
|
||||
// 设置登陆主机的密码
|
||||
session.setPassword(password);
|
||||
// 设置第一次登陆的时候提示,可选值:(ask | yes | no)
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
// 设置登陆超时时间
|
||||
session.connect(30000);
|
||||
OutputStream outstream = null;
|
||||
|
||||
try {
|
||||
// 创建sftp通信通道
|
||||
channel = (Channel) session.openChannel("sftp");
|
||||
channel.connect(1000);
|
||||
ChannelSftp sftp = (ChannelSftp) channel;
|
||||
// 进入服务器指定的文件夹
|
||||
// File dir = new File(basePath+"/"+path);
|
||||
// dir.setWritable(true, false);
|
||||
// if(!dir.exists()){
|
||||
// dir.mkdirs();
|
||||
// }
|
||||
createDir(basePath + path, sftp);
|
||||
sftp.cd(basePath + path);
|
||||
// 列出服务器指定的文件列表
|
||||
// Vector v = sftp.ls("*");
|
||||
// for(int i=0;i<v.size();i++){
|
||||
// System.out.println(v.get(i));
|
||||
// }
|
||||
// 以下代码实现从本地上传一个文件到服务器,如果要实现下载,对换以下流就可以了
|
||||
|
||||
sftp.put(file.getInputStream(), fileName);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关流操作
|
||||
if (outstream != null) {
|
||||
outstream.flush();
|
||||
outstream.close();
|
||||
}
|
||||
if (session != null) {
|
||||
session.disconnect();
|
||||
}
|
||||
if (channel != null) {
|
||||
channel.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sshSftpForInput(InputStream fileI, String fileName, String path) throws Exception {
|
||||
Session session = null;
|
||||
Channel channel = null;
|
||||
JSch jsch = new JSch();
|
||||
if (port <= 0) {
|
||||
// 连接服务器,采用默认端口
|
||||
session = jsch.getSession(user, host);
|
||||
} else {
|
||||
// 采用指定的端口连接服务器
|
||||
session = jsch.getSession(user, host, port);
|
||||
}
|
||||
|
||||
// 如果服务器连接不上,则抛出异常
|
||||
if (session == null) {
|
||||
throw new Exception("session is null");
|
||||
}
|
||||
// 设置登陆主机的密码
|
||||
session.setPassword(password);
|
||||
// 设置第一次登陆的时候提示,可选值:(ask | yes | no)
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
// 设置登陆超时时间
|
||||
session.connect(30000);
|
||||
OutputStream outstream = null;
|
||||
|
||||
try {
|
||||
// 创建sftp通信通道
|
||||
channel = (Channel) session.openChannel("sftp");
|
||||
channel.connect(1000);
|
||||
ChannelSftp sftp = (ChannelSftp) channel;
|
||||
// 进入服务器指定的文件夹
|
||||
// File dir = new File(basePath+"/"+path);
|
||||
// dir.setWritable(true, false);
|
||||
// if(!dir.exists()){
|
||||
// dir.mkdirs();
|
||||
// }
|
||||
createDir(basePath + path, sftp);
|
||||
sftp.cd(basePath + path);
|
||||
// 列出服务器指定的文件列表
|
||||
// Vector v = sftp.ls("*");
|
||||
// for(int i=0;i<v.size();i++){
|
||||
// System.out.println(v.get(i));
|
||||
// }
|
||||
// 以下代码实现从本地上传一个文件到服务器,如果要实现下载,对换以下流就可以了
|
||||
|
||||
sftp.put(fileI, fileName);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关流操作
|
||||
if (outstream != null) {
|
||||
outstream.flush();
|
||||
outstream.close();
|
||||
}
|
||||
if (session != null) {
|
||||
session.disconnect();
|
||||
}
|
||||
if (channel != null) {
|
||||
channel.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void createDir(String createpath, ChannelSftp sftp) {
|
||||
try {
|
||||
if (isDirExist(createpath, sftp)) {
|
||||
sftp.cd(createpath);
|
||||
}
|
||||
String pathArry[] = createpath.split("/");
|
||||
StringBuffer filePath = new StringBuffer("/");
|
||||
for (String path : pathArry) {
|
||||
if (path.equals("")) {
|
||||
continue;
|
||||
}
|
||||
filePath.append(path + "/");
|
||||
if (isDirExist(filePath.toString(), sftp)) {
|
||||
sftp.cd(filePath.toString());
|
||||
} else {
|
||||
// 建立目录
|
||||
sftp.mkdir(filePath.toString());
|
||||
// 进入并设置为当前目录
|
||||
sftp.cd(filePath.toString());
|
||||
}
|
||||
}
|
||||
sftp.cd(createpath);
|
||||
} catch (SftpException e) {
|
||||
// throw new SystemException("创建路径错误:" + createpath);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDirExist(String directory, ChannelSftp sftp) {
|
||||
boolean isDirExistFlag = false;
|
||||
try {
|
||||
SftpATTRS sftpATTRS = sftp.lstat(directory);
|
||||
isDirExistFlag = true;
|
||||
return sftpATTRS.isDir();
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().toLowerCase().equals("no such file")) {
|
||||
isDirExistFlag = false;
|
||||
}
|
||||
}
|
||||
return isDirExistFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* Rhidd
|
||||
*
|
||||
* @throws SftpException
|
||||
* @throws JSchException
|
||||
*/
|
||||
public static void deleteFile(String directoryFile) throws Exception {
|
||||
|
||||
Session session = null;
|
||||
JSch jsch = new JSch();
|
||||
if (port <= 0) {
|
||||
// 连接服务器,采用默认端口
|
||||
session = jsch.getSession(user, host);
|
||||
} else {
|
||||
// 采用指定的端口连接服务器
|
||||
session = jsch.getSession(user, host, port);
|
||||
}
|
||||
|
||||
// 如果服务器连接不上,则抛出异常
|
||||
if (session == null) {
|
||||
throw new Exception("session is null");
|
||||
}
|
||||
// 设置登陆主机的密码
|
||||
session.setPassword(password);
|
||||
// 设置第一次登陆的时候提示,可选值:(ask | yes | no)
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
// 设置登陆超时时间
|
||||
session.connect(30000);
|
||||
// 打开openChannel的sftp
|
||||
ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
|
||||
// 远程连接
|
||||
channelSftp.connect();
|
||||
// 删除文件
|
||||
try {
|
||||
Vector<ChannelSftp.LsEntry> vector = channelSftp.ls(basePath + directoryFile);
|
||||
if (vector.size() == 1) { // 文件,直接删除
|
||||
channelSftp.rm(basePath + directoryFile);
|
||||
System.out.println("4、" + directoryFile + " 删除的文件.....");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
// 切断远程连接
|
||||
channelSftp.exit();
|
||||
|
||||
}
|
||||
|
||||
// public String saveFile(MultipartFile multipartFile) throws Exception{
|
||||
// return this.saveFile(multipartFile,Const.FILEPATHFILE);
|
||||
// }
|
||||
|
||||
public static String saveFile(MultipartFile file, String filePath) throws Exception{
|
||||
// 生成文件名
|
||||
String fileName = Tools.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
// 根据项目类型生成项目文件
|
||||
sshSftp(file, fileName, filePath);
|
||||
// 返回文件保存目录
|
||||
return filePath + "/" + fileName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -132,6 +132,23 @@ public class UserDO extends BaseDO {
|
|||
@TableField(exist = false)
|
||||
private String password;
|
||||
|
||||
// 年龄
|
||||
@ApiModelProperty(value = "年龄")
|
||||
@TableField(exist = false)
|
||||
private Integer age;
|
||||
|
||||
//生日
|
||||
@ApiModelProperty(value = "生日")
|
||||
@TableField(exist = false)
|
||||
private String birthday;
|
||||
|
||||
// 性别
|
||||
@ApiModelProperty(value = "性别")
|
||||
@TableField(exist = false)
|
||||
private String sex;
|
||||
|
||||
|
||||
|
||||
public UserDO(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,8 +109,6 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
|
||||
@Override
|
||||
public UserDO getInfoById(Long id) {
|
||||
UserDO d = userMapper.getInfoById(id);
|
||||
System.out.println("getInfoById");
|
||||
return userMapper.getInfoById(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,20 @@
|
|||
u.political_affiliation_name,
|
||||
u.employment_flag,
|
||||
CASE
|
||||
WHEN MOD(SUBSTRING( u.user_id_card, 17, 1), 2) = 1 THEN '男'
|
||||
ELSE '女'
|
||||
END AS sex
|
||||
WHEN LENGTH(u.user_id_card) > 0
|
||||
AND MOD(SUBSTRING(u.user_id_card, 17, 1), 2) = 1 THEN
|
||||
'男'
|
||||
WHEN LENGTH(u.user_id_card) > 0
|
||||
AND MOD(SUBSTRING(u.user_id_card, 17, 1), 2) = 0 THEN
|
||||
'女'
|
||||
END AS sex,
|
||||
|
||||
CASE
|
||||
WHEN LENGTH(u.user_id_card) > 0 THEN
|
||||
(YEAR(NOW()) - SUBSTRING(u.user_id_card, 7, 4)) ELSE NULL
|
||||
END AS age,
|
||||
|
||||
cast(substring(u.user_id_card, 7, 8) AS DATE) AS birthday
|
||||
from user u
|
||||
left join corp_info c on c.id = u.corpinfo_id
|
||||
left join department d on d.id = u.department_id
|
||||
|
|
@ -129,10 +140,21 @@
|
|||
u.political_affiliation,
|
||||
u.political_affiliation_name,
|
||||
u.employment_flag,
|
||||
CASE
|
||||
WHEN MOD(SUBSTRING( u.user_id_card, 17, 1), 2) = 1 THEN '男'
|
||||
ELSE '女'
|
||||
END AS sex
|
||||
CASE
|
||||
WHEN LENGTH(u.user_id_card) > 0
|
||||
AND MOD(SUBSTRING(u.user_id_card, 17, 1), 2) = 1 THEN
|
||||
'男'
|
||||
WHEN LENGTH(u.user_id_card) > 0
|
||||
AND MOD(SUBSTRING(u.user_id_card, 17, 1), 2) = 0 THEN
|
||||
'女'
|
||||
END AS sex,
|
||||
|
||||
CASE
|
||||
WHEN LENGTH(u.user_id_card) > 0 THEN
|
||||
(YEAR(NOW()) - SUBSTRING(u.user_id_card, 7, 4)) ELSE NULL
|
||||
END AS age,
|
||||
|
||||
cast(substring(u.user_id_card, 7, 8) AS DATE) AS birthday
|
||||
from user u
|
||||
left join corp_info c on c.id = u.corpinfo_id
|
||||
left join department d on d.id = u.department_id
|
||||
|
|
@ -189,9 +211,20 @@
|
|||
u.political_affiliation_name,
|
||||
u.employment_flag,
|
||||
CASE
|
||||
WHEN MOD(SUBSTRING( u.user_id_card, 17, 1), 2) = 1 THEN '男'
|
||||
ELSE '女'
|
||||
END AS sex
|
||||
WHEN LENGTH(u.user_id_card) > 0
|
||||
AND MOD(SUBSTRING(u.user_id_card, 17, 1), 2) = 1 THEN
|
||||
'男'
|
||||
WHEN LENGTH(u.user_id_card) > 0
|
||||
AND MOD(SUBSTRING(u.user_id_card, 17, 1), 2) = 0 THEN
|
||||
'女'
|
||||
END AS sex,
|
||||
|
||||
CASE
|
||||
WHEN LENGTH(u.user_id_card) > 0 THEN
|
||||
(YEAR(NOW()) - SUBSTRING(u.user_id_card, 7, 4)) ELSE NULL
|
||||
END AS age,
|
||||
|
||||
cast(substring(u.user_id_card, 7, 8) AS DATE) AS birthday
|
||||
from user u
|
||||
left join corp_info c on c.id = u.corpinfo_id
|
||||
left join department d on d.id = u.department_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue