福利核算干预数据导入功能优化v2-针对单个保险种类的数值未填值时,默认取数据库中原有数值

This commit is contained in:
sy 2022-09-14 14:36:05 +08:00
parent 198075209e
commit a6028c51e7
1 changed files with 32 additions and 1 deletions

View File

@ -63,6 +63,8 @@ import weaver.hrm.User;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
@ -1377,15 +1379,44 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
*/
private Map<String, String> checkJsonMap(Map<String, String> newMap, String oldJson) {
Map<String, String> oldMap = JSON.parseObject(oldJson, HashMap.class);
//校验newMap中的value值是否为整数或者小数
for(Map.Entry<String, String> newEntry : newMap.entrySet()) {
String newValue = newEntry.getValue();
int l = newValue.length();
if (newValue.length() > 0 && !isNumeric(newValue)) {
throw new SalaryRunTimeException("请检查导入Excel中个人或单位对应的福利项数值是否为整数或小数");
}
}
//保留oldMap无变动数据更新newMap已变动数据
for (Map.Entry<String, String> oldEntry : oldMap.entrySet()) {
//保留无变动数据更新已变动数据
if (!newMap.containsKey(oldEntry.getKey())) {
newMap.put(oldEntry.getKey(), oldEntry.getValue());
} else if (newMap.containsKey(oldEntry.getKey()) && "".equals(newMap.get(oldEntry.getKey()))) {
newMap.put(oldEntry.getKey(), oldEntry.getValue());
}
}
return newMap;
}
/**
* 判断字符串是否为整数或者小数
*/
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*\\.?[0-9]+");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
return false;
}
return true;
}
/**
* 校验福利核算的账单月份输入格式是否正确
*/