张庆宇 1 year ago
parent
commit
a8b292a765

+ 16
- 0
src/main/java/com/th/demo/controller/ware/StoreController.java View File

162
         }
162
         }
163
     }
163
     }
164
 
164
 
165
+    @RequestMapping(value = "/changeStack.do")
166
+    public String changeStack(String json,String newWare,String newStack,String newRemark1,HttpServletRequest request) {
167
+
168
+        try {
169
+            String userId = (String) request.getAttribute("userId");
170
+            String belongId = (String) request.getAttribute("belongId");
171
+            result=storeService.changeStack(json,newWare,newStack,newRemark1,userId,belongId);
172
+
173
+        } catch (Exception ex) {
174
+            ex.printStackTrace();
175
+            result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());
176
+        } finally {
177
+            return result;
178
+        }
179
+    }
180
+
165
 }
181
 }

+ 2
- 0
src/main/java/com/th/demo/mapping/ware/StoreMapper.java View File

53
     int selEffStore(String plateNo);
53
     int selEffStore(String plateNo);
54
 
54
 
55
     void updateByOutId(String id, String noUserParam, String userId, String belongId);
55
     void updateByOutId(String id, String noUserParam, String userId, String belongId);
56
+
57
+    int updateFkById(Store store);
56
 }
58
 }

+ 3
- 3
src/main/java/com/th/demo/service/impl/ware/ChangeServiceImpl.java View File

64
         double sum_weight = 0;//可以进行货权转移的重量(货权转移的地方维护的)
64
         double sum_weight = 0;//可以进行货权转移的重量(货权转移的地方维护的)
65
         double use_weight = 0;//已经使用的货权转移的重量
65
         double use_weight = 0;//已经使用的货权转移的重量
66
         // 增加校验
66
         // 增加校验
67
-        Customer fk_cus = customerMapper.selectByPrimaryKey(list.get(0).getCustomer().getId());//老货主
67
+        Store store = storeMapper.selectByPrimaryKey(list.get(0).getId());
68
+        Customer fk_cus = customerMapper.selectByPrimaryKey(store.getCustomer().getId());//老货主
68
         Cargo cargo = cargoMapper.selectByByFkAndCustomer(fk_cus.getId(),c.getId(),belongId);
69
         Cargo cargo = cargoMapper.selectByByFkAndCustomer(fk_cus.getId(),c.getId(),belongId);
69
         if (cargo == null){
70
         if (cargo == null){
70
             sum_weight=0;
71
             sum_weight=0;
91
             list.get(i).setFkComponyId(fk_cus.getId());
92
             list.get(i).setFkComponyId(fk_cus.getId());
92
             list.get(i).setReceiveAddress(address);
93
             list.get(i).setReceiveAddress(address);
93
             num += storeMapper.updateByPrimaryKey(list.get(i));
94
             num += storeMapper.updateByPrimaryKey(list.get(i));
95
+            num += storeMapper.updateFkById(list.get(i));
94
             use_weight = use_weight + list.get(i).getWeight();
96
             use_weight = use_weight + list.get(i).getWeight();
95
         }
97
         }
96
         if (sum_weight != 0){
98
         if (sum_weight != 0){
112
             result = Tools.moreThanZeroResultJSON(num);
114
             result = Tools.moreThanZeroResultJSON(num);
113
         }
115
         }
114
 
116
 
115
-
116
-
117
         return Tools.moreThanZeroResultJSON(num);
117
         return Tools.moreThanZeroResultJSON(num);
118
     }
118
     }
119
 
119
 

+ 90
- 1
src/main/java/com/th/demo/service/impl/ware/StoreServiceImpl.java View File

5
 import com.github.pagehelper.PageHelper;
5
 import com.github.pagehelper.PageHelper;
6
 import com.github.pagehelper.PageInfo;
6
 import com.github.pagehelper.PageInfo;
7
 import com.th.demo.mapping.maint.CustomerMapper;
