| | |
| | | package org.springblade.modules.FTP; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import org.springblade.common.utils.DesensitizedUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * ftp 数据处理 |
| | |
| | | //申明对象 |
| | | private static DataHandler handler; |
| | | |
| | | /** |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | private MyAsyncService myAsyncService; |
| | | |
| | | |
| | | /** |
| | | * 初始化 |
| | | */ |
| | | @PostConstruct |
| | | public void init(){ |
| | | handler = this; |
| | | handler.userService = this.userService; |
| | | handler.redisTemplate = this.redisTemplate; |
| | | handler.myAsyncService = this.myAsyncService; |
| | | } |
| | | |
| | | /** |
| | | * 获取保安员证编号位数 |
| | | * @param json |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | public static Result handlerSecurityNumberBit(String json, String uuid) { |
| | | Map map = JSON.parseObject(json, Map.class); |
| | | //获取结果 |
| | | Object o = map.get(uuid); |
| | | if (null== o || o.equals("")){ |
| | | return new Result(400,null,"uuid 不匹配",null); |
| | | }else { |
| | | //转换 |
| | | Result result = JSON.parseObject(o.toString(), Result.class); |
| | | //返回 |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取数据 |
| | | * @param json |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | public static Result handlerList(String json, String uuid) { |
| | | Map map = JSON.parseObject(json, Map.class); |
| | | //获取结果 |
| | | Object o = map.get(uuid); |
| | | if (null== o || o.equals("")){ |
| | | return new Result(400,null,"uuid 不匹配",null); |
| | | }else { |
| | | //转换 |
| | | Result result = JSON.parseObject(o.toString(), Result.class); |
| | | //返回 |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param uuid 随机字符串 |
| | | * @return |
| | | */ |
| | | public static R handler(String json, String uuid){ |
| | | //读取数据 |
| | | List<String> list = Arrays.asList(json.split(";")); |
| | | list.forEach(s -> { |
| | | System.out.println("s = " + s); |
| | | }); |
| | | return R.data(400,null,"未能找到对应数据"); |
| | | public static Result handler(String json, String uuid){ |
| | | Map map = JSON.parseObject(json, Map.class); |
| | | //获取结果 |
| | | Object o = map.get(uuid); |
| | | if (null== o || o.equals("")){ |
| | | return new Result(400,null,"uuid 不匹配",null); |
| | | }else { |
| | | List<Result> list = new ArrayList<>(); |
| | | //转换 |
| | | Result result = JSON.parseObject(o.toString(), Result.class); |
| | | list.add(result); |
| | | //返回 |
| | | return new Result(200,null,list); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户数据获取和处理 |
| | | * @param uuid 随机参数 |
| | | * @return |
| | | */ |
| | | public static User handlerUserInfo(String uuid){ |
| | | User user2 = new User(); |
| | | //从redis 中获取用户数据 |
| | | Object o1 = handler.redisTemplate.opsForValue().get(uuid); |
| | | if (null!=o1){ |
| | | User user = JSON.parseObject(o1.toString(), User.class); |
| | | //取出后将 redis 删除 |
| | | handler.redisTemplate.delete(uuid); |
| | | //返回的user,需处理敏感数据 |
| | | User user1 = Objects.requireNonNull(BeanUtil.copy(user, User.class)); |
| | | //敏感数据处理 |
| | | user1.setRealName(DesensitizedUtil.desensitizedName(user.getRealName())); |
| | | user1.setCardid(DesensitizedUtil.desensitizedIdNumberBy4(user.getCardid())); |
| | | user1.setPhone(DesensitizedUtil.desensitizedPhoneNumber(user.getPhone())); |
| | | user1.setRegistered(DesensitizedUtil.desensitizedAddress(user.getRegistered())); |
| | | if (user.getHold().equals("1")) { |
| | | user1.setSecuritynumber(DesensitizedUtil.desensitizedSecurityNumber(user.getSecuritynumber())); |
| | | } else { |
| | | user1.setSecuritynumber(""); |
| | | } |
| | | user1.setAvatar(""); |
| | | user1.setEmail(""); |
| | | user1.setFingerprint(""); |
| | | user1.setNation(""); |
| | | user1.setNativeplace(""); |
| | | user1.setEducation(""); |
| | | user1.setPoliticaloutlook(""); |
| | | user1.setMyPicture(""); |
| | | user1.setHeight(""); |
| | | user1.setRtime(null); |
| | | //返回 |
| | | return user1; |
| | | } |
| | | //返回null |
| | | return user2; |
| | | } |
| | | } |