TpParkPInterfaceLogServiceImpl.java 2.02 KB
package com.zteits.park.biz;

import com.alibaba.fastjson.JSONObject;
import com.zteits.clouds.api.apibase.bean.BizResult;
import com.zteits.clouds.api.dto.park.param.SaveInterfaceRequest;
import com.zteits.clouds.api.service.park.TpParkPInterfaceLogService;
import com.zteits.park.dao.TpPInterfaceLogDao;
import com.zteits.park.domain.TpPExceptionLogWithBLOBs;
import com.zteits.park.domain.TpPInterfaceLogWithBLOBs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("com.zteits.park.biz.TpParkPInterfaceLogServiceImpl")
public class TpParkPInterfaceLogServiceImpl implements TpParkPInterfaceLogService {
	
	private static final Logger logger = LoggerFactory.getLogger(TpParkPInterfaceLogServiceImpl.class);

	@Autowired
	private TpPInterfaceLogDao tpPInterfaceLogDao;

	@Override
	public BizResult<Boolean> SaveInterfaceLog(SaveInterfaceRequest request) {
		logger.info("地磁上报数据入参:"+ JSONObject.toJSONString(request));

		try{
			if(request.getSuccess() && request.getIsSaveSuccess()){
				//记录成功日志
				TpPInterfaceLogWithBLOBs interfaceLogWithBLOBs = new TpPInterfaceLogWithBLOBs();
				BeanUtils.copyProperties(request, interfaceLogWithBLOBs);
				interfaceLogWithBLOBs.setBusiType(request.getBusiType().getValue());
				interfaceLogWithBLOBs.setBusiDesc(request.getBusiType().getDesc());
				tpPInterfaceLogDao.saveSuccessLog(interfaceLogWithBLOBs);
			}else if(!request.getSuccess() && request.getIsSaveError()){
				//放入异常表
				TpPExceptionLogWithBLOBs exceptionLog = new TpPExceptionLogWithBLOBs();
				BeanUtils.copyProperties(request, exceptionLog);
				exceptionLog.setBusiType(request.getBusiType().getValue());
				exceptionLog.setBusiDesc(request.getBusiType().getDesc());
				tpPInterfaceLogDao.saveExceptionLog(exceptionLog );
			}
		}catch(Exception e){
			logger.error("记录日志失败:",e);
		}
		return new BizResult<Boolean>(true);
	}

}