Commit cf0c26cf authored by 赵啸非's avatar 赵啸非

修改员工列表和用户列表

parent e79fb360
...@@ -27,4 +27,11 @@ public interface RoleUserService extends ICRUDService<RoleUserEntity,Long> { ...@@ -27,4 +27,11 @@ public interface RoleUserService extends ICRUDService<RoleUserEntity,Long> {
void doDistributionUser(RoleUserQuery query); void doDistributionUser(RoleUserQuery query);
void doDistributionRole(RoleUserQuery query); void doDistributionRole(RoleUserQuery query);
/**
* 给用户分配角色
* @param query
*/
void assignRoleToUser(RoleUserQuery query);
} }
\ No newline at end of file
...@@ -70,6 +70,26 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,Rol ...@@ -70,6 +70,26 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,Rol
this.dao.insertBatch(list); this.dao.insertBatch(list);
} }
@Override
public void assignRoleToUser(RoleUserQuery query) {
//删除当前用户所有关联角色
Long userId = query.getUserId();
Map<String, Object> condition = new HashMap<>(1);
condition.put("userId", userId);
dao.delete(condition);
//新增用户角色
List<Long> roleIdList = query.getRoleIdList();
List<RoleUserEntity> list = new ArrayList<>();
for (Long roleId : roleIdList) {
RoleUserEntity rolseUser = new RoleUserEntity();
rolseUser.setRoleId(roleId);
rolseUser.setUserId(userId);
list.add(rolseUser);
}
this.save(list);
}
} }
\ No newline at end of file
...@@ -48,7 +48,7 @@ public class UserEntity extends UserVo implements IUser { ...@@ -48,7 +48,7 @@ public class UserEntity extends UserVo implements IUser {
*/ */
private String qq; private String qq;
/** /**
* 用户类型(0.系统用户,1.普通用户,2.工作人员) * 用户类型(0.系统用户,1.普通用户,2.工作人员,3.普通员工)
*/ */
private Integer userType; private Integer userType;
...@@ -232,7 +232,7 @@ public class UserEntity extends UserVo implements IUser { ...@@ -232,7 +232,7 @@ public class UserEntity extends UserVo implements IUser {
this.qq = qq; this.qq = qq;
} }
/** /**
* 获取 用户类型(0.系统用户,1.普通用户,2.工作人员) * 获取 用户类型(0.系统用户,1.普通用户,2.工作人员,3.普通员工)
* @return Integer * @return Integer
*/ */
public Integer getUserType(){ public Integer getUserType(){
......
...@@ -6,6 +6,7 @@ import com.mortals.framework.ap.CookieService; ...@@ -6,6 +6,7 @@ import com.mortals.framework.ap.CookieService;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.ap.SysConstains; import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.IAuthTokenService; import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IUser; import com.mortals.framework.service.IUser;
...@@ -32,6 +33,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -32,6 +33,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -46,34 +49,12 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -46,34 +49,12 @@ public class ApiLoginController extends BaseJsonBodyController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
private ValidCodeService validCodeService;
@Autowired
private ResourceService resourceService;
@Autowired
private MenuService menuService;
// @Autowired
// private ITokenService tokenService;
@Autowired
private ICacheService cacheService;
@Autowired
private IAuthTokenService authTokenService; private IAuthTokenService authTokenService;
@RequestMapping("login") @RequestMapping("login")
public String login(@RequestBody LoginForm loginForm) throws Exception { public String login(@RequestBody LoginForm loginForm) throws Exception {
/*
JSONObject ret = new JSONObject();
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
UserPdu userPdu = new UserPdu();
userPdu.setLoginName(loginName);
userPdu.setPassword(password);
String resp = userFeign.portalLogin(userPdu);
return resp;
*/
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
String loginName = loginForm.getLoginName(); String loginName = loginForm.getLoginName();
String password = loginForm.getPassword(); String password = loginForm.getPassword();
...@@ -88,42 +69,35 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -88,42 +69,35 @@ public class ApiLoginController extends BaseJsonBodyController {
loginForm.validate(); loginForm.validate();
userEntity = userService.doLogin(loginName, password, ip); userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip); userEntity.setLastLoginAddress(ip);
recordSysLog(request, userEntity, "H5用户登录系统成功!");
recordSysLog(request, userEntity, "用户登录系统成功!");
// 返回拥有的菜单数据
Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
List<MenuEntity> outlookBarList = menuService.findTreeMenu(userEntity, urls);
String currUserName = userEntity.getRealName(); String currUserName = userEntity.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) { if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员"; currUserName = "管理员";
} }
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
data.put("currUserName", currUserName); data.put("currUserName", currUserName);
data.put("barList", outlookBarList);
data.put("id", userEntity.getId()); data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType()); data.put("userType", userEntity.getUserType());
HashSet<Integer> set = new HashSet<>();
set.add(1);
set.add(2);
if (ObjectUtils.isEmpty(userEntity.getUserType()) || !set.contains(userEntity.getUserType())) {
throw new AppException("当前用户不支持H5登录!");
}
userEntity.setLoginTime(System.currentTimeMillis()); userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID()); userEntity.setToken(IdUtil.fastSimpleUUID());
userEntity.setExpireTime(DateUtils.addCurrDate(7).getTime()); userEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
userEntity.setMenuUrl(generateMenuUrlCode(urls));
String token = authTokenService.createToken(userEntity); String token = authTokenService.createToken(userEntity);
data.put("token", token); data.put("token", token);
//设置token 和过期时间
//data.put("expiresTime", DateUtils.addCurrDate(7).getTime());
generateMenuUrlCode(urls);
//this.generateBlackCookie(request, response, loginName, urls);
ret.put(KEY_RESULT_DATA, data); ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!"); ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
ret.put("resources", urls);
return ret.toJSONString(); return ret.toJSONString();
} catch (Exception e) { } catch (Exception e) {
log.error("login error ", e); log.error("h5 login error ", e);
if (userEntity == null) {
userEntity = new UserEntity();
userEntity.setLoginName(loginName);
}
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE); ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e)); ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString(); return ret.toJSONString();
...@@ -136,78 +110,6 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -136,78 +110,6 @@ public class ApiLoginController extends BaseJsonBodyController {
super.removeCurrUser(request); super.removeCurrUser(request);
} }
@RequestMapping("index")
public String index() throws Exception {
JSONObject ret = new JSONObject();
IUser user = this.getCurUser();
if (user == null) {
return JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_EXPIRED, ERROR_TOKEN_EXPIRED_CONTENT));
}
Set<String> urls = resourceService.findUrlSetByUserId(user.getId());
List<MenuEntity> outlookBarList = menuService.findTreeMenu(user, urls);
String currUserName = user.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员";
}
JSONObject data = new JSONObject();
String token = authTokenService.getToken(request);
data.put("token", token);
data.put("currUserName", currUserName);
data.put("barList", outlookBarList);
data.put("id", user.getId());
data.put("userType", user.getUserType());
ret.put(KEY_RESULT_DATA, data);
//this.generateBlackCookie(request, response, user.getLoginName(), urls);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
ret.put("resources", urls);
return ret.toJSONString();
}
private void generateBlackCookie(HttpServletRequest request, HttpServletResponse response, String loginName, Set<String> urls) {
try {
String cacheKey = RedisKey.KEY_MENU_CACHE + loginName;
String securityKey = GlobalSysInfo.getPropertyValue(SysConstains.PROP_COOKIE_SECURITY_KEY);
//应为Cookie会超长,所以改为仅存储key将值放入redis
//CookieService.setCookieForAuth(request, response, securityKey, null);
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();
menuUrl = AESUtil.encrypt(menuUrl, securityKey);
cacheService.set(cacheKey, menuUrl, 604800);
HttpUtil.setCookieValue(request, response, SysConstains.COOKIE_MENU, cacheKey, -1);
} catch (Throwable e) {
}
}
private 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;
}
}
@RequestMapping("parseToken") @RequestMapping("parseToken")
public IUser parseToken() throws Exception { public IUser parseToken() throws Exception {
......
...@@ -55,7 +55,7 @@ public class AppealApiController extends BaseJsonBodyController { ...@@ -55,7 +55,7 @@ public class AppealApiController extends BaseJsonBodyController {
/** /**
* 个人申诉绩效统计 * 个人申诉绩效统计
*/ */
@PostMapping(value = "appeal/stat") @PostMapping(value = "stat")
public Rest<AppealStatInfo> appealStat() { public Rest<AppealStatInfo> appealStat() {
String busiDesc = "H5个人申诉绩效统计"; String busiDesc = "H5个人申诉绩效统计";
Rest<AppealStatInfo> rest = Rest.ok(busiDesc + " 【成功】"); Rest<AppealStatInfo> rest = Rest.ok(busiDesc + " 【成功】");
...@@ -72,7 +72,7 @@ public class AppealApiController extends BaseJsonBodyController { ...@@ -72,7 +72,7 @@ public class AppealApiController extends BaseJsonBodyController {
/** /**
* 申诉列表 * 申诉列表
*/ */
@PostMapping(value = "appeal/list") @PostMapping(value = "list")
public Rest<List<PerformAttendAppealEntity>> performList(@RequestBody AppealReq appealReq) { public Rest<List<PerformAttendAppealEntity>> performList(@RequestBody AppealReq appealReq) {
String busiDesc = "个人申诉列表"; String busiDesc = "个人申诉列表";
Rest<List<PerformAttendAppealEntity>> rest = Rest.ok(busiDesc + " 【成功】"); Rest<List<PerformAttendAppealEntity>> rest = Rest.ok(busiDesc + " 【成功】");
...@@ -95,8 +95,8 @@ public class AppealApiController extends BaseJsonBodyController { ...@@ -95,8 +95,8 @@ public class AppealApiController extends BaseJsonBodyController {
/** /**
* 申诉详细 * 申诉详细
*/ */
@PostMapping(value = "appeal/detail") @PostMapping(value = "info")
public Rest<PerformAttendAppealEntity> performDetail(@RequestBody AppealReq appealReq) { public Rest<PerformAttendAppealEntity> performInfo(@RequestBody AppealReq appealReq) {
String busiDesc = "个人申诉详细"; String busiDesc = "个人申诉详细";
Rest<PerformAttendAppealEntity> rest = Rest.ok(busiDesc + " 【成功】"); Rest<PerformAttendAppealEntity> rest = Rest.ok(busiDesc + " 【成功】");
try { try {
...@@ -116,7 +116,7 @@ public class AppealApiController extends BaseJsonBodyController { ...@@ -116,7 +116,7 @@ public class AppealApiController extends BaseJsonBodyController {
/** /**
* 申诉新增 * 申诉新增
*/ */
@PostMapping(value = "appeal/save") @PostMapping(value = "save")
public Rest<String> appealSave(@RequestBody PerformAttendAppealEntity appealEntity) { public Rest<String> appealSave(@RequestBody PerformAttendAppealEntity appealEntity) {
String busiDesc = "个人申诉新增"; String busiDesc = "个人申诉新增";
Rest<String> rest = Rest.ok(busiDesc + " 【成功】"); Rest<String> rest = Rest.ok(busiDesc + " 【成功】");
......
...@@ -48,7 +48,7 @@ public class FeedbackApiController extends BaseJsonBodyController { ...@@ -48,7 +48,7 @@ public class FeedbackApiController extends BaseJsonBodyController {
/** /**
* 反馈列表 * 反馈列表
*/ */
@PostMapping(value = "feedback/list") @PostMapping(value = "list")
public Rest<List<PerformAttendAppealEntity>> feedbackList(@RequestBody FeedbackReq feedbackReq) { public Rest<List<PerformAttendAppealEntity>> feedbackList(@RequestBody FeedbackReq feedbackReq) {
String busiDesc = "个人反馈列表"; String busiDesc = "个人反馈列表";
Rest<List<PerformAttendAppealEntity>> rest = Rest.ok(busiDesc + " 【成功】"); Rest<List<PerformAttendAppealEntity>> rest = Rest.ok(busiDesc + " 【成功】");
...@@ -71,7 +71,7 @@ public class FeedbackApiController extends BaseJsonBodyController { ...@@ -71,7 +71,7 @@ public class FeedbackApiController extends BaseJsonBodyController {
/** /**
* 反馈详细 * 反馈详细
*/ */
@PostMapping(value = "feedback/question") @PostMapping(value = "question")
public Rest<PerformAttendAppealEntity> performDetail(@RequestBody AppealReq appealReq) { public Rest<PerformAttendAppealEntity> performDetail(@RequestBody AppealReq appealReq) {
String busiDesc = "个人申诉详细"; String busiDesc = "个人申诉详细";
Rest<PerformAttendAppealEntity> rest = Rest.ok(busiDesc + " 【成功】"); Rest<PerformAttendAppealEntity> rest = Rest.ok(busiDesc + " 【成功】");
...@@ -92,9 +92,9 @@ public class FeedbackApiController extends BaseJsonBodyController { ...@@ -92,9 +92,9 @@ public class FeedbackApiController extends BaseJsonBodyController {
/** /**
* 申诉新增 * 申诉新增
*/ */
@PostMapping(value = "appeal/save") @PostMapping(value = "save")
public Rest<String> appealSave(@RequestBody PerformAttendAppealEntity appealEntity) { public Rest<String> feedbackSave(@RequestBody PerformAttendAppealEntity appealEntity) {
String busiDesc = "个人申诉新增"; String busiDesc = "反馈回答";
Rest<String> rest = Rest.ok(busiDesc + " 【成功】"); Rest<String> rest = Rest.ok(busiDesc + " 【成功】");
try { try {
......
...@@ -47,7 +47,7 @@ public class PerformApiController extends BaseJsonBodyController { ...@@ -47,7 +47,7 @@ public class PerformApiController extends BaseJsonBodyController {
/** /**
* 个人当天绩效统计 * 个人当天绩效统计
*/ */
@PostMapping(value = "perform/stat") @PostMapping(value = "stat")
public Rest<PerformStatInfo> performStat() { public Rest<PerformStatInfo> performStat() {
String busiDesc = "H5 个人绩效统计"; String busiDesc = "H5 个人绩效统计";
Rest<PerformStatInfo> rest = Rest.ok(busiDesc + " 【成功】"); Rest<PerformStatInfo> rest = Rest.ok(busiDesc + " 【成功】");
...@@ -65,7 +65,7 @@ public class PerformApiController extends BaseJsonBodyController { ...@@ -65,7 +65,7 @@ public class PerformApiController extends BaseJsonBodyController {
/** /**
* 个人当月绩效加分扣分列表 * 个人当月绩效加分扣分列表
*/ */
@PostMapping(value = "perform/list") @PostMapping(value = "list")
public Rest<List<PerformInfo>> performList(@RequestBody PerformReq performReq) { public Rest<List<PerformInfo>> performList(@RequestBody PerformReq performReq) {
String busiDesc = "个人绩效列表"; String busiDesc = "个人绩效列表";
Rest<List<PerformInfo>> rest = Rest.ok(busiDesc + " 【成功】"); Rest<List<PerformInfo>> rest = Rest.ok(busiDesc + " 【成功】");
...@@ -107,7 +107,7 @@ public class PerformApiController extends BaseJsonBodyController { ...@@ -107,7 +107,7 @@ public class PerformApiController extends BaseJsonBodyController {
/** /**
* 详细 * 详细
*/ */
@PostMapping(value = "perform/info") @PostMapping(value = "info")
public Rest<PerformDetailInfo> performInfo(@RequestBody PerformReq performReq) { public Rest<PerformDetailInfo> performInfo(@RequestBody PerformReq performReq) {
String busiDesc = "个人绩效增减详细"; String busiDesc = "个人绩效增减详细";
Rest<PerformDetailInfo> rest = Rest.ok(busiDesc + " 【成功】"); Rest<PerformDetailInfo> rest = Rest.ok(busiDesc + " 【成功】");
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.daemon.task; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -115,7 +116,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -115,7 +116,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> { List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity(); AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue(); recordHikEntity.initAttrValue();
StaffEntity staffCache = staffService.getExtCache(item.getJobNo()); StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) { if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}",item.getJobNo()); log.info("staff is null !staffCode:{}",item.getJobNo());
return null; return null;
......
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -57,8 +58,6 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -57,8 +58,6 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private DeptService deptService; private DeptService deptService;
@Autowired
private StaffService service;
@Autowired @Autowired
private AttendanceStatService attendanceStatService; private AttendanceStatService attendanceStatService;
...@@ -70,12 +69,11 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -70,12 +69,11 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("同步用户--部门");
try { try {
//同步部门 log.info("同步用户");
syncDepts();
//同步员工
syncPersons(); syncPersons();
log.info("同步部门");
syncDepts();
} catch (Exception e) { } catch (Exception e) {
log.error("同步人事异常", e); log.error("同步人事异常", e);
} }
...@@ -89,7 +87,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -89,7 +87,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
if (personRest.getCode() == YesNoEnum.YES.getValue()) { if (personRest.getCode() == YesNoEnum.YES.getValue()) {
List<PersonInfo> personInfoList = personRest.getData().getList(); List<PersonInfo> personInfoList = personRest.getData().getList();
for (PersonInfo personInfo : personInfoList) { for (PersonInfo personInfo : personInfoList) {
StaffEntity staffEntity = staffService.getExtCache(personInfo.getJobNo()); StaffEntity staffEntity = staffService.getExtCache(StrUtil.padPre(personInfo.getJobNo(), 8, "0"));
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(personInfo.getOrgIndexCode())); DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(personInfo.getOrgIndexCode()));
// AttendanceVacationBalanceEntity balanceEntity = balanceService.selectOne(new AttendanceVacationBalanceQuery().staffId(staffEntity.getId())); // AttendanceVacationBalanceEntity balanceEntity = balanceService.selectOne(new AttendanceVacationBalanceQuery().staffId(staffEntity.getId()));
// AttendanceStatEntity statEntity = attendanceStatService.selectOne(new AttendanceStatQuery().staffId(staffEntity.getId())); // AttendanceStatEntity statEntity = attendanceStatService.selectOne(new AttendanceStatQuery().staffId(staffEntity.getId()));
...@@ -111,7 +109,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -111,7 +109,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
staffEntity.setPhoneNumber(personInfo.getPhoneNo()); staffEntity.setPhoneNumber(personInfo.getPhoneNo());
staffEntity.setCreateUserId(1L); staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date()); staffEntity.setCreateTime(new Date());
service.save(staffEntity); staffService.save(staffEntity);
AttendanceVacationBalanceEntity balanceEntity = new AttendanceVacationBalanceEntity(); AttendanceVacationBalanceEntity balanceEntity = new AttendanceVacationBalanceEntity();
balanceEntity.initAttrValue(); balanceEntity.initAttrValue();
...@@ -181,7 +179,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -181,7 +179,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
staffEntity.setPhoneNumber(personInfo.getPhoneNo()); staffEntity.setPhoneNumber(personInfo.getPhoneNo());
staffEntity.setUpdateUserId(1L); staffEntity.setUpdateUserId(1L);
staffEntity.setUpdateTime(new Date()); staffEntity.setUpdateTime(new Date());
service.update(staffEntity); staffService.update(staffEntity);
//统计各级部门员工数量 //统计各级部门员工数量
String ancestor = deptEntity.getAncestors().split(",", 2)[1]; String ancestor = deptEntity.getAncestors().split(",", 2)[1];
String[] ancestors = ancestor.split(","); String[] ancestors = ancestor.split(",");
......
package com.mortals.xhx.module.staff.service.impl; package com.mortals.xhx.module.staff.service.impl;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
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.service.UserService;
import com.mortals.xhx.common.code.StaffSatusEnum; import com.mortals.xhx.common.code.StaffSatusEnum;
import com.mortals.xhx.common.code.StaffTypeEnum; import com.mortals.xhx.common.code.StaffTypeEnum;
import com.mortals.xhx.common.code.StatusEnum; import com.mortals.xhx.common.code.StatusEnum;
import com.mortals.xhx.common.code.UserStatus;
import com.mortals.xhx.module.staff.dao.StaffDao; import com.mortals.xhx.module.staff.dao.StaffDao;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl; import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.dao.ibatis.StaffLeaveDaoImpl; import com.mortals.xhx.module.staff.dao.ibatis.StaffLeaveDaoImpl;
...@@ -13,8 +22,10 @@ import com.mortals.xhx.module.staff.model.vo.StaffInfoVo; ...@@ -13,8 +22,10 @@ import com.mortals.xhx.module.staff.model.vo.StaffInfoVo;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -29,10 +40,17 @@ import java.util.stream.Collectors; ...@@ -29,10 +40,17 @@ import java.util.stream.Collectors;
@Service("staffService") @Service("staffService")
public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, StaffEntity, Long> implements StaffService { public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, StaffEntity, Long> implements StaffService {
@Autowired
private UserService userService;
@Autowired
private RoleUserService roleUserService;
@Override @Override
protected String getExtKey(StaffEntity data) { protected String getExtKey(StaffEntity data) {
//工号作为redis 扩展key //工号作为redis 扩展key
return data.getWorkNum(); return StrUtil.padPre(data.getWorkNum(), 8, "0");
// return "1000"+data.getWorkNum();
} }
@Override @Override
...@@ -68,4 +86,51 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -68,4 +86,51 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
return staffEntities.size(); return staffEntities.size();
} }
@Override
protected void saveAfter(StaffEntity entity, Context context) throws AppException {
try {
UserEntity userEntity = new UserEntity();
if (ObjectUtils.isEmpty(entity.getLoginName())) {
//姓名加工号作为登录名
entity.setLoginName(entity.getName() + entity.getWorkNum());
}
if (ObjectUtils.isEmpty(entity.getLoginPwd())) {
//设置初始密码
entity.setLoginPwd("123456");
}
userEntity.setLoginName(StrUtil.cleanBlank(entity.getLoginName()));
userEntity.setRealName(entity.getName());
userEntity.setUserType(2);
userEntity.setSiteIds("1");
userEntity.setAreaCodes("511500000000");
userEntity.setStatus(UserStatus.NORMAL.getValue());
userEntity.setCreateUserId(this.getContextUserId(context));
userEntity.setCreateTime(new Date());
userEntity.setCustomerId(entity.getId());
userEntity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
int insert = userService.getUserDao().insert(userEntity);
if (insert > 0) {
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(userEntity.getId());
roleUserQuery.setRoleIdList(Arrays.asList(4L));
roleUserService.assignRoleToUser(roleUserQuery);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
super.saveAfter(entity, context);
}
public static void main(String[] args) {
System.out.println("1" + StrUtil.padPre("125", 7, "0"));
}
} }
\ No newline at end of file
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