From 6ac56a4c8b506d66b40fc295a84fcd22d6894164 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Sun, 29 Sep 2024 17:02:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=93=81=E7=BB=9F=E8=AE=A1=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SampleAllManageController.java | 54 +++ .../aqgqj/basis/dao/SampleAllManageDao.java | 22 ++ .../basis/service/SampleAllManageService.java | 19 + .../impl/SampleAllManageServiceImpl.java | 43 +++ .../mappers/basis/SampleAllManageMapper.xml | 47 +++ .../static/js/sampleAll/sampleAllManage.js | 363 ++++++++++++++++++ .../pages/sampleAll/sampleAllManage.html | 119 ++++++ 7 files changed, 667 insertions(+) create mode 100644 src/main/java/com/bonus/aqgqj/basis/controller/SampleAllManageController.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/dao/SampleAllManageDao.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/service/SampleAllManageService.java create mode 100644 src/main/java/com/bonus/aqgqj/basis/service/impl/SampleAllManageServiceImpl.java create mode 100644 src/main/resources/mappers/basis/SampleAllManageMapper.xml create mode 100644 src/main/resources/static/js/sampleAll/sampleAllManage.js create mode 100644 src/main/resources/static/pages/sampleAll/sampleAllManage.html diff --git a/src/main/java/com/bonus/aqgqj/basis/controller/SampleAllManageController.java b/src/main/java/com/bonus/aqgqj/basis/controller/SampleAllManageController.java new file mode 100644 index 0000000..ceac3d4 --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/controller/SampleAllManageController.java @@ -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 data) { + PageHelper.startPage(data.getData().getPage(), data.getData().getLimit()); + try { + List list = sampleAllManageService.list(data.getData()); + PageInfo 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()); + } + + +} diff --git a/src/main/java/com/bonus/aqgqj/basis/dao/SampleAllManageDao.java b/src/main/java/com/bonus/aqgqj/basis/dao/SampleAllManageDao.java new file mode 100644 index 0000000..c4c2cac --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/dao/SampleAllManageDao.java @@ -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 list(ToolsManageDto bean); + + +} diff --git a/src/main/java/com/bonus/aqgqj/basis/service/SampleAllManageService.java b/src/main/java/com/bonus/aqgqj/basis/service/SampleAllManageService.java new file mode 100644 index 0000000..0b867b9 --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/service/SampleAllManageService.java @@ -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 list(ToolsManageDto bean); + +} diff --git a/src/main/java/com/bonus/aqgqj/basis/service/impl/SampleAllManageServiceImpl.java b/src/main/java/com/bonus/aqgqj/basis/service/impl/SampleAllManageServiceImpl.java new file mode 100644 index 0000000..940da34 --- /dev/null +++ b/src/main/java/com/bonus/aqgqj/basis/service/impl/SampleAllManageServiceImpl.java @@ -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 list(ToolsManageDto bean) { + List list = new ArrayList<>(); + list = sampleAllManageDao.list(bean); + return list; + } + + + +} diff --git a/src/main/resources/mappers/basis/SampleAllManageMapper.xml b/src/main/resources/mappers/basis/SampleAllManageMapper.xml new file mode 100644 index 0000000..8d4a8f1 --- /dev/null +++ b/src/main/resources/mappers/basis/SampleAllManageMapper.xml @@ -0,0 +1,47 @@ + + + + + + diff --git a/src/main/resources/static/js/sampleAll/sampleAllManage.js b/src/main/resources/static/js/sampleAll/sampleAllManage.js new file mode 100644 index 0000000..a3c35a4 --- /dev/null +++ b/src/main/resources/static/js/sampleAll/sampleAllManage.js @@ -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 `
${d.sampleTools}
`; + } + }, + { + field: "devCode", + // width: 150, + title: "样品编号", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.devCode}
`; + } + }, + { + field: "customerCode", + // width: 150, + title: "样品编码", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.customerCode}
`; + } + }, + { + field: "devModule", + // width: 150, + title: "样品规格", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.devModule}
`; + } + }, + { + field: "customName", + // width: 175, + title: "送样单位", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.customName}
`; + } + }, + { + field: "sampleDepartment", + // width: 170, + title: "送样部门", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.sampleDepartment}
`; + } + }, + { + field: "manufactureDate", + // width: 150, + title: "生产日期", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.manufactureDate}
`; + } + }, + { + field: "experTime", + // width: 150, + title: "试验日期", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.experTime}
`; + } + }, + { + field: "experConclu", + // width: 120, + title: "试验结果", + unresize: true, + align: "center", + templet: function (d) { + return `
${d.experConclu}
`; + } + }, + ], + ], + 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 = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} diff --git a/src/main/resources/static/pages/sampleAll/sampleAllManage.html b/src/main/resources/static/pages/sampleAll/sampleAllManage.html new file mode 100644 index 0000000..c6471bd --- /dev/null +++ b/src/main/resources/static/pages/sampleAll/sampleAllManage.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + 样品统计管理 + + +
+ +
+
+
+
+
+
+ + + + + + +