use of com.eservice.api.model.machine.MachineInfo in project sinsim by WilsonHu.
the class MachineController method processMachineExport.
@PostMapping("/processMachineExport")
public Result processMachineExport(Integer order_id, String orderNum, String contractNum, String machine_strid, String nameplate, String location, String status, String query_start_time, String query_finish_time, // 工序集合,逗号分隔,支持UI按多个工序查询
String taskNameList, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
List<MachineInfo> list = machineService.selectProcessMachine(order_id, orderNum, contractNum, machine_strid, nameplate, location, status, query_start_time, query_finish_time, taskNameList, is_fuzzy);
InputStream fs = null;
POIFSFileSystem pfs = null;
HSSFWorkbook wb = null;
FileOutputStream out = null;
String downloadPath = "";
/*
返回给docker外部下载
*/
String downloadPathForNginx = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy/MM/dd HH:mm");
String dateString;
try {
// 生成一个空的Excel文件
wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("sheet1");
// 设置标题行格式
HSSFCellStyle headcellstyle = wb.createCellStyle();
HSSFFont headfont = wb.createFont();
headfont.setFontHeightInPoints((short) 10);
// 粗体显示
headfont.setBold(true);
headcellstyle.setFont(headfont);
Row row;
// 创建行和列
for (int r = 0; r < list.size() + 1; r++) {
// 新创建一行,行号为row+1
row = sheet1.createRow(r);
// 序号,机器编号,机型,订单号,位置,当前工序,已完成/总工序,安装状态,开始时间,计划交货日期
for (int c = 0; c < 10; c++) {
// 创建一个单元格,列号为col+1
row.createCell(c);
sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
sheet1.setColumnWidth(c, 4500);
sheet1.setColumnWidth(0, 2500);
}
}
// 第一行为标题
sheet1.getRow(0).getCell(0).setCellValue("序号");
sheet1.getRow(0).getCell(1).setCellValue("机器编号");
sheet1.getRow(0).getCell(2).setCellValue("机型");
sheet1.getRow(0).getCell(3).setCellValue("订单号");
sheet1.getRow(0).getCell(4).setCellValue("位置");
// sheet1.getRow(0).getCell(5).setCellValue("当前工序");
// sheet1.getRow(0).getCell(6).setCellValue("已完成/总工序");
sheet1.getRow(0).getCell(7).setCellValue("安装状态");
sheet1.getRow(0).getCell(8).setCellValue("开始时间");
sheet1.getRow(0).getCell(9).setCellValue("计划交货日期");
// 第二行开始,填入值
Machine machine = null;
MachineOrder machineOrder = null;
MachineType machineType1 = null;
Byte machineStatus = 0;
for (int r = 0; r < list.size(); r++) {
// 序号,机器编号,机型,订单号,位置,当前工序,已完成/总工序,安装状态,开始时间,计划交货日期
row = sheet1.getRow(r + 1);
row.getCell(0).setCellValue(r + 1);
// 机器编号
if (list.get(r).getMachineStrId() != null) {
row.getCell(1).setCellValue(list.get(r).getNameplate());
}
// 机型
int machineTypeID = list.get(r).getMachineType();
// machine = machineService.selectMachinesByNameplate(list.get(r).getNameplate());
/**
* 获取机型类型的名称 machine_type.name
*/
machineType1 = machineTypeService.findById(machineTypeID);
if (machineType1 != null) {
// 机型
row.getCell(2).setCellValue(machineType1.getName());
}
// 订单号
if (list.get(r).getOrderNum() != null) {
row.getCell(3).setCellValue(list.get(r).getOrderNum());
}
// 位置
if (list.get(r).getLocation() != null) {
row.getCell(4).setCellValue(list.get(r).getLocation());
}
// 当前工序
// /todo: 从 nodeData中解析出工序? 注意可能有多个。
// 已完成/总工序
// / todo: 从 nodeData中解析计算?
// 状态
machineStatus = list.get(r).getStatus();
if (machineStatus == Constant.MACHINE_INITIAL) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_INITIAL);
} else if (machineStatus == Constant.MACHINE_CONFIGURED) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_CONFIGURED);
} else if (machineStatus == Constant.MACHINE_PLANING) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_PLANING);
} else if (machineStatus == Constant.MACHINE_INSTALLING) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_INSTALLING);
} else if (machineStatus == Constant.MACHINE_INSTALLED) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_INSTALLED);
} else if (machineStatus == Constant.MACHINE_CHANGED) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_CHANGED);
} else if (machineStatus == Constant.MACHINE_SPLITED) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_SPLITED);
} else if (machineStatus == Constant.MACHINE_CANCELED) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_CANCELED);
} else if (machineStatus == Constant.MACHINE_INSTALLING_INCLUDE_SKIP_TASK) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_INSTALLING_INCLUDE_SKIP_TASK);
} else if (machineStatus == Constant.MACHINE_SHIPPED) {
row.getCell(7).setCellValue(Constant.STR_MACHINE_SHIPPED);
}
// 的开始时间
if (list.get(r).getProcessCreateTime() != null) {
dateString = formatter2.format(list.get(r).getProcessCreateTime());
row.getCell(8).setCellValue(dateString);
}
// 计划交货日期
if (list.get(r).getPlanShipDate() != null) {
dateString = formatter.format(list.get(r).getPlanShipDate());
row.getCell(9).setCellValue(dateString);
}
}
downloadPath = machinePorcessExcelOutputDir + "安装进度" + ".xls";
downloadPathForNginx = "/excel/" + "安装进度" + ".xls";
out = new FileOutputStream(downloadPath);
wb.write(out);
out.close();
//
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if ("".equals(downloadPath)) {
return ResultGenerator.genFailResult("异常导出失败!");
} else {
return ResultGenerator.genSuccessResult(downloadPathForNginx);
}
}
use of com.eservice.api.model.machine.MachineInfo in project sinsim by WilsonHu.
the class MachineController method selectProcessMachine.
@PostMapping("/selectProcessMachine")
public Result selectProcessMachine(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Integer order_id, String orderNum, String contractNum, String machine_strid, String nameplate, String location, Byte status, String query_start_time, String query_finish_time, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
PageHelper.startPage(page, size);
List<MachineInfo> list = machineService.selectProcessMachine(order_id, orderNum, contractNum, machine_strid, nameplate, location, status, query_start_time, query_finish_time, is_fuzzy);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
use of com.eservice.api.model.machine.MachineInfo in project sinsim by WilsonHu.
the class MachineController method selectConfigMachine.
//
@PostMapping("/selectConfigMachine")
public Result selectConfigMachine(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Integer order_id, String orderNum, String contractNum, String machine_strid, String nameplate, Integer machineType, String location, Byte status, String query_start_time, String query_finish_time, @RequestParam(defaultValue = "0") Integer configStatus, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
PageHelper.startPage(page, size);
List<MachineInfo> list = machineService.selectConfigMachine(order_id, orderNum, contractNum, machine_strid, nameplate, machineType, location, status, query_start_time, query_finish_time, configStatus, is_fuzzy);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
use of com.eservice.api.model.machine.MachineInfo in project sinsim by WilsonHu.
the class MachineController method selectProcessMachine.
@PostMapping("/selectProcessMachine")
public Result selectProcessMachine(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Integer order_id, String orderNum, String contractNum, String machine_strid, String nameplate, String location, // /支持多个状态用逗号隔开, "2,3,4"
String status, String query_start_time, String query_finish_time, // 工序集合,逗号分隔,支持UI按多个工序查询
String taskNameList, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
PageHelper.startPage(page, size);
List<MachineInfo> list = machineService.selectProcessMachine(order_id, orderNum, contractNum, machine_strid, nameplate, location, status, query_start_time, query_finish_time, taskNameList, is_fuzzy);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
Aggregations