From a2e5aea180e13b868edd3eac3318042f87c10141 Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Wed, 21 Feb 2024 14:26:14 +0800
Subject: [PATCH] 考核权重配置
---
src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigExcel.java | 91 ++++++
src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.xml | 40 ++
src/main/java/org/springblade/modules/assessment/vo/AssessmentConfigVO.java | 34 ++
src/main/java/org/springblade/modules/assessment/dto/AssessmentConfigDTO.java | 34 ++
src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigImporter.java | 25 +
src/main/java/org/springblade/modules/assessment/service/IAssessmentConfigService.java | 62 ++++
src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.java | 54 +++
src/main/java/org/springblade/modules/assessment/service/impl/AssessmentConfigServiceImpl.java | 114 ++++++++
src/main/java/org/springblade/modules/assessment/wrapper/AssessmentConfigWrapper.java | 50 +++
src/main/java/org/springblade/modules/assessment/controller/AssessmentConfigController.java | 182 +++++++++++++
src/main/java/org/springblade/modules/assessment/entity/AssessmentConfigEntity.java | 100 +++++++
src/main/java/org/springblade/modules/assessment/utils/AssExcelUtil.java | 34 ++
12 files changed, 820 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/assessment/controller/AssessmentConfigController.java b/src/main/java/org/springblade/modules/assessment/controller/AssessmentConfigController.java
new file mode 100644
index 0000000..9f74949
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/controller/AssessmentConfigController.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.excel.util.ExcelUtil;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.annotation.PreAuth;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.constant.BladeConstant;
+import org.springblade.core.tool.constant.RoleConstant;
+import org.springblade.core.tool.utils.DateUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+import org.springblade.modules.assessment.excel.AssessmentConfigExcel;
+import org.springblade.modules.assessment.excel.AssessmentConfigImporter;
+import org.springblade.modules.assessment.service.IAssessmentConfigService;
+import org.springblade.modules.assessment.utils.AssExcelUtil;
+import org.springblade.modules.assessment.vo.AssessmentConfigVO;
+import org.springblade.modules.assessment.wrapper.AssessmentConfigWrapper;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 考核权重配置表 控制器
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("assessment/assessmentConfig")
+@Api(value = "考核权重配置表", tags = "考核权重配置表接口")
+public class AssessmentConfigController extends BladeController {
+
+ private final IAssessmentConfigService assessmentConfigService;
+
+ /**
+ * 考核权重配置表 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "详情", notes = "传入assessmentConfig")
+ public R<AssessmentConfigVO> detail(AssessmentConfigEntity assessmentConfig) {
+ AssessmentConfigEntity detail = assessmentConfigService.getOne(Condition.getQueryWrapper(assessmentConfig));
+ return R.data(AssessmentConfigWrapper.build().entityVO(detail));
+ }
+ /**
+ * 考核权重配置表 分页
+ */
+ @GetMapping("/list")
+ @ApiOperationSupport(order = 2)
+ @ApiOperation(value = "分页", notes = "传入assessmentConfig")
+ public R<IPage<AssessmentConfigVO>> list(@ApiIgnore @RequestParam Map<String, Object> assessmentConfig, Query query) {
+ IPage<AssessmentConfigEntity> pages = assessmentConfigService.page(Condition.getPage(query), Condition.getQueryWrapper(assessmentConfig, AssessmentConfigEntity.class));
+ return R.data(AssessmentConfigWrapper.build().pageVO(pages));
+ }
+
+ /**
+ * 考核权重配置表 自定义分页
+ */
+ @GetMapping("/page")
+ @ApiOperationSupport(order = 3)
+ @ApiOperation(value = "分页", notes = "传入assessmentConfig")
+ public R<IPage<AssessmentConfigVO>> page(AssessmentConfigVO assessmentConfig, Query query) {
+ IPage<AssessmentConfigVO> pages = assessmentConfigService.selectAssessmentConfigPage(Condition.getPage(query), assessmentConfig);
+ return R.data(pages);
+ }
+
+ /**
+ * 根据被考核人id获取考核人列表
+ * @param userId
+ * @return
+ */
+ @GetMapping("/list/{userId}")
+ public R listByUserId(@PathVariable("userId") Long userId) {
+ QueryWrapper queryWrapper = new QueryWrapper();
+ queryWrapper.eq("user_id", userId);
+ return R.data(assessmentConfigService.list(queryWrapper));
+ }
+
+ /**
+ * 考核权重配置表 新增
+ */
+ @PostMapping("/save")
+ @ApiOperationSupport(order = 4)
+ @ApiOperation(value = "新增", notes = "传入assessmentConfig")
+ public R save(@Valid @RequestBody AssessmentConfigEntity assessmentConfig) {
+ return R.status(assessmentConfigService.save(assessmentConfig));
+ }
+
+ /**
+ * 考核权重配置表 修改
+ */
+ @PostMapping("/update")
+ @ApiOperationSupport(order = 5)
+ @ApiOperation(value = "修改", notes = "传入assessmentConfig")
+ public R update(@Valid @RequestBody AssessmentConfigEntity assessmentConfig) {
+ return R.status(assessmentConfigService.updateById(assessmentConfig));
+ }
+
+ /**
+ * 考核权重配置表 新增或修改
+ */
+ @PostMapping("/submit")
+ @ApiOperationSupport(order = 6)
+ @ApiOperation(value = "新增或修改", notes = "传入assessmentConfig")
+ public R submit(@Valid @RequestBody AssessmentConfigEntity assessmentConfig) {
+ return R.status(assessmentConfigService.saveOrUpdate(assessmentConfig));
+ }
+
+ /**
+ * 考核权重配置表 删除
+ */
+ @PostMapping("/remove")
+ @ApiOperationSupport(order = 7)
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+ return R.status(assessmentConfigService.deleteLogic(Func.toLongList(ids)));
+ }
+
+ /**
+ * 导入用户
+ */
+ @PostMapping("import-assessmentConfig")
+ @ApiOperationSupport(order = 12)
+ @ApiOperation(value = "导入用户", notes = "传入excel")
+ @PreAuth(RoleConstant.HAS_ROLE_ADMIN)
+ public R importData(MultipartFile file, Integer isCovered) {
+ AssessmentConfigImporter assessmentConfigImporter = new AssessmentConfigImporter(assessmentConfigService, isCovered == 1);
+ AssExcelUtil.save(file, assessmentConfigImporter, AssessmentConfigExcel.class, 0, 3);
+// ExcelUtil.save(file, assessmentConfigImporter, AssessmentConfigExcel.class);
+ return R.success("操作成功");
+ }
+
+
+ /**
+ * 导出数据
+ */
+ @GetMapping("/export-assessmentConfig")
+ @ApiOperationSupport(order = 9)
+ @ApiOperation(value = "导出数据", notes = "传入assessmentConfig")
+ public void exportAssessmentConfig(@ApiIgnore @RequestParam Map<String, Object> assessmentConfig, BladeUser bladeUser, HttpServletResponse response) {
+ QueryWrapper<AssessmentConfigEntity> queryWrapper = Condition.getQueryWrapper(assessmentConfig, AssessmentConfigEntity.class);
+ //if (!AuthUtil.isAdministrator()) {
+ // queryWrapper.lambda().eq(AssessmentConfig::getTenantId, bladeUser.getTenantId());
+ //}
+ queryWrapper.lambda().eq(AssessmentConfigEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
+ List<AssessmentConfigExcel> list = assessmentConfigService.exportAssessmentConfig(queryWrapper);
+ ExcelUtil.export(response, "考核权重配置表数据" + DateUtil.time(), "考核权重配置表数据表", list, AssessmentConfigExcel.class);
+ }
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/dto/AssessmentConfigDTO.java b/src/main/java/org/springblade/modules/assessment/dto/AssessmentConfigDTO.java
new file mode 100644
index 0000000..ce378f9
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/dto/AssessmentConfigDTO.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.dto;
+
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 考核权重配置表 数据传输对象实体类
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class AssessmentConfigDTO extends AssessmentConfigEntity {
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/entity/AssessmentConfigEntity.java b/src/main/java/org/springblade/modules/assessment/entity/AssessmentConfigEntity.java
new file mode 100644
index 0000000..c7c7e60
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/entity/AssessmentConfigEntity.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.tenant.mp.TenantEntity;
+
+/**
+ * 考核权重配置表 实体类
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+@Data
+@TableName("yw_assessment_config")
+@ApiModel(value = "AssessmentConfig对象", description = "考核权重配置表")
+@EqualsAndHashCode(callSuper = true)
+public class AssessmentConfigEntity extends TenantEntity {
+
+ /**
+ * 被考核人
+ */
+ @ApiModelProperty(value = "被考核人")
+ private Long userId;
+ /**
+ * 被考核人名称
+ */
+ @ApiModelProperty(value = "被考核人名称")
+ private String userName;
+ /**
+ * 被考核人部门id
+ */
+ @ApiModelProperty(value = "被考核人部门id")
+ private Long deptId;
+ /**
+ * 被考核人部门名称
+ */
+ @ApiModelProperty(value = "被考核人部门名称")
+ private String deptName;
+ /**
+ * 被考核人职位名称
+ */
+ @ApiModelProperty(value = "被考核人职位名称")
+ private String postName;
+ /**
+ * 考核人
+ */
+ @ApiModelProperty(value = "考核人")
+ private Long assessorUserId;
+ /**
+ * 考核人名称
+ */
+ @ApiModelProperty(value = "考核人名称")
+ private String assessorUserName;
+ /**
+ * 考核人部门id
+ */
+ @ApiModelProperty(value = "考核人部门id")
+ private Long assessorDeptId;
+ /**
+ * 考核人部门名称
+ */
+ @ApiModelProperty(value = "考核人部门名称")
+ private String assessorDeptName;
+ /**
+ * 考核人职位名称
+ */
+ @ApiModelProperty(value = "考核人职位名称")
+ private String assessorPostName;
+
+ /**
+ * 权值
+ */
+ @ApiModelProperty(value = "权值")
+ private Integer weight;
+ /**
+ * 范围
+ */
+ @ApiModelProperty(value = "范围")
+ private Integer rangeVal;
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigExcel.java b/src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigExcel.java
new file mode 100644
index 0000000..9c0f315
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigExcel.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.excel;
+
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 考核权重配置表 Excel实体类
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class AssessmentConfigExcel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * 被考核人
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("序号")
+ private Long no;
+ /**
+ * 被考核人名称
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("被考核人")
+ private String userName;
+
+ /**
+ * 被考核人部门名称
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("被考核人所在部门")
+ private String deptName;
+
+ /**
+ * 考核人名称
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("考核人")
+ private String assessorUserName;
+
+ /**
+ * 考核人部门名称
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("考核人所在部门")
+ private String assessorDeptName;
+
+ /**
+ * 权值
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("总权值")
+ private Integer weight;
+ /**
+ * 范围
+ */
+ @ColumnWidth(20)
+ @ExcelProperty("可评分上下调整范围")
+ private Integer rangeVal;
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigImporter.java b/src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigImporter.java
new file mode 100644
index 0000000..a74ed53
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/excel/AssessmentConfigImporter.java
@@ -0,0 +1,25 @@
+package org.springblade.modules.assessment.excel;
+
+import lombok.RequiredArgsConstructor;
+import org.springblade.core.excel.support.ExcelImporter;
+import org.springblade.modules.assessment.service.IAssessmentConfigService;
+
+import java.util.List;
+
+/**
+ * @PROJECT_NAME: zttj-java-boot
+ * @DESCRIPTION:
+ * @USER: aix
+ * @DATE: 2024/2/21 9:39
+ */
+@RequiredArgsConstructor
+public class AssessmentConfigImporter implements ExcelImporter<AssessmentConfigExcel> {
+
+ private final IAssessmentConfigService service;
+ private final Boolean isCovered;
+
+ @Override
+ public void save(List<AssessmentConfigExcel> data) {
+ service.importData(data, isCovered);
+ }
+}
diff --git a/src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.java b/src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.java
new file mode 100644
index 0000000..6ce3cfe
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.mapper;
+
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+import org.springblade.modules.assessment.vo.AssessmentConfigVO;
+import org.springblade.modules.assessment.excel.AssessmentConfigExcel;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import java.util.List;
+
+/**
+ * 考核权重配置表 Mapper 接口
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+public interface AssessmentConfigMapper extends BaseMapper<AssessmentConfigEntity> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param assessmentConfig
+ * @return
+ */
+ List<AssessmentConfigVO> selectAssessmentConfigPage(IPage page, AssessmentConfigVO assessmentConfig);
+
+
+ /**
+ * 获取导出数据
+ *
+ * @param queryWrapper
+ * @return
+ */
+ List<AssessmentConfigExcel> exportAssessmentConfig(@Param("ew") Wrapper<AssessmentConfigEntity> queryWrapper);
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.xml b/src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.xml
new file mode 100644
index 0000000..e3713fd
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/mapper/AssessmentConfigMapper.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.modules.assessment.mapper.AssessmentConfigMapper">
+
+ <!-- 通用查询映射结果 -->
+ <resultMap id="assessmentConfigResultMap" type="org.springblade.modules.assessment.entity.AssessmentConfigEntity">
+ <result column="id" property="id"/>
+ <result column="tenant_id" property="tenantId"/>
+ <result column="user_id" property="userId"/>
+ <result column="user_name" property="userName"/>
+ <result column="dept_id" property="deptId"/>
+ <result column="dept_name" property="deptName"/>
+ <result column="post_name" property="postName"/>
+ <result column="assessor_user_id" property="assessorUserId"/>
+ <result column="assessor_user_name" property="assessorUserName"/>
+ <result column="assessor_dept_id" property="assessorDeptId"/>
+ <result column="assessor_dept_name" property="assessorDeptName"/>
+ <result column="assessor_post_name" property="assessorPostName"/>
+ <result column="weight" property="weight"/>
+ <result column="range_val" property="rangeVal"/>
+ <result column="create_user" property="createUser"/>
+ <result column="create_dept" property="createDept"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_user" property="updateUser"/>
+ <result column="update_time" property="updateTime"/>
+ <result column="status" property="status"/>
+ <result column="is_deleted" property="isDeleted"/>
+ </resultMap>
+
+
+ <select id="selectAssessmentConfigPage" resultMap="assessmentConfigResultMap">
+ select * from yw_assessment_config where is_deleted = 0
+ </select>
+
+
+ <select id="exportAssessmentConfig" resultType="org.springblade.modules.assessment.excel.AssessmentConfigExcel">
+ SELECT * FROM yw_assessment_config ${ew.customSqlSegment}
+ </select>
+
+</mapper>
diff --git a/src/main/java/org/springblade/modules/assessment/service/IAssessmentConfigService.java b/src/main/java/org/springblade/modules/assessment/service/IAssessmentConfigService.java
new file mode 100644
index 0000000..737e9ba
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/service/IAssessmentConfigService.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.service;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+import org.springblade.modules.assessment.excel.AssessmentConfigExcel;
+import org.springblade.modules.assessment.vo.AssessmentConfigVO;
+
+import java.util.List;
+
+/**
+ * 考核权重配置表 服务类
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+public interface IAssessmentConfigService extends BaseService<AssessmentConfigEntity> {
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param assessmentConfig
+ * @return
+ */
+ IPage<AssessmentConfigVO> selectAssessmentConfigPage(IPage<AssessmentConfigVO> page, AssessmentConfigVO assessmentConfig);
+
+
+ /**
+ * 导出数据
+ *
+ * @param queryWrapper
+ * @return
+ */
+ List<AssessmentConfigExcel> exportAssessmentConfig(Wrapper<AssessmentConfigEntity> queryWrapper);
+
+ /**
+ * 导入数据
+ *
+ * @param data
+ * @param isCovered
+ * @return
+ */
+ void importData(List<AssessmentConfigExcel> data, Boolean isCovered);
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/service/impl/AssessmentConfigServiceImpl.java b/src/main/java/org/springblade/modules/assessment/service/impl/AssessmentConfigServiceImpl.java
new file mode 100644
index 0000000..f6b4e8f
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/service/impl/AssessmentConfigServiceImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import lombok.AllArgsConstructor;
+import org.springblade.common.cache.SysCache;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringPool;
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+import org.springblade.modules.assessment.excel.AssessmentConfigExcel;
+import org.springblade.modules.assessment.mapper.AssessmentConfigMapper;
+import org.springblade.modules.assessment.service.IAssessmentConfigService;
+import org.springblade.modules.assessment.vo.AssessmentConfigVO;
+import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IUserService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 考核权重配置表 服务实现类
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+@Service
+@AllArgsConstructor
+public class AssessmentConfigServiceImpl extends BaseServiceImpl<AssessmentConfigMapper, AssessmentConfigEntity> implements IAssessmentConfigService {
+
+ private final IUserService userService;
+
+ @Override
+ public IPage<AssessmentConfigVO> selectAssessmentConfigPage(IPage<AssessmentConfigVO> page, AssessmentConfigVO assessmentConfig) {
+ return page.setRecords(baseMapper.selectAssessmentConfigPage(page, assessmentConfig));
+ }
+
+
+ @Override
+ public List<AssessmentConfigExcel> exportAssessmentConfig(Wrapper<AssessmentConfigEntity> queryWrapper) {
+ List<AssessmentConfigExcel> assessmentConfigList = baseMapper.exportAssessmentConfig(queryWrapper);
+ //assessmentConfigList.forEach(assessmentConfig -> {
+ // assessmentConfig.setTypeName(DictCache.getValue(DictEnum.YES_NO, AssessmentConfig.getType()));
+ //});
+ return assessmentConfigList;
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void importData(List<AssessmentConfigExcel> data, Boolean isCovered) {
+ data.forEach(configExcel -> {
+
+ if (configExcel.getUserName() != null && configExcel.getDeptName() != null) {
+ AssessmentConfigEntity po = Objects.requireNonNull(BeanUtil.copy(configExcel, AssessmentConfigEntity.class));
+ // 被考核人信息
+ QueryWrapper qw = new QueryWrapper();
+ qw.eq("name", po.getUserName().trim());
+ qw.eq("dept_id", Func.toStrWithEmpty(SysCache.getDeptIds("000000", po.getDeptName().trim()), StringPool.EMPTY));
+ User user = userService.getOne(qw);
+ po.setUserId(user.getId());
+ po.setDeptId(Func.toLong(user.getDeptId()));
+ po.setDeptName(po.getDeptName());
+ po.setPostName(SysCache.getPostName(Func.toLong(user.getPostId())));
+
+ //考核人信息
+ QueryWrapper beQw = new QueryWrapper();
+ beQw.eq("name", po.getAssessorUserName().trim());
+ beQw.eq("dept_id", Func.toStrWithEmpty(SysCache.getDeptIds("000000", po.getAssessorDeptName().trim()), StringPool.EMPTY));
+ User beUser = userService.getOne(beQw);
+ po.setAssessorUserId(beUser.getId());
+ po.setAssessorDeptId(Func.toLong(beUser.getDeptId()));
+ po.setAssessorDeptName(po.getAssessorDeptName());
+ po.setAssessorPostName(SysCache.getPostName(Func.toLong(beUser.getPostId())));
+
+ // 覆盖数据
+ if (isCovered) {
+ QueryWrapper configQw = new QueryWrapper();
+ configQw.eq("user_id", po.getUserId());
+ configQw.eq("assessor_user_id", po.getAssessorUserId());
+ AssessmentConfigEntity assessmentConfig = getOne(configQw);
+ if (assessmentConfig != null && assessmentConfig.getId() != null) {
+ po.setId(assessmentConfig.getId());
+ }
+ }
+
+ saveOrUpdate(po);
+ }
+
+
+
+
+ });
+ }
+}
diff --git a/src/main/java/org/springblade/modules/assessment/utils/AssExcelUtil.java b/src/main/java/org/springblade/modules/assessment/utils/AssExcelUtil.java
new file mode 100644
index 0000000..66512d5
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/utils/AssExcelUtil.java
@@ -0,0 +1,34 @@
+package org.springblade.modules.assessment.utils;
+
+import com.alibaba.excel.read.builder.ExcelReaderBuilder;
+import org.springblade.core.excel.listener.ImportListener;
+import org.springblade.core.excel.support.ExcelImporter;
+import org.springblade.core.excel.util.ExcelUtil;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @PROJECT_NAME: zttj-java-boot
+ * @DESCRIPTION:
+ * @USER: aix
+ * @DATE: 2024/2/20 16:19
+ */
+public class AssExcelUtil extends ExcelUtil {
+
+ /**
+ * 自定义模板导入保存
+ * @param excel 文件
+ * @param importer
+ * @param clazz
+ * @param sheetNo sheet序号(从0开始)
+ * @param headRowNumber 表头行数
+ * @param <T>
+ */
+ public static <T> void save(MultipartFile excel, ExcelImporter<T> importer, Class<T> clazz,int sheetNo, int headRowNumber) {
+ ImportListener<T> importListener = new ImportListener<>(importer);
+ ExcelReaderBuilder builder = getReaderBuilder(excel, importListener, clazz);
+ if (builder != null) {
+ builder.sheet(sheetNo).headRowNumber(headRowNumber).doRead();
+ }
+ }
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/vo/AssessmentConfigVO.java b/src/main/java/org/springblade/modules/assessment/vo/AssessmentConfigVO.java
new file mode 100644
index 0000000..9915b69
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/vo/AssessmentConfigVO.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+
+/**
+ * 考核权重配置表 视图实体类
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class AssessmentConfigVO extends AssessmentConfigEntity {
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/assessment/wrapper/AssessmentConfigWrapper.java b/src/main/java/org/springblade/modules/assessment/wrapper/AssessmentConfigWrapper.java
new file mode 100644
index 0000000..a719123
--- /dev/null
+++ b/src/main/java/org/springblade/modules/assessment/wrapper/AssessmentConfigWrapper.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.assessment.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.assessment.entity.AssessmentConfigEntity;
+import org.springblade.modules.assessment.vo.AssessmentConfigVO;
+import java.util.Objects;
+
+/**
+ * 考核权重配置表 包装类,返回视图层所需的字段
+ *
+ * @author Aix
+ * @since 2024-02-21
+ */
+public class AssessmentConfigWrapper extends BaseEntityWrapper<AssessmentConfigEntity, AssessmentConfigVO> {
+
+ public static AssessmentConfigWrapper build() {
+ return new AssessmentConfigWrapper();
+ }
+
+ @Override
+ public AssessmentConfigVO entityVO(AssessmentConfigEntity assessmentConfig) {
+ AssessmentConfigVO assessmentConfigVO = Objects.requireNonNull(BeanUtil.copy(assessmentConfig, AssessmentConfigVO.class));
+
+ //User createUser = UserCache.getUser(assessmentConfig.getCreateUser());
+ //User updateUser = UserCache.getUser(assessmentConfig.getUpdateUser());
+ //assessmentConfigVO.setCreateUserName(createUser.getName());
+ //assessmentConfigVO.setUpdateUserName(updateUser.getName());
+
+ return assessmentConfigVO;
+ }
+
+
+}
--
Gitblit v1.9.3