Merge branch 'dev_2nd_period_test' into 'feature_dev_20221008_TODO'

# Conflicts:
#   jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/ParamsCollectManifestEOMapper.java
#   jero-boot/jero-boot-modules/src/main/java/com/jero/modules/cert/collect/mapper/xml/ParamsManifestEOMapper.xml
This commit is contained in:
787203167
2022-11-03 14:41:16 +08:00
224 changed files with 15471 additions and 3963 deletions
@@ -7,7 +7,6 @@ import com.jero.common.api.vo.Result;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.RestUtil;
import com.jero.common.util.TokenUtils;
import com.jero.common.util.oConvertUtils;
@@ -19,7 +18,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -27,12 +25,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.HandlerMapping;
@@ -41,12 +34,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -170,11 +158,11 @@ public class CommonController {
// bizPath = "";
// }
}
if(file.getOriginalFilename().length()>70){
if(file.getOriginalFilename().length()>100){
if(StringUtils.equals(cut,CutEnum.CN.getValue())){
throw new JeroBootException("文件名长度不能超过70位,请检查!");
throw new JeroBootException("文件名长度不能超过100位,请检查!");
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
throw new JeroBootException("File name length cannot exceed 70 characters, please check!");
throw new JeroBootException("File name length cannot exceed 100 characters, please check!");
}
}
// OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state,cut);
@@ -382,12 +370,13 @@ public class CommonController {
fileName = ossFile.getFileName();
response.setContentType("application/force-download");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
InputStream download = CosBootUtil.download(filePath);
File file = new File(filePath);
if(file.getName().endsWith(".pdf") || file.getName().endsWith(".PDF")){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = sdf.format(new Date());
String waterContent = userName+" "+currentTime;
InputStream download = CosBootUtil.download(filePath);
newFile = PDFUtils.PDFWatermark(download,uploadpath,file.getName(),waterContent);
inputStream = new FileInputStream(newFile.getPath());
}else{
@@ -432,6 +421,83 @@ public class CommonController {
}
}
/**
* word,excel预览 cos -pdf无水印
*
* @param id 传入文件id
* @param request
* @param response
*/
@GetMapping(value = "/downLoadFileNOMark")
public void downLoadFileNoPDFWatermarkCos(String id,HttpServletRequest request, HttpServletResponse response,String userName) {
if(StringUtils.isBlank(id)){
throw new JeroBootException("参数信息不全");
}
id = id.split("\\.")[0];
// 查询数据表数据是否存在
LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OSSFile::getId,id);
OSSFile ossFile = ossFileService.getOne(queryWrapper);
if( null == ossFile){
throw new JeroBootException("文件不存在");
}
InputStream inputStream = null;
OutputStream outputStream = null;
File newFile =null;
try {
String fileName = "";
//本地下载
String filePath = ossFile.getUrl();
if(!CosBootUtil.doesObjectExist(filePath)){
response.setStatus(404);
throw new RuntimeException("文件不存在..");
}
// 文件名称
fileName = ossFile.getFileName();
response.setContentType("application/force-download");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
File file = new File(filePath);
inputStream = CosBootUtil.download(filePath);
outputStream = response.getOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
outputStream.write(buf, 0, len);
}
response.flushBuffer();
} catch (IOException e) {
log.error("文件下载失败" + e.getMessage());
response.setStatus(404);
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
if (newFile != null) {
try {
newFile.delete();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
/**
* 文件下载
*
@@ -127,10 +127,24 @@ public class SysUserController {
public Result<IPage<SysUser>> queryPageList(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
Map<String, String[]> reqMap = req.getParameterMap();
Map<String, String[]> newReqMap = new HashMap<>();
for (String key : reqMap.keySet()){
if(!key.equals("orgCode")){
newReqMap.put(key,reqMap.get(key));
}
}
user.setOrgCode(null);
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, newReqMap);
//TODO 外部模拟登陆临时账号,列表不显示
queryWrapper.ne("username", "_reserve_user_external");
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
String[] orgCode = reqMap.get("orgCode");
if(null != orgCode && orgCode.length > 0){
List<String> orgCodeList = sysDepartService.getSubDepIdsByDepId(orgCode[0]);
orgCodeList.add(orgCode[0]);
queryWrapper.in("org_code",orgCodeList);
}
Page<SysUser> page = new Page<>(pageNo, pageSize);
IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
//批量查询用户的所属部门
@@ -1549,6 +1563,12 @@ public class SysUserController {
for (SysDepartTreeModel sdtm: departTreeModelList) {
dutList.addAll(findChildNode(sdtm));
}
SysUser admin = sysUserService.getUserByName("admin");
DepartUserTree dut = new DepartUserTree();
dut.setId(admin.getId());
dut.setName(admin.getUsername());
dut.setType("User");
dutList.add(dut);
result.setResult(dutList);
result.setSuccess(true);
return result;
@@ -157,4 +157,8 @@ public class SysAnnouncement implements Serializable {
* 发起人
*/
private java.lang.String initiator;
private java.lang.String msgContentCn;//消息的中文(不带标签)
private java.lang.String msgContentInfoCn;//消息的中文(带标签)
}
@@ -0,0 +1,64 @@
package com.jero.modules.system.enums;
public enum RoleEnum {
ADMIN_ID("R&H Manager","R&H Manager","manager","1534020391015444481",2),
MANAGER_ID("系统管理员","Administrator","admin","f6817f48af4fb3af11b9e8bf182f618b",3),
COUNTRU_CARD_MANAGE("countryCard管理员","countryCardManage","countryCardManage","1564916346120916993",4),
ENGINEERING_INTERFACE_PERSON("工程接口人","engineeringInterfacePerson","engineeringInterfacePerson","1534020084667674626",5),
ENGINEER("工程师","engineer","engineer","1534020318437208065",6),
;
String name;
String enName;
String value;
String id;
Integer order;
RoleEnum(String name, String enName, String value, String id, Integer order) {
this.name = name;
this.enName = enName;
this.value = value;
this.id = id;
this.order = order;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getEnName() {
return enName;
}
public void setEnName(String enName) {
this.enName = enName;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
}
@@ -18,6 +18,8 @@
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
<result column="document_id" property="documentId" jdbcType="VARCHAR"/>
<result column="initiator" property="initiator" jdbcType="VARCHAR"/>
<result column="msg_content_cn" property="msgContentCn" jdbcType="VARCHAR"/>
<result column="msg_content_info_cn" property="msgContentInfoCn" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryByUserId" parameterType="String" resultType="String">
@@ -43,7 +45,9 @@
sa.open_page as open_page,
sa.msg_abstract,
sa.document_id as document_id,
sa.initiator as initiator
sa.initiator as initiator,
sa.msg_content_cn as msg_content_cn,
sa.msg_content_info_cn as msg_content_info_cn
from sys_announcement_send sas
left join sys_announcement sa ON sas.annt_id = sa.id
where sa.del_flag = '0'
@@ -87,4 +87,8 @@ public class AnnouncementSendModel implements Serializable {
*/
private java.lang.String initiator;
private java.lang.String msgContentCn;//消息的中文(不带标签)
private java.lang.String msgContentInfoCn;//消息的中文(带标签)
}
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.common.api.vo.Result;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.system.vo.SysUserCacheInfo;
import com.jero.modules.system.entity.PPEmployee;
import com.jero.modules.system.entity.SysRole;
@@ -270,4 +271,22 @@ public interface ISysUserService extends IService<SysUser> {
* @return
*/
List<SysRole> queryUserRoleListInfoByUserId(String userId);
/**
* 验证当前登录用户是否是超级管理员。
* @return
*/
boolean isAdministrator();
/**
* 验证当前登录用户是否是工程接口人角色
* @return
*/
boolean isEngineeringInterfacePerson(LoginUser currentUser);
/**
* 验证当前登录用户是否是工程师角色
* @return
*/
boolean isEngineer(LoginUser currentUser);
}
@@ -1,5 +1,6 @@
package com.jero.modules.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static com.jero.modules.system.util.FindsDepartsChildrenUtil.convertSysDepartToSysDepartTreeModel;
@@ -286,7 +288,37 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
@Override
public List<String> getSubDepIdsByDepId(String departId) {
return this.baseMapper.getSubDepIdsByDepId(departId);
List<String> idList = new ArrayList<>();
if(StringUtils.isNotEmpty(departId)) {
// 查询所有部门
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
List<SysDepart> listAll = this.list(query);
List<SysDepart> result = new ArrayList<>();
// 递归查询 指定父节点下的所有子节点,包括父节点
if (CollectionUtil.isNotEmpty(listAll)) {
recursion(listAll, result, departId);
}
idList.add(departId); // 加上父节点
idList = result.stream().map(SysDepart::getId).collect(Collectors.toList());
}
return idList;
}
// 递归查询子节点
private void recursion(List<SysDepart> listAll, List<SysDepart> result, String fatherId) {
List<SysDepart> childern = listAll.stream().filter(e-> fatherId.equals(e.getParentId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(childern)) {
result.addAll(childern);
for(SysDepart depart : childern) {
recursion(listAll, result, depart.getId());
}
}
}
@Override
@@ -17,6 +17,7 @@ import com.jero.common.util.oConvertUtils;
import com.jero.modules.base.service.BaseCommonService;
import com.jero.modules.system.entity.*;
import com.jero.modules.system.enums.PPSyncEnum;
import com.jero.modules.system.enums.RoleEnum;
import com.jero.modules.system.mapper.*;
import com.jero.modules.system.model.SysUserSysDepartModel;
import com.jero.modules.system.service.ISysUserService;
@@ -24,6 +25,7 @@ import com.jero.modules.system.vo.SysUserDepVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
@@ -586,4 +588,72 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
return result;
}
/**
* 验证当前登录用户是否是超级管理员
* @return
*/
@Override
public boolean isAdministrator() {
boolean result = false;
RoleEnum administrator = RoleEnum.MANAGER_ID;
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<SysUserRole> userRoleList = this.sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, currentUser.getId())); // 查询用户所有角色
if(CollectionUtils.isNotEmpty(userRoleList)){
List<SysUserRole> userRoles = userRoleList.stream().filter(userRole -> {
boolean flag = false;
if(StringUtils.equals(userRole.getRoleId(),administrator.getId())){
flag = true;
}
return flag;
}).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(userRoles)){
result = true;
}
}
return result;
}
@Override
public boolean isEngineeringInterfacePerson(LoginUser currentUser) {
boolean result = false;
RoleEnum engineeringInterfacePerson = RoleEnum.ENGINEERING_INTERFACE_PERSON;
List<SysUserRole> userRoleList = this.sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, currentUser.getId()));
if(CollectionUtils.isNotEmpty(userRoleList)){
List<SysUserRole> userRoles = userRoleList.stream().filter(userRole -> {
boolean flag = false;
if(StringUtils.equals(userRole.getRoleId(),engineeringInterfacePerson.getId())){
flag = true;
}
return flag;
}).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(userRoles)){
result = true;
}
}
return result;
}
@Override
public boolean isEngineer(LoginUser currentUser) {
boolean result = false;
RoleEnum engineer = RoleEnum.ENGINEER;
List<SysUserRole> userRoleList = this.sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, currentUser.getId()));
if(CollectionUtils.isNotEmpty(userRoleList)){
List<SysUserRole> userRoles = userRoleList.stream().filter(userRole -> {
boolean flag = false;
if(StringUtils.equals(userRole.getRoleId(),engineer.getId())){
flag = true;
}
return flag;
}).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(userRoles)){
result = true;
}
}
return result;
}
}
@@ -17,6 +17,7 @@ import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.*;
import java.lang.reflect.Field;
@Slf4j
public class PDFUtils {
@@ -217,7 +218,10 @@ public class PDFUtils {
String path = uploadpath + File.separator + fileName;
newFilePath = path.replace(fileName, "transformation" + fileName);
reader = new PdfReader(byes);
//解密文件
Field f = PdfReader.class.getDeclaredField("ownerPasswordUsed");
f.setAccessible(true);
f.set(reader, Boolean.TRUE);
// 加完水印的文件
os = new FileOutputStream(newFilePath);
stamper = new PdfStamper(reader, os);
@@ -286,6 +290,11 @@ public class PDFUtils {
e.printStackTrace();
log.error(e.getMessage());
} catch (IllegalAccessException e) {
e.printStackTrace();
log.error(e.getMessage());
}catch (NoSuchFieldException e) {
e.printStackTrace();
} finally {
try {
stamper.close();