Commit cceba6d2 authored by hongguangwu's avatar hongguangwu

人员档案-批量导入

parent f3237aa3
......@@ -17,6 +17,7 @@
package com.yifu.cloud.plus.v1.yifu.archives.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
......@@ -342,5 +343,22 @@ public class TEmployeeInfo extends BaseEntity {
@Schema(description = "通信地址")
private String contactAddress;
// 以下是项目档案信息
@TableField(exist = false)
@Schema(description = "项目id")
private String deptId;
@TableField(exist = false)
@Schema(description = "项目名称")
private String deptName;
@TableField(exist = false)
@Schema(description = "项目编码")
private String deptNo;
@TableField(exist = false)
@Schema(description = "就职岗位")
private String post;
}
/*
* Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 项目档案表excel对应的实体
*
* @author huyc
* @date 2022-06-20 17:54:40
*/
@Data
@ColumnWidth(30)
public class EmployeeVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 员工类型(字典值,0外包1派遣2代理)
*/
@NotNull(message = "员工类型不能为空")
@ExcelProperty(value = "员工类型")
private String empNatrue;
/**
* 姓名
*/
@ExcelProperty(value = "姓名")
@Max(value = 20, message = "姓名不可超过20位")
private String empName;
/**
* 身份证号
*/
@ExcelProperty(value = "身份证号")
@Max(value = 20, message = "身份证号不可超过20位")
private String empIdcard;
/**
* 项目编码
*/
@ExcelProperty(value = "项目编码")
@Max(value = 32, message = "项目编码不可超过32位")
private String deptNo;
/**
* 就职岗位
*/
@ExcelProperty(value = "就职岗位")
@Max(value = 50, message = "就职岗位不可超过50位")
private String post;
/**
* 身份证有效期起
*/
@ExcelProperty(value = "身份证开始日期")
private LocalDateTime validityStart;
/**
* 身份证有效期止
*/
@ExcelProperty(value = "身份证截止日期")
private LocalDateTime validityEnd;
/**
* 婚姻状况
*/
@ExcelProperty(value = "婚姻状况")
@Max(value = 32, message = "婚姻状况不可超过32位")
private String empMarriStatus;
/**
* 民族
*/
@ExcelProperty(value = "民族")
@Max(value = 32, message = "民族不可超过32位")
private String empNational;
/**
* 政治面貌
*/
@ExcelProperty(value = "政治面貌")
@Max(value = 32, message = "政治面貌不可超过32位")
private String politicalStatus;
/**
* 手机号码
*/
@ExcelProperty(value = "手机号码")
@Max(value = 11, message = "手机号码不可超过11位")
private String empPhone;
/**
* 邮箱
*/
@ExcelProperty(value = "邮箱")
@Max(value = 32, message = "邮箱不可超过32位")
private String empEmail;
/**
* 身份证-省
*/
@ExcelProperty(value = "户籍所在省")
private String idProvince;
/**
* 身份证-市
*/
@ExcelProperty(value = "户籍所在市")
private String idCity;
/**
* 身份证-县
*/
@ExcelProperty(value = "户籍所在县")
private String idTown;
/**
* 户口性质
*/
@ExcelProperty(value = "户口性质")
private String empRegisType;
/**
* 档案-省
*/
@ExcelProperty(value = "档案所在省")
private String fileProvince;
/**
* 档案-市
*/
@ExcelProperty(value = "档案所在市")
private String fileCity;
/**
* 档案-县
*/
@ExcelProperty(value = "档案所在县")
private String fileTown;
/**
* 是否大专及以上(0否1是)
*/
@ExcelProperty(value = "是否大专及以上")
private String isCollege;
/**
* 最高学历(字典值)
*/
@ExcelProperty(value = "最高学历")
private String hignEducation;
/**
* 学校
*/
@ExcelProperty(value = "学校")
private String school;
/**
* 专业
*/
@ExcelProperty(value = "专业")
private String major;
/**
* 入学时间
*/
@ExcelProperty(value = "入学时间")
private LocalDateTime admissionDate;
/**
* 毕业时间
*/
@ExcelProperty(value = "毕业时间")
private LocalDateTime gradutionDate;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}
......@@ -19,9 +19,14 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDataAuth;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
......@@ -39,6 +44,7 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
......@@ -229,4 +235,20 @@ public class TEmployeeInfoController {
return tEmployeeInfoService.minusEmployee(id);
}
/**
* @param excelList
* @param bindingResult
* @Description: 批量导入人员档案
* @Author: hgw
* @Date: 2022/6/22 11:57
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
@Operation(description = "批量导入人员档案 hasPermission('employee_batch_import') 额外属性:isCanAdd:0不可以复档复项;1允许复档复项")
@SysLog("批量导入人员档案")
@PostMapping("/batchImportEmployee")
@PreAuthorize("@pms.hasPermission('employee_batch_import')")
public R<List<ErrorMessage>> batchImportEmployee(@RequestExcel List<EmployeeVO> excelList, BindingResult bindingResult, @RequestParam Integer isCanAdd) {
return tEmployeeInfoService.batchImportEmployee(excelList, bindingResult, isCanAdd);
}
}
......@@ -40,6 +40,12 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
List<TEmployeeInfo> getList(@Param("tEmployeeInfo") TEmployeeInfo tEmployeeInfo);
// hgw 2022-6-22 15:32:39 根据身份证查询一批档案
List<TEmployeeInfo> getListByIdCard(@Param("idCardList") List<String> idCardList);
// hgw 2022-6-22 15:32:39 根据手机号查询一批档案
List<TEmployeeInfo> getListByPhone(@Param("phoneList") List<String> phoneList);
int updateEducationOfEmp(@Param("education") EmpEducationUpdateVo education);
void updateExcelEmployeeInfo(@Param("list") List<TEmployeeInfo> list);
......
......@@ -20,9 +20,12 @@ package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult;
import java.util.List;
......@@ -101,7 +104,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
/**
* @param employeeInfo 档案信息
* @param fileSource 人员档案来源(4人员档案新建、5项目档案新建、1社保/公积金、3商险、2薪酬)
* @param fileSource 人员档案来源(4人员档案新建、5项目档案新建、1社保/公积金、3商险、2薪酬)
* @Description: 新增人员档案,其他服务新增时调用
* @Author: hgw
* @Date: 2022/6/21 19:03
......@@ -109,5 +112,13 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
**/
R<TEmployeeInfo> saveNewEmpLoyee(TEmployeeInfo employeeInfo, String fileSource);
/**
* @Description: 批量导入人员档案
* @Author: hgw
* @Date: 2022/6/22 11:58
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
R<List<ErrorMessage>> batchImportEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult, int isCanAdd);
void updateEducationOfEmp(EmpEducationUpdateVo education);
}
......@@ -53,6 +53,16 @@ public interface TEmployeeProjectService extends IService<TEmployeeProject> {
**/
List<TEmployeeProject> getListByEmpId(String empId, int projectStatus);
/**
* @param empId
* @param deptNo
* @Description: 获取档案下的项目信息
* @Author: hgw
* @Date: 2022/6/22 17:48
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject>
**/
List<TEmployeeProject> getListByEmpIdAndDeptNo(String empId, String deptNo);
R<List<ErrorMessage>> importEmpProjectUpdate(List<EmployeeProjectVO> excelVOList, BindingResult bindingResult);
/**
......
......@@ -471,4 +471,13 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
project.setDeleteFlag(CommonConstants.STATUS_NORMAL);
return this.list(Wrappers.query(project));
}
@Override
public List<TEmployeeProject> getListByEmpIdAndDeptNo(String empId, String deptNo) {
TEmployeeProject project = new TEmployeeProject();
project.setEmpId(empId);
project.setDeptNo(deptNo);
project.setDeleteFlag(CommonConstants.STATUS_NORMAL);
return this.list(Wrappers.query(project));
}
}
......@@ -313,6 +313,30 @@
order by a.CREATE_TIME desc
</select>
<!-- hgw 根据身份证查询 -->
<select id="getListByIdCard" resultMap="tEmployeeInfoMap">
select
<include refid="baseParam"/>
from t_employee_info a
where
a.DELETE_FLAG = '0' and a.EMP_IDCARD in
<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!-- hgw 根据手机号查询 -->
<select id="getListByPhone" resultMap="tEmployeeInfoMap">
select
<include refid="baseParam"/>
from t_employee_info a
where
a.DELETE_FLAG = '0' and a.EMP_PHONE in
<foreach item="item" index="index" collection="phoneList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updateExcelEmployeeInfo" parameterType="java.util.List">
update t_employee_info
<trim prefix="set" suffixOverrides=",">
......
......@@ -232,4 +232,8 @@ public interface CommonConstants {
String SAVE_SUCCESS = "保存成功!";
String PARAM_IS_NOT_EMPTY = "参数不可为空";
// 是否
String IS_FALSE = "否";
String IS_TRUE = "是";
}
......@@ -221,6 +221,37 @@ public interface ErrorCodes {
* 人员不在该项目,无法更新
*/
String CHECKS_EMP_EXIT_ERROR = "checks.emp.exit.error";
// 该人员已存在,禁止重复添加
String ARCHIVES_IMPORT_EMP_IDCARD_EXISTING = "archives.import.emp.idCard.existing";
// 该人员已减档,禁止导入
String ARCHIVES_IMPORT_EMP_IDCARD_LEAVE_EXISTING = "archives.import.emp.idCard.leave.existing";
// 手机号校验错误
String ARCHIVES_IMPORT_EMP_PHONE_CHECK_ERROR = "archives.import.emp.phone.check.error";
// 手机号已被其他身份证使用
String ARCHIVES_IMPORT_EMP_PHONE_EXIST_ERROR = "archives.import.emp.phone.exist.error";
// 婚姻状况在字典中未找到
String ARCHIVES_IMPORT_EMP_MARRIED_ERROR = "archives.import.emp.married.error";
// 民族在字典中未找到
String ARCHIVES_IMPORT_EMP_NATIONAL_ERROR = "archives.import.emp.national.error";
// 政治面貌在字典中未找到
String ARCHIVES_IMPORT_EMP_POLITICAL_ERROR = "archives.import.emp.political.error";
// 户口性质在字典中未找到
String ARCHIVES_IMPORT_EMP_REGISTYPE_ERROR = "archives.import.emp.registype.error";
// 最高学历在字典中未找到
String ARCHIVES_IMPORT_EMP_EDUCATION_ERROR = "archives.import.emp.education.error";
// 员工类型在字典中未找到
String ARCHIVES_IMPORT_EMP_NATRUE_ERROR = "archives.import.emp.natrue.error";
// 户籍所在地未找到区域
String ARCHIVES_IMPORT_EMP_AREA_ERROR = "archives.import.emp.area.error";
// 档案所在地未找到区域
String ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR = "archives.import.emp.file.area.error";
// 大专及以上,最高学历必填
String ARCHIVES_IMPORT_EMP_HIGH_EDUCATION_ERROR = "archives.import.emp.high.education.error";
/**
* 项目档案状态为已审核,禁止删除
*/
......
......@@ -65,6 +65,20 @@ archives.emp.certificate.name.existing=\u5DF2\u5B58\u5728\u5BF9\u5E94\u8EAB\u4EF
checks.change.emp.project=\u5F85\u5212\u8F6C\u5458\u5DE5\u5DF2\u5728\u76EE\u6807\u9879\u76EE\u4E0B\u4E0D\u53EF\u5212\u8F6C
archives.import.emp.idCard.existing=\u8BE5\u4EBA\u5458\u5DF2\u5B58\u5728\uFF0C\u7981\u6B62\u91CD\u590D\u6DFB\u52A0
archives.import.emp.idCard.leave.existing=\u8BE5\u4EBA\u5458\u5DF2\u51CF\u6863\uFF0C\u7981\u6B62\u5BFC\u5165
archives.import.emp.phone.check.error=\u624B\u673A\u53F7\u6821\u9A8C\u9519\u8BEF
archives.import.emp.phone.exist.error=\u624B\u673A\u53F7\u5DF2\u88AB\u5176\u4ED6\u8EAB\u4EFD\u8BC1\u4F7F\u7528
archives.import.emp.married.error=\u5A5A\u59FB\u72B6\u51B5\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.national.error=\u6C11\u65CF\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.political.error=\u653F\u6CBB\u9762\u8C8C\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.registype.error=\u6237\u53E3\u6027\u8D28\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.education.error=\u6700\u9AD8\u5B66\u5386\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.natrue.error=\u5458\u5DE5\u7C7B\u578B\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.area.error=\u6237\u7C4D\u6240\u5728\u5730\u672A\u627E\u5230\u533A\u57DF
archives.import.emp.file.area.error=\u6863\u6848\u6240\u5728\u5730\u672A\u627E\u5230\u533A\u57DF
archives.import.emp.file.area.error=\u5927\u4E13\u53CA\u4EE5\u4E0A\uFF0C\u6700\u9AD8\u5B66\u5386\u5FC5\u586B
......
package com.yifu.cloud.plus.v1.yifu.admin.api.entity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 区划实体
* @author hgw
* @date 2022-6-22 19:30:59
*/
@Data
@Schema(description ="区域")
public class SysArea {
private Integer id;
private String areaName;
private String areaCode;
private Integer parentId;
private LocalDateTime updateDate;
private Integer status;
private Integer createUser;
/**
*车牌简称
*/
private String areaShort;
}
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.controller;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysAreaService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* <p>
* 字典表 前端控制器
* </p>
*
* @author lengleng
* @since 2019-03-19
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/area")
@Tag(name = "区域管理模块")
public class AreaController {
private final SysAreaService sysAreaService;
/**
* @Description: 获取所有区域(id,名称)
* @Author: hgw
* @Date: 2022/6/22 19:33
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.Integer, java.lang.String>>
**/
@Inner
@GetMapping("/inner/getAreaToId")
public R<Map<String, String>> getAreaToId() {
return sysAreaService.getAreaToId();
}
/**
* @param
* @Description: 获取所有区域(名称,id)
* @Author: hgw
* @Date: 2022/6/22 19:34
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
@Inner
@GetMapping("/inner/getAreaToName")
public R<Map<String, String>> getAreaToName() {
return sysAreaService.getAreaToName();
}
}
......@@ -32,6 +32,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
......@@ -303,4 +304,28 @@ public class DictController {
return R.ok(sysDictItemService.treeMenu(lazy, parentId));
}
/**
* @Description: 获取所有字典数据:用做导入:type,<lable,value>
* @Author: hgw
* @Date: 2022/6/22 18:19
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
@Inner
@GetMapping("/inner/getDictToLable")
public R<Map<String, Map<String, String>>> getDictToLable() {
return sysDictItemService.getDictToLable();
}
/**
* @Description: 获取所有字典数据:用做导出:type,<value,lable>
* @Author: hgw
* @Date: 2022/6/22 18:20
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
@Inner
@GetMapping("/inner/getDictToLable")
public R<Map<String, Map<String, String>>> getDictToValue() {
return sysDictItemService.getDictToValue();
}
}
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysArea;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 区域表 Mapper 接口
* </p>
*
* @author hgw
* @since 2022-6-22 19:41:44
*/
@Mapper
public interface SysAreaMapper extends BaseMapper<SysArea> {
}
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysArea;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.util.Map;
/**
* 区域
*
* @author hgw
* @date 2022-6-22 19:35:06
*/
public interface SysAreaService extends IService<SysArea> {
/**
* @Description: 获取所有区域数据:用做导出:<id,name>
* @Author: hgw
* @Date: 2022/6/22 18:04
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
R<Map<String, String>> getAreaToId();
/**
* @Description: 获取所有区域数据:用做导入:<name,id>
* @Author: hgw
* @Date: 2022/6/22 18:04
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
R<Map<String, String>> getAreaToName();
}
......@@ -63,5 +63,21 @@ public interface SysDictItemService extends IService<SysDictItem> {
R<Map<String, Object>> getAllDictItem();
/**
* @Description: 获取所有字典数据:用做导入:type,<lable,value>
* @Author: hgw
* @Date: 2022/6/22 18:04
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
R<Map<String, Map<String, String>>> getDictToLable();
/**
* @Description: 获取所有字典数据:用做导出:type,<value,lable>
* @Author: hgw
* @Date: 2022/6/22 18:04
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/
R<Map<String, Map<String, String>>> getDictToValue();
void clearDictItemCache();
}
/*
* Copyright (c) 2020 yifu4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.admin.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysArea;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysAreaMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysAreaService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 字典项
*
* @author hgw
* @date 2022-6-22 19:40:43
*/
@Service
public class SysAreaServiceImpl extends ServiceImpl<SysAreaMapper, SysArea> implements SysAreaService {
@Override
public R<Map<String, String>> getAreaToId() {
Map<String, String> resultMap = this.getStringMapMap(true);
return R.ok(resultMap);
}
@Override
public R<Map<String, String>> getAreaToName() {
Map<String, String> resultMap = this.getStringMapMap(false);
return R.ok(resultMap);
}
private Map<String, String> getStringMapMap(boolean type) {
List<SysArea> allList = baseMapper.selectList(Wrappers.<SysArea>query().lambda()
.eq(SysArea::getStatus, CommonConstants.ZERO_INT));
Map<String, String> resultMap = new HashMap<>();
doAssemble(allList, resultMap, type);
return resultMap;
}
/**
* @Description: 组装
* @Author: hgw
* @Date: 2022/6/22 18:12
* @return: void
**/
private void doAssemble(List<SysArea> allList, Map<String, String> resultMap, boolean type) {
if (Common.isNotNull(allList)) {
for (SysArea item : allList) {
if (type) {
resultMap.put(String.valueOf(item.getId()), item.getAreaName());
} else {
resultMap.put(item.getAreaName(), String.valueOf(item.getId()));
}
}
}
}
}
......@@ -200,6 +200,53 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
}
}
}
@Override
public R<Map<String, Map<String, String>>> getDictToLable() {
Map<String, Map<String, String>> resultMap = this.getStringMapMap(false);
return R.ok(resultMap);
}
@Override
public R<Map<String, Map<String, String>>> getDictToValue() {
Map<String, Map<String, String>> resultMap = this.getStringMapMap(true);
return R.ok(resultMap);
}
private Map<String, Map<String, String>> getStringMapMap(boolean type) {
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getDelFlag,CommonConstants.STATUS_NORMAL));
Map<String, Map<String, String>> resultMap = new HashMap<>();
doAssemble(allList, resultMap, type);
return resultMap;
}
/**
* @Description: 组装
* @Author: hgw
* @Date: 2022/6/22 18:12
* @return: void
**/
private void doAssemble(List<SysDictItem> allList, Map<String, Map<String, String>> resultMap, boolean type) {
if (Common.isNotNull(allList)){
String dictCode;
Map<String, String> dictMap;
for (SysDictItem item : allList) {
dictCode = item.getType();
dictMap = resultMap.get(dictCode);
if (dictMap == null) {
dictMap = new HashMap<>();
}
if (type) {
dictMap.put(item.getValue(), item.getLabel());
} else {
dictMap.put(item.getLabel(), item.getValue());
}
resultMap.put(dictCode, dictMap);
}
}
}
/**
* 构建查询的 wrapper
* @param sysDictItem 查询条件
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.admin.mapper.SysAreaMapper">
<resultMap id="sysDictMap" type="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysArea">
<id property="id" column="id"/>
<result property="areaName" column="AREA_NAME"/>
<result property="areaCode" column="AREA_CODE"/>
<result property="parentId" column="PARENT_ID"/>
<result property="updateDate" column="UPDATE_DATE"/>
<result property="status" column="STATUS"/>
<result property="createUser" column="CREATE_USER"/>
<result property="areaShort" column="AREA_SHORT"/>
</resultMap>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment