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