|
|
@@ -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 {
|