Administrator
2022-04-27 8e6f6217e52a635d1dfd4ccbb549b0427d3f9fa6
新增保安员新增审查
4 files modified
1 files added
236 ■■■■■ changed files
src/main/java/org/springblade/Application.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/DesensitizedUtil.java 125 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/DataHanlder.java 14 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/FtpUtil.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/MyAsyncService.java 88 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/Application.java
@@ -19,6 +19,7 @@
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.launch.BladeApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
 * 启动器
@@ -27,6 +28,7 @@
 */
@EnableScheduling
@SpringBootApplication
@EnableAsync
public class Application{
    public static void main(String[] args) {
src/main/java/org/springblade/common/utils/DesensitizedUtil.java
New file
@@ -0,0 +1,125 @@
package org.springblade.common.utils;
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * 铭感信息处理
 * @author zhongrj
 * @since 2022-04-27
 */
public class DesensitizedUtil {
    /**
     * 姓名脱敏处理
     * @param fullName
     * @return
     */
    public static String desensitizedName(String fullName){
        if (!Strings.isNullOrEmpty(fullName)) {
            String name = StringUtils.left(fullName, 1);
            return StringUtils.rightPad(name, StringUtils.length(fullName), "*");
        }
        return fullName;
    }
    /**
     * 手机号脱敏处理
     * @param phoneNumber
     * @return
     */
    public static String desensitizedPhoneNumber(String phoneNumber){
        if(StringUtils.isNotEmpty(phoneNumber)){
            phoneNumber = phoneNumber.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
        }
        return phoneNumber;
    }
    /**
     * 身份证号码脱敏处理
     * @param idNumber
     * @return
     */
    public static String desensitizedIdNumber(String idNumber){
        if (!Strings.isNullOrEmpty(idNumber)) {
            if (idNumber.length() == 15){
                idNumber = idNumber.replaceAll("(\\w{6})\\w*(\\w{3})", "$1******$2");
            }
            if (idNumber.length() == 18){
                idNumber = idNumber.replaceAll("(\\w{6})\\w*(\\w{3})", "$1*********$2");
            }
        }
        return idNumber;
    }
    /**
     * 保安证编号
     * @param securityNumber
     * @return
     */
    public static String desensitizedSecurityNumber(String securityNumber){
        if (!Strings.isNullOrEmpty(securityNumber)) {
            //分割
            String s = securityNumber.substring(0, securityNumber.length() - 4);
            String s2 = s.replaceAll("\\D", "*");
            //替换数字
            Pattern p = Pattern.compile("[\\d]");
            Matcher matcher = p.matcher(s2);
            String s3 = matcher.replaceAll("*");
            //保留后4位
            String s1 = securityNumber.substring(securityNumber.length() - 4);
            securityNumber = s3 + s1;
        }
        return securityNumber;
    }
    /**
     * 身份证号码脱敏处理(只保留后4位)
     * @param idNumber
     * @return
     */
    public static String desensitizedIdNumberBy4(String idNumber){
        if (!Strings.isNullOrEmpty(idNumber)) {
            if (idNumber.length() == 15){
                idNumber = idNumber.replaceAll("\\w*(\\w{4})", "***********$1");
            }
            if (idNumber.length() == 18){
                idNumber = idNumber.replaceAll("\\w*(\\w{4})", "**************$1");
            }
        }
        return idNumber;
    }
    /**
     * 地址
     * @param address
     * @return
     */
    public static String desensitizedAddress(String address){
        if (!Strings.isNullOrEmpty(address)) {
            return StringUtils.left(address, 3).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(address, address.length()-11), StringUtils.length(address), "*"), "***"));
        }
        return address;
    }
    public static void main(String[] args) {
        desensitizedIdNumberBy4("360728199205280059");
        desensitizedSecurityNumber("赣洪202100124");
        Map<String, Object> map = new HashMap<>(1);
        String a = "sdafa-445sdaf-fsafdsaf";
        map.put(a,"abc");
        System.out.println("map = " + map);
        Object o = map.get(a);
        System.out.println("o = " + o);
    }
}
src/main/java/org/springblade/modules/FTP/DataHanlder.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import liquibase.pro.packaged.M;
import org.springblade.common.utils.DesensitizedUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.modules.dispatcher.entity.Dispatcher;
@@ -77,15 +78,19 @@
            String uuid = user1.getReasonForLeav();
            //用户数据校验
            Result result = userCheckOut(user1);
            System.out.println("result = " + result);
            //创建返回对象
            Result result1 = new Result();
            if (result.getCode()==200){
                user1.setReasonForLeav("");
                //校验保安员证编号
                Result result2 = hanlder.checkSecurityNumber(user1);
                User user2 = result2.getUser();
                //去新增
                hanlder.userService.save(result2.getUser());
                boolean save = hanlder.userService.save(user2);
                if (save){
                    //异步审查
                    hanlder.myAsyncService.checkUserExamineByCardNo(user2);
                }
                if (result2.getCode()==200){
                    //设置返回结果
@@ -238,6 +243,9 @@
            //新增
            experienceService.save(experience);
            // 身份证号脱敏
            String cardid = DesensitizedUtil.desensitizedIdNumberBy4(user.getCardid());
            //内网同步
            String s = "insert into sys_experience(id,name,entryTime,departureTime,leaving,cardId,companyname,securityId) " +
                "values(" + "'" + experience.getId() + "'" + "," +
@@ -245,7 +253,7 @@
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" +
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getDeparturetime()) + "'" +
                "," + "'" + experience.getLeaving() + "'" +
                "," + "'" + experience.getCardid() + "'" +
                "," + "'" + cardid + "'" +
                "," + "'" + experience.getCompanyname() + "'" +
                "," + "'" + experience.getSecurityid() + "'"
                + ")";
src/main/java/org/springblade/modules/FTP/FtpUtil.java
@@ -295,14 +295,15 @@
    public static void sqlFileUpload(String s1){
        String json1 = JSON.toJSONString(s1);
        String response1 = String.valueOf((new Date()).getTime());
        OutJson.createJsonFile(json1, localPath, "n"+response1);
        OutJson.createJsonFile(json1, localPath, "nsql"+response1);
        FileInputStream in1 = null;
        try {
            in1 = new FileInputStream(new File(localPath + "n"+response1+".json"));
            in1 = new FileInputStream(new File(localPath + "nsql"+response1+".json"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "n"+response1+".json", in1);
        FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "nsql"+response1+".json", in1);
//        MysqlCenlint.deletess("nsql"+response1+".json");
    }
    /**
     *
src/main/java/org/springblade/modules/FTP/MyAsyncService.java
@@ -1,12 +1,28 @@
package org.springblade.modules.FTP;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springblade.common.utils.InvestigateUtil;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.Date;
/**
 * @author Administrator
 */
@Service
public class MyAsyncService {
    @Autowired
    private IUserService userService;
    /**
     * FTP
     * @param s sql语句
@@ -15,4 +31,76 @@
        FtpUtil.sqlFileUpload(s);
    }
    /**
     * 异步审查新增的保安员
     * @param user0
     */
    @Async
    public void checkUserExamineByCardNo(User user0){
        User byId = userService.getById(user0.getId());
        //如果是保安员
        if (user0.getRoleId().equals("1412226235153731586")){
            //读取身份证号
            String cardid = user0.getCardid();
            //创建用户对象
            User user = new User();
            user.setId(user.getId());
            //远程调用接口
            String body = InvestigateUtil.httpGetOne(user0.getCardid());
            JSONObject jsonObject = new JSONObject(body);
            Object data = jsonObject.get("data");
            JSONObject jsonData = new JSONObject(data.toString());
            JSONArray res = jsonData.getJSONArray("res");
            //设置审核时间
            user.setAuditTime(new Date());
            if (res.length() == 0) {
                //没有数据正常
                user.setExaminationType("0");
            } else {
                int count = 0;
                user.setExaminationType("1");
                for (int i = 0; i < res.length(); i++) {
                    if (res.getJSONObject(i).get("zdrylbjh").toString() != null
                        && res.getJSONObject(i).get("zdrylbjh").toString() != ""
                        && res.getJSONObject(i).get("zdrylbjh").toString() != "null"
                    ) {
                        user.setExaminationMx(res.getJSONObject(i).get("zdrylbjh").toString());
                        //更新用户数据
                        userService.updateById(user);
                        break;
                    }
                    if (res.getJSONObject(i).get("zdryxlmc").toString() != null
                        && res.getJSONObject(i).get("zdryxlmc").toString() != ""
                        && res.getJSONObject(i).get("zdryxlmc").toString() != "null"
                    ) {
                        user.setExaminationMx(res.getJSONObject(i).get("zdryxlmc").toString());
                        //更新用户数据
                        userService.updateById(user);
                        break;
                    }
                    if (res.getJSONObject(i).get("ztrylx").toString() != null
                        && res.getJSONObject(i).get("ztrylx").toString() != ""
                        && res.getJSONObject(i).get("ztrylx").toString() != "null"
                    ) {
                        user.setExaminationMx(res.getJSONObject(i).get("ztrylx").toString());
                        //更新用户数据
                        userService.updateById(user);
                        break;
                    }
                    count++;
                    //条件中的数据都为空,则审查为正常
                    if (count==res.length()){
                        //更新用户数据,设为正常
                        user.setExaminationType("0");
                        userService.updateById(user);
                    }
                }
            }
            //更新用户数据
            userService.updateById(user);
        }
    }
}