diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AutoEvaluateDemandFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AutoEvaluateDemandFormDTO.java new file mode 100644 index 0000000000..fd716562ae --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/AutoEvaluateDemandFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 自动评价参数 + */ +@Data +public class AutoEvaluateDemandFormDTO implements Serializable { + private String customerId; + private Integer exceedDay; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java index 8ea54cc72f..77f86a5f43 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/FinishResultDTO.java @@ -32,4 +32,5 @@ public class FinishResultDTO implements Serializable { private String remark; private String firstCategoryName; private String categoryCode; + private String demandRecId; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 9dffeb784e..d4f3c8c92d 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.ActInfoDTO; import com.epmet.dto.VolunteerInfoDTO; +import com.epmet.dto.form.AutoEvaluateDemandFormDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.form.resi.VolunteerCommonFormDTO; @@ -73,5 +74,5 @@ public interface EpmetHeartOpenFeignClient { * @return */ @PostMapping("/heart/residemand/autoevaluate") - Result AutoEvaluateDemand(); + Result AutoEvaluateDemand(@RequestBody AutoEvaluateDemandFormDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java index f4e19d0906..eed34f0116 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.ActInfoDTO; import com.epmet.dto.VolunteerInfoDTO; +import com.epmet.dto.form.AutoEvaluateDemandFormDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.form.resi.VolunteerCommonFormDTO; @@ -67,7 +68,7 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli * @return */ @Override - public Result AutoEvaluateDemand() { - return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "autoEvaluate"); + public Result AutoEvaluateDemand(AutoEvaluateDemandFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "autoEvaluate",formDTO); } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java index beb25ce050..a18b304aeb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/UserDemandConstant.java @@ -32,7 +32,7 @@ public interface UserDemandConstant { */ String STAFF="staff"; String RESI="resi"; - + String SYS="sys"; /** * 创建需求:create;撤销需求:cancel;指派:assign;接单:take_order;完成:finish;;评价:evaluate @@ -78,4 +78,8 @@ public interface UserDemandConstant { String DEMAND_SERVER="server"; String GRANT_POINT_REMARK="完成了%s的需求:%s"; + + String DEFAULT_EVALUATE_REMARK="此用户没有填写内容,由系统默认评分"; + // 完成结果:已解决 resolved,未解决 unresolved + String RESOLVED="resolved"; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java index fbdbc7afca..5b8417ad82 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java @@ -14,6 +14,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.SystemMessageType; import com.epmet.constant.UserDemandConstant; +import com.epmet.dto.form.AutoEvaluateDemandFormDTO; import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.form.demand.*; import com.epmet.dto.result.demand.*; @@ -251,8 +252,8 @@ public class ResiDemandController { * @return */ @PostMapping("autoevaluate") - public Result autoEvaluate(){ - icUserDemandRecService.autoEvaluate(); + public Result autoEvaluate(@RequestBody AutoEvaluateDemandFormDTO formDTO){ + icUserDemandRecService.autoEvaluate(formDTO); return new Result(); } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java index 6d11009c14..6ab67eed69 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java @@ -113,5 +113,7 @@ public interface IcUserDemandRecDao extends BaseDao { @Param("type")String type, @Param("demandUserId")String demandUserId); - List selectNoEvaluate(); + List selectNoEvaluate(@Param("customerId")String customerId,@Param("exceedDay")Integer exceedDay); + + int evaluate(@Param("demandRecId")String demandRecId, @Param("finishResult")String finishResult); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcUserDemandSatisfactionEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcUserDemandSatisfactionEntity.java index ab17c5d738..819fb8239d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcUserDemandSatisfactionEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcUserDemandSatisfactionEntity.java @@ -50,7 +50,7 @@ public class IcUserDemandSatisfactionEntity extends BaseEpmetEntity { private String demandRecId; /** - * 当前操作用户属于哪个端?工作端:staff;居民端:resi + * 当前操作用户属于哪个端?工作端:staff;居民端:resi;系统操作:sys */ private String userType; diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java index 57e5192dc8..093eb4e011 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java @@ -20,6 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcUserDemandRecDTO; +import com.epmet.dto.form.AutoEvaluateDemandFormDTO; import com.epmet.dto.form.demand.*; import com.epmet.dto.result.demand.*; import com.epmet.entity.IcUserDemandRecEntity; @@ -217,5 +218,5 @@ public interface IcUserDemandRecService extends BaseService { + List evaluateDemandAuto(String customerId, Integer exceedDay); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index f8a40d37c9..41969b7cdc 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -21,10 +21,13 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.DictTypeEnum; +import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; @@ -37,6 +40,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ReadFlagConstant; +import com.epmet.constant.SystemMessageType; import com.epmet.constant.UserDemandConstant; import com.epmet.constant.UserMessageTypeConstant; import com.epmet.dao.IcUserDemandOperateLogDao; @@ -106,6 +110,11 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl list=baseDao.selectNoEvaluate(); - + public void autoEvaluate(AutoEvaluateDemandFormDTO formDTO) { + if (null == formDTO.getExceedDay()) { + formDTO.setExceedDay(NumConstant.SEVEN); + } + List list=icUserDemandSatisfactionService.evaluateDemandAuto(formDTO.getCustomerId(),formDTO.getExceedDay()); + if(CollectionUtils.isNotEmpty(list)){ + List actPointEventMsgList = new ArrayList<>(); + list.forEach(finishResultDTO->{ + BasePointEventMsg actPointEventMsg = new BasePointEventMsg(); + actPointEventMsg.setCustomerId(formDTO.getCustomerId()); + actPointEventMsg.setSourceType(MqConstant.SOURCE_TYPE_DEMAND); + actPointEventMsg.setSourceId(finishResultDTO.getDemandRecId()); + actPointEventMsg.setUserId(finishResultDTO.getServerId()); + actPointEventMsg.setActionFlag(MqConstant.PLUS); + actPointEventMsg.setIsCommon(false); + actPointEventMsg.setRemark(finishResultDTO.getRemark()); + actPointEventMsg.setEventTag(EventEnum.FINISH_USER_DEMAND.getEventTag()); + actPointEventMsg.setEventClass(EventEnum.FINISH_USER_DEMAND.getEventClass()); + actPointEventMsg.setEventName(finishResultDTO.getFirstCategoryName()); + actPointEventMsg.setObjectId(finishResultDTO.getCategoryCode()); + actPointEventMsg.setPoint(finishResultDTO.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.error(String.format("需求评价完成:demandRecId:%s,给志愿者发放积分失败", JSON.toJSONString(sendMsgForm))); + } + } } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandSatisfactionServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandSatisfactionServiceImpl.java new file mode 100644 index 0000000000..f2b91050a0 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandSatisfactionServiceImpl.java @@ -0,0 +1,109 @@ +package com.epmet.service.impl; + +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.NumConstant; +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.entity.IcUserDemandOperateLogEntity; +import com.epmet.entity.IcUserDemandSatisfactionEntity; +import com.epmet.entity.IcUserDemandServiceEntity; +import com.epmet.service.IcPartyUnitService; +import com.epmet.service.IcResiDemandDictService; +import com.epmet.service.IcUserDemandSatisfactionService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +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; + +public class IcUserDemandSatisfactionServiceImpl extends BaseServiceImpl implements IcUserDemandSatisfactionService { + + @Autowired + private IcUserDemandRecDao icUserDemandRecDao; + @Autowired + private IcUserDemandOperateLogDao operateLogDao; + @Autowired + private IcUserDemandServiceDao demandServiceDao; + @Autowired + private IcResiDemandDictService demandDictService; + @Autowired + private IcPartyUnitService icPartyUnitService; + + @Transactional(rollbackFor = Exception.class) + @Override + public List evaluateDemandAuto(String customerId, Integer exceedDay) { + // 查询完成后,超过7天未评价的记录 + List list=icUserDemandRecDao.selectNoEvaluate(customerId,exceedDay); + if(CollectionUtils.isEmpty(list)){ + return Collections.EMPTY_LIST; + } + List resultList=new ArrayList<>(); + Date nowDate=new Date(); + for(IcUserDemandRecDTO demand:list){ + + // 1、插入评价得分记录 + IcUserDemandSatisfactionEntity satisfactionEntity = new IcUserDemandSatisfactionEntity(); + satisfactionEntity.setCustomerId(demand.getCustomerId()); + satisfactionEntity.setDemandRecId(demand.getId()); + satisfactionEntity.setEvaluateTime(nowDate); + satisfactionEntity.setUserType(UserDemandConstant.SYS); + satisfactionEntity.setUserId(Constant.APP_USER_FLAG); + satisfactionEntity.setScore(new BigDecimal(NumConstant.FIVE_STR)); + satisfactionEntity.setRemark(UserDemandConstant.DEFAULT_EVALUATE_REMARK); + baseDao.insert(satisfactionEntity); + + // 2、插入评价操作日志 + IcUserDemandOperateLogEntity evaluateEntity = new IcUserDemandOperateLogEntity(); + evaluateEntity.setCustomerId(demand.getCustomerId()); + evaluateEntity.setDemandRecId(demand.getId()); + evaluateEntity.setUserType(UserDemandConstant.SYS); + evaluateEntity.setUserId(Constant.APP_USER_FLAG); + evaluateEntity.setActionCode(UserDemandConstant.EVALUATE); + evaluateEntity.setOperateTime(nowDate); + operateLogDao.insert(evaluateEntity); + + // 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; + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml index dbeb852712..bf1ab18831 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml @@ -511,6 +511,18 @@ AND r.EVALUATE_FLAG = '0' and s.SERVICE_START_TIME is not NULL and s.SERVICE_END_TIME is not null - and timestampdiff(day,s.UPDATED_TIME,now()) >7 + and timestampdiff(day,s.UPDATED_TIME,now()) > #{exceedDay} + + AND r.customer_id =#{customerId} + + + + + update ic_user_demand_rec + set EVALUATE_FLAG='1', + FINISH_RESULT=#{finishResult}, + UPDATED_TIME=NOW() + where id=#{demandRecId} + \ No newline at end of file diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/AutoEvaluateDemandTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/AutoEvaluateDemandTask.java index 1f1f2e74f9..c2e21696ab 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/AutoEvaluateDemandTask.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/AutoEvaluateDemandTask.java @@ -1,9 +1,12 @@ package com.epmet.task; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AutoEvaluateDemandFormDTO; import com.epmet.feign.EpmetHeartOpenFeignClient; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -19,6 +22,10 @@ public class AutoEvaluateDemandTask implements ITask { @Override public void run(String params) { - Result result = heartOpenFeignClient.AutoEvaluateDemand(); + AutoEvaluateDemandFormDTO formDTO = new AutoEvaluateDemandFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, AutoEvaluateDemandFormDTO.class); + } + Result result = heartOpenFeignClient.AutoEvaluateDemand(formDTO); } }