拉取考试分数

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

@@ -0,0 +1,46 @@
package com.cool.store.enums;
import org.apache.commons.lang3.StringUtils;
/**
* @author Fun Li
* @version 1.0
* @date 2023/7/19 17:55
*/
public enum ExamStatusEnum {
NOT_START(0, "未开始"),
PASS(1, "通过"),
NOT_PASS(2, "不通过");
private Integer code;
private String desc;
ExamStatusEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static Integer matchCodeByDesc(String desc) {
if(StringUtils.isBlank(desc)){
return null;
}
for (ExamStatusEnum statusEnum : ExamStatusEnum.values()) {
if (statusEnum.getDesc().equals(desc)) {
return statusEnum.code;
}
}
return null;
}
}

View File

@@ -66,6 +66,12 @@ public enum UploadTypeEnum {
* 陈列检查内容提交
*/
TB_DISPLAY_TABLE_DATA_CONTENT(14),
/**
* 考核數據
*/
ASSESSMENT_DATA_CONTENT(201),
;

View File

@@ -80,5 +80,9 @@ public class AssessmentDataDAO {
assessmentDataMapper.batchInsert(assessmentDataDOList);
}
public void batchInsertOrUpdate(List<AssessmentDataDO> assessmentDataDOList) {
assessmentDataMapper.batchInsertOrUpdate(assessmentDataDOList);
}
}

View File

@@ -14,4 +14,6 @@ public interface AssessmentDataMapper extends Mapper<AssessmentDataDO> {
Boolean deleteByShopId(@Param("shopId") Long shopId);
Integer batchInsert(@Param("assessmentDataList") List<AssessmentDataDO> assessmentDataList);
Integer batchInsertOrUpdate(@Param("assessmentDataList") List<AssessmentDataDO> assessmentDataList);
}

View File

@@ -23,6 +23,34 @@
#{item.assessmentUserId})
</foreach>
</insert>
<insert id="batchInsertOrUpdate">
insert into xfsg_assessment_data
(
template_id,
shop_id,
assessment_user_id,
qualified,
score,
reason,
comments,
picture,
video
) values
<foreach collection="assessmentDataList" item="item" separator=",">
( #{item.templateId},
#{item.shopId},
#{item.assessmentUserId},
#{item.qualified},
#{item.score},
#{item.reason},
#{item.comments},
#{item.picture},
#{item.video}
)
</foreach>
ON DUPLICATE KEY UPDATE qualified=values(qualified), score=values(score), reason=values(reason)
, comments=values(comments), picture=values(picture), video=values(video)
</insert>
<update id="batchUpdate">
update xfsg_assessment_data
<set>

View File

@@ -142,6 +142,7 @@
u.shop_id as shopId,
s.shop_name as shopName,
u.id_card as idCard,
u.register_time as registerTime,
e.id as employeeTrainingId,
e.training_store_id as trainingStoreId,
e.training_teacher_user_id as trainingTeacherUserId,

View File

@@ -0,0 +1,36 @@
package com.cool.store.dto;
import lombok.Data;
/**
* @author byd
* @date 2024-05-08 14:07
*/
@Data
public class StaffExamInfoDTO {
/**
* 考试名称
*/
private String examName;
/**
* 姓名
*/
private String staffName;
/**
* 部门
*/
private String deptPath;
/**
* 员工编号
*/
private String staffNumber;
/**
* 考试结果
*/
private String examResult;
/**
* 考试分数
*/
private String examScore;
}

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;