样品统计管理

This commit is contained in:
jjLv 2024-09-29 17:02:49 +08:00
parent 8fcc4280e0
commit 6ac56a4c8b
7 changed files with 667 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package com.bonus.aqgqj.basis.controller;
import com.bonus.aqgqj.annotation.DecryptAndVerify;
import com.bonus.aqgqj.annotation.LogAnnotation;
import com.bonus.aqgqj.basis.entity.dto.ToolsManageDto;
import com.bonus.aqgqj.basis.service.SampleAllManageService;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 样品统计管理
* @author hay
*/
@Api(tags = "样品统计管理")
@RestController
@RequestMapping("/sampleAll/")
public class SampleAllManageController {
private static final Logger log = LoggerFactory.getLogger("adminLogger");
@Autowired
private SampleAllManageService sampleAllManageService;
@PostMapping(value = "getList")
@DecryptAndVerify(decryptedClass = ToolsManageDto.class)
@LogAnnotation(operModul = "样品统计管理-样品统计管理", operation = "查询列表", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:sampleAll:query')" )
public ServerResponse listUsers(EncryptedReq<ToolsManageDto> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
try {
List<ToolsManageDto> list = sampleAllManageService.list(data.getData());
PageInfo<ToolsManageDto> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit());
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit());
}
}

View File

@ -0,0 +1,22 @@
package com.bonus.aqgqj.basis.dao;
import com.bonus.aqgqj.basis.entity.dto.ToolsManageDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author hay
*/
@Mapper
public interface SampleAllManageDao {
/**
* 查询列表
* @param bean
* @return
*/
List<ToolsManageDto> list(ToolsManageDto bean);
}

View File

@ -0,0 +1,19 @@
package com.bonus.aqgqj.basis.service;
import com.bonus.aqgqj.basis.entity.dto.ToolsManageDto;
import java.util.List;
/**
* 样品统计管理
* @author hay
*/
public interface SampleAllManageService {
/**
* 查询列表
* @param bean
* @return
*/
List<ToolsManageDto> list(ToolsManageDto bean);
}

View File

@ -0,0 +1,43 @@
package com.bonus.aqgqj.basis.service.impl;
import com.bonus.aqgqj.basis.dao.SampleAllManageDao;
import com.bonus.aqgqj.basis.dao.ToolsManageDao;
import com.bonus.aqgqj.basis.entity.dto.ToolsManageDto;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalVo;
import com.bonus.aqgqj.basis.service.SampleAllManageService;
import com.bonus.aqgqj.basis.service.ToolsManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @description 工器具个体管理
* @author hay
* @date 2024/7/20 16:10
*/
@Slf4j
@Service
public class SampleAllManageServiceImpl implements SampleAllManageService {
@Resource
private SampleAllManageDao sampleAllManageDao;
/**
* 查询列表
* @param bean
* @return
*/
@Override
public List<ToolsManageDto> list(ToolsManageDto bean) {
List<ToolsManageDto> list = new ArrayList<>();
list = sampleAllManageDao.list(bean);
return list;
}
}

View File

@ -0,0 +1,47 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.aqgqj.basis.dao.SampleAllManageDao">
<select id="list" resultType="com.bonus.aqgqj.basis.entity.dto.ToolsManageDto">
SELECT
ted.id,
tsd.dev_type_name as sampleTools,
ted.dev_code as devCode,
tsd.customer_code as customerCode,
tsd.dev_module as devModule,
tc.custom_name as customName,
tcs.custom_name as sampleDepartment,
ted.manufacture_date as manufactureDate,
COALESCE(te.exper_time,'') as experTime,
case ted.is_hg when 0 then '合格'
when 1 then '不合格'
end as experConclu,
te.next_exper_time as nextExperTime,
te.submit_location as submitLocation,
su.user_name as experUser
FROM
tb_exper_dev ted
LEFT JOIN tb_sample_device tsd on ted.dev_id=tsd.id and tsd.del_falg=0
LEFT JOIN tb_sample ts on ts.id=tsd.sample_id and ts.del_flag=0
LEFT JOIN tb_custom tc on tc.id=ts.custom_id and tc.del_flag=0
LEFT JOIN tb_custom tcs on tcs.id=ted.department_id and tcs.del_flag=0
LEFT JOIN tb_exper te on te.id=ted.exper_id
LEFT JOIN sys_user su on su.id=te.create_user and su.del_flag=0
WHERE
tsd.dev_type_name is not null
<if test="sampleTools != null and sampleTools != ''">
and tsd.dev_type_name like concat('%',#{sampleTools}, '%')
</if>
<if test="keyWord != null and keyWord != ''">
AND (
ted.dev_code like concat('%', #{keyWord}, '%') OR
tsd.customer_code like concat('%', #{keyWord}, '%') OR
tsd.dev_module like concat('%', #{keyWord}, '%') OR
tc.custom_name like concat('%', #{keyWord}, '%') OR
tcs.custom_name like concat('%', #{keyWord}, '%')
)
</if>
ORDER BY te.exper_time DESC
</select>
</mapper>

View File

@ -0,0 +1,363 @@
let form, layer, table, tableIns;
let pageNum = 1, limitSize = 10; // 默认第一页分页数量为10
let orgData,selectOrgId;
var modal = $('#myModal');
var span = $('.close');
var printButton = $('#PrintButton');
layui.use(['form', 'layer', 'table', 'laydate'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
layui.form.render();
pages(1, 10, 1);
getToolsSelected();
})
function getToolsSelected() {
let url = dataUrl + '/tools/all';
ajaxRequest(url, "POST", null, true, function () {
}, function (result) {
console.log(result)
if (result.code === 200) {
setSelectValue(result.data, 'sampleTools');
// return result.data
} else {
layer.alert(result.msg, {icon: 2})
}
}, function (xhr) {
error(xhr)
});
}
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
let url = dataUrl + "/sampleAll/getList"
ajaxRequest(url, "POST", params, true, function () {
}, function (result) {
console.log(result);
if (result.code === 200) {
if (result.data) {
initTable(result.data, result.limit, result.curr)
laypages(result.count, result.curr, result.limit)
}
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
}
}, function (xhr) {
error(xhr)
});
}
function laypages(total, page, limit) {
layui.use(['laypage'], function () {
let laypage = layui.laypage;
laypage.render({
elem: 'voi-page',
count: total,
curr: page,
limit: limit,
limits: [10, 20, 50, 100, 200, 500],
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
groups: 5,
jump: function (obj, first) {
if (!first) {
pageNum = obj.curr, limitSize = obj.limit;
pages(obj.curr, obj.limit, null);
}
}
});
})
}
/*初始化表格*/
function initTable(dataList, limit, page) {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0});
tableIns = table.render({
elem: "#table_data",
height: "full-130",
data: dataList,
limit: limit,
cols: [
[
// {type: "checkbox", width: 50, unresize: true, align: "center"},
//表头
{title: "序号", width: 70, unresize: true, align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "sampleTools",
// width: 155,
title: "样品类型",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.sampleTools}">${d.sampleTools}</div>`;
}
},
{
field: "devCode",
// width: 150,
title: "样品编号",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.devCode}">${d.devCode}</div>`;
}
},
{
field: "customerCode",
// width: 150,
title: "样品编码",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.customerCode}">${d.customerCode}</div>`;
}
},
{
field: "devModule",
// width: 150,
title: "样品规格",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.devModule}">${d.devModule}</div>`;
}
},
{
field: "customName",
// width: 175,
title: "送样单位",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.customName}">${d.customName}</div>`;
}
},
{
field: "sampleDepartment",
// width: 170,
title: "送样部门",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.sampleDepartment}">${d.sampleDepartment}</div>`;
}
},
{
field: "manufactureDate",
// width: 150,
title: "生产日期",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.manufactureDate}">${d.manufactureDate}</div>`;
}
},
{
field: "experTime",
// width: 150,
title: "试验日期",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.experTime}">${d.experTime}</div>`;
}
},
{
field: "experConclu",
// width: 120,
title: "试验结果",
unresize: true,
align: "center",
templet: function (d) {
return `<div class="ellipsis" title="${d.experConclu}">${d.experConclu}</div>`;
}
},
],
],
done: function (res, curr, count) {
layer.close(loadingMsg);
table.resize("table_data");
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
},
});
}
// /**
// * 批量下载
// */
// function batchDownload() {
// var selectedRows = table.checkStatus("table_data").data;
// if (selectedRows.length == 0) {
// return layer.msg('请选择要下载的数据', {icon: 7})
// }
// // 创建一个临时 canvas 用于绘制带白边的二维码
// var qrWidth = 300; // 二维码的标准宽度
// var whiteBorder = 20; // 白边的宽度
// var totalWidth = qrWidth + 2 * whiteBorder; // 总宽度
// var canvas = document.createElement('canvas');
// canvas.width = totalWidth;
// canvas.height = totalWidth; // 保持正方形
// var ctx = canvas.getContext('2d');
//
// selectedRows.forEach(function (row, index) {
// // 准备二维码内容
// const qrCodeData="hgz/"+row.customerCode;
//
//
// // const qrCodeData = {
// // "样品名称": row.sampleTools,
// // "规格型号": row.devModule,
// // "样品编号": row.devCode,
// // "检验日期": row.experTime,
// // "下次检验日期": row.nextExperTime,
// // "试验人员": row.experUser,
// // "试验结果": row.experConclu,
// // "送检单位": row.customName
// // };
//
// // 创建二维码并填充白色背景
// $('#qr-canvas').empty();
// // $('#qr-canvas').qrcode(utf16to8(JSON.stringify(qrCodeData, null, 2)));
// $('#qr-canvas').qrcode(utf16to8(qrCodeData));
//
// // 获取 qr-canvas 中的二维码元素
// var qrCanvas = document.querySelector('#qr-canvas canvas');
// var qrSize = qrCanvas.width;
//
// // 绘制白边
// ctx.fillStyle = "#FFFFFF"; // 设置白色
// ctx.fillRect(0, 0, totalWidth, totalWidth); // 填充整个画布
//
// // 计算二维码的位置以确保居中
// var xOffset = (totalWidth - qrSize) / 2;
// var yOffset = (totalWidth - qrSize) / 2;
//
// // 将二维码绘制到白边画布中,居中对齐
// ctx.drawImage(qrCanvas, xOffset, yOffset, qrSize, qrSize);
// var dataURL = canvas.toDataURL('image/png');
//
// // 创建下载链接并自动点击
// var link = document.createElement('a');
// link.href = dataURL;
// link.download = `QRCode_${index + 1}.png`;
// link.click();
// });
// }
// 获取参数
function getReqParams(page, limit, type) {
var selectedValue =$('#sampleTools').val()
// 2. 查找对应的选项文本
var selectedText = $('#sampleTools option[value="' + selectedValue + '"]').text();
console.log(selectedText)
if (selectedText=='请选择样品类型'){
selectedText=''
}
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
sampleTools: selectedText,
keyWord:$('#keyWord').val()
};
} else {
obj = {
page: '1',
limit: '10',
sampleTools: '',
keyWord: ''
};
}
console.log(obj)
obj={
encryptedData:encryptCBC(JSON.stringify(obj))
}
return obj;
}
// 查询/重置
function query() {
let pattern = new RegExp("[%_<>]");
if (pattern.test($("#loginName").val())) {
$("#loginName").val('');
return layer.msg('用户名查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
if (pattern.test($("#phone").val())) {
$("#phone").val('');
return layer.msg('手机号查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
pageNum = 1;
pages(1, limitSize);
}
//重置
function reset() {
pages(1, limitSize, 1)
}
function reloadData() {
pages(pageNum, limitSize);
}
// 启用/停用/解除锁定
function editUserAccountStatus(id, status, type) {
let url = dataUrl + "/sys/user/editUserAccountStatus?token=" + token;
let params = {
'id': id,
'accountStatus': status,
'type': type
}
ajaxRequest(url, "POST", params, true, function () {
}, function (result) {
if (result.code === 200) {
if(type){
reloadData();
}
parent.layer.msg(result.msg, {icon: 1})
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
}
}, function (xhr) {
error(xhr)
});
}
// 管理员修改密码
function resetPwd(id) {
let param = {
'id': id,
'type': '1'
}
openIframe2("addOrEditUnifyUser", '修改密码', "password.html", '770px', '400px', param);
}
/*下拉选表单赋值*/
function setSelectValue(list, selectName) {
console.log("list",list)
let html = '<option value="" selected>请选择样品类型</option>';
$.each(list, function (index, item) {
html += '<option value="' + item.id + '">' + item.name + '</option>';
})
$('#' + selectName).empty().append(html);
layui.form.render();
}

View File

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../js/layui-v2.6.8/css/layui.css" media="all">
<link rel="stylesheet" href="../../js/layui-v2.6.8/dtree/dtree.css">
<link rel="stylesheet" href="../../js/layui-v2.6.8/dtree/font/dtreefont.css">
<link rel="stylesheet" href="../../css/table-common2.css">
<script src="../../js/libs/jquery-3.7.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="../../js/layui-v2.6.8/layui.js" charset="UTF-8" type="text/javascript"></script>
<script src="../../js/publicJs.js"></script>
<script src="../../js/dict.js"></script>
<script src="../../js/commonUtils.js"></script>
<script src="../../js/openIframe.js"></script>
<script src="../../js/my/aes.js"></script>
<script src="../../js/ajaxRequest.js"></script>
<script src="../../js/libs/jquery.qrcode.min.js"></script>
<title>样品统计管理</title>
</head>
<body>
<div id="content">
<div class="basic-search-box layout">
<form class="layui-form basic-form" onsubmit="return false;" style="width: 100%">
<div class="layui-form-item">
<div class="layui-inline" style="padding: 0 0 0 10px;">
<div class="layui-input-inline">
<select id="sampleTools" name="sampleTools" class="form-control input-sm">
</select>
</div>
</div>
<div class="layui-inline" style="padding: 0 0 0 10px;">
<div class="layui-input-inline">
<input type="text" id="keyWord" maxlength="30" class="layui-input" autocomplete="off" placeholder="请输入关键字">
</div>
</div>
<div class="layui-inline btns" style="width: 65%">
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="query(1)">查询
</button>
</div>
</div>
</form>
</div>
<div class="table-box" table-responsive style="z-index: 1;">
<table id="table_data" class="table" lay-filter="table_data"></table>
<div id="voi-page" class="layout"></div>
</div>
</div>
<div id="qr-canvas"></div>
<!-- 模态对话框 -->
<div id="myModal" class="modal" style="text-align: center;">
<div style="width: 380px; margin-left: 30%; margin-top: 11%">
<div class="modal-content">
<div id="Qrcode"></div>
</div>
</div>
</div>
</body>
<style>
.layui-table-init {
background-color: transparent !important;
}
#Qrcode {
margin-top: 20px;
}
/* 模态对话框样式 */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
/* 简单样式,仅用于演示 */
#qr-canvas {
display: none;
}
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 150px; /* 根据需要调整宽度 */
display: block;
}
</style>
<script src="../../js/sampleAll/sampleAllManage.js" charset="UTF-8" type="text/javascript"></script>
</html>