PCTrainingExperienceController

This commit is contained in:
guohb
2024-04-07 17:01:45 +08:00
parent 84efb14e53
commit 257aa09005
7 changed files with 72 additions and 6 deletions

View File

@@ -1,16 +1,14 @@
package com.cool.store.service.impl;
import com.cool.store.dao.LineInfoDAO;
import com.cool.store.entity.LeaseBaseInfoDO;
import com.cool.store.entity.LineInfoDO;
import com.cool.store.entity.*;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.ExperienceStatusEnum;
import com.cool.store.enums.WorkflowSubStageEnum;
import com.cool.store.enums.WorkflowSubStageStatusEnum;
import com.cool.store.enums.*;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.LineInfoMapper;
import com.cool.store.mapper.TrainingExperienceMapper;
import com.cool.store.mapper.*;
import com.cool.store.request.TrainingExperienceDistributionRequest;
import com.cool.store.service.TrainingExperienceService;
import lombok.extern.slf4j.Slf4j;
@@ -19,7 +17,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.annotation.Tainted;
import java.util.Objects;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import static com.cool.store.enums.ErrorCodeEnum.INTERVIEW_LINE_ID_IS_NULL;
@@ -35,6 +35,22 @@ public class TrainingExperienceServiceImpl extends LineFlowService implements Tr
@Resource
LineInfoDAO lineInfoDAO;
@Resource
SysRoleMapper sysRoleMapper;
@Resource
EnterpriseUserMapper enterpriseUserMapper;
@Resource
RegionMapper regionMapper;
@Resource
UserAuthMappingMapper userAuthMappingMapper;
@Resource
EnterpriseUserRoleMapper enterpriseUserRoleMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean distribution(TrainingExperienceDistributionRequest request) {
@@ -45,6 +61,17 @@ public class TrainingExperienceServiceImpl extends LineFlowService implements Tr
throw new ServiceException(INTERVIEW_LINE_ID_IS_NULL);
}
LeaseBaseInfoDO leaseBaseInfoDO = request.toLeaseBaseInfoDO();
Date currentDate = new Date();
if (request.getExperienceStartTime().compareTo(request.getExperienceEndTime()) >= 0){
throw new ServiceException("结束时间不能早于开始时间");
}
if (currentDate.before(request.getExperienceStartTime())){
leaseBaseInfoDO.setExperienceStatus(WorkflowSubStageStatusEnum.STORE_EXPERIENCE_85.getCode());
}else if (currentDate.after(request.getExperienceStartTime()) || currentDate.before(request.getExperienceEndTime())){
leaseBaseInfoDO.setExperienceStatus(WorkflowSubStageStatusEnum.STORE_EXPERIENCE_90.getCode());
}else {
throw new ServiceException("时间");
}
trainingExperienceMapper.insert(leaseBaseInfoDO);
LineInfoDO lineInfoDO = new LineInfoDO();
lineInfoDO.setWorkflowSubStage(WorkflowSubStageEnum.STORE_EXPERIENCE.getCode());
@@ -71,7 +98,20 @@ public class TrainingExperienceServiceImpl extends LineFlowService implements Tr
@Override
public LeaseBaseInfoDO getTrainingExperience(Long lineId) {
String eid = "e17cd2dc350541df8a8b0af9bd27f77d";
List<String> roleNames = new ArrayList<>();
roleNames.add("加盟店店长");
roleNames.add("加盟店储备店长");
LeaseBaseInfoDO leaseBaseInfoDO = trainingExperienceMapper.selectByLineId(lineId);
String storeId = leaseBaseInfoDO.getStoreId();
RegionDO regionDO = regionMapper.getRegionByStoreId(storeId);
List<SysRoleDO> xfStoreManager = sysRoleMapper.getXFStoreManager(roleNames);
List<Long> roleIds = xfStoreManager.stream().map(SysRoleDO::getId).collect(Collectors.toList());
List<String> userIdsByRoleIdList = enterpriseUserRoleMapper.getUserIdsByRoleIdList(roleIds);
List<EnterpriseUserDO> userInfoByUserIds = enterpriseUserMapper.getUserInfoByUserIds(userIdsByRoleIdList);
String storeManagers = userInfoByUserIds.stream().map(EnterpriseUserDO::getName).collect(Collectors.toList()).toString();
leaseBaseInfoDO.setStoreManager(storeManagers);
return leaseBaseInfoDO;
}