zelong.shao

customer|流程代码调整

Showing 27 changed files with 144 additions and 56 deletions
......@@ -4,4 +4,6 @@ import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
public interface IAttachmentQueryController {
ResponseVo queryInfo(Long consignmentId);
ResponseVo queryByRecord(Long recordId);
}
......
package com.fedex.connect.customer.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
public interface IUploadRecordController {
ResponseVo queryHistoryList(Long consignmentId);
ResponseVo queryHistoryList(AttachmentHistoryQuery attachmentHistoryQuery);
}
......
......@@ -5,13 +5,15 @@ import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IAttachmentQueryController;
import com.fedex.connect.customer.data.bo.LongBo;
import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author Szl
......@@ -43,4 +45,23 @@ public class AttachmentQueryController extends BaseController implements IAttach
UserConsignmentInfoQuery userConsignmentInfoQuery = UserConsignmentInfoQuery.getInstance(user,consignmentId);
return attachmentQueryService.queryInfo(userConsignmentInfoQuery);
}
@Override
@PostMapping("/queryByRecord/{recordId}")
@ApiOperation(value = "ResponseVo", notes = "根据批次号查询用户上传记录")
@OperationMethodLog(describe = "business_log_20005")
public ResponseVo queryByRecord(@ApiParam(value="Record ID",required = true) @PathVariable(value = "recordId") Long recordId) {
/**
* 运单id非空校验
*/
consignmentInfoValidate.validateConsignmentId(recordId);
/**
* 获取当前用户信息
*/
User user = this.getCurrentUserInfo();
/**
* 构造查询对象
*/
return attachmentQueryService.queryByRecord(recordId);
}
}
......
......@@ -8,10 +8,9 @@ import com.fedex.connect.customer.controller.biz.IUploadRecordController;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -30,8 +29,7 @@ public class UploadRecordController extends BaseController implements IUploadRec
@PostMapping("/queryHistoryList/{consignmentId}")
@ApiOperation(value = "ResponseVo", notes = "运单历史上传记录查询")
@OperationMethodLog(describe = "business_log_20006")
public ResponseVo queryHistoryList(@ApiParam(value="运单ID",required = true) @PathVariable(value = "consignmentId") Long consignmentId) {
AttachmentHistoryQuery attachmentHistoryQuery = AttachmentHistoryQuery.getInstance(consignmentId);
public ResponseVo queryHistoryList(@RequestBody AttachmentHistoryQuery attachmentHistoryQuery) {
/**
* 运单id非空校验
*/
......
package com.fedex.connect.customer.data.bo;
import com.fedex.connect.common.dependencies.annotation.BaseNotBlank;
import com.fedex.connect.common.model.biz.Attachment;
import lombok.Data;
import java.util.List;
......@@ -29,5 +30,5 @@ public class ConsignmentBo {
private String destinationCountry;
//文件业务类型AWB,INV,PKL,OTH(分运单,发票,箱单和其它这四种类型)
@BaseNotBlank(describe = "business_field_31008")
private List<String> attachmentBizTypeList;
private List<Attachment> attachmentBizTypeList;
}
......
package com.fedex.connect.customer.data.dto;
import com.fedex.connect.common.model.biz.UploadRecord;
import lombok.Data;
import java.util.Date;
@Data
public class AttachmentHistoryDto {
private String uploadUserName;
private Long uploadUserId;
private Date uploadTime;
private String statusName;
private String filePath;
private UploadRecord uploadRecord;
private Integer creatorFlag;
}
......
......@@ -3,6 +3,7 @@ package com.fedex.connect.customer.repository.base;
import com.fedex.connect.common.dao.biz.*;
import com.fedex.connect.customer.repository.dao.AttachmentExtMapper;
import com.fedex.connect.customer.repository.dao.ConsignmentExtMapper;
import com.fedex.connect.customer.repository.dao.UploadRecordExtMapper;
import org.springframework.beans.factory.annotation.Autowired;
public class BaseDao {
......@@ -22,4 +23,6 @@ public class BaseDao {
protected AttachmentExtMapper attachmentExtMapper;
@Autowired
protected EmailMapper emailMapper;
@Autowired
protected UploadRecordExtMapper uploadRecordExtMapper;
}
\ No newline at end of file
......
......@@ -18,4 +18,8 @@ public interface AttachmentExtMapper {
"(SELECT MAX(ID) FROM T_BIZ_UPLOAD_RECORD WHERE CREATE_USER_ID = #{query.userId} " +
"AND CONSIGNMENT_ID = #{query.consignmentId}) AND STATUS = 1")
List<Attachment> queryInfo(@Param("query") UserConsignmentInfoQuery query);
@Select("SELECT * FROM T_BIZ_ATTACHMENT WHERE UPLOAD_RECORD_ID = #{uploadRecordId}")
List<Attachment> getAttachmentsByUploadRecordId(@Param("uploadRecordId") Long uploadRecordId);
}
\ No newline at end of file
......
......@@ -25,7 +25,7 @@ public interface ConsignmentExtMapper {
") WHERE ROWNUM = 1")
Consignment findByConsignmentCode(@Param("consignmentCode") String consignmentCode, @Param("dateParam") LocalDate dateParam);
@Select("SELECT BC.* FROM T_BIZ_CONSIGNMENT BC INNER JOIN T_BIZ_USER_CONSIGNMENT_MAPPING BUCM ON(BC.ID = BUCM.CONSIGNMENT_ID) " +
@Select("SELECT BC.* FROM T_BIZ_CONSIGNMENT BC LEFT JOIN T_BIZ_USER_CONSIGNMENT_MAPPING BUCM ON(BC.ID = BUCM.CONSIGNMENT_ID) " +
"WHERE BC.ID = #{query.consignmentId} AND (BC.USER_UUID = #{query.userUuid} OR BUCM.USER_ID = #{query.userId})")
Consignment findConsignmentInfo(@Param("query") UserConsignmentInfoQuery query);
......
package com.fedex.connect.customer.repository.dao;
import com.fedex.connect.common.model.biz.UploadRecord;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UploadRecordExtMapper {
List<UploadRecord> getUploadRecordsByConsignmentId(AttachmentHistoryQuery attachmentHistoryQuery);
}
......
......@@ -15,4 +15,6 @@ public interface IAttachmentRepository {
Attachment saveOrUpdate(Attachment entity);
void saveOrUpdateAll(List<Attachment> list);
List<Attachment> getAttachmentsByUploadRecordId(Long uploadRecordId);
}
\ No newline at end of file
......
package com.fedex.connect.customer.repository.repo;
import com.fedex.connect.common.model.biz.UploadRecord;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
import java.util.List;
......@@ -21,4 +22,12 @@ public interface IUploadRecordRepository {
* @return void
*/
void saveOrUpdateAll(List<UploadRecord> list);
/**
* @Author Szl
* @Description 功能说明 根据运单id查询历史上传数据
* @Date 2024/12/16
* @return java.util.List<com.fedex.connect.common.model.biz.UploadRecord>
*/
List<UploadRecord> getUploadRecordsByConsignmentId(AttachmentHistoryQuery attachmentHistoryQuery);
}
......
package com.fedex.connect.customer.repository.repo.impl;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.common.model.biz.UploadRecord;
import com.fedex.connect.customer.data.dto.AttachmentHistoryDto;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
......@@ -52,4 +51,9 @@ public class AttachmentRepositoryImpl extends BaseDao implements IAttachmentRepo
}
});
}
@Override
public List<Attachment> getAttachmentsByUploadRecordId(Long uploadRecordId) {
return attachmentExtMapper.getAttachmentsByUploadRecordId(uploadRecordId);
}
}
\ No newline at end of file
......
package com.fedex.connect.customer.repository.repo.impl;
import com.fedex.connect.common.model.biz.UploadRecord;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
import com.fedex.connect.customer.repository.base.BaseDao;
import com.fedex.connect.customer.repository.repo.IUploadRecordRepository;
import org.springframework.stereotype.Repository;
......@@ -31,4 +32,11 @@ public class UploadRecordRepositoryImpl extends BaseDao implements IUploadRecord
}
});
}
@Override
public List<UploadRecord> getUploadRecordsByConsignmentId(AttachmentHistoryQuery attachmentHistoryQuery) {
return uploadRecordExtMapper.getUploadRecordsByConsignmentId(attachmentHistoryQuery);
}
}
......
......@@ -5,4 +5,6 @@ import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
public interface IAttachmentQueryService {
ResponseVo queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery);
ResponseVo queryByRecord(Long recordId);
}
......
......@@ -8,7 +8,7 @@ import java.util.List;
public interface IAttachmentService {
List<Attachment> uploadAttachments(MultipartFile[] files,
List<String> attachmentBizTypeList,
List<Attachment> attachmentBizTypeList,
User user,
String consignmentCode);
......
......@@ -28,4 +28,9 @@ public class AttachmentQueryServiceImpl extends BaseService implements IAttachme
List<Attachment> attachmentList = attachmentRepository.queryInfo(userConsignmentInfoQuery);
return responseUtils.success(attachmentList);
}
@Override
public ResponseVo queryByRecord(Long recordId) {
return responseUtils.success(attachmentRepository.getAttachmentsByUploadRecordId(recordId));
}
}
\ No newline at end of file
......
......@@ -7,6 +7,7 @@ import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IAttachmentService;
import com.fedex.connect.customer.util.service.biz.AttachmentUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
......@@ -48,19 +49,33 @@ public class AttachmentServiceImpl extends BaseService implements IAttachmentSer
* @return void
*/
public List<Attachment> uploadAttachments(MultipartFile[] files,
List<String> attachmentBizTypeList,
List<Attachment> attachmentBizTypeList,
User user,
String consignmentCode){
List<Attachment> attachmentList = new ArrayList<>();
String yyyyMMddHHmmss = DateUtil.yyyyMMddHHmmss(new Date());
try {
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
String bizType = attachmentBizTypeList.get(i);
int i = 0;
for (Attachment attachment : attachmentBizTypeList) {
/**
* 判断是否为需要复制过来的历史图片,如果是则复制,如果不是则新增
*/
String bizType = attachment.getBizTypeCode();
//构造文件后缀
String fileSuffix = yyyyMMddHHmmss + BaseSeparatorConstants.SEPARATOR_UNDERLINE + String.format("%03d",(i + 1));
Attachment attachment = attachmentUtil.uploadFile(file, bizType, user, consignmentCode, fileSuffix);
attachmentList.add(attachment);
String filePath = attachment.getFilePath();
Attachment attachmentNew = null;
if (StringUtils.isEmpty(filePath)){
MultipartFile file = attachmentUtil.findFileByName(files,attachment.getFileName());
attachmentNew = attachmentUtil.uploadFile(file, bizType, user, consignmentCode, fileSuffix);
}else {
attachmentNew = attachment;
attachmentNew.setId(null);
attachmentNew.setCreateTime(new Date());
attachmentNew.setModifyTime(new Date());
}
attachmentList.add(attachmentNew);
++i;
}
}catch(Exception ex){
//如果上传过程中存在失败,则所有已上传的文件进行删除
......
......@@ -3,6 +3,7 @@ package com.fedex.connect.customer.service.biz.impl;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.date.vo.PageResult;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.model.biz.UploadRecord;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.data.dto.AttachmentHistoryDto;
import com.fedex.connect.customer.data.query.AttachmentHistoryQuery;
......@@ -10,6 +11,7 @@ import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IUploadRecordService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -29,22 +31,23 @@ public class UploadRecordServiceImpl extends BaseService implements IUploadRecor
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
public ResponseVo findHistory(AttachmentHistoryQuery attachmentHistoryQuery, User user) {
List<AttachmentHistoryDto> history = attachmentRepository.findHistory(attachmentHistoryQuery);
List<UploadRecord> history = uploadRecordRepository.getUploadRecordsByConsignmentId(attachmentHistoryQuery);
List<AttachmentHistoryDto> attachmentHistoryDtos = new ArrayList<>();
if (history != null) {
history.forEach(attachmentHistoryDto ->
for (UploadRecord uploadRecord : history) {
AttachmentHistoryDto attachmentHistoryDto = new AttachmentHistoryDto();
attachmentHistoryDto.setUploadRecord(uploadRecord);
attachmentHistoryDto.setCreatorFlag(
(attachmentHistoryDto.getUploadUserId() != null &&
attachmentHistoryDto.getUploadUserId().equals(user.getId())) ?
(uploadRecord.getCreateUserId() != null) ?
DigitConstants.DIGIT_ONE : DigitConstants.DIGIT_ZERO
)
);
attachmentHistoryDtos.add(attachmentHistoryDto);
}
}
PageResult pageResult = new PageResult();
pageResult.setPage(attachmentHistoryQuery.getPage());
pageResult.setSize(attachmentHistoryQuery.getSize());
pageResult.setList(history != null ? history : Collections.emptyList());
pageResult.setList(attachmentHistoryDtos != null ? attachmentHistoryDtos : Collections.emptyList());
return responseUtils.success(pageResult);
}
......
......@@ -108,7 +108,7 @@ public class AttachmentUtil {
//用户上传原文件名称
attachment.setSourceFileName(sourceFileName);
//生成系统文件名称例子:AWB_123456789012_20241023164532982_001.pdf
String fileName = AttachmentBizTypeEnum.valueOf(bizType).getExt1() + BaseSeparatorConstants.SEPARATOR_UNDERLINE +
String fileName = AttachmentBizTypeEnum.getExt1ByCode(bizType) + BaseSeparatorConstants.SEPARATOR_UNDERLINE +
consignmentCode + BaseSeparatorConstants.SEPARATOR_UNDERLINE + fileSuffix + suffix;
//系统生成文件名称
attachment.setFileName(fileName);
......@@ -139,4 +139,13 @@ public class AttachmentUtil {
}
return attachment;
}
public static MultipartFile findFileByName(MultipartFile[] files, String fileName) {
for (MultipartFile file : files) {
if (file.getOriginalFilename().equals(fileName)) {
return file; // 找到匹配的文件,返回该文件
}
}
return null; // 如果没有找到匹配的文件,返回 null
}
}
\ No newline at end of file
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.enums.biz.AttachmentBizTypeEnum;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.customer.constants.CustomerConstant;
......@@ -57,17 +56,5 @@ public class AttachmentValidate {
if(totalSize > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE);
}
List<String> fileBizTypeList = consignmentBo.getAttachmentBizTypeList();
//运单或发票未上传
if(!fileBizTypeList.contains(AttachmentBizTypeEnum.AWB.getExt1()) ||
!fileBizTypeList.contains(AttachmentBizTypeEnum.INV.getExt1())){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30009);
}
//文件类型不在范围内
fileBizTypeList.stream().forEach(p -> {
if(Objects.isNull(AttachmentBizTypeEnum.valueOf(p))){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30010);
};
});
}
}
......
......@@ -5,6 +5,7 @@ business_log_20003=运单查询
business_log_20004=运单详细信息查询
business_log_20005=根据运单ID查询用户上传记录
business_log_20006=运单历史上传记录查询
business_log_20007=上传历史附件记录
system_exception_20003=提示信息过长,未保存成功
#******************鉴权相关提示,需要做国际化******************
......
......@@ -5,6 +5,7 @@ business_log_20003=运单查询
business_log_20004=运单详细信息查询
business_log_20005=根据运单ID查询用户上传记录
business_log_20006=运单历史上传记录查询
business_log_20007=上传历史附件记录
system_exception_20003=提示信息过长,未保存成功
#******************鉴权相关提示,需要做国际化******************
......
......@@ -29,6 +29,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* 定义切面。用于处理定义的切点。
......@@ -97,13 +98,19 @@ public class OperationLogAspect {
//如果是MultipartFile类型,只记录文件的名称
Object[] param = pjp.getArgs();
param = Arrays.stream(pjp.getArgs())
.filter(o -> !( o instanceof HttpServletResponse))
.filter(o -> !( o instanceof HttpServletRequest))
.filter(o -> !(o instanceof HttpServletResponse))
.filter(o -> !(o instanceof HttpServletRequest))
.map(o -> {
if (o instanceof MultipartFile){
if (o instanceof MultipartFile) {
// 单个 MultipartFile,返回文件名
return ((MultipartFile) o).getOriginalFilename();
} else if (o instanceof MultipartFile[]) {
// MultipartFile[],拼接所有文件名,用逗号分隔
return Arrays.stream((MultipartFile[]) o)
.map(MultipartFile::getOriginalFilename)
.collect(Collectors.joining(", "));
}
return o;
return o; // 其他类型参数保持不变
})
.toArray();
//获取请求的参数进行处理
......
......@@ -55,4 +55,14 @@ public enum AttachmentBizTypeEnum {
public void setExt1(String ext1) {
this.ext1 = ext1;
}
// 通过 code 获取对应的 ext1
public static String getExt1ByCode(String code) {
for (AttachmentBizTypeEnum type : AttachmentBizTypeEnum.values()) {
if (type.getCode().equals(code)) {
return type.getExt1();
}
}
return null; // 如果没有找到匹配的 code,返回 null
}
}
......
......@@ -203,7 +203,7 @@ public class Dm501Util {
/**
* 初始化运单表原产国、目的国
*/
this.initOriginCountryDestinationCountry(ceInfo,consignment);
this.initOriginCountryDestinationCountry(ceInfo,resultConsignment);
/**
* 初始化表基础字段
*/
......