@ -1,392 +1,256 @@
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.excel ;
import cn.estsh.i3plus.mes.api.iservice.busi.IExcelImportService ;
import cn.estsh.i3plus.mes.apiservice.serviceimpl.busi.CommonService ;
import cn.estsh.i3plus.mes.apiservice.util.MesCommonUtil ;
import cn.estsh.i3plus.platform.common.convert.ConvertBean ;
import cn.estsh.i3plus.pojo.mes.bean.MesPartPtr ;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder ;
import cn.estsh.i3plus.pojo.mes.model.ExcelImportErrorModel ;
import cn.estsh.i3plus.pojo.mes.model.ExcelImportResultModel ;
import cn.estsh.i3plus.pojo.mes.repository.MesPartPtrRepository ;
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository ;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.poi.ss.usermodel.CellType ;
import org.apache.poi.ss.usermodel.Row ;
import org.apache.poi.ss.usermodel.Sheet ;
import org.apache.poi.ss.usermodel.Workbook ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
import org.springframework.util.StringUtils ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
/ * *
* @Description : MES 工 单 导 入 , BTO
* @Reference :
* @Author : junsheng . li
* @CreateDate 2024 / 5 / 16 14 : 14
* @Modify :
* * /
@Service
@Slf4j
public class MesWorkOrderBtoExcelServiceImpl implements IExcelImportService {
@Autowired
private CommonService commonService ;
@Autowired
private MesPartRepository partRepository ;
@Autowired
private MesWorkOrderRepository mesWorkOrderRDao ;
@Override
public ExcelImportResultModel insertDataByExcel ( Workbook workbook , String organizeCode , String userName ) {
//读取表格
ExcelImportResultModel excelImportResultModel = this . sheetExtractMesWorkOrder ( workbook . getSheetAt ( 0 ) , organizeCode , userName ) ;
//数据入库
this . insertExcelMesWorkOrder ( excelImportResultModel ) ;
return excelImportResultModel ;
// return null;
}
/ * *
* 工 位 BOM 表 导 入 - 读 取 表 格
*
* @param sheetAt
* @param organizeCode
* @param userName
* @return
* /
private ExcelImportResultModel sheetExtractMesWorkOrder ( Sheet sheetAt , String organizeCode , String userName ) {
//从0行开始读取
int totalNumberOfRows = sheetAt . getLastRowNum ( ) + 1 ;
//MesStationBom集合
List < MesPartPtr > partPtrList = new ArrayList < > ( ) ;
//成功数量
Integer successRowNum = 0 ;
//失败数量
Integer failRowNum = 0 ;
//错误的行号
String errorRows = "" ;
//错误行信息集合
List < ExcelImportErrorModel > excelImportErrorModels = new ArrayList < > ( ) ;
// 查询物料表
Map < String , Object > partCodeEntityMap ;
try {
partCodeEntityMap = MesCommonUtil . getCodeEntityMap ( partRepository , "partNo" , organizeCode , "物料表" ) ;
} catch ( Exception e ) {
partCodeEntityMap = null ;
}
// //查询关键件条码校验规则表
// List<MesPartPtr> partPtrList = partPtrRepository.findByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED},
// new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()});
// Map<String, List<MesPartPtr>> preventionMap =
// partPtrList.stream().collect(Collectors.groupingBy(k -> k.getPreventionObjectCode() + "&" + k.getPartNo()));
Map < String , String > map = new HashMap < > ( ) ;
for ( int i = ( sheetAt . getFirstRowNum ( ) + 1 ) ; i < totalNumberOfRows ; i + + ) {
Row row = sheetAt . getRow ( i ) ;
//空行跳过
if ( null = = row ) {
continue ;
}
//获取总列数
Short lastCellNum = row . getLastCellNum ( ) ;
if ( lastCellNum > 0 ) {
int rowNum = i + 1 ; //当前行号
int errorNum = 0 ; //错误数量
String cellNum = "" ; //错误列号
String errorInfo = "" ; //错误信息
//产线编号
String workCenterCode = row . getCell ( 0 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
//开始时间
String startTime = null ;
try {
row . getCell ( 1 ) . setCellType ( CellType . STRING ) ;
startTime = row . getCell ( 1 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//结束时间
String endTime = null ;
try {
row . getCell ( 2 ) . setCellType ( CellType . STRING ) ;
endTime = row . getCell ( 2 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//PTR车辆数量
String prtVehicleCount = null ;
try {
row . getCell ( 3 ) . setCellType ( CellType . STRING ) ;
prtVehicleCount = row . getCell ( 3 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//PTR车辆实际数量
String prtVehicleActualCount = null ;
try {
row . getCell ( 4 ) . setCellType ( CellType . STRING ) ;
prtVehicleActualCount = row . getCell ( 4 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//原零件号
String sourcePartNo = null ;
try {
row . getCell ( 5 ) . setCellType ( CellType . STRING ) ;
sourcePartNo = row . getCell ( 5 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//替换零件号
String targetPartNo = null ;
try {
row . getCell ( 6 ) . setCellType ( CellType . STRING ) ;
targetPartNo = row . getCell ( 6 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//是否客户 发送PTR信息
String isCustomerSendPrtInfo = null ;
try {
row . getCell ( 7 ) . setCellType ( CellType . STRING ) ;
isCustomerSendPrtInfo = row . getCell ( 7 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//排序信息PTR零件号
String seqInfoPrtPart = null ;
try {
row . getCell ( 8 ) . setCellType ( CellType . STRING ) ;
seqInfoPrtPart = row . getCell ( 8 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//PTR项目编号
String ptrProjectNo = null ;
try {
row . getCell ( 9 ) . setCellType ( CellType . STRING ) ;
ptrProjectNo = row . getCell ( 9 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//替换零件条码规则
String targetPartNoSnRuleCode = null ;
try {
row . getCell ( 10 ) . setCellType ( CellType . STRING ) ;
targetPartNoSnRuleCode = row . getCell ( 10 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//总成类型
String partTypeCode = null ;
try {
row . getCell ( 11 ) . setCellType ( CellType . STRING ) ;
partTypeCode = row . getCell ( 11 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//总成类型
String isInterPrt = null ;
try {
row . getCell ( 12 ) . setCellType ( CellType . STRING ) ;
isInterPrt = row . getCell ( 12 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//目视单显示项
String visualSingleDisplayItem = null ;
try {
row . getCell ( 13 ) . setCellType ( CellType . STRING ) ;
visualSingleDisplayItem = row . getCell ( 13 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//起始序号
String startSeq = null ;
try {
row . getCell ( 14 ) . setCellType ( CellType . STRING ) ;
startSeq = row . getCell ( 14 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//目视单替换位置
String visualSingleReplacePosition = null ;
try {
row . getCell ( 14 ) . setCellType ( CellType . STRING ) ;
visualSingleReplacePosition = row . getCell ( 14 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//硬件版本号
String hardwareVersionNo = null ;
try {
row . getCell ( 15 ) . setCellType ( CellType . STRING ) ;
hardwareVersionNo = row . getCell ( 15 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//软件版本号
String softwareVersionNo = null ;
try {
row . getCell ( 16 ) . setCellType ( CellType . STRING ) ;
softwareVersionNo = row . getCell ( 16 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//软件版本号
String status = null ;
try {
row . getCell ( 17 ) . setCellType ( CellType . STRING ) ;
status = row . getCell ( 17 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
//软件版本号
String memo = null ;
try {
row . getCell ( 18 ) . setCellType ( CellType . STRING ) ;
memo = row . getCell ( 18 , Row . MissingCellPolicy . CREATE_NULL_AS_BLANK ) . getStringCellValue ( ) . trim ( ) ;
} catch ( Exception e ) {
}
// if (!map.containsKey(preventionObjectCode + "&" + partNo)) {
// map.put(preventionObjectCode + "&" + partNo, String.valueOf(rowNum));
// } else {
//package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.excel;
//
//import cn.estsh.i3plus.mes.api.iservice.busi.IExcelImportService;
//import cn.estsh.i3plus.mes.apiservice.serviceimpl.busi.CommonService;
//import cn.estsh.i3plus.mes.apiservice.util.MesCommonUtil;
//import cn.estsh.i3plus.platform.common.convert.ConvertBean;
//import cn.estsh.i3plus.pojo.mes.bean.MesPartPtr;
//import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
//import cn.estsh.i3plus.pojo.mes.model.ExcelImportErrorModel;
//import cn.estsh.i3plus.pojo.mes.model.ExcelImportResultModel;
//import cn.estsh.i3plus.pojo.mes.repository.MesPartPtrRepository;
//import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
//import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository;
//import cn.estsh.i3plus.pojo.mes.unit.MesExtEnumUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.poi.ss.usermodel.CellType;
//import org.apache.poi.ss.usermodel.Row;
//import org.apache.poi.ss.usermodel.Sheet;
//import org.apache.poi.ss.usermodel.Workbook;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * @Description : MES工单导入, BTO
// * @Reference :
// * @Author : junsheng.li
// * @CreateDate 2024/5/16 14:14
// * @Modify:
// **/
//@Service
//@Slf4j
//public class MesWorkOrderBtoExcelServiceImpl implements IExcelImportService {
//
// @Autowired
// private CommonService commonService;
// @Autowired
// private MesPartRepository partRepository;
// @Autowired
// private MesWorkOrderRepository mesWorkOrderRDao;
//
// @Override
// public ExcelImportResultModel insertDataByExcel(Workbook workbook, String organizeCode, String userName) {
//
// //读取表格
// ExcelImportResultModel excelImportResultModel = this.sheetExtractMesWorkOrder(workbook.getSheetAt(0), organizeCode, userName);
// //数据入库
// this.insertExcelMesWorkOrder(excelImportResultModel);
// return excelImportResultModel;
//// return null;
// }
//
// /**
// * 工位BOM表导入-读取表格
// *
// * @param sheetAt
// * @param organizeCode
// * @param userName
// * @return
// */
// private ExcelImportResultModel sheetExtractMesWorkOrder(Sheet sheetAt, String organizeCode, String userName) {
//
// //从0行开始读取
// int totalNumberOfRows = sheetAt.getLastRowNum() + 1;
//
// //MesStationBom集合
// List<MesPartPtr> partPtrList = new ArrayList<>();
//
// //成功数量
// Integer successRowNum = 0;
// //失败数量
// Integer failRowNum = 0;
// //错误的行号
// String errorRows = "";
//
// //错误行信息集合
// List<ExcelImportErrorModel> excelImportErrorModels = new ArrayList<>();
//
// // 查询物料表
// Map<String, Object> partCodeEntityMap;
// try {
// partCodeEntityMap = MesCommonUtil.getCodeEntityMap(partRepository, "partNo", organizeCode, "物料表");
// } catch (Exception e) {
// partCodeEntityMap = null;
// }
//
//// //查询关键件条码校验规则表
//// List<MesPartPtr> partPtrList = partPtrRepository.findByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED},
//// new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()});
//// Map<String, List<MesPartPtr>> preventionMap =
//// partPtrList.stream().collect(Collectors.groupingBy(k -> k.getPreventionObjectCode() + "&" + k.getPartNo()));
//
//
// Map<String, String> map = new HashMap<>();
//
// for (int i = (sheetAt.getFirstRowNum() + 1); i < totalNumberOfRows; i++) {
// Row row = sheetAt.getRow(i);
// //空行跳过
// if (null == row) {
// continue;
// }
// //获取总列数
// Short lastCellNum = row.getLastCellNum();
// if (lastCellNum > 0) {
//
// int rowNum = i + 1; //当前行号
// int errorNum = 0; //错误数量
// String cellNum = ""; //错误列号
// String errorInfo = ""; //错误信息
//
// //生产线代码
// String workCenterCode = null;
// try {
// row.getCell(0).setCellType(CellType.STRING);
// workCenterCode = row.getCell(0, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue().trim();
// } catch (Exception e) {
// }
// //ERP总成零件号
// String partNo = null;
// try {
// row.getCell(1).setCellType(CellType.STRING);
// partNo = row.getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue().trim();
// } catch (Exception e) {
// }
// //计划开始时间( yyyy-MM-dd)
// String startTime = null;
// try {
// row.getCell(2).setCellType(CellType.STRING);
// startTime = row.getCell(2, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue().trim();
// } catch (Exception e) {
// }
// //计划结束时间( yyyy-MM-dd)
// String endTime = null;
// try {
// row.getCell(3).setCellType(CellType.STRING);
// endTime = row.getCell(3, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue().trim();
// } catch (Exception e) {
// }
//
// //数量
// String qty = null;
// try {
// row.getCell(4).setCellType(CellType.STRING);
// qty = row.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue().trim();
// } catch (Exception e) {
// }
//
// //校验产线编号
// if (StringUtils.isEmpty(workCenterCode)) {
// errorNum++;
// cellNum += "A; C; ";
// errorInfo += "第A列数据 :" + preventionObjectCode + ",第C列数据:" + partNo ;
// cellNum += "A;";
// errorInfo += "第A列数据必填;";
// }
//
// // 校验物料 号
// //ERP总成零件号
// if (StringUtils.isEmpty(partNo)) {
// errorNum++;
// cellNum += "B;";
// errorInfo += "第B列数据必填;";
// }
// //计划开始时间( yyyy-MM-dd)
// if (StringUtils.isEmpty(startTime)) {
// errorNum++;
// cellNum += "C;";
// errorInfo += "第C列数据必填;";
// } else {
// if (CollectionUtils.isEmpty(partCodeEntityMap) ||
// (!CollectionUtils.isEmpty(partCodeEntityMap) && !partCodeEntityMap.containsKey(partNo))) {
// }
// //校验替换零件号
// if (StringUtils.isEmpty()) {
// errorNum++;
// cellNum += "C;";
// errorInfo += "第C列数据无效;";
// cellNum += "J;";
// errorInfo += "第J列数据必填;";
// }
// //校验总成类型
// if (StringUtils.isEmpty(partTypeCode)) {
// errorNum++;
// cellNum += "L;";
// errorInfo += "第L列数据必填;";
// }
//
//
// //没有错误的时候, 封装MesStationBom
// if (errorNum == 0) {
//
// MesPartPtr partPtr;
//// if (preventionMap.containsKey(preventionObjectCode + "&" + partNo)) {
//// itemPartErrorPrevention = preventionMap.get(partNo).get(0);
//// ConvertBean.serviceModelUpdate(itemPartErrorPrevention, userName);
//// } else {
// partPtr = new MesPartPtr();
// ConvertBean.serviceModelInitialize(partPtr, userName);
//// }
// partPtr.setWorkCenterCode(workCenterCode);
// partPtr.setStartTime(startTime);
// partPtr.setEndTime(endTime);
// partPtr.setPrtVehicleCount(Integer.parseInt(prtVehicleCount));
// partPtr.setPrtVehicleActualCount(Integer.parseInt(prtVehicleActualCount));
// partPtr.setSourcePartNo(sourcePartNo);
// partPtr.setTargetPartNo(targetPartNo);
// partPtr.setIsCustomerSendPrtInfo(Integer.parseInt(isCustomerSendPrtInfo));
// partPtr.setSeqInfoPrtPart(seqInfoPrtPart);
// partPtr.setPtrProjectNo(ptrProjectNo);
// partPtr.setTargetPartNoSnRuleCode(targetPartNoSnRuleCode);
// partPtr.setPartTypeCode(Integer.parseInt(partTypeCode));
// partPtr.setIsInterPrt(Integer.parseInt(isInterPrt));
// partPtr.setVisualSingleDisplayItem(visualSingleDisplayItem);
// partPtr.setStartSeq(startSeq);
// partPtr.setVisualSingleReplacePosition(visualSingleReplacePosition);
// partPtr.setHardwareVersionNo(hardwareVersionNo);
// partPtr.setSoftwareVersionNo(softwareVersionNo);
// partPtr.setStatus(Integer.parseInt(status));
// partPtr.setMemo(memo);
// partPtrList.add(partPtr);
// successRowNum++;
// } else {
// //封装错误行信息ExcelImportErrorModel
// excelImportErrorModels = commonService.getExcelImportErrorModels(excelImportErrorModels, rowNum, errorNum, cellNum, errorInfo);
//
// errorRows += rowNum + ";";
// failRowNum++;
// }
//
// }
// }
//
// //校验EXCEL数据
// commonService.checkExcelData(failRowNum, successRowNum, errorRows);
// //封装返回结果
// ExcelImportResultModel excelImportResultModel = commonService.getExcelImportResultModel(failRowNum, successRowNum, excelImportErrorModels, errorRows);
// excelImportResultModel.setExcelList((failRowNum > 0) ? null : partPtrList);
// return excelImportResultModel;
// }
//校验产线编号
if ( StringUtils . isEmpty ( workCenterCode ) ) {
errorNum + + ;
cellNum + = "A;" ;
errorInfo + = "第A列数据必填;" ;
}
//校验原零件号
if ( StringUtils . isEmpty ( sourcePartNo ) ) {
errorNum + + ;
cellNum + = "F;" ;
errorInfo + = "第F列数据必填;" ;
}
//校验产线编号
if ( StringUtils . isEmpty ( targetPartNo ) ) {
errorNum + + ;
cellNum + = "G;" ;
errorInfo + = "第G列数据必填;" ;
}
//校验替换零件号
if ( StringUtils . isEmpty ( ptrProjectNo ) ) {
errorNum + + ;
cellNum + = "J;" ;
errorInfo + = "第J列数据必填;" ;
}
//校验总成类型
if ( StringUtils . isEmpty ( partTypeCode ) ) {
errorNum + + ;
cellNum + = "L;" ;
errorInfo + = "第L列数据必填;" ;
}
//没有错误的时候, 封装MesStationBom
if ( errorNum = = 0 ) {
MesPartPtr partPtr ;
// if (preventionMap.containsKey(preventionObjectCode + "&" + partNo)) {
// itemPartErrorPrevention = preventionMap.get(partNo).get(0);
// ConvertBean.serviceModelUpdate(itemPartErrorPrevention, userName);
//
// private void insertExcelMesWorkOrder(ExcelImportResultModel excelImportResultModel) {
// if (excelImportResultModel == null) {
// return;
// }
// List<MesWorkOrder> partPtrList = excelImportResultModel.getExcelList();
// if (CollectionUtils.isEmpty(partPtrList)) {
// return;
// }
//
// partPtrList.forEach(k -> {
// if (StringUtils.isEmpty(k.getId())) {
// mesWorkOrderRDao.insert(k);
// } else {
partPtr = new MesPartPtr ( ) ;
ConvertBean . serviceModelInitialize ( partPtr , userName ) ;
// mesWorkOrderRDao.update(k);
// }
// });
// }
//}
partPtr . setWorkCenterCode ( workCenterCode ) ;
partPtr . setStartTime ( startTime ) ;
partPtr . setEndTime ( endTime ) ;
partPtr . setPrtVehicleCount ( Integer . parseInt ( prtVehicleCount ) ) ;
partPtr . setPrtVehicleActualCount ( Integer . parseInt ( prtVehicleActualCount ) ) ;
partPtr . setSourcePartNo ( sourcePartNo ) ;
partPtr . setTargetPartNo ( targetPartNo ) ;
partPtr . setIsCustomerSendPrtInfo ( Integer . parseInt ( isCustomerSendPrtInfo ) ) ;
partPtr . setSeqInfoPrtPart ( seqInfoPrtPart ) ;
partPtr . setPtrProjectNo ( ptrProjectNo ) ;
partPtr . setTargetPartNoSnRuleCode ( targetPartNoSnRuleCode ) ;
partPtr . setPartTypeCode ( Integer . parseInt ( partTypeCode ) ) ;
partPtr . setIsInterPrt ( Integer . parseInt ( isInterPrt ) ) ;
partPtr . setVisualSingleDisplayItem ( visualSingleDisplayItem ) ;
partPtr . setStartSeq ( startSeq ) ;
partPtr . setVisualSingleReplacePosition ( visualSingleReplacePosition ) ;
partPtr . setHardwareVersionNo ( hardwareVersionNo ) ;
partPtr . setSoftwareVersionNo ( softwareVersionNo ) ;
partPtr . setStatus ( Integer . parseInt ( status ) ) ;
partPtr . setMemo ( memo ) ;
partPtrList . add ( partPtr ) ;
successRowNum + + ;
} else {
//封装错误行信息ExcelImportErrorModel
excelImportErrorModels = commonService . getExcelImportErrorModels ( excelImportErrorModels , rowNum , errorNum , cellNum , errorInfo ) ;
errorRows + = rowNum + ";" ;
failRowNum + + ;
}
}
}
//校验EXCEL数据
commonService . checkExcelData ( failRowNum , successRowNum , errorRows ) ;
//封装返回结果
ExcelImportResultModel excelImportResultModel = commonService . getExcelImportResultModel ( failRowNum , successRowNum , excelImportErrorModels , errorRows ) ;
excelImportResultModel . setExcelList ( ( failRowNum > 0 ) ? null : partPtrList ) ;
return excelImportResultModel ;
}
private void insertExcelMesWorkOrder ( ExcelImportResultModel excelImportResultModel ) {
if ( excelImportResultModel = = null ) {
return ;
}
List < MesWorkOrder > partPtrList = excelImportResultModel . getExcelList ( ) ;
if ( CollectionUtils . isEmpty ( partPtrList ) ) {
return ;
}
partPtrList . forEach ( k - > {
if ( StringUtils . isEmpty ( k . getId ( ) ) ) {
mesWorkOrderRDao . insert ( k ) ;
} else {
mesWorkOrderRDao . update ( k ) ;
}
} ) ;
}
}