Bladeren bron

庫存界面批量修改

wangchenchen 1 maand geleden
bovenliggende
commit
cdedbf4913

+ 27
- 0
src/main/java/com/th/demo/controller/ware/StoreController.java Bestand weergeven

@@ -157,4 +157,31 @@ public class StoreController {
157 157
         }
158 158
     }
159 159
 
160
+    @RequestMapping(value = "/changeAll.do")//查询方法 前两个参数是分页参数
161
+    public String changeAll(
162
+
163
+            String json,
164
+            String newCustomername,
165
+            String newFKCustomername,
166
+            String newContractno,
167
+            String newOrdno,
168
+            String newReceiveaddress,
169
+            String newProductionplace,
170
+            String newPackno,
171
+
172
+            HttpServletRequest request) {
173
+
174
+        try {
175
+            String userId = (String) request.getAttribute("userId");
176
+            String belongId = (String) request.getAttribute("belongId");
177
+            result = storeService.changeAll( json,newCustomername,newFKCustomername,newContractno,newOrdno,newReceiveaddress,
178
+                    newProductionplace,newPackno,userId, belongId);
179
+        } catch (Exception ex) {
180
+            ex.printStackTrace();
181
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
182
+        } finally {
183
+            return result;
184
+        }
185
+    }
186
+
160 187
 }

+ 91
- 0
src/main/java/com/th/demo/service/impl/ware/StoreServiceImpl.java Bestand weergeven

@@ -6,11 +6,13 @@ import com.github.pagehelper.PageHelper;
6 6
 import com.github.pagehelper.PageInfo;
7 7
 import com.th.demo.mapping.maint.CustomerMapper;
8 8
 import com.th.demo.mapping.ware.ChangeRecordMapper;
9
+import com.th.demo.mapping.ware.InRecordMapper;
9 10
 import com.th.demo.mapping.ware.StoreMapper;
10 11
 import com.th.demo.model.maint.Customer;
11 12
 import com.th.demo.model.maint.Stack;
12 13
 import com.th.demo.model.system.Type;
13 14
 import com.th.demo.model.ware.ChangeRecord;
15
+import com.th.demo.model.ware.InRecord;
14 16
 import com.th.demo.model.ware.SplitRecord;
15 17
 import com.th.demo.model.ware.Store;
16 18
 import com.th.demo.service.maint.CustomerService;
