tao.mo

task-schedule | 修改 | 推送IMP001报文开发

mt
2024年11月21日16:13:02
Showing 26 changed files with 305 additions and 331 deletions
......@@ -17,5 +17,5 @@ public interface AttachmentExtMapper {
@Select("SELECT * FROM T_BIZ_ATTACHMENT WHERE UPLOAD_RECORD_ID = " +
"(SELECT MAX(ID) FROM T_BIZ_UPLOAD_RECORD WHERE CREATE_USER_ID = #{query.userId} " +
"AND CONSIGNMENT_ID = #{query.consignmentId}) AND STATUS = 1")
Attachment queryInfo(@Param("query") UserConsignmentInfoQuery query);
List<Attachment> queryInfo(@Param("query") UserConsignmentInfoQuery query);
}
\ No newline at end of file
......
......@@ -10,7 +10,7 @@ import java.util.List;
public interface IAttachmentRepository {
List<AttachmentHistoryDto> findHistory(AttachmentHistoryQuery attachmentHistoryQuery);
Attachment queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery);
List<Attachment> queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery);
Attachment saveOrUpdate(Attachment entity);
......
......@@ -26,7 +26,7 @@ public class AttachmentRepositoryImpl extends BaseDao implements IAttachmentRepo
* @return com.fedex.connect.common.model.biz.Attachment
*/
@Override
public Attachment queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){
public List<Attachment> queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){
return attachmentExtMapper.queryInfo(userConsignmentInfoQuery);
}
......
......@@ -7,6 +7,8 @@ import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IAttachmentQueryService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author Szl
* @Description 类说明 附件查询相关service
......@@ -23,7 +25,7 @@ public class AttachmentQueryServiceImpl extends BaseService implements IAttachme
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
public ResponseVo queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){
Attachment attachment = attachmentRepository.queryInfo(userConsignmentInfoQuery);
return responseUtils.success(attachment);
List<Attachment> attachmentList = attachmentRepository.queryInfo(userConsignmentInfoQuery);
return responseUtils.success(attachmentList);
}
}
\ No newline at end of file
......
......@@ -21,8 +21,12 @@ public interface ParamConfigConstants {
* @Date 2024/11/20
*/
interface TASK_PARAM_KEYS{
//推送TW001间隔配置key
//推送IMP001任务间隔
String PUSH_IMP001_INTERVAL = "push_imp001_interval";
//推送IMP001定时任务处理数量
String PUSH_IMP001_NUMBER = "push_imp001_number";
//推送IMP001重试处理数量
String PUSH_IMP001_RETRY_NUMBER = "push_imp001_retry_number";
//推送进口文件定时任务处理数量
String PUSH_CON_NUMBER = "push_con_number";
//通知发件人定时任务处理数量
......
package com.fedex.connect.task.constants;
/**
* @Author mt
* @Description 类说明 常量接口
* @Date 2024/4/18
*/
public interface Constant {
//TW001表头信息
interface IMP001_HEAD_KEYS{
/**
* 消息代码:IMP001报文标志
*/
String MESSAGE_CODE = "IMP001";
/**
* 发送程序ID:TWEXP
*/
String SENDER_ID = "TWEXP";
/**
* 接受程序ID:IMP
*/
String RECEIVER_ID = "IMP";
}
//文件后缀字符串keys
interface FILE_SUFFIX_KEYS{
/**
* json字符串
*/
String JSON = ".json";
/**
* temp临时文件
*/
String TEMP = ".temp";
/**
* zip文件后缀
*/
String ZIP = ".zip";
}
}
\ No newline at end of file
package com.fedex.connect.task.data.dto.imp001;
import com.fedex.connect.common.dependencies.arithmetic.AESUtil;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
......@@ -25,65 +23,5 @@ public class Imp001Consignment implements Serializable {
* @Description 联络人
* @Date 2024/5/23
*/
private String liaisons;
/**
* @Author mt
* @Description 货物输出统一编号
* 8-12位,数字加英文大写
* @Date 2024/5/23
*/
private String consigneeNo;
/**
* @Author mt
* @Description 联络人email
* 标准邮件格式:xxx@xx.com
* @Date 2024/5/23
*/
private String email;
/**
* @Author mt
* @Description 联络电话
* 包含:数字、空格-()()#::,,;;+.
* @Date 2024/5/23
*/
private String tel;
/**
* @Author mt
* @Description 分机
* 包含:数字、空格-()()#::,,;;+.
* @Date 2024/5/23
*/
private String extensionTel;
/**
* @Author mt
* @Description 行动电话
* 包含:数字、空格-()()#::,,;;+.
* @Date 2024/5/23
*/
private String phone;
/**
* @Author mt
* @Description 特殊交代事项
* @Date 2024/5/23
*/
private String customsClearanceInstruction;
/**
* @Author mt
* @Description 对部分字段进行解密
* @Date 2024/6/13
* @param
* @return void
*/
public void decode() {
if (StringUtils.isNotBlank(this.getLiaisons())){
this.setLiaisons(AESUtil.decode_default(this.getLiaisons()));
}
if (StringUtils.isNotBlank(this.getTel())){
this.setTel(AESUtil.decode_default(this.getTel()));
}
if (StringUtils.isNotBlank(this.getPhone())){
this.setPhone(AESUtil.decode_default(this.getPhone()));
}
}
private Integer attachedFilesCount;
}
\ No newline at end of file
......
......@@ -20,20 +20,19 @@ public class Imp001Files implements Serializable {
private String name;
/**
* @Author mt
* @Description 文件来源
* "文件类型
* (1:系统生成的的“聯絡方式與特殊交待事項”。2:系统生成的“出口報關檢核表”。3:用户上传的文件)"
* @Date 2024/5/23
*/
private Integer source;
/**
* @Author mt
* @Description 文件名后缀
* 小写
* @Date 2024/5/23
*/
private String suffix;
/**
* @Author mt
* @Description 分运单,发票,箱单和其它这四种类型 AWB,INV,PKL,OTH
* 大写
* @Date 2024/5/23
*/
private String contentType;
/**
* @Author mt
* @Description 文件大小
* 字节数
......
......@@ -7,7 +7,7 @@ import java.io.Serializable;
/**
* @Author mt
* @Description tw001消息主体
* @Description imp001消息主体
* @Date 2024/5/23
*/
@Data
......
package com.fedex.connect.task.repository.base;
import com.fedex.connect.common.dao.biz.ConsignmentMapper;
import com.fedex.connect.common.dao.biz.EmailMapper;
import com.fedex.connect.common.dao.biz.PushObMapper;
import com.fedex.connect.common.dao.log.EmailHistoryMapper;
......@@ -34,4 +35,6 @@ public class AbstractDaoRepository {
protected PushObMapperExt pushObMapperExt;
@Autowired
protected ParamConfigMapper paramConfigMapper;
@Autowired
protected ConsignmentMapper consignmentMapper;
}
\ No newline at end of file
......
package com.fedex.connect.task.repository.dao;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.task.data.dto.PushZipEmailDto;
import org.apache.ibatis.annotations.*;
......@@ -14,4 +15,8 @@ public interface AttachmentExtMapper {
"WHERE a.BIZ_ID = #{bizId}")
List<PushZipEmailDto> findAttachmentDetailsByBizId(@Param("bizId") Long bizId);
@Select("SELECT * FROM T_BIZ_ATTACHMENT WHERE UPLOAD_RECORD_ID = " +
"(SELECT MAX(ID) FROM T_BIZ_UPLOAD_RECORD WHERE " +
" CONSIGNMENT_ID = #{consignmentId}) AND STATUS = 1")
List<Attachment> queryAttachmentInfo(@Param("consignmentId") Long consignmentId);
}
......
......@@ -11,18 +11,18 @@ import java.util.List;
public interface PushObMapperExt {
@Select( "<script>" +
"SELECT * FROM T_PUSH_OB_LOG WHERE STATUS_CODE = #{statusCode,jdbcType=VARCHAR} AND ROWNUM &lt;= 500" +
"SELECT * FROM T_BIZ_PUSH_OB WHERE STATUS_CODE = #{statusCode,jdbcType=VARCHAR} AND ROWNUM &lt;= #{rownum,jdbcType=NUMERIC}" +
"</script>")
List<PushOb> findPushObByStatus(@Param("statusCode") String statusCode);
List<PushOb> findPushObByStatus(@Param("statusCode") String statusCode,@Param("rownum") Long rownum);
@Select( "<script>" +
"SELECT * FROM T_PUSH_OB_LOG WHERE PUSH_NUM &lt; #{pushNum,jdbcType=NUMERIC} AND STATUS_CODE = #{statusCode,jdbcType=VARCHAR} AND ROWNUM &lt;= 500" +
"SELECT * FROM T_BIZ_PUSH_OB WHERE PUSH_NUM &lt; #{pushNum,jdbcType=NUMERIC} AND STATUS_CODE = #{statusCode,jdbcType=VARCHAR} AND ROWNUM &lt;= #{rownum,jdbcType=NUMERIC}" +
"</script>")
List<PushOb> findPushObByStatusAndNum(@Param("pushNum") Long pushNum, @Param("statusCode") String statusCode);
List<PushOb> findPushObByStatusAndNum(@Param("pushNum") Long pushNum, @Param("statusCode") String statusCode,@Param("rownum") Long rownum);
@Select( "<script>" +
"SELECT count(*) FROM T_PUSH_OB_LOG WHERE PUSH_NUM &gt;= #{pushNum,jdbcType=NUMERIC} AND PUSH_STATUS = #{statusCode,jdbcType=VARCHAR} " +
"SELECT count(*) FROM T_BIZ_PUSH_OB WHERE PUSH_NUM &gt;= #{pushNum,jdbcType=NUMERIC} AND PUSH_STATUS = #{statusCode,jdbcType=VARCHAR} " +
"AND TRUNC(CREATE_TIME) = TRUNC(TO_DATE(#{date,jdbcType=VARCHAR}, 'YYYY-MM-DD'))" +
"</script>")
Integer findErrPushForEmail(@Param("pushNum") Long pushNum, @Param("statusCode") String statusCode, @Param("date") String date);
}
}
\ No newline at end of file
......
package com.fedex.connect.task.repository.repo.biz;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.task.data.dto.PushZipEmailDto;
import org.apache.ibatis.annotations.Param;
......@@ -8,4 +9,6 @@ import java.util.List;
public interface IAttachmentRepository {
List<PushZipEmailDto> findAttachmentDetailsByBizId(@Param("bizId") Long bizId);
List<Attachment> queryAttachmentInfo(Long consignmentId);
}
......
package com.fedex.connect.task.repository.repo.biz;
import com.fedex.connect.common.model.biz.Consignment;
public interface IConsignmentRepository {
Consignment findById(Long id);
}
......@@ -28,9 +28,10 @@ public interface IPushObRepository {
* @Description 根据推送次数,推送状态查找需要推送记录
* @Date 2024/11/20
* @param statusCode
* @param rownum
* @return java.util.List<com.fedex.connect.common.model.biz.PushOb>
*/
List<PushOb> findPushOb(String statusCode);
List<PushOb> findPushOb(String statusCode,Long rownum);
/**
* @Author mt
......@@ -38,9 +39,10 @@ public interface IPushObRepository {
* @Date 2024/11/20
* @param pushNum
* @param statusCode
* @param rownum
* @return java.util.List<com.fedex.connect.common.model.biz.PushOb>
*/
List<PushOb> findErrPushOb(Long pushNum,String statusCode);
List<PushOb> findErrPushOb(Long pushNum,String statusCode,Long rownum);
Integer findErrPushForEmail(Long pushNum,String statusCode,String date);
}
......
package com.fedex.connect.task.repository.repo.biz.impl;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.task.data.dto.PushZipEmailDto;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.biz.IAttachmentRepository;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -14,4 +16,9 @@ public class AttachmentRepositoryImpl extends AbstractDaoRepository implements I
public List<PushZipEmailDto> findAttachmentDetailsByBizId(Long bizId) {
return attachmentExtMapper.findAttachmentDetailsByBizId(bizId);
}
@Override
public List<Attachment> queryAttachmentInfo(Long consignmentId){
return attachmentExtMapper.queryAttachmentInfo(consignmentId);
}
}
......
package com.fedex.connect.task.repository.repo.biz.impl;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.biz.IConsignmentRepository;
import org.springframework.stereotype.Repository;
@Repository
public class ConsignmentRepositoryImpl extends AbstractDaoRepository implements IConsignmentRepository {
/**
* @Author mt
* @Description 根据运单ID查找运单信息
* @Date 2024/11/18
* @param id
* @return com.fedex.connect.common.model.biz.Consignment
*/
public Consignment findById(Long id){
return consignmentMapper.selectByPrimaryKey(id);
}
}
......@@ -41,8 +41,8 @@ public class PushObRepositoryImpl extends AbstractDaoRepository implements IPush
* @return java.util.List<com.fedex.connect.common.model.biz.PushOb>
*/
@Override
public List<PushOb> findPushOb(String statusCode) {
return pushObMapperExt.findPushObByStatus(statusCode);
public List<PushOb> findPushOb(String statusCode,Long rownum) {
return pushObMapperExt.findPushObByStatus(statusCode,rownum);
}
/**
......@@ -54,8 +54,8 @@ public class PushObRepositoryImpl extends AbstractDaoRepository implements IPush
* @return java.util.List<com.fedex.connect.common.model.biz.PushOb>
*/
@Override
public List<PushOb> findErrPushOb(Long pushNum, String statusCode) {
return pushObMapperExt.findPushObByStatusAndNum(pushNum,statusCode);
public List<PushOb> findErrPushOb(Long pushNum, String statusCode,Long rownum) {
return pushObMapperExt.findPushObByStatusAndNum(pushNum,statusCode,rownum);
}
@Override
......
......@@ -2,6 +2,9 @@ package com.fedex.connect.task.repository.repo.sys;
import com.fedex.connect.common.model.sys.ParamConfig;
import java.util.Map;
public interface IParamConfigRepository {
ParamConfig findValueByCode(String code);
Map<String,ParamConfig> findValueByCodes(String...strings);
}
......
......@@ -8,6 +8,12 @@ import com.fedex.connect.task.repository.repo.sys.IParamConfigRepository;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Repository
public class ParamConfigRepositoryImpl extends AbstractDaoRepository implements IParamConfigRepository {
......@@ -19,4 +25,19 @@ public class ParamConfigRepositoryImpl extends AbstractDaoRepository implements
criteria.andStatusEqualTo(StatusEnum.YES.getCode());
return CollectionUtils.firstElement(paramConfigMapper.selectByExample(example));
}
@Override
public Map<String,ParamConfig> findValueByCodes(String...strings) {
if(Objects.isNull(strings) || strings.length == 0){
return null;
}
List<String> codes = Arrays.asList(strings);
ParamConfigExample example = new ParamConfigExample();
ParamConfigExample.Criteria criteria = example.createCriteria();
criteria.andCodeIn(codes);
criteria.andStatusEqualTo(StatusEnum.YES.getCode());
List<ParamConfig> paramConfigList = paramConfigMapper.selectByExample(example);
Map<String,ParamConfig> paramConfigMap = paramConfigList.stream().filter(Objects::nonNull).collect(Collectors.toMap(ParamConfig::getCode, paramConfig -> paramConfig));
return paramConfigMap;
}
}
\ No newline at end of file
......
......@@ -6,6 +6,7 @@ import com.fedex.connect.task.repository.repo.biz.IEmailRepository;
import com.fedex.connect.task.repository.repo.biz.IPushObRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaTemporaryStorageRepository;
import com.fedex.connect.task.repository.repo.sys.IParamConfigRepository;
import com.fedex.connect.task.repository.repo.sys.IRedisSlabExtRepository;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,4 +30,6 @@ public class BaseService {
protected IAttachmentRepository attachmentExtRepository;
@Autowired
protected IPushObRepository pushObRepository;
@Autowired
protected IParamConfigRepository paramConfigRepository;
}
\ No newline at end of file
......
package com.fedex.connect.task.service.biz;
import com.fedex.connect.common.model.biz.Consignment;
public interface IPushObService {
/**
* @Author mt
* @Description 保存pushLog表记录
* @Date 2024/8/2
* @param consignment
* @return void
*/
void savePushLog(Consignment consignment);
/**
* @Author mt
* @Description 推送Imp001报文数据zip包文件
* @Date 2024/8/2
* @param
......
package com.fedex.connect.task.service.biz.impl;
import com.fedex.connect.common.dependencies.contants.ParamConfigConstants;
import com.fedex.connect.common.dependencies.enums.biz.PushObStatusEnum;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.biz.PushOb;
import com.fedex.connect.common.model.sys.ParamConfig;
import com.fedex.connect.task.data.bo.Imp001GenerateBo;
import com.fedex.connect.task.service.base.BaseService;
import com.fedex.connect.task.service.biz.IPushObService;
import com.fedex.connect.task.utils.biz.imp001.Imp001GenerateUtil;
import com.fedex.connect.task.utils.biz.imp001.Imp001PushUtil;
import com.fedex.connect.task.utils.biz.imp001.Imp001RecordLogUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @Author mt
......@@ -18,18 +27,25 @@ import java.util.List;
@Slf4j
@Service
public class PushObServiceImpl extends BaseService implements IPushObService {
public void savePushLog(Consignment consignment){
}
@Autowired
Imp001GenerateUtil imp001GenerateUtil;
@Autowired
Imp001PushUtil imp001PushUtil;
@Autowired
Imp001RecordLogUtil imp001RecordLogUtil;
/**
* 推送OB报文数据zip包文件
*/
@Override
public void sendOb() {
//获取每次处理数据量量参数
ParamConfig paramConfig = paramConfigRepository.findValueByCode(ParamConfigConstants.TASK_PARAM_KEYS.PUSH_IMP001_NUMBER);
Long rownum = Long.parseLong(paramConfig.getValue());
//获取需要处理的记录
List<PushOb> pushObLogList = pushObRepository.findPushOb(PushObStatusEnum.TO_BE_SENT.getCode());
List<PushOb> pushObList = pushObRepository.findPushOb(PushObStatusEnum.TO_BE_SENT.getCode(),rownum);
//推送imp001数据
this.pushOb(pushObList);
}
/**
......@@ -37,7 +53,24 @@ public class PushObServiceImpl extends BaseService implements IPushObService {
*/
@Override
public void sendObRetry() {
//获取每次处理数据量量参数
Map<String,ParamConfig> paramConfig = paramConfigRepository.findValueByCodes(ParamConfigConstants.TASK_PARAM_KEYS.PUSH_IMP001_NUMBER,
ParamConfigConstants.TASK_PARAM_KEYS.PUSH_IMP001_RETRY_NUMBER);
//推送IMP001重试处理数量
ParamConfig retryNumConfig = paramConfig.get(ParamConfigConstants.TASK_PARAM_KEYS.PUSH_IMP001_RETRY_NUMBER);
Long retryNum = Long.parseLong(retryNumConfig.getCode());
//推送IMP001定时任务处理数量
ParamConfig rownumConfig = paramConfig.get(ParamConfigConstants.TASK_PARAM_KEYS.PUSH_IMP001_NUMBER);
Long rownum = Long.parseLong(rownumConfig.getCode());
//获取需要重新处理的记录:处理4次以下,并且推送失败的
List<PushOb> errPushObLog = pushObRepository.findErrPushOb(retryNum, PushObStatusEnum.PUSH_FAILED.getCode(),rownum);
if (errPushObLog!=null && !errPushObLog.isEmpty()){
log.info("sendObRetryTask : sendObRetry size: "+errPushObLog.size());
//重新推送tw001数据
this.pushOb(errPushObLog);
}else{
log.info("sendObRetryTask : No data found for sendObRetry!");
}
}
/**
......@@ -48,6 +81,33 @@ public class PushObServiceImpl extends BaseService implements IPushObService {
* @return void
*/
private void pushOb(List<PushOb> pushObList){
Utils.listOf(pushObList).stream().filter(Objects::nonNull).forEach(ob ->{
boolean flag = false;
String errorMsg = "";
Imp001GenerateBo imp001GenerateBo = null;
try {
//生成tw001 json对象dto
imp001GenerateBo = imp001GenerateUtil.generateImp001Json(ob);
//根据tw001 json对象生成并且推送zip包
imp001PushUtil.pushImp001(imp001GenerateBo);
flag = true;
}catch(Exception ex){
log.error("pushOb error : ",ex);
errorMsg = ex.getMessage();
flag = false;
}finally{
/**
* 如果生成失败,推送失败,则不会记录推送日志明细,更新推送日志表。
* 记录日志,并且备份
*/
if(flag){
//推送成功
imp001RecordLogUtil.pushSuccessRecordLog(imp001GenerateBo, ob);
}else{
//推送失败
imp001RecordLogUtil.pushFailRecordLog(imp001GenerateBo, ob, errorMsg);
}
}
});
}
}
\ No newline at end of file
......
//package com.fedex.connect.task.utils.biz.imp001;
//
//import com.fedex.connect.common.dependencies.cache.CacheSystem;
//import com.fedex.connect.common.dependencies.util.NIOFileUtils;
//import com.fedex.connect.common.model.bi.DictionaryEntries;
//import com.fedex.connect.common.model.biz.Attachment;
//import com.fedex.connect.common.model.biz.Consignment;
//import com.fedex.connect.common.model.biz.PushOb;
//import com.fedex.connect.task.config.PropertiesConfig;
//import com.fedex.connect.task.data.bo.Imp001FileInfoBo;
//import com.fedex.connect.task.data.bo.Imp001GenerateBo;
//import com.fedex.connect.task.data.dto.imp001.*;
//import com.fedex.connect.task.repository.repo.biz.IAttachmentRepository;
//import com.fedex.connect.task.repository.repo.biz.IConsignmentRepository;
//import com.fedex.export.common.util.DateUtil;
//import com.fedex.export.common.util.NioFileUtils;
//import com.fedex.export.common.util.StringExtUtil;
......@@ -26,66 +38,55 @@
//
///**
// * @Author mt
// * @Description tw001报文生成json,util
// * @Description imp001报文生成json,util
// * @Date 2024/5/24
// */
//@Slf4j
//@Component
//public class Tw001GenerateUtil {
//public class Imp001GenerateUtil {
// @Autowired
// private ISysDictionaryService sysDictionaryService;
// CacheSystem cacheSystem;
// @Autowired
// private IDeclareInfoService declareInfoService;
// private IAttachmentRepository attachmentRepository;
// @Autowired
// private IDeclareCheckInfoService declareCheckInfoService;
// @Autowired
// private IDeclareCustomsFileService declareCustomsFileService;
// @Autowired
// private IUploadFileService uploadFileService;
// @Autowired
// private NioFileUtils nioFileUtils;
// private NIOFileUtils nioFileUtils;
// @Autowired
// private PropertiesConfig propertiesConfig;
//
// /**
// * @Author mt
// * @Description 生成tw001报文json对象
// * @Date 2024/5/27
// * @param pushObLog
// * @return com.fedex.export.data.dto.tw001.Imp001RootJsonDto
// * @Description 生成imp001报文json对象
// * @Date 2024/11/21
// * @param pushOb
// * @return Imp001GenerateBo
// */
// public Imp001GenerateBo generateTw001Json(PushObLog pushObLog) throws IOException{
// public Imp001GenerateBo generateImp001Json(PushOb pushOb) throws IOException{
// Imp001RootJsonDto tw001RootJsonDto = new Imp001RootJsonDto();
// //根据运单id
// DeclareInfo declareInfo = declareInfoService.findByDeclareId(pushObLog.getDeclareId());
// DeclareCheckInfo declareCheckInfo = declareCheckInfoService.findByDeclareId(pushObLog.getDeclareId());
// DeclareCustomsFile declareCustomsFile = declareCustomsFileService.findByDeclareId(pushObLog.getDeclareId());
// List<UploadFile> uploadFiles = uploadFileService.findFilesByCusFileId(declareCustomsFile);
// //获取文件类型字典集合
// Map<String,SysDictionary> pushFileTypeMap = sysDictionaryService.findDicByCodeGroup(Constant.SEND_TW001_KEYS.PUSH_FILE_TYPE_KEYS.CODE_GROUP);
// //生成TW001报文数据
// Imp001Data tw001Data = new Imp001Data();
// List<Attachment> attachmentList = attachmentRepository.queryAttachmentInfo(pushOb.getConsignmentId());
// //生成IMP001报文数据
// Imp001Data imp001Data = new Imp001Data();
// Imp001Consignments[] consignments = new Imp001Consignments[1];
// Imp001Consignments tw001Consignments = new Imp001Consignments();
// Imp001Consignments imp001Consignments = new Imp001Consignments();
// //生成运单数据
// Imp001Consignment consignment = this.generateConsignment(declareInfo);
// //生成检核表数据
// Tw001CheckInfo checkInfo = this.generateCheckInfo(declareCheckInfo,declareInfo.getDeliveryNo());
// Imp001Consignment imp001Consignment = new Imp001Consignment();
// //运单号
// imp001Consignment.setDeliveryNo(pushOb.getConsignmentCode());
// //附件个数
// imp001Consignment.setAttachedFilesCount(attachmentList.size());
// //生成文件列表数据
// Imp001Files[] files = this.generateFiles(uploadFiles,declareInfo.getDeliveryNo(),declareInfo.getDeclareId());
// Imp001Files[] files = this.generateFiles(attachmentList);
// /***************设置对象赋值***************/
// tw001Consignments.setConsignment(consignment);
// tw001Consignments.setCheckInfo(checkInfo);
// tw001Consignments.setFiles(files);
// consignments[0] = tw001Consignments;
// tw001Data.setConsignments(consignments);
// imp001Consignments.setConsignment(imp001Consignment);
// imp001Consignments.setFiles(files);
// consignments[0] = imp001Consignments;
// imp001Data.setConsignments(consignments);
// //初始化TW001表头信息
// this.initTw001Head(tw001RootJsonDto);
// tw001RootJsonDto.setData(tw001Data);
// this.initImp001Head(tw001RootJsonDto);
// tw001RootJsonDto.setData(imp001Data);
// //返回对象
// Imp001GenerateBo tw001GenerateBo = new Imp001GenerateBo();
// tw001GenerateBo.setDeclareInfo(declareInfo);
// tw001GenerateBo.setTw001RootJsonDto(tw001RootJsonDto);
// tw001GenerateBo.setImp001RootJsonDto(tw001RootJsonDto);
// //获取生成tw001临时文件夹目录
// String workFilePath = this.generateWorkPath(declareInfo.getDeliveryNo(),declareInfo.getDeclareId());
// tw001GenerateBo.setWorkFilePath(workFilePath);
......@@ -115,23 +116,23 @@
// /**
// * @Author mt
// * @Description 初始化TW001表头信息
// * @Date 2024/5/31
// * @param tw001RootJsonDto
// * @Date 2024/11/21
// * @param imp001RootJsonDto
// * @return void
// */
// private void initTw001Head(Imp001RootJsonDto tw001RootJsonDto){
// private void initImp001Head(Imp001RootJsonDto imp001RootJsonDto){
// String UUIDStr=String.valueOf(UUID.randomUUID());
// //消息代码/类型
// tw001RootJsonDto.setMessageId(UUIDStr);
// imp001RootJsonDto.setMessageId(UUIDStr);
// //消息代码/类型
// tw001RootJsonDto.setMessageCode(Constant.SEND_TW001_KEYS.TW001_HEAD_KEYS.MESSAGE_CODE);
// imp001RootJsonDto.setMessageCode(Constant.SEND_TW001_KEYS.TW001_HEAD_KEYS.MESSAGE_CODE);
// //发送程序ID
// tw001RootJsonDto.setSenderId(Constant.SEND_TW001_KEYS.TW001_HEAD_KEYS.SENDER_ID);
// imp001RootJsonDto.setSenderId(Constant.SEND_TW001_KEYS.TW001_HEAD_KEYS.SENDER_ID);
// //接受程序ID
// tw001RootJsonDto.setReceiverId(Constant.SEND_TW001_KEYS.TW001_HEAD_KEYS.RECEIVER_ID);
// imp001RootJsonDto.setReceiverId(Constant.SEND_TW001_KEYS.TW001_HEAD_KEYS.RECEIVER_ID);
// String sendTime = String.valueOf(System.currentTimeMillis());
// //发送时间,时间戳
// tw001RootJsonDto.setSendTime(sendTime);
// imp001RootJsonDto.setSendTime(sendTime);
// }
//
// /**
......@@ -161,7 +162,7 @@
// * @param fileName
// * @return com.fedex.export.data.bo.Imp001FileInfoBo
// */
// private Imp001FileInfoBo initFileInfo(Map<String,SysDictionary> pushFileTypeMap,String fileTypeCode,String fileName){
// private Imp001FileInfoBo initFileInfo(Map<String,SysDictionary> pushFileTypeMap, String fileTypeCode, String fileName){
// Imp001FileInfoBo fileInfoBo = new Imp001FileInfoBo();
// //类型编码不为空则初始化文件id,文件类型
// if(StringUtils.isNotEmpty(fileTypeCode)) {
......@@ -178,111 +179,24 @@
//
// /**
// * @Author mt
// * @Description 生成运单对象vo
// * @Date 2024/5/27
// * @param declareInfo
// * @return com.fedex.export.data.dto.tw001.Imp001Consignment
// */
// private Imp001Consignment generateConsignment(DeclareInfo declareInfo){
// if(declareInfo == null){
// return null;
// }
// Imp001Consignment tw001Consignment = new Imp001Consignment();
// //提单号码
// tw001Consignment.setDeliveryNo(declareInfo.getDeliveryNo());
// //联络人
// tw001Consignment.setLiaisons(declareInfo.getLiaisons());
// //货物输出统一编号
// tw001Consignment.setConsigneeNo(declareInfo.getConsigneeNo());
// //联络人email
// tw001Consignment.setEmail(declareInfo.getEmail());
// //联络电话
// tw001Consignment.setTel(declareInfo.getTel());
// //分机号
// tw001Consignment.setExtensionTel(declareInfo.getExtensionTel());
// //行动电话
// tw001Consignment.setPhone(declareInfo.getPhone());
// //特殊交代事项
// tw001Consignment.setCustomsClearanceInstruction(declareInfo.getCustomsClearanceInstruction());
// //对字段进行解密
// tw001Consignment.decode();
// return tw001Consignment;
// }
//
// /**
// * @Author mt
// * @Description 生成检核表对象vo
// * @Date 2024/5/27
// * @param declareCheckInfo
// * @param deliveryNo
// * @return com.fedex.export.data.dto.tw001.Tw001CheckInfo
// */
// private Tw001CheckInfo generateCheckInfo(DeclareCheckInfo declareCheckInfo,String deliveryNo) throws IOException{
// if(declareCheckInfo == null){
// return null;
// }
// Tw001CheckInfo tw001CheckInfo = new Tw001CheckInfo();
// //报单类别(数据字典的KEY值,多个KEY分号拼接)
// tw001CheckInfo.setCustomsDeclarationType(declareCheckInfo.getCustomsDeclarationType());
// //是否为电子冲退税报单
// tw001CheckInfo.setTaxRefundFormFlag(declareCheckInfo.getTaxRefundFormFlag() == null ? null : declareCheckInfo.getTaxRefundFormFlag().intValue());
// //监管编号-5个字元,包含中文英文大写
// tw001CheckInfo.setSupervisoryNo(declareCheckInfo.getSupervisoryNo());
// //原进口报单号码
// tw001CheckInfo.setOriginalImportEntryNo(declareCheckInfo.getOriginalImportEntryNo());
// //用料清表文号
// tw001CheckInfo.setListOfMaterialsNo(declareCheckInfo.getListOfMaterialsNo());
// //出口统计方式(数据字典KEY值,多个KEY分号拼接)
// tw001CheckInfo.setExportStatisticsMethod(declareCheckInfo.getExportStatisticsMethod());
// //出口统计方式其他附加信息
// tw001CheckInfo.setMethodAdditional(declareCheckInfo.getMethodAdditional());
// //指定报关日
// tw001CheckInfo.setDayOfEntry(declareCheckInfo.getDayOfEntry());
// //中文品名
// tw001CheckInfo.setChineseName(declareCheckInfo.getChineseName());
// //税则
// tw001CheckInfo.setTaxRules(declareCheckInfo.getTaxRules());
// //报关金额
// tw001CheckInfo.setCustomsDeclarationAmount(declareCheckInfo.getCustomsDeclarationAmount());
// //报关金额币别
// tw001CheckInfo.setCurrencyCd(declareCheckInfo.getCurrencyCd());
// //是否有商标
// tw001CheckInfo.setBrandFlag(declareCheckInfo.getBrandFlag() == null ? null : declareCheckInfo.getBrandFlag().intValue());
// //文字商标
// tw001CheckInfo.setBrandTxt(declareCheckInfo.getBrandTxt());
// //图案商标名称
// String brandImage = this.brandImage(declareCheckInfo,deliveryNo);
// //图案商标
// tw001CheckInfo.setBrandImage(brandImage);
// //产证
// tw001CheckInfo.setPropertyCertificate(declareCheckInfo.getPropertyCertificate());
// //ECFA产证
// tw001CheckInfo.setEcfaPropertyCertificate(declareCheckInfo.getEcfaPropertyCertificate());
// //ECFA产证编号
// tw001CheckInfo.setEcfaPropertyCertificateNo(declareCheckInfo.getEcfaPropertyCertificateNo());
// //申请
// tw001CheckInfo.setApplyFor(declareCheckInfo.getApplyFor());
// return tw001CheckInfo;
// }
//
// /**
// * @Author mt
// * @Description 生成文件对象集合vo,并且将文件复制到指定目录
// * @Date 2024/5/27
// * @param uploadFiles
// * @return com.fedex.export.data.dto.tw001.Imp001Files[]
// * @Date 2024/11/21
// * @param attachmentList
// * @return com.fedex.connect.task.data.dto.imp001.Imp001Files[]
// */
// private Imp001Files[] generateFiles(List<UploadFile> uploadFiles,String deliveryNo,Long declareId) throws IOException{
// if(uploadFiles == null || uploadFiles.size() == 0){
// private Imp001Files[] generateFiles(List<Attachment> attachmentList) throws IOException{
// if(attachmentList == null || attachmentList.size() == 0){
// return null;
// }
// Imp001Files[] tw001Files = new Imp001Files[uploadFiles.size()];
// for(int i = 0 ; i < uploadFiles.size() ; i ++){
// UploadFile uploadFile = uploadFiles.get(i);
// Imp001Files[] tw001Files = new Imp001Files[attachmentList.size()];
// for(int i = 0 ; i < attachmentList.size() ; i ++){
// Attachment attachment = attachmentList.get(i);
// Imp001Files file = new Imp001Files();
// //获取文件类型
// Integer source = this.sourceType(uploadFile.getName(),uploadFile.getSource());
// if(source == null){
// //获取附件业务类型
// DictionaryEntries attBizType = cacheSystem.getDicAttachmentBizType(attachment.getBizTypeCode());
// //运单、发票、箱单、其他
// String bizTypeCode = attBizType.getExt1();
// if(StringUtils.isEmpty(bizTypeCode)){
// continue;
// }
// //重置文件名称,并且复制源文件到指定目录
......@@ -341,61 +255,6 @@
//
// /**
// * @Author mt
// * @Description 获取文件类型
// * @Date 2024/5/27
// * @param name 文件名称
// * @param sourceType 1:用户上传。2:系统生成。3:图案商标
// * @return java.lang.Integer
// * (1:系统生成的的“聯絡方式與特殊交待事項”。2:系统生成的“出口報關檢核表”。3:用户上传的文件)
// */
// private Integer sourceType(String name,Long sourceType){
// //1:用户上传。2:系统生成。3:图案商标
// if(sourceType.equals(Constant.SEND_TW001_KEYS.UPLOAD_SOURCE_2)){
// if(name.equals(Constant.SEND_TW001_KEYS.APPLICATION_FORM)){
// //出口報關申請表
// return Constant.SEND_TW001_KEYS.TW001_FILE_SOURCE_1;
// }else if(name.equals(Constant.SEND_TW001_KEYS.REVIEW_FORM)){
// //出口報關檢核表
// return Constant.SEND_TW001_KEYS.TW001_FILE_SOURCE_2;
// }
// }else if(sourceType.equals(Constant.SEND_TW001_KEYS.UPLOAD_SOURCE_1)){
// return Constant.SEND_TW001_KEYS.TW001_FILE_SOURCE_3;
// }
// //如果类型为图案商标则返回null
// return null;
// }
//
// /**
// * @Author mt
// * @Description COMPRESS_12位运单号_10位运单ID_yyyyMMddHHmmssSSS.jpeg 图案商标名称,并且复制源文件到指定目录
// * 【可上传类型:圖片格式僅支持bmp,jpg,jpeg,png格式,大小不超過2M】
// * @Date 2024/5/27
// * @param checkInfo
// * @param deliveryNo
// * @return java.lang.String
// */
// private String brandImage(DeclareCheckInfo checkInfo,String deliveryNo) throws IOException{
// String resBrandImage = null;
// //图案商标名称不为空,并且存在后缀
// if(!Utils.isEmpty(checkInfo.getBrandImage()) && checkInfo.getBrandImage().lastIndexOf(Constant.COMMON_KEYS.SPOT) > 0){
// String suffix = checkInfo.getBrandImage().substring(checkInfo.getBrandImage().lastIndexOf(Constant.COMMON_KEYS.SPOT));
// resBrandImage = Constant.SEND_TW001_KEYS.COMPRESS
// + Constant.COMMON_KEYS.UNDER_LINE + deliveryNo
// + Constant.COMMON_KEYS.UNDER_LINE + StringExtUtil.idLeftPadStr(checkInfo.getDeclareId())
// + Constant.COMMON_KEYS.UNDER_LINE +
// DateUtil.yyyyMMddHH24mmssSSS(new Date()) + suffix;
// //获取源文件目录
// String sourceFilePath = checkInfo.getBrandImage();
// //获取复制目标目录
// String targetFilePath = this.generateWorkPath(deliveryNo,checkInfo.getDeclareId()) + resBrandImage;
// //复制文件到指定目录
// nioFileUtils.copyFile(sourceFilePath,targetFilePath);
// }
// return resBrandImage;
// }
//
// /**
// * @Author mt
// * @Description 生成文件夹目录 /var/share/icleartw/TWIMPORT/work/yyyy-MM-dd/运单号_运单ID/
// * @Date 2024/5/29
// * @param deliveryNo
......
//package com.fedex.connect.task.utils.biz.imp001;
//
//import com.fedex.connect.task.config.PropertiesConfig;
//import com.fedex.connect.task.data.bo.Imp001GenerateBo;
//import com.fedex.export.common.util.*;
//import com.fedex.export.config.PropertiesConfig;
//import com.fedex.export.constants.Constant;
......@@ -7,6 +9,7 @@
//import com.fedex.export.data.bo.Imp001GenerateBo;
//import com.fedex.export.repository.entity.DeclareInfo;
//import com.fedex.export.repository.entity.SysDictionary;
//import lombok.extern.slf4j.Slf4j;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
......@@ -24,9 +27,9 @@
// * @Description tw001报文推送,util
// * @Date 2024/5/29
// */
//@Slf4j
//@Component
//public class Tw001PushUtil {
// private static Logger log = LoggerFactory.getLogger(Tw001PushUtil.class);
//public class Imp001PushUtil {
// @Autowired
// PropertiesConfig propertiesConfig;
// @Autowired
......@@ -36,17 +39,17 @@
//
// /**
// * @Author mt
// * @Description 推送tw001
// * @Date 2024/5/29
// * @param tw001GenerateBo
// * @return com.fedex.export.data.dto.tw001.Imp001RootJsonDto
// * @Description 推送imp001
// * @Date 2024/11/21
// * @param imp001GenerateBo
// * @return void
// */
// public void pushTw001(Imp001GenerateBo tw001GenerateBo) throws Exception{
// public void pushImp001(Imp001GenerateBo imp001GenerateBo) throws Exception{
// long start = System.currentTimeMillis();
// //生成zip临时文件到指定临时目录
// String zipFileName = this.toZips(tw001GenerateBo);
// String zipFileName = this.toZips(imp001GenerateBo);
// //zip原始临时目录,zip为临时文件
// String zipSourceTempFilePath = tw001GenerateBo.getWorkFilePath() + zipFileName + Constant.FILE_SUFFIX_KEYS.TEMP;
// String zipSourceTempFilePath = imp001GenerateBo.getWorkFilePath() + zipFileName + Constant.FILE_SUFFIX_KEYS.TEMP;
// //推送zip文件最终目录
// String zipTargetFilePath = propertiesConfig.getTw001PathFinal() + zipFileName;
// //记录zip文件名称
......
//package com.fedex.connect.task.utils.biz.imp001;
//
//import com.fedex.connect.common.model.biz.PushOb;
//import com.fedex.connect.task.config.PropertiesConfig;
//import com.fedex.connect.task.data.bo.Imp001GenerateBo;
//import com.fedex.export.common.enums.PushLogEnum;
//import com.fedex.export.common.util.DateUtil;
//import com.fedex.export.common.util.NioFileUtils;
......@@ -12,6 +15,7 @@
//import com.fedex.export.repository.entity.log.PushObLog;
//import com.fedex.export.repository.repo.business.IPushObLogRepository;
//import com.fedex.export.service.business.IPushObDetailService;
//import lombok.extern.slf4j.Slf4j;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,9 +31,9 @@
// * @Description 类说明 推送tw001完成,记录日志,并且备份数据
// * @Date 2024/5/30
// */
//@Slf4j
//@Component
//public class Tw001RecordLogUtil {
// private static Logger log = LoggerFactory.getLogger(Tw001RecordLogUtil.class);
//public class Imp001RecordLogUtil {
// @Autowired
// PropertiesConfig propertiesConfig;
// @Autowired
......@@ -41,18 +45,19 @@
//
// /**
// * @Author mt
// * @Description 功能说明 推送成功记录日志
// * @Date 2024/5/30
// * @param tw001GenerateBo
// * @Description 推送成功记录日志
// * @Date 2024/11/21
// * @param imp001GenerateBo
// * @param obLog
// * @return void
// */
// public void pushSuccessRecordLog(Imp001GenerateBo tw001GenerateBo, PushObLog obLog){
// public void pushSuccessRecordLog(Imp001GenerateBo imp001GenerateBo, PushOb obLog){
// try {
// if(Objects.nonNull(tw001GenerateBo)){
// if(Objects.nonNull(imp001GenerateBo)){
// //备份文件,并且记录日志
// String targetPath = this.recordLog(tw001GenerateBo,obLog , propertiesConfig.getTw001PathBak(),PushLogEnum.PUSHED_SUCCESS,null);
// obLog.setFileName(tw001GenerateBo.getZipFileName());
// obLog.setFilePath(tw001GenerateBo.getZipFileTargetPath());
// String targetPath = this.recordLog(imp001GenerateBo,obLog , propertiesConfig.getTw001PathBak(),PushLogEnum.PUSHED_SUCCESS,null);
// obLog.setFileName(imp001GenerateBo.getZipFileName());
// obLog.setFilePath(imp001GenerateBo.getZipFileTargetPath());
// obLog.setFileBackPath(targetPath);
// }
// obLog.setPushNum(obLog.getPushNum() + 1);
......@@ -75,7 +80,7 @@
// * @param errorMsg
// * @return void
// */
// public void pushFailRecordLog(Imp001GenerateBo tw001GenerateBo, PushObLog obLog, String errorMsg){
// public void pushFailRecordLog(Imp001GenerateBo tw001GenerateBo, PushOb obLog, String errorMsg){
// try {
// if(Objects.nonNull(tw001GenerateBo)){
// //备份文件,并且记录失败日志
......@@ -105,7 +110,7 @@
// * @return 返回目标备份路径
// */
// private String recordLog(Imp001GenerateBo tw001GenerateBo,
// PushObLog obLog,
// PushOb obLog,
// String tarPath,
// PushLogEnum pushLogEnum,
// String remark){
......