Browse Source

【服务项目】新增发起项目接口

feature/teamB_zz_wgh
wangxianzhang 3 years ago
parent
commit
a3cc07497f
  1. 35
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectFeedbackFormDTO.java
  2. 36
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectRecordFormDTO.java
  3. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceProjectController.java
  4. 16
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceFeedbackDao.java
  5. 83
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceFeedbackEntity.java
  6. 5
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceRecordEntity.java
  7. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceScopeEntity.java
  8. 7
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordService.java
  9. 138
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordServiceImpl.java
  10. 28
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceFeedbackDao.xml

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

@ -0,0 +1,35 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
@Data
public class ServiceProjectFeedbackFormDTO {
private String serviceProjectId;
private String serviceGoal;
private String serviceEffect;
private Integer servicePeopleNumber;
/**
* 服务状态in_service服务中completed:已完成
*/
private String serviceStatus;
/**
* 满意度不满意:bad基本满意:good非常满意:perfect
*/
private String satisfaction;
private String longitude;
private String latitude;
private String address;
private List<Feedback> attachmentList;
@Data
public static class Feedback {
private String attachmentName;
private String attachmentFormat;
private String attachmentType;
private String attachmentUrl;
}
}

36
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/ServiceProjectRecordFormDTO.java

@ -1,27 +1,63 @@
package com.epmet.dto.form;
import com.epmet.dto.result.IcServiceScopeDTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@Data
public class ServiceProjectRecordFormDTO {
/**
* 发起服务
*/
public interface Initiate {}
@NotBlank(message = "服务类别key不能为空", groups = { Initiate.class })
private String serviceCategoryKey;
@NotBlank(message = "服务项目Id不能为空", groups = { Initiate.class })
private String serviceProjectId;
private String serviceProjectName;
@NotBlank(message = "服务组织Id不能为空", groups = { Initiate.class })
private String serviceOrgId;
private String serviceOrgName;
@NotEmpty(message = "发布范围不能为空", groups = { Initiate.class })
private List<IcServiceScopeDTO> serviceScope;
@NotNull(message = "服务起始时间不能为空", groups = { Initiate.class })
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date serviceTimeStart;
@NotNull(message = "服务结束时间不能为空", groups = { Initiate.class })
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date serviceTimeEnd;
private String serviceStatus;
private String satisfaction;
private String principalName;
private String principalContact;
/**
* 备注
*/
private String remark;
private ServiceProjectFeedbackFormDTO feedback;
private Integer pageNo = 1;
private Integer pageSize = 20;

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

@ -197,4 +197,18 @@ public class IcServiceProjectController {
return new Result().ok(page);
}
/**
* 发起服务
* @param input
* @return
*/
@PostMapping("/service/initiate")
public Result initiateService(@RequestBody ServiceProjectRecordFormDTO input) {
ValidatorUtils.validateEntity(input, ServiceProjectRecordFormDTO.Initiate.class);
icServiceRecordService.initiateService(input);
return new Result();
}
}

16
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceFeedbackDao.java

@ -0,0 +1,16 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.IcServiceFeedbackEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-30
*/
@Mapper
public interface IcServiceFeedbackDao extends BaseDao<IcServiceFeedbackEntity> {
}

83
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceFeedbackEntity.java

@ -0,0 +1,83 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-30
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_service_feedback")
public class IcServiceFeedbackEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
@TableField(fill = FieldFill.INSERT)
private String customerId;
/**
* 服务类别ID
*/
private String serviceCategoryKey;
/**
* 服务项目ID
*/
private String serviceProjectId;
/**
* 服务组织ID
*/
private String serviceOrgId;
/**
* 服务目标
*/
private String serviceGoal;
/**
* 服务效果
*/
private String serviceEffect;
/**
* 服务人数
*/
private Integer servicePeopleNumber;
/**
* 满意度满意度 - 不满意:bad基本满意:good非常满意:perfect
*/
private String satisfaction;
/**
* 地址经度
*/
private String longitude;
/**
* 地址纬度
*/
private String latitude;
/**
* 地址
*/
private String address;
/**
*
*/
private String serviceRecordId;
}

