diff --git a/src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java b/src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java index 04b06e0..b00339f 100644 --- a/src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java +++ b/src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java @@ -25,11 +25,34 @@ public class AsraOpQueryReq extends BaseRequest{ /**员工邮箱*/ private String email; - + /**父级ID 顶级为-1*/ private Long parentId; - - + + + + + /**员工idlist*/ + private List opIdLists; + + /**员工idlist*/ + private List opParentIdLists; + + public List getOpIdLists() { + return opIdLists; + } + + public void setOpIdLists(List opIdLists) { + this.opIdLists = opIdLists; + } + + public List getOpParentIdLists() { + return opParentIdLists; + } + + public void setOpParentIdLists(List opParentIdLists) { + this.opParentIdLists = opParentIdLists; + } public Long getParentId() { return parentId; diff --git a/src/main/java/com/zteits/oa/api/service/report/query/AsraOpRelationsQueryService.java b/src/main/java/com/zteits/oa/api/service/report/query/AsraOpRelationsQueryService.java deleted file mode 100644 index 93233b5..0000000 --- a/src/main/java/com/zteits/oa/api/service/report/query/AsraOpRelationsQueryService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.zteits.oa.api.service.report.query; - -import com.zteits.oa.api.base.bean.BizResult; -import com.zteits.oa.api.base.bean.PageBean; -import com.zteits.oa.api.dto.asraop.AsraOpDTO; -import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; -import com.zteits.oa.api.dto.asraoprelations.AsraOpRelationsDTO; -import com.zteits.oa.api.dto.asraoprelations.param.AsraOpRelationsQueryReq; - -import java.util.List; - -/** - * 员工关系表查询service.
- * - * Copyright: Copyright (c) 2017 ZTE-ITS - * - * @ClassName: AmountUtils.java - * @Description: - * @version: v1.0.0 - * @author: wangfs - * @date: 2018年7月30日 - * Modification History: - * Date Author Version Description - *---------------------------------------------------------* - * 2018年7月30日 xiejp v1.0.0 创建 - */ -public interface AsraOpRelationsQueryService { - - /** - * 根据登录工号查询管理的员工信息 - * @param - * @return - * @Author: xiejianpeng - * @Date: 2018/7/31 10:33 - * - */ - BizResult> queryAsraOpRelations(AsraOpRelationsQueryReq asraOpRelationsQueryReq); -} diff --git a/src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java b/src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java index 2e4b676..5635cec 100644 --- a/src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java +++ b/src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java @@ -4,11 +4,11 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import com.xiaoleilu.hutool.util.CollectionUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.xiaoleilu.hutool.date.DateUtil; -import com.xiaoleilu.hutool.util.CollectionUtil; import com.zteits.oa.api.dto.asradaily.param.AsraDailyForTotalNumAndDetailReq; import com.zteits.oa.api.dto.asradaily.param.AsraDailyQueryReq; import com.zteits.oa.report.dao.AsraDailyDao; @@ -69,13 +69,13 @@ public class AsraDailyDaoImpl implements AsraDailyDao{ public AsraDailyOpNumForCurrentDayDO queryAsraDailyOpNumForCurrentDay(AsraDailyForTotalNumAndDetailReq request) { AsraDailyOpNumForCurrentDayDO asraDailyOpNumForCurrentDayDO = new AsraDailyOpNumForCurrentDayDO(); List opList = new ArrayList<>(); - + //1.总人数获取 int employeeTotal = 0; if(CollectionUtil.isNotEmpty(request.getOpIds())){ employeeTotal = request.getOpIds().size(); } - + //2.查询今日日报填写人数 AsraDailyExample exampleTwo = new AsraDailyExample(); exampleTwo.createCriteria().andAsarOpIdIn(opList) diff --git a/src/main/java/com/zteits/oa/report/web/AsraOpController.java b/src/main/java/com/zteits/oa/report/web/AsraOpController.java index ebe5510..aeab69c 100644 --- a/src/main/java/com/zteits/oa/report/web/AsraOpController.java +++ b/src/main/java/com/zteits/oa/report/web/AsraOpController.java @@ -1,31 +1,23 @@ package com.zteits.oa.report.web; import com.alibaba.fastjson.JSONObject; -import com.xiaoleilu.hutool.util.CollectionUtil; import com.zteits.oa.api.base.bean.BizResult; import com.zteits.oa.api.base.bean.PageBean; import com.zteits.oa.api.base.constants.SessionEnum; import com.zteits.oa.api.dto.asraop.AsraOpDTO; import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; -import com.zteits.oa.api.dto.asraoprelations.AsraOpRelationsDTO; -import com.zteits.oa.api.dto.asraoprelations.param.AsraOpRelationsQueryReq; import com.zteits.oa.api.service.report.query.AsraOpQueryService; -import com.zteits.oa.api.service.report.query.AsraOpRelationsQueryService; import com.zteits.oa.report.web.vo.EasyUIDataGridVO; import io.swagger.annotations.Api; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cglib.core.CollectionUtils; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.util.ArrayList; -import java.util.List; @Api(value = "日报系统-员工管理", description = "日报系统-员工管理") @RestController @@ -38,15 +30,12 @@ public class AsraOpController extends BizController { private AsraOpQueryService asraOpQueryService; - - - @RequestMapping(value="/queryAsraOpPage",method = RequestMethod.POST) public BizResult> queryAsraOpPage(@RequestBody AsraOpQueryReq asraOpQueryReq, HttpServletRequest request) throws IllegalAccessException, InstantiationException { logger.info("日报系统-员工管理-根据登录人分页查询员工信息入参:{}", JSONObject.toJSON(asraOpQueryReq)); /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); - asraOpQueryReq.setId(asraOpDTO.getId()); + asraOpQueryReq.setOpIdLists(asraOpDTO.getOpIds()); BizResult> result = asraOpQueryService.queryAsraOpForPage(asraOpQueryReq); logger.info("日报系统-员工管理-根据登录人分页查询员工信息结果:{}", JSONObject.toJSON(result)); return returnJqGridData(result, AsraOpDTO.class); diff --git a/src/main/java/com/zteits/oa/report/web/OAuthController.java b/src/main/java/com/zteits/oa/report/web/OAuthController.java index d0391e9..5dcc9f8 100644 --- a/src/main/java/com/zteits/oa/report/web/OAuthController.java +++ b/src/main/java/com/zteits/oa/report/web/OAuthController.java @@ -1,6 +1,5 @@ package com.zteits.oa.report.web; - import java.util.ArrayList; import java.util.List; @@ -15,10 +14,10 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import com.alibaba.fastjson.JSONObject; import com.xiaoleilu.hutool.util.CollectionUtil; import com.zteits.oa.api.base.bean.BizResult; +import com.zteits.oa.api.base.bean.PageBean; import com.zteits.oa.api.base.constants.ErrorType; import com.zteits.oa.api.base.constants.SessionEnum; import com.zteits.oa.api.dto.asraop.AsraOpDTO; @@ -28,7 +27,6 @@ import com.zteits.oa.api.dto.asraop.param.LoginOauthReq; import com.zteits.oa.api.service.report.query.AsraOpQueryService; import com.zteits.oa.report.vo.OAuthResult; import com.zteits.oa.util.MD5Utils; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -94,8 +92,10 @@ public class OAuthController { List opIds = new ArrayList<>(); opIds.add(asraOpDTO.getId()); + List opParentIds = new ArrayList<>(); + opParentIds.add(asraOpDTO.getId()); /**递归查询员工ids.*/ - opIds = queryOpTreeByOpId(asraOpDTO.getId()); + opIds = queryOpTreeByOpIds(opParentIds,opIds); logger.info("---获取到的opIds={}",JSONObject.toJSON(opIds)); asraOpDTO.setOpIds(opIds); HttpSession session = request.getSession(); @@ -117,7 +117,7 @@ public class OAuthController { } /** * 退出登录 - * @param req + * @param * @return * 2018年7月31日 wangfs.
*/ @@ -135,9 +135,33 @@ public class OAuthController { return new OAuthResult<>(true); } + + private List queryOpTreeByOpIds(List queryOpList,List opList){ + if(queryOpList != null && CollectionUtil.isNotEmpty(queryOpList)){ + AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq(); + asraOpQueryRe.setOpParentIdLists(queryOpList); + asraOpQueryRe.getBaseRequest().setPageNum(1); + asraOpQueryRe.getBaseRequest().setPageSize(0); + BizResult> asraOpReult = asraOpQueryService.queryAsraOpForPage(asraOpQueryRe); + if(asraOpReult != null && asraOpReult.getData() != null){ + queryOpList.clear(); + List data = asraOpReult.getData().getDataList(); + if(CollectionUtil.isNotEmpty(data)){ + for(AsraOpDTO dto:data){ + queryOpList.add(dto.getId()); + opList.add(dto.getId()); + } + } + queryOpTreeByOpIds(queryOpList,opList); + } + } + return opList; + } + + /** * 递归查询员工id.
- * @param parentOpId + * @param * @param opList * @return * 2018年8月2日 wangfs.
@@ -160,66 +184,65 @@ public class OAuthController { } return rootAllList; } - - /** - * 递归查找一级以下的用户 - * @param parentId - * @return - * 2018年8月2日 wangfs.
- */ - private List getChildOpIds(Long parentId,List childOpIds){ - AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq(); - asraOpQueryRe.setParentId(parentId); - BizResult> asraOpReult = asraOpQueryService.queryAsraOpByParentId(asraOpQueryRe); - if(asraOpReult != null && CollectionUtil.isNotEmpty(asraOpReult.getData())){ - List list = asraOpReult.getData(); - for(AsraOpDTO asraOpDTO :list){ - if(asraOpDTO == null){ - continue; - } - childOpIds.add(asraOpDTO.getId()); - } + /** + * 递归查找一级以下的用户 + * @param parentId + * @return + * 2018年8月2日 wangfs.
+ */ + private List getChildOpIds(Long parentId,List childOpIds){ + AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq(); + asraOpQueryRe.setParentId(parentId); + BizResult> asraOpReult = asraOpQueryService.queryAsraOpByParentId(asraOpQueryRe); + if(asraOpReult != null && CollectionUtil.isNotEmpty(asraOpReult.getData())){ + List list = asraOpReult.getData(); + for(AsraOpDTO asraOpDTO :list){ + if(asraOpDTO == null){ + continue; + } + childOpIds.add(asraOpDTO.getId()); + } + + //遍历下一级 + if(CollectionUtil.isNotEmpty(childOpIds)){ + for(Long opId:childOpIds){ + if(opId != null && !opId.equals(parentId)){ + getChildOpIds(opId,childOpIds); + } + break; + + } + + } + } + + return childOpIds; + } + + /** + * 查找登陆用户下一级用户 + * @param opId + * @param opList + * @return + * 2018年8月2日 wangfs.
+ */ + private List getRootOpIds(Long parentId){ + List opList = new ArrayList<>(); + AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq(); + asraOpQueryRe.setParentId(parentId); + BizResult> asraOpReult = asraOpQueryService.queryAsraOpByParentId(asraOpQueryRe); + if(asraOpReult != null && CollectionUtil.isNotEmpty(asraOpReult.getData())){ + List list = asraOpReult.getData(); + for(AsraOpDTO asraOpDTO :list){ + if(asraOpDTO == null){ + continue; + } + opList.add(asraOpDTO.getId()); + } + } + return opList; + } + - //遍历下一级 - if(CollectionUtil.isNotEmpty(childOpIds)){ - for(Long opId:childOpIds){ - if(opId != null && !opId.equals(parentId)){ - getChildOpIds(opId,childOpIds); - } - break; - - } - - } - } - - return childOpIds; - } - - /** - * 查找登陆用户下一级用户 - * @param opId - * @param opList - * @return - * 2018年8月2日 wangfs.
- */ - private List getRootOpIds(Long parentId){ - List opList = new ArrayList<>(); - AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq(); - asraOpQueryRe.setParentId(parentId); - BizResult> asraOpReult = asraOpQueryService.queryAsraOpByParentId(asraOpQueryRe); - if(asraOpReult != null && CollectionUtil.isNotEmpty(asraOpReult.getData())){ - List list = asraOpReult.getData(); - for(AsraOpDTO asraOpDTO :list){ - if(asraOpDTO == null){ - continue; - } - opList.add(asraOpDTO.getId()); - } - } - return opList; - } - - } diff --git a/src/main/resources/mybatis/smapper/AsraOpSmapper.xml b/src/main/resources/mybatis/smapper/AsraOpSmapper.xml index d6d298a..bc1112d 100644 --- a/src/main/resources/mybatis/smapper/AsraOpSmapper.xml +++ b/src/main/resources/mybatis/smapper/AsraOpSmapper.xml @@ -19,43 +19,43 @@ + - id, login_code, login_password, op_name, email, role_id, city_id, city_name, - is_remind_email, data_state, create_empid, create_emp_name, create_date, modfiy_empid, - modfiy_emp_name, modfiy_date, remark + id, login_code, login_password, op_name, email, role_id, city_id, city_name, is_remind_email, + data_state, create_empid, create_emp_name, create_date, modfiy_empid, modfiy_emp_name, + modfiy_date, remark, parent_id - select - ap.id id, - ap.login_code loginCode, - ap.op_name opName, - ap.email email, - ap.role_id roleId, - ap.city_id cityId, - ap.city_name cityName, - ap.is_remind_email isRemindEmail - from asra_op ap left join asra_op_relations apr on ap.id = apr.op_id + + from asra_op where 1=1 - and (apr.parent_id = #{id} or ap.id = #{id}) + id = #{id} - and ap.login_code = #{loginCode,jdbcType=VARCHAR} + and login_code = #{loginCode,jdbcType=VARCHAR} - and ap.op_name like concat('%','${opName}','%') + and op_name like concat('%','${opName}','%') - and ap.email = #{email,jdbcType=VARCHAR} + and email = #{email,jdbcType=VARCHAR} - and ap.id in + and id in #{opId} + + and parent_id in + + #{opId} + + \ No newline at end of file