食堂报表,部门
diff --git a/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java b/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java
index ddc4d15..a7db678 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java
@@ -111,6 +111,7 @@
value = value.replaceAll("eval\\((.*)\\)", "");
value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");
value = value.replaceAll("script", "");
+ value = value.replaceAll(" ", "");
value = cleanSqlKeyWords(value);
return value;
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java
index adcdd79..e2f504c 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java
@@ -7,6 +7,7 @@
private String phone;
private String cardno;
private String bankcardno;
+ private String deptcode;
public String getCustname() {
return custname;
@@ -39,4 +40,12 @@
public void setBankcardno(String bankcardno) {
this.bankcardno = bankcardno;
}
+
+ public String getDeptcode() {
+ return deptcode;
+ }
+
+ public void setDeptcode(String deptcode) {
+ this.deptcode = deptcode;
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSaveBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSaveBean.java
index d4d4f97..3184dc7 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSaveBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSaveBean.java
@@ -18,6 +18,7 @@
private String bankcardno;
private String checkstatus;
private Integer savecardflag;
+ private String deptcode;
public String getCustid() {
return custid;
@@ -140,6 +141,14 @@
this.checkstatus = checkstatus;
}
+ public String getDeptcode() {
+ return deptcode;
+ }
+
+ public void setDeptcode(String deptcode) {
+ this.deptcode = deptcode;
+ }
+
@Override
public String toString() {
return "CustomerSaveBean{" +
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSearchBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSearchBean.java
index 06986ef..2863a53 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSearchBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerSearchBean.java
@@ -5,7 +5,8 @@
public class CustomerSearchBean extends PageBean {
private String custname;
private String checkstatus;
-
+ private String deptcode;
+ private Integer custtypeid;
public String getCustname() {
return custname;
}
@@ -21,4 +22,20 @@
public void setCheckstatus(String checkstatus) {
this.checkstatus = checkstatus;
}
+
+ public String getDeptcode() {
+ return deptcode;
+ }
+
+ public void setDeptcode(String deptcode) {
+ this.deptcode = deptcode;
+ }
+
+ public Integer getCusttypeid() {
+ return custtypeid;
+ }
+
+ public void setCusttypeid(Integer custtypeid) {
+ this.custtypeid = custtypeid;
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerShowBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerShowBean.java
index 74b5e99..9fb2eab 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerShowBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerShowBean.java
@@ -14,20 +14,11 @@
private String checkstatus;
private String status;
private String inputdate;
+ private String deptcode;
+ private String deptname;
+ private String custtypename;
+ private Integer discnt;
- public CustomerShowBean(){
-
- }
-
- public CustomerShowBean(String custid, Integer custtype, String custname, String phone, String cardno, String cardphyid, String bankcardno) {
- this.custid = custid;
- this.custtype = custtype;
- this.custname = custname;
- this.phone = phone;
- this.cardno = cardno;
- this.cardphyid = cardphyid;
- this.bankcardno = bankcardno;
- }
public String getCustid() {
return custid;
@@ -110,4 +101,36 @@
public void setInputdate(String inputdate) {
this.inputdate = inputdate;
}
+
+ public String getDeptcode() {
+ return deptcode;
+ }
+
+ public void setDeptcode(String deptcode) {
+ this.deptcode = deptcode;
+ }
+
+ public Integer getDiscnt() {
+ return discnt;
+ }
+
+ public String getDeptname() {
+ return deptname;
+ }
+
+ public void setDeptname(String deptname) {
+ this.deptname = deptname;
+ }
+
+ public String getCusttypename() {
+ return custtypename;
+ }
+
+ public void setCusttypename(String custtypename) {
+ this.custtypename = custtypename;
+ }
+
+ public void setDiscnt(Integer discnt) {
+ this.discnt = discnt;
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/DeptSearchBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/DeptSearchBean.java
index da93407..a70f465 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/DeptSearchBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/DeptSearchBean.java
@@ -3,22 +3,13 @@
import com.supwisdom.dlpay.system.bean.PageBean;
public class DeptSearchBean extends PageBean {
- private String deptname;
- private String deptcode;
+ private String searchkey;
- public String getDeptname() {
- return deptname;
+ public String getSearchkey() {
+ return searchkey;
}
- public void setDeptname(String deptname) {
- this.deptname = deptname;
- }
-
- public String getDeptcode() {
- return deptcode;
- }
-
- public void setDeptcode(String deptcode) {
- this.deptcode = deptcode;
+ public void setSearchkey(String searchkey) {
+ this.searchkey = searchkey;
}
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
index 5b50f30..b04b17d 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
@@ -3,6 +3,7 @@
import com.google.gson.Gson;
import com.supwisdom.dlpay.api.bean.JsonResult;
+import com.supwisdom.dlpay.framework.domain.TOperator;
import com.supwisdom.dlpay.framework.util.ExportExcel;
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.framework.util.WebConstant;
@@ -11,11 +12,17 @@
import com.supwisdom.dlpay.restaurant.bean.CustomerShowBean;
import com.supwisdom.dlpay.restaurant.domain.TCustType;
import com.supwisdom.dlpay.restaurant.domain.TCustomer;
+import com.supwisdom.dlpay.restaurant.domain.TDept;
import com.supwisdom.dlpay.restaurant.service.CustTypeService;
import com.supwisdom.dlpay.restaurant.service.CustomerService;
+import com.supwisdom.dlpay.restaurant.service.DeptService;
+import com.supwisdom.dlpay.restaurant.service.DeviceDiscountRuleService;
import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import com.supwisdom.dlpay.system.bean.TreeSelectNode;
+import com.supwisdom.dlpay.system.bean.ZTreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
@@ -34,21 +41,19 @@
@Autowired
private CustomerService customerService;
-
+ @Autowired
+ private DeviceDiscountRuleService discountRuleService;
@Autowired
private CustTypeService custTypeService;
+ @Autowired
+ private DeptService deptService;
@RequestMapping("/index")
public String indexView(ModelMap model) {
List<TCustType> lst = custTypeService.findAll();
- Map<Integer, String> map = new HashMap<>();
- for (TCustType type : lst) {
- map.put(type.getCusttypeid(), type.getCusttypename());
- }
- Gson gson = new Gson();
- String gsonString = gson.toJson(map);
- model.put("custtypelist", gsonString);
-
+ List<TDept> dept = deptService.findAllDept();
+ model.addAttribute("typelist", lst);
+ model.addAttribute("deptlist", dept);
return "restaurant/customer/index";
}
@@ -57,14 +62,18 @@
@ResponseBody
public PageResult<CustomerShowBean> getDataList(@RequestParam("page") Integer pageNo,
@RequestParam("limit") Integer pageSize,
- @RequestParam(value = "searchkey", required = false) String searchKey) {
+ @RequestParam(value = "custname", required = false) String custname,
+ @RequestParam(value = "deptcode", required = false) String deptcode,
+ @RequestParam(value = "custtypeid", required = false) Integer custtypeid) {
try {
if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;
if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;
CustomerSearchBean searchBean = new CustomerSearchBean();
searchBean.setPageNo(pageNo);
- searchBean.setCustname(searchKey);
+ searchBean.setCustname(custname);
searchBean.setPageSize(pageSize);
+ searchBean.setDeptcode(deptcode);
+ searchBean.setCusttypeid(custtypeid);
PageResult<CustomerShowBean> bean= customerService.getCustomerPage(searchBean);
return bean;
@@ -78,8 +87,11 @@
@GetMapping("/loadadd")
@PreAuthorize("hasPermission('/customer/loadadd','')")
public String loadadd(Model model) {
- List<TCustType> list=custTypeService.findAll();
- model.addAttribute("typelist",list);
+// List<TCustType> list=custTypeService.findAll();
+// model.addAttribute("typelist",list);
+// List<TDept> dept = deptService.findAllDept();
+// model.addAttribute("deptlist",dept);
+
return "restaurant/customer/form";
}
@@ -116,9 +128,9 @@
@PreAuthorize("hasPermission('/customer/download','')")
@ResponseBody
public JsonResult downloadfile(HttpServletRequest request, HttpServletResponse response) throws Exception{
- String[] titles0 = {"姓名", "市名卡号", "市名卡银行卡号","人员类别号","手机(选填)"
+ String[] titles0 = {"姓名", "市名卡号", "市名卡银行卡号","人员类别号","手机(选填)","部门代码(选填)"
}; //表头
- String[][] info0 = {{"张三", "123456", "3000000","1","12341234123"
+ String[][] info0 = {{"张三", "123456", "3000000","1","12341234123","1"
}}; // 示例内容
String fileName0 = "客户导入模板";// 保存数据
@@ -149,4 +161,31 @@
}
+ @GetMapping("/depttree")
+ @ResponseBody
+ public List<TreeSelectNode> searchDeptTree(@AuthenticationPrincipal TOperator operUser) {
+
+ List<TreeSelectNode> tree = deptService.getDeptSelectTree("");
+ return tree;
+ }
+ @GetMapping("/loaddiscount")
+ @PreAuthorize("hasPermission('/discountrule/load4detail','')")
+ public String loaddiscount() {
+ return "restaurant/customer/discount";
+ }
+
+ @GetMapping("/getdiscount")
+ @ResponseBody
+ public JsonResult getdiscount(@RequestParam String custid) {
+ List<ZTreeNode> nodes = discountRuleService.getUserDiscount(custid);
+ JsonResult result = JsonResult.ok();
+ result.put("node", nodes);
+ return result;
+ }
+
+ @RequestMapping("/savediscount")
+ @ResponseBody
+ public JsonResult savediscount(@RequestParam String custid,@RequestParam String rules) {
+ return discountRuleService.saveDiscountDetails(custid,rules);
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeptController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeptController.java
index 50280a9..9629e7f 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeptController.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/DeptController.java
@@ -3,26 +3,19 @@
import com.google.gson.Gson;
import com.supwisdom.dlpay.api.bean.JsonResult;
-import com.supwisdom.dlpay.framework.util.ExportExcel;
import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.framework.util.StringUtil;
import com.supwisdom.dlpay.framework.util.WebConstant;
import com.supwisdom.dlpay.restaurant.bean.DeptSearchBean;
-import com.supwisdom.dlpay.restaurant.bean.TDeptShowBean;
import com.supwisdom.dlpay.restaurant.domain.TDept;
import com.supwisdom.dlpay.restaurant.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
@Controller
@RequestMapping("/dept")
@@ -32,32 +25,25 @@
private DeptService deptService;
@RequestMapping("/index")
- public String indexView(ModelMap model) {
- List<TDept> lst = deptService.findAll();
- Map<String, String> map = new HashMap<>();
- for (TDept dept : lst) {
- map.put(dept.getDeptcode(), dept.getDeptname());
- }
+ public String deptindex(ModelMap map){
+ List<TDept> dept=deptService.findAllDept();
Gson gson = new Gson();
- String gsonString = gson.toJson(map);
- model.put("deptList", gsonString);
+ String gsonString = gson.toJson(dept);
+ map.put("deptList", gsonString);
return "restaurant/dept/index";
}
- @RequestMapping("/list")
- @PreAuthorize("hasPermission('/dept/index','')")
+ @RequestMapping("/listdept")
@ResponseBody
- public PageResult<TDeptShowBean> getDataList(@RequestParam("page") Integer pageNo,
- @RequestParam("limit") Integer pageSize,
- @RequestParam(value = "deptname", required = false) String deptname,
- @RequestParam(value = "deptcode", required = false) String deptcode) {
+ public PageResult<TDept> getDataList(@RequestParam("page") Integer pageNo,
+ @RequestParam("limit") Integer pageSize,
+ @RequestParam(value = "searchkey", required = false) String searchKey) {
try {
if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;
if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;
DeptSearchBean searchBean = new DeptSearchBean();
searchBean.setPageNo(pageNo);
- searchBean.setDeptname(deptname);
- searchBean.setDeptcode(deptcode);
+ searchBean.setSearchkey(searchKey);
searchBean.setPageSize(pageSize);
return deptService.getDeptByKey(searchBean);
} catch (Exception e) {
@@ -67,19 +53,16 @@
}
- @GetMapping("/loadadd")
- @PreAuthorize("hasPermission('/dept/loadadd','')")
- public String loadadd(Model model) {
- List<TDept> list = deptService.findFDept();
- model.addAttribute("fdeptlist", list);
+ @GetMapping("/loaddeptadd")
+ public String loadDeptadd(Model model) {
+ List<TDept> list = deptService.findAllDept();
+ model.addAttribute("deptlist", list);
return "restaurant/dept/form";
}
- @PostMapping("/add")
- @PreAuthorize("hasPermission('/dept/add','')")
+ @PostMapping("/adddept")
@ResponseBody
- public JsonResult add(@RequestBody TDept dept) {
- System.out.println(dept);
+ public JsonResult addDept(@RequestBody TDept dept) {
if (dept != null) {
return deptService.saveDept(dept);
} else {
@@ -87,54 +70,28 @@
}
}
+ @PostMapping("/deletedept")
+ @ResponseBody
+ public JsonResult deleteDept(@RequestParam String deptcode) {
+ return deptService.deleteDept(deptcode);
+ }
+
@GetMapping("/checkdeptno")
@ResponseBody
- public JsonResult delete(@RequestParam String deptno) {
- if(deptService.checkDeptnoExists(deptno)){
- return JsonResult.ok();
- }
-
- return JsonResult.error("部门代码已存在");
- }
-
-
- @PostMapping("/delete")
- @PreAuthorize("hasPermission('/dept/delete','')")
- @ResponseBody
- public JsonResult delete(@RequestParam Long deptno) {
- return deptService.delete(deptno);
- }
-
- @GetMapping("/loadimport")
- public String loadimport(Model model) {
- return "restaurant/dept/import";
- }
-
-
- @RequestMapping("/download")
- @ResponseBody
- public JsonResult downloadfile(HttpServletRequest request, HttpServletResponse response) throws Exception{
- String[] titles0 = {"部门编号", "部门名称", "上级部门编号(若为根部门则填0)","部门英文名称(选填)"
- }; //表头
- String[][] info0 = {{"01", "测试部门", "0",""
- }}; // 示例内容
- String fileName0 = "部门导入模板";// 保存数据
-
+ public JsonResult checkDeptno(@RequestParam("deptno") String deptno) {
try {
- ExportExcel.queryexcel(fileName0, titles0,info0,request, response);
- return JsonResult.ok("操作成功");
+ if (StringUtil.isEmpty(deptno)) {
+ return JsonResult.error("部门代码不能为空");
+ }
+ if (deptService.checkDeptnoExist(deptno.trim())) {
+ return JsonResult.error("部门代码已存在");
+ } else {
+ return JsonResult.ok("success");
+ }
} catch (Exception e) {
e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
}
- return JsonResult.error("操作失败");
- }
-
- @PostMapping("/import")
- @PreAuthorize("hasPermission('/dept/import','')")
- @ResponseBody
- public JsonResult importFile(@RequestParam(value = "file",required = false) MultipartFile file, HttpServletRequest request) throws Exception{
-// System.out.println("---------under the upload file:"+file);
- return deptService.importFile(file,request);
}
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeptDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeptDao.java
index 2506a7b..77ad851 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeptDao.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeptDao.java
@@ -1,6 +1,8 @@
package com.supwisdom.dlpay.restaurant.dao;
import com.supwisdom.dlpay.restaurant.domain.TDept;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@@ -8,22 +10,21 @@
import java.util.List;
@Repository
-public interface DeptDao extends JpaRepository<TDept, Long> {
+public interface DeptDao extends JpaRepository<TDept, String> {
@Query("from TDept t where t.status='normal' ")
List<TDept> findNormalDept();
- List<TDept> findByFdeptcode(String fdeptcode);
+ @Query("from TDept t order by deptno")
+ List<TDept> findAllOrderByDeptno();
- List<TDept> findByDeptcode(String deptcode);
+ Page<TDept> findAllByDeptnameContainingOrDeptnoContainingOrderByDeptcode(String name, String deptno, Pageable pageable);
- Integer countByDeptcode(String deptcode);
+ @Query("select count(t.deptno) from TDept t where t.deptno=?1 ")
+ long checkDeptnoExists(String deptno);
- Integer countByFdeptcode(String fdeptcode);
+ List<TDept> findByDeptno(String deptno);
+ int countByFdeptcode(String fdeptcode);
- @Query(value = "select distinct deptno from tb_dept where deptno=?1 or fdept=?1",nativeQuery = true)
- List<String> findDeptnoByDeptno(String deptno);
- @Query(value = "select distinct deptno from tb_dept",nativeQuery = true)
- List<String> findAllDeptno();
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountDetailDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountDetailDao.java
index 2b40245..d56a099 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountDetailDao.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountDetailDao.java
@@ -7,6 +7,8 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
+import java.util.List;
+
@Repository
public interface DiscountDetailDao extends JpaRepository<TDiscountDetail, String>, JpaSpecificationExecutor<TDiscountDetail> {
@@ -17,4 +19,8 @@
@Modifying
@Query("update TDiscountDetail t set t.status=?1 where t.ruleid=?2 ")
void updateRuleDetailStatusByRuleid(String status, int ruleid);
+
+ List<TDiscountDetail> findAllByUserid(String userid);
+
+ void deleteByUserid(String userid);
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountRuleDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountRuleDao.java
index 6583740..47481ad 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountRuleDao.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DiscountRuleDao.java
@@ -1,5 +1,6 @@
package com.supwisdom.dlpay.restaurant.dao;
+import com.supwisdom.dlpay.framework.data.NodeData;
import com.supwisdom.dlpay.restaurant.domain.TDiscountRule;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@@ -18,4 +19,9 @@
@Query("from TDiscountRule where status=?1 order by ruleid ")
List<TDiscountRule> getDiscountRuleByStatus(String status);
+
+ @Query(value ="select t.ruleid||'' as id, '0' as pid,t.rulename as name," +
+ "0 as checked,0 as open from tb_discount_rule t where t.status='normal'", nativeQuery = true)
+ List<NodeData> findDiscountRuleNode();
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TCustomer.java b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TCustomer.java
index 01bafaf..3b44efc 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TCustomer.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TCustomer.java
@@ -22,7 +22,7 @@
private String status;
private String checkstatus;
private String inputdate;
- private String deptno;
+ private String deptcode;
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@@ -132,13 +132,13 @@
this.checkstatus = checkstatus;
}
- @Column(name = "DEPTNO", length = 32)
- public String getDeptno() {
- return deptno;
+ @Column(name = "deptcode", length = 32)
+ public String getDeptcode() {
+ return deptcode;
}
- public void setDeptno(String deptno) {
- this.deptno = deptno;
+ public void setDeptcode(String deptcode) {
+ this.deptcode = deptcode;
}
@Column(name = "inputdate", length = 8)
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDept.java b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDept.java
index 64727b9..071e390 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDept.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/domain/TDept.java
@@ -1,5 +1,7 @@
package com.supwisdom.dlpay.restaurant.domain;
+import org.hibernate.annotations.GenericGenerator;
+
import javax.persistence.*;
@Entity
@@ -7,13 +9,13 @@
indexes = {@Index(name = "UK_DEPT_DEPTNO", unique = true, columnList = "DEPTNO")})
public class TDept {
@Id
- @SequenceGenerator(name = "pk_dept_deptcode", sequenceName = "SEQ_DEPTCODE", allocationSize = 1, initialValue = 10)
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "pk_dept_deptcode")
- @Column(name="deptno", nullable = false, length = 32)
- private Long deptno; //ID
+ @GenericGenerator(name = "idGenerator", strategy = "uuid")
+ @GeneratedValue(generator = "idGenerator")
+ @Column(name="DEPTCODE", nullable = false, length = 32)
+ private String deptcode; //ID
- @Column(name="deptcode", nullable = false, length = 20)
- private String deptcode; //部门编号,可能会要修改,不能为主键,唯一索引
+ @Column(name="DEPTNO", nullable = false, length = 20)
+ private String deptno; //部门编号,可能会要修改,不能为主键,唯一索引
@Column(name="DEPTNAME", precision = 600)
private String deptname; //部门名称
@@ -30,11 +32,11 @@
@Column(name="LASTSAVED", length = 20)
private String lastsaved; //最后更新时间
- public Long getDeptno() {
+ public String getDeptno() {
return deptno;
}
- public void setDeptno(Long deptno) {
+ public void setDeptno(String deptno) {
this.deptno = deptno;
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/CardService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/CardService.java
index db7abaa..f128eb2 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/CardService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/CardService.java
@@ -24,9 +24,6 @@
JsonResult saveCardver(TCardver card);
-/* @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- TCard getCardByCardno(String cardno);*/
-
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
TCard getCardByCardnoAndCardphyid(String cardno,String Cardphyid);
@@ -36,10 +33,11 @@
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
String getMaxCarcver();
-
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
List<TCardver> getCardlistByTCardVer(String cardverno);
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ TCard getNormalCardByCustid(String custid);
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java
index 25e1cab..5f2af6b 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/CustomerService.java
@@ -10,6 +10,7 @@
import com.supwisdom.dlpay.restaurant.domain.TCard;
import com.supwisdom.dlpay.restaurant.domain.TCustomer;
import com.supwisdom.dlpay.restaurant.domain.TDevice;
+import com.supwisdom.dlpay.system.bean.ZTreeNode;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -26,15 +27,12 @@
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
TCustomer getCustomerByCustid(String custid);
-
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
JsonResult saveCustomer(CustomerSaveBean customer);
-
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
JsonResult deleteCustomer(String custid);
-
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
JsonResult importFile(MultipartFile file, HttpServletRequest request) throws Exception;
@@ -43,4 +41,5 @@
TCustomer getCustomerByCardno(String cardno) ;
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeptService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeptService.java
index 2ee5589..3c32211 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeptService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeptService.java
@@ -7,6 +7,7 @@
import com.supwisdom.dlpay.restaurant.bean.TDeptShowBean;
import com.supwisdom.dlpay.restaurant.domain.TArea;
import com.supwisdom.dlpay.restaurant.domain.TDeviceGroup;
+import com.supwisdom.dlpay.system.bean.TreeSelectNode;
import com.supwisdom.dlpay.system.bean.ZTreeNode;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -18,31 +19,27 @@
import java.util.List;
public interface DeptService {
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
- PageResult<ZTreeNode> getDeptTree();
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
- PageResult<TDeptShowBean> getDeptByKey(DeptSearchBean param);
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+ PageResult<TDept> getDeptByKey(DeptSearchBean param);
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
- List<TDept> findAll();
-
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
- boolean checkDeptnoExists(String deptno);
-
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
- List<TDept> findFDept();
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+ List<TDept> findAllDept();
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- JsonResult saveDept(TDept dept);
+ JsonResult saveDept(TDept area);
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- JsonResult delete(Long deptcode);
+ JsonResult deleteDept(String deptcode);
+ @Transactional(rollbackFor = Exception.class, readOnly = true)
+ boolean checkDeptnoExist(String deptno);
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
- JsonResult importFile(MultipartFile file, HttpServletRequest request) throws Exception;
+ @Transactional(rollbackFor = Exception.class, readOnly = true)
+ TDept getDeptByDeptno(String deptno);
+ @Transactional(rollbackFor = Exception.class, readOnly = true)
+ List<TreeSelectNode> getDeptSelectTree(String deptcode);
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java
index e0b8586..c64a79e 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java
@@ -1,5 +1,6 @@
package com.supwisdom.dlpay.restaurant.service;
+import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.exception.WebCheckException;
import com.supwisdom.dlpay.framework.domain.TOperator;
import com.supwisdom.dlpay.framework.util.PageResult;
@@ -8,6 +9,8 @@
import com.supwisdom.dlpay.restaurant.domain.TCustomerList;
import com.supwisdom.dlpay.restaurant.domain.TDiscountDetail;
import com.supwisdom.dlpay.restaurant.domain.TDiscountDevbind;
+import com.supwisdom.dlpay.system.bean.ZTreeNode;
+import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -70,4 +73,10 @@
@Transactional(rollbackFor = Exception.class)
boolean saveDiscountDetails(int ruleid, List<String> custids ) throws WebCheckException;
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+ List<ZTreeNode> getUserDiscount(String custid);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ JsonResult saveDiscountDetails(String custid, String rules);
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CardServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CardServiceImpl.java
index b38fbb5..5ae7fbc 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CardServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CardServiceImpl.java
@@ -6,6 +6,7 @@
import com.supwisdom.dlpay.restaurant.domain.TCard;
import com.supwisdom.dlpay.restaurant.domain.TCardver;
import com.supwisdom.dlpay.restaurant.service.CardService;
+import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -70,4 +71,15 @@
public List<TCardver> getCardlistByTCardVer(String cardverno) {
return cardverDao.findAllWhitelist(cardverno);
}
+
+ @Override
+ public TCard getNormalCardByCustid(String custid) {
+ List<TCard> cards=cardDao.findAllByCustidAndStatus(custid, RestaurantConstant.STATUS_CARD_NORMAL);
+ if(cards.size()>0){
+ return cards.get(0);
+ }
+ return null;
+ }
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
index 25ff130..9b1701c 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
@@ -4,15 +4,17 @@
import com.supwisdom.dlpay.framework.service.SystemUtilService;
import com.supwisdom.dlpay.framework.util.*;
import com.supwisdom.dlpay.restaurant.bean.*;
-import com.supwisdom.dlpay.restaurant.dao.CardDao;
-import com.supwisdom.dlpay.restaurant.dao.CardverDao;
-import com.supwisdom.dlpay.restaurant.dao.CustomerDao;
+import com.supwisdom.dlpay.restaurant.dao.*;
import com.supwisdom.dlpay.restaurant.domain.TCard;
import com.supwisdom.dlpay.restaurant.domain.TCardver;
import com.supwisdom.dlpay.restaurant.domain.TCustomer;
+import com.supwisdom.dlpay.restaurant.domain.TDept;
import com.supwisdom.dlpay.restaurant.service.CardService;
import com.supwisdom.dlpay.restaurant.service.CustomerService;
+import com.supwisdom.dlpay.restaurant.service.DeptService;
import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import com.supwisdom.dlpay.system.bean.ZTreeNode;
+import org.apache.commons.lang3.StringUtils;
import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,17 +42,34 @@
private CardDao cardDao;
@Autowired
private CardverDao cardverDao;
+ @Autowired
+ private DeptService deptService;
+ @Autowired
+ private DiscountDetailDao discountDetailDao;
@PersistenceContext
private EntityManager entityManager;
@Override
public PageResult<CustomerShowBean> getCustomerPage(CustomerSearchBean param) {
- StringBuffer querySql = new StringBuffer("select t.cardno,c.custid,c.custname,c.inputdate, " +
+
+ StringBuffer querySql = new StringBuffer("select t.cardno,c.custid,c.custname,c.inputdate,gg.discnt,d.deptcode,d.deptname,p.custtypename, " +
"t.bankcardno,t.cardphyid,c.phone,c.custtype,c.checkstatus,t.status from tb_customer c " +
- "left join Tb_card t on t.custid=c.custid where 1=1 ");
+ "left join Tb_card t on t.custid=c.custid " +
+ "left join (select cardno,cast(count(ruleid) as int4)as discnt from tb_discount_detail group by cardno) gg " +
+ "on t.cardno=gg.cardno " +
+ "left join tb_dept d on c.deptcode= d.deptcode " +
+ "left join tb_custtype p on c.custtype=p.custtypeid " +
+
+ " where 1=1 ");
StringBuffer countSql = new StringBuffer("select count(*) as cnt from tb_customer c " +
- "left join Tb_card t on t.custid=c.custid where 1=1 ");
+ "left join Tb_card t on t.custid=c.custid " +
+ "left join (select cardno,cast(count(ruleid) as int4)as discnt from tb_discount_detail group by cardno) gg " +
+ "on t.cardno=gg.cardno " +
+ "left join tb_dept d on c.deptcode= d.deptcode " +
+ "left join tb_custtype p on c.custtype=p.custtypeid " +
+
+ " where 1=1 ");
if (!StringUtil.isEmpty(param.getCustname())) {
querySql.append(" and c.custname like :str ");
countSql.append(" and c.custname like :str ");
@@ -59,6 +78,20 @@
querySql.append(" and c.checkstatus = :checkstatus ");
countSql.append(" and c.checkstatus = :checkstatus ");
}
+ Integer i=param.getCusttypeid();
+ if (null!=i&&-1!=i){
+ querySql.append(" and c.custtype = :custtypeid ");
+ countSql.append( " and c.custtype = :custtypeid ");
+ }
+ if (!StringUtil.isEmpty(param.getDeptcode())) {
+ List<String> childdplist = getChildDeptlist( param.getDeptcode());
+ if (!StringUtil.isEmpty(childdplist)) {
+ querySql.append(" and c.deptcode in ('"+ StringUtils.join(childdplist.toArray(),"','")+"') ");
+ countSql.append(" and c.deptcode in ('"+ StringUtils.join(childdplist.toArray(),"','")+"') ");
+ }
+ }
+
+
querySql.append(" order by t.cardno ");
Query query = entityManager.createNativeQuery(querySql.toString());
Query countQuery = entityManager.createNativeQuery(countSql.toString());
@@ -70,6 +103,10 @@
query.setParameter("checkstatus", param.getCheckstatus().trim());
countQuery.setParameter("checkstatus", param.getCheckstatus().trim());
}
+ if (null!=i&&-1!=i){
+ query.setParameter("custtypeid", param.getCusttypeid());
+ countQuery.setParameter("custtypeid", param.getCusttypeid());
+ }
query.setFirstResult((param.getPageNo() - 1) * param.getPageSize());
query.setMaxResults(param.getPageSize()); //分页显示
query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(CustomerShowBean.class));
@@ -109,6 +146,7 @@
cus.setStatus(customer.getStatus());
cus.setCheckstatus(customer.getCheckstatus());
cus.setInputdate(DateUtil.getNow("yyyyMMdd"));
+ cus.setDeptcode(customer.getDeptcode());
cus = customerDao.save(cus);
if (null != cus) {
if(0==customer.getSavecardflag()){
@@ -169,7 +207,7 @@
String date = DateUtil.getNow("yyyyMMdd");
saveCardver(cardverno, date, c, c.getStatus(), RestaurantConstant.STATUS_CARD_LOGOUT, 0);
}
-
+ discountDetailDao.deleteByUserid(custid);
customerDao.deleteById(custid);
return JsonResult.ok("成功");
@@ -224,6 +262,17 @@
if (null != data[i][4]) {
d.setPhone((String) data[i][4]);
}
+ if(null!=data[i][5]){
+ String deptno=(String)data[i][5];
+ TDept dept=deptService.getDeptByDeptno(deptno);
+ if(null==dept){
+ msg = msg + "第" + i + "行,部门不存在。<br/>";
+ failCnt += 1;
+ }
+ d.setDeptcode(dept.getDeptcode());
+ }
+
+
if(cardDao.countByCardno((String) data[i][1]) > 0){
d.setSavecardflag(1);
msg = msg + "第" + i + "行,卡号已存在,请手动添加市名卡号和银行卡号。<br/>";
@@ -286,7 +335,9 @@
private List<CustomerExportBean> getCustomerExport() {
StringBuffer querySql = new StringBuffer(
- "select c.custname,c.phone,t.cardno,t.bankcardno from tb_card t left join tb_customer c on t.custid=c.custid");
+ "select c.custname,c.phone,t.cardno,t.bankcardno,d.deptname from tb_card t" +
+ " left join tb_customer c on t.custid=c.custid" +
+ "left join tb_dept d on c.deptcode=d.deptcode");
Query query = entityManager.createNativeQuery(querySql.toString());
query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(CustomerExportBean.class));
@@ -309,4 +360,18 @@
return null;
}
+ private List<String> getChildDeptlist( String deptcode) {
+ List<String> childdplist=null;
+ if (!StringUtil.isEmpty(deptcode)) {
+ Query chirdGroupQuery = entityManager.createNativeQuery("WITH RECURSIVE r AS(" +
+ "SELECT * FROM tb_dept WHERE deptcode =:deptcode " +
+ "union ALL " +
+ "SELECT t.* FROM tb_dept t, r WHERE t.fdeptcode = r.deptcode) " +
+ "select deptcode from r order by deptno");
+ chirdGroupQuery.setParameter("deptcode", deptcode);
+ childdplist = chirdGroupQuery.getResultList(); //递归查询所有的子节点
+ }
+ return childdplist;
+ }
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptReportServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptReportServiceImpl.java
index bf9e8a3..ced3370 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptReportServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptReportServiceImpl.java
@@ -4,21 +4,15 @@
import com.supwisdom.dlpay.framework.domain.TOperator;
import com.supwisdom.dlpay.framework.service.SystemUtilService;
import com.supwisdom.dlpay.framework.util.DateUtil;
-import com.supwisdom.dlpay.framework.util.MoneyUtil;
-import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.framework.util.StringUtil;
-import com.supwisdom.dlpay.restaurant.bean.*;
-import com.supwisdom.dlpay.restaurant.dao.*;
-import com.supwisdom.dlpay.restaurant.service.DailyReportService;
+import com.supwisdom.dlpay.restaurant.bean.DeptReportSearchBean;
+import com.supwisdom.dlpay.restaurant.bean.DeptReportSearchData;
+import com.supwisdom.dlpay.restaurant.bean.DeptReportShowBean;
+import com.supwisdom.dlpay.restaurant.dao.CheckCtlDao;
+import com.supwisdom.dlpay.restaurant.dao.DeptDao;
+import com.supwisdom.dlpay.restaurant.dao.MealTypeDao;
+import com.supwisdom.dlpay.restaurant.dao.MealsdtlDao;
import com.supwisdom.dlpay.restaurant.service.DeptReportService;
-import com.supwisdom.dlpay.restaurant.service.DeptService;
-import com.supwisdom.dlpay.restaurant.util.ExcelPoiUtil;
-import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.util.CellRangeAddress;
import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers;
import org.slf4j.Logger;
@@ -30,7 +24,6 @@
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.servlet.http.HttpServletResponse;
-import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptServiceImpl.java
index 96ffa1d..37a2c7b 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeptServiceImpl.java
@@ -10,6 +10,7 @@
import com.supwisdom.dlpay.restaurant.dao.DeptDao;
import com.supwisdom.dlpay.restaurant.domain.TDept;
import com.supwisdom.dlpay.restaurant.service.DeptService;
+import com.supwisdom.dlpay.system.bean.TreeSelectNode;
import com.supwisdom.dlpay.system.bean.ZTreeNode;
import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers;
@@ -40,164 +41,112 @@
private EntityManager entityManager;
+
@Override
- public PageResult<ZTreeNode> getDeptTree() {
- List<TDept> groups=deptDao.findAll();
- List<ZTreeNode> zlist=new ArrayList<>();
- for(TDept g:groups){
- ZTreeNode z=new ZTreeNode();
- z.setId(g.getDeptcode().toString());
- z.setName(g.getDeptname());
- if(g.getFdeptcode()==null){
- z.setpId("0");
- }else{
- z.setpId(g.getDeptcode().toString());
- }
- z.setChecked(false);
- z.setOpen(true);
- zlist.add(z);
+ public PageResult<TDept> getDeptByKey(DeptSearchBean param) {
+ Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize()
+ , Sort.by("deptno"));
+ if (!StringUtil.isEmpty(param.getSearchkey())) {
+ return new PageResult<>(deptDao.findAllByDeptnameContainingOrDeptnoContainingOrderByDeptcode(param.getSearchkey(), param.getSearchkey(), pageable));
}
- PageResult<ZTreeNode> p=new PageResult<>(zlist);
- p.setCode(0);
- return p;
+
+ return new PageResult<>(deptDao.findAll(pageable));
}
@Override
- public PageResult<TDeptShowBean> getDeptByKey(DeptSearchBean param) {
-
- StringBuffer querySql = new StringBuffer("select t.deptcode,t.deptno,t.deptname, " +
- "t.fdeptcode,t.ename,t.lastsaved from tb_dept t where 1=1 ");
- StringBuffer countSql = new StringBuffer("select count(*) as cnt from tb_dept t " +
- " where 1=1 ");
- if (!StringUtil.isEmpty(param.getDeptname())) {
- querySql.append(" and t.deptname like :str ");
- countSql.append(" and t.deptname like :str ");
- }
- if (!StringUtil.isEmpty(param.getDeptcode())) {
- querySql.append(" and t.deptcode = :deptcode ");
- countSql.append(" and t.deptcode = :deptcode ");
- }
- querySql.append(" order by t.deptcode ");
- Query query = entityManager.createNativeQuery(querySql.toString());
- Query countQuery = entityManager.createNativeQuery(countSql.toString());
- if (!StringUtil.isEmpty(param.getDeptname())) {
- query.setParameter("str", "%" + param.getDeptname().trim() + "%");
- countQuery.setParameter("str", "%" + param.getDeptname().trim() + "%");
- }
- if (!StringUtil.isEmpty(param.getDeptcode())) {
- query.setParameter("deptcode", "%" + param.getDeptcode().trim() + "%");
- countQuery.setParameter("deptcode", "%" + param.getDeptcode().trim() + "%");
- }
- query.setFirstResult((param.getPageNo() - 1) * param.getPageSize());
- query.setMaxResults(param.getPageSize()); //分页显示
- query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(TDeptShowBean.class));
- List<TDeptShowBean> list = query.getResultList();
- BigInteger count = (BigInteger) countQuery.getSingleResult();
- return new PageResult<>(count.longValue(), list);
- }
-
- @Override
- public List<TDept> findAll() {
- return deptDao.findAll();
- }
-
- @Override
- public boolean checkDeptnoExists(String deptcode) {
- List<TDept> depts=deptDao.findByDeptcode(deptcode);
- if(depts.size()>0){
- return false;
- }
- return true;
- }
-
- @Override
- public List<TDept> findFDept() {
- return deptDao.findByFdeptcode("0");
+ public List<TDept> findAllDept() {
+ return deptDao.findAllOrderByDeptno();
}
@Override
public JsonResult saveDept(TDept dept) {
+ /* TArea temp = areaDao.findByAreaname(area.getAreaname());
+ if (temp != null) {
+ return JsonResult.error("地区名重复");
+ }*/
dept.setLastsaved(DateUtil.getNow());
dept.setStatus("normal");
deptDao.save(dept);
-
- return JsonResult.ok("保存成功");
+ return JsonResult.ok("成功");
}
@Override
- public JsonResult delete(Long deptcode) {
+ public JsonResult deleteDept(String deptcode) {
+ if("0".equals(deptcode)){
+ return JsonResult.error("根目录不能删除");
+ }
+ if(deptDao.countByFdeptcode(deptcode)>0){
+ return JsonResult.error("不能删除含有子部门的部门");
+ }
deptDao.deleteById(deptcode);
return JsonResult.ok("成功");
}
@Override
- public JsonResult importFile(MultipartFile file, HttpServletRequest request) throws Exception {
- String fname = file.getOriginalFilename();
- if (!fname.endsWith(".xls") && !fname.endsWith(".xlsx")) {
+ public boolean checkDeptnoExist(String deptno) {
+ if (deptDao.checkDeptnoExists(deptno) > 0) {
+ return true;
+ }
+ return false;
+ }
- return JsonResult.error("文件格式错误,请选择excel文件格式(.xls/.xlsx)");
+ @Override
+ public TDept getDeptByDeptno(String deptno) {
+ List<TDept> dept=deptDao.findByDeptno(deptno);
+ return dept.size()>0?dept.get(0):null;
+ }
+
+ public List<TreeSelectNode> getDeptSelectTree(String deptcode) {
+ List<TDept> groupList;
+ String pid;
+ if(StringUtil.isEmpty(deptcode)){
+ groupList = deptDao.findAll();
+ pid="-1";
+ }else{
+ groupList=getChildDeptlist(deptcode);
+ pid="0";
}
-// InputStream excelstream = new FileInputStream(savePath+"/"+fname);
- InputStream excelstream = file.getInputStream();
- List<Object[][]> oList = null;
- try {
- if (fname.endsWith(".xls")) {
- oList = ImportExcelUtil.getIntegralData(excelstream);//2003版本
- } else {
- oList = ImportExcelUtil.getIntegralData07(excelstream);//2007版本以上
- }
- } catch (Exception e) {
- return JsonResult.error("模板格式错误,请重新下载模板");
- }
+ if (StringUtil.isEmpty(groupList)) return new ArrayList<>(0);
+ return getDeptTree(groupList, pid);
+ }
-
- String msg = "";
- Integer successCnt = 0;
- Integer failCnt = 0;
- String batchno = DateUtil.getNow("yyyyMMddHHmmss");
- for (Object[][] data : oList) {
- for (int i = 1; i < data.length; i++) {
- String deptcode=(String) data[i][0];
- String deptname=(String) data[i][1];
- String fdeptcode=(String) data[i][2];
-
- if (StringUtil.isEmpty((String) data[i][0]) || StringUtil.isEmpty((String) data[i][1]) || StringUtil.isEmpty((String) data[i][2])) {
- msg = msg + "第" + i + "行,关键字段缺失。<br/>";
- failCnt += 1;
- } else if (deptDao.countByDeptcode(deptcode) > 0) {
- msg = msg + "第" + i + "行,该部门编号在系统中已存在。<br/>";
- failCnt += 1;
- } else if (deptDao.countByFdeptcode(fdeptcode) > 0) {
- msg = msg + "第" + i + "行,上级部门系统中不存在。<br/>";
- failCnt += 1;
+ private List<TreeSelectNode> getDeptTree(List<TDept> groupList, String pid) {
+ List<TreeSelectNode> result = new ArrayList<>(0);
+ for (TDept gp : groupList) {
+ // if (("-1".equals(pid) && "-1".equals(gp.getFdeptcode())) || (null != pid && pid.equals(gp.getFdeptcode()))) {
+ if ( (null != pid && pid.equals(gp.getFdeptcode()))) {
+ TreeSelectNode node = new TreeSelectNode();
+ node.setId(gp.getDeptcode());
+ node.setName(gp.getDeptname());
+ node.setOpen(true);
+ node.setChecked(false);
+ List<TreeSelectNode> children = getDeptTree(groupList, gp.getDeptcode());
+ if (!StringUtil.isEmpty(children)) {
+ node.setChildren(children);
} else {
- TDept d = new TDept();
- d.setDeptname(deptname);
- d.setDeptcode(deptcode);
- d.setFdeptcode(fdeptcode);
- d.setLastsaved(batchno);
- if (null != data[i][3]) {
- d.setEname((String) data[i][3]);
- }
-
- d.setStatus("normal");
- saveDept(d);
- successCnt += 1;
+ node.setChildren(null);
}
+ result.add(node);
}
}
- /*resp.setCode(Code.SUCCESS);
- // resp.setMsg("成功导入了"+sList.size()+"条信息");
- resp.setMsg(String.format(Locale.CHINESE, msg));
- return resp;*/
+ return result;
+ }
- if (StringUtil.isEmpty(msg)) {
- return JsonResult.ok("成功导入" + oList.size() + "条信息");
+ private List<TDept> getChildDeptlist( String deptcode) {
+ List<TDept> childdplist=null;
+ if (!StringUtil.isEmpty(deptcode)) {
+ Query query = entityManager.createNativeQuery("WITH RECURSIVE r AS(" +
+ "SELECT * FROM tb_dept WHERE deptcode =:deptcode " +
+ "union ALL " +
+ "SELECT t.* FROM tb_dept t, r WHERE t.fdeptcode = r.deptcode) " +
+ "select * from r order by deptno");
+ query.setParameter("deptcode", deptcode);
+
+ query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(TDept.class));
+ childdplist = query.getResultList();
}
- msg = "导入成功" + successCnt + "条,导入失败" + failCnt + "条<br/>" + msg;
-
- return JsonResult.error(String.format(Locale.CHINESE, msg));
+ return childdplist;
}
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
index cce8dfc..7617bb7 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
@@ -1,7 +1,11 @@
package com.supwisdom.dlpay.restaurant.service.impl;
+import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.exception.WebCheckException;
+import com.supwisdom.dlpay.framework.data.NodeData;
import com.supwisdom.dlpay.framework.domain.TOperator;
+import com.supwisdom.dlpay.framework.domain.TPermission;
+import com.supwisdom.dlpay.framework.domain.TRoleFunction;
import com.supwisdom.dlpay.framework.service.SystemUtilService;
import com.supwisdom.dlpay.framework.util.ImportExcelUtil;
import com.supwisdom.dlpay.framework.util.PageResult;
@@ -9,10 +13,12 @@
import com.supwisdom.dlpay.restaurant.bean.*;
import com.supwisdom.dlpay.restaurant.dao.*;
import com.supwisdom.dlpay.restaurant.domain.*;
+import com.supwisdom.dlpay.restaurant.service.CardService;
import com.supwisdom.dlpay.restaurant.service.CustomerListService;
import com.supwisdom.dlpay.restaurant.service.CustomerService;
import com.supwisdom.dlpay.restaurant.service.DeviceDiscountRuleService;
import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import com.supwisdom.dlpay.system.bean.ZTreeNode;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers;
@@ -54,10 +60,12 @@
@Autowired
private CustomerListService customerListService;
-
@Autowired
private CustomerService customerService;
+ @Autowired
+ private CardService cardService;
+
@PersistenceContext
private EntityManager entityManager;
@@ -557,6 +565,62 @@
return true;
}
+ @Override
+ public List<ZTreeNode> getUserDiscount(String custid) {
+ List<NodeData> nodeData = discountRuleDao.findDiscountRuleNode();
+ List<TDiscountDetail> details=discountDetailDao.findAllByUserid(custid);
+ List<ZTreeNode> ret = new ArrayList<>();
+ ZTreeNode zTreeNode = new ZTreeNode();
+ zTreeNode.setpId("-1");
+ zTreeNode.setId("0");
+ zTreeNode.setName("餐补列表");
+ zTreeNode.setChecked(false);
+ zTreeNode.setOpen(true);
+ ret.add(zTreeNode);
+
+ for (NodeData data : nodeData) {
+ zTreeNode = new ZTreeNode();
+ zTreeNode.setpId(data.getPid());
+ zTreeNode.setId(data.getId());
+ zTreeNode.setName(data.getName());
+ zTreeNode.setChecked(false);
+ for(TDiscountDetail detail:details){
+ if(detail.getRuleid().toString().equals(data.getId())){
+ zTreeNode.setChecked(true);
+ }
+ }
+ zTreeNode.setOpen(true);
+ ret.add(zTreeNode);
+ }
+ return ret;
+ }
+
+ @Override
+ public JsonResult saveDiscountDetails(String custid, String rules) {
+ TCustomer customer=customerService.getCustomerByCustid(custid);
+ if(null==customer){
+ return JsonResult.error("客户不存在");
+ }
+ TCard card=cardService.getNormalCardByCustid(custid);
+ discountDetailDao.deleteByUserid(custid);
+ String[] datas = rules.split(",");
+ for (String rule : datas) {
+ if("0".equals(rule)){
+ continue;
+ }
+ TDiscountDetail detail = new TDiscountDetail();
+ detail.setRuleid(Integer.parseInt(rule.trim()));
+ detail.setCardno(card.getCardno());
+ detail.setUsername(customer.getCustname());
+ detail.setUserid(customer.getCustid());
+ detail.setStatus("normal");
+ detail.setLastsaved(systemUtilService.getSysdatetime().getHostdatetime());
+ discountDetailDao.save(detail); //保存明细
+ }
+ return JsonResult.ok("成功");
+
+ }
+
private DiscountDetailAddBean getDiscountDetailForAdd(String custid){
StringBuffer querySql = new StringBuffer("select t.custid,t.custname,c.cardno from tb_customer t " +
"left join tb_card c on t.custid=c.custid where t.custid=:custid ");
diff --git a/src/main/resources/templates/restaurant/customer/discount.html b/src/main/resources/templates/restaurant/customer/discount.html
new file mode 100644
index 0000000..c350363
--- /dev/null
+++ b/src/main/resources/templates/restaurant/customer/discount.html
@@ -0,0 +1,89 @@
+<div style="padding: 0 20px">
+ <div class="layui-form-item" style="max-height: 490px;overflow: auto;">
+ <ul id="discountlist" class="ztree"></ul>
+ </div>
+ <div class="layui-form-item model-form-footer">
+ <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
+ <button class="layui-btn" lay-filter="form-submit" id="discount-submitbtn">保存</button>
+ </div>
+</div>
+<script>
+ layui.use(['layer', 'admin', 'form', 'formSelects'], function () {
+ var layer = layui.layer;
+ var admin = layui.admin;
+ var form = layui.form;
+ var custid = admin.getTempData('custid');
+ let initTree = function (nodes) {
+ let menuSetting = {
+ view: {
+ dblClickExpand: true,
+ showLine: true,
+ showIcon: false
+ },
+ check: {
+ enable: true,
+ },
+ data: {
+ simpleData: {
+ enable: true
+ }
+ }
+ };
+ $.fn.zTree.init($("#discountlist"), menuSetting, nodes);
+ }
+ admin.dgo('[[@{/customer/getdiscount}]]', {
+ custid: custid,
+ }, function (data) {
+ layer.closeAll('loading');
+ if (data.code == 200) {
+ initTree(data.node);
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('[[@{/login}]]');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2});
+ }
+ }, function (ret) {
+ layer.closeAll('loading');
+ layer.msg('请求失败了,请稍后再试', {icon: 2});
+ });
+ $("#discount-submitbtn").on('click', function (e) {
+ let ids = [];
+ let treeObj = $.fn.zTree.getZTreeObj("discountlist");
+ let nodes = treeObj.getCheckedNodes(true);
+ for (let i = 0; i < nodes.length; i++) {
+ ids.push(nodes[i].id);//存功能ID
+ }
+ if (ids.length < 1) {
+ return;
+ }
+ let idStr = ids.toString();
+ console.log(idStr)
+ let token = $("meta[name='_csrf_token']").attr("value");
+ admin.go('[[@{/customer/savediscount}]]', {
+ custid: custid,
+ rules: idStr,
+ _csrf: token,
+ }, function (data) {
+ layer.closeAll('loading');
+ if (data.code == 200) {
+ layer.msg(data.msg, {icon: 1});
+ admin.finishPopupCenter();
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('[[@{/login}]]');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2});
+ }
+ }, function (ret) {
+ console.log(ret);
+ layer.closeAll('loading');
+ layer.msg('请求失败了,请稍后再试', {icon: 2});
+ });
+ })
+ });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/restaurant/customer/form.html b/src/main/resources/templates/restaurant/customer/form.html
index 0ae132f..cc312e3 100644
--- a/src/main/resources/templates/restaurant/customer/form.html
+++ b/src/main/resources/templates/restaurant/customer/form.html
@@ -32,6 +32,14 @@
</select>
</div>
</div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">部门</label>
+ <div class="layui-input-block">
+ <select name="deptcode" id="customer-deptment" lay-verify="required">
+ <option th:each="dept : ${deptlist}" th:value="${dept.deptcode}">[[${dept.deptname}]]</option>
+ </select>
+ </div>
+ </div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">* </span>银行卡号</label>
diff --git a/src/main/resources/templates/restaurant/customer/index.html b/src/main/resources/templates/restaurant/customer/index.html
index 3e91ddc..f896fcf 100644
--- a/src/main/resources/templates/restaurant/customer/index.html
+++ b/src/main/resources/templates/restaurant/customer/index.html
@@ -9,7 +9,21 @@
<div class="layui-card-body">
<div class="layui-form toolbar">
搜索:
- <input id="customer-search-value" class="layui-input search-input" type="text" placeholder="输入姓名"/> 
+ <div class="layui-inline" style="margin-right: 20px;">
+ <input id="customer-search-value" class="layui-input search-input" type="text" placeholder="输入姓名"
+ />
+ <select class="layui-select" id="customer-search-custtype" style="margin-right: 20px">
+ <option value="">全部</option>
+ <option th:each="type : ${typelist}" th:value="${type.custtypeid}">[[${type.custtypename}]]</option>
+ </select>
+ <select class="layui-select" id="customer-search-deptcode" style="margin-right: 20px">
+ <option value="">全部</option>
+ <option th:each="dept : ${deptlist}" th:value="${dept.deptcode}">[[${dept.deptname}]]</option>
+ </select>
+<!-- <input id="search-customer-deptcode" type="text"-->
+<!-- lay-filter="search-customer-deptcode-filter" autocomplete="off"-->
+<!-- class="layui-input search-input"/>-->
+ </div>
<button id="customer-btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
</button>
<button id="customer-btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>添加人员</button>
@@ -19,19 +33,40 @@
<table class="layui-table" id="customer-table" lay-filter="customer-table"></table>
</div>
</div>
-<input hidden th:value="${custtypelist}" id="custtypelist">
<script>
- var rawlist=$("#custtypelist").val();
- var custtypelist=JSON.parse(rawlist);
- layui.use(['form', 'table', 'layer', 'admin', 'element'], function () {
+ layui.use(['form', 'table', 'layer', 'admin', 'element','treeSelect'], function () {
let form = layui.form;
let table = layui.table;
let admin = layui.admin;
+ form.render("select");
- form.render('select');
-
+ // var treeSelect=layui.treeSelect;
+ // treeSelect.render({
+ // elem: '#search-customer-deptcode',
+ // data: '[[@{/customer/depttree}]]',
+ // type: 'get',
+ // placeholder: '选择部门',
+ // search: false,
+ // style: {
+ // folder: {
+ // enable: false
+ // },
+ // line: {
+ // enable: true
+ // }
+ // },
+ // // 点击回调
+ // click: function (d) {
+ // var treeNode = d.current;
+ // console.log(treeNode);
+ // return true;
+ // },
+ // success: function (d) {
+ // console.log(d); // 加载完成后的回调函数
+ // }
+ // });
// 渲染表格
table.render({
elem: '#customer-table',
@@ -40,13 +75,21 @@
minWidth: 80,
cols: [
[
- {field: 'custname', sort: true, width: 120, title: '客户姓名'},
- {field: 'cardno', sort: true,width: 120, title: '市名卡号'},
- {field: 'phone', title: '联系电话'},
- {field: 'bankcardno', sort: true, width: 200, title: '银行卡号'},
- {field: 'inputdate', sort: true, width: 120, title: '保存日期'},
+ {field: 'custname', sort: true, title: '客户姓名'},
+ {field: 'cardno', sort: true, title: '市名卡号'},
+ {field: 'deptname', sort: true, title: '部门'},
+ {field: 'custtypename', title: '客户类别'},
{
- field: 'checkstatus', title: '审核状态', align: 'center', width: 120, sort: true, templet: function (d) {
+ field: 'discnt', title: '有无餐补', align: 'center', width: 120, sort: true, templet: function (d) {
+ if (0< d.discnt) {
+ return '<span class="layui-badge layui-bg-green">有</span>';
+ } else {
+ return '<span class="layui-badge layui-bg-gray">无</span>';
+ }
+ }
+ },
+ {
+ field: 'checkstatus', title: '审核状态', align: 'center', sort: true, templet: function (d) {
if ('uncheck' == d.checkstatus) {
return '<span class="layui-badge layui-bg-orange">待审核</span>'
} else if ('normal' == d.checkstatus) {
@@ -60,17 +103,9 @@
},
{
- field: 'custtype', width:100, title: '人员类别', templet: function (item) {
- if(item.custtype==null){
- return ''
- }else{
- return custtypelist[item.custtype];
- }
- }
- },
- {
- field: 'custid', align: 'center',width:150, title: '操作', fixed: 'right', templet: function (item) {
+ field: 'custid', align: 'center',title: '操作',width:250, fixed: 'right', templet: function (item) {
return ' <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> '+
+ ' <a class="layui-btn layui-btn-xs" lay-event="discount"><i class="layui-icon layui-icon-edit"></i>设置餐补</a> '+
' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>';
}
}
@@ -89,7 +124,9 @@
// 搜索按钮点击事件
$('#customer-btn-search').click(function () {
let key = $('#customer-search-value').val().trim();
- table.reload('customer-table', {where: {searchkey: key}, page: {curr: 1}});
+ let deptcode=$('#customer-search-deptcode').val();
+ let custtypeid=$('#customer-search-custtype').val();
+ table.reload('customer-table', {where: {custname: key,deptcode:deptcode,custtypeid:custtypeid}, page: {curr: 1}});
});
$('#customer-btn-add').click(function () {
showModel();
@@ -127,10 +164,22 @@
console.log(data);
if (layEvent === 'edit') {
showModel(data);
+ } else if (layEvent === 'discount') {
+ showDiscount(data);
} else if (layEvent === 'del') {
showDelete(data);
}
});
+ let showDiscount = function (data) {
+ let title = '分配餐补';
+ admin.putTempData('custid', data.custid);
+ admin.popupCenter({
+ title: title,
+ area:['400px','600px'],
+ path: '[[@{/customer/loaddiscount}]]'
+ });
+ };
+
let showDelete = function (data) {
console.log(data);
layer.confirm('确定要删除吗?', function (i) {
diff --git a/src/main/resources/templates/restaurant/dept/form.html b/src/main/resources/templates/restaurant/dept/form.html
index e828411..33d2c35 100644
--- a/src/main/resources/templates/restaurant/dept/form.html
+++ b/src/main/resources/templates/restaurant/dept/form.html
@@ -1,50 +1,36 @@
+<!-- operator表单弹窗 -->
+<form id="dept-form" lay-filter="dept-form" class="layui-form model-form">
+ <input name="deptcode" id="deptcode" type="hidden"/>
-<form id="dept-form" lay-filter="form" class="layui-form model-form">
- <input name="deptno" id="dept-id" type="hidden"/>
<div class="layui-form-item">
- <label class="layui-form-label"><span style="color: red">* </span>部门代码</label>
+ <label class="layui-form-label">部门代码</label>
<div class="layui-input-block">
- <input name="deptcode" placeholder="不能重复" type="text" class="layui-input" maxlength="20"
- lay-verify="required|deptcode" required/>
+ <input name="deptno" placeholder="" type="text" class="layui-input"
+ lay-verify="deptcode" />
</div>
</div>
+
<div class="layui-form-item">
- <label class="layui-form-label"><span style="color: red">* </span>部门名称</label>
+ <label class="layui-form-label">部门名称</label>
<div class="layui-input-block">
- <input name="deptname" type="text" class="layui-input"
- required/>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"></span>部门英语名称</label>
- <div class="layui-input-block">
- <input name="ename" type="text" class="layui-input" maxlength="20"
- />
+ <input name="deptname" placeholder="" type="text" class="layui-input"
+ lay-verify="required" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">上级部门</label>
<div class="layui-input-block">
- <select name="fdeptcode" id="dept-fdeptcode" lay-verify="required">
- <option value="0">根部门</option>
- <option th:each="type : ${fdeptlist}" th:value="${type.deptcode}">[[${type.deptname}]]</option>
+ <select name="fdeptcode" id="fdeptcode" lay-verify="required">
+ <!-- <option value="0">根部门</option>-->
+ <option th:each="dept : ${deptlist}" th:value="${dept.deptcode}">[[${dept.deptname}]]</option>
</select>
</div>
</div>
- <!-- <div class="layui-form-item">
- <label class="layui-form-label">上级部门</label>
- <div class="layui-input-block">
- <input type="text" name="fdeptcode" id="dept-fdeptcode" lay-filter="dept-search-fdeptcode-filter"
- autocomplete="off" class="layui-input"/>
- </div>
- </div>-->
-
-
<div class="layui-form-item model-form-footer">
<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
- <button class="layui-btn" lay-filter="dept-form-submit" lay-submit id="submitbtn">保存</button>
+ <button class="layui-btn" lay-filter="dept-form-submit" lay-submit id="dept-submitbtn">保存</button>
</div>
</form>
@@ -53,22 +39,24 @@
var layer = layui.layer;
var admin = layui.admin;
var form = layui.form;
- form.render('select');
- form.render('radio');
- form.verify({
+ form.render('select');
+
+ form.verify({
"deptcode": function (e) {
- if(""==e|| ""==$.trim(e)){
+ if ("" == e || "" == $.trim(e)) {
return "部门代码不能为空";
}
-
var msg = "";
+ if(ct){
+ return;
+ }
$.ajax({
type: "GET",
- url: '[[@{/dept/checkdeptcode}]]',
+ url: '[[@{/dept/checkdeptno}]]',
async: false, //同步提交。不设置则默认异步,异步的话,最后执行ajax
data: {
- deptcode: e,
+ deptno: e
},
success: function (result) {
if (result.code != 200) {
@@ -85,23 +73,18 @@
}
});
- var url = '[[@{/dept/add}]]';
+
+ var url = '[[@{/dept/adddept}]]';
// 回显user数据
- var dev = admin.getTempData('t_dev');
- if (dev) {
- $('input[name="deptcode"]').attr('readonly', 'readonly');
- form.val('form', dev);
+ var ct = admin.getTempData('t_ct');
+ if (ct) {
+ // $('input[name="deptid"]').attr('readonly', 'readonly');
+ form.val('dept-form', ct);
}
- /* let fid = admin.getTempData("fid");
- if (fid) {
- form.val('form', {"fid": fid});
- }*/
// 表单提交事件
form.on('submit(dept-form-submit)', function (data) {
- console.log(data);
layer.load(2);
let token = $("meta[name='_csrf_token']").attr("value");
- console.log(token);
$.ajax({
type: "POST",
dataType: "json",
@@ -135,4 +118,5 @@
return false;
});
});
-</script>
\ No newline at end of file
+</script>
+
diff --git a/src/main/resources/templates/restaurant/dept/index.html b/src/main/resources/templates/restaurant/dept/index.html
index 718795c..7986a86 100644
--- a/src/main/resources/templates/restaurant/dept/index.html
+++ b/src/main/resources/templates/restaurant/dept/index.html
@@ -9,60 +9,57 @@
<div class="layui-card-body">
<div class="layui-form toolbar">
搜索:
- <input id="dept-deptname" class="layui-input search-input" type="text" placeholder="部门名称"/> 
- <input id="dept-deptcode" class="layui-input search-input" type="text" placeholder="部门代码"/> 
-
+ <input id="dept-search-value" class="layui-input search-input" type="text" placeholder="输入部门代码或名称"/> 
<button id="dept-btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
</button>
<button id="dept-btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>添加部门</button>
- <button id="dept-btn-import" class="layui-btn icon-btn" ><i class="layui-icon"></i>批量导入</button>
-
</div>
<table class="layui-table" id="dept-table" lay-filter="dept-table"></table>
</div>
</div>
-<input hidden th:value="${deptList}" id="deptlist">
+<input hidden th:value="${deptList}" id="dplist">
<script>
-
- var rawlist=$("#deptlist").val();
- var deptlist=JSON.parse(rawlist);
+ var rawlist=$("#dplist").val();
+ var dplist=JSON.parse(rawlist);
layui.use(['form', 'table', 'layer', 'admin', 'element'], function () {
let form = layui.form;
let table = layui.table;
let admin = layui.admin;
- form.render('select');
+ // form.render('select');
// 渲染表格
table.render({
elem: '#dept-table',
- url: '[[@{/dept/list}]]',
+ url: '[[@{/dept/listdept}]]',
page: true,
cols: [
[
- {field: 'deptcode', title: '部门代码', sort: true},
- {field: 'deptname', sort: true, width: 200, title: '部门名称'},
- {field: 'fdeptcode',
- sort: true, width: 200,
- title: '上级部门名称',
+ {field: 'deptno', title: '部门代码', sort: true},
+ {field: 'deptname', title: '部门名称', sort: true},
+ {
+ field: 'fdeptcode',
+ title: '上级部门',
+ sort: true,
+
+ align: 'center',
templet: function (item) {
- if (item.fdeptcode == '0') {
- return '根部门';
- } else {
- return deptlist[item.deptcode];
+ for(var i=0 ;i<dplist.length;i++){
+ if(item.fdeptcode==dplist[i].deptcode){
+ return dplist[i].deptname;
+ }
}
- // return areaList.get(item.id);
- }},
- {field: 'ename', sort: true, width: 200, title: '部门英语名称'},
- {field: 'lastsaved', sort: true, width: 170, title: '保存时间'},
-
+ return item.deptno;
+ }
+ },
+ {field: 'lastsaved', title: '修改日期', sort: true},
{
- field: 'id', align: 'center', title: '操作', fixed: 'right', templet: function (item) {
- return ' <a class="layui-btn layui-btn-xs" lay-event="dept-edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> '+
- ' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="dept-del"><i class="layui-icon layui-icon-delete"></i>删除</a>';;
+ field: 'deptcode', align: 'center',width:160, title: '操作', fixed: 'right', templet: function (item) {
+ return ' <a class="layui-btn layui-btn-xs" lay-event="dept-edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> ' +
+ ' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="dept-del"><i class="layui-icon layui-icon-delete"></i>删除</a>'
}
}
]
@@ -70,37 +67,23 @@
});
// 搜索按钮点击事件
$('#dept-btn-search').click(function () {
- let key = $('#dept-search-value').val().trim();
+ let key = $('#dept-search-value').val();
table.reload('dept-table', {where: {searchkey: key}, page: {curr: 1}});
});
$('#dept-btn-add').click(function () {
- showDeptModel();
+ showModel();
});
- $('#dept-btn-import').click(function () {
- showDownload();
- });
- let showDownload = function () {
- let title ='导入';
+ let showModel = function (data) {
+ let title = data ? '修改客户部门' : '添加客户部门';
+ admin.putTempData('t_ct', data);
admin.popupCenter({
title: title,
- path: '[[@{/dept/loadimport}]]',
+ path: '[[@{/dept/loaddeptadd}]]',
finish: function () {
table.reload('dept-table', {});
}
});
};
- let showDeptModel = function (data) {
- let title = data ? '修改部门' : '添加部门';
- admin.putTempData('t_dev', data);
- admin.popupCenter({
- title: title,
- path: '[[@{/dept/loadadd}]]',
- finish: function () {
- table.reload('dept-table', {});
- }
- });
- };
-
// 工具条点击事件
table.on('tool(dept-table)', function (obj) {
@@ -108,18 +91,22 @@
let layEvent = obj.event;
console.log(data);
if (layEvent === 'dept-edit') {
- showDeptModel(data);
- }else if (layEvent === 'dept-del') {
- showDeptDelete(data);
+ showModel(data);
+ } else if (layEvent === 'dept-del') {
+ showDelete(data);
}
});
- let showDeptDelete = function (data) {
+ let showDelete = function (data) {
+ if('0'==data.deptcode){
+ layer.msg('根目录无法删除!', {icon: 2, time: 1500});
+ return;
+ }
layer.confirm('确定要删除吗?', function (i) {
layer.close(i);
layer.load(2);
let token = $("meta[name='_csrf_token']").attr("value");
- admin.go('[[@{/dept/delete}]]', {
- deptno: data.deptno,
+ admin.go('[[@{/dept/deletedept}]]', {
+ deptcode: data.deptcode,
_csrf: token
}, function (data) {
console.log(data.code);
@@ -141,8 +128,6 @@
layer.msg('请求失败了,请稍后再试', {icon: 2});
});
});
- };
-
-
+ }
});
</script>