YL2767 il y a 2 mois
Parent
révision
a8b292a765

+ 16
- 0
src/main/java/com/th/demo/controller/ware/StoreController.java Voir le fichier

@@ -162,4 +162,20 @@ public class StoreController {
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 Voir le fichier

@@ -53,4 +53,6 @@ public interface StoreMapper {
53 53
     int selEffStore(String plateNo);
54 54
 
55 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 Voir le fichier

@@ -64,7 +64,8 @@ public class ChangeServiceImpl implements ChangeService {
64 64
         double sum_weight = 0;//可以进行货权转移的重量(货权转移的地方维护的)
65 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 69
         Cargo cargo = cargoMapper.selectByByFkAndCustomer(fk_cus.getId(),c.getId(),belongId);
69 70
         if (cargo == null){
70 71
             sum_weight=0;
@@ -91,6 +92,7 @@ public class ChangeServiceImpl implements ChangeService {
91 92
             list.get(i).setFkComponyId(fk_cus.getId());
92 93
             list.get(i).setReceiveAddress(address);
93 94
             num += storeMapper.updateByPrimaryKey(list.get(i));
95
+            num += storeMapper.updateFkById(list.get(i));
94 96
             use_weight = use_weight + list.get(i).getWeight();
95 97
         }
96 98
         if (sum_weight != 0){
@@ -112,8 +114,6 @@ public class ChangeServiceImpl implements ChangeService {
112 114
             result = Tools.moreThanZeroResultJSON(num);
113 115
         }
114 116
 
115
-
116
-
117 117
         return Tools.moreThanZeroResultJSON(num);
118 118
     }
119 119
 

+ 90
- 1
src/main/java/com/th/demo/service/impl/ware/StoreServiceImpl.java Voir le fichier

@@ -5,15 +5,20 @@ import com.alibaba.fastjson.TypeReference;
5 5
 import com.github.pagehelper.PageHelper;
6 6
 import com.github.pagehelper.PageInfo;
7 7
 import com.th.demo.mapping.maint.CustomerMapper;
8
+import com.th.demo.mapping.maint.StackMapper;
8 9
 import com.th.demo.mapping.ware.ChangeRecordMapper;
10
+import com.th.demo.mapping.ware.MoveRecordMapper;
9 11
 import com.th.demo.mapping.ware.StoreMapper;
10 12
 import com.th.demo.model.maint.Customer;
11 13
 import com.th.demo.model.maint.Stack;
14
+import com.th.demo.model.system.SysUser;
12 15
 import com.th.demo.model.system.Type;
13 16
 import com.th.demo.model.ware.ChangeRecord;
17
+import com.th.demo.model.ware.MoveRecord;
14 18
 import com.th.demo.model.ware.SplitRecord;
15 19
 import com.th.demo.model.ware.Store;
16 20
 import com.th.demo.service.maint.CustomerService;
21
+import com.th.demo.service.ware.MoveService;
17 22
 import com.th.demo.service.ware.StoreService;
18 23
 import com.th.demo.tools.JSONTools;
19 24
 import com.th.demo.tools.Tools;
@@ -33,6 +38,10 @@ public class StoreServiceImpl implements StoreService {
33 38
     public ChangeRecordMapper changeRecordMapper;
34 39
     @Autowired//自动注入Mapper
35 40
     public StoreMapper storeMapper;
41
+    @Autowired//自动注入Mapper
42
+    public StackMapper stackMapper;
43
+    @Autowired//自动注入Mapper
44
+    public MoveRecordMapper moveRecordMapper;
36 45
     String result = Type.FAIL;
37 46
     int num = 0;
38 47
 
@@ -86,7 +95,7 @@ public class StoreServiceImpl implements StoreService {
86 95
                              String fkcustmerName,
87 96
                              String userId,
88 97
                              String belongId) {
89
-        PageHelper.startPage(page, rows);
98
+
90 99
         List<String> pltNos =new ArrayList<>() ;
91 100
         List<String> ordNos =new ArrayList<>() ;
92 101
         if (plateNo.indexOf(",") != -1){
@@ -100,6 +109,7 @@ public class StoreServiceImpl implements StoreService {
100 109
                 customerName, plateNo,ordNo, pltNos,ordNos, userId,belongId,remark1,fkcustmerName);
101 110
 
102 111
         if(page != -1){
112
+            PageHelper.startPage(page, rows);
103 113
             PageInfo<Store> pageInfo = new PageInfo<>(list);
104 114
             result = JSONTools.toStringyyyyMMddHHmmss(pageInfo);
105 115
         }else {
@@ -237,4 +247,83 @@ public class StoreServiceImpl implements StoreService {
237 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 Voir le fichier

@@ -17,4 +17,6 @@ public interface StoreService {
17 17
     String modifyCustomer(String id,String customerNameOld,String customerNameNew);
18 18
 
19 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 Voir le fichier

@@ -1,14 +1,14 @@
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 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 3
 #jdbc.user=root
10 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 12
 #jdbc.driverClass=com.mysql.jdbc.Driver
13 13
 #jdbc.jdbcUrl=jdbc:mysql://60.205.9.174:3309/thware?useUnicode=true&characterEncoding=utf8
14 14
 #jdbc.user=root

+ 6
- 2
src/main/resource/mapper/ware/StoreMapper.xml Voir le fichier

@@ -330,8 +330,7 @@
330 330
       out_flag = #{outFlag,jdbcType=VARCHAR},
331 331
       lock_flag = #{lockFlag,jdbcType=VARCHAR},
332 332
       contract_no = #{contractNo,jdbcType=VARCHAR},
333
-      remark1 = #{remark1,jdbcType=VARCHAR},
334
-      fk_compony_id = #{fkComponyId,jdbcType=VARCHAR}
333
+      remark1 = #{remark1,jdbcType=VARCHAR}
335 334
     where id = #{id,jdbcType=VARCHAR}
336 335
   </update>
337 336
 
@@ -554,4 +553,9 @@ update t_ware_store t set t.layer =   #{param7,jdbcType=INTEGER}
554 553
       and t.plate_no = #{param1,jdbcType=VARCHAR};
555 554
 
556 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 561
 </mapper>

Loading…
Annuler
Enregistrer