Commit 988c9f4b authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	attendance-performance-manager/src/main/java/com/mortals/xhx/common/key/RedisKey.java
parents 30d24015 b11e3029
......@@ -2,14 +2,13 @@ package com.mortals.xhx.base.framework.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.AESUtil;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.key.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
......@@ -20,9 +19,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import static com.mortals.xhx.common.key.ErrorCode.*;
import static com.mortals.xhx.common.key.ErrorCode.ERROR_USER_OPERATION_CONTENT;
/**
* 用户权限验证,基于token
*
......@@ -44,8 +40,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
JSONObject ret = new JSONObject();
if(handler instanceof HandlerMethod){
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
......@@ -53,9 +48,10 @@ public class AuthUserInterceptor extends BaseInterceptor {
//取消校验
return true;
}
}else if(handler instanceof ResourceHttpRequestHandler){
} else if (handler instanceof ResourceHttpRequestHandler) {
return true;
}
JSONObject ret = new JSONObject();
try {
String uri = request.getServletPath();
//校验配置的请求路径是否需要检查权限
......@@ -63,23 +59,23 @@ public class AuthUserInterceptor extends BaseInterceptor {
//需要校验权限
boolean auth = this.checkAuth(request, uri, config.getSecurityKey());
if (!auth) {
//校验token不正常
String token = authTokenService.getToken(request);
if(ObjectUtils.isEmpty(token)){
ServletUtils.renderString(response, JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_UNAUTHORIZED, ERROR_TOKEN_UNAUTHORIZED_CONTENT)));
return false;
}
//不存在时候 如果是管理员也不做拦截
IUser loginUser = authTokenService.getLoginUser(request);
if (ObjectUtils.isEmpty(loginUser)) {
ServletUtils.renderString(response, JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_EXPIRED, ERROR_TOKEN_EXPIRED_CONTENT)));
//loginUser.isManager()
if(ObjectUtils.isEmpty(loginUser)){
ret.put("code", 401);
ret.put("msg", "用户未登录或登录失效,请重新登录");
ServletUtils.renderString(response, JSONObject.toJSONString(ret));
return false;
} else if (loginUser.isAdmin() || loginUser.getUserType() == 1) {
}else if(loginUser.isAdmin()||loginUser.getUserType()==1){
return super.preHandle(request, response, handler);
} else {
ServletUtils.renderString(response, JSONObject.toJSONString(Rest.fail(ERROR_USER_OPERATION, ERROR_USER_OPERATION_CONTENT)));
ret.put("code", -1);
ret.put("msg", "用户无该操作权限!");
ServletUtils.renderString(response, JSONObject.toJSONString(ret));
return false;
}
}
}
} catch (Exception e) {
......@@ -106,4 +102,6 @@ public class AuthUserInterceptor extends BaseInterceptor {
return false;
}
}
......@@ -15,7 +15,6 @@ import com.mortals.xhx.base.system.resource.dao.ResourceDao;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.model.ResourceQuery;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import org.springframework.stereotype.Service;
import java.util.HashSet;
......
package com.mortals.xhx.base.system.resource.web;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType;
import java.util.HashMap;
import java.util.Map;
/**
* 资源信息
......@@ -36,7 +30,6 @@ import com.mortals.xhx.common.code.SourceType;
public class ResourceController extends BaseCRUDJsonBodyMappingController<ResourceService,ResourceEntity,Long> {
public ResourceController(){
super.setFormClass(ResourceForm.class);
super.setModuleDesc("资源信息");
}
......@@ -45,14 +38,11 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour
Map<String, Object> statsus = new HashMap<String, Object>();
statsus.put("authType", AuthType.getEnumMap());
statsus.put("sourceType", SourceType.getEnumMap());
if(!ObjectUtils.isEmpty(context.getUser())){
if (context.getUser().isAdmin()) {
statsus.put("userType", IBaseEnum.getEnumMap(UserType.class));
} else {
statsus.put("userType", UserType.findByValue(getCurUser().getUserType()));
}
if (getCurUser().isAdmin()) {
statsus.put("userType", IBaseEnum.getEnumMap(UserType.class));
} else {
statsus.put("userType", UserType.findByValue(getCurUser().getUserType()));
}
model.put(KEY_RESULT_DICT, statsus);
}
......
/**
* 文件:ResourceForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.resource.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.model.ResourceQuery;
/**
* <p>Title: 资源信息</p>
* <p>Description: ResourceForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class ResourceForm extends BaseCRUDFormLong<ResourceEntity> {
private ResourceEntity entity = new ResourceEntity();
private ResourceQuery query = new ResourceQuery();
public ResourceForm(){
}
@Override
public ResourceEntity getEntity() {
return entity;
}
public void setEntity(ResourceEntity entity) {
this.entity = entity;
}
@Override
public ResourceQuery getQuery() {
return query;
}
public void setQuery(ResourceQuery query) {
this.query = query;
}
}
\ No newline at end of file
/**
* 文件:RoleAuthServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
* 文件:RoleAuthServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.service.impl;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.dao.RoleAuthDao;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import com.mortals.xhx.common.key.RedisKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @author
* @version 1.0.0
*/
@Service("roleAuthService")
public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao,RoleAuthEntity,Long> implements RoleAuthService {
public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, RoleAuthEntity, Long> implements RoleAuthService {
@Autowired
private ICacheService cacheService;
@Autowired
private ResourceService resourceService;
@Override
public void doDistributionSource(RoleAuthQuery query) {
......@@ -49,6 +56,18 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao,Rol
list.add(entity);
}
this.dao.insertBatch(list);
this.updateUserMenuUrlCache();
}
private void updateUserMenuUrlCache() {
//更新用户菜单
Set<String> hkeys = cacheService.hkeys(RedisKey.KEY_USER_MENU_CACHE);
for (String userId : hkeys) {
Set<String> urls = resourceService.findUrlSetByUserId(DataUtil.converStr2Long(userId, 0L));
String menuUrlCode = generateMenuUrlCode(urls);
cacheService.hset(RedisKey.KEY_USER_MENU_CACHE, userId, menuUrlCode);
}
}
}
\ No newline at end of file
/**
* 文件:RoleServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
* 文件:RoleServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.service.impl;
......@@ -15,7 +15,6 @@ import com.mortals.xhx.base.system.role.dao.RoleDao;
import com.mortals.xhx.base.system.role.model.*;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -27,7 +26,7 @@ import java.util.Arrays;
* <p>Description: RoleServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @author
* @version 1.0.0
*/
@Service("roleService")
......@@ -56,5 +55,5 @@ public class RoleServiceImpl extends AbstractCRUDServiceImpl<RoleDao,RoleEntity,
}).count();
super.removeAfter(ids, context, result);
}
}
\ No newline at end of file
......@@ -8,18 +8,24 @@
package com.mortals.xhx.base.system.role.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.dao.RoleUserDao;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.common.key.RedisKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
/**
* <p>Title: 角色用户</p>
......@@ -33,6 +39,12 @@ import java.util.Map;
public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,RoleUserEntity,Long> implements RoleUserService {
@Autowired
private ICacheService cacheService;
@Autowired
private ResourceService resourceService;
@Override
public void doDistributionUser(RoleUserQuery query) {
Long roleId = query.getRoleId();
......@@ -50,6 +62,14 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,Rol
list.add(rolseUser);
}
this.dao.insertBatch(list);
updateUserMenuUrlCache();
}
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
updateUserMenuUrlCache();
}
@Override
......@@ -68,6 +88,19 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,Rol
list.add(rolseUser);
}
this.dao.insertBatch(list);
updateUserMenuUrlCache();
}
private void updateUserMenuUrlCache() {
//更新用户菜单
Set<String> hkeys = cacheService.hkeys(RedisKey.KEY_USER_MENU_CACHE);
for (String userId : hkeys) {
Set<String> urls = resourceService.findUrlSetByUserId(DataUtil.converStr2Long(userId, 0L));
String menuUrlCode = generateMenuUrlCode(urls);
cacheService.hset(RedisKey.KEY_USER_MENU_CACHE, userId, menuUrlCode);
}
}
@Override
......
......@@ -3,20 +3,15 @@ package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 角色资源权限
*
......@@ -29,7 +24,6 @@ import javax.servlet.http.HttpServletResponse;
public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAuthService, RoleAuthEntity, Long> {
public RoleAuthController() {
super.setFormClass(RoleAuthForm.class);
super.setModuleDesc("角色资源权限");
}
......
/**
* 文件:RoleAuthForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleAuthForm extends BaseCRUDFormLong<RoleAuthEntity> {
private RoleAuthEntity entity = new RoleAuthEntity();
private RoleAuthQuery query = new RoleAuthQuery();
public RoleAuthForm(){
}
@Override
public RoleAuthEntity getEntity() {
return entity;
}
public void setEntity(RoleAuthEntity entity) {
this.entity = entity;
}
@Override
public RoleAuthQuery getQuery() {
return query;
}
public void setQuery(RoleAuthQuery query) {
this.query = query;
}
}
\ No newline at end of file
......@@ -5,21 +5,18 @@ import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.framework.web.BasePhpCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.common.code.RoleType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -39,7 +36,6 @@ public class RoleController extends BaseCRUDJsonBodyMappingController<RoleServic
private RoleUserService roleUserService;
public RoleController(){
super.setFormClass(RoleForm.class);
super.setModuleDesc("角色信息");
}
......
/**
* 文件:RoleForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleQuery;
/**
* <p>Title: 角色信息</p>
* <p>Description: RoleForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleForm extends BaseCRUDFormLong<RoleEntity> {
private RoleEntity entity = new RoleEntity();
private RoleQuery query = new RoleQuery();
/** 用户ID */
private Long userId;
public RoleForm(){
}
@Override
public RoleEntity getEntity() {
return entity;
}
public void setEntity(RoleEntity entity) {
this.entity = entity;
}
@Override
public RoleQuery getQuery() {
return query;
}
public void setQuery(RoleQuery query) {
this.query = query;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
}
\ No newline at end of file
......@@ -7,26 +7,22 @@ import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -49,7 +45,6 @@ public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUs
private UserService userService;
public RoleUserController() {
super.setFormClass(RoleUserForm.class);
super.setModuleDesc("角色用户");
}
......
/**
* 文件:RoleUserForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
/**
* <p>Title: 角色用户</p>
* <p>Description: RoleUserForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleUserForm extends BaseCRUDFormLong<RoleUserEntity> {
private RoleUserEntity entity = new RoleUserEntity();
private RoleUserQuery query = new RoleUserQuery();
public RoleUserForm(){
}
@Override
public RoleUserEntity getEntity() {
return entity;
}
public void setEntity(RoleUserEntity entity) {
this.entity = entity;
}
@Override
public RoleUserQuery getQuery() {
return query;
}
public void setQuery(RoleUserQuery query) {
this.query = query;
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ public class UserVo extends BaseEntityLong {
*/
private String siteName;
private String roleIds;
private List<Long> roleIds;
/**
* 唯一标识
*/
......
......@@ -10,7 +10,7 @@ package com.mortals.xhx.base.system.user.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDService;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.menu.model.MenuEntity;
import com.mortals.xhx.base.system.user.dao.UserDao;
......@@ -28,7 +28,7 @@ import java.util.Set;
* @version 1.0.0
*/
public interface UserService extends ICRUDService<UserEntity,Long> {
public interface UserService extends ICRUDCacheService<UserEntity,Long> {
/**
* 用户登录
*
......@@ -38,7 +38,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @return
* @throws AppException
*/
UserEntity doLogin(String loginName, String password, String loginIp) throws AppException;
public UserEntity doLogin(String loginName, String password, String loginIp) throws AppException;
/**
* 校验用户名与密码是否正确
......@@ -48,7 +48,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @return
* @throws AppException
*/
UserEntity doCheckUser(String loginName, String password) throws AppException;
public UserEntity doCheckUser(String loginName, String password) throws AppException;
/**
* 检查用户是否存在
......@@ -57,7 +57,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @param userId 密码
* @return
*/
boolean existUser(String loginName, Long userId) throws AppException;
public boolean existUser(String loginName, Long userId) throws AppException;
/**
* 通过登录用户获取菜单功能权限
......@@ -65,7 +65,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @param user
* @return
*/
List<MenuEntity> findOutlookBarList(IUser user);
public List<MenuEntity> findOutlookBarList(IUser user);
/**
* 查询用户所有有权限的菜单ID
......@@ -73,7 +73,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @param userEntity
* @return
*/
Set<Long> findAllAuthIds(UserEntity userEntity) throws AppException;
public Set<Long> findAllAuthIds(UserEntity userEntity) throws AppException;
/**
* 查询用户记录
......@@ -85,7 +85,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @return
* @throws AppException
*/
Result<UserEntity> find(Long platformId, UserEntity params, int currPage, int prePageResult) throws AppException;
public Result<UserEntity> find(Long platformId, UserEntity params, int currPage, int prePageResult) throws AppException;
/**
* 为客户创建用户
......@@ -100,7 +100,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @return
* @throws AppException
*/
UserEntity createUser(IUser currUser, Long customerId, String customerName, String loginName, String password,
public UserEntity createUser(IUser currUser, Long customerId, String customerName, String loginName, String password,
String userName, String mobile) throws AppException;
/**
......@@ -112,12 +112,9 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
* @return
* @throws AppException
*/
boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
UserDao getUserDao();
void doHandlerUser(UserEntity entity);
UserDao getUserDao();
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -54,7 +55,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
private DeptService deptService;
public UserController() {
super.setFormClass(UserForm.class);
super.setModuleDesc("用户信息");
}
......@@ -82,7 +82,7 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
protected int editAfter(Long id, Map<String, Object> model, UserEntity entity, Context context) throws AppException {
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(entity.getId());
String roleIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(","));
List<Long> roleIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getRoleId).collect(Collectors.toList());
entity.setRoleIds(roleIds);
return super.editAfter(id, model, entity, context);
}
......
/**
* 文件:UserForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.user.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
/**
* <p>Title: 用户信息</p>
* <p>Description: UserForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class UserForm extends BaseCRUDFormLong<UserEntity> {
private UserEntity entity = new UserEntity();
private UserQuery query = new UserQuery();
public UserForm(){
}
@Override
public UserEntity getEntity() {
return entity;
}
public void setEntity(UserEntity entity) {
this.entity = entity;
}
@Override
public UserQuery getQuery() {
return query;
}
public void setQuery(UserQuery query) {
this.query = query;
}
}
\ No newline at end of file
......@@ -12,7 +12,8 @@ public enum AppealResultEnum {
审核中(0, "审核中"),
通过(1, "通过"),
不通过(2, "不通过"),
撤销审批中(3, "撤销审批中");
撤销审批中(3, "撤销审批中"),
撤销审批通过(4, "撤销审批通过");
private Integer value;
private String desc;
......
......@@ -21,7 +21,4 @@ public class RedisKey {
*/
public static final String KEY_ATTENC_TOTOAL_CACHE = "attend:total";
/** 考勤统计 **/
public static final String KEY_ATTENDANCE_STAT_CACHE = "attendance:stat";
}
package com.mortals.xhx.common.utils;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.util.AESUtil;
import lombok.extern.slf4j.Slf4j;
import java.util.Set;
@Slf4j
public class MenuEncodeUtil {
public static String generateMenuUrlCode(Set<String> urls) {
try {
String securityKey = GlobalSysInfo.getPropertyValue(SysConstains.PROP_COOKIE_SECURITY_KEY);
StringBuilder sb = new StringBuilder();
if (urls != null && urls.size() > 0) {
for (String url : urls) {
int index = url.hashCode() & (Integer.MAX_VALUE - 1);
sb.append(index).append(",");
}
}
String menuUrl = sb.toString();
return AESUtil.encrypt(menuUrl, securityKey);
} catch (Throwable e) {
log.error("编码异常",e);
return null;
}
}
}
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.SourceType;
import com.mortals.xhx.common.code.StaffSatusEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupStaffService;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo;
import com.mortals.xhx.module.hik.door.service.IHikDoorService;
import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -47,6 +40,8 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService {
private AttendanceGroupStaffService attendanceGroupStaffService;
@Autowired
private AttendanceGroupFixedworkService groupFixedworkService;
@Autowired
private HolidayService holidayService;
@Override
......@@ -67,22 +62,34 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService {
String week = this.getWeek(new Date());
Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week);
//weekClassId为-1 则不在考勤
//对于节假日 分两种情况。
// 1.当前是工作日,但是是节假日。则不做考勤continue;
// 2.当前是非工作日,但是由于节假日情况,需要补班,需要做考勤
//weekClassId == -1L 当日不需要考勤的 与节假日冲突的 以节假日为准
Boolean checkWorkByHoliday = checkWorkByHoliday();
Boolean checkHolidayByWorkDay = checkHolidayByWorkDay();
if (weekClassId == -1L) {
//跳过本次循环
log.info("当前日期不在考勤时间范围内,不做处理!");
continue;
if (!checkWorkByHoliday) {
continue;
}
} else {
if (checkHolidayByWorkDay) {
//本来当天是需要考勤的,但是是节假日,则不计算考勤
continue;
}
}
List<AttendanceGroupStaffEntity> groupStaffList = item.getValue();
//查看当前需要考勤但是没有记录的人
List<Long> unAttendStaffIdList = groupStaffList.stream().filter(f -> !attendStaffSet.contains(f.getStaffId())).map(i -> i.getStaffId()).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(unAttendStaffIdList)) {
for (Long staffId : unAttendStaffIdList) {
StaffEntity staffCache = staffService.getCache(staffId.toString());
if (!ObjectUtils.isEmpty(staffCache)) {
if (!ObjectUtils.isEmpty(staffCache) && StaffSatusEnum.离职.getValue() != staffCache.getStatus()) {
//构建考勤记录 判断当前人是否离职,如果非离职 构建记录
//构建考勤记录
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue();
recordHikEntity.setStaffId(staffCache.getId());
......@@ -114,6 +121,39 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService {
calculateAttendByDay();
}
private Boolean checkWorkByHoliday() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
private Boolean checkHolidayByWorkDay() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
}
private void calculateAttendByDay() {
Context context = new Context();
UserEntity userEntity = new UserEntity();
......
......@@ -51,7 +51,6 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService {
@Override
public void excuteTask(ITask task) throws AppException {
// syncDoorEvents();
//判断时间段 不在时间段的 不做计算
//早上9点 子晚上8点 计算
Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 09:00:00");
......
......@@ -65,7 +65,6 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
} else {
day = 0;
}
Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 08:00:00");
Date endDateTime=DateUtil.parseDateTime(DateUtil.today()+" 20:30:00");
......@@ -73,28 +72,6 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
if(in){
syncDoorEvents();
}
//calculateAttendByDay();
}
private void calculateAttendByDay() {
Context context = new Context();
UserEntity userEntity = new UserEntity();
userEntity.setCreateUserId(1L);
userEntity.setId(1L);
userEntity.setCreateUserName("admin");
userEntity.setCreateTime(new Date());
context.setUser(userEntity);
AttendanceRecordHikQuery recordHikEntity = new AttendanceRecordHikQuery();
// Date todayStart = DateUtil.offsetHour(new Date(), -5).toJdkDate();
// recordHikEntity.setAttendanceDateStart(DateUtils.getCurrStrDate());
recordHikEntity.setAttendanceDateStart(DateUtil.today());
recordHikEntity.setAttendanceDateEnd(DateUtil.today());
try {
recordHikService.addAttendanceRecordByQuery(recordHikEntity, context);
} catch (Exception e) {
log.error("计算考勤异常", e);
}
}
private void syncDoorEvents() {
......
......@@ -65,162 +65,12 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
log.info("同步用户");
staffService.syncPersons(null);
// syncPersons();
} catch (Exception e) {
log.error("同步人事异常", e);
}
}
private void syncPersons() {
PersonReq personReq = new PersonReq();
personReq.setPageNo(1);
personReq.setPageSize(1000);
Rest<PersonDataInfo> personRest = hikPersonService.getPersonList(personReq);
if (personRest.getCode() == YesNoEnum.YES.getValue()) {
List<PersonInfo> personInfoList = personRest.getData().getList();
//做差集 更新本地用户为离职员工
StaffQuery staffQuery = new StaffQuery();
staffQuery.setSource(1);
staffQuery.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
Map<String, StaffEntity> staffCollect = staffService.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
for (PersonInfo personInfo : personInfoList) {
if (ObjectUtils.isEmpty(personInfo.getJobNo())) {
log.info("jobNo is null ==>{}", JSON.toJSONString(personInfo));
continue;
}
if (staffCollect.containsKey(personInfo.getJobNo())) {
staffCollect.remove(personInfo.getJobNo());
}
StaffEntity staffEntity = staffService.getExtCache(StrUtil.padPre(personInfo.getJobNo(), 8, "0"));
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(personInfo.getOrgIndexCode()));
//判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) {
//新增员工信息
staffEntity = new StaffEntity();
staffEntity.initAttrValue();
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(personInfo.getPersonName());
staffEntity.setRemarkId(personInfo.getPersonId());
staffEntity.setPicUri(personInfo.getPersonPhoto().getPicUri());
staffEntity.setServerIndexCode(personInfo.getPersonPhoto().getServerIndexCode());
staffEntity.setDeptName(personInfo.getOrgName());
staffEntity.setGender(personInfo.getGender());
staffEntity.setWorkNum(personInfo.getJobNo());
staffEntity.setPhoneNumber(personInfo.getPhoneNo());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
staffService.save(staffEntity);
AttendanceVacationBalanceEntity balanceEntity = new AttendanceVacationBalanceEntity();
balanceEntity.initAttrValue();
balanceEntity.setStaffId(staffEntity.getId());
balanceEntity.setStaffName(staffEntity.getName());
balanceEntity.setDeptId(staffEntity.getDeptId());
balanceEntity.setDeptName(staffEntity.getDeptName());
balanceEntity.setCreateUserId(1L);
balanceEntity.setCreateTime(new Date());
balanceService.save(balanceEntity);
//AttendanceVacationBalanceEntity balanceEntity = balanceService.selectOne(new AttendanceVacationBalanceQuery().staffId(staffEntity.getId()));
AttendanceStatEntity attendanceStatEntity = new AttendanceStatEntity();
attendanceStatEntity.initAttrValue();
attendanceStatEntity.setStaffId(staffEntity.getId());
attendanceStatEntity.setStaffName(staffEntity.getName());
attendanceStatEntity.setDeptId(staffEntity.getDeptId());
attendanceStatEntity.setDeptName(staffEntity.getDeptName());
attendanceStatEntity.setCreateUserId(1L);
attendanceStatEntity.setCreateTime(new Date());
//21假
attendanceStatEntity.setBackToUnit(balanceEntity.getBackToUnit());
attendanceStatEntity.setOnDutyLeave(balanceEntity.getOnDutyLeave());
attendanceStatEntity.setOutOfOffice(balanceEntity.getOutOfOffice());
attendanceStatEntity.setShiftCompensation(balanceEntity.getShiftCompensation());
attendanceStatEntity.setPhysicalExamination(balanceEntity.getPhysicalExamination());
attendanceStatEntity.setQuarantine(balanceEntity.getQuarantine());
attendanceStatEntity.setBusinessTrip(balanceEntity.getBusinessTrip());
attendanceStatEntity.setPublicHoliday(balanceEntity.getPublicHoliday());
attendanceStatEntity.setSickLeave(balanceEntity.getSickLeaveDays());
attendanceStatEntity.setFuneralLeave(balanceEntity.getBereavementLeaveDays());
attendanceStatEntity.setMarriageLeave(balanceEntity.getMarriageLeaveDays());
attendanceStatEntity.setChildRearingLeave(balanceEntity.getChildRearingLeave());
attendanceStatEntity.setBreastfeedingLeaveDays(balanceEntity.getBreastfeedingLeaveDays());
attendanceStatEntity.setMenstrualLeaveDays(balanceEntity.getMenstrualLeaveDays());
attendanceStatEntity.setAnnualLeaveDays(balanceEntity.getAnnualLeaveDays());
attendanceStatEntity.setCompensatedLeaveDays(balanceEntity.getCompensatedLeaveDays());
attendanceStatEntity.setPaternityLeaveDays(balanceEntity.getPaternityLeaveDays());
attendanceStatEntity.setMaternityLeave(balanceEntity.getMaternityLeaveDays());
attendanceStatEntity.setTransferBack(balanceEntity.getTransferBack());
attendanceStatEntity.setHomeLeave(balanceEntity.getHomeLeave());
attendanceStatEntity.setPersonalLeave(balanceEntity.getPersonalLeaveDays());
attendanceStatService.save(attendanceStatEntity);
} else {
//更新
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(personInfo.getPersonName());
staffEntity.setRemarkId(personInfo.getPersonId());
staffEntity.setPicUri(personInfo.getPersonPhoto().getPicUri());
staffEntity.setServerIndexCode(personInfo.getPersonPhoto().getServerIndexCode());
staffEntity.setDeptName(personInfo.getOrgName());
staffEntity.setGender(personInfo.getGender());
staffEntity.setWorkNum(personInfo.getJobNo());
staffEntity.setPhoneNumber(personInfo.getPhoneNo());
staffEntity.setUpdateUserId(1L);
staffEntity.setUpdateTime(new Date());
staffService.update(staffEntity);
}
}
if (staffCollect.size() > 0) {
//需要将此人员变更为离职
staffCollect.entrySet().stream().forEach(item -> {
StaffEntity staffEntity = item.getValue();
staffEntity.setStatus(StaffSatusEnum.离职.getValue());
staffEntity.setUpdateTime(new Date());
staffEntity.setUpdateUserId(1L);
staffService.update(staffEntity);
//新增离职人员
StaffLeaveEntity staffLeaveEntity = new StaffLeaveEntity();
staffLeaveEntity.initAttrValue();
staffLeaveEntity.setStaffId(staffEntity.getId());
staffLeaveEntity.setStaffName(staffEntity.getName());
staffLeaveEntity.setGender(staffEntity.getGender());
staffLeaveEntity.setBirthday(staffEntity.getBirthday());
staffLeaveEntity.setPhotoPath(staffEntity.getPhotoPath());
staffLeaveEntity.setPhoneNumber(staffEntity.getPhoneNumber());
staffLeaveEntity.setIdCard(staffEntity.getIdCard());
staffLeaveEntity.setWorkNum(staffEntity.getWorkNum());
staffLeaveEntity.setPoliticalstatus(staffEntity.getPoliticalstatus());
staffLeaveEntity.setDeptId(staffEntity.getDeptId());
staffLeaveEntity.setDeptName(staffEntity.getDeptName());
staffLeaveEntity.setJobId(staffEntity.getPositionId());
staffLeaveEntity.setJobName(staffEntity.getPositionName());
staffLeaveEntity.setStaffType(staffEntity.getStaffType());
staffLeaveEntity.setStatus(StaffSatusEnum.离职.getValue());
staffLeaveEntity.setLeaveDate(new Date());
staffLeaveEntity.setLeaveReason("");
staffLeaveEntity.setAuditStatus(AuditStatusEnum.通过.getValue());
staffLeaveEntity.setCreateUserId(1L);
staffLeaveEntity.setCreateTime(new Date());
staffLeaveService.save(staffLeaveEntity);
});
}
}
}
private void syncDepts() {
//部门同步
OrgListReq orgListReq = new OrgListReq();
......
......@@ -291,14 +291,16 @@ public class DingMessageController {
if(result.getResult().compareToIgnoreCase("AGREE") == 0){
// if(result.getTasks().size() > 1){
// if(result.getTasks().get(1).getStatus().compareToIgnoreCase("CANCELED") == 0){
// leaveRecordEntity.setAuditResult(4); //撤销审批完成
// }else {
// leaveRecordEntity.setAuditResult(1);
// }
// }
leaveRecordEntity.setAuditResult(AppealResultEnum.通过.getValue());
//10/19增加撤销审批状态
if(result.getTasks().size() > 1){
if((result.getTasks().get(1).getStatus().compareToIgnoreCase("CANCELED") == 0) ||
result.getBizAction().compareToIgnoreCase("REVOKE") == 0){
leaveRecordEntity.setAuditResult(4); //撤销审批完成
leaveRecordEntity.setAuditResult(AppealResultEnum.撤销审批通过.getValue());
}
}
}
else if(result.equals("")){ //撤销假期审批中result会为空 撤销审批通过后result为AGREE
if(result.getTasks().size() > 1){
......
......@@ -102,7 +102,7 @@ public class AttendanceLeaveRecordEntity extends AttendanceLeaveRecordVo {
/**
* 审核结果(1.申请通过,2.申请不通过)
*/
@Excel(name = "审核结果", readConverterExp = "1=申请通过,2=申请不通过")
@Excel(name = "审核结果", readConverterExp = "1=申请通过,2=申请不通过,3=撤销审批中,4=撤销审批通过")
private Integer auditResult;
/**
* 审核说明
......
......@@ -4,10 +4,14 @@ import cn.hutool.core.date.DateUtil;
import com.mortals.xhx.common.code.GoWorkResultEnum;
import com.mortals.xhx.common.code.MustEnum;
import com.mortals.xhx.common.code.TypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.AttendanceClassService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkSpecialService;
import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
......@@ -33,13 +37,15 @@ public class FixWorkAttendance extends AttendanceWorkAbstract {
private AttendanceGroupFixedworkSpecialService specialService;
private HolidayService holidayService;
public FixWorkAttendance(int type) {
super(type);
this.attendanceGroupFixedworkService = SpringUtils.getBean(AttendanceGroupFixedworkService.class);
this.attendanceClassService = SpringUtils.getBean(AttendanceClassService.class);
this.specialService = SpringUtils.getBean(AttendanceGroupFixedworkSpecialService.class);
this.holidayService = SpringUtils.getBean(HolidayService.class);
}
@Override
......@@ -68,11 +74,27 @@ public class FixWorkAttendance extends AttendanceWorkAbstract {
Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week);
//log.info("weekClassId:{}", weekClassId);
//weekClassId为-1 则不在考勤
Boolean checkWorkByHoliday = checkWorkByHoliday();
Boolean checkHolidayByWorkDay = checkHolidayByWorkDay();
if (weekClassId == -1L) {
//跳过本次循环
return;
log.info("当前日期不在考勤时间范围内,不做处理!");
if (!checkWorkByHoliday) {
return;
}
} else {
if (checkHolidayByWorkDay) {
//本来当天是需要考勤的,但是是节假日,则不计算考勤
return;
}
}
/* if (weekClassId == -1L) {
//跳过本次循环
return;
}*/
//特殊日期考勤配置
List<AttendanceGroupFixedworkSpecialEntity> specialEntities = specialService.find(new AttendanceGroupFixedworkSpecialQuery().fixedWorkId(attendanceGroupFixedworkEntity.getId()));
......@@ -218,7 +240,37 @@ public class FixWorkAttendance extends AttendanceWorkAbstract {
}
}
}
}
private Boolean checkWorkByHoliday() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
private Boolean checkHolidayByWorkDay() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
}
}
......@@ -16,10 +16,7 @@ import com.mortals.framework.utils.poi.ExcelUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.GoWorkResultEnum;
import com.mortals.xhx.common.code.NormalEnum;
import com.mortals.xhx.common.code.OffWorkResultEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.model.vo.AttendStatInfo;
......
......@@ -242,9 +242,12 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
if (count == 0) {
staffLeaveService.save(staffLeaveEntity);
}
//考勤人员中有离职的 删除
Long[] groudStaffIds = attendanceGroupStaffService.find(new AttendanceGroupStaffQuery().staffId(staff.getId())).stream().toArray(Long[]::new);
// List<AttendanceGroupStaffEntity> attendanceGroupStaffEntities = attendanceGroupStaffService.find(new AttendanceGroupStaffQuery().staffId(staff.getId()));
// if (!ObjectUtils.isEmpty(attendanceGroupStaffEntities)) {
// attendanceGroupStaffService.removeList(attendanceGroupStaffEntities,context);
// }
Long[] groudStaffIds = attendanceGroupStaffService.find(new AttendanceGroupStaffQuery().staffId(staff.getId())).stream().map(i->i.getId()).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(groudStaffIds)) {
attendanceGroupStaffService.remove(groudStaffIds, null);
}
......@@ -340,10 +343,7 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
deptService.updateDeptNum(context);
}
public static void main(String[] args) {
System.out.println("1" + StrUtil.padPre("125", 7, "0"));
}
@Override
protected StaffEntity findBefore(StaffEntity params, PageInfo pageInfo, Context context) throws AppException {
......@@ -361,4 +361,17 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
}
return params;
}
public static void main(String[] args) {
System.out.println("1" + StrUtil.padPre("125", 7, "0"));
ArrayList<AttendanceGroupStaffEntity> attendanceGroupStaffEntities = new ArrayList<>();
Long[] ids = attendanceGroupStaffEntities.stream().map(i -> i.getId()).toArray(Long[]::new);
System.out.println(JSON.toJSONString(ids));
}
}
\ No newline at end of file
......@@ -6,8 +6,17 @@
"baseUrl": "http://192.168.0.98:11039/attendance",
"baseLogin": "http://192.168.0.98:11078/base"
},
"yibin": {
"baseUrl": "http://112.19.80.237:11039/attendance",
"baseLogin": "http://192.168.0.98:11078/base"
},
"portal": {
"baseUrl": "http://192.168.0.98:11072/zwfw",
"baseLogin": "http://192.168.0.98:11078/base"
},
"portal-yibin": {
"baseUrl": "http://112.19.80.237:11078/zwfw"
}
}
\ No newline at end of file
......@@ -5,8 +5,8 @@ Content-Type: application/json
{
"loginName":"admin",
"password":"admin",
"securityCode":"8888"
"password":"xhxADMIN8@a",
"securityCode":"admin"
}
> {%
......@@ -27,6 +27,17 @@ Content-Type: application/json
###海康考勤打卡记录计算
POST {{baseUrl}}/attendance/record/hik/addAttendanceRecord
Authorization: {{authToken}}
Content-Type: application/json
{
"attendanceDateStart":"2023-09-28",
"attendanceDateEnd":"2023-10-08"
}
###短信设置编辑
GET {{baseUrl}}/sms/set/edit?id={{SmsSet_id}}
Accept: application/json
......
......@@ -25,7 +25,7 @@ public interface IHolidayFeign extends IFeign {
* @param holidayPdu
* @return
*/
@PostMapping(value = "/holiday/list")
@PostMapping(value = "/holiday/interlist")
Rest<RespData<List<HolidayPdu>>> list(@RequestBody HolidayPdu holidayPdu);
......@@ -35,7 +35,7 @@ public interface IHolidayFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/holiday/info")
@GetMapping(value = "/holiday/interinfo")
Rest<HolidayPdu> info(@RequestParam(value = "id") Long id);
/**
......
......@@ -28,7 +28,7 @@ public interface IUserFeign extends IFeign {
* @param userPdu
* @return
*/
@PostMapping(value = "/user/list")
@PostMapping(value = "/user/interlist")
Rest<RespData<List<UserPdu>>> list(@RequestBody UserPdu userPdu);
......@@ -38,7 +38,7 @@ public interface IUserFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/user/info")
@GetMapping(value = "/user/interinfo")
Rest<UserPdu> info(@RequestParam(value = "id") Long id);
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment