薪酬报表与解密方法

This commit is contained in:
钱涛 2022-07-13 13:55:31 +08:00
parent 1d5c69278f
commit bb8c863bcc
3 changed files with 42 additions and 77 deletions

View File

@ -6,15 +6,18 @@ import weaver.general.BaseBean;
public class AESEncryptUtil {
static BaseBean bb = new BaseBean();
static String aesEncryptScrect = bb.getPropValue("hrmSalary", "AESEncryptScrect");
/**
* AES加密
*
* @param source 原始数据
* @return 加密数据
*/
public static String encrypt(String source) {
BaseBean bb = new BaseBean();
String aesEncryptScrect = bb.getPropValue("hrmSalary", "AESEncryptScrect");
if(StringUtils.isNotBlank(source)) {
if (StringUtils.isNotBlank(source)) {
return AES.encrypt(source, aesEncryptScrect);
}
return source;
@ -22,13 +25,12 @@ public class AESEncryptUtil {
/**
* AES解密
*
* @param encryptStr 加密字符串
* @return 解密字符串
*/
public static String decrypt(String encryptStr) {
BaseBean bb = new BaseBean();
String aesEncryptScrect = bb.getPropValue("hrmSalary", "AESEncryptScrect");
if(StringUtils.isNotBlank(encryptStr)) {
if (StringUtils.isNotBlank(encryptStr)) {
return AES.decrypt(encryptStr, aesEncryptScrect);
}
return encryptStr;

View File

@ -0,0 +1,34 @@
package com.engine.salary.util.report;
import com.engine.salary.encrypt.AESEncryptUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class SalaryReportUtil {
/**
* 薪酬解密方法
*
* @param s 待解密字符串集合
* @return 解密字符集合
*/
public static List<String> decrypt(List<String> s) {
if (s != null) {
return s.stream().map(AESEncryptUtil::decrypt).collect(Collectors.toList());
}
return new ArrayList<>();
}
/**
* 薪酬解密方法
*
* @param s 待解密字符串
* @return 解密字符
*/
public static String decrypt(String s) {
return AESEncryptUtil.decrypt(s);
}
}

View File

@ -1,71 +0,0 @@
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
public class demo {
public static void main(String[] args) {
//全天会议可用的时间点900-1800每15min
List<LocalTime> allTime = new ArrayList() {{
//初始化全天可用的时间点集合可以仿照下面splitTimeRange()写个
add(LocalTime.of(9, 0));
add(LocalTime.of(9, 15));
add(LocalTime.of(9, 30));
add(LocalTime.of(9, 45));
add(LocalTime.of(10, 0));
//.....
add(LocalTime.of(17, 45));
add(LocalTime.of(18, 0));
}};
//占用的时间点从数据库里查的
List<String> takeUpStringList = new ArrayList(){{
}};
List<LocalTime> takeUpTimeList = takeUpStringList.stream().map(LocalTime::parse).collect(Collectors.toList());
//比较两个时间点数组将全天的时间点分割
List<Integer> indexList = new ArrayList<>();
for (int i = 0; i < allTime.size(); i++) {
//比较
for (int j = 0; j < takeUpTimeList.size(); j++) {
if (allTime.get(i).equals(takeUpTimeList.get(j))) {
indexList.add(i);
}
}
}
//按indexList下标分割allTime获取list
List<List<LocalTime>> list = new ArrayList<>();
for (int i = 0; i < indexList.size(); i++) {
if (indexList.get(i) != 0 && (i + 1) != indexList.size()) {
list.add(allTime.subList(indexList.get(i), indexList.get(i + 1)));
} else {
list.add(allTime.subList(0, indexList.get(i)));
}
}
//获取超出1小时的时间段就是集合里时间点大于等于5的集合
//取出集合返回接口要求可能就是返回时间-时间取集合第一个-集合末尾
}
private static void splitTimeRange() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");//设置时间格式
Date end = new Date();
Date start = new Date();
List<String> list = new ArrayList<String>();//用来接收划分后的时间
//进行循环将时间按照分钟进行划分
for (Date i = start; i.before(end); ) {
list.add(simpleDateFormat.format(i));
i.setMinutes(i.getMinutes() + 1);
}
}
}