@ -15,15 +15,15 @@ import com.zdxt.common.util.IdCardCryptoUtil;
import com.zdxt.common.util.TableDataInfo ;
import com.zdxt.common.util.TableDataInfo ;
import com.zdxt.domain.auth.Dept ;
import com.zdxt.domain.auth.Dept ;
import com.zdxt.domain.auth.User ;
import com.zdxt.domain.auth.User ;
import org.apache.poi.hssf.usermodel.* ;
import org.apache.shiro.authz.annotation.RequiresPermissions ;
import org.apache.shiro.authz.annotation.RequiresPermissions ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Controller ;
import org.springframework.stereotype.Controller ;
import org.springframework.ui.Model ;
import org.springframework.ui.Model ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.* ;
import org.springframework.web.bind.annotation.PostMapping ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.ResponseBody ;
import javax.servlet.http.HttpServletResponse ;
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Map ;
@ -114,6 +114,44 @@ public class DeptStaticController extends BaseController {
//list=users;
//list=users;
return getDataTable ( zfryjdm2405301List ) ;
return getDataTable ( zfryjdm2405301List ) ;
}
}
@PostMapping ( "/export" )
@ResponseBody
public void exportDept ( HttpServletResponse httpServletResponse , @RequestBody Zfryjdm2405301 zfryjdm2405301 ) throws IOException {
List < Zfryjdm2405301 > zfryjdm2405301List = iZfryjdm2405301Service . selectZfryjdmList2 ( zfryjdm2405301 ) ;
for ( int i = 0 ; i < zfryjdm2405301List . size ( ) ; i + + ) {
if ( zfryjdm2405301List . get ( i ) . getPhoneNumber ( ) ! = null & & ! "" . equals ( zfryjdm2405301List . get ( i ) . getPhoneNumber ( ) ) ) {
zfryjdm2405301List . get ( i ) . setPhoneNumber ( IdCardCryptoUtil . symmetricDecryptIdCard ( "VRJHzFqJpsSZhwnsKTWNspv_GZMxTWl-bgH6DyE9Ty0" , zfryjdm2405301List . get ( i ) . getPhoneNumber ( ) ) ) ;
}
}
HSSFWorkbook workbook = new HSSFWorkbook ( ) ;
HSSFSheet sheet = workbook . createSheet ( "部门统计" ) ;
//设置文件名称
String fileName = "部门统计.xls" ;
//设置表头
String [ ] headerList = { "部门名称" , "执法人员" , "执法证号" , "联系方式" } ;
HSSFRow headerRow = sheet . createRow ( 0 ) ;
for ( int i = 0 ; i < headerList . length ; i + + ) {
HSSFCell cell = headerRow . createCell ( i ) ;
HSSFRichTextString text = new HSSFRichTextString ( headerList [ i ] ) ;
cell . setCellValue ( text ) ;
}
for ( int i = 0 ; i < zfryjdm2405301List . size ( ) ; i + + ) {
HSSFRow row = sheet . createRow ( i + 1 ) ;
HSSFCell cell1 = row . createCell ( 0 ) ;
HSSFCell cell2 = row . createCell ( 1 ) ;
HSSFCell cell3 = row . createCell ( 2 ) ;
HSSFCell cell4 = row . createCell ( 3 ) ;
cell1 . setCellValue ( zfryjdm2405301List . get ( i ) . getZfdw ( ) ) ;
cell2 . setCellValue ( zfryjdm2405301List . get ( i ) . getName ( ) ) ;
cell3 . setCellValue ( zfryjdm2405301List . get ( i ) . getZfcode ( ) ) ;
cell4 . setCellValue ( zfryjdm2405301List . get ( i ) . getPhoneNumber ( ) ) ;
}
httpServletResponse . setCharacterEncoding ( "UTF-8" ) ;
httpServletResponse . setContentType ( "application/vnd.ms-excel" ) ;
httpServletResponse . setHeader ( "Content-disposition" , "attachment;filename=" + fileName ) ;
httpServletResponse . flushBuffer ( ) ;
workbook . write ( httpServletResponse . getOutputStream ( ) ) ;
workbook . close ( ) ;
}
}
}