浏览代码

Merge remote-tracking branch 'origin/master'

user4 5 年之前
父节点
当前提交
5524215c66

+ 7 - 7
src/main/java/com/jeeplus/modules/sys/service/UserService.java

@@ -237,14 +237,14 @@ public class UserService extends BaseController {
             UserUtils.putCache("selectOffice", user.getOffice().getId());
         }
         if (!loginUser.getComId().equals("1")){
-            Role comRole =  systemService.getRoleByEnname(loginUser.getCompany().getId(), user.getOffice(),"yg");
-            if (comRole != null && !comRole.getCompany().getId().equals("1")){
+//            Role comRole =  systemService.getRoleByEnname(loginUser.getCompany().getId(), user.getOffice(),"yg");
+//            if (comRole != null && !comRole.getCompany().getId().equals("1")){
                 Useroffice useroffice = new Useroffice();
                 useroffice.setUserId(user.getId());
                 useroffice.setStatus("3");
                 useroffice.setMaster(UserUtils.getUser().getId());
                 useroffice.setCompanyId(loginUser.getCompany().getId());
-                useroffice.setOfficeId(comRole.getOffice().getId());
+                useroffice.setOfficeId(user.getOffice().getId());
                 List<Useroffice> listOffice = userofficeService.findList(useroffice);
                 if(listOffice==null || listOffice.size()==0){
                     userofficeService.save(useroffice);
@@ -253,10 +253,10 @@ public class UserService extends BaseController {
                     oldUseroffice.setOfficeId(user.getOffice().getId());
                     userofficeService.save(oldUseroffice);
                 }
-            }
-            if (b) {
-                systemService.assignUserToRole(comRole, user,0);
-            }
+//            }
+//            if (b) {
+//                systemService.assignUserToRole(comRole, user,0);
+//            }
         }else {
             systemService.addUserToRole(user);
         }

+ 18 - 0
src/main/java/com/jeeplus/modules/workofficechange/entity/WorkOfficeChange.java

@@ -36,6 +36,8 @@ public class WorkOfficeChange extends ActEntity<WorkOfficeChange> {
 	private String userName;
 	private String home;
 	private List<WorkOfficeChangeUser> WorkOfficeChangeUserList;
+	private String roleId;
+	private String roleName;
 	public WorkOfficeChange() {
 		super();
 	}
@@ -173,4 +175,20 @@ public class WorkOfficeChange extends ActEntity<WorkOfficeChange> {
 	public void setHome(String home) {
 		this.home = home;
 	}
+
+	public String getRoleId() {
+		return roleId;
+	}
+
+	public void setRoleId(String roleId) {
+		this.roleId = roleId;
+	}
+
+	public String getRoleName() {
+		return roleName;
+	}
+
+	public void setRoleName(String roleName) {
+		this.roleName = roleName;
+	}
 }

+ 46 - 32
src/main/java/com/jeeplus/modules/workofficechange/service/WorkOfficeChangeService.java

@@ -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);
 		}
 
 	}

+ 10 - 8
src/main/java/com/jeeplus/modules/workofficechange/web/WorkOfficeChangeController.java

