|  |  |  | 
|---|
|  |  |  | package com.doumee.core.utils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.io.IoUtil; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonInclude; | 
|---|
|  |  |  | import com.fasterxml.jackson.core.JsonProcessingException; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.fasterxml.jackson.databind.PropertyNamingStrategy; | 
|---|
|  |  |  | import io.swagger.models.auth.In; | 
|---|
|  |  |  | import org.apache.batik.util.Platform; | 
|---|
|  |  |  | import org.apache.commons.compress.archivers.zip.Zip64Mode; | 
|---|
|  |  |  | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; | 
|---|
|  |  |  | import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.io.FileInputStream; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.OutputStream; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.net.URLDecoder; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String HK_TOKEN_VALIDITY = "HK_TOKEN_VALIDITY"; | 
|---|
|  |  |  | public static final String[]  ALL_SPELL_LIST_FIRST = new String[]{"A", "B", "C", "D", "E", "F", "G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; | 
|---|
|  |  |  | public static final int ZERO = 0 ; | 
|---|
|  |  |  | public static final int SIX = 6 ; | 
|---|
|  |  |  | public static final int ONE = 1 ; | 
|---|
|  |  |  | public static final int TWO = 2 ; | 
|---|
|  |  |  | public static final String HK_PARAM ="HK_PARAM" ; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String PLATFORM ="PLATFORM" ; | 
|---|
|  |  |  | public static final String POWER_MINUTE ="POWER_MINUTE" ; | 
|---|
|  |  |  | public static final String SPECIAL_COMPANY_ID ="SPECIAL_COMPANY_ID" ; | 
|---|
|  |  |  | public static final String YW_DEVICE ="YW_DEVICE" ; | 
|---|
|  |  |  | public static final String YW_PATROL ="YW_PATROL" ; | 
|---|
|  |  |  | public static final String YW_CONTRACT_BILL ="YW_CONTRACT_BILL" ; | 
|---|
|  |  |  | public static final String YW_MATERIAL ="YW_MATERIAL" ; | 
|---|
|  |  |  | public static final String YW_PROBLEM ="YW_PROBLEM" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String RESERVATION_TOTAL_NUM ="RESERVATION_TOTAL_NUM" ; | 
|---|
|  |  |  | public static final String SIGN_IN_PLACE_LAT ="SIGN_IN_PLACE_LAT" ; | 
|---|
|  |  |  | public static final String SIGN_IN_PLACE_LNT ="SIGN_IN_PLACE_LNT" ; | 
|---|
|  |  |  | public static final String SIGN_IN_PLACE_DISTANCE ="SIGN_IN_PLACE_DISTANCE" ; | 
|---|
|  |  |  | public static final String SIGN_IN_QRCODE ="SIGN_IN_QRCODE" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //被拜访人信息校验方式(0手机号单独校验 1手机号和姓名组合校验) | 
|---|
|  |  |  | public static final String BEVISITED_USER_VALID = "BEVISITED_USER_VALID"; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String ERP ="ERP" ; | 
|---|
|  |  |  | public static final Integer THREE =3 ; | 
|---|
|  |  |  | public static final Integer FOUR =4 ; | 
|---|
|  |  |  | public static final Integer SEVEN =7 ; | 
|---|
|  |  |  | public static final Integer FIVE =5 ; | 
|---|
|  |  |  | public static final String ORG_USER_ORIGIN = "ORG_USER_ORIGIN"; | 
|---|
|  |  |  | public static final String VIRTUAL_CARD_INDEX = "02098469790"; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String MYSQL_BACKUP_DIR ="MYSQL_BACKUP_DIR" ; | 
|---|
|  |  |  | public static final String EVENT_FILES_PRIVATE_DOMAIN ="EVENT_FILES_PRIVATE_DOMAIN" ; | 
|---|
|  |  |  | public static final String EVENT_FILES_PUBLIC_DOMAIN ="EVENT_FILES_PUBLIC_DOMAIN" ; | 
|---|
|  |  |  | public static final String YW_CONTRACT_FILE = "YW_CONTRACT_FILE"; | 
|---|
|  |  |  | public static  boolean DEALING_HK_SYNCPRIVILEGE= false; | 
|---|
|  |  |  | public static  boolean DEALING_HK_SYNCDEVICE = false; | 
|---|
|  |  |  | public static  boolean DEALING_HK_SYNCPLATFORM = false; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String TIMEOUT_WARNING = "TIMEOUT_WARNING"; | 
|---|
|  |  |  | // FTP文件服务器资源访问地址 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *    付款周期类型 0=元每平米天;1=元每平米月;2=元每平米年;3=元每天;4=元每月;5=元每年;6=元每场; | 
|---|
|  |  |  | * @param circleType | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getUnitTypeByNum(Integer circleType) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int zlPayType = Constants.formatIntegerNum(circleType); | 
|---|
|  |  |  | if(zlPayType == 1){ | 
|---|
|  |  |  | return "元/㎡·月"; | 
|---|
|  |  |  | }else   if(zlPayType == 2){ | 
|---|
|  |  |  | return "元/㎡·天"; | 
|---|
|  |  |  | }else  if(zlPayType == 3){ | 
|---|
|  |  |  | return "元/天"; | 
|---|
|  |  |  | }else  if(zlPayType == 4){ | 
|---|
|  |  |  | return "元/月"; | 
|---|
|  |  |  | }else  if(zlPayType == 5){ | 
|---|
|  |  |  | return "元/年"; | 
|---|
|  |  |  | }else  if(zlPayType == 6){ | 
|---|
|  |  |  | return "元/场"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return "元/㎡·天"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *  周期支付方式 0=一次性付款;1=每三个月一付;2=六个月一付;3=一年一付 | 
|---|
|  |  |  | * @param zlPayType | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getPayTypeByNum(Integer zlPayType) { | 
|---|
|  |  |  | if(zlPayType == null){ | 
|---|
|  |  |  | return  ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(zlPayType == 1){ | 
|---|
|  |  |  | return "3个月一付"; | 
|---|
|  |  |  | }else   if(zlPayType == 2){ | 
|---|
|  |  |  | return "6个月一付"; | 
|---|
|  |  |  | }else  if(zlPayType == 3){ | 
|---|
|  |  |  | return "1年一付"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return "一次性付款"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String getRandom6Num( ) { | 
|---|
|  |  |  | Random random = new Random(); | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final  int self = -1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 账单类型 0租赁条款 1物业条款 2租赁押金 3物业押金 4自建账单 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface contractBillType{ | 
|---|
|  |  |  | int lease = 0; | 
|---|
|  |  |  | int property= 1; | 
|---|
|  |  |  | int leaseDeposit = 2; | 
|---|
|  |  |  | int propertyDeposit =3; | 
|---|
|  |  |  | int create =4; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 作业类型 0自有车卸货 1自有车装货 2外协车卸货 3外协车装货 4市公司外协车卸货 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | int sgscxh = 4; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface patrolTaskStatus{ | 
|---|
|  |  |  | int waitStart = 0; | 
|---|
|  |  |  | int working= 1; | 
|---|
|  |  |  | int timeout = 2; | 
|---|
|  |  |  | int finish =3; | 
|---|
|  |  |  | int cancel =4; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static  Date  getBirthdyByCardNo(String idCard){ | 
|---|
|  |  |  | if(idCard ==null || idCard.length()<14){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final long EXPIRE_TIME = 7200; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String INTERNAL_TOKEN ="INTERNAL_TOKEN"; | 
|---|
|  |  |  | public static final String COM_OUTBOUND_OUT_KEY = "obout_"; | 
|---|
|  |  |  | public static final String COM_OUTBOUND_IN_KEY = "obin_"; | 
|---|
|  |  |  | public static final String COM_OUTBOUND_TAKING_KEY = "obtaking_"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String GOODSORDER_KEY = "ordercode_"; | 
|---|
|  |  |  | public static final String ACTIVITY_SIGN_KEY = "actcode_"; | 
|---|
|  |  |  | public static final String AFTERSALE_KEY = "salecode_"; | 
|---|
|  |  |  | public static final String PATROL_SCHEME_CODE_KEY = "patrolSchemeCode"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //保留两位小数且四舍五入 | 
|---|
|  |  |  | d = d.setScale(4, BigDecimal.ROUND_HALF_UP); | 
|---|
|  |  |  | return  d; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static BigDecimal formatBigdecimal0Float(BigDecimal d) { | 
|---|
|  |  |  | if (d == null) { | 
|---|
|  |  |  | d = new BigDecimal(0.0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //保留两位小数且四舍五入 | 
|---|
|  |  |  | d = d.setScale(0, BigDecimal.ROUND_HALF_UP); | 
|---|
|  |  |  | return  d; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static BigDecimal formatBigdecimal2Float(BigDecimal d) { | 
|---|
|  |  |  | 
|---|
|  |  |  | int driver = 0;//司机人员 | 
|---|
|  |  |  | int visitor = 1;//普通访客 | 
|---|
|  |  |  | int internal = 2;//内部人员 | 
|---|
|  |  |  | int customer = 3;//客户人员 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | int otherDeal = 5;//他人已处理 | 
|---|
|  |  |  | int otherUnPass = 6;//他人拒绝 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //类型 0采购入库 1领用退回 2库存调整入库 3其他入库 4盘盈入库 5领用出库 6仓库出库 7调整出库 8采购出库 9其他出库 10盘亏出库 | 
|---|
|  |  |  | public  enum ywOutInType{ | 
|---|
|  |  |  | BUY_IN(0, 0), | 
|---|
|  |  |  | USE_RETURN_IN(1, 0), | 
|---|
|  |  |  | STOCK_IN(2, 0), | 
|---|
|  |  |  | OTHER_IN(3, 0), | 
|---|
|  |  |  | TAKING_IN(4, 0), | 
|---|
|  |  |  | USE_OUT(5, 1), | 
|---|
|  |  |  | HOUSE_OUT(6, 1), | 
|---|
|  |  |  | STOCK_OUT(7, 1), | 
|---|
|  |  |  | OTHER_UN_PASS_OUT(8, 1), | 
|---|
|  |  |  | BUY_OUT(9, 1), | 
|---|
|  |  |  | TAKING_OUT(10, 1) | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | // 成员变量 | 
|---|
|  |  |  | private int key; | 
|---|
|  |  |  | private int inOut; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 构造方法 | 
|---|
|  |  |  | ywOutInType(int key, int inOut) { | 
|---|
|  |  |  | this.inOut = inOut; | 
|---|
|  |  |  | this.key = key; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | public static Integer getInOutValue(int index) { | 
|---|
|  |  |  | for (ywOutInType c : ywOutInType.values()) { | 
|---|
|  |  |  | if (c.getKey() == index) { | 
|---|
|  |  |  | return c.getInOut(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | public static ywOutInType getYwOutInType(int index) { | 
|---|
|  |  |  | for (ywOutInType c : ywOutInType.values()) { | 
|---|
|  |  |  | if (c.getKey() == index) { | 
|---|
|  |  |  | return c; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据出入库类型获取所有的具体类型 | 
|---|
|  |  |  | * @param inOutType | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static List<Integer> getAllTypeKey(int inOutType) { | 
|---|
|  |  |  | List<Integer> list = new ArrayList<>(); | 
|---|
|  |  |  | for (ywOutInType c : ywOutInType.values()) { | 
|---|
|  |  |  | if (c.getInOut() == inOutType) { | 
|---|
|  |  |  | list.add(c.getKey()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // get set 方法 | 
|---|
|  |  |  | public int getInOut() { | 
|---|
|  |  |  | return inOut; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setInOut(int inOut) { | 
|---|
|  |  |  | this.inOut = inOut; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int getKey() { | 
|---|
|  |  |  | return key; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setKey(int key) { | 
|---|
|  |  |  | this.key = key; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取车牌类型信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | HIDDEN_DANGER_DEAL_AFTER(2, "隐患随手拍处理后 ", "隐患随手拍处理后 "), | 
|---|
|  |  |  | YW_WORKORDER_PROBLEM(3, "运维工单问题附件 ", "运维工单问题附件 "), | 
|---|
|  |  |  | YW_WORKORDER_DEAL(4, "运维工单处理附件 ", "运维工单处理附件 "), | 
|---|
|  |  |  | FN_DEVICE_FILE(5, "阜宁服务平台设备类型图片 ", "阜宁服务平台设备类型图片 "), | 
|---|
|  |  |  | FN_DEVICE_RECORD_FILE(6, "阜宁服务平台运维记录图片 ", "阜宁服务平台运维记录图片 "), | 
|---|
|  |  |  | FN_PATROL_POINT_FILE(7, "巡检点附件 ", "巡检点附件 "), | 
|---|
|  |  |  | FN_CONTRACT_BILL_FILE(8, "合同账单附件 ", "合同账单附件 "), | 
|---|
|  |  |  | YW_CONTRACT_FILE(9, "合同附件 ", "合同附件 "), | 
|---|
|  |  |  | FN_CONTRACT_REVENUE_FILE(10, "收支流水附件 ", "合同账单附件 "), | 
|---|
|  |  |  | FN_PATROL_TASK_RECORD_FILE(11, "巡检任务点处理附件 ", "巡检任务点处理附件 "), | 
|---|
|  |  |  | MATERIAL_FILE(12, "资产附件 ", "资产附件 "), | 
|---|
|  |  |  | PROBLEM_FILE(13, "问题附件 ", "问题附件 "), | 
|---|
|  |  |  | FN_DEVICE_MAINTENANCE_FILE(14, "阜宁服务平台设备文件 ", "阜宁服务平台设备文件 "), | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | // 成员变量 | 
|---|
|  |  |  | private String name; | 
|---|
|  |  |  | 
|---|
|  |  |  | return noteinfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 运维合同、工单信息记录类型 | 
|---|
|  |  |  | * 操作类型 0工单创建 1指派 2处理 3合同创建 4合同变更 5合同退租 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public  enum YwLogType{ | 
|---|
|  |  |  | WORKORDER_CREATE(0, "创建工单", "创建工单"), | 
|---|
|  |  |  | WORKORDER_DISPATCH(1, "分派工单", "分派工单"), | 
|---|
|  |  |  | WORKORDER_DEAL(2, "处理工单", "处理工单"), | 
|---|
|  |  |  | CONTRACT_CREATE(3, "合同新建", "新建"), | 
|---|
|  |  |  | CONTRACT_UPDATE(4, "合同变更", "变更"), | 
|---|
|  |  |  | CONTRACT_BACK(5, "合同退租", "退租"), | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | // 成员变量 | 
|---|
|  |  |  | private String name; | 
|---|
|  |  |  | private int key; | 
|---|
|  |  |  | private String noteinfo;// 描述 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 构造方法 | 
|---|
|  |  |  | YwLogType(int key, String name, String noteinfo) { | 
|---|
|  |  |  | this.name = name; | 
|---|
|  |  |  | this.key = key; | 
|---|
|  |  |  | this.noteinfo = noteinfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | public static String getName(int index) { | 
|---|
|  |  |  | for (MultiFile c : MultiFile.values()) { | 
|---|
|  |  |  | if (c.getKey() == index) { | 
|---|
|  |  |  | return c.name; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | public static String getInfo(int index) { | 
|---|
|  |  |  | for (YwLogType c : YwLogType.values()) { | 
|---|
|  |  |  | if (c.getKey() == index) { | 
|---|
|  |  |  | return c.noteinfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // get set 方法 | 
|---|
|  |  |  | public String getName() { | 
|---|
|  |  |  | return name; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setName(String name) { | 
|---|
|  |  |  | this.name = name; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int getKey() { | 
|---|
|  |  |  | return key; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setKey(int key) { | 
|---|
|  |  |  | this.key = key; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getNoteinfo() { | 
|---|
|  |  |  | return noteinfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //邮箱格式的验证 | 
|---|
|  |  |  | public static boolean validEmail(String email) { | 
|---|
|  |  |  | Pattern p = Pattern.compile("[a-zA-Z0-9]+@[A-Za-z0-9]+\\.[a-z0-9]"); | 
|---|
|  |  |  | Matcher m = p.matcher(email); | 
|---|
|  |  |  | if(m.find()){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void packFilesToZip(List<File> files, OutputStream os) throws IOException { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(os); | 
|---|
|  |  |  | zipOutputStream.setUseZip64(Zip64Mode.AsNeeded); | 
|---|
|  |  |  | for (File file : files) { | 
|---|
|  |  |  | if(!file.exists()){ | 
|---|
|  |  |  | System.out.println("===文件不存在======="+file.getPath()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.out.println("===文件存在======="+file.getPath()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ZipArchiveEntry entry = new ZipArchiveEntry(file.getName()); | 
|---|
|  |  |  | zipOutputStream.putArchiveEntry(entry); | 
|---|
|  |  |  | FileInputStream fileInputStream = new FileInputStream(file); | 
|---|
|  |  |  | byte[] buffer = new byte[1024]; | 
|---|
|  |  |  | int length; | 
|---|
|  |  |  | while ((length = fileInputStream.read(buffer)) > 0) { | 
|---|
|  |  |  | zipOutputStream.write(buffer, 0, length); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | zipOutputStream.closeArchiveEntry(); | 
|---|
|  |  |  | zipOutputStream.flush(); | 
|---|
|  |  |  | IoUtil.close(fileInputStream); | 
|---|
|  |  |  | file.delete(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR.getCode(),"对不起,下载压缩文件失败"); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | if (os != null) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | os.close(); | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|