package com.ann.demo.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ann.demo.entity.constant.AliasName;
import com.ann.demo.entity.constant.InterfaceName;
import com.ann.demo.entity.filing.MessageSubordinate;
import com.ann.demo.entity.filing.dto.MessageDto;
import com.ann.demo.entity.filing.dto.PatientMainDto;
import com.ann.demo.entity.interfaceEntity.ArchiveMaster;
import com.ann.demo.entity.interfaceEntity.MessageLog;
import com.ann.demo.repository.MessageRepository;
import com.ann.demo.service.ArchiveMasterService;
import com.ann.demo.service.MessageService;
import com.ann.demo.service.MessageSubordinateService;
import com.ann.demo.utils.XMLUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @Description
 * @Date 2019/7/9 10:24
 * @Created by  ljx
 */
@Service
public class MessageServiceImpl implements MessageService {

    static final Logger logger = LoggerFactory.getLogger(MessageServiceImpl.class);

    @Autowired
    MessageRepository messageRepository;

    @Override
    public void save(MessageLog log) {
        //打日志信息
        try {
            messageRepository.save(log);
            //-------------------------打出来的日志 需改善
        } catch (Exception e) {
            logger.error("出错咯！保存消息内容错误信息:" + e);
        }
    }

    @Override
    public Integer countByInputContentAndInterfaceName(String xmlStr, String hipMessageServer) {
        return messageRepository.countByInputContentAndInterfaceName(xmlStr, hipMessageServer);
    }

    @Override
    public List<MessageLog> findAllMessage() {
        List<MessageLog> allHaha = messageRepository.findAllHaha();
        System.out.println(allHaha.size());
        return allHaha;
    }


    public String getArchiveMasterId(String inpNo,String visitId) {
        return  messageRepository.getArchiveMasterId(inpNo, visitId);
    }

}
