| | |
| | | package com.ruoyi.management.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.management.domain.ManagementGoodsMaterials; |
| | | import com.ruoyi.management.domain.SlStoreManagement; |
| | | |
| | |
| | | import com.ruoyi.management.mapper.SlVolumeProductionRkMapper; |
| | | import com.ruoyi.management.mapper.SlVolumeProductionRkglMapper; |
| | | import com.ruoyi.management.service.SlStoreManagementService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.apache.catalina.security.SecurityUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void addStoreManagement(StoreManagementDTO storeManagementDTO) { |
| | | public AjaxResult addStoreManagement(StoreManagementDTO storeManagementDTO) { |
| | | if (storeManagementDTO.getId()==null){ |
| | | List<SlStoreManagement> list = this.list(new QueryWrapper<SlStoreManagement>() |
| | | .eq("store_management_grade", storeManagementDTO.getStoreManagementGrade()) |
| | | .eq("store_management_no", storeManagementDTO.getStoreManagementNo()) |
| | | .eq("del_flag", 0)); |
| | | if (!list.isEmpty()){ |
| | | return AjaxResult.error("当前仓库等级已有相同编号仓库"); |
| | | } |
| | | SlStoreManagement slStoreManagement=new SlStoreManagement(); |
| | | slStoreManagement.setStoreManagementNo(storeManagementDTO.getStoreManagementNo()); |
| | | slStoreManagement.setStoreManagementAdder(storeManagementDTO.getStoreManagementAdder()); |
| | |
| | | this.save(slStoreManagement); |
| | | }else { |
| | | SlStoreManagement slStoreManagement = this.getById(storeManagementDTO.getId()); |
| | | List<SlStoreManagement> list = this.list(new QueryWrapper<SlStoreManagement>() |
| | | .eq("store_management_grade", storeManagementDTO.getStoreManagementGrade()) |
| | | .eq("store_management_no", storeManagementDTO.getStoreManagementNo()) |
| | | .ne("id",slStoreManagement.getId()) |
| | | .eq("del_flag", 0)); |
| | | if (!list.isEmpty()){ |
| | | return AjaxResult.error("当前仓库等级已有相同编号仓库"); |
| | | } |
| | | if (storeManagementDTO.getStoreManagementNo()!=null){ |
| | | slStoreManagement.setStoreManagementNo(storeManagementDTO.getStoreManagementNo()); |
| | | } |
| | |
| | | } |
| | | this.updateById(slStoreManagement); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Override |
| | | public List<SlStoreManagement> QueryStoreManagementList(QStoreManagementQuery StoreManagementQuery) { |
| | | LambdaQueryWrapper< SlStoreManagement> wrapper= Wrappers.lambdaQuery(); |
| | | if (StoreManagementQuery.getCityCode()!="" && StoreManagementQuery.getCityCode()!=null){ |
| | | wrapper.eq(SlStoreManagement::getCityCode,StoreManagementQuery.getCityCode()); |
| | | if (StoreManagementQuery.getCityCode()!=null && StoreManagementQuery.getCityCode()!=""){ |
| | | wrapper.eq(SlStoreManagement::getCityCode,StoreManagementQuery.getCityCode()); |
| | | } |
| | | if (StoreManagementQuery.getCountyCode()!="" && StoreManagementQuery.getCountyCode()!=null){ |
| | | if (StoreManagementQuery.getCountyCode()!=null && StoreManagementQuery.getCountyCode()!=""){ |
| | | wrapper.eq(SlStoreManagement::getCountyCode,StoreManagementQuery.getCountyCode()); |
| | | } |
| | | if (StoreManagementQuery.getStoreManagementGrade()!=null&&StoreManagementQuery.getStoreManagementGrade()!=0 ){ |
| | | if (StoreManagementQuery.getTownCode()!=null && StoreManagementQuery.getTownCode()!=""){ |
| | | wrapper.eq(SlStoreManagement::getTownCode,StoreManagementQuery.getTownCode()); |
| | | } |
| | | if (StoreManagementQuery.getStoreManagementGrade()!=null&&StoreManagementQuery.getStoreManagementGrade()!=0){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementGrade,StoreManagementQuery.getStoreManagementGrade()); |
| | | } |
| | | |
| | | wrapper.eq( SlStoreManagement::getDelFlag,0); |
| | | wrapper.eq(SlStoreManagement::getDelFlag,0); |
| | | wrapper.orderByDesc(SlStoreManagement::getCreateTime); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | if (data!=null){ |
| | | if (!data.getUserType().equals("00")){ |
| | | // 仓库管理员 根据仓库管理员的等级查询对应的仓库 |
| | | switch (data.getRoleType()){ |
| | | case 3: |
| | | wrapper.ge(SlStoreManagement::getStoreManagementGrade,3); |
| | | break; |
| | | case 4: |
| | | wrapper.ge(SlStoreManagement::getStoreManagementGrade,4); |
| | | break; |
| | | case 5: |
| | | wrapper.ge(SlStoreManagement::getStoreManagementGrade,5); |
| | | break; |
| | | case 6: |
| | | wrapper.eq(SlStoreManagement::getStoreManagementGrade,6); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | List<SlStoreManagement> page1 = this.list(wrapper); |
| | | return page1; |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<SlStoreManagementInventoryVO> getManagementInventoryList(StoreManagementQuery storeManagementQuery) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | SysUser data = sysUserClient.getSysUser(userId).getData(); |
| | | |
| | | Page<SlStoreManagement> page = new Page<>(storeManagementQuery.getPageCurr(), storeManagementQuery.getPageSize()); |
| | | LambdaQueryWrapper< SlStoreManagement> wrapper= Wrappers.lambdaQuery(); |
| | | if (storeManagementQuery.getStoreManagementName()!=null){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementName,storeManagementQuery.getStoreManagementName()); |
| | | wrapper.like(SlStoreManagement::getStoreManagementName,storeManagementQuery.getStoreManagementName()); |
| | | } |
| | | if (!data.getUserType().equals("00")){ |
| | | // 不是平台账号 根据角色类型查询对应的仓库 |
| | | switch (data.getRoleType()){ |
| | | case 3: |
| | | wrapper.ge(SlStoreManagement::getStoreManagementGrade,3); |
| | | break; |
| | | case 4: |
| | | wrapper.ge(SlStoreManagement::getStoreManagementGrade,4); |
| | | break; |
| | | case 5: |
| | | wrapper.ge(SlStoreManagement::getStoreManagementGrade,5); |
| | | break; |
| | | case 6: |
| | | wrapper.eq(SlStoreManagement::getStoreManagementGrade,6); |
| | | break; |
| | | } |
| | | } |
| | | if (storeManagementQuery.getStoreManagementNo()!=null){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementNo,storeManagementQuery.getStoreManagementNo()); |