日期案例
<div class="form-group">
<label class="col-sm-3 control-label">提交日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="submitdate" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
附件上传
前端页面
<!--附件上传-->
案例一
<div class="form-group">
<label class="col-sm-2 control-label">附件1-发改委立项批复或领导批示:</label>
<div class="col-sm-9">
<div class="file-loading">
<input id="multipleFile1" name="files" type="file" multiple>
</div>
<input id="accessorypf1" name="accessorypf1" >
</div>
</div>
案例二
<div class="col-sm-8 col-md-offset-2" >
<div class="ibox form-group float-e-margins col-sm-8">
<div class="ibox-title col-sm-8">
<label class=" control-label is-required">附件1-发改委立项批复或领导批示:</label>
</div>
<div class="ibox-content ">
<div class="form-group col-sm-12">
<div class="file-loading col-sm-12">
<input id="accessorypf_up" name="accessorypf_up" type="file" multiple>
</div>
<input id="accessorypf" name="accessorypf" >
</div>
</div>
</div>
</div>
前端js
$(document).ready(function () {
// 发改委立项批复或领导批示
$("#multipleFile1").fileinput({
language: 'zh',
uploadUrl: ctx + 'common/uploads',
showUpload: false, //是否显示上传按钮,加上这个,把上传按钮隐藏掉,避免歧义
uploadAsync: true
}).on('fileuploaded', function (event, data, previewId, index) {
//上传成功
console.log("上傳成功!")
var rsp = data.response;
let urls = rsp.urls;
var filepath =urls+';id:'+previewId;
log.info("return urls:" +urls)
log.info("return filepath:" +filepath)
//存放在input
var url=$("#accessorypf1").val();
if (url != null || url !=''){
$("#accessorypf1").val(url+"*|||*"+filepath);
}else {
$("#accessorypf1").val(filepath)
}
console.log(event)
console.log(data)
console.log(previewId)
console.log(index)
var rsp = data.response;
log.info("return urls:" + rsp.urls)
log.info("return fileMsg:" + rsp.fileMsg)
log.info("reutrn fileNames:" + rsp.fileNames)
log.info("reutrn newFileNames:" + rsp.newFileNames)
log.info("return originalFilenames:" + rsp.originalFilenames)
log.info("return previewId:" + rsp.previewId)
}).on('filesuccessremove', function (event,id) {
//event,data,previewId,index
console.log("删除成功上传通知")
var urls=$("#accessorypf1").val();
//删除input urls
var szarr=urls.split('*|||*');
//遍历删除指定图片
for(let i = 0; i < szarr.length; i++) {
var index= szarr[i].indexOf(id);
if(index > 0){
//存在
//服务器本地删除
$.get(
'/common/del',
{
fileurl:szarr[i],
id:id
},function(data){ //回传函数
$.modal.msg(data.msg)
},
)
console.log("id存在,删除成功!")
szarr.splice(i, 1);
i--;
}else{
//不存在
console.log("id不存在,删除失败!")
}
}
//遍历还原字符串
var newurl="";
for(let i = 0; i < szarr.length; i++) {
newurl=newurl+szarr[i]+'*|||*';
}
$("#accessorypf1").val(newurl)
console.log(event.currentTarget.id)
console.log(id)
}).on('fileremoved', function (event, data, previewId, index) {
//删除信息
console.log("删除")
console.log(event)
console.log(data)
console.log(previewId)
console.log(index)
}).on('filebatchselected', function (event, data, id, index) {
$(this).fileinput("upload");//主要就是这个事件啊,选择文件之后,直接出发upload事件
})
js 上面html尾部加上这段
<th:block th:include="include :: bootstrap-fileinput-js" />
<th:block th:include="include :: datetimepicker-js" />
文件上传后端代码,看common/uploads通用上传代码
idea热部署方法
https://www.jianshu.com/p/c50df2882325 免费使用JRebel插件教程
前端表单校验
在input中的class 增加 required,必输入校验
<div class="form-group">
<label class="col-sm-3 control-label is-required">送审单位:</label>
<div class="col-sm-8">
<input name="submitunit" class="form-control required" type="text">
</div>
</div>
后端发起ajax请求,post提交
前端表单
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-project-add">
<div class="form-group">
<h2 style=" text-align:center;"><b>项目评审填报</b></h2>
<hr>
<label class="col-sm-3 control-label is-required">项目名称:</label>
<div class="col-sm-8">
<input name="rojectname" class="form-control required "></input>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">送审单位:</label>
<div class="col-sm-8">
<input name="submitunit" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">联系人:</label>
<div class="col-sm-8">
<input name="linkman" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required "> 手机:</label>
<div class="col-sm-8">
<input name="phone" onkeyup="this.value=this.value.replace(/\D/g,'')" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required" >单位座机电话:</label>
<div class="col-sm-8">
<input name="call" onkeyup="this.value=this.value.replace(/\D/g,'')" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required" >前期是否已编制控制价:</label>
<div class="col-sm-8">
<div class="radio check-box">
<label>
<input type="radio" value="1" name="enableqqkzj" class="form-control required"> <i></i> 是</label>
</div>
<div class="radio check-box">
<label>
<input type="radio" value="0" name="enableqqkzj" class="form-control required"> <i></i> 否</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">金额(万元):</label>
<div class="col-sm-8">
<input name="rojectmoney" onkeyup="value=value.replace(/[^\d.]/g,'')" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">概算金额(万元):</label>
<div class="col-sm-8">
<input name="budgetmoney" onkeyup="value=value.replace(/[^\d.]/g,'')" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">概算的工程费(万元):</label>
<div class="col-sm-8">
<input name="budgetengineeringmoney" onkeyup="value=value.replace(/[^\d.]/g,'')" class="form-control required" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">投资估算工程费(万元):</label>
<div class="col-sm-8">
<input name="investengineeringmoney" onkeyup="value=value.replace(/[^\d.]/g,'')" class="form-control required" type="text">
</div>
</div>
<hr>
<!--附件上传-->
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件1-发改委立项批复或领导批示:</label>
<div class="col-sm-6">
<div class="file-loading">
<input id="accessorypf_up" name="files" type="file" multiple>
</div>
<input id="accessorypf" name="accessorypf" type="hidden" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件2-可行性研究报告:</label>
<div class="col-sm-6">
<div class="file-loading">
<input id="accessorykxxbg_up" name="files" type="file" multiple>
</div>
<input id="accessorykxxbg" name="accessorykxxbg" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件3-初步设计:</label>
<div class="col-sm-5">
<div class="file-loading">
<input id="accessorycbsj_up" name="files" type="file" multiple>
</div>
<input id="accessorycbsj" name="accessorycbsj" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件4-发改委初步设计批复:</label>
<div class="col-sm-5">
<div class="file-loading">
<input id="accessorycbsjpf_up" name="files" type="file" multiple>
</div>
<input id="accessorycbsjpf" name="accessorycbsjpf" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件5-委托函:</label>
<div class="col-sm-5">
<div class="file-loading">
<input id="accessorywth_up" name="files" type="file" multiple>
</div>
<input id="accessorywth" name="accessorywth" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件6-评审项目报审表(前期):<a href="">模版下载</a></label>
<div class="col-sm-5">
<div class="file-loading">
<input id="accessorypsxmb_up" name="files" type="file" multiple>
</div>
<input id="accessorypsxmb" name="accessorypsxmb" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">附件7-电子版图纸:</label>
<div class="col-sm-5">
<div class="file-loading">
<input id="electronicdrawing_up" name="files" type="file" multiple>
</div>
<input id="electronicdrawing" name="electronicdrawing" class="form-control required" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label ">附件8-其他附件:</label>
<div class="col-sm-5">
<div class="file-loading">
<input id="accessory_up" name="files" type="file" multiple>
</div>
<input id="accessory" name="accessory" class="form-control required" >
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<div class="col-sm-12 col-sm-offset-3">
<button type="submit" class="btn btn-primary">提交</button>
<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
</div>
</div>
</div>
</form>
</div>
后端js提交
var prefix = ctx + "business/project"
//表单清除
$("#form-project-add").validate({
focusCleanup: true
});
//提交表单
function submitHandler() {
if ($.validate.form()) {
add();
}
}
//ajax异步提交表单数据
function add() {
//获取全部参数 $('#form-project-add').serialize()
//校验全部参数 $("#form-xxx").validate().form();
var rojectname = $("input[name='rojectname']").val();
var submitunit = $("textarea[name='submitunit']").val();
var linkman = $("input[name='linkman']").val();
var phone = $("input[name='phone']").val();
var call = $("input[name='call']").val();
var enableqqkzj = $("input[name='enableqqkzj']").val();
var rojectmoney = $("input[name='rojectmoney']").val();
var budgetmoney = $("input[name='budgetmoney']").val();
var budgetengineeringmoney = $("input[name='budgetengineeringmoney']").val();
var investengineeringmoney = $("input[name='investengineeringmoney']").val();
var accessorypf = $("input[name='accessorypf']").val();
var accessorykxxbg = $("input[name='accessorykxxbg']").val();
var accessorycbsj = $("input[name='accessorycbsj']").val();
var accessorycbsjpf = $("input[name='accessorycbsjpf']").val();
var accessorywth = $("input[name='accessorywth']").val();
var accessorypsxmb = $("input[name='accessorypsxmb']").val();
var electronicdrawing = $("input[name='electronicdrawing']").val();
var accessory = $("input[name='accessory']").val();
$.ajax({
cache : true,
type : "POST",
url : prefix + "/add",
data : {
"rojectname": rojectname,
"submitunit": submitunit,
"linkman": linkman,
"phone": phone,
"call": call,
"enableqqkzj": enableqqkzj,
"rojectmoney": rojectmoney,
"budgetmoney": budgetmoney,
"budgetengineeringmoney": budgetengineeringmoney,
"investengineeringmoney": investengineeringmoney,
"accessorypf": accessorypf,
"accessorykxxbg": accessorykxxbg,
"accessorycbsj": accessorycbsj,
"accessorycbsjpf": accessorycbsjpf,
"accessorywth": accessorywth,
"accessorypsxmb": accessorypsxmb,
"electronicdrawing": electronicdrawing,
"accessory": accessory,
},
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
$.operate.successCallback(data);
}
});
}
日志输出
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BusinessProjectController.class);
//使用
log.info("进入上传文件接口");
后端工具类使用
1.是否包含制定内容
busBuy.getState().contains("待编辑")
2.设置uuid
IdUtils.fastSimpleUUID()
3.解析日期到date
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(DateUtils.getTime())
4.map 赋值到实体类
//map 赋值 实体类
BusinessProject businessProject = new BusinessProject();
BeanUtils.populate(businessProject, allParams);
卡片列表
table自动计算
https://blog.csdn.net/weixin_30790841/article/details/97834511
表格table 组合/合并
<table id="tb_report" border="1px" cellspacing="0" cellpadding="15px" >
<caption style="font-size: 30px;margin-top: 10px;margin-bottom: 20px;">工程造价咨询服务项目和收费汇总表</caption>
<tr class="success">
<th data-field="district" rowspan="2" data-valign="middle" data-align="center">阶段</th>
<th data-field="sprayPropertyName" rowspan="2" data-valign="middle" data-align="center">咨询服务范围名称</th>
<th data-field="parentBuildName" rowspan="2" data-valign="middle" data-align="center">收费基数</th>
<th data-field="parentBuildName" rowspan="2" data-valign="middle" data-align="center">造价(万元)</th>
<th data-field="parentBuildName" rowspan="2" data-valign="middle" data-align="center">咨询服务费(万元)</th>
<th colspan="5" data-valign="middle" data-align="center">划分标准</th>
</tr>
<tr class="success">
<td>≤500万元</td>
<td>501-3000万元</td>
<td>3001-5000万元</td>
<td>5001-10000万元</td>
<td>>10000万元</td>
</tr>
<!--表头结束-->
<tr>
<td rowspan="2">发承包阶段</td>
<td data-valign="middle" data-align="center"> 工程量清单</td>
<td data-valign="middle" data-align="center"> 建筑安装工程造价</td>
<td data-valign="middle" data-align="center"> <input name="accessorywth" class="form-control" ></td>
<td style="text-align: center;"> 咨询结果</td>
<td style="text-align: center;"> 500</td>
<td style="text-align: center;"> 400</td>
<td style="text-align: center;"> 500</td>
<td style="text-align: center;"> 500</td>
<td style="text-align: center;"> 500</td>
</tr>
<tr>
<td data-valign="middle" data-align="center"> 最高投标限价</td>
<td data-valign="middle" data-align="center"> 建筑安装工程造价</td>
<td data-valign="middle" data-align="center"> <input name="accessorywth" class="form-control" ></td>
<td style="text-align: center;"> 咨询结果</td>
<td style="text-align: center;"> 500</td>
<td style="text-align: center;"> 400</td>
<td style="text-align: center;"> 500</td>
<td style="text-align: center;"> 500</td>
<td style="text-align: center;"> 500</td>
</tr>
<!--竣工结算-->
<tr>
<td rowspan="2">竣工结算</td>
<td data-valign="middle" data-align="center"> (1)基本收费</td>
<td data-valign="middle" data-align="center"> 建筑安装工程送审造价</td>
<td data-valign="middle" data-align="center"> <input name="accessorywth" class="form-control" ></td>
<td data-valign="middle" style="text-align: center;"> 咨询结果</td>
<td data-valign="middle" style="text-align: center;"> 500</td>
<td data-valign="middle" style="text-align: center;"> 500</td>
<td data-valign="middle" style="text-align: center;"> 500</td>
<td data-valign="middle" style="text-align: center;"> 500</td>
<td data-valign="middle" style="text-align: center;"> 500</td>
</tr>
<tr>
<td data-valign="middle" data-align="center"> (2)效益收费</td>
<td data-valign="middle" data-align="center"> 核减额+核增额</td>
<td data-valign="middle" data-align="center"> <input name="accessorywth" class="form-control" ></td>
<td data-valign="middle" style="text-align: center;" > 咨询结果</td>
<td colspan="5" style="text-align: center;"> 6%</td>
</tr>
</table>
input 前端输入限制
1. 只能输入数字和点
<input name="gongclqingdan" oninput="value=value.replace(/[^0-9\.]/g,'').replace(/^\./g,'').replace(/\.{2,}/g,'.').replace('.','$#$').replace(/\./g,'').replace('$#$','.')" />
2.
若依选项卡+Thymeleaf 局部刷新
效果图
前端代码
<!DOCTYPE html>
<html lang="zh">
<head>
<th:block th:include="include :: header('评审项目列表')" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeIn">
<div class="row">
<div class="col-sm-12">
<div class="tabs-container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" onclick="viewBystate(0)" href="#tab-1" aria-expanded="true">草稿</a>
</li>
<li class=""><a data-toggle="tab" onclick="viewBystate(1)" href="#tab-2" aria-expanded="false">待审核</a>
</li>
<li class=""><a data-toggle="tab" onclick="viewBystate(2)" href="#tab-3" aria-expanded="false">已审核</a>
</li>
<li class=""><a data-toggle="tab" onclick="viewBystate(3)" href="#tab-4" aria-expanded="false">已撤销</a>
</li>
</ul>
<div class="tab-content">
<!--草稿-->
<div id="tab-1" class="tab-pane active">
<div class="panel-body" id="main-content0">
<div class="ibox" th:fragment="main-content0" style="background-color: #3c8dbc;" th:each="mode0:${Projectslist0}">
<div class="ibox-title">
<span class="label label-primary pull-right">草稿</span>
<span class="ibox-title" style="font-weight:bold " th:text="${#dates.format(mode0.submitdate, 'yyyy-MM-dd')}"></span>
<span class="ibox-title" style="font-weight:bold " th:text="'预算单位:'+${mode0.submitunit}"></span>
<span class="ibox-title" style="color: #1a7bb9" th:text="'状态:待审核'"></span>
</div>
<div class="ibox-content">
<div class="row m-t-sm">
<div class="col-sm-10" >
<h5>项目详情</h5>
<p th:text="' 项目名称:'+${mode0.rojectname}">
<p th:text="' 联系人:'+${mode0.linkman}">
<p th:text="' 手机号:'+${mode0.phone}">
</div>
<div class="col-sm-2" >
<h5>操作</h5>
<button type="button" onclick="viewByid(${mode0.id})" class="btn btn-w-m btn-primary">查看</button>
<button style="margin-top: 10px;" type="button" class="btn btn-w-m btn-info"> 审核</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--待审核-->
<div id="tab-2" class="tab-pane">
<div class="panel-body" id="main-content1" >
<div class="ibox" th:fragment="main-content1" style="background-color: #3c8dbc;" th:each="mode1:${Projectslist1}">
<div class="ibox-title">
<span class="label label-primary pull-right">待审核</span>
<span class="ibox-title" style="font-weight:bold " th:text="${#dates.format(mode1.submitdate, 'yyyy-MM-dd')}"></span>
<span class="ibox-title" style="font-weight:bold " th:text="'预算单位:'+${mode1.submitunit}"></span>
<span class="ibox-title" style="color: #1a7bb9" th:text="'状态:待审核'"></span>
</div>
<div class="ibox-content">
<div class="row m-t-sm">
<div class="col-sm-10" >
<h5>项目详情</h5>
<p th:text="' 项目名称:'+${mode1.rojectname}">
<p th:text="' 联系人:'+${mode1.linkman}">
<p th:text="' 手机号:'+${mode1.phone}">
</div>
<div class="col-sm-2" >
<h5>操作</h5>
<button type="button" onclick="viewByid(${mode1.id})" class="btn btn-w-m btn-primary">查看</button>
<button style="margin-top: 10px;" type="button" class="btn btn-w-m btn-info"> 审核</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--已审核-->
<div id="tab-3" class="tab-pane">
<div class="panel-body" id="main-content2" >
<div class="ibox" th:fragment="main-content2" style="background-color: #3c8dbc;" th:each="mode:${Projectslist2}">
<div class="ibox-title">
<span class="label label-primary pull-right">已审核</span>
<span class="ibox-title" style="font-weight:bold " th:text="${#dates.format(mode.submitdate, 'yyyy-MM-dd')}"></span>
<span class="ibox-title" style="font-weight:bold " th:text="'预算单位:'+${mode.submitunit}"></span>
<span class="ibox-title" style="color: #1a7bb9" th:text="'状态:待审核'"></span>
</div>
<div class="ibox-content">
<div class="row m-t-sm">
<div class="col-sm-10" >
<h5>项目详情</h5>
<p th:text="' 项目名称:'+${mode.rojectname}">
<p th:text="' 联系人:'+${mode.linkman}">
<p th:text="' 手机号:'+${mode.phone}">
</div>
<div class="col-sm-2" >
<h5>操作</h5>
<button type="button" onclick="viewByid(${mode.id})" class="btn btn-w-m btn-primary">查看</button>
<button style="margin-top: 10px;" type="button" class="btn btn-w-m btn-info"> 审核</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--已撤销-->
<div id="tab-4" class="tab-pane">
<div class="panel-body" id="main-content3" >
<div class="ibox" th:fragment="main-content3" style="background-color: #3c8dbc;" th:each="mode:${Projectslist3}">
<div class="ibox-title">
<span class="label label-primary pull-right">已撤销</span>
<span class="ibox-title" style="font-weight:bold " th:text="${#dates.format(mode.submitdate, 'yyyy-MM-dd')}"></span>
<span class="ibox-title" style="font-weight:bold " th:text="'预算单位:'+${mode.submitunit}"></span>
<span class="ibox-title" style="color: #1a7bb9" th:text="'状态:待审核'"></span>
</div>
<div class="ibox-content">
<div class="row m-t-sm">
<div class="col-sm-10" >
<h5>项目详情</h5>
<p th:text="' 项目名称:'+${mode.rojectname}">
<p th:text="' 联系人:'+${mode.linkman}">
<p th:text="' 手机号:'+${mode.phone}">
</div>
<div class="col-sm-2" >
<h5>操作</h5>
<button type="button" onclick="viewByid(${mode.id})" class="btn btn-w-m btn-primary">查看</button>
<button style="margin-top: 10px;" type="button" class="btn btn-w-m btn-info"> 审核</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script> var ctx = "\/"; var lockscreen = null; if(lockscreen){window.top.location=ctx+"lockscreen";} </script>
<a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
<script src="/js/jquery.min.js?v=3.6.1"></script>
<script src="/js/bootstrap.min.js?v=3.3.7"></script>
<!-- bootstrap-table 表格插件 -->
<script src="/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=1.18.3"></script>
<script src="/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=1.18.3"></script>
<script src="/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js?v=1.18.3"></script>
<!-- jquery-validate 表单验证插件 -->
<script src="/ajax/libs/validate/jquery.validate.min.js?v=1.19.3"></script>
<script src="/ajax/libs/validate/jquery.validate.extend.js?v=1.19.3"></script>
<script src="/ajax/libs/validate/messages_zh.js?v=1.19.3"></script>
<!-- bootstrap-table 表格树插件 -->
<script src="/ajax/libs/bootstrap-table/extensions/tree/bootstrap-table-tree.min.js?v=1.18.3"></script>
<!-- 遮罩层 -->
<script src="/ajax/libs/blockUI/jquery.blockUI.js?v=2.70.0"></script>
<script src="/ajax/libs/iCheck/icheck.min.js?v=1.0.3"></script>
<script src="/ajax/libs/layer/layer.min.js?v=3.5.1"></script>
<script src="/ajax/libs/layui/layui.min.js?v=2.7.5"></script>
<script src="/ruoyi/js/common.js?v=4.7.6"></script>
<script src="/ruoyi/js/ry-ui.js?v=4.7.6"></script>
<script th:inline="javascript">
var prefix = ctx + "business/project"
//选项卡查询不同数据
function viewBystate(state){
console.log("选择状态"+state)
$.ajax({
type : "get",
url : prefix + "/ByStatelist/"+state,
error : function(request) {
console.log("cuowuxinxi:"+request)
// $.modal.alertError("系统错误");
},
success : function(data) {
// $.operate.successCallback(data);
console.log(data)
if(state==0){
console.log(0)
$("#main-content0").html(data);
}else if(state==1){
console.log(1)
$("#main-content1").html(data);
}else if(state==2){
$("#main-content2").html(data);
}else if(state==3){
$("#main-content3").html(data);
}
//$("#box3").children.remove();
//$.modal.alertSuccess(data)
// $.modal.closeTab();
}
});
}
</script>
</html>
局部刷新重点, th:fragment="main-content1" 在遍历元素加上,然后在父div 加上同名字的id
页面必须直接放在template 目录下,不可放在新建文件里面
后端
@RequiresPermissions("system:project:list")
@GetMapping("/ByStatelist/{state}")
public String aaa(ModelMap mmap,@PathVariable String state) {
try {
BusinessProject businessProject = new BusinessProject();
businessProject.setState(state);
log.info("根据状态查询实体类"+businessProject);
startPage();
List<BusinessProject> list = businessProjectService.selectBusinessProjectList(businessProject);
if(businessProject.getState().equals("0")){
mmap.put("Projectslist0",list);
return "project::main-content0";
} else if (businessProject.getState().equals("1")) {
mmap.put("Projectslist1",list);
return "project::main-content1";
}else if (businessProject.getState().equals("2")) {
mmap.put("Projectslist2",list);
return "project::main-content2";
}else if (businessProject.getState().equals("3")) {
mmap.put("Projectslist3",list);
return "project::main-content3";
}
log.info("根据状态查询list: "+list);
return "评审项目,局部刷新数据错误,!";
} catch (Exception e) {
throw new RuntimeException(e);
}
}
分页案例
异步提交
1.pots方式
$.ajax({
cache : false,
type : "POST",
url : prefix + "/add",
data : {
"rojectname": rojectname,
"submitunit": submitunit,
"linkman": linkman,
"phone": phone,
"calls": calls,
"enableqqkzj": enableqqkzj,
//估算
"estimatemoney": estimatemoney,
"estimateengmoney": estimateengmoney,
"estimateengothermoney": estimateengothermoney,
"estimatereadymoney": estimatereadymoney,
//概算
"budgetmoney": budgetmoney,
"budgetengmoney": budgetengmoney,
"budgetengothermoney": budgetengothermoney,
"budgetreadymoney": budgetreadymoney,
//附件
"accessorypf": accessorypf,
"accessorykxxbg": accessorykxxbg,
"accessorycbsj": accessorycbsj,
"accessorycbsjpf": accessorycbsjpf,
"accessorywth": accessorywth,
"accessorypsxmb": accessorypsxmb,
"electronicdrawing": electronicdrawing,
"accessory": accessory,
},
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
$.operate.successCallback(data);
console.log(data)
$.modal.alertSuccess(data)
$.modal.closeTab();
}
});
2.get方式
//跳转通过id查看页面
function view(projectid){
console.log("通过id查看页面"+projectid);
$.modal.openTab('查看报审项目', prefix + "/view/"+projectid);
}
若依系统导入表格并解析表格入库(案例分析)
效果图
后端接口代码
/**
* 导入表格解析
*/
@PostMapping("/uploadFileSave")
@ResponseBody
public AjaxResult uploadFileSave(@RequestParam("file") MultipartFile file,@RequestParam("filepath") String filepath)
{
try {
log.info("【导入表格解析】入参file:"+file);
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
log.info("【导入表格解析】新文件的名称"+fileName);
log.info("【导入表格解析】新文件的路径"+filePath);
//开始解析
if(StringUtils.isBlank(fileName)){
return error("文件上传错误!");
}
//上传到本地服务器地址为:
int i = fileName.lastIndexOf("upload/");
String substring = fileName.substring(i + 6);
filePath=filePath+substring;
log.info("【导入表格解析】新文件的路径"+filePath);
InputStream is = new FileInputStream(new File(filePath));
//开始解析
ExcelUtil<BusinessProject> util = new ExcelUtil<BusinessProject>(BusinessProject.class);
List<BusinessProject> list = util.importExcel(is,3);
log.info("[导入表格解析]解析之后的集合:"+list);
int success =0;
int err=0;
for (BusinessProject businessProject : list) {
businessProject.setState("4");
businessProject.setEnableqqkzj("0");
businessProject.setRojectid(IdUtils.fastSimpleUUID());
if(businessProject.getAuthorizedmoney()>businessProject.getReportmoney()){
throw new RuntimeException("[档案馆]["+businessProject.getRojectname()+"][审定金额大于报审金额!无法填报!]");
}
}
}catch (Exception e) {
throw new RuntimeException("[(注意表头必须在第四行)导入档案馆表格出现错误:]"+e);
}
return success("表格已导入档案馆!");
}
}
前端代码
<a class="btn btn-primary" onclick="clickbtn()">
<i class="fa fa-cloud-upload"></i>
表格导入档案馆
</a>
<input id="filePath" onchange="uploadFile(this.files)" style="display: none;" name="filePath" class="btn btn-primary form-control" type="file">
前端js
//点击 button代替input file 修改样式
function clickbtn() {
file = document.getElementById("filePath");
if(file){
$('#filePath').click();
}
}
//导入数据
function uploadFile() {
//构建返回data
var formData = new FormData();
//判断是否选择路径文件
if ($('#filePath')[0].files[0] == null) {
$.modal.alertWarning("请先选择文件路径");
return false;
}
let file = $("#filePath").val();
console.log(file)
//判断是否文件是xls或者xlsx
if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))) {
$.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
return false;
}
//data 构造 (字段,值)
formData.append('filepath', file);
formData.append('file', $('#filePath')[0].files[0]);
//异步请求接口
$.ajax({
url: prefixda + "/uploadFileSave",
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function (result) {
if (result.code == web_status.SUCCESS) {
$.modal.closeAll();
$.modal.alertSuccess(result.msg);
//成功后表格刷新
$.table.refresh();
} else if (result.code == web_status.WARNING) {
$.modal.enable();
$.modal.alertWarning(result.msg)
} else {
$.modal.enable();
$.modal.alertError(result.msg);
}
}});
}
若依系统根据表格勾选导出数据
效果图
前端
<a class="btn btn-warning" onclick="checkItem()" >
<i class="fa fa-download"></i> 导出
</a>
前端js
// 导出数据到表格
function checkItem(){
// var arrays = $.table.selectColumns("userId");
var arrays = $.table.selectColumns("rojectid");
// alert(arrays);
$.modal.loading("正在导出数据,请稍候...");
$.ajax({
type : "POST",
url : ctx + "business/project/export",
data : {
"arrays_ids": arrays.toString(),
},
async : false,
error : function(request) {
console.log("填报返回结果错误:"+request)
$.modal.alertError("系统错误");
},
success : function(result) {
if (result.code == web_status.SUCCESS) {
console.log("成功:")
console.log(result)
window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
} else if (result.code == web_status.WARNING) {
$.modal.alertWarning(result.msg)
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
}
});
}
后端
/**
* 导出【评审项目】列表
*/
@Log(title = "【评审项目】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(@RequestParam("arrays_ids") String ids )
{
log.info("[导出表格][入参]"+ids);
List<BusinessProject> list =new ArrayList<>() ;
String[] split = ids.split(",");
for (String s : split) {
if(StringUtils.isBlank(s)){
}else {
BusinessProject businessProjects = businessProjectService.selectBusinessProjectByRojectid(s);
list.add(businessProjects);
}
}
// businessProjectService.selectBusinessProjectList(businessProject);
ExcelUtil<BusinessProject> util = new ExcelUtil<BusinessProject>(BusinessProject.class);
return util.exportExcel(list, "【评审项目】数据");
}
模板下载
前端
<a onclick="mobanxiazai()" >
<i class="fa fa-download"></i> 导入模版下载
</a>
前端js
//模板下载
function mobanxiazai(){
$.modal.msgSuccess("模板下载成功!",5000)
window.location.href = "/ImportTemplate/【评审项目】导入数据模板.xlsx";
}
idea 设置模板文件
div悬浮效果
效果图
<style>
.buttonDiv{
}
.buttonDiv:hover{
position:relative;
top:-10px;
left:-10px;
box-shadow: 10px 10px 5px #888888;
}
.buttonDiv>i{
position:relative;
color:#2959ad;
}
</style>
大数据平台
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('图表组合')" />
<link href="/css/bootstrap.min.css?v=3.3.7" rel="stylesheet"/>
<link href="/css/font-awesome.min.css?v=4.7.0" rel="stylesheet"/>
<link rel="stylesheet" href="/shujupingtai/css/index.css">
<title>二连浩特市财政预算评审综合管理系统数据平台</title>
</head>
<body>
<div class="t_container">
<header class="t_header">
<span>二连浩特市财政预算评审大数据平台</span>
</header>
<main class="t_main">
<!-- //三个方块 显示金额-->
<div class="t_left_box">
<div class="t_mbox t_rbox">
<i></i>
<span>[[${year}]]年控制价审定金额</span>
<h2>[[${
#numbers.formatDecimal(kzj_totle,1,'COMMA',4,'POINT')
}]]万元</h2>
</div>
<div class="t_mbox t_gbox">
<i></i>
<span>[[${year}]]年结算报审金额</span>
<h2>[[${
#numbers.formatDecimal(totle_js_ss,1,'COMMA',4,'POINT')
}]]万元</h2>
</div>
<div class="t_mbox t_ybox">
<i></i>
<span>[[${year}]]年结算审定金额</span>
<h2>[[${
#numbers.formatDecimal(totle_js_sd,1,'COMMA',4,'POINT')
}]]万元</h2>
</div>
</div>
<!-- //中间显示评审项目数量 和地图-->
<div class="t_center_box">
<div class="t_top_box">
<ul class="t_nav">
<li>
<span>评审总项目数</span>
<h1>[[${total}]]</h1>
<i></i>
</li>
<li>
<span>控制价评审项目数</span>
<h1>[[${kzj_size}]]</h1>
<i></i>
</li>
<li>
<span>结算项目数</span>
<h1>[[${js_size}]]</h1>
<i></i>
</li>
</ul>
</div>
<!-- //中间二连浩特市地图显示-->
<div class="t_bottom_box">
<div id="chart_3" class="echart" style="width: 100%; height: 3.6rem;"></div>
</div>
</div>
<!--最右侧 柱状图-->
<div class="t_right_box">
<div id="chart_2" class="echart" style="height: 4.6rem;"></div>
</div>
<div class="b_left_box">
<h1 class="t_title">[[${year}]]年Top3评审项目</h1>
<table class="t_table">
<thead >
<tr style=" text-align: center; ">
<th>申请时间</th>
<th>送审项目</th>
<th>送审单位</th>
<th>前期是否编制控制价</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<tr th:each="buy:${pingshenlist}">
<td th:text="
${#dates.format(buy.submitdate,'yyyy-MM-dd HH:mm:ss')}
"></td>
<td th:text="${buy.rojectname}"></td>
<td th:text="${buy.submitunit}"></td>
<td th:if="${buy.enableqqkzj} eq '1' ">是</td>
<td th:if="${buy.enableqqkzj} eq '0' ">否</td>
<td th:if="${buy.state} eq '0'">草稿</td>
<td th:if="${buy.state} eq '1'">待审核</td>
<td th:if="${buy.state} eq '2'">待填报控制价</td>
<td th:if="${buy.state} eq '3'">待结算</td>
<td th:if="${buy.state} eq '4'">已完成</td>
<td th:if="${buy.state} eq '5'">已终止</td>
</tr>
</tbody>
</table>
</div>
<!--并状态-->
<div class="b_center_box">
<div id="chart_1" class="echart" style="width: 100%; height: 3.6rem; "></div>
</div>
<!--最后-->
<div class="b_right_box">
<div id="chart_4" style="position: relative;height:3.6rem;overflow: hidden; " ></div>
</div>
</main>
</div>
<script src="/shujupingtai/js/jquery-2.2.1.min.js"></script>
<script src="/shujupingtai/js/rem.js"></script>
<script src="/shujupingtai/js/echarts.min.js"></script>
<script src="/shujupingtai/js/erlians.js"></script>
<!--<script src="/shujupingtai/js/index.js"></script>-->
<script>
$(function () {
echart_1();
echart_2();
echart_3();
echart_4();
linyiChart();
//饼状图
function echart_1() {
var dangernum=[[${totle_js_sj}]];
var Greennum=[[${totle_js_ss}]];
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('chart_1'));
option = {
title: {
text: [[${year}]]+'年结算报审金额与审减金额比例',
top: 35,
left: 20,
textStyle: {
fontSize: 18,
color: '#fff'
}
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
series: [{
name: '单位:万元',
type: 'pie',
radius: '65%',
center: ['50%', '50%'],
color: ['#2ca3fd', '#d9780b'],
label: {
normal: {
formatter: '{b}\n{d}%'
},
},
grid:{
left:'8%',
right:'0',
bottom:'1%',
containLabel:true
},
data: [{
value: dangernum,
name: '审减金额'
},
{
value: Greennum,
name: '报审金额',
selected: true
}
]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
//柱状图
function echart_2() {
var kzj=[[${array_kzj}]]
var js=[[${array_js}]]
console.log("大数据柱状图——控制价:"+kzj);
console.log("大数据柱状图--结算:"+js);
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('chart_2'));
option = {
title: {
text: [[${year}]]+'年控制价和结算审定金额',
textStyle: {
fontSize: 18,
color: '#fff'
}
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['控制价', '结算审定金额']
},
toolbox: {
show: true,
feature: {
dataView: { show: true, readOnly: true },
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
saveAsImage: { show: true }
}
},
calculable: true,
xAxis: [
{
type: 'category',
// prettier-ignore
data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
axisLabel:{
show: true,
textStyle: {
color: '#fff'
}
}
}
],
yAxis: [
{
type: 'value',
axisLabel:{
show: true,
formatter:'{value}万元',
textStyle: {
color: '#fff'
}
}
,
show:true
}
],
series: [
{
name: '控制价',
type: 'bar',
color: '#2ca3fd',
data: /*[
2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
]*/kzj,
markPoint: {
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
markLine: {
data: [{ type: 'average', name: 'Avg' }]
}
},
{
name: '结算审定金额',
type: 'bar',
color: '#d9780b',
data: /*[
2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
]*/js,
markPoint: {
data: [
{ name: 'Max',type: 'max'},
{ name: 'Min', type: 'min' }
]
},
markLine: {
data: [{ type: 'average', name: 'Avg' }]
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
function linyiChart() {
var linyiMapChart = echarts.init(document.getElementById('linyiMap'))
echarts.registerMap('linyi', linyiMap, {})
//echarts提供的方法echarts.registerMap(名称,地图数据,其他配置)
option = {
series: [
{
type: 'map',
mapType: 'linyi',//名称需要echarts.registerMap('linyi',linyiMap,{})中的名称一致
label: { show: true }, //显示文字
roam: true,
data: [],
},
],
}
linyiMapChart.setOption(option)
window.addEventListener('resize', function () {
linyiMapChart.resize()
})
}
//地图
function echart_3() {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('chart_3'));
function showProvince() {
var geoCoordMap = {
'二连浩特市': [111.94300677940726,
43.63998921077686],
/* '柳州': [109.412578,24.354875],
'梧州': [111.323462,23.478238],
'南宁': [108.359656,22.81328],
'北海': [109.171374,21.477419],
'崇左': [107.347374,22.377503]*/
};
var data = [{
name: '二连浩特市',
value: 100
}/*,
{
name: '柳州',
value: 100
},
{
name: '梧州',
value: 100
},
{
name: '北海',
value: 100
},
{
name: '崇左',
value: 100
}*/
];
var max = 480,
min = 9; // todo
var maxSize4Pin = 100,
minSize4Pin = 20;
var convertData = function (data) {
var res = [];
for (var i = 0; i < data.length; i++) {
var geoCoord = geoCoordMap[data[i].name];
if (geoCoord) {
res.push({
name: data[i].name,
value: geoCoord.concat(data[i].value)
});
}
}
return res;
};
myChart.setOption(option = {
title: {
text: '二连浩特市',
subtext: '',
x: 'center',
textStyle: {
color: '#FFF'
},
left: '6%',
top: '10%'
},
legend: {
orient: 'vertical',
y: 'bottom',
x: 'right',
data: ['pm2.5'],
textStyle: {
color: '#fff'
}
},
visualMap: {
show: false,
min: 0,
max: 480,
left: 'left',
top: 'bottom',
text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
seriesIndex: [1],
inRange: {}
},
geo: {
show: true,
map: 'guangxi',
mapType: 'guangxi',
label: {
normal: {},
//鼠标移入后查看效果
emphasis: {
textStyle: {
color: '#fff'
}
}
},
//鼠标缩放和平移
roam: true,
itemStyle: {
normal: {
// color: '#ddd',
borderColor: 'rgba(147, 235, 248, 1)',
borderWidth: 1,
areaColor: {
type: 'radial',
x: 0.5,
y: 0.5,
r: 0.5,
colorStops: [{
offset: 0,
color: 'rgba(175,238,238, 0)' // 0% 处的颜色
}, {
offset: 1,
color: 'rgba( 47,79,79, .1)' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
},
shadowColor: 'rgba(128, 217, 248, 1)',
shadowOffsetX: -2,
shadowOffsetY: 2,
shadowBlur: 10
},
emphasis: {
areaColor: '#389BB7',
borderWidth: 0
}
}
},
series: [{
name: 'light',
type: 'map',
coordinateSystem: 'geo',
data: convertData(data),
itemStyle: {
normal: {
color: '#F4E925'
}
}
},
{
name: '点',
type: 'scatter',
coordinateSystem: 'geo',
symbol: 'pin',
symbolSize: function (val) {
var a = (maxSize4Pin - minSize4Pin) / (max - min);
var b = minSize4Pin - a * min;
b = maxSize4Pin - a * max;
return a * val[2] + b;
},
label: {
normal: {
// show: true,
// textStyle: {
// color: '#fff',
// fontSize: 9,
// }
}
},
itemStyle: {
normal: {
color: '#F62157', //标志颜色
}
},
zlevel: 6,
data: convertData(data),
},
{
name: 'light',
type: 'map',
mapType: 'hunan',
geoIndex: 0,
aspectScale: 0.75, //长宽比
showLegendSymbol: false, // 存在legend时显示
label: {
normal: {
show: false
},
emphasis: {
show: false,
textStyle: {
color: '#fff'
}
}
},
roam: true,
itemStyle: {
normal: {
areaColor: '#031525',
borderColor: '#FFFFFF',
},
emphasis: {
areaColor: '#2B91B7'
}
},
animation: false,
data: data
},
{
name: ' ',
type: 'effectScatter',
coordinateSystem: 'geo',
data: convertData(data.sort(function (a, b) {
return b.value - a.value;
}).slice(0, 5)),
symbolSize: function (val) {
return val[2] / 10;
},
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: true
}
},
itemStyle: {
normal: {
color: '#05C3F9',
shadowBlur: 10,
shadowColor: '#05C3F9'
}
},
zlevel: 1
},
]
});
}
showProvince();
// 使用刚指定的配置项和数据显示图表。
// myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
//马力图
function echart_4() {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('chart_4'));
var data = [[${totle_js_sjl}]];
console.log("大数据审减率:"+data);
var myColor = ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'];
option = {
title: {
text: [[${year}]]+'年审减率',
textStyle: {
fontSize: 18,
color: '#fff'
}
},
series: [
{
type: 'gauge',
axisLine: {
lineStyle: {
width: 15,
color: [
[0.3, '#67e0e3'],
[0.7, '#37a2da'],
[1, '#fd666d']
]
}
},
pointer: {
itemStyle: {
color: 'auto'
}
},
axisTick: {
distance: -30,
length: 8,
lineStyle: {
color: '#fff',
width: 2
}
},
splitLine: {
distance: -30,
length: 15,
lineStyle: {
color: '#fff',
width: 4
}
},
axisLabel: {
color: '#inherit',
distance: 10,
fontSize: 12
},
detail: {
valueAnimation: true,
formatter: '审减率{value}%',
color: '#67e0e3',
fontSize: 12
},
data: [
{
value: data
}
]
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
// window.addEventListener("resize", function () {
// myChart.resize();
// });
}
});
</script>
</body>
</html>
报表平台(查询生成word文档)
因内网系统无连接外网,连接外网可对接第三方"帆软平台"进行生成文档 显示
前端代码
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('报表平台')" />
<th:block th:include="include :: bootstrap-fileinput-css" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>开始日期:</label>
<input type="text" name="strt_submitdate" id="laydate-startTime" placeholder="请选择开始日期yyyy-MM-dd"/>
</li>
<li>
<label>截至日期:</label>
<input type="text" name="end_submitdate" id="laydate-endTime" placeholder="请选择截至日期yyyy-MM-dd"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="reportShreach()"><i class="fa fa-search"></i> 报表查询</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-primary" onclick="reportExport()">
<i class="fa fa-file-word-o"></i></i>
报告导出
</a>
<a class="btn btn-info" onclick="mingxiExport()">
<i class="fa fa-file-excel-o"></i>
明细导出[核对]
</a>
<input id="export" type="hidden">
<input id="mingxi" type="hidden">
</div>
</div>
<!-- <div class="row">
https://view.xdocin.com/view?src=你的文档地址
<a href=" https://view.xdocin.com/view?src=" target="_blank" rel="nofollow"></a>
</div>-->
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/ajax/libs/layui/layui.min.js?v=2.7.5}"></script>
<script src="/viewerjs/viewer.min.js"></script>
<script th:inline="javascript">
var prefixda = ctx + "business/DangAn"
//页面加载函数
$(function() {
<!-- laydate示例 -->
//开始时间
layui.use('laydate', function(){
var laydate = layui.laydate;
var startDate = laydate.render({
elem: '#laydate-startTime',
max: $('#laydate-endTime').val(),
theme: 'molv',
trigger: 'click',
done: function(value, date) {
// 结束时间大于开始时间
if (value !== '') {
endDate.config.min.year = date.year;
endDate.config.min.month = date.month - 1;
endDate.config.min.date = date.date;
} else {
endDate.config.min.year = '';
endDate.config.min.month = '';
endDate.config.min.date = '';
}
}
});
// 结束
var endDate = laydate.render({
elem: '#laydate-endTime',
min: $('#laydate-startTime').val(),
theme: 'molv',
trigger: 'click',
done: function(value, date) {
// 开始时间小于结束时间
if (value !== '') {
startDate.config.max.year = date.year;
startDate.config.max.month = date.month - 1;
startDate.config.max.date = date.date;
} else {
startDate.config.max.year = '';
startDate.config.max.month = '';
startDate.config.max.date = '';
}
}
});
});
})
//报表导出
function reportExport(){
var filepath=$('#export').val();
//window.location.href = "/ImportTemplate/【评审项目】导入数据模板.xlsx";
window.location.href = filepath;
$.modal.msgSuccess("总结报告下载成功!",5000)
}
//明细导出
function mingxiExport(){
var filepath=$('#mingxi').val();
//window.location.href = "/ImportTemplate/【评审项目】导入数据模板.xlsx";
window.location.href = filepath;
$.modal.msgSuccess("明细表下载成功!",5000)
}
//文件预览
function ciew_file(){
// 获取要预览的 Word 文档的 URL
// let wordDocUrl = 'your_word_doc_url';
var filepath=$('#export').val();
console.log("开始预览");
console.log(filepath);
var viewer = new Viewer(document.getElementById('preview'), {
url: filepath,
// 其他配置选项...
});
// 初始化 Viewer.js
/* Viewer.init({
container: '#preview', // 预览容器的 ID
url: filepath // Word 文档的 URL
});*/
}
// 报表查询
function reportShreach(){
let start = $('input[name="strt_submitdate"]').val();
let end = $('input[name="end_submitdate"]').val();
if(start.length==0){
$.modal.alertError("请选择开始时间!")
return
}
if(end.length==0){
$.modal.alertError("请选择结束时间!")
return
}
$.modal.loading("正在查询数据,请稍候...");
$.ajax({
type : "POST",
url : prefixda + "/reportExport",
data : {
"submitdate": start,
"end_submitdate": end,
},
async : false,
error : function(request) {
console.log("填报返回结果错误:"+request)
$.modal.alertError("系统错误");
},
success : function(result) {
if (result.code == web_status.SUCCESS) {
console.log("成功:")
console.log(result)
// window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
//文件预览
//word url
var hddata=result.data
console.log(hddata)
console.log(hddata.wordurl)
console.log(hddata.mingxi)
//$('#export').val(result.data.'wordurl');
$('#export').val(hddata.wordurl);
$('#mingxi').val(hddata.mingxi);
ciew_file();
$.modal.msgSuccess(result.msg,5000)
//window.location.href = "/ImportTemplate/【评审项目】导入数据模板.xlsx";
} else if (result.code == web_status.WARNING) {
$.modal.alertWarning(result.msg)
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
}
});
}
</script>
</body>
</html>
后端代码
/**
* 跳转评审项目报表平台页面
*/
@GetMapping("/reportExport_view")
public String reportExport_view()
{
log.info("[跳转报表平台页面]");
return "czps/reportExport/repoetExport";
}
/**
* 评审项目报表导出
*/
@PostMapping("/reportExport")
@ResponseBody
public AjaxResult reportExport(@RequestParam Map<String, Object> map)
{
List<BusinessProject> businessProjectslist=null;
try {
log.info("[评审项目报表导出][入参数据:]"+map.toString());
//获取参数,根据时间范围查询评审项目
String start = map.get("submitdate").toString();
String end = map.get("end_submitdate").toString();
if(StringUtils.isBlank(start) || StringUtils.isBlank(end)){
throw new Exception("[评审项目报表导出][入参为空]"+map);
}
//map.put("state",4);
List<BusinessProject> businessProjects = businessProjectService.SreachBusinessProjectListByreport(map);
log.info("[评审项目报表导出][查询数据:]"+businessProjects.toString());
//总项目数
int size = businessProjects.size();
map.put("size",size);
LinkedHashMap<String, Double> kzj = new LinkedHashMap<>();
//计算控制价项目
for (BusinessProject businessProject : businessProjects) {
if( businessProject.getCheckprice()==null){
break;
}
if(businessProject.getCheckprice()==0.0){
break;
}
kzj.put(businessProject.getRojectname(),businessProject.getCheckprice());
}
log.info("[评审项目报表导出][控制价map数据:]"+kzj.toString());
//控制价个数
map.put("kzj_size",kzj.size());
log.info("[评审项目报表导出][控制价项目个数:]"+kzj.size());
//控制价
double totle_kzj=0.00;
for (Map.Entry<String, Double> entry : kzj.entrySet()) {
BigDecimal bigDecimal = new BigDecimal(entry.getValue());
BigDecimal bigDecimal2 = new BigDecimal(totle_kzj);
BigDecimal add = bigDecimal.add(bigDecimal2);
totle_kzj = add.doubleValue();
}
BigDecimal totle_kzj_bd = new BigDecimal(totle_kzj);
String v = totle_kzj_bd.setScale(4, BigDecimal.ROUND_HALF_UP).toString();
log.info("[评审项目报表导出][控制价项目总价double:]"+totle_kzj);
log.info("[评审项目报表导出][控制价项目总价db:]"+v);
map.put("kzj_totle",v);
//计算结算价项目
LinkedHashMap<String, ReportExportDTO> js = new LinkedHashMap<>();
for (BusinessProject businessProject : businessProjects) {
if( businessProject.getReportmoney()==null || businessProject.getAuthorizedmoney()==null){
break;
}
if(businessProject.getReportmoney()==0.0 || businessProject.getAuthorizedmoney()==0.0){
break;
}
ReportExportDTO reportExportDTO = new ReportExportDTO();
reportExportDTO.setAuthorizedmoney(businessProject.getAuthorizedmoney());
reportExportDTO.setReportmoney(businessProject.getReportmoney());
reportExportDTO.setReductionrate(businessProject.getReductionrate());
reportExportDTO.setReducedmoney(businessProject.getReducedmoney());
//
js.put(businessProject.getRojectname(),reportExportDTO);
}
//结算项目数
map.put("js_size",js.size());
log.info("[评审项目报表导出][结算项目个数:]"+kzj.size());
//送审金额_总 reportmoney
//审定金额_总 authorizedmoney
//审减金额_总 reducedmoney
Double reportmoney_tole =0.0;
Double authorizedmoney_tole =0.0;
Double reducedmoney_tole =0.0;
for (Map.Entry<String, ReportExportDTO> entry : js.entrySet()) {
//送审
BigDecimal bigDecimal1 = new BigDecimal(entry.getValue().getReportmoney());
BigDecimal bigDecimal3 = new BigDecimal(reportmoney_tole);
BigDecimal add1 = bigDecimal1.add(bigDecimal3);
reportmoney_tole=add1.doubleValue();
//审定
BigDecimal bigDecimal2 = new BigDecimal(entry.getValue().getAuthorizedmoney());
BigDecimal bigDecimal4 = new BigDecimal(authorizedmoney_tole);
BigDecimal add2 = bigDecimal2.add(bigDecimal4);
authorizedmoney_tole=add2.doubleValue();
//减少
BigDecimal bigDecimal5 = new BigDecimal(entry.getValue().getReducedmoney());
BigDecimal bigDecimal6 = new BigDecimal(reducedmoney_tole);
BigDecimal add3 = bigDecimal5.add(bigDecimal6);
reducedmoney_tole=add3.doubleValue();
}
double totle_js_ss = new BigDecimal(reportmoney_tole).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
map.put("totle_js_ss",totle_js_ss);
log.info("[评审项目报表导出][结算送审金额总价:]"+totle_js_ss);
double totle_js_sd = new BigDecimal(authorizedmoney_tole).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
map.put("totle_js_sd",totle_js_sd);
log.info("[评审项目报表导出][结算审定金额总价:]"+totle_js_sd);
double totle_js_sj = new BigDecimal(reducedmoney_tole).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
map.put("totle_js_sj",totle_js_sj);
log.info("[评审项目报表导出][结算审减金额总价:]"+totle_js_sj);
//审减率
if(reportmoney_tole==0.0){
map.put("totle_js_sjl",0.0);
log.info("[评审项目报表导出][送审金额为0,结算审减率为0]");
}else {
BigDecimal sj = new BigDecimal(reducedmoney_tole);
BigDecimal ss = new BigDecimal(reportmoney_tole);
BigDecimal bigDecimal = new BigDecimal(100);
BigDecimal divide = sj.divide(ss,2, BigDecimal.ROUND_HALF_UP)
.multiply(bigDecimal)
.setScale(2, BigDecimal.ROUND_HALF_UP);
map.put("totle_js_sjl",divide.toString());
log.info("[评审项目报表导出][结算审减率:]"+divide.toString());
}
//开始生成报表
String localPath = RuoYiConfig.getProfile()+"/word";
log.info("[评审项目报表导出][导出路径]"+localPath);
// 创建 File 对象
File file = new File(localPath);
// 判断路径是否存在
if (file.exists()) {
log.info("文件路径存在");
} else {
// 如果路径不存在,则创建该路径
file.mkdirs();
log.info("文件路径不存在,已创建");
}
// 插件列表,可以去官网查看,有列循环,还有行循环,这里是行循环实例
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
//这里可以指定一个config类,用来指定一些规则,也可以改变模板中{{}}的这种格式
Configure config = Configure.builder()
.bind("list", policy).build();
XWPFTemplate compile = XWPFTemplate.compile( new ClassPathResource("templates/doc/czps/二连浩特市财政投资评审中心工作报告.docx").getFile(),config).render(map);
//设置输出文件名字
String outFilename ="/out_二连浩特市财政绩效评审服务中心服务报告_" + System.currentTimeMillis() + ".docx";
compile.writeToFile(localPath+outFilename);
log.info("[评审项目报表导出][输出成功]"+localPath+outFilename);
//word 下载地址
String url="http://localhost/profile/word"+outFilename;
//明细下载
ExcelUtil<BusinessProject> util = new ExcelUtil<BusinessProject>(BusinessProject.class);
AjaxResult mingxi = util.exportExcel(businessProjects, "总结报告数据明细");
String filename = mingxi.get("msg").toString();
log.info("[评审项目报表导出][明细数据filename]"+filename);
if(StringUtils.isBlank(filename)){
throw new Exception("[评审项目报表导出][明细数据filename为空!]");
}
String mingxiurl = "http://localhost/profile/download/"+filename;
//返回结果
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("wordurl",url);
stringStringHashMap.put("mingxi",mingxiurl);
return AjaxResult.success("报告生成成功,可下载明细进行核对!",stringStringHashMap);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("生成失败!"+e.getMessage());
}
}
导入解析excel存入数据库(电子档案馆)
前端代码
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('【请填写功能名称】列表')" />
<th:block th:include="include :: bootstrap-fileinput-css" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>项目名称:</label>
<input type="text" name="rojectname"/>
</li>
<li>
<label>送审单位:</label>
<input type="text" name="submitunit"/>
</li>
<li>
<label>联系人:</label>
<input type="text" name="linkman"/>
</li>
<li>
<label>手机:</label>
<input type="text" name="phone"/>
</li>
<li>
<label>开始日期:</label>
<input type="text" name="submitdate" id="laydate-startTime" placeholder="请选择开始日期yyyy-MM-dd"/>
</li>
<li>
<label>截至日期:</label>
<input type="text" name="end_submitdate" id="laydate-endTime" placeholder="请选择截至日期yyyy-MM-dd"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-warning" onclick="checkItem()" >
<i class="fa fa-download"></i> 导出excel
</a>
<!-- <a class="btn btn-primary" onclick="reportExport()">
<i class="fa fa-cloud-upload"></i>
报告导出
</a>-->
<a class="btn btn-primary" onclick="clickbtn()">
<i class="fa fa-cloud-upload"></i>
表格导入档案馆
</a>
<input id="filePath" onchange="uploadFile(this.files)" style="display: none;" name="filePath" class="btn btn-primary form-control" type="file">
<a onclick="mobanxiazai()" >
<i class="fa fa-download"></i> 导入模版下载
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/ajax/libs/layui/layui.min.js?v=2.7.5}"></script>
<script th:inline="javascript">
/* var editFlag = [[${@permission.hasPermi('system:project:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:project:remove')}]];*/
var viewFlag = [[${@permission.hasPermi('system:project:view')}]];
var shenheFlag = [[${@permission.hasPermi('system:project:shenhe')}]];
var prefix = ctx + "business/project"
var prefixda = ctx + "business/DangAn"
//页面加载函数
$(function() {
var options = {
url: prefixda + "/list",
modalName: "【评审项目】",
columns: [{
checkbox: true
},
{
field: 'rojectid',
title: '项目编号',
visible: false
},
{
field: 'rojectname',
title: '项目名称'
},
{
field: 'submitunit',
title: '送审单位'
},
{
field: 'linkman',
title: '联系人'
},
{
field: 'phone',
title: '手机'
},
{
field: 'calls',
title: '电话',
visible: false
},
{
field: 'budgetmoney',
title: '概算金额',
visible: false
},
{
field: 'budgetengmoney',
title: '概算的工程费',
visible: false
},
{
field: 'budgetengothermoney',
title: '概算工程建设其他费',
visible: false
}, {
field: 'enableqqkzj',
title: '前期是否编制控制价',
visible: true,
formatter: function (value, row, index) {
if (row.enableqqkzj == '1') {
// return $.table.tooltip("是");
return '<span style="color: red">是</span>';
} else if (row.enableqqkzj == '0') {
// return $.table.tooltip("否");
return '<span >否</span>';
}
}
},
{
field: 'state',
title: '状态',
formatter: function (value, row, index) {
if (row.state == '0') {
return $.table.tooltip("草稿");
} else if (row.state == '1') {
return $.table.tooltip("待审核");
} else if (row.state == '2') {
return $.table.tooltip("待控制价填报");
} else if (row.state == '3') {
return $.table.tooltip("待结算");
} else if (row.state == '4') {
return $.table.tooltip("已完成");
} else if (row.state == '5') {
return $.table.tooltip("已终止");
}
/* actions.push("<a class='btn btn-success btn-xs " + viewFlag + "'href='javascript:void(0)' οnclick='viewupload(\""+
row.sanzhongyida +"\",\"三重一大及采购手续\")'><i class='fa fa-adn'></i>查看</a> ");
return actions.join('');*/
}
},
{
field: 'budgetreadymoney',
title: '概算预备费',
visible: false
},
{
field: 'estimatemoney',
title: '估算金额',
visible: false
},
{
field: 'estimateengmoney',
title: '估算工程费用',
visible: false
},
{
field: 'estimateengothermoney',
title: '估算工程建设其他费',
visible: false
},
{
field: 'estimatereadymoney',
title: '估算预备费',
visible: false
},
{
field: 'checkprice',
title: '控制价',
visible: false
},
{
field: 'authorizedmoney',
title: '审定金额',
visible: false
},
{
field: 'reportmoney',
title: '报审金额',
visible: false
},
{
field: 'reductionrate',
title: '审减率',
visible: false
},
{
field: 'reducedmoney',
title: '审减金额',
visible: false
},
{
field: 'submitdate',
title: '提交日期'
},
{
field: 'accessorypf',
title: '附件-发改委立项批复或领导批示',
visible: false
},
{
field: 'accessorykxxbg',
title: '附件-可行性研究报告',
visible: false
},
{
field: 'accessorycbsj',
title: '附件-初步设计',
visible: false
},
{
field: 'accessorycbsjpf',
title: '附件-发改委初步设计批复',
visible: false
},
{
field: 'accessorywth',
title: '附件-委托函',
visible: false
},
{
field: 'accessorypsxmb',
title: '附件-评审项目报审表(前期)',
visible: false
},
{
field: 'electronicdrawing',
title: '附件-图纸及电子版图纸',
visible: false
},
{
field: 'otheraccessory',
title: '其他附件',
visible: false
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
//已完成 档案查看
actions.push('<a class="btn btn-success btn-xs ' + viewFlag + '" href="javascript:void(0)" οnclick="view_dangan(\'' + row.rojectid + '\')"><i class="fa fa-edit"></i>档案查看</a> ');
actions.push('<a class="btn btn-primary btn-xs ' + shenheFlag + '" href="javascript:void(0)" οnclick="buchongziliao(\'' + row.rojectid + '\')"><i class="fa fa-edit"></i>补充资料</a> ');
return actions.join('');
}
}]
};
$.table.init(options);
<!-- laydate示例 -->
//开始时间
layui.use('laydate', function(){
var laydate = layui.laydate;
var startDate = laydate.render({
elem: '#laydate-startTime',
max: $('#laydate-endTime').val(),
theme: 'molv',
trigger: 'click',
done: function(value, date) {
// 结束时间大于开始时间
if (value !== '') {
endDate.config.min.year = date.year;
endDate.config.min.month = date.month - 1;
endDate.config.min.date = date.date;
} else {
endDate.config.min.year = '';
endDate.config.min.month = '';
endDate.config.min.date = '';
}
}
});
// 结束
var endDate = laydate.render({
elem: '#laydate-endTime',
min: $('#laydate-startTime').val(),
theme: 'molv',
trigger: 'click',
done: function(value, date) {
// 开始时间小于结束时间
if (value !== '') {
startDate.config.max.year = date.year;
startDate.config.max.month = date.month - 1;
startDate.config.max.date = date.date;
} else {
startDate.config.max.year = '';
startDate.config.max.month = '';
startDate.config.max.date = '';
}
}
});
});
})
// 导出数据到表格
function checkItem(){
var arrays = $.table.selectColumns("rojectid");
if (arrays.toString().length==0){
$.modal.alertError("请勾选表格数据!");
return;
}
$.modal.loading("正在导出数据,请稍候...");
$.ajax({
type : "POST",
url : ctx + "business/project/export",
data : {
"arrays_ids": arrays.toString(),
},
async : false,
error : function(request) {
console.log("填报返回结果错误:"+request)
$.modal.alertError("系统错误");
},
success : function(result) {
if (result.code == web_status.SUCCESS) {
console.log("成功:")
console.log(result)
window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
} else if (result.code == web_status.WARNING) {
$.modal.alertWarning(result.msg)
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
}
});
}
//点击
function clickbtn() {
file = document.getElementById("filePath");
if(file){
$('#filePath').click();
}
}
//导入数据
function uploadFile() {
var formData = new FormData();
if ($('#filePath')[0].files[0] == null) {
$.modal.alertWarning("请先选择文件路径");
return false;
}
// let file = $("input[name='filePath']").val();
let file = $("#filePath").val();
console.log(file)
// console.log(file2)
if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))) {
$.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
return false;
}
formData.append('filename', file);
formData.append('file', $('#filePath')[0].files[0]);
$.ajax({
url: prefixda + "/uploadFileSave",
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function (result) {
if (result.code == web_status.SUCCESS) {
$.modal.closeAll();
$.modal.alertSuccess(result.msg);
$.table.refresh();
} else if (result.code == web_status.WARNING) {
$.modal.enable();
$.modal.alertWarning(result.msg)
} else {
$.modal.enable();
$.modal.alertError(result.msg);
}
}});
}
//模板下载
function mobanxiazai(){
$.modal.msgSuccess("模板下载成功!",5000)
window.location.href = "/ImportTemplate/【评审项目】导入数据模板.xlsx";
}
//补充资料
function buchongziliao(projectid){
$.modal.open('补充资料', prefix + "/buchongziliao/"+projectid);
}
//view_dangan 档案查看 状态为已完成
function view_dangan(projectid){
$.modal.openTab('档案查看', prefix + "/view_dangan/"+projectid);
}
</script>
</body>
</html>
后端代码
/**
* 跳转评审档案页面
*/
@GetMapping("/view")
public String jsproject()
{
return "czps/danganguan/da_project";
}
/**
* 导入表格解析
*/
@PostMapping("/uploadFileSave")
@ResponseBody
@Transactional
public AjaxResult uploadFileSave(@RequestParam("file") MultipartFile file,@RequestParam("filename") String filename)
{
List<BusinessProject> list =new ArrayList<>();
int success =0;
try {
log.info("【导入表格解析】入参file:"+file);
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
log.info("【导入表格解析】新文件的名称"+fileName);
log.info("【导入表格解析】新文件的路径"+filePath);
//开始解析
if(StringUtils.isBlank(fileName)){
return error("文件上传错误!");
}
//上传到本地服务器地址为:
int i = fileName.lastIndexOf("upload/");
String substring = fileName.substring(i + 6);
filePath=filePath+substring;
log.info("【导入表格解析】新文件的路径"+filePath);
InputStream is = new FileInputStream(new File(filePath));
//开始解析
ExcelUtil<BusinessProject> util = new ExcelUtil<BusinessProject>(BusinessProject.class);
//3就是前三行都是title 从第四行开始解析
list = util.importExcel(is,3);
log.info("[导入表格解析]解析之后的集合:"+list);
if(list.size()==0){
throw new RuntimeException("[导入档案馆][导入数据集合为空,请检查模版是否正确][list:]"+list.toString());
}
for (BusinessProject businessProject : list) {
businessProject.setState("4");
businessProject.setEnableqqkzj("0");
businessProject.setRojectid(IdUtils.fastSimpleUUID());
if(businessProject.getAuthorizedmoney()==null ){
businessProject.setAuthorizedmoney(0.0);
}
if(businessProject.getReportmoney()==null){
businessProject.setReportmoney(0.0);
}
if(businessProject.getAuthorizedmoney()>businessProject.getReportmoney()){
throw new RuntimeException("[导入档案馆]["+businessProject.getRojectname()+"][审定金额大于报审金额!无法填报!]");
}
//设置审减金额
Double shenjian=businessProject.getReportmoney()-businessProject.getAuthorizedmoney();
businessProject.setReducedmoney(shenjian);
Double shenjianlv=(shenjian/businessProject.getReportmoney())*100;
if(Double.isNaN(shenjianlv)){
shenjianlv=0.0;
}
BigDecimal b = new BigDecimal(shenjianlv);
Double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
//审减率
businessProject.setReductionrate(f1.toString()+"%");
if(StringUtils.isBlank(businessProject.getSubmitdate().toString())){
throw new RuntimeException("[导入档案馆]["+businessProject.getRojectname()+"][项目提交日期为空!]");
}
int i1 = businessProjectService.insertBusinessProject(businessProject);
if(i1>0){
}else {
throw new RuntimeException("[导入档案馆]["+businessProject.getRojectname()+"][保存数据库错误!]");
}
success=success+1;
}
}catch (Exception e) {
throw new RuntimeException("[(注意表头必须在第四行)导入档案馆表格出现错误:]"+e);
}
return success("已导入档案馆,总共:"+list.size()+",成功导入:"+success+".");
}
前端input显示科学计数法(解决方案)
前端代码
//只需将其转成字符串即可
var budgetmoney = $("input[name='budgetmoney']").val();
var budgetmoney_str=parseFloat(budgetmoney).toString();
$("input[name='budgetmoney']").val(budgetmoney_str);
Thymeleaf案例和实际演示
后端跳转页面携带参数
public string 方法名(ModelMap mmap){
//参数名 参数值
mmap.put("quanxian",lrg_list);
}
1.根据实体类展示各属性值
在form表单中加入
th:object="${businessProject}"
各表项加入
th:field="*{submitunit}"
2.遍历list 页面展示
th:each="buy:${pingshenlist}"
buy是遍历的单个实体类, 右侧list参数名
3.时间格式化
${#dates.format(buy.submitdate,'yyyy-MM-dd HH:mm:ss')}
4.if的使用
<td th:if="${buy.state} eq '0'">草稿</td>
如果等于就展示该元素
5.前端js项获取值
[[${参数值}]] 前端页面任何地方可随时获取.