Selaa lähdekoodia

修改bug,及首页接口上半部。

李天标 5 vuotta sitten
vanhempi
commit
d2958f376b

+ 2 - 0
app-backend-web/src/main/java/com/hboxs/control/admin/AdminController.java

@@ -10,8 +10,10 @@ import com.hboxs.common.Message;
 import com.hboxs.common.Pageable;
 import com.hboxs.entity.Admin;
 import com.hboxs.entity.BaseEntity.Save;
+import com.hboxs.entity.Equipment;
 import com.hboxs.entity.Role;
 import com.hboxs.service.AdminService;
+import com.hboxs.service.EquipmentService;
 import com.hboxs.service.GlobalConfigService;
 import com.hboxs.service.RoleService;
 import org.apache.commons.codec.digest.DigestUtils;

+ 2 - 5
app-backend-web/src/main/java/com/hboxs/control/admin/CleanHistoryController.java

@@ -7,12 +7,10 @@ package com.hboxs.control.admin;
 
 import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
-import com.hboxs.common.Filter;
-import com.hboxs.common.JsonMessage;
-import com.hboxs.common.Message;
-import com.hboxs.common.Pageable;
+import com.hboxs.common.*;
 import com.hboxs.entity.Admin;
 import com.hboxs.entity.AlarmRecord;
+import com.hboxs.entity.CleanHistory;
 import com.hboxs.excel.AlarmRecordTarget;
 import com.hboxs.service.AdminService;
 import com.hboxs.service.AlarmRecordService;
@@ -161,7 +159,6 @@ public class CleanHistoryController extends BaseController {
 //        model.addAttribute("alarmContent", alarmContent);
         model.addAttribute("admin", adminService.getCurrent());
         model.addAttribute("page", cleanHistoryService.findPage(pageable));
-//        model.addAttribute("type", type);
         return "/admin/cleanHistory/list";
     }
 

+ 12 - 12
app-backend-web/src/main/java/com/hboxs/control/admin/EquipmentApplyController.java

