更新导入实体新页面

dev^2
mqh 1 year ago
parent 7f3093b53c
commit c4fb53431f
  1. 89
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 99
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
  3. 795
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java

@ -124,26 +124,28 @@
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" <!-- <a-upload name="file" :showUploadList="false" :multiple="false"
:headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel">--> :headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel">-->
<a-button type="primary" icon="import" @click="showProcess()">导入实体</a-button> <a-button type="primary" icon="import"
<!-- <a-button type="primary" icon="import" @click="showModalImport()">导入实体</a-button>--> @click="showProcess( 1)">导入实体
<a-modal </a-button>
title="正在上传..." <!-- <a-button type="primary" icon="import" @click="showModalImport()">导入实体</a-button>-->
:visible="ModalData.isVisible==='true'" <!-- <a-modal
:confirm-loading="false" title="正在上传..."
:mask="true" :visible="ModalData.isVisible==='true'"
:maskClosable="false" :confirm-loading="false"
:keyboard="false" :mask="true"
:closable="false" :maskClosable="false"
:footer="false" :keyboard="false"
> :closable="false"
<p>当前状态{{ ModalData.status }}</p> :footer="false"
<p>总记录数{{ ModalData.records }}</p> >
<p>已上传{{ ModalData.uploaded }}</p> <p>当前状态{{ ModalData.status }}</p>
<a-progress <p>总记录数{{ ModalData.records }}</p>
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))" <p>已上传{{ ModalData.uploaded }}</p>
title="上传进度:" <a-progress
status="active" :steps="ModalData.records"/> :percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
</a-modal> title="上传进度:"
status="active" :steps="ModalData.records"/>
</a-modal>-->
<!-- </a-upload>--> <!-- </a-upload>-->
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button> <a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
@ -484,6 +486,7 @@ export default {
importExcelUrl: "modulex/modulex/importExcel", importExcelUrl: "modulex/modulex/importExcel",
functionImportExcelUrl: "/functionx/functionx/importExcel", functionImportExcelUrl: "/functionx/functionx/importExcel",
tablexImportExcelUrl: "tablex/tablex/importExcel", tablexImportExcelUrl: "tablex/tablex/importExcel",
tablexDownExcelUrl: "tablex/tablex/templateExcel",
ruleImportExcelUrl: "rulex/rulex/importExcel", ruleImportExcelUrl: "rulex/rulex/importExcel",
exportxsxl: "modulex/modulex/exportxsxl" exportxsxl: "modulex/modulex/exportxsxl"
}, },
@ -502,7 +505,7 @@ export default {
this.loginRole(usercode) this.loginRole(usercode)
//console.log('userole1',this.userRole1) //console.log('userole1',this.userRole1)
this.getSuperFieldList() this.getSuperFieldList()
this.showProcess() /* this.showProcess()*/
}, },
computed: { computed: {
importExcelUrl: function () { importExcelUrl: function () {
@ -521,32 +524,48 @@ export default {
tablexImportExcelUrl: function () { tablexImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.tablexImportExcelUrl}`; return `${window._CONFIG['domianURL']}/${this.url.tablexImportExcelUrl}`;
}, },
tablexDownExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.tablexDownExcelUrl}`;
},
ruleImportExcelUrl: function () { ruleImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.ruleImportExcelUrl}` return `${window._CONFIG['domianURL']}/${this.url.ruleImportExcelUrl}`
}, },
}, },
methods: { methods: {
showModalImport() {
this.$refs.moduleximport.edit(this.ModalData);
// this.$refs.moduleximport.title = "111111";
this.$refs.moduleximport.disableSubmit = false;
},
// //
showProcess() { showProcess(type) {
let data = {
uploadUrl: '',
downUrl: '',
title: '',
note: []
}
switch (type) {
case 1: {
data.note = ['对应模块id(必填):填写正确的模块名称',
'中文名称(必填):与模块名称相同。',
'英文名称(必填):与模块名称相同,写模块名称的英文名称。',
'结构图(选填):类图或E-R图,可以为空,不填写。',
'实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。',
'版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态',
'版本号:请填写小与五位数的正整数'
]
data.title = '导入实体'
data.uploadUrl = this.tablexImportExcelUrl
data.downUrl = this.tablexDownExcelUrl
break;
}
default: {
return
}
}
let userId = store.getters.userInfo.id let userId = store.getters.userInfo.id
let base_url = window._CONFIG['domianURL'] let base_url = window._CONFIG['domianURL']
base_url = base_url.replace('http', 'ws') base_url = base_url.replace('http', 'ws')
let ws = new WebSocket(`${base_url}/uploadProcess/${userId}`) let ws = new WebSocket(`${base_url}/uploadProcess/${userId}`)
this.$refs.moduleximport.show(this.tablexImportExcelUrl,''); this.$refs.moduleximport.show(data);
ws.onmessage = (e) => { ws.onmessage = (e) => {
// this.ModalData = JSON.parse(e.data)
this.$refs.moduleximport.edit(JSON.parse(e.data)); this.$refs.moduleximport.edit(JSON.parse(e.data));
// if (JSON.parse(e.data).isVisible === 'false') {
// this.$refs.moduleximport.close();
// // this.getList()
// console.log("")
// }
} }
}, },
// //

@ -24,50 +24,26 @@
</div> </div>
</a-form-item> </a-form-item>
<a-form-item label="上传标准表格"> <a-form-item label="上传标准表格">
<!-- @click="showProcess" -->
<!-- <a-upload
:multiple="false"
:action="url.uploadUrl"
@change="handleChange"
>-->
<a-upload name="file" <a-upload name="file"
:multiple="false" :multiple="false"
:action="url.uploadUrl" :action="url.uploadUrl"
@change="handleChange"
:showUploadList="false" :showUploadList="false"
:headers="tokenHeader"> :headers="tokenHeader">
<a-button type="primary" icon="upload"></a-button> <a-button type="primary" icon="upload"></a-button>
<div v-if="ModalData.isVisible==='true'">
<p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p>
<a-progress
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:"
status="active"
:steps="ModalData.records"/>
</div>
</a-upload> </a-upload>
</a-form-item> </a-form-item>
<!-- <a-modal--> <a-form-item v-if="ModalData.isVisible==='true'" class="box">
<!-- title="正在上传..."--> <p>当前状态{{ ModalData.status }}</p>
<!-- :visible="ModalData.isVisible==='true'"--> <p>总记录数{{ ModalData.records }}</p>
<!-- :confirm-loading="false"--> <p>已上传{{ ModalData.uploaded }}</p>
<!-- :mask="true"--> <a-progress
<!-- :maskClosable="false"--> :percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
<!-- :keyboard="false"--> title="上传进度:"
<!-- :closable="false"--> status="active"
<!-- :footer="false"--> :steps="ModalData.records"/>
<!-- >--> </a-form-item>
<!-- <p>当前状态{{ ModalData.status }}</p>--> <!-- <a-form-model-item label="注意事项" v-if="uploadFinished">-->
<!-- <p>总记录数{{ ModalData.records }}</p>--> <a-form-model-item label="注意事项">
<!-- <p>已上传{{ ModalData.uploaded }}</p>-->
<!-- <a-progress-->
<!-- :percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"-->
<!-- title="上传进度:"-->
<!-- status="active" :steps="ModalData.records"/>-->
<!-- </a-modal>-->
<a-form-model-item label="注意事项" v-if="uploadFinished">
<a-list size="small" :data-source="datas"> <a-list size="small" :data-source="datas">
<a-list-item slot="renderItem" slot-scope="item,index" style="border-bottom:0px ;"> {{ index + 1 }} . {{ <a-list-item slot="renderItem" slot-scope="item,index" style="border-bottom:0px ;"> {{ index + 1 }} . {{
item item
@ -80,7 +56,7 @@
</template> </template>
<script> <script>
import getAction from '@api/manage' import {getAction} from "@api/manage"
import store from '@/store' import store from '@/store'
import {JeecgListMixin} from '@/mixins/JeecgListMixin' import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {mixinDevice} from '@/utils/mixin' import {mixinDevice} from '@/utils/mixin'
@ -91,7 +67,7 @@ export default {
comments: {}, comments: {},
data() { data() {
return { return {
title: '', title: '导入xxxxx',
visible: false, visible: false,
model: {}, model: {},
// //
@ -107,7 +83,8 @@ export default {
url: url:
{ {
downfile: '', downfile: '',
uploadUrl: '' uploadUrl: '',
list: "/modulex/modulex/list"
}, },
datas: [ datas: [
'Racing car sprays burning fuel into crowd.', 'Racing car sprays burning fuel into crowd.',
@ -116,6 +93,7 @@ export default {
'Man charged over missing wedding girl.', 'Man charged over missing wedding girl.',
'Los Angeles battles huge wildfires.' 'Los Angeles battles huge wildfires.'
] ]
} }
}, },
created() { created() {
@ -151,31 +129,36 @@ export default {
}, },
// //
handleDownload() { handleDownload() {
console.log(1111) // getAction(this.url.list, params).then((res) =>
// getAction(this.url.downfile).then(response => { getAction(this.url.downfile).then((response) => {
// const url = window.URL.createObjectURL(new Blob([response.data])) const url = window.URL.createObjectURL(new Blob([response.data]))
// const link = document.createElement('a') const link = document.createElement('a')
// link.href = url link.href = url
// link.setAttribute('download', 'your-document.pdf') link.setAttribute('download', 'your-document.pdf')
// document.body.appendChild(link) document.body.appendChild(link)
// link.click() link.click()
// }) })
// .catch(error => { .catch(error => {
// console.error(error) console.error(error)
// }) })
}, },
add() { add() {
}, },
show(uploadUrl, downUrl) { show(data) {
this.url.uploadUrl = uploadUrl this.url.uploadUrl = data.uploadUrl
this.url.downfile = downUrl this.url.downfile = data.downUrl
this.datas=data.note
this.title=data.title
this.ModalData = {}
this.visible = true this.visible = true
}, },
edit(record) { edit(record) {
// this.visible = true
this.ModalData = record this.ModalData = record
}, },
edit1(record) {
this.visible = true
},
close() { close() {
this.$emit('close') this.$emit('close')
@ -206,4 +189,10 @@ export default {
width: 85%; width: 85%;
float: right; float: right;
} }
.box{
display: flex;
flex-direction:column;
justify-content:center;
align-items: center;
}
</style> </style>

@ -51,6 +51,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView; 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;
@ -60,408 +61,412 @@ 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 req * @param tablex
* @return * @param pageNo
*/ * @param pageSize
@AutoLog(value = "实体表-分页列表查询") * @param req
@ApiOperation(value = "实体表-分页列表查询", notes = "实体表-分页列表查询") * @return
@GetMapping(value = "/list") */
public Result<?> queryPageList(Tablex tablex, @AutoLog(value = "实体表-分页列表查询")
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @ApiOperation(value = "实体表-分页列表查询", notes = "实体表-分页列表查询")
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @GetMapping(value = "/list")
HttpServletRequest req) { public Result<?> queryPageList(Tablex tablex,
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
Page<Tablex> page = new Page<Tablex>(pageNo, pageSize); @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
IPage<Tablex> pageList = tablexService.page(page, queryWrapper); HttpServletRequest req) {
return Result.OK(pageList); QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap());
} Page<Tablex> page = new Page<Tablex>(pageNo, pageSize);
IPage<Tablex> pageList = tablexService.page(page, queryWrapper);
/** return Result.OK(pageList);
* 添加 }
*
* @param tablex /**
* @return * 添加
*/ *
@AutoLog(value = "实体表-添加") * @param tablex
@ApiOperation(value = "实体表-添加", notes = "实体表-添加") * @return
@PostMapping(value = "/add") */
public Result<?> add(@RequestBody Tablex tablex) { @AutoLog(value = "实体表-添加")
List<Tablex> tablexList = tablexService.list(); @ApiOperation(value = "实体表-添加", notes = "实体表-添加")
for (Tablex tablex1 : tablexList) { @PostMapping(value = "/add")
if (tablex1.getModuleId().equals(tablex.getModuleId())) { public Result<?> add(@RequestBody Tablex tablex) {
return Result.error("该模块已有实体,添加失败"); List<Tablex> tablexList = tablexService.list();
} for (Tablex tablex1 : tablexList) {
} if (tablex1.getModuleId().equals(tablex.getModuleId())) {
if (tablex.getModuleId() != null) { return Result.error("该模块已有实体,添加失败");
Modulex modulex = modulexService.getById(tablex.getModuleId()); }
tablex.setTableName(modulex.getModuleName()); }
tablex.setTableEnName(modulex.getModuleEnName()); if (tablex.getModuleId() != null) {
} Modulex modulex = modulexService.getById(tablex.getModuleId());
tablex.setVerison(1); tablex.setTableName(modulex.getModuleName());
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); tablex.setTableEnName(modulex.getModuleEnName());
tablexService.save(tablex); }
System.err.println(tablex.toString()); tablex.setVerison(1);
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();");
return Result.OK("添加成功!"); tablexService.save(tablex);
} System.err.println(tablex.toString());
modulexService.setmodule(tablex.getId(), tablex.getModuleId());
/** return Result.OK("添加成功!");
* 转化 }
*
* @param tablex /**
* @return * 转化
*/ *
@AutoLog(value = "转化") * @param tablex
@ApiOperation(value = "转化", notes = "转化") * @return
@PostMapping(value = "/zh") */
public Result<?> zh(@RequestBody Tablex tablex,HttpServletRequest req) { @AutoLog(value = "转化")
String reid = tablex.getId(); @ApiOperation(value = "转化", notes = "转化")
tablex.setId(null); @PostMapping(value = "/zh")
List<Tablex> tablexList = tablexService.list(); public Result<?> zh(@RequestBody Tablex tablex, HttpServletRequest req) {
for (Tablex tablex1 : tablexList) { String reid = tablex.getId();
if (tablex1.getModuleId().equals(tablex.getModuleId())) { tablex.setId(null);
return Result.error("该模块已有实体,转化失败"); List<Tablex> tablexList = tablexService.list();
} for (Tablex tablex1 : tablexList) {
} if (tablex1.getModuleId().equals(tablex.getModuleId())) {
RequirementEntity requirementEntity = requirementEntityService.getById(reid); return Result.error("该模块已有实体,转化失败");
tablex.setTableName(requirementEntity.getEntityName()); }
tablex.setTableEnName(requirementEntity.getEntityEnName()); }
tablex.setVerison(1); RequirementEntity requirementEntity = requirementEntityService.getById(reid);
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); tablex.setTableName(requirementEntity.getEntityName());
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); tablex.setTableEnName(requirementEntity.getEntityEnName());
queryWrapper.eq("table_name",tablex.getTableName()).or().eq("table_en_name",tablex.getTableEnName()); tablex.setVerison(1);
List<Tablex> tlist = tablexService.list(queryWrapper); tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();");
if(tlist.size()>0){ QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap());
return Result.error("中文或者英文名称重复,不可转化"); queryWrapper.eq("table_name", tablex.getTableName()).or().eq("table_en_name", tablex.getTableEnName());
}else { List<Tablex> tlist = tablexService.list(queryWrapper);
tablexService.save(tablex); if (tlist.size() > 0) {
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); return Result.error("中文或者英文名称重复,不可转化");
requirementEntity.setEntityStatus(3); } else {
requirementEntity.setTableId(tablex.getId()); tablexService.save(tablex);
requirementEntity.setModuleId(tablex.getModuleId()); modulexService.setmodule(tablex.getId(), tablex.getModuleId());
requirementEntityService.updateById(requirementEntity); requirementEntity.setEntityStatus(3);
return Result.OK("转化成功!"); requirementEntity.setTableId(tablex.getId());
} requirementEntity.setModuleId(tablex.getModuleId());
} requirementEntityService.updateById(requirementEntity);
return Result.OK("转化成功!");
/** }
* 编辑 }
*
* @param tablex /**
* @return * 编辑
*/ *
@AutoLog(value = "实体表-编辑") * @param tablex
@ApiOperation(value = "实体表-编辑", notes = "实体表-编辑") * @return
@PutMapping(value = "/edit") */
public Result<?> edit(@RequestBody Tablex tablex) { @AutoLog(value = "实体表-编辑")
tablex.setVerison(tablex.getVerison() + 1); @ApiOperation(value = "实体表-编辑", notes = "实体表-编辑")
List<Tablex> tablexList = tablexService.list(); @PutMapping(value = "/edit")
for (Tablex tablex1 : tablexList) { public Result<?> edit(@RequestBody Tablex tablex) {
if (tablex1.getModuleId().equals(tablex.getModuleId())) { tablex.setVerison(tablex.getVerison() + 1);
return Result.error("该模块已有实体,编辑失败"); List<Tablex> tablexList = tablexService.list();
} for (Tablex tablex1 : tablexList) {
} if (tablex1.getModuleId().equals(tablex.getModuleId())) {
if (tablex.getModuleId() != null) { return Result.error("该模块已有实体,编辑失败");
Modulex modulex = modulexService.getById(tablex.getModuleId()); }
tablex.setTableName(modulex.getModuleName()); }
tablex.setTableEnName(modulex.getModuleEnName()); if (tablex.getModuleId() != null) {
} Modulex modulex = modulexService.getById(tablex.getModuleId());
tablexService.updateById(tablex); tablex.setTableName(modulex.getModuleName());
tablexService.updateSql(tablex.getId(), fieldxController.createSql(tablex.getId())); tablex.setTableEnName(modulex.getModuleEnName());
return Result.OK("编辑成功!"); }
} tablexService.updateById(tablex);
tablexService.updateSql(tablex.getId(), fieldxController.createSql(tablex.getId()));
/** return Result.OK("编辑成功!");
* 通过id删除 }
*
* @param id /**
* @return * 通过id删除
*/ *
@AutoLog(value = "实体表-通过id删除") * @param id
@ApiOperation(value = "实体表-通过id删除", notes = "实体表-通过id删除") * @return
@DeleteMapping(value = "/delete") */
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { @AutoLog(value = "实体表-通过id删除")
List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", id)); @ApiOperation(value = "实体表-通过id删除", notes = "实体表-通过id删除")
if (!fieldxList.isEmpty()) { @DeleteMapping(value = "/delete")
return Result.error("该表内已有字段,不能删除"); public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
} List<Fieldx> fieldxList = fieldxService.list(new QueryWrapper<Fieldx>().eq("table_id", id));
List<Fieldx> fieldxList1 = fieldxService.list(new QueryWrapper<Fieldx>().eq("associate_table", id)); if (!fieldxList.isEmpty()) {
if (!fieldxList1.isEmpty()) { return Result.error("该表内已有字段,不能删除");
return Result.error("该表已被关联,不能删除"); }
} List<Fieldx> fieldxList1 = fieldxService.list(new QueryWrapper<Fieldx>().eq("associate_table", id));
tablexService.removeById(id); if (!fieldxList1.isEmpty()) {
return Result.OK("删除成功!"); return Result.error("该表已被关联,不能删除");
} }
tablexService.removeById(id);
return Result.OK("删除成功!");
/** }
* 批量删除
*
* @param ids /**
* @return * 批量删除
*/ *
@AutoLog(value = "实体表-批量删除") * @param ids
@ApiOperation(value = "实体表-批量删除", notes = "实体表-批量删除") * @return
@DeleteMapping(value = "/deleteBatch") */
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { @AutoLog(value = "实体表-批量删除")
this.tablexService.removeByIds(Arrays.asList(ids.split(","))); @ApiOperation(value = "实体表-批量删除", notes = "实体表-批量删除")
return Result.OK("批量删除成功!"); @DeleteMapping(value = "/deleteBatch")
} public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.tablexService.removeByIds(Arrays.asList(ids.split(",")));
/** return Result.OK("批量删除成功!");
* 通过id查询 }
*
* @param id /**
* @return * 通过id查询
*/ *
@AutoLog(value = "实体表-通过id查询") * @param id
@ApiOperation(value = "实体表-通过id查询", notes = "实体表-通过id查询") * @return
@GetMapping(value = "/queryById") */
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { @AutoLog(value = "实体表-通过id查询")
Tablex tablex = tablexService.getById(id); @ApiOperation(value = "实体表-通过id查询", notes = "实体表-通过id查询")
if (tablex == null) { @GetMapping(value = "/queryById")
return Result.error("未找到对应数据"); public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
} Tablex tablex = tablexService.getById(id);
return Result.OK(tablex); if (tablex == null) {
} return Result.error("未找到对应数据");
}
/** return Result.OK(tablex);
* 导出excel }
*
* @param request /**
* @param tablex * 导出excel
*/ *
@RequestMapping(value = "/exportXls") * @param request
public ModelAndView exportXls(HttpServletRequest request, Tablex tablex) { * @param 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 /**
* @return * 通过excel导入数据
*/ *
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) * @param file
public Result<?> importExcel(MultipartFile file) { * @return
*/
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(MultipartFile file) {
Map<String, String> message = new HashMap<>();
message.put("isVisible", "true"); LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
message.put("uploaded", "0");
message.put("status", "判断文件结构"); Map<String, String> message = new HashMap<>();
webSocketUtils.sendMessage(loginUser.getId(), message); message.put("isVisible", "true");
message.put("uploaded", "0");
try { message.put("status", "判断文件结构");
// 判断文件是否是表格 webSocketUtils.sendMessage(loginUser.getId(), message);
String originalFilename = file.getOriginalFilename();
if (StringUtils.isBlank(originalFilename) || try {
(!originalFilename.endsWith("xls") && // 判断文件是否是表格
!originalFilename.endsWith("xlsx"))) { String originalFilename = file.getOriginalFilename();
/* message.put("isVisible", "false");*/ if (StringUtils.isBlank(originalFilename) ||
webSocketUtils.sendMessage(loginUser.getId(), message); (!originalFilename.endsWith("xls") &&
return Result.error("文件格式不正确"); !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 ImportParams params = new ImportParams();
List<TablexVo> list = null; params.setTitleRows(1);//表格标题行数,默认0
message.put("status", "读取数据中"); params.setHeadRows(1);//表头行数,默认1
webSocketUtils.sendMessage(loginUser.getId(), message); params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
try { List<TablexVo> list = null;
//读取excel数据 message.put("status", "读取数据中");
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); webSocketUtils.sendMessage(loginUser.getId(), message);
} catch (Exception e) { try {
/* message.put("isVisible", "false");*/ //读取excel数据
webSocketUtils.sendMessage(loginUser.getId(), message); list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params);
return Result.error("文件读取失败"); } catch (Exception e) {
} /* message.put("isVisible", "false");*/
//判断文件中是否存在数据 webSocketUtils.sendMessage(loginUser.getId(), message);
if (list == null || list.size() == 0) { return Result.error("文件读取失败");
/* message.put("isVisible", "false");*/ }
webSocketUtils.sendMessage(loginUser.getId(), message); //判断文件中是否存在数据
return Result.error("Excel数据为空"); if (list == null || list.size() == 0) {
} /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
message.put("status", "数据预读入"); return Result.error("Excel数据为空");
webSocketUtils.sendMessage(loginUser.getId(), message); }
for (TablexVo tablexVo : list) {
//判断当前存入行是否为空值 message.put("status", "数据预读入");
if (tablexVo.getModuleId() == null && webSocketUtils.sendMessage(loginUser.getId(), message);
tablexVo.getTableName() == null && for (TablexVo tablexVo : list) {
tablexVo.getTableEnName() == null && //判断当前存入行是否为空值
tablexVo.getTableStructure() == null && if (StringUtils.isBlank(tablexVo.getModuleId()) &&
tablexVo.getStructuralDiagram() == null && StringUtils.isBlank(tablexVo.getTableName()) &&
tablexVo.getStatus() == null && StringUtils.isBlank(tablexVo.getTableEnName()) &&
tablexVo.getVerisonStatus() == null && StringUtils.isBlank(tablexVo.getTableStructure()) &&
tablexVo.getVerison() == null) continue; StringUtils.isBlank(tablexVo.getStructuralDiagram()) &&
// 将总的记录数传递给前端 StringUtils.isBlank(tablexVo.getStatus()) &&
message.put("records", String.valueOf(list.size())); StringUtils.isBlank(tablexVo.getVerisonStatus()) &&
webSocketUtils.sendMessage(loginUser.getId(), message); StringUtils.isBlank(tablexVo.getVerison())) {
list.remove(tablexVo);
//判断版本号长度 continue;
String verison = tablexVo.getVerison(); }
if (verison.length() > 5) { //判断版本号长度
/* message.put("isVisible", "false");*/ String verison = tablexVo.getVerison();
webSocketUtils.sendMessage(loginUser.getId(), message); if (verison.length() > 5) {
return Result.error("预读入失败,版本号格式错误"); /* message.put("isVisible", "false");*/
} webSocketUtils.sendMessage(loginUser.getId(), message);
//存入临时表中 return Result.error("预读入失败,版本号格式错误");
tablexVoService.save(tablexVo); }
} //存入临时表中
tablexVoService.save(tablexVo);
//从临时表中取出数据 }
List<TablexVo> voList = tablexVoService.list(); //从临时表中取出数据
//删除临时表中的数据 List<TablexVo> voList = tablexVoService.list();
tablexVoService.removeAll(voList); // 将总的记录数传递给前端
message.put("records", String.valueOf(voList.size()));
if (voList.size() == 0) { webSocketUtils.sendMessage(loginUser.getId(), message);
/* message.put("isVisible", "false");*/ //删除临时表中的数据
webSocketUtils.sendMessage(loginUser.getId(), message); tablexVoService.removeAll(voList);
return Result.error("导入失败,数据为空");
} if (voList.size() == 0) {
/* message.put("isVisible", "false");*/
message.put("status", "开始数据校验"); webSocketUtils.sendMessage(loginUser.getId(), message);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,数据为空");
for (int i = 0; i < voList.size(); i++) { }
List<Tablex> tablexList = new ArrayList<>(); message.put("status", "开始数据校验");
Tablex tablex = new Tablex(); webSocketUtils.sendMessage(loginUser.getId(), message);
for (int i = 0; i < voList.size(); i++) {
String moduleId = voList.get(i).getModuleId();
if (moduleId == null || moduleId.equals("")){ List<Tablex> tablexList = new ArrayList<>();
/* message.put("isVisible", "false");*/ Tablex tablex = new Tablex();
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写不能为空"); String moduleId = voList.get(i).getModuleId();
} if (moduleId == null || moduleId.equals("")) {
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); /* message.put("isVisible", "false");*/
queryWrapper.eq(Modulex::getId,moduleId); webSocketUtils.sendMessage(loginUser.getId(), message);
Modulex modulex = modulexService.getOne(queryWrapper); return Result.error("对应模块填写不能为空");
if(modulex == null){ }
/* message.put("isVisible", "false");*/ LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>();
webSocketUtils.sendMessage(loginUser.getId(), message); queryWrapper.eq(Modulex::getId, moduleId);
return Result.error("对应模块填写错误"); Modulex modulex = modulexService.getOne(queryWrapper);
} if (modulex == null) {
String modulexId = modulex.getId(); /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
String status = voList.get(i).getStatus(); return Result.error("对应模块填写错误");
String verisonStatus = voList.get(i).getVerisonStatus(); }
String modulexId = modulex.getId();
//判断实体状态
//int statusInt = status.equals("正常") ? 1 : status.equals("停用") ? 0 : status.equals("废弃") ? 9 : 3; String status = voList.get(i).getStatus();
//判断版本状态 String verisonStatus = voList.get(i).getVerisonStatus();
//int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3;
//判断实体状态
//判断对应模块 //int statusInt = status.equals("正常") ? 1 : status.equals("停用") ? 0 : status.equals("废弃") ? 9 : 3;
if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) { //判断版本状态
//判断中文名称 //int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3;
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 (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) {
//判断实体状态 //判断中文名称
if (status.equals("1") || status.equals("0") || status.equals("9")) { if (voList.get(i).getTableName() != null && !voList.get(i).getTableName().equals("") && !voList.get(i).getTableName().equals(modulex.getModuleName())) {
//判断版本状态 //判断英文名称
if (verisonStatus.equals("1") || verisonStatus.equals("0")) { if (voList.get(i).getTableEnName() != null && !voList.get(i).getTableEnName().equals("") && !voList.get(i).getTableEnName().equals(modulex.getModuleEnName())) {
//判断版本号 //判断实体状态
if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) { if (status.equals("1") || status.equals("0") || status.equals("9")) {
tablex.setModuleId(voList.get(i).getModuleId()); //判断版本状态
tablex.setTableName(voList.get(i).getTableName()); if (verisonStatus.equals("1") || verisonStatus.equals("0")) {
tablex.setTableEnName(voList.get(i).getTableEnName()); //判断版本号
tablex.setTableStructure(voList.get(i).getTableStructure()); if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) {
tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); tablex.setModuleId(voList.get(i).getModuleId());
tablex.setCreateBy(loginUser.getRealname()); tablex.setTableName(voList.get(i).getTableName());
tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); tablex.setTableEnName(voList.get(i).getTableEnName());
tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); tablex.setTableStructure(voList.get(i).getTableStructure());
tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram());
tablex.setCreateBy(loginUser.getRealname());
tablexList.add(tablex); tablex.setStatus(Integer.valueOf(voList.get(i).getStatus()));
tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus()));
//单条保存到真实表中 tablex.setVerison(Integer.valueOf(voList.get(i).getVerison()));
tablexService.saveSingleBatch(tablexList,loginUser,message);
tablexList.add(tablex);
} else {
/* message.put("isVisible", "false");*/ //单条保存到真实表中
webSocketUtils.sendMessage(loginUser.getId(), message); tablexService.saveSingleBatch(tablexList, loginUser, message);
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!");
} } else {
} else { /* message.put("isVisible", "false");*/
/* message.put("isVisible", "false");*/ webSocketUtils.sendMessage(loginUser.getId(), message);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!");
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); }
} } else {
} else { /* message.put("isVisible", "false");*/
/* message.put("isVisible", "false");*/ webSocketUtils.sendMessage(loginUser.getId(), message);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!");
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); }
} } else {
} else { /* message.put("isVisible", "false");*/
/* message.put("isVisible", "false");*/ webSocketUtils.sendMessage(loginUser.getId(), message);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!");
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); }
} } else {
} else { /* message.put("isVisible", "false");*/
/* message.put("isVisible", "false");*/ webSocketUtils.sendMessage(loginUser.getId(), message);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!");
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); }
} } else {
} else { /* message.put("isVisible", "false");*/
/*message.put("isVisible", "false");*/ webSocketUtils.sendMessage(loginUser.getId(), message);
webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!");
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); }
} } else {
} /*message.put("isVisible", "false");*/
} catch (Exception e) { webSocketUtils.sendMessage(loginUser.getId(), message);
/* message.put("isVisible", "false");*/ return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!");
webSocketUtils.sendMessage(loginUser.getId(), message); }
return Result.error("文件导入失败"); }
} } catch (Exception e) {
/*message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.ok("文件导入成功!"); return Result.error("文件导入失败");
} }
/*message.put("isVisible", "false");*/
/* //导出实体标准模板 webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.ok("文件导入成功!");
}
//导出实体标准模板
@RequestMapping(value = "/templateExcel") @RequestMapping(value = "/templateExcel")
public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -486,5 +491,5 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
log.error("下载模板异常--》{}", e); log.error("下载模板异常--》{}", e);
} }
return null; return null;
}*/ }
} }

Loading…
Cancel
Save