|
|
|
@ -1,13 +1,23 @@
|
|
|
|
package com.ruoyi.kaohe.service.impl;
|
|
|
|
package com.ruoyi.kaohe.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.ruoyi.kaohe.mapper.KhEmployeeMapper;
|
|
|
|
import com.ruoyi.kaohe.mapper.KhEmployeeMapper;
|
|
|
|
import com.ruoyi.kaohe.domain.KhEmployee;
|
|
|
|
import com.ruoyi.kaohe.domain.KhEmployee;
|
|
|
|
import com.ruoyi.kaohe.service.IKhEmployeeService;
|
|
|
|
import com.ruoyi.kaohe.service.IKhEmployeeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 职工信息Service业务层处理
|
|
|
|
* 职工信息Service业务层处理
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -17,9 +27,11 @@ import com.ruoyi.kaohe.service.IKhEmployeeService;
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class KhEmployeeServiceImpl implements IKhEmployeeService
|
|
|
|
public class KhEmployeeServiceImpl implements IKhEmployeeService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
@Resource
|
|
|
|
private KhEmployeeMapper khEmployeeMapper;
|
|
|
|
private KhEmployeeMapper khEmployeeMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(KhEmployeeServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询职工信息
|
|
|
|
* 查询职工信息
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -93,4 +105,62 @@ public class KhEmployeeServiceImpl implements IKhEmployeeService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return khEmployeeMapper.deleteKhEmployeeById(id);
|
|
|
|
return khEmployeeMapper.deleteKhEmployeeById(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String importEmp(List<KhEmployee> empList, boolean updateSupport, String operName) {
|
|
|
|
|
|
|
|
if (StringUtils.isNull(empList) || empList.size() == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new ServiceException("导入职工数据不能为空!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
|
|
|
for (KhEmployee employee : empList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 验证是否存在这个职工
|
|
|
|
|
|
|
|
KhEmployee param = new KhEmployee();
|
|
|
|
|
|
|
|
param.setEmpName(employee.getEmpName());
|
|
|
|
|
|
|
|
param.setDeptId(employee.getDeptId());
|
|
|
|
|
|
|
|
List<KhEmployee> e = khEmployeeMapper.selectKhEmployeeList(param);
|
|
|
|
|
|
|
|
if (StringUtils.isNull(e)||e.size()==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
khEmployeeMapper.insertKhEmployee(employee);
|
|
|
|
|
|
|
|
successNum++;
|
|
|
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、账号 " + employee.getEmpName() + " 导入成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (updateSupport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
employee.setId(param.getId());
|
|
|
|
|
|
|
|
khEmployeeMapper.updateKhEmployee(employee);
|
|
|
|
|
|
|
|
successNum++;
|
|
|
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、账号 " + employee.getEmpName() + " 更新成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failureNum++;
|
|
|
|
|
|
|
|
failureMsg.append("<br/>" + failureNum + "、账号 " + employee.getEmpName() + " 已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failureNum++;
|
|
|
|
|
|
|
|
String msg = "<br/>" + failureNum + "、账号 " + employee.getEmpName() + " 导入失败:";
|
|
|
|
|
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (failureNum > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
|
|
|
throw new ServiceException(failureMsg.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return successMsg.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|