拆分-日期校验修改
This commit is contained in:
+44
-13
@@ -1,15 +1,13 @@
|
|||||||
package com.jero.common.util;
|
package com.jero.common.util;
|
||||||
|
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类描述:时间操作定义类
|
* 类描述:时间操作定义类
|
||||||
@@ -647,7 +645,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|||||||
return calendar.get(Calendar.YEAR);
|
return calendar.get(Calendar.YEAR);
|
||||||
}
|
}
|
||||||
/***
|
/***
|
||||||
* @Description: 判断多个日期是否都符合日期格式
|
* @Description: 判断多个日期是否都符合日期格式 yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日
|
||||||
* @Author: yangxuenan
|
* @Author: yangxuenan
|
||||||
* @Date: 2020/12/31 11:31
|
* @Date: 2020/12/31 11:31
|
||||||
* @Param: [str]
|
* @Param: [str]
|
||||||
@@ -655,19 +653,52 @@ public class DateUtils extends PropertyEditorSupport {
|
|||||||
*/
|
*/
|
||||||
public static boolean isValidDate(String str){
|
public static boolean isValidDate(String str){
|
||||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(str)){
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(str)){
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
String dateRegex = "^\\d{4}年\\d{1,2}月\\d{1,2}日";
|
||||||
|
str = str.replace(",",",");
|
||||||
String[] strArr = str.split(",");
|
String[] strArr = str.split(",");
|
||||||
for (String dateStr : strArr) {
|
for (String dateStr : strArr) {
|
||||||
String replace = dateStr.replace("/", "-");
|
if(dateStr.matches(dateRegex)){
|
||||||
try {
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
||||||
simpleDateFormat.setLenient(false);
|
try {
|
||||||
simpleDateFormat.parse(replace);
|
simpleDateFormat.setLenient(false);
|
||||||
} catch (Exception e){
|
simpleDateFormat.parse(dateStr);
|
||||||
return false;
|
} catch (Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String replace = dateStr.replace("/", "-");
|
||||||
|
try {
|
||||||
|
simpleDateFormat.setLenient(false);
|
||||||
|
simpleDateFormat.parse(replace);
|
||||||
|
} catch (Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//yyyy年MM月dd日,yyyy/MM/dd 转 yyyy-MM-dd
|
||||||
|
public static String coverDate(String str) throws ParseException {
|
||||||
|
List<String> newStrList = new ArrayList<>();
|
||||||
|
String dateRegex = "^\\d{4}年\\d{1,2}月\\d{1,2}日";
|
||||||
|
str = str.replace(",",",");
|
||||||
|
String[] strArr = str.split(",");
|
||||||
|
for (String dateStr : strArr) {
|
||||||
|
String newStr = null;
|
||||||
|
if (dateStr.matches(dateRegex)) {
|
||||||
|
Date date = new SimpleDateFormat("yyyy年MM月dd日").parse(dateStr);
|
||||||
|
newStr = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
||||||
|
} else if (dateStr.contains("/")) {
|
||||||
|
Date date = new SimpleDateFormat("yyyy/MM/dd").parse(dateStr);
|
||||||
|
newStr = new SimpleDateFormat("yyyy-MM-dd").format(date);
|
||||||
|
} else if (dateStr.contains("-")){
|
||||||
|
newStr = dateStr;
|
||||||
|
}
|
||||||
|
newStrList.add(newStr);
|
||||||
|
}
|
||||||
|
return org.apache.commons.lang3.StringUtils.join(newStrList, ",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-4
@@ -539,11 +539,13 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
if(fieldPersonList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())) {
|
if(fieldPersonList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())) {
|
||||||
List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(entry.getValue().toString().split(",")));
|
List<SysUser> sysUserList = sysUserService.listByIds(Arrays.asList(entry.getValue().toString().split(",")));
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for(SysUser user : sysUserList){
|
if (CollectionUtil.isNotEmpty(sysUserList)) {
|
||||||
stringBuilder.append(user.getRealname()).append("(").append(user.getUsername()).append("),");
|
for (SysUser user : sysUserList) {
|
||||||
|
stringBuilder.append(user.getRealname()).append("(").append(user.getUsername()).append("),");
|
||||||
|
}
|
||||||
|
String value = stringBuilder.substring(0, stringBuilder.lastIndexOf(","));
|
||||||
|
entry.setValue(value);
|
||||||
}
|
}
|
||||||
String value = stringBuilder.substring(0, stringBuilder.lastIndexOf(","));
|
|
||||||
entry.setValue(value);
|
|
||||||
}
|
}
|
||||||
// 标准选择
|
// 标准选择
|
||||||
if(fieldStanList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())) {
|
if(fieldStanList.contains(entry.getKey()) && StringUtils.isNotBlank((String)entry.getValue())) {
|
||||||
@@ -797,6 +799,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getInfoById(String id) {
|
public Map<String, Object> getInfoById(String id) {
|
||||||
|
if (StringUtils.isBlank(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Map<String, Object> itemsMap = dao.selectByPrimaryKey(id);
|
Map<String, Object> itemsMap = dao.selectByPrimaryKey(id);
|
||||||
// 查询条款表单字段
|
// 查询条款表单字段
|
||||||
List<OnlCgformField> formFieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue());
|
List<OnlCgformField> formFieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue());
|
||||||
@@ -2035,6 +2040,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
errorMsg += fieldName + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日;";
|
errorMsg += fieldName + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日;";
|
||||||
}
|
}
|
||||||
countError++;
|
countError++;
|
||||||
|
} else {
|
||||||
|
value = DateUtils.coverDate((String) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (FieldTypeEnum.DATE_MORE.getValue().equals(fieldShowType)) {
|
} else if (FieldTypeEnum.DATE_MORE.getValue().equals(fieldShowType)) {
|
||||||
@@ -2056,6 +2063,19 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
errorMsg += fieldName + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日;";
|
errorMsg += fieldName + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日;";
|
||||||
}
|
}
|
||||||
countError++;
|
countError++;
|
||||||
|
} else {
|
||||||
|
value = DateUtils.coverDate((String) value);
|
||||||
|
}
|
||||||
|
//判断是否是两个日期点
|
||||||
|
String str = value.replace(",",",");
|
||||||
|
String[] strArr = str.split(",");
|
||||||
|
if (strArr.length != 2) {
|
||||||
|
if(CutEnum.CN.getValue().equals(cut)){
|
||||||
|
errorMsg += fieldName + "必须填写两个日期;";
|
||||||
|
}else{
|
||||||
|
errorMsg += fieldName + " must fill in the two dates;";
|
||||||
|
}
|
||||||
|
countError++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (FieldTypeEnum.FILE.getValue().equals(fieldShowType)) {
|
} else if (FieldTypeEnum.FILE.getValue().equals(fieldShowType)) {
|
||||||
@@ -2184,6 +2204,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
SysUser user = sysUserService.getUserByName(uName);
|
SysUser user = sysUserService.getUserByName(uName);
|
||||||
if (ObjectUtils.isNotEmpty(user)) {
|
if (ObjectUtils.isNotEmpty(user)) {
|
||||||
userIdList.add(user.getId());
|
userIdList.add(user.getId());
|
||||||
|
} else {
|
||||||
|
if(CutEnum.CN.getValue().equals(cut)) {
|
||||||
|
errorMsg += fieldName + "中人员" + userNames[u] + "不存在;";
|
||||||
|
} else {
|
||||||
|
errorMsg += fieldName + " " + userNames[u] + "Not exist;";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user