ArchivesService.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package camel.central.archives.processor;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import com.fasterxml.jackson.databind.node.ObjectNode;
  4. import com.yihu.hos.core.log.Logger;
  5. import com.yihu.hos.core.log.LoggerFactory;
  6. import org.apache.camel.Exchange;
  7. import org.apache.camel.Message;
  8. import org.springframework.stereotype.Component;
  9. import org.springframework.util.StringUtils;
  10. import java.io.IOException;
  11. /**
  12. * 数据入库
  13. * @author HZY
  14. * @vsrsion 1.0
  15. * Created at 2017/06/26.
  16. */
  17. @Component
  18. public class ArchivesService {
  19. private static final Logger logger = LoggerFactory.getLogger(ArchivesService.class);
  20. private ObjectMapper objectMapper = new ObjectMapper();
  21. public void bodyValue(Exchange exchange) {
  22. Message in = exchange.getIn();
  23. String body = in.getBody(String.class);
  24. System.out.println("入库解析结果:"+body);
  25. // exchange.getOut().setBody(body);
  26. }
  27. //入库服务参数设置
  28. public void storageArchive(Exchange exchange) {
  29. Message in = exchange.getIn();
  30. String body = in.getBody(String.class);
  31. if (!StringUtils.isEmpty(body)){
  32. try {
  33. ObjectNode objectNode = objectMapper.readValue(body,ObjectNode.class);
  34. String packageId = objectNode.get("id").asText();
  35. String clientId = objectNode.get("clientId").asText();
  36. String query = "&packageId="+packageId+"&clientId="+clientId+"&echo="+false;
  37. exchange.getOut().setHeader(Exchange.REST_HTTP_QUERY,query);
  38. System.out.println("入库参数:"+query);
  39. } catch (IOException e) {
  40. e.printStackTrace();
  41. }
  42. }else {
  43. System.out.println("上传档案失败处理,body: "+exchange.getIn().getBody(String.class));
  44. }
  45. }
  46. // public static void main(String[] args) throws Exception {
  47. // String value= MD5.getMd5ByFile(new File("E:\\test\\可使用包\\dc3ec66729fef8f1311f247a34fa7e_4.zip"));
  48. // System.out.println(value);
  49. // }
  50. }