| | |
| | | package com.kidgrow.usercenter.service.impl; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.model.SysOrganization; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import com.kidgrow.usercenter.model.SysDepartment; |
| | | import com.kidgrow.usercenter.mapper.SysDepartmentMapper; |
| | | import com.kidgrow.usercenter.model.SysDepartment; |
| | | import com.kidgrow.usercenter.model.SysHospital; |
| | | import com.kidgrow.usercenter.service.ISysDepartmentService; |
| | | import com.kidgrow.usercenter.service.ISysHospitalService; |
| | | import com.kidgrow.usercenter.service.ISysOrganizationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class SysDepartmentServiceImpl extends SuperServiceImpl<SysDepartmentMapper, SysDepartment> implements ISysDepartmentService { |
| | | |
| | | @Autowired |
| | | private ISysOrganizationService iSysOrganizationService; |
| | | @Autowired |
| | | private ISysHospitalService iSysHospitalService; |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | |
| | | public SysDepartment findByObject(SysDepartment sysDepartment){ |
| | | return baseMapper.findByObject(sysDepartment); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updatePay(Long departmentId, boolean isPay) { |
| | | return baseMapper.updatePay(departmentId,isPay); |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody findAll(Map<String, Object> params) { |
| | | return ResultBody.ok().data(baseMapper.selectByMap(params)); |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody findListByHospitalId(Map<String, Object> params) { |
| | | //查询组织 |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | List<SysDepartment> sysDepartments=new ArrayList<>(); |
| | | SysHospital byId = iSysHospitalService.getById(id); |
| | | if(byId!=null){ |
| | | params=new HashMap<>(); |
| | | params.put("org_parent_id",byId.getOrgId()); |
| | | List<SysOrganization> sysOrganizations = iSysOrganizationService.listByMap(params); |
| | | if (sysOrganizations.size()>0) { |
| | | List<Long> collect = sysOrganizations.stream().map(e -> e.getId()).collect(Collectors.toList()); |
| | | QueryWrapper<SysDepartment> queryWrapper=new QueryWrapper(); |
| | | queryWrapper.in("org_id",collect ); |
| | | sysDepartments= baseMapper.selectList(queryWrapper); |
| | | } |
| | | } |
| | | return ResultBody.ok().data(sysDepartments); |
| | | } |
| | | |
| | | @Override |
| | | public String checkDepartmentName(Long hosId, String departmentName) { |
| | | String departName=baseMapper.checkDepartmentName(hosId,departmentName); |
| | | return departName; |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody getHealth(SysDepartment sysDepartment) { |
| | | SysDepartment department = baseMapper.selectById(sysDepartment.getId()); |
| | | if(department==null){ |
| | | return ResultBody.failed("该数据为空"); |
| | | }else { |
| | | if(department.getIsHealth()){ |
| | | Date now= new Date(); |
| | | if(now.getTime()<department.getHealthBeginTime().getTime()){ |
| | | department.setIsHealth(false); |
| | | return ResultBody.ok().data(department); |
| | | }else if(department.getHealthBeginTime().getTime()<=now.getTime()&&now.getTime()<=department.getHealthEndTime().getTime()){ |
| | | return ResultBody.ok().data(department); |
| | | }else if(department.getHealthEndTime().getTime()<now.getTime()) { |
| | | department.setIsHealth(false); |
| | | return ResultBody.ok().data(department); |
| | | } |
| | | return ResultBody.ok(); |
| | | }else { |
| | | return ResultBody.ok().data(false); |
| | | } |
| | | } |
| | | } |
| | | } |