|
@@ -1,11 +1,16 @@
|
|
|
package org.dromara.backstage.payment.service.impl;
|
|
package org.dromara.backstage.payment.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.lang.UUID;
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import lombok.Builder;
|
|
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.backstage.cardCenter.domain.bo.PtCardBo;
|
|
import org.dromara.backstage.cardCenter.domain.bo.PtCardBo;
|
|
@@ -14,9 +19,11 @@ import org.dromara.backstage.payment.domain.vo.PtUserAccount4SelectVo;
|
|
|
import org.dromara.backstage.payment.service.IPtBagService;
|
|
import org.dromara.backstage.payment.service.IPtBagService;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
+import org.dromara.common.core.utils.SpringUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.core.utils.file.FileUtils;
|
|
import org.dromara.common.core.utils.file.FileUtils;
|
|
|
import org.dromara.common.core.utils.file.MimeTypeUtils;
|
|
import org.dromara.common.core.utils.file.MimeTypeUtils;
|
|
|
|
|
+import org.dromara.common.encrypt.interceptor.MybatisEncryptInterceptor;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -32,8 +39,11 @@ import org.dromara.backstage.payment.mapper.PtUserAccountMapper;
|
|
|
import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
|
+import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.net.MalformedURLException;
|
|
|
|
|
+import java.net.URL;
|
|
|
|
|
+import java.nio.charset.Charset;
|
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -123,6 +133,10 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<PtUserAccount> buildQueryWrapper(PtUserAccountBo bo) {
|
|
private LambdaQueryWrapper<PtUserAccount> buildQueryWrapper(PtUserAccountBo bo) {
|
|
|
|
|
+
|
|
|
|
|
+ //手机号加密处理
|
|
|
|
|
+ MybatisEncryptInterceptor encryptInterceptor = SpringUtils.getBean(MybatisEncryptInterceptor.class);
|
|
|
|
|
+ bo.setPhone(encryptInterceptor.encrypt(bo.getPhone()));
|
|
|
Map<String, Object> params = bo.getParams();
|
|
Map<String, Object> params = bo.getParams();
|
|
|
LambdaQueryWrapper<PtUserAccount> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<PtUserAccount> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(bo.getPostId() != null, PtUserAccount::getPostId, bo.getPostId());
|
|
lqw.eq(bo.getPostId() != null, PtUserAccount::getPostId, bo.getPostId());
|
|
@@ -449,4 +463,115 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
}
|
|
}
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public static void downloadPicture(String urlList,String name,String userNumb) {
|
|
|
|
|
+ URL url = null;
|
|
|
|
|
+ int imageNumber = 0;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ url = new URL("http://172.16.137.86:8080/upload/"+urlList);
|
|
|
|
|
+ DataInputStream dataInputStream = new DataInputStream(url.openStream());
|
|
|
|
|
+
|
|
|
|
|
+ String imageName = "C:\\Users\\LENOVO\\Desktop\\img\\"+name+"_"+userNumb+urlList.substring(urlList.lastIndexOf("."));
|
|
|
|
|
+
|
|
|
|
|
+ FileOutputStream fileOutputStream = new FileOutputStream(new File(imageName));
|
|
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
|
+
|
|
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
|
|
+ int length;
|
|
|
|
|
+
|
|
|
|
|
+ while ((length = dataInputStream.read(buffer)) > 0) {
|
|
|
|
|
+ output.write(buffer, 0, length);
|
|
|
|
|
+ }
|
|
|
|
|
+ byte[] context=output.toByteArray();
|
|
|
|
|
+ fileOutputStream.write(output.toByteArray());
|
|
|
|
|
+ dataInputStream.close();
|
|
|
|
|
+ fileOutputStream.close();
|
|
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static class ImageData{
|
|
|
|
|
+ private String url;
|
|
|
|
|
+ private String name;
|
|
|
|
|
+
|
|
|
|
|
+ private String userNumb;
|
|
|
|
|
+
|
|
|
|
|
+ public ImageData(String url, String name, String userNumb) {
|
|
|
|
|
+ this.url = url;
|
|
|
|
|
+ this.name = name;
|
|
|
|
|
+ this.userNumb = userNumb;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static List<ImageData> parseTxt(String filePath){
|
|
|
|
|
+ return FileUtils.readLines(filePath, Charset.defaultCharset()).stream().map(line->{
|
|
|
|
|
+ String[] split = line.split("\\|");
|
|
|
|
|
+ if(split.length!=3){
|
|
|
|
|
+ throw new RuntimeException("txt文件格式错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ String userNumb = split[0].replaceAll(" ", "");
|
|
|
|
|
+ String url = split[1].replaceAll(" ", "");
|
|
|
|
|
+ String name = split[2].replaceAll(" ", "");
|
|
|
|
|
+ return new ImageData(url,name,userNumb);
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //使用 http form-data方式上传图片,使用hutool工具包
|
|
|
|
|
+ public static String uploadImage(String userNumb,String name) throws IOException {
|
|
|
|
|
+ //使用 http form-data方式上传图片,使用hutool工具包
|
|
|
|
|
+ String imagePath = "C:\\Users\\LENOVO\\Desktop\\img\\"+name+"_"+userNumb+".jpg";
|
|
|
|
|
+ File file = new File(imagePath);
|
|
|
|
|
+ Long length = file.length();
|
|
|
|
|
+ if(!file.exists() || length <= 0){
|
|
|
|
|
+ System.err.println(userNumb+" "+name+" "+"照片不存在 "+ imagePath);
|
|
|
|
|
+ return "error: "+ userNumb+" "+name+" "+"照片不存在";
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String,String> headers = new HashMap<>();
|
|
|
|
|
+ headers.put("Content-Type", "multipart/form-data");
|
|
|
|
|
+ headers.put("cookie", "Data=jsv2g08wiSwgsuDrAwQvLCDfueDealwvg330G2yywIAVWXnLV1M/jR6EKPdJqhxGkWwYfHnmjF6+WJk2b8t4gPWQ8T35rBBxD1GiOIQF9jM%3D; Words=MTY6OTQyNjgyNDIyOjg1ODkyODk0NTo5NDMwNzU2MzI6ODQyMDE5NjM3");
|
|
|
|
|
+ String json = "{\"method\":\"faceInfoUpdate.addFace\",\"params\":{\"GroupID\":1,\"PersonInfo\":{\"CertificateType\":\"IC\",\"ID\":\""+userNumb+"\"},\"ImageInfo\":{\"Lengths\":["+length+"],\"Amount\":1}},\"session\":\"1d6e61e33641e339c68a3930c4b3e949\",\"id\":120}";
|
|
|
|
|
+// System.err.println(" json "+json);
|
|
|
|
|
+ HttpRequest form = HttpRequest.post("http://172.19.50.101/CmdCall")
|
|
|
|
|
+ .addHeaders(headers)
|
|
|
|
|
+ .form("json", json)
|
|
|
|
|
+ .form("data", file);
|
|
|
|
|
+ HttpResponse execute = form.execute();
|
|
|
|
|
+ String body = execute.body();
|
|
|
|
|
+
|
|
|
|
|
+ if(body.contains("error")){
|
|
|
|
|
+ System.err.println("error: "+ userNumb+" "+name+" "+"照片上传失败,请手动上传"+ " " + body);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ System.out.println("state : "+ userNumb+" "+name+" " + execute.isOk() + " " + body);
|
|
|
|
|
+ }
|
|
|
|
|
+// System.err.println("body : " + body);
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
|
|
+ /*List<ImageData> list = new ArrayList<>();
|
|
|
|
|
+ list = parseTxt("C:\\Users\\LENOVO\\Desktop\\T_PT_User_202410221658_txt.txt");
|
|
|
|
|
+
|
|
|
|
|
+ System.err.println(list);
|
|
|
|
|
+
|
|
|
|
|
+ list.forEach(item->{
|
|
|
|
|
+ downloadPicture(item.url,item.name, item.userNumb);
|
|
|
|
|
+ });*/
|
|
|
|
|
+ /*File file = new File("C:\\Users\\LENOVO\\Desktop\\img\\冯晓辉_2022118036.jpg");
|
|
|
|
|
+ System.err.println(file.length());*/
|
|
|
|
|
+
|
|
|
|
|
+ List<ImageData> list = new ArrayList<>();
|
|
|
|
|
+ list = parseTxt("C:\\Users\\LENOVO\\Desktop\\userdata.txt");
|
|
|
|
|
+
|
|
|
|
|
+ for (ImageData imageData : list) {
|
|
|
|
|
+ uploadImage(imageData.userNumb,imageData.name);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ System.err.println("11111");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|