初始化
This commit is contained in:
@ -0,0 +1,70 @@
|
||||
package com.ruoyi.jd.task;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.CodeConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.exception.ImportException;
|
||||
import com.ruoyi.common.utils.IpUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.system.mapper.CommonAttachmentMapper;
|
||||
import com.ruoyi.system.service.ICommonAttachmentService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 排队导入
|
||||
* @Description TODO
|
||||
* @Author maj
|
||||
* @Date 2021/5/2 21:13
|
||||
*/
|
||||
@Component
|
||||
public class QueueUploadTask {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public void queueUploadFile() throws ParseException {
|
||||
String ip = IpUtils.getInnetIp();
|
||||
logger.info("--------------排队机制导入文件---------------开始:{}", ip);
|
||||
int idMod = 0;
|
||||
// switch (ip) {
|
||||
// case CodeConstants.IP_25: {
|
||||
// idMod = 0;
|
||||
// break;
|
||||
// }case CodeConstants.IP_26: {
|
||||
// idMod = 2;
|
||||
// break;
|
||||
// }case CodeConstants.IP_28: {
|
||||
// idMod = 4;
|
||||
// break;
|
||||
// }case CodeConstants.IP_29: {
|
||||
// idMod = 6;
|
||||
// break;
|
||||
// } default:idMod = 8;
|
||||
// }
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
while (true) {
|
||||
if(true){
|
||||
try {
|
||||
logger.info("--------------睡眠10分钟之后再次查询--------------");
|
||||
Thread.sleep(1000*60*10);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("睡眠抛异常",e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
265
ruoyi-admin/src/main/java/com/ruoyi/jd/utils/BlankUtils.java
Normal file
265
ruoyi-admin/src/main/java/com/ruoyi/jd/utils/BlankUtils.java
Normal file
@ -0,0 +1,265 @@
|
||||
package com.ruoyi.jd.utils;
|
||||
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysAreaHn;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author maj
|
||||
* @Date 2021/3/29 20:40
|
||||
*/
|
||||
public class BlankUtils {
|
||||
|
||||
|
||||
public static <U> Map industryBlank(Class<U> clazz, U cla, StringBuilder failureMsg, List<SysAreaHn> areaList, SysAreaHn company) {
|
||||
Map map = new HashMap();
|
||||
//将传过来的对象进行赋值处理,
|
||||
//此时u可用来代表传过来的对象(本示意中是Users),
|
||||
//此时可以用u调用传过来对象的方法
|
||||
U u = clazz.cast(cla);
|
||||
//以下是验证此示意中实体类可被操作了
|
||||
//getDeclaredFields():获得某个类的所有声明的字段,即包括public、private和proteced,但是不包括父类的申明字段。
|
||||
//.getClass()是一个对象实例的方法,只有对象实例才有这个方法,具体的类是没有的
|
||||
String cityNameStr = "怀化市";
|
||||
String districtNameStr = company.getName();
|
||||
String townNameStr = null;
|
||||
String villageNameStr = null;
|
||||
String townCodeStr = null;
|
||||
|
||||
try {
|
||||
Field cityName = u.getClass().getDeclaredField("cityName");
|
||||
cityName.setAccessible(true);
|
||||
cityName.set(u, cityNameStr);
|
||||
// System.out.println(cityName.getName()+":::"+String.valueOf(cityName.get(u)));
|
||||
|
||||
Field districtName = u.getClass().getDeclaredField("districtName");
|
||||
districtName.setAccessible(true);
|
||||
districtName.set(u, districtNameStr);
|
||||
// System.out.println(districtName.getName()+":::"+String.valueOf(districtName.get(u)));
|
||||
|
||||
Field townName = u.getClass().getDeclaredField("townName");
|
||||
townName.setAccessible(true);
|
||||
townNameStr = (String) townName.get(u);
|
||||
// System.out.println(townName.getName()+":::"+String.valueOf(townName.get(u)));
|
||||
|
||||
Field villageName = u.getClass().getDeclaredField("villageName");
|
||||
villageName.setAccessible(true);
|
||||
villageNameStr = (String) villageName.get(u);
|
||||
// System.out.println(villageName.getName()+":::"+String.valueOf(villageName.get(u)));
|
||||
|
||||
Field cityCode = u.getClass().getDeclaredField("cityCode");
|
||||
cityCode.setAccessible(true);
|
||||
cityCode.set(u, company.getParentCode());
|
||||
// System.out.println(cityCode.getName()+":::"+String.valueOf(cityCode.get(u)));
|
||||
|
||||
Field districtCode = u.getClass().getDeclaredField("districtCode");
|
||||
districtCode.setAccessible(true);
|
||||
districtCode.set(u, company.getAreaCode());
|
||||
|
||||
Field townCode = u.getClass().getDeclaredField("townCode");
|
||||
townCode.setAccessible(true);
|
||||
// 乡镇
|
||||
if (StringUtils.isBlank(townNameStr)) {
|
||||
failureMsg.append("乡镇栏不能为空;");
|
||||
} else {
|
||||
String finalTownName = townNameStr.trim();
|
||||
Optional<SysAreaHn> areaOpt = areaList.stream()
|
||||
.filter(s -> finalTownName.equals(s.getName()))
|
||||
.filter(s -> s.getParentCode().equals(company.getAreaCode()))
|
||||
.findFirst();
|
||||
if (areaOpt.isPresent()) {
|
||||
townCode.set(u, areaOpt.get().getAreaCode());
|
||||
townCodeStr = areaOpt.get().getAreaCode();
|
||||
} else {
|
||||
failureMsg.append("名为" + finalTownName + "的乡镇不存在系统中;");
|
||||
}
|
||||
}
|
||||
|
||||
//如果镇级编码不为空则去验证村
|
||||
if (StringUtils.isNotBlank(townCodeStr)) {
|
||||
Field villageCode = u.getClass().getDeclaredField("villageCode");
|
||||
villageCode.setAccessible(true);
|
||||
// 村
|
||||
if (StringUtils.isBlank(villageNameStr)) {
|
||||
failureMsg.append("村栏不能为空;");
|
||||
} else {
|
||||
String finalVillageName = villageNameStr.trim();
|
||||
String finalTownCode = StringUtils.isBlank(townCodeStr) ? "" : townCodeStr.trim();
|
||||
Optional<SysAreaHn> areaOpt = areaList.stream()
|
||||
.filter(s -> finalVillageName.equals(s.getName()))
|
||||
.filter(s -> s.getParentCode().equals(finalTownCode))
|
||||
.findFirst();
|
||||
if (areaOpt.isPresent()) {
|
||||
villageCode.set(u, areaOpt.get().getAreaCode());
|
||||
} else {
|
||||
failureMsg.append("名为" + finalVillageName + "的村不存在系统中;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Field name = u.getClass().getDeclaredField("name");
|
||||
name.setAccessible(true);
|
||||
String nameStr = (String) name.get(u);
|
||||
if (StringUtils.isBlank(nameStr)) {
|
||||
failureMsg.append("姓名栏不能为空;");
|
||||
}
|
||||
|
||||
Field certificatesNo = u.getClass().getDeclaredField("certificatesNo");
|
||||
certificatesNo.setAccessible(true);
|
||||
String certificatesNoStr = (String) certificatesNo.get(u);
|
||||
if (StringUtils.isBlank(certificatesNoStr)) {
|
||||
failureMsg.append("身份证栏不能为空;");
|
||||
} else if (certificatesNoStr.trim().length() < 18) {
|
||||
failureMsg.append("身份证栏长度少于18位;");
|
||||
}
|
||||
|
||||
//校验金额
|
||||
Field money = u.getClass().getDeclaredField("money");
|
||||
money.setAccessible(true);
|
||||
String moneyStr = (String) money.get(u);
|
||||
if (StringUtils.isBlank(moneyStr)) {
|
||||
failureMsg.append("金额不能为空;");
|
||||
} else if (!validMoneyFormat(moneyStr)) {
|
||||
failureMsg.append("金额错误;");
|
||||
}
|
||||
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
map.put("u", u);
|
||||
map.put("msg", failureMsg);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <U> Map industryBlank2(Class<U> clazz, U cla, StringBuilder failureMsg, List<SysAreaHn> areaList, SysAreaHn company) {
|
||||
Map map = new HashMap();
|
||||
//将传过来的对象进行赋值处理,
|
||||
//此时u可用来代表传过来的对象(本示意中是Users),
|
||||
//此时可以用u调用传过来对象的方法
|
||||
U u = clazz.cast(cla);
|
||||
//以下是验证此示意中实体类可被操作了
|
||||
//getDeclaredFields():获得某个类的所有声明的字段,即包括public、private和proteced,但是不包括父类的申明字段。
|
||||
//.getClass()是一个对象实例的方法,只有对象实例才有这个方法,具体的类是没有的
|
||||
String cityNameStr = "怀化市";
|
||||
String districtNameStr = company.getName();
|
||||
String townNameStr = null;
|
||||
String villageNameStr = null;
|
||||
String townCodeStr = null;
|
||||
|
||||
try {
|
||||
Field cityName = u.getClass().getDeclaredField("cityName");
|
||||
cityName.setAccessible(true);
|
||||
cityName.set(u, cityNameStr);
|
||||
// System.out.println(cityName.getName()+":::"+String.valueOf(cityName.get(u)));
|
||||
|
||||
Field districtName = u.getClass().getDeclaredField("districtName");
|
||||
districtName.setAccessible(true);
|
||||
districtName.set(u, districtNameStr);
|
||||
// System.out.println(districtName.getName()+":::"+String.valueOf(districtName.get(u)));
|
||||
|
||||
Field townName = u.getClass().getDeclaredField("townName");
|
||||
townName.setAccessible(true);
|
||||
townNameStr = (String) townName.get(u);
|
||||
// System.out.println(townName.getName()+":::"+String.valueOf(townName.get(u)));
|
||||
|
||||
Field villageName = u.getClass().getDeclaredField("villageName");
|
||||
villageName.setAccessible(true);
|
||||
villageNameStr = (String) villageName.get(u);
|
||||
// System.out.println(villageName.getName()+":::"+String.valueOf(villageName.get(u)));
|
||||
|
||||
Field cityCode = u.getClass().getDeclaredField("cityCode");
|
||||
cityCode.setAccessible(true);
|
||||
cityCode.set(u, company.getParentCode());
|
||||
// System.out.println(cityCode.getName()+":::"+String.valueOf(cityCode.get(u)));
|
||||
|
||||
Field districtCode = u.getClass().getDeclaredField("districtCode");
|
||||
districtCode.setAccessible(true);
|
||||
districtCode.set(u, company.getAreaCode());
|
||||
|
||||
Field townCode = u.getClass().getDeclaredField("townCode");
|
||||
townCode.setAccessible(true);
|
||||
// 乡镇
|
||||
if (StringUtils.isBlank(townNameStr)) {
|
||||
failureMsg.append("乡镇栏不能为空;");
|
||||
} else {
|
||||
String finalTownName = townNameStr.trim();
|
||||
Optional<SysAreaHn> areaOpt = areaList.stream()
|
||||
.filter(s -> finalTownName.equals(s.getName()))
|
||||
.filter(s -> s.getParentCode().equals(company.getAreaCode()))
|
||||
.findFirst();
|
||||
if (areaOpt.isPresent()) {
|
||||
townCode.set(u, areaOpt.get().getAreaCode());
|
||||
townCodeStr = areaOpt.get().getAreaCode();
|
||||
} else {
|
||||
failureMsg.append("名为" + finalTownName + "的乡镇不存在系统中;");
|
||||
}
|
||||
}
|
||||
|
||||
//如果镇级编码不为空则去验证村
|
||||
if (StringUtils.isNotBlank(townCodeStr)) {
|
||||
Field villageCode = u.getClass().getDeclaredField("villageCode");
|
||||
villageCode.setAccessible(true);
|
||||
// 村
|
||||
if (StringUtils.isBlank(villageNameStr)) {
|
||||
failureMsg.append("村栏不能为空;");
|
||||
} else {
|
||||
String finalVillageName = villageNameStr.trim();
|
||||
String finalTownCode = StringUtils.isBlank(townCodeStr) ? "" : townCodeStr.trim();
|
||||
Optional<SysAreaHn> areaOpt = areaList.stream()
|
||||
.filter(s -> finalVillageName.equals(s.getName()))
|
||||
.filter(s -> s.getParentCode().equals(finalTownCode))
|
||||
.findFirst();
|
||||
if (areaOpt.isPresent()) {
|
||||
villageCode.set(u, areaOpt.get().getAreaCode());
|
||||
} else {
|
||||
failureMsg.append("名为" + finalVillageName + "的村不存在系统中;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Field name = u.getClass().getDeclaredField("name");
|
||||
name.setAccessible(true);
|
||||
String nameStr = (String) name.get(u);
|
||||
if (StringUtils.isBlank(nameStr)) {
|
||||
failureMsg.append("姓名栏不能为空;");
|
||||
}
|
||||
|
||||
Field certificatesNo = u.getClass().getDeclaredField("certificatesNo");
|
||||
certificatesNo.setAccessible(true);
|
||||
String certificatesNoStr = (String) certificatesNo.get(u);
|
||||
if (StringUtils.isBlank(certificatesNoStr)) {
|
||||
failureMsg.append("证件号不能为空;");
|
||||
}
|
||||
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
map.put("u", u);
|
||||
map.put("msg", failureMsg);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验金额格式是否正确,不允许为负数
|
||||
*
|
||||
* @param money 金额
|
||||
*/
|
||||
public static boolean validMoneyFormat(String money) {
|
||||
// String regex ="^[+-]?(0|([1-9]\\d*))(\\.\\d+)?$";
|
||||
String regex = "^(0|([1-9]\\d*))(\\.\\d+)?$";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(money);
|
||||
return matcher.find();
|
||||
}
|
||||
}
|
||||
54
ruoyi-admin/src/main/java/com/ruoyi/jd/utils/CardUtils.java
Normal file
54
ruoyi-admin/src/main/java/com/ruoyi/jd/utils/CardUtils.java
Normal file
@ -0,0 +1,54 @@
|
||||
package com.ruoyi.jd.utils;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
public class CardUtils {
|
||||
/**
|
||||
* 身份证脱敏,保留前六后四
|
||||
* @param cardNumber
|
||||
* @return
|
||||
*/
|
||||
public static String desensitizationFirstSixLastFour(String cardNumber){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(StringUtils.isNotBlank(cardNumber) && cardNumber.length() >= 18){
|
||||
sb.append(cardNumber.substring(0,6));
|
||||
sb.append("********");
|
||||
sb.append(cardNumber.substring(14,18));
|
||||
return sb.toString();
|
||||
}else{
|
||||
return cardNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证脱敏,保留前六
|
||||
* @param cardNumber
|
||||
* @return
|
||||
*/
|
||||
public static String desensitizationFirstSix(String cardNumber){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(StringUtils.isNotBlank(cardNumber) && cardNumber.length() >= 18){
|
||||
sb.append(cardNumber.substring(0,6));
|
||||
sb.append("************");
|
||||
return sb.toString();
|
||||
}else{
|
||||
return cardNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证脱敏,保留后四
|
||||
* @param cardNumber
|
||||
* @return
|
||||
*/
|
||||
public static String desensitizationLastFour(String cardNumber){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(StringUtils.isNotBlank(cardNumber) && cardNumber.length() >= 18){
|
||||
sb.append(cardNumber.substring(0,14));
|
||||
sb.append("****");
|
||||
return sb.toString();
|
||||
}else{
|
||||
return cardNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user