部门分餐表临时提交
diff --git a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
index f05e285..7d42137 100644
--- a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
@@ -395,6 +395,7 @@
             tTransdtl.setManagefeetype(bean.getRuletype());
             tTransdtl.setAmount(cntamount);
         }else{
+            tTransdtl.setManagefeetype(RestaurantConstant.RULETYPE_NORMAL);
             tTransdtl.setAmount(amount);
             tTransdtl.setManagefee(cntamount);
         }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlList.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlList.java
new file mode 100644
index 0000000..a0d84eb
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlList.java
@@ -0,0 +1,21 @@
+package com.supwisdom.dlpay.restaurant.bean;
+
+
+public interface MealsDtlList {
+
+    String getCheckdate();
+
+    String getMealtype();
+
+    String getDeptcode();
+
+    String getGroupname();
+
+    Double getAmount();
+
+    Integer getCnt();
+
+    Double getFeeamount();
+
+    Integer getFeecount();
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlSearchBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlSearchBean.java
new file mode 100644
index 0000000..5db77bd
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlSearchBean.java
@@ -0,0 +1,42 @@
+package com.supwisdom.dlpay.restaurant.bean;
+
+import com.supwisdom.dlpay.system.bean.PageBean;
+
+public class MealsDtlSearchBean extends PageBean {
+    private String startdate;
+    private String enddate;
+    private Integer groupid;
+
+    public String getStartdate() {
+        return startdate;
+    }
+
+    public void setStartdate(String startdate) {
+        this.startdate = startdate;
+    }
+
+    public String getEnddate() {
+        return enddate;
+    }
+
+    public void setEnddate(String enddate) {
+        this.enddate = enddate;
+    }
+
+    public Integer getGroupid() {
+        return groupid;
+    }
+
+    public void setGroupid(Integer groupid) {
+        this.groupid = groupid;
+    }
+
+    @Override
+    public String toString() {
+        return "MealsDtlSearchBean{" +
+                "startdate='" + startdate + '\'' +
+                ", enddate='" + enddate + '\'' +
+                ", groupid=" + groupid +
+                '}';
+    }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlShowBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlShowBean.java
new file mode 100644
index 0000000..d1577aa
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/MealsDtlShowBean.java
@@ -0,0 +1,213 @@
+package com.supwisdom.dlpay.restaurant.bean;
+
+
+public class MealsDtlShowBean {
+    private String devgroupname;
+    private Integer devicename;
+    private String checkdate;
+    private Double b_amt;
+    private Integer b_cnt;
+    private Integer b_feecnt;
+    private Double b_feeamt;
+    private Double b_getamt;
+    private Double d_amt;
+    private Integer d_cnt;
+    private Integer d_feecnt;
+    private Double d_feeamt;
+    private Double d_getamt;
+    private Double l_amt;
+    private Integer l_cnt;
+    private Integer l_feecnt;
+    private Double l_feeamt;
+    private Double l_getamt;
+    private Double t_amt;
+    private Integer t_cnt;
+    private Integer t_feecnt;
+    private Double t_feeamt;
+    private Double t_getamt;
+
+
+    public String getDevgroupname() {
+        return devgroupname;
+    }
+
+    public void setDevgroupname(String devgroupname) {
+        this.devgroupname = devgroupname;
+    }
+
+    public Integer getDevicename() {
+        return devicename;
+    }
+
+    public void setDevicename(Integer devicename) {
+        this.devicename = devicename;
+    }
+
+    public String getCheckdate() {
+        return checkdate;
+    }
+
+    public void setCheckdate(String checkdate) {
+        this.checkdate = checkdate;
+    }
+
+    public Double getB_amt() {
+        return b_amt;
+    }
+
+    public void setB_amt(Double b_amt) {
+        this.b_amt = b_amt;
+    }
+
+    public Integer getB_cnt() {
+        return b_cnt;
+    }
+
+    public void setB_cnt(Integer b_cnt) {
+        this.b_cnt = b_cnt;
+    }
+
+    public Integer getB_feecnt() {
+        return b_feecnt;
+    }
+
+    public void setB_feecnt(Integer b_feecnt) {
+        this.b_feecnt = b_feecnt;
+    }
+
+    public Double getB_feeamt() {
+        return b_feeamt;
+    }
+
+    public void setB_feeamt(Double b_feeamt) {
+        this.b_feeamt = b_feeamt;
+    }
+
+    public Double getB_getamt() {
+        return b_getamt;
+    }
+
+    public void setB_getamt(Double b_getamt) {
+        this.b_getamt = b_getamt;
+    }
+
+    public Double getD_amt() {
+        return d_amt;
+    }
+
+    public void setD_amt(Double d_amt) {
+        this.d_amt = d_amt;
+    }
+
+    public Integer getD_cnt() {
+        return d_cnt;
+    }
+
+    public void setD_cnt(Integer d_cnt) {
+        this.d_cnt = d_cnt;
+    }
+
+    public Integer getD_feecnt() {
+        return d_feecnt;
+    }
+
+    public void setD_feecnt(Integer d_feecnt) {
+        this.d_feecnt = d_feecnt;
+    }
+
+    public Double getD_feeamt() {
+        return d_feeamt;
+    }
+
+    public void setD_feeamt(Double d_feeamt) {
+        this.d_feeamt = d_feeamt;
+    }
+
+    public Double getD_getamt() {
+        return d_getamt;
+    }
+
+    public void setD_getamt(Double d_getamt) {
+        this.d_getamt = d_getamt;
+    }
+
+    public Double getL_amt() {
+        return l_amt;
+    }
+
+    public void setL_amt(Double l_amt) {
+        this.l_amt = l_amt;
+    }
+
+    public Integer getL_cnt() {
+        return l_cnt;
+    }
+
+    public void setL_cnt(Integer l_cnt) {
+        this.l_cnt = l_cnt;
+    }
+
+    public Integer getL_feecnt() {
+        return l_feecnt;
+    }
+
+    public void setL_feecnt(Integer l_feecnt) {
+        this.l_feecnt = l_feecnt;
+    }
+
+    public Double getL_feeamt() {
+        return l_feeamt;
+    }
+
+    public void setL_feeamt(Double l_feeamt) {
+        this.l_feeamt = l_feeamt;
+    }
+
+    public Double getL_getamt() {
+        return l_getamt;
+    }
+
+    public void setL_getamt(Double l_getamt) {
+        this.l_getamt = l_getamt;
+    }
+
+    public Double getT_amt() {
+        return t_amt;
+    }
+
+    public void setT_amt(Double t_amt) {
+        this.t_amt = t_amt;
+    }
+
+    public Integer getT_cnt() {
+        return t_cnt;
+    }
+
+    public void setT_cnt(Integer t_cnt) {
+        this.t_cnt = t_cnt;
+    }
+
+    public Integer getT_feecnt() {
+        return t_feecnt;
+    }
+
+    public void setT_feecnt(Integer t_feecnt) {
+        this.t_feecnt = t_feecnt;
+    }
+
+    public Double getT_feeamt() {
+        return t_feeamt;
+    }
+
+    public void setT_feeamt(Double t_feeamt) {
+        this.t_feeamt = t_feeamt;
+    }
+
+    public Double getT_getamt() {
+        return t_getamt;
+    }
+
+    public void setT_getamt(Double t_getamt) {
+        this.t_getamt = t_getamt;
+    }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeviceGroupController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeviceGroupController.java
index 2c222d3..f338833 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeviceGroupController.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeviceGroupController.java
@@ -11,6 +11,7 @@
 import com.supwisdom.dlpay.restaurant.service.DeviceService;
 import com.supwisdom.dlpay.framework.util.PageResult;
 import com.supwisdom.dlpay.framework.util.WebConstant;
+import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
 import com.supwisdom.dlpay.system.bean.ZTreeNode;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -76,7 +77,7 @@
     @GetMapping("/loadadd")
     @PreAuthorize("hasPermission('/devicegroup/loadadd','')")
     public String loadadd(Model model) {
-        List<TDeviceGroup> list=groupService.findAll();
+        List<TDeviceGroup> list=groupService.findByGrouptype(RestaurantConstant.DEVICEGROUP_TYPE_BRANCH);
         model.addAttribute("grouplist",list);
 
         return "restaurant/devicegroup/form";
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/MealsDtlController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/MealsDtlController.java
new file mode 100644
index 0000000..6f5e543
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/MealsDtlController.java
@@ -0,0 +1,62 @@
+package com.supwisdom.dlpay.restaurant.controller;
+
+
+import com.supwisdom.dlpay.framework.util.DateUtil;
+import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.framework.util.StringUtil;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlSearchBean;
+import com.supwisdom.dlpay.restaurant.bean.CustomerSearchBean;
+import com.supwisdom.dlpay.restaurant.bean.CustomerShowBean;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlShowBean;
+import com.supwisdom.dlpay.restaurant.service.CustomerService;
+import com.supwisdom.dlpay.restaurant.service.MealsdtlService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+@Controller
+@RequestMapping("/mealsdtl")
+public class MealsDtlController {
+
+
+    @Autowired
+    private MealsdtlService mealsdtlService;
+
+    @RequestMapping("/index")
+    public String indexView(ModelMap model) {
+        String settledate = mealsdtlService.getCheckdateToday();
+        if (StringUtil.isEmpty(settledate)) {
+            settledate = DateUtil.getNow("yyyyMMdd");
+        }
+        model.addAttribute("maxdate", DateUtil.parseToDateFormat(DateUtil.getNewDay(settledate, -1)));
+        return "restaurant/mealsdtl/index";
+    }
+
+    @RequestMapping("/mealsdtllist")
+    // @PreAuthorize("hasPermission('/mealsdtl/mealsdtllist','')")
+    @ResponseBody
+    public PageResult<MealsDtlShowBean> getDataList(
+            @RequestParam(value = "startdate", required = false) String startdate,
+            @RequestParam(value = "enddate", required = false) String enddate,
+            @RequestParam(value = "groupid", required = false) Integer groupid) {
+        try {
+            MealsDtlSearchBean searchBean = new MealsDtlSearchBean();
+            searchBean.setEnddate(enddate);
+            searchBean.setStartdate(startdate);
+            searchBean.setGroupid(groupid);
+
+            System.out.println(searchBean.toString());
+
+            PageResult<MealsDtlShowBean> bean = mealsdtlService.getMealsdtlByKey(searchBean);
+
+            return bean;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new PageResult<>(99, "系统查询错误");
+        }
+    }
+
+
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java
index 7f90450..6762816 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java
@@ -2,6 +2,9 @@
 
 import com.supwisdom.dlpay.restaurant.domain.TDeviceGroup;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
 
 
 public interface DeviceGroupDao  extends  JpaRepository<TDeviceGroup, Integer> {
@@ -15,4 +18,11 @@
 
 
     Integer countByPid(Integer Devgroupid);
+
+    List<TDeviceGroup> findByGrouptype(String grouptype);
+
+    @Query(value = "select distinct devgroupid from tb_devicegroup where devgroupid=?1 or pid=?1",nativeQuery = true)
+    List<Integer> findGroupidByDevgroupid(Integer groupid);
+    @Query(value = "select distinct devgroupid from tb_devicegroup where grouptype='leaf'",nativeQuery = true)
+    List<Integer> findAllGroupid();
 }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/MealsdtlDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/MealsdtlDao.java
new file mode 100644
index 0000000..f57f660
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/MealsdtlDao.java
@@ -0,0 +1,32 @@
+package com.supwisdom.dlpay.restaurant.dao;
+
+
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlList;
+import com.supwisdom.dlpay.restaurant.domain.TMealsDtl;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface MealsdtlDao extends JpaRepository<TMealsDtl, String> {
+
+    @Query(value="select tt.groupname,sum(tt.amount) as amount,sum(tt.count) as cnt,sum(tt.feecount) as feecount " +
+            ",sum(tt.feeamount) as feeamount,tt.mealtype " +
+            "from  " +
+            "(select distinct t.devgroupid,t.groupname,m.amount,m.count,m.feecount,m.feeamount,m.mealtype,m.checkdate from  " +
+            " tb_mealsdtl m " +
+            "left join tb_devicegroup t " +
+            "on t.devgroupid=m.devgroupid " +
+            "where t.grouptype='leaf' " +
+            "and m.checkdate BETWEEN :startdate and :enddate " +
+            "and t.devgroupid =:groupid) tt " +
+            "group by tt.mealtype,tt.groupname,tt.groupname ", nativeQuery = true)
+    List<MealsDtlList> getMealsDtl(@Param("startdate")String startdate, @Param("enddate")String enddate, @Param("groupid")Integer groupid);
+
+    @Query(value = "select max(checkdate) from tb_mealsdtl",nativeQuery = true)
+    String findMaxCheckdate();
+
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDeviceGroup.java b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDeviceGroup.java
index 80564dd..67eccce 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDeviceGroup.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDeviceGroup.java
@@ -11,6 +11,7 @@
     private String groupname;
     private Integer pid;
     private String operid;
+    private String grouptype;
 
     @Id
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DEVGROUP")
@@ -51,5 +52,12 @@
         this.operid = operid;
     }
 
+    @Column(name = "grouptype", length = 10)
+    public String getGrouptype() {
+        return grouptype;
+    }
 
+    public void setGrouptype(String grouptype) {
+        this.grouptype = grouptype;
+    }
 }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TMealsDtl.java b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TMealsDtl.java
index 85ea576..ce0759c 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TMealsDtl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TMealsDtl.java
@@ -1,6 +1,8 @@
 package com.supwisdom.dlpay.restaurant.domain;
 
 
+import org.hibernate.annotations.GenericGenerator;
+
 import javax.persistence.*;
 import javax.validation.constraints.NotNull;
 
@@ -21,10 +23,10 @@
     private Integer feecount;
 
     @Id
-    @SequenceGenerator(name = "mealsdtl_id", sequenceName = "SEQ_MEALSDTL", allocationSize = 1)
-    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "mealsdtl_id")
+    @GenericGenerator(name = "idGenerator", strategy = "uuid")
+    @GeneratedValue(generator = "idGenerator")
     @NotNull
-    @Column(name = "id", unique = true,  length = 15)
+    @Column(name = "id", unique = true,  length = 32)
     public String getId() {
         return id;
     }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceGroupService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceGroupService.java
index 9265b95..dcb2a0c 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceGroupService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceGroupService.java
@@ -15,6 +15,8 @@
 
     List<TDeviceGroup> findAll();
 
+    List<TDeviceGroup> findByGrouptype(String grouptype);
+
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     JsonResult saveGroup(TDeviceGroup device);
 
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/MealsdtlService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/MealsdtlService.java
new file mode 100644
index 0000000..7932b74
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/MealsdtlService.java
@@ -0,0 +1,22 @@
+package com.supwisdom.dlpay.restaurant.service;
+
+import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlSearchBean;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlShowBean;
+import com.supwisdom.dlpay.restaurant.domain.TArea;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+public interface MealsdtlService {
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+    PageResult<MealsDtlShowBean> getMealsdtlByKey(MealsDtlSearchBean param);
+
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+    String getCheckdateToday();
+
+
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceGroupServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceGroupServiceImpl.java
index 20a4bc9..a990852 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceGroupServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceGroupServiceImpl.java
@@ -29,6 +29,7 @@
             ZTreeNode z=new ZTreeNode();
             z.setId(g.getDevgroupid().toString());
             z.setName(g.getGroupname());
+            z.setGrouptype(g.getGrouptype());
             if(g.getPid()==null){
                 z.setpId("0");
             }else{
@@ -50,6 +51,11 @@
     }
 
     @Override
+    public List<TDeviceGroup> findByGrouptype(String grouptype) {
+        return groupDao.findByGrouptype(grouptype);
+    }
+
+    @Override
     public JsonResult saveGroup(TDeviceGroup device){
         device.setOperid(OperUtil.getCurrentOperid());
         if(device.getPid()==null){
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/MealsdtlServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/MealsdtlServiceImpl.java
new file mode 100644
index 0000000..7dd02f4
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/MealsdtlServiceImpl.java
@@ -0,0 +1,139 @@
+package com.supwisdom.dlpay.restaurant.service.impl;
+
+import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.framework.util.StringUtil;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlList;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlSearchBean;
+import com.supwisdom.dlpay.restaurant.bean.MealsDtlShowBean;
+import com.supwisdom.dlpay.restaurant.dao.DeviceGroupDao;
+import com.supwisdom.dlpay.restaurant.dao.MealTypeDao;
+import com.supwisdom.dlpay.restaurant.dao.MealsdtlDao;
+import com.supwisdom.dlpay.restaurant.domain.TMealsDtl;
+import com.supwisdom.dlpay.restaurant.domain.TMealtype;
+import com.supwisdom.dlpay.restaurant.service.AreaService;
+import com.supwisdom.dlpay.restaurant.service.DeviceGroupService;
+import com.supwisdom.dlpay.restaurant.service.MealsdtlService;
+import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class MealsdtlServiceImpl implements MealsdtlService {
+
+    @Autowired
+    private MealsdtlDao mealsdtlDao;
+    @Autowired
+    private DeviceGroupDao deviceGroupDao;
+    @Autowired
+    private MealTypeDao mealTypeDao;
+
+    private static final Logger logger = LoggerFactory.getLogger(MealsdtlServiceImpl.class);
+
+    @Override
+    public PageResult<MealsDtlShowBean> getMealsdtlByKey(MealsDtlSearchBean param) {
+        List<Integer> groupids;
+        if (null != param.getGroupid()) {
+            groupids = deviceGroupDao.findGroupidByDevgroupid(param.getGroupid());
+        } else {
+            groupids = deviceGroupDao.findAllGroupid();
+        }
+
+        List<MealsDtlShowBean> showBeans = new ArrayList<>();
+
+        for (Integer groupid : groupids) {
+            MealsDtlShowBean bean = new MealsDtlShowBean();
+            List<MealsDtlList> dtls = mealsdtlDao.getMealsDtl(param.getStartdate(), param.getEnddate(), groupid);
+
+            if(dtls.size()<=0){
+                continue;
+            }
+
+            Double totamt=0d;
+            Integer totcnt=0;
+            Double totfeeamt=0d;
+            Integer totfeecnt=0;
+
+            for(MealsDtlList dtl:dtls){
+                String groupname=dtl.getGroupname();
+               /* if(StringUtil.isEmpty(groupname)){
+                    groupname=deviceGroupDao.findById(groupid).get().getGroupname();
+                }*/
+                bean.setDevgroupname(groupname);
+             /*   if(null==dtl.getAmount()){
+                    bean.setB_amt(0d);
+                    bean.setB_cnt(0);
+                    bean.setB_feeamt(0d);
+                    bean.setB_feecnt(0);
+                    bean.setB_getamt(0d);
+                    bean.setD_amt(0d);
+                    bean.setD_cnt(0);
+                    bean.setD_feeamt(0d);
+                    bean.setD_feecnt(0);
+                    bean.setD_getamt(0d);
+                    bean.setL_amt(0d);
+                    bean.setL_cnt(0);
+                    bean.setL_feeamt(0d);
+                    bean.setL_feecnt(0);
+                    bean.setL_getamt(0d);
+                    bean.setT_amt(0d);
+                    bean.setT_cnt(0);
+                    bean.setT_feeamt(0d);
+                    bean.setT_feecnt(0);
+                    bean.setT_getamt(0d);
+                    break;
+                }*/
+
+                totamt+=dtl.getAmount();
+                totcnt+=dtl.getCnt();
+                totfeeamt+=dtl.getFeeamount();
+                totfeecnt+=dtl.getFeecount();
+
+
+                if(dtl.getMealtype().equalsIgnoreCase(RestaurantConstant.MEALTYPE_BREAKFAST)){
+
+                    bean.setB_amt(dtl.getAmount());
+                    bean.setB_cnt(dtl.getCnt());
+                    bean.setB_feeamt(dtl.getFeeamount());
+                    bean.setB_feecnt(dtl.getFeecount());
+                    bean.setB_getamt(dtl.getAmount()-dtl.getFeeamount());
+                }else if(dtl.getMealtype().equalsIgnoreCase(RestaurantConstant.MEALTYPE_LUNCH)){
+                    bean.setL_amt(dtl.getAmount());
+                    bean.setL_cnt(dtl.getCnt());
+                    bean.setL_feeamt(dtl.getFeeamount());
+                    bean.setL_feecnt(dtl.getFeecount());
+                    bean.setL_getamt(dtl.getAmount()-dtl.getFeeamount());
+                }else if(dtl.getMealtype().equalsIgnoreCase(RestaurantConstant.MEALTYPE_DINNER)){
+                    bean.setD_amt(dtl.getAmount());
+                    bean.setD_cnt(dtl.getCnt());
+                    bean.setD_feeamt(dtl.getFeeamount());
+                    bean.setD_feecnt(dtl.getFeecount());
+                    bean.setD_getamt(dtl.getAmount()-dtl.getFeeamount());
+                }
+            }
+
+            Double totgetamt=totamt-totfeeamt;
+            bean.setT_amt(totamt);
+            bean.setT_cnt(totcnt);
+            bean.setT_feeamt(totfeeamt);
+            bean.setT_feecnt(totfeecnt);
+            bean.setT_getamt(totgetamt);
+
+            showBeans.add(bean);
+        }
+
+        return new PageResult<>(showBeans);
+
+    }
+
+    @Override
+    public String getCheckdateToday() {
+        String date=mealsdtlDao.findMaxCheckdate();
+
+        return null;
+    }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/TransDtlServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/TransDtlServiceImpl.java
index d19ee55..f5f5344 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/TransDtlServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/TransDtlServiceImpl.java
@@ -201,7 +201,10 @@
         revDtl.setTermid(targetDtl.getTermid());
         revDtl.setShopid(targetDtl.getShopid());
         revDtl.setMealtype(targetDtl.getMealtype());
-        revDtl.setManagefee(targetDtl.getManagefee());
+        Double managefee=targetDtl.getManagefee();
+        if(null!=managefee){
+            revDtl.setManagefee(managefee*-1.00);
+        }
         revDtl.setRuleid(targetDtl.getRuleid());
         revDtl.setCustid(targetDtl.getCustid());
         revDtl.setCardno(targetDtl.getCardno());
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/util/RestaurantConstant.java b/src/main/java/com/supwisdom/dlpay/restaurant/util/RestaurantConstant.java
index 80933c7..d5732cc 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/util/RestaurantConstant.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/util/RestaurantConstant.java
@@ -14,6 +14,9 @@
     public static final String TRANSMODE_CARD = "card";  //卡消费
     public static final String TRANSMODE_CODE = "code";  //二维码消费
 
+    public static final String DEVICEGROUP_TYPE_BRANCH = "branch";   //驳回
+    public static final String DEVICEGROUP_TYPE_LEAF = "leaf";   //驳回
+
 
     public static final String STATUS_TRANSDTL_INIT = "init";   //初始化
     public static final String STATUS_TRANSDTL_WAIT = "wip";   //提交中
@@ -43,6 +46,7 @@
     public static final String RULETYPE_QUOTA = "quota"; //定额
     public static final String RULETYPE_REDUCTION = "reduction"; //减免
     public static final String RULETYPE_DISCOUNT = "discount"; //折扣
+    public static final String RULETYPE_NORMAL = "normal"; //普通
 
 
     public static final int POS_TIME_ERROR_DIFFMINS = 10; //设备时钟误差
diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java b/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java
index 9d50273..c6cd95e 100644
--- a/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java
+++ b/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java
@@ -5,6 +5,7 @@
     private String id;
     private String pId;
     private String name;
+    private String grouptype;
     private boolean checked;
     private boolean open;
 
@@ -44,6 +45,14 @@
         return checked;
     }
 
+    public String getGrouptype() {
+        return grouptype;
+    }
+
+    public void setGrouptype(String grouptype) {
+        this.grouptype = grouptype;
+    }
+
     public void setChecked(boolean checked) {
         this.checked = checked;
     }
diff --git a/src/main/resources/templates/restaurant/devicegroup/form.html b/src/main/resources/templates/restaurant/devicegroup/form.html
index 281367a..aaa6ed2 100644
--- a/src/main/resources/templates/restaurant/devicegroup/form.html
+++ b/src/main/resources/templates/restaurant/devicegroup/form.html
@@ -17,6 +17,15 @@
             </select>
         </div>
     </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label"><span style="color: red">* </span>设备组类型</label>
+        <div class="layui-input-block">
+            <select name="grouptype"  lay-verify="required">
+                <option value="branch">枝</option>
+                <option value="leaf">叶</option>
+            </select>
+        </div>
+    </div>
 
     <div class="layui-form-item model-form-footer">
         <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
diff --git a/src/main/resources/templates/restaurant/devicegroup/index.html b/src/main/resources/templates/restaurant/devicegroup/index.html
index a26b228..157accd 100644
--- a/src/main/resources/templates/restaurant/devicegroup/index.html
+++ b/src/main/resources/templates/restaurant/devicegroup/index.html
@@ -41,6 +41,7 @@
 <script>
     var groupid=null;
     var groupname=null;
+    var grouptype=null;
     layui.use(['form', 'table', 'layer', 'admin', 'element'], function () {
         let form = layui.form;
         let table = layui.table;
@@ -94,12 +95,18 @@
             });
         };
 
-        let showDeviceModel = function (data) {
+        let showDeviceModel = function () {
             if(groupid==null){
                 layer.msg('请先选择设备组', {icon: 2});
                 return;
             }
-            let title = groupname;
+            console.log(grouptype);
+            if(grouptype=='branch'){
+                layer.msg('枝类型的设备组不能添加设备', {icon: 2});
+                return;
+            }
+            var title = groupname;
+
             admin.putTempData('t_groupname', groupname);
             admin.putTempData('t_groupid', groupid);
             admin.popupCenter({
@@ -154,6 +161,7 @@
         function OnGrpClick(e, treeId, treeNode) {
             console.log(treeNode.id);
             groupid=treeNode.id;
+            grouptype=treeNode.grouptype;
             groupname=treeNode.name;
             table.reload('devicegroup-table', {where: {searchkey: treeNode.id}, page: {curr: 1}});
 
@@ -259,7 +267,8 @@
             var data = {
                 'devgroupid': treeNode.id,
                 'pid': treeNode.pId,
-                'groupname': treeNode.name
+                'groupname': treeNode.name,
+                'grouptype':treeNode.grouptype
             };
             let token = $("meta[name='_csrf_token']").attr("value");
             var url = '[[@{devicegroup/add}]]';
diff --git a/src/main/resources/templates/restaurant/mealsdtl/index.html b/src/main/resources/templates/restaurant/mealsdtl/index.html
new file mode 100644
index 0000000..cc6fbc8
--- /dev/null
+++ b/src/main/resources/templates/restaurant/mealsdtl/index.html
@@ -0,0 +1,310 @@
+<div class="layui-card">
+    <div class="layui-card-header">
+        <h2 class="header-title">食堂分餐表</h2>
+        <span class="layui-breadcrumb pull-right">
+          <a href="#">报表中心</a>
+          <a><cite>食堂分餐表</cite></a>
+        </span>
+    </div>
+    <div class="layui-card-body">
+        <div class="layui-form" lay-filter="mealsdtl-search-form">
+            <input type="hidden" id="mealsdtl-hidden-maxdate" th:value="${maxdate}" />
+            <div class="layui-form-item" style="margin-bottom: 0;">
+                <div class="layui-inline">
+                    <label class="layui-form-label">记账日期</label>
+                    <div class="layui-input-inline">
+                        <input type="text" name="startdate" id="mealsdtl-search-startdate" placeholder="起始日期" th:value="${maxdate}"
+                               autocomplete="off" class="layui-input"/>
+                    </div>
+                    <div class="layui-form-mid">-</div>
+                    <div class="layui-input-inline">
+                        <input type="text" name="enddate" id="mealsdtl-search-enddate" placeholder="截止日期" th:value="${maxdate}"
+                               autocomplete="off" class="layui-input"/>
+                    </div>
+                </div>
+
+                <div class="layui-inline">
+                    <label class="layui-form-label">选择设备组</label>
+                    <div class="layui-input-block">
+                        <input type="text" name="groupid" id="mealsdtl-search-devgroup"  lay-filter="mealsdtl-search-devgroup-filter"
+                               autocomplete="off" class="layui-input"/>
+                    </div>
+                </div>
+
+                <div class="layui-inline">
+                    <button id="mealsdtl-search-btn" class="layui-btn icon-btn" data-type="search"><i
+                            class="layui-icon">&#xe615;</i>搜索
+                    </button>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="layui-card-body">
+        <!--<div class="layui-btn-group">-->
+        <!--<button class="layui-btn" id="btn-fold-mealsdtl">仅看一级</button>-->
+        <!--<button class="layui-btn" id="btn-expand-mealsdtl">查看二级</button>-->
+        <!--</div>-->
+        <table class="layui-table" id="mealsdtlTable" lay-filter="mealsdtlTable-filter"></table>
+    </div>
+</div>
+
+<!--<script type="text/html" id="mealsdtl-toolbar">
+    <div class="layui-btn-container">
+        <button class="layui-btn layui-btn-sm" id="btn-fold-mealsdtl" lay-event="mealsdtlShowFold">仅看一级</button>
+        <button class="layui-btn layui-btn-sm" id="btn-expand-mealsdtl" lay-event="mealsdtlExpandAll">查看二级</button>
+    </div>
+</script>-->
+
+<script>
+    layui.use(['form', 'table', 'layer', 'admin', 'element', 'laydate', 'treetable','treeSelect'], function () {
+        var form = layui.form;
+        var table = layui.table;
+        var admin = layui.admin;
+        var laydate = layui.laydate;
+        var treetable = layui.treetable;
+        var treeSelect = layui.treeSelect;
+
+        form.render("checkbox");
+        laydate.render({
+            elem: '#mealsdtl-search-startdate',
+            max: $("#mealsdtl-hidden-maxdate").val(),
+            trigger: 'click'
+        });
+        laydate.render({
+            elem: '#mealsdtl-search-enddate',
+            max: $("#mealsdtl-hidden-maxdate").val(),
+            trigger: 'click'
+        });
+
+        treeSelect.render({
+            elem: '#mealsdtl-search-devgroup',
+            data: '[[@{/whitelistbind/devgrouptree}]]',
+            type: 'get',
+            placeholder: '选择设备组',
+            search: false,
+            style: {
+                folder: {
+                    enable: false
+                },
+                line: {
+                    enable: true
+                }
+            },
+            // 点击回调
+            click: function (d) {
+                var treeNode = d.current;
+                console.log(treeNode);
+                if(treeNode.accno == '0'){
+                    layer.msg("请选择末级科目", {icon: 2, time:1500});
+                    $("#mealsdtl-search-devgroup").val("");
+                    treeSelect.revokeNode('mealsdtl-search-devgroup-filter');
+                    return false;
+                }
+                return true;
+            },
+            success: function (d) {
+                console.log(d); // 加载完成后的回调函数
+            }
+        });
+
+        var renderTable = function (obj) {
+            layer.load(2);
+            table.render({
+                id: 'mealsdtlReport',
+                title: '食堂分餐表',
+                 // treeColIndex: 0,
+                 // treeSpid: '-1',
+                // treeIdName: 'subjno',
+                // treePidName: 'fsubjno',
+                // treeDefaultClose: false,
+                // treeLinkage: false,
+                elem: '#mealsdtlTable',
+                url: '[[@{/mealsdtl/mealsdtllist}]]',
+                page: false,
+                where: obj,
+            //    showicon: false,
+              //  toolbar:'#mealsdtl-toolbar',
+                cols: [
+                    [
+                        {
+                            field: 'devgroupname', title: '商户名称', align: 'left', rowspan: 2, width:150,templet: function (d) {
+                                if (d.subjlevel == 1) {
+                                    return '<span>' + d.devgroupname + '</span>';
+                                } else {
+                                    return '<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + d.devgroupname + '</span>';
+                                }
+
+                            }
+                        },
+                        // {align: 'center', title: '期初余额', colspan: 2},
+                        {align: 'center', title: '早餐', colspan: 5},
+                        {align: 'center', title: '午餐', colspan: 5},
+                        {align: 'center', title: '晚餐', colspan: 5},
+                        {align: 'center', title: '合计', colspan: 5},
+                    ], [
+                        // {field: 'lastdaydrbal', title: '借方', align: 'center'},
+                        // {field: 'lastdaycrbal', title: '贷方', align: 'center'},
+                        {
+                            field: 'b_amt', title: '金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.b_amt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'b_cnt', title: '份数', width:150, align: 'center', templet: function (e) {
+                                return e.b_cnt;
+                            }
+                        },
+                        {
+                            field: 'b_feeamt', title: '餐补金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.b_feeamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'b_feecnt', title: '餐补份数', width:150, align: 'center', templet: function (e) {
+                                return e.b_feecnt;
+                            }
+                        },
+                        {
+                            field: 'b_getamt', title: '劳务费金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.b_getamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'l_amt', title: '金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.l_amt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'l_cnt', title: '份数', width:150, align: 'center', templet: function (e) {
+                                return e.l_cnt;
+                            }
+                        },
+                        {
+                            field: 'l_feeamt', title: '餐补金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.l_feeamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'l_feecnt', title: '餐补份数', width:150, align: 'center', templet: function (e) {
+                                return e.l_feecnt;
+                            }
+                        },
+                        {
+                            field: 'l_getamt', title: '劳务费金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.l_getamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'd_amt', title: '金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.d_amt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'd_cnt', title: '份数', width:150, align: 'center', templet: function (e) {
+                                return e.d_cnt;
+                            }
+                        },
+                        {
+                            field: 'd_feeamt', title: '餐补金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.d_feeamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 'd_feecnt', title: '餐补份数', width:150, align: 'center', templet: function (e) {
+                                return e.d_feecnt;
+                            }
+                        },
+                        {
+                            field: 'd_getamt', title: '劳务费金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.d_getamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 't_amt', title: '金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.t_amt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 't_cnt', title: '份数', width:150, align: 'center', templet: function (e) {
+                                return e.t_cnt;
+                            }
+                        },
+                        {
+                            field: 't_feeamt', title: '餐补金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.t_feeamt).toFixed(2);
+                            }
+                        },
+                        {
+                            field: 't_feecnt', title: '餐补份数', width:150, align: 'center', templet: function (e) {
+                                return e.t_feecnt;
+                            }
+                        },
+                        {
+                            field: 't_getamt', title: '劳务费金额', width:150, align: 'center', templet: function (e) {
+                                return parseFloat(e.t_getamt).toFixed(2);
+                            }
+                        }
+
+                    ]
+                ],
+                done: function (res, curr, count) {
+                    console.log(res);
+                    layer.closeAll('loading');
+                }
+            });
+        }
+       /* renderTable({
+            startdate: $("#mealsdtl-search-startdate").val(),
+            enddate: $("#mealsdtl-search-enddate").val(),
+       //     nodealshow: false
+        });*/
+
+        $('#btn-expand-mealsdtl').click(function () {
+            treetable.expandAll('#mealsdtlTable');
+        });
+
+        $('#btn-fold-mealsdtl').click(function () {
+            treetable.foldAll('#mealsdtlTable');
+        });
+
+
+
+
+
+
+        $('#mealsdtl-search-btn').click(function () {
+            var startdate = $("#mealsdtl-search-startdate").val();
+            var enddate = $("#mealsdtl-search-enddate").val();
+       //     var nodealshow = $("#mealsdtl-search-nodealshow").is(':checked');
+            var groupid=$("#mealsdtl-search-devgroup").val();
+            if (null == startdate || "" == $.trim(startdate)) {
+                layer.msg('请选择起始日期', {icon: 2, time: 1500});
+                return;
+            }
+            if (null == enddate || "" == $.trim(enddate)) {
+                layer.msg('请选择截止日期', {icon: 2, time: 1500});
+                return;
+            }
+            if (null == groupid || "" == $.trim(groupid)) {
+                layer.msg('请选择设备组', {icon: 2, time: 1500});
+                return;
+            }
+            renderTable({
+                startdate: startdate,
+                enddate: enddate,
+                groupid: groupid
+            });
+        });
+
+        table.on('toolbar(mealsdtlTable-filter)', function(obj){
+            switch(obj.event){
+                case 'mealsdtlShowFold':
+                    treetable.foldAll('#mealsdtlTable');
+                    break;
+                case 'mealsdtlExpandAll':
+                    treetable.expandAll('#mealsdtlTable');
+                    break;
+            }
+        });
+    });
+</script>
\ No newline at end of file