| 
					
				 | 
			
			
				@@ -4,6 +4,7 @@ import com.ruoyi.basicData.domain.FleetDriverMsg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.basicData.mapper.FleetDriverMsgMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.basicData.service.IFleetDriverMsgService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.core.domain.AjaxResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.core.domain.entity.SysRole; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.core.domain.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.utils.SecurityUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -12,6 +13,7 @@ import com.ruoyi.orderPlan.domain.Ftmsorderbillscars; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.orderPlan.mapper.FtmsorderbillscarsMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.system.domain.SysUserPost; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.system.domain.SysUserRole; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.system.mapper.SysRoleMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.system.mapper.SysUserMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.system.mapper.SysUserPostMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.system.mapper.SysUserRoleMapper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -38,6 +40,9 @@ public class FleetDriverMsgServiceImpl implements IFleetDriverMsgService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private FleetDriverMsgMapper fleetDriverMsgMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysRoleMapper roleMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private FtmsorderbillscarsMapper ftmsorderbillscarsMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -111,10 +116,10 @@ public class FleetDriverMsgServiceImpl implements IFleetDriverMsgService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sysUser.setDeptId(120L); // 当前给定、后期修改 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Long[] rolr = {110L}; // 当前给定、后期修改 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sysUser.setRoleIds(rolr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 查询是否有用户提前关注公众号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 查询是否有用户提前关注小程序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             SysUser user = userMapper.selectUserByTel(fleetDriverMsg.getTel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (StringUtils.isNotNull(user)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // 该用户提前关注公众号了 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 该用户提前关注小程序了 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 sysUser.setOpenId(user.getOpenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (StringUtils.isNotNull(user.getSessionKey())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     sysUser.setSessionKey(user.getSessionKey()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -122,15 +127,21 @@ public class FleetDriverMsgServiceImpl implements IFleetDriverMsgService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 userMapper.deleteUserById(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 新增用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            int rows = userMapper.insertUser(sysUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (rows <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            userMapper.insertUser(sysUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 新增用户与角色管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 查询是否存在车队 角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SysRole role = roleMapper.selectRoleByName("司机"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.isNull(role)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return AjaxResult.error("请填写必填项"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("未找到司机角色,请创建司机角色后提交"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 新增用户岗位关联 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            insertUserPost(sysUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 新增用户与角色管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            insertUserRole(sysUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 创建用户与角色关联 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<SysUserRole> list = new ArrayList<SysUserRole>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SysUserRole sysUserRole = new SysUserRole(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sysUserRole.setRoleId(role.getRoleId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sysUserRole.setUserId(sysUser.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.add(sysUserRole); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            userRoleMapper.batchUserRole(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fleetDriverMsg.setCreateBy(SecurityUtils.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fleetDriverMsg.setCreatTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             fleetDriverMsgMapper.insertFleetDriverMsg(fleetDriverMsg); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -222,49 +233,4 @@ public class FleetDriverMsgServiceImpl implements IFleetDriverMsgService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return fleetDriverMsgMapper.selectFleetDriverMsgIdNameList(fleetDriverMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 新增用户岗位信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param user 用户对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void insertUserPost(SysUser user) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Long[] posts = user.getPostIds(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (StringUtils.isNotNull(posts)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 新增用户与岗位管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<SysUserPost> list = new ArrayList<SysUserPost>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (Long postId : posts) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                SysUserPost up = new SysUserPost(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                up.setUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                up.setPostId(postId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                list.add(up); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                userPostMapper.batchUserPost(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 新增用户角色信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param user 用户对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void insertUserRole(SysUser user) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Long[] roles = user.getRoleIds(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (StringUtils.isNotNull(roles)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 新增用户与角色管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<SysUserRole> list = new ArrayList<SysUserRole>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (Long roleId : roles) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                SysUserRole ur = new SysUserRole(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ur.setUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ur.setRoleId(roleId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                list.add(ur); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                userRoleMapper.batchUserRole(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |