package com.nis.web.service; import java.util.Date; import java.util.List; import java.util.Map; import org.springframework.stereotype.Service; import com.nis.domain.SysOffice; import com.nis.util.DictUtils; import com.nis.util.StringUtil; import com.nis.web.dao.SysOfficeDao; import com.nis.web.security.UserUtils; @Service public class OfficeService extends TreeService{ public List findAll() { return UserUtils.getOfficeList(); } public List findList(Boolean isAll){ if (isAll != null && isAll){ return UserUtils.getOfficeAllList(); }else{ return UserUtils.getOfficeList(); } } public SysOffice selectByPrimaryKey(Integer id){ if(id != null){ return dao.selectByPrimaryKey(id); }else{ return null; } } public List findAllOfficeList(SysOffice office){ //office.getSqlMap().put("dsf", dataScopeFilter(UserUtils.getUser(), "a", "")); if (!StringUtil.isEmpty(office.getId()) && office.getId() != 1l) { office.setParentIds(office.getParentIds()+office.getId()+","+"%"); } else { office.setParentIds(office.getParentIds()+"%"); } return dao.findByParentIdsLike(office); } public void saveOrUpdate(SysOffice office) { if (StringUtil.isEmpty(office.getId())) { office.setCreateTime(new Date()); office.setDelFlag(1); } this.save(office); if(office.getChildDeptList() != null) { SysOffice childOffice = null; for(String id : office.getChildDeptList()){ childOffice = new SysOffice(); childOffice.setName(DictUtils.getDictLabel("SYS_OFFICE_COMMON", id, "未知")); childOffice.setParent(office); childOffice.setArea(office.getArea()); childOffice.setType(2); childOffice.setGrade(office.getGrade()+1); childOffice.setUseable(1); childOffice.setCreateTime(new Date()); childOffice.setDelFlag(1); this.save(childOffice); } } UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST); } public void delete(SysOffice office) { super.delete(office); UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST); } public List selectOfficeForDeptment(Map map) { List sysOfficeList=dao.selectOfficeForDeptment(map); return sysOfficeList; } public List selectOfficeForLetter(Map hmap) { List sysOfficeList=dao.selectOfficeForLetter(hmap); return sysOfficeList; } public List selectLowerDeptement(Map hmap) { List sysOfficeList=dao.selectLowerDeptement(hmap); return sysOfficeList; } public List selectSysOffice(SysOffice sysOffice) { return dao.selectSysOffice(sysOffice); } }