|
|
|
@ -2,6 +2,7 @@ package com.inspect.metadata.montdatamqhandle.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.inspect.base.core.constant.Color; |
|
|
|
import com.inspect.metadata.alg.mapper.BasedataAlgSubtypeMapper; |
|
|
|
import com.inspect.metadata.bdconfig.domain.BasedataBdConfigMainSystem; |
|
|
|
import com.inspect.metadata.bdconfig.mapper.BasedataBdConfigAlgConvertMapper; |
|
|
|
@ -26,11 +27,15 @@ import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
@Component("basedataMont-modelup-1024") |
|
|
|
public class BasedataMontPatrolPointConsumerHandle implements IBasedataMontDataHandleService { |
|
|
|
private final Logger log = LoggerFactory.getLogger(BasedataMontPatrolPointConsumerHandle.class); |
|
|
|
|
|
|
|
@Resource |
|
|
|
private IBasedataPatrolPointService basedataPatrolPointService; |
|
|
|
@Resource |
|
|
|
@ -60,7 +65,7 @@ public class BasedataMontPatrolPointConsumerHandle implements IBasedataMontDataH |
|
|
|
String Type = jsonObject.getString("Type"); |
|
|
|
String convertFlag = "0"; |
|
|
|
String SendCode = jsonObject.getString("SendCode"); |
|
|
|
BasedataBdConfigMainSystem mainSystem = this.basedataBdconfigMainsystemMapper.selectBasedataBdConfigMainSystemByMainSystemCode(SendCode); |
|
|
|
BasedataBdConfigMainSystem mainSystem = basedataBdconfigMainsystemMapper.selectBasedataBdConfigMainSystemByMainSystemCode(SendCode); |
|
|
|
if (null != mainSystem) { |
|
|
|
String flag = mainSystem.getConvertFlag(); |
|
|
|
if (null != flag && flag.equals("1")) { |
|
|
|
@ -72,22 +77,19 @@ public class BasedataMontPatrolPointConsumerHandle implements IBasedataMontDataH |
|
|
|
List<ModelFileItem> list = jsonObjectItems.toJavaList(ModelFileItem.class); |
|
|
|
if (null != list && !list.isEmpty()) { |
|
|
|
String modelString; |
|
|
|
for (Iterator<ModelFileItem> iterator = list.iterator(); iterator.hasNext(); this.basedataMontPatrolPointHandleComponent.handPointModelData(SendCode, modelString)) { |
|
|
|
for (Iterator<ModelFileItem> iterator = list.iterator(); iterator.hasNext(); basedataMontPatrolPointHandleComponent.handPointModelData(SendCode, modelString)) { |
|
|
|
ModelFileItem item = iterator.next(); |
|
|
|
String deviceFilePath = item.getDevice_file_path(); |
|
|
|
String source = deviceFilePath; |
|
|
|
System.out.println("目标文件待下载路径:" + deviceFilePath); |
|
|
|
log.info(Color.BLUE + "[METADATA] TCPSERVER文件路径: {}" + Color.END, deviceFilePath); |
|
|
|
ByteBuf byteBuf = Unpooled.buffer(); |
|
|
|
|
|
|
|
try { |
|
|
|
this.sftpClient.downLoad(source, (inputStream) -> { |
|
|
|
sftpClient.downLoad(source, (inputStream) -> { |
|
|
|
byte[] bytes = new byte[1024]; |
|
|
|
|
|
|
|
int index; |
|
|
|
while ((index = inputStream.read(bytes)) > -1) { |
|
|
|
byteBuf.writeBytes(Arrays.copyOfRange(bytes, 0, index)); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|