|
@@ -8,6 +8,7 @@ import com.zcxk.core.common.pojo.ResultMessage;
|
|
import com.zcxk.rmcp.web.excel.model.DeviceImportData;
|
|
import com.zcxk.rmcp.web.excel.model.DeviceImportData;
|
|
import com.zcxk.rmcp.web.excel.model.ExcelData;
|
|
import com.zcxk.rmcp.web.excel.model.ExcelData;
|
|
import com.zcxk.rmcp.web.service.DeviceService;
|
|
import com.zcxk.rmcp.web.service.DeviceService;
|
|
|
|
+import com.zcxk.rmcp.web.util.Utils;
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -27,26 +28,34 @@ public class DeviceImportListener extends AnalysisEventListener<DeviceImportData
|
|
private ExcelData excelData;
|
|
private ExcelData excelData;
|
|
|
|
|
|
|
|
|
|
- public DeviceImportListener(DeviceService deviceService,ExcelData excelData) {
|
|
|
|
|
|
+ public DeviceImportListener(DeviceService deviceService, ExcelData excelData) {
|
|
this.deviceService = deviceService;
|
|
this.deviceService = deviceService;
|
|
this.excelData = excelData;
|
|
this.excelData = excelData;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void invoke(DeviceImportData data, AnalysisContext analysisContext) {
|
|
public void invoke(DeviceImportData data, AnalysisContext analysisContext) {
|
|
|
|
+ try {
|
|
|
|
+ if (Utils.checkObjFieldIsNull(data)
|
|
|
|
+ ) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
if (
|
|
if (
|
|
data.getDeviceNo() == null || data.getDeviceTypeName() == null
|
|
data.getDeviceNo() == null || data.getDeviceTypeName() == null
|
|
- && data.getMeterNo() == null || data.getCompanyOrgName() == null
|
|
|
|
|
|
+ || data.getMeterNo() == null || data.getCompanyOrgName() == null
|
|
) {
|
|
) {
|
|
data.setRemark("必填项不能为空");
|
|
data.setRemark("必填项不能为空");
|
|
list.add(data);
|
|
list.add(data);
|
|
excelData.getFailNum().incrementAndGet();
|
|
excelData.getFailNum().incrementAndGet();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- ResultMessage resultMessage = deviceService.saveExcelData(data,excelData);
|
|
|
|
- if(resultMessage.getStatus()){
|
|
|
|
|
|
+ ResultMessage resultMessage = deviceService.saveExcelData(data, excelData);
|
|
|
|
+ if (resultMessage.getStatus()) {
|
|
excelData.getSuccessNum().incrementAndGet();
|
|
excelData.getSuccessNum().incrementAndGet();
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
data.setRemark(resultMessage.getMessage());
|
|
data.setRemark(resultMessage.getMessage());
|
|
list.add(data);
|
|
list.add(data);
|
|
excelData.getFailNum().incrementAndGet();
|
|
excelData.getFailNum().incrementAndGet();
|
|
@@ -55,9 +64,10 @@ public class DeviceImportListener extends AnalysisEventListener<DeviceImportData
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
- log.info("批量导出设备完成 successNum = {},failNum = {}",excelData.getSuccessNum().get(),excelData.getFailNum().get());
|
|
|
|
|
|
+ log.info("批量导出设备完成 successNum = {},failNum = {}", excelData.getSuccessNum().get(), excelData.getFailNum().get());
|
|
}
|
|
}
|
|
- public List<DeviceImportData> getData(){
|
|
|
|
|
|
+
|
|
|
|
+ public List<DeviceImportData> getData() {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|