Compare commits

..

4 Commits

  1. 6
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 40
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
  3. 64
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java
  4. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/impl/TablexServiceImpl.java

@ -508,14 +508,15 @@ export default {
return { return {
note: ['对应模块id(必填):填写正确的模块名称', note: ['对应模块id(必填):填写正确的模块名称',
'中文名称(必填):与模块名称相同。', '中文名称(必填):与模块名称相同。',
'英文名称(必填):与模块名称相同,写模块名称的英文名称。', '英文名称(必填):与模块名称相同,写模块名称的英文名称。',
'实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。',
'版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态', '版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态',
'版本号:请填写小与五位数的正整数' '版本号:请填写小与五位数的正整数'
], ],
title: '导入实体', title: '导入实体',
uploadUrl: this.tablexImportExcelUrl, uploadUrl: this.tablexImportExcelUrl,
downUrl: this.tablexDownExcelUrl downUrl: "temp/tablex.xls",
downName: "实体模板表.xls"
} }
}, },
modelData: function () { modelData: function () {
@ -604,6 +605,7 @@ export default {
let flag = false let flag = false
this.ws.onmessage = (e) => { this.ws.onmessage = (e) => {
let res = JSON.parse(e.data); let res = JSON.parse(e.data);
console.log('1111111111111',res)
this.$refs.moduleximport.edit(res); this.$refs.moduleximport.edit(res);
if (res.isError === 'true') { if (res.isError === 'true') {
this.$message.error(res.status) this.$message.error(res.status)

@ -6,6 +6,7 @@
:closable="closable" :closable="closable"
@cancel="handleCancel" @cancel="handleCancel"
:maskClosable="maskClosable" :maskClosable="maskClosable"
> >
<a-alert message="请下载" type="info" show-icon style="margin-bottom: 20px;"/> <a-alert message="请下载" type="info" show-icon style="margin-bottom: 20px;"/>
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }"> <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
@ -16,7 +17,7 @@
</div> </div>
<div class="standBu"> <div class="standBu">
<a-alert <a-alert
message="必须下载标准表格,否则审核不通过" message="必须下载标准表格,否则审核可能不通过"
type="error" type="error"
closable closable
@close="onClose" @close="onClose"
@ -53,13 +54,13 @@
</a-form-model-item> </a-form-model-item>
</a-form> </a-form>
<template slot="footer"> <template slot="footer">
<a-button type="primary" @click="handleCancel" :disabled="closeable == 'true' ? false : true">确定</a-button> <a-button type="primary" @click="handleCancel" :disabled="ModalData.closeable == 'true' ? false : true">关闭</a-button>
</template> </template>
</a-modal> </a-modal>
</template> </template>
<script> <script>
import {getAction} from "@api/manage" import {downloadFile, 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'
@ -76,17 +77,15 @@ export default {
visible: false, visible: false,
model: {}, model: {},
// //
closeable: 'true',
uploadFinished: false, uploadFinished: false,
ModalData: { ModalData: {
uploaded: '0', uploaded: '0',
isVisible: 'false', isVisible: 'false',
records: '0', records: '0',
status: '判断文件结构', status: '判断文件结构',
// closeable: 'false'
}, },
btnState: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
downName:'',
url: url:
{ {
downfile: '', downfile: '',
@ -127,18 +126,20 @@ export default {
}, },
// //
handleDownload() { handleDownload() {
console.log(this.downName,"111")
downloadFile( this.url.downfile,this.downName)
// getAction(this.url.list, params).then((res) => // 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() {
@ -146,14 +147,18 @@ export default {
show(data,ws) { show(data,ws) {
this.url.uploadUrl = data.uploadUrl this.url.uploadUrl = data.uploadUrl
this.url.downfile = data.downUrl this.url.downfile = data.downUrl
this.downName = data.downName
this.datas = data.note this.datas = data.note
this.title = data.title this.title = data.title
this.ModalData = {} this.ModalData = {}
this.ModalData.closeable = "true"
this.visible = true this.visible = true
this.ws=ws this.ws=ws
}, },
edit(record) { edit(record) {
this.ModalData = record this.ModalData = record
// this.closeable = this.ModalData.closeable === "true"
}, },
edit1(record) { edit1(record) {
this.visible = true this.visible = true
@ -165,6 +170,7 @@ export default {
this.ws.close() this.ws.close()
}, },
handleCancel() { handleCancel() {
console.log(this.ModalData,'11111')
this.close() this.close()
this.ws.close() this.ws.close()
}, },

@ -311,8 +311,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//获取上传文件对象 //获取上传文件对象
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
params.setTitleRows(1);//表格标题数,默认0 params.setTitleRows(1);//表格标题数,默认0
params.setHeadRows(1);//表头数,默认1 params.setHeadRows(1);//表头数,默认1
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
List<TablexVo> list = null; List<TablexVo> list = null;
try { try {
@ -336,8 +336,10 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
message.put("status", "数据预读入"); message.put("status", "数据预读入");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
Iterator<TablexVo> iterator = list.iterator();
// for (TablexVo tablexVo : list) {
for (TablexVo tablexVo : list) { for (TablexVo tablexVo : list) {
//判断当前存入行是否为空值 //判断当前存入是否为空值
if (StringUtils.isBlank(tablexVo.getModuleId()) && if (StringUtils.isBlank(tablexVo.getModuleId()) &&
StringUtils.isBlank(tablexVo.getTableName()) && StringUtils.isBlank(tablexVo.getTableName()) &&
StringUtils.isBlank(tablexVo.getTableEnName()) && StringUtils.isBlank(tablexVo.getTableEnName()) &&
@ -346,7 +348,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
StringUtils.isBlank(tablexVo.getStatus()) && StringUtils.isBlank(tablexVo.getStatus()) &&
StringUtils.isBlank(tablexVo.getVerisonStatus()) && StringUtils.isBlank(tablexVo.getVerisonStatus()) &&
StringUtils.isBlank(tablexVo.getVerison())) { StringUtils.isBlank(tablexVo.getVerison())) {
list.remove(tablexVo); // list.remove(tablexVo);
// break;
continue; continue;
} }
//判断版本号长度 //判断版本号长度
@ -379,9 +382,11 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
message.put("status", "开始数据校验"); message.put("status", "开始数据校验");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
List<Tablex> tablexList = new ArrayList<>();
for (int i = 0; i < voList.size(); i++) { for (int i = 0; i < voList.size(); i++) {
List<Tablex> tablexList = new ArrayList<>();
Tablex tablex = new Tablex(); Tablex tablex = new Tablex();
String moduleId = voList.get(i).getModuleId(); String moduleId = voList.get(i).getModuleId();
@ -415,9 +420,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//判断对应模块 //判断对应模块
if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) { 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).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 (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 (status.equals("1") || status.equals("0") || status.equals("9")) {
//判断版本状态 //判断版本状态
@ -440,64 +445,65 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexList.add(tablex); tablexList.add(tablex);
message.put("status", "正在上传");
webSocketUtils.sendMessage(loginUser.getId(), message);
//单条保存到真实表中
tablexService.saveSingleBatch(tablexList, loginUser, message);
message.put("status", "上传成功");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
} else { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的版本号填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的版本号填写错误!");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); return Result.error("导入失败,第" + (i + 1) + "条的版本号填写错误!");
} }
} else { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的版本状态填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!");
} }
} else { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的实体状态填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的实体状态填写错误!");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); return Result.error("导入失败,第" + (i + 1) + "条的实体状态填写错误!");
} }
} else { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的英文名称填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的英文名称填写错误!");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); return Result.error("导入失败,第" + (i + 1) + "条的英文名称填写错误!");
} }
} else { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的中文名称填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的中文名称填写错误!");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); return Result.error("导入失败,第" + (i + 1) + "条的中文名称填写错误!");
} }
} else { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的对应模块填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的对应模块填写错误!");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); return Result.error("导入失败,第" + (i + 1) + "条的对应模块填写错误!");
} }
} }
message.put("status", "正在上传");
webSocketUtils.sendMessage(loginUser.getId(), message);
//保存到真实表中
tablexService.saveSingleBatch(tablexList, loginUser, message);
message.put("status", "上传成功");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
} catch (Exception e) { } catch (Exception e) {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","文件导入失败"); message.put("status","文件导入失败");
message.put("closeable","true"); message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
log.error(e.getMessage(),e);
return Result.error("文件导入失败"); return Result.error("文件导入失败");
} }
return Result.ok("文件导入成功!"); return Result.ok("文件导入成功!");

@ -43,7 +43,7 @@ public class TablexServiceImpl extends ServiceImpl<TablexMapper, Tablex> impleme
public void saveSingleBatch(List<Tablex> tablexList, LoginUser loginUser, Map<String, String> message) { public void saveSingleBatch(List<Tablex> tablexList, LoginUser loginUser, Map<String, String> message) {
for (int i = 0; i < tablexList.size(); i++){ for (int i = 0; i < tablexList.size(); i++){
try { try {
Thread.sleep(1000L); Thread.sleep(3000L);
message.put("uploaded", String.valueOf(i + 1)); message.put("uploaded", String.valueOf(i + 1));
this.save(tablexList.get(i)); this.save(tablexList.get(i));
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);

Loading…
Cancel
Save