shichongfu
2023-04-25 ce0b49552668d3331055e2b1a1447a743dc54939
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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;
    }
 
}