@@ -290,20 +290,22 @@ public class WorkOfficeChangeController extends BaseController {
 	@RequestMapping(value = "saveAudit")
 	public String saveAudit(WorkOfficeChange workOfficeChange, Model model,
 							RedirectAttributes redirectAttributes) {
-		try {
+//		try {
 			// 对不同环节的业务逻辑进行操作
 			String taskDefKey = workOfficeChange.getAct().getTaskDefKey();
 			List<User> users = null;
+			User createUser = UserUtils.getUser();
+			String newOfficeId = workOfficeChange.getChangeOffice();
 			if ("bmzr".equals(taskDefKey)){
 				users = UserUtils.getByProssType(workOfficeChange.getProcessInstanceId(),2);
 				if (users==null )
-					users = UserUtils.getByRoleActivityEnname("fgld",2,workOfficeChange.getOfficeId(),"68",workOfficeChange.getCreateBy());
+					users = UserUtils.getByRoleActivityEnname("bmzr",2,newOfficeId,"68",workOfficeChange.getCreateBy());
 			}else  if ("fgld".equals(taskDefKey)){
 				users = UserUtils.getByProssType(workOfficeChange.getProcessInstanceId(),3);
 				if (users==null )
-					users = UserUtils.getByRoleActivityEnname("zjl", 3, workOfficeChange.getOfficeId(), "68", workOfficeChange.getCreateBy());
+					users = UserUtils.findRszrList(createUser);
 			}else  if ("zjl".equals(taskDefKey)){
-				users = UserUtils.getByProssType(workOfficeChange.getProcessInstanceId(),3);
+				users = UserUtils.findRszrList(createUser);
 			}else if ("modifyApply".equals(taskDefKey)){
 				users = UserUtils.getByProssType(workOfficeChange.getProcessInstanceId(),1);
 			}
@@ -313,10 +315,10 @@ public class WorkOfficeChangeController extends BaseController {
 				String str = workOfficeChangeService.auditSave(workOfficeChange,users);
 				addMessage(redirectAttributes, str);
 			}
-		}catch (Exception e){
-			logger.info("Exception e:"+e);
-			addMessage(redirectAttributes, "审批失败");
-		}
+//		}catch (Exception e){
+//			logger.info("Exception e:"+e);
+//			addMessage(redirectAttributes, "审批失败");
+//		}
 		if (StringUtils.isNotBlank(workOfficeChange.getHome()) && "home".equals(workOfficeChange.getHome())) {
 			return "redirect:" + Global.getAdminPath() + "/home/?repage";
 		} else {

+ 11 - 3
src/main/resources/mappings/modules/workofficechange/WorkOfficeChangeDao.xml

@@ -20,7 +20,9 @@
 		a.state AS "state",
 		a.process_instance_id AS "processInstanceId",
 		office.top_company as "changeOfficeName",
-		us.name as "userName"
+		us.name as "userName",
+		a.role_id as "roleId",
+		r.name as "roleName"
 	</sql>
 	
 	<sql id="workOfficeChangeJoins">
@@ -29,6 +31,7 @@
 		LEFT JOIN sys_user u ON u.id = a.create_by*/
 		LEFT JOIN sys_user us ON us.id = a.changer
 		LEFT JOIN sys_office office ON office.id = a.change_office
+		LEFT JOIN sys_role r ON r.id = a.role_id
 	</sql>
 	
     
@@ -135,7 +138,8 @@
 			change_date,
 			change_for,
 			state,
-			process_instance_id
+			process_instance_id,
+			role_id
 		) VALUES (
 			#{id},
 			#{createBy.id},
@@ -152,7 +156,8 @@
 			#{changeDate},
 			#{changeFor},
 			#{state},
-			#{processInstanceId}
+			#{processInstanceId},
+			#{roleId}
 		)
 	</insert>
 	
@@ -169,6 +174,9 @@
 			change_date = #{changeDate},
 			change_for = #{changeFor},
 			state = #{state},
+			<if test="roleId != null and roleId != ''">
+			role_id = #{roleId},
+			</if>
 			process_instance_id = #{processInstanceId}
 		WHERE id = #{id}
 	</update>

+ 2 - 1
src/main/webapp/webpage/modules/sys/sysLogin.jsp

@@ -933,7 +933,8 @@
 				area: ['40%', '40%'],
 				title: '选择用户',
 				maxmin: true, //开启最大化最小化按钮
-				content: '${ctx}/workstaff/workStaffBasicInfo/repeatName?name='+encodeURI(encodeURI(name))
+				content: '${ctx}/workstaff/workStaffBasicInfo/repeatName?name='+encodeURI(encodeURI(name)),
+				// btn: ['关闭'],
 			});
 		}
 

+ 6 - 0
src/main/webapp/webpage/modules/workofficechange/workOfficeChangeAudit.jsp

@@ -93,6 +93,12 @@
 					</div>
 				</div>
 				<div class="layui-item layui-col-sm6">
+					<label class="layui-form-label"><span class="require-item">*</span>岗位:</label>
+					<div class="layui-input-block">
+						<form:input id="roleName" readonly="true" path="roleName" htmlEscape="false" class="form-control   layui-input"/>
+					</div>
+				</div>
+				<div class="layui-item layui-col-sm6">
 					<label class="layui-form-label"><span class="require-item">*</span>调转编号:</label>
 					<div class="layui-input-block">
 						<div class="input-group">

+ 24 - 0
src/main/webapp/webpage/modules/workofficechange/workOfficeChangeForm.jsp

