Browse Source

支部年度工作计划导出

Wang Zi Wen 1 year ago
parent
commit
c6b3c2e450

+ 58 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/branch/TBranchPlanController.java

@@ -1,10 +1,19 @@
 package com.ruoyi.web.controller.branch;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.branch.domain.TBranchPlanItem;
 import com.ruoyi.branch.service.ITBranchPlanItemService;
+import com.ruoyi.common.core.domain.entity.SysDictData;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysDictTypeService;
+import com.ruoyi.system.service.ISysUserService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -40,14 +49,19 @@ public class TBranchPlanController extends BaseController
     @Autowired
     private ITBranchPlanItemService tBranchPlanItemService;
 
+    @Autowired
+    private ISysDictTypeService sysDictTypeService;
+
+    @Autowired
+    private ISysUserService userService;
+
     /**
      * 查询支部年度工作计划列表
      */
     @PreAuthorize("@ss.hasPermi('branch:plan:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TBranchPlan tBranchPlan)
+    public AjaxResult list(TBranchPlan tBranchPlan)
     {
-        startPage();
         List<TBranchPlan> list = tBranchPlanService.selectTBranchPlanList(tBranchPlan);
         // 查询工作计划条目
         for (TBranchPlan branchPlan : list) {
@@ -58,7 +72,7 @@ public class TBranchPlanController extends BaseController
             List<TBranchPlanItem> tBranchPlanItems = tBranchPlanItemService.selectTBranchPlanItemList(tBranchPlanItem);
             branchPlan.setItemList(tBranchPlanItems);
         }
-        return getDataTable(list);
+        return AjaxResult.success(list);
     }
 
     /**
@@ -69,9 +83,48 @@ public class TBranchPlanController extends BaseController
     @PostMapping("/export")
     public void export(HttpServletResponse response, TBranchPlan tBranchPlan)
     {
+        List<TBranchPlanItem> itemList = new ArrayList<TBranchPlanItem>();
         List<TBranchPlan> list = tBranchPlanService.selectTBranchPlanList(tBranchPlan);
-        ExcelUtil<TBranchPlan> util = new ExcelUtil<TBranchPlan>(TBranchPlan.class);
-        util.exportExcel(response, list, "支部年度工作计划数据");
+        // 查询工作计划条目
+        for (TBranchPlan branchPlan : list) {
+            TBranchPlanItem tBranchPlanItem = new TBranchPlanItem();
+            tBranchPlanItem.setPlanId(branchPlan.getPlanId());
+            tBranchPlanItem.setItemStatus(tBranchPlan.getItemStatus());
+            tBranchPlanItem.setPersonInCharge(tBranchPlan.getPersonInCharge());
+            List<TBranchPlanItem> tBranchPlanItems = tBranchPlanItemService.selectTBranchPlanItemList(tBranchPlanItem);
+            itemList.addAll(tBranchPlanItems);
+        }
+        List<SysDictData> PlanItemStatus = sysDictTypeService.selectDictDataByType("plan_item_status");
+        List<SysUser> sysUsers = userService.selectUserList(new SysUser());
+        Map<Long, String> userMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName));
+        List<TBranchPlan> branchPlans = tBranchPlanService.selectTBranchPlanList(new TBranchPlan());
+        Map<Long, String> planMap = branchPlans.stream().collect(Collectors.toMap(TBranchPlan::getPlanId, TBranchPlan::getPlanTitle));
+        for (TBranchPlanItem tBranchPlanItem : itemList) {
+            for (SysDictData data : PlanItemStatus) {
+                if (data.getDictValue().equals(tBranchPlanItem.getItemStatus())) {
+                    tBranchPlanItem.setItemStatus(data.getDictLabel());
+                }
+            }
+
+            String personInCharge = "";
+            String[] split = tBranchPlanItem.getPersonInCharge().split(",");
+            for (String s : split) {
+                for (Long key : userMap.keySet()) {
+                    if (key.toString().equals(s)) {
+                        personInCharge += userMap.get(key) + "、";
+                    }
+                }
+            }
+            tBranchPlanItem.setPersonInCharge(personInCharge.substring(0, personInCharge.length() - 1));
+
+            for (Long key : planMap.keySet()) {
+                if (key.toString().equals(tBranchPlanItem.getPlanId().toString())) {
+                    tBranchPlanItem.setTitle(planMap.get(key));
+                }
+            }
+        }
+        ExcelUtil<TBranchPlanItem> util = new ExcelUtil<TBranchPlanItem>(TBranchPlanItem.class);
+        util.exportExcel(response, itemList, "支部年度工作计划数据");
     }
 
     /**

+ 12 - 3
ruoyi-system/src/main/java/com/ruoyi/branch/domain/TBranchPlanItem.java

@@ -18,16 +18,18 @@ public class TBranchPlanItem extends BaseEntity
     private static final long serialVersionUID = 1L;
 
     /** 主键id */
-    @Excel(name = "主键id")
     private Long itemId;
 
     /** 年份 */
     private String planYear;
 
     /** 工作计划id */
-    @Excel(name = "工作计划id")
     private Long planId;
 
+    /** 工作计划标题 */
+    @Excel(name = "标题")
+    private String title;
+
     /** 内容 */
     @Excel(name = "内容")
     private String itemContent;
@@ -54,9 +56,16 @@ public class TBranchPlanItem extends BaseEntity
     private String delFlag;
 
     /** 部门id */
-    @Excel(name = "部门id")
     private Long deptId;
 
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
     public String getPlanYear() {
         return planYear;
     }

+ 24 - 21
ruoyi-ui/src/views/branch/zbjs/plan/index.vue

@@ -52,11 +52,21 @@
           @click="handleAddPlan"
           v-hasPermi="['branch:plan:add']"
         >新增标题</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['branch:plan:export']"
+        >导出</el-button>
       </el-col>
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table :cell-style="tableCellStyle" v-loading="loading" :data="planList" @selection-change="handleSelectionChange" :height="clientHeight" border :span-method="objectSpanMethod">
+    <el-table :cell-style="tableCellStyle" v-loading="loading" :data="planList" @selection-change="handleSelectionChange" border :span-method="objectSpanMethod">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="标题" align="center" prop="planTitle" width="200" />
       <el-table-column label="内容" align="center" prop="itemContent"/>
@@ -65,13 +75,13 @@
           <span>{{ parseTime(scope.row.planTime, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="当前状态" align="center" prop="itemStatus" :formatter="itemStatusFormat" />
+      <el-table-column label="当前状态" align="center" prop="itemStatus" :formatter="itemStatusFormat" width="120" />
       <el-table-column label="实际完成日期" align="center" prop="actualTime" width="100">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.actualTime, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="负责人" align="center" prop="personInChargeString" />
+      <el-table-column label="负责人" align="center" prop="personInChargeString" width="120" />
       <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -119,13 +129,13 @@
       </el-table-column>
     </el-table>
 
-    <pagination
-      v-show="total>0"
-      :total="total"
-      :page.sync="queryParams.pageNum"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
+    <!--<pagination-->
+      <!--v-show="total>0"-->
+      <!--:total="total"-->
+      <!--:page.sync="queryParams.pageNum"-->
+      <!--:limit.sync="queryParams.pageSize"-->
+      <!--@pagination="getList"-->
+    <!--/>-->
 
     <!-- 添加或修改支部年度工作计划条目对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -440,7 +450,7 @@ export default {
           "deptId": this.queryParams.deptId
         });
       }).then(response => {
-        let rows = response.rows;
+        let rows = response.data;
         let planList = [];
         for (let i = 0; i < rows.length; i ++) {
           let itemList = rows[i].itemList;
@@ -651,16 +661,9 @@ export default {
     },
     /** 导出按钮操作 */
     handleExport() {
-      const queryParams = this.queryParams;
-      this.$confirm('是否确认导出所有支部年度工作计划数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return exportPlanitem(queryParams);
-        }).then(response => {
-          this.download(response.msg);
-        })
+      this.download('branch/plan/export', {
+        ...this.queryParams
+      }, `年度工作计划_${new Date().getTime()}.xlsx`)
     },
       /** 导入按钮操作 */
       handleImport() {