package com.product.org.admin.service; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.product.org.admin.config.CmnConst; import com.product.org.admin.config.SystemCode; import com.product.org.admin.service.idel.IStaffRegularEmployeeService; import com.product.util.BaseUtil; 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; /** * * Copyright LX-BASE * @Title: LX-BASE- * @Project: StaffChangeService * @Date: 2020-06-09 15:27 * @Author: 杜洪波 * @Description:人员转正 */ @Component public class StaffRegularEmployeeService extends AbstractBaseService implements IStaffRegularEmployeeService{ @Autowired public BaseDao baseDao; @Autowired PermissionService permissionService; @Autowired QueryFilterService queryFilterService; /** * 人员转正信息列表 * @param cpage * @param pageSize * @return * @throws BaseException */ public DataTableEntity listStaffRegularEmployee(Integer cpage,Integer pageSize, FieldSetEntity fse) throws BaseException { //数据策略 String dataFilter=permissionService.getDataFilter("b."+CmnConst.ORG_LEVEL_UUID) ; //高级查询 String searchFilter=queryFilterService.getQueryFilter(fse); 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.staff_uuid,a.employment_date,a.probation_end_date,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_complete_probation a "); sql.append(" LEFT JOIN product_sys_staffs b ON a.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, pageSize, cpage); dt.getMeta().addAliasTable("product_sys_staff_complete_probation","a"); dt.getMeta().addAliasTable("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"); if (!BaseUtil.dataTableIsEmpty(dt)) { baseDao.loadPromptData(dt); baseDao.listInternationDataTable(dt, null); } return dt; } /** * 人员变更信息详情 * @param uuid * @return * @throws BaseException */ public FieldSetEntity findStaffRegularEmployee(String uuid) throws BaseException { String sql=" SELECT a.uuid,a.staff_uuid,a.remarks,a.result_status,a.probation_end_date,b.uuid,b.show_name,b.entry_datetime employment_date FROM product_sys_staff_complete_probation a LEFT JOIN product_sys_staffs b ON a.staff_uuid=b.uuid WHERE a.uuid=?"; DataTableEntity dtInfo=baseDao.listTable(sql, new String[] {uuid}); return baseDao.listInternationDataTable(dtInfo.getFieldSetEntity(0), null); } /** * 新增转正信息 * @param fs * @return * @throws BaseException */ @Transactional public String addRegularEmployee(FieldSetEntity fse) throws BaseException { String staff_uuid=fse.getString(CmnConst.STAFF_UUID); FieldSetEntity fseStaff=baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, staff_uuid, false); fse.setValue(CmnConst.ORG_LEVEL_UUID, fseStaff.getString(CmnConst.ORG_LEVEL_UUID)); fse.setValue(CmnConst.RESULT_STATUS, 0); String uuid= baseDao.add(fse); /* if(uuid !=null ) { //查询对应员工信息 FieldSetEntity sfs =baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, fse.getString(CmnConst.STAFF_UUID), false); if(sfs !=null ) { //变更状态为"准备转正" String sql="update product_sys_staffs set staff_status=? where uuid=?"; baseDao.executeUpdate(sql, new Object[] {2,fse.getString(CmnConst.STAFF_UUID)}); } } */ return uuid; } /** * 修改转正信息 * @param fse * @return * @throws BaseException */ public boolean updateRegularEmployee(FieldSetEntity fse) throws BaseException { if(fse.getInteger("result_status")==1) { throw new BaseException(SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_UPDATE_FAIL_CHANGED.getValue(),SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_UPDATE_FAIL_CHANGED.getText(),this.getClass(),"updateRegularEmployee"); } return baseDao.update(fse); } /** * 删除转正信息 * @param uuid * @return * @throws BaseException */ @Transactional public boolean deleteRegularEmployee(String uuid) throws BaseException { boolean flag=true; FieldSetEntity fseRegularInfo =baseDao.getFieldSetEntity("product_sys_staff_complete_probation", uuid, false); if(fseRegularInfo !=null) { if(fseRegularInfo.getInteger("result_status")==1) { throw new BaseException(SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_DELETE_FAIL_CHANGED.getValue(),SystemCode.SYSTEM_STAFF_REGULAR_EMPLOYEE_DELETE_FAIL_CHANGED.getText(),this.getClass(),"deleteRegularEmployee"); } /* FieldSetEntity fseStaffInfo =baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_STAFFS, fseRegularInfo.getString(CmnConst.STAFF_UUID), false); if(fseStaffInfo !=null ) {//改回 //变更状态为"试用" String sql="update product_sys_staffs set staff_status=? where uuid=?"; baseDao.executeUpdate(sql, new Object[] {1,fseRegularInfo.getString(CmnConst.STAFF_UUID)}); } */ } flag=baseDao.delete(CmnConst.PRODUCT_SYS_STAFF_COMPLETE_PROBATION, new String[] {uuid}); return flag; } }