Commit 00227a49 by kangxiaoshan

上传附件

parent c3405769
......@@ -178,7 +178,7 @@
<redis.event.database>13</redis.event.database>
<!--Redis setting//end-->
<downhost>http://172.23.6.108:9001</downhost>
<ddb.accesskey>AKIAOS2UEXIFNVER2O6A</ddb.accesskey>
<ddb.secretkey>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</ddb.secretkey>
<ddb.region>cn-north-1</ddb.region>
......@@ -286,6 +286,7 @@
<redis.event.database>13</redis.event.database>
<!--Redis setting//end-->
<downhost>http://172.31.25.137:9001</downhost>
<ddb.accesskey>AKIA3XXNRTS2KXU632MD</ddb.accesskey>
<ddb.secretkey>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</ddb.secretkey>
<ddb.region>cn-north-1</ddb.region>
......
package common.controller;
import common.model.DmpIncome;
import common.model.PdAttachment;
import common.model.User;
import common.service.DmpIncomeService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import security.annotation.CurrentAccount;
import util.ResultModel;
@Controller
@RequestMapping("{platform}")
public class AttachmnetUploadController {
@Autowired
DmpIncomeService dmpIncomeService;
//上传附件
@PostMapping("/upload/attachment")
@ResponseBody
public ResultModel uploadAttach(@RequestParam("file") MultipartFile[] files, String contractCode, @CurrentAccount User user) {
String erroNames = "";
for (MultipartFile file : files) {
PdAttachment attachment = dmpIncomeService.uploadPdAttach(file, contractCode, user);
if (attachment.getFaild()) {
erroNames += " " + attachment.getFileOrginName();
}
}
if (!StringUtils.isEmpty(erroNames)) {
return ResultModel.ERROR(5001, "文件:" + erroNames + "上传失败");
}
return ResultModel.OK();
}
//下载附加
@RequestMapping(value = "/download/attachment/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity<byte[]> getDownloadResponseEntity(@PathVariable Long id) {
return dmpIncomeService.downloadAttach(id);
}
//删除附件
@PostMapping("/delete/attachment/{id}")
@ResponseBody
public ResultModel deleteAttach(@PathVariable Long id) {
return ResultModel.OK(dmpIncomeService.deleteAttach(id));
}
//附件列表
@GetMapping("/list/attachment")
@ResponseBody
public ResultModel attachList(String code,String startDate,String endDate, @PathVariable String platform) {
return dmpIncomeService.attachList(code,startDate,endDate, platform);
}
}
......@@ -48,22 +48,23 @@ public class PdController {
return ResultModel.OK(dmpIncomeService.pdDelete(income));
}
//上传附件
@PostMapping("/upload/attachment")
public ResultModel uploadAttach(@RequestParam("file") MultipartFile file, String contractCode, @CurrentAccount User user) {
////上传附件
//@PostMapping("/upload/attachment")
//public ResultModel uploadAttach(@RequestParam("file") MultipartFile file, String contractCode, @CurrentAccount User user) {
//
// return ResultModel.OK(dmpIncomeService.uploadPdAttach(file, contractCode, user));
//}
//
////下载附加
//@RequestMapping(value = "download/attachment/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
//public ResponseEntity<byte[]> getDownloadResponseEntity(@PathVariable Long id) {
// return dmpIncomeService.downloadAttach(id);
//}
//
////删除附件
//@PostMapping("/delete/load/attachment/{id}")
//public ResultModel deleteAttach(@PathVariable Long id) {
// return ResultModel.OK(dmpIncomeService.deleteAttach(id));
//}
return ResultModel.OK(dmpIncomeService.uploadPdAttach(file, contractCode, user));
}
//下载附加
@RequestMapping(value = "download/attachment/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity<byte[]> getDownloadResponseEntity(@PathVariable Long id) {
return dmpIncomeService.downloadAttach(id);
}
//删除附件
@PostMapping("/delete/load/attachment/{id}")
public ResultModel deleteAttach(@PathVariable Long id) {
return ResultModel.OK(dmpIncomeService.deleteAttach(id));
}
}
......@@ -3,6 +3,7 @@ package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
@Entity
......@@ -13,7 +14,10 @@ public class PdAttachment {
private String fileName;//文件名
private String fileType;//文件类型
private Date uploadDate;//上传日期
private String uploadDateValue;
private String uploadUser;
private Boolean isFaild;// 是否失败
private String downloadUrl;
@Id
@GeneratedValue
......@@ -72,4 +76,30 @@ public class PdAttachment {
public void setFileType(String fileType) {
this.fileType = fileType;
}
@Transient
public Boolean getFaild() {
return isFaild;
}
public void setFaild(Boolean faild) {
isFaild = faild;
}
public String getUploadDateValue() {
return uploadDateValue;
}
public void setUploadDateValue(String uploadDateValue) {
this.uploadDateValue = uploadDateValue;
}
@Transient
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
}
......@@ -2,6 +2,14 @@ package common.repository;
import common.model.PdAttachment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface PdAttachmentRepository extends JpaRepository<PdAttachment, Long> {
List<PdAttachment> findBycontractCode(String code);
@Query(value = "select * from pd_attachment where contract_code=?1 and upload_date >= ?2 and upload_date <= ?3", nativeQuery = true)
List<PdAttachment> findBycontractCodeAndDate(String code, String startDate, String endDate);
}
......@@ -7,7 +7,6 @@ import common.model.User;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import tkio.model.Account;
import util.ResultModel;
import java.util.List;
......@@ -46,4 +45,5 @@ public interface DmpIncomeService {
HSSFWorkbook exportPdIncomeList(String startDate, String endDate, String bodyCode, String serchName);
ResultModel attachList(String code, String startDate, String endDate, String platform);
}
......@@ -45,6 +45,7 @@ public class Constant {
public static String ddbregion = ddbBundle.getString("ddb.region");
public static String bucket = ddbBundle.getString("ddb.bucket");
public static String uploadPath = ddbBundle.getString("ddb.upload.path");
public static String downhost = ddbBundle.getString("downhost");
}
......@@ -2,4 +2,6 @@ ddb.accesskey=${ddb.accesskey}
ddb.secretkey=${ddb.secretkey}
ddb.region=${ddb.region}
ddb.bucket=${ddb.bucket}
ddb.upload.path=${ddb.upload.path}
\ No newline at end of file
ddb.upload.path=${ddb.upload.path}
downhost=${downhost}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment