Jiaqi.xu

BASF申报接口

...@@ -2,11 +2,15 @@ package com.erry.iclear.dateInterface.api; ...@@ -2,11 +2,15 @@ package com.erry.iclear.dateInterface.api;
2 2
3 import com.erry.iclear.dateInterface.api.request.BasfMawb; 3 import com.erry.iclear.dateInterface.api.request.BasfMawb;
4 import com.erry.iclear.dateInterface.api.request.Basfc; 4 import com.erry.iclear.dateInterface.api.request.Basfc;
5 +import com.erry.iclear.dateInterface.api.request.ConsignmentCode;
5 import com.erry.iclear.dateInterface.api.response.ResultRS; 6 import com.erry.iclear.dateInterface.api.response.ResultRS;
7 +import com.erry.iclear.dateInterface.entity.DeclaredInfo;
6 import com.erry.iclear.dateInterface.entity.IClearApiLog; 8 import com.erry.iclear.dateInterface.entity.IClearApiLog;
7 import com.erry.iclear.dateInterface.service.BasfService; 9 import com.erry.iclear.dateInterface.service.BasfService;
8 import com.erry.iclear.dateInterface.service.ChmConsignmentService; 10 import com.erry.iclear.dateInterface.service.ChmConsignmentService;
11 +import com.erry.iclear.dateInterface.service.DeclaredInfoService;
9 import com.erry.iclear.dateInterface.service.IClearApiLogService; 12 import com.erry.iclear.dateInterface.service.IClearApiLogService;
13 +import com.erry.iclear.dateInterface.util.StringUtil;
10 import com.google.gson.Gson; 14 import com.google.gson.Gson;
11 import io.swagger.annotations.ApiOperation; 15 import io.swagger.annotations.ApiOperation;
12 import lombok.extern.slf4j.Slf4j; 16 import lombok.extern.slf4j.Slf4j;
...@@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
17 21
18 import javax.servlet.http.HttpServletRequest; 22 import javax.servlet.http.HttpServletRequest;
19 import java.util.Date; 23 import java.util.Date;
24 +import java.util.List;
20 import java.util.Objects; 25 import java.util.Objects;
21 26
22 @RestController 27 @RestController
...@@ -34,6 +39,9 @@ public class BasfDataInterface { ...@@ -34,6 +39,9 @@ public class BasfDataInterface {
34 @Autowired 39 @Autowired
35 private IClearApiLogService iClearApiLogService; 40 private IClearApiLogService iClearApiLogService;
36 41
42 + @Autowired
43 + private DeclaredInfoService declaredInfoService;
44 +
37 @ApiOperation(value = "BASF推送运单数据", httpMethod = "POST", notes = "ex: http://192.168.1.75:8080/customs/sendMawbBasf") 45 @ApiOperation(value = "BASF推送运单数据", httpMethod = "POST", notes = "ex: http://192.168.1.75:8080/customs/sendMawbBasf")
38 @PostMapping("/sendMawbBasf") 46 @PostMapping("/sendMawbBasf")
39 @ResponseBody 47 @ResponseBody
...@@ -122,4 +130,51 @@ public class BasfDataInterface { ...@@ -122,4 +130,51 @@ public class BasfDataInterface {
122 result.setCode("0"); 130 result.setCode("0");
123 return result; 131 return result;
124 } 132 }
133 +
134 + @ApiOperation(value = "BASF获取申报信息", httpMethod = "POST", notes = "ex: http://192.168.1.75:8080/customs/selectDecListBasf")
135 + @PostMapping("/selectDecListBasf")
136 + @ResponseBody
137 + public ResultRS selectDecListBasf(HttpServletRequest request
138 + , @Validated @RequestBody ConsignmentCode consignmentCode) {
139 + log.info("接收到请求数据consignmentCode:"+consignmentCode.getConsignmentCode()+" data:" + gson.toJson(consignmentCode));
140 + ResultRS result = new ResultRS(Boolean.FALSE,"","");
141 + //获取请求的运单号
142 + String[] splitConsignment = StringUtil.split(consignmentCode.getConsignmentCode(),",");
143 + if(splitConsignment.length > 20){
144 + result.setCode("30001");
145 + result.setMsg("请求信息不能大于20条运单");
146 + return result;
147 + }
148 + if(splitConsignment.length<1){
149 + result.setCode("-7");
150 + result.setMsg("请求信息不能为空");
151 + return result;
152 + }
153 + StopWatch sw = new StopWatch("receice mawbBasf");
154 + sw.start("save log");
155 +
156 + String appId=(String) request.getHeader("Appid");
157 + String appKey=(String) request.getHeader("Appkey");
158 + String timeStamp=(String) request.getHeader("TimeStamp");
159 + //记录请求的运单
160 + IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLogCselect(consignmentCode.getConsignmentCode(),appId,appKey,new Date(Long.valueOf(timeStamp))));
161 + //日志的ID放入到回执日志中对应
162 + saveIClearApiLogResult.getMsgId();
163 +
164 + //查询请求需要得运单申报信息
165 + List<DeclaredInfo> declaredInfos = declaredInfoService.selectDeclaredInfo(splitConsignment);
166 + if(declaredInfos.size()>0){
167 + for (int i= 0;i<declaredInfos.size();i++){
168 +
169 + }
170 + }
171 + //返回申报数据
172 + //更新记录的请求信息
173 + //记录返回得申报数据记录
174 +
175 + //6、return result
176 + result.setSuccess(Boolean.TRUE);
177 + result.setCode("0");
178 + return result;
179 + }
125 } 180 }
......
1 +package com.erry.iclear.dateInterface.api.request;
2 +
3 +import java.io.Serializable;
4 +import java.util.List;
5 +
6 +/**
7 + * 运单集合 2021年11月4日 xjq
8 + */
9 +public class ConsignmentCode implements Serializable {
10 +
11 + private String consignmentCode;
12 +
13 + public String getConsignmentCode() {
14 + return consignmentCode;
15 + }
16 +
17 + public void setConsignmentCode(String consignmentCode) {
18 + this.consignmentCode = consignmentCode;
19 + }
20 +}
1 +package com.erry.iclear.dateInterface.common;
2 +
3 +import java.io.Serializable;
4 +
5 +/**
6 + * Created by liyang on 2017/4/22.
7 + */
8 +public class BaseModel implements Serializable {
9 +
10 + private static final long serilalVersionUID = 1L;
11 +
12 + private Long id;
13 +
14 + public BaseModel() {
15 + }
16 +
17 + public Long getId() {
18 + return id;
19 + }
20 +
21 + public void setId(Long id) {
22 + this.id = id;
23 + }
24 +
25 +
26 +}
1 +package com.erry.iclear.dateInterface.common;
2 +
3 +import com.fasterxml.jackson.core.JsonGenerator;
4 +import com.fasterxml.jackson.core.JsonProcessingException;
5 +import com.fasterxml.jackson.databind.JsonSerializer;
6 +import com.fasterxml.jackson.databind.SerializerProvider;
7 +
8 +import java.io.IOException;
9 +import java.text.SimpleDateFormat;
10 +import java.util.Date;
11 +
12 +public class JsonDateTimeSerializer extends JsonSerializer<Date> {
13 +
14 + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
15 +
16 + @Override
17 + public void serialize(Date date, JsonGenerator gen, SerializerProvider provider)
18 + throws IOException, JsonProcessingException {
19 +
20 + String formattedDate = dateFormat.format(date);
21 +
22 + gen.writeString(formattedDate);
23 + }
24 +}
1 +package com.erry.iclear.dateInterface.entity;
2 +
3 +import com.erry.iclear.dateInterface.common.BaseModel;
4 +import com.fasterxml.jackson.annotation.JsonIgnore;
5 +
6 +import javax.persistence.*;
7 +import java.util.Date;
8 +import java.util.Objects;
9 +
10 +/**
11 + * 组织结构表
12 + *
13 + * @author Created by Erry 2019/7/1.
14 + */
15 +@Entity
16 +@Table(name = "T_AU_ORGANIZATION")
17 +public class Organization extends BaseModel {
18 +
19 + private static final long serialVersionUID = 2693103610036977383L;
20 +
21 + /**
22 + * 表ID,自动增加
23 + */
24 + @Id
25 + @GeneratedValue
26 + @Column(name = "ID")
27 + private Long id;
28 +
29 +// @Version
30 +// @Column(name = "VERSION")
31 +// private Integer version;
32 +
33 +
34 + /**
35 + * 编码
36 + */
37 + @Column(name = "CODE")
38 + private String code;
39 +
40 + /**
41 + * 名称
42 + */
43 + @Column(name = "NAME")
44 + private String name;
45 +
46 + /**
47 + * 组织架构类型 (和用户类型、角色类型对应的是同一个数据字典)
48 + * <p>
49 + * 客户
50 + * 速递员
51 + * 站点
52 + * RDE
53 + * 口岸
54 + * 总部
55 + */
56 + @JsonIgnore
57 + @ManyToOne(targetEntity = DictionaryEntries.class)
58 + @JoinColumn(name = "TYPE_ID")
59 + private DictionaryEntries type;
60 +
61 + /**
62 + * 上级组织
63 + */
64 + @JsonIgnore
65 + @ManyToOne(targetEntity = Organization.class)
66 + @JoinColumn(name = "PARENT_ID")
67 + private Organization parent;
68 +
69 + /**
70 + * 级别
71 + */
72 + @Column(name = "LEVEL")
73 + private Long LEVEL;
74 +
75 + /**
76 + * 创建人
77 + */
78 + @JsonIgnore
79 + @ManyToOne(targetEntity = SysUser.class)
80 + @JoinColumn(name = "CREATE_USER_ID")
81 + private SysUser createUser;
82 +
83 + /**
84 + * 创建时间
85 + */
86 + @Column(name = "CREATE_TIME")
87 + private Date createTime;
88 +
89 + /**
90 + * 最后修改人
91 + */
92 + @JsonIgnore
93 + @ManyToOne(targetEntity = SysUser.class)
94 + @JoinColumn(name = "LAST_MODIFY_USER_ID")
95 + private SysUser lastModifyUser;
96 +
97 + /**
98 + * 最后修改时间
99 + */
100 + @Column(name = "LAST_MODIFY_TIME")
101 + private Date lastModifyTime;
102 +
103 +
104 + @Override
105 + public Long getId() {
106 + return id;
107 + }
108 +
109 + @Override
110 + public void setId(Long id) {
111 + this.id = id;
112 + }
113 +
114 + public String getCode() {
115 + return code;
116 + }
117 +
118 + public void setCode(String code) {
119 + this.code = code;
120 + }
121 +
122 + public String getName() {
123 + return name;
124 + }
125 +
126 + public void setName(String name) {
127 + this.name = name;
128 + }
129 +
130 + public DictionaryEntries getType() {
131 + return type;
132 + }
133 +
134 + public void setType(DictionaryEntries type) {
135 + this.type = type;
136 + }
137 +
138 +
139 + public Organization getParent() {
140 + return parent;
141 + }
142 +
143 + public void setParent(Organization parent) {
144 + this.parent = parent;
145 + }
146 +
147 + public Long getLEVEL() {
148 + return LEVEL;
149 + }
150 +
151 + public void setLEVEL(Long LEVEL) {
152 + this.LEVEL = LEVEL;
153 + }
154 +
155 +
156 + public Date getCreateTime() {
157 + return createTime;
158 + }
159 +
160 + public void setCreateTime(Date createTime) {
161 + this.createTime = createTime;
162 + }
163 +
164 + public SysUser getCreateUser() {
165 + return createUser;
166 + }
167 +
168 + public void setCreateUser(SysUser createUser) {
169 + this.createUser = createUser;
170 + }
171 +
172 + public SysUser getLastModifyUser() {
173 + return lastModifyUser;
174 + }
175 +
176 + public void setLastModifyUser(SysUser lastModifyUser) {
177 + this.lastModifyUser = lastModifyUser;
178 + }
179 +
180 + public Date getLastModifyTime() {
181 + return lastModifyTime;
182 + }
183 +
184 + public void setLastModifyTime(Date lastModifyTime) {
185 + this.lastModifyTime = lastModifyTime;
186 + }
187 +
188 + @Override
189 + public boolean equals(Object o) {
190 + if (this == o) {
191 + return true;
192 + }
193 + if (o == null || getClass() != o.getClass()) {
194 + return false;
195 + }
196 + Organization that = (Organization) o;
197 + return Objects.equals(id, that.id) &&
198 + Objects.equals(code, that.code) &&
199 + Objects.equals(name, that.name) &&
200 + Objects.equals(type, that.type) &&
201 + Objects.equals(parent, that.parent) &&
202 + Objects.equals(LEVEL, that.LEVEL) &&
203 + Objects.equals(createUser, that.createUser) &&
204 + Objects.equals(createTime, that.createTime) &&
205 + Objects.equals(lastModifyUser, that.lastModifyUser) &&
206 + Objects.equals(lastModifyTime, that.lastModifyTime);
207 + }
208 +
209 + @Override
210 + public int hashCode() {
211 + return Objects.hash(id, code, name, type, parent, LEVEL, createUser, createTime, lastModifyUser, lastModifyTime);
212 + }
213 +
214 + @Override
215 + public String toString() {
216 + return "Organization{" +
217 + "id=" + id +
218 + ", code='" + code + '\'' +
219 + ", name='" + name + '\'' +
220 + ", type=" + type +
221 + ", parent=" + parent +
222 + ", LEVEL=" + LEVEL +
223 + ", createUser=" + createUser +
224 + ", createTime=" + createTime +
225 + ", lastModifyUser=" + lastModifyUser +
226 + ", lastModifyTime=" + lastModifyTime +
227 + '}';
228 + }
229 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +package com.erry.iclear.dateInterface.repository;
2 +
3 +import com.erry.iclear.dateInterface.entity.DeclaredInfo;
4 +import org.springframework.data.jpa.repository.JpaRepository;
5 +import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 +import org.springframework.data.jpa.repository.Query;
7 +import org.springframework.stereotype.Repository;
8 +import org.springframework.transaction.annotation.Transactional;
9 +
10 +import java.util.List;
11 +
12 +/**
13 + * xjq 2021年11月5日
14 + */
15 +@Repository
16 +@Transactional(rollbackFor = Exception.class)
17 +public interface DeclaredInfoRepository extends JpaRepository<DeclaredInfo, Integer>, JpaSpecificationExecutor<DeclaredInfo> {
18 +
19 + /**
20 + * 根据运单号在申报数据表中查询数据
21 + * @return
22 + */
23 + @Query(nativeQuery = true, value = "select * from T_DECLARED_INFO where CONSIGNMENT_ID IN (SELECT * FROM T_CHM_CONSIGNMENT WHERE T_CHM_CONSIGNMENT.CONSIGNMENT_CODE IN ?1)")
24 + public List<DeclaredInfo> getDeclaredInfoByAll(List<String> consignmentCodeList);
25 +}
1 +package com.erry.iclear.dateInterface.service;
2 +
3 +import com.erry.iclear.dateInterface.entity.DeclaredInfo;
4 +import com.erry.iclear.dateInterface.repository.DeclaredInfoRepository;
5 +import lombok.extern.slf4j.Slf4j;
6 +import org.springframework.beans.factory.annotation.Autowired;
7 +import org.springframework.stereotype.Service;
8 +
9 +import javax.transaction.Transactional;
10 +import java.util.ArrayList;
11 +import java.util.List;
12 +
13 +/**
14 + * xjq 2021年11月5日
15 + */
16 +@Service
17 +@Slf4j
18 +@Transactional(rollbackOn = Exception.class)
19 +public class DeclaredInfoService {
20 +
21 + @Autowired
22 + private DeclaredInfoRepository declaredInfoRepository;
23 +
24 + public List<DeclaredInfo> selectDeclaredInfo(String[] consignmentCode){
25 + List<DeclaredInfo> DeclaredInfo = new ArrayList<>();
26 + List consignmentCodeList = new ArrayList();
27 + if(consignmentCode.length>0){
28 + for(int i = 0; i < consignmentCode.length; i++){
29 + consignmentCodeList.add(consignmentCode[i]);
30 + }
31 + }
32 + DeclaredInfo = declaredInfoRepository.getDeclaredInfoByAll(consignmentCodeList);
33 + return DeclaredInfo;
34 + }
35 +
36 +}
...@@ -83,6 +83,29 @@ public class IClearApiLogService { ...@@ -83,6 +83,29 @@ public class IClearApiLogService {
83 return result; 83 return result;
84 } 84 }
85 85
86 + /**
87 + * BASF请求申报数据-添加日志 2021年11月3日 xjq
88 + * @return
89 + */
90 + public IClearApiLog convertToIClearApiLogCselect(String basfc, String appId, String appKey, Date pushTime){
91 + IClearApiLog result = new IClearApiLog();
92 + try{
93 + result.setMsgType(Constant.MSG_TYPE_C);
94 + result.setAppId(appId);
95 + result.setAppKey(appKey);
96 + result.setCreateTime(new Date());
97 + result.setPushTime(pushTime);
98 + result.setReceiveResult(null);
99 + result.setResponseTime(null);
100 + result.setSpendTime(null);
101 + result.setSendTimes(1);
102 + result.setBillNo(basfc);
103 + }catch (Exception e){
104 + log.error("convertToIClearApiLog() error:"+e.getMessage());
105 + }
106 + return result;
107 + }
108 +
86 109
87 public void updateIClearApiLog(IClearApiLog iClearApiLog){ 110 public void updateIClearApiLog(IClearApiLog iClearApiLog){
88 try{ 111 try{
......