Commit 4f21b81c authored by chase's avatar chase

merge档案管理

parent df3c5b4a
...@@ -22,6 +22,7 @@ import pwc.taxtech.atms.vat.entity.FileUpload; ...@@ -22,6 +22,7 @@ import pwc.taxtech.atms.vat.entity.FileUpload;
import pwc.taxtech.atms.vat.entity.ReportFileUpload; import pwc.taxtech.atms.vat.entity.ReportFileUpload;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
...@@ -346,6 +347,76 @@ public class TaxDocumentServiceImpl { ...@@ -346,6 +347,76 @@ public class TaxDocumentServiceImpl {
} }
} }
public void downloadAllFile(HttpServletResponse response, List<Long> ids) { public void downloadAllFile(HttpServletResponse response, List<Long> ids) {
//如果只选择了一个附件,则不打包
if (null != ids &&ids.size()==1){
TaxDocumentExample example = new TaxDocumentExample();
TaxDocumentExample.Criteria criteria = example.createCriteria();
criteria.andIdIn(ids);
TaxDocument taxDocument = taxDocumentMapper.selectByExample(example).get(0);
String urlPath = taxDocument.getFilePositionUrl();
//如果url为null或空字符串而抛出异常
if (StringUtils.isBlank(urlPath)) {
throw new RuntimeException("文件url为空,id为:" + taxDocument.getId());
}
//文件名称(带后缀)
String fileName = StringUtils.isBlank(taxDocument.getFileOriginalName()) ? "未知文件(请修改后缀名).xlsx" : taxDocument.getFileOriginalName();
//获取需要下载的文件流
InputStream is = null;
BufferedInputStream in = null;
byte[] buffer = new byte[1024];
int len;
ServletOutputStream out = null;
try {
URL httpurl = new URL(URLDecoder.decode(urlPath, "UTF-8"));
HttpURLConnection httpConn = (HttpURLConnection) httpurl.openConnection();
httpConn.setDoOutput(true);// 使用 URL 连接进行输出
httpConn.setDoInput(true);// 使用 URL 连接进行输入
httpConn.setUseCaches(false);// 忽略缓存
httpConn.setRequestMethod("GET");// 设置URL请求方法
//可设置请求头
httpConn.setRequestProperty("Content-Type", "application/octet-stream");
httpConn.setRequestProperty("Connection", "Keep-Alive");// 维持长连接
httpConn.setRequestProperty("Charset", "UTF-8");
httpConn.connect();
if (httpConn.getResponseCode() >= 400) {
is = httpConn.getErrorStream();
} else {
is = httpConn.getInputStream();
}
in = new BufferedInputStream(is);
out = response.getOutputStream();
//文件流循环写入ZipOutputStream
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
} catch (IOException e) {
log.error("单个附件下载异常:"+e.getMessage());
} finally {
if (null != out){
try {
out.close();
} catch (IOException e) {
log.error("关闭输出流错误:"+e.getMessage());
}
}
if (null != is) {
try {
is.close();
} catch (IOException e) {
log.error("关闭输入流错误:"+e.getMessage());
}
}
if (null != in) {
try {
in.close();
} catch (IOException e) {
log.error("关闭缓存输入流错误:"+e.getMessage());
}
}
}
return;
}
//如果选择了多个附件
String downloadName = "多选附件.zip"; String downloadName = "多选附件.zip";
try { try {
response.setContentType("multipart/form-data"); response.setContentType("multipart/form-data");
...@@ -353,7 +424,6 @@ public class TaxDocumentServiceImpl { ...@@ -353,7 +424,6 @@ public class TaxDocumentServiceImpl {
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException("下载文件名编码时出现错误.", e); throw new RuntimeException("下载文件名编码时出现错误.", e);
} }
OutputStream outputStream = null; OutputStream outputStream = null;
ZipOutputStream zos = null; ZipOutputStream zos = null;
try { try {
......
...@@ -52,7 +52,6 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -52,7 +52,6 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
} }
private double countForTrialBalance(String revenueTypeName, List<ReportCellDataSourceDto> contain, Integer billType) { private double countForTrialBalance(String revenueTypeName, List<ReportCellDataSourceDto> contain, Integer billType) {
formulaContext.getOrganizationId();
String queryDate = formulaContext.getYear()+(formulaContext.getPeriod()<10?("0"+formulaContext.getPeriod()):(formulaContext.getPeriod()+"")); String queryDate = formulaContext.getYear()+(formulaContext.getPeriod()<10?("0"+formulaContext.getPeriod()):(formulaContext.getPeriod()+""));
RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample(); RevenueTypeMappingExample typeMappingExample = new RevenueTypeMappingExample();
typeMappingExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId()) typeMappingExample.createCriteria().andOrgIdEqualTo(formulaContext.getOrganizationId())
...@@ -69,7 +68,7 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -69,7 +68,7 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
} }
BillDetailExample billDetailExample = new BillDetailExample(); BillDetailExample billDetailExample = new BillDetailExample();
BillDetailExample.Criteria c = billDetailExample.createCriteria().andBillContentIn(contens).andProjectIdEqualTo(formulaContext.getProjectId()) BillDetailExample.Criteria c = billDetailExample.createCriteria().andBillContentIn(contens).andProjectIdEqualTo(formulaContext.getProjectId())
.andPeriodEqualTo(formulaContext.getPeriod()) .andPeriodEqualTo(Integer.valueOf(queryDate))
.andBillTypeEqualTo(BillDetailEnum.BillType.MAPPING.get(billType)); .andBillTypeEqualTo(BillDetailEnum.BillType.MAPPING.get(billType));
List<BillDetail> billDetails = SpringContextUtil.billDetailMapper.selectByExample(billDetailExample); List<BillDetail> billDetails = SpringContextUtil.billDetailMapper.selectByExample(billDetailExample);
for (BillDetail billDetail : billDetails) { for (BillDetail billDetail : billDetails) {
...@@ -78,10 +77,10 @@ public class KPSR extends FunctionBase implements FreeRefFunction { ...@@ -78,10 +77,10 @@ public class KPSR extends FunctionBase implements FreeRefFunction {
dto.setPeriod(formulaContext.getPeriod()); dto.setPeriod(formulaContext.getPeriod());
dto.setIsOnlyManualInput(Boolean.FALSE); dto.setIsOnlyManualInput(Boolean.FALSE);
dto.setName(Constant.DataSourceName.ReportDataSource); dto.setName(Constant.DataSourceName.ReportDataSource);
dto.setType(FormulaDataSourceType.TrialBalanceSource.getCode()); dto.setType(FormulaDataSourceType.Report.getCode());
contain.add(dto); contain.add(dto);
} }
return billDetails.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum(); return billDetails.stream().mapToDouble(a -> a.getBillAmount().doubleValue()).sum();
} }
......
...@@ -403,6 +403,7 @@ ...@@ -403,6 +403,7 @@
SELECT SELECT
id,file_attr, file_type id,file_attr, file_type
FROM file_types FROM file_types
WHERE status = 1
ORDER BY file_attr ORDER BY file_attr
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment