Browse Source

fix:“优化绑定设备时商品添加,冰淇淋商品顺序调整“

soobin 1 year ago
parent
commit
3d0fe76ac4

+ 12 - 7
src/main/java/com/szwl/controller/IndexController.java

@@ -625,11 +625,11 @@ public class IndexController {
                             }
                         } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
                             if (equimentType.equals("P30")) {
-                                saveProductP30(equipmentId);
+                                saveGoodsData(equipmentId, machineType, 6);
                             }
                         } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
                             if (equimentType.equals("SI320")) {
-                                saveProductSI320(equipmentId);
+                                saveGoodsData(equipmentId, machineType, 6);
                             }
                         }
 
@@ -710,7 +710,7 @@ public class IndexController {
      * @param machineType
      * @param number
      */
-    private void saveProduct(Long id, String machineType, Integer number) {
+    private void saveGoodsData(Long id, String machineType, Integer number) {
         LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
         wrapper.eq(TGoodsData::getNumber, number);
         wrapper.eq(TGoodsData::getMachineType, machineType);
@@ -726,8 +726,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
     }
@@ -899,7 +899,12 @@ public class IndexController {
      * @param id
      */
     private void saveProductSI320(Long id) {
-        String[] str = {"雪糕-I01", "果酱(1)-J01", "果酱(2)-J02", "果酱(3)-J03", "果碎(1)-C01", "果碎(2)-C02"};
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, 6);
+        wrapper.eq(TGoodsData::getMachineType, "2");
+        TGoodsData goodsData = goodsDataService.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
 
         for (int i = 0; i < str.length; i++) {
             TProduct product = new TProduct();
@@ -992,7 +997,7 @@ public class IndexController {
                 machineType = "0";
             }
             //创建花型
-            saveProduct(id, machineType, Integer.parseInt(number));
+            saveGoodsData(id, machineType, Integer.parseInt(number));
 //            if (number.equals("18")) {
 //                saveProduct(id);
 //            }

+ 64 - 11
src/main/java/com/szwl/controller/TEquipmentApplyController.java

@@ -72,6 +72,9 @@ public class TEquipmentApplyController {
     @Autowired
     AmqpAdmin amqpAdmin;
 
+    @Autowired
+    TGoodsDataService goodsDataService;
+
     @ApiOperation(value = "查找机器审核列表")
     @GetMapping("/pageTEquipmentApply")
     public ResponseModel<IPage<?>> pageTEquipmentApply(String adminId, String clientId, String userName,String managerId,String statusType, long current, long size ) {
@@ -286,17 +289,34 @@ public class TEquipmentApplyController {
                         }
                         //获取设备的id
                         Long equipmentId = equipment.getId();
-                        if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("MG280")){
-                            saveProductMG280(equipmentId);
-                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("MG320-1")){
-                            saveProductMG1(equipmentId);
-                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("P30")){
-                            saveProductP30(equipmentId);
-                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("SI320")){
-                            saveProductSI320(equipmentId);
-                        } else {
-                            saveProduct(equipmentId);
+                        if (StringUtils.isEmpty(machineType) || machineType.equals("0")) {
+                            if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG280")) {
+                                saveProductMG280(equipmentId);
+                            } else if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG320-1")) {
+                                saveProductMG1(equipmentId);
+                            } else {
+                                saveProduct(equipmentId);
+                            }
+                        } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
+                            if (equipmentType.equals("P30")) {
+                                saveGoodsData(equipmentId, machineType, 6);
+                            }
+                        } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
+                            if (equipmentType.equals("SI320")) {
+                                saveGoodsData(equipmentId, machineType, 6);
+                            }
                         }
+//                        if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("MG280")){
+//                            saveProductMG280(equipmentId);
+//                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("MG320-1")){
+//                            saveProductMG1(equipmentId);
+//                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("P30")){
+//                            saveProductP30(equipmentId);
+//                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("SI320")){
+//                            saveProductSI320(equipmentId);
+//                        } else {
+//                            saveProduct(equipmentId);
+//                        }
                         LambdaQueryWrapper<TEquipment> query1 = Wrappers.lambdaQuery();
                         query1.eq(TEquipment::getClientId,clientId);
                         TEquipment tEquipment = equipmentService.getOne(query1);
@@ -343,6 +363,34 @@ public class TEquipmentApplyController {
     }
 
     /**
+     * 添加商品
+     * @param id
+     * @param machineType
+     * @param number
+     */
+    private void saveGoodsData(Long id, String machineType, Integer number) {
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, number);
+        wrapper.eq(TGoodsData::getMachineType, machineType);
+        TGoodsData goodsData = goodsDataService.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
+
+        for (int i = 0; i < str.length; i++) {
+            TProduct product = new TProduct();
+            product.setCreateDate(new Date());
+            product.setModifyDate(new Date());
+            product.setEquipmentId(id);
+            String[] split = str[i].split("-");
+            product.setProductName(split[0]);
+            product.setNo(split[1]);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
+            productService.save(product);
+        }
+    }
+
+    /**
      * 添加产品
      *
      * @param id
@@ -484,7 +532,12 @@ public class TEquipmentApplyController {
      * @param id
      */
     private void saveProductSI320(Long id) {
-        String[] str = {"雪糕-I01", "果酱(1)-J01", "果酱(2)-J02", "果酱(3)-J03", "果碎(1)-C01", "果碎(2)-C02"};
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, 6);
+        wrapper.eq(TGoodsData::getMachineType, "2");
+        TGoodsData goodsData = goodsDataService.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
 
         for (int i = 0; i < str.length; i++) {
             TProduct product = new TProduct();