package com.ld.igds.oa.service;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.bstek.dorado.data.provider.Page;
|
import com.ld.igds.models.OAStaff;
|
import com.ld.igds.models.OAStaff;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.util.DateUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.hibernate.Session;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* 人员管理
|
*
|
* @Author:YAN
|
*/
|
@Component
|
public class HStaffService extends HibernateDao {
|
|
|
public void pageData(Page<OAStaff> page, Map<String, Object> param)
|
throws Exception {
|
String hql = " from " + OAStaff.class.getName() + " where companyId =:companyId and deptId =:deptId";
|
|
Map<String, Object> args = new HashMap<>();
|
args.put("companyId", ContextUtil.getCompanyId());
|
args.put("deptId", ContextUtil.subDeptId(null));
|
|
if (null != param) {
|
|
String str = (String) param.get("sector");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and lsbm like:sector";
|
args.put("sector", "%" + str + "%");
|
}
|
str = (String) param.get("name");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and xm like :name";
|
args.put("name", "%" + str + "%");
|
}
|
str = (String) param.get("userId");
|
if (StringUtils.isNotEmpty(str)) {
|
hql += " and sfzhm like :userId";
|
args.put("userId", "%" + str + "%");
|
}
|
Date date = (Date) param.get("start");
|
if (null != date) {
|
hql += " and rzrq >=:start";
|
args.put("start", DateUtil.getCurZero(date));
|
}
|
date = (Date) param.get("end");
|
if (null != date) {
|
hql += " and rzrq <:end";
|
args.put("end", DateUtil.getNextZero(date));
|
}
|
|
}
|
|
String count = "select count(*) " + hql;
|
|
hql += " order by updateTime desc";
|
this.pagingQuery(page, hql, count, args);
|
|
}
|
|
public String saveOrUpdate(OAStaff data) {
|
//判断组织编码
|
if (StringUtils.isEmpty(data.getCompanyId())) {
|
data.setCompanyId(data.getCompanyId());
|
}
|
Session session = this.getSessionFactory().openSession();
|
try {
|
data.setCompanyId(ContextUtil.getCompanyId());
|
session.saveOrUpdate(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public String delData(OAStaff data) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
session.delete(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
|
}
|