|
|
@ -1,19 +1,27 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.MqConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; |
|
|
|
import com.epmet.commons.tools.enums.EventEnum; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.SystemMessageType; |
|
|
|
import com.epmet.constant.UserDemandConstant; |
|
|
|
import com.epmet.dao.IcUserDemandOperateLogDao; |
|
|
|
import com.epmet.dao.IcUserDemandRecDao; |
|
|
|
import com.epmet.dao.IcUserDemandSatisfactionDao; |
|
|
|
import com.epmet.dao.IcUserDemandServiceDao; |
|
|
|
import com.epmet.dto.IcUserDemandRecDTO; |
|
|
|
import com.epmet.dto.result.demand.FinishResultDTO; |
|
|
|
import com.epmet.dto.form.AutoEvaluateDemandFormDTO; |
|
|
|
import com.epmet.dto.form.SystemMsgFormDTO; |
|
|
|
import com.epmet.entity.IcUserDemandOperateLogEntity; |
|
|
|
import com.epmet.entity.IcUserDemandSatisfactionEntity; |
|
|
|
import com.epmet.entity.IcUserDemandServiceEntity; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.service.IcPartyUnitService; |
|
|
|
import com.epmet.service.IcResiDemandDictService; |
|
|
|
import com.epmet.service.IcUserDemandSatisfactionService; |
|
|
@ -26,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
@Slf4j |
|
|
@ -43,19 +50,72 @@ public class IcUserDemandSatisfactionServiceImpl extends BaseServiceImpl<IcUserD |
|
|
|
private IcResiDemandDictService demandDictService; |
|
|
|
@Autowired |
|
|
|
private IcPartyUnitService icPartyUnitService; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public List<FinishResultDTO> evaluateDemandAuto(String customerId, Integer exceedDay) { |
|
|
|
public void evaluateDemandAuto(AutoEvaluateDemandFormDTO formDTO) { |
|
|
|
if (null == formDTO.getExceedValue()) { |
|
|
|
formDTO.setExceedValue(NumConstant.SEVEN); |
|
|
|
formDTO.setType("day"); |
|
|
|
} |
|
|
|
// 查询完成后,超过7天未评价的记录
|
|
|
|
List<IcUserDemandRecDTO> list=icUserDemandRecDao.selectNoEvaluate(customerId,exceedDay); |
|
|
|
List<IcUserDemandRecDTO> list=icUserDemandRecDao.selectNoEvaluate(formDTO.getCustomerId(),formDTO.getExceedValue(),formDTO.getType()); |
|
|
|
if(CollectionUtils.isEmpty(list)){ |
|
|
|
return Collections.EMPTY_LIST; |
|
|
|
return; |
|
|
|
} |
|
|
|
List<FinishResultDTO> resultList=new ArrayList<>(); |
|
|
|
Date nowDate=new Date(); |
|
|
|
for(IcUserDemandRecDTO demand:list){ |
|
|
|
|
|
|
|
//4、返回服务方,志愿者发放积分,区域化党建单位,计算群众满意度
|
|
|
|
IcUserDemandServiceEntity serviceEntity = demandServiceDao.selectByRecId(demand.getId()); |
|
|
|
if(null==serviceEntity){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(UserDemandConstant.PARTY_UNIT.equals(serviceEntity.getServiceType())){ |
|
|
|
ServerSatisfactionCalFormDTO satisfactionCalFormDTO=new ServerSatisfactionCalFormDTO(); |
|
|
|
satisfactionCalFormDTO.setCustomerId(demand.getCustomerId()); |
|
|
|
satisfactionCalFormDTO.setServiceType(serviceEntity.getServiceType()); |
|
|
|
satisfactionCalFormDTO.setServerId(serviceEntity.getServerId()); |
|
|
|
icPartyUnitService.calPartyUnitSatisfation(satisfactionCalFormDTO); |
|
|
|
}else if(UserDemandConstant.VOLUNTEER.equals(serviceEntity.getServiceType())){ |
|
|
|
List<BasePointEventMsg> actPointEventMsgList = new ArrayList<>(); |
|
|
|
BasePointEventMsg actPointEventMsg = new BasePointEventMsg(); |
|
|
|
actPointEventMsg.setCustomerId(demand.getCustomerId()); |
|
|
|
actPointEventMsg.setSourceType(MqConstant.SOURCE_TYPE_DEMAND); |
|
|
|
actPointEventMsg.setSourceId(demand.getId()); |
|
|
|
actPointEventMsg.setUserId(serviceEntity.getServerId()); |
|
|
|
actPointEventMsg.setActionFlag(MqConstant.PLUS); |
|
|
|
actPointEventMsg.setIsCommon(false); |
|
|
|
String content = demand.getContent().length() > 100 ? demand.getContent().substring(0, 99) : demand.getContent(); |
|
|
|
actPointEventMsg.setRemark(String.format(UserDemandConstant.GRANT_POINT_REMARK,demand.getDemandUserName(),content)); |
|
|
|
actPointEventMsg.setEventTag(EventEnum.FINISH_USER_DEMAND.getEventTag()); |
|
|
|
actPointEventMsg.setEventClass(EventEnum.FINISH_USER_DEMAND.getEventClass()); |
|
|
|
if(StringUtils.isBlank(demand.getParentCode())||NumConstant.ZERO_STR.equals(demand.getParentCode())){ |
|
|
|
actPointEventMsg.setEventName(demandDictService.getCategoryName(demand.getCustomerId(),demand.getCategoryCode())); |
|
|
|
}else{ |
|
|
|
actPointEventMsg.setEventName(demandDictService.getCategoryName(demand.getCustomerId(),demand.getParentCode())); |
|
|
|
} |
|
|
|
actPointEventMsg.setObjectId(demand.getCategoryCode()); |
|
|
|
actPointEventMsg.setPoint(demand.getAwardPoint()); |
|
|
|
actPointEventMsgList.add(actPointEventMsg); |
|
|
|
SystemMsgFormDTO sendMsgForm = new SystemMsgFormDTO(); |
|
|
|
sendMsgForm.setContent(actPointEventMsgList); |
|
|
|
sendMsgForm.setMessageType(SystemMessageType.FINISH_USER_DEMAND); |
|
|
|
Result mqResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(sendMsgForm); |
|
|
|
if (!mqResult.success()) { |
|
|
|
log.warn(String.format("需求自动评价志愿者发放积分失败:demandRecId:%s,消息体:%s", demand.getId(), JSON.toJSONString(sendMsgForm))); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 1、插入评价得分记录
|
|
|
|
IcUserDemandSatisfactionEntity satisfactionEntity = new IcUserDemandSatisfactionEntity(); |
|
|
|
satisfactionEntity.setCustomerId(demand.getCustomerId()); |
|
|
@ -79,34 +139,6 @@ public class IcUserDemandSatisfactionServiceImpl extends BaseServiceImpl<IcUserD |
|
|
|
|
|
|
|
// 3、更新主表已评价标识,是否解决标识。
|
|
|
|
icUserDemandRecDao.evaluate(demand.getId(),UserDemandConstant.RESOLVED); |
|
|
|
|
|
|
|
//4、返回服务方,志愿者发放积分,区域化党建单位,计算群众满意度
|
|
|
|
IcUserDemandServiceEntity serviceEntity = demandServiceDao.selectByRecId(demand.getId()); |
|
|
|
if(null==serviceEntity){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(UserDemandConstant.PARTY_UNIT.equals(serviceEntity.getServiceType())){ |
|
|
|
ServerSatisfactionCalFormDTO satisfactionCalFormDTO=new ServerSatisfactionCalFormDTO(); |
|
|
|
satisfactionCalFormDTO.setCustomerId(demand.getCustomerId()); |
|
|
|
satisfactionCalFormDTO.setServiceType(serviceEntity.getServiceType()); |
|
|
|
satisfactionCalFormDTO.setServerId(serviceEntity.getServerId()); |
|
|
|
icPartyUnitService.calPartyUnitSatisfation(satisfactionCalFormDTO); |
|
|
|
}else if(UserDemandConstant.VOLUNTEER.equals(serviceEntity.getServiceType())){ |
|
|
|
FinishResultDTO finishResultDTO = new FinishResultDTO(); |
|
|
|
finishResultDTO.setServerId(serviceEntity.getServerId()); |
|
|
|
finishResultDTO.setServiceType(serviceEntity.getServiceType()); |
|
|
|
finishResultDTO.setAwardPoint(demand.getAwardPoint()); |
|
|
|
finishResultDTO.setEvaluateFlag(true); |
|
|
|
if(StringUtils.isBlank(demand.getParentCode())||NumConstant.ZERO_STR.equals(demand.getParentCode())){ |
|
|
|
finishResultDTO.setFirstCategoryName(demandDictService.getCategoryName(demand.getCustomerId(),demand.getCategoryCode())); |
|
|
|
}else{ |
|
|
|
finishResultDTO.setFirstCategoryName(demandDictService.getCategoryName(demand.getCustomerId(),demand.getParentCode())); |
|
|
|
} |
|
|
|
String content = demand.getContent().length() > 100 ? demand.getContent().substring(0, 99) : demand.getContent(); |
|
|
|
finishResultDTO.setRemark(String.format(UserDemandConstant.GRANT_POINT_REMARK,demand.getDemandUserName(),content)); |
|
|
|
resultList.add(finishResultDTO) ; |
|
|
|
} |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
} |
|
|
|