package com.java110.job.importData.adapt;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.java110.dto.PropertyWhiteListFlowDto;
|
import com.java110.dto.importData.ImportOwnerRoomDto;
|
import com.java110.dto.log.AssetImportLogDetailDto;
|
import com.java110.intf.IImportPropertyWhiteListfFlowServiceSMO;
|
import com.java110.intf.community.IImportOwnerRoomInnerServiceSMO;
|
import com.java110.job.importData.DefaultImportData;
|
import com.java110.job.importData.IImportDataAdapt;
|
import com.java110.utils.util.BeanConvertUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
/**
|
* 房产信息导入 适配器
|
* 前端请求 时 必须传入
|
* param.append('importAdapt', "importRoomOwner");
|
*/
|
@Service("importPropertyWhiteListFlowQueueData")
|
public class ImportPropertyWhiteListfFlowQueueDataAdapt extends DefaultImportData implements IImportDataAdapt {
|
|
|
@Autowired
|
private IImportPropertyWhiteListfFlowServiceSMO importPropertyWhiteListfFlowServiceSMOImpl;
|
|
|
@Override
|
public void importData(List<AssetImportLogDetailDto> assetImportLogDetailDtos) {
|
importDatas(assetImportLogDetailDtos);
|
}
|
|
private void importDatas(List<AssetImportLogDetailDto> infos) {
|
String state = "";
|
String msg = "";
|
for (AssetImportLogDetailDto assetImportLogDetailDto : infos) {
|
|
try {
|
doImportData(assetImportLogDetailDto);
|
updateImportLogDetailState(assetImportLogDetailDto.getDetailId());
|
} catch (Exception e) {
|
e.printStackTrace();
|
updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), e);
|
}
|
}
|
PropertyWhiteListFlowDto propertyWhiteListFlowDto = new PropertyWhiteListFlowDto();
|
propertyWhiteListFlowDto.setFrequencyLike("退费-");
|
List<PropertyWhiteListFlowDto> propertyWhiteListFlowDtos = importPropertyWhiteListfFlowServiceSMOImpl.queryPropertyWhiteListFlow(propertyWhiteListFlowDto);
|
for (PropertyWhiteListFlowDto propertyWhiteListFlowDto1 : propertyWhiteListFlowDtos) {
|
PropertyWhiteListFlowDto propertyWhiteListFlowDto2 = new PropertyWhiteListFlowDto();
|
propertyWhiteListFlowDto2.setInvoiceReceiptNo(propertyWhiteListFlowDto1.getFrequency().split("-")[1]);
|
propertyWhiteListFlowDto2.setCommunityId(propertyWhiteListFlowDto1.getCommunityId());
|
List<PropertyWhiteListFlowDto> propertyWhiteListFlowDtos1 = importPropertyWhiteListfFlowServiceSMOImpl.queryPropertyWhiteListFlow(propertyWhiteListFlowDto2);
|
if (propertyWhiteListFlowDtos1.size() != 0) {
|
propertyWhiteListFlowDtos1.get(0).setFrequency("被退费-"+propertyWhiteListFlowDto2.getInvoiceReceiptNo());
|
importPropertyWhiteListfFlowServiceSMOImpl.updatePropertyWhiteListFlow(propertyWhiteListFlowDtos1.get(0));
|
}
|
}
|
|
}
|
|
/**
|
* 导入数据
|
*
|
* @param assetImportLogDetailDto
|
*/
|
private void doImportData(AssetImportLogDetailDto assetImportLogDetailDto) {
|
JSONObject data = JSONObject.parseObject(assetImportLogDetailDto.getContent());
|
PropertyWhiteListFlowDto whites = BeanConvertUtil.covertBean(data, PropertyWhiteListFlowDto.class);
|
int count = importPropertyWhiteListfFlowServiceSMOImpl.countPropertyWhiteListFlowFilter(whites);
|
if (count > 0) {
|
throw new IllegalArgumentException("第" + whites.getRow() + "行存在重复的导入内容");
|
}
|
int flag = importPropertyWhiteListfFlowServiceSMOImpl.savePropertyWhiteListFlow(whites);
|
if (flag < 1) {
|
throw new IllegalArgumentException("第" + whites.getRow() + "行导入失败");
|
}
|
|
}
|
|
|
}
|