Explorar o código

清洗逻辑优化

李天标 %!s(int64=5) %!d(string=hai) anos
pai
achega
8c3ecf0528

+ 29 - 2
app-api/src/main/java/com/hboxs/control/api/equipment/CleanController.java

@@ -286,8 +286,24 @@ public class CleanController extends BaseController {
             }
         }
         JSONObject jsonObject = new JSONObject();
+
+        if(overdueDate==null||overdueDate.equals("")){
+            Date date = new Date();
+            SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//日期格式
+            overdueDate = sformat.format(date);
+        }else{
+            if(overdueDate.endsWith(".0")){
+                overdueDate = overdueDate.substring(0,overdueDate.length()-2);
+            }
+        }
+        if(remaining==null||remaining.equals("")){
+            remaining = "0";
+        }
         jsonObject.put("overdueDate", overdueDate);
         jsonObject.put("remaining", remaining);
+        equipment.setRemaining(remaining);
+        equipment.setOverdueDate(overdueDate);
+        equipmentService.update(equipment);
         return jsonObject;
     }
 
@@ -324,18 +340,29 @@ public class CleanController extends BaseController {
                 equipment.setRemaining(String.valueOf(re));
                 equipmentService.update(equipment);
                 if(re==0){
-                    return "机器已过期";
+                    return JsonMessage.success("机器已过期");
                 }
             }
         } catch (ParseException e) {
             e.printStackTrace();
         }
 
-        return "success";
+        return JsonMessage.success("success");
     }
     private String getMessage(String content, String name, String clientId) {
         String message = "您好,机器" + content + ",机器名:" + name + ",设备号:" + clientId;
         return message;
     }
 
+    /**
+     * 获取时间
+     */
+    @RequestMapping(value = "/getTime", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
+    @ResponseBody
+    public Object getTime() {
+        Date date = new Date();
+        SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//日期格式
+         return JsonMessage.success(sformat.format(date));
+    }
+
 }

+ 6 - 3
app-api/src/main/java/com/hboxs/control/api/order/OrderController.java

@@ -1276,8 +1276,8 @@ public class OrderController extends BaseController {
             orderService.update(order);
 
             JSONObject kindData = new JSONObject();
-            kindData.put("sn" , order.getSn());
-            kindData.put("productName" , order.getProductName());
+//            kindData.put("sn" , order.getSn());
+//            kindData.put("productName" , order.getProductName());
 
             Equipment byClientId = equipmentService.findByClientId(order.getClientId());
             List<Price> priceList = priceService.findAll();
@@ -1353,11 +1353,14 @@ public class OrderController extends BaseController {
                 }else{
                     int value = number.intValue();
                     byClientId.setRemaining(String.valueOf(value));
+                    equipmentService.update(byClientId);
                 }
 
             }
             String gtClientId = byClientId.getGtClientId();
-
+            kindData.put("overdueDate" , byClientId.getOverdueDate());
+            kindData.put("remaining" , byClientId.getRemaining());
+            PushUtils.push(byClientId.getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("paySuccess", kindData.toString()).toString());
 //            PushUtils.push(gtClientId, "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
 //            PushUtils.push(equipmentService.findByClientId(order.getClientId()).getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
             order.setNote(gtClientId+"已推送");

+ 1 - 1
app-backend-web/src/main/webapp/WEB-INF/template/admin/common/index.ftl

@@ -136,7 +136,7 @@
                             <li id="regular">0次</li>
                         </ul>
                         <ul>
-                            <li>今日随机清洗次数</li>
+                            <li>今日自动清洗次数</li>
                             <li>今日总清洗次数</li>
                             <li>今日定时清洗次数</li>
                         </ul>