Blame view

parking-module-park/src/main/java/com/zteits/park/biz/TpParkPInterfaceLogServiceImpl.java 2.02 KB
9af4a544   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  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);
  	}
  
  }