Browse Source

新增:【服务项目】新增提交服务反馈接口

feature/teamB_zz_wgh
wangxianzhang 3 years ago
parent
commit
6fbfe43ffc
  1. 20
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectFeedbackFormDTO.java
  2. 38
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceProjectController.java
  3. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordService.java
  4. 95
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordServiceImpl.java

20
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectFeedbackFormDTO.java

@ -2,11 +2,24 @@ package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
@Data
public class ServiceProjectFeedbackFormDTO {
/**
* 反馈接口分组
*/
public interface FeedbackGroup {}
/**
* 发起服务接口分组
*/
public interface InitiateGroup {}
@NotBlank(message = "服务记录id不能为空", groups = { FeedbackGroup.class })
private String serviceRecordId;
private String serviceProjectId;
private String serviceGoal;
private String serviceEffect;
@ -14,9 +27,11 @@ public class ServiceProjectFeedbackFormDTO {
/**
* 服务状态in_service服务中completed:已完成
*/
@NotBlank(message = "服务状态不能为空", groups = { FeedbackGroup.class, InitiateGroup.class })
private String serviceStatus;
/**
* 满意度不满意:bad基本满意:good非常满意:perfect
* 按理说服务完成的时候才可以选不完成应该不能选可是谁知道呢原型也没写
*/
private String satisfaction;
private String longitude;
@ -26,9 +41,14 @@ public class ServiceProjectFeedbackFormDTO {
@Data
public static class Attachment {
@NotBlank(message = "附件名称不能为空", groups = { FeedbackGroup.class, InitiateGroup.class })
private String attachmentName;
@NotBlank(message = "附件格式不能为空", groups = { FeedbackGroup.class, InitiateGroup.class })
private String attachmentFormat;
@NotBlank(message = "附件类型不能为空", groups = { FeedbackGroup.class, InitiateGroup.class })
private String attachmentType;
@NotBlank(message = "附件url不能为空", groups = { FeedbackGroup.class, InitiateGroup.class })
private String attachmentUrl;
}
}

38
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceProjectController.java

@ -2,6 +2,8 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
@ -11,13 +13,11 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcServiceProjectDTO;
import com.epmet.dto.form.IcServiceEditFormDTO;
import com.epmet.dto.form.ServiceProjectFormDTO;
import com.epmet.dto.form.ServiceProjectListFormDTO;
import com.epmet.dto.form.ServiceProjectRecordFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.IcServiceRecDetailRes;
import com.epmet.dto.result.ServiceProjectListResultDTO;
import com.epmet.dto.result.ServiceProjectRecordResultDTO;
import com.epmet.entity.IcServiceRecordEntity;
import com.epmet.service.IcServiceProjectService;
import com.epmet.service.IcServiceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
@ -211,4 +211,34 @@ public class IcServiceProjectController {
return new Result();
}
/**
* 反馈
* @param input
* @return
*/
@PostMapping("/service/feedback")
public Result serviceFeedback(@RequestBody ServiceProjectFeedbackFormDTO input) {
ValidatorUtils.validateEntity(input, ServiceProjectFeedbackFormDTO.FeedbackGroup.class);
String serviceRecordId = input.getServiceRecordId();
// 做状态检查,未反馈的,服务状态为服务中的才可以反馈
IcServiceRecordEntity serviceRecord = icServiceRecordService.selectById(serviceRecordId);
if (serviceRecord == null) {
String msg = "未找到服务记录";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
if ("completed".equals(serviceRecord.getServiceStatus())) {
String msg = "服务已完成,不能再次反馈";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
icServiceRecordService.serviceFeedback(serviceRecord.getServiceCategoryKey(),
serviceRecord.getServiceOrgId(),
serviceRecord.getServiceProjectId(),
serviceRecord.getId(),
input);
return new Result();
}
}

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordService.java

@ -3,6 +3,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.form.IcServiceEditFormDTO;
import com.epmet.dto.form.ServiceProjectFeedbackFormDTO;
import com.epmet.dto.form.ServiceProjectRecordFormDTO;
import com.epmet.dto.result.IcServiceRecDetailRes;
import com.epmet.dto.result.ServiceProjectRecordResultDTO;
@ -47,4 +48,9 @@ public interface IcServiceRecordService extends BaseService<IcServiceRecordEntit
* @param input
*/
void initiateService(ServiceProjectRecordFormDTO input);
/**
* 服务反馈
*/
void serviceFeedback(String serviceCategoryKey, String serviceOrgId, String serviceProjectId, String serviceRecordId, ServiceProjectFeedbackFormDTO feedbackDto);
}

95
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.enums.DictTypeEnum;
@ -59,6 +60,8 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
private IcServiceFeedbackDao serviceFeedbackDao;
@Autowired
private IcServiceProjectAttachmentDao serviceProjectAttachmentDao;
@Autowired
private IcServiceRecordDao serviceRecordDao;
/**
* http://yapi.elinkservice.cn/project/245/interface/api/7820
@ -159,6 +162,15 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
@Transactional(rollbackFor = Throwable.class)
public void initiateService(ServiceProjectRecordFormDTO input) {
LambdaQueryWrapper<IcServiceRecordEntity> query = new LambdaQueryWrapper<>();
query.eq(IcServiceRecordEntity::getServiceProjectId, input.getServiceProjectId());
if (serviceRecordDao.selectCount(query) > 0) {
String msg = "该项目已经发起服务,不能重复发起";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
IcServiceProjectEntity serviceProject = serviceProjectDao.selectById(input.getServiceProjectId());
IcServiceOrgEntity serviceOrg = serviceOrgDao.selectById(input.getServiceOrgId());
@ -203,40 +215,7 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
return;
}
IcServiceFeedbackEntity feedbackEntity = new IcServiceFeedbackEntity();
feedbackEntity.setServiceCategoryKey(input.getServiceCategoryKey());
feedbackEntity.setServiceProjectId(input.getServiceProjectId());
feedbackEntity.setServiceOrgId(input.getServiceOrgId());
feedbackEntity.setServiceGoal(feedbackDto.getServiceGoal());
feedbackEntity.setServiceEffect(feedbackDto.getServiceEffect());
feedbackEntity.setServicePeopleNumber(feedbackDto.getServicePeopleNumber());
feedbackEntity.setSatisfaction(feedbackDto.getSatisfaction());
feedbackEntity.setLongitude(feedbackDto.getLongitude());
feedbackEntity.setLatitude(feedbackDto.getLatitude());
feedbackEntity.setAddress(feedbackDto.getAddress());
feedbackEntity.setServiceRecordId(serviceRecord.getId());
serviceFeedbackDao.insert(feedbackEntity);
// 4.反馈附件列表
List<ServiceProjectFeedbackFormDTO.Attachment> attachmentList = feedbackDto.getAttachmentList();
if (CollectionUtils.isNotEmpty(attachmentList)) {
for (int i = 0; i < attachmentList.size(); i++) {
ServiceProjectFeedbackFormDTO.Attachment a = attachmentList.get(i);
IcServiceProjectAttachmentEntity at = new IcServiceProjectAttachmentEntity();
at.setAttachmentFormat(a.getAttachmentFormat());
at.setAttachmentName(a.getAttachmentName());
at.setAttachmentType(a.getAttachmentType());
at.setAttachmentUrl(a.getAttachmentUrl());
at.setDuration(0);
at.setIcServiceId(input.getServiceProjectId());
// 根本不需要审核,逗你玩
at.setReason(null);
at.setStatus("auto_passed");
at.setSort(i);
serviceProjectAttachmentDao.insert(at);
}
}
serviceFeedback(input.getServiceCategoryKey(), input.getServiceOrgId(), input.getServiceProjectId(), serviceRecord.getId(), feedbackDto);
}
/**
@ -283,4 +262,52 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
}
@Transactional(rollbackFor = Throwable.class)
@Override
public void serviceFeedback(String serviceCategoryKey, String serviceOrgId, String serviceProjectId, String serviceRecordId, ServiceProjectFeedbackFormDTO feedbackDto) {
// 如果还在服务中,那么需要改为已结束
IcServiceRecordEntity serviceRecord = serviceRecordDao.selectById(serviceRecordId);
if ("in_service".equals(serviceRecord.getServiceStatus())) {
serviceRecord.setServiceStatus("completed");
serviceRecordDao.updateById(serviceRecord);
}
// 反馈信息
IcServiceFeedbackEntity feedbackEntity = new IcServiceFeedbackEntity();
feedbackEntity.setServiceCategoryKey(serviceCategoryKey);
feedbackEntity.setServiceProjectId(serviceProjectId);
feedbackEntity.setServiceOrgId(serviceOrgId);
feedbackEntity.setServiceGoal(feedbackDto.getServiceGoal());
feedbackEntity.setServiceEffect(feedbackDto.getServiceEffect());
feedbackEntity.setServicePeopleNumber(feedbackDto.getServicePeopleNumber());
feedbackEntity.setSatisfaction(feedbackDto.getSatisfaction());
feedbackEntity.setLongitude(feedbackDto.getLongitude());
feedbackEntity.setLatitude(feedbackDto.getLatitude());
feedbackEntity.setAddress(feedbackDto.getAddress());
feedbackEntity.setServiceRecordId(serviceRecordId);
serviceFeedbackDao.insert(feedbackEntity);
// 反馈附件列表
List<ServiceProjectFeedbackFormDTO.Attachment> attachmentList = feedbackDto.getAttachmentList();
if (CollectionUtils.isNotEmpty(attachmentList)) {
for (int i = 0; i < attachmentList.size(); i++) {
ServiceProjectFeedbackFormDTO.Attachment a = attachmentList.get(i);
IcServiceProjectAttachmentEntity at = new IcServiceProjectAttachmentEntity();
at.setAttachmentFormat(a.getAttachmentFormat());
at.setAttachmentName(a.getAttachmentName());
at.setAttachmentType(a.getAttachmentType());
at.setAttachmentUrl(a.getAttachmentUrl());
at.setDuration(0);
at.setIcServiceId(serviceProjectId);
// 根本不需要审核,逗你玩
at.setReason(null);
at.setStatus("auto_passed");
at.setSort(i);
serviceProjectAttachmentDao.insert(at);
}
}
}
}
Loading…
Cancel
Save