Merge remote-tracking branch 'origin/master'

This commit is contained in:
baozhipeng
2021-09-10 11:42:24 +08:00
12 changed files with 151 additions and 57 deletions
@@ -66,10 +66,12 @@ public class PayCaseCommitteeSubitemController extends JeroController<PayCaseCom
) {
QueryWrapper<PayCaseCommitteeSubitem> queryWrapper = Wrappers.query();
queryWrapper
.like(StringUtils.isNotBlank(name), "pt.name", name).or()
.like(StringUtils.isNotBlank(companyName), "pm.company_name", companyName)
.like(StringUtils.isNotBlank(fenBiaoWeiName), "pe.name", fenBiaoWeiName);
Page<PayCaseCommitteeSubitem> page = new Page<>(pageNo, pageSize);
IPage<FindByName> pageList = payCaseCommitteeSubitemService.list3(name,companyName,page, queryWrapper);
IPage<FindByName> pageList = payCaseCommitteeSubitemService.list3(page, queryWrapper);
List<FindByName> records = pageList.getRecords();
if (!CollectionUtils.isEmpty(records)) {
try {
@@ -2,10 +2,8 @@ package com.jero.data.controller;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Resource;
@@ -31,12 +29,14 @@ import com.jero.data.service.IPayFileDownloadRecordService;
import com.jero.meeting.entity.PayMeetingSituation;
import com.jero.meeting.service.IPayMeetingSituationService;
import com.jero.modules.message.handle.impl.EmailSendMsgHandle;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
@@ -77,6 +77,7 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
//拼接目录结构
StringBuffer stringBuffer;
@Autowired
private IPayFileDownloadRecordService payFileDownloadRecordService;
@@ -97,7 +98,8 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
) {
QueryWrapper<QueryFileList2> queryWrapper = QueryGenerator.initQueryWrapper(queryFileList2, req.getParameterMap());
queryWrapper.eq("pd.id",id);
List<String> tree = tree(id, 1);
queryWrapper.in("pd.id",tree);
queryWrapper.eq("pd.type",1);
queryWrapper.orderByDesc("pf.create_time");
Page<PayDataFile> page = new Page<>(pageNo, pageSize);
@@ -115,7 +117,7 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
@GetMapping(value = "/listMeeting")
@ApiImplicitParam(name = "id", value = "目录id,查询该目录下文件", dataType = "String", required = true)
public Result<?> queryPageListMeeting(
@RequestParam(name="id",required = true) String id,
@RequestParam(name="id") String id,
QueryFileListBySearch queryFileListBySearch,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@@ -134,26 +136,67 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
}
if (ObjectUtil.isNotEmpty(queryFileListBySearch.getFileName())){
queryWrapper.eq("of.file_name",queryFileListBySearch.getFileName());
queryWrapper.like("of.file_name",queryFileListBySearch.getFileName());
}
if (ObjectUtil.isNotEmpty(queryFileListBySearch.getMeetingName())){
queryWrapper.eq("pm.meeting_name",queryFileListBySearch.getMeetingName());
queryWrapper.like("pm.meeting_name",queryFileListBySearch.getMeetingName());
}
Page<PayDataFile> page = new Page<>(pageNo, pageSize);
queryWrapper.eq("pd.type",2);
queryWrapper.orderByDesc("pf.create_time");
queryWrapper.eq("pd.id",id);
// QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("pf.id",id);
// queryWrapper.like(StringUtils.isNotBlank(fileName),"of.fileName",fileName);
// queryWrapper.like(StringUtils.isNotBlank(meetingName),"of.fileName",meetingName);
// queryWrapper.orderByDesc("pf.create_time");
// queryWrapper.eq("pd.type",2);
// Page<PayDataFile> page = new Page<>(pageNo, pageSize);
List<String> tree = tree(id, 2);
queryWrapper.in("pd.id",tree);
IPage<QueryFileList> pageList = payDataFileService.pageDataMeeting(page,queryWrapper);
return Result.OK(pageList);
}
public List<String> tree(String id , int dataType) {
LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
QueryWrapper<PayDataDirectory> queryWrapper = new QueryWrapper();
queryWrapper.eq("type",dataType);
queryWrapper.eq("create_by",sysUser.getUsername());
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(id);
List<PayDataDirectory> list = payDataDirectoryService.list(queryWrapper);
List<DirectoryToTree> collect = list.stream()
.filter(payDataDirectory -> id.equals(payDataDirectory.getParentId()))
.map(payDataDirectory -> {
arrayList.add(payDataDirectory.getId());
DirectoryToTree directoryToTree = transtoTree(payDataDirectory, list,arrayList);
return directoryToTree;
}).sorted(Comparator.comparing(DirectoryToTree::getSort))
.collect(Collectors.toList());
return arrayList;
}
/**
* 转换为树
* @param payDataDirectory 单个节点用于查找其子节点
* @param list 所以节点集合
* @return
*/
private DirectoryToTree transtoTree(PayDataDirectory payDataDirectory, List<PayDataDirectory> list,List<String> arrayList) {
DirectoryToTree directoryToTree = new DirectoryToTree();
BeanUtils.copyProperties(payDataDirectory, directoryToTree);
List<PayDataDirectory> collect = list.stream()
.filter(payDataDirectory1 -> payDataDirectory.getId().equals(payDataDirectory1.getParentId()))
.map(
payDataDirectory2 -> {
arrayList.add(payDataDirectory2.getId());
DirectoryToTree directoryToTree1 = transtoTree(payDataDirectory2, list, arrayList);
return directoryToTree;
}
).sorted(Comparator.comparing(PayDataDirectory::getSort))
.collect(Collectors.toList());
directoryToTree.setChildren(collect);
return directoryToTree;
}
/**
* 资料列表上传
*
@@ -224,6 +267,7 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
iossFileService.removeById(oldFileId);
payDataFileService.removeById(keyId);
ArrayList<String> fileIdList = new ArrayList<>(Arrays.asList(fileIds.split(",")));
fileIdList.remove(oldFileId);
ArrayList<PayDataFile> list = new ArrayList<>();
stringBuffer = new StringBuffer();
findToTree(dataId, dataType);
@@ -439,11 +483,16 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
*/
@AutoLog(value = "导出下载")
@ApiOperation(value="导出下载", notes="导出下载")
@ApiImplicitParam(name = "fileNames", value = "文件名称,多个以逗号隔开")
@ApiImplicitParam(name = "ids", value = "文件id,多个以逗号隔开")
@GetMapping(value = "/importFile")
public void importFile(@RequestParam(name="fileNames",required = true) String fileNames) {
ArrayList<String> fileIdList = new ArrayList<>(Arrays.asList(fileNames.split(",")));
zipFileDownload(fileIdList);
public void importFile(@RequestParam(name="ids",required = true) String ids) {
ArrayList<String> fileIdList = new ArrayList<>(Arrays.asList(ids.split(",")));
ArrayList<String> objects = new ArrayList<>();
for(String id :fileIdList){
OSSFile byId = iossFileService.getById(id);
objects.add(byId.getFileName());
}
zipFileDownload(objects);
}
@@ -481,10 +530,10 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
zipos.setMethod(ZipOutputStream.DEFLATED); //设置压缩方法
for (String path : paths){
File file = new File(upLoadPath + "\\" + path + ".pdf");
File file = new File(upLoadPath + "\\" + path);
if(file.exists()){
try {
//添加ZipEntry,并ZipEntry中写入文件流
//添加ZipEntry,并ZipEntry中写入文件流w
//这里,防止要下载的文件有重名的导致下载失败
zipos.putNextEntry(new ZipEntry("folder/"+ file.getName()));
os = new DataOutputStream(zipos);
@@ -4,6 +4,7 @@ import java.io.*;
import java.util.Arrays;
import java.util.List;
import javax.activation.MimetypesFileTypeMap;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -20,6 +21,8 @@ import com.jero.data.entity.PayCaseCommitteeSubitem;
import com.jero.data.entity.PayDistributionRecord;
import com.jero.data.entity.PayFileDownloadRecord;
import com.jero.data.service.IPayFileDownloadRecordService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -47,6 +50,9 @@ public class PayFileDownloadRecordController extends JeroController<PayFileDownl
@Value("${jero.path.upload}")
private String upLoadPath;
@Resource
private IOSSFileService iossFileService;
@Autowired
private IPayFileDownloadRecordService payFileDownloadRecordService;
@@ -77,19 +83,22 @@ public class PayFileDownloadRecordController extends JeroController<PayFileDownl
@ApiOperation(value="资料下载", notes="资料下载")
@GetMapping(value = "download")
public void download(
@RequestParam(name = "fileName",required = true) String filename
@RequestParam(name = "fileid",required = true) String fileid
) throws IOException {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = requestAttributes.getResponse();
OSSFile byId = iossFileService.getById(fileid);
String fileName = byId.getFileName();
// 设置信息给客户端不解析
String type = new MimetypesFileTypeMap().getContentType(filename);
String type = new MimetypesFileTypeMap().getContentType(fileName);
// 设置contenttype,即告诉客户端所发送的数据属于什么类型
response.setHeader("Content-type",type);
// 设置编码
String hehe = new String(filename.getBytes("utf-8"), "iso-8859-1");
String hehe = new String(fileName.getBytes("utf-8"), "iso-8859-1");
// 设置扩展头,当Content-Type 的类型为要下载的类型时 , 这个信息头会告诉浏览器这个文件的名字和类型。
response.setHeader("Content-Disposition", "attachment;filename=" + hehe);
download(filename, response);
download(fileName, response);
}
@@ -99,7 +108,7 @@ public class PayFileDownloadRecordController extends JeroController<PayFileDownl
byte[] buff = new byte[1024];
BufferedInputStream bis = null;
// 读取filename
bis = new BufferedInputStream(new FileInputStream(new File(upLoadPath+"\\"+filename +".pdf")));
bis = new BufferedInputStream(new FileInputStream(new File(upLoadPath+"\\"+filename)));
int i = bis.read(buff);
while (i != -1) {
outputStream.write(buff, 0, buff.length);
@@ -18,6 +18,7 @@ public class PayDataDirectoryDTO {
@ApiModelProperty(value = "名称")
private java.lang.String name;
@NotBlank(message = "排序号不能为空,不传可设置为0")
@ApiModelProperty(value = "排序号")
private java.lang.String sort;
@@ -9,7 +9,7 @@ import lombok.Data;
public class QueryFileList {
@ApiModelProperty(value = "主键id")
private java.lang.String keyid;
private java.lang.String keyId;
@ApiModelProperty(value = "资料id")
private java.lang.String dataId;
@@ -24,7 +24,7 @@ import java.util.List;
*/
public interface PayCaseCommitteeSubitemMapper extends BaseMapper<PayCaseCommitteeSubitem> {
Page<FindByName> list3 (String name,String companyName,IPage<PayCaseCommitteeSubitem> page, @Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper);
Page<FindByName> list3 (IPage<PayCaseCommitteeSubitem> page, @Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper);
List<payCaseCommitteeSubitemVO> list2 (@Param(Constants.WRAPPER) Wrapper<PayCaseCommitteeSubitem> wrapper);
@@ -4,33 +4,21 @@
<resultMap id="people" type="com.jero.data.entity.FindByName">
<id property="id" column="id"></id>
<result property="name" column="name"></result>
<collection property="list" column="id" select="list4">
<collection property="list" ofType="com.jero.data.entity.ChildrenFindByName" javaType="java.util.List">
<id property="childrenId" column="childrenId"></id>
<result property="companyName" column="companyName"></result>
<result property="post" column="post"></result>
<result property="phone" column="phone"></result>
<result property="peopleName" column="peopleName"></result>
</collection>
</resultMap>
<select id="list3" resultMap="people">
SELECT pe.id as id,pe.name as name
SELECT pe.id as id,pt.name as peopleName,pm.company_name as companyName,pt.post as post,pt.phone as phone ,pe.name as name,pm.id as childrenId
from
pay_case_committee pe
${ew.customSqlSegment}
<!-- <if test="#{fenBiaoWeiName} != null and #{fenBiaoWeiName} !=''">-->
<!-- where pe.name=#{fenBiaoWeiName}-->
<!-- </if>-->
</select>
<select id="list4" resultType="com.jero.data.entity.ChildrenFindByName">
SELECT pt.name as peopleName,pm.company_name as companyName,pt.post as post,pt.phone as phone ,pm.id as childrenId
from
pay_case_committee_subitem pm
left JOIN pay_contacts_management pt on (pm.contacts_id = pt.id) where pm.committee_id = #{id}
${wrapper2.customSqlSegment}
<where>
<if test="#{companyName} != null and #{companyName} !=''">
and pm.company_name=#{companyName}
</if>
<if test="#{name} != null and #{name} !=''">
and pt.name=#{name}
</if>
</where>
left JOIN pay_case_committee_subitem pm on (pe.id = pm.committee_id)
left JOIN pay_contacts_management pt on (pm.contacts_id = pt.id)
${ew.customSqlSegment}
</select>
@@ -16,7 +16,7 @@
</select>
<select id="pageDataMeeting" resultType="com.jero.data.entity.QueryFileList">
SELECT pf.id as keyid,
SELECT pf.id as keyId,
pf.file_id as dataId,
pf.data_id as fileId,
pf.file_path as filePath,
@@ -28,5 +28,5 @@ public interface IPayCaseCommitteeSubitemService extends IService<PayCaseCommitt
List<payCaseCommitteeSubitemVO> list2(QueryWrapper<PayCaseCommitteeSubitem> queryWrapper);
IPage<FindByName> list3(String name,String companyName,Page<PayCaseCommitteeSubitem> page, QueryWrapper<PayCaseCommitteeSubitem> queryWrapper);
IPage<FindByName> list3(Page<PayCaseCommitteeSubitem> page, QueryWrapper<PayCaseCommitteeSubitem> queryWrapper);
}
@@ -46,7 +46,7 @@ public class PayCaseCommitteeSubitemServiceImpl extends ServiceImpl<PayCaseCommi
}
@Override
public IPage<FindByName> list3(String name,String companyName,Page<PayCaseCommitteeSubitem> page, QueryWrapper<PayCaseCommitteeSubitem> queryWrapper) {
return payCaseCommitteeSubitemMapper.list3(name,companyName,page, queryWrapper);
public IPage<FindByName> list3(Page<PayCaseCommitteeSubitem> page, QueryWrapper<PayCaseCommitteeSubitem> queryWrapper) {
return payCaseCommitteeSubitemMapper.list3(page, queryWrapper);
}
}
@@ -0,0 +1,42 @@
package com.jero.util;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.RestUtil;
import org.springframework.beans.factory.annotation.Value;
/**
* @author liJiaRao
* @date 2021-09-10 9:58
*/
public class standardsUtil {
@Value("${standards.url}")
private static String url;
@Value("${standards.token}")
private static String token;
public static String getRSAPublicKey(){
JSONObject jsonObject = RestUtil.get(url + "/sys/getRSAPublicKey");
if (jsonObject.getBoolean("success")) {
return jsonObject.getString("result");
}else {
throw new JeroBootException("调用会员系统出错");
}
}
/**
* RSA 使用公钥加密token
* @param RSAPublicKey 公钥
* @return String 加密后的字符串
*/
public static String encryptByRsaPriKey(String RSAPublicKey) {
RSA rsa = new RSA(null, RSAPublicKey);
byte[] encrypt = rsa.encrypt(token, KeyType.PublicKey);
return new String(encrypt);
}
}
@@ -298,4 +298,7 @@ justauth:
type: default
prefix: 'demo::'
timeout: 1h
defaultPassword: HZWLsoft.com123
defaultPassword: HZWLsoft.com123
standards:
url: http://loaclhots:8081/api
token: Aa123456!!