|
|
@ -0,0 +1,605 @@ |
|
|
|
package org.jeecg.modules.apiService.impl; |
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
import org.apache.poi.ss.usermodel.Sheet; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
import org.jeecg.modules.apiService.ExcelService; |
|
|
|
import org.jeecg.modules.workorderGeneralStepfour.entity.WorkorderGeneralStepfour; |
|
|
|
import org.jeecg.modules.workorderGeneralStepfour.service.IWorkorderGeneralStepfourService; |
|
|
|
import org.jeecg.modules.workorderGeneralStepone.entity.WorkorderGeneralStepone; |
|
|
|
import org.jeecg.modules.workorderGeneralStepone.service.IWorkorderGeneralSteponeService; |
|
|
|
import org.jeecg.modules.workorderGeneralStepthree.entity.WorkorderGeneralStepthree; |
|
|
|
import org.jeecg.modules.workorderGeneralStepthree.service.IWorkorderGeneralStepthreeService; |
|
|
|
import org.jeecg.modules.workorderGeneralSteptwo.entity.WorkorderGeneralSteptwo; |
|
|
|
import org.jeecg.modules.workorderGeneralSteptwo.service.IWorkorderGeneralSteptwoService; |
|
|
|
import org.jeecg.modules.workorderItemCheck.entity.WorkorderItemCheck; |
|
|
|
import org.jeecg.modules.workorderItemCheck.service.IWorkorderItemCheckService; |
|
|
|
import org.jeecg.modules.workorderParamStepfour.entity.WorkorderParamStepfour; |
|
|
|
import org.jeecg.modules.workorderParamStepfour.service.IWorkorderParamStepfourService; |
|
|
|
import org.jeecg.modules.workorderParamStepone.entity.WorkorderParamStepone; |
|
|
|
import org.jeecg.modules.workorderParamStepone.service.IWorkorderParamSteponeService; |
|
|
|
import org.jeecg.modules.workorderParamStepthree.entity.WorkorderParamStepthree; |
|
|
|
import org.jeecg.modules.workorderParamStepthree.service.IWorkorderParamStepthreeService; |
|
|
|
import org.jeecg.modules.workorderParamSteptwo.entity.WorkorderParamSteptwo; |
|
|
|
import org.jeecg.modules.workorderParamSteptwo.service.IWorkorderParamSteptwoService; |
|
|
|
import org.jeecg.modules.workorderProcess.entity.WorkorderProcess; |
|
|
|
import org.jeecg.modules.workorderProcess.service.IWorkorderProcessService; |
|
|
|
import org.jeecg.modules.workorderStep.entity.WorkorderStep; |
|
|
|
import org.jeecg.modules.workorderStep.service.IWorkorderStepService; |
|
|
|
import org.jeecg.modules.workorderTemplate.entity.WorkorderTemplate; |
|
|
|
import org.jeecg.modules.workorderTemplate.service.IWorkorderTemplateService; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class ExcelServiceImpl implements ExcelService { |
|
|
|
|
|
|
|
//工单信息 |
|
|
|
@Resource |
|
|
|
private IWorkorderTemplateService workorderTemplateService; |
|
|
|
|
|
|
|
//工序卡信息 |
|
|
|
@Resource |
|
|
|
private IWorkorderStepService workorderStepService; |
|
|
|
|
|
|
|
//工序流程信息 |
|
|
|
@Resource |
|
|
|
private IWorkorderProcessService workorderProcessService; |
|
|
|
|
|
|
|
//检查项目信息 |
|
|
|
@Resource |
|
|
|
private IWorkorderItemCheckService workorderItemCheckService; |
|
|
|
|
|
|
|
//工序卡常规参数 |
|
|
|
@Resource |
|
|
|
private IWorkorderGeneralSteponeService workorderGeneralSteponeService; |
|
|
|
@Resource |
|
|
|
private IWorkorderGeneralSteptwoService workorderGeneralSteptwoService; |
|
|
|
@Resource |
|
|
|
private IWorkorderGeneralStepthreeService workorderGeneralStepthreeService; |
|
|
|
@Resource |
|
|
|
private IWorkorderGeneralStepfourService workorderGeneralStepfourService; |
|
|
|
|
|
|
|
//工序卡列表参数 |
|
|
|
@Resource |
|
|
|
private IWorkorderParamSteponeService workorderParamSteponeService; |
|
|
|
@Resource |
|
|
|
private IWorkorderParamSteptwoService workorderParamSteptwoService; |
|
|
|
@Resource |
|
|
|
private IWorkorderParamStepthreeService workorderParamStepthreeService; |
|
|
|
@Resource |
|
|
|
private IWorkorderParamStepfourService workorderParamStepfourService; |
|
|
|
/******************************************************************************************************************/ |
|
|
|
/**********************************************主体入口************************************************************/ |
|
|
|
//工单导入 |
|
|
|
@Override |
|
|
|
public Result<?> templateImport(String path) { |
|
|
|
try { |
|
|
|
//1、获取excel数据 |
|
|
|
List<WorkorderTemplate> templateList = getImportData(path); |
|
|
|
|
|
|
|
//2、将数据录入到数据库 |
|
|
|
Boolean result = workorderTemplateService.saveBatch(templateList); |
|
|
|
if(result){ |
|
|
|
return Result.OK("数据导入成功!"); |
|
|
|
}else { |
|
|
|
return Result.error("数据导入失败!"); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return Result.error("数据导入失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//工单导出 |
|
|
|
@Override |
|
|
|
public Result<?> templateExport(String templateId) { |
|
|
|
try { |
|
|
|
template(templateId); |
|
|
|
System.out.println("test over!"); |
|
|
|
return Result.OK("导出成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return Result.OK("导出失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/******************************************************************************************************************/ |
|
|
|
/**********************************************工单导入************************************************************/ |
|
|
|
//获取导入工单数据 |
|
|
|
public List<WorkorderTemplate> getImportData(String path) throws Exception{ |
|
|
|
//path = "F:\\temp\\工单导入测试数据.xlsx"; |
|
|
|
//工单列表 |
|
|
|
List<WorkorderTemplate> templateList = new ArrayList<>(); |
|
|
|
|
|
|
|
//创建文件流 |
|
|
|
InputStream fileInputStream = null; |
|
|
|
try{ |
|
|
|
//获取文件流 |
|
|
|
fileInputStream = new FileInputStream(path); |
|
|
|
|
|
|
|
//1、创建一个工作簿 |
|
|
|
Workbook workbook = new XSSFWorkbook(fileInputStream); |
|
|
|
//2、得到一个工作表 |
|
|
|
Sheet sheet = workbook.getSheetAt(0); |
|
|
|
|
|
|
|
//3、获取表中内容 |
|
|
|
//3.1、获取表中有多少行数据 |
|
|
|
int rowCount = sheet.getPhysicalNumberOfRows(); |
|
|
|
for (int rowNum = 1; rowNum < rowCount; rowNum++) { |
|
|
|
WorkorderTemplate template = new WorkorderTemplate(); |
|
|
|
Row rowData = sheet.getRow(rowNum); |
|
|
|
if(rowData != null){ |
|
|
|
template.setTaskNo(rowData.getCell(0).getStringCellValue()); |
|
|
|
template.setResponsibler(rowData.getCell(1).getStringCellValue()); |
|
|
|
template.setModel(rowData.getCell(2).getStringCellValue()); |
|
|
|
template.setNumber((int)rowData.getCell(3).getNumericCellValue()); |
|
|
|
} |
|
|
|
templateList.add(template); |
|
|
|
} |
|
|
|
|
|
|
|
return templateList; |
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
return null; |
|
|
|
}finally { |
|
|
|
if(null != fileInputStream){ |
|
|
|
//操作结束,关闭文件 |
|
|
|
fileInputStream.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************************************************/ |
|
|
|
/**********************************************工单导出************************************************************/ |
|
|
|
//创建工作表 |
|
|
|
public void template(String templateId) throws Exception{ |
|
|
|
//创建一个工作表 |
|
|
|
Workbook workbook = new SXSSFWorkbook(); |
|
|
|
|
|
|
|
//编辑工作表内容 |
|
|
|
sheet(workbook, templateId); |
|
|
|
|
|
|
|
//导出工作表 |
|
|
|
FileOutputStream out = new FileOutputStream("F:\\temp\\test0001.xlsx"); |
|
|
|
workbook.write(out); |
|
|
|
|
|
|
|
//操作结束,关闭文件流 |
|
|
|
out.close(); |
|
|
|
|
|
|
|
//清除临时文件 |
|
|
|
((SXSSFWorkbook) workbook).dispose(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//工作簿 |
|
|
|
public void sheet(Workbook workbook, String templateId) { |
|
|
|
WorkorderTemplate template = getExportData(templateId); |
|
|
|
|
|
|
|
int stepCount = template.getWorkorderStepList().size();//工序卡数量 |
|
|
|
for (int stepNum = 0; stepNum < stepCount; stepNum++) { |
|
|
|
int lineNum = 0;//写入单元行 |
|
|
|
int firstLine= 0;//合并单元起始行 |
|
|
|
String stepName = template.getWorkorderStepList().get(stepNum).getName();//工序卡名称 |
|
|
|
Sheet sheet = workbook.createSheet(stepName);//创建工序卡 |
|
|
|
int processCount = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().size();//工序数量 |
|
|
|
//工序卡1 |
|
|
|
String stepId = template.getWorkorderStepList().get(stepNum).getId();//工序卡id |
|
|
|
for (int processNum = 0; processNum < processCount; processNum++) { |
|
|
|
int line = 0;//合并行数(检查项目) |
|
|
|
//工序 |
|
|
|
String p_stepId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getStepId();//关联工序卡id |
|
|
|
if(p_stepId.equals(stepId)){ |
|
|
|
String processId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getId();//工序id |
|
|
|
String processName = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getName();//工序名称 |
|
|
|
int itemCheckCount = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().size();//检查项目数量 |
|
|
|
|
|
|
|
for (int itemNum = 0; itemNum < itemCheckCount; itemNum++) { |
|
|
|
//检查项目 |
|
|
|
String i_processId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getProcessId();//关联工序id |
|
|
|
if(i_processId.equals(processId)){ |
|
|
|
line++; |
|
|
|
String itemCheckId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getId();//检查项目id |
|
|
|
String itemCheckName = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getName();//检查项目名称 |
|
|
|
int paramOneCount = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamSteponeList().size(); |
|
|
|
for (int paramNum = 0; paramNum < paramOneCount; paramNum++) { |
|
|
|
String p_itemCheckId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamSteponeList().get(paramNum).getProcessId();//关联检查项目id |
|
|
|
if(p_itemCheckId.equals(itemCheckId)){ |
|
|
|
//检查项目参数-工序卡1 |
|
|
|
WorkorderParamStepone paramStepone = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamSteponeList().get(paramNum); |
|
|
|
if (null != paramStepone) { |
|
|
|
//第n行 |
|
|
|
//int lineNum = (stepNum * processCount * itemCheckCount) + (itemCheckCount * itemNum) + itemNum; |
|
|
|
Row row = sheet.createRow((lineNum)); |
|
|
|
//第n行第n列 |
|
|
|
Cell process = row.createCell(0); |
|
|
|
process.setCellValue(processName); |
|
|
|
Cell itemCheck = row.createCell(1); |
|
|
|
itemCheck.setCellValue(itemCheckName); |
|
|
|
Cell specs = row.createCell(2); |
|
|
|
specs.setCellValue(paramStepone.getSpecs()); |
|
|
|
Cell param1 = row.createCell(3); |
|
|
|
param1.setCellValue(paramStepone.getParam1()); |
|
|
|
Cell param2 = row.createCell(4); |
|
|
|
param2.setCellValue(paramStepone.getParam2()); |
|
|
|
Cell param3 = row.createCell(5); |
|
|
|
param3.setCellValue(paramStepone.getParam3()); |
|
|
|
Cell param4 = row.createCell(6); |
|
|
|
param4.setCellValue(paramStepone.getParam4()); |
|
|
|
Cell param5 = row.createCell(7); |
|
|
|
param5.setCellValue(paramStepone.getParam5()); |
|
|
|
Cell param6 = row.createCell(8); |
|
|
|
param6.setCellValue(paramStepone.getParam6()); |
|
|
|
Cell param7 = row.createCell(9); |
|
|
|
param7.setCellValue(paramStepone.getParam7()); |
|
|
|
Cell param8 = row.createCell(10); |
|
|
|
param8.setCellValue(paramStepone.getParam8()); |
|
|
|
Cell param9 = row.createCell(11); |
|
|
|
param9.setCellValue(paramStepone.getParam9()); |
|
|
|
Cell param10 = row.createCell(12); |
|
|
|
param10.setCellValue(paramStepone.getParam10()); |
|
|
|
Cell param11 = row.createCell(13); |
|
|
|
param11.setCellValue(paramStepone.getParam11()); |
|
|
|
Cell param12 = row.createCell(14); |
|
|
|
param12.setCellValue(paramStepone.getParam12()); |
|
|
|
Cell param13 = row.createCell(15); |
|
|
|
param13.setCellValue(paramStepone.getParam13()); |
|
|
|
Cell param14 = row.createCell(16); |
|
|
|
param14.setCellValue(paramStepone.getParam14()); |
|
|
|
Cell param15 = row.createCell(17); |
|
|
|
param15.setCellValue(paramStepone.getParam15()); |
|
|
|
Cell param16 = row.createCell(18); |
|
|
|
param16.setCellValue(paramStepone.getParam16()); |
|
|
|
Cell param17 = row.createCell(19); |
|
|
|
param17.setCellValue(paramStepone.getParam17()); |
|
|
|
Cell param18 = row.createCell(20); |
|
|
|
param18.setCellValue(paramStepone.getParam18()); |
|
|
|
Cell param19 = row.createCell(21); |
|
|
|
param19.setCellValue(paramStepone.getParam19()); |
|
|
|
Cell param20 = row.createCell(22); |
|
|
|
param20.setCellValue(paramStepone.getParam20()); |
|
|
|
Cell remark = row.createCell(23); |
|
|
|
remark.setCellValue(paramStepone.getRemark()); |
|
|
|
lineNum++; |
|
|
|
} else { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//检查项目参数-工序卡2 |
|
|
|
int paramTwoCount = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamSteptwoList().size(); |
|
|
|
for (int paramNum = 0; paramNum < paramTwoCount; paramNum++) { |
|
|
|
String p_itemCheckId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamSteptwoList().get(paramNum).getProcessId();//关联检查项目id |
|
|
|
if(p_itemCheckId.equals(itemCheckId)){ |
|
|
|
//工序卡1 |
|
|
|
WorkorderParamSteptwo paramSteptwo = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamSteptwoList().get(paramNum); |
|
|
|
if (null != paramSteptwo) { |
|
|
|
//第n行 |
|
|
|
//int lineNum = (stepNum * processCount * itemCheckCount) + (itemCheckCount * itemNum) + itemNum; |
|
|
|
Row row = sheet.createRow((lineNum)); |
|
|
|
//第n行第n列 |
|
|
|
Cell process = row.createCell(0); |
|
|
|
process.setCellValue(processName); |
|
|
|
Cell itemCheck = row.createCell(1); |
|
|
|
itemCheck.setCellValue(itemCheckName); |
|
|
|
Cell specs = row.createCell(2); |
|
|
|
specs.setCellValue(paramSteptwo.getSpecs()); |
|
|
|
Cell param1 = row.createCell(3); |
|
|
|
param1.setCellValue(paramSteptwo.getParam1()); |
|
|
|
Cell param2 = row.createCell(4); |
|
|
|
param2.setCellValue(paramSteptwo.getParam2()); |
|
|
|
Cell param3 = row.createCell(5); |
|
|
|
param3.setCellValue(paramSteptwo.getParam3()); |
|
|
|
Cell param4 = row.createCell(6); |
|
|
|
param4.setCellValue(paramSteptwo.getParam4()); |
|
|
|
Cell param5 = row.createCell(7); |
|
|
|
param5.setCellValue(paramSteptwo.getParam5()); |
|
|
|
Cell param6 = row.createCell(8); |
|
|
|
param6.setCellValue(paramSteptwo.getParam6()); |
|
|
|
Cell param7 = row.createCell(9); |
|
|
|
param7.setCellValue(paramSteptwo.getParam7()); |
|
|
|
Cell param8 = row.createCell(10); |
|
|
|
param8.setCellValue(paramSteptwo.getParam8()); |
|
|
|
Cell param9 = row.createCell(11); |
|
|
|
param9.setCellValue(paramSteptwo.getParam9()); |
|
|
|
Cell param10 = row.createCell(12); |
|
|
|
param10.setCellValue(paramSteptwo.getParam10()); |
|
|
|
Cell operator = row.createCell(23); |
|
|
|
operator.setCellValue(paramSteptwo.getOperator()); |
|
|
|
lineNum++; |
|
|
|
} else { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//检查项目参数-工序卡3 |
|
|
|
int paramThreeCount = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamStepthreeList().size(); |
|
|
|
for (int paramNum = 0; paramNum < paramThreeCount; paramNum++) { |
|
|
|
String p_itemCheckId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamStepthreeList().get(paramNum).getProcessId();//关联检查项目id |
|
|
|
if(p_itemCheckId.equals(itemCheckId)){ |
|
|
|
//工序卡1 |
|
|
|
WorkorderParamStepthree paramStepthree = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamStepthreeList().get(paramNum); |
|
|
|
if (null != paramStepthree) { |
|
|
|
//第n行 |
|
|
|
//int lineNum = (stepNum * processCount * itemCheckCount) + (itemCheckCount * itemNum) + itemNum; |
|
|
|
Row row = sheet.createRow((lineNum)); |
|
|
|
//第n行第n列 |
|
|
|
Cell process = row.createCell(0); |
|
|
|
process.setCellValue(processName); |
|
|
|
Cell itemCheck = row.createCell(1); |
|
|
|
itemCheck.setCellValue(itemCheckName); |
|
|
|
Cell specs = row.createCell(2); |
|
|
|
specs.setCellValue(paramStepthree.getSpecs()); |
|
|
|
Cell param1 = row.createCell(3); |
|
|
|
param1.setCellValue(paramStepthree.getParam1()); |
|
|
|
Cell param2 = row.createCell(4); |
|
|
|
param2.setCellValue(paramStepthree.getParam2()); |
|
|
|
Cell param3 = row.createCell(5); |
|
|
|
param3.setCellValue(paramStepthree.getParam3()); |
|
|
|
Cell param4 = row.createCell(6); |
|
|
|
param4.setCellValue(paramStepthree.getParam4()); |
|
|
|
Cell param5 = row.createCell(7); |
|
|
|
param5.setCellValue(paramStepthree.getParam5()); |
|
|
|
Cell param6 = row.createCell(8); |
|
|
|
param6.setCellValue(paramStepthree.getParam6()); |
|
|
|
Cell param7 = row.createCell(9); |
|
|
|
param7.setCellValue(paramStepthree.getParam7()); |
|
|
|
Cell param8 = row.createCell(10); |
|
|
|
param8.setCellValue(paramStepthree.getParam8()); |
|
|
|
Cell param9 = row.createCell(11); |
|
|
|
param9.setCellValue(paramStepthree.getParam9()); |
|
|
|
Cell param10 = row.createCell(12); |
|
|
|
param10.setCellValue(paramStepthree.getParam10()); |
|
|
|
Cell operator = row.createCell(23); |
|
|
|
operator.setCellValue(paramStepthree.getOperator()); |
|
|
|
lineNum++; |
|
|
|
} else { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//检查项目参数-工序卡4 |
|
|
|
int paramFourCount = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamStepfourList().size(); |
|
|
|
for (int paramNum = 0; paramNum < paramFourCount; paramNum++) { |
|
|
|
String p_itemCheckId = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamStepfourList().get(paramNum).getProcessId();//关联检查项目id |
|
|
|
if(p_itemCheckId.equals(itemCheckId)){ |
|
|
|
//工序卡1 |
|
|
|
WorkorderParamStepfour paramStepfour = template.getWorkorderStepList().get(stepNum).getWorkorderProcessList().get(processNum).getWorkorderItemCheckList().get(itemNum).getWorkorderParamStepfourList().get(paramNum); |
|
|
|
if (null != paramStepfour) { |
|
|
|
//第n行 |
|
|
|
//int lineNum = (stepNum * processCount * itemCheckCount) + (itemCheckCount * itemNum) + itemNum; |
|
|
|
Row row = sheet.createRow((lineNum)); |
|
|
|
//第n行第n列 |
|
|
|
Cell process = row.createCell(0); |
|
|
|
process.setCellValue(processName); |
|
|
|
Cell itemCheck = row.createCell(1); |
|
|
|
itemCheck.setCellValue(itemCheckName); |
|
|
|
Cell specs = row.createCell(2); |
|
|
|
specs.setCellValue(paramStepfour.getSpecs()); |
|
|
|
Cell param1 = row.createCell(3); |
|
|
|
param1.setCellValue(paramStepfour.getParam1()); |
|
|
|
Cell param2 = row.createCell(4); |
|
|
|
param2.setCellValue(paramStepfour.getParam2()); |
|
|
|
Cell param3 = row.createCell(5); |
|
|
|
param3.setCellValue(paramStepfour.getParam3()); |
|
|
|
Cell param4 = row.createCell(6); |
|
|
|
param4.setCellValue(paramStepfour.getParam4()); |
|
|
|
Cell param5 = row.createCell(7); |
|
|
|
param5.setCellValue(paramStepfour.getParam5()); |
|
|
|
Cell param6 = row.createCell(8); |
|
|
|
param6.setCellValue(paramStepfour.getParam6()); |
|
|
|
Cell param7 = row.createCell(9); |
|
|
|
param7.setCellValue(paramStepfour.getParam7()); |
|
|
|
Cell param8 = row.createCell(10); |
|
|
|
param8.setCellValue(paramStepfour.getParam8()); |
|
|
|
Cell param9 = row.createCell(11); |
|
|
|
param9.setCellValue(paramStepfour.getParam9()); |
|
|
|
Cell param10 = row.createCell(12); |
|
|
|
param10.setCellValue(paramStepfour.getParam10()); |
|
|
|
Cell operator = row.createCell(23); |
|
|
|
operator.setCellValue(paramStepfour.getOperator()); |
|
|
|
lineNum++; |
|
|
|
} else { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(firstLine,firstLine+line,0,0));//合并单元格 |
|
|
|
firstLine = firstLine+line+1;//改变下一个起始行位置 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取数据 |
|
|
|
public WorkorderTemplate getExportData(String templateId){ |
|
|
|
//查询工单信息 |
|
|
|
WorkorderTemplate workorderTemplate = workorderTemplateService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderTemplate::getId, templateId) |
|
|
|
.one(); |
|
|
|
|
|
|
|
//查询工序卡信息 |
|
|
|
List<WorkorderStep> stepList = workorderStepService |
|
|
|
.lambdaQuery() |
|
|
|
.list(); |
|
|
|
|
|
|
|
//查询工序信息 |
|
|
|
List<WorkorderProcess> processList = workorderProcessService |
|
|
|
.lambdaQuery() |
|
|
|
.list(); |
|
|
|
|
|
|
|
//查询检查项目信息 |
|
|
|
List<WorkorderItemCheck> itemCheckList = workorderItemCheckService |
|
|
|
.lambdaQuery() |
|
|
|
.list(); |
|
|
|
|
|
|
|
//根据工单id查询常规参数 |
|
|
|
List<WorkorderGeneralStepone> GeneralSteponeList = workorderGeneralSteponeService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderGeneralStepone::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
List<WorkorderGeneralSteptwo> GeneralSteptwoList = workorderGeneralSteptwoService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderGeneralSteptwo::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
List<WorkorderGeneralStepthree> GeneralStepthreeList = workorderGeneralStepthreeService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderGeneralStepthree::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
List<WorkorderGeneralStepfour> GeneralStepfourList = workorderGeneralStepfourService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderGeneralStepfour::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
|
|
|
|
//根据工单id查询检查项目参数 |
|
|
|
List<WorkorderParamStepone> paramSteponeList = workorderParamSteponeService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderParamStepone::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
List<WorkorderParamSteptwo> paramSteptwoList = workorderParamSteptwoService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderParamSteptwo::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
List<WorkorderParamStepthree> paramStepthreeList = workorderParamStepthreeService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderParamStepthree::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
List<WorkorderParamStepfour> paramStepfourList = workorderParamStepfourService |
|
|
|
.lambdaQuery() |
|
|
|
.eq(WorkorderParamStepfour::getTemplateId, templateId) |
|
|
|
.list(); |
|
|
|
|
|
|
|
//一、将检查项目参数对象放入对应检查项目对象下 |
|
|
|
for (WorkorderItemCheck workorderItemCheck : itemCheckList) { |
|
|
|
//工序卡1 |
|
|
|
List<WorkorderParamStepone> workorderParamSteponeList = new ArrayList<>(); |
|
|
|
for (WorkorderParamStepone workorderParamStepone : paramSteponeList) { |
|
|
|
if(workorderParamStepone.getProcessId().equals(workorderItemCheck.getId()) ){ |
|
|
|
workorderParamSteponeList.add(workorderParamStepone); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderItemCheck.setWorkorderParamSteponeList(workorderParamSteponeList); |
|
|
|
|
|
|
|
//工序卡2 |
|
|
|
List<WorkorderParamSteptwo> workorderParamSteptwoList = new ArrayList<>(); |
|
|
|
for (WorkorderParamSteptwo workorderParamSteptwo : paramSteptwoList) { |
|
|
|
if(workorderParamSteptwo.getProcessId().equals(workorderItemCheck.getId())){ |
|
|
|
workorderParamSteptwoList.add(workorderParamSteptwo); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderItemCheck.setWorkorderParamSteptwoList(workorderParamSteptwoList); |
|
|
|
|
|
|
|
//工序卡3 |
|
|
|
List<WorkorderParamStepthree> workorderParamStepthreeList = new ArrayList<>(); |
|
|
|
for (WorkorderParamStepthree workorderParamStepthree : paramStepthreeList) { |
|
|
|
if(workorderParamStepthree.getProcessId().equals(workorderItemCheck.getId())){ |
|
|
|
workorderParamStepthreeList.add(workorderParamStepthree); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderItemCheck.setWorkorderParamStepthreeList(workorderParamStepthreeList); |
|
|
|
|
|
|
|
//工序卡4 |
|
|
|
List<WorkorderParamStepfour> workorderParamStepfourList = new ArrayList<>(); |
|
|
|
for (WorkorderParamStepfour workorderParamStepfour : paramStepfourList) { |
|
|
|
if(workorderParamStepfour.getProcessId().equals(workorderItemCheck.getId())){ |
|
|
|
workorderParamStepfourList.add(workorderParamStepfour); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderItemCheck.setWorkorderParamStepfourList(workorderParamStepfourList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//二、将检查项目对象放入对应工序流程对象下 |
|
|
|
for (WorkorderProcess workorderProcess : processList) { |
|
|
|
List<WorkorderItemCheck> workorderItemCheckList = new ArrayList<>(); |
|
|
|
for (WorkorderItemCheck workorderItemCheck : itemCheckList) { |
|
|
|
if(workorderItemCheck.getProcessId().equals(workorderProcess.getId())){ |
|
|
|
workorderItemCheckList.add(workorderItemCheck); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderProcess.setWorkorderItemCheckList(workorderItemCheckList); |
|
|
|
} |
|
|
|
|
|
|
|
//三、将工序流程对象放入对应工序卡对象下 |
|
|
|
for (WorkorderStep workorderStep : stepList) { |
|
|
|
//工序参数 |
|
|
|
List<WorkorderProcess> workorderProcessList = new ArrayList<>(); |
|
|
|
for (WorkorderProcess workorderProcess : processList) { |
|
|
|
if (workorderProcess.getStepId().equals(workorderStep.getId())) { |
|
|
|
workorderProcessList.add(workorderProcess); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderStep.setWorkorderProcessList(workorderProcessList); |
|
|
|
|
|
|
|
//常规参数(待优化--冗余list) |
|
|
|
//工序卡1 |
|
|
|
List<WorkorderGeneralStepone> workorderGeneralSteponeList = new ArrayList<>(); |
|
|
|
for (WorkorderGeneralStepone generalStepone : GeneralSteponeList) { |
|
|
|
if (generalStepone.getStepId().equals(workorderStep.getId())) { |
|
|
|
workorderGeneralSteponeList.add(generalStepone); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderStep.setWorkorderGeneralSteponeList(workorderGeneralSteponeList); |
|
|
|
|
|
|
|
//工序卡2 |
|
|
|
List<WorkorderGeneralSteptwo> workorderGeneralSteptwoList = new ArrayList<>(); |
|
|
|
for (WorkorderGeneralSteptwo generalSteptwo : GeneralSteptwoList) { |
|
|
|
if (generalSteptwo.getStepId().equals(workorderStep.getId())) { |
|
|
|
workorderGeneralSteptwoList.add(generalSteptwo); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderStep.setWorkorderGeneralSteptwoList(workorderGeneralSteptwoList); |
|
|
|
|
|
|
|
//工序卡3 |
|
|
|
List<WorkorderGeneralStepthree> workorderGeneralStepthreeList = new ArrayList<>(); |
|
|
|
for (WorkorderGeneralStepthree generalStepthree : GeneralStepthreeList) { |
|
|
|
if (generalStepthree.getStepId().equals(workorderStep.getId())) { |
|
|
|
workorderGeneralStepthreeList.add(generalStepthree); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderStep.setWorkorderGeneralStepthreeList(workorderGeneralStepthreeList); |
|
|
|
|
|
|
|
//工序卡4 |
|
|
|
List<WorkorderGeneralStepfour> workorderGeneralStepfourList = new ArrayList<>(); |
|
|
|
for (WorkorderGeneralStepfour generalStepfour : GeneralStepfourList) { |
|
|
|
if (generalStepfour.getStepId().equals(workorderStep.getId())) { |
|
|
|
workorderGeneralStepfourList.add(generalStepfour); |
|
|
|
} |
|
|
|
} |
|
|
|
workorderStep.setWorkorderGeneralStepfourList(workorderGeneralStepfourList); |
|
|
|
} |
|
|
|
|
|
|
|
//四、将工序卡对象放入对应工单对象下 |
|
|
|
workorderTemplate.setWorkorderStepList(stepList); |
|
|
|
|
|
|
|
return workorderTemplate; |
|
|
|
} |
|
|
|
|
|
|
|
} |