@@ -38,6 +38,23 @@
                 type : 'date'
             });*/
 
+			$('#changeOfficeId').on("change",function(){
+				$("#roleId").empty()
+				var officeId = $(this).val()
+				$.ajax({
+					type: 'POST',
+					url: '${ctx}/sys/role/getByOfficeId',
+					data: {'id':officeId},
+					success: function(result){
+						var data1 = result.data
+						var html = "";
+						for (var e in data1) {
+							html += '<option value=' + data1[e].id+ '>' + data1[e].name + '</option>'
+						}
+						$("#roleId").append(html);
+					}
+				});
+			})
 
         });
         function doSubmit(obj){//回调函数,在编辑和保存动作时,供openDialog调用提交表单。
@@ -308,6 +325,13 @@
 										title="部门" url="/sys/office/treeDataAllOffice?type=2" cssClass="form-control required layui-input" allowClear="true" notAllowSelectParent="true" />
 					</div>
 				</div>
+				<div class="layui-item layui-col-sm6 ">
+					<label class="layui-form-label"><span class="require-item">*</span>岗位:</label>
+					<div class="layui-input-block ">
+						<select id="roleId" class="form-control simple-select required" name="roleId">
+						</select>
+					</div>
+				</div>
 				<div class="layui-item layui-col-sm6">
 					<label class="layui-form-label"><span class="require-item">*</span>调转编号:</label>
 					<div class="layui-input-block">

+ 46 - 0
src/main/webapp/webpage/modules/workofficechange/workOfficeChangeModifyApply.jsp

@@ -48,6 +48,45 @@
                 format: 'yyyy-MM-dd',
                 type : 'date'
             });*/
+			var off = $("#changeOfficeId").val();
+			if(off != ''){
+				$.ajax({
+					type: 'POST',
+					url: '${ctx}/sys/role/getByOfficeId',
+					data: {'id':off},
+					success: function(result){
+						var role__id =  '${workOfficeChange.roleId}';
+						var data1 = result.data;
+						var html = "";
+						for (var e in data1) {
+							if(data1[e].id == role__id){
+								html += '<option value=' + data1[e].id+ ' selected>' + data1[e].name + '</option>'
+							}else{
+								html += '<option value=' + data1[e].id+ '>' + data1[e].name + '</option>'
+							}
+						}
+						$("#roleId").append(html);
+					}
+				});
+			}
+
+			$('#changeOfficeId').on("change",function(){
+				$("#roleId").empty()
+				var officeId = $(this).val()
+				$.ajax({
+					type: 'POST',
+					url: '${ctx}/sys/role/getByOfficeId',
+					data: {'id':officeId},
+					success: function(result){
+						var data1 = result.data
+						var html = "";
+						for (var e in data1) {
+							html += '<option value=' + data1[e].id+ '>' + data1[e].name + '</option>'
+						}
+						$("#roleId").append(html);
+					}
+				});
+			})
         });
 
         function deleteRow(obj,index){
@@ -299,6 +338,13 @@
 										title="部门" url="/sys/office/treeDataAllOffice?type=2" cssClass="form-control required layui-input" allowClear="true" notAllowSelectParent="true" />
 					</div>
 				</div>
+				<div class="layui-item layui-col-sm6 ">
+					<label class="layui-form-label"><span class="require-item">*</span>岗位:</label>
+					<div class="layui-input-block ">
+						<select id="roleId" class="form-control simple-select required" name="roleId">
+						</select>
+					</div>
+				</div>
 				<div class="layui-item layui-col-sm6">
 					<label class="layui-form-label"><span class="require-item">*</span>调转编号:</label>
 					<div class="layui-input-block">

+ 2 - 6
src/main/webapp/webpage/modules/workstaff/infoList.jsp

@@ -17,12 +17,6 @@
         $(document).ready(function() {
 
         });
-
-
-
-        function setParentInfo(ids,names,nos,salarys){
-            return;
-        }
 	</script>
 </head>
 <body>
@@ -44,7 +38,9 @@
                 <%--<table:page page="${page}"></table:page>--%>
                 <%--<div style="clear: both;"></div>--%>
             </div>
+            <a href="javascript:window.opener=null;window.open('','_self');window.close();">关闭</a>
         </div>
+
     </div>
     <div id="changewidth"></div>
 </div>