package com.gk.hotwork.Service.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gk.hotwork.Domain.Exception.BusinessException; import com.gk.hotwork.Domain.InspectionExpert; import com.gk.hotwork.Domain.SafetyInspectionElementA; import com.gk.hotwork.Domain.UserInfo; import com.gk.hotwork.Mapper.InspectionExpertGroupMapper; import com.gk.hotwork.Mapper.InspectionExpertMapper; import com.gk.hotwork.Mapper.SafetyInspectionElementAMapper; import com.gk.hotwork.Service.InspectionExpertService; import com.gk.hotwork.Service.SafetyInspectionElementAService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * @email 1603559716@qq.com * @author: zf * @date: 2023/7/19 * @time: 17:30 */ @Service public class InspectionExpertServiceImpl extends ServiceImpl implements InspectionExpertService { @Autowired private InspectionExpertMapper inspectionExpertMapper; @Override public void setLeader(InspectionExpert inspectionExpert, UserInfo user) { requireVertify(inspectionExpert); inspectionExpertMapper.updateById(inspectionExpert); } /** * 根据专家组id获取专家成员 * @param expertGroupId * @return */ public List getByGroupId(Long expertGroupId){ List list = inspectionExpertMapper.selectList(new LambdaQueryWrapper().eq(InspectionExpert::getExpertGropId, expertGroupId)); return list; } /** * 根据检查清单id获取专家成员 * @param selfInspectionId * @return */ public List getBySelfInspectionId(Long selfInspectionId){ List list = inspectionExpertMapper.selectList(new LambdaQueryWrapper() .eq(InspectionExpert::getSelfInspectionId, selfInspectionId)); return list; } public List getLeaderList(Long expertGroupId){ List list = inspectionExpertMapper .selectList(new LambdaQueryWrapper() .eq(InspectionExpert::getExpertGropId, expertGroupId) .eq(InspectionExpert::getIsLeader,true)); return list; } private void requireVertify(InspectionExpert inspectionExpert) { if(inspectionExpert.getId() == null){ throw new BusinessException("专家主键不可为空"); } if(inspectionExpert.getIsLeader() == null){ throw new BusinessException("专家成员类型不可为空"); } if(inspectionExpert.getExpertGropId() == null){ throw new BusinessException("专家组id不可为空"); } List leaderList = this.getLeaderList(inspectionExpert.getExpertGropId()); if(leaderList.size() > 0){ InspectionExpert expert = leaderList.get(0); if(expert.getId().equals(inspectionExpert.getId())){ if(expert.getIsLeader() == true){ throw new BusinessException("该专家成员已是组长"); } }else { throw new BusinessException("该专家组已有组长"); } } } }