shichongfu
2023-05-31 6f9405da1b729783c9c0811b5b475d03793c1da2
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
package com.product.mobile.core.service;
 
import java.text.SimpleDateFormat;
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.mobile.core.config.MobileCoreConst;
import com.product.module.sys.entity.SystemUser;
import com.product.util.BaseUtil;
 
/**
 * 手机端,获取用户所有应用
 * @author Administrator
 *
 */
@Component
public class SignInService extends AbstractBaseService{
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //制定输出格式
    
    @Autowired
    public BaseDao baseDao;
    /**
     *     先查出历史打卡记录
     * @param cpage
     * @param pagesize
     * @return
     * @throws BaseException
     */
    public boolean signIn(FieldSetEntity fse) throws BaseException{
        fse.setTableName(MobileCoreConst.TABLE_PUNCH_RECORD);
        SystemUser user=SpringMVCContextHolder.getCurrentUser();
        Date d = new Date();
        DataTableEntity dt=signInList(fse);
        if(user!=null) {
            fse.setValue(MobileCoreConst.ORG_LEVEL_UUID, user.getOrg_level_uuid());
            fse.setValue(MobileCoreConst.DEPT_UUID, user.getDept_uuid());
            fse.setValue(MobileCoreConst.CREATED_UTC_DATETIME, d);
        }
        fse.setValue(MobileCoreConst.FIELD_PUNCH_TYPE,1);//手机打卡
        
        
        return baseDao.saveFieldSetEntity(fse);
    }
    /**
     *     查出指定日期打卡记录
     * @param cpage
     * @param pagesize
     * @return
     * @throws BaseException
     */
    public DataTableEntity signInList(FieldSetEntity fse) throws BaseException{
        SystemUser user=SpringMVCContextHolder.getCurrentUser();
        Date d = new Date();
        String str = sdf.format(d); //将日期转换为字符串且格式按照之前制定的
        StringBuilder sql=new StringBuilder();
        sql.append("select *  from ").append(MobileCoreConst.TABLE_PUNCH_RECORD)
        .append(" where created_by=?  and DATE_FORMAT(created_utc_datetime,'%Y-%m-%d')=? ");
        
        DataTableEntity dt=baseDao.listTable(sql.toString(), new Object[] {user.getUser_id(),str});
        return dt;
    }
    /**
     * 查询公司定义的考勤点
     * @param org_level_uuid
     * @return
     */
    public DataTableEntity signInSites(String org_level_uuid) {
        if(StringUtils.isEmpty(org_level_uuid)) {
            return baseDao.listTable(MobileCoreConst.TABLE_PUNCH_SITE);
        }else {
            return baseDao.listTable(MobileCoreConst.TABLE_PUNCH_SITE,"org_level_uuid=?",new String[] {org_level_uuid});
        }
    }
    
}