|
|
|
@ -12,6 +12,9 @@ import com.ruoyi.nanjing.domain.TBdProductinfo;
|
|
|
|
|
import com.ruoyi.nanjing.domain.TBdSubstation;
|
|
|
|
|
import com.ruoyi.nanjing.service.ITBdSubstationService;
|
|
|
|
|
import com.ruoyi.nanjing.service.ITSyTracestateService;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
@ -23,6 +26,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -36,49 +43,178 @@ public class StationParaInfoController extends BaseController {
|
|
|
|
|
private ITSyTracestateService tracestateService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ITBdSubstationService substationService;
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("nanjing:StationPara:view")
|
|
|
|
|
@GetMapping()
|
|
|
|
|
public String ProRpList(ModelMap map)
|
|
|
|
|
{
|
|
|
|
|
public String ProRpList(ModelMap map) {
|
|
|
|
|
List<TBdSubstation> substations = substationService.selectTBdSubstationList(new TBdSubstation());
|
|
|
|
|
map.addAttribute("list",substations);
|
|
|
|
|
map.addAttribute("list", substations);
|
|
|
|
|
return prefix + "/StationParaInfo";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("nanjing:StationPara:list")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public TableDataInfo list(HttpServletRequest request)
|
|
|
|
|
{
|
|
|
|
|
public TableDataInfo list(HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
String stationCode = request.getParameter("stationCode");
|
|
|
|
|
String semiBarcode = request.getParameter("semiBarcode");
|
|
|
|
|
String beginTime = request.getParameter("beginTime");
|
|
|
|
|
String endTime = request.getParameter("endTime");
|
|
|
|
|
Map<String, Object> map = new HashMap<String,Object>();
|
|
|
|
|
map.put("beginTime",beginTime);
|
|
|
|
|
map.put("endTime",endTime);
|
|
|
|
|
map.put("StationID",stationCode);
|
|
|
|
|
map.put("Barcode","");
|
|
|
|
|
map.put("SemiBarcode",semiBarcode);
|
|
|
|
|
map.put("StateID","");
|
|
|
|
|
List list = tracestateService.selectStationPara(map);
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("beginTime", beginTime);
|
|
|
|
|
map.put("endTime", endTime);
|
|
|
|
|
map.put("StationID", stationCode);
|
|
|
|
|
map.put("Barcode", "");
|
|
|
|
|
map.put("SemiBarcode", semiBarcode);
|
|
|
|
|
map.put("StateID", "");
|
|
|
|
|
List<Map<String, Object>> list = tracestateService.selectStationPara(map);
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
if (list.get(i).containsKey("产品码")) {
|
|
|
|
|
continue;
|
|
|
|
|
} else {
|
|
|
|
|
list.get(i).put("产品码", "-");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @RequiresPermissions("nanjing:StationPara:export")
|
|
|
|
|
// @RequiresPermissions("nanjing:StationPara:export")
|
|
|
|
|
// @Log(title = "产品码查询", businessType = BusinessType.EXPORT)
|
|
|
|
|
// @PostMapping("/export")
|
|
|
|
|
// @ResponseBody
|
|
|
|
|
// public AjaxResult export(HttpServletRequest request)
|
|
|
|
|
// {
|
|
|
|
|
// String semiBarcode = request.getParameter("semiBarcode");
|
|
|
|
|
// Map map = new HashMap<String,Object>();
|
|
|
|
|
// map.put("beginTime",null);
|
|
|
|
|
// map.put("endTime",null);
|
|
|
|
|
// map.put("semiBarcode",semiBarcode);
|
|
|
|
|
// List<ParaAllShow> list = tracestateService.selectAllPara(map);
|
|
|
|
|
// ExcelUtil<ParaAllShow> util = new ExcelUtil<ParaAllShow>(ParaAllShow.class);
|
|
|
|
|
// return util.exportExcel(list, "StationPara");
|
|
|
|
|
//// return null;
|
|
|
|
|
// }
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult export(HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
String semiBarcode = request.getParameter("semiBarcode");
|
|
|
|
|
Map map = new HashMap<String, Object>();
|
|
|
|
|
map.put("beginTime", null);
|
|
|
|
|
map.put("endTime", null);
|
|
|
|
|
map.put("semiBarcode", semiBarcode);
|
|
|
|
|
List list = tracestateService.selectStationPara(map);
|
|
|
|
|
HSSFWorkbook wb = listToExcle.getExcle("测试", list, 9);
|
|
|
|
|
listToExcle.responseExcel(wb,"工位参数",response);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class listToExcle{
|
|
|
|
|
public static HSSFWorkbook getExcle(String title, List<String> list, int colNums){
|
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
|
HSSFSheet sheet = wb.createSheet(title);
|
|
|
|
|
HSSFRow row;
|
|
|
|
|
HSSFCell cell;
|
|
|
|
|
HSSFCellStyle styleTitle = wb.createCellStyle();
|
|
|
|
|
//标题
|
|
|
|
|
// HSSFCellStyle styleTitle = wb.createCellStyle();
|
|
|
|
|
// styleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
// HSSFFont fontTitle = wb.createFont();
|
|
|
|
|
// fontTitle.setFontHeightInPoints((short) 20);
|
|
|
|
|
// styleTitle.setFont(fontTitle);
|
|
|
|
|
|
|
|
|
|
//表头
|
|
|
|
|
HSSFCellStyle styleHead = wb.createCellStyle();
|
|
|
|
|
HSSFFont fontHead = wb.createFont();
|
|
|
|
|
fontHead.setFontHeightInPoints((short) 11);
|
|
|
|
|
styleHead.setFont(fontHead);
|
|
|
|
|
|
|
|
|
|
//表格
|
|
|
|
|
HSSFCellStyle styleBody = wb.createCellStyle();
|
|
|
|
|
HSSFFont fontBody = wb.createFont();
|
|
|
|
|
fontBody.setFontHeightInPoints((short) 10);
|
|
|
|
|
|
|
|
|
|
styleBody.setFont(fontBody);
|
|
|
|
|
|
|
|
|
|
//尾注
|
|
|
|
|
HSSFCellStyle styleFoot = wb.createCellStyle();
|
|
|
|
|
HSSFFont fontFoot = wb.createFont();
|
|
|
|
|
fontFoot.setFontHeightInPoints((short) 12);
|
|
|
|
|
fontFoot.setColor(HSSFColor.DARK_GREEN.index);
|
|
|
|
|
styleFoot.setFont(fontFoot);
|
|
|
|
|
styleFoot.setFillForegroundColor(HSSFColor.YELLOW.index);
|
|
|
|
|
|
|
|
|
|
//设置标题行
|
|
|
|
|
row = sheet.createRow(0);
|
|
|
|
|
cell = row.createCell(0);
|
|
|
|
|
//行高
|
|
|
|
|
row.setHeightInPoints((float) (10.75 * 3));
|
|
|
|
|
//内容
|
|
|
|
|
cell.setCellValue(title);
|
|
|
|
|
//样式
|
|
|
|
|
cell.setCellStyle(styleTitle);
|
|
|
|
|
// 合并单元格 (始行,终行,始列,终列)
|
|
|
|
|
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, colNums - 1));
|
|
|
|
|
|
|
|
|
|
//设置表头
|
|
|
|
|
row = sheet.createRow(1);
|
|
|
|
|
//行高
|
|
|
|
|
row.setHeightInPoints(15);
|
|
|
|
|
//内容
|
|
|
|
|
String str = list.get(0);
|
|
|
|
|
String[] ary = str.split(",");
|
|
|
|
|
for (int j = 0; j < ary.length; j++) {
|
|
|
|
|
cell = row.createCell(j);
|
|
|
|
|
cell.setCellValue(ary[j]);
|
|
|
|
|
cell.setCellStyle(styleHead);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置表格内容
|
|
|
|
|
for (int i = 2; i <= list.size(); i++) {
|
|
|
|
|
//序号列
|
|
|
|
|
row = sheet.createRow(i);
|
|
|
|
|
cell = row.createCell(0);
|
|
|
|
|
cell.setCellValue(i - 1);
|
|
|
|
|
cell.setCellStyle(styleBody);
|
|
|
|
|
|
|
|
|
|
//内容列
|
|
|
|
|
str = list.get(i - 1);
|
|
|
|
|
ary = str.split(",");
|
|
|
|
|
for (int j = 1; j <= ary.length; j++) {
|
|
|
|
|
cell = row.createCell(j);
|
|
|
|
|
cell.setCellValue(ary[j - 1]);
|
|
|
|
|
cell.setCellStyle(styleBody);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置脚注
|
|
|
|
|
int n = sheet.getLastRowNum();
|
|
|
|
|
row = sheet.createRow(++n);
|
|
|
|
|
row.setHeightInPoints((float) (12.75 * 2));
|
|
|
|
|
cell = row.createCell(0);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
cell.setCellValue("数据生成时间:" + sdf.format(new Date()));
|
|
|
|
|
cell.setCellStyle(styleFoot);
|
|
|
|
|
sheet.addMergedRegion(new CellRangeAddress(n, n, 0, colNums - 1));
|
|
|
|
|
|
|
|
|
|
// 自动调整列宽
|
|
|
|
|
for (int k = 0; k < colNums; k++) {
|
|
|
|
|
sheet.autoSizeColumn((short) k, true);
|
|
|
|
|
}
|
|
|
|
|
//手动设置列宽
|
|
|
|
|
//sheet.setColumnWidth(列号,宽度);
|
|
|
|
|
|
|
|
|
|
return wb;
|
|
|
|
|
}
|
|
|
|
|
//通过浏览器下载
|
|
|
|
|
public static void responseExcel(HSSFWorkbook wb, String fileName, HttpServletResponse response) {
|
|
|
|
|
OutputStream out = null;
|
|
|
|
|
try {
|
|
|
|
|
out = response.getOutputStream();
|
|
|
|
|
response.setContentType("application/x-msdownload");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
|
|
wb.write(out);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
out.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|