条款导入bug修改

This commit is contained in:
liyawei
2022-04-06 00:21:59 +08:00
parent 86a07bf1a0
commit 0e425d8ebc
3 changed files with 267 additions and 223 deletions
@@ -194,4 +194,6 @@ public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibr
String verifyBind(List<String> ids);
List<Map<String,Object>> queryListByIds(String ids);
List<Map<String, Object>> getListBySerialNumber(String serialNumbers);
}
@@ -4062,6 +4062,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
return false;
}
@Override
public List<Map<String, Object>> getListBySerialNumber(String serialNumbers) {
return bussDocumentLibraryEOMapper.getListBySerialNumber(serialNumbers);
}
@@ -59,6 +59,7 @@ import org.apache.http.entity.ContentType;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
@@ -201,14 +202,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
getValList.add(itemValEO);
}
String itemId = parameter.get("id").toString();
String itemId = (String) parameter.get("id");
String itemConditions = "";
String userId = UserUtils.getUserId();
int resultCount = 0;
//修改条款要求内容
if (getValList != null && !getValList.isEmpty()) {
String delIds = parameter.get("delItemIds").toString();
String delIds = (String) parameter.get("delItemIds");
List<String> itemValIds = new ArrayList<>();
//删除VAL表前台删掉的条目信息
if (com.jero.modules.system.util.StringUtils.isNotEmpty(delIds)) {
@@ -458,8 +459,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// }
//sql查询条件
String condition = getConditionStr(parameter);
int pageNo = Integer.parseInt(parameter.get("pageNo").toString());
int pageSize = Integer.parseInt(parameter.get("pageSize").toString());
int pageNo = Integer.parseInt((String) parameter.get("pageNo"));
int pageSize = Integer.parseInt((String) parameter.get("pageSize"));
IPage page = new Page(pageNo, pageSize);
IPage infoPage = dao.getInfoPage(page, " " + "sar_file_split_items.*", condition);
@@ -686,7 +687,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (getMenuList != null && !getMenuList.isEmpty()) {
for (Map<String, Object> splitItemsMap : getMenuList) {
SarFileSplitMenuEO sarMenuEO = new SarFileSplitMenuEO();
sarMenuEO.setId(splitItemsMap.get("menu_id").toString());
sarMenuEO.setId((String)splitItemsMap.get("menu_id"));
List<SarFileSplitMenuEO> list = sarFileSplitMenuEOMapper.queryByPidExcpetSelf(sarMenuEO);
if(list != null && !list.isEmpty()){
// String menuNameStr = list.stream().map(SarFileSplitMenuEO :: getName).collect(Collectors.joining(""));
@@ -756,7 +757,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String fieldType = onlCgformField.getFieldShowType();
String dbFieldName = onlCgformField.getDbFieldName();
if (FieldTypeEnum.TREE.getValue().equals(fieldType)) {
if (StringUtils.isNotBlank(itemsMap.get(dbFieldName).toString())) {
if (StringUtils.isNotBlank((String)itemsMap.get(dbFieldName))) {
String[] values = itemsMap.get(dbFieldName).toString().split(",");
itemsMap.put(dbFieldName, values);
}
@@ -789,7 +790,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
.collect(Collectors.toList()).get(0);
// 合并条款数据
Map<String, Object> newItemMap = firstItemMap;
String newItemId = firstItemMap.get("id").toString();
String newItemId = (String) firstItemMap.get("id");
for (OnlCgformField onlCgformField : formFieldList){
StringBuilder conditionSb = new StringBuilder();
String fieldType = onlCgformField.getFieldShowType();
@@ -809,7 +810,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
StringBuilder con = new StringBuilder();
// 去重合并内容
oldItemMapList.forEach(item -> {
if(StringUtils.isNotBlank(item.get(dbFieldName).toString())) {
if(StringUtils.isNotBlank((String)item.get(dbFieldName))) {
con.append(",").append(item.get(dbFieldName).toString());
}
}); // 合并
@@ -823,14 +824,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// 查询合并条款的所有文件列表
String connectIds = null;
for(Map<String, Object> oldItemMap : oldItemMapList){
if(StringUtils.isNotBlank(oldItemMap.get(dbFieldName).toString())){
if(StringUtils.isNotBlank((String)oldItemMap.get(dbFieldName))){
connectIds += oldItemMap.get(dbFieldName).toString();
}
}
if(connectIds != null){
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectIds);
ossFileList.forEach(file->{
file.setConnectId(firstItemMap.get(dbFieldName).toString());
file.setConnectId((String)firstItemMap.get(dbFieldName));
});
ossFileService.updateFileInfo(ossFileList);
}
@@ -916,7 +917,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
@Override
public Result<?> importSplitItemsData(List<Map<String, Object>> list,
String menuId, String filepath,
String menuId,
String filepath,
String infoId,
String cut,
List<SplitTableInfo> getSheetTableList) {
@@ -955,6 +957,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
Map<String, Object> oldItems = addItemsEOList.get(addItemsEOList.size()-1);
if (itemNum > 0 && importDto.get("items_num").equals(oldItems.get("items_num"))
&& importDto.get("items_name").equals(oldItems.get("items_name"))) {
if(ObjectUtil.isEmpty(importDto.get("iterms_conditions"))){
continue;
}
addItemValList = (List<SarFileSplitItemsValEO>) oldItems.get("itemValEOList");
String itemContent = oldItems.get("iterms_conditions").toString() + importDto.get("iterms_conditions").toString();
oldItems.put("iterms_conditions", itemContent);
@@ -1002,9 +1007,58 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
oldItems.put("itemValEOList", addItemValList);
}else {
if(ObjectUtil.isNotEmpty(importDto.get("iterms_conditions"))) {
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
if (valArr != null && valArr.length > 0) {
for (int i = 0; i < valArr.length; i++) {
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
boolean isText = true;
if (getSheetTableList != null && !getSheetTableList.isEmpty()) {
for (SplitTableInfo splitTableInfo : getSheetTableList) {
if (splitTableInfo.getTableName().equals(valArr[i])) {
isText = false;
valEO.setType("TABLE");
valEO.setItemContent(splitTableInfo.getTableHtml());
}
}
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
String url = nowfilelist.get(0).getPath();
MultipartFile multipartFile = createMfileByPath(url);
String state = "0";
String fileSuffix = url.substring(url.lastIndexOf("."));
String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
if (fileTypeStr.contains(fileSuffix)) {
state = "1";
}
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state);
if (oSSFile != null) {
oSSFile = ossFileService.getById(oSSFile.getId());
isText = false;
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/"));
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
// valEO.setItemContent(imgCon);
valEO.setItemContent(path);
}
}
if (isText) {
valEO.setType("TEXT");
valEO.setItemContent(valArr[i]);
}
addItemValList.add(valEO);
}
}
importDto.put("itemValEOList", addItemValList);
}
addItemsEOList.add(importDto);
}
} else {
if(ObjectUtil.isNotEmpty(importDto.get("iterms_conditions"))) {
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
if (valArr != null && valArr.length > 0) {
for (int i=0;i<valArr.length;i++) {
for (int i = 0; i < valArr.length; i++) {
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
boolean isText = true;
if (getSheetTableList != null && !getSheetTableList.isEmpty()) {
@@ -1018,22 +1072,13 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
String url = nowfilelist.get(0).getPath();
MultipartFile multipartFile = createMfileByPath(url);
String state = "0";
String fileSuffix = url.substring(url.lastIndexOf("."));
String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
if (fileTypeStr.contains(fileSuffix)) {
state = "1";
}
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "",state);
if(oSSFile!=null){
oSSFile = ossFileService.getById(oSSFile.getId());
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "", "1");
if (oSSFile != null) {
isText = false;
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/"));
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
// valEO.setItemContent(imgCon);
// valEO.setItemContent(imgCon);
valEO.setItemContent(path);
}
}
@@ -1045,43 +1090,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
}
importDto.put("itemValEOList", addItemValList);
addItemsEOList.add(importDto);
}
} else {
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
if (valArr != null && valArr.length > 0) {
for (int i=0;i<valArr.length;i++) {
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
boolean isText = true;
if (getSheetTableList != null && !getSheetTableList.isEmpty()) {
for (SplitTableInfo splitTableInfo : getSheetTableList) {
if (splitTableInfo.getTableName().equals(valArr[i])) {
isText = false;
valEO.setType("TABLE");
valEO.setItemContent(splitTableInfo.getTableHtml());
}
}
}
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
if (nowfilelist != null && !nowfilelist.isEmpty()) {
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1");
if(oSSFile!=null){
isText = false;
String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/"));
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
// valEO.setItemContent(imgCon);
valEO.setItemContent(path);
}
}
if (isText) {
valEO.setType("TEXT");
valEO.setItemContent(valArr[i]);
}
addItemValList.add(valEO);
}
}
importDto.put("itemValEOList", addItemValList);
addItemsEOList.add(importDto);
}
itemNum++;
@@ -1162,7 +1171,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//添加条款
for (Map<String, Object> itemsEO : addItemsEOList) {
if(menuAndItemMap.get(itemsEO.get("id")) != null) {
createItemsInfo(itemsEO, menuAndItemMap.get(itemsEO.get("id").toString()), infoId);
createItemsInfo(itemsEO, menuAndItemMap.get((String)itemsEO.get("id")), infoId);
}
countSuccess++;
}
@@ -1353,94 +1362,97 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
return mFile;
}
private List<Map<String, Object>> read(File file, List<String> dbfieldList, String[] titles) {
try {
//最终返回数据
List<Map<String, Object>> list = new ArrayList<>();
private List<Map<String, Object>> read(File file, List<String> dbfieldList, String[] titles) throws IOException, InvalidFormatException {
Workbook workbook = null;
InputStream is = new FileInputStream(file);
String name = file.getName().toLowerCase();
// 创建excel操作对象
if (name.contains(".xlsx") || name.contains(".xls")) {
workbook = WorkbookFactory.create(is);
}
//得到一个工作表
Sheet sheet = workbook.getSheetAt(0);
//最终返回数据
List<Map<String, Object>> list = new ArrayList<>();
//获得数据的总行数
int totalRowNum = sheet.getLastRowNum();
Workbook workbook = null;
InputStream is = new FileInputStream(file);
String name = file.getName().toLowerCase();
// 创建excel操作对象
if (name.contains(".xlsx") || name.contains(".xls")) {
workbook = WorkbookFactory.create(is);
}
//得到一个工作表
Sheet sheet = workbook.getSheetAt(0);
//获得总列
int cellLength = sheet.getRow(0).getPhysicalNumberOfCells();
// 验证模板表头是否正确
Row row = sheet.getRow(0);
for (int i = 0; i < cellLength; i++) {
if (!(row == null)) {
Cell cell = row.getCell(i);
if(ObjectUtil.isNotNull(cell)){
//设置单元格类型
cell.setCellType(CellType.STRING);
String cellValue = cell.getStringCellValue();
if(!cellValue.equals(titles[i])){
throw new JeroBootException("请导入正确模板!");
}
} else{
//获得数据的总行
int totalRowNum = sheet.getLastRowNum();
//获得总列数
int cellLength = sheet.getRow(0).getPhysicalNumberOfCells();
// 验证模板表头是否正确
Row rowTitle = sheet.getRow(0);
for (int i = 0; i < cellLength; i++) {
if (rowTitle != null) {
Cell cell = rowTitle.getCell(i);
if(ObjectUtil.isNotNull(cell)){
//设置单元格类型
cell.setCellType(CellType.STRING);
String cellValue = cell.getStringCellValue().substring(cell.getStringCellValue().indexOf("*")+1);
if(!cellValue.equals(titles[i])){
throw new JeroBootException("请导入正确模板!");
}
}else{
} else{
throw new JeroBootException("请导入正确模板!");
}
}else{
throw new JeroBootException("请导入正确模板!");
}
}
Map<String, Object> map = null;
//获得所有数据
//从第x行开始获取
for (int x = 2; x <= totalRowNum; x++) {
map = new HashMap<String, Object>();
//获得第i行对象
Row rowTitle = sheet.getRow(x);
//如果一行里的所有单元格都为空则不放进list里面
int a = 0;
for (int y = 0; y < cellLength; y++) {
if (!(row == null)) {
Cell cell = row.getCell(y); // cell 为空时会抛空指针异常
if(ObjectUtil.isNull(cell)) {
continue;
}
Map<String, Object> map = null;
//获得所有数据
//从第x行开始获取
for (int x = 2; x <= totalRowNum; x++) {
map = new HashMap<String, Object>();
//获得第i行对象
Row row= sheet.getRow(x);
//如果一行里的所有单元格都为空则不放进list里面
int a = 0;
for (int y = 0; y < cellLength; y++) {
if (!(row == null)) {
Cell cell = row.getCell(y); // cell 为空时会抛空指针异常
if(ObjectUtil.isNull(cell)) {
map.put(dbfieldList.get(y), "");
continue;
}
String cellValue = null;
if (cell.getCellTypeEnum().equals("NUMERIC") && HSSFDateUtil.isCellDateFormatted(cell)) {
// 获取日期类型的单元格的值
Date d = cell.getDateCellValue();
// 进行格式转换
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
cellValue = formatter.format(d);
} else {
//设置单元格类型
cell.setCellType(CellType.STRING);
String cellValue = null;
boolean isMerge = isMergedRegion(sheet, row.getRowNum(), cell.getColumnIndex());
//判断是否具有合并单元格
if (isMerge) {
cellValue = getMergedRegionValue(sheet, row.getRowNum(), cell.getColumnIndex());
} else {
cellValue = cell.getStringCellValue();
}
//
if (cell == null) {
map.put(dbfieldList.get(y), "");
} else {
map.put(dbfieldList.get(y), cellValue);
}
if (map.get(dbfieldList.get(y)) == null || "".equals(map.get(dbfieldList.get(y)))) {
a++;
}
}
boolean isMerge = isMergedRegion(sheet, row.getRowNum(), cell.getColumnIndex());
//判断是否具有合并单元格
if (isMerge) {
cellValue = getMergedRegionValue(sheet, row.getRowNum(), cell.getColumnIndex());
} else {
cellValue = cell.getStringCellValue();
}
//
map.put(dbfieldList.get(y), cellValue);
if (map.get(dbfieldList.get(y)) == null || "".equals(map.get(dbfieldList.get(y)))) {
a++;
}
}
// 当前行所有单元格均不为空时
if (a != cellLength && row != null) {
list.add(map);
}
}
return list;
} catch (Exception e) {
e.printStackTrace();
// 当前行所有单元格均不为空时
if (a != cellLength && row != null) {
list.add(map);
}
}
return null;
return list;
}
/**
* 获取合并单元格的值
*
@@ -1554,7 +1566,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (key.contains("*")) {
key = key.replace("*", "");
}
String value = entry.getValue().toString();
String value = (String) entry.getValue();
String field = "";
for (Map<String, Object> map : fieldList) {
String fieldName = (String) map.get("db_field_txt");//中文名称
@@ -1570,12 +1582,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//树形
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
countError++;
}
//判断数据是否匹配
@@ -1583,12 +1595,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
value = value.replace("",",");
for (String valueTemp : value.split(",")) {
if (!treeNameList.contains(valueTemp)) {
errorMsg += fieldName + "中的" + valueTemp + "与数据字典不匹配";
errorMsg += fieldName + "中的" + valueTemp + "与数据字典不匹配";
countError++;
}
}
}
String valueId = "";
List<String> valueIdList = new ArrayList<>();
//文字转ID
if (StringUtils.isNotBlank(value)) {
value = value.replace("",",");
@@ -1602,51 +1614,61 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
collect = categoryList.stream().filter(e -> e.getEnName().equals(valueTemp)).collect(Collectors.toList());
}
if (collect.size() != 0) {
valueId += collect.get(0).getId();
valueIdList.add(collect.get(0).getId());
}
}
}
value = valueId;
value = StringUtils.join(valueIdList, ",");
}
} else if (FieldTypeEnum.TEXT_STRING.getValue().equals(fieldShowType)) {
//输入框
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
countError++;
}
} else if (FieldTypeEnum.TEXT_NUMBER.getValue().equals(fieldShowType)) {
//输入框(数字)
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空;";
countError++;
}
//正则判断仅能为 负号(-),小数点(.)和数字
String regexNumber = "^(\\-|\\+)?\\d+(\\.\\d+)?$";
if(StringUtils.isNotBlank(value) && !value.matches(regexNumber)){
errorMsg += fieldName + "仅能为 负号(-),小数点(.)和数字;";
countError++;
}
} else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldShowType)) {
//下拉单选
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
countError++;
}
//判断是否是单选
if (StringUtils.isNotBlank(value) && value.contains(",")) {
errorMsg += fieldName + "为单选项";
errorMsg += fieldName + "为单选项";
countError++;
}
//判断数据是否匹配
if (StringUtils.isNotBlank(value)) {
if (!itemNameList.contains(value)) {
errorMsg += fieldName + "中的" + value + "与数据字典不匹配";
errorMsg += fieldName + "中的" + value + "与数据字典不匹配";
countError++;
}
}
@@ -1666,12 +1688,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
} else if (FieldTypeEnum.PULL_MORE.getValue().equals(fieldShowType)) {
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
countError++;
}
//下拉多选
@@ -1679,7 +1701,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
value = value.replace("",",");
for (String valueTemp : value.split(",")) {
if (!itemNameList.contains(valueTemp)) {
errorMsg += fieldName + "中的" + valueTemp + "与数据字典不匹配";
errorMsg += fieldName + "中的" + valueTemp + "与数据字典不匹配";
countError++;
}
}
@@ -1708,30 +1730,31 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//单选日期
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//a判断是否是单日期选择
//判断是否是单日期选择
value = value.replace("",",");
if (StringUtils.isNotBlank(value) && value.contains(",")) {
errorMsg += fieldName + "为单日期选项";
errorMsg += fieldName + "为单日期选项";
countError++;
}
//判断格式是否正确
if (!DateUtils.isValidDate((String) value)) {
errorMsg += fieldName + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
errorMsg += fieldName + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
countError++;
}
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) {
} else if (FieldTypeEnum.DATE_MORE.getValue().equals(fieldShowType)) {
//多选日期
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//判断格式是否正确
if (!DateUtils.isValidDate((String) value)) {
errorMsg += fieldName + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
errorMsg += fieldName + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
countError++;
}
@@ -1740,12 +1763,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//文件
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空";
errorMsg += fieldName + "为必填项,不能为空";
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
countError++;
}
if (StringUtils.isNotBlank(value)) {
@@ -1777,20 +1800,21 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
}
} /*else if (FieldTypeEnum.STANDARD.getValue().equals(fieldShowType)) {
} else if (FieldTypeEnum.STANDARD.getValue().equals(fieldShowType)) {
//标准选择
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += key + "为必填项,不能为空";
errorMsg += key + "为必填项,不能为空;";
countError++;
}
//判断长度
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
errorMsg += key + "不能超过" + dbLength + "个字符";
errorMsg += key + "不能超过" + dbLength + "个字符;";
countError++;
}
//判断库中是否存在,如果存在则存id,如果不存在则存输入的值
List<Map<String, Object>> listBySerialNumber = getListBySerialNumber(value);
value = value.replace("",",");
List<Map<String, Object>> listBySerialNumber = documentLibraryEOService.getListBySerialNumber(value);
String serialNumberStr = "";
StringBuilder sb = new StringBuilder();
List<String> list = new ArrayList<>();
@@ -1812,7 +1836,43 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
value = substring;
}
}*/
} else if (FieldTypeEnum.PERSON.getValue().equals(fieldShowType)) {
//人员选择
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空;";
countError++;
}
value = value.replace("",",");
if(StringUtils.isNotBlank(value)) {
String[] userNames = value.split(",");
List<String> userIdList = new ArrayList<>();
for(int u=0 ; u<userNames.length; u++){
String uName = userNames[u].substring(userNames[u].indexOf("(")+1, userNames[u].indexOf(")"));
SysUser user = sysUserService.getUserByName(uName);
if(ObjectUtils.isNotEmpty(user)){
userIdList.add(user.getId());
}
}
value = StringUtils.join(userIdList, ",");
}
} else if (FieldTypeEnum.TEXT_LINK.getValue().equals(fieldShowType)) {
//输入框(链接)
//判断是否必填
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
errorMsg += fieldName + "为必填项,不能为空;";
countError++;
}
//正则判断仅能为 负号(-),小数点(.)和数字
String regexLink = "(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";
if(StringUtils.isNotBlank(value) && !value.matches(regexLink)){
errorMsg += fieldName + "不是正确的链接格式,必须以http或https开头;";
countError++;
}
}
}
}
if((dto.get(key)== null && value != null) || (dto.get(key)!= null && !dto.get(key).toString().equals(value))){
@@ -1878,7 +1938,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
// val表信息
valEO.setId(UUIDUtils.randomUUID20());
// valEO.setItemId(itemsId);
valEO.setItemId(sarFileSplitItemsEO.get("id").toString());
valEO.setItemId((String)sarFileSplitItemsEO.get("id"));
valEO.setDisplaySeq(ind);
valEO.setValidFlag(0);
valEO.setCreationTime(new Date());
@@ -1890,7 +1950,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
sarFileSplitItemsValEOMapper.insertForeach(getValList);
sarFileSplitItemsEO.put("iterms_conditions", itemConditions);
}
String id = sarFileSplitItemsEO.get("id").toString();
String id = (String)sarFileSplitItemsEO.get("id");
sarFileSplitItemsEO.remove("id");
sarFileSplitItemsEO.remove("itemValEOList");
insertInfo(sarFileSplitItemsEO,id); // 添加条款
@@ -2149,8 +2209,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
if (dateMoreList.size() != 0) {
//多选日期
String dateSingle = StringUtils.join(dateSingleList, ",") + "字段为日期,必须精确到日,可填写多个,填写多个时采用英文或中文逗号分割\n";
sbTwo.append(count++ + "." + dateSingle);
String dateMore = StringUtils.join(dateMoreList, ",") + "字段为日期,必须精确到日,可填写多个,填写多个时采用英文或中文逗号分割\n";
sbTwo.append(count++ + "." + dateMore);
}
if (textStringList.size() != 0) {
//输入框
@@ -2529,23 +2589,32 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String imgContent = itemsValEO.getItemContent();
String imgUUIndex = "img" + String.valueOf(imgIndex);
if (com.jero.modules.system.util.StringUtils.isNotEmpty(imgContent)){
int pathIndex = imgContent.indexOf("src='uploadPath");
if (pathIndex > -1 && imgContent.length()>(pathIndex+16)) {
String imgPath = imgContent.substring(pathIndex+16,imgContent.length()-2);
String imgName = imgUUIndex + "-" +imgPath.substring(imgPath.lastIndexOf("/")+1,imgPath.length());
lastOne.setValContent(imgUUIndex+".png");
valContent.add(lastOne);
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
if (com.jero.modules.system.util.StringUtils.isNotEmpty(itemsValEO.getImgName())) {
fileSplitValImgExportDto.setImgPath(itemsValEO.getImgName());
} else {
fileSplitValImgExportDto.setImgPath(imgPath);
}
allImgList.add(fileSplitValImgExportDto);
imgIndex++;
page.setImgIndex(imgIndex);
}
lastOne.setValContent(imgUUIndex+".png");
valContent.add(lastOne);
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
fileSplitValImgExportDto.setImgPath(imgContent.substring(imgContent.lastIndexOf("/")+1));
allImgList.add(fileSplitValImgExportDto);
imgIndex++;
page.setImgIndex(imgIndex);
// int pathIndex = imgContent.indexOf("src='uploadPath");
// if (pathIndex > -1 && imgContent.length()>(pathIndex+16)) {
// String imgPath = imgContent.substring(pathIndex+16,imgContent.length()-2);
// String imgName = imgUUIndex + "-" +imgPath.substring(imgPath.lastIndexOf("/")+1,imgPath.length());
// lastOne.setValContent(imgUUIndex+".png");
// valContent.add(lastOne);
// FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
// fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
// if (com.jero.modules.system.util.StringUtils.isNotEmpty(itemsValEO.getImgName())) {
// fileSplitValImgExportDto.setImgPath(itemsValEO.getImgName());
// } else {
// fileSplitValImgExportDto.setImgPath(imgPath);
// }
// allImgList.add(fileSplitValImgExportDto);
// imgIndex++;
// page.setImgIndex(imgIndex);
// }
}
}
preType = itemsValEO.getType();
@@ -2654,23 +2723,17 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
}
// 在excel表中添加表头
HSSFRow row = sheetItems.createRow(0);
sheetItems.setColumnWidth(0,10*256);
sheetItems.setColumnWidth(1,20*256);
sheetItems.setColumnWidth(2,100*256);
//导出目前只需要条款号、条款名称、条款内容
// sheetItems.setColumnWidth(3,20*256);
// sheetItems.setColumnWidth(4,20*256);
// sheetItems.setColumnWidth(5,20*256);
// sheetItems.setColumnWidth(6,20*256);
// sheetItems.setColumnWidth(7,20*256);
// sheetItems.setColumnWidth(8,20*256);
// sheetItems.setColumnWidth(9,40*256);
for (int i = 0; i < headers.length; i++) {
HSSFCell cell = row.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(headers[i]);
cell.setCellValue(text);
cell.setCellStyle(cellStyle1);
// 设置单元格宽度
if("条款内容".equals(headers[i])) {
sheetItems.setColumnWidth(i, 80 * 256);
} else {
sheetItems.setColumnWidth(i, 20 * 256);
}
}
//放文字内容
int allRow = 0;
@@ -2763,14 +2826,11 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
//
}
if (allRow > startRow) {
sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,0,0));
sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,1,1));
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,3,3));
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,4,4));
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,5,5));
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,6,6));
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,7,7));
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,8,8));
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++) {
if (!"iterms_conditions".equals(fieldList.get(cellNum))) {
sheetItems.addMergedRegion(new CellRangeAddress(startRow, allRow, cellNum, cellNum));
}
}
// if (countFile > 0) {
// for (int i=0;i<=countFile;i++) {
// sheetItems.addMergedRegion(new CellRangeAddress(startRow,allRow,9+i,9+i));
@@ -2789,25 +2849,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
row1.getCell(cellNum).setCellStyle(cellStyle);
}
}
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// if (exportDto.getNewcarPutTime() != null) {
// String time= sdf.format(exportDto.getNewcarPutTime());
// row1.createCell(3).setCellValue(time);
// row1.getCell(3).setCellStyle(cellStyle);
// }
// if (exportDto.getProductPutTime() != null) {
// String time= sdf.format(exportDto.getProductPutTime());
// row1.createCell(4).setCellValue(time);
// row1.getCell(4).setCellStyle(cellStyle);
// }
// row1.createCell(5).setCellValue(exportDto.getFunctionTerritory());
// row1.getCell(5).setCellStyle(cellStyle);
// row1.createCell(6).setCellValue(exportDto.getApplyArctic());
// row1.getCell(6).setCellStyle(cellStyle);
// row1.createCell(7).setCellValue(exportDto.getReferenceStand());
// row1.getCell(7).setCellStyle(cellStyle);
// row1.createCell(8).setCellValue(exportDto.getTechnologyTerritory());
// row1.getCell(8).setCellStyle(cellStyle);
// if (StringUtils.isNotEmpty(exportDto.getRelevanceFile())) {
// List<AttFileEO> fileList = attFileEOService.getMultiFileInfos(exportDto.getRelevanceFile());
// if (fileList != null && !fileList.isEmpty()) {