@@ -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 ( ) ) ;
assessmentDataDA O . 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 ( ) ) ;
//存入未转码完成的map, vod回调的时候使用
redisUtilPool . hashSet ( RedisConstant . VIDEO_NOT_COMPLETE_CACHE , smallVideo . getVideoId ( ) , JSONObject . toJSONString ( smallVideoParam ) ) ;
}
}