ES--身份证判断性别

版权声明:商业用途请联系博主,非商业转载请标明出处。 https://blog.csdn.net/qq_15807167/article/details/86723274

身份证性别是身份证号的第17位,奇数为男 偶数为女

ES脚本

  int type = params.sexType;
                                boolean isStart = params.isStart;
                                if(!isStart){
                                    return true;
                                }
                                String keys =  doc['keys'].value;
                                if(keys.length() != 18)
                                    return true;
                                String sexId =keys.substring(16, 17);
                                int number = Integer.parseInt(sexId);
                                int result = number % 2;
                                if(type == 1 && result != 0){
                                    return true;
                                }else if(type == 0 && result == 0){
                                    return true;
                                }
                                return false;

猜你喜欢

转载自blog.csdn.net/qq_15807167/article/details/86723274