parent
0a27d569e3
commit
f285572689
|
@ -0,0 +1,59 @@
|
|||
package net.shapelight.common.utils;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
|
||||
/**
|
||||
* 日志辅助类,用来处理敏感信息,进行脱敏
|
||||
* @author tyg
|
||||
* @date 2018年5月5日下午4:01:22
|
||||
*/
|
||||
public class PrivacyUtil {
|
||||
|
||||
private static String desensitizedName(String fullName) {
|
||||
if (!Strings.isNullOrEmpty(fullName)) {
|
||||
String name = StringUtils.left(fullName, 1);
|
||||
return StringUtils.rightPad(name, StringUtils.length(fullName), "*");
|
||||
}
|
||||
return fullName;
|
||||
}
|
||||
|
||||
private static String desensitizedPhoneNumber(String phoneNumber) {
|
||||
if (StringUtils.isNotEmpty(phoneNumber)) {
|
||||
phoneNumber = phoneNumber.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
|
||||
}
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
|
||||
private static String desensitizedIdNumber(String idNumber) {
|
||||
if (!Strings.isNullOrEmpty(idNumber)) {
|
||||
if (idNumber.length() == 15) {
|
||||
idNumber = idNumber.replaceAll("(\\w{6})\\w*(\\w{4})", "$1******$2");
|
||||
}
|
||||
if (idNumber.length() == 18) {
|
||||
idNumber = idNumber.replaceAll("(\\w{6})\\w*(\\w{4})", "$1*********$2");
|
||||
}
|
||||
}
|
||||
return idNumber;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String id = "610124198825458";
|
||||
String ide = desensitizedIdNumber(id);
|
||||
System.out.println(ide);
|
||||
|
||||
String m = "1368898";
|
||||
String me = desensitizedPhoneNumber(m);
|
||||
System.out.println(me);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package net.shapelight.modules.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CarImageCache implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String fileName;
|
||||
private String imgUrl;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package gb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.minio.MinioClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.AdminApplication;
|
||||
import net.shapelight.common.config.MinioConfig;
|
||||
import net.shapelight.common.utils.DateUtils;
|
||||
import net.shapelight.common.utils.RedisUtils;
|
||||
import net.shapelight.modules.xian.service.XaApi;
|
||||
import net.shapelight.modules.xian.utils.XaUtils;
|
||||
import net.shapelight.modules.xian.vo.XaData;
|
||||
import net.shapelight.modules.xian.vo.XaPages;
|
||||
import net.shapelight.modules.xian.vo.XaRYRKPHOTO;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AdminApplication.class)
|
||||
@Slf4j
|
||||
public class CarImageRedisTest {
|
||||
|
||||
@Autowired
|
||||
private MinioClient minioClient;
|
||||
@Autowired
|
||||
private MinioConfig minioConfig;
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
@Test
|
||||
public void carRedisTest(){
|
||||
Object url = redisUtils.getPattern("CarImage");
|
||||
if(url!=null){
|
||||
String urlStr = (String)url;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package gb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.minio.MinioClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.AdminApplication;
|
||||
import net.shapelight.common.config.MinioConfig;
|
||||
import net.shapelight.common.utils.DateUtils;
|
||||
import net.shapelight.modules.ten.entity.TenTranEntity;
|
||||
import net.shapelight.modules.xian.service.XaApi;
|
||||
import net.shapelight.modules.xian.utils.XaUtils;
|
||||
import net.shapelight.modules.xian.vo.XaData;
|
||||
import net.shapelight.modules.xian.vo.XaPages;
|
||||
import net.shapelight.modules.xian.vo.XaRYRKPHOTO;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AdminApplication.class)
|
||||
@Slf4j
|
||||
public class ImageUpdateTest {
|
||||
|
||||
@Autowired
|
||||
private MinioClient minioClient;
|
||||
@Autowired
|
||||
private MinioConfig minioConfig;
|
||||
|
||||
@Test
|
||||
public void upTest(){
|
||||
|
||||
String appId = "1297164778041095";
|
||||
String appSecret = "22971647780410956329716477804109";
|
||||
String xqid = "";
|
||||
String fwikUrl = XaApi.getFwikUrl(appId, appSecret);
|
||||
|
||||
/*
|
||||
{"LV_CASE_ID":"10622102195604059627000138841819",
|
||||
"LV_DJSJ":"20210712061714",
|
||||
"LV_GMSFHM":"622102195604059627",
|
||||
"LV_SSXQBM":"A61011312479",
|
||||
"LV_ZP":""}
|
||||
*/
|
||||
String lv_case_id = "10622102195604059627000138841819";
|
||||
String lv_djsj = "20210712061714";
|
||||
String lv_gmsfhm = "622102195604059627";
|
||||
String lv_ssxqbm = "A61011312479";
|
||||
|
||||
String faceImageUrl = "images/842043084869992448/849569914418102274/s_76cfb8b5c54e4995b2d93775aeab7e69.jpg";
|
||||
|
||||
|
||||
|
||||
List<XaRYRKPHOTO> syncPersons = new ArrayList();
|
||||
|
||||
XaRYRKPHOTO realPerson = new XaRYRKPHOTO();
|
||||
realPerson.setLV_CASE_ID(lv_case_id); //实有人口编码
|
||||
realPerson.setLV_GMSFHM(lv_gmsfhm); //身份证号
|
||||
realPerson.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
|
||||
realPerson.setLV_SSXQBM(lv_ssxqbm);
|
||||
|
||||
|
||||
String base64Image = "";
|
||||
InputStream inStream = null;
|
||||
ByteArrayOutputStream outStream = null;
|
||||
|
||||
try {
|
||||
minioClient.statObject(minioConfig.getBucketName(), faceImageUrl);
|
||||
|
||||
inStream = minioClient.getObject(minioConfig.getBucketName(), faceImageUrl);
|
||||
outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
base64Image = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
log.error("照片不存在:" + faceImageUrl);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error("inputStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error("outStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (base64Image.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
realPerson.setLV_ZP(base64Image);
|
||||
syncPersons.add(realPerson);
|
||||
|
||||
|
||||
XaData jsonData = new XaData();
|
||||
jsonData.setDatas(syncPersons);
|
||||
|
||||
List<XaPages> listPages = new ArrayList<>();
|
||||
XaPages pages = new XaPages();
|
||||
pages.setPno("1");
|
||||
pages.setPsize("1");
|
||||
listPages.add(pages);
|
||||
jsonData.setPages(listPages);
|
||||
|
||||
String json = JSONObject.toJSONString(jsonData);
|
||||
String enJson = XaUtils.encryptStr(json.trim(), appSecret);
|
||||
String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "RYRKPHOTO", "RYRKPHOTO", appId, appSecret,"1000000001");
|
||||
log.debug("上传实有人口返回数据:" + resJson);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package gb;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectOptions;
|
||||
import net.shapelight.AdminApplication;
|
||||
import net.shapelight.common.config.MinioConfig;
|
||||
import net.shapelight.common.utils.ImageUtils;
|
||||
import net.shapelight.common.utils.StringUtils;
|
||||
import net.shapelight.common.utils.ThumbnailsUtils;
|
||||
import net.shapelight.common.utils.UUIDUtil;
|
||||
import net.shapelight.modules.ten.entity.TenPackRecordEnterEntity;
|
||||
import net.shapelight.modules.ten.service.TenPackRecordEnterService;
|
||||
import net.shapelight.modules.ten.service.TenPackRecordService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AdminApplication.class)
|
||||
public class NullTest {
|
||||
|
||||
@Autowired
|
||||
private TenPackRecordEnterService tenPackRecordEnterService;
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
|
||||
List<TenPackRecordEnterEntity> records = this.tenPackRecordEnterService.getNotSync(836275079963738113L);
|
||||
System.out.println("");
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue