LiGuang 3 年 前
コミット
d2a3ddded5

+ 1 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/userShift/mapper/UserShiftMapper.java

@@ -53,5 +53,6 @@ public interface UserShiftMapper extends BaseMapper<UserShift> {
 
     List<String>uids(@Param("depts") List<String> depts);
 
+    //统计每月班次有多少次人员排班
    Map<String,Object>ShiftCount(@Param("id")String id,@Param("date")String date,@Param("deptids")List<String>deptids);
 }

+ 10 - 7
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/userShift/mapper/xml/UserShiftMapper.xml

@@ -151,18 +151,21 @@ order by a.shift_date desc
     </select>
     <select id="ShiftCount" resultType="java.util.Map">
         select count(shift_id) as 'count' from geke_user_shift a
-        left join (
-        select distinct a.id from sys_user a left join sys_user_depart b on a.id=b.user_id where a.del_flag='0' and a.employment_status='10'
+        where 1=1
+        <if test="id!=null and ''!=id">
+            and shift_id=#{id}
+        </if>
         <if test="deptids!=null and deptids.size()>0">
+            and a.user_id in (select distinct a.id
+            FROM sys_user a
+            LEFT JOIN sys_user_depart b
+            ON a.id=b.user_id
+            WHERE a.del_flag='0' and a.employment_status='10'
             and b.dep_id in
             <foreach collection="deptids" index="index" item="id" open="(" separator="," close=")">
                 #{id}
             </foreach>
-        </if>
-        ) c on a.user_id=c.id
-        where 1=1
-        <if test="id!=null and ''!=id">
-            and shift_id=#{id}
+            )
         </if>
 
         <if test="date!=null and ''!=date">

+ 90 - 84
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -32,10 +32,7 @@ import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.model.SysLoginModel;
 import org.jeecg.modules.system.service.*;
-import org.jeecg.modules.system.util.AES;
-import org.jeecg.modules.system.util.RandImageUtil;
-import org.jeecg.modules.system.util.RestTemplateUtil;
-import org.jeecg.modules.system.util.TokenInfo;
+import org.jeecg.modules.system.util.*;
 import org.jeecg.modules.system.vo.WeixinUser;
 import org.jeecg.modules.system.vo.WeixinXCX;
 import org.springframework.beans.BeanUtils;
