Subversion Repositories SmartDukaan

Rev

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

Rev 9553 Rev 9555
Line 587... Line 587...
587
				}
587
				}
588
			} catch (TException e) {
588
			} catch (TException e) {
589
				// TODO Auto-generated catch block
589
				// TODO Auto-generated catch block
590
				e.printStackTrace();
590
				e.printStackTrace();
591
			}
591
			}
592
			System.out.println("Seller SKU "+inventory.getSellerSku());
592
			if(PendingOrdersInventoryHistoryMap.containsKey(inventory.getSellerSku())){
593
			System.out.println("Pending Orders "+ PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getPendingOrders());
-
 
594
			pending_orders = PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getPendingOrders()+(inventory.getAvailableInventory() - PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getInventoryHistory() - created_orders);
593
				pending_orders = PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getPendingOrders()+(inventory.getAvailableInventory() - PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku()).getInventoryHistory() - created_orders);
-
 
594
			}
595
			itemIdpendingOrdersMap.put(sku, pending_orders);
595
			itemIdpendingOrdersMap.put(sku, pending_orders);
596
			PendingOrderInventoryHistory pendingOrderInventoryHistory = PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku());
596
			PendingOrderInventoryHistory pendingOrderInventoryHistory = PendingOrdersInventoryHistoryMap.get(inventory.getSellerSku());
597
			pendingOrderInventoryHistory.setPendingOrders(pending_orders);
597
			pendingOrderInventoryHistory.setPendingOrders(pending_orders);
598
			PendingOrdersInventoryHistoryMap.put(inventory.getSellerSku(),pendingOrderInventoryHistory);
598
			PendingOrdersInventoryHistoryMap.put(inventory.getSellerSku(),pendingOrderInventoryHistory);
599
 
599
 
Line 665... Line 665...
665
				reserve = inventoryItem.getReserve();
665
				reserve = inventoryItem.getReserve();
666
				defaultinventory = inventoryItem.getDefaultInventory();
666
				defaultinventory = inventoryItem.getDefaultInventory();
667
				holdinventory = inventoryItem.getHoldInventory();
667
				holdinventory = inventoryItem.getHoldInventory();
668
				totalheld = inventoryItem.getTotalHeldInventory();
668
				totalheld = inventoryItem.getTotalHeldInventory();
669
				heldforsource = inventoryItem.getHeldForSource();
669
				heldforsource = inventoryItem.getHeldForSource();
670
				
670
 
671
				if(itemIdpendingOrdersMap.containsKey(sku)){
671
				if(itemIdpendingOrdersMap.containsKey(sku)){
672
					heldorders = itemIdpendingOrdersMap.get(sku);
672
					heldorders = itemIdpendingOrdersMap.get(sku);
673
					if(heldorders < 0){
673
					if(heldorders < 0){
674
						heldorders = 0;
674
						heldorders = 0;
675
					}
675
					}
Line 677... Line 677...
677
				System.out.println("itemId: " + inventoryItem.getId() + "\trisky: " + inventoryItem.getRisky()+ 
677
				System.out.println("itemId: " + inventoryItem.getId() + "\trisky: " + inventoryItem.getRisky()+ 
678
						"\tavailable: " + available + "\treserve: " + reserve + "\theldForSource:" + heldforsource +
678
						"\tavailable: " + available + "\treserve: " + reserve + "\theldForSource:" + heldforsource +
679
						"\twebsite_hold: " + holdinventory + "\ttotal_held: " +totalheld +"\tdefault_inv: "
679
						"\twebsite_hold: " + holdinventory + "\ttotal_held: " +totalheld +"\tdefault_inv: "
680
						+ defaultinventory + "\theldorders " + heldorders);
680
						+ defaultinventory + "\theldorders " + heldorders);
681
				row =   sheet.getRow((short) iterator);
681
				row =   sheet.getRow((short) iterator);
682
				
682
 
683
				if(inventoryItem.getRisky()){
683
				if(inventoryItem.getRisky()){
684
					allocable = available - reserve - totalheld - holdinventory;
684
					allocable = available - reserve - totalheld - holdinventory;
685
					if(allocable < 0){
685
					if(allocable < 0){
686
						allocable = 0;
686
						allocable = 0;
687
					}
687
					}
Line 743... Line 743...
743
		GmailUtils mailer = new GmailUtils();
743
		GmailUtils mailer = new GmailUtils();
744
		String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
744
		String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
745
		/*String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
745
		/*String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
746
				"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
746
				"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
747
				"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
747
				"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
748
		*/if(iterator > 1){
748
		 */if(iterator > 1){
749
			FileOutputStream fileOut = null;
749
			 FileOutputStream fileOut = null;
750
			fis.close();
750
			 fis.close();
751
			try {
751
			 try {
752
				//System.out.println("Before writing file ");
752
				 //System.out.println("Before writing file ");
753
				fileOut = new FileOutputStream(SNAPDEAL_INVENTORY_SHEET);
753
				 fileOut = new FileOutputStream(SNAPDEAL_INVENTORY_SHEET);
754
			} catch (FileNotFoundException e) {
754
			 } catch (FileNotFoundException e) {
755
				// TODO Auto-generated catch block
755
				 // TODO Auto-generated catch block
756
				e.printStackTrace();
756
				 e.printStackTrace();
757
			}
757
			 }
758
			try {
758
			 try {
759
 
759
 
760
				hwb.write(fileOut);
760
				 hwb.write(fileOut);
761
			} catch (IOException e) {
761
			 } catch (IOException e) {
762
				// TODO Auto-generated catch block
762
				 // TODO Auto-generated catch block
763
				e.printStackTrace();
763
				 e.printStackTrace();
764
			}
764
			 }
765
			HttpClient client = new DefaultHttpClient();
765
			 HttpClient client = new DefaultHttpClient();
766
			HttpPost post = new HttpPost("http://seller.snapdeal.com/login_security_check?spring-security-redirect=http://seller.snapdeal.com/inventory&");
766
			 HttpPost post = new HttpPost("http://seller.snapdeal.com/login_security_check?spring-security-redirect=http://seller.snapdeal.com/inventory&");
767
			BufferedReader rd= null;
767
			 BufferedReader rd= null;
768
			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
768
			 List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
769
			nameValuePairs.add(new BasicNameValuePair("j_username",
769
			 nameValuePairs.add(new BasicNameValuePair("j_username",
770
			"khushal.bhatia@saholic.com"));
770
			 "khushal.bhatia@saholic.com"));
771
			nameValuePairs.add(new BasicNameValuePair("j_password",
771
			 nameValuePairs.add(new BasicNameValuePair("j_password",
772
			"sonline"));
772
			 "sonline"));
773
			post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
773
			 post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
774
			HttpResponse response = null;
774
			 HttpResponse response = null;
775
			String line;
775
			 String line;
776
			try {
776
			 try {
777
				response = client.execute(post);
777
				 response = client.execute(post);
778
				rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
778
				 rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
779
				while ((line = rd.readLine()) != null) {
779
				 while ((line = rd.readLine()) != null) {
780
					System.out.println(line);
780
					 System.out.println(line);
781
				}
781
				 }
782
 
782
 
783
			} catch (ClientProtocolException e) {
783
			 } catch (ClientProtocolException e) {
784
				// TODO Auto-generated catch block
784
				 // TODO Auto-generated catch block
785
				e.printStackTrace();
785
				 e.printStackTrace();
786
			} catch (IOException e) {
786
			 } catch (IOException e) {
787
				// TODO Auto-generated catch block
787
				 // TODO Auto-generated catch block
788
				e.printStackTrace();
788
				 e.printStackTrace();
789
			}
789
			 }
790
			post = new HttpPost("http://seller.snapdeal.com/inventory/upload");
790
			 post = new HttpPost("http://seller.snapdeal.com/inventory/upload");
791
			File file = new File(SNAPDEAL_INVENTORY_SHEET);
791
			 File file = new File(SNAPDEAL_INVENTORY_SHEET);
792
			MultipartEntity mpEntity = new MultipartEntity();
792
			 MultipartEntity mpEntity = new MultipartEntity();
793
			ContentBody cbFile = new FileBody(file,"application/vnd.ms-excel");
793
			 ContentBody cbFile = new FileBody(file,"application/vnd.ms-excel");
794
			mpEntity.addPart("file", cbFile);
794
			 mpEntity.addPart("file", cbFile);
795
			post.setEntity(mpEntity);
795
			 post.setEntity(mpEntity);
796
			//response = client.execute(post);
796
			 //response = client.execute(post);
797
			try {
797
			 try {
798
				rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
798
				 rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
799
			} catch (IllegalStateException e1) {
799
			 } catch (IllegalStateException e1) {
800
				// TODO Auto-generated catch block
800
				 // TODO Auto-generated catch block
801
				e1.printStackTrace();
801
				 e1.printStackTrace();
802
			} catch (IOException e1) {
802
			 } catch (IOException e1) {
803
				// TODO Auto-generated catch block
803
				 // TODO Auto-generated catch block
804
				e1.printStackTrace();
804
				 e1.printStackTrace();
805
			}
805
			 }
806
			line = "";
806
			 line = "";
807
			String feedresponse = null;
807
			 String feedresponse = null;
808
			try {
808
			 try {
809
				while ((line = rd.readLine()) != null) {
809
				 while ((line = rd.readLine()) != null) {
810
					System.out.println(line);
810
					 System.out.println(line);
811
					feedresponse = line;
811
					 feedresponse = line;
812
				}
812
				 }
813
			} catch (IOException e) {
813
			 } catch (IOException e) {
814
				// TODO Auto-generated catch block
814
				 // TODO Auto-generated catch block
815
				e.printStackTrace();
815
				 e.printStackTrace();
816
			}
816
			 }
817
			in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
817
			 in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
818
			long lastSentInventoryTime = System.currentTimeMillis();
818
			 long lastSentInventoryTime = System.currentTimeMillis();
819
			try {
819
			 try {
820
				transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
820
				 transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
821
				transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
821
				 transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
822
			} catch (Exception e) {
822
			 } catch (Exception e) {
823
				try {
823
				 try {
824
					transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
824
					 transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
825
					transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
825
					 transactionClient.updateSourceDetailTimestamp(7, lastSentInventoryTime);
826
				} catch (Exception ex) {
826
				 } catch (Exception ex) {
827
					ex.printStackTrace();
827
					 ex.printStackTrace();
828
				}
828
				 }
829
			}
829
			 }
830
			String emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime);
830
			 String emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime);
831
			String text = backInStockItems.toString();
831
			 String text = backInStockItems.toString();
832
			if(text.length() > 0){
832
			 if(text.length() > 0){
833
				try {
833
				 try {
834
					mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
834
					 mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
835
				} catch (MessagingException e) {
835
				 } catch (MessagingException e) {
836
					e.printStackTrace();
836
					 e.printStackTrace();
837
				}
837
				 }
838
			}
838
			 }
839
			emailSubjectTxt = "Products out of stock on Snapdeal "+sdf.format(lastSentInventoryTime);
839
			 emailSubjectTxt = "Products out of stock on Snapdeal "+sdf.format(lastSentInventoryTime);
840
			text = outOfStockItems.toString();
840
			 text = outOfStockItems.toString();
841
			if(text.length() > 0){
841
			 if(text.length() > 0){
842
				try {
842
				 try {
843
					mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
843
					 mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
844
				} catch (MessagingException e) {
844
				 } catch (MessagingException e) {
845
					e.printStackTrace();
845
					 e.printStackTrace();
846
				}
846
				 }
847
			}
847
			 }
848
			/*			List<File> files = new ArrayList<File>();
848
			 /*			List<File> files = new ArrayList<File>();
849
			files.add(new File(SNAPDEAL_INVENTORY_SHEET));
849
			files.add(new File(SNAPDEAL_INVENTORY_SHEET));
850
			try {
850
			try {
851
				mailer.sendSSLMessage(sendTo,"Inventory File",feedresponse, emailFromAddress, password, files);
851
				mailer.sendSSLMessage(sendTo,"Inventory File",feedresponse, emailFromAddress, password, files);
852
			} catch (MessagingException e) {
852
			} catch (MessagingException e) {
853
				e.printStackTrace();
853
				e.printStackTrace();
854
			}
854
			}
855
			 */
855
			  */
856
			try {
856
			 try {
857
				mailer.sendSSLMessage(sendTo,"Snapdeal Inventory Updates sent for " +(iterator-1)+" items "+ sdf.format(System.currentTimeMillis()),feedresponse, emailFromAddress, password, new ArrayList<File>());
857
				 mailer.sendSSLMessage(sendTo,"Snapdeal Inventory Updates sent for " +(iterator-1)+" items "+ sdf.format(System.currentTimeMillis()),feedresponse, emailFromAddress, password, new ArrayList<File>());
858
			} catch (MessagingException e) {
858
			 } catch (MessagingException e) {
859
				e.printStackTrace();
859
				 e.printStackTrace();
860
			}
860
			 }
861
		
861
 
862
		}
862
		 }
863
		else{
863
		 else{
864
			try {
864
			 try {
865
				mailer.sendSSLMessage(sendTo,"No changes in Snapdeal inventory to update)"+ sdf.format(System.currentTimeMillis()),"No change in Snapdeal Inventory to be updated ", emailFromAddress, password, new ArrayList<File>());
865
				 mailer.sendSSLMessage(sendTo,"No changes in Snapdeal inventory to update)"+ sdf.format(System.currentTimeMillis()),"No change in Snapdeal Inventory to be updated ", emailFromAddress, password, new ArrayList<File>());
866
			} catch (MessagingException e) {
866
			 } catch (MessagingException e) {
867
				e.printStackTrace();
867
				 e.printStackTrace();
868
			}
868
			 }
869
		}
869
		 }
870
 
870
 
871
 
871
 
872
 
872
 
873
	}
873
	}
874
 
874