@@ -130,10 +130,10 @@ public class EquipmentApplyController extends BaseController {
                     if (status.equals("agreed")) {
                         String clientId = equipmentApply.getClientId();
                         //判端是否有默认规则
-                        if (timeRuleService.find(Long.valueOf(1)) == null) {
-                            addFlashMessage(redirectAttributes, Message.error("请先填写默认广告规则"));
-                            return "redirect:listInit.htm";
-                        }
+//                        if (timeRuleService.find(Long.valueOf(1)) == null) {
+//                            addFlashMessage(redirectAttributes, Message.error("请先填写默认广告规则"));
+//                            return "redirect:listInit.htm";
+//                        }
                         //判断是否设备初始化
                         if (equipmentService.findByClientId(clientId) != null) {
                             addFlashMessage(redirectAttributes, Message.error("该设备已经初始化"));
@@ -169,11 +169,11 @@ public class EquipmentApplyController extends BaseController {
                             equipment.setType(Equipment.Type.forValue(type));
                             equipmentService.update(equipment);
                             addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
-                            PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
+                            PushUtils.push(equipmentApply.getGtClientId(), "设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
                             equipmentApplyService.update(equipmentApply);
                             return "redirect:listInit.htm";
                         }
-                        PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
+                        PushUtils.push(equipmentApply.getGtClientId(), "设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
                         Equipment equipment = new Equipment();
                         equipment.setClientId(clientId);
                         equipment.setManagerId(equipmentApply.getManagerId());
@@ -197,17 +197,17 @@ public class EquipmentApplyController extends BaseController {
                         //获取设备的id
                         Long equipmentId = equipmentService.findByClientId(clientId).getId();
                         if (!productService.exists(Filter.eq("equipmentId", equipmentId))) {
-                            if(equipmentApply.getEquimentType().equals("MG280")){
-                                saveProductMG280(equipmentId);
-                            }else{
-                                saveProduct(equipmentId);
-                            }
+//                            if(equipmentApply.getEquimentType().equals("MG280")){
+//                                saveProductMG280(equipmentId);
+//                            }else{
+//                                saveProduct(equipmentId);
+//                            }
 
                         }
 
                     } else if (status.equals("rejected")) {
                         equipmentApply.setStatusType(EquipmentApply.StatusType.rejected);
-                        PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "拒绝", PushUtils.buildJson("statusType", "rejected").toString());
+                        PushUtils.push(equipmentApply.getGtClientId(), "设备初始化申请", "拒绝", PushUtils.buildJson("statusType", "rejected").toString());
                     }
                     equipmentApplyService.update(equipmentApply);
 

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

@@ -77,20 +77,20 @@ public class EquipmentController extends BaseController {
         Equipment equipment = equipmentService.find(id);
         model.addAttribute("equipment", equipment);
         String rule = equipment.getRule();
-        if(rule.length()>1){
-            String[] split = rule.split(",");
-            List<String> list = new ArrayList<>(Arrays.asList(split));
-            model.addAttribute("rules", list);
-            if(list.size()<10){
-                List<String> lis = new ArrayList<>();
-                for(int i = 0;i<(10-list.size());i++){
-                    lis.add("a");
-                }
-                model.addAttribute("rulesCkche", lis);
-            }
-        }
-        List<TimeRule> timeRules = timeRuleService.findAll();
-        model.addAttribute("timeRules", timeRules);
+//        if(rule.length()>1){
+//            String[] split = rule.split(",");
+//            List<String> list = new ArrayList<>(Arrays.asList(split));
+//            model.addAttribute("rules", list);
+//            if(list.size()<10){
+//                List<String> lis = new ArrayList<>();
+//                for(int i = 0;i<(10-list.size());i++){
+//                    lis.add("a");
+//                }
+//                model.addAttribute("rulesCkche", lis);
+//            }
+//        }
+//        List<TimeRule> timeRules = timeRuleService.findAll();
+//        model.addAttribute("timeRules", timeRules);
         String type = adminService.getCurrent().getType().toValue();
         model.addAttribute("type", type);
         Long timeRuleId = equipment.getTimeRuleId();
@@ -305,7 +305,7 @@ public class EquipmentController extends BaseController {
                 break;
             //远程锁机
             case "clean":
-                PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("clean", eqeStatus).toString());
+                PushUtils.push(equipment.getGtClientId(), "清洗", "清洗", PushUtils.buildJson("clean", eqeStatus).toString());
                 break;
             //远程开启设备睡眠状态
             case "sleep":

+ 364 - 0
app-backend-web/src/main/java/com/hboxs/control/admin/IndexController.java

@@ -0,0 +1,364 @@
+/*
+ *
+ *
+ *
+ */
+package com.hboxs.control.admin;
+
+import com.hboxs.common.Filter;
+import com.hboxs.common.Message;
+import com.hboxs.common.Pageable;
+import com.hboxs.entity.*;
+import com.hboxs.entity.BaseEntity.Save;
+import com.hboxs.service.*;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang.StringUtils;
+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.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * Controller -
+ */
+@Controller("indexController")
+@RequestMapping("/asl-admin/index")
+public class IndexController extends BaseController {
+
+    @Resource(name = "adminServiceImpl")
+    private AdminService adminService;
+    @Resource(name = "roleServiceImpl")
+    private RoleService roleService;
+    @Resource(name = "globalConfigServiceImpl")
+    private GlobalConfigService globalConfigService;
+    @Resource(name = "equipmentServiceImpl")
+    private EquipmentService equipmentService;
+    @Resource(name = "cleanHistoryServiceImpl")
+    private CleanHistoryService cleanHistoryService;
+    @Resource(name = "alarmRecordServiceImpl")
+    private AlarmRecordService alarmRecordService;
+
+    /**
+     * 检查用户名是否存在
+     */
+    @RequestMapping(value = "/check_username", method = RequestMethod.GET)
+    public
+    @ResponseBody
+    boolean checkUsername(String username) {
+
+        if(adminService.getCurrent().getType()  == Admin.Type.merchant || adminService.getCurrent().getType()  == Admin.Type.personage ){
+            return false;
+        }
+
+
+
+        if (StringUtils.isEmpty(username)) {
+            return false;
+        }
+
+        List<Filter> fs = new ArrayList<>();
+
+        Admin.Type type = adminService.getCurrent().getType();
+        switch (type) {
+            case agency:
+                fs.add(Filter.eq("type", Admin.Type.agency));
+                fs.add(Filter.eq("agencyId", adminService.getCurrent().getAgencyId()));
+                break;
+            case merchant:
+                fs.add(Filter.eq("type", Admin.Type.merchant));
+                fs.add(Filter.eq("agencyId", adminService.getCurrent().getAgencyId()));
+                fs.add(Filter.isNotNull("merchantId"));
+                fs.add(Filter.eq("merchantId", adminService.getCurrent().getMerchantId()));
+                break;
+            case personage:
+                fs.add(Filter.eq("type", Admin.Type.personage));
+                fs.add(Filter.eq("personageId", adminService.getCurrent().getPersonageId()));
+                break;
+            case admin:
+                fs.add(Filter.eq("type", Admin.Type.admin));
+        }
+        fs.add(Filter.eq("username" , username));
+
+
+        List<Admin> as = adminService.findList(1, fs , null);
+        if(as!=null&&as.size()>0){
+            return false;
+        }
+        return true;
+    }
+    /**
+     *今日人流量
+     */
+    @RequestMapping(value = "/peopleCounting", method = RequestMethod.GET)
+    public Integer peopleCounting(ModelMap model , RedirectAttributes redirectAttributes) {
+        int number = 0;
+        Admin admin = adminService.getCurrent();
+        List<Equipment> equipmentList = equipmentService.findByAdminId(admin.getId());
+        for(Equipment equipment:equipmentList){
+            //今日人流量
+            if(equipment.getPeopleCounting()!=null){
+                number+=equipment.getPeopleCounting();
+            }
+        }
+        model.addAttribute("peopleCounting", number);
+        return number;
+    }
+    /**
+     *机器启动数量/机器总数量
+     */
+    @RequestMapping(value = "/equipmentNumber", method = RequestMethod.GET)
+    public Map<String,Integer> equipmentNumber(ModelMap model , RedirectAttributes redirectAttributes) {
+        Map<String,Integer> map = new HashMap<>();
+        Admin admin = adminService.getCurrent();
+        List<Equipment> equipmentList = equipmentService.findByAdminId(admin.getId());
+        int on = 0;
+        for(Equipment equipment:equipmentList){
+            //开启的机器数量
+            if(equipment.getEqeStatus()==1){
+                on++;
+            }
+        }
+        map.put("totalNum",equipmentList.size());
+        map.put("openNum",on);
+        model.addAttribute("equipmentNumber", map);
+        return map;
+    }
+    /**
+     *今日定时清洗次数/随机清洗次数
+     */
+    @RequestMapping(value = "/cleanNumber", method = RequestMethod.GET)
+    public Map<String,Integer> cleanNumber(ModelMap model , RedirectAttributes redirectAttributes) {
+        Map<String,Integer> map = new HashMap<>();
+        Admin admin = adminService.getCurrent();
+        List<Filter> fs = new ArrayList<>();
+        List<Filter> fs1 = new ArrayList<>();
+        String beginEndDate = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        Date date = new Date();
+        String startToday = simpleDateFormat.format(date);
+        SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
+        String endToday = _format.format(date);
+        beginEndDate = startToday + " - " + endToday;
+        Date begin = null;
+        Date end = null;
+        if (!StringUtils.isEmpty(beginEndDate)) {
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+            try {
+                begin = simpleDateFormat1.parse(beginEndDate.split(" - ")[0].trim());
+                end = simpleDateFormat1.parse(beginEndDate.split(" - ")[1].trim());
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+        fs.add(Filter.eq("type", 0));
+        fs.add(Filter.eq("adminId", admin.getId()));
+        fs.add(Filter.geDate("createDate", begin));
+        fs.add(Filter.leDate("createDate", end));
+        List<CleanHistory> list1 = cleanHistoryService.findList(99999, fs, null);
+        fs1.add(Filter.eq("type", 1));
+        fs1.add(Filter.eq("adminId", admin.getId()));
+        fs1.add(Filter.geDate("createDate", begin));
+        fs1.add(Filter.leDate("createDate", end));
+        List<CleanHistory> list2 = cleanHistoryService.findList(99999, fs1, null);
+        int random = 0;
+        if(list2!=null){
+            random+=list2.size();
+        }
+        int regular = 0;
+        if(list1!=null){
+            regular+=list1.size();
+        }
+        map.put("random",random);
+        map.put("regular",regular);
+        model.addAttribute("cleanNumber", map);
+        return map;
+    }
+    /**
+     *机器的状态,温度,湿度,清洗剂的剩余用量
+     */
+    @RequestMapping(value = "/equipmentStatus", method = RequestMethod.GET)
+    public List<Equipment> equipmentStatus(ModelMap model , RedirectAttributes redirectAttributes) {
+        List<Equipment> equipmentList = new ArrayList<>();
+        Admin admin = adminService.getCurrent();
+        equipmentList = equipmentService.findByAdminId(admin.getId());
+        model.addAttribute("equipmentList", equipmentList);
+        return equipmentList;
+    }
+    /**
+     *机器今日的报警记录
+     */
+    @RequestMapping(value = "/alarmRecordList", method = RequestMethod.GET)
+    public List<AlarmRecord> alarmRecordList(ModelMap model , RedirectAttributes redirectAttributes) {
+        List<AlarmRecord> alarmRecordList = new ArrayList<>();
+        Admin admin = adminService.getCurrent();
+        List<Filter> fs = new ArrayList<>();
+        String beginEndDate = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        Date date = new Date();
+        String startToday = simpleDateFormat.format(date);
+        SimpleDateFormat _format = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
+        String endToday = _format.format(date);
+        beginEndDate = startToday + " - " + endToday;
+        Date begin = null;
+        Date end = null;
+        if (!StringUtils.isEmpty(beginEndDate)) {
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+            try {
+                begin = simpleDateFormat1.parse(beginEndDate.split(" - ")[0].trim());
+                end = simpleDateFormat1.parse(beginEndDate.split(" - ")[1].trim());
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+        fs.add(Filter.eq("adminId", admin.getId()));
+        fs.add(Filter.geDate("createDate", begin));
+        fs.add(Filter.leDate("createDate", end));
+        alarmRecordList = alarmRecordService.findList(999, fs, null);
+        return alarmRecordList;
+    }
+
+    /**
+     *机器消耗的资源
+     */
+    @RequestMapping(value = "/consumedResources", method = RequestMethod.GET)
+    public Map<String,Integer> consumedResources(String time,ModelMap model , RedirectAttributes redirectAttributes) {
+        Map<String,Integer> map = new HashMap<>();
+        Admin admin = adminService.getCurrent();
+        List<Filter> fs = new ArrayList<>();
+        fs.add(Filter.eq("adminId", admin.getId()));
+        int electricity = 0;
+        int water = 0;
+        if(time.equals("All")){
+            List<CleanHistory> cleanHistoryList = cleanHistoryService.findAll();
+            for(CleanHistory cleanHistory:cleanHistoryList){
+                if(cleanHistory.getElectricity()!=null){
+                    electricity+=cleanHistory.getElectricity();
+                }
+                if(cleanHistory.getWater()!=null){
+                    water+=cleanHistory.getWater();
+                }
+            }
+        }else if(time.length()==4){
+            Date begin = null;
+            Date end = null;
+            begin = beginY(time);
+            end = endY(time);
+            fs.add(Filter.geDate("createDate", begin));
+            fs.add(Filter.leDate("createDate", end));
+            List<CleanHistory> list = cleanHistoryService.findList(99999, fs, null);
+            for(CleanHistory cleanHistory:list){
+                if(cleanHistory.getElectricity()!=null){
+                    electricity+=cleanHistory.getElectricity();
+                }
+                if(cleanHistory.getWater()!=null){
+                    water+=cleanHistory.getWater();
+                }
+            }
+        }else {
+            Date begin = null;
+            Date end = null;
+            begin = beginM(time);
+            end = endM(time);
+            fs.add(Filter.geDate("createDate", begin));
+            fs.add(Filter.leDate("createDate", end));
+            List<CleanHistory> list = cleanHistoryService.findList(99999, fs, null);
+            for(CleanHistory cleanHistory:list){
+                if(cleanHistory.getElectricity()!=null){
+                    electricity+=cleanHistory.getElectricity();
+                }
+                if(cleanHistory.getWater()!=null){
+                    water+=cleanHistory.getWater();
+                }
+            }
+        }
+        map.put("electricity",electricity);
+        map.put("water",water);
+        return map;
+    }
+
+    private Date beginY(String time) {
+        Date dater = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
+        Date date = null;
+        try {
+            date = simpleDateFormat.parse(time);
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String startToday = simpleDateFormat1.format(date);
+            dater = simpleDateFormat1.parse(startToday);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return dater;
+    }
+    private Date endY(String time) {
+        Date dater = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
+        Date date = null;
+        try {
+            date = simpleDateFormat.parse(time);
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-12-31 23:59:59");
+            String startToday = simpleDateFormat1.format(date);
+            SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            dater = simpleDateFormat2.parse(startToday);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return dater;
+    }
+
+    private Date beginM(String time) {
+        Date dater = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+        Date date = null;
+        try {
+            date = simpleDateFormat.parse(time);
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String startToday = simpleDateFormat1.format(date);
+            dater = simpleDateFormat1.parse(startToday);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return dater;
+    }
+    private Date endM(String time) {
+        String[] split = time.split("-");
+        int year = Integer.parseInt(split[0]);
+        int month = Integer.parseInt(split[1]);
+        Calendar cal = Calendar.getInstance();
+        //设置年份
+        cal.set(Calendar.YEAR,year);
+        //设置月份
+        cal.set(Calendar.MONTH, month-1);
+        //获取某月最大天数
+        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
+        //设置日历中月份的最大天数
+        cal.set(Calendar.DAY_OF_MONTH, lastDay);
+        //格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String lastDayOfMonth = sdf.format(cal.getTime());
+        Date dater = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+        Date date = null;
+        try {
+            date = simpleDateFormat.parse(lastDayOfMonth);
+            SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
+            String startToday = simpleDateFormat1.format(date);
+            SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            dater = simpleDateFormat2.parse(startToday);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return dater;
+    }
+}

+ 5 - 0
app-entity/src/main/java/com/hboxs/entity/AlarmRecord.java

@@ -136,6 +136,11 @@ public class AlarmRecord extends BaseEntity {
      */
     private Long personageId;
 
+    /**
+     * 小区域地点
+     */
+    private String site;
+
 
     public String getClientId() {
         return clientId;

+ 25 - 0
app-entity/src/main/java/com/hboxs/entity/Equipment.java

@@ -114,6 +114,10 @@ public class Equipment extends BaseEntity {
      * 地区完整名称
      */
     private String fullName;
+    /**
+     * 小区域名称
+     */
+    private String site;
 
 
     public enum PayType {
@@ -409,6 +413,27 @@ public class Equipment extends BaseEntity {
      */
     private String  rule;
 
+    /**
+     * 人流量
+     */
+    private Long  peopleCounting;
+
+    public Long getPeopleCounting() {
+        return peopleCounting;
+    }
+
+    public void setPeopleCounting(Long peopleCounting) {
+        this.peopleCounting = peopleCounting;
+    }
+
+    public String getSite() {
+        return site;
+    }
+
+    public void setSite(String site) {
+        this.site = site;
+    }
+
     public String getCleaner() {
         return cleaner;
     }