Prechádzať zdrojové kódy

午餐订单模块文档下载

user5 5 rokov pred
rodič
commit
2309e93797

+ 3 - 0
src/main/java/com/jeeplus/modules/wexintheorder/dao/TheOrderWebDao.java

@@ -16,4 +16,7 @@ public interface TheOrderWebDao extends CrudDao<TheOrder> {
     /*根据分管领导查询订餐或预定信息*/
     List<TheOrder> getTheOrderListByLeadership(TheOrder theOrder);
 
+    /*根据分管领导查询预定信息总量(按部门)*/
+    List<TheOrder> getTheOrderListCountByDepartment(TheOrder theOrder);
+
 }

+ 28 - 3
src/main/java/com/jeeplus/modules/wexintheorder/entity/TheOrder.java

@@ -1,15 +1,16 @@
 package com.jeeplus.modules.wexintheorder.entity;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.jeeplus.common.persistence.DataEntity;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
 
-import javax.xml.crypto.Data;
 import java.util.Date;
 
 public class TheOrder extends DataEntity<TheOrder> {
     private String name;//姓名
     private String department;//部门
-    private String team;
-    private String specific;
+    private String team; //团队
+    private String specific; //具体部门
     private Date scheduled;//预定餐
     private String correlationId;//关联id
     private String status;//有无回显 1-回显 2-本来就有
@@ -17,6 +18,25 @@ public class TheOrder extends DataEntity<TheOrder> {
     private String DateStart;
     private Date beginDate;
     private Date EndDate;
+    private String serialNumber;
+    private String number;
+
+
+    public String getNumber() {
+        return number;
+    }
+
+    public void setNumber(String number) {
+        this.number = number;
+    }
+
+    @ExcelField(title="序号", align=2, sort=1)
+    public String getSerialNumber() {
+        return serialNumber;
+    }
+    public void setSerialNumber(String serialNumber) {
+        this.serialNumber = serialNumber;
+    }
 
     public Date getEndDate() {
         return EndDate;
@@ -50,6 +70,7 @@ public class TheOrder extends DataEntity<TheOrder> {
         DateStart = dateStart;
     }
 
+    @ExcelField(title="姓名", align=2, sort=2)
     public String getName() {
         return name;
     }
@@ -66,6 +87,7 @@ public class TheOrder extends DataEntity<TheOrder> {
         this.department = department;
     }
 
+    @ExcelField(title="团队", align=2, sort=3)
     public String getTeam() {
         return team;
     }
@@ -74,6 +96,7 @@ public class TheOrder extends DataEntity<TheOrder> {
         this.team = team;
     }
 
+    @ExcelField(title="部门", align=2, sort=4)
     public String getSpecific() {
         return specific;
     }
@@ -82,6 +105,8 @@ public class TheOrder extends DataEntity<TheOrder> {
         this.specific = specific;
     }
 
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @ExcelField(title="预定时间", align=2, sort=5)
     public Date getScheduled() {
         return scheduled;
     }

+ 1 - 3
src/main/java/com/jeeplus/modules/wexintheorder/service/TheOrderLeadership.java

@@ -1,6 +1,4 @@
-package com.jeeplus.modules.wexintheorder.service;
-
-import com.jeeplus.modules.wexintheorder.entity.TheOrder;
+package com.jeeplus.modules.wexintheorder.entity;
 
 import java.util.List;
 

+ 14 - 2
src/main/java/com/jeeplus/modules/wexintheorder/service/TheOrderWebService.java

@@ -32,11 +32,11 @@ public class TheOrderWebService extends CrudService<TheOrderWebDao,TheOrder>{
         }
         Date time = new Date();
         if (null == theOrder.getBeginDate()){
-            time = time(0);
+            time = time(1);
             theOrder.setBeginDate(time);
         }
         if (null == theOrder.getEndDate()){
-            time = time(1);
+            time = time(2);
             theOrder.setEndDate(time);
         }
         int count = dao.queryCount(theOrder);
@@ -62,6 +62,9 @@ public class TheOrderWebService extends CrudService<TheOrderWebDao,TheOrder>{
             } else if (1 == status){
                 c.add(Calendar.DAY_OF_MONTH, 1);
                 date = sf.parse(sf.format(c.getTime()));
+            } else if (2 == status){
+                c.add(Calendar.DAY_OF_MONTH, 2);
+                date = sf.parse(sf.format(c.getTime()));
             }
             System.out.println(date);
         } catch (ParseException e) {
@@ -83,5 +86,14 @@ public class TheOrderWebService extends CrudService<TheOrderWebDao,TheOrder>{
         return dao.getTheOrderListByLeadership(theOrder);
     }
 
+    /**
+     * 根据分管领导查询预定信息总量(按部门)
+     * @param theOrder
+     * @return
+     */
+    public List<TheOrder> getTheOrderListCountByDepartment(TheOrder theOrder){
+        return dao.getTheOrderListCountByDepartment(theOrder);
+    }
+
 
 }

+ 49 - 7
src/main/java/com/jeeplus/modules/wexintheorder/utils/TheOrderExportExcel.java

@@ -7,7 +7,7 @@ import com.jeeplus.common.utils.excel.ExportExcel;
 import com.jeeplus.common.utils.excel.annotation.ExcelField;
 import com.jeeplus.modules.sys.utils.DictUtils;
 import com.jeeplus.modules.wexintheorder.entity.TheOrder;
-import com.jeeplus.modules.wexintheorder.service.TheOrderLeadership;
+import com.jeeplus.modules.wexintheorder.entity.TheOrderLeadership;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
@@ -66,8 +66,8 @@ public class TheOrderExportExcel {
      * @param title 表格标题,传“空值”,表示无标题
      * @param cls 实体对象,通过annotation.ExportField获取标题
      */
-    public TheOrderExportExcel(String title, List<TheOrderLeadership> theOrderList, List<TheOrder> leadershipList, Class<?> cls){
-        this(title, theOrderList,leadershipList , cls, 1);
+    public TheOrderExportExcel(String title, List<TheOrderLeadership> theOrderList, List<TheOrder> leadershipList,List<TheOrder> theOrderListCountByDepartment, Class<?> cls){
+        this(title, theOrderList,leadershipList,theOrderListCountByDepartment , cls, 1);
     }
 
     /**
@@ -77,8 +77,7 @@ public class TheOrderExportExcel {
      * @param type 导出类型(1:导出数据;2:导出模板)
      * @param groups 导入分组
      */
-    public TheOrderExportExcel(String title, List<TheOrderLeadership> theOrderList,List<TheOrder> leadershipList, Class<?> cls, int type, int... groups){
-        // Get annotation field
+    public TheOrderExportExcel(String title, List<TheOrderLeadership> theOrderList,List<TheOrder> leadershipList,List<TheOrder> theOrderListCountByDepartment, Class<?> cls, int type, int... groups){
         Field[] fs = cls.getDeclaredFields();
         for (Field f : fs){
             ExcelField ef = f.getAnnotation(ExcelField.class);
@@ -145,7 +144,7 @@ public class TheOrderExportExcel {
             }
             headerList.add(t);
         }
-        initialize(title, headerList, theOrderList,leadershipList);
+        initialize(title, headerList, theOrderList,leadershipList,theOrderListCountByDepartment);
     }
 
     /**
@@ -153,8 +152,51 @@ public class TheOrderExportExcel {
      * @param title 表格标题,传“空值”,表示无标题
      * @param headerList 表头列表
      */
-    private void initialize(String title, List<String> headerList,List<TheOrderLeadership> theOrderList, List<TheOrder> leadershipList) {
+    private void initialize(String title, List<String> headerList,List<TheOrderLeadership> theOrderList, List<TheOrder> leadershipList,List<TheOrder> theOrderListCountByDepartment) {
         this.wb = new SXSSFWorkbook(500);
+        this.sheet = wb.createSheet("统计");
+        this.styles = createStyles(wb);
+        rownum = 0;
+        // Create title
+        if (StringUtils.isNotBlank(title)){
+            Row titleRow = sheet.createRow(rownum++);
+            titleRow.setHeightInPoints(30);
+            Cell titleCell = titleRow.createCell(0);
+            titleCell.setCellStyle(styles.get("title"));
+            titleCell.setCellValue(title);
+            sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
+                    titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-2));
+        }
+        Row headerRows = sheet.createRow(rownum++);
+        headerRows.setHeightInPoints(16);
+        for (int cellnum = 0; cellnum < 4; cellnum++) {
+            Cell cell = headerRows.createCell(cellnum);
+            cell.setCellStyle(styles.get("header"));
+            int colWidth = sheet.getColumnWidth(cellnum)*2;
+            sheet.setColumnWidth(cellnum, colWidth < 3000 ? 3000 : colWidth);
+            // 判断单元格
+            if (cellnum == 0) {
+                cell.setCellValue("序列");
+            } else if (cellnum == 1) {
+                cell.setCellValue("团队");
+            } else if (cellnum == 2) {
+                cell.setCellValue("部门");
+            } else if (cellnum == 3) {
+                cell.setCellValue("订餐人数");
+            } else {
+                cell.setCellValue("");
+            }
+        }
+
+        // 遍历创建行,导出数据
+        for (int rownum = 1; rownum <= theOrderListCountByDepartment.size(); rownum++) {
+            Row cells = this.addRow();
+            this.addCell(cells, 0, theOrderListCountByDepartment.get(rownum - 1).getSerialNumber(), 2, null);
+            this.addCell(cells, 1, theOrderListCountByDepartment.get(rownum - 1).getTeam(), 2, null);
+            this.addCell(cells, 2, theOrderListCountByDepartment.get(rownum - 1).getDepartment(), 2, null);
+            this.addCell(cells, 3, theOrderListCountByDepartment.get(rownum - 1).getNumber(), 2, null);
+        }
+
         for (TheOrderLeadership theOrder: theOrderList) {
             this.sheet = wb.createSheet(theOrder.getLeadership());
             this.styles = createStyles(wb);

+ 7 - 21
src/main/java/com/jeeplus/modules/wexintheorder/web/TheOrderWebController.java

@@ -2,11 +2,10 @@ package com.jeeplus.modules.wexintheorder.web;
 
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.persistence.Page;
-import com.jeeplus.common.utils.DateUtils;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.common.web.BaseController;
 import com.jeeplus.modules.wexintheorder.entity.TheOrder;
-import com.jeeplus.modules.wexintheorder.service.TheOrderLeadership;
+import com.jeeplus.modules.wexintheorder.entity.TheOrderLeadership;
 import com.jeeplus.modules.wexintheorder.service.TheOrderWebService;
 import com.jeeplus.modules.wexintheorder.utils.TheOrderExportExcel;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -65,18 +64,14 @@ public class TheOrderWebController extends BaseController {
     @RequestMapping(value = "export", method= RequestMethod.POST)
     public String exportFile(TheOrder theOrder, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) throws IOException {
         /*try {*/
-            String fileHeader = null;
+            String fileHeader = "预订单";
             String excelHeaderName = null;
-            if (null != theOrder.getOrderStatus() && 0 == theOrder.getOrderStatus()){
-                fileHeader = "预订单";
-            }else if (null != theOrder.getOrderStatus() && 1 == theOrder.getOrderStatus()){
-                fileHeader = "确定单";
-            }
             if (null != theOrder.getBeginDate()){
                 excelHeaderName = dateTimeStr(theOrder.getBeginDate());
             }
-            String fileName = fileHeader+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
-            List<TheOrder> leadershipList = this.getLeadershipList(theOrder);
+            String fileName = fileHeader+ excelHeaderName+".xlsx";
+            List<TheOrder> leadershipList = theOrderWebService.getLeadershipList(theOrder);
+            List<TheOrder> theOrderListCountByDepartment = theOrderWebService.getTheOrderListCountByDepartment(theOrder);
             List<TheOrderLeadership> theOrderList = new ArrayList<>();
 
             //根据分管领导名称查询对应数据
@@ -86,12 +81,12 @@ public class TheOrderWebController extends BaseController {
                 leadership.setEndDate(theOrder.getEndDate());
                 leadership.setOrderStatus(theOrder.getOrderStatus());
                 List<TheOrder> theOrderListByLeadership = theOrderWebService.getTheOrderListByLeadership(leadership);
-//                theOrderLeadership.setLeadership(leadership.getLeadership());
+                theOrderLeadership.setLeadership(leadership.getDepartment());
                 theOrderLeadership.setTheOrderList(theOrderListByLeadership);
                 theOrderList.add(theOrderLeadership);
             }
 
-            new TheOrderExportExcel(excelHeaderName + fileHeader, theOrderList,leadershipList, TheOrder.class).write(response, fileName).dispose();
+            new TheOrderExportExcel(excelHeaderName + fileHeader, theOrderList,leadershipList,theOrderListCountByDepartment, TheOrder.class).write(response, fileName).dispose();
             //return null;
         /*} catch (Exception e) {
             addMessage(redirectAttributes, "导出项目记录失败!失败信息:"+e.getMessage());
@@ -104,13 +99,4 @@ public class TheOrderWebController extends BaseController {
         Calendar c = Calendar.getInstance();
         return sf.format(dateTime);
     }
-
-    /**
-     * 查询分管领导名称
-     * @param theOrder
-     * @return
-     */
-    private List<TheOrder> getLeadershipList(TheOrder theOrder){
-        return theOrderWebService.getLeadershipList(theOrder);
-    }
 }

+ 53 - 49
src/main/resources/mappings/modules/wexintheorder/TheOrderWebDao.xml

@@ -2,19 +2,19 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jeeplus.modules.wexintheorder.dao.TheOrderWebDao">
 	<sql id="orderColumns">
-		a.id AS "id",
-		a.create_by AS "createBy.id",
-		a.create_date AS "createDate",
-		a.update_by AS "updateBy.id",
-		a.update_date AS "updateDate",
-		a.remarks AS "remarks",
-		a.del_flag AS "delFlag",
-		a.name AS "name",
-		a.department AS "department",
-		a.leadership AS "leadership",
-		a.confirmOrder AS "confirmOrder",
-		a.scheduled AS "scheduled",
-		a.correlationId AS "correlationId"
+	  a.id,
+	  a.create_by AS "createBy.id",
+	  a.create_date AS "createDate",
+	  a.update_by AS "updateBy.id",
+	  a.update_date AS "updateDate",
+	  a.del_flag as "delFlag",
+	  a.remarks,
+	  a.name,
+	  a.team,
+	  a.financial,
+	  a.specific,
+	  a.scheduled,
+	  a.correlationId
 	</sql>
 
 	<sql id="orderLeftJoinColumns">
@@ -26,6 +26,7 @@
 	<select id="get" resultType="com.jeeplus.modules.wexintheorder.entity.TheOrder">
 		SELECT
 		<include refid="orderColumns"/>
+		,a.department
 		FROM the_order a
 		WHERE a.id = #{id}
 	</select>
@@ -33,11 +34,12 @@
 	<select id="findList" resultType="com.jeeplus.modules.wexintheorder.entity.TheOrder" >
 		SELECT
 		<include refid="orderColumns"/>
+		, concat_ws(" / ",a.department,a.specific) as department
 		FROM the_order a
 		<include refid="orderLeftJoinColumns"/>
 		<where>
 			a.del_flag = #{DEL_FLAG_NORMAL}
-			<if test="orderStatus != null and orderStatus = 0">
+			<if test="orderStatus != null and orderStatus == 0">
 				<if test="beginDate !=null">
 					and a.scheduled >= #{beginDate}
 				</if>
@@ -45,21 +47,13 @@
 					and a.scheduled &lt; #{endDate}
 				</if>
 			</if>
-			<if test="orderStatus != null and orderStatus = 1">
-				<if test="beginDate !=null">
-					and a.confirmOrder >= #{beginDate}
-				</if>
-				<if test="endDate !=null">
-					and a.confirmOrder &lt; #{endDate}
-				</if>
-			</if>
 		</where>
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY sc.id desc , so.id desc , a.leadership desc, a.create_date asc , ${page.orderBy}
+				ORDER BY a.team asc,a.department asc,a.specific asc ,sc.id desc , so.id desc, a.create_date asc , ${page.orderBy}
 			</when>
 			<otherwise>
-				ORDER BY sc.id desc , so.id desc, a.leadership desc, a.create_date asc
+				ORDER BY a.team asc,a.department asc,a.specific asc ,sc.id desc , so.id desc, a.create_date asc
 			</otherwise>
 		</choose>
 	</select>
@@ -68,7 +62,7 @@
 		SELECT count(DISTINCT a.id)
 		from the_order a
 	  	<where>
-			<if test="orderStatus != null and orderStatus = 0">
+			<if test="orderStatus != null and orderStatus == 0">
 				<if test="beginDate !=null">
 					and a.scheduled >= #{beginDate}
 				</if>
@@ -76,36 +70,18 @@
 					and a.scheduled &lt; #{endDate}
 				</if>
 			</if>
-			<if test="orderStatus != null and orderStatus = 1">
-				<if test="beginDate !=null">
-					and a.confirmOrder >= #{beginDate}
-				</if>
-				<if test="endDate !=null">
-					and a.confirmOrder &lt; #{endDate}
-				</if>
-			</if>
 		</where>
 	</select>
 
 	<!-- 查询分管领导名称 -->
 	<select id="getLeadershipList" resultType="com.jeeplus.modules.wexintheorder.entity.TheOrder">
-		select distinct(a.leadership) as leadership from the_order a
+		select distinct(a.department) as department from the_order a
 		<where>
-			<if test="orderStatus != null and orderStatus = 0">
-				<if test="beginDate !=null">
-					and a.scheduled >= #{beginDate}
-				</if>
-				<if test="endDate !=null">
-					and a.scheduled &lt; #{endDate}
-				</if>
+			<if test="beginDate !=null">
+				and a.scheduled >= #{beginDate}
 			</if>
-			<if test="orderStatus != null and orderStatus = 1">
-				<if test="beginDate !=null">
-					and a.confirmOrder >= #{beginDate}
-				</if>
-				<if test="endDate !=null">
-					and a.confirmOrder &lt; #{endDate}
-				</if>
+			<if test="endDate !=null">
+				and a.scheduled &lt; #{endDate}
 			</if>
 		</where>
 	</select>
@@ -114,11 +90,39 @@
 	select (@rownum :=@rownum + 1) as "serialNumber",theOrder.* from (
 		select
 			<include refid="orderColumns"/>
+		,a.department
 		from the_order a
 			<include refid="orderLeftJoinColumns"/>
-		where a.leadership=#{leadership}
+		<where>
+			a.department=#{department}
+			<if test="beginDate !=null">
+				and a.scheduled >= #{beginDate}
+			</if>
+			<if test="endDate !=null">
+				and a.scheduled &lt; #{endDate}
+			</if>
+		</where>
 		order by sc.id desc ,so.id desc,a.create_date asc) as theOrder ,(select @rownum := 0) temp
 	</select>
 
 
+	<select id="getTheOrderListCountByDepartment" resultType="com.jeeplus.modules.wexintheorder.entity.TheOrder">
+		select (@rownum :=@rownum + 1) as "serialNumber",theOrder.* from (
+		select
+		<include refid="orderColumns"/>
+		, concat_ws(" / ",a.department,a.specific) as department,count(1) as `number`
+		from the_order a
+		<include refid="orderLeftJoinColumns"/>
+		<where>
+			<if test="beginDate !=null">
+				and a.scheduled >= #{beginDate}
+			</if>
+			<if test="endDate !=null">
+				and a.scheduled &lt; #{endDate}
+			</if>
+		</where>
+		group by a.specific
+		order by a.specific desc,a.team asc,a.department asc,sc.id desc ,so.id desc,a.create_date asc) as theOrder ,(select @rownum := 0) temp
+	</select>
+
 </mapper>

+ 6 - 19
src/main/webapp/webpage/modules/theorder/theOrderList.jsp

@@ -21,15 +21,13 @@
                 elem: '#beginDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎,因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                 event: 'focus', //响应事件。如果没有传入event,则按照默认的click
                 type : 'date',
-                value: new Date(),
-                done: function (value, date) {
-                }
+                value : getRecentDay(1)
             });
             laydate.render({
                 elem: '#endDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎,因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                 event: 'focus', //响应事件。如果没有传入event,则按照默认的click
                 type : 'date',
-                value : getRecentDay(1)
+                value : getRecentDay(2)
             });
         });
 
@@ -90,15 +88,6 @@
 								</input>
 							</div>
 						</div>
-						<div class="layui-item query athird ">
-							<label class="layui-form-label">状态:</label>
-							<div class="layui-input-block">
-								<form:select path="orderStatus" class=" form-control  simple-select">
-									<form:option value="0" label="预定信息"/>
-									<form:option value="1" label="确定信息"/>
-								</form:select>
-							</div>
-						</div>
 						<div class="layui-item athird">
 							<div class="input-group">
 								<a href="#" id="moresee"><i class="glyphicon glyphicon-menu-down"></i></a>
@@ -144,13 +133,12 @@
                 ,{field:'name', align:'center',title: '姓名',minWidth:100,templet:function(d){
                         return "<span title='"+ d.name +"'>" + d.name + "</span>";
                     }}
+                ,{field:'team', align:'center',title: '团队',minWidth:100,templet:function(d){
+                        return "<span title='"+ d.team +"'>" + d.team + "</span>";
+                    }}
                 ,{field:'department', align:'center',title: '部门',minWidth:100,templet:function(d){
                         return "<span title='"+ d.department +"'>" + d.department + "</span>";
                     }}
-                ,{field:'leadership', align:'center',title: '分管领导',minWidth:100,templet:function(d){
-                        return "<span title='"+ d.leadership +"'>" + d.leadership + "</span>";
-                    }}
-                ,{field:'confirmOrder',align:'center', title: '订餐时间',  width:180}
                 ,{field:'scheduled',align:'center', title: '预定时间',  width:180}
                 ,{field:'createDate',align:'center', title: '创建时间',  width:180}
             ]]
@@ -162,9 +150,8 @@
                     "index":"${index.index+1}"
                     ,"id":"${theOrder.id}"
                     ,"name":"${theOrder.name}"
+                    ,"team":"${theOrder.team}"
                     ,"department":"${theOrder.department}"
-                    ,"leadership":"${theOrder.leadership}"
-                    ,"confirmOrder":"<fmt:formatDate value="${theOrder.confirmOrder}" pattern="yyyy-MM-dd HH:ss:mm"/>"
                     ,"scheduled":"<fmt:formatDate value="${theOrder.scheduled}" pattern="yyyy-MM-dd HH:ss:mm"/>"
                     ,"createDate":"<fmt:formatDate value="${theOrder.createDate}" pattern="yyyy-MM-dd HH:ss:mm"/>"
                 }