| | |
| | | import org.hibernate.Session; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.bstek.bdf2.core.orm.hibernate.HibernateDao; |
| | | import com.bstek.dorado.data.entity.EntityState; |
| | | import com.bstek.dorado.data.entity.EntityUtils; |
| | |
| | | */ |
| | | @Component |
| | | public class BuildingService extends HibernateDao { |
| | | |
| | | String BEAN_ID = "core.buildingService"; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public List<Building> getCacheBuilding(String companyId,String deptId) { |
| | | public List<Building> getCacheBuilding(String companyId, String deptId) { |
| | | if(StringUtils.isEmpty(companyId)){ |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | |
| | | } |
| | | |
| | | if(null == deptId) return result; |
| | | |
| | | |
| | | return result.stream().filter(item -> item.getDeptId().equals(deptId)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public Building getCacheBuilding(String companyId, String deptId, String buildingId) { |
| | | if(StringUtils.isEmpty(companyId)){ |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | |
| | | List<Building> result = getCacheBuilding(companyId, deptId); |
| | | |
| | | if (null == result) { |
| | | refreshCache(companyId); |
| | | |
| | | return null; |
| | | } |
| | | for (Building building : result) { |
| | | if(buildingId.equals(building.getId())){ |
| | | return building; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public void refreshCache(String companyId) { |