Commit 9957bb62 authored by 赵啸非's avatar 赵啸非

更新评价统计计算

parent 429ba8ee
......@@ -294,6 +294,9 @@ public class DeclareServiceImpl extends AbstractCRUDServiceImpl<DeclareDao, Decl
}
declareFinImagesService.save(query.getDeclareFinImagesList());
}
staffService.updateAgentUserRecordNum(declareEntity.getAgentUserId(),context);
return Rest.ok("办结工作成功!");
}
}
\ No newline at end of file
package com.mortals.xhx.module.evaluation.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.declare.model.DeclareEntity;
import com.mortals.xhx.module.declare.service.DeclareService;
import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.BeanUtils;
import java.util.function.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -10,15 +18,31 @@ import com.mortals.xhx.module.evaluation.dao.EvaluationInfoDao;
import com.mortals.xhx.module.evaluation.model.EvaluationInfoEntity;
import com.mortals.xhx.module.evaluation.service.EvaluationInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
/**
* EvaluationInfoService
* 用户代办帮办评价 service实现
*
* @author zxfei
* @date 2025-04-27
*/
* EvaluationInfoService
* 用户代办帮办评价 service实现
*
* @author zxfei
* @date 2025-04-27
*/
@Service("evaluationInfoService")
@Slf4j
public class EvaluationInfoServiceImpl extends AbstractCRUDServiceImpl<EvaluationInfoDao, EvaluationInfoEntity, Long> implements EvaluationInfoService {
@Autowired
private DeclareService declareService;
@Autowired
private StaffService staffService;
@Override
protected void saveAfter(EvaluationInfoEntity entity, Context context) throws AppException {
//更新代办人累计评分
if(ObjectUtils.isEmpty(entity.getDeclareId())) return;
DeclareEntity declareEntity = declareService.get(entity.getDeclareId(), context);
if (ObjectUtils.isEmpty(declareEntity)) return;
staffService.updateAgentUserTotalScore(declareEntity.getAgentUserId(), context);
super.saveAfter(entity, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.staff.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.dao.StaffDao;
......@@ -13,4 +15,10 @@ import com.mortals.xhx.module.staff.dao.StaffDao;
public interface StaffService extends ICRUDService<StaffEntity,Long>{
StaffDao getDao();
Rest<Void> updateAgentUserRecordNum(Long agentUserId, Context context);
Rest<Void> updateAgentUserTotalScore(Long agentUserId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.staff.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.DeclareStatusEnum;
import com.mortals.xhx.module.declare.model.DeclareQuery;
import com.mortals.xhx.module.declare.service.DeclareService;
import com.mortals.xhx.module.evaluation.model.EvaluationInfoEntity;
import com.mortals.xhx.module.evaluation.model.EvaluationInfoQuery;
import com.mortals.xhx.module.evaluation.service.EvaluationInfoService;
import com.mortals.xhx.module.staff.model.StaffQuery;
import org.springframework.beans.BeanUtils;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -31,6 +41,11 @@ import org.springframework.util.ObjectUtils;
public class StaffServiceImpl extends AbstractCRUDServiceImpl<StaffDao, StaffEntity, Long> implements StaffService {
@Autowired
private UserService userService;
@Autowired
private DeclareService declareService;
@Autowired
private EvaluationInfoService evaluationInfoService;
@Override
......@@ -82,7 +97,7 @@ public class StaffServiceImpl extends AbstractCRUDServiceImpl<StaffDao, StaffEnt
protected void updateAfter(StaffEntity entity, Context context) throws AppException {
//更新用户
UserEntity userEntity = userService.get(entity.getUserId(), context);
if(!ObjectUtils.isEmpty(userEntity)){
if (!ObjectUtils.isEmpty(userEntity)) {
userEntity.setLoginName(entity.getLoginName());
String password = null;
try {
......@@ -100,4 +115,44 @@ public class StaffServiceImpl extends AbstractCRUDServiceImpl<StaffDao, StaffEnt
super.updateAfter(entity, context);
}
@Override
public Rest<Void> updateAgentUserRecordNum(Long agentUserId, Context context) {
StaffEntity staffEntity = this.selectOne(new StaffQuery().userId(agentUserId), context);
// StaffEntity staffEntity = this.get(agentUserId, context);
if (ObjectUtils.isEmpty(staffEntity)) throw new AppException("用户不存在");
DeclareQuery declareQuery = new DeclareQuery();
declareQuery.setAgentUserId(staffEntity.getUserId());
declareQuery.setDeclareStatus(DeclareStatusEnum.完结.getValue());
int count = declareService.count(declareQuery, context);
staffEntity.setTotalNum(count);
dao.update(staffEntity);
return Rest.ok();
}
@Override
public Rest<Void> updateAgentUserTotalScore(Long agentUserId, Context context) {
StaffEntity staffEntity = this.selectOne(new StaffQuery().userId(agentUserId), context);
if (ObjectUtils.isEmpty(staffEntity)) throw new AppException("用户不存在");
DeclareQuery declareQuery = new DeclareQuery();
declareQuery.setAgentUserId(agentUserId);
declareQuery.setDeclareStatus(DeclareStatusEnum.完结.getValue());
List<Long> declareIdList = declareService.find(declareQuery).stream().map(i -> i.getId()).collect(Collectors.toList());
if(!ObjectUtils.isEmpty(declareIdList)){
EvaluationInfoQuery evaluationInfoQuery = new EvaluationInfoQuery();
evaluationInfoQuery.setDeclareIdList(declareIdList);
int sum = (int)evaluationInfoService.find(evaluationInfoQuery, context)
.stream().collect(Collectors.summarizingInt(EvaluationInfoEntity::getScore)).getSum();
staffEntity.setTotalScore(sum);
dao.update(staffEntity);
}
return Rest.ok();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment