Merge remote-tracking branch 'origin/master'

master
wanglei 2 years ago
commit 88d62876f2

@ -1,5 +1,6 @@
package com.da.dangan.controller;
import cn.hutool.core.util.URLUtil;
import com.da.common.annotation.Log;
import com.da.common.core.controller.BaseController;
import com.da.common.core.domain.AjaxResult;
@ -8,12 +9,23 @@ import com.da.common.enums.BusinessType;
import com.da.common.utils.poi.ExcelUtil;
import com.da.dangan.domain.DaPicturesRecard;
import com.da.dangan.service.IDaPicturesRecardService;
import org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.parallel.InputStreamSupplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* Controller
@ -25,9 +37,10 @@ import java.util.List;
@RequestMapping("/dangan/pictureRecard")
public class DaPicturesRecardController extends BaseController
{
@Autowired
private ExecutorService executorService;
@Autowired
private IDaPicturesRecardService daPicturesRecardService;
/**
*
*/
@ -53,6 +66,20 @@ public class DaPicturesRecardController extends BaseController
util.exportExcel(response, list, "档案图片信息记录数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:pictureRecard:export')")
@Log(title = "图片下载", businessType = BusinessType.EXPORT)
@PostMapping("/exportImage")
public void export2(HttpServletRequest request,HttpServletResponse response, DaPicturesRecard daPicturesRecard)
{
List<DaPicturesRecard> list = daPicturesRecardService.selectDaPicturesRecardList(daPicturesRecard);
List<String> images = list.stream().map(DaPicturesRecard ::getPicUrl).collect(Collectors.toList());
//exportImages(request,response,images,"档案图片");
exportImages1(response,images,"档案图片");
}
/**
*
*/
@ -106,4 +133,97 @@ public class DaPicturesRecardController extends BaseController
{
return daPicturesRecardService.deleteDaPicturesRecardByIds(ids);
}
/**
* 使线
*/
private void exportImages1( HttpServletResponse response, List<String> images, String name) {
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment;filename=demo.zip");
ParallelScatterZipCreator parallelScatterZipCreator = new ParallelScatterZipCreator(executorService);
try (ZipArchiveOutputStream zipArchiveOutputStream = new ZipArchiveOutputStream(response.getOutputStream())) {
zipArchiveOutputStream.setLevel(0);
images.forEach(x -> {
ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry(StringUtils.getFilename(x));
zipArchiveEntry.setMethod(ZipArchiveEntry.STORED);
InputStreamSupplier inputStreamSupplier = () -> URLUtil.getStream(URLUtil.url(x));
parallelScatterZipCreator.addArchiveEntry(zipArchiveEntry, inputStreamSupplier);
});
parallelScatterZipCreator.writeTo(zipArchiveOutputStream);
} catch (Exception e) {
e.printStackTrace();
}
}
private void exportImages(HttpServletRequest request, HttpServletResponse response, List<String> images, String name) {
//响应头的设置
response.reset();
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
//设置压缩包的名字
//解决不同浏览器压缩包名字含有中文乱码的问题
String billname ="workerCard";
String downloadName=name+".zip";
//返回客户端浏览器的版本号、类型
String agent = request.getHeader("USER-AGENT");
try {
//针对IE或者以IE为内核的浏览器处理
if (agent.contains("MSIE")||agent.contains("Trident")){
downloadName=java.net.URLEncoder.encode(downloadName, "UTF-8");
}else {
downloadName=new String(downloadName.getBytes("UTF-8"),"ISO-8859-1");
}
}catch (Exception e) {
e.printStackTrace();
}
response.setHeader("Content-Disposition","attachment;fileName=\"" + downloadName + "\"");
//设置压缩流
ZipOutputStream zip=null;
try {
zip=new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
//设置压缩方法
zip.setMethod(ZipOutputStream.DEFLATED);
} catch (IOException e) {
e.printStackTrace();
}
DataOutputStream os=null;
//从数据库中取出要下载的图片路径
for (String image : images) {
File file = new File(image);
if (file.exists()){
//添加ZipEntry并ZipEntry中写入文件流
//这里加上i是防止要下载的文件有重名的导致下载失败
try {
zip.putNextEntry(new ZipEntry(file.getName()));
os=new DataOutputStream(zip);
InputStream is = new FileInputStream(file);
byte[]b= new byte [1024];
int length =0;
while ((length=is.read(b))!=-1){
os.write(b,0,length);
}
is.close();
//zip.closeEntry();
} catch (IOException e) {
e.printStackTrace();
}
}
//关闭流
try {
if (os!=null){
os.flush();
os.close();
zip.close();
}else {
break;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@ -22,7 +22,7 @@ public class DaBirthDj extends BaseEntity
private Long id;
/** 业务类型(字典) */
@Excel(name = "业务类型(字典)")
@Excel(name = "业务类型",dictType = "yw_type")
private String ywType;
/** 目录id */
@ -107,7 +107,7 @@ public class DaBirthDj extends BaseEntity
private String jsUnit;
/** 出生登记类型(字典) */
@Excel(name = "出生登记类型(字典)")
// @Excel(name = "出生登记类型(字典)")
private String djType;
/** 识别图片id */
@ -127,11 +127,11 @@ public class DaBirthDj extends BaseEntity
private String allPics;
/** 是否纠错(字典0否1是) */
@Excel(name = "是否纠错(字典0否1是)")
@Excel(name = "是否纠错",dictType = "error_correct")
private String errorCorrect;
/** 审核状态(字典) */
@Excel(name = "审核状态(字典)")
@Excel(name = "审核状态",dictType = "audit_status")
private String auditStatus;
/** 审核人 */

@ -25,7 +25,7 @@ public class DaCzrkdj extends BaseEntity {
/**
* ()
*/
@Excel(name = "业务类型(字典)")
@Excel(name = "业务类型",dictType = "yw_type")
private String ywType;
/**
@ -267,13 +267,13 @@ public class DaCzrkdj extends BaseEntity {
/**
* (01)
*/
@Excel(name = "是否纠错(字典0否1是)")
@Excel(name = "是否纠错",dictType = "error_correct")
private String errorCorrect;
/**
* ()
*/
@Excel(name = "审核状态(字典)")
@Excel(name = "审核状态",dictType = "audit_status")
private String auditStatus;
/**

@ -19,7 +19,7 @@ public class DaQyz extends BaseEntity
private Long id;
/** 业务类型(字典) */
@Excel(name = "业务类型(字典)")
@Excel(name = "业务类型",dictType = "yw_type")
private String ywType;
/** 目录id */
@ -123,11 +123,11 @@ public class DaQyz extends BaseEntity
private String allPics;
/** 是否纠错(字典0否1是) */
@Excel(name = "是否纠错(字典0否1是)")
@Excel(name = "是否纠错",dictType = "error_correct")
private String errorCorrect;
/** 审核状态(字典) */
@Excel(name = "审核状态(字典)")
@Excel(name = "审核状态",dictType = "audit_status")
private String auditStatus;
/** 审核人 */

@ -14,382 +14,408 @@ import java.util.Date;
* @author hs
* @date 2024-06-14
*/
public class DaYtzm extends BaseEntity
{
public class DaYtzm extends BaseEntity {
private static final long serialVersionUID = 1L;
/** id */
/**
* id
*/
private Long id;
/** 业务类型(字典) */
@Excel(name = "业务类型(字典)")
/**
* ()
*/
@Excel(name = "业务类型", dictType = "yw_type")
private String ywType;
/** 目录id */
/**
* id
*/
@Excel(name = "目录id")
private Long muId;
/** 年份 */
/**
*
*/
@Excel(name = "年份")
private String year;
/** 序号 */
/**
*
*/
@Excel(name = "序号")
private String xh;
/** 姓名女 */
/**
*
*/
@Excel(name = "姓名女")
private String wName;
/** 工作单位女 */
/**
*
*/
@Excel(name = "工作单位女")
private String wUnit;
/** 身份证号女 */
/**
*
*/
@Excel(name = "身份证号女")
private String wCardId;
/** 姓名男 */
/**
*
*/
@Excel(name = "姓名男")
private String mName;
/** 工作单位男 */
/**
*
*/
@Excel(name = "工作单位男")
private String mUnit;
/** 身份证号男 */
/**
*
*/
@Excel(name = "身份证号男")
private String mCardId;
/** 生育证号 */
/**
*
*/
@Excel(name = "生育证号")
private String syzh;
/** 出生日期 */
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
/** 医院地址 */
/**
*
*/
@Excel(name = "医院地址")
private String hospital;
/** 婴儿性别 */
/**
*
*/
@Excel(name = "婴儿性别")
private String babySex;
/** 意见 */
/**
*
*/
@Excel(name = "意见")
private String suggest;
/** 派出所位置 */
/**
*
*/
@Excel(name = "派出所位置")
private String pcsAddress;
/**
1 */
/**
*
* 1
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "填表日期1", width = 30, dateFormat = "yyyy-MM-dd")
private Date tbDate1;
/**
2 */
/**
*
* 2
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "填表日期2", width = 30, dateFormat = "yyyy-MM-dd")
private Date tbDate2;
/** 识别图片id */
/**
* id
*/
@Excel(name = "识别图片id")
private String picIds;
/** 识别图片 */
/**
*
*/
@Excel(name = "识别图片")
private String pictures;
/** 相关图片id */
/**
* id
*/
@Excel(name = "相关图片id")
private String allPicIds;
/** 相关图片 */
/**
*
*/
@Excel(name = "相关图片")
private String allPics;
/** 是否纠错(字典0否1是) */
@Excel(name = "是否纠错(字典0否1是)")
/**
* (01)
*/
@Excel(name = "是否纠错",dictType = "error_correct")
private String errorCorrect;
/** 审核状态(字典) */
@Excel(name = "审核状态(字典)")
/**
* ()
*/
@Excel(name = "审核状态",dictType = "audit_status")
private String auditStatus;
/** 审核人 */
/**
*
*/
@Excel(name = "审核人")
private String auditName;
/** 审核结果 */
/**
*
*/
@Excel(name = "审核结果")
private String auditResult;
/** 审核原由 */
/**
*
*/
@Excel(name = "审核原由")
private String auditReason;
public void setId(Long id)
{
public void setId(Long id) {
this.id = id;
}
public Long getId()
{
public Long getId() {
return id;
}
public void setYwType(String ywType)
{
public void setYwType(String ywType) {
this.ywType = ywType;
}
public String getYwType()
{
public String getYwType() {
return ywType;
}
public void setMuId(Long muId)
{
public void setMuId(Long muId) {
this.muId = muId;
}
public Long getMuId()
{
public Long getMuId() {
return muId;
}
public void setYear(String year)
{
public void setYear(String year) {
this.year = year;
}
public String getYear()
{
public String getYear() {
return year;
}
public void setXh(String xh)
{
public void setXh(String xh) {
this.xh = xh;
}
public String getXh()
{
public String getXh() {
return xh;
}
public void setwName(String wName)
{
public void setwName(String wName) {
this.wName = wName;
}
public String getwName()
{
public String getwName() {
return wName;
}
public void setwUnit(String wUnit)
{
public void setwUnit(String wUnit) {
this.wUnit = wUnit;
}
public String getwUnit()
{
public String getwUnit() {
return wUnit;
}
public void setwCardId(String wCardId)
{
public void setwCardId(String wCardId) {
this.wCardId = wCardId;
}
public String getwCardId()
{
public String getwCardId() {
return wCardId;
}
public void setmName(String mName)
{
public void setmName(String mName) {
this.mName = mName;
}
public String getmName()
{
public String getmName() {
return mName;
}
public void setmUnit(String mUnit)
{
public void setmUnit(String mUnit) {
this.mUnit = mUnit;
}
public String getmUnit()
{
public String getmUnit() {
return mUnit;
}
public void setmCardId(String mCardId)
{
public void setmCardId(String mCardId) {
this.mCardId = mCardId;
}
public String getmCardId()
{
public String getmCardId() {
return mCardId;
}
public void setSyzh(String syzh)
{
public void setSyzh(String syzh) {
this.syzh = syzh;
}
public String getSyzh()
{
public String getSyzh() {
return syzh;
}
public void setBirthday(Date birthday)
{
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public Date getBirthday()
{
public Date getBirthday() {
return birthday;
}
public void setHospital(String hospital)
{
public void setHospital(String hospital) {
this.hospital = hospital;
}
public String getHospital()
{
public String getHospital() {
return hospital;
}
public void setBabySex(String babySex)
{
public void setBabySex(String babySex) {
this.babySex = babySex;
}
public String getBabySex()
{
public String getBabySex() {
return babySex;
}
public void setSuggest(String suggest)
{
public void setSuggest(String suggest) {
this.suggest = suggest;
}
public String getSuggest()
{
public String getSuggest() {
return suggest;
}
public void setPcsAddress(String pcsAddress)
{
public void setPcsAddress(String pcsAddress) {
this.pcsAddress = pcsAddress;
}
public String getPcsAddress()
{
public String getPcsAddress() {
return pcsAddress;
}
public void setTbDate1(Date tbDate1)
{
public void setTbDate1(Date tbDate1) {
this.tbDate1 = tbDate1;
}
public Date getTbDate1()
{
public Date getTbDate1() {
return tbDate1;
}
public void setTbDate2(Date tbDate2)
{
public void setTbDate2(Date tbDate2) {
this.tbDate2 = tbDate2;
}
public Date getTbDate2()
{
public Date getTbDate2() {
return tbDate2;
}
public void setPicIds(String picIds)
{
public void setPicIds(String picIds) {
this.picIds = picIds;
}
public String getPicIds()
{
public String getPicIds() {
return picIds;
}
public void setPictures(String pictures)
{
public void setPictures(String pictures) {
this.pictures = pictures;
}
public String getPictures()
{
public String getPictures() {
return pictures;
}
public void setAllPicIds(String allPicIds)
{
public void setAllPicIds(String allPicIds) {
this.allPicIds = allPicIds;
}
public String getAllPicIds()
{
public String getAllPicIds() {
return allPicIds;
}
public void setAllPics(String allPics)
{
public void setAllPics(String allPics) {
this.allPics = allPics;
}
public String getAllPics()
{
public String getAllPics() {
return allPics;
}
public void setErrorCorrect(String errorCorrect)
{
public void setErrorCorrect(String errorCorrect) {
this.errorCorrect = errorCorrect;
}
public String getErrorCorrect()
{
public String getErrorCorrect() {
return errorCorrect;
}
public void setAuditStatus(String auditStatus)
{
public void setAuditStatus(String auditStatus) {
this.auditStatus = auditStatus;
}
public String getAuditStatus()
{
public String getAuditStatus() {
return auditStatus;
}
public void setAuditName(String auditName)
{
public void setAuditName(String auditName) {
this.auditName = auditName;
}
public String getAuditName()
{
public String getAuditName() {
return auditName;
}
public void setAuditResult(String auditResult)
{
public void setAuditResult(String auditResult) {
this.auditResult = auditResult;
}
public String getAuditResult()
{
public String getAuditResult() {
return auditResult;
}
public void setAuditReason(String auditReason)
{
public void setAuditReason(String auditReason) {
this.auditReason = auditReason;
}
public String getAuditReason()
{
public String getAuditReason() {
return auditReason;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("ywType", getYwType())
.append("muId", getMuId())

@ -1,11 +1,12 @@
package com.da.dangan.domain;
import java.util.Date;
import com.da.common.annotation.Excel;
import com.da.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.da.common.annotation.Excel;
import com.da.common.core.domain.BaseEntity;
import java.util.Date;
/**
* da_zfnyhkcg
@ -21,7 +22,7 @@ public class DaZfnyhkcg extends BaseEntity
private Long id;
/** 业务类型(字典) */
@Excel(name = "业务类型(字典)")
@Excel(name = "业务类型",dictType = "yw_type")
private String ywType;
/** 目录id */
@ -134,11 +135,11 @@ public class DaZfnyhkcg extends BaseEntity
private String allPics;
/** 是否纠错(字典0否1是) */
@Excel(name = "是否纠错(字典0否1是)")
@Excel(name = "是否纠错",dictType = "error_correct")
private String errorCorrect;
/** 审核状态(字典) */
@Excel(name = "审核状态(字典)")
@Excel(name = "审核状态",dictType = "audit_status")
private String auditStatus;
/** 审核人 */

@ -22,7 +22,7 @@ public class DaZqz extends BaseEntity
private Long id;
/** 业务类型(字典) */
@Excel(name = "业务类型(字典)")
@Excel(name = "业务类型",dictType = "yw_type")
private String ywType;
/** 目录id */
@ -175,11 +175,11 @@ public class DaZqz extends BaseEntity
private String allPics;
/** 是否纠错(字典0否1是) */
@Excel(name = "是否纠错(字典0否1是)")
@Excel(name = "是否纠错",dictType = "error_correct")
private String errorCorrect;
/** 审核状态(字典) */
@Excel(name = "审核状态(字典)")
@Excel(name = "审核状态",dictType = "audit_status")
private String auditStatus;
/** 审核人 */

@ -5,9 +5,8 @@ import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.*;
/**
* 线
@ -60,4 +59,18 @@ public class ThreadPoolConfig
}
};
}
/**
* ExecutorService
*/
@Bean(name = "executorService")
protected ExecutorService executorService()
{
return new ThreadPoolExecutor(
corePoolSize,
maxPoolSize,
keepAliveSeconds,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>()
);
}
}

Loading…
Cancel
Save