123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package camel.central.archives.processor;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.databind.node.ObjectNode;
- import com.yihu.hos.core.log.Logger;
- import com.yihu.hos.core.log.LoggerFactory;
- import org.apache.camel.Exchange;
- import org.apache.camel.Message;
- import org.springframework.stereotype.Component;
- import org.springframework.util.StringUtils;
- import java.io.IOException;
- /**
- * 数据入库
- * @author HZY
- * @vsrsion 1.0
- * Created at 2017/06/26.
- */
- @Component
- public class ArchivesService {
- private static final Logger logger = LoggerFactory.getLogger(ArchivesService.class);
- private ObjectMapper objectMapper = new ObjectMapper();
- public void bodyValue(Exchange exchange) {
- Message in = exchange.getIn();
- String body = in.getBody(String.class);
- System.out.println("入库解析结果:"+body);
- // exchange.getOut().setBody(body);
- }
- //入库服务参数设置
- public void storageArchive(Exchange exchange) {
- Message in = exchange.getIn();
- String body = in.getBody(String.class);
- if (!StringUtils.isEmpty(body)){
- try {
- ObjectNode objectNode = objectMapper.readValue(body,ObjectNode.class);
- String packageId = objectNode.get("id").asText();
- String clientId = objectNode.get("clientId").asText();
- String query = "&packageId="+packageId+"&clientId="+clientId+"&echo="+false;
- exchange.getOut().setHeader(Exchange.REST_HTTP_QUERY,query);
- System.out.println("入库参数:"+query);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }else {
- System.out.println("上传档案失败处理,body: "+exchange.getIn().getBody(String.class));
- }
- }
- // public static void main(String[] args) throws Exception {
- // String value= MD5.getMd5ByFile(new File("E:\\test\\可使用包\\dc3ec66729fef8f1311f247a34fa7e_4.zip"));
- // System.out.println(value);
- // }
- }
|