Subversion Repositories SmartDukaan

Rev

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

Rev 7567 Rev 13146
Line 13... Line 13...
13
import javax.servlet.http.HttpServletRequest;
13
import javax.servlet.http.HttpServletRequest;
14
import javax.servlet.http.HttpSession;
14
import javax.servlet.http.HttpSession;
15
 
15
 
16
import org.apache.commons.io.FileUtils;
16
import org.apache.commons.io.FileUtils;
17
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
17
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
 
18
import org.apache.poi.ss.usermodel.Cell;
18
import org.apache.poi.ss.usermodel.Row;
19
import org.apache.poi.ss.usermodel.Row;
19
import org.apache.poi.ss.usermodel.Sheet;
20
import org.apache.poi.ss.usermodel.Sheet;
20
import org.apache.poi.ss.usermodel.Workbook;
21
import org.apache.poi.ss.usermodel.Workbook;
21
import org.apache.struts2.convention.annotation.InterceptorRef;
22
import org.apache.struts2.convention.annotation.InterceptorRef;
22
import org.apache.struts2.convention.annotation.InterceptorRefs;
23
import org.apache.struts2.convention.annotation.InterceptorRefs;
Line 45... Line 46...
45
    private HttpSession session;
46
    private HttpSession session;
46
    
47
    
47
    private File awbFile;
48
    private File awbFile;
48
    private String awbFileContentType;
49
    private String awbFileContentType;
49
    private String awbFileFileName;
50
    private String awbFileFileName;
-
 
51
    //private String 
50
    
52
    
51
    private String errorMsg = "";
53
    private String errorMsg = "";
52
 
54
 
53
    public String index() {
55
    public String index() {
54
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath()))
56
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath()))
Line 67... Line 69...
67
           addActionError("Error while writing AWB file to the local file system");
69
           addActionError("Error while writing AWB file to the local file system");
68
        }
70
        }
69
        
71
        
70
        long providerId = Long.parseLong(this.request.getParameter("providerId"));
72
        long providerId = Long.parseLong(this.request.getParameter("providerId"));
71
        boolean isCod = Boolean.parseBoolean(this.request.getParameter("awbType"));
73
        boolean isCod = Boolean.parseBoolean(this.request.getParameter("awbType"));
-
 
74
        long awbUsedFor = Long.parseLong(this.request.getParameter("awbUsedFor"));
72
        
75
        
73
        
76
        
74
        if(checkForErrors())
77
        if(checkForErrors())
75
            return "authsuccess";
78
            return "authsuccess";
76
        
79
        
Line 95... Line 98...
95
        logger.info("Last row number is:" + sheet.getLastRowNum());
98
        logger.info("Last row number is:" + sheet.getLastRowNum());
96
        for (Row row : sheet) {
99
        for (Row row : sheet) {
97
            if(row.equals(firstRow))
100
            if(row.equals(firstRow))
98
                continue;
101
                continue;
99
            logger.info("Row no. " + row.getRowNum());
102
            logger.info("Row no. " + row.getRowNum());
-
 
103
            Cell awbCell = row.getCell(0);
-
 
104
            String awb ="";
-
 
105
            if(Cell.CELL_TYPE_STRING==row.getCell(0).getCellType()){
100
            String awb = row.getCell(0).getStringCellValue();
106
            	awb = row.getCell(0).getStringCellValue();
-
 
107
            }
-
 
108
            if(Cell.CELL_TYPE_NUMERIC==row.getCell(0).getCellType()){
-
 
109
            	awb = row.getCell(0).getNumericCellValue()+"";
-
 
110
            }
101
            awbs.add(awb);
111
            awbs.add(awb);
102
        }
112
        }
103
        if(checkForErrors())
113
        if(checkForErrors())
104
            return "authsuccess";
114
            return "authsuccess";
105
        
115
        
106
        
116
        
107
        try {
117
        try {
108
            LogisticsClient logisticsClient = new LogisticsClient();
118
            LogisticsClient logisticsClient = new LogisticsClient();
109
            in.shop2020.logistics.LogisticsService.Client lsc = logisticsClient.getClient();
119
            in.shop2020.logistics.LogisticsService.Client lsc = logisticsClient.getClient();
110
            lsc.addNewAwbs(providerId, isCod, awbs);
120
            lsc.addNewAwbs(providerId, isCod, awbs, awbUsedFor);
111
        } catch (TException e) {
121
        } catch (TException e) {
112
        	logger.error("Unable to add AWBs", e);
122
        	logger.error("Unable to add AWBs", e);
113
            addActionError(e.getMessage());
123
            addActionError(e.getMessage());
114
        }
124
        }
115
        
125