Przeglądaj źródła

feat:“添加新的商品调价接口“

soobin 1 rok temu
rodzic
commit
543279a332

+ 40 - 11
src/main/java/com/szwl/controller/IndexController.java

@@ -210,7 +210,7 @@ public class IndexController {
             }
             // 如果是爆米花机
             String machineType = newEquipment.getMachineType();
-            if(StringUtils.isNotEmpty(machineType) && "1".equals(newEquipment.getMachineType())) {
+            if (StringUtils.isNotEmpty(machineType) && "1".equals(newEquipment.getMachineType())) {
                 // 爆米花机搅拌温度
                 if (StringUtils.isNotEmpty(cabinetTm)) {
                     equipmentDesc.setStirTm(cabinetTm);
@@ -226,7 +226,7 @@ public class IndexController {
             }
             // 如果是雪糕机
             if (StringUtils.isNotEmpty(machineType) && "2".equals(newEquipment.getMachineType())) {
-                if (workingMode!= null) {
+                if (workingMode != null) {
                     equipmentDesc.setWorkingMode(workingMode);
                 }
             }
@@ -493,10 +493,10 @@ public class IndexController {
                             if (StringUtils.isEmpty(machineType) || machineType.equals("0")) {
                                 equipmentService.sentMessage(clientId, PushUtils.buildJson("statusType", "agreed" + old).toString());
                                 PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
-                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")) {
                                 equipmentService.sentMessage(clientId, PushUtils.buildJson("statusType", "agreed" + old).toString());
                                 PushUtils.push(equipmentApply.getGtClientId(), "【爆米花】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
-                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")) {
                                 equipmentService.sentMessage(clientId, PushUtils.buildJson("statusType", "agreed" + old).toString());
                                 PushUtils.push(equipmentApply.getGtClientId(), "【冰淇淋】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
                             }
@@ -556,10 +556,10 @@ public class IndexController {
                             if (StringUtils.isEmpty(machineType) || machineType.equals("0")) {
                                 equipmentService.sentMessage(clientId, PushUtils.buildJson("statusType", "agreed" + old).toString());
                                 PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
-                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")) {
                                 equipmentService.sentMessage(clientId, PushUtils.buildJson("statusType", "agreed" + old).toString());
                                 PushUtils.push(equipmentApply.getGtClientId(), "【爆米花】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
-                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")) {
                                 equipmentService.sentMessage(clientId, PushUtils.buildJson("statusType", "agreed" + old).toString());
                                 PushUtils.push(equipmentApply.getGtClientId(), "【冰淇淋】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
                             }
@@ -598,11 +598,11 @@ public class IndexController {
                                 } else {
                                     saveProduct(equipmentId);
                                 }
-                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")) {
                                 if (equimentType.equals("P30")) {
                                     saveGoodsData(equipmentId, machineType, 6);
                                 }
-                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")) {
                                 if (equimentType.equals("SI320")) {
                                     saveGoodsData(equipmentId, machineType, 6);
                                 }
@@ -682,6 +682,7 @@ public class IndexController {
 
     /**
      * 添加商品
+     *
      * @param id
      * @param machineType
      * @param number
@@ -972,7 +973,7 @@ public class IndexController {
             }
             // 机器类型
             String machineType = equipment.getMachineType();
-            if(StringUtils.isEmpty(equipment.getMachineType())) {
+            if (StringUtils.isEmpty(equipment.getMachineType())) {
                 machineType = "0";
             }
             //创建花型
@@ -1077,7 +1078,6 @@ public class IndexController {
                 productService.updateById(tProduct);
             }
         }
-
         return "调价成功";
     }
 
@@ -1416,7 +1416,7 @@ public class IndexController {
         // 设备名称
         String name = equipment.getName();
         // 如果为空就拿设备编号后六位
-        if(StringUtils.isEmpty(name)) {
+        if (StringUtils.isEmpty(name)) {
             name = equipment.getClientId().substring(equipment.getClientId().length() - 6);
         }
         if (eqeStatus != null) {
@@ -2320,6 +2320,7 @@ public class IndexController {
 
     /**
      * 获取DIY使用密码
+     *
      * @return
      */
     @RequestMapping(value = "/getDIYPassword", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
@@ -2361,5 +2362,33 @@ public class IndexController {
         return "fail";
     }
 
+    /**
+     * 商品调价
+     */
+    @RequestMapping(value = "/newUpdateProduct", method = RequestMethod.POST, produces = "text/html;charset=utf-8")
+    @ResponseBody
+    public String newUpdateProduct(@RequestBody List<ProductVo> productVos) {
+        for (ProductVo product : productVos) {
+            String clientId = product.getClientId();
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = equipmentService.getOne(query);
+            Long id = equipment.getId();
+            LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
+            queryProduct.eq(TProduct::getEquipmentId, id);
+            queryProduct.eq(TProduct::getNo, product.getProductNo());
+            TProduct tProduct = productService.getOnly(queryProduct);
+            if (tProduct == null) {
+                return "找不到商品";
+            }
+            tProduct.setRmbPrice(BigDecimal.valueOf(product.getRmbPrice()));
+            tProduct.setCodePrice(BigDecimal.valueOf(product.getCodePrice()));
+            tProduct.setShowType(product.getShowType());
+            tProduct.setSellStatus(product.getSellStatus());
+            productService.updateById(tProduct);
+        }
+        return "调价成功";
+    }
+
 }
 

+ 4 - 6
src/main/java/com/szwl/controller/TAdminController.java

@@ -358,8 +358,7 @@ public class TAdminController {
             query.eq(TAdmin::getName, name);
         }
         if (StringUtils.isNotEmpty(adminId)) {
-            if (adminId.equals("1")) {
-//                query.in(TAdmin::getType,"1","3");
+            if (adminId.equals("18")) {
                 query.eq(TAdmin::getType, "1");
             } else {
                 query.eq(TAdmin::getType, "3");
@@ -369,11 +368,10 @@ public class TAdminController {
         }
         query.eq(TAdmin::getIsAdmined, false);
         List<TAdmin> list = tAdminService.list(query);
-        if (list.size() > 0) {
+        if (!list.isEmpty()) {
 
             for (TAdmin admin : list) {
                 AddLoginUserParam addLoginUserParam = new AddLoginUserParam();
-//                JSONObject jsonObject = new JSONObject();
                 addLoginUserParam.setUsername(admin.getUsername());
                 addLoginUserParam.setName(admin.getName());
                 addLoginUserParam.setEmail(admin.getEmail());
@@ -383,7 +381,7 @@ public class TAdminController {
                 LambdaQueryWrapper<TAdminEquipment> query2 = Wrappers.lambdaQuery();
                 query2.eq(TAdminEquipment::getAdminId, admin.getId());
                 List<TAdminEquipment> list1 = tAdminEquipmentService.list(query2);
-                if (list1.size() > 0) {
+                if (!list1.isEmpty()) {
                     TAdminEquipment tAdminEquipment1 = list1.get(0);
                     if (tAdminEquipment1.getType().equals("0")) {
                         //管理全部机器
@@ -403,7 +401,7 @@ public class TAdminController {
                 List<SysUserRole> roleList = sysUserRoleService.list(query1);
                 List<String> ids = new ArrayList<>();
                 StringBuilder roleName = new StringBuilder();
-                if (roleList.size() > 0) {
+                if (!roleList.isEmpty()) {
                     for (int i = 0; i < roleList.size(); i++) {
                         SysUserRole sysUserRole = roleList.get(0);
                         ids.add(sysUserRole.getRoleId());

+ 10 - 63
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -1019,7 +1019,6 @@ public class TEquipmentController {
         TEquipment equipment = tEquipmentService.getById(id);
         String network = equipment.getNetwork();
         Long nowTime2 = getNetworkTime();
-//        Long nowTime2 = new Date().getTime();
         if (network != null) {
             Long old = Long.valueOf(network);
             if (nowTime2 == null) {
@@ -1036,13 +1035,6 @@ public class TEquipmentController {
                                 .setData("SUCCESS")
                                 .setMessage("网络良好"));
             } else {
-//                if(equipment.getEqeStatus()==0){
-//                    equipment.setEqeStatus(1);
-//                    tEquipmentService.updateById(equipment);
-//                }else {
-//                    equipment.setEqeStatus(0);
-//                    tEquipmentService.updateById(equipment);
-//                }
                 return ResponseEntity
                         .status(HttpStatus.OK)
                         .body(new ResultMessage()
@@ -1084,9 +1076,6 @@ public class TEquipmentController {
         String equipmentId = param.getEquipmentId();
         Long id = Long.valueOf(equipmentId);
         TEquipment equipment = tEquipmentService.getById(id);
-//        if (equipment == null) {
-//			return ERROR_MESSAGE;
-//        }
         String eqeStatus = "0";
         String code = param.getEqeStatus();
         if (code.equals("1")) {
@@ -1099,7 +1088,6 @@ public class TEquipmentController {
 
         tEquipmentService.updateById(equipment);
         tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("is_sleep", eqeStatus).toString());
-//        PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("is_sleep", eqeStatus).toString());
         return ResponseEntity
                 .status(HttpStatus.OK)
                 .body(new ResultMessage()
@@ -1132,7 +1120,6 @@ public class TEquipmentController {
         if (equipmentList.size() > 0) {
             for (TEquipment equipment : equipmentList) {
                 tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("onoffstatus", "0").toString());
-//                PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("onoffstatus", "0").toString());
             }
         }
         return R.ok();
@@ -1499,23 +1486,22 @@ public class TEquipmentController {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
 
         Calendar cal = Calendar.getInstance();
-        cal.setFirstDayOfWeek(Calendar.MONDAY);// 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
-        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
+        // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        // 获得当前日期是一个星期的第几天
+        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
         if (dayWeek == 1) {
             dayWeek = 8;
         }
-//		System.out.println("要计算日期为:" + sdf.format(cal.getTime())); // 输出要计算日期
-
-        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - dayWeek);// 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - dayWeek);
         Date mondayDate = cal.getTime();
         String weekBegin = sdf.format(mondayDate);
-//		System.out.println("所在周星期一的日期:" + weekBegin);
 
 
         cal.add(Calendar.DATE, 4 + cal.getFirstDayOfWeek());
         Date sundayDate = cal.getTime();
         String weekEnd = sdf.format(sundayDate);
-//		System.out.println("所在周星期日的日期:" + weekEnd);
 
         map.put("mondayDate", weekBegin);
         map.put("sundayDate", weekEnd);
@@ -1530,18 +1516,11 @@ public class TEquipmentController {
      * @return
      */
     @PostMapping("/updateParameters")
-    public ResponseEntity<?> updateCommonParam(@RequestBody CommonParamVo commonParamVo) {
+    public ResponseModel<?> updateCommonParam(@RequestBody CommonParamVo commonParamVo) {
         String equipmentId = commonParamVo.getId();
         TEquipment equipment = tEquipmentService.getById(Long.valueOf(equipmentId));
         tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("Param", commonParamVo.getName() + ":" + commonParamVo.getVal()).toString());
-//        PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("Param", commonParamVo.getName() + ":" + commonParamVo.getVal()).toString());
-
-        return ResponseEntity
-                .status(HttpStatus.OK)
-                .body(new ResultMessage()
-                        .setCode(true)
-                        .setData("SUCCESS")
-                        .setMessage("SUCCESS"));
+        return R.ok();
     }
 
     /**
@@ -1551,18 +1530,11 @@ public class TEquipmentController {
      * @return
      */
     @PostMapping("/humidityParameters")
-    public ResponseEntity<?> humidityParameters(@RequestBody CommonParamVo commonParamVo) {
+    public ResponseModel<?> humidityParameters(@RequestBody CommonParamVo commonParamVo) {
         String equipmentId = commonParamVo.getId();
         TEquipment equipment = tEquipmentService.getById(equipmentId);
         tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("humidityParameters", commonParamVo.getName() + ":" + commonParamVo.getVal()).toString());
-//        PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("Param", commonParamVo.getName() + ":" + commonParamVo.getVal()).toString());
-
-        return ResponseEntity
-                .status(HttpStatus.OK)
-                .body(new ResultMessage()
-                        .setCode(true)
-                        .setData("SUCCESS")
-                        .setMessage("SUCCESS"));
+        return R.ok();
     }
 
     /**
@@ -1576,9 +1548,6 @@ public class TEquipmentController {
     @GetMapping("/downloadLog")
     public ResponseModel<?> downloadLog(String equipmentId, String day, HttpServletResponse response) throws IOException, InterruptedException {
         // 1、发送MQ到安卓端上传日志
-/*        if(day.length()!=8){
-            return R.fail(A0001,"日期格式有误");
-        }*/
         if (StringUtils.isEmpty(equipmentId)) {
             return R.fail(A0001);
         }
@@ -1591,8 +1560,6 @@ public class TEquipmentController {
         String filepath = "/home/hboxs/log/" + kind + ".txt";
         // 1.1 如果文件已存在,直接下载
         if (Files.exists(Paths.get(filepath))) {
-//            DownloadUtils.downloadFile(filepath, response);
-//            return R.ok();
             try {
                 Files.delete(Paths.get(filepath));
                 return R.ok();
@@ -1642,25 +1609,6 @@ public class TEquipmentController {
         return R.ok();
     }
 
-    // 从服务器下载文件
-//    public void downloadFile(String filepath, HttpServletResponse response) throws IOException {
-//        File logFile = new File(filepath);
-//        response.setHeader("Content-Disposition", "attachment; filename=\"" + logFile.getName() + "\"");
-//
-//        FileInputStream fis = new FileInputStream(logFile);
-//        OutputStream os = response.getOutputStream();
-//
-//        byte[] buffer = new byte[4096];
-//        int length;
-//        while ((length = fis.read(buffer)) > 0) {
-//            os.write(buffer, 0, length);
-//            os.flush();
-//        }
-//        os.close();
-//        fis.close();
-//        response.flushBuffer();
-//    }
-
     //查找设备
     @ApiOperation(value = "获取对应的机器编号")
     @GetMapping("/findEquipmentByClientIds")
@@ -1719,7 +1667,6 @@ public class TEquipmentController {
             }
         }
         tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("updateDIYProductShow", JSON.toJSONString(list)).toString());
-//        tDiyFlowerService.updateBatchById(products);
         return R.ok(null, "修改请求发送成功");
     }
 

+ 7 - 57
src/main/java/com/szwl/model/bean/ProductVo.java

@@ -1,6 +1,8 @@
 package com.szwl.model.bean;
 
+import lombok.Data;
 
+@Data
 public class ProductVo implements Comparable<ProductVo> {
 
     /**
@@ -30,69 +32,17 @@ public class ProductVo implements Comparable<ProductVo> {
     private String productName;
 
     /**
+     * 商品编号
+     */
+    private String productNo;
+
+    /**
      * 是否显示  0:显示 1:屏蔽
      */
     private String showType;
 
     private String id;
 
-    public String getShowType() {
-        return showType;
-    }
-
-    public void setShowType(String showType) {
-        this.showType = showType;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getProductName() {
-        return productName;
-    }
-
-    public void setProductName(String productName) {
-        this.productName = productName;
-    }
-
-    public String getClientId() {
-        return clientId;
-    }
-
-    public void setClientId(String clientId) {
-        this.clientId = clientId;
-    }
-
-    public Double getRmbPrice() {
-        return rmbPrice;
-    }
-
-    public void setRmbPrice(Double rmbPrice) {
-        this.rmbPrice = rmbPrice;
-    }
-
-    public Double getCodePrice() {
-        return codePrice;
-    }
-
-    public void setCodePrice(Double codePrice) {
-        this.codePrice = codePrice;
-    }
-
-    public Boolean getSellStatus() {
-        return sellStatus;
-    }
-
-    public void setSellStatus(Boolean sellStatus) {
-
-        this.sellStatus = sellStatus;
-    }
-
     @Override
     public int compareTo(ProductVo o) {
         return this.getId().compareTo(o.getId());