@@ -46,6 +43,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
+import java.io.IOException;
 import java.util.*;
 
 /**
@@ -87,9 +85,10 @@ public class LoginController {
 
 	@ApiOperation("登录接口")
 	@RequestMapping(value = "/login", method = RequestMethod.POST)
-	public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel){
+	public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) throws IOException {
 		Result<JSONObject> result = new Result<JSONObject>();
 		String username = sysLoginModel.getUsername();
+		System.out.println("=================="+username+"=================");
 		String password = sysLoginModel.getPassword();
 		//update-begin--Author:scott  Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
 		//前端密码加密,后端进行密码解密
@@ -97,19 +96,19 @@ public class LoginController {
 		//update-begin--Author:scott  Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
 
 		//update-begin-author:taoyan date:20190828 for:校验验证码
-		String captcha = sysLoginModel.getCaptcha();
-		if(captcha==null){
-//            result.error500("验证码无效");
-//            return result;
-		}
-		String lowerCaseCaptcha = captcha.toLowerCase();
-		String realKey = MD5Util.MD5Encode(lowerCaseCaptcha+sysLoginModel.getCheckKey(), "utf-8");
-		Object checkCode = redisUtil.get(realKey);
-		//当进入登录页时,有一定几率出现验证码错误 #1714
-		if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
-//			result.error500("验证码错误");
-//			return result;
-		}
+//		String captcha = sysLoginModel.getCaptcha();
+//		if(captcha==null){
+////            result.error500("验证码无效");
+////            return result;
+//		}
+//		String lowerCaseCaptcha = captcha.toLowerCase();
+//		String realKey = MD5Util.MD5Encode(lowerCaseCaptcha+sysLoginModel.getCheckKey(), "utf-8");
+//		Object checkCode = redisUtil.get(realKey);
+//		//当进入登录页时,有一定几率出现验证码错误 #1714
+//		if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
+////			result.error500("验证码错误");
+////			return result;
+//		}
 		//update-end-author:taoyan date:20190828 for:校验验证码
 
 		//1. 校验用户是否有效
@@ -117,6 +116,13 @@ public class LoginController {
 		LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
 		queryWrapper.eq(SysUser::getUsername,username);
 		SysUser sysUser = sysUserService.getOne(queryWrapper);
+
+//		String auts = weixinUserService.auts(username,"2");
+//		System.out.println(auts);
+//		SysUser sysUser=null;
+//		if (auts!=null){
+//			sysUser = sysUserService.getById(auts);
+//		}
 		//update-end-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bug,if条件永远为false
 		result = sysUserService.checkUserIsEffective(sysUser);
 		if(!result.isSuccess()) {
@@ -384,7 +390,7 @@ public class LoginController {
 		String token = JwtUtil.sign(username, syspassword);
 		// 设置token缓存有效时间
 		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
-		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
+		//redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
 
 		// 获取用户部门信息
 		JSONObject obj = new JSONObject();
@@ -460,7 +466,7 @@ public class LoginController {
 	public Result<JSONObject> mLogins(String code, HttpSession session,HttpServletRequest request) throws Exception {
 		Result<JSONObject> result = new Result<JSONObject>();
 		System.out.println("============code= "+code+"=============");
-		String auts = weixinUserService.auts(code);
+		String auts = weixinUserService.auts(code,"1");
 		System.out.println(auts);
 		SysUser byId=null;
 		if (auts!=null){
@@ -502,74 +508,27 @@ public class LoginController {
 	public Result<JSONObject> mLogin(@RequestBody SysLoginModel sysLoginModel, HttpSession session,HttpServletRequest request) throws Exception {
 		Result<JSONObject> result = new Result<JSONObject>();
 		String username = sysLoginModel.getUsername();
-		System.out.println("============code= "+username+"=============");
-		String auts = weixinUserService.auts(username);
-		System.out.println(auts);
-		SysUser byId=null;
-		if (auts!=null){
-			byId = sysUserService.getById(auts);
-		}
-//		//1. 校验用户是否有效
-		result = sysUserService.checkUserIsEffective(byId);
-		if(!result.isSuccess()) {
-			return result;
-		}
-		String userpassword = PasswordUtil.encrypt(byId.getUsername(), byId.getPassword(), byId.getSalt());
-		JSONObject obj = new JSONObject();
-//		//用户登录信息
-		obj.put("userInfo", byId);
-//
-//		// 生成token
-		String token = JwtUtil.sign(byId.getUsername(), userpassword);
-//		// 设置超时时间
-		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
-		//token 信息
-		obj.put("token", token);
-		obj.put("sessionId",session.getId());
-		result.setResult(obj);
-		result.setSuccess(true);
-		result.setCode(200);
-		Map<String,Object>map=new HashMap<>();
-		List<TokenInfo>list=new ArrayList<>();
-		TokenInfo tokenInfo=new TokenInfo();
-//		String password = sysLoginModel.getPassword();
-		//1. 校验用户是否有效
-//		SysUser sysUser = sysUserService.getUserByName(username);
-//		result = sysUserService.checkUserIsEffective(sysUser);
-//		if(!result.isSuccess()) {
-//			return result;
+//		System.out.println("============code= "+username+"=============");
+//		String auts = weixinUserService.auts(username,"1");
+//		System.out.println(auts);
+//		SysUser byId=null;
+//		if (auts!=null){
+//			byId = sysUserService.getById(auts);
 //		}
-//
-//		//2. 校验用户名或密码是否正确
-//		String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
-//		String syspassword = sysUser.getPassword();
-//		if (!syspassword.equals(userpassword)) {
-//			result.error500("用户名或密码错误");
+////		//1. 校验用户是否有效
+//		result = sysUserService.checkUserIsEffective(byId);
+//		if(!result.isSuccess()) {
 //			return result;
 //		}
-//
-//		String orgCode = sysUser.getOrgCode();
-//		if(oConvertUtils.isEmpty(orgCode)) {
-//			//如果当前用户无选择部门 查看部门关联信息
-//			List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
-//			if (departs == null || departs.size() == 0) {
-//				result.error500("用户暂未归属部门,不可登录!");
-//				return result;
-//			}
-//			orgCode = departs.get(0).getOrgCode();
-//			sysUser.setOrgCode(orgCode);
-//			this.sysUserService.updateUserDepart(username, orgCode);
-//		}
+//		String userpassword = PasswordUtil.encrypt(byId.getUsername(), byId.getPassword(), byId.getSalt());
 //		JSONObject obj = new JSONObject();
-//		//用户登录信息
-//		obj.put("userInfo", sysUser);
-//
-//		// 生成token
-//		String token = JwtUtil.sign(username, syspassword);
-//		// 设置超时时间
+////		//用户登录信息
+//		obj.put("userInfo", byId);
+////
+////		// 生成token
+//		String token = JwtUtil.sign(byId.getUsername(), userpassword);
+////		// 设置超时时间
 //		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
-//		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
-//
 //		//token 信息
 //		obj.put("token", token);
 //		obj.put("sessionId",session.getId());
@@ -579,7 +538,54 @@ public class LoginController {
 //		Map<String,Object>map=new HashMap<>();
 //		List<TokenInfo>list=new ArrayList<>();
 //		TokenInfo tokenInfo=new TokenInfo();
-//		baseCommonService.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null);
+		String password = sysLoginModel.getPassword();
+		//1. 校验用户是否有效
+		SysUser sysUser = sysUserService.getUserByName(username);
+		result = sysUserService.checkUserIsEffective(sysUser);
+		if(!result.isSuccess()) {
+			return result;
+		}
+
+		//2. 校验用户名或密码是否正确
+		String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
+		String syspassword = sysUser.getPassword();
+		if (!syspassword.equals(userpassword)) {
+			result.error500("用户名或密码错误");
+			return result;
+		}
+
+		String orgCode = sysUser.getOrgCode();
+		if(oConvertUtils.isEmpty(orgCode)) {
+			//如果当前用户无选择部门 查看部门关联信息
+			List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
+			if (departs == null || departs.size() == 0) {
+				result.error500("用户暂未归属部门,不可登录!");
+				return result;
+			}
+			orgCode = departs.get(0).getOrgCode();
+			sysUser.setOrgCode(orgCode);
+			this.sysUserService.updateUserDepart(username, orgCode);
+		}
+		JSONObject obj = new JSONObject();
+		//用户登录信息
+		obj.put("userInfo", sysUser);
+
+		// 生成token
+		String token = JwtUtil.sign(username, syspassword);
+		// 设置超时时间
+		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
+		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
+
+		//token 信息
+		obj.put("token", token);
+		obj.put("sessionId",session.getId());
+		result.setResult(obj);
+		result.setSuccess(true);
+		result.setCode(200);
+		Map<String,Object>map=new HashMap<>();
+		List<TokenInfo>list=new ArrayList<>();
+		TokenInfo tokenInfo=new TokenInfo();
+		baseCommonService.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null);
 		return result;
 	}
 

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -692,6 +692,19 @@ public class SysUserController {
         ExportParams exportParams = new ExportParams("员工列表数据", "导出人:"+user.getRealname(), "导出信息");
         exportParams.setImageBasePath(upLoadPath);
         mv.addObject(NormalExcelConstants.PARAMS, exportParams);
+        if (sysUser.getOrgCodeTxt().equals("空白模板")){
+            SysUser u=new SysUser();
+            u.setRealname("例:李四");
+            u.setEgName("例:cent");
+            u.setEmail("例:cent.li@gksports.com.cn");
+            u.setWorkNo("200001");
+            u.setSfzCode("430424197506127677");
+            u.setCategory(101);
+            u.setEmploymentStatus(10);
+            u.setOrgCodeTxt("例:销售部,信息部");
+            pageList=new ArrayList<>();
+            pageList.add(u);
+        }
         mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
 
         return mv;
@@ -721,6 +734,7 @@ public class SysUserController {
             params.setNeedSave(true);
             try {
                 List<SysUser> listSysUsers = ExcelImportUtil.importExcel(file.getInputStream(), SysUser.class, params);
+                listSysUsers.remove(0);
                 for (int i = 0; i < listSysUsers.size(); i++) {
                     SysUser sysUserExcel = listSysUsers.get(i);
                     CodeVo codeVo=new CodeVo();

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysWeixinController.java

@@ -217,7 +217,7 @@ public class SysWeixinController {
     @RequestMapping("/autst")
     public  Map<String,Object> autst( String code) throws IOException {
         Map<String,Object>map=new HashMap<>();
-            weixinUserService.auts(code);
+            weixinUserService.auts(code,"1");
         return map;
     }
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysUser.java

@@ -138,7 +138,7 @@ public class SysUser implements Serializable {
     @Excel(name = "*部门", width = 15)
     private transient String orgCodeTxt;
 
-    @Excel(name = "银行账号", width = 15)
+    @Excel(name = "*银行账号", width = 15)
     @TableField(typeHandler = AESEncryptHandler.class)
     private String bankCard;
 

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IWeixinUserService.java

@@ -47,6 +47,6 @@ public interface IWeixinUserService {
 
         //微信补卡信息
         public Map<String, Object> WeixinUpCard() throws IOException, ParseException;
-
-        public String auts(String code) throws IOException;
+        //企业微信获取用户信息
+        public String auts(String code,String type) throws IOException;
 }

+ 16 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/WeixinUserImpl.java

@@ -262,14 +262,22 @@ public class WeixinUserImpl implements IWeixinUserService{
      * @return
      * @throws IOException
      */
