zelong.shao

customer|流程代码调整

Showing 17 changed files with 444 additions and 41 deletions
1 package com.fedex.connect.customer.controller.biz.impl; 1 package com.fedex.connect.customer.controller.biz.impl;
2 2
3 +import com.fedex.connect.common.dependencies.annotation.OperationMethodLog;
4 +import com.fedex.connect.common.dependencies.contants.AnnotationConstants;
5 +import com.fedex.connect.common.dependencies.util.FileUtil;
3 import com.fedex.connect.customer.controller.base.BaseController; 6 import com.fedex.connect.customer.controller.base.BaseController;
4 import com.fedex.connect.customer.controller.biz.IAttachmentController; 7 import com.fedex.connect.customer.controller.biz.IAttachmentController;
5 import io.swagger.annotations.Api; 8 import io.swagger.annotations.Api;
9 +import io.swagger.annotations.ApiOperation;
6 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
11 +import org.springframework.web.bind.annotation.GetMapping;
7 import org.springframework.web.bind.annotation.RequestMapping; 12 import org.springframework.web.bind.annotation.RequestMapping;
13 +import org.springframework.web.bind.annotation.RequestParam;
8 import org.springframework.web.bind.annotation.RestController; 14 import org.springframework.web.bind.annotation.RestController;
9 15
16 +import javax.servlet.http.HttpServletRequest;
17 +import javax.servlet.http.HttpServletResponse;
18 +
10 /** 19 /**
11 * @Author Szl 20 * @Author Szl
12 * @Description 类说明 附件相关 21 * @Description 类说明 附件相关
...@@ -18,4 +27,15 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,4 +27,15 @@ import org.springframework.web.bind.annotation.RestController;
18 @Api(value = "AttachmentControllerImpl", tags = {"附件操作相关"}) 27 @Api(value = "AttachmentControllerImpl", tags = {"附件操作相关"})
19 public class AttachmentController extends BaseController implements IAttachmentController { 28 public class AttachmentController extends BaseController implements IAttachmentController {
20 29
30 + @GetMapping(value = "/downLoadFile")
31 + @OperationMethodLog(describe = "business_log_20008",remarkType = AnnotationConstants.LOG_REMARK_TYPE_SPECIAL,status = AnnotationConstants.LOG_STATUS_SHOW)
32 + @ApiOperation(value = "下载单个文件")
33 + public void downLoadFile(HttpServletRequest request, HttpServletResponse response,
34 + @RequestParam(name = "path") String path, @RequestParam(name = "name") String name) throws Exception {
35 +
36 + name = new String(name.getBytes("UTF-8"), "ISO-8859-1");
37 + String contentType = FileUtil.getContentType(name);
38 + response.setHeader("Content-Disposition", "attachment;filename=" + name +";content-type:"+contentType);
39 + FileUtil.download(request, response, path + FileUtil.SIGN, name,contentType);
40 + }
21 } 41 }
......
...@@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
26 public class UploadRecordController extends BaseController implements IUploadRecordController { 26 public class UploadRecordController extends BaseController implements IUploadRecordController {
27 27
28 @Override 28 @Override
29 - @PostMapping("/queryHistoryList/{consignmentId}") 29 + @PostMapping("/queryHistoryList")
30 @ApiOperation(value = "ResponseVo", notes = "运单历史上传记录查询") 30 @ApiOperation(value = "ResponseVo", notes = "运单历史上传记录查询")
31 @OperationMethodLog(describe = "business_log_20006") 31 @OperationMethodLog(describe = "business_log_20006")
32 public ResponseVo queryHistoryList(@RequestBody AttachmentHistoryQuery attachmentHistoryQuery) { 32 public ResponseVo queryHistoryList(@RequestBody AttachmentHistoryQuery attachmentHistoryQuery) {
......
...@@ -8,6 +8,7 @@ import com.fedex.connect.customer.data.query.ConsignmentQuery; ...@@ -8,6 +8,7 @@ import com.fedex.connect.customer.data.query.ConsignmentQuery;
8 import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery; 8 import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
9 import com.fedex.connect.customer.repository.base.BaseDao; 9 import com.fedex.connect.customer.repository.base.BaseDao;
10 import com.fedex.connect.customer.repository.repo.IConsignmentRepository; 10 import com.fedex.connect.customer.repository.repo.IConsignmentRepository;
11 +import org.apache.commons.lang3.StringUtils;
11 import org.springframework.stereotype.Repository; 12 import org.springframework.stereotype.Repository;
12 13
13 import java.time.LocalDate; 14 import java.time.LocalDate;
...@@ -45,7 +46,7 @@ public class ConsignmentRepositoryImpl extends BaseDao implements IConsignmentRe ...@@ -45,7 +46,7 @@ public class ConsignmentRepositoryImpl extends BaseDao implements IConsignmentRe
45 if (SystemDefaultUserConstants.SYSTEM_USER_KEYS.USER_NAME.equals(consignment.getCreateUserName())){ 46 if (SystemDefaultUserConstants.SYSTEM_USER_KEYS.USER_NAME.equals(consignment.getCreateUserName())){
46 consignment.setCreateUserName(user.getUserName()); 47 consignment.setCreateUserName(user.getUserName());
47 } 48 }
48 - if (!user.getUserUuid().equals(consignment.getUserUuid()) && !user.getAccountNo().equals(consignment.getShipperAccount())){ 49 + if (!user.getUserUuid().equals(consignment.getUserUuid()) && (!StringUtils.isEmpty(user.getAccountNo()) && !user.getAccountNo().equals(consignment.getShipperAccount()))){
49 consignment.setRecipientContactName(null); 50 consignment.setRecipientContactName(null);
50 consignment.setRecipientCompany(null); 51 consignment.setRecipientCompany(null);
51 consignment.setDocNondocFlag(null); 52 consignment.setDocNondocFlag(null);
......
...@@ -129,7 +129,7 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS ...@@ -129,7 +129,7 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
129 /** 129 /**
130 * 初始化上传记录信息 130 * 初始化上传记录信息
131 */ 131 */
132 - UploadRecord uploadRecord = uploadRecordUtil.initUploadRecord(consignment.getConsignmentCode()); 132 + UploadRecord uploadRecord = uploadRecordUtil.initUploadRecord(consignment.getConsignmentCode(),user);
133 /** 133 /**
134 * 保存运单相关信息 134 * 保存运单相关信息
135 */ 135 */
......
...@@ -50,7 +50,7 @@ public class AttachmentUtil { ...@@ -50,7 +50,7 @@ public class AttachmentUtil {
50 * @return void 50 * @return void
51 */ 51 */
52 private void initAttachment(Attachment attachment,String bizType,User user) throws Exception{ 52 private void initAttachment(Attachment attachment,String bizType,User user) throws Exception{
53 - DictionaryEntries attachmentBizTypeEntries = cacheSystem.getDicAttachmentBizType(bizType); 53 + DictionaryEntries attachmentBizTypeEntries = cacheSystem.getDicAttachmentBizType(AttachmentBizTypeEnum.getCodeByExt1(bizType));
54 attachment.setBizTypeCode(attachmentBizTypeEntries.getCode()); 54 attachment.setBizTypeCode(attachmentBizTypeEntries.getCode());
55 attachment.setBizTypeName(attachmentBizTypeEntries.getEnglishName()); 55 attachment.setBizTypeName(attachmentBizTypeEntries.getEnglishName());
56 DictionaryEntries attachmentFileTypeEntries = cacheSystem.getDicAttachmentFileType(AttachmentFileTypeEnum.FILE.getCode()); 56 DictionaryEntries attachmentFileTypeEntries = cacheSystem.getDicAttachmentFileType(AttachmentFileTypeEnum.FILE.getCode());
...@@ -108,7 +108,7 @@ public class AttachmentUtil { ...@@ -108,7 +108,7 @@ public class AttachmentUtil {
108 //用户上传原文件名称 108 //用户上传原文件名称
109 attachment.setSourceFileName(sourceFileName); 109 attachment.setSourceFileName(sourceFileName);
110 //生成系统文件名称例子:AWB_123456789012_20241023164532982_001.pdf 110 //生成系统文件名称例子:AWB_123456789012_20241023164532982_001.pdf
111 - String fileName = AttachmentBizTypeEnum.getExt1ByCode(bizType) + BaseSeparatorConstants.SEPARATOR_UNDERLINE + 111 + String fileName = bizType + BaseSeparatorConstants.SEPARATOR_UNDERLINE +
112 consignmentCode + BaseSeparatorConstants.SEPARATOR_UNDERLINE + fileSuffix + suffix; 112 consignmentCode + BaseSeparatorConstants.SEPARATOR_UNDERLINE + fileSuffix + suffix;
113 //系统生成文件名称 113 //系统生成文件名称
114 attachment.setFileName(fileName); 114 attachment.setFileName(fileName);
...@@ -142,6 +142,7 @@ public class AttachmentUtil { ...@@ -142,6 +142,7 @@ public class AttachmentUtil {
142 142
143 public static MultipartFile findFileByName(MultipartFile[] files, String fileName) { 143 public static MultipartFile findFileByName(MultipartFile[] files, String fileName) {
144 for (MultipartFile file : files) { 144 for (MultipartFile file : files) {
145 + log.info("fileName:" + file.getOriginalFilename());
145 if (file.getOriginalFilename().equals(fileName)) { 146 if (file.getOriginalFilename().equals(fileName)) {
146 return file; // 找到匹配的文件,返回该文件 147 return file; // 找到匹配的文件,返回该文件
147 } 148 }
......
...@@ -6,6 +6,7 @@ import com.fedex.connect.common.dependencies.enums.biz.ConsignmentStatusEnum; ...@@ -6,6 +6,7 @@ import com.fedex.connect.common.dependencies.enums.biz.ConsignmentStatusEnum;
6 import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils; 6 import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils;
7 import com.fedex.connect.common.model.bi.DictionaryEntries; 7 import com.fedex.connect.common.model.bi.DictionaryEntries;
8 import com.fedex.connect.common.model.biz.UploadRecord; 8 import com.fedex.connect.common.model.biz.UploadRecord;
9 +import com.fedex.connect.common.model.sys.User;
9 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Component; 12 import org.springframework.stereotype.Component;
...@@ -28,7 +29,7 @@ public class UploadRecordUtil { ...@@ -28,7 +29,7 @@ public class UploadRecordUtil {
28 * @param consignmentCode 29 * @param consignmentCode
29 * @return com.fedex.connect.common.model.biz.UploadRecord 30 * @return com.fedex.connect.common.model.biz.UploadRecord
30 */ 31 */
31 - public UploadRecord initUploadRecord(String consignmentCode) throws Exception{ 32 + public UploadRecord initUploadRecord(String consignmentCode, User user) throws Exception{
32 DictionaryEntries consignmentStatusDic = cacheSystem.getDicConsignmentStatus(ConsignmentStatusEnum.CONSIGNMENT_STATUS_01.getCode()); 33 DictionaryEntries consignmentStatusDic = cacheSystem.getDicConsignmentStatus(ConsignmentStatusEnum.CONSIGNMENT_STATUS_01.getCode());
33 UploadRecord uploadRecord = new UploadRecord(); 34 UploadRecord uploadRecord = new UploadRecord();
34 //记录当前运单号 35 //记录当前运单号
...@@ -36,6 +37,10 @@ public class UploadRecordUtil { ...@@ -36,6 +37,10 @@ public class UploadRecordUtil {
36 //记录当前运单状态 37 //记录当前运单状态
37 uploadRecord.setStatusCode(consignmentStatusDic.getCode()); 38 uploadRecord.setStatusCode(consignmentStatusDic.getCode());
38 uploadRecord.setStatusName(consignmentStatusDic.getEnglishName()); 39 uploadRecord.setStatusName(consignmentStatusDic.getEnglishName());
40 + uploadRecord.setCreateUserId(user.getId());
41 + uploadRecord.setCreateUserName(user.getUserName());
42 + uploadRecord.setModifyUserId(user.getId());
43 + uploadRecord.setModifyUserName(user.getUserName());
39 /** 44 /**
40 * 初始化基础字段 45 * 初始化基础字段
41 */ 46 */
......
...@@ -6,6 +6,7 @@ business_log_20004=运单详细信息查询 ...@@ -6,6 +6,7 @@ business_log_20004=运单详细信息查询
6 business_log_20005=根据运单ID查询用户上传记录 6 business_log_20005=根据运单ID查询用户上传记录
7 business_log_20006=运单历史上传记录查询 7 business_log_20006=运单历史上传记录查询
8 business_log_20007=上传历史附件记录 8 business_log_20007=上传历史附件记录
9 +business_log_20008=下载附件
9 system_exception_20003=提示信息过长,未保存成功 10 system_exception_20003=提示信息过长,未保存成功
10 11
11 #******************鉴权相关提示,需要做国际化****************** 12 #******************鉴权相关提示,需要做国际化******************
......
...@@ -6,6 +6,7 @@ business_log_20004=运单详细信息查询 ...@@ -6,6 +6,7 @@ business_log_20004=运单详细信息查询
6 business_log_20005=根据运单ID查询用户上传记录 6 business_log_20005=根据运单ID查询用户上传记录
7 business_log_20006=运单历史上传记录查询 7 business_log_20006=运单历史上传记录查询
8 business_log_20007=上传历史附件记录 8 business_log_20007=上传历史附件记录
9 +business_log_20008=下载附件
9 system_exception_20003=提示信息过长,未保存成功 10 system_exception_20003=提示信息过长,未保存成功
10 11
11 #******************鉴权相关提示,需要做国际化****************** 12 #******************鉴权相关提示,需要做国际化******************
......
...@@ -65,4 +65,14 @@ public enum AttachmentBizTypeEnum { ...@@ -65,4 +65,14 @@ public enum AttachmentBizTypeEnum {
65 } 65 }
66 return null; // 如果没有找到匹配的 code,返回 null 66 return null; // 如果没有找到匹配的 code,返回 null
67 } 67 }
68 +
69 + public static String getCodeByExt1(String ext1) {
70 + for (AttachmentBizTypeEnum type : AttachmentBizTypeEnum.values()) {
71 + if (type.getExt1().equals(ext1)) {
72 + return type.getCode();
73 + }
74 + }
75 + return null; // 如果没有找到匹配的 ext1,返回 null
76 + }
77 +
68 } 78 }
......
...@@ -28,17 +28,20 @@ public class DuplicateEmailTemplate implements EmailTemplate { ...@@ -28,17 +28,20 @@ public class DuplicateEmailTemplate implements EmailTemplate {
28 } 28 }
29 29
30 interface CLEARANCE_TITLE{ 30 interface CLEARANCE_TITLE{
31 - String TITLE = "Sender Reminder:"; 31 + String TITLE = "Create waybill({0}) reminder";
32 } 32 }
33 33
34 interface CLEARANCE_BODY{ 34 interface CLEARANCE_BODY{
35 - String DESCRIPTION = "<p>Sender Reminder: The task will poll every {0} minutes after the system starts.</p>\n"; 35 + String DESCRIPTION = "<p>This email is a reminder email, please do not reply!</p>\n";
36 36
37 String BODY = "<div><div style='margin-left:4%;'>" + 37 String BODY = "<div><div style='margin-left:4%;'>" +
38 - "<p align='center'><img src='{0}'></p>" + 38 + //"<p align='center'><img src='{0}'></p>" +
39 - "<p align='center'><img src='{1}'></p>" + 39 + //"<p align='center'><img src='{1}'></p>" +
40 - "<p>Import Pre-Clearance System Notification:</p>" + 40 + "<p>FedEx iClear Connect System Notification:</p>" +
41 - "<p>&nbsp;&nbsp;&nbsp;&nbsp;{2}The consignment has been created and uploaded by another user.</p>" + 41 + "<p>&nbsp;&nbsp;&nbsp;&nbsp;The waybill with tracking number {0} has been created by someone else. Please verify!</p>" +
42 - "</font><br/><br/>"; 42 + "</font><br/><br/>" +
43 + "<div style=color:#808080;font-style:Arial;font-size:14px;margin: auto;margin-bottom: 5px;>" +
44 + "{1}\n" +
45 + "</div>";
43 } 46 }
44 } 47 }
......
1 +package com.fedex.connect.common.dependencies.util;
2 +
3 +import org.apache.poi.util.IOUtils;
4 +import org.slf4j.Logger;
5 +import org.slf4j.LoggerFactory;
6 +import org.springframework.util.StreamUtils;
7 +import org.springframework.web.multipart.MultipartFile;
8 +
9 +import javax.servlet.http.HttpServletRequest;
10 +import javax.servlet.http.HttpServletResponse;
11 +import java.io.*;
12 +import java.net.URL;
13 +import java.net.URLConnection;
14 +import java.nio.file.*;
15 +import java.nio.file.attribute.BasicFileAttributes;
16 +import java.text.SimpleDateFormat;
17 +import java.util.Arrays;
18 +import java.util.Date;
19 +
20 +//import org.junit.platform.commons.util.StringUtils;
21 +
22 +/**
23 + * Created by liyang on 2017/4/22.
24 + */
25 +public class FileUtil {
26 +
27 + private static Logger log= LoggerFactory.getLogger(FileUtil.class);
28 +
29 +
30 + private static final int BUFFER_SIZE = 16 * 1024;
31 +
32 + public static final String SIGN = "/";
33 +
34 + private static final SimpleDateFormat DATE_FORMAT_YYYYMM = new SimpleDateFormat("yyyyMM");
35 + private static final SimpleDateFormat DATE_FORMAT_YYYYMMDDHHMMSSSSS = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS");
36 +
37 +
38 + public static String getContentType(String fileName) {
39 + // 使用 URLConnection 根据文件名获取 MIME 类型
40 + String contentType = URLConnection.guessContentTypeFromName(fileName);
41 + if (contentType == null) {
42 + // 如果无法推测出 MIME 类型,则默认为 "application/octet-stream"
43 + contentType = "application/octet-stream";
44 + }
45 + return contentType;
46 + }
47 +
48 + /**
49 + * 文件上传到服务器
50 + *
51 + * @param file
52 + * @param updatePath
53 + * @param entityName
54 + * @return
55 + * @throws IOException
56 + */
57 + public static File fileUpload(MultipartFile file, String updatePath,
58 + String entityName) throws IOException {
59 + byte[] bytes = file.getBytes();
60 + if (bytes == null || bytes.length == 0) {
61 + return null;
62 + }
63 + if (updatePath.endsWith(SIGN)){
64 + updatePath = updatePath.substring(0, updatePath.lastIndexOf("SIGN"));
65 + }
66 + String finalTargetFolder = updatePath + SIGN + DATE_FORMAT_YYYYMM.format(new Date());
67 + File rootFolder = new File(finalTargetFolder);
68 + // 文件夹不存在,则创建文件夹
69 + if (!rootFolder.exists()) {
70 + rootFolder.mkdirs();
71 + }
72 + // 生成文件名
73 + String[] nameSplit = file.getOriginalFilename().split("\\.");
74 + File finalFile = new File(finalTargetFolder + SIGN + entityName + "_"
75 + + DATE_FORMAT_YYYYMMDDHHMMSSSSS.format(new Date()) + "."
76 + + nameSplit[nameSplit.length - 1]);
77 + // 写文件
78 + if (!file.isEmpty()) {
79 + file.transferTo(finalFile);
80 + }
81 + return finalFile;
82 + }
83 +
84 + /**
85 + * 文件上传到服务器
86 + *
87 + * @param file
88 + * @param updatePath
89 + * @param entityName
90 + * @param superAddition 追加目录
91 + * @return
92 + * @throws IOException
93 + */
94 + public static File fileUpload(MultipartFile file, String updatePath,
95 + String entityName, String superAddition) throws IOException {
96 +/* byte[] bytes = file.getBytes();
97 + if (bytes == null || bytes.length == 0) {
98 + return null;
99 + }*/
100 + if (updatePath.endsWith(SIGN)){
101 + updatePath = updatePath.substring(0, updatePath.lastIndexOf(SIGN));
102 + }
103 + String finalTargetFolder = updatePath + SIGN + DATE_FORMAT_YYYYMM.format(new Date()) + SIGN + superAddition;
104 + log.info(finalTargetFolder);
105 + File rootFolder = new File(finalTargetFolder);
106 + // 文件夹不存在,则创建文件夹
107 + if (!rootFolder.exists()) {
108 + rootFolder.mkdirs();
109 + }
110 + // 生成文件名
111 + String[] nameSplit = file.getOriginalFilename().split("\\.");
112 + File finalFile = new File(finalTargetFolder + SIGN + entityName + "_"
113 + + DATE_FORMAT_YYYYMMDDHHMMSSSSS.format(new Date()) + "."
114 + + nameSplit[nameSplit.length - 1]);
115 + log.info(Arrays.toString(nameSplit));
116 + // 写文件
117 + //if (!file.isEmpty()) {
118 + /*import org.apache.commons.io.FileUtils;
119 + FileUtils.copyInputStreamToFile(file.getInputStream(), finalFile);*/
120 + //具体参考:https://blog.csdn.net/canduecho/article/details/131598461
121 + try (OutputStream outputStream = new FileOutputStream(finalFile)) {
122 + StreamUtils.copy(file.getInputStream(), outputStream);
123 + }
124 + //}
125 + return finalFile;
126 + }
127 +
128 + /**
129 + * 下载
130 + *
131 + * @param request
132 + * @param response
133 + * @param storeName
134 + * @param contentType
135 + * @throws Exception
136 + */
137 + public static void download(HttpServletRequest request,
138 + HttpServletResponse response, String folder,
139 + String storeName, String contentType)
140 + throws Exception {
141 + response.setContentType("text/html;charset=UTF-8");
142 + request.setCharacterEncoding("UTF-8");
143 + BufferedInputStream bis = null;
144 + BufferedOutputStream bos = null;
145 +
146 + String downLoadPath = folder + storeName;
147 +
148 + long fileLength = new File(downLoadPath).length();
149 +
150 + response.setContentType(contentType);
151 + response.setHeader("Content-Length", String.valueOf(fileLength));
152 +
153 + bis = new BufferedInputStream(new FileInputStream(downLoadPath));
154 + bos = new BufferedOutputStream(response.getOutputStream());
155 + byte[] buff = new byte[2048];
156 + int bytesRead;
157 + while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
158 + bos.write(buff, 0, bytesRead);
159 + }
160 + bis.close();
161 + bos.close();
162 + }
163 +
164 + /**
165 + * 下载
166 + *
167 + * @param request
168 + * @param response
169 + * @param storeName
170 + * @param contentType
171 + * @param realName
172 + * @throws Exception
173 + */
174 + public static void download(HttpServletRequest request,
175 + HttpServletResponse response, String folder,
176 + String storeName, String contentType, String realName)
177 + throws Exception {
178 + response.setContentType("text/html;charset=UTF-8");
179 + request.setCharacterEncoding("UTF-8");
180 + BufferedInputStream bis = null;
181 + BufferedOutputStream bos = null;
182 +
183 + // String ctxPath = uploadFolder + SIGN;
184 + String downLoadPath = folder + storeName;
185 +
186 + long fileLength = new File(downLoadPath).length();
187 +
188 + response.setContentType(contentType);
189 + response.setHeader("Content-disposition", "attachment; filename=\""
190 + + new String(realName.getBytes("GBK"), "ISO8859-1") + "\"");
191 + response.setHeader("Content-Length", String.valueOf(fileLength));
192 +
193 + bis = new BufferedInputStream(new FileInputStream(downLoadPath));
194 + bos = new BufferedOutputStream(response.getOutputStream());
195 + byte[] buff = new byte[2048];
196 + int bytesRead;
197 + while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
198 + bos.write(buff, 0, bytesRead);
199 + }
200 + bis.close();
201 + bos.close();
202 + }
203 +
204 + /**
205 + * copy文件
206 + *
207 + * @param oldLoad 需要下载文件路径
208 + * @param newLoad 需要copy路径
209 + */
210 + public static void copyFile(String oldLoad, String newLoad, String fileNme) {
211 + InputStream inputStream = null;
212 + OutputStream outputStream = null;
213 + try {
214 + File rootFolder = new File(newLoad);
215 + //文件夹不存在,则创建文件夹
216 + if (!rootFolder.exists()) {
217 + rootFolder.mkdirs();
218 + }
219 + //图片下载
220 + URL url = new URL(oldLoad);
221 + URLConnection conn = url.openConnection();
222 + inputStream = conn.getInputStream();
223 + outputStream = new FileOutputStream(new File(newLoad + "//" + fileNme));
224 + IOUtils.copy(inputStream, outputStream);
225 + } catch (IOException e) {
226 + System.err.println(e);
227 + } finally {
228 + IOUtils.closeQuietly(inputStream);
229 + IOUtils.closeQuietly(outputStream);
230 + }
231 +
232 +
233 + }
234 +
235 + /**
236 + * 创建文件
237 + *
238 + * @param filepath
239 + * @throws IOException
240 + */
241 + public static void createFile(String filepath) throws IOException {
242 + File file = new File(filepath);
243 + if (!file.exists()) {
244 + file.createNewFile();
245 + }
246 + }
247 +
248 + public static void copyAndRenameFile(String sourceFile, String targetPath, String newFileName) {
249 + File in = new File(sourceFile);
250 + File out = new File(targetPath); // 目标文件夹
251 + try {
252 + Files.copy(in.toPath(), out.toPath().resolve(newFileName), StandardCopyOption.REPLACE_EXISTING);
253 + } catch (IOException e) {
254 + e.printStackTrace();
255 + }
256 + }
257 +
258 +
259 + public static void createFolder(String folderPath){
260 + try{
261 + File file = new File(folderPath);
262 + file.mkdirs();
263 + }catch (Exception e){
264 + e.printStackTrace();
265 + log.error("createFolder() error:{}",e);
266 + }
267 + }
268 +
269 +
270 + public static boolean deleteAllFile(String dir) {
271 + File dirFile = new File(dir);
272 + if ((!dirFile.exists()) || (!dirFile.isDirectory())) {
273 + log.info("删除文件夹失败:{} 不存在!",dir);
274 + return false;
275 + }
276 + boolean flag = true;
277 + // 删除文件夹中的所有文件包括子文件夹
278 + File[] files = dirFile.listFiles();
279 + for (int i = 0; i < files.length; i++) {
280 + // 删除子文件
281 + if (files[i].isFile()) {
282 + flag = FileUtil.deleteFile(files[i].getAbsolutePath());
283 + if (!flag){
284 + break;
285 + }
286 + // 删除子文件夹
287 + }else if (files[i].isDirectory()) {
288 + flag = FileUtil.deleteAllFile(files[i].getAbsolutePath());
289 + if (!flag){
290 + break;
291 + }
292 + }
293 + }
294 + if (!flag) {
295 + log.info("删除文件夹{}失败!",dir);
296 + return false;
297 + }
298 + // 删除当前文件夹
299 + if (dirFile.delete()) {
300 + log.info("删除文件夹" + dir + "成功!");
301 + return true;
302 + } else {
303 + return false;
304 + }
305 + }
306 +
307 +
308 +
309 + public static boolean deleteFile(String fileName) {
310 + try{
311 + File file = new File(fileName);
312 + if (file.exists() && file.isFile()) {
313 + if (file.delete()) {
314 + log.info("删除文件" + fileName + "成功!");
315 + return true;
316 + } else {
317 + log.info("删除文件" + fileName + "失败!");
318 + return false;
319 + }
320 + } else {
321 + log.info(fileName + "不存在!");
322 + return false;
323 + }
324 + }catch (Exception e){
325 + log.error("deleteFile() fileName:{} error:{},",fileName,e);
326 + }
327 + return false;
328 + }
329 +
330 +
331 + public static String getFileNameWithoutSuffix(String fileName){
332 + return fileName.substring(0, fileName.lastIndexOf("."));
333 + }
334 +
335 +
336 + public static void copyFiles(String sourceFolder, String targetFolder) throws IOException {
337 + Path sourcePath = Paths.get(sourceFolder);
338 + Path targetPath = Paths.get(targetFolder);
339 +
340 + if (!Files.exists(targetPath)) {
341 + Files.createDirectories(targetPath);
342 + }
343 +
344 + Files.walkFileTree(sourcePath, new SimpleFileVisitor<Path>() {
345 + @Override
346 + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
347 + Path destination = targetPath.resolve(sourcePath.relativize(file));
348 + Files.copy(file, destination, StandardCopyOption.REPLACE_EXISTING);
349 + return FileVisitResult.CONTINUE;
350 + }
351 +
352 + @Override
353 + public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
354 + return FileVisitResult.CONTINUE;
355 + }
356 + });
357 + }
358 +}
...@@ -86,7 +86,12 @@ public class ResponseUtils { ...@@ -86,7 +86,12 @@ public class ResponseUtils {
86 } 86 }
87 87
88 public <T> ResponseVo success(T data) { 88 public <T> ResponseVo success(T data) {
89 - return new ResponseVo<>(data); 89 + if (data instanceof Enum) {
90 + ResponseCodeBo responseCodeBo = this.ref(data);
91 + return new ResponseVo<>(200, responseCodeBo.getErrMsg(), null);
92 + } else {
93 + return new ResponseVo<>(data);
94 + }
90 } 95 }
91 96
92 public String msg(String msg){ 97 public String msg(String msg){
......
...@@ -52,7 +52,7 @@ public class Dm501Consignments implements Serializable { ...@@ -52,7 +52,7 @@ public class Dm501Consignments implements Serializable {
52 //扫描状态日期 52 //扫描状态日期
53 Date scanDate; 53 Date scanDate;
54 //用户uuid 54 //用户uuid
55 - String uuid; 55 + String userId;
56 //发件人邮箱 56 //发件人邮箱
57 String shipperEmail; 57 String shipperEmail;
58 58
......
1 package com.fedex.connect.kafka.util; 1 package com.fedex.connect.kafka.util;
2 2
3 import com.fedex.connect.common.dependencies.cache.CacheSystem; 3 import com.fedex.connect.common.dependencies.cache.CacheSystem;
4 -import com.fedex.connect.common.dependencies.enums.biz.ConsignmentStatusEnum;
5 import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils; 4 import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils;
6 import com.fedex.connect.common.dependencies.util.DateUtil; 5 import com.fedex.connect.common.dependencies.util.DateUtil;
7 import com.fedex.connect.common.model.bi.DictionaryEntries; 6 import com.fedex.connect.common.model.bi.DictionaryEntries;
...@@ -108,7 +107,7 @@ public class Dm501Util { ...@@ -108,7 +107,7 @@ public class Dm501Util {
108 //重量单位 107 //重量单位
109 ceInfo.setWeightunit(dm501Consignment.getWeightUnit()); 108 ceInfo.setWeightunit(dm501Consignment.getWeightUnit());
110 //用户uuid 109 //用户uuid
111 - ceInfo.setUserUuid(dm501Consignment.getUuid()); 110 + ceInfo.setUserUuid(dm501Consignment.getUserId());
112 //发件人邮箱 111 //发件人邮箱
113 ceInfo.setShipperEmail(dm501Consignment.getShipperEmail()); 112 ceInfo.setShipperEmail(dm501Consignment.getShipperEmail());
114 //参考信息 113 //参考信息
......
...@@ -9,4 +9,8 @@ ...@@ -9,4 +9,8 @@
9 <library-name>lib4iClearConnect</library-name> 9 <library-name>lib4iClearConnect</library-name>
10 <specification-version>1.0</specification-version> 10 <specification-version>1.0</specification-version>
11 </wls:library-ref> 11 </wls:library-ref>
12 + <wls:virtual-directory-mapping>
13 + <wls:local-path>/app/Oracle/Middleware/user_projects/domains/base_domain/iclearConnect</wls:local-path>
14 + <wls:url-pattern>/*</wls:url-pattern>
15 + </wls:virtual-directory-mapping>
12 </wls:weblogic-web-app> 16 </wls:weblogic-web-app>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -25,11 +25,11 @@ public class EmailJob { ...@@ -25,11 +25,11 @@ public class EmailJob {
25 * @param 25 * @param
26 * @return void 26 * @return void
27 */ 27 */
28 - //@ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_INTERVAL) 28 + @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_INTERVAL)
29 - //@Scheduled(cron = "${export.task.allocation.sendOb}") 29 + @Scheduled(cron = "${export.task.allocation.sendOb}")
30 - //public void notificationSenderTask() { 30 + public void notificationSenderTask() {
31 - // duplicateConsignmentEmailService.duplicateConsignmentEmail(); 31 + duplicateConsignmentEmailService.duplicateConsignmentEmail();
32 - //} 32 + }
33 33
34 /** 34 /**
35 * @Author Szl 35 * @Author Szl
...@@ -38,15 +38,15 @@ public class EmailJob { ...@@ -38,15 +38,15 @@ public class EmailJob {
38 * @param 38 * @param
39 * @return void 39 * @return void
40 */ 40 */
41 - @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.PUSH_CON_EMAIL_INTERVAL) 41 + //@ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.PUSH_CON_EMAIL_INTERVAL)
42 - @Scheduled(cron = "${export.task.allocation.sendOb}") 42 + //@Scheduled(cron = "${export.task.allocation.sendOb}")
43 - public void pushConsignmentFileTask() { 43 + //public void pushConsignmentFileTask() {
44 - pushConsignmentFileService.pushConsignmentFileTask(); 44 + // pushConsignmentFileService.pushConsignmentFileTask();
45 - } 45 + //}
46 - 46 + //
47 - /** 47 + ///**
48 - * 发送失败邮件提醒 48 + // * 发送失败邮件提醒
49 - */ 49 + // */
50 //@ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.SEND_FAIL_ALERT_INTERVAL) 50 //@ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.SEND_FAIL_ALERT_INTERVAL)
51 //@Scheduled(cron = "${export.task.allocation.sendOb}") 51 //@Scheduled(cron = "${export.task.allocation.sendOb}")
52 //public void sendingFailedEmailAlert() { 52 //public void sendingFailedEmailAlert() {
......
1 package com.fedex.connect.task.utils.sys; 1 package com.fedex.connect.task.utils.sys;
2 2
3 import com.fedex.connect.common.dependencies.cache.CacheSystem; 3 import com.fedex.connect.common.dependencies.cache.CacheSystem;
4 -import com.fedex.connect.common.dependencies.contants.ParamConfigConstants;
5 import com.fedex.connect.common.dependencies.enums.biz.EmailStatusEnum; 4 import com.fedex.connect.common.dependencies.enums.biz.EmailStatusEnum;
6 import com.fedex.connect.common.dependencies.template.clearanceEmail.DuplicateEmailTemplate; 5 import com.fedex.connect.common.dependencies.template.clearanceEmail.DuplicateEmailTemplate;
7 import com.fedex.connect.common.model.bi.DictionaryEntries; 6 import com.fedex.connect.common.model.bi.DictionaryEntries;
8 import com.fedex.connect.common.model.biz.Email; 7 import com.fedex.connect.common.model.biz.Email;
9 import com.fedex.connect.common.model.log.EmailHistory; 8 import com.fedex.connect.common.model.log.EmailHistory;
10 -import com.fedex.connect.common.model.sys.ParamConfig;
11 import com.fedex.connect.task.config.PropertiesConfig; 9 import com.fedex.connect.task.config.PropertiesConfig;
12 import com.fedex.connect.task.data.dto.MailConfigDto; 10 import com.fedex.connect.task.data.dto.MailConfigDto;
13 import com.fedex.connect.task.repository.repo.biz.IEmailRepository; 11 import com.fedex.connect.task.repository.repo.biz.IEmailRepository;
...@@ -59,7 +57,7 @@ public class DuplicateEmailUtil { ...@@ -59,7 +57,7 @@ public class DuplicateEmailUtil {
59 mailConfigDto.setReceiveAccount(email.getToAddress()); 57 mailConfigDto.setReceiveAccount(email.getToAddress());
60 58
61 //设置邮件标题 59 //设置邮件标题
62 - mailConfigDto.setSubject(duplicateEmailTemplate.getTitle()); 60 + mailConfigDto.setSubject(duplicateEmailTemplate.getTitle(email.getBizCode()));
63 String emailBody = this.createEmailBody(email.getBizCode()); 61 String emailBody = this.createEmailBody(email.getBizCode());
64 mailConfigDto.setContent(emailBody); 62 mailConfigDto.setContent(emailBody);
65 63
...@@ -89,14 +87,11 @@ public class DuplicateEmailUtil { ...@@ -89,14 +87,11 @@ public class DuplicateEmailUtil {
89 * 邮件备注 87 * 邮件备注
90 */ 88 */
91 StringBuffer remarks = new StringBuffer(); 89 StringBuffer remarks = new StringBuffer();
92 - ParamConfig paramConfig = paramConfigRepository.findValueByCode(ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_INTERVAL); 90 + this.buildBottom(remarks);
93 - this.buildBottom(remarks,paramConfig.getValue());
94 /** 91 /**
95 * 添加模板 92 * 添加模板
96 */ 93 */
97 - return duplicateEmailTemplate.getBody(propertiesConfig.getBaseUrl()+propertiesConfig.getLine(), 94 + return duplicateEmailTemplate.getBody(bizCode, remarks);
98 - propertiesConfig.getBaseUrl()+propertiesConfig.getFedex(),
99 - bizCode, remarks);
100 } 95 }
101 96
102 97
...@@ -107,8 +102,8 @@ public class DuplicateEmailUtil { ...@@ -107,8 +102,8 @@ public class DuplicateEmailUtil {
107 * @param remarks 102 * @param remarks
108 * @return void 103 * @return void
109 */ 104 */
110 - private void buildBottom(StringBuffer remarks, String paramConfig){ 105 + private void buildBottom(StringBuffer remarks){
111 - remarks.append(duplicateEmailTemplate.getDescription(paramConfig)); 106 + remarks.append(duplicateEmailTemplate.getDescription());
112 } 107 }
113 108
114 /** 109 /**
......