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});
|
}
|
}
|
|
}
|