|  | @@ -23,6 +23,7 @@ import com.jeeplus.modules.sys.entity.Office;
 | 
	
		
			
				|  |  |  import com.jeeplus.modules.sys.entity.Role;
 | 
	
		
			
				|  |  |  import com.jeeplus.modules.sys.entity.User;
 | 
	
		
			
				|  |  |  import com.jeeplus.modules.sys.service.SystemService;
 | 
	
		
			
				|  |  | +import com.jeeplus.modules.sys.service.UserService;
 | 
	
		
			
				|  |  |  import com.jeeplus.modules.sys.utils.UserUtils;
 | 
	
		
			
				|  |  |  import com.jeeplus.modules.sysuseroffice.dao.UserofficeDao;
 | 
	
		
			
				|  |  |  import com.jeeplus.modules.sysuseroffice.entity.Useroffice;
 | 
	
	
		
			
				|  | @@ -108,6 +109,8 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  	private WorkStaffAchivesDao workStaffAchivesDao;
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private WorkJobGradeDao workJobGradeDao;
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private UserService userService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	public WorkOfficeChange get(String id) {
 | 
	
		
			
				|  |  |  		return super.get(id);
 | 
	
	
		
			
				|  | @@ -267,9 +270,11 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  					);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			List<User> users = new ArrayList<>();
 | 
	
		
			
				|  |  | -			List<User> bmzrList = UserUtils.getByRoleActivityEnname("bmzr",2,office.getId(),"24",workOfficeChange.getCreateBy());
 | 
	
		
			
				|  |  | -			List<User> fgldList = UserUtils.getByRoleActivityEnname("fgld",2,office.getId(),"24",workOfficeChange.getCreateBy());
 | 
	
		
			
				|  |  | -			List<User> zjlList = UserUtils.getByRoleActivityEnname("zjl",3,office.getId(),"24",workOfficeChange.getCreateBy());
 | 
	
		
			
				|  |  | +			String oldOfficeId = workOfficeChange.getWorkOfficeChangeUserList().get(0).getOldOfficeId();
 | 
	
		
			
				|  |  | +			String newOfficeId = workOfficeChange.getChangeOffice();
 | 
	
		
			
				|  |  | +			List<User> bmzrList = UserUtils.getByRoleActivityEnname("bmzr",2,oldOfficeId,"24",workOfficeChange.getCreateBy()); //原部门负责人
 | 
	
		
			
				|  |  | +			List<User> fgldList = UserUtils.getByRoleActivityEnname("bmzr",2,newOfficeId,"24",workOfficeChange.getCreateBy());  //现部门负责人
 | 
	
		
			
				|  |  | +			List<User> zjlList = UserUtils.findRszrList(createUser); //人事主任
 | 
	
		
			
				|  |  |  			if (StringUtils.isNotBlank(workActivityMenu.getId())) {
 | 
	
		
			
				|  |  |  				workProjectNotify.setNotifyRole("");
 | 
	
		
			
				|  |  |  				workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
 | 
	
	
		
			
				|  | @@ -311,7 +316,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  					return "流程审批人不能为空,请联系管理员!";
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  				variables.put("bmzrCount",bmzrList.size());
 | 
	
		
			
				|  |  | -				processType = "workOfficeChange";
 | 
	
		
			
				|  |  | +				processType = "jobChange";
 | 
	
		
			
				|  |  |  				users.addAll(bmzrList);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			List<String> userIds = new ArrayList<>(users.size());
 | 
	
	
		
			
				|  | @@ -319,7 +324,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  				userIds.add(u.getId());
 | 
	
		
			
				|  |  |  				workProjectNotify.setUser(u);
 | 
	
		
			
				|  |  |  				workProjectNotify.setId("");
 | 
	
		
			
				|  |  | -				workProjectNotify.setNotifyRole("部门负责人审核");
 | 
	
		
			
				|  |  | +				workProjectNotify.setNotifyRole("现部门主任审核");
 | 
	
		
			
				|  |  |  				workProjectNotifyService.save(workProjectNotify);
 | 
	
		
			
				|  |  |  				Map<String,Object> extras = new HashMap<>();
 | 
	
		
			
				|  |  |  				extras.put("type","7001");
 | 
	
	
		
			
				|  | @@ -417,7 +422,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  		selectProcess.setProcessInstanceId(workOfficeChange.getProcessInstanceId());
 | 
	
		
			
				|  |  |  		List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
 | 
	
		
			
				|  |  |  		List<Activity> activities = workActivityMenu.getActivities();
 | 
	
		
			
				|  |  | -		if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workOfficeChange")) {
 | 
	
		
			
				|  |  | +		if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("jobChange")) {
 | 
	
		
			
				|  |  |  			key = 1;
 | 
	
		
			
				|  |  |  			for (int i = 0; i < workActivityProcesses.size(); i++) {
 | 
	
		
			
				|  |  |  				WorkActivityProcess activityProcess = workActivityProcesses.get(i);
 | 
	
	
		
			
				|  | @@ -462,7 +467,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		} else {
 | 
	
		
			
				|  |  | -			workActivityMenu.setProcessType("workOfficeChange");
 | 
	
		
			
				|  |  | +			workActivityMenu.setProcessType("jobChange");
 | 
	
		
			
				|  |  |  			for (int i = 0; i < workActivityProcesses.size(); i++) {
 | 
	
		
			
				|  |  |  				WorkActivityProcess activityProcess = workActivityProcesses.get(i);
 | 
	
		
			
				|  |  |  				String count = activityProcess.getCount() + "";
 | 
	
	
		
			
				|  | @@ -478,7 +483,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  						vars.put("fgldList", auditUsers);
 | 
	
		
			
				|  |  |  						vars.put("fgldCount",auditUsers.size());
 | 
	
		
			
				|  |  |  						workActivityProcessService.insertAuditsByType(auditUsers,workOfficeChange.getProcessInstanceId(),2,1);
 | 
	
		
			
				|  |  | -						notifyRole = "分管领导审核";
 | 
	
		
			
				|  |  | +						notifyRole = "新部门主任审核";
 | 
	
		
			
				|  |  |  						workActivityProcess.setIsApproval("1");
 | 
	
		
			
				|  |  |  						enname = "fgld";
 | 
	
		
			
				|  |  |  					} else {
 | 
	
	
		
			
				|  | @@ -495,7 +500,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  						vars.put("zjlList", auditUsers);
 | 
	
		
			
				|  |  |  						vars.put("zjlCount",auditUsers.size());
 | 
	
		
			
				|  |  |  						workActivityProcessService.insertAuditsByType(auditUsers,workOfficeChange.getProcessInstanceId(),3,1);
 | 
	
		
			
				|  |  | -						notifyRole = "总经理审核";
 | 
	
		
			
				|  |  | +						notifyRole = "人事主任审核";
 | 
	
		
			
				|  |  |  						workActivityProcess.setIsApproval("1");
 | 
	
		
			
				|  |  |  						enname = "zjl";
 | 
	
		
			
				|  |  |  					} else {
 | 
	
	
		
			
				|  | @@ -516,7 +521,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  |  					break;
 | 
	
		
			
				|  |  |  				}  else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
 | 
	
		
			
				|  |  | -					notifyRole = "部门负责人审核";
 | 
	
		
			
				|  |  | +					notifyRole = "现部门主任审核";
 | 
	
		
			
				|  |  |  					taskCount = "0";
 | 
	
		
			
				|  |  |  					exp = "pass";
 | 
	
		
			
				|  |  |  					workActivityProcess.setCount(0);
 | 
	
	
		
			
				|  | @@ -533,6 +538,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  		workOfficeChange.preUpdate();
 | 
	
		
			
				|  |  |  		// 提交流程任务
 | 
	
		
			
				|  |  |  		vars.put(exp, "yes".equals(flag) ? true : false);
 | 
	
		
			
				|  |  | +		vars.put("passs", true);
 | 
	
		
			
				|  |  |  		workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workOfficeChange.getProcessInstanceId(),taskDefKey,"modifyApply",flag,comment, activities);
 | 
	
		
			
				|  |  |  		// 提交流程任务
 | 
	
		
			
				|  |  |  		actTaskService.complete(act.getTaskId(), act.getProcInsId(), act.getComment(), vars);
 | 
	
	
		
			
				|  | @@ -580,7 +586,7 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			workActivityProcessService.deleteProcessIdAuditUsers(workOfficeChange.getProcessInstanceId());
 | 
	
		
			
				|  |  |  		} else {
 | 
	
		
			
				|  |  | -			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("workOfficeChange")) {
 | 
	
		
			
				|  |  | +			if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("jobChange")) {
 | 
	
		
			
				|  |  |  				WorkProjectNotify notify = new WorkProjectNotify();
 | 
	
		
			
				|  |  |  				notify.setNotifyId(workOfficeChange.getId());
 | 
	
		
			
				|  |  |  				userList = workProjectNotifyService.readByNotifyId(notify);
 | 
	
	
		
			
				|  | @@ -764,30 +770,32 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  						useroffice.setCompanyId(workStaffBasicInfo.getCompany().getId());
 | 
	
		
			
				|  |  |  						useroffice.setOfficeId(workOfficeChange.getChangeOffice());
 | 
	
		
			
				|  |  |  						Useroffice useroffice1=userofficeDao.findOfficeId(useroffice);
 | 
	
		
			
				|  |  | -						if(useroffice1.getOfficeId().equals(user.getOffice().getId())){
 | 
	
		
			
				|  |  | -							user.setId(workOfficeChangeUser.getUserId());
 | 
	
		
			
				|  |  | -							user.setOffice(office);
 | 
	
		
			
				|  |  | -							userDao.update(user);
 | 
	
		
			
				|  |  | +						if(useroffice1 != null) {
 | 
	
		
			
				|  |  | +							if (useroffice1.getOfficeId().equals(user.getOffice().getId())) {
 | 
	
		
			
				|  |  | +								user.setId(workOfficeChangeUser.getUserId());
 | 
	
		
			
				|  |  | +								user.setOffice(office);
 | 
	
		
			
				|  |  | +								userDao.update(user);
 | 
	
		
			
				|  |  | +							}
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  |  						userofficeDao.updateOffice(useroffice);
 | 
	
		
			
				|  |  |  						//在新部门增加默认岗位
 | 
	
		
			
				|  |  | -						Role r=new Role();
 | 
	
		
			
				|  |  | -						r.setOffice(office);
 | 
	
		
			
				|  |  | -						r.setName("员工");
 | 
	
		
			
				|  |  | -						r.setEnname("yg");
 | 
	
		
			
				|  |  | -						List<Role> list=new ArrayList<>();
 | 
	
		
			
				|  |  | -						Role role=roleDao.getRoleByOfficeId(r);
 | 
	
		
			
				|  |  | -						if(role!=null){
 | 
	
		
			
				|  |  | -							list.add(role);
 | 
	
		
			
				|  |  | -							User uu=new User();
 | 
	
		
			
				|  |  | -							uu.setId(workOfficeChangeUser.getUserId());
 | 
	
		
			
				|  |  | -							uu.setRoleList(list);
 | 
	
		
			
				|  |  | -							//查询是否存在员工岗位
 | 
	
		
			
				|  |  | -							List userRole=userDao.findUserRole(workOfficeChangeUser.getUserId(),role.getId());
 | 
	
		
			
				|  |  | -							if(userRole==null||list.size() ==0 ){
 | 
	
		
			
				|  |  | -								userDao.insertUserRole(uu);
 | 
	
		
			
				|  |  | -							}
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  | +//						Role r=new Role();
 | 
	
		
			
				|  |  | +//						r.setOffice(office);
 | 
	
		
			
				|  |  | +//						r.setName("员工");
 | 
	
		
			
				|  |  | +//						r.setEnname("yg");
 | 
	
		
			
				|  |  | +//						List<Role> list=new ArrayList<>();
 | 
	
		
			
				|  |  | +//						Role role=roleDao.getRoleByOfficeId(r);
 | 
	
		
			
				|  |  | +//						if(role!=null){
 | 
	
		
			
				|  |  | +//							list.add(role);
 | 
	
		
			
				|  |  | +//							User uu=new User();
 | 
	
		
			
				|  |  | +//							uu.setId(workOfficeChangeUser.getUserId());
 | 
	
		
			
				|  |  | +//							uu.setRoleList(list);
 | 
	
		
			
				|  |  | +//							//查询是否存在员工岗位
 | 
	
		
			
				|  |  | +//							List userRole=userDao.findUserRole(workOfficeChangeUser.getUserId(),role.getId());
 | 
	
		
			
				|  |  | +//							if(userRole==null||list.size() ==0 ){
 | 
	
		
			
				|  |  | +//								userDao.insertUserRole(uu);
 | 
	
		
			
				|  |  | +//							}
 | 
	
		
			
				|  |  | +//						}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  |  					//修改入职登记表office
 | 
	
	
		
			
				|  | @@ -803,6 +811,12 @@ public class WorkOfficeChangeService extends CrudService<WorkOfficeChangeDao, Wo
 | 
	
		
			
				|  |  |  					workStaffAchivesDao.update(workStaffBasicInfo);
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | +			String userId = workOfficeChange.getWorkOfficeChangeUserList().get(0).getUserId();
 | 
	
		
			
				|  |  | +			String roleId = workOfficeChange.getRoleId();
 | 
	
		
			
				|  |  | +			WorkStaffBasicInfo workStaffBasicInfo = new WorkStaffBasicInfo();
 | 
	
		
			
				|  |  | +			workStaffBasicInfo.setUserId(userId);
 | 
	
		
			
				|  |  | +			workStaffBasicInfo.setRoleId(roleId);
 | 
	
		
			
				|  |  | +			userService.updateRole(workStaffBasicInfo);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	}
 |