| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.management.domain.SlGoodsMaterials; |
| | | import com.ruoyi.management.domain.SlStoreManagement; |
| | | import com.ruoyi.management.domain.SlVolumeProductionCk; |
| | | import com.ruoyi.management.domain.SlVolumeProductionRk; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.management.domain.*; |
| | | import com.ruoyi.management.domain.dto.HomeStatisticsQuery; |
| | | import com.ruoyi.management.domain.vo.HomeStatisticsVO; |
| | | import com.ruoyi.management.domain.vo.goodsMaterialsNmVO; |
| | | import com.ruoyi.management.domain.vo.homeVO; |
| | | import com.ruoyi.management.service.*; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | @Resource |
| | | private SlVolumeProductionCkService slVolumeProductionCkService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private ManagementGoodsMaterialsService managementGoodsMaterialsService; |
| | | @Resource |
| | | private SlVolumeProductionZyService slVolumeProductionZyService; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | LambdaQueryWrapper<SlStoreManagement> wrapper= Wrappers.lambdaQuery(); |
| | | if (homeStatisticsQuery.getStoreManagementName()!=null&&homeStatisticsQuery.getStoreManagementName()!=""){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementName,homeStatisticsQuery.getStoreManagementName()); |
| | | wrapper.eq(SlStoreManagement::getId,homeStatisticsQuery.getStoreManagementName()); |
| | | } |
| | | if(homeStatisticsQuery.getStoreManagementNo()!=null&&homeStatisticsQuery.getStoreManagementNo()!=""){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementNo,homeStatisticsQuery.getStoreManagementNo()); |
| | | } |
| | | if (homeStatisticsQuery.getStoreManagementGrade()!=null && homeStatisticsQuery.getStoreManagementGrade()!=0 ){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementGrade,homeStatisticsQuery.getStoreManagementGrade()); |
| | | if (StringUtils.hasLength(homeStatisticsQuery.getStoreManagementGrade())&& !homeStatisticsQuery.getStoreManagementGrade().equals("0")){ |
| | | String[] split = homeStatisticsQuery.getStoreManagementGrade().split(","); |
| | | if (split.length>0){ |
| | | wrapper.in(SlStoreManagement::getStoreManagementGrade,split); |
| | | } |
| | | } |
| | | |
| | | if ( homeStatisticsQuery.getStoreManagementNumber()!=null&& homeStatisticsQuery.getStoreManagementNumber()!=0 ){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementNumber,homeStatisticsQuery.getStoreManagementNumber()); |
| | | } |
| | | |
| | | if (homeStatisticsQuery.getCityCode()!=null){ |
| | | wrapper.eq(SlStoreManagement::getCityCode,homeStatisticsQuery.getCityCode()); |
| | | } |
| | |
| | | wrapper.eq(SlStoreManagement::getCountyCode,homeStatisticsQuery.getCountyCode()); |
| | | } |
| | | if (homeStatisticsQuery.getTownCode()!=null){ |
| | | wrapper.eq(SlStoreManagement::getCountyCode,homeStatisticsQuery.getTownCode()); |
| | | wrapper.eq(SlStoreManagement::getTownCode,homeStatisticsQuery.getTownCode()); |
| | | } |
| | | wrapper.eq(SlStoreManagement::getDelFlag,"0"); |
| | | List<SlStoreManagement> list = slStoreManagementService.list(wrapper); |
| | | |
| | | Set<Long> slStoreManagementIdList = null; |
| | | slStoreManagementIdList = list.stream().map(SlStoreManagement::getId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | LambdaQueryWrapper<SlGoodsMaterials> wrapper1= Wrappers.lambdaQuery(); |
| | | |
| | | if (homeStatisticsQuery.getGoodsMaterialsName()!=null&&homeStatisticsQuery.getStoreManagementName()!=""){ |
| | | wrapper1.eq(SlGoodsMaterials::getGoodsMaterialsName,homeStatisticsQuery.getGoodsMaterialsName()); |
| | | wrapper1.like(SlGoodsMaterials::getGoodsMaterialsName,homeStatisticsQuery.getGoodsMaterialsName()); |
| | | } |
| | | List<SlGoodsMaterials> list1 = slGoodsMaterialsService.list(wrapper1); |
| | | |
| | |
| | | if (homeStatisticsQuery.getShelfId()!=null){ |
| | | wrapper2.eq(SlVolumeProductionRk::getShelfId,homeStatisticsQuery.getShelfId()); |
| | | } |
| | | |
| | | wrapper2.isNotNull(SlVolumeProductionRk::getNewAddTime); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | SysUser data = sysUserClient.getSysUser(userId).getData(); |
| | | List<Long> collect = new ArrayList<>(); |
| | | if (data!=null){ |
| | | if (!data.getUserType().equals("00")){ |
| | | switch (data.getRoleType()){ |
| | | case 3: |
| | | collect = slStoreManagementService.lambdaQuery().eq(SlStoreManagement::getDelFlag, "0") |
| | | .ge(SlStoreManagement::getStoreManagementGrade, 3).eq(SlStoreManagement::getCityCode, data.getCityCode()) |
| | | .list().stream().map(SlStoreManagement::getId).collect(Collectors.toList()); |
| | | wrapper2.in(SlVolumeProductionRk::getManagementId, collect); |
| | | break; |
| | | case 4: |
| | | collect = slStoreManagementService.lambdaQuery().eq(SlStoreManagement::getDelFlag, "0") |
| | | .ge(SlStoreManagement::getStoreManagementGrade, 4).eq(SlStoreManagement::getCountyCode, data.getCountyCode()) |
| | | .list().stream().map(SlStoreManagement::getId).collect(Collectors.toList()); |
| | | wrapper2.in(SlVolumeProductionRk::getManagementId, collect); |
| | | break; |
| | | case 5: |
| | | collect = slStoreManagementService.lambdaQuery().eq(SlStoreManagement::getDelFlag, "0") |
| | | .ge(SlStoreManagement::getStoreManagementGrade, 5).eq(SlStoreManagement::getTownCode, data.getTownCode()) |
| | | .list().stream().map(SlStoreManagement::getId).collect(Collectors.toList()); |
| | | wrapper2.in(SlVolumeProductionRk::getManagementId, collect); |
| | | break; |
| | | case 6: |
| | | collect = slStoreManagementService.lambdaQuery().eq(SlStoreManagement::getDelFlag, "0") |
| | | .ge(SlStoreManagement::getStoreManagementGrade, 6).eq(SlStoreManagement::getTownCode, data.getTownCode()) |
| | | .list().stream().map(SlStoreManagement::getId).collect(Collectors.toList()); |
| | | wrapper2.in(SlVolumeProductionRk::getManagementId, collect); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | List<SlVolumeProductionRk> list2 = slVolumeProductionRkService.list(wrapper2); |
| | | |
| | | |
| | | Map<Long, List<SlVolumeProductionRk>> groupByUserNameMap = list2.stream().collect(Collectors.groupingBy(SlVolumeProductionRk::getMaterialsId)); |
| | | |
| | | |
| | | HomeStatisticsVO homeStatisticsVO=new HomeStatisticsVO(); |
| | | homeStatisticsVO.setGoodsMaterialsSumNum(groupByUserNameMap.size()); |
| | | |
| | | // 物资总数 |
| | | Long temp = 0L; |
| | | // 将list2中的在库数量累加起来 |
| | | Double d=0.0; |
| | | |
| | | for (SlVolumeProductionRk li:list2){ |
| | | Long repertoryZhai = li.getRepertoryZhai(); |
| | | List<String> longs = new ArrayList<>(); |
| | | for (SlVolumeProductionRk li:list2){ |
| | | Long repertoryZhai = li.getRepertoryZhai(); |
| | | li.setRepertoryZhai(repertoryZhai); |
| | | if (longs.isEmpty()){ |
| | | longs.add(li.getManagementId()+"-"+li.getMaterialsId()); |
| | | // 根据仓库id和物资id 查询遗失数量 |
| | | ManagementGoodsMaterials one = managementGoodsMaterialsService.lambdaQuery().eq(ManagementGoodsMaterials::getGoodsMaterialsId, li.getMaterialsId()) |
| | | .eq(ManagementGoodsMaterials::getManagementId, li.getManagementId()) |
| | | .eq(ManagementGoodsMaterials::getDelFlag, "0").one(); |
| | | if (one!=null){ |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkNum()-one.getRepertoryYishi())).doubleValue(); |
| | | temp+=li.getRkNum()-one.getRepertoryYishi(); |
| | | li.setRepertoryZhai(li.getRkNum()-one.getRepertoryYishi()); |
| | | }else{ |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkNum())).doubleValue(); |
| | | temp+=li.getRkNum(); |
| | | } |
| | | }else if(longs.contains(li.getManagementId()+"-"+li.getMaterialsId())){ |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkNum())).doubleValue(); |
| | | temp+=li.getRkNum(); |
| | | }else{ |
| | | longs.add(li.getManagementId()+"-"+li.getMaterialsId()); |
| | | // 根据仓库id和物资id 查询遗失数量 |
| | | ManagementGoodsMaterials one = managementGoodsMaterialsService.lambdaQuery().eq(ManagementGoodsMaterials::getGoodsMaterialsId, li.getMaterialsId()) |
| | | .eq(ManagementGoodsMaterials::getManagementId, li.getManagementId()) |
| | | .eq(ManagementGoodsMaterials::getDelFlag, "0").one(); |
| | | if (one!=null){ |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkNum()-one.getRepertoryYishi())).doubleValue(); |
| | | temp+=li.getRkNum()-one.getRepertoryYishi(); |
| | | li.setRepertoryZhai(li.getRkNum()-one.getRepertoryYishi()); |
| | | }else{ |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkNum())).doubleValue(); |
| | | temp+=li.getRkNum(); |
| | | } |
| | | } |
| | | // 查询这个入库记录有没有转移 转移了的话 需要扣去转移数量 |
| | | Long tem = 0L; |
| | | List<SlVolumeProductionZy> list3 = slVolumeProductionZyService.lambdaQuery().eq(SlVolumeProductionZy::getRkId, li.getId()) |
| | | .eq(SlVolumeProductionZy::getDelFlag, "0").list(); |
| | | if (!list3.isEmpty()){ |
| | | tem+= list3.stream().map(SlVolumeProductionZy::getZyNum).reduce(0, Integer::sum); |
| | | } |
| | | temp-=tem; |
| | | LambdaQueryWrapper<SlVolumeProductionCk> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(SlVolumeProductionCk::getRkId,li.getId()); |
| | | wrapper3.eq(SlVolumeProductionCk::getIsGh,1); |
| | | List<SlVolumeProductionCk> list3 = slVolumeProductionCkService.list(wrapper3); |
| | | if (list3.size()>0){ |
| | | for (SlVolumeProductionCk li1:list3){ |
| | | repertoryZhai=repertoryZhai+li1.getCkNum(); |
| | | } |
| | | } |
| | | if (li.getRkPice() == null){ |
| | | li.setRkPice(BigDecimal.ZERO); |
| | | } |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkPice().intValue())).doubleValue(); |
| | | li.setRepertoryZhai(repertoryZhai); |
| | | } |
| | | |
| | | homeStatisticsVO.setGoodsMaterialsSumNum(temp); |
| | | homeStatisticsVO.setGoodsMaterialsSumPice(d); |
| | | |
| | | //非消耗 |
| | |
| | | h.setId(byId.getId()); |
| | | h.setGoodsMaterialsName(byId.getGoodsMaterialsName()); |
| | | h.setGoodsMaterialsNum(l.getRepertoryZhai()); |
| | | // 判断物资预警库存 |
| | | if (byId.getRepertory()==null || byId.getRepertory() == 0){ |
| | | h.setColor(1); |
| | | }else{ |
| | | if (l.getRepertoryZhai()<=byId.getRepertory()){ |
| | | h.setColor(2); |
| | | }else{ |
| | | h.setColor(1); |
| | | } |
| | | } |
| | | |
| | | if (byId.getIsConsume()==1){ |
| | | arr.add(h); |
| | | }else{ |
| | |
| | | goodsMaterialsNmVO.setGoodsMaterialsName(key); |
| | | goodsMaterialsNmVO.setGoodsMaterialsId(entry.getValue().get(0).getId()); |
| | | List<homeVO> value = entry.getValue(); |
| | | goodsMaterialsNmVO.setColor(entry.getValue().get(0).getColor()); |
| | | // 处理键和值 |
| | | int a=0; |
| | | for (homeVO vo : value) { |
| | |
| | | String key = entry.getKey(); |
| | | goodsMaterialsNmVO1.setGoodsMaterialsName(key); |
| | | goodsMaterialsNmVO1.setGoodsMaterialsId(entry.getValue().get(0).getId()); |
| | | goodsMaterialsNmVO1.setColor(entry.getValue().get(0).getColor()); |
| | | List<homeVO> value = entry.getValue(); |
| | | // 处理键和值 |
| | | int a=0; |