多文件上传和读取txt数据显示表格

编程入门 行业动态 更新时间:2024-10-10 17:28:30

多<a href=https://www.elefans.com/category/jswz/34/1770535.html style=文件上传和读取txt数据显示表格"/>

多文件上传和读取txt数据显示表格

自适应高度
<template><a-card  class="MainCard" hoverable style="width: 100% ;height: auto;"><a-row type="flex" justify="space-between" ><a-col span="24"><a-card hoverable style="font-size: 20px;width: 100%;height:auto;float:left"><div><a-row><a-col span="7"><div style="font-weight:bold;font-size: 20px;color: black;">① 油藏模型导入</div></a-col><a-col span="10" ><a-upload-draggername="file":action="uploadUrl":multiple="true"@change="handleChange"><p class="ant-upload-drag-icon"><a-icon type="inbox" /></p><p class="ant-upload-text">点击或者拖拽上传</p><p class="ant-upload-hint">将油藏模型文件多选上传,不能选文件夹!</p></a-upload-dragger></a-col></a-row></div></a-card></a-col><a-col span="24" ><a-spin size="large" :spinning="spinning_data" ><a-card hoverable style="font-size: 20px;width: 100%;height:auto;margin-top: 10px"><a slot = "title" style="font-weight:bold;font-size: 20px;color: black;">② 井生产数据展示</a><a slot="extra" href="#"><a-button type="primary" :loading="loading_chuli" @click="read_Sch">开始展示</a-button></a><el-table:data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"style="width: 100%"><el-table-columnlabel="井名"prop="wellname"></el-table-column><el-table-columnlabel="井别"prop="type"></el-table-column><el-table-columnlabel="产液量"prop="chanye"></el-table-column><el-table-columnlabel="上限"prop="up"></el-table-column><el-table-columnlabel="下限"prop="down"></el-table-column><el-table-columnalign="right"><template slot="header" slot-scope="scope"><el-inputv-model="search"size="mini"placeholder="输入关键字搜索"/></template><template slot-scope="scope"><el-buttonsize="mini"@click="handleEdit(scope.$index, scope.row)">Edit</el-button><el-buttonsize="mini"type="danger"@click="handleDelete(scope.$index, scope.row)">Delete</el-button></template></el-table-column></el-table></a-card></a-spin></a-col></a-row></a-card></template><script >
// 张宝东
import {uploadFile2} from '../../api'
import {read_sch} from '../../api'export default {data() {return {//张宝东tableData: [ ],cslj:'D:\\Injection_production_optimization\\item\\BASE',xmm:'BASE',sxbs:'1.5',xxbs:'0.5',opt:null,spinning_data:false}},computed: {uploadUrl() {return uploadFile2}},methods: {//上传文件,张宝东handleClick(row) {console.log(row);},handleChange(info) {const status = info.file.status;if (status !== 'uploading') {console.log(info.file, info.fileList);}if (status === 'done') {this.$message.success(`${info.file.name} file uploaded successfully.`);} else if (status === 'error') {this.$message.error(`${info.file.name} file upload failed.`);}},// 调用特征数据read_Sch () {var qs = require('qs');var params = qs.stringify({cslj: this.cslj,xmm: this.xmm,sxbs: this.sxbs,xxbs: this.xxbs});read_sch(params).then(function (result) {this.opt = result.data.opt;this.tableData=result.data.opt.wellmodel;}.bind(this)).catch(function (error) {// this.loading4 = falseconsole.log(error)})}}
}
</script>
const BASE_PATH2 = 'http://127.0.0.1:9521/api/yw1';//张宝东编辑 文件上传地址
export const uploadFile2 = `http://127.0.0.1:9521/api/yw1/user/muilty_upload`
// 保存选择模型
export const read_sch = params => { return Axios.post(`${BASE_PATH2}/user/sch`,  params  ).then(res => res.data) }
@RequestMapping(value="/muilty_upload", method = RequestMethod.POST)public ResponseData uploadImg(@RequestParam("file") MultipartFile file) {String contentType = file.getContentType();String fileName = file.getOriginalFilename();System.out.println("fileName-->" + fileName);System.out.println("getContentType-->" + contentType);String filePath = "D:\\11\\";try {new SgtzdController().uploadFile(file.getBytes(), filePath, fileName);} catch (Exception e) {e.printStackTrace();}return ResponseData.ok("success");}public  void uploadFile(byte[] file, String filePath, String fileName) throws Exception {File targetFile = new File(filePath);if(!targetFile.exists()){targetFile.mkdirs();}FileOutputStream out = new FileOutputStream(filePath+fileName);out.write(file);out.flush();out.close();}@RequestMapping(value="/sch", method = RequestMethod.POST)public ResponseData Culculate(OptModel opt) throws JsonParseException, JsonMappingException, IOException  {//HttpServletRequest request  = ServletActionContext.getRequest();//String Optmod = request.getParameter("Optmod");//	ObjectMapper mapper = new ObjectMapper();//	opt = mapper.readValue(Optmod,OptModel.class);//特殊的复杂数据结构//OptModel opt=new OptModel();WellData welldata = new WellData();LinkedList<WellData> welllist=new LinkedList<WellData>();//读井sch数据//读sch文件String pathsch =opt.getCslj()+"\\"+opt.getXmm()+".SCH";System.out.println(pathsch);Scanner scanner = new Scanner(new FileInputStream(pathsch) ) ;FileInputStream fis=new FileInputStream(pathsch);InputStreamReader isr=new InputStreamReader(fis);BufferedReader br = new BufferedReader(isr);String line="";String[] arrs=null;while (true) {String lines=br.readLine();if(lines==null)break;if(lines.contains("WCONPROD")) {//查找关键字welllist.clear();while((lines = br.readLine())!=null) {if(lines.toCharArray().length<16)break;arrs = lines.split("\\s+");//按照空格分割一行的数据WellData wellnode = new WellData();WellData wellnodea = new WellData();wellnode = nwelldata2oil(wellnodea, arrs, opt.getSxbs(), opt.getXxbs());welllist.add(wellnode);//加一行 井节点,table数据的一行,循环加完}}if(lines.contains("WCONINJE")) {while((lines = br.readLine())!=null) {if(lines.toCharArray().length<16)break;arrs = lines.split("\\s+");WellData wellnode = new WellData();WellData wellnodea = new WellData();wellnode = nwelldata2water(wellnodea, arrs, opt.getSxbs(), opt.getXxbs());welllist.add(wellnode);}}}opt.setWellmodel(welllist);//writeOptFile(opt);HashMap data=new HashMap();data.put("opt",opt);//beanreturn ResponseData.ok(data);}private WellData nwelldata2oil(WellData welldata, String[] arrs, String up, String down) {welldata.setChanye(arrs[4]);double chanyeliang=Double.parseDouble(arrs[4]);DecimalFormat df = new DecimalFormat("#.00");String upd=df.format(Double.parseDouble(up)*chanyeliang);String dowd=df.format(Double.parseDouble(down)*chanyeliang);welldata.setUp(String.valueOf(upd) );welldata.setWellname(arrs[0]);welldata.setDown(String.valueOf(dowd) );String aa=null;welldata.setType("oil");return welldata;}private WellData nwelldata2water(WellData welldata, String[] arrs, String up, String down) {welldata.setChanye(arrs[4]);double chanyeliang=Double.parseDouble(arrs[4]);DecimalFormat df = new DecimalFormat("#.00");String upd=df.format(Double.parseDouble(up)*chanyeliang);String dowd=df.format(Double.parseDouble(down)*chanyeliang);welldata.setUp(String.valueOf(upd) );welldata.setWellname(arrs[0]);welldata.setDown(String.valueOf(dowd) );String aa=null;welldata.setType("water");return welldata;}


后台返回的对象

更多推荐

多文件上传和读取txt数据显示表格

本文发布于:2024-02-06 15:59:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749917.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件上传   表格   数据   txt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!