|
|
@@ -1,6 +1,7 @@
|
|
|
package org.dromara.backstage.payment.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
@@ -19,6 +20,7 @@ import org.dromara.backstage.basics.domain.vo.PtCardtypeVo;
|
|
|
import org.dromara.backstage.basics.service.IPtCardtypeService;
|
|
|
import org.dromara.backstage.cardCenter.domain.bo.PtCardBo;
|
|
|
import org.dromara.backstage.cardCenter.service.IPtCardService;
|
|
|
+import org.dromara.backstage.domain.vo.card.PtCardVo;
|
|
|
import org.dromara.backstage.domain.vo.yc.YcTraineeVo;
|
|
|
import org.dromara.backstage.mq.PushKafkaData;
|
|
|
import org.dromara.backstage.payment.domain.PtUserAccount;
|
|
|
@@ -31,6 +33,7 @@ import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
|
import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.constant.DefaultConstants;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.enums.CardStatusEnum;
|
|
|
import org.dromara.common.core.service.DictService;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
|
@@ -47,6 +50,7 @@ import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.dromara.system.api.RemoteDeptService;
|
|
|
import org.dromara.system.api.domain.vo.RemoteDeptVo;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -80,6 +84,9 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
@DubboReference
|
|
|
private final RemoteDeptService remoteDeptService;
|
|
|
|
|
|
+ @Value("${photo-prefix:}")
|
|
|
+ private String photoPrefix;
|
|
|
+
|
|
|
/**
|
|
|
* 查询一卡通账户
|
|
|
*
|
|
|
@@ -602,116 +609,6 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- 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");
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public PtUserAccount4SelectVo getCardInfoByFactoryId(String factoryId) {
|
|
|
if (StringUtils.isBlank(factoryId)){
|
|
|
@@ -729,4 +626,50 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户查询账户信息及账户卡信息
|
|
|
+ *
|
|
|
+ * @param userId userId 为null 则查询所有账户信息
|
|
|
+ * @return 账户信息及账户卡信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PtUserAccountVo> getUserAccountsAndCard(Long userId) {
|
|
|
+ List<PtUserAccountVo> res = new ArrayList<>();
|
|
|
+ //账户信息
|
|
|
+ LambdaQueryWrapper<PtUserAccount> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(userId != null, PtUserAccount::getUserId, userId);
|
|
|
+ List<PtUserAccountVo> userAccounts = baseMapper.selectVoList(lqw);
|
|
|
+ if(CollectionUtil.isEmpty(userAccounts)){
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ // 正常卡信息
|
|
|
+ PtCardBo ptCardBo = new PtCardBo();
|
|
|
+ ptCardBo.setStatus(CardStatusEnum.NORMAL.code().toString());
|
|
|
+ if(userId != null){
|
|
|
+ ptCardBo.setUserId(userId);
|
|
|
+ }
|
|
|
+ List<PtCardVo> cards = ptCardService.getList(ptCardBo);
|
|
|
+ if(CollectionUtil.isEmpty(cards)){
|
|
|
+ return userAccounts;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 拼接信息
|
|
|
+ for (PtUserAccountVo userAccount : userAccounts) {
|
|
|
+ Long id = userAccount.getUserId();
|
|
|
+ // 按时间排序
|
|
|
+ PtCardVo ptCardVo = new PtCardVo();
|
|
|
+ Optional<PtCardVo> first = cards.stream()
|
|
|
+ .filter(p -> Objects.equals(p.getUserId(), id))
|
|
|
+ .sorted(Comparator.comparing(PtCardVo::getChangeTime).reversed()).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ ptCardVo = first.get();
|
|
|
+ }
|
|
|
+ userAccount.setCard(ptCardVo);
|
|
|
+ userAccount.setFacePicUrl(photoPrefix+userAccount.getPhoto());
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|