话不多说,直接上代码
ImportParams importParams = new ImportParams();
importParams.setTitleRows(0);
importParams.setHeadRows(1);
importParams.setNeedVerfiy(true);
importParams.setVerifyHandler(dnImportExcelVerifyHandler);
import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.pig4cloud.pigx.fashion.api.excel.asnImport.AsnImport;
import com.pig4cloud.pigx.fashion.api.excel.dnImport.DnImport;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
/**
* 检查是否有空行
*/
@Component
public class DnImportExcelVerifyHandler implements IExcelVerifyHandler<DnImport> {
@Override
public ExcelVerifyHandlerResult verifyHandler(DnImport dnImport) {
if(StringUtils.isBlank(dnImport.getWarehouseCode())
&& StringUtils.isBlank(dnImport.getCompanyCode())
&& StringUtils.isBlank(dnImport.getOutboundDispatchNumber())
&& StringUtils.isBlank(dnImport.getCustomerNumber())
&& StringUtils.isBlank(dnImport.getOrderType())
&& StringUtils.isBlank(dnImport.getProductPropertyBin())
&& StringUtils.isBlank(dnImport.getExpectedArrivalDate())
&& null==dnImport.getPriority()
&& StringUtils.isBlank(dnImport.getNeedQc())
&& StringUtils.isBlank(dnImport.getReceivingAddressCode())
&& StringUtils.isBlank(dnImport.getReceiverName())
&& StringUtils.isBlank(dnImport.getTelephone())
&& StringUtils.isBlank(dnImport.getAddress())
&& StringUtils.isBlank(dnImport.getRemark())
&& StringUtils.isBlank(dnImport.getPartNumber())
&& StringUtils.isBlank(dnImport.getEan())
&& null == dnImport.getQuantity()
&& StringUtils.isBlank(dnImport.getSpecifyLocation())
&& StringUtils.isBlank(dnImport.getSpecifyReceiptBatch())
&& StringUtils.isBlank(dnImport.getQuantityUnit())
){
ExcelVerifyHandlerResult result = new ExcelVerifyHandlerResult(false);
result.setMsg("空行数据");
return result;
}
return new ExcelVerifyHandlerResult(true);
}
}