7
 import com.th.demo.mapping.maint.CustomerMapper;
8
+import com.th.demo.mapping.maint.StackMapper;
8
 import com.th.demo.mapping.ware.ChangeRecordMapper;
9
 import com.th.demo.mapping.ware.ChangeRecordMapper;
10
+import com.th.demo.mapping.ware.MoveRecordMapper;
9
 import com.th.demo.mapping.ware.StoreMapper;
11
 import com.th.demo.mapping.ware.StoreMapper;
10
 import com.th.demo.model.maint.Customer;
12
 import com.th.demo.model.maint.Customer;
11
 import com.th.demo.model.maint.Stack;
13
 import com.th.demo.model.maint.Stack;
14
+import com.th.demo.model.system.SysUser;
12
 import com.th.demo.model.system.Type;
15
 import com.th.demo.model.system.Type;
13
 import com.th.demo.model.ware.ChangeRecord;
16
 import com.th.demo.model.ware.ChangeRecord;
17
+import com.th.demo.model.ware.MoveRecord;
14
 import com.th.demo.model.ware.SplitRecord;
18
 import com.th.demo.model.ware.SplitRecord;
15
 import com.th.demo.model.ware.Store;
19
 import com.th.demo.model.ware.Store;
16
 import com.th.demo.service.maint.CustomerService;
20
 import com.th.demo.service.maint.CustomerService;
21
+import com.th.demo.service.ware.MoveService;
17
 import com.th.demo.service.ware.StoreService;
22
 import com.th.demo.service.ware.StoreService;
18
 import com.th.demo.tools.JSONTools;
23
 import com.th.demo.tools.JSONTools;
19
 import com.th.demo.tools.Tools;
24
 import com.th.demo.tools.Tools;
33
     public ChangeRecordMapper changeRecordMapper;
38
     public ChangeRecordMapper changeRecordMapper;
34
     @Autowired//自动注入Mapper
39
     @Autowired//自动注入Mapper
35
     public StoreMapper storeMapper;
40
     public StoreMapper storeMapper;
41
+    @Autowired//自动注入Mapper
42
+    public StackMapper stackMapper;
43
+    @Autowired//自动注入Mapper
44
+    public MoveRecordMapper moveRecordMapper;
36
     String result = Type.FAIL;
45
     String result = Type.FAIL;
37
     int num = 0;
46
     int num = 0;
38
 
47
 
86
                              String fkcustmerName,
95
                              String fkcustmerName,
87
                              String userId,
96
                              String userId,
