Compare commits

...

3 Commits

  1. 258
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 150
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
  3. 813
      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

@ -52,7 +52,7 @@
<a-col :xl="6" :lg="7" :md="8" :sm="24"> <a-col :xl="6" :lg="7" :md="8" :sm="24">
<a-form-item label="责任人"> <a-form-item label="责任人">
<j-select-user-by-dep placeholder="请选择责任人" v-model="queryParam.managerUsers" /> <j-select-user-by-dep placeholder="请选择责任人" v-model="queryParam.managerUsers"/>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -72,7 +72,8 @@
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!-- <a-button type="primary" @click="showModal1()"></a-button> --> <!-- <a-button type="primary" @click="showModal1()"></a-button> -->
<a-button type="primary" icon="import" @click="showModalImport()">导入模块</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 <a-modal
title="正在上传..." title="正在上传..."
:visible="ModalData.isVisible==='true'" :visible="ModalData.isVisible==='true'"
@ -93,35 +94,14 @@
</a-modal> </a-modal>
<a-button type="primary" icon="import" @click="showProcess">导入模块</a-button> <a-button type="primary" icon="import" @click="showProcess">导入模块</a-button>
</a-upload> </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-button type="primary" icon="import">导入功能</a-button>
</a-upload> </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-button type="primary" icon="import" @click="showProcess">导入规则</a-button>
<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-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-modal <a-modal
title="正在上传..." title="正在上传..."
:visible="ModalData.isVisible==='true'" :visible="ModalData.isVisible==='true'"
@ -142,10 +122,37 @@
</a-modal> </a-modal>
</a-upload> </a-upload>
<!-- <a-upload name="file" :showUploadList="false" :multiple="false"
:headers="tokenHeader" :action="tablexImportExcelUrl" @change="handleImportExcel">-->
<a-button type="primary" icon="import"
@click="showProcess( 1)">导入实体
</a-button>
<!-- <a-button type="primary" icon="import" @click="showModalImport()">导入实体</a-button>-->
<!-- <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-upload>-->
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button> <a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
<a-button type="primary" icon="download" @click="exportxsxl('模块,功能,规则表')">导出综合表</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-button type="primary" icon="import">导入字段</a-button>
</a-upload> </a-upload>
</div> </div>
@ -176,27 +183,27 @@
<!-- 管理 公用部分--> <!-- 管理 公用部分-->
<span slot="htmlSlot" slot-scope="text, record"> <span slot="htmlSlot" slot-scope="text, record">
<a @click="functionManage(record)">功能</a> <a @click="functionManage(record)">功能</a>
<a-divider type="vertical" /> <a-divider type="vertical"/>
<a @click="tablexManage(record)">实体</a> <a @click="tablexManage(record)">实体</a>
<!-- <a-divider type="vertical" /> --> <!-- <a-divider type="vertical" /> -->
<br /> <br/>
<a @click="viewVid(record)">字段</a> <a @click="viewVid(record)">字段</a>
</span> </span>
<!--功能 管理员--> <!--功能 管理员-->
<span slot="actionManage" slot-scope="text, record" v-if="userRole1 === '1'"> <span slot="actionManage" slot-scope="text, record" v-if="userRole1 === '1'">
<a @click="fabu(record)">发布</a> <a @click="fabu(record)">发布</a>
<a-divider type="vertical" /> <a-divider type="vertical"/>
<a @click="tijiao(record)">提交</a> <a @click="tijiao(record)">提交</a>
<a-divider type="vertical" /> <a-divider type="vertical"/>
<a @click="kaishi(record)">开始</a> <a @click="kaishi(record)">开始</a>
<br /> <br/>
<a @click="chehui(record)">撤回</a> <a @click="chehui(record)">撤回</a>
<a-divider type="vertical" /> <a-divider type="vertical"/>
<a @click="bugfankui(record)">BUG反馈</a> <a @click="bugfankui(record)">BUG反馈</a>
<br /> <br/>
<!-- <a @click="shenhe(record)">审核</a>--> <!-- <a @click="shenhe(record)">审核</a>-->
<!-- <a-divider type="vertical"/>--> <!-- <a-divider type="vertical"/>-->
</span> </span>
@ -218,13 +225,13 @@
<!--操作 --> <!--操作 -->
<span slot="action1" slot-scope="text, record"> <span slot="action1" slot-scope="text, record">
<a @click="fuzhiProject(record)">复制</a> <a @click="fuzhiProject(record)">复制</a>
<a-divider type="vertical" /> <a-divider type="vertical"/>
<a @click="handleEdit(record)">编辑</a> <a @click="handleEdit(record)">编辑</a>
<!-- <a-divider type="vertical" /> --> <!-- <a-divider type="vertical" /> -->
<br /> <br/>
<a @click="handleDetail(record)">详情</a> <a @click="handleDetail(record)">详情</a>
<a-divider type="vertical" /> <a-divider type="vertical"/>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)"> <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a> <a>删除</a>
@ -233,7 +240,7 @@
<span slot="filterDropdown"> <span slot="filterDropdown">
<a-card> <a-card>
<!-- /* 多选框 options:指定可选项 defaultValue:默认选中的选项 change:变化时回调 */ --> <!-- /* 多选框 options:指定可选项 defaultValue:默认选中的选项 change:变化时回调 */ -->
<a-checkbox-group :options="checkColumn" :defaultValue="checkColumn" @change="checkChange" /> <a-checkbox-group :options="checkColumn" :defaultValue="checkColumn" @change="checkChange"/>
</a-card> </a-card>
</span> </span>
</a-table> </a-table>
@ -251,17 +258,18 @@
<script> <script>
import '@assets/less/TableExpand.less' import '@assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin' import {mixinDevice} from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import ModulexModal from './modules/ModulexModal' import ModulexModal from './modules/ModulexModal'
import ModulexImport from './modules/ModulexImport.vue' import ModulexImport from './modules/ModulexImport.vue'
import { getAction } from "@api/manage" import {getAction} from "@api/manage"
import BugxModal from "@views/modulex/modules/BugxModal" import BugxModal from "@views/modulex/modules/BugxModal"
import store from "@/store" import store from "@/store"
import { filterObj } from "@/utils/util" import {filterObj} from "@/utils/util"
import FieldxList from "@views/fieldx/FieldxList.vue" import FieldxList from "@views/fieldx/FieldxList.vue"
import TablexList from "@views/tablex/TablexList.vue" import TablexList from "@views/tablex/TablexList.vue"
import axios from 'axios'; import axios from 'axios';
export default { export default {
name: 'ModulexList', name: 'ModulexList',
mixins: [JeecgListMixin, mixinDevice], mixins: [JeecgListMixin, mixinDevice],
@ -272,15 +280,15 @@ export default {
ModulexModal, ModulexModal,
ModulexImport ModulexImport
}, },
data () { data() {
return { return {
ModalData:{ ModalData: {
uploaded: '0', uploaded: '0',
isVisible: 'false', isVisible: 'false',
records: '0', records: '0',
status: '判断文件结构' status: '判断文件结构'
}, },
visible:false, visible: false,
moduleximport: false, moduleximport: false,
description: '模块管理管理页面', description: '模块管理管理页面',
// //
@ -435,7 +443,7 @@ export default {
align: "center", align: "center",
fixed: "right", fixed: "right",
width: 98, width: 98,
scopedSlots: { customRender: 'htmlSlot' }, scopedSlots: {customRender: 'htmlSlot'},
// customCell: () => { // customCell: () => {
// return { // return {
// style: { // style: {
@ -450,7 +458,7 @@ export default {
align: "center", align: "center",
fixed: "right", fixed: "right",
width: 140, width: 140,
scopedSlots: { customRender: 'actionManage' }, scopedSlots: {customRender: 'actionManage'},
customCell: () => { customCell: () => {
return { return {
style: { style: {
@ -466,7 +474,7 @@ export default {
align: "center", align: "center",
fixed: "right", fixed: "right",
width: 100, width: 100,
scopedSlots: { customRender: 'action1', filterDropdown: 'filterDropdown' } scopedSlots: {customRender: 'action1', filterDropdown: 'filterDropdown'}
} }
], ],
url: { url: {
@ -478,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"
}, },
@ -488,7 +497,7 @@ export default {
loadRouteType: false, loadRouteType: false,
} }
}, },
created () { created() {
// columnsfilterColumns // columnsfilterColumns
this.filterColumn = this.columns this.filterColumn = this.columns
let usercode = store.getters.userInfo.id let usercode = store.getters.userInfo.id
@ -496,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 () {
@ -509,39 +518,58 @@ export default {
checkColumn: function () { checkColumn: function () {
return this.columns.map(item => item.title) return this.columns.map(item => item.title)
}, },
functionImportExcelUrl: function(){ functionImportExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.functionImportExcelUrl}`; return `${window._CONFIG['domianURL']}/${this.url.functionImportExcelUrl}`;
}, },
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.$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}`)
ws.onmessage = (e) =>{ this.$refs.moduleximport.show(data);
this.ModalData=JSON.parse(e.data) ws.onmessage = (e) => {
if (this.visible===false) { this.$refs.moduleximport.edit(JSON.parse(e.data));
// this.getList()
console.log("重新获取列表")
}
} }
}, },
// //
checkChange (checked) { checkChange(checked) {
// name // name
console.log(checked) // ['age','address','action'] console.log(checked) // ['age','address','action']
const columns = this.columns const columns = this.columns
@ -558,14 +586,14 @@ export default {
this.filterColumn = filterValue this.filterColumn = filterValue
}, },
fanhui () { fanhui() {
this.$router.push({ this.$router.push({
/*返回产品*/ /*返回产品*/
path: '/src/views/projectx/ProjectxList',/*在引号中填写返回vue*/ path: '/src/views/projectx/ProjectxList',/*在引号中填写返回vue*/
}) })
}, },
loginRole (id) { loginRole(id) {
getAction('functionx/functionx/loginrole', { id: id }).then((res) => { getAction('functionx/functionx/loginrole', {id: id}).then((res) => {
if (res.success) { if (res.success) {
// //
this.userRole1 = res.result this.userRole1 = res.result
@ -573,8 +601,8 @@ export default {
} }
}) })
}, },
shenhe (record) { shenhe(record) {
getAction('/modulex/modulex/shenhe', { id: record.id }).then((res) => { getAction('/modulex/modulex/shenhe', {id: record.id}).then((res) => {
if (res.success) { if (res.success) {
// //
this.$message.success(res.result) this.$message.success(res.result)
@ -584,10 +612,10 @@ export default {
} }
}) })
}, },
viewVid (record) { viewVid(record) {
// console.log(record) // console.log(record)
let s = null let s = null
getAction('/tablex/tablex/list', { moduleId: record.id }).then((res) => { getAction('/tablex/tablex/list', {moduleId: record.id}).then((res) => {
s = res.result.records s = res.result.records
console.log(s) console.log(s)
if (s[0] == null) { if (s[0] == null) {
@ -605,8 +633,8 @@ export default {
this.$refs.BugxModal.title = "BUG反馈" this.$refs.BugxModal.title = "BUG反馈"
this.$refs.BugxModal.disableSubmit = false this.$refs.BugxModal.disableSubmit = false
}, },
chehui (record) { chehui(record) {
getAction('/modulex/modulex/cehui', { id: record.id }).then((res) => { getAction('/modulex/modulex/cehui', {id: record.id}).then((res) => {
if (res.success) { if (res.success) {
// //
this.$message.success(res.result) this.$message.success(res.result)
@ -616,8 +644,8 @@ export default {
} }
}) })
}, },
tijiao (record) { tijiao(record) {
getAction('/modulex/modulex/tijiao', { id: record.id }).then((res) => { getAction('/modulex/modulex/tijiao', {id: record.id}).then((res) => {
if (res.success) { if (res.success) {
// //
this.$message.success(res.result) this.$message.success(res.result)
@ -627,8 +655,8 @@ export default {
} }
}) })
}, },
kaishi (record) { kaishi(record) {
getAction('/modulex/modulex/kaishi', { id: record.id }).then((res) => { getAction('/modulex/modulex/kaishi', {id: record.id}).then((res) => {
if (res.success) { if (res.success) {
// //
this.$message.success(res.result) this.$message.success(res.result)
@ -638,8 +666,8 @@ export default {
} }
}) })
}, },
fabu (record) { fabu(record) {
getAction('/modulex/modulex/fabu', { id: record.id }).then((res) => { getAction('/modulex/modulex/fabu', {id: record.id}).then((res) => {
if (res.success) { if (res.success) {
// //
this.$message.success(res.result) this.$message.success(res.result)
@ -647,7 +675,7 @@ export default {
} }
}) })
}, },
functionManage (record) { functionManage(record) {
this.$router.push({ this.$router.push({
path: '/src/views/functionx/FunctionxList', path: '/src/views/functionx/FunctionxList',
query: { query: {
@ -657,7 +685,7 @@ export default {
// query: {id: '123456'} // query: {id: '123456'}
}) })
}, },
tablexManage (record) { tablexManage(record) {
this.$refs.TablexList.showModal() this.$refs.TablexList.showModal()
this.$refs.TablexList.edit(record) this.$refs.TablexList.edit(record)
this.$refs.TablexList.disableSubmit = false this.$refs.TablexList.disableSubmit = false
@ -666,34 +694,34 @@ export default {
// query: {moduleid: record.id,project:this.$route.query.project} // query: {moduleid: record.id,project:this.$route.query.project}
// }) // })
}, },
initDictConfig () { initDictConfig() {
}, },
getSuperFieldList () { getSuperFieldList() {
let fieldList = [] let fieldList = []
fieldList.push({ type: 'string', value: 'pid', text: '上级模块id', dictCode: '' }) fieldList.push({type: 'string', value: 'pid', text: '上级模块id', dictCode: ''})
fieldList.push({ type: 'string', value: 'projectId', text: '项目id', dictCode: '' }) fieldList.push({type: 'string', value: 'projectId', text: '项目id', dictCode: ''})
fieldList.push({ type: 'string', value: 'moduleName', text: '中文名称', dictCode: '' }) fieldList.push({type: 'string', value: 'moduleName', text: '中文名称', dictCode: ''})
fieldList.push({ type: 'string', value: 'moduleEnName', text: '英文名称', dictCode: '' }) fieldList.push({type: 'string', value: 'moduleEnName', text: '英文名称', dictCode: ''})
fieldList.push({ type: 'string', value: 'moduleCode', text: '模块编码', dictCode: '' }) fieldList.push({type: 'string', value: 'moduleCode', text: '模块编码', dictCode: ''})
fieldList.push({ type: 'string', value: 'pmDescribe', text: '内容描述', dictCode: '' }) fieldList.push({type: 'string', value: 'pmDescribe', text: '内容描述', dictCode: ''})
fieldList.push({ type: 'string', value: 'managerUsers', text: '责任人', dictCode: '' }) fieldList.push({type: 'string', value: 'managerUsers', text: '责任人', dictCode: ''})
fieldList.push({ type: 'int', value: 'workLevel', text: '任务等级', dictCode: '' }) fieldList.push({type: 'int', value: 'workLevel', text: '任务等级', dictCode: ''})
fieldList.push({ type: 'int', value: 'workStatus', text: '任务状态', dictCode: '' }) fieldList.push({type: 'int', value: 'workStatus', text: '任务状态', dictCode: ''})
fieldList.push({ type: 'date', value: 'publishTime', text: '发布时间' }) fieldList.push({type: 'date', value: 'publishTime', text: '发布时间'})
fieldList.push({ type: 'double', value: 'duration', text: '任务时长', dictCode: '' }) fieldList.push({type: 'double', value: 'duration', text: '任务时长', dictCode: ''})
fieldList.push({ type: 'date', value: 'startTime', text: '开始时间' }) fieldList.push({type: 'date', value: 'startTime', text: '开始时间'})
fieldList.push({ type: 'date', value: 'submitTime', text: '提交时间' }) fieldList.push({type: 'date', value: 'submitTime', text: '提交时间'})
fieldList.push({ type: 'double', value: 'realDuration', text: '实际时长', dictCode: '' }) fieldList.push({type: 'double', value: 'realDuration', text: '实际时长', dictCode: ''})
fieldList.push({ type: 'string', value: 'userRole', text: '用户角色', dictCode: '' }) fieldList.push({type: 'string', value: 'userRole', text: '用户角色', dictCode: ''})
fieldList.push({ type: 'string', value: 'relatedBean', text: '关联实体', dictCode: '' }) fieldList.push({type: 'string', value: 'relatedBean', text: '关联实体', dictCode: ''})
fieldList.push({ type: 'string', value: 'prototypes', text: '原型图', dictCode: '' }) fieldList.push({type: 'string', value: 'prototypes', text: '原型图', dictCode: ''})
fieldList.push({ type: 'string', value: 'diagrams', text: '分析图', dictCode: '' }) fieldList.push({type: 'string', value: 'diagrams', text: '分析图', dictCode: ''})
fieldList.push({ type: 'int', value: 'status', text: '模块状态', dictCode: '' }) fieldList.push({type: 'int', value: 'status', text: '模块状态', dictCode: ''})
fieldList.push({ type: 'int', value: 'verisonStatus', text: '版本状态', dictCode: '' }) fieldList.push({type: 'int', value: 'verisonStatus', text: '版本状态', dictCode: ''})
fieldList.push({ type: 'int', value: 'verison', text: '版本号', dictCode: '' }) fieldList.push({type: 'int', value: 'verison', text: '版本号', dictCode: ''})
this.superFieldList = fieldList this.superFieldList = fieldList
}, },
loadParameter () { loadParameter() {
if (this.loadRouteType === false) { if (this.loadRouteType === false) {
this.projectIdx = this.$route.query.project this.projectIdx = this.$route.query.project
// console.log('aaaaaaaaa',this.projectIdx) // console.log('aaaaaaaaa',this.projectIdx)
@ -701,7 +729,7 @@ export default {
this.loadRouteType = true this.loadRouteType = true
} }
}, },
loadData (arg) { loadData(arg) {
if (!this.url.list) { if (!this.url.list) {
this.$message.error("请设置url.list属性!") this.$message.error("请设置url.list属性!")
return return
@ -730,7 +758,7 @@ export default {
this.loading = false this.loading = false
}) })
}, },
getQueryParams () { getQueryParams() {
// //
let sqp = {} let sqp = {}
if (this.superQueryParams) { if (this.superQueryParams) {
@ -742,7 +770,7 @@ export default {
param.pageNo = this.ipagination.current param.pageNo = this.ipagination.current
param.pageSize = this.ipagination.pageSize param.pageSize = this.ipagination.pageSize
// 使 // 使
if(param.projectId==null) if (param.projectId == null)
param.projectId = this.$route.query.project; param.projectId = this.$route.query.project;
//param.id=this.id; //param.id=this.id;
//!!!!!!! //!!!!!!!
@ -750,7 +778,7 @@ export default {
// console.log('paaaaaaaaaaaaaaaaaaaaa') // console.log('paaaaaaaaaaaaaaaaaaaaa')
return filterObj(param) return filterObj(param)
}, },
searchReset () { searchReset() {
this.queryParam = '' this.queryParam = ''
this.loadData() this.loadData()
}, },

@ -7,40 +7,48 @@
@ok="handleOk" @ok="handleOk"
@cancel="handleCancel" @cancel="handleCancel"
cancelText="关闭"> cancelText="关闭">
<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 }">
<!-- <a-alert message="请下载" type="info" show-icon /> --> <!-- <a-alert message="请下载" type="info" show-icon /> -->
<a-form-item label="下载标准表格"> <a-form-item label="下载标准表格">
<div class="standB"><a-button type="primary" icon="download" @click="handleDownload"/></div> <div class="standB">
<div class="standBu"> <a-alert <a-button type="primary" icon="download" @click="handleDownload"/>
message="必须下载标准表格,否则审核不通过" </div>
type="error" <div class="standBu">
closable <a-alert
@close="onClose" message="必须下载标准表格,否则审核不通过"
/></div> type="error"
closable
@close="onClose"
/>
</div>
</a-form-item> </a-form-item>
<a-form-item label="上传标准表格"> <a-form-item label="上传标准表格">
<!-- @click="showProcess" --> <a-upload name="file"
<a-upload :multiple="false"
:multiple="false" :action="url.uploadUrl"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76" :showUploadList="false"
@change="handleChange"> :headers="tokenHeader">
<a-button type="primary" icon="upload" ></a-button> <a-button type="primary" icon="upload"></a-button>
<!-- <div>
<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-form-model-item label="注意事项" v-if="uploadFinished"> <a-form-item v-if="ModalData.isVisible==='true'" class="box">
<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-form-item>
<!-- <a-form-model-item label="注意事项" v-if="uploadFinished">-->
<a-form-model-item label="注意事项">
<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 }} . {{ 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-list>
</a-form-model-item> </a-form-model-item>
</a-form> </a-form>
@ -48,16 +56,18 @@
</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 {mixinDevice} from '@/utils/mixin'
export default { export default {
name: 'ModelTest', name: 'ModelTest',
comments: { mixins: [JeecgListMixin, mixinDevice],
comments: {},
},
data() { data() {
return { return {
title: '导入xxxxxx', title: '导入xxxxx',
visible: false, visible: false,
model: {}, model: {},
// //
@ -71,9 +81,11 @@ export default {
confirmLoading: false, confirmLoading: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
url: url:
{ {
downfile: '' downfile: '',
}, uploadUrl: '',
list: "/modulex/modulex/list"
},
datas: [ datas: [
'Racing car sprays burning fuel into crowd.', 'Racing car sprays burning fuel into crowd.',
'Japanese princess to wed commoner.', 'Japanese princess to wed commoner.',
@ -81,24 +93,24 @@ 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() {
}, },
computed: { computed: {},
},
methods: { methods: {
// //
// //
showProcess() { /* showProcess() {
let userId = store.getters.userInfo.id let userId = store.getters.userInfo.id
let baseUrl = window._CONFIG['domianURL'] let baseUrl = window._CONFIG['domianURL']
baseUrl = baseUrl.replace('http', 'ws') baseUrl = baseUrl.replace('http', 'ws')
let ws = new WebSocket(`${baseUrl}/uploadProcess/${userId}`) let ws = new WebSocket(`${baseUrl}/uploadProcess/${userId}`)
ws.onmessage = (e) => { ws.onmessage = (e) => {
this.ModalData = JSON.parse(e.data) this.ModalData = JSON.parse(e.data)
} }
}, },*/
// //
handleChange(info) { handleChange(info) {
if (info.file.status !== 'uploading') { if (info.file.status !== 'uploading') {
@ -117,23 +129,34 @@ 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(data) {
this.url.uploadUrl = data.uploadUrl
this.url.downfile = data.downUrl
this.datas=data.note
this.title=data.title
this.ModalData = {}
this.visible = true
}, },
edit(record) { edit(record) {
this.ModalData = record
},
edit1(record) {
this.visible = true this.visible = true
}, },
@ -157,12 +180,19 @@ export default {
</script> </script>
<style scoped> <style scoped>
.standB{ .standB {
width: 15%; width: 15%;
float: left; float: left;
} }
.standBu{
.standBu {
width: 85%; width: 85%;
float: right; float: right;
} }
.box{
display: flex;
flex-direction:column;
justify-content:center;
align-items: center;
}
</style> </style>

@ -1,5 +1,7 @@
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;
@ -40,12 +42,16 @@ 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;
@ -55,404 +61,435 @@ 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");
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(); // 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
if (StringUtils.isBlank(originalFilename) || String templateUrl = wordPath + File.separator + "实体表模板.xls";
(!originalFilename.endsWith("xls") && TemplateExportParams params = new TemplateExportParams(
!originalFilename.endsWith("xlsx"))) { templateUrl);
message.put("isVisible", "false"); ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView());
webSocketUtils.sendMessage(loginUser.getId(), message); mv.addObject(TemplateExcelConstants.FILE_NAME, fileName);
return Result.error("文件格式不正确"); mv.addObject(TemplateExcelConstants.PARAMS, params);
} // 添加模板参数
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) {
message.put("isVisible", "false"); log.error("下载模板异常--》{}", e);
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败");
} }
message.put("isVisible", "false"); return null;
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.ok("文件导入成功!");
} }
} }

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

Loading…
Cancel
Save