拉取考试分数

This commit is contained in:
bianyadong
2024-05-08 15:16:20 +08:00
parent a2e999444a
commit 58a05fd8cf
11 changed files with 270 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
package com.cool.store.service;
import com.cool.store.dto.StaffExamInfoDTO;
import com.cool.store.dto.ehr.FranchiseeInfoDTO;
import com.cool.store.dto.ehr.StaffBaseInfoDTO;
@@ -22,5 +23,10 @@ public interface XfsgEhrService {
FranchiseeInfoDTO getFranchiseeInfoByFrId(String frId);
/**
* 员工考试信息接口
* @param staffNumber
* @return
*/
StaffExamInfoDTO getUserExamInfo(String staffNumber);
}

View File

@@ -1,20 +1,30 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.constants.RedisConstant;
import com.cool.store.dao.*;
import com.cool.store.dto.SmallVideoDTO;
import com.cool.store.dto.SmallVideoInfoDTO;
import com.cool.store.dto.StaffExamInfoDTO;
import com.cool.store.entity.*;
import com.cool.store.enums.AssessmentTemplateType;
import com.cool.store.enums.ExamStatusEnum;
import com.cool.store.enums.video.ResourceStatusEnum;
import com.cool.store.enums.video.UploadTypeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.request.*;
import com.cool.store.service.EmployeeTrainingService;
import com.cool.store.service.RegionService;
import com.cool.store.service.SysRoleService;
import com.cool.store.service.UserAuthMappingService;
import com.cool.store.service.*;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.poi.DateUtils;
import com.cool.store.utils.vod.SmallVideoParam;
import com.cool.store.vo.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +73,11 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
@Resource
private AssessmentDataDAO assessmentDataDAO;
@Resource
private RedisUtilPool redisUtilPool;
@Resource
private XfsgEhrService xfsgEhrService;
@Override
public PageInfo<EmployeeTrainingVO> employeeTrainingList(String userId, EmployeeTrainingRequest request) {
@@ -114,6 +129,8 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
EmployeeTrainingDO employeeTrainingDO = employeeTrainingDAO.selectByUserDetailId(id);
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.getUserInfoByThirdOaUniqueFlag(tempUserDetailDO.getIdCard());
EmployeeTrainingDetailVO employeeTrainingVO = new EmployeeTrainingDetailVO();
employeeTrainingVO.setId(employeeTrainingDO.getId());
employeeTrainingVO.setRegionId(employeeTrainingDO.getRegionId());
@@ -133,6 +150,19 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
employeeTrainingVO.setAssessmentTotalNum(employeeTrainingDO.getAssessmentTotalNum());
employeeTrainingVO.setTheoreticalExamStatus(employeeTrainingDO.getTheoreticalExamStatus());
employeeTrainingVO.setTheoreticalExamScore(employeeTrainingDO.getTheoreticalExamScore());
//查询理论分支并更新
StaffExamInfoDTO staffExamInfoDTO = xfsgEhrService.getUserExamInfo(enterpriseUserDO.getJobnumber());
if (staffExamInfoDTO != null && StringUtils.isNotBlank(staffExamInfoDTO.getExamResult())
&& StringUtils.isNotBlank(staffExamInfoDTO.getExamScore())) {
employeeTrainingVO.setTheoreticalExamScore(StringUtils.isNotBlank(staffExamInfoDTO.getExamScore()) ? Integer.valueOf(staffExamInfoDTO.getExamScore()) : null);
employeeTrainingVO.setTheoreticalExamStatus(ExamStatusEnum.matchCodeByDesc(staffExamInfoDTO.getExamResult()));
if(!employeeTrainingVO.getTheoreticalExamScore().equals(employeeTrainingDO.getTheoreticalExamScore())
|| !employeeTrainingVO.getTheoreticalExamStatus().equals(employeeTrainingDO.getTheoreticalExamStatus())){
employeeTrainingDO.setTheoreticalExamScore(employeeTrainingVO.getTheoreticalExamScore());
employeeTrainingDO.setTheoreticalExamStatus(employeeTrainingVO.getTheoreticalExamStatus());
employeeTrainingDAO.updateByPrimaryKeySelective(employeeTrainingDO);
}
}
employeeTrainingVO.setPracticalExamStatus(employeeTrainingDO.getPracticalExamStatus());
employeeTrainingVO.setPracticalExamScore(employeeTrainingDO.getPracticalExamScore());
employeeTrainingVO.setEstimatedAssessmentTime(employeeTrainingDO.getEstimatedAssessmentTime());
@@ -226,7 +256,7 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
@Override
public List<EmployeeTrainingVO> trainerUserList(String userId, Integer status) {
List<EmployeeTrainingVO> list = employeeTrainingDAO.trainingListByShopId(null, userId, status);
if(CollectionUtils.isEmpty(list)){
if (CollectionUtils.isEmpty(list)) {
return list;
}
List<String> storeIdList = list.stream().map(EmployeeTrainingVO::getTrainingStoreId).collect(Collectors.toList());
@@ -266,11 +296,11 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
employeeUserTrainingVO.setRegionId(tempUserDetailDO.getRegionId());
employeeUserTrainingVO.setShopId(tempUserDetailDO.getShopId());
ShopInfoDO shopInfoDO = shopInfoDAO.getShopInfo(tempUserDetailDO.getShopId());
if(shopInfoDO != null){
if (shopInfoDO != null) {
employeeUserTrainingVO.setShopName(shopInfoDO.getShopName());
}
StoreDO storeDO = storeDAO.getByStoreId(employeeTrainingDO.getTrainingStoreId());
if(storeDO != null){
if (storeDO != null) {
employeeUserTrainingVO.setTrainingStoreName(storeDO.getStoreName());
}
@@ -402,8 +432,25 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
assessmentUserTrainingVO.setShopId(tempUserDetailDO.getShopId());
assessmentUserTrainingVO.setTheoreticalExamStatus(employeeTrainingDO.getTheoreticalExamStatus());
assessmentUserTrainingVO.setTheoreticalExamScore(employeeTrainingDO.getTheoreticalExamScore());
//查询理论分支并更新
StaffExamInfoDTO staffExamInfoDTO = xfsgEhrService.getUserExamInfo(enterpriseUserDO.getJobnumber());
if (staffExamInfoDTO != null && StringUtils.isNotBlank(staffExamInfoDTO.getExamResult())
&& StringUtils.isNotBlank(staffExamInfoDTO.getExamScore())) {
assessmentUserTrainingVO.setTheoreticalExamScore(StringUtils.isNotBlank(staffExamInfoDTO.getExamScore()) ? Integer.valueOf(staffExamInfoDTO.getExamScore()) : null);
assessmentUserTrainingVO.setTheoreticalExamStatus(ExamStatusEnum.matchCodeByDesc(staffExamInfoDTO.getExamResult()));
if(!assessmentUserTrainingVO.getTheoreticalExamScore().equals(employeeTrainingDO.getTheoreticalExamScore())
|| !assessmentUserTrainingVO.getTheoreticalExamStatus().equals(employeeTrainingDO.getTheoreticalExamStatus())){
employeeTrainingDO.setTheoreticalExamScore(assessmentUserTrainingVO.getTheoreticalExamScore());
employeeTrainingDO.setTheoreticalExamStatus(assessmentUserTrainingVO.getTheoreticalExamStatus());
employeeTrainingDAO.updateByPrimaryKeySelective(employeeTrainingDO);
}
}
assessmentUserTrainingVO.setPracticalExamScore(employeeTrainingDO.getPracticalExamScore());
assessmentUserTrainingVO.setPracticalExamStatus(employeeTrainingDO.getPracticalExamStatus());
assessmentUserTrainingVO.setId(tempUserDetailDO.getId());
assessmentUserTrainingVO.setRegionId(tempUserDetailDO.getRegionId());
ShopInfoDO shopInfoDO = shopInfoDAO.getShopInfo(employeeTrainingDO.getShopId());
if (shopInfoDO != null) {
assessmentUserTrainingVO.setShopName(shopInfoDO.getShopName());
@@ -473,6 +520,12 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.getUserInfoByThirdOaUniqueFlag(tempUserDetailDO.getIdCard());
String userId = enterpriseUserDO.getUserId();
AtomicReference<Long> totalScore = new AtomicReference<>(0L);
List<AssessmentTemplateDO> assessmentTemplateDOList = assessmentTemplateDAO.listByType(AssessmentTemplateType.STORE_MANAGER.getCode());
List<Long> templateIdList = assessmentTemplateDOList.stream().map(AssessmentTemplateDO::getId).collect(Collectors.toList());
List<AssessmentDataDO> assessmentDataDOList = assessmentDataDAO.selectList(tempUserDetailDO.getShopId(), userId, templateIdList);
request.getList().forEach(item -> {
AssessmentDataDO assessmentDataDO = null;
totalScore.set(totalScore.get() + item.getScore());
@@ -484,7 +537,8 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
if (assessmentDataDO != null) {
assessmentDataDO.setScore(item.getScore());
assessmentDataDO.setComments(item.getComments());
assessmentDataDAO.updateByPrimaryKeySelective(assessmentDataDO);
assessmentDataDO.setPicture(item.getPicture());
assessmentDataDO.setVideo(item.getVideo());
} else {
assessmentDataDO = new AssessmentDataDO();
assessmentDataDO.setTemplateId(item.getTemplateId());
@@ -492,9 +546,14 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
assessmentDataDO.setComments(item.getComments());
assessmentDataDO.setScore(item.getScore());
assessmentDataDO.setAssessmentUserId(employeeTrainingDO.getXfsgUserDetailId().toString());
assessmentDataDO.setPicture(item.getPicture());
assessmentDataDO.setVideo(item.getVideo());
assessmentDataDAO.insertSelective(assessmentDataDO);
}
assessmentDataDOList.add(assessmentDataDO);
});
checkVideoHandel(assessmentDataDOList);
assessmentDataDAO.batchInsertOrUpdate(assessmentDataDOList);
employeeTrainingDO.setPracticalAssessmentUserId(userId);
employeeTrainingDO.setPracticalExamScore(totalScore.get().intValue());
@@ -513,4 +572,47 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
}
employeeTrainingDAO.updateByPrimaryKeySelective(employeeTrainingDO);
}
private void checkVideoHandel(List<AssessmentDataDO> assessmentDataDOList) {
if (CollectionUtils.isEmpty(assessmentDataDOList)) {
return;
}
for (AssessmentDataDO assessmentDataDO : assessmentDataDOList) {
SmallVideoInfoDTO smallVideoInfo = JSONObject.parseObject(assessmentDataDO.getVideo(), SmallVideoInfoDTO.class);
if (smallVideoInfo != null && CollectionUtils.isNotEmpty(smallVideoInfo.getVideoList())) {
String callbackCache;
SmallVideoDTO smallVideoCache;
SmallVideoParam smallVideoParam;
for (SmallVideoDTO smallVideo : smallVideoInfo.getVideoList()) {
//如果转码完成
if (smallVideo.getStatus() != null && smallVideo.getStatus() >= ResourceStatusEnum.TRANSCODE_FINISH.getValue()) {
continue;
}
callbackCache = redisUtilPool.getString(RedisConstant.VIDEO_CALLBACK_CACHE + smallVideo.getVideoId());
if (StringUtils.isNotBlank(callbackCache)) {
smallVideoCache = JSONObject.parseObject(callbackCache, SmallVideoDTO.class);
if (smallVideoCache != null && smallVideoCache.getStatus() != null && smallVideoCache.getStatus() >= 3) {
BeanUtils.copyProperties(smallVideoCache, smallVideo);
} else {
smallVideoParam = new SmallVideoParam();
setNotCompleteCache(smallVideoParam, smallVideo, assessmentDataDO.getId());
}
} else {
smallVideoParam = new SmallVideoParam();
setNotCompleteCache(smallVideoParam, smallVideo, assessmentDataDO.getId());
}
}
assessmentDataDO.setVideo(JSONObject.toJSONString(smallVideoInfo));
}
}
}
public void setNotCompleteCache(SmallVideoParam smallVideoParam, SmallVideoDTO smallVideo, Long businessId) {
smallVideoParam.setVideoId(smallVideo.getVideoId());
smallVideoParam.setUploadType(UploadTypeEnum.ASSESSMENT_DATA_CONTENT.getValue());
smallVideoParam.setBusinessId(businessId);
smallVideoParam.setUploadTime(new Date());
//存入未转码完成的mapvod回调的时候使用
redisUtilPool.hashSet(RedisConstant.VIDEO_NOT_COMPLETE_CACHE, smallVideo.getVideoId(), JSONObject.toJSONString(smallVideoParam));
}
}

View File

@@ -2,6 +2,7 @@ package com.cool.store.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.StaffExamInfoDTO;
import com.cool.store.dto.ehr.FranchiseeInfoDTO;
import com.cool.store.dto.ehr.StaffBaseInfoDTO;
import com.cool.store.mq.util.HttpRestTemplateService;
@@ -18,6 +19,7 @@ import java.util.Map;
/**
* describe: 鲜丰水果api
*
* @author wxp
* @date 2024/04/28
*/
@@ -80,4 +82,29 @@ public class XfsgEhrServiceImpl implements XfsgEhrService {
requestMap.put("signature", signature);
}
@Override
public StaffExamInfoDTO getUserExamInfo(String staffNumber) {
Map<String, Object> requestMap = new HashMap<>();
fillSignatureInfo(requestMap);
requestMap.put("staffNumber", staffNumber);
String url = xfsgUrl + Constants.GET_USER_EXAM_INFO;
try {
JSONObject result = httpRestTemplateService.getForObject(url, JSONObject.class, requestMap);
Integer code = result.getInteger("code");
if (code != 0) {
log.info("xfsg#getUserExamInfo,staffNumber:{},请求失败", staffNumber);
return null;
}
JSONObject data = result.getJSONObject("data");
if (data == null) {
log.info("xfsg#getUserExamInfo,staffNumber:{},返回值data为空", staffNumber);
return null;
}
return JSON.parseObject(data.toJSONString(), StaffExamInfoDTO.class);
} catch (Exception e) {
log.info("xfsg#getUserExamInfo,staffNumber:{},Exception:", staffNumber, e);
}
return null;
}
}

View File

@@ -185,6 +185,9 @@ public class Constants
// 加盟商信息数据接口
public static final String GET_FRANCHISEE_INFO_BY_CODE = "/api/kdz/franchisee/get-info";
// 员工云学堂考核结果
public static final String GET_USER_EXAM_INFO = "/api/kdz/get-user-exam-info";
public static final Integer ZERO_INTEGER = 0;