use of com.eservice.api.model.machine_type.MachineType in project sinsim by WilsonHu.
the class MachineOrderController method exportToSaleExcel.
@PostMapping("/exportToSaleExcel")
public Result exportToSaleExcel(Integer id, Integer contract_id, String order_num, String contract_num, String status, String sellman, String customer, String marketGroupName, // 这个是查询创建日期
String query_start_time, // 这个是查询创建日期
String query_finish_time, // 这个是查询审核日期
String queryStartTimeSign, // 这个是查询审核日期
String queryFinishTimeSign, String machine_name, String oderSignCurrentStep, String searchDepartment, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
List<MachineOrderDetail> list = machineOrderService.selectOrder(id, contract_id, order_num, contract_num, status, sellman, customer, marketGroupName, query_start_time, query_finish_time, queryStartTimeSign, queryFinishTimeSign, machine_name, oderSignCurrentStep, searchDepartment, is_fuzzy);
HSSFWorkbook wb = null;
FileOutputStream out = null;
String downloadPath = "";
/*
返回给docker外部下载
*/
String downloadPathForNginx = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
try {
// 生成一个空的Excel文件
wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("销售报表");
// 设置标题行格式
HSSFCellStyle headcellstyle = wb.createCellStyle();
HSSFFont headfont = wb.createFont();
headfont.setFontHeightInPoints((short) 10);
// 粗体显示
headfont.setBold(true);
headcellstyle.setFont(headfont);
Row row;
// 新创建一行,行号为row+1
row = sheet1.createRow(0);
int columnSum = 22;
for (int c = 0; c < columnSum; c++) {
// 列头
// 创建一个单元格,列号为col+1
row.createCell(c);
sheet1.setColumnWidth(c, 4500);
sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
}
// 第一行为标题
int columnX = 0;
sheet1.getRow(0).getCell(columnX++).setCellValue("客户");
sheet1.getRow(0).getCell(columnX++).setCellValue("国家");
sheet1.getRow(0).getCell(columnX++).setCellValue("部门");
sheet1.getRow(0).getCell(columnX++).setCellValue("合同号");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单号");
// sheet1.getRow(0).getCell(3).setCellValue("铭牌号");
sheet1.getRow(0).getCell(columnX++).setCellValue("机器信息");
sheet1.getRow(0).getCell(columnX++).setCellValue("台数");
sheet1.getRow(0).getCell(columnX++).setCellValue("单价");
sheet1.getRow(0).getCell(columnX++).setCellValue("装置");
sheet1.getRow(0).getCell(columnX++).setCellValue("装置数量");
sheet1.getRow(0).getCell(columnX++).setCellValue("装置总价");
sheet1.getRow(0).getCell(columnX++).setCellValue("优惠金额");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单总金额(美元)");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单总金额(人民币)");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单总金额(欧元)");
// sheet1.getRow(0).getCell(columnX++).setCellValue("币种");
sheet1.getRow(0).getCell(columnX++).setCellValue("销售员");
// 销售费
sheet1.getRow(0).getCell(columnX++).setCellValue("业务费");
sheet1.getRow(0).getCell(columnX++).setCellValue("付款方式");
sheet1.getRow(0).getCell(columnX++).setCellValue("毛利");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单类型");
sheet1.getRow(0).getCell(columnX++).setCellValue("保修费");
sheet1.getRow(0).getCell(columnX++).setCellValue("签核完成时间");
DataFormat dataFormat = wb.createDataFormat();
CellStyle cellStyle;
HSSFCellStyle wrapStyle = wb.createCellStyle();
wrapStyle.setWrapText(true);
// 第二行开始,填入值
// 各订单的装置数量-合计
int allOrdersEquipmentCount = 0;
// 各订单的装置总价-合计
int allOrdersEquipemntAmountCount = 0;
// 各订单的优惠金额-合计
int allOrdersDiscountCount = 0;
// 各订单订单总金额(美元) 合计
int allOrdersTotalPriceCount_USD = 0;
// 各订单订单总金额(人民币)合计
int allOrdersTotalPriceCount_RMB = 0;
// 各订单订单总金额(欧元)合计
int allOrdersTotalPriceCount_EUR = 0;
cellStyle = wb.createCellStyle();
// 金额格式
cellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
for (int i = 0; i < list.size(); i++) {
String dateStringSignFinish = "未完成签核";
int r = i + 1;
MachineOrderDetail mod = list.get(i);
// 新创建一行
row = sheet1.createRow(r);
for (int c = 0; c < columnSum; c++) {
// 创建列单元格
row.createCell(c);
}
// 合同的内容也用到
Contract contract = contractService.findById(list.get(i).getContractId());
if (contract == null) {
logger.error("异常,根据合同ID号,查找不到合同");
return ResultGenerator.genFailResult("异常,根据合同ID号,查找不到合同");
}
// 签核也用到:签核完成时间
List<OrderSign> orderSignList = orderSignService.getOrderSignListByOrderId(mod.getOrderSign().getOrderId());
OrderSign orderSign = null;
List<SignContentItem> signContentItemList = null;
if (orderSignList.size() > 0) {
// 订单的签核记录只有在新增合同-订单时,才创建订单的签核记录,所以这里 getOrderSignListByOrderId其实只返回一个签核记录
orderSign = orderSignList.get(orderSignList.size() - 1);
if (orderSign.getCurrentStep() == null) {
logger.warn("异常,orderSign.getCurrentStep()为null, 比如测试数据手动乱改动时可能出现");
}
if (orderSign.getCurrentStep() != null && orderSign.getCurrentStep().equals("签核完成")) {
// 如果签核完成,取最后一个角色的签核时间
signContentItemList = JSON.parseArray(orderSign.getSignContent(), SignContentItem.class);
// 注意订单签核没有enable开关
if (signContentItemList.get(signContentItemList.size() - 1).getDate() != null) {
dateStringSignFinish = formatter.format(signContentItemList.get(signContentItemList.size() - 1).getDate());
} else {
logger.warn("signContentItemList.get(signContentItemList.size()-1).getDate() 是 null,比如测试数据手动乱改动时可能出现");
}
}
}
columnX = 0;
// 客户
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getCustomer());
sheet1.getRow(r).getCell(columnX++).setCellStyle(wrapStyle);
// 国家
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getCountry());
// 部门
sheet1.getRow(r).getCell(columnX++).setCellValue(contract.getMarketGroupName());
// 合同号
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getContractNum());
sheet1.getRow(r).getCell(columnX++).setCellStyle(wrapStyle);
//
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getOrderNum());
sheet1.getRow(r).getCell(columnX++).setCellStyle(wrapStyle);
// sheet1.getRow(r).getCell(3).setCellValue(mod.getNameplate());//
MachineType mt = mod.getMachineType();
if (mt != null) {
// 机器信息
String machineInfo = mt.getName() + "/" + mod.getNeedleNum() + "/" + mod.getHeadNum() + "/" + mod.getHeadDistance() + "/" + mod.getxDistance() + "/" + mod.getyDistance() + "/" + mod.getElectricTrim() + "/" + mod.getElectricPc();
//
sheet1.getRow(r).getCell(columnX++).setCellValue(machineInfo);
}
//
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getMachineNum());
//
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getMachinePrice());
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
List<Equipment> epArray = JSON.parseArray(mod.getEquipment(), Equipment.class);
String strEp = "";
// 订单内 各种装置数量之和
int equipmentCount = 0;
int epPriceAmount = 0;
for (Equipment itemEquipment : epArray) {
strEp += itemEquipment.getName() + ":" + itemEquipment.getNumber() + "个" + "\r\n";
epPriceAmount += itemEquipment.getPrice() * itemEquipment.getNumber();
equipmentCount += itemEquipment.getNumber();
}
allOrdersEquipmentCount += equipmentCount;
allOrdersEquipemntAmountCount += epPriceAmount;
// sheet1.getRow(r).getCell(columnX).setCellStyle(wrapStyle);
// 装置
sheet1.getRow(r).getCell(columnX++).setCellValue(new HSSFRichTextString(strEp));
// 装置数量
sheet1.getRow(r).getCell(columnX++).setCellValue(equipmentCount);
// 装置总价
sheet1.getRow(r).getCell(columnX).setCellValue(epPriceAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
// 优惠金额
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getDiscounts());
allOrdersDiscountCount += Integer.valueOf(mod.getDiscounts());
Double totalAmount = Double.parseDouble(mod.getMachinePrice()) * mod.getMachineNum() + epPriceAmount * mod.getMachineNum() - // 优惠金额 (需求单总价格优惠金额)
Double.parseDouble(mod.getOrderTotalDiscounts()) - // 每台的优惠金额
Double.parseDouble(mod.getDiscounts()) * mod.getMachineNum();
// - Double.parseDouble(mod.getIntermediaryPrice())*mod.getMachineNum();//每台的居间费用 和总价无关
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
if (mod.getCurrencyType().equals("美元")) {
allOrdersTotalPriceCount_USD += totalAmount;
// 总金额(美元)
sheet1.getRow(r).getCell(columnX).setCellValue(totalAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
columnX++;
//
columnX++;
}
if (mod.getCurrencyType().equals("人民币")) {
allOrdersTotalPriceCount_RMB += totalAmount;
columnX++;
// 总金额(人民币)
sheet1.getRow(r).getCell(columnX).setCellValue(totalAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
columnX++;
}
if (mod.getCurrencyType().equals("欧元")) {
allOrdersTotalPriceCount_EUR += totalAmount;
columnX++;
columnX++;
// 总金额(欧元)
sheet1.getRow(r).getCell(columnX).setCellValue(totalAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
}
// sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getCurrencyType());//币种
// 销售员
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getSellman());
// 销售费 业务费
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getBusinessExpense());
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
// 付款方式
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getPayMethod());
// 毛利率
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getGrossProfit());
// 订单类型
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getOrderType());
// 保修费
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getWarrantyFee());
// 签核完成时间
sheet1.getRow(r).getCell(columnX++).setCellValue(dateStringSignFinish);
}
// 最后一行 汇总
// 新创建一行
Row rowSum = sheet1.createRow(list.size() + 1);
for (int c = 0; c < columnSum; c++) {
// 创建列单元格
rowSum.createCell(c);
}
// 各订单的装置数量-合计
rowSum.getCell(9).setCellValue(allOrdersEquipmentCount);
// 各订单的装置总价 合计
rowSum.getCell(10).setCellValue(allOrdersEquipemntAmountCount);
rowSum.getCell(10).setCellStyle(cellStyle);
// 优惠金额 合计
rowSum.getCell(11).setCellValue(allOrdersDiscountCount);
// 订单总金额(美元) 合计
rowSum.getCell(12).setCellValue(allOrdersTotalPriceCount_USD);
rowSum.getCell(12).setCellStyle(cellStyle);
// 订单总金额(人民币)合计
rowSum.getCell(13).setCellValue(allOrdersTotalPriceCount_RMB);
rowSum.getCell(13).setCellStyle(cellStyle);
// 订单总金额(欧元)合计
rowSum.getCell(14).setCellValue(allOrdersTotalPriceCount_EUR);
rowSum.getCell(14).setCellStyle(cellStyle);
downloadPath = reportOutputPath + "销售报表" + ".xls";
downloadPathForNginx = "/report/" + "销售报表" + ".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_type.MachineType 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_type.MachineType in project sinsim by WilsonHu.
the class MachineTypeController method update.
@PostMapping("/update")
public Result update(String machineType) {
MachineType model = JSON.parseObject(machineType, MachineType.class);
Integer count = machineOrderService.getUsedMachineTypeCount(model.getId());
if (count > 0) {
// 机器被使用,检查机型的名称是否更改
MachineType typeInDB = machineTypeService.findById(model.getId());
if (typeInDB != null && typeInDB.getName().equals(model.getName())) {
// 名称没变,变的可能是是否成品机信息
machineTypeService.update(model);
ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("此机型已在使用中,不能修改!");
}
}
List<MachineType> dataList = machineTypeService.selectByName(model.getName());
if (dataList.size() > 0) {
for (MachineType item : dataList) {
if (item.getId() != model.getId()) {
return ResultGenerator.genFailResult("名称与其它机型重复,请重新输入!");
}
}
}
machineTypeService.update(model);
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.machine_type.MachineType in project sinsim by WilsonHu.
the class MachineTypeController method selectAfterN.
/**
* 查询机器类型,从第N个开始的机器类型
* 机型名称改了,之前的名称以后不用了,但是在旧订单里还要用所以无法删除。
* 返回N个之后的机型(即所有新的机型名称)用于新订单
*/
@PostMapping("/selectAfterN")
public Result selectAfterN(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
// PageHelper.startPage(page, size);// 这一行加了,会出错:IndexOutOfBoundsException: Index: 0, Size: 0
// PageHelper.startPage(page, 20);
//
List<MachineType> list = machineTypeService.selectAfterN(23);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
use of com.eservice.api.model.machine_type.MachineType in project sinsim by WilsonHu.
the class TaskRecordController method exportToExcel.
/**
* 在”生产管理”的“生产报表”导出到excel.
*/
@PostMapping("/exportToExcel")
public Result exportToExcel(Integer taskRecordId, String taskName, String machineOrderNumber, String queryStartTime, String queryFinishTime, String nameplate) {
List<TaskRecordDetail> list = taskRecordService.searchTaskRecordDetail(taskRecordId, taskName, machineOrderNumber, queryStartTime, queryFinishTime, nameplate);
HSSFWorkbook wb = null;
FileOutputStream out = null;
String downloadPath = "";
/*
返回给docker外部下载
*/
String downloadPathForNginx = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm");
String dateString;
try {
// 生成一个空的Excel文件
wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("生产报表");
// 设置标题行格式
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 < 8; c++) {
// 创建一个单元格,列号为col+1
row.createCell(c);
sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
}
}
for (int k = 1; k < 8; k++) {
sheet1.setColumnWidth(k, 4500);
}
// 第一行为标题
sheet1.getRow(0).getCell(0).setCellValue("序号");
sheet1.getRow(0).getCell(1).setCellValue("工序名称");
sheet1.getRow(0).getCell(2).setCellValue("订单号");
sheet1.getRow(0).getCell(3).setCellValue("铭牌号/机器类型/针数/头数/头距/X行程/Y行程");
sheet1.getRow(0).getCell(4).setCellValue("安装组长");
sheet1.getRow(0).getCell(5).setCellValue("开始时间");
sheet1.getRow(0).getCell(6).setCellValue("结束时间");
sheet1.getRow(0).getCell(7).setCellValue("耗时(分钟)");
// 第二行开始,填入值
MachineType machineType1 = null;
Byte taskStatus = 0;
for (int r = 0; r < list.size(); r++) {
row = sheet1.getRow(r + 1);
row.getCell(0).setCellValue(r + 1);
// 工序名称
if (list.get(r).getTaskName() != null) {
row.getCell(1).setCellValue(list.get(r).getTaskName());
}
// 订单号
if (list.get(r).getMachineOrder().getOrderNum() != null) {
row.getCell(2).setCellValue(list.get(r).getMachineOrder().getOrderNum());
}
// 机器编号等机器信息
Machine machine = list.get(r).getMachine();
MachineOrder machineOrder = list.get(r).getMachineOrder();
MachineOrderDetail machineOrderDetail = machineOrderService.getOrderAllDetail(machineOrder.getId());
if (machine != null && machineOrder != null) {
String machineInfo = machine.getNameplate() + "/" + machineOrderDetail.getMachineType().getName() + "/" + machineOrder.getNeedleNum() + "/" + machineOrder.getHeadNum() + "/" + machineOrder.getHeadDistance() + "/" + machineOrder.getxDistance() + "/" + machineOrder.getyDistance();
row.getCell(3).setCellValue(machineInfo);
}
// 安装组长
if (list.get(r).getLeader() != null) {
row.getCell(4).setCellValue(list.get(r).getLeader());
}
// 开始时间
if (list.get(r).getInstallBeginTime() != null) {
dateString = formatter.format(list.get(r).getInstallBeginTime());
row.getCell(5).setCellValue(dateString);
}
// 结束时间
if (list.get(r).getInstallEndTime() != null) {
dateString = formatter.format(list.get(r).getInstallEndTime());
row.getCell(6).setCellValue(dateString);
}
// 耗时
if (list.get(r).getInstallBeginTime() != null && list.get(r).getInstallEndTime() != null) {
long minHourDay = commonService.secondsToMin(list.get(r).getInstallEndTime().getTime() - list.get(r).getInstallBeginTime().getTime());
row.getCell(7).setCellValue(minHourDay);
}
}
downloadPath = taskRecordExcelOutputDir + "生产报表" + ".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);
}
}
Aggregations