首页预警代码提交

This commit is contained in:
liang.chao 2026-01-30 17:42:57 +08:00
parent 417cb7e497
commit 7f4d00ca00
3 changed files with 575 additions and 438 deletions

View File

@ -11,7 +11,6 @@
<script src="${bonuspath}/static/js/layui/layui.js"></script>
<meta charset="UTF-8">
<title>预警信息</title>
<%-- <link href="https://www.layuicdn.com/layui-v2.6.8/css/layui.css" rel="stylesheet">--%>
<style>
.warning-container {
@ -90,7 +89,7 @@
</div>
<!-- 库存不足 -->
<div class="warning-content active" id="stock">
<div class="warning-content" id="stock">
<div class="search-box">
<div class="layui-form">
<div class="layui-inline">
@ -105,6 +104,13 @@
</div>
</div>
</div>
<script type="text/html" id="stockToolbar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="export">
<i class="layui-icon layui-icon-export"></i> 导出
</button>
</div>
</script>
<table id="stockTable" lay-filter="stockTable"></table>
</div>
@ -212,9 +218,9 @@
height: 'full-100',
method: 'post',
page: true,
limit: 50, // 每页显示的条数
limits: [10, 20, 50, 100], // 每页条数的选择项
loading: true, // 显示加载条
limit: 50,
limits: [10, 20, 50, 100],
loading: true,
cols: [[
{type: 'numbers', title: '序号', width: '5%'},
{field: 'projectName', title: '工程名称', width: '18%'},
@ -244,19 +250,17 @@
parseData: function(res) {
var data = [];
if(res.obj && Array.isArray(res.obj)) {
// 根据当前页码和每页条数计算起始索引
var curr = this.page.curr || 1;
var limit = this.page.limit || 50;
var start = (curr - 1) * limit;
var end = start + limit;
// 截取对应页的数据
data = res.obj.slice(start, end);
}
return {
"code": 200,
"msg": res.resMsg,
"count": res.obj ? res.obj.length : 0, // 总数据条数
"data": data // 当前页数据
"count": res.obj ? res.obj.length : 0,
"data": data
};
}
});
@ -270,9 +274,10 @@
height: 'full-100',
method: 'post',
page: true,
limit: 20, // 每页显示的条数
limits: [10, 20, 30, 50], // 每页条数的选择项
loading: true, // 显示加载条
limit: 20,
limits: [10, 20, 30, 50],
loading: true,
toolbar: '#stockToolbar',
cols: [[
{type: 'numbers', title: '序号', width: '10%'},
{ title: '机具类别', width: '20%',templet:function(d) {
@ -289,22 +294,27 @@
parseData: function(res) {
var data = [];
if(res.obj && Array.isArray(res.obj)) {
// 根据当前页码和每页条数计算起始索引
var curr = this.page.curr || 1;
var limit = this.page.limit || 50;
var start = (curr - 1) * limit;
var end = start + limit;
// 截取对应页的数据
data = res.obj.slice(start, end);
}
return {
"code": 200,
"msg": res.resMsg,
"count": res.obj ? res.obj.length : 0, // 总数据条数
"data": data // 当前页数据
"count": res.obj ? res.obj.length : 0,
"data": data
};
}
});
// 监听工具栏事件
table.on('toolbar(stockTable)', function(obj){
if(obj.event === 'export'){
exportStockData();
}
});
}
// 初始化检验周期表格
@ -319,7 +329,7 @@
limits: [10, 20, 30, 50],
loading: true,
cols: [[
{type: 'numbers', title: '序号', width: '5%'}, // 序号
{type: 'numbers', title: '序号', width: '5%'},
{field: 'deviceType', title: '机具类别', width: '5%',templet:function(d) {
return d.isCount === '0' ? '设备' : '机具';
}},
@ -377,6 +387,47 @@
});
}
// 导出库存不足数据
function exportStockData() {
// 获取搜索条件
var maName = $('#stock input[name="maName"]').val();
var maType = $('#stock input[name="maType"]').val();
// 构建请求参数
var params = {
maName: maName || '',
maType: maType || ''
};
// 构建URL参数
var queryParams = [];
for(var key in params){
if(params[key]){
queryParams.push(key + '=' + encodeURIComponent(params[key]));
}
}
var url = '${bonuspath}/backstage/indexHomeDetails/exportStorageWarn';
if(queryParams.length > 0){
url += '?' + queryParams.join('&');
}
// 使用layer提示
layer.load(1);
// 创建隐藏的iframe下载文件
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = url;
document.body.appendChild(iframe);
// 移除iframe
setTimeout(function(){
document.body.removeChild(iframe);
layer.closeAll('loading');
}, 2000);
}
// 初始化长期占用表格
function initOccupyTable() {
table.render({
@ -389,7 +440,7 @@
limits: [10, 20, 30, 50],
loading: true,
cols: [[
{type: 'numbers', title: '序号', width: '7%'}, // 序号
{type: 'numbers', title: '序号', width: '7%'},
{field: 'deviceType', title: '机具类别', width: '8%',templet:function(d) {
return d.isCount === '0' ? '设备' : '机具';
}},

View File

@ -597,7 +597,7 @@
mt.`NAME` as maName,
mt.UNIT as maUnit,
mt.is_COUNT AS isCount,
mt.NUM as storageNum
CAST(mt.NUM AS SIGNED) AS storageNum
FROM
mm_type mt
LEFT JOIN mm_type mt2 on mt.PARENT_ID = mt2.ID
@ -641,33 +641,52 @@
<select id="getInUseWarn" parameterType="com.bonus.index.beans.IndexInuseWarnBean" resultType="com.bonus.index.beans.IndexInuseWarnBean">
SELECT
mt2.`NAME` as maType,
mt.`NAME` as maName,
mt.UNIT as maUnit,
COUNT( DISTINCT mm.ID) as inuseNum,
MIN(mtp.start_date) as outTime,
mt.IS_COUNT as isCount,
to_days(now()) -to_days(mtp.start_date) as days ,
wla.`CODE` as agreementCode,
bc.`NAME` as projectName,
bp.`NAME` as companyName
mt2.`NAME` AS maType,
mt.`NAME` AS maName,
mt.UNIT AS maUnit,
COUNT( DISTINCT mm.ID ) AS inuseNum,
MIN( filtered_mtp.start_date ) AS outTime,
mt.IS_COUNT AS isCount,
DATEDIFF(
NOW(),
MIN( filtered_mtp.start_date )) AS days,
wla.`CODE` AS agreementCode,
bp.`NAME` AS projectName,
bc.`NAME` AS companyName
FROM
ma_type_project_storage mtp
LEFT JOIN mm_machines mm on mtp.machine = mm.ID
LEFT JOIN mm_type mt on mm.TYPE = mt.ID
LEFT JOIN mm_type mt2 on mt.PARENT_ID = mt2.ID
LEFT JOIN wf_lease_agreement wla on mtp.agreement_id = wla.ID
LEFT JOIN bm_project bp on wla.PROJECT = bp.ID
LEFT JOIN bm_company bc on bp.COMPANY_ID = bc.ID
WHERE mm.BATCH_STATUS=6 and mtp.`status` =1
(
SELECT
ps.machine,
ps.agreement_id,
ps.start_date
FROM
ma_type_project_storage ps
INNER JOIN mm_machines mm ON ps.machine = mm.ID
WHERE
ps.`status` = 1
AND ps.`end_date` is null
AND mm.BATCH_STATUS = 6
AND DATEDIFF( NOW(), ps.start_date ) > 180
) AS filtered_mtp
INNER JOIN mm_machines mm ON filtered_mtp.machine = mm.ID
INNER JOIN mm_type mt ON mm.TYPE = mt.ID
LEFT JOIN mm_type mt2 ON mt.PARENT_ID = mt2.ID
LEFT JOIN wf_lease_agreement wla ON filtered_mtp.agreement_id = wla.ID
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc ON bp.COMPANY_ID = bc.ID
where 1=1
<if test="maType != null and maType != ''">
and mt2.`NAME` like concat('%', #{maType}, '%')
</if>
<if test="maName != null and maName != ''">
and mt.`NAME` like concat('%', #{maName}, '%')
</if>
GROUP BY mm.TYPE
HAVING days > 180
GROUP BY
mt.ID,
mt2.ID,
wla.ID,
bp.ID,
bc.ID
</select>
<select id="getTotalChangeWarn" parameterType="com.bonus.index.beans.IndexTotalWarnBean" resultType="com.bonus.index.beans.IndexTotalWarnBean">

View File

@ -1,7 +1,19 @@
package com.bonus.index.controller;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.bonus.ma.beans.pickDetailsBean;
import com.bonus.sys.*;
import com.bonus.sys.beans.UserBean;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@ -9,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bonus.exp.POIOutputHelper;
import com.bonus.index.beans.IndexCheckWarnBean;
import com.bonus.index.beans.IndexHomeCalendarBean;
import com.bonus.index.beans.IndexHomeDetailsBean;
@ -19,9 +32,6 @@ import com.bonus.index.beans.IndexStorageWarnBean;
import com.bonus.index.beans.IndexTodoWarnBean;
import com.bonus.index.beans.IndexTotalWarnBean;
import com.bonus.index.service.IndexHomeDetailsService;
import com.bonus.sys.AjaxRes;
import com.bonus.sys.BaseController;
import com.bonus.sys.GlobalConst;
@Controller
@RequestMapping("/backstage/indexHomeDetails/")
@ -235,6 +245,63 @@ public class IndexHomeDetailsController extends BaseController<IndexHomeDetailsB
}
return ar;
}
// 库存不足-导出
@RequestMapping(value = "exportStorageWarn", method = RequestMethod.GET)
public void export(HttpServletResponse response, IndexStorageWarnBean o) {
try {
List<IndexStorageWarnBean> list = service.getStorageWarn(o);
expOutExcel(response, list, "库存不足预警导出");
} catch (Exception e) {
logger.error(e.toString(), e);
}
}
private void expOutExcel(HttpServletResponse response, List<IndexStorageWarnBean> list, String filename)
throws Exception {
if (list != null) {
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
int size = list.size();
for (int i = 0; i < size; i++) {
IndexStorageWarnBean bean = list.get(i);
Map<String, Object> maps = outMaLeaseBeanToMap(i, bean);
results.add(maps);
}
List<String> headers = reportHeader();
HSSFWorkbook workbook = POIOutputHelper.excel(results, headers, filename);
OutputStream out = null;
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.addHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
response.setHeader("Pragma", "No-cache");
out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
}
}
private Map<String, Object> outMaLeaseBeanToMap(int i, IndexStorageWarnBean o) {
Map<String, Object> maps = new LinkedHashMap<String, Object>();
maps.put("id", i + 1);
maps.put("isCount", o.getIsCount().equals("0")?"设备":"机具");
maps.put("maType", o.getMaType());
maps.put("maName", o.getMaName());
maps.put("storageNum", o.getStorageNum());
maps.put("maUnit", o.getMaUnit());
return maps;
}
private List<String> reportHeader() {
ArrayList<String> list = new ArrayList<String>();
list.add("序号");
list.add("机具类别");
list.add("机具名称");
list.add("规格型号");
list.add("库存量");
list.add("单位");
return list;
}
// 检验周期
@RequestMapping(value = "getCheckWarn", method = RequestMethod.POST)