Compare commits

..

No commits in common. 'develop' and 'master' have entirely different histories.

@ -1,11 +0,0 @@
debuggerSwich=true
# 人脸bcp抓拍开关
faceMultiV3Switch=true
# 形体bcp抓拍开关
bodyMultiV3Switch=false
#错误bcp路径
errPath=/home/err

@ -1,17 +0,0 @@
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";;
}

@ -1,232 +0,0 @@
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));
}
}

@ -1,168 +0,0 @@
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;
}
}

@ -1,38 +0,0 @@
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<Object> keys = new LinkedHashSet<Object>();
public Enumeration<Object> keys() {
return Collections.<Object> enumeration(keys);
}
public Object put(Object key, Object value) {
keys.add(key);
return super .put(key, value);
}
public Set<Object> keySet() {
return keys;
}
public Set<String> stringPropertyNames() {
Set<String> set = new LinkedHashSet<String>();
for (Object key : this .keys) {
set.add((String) key);
}
return set;
}
}

@ -1,189 +0,0 @@
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,classpathconfig.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;
/**
* shclasspathconfig.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<String, String> readAllProperties() throws FileNotFoundException, IOException {
//保存所有的键值
Map<String, String> map = new HashMap<String, String>();
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 "";
}
/**
* keyvalue
*
* @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;
}
}

@ -1,298 +0,0 @@
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 ivsSN
* 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;
}
}
Loading…
Cancel
Save