@@ -33,6 +35,10 @@ public class StoreServiceImpl implements StoreService {
33 35
     public ChangeRecordMapper changeRecordMapper;
34 36
     @Autowired//自动注入Mapper
35 37
     public StoreMapper storeMapper;
38
+    @Autowired//自动注入Mapper
39
+    public CustomerMapper customerMapper;
40
+    @Autowired//自动注入Mapper
41
+    public InRecordMapper inRecordMapper;
36 42
     String result = Type.FAIL;
37 43
     int num = 0;
38 44
 
@@ -242,4 +248,89 @@ public class StoreServiceImpl implements StoreService {
242 248
 //        return result;
243 249
 //
244 250
 //    }
251
+    @Override
252
+    public String changeAll(String json,
253
+                            String newCustomername,
254
+                            String newFKCustomername,
255
+                            String newContractno,
256
+                            String newOrdno,
257
+                            String newReceiveaddress,
258
+                            String newProductionplace,
259
+                            String newPackno,
260
+                            String userId,
261
+                            String belongId) {
262
+        List<Store> list = JSON.parseObject(json, new TypeReference<List<Store>>() {
263
+        });
264
+        Customer customer = new Customer();
265
+        Customer kfcustomer = new Customer();
266
+        if(newCustomername != null && !newCustomername.equals("")){
267
+            customer = customerMapper.selectByName(newCustomername,belongId);
268
+
269
+        }
270
+
271
+        if(newFKCustomername != null && !newFKCustomername.equals("")){
272
+            kfcustomer = customerMapper.selectByName(newFKCustomername,belongId);
273
+
274
+        }
275
+
276
+        for(int i = 0; i < list.size(); i++){
277
+            InRecord inRecord = inRecordMapper.selectByPrimaryKey(list.get(i).getInId());
278
+            if (newCustomername != null && !newCustomername.equals("")){
279
+                list.get(i).setCustomer(customer);
280
+                inRecord.setCustomerName(newCustomername);
281
+            }
282
+            if(newFKCustomername != null && !newFKCustomername.equals("")){
283
+                list.get(i).setFkComponyId(kfcustomer.getId());
284
+                num += storeMapper.updateFKByPKey(list.get(i));
285
+                inRecord.setFkComponyName(kfcustomer.getId());
286
+            }
287
+
288
+
289
+            if (newContractno != null && !newContractno.equals("")){
290
+                list.get(i).setContractNo(newContractno);
291
+                inRecord.setContractNo(newContractno);
292
+            } else if (newContractno.equals("0")) {
293
+                list.get(i).setContractNo("");
294
+                inRecord.setContractNo("");
295
+            }
296
+
297
+            if (newOrdno != null && !newOrdno.equals("")){
298
+                list.get(i).setOrdNo(newOrdno);
299
+                inRecord.setOrdNo(newOrdno);
300
+            } else if (newOrdno.equals("0")) {
301
+                list.get(i).setOrdNo("");
302
+                inRecord.setOrdNo("");
303
+            }
304
+
305
+            if (newReceiveaddress != null && !newReceiveaddress.equals("")){
306
+                list.get(i).setReceiveAddress(newReceiveaddress);
307
+                inRecord.setReceiveAddress(newReceiveaddress);
308
+            } else if (newReceiveaddress.equals("0")) {
309
+                list.get(i).setReceiveAddress("");
310
+                inRecord.setReceiveAddress("");
311
+            }
312
+
313
+            if (newProductionplace != null && !newProductionplace.equals("")){
314
+                list.get(i).setProductionPlace(newProductionplace);
315
+                inRecord.setProductionPlace(newProductionplace);
316
+            } else if (newProductionplace.equals("0")) {
317
+                list.get(i).setProductionPlace("");
318
+                inRecord.setProductionPlace("");
319
+            }
320
+
321
+            if (newPackno != null && !newPackno.equals("")){
322
+                list.get(i).setPackNo(newPackno);
323
+                inRecord.setPackNo(newPackno);
324
+            } else if (newPackno.equals("0")) {
325
+                list.get(i).setPackNo("");
326
+                inRecord.setPackNo("");
327
+            }
328
+            num += storeMapper.updateByPrimaryKey(list.get(i));
329
+
330
+
331
+            num += inRecordMapper.updateIn(inRecord);
332
+
333
+        }
334
+        return Tools.moreThanZeroResultJSON(num);
335
+    }
245 336
 }

+ 12
- 0
src/main/java/com/th/demo/service/ware/StoreService.java Bestand weergeven

@@ -18,4 +18,16 @@ public interface StoreService {
18 18
     String modifyCustomer(String id,String customerNameOld,String customerNameNew);
19 19
 
20 20
     String modifyCustomeradress(String id,String customerAddressOld,String customerAddressNew);
21
+
22
+    String changeAll(String json,
23
+                     String newCustomername,
24
+                     String newFKCustomername,
25
+                     String newContractno,
26
+                     String newOrdno,
27
+                     String newReceiveaddress,
28
+                     String newProductionplace,
29
+                     String newPackno,
30
+                     String userId,
31
+                     String belongId);
32
+
21 33
 }

+ 6
- 1
src/main/resource/mapper/ware/InRecordMapper.xml Bestand weergeven

@@ -323,7 +323,12 @@
323 323
     receive_address = #{receiveAddress,jdbcType=VARCHAR},
324 324
         contract_no= #{contractNo,jdbcType=VARCHAR},
325 325
         pack_no= #{packNo,jdbcType=VARCHAR},
326
-        out_flag= #{outFlag,jdbcType=VARCHAR}
326
+        out_flag= #{outFlag,jdbcType=VARCHAR},
327
+      ord_no= #{ordNo,jdbcType=VARCHAR},
328
+        fk_compony_name= #{fkComponyName,jdbcType=VARCHAR},
329
+        production_place= #{productionPlace,jdbcType=VARCHAR}
330
+
331
+
327 332
     where id = #{id,jdbcType=VARCHAR}
328 333
   </update>
329 334
 

+ 3
- 1
src/main/resource/mapper/ware/StoreMapper.xml Bestand weergeven

@@ -371,7 +371,9 @@
371 371
         keep_day = #{keepDay,jdbcType=DOUBLE},
372 372
         ord_price = #{ordPrice,jdbcType=DOUBLE},
373 373
         out_ord_price = #{outOrdPrice,jdbcType=DOUBLE},
374
-        pay_way = #{payWay,jdbcType=VARCHAR}
374
+        pay_way = #{payWay,jdbcType=VARCHAR},
375
+        ord_no= #{ordNo,jdbcType=VARCHAR},
376
+        production_place= #{productionPlace,jdbcType=VARCHAR}
375 377
     where id = #{id,jdbcType=VARCHAR}
376 378
   </update>
377 379
 

Laden…
Annuleren
Opslaan