From 0a80b7941d86bf210e071f32910a8a952f1a5422 Mon Sep 17 00:00:00 2001 From: cyFeng <123456789@qq.com> Date: Mon, 14 Aug 2023 10:14:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.properties | 11 + .../wuhuacloud/common/utils/ConfigParam.java | 17 + .../com/wuhuacloud/common/utils/DateUtil.java | 232 ++++++++++++++ .../com/wuhuacloud/common/utils/FileUtil.java | 168 ++++++++++ .../common/utils/OrderedProperties.java | 38 +++ .../common/utils/PropertiesUtil.java | 189 +++++++++++ .../wuhuacloud/common/utils/ValidUtil.java | 298 ++++++++++++++++++ 7 files changed, 953 insertions(+) create mode 100644 config/application.properties create mode 100644 fb-common/src/main/java/com/wuhuacloud/common/utils/ConfigParam.java create mode 100644 fb-common/src/main/java/com/wuhuacloud/common/utils/DateUtil.java create mode 100644 fb-common/src/main/java/com/wuhuacloud/common/utils/FileUtil.java create mode 100644 fb-common/src/main/java/com/wuhuacloud/common/utils/OrderedProperties.java create mode 100644 fb-common/src/main/java/com/wuhuacloud/common/utils/PropertiesUtil.java create mode 100644 fb-common/src/main/java/com/wuhuacloud/common/utils/ValidUtil.java diff --git a/config/application.properties b/config/application.properties new file mode 100644 index 0000000..1e39b84 --- /dev/null +++ b/config/application.properties @@ -0,0 +1,11 @@ +debuggerSwich=true +# 人脸bcp抓拍开关 +faceMultiV3Switch=true +# 形体bcp抓拍开关 +bodyMultiV3Switch=false + + +#错误bcp路径 +errPath=/home/err + + diff --git a/fb-common/src/main/java/com/wuhuacloud/common/utils/ConfigParam.java b/fb-common/src/main/java/com/wuhuacloud/common/utils/ConfigParam.java new file mode 100644 index 0000000..00aabbc --- /dev/null +++ b/fb-common/src/main/java/com/wuhuacloud/common/utils/ConfigParam.java @@ -0,0 +1,17 @@ +package com.wuhuacloud.common.utils; + +import org.springframework.stereotype.Component; + +@Component +public class ConfigParam { + + + /*基础目录根路径*/ + public static String basePath = "/home/dataaccess/"; + + public static String debuggerSwich = PropertiesUtil.queryPropertiesByKey("debuggerSwich"); + public static String faceMultiV3Switch = PropertiesUtil.queryPropertiesByKey("faceMultiV3Switch"); + public static String bodyMultiV3Switch = PropertiesUtil.queryPropertiesByKey("bodyMultiV3Switch"); + public static String errPath = PropertiesUtil.queryPropertiesByKey("errPath"); + public static String BCP_TYPE_RENLIAN = "renlian";; +} diff --git a/fb-common/src/main/java/com/wuhuacloud/common/utils/DateUtil.java b/fb-common/src/main/java/com/wuhuacloud/common/utils/DateUtil.java new file mode 100644 index 0000000..1da1abd --- /dev/null +++ b/fb-common/src/main/java/com/wuhuacloud/common/utils/DateUtil.java @@ -0,0 +1,232 @@ +package com.wuhuacloud.common.utils; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class DateUtil { + + private static Logger logger = LoggerFactory.getLogger(com.wt.analysisBcp.util.DateUtil.class); + + public static SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); + public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static final SimpleDateFormat ymdhms = new SimpleDateFormat("yyyyMMddHHmmss"); + + + private static final Logger log = LoggerFactory.getLogger(com.wt.analysisBcp.util.DateUtil.class); + private static final SimpleDateFormat ym = new SimpleDateFormat("yyyyMM"); + private static final SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + /** + * 时间转换为时间戳 + */ + public static String dateToStamp(String s) { + + try { + String res; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + Date date = simpleDateFormat.parse(s); + long ts = date.getTime(); + ts = ts / 1000; + res = StringKit.toString(ts); + return res; + } catch (Exception e) { + if ("true".equals(ConfigParam.debuggerSwich)) logger.info(StringKit.getTrace(e)); + e.printStackTrace(); + } + return ""; + } + + /** + * 时间转换为时间戳 + */ + public static String getNowTimeStr() { + + try { + String currentTime = df.format(new Date()); + return currentTime; + } catch (Exception e) { + logger.info(StringKit.getTrace(e)); + e.printStackTrace(); + } + return ""; + } + + public static String getTime() { + return ymdhms.format(new Date()); + } + + + /** + * 时间戳转换成 标准时间 + * + * @param seconds + * @param format + * @return + */ + public static String timeStamp2Date(String seconds, String format) { + if (seconds == null || seconds.isEmpty() || seconds.equals("null")) { + return ""; + } + if (format == null || format.isEmpty()) { + format = "yyyy-MM-dd HH:mm:ss"; + } + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(new Date(Long.valueOf(seconds + "000"))); + } + + /** + * 上个月 时间戳转换成 标准时间 + * + * @param format + * @return + */ + public static String getLastMonth(String format) { + Calendar calendar = Calendar.getInstance();//日历对象 + calendar.setTime(new Date());//设置当前日期 + calendar.add(Calendar.MONTH, -1);//月份减一 + Date lastMonth = calendar.getTime(); + + if (format == null || format.isEmpty()) { + format = "yyyy-MM-dd HH:mm:ss"; + } + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(lastMonth); + } + + public static String getDateStr(String sendTime) { + String dateStr; + String dateFir = StringKit.toString(sendTime); + Date date = null; + if ("".equals(dateFir)) { + date = new Date(System.currentTimeMillis()); + } else { + Long dateFirL = Long.valueOf(dateFir); + date = new Date(dateFirL * 1000); + } + dateStr = sdf.format(date); + return dateStr; + } + + public static String convertTimeToString(String longTime) { + String format = "yyyyMMddHHmmss"; + try { + Timestamp t = new Timestamp(Long.parseLong(longTime) * 1000L); + SimpleDateFormat sDateFormat = new SimpleDateFormat(format); + return sDateFormat.format(t); + } catch (Exception ex) { + throw new RuntimeException((new StringBuilder()).append("Can't format the time by format[").append(format).append("]!").toString()); + } + } + + /** + * 30天前 + * + * @return + */ + public static String readRecordStart() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.DAY_OF_MONTH, -30); + String startDate = sdf.format(calendar.getTime()); + startDate = startDate.substring(0, 10) + " 00:00:00"; + return startDate; + } + + /** + * 今天 + * + * @return + */ + public static String readRecordEnd() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + String endDate = sdf.format(calendar.getTime()); + endDate = endDate.substring(0, 10) + " 23:59:59"; + return endDate; + } + + + /** + * 根据绝对秒 计算年月 yyyyMM + * + * @param tempLongTime + * @return + */ + public static int yearMonth(String tempLongTime) { + if (StringUtils.isBlank(tempLongTime) || tempLongTime.length() != 10) { + return 0; + } + String format = ym.format(new Date(Long.parseLong(tempLongTime) * 1000L)); + return Integer.parseInt(format); + } + + public static String yearMonthDay(String tempLongTime) { + if (StringUtils.isBlank(tempLongTime) || tempLongTime.length() != 10) { + return null; + } + String format = ymd.format(new Date(Long.parseLong(tempLongTime) * 1000L)); + return format; + } + + + /** + * 特殊场景 + * 通过jpg获取时间 + * + * @param tempLongTime + * @return + */ + public static long ymdhms(String tempLongTime) { + long rel = 0; + try { + rel = ymdhms.parse(tempLongTime).getTime() / 1000; + } catch (ParseException e) { + e.printStackTrace(); + } + return rel; + } + + public static long getLongTime(String tempLongTime) { + long rel = 0; + try { + rel = ymd.parse(tempLongTime).getTime() / 1000; + } catch (ParseException e) { + e.printStackTrace(); + } + return rel; + } + + public static String ymdhmsDate() { + return ymdhms.format(new Date()); + } + + /** + * 开始时间 + * + * @return + */ + public String getStart() { + long time = System.currentTimeMillis() / 1000 - 60 * 60 * 24 * 180; + return ymd.format(new Date(time * 1000)); + } + + /** + * 当前日期 + * + * @return + */ + public String getEnd() { + long time = System.currentTimeMillis(); + return ymd.format(new Date(time)); + } + + +} diff --git a/fb-common/src/main/java/com/wuhuacloud/common/utils/FileUtil.java b/fb-common/src/main/java/com/wuhuacloud/common/utils/FileUtil.java new file mode 100644 index 0000000..3df84d7 --- /dev/null +++ b/fb-common/src/main/java/com/wuhuacloud/common/utils/FileUtil.java @@ -0,0 +1,168 @@ +package com.wuhuacloud.common.utils; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.File; + +@Component +public class FileUtil { + + private static final Logger logger = LoggerFactory.getLogger(FileUtil.class); + private static final String BCP_END = ".bcp"; + private static final String TXT_END = ".txt"; + private static final String JPG_END = ".jpg"; + + /** + * 转移文件 /home/pic/20210907/123.bcp + * bcpNamePrefix 123 + * type .bcp + * sourceFilePathError 需要转移的目录 + * sourceFileName /home/pic/20210907/123.bcp + */ + public static void moveFileTo(String bcpNamePrefix, String type, String sourceFilePathError, String sourceFileName) { + boolean rel = false; + File bakFile = new File(sourceFilePathError); + if (!bakFile.exists()) { + bakFile.mkdirs(); + } + + + File f = new File(sourceFileName); + rel = f.renameTo(new File(sourceFilePathError + bcpNamePrefix + type)); + if (!rel) { + f.delete(); + } + } + + + /** + * 转移文件到错误目录 + * + * @param sourceFilePathError + * @param sourceFileName + */ + public static void moveFileToError(String sourceFilePathError, String sourceFileName) { + File bakFile = new File(sourceFilePathError); + if (!bakFile.exists()) { + bakFile.mkdirs(); + } + File f = new File(sourceFileName); + boolean rel = f.renameTo(new File(sourceFilePathError + f.getName())); + if (!rel) { + f.delete(); + } + } + + /** + * 根据文件绝对路径删除文件 + * + * @param filePath + */ + public static void deleteFile(String filePath) { + if (StringUtils.isBlank(filePath)) { + return; + } + File f = new File(filePath); + try { + if (f.exists()) { + f.delete(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 检测bcp文件名是否合规 + */ + public static boolean checkBcpFile(String fileName) { + if (StringUtils.isBlank(fileName)) { + logger.error("checkFile 文件名不存在 fileName=" + fileName); + return false; + } + if (!fileName.endsWith(BCP_END)) { + logger.error("checkFile 文件名不合规,不是bcp文件 fileName=" + fileName); + return false; + } + return true; + } + + + /** + * 获取bcp文件名称 不包含后缀 + * FaceCapture_图片ID_绝对秒_时分秒_序号 + * + * @param bcpName + * @return + */ + public static String getBcpName(String bcpName) { + if (StringUtils.isBlank(bcpName) || !bcpName.endsWith(BCP_END)) { + return ""; + } + bcpName = bcpName.substring(bcpName.lastIndexOf("/") + 1); + return bcpName.substring(0, bcpName.length() - BCP_END.length()); + } + + /** + * 获取图片ID + * + * @param bcpName + * @return + */ + public static String getPictureId(String bcpName) { + String tmp = getBcpName(bcpName); + String[] arr = tmp.split("_"); + return arr[1]; + } + + /** + * 图片类型type + * + * @param picName + * @return + */ + public static String getPictureType(String picName) { + if (StringUtils.isBlank(picName)) { + return ""; + } + if (picName.contains("person")) { + return "person"; + } + if (picName.contains("globle")) { + return "globle"; + } + return ""; + } + + /** + * 检测txt文件名是否合规 + */ + public static boolean checkTxtFile(String fileName) { + if (StringUtils.isBlank(fileName)) { + logger.error("checkTxtFile 文件名不存在 fileName=" + fileName); + return false; + } + if (!fileName.endsWith(TXT_END)) { + logger.error("checkTxtFile 文件名不合规,不是txt文件 fileName=" + fileName); + return false; + } + return true; + } + + + /** + * 判断是否是数字 + * + * @param s + * @return + */ + private boolean isNumeric(String s) { + if (s != null && !"".equals(s.trim())) + return s.matches("^[0-9]*$"); + else + return false; + } +} \ No newline at end of file diff --git a/fb-common/src/main/java/com/wuhuacloud/common/utils/OrderedProperties.java b/fb-common/src/main/java/com/wuhuacloud/common/utils/OrderedProperties.java new file mode 100644 index 0000000..a5447a8 --- /dev/null +++ b/fb-common/src/main/java/com/wuhuacloud/common/utils/OrderedProperties.java @@ -0,0 +1,38 @@ +package com.wuhuacloud.common.utils; + +import java.util.*; + +/** + * OrderedProperties + * @author Unmi + * @date 2012-12-07 + */ +public class OrderedProperties extends Properties { + + private static final long serialVersionUID = -4627607243846121965L; + + private final LinkedHashSet keys = new LinkedHashSet(); + + public Enumeration keys() { + return Collections. enumeration(keys); + } + + public Object put(Object key, Object value) { + keys.add(key); + return super .put(key, value); + } + + public Set keySet() { + return keys; + } + + public Set stringPropertyNames() { + Set set = new LinkedHashSet(); + + for (Object key : this .keys) { + set.add((String) key); + } + + return set; + } +} \ No newline at end of file diff --git a/fb-common/src/main/java/com/wuhuacloud/common/utils/PropertiesUtil.java b/fb-common/src/main/java/com/wuhuacloud/common/utils/PropertiesUtil.java new file mode 100644 index 0000000..36790df --- /dev/null +++ b/fb-common/src/main/java/com/wuhuacloud/common/utils/PropertiesUtil.java @@ -0,0 +1,189 @@ +package com.wuhuacloud.common.utils; + + +import org.apache.commons.lang3.StringUtils; + +import java.io.*; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * 读取Properties综合类,默认绑定到classpath下的config.properties文件。 + * + * @author 朱志杰 QQ:695520848 + */ +public class PropertiesUtil { + //配置文件的路径 + private String configPath = "config"+File.separator+"application.properties"; + public static final String Path = "config"+File.separator+"application.properties"; + + /** + * 配置文件对象 + */ + private Properties props = null; + + /** + * 默认构造函数,用于sh运行,自动找到classpath下的config.properties。 + */ + public PropertiesUtil() throws IOException { + InputStream in = com.wt.analysisBcp.util.PropertiesUtil.class.getClassLoader().getResourceAsStream("application.properties"); + props = new Properties(); + props.load(in); + //关闭资源 + in.close(); + } + + /** + * 根据key值读取配置的值 + * Jun 26, 2010 9:15:43 PM + * + * @param key key值 + * @return key 键对应的值 + * @throws IOException + * @author 朱志杰 + */ + public String readValue(String key) throws IOException { + return props.getProperty(key); + } + + /** + * 读取properties的全部信息 + * Jun 26, 2010 9:21:01 PM + * + * @throws FileNotFoundException 配置文件没有找到 + * @throws IOException 关闭资源文件,或者加载配置文件错误 + * @author 朱志杰 + */ + public Map readAllProperties() throws FileNotFoundException, IOException { + //保存所有的键值 + Map map = new HashMap(); + Enumeration en = props.propertyNames(); + while (en.hasMoreElements()) { + String key = (String) en.nextElement(); + String Property = props.getProperty(key); + map.put(key, Property); + } + return map; + } + + /** + * 设置某个key的值,并保存至文件。 + * Jun 26, 2010 9:15:43 PM + * + * @param key key值 + * @return key 键对应的值 + * @throws IOException + * @author 朱志杰 + */ + public void setValue(String key, String value) throws IOException { + Properties prop = new Properties(); + InputStream fis = new FileInputStream(this.configPath); + // 从输入流中读取属性列表(键和元素对) + prop.load(fis); + // 调用 Hashtable 的方法 put。使用 getProperty 方法提供并行性。 + // 强制要求为属性的键和值使用字符串。返回值是 Hashtable 调用 put 的结果。 + OutputStream fos = new FileOutputStream(this.configPath); + prop.setProperty(key, value); + // 以适合使用 load 方法加载到 Properties 表中的格式, + // 将此 Properties 表中的属性列表(键和元素对)写入输出流 + prop.store(fos, "last update"); + //关闭文件 + fis.close(); + fos.close(); + } + + /** + * 读取配置文件中key的对应值 + * + * @param key + * @return + */ + public static String queryPropertiesByKey(String key) { + if (StringUtils.isBlank(key)) return ""; + Properties properties = new Properties(); + // 使用InPutStream流读取properties文件 + BufferedReader bufferedReader = null; + try { + bufferedReader = new BufferedReader(new FileReader(Path)); + properties.load(bufferedReader); + String rel = properties.getProperty(key); + bufferedReader.close(); + // 获取key对应的value值 + return rel; + } catch (IOException e) { + if(null != bufferedReader){ + try { + bufferedReader.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + e.printStackTrace(); + } + if(null != bufferedReader){ + try { + bufferedReader.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + return ""; + } + + /** + * 设置配置文件key的value值 + * + * @param key + * @param value + */ + public static void setPropertiesByKey(String key, String value) { +// String realpath = ClassUtils.getDefaultClassLoader().getResource("").getPath(); + File file = new File(Path); + com.wt.analysisBcp.util.OrderedProperties properties = new com.wt.analysisBcp.util.OrderedProperties(); + try { + properties.load(new FileInputStream(file)); + properties.setProperty(key, value); + FileOutputStream oFile = new FileOutputStream(Path);//true表示追加打开 + properties.store(oFile, "The New properties file"); + oFile.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 读取配置文件中key的对应值 + * + * @param key + * @return + */ + public static String queryValue(String key) { + if (StringUtils.isBlank(key)) return ""; + Properties properties = new Properties(); + BufferedReader bufferedReader = null; + String rel = ""; + try { + bufferedReader = new BufferedReader(new FileReader(Path)); + properties.load(bufferedReader); + rel = properties.getProperty(key); + if (StringUtils.isNotBlank(rel)) { + rel = rel.trim(); + } + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (null != bufferedReader) { + try { + bufferedReader.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + return rel; + } + +} \ No newline at end of file diff --git a/fb-common/src/main/java/com/wuhuacloud/common/utils/ValidUtil.java b/fb-common/src/main/java/com/wuhuacloud/common/utils/ValidUtil.java new file mode 100644 index 0000000..b838193 --- /dev/null +++ b/fb-common/src/main/java/com/wuhuacloud/common/utils/ValidUtil.java @@ -0,0 +1,298 @@ +package com.wuhuacloud.common.utils; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class ValidUtil { + + private static final Logger log = LoggerFactory.getLogger(com.wt.analysisBcp.util.ValidUtil.class); + private static final String SM = "SM"; + private static final String FSM = "FSM"; + private static final int VILLAGE_CODE_LENGTH = 15; + + /** + * 校验身份证号 + * + * @param idCard + * @return + */ + public String checkIdCard(String idCard) { + if (StringUtils.isBlank(idCard)) { + return ""; + } + if (idCard.length() != 18) { + return ""; + } + return idCard.trim(); + } + + /** + * 检测是否带眼镜 + * + * @param glasses + * @return + */ + public String checkGlasses(String glasses) { + if (StringUtils.isBlank(glasses)) { + return "0"; + } + int glassInt = 0; + try { + glassInt = Integer.parseInt(glasses); + } catch (Exception e) { + return "0"; + } + if (glassInt == 0 || glassInt == 1 || glassInt == 2) { + glasses = String.valueOf(glassInt); + } else { + return "0"; + } + return glasses; + } + + /** + * 是否戴帽子 + * + * @param hat + * @return + */ + public String checkHat(String hat) { + if (StringUtils.isBlank(hat)) { + return "0"; + } + int hatInt = 0; + try { + hatInt = Integer.parseInt(hat); + } catch (Exception e) { + return "0"; + } + if (hatInt == 0 || hatInt == 1 || hatInt == 2) { + hat = String.valueOf(hatInt); + } else { + return "0"; + } + return hat; + } + + /** + * 是否戴口罩 + * + * @param mask + * @return + */ + public String checkMask(String mask) { + if (StringUtils.isBlank(mask)) { + return "0"; + } + int maskInt = 0; + try { + maskInt = Integer.parseInt(mask); + } catch (Exception e) { + return "0"; + } + if (maskInt == 0 || maskInt == 1 || maskInt == 2) { + mask = String.valueOf(maskInt); + } else { + return "0"; + } + return mask; + } + + /** + * 档案编号 + * + * @param dossierCode + * @return + */ + public String checkDossierCode(String dossierCode) { + if (StringUtils.isBlank(dossierCode) || dossierCode.equals("0")) { + return ""; + } + int dossierCodeInt = 0; + try { + dossierCodeInt = Integer.parseInt(dossierCode); + } catch (Exception e) { + return ""; + } + return String.valueOf(dossierCodeInt); + } + + /** + * 相似度 + * + * @param similarity + * @return + */ + public String checkSimilarity(String similarity) { + if (StringUtils.isBlank(similarity) || similarity.equals("0")) { + return ""; + } + int similarityInt = 0; + try { + similarityInt = Integer.parseInt(similarity); + } catch (Exception e) { + return ""; + } + return String.valueOf(similarityInt); + } + + public String checkIvsDeviceCode(String isvCode) { + if (StringUtils.isBlank(isvCode) || isvCode.equals("0")) { + return ""; + } + return String.valueOf(isvCode.trim()); + } + + /** + * 入库档案编号 + * ivsCode ivs服务器SN + * dossierCode 样本库和陌生人库id + */ + public String dealDossierCode(String ivsCode, String idCard, String dossierCode) { + if (StringUtils.isBlank(ivsCode) + || StringUtils.isBlank(dossierCode) + || "0".equals(ivsCode)) { + return ""; + } + if (StringUtils.isBlank(idCard)) { + return FSM + "-" + ivsCode + "-" + dossierCode; + } else { + return SM + "-" + ivsCode + "-" + dossierCode; + } + } + + + /** + * 人脸比对结果 + * 1比对成功 2比对失败 3未比对 + * + * @param idCard + * @return + */ + public int dealCompare(String idCard) { + if (StringUtils.isBlank(idCard)) { + return 3; + } + if (idCard.length() == 18) { + return 1; + } + return 2; + } + + public boolean checkTime(String time) { + try { + if (StringUtils.isBlank(time) + || time.length() != 10) { + log.error("checkTime time:" + time); + return false; + } + String s = DateUtil.yearMonthDay(time); + if (StringUtils.isBlank(s) || s.contains("-00")) { + return false; + } + } catch (Exception e) { + log.error("checkTime Exception:" + e.getMessage()); + return false; + } + return true; + } + + /** + * 车牌颜色 + * + * @param color + * @return + */ + public int dealPlateColor(String color) { + if (StringUtils.isBlank(color)) { + return 7; + } + if ("黄".equals(color) || "黄色".equals(color)) { + return 1; + } + if ("蓝".equals(color) || "蓝色".equals(color)) { + return 2; + } + if ("白".equals(color) || "白色".equals(color)) { + return 3; + } + if ("黑".equals(color) || "黑色".equals(color)) { + return 4; + } + if ("绿".equals(color) || "绿色".equals(color)) { + return 5; + } + if ("黄绿".equals(color) || "黄绿色".equals(color)) { + return 6; + } + return 7; + } + + /** + * 车身颜色 + * + * @param color + * @return + */ + public int dealVehicleColor(String color) { + if (StringUtils.isBlank(color)) { + return 99; + } + if ("黑".equals(color) || "黑色".equals(color)) { + return 1; + } + if ("白".equals(color) || "白色".equals(color)) { + return 2; + } + if ("灰".equals(color) || "灰色".equals(color)) { + return 3; + } + if ("红".equals(color) || "红色".equals(color)) { + return 4; + } + if ("蓝".equals(color) || "蓝色".equals(color)) { + return 5; + } + if ("黄".equals(color) || "黄色".equals(color)) { + return 6; + } + if ("橙".equals(color) || "橙色".equals(color)) { + return 7; + } + if ("棕".equals(color) || "棕色".equals(color)) { + return 8; + } + if ("绿".equals(color) || "绿色".equals(color)) { + return 9; + } + if ("紫".equals(color) || "紫色".equals(color)) { + return 10; + } + if ("青".equals(color) || "青色".equals(color)) { + return 11; + } + if ("粉".equals(color) || "粉色".equals(color)) { + return 12; + } + if ("透明".equals(color) || "透明色".equals(color)) { + return 13; + } + return 99; + } + + public String checkVillageCode(String villageCode) { + if (StringUtils.isBlank(villageCode)) { + return ""; + } + villageCode = villageCode.trim(); + if (villageCode.length() != VILLAGE_CODE_LENGTH) { + return ""; + } + return villageCode; + } + + +}