@ -12,9 +12,10 @@ import weaver.general.GCONST;
import weaver.general.Util ;
import java.io.File ;
import java.io.FileOutputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
import java.time.LocalDate ;
import java.util.HashMap ;
import java.util.List ;
@ -34,6 +35,7 @@ public class SzBatchExportServiceImpl extends Service implements SzBatchExportSe
if ( CollectionUtils . isEmpty ( idList ) ) {
throw new CustomizeRunTimeException ( "未选择需要下载的人员信息" ) ;
}
// 身份证复印件+日期
String zipFilename = "身份证复印件" + LocalDate . now ( ) + ".zip" ;
String outPutPath = GCONST . getRootPath ( ) + "filesystem" + File . separator + "downloadBatchTemp" ;
@ -47,7 +49,7 @@ public class SzBatchExportServiceImpl extends Service implements SzBatchExportSe
try {
RecordSet rs = new RecordSet ( ) ;
String sql = "select a.lastname ,a.workcode ,b.field0 as fileId from HrmResource a inner join cus_fielddata b on a.id =b.id and b.scopeid =3 and a.id = ? " ;
ZipOutputStream zipOutputStream = new ZipOutputStream ( new File OutputStream( outPutPath) ) ;
ZipOutputStream zipOutputStream = new ZipOutputStream ( File s. new OutputStream( Paths. get ( outPutPath) ) ) ;
byte [ ] buffer = new byte [ 1024 ] ;
for ( Long userId : idList ) {
String fileId = "" ;
@ -65,7 +67,71 @@ public class SzBatchExportServiceImpl extends Service implements SzBatchExportSe
manager . getImageFileInfoById ( Util . getIntValue ( file ) ) ;
manager . getImageFileType ( ) ;
InputStream inputStream = manager . getInputStream ( ) ;
zipOutputStream . putNextEntry ( new ZipEntry ( lastname + "-" + workcode + "(身份证)" + getFileSuffix ( manager . getImageFileName ( ) ) ) ) ;
// 姓名+工号(身份证)
zipOutputStream . putNextEntry ( new ZipEntry ( lastname + workcode + getFileSuffix ( manager . getImageFileName ( ) ) ) ) ;
int length ;
while ( ( length = inputStream . read ( buffer ) ) > 0 ) {
zipOutputStream . write ( buffer , 0 , length ) ;
}
inputStream . close ( ) ;
zipOutputStream . closeEntry ( ) ;
}
}
}
zipOutputStream . close ( ) ;
returnMap . put ( "zipFilename" , zipFilename ) ;
returnMap . put ( "outPutPath" , outPutPath ) ;
} catch ( IOException e ) {
new BaseBean ( ) . writeLog ( e ) ;
throw new CustomizeRunTimeException ( e ) ;
}
return returnMap ;
}
@Override
public Map < String , Object > downloadContractFile ( List < Long > idList ) {
Map < String , Object > returnMap = new HashMap < > ( 2 ) ;
if ( CollectionUtils . isEmpty ( idList ) ) {
throw new CustomizeRunTimeException ( "未选择需要下载的人员信息" ) ;
}
// 合同附件+日期
String zipFilename = "合同附件" + LocalDate . now ( ) + ".zip" ;
String outPutPath = GCONST . getRootPath ( ) + "filesystem" + File . separator + "downloadBatchTemp" ;
File outPut = new File ( outPutPath ) ;
if ( ! outPut . exists ( ) & & ! outPut . isDirectory ( ) ) {
outPut . mkdir ( ) ;
}
outPutPath + = File . separator + zipFilename ;
try {
RecordSet rs = new RecordSet ( ) ;
String sql = "select a.lastname ,a.workcode ,b.fj as fileId, b.htksrq from HrmResource a inner join uf_ygqdhtbd b on a.id =b.xm where b.id = ?" ;
ZipOutputStream zipOutputStream = new ZipOutputStream ( Files . newOutputStream ( Paths . get ( outPutPath ) ) ) ;
byte [ ] buffer = new byte [ 1024 ] ;
for ( Long id : idList ) {
String fileId = "" ;
String lastname = "" ;
String workcode = "" ;
String htksrq = "" ;
rs . executeQuery ( sql , id ) ;
if ( rs . next ( ) ) {
fileId = rs . getString ( "fileId" ) ;
lastname = rs . getString ( "lastname" ) ;
workcode = rs . getString ( "workcode" ) ;
htksrq = rs . getString ( "htksrq" ) ;
}
if ( StringUtils . isNotBlank ( fileId ) ) {
for ( String file : fileId . split ( "," ) ) {
ImageFileManager manager = new ImageFileManager ( ) ;
manager . getImageFileInfoById ( Util . getIntValue ( file ) ) ;
manager . getImageFileType ( ) ;
InputStream inputStream = manager . getInputStream ( ) ;
// 姓名+工号+开始日期(合同)
zipOutputStream . putNextEntry ( new ZipEntry ( lastname + workcode + htksrq + getFileSuffix ( manager . getImageFileName ( ) ) ) ) ;
int length ;
while ( ( length = inputStream . read ( buffer ) ) > 0 ) {
zipOutputStream . write ( buffer , 0 , length ) ;