Java Code Examples for com.ruoyi.common.utils.StringUtils#substring()

The following examples show how to use com.ruoyi.common.utils.StringUtils#substring() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenUtils.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 获取模块名
 * 
 * @param packageName 包名
 * @return 模块名
 */
public static String getModuleName(String packageName)
{
    int lastIndex = packageName.lastIndexOf(".");
    int nameLength = packageName.length();
    String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
    return moduleName;
}
 
Example 2
Source File: GenUtils.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 获取业务名
 * 
 * @param tableName 表名
 * @return 业务名
 */
public static String getBusinessName(String tableName)
{
    int lastIndex = tableName.lastIndexOf("_");
    int nameLength = tableName.length();
    String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
    return businessName;
}
 
Example 3
Source File: VelocityUtils.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 获取包前缀
 * 
 * @param packageName 包名称
 * @return 包前缀名称
 */
public static String getPackagePrefix(String packageName)
{
    int lastIndex = packageName.lastIndexOf(".");
    String basePackage = StringUtils.substring(packageName, 0, lastIndex);
    return basePackage;
}
 
Example 4
Source File: FileUploadUtils.java    From supplierShop with MIT License 5 votes vote down vote up
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
{
    int dirLastIndex = uploadDir.lastIndexOf("/") + 1;
    String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
    String pathFileName = "/profile/" + currentDir + "/" + fileName;
    return pathFileName;
}
 
Example 5
Source File: AbstractQuartzJob.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 执行后
 *
 * @param context 工作执行上下文对象
 * @param sysScheduleJob 系统计划任务
 */
protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
{
    Date startTime = threadLocal.get();
    threadLocal.remove();

    final SysJobLog sysJobLog = new SysJobLog();
    sysJobLog.setJobName(sysJob.getJobName());
    sysJobLog.setJobGroup(sysJob.getJobGroup());
    sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
    sysJobLog.setStartTime(startTime);
    sysJobLog.setEndTime(new Date());
    long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime();
    sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
    if (e != null)
    {
        sysJobLog.setStatus(Constants.FAIL);
        String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
        sysJobLog.setExceptionInfo(errorMsg);
    }
    else
    {
        sysJobLog.setStatus(Constants.SUCCESS);
    }

    // 写入数据库当中
    SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}
 
Example 6
Source File: GenUtils.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 获取模块名
 * 
 * @param packageName 包名
 * @return 模块名
 */
public static String getModuleName(String packageName)
{
    int lastIndex = packageName.lastIndexOf(".");
    int nameLength = packageName.length();
    String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
    return moduleName;
}
 
Example 7
Source File: GenUtils.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 获取业务名
 * 
 * @param tableName 表名
 * @return 业务名
 */
public static String getBusinessName(String tableName)
{
    int lastIndex = tableName.lastIndexOf("_");
    int nameLength = tableName.length();
    String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
    return businessName;
}
 
Example 8
Source File: VelocityUtils.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 获取包前缀
 * 
 * @param packageName 包名称
 * @return 包前缀名称
 */
public static String getPackagePrefix(String packageName)
{
    int lastIndex = packageName.lastIndexOf(".");
    String basePackage = StringUtils.substring(packageName, 0, lastIndex);
    return basePackage;
}
 
Example 9
Source File: AbstractQuartzJob.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 执行后
 *
 * @param context 工作执行上下文对象
 * @param sysScheduleJob 系统计划任务
 */
protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
{
    Date startTime = threadLocal.get();
    threadLocal.remove();

    final SysJobLog sysJobLog = new SysJobLog();
    sysJobLog.setJobName(sysJob.getJobName());
    sysJobLog.setJobGroup(sysJob.getJobGroup());
    sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
    sysJobLog.setStartTime(startTime);
    sysJobLog.setStopTime(new Date());
    long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
    sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
    if (e != null)
    {
        sysJobLog.setStatus(Constants.FAIL);
        String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
        sysJobLog.setExceptionInfo(errorMsg);
    }
    else
    {
        sysJobLog.setStatus(Constants.SUCCESS);
    }

    // 写入数据库当中
    SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}
 
Example 10
Source File: FileUploadUtils.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
{
    int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
    String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
    String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
    return pathFileName;
}
 
Example 11
Source File: GenUtils.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 获取模块名
 * 
 * @param packageName 包名
 * @return 模块名
 */
public static String getModuleName(String packageName)
{
    int lastIndex = packageName.lastIndexOf(".");
    int nameLength = packageName.length();
    String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
    return moduleName;
}
 
Example 12
Source File: GenUtils.java    From ruoyiplus with MIT License 4 votes vote down vote up
public static String getBasePackage(String packageName)
{
    int lastIndex = packageName.lastIndexOf(".");
    String basePackage = StringUtils.substring(packageName, 0, lastIndex);
    return basePackage;
}