Browse Source

福利领取统计功能,导出优化

xianwait 2 years ago
parent
commit
56716e689e

+ 7 - 0
willalp-admin/src/main/java/com/willalp/web/controller/app/AppThreeController.java

@@ -370,6 +370,13 @@ public class AppThreeController extends BaseController {
         if (null == welfareApplyRecord) {
             return AjaxResult.error();
         }
+        if (StringUtils.isBlank(welfareApplyRecord.getId())) {
+            return AjaxResult.error();
+        }
+        HsWelfareApplyRecord applyRecord = welfareApplyRecordService.getById(welfareApplyRecord.getId());
+        if ("3".equals(applyRecord.getNowStatus())) {
+            return AjaxResult.error("不可重复报名");
+        }
         welfareApplyRecord.setNowStatus("3");
         return toAjax(welfareApplyRecordService.updateById(welfareApplyRecord));
     }

+ 17 - 3
willalp-admin/src/main/java/com/willalp/web/controller/clockingin/HsWelfareApplyRecordController.java

@@ -47,13 +47,28 @@ public class HsWelfareApplyRecordController extends BaseController {
      * 查询福利报名记录列表
      */
     @GetMapping("/sourceList")
-    public TableDataInfo sourceList(HsWelfareApplyRecord hsWelfareApplyRecord) {
+    public TableDataInfo sourceList() {
         startPage();
         List<HsWelfareApplyRecord> source = hsWelfareApplyRecordService.list(new QueryWrapper<HsWelfareApplyRecord>()
                 .groupBy("source"));
         return getDataTable(source);
     }
 
+    /**
+     * 查询福利报名记录列表
+     */
+    @GetMapping("/stat")
+    public AjaxResult stat(String source) {
+        return AjaxResult.success(hsWelfareApplyRecordService.stat(source));
+    }
+
+    /**
+     * 查询福利报名记录列表
+     */
+    @GetMapping("/doUnregistered")
+    public AjaxResult doUnregistered(String source) {
+        return toAjax(hsWelfareApplyRecordService.doUnregistered(source));
+    }
 
     /**
      * 导出福利报名记录列表
@@ -62,12 +77,11 @@ public class HsWelfareApplyRecordController extends BaseController {
     @Log(title = "福利报名记录", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(HsWelfareApplyRecord hsWelfareApplyRecord) {
-        List<HsWelfareApplyRecord> list = hsWelfareApplyRecordService.selectHsWelfareApplyRecordList(hsWelfareApplyRecord);
+        List<HsWelfareApplyRecord> list = hsWelfareApplyRecordService.exportDataAndInterpret(hsWelfareApplyRecord);
         ExcelUtil<HsWelfareApplyRecord> util = new ExcelUtil<>(HsWelfareApplyRecord.class);
         return util.exportExcel(list, "福利报名记录数据");
     }
 
-
     @GetMapping("/importTemp")
     public AjaxResult importTemp() {
         ExcelUtil<HsWelfareApplyRecord> util = new ExcelUtil<>(HsWelfareApplyRecord.class);

+ 2 - 2
willalp-clocking-in/src/main/java/com/willalp/event/domain/HsWelfareApplyRecord.java

@@ -30,14 +30,14 @@ public class HsWelfareApplyRecord extends BaseEntity
 
     /** 用户编号 */
     @Excel(name = "用户编号")
-    private String userCode;
+        private String userCode;
 
     /** 用户名称 */
     @Excel(name = "用户名称")
     private String userName;
 
     /** 地点 */
-    @Excel(name = "地点")
+    @Excel(name = "地点",width = 60)
     private String address;
 
     /** 当前状态 */

+ 30 - 0
willalp-clocking-in/src/main/java/com/willalp/event/domain/vo/WelfareApplyStatVo.java

@@ -0,0 +1,30 @@
+/**
+ * @projectName willalp-pns-ml
+ * @package com.willalp.event.domain.vo
+ * @className com.willalp.event.domain.vo.WelfareApplyStatVo
+ * @copyright Copyright 2019 HuiShan, Inc All rights reserved.
+ */
+package com.willalp.event.domain.vo;
+
+import com.willalp.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * WelfareApplyStatVo
+ * @description 福利领取报名统计Excel封装伪类
+ * @author hs
+ * @date 2023/4/18 15:03
+ * @version 1.0
+ */
+@Data
+public class WelfareApplyStatVo {
+    @Excel(name = "地点")
+    private String address;
+
+    @Excel(name = "报名数量")
+    private String applyNum;
+
+    @Excel(name = "未报名数量")
+    private String unregistered;
+}
+ 

+ 18 - 0
willalp-clocking-in/src/main/java/com/willalp/event/mapper/HsWelfareApplyRecordMapper.java

@@ -2,6 +2,8 @@ package com.willalp.event.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.willalp.event.domain.HsWelfareApplyRecord;
+import com.willalp.event.domain.vo.WelfareApplyStatVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -20,4 +22,20 @@ public interface HsWelfareApplyRecordMapper extends BaseMapper<HsWelfareApplyRec
      * @return 福利报名记录集合
      */
     List<HsWelfareApplyRecord> selectHsWelfareApplyRecordList(HsWelfareApplyRecord hsWelfareApplyRecord);
+
+    /**
+     * 统计活动报名数量
+     *
+     * @param source
+     * @return
+     */
+    List<WelfareApplyStatVo> stat(@Param("source") String source);
+
+    /**
+     * 发布操作修改为未报名
+     *
+     * @param source
+     * @return
+     */
+    int doUnregistered(@Param("source") String source);
 }

+ 17 - 0
willalp-clocking-in/src/main/java/com/willalp/event/mapper/xml/HsWelfareApplyRecordMapper.xml

@@ -34,6 +34,11 @@
                remark
         from hs_welfare_apply_record
     </sql>
+    <update id="doUnregistered">
+        update hs_welfare_apply_record
+        set now_status = '3'
+        WHERE source = #{source}
+    </update>
 
     <select id="selectHsWelfareApplyRecordList" parameterType="HsWelfareApplyRecord"
             resultMap="HsWelfareApplyRecordResult">
@@ -60,4 +65,16 @@
             </if>
         </where>
     </select>
+    <select id="stat" resultType="com.willalp.event.domain.vo.WelfareApplyStatVo">
+        SELECT sdd.dict_label        address,
+               sum(now_status = '2') applyNum
+        FROM `hs_welfare_apply_record` hwar
+                 LEFT JOIN sys_dict_data sdd ON sdd.dict_value = hwar.address
+            AND dict_type = 'welfare_apply_addr'
+        WHERE hwar.is_delete = 0
+          AND hwar.now_status = '2'
+          AND hwar.source = #{source}
+        GROUP BY address
+    </select>
+
 </mapper>

+ 38 - 3
willalp-clocking-in/src/main/java/com/willalp/event/service/IHsWelfareApplyRecordService.java

@@ -2,6 +2,7 @@ package com.willalp.event.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.willalp.event.domain.HsWelfareApplyRecord;
+import com.willalp.event.domain.vo.WelfareApplyStatVo;
 
 import java.util.List;
 
@@ -11,8 +12,7 @@ import java.util.List;
  * @author willalp
  * @date 2023-04-17
  */
-public interface IHsWelfareApplyRecordService extends IService<HsWelfareApplyRecord>
-{
+public interface IHsWelfareApplyRecordService extends IService<HsWelfareApplyRecord> {
     /**
      * 查询福利报名记录列表
      *
@@ -21,5 +21,40 @@ public interface IHsWelfareApplyRecordService extends IService<HsWelfareApplyRec
      */
     List<HsWelfareApplyRecord> selectHsWelfareApplyRecordList(HsWelfareApplyRecord hsWelfareApplyRecord);
 
-    String importData(List<HsWelfareApplyRecord> list,String fileName);
+
+    /**
+     * 导出数据并翻译
+     *
+     * @param hsWelfareApplyRecord
+     * @return
+     */
+    List<HsWelfareApplyRecord> exportDataAndInterpret(HsWelfareApplyRecord hsWelfareApplyRecord);
+
+
+    /**
+     * 数据导入
+     *
+     * @param list
+     * @param fileName
+     * @return
+     */
+    String importData(List<HsWelfareApplyRecord> list, String fileName);
+
+
+    /**
+     * 统计活动报名数量
+     *
+     * @param source
+     * @return
+     */
+    List<WelfareApplyStatVo> stat(String source);
+
+    /**
+     * 发布操作修改为未报名
+     *
+     * @param source
+     * @return
+     */
+    int doUnregistered(String source);
+
 }

+ 45 - 12
willalp-clocking-in/src/main/java/com/willalp/event/service/impl/HsWelfareApplyRecordServiceImpl.java

@@ -3,12 +3,15 @@ package com.willalp.event.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.willalp.common.core.domain.ReturnEntity;
+import com.willalp.common.core.domain.entity.SysDictData;
 import com.willalp.common.exception.base.BaseException;
 import com.willalp.common.utils.ObjectToTypes;
 import com.willalp.common.utils.StringUtils;
 import com.willalp.event.domain.HsWelfareApplyRecord;
+import com.willalp.event.domain.vo.WelfareApplyStatVo;
 import com.willalp.event.mapper.HsWelfareApplyRecordMapper;
 import com.willalp.event.service.IHsWelfareApplyRecordService;
+import com.willalp.system.service.ISysDictTypeService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -26,6 +29,9 @@ public class HsWelfareApplyRecordServiceImpl extends ServiceImpl<HsWelfareApplyR
     @Resource
     private HsWelfareApplyRecordMapper hsWelfareApplyRecordMapper;
 
+    @Resource
+    private ISysDictTypeService dictTypeService;
+
     /**
      * 查询福利报名记录列表
      *
@@ -37,34 +43,46 @@ public class HsWelfareApplyRecordServiceImpl extends ServiceImpl<HsWelfareApplyR
         return hsWelfareApplyRecordMapper.selectHsWelfareApplyRecordList(hsWelfareApplyRecord);
     }
 
+    @Override
+    public List<HsWelfareApplyRecord> exportDataAndInterpret(HsWelfareApplyRecord hsWelfareApplyRecord) {
+        List<HsWelfareApplyRecord> list = hsWelfareApplyRecordMapper.selectHsWelfareApplyRecordList(hsWelfareApplyRecord);
+        List<SysDictData> applyAddr = dictTypeService.selectDictDataByType("welfare_apply_addr");
+        List<SysDictData> applyStatus = dictTypeService.selectDictDataByType("welfare_apply_status");
+        list.forEach(item -> {
+            applyAddr.forEach(dict -> {
+                if (StringUtils.isNotBlank(item.getAddress()) && item.getAddress().equals(dict.getDictValue())) {
+                    item.setAddress(dict.getDictLabel());
+                }
+            });
+            applyStatus.forEach(dict -> {
+                if (StringUtils.isNotBlank(item.getNowStatus()) && item.getNowStatus().equals(dict.getDictValue())) {
+                    item.setNowStatus(dict.getDictLabel());
+                }
+            });
+        });
+        return list;
+    }
+
     @Override
     public String importData(List<HsWelfareApplyRecord> list, String fileName) {
         if (StringUtils.isBlank(fileName)) {
             if (count(new QueryWrapper<HsWelfareApplyRecord>().eq("source", fileName)) > 0) {
-                throw new BaseException("该Excel已经存在");
+                throw new BaseException("该Excel数据已经存在,请检查或重命名");
             }
         }
         int successNum = 0;
         int failureNum = 0;
-        List<HsWelfareApplyRecord> toSaveList = new ArrayList<>();
         for (HsWelfareApplyRecord welfareApplyRecord : list) {
             try {
-                if (StringUtils.isBlank(welfareApplyRecord.getUserCode())) {
-                    throw new Exception();
-                }
-                if (StringUtils.isBlank(welfareApplyRecord.getUserName())) {
-                    throw new Exception();
-                }
                 welfareApplyRecord.setSource(fileName);
-                toSaveList.add(welfareApplyRecord);
+                welfareApplyRecord.setNowStatus("1");
+                save(welfareApplyRecord);
+                successNum++;
             } catch (Exception e) {
                 failureNum++;
                 log.error(e.getMessage(), e);
             }
         }
-        if (saveBatch(toSaveList)) {
-            successNum = toSaveList.size();
-        }
         ReturnEntity<String> res = new ReturnEntity<>();
         res.setReturnMessage("event.club.successCode", new String[]{
                 ObjectToTypes.parseString(successNum), ObjectToTypes.parseString(failureNum)
@@ -72,5 +90,20 @@ public class HsWelfareApplyRecordServiceImpl extends ServiceImpl<HsWelfareApplyR
         return res.getMessage();
     }
 
+    @Override
+    public List<WelfareApplyStatVo> stat(String source) {
+        if (StringUtils.isBlank(source)) {
+            return new ArrayList<>();
+        }
+        return baseMapper.stat(source);
+    }
+
+    @Override
+    public int doUnregistered(String source) {
+        if (StringUtils.isBlank(source)) {
+            return 0;
+        }
+        return baseMapper.doUnregistered(source);
+    }
 
 }

+ 15 - 0
willalp-ui/src/api/event/applyRecord.js

@@ -17,6 +17,13 @@ export function sourceListApplyRecord(query) {
   })
 }
 
+export function statApplyRecord(id) {
+  return request({
+    url: '/event/applyRecord/stat?source=' + id,
+    method: 'get'
+  })
+}
+
 // 查询福利报名记录详细
 export function getApplyRecord(id) {
   return request({
@@ -25,6 +32,14 @@ export function getApplyRecord(id) {
   })
 }
 
+// 查询福利报名记录详细
+export function doUnregistered(source) {
+  return request({
+    url: '/event/applyRecord/doUnregistered?source=' + source,
+    method: 'get'
+  })
+}
+
 // 新增福利报名记录
 export function addApplyRecord(data) {
   return request({

+ 88 - 21
willalp-ui/src/views/event/applyRecord/index.vue

@@ -1,15 +1,15 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
-      <el-form-item label="Excel来源" prop="source">
-        <el-input
-          v-model="queryParams.source"
-          placeholder="请输入Excel来源"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
+      <!--      <el-form-item label="Excel来源" prop="source">-->
+      <!--        <el-input-->
+      <!--          v-model="queryParams.source"-->
+      <!--          placeholder="请输入Excel来源"-->
+      <!--          clearable-->
+      <!--          size="small"-->
+      <!--          @keyup.enter.native="handleQuery"-->
+      <!--        />-->
+      <!--      </el-form-item>-->
       <el-form-item label="用户编号" prop="userCode">
         <el-input
           v-model="queryParams.userCode"
@@ -115,14 +115,33 @@
     </el-row>
 
     <el-row :gutter="6">
-      <el-col :span="8">
+      <el-col :span="7">
         <el-card class="box-card">
           <div slot="header" class="clearfix">
             <span>福利领取目录</span>
           </div>
           <div class="item">
-            <el-table v-loading="loading" :data="sourceList" @selection-change="handleSelectionChange" rowClick>
-              <el-table-column label="Excel来源" align="center" prop="source"/>
+            <el-table v-loading="loading" :data="sourceList" @selection-change="handleSelectionChange"
+                      @row-click="rowClick">
+              <el-table-column label="文件名" align="center" prop="source"/>
+              <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="130">
+                <template slot-scope="scope">
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-pie-chart"
+                    @click="openStat(scope.row.source)"
+                  >统计
+                  </el-button>
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-magic-stick"
+                    @click="sourceDoUnregistered(scope.row.source)"
+                  >发布
+                  </el-button>
+                </template>
+              </el-table-column>
             </el-table>
             <pagination
               v-show="total>0"
@@ -134,17 +153,17 @@
           </div>
         </el-card>
       </el-col>
-      <el-col :span="16">
+      <el-col :span="17">
         <el-card class="box-card">
           <div slot="header" class="clearfix">
-            <span>报名信息</span>
+            <span>{{ sourceName }}</span>
           </div>
           <div class="item">
             <el-table v-loading="loading" :data="applyRecordList" @selection-change="handleSelectionChange">
               <el-table-column type="selection" width="55" align="center"/>
               <el-table-column label="用户编号" align="center" prop="userCode"/>
               <el-table-column label="用户名称" align="center" prop="userName"/>
-              <el-table-column label="地点" align="center" prop="address">
+              <el-table-column label="地点" align="center" prop="address" width="380">
                 <template slot-scope="scope">
                   <dict-tag :options="dict.type.welfare_apply_addr" :value="scope.row.address"/>
                 </template>
@@ -200,7 +219,14 @@
           <el-input v-model="form.userName" placeholder="请输入用户名称"/>
         </el-form-item>
         <el-form-item label="地点" prop="address">
-          <el-input v-model="form.address" placeholder="请输入地点"/>
+          <el-select v-model="form.address" placeholder="请选择地点">
+            <el-option
+              v-for="dict in dict.type.welfare_apply_addr"
+              :key="dict.value"
+              :label="dict.label"
+              :value="dict.value"
+            ></el-option>
+          </el-select>
         </el-form-item>
         <el-form-item label="当前状态" prop="nowStatus">
           <el-select v-model="form.nowStatus" placeholder="请选择当前状态">
@@ -249,6 +275,12 @@
         <el-button @click="cancelTemplate">取 消</el-button>
       </div>
     </el-dialog>
+    <el-dialog :title="stat.title" :visible.sync="stat.open" width="900px">
+      <el-table v-loading="stat.loading" :data="statList" :show-summary="true">
+        <el-table-column label="部门" align="center" prop="address"/>
+        <el-table-column label="报名数量" align="center" prop="applyNum"/>
+      </el-table>
+    </el-dialog>
   </div>
 </template>
 
@@ -256,6 +288,8 @@
 import {
   listApplyRecord,
   sourceListApplyRecord,
+  statApplyRecord,
+  doUnregistered,
   getApplyRecord,
   delApplyRecord,
   addApplyRecord,
@@ -264,7 +298,7 @@ import {
   importTempApplyRecord
 } from '@/api/event/applyRecord'
 import { getToken } from '@/utils/auth'
-import { listSalaryslip } from '@/api/salary/salaryslip'
+import { exportDetail } from '@/api/canteen/giftDetail'
 
 export default {
   name: 'ApplyRecord',
@@ -288,6 +322,7 @@ export default {
       // 福利报名记录表格数据
       applyRecordList: [],
       sourceList: [],
+      statList: [],
       // 弹出层标题
       title: '',
       // 是否显示弹出层
@@ -312,6 +347,7 @@ export default {
       form: {},
       // 表单校验
       rules: {},
+      sourceName: '',
       upload: {
         // 是否显示弹出层(用户导入)
         open: false,
@@ -324,6 +360,11 @@ export default {
         headers: { Authorization: 'Bearer ' + getToken() },
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + '/event/applyRecord/importData'
+      },
+      stat: {
+        open: false,
+        title: '统计',
+        loading: false
       }
     }
   },
@@ -331,11 +372,12 @@ export default {
     this.getList()
   },
   methods: {
-    rowClick(row, column, event) {
+    rowClick(row) {
+      this.loading = true
       this.queryParams.source = row.source
-      this.excelInfo.source = row.source
-      listSalaryslip(this.queryParams).then(response => {
-        this.salaryslipList = response.rows
+      this.sourceName = row.source
+      listApplyRecord(this.queryParams).then(response => {
+        this.applyRecordList = response.rows
         this.total = response.total
         this.loading = false
       })
@@ -353,6 +395,31 @@ export default {
         this.sourceQueryParams.total = response.total
       })
     },
+    openStat(source) {
+      this.stat.open = true
+      this.stat.loading = true
+      this.stat.title = '统计【' + source + '】'
+      statApplyRecord(source).then(response => {
+        if (response.code === 200) {
+          this.statList = response.data
+          this.stat.loading = false
+        }
+      })
+    },
+    sourceDoUnregistered(source) {
+      this.$modal.confirm('发布成功后所有人员都设置为【未报名】状态,确认发布吗?').then(() => {
+        return doUnregistered(source)
+      }).then(response => {
+        if (response.code === 200) {
+          this.$modal.msgSuccess('发布成功')
+          this.getList()
+        } else {
+          this.$modal.msgError('发布失败')
+        }
+      }).catch(() => {
+
+      })
+    },
     // 取消按钮
     cancel() {
       this.open = false

+ 14 - 12
willalp-ui/src/views/salary/salaryslip/index.vue

@@ -270,13 +270,15 @@
 <script>
 import {
   listSalaryslip,
-  getSalaryslip,
-  delSalaryslip,
-  addSalaryslip,
-  updateSalaryslip,
-  exportSalaryslip, importTempSalaryslip, getSalaryslips, push, excelList
-} from '@/api/salary/salaryslip'
-import {getToken} from '@/utils/auth'
+    getSalaryslip,
+    delSalaryslip,
+    addSalaryslip,
+    updateSalaryslip,
+    exportSalaryslip, importTempSalaryslip, getSalaryslips, push, excelList
+}
+from
+'@/api/salary/salaryslip'
+import { getToken } from '@/utils/auth'
 
 export default {
   name: 'Salaryslip',
@@ -326,7 +328,7 @@ export default {
         isUploading: false,
         // 是否更新已经存在的用户数据
         // 设置上传的请求头部
-        headers: {Authorization: 'Bearer ' + getToken()},
+        headers: { Authorization: 'Bearer ' + getToken() },
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + '/salary/salaryslip/importData'
       },
@@ -476,7 +478,7 @@ export default {
     /** 删除按钮操作 */
     handleDelete(row) {
       const ids = row.id || this.ids
-      this.$modal.confirm('是否确认删除工资条基础编号为"' + ids + '"的数据项?').then(function () {
+      this.$modal.confirm('是否确认删除工资条基础编号为"' + ids + '"的数据项?').then(function() {
         return delSalaryslip(ids)
       }).then(() => {
         this.getList()
@@ -496,7 +498,7 @@ export default {
           return
         }
       }
-      this.$modal.confirm('是否确认发布工资条').then(function () {
+      this.$modal.confirm('是否确认发布工资条').then(function() {
         return push(ids)
       }).then(() => {
         this.getList()
@@ -507,7 +509,7 @@ export default {
     /** 一键发布*/
     publishWithOneClick() {
       const ids = this.ids
-      this.$modal.confirm('是否确认一键发布所有工资条').then(function () {
+      this.$modal.confirm('是否确认一键发布所有工资条').then(function() {
         return push(ids)
       }).then(() => {
         this.getList()
@@ -539,7 +541,7 @@ export default {
       this.upload.open = false
       this.upload.isUploading = false
       this.$refs.upload.clearFiles()
-      this.$alert(response.msg, '导入结果', {dangerouslyUseHTMLString: true})
+      this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
       this.cancel()
       this.getList()
     },