Subversion Repositories SmartDukaan

Rev

Rev 23568 | Rev 23779 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23568 Rev 23717
Line 11... Line 11...
11
import java.util.Map;
11
import java.util.Map;
12
import java.util.stream.Collectors;
12
import java.util.stream.Collectors;
13
 
13
 
14
import javax.servlet.http.HttpServletRequest;
14
import javax.servlet.http.HttpServletRequest;
15
 
15
 
16
import org.apache.logging.log4j.Logger;
-
 
17
import org.apache.logging.log4j.LogManager;
16
import org.apache.logging.log4j.LogManager;
-
 
17
import org.apache.logging.log4j.Logger;
18
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.stereotype.Controller;
19
import org.springframework.stereotype.Controller;
20
import org.springframework.transaction.annotation.Transactional;
20
import org.springframework.transaction.annotation.Transactional;
21
import org.springframework.ui.Model;
21
import org.springframework.ui.Model;
22
import org.springframework.web.bind.annotation.RequestBody;
22
import org.springframework.web.bind.annotation.RequestBody;
23
import org.springframework.web.bind.annotation.RequestMapping;
23
import org.springframework.web.bind.annotation.RequestMapping;
24
import org.springframework.web.bind.annotation.RequestMethod;
24
import org.springframework.web.bind.annotation.RequestMethod;
25
 
25
 
26
import com.google.common.base.Functions;
-
 
27
import com.spice.profitmandi.common.enumuration.IndentStatus;
26
import com.spice.profitmandi.common.enumuration.IndentStatus;
28
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
27
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
29
import com.spice.profitmandi.common.model.ItemIdQuantity;
28
import com.spice.profitmandi.common.model.ItemIdQuantity;
30
import com.spice.profitmandi.dao.entity.catalog.TagListing;
29
import com.spice.profitmandi.dao.entity.catalog.TagListing;
31
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
30
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
Line 137... Line 136...
137
			List<FofoOrderItem> fofoOrderItems = fofoOrderRepository.selectByFofoItemIds(fofoId, pendingIndentIds, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30), LocalDateTime.now());
136
			List<FofoOrderItem> fofoOrderItems = fofoOrderRepository.selectByFofoItemIds(fofoId, pendingIndentIds, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(30), LocalDateTime.now());
138
			Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
137
			Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
139
					Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
138
					Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
140
			
139
			
141
			List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
140
			List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
142
			Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream().collect(Collectors.toMap(CurrentInventorySnapshot::getItemId, Functions.identity()));
141
			Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream().collect(Collectors.toMap(x->x.getItemId(), x->x));
143
			
142
			
144
			for(TagListing tagListing : tagListings){
143
			for(TagListing tagListing : tagListings){
145
				Integer itemId = tagListing.getItemId();
144
				Integer itemId = tagListing.getItemId();
146
				tagListing.setItemDescription(itemRepository.selectById(itemId).getItemDescription());
145
				tagListing.setItemDescription(itemRepository.selectById(itemId).getItemDescription());
147
				if(itemQuantity.containsKey(itemId)) {
146
				if(itemQuantity.containsKey(itemId)) {
Line 190... Line 189...
190
		Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
189
		Map<Integer, Integer> itemQuantity = fofoOrderItems.stream().collect(
191
				Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
190
				Collectors.groupingBy(FofoOrderItem::getItemId, Collectors.summingInt(FofoOrderItem::getQuantity)));
192
 
191
 
193
		List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
192
		List<CurrentInventorySnapshot> cis = currentInventorySnapshotRepository.selectByFofoId(fofoId);
194
		Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream()
193
		Map<Integer, CurrentInventorySnapshot> itemIdSnapshotMap = cis.stream()
195
				.collect(Collectors.toMap(CurrentInventorySnapshot::getItemId, Functions.identity()));
194
				.collect(Collectors.toMap(x->x.getItemId(), x->x));
196
 
195
 
197
		List<Integer> pendingIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.PENDING).stream()
196
		List<Integer> pendingIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.PENDING).stream()
198
				.map(x -> x.getId()).collect(Collectors.toList());
197
				.map(x -> x.getId()).collect(Collectors.toList());
199
		List<Integer> allocatedIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.ALLOCATED)
198
		List<Integer> allocatedIndentIds = indentRepository.selectIndentByStatus(fofoId, IndentStatus.ALLOCATED)
200
				.stream().map(x -> x.getId()).collect(Collectors.toList());
199
				.stream().map(x -> x.getId()).collect(Collectors.toList());