Commit d1bea003 authored by mlchun's avatar mlchun

1.订单图片关联 附件上传接口完成

parent a73e2dd7
...@@ -22,7 +22,7 @@ public class PensionOrderDocumentDTO implements Serializable { ...@@ -22,7 +22,7 @@ public class PensionOrderDocumentDTO implements Serializable {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private Long id; private Long id;
@ApiModelProperty(value = "服务id") @ApiModelProperty(value = "订单id")
private Long orderId; private Long orderId;
@ApiModelProperty(value = "文件id") @ApiModelProperty(value = "文件id")
......
...@@ -20,7 +20,7 @@ public class PensionOrderDocumentEntity extends BaseEntity { ...@@ -20,7 +20,7 @@ public class PensionOrderDocumentEntity extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 服务id * 订单id
*/ */
private Long orderId; private Long orderId;
/** /**
......
...@@ -38,6 +38,11 @@ spring: ...@@ -38,6 +38,11 @@ spring:
min-idle: 5 # 连接池中的最小空闲连接 min-idle: 5 # 连接池中的最小空闲连接
activiti: activiti:
check-process-definitions: false check-process-definitions: false
# mvc:
# static-path-pattern: /static/**
# resources:
# static-locations: file:${QR.download-path},classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/
#静态资源对外暴露的访问路径
fdfs: fdfs:
......
package io.hmit.modules.serviceOrder.controller; package io.hmit.modules.serviceOrder.controller;
import io.hmit.annotation.Login;
import io.hmit.annotation.LoginUser;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -8,16 +10,25 @@ import io.hmit.common.validator.ValidatorUtils; ...@@ -8,16 +10,25 @@ import io.hmit.common.validator.ValidatorUtils;
import io.hmit.common.validator.group.AddGroup; import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup; import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup; import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.PensionOrderDocumentDTO; import io.hmit.modules.serviceOrder.dto.PensionOrderDocumentDTO;
import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity;
import io.hmit.modules.serviceOrder.service.PensionDocumentService;
import io.hmit.modules.serviceOrder.service.PensionOrderDocumentService; import io.hmit.modules.serviceOrder.service.PensionOrderDocumentService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -34,6 +45,9 @@ public class PensionOrderDocumentController { ...@@ -34,6 +45,9 @@ public class PensionOrderDocumentController {
@Autowired @Autowired
private PensionOrderDocumentService pensionOrderDocumentService; private PensionOrderDocumentService pensionOrderDocumentService;
@Autowired
private PensionDocumentService pensionDocumentService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -89,4 +103,25 @@ public class PensionOrderDocumentController { ...@@ -89,4 +103,25 @@ public class PensionOrderDocumentController {
return new Result(); return new Result();
} }
/**
* 上传文件
*/
@PostMapping("/uploadFile")
@ApiOperation("附件上传")
public Result<Map<String, Object>> uploadFile(@RequestParam("file") MultipartFile file,
@RequestParam("orderId") Long orderId){
Map<String, Object> fileMap = pensionDocumentService.uploadFile(file);
if (null != fileMap) {
PensionOrderDocumentDTO dto = new PensionOrderDocumentDTO();
dto.setCreateDate(new Date());
dto.setOrderId(orderId);
dto.setDocId(Long.parseLong(fileMap.get("docId").toString()));
dto.setFileName(fileMap.get("fileName").toString());
dto.setFilePath(fileMap.get("filePath").toString());
pensionOrderDocumentService.save(dto);
} else {
return null;
}
return new Result<Map<String, Object>>().ok(fileMap);
}
} }
\ No newline at end of file
...@@ -22,7 +22,7 @@ public class PensionOrderDocumentDTO implements Serializable { ...@@ -22,7 +22,7 @@ public class PensionOrderDocumentDTO implements Serializable {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private Long id; private Long id;
@ApiModelProperty(value = "服务id") @ApiModelProperty(value = "订单id")
private Long orderId; private Long orderId;
@ApiModelProperty(value = "文件id") @ApiModelProperty(value = "文件id")
......
...@@ -20,7 +20,7 @@ public class PensionOrderDocumentEntity extends BaseEntity { ...@@ -20,7 +20,7 @@ public class PensionOrderDocumentEntity extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 服务id * 订单id
*/ */
private Long orderId; private Long orderId;
/** /**
......
...@@ -3,6 +3,9 @@ package io.hmit.modules.serviceOrder.service; ...@@ -3,6 +3,9 @@ package io.hmit.modules.serviceOrder.service;
import io.hmit.common.service.CrudService; import io.hmit.common.service.CrudService;
import io.hmit.modules.serviceOrder.dto.PensionDocumentDTO; import io.hmit.modules.serviceOrder.dto.PensionDocumentDTO;
import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity; import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;
/** /**
* 文件信息表 * 文件信息表
...@@ -12,4 +15,6 @@ import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity; ...@@ -12,4 +15,6 @@ import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity;
*/ */
public interface PensionDocumentService extends CrudService<PensionDocumentEntity, PensionDocumentDTO> { public interface PensionDocumentService extends CrudService<PensionDocumentEntity, PensionDocumentDTO> {
Map<String, Object> uploadFile(MultipartFile file);
} }
\ No newline at end of file
...@@ -2,13 +2,19 @@ package io.hmit.modules.serviceOrder.service.impl; ...@@ -2,13 +2,19 @@ package io.hmit.modules.serviceOrder.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.Result;
import io.hmit.modules.serviceOrder.dao.PensionDocumentDao; import io.hmit.modules.serviceOrder.dao.PensionDocumentDao;
import io.hmit.modules.serviceOrder.dto.PensionDocumentDTO; import io.hmit.modules.serviceOrder.dto.PensionDocumentDTO;
import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity; import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity;
import io.hmit.modules.serviceOrder.service.PensionDocumentService; import io.hmit.modules.serviceOrder.service.PensionDocumentService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -30,5 +36,44 @@ public class PensionDocumentServiceImpl extends CrudServiceImpl<PensionDocumentD ...@@ -30,5 +36,44 @@ public class PensionDocumentServiceImpl extends CrudServiceImpl<PensionDocumentD
return wrapper; return wrapper;
} }
@Value("${QR.download-path}")
private String QRPath;
@Override
public Map<String, Object> uploadFile(MultipartFile file) {
if (file.isEmpty()) {
return null;
}
//生成随机时间错
Long currenttime=System.currentTimeMillis();
//上传文件
String file_path = "/static/"+ currenttime +"-" + file.getOriginalFilename();
String file_path_act = QRPath + currenttime+"-"+file.getOriginalFilename();
System.out.println(file_path_act);
File fileAct = new File(file_path_act);
if (!fileAct.getParentFile().exists()) {
fileAct.getParentFile().mkdirs();
}
try {
file.transferTo(fileAct);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
//保存文件信息
PensionDocumentEntity pensionDocumentEntity = new PensionDocumentEntity();
pensionDocumentEntity.setFileName(fileAct.getName());
pensionDocumentEntity.setFilePath(file_path);
pensionDocumentEntity.setFilePathAct(fileAct.getPath());
pensionDocumentEntity.setFileSize(Double.parseDouble(String.valueOf(file.getSize())));
pensionDocumentEntity.setFileType(file.getContentType());
pensionDocumentEntity.setStatus("1");
insert(pensionDocumentEntity);
Map<String, Object> result = new HashMap<>();
result.put("fileName",fileAct.getName());
result.put("filePath",file_path);
result.put("docId", pensionDocumentEntity.getId());
return result;
}
} }
\ No newline at end of file
...@@ -38,6 +38,11 @@ spring: ...@@ -38,6 +38,11 @@ spring:
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接 max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接 min-idle: 5 # 连接池中的最小空闲连接
# mvc:
# static-path-pattern: /static/**
# resources:
# static-locations: file:${QR.download-path},classpath:/META-INF/resources/, classpath:/resources/, classpath:/static/, classpath:/public/
# #静态资源对外暴露的访问路径
hmit: hmit:
redis: redis:
...@@ -65,3 +70,6 @@ mybatis-plus: ...@@ -65,3 +70,6 @@ mybatis-plus:
cache-enabled: false cache-enabled: false
call-setters-on-nulls: true call-setters-on-nulls: true
jdbc-type-for-null: 'null' jdbc-type-for-null: 'null'
QR:
# download-path: /home/resourse/bsqzc/ D:/123/ /home/websoft/java_jar/bl_workorder/myfile/
download-path: D:/123/
\ 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