dev^2
itcast 1 year ago
parent c33a3ab60c
commit 7f6569753b
  1. 2
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 97
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java
  3. 16
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java

@ -572,7 +572,7 @@ export default {
},
fieldData: function () {
return {
note: ['序号: 请按顺序填入每行数据的序号,比如第一行就写1',
note: ['项目名称(非空): 请填写字段对应的项目名称',
'表名(非空): 请填写实体表的名称',
'中文名称(非空): 请填写字段名称',
'英文名称(非空): 请填写字段名称的英语名称',

@ -366,7 +366,7 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
}
if(!"序号".equals(row.getCell(0).getStringCellValue())||!"表名".equals(row.getCell(1).getStringCellValue())
if(!"项目名称".equals(row.getCell(0).getStringCellValue())||!"表名".equals(row.getCell(1).getStringCellValue())
||!"中文名称".equals(row.getCell(2).getStringCellValue())||!"英文名称".equals(row.getCell(3).getStringCellValue())
||!"数据类型".equals(row.getCell(4).getStringCellValue())||!"数据长度".equals(row.getCell(5).getStringCellValue())
||!"浮点精度".equals(row.getCell(6).getStringCellValue())||!"显示形式".equals(row.getCell(7).getStringCellValue())
@ -426,43 +426,51 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
for (int i=0;i< numberofSheets;i++)
{
Sheet Sheet=workbook.getSheetAt(i);
int physicalNumberOfRows = Sheet.getPhysicalNumberOfRows();
for(int r=3;r<=Sheet.getLastRowNum();r++) {
for(int r=3;r<=physicalNumberOfRows;r++) {
Row cells = Sheet.getRow(r);
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
Cell cell = cells.getCell(0);
if (cell==null||String.valueOf(cell).equals("")) {
break;
}
ExcelInfo excelInfo = new ExcelInfo();
excelInfo.setcells(cells,workbook);
Fieldx222 fieldx222 = new Fieldx222();
if(StringUtil.isBlank(excelInfo.getproject())&&StringUtil.isBlank(excelInfo.getTableId())&&StringUtil.isBlank(excelInfo.getFieldName()))
break;
if(StringUtil.isBlank(excelInfo.getproject())){
message.put("isError", "true");
message.put("status","序号为" + (r + 1) + "的”项目名称”不能为空或是此项目不存在");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r + 1) + "的项目名称不能为空或是此项目不纯在");
}
if (StringUtil.isBlank(excelInfo.getTableId())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”表名”不能为空或是此表不存在");
message.put("status","序号为" + (r + 1) + "的”表名”不能为空或是此表不存在");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的表名不能为空或是此表不纯在");
return Result.error("序号为" + (r + 1) + "的表名不能为空或是此表不纯在");
}
fieldx222.setTableId(excelInfo.getTableId());
if (StringUtil.isBlank(excelInfo.getFieldName())) {
message.put("isError", "true");
message.put("status","序号为 "+ (r - 2) + "的”中文名称”不能为空");
message.put("status","序号为 "+ (r + 1) + "的”中文名称”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的中文名称不能为空");
return Result.error("序号为" + (r + 1) + "的中文名称不能为空");
}
fieldx222.setFieldName(excelInfo.getFieldName());
Fieldx222 fieldx2221=fieldx222Service.query().eq("field_name",excelInfo.getFieldName()).one();
Fieldx222 fieldx2221=fieldx222Service.query().eq("field_name",
excelInfo.getFieldName()).eq("table_id",excelInfo.getTableId()).one();
if(fieldx2221!=null){
message.put("isError", "true");
message.put("status","序号为 "+ (r - 2) + "的”中文名称”与表中数据已重复");
message.put("status","序号为 "+ (r + 1) + "的”中文名称”与表中数据已重复");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的中文名称与表中数据已重复");
return Result.error("序号为" + (r + 1) + "的中文名称与表中数据已重复");
}
fieldx222.setFieldName(excelInfo.getFieldName());
@ -471,45 +479,46 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
List<Fieldx> list=fieldxService.list(queryWrapper);
if(list!=null&&list.size()!=0){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的字段名此表已存在不能重复");
message.put("status","序号为" + (r + 1) + "的字段名此表已存在不能重复");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的字段名此表已存在不能重复");
return Result.error("序号为" + (r + 1) + "的字段名此表已存在不能重复");
}
if (StringUtil.isBlank(excelInfo.getFieldEnName())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”英文名称”不能为空");
message.put("status","序号为" + (r + 1) + "的”英文名称”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的英文名称不能为空");
return Result.error("序号为" + (r + 1) + "的英文名称不能为空");
}
Fieldx222 fieldx2222=fieldx222Service.query().eq("field_en_name",excelInfo.getFieldEnName()).one();
Fieldx222 fieldx2222=fieldx222Service.query().eq("field_en_name",excelInfo.getFieldEnName())
.eq("table_id",excelInfo.getTableId()).one();
if(fieldx2222!=null){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) +" 的”英文名称”与表中数据已重复");
message.put("status","序号为" + (r + 1) +" 的”英文名称”与表中数据已重复");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的英文名称与表中数据已重复");
return Result.error("序号为" + (r + 1) + "的英文名称与表中数据已重复");
}
fieldx222.setFieldEnName(excelInfo.getFieldEnName());
if (StringUtil.isBlank(excelInfo.getType())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”数据类型”不能为空");
message.put("status","序号为" + (r + 1) + "的”数据类型”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的数据类型不能为空");
return Result.error("序号为" + (r + 1) + "的数据类型不能为空");
}
else if(!sjlx.contains(excelInfo.getType())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”数据类型”输入格式不正确");
message.put("status","序号为" + (r + 1) + "的”数据类型”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的数据类型输入格式不正确");
return Result.error("序号为" + (r + 1) + "的数据类型输入格式不正确");
}
fieldx222.setType(excelInfo.getType());
@ -518,11 +527,11 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
}
else if(!sf.contains(excelInfo.getIsPk())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”是否主键”输入格式不正确");
message.put("status","序号为" + (r + 1) + "的”是否主键”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的是否主键输入格式不正确");
return Result.error("序号为" + (r + 1) + "的是否主键输入格式不正确");
}
fieldx222.setIsPk(excelInfo.getIsPk());
if (StringUtil.isBlank(excelInfo.getIsFk())) {
@ -530,79 +539,79 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
}
else if(!sf.contains(excelInfo.getIsFk())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”是否外键”输入格式不正确");
message.put("status","序号为" + (r + 1) + "的”是否外键”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的是否外键输入格式不正确");
return Result.error("序号为" + (r + 1) + "的是否外键输入格式不正确");
}
fieldx222.setIsFk(excelInfo.getIsFk());
if (StringUtil.isBlank(excelInfo.getIsNull())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”是否为空”不能为空");
message.put("status","序号为" + (r + 1) + "的”是否为空”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的是否为空不能为空");
return Result.error("序号为" + (r + 1) + "的是否为空不能为空");
}
else if(!sf.contains(excelInfo.getIsNull())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”是否为空”输入格式不正确");
message.put("status","序号为" + (r + 1)+ "的”是否为空”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的是否为空输入格式不正确");
return Result.error("序号为" + (r + 1) + "的是否为空输入格式不正确");
}
fieldx222.setIsNull(excelInfo.getIsNull());
if (StringUtil.isBlank(excelInfo.getIsUniqueness())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”是否重复”不能为空");
message.put("status","序号为" + (r + 1) + "的”是否重复”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的是否重复不能为空");
return Result.error("序号为" + (r + 1)+ "的是否重复不能为空");
}
else if(!sf.contains(excelInfo.getIsUniqueness())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”是否重复”输入格式不正确");
message.put("status","序号为" + (r + 1) + "的”是否重复”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的是否重复输入格式不正确");
return Result.error("序号为" + (r + 1) + "的是否重复输入格式不正确");
}
fieldx222.setIsUniqueness(excelInfo.getIsUniqueness());
if (StringUtil.isBlank(excelInfo.getStatus())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”字段状态”不能为空");
message.put("status","序号为" + (r + 1)+ "的”字段状态”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的”字段状态”不能为空");
return Result.error("序号为" + (r + 1) + "的”字段状态”不能为空");
}
else if(!zt.contains(excelInfo.getStatus())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”字段状态”输入格式不正确");
message.put("status","序号为" + (r + 1) + "的”字段状态”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的字段状态输入格式不正确");
return Result.error("序号为" + (r + 1) + "的字段状态输入格式不正确");
}
fieldx222.setStatus(excelInfo.getStatus());
if (StringUtil.isBlank(excelInfo.getVerisonStatus())) {
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”版本状态”不能为空");
message.put("status","序号为" + (r + 1) + "的”版本状态”不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的”版本状态”不能为空");
return Result.error("序号为" + (r + 1) + "的”版本状态”不能为空");
}
else if(!sf.contains(excelInfo.getVerisonStatus())){
message.put("isError", "true");
message.put("status","序号为" + (r - 2) + "的”版本状态”输入格式不正确");
message.put("status","序号为" + (r + 1) + "的”版本状态”输入格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
fieldx222Service.remove(null);
return Result.error("序号为" + (r - 2) + "的版本状态输入格式不正确");
return Result.error("序号为" + (r + 1) + "的版本状态输入格式不正确");
}
fieldx222.setVerisonStatus(excelInfo.getVerisonStatus());

@ -2,6 +2,8 @@ package org.jeecg.modules.fieldx.dto;
import com.aliyuncs.utils.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.jeecg.modules.projectx.entity.Projectx;
import org.jeecg.modules.projectx.service.impl.ProjectxServiceImpl;
import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.impl.TablexServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,6 +22,8 @@ public class ExcelInfo {
@Autowired
private TablexServiceImpl tablexService;
@Autowired
private ProjectxServiceImpl projectxService;
public void setcells(Row cells ,Workbook workbook){
this.cells = cells;
@ -30,11 +34,21 @@ public class ExcelInfo {
public void init(){
excelInfo=this;
excelInfo.tablexService=this.tablexService;
excelInfo.projectxService=this.projectxService;
}
public String getproject(){
String value=zhcell((cells.getCell(0)));
if (value==null)
return null;
Projectx projectx=excelInfo.projectxService.query().eq("project_name",value).one();
if(projectx==null)
return null;
return "1";
}
public String getTableId(){
String value=zhcell(cells.getCell(1));
System.out.println("value = ==================================" + value);
if(StringUtils.isEmpty(value))
if(value==null)
return null;
List<Tablex> list =excelInfo.tablexService.query().eq("table_name",value).list();
if(list==null||list.size()==0)

Loading…
Cancel
Save