88
                              String belongId) {
97
                              String belongId) {
89
-        PageHelper.startPage(page, rows);
98
+
90
         List<String> pltNos =new ArrayList<>() ;
99
         List<String> pltNos =new ArrayList<>() ;
91
         List<String> ordNos =new ArrayList<>() ;
100
         List<String> ordNos =new ArrayList<>() ;
92
         if (plateNo.indexOf(",") != -1){
101
         if (plateNo.indexOf(",") != -1){
100
                 customerName, plateNo,ordNo, pltNos,ordNos, userId,belongId,remark1,fkcustmerName);
109
                 customerName, plateNo,ordNo, pltNos,ordNos, userId,belongId,remark1,fkcustmerName);
101
 
110
 
102
         if(page != -1){
111
         if(page != -1){
112
+            PageHelper.startPage(page, rows);
103
             PageInfo<Store> pageInfo = new PageInfo<>(list);
113
             PageInfo<Store> pageInfo = new PageInfo<>(list);
104
             result = JSONTools.toStringyyyyMMddHHmmss(pageInfo);
114
             result = JSONTools.toStringyyyyMMddHHmmss(pageInfo);
105
         }else {
115
         }else {
237
 //        return result;
247
 //        return result;
238
 //
248
 //
239
 //    }
249
 //    }
250
+
251
+    @Override
252
+    public String changeStack(String json,String newWare,String newStack,String newRemark1,String userId,String belongId) {
253
+        List<Store> listStore = JSON.parseObject(json, new TypeReference<List<Store>>() {});
254
+
255
+        int layerNew = 0;
256
+        int layerOld = 0;
257
+        int layer = 0;
258
+        if (!newWare.equals("") && newWare!=null && !newStack.equals("") && newStack!=null){
259
+            Stack toStack = stackMapper.selectByWareNameStackName(newWare,newStack,userId,belongId);
260
+            int currentLayer = Integer.parseInt(storeMapper.selectLayerByStackId(toStack.getId(), belongId));
261
+            if (toStack==null){
262
+                return JSONTools.toString(1,"没有找到该垛位信息");
263
+            }else{
264
+                for (int i = 0; i < listStore.size(); i++) {
265
+                    layerOld = listStore.get(i).getLayer();
266
+
267
+                    if (toStack.getIsLayer().equals("0")) {
268
+                        layerNew = 0;
269
+                    } else if (toStack.getIsLayer().equals("1")) {
270
+                        layerNew = currentLayer + 1 + i;
271
+                    } else if (toStack.getIsLayer().equals("2")) {
272
+                        layerNew = layer;
273
+                    }
274
+
275
+                    listStore.get(i).setWare(toStack.getWare());
276
+                    listStore.get(i).setStack(toStack);
277
+                    listStore.get(i).setLayer(layerNew);
278
+
279
+
280
+                    MoveRecord moveRecord = getMoveRecord(listStore.get(i), listStore.get(i).getStack(), toStack, layerNew, layerOld, userId);
281
+                    num = moveRecordMapper.insert(moveRecord);
282
+
283
+                    num += storeMapper.updateByPrimaryKey(listStore.get(i));
284
+                }
285
+            }
286
+        }
287
+
288
+        for (int i = 0; i < listStore.size(); i++) {
289
+            if (!newRemark1.equals("") && newRemark1!=null){
290
+                if (newRemark1.equals("0")){
291
+                    listStore.get(i).setRemark1("");
292
+                }else {
293
+                    listStore.get(i).setRemark1(newRemark1);
294
+                }
295
+            }
296
+            num = storeMapper.updateByPrimaryKey(listStore.get(i));
297
+        }
298
+        return result;
299
+    }
300
+
301
+    private MoveRecord getMoveRecord(Store store, Stack fromStack, Stack toStack, int layerNew, int layerOld, String userId) {
302
+        MoveRecord moveRecord = new MoveRecord();
303
+        moveRecord.setWareNameOld(fromStack.getWare().getName());
304
+        moveRecord.setWareNameNew(toStack.getWare().getName());
305
+        moveRecord.setStackNameOld(fromStack.getName());
306
+        moveRecord.setStackNameNew(toStack.getName());
307
+        moveRecord.setLayerOld(layerOld);
308
+        moveRecord.setLayerNew(layerNew);
309
+        moveRecord.setMaterialName(store.getMaterial().getName());
310
+        // moveRecord.setMaterialNo(store.getMaterialNo());
311
+        moveRecord.setStandard(store.getMaterial().getStandard());
312
+        moveRecord.setModel(store.getModel());
313
+        moveRecord.setCustomerName(store.getCustomer().getName());
314
+        // moveRecord.setCustomerNo(store.getCustomerNo());
315
+        moveRecord.setCount(store.getCount());
316
+        moveRecord.setWeight(store.getWeight());
317
+        moveRecord.setRemark(store.getRemark());
318
+        moveRecord.setBelongId(store.getBelongId());
319
+        moveRecord.setPlateNo(store.getPlateNo());
320
+        moveRecord.setAddUser(new SysUser(userId));
321
+        moveRecord.setAddTime(new Date());
322
+        moveRecord.setReceiveAddress(store.getReceiveAddress());
323
+        moveRecord.setWgtDcnMtcCd(store.getWgtDcnMtcCd());
324
+        moveRecord.setEdgeTy(store.getEdgeTy());
325
+        moveRecord.setProductionPlace(store.getProductionPlace());
326
+        moveRecord.setCancelFlag("0");
327
+        return moveRecord;
328
+    }
240
 }
329
 }

+ 2
- 0
src/main/java/com/th/demo/service/ware/StoreService.java View File

17
     String modifyCustomer(String id,String customerNameOld,String customerNameNew);
17
     String modifyCustomer(String id,String customerNameOld,String customerNameNew);
18
 
18
 
19
     String modifyCustomeradress(String id,String customerAddressOld,String customerAddressNew);
19
     String modifyCustomeradress(String id,String customerAddressOld,String customerAddressNew);
20
+
21
+    String changeStack(String json,String newWare,String newStack,String newRemark1,String userId,String belongId);
20
 }
