Commit 79f2e625 authored by 廖旭伟's avatar 廖旭伟

H5登录逻辑修改

parent 789c742f
...@@ -27,6 +27,11 @@ import com.mortals.xhx.base.system.valid.service.ValidCodeService; ...@@ -27,6 +27,11 @@ import com.mortals.xhx.base.system.valid.service.ValidCodeService;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService; import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
import com.mortals.xhx.module.window.model.WindowOwnerEntity;
import com.mortals.xhx.module.window.model.WindowOwnerQuery;
import com.mortals.xhx.module.window.service.WindowOwnerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -36,10 +41,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -36,10 +41,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.*;
import java.util.HashSet; import java.util.stream.Collectors;
import java.util.List;
import java.util.Set;
import static com.mortals.xhx.common.key.ErrorCode.*; import static com.mortals.xhx.common.key.ErrorCode.*;
...@@ -55,6 +58,10 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -55,6 +58,10 @@ public class ApiLoginController extends BaseJsonBodyController {
@Autowired @Autowired
private IDingPersonService dingPersonService; private IDingPersonService dingPersonService;
@Autowired
private StaffService staffService;
@Autowired
private WindowOwnerService windowOwnerService;
@RequestMapping("login") @RequestMapping("login")
...@@ -73,30 +80,55 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -73,30 +80,55 @@ public class ApiLoginController extends BaseJsonBodyController {
} }
UserEntity userEntity = null; UserEntity userEntity = null;
try { try {
if (ObjectUtils.isEmpty(loginForm.getCode())) { // if (ObjectUtils.isEmpty(loginForm.getCode())) {
throw new AppException("钉钉code不能为空!"); // throw new AppException("钉钉code不能为空!");
} // }
//根据code 查询钉钉用户id // //根据code 查询钉钉用户id
Rest<String> personRest = dingPersonService.getPersonByCode(loginForm.getCode()); // Rest<String> personRest = dingPersonService.getPersonByCode(loginForm.getCode());
if (personRest.getCode() != YesNoEnum.YES.getValue()) { // if (personRest.getCode() != YesNoEnum.YES.getValue()) {
throw new AppException(DING_AUTH_FAIL,String.format("获取钉钉用户异常,%s", personRest.getMsg())); // throw new AppException(DING_AUTH_FAIL,String.format("获取钉钉用户异常,%s", personRest.getMsg()));
} // }
userEntity = userService.doLogin(loginName, password, ip); userEntity = userService.doLogin(loginName, password, ip);
//
if (!ObjectUtils.isEmpty(loginForm.getCode())) { // if (!ObjectUtils.isEmpty(loginForm.getCode())) {
//更新绑定钉钉 // //更新绑定钉钉
userEntity.setDingUserId(loginForm.getCode()); // userEntity.setDingUserId(loginForm.getCode());
userService.getUserDao().update(userEntity); // userService.getUserDao().update(userEntity);
// }
StaffEntity staffEntity = null;
if(userEntity.getCustomerId()!=null){
staffEntity = staffService.getCache(userEntity.getCustomerId().toString());
} }
if(staffEntity!=null){
HashSet<Integer> set = new HashSet<>(); WindowOwnerEntity windowOwnerEntity = windowOwnerService.selectOne(new WindowOwnerQuery().staffId(staffEntity.getId()));
set.add(0); if(windowOwnerEntity == null){
set.add(2); userEntity.setUserType(1); //工作人员
set.add(3); }else {
if(windowOwnerEntity.getInspect()==1){
if (ObjectUtils.isEmpty(userEntity.getUserType()) || !set.contains(userEntity.getUserType())) { userEntity.setUserType(3); //具有巡检的窗口负责人
}else {
userEntity.setUserType(2); //普通窗口负责人
}
if(StringUtils.isNotEmpty(windowOwnerEntity.getStaffIds())){
List<Long> staffIdList = Arrays.asList(windowOwnerEntity.getStaffIds().split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
windowOwnerEntity.setStaffCount(staffIdList.size());
}else {
windowOwnerEntity.setStaffCount(0);
}
windowOwnerEntity.setWindowOwnerDetailList(null);
data.put("windowOwner", windowOwnerEntity);
}
}else {
throw new AppException("当前用户不支持H5登录!"); throw new AppException("当前用户不支持H5登录!");
} }
// HashSet<Integer> set = new HashSet<>();
// set.add(0);
// set.add(2);
// set.add(3);
//
// if (ObjectUtils.isEmpty(userEntity.getUserType()) || !set.contains(userEntity.getUserType())) {
// throw new AppException("当前用户不支持H5登录!");
// }
data.put("id", userEntity.getId()); data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType()); data.put("userType", userEntity.getUserType());
......
...@@ -46,4 +46,11 @@ public interface WindowOwnerService extends ICRUDService<WindowOwnerEntity, Long ...@@ -46,4 +46,11 @@ public interface WindowOwnerService extends ICRUDService<WindowOwnerEntity, Long
Rest<List<String>> getPerformMonthList(Context context); Rest<List<String>> getPerformMonthList(Context context);
/**
* 获取负责人管辖的工作人员
* @param id
* @return
*/
List<StaffEntity> getStaffList(Long id);
} }
\ No newline at end of file
...@@ -247,7 +247,7 @@ public class WindowOwnerServiceImpl extends AbstractCRUDServiceImpl<WindowOwnerD ...@@ -247,7 +247,7 @@ public class WindowOwnerServiceImpl extends AbstractCRUDServiceImpl<WindowOwnerD
Set<String> performMonthSet = collect.keySet(); Set<String> performMonthSet = collect.keySet();
collectSet.addAll(performMonthSet); collectSet.addAll(performMonthSet);
//查询所有窗口人员汇总表 //查询所有窗口人员汇总表
WindowWorkmanPerformQuery windowWorkmanPerformQuery = new WindowWorkmanPerformQuery(); WindowWorkmanPerformQuery windowWorkmanPerformQuery = new WindowWorkmanPerformQuery();
windowWorkmanPerformQuery.setOwnerId(context.getUser().getCustomerId()); windowWorkmanPerformQuery.setOwnerId(context.getUser().getCustomerId());
Map<String, List<WindowWorkmanPerformEntity>> workmanMonthSet = windowWorkmanPerformService.find(windowWorkmanPerformQuery).stream().collect(Collectors.groupingBy(item -> item.getYear() + "-" + item.getMonth())); Map<String, List<WindowWorkmanPerformEntity>> workmanMonthSet = windowWorkmanPerformService.find(windowWorkmanPerformQuery).stream().collect(Collectors.groupingBy(item -> item.getYear() + "-" + item.getMonth()));
...@@ -317,4 +317,20 @@ public class WindowOwnerServiceImpl extends AbstractCRUDServiceImpl<WindowOwnerD ...@@ -317,4 +317,20 @@ public class WindowOwnerServiceImpl extends AbstractCRUDServiceImpl<WindowOwnerD
} }
return entity; return entity;
} }
@Override
public List<StaffEntity> getStaffList(Long key) {
WindowOwnerEntity entity = this.dao.get(key);
if(entity!=null){
if(StringUtils.isNotEmpty(entity.getStaffIds())){
List<Long> staffIdList = Arrays.asList(entity.getStaffIds().split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
List<StaffEntity> staffEntityList = staffService.find(new StaffQuery().idList(staffIdList));
return staffEntityList;
}else {
return Collections.emptyList();
}
}else {
return Collections.emptyList();
}
}
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package com.mortals.xhx.module.window.web; ...@@ -3,6 +3,8 @@ package com.mortals.xhx.module.window.web;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.site.model.SiteQuery; import com.mortals.xhx.base.system.site.model.SiteQuery;
...@@ -200,5 +202,28 @@ public class WindowOwnerController extends BaseCRUDJsonBodyMappingController<Win ...@@ -200,5 +202,28 @@ public class WindowOwnerController extends BaseCRUDJsonBodyMappingController<Win
return jsonObject.toJSONString(); return jsonObject.toJSONString();
} }
/**
* 查询窗口负责人下属列表
*/
@PostMapping(value = "staffList")
@UnAuth
public Rest<List<StaffEntity>> staffList(@RequestBody WindowOwnerEntity query){
Rest<List<StaffEntity>> ret = new Rest();
String busiDesc = "查询当前负责人负责的人员列表" + this.getModuleDesc();
Context context = this.getContext();
Map<String, Object> model = new HashMap();
int code = 1;
try {
List<StaffEntity> result = this.getService().getStaffList(query.getId());
ret.setData(result);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
code = -1;
this.doException(this.request, busiDesc, model, e);
}
ret.setCode(code);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
} }
\ No newline at end of file
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<if test="checkTimeEnd != null and checkTimeEnd!=''"> AND happenTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if> <if test="checkTimeEnd != null and checkTimeEnd!=''"> AND happenTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{checkTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') </if>
<if test="createUserId != null and createUserId!=''"> AND createUserId = #{createUserId} </if> <if test="createUserId != null and createUserId!=''"> AND createUserId = #{createUserId} </if>
UNION UNION
SELECT id,recordId,staffId,staffName,workNum,deptId,deptName,ruleId,ruleName,subAddType,checkStatus,checkResult,auditStatus,createTime,score,subMethod,checkTime, deductTime,6 AS checkType ,'complain' AS performType,updateTime FROM mortals_xhx_check_complain_record WHERE 1=1 SELECT id,recordId,staffId,staffName,workNum,deptId,deptName,ruleId,ruleName,subAddType,checkStatus,checkResult,auditStatus,createTime,score,subMethod,checkTime, deductTime,2 AS checkType ,'complain' AS performType,updateTime FROM mortals_xhx_check_complain_record WHERE 1=1
<if test="checkStatus != null and checkStatus!=''"> AND checkStatus = #{checkStatus} </if> <if test="checkStatus != null and checkStatus!=''"> AND checkStatus = #{checkStatus} </if>
<if test="subMethod != null and subMethod!=''"> AND subMethod = #{subMethod} </if> <if test="subMethod != null and subMethod!=''"> AND subMethod = #{subMethod} </if>
<if test="subAddType != null and subAddType!=''"> AND subAddType = #{subAddType} </if> <if test="subAddType != null and subAddType!=''"> AND subAddType = #{subAddType} </if>
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
p.recordId = w.id p.recordId = w.id
AND d.performId = w.id AND d.performId = w.id
AND s.id = d.staffId AND s.id = d.staffId
AND checkStatus = 2 AND p.checkStatus = 2
AND manageCheckResult = 1 AND p.manageCheckResult = 1
<if test="recordId != null and recordId!=''"> AND p.recordId = #{recordId} </if> <if test="recordId != null and recordId!=''"> AND p.recordId = #{recordId} </if>
<if test="year != null and year!=''"> AND p.`year` = #{year} </if> <if test="year != null and year!=''"> AND p.`year` = #{year} </if>
<if test="month != null and month!=''"> AND p.`month` = #{month} </if> <if test="month != null and month!=''"> AND p.`month` = #{month} </if>
......
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