| | |
| | | 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; |
| | | |
| | |
| | | String hql = " from " + Building.class.getName() |
| | | + " where companyId=:companyId "; |
| | | if (null == parameter) { |
| | | parameter = new HashMap<String, Object>(); |
| | | parameter = new HashMap<>(); |
| | | } |
| | | |
| | | String companyId = (String) parameter.get("companyId"); |
| | |
| | | parameter.put("companyId", companyId); |
| | | |
| | | String deptId = (String) parameter.get("deptId"); |
| | | if(StringUtils.isNoneEmpty(deptId)){ |
| | | if(StringUtils.isNotEmpty(deptId)){ |
| | | hql += " and deptId=:deptId "; |
| | | parameter.put("deptId", 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) { |
| | | Map<String, Object> parameter = new HashMap<String, Object>(); |