22
 }

+ 7
- 7
src/main/resource/localhost/db.properties View File

1
-jdbc.driverClass=com.mysql.jdbc.Driver
2
-jdbc.jdbcUrl=jdbc:mysql://172.18.200.32:3306/ware_mj?useUnicode=true&characterEncoding=utf8
3
-jdbc.user=root
4
-jdbc.password=root
5
-
6
-#???????????????????????????????
7
 #jdbc.driverClass=com.mysql.jdbc.Driver
1
 #jdbc.driverClass=com.mysql.jdbc.Driver
8
-#jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ware_mj?characterEncoding=utf8
2
+#jdbc.jdbcUrl=jdbc:mysql://172.18.200.32:3306/ware_mj?useUnicode=true&characterEncoding=utf8
9
 #jdbc.user=root
3
 #jdbc.user=root
10
 #jdbc.password=root
4
 #jdbc.password=root
11
 
5
 
6
+#???????????????????????????????
7
+jdbc.driverClass=com.mysql.jdbc.Driver
8
+jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ware_mj?characterEncoding=utf8
9
+jdbc.user=root
10
+jdbc.password=root
11
+
12
 #jdbc.driverClass=com.mysql.jdbc.Driver
12
 #jdbc.driverClass=com.mysql.jdbc.Driver
13
 #jdbc.jdbcUrl=jdbc:mysql://60.205.9.174:3309/thware?useUnicode=true&characterEncoding=utf8
13
 #jdbc.jdbcUrl=jdbc:mysql://60.205.9.174:3309/thware?useUnicode=true&characterEncoding=utf8
14
 #jdbc.user=root
14
 #jdbc.user=root

+ 6
- 2
src/main/resource/mapper/ware/StoreMapper.xml View File

330
       out_flag = #{outFlag,jdbcType=VARCHAR},
330
       out_flag = #{outFlag,jdbcType=VARCHAR},
331
       lock_flag = #{lockFlag,jdbcType=VARCHAR},
331
       lock_flag = #{lockFlag,jdbcType=VARCHAR},
332
       contract_no = #{contractNo,jdbcType=VARCHAR},
332
       contract_no = #{contractNo,jdbcType=VARCHAR},
333
-      remark1 = #{remark1,jdbcType=VARCHAR},
334
-      fk_compony_id = #{fkComponyId,jdbcType=VARCHAR}
333
+      remark1 = #{remark1,jdbcType=VARCHAR}
335
     where id = #{id,jdbcType=VARCHAR}
334
     where id = #{id,jdbcType=VARCHAR}
336
   </update>
335
   </update>
337
 
336
 
554
       and t.plate_no = #{param1,jdbcType=VARCHAR};
553
       and t.plate_no = #{param1,jdbcType=VARCHAR};
555
 
554
 
556
   </select>
555
   </select>
556
+
557
+  <update id="updateFkById"  parameterType="com.th.demo.model.ware.Store">
558
+    update  t_ware_store t set t.fk_compony_id = #{fkComponyId,jdbcType=VARCHAR}
559
+    where t.id = #{id,jdbcType=VARCHAR}
560
+  </update>
557
 </mapper>
561
 </mapper>

Loading…
Cancel
Save