| | |
| | | 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 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 YW_QUICK_MODEL ="YW_QUICK_MODEL" ; |
| | | |
| | | 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 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 final String XUNJIAN ="XUNJIAN" ; |
| | | public static final String XJ_POINT_PREFIX ="XJ_POINT_PREFIX" ; |
| | | public static final String XJ_POINT_CODE_LENGTH ="XJ_POINT_CODE_LENGTH" ; |
| | | public static final String XJ_POINT_QRCODE_URL ="XJ_POINT_QRCODE_URL" ; |
| | | public static final String XJ_RERIRECT_URI ="XJ_RERIRECT_URI" ; |
| | | public static boolean DEALING_HK_SYNCPRIVILEGE= false; |
| | | public static boolean DEALING_HK_SYNCDEVICE = false; |
| | | public static boolean DEALING_HK_SYNCPLATFORM = false; |
| | |
| | | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static String formartNumString(int length, long l) { |
| | | |
| | | return String.format("%0"+length+"d",l ); |
| | | } |
| | | |
| | | public interface VisitIccmStatus{ |
| | | //访客状态(0:未签到,1:已签到,2:已签退,3:滞留,4:未访问,5:自动签离,6:未签退) |
| | | int waitSign = 0; |
| | |
| | | |
| | | public static final String WX_PLATFORM = "WX_PLATFORM"; |
| | | public static final String WX_PLATFORM_ACCESS_TOKEN = "WX_PLATFORM_ACCESS_TOKEN"; |
| | | public static final String WX_AUTH_URL = "WX_AUTH_URL"; |
| | | public static final String WX_PLATFORM_APPID = "WX_PLATFORM_APPID"; |
| | | public static final String WX_PLATFORM_SECRET = "WX_PLATFORM_SECRET"; |
| | | public static final String WX_PLATFORM_AUDIT_VISIT = "WX_PLATFORM_AUDIT_VISIT"; |
| | |
| | | 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_"; |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取车牌类型信息 |
| | | * |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(Constants.checkCarNo("皖A10991")); |
| | | System.out.println(Constants.checkCarNo("皖AA10991")); |
| | | System.out.println(Constants.formartNumString(8,1023492384023480l)); |
| | | // System.out.println(Constants.checkCarNo("皖AA10991")); |
| | | // System.out.println(Constants.getVehiclePlateNo("湘B140D17").getDescription()); |
| | | // System.out.println(Constants.getVehiclePlateNo("宿AP0637").getDescription()); |
| | | |
| | |
| | | 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, "阜宁服务平台设备文件 ", "阜宁服务平台设备文件 "), |
| | | |
| | | ; |
| | | // 成员变量 |
| | |
| | | } |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |