Showing
10 changed files
with
149 additions
and
74 deletions
| ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; | ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; |
| 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; | 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| 12 | 12 | ||
| 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) | 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) |
| 14 | -@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.customer.repository.dao.*"}) | 14 | +@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.customer.repository.dao"}) |
| 15 | @EnableTransactionManagement | 15 | @EnableTransactionManagement |
| 16 | @EnableSwagger2 | 16 | @EnableSwagger2 |
| 17 | public class CustomerApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | 17 | public class CustomerApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | ... | ... |
| ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; | ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; |
| 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; | 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| 12 | 12 | ||
| 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) | 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) |
| 14 | -@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.kafka.repository.dao.*"}) | 14 | +@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.kafka.repository.dao"}) |
| 15 | @EnableTransactionManagement | 15 | @EnableTransactionManagement |
| 16 | @EnableSwagger2 | 16 | @EnableSwagger2 |
| 17 | public class KafkaApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | 17 | public class KafkaApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | ... | ... |
| 1 | package com.fedex.connect.kafka.repository.base; | 1 | package com.fedex.connect.kafka.repository.base; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.common.dao.biz.CeInfoMapper; | 3 | import com.fedex.connect.common.dao.biz.CeInfoMapper; |
| 4 | +import com.fedex.connect.common.dao.biz.ConsignmentMapper; | ||
| 4 | import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper; | 5 | import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper; |
| 5 | import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper; | 6 | import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper; |
| 6 | import com.fedex.connect.kafka.repository.dao.CeInfoMapperExt; | 7 | import com.fedex.connect.kafka.repository.dao.CeInfoMapperExt; |
| ... | @@ -15,6 +16,8 @@ public class AbstractDaoRepository { | ... | @@ -15,6 +16,8 @@ public class AbstractDaoRepository { |
| 15 | @Autowired | 16 | @Autowired |
| 16 | protected CeInfoMapper ceInfoMapper; | 17 | protected CeInfoMapper ceInfoMapper; |
| 17 | @Autowired | 18 | @Autowired |
| 19 | + protected ConsignmentMapper consignmentMapper; | ||
| 20 | + @Autowired | ||
| 18 | protected CeInfoMapperExt ceInfoMapperExt; | 21 | protected CeInfoMapperExt ceInfoMapperExt; |
| 19 | @Autowired | 22 | @Autowired |
| 20 | protected KafkaTemporaryStorageMapperExt kafkaTemporaryStorageMapperExt; | 23 | protected KafkaTemporaryStorageMapperExt kafkaTemporaryStorageMapperExt; | ... | ... |
| 1 | +package com.fedex.connect.kafka.repository.repo.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.model.biz.Consignment; | ||
| 4 | +import com.fedex.connect.kafka.repository.base.AbstractDaoRepository; | ||
| 5 | +import com.fedex.connect.kafka.repository.repo.IConsignmentRepository; | ||
| 6 | +import org.springframework.stereotype.Repository; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Repository | ||
| 11 | +public class ConsignmentRepositoryImpl extends AbstractDaoRepository implements IConsignmentRepository { | ||
| 12 | + @Override | ||
| 13 | + public Consignment save(Consignment entity) { | ||
| 14 | + if(entity != null) { | ||
| 15 | + if (entity.getId() == null || entity.getId().longValue() <= 0) { | ||
| 16 | + consignmentMapper.insertSelective(entity); | ||
| 17 | + } else if (entity.getId() != null && entity.getId().longValue() > 0){ | ||
| 18 | + consignmentMapper.updateByPrimaryKeySelective(entity); | ||
| 19 | + } | ||
| 20 | + } | ||
| 21 | + return entity; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public void saveAll(List<Consignment> list) { | ||
| 26 | + list.stream().forEach(p->{ | ||
| 27 | + if(p.getId() == null || p.getId().longValue() <=0){ | ||
| 28 | + consignmentMapper.insertSelective(p); | ||
| 29 | + }else if(p.getId() != null && p.getId().longValue() >0){ | ||
| 30 | + consignmentMapper.updateByPrimaryKeySelective(p); | ||
| 31 | + } | ||
| 32 | + }); | ||
| 33 | + } | ||
| 34 | +} |
| 1 | package com.fedex.connect.kafka.service.base; | 1 | package com.fedex.connect.kafka.service.base; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.kafka.repository.repo.ICeInfoRepository; | 3 | import com.fedex.connect.kafka.repository.repo.ICeInfoRepository; |
| 4 | +import com.fedex.connect.kafka.repository.repo.IConsignmentRepository; | ||
| 4 | import com.fedex.connect.kafka.repository.repo.IKafkaStorageHistoryRepository; | 5 | import com.fedex.connect.kafka.repository.repo.IKafkaStorageHistoryRepository; |
| 5 | import com.fedex.connect.kafka.repository.repo.IKafkaTemporaryStorageRepository; | 6 | import com.fedex.connect.kafka.repository.repo.IKafkaTemporaryStorageRepository; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -17,4 +18,6 @@ public class BaseService { | ... | @@ -17,4 +18,6 @@ public class BaseService { |
| 17 | protected IKafkaTemporaryStorageRepository kafkaTemporaryStorageRepository; | 18 | protected IKafkaTemporaryStorageRepository kafkaTemporaryStorageRepository; |
| 18 | @Autowired | 19 | @Autowired |
| 19 | protected ICeInfoRepository ceInfoRepository; | 20 | protected ICeInfoRepository ceInfoRepository; |
| 21 | + @Autowired | ||
| 22 | + protected IConsignmentRepository consignmentRepository; | ||
| 20 | } | 23 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | package com.fedex.connect.kafka.service.impl; | 1 | package com.fedex.connect.kafka.service.impl; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | -import com.fedex.connect.common.dependencies.util.DateUtil; | ||
| 5 | import com.fedex.connect.common.dependencies.util.Utils; | 4 | import com.fedex.connect.common.dependencies.util.Utils; |
| 6 | import com.fedex.connect.common.model.biz.CeInfo; | 5 | import com.fedex.connect.common.model.biz.CeInfo; |
| 6 | +import com.fedex.connect.common.model.biz.Consignment; | ||
| 7 | import com.fedex.connect.common.model.sys.KafkaTemporaryStorage; | 7 | import com.fedex.connect.common.model.sys.KafkaTemporaryStorage; |
| 8 | -import com.fedex.connect.kafka.constants.Constant; | ||
| 9 | import com.fedex.connect.kafka.data.dto.DmProcessResults; | 8 | import com.fedex.connect.kafka.data.dto.DmProcessResults; |
| 10 | -import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501ConAddresses; | ||
| 11 | import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Consignments; | 9 | import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Consignments; |
| 12 | import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Data; | 10 | import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Data; |
| 13 | import com.fedex.connect.kafka.service.IDm501Service; | 11 | import com.fedex.connect.kafka.service.IDm501Service; |
| 14 | import com.fedex.connect.kafka.service.base.BaseService; | 12 | import com.fedex.connect.kafka.service.base.BaseService; |
| 15 | -import org.apache.commons.lang3.StringUtils; | 13 | +import com.fedex.connect.kafka.util.Dm501Util; |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 17 | 16 | ||
| 18 | -import java.util.Date; | ||
| 19 | import java.util.List; | 17 | import java.util.List; |
| 20 | import java.util.Objects; | 18 | import java.util.Objects; |
| 21 | 19 | ||
| ... | @@ -27,6 +25,9 @@ import java.util.Objects; | ... | @@ -27,6 +25,9 @@ import java.util.Objects; |
| 27 | @Service | 25 | @Service |
| 28 | public class Dm501ServiceImpl extends BaseService implements IDm501Service { | 26 | public class Dm501ServiceImpl extends BaseService implements IDm501Service { |
| 29 | 27 | ||
| 28 | + @Autowired | ||
| 29 | + Dm501Util dm501Util; | ||
| 30 | + | ||
| 30 | /** | 31 | /** |
| 31 | * @Author mt | 32 | * @Author mt |
| 32 | * @Description 处理dm501消息 | 33 | * @Description 处理dm501消息 |
| ... | @@ -48,8 +49,7 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service { | ... | @@ -48,8 +49,7 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service { |
| 48 | processResults.setConsignmentCode(consignment.getTrackingNumber()); | 49 | processResults.setConsignmentCode(consignment.getTrackingNumber()); |
| 49 | //该运单号不存在创建时间为1个月内CE数据 | 50 | //该运单号不存在创建时间为1个月内CE数据 |
| 50 | if(Objects.isNull(bizCeInfo)){ | 51 | if(Objects.isNull(bizCeInfo)){ |
| 51 | - CeInfo ceInfo = this.generateCeInfo(kafKaTemporaryStorage.getSendTime(),consignment); | 52 | + CeInfo ceInfo = dm501Util.generateCeInfo(kafKaTemporaryStorage.getSendTime(),consignment); |
| 52 | - ceInfoRepository.save(ceInfo); | ||
| 53 | } | 53 | } |
| 54 | }); | 54 | }); |
| 55 | return processResults; | 55 | return processResults; |
| ... | @@ -57,69 +57,13 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service { | ... | @@ -57,69 +57,13 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service { |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | * @Author mt | 59 | * @Author mt |
| 60 | - * @Description 生成CE数据实体 | 60 | + * @Description 保存ce信息、以及运单表信息 |
| 61 | - * @Date 2024/4/22 | 61 | + * @Date 2024/11/1 |
| 62 | - * @param dm501Consignment | 62 | + * @param ceInfo |
| 63 | - * @return com.fedex.connect.common.model.biz.CeInfo | 63 | + * @param consignment |
| 64 | + * @return void | ||
| 64 | */ | 65 | */ |
| 65 | - private CeInfo generateCeInfo(Date sendTime, Dm501Consignments dm501Consignment){ | 66 | + public void saveCeInfoAndConsignment(CeInfo ceInfo, Consignment consignment){ |
| 66 | - CeInfo bizCeInfo = new CeInfo(); | 67 | + ceInfoRepository.save(ceInfo); |
| 67 | - bizCeInfo.setConsignmentCode(dm501Consignment.getTrackingNumber()); | ||
| 68 | - bizCeInfo.setCreateTime(new Date()); | ||
| 69 | - bizCeInfo.setDestIataCode(dm501Consignment.getDestIataCode()); | ||
| 70 | - //地址信息 | ||
| 71 | - List<Dm501ConAddresses> addressList = dm501Consignment.getAddresses(); | ||
| 72 | - //没有地址信息,不需要处理,不进CE业务表 | ||
| 73 | - if(addressList == null){ | ||
| 74 | - return null; | ||
| 75 | - } | ||
| 76 | - //发件人 | ||
| 77 | - Dm501ConAddresses shipperAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.SHIPPER); | ||
| 78 | - //收件人 | ||
| 79 | - Dm501ConAddresses recipientAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.RECIPIENT); | ||
| 80 | - //没有收发件人地址信息,不需要处理,不进CE业务表 | ||
| 81 | - if(shipperAddress == null || recipientAddress == null){ | ||
| 82 | - return null; | ||
| 83 | - } | ||
| 84 | - //发件人国家 | ||
| 85 | - String shipperCountry = shipperAddress.getCountry(); | ||
| 86 | - //始发国(二字码) | ||
| 87 | - bizCeInfo.setShipperCountry(shipperCountry); | ||
| 88 | - //发件人国家不为TW,不需要处理,不进CE业务表 | ||
| 89 | - if(StringUtils.isEmpty(shipperCountry) || !shipperCountry.trim().equals(Constant.CE_INFO_KEYS.TW)){ | ||
| 90 | - return null; | ||
| 91 | - } | ||
| 92 | - //收件人国家 | ||
| 93 | - String recipientCountry = recipientAddress.getCountry(); | ||
| 94 | - //目的国家二字码 | ||
| 95 | - bizCeInfo.setRecipientCountry(recipientCountry); | ||
| 96 | - //收件人国家不为CN,不需要处理,不进CE业务表 | ||
| 97 | - if(StringUtils.isEmpty(recipientCountry) || !recipientCountry.trim().equals(Constant.CE_INFO_KEYS.CN)){ | ||
| 98 | - return null; | ||
| 99 | - } | ||
| 100 | - bizCeInfo.setSendTime(sendTime); | ||
| 101 | - String shipDate = dm501Consignment.getShipDate(); | ||
| 102 | - if(StringUtils.isNotEmpty(shipDate)){ | ||
| 103 | - bizCeInfo.setShipDate(DateUtil.parse(shipDate)); | ||
| 104 | - } | ||
| 105 | - return bizCeInfo; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - /** | ||
| 109 | - * 根据类型获取地址信息 | ||
| 110 | - * SHIPPER/发件人---RECIPIENT/收件人---BROKEN/代理人 | ||
| 111 | - * @param type | ||
| 112 | - * @return | ||
| 113 | - */ | ||
| 114 | - private Dm501ConAddresses queryDM501Addresses(List<Dm501ConAddresses> addressList,String type){ | ||
| 115 | - Dm501ConAddresses address = null; | ||
| 116 | - for(int i = 0 ; i < addressList.size() ; i ++){ | ||
| 117 | - Dm501ConAddresses ad = addressList.get(i); | ||
| 118 | - if(ad.getType().equals(type)){ | ||
| 119 | - address = ad; | ||
| 120 | - break; | ||
| 121 | - } | ||
| 122 | - } | ||
| 123 | - return address; | ||
| 124 | } | 68 | } |
| 125 | } | 69 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | +package com.fedex.connect.kafka.util; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.util.DateUtil; | ||
| 4 | +import com.fedex.connect.common.model.biz.CeInfo; | ||
| 5 | +import com.fedex.connect.kafka.constants.Constant; | ||
| 6 | +import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501ConAddresses; | ||
| 7 | +import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Consignments; | ||
| 8 | +import org.apache.commons.lang3.StringUtils; | ||
| 9 | +import org.springframework.stereotype.Component; | ||
| 10 | + | ||
| 11 | +import java.util.Date; | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +@Component | ||
| 15 | +public class Dm501Util { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * @Author mt | ||
| 19 | + * @Description 生成CE数据实体 | ||
| 20 | + * @Date 2024/4/22 | ||
| 21 | + * @param dm501Consignment | ||
| 22 | + * @return com.fedex.connect.common.model.biz.CeInfo | ||
| 23 | + */ | ||
| 24 | + public CeInfo generateCeInfo(Date sendTime, Dm501Consignments dm501Consignment){ | ||
| 25 | + CeInfo ceInfo = new CeInfo(); | ||
| 26 | + ceInfo.setConsignmentCode(dm501Consignment.getTrackingNumber()); | ||
| 27 | + ceInfo.setCreateTime(new Date()); | ||
| 28 | + ceInfo.setDestIataCode(dm501Consignment.getDestIataCode()); | ||
| 29 | + //地址信息 | ||
| 30 | + List<Dm501ConAddresses> addressList = dm501Consignment.getAddresses(); | ||
| 31 | + //没有地址信息,不需要处理,不进CE业务表 | ||
| 32 | + if(addressList == null){ | ||
| 33 | + return null; | ||
| 34 | + } | ||
| 35 | + //发件人 | ||
| 36 | + Dm501ConAddresses shipperAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.SHIPPER); | ||
| 37 | + //收件人 | ||
| 38 | + Dm501ConAddresses recipientAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.RECIPIENT); | ||
| 39 | + //没有收发件人地址信息,不需要处理,不进CE业务表 | ||
| 40 | + if(shipperAddress == null || recipientAddress == null){ | ||
| 41 | + return null; | ||
| 42 | + } | ||
| 43 | + //发件人国家 | ||
| 44 | + String shipperCountry = shipperAddress.getCountry(); | ||
| 45 | + //始发国(二字码) | ||
| 46 | + ceInfo.setShipperCountry(shipperCountry); | ||
| 47 | + //收件人国家 | ||
| 48 | + String recipientCountry = recipientAddress.getCountry(); | ||
| 49 | + //目的国家二字码 | ||
| 50 | + ceInfo.setRecipientCountry(recipientCountry); | ||
| 51 | + //收件人国家不为CN,不需要处理,不进CE业务表 | ||
| 52 | + if(StringUtils.isEmpty(recipientCountry) || !recipientCountry.trim().equals(Constant.CE_INFO_KEYS.CN)){ | ||
| 53 | + return null; | ||
| 54 | + } | ||
| 55 | + ceInfo.setSendTime(sendTime); | ||
| 56 | + String shipDate = dm501Consignment.getShipDate(); | ||
| 57 | + if(StringUtils.isNotEmpty(shipDate)){ | ||
| 58 | + ceInfo.setShipDate(DateUtil.parse(shipDate)); | ||
| 59 | + } | ||
| 60 | + return ceInfo; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 根据类型获取地址信息 | ||
| 65 | + * SHIPPER/发件人---RECIPIENT/收件人---BROKEN/代理人 | ||
| 66 | + * @param type | ||
| 67 | + * @return | ||
| 68 | + */ | ||
| 69 | + private Dm501ConAddresses queryDM501Addresses(List<Dm501ConAddresses> addressList,String type){ | ||
| 70 | + Dm501ConAddresses address = null; | ||
| 71 | + for(int i = 0 ; i < addressList.size() ; i ++){ | ||
| 72 | + Dm501ConAddresses ad = addressList.get(i); | ||
| 73 | + if(ad.getType().equals(type)){ | ||
| 74 | + address = ad; | ||
| 75 | + break; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + return address; | ||
| 79 | + } | ||
| 80 | +} |
| ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; | ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; |
| 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; | 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| 12 | 12 | ||
| 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) | 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) |
| 14 | -@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.manager.repository.dao.*"}) | 14 | +@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.manager.repository.dao"}) |
| 15 | @EnableTransactionManagement | 15 | @EnableTransactionManagement |
| 16 | @EnableSwagger2 | 16 | @EnableSwagger2 |
| 17 | public class ManagerApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | 17 | public class ManagerApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | ... | ... |
| ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; | ... | @@ -11,7 +11,7 @@ import org.springframework.web.WebApplicationInitializer; |
| 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; | 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| 12 | 12 | ||
| 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) | 13 | @SpringBootApplication(exclude = SecurityAutoConfiguration.class) |
| 14 | -@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.task.repository.dao.*"}) | 14 | +@MapperScan({"com.fedex.connect.common.dao.*.**","com.fedex.connect.task.repository.dao"}) |
| 15 | @EnableTransactionManagement | 15 | @EnableTransactionManagement |
| 16 | @EnableSwagger2 | 16 | @EnableSwagger2 |
| 17 | public class TaskApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | 17 | public class TaskApplication extends SpringBootServletInitializer implements WebApplicationInitializer { | ... | ... |
-
Please register or login to post a comment