| | |
| | | package com.ruoyi.management.service.impl; |
| | | |
| | | 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.management.domain.dto.HomeStatisticsQuery; |
| | | import com.ruoyi.management.domain.vo.HomeStatisticsVO; |
| | | import com.ruoyi.management.service.HomeStatisticsService; |
| | | import com.ruoyi.management.domain.vo.goodsMaterialsNmVO; |
| | | import com.ruoyi.management.domain.vo.homeVO; |
| | | import com.ruoyi.management.service.*; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class HomeStatisticsServiceImpl implements HomeStatisticsService { |
| | | |
| | | @Resource |
| | | private SlVolumeProductionRkService slVolumeProductionRkService; |
| | | |
| | | @Resource |
| | | private SlGoodsMaterialsService slGoodsMaterialsService; |
| | | |
| | | @Resource |
| | | private SlStoreManagementService slStoreManagementService; |
| | | |
| | | @Resource |
| | | private SlVolumeProductionCkService slVolumeProductionCkService; |
| | | |
| | | |
| | | @Override |
| | | public HomeStatisticsVO getHomeStatistics(HomeStatisticsQuery homeStatisticsQuery) { |
| | | return null; |
| | | |
| | | LambdaQueryWrapper<SlStoreManagement> wrapper= Wrappers.lambdaQuery(); |
| | | if (homeStatisticsQuery.getStoreManagementName()!=null&&homeStatisticsQuery.getStoreManagementName()!=""){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementName,homeStatisticsQuery.getStoreManagementName()); |
| | | } |
| | | if(homeStatisticsQuery.getStoreManagementNo()!=null&&homeStatisticsQuery.getStoreManagementNo()!=""){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementNo,homeStatisticsQuery.getStoreManagementNo()); |
| | | } |
| | | if (homeStatisticsQuery.getStoreManagementGrade()!=0 && homeStatisticsQuery.getStoreManagementGrade()!=null){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementGrade,homeStatisticsQuery.getStoreManagementGrade()); |
| | | } |
| | | |
| | | if (homeStatisticsQuery.getStoreManagementNumber()!=0 && homeStatisticsQuery.getStoreManagementNumber()!=null){ |
| | | wrapper.eq(SlStoreManagement::getStoreManagementNumber,homeStatisticsQuery.getStoreManagementNumber()); |
| | | } |
| | | |
| | | if (homeStatisticsQuery.getCityCode()!=null){ |
| | | wrapper.eq(SlStoreManagement::getCityCode,homeStatisticsQuery.getCityCode()); |
| | | } |
| | | if (homeStatisticsQuery.getCountyCode()!=null){ |
| | | wrapper.eq(SlStoreManagement::getCountyCode,homeStatisticsQuery.getCountyCode()); |
| | | } |
| | | if (homeStatisticsQuery.getTownCode()!=null){ |
| | | wrapper.eq(SlStoreManagement::getCountyCode,homeStatisticsQuery.getTownCode()); |
| | | } |
| | | 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()); |
| | | } |
| | | List<SlGoodsMaterials> list1 = slGoodsMaterialsService.list(wrapper1); |
| | | |
| | | Set<Long> SlGoodsMaterialsList = null; |
| | | SlGoodsMaterialsList = list1.stream().map(SlGoodsMaterials::getId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | LambdaQueryWrapper<SlVolumeProductionRk> wrapper2= Wrappers.lambdaQuery(); |
| | | if (slStoreManagementIdList.size()>0){ |
| | | wrapper2.in(SlVolumeProductionRk::getManagementId,slStoreManagementIdList); |
| | | }else{ |
| | | slStoreManagementIdList=new HashSet<>(); |
| | | slStoreManagementIdList.add(0L); |
| | | wrapper2.in(SlVolumeProductionRk::getManagementId,slStoreManagementIdList); |
| | | } |
| | | |
| | | if (SlGoodsMaterialsList.size()>0){ |
| | | wrapper2.in(SlVolumeProductionRk::getMaterialsId,SlGoodsMaterialsList); |
| | | }else{ |
| | | SlGoodsMaterialsList=new HashSet<>(); |
| | | SlGoodsMaterialsList.add(0L); |
| | | wrapper2.in(SlVolumeProductionRk::getMaterialsId,SlGoodsMaterialsList); |
| | | } |
| | | if (homeStatisticsQuery.getShelfId()!=null){ |
| | | wrapper2.eq(SlVolumeProductionRk::getShelfId,homeStatisticsQuery.getShelfId()); |
| | | } |
| | | |
| | | 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()); |
| | | |
| | | Double d=0.0; |
| | | |
| | | for (SlVolumeProductionRk li:list2){ |
| | | Long repertoryZhai = li.getRepertoryZhai(); |
| | | 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(); |
| | | } |
| | | } |
| | | d=d+li.getRkPice().multiply(new BigDecimal(li.getRkPice().intValue())).doubleValue(); |
| | | li.setRepertoryZhai(repertoryZhai); |
| | | } |
| | | |
| | | homeStatisticsVO.setGoodsMaterialsSumPice(d); |
| | | |
| | | //非消耗 |
| | | List<homeVO> arr=new ArrayList<>(); |
| | | //消耗 |
| | | List<homeVO> arr1=new ArrayList<>(); |
| | | for (SlVolumeProductionRk l:list2){ |
| | | homeVO h=new homeVO(); |
| | | SlGoodsMaterials byId = slGoodsMaterialsService.getById(l.getMaterialsId()); |
| | | h.setIsConsume(byId.getIsConsume()); |
| | | h.setId(byId.getId()); |
| | | h.setGoodsMaterialsName(byId.getGoodsMaterialsName()); |
| | | h.setGoodsMaterialsNum(l.getRepertoryZhai()); |
| | | if (byId.getIsConsume()==1){ |
| | | arr.add(h); |
| | | }else{ |
| | | arr1.add(h); |
| | | } |
| | | |
| | | } |
| | | |
| | | List<goodsMaterialsNmVO> goodsMaterialsNmVOS=new ArrayList<>(); |
| | | Map<String, List<homeVO>> groupByUserNameMap1 = arr.stream().collect(Collectors.groupingBy(homeVO::getGoodsMaterialsName)); |
| | | for (Map.Entry<String, List<homeVO>> entry : groupByUserNameMap1.entrySet()) { |
| | | goodsMaterialsNmVO goodsMaterialsNmVO=new goodsMaterialsNmVO(); |
| | | String key = entry.getKey(); |
| | | goodsMaterialsNmVO.setGoodsMaterialsName(key); |
| | | List<homeVO> value = entry.getValue(); |
| | | // 处理键和值 |
| | | Long a=0L; |
| | | for (homeVO vo : value) { |
| | | a=a+vo.getGoodsMaterialsNum(); |
| | | } |
| | | goodsMaterialsNmVO.setGoodsMaterialsNum(a); |
| | | goodsMaterialsNmVOS.add(goodsMaterialsNmVO); |
| | | } |
| | | |
| | | homeStatisticsVO.setGoodsMaterialsfxiaohao(goodsMaterialsNmVOS); |
| | | |
| | | |
| | | List<goodsMaterialsNmVO> goodsMaterialsNmVOS1=new ArrayList<>(); |
| | | Map<String, List<homeVO>> groupByUserNameMap2 = arr1.stream().collect(Collectors.groupingBy(homeVO::getGoodsMaterialsName)); |
| | | for (Map.Entry<String, List<homeVO>> entry : groupByUserNameMap2.entrySet()) { |
| | | goodsMaterialsNmVO goodsMaterialsNmVO1=new goodsMaterialsNmVO(); |
| | | String key = entry.getKey(); |
| | | goodsMaterialsNmVO1.setGoodsMaterialsName(key); |
| | | List<homeVO> value = entry.getValue(); |
| | | // 处理键和值 |
| | | Long a=0L; |
| | | for (homeVO vo : value) { |
| | | a=a+vo.getGoodsMaterialsNum(); |
| | | } |
| | | goodsMaterialsNmVO1.setGoodsMaterialsNum(a); |
| | | goodsMaterialsNmVOS1.add(goodsMaterialsNmVO1); |
| | | } |
| | | |
| | | homeStatisticsVO.setGoodsMaterialsxiaohao(goodsMaterialsNmVOS); |
| | | |
| | | return homeStatisticsVO; |
| | | } |
| | | } |