tao.mo

biz-customer | 修改 | 运单提交、附件上传

mt
2024年11月18日13:53:34
Showing 20 changed files with 277 additions and 63 deletions
......@@ -12,10 +12,10 @@ public interface CustomerConstant {
* @Date 2024/11/12
*/
interface VALIDATE_KEYS{
//最大上传文件个数50哥
Integer UPLOAD_FILE_MAX_TOTAL = 50;
//最大上传总文件大小50M
Integer UPLOAD_FILE_MAX_SIZE = 50 * 1024 * 1024;
//最大上传文件个数100个
Integer UPLOAD_FILE_MAX_TOTAL = 100;
//最大上传总文件大小95M
Integer UPLOAD_FILE_MAX_SIZE = 95 * 1024 * 1024;
}
}
......
......@@ -8,7 +8,7 @@ import java.util.List;
@Data
public class ConsignmentBo {
//运单id
private Integer id;
private Long consignmentId;
//运单号
@BaseNotBlank(describe = "business_field_31003")
private String consignmentCode;
......
......@@ -16,6 +16,8 @@ public class UserConsignmentInfoQuery {
private String userUuid;
//运单id
private Long consignmentId;
//用户shipperaccount
private String shipperAccount;
/**
* @Author mt
......@@ -30,6 +32,7 @@ public class UserConsignmentInfoQuery {
userConsignmentInfoQuery.setUserId(user.getId());
userConsignmentInfoQuery.setUserUuid(user.getUserUuid());
userConsignmentInfoQuery.setConsignmentId(consignmentId);
userConsignmentInfoQuery.setShipperAccount(user.getAccountNo());
return userConsignmentInfoQuery;
}
}
......
......@@ -30,6 +30,7 @@ public enum ResponseCode {
MESSAGE_CODE_30010(30010,"business_exception_30010"),
MESSAGE_CODE_30011(30011,"business_exception_30011"),
MESSAGE_CODE_30012(30012,"business_exception_30012"),
MESSAGE_CODE_30013(30013,"business_exception_30013"),
/******打个样,编写样例*****/
// MESSAGE_CODE_30001(30001,"business_exception_30001"),
......
package com.fedex.connect.customer.repository.base;
import com.fedex.connect.common.dao.biz.ConsignmentMapper;
import com.fedex.connect.customer.repository.dao.AttachmentExtMapper;
import com.fedex.connect.customer.repository.dao.ConsignmentExtMapper;
import org.springframework.beans.factory.annotation.Autowired;
public class BaseDao {
@Autowired
public ConsignmentMapper consignmentMapper;
@Autowired
public ConsignmentExtMapper consignmentExtMapper;
@Autowired
public AttachmentExtMapper attachmentExtMapper;
......
......@@ -26,6 +26,7 @@ public interface ConsignmentExtMapper {
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) " +
"WHERE BC.ID = #{query.consignmentId} AND (BC.USER_UUID = #{query.userUuid} AND BUCM.USER_ID = #{query.userId})")
"WHERE BC.ID = #{query.consignmentId} AND (BC.USER_UUID = #{query.userUuid} OR BUCM.USER_ID = #{query.userId})")
Consignment findConsignmentInfo(@Param("query") UserConsignmentInfoQuery query);
}
......
......@@ -10,6 +10,8 @@ import java.time.LocalDate;
import java.util.List;
public interface IConsignmentRepository {
Consignment findById(Long id);
List<FindConsignmentsDto> findConsignments(ConsignmentQuery query, User user);
Long findAllCount(ConsignmentQuery query);
......
......@@ -16,6 +16,16 @@ import java.util.List;
@Repository
public class ConsignmentRepositoryImpl extends BaseDao 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);
}
/**
* @Author Szl
......
......@@ -7,5 +7,10 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface IAttachmentService {
List<Attachment> uploadAttachments(MultipartFile[] files,List<String> fileBizTypeList, User user);
List<Attachment> uploadAttachments(MultipartFile[] files,
List<String> attachmentBizTypeList,
User user,
String consignmentCode);
void deleteAttachments(List<Attachment> attachmentList);
}
......
......@@ -24,23 +24,43 @@ public class AttachmentServiceImpl extends BaseService implements IAttachmentSer
AttachmentUtil attachmentUtil;
/**
* @Author mt
* @Description 删除已存在的附件
* @Date 2024/11/15
* @param attachmentList
* @return void
*/
public void deleteAttachments(List<Attachment> attachmentList){
attachmentUtil.deleteAttachments(attachmentList);
}
/**
* @Author mt
* @Description 文件上传到服务器,并且生成附件实体返回
* 除运单ID、运单号、用户上传记录表ID,其他参数会返回
* 除运单ID、用户上传记录表ID,其他参数会返回
* @Date 2024/11/12
* @param files
* @param attachmentBizTypeList
* @param user
* @return void
*/
public List<Attachment> uploadAttachments(MultipartFile[] files,List<String> attachmentBizTypeList,User user){
public List<Attachment> uploadAttachments(MultipartFile[] files,
List<String> attachmentBizTypeList,
User user,
String consignmentCode){
List<Attachment> attachmentList = new ArrayList<>();
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
String bizType = attachmentBizTypeList.get(i);
Attachment attachment = attachmentUtil.uploadFile(file,bizType,user);
attachmentList.add(attachment);
try {
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
String bizType = attachmentBizTypeList.get(i);
Attachment attachment = attachmentUtil.uploadFile(file, bizType, user, consignmentCode, (i + 1));
attachmentList.add(attachment);
}
}catch(Exception ex){
//如果上传过程中存在失败,则所有已上传的文件进行删除
attachmentUtil.deleteAttachments(attachmentList);
throw ex;
}
return attachmentList;
}
}
}
\ No newline at end of file
......
......@@ -62,7 +62,9 @@ public class ConsignmentQueryServiceImpl extends BaseService implements IConsign
*/
public ResponseVo findConsignmentInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){
Consignment consignment = consignmentRepository.findConsignmentInfo(userConsignmentInfoQuery);
if(Objects.nonNull(consignment) && !consignment.getUserUuid().equals(userConsignmentInfoQuery.getUserUuid())){
if(Objects.nonNull(consignment)
&& !consignment.getUserUuid().equals(userConsignmentInfoQuery.getUserUuid())
&& !consignment.getShipperAccount().equals(userConsignmentInfoQuery.getShipperAccount())){
Consignment consignmentTemp = new Consignment();
consignmentTemp.setId(consignment.getId());
consignmentTemp.setConsignmentCode(consignment.getConsignmentCode());
......
......@@ -51,18 +51,18 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
if (consignment == null){
if (!StringUtils.isEmpty(bo.getShipperAccount())){
if (Objects.equals(user.getAccountNo(),bo.getShipperAccount())){
return new ResponseUtils().success();
return responseUtils.success();
}else {
/**
* 不存在运单,并且没有填写shipperAccount,则直接返回
*/
return new ResponseUtils().success();
return responseUtils.success();
}
}else {
/**
* 不存在运单,并且没有填写shipperAccount,则直接返回
*/
return new ResponseUtils().success();
return responseUtils.success();
}
}
/**
......@@ -92,10 +92,14 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
*/
public ResponseVo submitConsignment(MultipartFile[] files,ConsignmentBo consignmentBo,User user){
/**
* 上传附件
* 上传附件,并将附件信息返回
*/
List<Attachment> attachmentList = attachmentService.uploadAttachments(files,consignmentBo.getAttachmentBizTypeList(),user);
List<Attachment> attachmentList = attachmentService.uploadAttachments(files,
consignmentBo.getAttachmentBizTypeList(),
user,
consignmentBo.getConsignmentCode());
return null;
}
}
}
\ No newline at end of file
......
package com.fedex.connect.customer.util.service.biz;
import com.fedex.connect.common.dependencies.cache.CacheSystem;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.contants.BaseSeparatorConstants;
import com.fedex.connect.common.dependencies.enums.base.StatusEnum;
import com.fedex.connect.common.dependencies.enums.biz.AttachmentBizTypeEnum;
import com.fedex.connect.common.dependencies.enums.biz.AttachmentFileTypeEnum;
import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils;
import com.fedex.connect.common.dependencies.util.DateUtil;
import com.fedex.connect.common.dependencies.util.NIOFileUtils;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.bi.DictionaryEntries;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.config.PropertiesConfig;
import com.fedex.connect.customer.enums.ResponseCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @Author mt
* @Description 附件相关util
* @Date 2024/11/12
*/
@Slf4j
@Component
public class AttachmentUtil {
@Autowired
PropertiesConfig propertiesConfig;
@Autowired
CacheSystem cacheSystem;
@Autowired
NIOFileUtils nioFileUtils;
@Autowired
ResponseUtils responseUtils;
/**
* @Author mt
* @Description 初始化附件表基础字段信息
* @Date 2024/11/14
* @param attachment
* @param bizType
* @param user
* @return void
*/
private void initAttachment(Attachment attachment,String bizType,User user) throws Exception{
DictionaryEntries attachmentBizTypeEntries = cacheSystem.getDicAttachmentBizType(bizType);
attachment.setBizTypeCode(attachmentBizTypeEntries.getCode());
attachment.setBizTypeName(attachmentBizTypeEntries.getDescription());
DictionaryEntries attachmentFileTypeEntries = cacheSystem.getDicAttachmentBizType(AttachmentFileTypeEnum.FILE.getCode());
attachment.setFileTypeCode(attachmentFileTypeEntries.getCode());
attachment.setFileTypeName(attachmentFileTypeEntries.getDescription());
attachment.setStatus(StatusEnum.YES.getCode());
attachment.setCreateUserId(user.getId());
attachment.setCreateUserName(user.getUserName());
attachment.setModifyUserId(user.getId());
attachment.setModifyUserName(user.getUserName());
/**
* 初始化基础字段
*/
AssignmentFieldUtils.assignmentTableBaseField(attachment);
}
/**
* @Author mt
* @Description 删除已存在的附件
* @Date 2024/11/15
* @param attachmentList
* @return void
*/
public void deleteAttachments(List<Attachment> attachmentList){
attachmentList.stream().forEach(p->{
String filePathName = p.getFilePath() + File.separator + p.getFileName();
try {
nioFileUtils.deleteIfExists(filePathName);
}catch(Exception ex){
log.error("delete file : {} " , filePathName , ex);
}
});
}
/**
* @Author mt
* @Description 文件上传到服务器,并且生成附件实体返回
* 除运单ID、运单号、用户上传记录表ID,其他参数会返回
* 除运单ID、用户上传记录表ID,其他参数会返回
* @Date 2024/11/14
* @param file
* @param bizType
* @param user
* @return com.fedex.connect.common.model.biz.Attachment
*/
public Attachment uploadFile(MultipartFile file,String bizType, User user){
public Attachment uploadFile(MultipartFile file,String bizType, User user,String consignmentCode,int index){
Attachment attachment = new Attachment();
// attachment.setBizTypeCode();
// attachment.setBizTypeName();
attachment.setStatus(StatusEnum.YES.getCode());
//用户上传文件名称,文件名去除前后空格
String sourceFileName = file.getOriginalFilename().trim();
String filePathName = null;
try{
//用户上传原文件名称
attachment.setSourceFileName(sourceFileName);
//生成系统文件名称例子:AWB_123456789012_20241023164532982_001.pdf
String fileName = AttachmentBizTypeEnum.valueOf(bizType).getExt1() + BaseSeparatorConstants.SEPARATOR_UNDERLINE +
consignmentCode + BaseSeparatorConstants.SEPARATOR_UNDERLINE +
DateUtil.yyyyMMddHHmmss(new Date()) + BaseSeparatorConstants.SEPARATOR_UNDERLINE +
String.format("%03d",(index + 1));
//系统生成文件名称
attachment.setFileName(fileName);
//文件存放目录格式:xxxxx/2024-11-15/123456789012
String filePath = propertiesConfig.getAttachmentPath() + File.separator + DateUtil.format(new Date()) + File.separator + consignmentCode;
//服务器地址
attachment.setFilePath(filePath);
//设置文件大小
attachment.setFileSize(file.getSize());
//完整文件路径
filePathName = filePath + File.separator + fileName;
//文件上传至服务器
FileUtils.copyInputStreamToFile(file.getInputStream(),new File(filePathName));
/**
* 初始化附件表基础字段信息
*/
this.initAttachment(attachment,bizType,user);
}catch(Exception ex){
//上传文件如果失败,需要将当前文件删除
if(Objects.nonNull(filePathName)){
try {
nioFileUtils.deleteFile(filePathName);
}catch(Exception e){
log.error("delete file : {} " , filePathName , e);
}
}
responseUtils.fail(ResponseCode.MESSAGE_CODE_30013,ex,sourceFileName);
}
return attachment;
}
}
}
\ No newline at end of file
......
......@@ -2,13 +2,14 @@ package com.fedex.connect.customer.util.service.biz;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.data.bo.AddBo;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.data.dto.ConsignmentAddDto;
import com.fedex.connect.customer.enums.ResponseCode;
import com.fedex.connect.customer.repository.repo.IConsignmentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
......@@ -23,10 +24,9 @@ import java.util.Objects;
@Component
public class ConsignmentUtil {
@Autowired
private LocaleMessageUtil localeMessageUtil;
@Autowired
ResponseUtils responseUtils;
@Autowired
IConsignmentRepository consignmentRepository;
/**
* @Author Szl
......@@ -118,4 +118,18 @@ public class ConsignmentUtil {
private boolean isShipperAccountMatch(String account1, String account2) {
return StringUtils.hasText(account1) && StringUtils.hasText(account2) && account1.equals(account2);
}
/**
* @Author mt
* @Description 初始化运单表信息
* @Date 2024/11/15
* @param consignmentBo
* @param user
* @return void
*/
public Consignment initConsignment(ConsignmentBo consignmentBo, User user){
Consignment consignment = consignmentRepository.findById(consignmentBo.getConsignmentId());
return consignment;
}
}
......
......@@ -43,7 +43,7 @@ public class AttachmentValidate {
}
//上传最大文件个数限制
if(files.length > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30007);
responseUtils.fail(ResponseCode.MESSAGE_CODE_30007,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL);
}
//上传总文件大小限制
List<Long> fileSizeList = new ArrayList<>();
......@@ -53,9 +53,9 @@ public class AttachmentValidate {
//总文件大小
Long totalSize = Utils.listOf(fileSizeList).stream().filter(Objects::nonNull)
.mapToLong(f -> Optional.ofNullable(f).orElse(0L)).sum();
//最大上传总文件大小超过50M
//最大上传总文件大小超过95M
if(totalSize > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30008);
responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE);
}
List<String> fileBizTypeList = consignmentBo.getAttachmentBizTypeList();
//运单或发票未上传
......
......@@ -28,15 +28,16 @@ business_field_31007=目的国全称
business_field_31008=文件业务类型
#*********具体响应到前端**********
business_exception_30001=${0}必填字段未填写
business_exception_30001=#{0}必填字段未填写
business_exception_30002=单次最多可查询1000个运单号码
business_exception_30003=${0}不正确,请重新输入
business_exception_30003=#{0}不正确,请重新输入
business_exception_30004=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30005=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30006=附件上传不符合标准
business_exception_30007=所有上传文件数量不超过50个文件
business_exception_30008=所有上传文件总大小不超过50M
business_exception_30007=所有上传文件数量不超过#{0}个文件
business_exception_30008=所有上传文件总大小不超过#{0}M
business_exception_30009=运单或发票未上传
business_exception_30010=文件类型不在:运单、发票、箱单、其他
business_exception_30011=该运单已被其他人创建,不可以重复创建
business_exception_30012=UUID不一致
\ No newline at end of file
business_exception_30012=UUID不一致
business_exception_30013=文件名为:#{0},上传失败,请检查后重试
\ No newline at end of file
......
......@@ -39,4 +39,5 @@ business_exception_30008=所有上传文件总大小不超过50M
business_exception_30009=运单或发票未上传
business_exception_30010=文件类型不在:运单、发票、箱单、其他
business_exception_30011=该运单已被其他人创建,不可以重复创建
business_exception_30012=UUID不一致
\ No newline at end of file
business_exception_30012=UUID不一致
business_exception_30013=文件名为:#{0},上传失败,请检查后重试
\ No newline at end of file
......
......@@ -65,14 +65,26 @@ public class CacheSystem implements CommandLineRunner {
/**
* @Author mt
* @Description 根据dictCode,字典code获取字典项
* @Date 2024/11/14
* @param dictCode
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
private DictionaryEntries getDicEntries(String dictCode,String code){
List<DictionaryEntries> filter = dictionaryMap.get(dictCode).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
}
/**
* @Author mt
* @Description 根据code获取用户类型指定字典项
* @Date 2024年11月5日18:38:28
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicUserType(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.USER_TYPE).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
return this.getDicEntries(DictionaryConstants.USER_TYPE,code);
}
/**
......@@ -83,8 +95,7 @@ public class CacheSystem implements CommandLineRunner {
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicConsignmentStatus(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.CONSIGNMENT_STATUS).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
return this.getDicEntries(DictionaryConstants.CONSIGNMENT_STATUS,code);
}
/**
......@@ -95,8 +106,7 @@ public class CacheSystem implements CommandLineRunner {
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicCountry(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.COUNTRY).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
return this.getDicEntries(DictionaryConstants.COUNTRY,code);
}
/**
......@@ -119,8 +129,7 @@ public class CacheSystem implements CommandLineRunner {
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicUserLoginType(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.USER_LOGIN_TYPE).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
return this.getDicEntries(DictionaryConstants.USER_LOGIN_TYPE,code);
}
/**
......@@ -131,8 +140,7 @@ public class CacheSystem implements CommandLineRunner {
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicEmailType(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.EMAIL_TYPE).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
return this.getDicEntries(DictionaryConstants.EMAIL_TYPE,code);
}
/**
......@@ -143,7 +151,28 @@ public class CacheSystem implements CommandLineRunner {
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicEmailStatus(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.EMAIL_STATUS).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
return this.getDicEntries(DictionaryConstants.EMAIL_STATUS,code);
}
/**
* @Author mt
* @Description 功能说明 根据code获取附件业务类型指定字典项
* @Date 2024/11/7
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicAttachmentBizType(String code){
return this.getDicEntries(DictionaryConstants.ATTACHMENT_BIZ_TYPE,code);
}
/**
* @Author mt
* @Description 功能说明 根据code获取附件文件类型指定字典项
* @Date 2024/11/7
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicAttachmentFileType(String code){
return this.getDicEntries(DictionaryConstants.ATTACHMENT_FILE_TYPE,code);
}
}
\ No newline at end of file
......
......@@ -21,8 +21,8 @@ public class DateUtil {
public static final String PATTERN_DATE = "yyyy-MM-dd";
public static final String PATTERN_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
public static final String PATTERN_DATE_TIME_ORACLE = "yyyy-MM-dd hh:mi:ss";
public static final String PATTERN_DATE_TIME_MS = "yyyy-mm-dd hh24:mi:ss";
public static final String PATTERN_yyyyMMddHHmmss = "yyyyMMddHHmmss";
private static SimpleDateFormat dateFormat = new SimpleDateFormat();
......@@ -59,11 +59,14 @@ public class DateUtil {
}
/**
* Format a Time object to a String. Now use the Medium format of Locale
* CHINA. The format is YYYYMMDDHHmmss
*/
public static String formatTimeWithoutSlash(Date date) {
dateFormat.applyPattern("yyyyMMddHHmmss");
* @Author mt
* @Description yyyyMMddHHmmss
* @Date 2024/11/14
* @param date
* @return java.lang.String
*/
public static String yyyyMMddHHmmss(Date date){
dateFormat.applyPattern(PATTERN_yyyyMMddHHmmss);
return dateFormat.format(date);
}
......
......@@ -48,6 +48,22 @@ public class ResponseUtils {
* @param objects
* @return void
*/
public void fail(Object codeEnum,Throwable e,Object...objects) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum,objects);
log.error(responseCodeBo.getErrMsg(),e);
throw new OpErrorException(responseCodeBo.getCode(), responseCodeBo.getErrMsg());
}
/**
* @Author mt
* @Description
* 第一个参数值为:#{0}必填字段未填写,#{1}。
* 第二个参数为:List<String>或字符串等
* @Date 2024/11/12
* @param codeEnum
* @param objects
* @return void
*/
public void fail(Object codeEnum,Object...objects) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum,objects);
log.error(responseCodeBo.getErrMsg());
......@@ -56,7 +72,7 @@ public class ResponseUtils {
public void fail(Object codeEnum,Throwable e) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum);
log.error(responseCodeBo.getErrMsg());
log.error(responseCodeBo.getErrMsg(),e);
throw new OpErrorException(responseCodeBo.getCode(), responseCodeBo.getErrMsg(),e);
}
......