提交源码

master
CaesarBao 12 months ago
parent 421481822b
commit 42cfd198dd

@ -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")
@ -107,31 +103,30 @@ public class StationParaInfoController extends BaseController {
// @RequiresPermissions("nanjing:StationPara:export")
// @Log(title = "产品码查询", businessType = BusinessType.EXPORT)
@PostMapping("/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<String, Object>();
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<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.exportExcel(list, "工位参数");
// try {
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// ExcelUtil.createWorkBook()
// }catch (IOException e){
// e.printStackTrace();
// }finally {
//
// }
//return null;
//动态封装实体
List<Map<String, Object>> 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");
}
}
}

@ -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<QsStation> nodeClick(String begin,String end,String node,String productid)
{
Map map = new HashMap<String,Object>();
map.put("begin",begin);
map.put("end",end);
@ -77,10 +76,26 @@ public class StatisticStProductController extends BaseController {
// map.put("productId",productid);
List<QsStation> qsStations = producttypeService.selectNodeQs(map);
List<QsStation> qsStations1 = null;
QsStation qsStation = qsStations.get(0);
qsStation.setStationCode(substationService.selectSubNameCode(node));
qsStation.setStationName(substationService.selectSubName(node));
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;
}
}
}

@ -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
# 从库数据源

@ -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();
}
})
})
}

@ -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();

@ -109,6 +109,7 @@
<artifactId>spring-websocket</artifactId>
</dependency>
</dependencies>
</project>

@ -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<T>
{
/**
* src:
*
* @param mapArrayList
* @param src
*/
public static boolean createExcel(List<Map<String, Object>> mapArrayList, String src) {
System.out.println("数据转成Excel...");
//获取数据源的 key, 用于获取列数及设置标题
Map<String, Object> map = mapArrayList.get(0);
Set<String> stringSet = map.keySet();
ArrayList<String> 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);
/**

@ -33,6 +33,10 @@
<artifactId>spring-boot-starter-websocket</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

@ -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 +
'}';
}
}

@ -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<BaseRepairinfoRecord> selectRework(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
}

@ -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<BaseRepairinfoRecord> selectRework(Date beginTime,Date endTime);
}

@ -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<BaseRepairinfoRecord> selectRework(Date beginTime,Date endTime) {
return reworkMapper.selectRework(beginTime, endTime);
}
}

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.nanjing.mapper.ReworkMapper">
<resultMap type="BaseRepairinfoRecord" id="BaseRepairinfoRecord">
<result property="id" column="ID"/>
<result property="barcode" column="Barcode"/>
<result property="productBarcode" column="ProductBarcode"/>
<result property="reStartStation" column="ReStartStation"/>
<result property="recordTime" column="RecordTime"/>
</resultMap>
<select id="selectRework" parameterType="String" resultMap="BaseRepairinfoRecord">
select * from base_RepairInfo_Record
<where>
<if test="beginTime!= null ">and recordTime <![CDATA[ <= ]]> #{endTime}</if>
<if test="endTime!= null ">and recordTime <![CDATA[ >= ]]> #{beginTime}</if>
</where>
order by recordTime desc
</select>
</mapper>
Loading…
Cancel
Save