导入实体功能修改

dev^2
mqh 1 year ago
parent f84d5ef57e
commit 837b544f2d
  1. 37
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 79
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
  3. 62
      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

@ -72,7 +72,8 @@
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!-- <a-button type="primary" @click="showModal1()"></a-button> -->
<a-button type="primary" icon="import" @click="showModalImport()">导入模块</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<a-modal
title="正在上传..."
:visible="ModalData.isVisible==='true'"
@ -93,10 +94,12 @@
</a-modal>
<a-button type="primary" icon="import" @click="showProcess">导入模块</a-button>
</a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="functionImportExcelUrl" @change="handleImportExcel">
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
:action="functionImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入功能</a-button>
</a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="ruleImportExcelUrl" @change="handleImportExcel">
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
:action="ruleImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import" @click="showProcess">导入规则</a-button>
<a-modal
@ -119,9 +122,10 @@
</a-modal>
</a-upload>
<a-upload name="file" :showUploadList="false" :multiple="false"
:headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import" @click="showProcess">导入实体</a-button>
<!-- <a-upload name="file" :showUploadList="false" :multiple="false"
:headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel">-->
<a-button type="primary" icon="import" @click="showProcess()">导入实体</a-button>
<!-- <a-button type="primary" icon="import" @click="showModalImport()">导入实体</a-button>-->
<a-modal
title="正在上传..."
:visible="ModalData.isVisible==='true'"
@ -140,12 +144,13 @@
title="上传进度:"
status="active" :steps="ModalData.records"/>
</a-modal>
</a-upload>
<!-- </a-upload>-->
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
<a-button type="primary" icon="download" @click="exportxsxl('模块,功能,规则表')">导出综合表</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrlf" @change="handleImportExcel">
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrlf"
@change="handleImportExcel">
<a-button type="primary" icon="import">导入字段</a-button>
</a-upload>
</div>
@ -262,6 +267,7 @@ import { filterObj } from "@/utils/util"
import FieldxList from "@views/fieldx/FieldxList.vue"
import TablexList from "@views/tablex/TablexList.vue"
import axios from 'axios';
export default {
name: 'ModulexList',
mixins: [JeecgListMixin, mixinDevice],
@ -522,7 +528,7 @@ export default {
methods: {
showModalImport() {
this.$refs.moduleximport.edit();
this.$refs.moduleximport.edit(this.ModalData);
// this.$refs.moduleximport.title = "111111";
this.$refs.moduleximport.disableSubmit = false;
},
@ -532,12 +538,15 @@ export default {
let base_url = window._CONFIG['domianURL']
base_url = base_url.replace('http', 'ws')
let ws = new WebSocket(`${base_url}/uploadProcess/${userId}`)
this.$refs.moduleximport.show(this.tablexImportExcelUrl,'');
ws.onmessage = (e) => {
this.ModalData=JSON.parse(e.data)
if (this.visible===false) {
// this.getList()
console.log("重新获取列表")
}
// this.ModalData = 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("")
// }
}
},
//

@ -11,22 +11,33 @@
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
<!-- <a-alert message="请下载" type="info" show-icon /> -->
<a-form-item label="下载标准表格">
<div class="standB"><a-button type="primary" icon="download" @click="handleDownload"/></div>
<div class="standBu"> <a-alert
<div class="standB">
<a-button type="primary" icon="download" @click="handleDownload"/>
</div>
<div class="standBu">
<a-alert
message="必须下载标准表格,否则审核不通过"
type="error"
closable
@close="onClose"
/></div>
/>
</div>
</a-form-item>
<a-form-item label="上传标准表格">
<!-- @click="showProcess" -->
<a-upload
<!-- <a-upload
:multiple="false"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
@change="handleChange">
:action="url.uploadUrl"
@change="handleChange"
>-->
<a-upload name="file"
:multiple="false"
:action="url.uploadUrl"
@change="handleChange"
:showUploadList="false"
:headers="tokenHeader">
<a-button type="primary" icon="upload"></a-button>
<!-- <div>
<div v-if="ModalData.isVisible==='true'">
<p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p>
@ -35,12 +46,33 @@
title="上传进度:"
status="active"
:steps="ModalData.records"/>
</div> -->
</div>
</a-upload>
</a-form-item>
<!-- <a-modal-->
<!-- title="正在上传..."-->
<!-- :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-item slot="renderItem" slot-scope="item,index" style="border-bottom:0px ;"> {{ index+1 }} . {{ item }}</a-list-item>
<a-list-item slot="renderItem" slot-scope="item,index" style="border-bottom:0px ;"> {{ index + 1 }} . {{
item
}}
</a-list-item>
</a-list>
</a-form-model-item>
</a-form>
@ -50,14 +82,16 @@
<script>
import getAction from '@api/manage'
import store from '@/store'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {mixinDevice} from '@/utils/mixin'
export default {
name: 'ModelTest',
comments: {
},
mixins: [JeecgListMixin, mixinDevice],
comments: {},
data() {
return {
title: '导入xxxxxx',
title: '',
visible: false,
model: {},
//
@ -72,7 +106,8 @@ export default {
form: this.$form.createForm(this),
url:
{
downfile: ''
downfile: '',
uploadUrl: ''
},
datas: [
'Racing car sprays burning fuel into crowd.',
@ -85,12 +120,11 @@ export default {
},
created() {
},
computed: {
},
computed: {},
methods: {
//
//
showProcess() {
/* showProcess() {
let userId = store.getters.userInfo.id
let baseUrl = window._CONFIG['domianURL']
baseUrl = baseUrl.replace('http', 'ws')
@ -98,7 +132,7 @@ export default {
ws.onmessage = (e) => {
this.ModalData = JSON.parse(e.data)
}
},
},*/
//
handleChange(info) {
if (info.file.status !== 'uploading') {
@ -133,9 +167,15 @@ export default {
add() {
},
edit(record) {
show(uploadUrl, downUrl) {
this.url.uploadUrl = uploadUrl
this.url.downfile = downUrl
this.visible = true
},
edit(record) {
// this.visible = true
this.ModalData = record
},
close() {
this.$emit('close')
@ -161,6 +201,7 @@ export default {
width: 15%;
float: left;
}
.standBu {
width: 85%;
float: right;

@ -1,5 +1,7 @@
package org.jeecg.modules.tablex.controller;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
@ -40,10 +42,13 @@ import org.jeecg.modules.tablex.vo.TablexVo;
import org.jeecg.modules.tablex.ws.WebSocketUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
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.ImportParams;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -291,7 +296,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
if (StringUtils.isBlank(originalFilename) ||
(!originalFilename.endsWith("xls") &&
!originalFilename.endsWith("xlsx"))) {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件格式不正确");
}
@ -308,13 +313,13 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//读取excel数据
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params);
} catch (Exception e) {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件读取失败");
}
//判断文件中是否存在数据
if (list == null || list.size() == 0) {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("Excel数据为空");
}
@ -338,7 +343,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//判断版本号长度
String verison = tablexVo.getVerison();
if (verison.length() > 5) {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读入失败,版本号格式错误");
}
@ -352,7 +357,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexVoService.removeAll(voList);
if (voList.size() == 0) {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,数据为空");
}
@ -366,7 +371,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
String moduleId = voList.get(i).getModuleId();
if (moduleId == null || moduleId.equals("")){
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写不能为空");
}
@ -374,7 +379,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
queryWrapper.eq(Modulex::getId,moduleId);
Modulex modulex = modulexService.getOne(queryWrapper);
if(modulex == null){
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写错误");
}
@ -416,43 +421,70 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexService.saveSingleBatch(tablexList,loginUser,message);
} else {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!");
}
} else {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!");
}
} else {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!");
}
} else {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!");
}
} else {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!");
}
} else {
message.put("isVisible", "false");
/*message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!");
}
}
} catch (Exception e) {
message.put("isVisible", "false");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败");
}
message.put("isVisible", "false");
/*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 {
String url = getClass().getClassLoader().getResource("static").getPath();
// 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
String templateUrl = wordPath + File.separator + "实体表模板.xls";
TemplateExportParams params = new TemplateExportParams(
templateUrl);
ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView());
mv.addObject(TemplateExcelConstants.FILE_NAME, fileName);
mv.addObject(TemplateExcelConstants.PARAMS, params);
// 添加模板参数
mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data
return mv;
} catch (Exception e) {
log.error("下载模板异常--》{}", e);
}
return null;
}*/
}

@ -48,7 +48,7 @@ public class TablexServiceImpl extends ServiceImpl<TablexMapper, Tablex> impleme
this.save(tablexList.get(i));
webSocketUtils.sendMessage(loginUser.getId(), message);
} catch (InterruptedException e) {
message.put("isVisible", "false");
/*message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
log.error(e.getMessage(), e);
}

Loading…
Cancel
Save