package com.doumee.core.utils;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.doumee.dao.business.vo.UnitCodeVo;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.lang3.StringUtils;
|
|
import java.io.IOException;
|
import java.math.BigDecimal;
|
import java.net.URLDecoder;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
import java.util.Date;
|
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
|
public class Constants {
|
|
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 ONE = 1 ;
|
public static final int TWO = 2 ;
|
public static final String HK_PARAM ="HK_PARAM" ;
|
public static final String HK_HOST ="HK_HOST" ;
|
public static final String HK_APPKEY ="HK_APPKEY" ;
|
public static final String HK_APPSECRET ="HK_APPSECRET" ;
|
public static final String HK_HTTPS ="HK_HTTPS" ;
|
public static final String HK_PUSH_URL = "HK_PUSH_URL";
|
public static final String HK_ROOTORG_CODE ="HK_ROOTORG_CODE" ;
|
public static final String HK_ROOTORG_NAME ="HK_ROOTORG_NAME" ;
|
|
//被拜访人信息校验方式(0手机号单独校验 1手机号和姓名组合校验)
|
public static final String BEVISITED_USER_VALID = "BEVISITED_USER_VALID";
|
public static final String LW_BEVISITED_USER_VALID = "LW_BEVISITED_USER_VALID";
|
public static final String SELECT_DOORS_VISIT_REQUIRED = "SELECT_DOORS_VISIT_REQUIRED";
|
public static final String SELECT_DOORS_LW_REQUIRED = "SELECT_DOORS_LW_REQUIRED";
|
public static final String PROBLEM_LW_REQUIRED = "PROBLEM_LW_REQUIRED";
|
public static final String PROBLEM_VISIT_REQUIRED = "PROBLEM_VISIT_REQUIRED";
|
public static final String MDJ_LW_REQUIRED = "MDJ_LW_REQUIRED";
|
public static final String MDJ_VISIT_REQUIRED = "MDJ_VISIT_REQUIRED";
|
public static final String EDS_PWD ="!@#$%^&QWERTY" ;
|
public static final String ROOT_PATH = "";
|
public static final String FILE_DIR = "";
|
public static final String INITIAL_PASSWORD = "INITIAL_PASSWORD";
|
public static final String VALIDATE_VISIT = "VALIDATE_VISIT";
|
|
// 访客来访配置
|
public static final String VISIT_CONFIG = "VISIT_CONFIG";
|
public static final String MEMBER_IMG = "MEMBER_IMG";
|
public static final String VISIT_NOTICE = "VISIT_NOTICE";
|
//健康证配置
|
public static final String LW_HEALTH_CARD = "LW_HEALTH_CARD";
|
public static final String HEALTH_CARD = "HEALTH_CARD";
|
//答题说明
|
public static final String LW_DESCRIPTION = "LW_DESCRIPTION";
|
public static final String DESCRIPTION = "DESCRIPTION";
|
//答题主题
|
public static final String LW_THEME = "LW_THEME";
|
public static final String THEME = "THEME";
|
|
// 劳务来访配置
|
public static final String LABOR_CONFIG = "LABOR_CONFIG";
|
public static final String VISIT_EVENT_IMG = "VISIT_EVENT_IMG";
|
public static final String CAR_EVENT_IMG = "CAR_EVENT_IMG";
|
public static final String DEVICE_EVENT_IMG = "DEVICE_EVENT_IMG";
|
public static final String FTP ="FTP" ;
|
public static final String FTP_HOST ="FTP_HOST" ;
|
public static final String FTP_PORT ="FTP_PORT" ;
|
public static final String FTP_USERNAME ="FTP_USERNAME" ;
|
public static final String FTP_PWD ="FTP_PWD" ;
|
public static final String FTP_RESOURCE_PATH ="FTP_RESOURCE_PATH" ;
|
public static final Integer THREE =3 ;
|
public static final Integer FOUR =4 ;
|
public static final String ORG_USER_ORIGIN = "ORG_USER_ORIGIN";
|
public static final String VIRTUAL_CARD_INDEX = "02098469790";
|
public static final String RETRY_CONNECT_NUM ="RETRY_CONNECT_NUM" ;
|
public static final String UNIT_CODE = "UNIT_CODE" ;
|
public static final String ZBOM = "ZBOM" ;
|
public static final String ZBOM_IAM_APPKEY = "ZBOM_IAM_APPKEY";
|
public static final String ZBOM_IAM_APPID = "ZBOM_IAM_APPID";
|
|
public static Integer parseIntByStr(String idtOrgStatus) {
|
try {
|
return Integer.parseInt(idtOrgStatus);
|
}catch (Exception e){
|
return null;
|
}
|
}
|
|
/**
|
* 附件对象类型 0news多图 1news视频
|
*/
|
public enum MultiFile{
|
NEWS_FILE(0, "推广资讯附件", "NEWS")
|
|
;
|
// 成员变量
|
private String name;
|
private int key;
|
private String info;// 描述
|
|
// 构造方法
|
MultiFile(int key, String name, String info) {
|
this.name = name;
|
this.key = key;
|
this.info = info;
|
}
|
|
// 普通方法
|
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 (MultiFile c : MultiFile.values()) {
|
if (c.getKey() == index) {
|
return c.info;
|
}
|
}
|
return null;
|
}
|
|
public String getInfo() {
|
return info;
|
}
|
|
public void setInfo(String info) {
|
this.info = info;
|
}
|
|
// 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 static Date getBirthdyByCardNo(String idCard){
|
if(idCard ==null || idCard.length()<14){
|
return null;
|
}
|
Date birthday = null; // 解析为日期对象
|
String birthdayString = idCard.substring(6, 14); // 截取身份证号的前六位数字作为出生日期
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
try {
|
birthday = dateFormat.parse(birthdayString);
|
} catch (Exception e) {
|
// throw new RuntimeException(e);
|
}
|
return birthday;
|
}
|
public static Integer getSexByCardNo(String idCard){
|
if(idCard ==null || idCard.length()<17){
|
return null;
|
}
|
String str = idCard.substring(16, 17); // 截取身份证号的前六位数字作为出生日期
|
try {
|
Integer num = Integer.parseInt(str);
|
return (num % 2 !=0) ? 1:2 ;
|
} catch (Exception e) {
|
}
|
return null;
|
}
|
|
/**
|
* 判断是否为有效车牌号
|
*/
|
public static boolean checkCarNo(String str) {
|
// String patt="^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵川青藏琼宁秦川]\\\\d{5}[A-Z]$";
|
// Pattern r = Pattern.compile(patt);
|
// Matcher matcher = r.matcher(str);
|
// String regex = "^[\u4e00-\u9fa5]{1}[A-Z]{1}[A-HJ-NP-Z]{1}[A-HJ-NP-Z0-9]{4}[D0-9X]$";
|
// Pattern pattern = Pattern.compile(regex);
|
// Matcher matcher = pattern.matcher(str);
|
// boolean isMatcher = matcher.matches();
|
// return isMatcher;
|
|
|
if (str.length() >= 7 && str.length() <= 8){
|
Pattern pattern = Pattern.compile("^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([ABCDF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[ABCDF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})$");
|
Matcher m = pattern.matcher(str);
|
if (!m.matches()){
|
return false;
|
}
|
return true;
|
}else {
|
return false;
|
}
|
|
}
|
|
public static String getTuominStr(String s){
|
if(StringUtils.isEmpty(s)){
|
return "";
|
}
|
int l = s.length();
|
if(l <= 2){
|
return s.substring(0,1)+"****";
|
}
|
if(l <= 5){
|
return s.substring(0,2)+"***";
|
}
|
if(l <= 10){
|
return s.substring(0,3)+"***"+s.substring(l-3,l);
|
}
|
if(l <= 11){
|
return s.substring(0,3)+"****"+s.substring(l-4,l);
|
}
|
if(l <= 15){
|
return s.substring(0,3)+"****"+s.substring(l-4,l);
|
}
|
return s.substring(0,5)+"*******"+s.substring(l-6,l);
|
}
|
|
|
/**
|
* mq tag
|
*/
|
public interface MQ_TAG{
|
String order = "order";
|
String activity = "activity";
|
}
|
|
/**
|
* 卡片状态 0禁用 1启用 2退卡 3挂失
|
*/
|
public interface MemberCard{
|
int forbidden = 0;
|
int normal = 1;
|
int returned = 2;
|
int loss = 3;
|
}
|
public interface MQ_KEY{
|
String activity_looknum = "looknum";
|
String activity_signup = "signup";
|
}
|
public interface DeviceRoleType{
|
int lw = 0;//劳务访客
|
int fk = 1;//普通访客
|
int nb = 2;//内部访客
|
}
|
public interface VisitStatus{
|
//审核状态 0待审核 1已提交ERP审批 2审核通过 3审核不通过 4取消 5下发成功 6下发失败 7已登记 8已签离 9已失效
|
int waitCheck = 0;
|
int submitCheck = 1;
|
int pass = 2;
|
int noPass = 3;
|
int cancel = 4;
|
int xfSuccess = 5;
|
int xfFail = 6;
|
int signin= 7;
|
int signout = 8;
|
int invalid =9;
|
}
|
public interface EmpowerStatus{
|
//一卡通授权下发状态 0待下发 1已下发 2下发成功 3已取消 4下发失败 5任务下载已结束
|
int wait = 0;
|
int ing = 1;
|
int pass = 2;
|
int cancel = 3;
|
int fail = 4;
|
int downloaded = 5;
|
}
|
public interface DOOR_ROLE_TYPE{
|
int lw = 0;
|
int fk = 1;
|
int nb = 2;
|
}
|
public static final String SUCCESS_STR = "SUCCESS" ;
|
|
//开门时间有效期(分钟)
|
public static final String ACCESS_ID="ACCESS_ID";
|
public static final String BUCKETNAME = "BUCKETNAME";
|
public static final String OBJCET_STORAGE = "OBJCET_STORAGE";
|
|
public static final String ACCESS_KEY = "ACCESS_KEY";
|
public static final String ENDPOINT = "ENDPOINT";
|
public static final String RESOURCE_PATH = "RESOURCE_PATH";
|
public static final String USERS_FILE = "USERS_FILE";
|
public static final String NEWS_FILE = "NEWS_FILE";
|
//发送会议开始 定时提前多少分钟发送
|
|
public static final String SYSTEM ="SYSTEM";
|
|
public static final String COFFEE_BEAN_TASK ="COFFEE_BEAN_TASK";
|
|
|
public static final String HOME_IMAGE ="HOME_IMAGE";
|
|
|
|
|
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_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 String ZBOM_CRM_API_URL = "ZBOM_CRM_API_URL";
|
public static final String ZBOM_CRM_API_KEY = "ZBOM_CRM_API_KEY";
|
public static final String ZBOM_SMS_API_KEY = "ZBOM_SMS_API_KEY";
|
public static final String ZBOM_SMS_API_URL = "ZBOM_SMS_API_URL";
|
public static final String WX_PLATFORM_PREFIX = "WX_PLATFORM_PREFIX";
|
|
|
|
|
|
|
public interface RedisKeys {
|
public static final String IMPORTING_MEMBER ="IMPORTING_MEMBER";
|
public static final String IMPORTING_SHOP ="IMPORTING_SHOP";
|
public static final String IAM_APPID ="IAM_APPID";
|
public static final String ZBOM_CRM_API_KEY ="ZBOM_CRM_API_KEY";
|
public static final String ZBOM_CRM_API_URL ="ZBOM_CRM_API_URL";
|
public static final String ZBOM_SMS_API_KEY ="ZBOM_SMS_API_KEY";
|
public static final String ZBOM_SMS_API_URL ="ZBOM_SMS_API_URL";
|
public static final String IAM_APPKEY ="IAM_APPKEY";
|
public static final String SHOP_TREE ="SHOP_TREE";
|
public static final String ERP_TOKEN ="ERP_TOKEN";
|
public static final long EXPIRE_TIME = 7200;
|
|
public static final String INTERNAL_TOKEN ="INTERNAL_TOKEN";
|
|
public static final String GOODSORDER_KEY = "ordercode_";
|
public static final String ACTIVITY_SIGN_KEY = "actcode_";
|
public static final String AFTERSALE_KEY = "salecode_";
|
}
|
|
|
|
public static BigDecimal formatBigdecimal(BigDecimal d) {
|
if (d == null) {
|
d = new BigDecimal(0.0);
|
}
|
//保留两位小数且四舍五入
|
// d = d.setScale(2, BigDecimal.ROUND_HALF_UP);
|
return d;
|
}
|
public static BigDecimal formatBigdecimal4Float(BigDecimal d) {
|
if (d == null) {
|
d = new BigDecimal(0.0);
|
}
|
//保留两位小数且四舍五入
|
d = d.setScale(4, BigDecimal.ROUND_HALF_UP);
|
return d;
|
}
|
|
public static boolean equalsObject(Object a, Object b) {
|
if (a == null && b == null) {
|
return true;
|
}
|
if (a != null){
|
return a.equals(b);
|
}
|
return false;
|
}
|
|
|
public static boolean equalsLong(Long a, Long b) {
|
if (a == null || b==null) {
|
return false;
|
}
|
return a.equals(b);
|
}
|
public static boolean equalsInteger(Integer a, Integer b) {
|
if (formatIntegerNum(a) == formatIntegerNum(b)) {
|
return true;
|
}
|
return false;
|
}
|
|
public static int formatIntegerNum(Integer d) {
|
if (d == null) {
|
d = 0;
|
}
|
return d.intValue();
|
}
|
|
public static long formatLongNum(Long d) {
|
if (d == null) {
|
d = 0L;
|
}
|
return d.longValue();
|
}
|
|
|
public interface memberType{
|
int lw_visitor = 0;//劳务访客
|
int visitor = 1;//普通访客
|
int internal = 2;//内部人员
|
}
|
|
|
public interface approveStatus{
|
int wait = 0;//待审批
|
int auditIng = 1;//审批中
|
int pass = 2;//审批通过
|
int unPass = 3;//审批未通过
|
int otherDeal = 4;//他人已处理
|
}
|
|
/**
|
* 获取车牌类型信息
|
*
|
* @param plateNo
|
* @return 返回null,表示车牌不匹配
|
*/
|
public static VehiclePlateNoEnum getVehiclePlateNo(String plateNo) {
|
for (VehiclePlateNoEnum vehiclePlateNoEnum : VehiclePlateNoEnum.values()) {
|
Matcher matcher = vehiclePlateNoEnum.pattern.matcher(plateNo);
|
if (matcher.find()) {
|
return vehiclePlateNoEnum;
|
}
|
}
|
return null;
|
}
|
|
|
public enum VehiclePlateNoEnum {
|
/**
|
* 匹配民用车牌和使馆车牌
|
* 1、第一位为汉子省份缩写
|
* 2、第二位为大写字母城市编码
|
* 3、后面是5位仅含字母和数字的组合
|
*/
|
CIVIL_LICENSE_PLATE_AND_EMBASSY_LICENSE_PLATE(1, "民用车牌和使馆车牌", Pattern.compile("^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]{1}[A-Z]{1}[0-9a-zA-Z]{5}$")),
|
/**
|
* 匹配特种车牌(挂,警,学,领,港,澳)
|
*/
|
SPECIAL_LICENSE_PLATES(2, "特种车牌", Pattern.compile("^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]{1}[A-Z]{1}[0-9a-zA-Z]{4}[挂警学领港澳]{1}$")),
|
/**
|
* 匹配
|
*/
|
ARMED_POLICE_CAR(3, "武警车牌", Pattern.compile("^WJ[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]?[0-9a-zA-Z]{5}$")),
|
/**
|
* 匹配军牌
|
*/
|
MILITARY_CAR(4, "军用车牌", Pattern.compile("^[A-Z]{2}[0-9]{5}$")),
|
/**
|
* 小型新能源车
|
* 1、匹配新能源车辆6位车牌
|
*/
|
SMALL_NEW_ENERGY_VEHICLE(5, "小型新能源车牌", Pattern.compile("^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]{1}[A-Z]{1}[A-Z]{1}[0-9a-zA-Z]{5}$")),
|
/**
|
* 大型新能源车
|
*/
|
LARGE_NEW_ENERGY_VEHICLE(6, "大型新能源车牌", Pattern.compile("^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]{1}[A-Z]{1}[0-9a-zA-Z]{5}[DF]{1}$"));
|
private int code;
|
|
private String description;
|
|
private Pattern pattern;
|
|
VehiclePlateNoEnum(int code, String description, Pattern pattern) {
|
this.code = code;
|
this.description = description;
|
this.pattern = pattern;
|
}
|
|
public int getCode() {
|
return code;
|
}
|
|
public String getDescription() {
|
return description;
|
}
|
}
|
|
public static void main(String[] args) {
|
System.out.println((DESUtil.decrypt(Constants.EDS_PWD, "En35O2o+Mpw5bThqkT8lmE6UPG+W6LFs")));
|
|
Map<String,String> map = new HashMap<>();
|
map.put("101","志邦本部");
|
map.put("102","制造事业部");
|
map.put("103","肥东销售公司");
|
map.put("104","ZB/志邦厨柜");
|
map.put("105","商品事业部");
|
map.put("106","巢湖销售公司");
|
map.put("107","IK/全屋定制");
|
map.put("108","工程事业部");
|
map.put("109","合肥销售公司");
|
map.put("110","外贸事业部");
|
map.put("111","志邦家居公司");
|
map.put("112","ZB/志邦衣柜");
|
map.put("127","志邦厨柜股份有限公司");
|
map.put("141","合肥志邦木业有限公司");
|
map.put("161","ZB/志邦木门");
|
map.put("263","国贸公司");
|
List<UnitCodeVo> list = new ArrayList<>();
|
Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
|
while (iterator.hasNext()) {
|
Map.Entry<String, String> entry = iterator.next();
|
UnitCodeVo m = new UnitCodeVo();
|
m.setCode(entry.getKey());
|
m.setName(entry.getValue());
|
list.add(m);
|
}
|
System.out.println(JSONObject.toJSONString(list));
|
|
}
|
|
|
|
/**
|
* 数据状态枚举
|
*
|
*/
|
public enum Status {
|
|
/** 用户启用禁用枚举值*/
|
ENABLE(0,"正常"),
|
DISABLE(1,"禁用"),
|
FREEZE(2,"拉黑/冻结"),
|
|
/** 用户类型 **/
|
LW_FK(0,"劳务访客"),
|
PT_FK(1,"普通访客"),
|
NB_FK(2,"内部人员"),
|
|
/** 进场类型 **/
|
OUT(0,"出"),
|
IN(1,"进");
|
|
private Integer value;
|
private String des;
|
|
|
Status(Integer value, String des) {
|
this.value = value;
|
this.des = des;
|
}
|
|
public Integer getValue() {
|
return value;
|
}
|
|
public void setValue(Integer value) {
|
this.value = value;
|
}
|
|
public String getDes() {
|
return des;
|
}
|
|
public void setDes(String des) {
|
this.des = des;
|
}
|
}
|
|
/**
|
* 对象驼峰属性转下划线
|
* @param object
|
* @return
|
* @throws JsonProcessingException
|
*/
|
public static String toUnderlineJSONString(Object object) throws JsonProcessingException {
|
ObjectMapper mapper = new ObjectMapper();
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
String reqJson = mapper.writeValueAsString(object);
|
return reqJson;
|
}
|
|
|
public static <T> T toSnakeObject(String json, Class<T> clazz) throws IOException {
|
ObjectMapper mapper = new ObjectMapper();
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
T reqJson = mapper.readValue(json, clazz);
|
return reqJson;
|
}
|
|
}
|