-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathM_itemfacilitymappingImpl.java
More file actions
134 lines (112 loc) · 4.88 KB
/
M_itemfacilitymappingImpl.java
File metadata and controls
134 lines (112 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.admin.service.itemfacilitymapping;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iemr.admin.data.itemfacilitymapping.M_itemfacilitymapping;
import com.iemr.admin.data.itemfacilitymapping.V_fetchItemFacilityMap;
import com.iemr.admin.data.items.ItemInStore;
import com.iemr.admin.data.items.ItemMaster;
import com.iemr.admin.data.rolemaster.StateServiceMapping;
import com.iemr.admin.repo.stockEntry.ItemStockEntryRepo;
import com.iemr.admin.repository.itemfacilitymapping.M_itemfacilitymappingRepo;
import com.iemr.admin.repository.itemfacilitymapping.V_fetchItemFacilityMapRepo;
@Service
public class M_itemfacilitymappingImpl implements M_itemfacilitymappingInter {
@Autowired
private V_fetchItemFacilityMapRepo v_fetchItemFacilityMapRepo;
@Autowired
private M_itemfacilitymappingRepo m_itemfacilitymappingRepo;
@Autowired
ItemStockEntryRepo itemStockEntryRepo;
@Override
public ArrayList<M_itemfacilitymapping> mapItemtoStore(List<M_itemfacilitymapping> resList) {
ArrayList<M_itemfacilitymapping> data = (ArrayList<M_itemfacilitymapping>) m_itemfacilitymappingRepo
.saveAll(resList);
return data;
}
@Override
public M_itemfacilitymapping editdata(Integer itemStoreMapID) {
M_itemfacilitymapping data = m_itemfacilitymappingRepo.findByItemFacilityMapID(itemStoreMapID);
return data;
}
@Override
public M_itemfacilitymapping saveEditedItem(M_itemfacilitymapping getdataforedit) {
M_itemfacilitymapping data = m_itemfacilitymappingRepo.save(getdataforedit);
return data;
}
@Override
public ArrayList<M_itemfacilitymapping> getsubitemforsubStote(Integer providerServiceMapID, Integer facilityID) {
ArrayList<M_itemfacilitymapping> itemForsubStore = new ArrayList<M_itemfacilitymapping>();
ArrayList<Object[]> resultSet = m_itemfacilitymappingRepo.getItemforSubstore(providerServiceMapID, facilityID);
for (Object[] objects : resultSet) {
if (objects != null && objects.length >= 3) {
itemForsubStore.add(new M_itemfacilitymapping((Integer) objects[0], (String) objects[1],(Boolean) objects[2],(Integer) objects[3]));
}
// logger.debug("for getting state " + resultSet);
}
// logger.debug("getting response with stateid " +
// stateServiceMappings);
return itemForsubStore;
}
@Override
public ArrayList<V_fetchItemFacilityMap> getAllFacilityMappedData(Integer providerServiceMapID) {
ArrayList<V_fetchItemFacilityMap> data = v_fetchItemFacilityMapRepo
.getAllFacilityMappedData(providerServiceMapID);
return data;
}
@Override
public ArrayList<V_fetchItemFacilityMap> getItemMappingsByFacilityID(Integer facilityID) {
return v_fetchItemFacilityMapRepo.getItemMappingsByFacilityAndSubStores(facilityID);
}
@Override
public List<ItemInStore> getItemMastersFromStoreID(Integer storeID) {
// TODO Auto-generated method stub
ArrayList<ItemInStore> itemForsubStore = new ArrayList<ItemInStore>();
ArrayList<Object[]> resultSet = m_itemfacilitymappingRepo.getItemforStore(storeID);
Integer[] itemID = new Integer[resultSet.size()];
Object[] objects;
// for (Object[] objects : resultSet)
for (int i = 0; i < resultSet.size(); i++) {
objects = resultSet.get(i);
if (objects != null && objects.length >= 2) {
itemID[i]=(Integer) objects[0];
}
// logger.debug("for getting state " + resultSet);
}
ArrayList<Object[]> quant = itemStockEntryRepo.getQuantity(itemID,storeID);
for (Object[] objects1 : quant) {
if (objects1 != null && objects1.length >= 2) {
itemForsubStore.add(new ItemInStore((Integer) objects1[0], (Integer) objects1[1],(String) objects1[2],(Long) objects1[3]));
}
// logger.debug("for getting state " + resultSet);
}
return itemForsubStore;
}
@Override
public Integer deleteItemStoreMapping(M_itemfacilitymapping storeID) {
// TODO Auto-generated method stub M_itemfacilitymapping
return m_itemfacilitymappingRepo.updateDeleteMap(storeID.getItemStoreMapID(),storeID.getDeleted());
};
}