package com.product.org.admin.service;
|
|
import com.product.admin.config.SystemCode;
|
import com.product.common.lang.StringUtils;
|
import com.product.core.dao.BaseDao;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.permission.PermissionService;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.core.service.support.QueryFilterService;
|
import com.product.core.transfer.Transactional;
|
import com.product.org.admin.config.CmnConst;
|
import com.product.org.admin.service.idel.IChangeDimissionService;
|
import com.product.util.BaseUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* Copyright LX-BASE
|
*
|
* @Title: ChangeDimissionService
|
* @Project: LX-BASE-SERVER
|
* @Date: 2020年6月10日 下午3:49:58
|
* @Author: 郑盟
|
* @Description:
|
*/
|
@Component
|
public class ChangeDimissionService extends AbstractBaseService implements IChangeDimissionService{
|
|
@Autowired
|
public BaseDao baseDao;
|
|
@Autowired
|
PermissionService permissionService;
|
|
@Autowired
|
QueryFilterService queryFilterService;
|
|
|
/**
|
* 员工离职详情
|
* @param uuid
|
* @return
|
* @throws BaseException
|
*/
|
public FieldSetEntity findDimission(String uuid) throws BaseException {
|
return baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFF_TERMINATION, uuid, false);
|
}
|
|
|
/**
|
* 员工离职列表
|
* @param fs
|
* @return
|
* @throws BaseException
|
*/
|
public DataTableEntity listDimission(FieldSetEntity fs) throws BaseException {
|
|
String dataFilter=permissionService.getDataFilter("b."+CmnConst.ORG_LEVEL_UUID) ;
|
//高级查询
|
String searchFilter=queryFilterService.getQueryFilter(fs);
|
|
if(!StringUtils.isEmpty(dataFilter)) {
|
dataFilter=" WHERE "+dataFilter;
|
if (!StringUtils.isEmpty(searchFilter)) {
|
dataFilter+=" AND "+ searchFilter;
|
}
|
}else {
|
if (!StringUtils.isEmpty(searchFilter)) {
|
dataFilter=searchFilter;
|
}
|
}
|
|
StringBuilder sql=new StringBuilder();
|
sql.append(" select * from (");
|
sql.append(" SELECT a.uuid uuid,b.uuid uuid1,c.uuid uuid2,d.uuid uuid3,e.uuid uuid4,f.uuid uuid5,a.apply_staff_uuid,a.termination_reason,a.change_effective,a.result_status,b.show_name,b.preferred_name,c.client_name,d.org_level_all,e.job_post_name,f.job_grade_name ");
|
sql.append(" FROM product_sys_staff_termination a ");
|
sql.append(" LEFT JOIN product_sys_staffs b ON a.apply_staff_uuid=b.uuid ");
|
sql.append(" LEFT JOIN product_sys_clients c ON c.uuid=b.client_uuid ");
|
sql.append(" LEFT JOIN product_sys_org_levels d ON d.uuid=b.dept_uuid ");
|
sql.append(" LEFT JOIN product_sys_job_posts e ON e.uuid=b.job_post_uuid ");
|
sql.append(" LEFT JOIN product_sys_job_post_grades f ON f.uuid=b.job_post_grade_uuid ");
|
sql.append(dataFilter);
|
sql.append(" ) b");
|
|
DataTableEntity dt=baseDao.listTable(sql.toString(), null, fs.getInteger("pagesize"), fs.getInteger("cpage"));
|
dt.getMeta().addAliasTable(CmnConst.PRODUCT_SYS_STAFF_TERMINATION,"a");
|
dt.getMeta().addAliasTable(CmnConst.PRODUCT_SYS_STAFFS,"b");
|
dt.getMeta().addAliasTable("product_sys_clients","c");
|
dt.getMeta().addAliasTable("product_sys_org_levels","d");
|
dt.getMeta().addAliasTable("product_sys_job_posts","e");
|
dt.getMeta().addAliasTable("product_sys_job_post_grades","f");
|
dt.getMeta().addAliasField("product_sys_staffs.uuid", "uuid1");
|
dt.getMeta().addAliasField("product_sys_staffs.show_name", "show_name");
|
|
if (!BaseUtil.dataTableIsEmpty(dt)) {
|
baseDao.loadPromptData(dt);
|
baseDao.listInternationDataTable(dt, null);
|
}
|
|
return dt;
|
}
|
|
/**
|
* 离职新增
|
* @param fs
|
* @return
|
* @throws BaseException
|
*/
|
@Transactional
|
public String addDimission(FieldSetEntity fs) throws BaseException {
|
String staff_uuid = fs.getString(CmnConst.APP_STAFF_UUID);
|
String sql = " SELECT uuid FROM product_sys_staffs WHERE staff_status in(1,2,3) and uuid not in (SELECT apply_staff_uuid FROM product_sys_staff_termination WHERE result_status<>2 or result_status is null or result_status='') AND uuid =? ";
|
DataTableEntity listTable = baseDao.listTable(sql, new Object[] {staff_uuid});
|
if (listTable.getRows() == 0) {
|
throw new BaseException(SystemCode.SYSTEM_STAFFS_WHERE_FAIL.getValue(),SystemCode.SYSTEM_STAFFS_WHERE_FAIL.getText(), this.getClass(), "addDimission");
|
}
|
FieldSetEntity staff_fs = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, staff_uuid, false);
|
fs.setValue("org_level_uuid", staff_fs.getString("org_level_uuid"));
|
fs.setValue("apply_dept_uuid", staff_fs.getString("dept_uuid"));
|
fs.setValue("job_post_uuid", staff_fs.getString("job_post_uuid"));
|
fs.setValue("role_uuids", staff_fs.getString("role_uuids"));
|
fs.setValue("direct_leader_code", staff_fs.getString("direct_leader_code"));
|
fs.setValue(CmnConst.RESULT_STATUS, 0);
|
baseDao.executeUpdate("update product_sys_staffs set staff_status=5 where uuid=?", new String[] { staff_uuid });
|
baseDao.executeUpdate("update product_sys_staff_employment_info set termination_effective_date=? where staff_uuid=?", new Object[] {fs.getString(CmnConst.CHANGE_EFFECTIVE),staff_uuid}); //杜洪波 2020-12-30 14:58:00 就业信息显示离职日期
|
String add = baseDao.add(fs);
|
return add;
|
}
|
|
/**
|
* 根据人员id获取人员信息
|
* @param staff_uuid
|
* @return
|
* @throws BaseException
|
*/
|
public FieldSetEntity getStaff(String staff_uuid) throws BaseException {
|
FieldSetEntity staff_fs = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, staff_uuid, false);
|
baseDao.loadPromptData(staff_fs);
|
return staff_fs;
|
}
|
|
/**
|
* 离职申请修改
|
* @param fs
|
* @return
|
* @throws BaseException
|
*/
|
public boolean updateDimission(FieldSetEntity fs) throws BaseException {
|
String uuid = fs.getString("uuid");
|
FieldSetEntity fss = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFF_TERMINATION, uuid, false);
|
String handover_staff_uuid = fss.getString("handover_staff_uuid");
|
fs.setValue(CmnConst.RESULT_STATUS, fss.getString(CmnConst.RESULT_STATUS));
|
fs.remove("handover_date");
|
if (!StringUtils.isEmpty(handover_staff_uuid)) {
|
fs.setValue("handover_staff_uuid", handover_staff_uuid);
|
fs.setValue("handover_detail", fss.getString("handover_detail"));
|
fs.setValue("attachment", fss.getString("attachment"));
|
fs.setValue(CmnConst.CHANGE_EFFECTIVE, fss.getString(CmnConst.CHANGE_EFFECTIVE));
|
}
|
//杜洪波 2020-12-30 14:58:00 就业信息显示离职日期
|
baseDao.executeUpdate("update product_sys_staff_employment_info set termination_effective_date=? where staff_uuid=?", new Object[] {fs.getDate(CmnConst.CHANGE_EFFECTIVE),fs.getString(CmnConst.APP_STAFF_UUID)});
|
return baseDao.update(fs);
|
}
|
|
/**
|
* 离职申请删除
|
* @param uuid
|
* @return
|
* @throws BaseException
|
*/
|
@Transactional
|
public boolean deleteDimission(String uuid)throws BaseException {
|
FieldSetEntity fseDimission=baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFF_TERMINATION, uuid, false);
|
if (fseDimission!=null) {
|
baseDao.executeUpdate("update product_sys_staffs set staff_status=3 where uuid=?", new Object[]{fseDimission.getString(CmnConst.APP_STAFF_UUID)});
|
baseDao.executeUpdate("update product_sys_staff_employment_info set termination_effective_date=null where staff_uuid=?", new Object[] {fseDimission.getString(CmnConst.APP_STAFF_UUID)}); //杜洪波 2020-12-30 14:58:00 就业信息显示离职日期
|
}
|
boolean flag=baseDao.delete(CmnConst.PRODUCT_SYS_STAFF_TERMINATION, "uuid=?", new Object[] {uuid});
|
return flag;
|
}
|
|
}
|