文档拆分条款-导入拆分结果
This commit is contained in:
+2
-2
@@ -191,10 +191,10 @@ public class FileSplitItemsEOController extends JeroController<SarFileSplitItems
|
||||
|
||||
@ApiOperation(value = "文档拆分条款信息-导入拆分结果")
|
||||
@PostMapping(value = "/importSplitResult")
|
||||
public Result<?> importSplitResult( MultipartFile file,
|
||||
public Result<?> importSplitResult( String splitFileId,
|
||||
String cut,
|
||||
SarFileSplitInfoEO splitInfoEO) throws IOException {
|
||||
return fileSplitItemsEOService.importSplitResult(file,cut,splitInfoEO);
|
||||
return fileSplitItemsEOService.importSplitResult(splitFileId, cut,splitInfoEO);
|
||||
}
|
||||
|
||||
@AutoLog(value = "文档拆分条款信息-导入")
|
||||
|
||||
+2
-2
@@ -45,11 +45,11 @@ public interface IFileSplitItemsEOService extends IService<SarFileSplitItemsEO>
|
||||
|
||||
int batchSet(Map<String,Object> parameter);
|
||||
|
||||
Result<?> importSplitItemsData(List<Map<String, Object>> list, String menuId, String filepath, String infoId, List<SplitTableInfo> getSheetTableList);
|
||||
Result<?> importSplitItemsData(List<Map<String, Object>> list, String menuId, String filepath, String infoId, String cut, List<SplitTableInfo> getSheetTableList);
|
||||
|
||||
Result<?> importSplitItems(MultipartFile file, String cut, String menuId, String infoId) throws IOException;
|
||||
|
||||
Result<?> importSplitResult(MultipartFile file, String cut, SarFileSplitInfoEO sarFileSplitInfoEO) throws IOException;
|
||||
Result<?> importSplitResult(String splitFileId, String cut, SarFileSplitInfoEO sarFileSplitInfoEO) throws IOException;
|
||||
|
||||
void exportTemplate(String cut, HttpServletResponse response, HttpServletRequest request);
|
||||
|
||||
|
||||
+434
-47
@@ -11,14 +11,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.constant.enums.IsMustEnum;
|
||||
import com.jero.common.constant.enums.ModuleEnum;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.lanswitch.service.ILanguageSwitchService;
|
||||
import com.jero.modules.ocr.util.UUIDUtils;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
@@ -50,6 +51,7 @@ import com.jero.modules.system.util.UserUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
@@ -61,10 +63,11 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -87,6 +90,7 @@ import static com.jero.modules.split.util.ExcelUtil.checkObjAllFieldsIsNull;
|
||||
* @Date: Created in 14:59 2022/3/24
|
||||
*/
|
||||
@Service
|
||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||
public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMapper, SarFileSplitItemsEO> implements IFileSplitItemsEOService {
|
||||
@Autowired
|
||||
private FileSplitItemsEOMapper dao;
|
||||
@@ -112,6 +116,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
|
||||
@Value(value = "${jero.path.upload}")
|
||||
private String uploadpath;
|
||||
@Value(value = "${jero.path.img}")
|
||||
private String imgpath;
|
||||
|
||||
@Override
|
||||
public int addItemContent(Map<String, Object> parameter){
|
||||
@@ -673,11 +679,21 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> importSplitItemsData(List<Map<String, Object>> list, String menuId, String filepath, String infoId, List<SplitTableInfo> getSheetTableList) {
|
||||
public Result<?> importSplitItemsData(List<Map<String, Object>> list,
|
||||
String menuId, String filepath,
|
||||
String infoId,
|
||||
String cut,
|
||||
List<SplitTableInfo> getSheetTableList) {
|
||||
//此处需要做各种验证,数据库操作
|
||||
try {
|
||||
//树形数据字典
|
||||
List<SysCategory> categoryList = sysCategoryService.list();
|
||||
//普通数据字典
|
||||
List<SysDictItem> dictItemList = sysDictItemServiceImpl.selectItemsAll();
|
||||
// 表头
|
||||
List<Map<String, Object>> fieldList = getImportOnlField(ModuleEnum.FILE_SPLIT_ITEMS.getValue(),cut);
|
||||
//验证导入数据是否符合规则
|
||||
Map map = validateImportDatas(list,filepath);
|
||||
Map map = validateImportDatas(list,categoryList,dictItemList,fieldList,filepath,cut);
|
||||
boolean isOk = (boolean) map.get("result");
|
||||
if (!isOk) {
|
||||
//验证没有通过
|
||||
@@ -703,7 +719,7 @@ 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"))) {
|
||||
addItemValList = (List<SarFileSplitItemsValEO>) oldItems.get("itemValEOList"); // TODO
|
||||
addItemValList = (List<SarFileSplitItemsValEO>) oldItems.get("itemValEOList");
|
||||
String itemContent = oldItems.get("iterms_conditions").toString() + importDto.get("iterms_conditions").toString();
|
||||
oldItems.put("iterms_conditions", itemContent);
|
||||
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
|
||||
@@ -722,13 +738,23 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
|
||||
if (nowfilelist != null && !nowfilelist.isEmpty()) {
|
||||
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1"); // TODO MultipartFile强转不知道会不会成功
|
||||
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 = "uploadPath/" + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/")+1);
|
||||
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (isText) {
|
||||
@@ -756,13 +782,23 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
|
||||
if (nowfilelist != null && !nowfilelist.isEmpty()) {
|
||||
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1"); // TODO MultipartFile强转不知道会不会成功
|
||||
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 = "uploadPath/" + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/")+1);
|
||||
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (isText) {
|
||||
@@ -792,13 +828,14 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
|
||||
if (nowfilelist != null && !nowfilelist.isEmpty()) {
|
||||
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1"); // TODO MultipartFile强转不知道会不会成功
|
||||
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1");
|
||||
if(oSSFile!=null){
|
||||
isText = false;
|
||||
String path = "uploadPath/" + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/")+1);
|
||||
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (isText) {
|
||||
@@ -983,6 +1020,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
SplitTableInfo splitTableInfo = new SplitTableInfo();
|
||||
splitTableInfo.setTableName(sheet.getSheetName());
|
||||
String tableHtml = POIReadExcelToHtml.readExcelToHtml(workbook,i,false);
|
||||
tableHtml = tableHtml.replaceAll("\'","\"");
|
||||
splitTableInfo.setTableHtml(tableHtml);
|
||||
getSheetTableList.add(splitTableInfo);
|
||||
}
|
||||
@@ -1003,7 +1041,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
datasUpdate.add(sarStandImportDto);
|
||||
}
|
||||
String unzipfilepath = zipEntryName;
|
||||
Result<?> message = importSplitItemsData(datasUpdate,menuId,unzipfilepath,infoId,getSheetTableList);
|
||||
Result<?> message = importSplitItemsData(datasUpdate,menuId,unzipfilepath,infoId,cut,getSheetTableList);
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
return message;
|
||||
@@ -1033,7 +1071,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> importSplitResult(MultipartFile file, String cut, SarFileSplitInfoEO sarFileSplitInfoEO) throws IOException {
|
||||
public Result<?> importSplitResult(String splitFileId, String cut, SarFileSplitInfoEO sarFileSplitInfoEO) throws IOException {
|
||||
OSSFile ossFile = ossFileService.getById(splitFileId);
|
||||
String url = ossFile.getUrl();
|
||||
MultipartFile mFile = createMfileByPath(url);
|
||||
// 新增拆分记录
|
||||
Date now = new Date();
|
||||
String infoId = UUID.randomUUID().toString().replace("-", "");
|
||||
@@ -1054,9 +1095,26 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
sarFileSplitMenuEO.setModifyTime(new Date());
|
||||
sarFileSplitMenuEOMapper.insertSelective(sarFileSplitMenuEO);
|
||||
// 导入文件
|
||||
return importSplitItems(file, cut, menuId, infoId);
|
||||
return importSplitItems(mFile, cut, menuId, infoId);
|
||||
}
|
||||
|
||||
private MultipartFile createMfileByPath(String path) {
|
||||
MultipartFile mFile = null;
|
||||
try {
|
||||
File file = new File(path);
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
|
||||
String fileName = file.getName();
|
||||
fileName = fileName.substring((fileName.lastIndexOf("/") + 1));
|
||||
mFile = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
|
||||
} catch (Exception e) {
|
||||
log.error("封装文件出现错误:{}", e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
return mFile;
|
||||
}
|
||||
|
||||
|
||||
private List<Map<String, Object>> read(File file, List<String> dbfieldList) {
|
||||
try {
|
||||
//最终返回数据
|
||||
@@ -1173,45 +1231,334 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
return false;
|
||||
}
|
||||
|
||||
private Map validateImportDatas(List<Map<String, Object>> datas, String filepath) throws Exception {
|
||||
private Map validateImportDatas(List<Map<String, Object>> datas,
|
||||
List<SysCategory> categoryList,
|
||||
List<SysDictItem> dictItemList,
|
||||
List<Map<String, Object>> fieldList,
|
||||
String filepath,
|
||||
String cut) throws Exception {
|
||||
//树形数据字典
|
||||
List<String> treeNameList = new ArrayList<>();
|
||||
//普通数据字典
|
||||
List<String> itemNameList = new ArrayList<>();
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
treeNameList = categoryList.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
itemNameList = dictItemList.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
|
||||
} else if(CutEnum.EN.getValue().equals(cut)){
|
||||
treeNameList = categoryList.stream().map(SysCategory::getEnName).collect(Collectors.toList());
|
||||
itemNameList = dictItemList.stream().map(SysDictItem::getEnName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//存放数据验证结果信息
|
||||
List<String> stringMessage = new ArrayList<>();
|
||||
int i = 1; //记录行号
|
||||
int i = 2; //记录行号
|
||||
int num = 0; //记录是第几条数据
|
||||
//循环验证数据
|
||||
for (Map<String, Object> dto : datas) {
|
||||
i++;
|
||||
int countError = 0; //记录失败数据数量
|
||||
String errorMsg = "第" + i + "行:";
|
||||
if (num > 0 && org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_num").toString())
|
||||
&& org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_name").toString())) {
|
||||
String nowItemContent = dto.get("iterms_conditions").toString();
|
||||
BeanUtils.copyProperties(datas.get(num-1), dto);
|
||||
dto.put("iterms_conditions", nowItemContent);
|
||||
}
|
||||
if (org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_num").toString())) {
|
||||
errorMsg += "条款号不能为空;";
|
||||
countError++;
|
||||
} else {
|
||||
if (dto.get("items_num").toString().length()>100) {
|
||||
errorMsg += "条款号不能超过100个字符;";
|
||||
countError++;
|
||||
}
|
||||
}
|
||||
if (org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_name").toString())) {
|
||||
errorMsg += "条款名称不能为空;";
|
||||
countError++;
|
||||
} else {
|
||||
if (dto.get("items_name").toString().length()>100) {
|
||||
errorMsg += "条款名称不能超过100个字符;";
|
||||
countError++;
|
||||
}
|
||||
}
|
||||
//判断发布日期,新车型实施日期,在产车实施日期
|
||||
|
||||
// try {
|
||||
// String issueTime = (String) stringStringMap.get("issue_time");
|
||||
// if(StringUtils.isNotBlank(issueTime)){
|
||||
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Date issueTimeDate = df.parse(issueTime);
|
||||
// String implementTime = (String) stringStringMap.get("implement_time");//在产车实施日期
|
||||
// String newCarimplementTime = (String) stringStringMap.get("xin1_che1_xing2_ren4_zheng4_shi2_jian1");//新车型实施日期
|
||||
// if(StringUtils.isNotBlank(implementTime)){
|
||||
// Date implementTimeDate = df.parse(implementTime);
|
||||
// if (issueTimeDate.after(implementTimeDate)) {
|
||||
// errorMsg += "发布日期不能大于在产车实施日期";
|
||||
// countError++;
|
||||
// }
|
||||
// }
|
||||
// if(StringUtils.isNotBlank(newCarimplementTime)){
|
||||
// Date newCarimplementTimeDate = df.parse(newCarimplementTime);
|
||||
// if (issueTimeDate.after(newCarimplementTimeDate)) {
|
||||
// errorMsg += "发布日期不能大于新车型实施日期";
|
||||
// countError++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("文档库导入失败导入");
|
||||
// }
|
||||
for (Map.Entry<String, Object> entry : dto.entrySet()) {
|
||||
|
||||
String key = entry.getKey();
|
||||
if (key.contains("*")) {
|
||||
key = key.replace("*", "");
|
||||
}
|
||||
String value = entry.getValue().toString();
|
||||
String field = "";
|
||||
for (Map<String, Object> map : fieldList) {
|
||||
String fieldName = (String) map.get("db_field_txt");//中文名称
|
||||
String dbfieldName = (String) map.get("db_field_name");//字段名
|
||||
String mustInput = (String) map.get("field_must_input");//是否必填
|
||||
String dbLength = map.get("db_length").toString();//字段长度
|
||||
String fieldShowType = (String) map.get("field_show_type");//字段类型
|
||||
|
||||
if (key.equals(dbfieldName)) {
|
||||
field = dbfieldName;
|
||||
//验证字段是否必填,长度,下拉框和树形的值是否匹配
|
||||
if (FieldTypeEnum.TREE.getValue().equals(fieldShowType)) {
|
||||
//树形
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断长度
|
||||
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
|
||||
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
|
||||
countError++;
|
||||
}
|
||||
//判断数据是否匹配
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = value.replace(",",",");
|
||||
for (String valueTemp : value.split(",")) {
|
||||
if (!treeNameList.contains(valueTemp)) {
|
||||
errorMsg += fieldName + "中的" + valueTemp + "与数据字典不匹配";
|
||||
countError++;
|
||||
}
|
||||
}
|
||||
}
|
||||
String valueId = "";
|
||||
//文字转ID
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = value.replace(",",",");
|
||||
for (String valueTemp : value.split(",")) {
|
||||
if (treeNameList.contains(valueTemp)) {
|
||||
// TODO 树形结构导入格式 a/b/c 需特殊处理
|
||||
List<SysCategory> collect = new ArrayList<>();
|
||||
if(CutEnum.CN.getValue().equals(cut)) {
|
||||
collect = categoryList.stream().filter(e -> e.getName().equals(valueTemp)).collect(Collectors.toList());
|
||||
} else if(CutEnum.EN.getValue().equals(cut)) {
|
||||
collect = categoryList.stream().filter(e -> e.getEnName().equals(valueTemp)).collect(Collectors.toList());
|
||||
}
|
||||
if (collect.size() != 0) {
|
||||
valueId += collect.get(0).getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
value = valueId;
|
||||
}
|
||||
|
||||
} else if (FieldTypeEnum.TEXT_STRING.getValue().equals(fieldShowType)) {
|
||||
//输入框
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断长度
|
||||
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
|
||||
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
|
||||
countError++;
|
||||
}
|
||||
|
||||
} else if (FieldTypeEnum.TEXT_NUMBER.getValue().equals(fieldShowType)) {
|
||||
//正则判断仅能为 负号(-),小数点(.)和数字
|
||||
|
||||
|
||||
} else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldShowType)) {
|
||||
//下拉单选
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断长度
|
||||
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
|
||||
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
|
||||
countError++;
|
||||
}
|
||||
//判断是否是单选
|
||||
if (StringUtils.isNotBlank(value) && value.contains(",")) {
|
||||
errorMsg += fieldName + "为单选项";
|
||||
countError++;
|
||||
}
|
||||
//判断数据是否匹配
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
if (!itemNameList.contains(value)) {
|
||||
errorMsg += fieldName + "中的" + value + "与数据字典不匹配";
|
||||
countError++;
|
||||
}
|
||||
}
|
||||
//文字转数据字典编码
|
||||
if (itemNameList.contains(value)) {
|
||||
String finalValue = value;
|
||||
List<SysDictItem> collect = new ArrayList<>();
|
||||
if(CutEnum.CN.getValue().equals(cut)) {
|
||||
collect = dictItemList.stream().filter(e -> StringUtils.isNotBlank(e.getItemText()) && e.getItemText().equals(finalValue)).collect(Collectors.toList());
|
||||
} else if(CutEnum.EN.getValue().equals(cut)) {
|
||||
collect = dictItemList.stream().filter(e -> StringUtils.isNotBlank(e.getEnName()) && e.getEnName().equals(finalValue)).collect(Collectors.toList());
|
||||
}
|
||||
if (collect.size() != 0) {
|
||||
value = collect.get(0).getItemValue();
|
||||
}
|
||||
}
|
||||
} else if (FieldTypeEnum.PULL_MORE.getValue().equals(fieldShowType)) {
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断长度
|
||||
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
|
||||
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
|
||||
countError++;
|
||||
}
|
||||
//下拉多选
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = value.replace(",",",");
|
||||
for (String valueTemp : value.split(",")) {
|
||||
if (!itemNameList.contains(valueTemp)) {
|
||||
errorMsg += fieldName + "中的" + valueTemp + "与数据字典不匹配";
|
||||
countError++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String valueId = "";
|
||||
//文字转数据字典id
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = value.replace(",",",");
|
||||
for (String valueTemp : value.split(",")) {
|
||||
if (itemNameList.contains(valueTemp)) {
|
||||
List<SysDictItem> collect = new ArrayList<>();
|
||||
if(CutEnum.CN.getValue().equals(cut)) {
|
||||
collect = dictItemList.stream().filter(e -> StringUtils.isNotBlank(e.getItemText()) && e.getItemText().equals(valueTemp)).collect(Collectors.toList());
|
||||
} else if(CutEnum.EN.getValue().equals(cut)) {
|
||||
collect = dictItemList.stream().filter(e -> StringUtils.isNotBlank(e.getEnName()) && e.getEnName().equals(valueTemp)).collect(Collectors.toList());
|
||||
}
|
||||
valueId += collect.get(0).getItemValue() + ",";
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(valueId)) {
|
||||
value = valueId.substring(0, valueId.length() - 1);
|
||||
}
|
||||
}
|
||||
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) {
|
||||
//单选日期
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//a判断是否是单日期选择
|
||||
if (StringUtils.isNotBlank(value) && value.contains(",")) {
|
||||
errorMsg += fieldName + "为单日期选项";
|
||||
countError++;
|
||||
}
|
||||
//判断格式是否正确
|
||||
if (!DateUtils.isValidDate((String) value)) {
|
||||
errorMsg += fieldName + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
|
||||
countError++;
|
||||
}
|
||||
|
||||
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) {
|
||||
//多选日期
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断格式是否正确
|
||||
if (!DateUtils.isValidDate((String) value)) {
|
||||
errorMsg += fieldName + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
|
||||
countError++;
|
||||
}
|
||||
|
||||
|
||||
} else if (FieldTypeEnum.FILE.getValue().equals(fieldShowType)) {
|
||||
//文件
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += fieldName + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断长度
|
||||
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
|
||||
errorMsg += fieldName + "不能超过" + dbLength + "个字符";
|
||||
countError++;
|
||||
}
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
value = value.replace(",",",");
|
||||
for (String fileName : value.split(",")) {
|
||||
List<File> nowFileList = FileUnZip.readFileByFilename(filepath, fileName);
|
||||
if (nowFileList.size() == 0) {
|
||||
errorMsg += fieldName + "压缩包中没有" + fileName + "文件; ";
|
||||
countError++;
|
||||
} else {
|
||||
try {
|
||||
FileInputStream input = new FileInputStream(nowFileList.get(0));
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = ossFileService.uploadLocal(multipartFile, "", null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(sb)) {
|
||||
String substring = sb.substring(0, sb.length() - 1);
|
||||
value = substring;
|
||||
}
|
||||
}
|
||||
|
||||
} /*else if (FieldTypeEnum.STANDARD.getValue().equals(fieldShowType)) {
|
||||
//标准选择
|
||||
//判断是否必填
|
||||
if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) {
|
||||
errorMsg += key + "为必填项,不能为空";
|
||||
countError++;
|
||||
}
|
||||
//判断长度
|
||||
if (StringUtils.isNotBlank(value) && value.length() > Long.parseLong(dbLength)) {
|
||||
errorMsg += key + "不能超过" + dbLength + "个字符";
|
||||
countError++;
|
||||
}
|
||||
//判断库中是否存在,如果存在则存id,如果不存在则存输入的值
|
||||
List<Map<String, Object>> listBySerialNumber = getListBySerialNumber(value);
|
||||
String serialNumberStr = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Map<String, Object> stringObjectMap : listBySerialNumber) {
|
||||
sb.append((String) stringObjectMap.get("id") + ",");
|
||||
list.add((String) stringObjectMap.get("serial_number"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
for (String s : value.split(",")) {
|
||||
if (!list.contains(s)) {
|
||||
sb.append(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(sb)) {
|
||||
String substring = sb.toString();
|
||||
if (substring.endsWith(",") || substring.endsWith(",")){
|
||||
substring = substring.substring(0, substring.length() - 1);
|
||||
}
|
||||
value = substring;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if((dto.get(key)== null && value != null) || (dto.get(key)!= null && !dto.get(key).toString().equals(value))){
|
||||
dto.put(key, value); // 覆盖原来的值
|
||||
}
|
||||
}
|
||||
if (countError > 0) {
|
||||
stringMessage.add(errorMsg);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
Map map = new HashMap();
|
||||
if (stringMessage.isEmpty()) {
|
||||
@@ -1711,6 +2058,46 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getImportOnlField(String flag, String cut) {
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(flag);
|
||||
if (fieldList.size() != 0) {
|
||||
//过滤出搜索条件()
|
||||
fieldList = fieldList.stream()
|
||||
.filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm()))
|
||||
|| "条款内容".equals(e.getDbFieldName()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
//树形数据字典
|
||||
List<SysCategoryTreeVO> sysCategoryTree = sysCategoryService.getSysCategoryTreeByCut(cut); // 查询所有 并以树结构返回
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (OnlCgformField onlCgformField : fieldList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (FieldTypeEnum.TREE.getValue().equals(onlCgformField.getFieldShowType())) {
|
||||
List<SysCategoryTreeVO> sysCategoryTreeVOList = sysCategoryTree.stream()
|
||||
.filter(e -> onlCgformField.getDictId().equals(e.getDictId()))
|
||||
.collect(Collectors.toList());
|
||||
map.put("tree", sysCategoryTreeVOList); // 树形结构字段 设置树形结构字段值
|
||||
} else {
|
||||
map.put("tree", new ArrayList<>()); // 其他类型字段 该key为空
|
||||
}
|
||||
|
||||
map.put("area", null);//展示区域。没用到
|
||||
map.put("field_show_type", onlCgformField.getFieldShowType());//类型(判断是下拉还是输入框,等等)
|
||||
map.put("field_must_input", onlCgformField.getFieldMustInput());//是否必填
|
||||
map.put("dict_field", onlCgformField.getDictField()); //下拉类型的数据字典编码
|
||||
map.put("db_field_name", onlCgformField.getDbFieldName());//字段
|
||||
map.put("db_length", onlCgformField.getDbLength());//字段长度
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
map.put("db_field_txt", onlCgformField.getDbFieldTxt());//字段中文名
|
||||
} else {
|
||||
map.put("db_field_txt", onlCgformField.getDbFieldEnName());//字段英文名
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤map中的值为 null的键值对
|
||||
* @param map
|
||||
|
||||
+3
@@ -20,6 +20,8 @@ import com.jero.modules.system.service.ISysDictItemService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -31,6 +33,7 @@ import java.util.stream.Collectors;
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||
public class SarFileSplitInfoServiceImpl extends ServiceImpl<SarFileSplitInfoMapper, SarFileSplitInfoEO> implements ISarFileSplitInfoService {
|
||||
|
||||
@Autowired
|
||||
|
||||
+40
-40
@@ -391,26 +391,26 @@ public class SarFileSplitMenuEOServiceImpl extends ServiceImpl<SarFileSplitMenuE
|
||||
// 查询该节点下所有的 子节点 并修改排序
|
||||
SarFileSplitMenuEO sarMenuEO = new SarFileSplitMenuEO();
|
||||
sarMenuEO.setId(itemsMap.get("menu_id").toString());
|
||||
List<SarFileSplitMenuEO> sarFileSplitMenuEOList = dao.queryAllChildrenByid(sarMenuEO);
|
||||
sarMenuEO = dao.selectByPrimaryKey(sarMenuEO.getId());
|
||||
int maxDisplay = dao.getMaxDisplayByid(sarMenuEO.getId());
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||
sarFileSplitMenuEO.setDisplaySeqStart(Long.valueOf(maxDisplay + 1));
|
||||
sarFileSplitMenuEO.setDisplaySeqEnd(10000L);
|
||||
sarFileSplitMenuEO.setChildrenCount(1L);
|
||||
sarFileSplitMenuEO.setModifyUser(UserUtils.getUserId());
|
||||
sarFileSplitMenuEO.setModifyTime(new Date());
|
||||
sarFileSplitMenuEO.setInfoId(itemsMap.get("info_id").toString());
|
||||
dao.updateDisplaySeqAdd(sarFileSplitMenuEO);
|
||||
// List<SarFileSplitMenuEO> sarFileSplitMenuEOList = dao.queryAllChildrenByid(sarMenuEO);
|
||||
// sarMenuEO = dao.selectByPrimaryKey(sarMenuEO.getId());
|
||||
// int maxDisplay = dao.getMaxDisplayByid(sarMenuEO.getId());
|
||||
// SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||
// sarFileSplitMenuEO.setDisplaySeqStart(Long.valueOf(maxDisplay + 1));
|
||||
// sarFileSplitMenuEO.setDisplaySeqEnd(10000L);
|
||||
// sarFileSplitMenuEO.setChildrenCount(1L);
|
||||
// sarFileSplitMenuEO.setModifyUser(UserUtils.getUserId());
|
||||
// sarFileSplitMenuEO.setModifyTime(new Date());
|
||||
// sarFileSplitMenuEO.setInfoId(itemsMap.get("info_id").toString());
|
||||
// dao.updateDisplaySeqAdd(sarFileSplitMenuEO);
|
||||
|
||||
// SAR_FILE_ITEMS_MENU 添加数据,
|
||||
sarMenuEO.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
sarMenuEO.setDisplaySeq(Long.valueOf(maxDisplay + 1));
|
||||
sarMenuEO.setCreationTime(new Date());
|
||||
sarMenuEO.setModifyTime(new Date());
|
||||
sarMenuEO.setCreationUser(UserUtils.getUserId());
|
||||
sarMenuEO.setModifyUser(UserUtils.getUserId());
|
||||
result = dao.insertSelective(sarMenuEO);
|
||||
// sarMenuEO.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
// sarMenuEO.setDisplaySeq(Long.valueOf(maxDisplay + 1));
|
||||
// sarMenuEO.setCreationTime(new Date());
|
||||
// sarMenuEO.setModifyTime(new Date());
|
||||
// sarMenuEO.setCreationUser(UserUtils.getUserId());
|
||||
// sarMenuEO.setModifyUser(UserUtils.getUserId());
|
||||
// result = dao.insertSelective(sarMenuEO);
|
||||
|
||||
// SAR_FILE_ITEMS 添加数据,
|
||||
String newItemId = UUID.randomUUID().toString().replace("-", "");
|
||||
@@ -440,29 +440,29 @@ public class SarFileSplitMenuEOServiceImpl extends ServiceImpl<SarFileSplitMenuE
|
||||
result += sarFileSplitItemsValEOMapper.insertForeach(sarFileSplitItemsValEOList);
|
||||
}
|
||||
// SAR_FILE_ITEMS_PARAMS 添加数据,
|
||||
List<SarFileSplitItemsParamsEO> sarFileSplitItemsParamsEOList = sarFileSplitItemsParamsMapper.queryItemsParamsByMenuId(oldItemIdList);
|
||||
for (SarFileSplitItemsParamsEO sarFileSplitItemsParamsEO : sarFileSplitItemsParamsEOList) {
|
||||
sarFileSplitItemsParamsEO.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
sarFileSplitItemsParamsEO.setItemId(newItemId);
|
||||
sarFileSplitItemsParamsEO.setCreationTime(new Date());
|
||||
sarFileSplitItemsParamsEO.setModifyTime(new Date());
|
||||
}
|
||||
if (sarFileSplitItemsParamsEOList.size()>0){
|
||||
result += sarFileSplitItemsParamsMapper.insertForeach(sarFileSplitItemsParamsEOList);
|
||||
}
|
||||
// List<SarFileSplitItemsParamsEO> sarFileSplitItemsParamsEOList = sarFileSplitItemsParamsMapper.queryItemsParamsByMenuId(oldItemIdList);
|
||||
// for (SarFileSplitItemsParamsEO sarFileSplitItemsParamsEO : sarFileSplitItemsParamsEOList) {
|
||||
// sarFileSplitItemsParamsEO.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
// sarFileSplitItemsParamsEO.setItemId(newItemId);
|
||||
// sarFileSplitItemsParamsEO.setCreationTime(new Date());
|
||||
// sarFileSplitItemsParamsEO.setModifyTime(new Date());
|
||||
// }
|
||||
// if (sarFileSplitItemsParamsEOList.size()>0){
|
||||
// result += sarFileSplitItemsParamsMapper.insertForeach(sarFileSplitItemsParamsEOList);
|
||||
// }
|
||||
// SAR_FILE_ITEMS_TABLE 添加数据,
|
||||
List<SarFileSplitItemsTableEO> sarFileSplitItemsTableEOList = sarFileSplitItemsTableEOMapper.queryItemsTableByMenuId(oldItemIdList);
|
||||
for (SarFileSplitItemsTableEO sarFileSplitItemsTableEO : sarFileSplitItemsTableEOList) {
|
||||
sarFileSplitItemsTableEO.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
sarFileSplitItemsTableEO.setItemsId(newItemId);
|
||||
sarFileSplitItemsTableEO.setItemsValId(itemValIdMap.get(sarFileSplitItemsTableEO.getItemsValId()).toString());
|
||||
sarFileSplitItemsTableEO.setCreationTime(new Date());
|
||||
sarFileSplitItemsTableEO.setModifyTime(new Date());
|
||||
sarFileSplitItemsTableEO.setModifyUser(UserUtils.getUserId());
|
||||
}
|
||||
if (sarFileSplitItemsTableEOList.size()>0){
|
||||
result += sarFileSplitItemsTableEOMapper.insertForeach(sarFileSplitItemsTableEOList);
|
||||
}
|
||||
// List<SarFileSplitItemsTableEO> sarFileSplitItemsTableEOList = sarFileSplitItemsTableEOMapper.queryItemsTableByMenuId(oldItemIdList);
|
||||
// for (SarFileSplitItemsTableEO sarFileSplitItemsTableEO : sarFileSplitItemsTableEOList) {
|
||||
// sarFileSplitItemsTableEO.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
// sarFileSplitItemsTableEO.setItemsId(newItemId);
|
||||
// sarFileSplitItemsTableEO.setItemsValId(itemValIdMap.get(sarFileSplitItemsTableEO.getItemsValId()).toString());
|
||||
// sarFileSplitItemsTableEO.setCreationTime(new Date());
|
||||
// sarFileSplitItemsTableEO.setModifyTime(new Date());
|
||||
// sarFileSplitItemsTableEO.setModifyUser(UserUtils.getUserId());
|
||||
// }
|
||||
// if (sarFileSplitItemsTableEOList.size()>0){
|
||||
// result += sarFileSplitItemsTableEOMapper.insertForeach(sarFileSplitItemsTableEOList);
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user