5
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceRecordEntity.java

@ -1,5 +1,7 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
@ -21,6 +23,9 @@ public class IcServiceRecordEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
@TableField(fill = FieldFill.INSERT)
private String customerId;
/**
* 服务类别ID
*/

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceScopeEntity.java

@ -1,10 +1,13 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.Date;
@ -21,6 +24,9 @@ public class IcServiceScopeEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
@TableField(fill = FieldFill.INSERT)
private String customerId;
/**
* 服务类别ID
*/

7
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.ServiceProjectRecordFormDTO;
import com.epmet.dto.result.IcServiceRecDetailRes;
import com.epmet.dto.result.ServiceProjectRecordResultDTO;
import com.epmet.entity.IcServiceRecordEntity;
@ -40,4 +41,10 @@ public interface IcServiceRecordService extends BaseService<IcServiceRecordEntit
PageData<ServiceProjectRecordResultDTO> listServiceRecords(String serviceCategoryKey, String serviceProjectName, String serviceOrgName,
Date serviceTimeStart, Date serviceTimeEnd, String serviceStatus,
String satisfaction, Integer pageNo, Integer pageSize);
/**
* 发起服务
* @param input
*/
void initiateService(ServiceProjectRecordFormDTO input);
}

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

@ -7,18 +7,26 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcServiceRecordDao;
import com.epmet.dao.IcServiceScopeDao;
import com.epmet.dao.*;
import com.epmet.dto.IcNeighborHoodDTO;
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.IcServiceScopeDTO;
import com.epmet.dto.result.ServiceProjectRecordResultDTO;
import com.epmet.entity.IcServiceRecordEntity;
import com.epmet.entity.*;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.IcServiceRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
@ -41,6 +50,16 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
private IcServiceScopeDao icServiceScopeDao;
@Autowired
private EpmetAdminOpenFeignClient adminOpenFeignClient;
@Autowired
private IcServiceProjectDao serviceProjectDao;
@Autowired
private IcServiceOrgDao serviceOrgDao;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private IcServiceFeedbackDao serviceFeedbackDao;
@Autowired
private IcServiceProjectAttachmentDao serviceProjectAttachmentDao;
/**
* http://yapi.elinkservice.cn/project/245/interface/api/7820
@ -138,4 +157,117 @@ public class IcServiceRecordServiceImpl extends BaseServiceImpl<IcServiceRecordD
return new PageData<>(records, pi.getTotal());
}
@Transactional(rollbackFor = Throwable.class)
public void initiateService(ServiceProjectRecordFormDTO input) {
IcServiceProjectEntity serviceProject = serviceProjectDao.selectById(input.getServiceProjectId());
IcServiceOrgEntity serviceOrg = serviceOrgDao.selectById(input.getServiceOrgId());
ServiceProjectFeedbackFormDTO feedbackDto = input.getFeedback();
// 1.服务记录
IcServiceRecordEntity serviceRecord = new IcServiceRecordEntity();
serviceRecord.setServiceCategoryKey(input.getServiceCategoryKey());
serviceRecord.setServiceProjectId(input.getServiceProjectId());
serviceRecord.setServiceProjectName(serviceProject.getServiceName());
serviceRecord.setServiceOrgId(input.getServiceOrgId());
serviceRecord.setServiceOrgName(serviceOrg.getOrgName());
serviceRecord.setPrincipalName(input.getPrincipalName());
serviceRecord.setPrincipalContact(input.getPrincipalContact());
serviceRecord.setServiceTimeStart(input.getServiceTimeStart());
serviceRecord.setServiceTimeEnd(input.getServiceTimeEnd());
serviceRecord.setServiceStatus(feedbackDto.getServiceStatus());
serviceRecord.setRemark(input.getRemark());
baseDao.insert(serviceRecord);
// 2.服务范围列表
List<IcServiceScopeDTO> serviceScope = input.getServiceScope();
serviceScope.stream().forEach(s -> {
String[] scopeObjectIdPathAndName = getScopeObjectIdPath(s.getObjectType(), s.getObjectId());
IcServiceScopeEntity scope = new IcServiceScopeEntity();
scope.setServiceCategoryKey(input.getServiceCategoryKey());
scope.setServiceProjectId(input.getServiceProjectId());
scope.setServiceOrgId(input.getServiceOrgId());
scope.setServiceRecordId(serviceRecord.getId());
scope.setObjectType(s.getObjectType());
scope.setObjectId(s.getObjectId());
scope.setObjectIdPath(scopeObjectIdPathAndName[0]);
scope.setObjectName(scopeObjectIdPathAndName[1]);
icServiceScopeDao.insert(scope);
//scope.setRemark(); 为什么会有这个字段??
});
// 3.反馈
if (input == null) {
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.Feedback> attachmentList = feedbackDto.getAttachmentList();
if (CollectionUtils.isNotEmpty(attachmentList)) {
attachmentList.forEach(a -> {
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());
// todo 需要审核吗
at.setReason(null);
at.setStatus(null);
serviceProjectAttachmentDao.insert(at);
});
}
}
/**
* 查询服务范围的对象的Id path
* @param scopeObjectType
* @param scopeObjectId
* @return
*/
private String[] getScopeObjectIdPath(String scopeObjectType, String scopeObjectId) {
if ("neighborhood".equals(scopeObjectType)) {
String msg = String.format("【服务项目】-发起服务-根据范围id查询小区信息失败。scopeObjectType:%s, scopeObjectId:%s",
scopeObjectType, scopeObjectId);
IcNeighborHoodDTO neighborHoodDTO = getResultDataOrThrowsException(govOrgOpenFeignClient.getIcNeighbordhoodById(scopeObjectId),
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.SERVER_ERROR.getCode(),
msg, msg);
return new String[]{ neighborHoodDTO.getAgencyPids().concat(":").concat(neighborHoodDTO.getId()),
neighborHoodDTO.getNeighborHoodName() };
} else if ("agency".equals(scopeObjectType)) {
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(scopeObjectId);
if ("0".equals(agencyInfo.getPid())) {
return new String[]{ agencyInfo.getId(), agencyInfo.getOrganizationName() };
}
return new String[]{ agencyInfo.getPids().concat(":").concat(agencyInfo.getPid()), agencyInfo.getOrganizationName() };
} else if ("grid".equals(scopeObjectType)) {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(scopeObjectId);
return new String[]{ gridInfo.getPids().concat(":").concat(gridInfo.getPid()), gridInfo.getGridName() };
} else {
String msg = String.format("【服务项目】-发起服务-范围type未知:scopeObjectType:%s,scopeObjectId:%s", scopeObjectType, scopeObjectId);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
}
}
}

28
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceFeedbackDao.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.IcServiceFeedbackDao">
<resultMap type="com.epmet.entity.IcServiceFeedbackEntity" id="icServiceFeedbackMap">
<result property="id" column="ID"/>
<result property="serviceCategoryKey" column="SERVICE_CATEGORY_KEY"/>
<result property="serviceProjectId" column="SERVICE_PROJECT_ID"/>
<result property="serviceOrgId" column="SERVICE_ORG_ID"/>
<result property="serviceGoal" column="SERVICE_GOAL"/>
<result property="serviceEffect" column="SERVICE_EFFECT"/>
<result property="servicePeopleNumber" column="SERVICE_PEOPLE_NUMBER"/>
<result property="satisfaction" column="SATISFACTION"/>
<result property="longitude" column="LONGITUDE"/>
<result property="latitude" column="LATITUDE"/>
<result property="address" column="address"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="serviceRecordId" column="SERVICE_RECORD_ID"/>
</resultMap>
</mapper>
Loading…
Cancel
Save