|
@@ -31,6 +31,7 @@ import com.goafanti.order.service.OrderProjectService;
|
|
|
import com.goafanti.organization.bo.*;
|
|
import com.goafanti.organization.bo.*;
|
|
|
import com.goafanti.patent.service.PatentNewService;
|
|
import com.goafanti.patent.service.PatentNewService;
|
|
|
import groovy.transform.Synchronized;
|
|
import groovy.transform.Synchronized;
|
|
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -42,6 +43,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.mail.MessagingException;
|
|
import javax.mail.MessagingException;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -49,6 +53,8 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.zip.ZipEntry;
|
|
|
|
|
+import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@EnableAsync
|
|
@EnableAsync
|
|
@@ -1766,6 +1772,69 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void orderNewListDownload(InputOrderNewListBo in,HttpServletResponse response) {
|
|
|
|
|
+ in.setPageSize(99999);
|
|
|
|
|
+ Pagination<TOrderNewBo> pagination = orderNewList(in);
|
|
|
|
|
+ List<TOrderNewBo> list = (List<TOrderNewBo>) pagination.getList();
|
|
|
|
|
+ downloadOrderImg( list, response);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void downloadOrderImg(List<TOrderNewBo> list, HttpServletResponse response){
|
|
|
|
|
+
|
|
|
|
|
+ String downloadFileName = "";
|
|
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
|
|
+ ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
|
|
|
+ downloadFileName="订单合同数据.zip";
|
|
|
|
|
+ for (TOrderNewBo t : list) {
|
|
|
|
|
+
|
|
|
|
|
+ //防止重名码
|
|
|
|
|
+ if (t != null) {
|
|
|
|
|
+
|
|
|
|
|
+ String annexUrl = t.getContractPictureUrl();
|
|
|
|
|
+ String[] split = annexUrl.split(",");
|
|
|
|
|
+ if (split.length>0){
|
|
|
|
|
+ int index =0;
|
|
|
|
|
+ for (String s : split) {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(s)){
|
|
|
|
|
+ index++;
|
|
|
|
|
+ String url=s.replace("/profile/upload","");
|
|
|
|
|
+ url=uploadPath+url;
|
|
|
|
|
+ System.out.println(url);
|
|
|
|
|
+ File file = new File(url);
|
|
|
|
|
+ if (file.exists()){
|
|
|
|
|
+ try {
|
|
|
|
|
+ String suffix = s.substring(s.indexOf("."));
|
|
|
|
|
+ String fileName=t.getUserName()+"/"+t.getUserName()+"_"+index+suffix;
|
|
|
|
|
+ ZipEntry e = new ZipEntry(fileName);
|
|
|
|
|
+ zip.putNextEntry(e);
|
|
|
|
|
+ IOUtils.write(FileUtils.getBytes(file),zip);
|
|
|
|
|
+ zip.closeEntry();
|
|
|
|
|
+ zip.flush();
|
|
|
|
|
+ } catch (IOException e){
|
|
|
|
|
+ throw new BusinessException("文件写入压缩失败:"+e.getLocalizedMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ IOUtils.closeQuietly(zip);
|
|
|
|
|
+ try {
|
|
|
|
|
+ byte[] data = outputStream.toByteArray();
|
|
|
|
|
+ response.reset();
|
|
|
|
|
+ response.addHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
|
+ response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=\"" + java.net.URLEncoder.encode(downloadFileName, "utf-8").replaceAll("\\+", "%20") + "\"");
|
|
|
|
|
+ response.addHeader("Content-Length", "" + data.length);
|
|
|
|
|
+ response.setContentType("application/octet-stream; charset=UTF-8");
|
|
|
|
|
+ IOUtils.write(data,response.getOutputStream());
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
private TOrderNew checkDeleteSign(String orderNo) {
|
|
private TOrderNew checkDeleteSign(String orderNo) {
|
|
|
TOrderNew t=tOrderNewMapper.selectByPrimaryKey(orderNo);
|
|
TOrderNew t=tOrderNewMapper.selectByPrimaryKey(orderNo);
|
|
|
//if(t.getDeleteSign()==2) throw new BusinessException(new Error(ErrorConstants.ORDER_ALREADY_REVOKE, t.getOrderNo(),""));
|
|
//if(t.getDeleteSign()==2) throw new BusinessException(new Error(ErrorConstants.ORDER_ALREADY_REVOKE, t.getOrderNo(),""));
|