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
package com.product.org.admin.service;
 
import java.util.Date;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
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.service.support.AbstractBaseService;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.org.admin.config.CmnConst;
import com.product.org.admin.config.SystemCode;
import com.product.util.BaseUtil;
 
/**
 *     工作时间
* Copyright  PRODUCT-BASE
* @Title: PRODUCT-BASE-
* @Project: CompanyWorkTimeController
* @Date: 2021年8月14日 下午3:34:07
* @Author: 杜洪波
* @Description:
 */
@Component
public class CompanyWorkTimeService extends AbstractBaseService{
 
    
    @Autowired
    BaseDao baseDao;
    
    /**
     *     工作信息新增
     * @param fse
     * @return
     */
    public String addOrUpdateInfo(FieldSetEntity fse) {
        getPunchType(fse);
        if(StringUtils.isEmpty(fse.getUUID())) {
            fse.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
            fse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
            baseDao.add(fse);
        }else {
            fse.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
            fse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
            baseDao.update(fse);
        }
        return fse.getUUID();
    }
    
    /**
     *     获取打卡类型
     *  0:上午上班
     *  1:上午上班  下午下班
     *  2:上午上班  下午上班
     *  3:上午上班  上午下班  下午上班  下午下班
     * @return
     */
    /*
    public void getPunchType(FieldSetEntity fse) {
        if (!StringUtils.isEmpty(fse.getString("work_time_one")) && StringUtils.isEmpty(fse.getString("work_time_two")) && StringUtils.isEmpty(fse.getString("work_time_three")) && StringUtils.isEmpty(fse.getString(fse.getString("work_time_four")))) {
            fse.setValue("work_time_type", 0);
        }else if (!StringUtils.isEmpty(fse.getString("work_time_one")) && StringUtils.isEmpty(fse.getString("work_time_two")) && StringUtils.isEmpty(fse.getString("work_time_three")) && !StringUtils.isEmpty(fse.getString(fse.getString("work_time_four")))) {
            fse.setValue("work_time_type", 1);
        }else if (!StringUtils.isEmpty(fse.getString("work_time_one")) && StringUtils.isEmpty(fse.getString("work_time_two")) && !StringUtils.isEmpty(fse.getString("work_time_three")) && StringUtils.isEmpty(fse.getString(fse.getString("work_time_four")))) {
            fse.setValue("work_time_type", 2);
        }else if (!StringUtils.isEmpty(fse.getString("work_time_one")) && !StringUtils.isEmpty(fse.getString("work_time_two")) && !StringUtils.isEmpty(fse.getString("work_time_three")) && !StringUtils.isEmpty(fse.getString(fse.getString("work_time_four")))) {
            fse.setValue("work_time_type", 3);
        }else {
            throw new BaseException(SystemCode.WORK_TIME_CONFIG_FAIL.getValue(), SystemCode.WORK_TIME_CONFIG_FAIL.getText());
        }
    }
    */
    public void getPunchType(FieldSetEntity fse) {
        String type="";
        if (!StringUtils.isEmpty(fse.getString("work_time_one"))) {
            type+="1";
        }
        if (!StringUtils.isEmpty(fse.getString("work_time_two"))) {
            type+="2";
        }
        if (!StringUtils.isEmpty(fse.getString("work_time_three"))) {
            type+="3";
        }
        if (!StringUtils.isEmpty(fse.getString("work_time_four"))) {
            type+="4";
        }
        if ("1".equals(type)) {
            fse.setValue("work_time_type", 0);
        }else if ("14".equals(type)) {
            fse.setValue("work_time_type", 1);
        }else if ("13".equals(type)) {
            fse.setValue("work_time_type", 2);
        }else if ("1234".equals(type)) {
            fse.setValue("work_time_type", 3);
        }else {
            throw new BaseException(SystemCode.WORK_TIME_CONFIG_FAIL.getValue(), SystemCode.WORK_TIME_CONFIG_FAIL.getText());
        }
    }
    
    /**
     *     工作信息详情
     * @param uuid
     * @return
     */
    public FieldSetEntity findInfo() {
        return baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_OA_PUNCH_TIME, "org_level_uuid=?", new Object[] {SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid()}, false);
    }
    
    /**
     *     公司工作时间配置
     * @param org_level_uuid
     * @param pageSize
     * @param cpage
     * @return
     */
    public DataTableEntity listInfo(String org_level_uuid, Integer pageSize, Integer cpage) {
        DataTableEntity dt=null;
        if (StringUtils.isEmpty(org_level_uuid)) {
            dt=baseDao.listTable(CmnConst.PRODUCT_OA_PUNCH_TIME, null, null, null, null, pageSize, cpage);
        }else {
            dt=baseDao.listTable(CmnConst.PRODUCT_OA_PUNCH_TIME, "org_level_uuid=?", new Object[] {org_level_uuid}, null, null, pageSize, cpage);
        }
        if (!BaseUtil.dataTableIsEmpty(dt)) {
            baseDao.loadPromptData(dt);
        }
        return dt;
    }
}