From 42cfd198dd8c25b6844571b8c27cba3cb913b2d7 Mon Sep 17 00:00:00 2001 From: CaesarBao <445720029@qq.com> Date: Fri, 1 Mar 2024 13:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=BA=90=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nanjing/StationParaInfoController.java | 59 ++++++------ .../nanjing/StatisticStProductController.java | 21 ++++- .../src/main/resources/application-druid.yml | 7 +- .../StationParaInfo/StationParaInfo.html | 39 +++++++- .../nanjing/Statistic/QsStation.html | 67 +------------ ruoyi-common/pom.xml | 1 + .../com/ruoyi/common/utils/poi/ExcelUtil.java | 94 +++++++++++++++++-- ruoyi-system/pom.xml | 4 + .../nanjing/domain/BaseRepairinfoRecord.java | 70 ++++++++++++++ .../ruoyi/nanjing/mapper/ReworkMapper.java | 12 +++ .../ruoyi/nanjing/service/ReworkService.java | 10 ++ .../service/impl/ReworkServiceImpl.java | 22 +++++ .../resources/mapper/nanjing/ReworkMapper.xml | 23 +++++ 13 files changed, 316 insertions(+), 113 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/nanjing/domain/BaseRepairinfoRecord.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/nanjing/mapper/ReworkMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/nanjing/service/ReworkService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/nanjing/service/impl/ReworkServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/nanjing/ReworkMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StationParaInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StationParaInfoController.java index ccc84aaf..ed49898c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StationParaInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StationParaInfoController.java @@ -1,6 +1,8 @@ package com.ruoyi.web.controller.nanjing; +import com.ruoyi.RuoYiApplication; import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.config.Global; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; @@ -14,19 +16,13 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import oshi.jna.platform.mac.SystemB; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; @Controller @RequestMapping("/nanjing/selectStationPara") @@ -106,32 +102,31 @@ public class StationParaInfoController extends BaseController { } // @RequiresPermissions("nanjing:StationPara:export") -// @Log(title = "产品码查询", businessType = BusinessType.EXPORT) - @PostMapping("/export") + // @Log(title = "产品码查询", businessType = BusinessType.EXPORT) + @GetMapping("/export") @ResponseBody - public AjaxResult export(HttpServletRequest request,HttpServletResponse response) { - String semiBarcode = request.getParameter("semiBarcode"); + public AjaxResult export(@RequestParam("beginTime") Date beginTime,@RequestParam("endTime") Date endTime,@RequestParam("StationID") String StationID,@RequestParam("semiBarcode") String semiBarcode) { Map map = new HashMap(); - BufferedInputStream bis = null; - BufferedOutputStream bos = null; - map.put("beginTime", null); - map.put("endTime", null); + map.put("beginTime", beginTime); + map.put("endTime", endTime); + map.put("StationID", StationID); map.put("semiBarcode", semiBarcode); - List list = tracestateService.selectStationPara(map); -// for (int i = 0; i < list.size() ; i++) { -// System.out.println(list.get(i)); -// } - ExcelUtil util = new ExcelUtil(SysUser.class); - - return util.exportExcel(list, "工位参数"); -// try { -// ByteArrayOutputStream os = new ByteArrayOutputStream(); -// ExcelUtil.createWorkBook() -// }catch (IOException e){ -// e.printStackTrace(); -// }finally { -// -// } - //return null; + + //动态封装实体 + List> list = tracestateService.selectStationPara(map); + //路径+文件名 + String url = Global.getProfile(); + String FileName = ""; + boolean iflag = ExcelUtil.createExcel(list, "工位参数"); + if(iflag){ + //下载 + + AjaxResult ajax = AjaxResult.success("1",0); + return ajax; + } + else{ + return AjaxResult.error("500"); + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StatisticStProductController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StatisticStProductController.java index 3046b68e..dfd1e3bc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StatisticStProductController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/nanjing/StatisticStProductController.java @@ -3,11 +3,9 @@ package com.ruoyi.web.controller.nanjing; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.nanjing.domain.QsStation; import com.ruoyi.nanjing.domain.TBdProductinfo; -import com.ruoyi.nanjing.domain.TRpShiftInfo; import com.ruoyi.nanjing.service.ITBdProductinfoService; import com.ruoyi.nanjing.service.ITBdProducttypeService; import com.ruoyi.nanjing.service.ITBdSubstationService; -import com.ruoyi.nanjing.service.TRpShiftInfoService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -69,6 +67,7 @@ public class StatisticStProductController extends BaseController { @ResponseBody public List nodeClick(String begin,String end,String node,String productid) { + Map map = new HashMap(); map.put("begin",begin); map.put("end",end); @@ -77,10 +76,26 @@ public class StatisticStProductController extends BaseController { // map.put("productId",productid); List qsStations = producttypeService.selectNodeQs(map); + List qsStations1 = null; QsStation qsStation = qsStations.get(0); qsStation.setStationCode(substationService.selectSubNameCode(node)); qsStation.setStationName(substationService.selectSubName(node)); - return qsStations; + int i = Integer.parseInt(node); + if (i==11) + { + qsStations.remove(1); + System.out.println("============================================="); + System.out.println("============================================="); + System.out.println(qsStations); + System.out.println("============================================="); + return qsStations; + }else{ + System.out.println("============================================="); + System.out.println(node); + System.out.println("============================================="); + return qsStations; + } + } } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 96577c61..0efa4ecd 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,14 +6,11 @@ spring: druid: # 主库数据源 # master: -# url: jdbc:sqlserver://121.36.58.109:1433;SelectMethod=cursor;DatabaseName=JYD_shengjie -# username: sa -# password: haiwei@123 # url: jdbc:sqlserver://127.0.0.1:1433;SelectMethod=cursor;DatabaseName=JYD_shengjie # username: sa -## password: 123456 +# password: haiwei@123 master: - url: jdbc:sqlserver://192.168.3.109:1433;SelectMethod=cursor;DatabaseName=JYD_shengjie + url: jdbc:sqlserver://127.0.0.1:1433;SelectMethod=cursor;DatabaseName=JYD_shengjie username: sa password: 123456 # 从库数据源 diff --git a/ruoyi-admin/src/main/resources/templates/nanjing/StationParaInfo/StationParaInfo.html b/ruoyi-admin/src/main/resources/templates/nanjing/StationParaInfo/StationParaInfo.html index 71f8b527..90fa62b1 100644 --- a/ruoyi-admin/src/main/resources/templates/nanjing/StationParaInfo/StationParaInfo.html +++ b/ruoyi-admin/src/main/resources/templates/nanjing/StationParaInfo/StationParaInfo.html @@ -177,10 +177,47 @@ }); } function expro() { + //table.set(); $.modal.confirm("确定导出所有" + "工位参数" + "吗?", function() { $.modal.loading("正在导出数据,请稍后..."); - $.post(prefix+"/export", function(result) { + // $.post(prefix+"/export", function(result) { + // + // }) + $.ajax({ + url: prefix + "/export?beginTime="+$("#beginTime").val() + "&endTime="+ $("#endTime").val() +"&StationID="+$("#stationCode").val() +"&semiBarcode="+ $("#semiBarcode").val(), + type: 'get', + cache: false, + processData: false, + contentType: false, + dataType: "json", + success: function(result) { + if (result.code == 0) { + // var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; + // var params = $("#" + table.options.id).bootstrapTable('getOptions'); + // var dataParam = $("#" + currentId).serializeArray(); + // dataParam.push({ "name": "orderByColumn", "value": params.sortName }); + // dataParam.push({ "name": "isAsc", "value": params.sortOrder }); + // $.post(table.options.exportUrl, dataParam, function(result) { + // if (result.code == web_status.SUCCESS) { + // $.modal.alertSuccess("成功导出"); + // 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(); + // }); + $.modal.alertSuccess("成功导出"); + + } else { + $.modal.alertError(result.msg); + } + $.modal.closeLoading(); + + + } }) }) } diff --git a/ruoyi-admin/src/main/resources/templates/nanjing/Statistic/QsStation.html b/ruoyi-admin/src/main/resources/templates/nanjing/Statistic/QsStation.html index f5c3d07a..5fefec07 100644 --- a/ruoyi-admin/src/main/resources/templates/nanjing/Statistic/QsStation.html +++ b/ruoyi-admin/src/main/resources/templates/nanjing/Statistic/QsStation.html @@ -79,41 +79,7 @@ queryDeptTree(); }); - // function queryList(url) { - // console.log(url); - // var options = { - // // url: url, - // // exportUrl: prefix + "/export", - // modalName: "工位合格率统计", - // columns: [ - // { - // field: 'productTp', - // title: '机种类型' - // }, - // { - // field: 'inputNum', - // title: '投入量' - // }, - // { - // field: 'okNum', - // title: '合格品' - // }, - // { - // field:'noNum', - // title:'不合格品' - // }, - // { - // field:'ero', - // title:'异常' - // }, - // { - // field: 'allRate', - // title: '综合合格率', - // } - // ] - // }; - // $.table.init(options); - // } + function searchAll(){ // console.log("点击查询按钮事件执行..."); @@ -133,32 +99,7 @@ productid:$('#product').val() }, modalName: "工位合格率统计", - // columns: [ - // { - // field: 'productTp', - // title: '机种类型' - // }, - // { - // field: 'inputNum', - // title: '投入量' - // }, - // { - // field: 'okNum', - // title: '合格品' - // }, - // { - // field:'noNum', - // title:'不合格品' - // }, - // { - // field:'ero', - // title:'异常' - // }, - // { - // field: 'allRate', - // title: '综合合格率', - // } - // ] + columns: [ { field: 'stationCode', @@ -191,7 +132,7 @@ function queryDeptTree() { - // console.log("加载树执行。。。。。。"); + console.log("222加载树执行。。。。。。"); var url = ctx + "nanjing/SubStation/treeData"; var options = { url: url, @@ -202,7 +143,7 @@ function zOnClick(event, treeId, treeNode) { // queryList(prefix + "/list"); - console.log("点击节点工位ID"+treeNode.id); + console.log("22222点击节点工位ID"+treeNode.id); $("#stationId").val(treeNode.id); $("#parentId").val(treeNode.pId); // $.table.search(); diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index b41258ad..46893732 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -109,6 +109,7 @@ spring-websocket + \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index ca1358a9..e20f3679 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -9,15 +9,10 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.math.BigDecimal; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; + +import com.alibaba.excel.EasyExcel; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; @@ -38,7 +33,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFDataValidation; +import org.apache.poi.xssf.usermodel.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ruoyi.common.annotation.Excel; @@ -59,8 +54,89 @@ import com.ruoyi.common.utils.spring.SpringUtils; * * @author ruoyi */ + public class ExcelUtil { + + /** + * src:定义下载的文件路径 + * + * @param mapArrayList + * @param src + */ + public static boolean createExcel(List> mapArrayList, String src) { + System.out.println("数据转成Excel..."); + + //获取数据源的 key, 用于获取列数及设置标题 + Map map = mapArrayList.get(0); + Set stringSet = map.keySet(); + ArrayList headList = new ArrayList<>(stringSet); + + // 定义一个新的工作簿 + XSSFWorkbook wb = new XSSFWorkbook(); + // 创建一个Sheet页 + XSSFSheet sheet = wb.createSheet("First sheet"); + //设置行高 + sheet.setDefaultRowHeight((short) (2 * 256)); + //设置列宽 + sheet.setColumnWidth(0, 4000); + sheet.setColumnWidth(1, 4000); + sheet.setColumnWidth(2, 4000); + XSSFFont font = wb.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 16); + //获得表格第一行 + XSSFRow row = sheet.createRow(0); + + //chen 优化标题获取 根据数据源信息给第一行每一列设置标题 + for (int i = 0; i < headList.size(); i++) { + XSSFCell cell = row.createCell(i); + cell.setCellValue(headList.get(i)); + } + + XSSFRow rows; + XSSFCell cells; + //循环拿到的数据给所有行每一列设置对应的值 + for (int i = 0; i < mapArrayList.size(); i++) { + + // 在这个sheet页里创建一行 + rows = sheet.createRow(i + 1); + //chen 优化值获取 给该行数据赋值 + for (int j = 0; j < headList.size(); j++) { + String value; + if (mapArrayList.get(i).get(headList.get(j)) != null) { + value = mapArrayList.get(i).get(headList.get(j)).toString(); + } else { + value = ""; + } + cells = rows.createCell(j); + cells.setCellValue(value); + } + } + try { + String FileName = UUID.randomUUID().toString() + "_" + src + ".xlsx"; + String downloadPath = Global.getDownloadPath() + FileName; + File desc = new File(downloadPath); + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + //File file = new File(src); + FileOutputStream fileOutputStream = new FileOutputStream(desc); + wb.write(fileOutputStream); + wb.close(); + fileOutputStream.close(); + return true; +// AjaxResult ajax = AjaxResult.success(); +// return ajax; + } catch (IOException e) { + e.printStackTrace(); + //return AjaxResult.error(e.getMessage()); + return false; + } + + } + private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); /** diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 45690310..7dcdc4be 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -33,6 +33,10 @@ spring-boot-starter-websocket 2.7.3 + + org.projectlombok + lombok + diff --git a/ruoyi-system/src/main/java/com/ruoyi/nanjing/domain/BaseRepairinfoRecord.java b/ruoyi-system/src/main/java/com/ruoyi/nanjing/domain/BaseRepairinfoRecord.java new file mode 100644 index 00000000..13c0d8c2 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/nanjing/domain/BaseRepairinfoRecord.java @@ -0,0 +1,70 @@ +package com.ruoyi.nanjing.domain; + + +import java.util.Date; + +public class BaseRepairinfoRecord { + + private static final long serialVersionUID = 1L; + + private Integer id; + + private String barcode; + + private String productBarcode; + + private String reStartStation; + + private Date recordTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBarcode() { + return barcode; + } + + public void setBarcode(String barcode) { + this.barcode = barcode; + } + + public String getProductBarcode() { + return productBarcode; + } + + public void setProductBarcode(String productBarcode) { + this.productBarcode = productBarcode; + } + + public String getReStartStation() { + return reStartStation; + } + + public void setReStartStation(String reStartStation) { + this.reStartStation = reStartStation; + } + + public Date getRecordTime() { + return recordTime; + } + + public void setRecordTime(Date recordTime) { + this.recordTime = recordTime; + } + + @Override + public String toString() { + return "BaseRepairinfoRecord{" + + "id=" + id + + ", barcode='" + barcode + '\'' + + ", productBarcode='" + productBarcode + '\'' + + ", reStartStation='" + reStartStation + '\'' + + ", recordTime=" + recordTime + + '}'; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/nanjing/mapper/ReworkMapper.java b/ruoyi-system/src/main/java/com/ruoyi/nanjing/mapper/ReworkMapper.java new file mode 100644 index 00000000..c7b94ba3 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/nanjing/mapper/ReworkMapper.java @@ -0,0 +1,12 @@ +package com.ruoyi.nanjing.mapper; + +import com.ruoyi.nanjing.domain.BaseRepairinfoRecord; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +//返修信息查询 +public interface ReworkMapper { + List selectRework(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/nanjing/service/ReworkService.java b/ruoyi-system/src/main/java/com/ruoyi/nanjing/service/ReworkService.java new file mode 100644 index 00000000..c10362c2 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/nanjing/service/ReworkService.java @@ -0,0 +1,10 @@ +package com.ruoyi.nanjing.service; + +import com.ruoyi.nanjing.domain.BaseRepairinfoRecord; + +import java.util.Date; +import java.util.List; + +public interface ReworkService { + List selectRework(Date beginTime,Date endTime); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/nanjing/service/impl/ReworkServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/nanjing/service/impl/ReworkServiceImpl.java new file mode 100644 index 00000000..37523c52 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/nanjing/service/impl/ReworkServiceImpl.java @@ -0,0 +1,22 @@ +package com.ruoyi.nanjing.service.impl; + +import com.ruoyi.nanjing.domain.BaseRepairinfoRecord; +import com.ruoyi.nanjing.mapper.ReworkMapper; +import com.ruoyi.nanjing.service.ReworkService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +@Service +public class ReworkServiceImpl implements ReworkService { + @Autowired ReworkMapper reworkMapper; + + + @Override + public List selectRework(Date beginTime,Date endTime) { + return reworkMapper.selectRework(beginTime, endTime); + + } +} diff --git a/ruoyi-system/src/main/resources/mapper/nanjing/ReworkMapper.xml b/ruoyi-system/src/main/resources/mapper/nanjing/ReworkMapper.xml new file mode 100644 index 00000000..fc7d8174 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/nanjing/ReworkMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + +