You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
467 lines
27 KiB
Java
467 lines
27 KiB
Java
package com.jingcheng.cms.service.impl;
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.jingcheng.cms.constants.Constants;
|
|
import com.jingcheng.cms.mapper.*;
|
|
import com.jingcheng.cms.model.*;
|
|
import com.jingcheng.cms.service.EmployeeService;
|
|
import com.jingcheng.cms.service.InfoSettingValueService;
|
|
import com.jingcheng.cms.beans.AjaxResult;
|
|
import com.jingcheng.cms.util.ExcelUtils;
|
|
import com.jingcheng.cms.util.PageUtils;
|
|
import com.jingcheng.cms.vo.DataAnalysisVO;
|
|
import com.jingcheng.cms.vo.DataStatisticsVO;
|
|
import lombok.SneakyThrows;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Service
|
|
@Transactional
|
|
public class EmployeeServiceImpl implements EmployeeService {
|
|
|
|
@Resource
|
|
private InfoSettingValueService infoSettingValueService;
|
|
|
|
@Resource
|
|
private EmployeeMapper employeeMapper;
|
|
@Resource
|
|
private EducationResumeMapper educationResumeMapper;
|
|
@Resource
|
|
private FamilyMembersMapper familyMembersMapper;
|
|
@Resource
|
|
private WorkExperienceMapper workExperienceMapper;
|
|
@Resource
|
|
private HonorMapper honorMapper;
|
|
|
|
@Override
|
|
public JSONObject getEmployeeByPage(JSONObject jsonObject) {
|
|
|
|
Example example = new Example(Employee.class);
|
|
example.setOrderByClause("id ASC");
|
|
Employee employee = JSONObject.toJavaObject(jsonObject, Employee.class);
|
|
Example.Criteria criteria = example.createCriteria();
|
|
criteria.andEqualTo("state",Constants.STATE_VALID);
|
|
String honorDescription = jsonObject.getString("honorDescription");
|
|
JSONArray ptqIdsJson = jsonObject.getJSONArray("ptqIds");
|
|
List<Long> ptqIds = ptqIdsJson != null ? ptqIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray postIdsJson = jsonObject.getJSONArray("postIds");
|
|
List<Long> postIds = postIdsJson != null ? postIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray groupsIdsJson = jsonObject.getJSONArray("groupsIds");
|
|
List<Long> groupsIds = groupsIdsJson != null ? groupsIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray skillLevelIdsJson = jsonObject.getJSONArray("skillLevelIds");
|
|
List<Long> skillLevelIds = skillLevelIdsJson != null ? skillLevelIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray highestEducationIdsJson = jsonObject.getJSONArray("highestEducationIds");
|
|
List<Long> highestEducationIds = highestEducationIdsJson != null ? highestEducationIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray unitIdsJson = jsonObject.getJSONArray("unitIds");
|
|
List<Long> unitIds = unitIdsJson != null ? unitIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray honorLevelsJson = jsonObject.getJSONArray("honorLevels");
|
|
List<Long> honorLevels = honorLevelsJson != null ? honorLevelsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray sexesJson = jsonObject.getJSONArray("sexes");
|
|
List<Integer> sexes = sexesJson != null ? sexesJson.toJavaList(Integer.class) : new ArrayList<>();
|
|
JSONArray departmentIdsJson = jsonObject.getJSONArray("departmentIds");
|
|
List<Long> departmentIds = departmentIdsJson != null ? departmentIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray agesJson = jsonObject.getJSONArray("ages");
|
|
List<Long> ages = agesJson != null ? agesJson.toJavaList(Long.class) : new ArrayList<>();
|
|
List<String> honorEmployees = new ArrayList<>();
|
|
if ((null != honorLevels && honorLevels.size() > 0) || StringUtils.isNotEmpty(honorDescription)) {
|
|
Example example1 = new Example(Honor.class);
|
|
Example.Criteria criteria1 = example1.createCriteria();
|
|
criteria1.andEqualTo("state",Constants.STATE_VALID);
|
|
if (null != honorLevels && honorLevels.size() > 0) {
|
|
criteria1.andIn("honorLevel", honorLevels);
|
|
}
|
|
if (StringUtils.isNotEmpty(honorDescription)) {
|
|
criteria1.andLike("honorDescription", "%"+honorDescription+"%");
|
|
}
|
|
List<Honor> honors = honorMapper.selectByExample(example1);
|
|
honorEmployees.addAll(honors.stream().map(item -> item.getEmployeeNo()).collect(Collectors.toSet()));
|
|
}
|
|
Integer current = jsonObject.getInteger("current") == null ? 1 : jsonObject.getInteger("current");
|
|
Integer pageSize = jsonObject.getInteger("pageSize") == null ? 10 : jsonObject.getInteger("pageSize");
|
|
if (StringUtils.isNotEmpty(employee.getEmployeeNo())) criteria.andLike("employeeNo", "%"+employee.getEmployeeNo()+"%");
|
|
if (honorEmployees.size() > 0) criteria.andIn("employeeNo", honorEmployees);
|
|
if (StringUtils.isNotEmpty(employee.getEmployeeName())) criteria.andLike("employeeName", "%"+employee.getEmployeeName()+"%");
|
|
if (StringUtils.isNotEmpty(employee.getMobile())) criteria.andLike("mobile", "%"+employee.getMobile()+"%");
|
|
if (null != sexes && sexes.size() > 0) criteria.andIn("sex", sexes);
|
|
if (null != departmentIds && departmentIds.size() > 0) criteria.andIn("departmentId", departmentIds);
|
|
if (null != ages && ages.size() == 2) criteria.andBetween("age", ages.get(0), ages.get(1));
|
|
if (null != ptqIds && ptqIds.size() > 0) criteria.andIn("ptqId", ptqIds);
|
|
if (null != unitIds && unitIds.size() > 0) criteria.andIn("unitId", unitIds);
|
|
if (null != postIds && postIds.size() > 0) criteria.andIn("postId", postIds);
|
|
if (null != groupsIds && groupsIds.size() > 0) criteria.andIn("groupsId", groupsIds);
|
|
if (null != skillLevelIds && skillLevelIds.size() > 0) criteria.andIn("skillLevelId", skillLevelIds);
|
|
if (null != highestEducationIds && highestEducationIds.size() > 0) criteria.andIn("highestEducationId", highestEducationIds);
|
|
List<Employee> employeeList = employeeMapper.selectByExample(example);
|
|
if (((null != honorLevels && honorLevels.size() > 0) || StringUtils.isNotEmpty(honorDescription)) && honorEmployees.size() == 0) employeeList = new ArrayList<>();
|
|
JSONObject pageJson = PageUtils.page(employeeList,current,pageSize);
|
|
return pageJson;
|
|
}
|
|
|
|
@Override
|
|
public void exportEmployee(JSONObject jsonObject, HttpServletResponse response) {
|
|
Example example = new Example(Employee.class);
|
|
example.setOrderByClause("id ASC");
|
|
Employee employee = JSONObject.toJavaObject(jsonObject, Employee.class);
|
|
Example.Criteria criteria = example.createCriteria();
|
|
criteria.andEqualTo("state",Constants.STATE_VALID);
|
|
String honorDescription = jsonObject.getString("honorDescription");
|
|
JSONArray ptqIdsJson = jsonObject.getJSONArray("ptqIds");
|
|
List<Long> ptqIds = ptqIdsJson != null ? ptqIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray postIdsJson = jsonObject.getJSONArray("postIds");
|
|
List<Long> postIds = postIdsJson != null ? postIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray groupsIdsJson = jsonObject.getJSONArray("groupsIds");
|
|
List<Long> groupsIds = groupsIdsJson != null ? groupsIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray skillLevelIdsJson = jsonObject.getJSONArray("skillLevelIds");
|
|
List<Long> skillLevelIds = skillLevelIdsJson != null ? skillLevelIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray highestEducationIdsJson = jsonObject.getJSONArray("highestEducationIds");
|
|
List<Long> highestEducationIds = highestEducationIdsJson != null ? highestEducationIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray unitIdsJson = jsonObject.getJSONArray("unitIds");
|
|
List<Long> unitIds = unitIdsJson != null ? unitIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray honorLevelsJson = jsonObject.getJSONArray("honorLevels");
|
|
List<Long> honorLevels = honorLevelsJson != null ? honorLevelsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray sexesJson = jsonObject.getJSONArray("sexes");
|
|
List<Integer> sexes = sexesJson != null ? sexesJson.toJavaList(Integer.class) : new ArrayList<>();
|
|
JSONArray departmentIdsJson = jsonObject.getJSONArray("departmentIds");
|
|
List<Long> departmentIds = departmentIdsJson != null ? departmentIdsJson.toJavaList(Long.class) : new ArrayList<>();
|
|
JSONArray agesJson = jsonObject.getJSONArray("ages");
|
|
List<Long> ages = agesJson != null ? agesJson.toJavaList(Long.class) : new ArrayList<>();
|
|
List<String> honorEmployees = new ArrayList<>();
|
|
if ((null != honorLevels && honorLevels.size() > 0) || StringUtils.isNotEmpty(honorDescription)) {
|
|
Example example1 = new Example(Honor.class);
|
|
Example.Criteria criteria1 = example1.createCriteria();
|
|
criteria1.andEqualTo("state",Constants.STATE_VALID);
|
|
if (null != honorLevels && honorLevels.size() > 0) {
|
|
criteria1.andIn("honorLevel", honorLevels);
|
|
}
|
|
if (StringUtils.isNotEmpty(honorDescription)) {
|
|
criteria1.andLike("honorDescription", "%"+honorDescription+"%");
|
|
}
|
|
List<Honor> honors = honorMapper.selectByExample(example1);
|
|
honorEmployees.addAll(honors.stream().map(item -> item.getEmployeeNo()).collect(Collectors.toSet()));
|
|
}
|
|
if (StringUtils.isNotEmpty(employee.getEmployeeNo())) criteria.andLike("employeeNo", "%"+employee.getEmployeeNo()+"%");
|
|
if (honorEmployees.size() > 0) criteria.andIn("employeeNo", honorEmployees);
|
|
if (StringUtils.isNotEmpty(employee.getEmployeeName())) criteria.andLike("employeeName", "%"+employee.getEmployeeName()+"%");
|
|
if (StringUtils.isNotEmpty(employee.getMobile())) criteria.andLike("mobile", "%"+employee.getMobile()+"%");
|
|
if (null != ptqIds && ptqIds.size() > 0) criteria.andIn("ptqId", ptqIds);
|
|
if (null != sexes && sexes.size() > 0) criteria.andIn("sex", sexes);
|
|
if (null != departmentIds && departmentIds.size() > 0) criteria.andIn("departmentId", departmentIds);
|
|
if (null != ages && ages.size() == 2) criteria.andBetween("age", ages.get(0), ages.get(1));
|
|
if (null != unitIds && unitIds.size() > 0) criteria.andIn("unitId", unitIds);
|
|
if (null != postIds && postIds.size() > 0) criteria.andIn("postId", postIds);
|
|
if (null != groupsIds && groupsIds.size() > 0) criteria.andIn("groupsId", groupsIds);
|
|
if (null != skillLevelIds && skillLevelIds.size() > 0) criteria.andIn("skillLevelId", skillLevelIds);
|
|
if (null != highestEducationIds && highestEducationIds.size() > 0) criteria.andIn("highestEducationId", highestEducationIds);
|
|
List<Employee> employeeList = employeeMapper.selectByExample(example);
|
|
if (((null != honorLevels && honorLevels.size() > 0) || StringUtils.isNotEmpty(honorDescription)) && honorEmployees.size() == 0) employeeList = new ArrayList<>();
|
|
ExportParams exportParams = new ExportParams();
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams,Employee.class, employeeList);
|
|
ExcelUtils.export(workbook, response, "员工导出");
|
|
}
|
|
|
|
@Override
|
|
public void exportEmployeeDetail(JSONObject jsonObject, HttpServletResponse response) {
|
|
List<Map<String, Object>> exportParamList = Lists.newArrayList();
|
|
String employeeNo = jsonObject.getString("employeeNo");
|
|
// 员工基本信息
|
|
Map<String, Object> sheetMap1 = Maps.newHashMap();
|
|
Employee employee = new Employee();
|
|
employee.setState(Constants.ENABLE);
|
|
employee.setEmployeeNo(employeeNo);
|
|
List<Employee> employeeList = employeeMapper.select(employee);
|
|
sheetMap1.put("title", new ExportParams("员工基本信息", "员工基本信息"));
|
|
sheetMap1.put("entity", Employee.class);
|
|
sheetMap1.put("data", employeeList);
|
|
exportParamList.add(sheetMap1);
|
|
// 员工教育履历
|
|
Map<String, Object> sheetMap2 = Maps.newHashMap();
|
|
EducationResume educationResume = new EducationResume();
|
|
educationResume.setState(Constants.ENABLE);
|
|
educationResume.setEmployeeNo(employeeNo);
|
|
List<EducationResume> educationResumes = educationResumeMapper.select(educationResume);
|
|
sheetMap2.put("title", new ExportParams("员工教育履历", "员工教育履历"));
|
|
sheetMap2.put("entity", EducationResume.class);
|
|
sheetMap2.put("data", educationResumes);
|
|
exportParamList.add(sheetMap2);
|
|
// 员工家庭成员
|
|
Map<String, Object> sheetMap3 = Maps.newHashMap();
|
|
FamilyMembers familyMembers = new FamilyMembers();
|
|
familyMembers.setState(Constants.ENABLE);
|
|
familyMembers.setEmployeeNo(employeeNo);
|
|
List<FamilyMembers> familyMembersList = familyMembersMapper.select(familyMembers);
|
|
sheetMap3.put("title", new ExportParams("员工家庭成员", "员工家庭成员"));
|
|
sheetMap3.put("entity", FamilyMembers.class);
|
|
sheetMap3.put("data", familyMembersList);
|
|
exportParamList.add(sheetMap3);
|
|
// 员工工作经历
|
|
Map<String, Object> sheetMap4 = Maps.newHashMap();
|
|
WorkExperience workExperience = new WorkExperience();
|
|
workExperience.setState(Constants.ENABLE);
|
|
workExperience.setEmployeeNo(employeeNo);
|
|
List<WorkExperience> workExperienceList = workExperienceMapper.select(workExperience);
|
|
sheetMap4.put("title", new ExportParams("员工工作经历", "员工工作经历"));
|
|
sheetMap4.put("entity", WorkExperience.class);
|
|
sheetMap4.put("data", workExperienceList);
|
|
exportParamList.add(sheetMap4);
|
|
// 员工奖惩
|
|
Map<String, Object> sheetMap5 = Maps.newHashMap();
|
|
Honor honor = new Honor();
|
|
honor.setState(Constants.ENABLE);
|
|
honor.setEmployeeNo(employeeNo);
|
|
List<Honor> honorList = honorMapper.select(honor);
|
|
sheetMap5.put("title", new ExportParams("员工奖惩", "员工奖惩"));
|
|
sheetMap5.put("entity", Honor.class);
|
|
sheetMap5.put("data", honorList);
|
|
exportParamList.add(sheetMap5);
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParamList, ExcelType.HSSF);
|
|
ExcelUtils.export(workbook, response, "员工明细导出");
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult saveEmployee(JSONObject jsonObject) {
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
Employee employee = JSONObject.toJavaObject(jsonObject, Employee.class);
|
|
employee.setState(Constants.ENABLE);
|
|
if (null == employee.getId()) {
|
|
employeeMapper.insert(employee);
|
|
} else {
|
|
employeeMapper.updateByPrimaryKey(employee);
|
|
}
|
|
return ajaxResult;
|
|
}
|
|
|
|
@SneakyThrows
|
|
@Override
|
|
public AjaxResult importEmployee(MultipartFile multipartFile) {
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
String prefix = fileName.substring(fileName.lastIndexOf("."));
|
|
File file = File.createTempFile(fileName, prefix);
|
|
multipartFile.transferTo(file);
|
|
ImportParams params = new ImportParams();
|
|
params.setTitleRows(0);//都是默认值 titlerow代表标题行 headrow代表数据开始行
|
|
params.setHeadRows(1);
|
|
List<Employee> employeeList = ExcelImportUtil.importExcel(file, Employee.class, params);
|
|
List<Employee> employeeListInsert = new ArrayList<>();
|
|
List<Employee> employeeListUpdate = new ArrayList<>();
|
|
for (Employee employee : employeeList) {
|
|
if (StringUtils.isEmpty(employee.getEmployeeNo())) continue;
|
|
//单位
|
|
if (StringUtils.isNotEmpty(employee.getUnit())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("单位");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getUnit())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setUnitId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
//岗位
|
|
if (StringUtils.isNotEmpty(employee.getPost())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("岗位");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getPost())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setPostId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
//班组
|
|
if (StringUtils.isNotEmpty(employee.getGroups())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("班组");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getGroups())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setGroupsId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
//专业技术资格
|
|
if (StringUtils.isNotEmpty(employee.getPtq())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("专业技术资格");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getPtq())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setPtqId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
} else {
|
|
employee.setPtq("无");
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("专业技术资格");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getPtq())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setPtqId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
//技能等级
|
|
if (StringUtils.isNotEmpty(employee.getSkillLevel())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("技能等级");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getSkillLevel())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setSkillLevelId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
} else {
|
|
employee.setSkillLevel("无");
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("技能等级");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getSkillLevel())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setSkillLevelId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
//学历
|
|
if (StringUtils.isNotEmpty(employee.getHighestEducation())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("学历");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getHighestEducation())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setHighestEducationId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
//部门
|
|
if (StringUtils.isNotEmpty(employee.getDepartment())) {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("部门");
|
|
List<InfoSettingValue> infoSettingValuesFilter = infoSettingValues.stream().filter(item -> item.getSettingValue().equals(employee.getDepartment())).collect(Collectors.toList());
|
|
if (infoSettingValuesFilter.size() > 0) {
|
|
employee.setDepartmentId(infoSettingValuesFilter.get(0).getId());
|
|
}
|
|
}
|
|
Employee employeeSelect = new Employee();
|
|
employeeSelect.setEmployeeNo(employee.getEmployeeNo());
|
|
employeeSelect.setState(Constants.ENABLE);
|
|
Employee employee1 = employeeMapper.selectOne(employeeSelect);
|
|
employee.setState(Constants.ENABLE);
|
|
if (null == employee1) {
|
|
employeeListInsert.add(employee);
|
|
} else {
|
|
employee.setId(employee1.getId());
|
|
employeeListUpdate.add(employee);
|
|
}
|
|
}
|
|
if(employeeListInsert.size() > 0) employeeMapper.insertList(employeeListInsert);
|
|
if (employeeListUpdate != null && employeeListUpdate.size() != 0) {
|
|
for (Employee employee : employeeListUpdate) {
|
|
employeeMapper.updateByPrimaryKey(employee);
|
|
}
|
|
}
|
|
|
|
return ajaxResult;
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult delEmployee(Long id) {
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
Employee employee = new Employee();
|
|
employee.setId(id);
|
|
employee.setState(Constants.STATE_VALID);
|
|
Employee employee1 = employeeMapper.selectOne(employee);
|
|
if (null == employee1){
|
|
ajaxResult.setRetmsg("未找到该员工");
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
return ajaxResult;
|
|
}else {
|
|
Example example = new Example(Employee.class);
|
|
Example.Criteria criteria = example.createCriteria();
|
|
criteria.andEqualTo("id",id);
|
|
employee1 = new Employee();
|
|
employee1.setState(Constants.DISABLE);
|
|
employeeMapper.updateByExampleSelective(employee1,example);
|
|
ajaxResult.setRetmsg("员工删除成功");
|
|
return ajaxResult;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult dataStatistics(JSONObject jsonObject) {
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
JSONArray postNamesJson = jsonObject.getJSONArray("postNames");
|
|
List<String> postNames = postNamesJson != null ? postNamesJson.toJavaList(String.class) : new ArrayList<>();
|
|
JSONArray departmentsJson = jsonObject.getJSONArray("departments");
|
|
List<String> departments = departmentsJson != null ? departmentsJson.toJavaList(String.class) : new ArrayList<>();
|
|
// List<Long> postIdList = (List<Long>) Arrays.stream(postIds.split(",")).mapToLong(num -> Long.parseLong(num));
|
|
Integer isEdu = jsonObject.getInteger("isEdu");
|
|
Integer isSkill = jsonObject.getInteger("isSkill");
|
|
Integer isPtq = jsonObject.getInteger("isPtq");
|
|
Integer isDepartment = jsonObject.getInteger("isDepartment");
|
|
Integer isAge = jsonObject.getInteger("isAge");
|
|
Integer isSex = jsonObject.getInteger("isSex");
|
|
List<DataStatisticsVO> dataStatisticsVOS = new ArrayList<>();
|
|
List<String> departmentList = new ArrayList<>();
|
|
if (departments != null && departments.size() > 0) {
|
|
departmentList = departments;
|
|
} else {
|
|
List<InfoSettingValue> infoSettingValues = infoSettingValueService.getAllInfoSettingValueBySettingName("部门");
|
|
departmentList = infoSettingValues.stream().map(item -> item.getSettingValue()).collect(Collectors.toList());
|
|
departmentList.add(0,"汇总数据");
|
|
}
|
|
|
|
for (String s : departmentList) {
|
|
DataStatisticsVO dataStatisticsVO = new DataStatisticsVO();
|
|
dataStatisticsVO.setPostName(s);
|
|
if (s.equals("汇总数据")) {
|
|
s = null;
|
|
}
|
|
if (null != isEdu && isEdu == 1) {
|
|
List<DataAnalysisVO> dataAnalysisVOS = employeeMapper.dataStatistics(1, s, postNames);
|
|
dataStatisticsVO.setEducationList(dataAnalysisVOS);
|
|
}
|
|
if (null != isPtq && isPtq == 1) {
|
|
List<DataAnalysisVO> dataAnalysisVOS = employeeMapper.dataStatistics(2, s, postNames);
|
|
dataStatisticsVO.setPtqList(dataAnalysisVOS);
|
|
}
|
|
if (null != isSkill && isSkill == 1) {
|
|
List<DataAnalysisVO> dataAnalysisVOS = employeeMapper.dataStatistics(3, s, postNames);
|
|
dataStatisticsVO.setSkillLevelList(dataAnalysisVOS);
|
|
}
|
|
if (null != isSex && isSex == 1) {
|
|
List<DataAnalysisVO> dataAnalysisVOS = employeeMapper.dataStatistics(4, s, postNames);
|
|
dataStatisticsVO.setSexList(dataAnalysisVOS);
|
|
}
|
|
if (null != isAge && isAge == 1) {
|
|
List<DataAnalysisVO> dataAnalysisVOS = employeeMapper.dataStatistics(5, s, postNames);
|
|
dataStatisticsVO.setAgeList(dataAnalysisVOS);
|
|
}
|
|
if (null != isDepartment && isDepartment == 1 && !dataStatisticsVO.getPostName().equals("汇总数据")) {
|
|
Employee employee = new Employee();
|
|
employee.setState(Constants.ENABLE);
|
|
Integer all = employeeMapper.selectCount(employee);
|
|
List<DataAnalysisVO> dataAnalysisVOS = employeeMapper.dataStatistics(6, s, postNames);
|
|
List<DataAnalysisVO> dataAnalysisVOS1 = new ArrayList<>();
|
|
for (DataAnalysisVO dataAnalysisVO : dataAnalysisVOS) {
|
|
dataAnalysisVO.setAnalysisCount(dataAnalysisVO.getPostCount());
|
|
dataAnalysisVO.setPostCount(all.longValue());
|
|
dataAnalysisVOS1.add(dataAnalysisVO);
|
|
}
|
|
dataAnalysisVOS = dataAnalysisVOS1;
|
|
dataStatisticsVO.setDepartmentList(dataAnalysisVOS);
|
|
}
|
|
dataStatisticsVOS.add(dataStatisticsVO);
|
|
}
|
|
|
|
ajaxResult.setData(dataStatisticsVOS);
|
|
return ajaxResult;
|
|
}
|
|
|
|
@Override
|
|
public AjaxResult getPostListByDept(JSONObject jsonObject) {
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
JSONArray departmentsJson = jsonObject.getJSONArray("departments");
|
|
List<String> departments = departmentsJson != null ? departmentsJson.toJavaList(String.class) : new ArrayList<>();
|
|
List<String> postList = employeeMapper.getPostListByDept(departments);
|
|
ajaxResult.setData(postList);
|
|
return ajaxResult;
|
|
}
|
|
|
|
}
|