wuxiang vor 4 Tagen
Ursprung
Commit
53bee8649d

+ 7 - 0
supervision-admin/pom.xml

@@ -43,6 +43,13 @@
             <scope>runtime</scope>
         </dependency>
 
+        <!-- EasyExcel -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.1.1</version>
+        </dependency>
+
         <!-- 核心模块-->
         <dependency>
             <groupId>com.supervision</groupId>

+ 197 - 11
supervision-admin/src/main/java/com/supervision/web/controller/grassrootsregistration/BdglCookbookController.java

@@ -1,23 +1,22 @@
 package com.supervision.web.controller.grassrootsregistration;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import com.supervision.common.core.domain.entity.SysRole;
 import com.supervision.common.core.domain.model.LoginUser;
-import com.supervision.framework.web.domain.server.Sys;
-import com.supervision.system.domain.BdglCookcategory;
+import com.supervision.grassrootsregistration.domain.BdglCookbookRegistration;
 import com.supervision.system.mapper.SysUserMapper;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.supervision.common.annotation.Log;
 import com.supervision.common.core.controller.BaseController;
 import com.supervision.common.core.domain.AjaxResult;
@@ -27,6 +26,8 @@ import com.supervision.grassrootsregistration.service.IBdglCookbookService;
 import com.supervision.common.utils.poi.ExcelUtil;
 import com.supervision.common.core.page.TableDataInfo;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 一周食谱Controller
  * 
@@ -53,7 +54,7 @@ public class BdglCookbookController extends BaseController
         List<SysRole> sysRoles = userMapper.selectRole(loginUser.getUserId());
         String role = CommonsController.getRole(sysRoles);
         //判断当前角色是否是最高权限   不是返回当前部门数据
-        if(!"user_admin".equals(role)){
+        if(!"admin".equals(role)){
             bdglCookbook.setUnitId(Integer.parseInt(loginUser.getDeptId().toString()));
         }
         startPage();
@@ -74,6 +75,191 @@ public class BdglCookbookController extends BaseController
         return util.exportExcel(list, "一周食谱数据");
     }
 
