更新导入实体新页面

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

@ -124,9 +124,11 @@
<!-- <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>
<!-- <a-button type="primary" icon="import" @click="showModalImport()">导入实体</a-button>-->
<!-- <a-modal
title="正在上传..." title="正在上传..."
:visible="ModalData.isVisible==='true'" :visible="ModalData.isVisible==='true'"
:confirm-loading="false" :confirm-loading="false"
@ -143,7 +145,7 @@
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))" :percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:" title="上传进度:"
status="active" :steps="ModalData.records"/> status="active" :steps="ModalData.records"/>
</a-modal> </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,20 +24,15 @@
</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'"> </a-upload>
</a-form-item>
<a-form-item v-if="ModalData.isVisible==='true'" class="box">
<p>当前状态{{ ModalData.status }}</p> <p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p> <p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p> <p>已上传{{ ModalData.uploaded }}</p>
@ -46,28 +41,9 @@
title="上传进度:" title="上传进度:"
status="active" status="active"
:steps="ModalData.records"/> :steps="ModalData.records"/>
</div>
</a-upload>
</a-form-item> </a-form-item>
<!-- <a-modal--> <!-- <a-form-model-item label="注意事项" v-if="uploadFinished">-->
<!-- title="正在上传..."--> <a-form-model-item label="注意事项">
<!-- :visible="ModalData.isVisible==='true'"-->
<!-- :confirm-loading="false"-->
<!-- :mask="true"-->
<!-- :maskClosable="false"-->
<!-- :keyboard="false"-->
<!-- :closable="false"-->
<!-- :footer="false"-->
<!-- >-->
<!-- <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"/>-->
<!-- </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,13 +61,13 @@ 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
@ -91,6 +92,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@Autowired @Autowired
private WebSocketUtils webSocketUtils; private WebSocketUtils webSocketUtils;
@Value("${jeecg.wordPath}")
private String wordPath;
/** /**
* 分页列表查询 * 分页列表查询
* *
@ -151,7 +155,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
@AutoLog(value = "转化") @AutoLog(value = "转化")
@ApiOperation(value = "转化", notes = "转化") @ApiOperation(value = "转化", notes = "转化")
@PostMapping(value = "/zh") @PostMapping(value = "/zh")
public Result<?> zh(@RequestBody Tablex tablex,HttpServletRequest req) { public Result<?> zh(@RequestBody Tablex tablex, HttpServletRequest req) {
String reid = tablex.getId(); String reid = tablex.getId();
tablex.setId(null); tablex.setId(null);
List<Tablex> tablexList = tablexService.list(); List<Tablex> tablexList = tablexService.list();
@ -166,11 +170,11 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablex.setVerison(1); tablex.setVerison(1);
tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();"); tablex.setTableStructure("CREATE TABLE '" + tablex.getTableEnName() + "' ();");
QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap()); QueryWrapper<Tablex> queryWrapper = QueryGenerator.initQueryWrapper(tablex, req.getParameterMap());
queryWrapper.eq("table_name",tablex.getTableName()).or().eq("table_en_name",tablex.getTableEnName()); queryWrapper.eq("table_name", tablex.getTableName()).or().eq("table_en_name", tablex.getTableEnName());
List<Tablex> tlist = tablexService.list(queryWrapper); List<Tablex> tlist = tablexService.list(queryWrapper);
if(tlist.size()>0){ if (tlist.size() > 0) {
return Result.error("中文或者英文名称重复,不可转化"); return Result.error("中文或者英文名称重复,不可转化");
}else { } else {
tablexService.save(tablex); tablexService.save(tablex);
modulexService.setmodule(tablex.getId(), tablex.getModuleId()); modulexService.setmodule(tablex.getId(), tablex.getModuleId());
requirementEntity.setEntityStatus(3); requirementEntity.setEntityStatus(3);
@ -296,7 +300,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
if (StringUtils.isBlank(originalFilename) || if (StringUtils.isBlank(originalFilename) ||
(!originalFilename.endsWith("xls") && (!originalFilename.endsWith("xls") &&
!originalFilename.endsWith("xlsx"))) { !originalFilename.endsWith("xlsx"))) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件格式不正确"); return Result.error("文件格式不正确");
} }
@ -313,13 +317,13 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//读取excel数据 //读取excel数据
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params);
} catch (Exception e) { } catch (Exception e) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件读取失败"); return Result.error("文件读取失败");
} }
//判断文件中是否存在数据 //判断文件中是否存在数据
if (list == null || list.size() == 0) { if (list == null || list.size() == 0) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("Excel数据为空"); return Result.error("Excel数据为空");
} }
@ -328,36 +332,37 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
for (TablexVo tablexVo : list) { for (TablexVo tablexVo : list) {
//判断当前存入行是否为空值 //判断当前存入行是否为空值
if (tablexVo.getModuleId() == null && if (StringUtils.isBlank(tablexVo.getModuleId()) &&
tablexVo.getTableName() == null && StringUtils.isBlank(tablexVo.getTableName()) &&
tablexVo.getTableEnName() == null && StringUtils.isBlank(tablexVo.getTableEnName()) &&
tablexVo.getTableStructure() == null && StringUtils.isBlank(tablexVo.getTableStructure()) &&
tablexVo.getStructuralDiagram() == null && StringUtils.isBlank(tablexVo.getStructuralDiagram()) &&
tablexVo.getStatus() == null && StringUtils.isBlank(tablexVo.getStatus()) &&
tablexVo.getVerisonStatus() == null && StringUtils.isBlank(tablexVo.getVerisonStatus()) &&
tablexVo.getVerison() == null) continue; StringUtils.isBlank(tablexVo.getVerison())) {
// 将总的记录数传递给前端 list.remove(tablexVo);
message.put("records", String.valueOf(list.size())); continue;
webSocketUtils.sendMessage(loginUser.getId(), message); }
//判断版本号长度 //判断版本号长度
String verison = tablexVo.getVerison(); String verison = tablexVo.getVerison();
if (verison.length() > 5) { if (verison.length() > 5) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读入失败,版本号格式错误"); return Result.error("预读入失败,版本号格式错误");
} }
//存入临时表中 //存入临时表中
tablexVoService.save(tablexVo); tablexVoService.save(tablexVo);
} }
//从临时表中取出数据 //从临时表中取出数据
List<TablexVo> voList = tablexVoService.list(); List<TablexVo> voList = tablexVoService.list();
// 将总的记录数传递给前端
message.put("records", String.valueOf(voList.size()));
webSocketUtils.sendMessage(loginUser.getId(), message);
//删除临时表中的数据 //删除临时表中的数据
tablexVoService.removeAll(voList); tablexVoService.removeAll(voList);
if (voList.size() == 0) { if (voList.size() == 0) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,数据为空"); return Result.error("导入失败,数据为空");
} }
@ -370,16 +375,16 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
Tablex tablex = new Tablex(); Tablex tablex = new Tablex();
String moduleId = voList.get(i).getModuleId(); String moduleId = voList.get(i).getModuleId();
if (moduleId == null || moduleId.equals("")){ if (moduleId == null || moduleId.equals("")) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写不能为空"); return Result.error("对应模块填写不能为空");
} }
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Modulex::getId,moduleId); queryWrapper.eq(Modulex::getId, moduleId);
Modulex modulex = modulexService.getOne(queryWrapper); Modulex modulex = modulexService.getOne(queryWrapper);
if(modulex == null){ if (modulex == null) {
/* message.put("isVisible", "false");*/ /* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写错误"); return Result.error("对应模块填写错误");
} }
@ -418,15 +423,15 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexList.add(tablex); tablexList.add(tablex);
//单条保存到真实表中 //单条保存到真实表中
tablexService.saveSingleBatch(tablexList,loginUser,message); tablexService.saveSingleBatch(tablexList, loginUser, message);
} 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 + "行的版本状态填写错误!");
} }
@ -461,7 +466,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
return Result.ok("文件导入成功!"); 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