| package doumeemes.service.ext.impl; | 
|   | 
| import com.github.pagehelper.PageHelper; | 
| import com.github.pagehelper.PageInfo; | 
| import doumeemes.core.constants.ResponseStatus; | 
| import doumeemes.core.exception.BusinessException; | 
| import doumeemes.core.model.LoginUserInfo; | 
| import doumeemes.core.model.PageData; | 
| import doumeemes.core.model.PageWrap; | 
| import doumeemes.core.utils.Constants; | 
| import doumeemes.dao.ext.WarehouseExtMapper; | 
| import doumeemes.dao.ext.dto.QueryWarehouseExtDTO; | 
| import doumeemes.dao.ext.vo.WarehouseExtListVO; | 
| import doumeemes.service.business.impl.WarehouseLocationServiceImpl; | 
| import doumeemes.service.ext.WarehouseExtService; | 
| import org.apache.shiro.SecurityUtils; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import java.util.List; | 
|   | 
| /** | 
|  * 仓库信息Service实现 | 
|  * @author 江蹄蹄 | 
|  * @date 2022/05/05 11:37 | 
|  */ | 
| @Service | 
| public class WarehouseExtServiceImpl implements WarehouseExtService { | 
|   | 
|     @Autowired | 
|     private WarehouseExtMapper warehouseExtMapper; | 
|     @Autowired | 
|     private WarehouseLocationServiceImpl warehouseLocationServiceImpl; | 
|   | 
|     @Override | 
|     public PageData<WarehouseExtListVO> findPage(PageWrap<QueryWarehouseExtDTO> pageWrap) { | 
|   | 
|         PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         List<WarehouseExtListVO> result = warehouseExtMapper.selectList(pageWrap.getModel()); | 
|         return PageData.from(new PageInfo<>(result)); | 
|     } | 
|   | 
|   | 
|   | 
|     @Override | 
|     public PageData<WarehouseExtListVO> QXpage(PageWrap<QueryWarehouseExtDTO> pageWrap) { | 
|   | 
|         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|         if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ | 
|             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); | 
|         } | 
|         //只能查看当前根组织的数据 | 
|         pageWrap.getModel().setRootDepartId(user.getRootDepartment().getId()); | 
| //        if(!Constants.equalsInteger(user.getCurComDepartment().getId(),user.getRootDepartment().getId())){ | 
|         //如果当前选择的公司级组织非根组织信息,只能查看当前选择公司级组织数据 | 
|         pageWrap.getModel().setDepartId(user.getCurComDepartment().getId()); | 
| //        } | 
|         //数据权限 | 
|         List<Integer> dataPermission = user.getDepartPermissionList(); | 
|         if(dataPermission!=null){ | 
|             pageWrap.getModel().setDepartIds(dataPermission); | 
|             pageWrap.getModel().setCreateUser(user.getId()); | 
|            /* if(dataPermission.size() == 0){ | 
|                 //只能看自己的 | 
|                 pageWrap.getModel().setPmodelUserId(user.getId()); | 
|             }else{ | 
|                 //否则走数据权限 | 
|                 pageWrap.getModel().setDepartIds(dataPermission); | 
|             }*/ | 
|         } | 
|   | 
|         PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         List<WarehouseExtListVO> result = warehouseExtMapper.selectList(pageWrap.getModel()); | 
|         return PageData.from(new PageInfo<>(result)); | 
|     } | 
|   | 
|     @Override | 
|     public List<WarehouseExtListVO> queryAllData(QueryWarehouseExtDTO pageWrap) { | 
|         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|         List<WarehouseExtListVO> result = warehouseExtMapper.selectList(pageWrap); | 
|         return result; | 
|     } | 
|   | 
|   | 
|     @Override | 
|     public List<WarehouseExtListVO> queryListByJurisdiction(QueryWarehouseExtDTO pageWrap) { | 
|         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|         if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ | 
|             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); | 
|         } | 
|         //只能查看当前根组织的数据 | 
|         pageWrap.setRootDepartId(user.getRootDepartment().getId()); | 
| //        if(!Constants.equalsInteger(user.getCurComDepartment().getId(),user.getRootDepartment().getId())){ | 
|         //如果当前选择的公司级组织非根组织信息,只能查看当前选择公司级组织数据 | 
|         pageWrap.setDepartId(user.getCurComDepartment().getId()); | 
| //        } | 
|         //数据权限 | 
|         List<Integer> dataPermission = user.getDepartPermissionList(); | 
|         if(dataPermission!=null){ | 
|             pageWrap.setDepartIds(dataPermission); | 
|             pageWrap.setCreateUser(user.getId()); | 
|            /* if(dataPermission.size() == 0){ | 
|                 //只能看自己的 | 
|                 pageWrap.getModel().setPmodelUserId(user.getId()); | 
|             }else{ | 
|                 //否则走数据权限 | 
|                 pageWrap.getModel().setDepartIds(dataPermission); | 
|             }*/ | 
|         } | 
|   | 
|         List<WarehouseExtListVO> result = warehouseExtMapper.selectList(pageWrap); | 
|         return result; | 
|     } | 
|   | 
|   | 
|   | 
|   | 
|     @Override | 
|     public List<WarehouseExtListVO> queryWareHouserAndLocaltion(QueryWarehouseExtDTO pageWrap) { | 
|         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|         if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ | 
|             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); | 
|         } | 
|         pageWrap.setRootDepartId(user.getRootDepartment().getId()); | 
|         pageWrap.setDepartId(user.getCurComDepartment().getId()); | 
|         List<WarehouseExtListVO> result = warehouseExtMapper.selectList(pageWrap); | 
| /*        for(int i=0;i<result.size();i++){ | 
|             WarehouseExtListVO res=result.get(i); | 
|             WarehouseLocation warehouseLocation=new WarehouseLocation(); | 
|             warehouseLocation.setDeleted(Constants.ZERO); | 
|             warehouseLocation.setRootDepartId(user.getRootDepartment().getId()); | 
|             warehouseLocation.setWarehouseId(res.getId()); | 
|             warehouseLocation.setStatus(Constants.ONE); | 
|           List<WarehouseLocation> warehouseLocationList= warehouseLocationServiceImpl.findList(warehouseLocation); | 
|           if(warehouseLocationList!=null){ | 
|               res.setWarehouseLocationList(warehouseLocationList); | 
|           } | 
|         }*/ | 
|         return result; | 
|     } | 
| } |