|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |