浏览代码

添加厕所格子

李天标 4 年之前
父节点
当前提交
3f84eb59bb

+ 59 - 4
app-api/src/main/java/com/hboxs/control/api/equipment/IndexController.java

@@ -10,10 +10,7 @@ import com.hboxs.common.JsonMessage;
 import com.hboxs.common.utils.AdminUtils;
 import com.hboxs.common.utils.PushUtils;
 import com.hboxs.control.api.BaseController;
-import com.hboxs.entity.Admin;
-import com.hboxs.entity.Equipment;
-import com.hboxs.entity.EquipmentApply;
-import com.hboxs.entity.Proportion;
+import com.hboxs.entity.*;
 import com.hboxs.service.*;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
@@ -45,6 +42,9 @@ public class IndexController extends BaseController {
     @Resource(name = "proportionServiceImpl")
     private ProportionService proportionService;
 
+    @Resource(name = "boxServiceImpl")
+    private BoxService boxService;
+
     /**
      * 心跳
      *
@@ -260,6 +260,61 @@ public class IndexController extends BaseController {
     }
 
     /**
+     * 添加厕所格子(有多少个坑)
+     *
+     * @param clientId  个推
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/createBox", method = RequestMethod.POST)
+    @ResponseBody
+    public JsonMessage createBox(String clientId,String number){
+        Equipment equipment = equipmentService.findByClientId(clientId);
+        List<Filter> fs = new ArrayList<>();
+        fs.add(Filter.eq("equipmentId", equipment.getId()));
+        List<Box> boxList = boxService.findList(100, fs, null);
+        if(boxList.size()>0){
+            for(Box box:boxList){
+                boxService.delete(box.getId());
+            }
+        }
+        int j = Integer.parseInt(number);
+        for(int i = 1;i <= j;i++){
+            Box newBox = new Box();
+            newBox.setAdminId(String.valueOf(equipment.getAdminId()));
+            newBox.setEquipmentId(String.valueOf(equipment.getId()));
+            newBox.setStatus("0");
+            newBox.setSn(i+"号");
+            boxService.save(newBox);
+        }
+        return JsonMessage.success("添加成功");
+    }
+    /**
+     * 添加厕所格子(有多少个坑)
+     *
+     * @param clientId  个推
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/updateBox", method = RequestMethod.POST)
+    @ResponseBody
+    public JsonMessage updateBox(String clientId,String sn,String status){
+        Equipment equipment = equipmentService.findByClientId(clientId);
+        List<Filter> fs = new ArrayList<>();
+        fs.add(Filter.eq("equipmentId", equipment.getId()));
+        fs.add(Filter.eq("sn", sn));
+        List<Box> boxList = boxService.findList(10, fs, null);
+        if(boxList.size()>0){
+            Box box = boxList.get(0);
+            box.setStatus(status);
+            boxService.update(box);
+        }else{
+            return JsonMessage.success("没找到该编号");
+        }
+
+        return JsonMessage.success("修改成功");
+    }
+    /**
      * 商品调价
      */
     @RequestMapping(value = "/updateProduct", method = RequestMethod.POST)

+ 9 - 0
app-api/src/main/java/com/hboxs/control/api/order/OrderController.java

@@ -1308,6 +1308,11 @@ public class OrderController extends BaseController {
                     try {
                         date= formatter.parse(overdueDate);
                         long time = date.getTime();
+                        Date date1 = new Date();
+                        long nowTime = date1.getTime();
+                        if(time<nowTime){
+                            time = nowTime;
+                        }
                         long dayN = dayNumber*24*3600*1000;
                         long finalTime = time + dayN;
                         Date dates = new Date(finalTime);
@@ -1344,6 +1349,10 @@ public class OrderController extends BaseController {
                 BigDecimal number = price.divide(pri);
                 String remaining = byClientId.getRemaining();
                 if(remaining!=null&&remaining.length()>0){
+                    long re  = Long.parseLong(remaining);
+                    if(re<0){
+                        remaining = "0";
+                    }
                     BigDecimal rmain = BigDecimal.valueOf(Double.valueOf(remaining));
                     BigDecimal remian = rmain.add(number);
                     int value = remian.intValue();

+ 45 - 0
app-backend-web/src/main/java/com/hboxs/control/admin/BoxController.java

@@ -0,0 +1,45 @@
+package com.hboxs.control.admin;
+
+import com.hboxs.ViewObject.AreaVo;
+import com.hboxs.common.Filter;
+import com.hboxs.common.Message;
+import com.hboxs.common.Pageable;
+import com.hboxs.common.utils.JsonUtils;
+import com.hboxs.common.utils.PushUtils;
+import com.hboxs.entity.AD;
+import com.hboxs.entity.Admin;
+import com.hboxs.entity.Area;
+import com.hboxs.entity.Equipment;
+import com.hboxs.service.*;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Controller -
+ */
+@Controller("adminBoxController")
+@RequestMapping("/asl-admin/box")
+public class BoxController extends BaseController {
+
+    @Resource(name = "boxServiceImpl")
+    private BoxService boxService;
+
+
+
+
+}

+ 50 - 4
app-backend-web/src/main/java/com/hboxs/control/admin/EquipmentController.java

@@ -23,10 +23,9 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * Controller - 设备管理器
@@ -322,6 +321,29 @@ public class EquipmentController extends BaseController {
                 break;
             //远程锁机
             case "clean":
+                Date now = new Date();
+                long nowTime = now.getTime();
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String overdueDate = equipment.getOverdueDate();
+                Date date = null;
+                try {
+                    date = sdf.parse(overdueDate);
+                    long overdueTime = date.getTime();
+                    if(nowTime>overdueTime){
+                        String remaining = equipment.getRemaining();
+                        if(StringUtils.isEmpty(remaining)){
+                            return ERROR_MESSAGE;
+                        }
+                        int re = Integer.parseInt(remaining)-1;
+                        equipment.setRemaining(String.valueOf(re));
+                        equipmentService.update(equipment);
+                        if(re<0){
+                            return ERROR_MESSAGE;
+                        }
+                    }
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
                 PushUtils.push(equipment.getGtClientId(), "清洗", "清洗", PushUtils.buildJson("clean", eqeStatus).toString());
                 break;
             //远程开启设备睡眠状态
@@ -461,7 +483,31 @@ public class EquipmentController extends BaseController {
     @GetMapping("/cleanPositionNum")
     @ResponseBody
     public Message cleanPositionNum(String clientId,String val){
+        //todo 检验是否过期
         Equipment equipment = equipmentService.findByClientId(clientId);
+        Date now = new Date();
+        long nowTime = now.getTime();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String overdueDate = equipment.getOverdueDate();
+        Date date = null;
+        try {
+            date = sdf.parse(overdueDate);
+            long overdueTime = date.getTime();
+            if(nowTime>overdueTime){
+                String remaining = equipment.getRemaining();
+                if(StringUtils.isEmpty(remaining)){
+                    return ERROR_MESSAGE;
+                }
+                int re = Integer.parseInt(remaining)-1;
+                equipment.setRemaining(String.valueOf(re));
+                equipmentService.update(equipment);
+                if(re<0){
+                    return ERROR_MESSAGE;
+                }
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
         PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("cleanPositionNum", val).toString());
         return SUCCESS_MESSAGE;
     }

+ 8 - 3
app-backend-web/src/main/webapp/WEB-INF/template/admin/equipment/edit.ftl

@@ -444,8 +444,7 @@
         <div class="layui-form-item">
             <div class="layui-input-block ">
 
-            [#--<td><input id="editProduct" type="submit" value="提交" /></td>
-            <td><input  type="reset" value="重置" /></td>--]
+
                 <td align="center">
                     <input id="editProduct" class="button" type="submit" value="提交并推送设备更新"/>
                     <input type="button" class="button" value="取消"
@@ -1288,8 +1287,14 @@
             contentType: 'application/json;charset=utf-8',
             // data: JSON.stringify(commonParam),
             success: function (data) {
-                layer.msg("发送成功");
+                if (data.type == "success") {
+
+                    layer.msg("发送成功");
+                } else {
+                    layer.msg("机器已过期,请续费");
+                }
             }
+
         })
     }
 </script>

+ 7 - 1
app-backend-web/src/main/webapp/WEB-INF/template/admin/equipment/list.ftl

@@ -421,7 +421,13 @@
 
                         location.reload();
                     } else {
-                        layer.msg("执行失败");
+                        if(url=="clean.htm"){
+                            layer.msg("机器已过期,请续费");
+                        }else {
+                            layer.msg("执行失败");
+                        }
+
+
                     }
                 }
             });

+ 16 - 0
app-dao/src/main/java/com/hboxs/dao/BoxDao.java

@@ -0,0 +1,16 @@
+/*
+ *
+ *  ADDao
+ *
+ */
+package com.hboxs.dao;
+
+import com.hboxs.entity.AD;
+import com.hboxs.entity.Box;
+
+/**
+ * Dao -
+ */
+public interface BoxDao extends BaseDao<Box, Long> {
+
+}

+ 20 - 0
app-dao/src/main/java/com/hboxs/dao/impl/BoxDaoImpl.java

@@ -0,0 +1,20 @@
+/*
+ *
+ *  ADDaoImpl
+ *
+ */
+package com.hboxs.dao.impl;
+
+import com.hboxs.dao.ADDao;
+import com.hboxs.dao.BoxDao;
+import com.hboxs.entity.AD;
+import com.hboxs.entity.Box;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Dao -
+ */
+@Repository("boxDaoImpl")
+public class BoxDaoImpl extends BaseDaoImpl<Box, Long> implements BoxDao {
+
+}

+ 66 - 0
app-entity/src/main/java/com/hboxs/entity/Box.java

@@ -0,0 +1,66 @@
+package com.hboxs.entity;
+
+
+import javax.persistence.Entity;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "t_box")
+@SequenceGenerator(name = "sequenceGenerator", sequenceName = "t_box_sequence")
+public class Box extends BaseEntity {
+    private static final long serialVersionUID = -6613252029623957372L;
+    /**
+     * 厕所编号
+     */
+    private String sn;
+
+    /**
+     *
+     */
+    private String adminId;
+
+    /**
+     *
+     */
+    private String equipmentId;
+
+    /**
+     * 状态  0:无人使用 1:正在使用 2:正在清洗
+     */
+    private String status;
+
+
+
+    public String getSn() {
+        return sn;
+    }
+
+    public void setSn(String sn) {
+        this.sn = sn;
+    }
+
+    public String getAdminId() {
+        return adminId;
+    }
+
+    public void setAdminId(String adminId) {
+        this.adminId = adminId;
+    }
+
+    public String getEquipmentId() {
+        return equipmentId;
+    }
+
+    public void setEquipmentId(String equipmentId) {
+        this.equipmentId = equipmentId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 16 - 0
app-service/src/main/java/com/hboxs/service/BoxService.java

@@ -0,0 +1,16 @@
+/*
+ *
+ * ADService
+ *
+ */
+package com.hboxs.service;
+
+import com.hboxs.entity.AD;
+import com.hboxs.entity.Box;
+
+/**
+ * Service -
+ */
+public interface BoxService extends BaseService<Box, Long> {
+
+}

+ 33 - 0
app-service/src/main/java/com/hboxs/service/impl/BoxServiceImpl.java

@@ -0,0 +1,33 @@
+/*
+ *
+ *  ADServiceImpl
+ *
+ */
+package com.hboxs.service.impl;
+
+import com.hboxs.dao.ADDao;
+import com.hboxs.dao.BoxDao;
+import com.hboxs.entity.AD;
+import com.hboxs.entity.Box;
+import com.hboxs.service.ADService;
+import com.hboxs.service.BoxService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * Service -
+ */
+@Service("boxServiceImpl")
+public class BoxServiceImpl extends BaseServiceImpl<Box, Long> implements BoxService {
+
+    @Resource(name = "boxDaoImpl")
+    private BoxDao boxDao;
+
+    @Resource(name = "boxDaoImpl")
+    public void setBaseDao(BoxDao boxDao) {
+        super.setBaseDao(boxDao);
+    }
+
+
+}