IClearApiLogService.java
2.98 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.erry.iclear.dateInterface.service;
import com.erry.iclear.dateInterface.api.request.Basfc;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.IClearApiLog;
import com.erry.iclear.dateInterface.repository.IClearApiLogRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author Administrator
*/
@Service
@Slf4j
public class IClearApiLogService {
@Autowired
private IClearApiLogRepository iClearApiLogRepository;
/**
* 保存日志
* @param iClearApiLog
*/
public IClearApiLog saveIClearApiLog(IClearApiLog iClearApiLog){
try{
return iClearApiLogRepository.save(iClearApiLog);
}catch (Exception e){
log.error("saveIClearApiLog() error:"+ e.getMessage());
}
return null;
}
/**
* 创建日志
* @return
*/
public IClearApiLog convertToIClearApiLog(Mawb mawb,String appId,String appKey,Date pushTime){
IClearApiLog result = new IClearApiLog();
try{
result.setMsgType(Constant.MSG_TYPE_D);
result.setAppId(appId);
result.setAppKey(appKey);
result.setCreateTime(new Date());
result.setPushTime(pushTime);
result.setReceiveResult(null);
result.setResponseTime(null);
result.setSpendTime(null);
result.setSendTimes(1);
result.setBillNo(mawb.getBillNo());
result.setContrNo(mawb.getContrNo());
}catch (Exception e){
log.error("convertToIClearApiLog() error:"+e.getMessage());
}
return result;
}
/**
* 创建日志
* @return
*/
public IClearApiLog convertToIClearApiLogC(Basfc basfc, String appId, String appKey, Date pushTime){
IClearApiLog result = new IClearApiLog();
try{
result.setMsgType(Constant.MSG_TYPE_C);
result.setAppId(appId);
result.setAppKey(appKey);
result.setCreateTime(new Date());
result.setPushTime(pushTime);
result.setReceiveResult(null);
result.setResponseTime(null);
result.setSpendTime(null);
result.setSendTimes(1);
result.setBillNo(basfc.getConsignmentCode());
//result.setContrNo(mawb.getContrNo());
}catch (Exception e){
log.error("convertToIClearApiLog() error:"+e.getMessage());
}
return result;
}
public void updateIClearApiLog(IClearApiLog iClearApiLog){
try{
iClearApiLogRepository.updateIClearApiLog(iClearApiLog.getMsgId(),iClearApiLog.getSpendTime(),iClearApiLog.getResponseTime(),iClearApiLog.getReceiveResult());
}catch (Exception e){
log.error("updateIClearApiLog() error:"+e.getMessage());
}
}
}