提交 7b13da71 编写于 作者: liyi_hz2008's avatar liyi_hz2008

Merge branch 'feature/Attendance.detail.analyse' into 'develop'

Merge for feature/Attendance.detail.analyse[考勤管理]修复考勤优化修改后,无法根据个人请假信息正确计算考勤结果的问题

See merge request o2oa/o2oa!641
......@@ -66,27 +66,40 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
return em.createQuery(cq.where(p)).getResultList();
}
//@MethodDescribe("列示单个员工的AttendanceSelfHoliday信息列表")
public List<String> getByEmployeeName(String empName) throws Exception {
public List<String> listIdsWithBatchFlag( String batchFlag ) throws Exception {
if( StringUtils.isEmpty( batchFlag )){
return null;
}
EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<AttendanceSelfHoliday> root = cq.from( AttendanceSelfHoliday.class);
Predicate p = root.get(AttendanceSelfHoliday_.employeeName).in( empName );
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
Predicate p = cb.equal( root.get(AttendanceSelfHoliday_.batchFlag), batchFlag );
cq.select(root.get(AttendanceSelfHoliday_.id));
return em.createQuery(cq.where(p)).getResultList();
}
//@MethodDescribe("根据流程的文档ID列示员工的AttendanceSelfHoliday信息列表")
public List<String> getByWorkFlowDocId(String docId) throws Exception {
//@MethodDescribe("列示单个员工的AttendanceSelfHoliday信息列表")
public List<String> getByEmployeeName(String empName) throws Exception {
EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<AttendanceSelfHoliday> root = cq.from( AttendanceSelfHoliday.class);
Predicate p = cb.equal(root.get(AttendanceSelfHoliday_.docId), docId);
Predicate p = root.get(AttendanceSelfHoliday_.employeeName).in( empName );
cq.select(root.get(AttendanceSelfHoliday_.id));
return em.createQuery(cq.where(p)).getResultList();
}
//@MethodDescribe("根据流程的文档ID列示员工的AttendanceSelfHoliday信息列表")
// public List<String> getByWorkFlowDocId(String docId) throws Exception {
// EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
// CriteriaBuilder cb = em.getCriteriaBuilder();
// CriteriaQuery<String> cq = cb.createQuery(String.class);
// Root<AttendanceSelfHoliday> root = cq.from( AttendanceSelfHoliday.class);
// Predicate p = cb.equal(root.get(AttendanceSelfHoliday_.docId), docId);
// cq.select(root.get(AttendanceSelfHoliday_.id));
// return em.createQuery(cq.where(p)).getResultList();
// }
public List<String> listByStartDateAndEndDate(Date startDate, Date endDate) throws Exception {
EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
......@@ -219,9 +232,6 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
/**
* 查询符合的文档信息总数
* @param id
* @param count
* @param sequence
* @param wrapIn
* @return
* @throws Exception
......
......@@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.persistence.Column;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.JsonElement;
......@@ -15,6 +16,9 @@ import com.x.attendance.entity.AttendanceScheduleSetting;
import com.x.attendance.entity.AttendanceSelfHoliday;
import com.x.attendance.entity.AttendanceStatisticalCycle;
import com.x.attendance.entity.AttendanceWorkDayConfig;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
......@@ -186,16 +190,31 @@ public class ActionReciveAttendance extends BaseAction {
public static class Wi {
@FieldDescribe( "员工标识,<font color='red'>必填</font>,员工的distinguishedName." )
private String empName = null;
@FieldDescribe( "员工号, 可以为空,默认为员工标识相同值." )
private String empNo = null;
@FieldDescribe( "打卡日期,格式yyyy-mm-dd,可以为空." )
private String recordDateString = null;
@FieldDescribe( "上午上班打卡时间,格式hh24:mi:ss,可以为空,为空就是未打卡." )
private String onDutyTime = null;
@FieldDescribe("上班下午打卡签退时间,打卡策略2和3时使用,格式hh24:mi:ss,可以为空,为空就是未打卡.")
private String morningOffdutyTime;
@FieldDescribe("下午上班打卡签到时间,打卡策略2和3时使用,格式hh24:mi:ss,可以为空,为空就是未打卡.")
private String afternoonOnDutyTime;
@FieldDescribe( "下午下班打卡时间,hh24:mi:ss,可以为空,为空就是未打卡." )
private String offDutyTime = null;
public String getMorningOffdutyTime() { return morningOffdutyTime; }
public void setMorningOffdutyTime(String morningOffdutyTime) { this.morningOffdutyTime = morningOffdutyTime; }
public String getAfternoonOnDutyTime() { return afternoonOnDutyTime; }
public void setAfternoonOnDutyTime(String afternoonOnDutyTime) { this.afternoonOnDutyTime = afternoonOnDutyTime; }
public String getEmpName() {
return empName;
}
......
......@@ -349,12 +349,10 @@ public class AttendanceDetailAction extends StandardJaxrsAction {
}
/**
* 打卡信息接入 1-员工姓名 EmployeeName 2-员工号 EmployeeNo 3-日期 RecordDateString 4-签到时间
* OnDutyTime 5-签退时间 OffDutyTime
*
* 打卡信息接入
* @author liyi_
*/
@JaxrsMethodDescribe(value = "接入完成的上下班打卡信息记录,接入完成后直接分析", action = ActionReciveAttendance.class)
@JaxrsMethodDescribe(value = "接入完整的打卡信息记录,接入完成后直接分析", action = ActionReciveAttendance.class)
@Path("recive")
@POST
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......
......@@ -35,7 +35,7 @@ public class ActionDeleteByWfDocId extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
// 先判断需要操作的应用信息是否存在,根据ID进行一次查询,如果不存在不允许继续操作
ids = business.getAttendanceSelfHolidayFactory().getByWorkFlowDocId(wfDocId);
ids = business.getAttendanceSelfHolidayFactory().listIdsWithBatchFlag(wfDocId);
if ( ListTools.isNotEmpty( ids ) ) {
attendanceSelfHolidays = business.getAttendanceSelfHolidayFactory().list(ids);
if (attendanceSelfHolidays != null && attendanceSelfHolidays.size() > 0) {
......
......@@ -7,16 +7,26 @@ import com.x.attendance.entity.AttendanceSelfHoliday;
import com.x.attendance.entity.AttendanceStatisticalCycle;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.AbstractPersistenceProperties;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.organization.Person;
import com.x.base.core.project.organization.Unit;
import com.x.base.core.project.tools.ListTools;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.Column;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
......@@ -46,6 +56,7 @@ public class ActionSave extends BaseAction {
if( check ){
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
AttendanceSelfHoliday attendanceSelfHoliday = null;
if( wrapIn != null && StringUtils.isNoneEmpty( wrapIn.getEmployeeName() )
......@@ -54,6 +65,34 @@ public class ActionSave extends BaseAction {
&& wrapIn.getStartTime() != null
&& wrapIn.getEndTime() != null
){
if( wrapIn.getEmployeeName().indexOf("@P") < 0 ){
//不是DistinguishedName
if( wrapIn.getEmployeeName().indexOf("@I") > 0 ){
wrapIn.setEmployeeName(userManagerService.getPersonNameByIdentity(wrapIn.getEmployeeName()));
}else{
Person person = userManagerService.getPersonObjByName(wrapIn.getEmployeeName());
if( person != null ){
wrapIn.setEmployeeName( person.getDistinguishedName() );
}
}
}
//补充员工的组织信息
Unit unit = userManagerService.getUnitWithPersonName( wrapIn.getEmployeeNumber() );
Unit topUnit = null;
String unitName = null;
String unitOu = null;
String topUnitName = null;
String topUnitOu = null;
if( unit != null ){
unitName = unit.getName();
unitOu = unit.getDistinguishedName();
topUnit = userManagerService.getTopUnitWithUnitName(unitOu);
}
if( topUnit != null ){
topUnitName = topUnit.getName();
topUnitOu = topUnit.getDistinguishedName();
}
emc.beginTransaction( AttendanceSelfHoliday.class );
//先根据batchFlag删除原来的数据,然后再进行新数据的保存
if(StringUtils.isNotEmpty( wrapIn.getBatchFlag() ) ){
......@@ -67,7 +106,7 @@ public class ActionSave extends BaseAction {
}
}
if(StringUtils.isNotEmpty( wrapIn.getId() ) ){
if( StringUtils.isNotEmpty( wrapIn.getId() ) ){
//根据ID查询信息是否存在,如果存在就update,如果不存在就create
attendanceSelfHoliday = emc.find( wrapIn.getId(), AttendanceSelfHoliday.class );
if( attendanceSelfHoliday != null ){
......@@ -75,6 +114,12 @@ public class ActionSave extends BaseAction {
wrapIn.copyTo( attendanceSelfHoliday );
attendanceSelfHoliday.setBatchFlag(wrapIn.getBatchFlag());
logger.info("更新:gson.toJson( attendanceSelfHoliday ) = " + gson.toJson( attendanceSelfHoliday ) );
attendanceSelfHoliday.setUnitName( unitName );
attendanceSelfHoliday.setUnitOu( unitOu );
attendanceSelfHoliday.setTopUnitName( topUnitName );
attendanceSelfHoliday.setTopUnitOu( topUnitOu );
emc.check( attendanceSelfHoliday, CheckPersistType.all);
}else{
attendanceSelfHoliday = new AttendanceSelfHoliday();
......@@ -83,6 +128,12 @@ public class ActionSave extends BaseAction {
attendanceSelfHoliday.setId( wrapIn.getId() );
attendanceSelfHoliday.setBatchFlag(wrapIn.getBatchFlag());
logger.info("新增:gson.toJson( attendanceSelfHoliday ) = " + gson.toJson( attendanceSelfHoliday ) );
attendanceSelfHoliday.setUnitName( unitName );
attendanceSelfHoliday.setUnitOu( unitOu );
attendanceSelfHoliday.setTopUnitName( topUnitName );
attendanceSelfHoliday.setTopUnitOu( topUnitOu );
emc.persist( attendanceSelfHoliday, CheckPersistType.all);
}
}else{
......@@ -92,9 +143,16 @@ public class ActionSave extends BaseAction {
wrapIn.copyTo( attendanceSelfHoliday );
attendanceSelfHoliday.setBatchFlag(wrapIn.getBatchFlag());
logger.debug("新增,无ID:gson.toJson( attendanceSelfHoliday ) = " + gson.toJson( attendanceSelfHoliday ) );
attendanceSelfHoliday.setUnitName( unitName );
attendanceSelfHoliday.setUnitOu( unitOu );
attendanceSelfHoliday.setTopUnitName( topUnitName );
attendanceSelfHoliday.setTopUnitOu( topUnitOu );
emc.persist( attendanceSelfHoliday, CheckPersistType.all);
result.setData( new Wo( attendanceSelfHoliday.getId() ) );
}
emc.commit();
result.setData( new Wo( attendanceSelfHoliday.getId() ) );
......@@ -137,8 +195,86 @@ public class ActionSave extends BaseAction {
return result;
}
public static class Wi extends AttendanceSelfHoliday {
private static final long serialVersionUID = -5076990764713538973L;
public static class Wi {
@FieldDescribe("ID,如果ID已存在,则为更新")
private String id;
@FieldDescribe("员工姓名:员工的标识,<font color='red'>必填</font>,员工的distinguishedName,如:张三@zhangsan@P")
private String employeeName;
@FieldDescribe("员工号,如果没有员工号,可以使用员工标识代替,不可为空")
private String employeeNumber;
@FieldDescribe("请假类型:带薪年休假|带薪病假|带薪福利假|扣薪事假|其他")
private String leaveType;
@FieldDescribe("开始时间,<font color='red'>必填</font>: yyyy-mm-dd hh24:mi:ss")
private Date startTime;
@FieldDescribe("结束时间,<font color='red'>必填</font>: yyyy-mm-dd hh24:mi:ss")
private Date endTime;
@FieldDescribe("请假天数,<font color='red'>必填</font>")
private Double leaveDayNumber = 0.0;
@FieldDescribe("请假说明")
private String description;
// @FieldDescribe("流程WorkId")
// private String docId;
@FieldDescribe("录入批次标识:可以填写流程workId,jobId, CMS的文档ID,或者自定义信息,数据保存时会先根据batchFlag做删除,然后再保存新的数据")
private String batchFlag;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getEmployeeName() { return employeeName; }
public void setEmployeeName(String employeeName) { this.employeeName = employeeName; }
public String getEmployeeNumber() { return employeeNumber; }
public void setEmployeeNumber(String employeeNumber) { this.employeeNumber = employeeNumber; }
public String getLeaveType() { return leaveType; }
public void setLeaveType(String leaveType) { this.leaveType = leaveType; }
public Date getStartTime() { return startTime; }
public void setStartTime(Date startTime) { this.startTime = startTime; }
public Date getEndTime() { return endTime; }
public void setEndTime(Date endTime) { this.endTime = endTime; }
public Double getLeaveDayNumber() { return leaveDayNumber; }
public void setLeaveDayNumber(Double leaveDayNumber) { this.leaveDayNumber = leaveDayNumber; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public String getBatchFlag() { return batchFlag; }
public void setBatchFlag(String batchFlag) { this.batchFlag = batchFlag; }
public void copyTo(AttendanceSelfHoliday attendanceSelfHoliday) {
attendanceSelfHoliday.setBatchFlag( this.batchFlag );
attendanceSelfHoliday.setDescription( this.description );
// attendanceSelfHoliday.setDocId( this.batchFlag );
attendanceSelfHoliday.setEmployeeName( this.employeeName );
attendanceSelfHoliday.setEmployeeNumber( this.employeeNumber );
attendanceSelfHoliday.setStartTime( this.startTime );
attendanceSelfHoliday.setEndTime( this.endTime );
attendanceSelfHoliday.setLeaveDayNumber( this.leaveDayNumber );
attendanceSelfHoliday.setLeaveType( this.leaveType );
}
}
public static class Wo extends WoId {
......
......@@ -265,7 +265,7 @@ class AttendanceDetailAnalyseCoreService {
*/
static Date getOffDutyTimeFromDetail(AttendanceDetail detail, Boolean debugger) {
try {
if( StringUtils.isEmpty( detail.getOnDutyTime() ) ){
if( StringUtils.isEmpty( detail.getOffDutyTime() ) ){
logger.debug( debugger, "offDutyTime " );
}else{
logger.debug( debugger, "offDutyTime=" + detail.getRecordDateString() + " " + detail.getOffDutyTime() );
......
......@@ -58,6 +58,32 @@ public class UserManagerService {
}
return result;
}
public Unit getUnitWithPersonName( String personName ) throws Exception{
List<String> unitNames = null;
Business business = null;
Integer level = 0;
Unit result = null;
Unit unit = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
unitNames = business.organization().unit().listWithPerson( personName );
if( ListTools.isNotEmpty( unitNames ) ) {
for( String unitName : unitNames ) {
if( StringUtils.isNotEmpty( unitName ) && !"null".equals( unitName ) ) {
unit = business.organization().unit().getObject( unitName );
if( level < unit.getLevel() ) {
level = unit.getLevel();
result = unit;
}
}
}
}
} catch ( Exception e ) {
throw e;
}
return unit;
}
/**
* 根据身份名称获取组织名称
......@@ -100,7 +126,7 @@ public class UserManagerService {
/**
* 检查组织名称是否有效
* @param name
* @param unitName
* @return
* @throws Exception
*/
......@@ -213,7 +239,7 @@ public class UserManagerService {
/**
* 根据组织名称获取顶层组织名称(递归)
* @param organizationName
* @param unitName
* @return
* @throws Exception
*/
......@@ -246,6 +272,35 @@ public class UserManagerService {
}
}
public Unit getTopUnitWithUnitName( String unitName ) throws Exception{
Unit currentUnit = null;
Unit parentUnit = null;
String parentUnitName = null;
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
currentUnit = business.organization().unit().getObject( unitName );
if( currentUnit != null ) {
parentUnitName = currentUnit.getSuperior();
if( StringUtils.isNotEmpty( parentUnitName ) && !"0".equals( parentUnitName ) ) {
try {
parentUnit = business.organization().unit().getObject( parentUnitName );
}catch( NullPointerException e ) {
}
}
if( parentUnit == null ) {
return currentUnit;
}else {
return getTopUnitWithUnitName( parentUnit.getDistinguishedName() );
}
}else {
throw new Exception("unit is not exists:" + unitName);
}
} catch ( Exception e ) {
throw e;
}
}
/**
* 根据上级组织名称获取所有下级组织名称列表
* @param parentUnitName
......
......@@ -49,11 +49,11 @@ public class AttendanceSelfHoliday extends SliceJpaObject {
* =============================================================================
* =====
*/
public static final String docId_FIELDNAME = "docId";
@FieldDescribe("流程WorkId")
@Column( length = JpaObject.length_id, name = ColumnNamePrefix + docId_FIELDNAME )
@CheckPersist(allowEmpty = true)
private String docId;
// public static final String docId_FIELDNAME = "docId";
// @FieldDescribe("流程WorkId")
// @Column( length = JpaObject.length_id, name = ColumnNamePrefix + docId_FIELDNAME )
// @CheckPersist(allowEmpty = true)
// private String docId;
public static final String topUnitName_FIELDNAME = "topUnitName";
@FieldDescribe("顶层组织名称")
......@@ -80,14 +80,14 @@ public class AttendanceSelfHoliday extends SliceJpaObject {
private String unitOu;
public static final String employeeName_FIELDNAME = "employeeName";
@FieldDescribe("员工姓名")
@Column( length = JpaObject.length_96B, name = ColumnNamePrefix + employeeName_FIELDNAME )
@FieldDescribe("员工姓名:员工的标识,distinguishedName")
@Column( length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix + employeeName_FIELDNAME )
@CheckPersist(allowEmpty = false)
private String employeeName;
public static final String employeeNumber_FIELDNAME = "employeeNumber";
@FieldDescribe("员工号")
@Column( length = JpaObject.length_32B, name = ColumnNamePrefix + employeeNumber_FIELDNAME )
@FieldDescribe("员工号,如果没有员工号,可以使用员工标识代替,不可为空")
@Column( length = AbstractPersistenceProperties.organization_name_length, name = ColumnNamePrefix + employeeNumber_FIELDNAME )
@CheckPersist(allowEmpty = true)
private String employeeNumber;
......@@ -220,13 +220,13 @@ public class AttendanceSelfHoliday extends SliceJpaObject {
public void setDescription(String description) {
this.description = description;
}
public String getDocId() {
return docId;
}
public void setDocId(String docId) {
this.docId = docId;
}
//
// public String getDocId() {
// return docId;
// }
//
// public void setDocId(String docId) {
// this.docId = docId;
// }
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册