|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
package com.op.quality.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.op.quality.domain.QcCheckProject;
|
|
|
|
|
import com.op.quality.domain.QcMaterialGroup;
|
|
|
|
|
import com.op.quality.domain.QcProjectType;
|
|
|
|
|
import com.op.common.core.domain.ExcelCol;
|
|
|
|
|
import com.op.common.core.utils.poi.ExcelMapUtil;
|
|
|
|
|
import com.op.quality.domain.*;
|
|
|
|
|
import com.op.quality.service.IQcMaterialGroupService;
|
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
@ -19,12 +23,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import com.op.common.log.annotation.Log;
|
|
|
|
|
import com.op.common.log.enums.BusinessType;
|
|
|
|
|
import com.op.common.security.annotation.RequiresPermissions;
|
|
|
|
|
import com.op.quality.domain.QcCheckTypeProject;
|
|
|
|
|
import com.op.quality.service.IQcCheckTypeProjectService;
|
|
|
|
|
import com.op.common.core.web.controller.BaseController;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.common.core.utils.poi.ExcelUtil;
|
|
|
|
|
import com.op.common.core.web.page.TableDataInfo;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 物料检验项目维护Controller
|
|
|
|
@ -127,4 +131,78 @@ public class QcCheckTypeProjectController extends BaseController {
|
|
|
|
|
List<QcProjectType> list = qcCheckTypeProjectService.getProjectOptions(qcCheckProject);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/importTemplate")
|
|
|
|
|
@Log(title = "生成订单模板", businessType = BusinessType.EXPORT)
|
|
|
|
|
public void importTemplate(HttpServletResponse response) throws IOException {
|
|
|
|
|
|
|
|
|
|
ArrayList<ExcelCol> excelCols = new ArrayList<>();
|
|
|
|
|
excelCols.add(new ExcelCol("线体编码", "lineCode", 20));
|
|
|
|
|
excelCols.add(new ExcelCol("产品编码", "productCode", 20));
|
|
|
|
|
excelCols.add(new ExcelCol("产品名称", "productName", 20));
|
|
|
|
|
excelCols.add(new ExcelCol("标准用人", "useMan", 20));
|
|
|
|
|
excelCols.add(new ExcelCol("标准效率", "efficiency", 20));
|
|
|
|
|
excelCols.add(new ExcelCol("标准工时", "attr1", 20));
|
|
|
|
|
String titleName = "线体产品信息导入";
|
|
|
|
|
SXSSFWorkbook workbook = null;
|
|
|
|
|
try {
|
|
|
|
|
//设置响应头
|
|
|
|
|
response.setHeader("Content-disposition",
|
|
|
|
|
"attachment; filename=" + titleName);
|
|
|
|
|
response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
//调用工具类
|
|
|
|
|
workbook = ExcelMapUtil.initWorkbook(titleName, null, excelCols, null);
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
if (workbook != null) {
|
|
|
|
|
workbook.dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/importMaterailTemplate")
|
|
|
|
|
public void importMaterailTemplate(HttpServletResponse response) throws IOException {
|
|
|
|
|
|
|
|
|
|
ArrayList<ExcelCol> excelCols = new ArrayList<>();
|
|
|
|
|
excelCols.add(new ExcelCol("质检物料组名称", "groupName", 50));
|
|
|
|
|
excelCols.add(new ExcelCol("物料编码", "materialCode", 50));
|
|
|
|
|
excelCols.add(new ExcelCol("物料名称", "materialName", 50));
|
|
|
|
|
String titleName = "质检物料组物料信息导入";
|
|
|
|
|
SXSSFWorkbook workbook = null;
|
|
|
|
|
try {
|
|
|
|
|
//设置响应头
|
|
|
|
|
response.setHeader("Content-disposition",
|
|
|
|
|
"attachment; filename=" + titleName);
|
|
|
|
|
response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
//调用工具类
|
|
|
|
|
workbook = ExcelMapUtil.initWorkbook(titleName, null, excelCols, null);
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
if (workbook != null) {
|
|
|
|
|
workbook.dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 导入订单信息接口
|
|
|
|
|
*
|
|
|
|
|
* @param file
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@Log(title = "导入线体产品信息", businessType = BusinessType.IMPORT)
|
|
|
|
|
@PostMapping("/importData")
|
|
|
|
|
public AjaxResult importData(MultipartFile file) throws Exception {
|
|
|
|
|
// 创建接收对象
|
|
|
|
|
ExcelUtil<QcMaterialGroupDetail> util = new ExcelUtil<>(QcMaterialGroupDetail.class);
|
|
|
|
|
// 接收表格信息
|
|
|
|
|
List<QcMaterialGroupDetail> orderList = util.importExcel(file.getInputStream());
|
|
|
|
|
return qcCheckTypeProjectService.importOrder(orderList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|