-    public Map<String,Object>WeixinUserid(String code) throws IOException {
+    public Map<String,Object>WeixinUserid(String code,String type) throws IOException {
         Map mapTypes = null;
         String errcode = "";
+        String token="";
+        if (type.equals("1")){
+            UrlData.getH5Token();
+            token=UrlData.H5Token;
+        }else {
+            UrlData.getWebToken();
+            token=UrlData.WebToken;
+        }
         Map<String, Object> headers = Maps.newHashMap();//设置请求头
         Map<String, Object> map = Maps.newHashMap();
         headers.put("Content-Type", "application/json; charset=utf-8");
         try {
-            String createDeptUrl = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token="+UrlData.H5Token+"&code="+code+"";
+            String createDeptUrl = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token="+token+"&code="+code+"";
             String res = UrlData.toAuth(createDeptUrl);
             mapTypes = JSON.parseObject(res);
             System.out.println("================"+res+"==================");
@@ -622,7 +630,10 @@ public class WeixinUserImpl implements IWeixinUserService{
         Map<String,Object> map=new HashMap<>();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");//日期格式化
         SysUser userByid = sysUserService.getUserByid(id);
-        Date entryDate = userByid.getEntryDate();
+        Date entryDate = null;
+        if (userByid!=null){
+            entryDate=userByid.getEntryDate();
+        }
         Date newDate=new Date();
         int year=0;
         if (entryDate!=null){
@@ -855,10 +866,9 @@ public class WeixinUserImpl implements IWeixinUserService{
     }
 
     @Override
-    public String auts(String code) throws IOException {
-        UrlData.getH5Token();
+    public String auts(String code,String type) throws IOException {
         String msg="";
-        Map<String, Object> map = WeixinUserid(code);
+        Map<String, Object> map = WeixinUserid(code,type);
         if (map.get("userid")!=null&&!map.get("userid").equals("")){
             msg=map.get("userid").toString();
         }

+ 13 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/UrlData.java

@@ -41,6 +41,8 @@ public class UrlData {
 
     public static String H5Token="";
 
+    public  static String WebToken="";
+
 
     private static Gson gson = new Gson();
 
@@ -115,6 +117,17 @@ public class UrlData {
         H5Token= map.get("access_token").toString();
     }
 
+    //Webtoken
+    public  static   void getWebToken() throws IOException {
+        UrlData uData = new UrlData();
+        uData.setGet_Token_Url("wwd372e7740b9b586f","rgwU8GJ5RAc7ir7TRpZ4c_ttoRgK5uaoU_4j1bVHlgY");
+        String resp = toAuth(uData.getGet_Token_Url());
+        Map<String, Object> map = gson.fromJson(resp,
+                new TypeToken<Map<String, Object>>() {
+                }.getType());
+        WebToken= map.get("access_token").toString();
+    }
+
     //获取返回的结果集并把access_token取出来
     public static String toAuth(String Get_Token_Url) throws IOException {
         CloseableHttpClient aDefault = HttpClients.createDefault();