tao.mo

Merge remote-tracking branch 'origin/API-2023-07-30-bug' into API-2023-07-30-bug

1 package com.erry.iclear.dateInterface.api; 1 package com.erry.iclear.dateInterface.api;
2 2
3 -import com.erry.iclear.dateInterface.api.request.MawbDetail;
4 -import com.erry.iclear.dateInterface.enums.ErrorCodeEnum;
5 import com.erry.iclear.dateInterface.api.request.Mawb; 3 import com.erry.iclear.dateInterface.api.request.Mawb;
6 import com.erry.iclear.dateInterface.api.response.ResultRS; 4 import com.erry.iclear.dateInterface.api.response.ResultRS;
7 import com.erry.iclear.dateInterface.entity.IClearApiLog; 5 import com.erry.iclear.dateInterface.entity.IClearApiLog;
6 +import com.erry.iclear.dateInterface.enums.ErrorCodeEnum;
8 import com.erry.iclear.dateInterface.repository.MawbAdd; 7 import com.erry.iclear.dateInterface.repository.MawbAdd;
9 import com.erry.iclear.dateInterface.service.*; 8 import com.erry.iclear.dateInterface.service.*;
10 import com.erry.iclear.dateInterface.util.StringUtil; 9 import com.erry.iclear.dateInterface.util.StringUtil;
...@@ -17,7 +16,9 @@ import org.springframework.validation.annotation.Validated; ...@@ -17,7 +16,9 @@ import org.springframework.validation.annotation.Validated;
17 import org.springframework.web.bind.annotation.*; 16 import org.springframework.web.bind.annotation.*;
18 17
19 import javax.servlet.http.HttpServletRequest; 18 import javax.servlet.http.HttpServletRequest;
20 -import java.util.*; 19 +import java.util.Date;
20 +import java.util.Map;
21 +import java.util.Objects;
21 22
22 /** 23 /**
23 * @author Administrator 24 * @author Administrator
...@@ -118,7 +119,7 @@ public class CustomsDataInterface { ...@@ -118,7 +119,7 @@ public class CustomsDataInterface {
118 119
119 //2、TODO 校验主单 120 //2、TODO 校验主单
120 sw.start("checkMawb"); 121 sw.start("checkMawb");
121 - result=mawbService.checkMawb(mawb); 122 + result=mawbService.checkMawb(mawb,appId);
122 if(!result.getSuccess()){ 123 if(!result.getSuccess()){
123 return result; 124 return result;
124 } 125 }
......
...@@ -110,7 +110,7 @@ public class FedexDataInterface { ...@@ -110,7 +110,7 @@ public class FedexDataInterface {
110 sw.stop(); 110 sw.stop();
111 111
112 sw.start("checkFedexMawb"); 112 sw.start("checkFedexMawb");
113 - ResultRS iclearCheckRs = fedexService.checkFedexMawb(saveMawbFedexResult,appInfo); 113 + ResultRS iclearCheckRs = fedexService.checkFedexMawb(saveMawbFedexResult,appInfo,appId);
114 //返回结果 114 //返回结果
115 ResultRS result = new ResultRS(Boolean.TRUE,ErrorCodeEnum.SUCCESS.getCode(),null,null); 115 ResultRS result = new ResultRS(Boolean.TRUE,ErrorCodeEnum.SUCCESS.getCode(),null,null);
116 if(nonEmptyCheck.getSuccess() && iclearCheckRs.getSuccess()){ 116 if(nonEmptyCheck.getSuccess() && iclearCheckRs.getSuccess()){
...@@ -195,7 +195,7 @@ public class FedexDataInterface { ...@@ -195,7 +195,7 @@ public class FedexDataInterface {
195 195
196 //2、TODO 校验主单 196 //2、TODO 校验主单
197 sw.start("checkFedexMawb"); 197 sw.start("checkFedexMawb");
198 - result=fedexService.checkFedexMawb(saveMawbFedexResult,null); 198 + result=fedexService.checkFedexMawb(saveMawbFedexResult,null,appId);
199 if(!result.getSuccess()){ 199 if(!result.getSuccess()){
200 return result; 200 return result;
201 } 201 }
...@@ -216,6 +216,7 @@ public class FedexDataInterface { ...@@ -216,6 +216,7 @@ public class FedexDataInterface {
216 return result; 216 return result;
217 } 217 }
218 sw.stop(); 218 sw.stop();
219 + log.info("saveIClearApiLogResult.getCreateTime():"+saveIClearApiLogResult.getCreateTime());
219 ChmConsignment chmGetId = chmConsignmentRepository.findChmConsignmentByConsignmentCode(saveIClearApiLogResult.getBillNo(), saveIClearApiLogResult.getCreateTime()); 220 ChmConsignment chmGetId = chmConsignmentRepository.findChmConsignmentByConsignmentCode(saveIClearApiLogResult.getBillNo(), saveIClearApiLogResult.getCreateTime());
220 //调用IClear接口进行运单推送EXP002 221 //调用IClear接口进行运单推送EXP002
221 String objJson = JsonToJava.toJson(chmGetId.getId()); 222 String objJson = JsonToJava.toJson(chmGetId.getId());
......
...@@ -100,4 +100,21 @@ public class Constant { ...@@ -100,4 +100,21 @@ public class Constant {
100 * 监管条件 100 * 监管条件
101 */ 101 */
102 public static final String supervise_condition = "superviseRestrict"; 102 public static final String supervise_condition = "superviseRestrict";
103 +
104 + /**
105 + * DM004接收取件信息
106 + */
107 + public static final String FILE_TYPE_GET_PICK_INFORMATION = "fileType_5";
108 +
109 + //OSPR状态
110 + /**
111 + * 未完成
112 + */
113 + public static final String OSPR_STATUS_INCOMPLETED = "OSPRStatus_1";
114 +
115 + //扫描代码
116 + /**
117 + * C类已取件
118 + */
119 + public static final String SCAN_CODE_TAKEN_PART= "scanCode_1";
103 } 120 }
......
...@@ -3,7 +3,6 @@ package com.erry.iclear.dateInterface.entity; ...@@ -3,7 +3,6 @@ package com.erry.iclear.dateInterface.entity;
3 3
4 import com.fasterxml.jackson.annotation.JsonIgnore; 4 import com.fasterxml.jackson.annotation.JsonIgnore;
5 import lombok.Data; 5 import lombok.Data;
6 -import org.springframework.format.annotation.DateTimeFormat;
7 6
8 import javax.persistence.*; 7 import javax.persistence.*;
9 import java.io.Serializable; 8 import java.io.Serializable;
...@@ -413,6 +412,62 @@ public class ChmConsignment implements Serializable { ...@@ -413,6 +412,62 @@ public class ChmConsignment implements Serializable {
413 @Column(name = "EANNO") 412 @Column(name = "EANNO")
414 private String eanNo; 413 private String eanNo;
415 414
415 + /**
416 + * 扫描代码ID
417 + */
418 + @JsonIgnore
419 + @ManyToOne(targetEntity = DictionaryEntries.class)
420 + @JoinColumn(name = "SCAN_CODE_ID")
421 + private DictionaryEntries scanCodeDic;
422 +
423 + /**
424 + * 扫描代码
425 + */
426 + @Column(name = "SCAN_CODE")
427 + private String scanCode;
428 +
429 + /**
430 + * 扫描状态日期
431 + */
432 + @Column(name = "SCAN_STATUS_TIME")
433 + private Date scanStatusTime;
434 +
435 + /**
436 + * 运单类型ID
437 + */
438 +// @JsonIgnore
439 +// @ManyToOne(targetEntity = DictionaryEntries.class)
440 +// @JoinColumn(name = "CONS_TYPE_ID")
441 +// private DictionaryEntries consTypeDic;
442 +
443 + /**
444 + * OSPR状态ID
445 + */
446 + @JsonIgnore
447 + @ManyToOne(targetEntity = DictionaryEntries.class)
448 + @JoinColumn(name = "OSPR_STATUS_ID")
449 + private DictionaryEntries osprStatusDic;
450 +
451 + /**
452 + * 站点
453 + */
454 + @JsonIgnore
455 + @ManyToOne(targetEntity = Organization.class)
456 + @JoinColumn(name = "STATION_ID")
457 + private Organization station;
458 +
459 + /**
460 + * 站点名称
461 + */
462 + @Column(name = "STATION_NAME")
463 + private String stationName;
464 +
465 + /**
466 + * 取件日期
467 + */
468 + @Column(name = "PICK_UP_DATE")
469 + private Date pickUpDate;
470 +
416 @OneToMany(mappedBy = "chmConsignment", cascade = CascadeType.ALL) 471 @OneToMany(mappedBy = "chmConsignment", cascade = CascadeType.ALL)
417 private List<ChmConsignmentDetail> chmConsignmentDetailList; 472 private List<ChmConsignmentDetail> chmConsignmentDetailList;
418 473
......
...@@ -4,7 +4,6 @@ import com.erry.iclear.dateInterface.entity.ChmConsignment; ...@@ -4,7 +4,6 @@ import com.erry.iclear.dateInterface.entity.ChmConsignment;
4 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.jpa.repository.Query;
7 -import org.springframework.data.repository.query.Param;
8 import org.springframework.stereotype.Repository; 7 import org.springframework.stereotype.Repository;
9 8
10 import java.util.Date; 9 import java.util.Date;
...@@ -33,6 +32,15 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo ...@@ -33,6 +32,15 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo
33 public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode,Date startDate); 32 public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode,Date startDate);
34 33
35 /** 34 /**
35 + * 根据运单号查找多条数据
36 + * @param consignmentCode
37 + * @param startDate
38 + * @return
39 + */
40 + @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE = ?1 and CREATE_TIME>= ?2 and CREATOR = ?3" )
41 + public List<ChmConsignment> findChmConsignmentByConsignmentCodes(String consignmentCode,Date startDate,String creator);
42 +
43 + /**
36 * 根据运单ID查运单 44 * 根据运单ID查运单
37 * @param id 45 * @param id
38 * @return 46 * @return
......
1 +package com.erry.iclear.dateInterface.repository;
2 +
3 +import com.erry.iclear.dateInterface.entity.Organization;
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.data.repository.query.Param;
8 +import org.springframework.stereotype.Repository;
9 +
10 +@Repository
11 +public interface OrganizationRepository extends JpaSpecificationExecutor<Organization>, JpaRepository<Organization, Long> {
12 + @Query(nativeQuery = true, value = "select top 1 * from T_AU_ORGANIZATION o where o.NAME = :name ")
13 + public Organization findOrganizationByName(@Param("name") String name);
14 +}
1 +package com.erry.iclear.dateInterface.repository;
2 +
3 +import com.erry.iclear.dateInterface.entity.TaskInfo;
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.data.repository.query.Param;
8 +import org.springframework.stereotype.Repository;
9 +
10 +@Repository
11 +public interface TaskInfoRepository extends JpaSpecificationExecutor<TaskInfo>, JpaRepository<TaskInfo, Long> {
12 +
13 + @Query(nativeQuery = true, value = "select top 1 * from T_TASK_INFO info where info.FILE_TYPE_ID = :fileTypeId and " +
14 + "info.AWB_NUMBER = :consignmentCode order by CREATE_TIME DESC")
15 + public TaskInfo findTaskInfoByConsignment(@Param("fileTypeId") Long taskStatusId,@Param("consignmentCode") String consignmentCode);
16 +
17 +}
1 package com.erry.iclear.dateInterface.service; 1 package com.erry.iclear.dateInterface.service;
2 2
3 //import cn.hutool.core.date.DateUtil; 3 //import cn.hutool.core.date.DateUtil;
4 -import com.erry.iclear.dateInterface.api.request.MawbDetail; 4 +
5 -import com.erry.iclear.dateInterface.enums.ErrorCodeEnum;
6 import com.erry.iclear.dateInterface.api.request.FedexMawb; 5 import com.erry.iclear.dateInterface.api.request.FedexMawb;
7 import com.erry.iclear.dateInterface.api.request.FedexReceipt; 6 import com.erry.iclear.dateInterface.api.request.FedexReceipt;
8 import com.erry.iclear.dateInterface.api.request.Mawb; 7 import com.erry.iclear.dateInterface.api.request.Mawb;
9 import com.erry.iclear.dateInterface.api.response.ResultRS; 8 import com.erry.iclear.dateInterface.api.response.ResultRS;
10 import com.erry.iclear.dateInterface.common.Constant; 9 import com.erry.iclear.dateInterface.common.Constant;
11 import com.erry.iclear.dateInterface.entity.*; 10 import com.erry.iclear.dateInterface.entity.*;
12 -import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; 11 +import com.erry.iclear.dateInterface.enums.ErrorCodeEnum;
13 -import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository; 12 +import com.erry.iclear.dateInterface.repository.*;
14 -import com.erry.iclear.dateInterface.repository.SysUserRepository;
15 import com.erry.iclear.dateInterface.util.DateUtils; 13 import com.erry.iclear.dateInterface.util.DateUtils;
16 import com.erry.iclear.dateInterface.util.NumberUtils; 14 import com.erry.iclear.dateInterface.util.NumberUtils;
17 import com.erry.iclear.dateInterface.util.StringUtil; 15 import com.erry.iclear.dateInterface.util.StringUtil;
...@@ -20,13 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,13 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
21 19
22 import javax.transaction.Transactional; 20 import javax.transaction.Transactional;
23 -import javax.validation.Valid;
24 import java.text.ParseException; 21 import java.text.ParseException;
25 import java.text.SimpleDateFormat; 22 import java.text.SimpleDateFormat;
26 -import java.util.ArrayList; 23 +import java.util.*;
27 -import java.util.Date; 24 +import java.util.stream.Collectors;
28 -import java.util.List;
29 -import java.util.Objects;
30 25
31 /** 26 /**
32 * @author Administrator 27 * @author Administrator
...@@ -51,6 +46,12 @@ public class ChmConsignmentService { ...@@ -51,6 +46,12 @@ public class ChmConsignmentService {
51 @Autowired 46 @Autowired
52 private SysUserRepository sysUserRepository; 47 private SysUserRepository sysUserRepository;
53 48
49 + @Autowired
50 + private TaskInfoRepository taskInfoRepository;
51 +
52 + @Autowired
53 + private OrganizationRepository organizationRepository;
54 +
54 /** 55 /**
55 * 转换主单 56 * 转换主单
56 * @return 57 * @return
...@@ -232,8 +233,14 @@ public class ChmConsignmentService { ...@@ -232,8 +233,14 @@ public class ChmConsignmentService {
232 233
233 //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据 234 //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
234 result.setCreateTime(new Date()); 235 result.setCreateTime(new Date());
235 - result.setUpdateTime(pushTime); 236 + result.setUpdateTime(new Date());
237 + SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
238 + if (sysUser == null){
236 result.setCreator(creator); 239 result.setCreator(creator);
240 + }else {
241 + result.setCreatorId(sysUser);
242 + result.setCreator(sysUser.getUserName());
243 + }
237 244
238 }catch (Exception e){ 245 }catch (Exception e){
239 result=null; 246 result=null;
...@@ -294,11 +301,12 @@ public class ChmConsignmentService { ...@@ -294,11 +301,12 @@ public class ChmConsignmentService {
294 //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据 301 //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
295 result.setCreateTime(new Date()); 302 result.setCreateTime(new Date());
296 result.setUpdateTime(pushTime); 303 result.setUpdateTime(pushTime);
297 - if (!creator.equals("IDE-ICLEAR-API")){
298 SysUser sysUser = sysUserRepository.findUserByLoginName(creator); 304 SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
299 - 305 + if (sysUser == null){
306 + result.setCreator(creator);
307 + }else {
300 result.setCreatorId(sysUser); 308 result.setCreatorId(sysUser);
301 - result.setCreator(sysUser.getLoginName()); 309 + result.setCreator(sysUser.getUserName());
302 } 310 }
303 }catch (Exception e){ 311 }catch (Exception e){
304 result=null; 312 result=null;
...@@ -492,6 +500,20 @@ public class ChmConsignmentService { ...@@ -492,6 +500,20 @@ public class ChmConsignmentService {
492 } 500 }
493 501
494 /** 502 /**
503 + * 根据运单号查找多条数据
504 + * @param consignmentCode
505 + * @return
506 + */
507 + public List<ChmConsignment> findChmConsignmentByConsignmentCodes(String consignmentCode, Date startDate,String creator){
508 + try {
509 + return chmConsignmentRepository.findChmConsignmentByConsignmentCodes(consignmentCode,startDate,creator);
510 + }catch (Exception e){
511 + log.error("findChmConsignmentByConsignmentCode() error:"+ e.getMessage());
512 + }
513 + return null;
514 + }
515 +
516 + /**
495 * 保存或更新 iclear中的运单信息 517 * 保存或更新 iclear中的运单信息
496 * @param mawb 518 * @param mawb
497 * @param timeStamp 519 * @param timeStamp
...@@ -513,19 +535,46 @@ public class ChmConsignmentService { ...@@ -513,19 +535,46 @@ public class ChmConsignmentService {
513 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList); 535 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
514 536
515 //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入 537 //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
516 - ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7)); 538 + ChmConsignment chmConsignmentDB = null;
517 - 539 +// ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7));
518 - //获取用户账号信息 540 + SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
519 - SysUser sysUser = sysUserRepository.findUserByLoginName("CUSTOMS"); 541 + String username = null;
542 + if (sysUser == null){
543 + username = creator;
544 + }else {
520 //设置当前运单创建人ID 545 //设置当前运单创建人ID
521 chmConsignment.setCreatorId(sysUser); 546 chmConsignment.setCreatorId(sysUser);
547 + username = sysUser.getUserName();
548 + }
549 + List<ChmConsignment> chmConsignmentDBs=this.findChmConsignmentByConsignmentCodes(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7),username);
550 + List<ChmConsignment> newChmConsignments = new ArrayList<ChmConsignment>();
551 + for (ChmConsignment chmConsignments : chmConsignmentDBs) {
552 + //如果有该用户曾经提交过得,运单状态为预审不通过或者中心审核已通过并且没有dm004的优先覆盖
553 + if (chmConsignments.getConsStatusDic().getCode().equals("transferWaybillStatus_3")){
554 + chmConsignmentDB = chmConsignments;
555 + break;
556 + }else if ((chmConsignments.getConsStatusDic().getCode().equals("transferWaybillStatus_15")
557 + || chmConsignments.getConsStatusDic().getCode().equals("transferWaybillStatus_1") || chmConsignments.getConsStatusDic().getCode().equals("transferWaybillStatus_24"))){
558 + //如果有新建、sep新建、草稿状态的,先存下来,按创建日期排序覆盖最后一个
559 + newChmConsignments.add(chmConsignments);
560 + }
561 + }
562 +
563 + if (chmConsignmentDB == null && !newChmConsignments.isEmpty()){
564 + List<ChmConsignment> sortList = newChmConsignments.stream().sorted(Comparator.comparing(ChmConsignment::getCreateTime).reversed()).collect(Collectors.toList());
565 + chmConsignmentDB = sortList.get(0);
566 + }
567 +
568 + //获取用户账号信息
522 //设置创建人名称 569 //设置创建人名称
523 - chmConsignment.setCreator(sysUser.getUserName()); 570 + chmConsignment.setCreator(username);
524 571
525 //3、新增或更新 572 //3、新增或更新
526 //新增:如果没有就插入 573 //新增:如果没有就插入
527 if (Objects.equals(chmConsignmentDB,null)){ 574 if (Objects.equals(chmConsignmentDB,null)){
528 log.info("新增主单"+ mawb.getBillNo()); 575 log.info("新增主单"+ mawb.getBillNo());
576 + //如果有dm004把dm004更新上去
577 + updateDM004(chmConsignment);
529 ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment); 578 ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment);
530 if(!Objects.equals(chmConsignmentSaveResult,null)){ 579 if(!Objects.equals(chmConsignmentSaveResult,null)){
531 log.info("主单"+ mawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId()); 580 log.info("主单"+ mawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId());
...@@ -540,9 +589,9 @@ public class ChmConsignmentService { ...@@ -540,9 +589,9 @@ public class ChmConsignmentService {
540 //条件1、状态为 待申报海关 589 //条件1、状态为 待申报海关
541 //条件2、本次推送时间 > 上次推送的时间 590 //条件2、本次推送时间 > 上次推送的时间
542 }else if(!Objects.equals(chmConsignmentDB,null) 591 }else if(!Objects.equals(chmConsignmentDB,null)
543 - && Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_5") 592 + //&& Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_5")
544 //TODO 提交时需要打开 593 //TODO 提交时需要打开
545 - && pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime() 594 + //&& pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime()
546 ){ 595 ){
547 //更新数据 596 //更新数据
548 log.info("更新主单"+ mawb.getBillNo()); 597 log.info("更新主单"+ mawb.getBillNo());
...@@ -555,11 +604,13 @@ public class ChmConsignmentService { ...@@ -555,11 +604,13 @@ public class ChmConsignmentService {
555 } 604 }
556 } 605 }
557 } 606 }
607 + //如果有dm004把dm004更新上去
608 + updateDM004(chmConsignment);
558 609
559 chmConsignment.setId(chmConsignmentDB.getId()); 610 chmConsignment.setId(chmConsignmentDB.getId());
560 611
561 chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime()); 612 chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime());
562 - chmConsignment.setUpdateTime(pushTime); 613 + chmConsignment.setUpdateTime(new Date());
563 ChmConsignment updateResult = this.saveChmConsignment(chmConsignment); 614 ChmConsignment updateResult = this.saveChmConsignment(chmConsignment);
564 if(!Objects.equals(updateResult,null)){ 615 if(!Objects.equals(updateResult,null)){
565 log.info("主单"+ mawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId()); 616 log.info("主单"+ mawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId());
...@@ -571,13 +622,48 @@ public class ChmConsignmentService { ...@@ -571,13 +622,48 @@ public class ChmConsignmentService {
571 } 622 }
572 } 623 }
573 }catch (Exception e){ 624 }catch (Exception e){
574 - log.error(""+e.getMessage()); 625 + log.error(""+e.getMessage(),e);
575 } 626 }
576 result.setSuccess(Boolean.TRUE); 627 result.setSuccess(Boolean.TRUE);
577 return result; 628 return result;
578 } 629 }
579 630
580 /** 631 /**
632 + * 如果dm004已经来了,但是运单未提交,则直接更新dm004的数据
633 + */
634 + public ChmConsignment updateDM004(ChmConsignment chmConsignment){
635 + TaskInfo taskInfo = new TaskInfo();
636 + DictionaryEntries dictionaryEntries = dictionaryEntriesRepository.findDictionaryEntriesByCode(Constant.FILE_TYPE_GET_PICK_INFORMATION);
637 + taskInfo = taskInfoRepository.findTaskInfoByConsignment(dictionaryEntries.getId(),chmConsignment.getConsignmentCode());
638 + if (StringUtil.isEmpty(chmConsignment.getScanCode()) && taskInfo!= null){
639 + chmConsignment.setScanCode(taskInfo.getScanCode());
640 + chmConsignment.setScanCodeDic(taskInfo.getScanCodeDic());
641 + chmConsignment.setScanStatusTime(taskInfo.getScanStatusTime());
642 +
643 + //D类OSPR未完成可以修改站点
644 + Organization organizationByName = organizationRepository.findOrganizationByName(taskInfo.getStationName());
645 + if(organizationByName !=null){
646 + DictionaryEntries dictionaryEntries3 = dictionaryEntriesRepository.findDictionaryEntriesByCode(Constant.consType_D);
647 + if (chmConsignment.getConsType().equals(dictionaryEntries3.getChineseName())){
648 + if (chmConsignment.getOsprStatusDic()!=null){
649 + if(chmConsignment.getOsprStatusDic().getCode().equals(Constant.OSPR_STATUS_INCOMPLETED)){
650 + chmConsignment.setStation(organizationByName);
651 + chmConsignment.setStationName(organizationByName.getName());
652 + }
653 + }
654 + }else{
655 + chmConsignment.setStation(organizationByName);
656 + chmConsignment.setStationName(organizationByName.getName());
657 + }
658 + }
659 + if(taskInfo.getScanCode().equals(Constant.SCAN_CODE_TAKEN_PART)){
660 + chmConsignment.setPickUpDate(taskInfo.getScanStatusTime());
661 + }
662 + }
663 + return chmConsignment;
664 + }
665 +
666 + /**
581 * 保存或更新 iclear中的运单信息 667 * 保存或更新 iclear中的运单信息
582 * @param fedexMawb 668 * @param fedexMawb
583 * @param timeStamp 669 * @param timeStamp
...@@ -598,14 +684,39 @@ public class ChmConsignmentService { ...@@ -598,14 +684,39 @@ public class ChmConsignmentService {
598 chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetailFedex(detail, chmConsignment,Boolean.FALSE)); 684 chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetailFedex(detail, chmConsignment,Boolean.FALSE));
599 }); 685 });
600 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList); 686 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
601 - 687 + ChmConsignment chmConsignmentDB = null;
602 //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入 688 //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
603 - ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7)); 689 + SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
604 - 690 + String username = null;
691 + if (sysUser == null){
692 + username = creator;
693 + }else {
694 + username = sysUser.getUserName();
695 + }
696 + List<ChmConsignment> chmConsignments = this.findChmConsignmentByConsignmentCodes(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7),username);
697 + //如果没有C类待申报,从list中拿时间最晚的一条去覆盖
698 + List<ChmConsignment> newChmConsignments = new ArrayList<ChmConsignment>();
699 + for (ChmConsignment consignment : chmConsignments) {
700 + //如果是C类待申报的,覆盖
701 + if (consignment.getConsStatusDic().getCode().equals("transferWaybillStatus_16")){
702 + chmConsignmentDB = consignment;
703 + break;
704 + }else if ((consignment.getConsStatusDic().getCode().equals("transferWaybillStatus_15")
705 + || consignment.getConsStatusDic().getCode().equals("transferWaybillStatus_1") || consignment.getConsStatusDic().getCode().equals("transferWaybillStatus_24"))){
706 + newChmConsignments.add(consignment);
707 + }
708 + }
709 + if (chmConsignmentDB == null && !newChmConsignments.isEmpty()){
710 + List<ChmConsignment> sortList = newChmConsignments.stream().sorted(Comparator.comparing(ChmConsignment::getCreateTime).reversed()).collect(Collectors.toList());
711 + chmConsignmentDB = sortList.get(0);
712 + }
605 //3、新增或更新 713 //3、新增或更新
714 + //新增:如果没有就插入,或者存在草稿、sep新建、新建的并且运单id不一样就新增一条
606 //新增:如果没有就插入 715 //新增:如果没有就插入
607 if (Objects.equals(chmConsignmentDB,null)){ 716 if (Objects.equals(chmConsignmentDB,null)){
608 log.info("新增主单"+ fedexMawb.getBillNo()); 717 log.info("新增主单"+ fedexMawb.getBillNo());
718 + //如果有dm004把dm004更新上去
719 + updateDM004(chmConsignment);
609 ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment); 720 ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment);
610 if(!Objects.equals(chmConsignmentSaveResult,null)){ 721 if(!Objects.equals(chmConsignmentSaveResult,null)){
611 log.info("主单"+ fedexMawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId()); 722 log.info("主单"+ fedexMawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId());
...@@ -620,9 +731,9 @@ public class ChmConsignmentService { ...@@ -620,9 +731,9 @@ public class ChmConsignmentService {
620 //条件1、状态为 C类待申报 731 //条件1、状态为 C类待申报
621 //条件2、本次推送时间 > 上次推送的时间 732 //条件2、本次推送时间 > 上次推送的时间
622 }else if(!Objects.equals(chmConsignmentDB,null) 733 }else if(!Objects.equals(chmConsignmentDB,null)
623 - && Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_16") 734 + //&& Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_16")
624 //TODO 提交时需要打开 735 //TODO 提交时需要打开
625 - && pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime() 736 + //&& pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime()
626 ){ 737 ){
627 //更新数据 738 //更新数据
628 log.info("更新主单"+ fedexMawb.getBillNo()); 739 log.info("更新主单"+ fedexMawb.getBillNo());
...@@ -635,9 +746,10 @@ public class ChmConsignmentService { ...@@ -635,9 +746,10 @@ public class ChmConsignmentService {
635 } 746 }
636 } 747 }
637 } 748 }
638 - 749 + //如果有dm004把dm004更新上去
750 + updateDM004(chmConsignment);
639 chmConsignment.setId(chmConsignmentDB.getId()); 751 chmConsignment.setId(chmConsignmentDB.getId());
640 - chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime()); 752 + //chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime());
641 chmConsignment.setUpdateTime(pushTime); 753 chmConsignment.setUpdateTime(pushTime);
642 ChmConsignment updateResult = this.saveChmConsignment(chmConsignment); 754 ChmConsignment updateResult = this.saveChmConsignment(chmConsignment);
643 if(!Objects.equals(updateResult,null)){ 755 if(!Objects.equals(updateResult,null)){
......
...@@ -113,13 +113,13 @@ public class FedexService { ...@@ -113,13 +113,13 @@ public class FedexService {
113 * @param fedexMawb 113 * @param fedexMawb
114 * @return 114 * @return
115 */ 115 */
116 - public ResultRS checkFedexMawb(FedexMawb fedexMawb,AppInfo appInfo){ 116 + public ResultRS checkFedexMawb(FedexMawb fedexMawb,AppInfo appInfo,String appId){
117 ResultRS result = new ResultRS(Boolean.FALSE,null,null,null); 117 ResultRS result = new ResultRS(Boolean.FALSE,null,null,null);
118 try{ 118 try{
119 log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(fedexMawb)); 119 log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(fedexMawb));
120 120
121 //1、将请求转换为运单 121 //1、将请求转换为运单
122 - ChmConsignment chmConsignment=consignmentService.convertToChmConsignmentFedex(fedexMawb,null,"IDE-ICLEAR-API",appInfo); 122 + ChmConsignment chmConsignment=consignmentService.convertToChmConsignmentFedex(fedexMawb,null,appId,appInfo);
123 if(Objects.equals(chmConsignment,null)){ 123 if(Objects.equals(chmConsignment,null)){
124 result.setCode(ErrorCodeEnum.ERROR_7.getCode()); 124 result.setCode(ErrorCodeEnum.ERROR_7.getCode());
125 result.setMsg(ErrorCodeEnum.ERROR_7.getName()); 125 result.setMsg(ErrorCodeEnum.ERROR_7.getName());
......
...@@ -2,15 +2,15 @@ package com.erry.iclear.dateInterface.service; ...@@ -2,15 +2,15 @@ package com.erry.iclear.dateInterface.service;
2 2
3 import com.erry.iclear.dateInterface.api.request.FedexMawb; 3 import com.erry.iclear.dateInterface.api.request.FedexMawb;
4 import com.erry.iclear.dateInterface.api.request.FedexMawbDetail; 4 import com.erry.iclear.dateInterface.api.request.FedexMawbDetail;
5 -import com.erry.iclear.dateInterface.common.Constant;
6 -import com.erry.iclear.dateInterface.entity.DictionaryEntries;
7 -import com.erry.iclear.dateInterface.enums.ErrorCodeEnum;
8 import com.erry.iclear.dateInterface.api.request.Mawb; 5 import com.erry.iclear.dateInterface.api.request.Mawb;
9 import com.erry.iclear.dateInterface.api.request.MawbDetail; 6 import com.erry.iclear.dateInterface.api.request.MawbDetail;
10 import com.erry.iclear.dateInterface.api.response.IClearCheckResult; 7 import com.erry.iclear.dateInterface.api.response.IClearCheckResult;
11 import com.erry.iclear.dateInterface.api.response.ResultRS; 8 import com.erry.iclear.dateInterface.api.response.ResultRS;
9 +import com.erry.iclear.dateInterface.common.Constant;
12 import com.erry.iclear.dateInterface.entity.ChmConsignment; 10 import com.erry.iclear.dateInterface.entity.ChmConsignment;
13 import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; 11 import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
12 +import com.erry.iclear.dateInterface.entity.DictionaryEntries;
13 +import com.erry.iclear.dateInterface.enums.ErrorCodeEnum;
14 import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository; 14 import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository;
15 import com.erry.iclear.dateInterface.repository.MawbRepository; 15 import com.erry.iclear.dateInterface.repository.MawbRepository;
16 import com.erry.iclear.dateInterface.util.HttpUtils; 16 import com.erry.iclear.dateInterface.util.HttpUtils;
...@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.beans.factory.annotation.Value; 23 import org.springframework.beans.factory.annotation.Value;
24 import org.springframework.stereotype.Service; 24 import org.springframework.stereotype.Service;
25 25
26 -import javax.validation.Valid;
27 import java.util.*; 26 import java.util.*;
28 27
29 /** 28 /**
...@@ -301,12 +300,12 @@ public class MawbService { ...@@ -301,12 +300,12 @@ public class MawbService {
301 * @param mawb 300 * @param mawb
302 * @return 301 * @return
303 */ 302 */
304 - public ResultRS checkMawb(Mawb mawb){ 303 + public ResultRS checkMawb(Mawb mawb,String appId){
305 ResultRS result = new ResultRS(Boolean.FALSE,null,null,null); 304 ResultRS result = new ResultRS(Boolean.FALSE,null,null,null);
306 try{ 305 try{
307 log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(mawb)); 306 log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(mawb));
308 //1、将请求转换为运单 307 //1、将请求转换为运单
309 - ChmConsignment chmConsignment=consignmentService.convertToChmConsignment(mawb,null,"IDE-ICLEAR-API"); 308 + ChmConsignment chmConsignment=consignmentService.convertToChmConsignment(mawb,null,appId);
310 if(Objects.equals(chmConsignment,null)){ 309 if(Objects.equals(chmConsignment,null)){
311 result.setCode(ErrorCodeEnum.ERROR_30001.getCode()); 310 result.setCode(ErrorCodeEnum.ERROR_30001.getCode());
312 result.setMsg(ErrorCodeEnum.ERROR_30001.getName()); 311 result.setMsg(ErrorCodeEnum.ERROR_30001.getName());
......