|
@@ -128,71 +128,68 @@ public class OutServiceImpl implements OutService {
|
128
|
128
|
@Transactional(rollbackFor = Exception.class)
|
129
|
129
|
@Override
|
130
|
130
|
public String outByDistribution(String json, String userId, String belongId) throws Exception {
|
131
|
|
- Distribution distribution = JSON.parseObject(json, new TypeReference<Distribution>() {
|
|
131
|
+ Distribution distribution1 = JSON.parseObject(json, new TypeReference<Distribution>() {
|
132
|
132
|
});
|
133
|
|
- distribution.setOutFlag("1");
|
134
|
|
- num += distributionMapper.updateByPrimaryKey(distribution);
|
135
|
|
- List<String> listStoreId = new ArrayList<String>();
|
136
|
|
- for (int i = 0; i < distribution.getListDetail().size(); i++) {
|
137
|
|
- listStoreId.add(distribution.getListDetail().get(i).getStore().getId());
|
138
|
|
- }
|
139
|
|
- Map<String, Object> map = new HashMap<String, Object>();
|
140
|
|
- map.put("storeId", listStoreId);
|
141
|
|
- for(int i = 0 ;i < listStoreId.size();i++){
|
142
|
|
- System.out.println(listStoreId.get(i));
|
143
|
|
- }
|
144
|
|
- List<StoreOfWareStack> listSows = storeMapper.selectWareStackByDistributionStore(map);
|
145
|
|
-
|
146
|
|
- for (int m = 0; m < listSows.size(); m++) {
|
147
|
|
-
|
148
|
|
-
|
149
|
|
- Stack stack = stackMapper.selectByPrimaryKey(listSows.get(m).getStackId());
|
150
|
|
- Map<String, Object> mapParam = new HashMap<String, Object>();
|
151
|
|
- mapParam.put("storeId", listStoreId);
|
152
|
|
- mapParam.put("wareId", listSows.get(m).getWareId());
|
153
|
|
- mapParam.put("stackId", listSows.get(m).getStackId());
|
154
|
|
-
|
155
|
|
- List<Store> listStore = storeMapper.selectByWareIdStackIdInStoreId(mapParam);
|
156
|
|
- if (stack.getIsLayer().equals("0") || stack.getIsLayer().equals("2")) {
|
157
|
|
- for (int i = 0; i < listStore.size(); i++) {
|
158
|
|
- OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
|
159
|
|
- num += outRecordMapper.insert(outRecord);
|
160
|
|
- AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
|
161
|
|
- num += accountDetailMapper.insert(accountDetail);
|
162
|
|
- listStore.get(i).setOutId(outRecord.getId());
|
163
|
|
- listStore.get(i).setOutFlag("1");
|
164
|
|
- num += storeMapper.updateByPrimaryKey(listStore.get(i));
|
165
|
|
- }
|
166
|
|
- result = Tools.moreThanZeroResultJSON(num);
|
167
|
|
- } else {
|
168
|
|
- Collections.sort(listStore);
|
169
|
|
- int currentLayer = Integer.parseInt(storeMapper.selectLayerByStackId(listStore.get(0).getStack().getId(), belongId));
|
170
|
|
- int min = listStore.get(0).getLayer();
|
171
|
|
- int max = listStore.get(listStore.size() - 1).getLayer();
|
172
|
|
-// if (currentLayer != max) {
|
173
|
|
-// throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
|
174
|
|
-// // result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "必须选择最上层出库!");
|
175
|
|
-// } else if (!WareTools.checkOrder(listStore)) {
|
176
|
|
-// throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
|
177
|
|
-// // result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "请选中连续数据移动!");
|
178
|
|
-// } else {
|
179
|
|
-//
|
180
|
|
-// }
|
181
|
|
- for (int i = 0; i < listStore.size(); i++) {
|
182
|
|
- OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
|
183
|
|
- num += outRecordMapper.insert(outRecord);
|
|
133
|
+ Distribution distribution = distributionMapper.selectByPrimaryKey(distribution1.getId());
|
|
134
|
+ if (distribution.getOutFlag().equals("1")){
|
|
135
|
+ return JSONTools.toString(1,"该车已出库,请勿重复操作");
|
|
136
|
+ }else{
|
|
137
|
+ distribution.setOutFlag("1");
|
|
138
|
+ num += distributionMapper.updateByPrimaryKey(distribution);
|
|
139
|
+ List<String> listStoreId = new ArrayList<String>();
|
|
140
|
+ for (int i = 0; i < distribution.getListDetail().size(); i++) {
|
|
141
|
+ listStoreId.add(distribution.getListDetail().get(i).getStore().getId());
|
|
142
|
+ }
|
|
143
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
144
|
+ map.put("storeId", listStoreId);
|
|
145
|
+ for(int i = 0 ;i < listStoreId.size();i++){
|
|
146
|
+ System.out.println(listStoreId.get(i));
|
|
147
|
+ }
|
|
148
|
+ List<StoreOfWareStack> listSows = storeMapper.selectWareStackByDistributionStore(map);
|
|
149
|
+
|
|
150
|
+ for (int m = 0; m < listSows.size(); m++) {
|
|
151
|
+
|
184
|
152
|
|
185
|
|
- AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
|
186
|
|
- num += accountDetailMapper.insert(accountDetail);
|
|
153
|
+ Stack stack = stackMapper.selectByPrimaryKey(listSows.get(m).getStackId());
|
|
154
|
+ Map<String, Object> mapParam = new HashMap<String, Object>();
|
|
155
|
+ mapParam.put("storeId", listStoreId);
|
|
156
|
+ mapParam.put("wareId", listSows.get(m).getWareId());
|
|
157
|
+ mapParam.put("stackId", listSows.get(m).getStackId());
|
187
|
158
|
|
188
|
|
- listStore.get(i).setOutId(outRecord.getId());
|
189
|
|
- listStore.get(i).setOutFlag("1");
|
190
|
|
- num += storeMapper.updateByPrimaryKey(listStore.get(i));
|
|
159
|
+ List<Store> listStore = storeMapper.selectByWareIdStackIdInStoreId(mapParam);
|
|
160
|
+ if (stack.getIsLayer().equals("0") || stack.getIsLayer().equals("2")) {
|
|
161
|
+ for (int i = 0; i < listStore.size(); i++) {
|
|
162
|
+ OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
|
|
163
|
+ num += outRecordMapper.insert(outRecord);
|
|
164
|
+ AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
|
|
165
|
+ num += accountDetailMapper.insert(accountDetail);
|
|
166
|
+ listStore.get(i).setOutId(outRecord.getId());
|
|
167
|
+ listStore.get(i).setOutFlag("1");
|
|
168
|
+ num += storeMapper.updateByPrimaryKey(listStore.get(i));
|
|
169
|
+ }
|
|
170
|
+ result = Tools.moreThanZeroResultJSON(num);
|
|
171
|
+ } else {
|
|
172
|
+ Collections.sort(listStore);
|
|
173
|
+ int currentLayer = Integer.parseInt(storeMapper.selectLayerByStackId(listStore.get(0).getStack().getId(), belongId));
|
|
174
|
+ int min = listStore.get(0).getLayer();
|
|
175
|
+ int max = listStore.get(listStore.size() - 1).getLayer();
|
|
176
|
+ for (int i = 0; i < listStore.size(); i++) {
|
|
177
|
+ OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
|
|
178
|
+ num += outRecordMapper.insert(outRecord);
|
191
|
179
|
|
|
180
|
+ AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
|
|
181
|
+ num += accountDetailMapper.insert(accountDetail);
|
|
182
|
+
|
|
183
|
+ listStore.get(i).setOutId(outRecord.getId());
|
|
184
|
+ listStore.get(i).setOutFlag("1");
|
|
185
|
+ num += storeMapper.updateByPrimaryKey(listStore.get(i));
|
|
186
|
+
|
|
187
|
+ }
|
|
188
|
+ result = Tools.moreThanZeroResultJSON(num);
|
192
|
189
|
}
|
193
|
|
- result = Tools.moreThanZeroResultJSON(num);
|
194
|
190
|
}
|
195
|
191
|
}
|
|
192
|
+
|
196
|
193
|
return result;
|
197
|
194
|
}
|
198
|
195
|
|