|
|
@@ -1,22 +1,30 @@
|
|
|
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;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import lombok.Builder;
|
|
|
-import lombok.NoArgsConstructor;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.backstage.cardCenter.domain.bo.PtCardBo;
|
|
|
import org.dromara.backstage.cardCenter.service.IPtCardService;
|
|
|
+import org.dromara.backstage.payment.domain.PtUserAccount;
|
|
|
+import org.dromara.backstage.payment.domain.bo.PtUserAccountBo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtUserAccount4SelectVo;
|
|
|
+import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
|
|
|
+import org.dromara.backstage.payment.mapper.PtUserAccountMapper;
|
|
|
import org.dromara.backstage.payment.service.IPtBagService;
|
|
|
+import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
|
+import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
|
@@ -24,19 +32,11 @@ import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.core.utils.file.FileUtils;
|
|
|
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.PageQuery;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.system.api.RemoteDeptService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.dromara.backstage.payment.domain.bo.PtUserAccountBo;
|
|
|
-import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
|
|
|
-import org.dromara.backstage.payment.domain.PtUserAccount;
|
|
|
-import org.dromara.backstage.payment.mapper.PtUserAccountMapper;
|
|
|
-import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
@@ -74,9 +74,9 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
* @return 一卡通账户
|
|
|
*/
|
|
|
@Override
|
|
|
- public PtUserAccountVo queryById(Long userId){
|
|
|
- PtUserAccountVo vo= baseMapper.selectVoById(userId);
|
|
|
- if(vo!=null) {
|
|
|
+ public PtUserAccountVo queryById(Long userId) {
|
|
|
+ PtUserAccountVo vo = baseMapper.selectVoById(userId);
|
|
|
+ if (vo != null) {
|
|
|
String deptName = remoteDeptService.selectDeptNameByIds(vo.getDeptId().toString());
|
|
|
vo.setDeptName(deptName);
|
|
|
}
|
|
|
@@ -94,7 +94,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
public TableDataInfo<PtUserAccountVo> queryPageList(PtUserAccountBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<PtUserAccount> lqw = buildQueryWrapper(bo);
|
|
|
Long deptId = bo.getDeptId();
|
|
|
- if(deptId != null){
|
|
|
+ if (deptId != null) {
|
|
|
List<Long> ids = remoteDeptService.selectDeptAndChildrenDeptById(bo.getDeptId());
|
|
|
lqw.in(PtUserAccount::getDeptId, ids);
|
|
|
}
|
|
|
@@ -174,6 +174,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
|
|
|
/**
|
|
|
* 给一卡通账户列表查询条件使用
|
|
|
+ *
|
|
|
* @param bo
|
|
|
* @param tableAlias
|
|
|
* @return
|
|
|
@@ -181,16 +182,16 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
private QueryWrapper<PtUserAccount> buildQueryWrapper4Select(PtUserAccountBo bo, String tableAlias) {
|
|
|
QueryWrapper<PtUserAccount> wrapper = new QueryWrapper<>();
|
|
|
String columnPrefix = "";
|
|
|
- if(StringUtils.isNotBlank(tableAlias)){
|
|
|
+ if (StringUtils.isNotBlank(tableAlias)) {
|
|
|
columnPrefix = tableAlias + ".";
|
|
|
}
|
|
|
- wrapper.eq(bo.getPostId() != null, columnPrefix+"post_id", bo.getPostId());
|
|
|
+ wrapper.eq(bo.getPostId() != null, columnPrefix + "post_id", bo.getPostId());
|
|
|
// wrapper.like(bo.getDeptId() != null, columnPrefix+"dept_id", bo.getDeptId());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(bo.getUserNumb()), columnPrefix+"user_numb", bo.getUserNumb());
|
|
|
- wrapper.like(StringUtils.isNotBlank(bo.getRealName()), columnPrefix+"real_name", bo.getRealName());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(bo.getAccountStatus()), columnPrefix+"account_status", bo.getAccountStatus());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(bo.getFreezeStatus()), columnPrefix+"freeze_status", bo.getFreezeStatus());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(bo.getStatus()), columnPrefix+"status", bo.getStatus());
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(bo.getUserNumb()), columnPrefix + "user_numb", bo.getUserNumb());
|
|
|
+ wrapper.like(StringUtils.isNotBlank(bo.getRealName()), columnPrefix + "real_name", bo.getRealName());
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(bo.getAccountStatus()), columnPrefix + "account_status", bo.getAccountStatus());
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(bo.getFreezeStatus()), columnPrefix + "freeze_status", bo.getFreezeStatus());
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(bo.getStatus()), columnPrefix + "status", bo.getStatus());
|
|
|
return wrapper;
|
|
|
}
|
|
|
|
|
|
@@ -227,7 +228,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(PtUserAccount entity){
|
|
|
+ private void validEntityBeforeSave(PtUserAccount entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
@@ -240,11 +241,12 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 根据Id更新账户的冻结状态
|
|
|
*
|
|
|
@@ -256,10 +258,11 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateFreezeStatus(Long userId, String freezeStatus) {
|
|
|
- return baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getFreezeStatus,freezeStatus)
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ return baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getFreezeStatus, freezeStatus)
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 根据Id更新账户的冻结状态
|
|
|
*
|
|
|
@@ -272,12 +275,13 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
@Override
|
|
|
public int updateFreezeStatus(Long[] userIds, String freezeStatus) {
|
|
|
for (Long userId : userIds) {
|
|
|
- baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getFreezeStatus,freezeStatus)
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getFreezeStatus, freezeStatus)
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
}
|
|
|
return userIds.length;
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 根据Id重置账户有效期
|
|
|
*
|
|
|
@@ -290,13 +294,14 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
@Override
|
|
|
public int resetLifespan(Long[] userIds, String lifespan) {
|
|
|
for (Long userId : userIds) {
|
|
|
- baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getLifespan,lifespan)
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getLifespan, lifespan)
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
}
|
|
|
return ptCardService.resetLifespan(userIds, lifespan);
|
|
|
// return userIds.length;
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 根据Id更新账户的卡类
|
|
|
*
|
|
|
@@ -309,13 +314,14 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
@Override
|
|
|
public int resetCardType(Long[] userIds, String cardType) {
|
|
|
for (Long userId : userIds) {
|
|
|
- baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getCardType,cardType)
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getCardType, cardType)
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
}
|
|
|
return ptCardService.resetCardType(userIds, cardType);
|
|
|
// return userIds.length;
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
* 根据Id更新账户的消费密码
|
|
|
*
|
|
|
@@ -328,9 +334,9 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
@Override
|
|
|
public int resetConsumePwd(Long[] userIds, String pwd) {
|
|
|
for (Long userId : userIds) {
|
|
|
- baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getConsumePwd,pwd)
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getConsumePwd, pwd)
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
}
|
|
|
return userIds.length;
|
|
|
}
|
|
|
@@ -345,16 +351,17 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int openAccount(Long[] userIds) {
|
|
|
- for (Long userId : userIds){
|
|
|
+ for (Long userId : userIds) {
|
|
|
//先初始化钱包
|
|
|
bagService.initAccountBag(userId);
|
|
|
//更新开户状态
|
|
|
- baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getAccountStatus,"1")
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getAccountStatus, "1")
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
}
|
|
|
return userIds.length;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 开户
|
|
|
*
|
|
|
@@ -375,7 +382,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
//return cardBusiness.openVirtualCard(cardBo);
|
|
|
|
|
|
}
|
|
|
- return R.fail(MessageFormat.format("[一卡通开户]-[失败]-[写账户表失败,开户Id:{0}]",bo.getUserId()));
|
|
|
+ return R.fail(MessageFormat.format("[一卡通开户]-[失败]-[写账户表失败,开户Id:{0}]", bo.getUserId()));
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -389,19 +396,19 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
@Override
|
|
|
public Boolean closeAccount(Long[] userIds) {
|
|
|
List<String> notCloseList = new ArrayList<>();
|
|
|
- for (Long userId : userIds){
|
|
|
+ for (Long userId : userIds) {
|
|
|
String tempValue = bagService.selectAccountBalanceByIds(String.valueOf(userId));
|
|
|
BigDecimal totalValue = new BigDecimal(tempValue);
|
|
|
- if (totalValue.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ if (totalValue.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
//卡余为0,可以销户
|
|
|
- baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
- .set(PtUserAccount::getAccountStatus,"-1")
|
|
|
- .eq(PtUserAccount::getUserId,userId));
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getAccountStatus, "-1")
|
|
|
+ .eq(PtUserAccount::getUserId, userId));
|
|
|
} else {
|
|
|
notCloseList.add(userId.toString());
|
|
|
}
|
|
|
}
|
|
|
- if(!notCloseList.isEmpty()){
|
|
|
+ if (!notCloseList.isEmpty()) {
|
|
|
log.warn("[销户失败,有账户存在余额]-[{}]", String.join(StringUtils.SEPARATOR, notCloseList));
|
|
|
}
|
|
|
return notCloseList.isEmpty();
|
|
|
@@ -411,33 +418,33 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
public int photoBatchUpload(MultipartFile[] files, String uploadPath, String userPath) throws IOException {
|
|
|
//1. 根据文件名查询账户信息
|
|
|
List<String> idCards = new ArrayList<>();
|
|
|
- for (MultipartFile file : files){
|
|
|
+ for (MultipartFile file : files) {
|
|
|
String idCard = FileUtil.mainName(file.getOriginalFilename());
|
|
|
idCards.add(idCard);
|
|
|
}
|
|
|
Map<String, Long> idCardMap = baseMapper.selectList(Wrappers.lambdaQuery(PtUserAccount.class)
|
|
|
.select(PtUserAccount::getIdNumber, PtUserAccount::getUserId)
|
|
|
- .in(PtUserAccount::getIdNumber,idCards)
|
|
|
- ).stream().collect(Collectors.toMap(PtUserAccount::getIdNumber, PtUserAccount:: getUserId));
|
|
|
+ .in(PtUserAccount::getIdNumber, idCards)
|
|
|
+ ).stream().collect(Collectors.toMap(PtUserAccount::getIdNumber, PtUserAccount::getUserId));
|
|
|
|
|
|
//2. 循环上传照片,并更新账号的照片路径
|
|
|
- //2.1. 拼接文件完整路径
|
|
|
+ //2.1. 拼接文件完整路径
|
|
|
String path = uploadPath + userPath;
|
|
|
int okNum = 0;
|
|
|
- for (MultipartFile file : files){
|
|
|
+ for (MultipartFile file : files) {
|
|
|
String extension = FileUtils.extName(file.getOriginalFilename());
|
|
|
if (StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
|
|
//只上传指定格式文件
|
|
|
String idCard = FileUtil.mainName(file.getOriginalFilename());
|
|
|
- if (idCardMap.containsKey(idCard)){
|
|
|
+ if (idCardMap.containsKey(idCard)) {
|
|
|
//只上传根据身份证能匹配到对应账号的照片
|
|
|
String newFileName = UUID.randomUUID() + "." + extension;
|
|
|
//2. 保存照片
|
|
|
FileUtils.upload(file, path, newFileName);
|
|
|
//4.保存图片路径到数据库
|
|
|
String photoUrl = userPath + newFileName;
|
|
|
- updateByBo(PtUserAccountBo.builder().userId(idCardMap.get(idCard)).photo(photoUrl).build());
|
|
|
- okNum++;
|
|
|
+ updateByBo(PtUserAccountBo.builder().userId(idCardMap.get(idCard)).photo(photoUrl).build());
|
|
|
+ okNum++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -446,33 +453,89 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
|
|
|
/**
|
|
|
* 根据人员编号与姓名查询人员信息
|
|
|
+ *
|
|
|
* @param realName 人员姓名
|
|
|
* @param userNumb 人员编号
|
|
|
* @return 人员信息
|
|
|
*/
|
|
|
@Override
|
|
|
public PtUserAccountVo queryByNameAndNumb(String realName, String userNumb) {
|
|
|
- LambdaQueryWrapper<PtUserAccount> query = new LambdaQueryWrapper<PtUserAccount>()
|
|
|
- .eq(PtUserAccount::getRealName,realName)
|
|
|
- .eq(PtUserAccount::getUserNumb,userNumb);
|
|
|
+ PtUserAccountVo vo;
|
|
|
+ List<PtUserAccountVo> redisList = RedisUtils.getCacheList(CacheNames.PT_USER_ACCOUNT);
|
|
|
+
|
|
|
+ if (ObjUtil.isNotNull(redisList) && !redisList.isEmpty()) {
|
|
|
+ vo = redisList.stream().filter(p -> Objects.equals(p.getRealName(), realName)
|
|
|
+ && Objects.equals(p.getUserNumb(),userNumb)).findFirst().orElse(null);
|
|
|
+ if (ObjUtil.isNotNull(vo)) {
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- PtUserAccountVo vo = baseMapper.selectVoOne(query);
|
|
|
- if(vo!=null) {
|
|
|
- String deptName = remoteDeptService.selectDeptNameByIds(vo.getDeptId().toString());
|
|
|
- vo.setDeptName(deptName);
|
|
|
+ PtUserAccountBo bo = new PtUserAccountBo();
|
|
|
+ bo.setRealName(realName);
|
|
|
+ bo.setUserNumb(userNumb);
|
|
|
+ return this.selectVoOneByBo(bo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PtUserAccountVo getUserAccountVoByUserNo(Long userNo) {
|
|
|
+ PtUserAccountVo vo;
|
|
|
+ List<PtUserAccountVo> redisList = RedisUtils.getCacheList(CacheNames.PT_USER_ACCOUNT);
|
|
|
+
|
|
|
+ if (ObjUtil.isNotNull(redisList) && !redisList.isEmpty()) {
|
|
|
+ vo = redisList.stream().filter(p -> Objects.equals(p.getUserNo(), userNo)).findFirst().orElse(null);
|
|
|
+ if (ObjUtil.isNotNull(vo)) {
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|
|
|
- return vo;
|
|
|
+
|
|
|
+ PtUserAccountBo bo = new PtUserAccountBo();
|
|
|
+ bo.setUserNo(userNo);
|
|
|
+ return this.selectVoOneByBo(bo);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public PtUserAccountVo getUserAccountVoByUserNumb(String userNumb) {
|
|
|
+ PtUserAccountVo vo;
|
|
|
+ List<PtUserAccountVo> redisList = RedisUtils.getCacheList(CacheNames.PT_USER_ACCOUNT);
|
|
|
+
|
|
|
+ if (ObjUtil.isNotNull(redisList) && !redisList.isEmpty()) {
|
|
|
+ vo = redisList.stream().filter(p -> Objects.equals(p.getUserNumb(), userNumb)).findFirst().orElse(null);
|
|
|
+ if (ObjUtil.isNotNull(vo)) {
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PtUserAccountBo bo = new PtUserAccountBo();
|
|
|
+ bo.setUserNumb(userNumb);
|
|
|
+ return this.selectVoOneByBo(bo);
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public PtUserAccountVo selectVoOneByBo(PtUserAccountBo bo) {
|
|
|
+ List<PtUserAccountVo> list = this.queryList(bo);
|
|
|
+ if (ObjectUtil.isNotEmpty(list) && !list.isEmpty()) {
|
|
|
+ PtUserAccountVo vo = list.get(0);
|
|
|
+ if (vo != null) {
|
|
|
+ String deptName = remoteDeptService.selectDeptNameByIds(vo.getDeptId().toString());
|
|
|
+ vo.setDeptName(deptName);
|
|
|
+
|
|
|
+ RedisUtils.addCacheList(CacheNames.PT_USER_ACCOUNT, vo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- public static void downloadPicture(String urlList,String name,String userNumb) {
|
|
|
+ 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);
|
|
|
+ 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("."));
|
|
|
+ String imageName = "C:\\Users\\LENOVO\\Desktop\\img\\" + name + "_" + userNumb + urlList.substring(urlList.lastIndexOf("."));
|
|
|
|
|
|
FileOutputStream fileOutputStream = new FileOutputStream(new File(imageName));
|
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
@@ -483,7 +546,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
while ((length = dataInputStream.read(buffer)) > 0) {
|
|
|
output.write(buffer, 0, length);
|
|
|
}
|
|
|
- byte[] context=output.toByteArray();
|
|
|
+ byte[] context = output.toByteArray();
|
|
|
fileOutputStream.write(output.toByteArray());
|
|
|
dataInputStream.close();
|
|
|
fileOutputStream.close();
|
|
|
@@ -494,7 +557,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static class ImageData{
|
|
|
+ public static class ImageData {
|
|
|
private String url;
|
|
|
private String name;
|
|
|
|
|
|
@@ -507,33 +570,33 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static List<ImageData> parseTxt(String filePath){
|
|
|
- return FileUtils.readLines(filePath, Charset.defaultCharset()).stream().map(line->{
|
|
|
+ public static List<ImageData> parseTxt(String filePath) {
|
|
|
+ return FileUtils.readLines(filePath, Charset.defaultCharset()).stream().map(line -> {
|
|
|
String[] split = line.split("\\|");
|
|
|
- if(split.length!=3){
|
|
|
+ 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);
|
|
|
+ return new ImageData(url, name, userNumb);
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
//使用 http form-data方式上传图片,使用hutool工具包
|
|
|
- public static String uploadImage(String userNumb,String name) throws IOException {
|
|
|
+ public static String uploadImage(String userNumb, String name) throws IOException {
|
|
|
//使用 http form-data方式上传图片,使用hutool工具包
|
|
|
- String imagePath = "C:\\Users\\LENOVO\\Desktop\\img\\"+name+"_"+userNumb+".jpg";
|
|
|
+ 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+" "+"照片不存在";
|
|
|
+ if (!file.exists() || length <= 0) {
|
|
|
+ System.err.println(userNumb + " " + name + " " + "照片不存在 " + imagePath);
|
|
|
+ return "error: " + userNumb + " " + name + " " + "照片不存在";
|
|
|
}
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
+ 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}";
|
|
|
+ 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)
|
|
|
@@ -542,10 +605,10 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
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);
|
|
|
+ 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";
|
|
|
@@ -567,7 +630,7 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
list = parseTxt("C:\\Users\\LENOVO\\Desktop\\userdata.txt");
|
|
|
|
|
|
for (ImageData imageData : list) {
|
|
|
- uploadImage(imageData.userNumb,imageData.name);
|
|
|
+ uploadImage(imageData.userNumb, imageData.name);
|
|
|
}
|
|
|
|
|
|
|