Subversion Repositories SmartDukaan

Rev

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

Rev 31737 Rev 33124
Line 1... Line 1...
1
package com.spice.profitmandi.service;
1
package com.spice.profitmandi.service;
2
 
2
 
3
import com.spice.profitmandi.common.model.ProfitMandiConstants;
3
import com.spice.profitmandi.common.model.ProfitMandiConstants;
4
import com.spice.profitmandi.dao.entity.logistics.PostOffice;
4
import com.spice.profitmandi.dao.entity.logistics.*;
-
 
5
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
5
import com.spice.profitmandi.dao.repository.logistics.PostOfficeRepository;
6
import com.spice.profitmandi.dao.repository.logistics.PostOfficeRepository;
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.stereotype.Component;
8
import org.springframework.stereotype.Component;
8
 
9
 
9
import java.util.*;
10
import java.util.*;
Line 47... Line 48...
47
    }
48
    }
48
 
49
 
49
    @Autowired
50
    @Autowired
50
    private PostOfficeRepository postOfficeRepository;
51
    private PostOfficeRepository postOfficeRepository;
51
 
52
 
-
 
53
    @Autowired
-
 
54
    private ASTRepository astRepository;
-
 
55
 
-
 
56
    @Autowired
-
 
57
    private StateRepository stateRepository;
-
 
58
 
-
 
59
    @Autowired
-
 
60
    private AreaRepository areaRepository;
-
 
61
 
-
 
62
    @Autowired
-
 
63
    private TerritoryRepository territoryRepository;
-
 
64
 
52
    @Override
65
    @Override
53
    public Map<String, Object> getPOPincode(int pinCode) {
66
    public Map<String, Object> getPOPincode(int pinCode) {
54
        List<PostOffice> postOffices = postOfficeRepository.selectByPinCode(pinCode);
67
        List<PostOffice> postOffices = postOfficeRepository.selectByPinCode(pinCode);
55
        Set<String> cities = new HashSet<>();
68
        Set<String> cities = new HashSet<>();
56
        Map<String, Object> map = new HashMap<>(3);
69
        Map<String, Object> map = new HashMap<>(3);
Line 70... Line 83...
70
        }
83
        }
71
        map.put(ProfitMandiConstants.CITIES, cities);
84
        map.put(ProfitMandiConstants.CITIES, cities);
72
        return map;
85
        return map;
73
    }
86
    }
74
 
87
 
-
 
88
    @Override
-
 
89
    public Map<String, Object> getAreasAndTerritoriesByStateName(String stateName) {
-
 
90
        int stateId = stateRepository.selectByName(stateName).getId();
-
 
91
        List<AST> astList = astRepository.selectByStateId(stateId);
-
 
92
        Map<String, Object> result = new HashMap<>();
-
 
93
        List<Map<String, Object>> astInfoList = new ArrayList<>();
-
 
94
 
-
 
95
        for (AST ast : astList) {
-
 
96
            Map<String, Object> astInfoMap = new HashMap<>();
-
 
97
            astInfoMap.put("ast_id", ast.getId());
-
 
98
 
-
 
99
            // Fetch territory descriptions from repository
-
 
100
            List<Territory> territoryList = territoryRepository.selectByName(ast.getTerritory());
-
 
101
            if (!territoryList.isEmpty()) {
-
 
102
                Territory territory = territoryList.get(0); // Assuming territory names are unique
-
 
103
                Map<String, String> territoryMap = new HashMap<>();
-
 
104
                territoryMap.put("name", ast.getTerritory());
-
 
105
                territoryMap.put("description", territory.getDescription());
-
 
106
                astInfoMap.put("territory", territoryMap);
-
 
107
            }
-
 
108
 
-
 
109
            // Fetch area descriptions from repository
-
 
110
            List<Area> areaList = areaRepository.selectByName(ast.getArea());
-
 
111
            if (!areaList.isEmpty()) {
-
 
112
                Area area = areaList.get(0); // Assuming area names are unique
-
 
113
                Map<String, String> areaMap = new HashMap<>();
-
 
114
                areaMap.put("name", ast.getArea());
-
 
115
                areaMap.put("description", area.getDescription());
-
 
116
                astInfoMap.put("area", areaMap);
-
 
117
            }
-
 
118
 
-
 
119
            astInfoList.add(astInfoMap);
-
 
120
        }
-
 
121
 
-
 
122
        result.put("ast_info", astInfoList);
-
 
123
        return result;
-
 
124
    }
-
 
125
 
-
 
126
    @Override
-
 
127
    public Map<String, Object> getAreasAndTerritoriesByAstId(int astid) {
-
 
128
        List<AST> astList = astRepository.selectById(astid);
-
 
129
        Map<String, Object> result = new HashMap<>();
-
 
130
        List<Map<String, Object>> astInfoList = new ArrayList<>();
-
 
131
 
-
 
132
        for (AST ast : astList) {
-
 
133
            Map<String, Object> astInfoMap = new HashMap<>();
-
 
134
            astInfoMap.put("ast_id", ast.getId());
-
 
135
 
-
 
136
            // Fetch territory descriptions from repository
-
 
137
            List<Territory> territoryList = territoryRepository.selectByName(ast.getTerritory());
-
 
138
            if (!territoryList.isEmpty()) {
-
 
139
                Territory territory = territoryList.get(0); // Assuming territory names are unique
-
 
140
                Map<String, String> territoryMap = new HashMap<>();
-
 
141
                territoryMap.put("name", ast.getTerritory());
-
 
142
                territoryMap.put("description", territory.getDescription());
-
 
143
                astInfoMap.put("territory", territoryMap);
-
 
144
            }
-
 
145
 
-
 
146
            // Fetch area descriptions from repository
-
 
147
            List<Area> areaList = areaRepository.selectByName(ast.getArea());
-
 
148
            if (!areaList.isEmpty()) {
-
 
149
                Area area = areaList.get(0); // Assuming area names are unique
-
 
150
                Map<String, String> areaMap = new HashMap<>();
-
 
151
                areaMap.put("name", ast.getArea());
-
 
152
                areaMap.put("description", area.getDescription());
-
 
153
                astInfoMap.put("area", areaMap);
-
 
154
            }
-
 
155
 
-
 
156
            astInfoList.add(astInfoMap);
-
 
157
        }
-
 
158
 
-
 
159
        result.put("ast_info", astInfoList);
-
 
160
        return result;
-
 
161
    }
75
}
162
}