|
|
@ -1,7 +1,5 @@ |
|
|
|
package org.jeecg.modules.tablex.controller; |
|
|
|
package org.jeecg.modules.tablex.controller; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
@ -42,16 +40,12 @@ import org.jeecg.modules.tablex.vo.TablexVo; |
|
|
|
import org.jeecg.modules.tablex.ws.WebSocketUtils; |
|
|
|
import org.jeecg.modules.tablex.ws.WebSocketUtils; |
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
|
|
|
import org.jeecgframework.poi.excel.def.TemplateExcelConstants; |
|
|
|
|
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams; |
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams; |
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams; |
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams; |
|
|
|
import org.jeecgframework.poi.excel.entity.TemplateExportParams; |
|
|
|
|
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView; |
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest; |
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest; |
|
|
@ -61,435 +55,404 @@ import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description: 实体表 |
|
|
|
* @Description: 实体表 |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Date: 2023-04-10 |
|
|
|
* @Date: 2023-04-10 |
|
|
|
* @Version: V1.0 |
|
|
|
* @Version: V1.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Api(tags = "实体表") |
|
|
|
@Api(tags="实体表") |
|
|
|
@RestController |
|
|
|
@RestController |
|
|
|
@RequestMapping("/tablex/tablex") |
|
|
|
@RequestMapping("/tablex/tablex") |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ITablexService tablexService; |
|
|
|
private ITablexService tablexService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IModulexService modulexService; |
|
|
|
private IModulexService modulexService; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IFieldxService fieldxService; |
|
|
|
private IFieldxService fieldxService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private FieldxController fieldxController; |
|
|
|
private FieldxController fieldxController; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ITablexVoService tablexVoService; |
|
|
|
private ITablexVoService tablexVoService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private IRequirementEntityService requirementEntityService; |
|
|
|
private IRequirementEntityService requirementEntityService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private WebSocketUtils webSocketUtils; |
|
|
|
private WebSocketUtils webSocketUtils; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${jeecg.wordPath}") |
|
|
|
/** |
|
|
|
private String wordPath; |
|
|
|
* 分页列表查询 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param tablex |
|
|
|
* 分页列表查询 |
|
|
|
* @param pageNo |
|
|
|
* |
|
|
|
* @param pageSize |
|
|
|
* @param tablex |
|
|
|
* @param req |
|
|
|
* @param pageNo |
|
|
|
* @return |
|
|
|
* @param pageSize |
|
|
|
*/ |
|
|
|
* @param req |
|
|
|
@AutoLog(value = "实体表-分页列表查询") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "实体表-分页列表查询", notes = "实体表-分页列表查询") |
|
|
|
*/ |
|
|
|
@GetMapping(value = "/list") |
|
|
|
@AutoLog(value = "实体表-分页列表查询") |
|
|
|
public Result<?> queryPageList(Tablex tablex, |
|
|
|
@ApiOperation(value = "实体表-分页列表查询", notes = "实体表-分页列表查询") |
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
@GetMapping(value = "/list") |
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
public Result<?> queryPageList(Tablex tablex, |
|
|
|
HttpServletRequest req) { |
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); |
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
Page<Tablex> page = new Page<Tablex>(pageNo, pageSize); |
|
|
|
HttpServletRequest req) { |
|
|
|
IPage<Tablex> pageList = tablexService.page(page, queryWrapper); |
|
|
|
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); |
|
|
|
return Result.OK(pageList); |
|
|
|
Page<Tablex> page = new Page<Tablex>(pageNo, pageSize); |
|
|
|
} |
|
|
|
IPage<Tablex> pageList = tablexService.page(page, queryWrapper); |
|
|
|
|
|
|
|
return Result.OK(pageList); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 添加 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param tablex |
|
|
|
* 添加 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param tablex |
|
|
|
@AutoLog(value = "实体表-添加") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "实体表-添加", notes = "实体表-添加") |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/add") |
|
|
|
@AutoLog(value = "实体表-添加") |
|
|
|
public Result<?> add(@RequestBody Tablex tablex) { |
|
|
|
@ApiOperation(value = "实体表-添加", notes = "实体表-添加") |
|
|
|
List<Tablex> tablexList = tablexService.list(); |
|
|
|
@PostMapping(value = "/add") |
|
|
|
for (Tablex tablex1 : tablexList) { |
|
|
|
public Result<?> add(@RequestBody Tablex tablex) { |
|
|
|
if (tablex1.getModuleId().equals(tablex.getModuleId())) { |
|
|
|
List<Tablex> tablexList = tablexService.list(); |
|
|
|
return Result.error("该模块已有实体,添加失败"); |
|
|
|
for (Tablex tablex1 : tablexList) { |
|
|
|
} |
|
|
|
if (tablex1.getModuleId().equals(tablex.getModuleId())) { |
|
|
|
} |
|
|
|
return Result.error("该模块已有实体,添加失败"); |
|
|
|
if (tablex.getModuleId() != null) { |
|
|
|
} |
|
|
|
Modulex modulex = modulexService.getById(tablex.getModuleId()); |
|
|
|
} |
|
|
|
tablex.setTableName(modulex.getModuleName()); |
|
|
|
if (tablex.getModuleId() != null) { |
|
|
|
tablex.setTableEnName(modulex.getModuleEnName()); |
|
|
|
Modulex modulex = modulexService.getById(tablex.getModuleId()); |
|
|
|
} |
|
|
|
tablex.setTableName(modulex.getModuleName()); |
|
|
|
tablex.setVerison(1); |
|
|
|
tablex.setTableEnName(modulex.getModuleEnName()); |
|
|
|
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); |
|
|
|
} |
|
|
|
tablexService.save(tablex); |
|
|
|
tablex.setVerison(1); |
|
|
|
System.err.println(tablex.toString()); |
|
|
|
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); |
|
|
|
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); |
|
|
|
tablexService.save(tablex); |
|
|
|
return Result.OK("添加成功!"); |
|
|
|
System.err.println(tablex.toString()); |
|
|
|
} |
|
|
|
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); |
|
|
|
|
|
|
|
return Result.OK("添加成功!"); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 转化 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param tablex |
|
|
|
* 转化 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param tablex |
|
|
|
@AutoLog(value = "转化") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "转化", notes = "转化") |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/zh") |
|
|
|
@AutoLog(value = "转化") |
|
|
|
public Result<?> zh(@RequestBody Tablex tablex,HttpServletRequest req) { |
|
|
|
@ApiOperation(value = "转化", notes = "转化") |
|
|
|
String reid = tablex.getId(); |
|
|
|
@PostMapping(value = "/zh") |
|
|
|
tablex.setId(null); |
|
|
|
public Result<?> zh(@RequestBody Tablex tablex, HttpServletRequest req) { |
|
|
|
List<Tablex> tablexList = tablexService.list(); |
|
|
|
String reid = tablex.getId(); |
|
|
|
for (Tablex tablex1 : tablexList) { |
|
|
|
tablex.setId(null); |
|
|
|
if (tablex1.getModuleId().equals(tablex.getModuleId())) { |
|
|
|
List<Tablex> tablexList = tablexService.list(); |
|
|
|
return Result.error("该模块已有实体,转化失败"); |
|
|
|
for (Tablex tablex1 : tablexList) { |
|
|
|
} |
|
|
|
if (tablex1.getModuleId().equals(tablex.getModuleId())) { |
|
|
|
} |
|
|
|
return Result.error("该模块已有实体,转化失败"); |
|
|
|
RequirementEntity requirementEntity = requirementEntityService.getById(reid); |
|
|
|
} |
|
|
|
tablex.setTableName(requirementEntity.getEntityName()); |
|
|
|
} |
|
|
|
tablex.setTableEnName(requirementEntity.getEntityEnName()); |
|
|
|
RequirementEntity requirementEntity = requirementEntityService.getById(reid); |
|
|
|
tablex.setVerison(1); |
|
|
|
tablex.setTableName(requirementEntity.getEntityName()); |
|
|
|
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); |
|
|
|
tablex.setTableEnName(requirementEntity.getEntityEnName()); |
|
|
|
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); |
|
|
|
tablex.setVerison(1); |
|
|
|
queryWrapper.eq("table_name",tablex.getTableName()).or().eq("table_en_name",tablex.getTableEnName()); |
|
|
|
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); |
|
|
|
List<Tablex> tlist = tablexService.list(queryWrapper); |
|
|
|
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); |
|
|
|
if(tlist.size()>0){ |
|
|
|
queryWrapper.eq("table_name", tablex.getTableName()).or().eq("table_en_name", tablex.getTableEnName()); |
|
|
|
return Result.error("中文或者英文名称重复,不可转化"); |
|
|
|
List<Tablex> tlist = tablexService.list(queryWrapper); |
|
|
|
}else { |
|
|
|
if (tlist.size() > 0) { |
|
|
|
tablexService.save(tablex); |
|
|
|
return Result.error("中文或者英文名称重复,不可转化"); |
|
|
|
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); |
|
|
|
} else { |
|
|
|
requirementEntity.setEntityStatus(3); |
|
|
|
tablexService.save(tablex); |
|
|
|
requirementEntity.setTableId(tablex.getId()); |
|
|
|
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); |
|
|
|
requirementEntity.setModuleId(tablex.getModuleId()); |
|
|
|
requirementEntity.setEntityStatus(3); |
|
|
|
requirementEntityService.updateById(requirementEntity); |
|
|
|
requirementEntity.setTableId(tablex.getId()); |
|
|
|
return Result.OK("转化成功!"); |
|
|
|
requirementEntity.setModuleId(tablex.getModuleId()); |
|
|
|
} |
|
|
|
requirementEntityService.updateById(requirementEntity); |
|
|
|
} |
|
|
|
return Result.OK("转化成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
} |
|
|
|
* 编辑 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param tablex |
|
|
|
* 编辑 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param tablex |
|
|
|
@AutoLog(value = "实体表-编辑") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "实体表-编辑", notes = "实体表-编辑") |
|
|
|
*/ |
|
|
|
@PutMapping(value = "/edit") |
|
|
|
@AutoLog(value = "实体表-编辑") |
|
|
|
public Result<?> edit(@RequestBody Tablex tablex) { |
|
|
|
@ApiOperation(value = "实体表-编辑", notes = "实体表-编辑") |
|
|
|
tablex.setVerison(tablex.getVerison() + 1); |
|
|
|
@PutMapping(value = "/edit") |
|
|
|
List<Tablex> tablexList = tablexService.list(); |
|
|
|
public Result<?> edit(@RequestBody Tablex tablex) { |
|
|
|
for (Tablex tablex1 : tablexList) { |
|
|
|
tablex.setVerison(tablex.getVerison() + 1); |
|
|
|
if (tablex1.getModuleId().equals(tablex.getModuleId())) { |
|
|
|
List<Tablex> tablexList = tablexService.list(); |
|
|
|
return Result.error("该模块已有实体,编辑失败"); |
|
|
|
for (Tablex tablex1 : tablexList) { |
|
|
|
} |
|
|
|
if (tablex1.getModuleId().equals(tablex.getModuleId())) { |
|
|
|
} |
|
|
|
return Result.error("该模块已有实体,编辑失败"); |
|
|
|
if (tablex.getModuleId() != null) { |
|
|
|
} |
|
|
|
Modulex modulex = modulexService.getById(tablex.getModuleId()); |
|
|
|
} |
|
|
|
tablex.setTableName(modulex.getModuleName()); |
|
|
|
if (tablex.getModuleId() != null) { |
|
|
|
tablex.setTableEnName(modulex.getModuleEnName()); |
|
|
|
Modulex modulex = modulexService.getById(tablex.getModuleId()); |
|
|
|
} |
|
|
|
tablex.setTableName(modulex.getModuleName()); |
|
|
|
tablexService.updateById(tablex); |
|
|
|
tablex.setTableEnName(modulex.getModuleEnName()); |
|
|
|
tablexService.updateSql(tablex.getId(), fieldxController.createSql(tablex.getId())); |
|
|
|
} |
|
|
|
return Result.OK("编辑成功!"); |
|
|
|
tablexService.updateById(tablex); |
|
|
|
} |
|
|
|
tablexService.updateSql(tablex.getId(), fieldxController.createSql(tablex.getId())); |
|
|
|
|
|
|
|
return Result.OK("编辑成功!"); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 通过id删除 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param id |
|
|
|
* 通过id删除 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param id |
|
|
|
@AutoLog(value = "实体表-通过id删除") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "实体表-通过id删除", notes = "实体表-通过id删除") |
|
|
|
*/ |
|
|
|
@DeleteMapping(value = "/delete") |
|
|
|
@AutoLog(value = "实体表-通过id删除") |
|
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
|
|
|
@ApiOperation(value = "实体表-通过id删除", notes = "实体表-通过id删除") |
|
|
|
List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", id)); |
|
|
|
@DeleteMapping(value = "/delete") |
|
|
|
if (!fieldxList.isEmpty()) { |
|
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
|
|
|
return Result.error("该表内已有字段,不能删除"); |
|
|
|
List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", id)); |
|
|
|
} |
|
|
|
if (!fieldxList.isEmpty()) { |
|
|
|
List<Fieldx> fieldxList1 = fieldxService.list(new QueryWrapper<Fieldx>().eq("associate_table", id)); |
|
|
|
return Result.error("该表内已有字段,不能删除"); |
|
|
|
if (!fieldxList1.isEmpty()) { |
|
|
|
} |
|
|
|
return Result.error("该表已被关联,不能删除"); |
|
|
|
List<Fieldx> fieldxList1 = fieldxService.list(new QueryWrapper<Fieldx>().eq("associate_table", id)); |
|
|
|
} |
|
|
|
if (!fieldxList1.isEmpty()) { |
|
|
|
tablexService.removeById(id); |
|
|
|
return Result.error("该表已被关联,不能删除"); |
|
|
|
return Result.OK("删除成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
tablexService.removeById(id); |
|
|
|
|
|
|
|
return Result.OK("删除成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
|
|
|
|
* 批量删除 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param ids |
|
|
|
* 批量删除 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param ids |
|
|
|
@AutoLog(value = "实体表-批量删除") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "实体表-批量删除", notes = "实体表-批量删除") |
|
|
|
*/ |
|
|
|
@DeleteMapping(value = "/deleteBatch") |
|
|
|
@AutoLog(value = "实体表-批量删除") |
|
|
|
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
|
|
|
@ApiOperation(value = "实体表-批量删除", notes = "实体表-批量删除") |
|
|
|
this.tablexService.removeByIds(Arrays.asList(ids.split(","))); |
|
|
|
@DeleteMapping(value = "/deleteBatch") |
|
|
|
return Result.OK("批量删除成功!"); |
|
|
|
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
|
|
|
} |
|
|
|
this.tablexService.removeByIds(Arrays.asList(ids.split(","))); |
|
|
|
|
|
|
|
return Result.OK("批量删除成功!"); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 通过id查询 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param id |
|
|
|
* 通过id查询 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param id |
|
|
|
@AutoLog(value = "实体表-通过id查询") |
|
|
|
* @return |
|
|
|
@ApiOperation(value = "实体表-通过id查询", notes = "实体表-通过id查询") |
|
|
|
*/ |
|
|
|
@GetMapping(value = "/queryById") |
|
|
|
@AutoLog(value = "实体表-通过id查询") |
|
|
|
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
|
|
|
@ApiOperation(value = "实体表-通过id查询", notes = "实体表-通过id查询") |
|
|
|
Tablex tablex = tablexService.getById(id); |
|
|
|
@GetMapping(value = "/queryById") |
|
|
|
if (tablex == null) { |
|
|
|
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
|
|
|
return Result.error("未找到对应数据"); |
|
|
|
Tablex tablex = tablexService.getById(id); |
|
|
|
} |
|
|
|
if (tablex == null) { |
|
|
|
return Result.OK(tablex); |
|
|
|
return Result.error("未找到对应数据"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return Result.OK(tablex); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 导出excel |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param request |
|
|
|
* 导出excel |
|
|
|
* @param tablex |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param request |
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
* @param tablex |
|
|
|
public ModelAndView exportXls(HttpServletRequest request, Tablex tablex) { |
|
|
|
*/ |
|
|
|
return super.exportXls(request, tablex, Tablex.class, "实体表"); |
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
} |
|
|
|
public ModelAndView exportXls(HttpServletRequest request, Tablex tablex) { |
|
|
|
|
|
|
|
return super.exportXls(request, tablex, Tablex.class, "实体表"); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 通过excel导入数据 |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param file |
|
|
|
* 通过excel导入数据 |
|
|
|
* @return |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param file |
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
* @return |
|
|
|
public Result<?> importExcel(MultipartFile file) { |
|
|
|
*/ |
|
|
|
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
public Result<?> importExcel(MultipartFile file) { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> message = new HashMap<>(); |
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
message.put("isVisible", "true"); |
|
|
|
|
|
|
|
message.put("uploaded", "0"); |
|
|
|
Map<String, String> message = new HashMap<>(); |
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
message.put("isVisible", "true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
message.put("uploaded", "0"); |
|
|
|
|
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 判断文件是否是表格
|
|
|
|
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
|
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
|
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取上传文件对象
|
|
|
|
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
|
|
|
|
params.setTitleRows(1);//表格标题行数,默认0
|
|
|
|
|
|
|
|
params.setHeadRows(1);//表头行数,默认1
|
|
|
|
|
|
|
|
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
|
|
|
|
|
|
|
|
List<TablexVo> list = null; |
|
|
|
|
|
|
|
message.put("status", "读取数据中"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
//读取excel数据
|
|
|
|
|
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("文件读取失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//判断文件中是否存在数据
|
|
|
|
|
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message.put("status", "数据预读入"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
for (TablexVo tablexVo : list) { |
|
|
|
|
|
|
|
//判断当前存入行是否为空值
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(tablexVo.getModuleId()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getTableName()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getTableEnName()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getTableStructure()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getStructuralDiagram()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getStatus()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getVerisonStatus()) && |
|
|
|
|
|
|
|
StringUtils.isBlank(tablexVo.getVerison())) { |
|
|
|
|
|
|
|
list.remove(tablexVo); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//判断版本号长度
|
|
|
|
|
|
|
|
String verison = tablexVo.getVerison(); |
|
|
|
|
|
|
|
if (verison.length() > 5) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("预读入失败,版本号格式错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//存入临时表中
|
|
|
|
|
|
|
|
tablexVoService.save(tablexVo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//从临时表中取出数据
|
|
|
|
|
|
|
|
List<TablexVo> voList = tablexVoService.list(); |
|
|
|
|
|
|
|
// 将总的记录数传递给前端
|
|
|
|
|
|
|
|
message.put("records", String.valueOf(voList.size())); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
//删除临时表中的数据
|
|
|
|
|
|
|
|
tablexVoService.removeAll(voList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (voList.size() == 0) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,数据为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message.put("status", "开始数据校验"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
for (int i = 0; i < voList.size(); i++) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Tablex> tablexList = new ArrayList<>(); |
|
|
|
|
|
|
|
Tablex tablex = new Tablex(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String moduleId = voList.get(i).getModuleId(); |
|
|
|
|
|
|
|
if (moduleId == null || moduleId.equals("")) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.eq(Modulex::getId, moduleId); |
|
|
|
|
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
|
|
|
|
if (modulex == null) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String modulexId = modulex.getId(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String status = voList.get(i).getStatus(); |
|
|
|
|
|
|
|
String verisonStatus = voList.get(i).getVerisonStatus(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断实体状态
|
|
|
|
|
|
|
|
//int statusInt = status.equals("正常") ? 1 : status.equals("停用") ? 0 : status.equals("废弃") ? 9 : 3;
|
|
|
|
|
|
|
|
//判断版本状态
|
|
|
|
|
|
|
|
//int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断对应模块
|
|
|
|
|
|
|
|
if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) { |
|
|
|
|
|
|
|
//判断中文名称
|
|
|
|
|
|
|
|
if (voList.get(i).getTableName() != null && !voList.get(i).getTableName().equals("") && !voList.get(i).getTableName().equals(modulex.getModuleName())) { |
|
|
|
|
|
|
|
//判断英文名称
|
|
|
|
|
|
|
|
if (voList.get(i).getTableEnName() != null && !voList.get(i).getTableEnName().equals("") && !voList.get(i).getTableEnName().equals(modulex.getModuleEnName())) { |
|
|
|
|
|
|
|
//判断实体状态
|
|
|
|
|
|
|
|
if (status.equals("1") || status.equals("0") || status.equals("9")) { |
|
|
|
|
|
|
|
//判断版本状态
|
|
|
|
|
|
|
|
if (verisonStatus.equals("1") || verisonStatus.equals("0")) { |
|
|
|
|
|
|
|
//判断版本号
|
|
|
|
|
|
|
|
if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) { |
|
|
|
|
|
|
|
tablex.setModuleId(voList.get(i).getModuleId()); |
|
|
|
|
|
|
|
tablex.setTableName(voList.get(i).getTableName()); |
|
|
|
|
|
|
|
tablex.setTableEnName(voList.get(i).getTableEnName()); |
|
|
|
|
|
|
|
tablex.setTableStructure(voList.get(i).getTableStructure()); |
|
|
|
|
|
|
|
tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); |
|
|
|
|
|
|
|
tablex.setCreateBy(loginUser.getRealname()); |
|
|
|
|
|
|
|
tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); |
|
|
|
|
|
|
|
tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); |
|
|
|
|
|
|
|
tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tablexList.add(tablex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//单条保存到真实表中
|
|
|
|
|
|
|
|
tablexService.saveSingleBatch(tablexList, loginUser, message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/*message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("文件导入失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*message.put("isVisible", "false");*/ |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导出实体标准模板
|
|
|
|
|
|
|
|
@RequestMapping(value = "/templateExcel") |
|
|
|
|
|
|
|
public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
|
|
|
|
//设置导出文件名称
|
|
|
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
|
|
Date date = new Date(System.currentTimeMillis()); |
|
|
|
|
|
|
|
String currTime = formatter.format(date); |
|
|
|
|
|
|
|
String fileName = currTime + "-" + "模板.xlsx"; |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
String url = getClass().getClassLoader().getResource("static").getPath(); |
|
|
|
// 判断文件是否是表格
|
|
|
|
// 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
String templateUrl = wordPath + File.separator + "实体表模板.xls"; |
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
TemplateExportParams params = new TemplateExportParams( |
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
templateUrl); |
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView()); |
|
|
|
message.put("isVisible", "false"); |
|
|
|
mv.addObject(TemplateExcelConstants.FILE_NAME, fileName); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
mv.addObject(TemplateExcelConstants.PARAMS, params); |
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
// 添加模板参数
|
|
|
|
} |
|
|
|
mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data
|
|
|
|
|
|
|
|
return mv; |
|
|
|
//获取上传文件对象
|
|
|
|
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
|
|
|
|
params.setTitleRows(1);//表格标题行数,默认0
|
|
|
|
|
|
|
|
params.setHeadRows(1);//表头行数,默认1
|
|
|
|
|
|
|
|
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
|
|
|
|
|
|
|
|
List<TablexVo> list = null; |
|
|
|
|
|
|
|
message.put("status", "读取数据中"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
//读取excel数据
|
|
|
|
|
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("文件读取失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//判断文件中是否存在数据
|
|
|
|
|
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message.put("status", "数据预读入"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
for (TablexVo tablexVo : list) { |
|
|
|
|
|
|
|
//判断当前存入行是否为空值
|
|
|
|
|
|
|
|
if (tablexVo.getModuleId() == null && |
|
|
|
|
|
|
|
tablexVo.getTableName() == null && |
|
|
|
|
|
|
|
tablexVo.getTableEnName() == null && |
|
|
|
|
|
|
|
tablexVo.getTableStructure() == null && |
|
|
|
|
|
|
|
tablexVo.getStructuralDiagram() == null && |
|
|
|
|
|
|
|
tablexVo.getStatus() == null && |
|
|
|
|
|
|
|
tablexVo.getVerisonStatus() == null && |
|
|
|
|
|
|
|
tablexVo.getVerison() == null) continue; |
|
|
|
|
|
|
|
// 将总的记录数传递给前端
|
|
|
|
|
|
|
|
message.put("records", String.valueOf(list.size())); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断版本号长度
|
|
|
|
|
|
|
|
String verison = tablexVo.getVerison(); |
|
|
|
|
|
|
|
if (verison.length() > 5) { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("预读入失败,版本号格式错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//存入临时表中
|
|
|
|
|
|
|
|
tablexVoService.save(tablexVo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从临时表中取出数据
|
|
|
|
|
|
|
|
List<TablexVo> voList = tablexVoService.list(); |
|
|
|
|
|
|
|
//删除临时表中的数据
|
|
|
|
|
|
|
|
tablexVoService.removeAll(voList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (voList.size() == 0) { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,数据为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message.put("status", "开始数据校验"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
for (int i = 0; i < voList.size(); i++) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Tablex> tablexList = new ArrayList<>(); |
|
|
|
|
|
|
|
Tablex tablex = new Tablex(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String moduleId = voList.get(i).getModuleId(); |
|
|
|
|
|
|
|
if (moduleId == null || moduleId.equals("")){ |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.eq(Modulex::getId,moduleId); |
|
|
|
|
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
|
|
|
|
if(modulex == null){ |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String modulexId = modulex.getId(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String status = voList.get(i).getStatus(); |
|
|
|
|
|
|
|
String verisonStatus = voList.get(i).getVerisonStatus(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断实体状态
|
|
|
|
|
|
|
|
//int statusInt = status.equals("正常") ? 1 : status.equals("停用") ? 0 : status.equals("废弃") ? 9 : 3;
|
|
|
|
|
|
|
|
//判断版本状态
|
|
|
|
|
|
|
|
//int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断对应模块
|
|
|
|
|
|
|
|
if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) { |
|
|
|
|
|
|
|
//判断中文名称
|
|
|
|
|
|
|
|
if (voList.get(i).getTableName() != null && !voList.get(i).getTableName().equals("") && !voList.get(i).getTableName().equals(modulex.getModuleName())) { |
|
|
|
|
|
|
|
//判断英文名称
|
|
|
|
|
|
|
|
if (voList.get(i).getTableEnName() != null && !voList.get(i).getTableEnName().equals("") && !voList.get(i).getTableEnName().equals(modulex.getModuleEnName())) { |
|
|
|
|
|
|
|
//判断实体状态
|
|
|
|
|
|
|
|
if (status.equals("1") || status.equals("0") || status.equals("9")) { |
|
|
|
|
|
|
|
//判断版本状态
|
|
|
|
|
|
|
|
if (verisonStatus.equals("1") || verisonStatus.equals("0")) { |
|
|
|
|
|
|
|
//判断版本号
|
|
|
|
|
|
|
|
if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) { |
|
|
|
|
|
|
|
tablex.setModuleId(voList.get(i).getModuleId()); |
|
|
|
|
|
|
|
tablex.setTableName(voList.get(i).getTableName()); |
|
|
|
|
|
|
|
tablex.setTableEnName(voList.get(i).getTableEnName()); |
|
|
|
|
|
|
|
tablex.setTableStructure(voList.get(i).getTableStructure()); |
|
|
|
|
|
|
|
tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); |
|
|
|
|
|
|
|
tablex.setCreateBy(loginUser.getRealname()); |
|
|
|
|
|
|
|
tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); |
|
|
|
|
|
|
|
tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); |
|
|
|
|
|
|
|
tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tablexList.add(tablex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//单条保存到真实表中
|
|
|
|
|
|
|
|
tablexService.saveSingleBatch(tablexList,loginUser,message); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("下载模板异常--》{}", e); |
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.error("文件导入失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|