提交 471d1e04 编写于 作者: O o2null

Merge branch 'feature/attendance_0818' into 'wrdp'

考勤-优化打卡部门计算方法

See merge request o2oa/o2oa!4969
......@@ -158,4 +158,27 @@ public class AttendanceDetailMobileAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "预打卡,根据当前人以及对应的排班设置,给出打卡的预判断", action = ActionMobilePreview.class)
@Path("mobilepreview")
@GET
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void mobilePreview(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request ) {
ActionResult<ActionMobilePreview.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
Boolean check = true;
if (check) {
try {
result = new ActionMobilePreview().execute( request, effectivePerson );
} catch (Exception e) {
result = new ActionResult<>();
Exception exception = new ExceptionAttendanceDetailProcess(e, "查询登录者当天的所有移动打卡信息记录时发生异常!");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ package com.x.attendance.assemble.control.service;
import java.util.List;
import com.x.attendance.entity.AttendanceDetail;
import com.x.attendance.entity.AttendanceEmployeeConfig;
import com.x.base.core.project.tools.ListTools;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.Business;
......@@ -18,7 +20,8 @@ import com.x.base.core.project.logger.LoggerFactory;
public class AttendanceScheduleSettingService {
private static Logger logger = LoggerFactory.getLogger( AttendanceScheduleSettingService.class );
private AttendanceEmployeeConfigServiceAdv attendanceEmployeeConfigServiceAdv = new AttendanceEmployeeConfigServiceAdv();
private String topUnit = "";
public List<AttendanceScheduleSetting> listAll( EntityManagerContainer emc ) throws Exception {
Business business = new Business( emc );
return business.getAttendanceScheduleSettingFactory().listAll();
......@@ -77,12 +80,21 @@ public class AttendanceScheduleSettingService {
}
public AttendanceScheduleSetting getAttendanceScheduleSettingWithPerson( String personName, Boolean debugger ) throws Exception {
topUnit = "";
UserManagerService userManagerService = new UserManagerService();
String unitName = userManagerService.getUnitNameWithPersonName( personName );
//先根据考勤人员配置去计算组织及顶级组织,如果没有符合条件的再按personName的人员组织计算
//String unitName = userManagerService.getUnitNameWithPersonName( personName );
String unitName = this.getUnitByconfig(userManagerService,personName);
if(StringUtils.isEmpty(unitName)){
unitName = userManagerService.getUnitNameWithPersonName( personName );
}
AttendanceScheduleSetting attendanceScheduleSetting = getAttendanceScheduleSettingWithUnitName( unitName );
if( attendanceScheduleSetting == null ) {
//如果没有找到,那么应该为该人员所属的组织创建一个新的排班配置
String topUnitName = userManagerService.getTopUnitNameWithUnitName( unitName );
String topUnitName = topUnit;
if(StringUtils.isEmpty(topUnit)){
topUnitName = userManagerService.getTopUnitNameWithUnitName( unitName );
}
attendanceScheduleSetting = createNewScheduleSetting( unitName, topUnitName, debugger );
}
return attendanceScheduleSetting;
......@@ -154,4 +166,23 @@ public class AttendanceScheduleSettingService {
}
return new_attendanceScheduleSetting;
}
private String getUnitByconfig(UserManagerService userManagerService,String personName) throws Exception {
String result = "";
List<AttendanceEmployeeConfig> attendanceEmployeeConfigList = attendanceEmployeeConfigServiceAdv.listByConfigType( "REQUIRED" );
if( ListTools.isNotEmpty( attendanceEmployeeConfigList ) ) {
for(AttendanceEmployeeConfig attendanceEmployeeConfig : attendanceEmployeeConfigList){
if(StringUtils.isNotEmpty(attendanceEmployeeConfig.getEmployeeName())){
if(StringUtils.equals(personName,attendanceEmployeeConfig.getEmployeeName())){
result = attendanceEmployeeConfig.getUnitName();
}
}else if(StringUtils.isNotEmpty(attendanceEmployeeConfig.getUnitName())){
if(userManagerService.checkHasPerson(personName,attendanceEmployeeConfig.getUnitName(),true)){
result = attendanceEmployeeConfig.getUnitName();
topUnit = attendanceEmployeeConfig.getTopUnitName();
}
}
}
}
return result;
}
}
......@@ -10,6 +10,7 @@ import com.x.base.core.project.organization.Identity;
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.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
......@@ -442,6 +443,23 @@ public class UserManagerService {
}
}
public Boolean checkHasPerson(String personName,String unitName,Boolean recursive) throws Exception {
if (personName == null || personName.isEmpty()) {
throw new Exception("personName is null!");
}
if (unitName == null || unitName.isEmpty()) {
throw new Exception("unitName is null!");
}
if (recursive ==null) {
throw new Exception("recursive is null!");
}
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
return business.organization().unit().checkHasPerson(personName,unitName,recursive);
}
}
public List<String> listUnitNamesWithPerson(String personName) throws Exception {
if (personName == null || personName.isEmpty()) {
throw new Exception("personName is null!");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册