Commit ce4bed83 authored by mengmeng's avatar mengmeng

修改文件上传功能

parent 4b4d641c
......@@ -11,6 +11,7 @@ import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.PensionDocumentDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderDocumentDTO;
import io.hmit.modules.serviceOrder.entity.PensionDocumentEntity;
import io.hmit.modules.serviceOrder.service.PensionDocumentService;
......@@ -108,9 +109,11 @@ public class PensionOrderDocumentController {
*/
@PostMapping("/uploadFile")
@ApiOperation("附件上传")
public Result<Map<String, Object>> uploadFile(@RequestParam("file") MultipartFile file,
@RequestParam("orderId") Long orderId){
public Result<Map<String, Object>> uploadFile(@RequestParam("file") MultipartFile file){
Map<String, Object> fileMap = pensionDocumentService.uploadFile(file);
// PensionOrderDocumentDTO dto = new PensionOrderDocumentDTO().assemblePensionOrder(fileMap,orderId,roleId);
/*
if (null != fileMap) {
PensionOrderDocumentDTO dto = new PensionOrderDocumentDTO();
dto.setCreateDate(new Date());
......@@ -122,6 +125,7 @@ public class PensionOrderDocumentController {
} else {
return null;
}
*/
return new Result<Map<String, Object>>().ok(fileMap);
}
}
......@@ -65,7 +65,7 @@ public class PensionOrderEvaluationController {
pensionOrderEvaluationService.save(dto);
pensionOrderService.evaluationDone(dto.getOrderId());
pensionOrderService.evaluationDone(dto);
return new Result();
}
......
package io.hmit.modules.serviceOrder.dto;
import io.hmit.modules.serviceOrder.service.RoleService;
import io.hmit.modules.serviceOrder.service.RoleUserService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
......@@ -17,6 +22,9 @@ import java.util.Date;
@Data
@ApiModel(value = "订单及相关图片附件关联表")
public class PensionOrderDocumentDTO implements Serializable {
@Autowired
private RoleService roleService;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "")
......@@ -34,7 +42,7 @@ public class PensionOrderDocumentDTO implements Serializable {
@ApiModelProperty(value = "文件链接")
private String filePath;
@ApiModelProperty(value = "备注")
@ApiModelProperty(value = "备注 1 服务人员图片;2 服务人员录音; 3 老人/子女评价图片")
private String remark;
@ApiModelProperty(value = "创建者")
......@@ -49,5 +57,30 @@ public class PensionOrderDocumentDTO implements Serializable {
@ApiModelProperty(value = "更新时间")
private Date updateDate;
public PensionOrderDocumentDTO assemblePensionOrder(Map<String, Object> fileMap,Long orderId,Long roleId) {
PensionOrderDocumentDTO dto = new PensionOrderDocumentDTO();
if (null != fileMap) {
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());
RoleDTO roleDTO = roleService.get(roleId);
if(roleDTO != null && roleDTO.getName().contains("老人")){
dto.setRemark("3");
}
if(roleDTO != null && roleDTO.getName().contains("服务")){
String fileName = fileMap.get("filePath").toString().toLowerCase();
dto.setRemark("1");
if (fileName.endsWith(".mp3")) {
dto.setRemark("2");
}
}
}
return dto;
}
}
......@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
......@@ -25,6 +26,9 @@ public class PensionOrderEvaluationDTO implements Serializable {
@ApiModelProperty(value = "订单所属的服务id")
private Long orderId;
@ApiModelProperty(value = "角色id")
private Long roleId;
@ApiModelProperty(value = "好差评 1 好评; 2 中评; 3 差评")
private Integer evaluationReview;
......@@ -35,7 +39,7 @@ public class PensionOrderEvaluationDTO implements Serializable {
private String content;
@ApiModelProperty(value = "评价文件地址")
private String file;
private String[] files;
@ApiModelProperty(value = "创建者")
private Long creator;
......
......@@ -3,6 +3,7 @@ package io.hmit.modules.serviceOrder.service;
import io.hmit.common.page.PageData;
import io.hmit.common.service.CrudService;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderEvaluationDTO;
import io.hmit.modules.serviceOrder.entity.PensionOrderEntity;
import java.util.Map;
......@@ -49,7 +50,10 @@ public interface PensionOrderService extends CrudService<PensionOrderEntity, Pen
PageData<PensionOrderDTO> getOrganizationOrder(Map<String, Object> params, Long userId);
//老人/子女完成评价
void evaluationDone(Long orderId);
void evaluationDone(PensionOrderEvaluationDTO dto);
//文件保存到数据库
void saveFilesToDB(Long orderId,String files[],Long roleId);
//机构处理订单状态
Boolean organizationHandle(Map<String, Object> params, Long userId);
......
......@@ -8,21 +8,16 @@ import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dao.PensionOrderDao;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderServiceDTO;
import io.hmit.modules.serviceOrder.dto.*;
import io.hmit.modules.serviceOrder.entity.PensionOrderDocumentEntity;
import io.hmit.modules.serviceOrder.entity.PensionOrderEntity;
import io.hmit.modules.serviceOrder.service.PensionOrderService;
import io.hmit.modules.serviceOrder.service.PensionOrderServiceService;
import io.hmit.modules.serviceOrder.service.PensionOrganizationService;
import io.hmit.modules.serviceOrder.service.*;
import io.hmit.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 订单表
......@@ -42,6 +37,8 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
return wrapper;
}
@Autowired
private RoleService roleService;
@Autowired
private PensionOrderDao pensionOrderDao;
......@@ -49,6 +46,9 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Autowired
private PensionOrderServiceService pensionOrderServiceService;
@Autowired
private PensionOrderDocumentService PensionOrderDocumentService;
@Autowired
private PensionOrganizationService pensionOrganizationService;
......@@ -233,14 +233,45 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
return list2;
}
//将文件保存到数据库
@Override
public void saveFilesToDB(Long orderId,String files[],Long roleId){
Arrays.stream(files).forEach(item->{
PensionOrderDocumentDTO orderDocumentDTO = new PensionOrderDocumentDTO();
orderDocumentDTO.setFilePath(item);
orderDocumentDTO.setOrderId(orderId);
orderDocumentDTO.setCreateDate(new Date());
RoleDTO roleDTO = roleService.get(roleId);
if(roleDTO != null && roleDTO.getName().contains("老人")){
orderDocumentDTO.setRemark("3");
}
if(roleDTO != null && roleDTO.getName().contains("服务")){
String fileName = item.toLowerCase();
orderDocumentDTO.setRemark("1");
if (fileName.endsWith(".mp3")) {
orderDocumentDTO.setRemark("2");
}
}
PensionOrderDocumentService.save(orderDocumentDTO);
});
}
@Override
public void evaluationDone(Long orderId) {
PensionOrderDTO dto = get(orderId);
if (dto != null){
dto.setStatus(Constant.OrderStatus.DONE.geStatus());
dto.setStatusName(Constant.OrderStatus.DONE.getMessage());
public void evaluationDone(PensionOrderEvaluationDTO dto) {
PensionOrderDTO pensionOrderDTO = get(dto.getOrderId());
if (pensionOrderDTO != null){
pensionOrderDTO.setStatus(Constant.OrderStatus.DONE.geStatus());
pensionOrderDTO.setStatusName(Constant.OrderStatus.DONE.getMessage());
}
update(dto);
update(pensionOrderDTO);
saveFilesToDB(dto.getOrderId(),dto.getFiles(),dto.getRoleId());
}
}
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