+    /**
+     * 导出指定食谱列表excel
+     */
+    @PreAuthorize("@ss.hasPermi('grassrootsregistration:bdglcookbook:export')")
+    /**
+     * 导出一周食谱Excel
+     * 完全按照表格格式实现导出功能
+     */
+    @GetMapping("/exportExcel/{id}")
+    public void exportExcel(@PathVariable("id") Integer id, HttpServletResponse response) throws IOException {
+        // 设置响应头
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        String fileName = URLEncoder.encode("食谱表", "UTF-8") + ".xlsx";
+        response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + fileName);
+
+        // 创建Workbook和Sheet
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("食谱表");
+
+        // 创建样式
+        CellStyle headerStyle = createHeaderStyle(workbook);
+        CellStyle contentStyle = createContentStyle(workbook);
+
+        // 从数据库获取数据
+        BdglCookbook cookbookData = bdglCookbookService.selectBdglCookbookById(id);
+        List<BdglCookbookRegistration> cookbookRegistrations = cookbookData.getCookbookRegistrations();
+
+        // 构建数据映射
+        Map<String, Map<String, Map<String, String>>> dataMap = buildDataMap(cookbookRegistrations);
+
+        // 创建表头行
+        Row headerRow = sheet.createRow(0);
+        createHeaderCells(headerRow, headerStyle);
+
+        // 创建数据行 - 按餐别和食物类型组织
+        int rowIndex = 1;
+        String[] mealTypes = {"早餐", "午餐", "晚餐"};
+        String[] foodTypes = {"主食", "副食"};
+        String[] weekdays = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
+
+        for (String mealType : mealTypes) {
+            // 创建餐别行(合并行)
+            Row mealRow = sheet.createRow(rowIndex);
+            Cell mealCell = mealRow.createCell(0);
+            mealCell.setCellValue(mealType);
+            mealCell.setCellStyle(headerStyle);
+            sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex + 1, 0, 0));
+
+            for (int i = 0; i < foodTypes.length; i++) {
+                String foodType = foodTypes[i];
+                Row foodRow = (i == 0) ? mealRow : sheet.createRow(rowIndex + 1);
+
+                // 设置食物类型单元格
+                Cell foodCell = foodRow.createCell(1);
+                foodCell.setCellValue(foodType);
+                foodCell.setCellStyle(headerStyle);
+
+                // 填充每个星期的数据
+                for (int j = 0; j < weekdays.length; j++) {
+                    String weekday = weekdays[j];
+                    int colIndex = j + 2; // 从第3列开始是星期数据
+
+                    // 获取对应的数据
+                    String cookName = "";
+                    String foodName = "";
+
+                    if (dataMap.containsKey(weekday) && dataMap.get(weekday).containsKey(mealType)) {
+                        Map<String, String> mealData = dataMap.get(weekday).get(mealType);
+                        if ("主食".equals(foodType)) {
+                            cookName = mealData.getOrDefault("stapleCook", "");
+                            foodName = mealData.getOrDefault("stapleFood", "");
+                        } else {
+                            cookName = mealData.getOrDefault("nonStapleCook", "");
+                            foodName = mealData.getOrDefault("nonStapleFood", "");
+                        }
+                    }
+
+                    // 创建炊事员单元格
+                    Cell cookCell = foodRow.createCell(colIndex);
+                    cookCell.setCellValue("炊事员:" + (cookName == null? "" : cookName));
+                    cookCell.setCellStyle(contentStyle);
+
+                    // 创建食物单元格(在下方的行)
+                    Row foodValueRow = (i == 0) ? sheet.createRow(rowIndex + 1) : foodRow;
+                    Cell foodValueCell = foodValueRow.createCell(colIndex);
+                    foodValueCell.setCellValue(foodName);
+                    foodValueCell.setCellStyle(contentStyle);
+                }
+            }
+
+            rowIndex += 2; // 每个餐别占用2行
+        }
+
+        // 设置列宽
+        sheet.setColumnWidth(0, 15 * 256); // 时间列
+        sheet.setColumnWidth(1, 15 * 256); // 食物类型列
+        for (int i = 2; i <= 8; i++) { // 星期列
+            sheet.setColumnWidth(i, 25 * 256);
+        }
+
+        // 写入响应流
+        try (OutputStream outputStream = response.getOutputStream()) {
+            workbook.write(outputStream);
+            workbook.close();
+        }
+    }
+
+    // 创建表头样式
+    private CellStyle createHeaderStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        Font font = workbook.createFont();
+        font.setBold(true);
+        font.setFontHeightInPoints((short) 12);
+        style.setFont(font);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        return style;
+    }
+
+    // 创建内容样式
+    private CellStyle createContentStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        return style;
+    }
+
+    // 创建表头单元格
+    private void createHeaderCells(Row headerRow, CellStyle headerStyle) {
+        // 第一列
+        Cell cell0 = headerRow.createCell(0);
+        cell0.setCellValue("时间");
+        cell0.setCellStyle(headerStyle);
+
+        // 第二列
+        Cell cell1 = headerRow.createCell(1);
+        cell1.setCellValue("");
+        cell1.setCellStyle(headerStyle);
+
+        // 星期列
+        String[] weekdays = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
+        for (int i = 0; i < weekdays.length; i++) {
+            Cell cell = headerRow.createCell(i + 2);
+            cell.setCellValue(weekdays[i]);
+            cell.setCellStyle(headerStyle);
+        }
+    }
+
+    // 构建数据映射
+    private Map<String, Map<String, Map<String, String>>> buildDataMap(List<BdglCookbookRegistration> cookbookRegistrations) {
+        Map<String, Map<String, Map<String, String>>> dataMap = new HashMap<>();
+
+        for (BdglCookbookRegistration registration : cookbookRegistrations) {
+            String week = (String) registration.getWeeklist();
+            String time = (String) registration.getTimelist();
+            String type = (String) registration.getTypelist();
+            String foodNames = (String) registration.getCookcategoryNames();
+            String peopleNames = (String) registration.getPeopleNames();
+
+            // 初始化映射结构
+            dataMap.putIfAbsent(week, new HashMap<>());
+            dataMap.get(week).putIfAbsent(time, new HashMap<>());
+
+            // 存储食物和炊事员信息
+            if ("主食".equals(type)) {
+                dataMap.get(week).get(time).put("stapleFood", foodNames);
+                dataMap.get(week).get(time).put("stapleCook", peopleNames);
+            } else if ("副食".equals(type)) {
+                dataMap.get(week).get(time).put("nonStapleFood", foodNames);
+                dataMap.get(week).get(time).put("nonStapleCook", peopleNames);
+            }
+        }
+
+        return dataMap;
+    }
+
     /**
      * 获取一周食谱详细信息
      */

+ 10 - 10
supervision-admin/src/main/java/com/supervision/web/controller/grassrootsregistration/BdglWeekworkController.java

@@ -64,7 +64,7 @@ public class BdglWeekworkController extends BaseController
         List<SysRole> sysRoles = userMapper.selectRole(loginUser.getUserId());
         String role = CommonsController.getRole(sysRoles);
         //判断当前角色是否是最高权限   不是返回当前部门数据
-        if(role.equals("user_admin") || role.equals("special_registration")){
+        if(role.equals("admin") || role.equals("special_registration")){
             startPage();
             List<BdglWeekwork> list1 = bdglWeekworkService.selectBdglWeekworkList(bdglWeekwork);
             return getDataTable(list1);
@@ -155,15 +155,15 @@ public class BdglWeekworkController extends BaseController
     {
         BdglWeekwork bdglWeekwork1 = new BdglWeekwork();
         bdglWeekwork1.setUnitId(bdglWeekwork.getUnitId());
-        List<BdglWeekwork> bdglWeekworks = bdglWeekworkService.selectBdglWeekworkLists(bdglWeekwork1);
-        for (BdglWeekwork weekwork : bdglWeekworks) {
-            long time = bdglWeekwork.getStartTime().getTime();//开始时间
-            long time3 = weekwork.getEndTime().getTime();//当前任务结束时间
-            if(time<=time3){
-                return AjaxResult.success("该部门当前时段已有周工作安排");
-            }
-
-        }
+//        List<BdglWeekwork> bdglWeekworks = bdglWeekworkService.selectBdglWeekworkLists(bdglWeekwork1);
+//        for (BdglWeekwork weekwork : bdglWeekworks) {
+//            long time = bdglWeekwork.getStartTime().getTime();//开始时间
+//            long time3 = weekwork.getEndTime().getTime();//当前任务结束时间
+//            if(time<=time3){
+//                return AjaxResult.success("该部门当前时段已有周工作安排");
+//            }
+//
+//        }
         return toAjax(bdglWeekworkService.insertBdglWeekwork(bdglWeekwork));
     }
     /**

+ 1 - 1
supervision-admin/src/main/java/com/supervision/web/controller/grassrootsregistration/CommonsController.java

@@ -221,7 +221,7 @@ public class CommonsController extends BaseController {
         String role="";
         if(sysRoles!=null){
             for (SysRole sysRole : sysRoles) {
-                if("user_admin".equals(sysRole.getRoleKey())){
+                if("admin".equals(sysRole.getRoleKey())){
                     role=sysRole.getRoleKey();
                     break;
                 }

+ 1 - 1
supervision-admin/src/main/java/com/supervision/web/controller/peopleManage/BdglPeopleController.java

@@ -74,7 +74,7 @@ public class BdglPeopleController extends BaseController {
     @Log(title = "人员管理", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(BdglPeople bdglPeople) {
-        List<BdglPeople> list = bdglPeopleService.selectBdglPeopleList(bdglPeople);
+        List<BdglPeople> list = bdglPeopleService.selectPowerPeoleLists(bdglPeople);
         ExcelUtil<BdglPeople> util = new ExcelUtil<BdglPeople>(BdglPeople.class);
         return util.exportExcel(list, "人员管理数据");
     }

+ 6 - 0
supervision-system/pom.xml

@@ -24,6 +24,12 @@
             <artifactId>supervision-common</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.1.1</version>
+        </dependency>
+
         <!--hutool工具包-->
         <dependency>
             <groupId>cn.hutool</groupId>

+ 5 - 5
supervision-system/src/main/resources/mapper/grassrootsregistration/BdglDrillMapper.xml

@@ -24,7 +24,7 @@
         <result property="safety"    column="safety"    />
         <result property="chiefOfficial"    column="chief_official"    />
         <result property="targeted"    column="targeted"    />
-        <result property="system"    column="system"    />
+        <result property="system"    column="`system`"    />
         <result property="excellent"    column="excellent"    />
         <result property="pass"    column="pass"    />
         <result property="fail"    column="fail"    />
@@ -37,7 +37,7 @@
     </resultMap>
 
     <sql id="selectBdglDrillVo">
-        select id, project, drill_time, ought_to, remark, unit_id, filename, filepath, equipment, ammunition, mototime, drill_endtime, training_category, address, createtime, create_id, safety, chief_official, targeted, system, excellent, pass, fail, yingxun, shixun, participation_rate, assessment, unitname,training_content from bdgl_drill
+        select id, project, drill_time, ought_to, remark, unit_id, filename, filepath, equipment, ammunition, mototime, drill_endtime, training_category, address, createtime, create_id, safety, chief_official, targeted, `system`, excellent, pass, fail, yingxun, shixun, participation_rate, assessment, unitname,training_content from bdgl_drill
     </sql>
 
     <select id="selectBdglDrillList" parameterType="BdglDrill" resultMap="BdglDrillResult">
@@ -60,7 +60,7 @@
             <if test="safety != null  and safety != ''"> and safety = #{safety}</if>
             <if test="chiefOfficial != null  and chiefOfficial != ''"> and chief_official = #{chiefOfficial}</if>
             <if test="targeted != null  and targeted != ''"> and targeted = #{targeted}</if>
-            <if test="system != null  and system != ''"> and system = #{system}</if>
+            <if test="system != null  and system != ''"> and `system` = #{system}</if>
             <if test="excellent != null  and excellent != ''"> and excellent = #{excellent}</if>
             <if test="pass != null "> and pass = #{pass}</if>
             <if test="fail != null  and fail != ''"> and fail = #{fail}</if>
@@ -111,7 +111,7 @@
             <if test="safety != null">safety,</if>
             <if test="chiefOfficial != null">chief_official,</if>
             <if test="targeted != null">targeted,</if>
-            <if test="system != null">system,</if>
+            <if test="system != null">`system`,</if>
             <if test="excellent != null">excellent,</if>
             <if test="pass != null">pass,</if>
             <if test="fail != null">fail,</if>
@@ -175,7 +175,7 @@
             <if test="safety != null">safety = #{safety},</if>
             <if test="chiefOfficial != null">chief_official = #{chiefOfficial},</if>
             <if test="targeted != null">targeted = #{targeted},</if>
-            <if test="system != null">system = #{system},</if>
+            <if test="system != null">`system` = #{system},</if>
             <if test="excellent != null">excellent = #{excellent},</if>
             <if test="pass != null">pass = #{pass},</if>
             <if test="fail != null">fail = #{fail},</if>

+ 4 - 2
supervision-system/src/main/resources/mapper/peopleManage/BdglPeopleMapper.xml

@@ -137,7 +137,9 @@
             <if test="authorizedStrength != null  and authorizedStrength != ''"> and authorized_strength = #{authorizedStrength}</if>
             <if test="aboral != null  and aboral != ''"> and aboral = #{aboral}</if>
             <if test="live != null  and live != ''"> and live = #{live}</if>
-            <if test="deptId != null "> and dept_id = #{deptId}</if>
+            <if test="deptId != null "> and dept_id = #{deptId}
+
+            </if>
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="nowMilitaryRank != null  and nowMilitaryRank != ''"> and now_military_rank = #{nowMilitaryRank}</if>
             <if test="treatmentLevel != null  and treatmentLevel != ''"> and treatment_level = #{treatmentLevel}</if>
@@ -772,7 +774,7 @@
         GROUP BY party_id
     </select>
     <select id="countTypeNumber" resultMap="BdglPeopleResult">
-        select count(id) id,dept_name from bdgl_people  group by  dept_id
+        select count(id) id,dept_name from bdgl_people  group by  dept_id, dept_name
     </select>
     <select id="getDeptXiangQi2" resultType="java.util.Map">
         SELECT

+ 1 - 1
supervision-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -149,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		FROM
 			sys_dept
 		WHERE parent_id = #{parentId}
-		  AND orderby &lt;&gt; ""
+<!--		  AND orderby &lt;&gt; ""-->
 		  AND del_flag = 0
 		  AND STATUS = 0
 		ORDER BY