Commit 2f0270432cea0b46a401b8e7e6f4c7930107e301

Authored by xiejianpeng
2 parents 4b2bb18a b1704d7c

Merge remote-tracking branch 'origin/branch0730' into branch

# Conflicts:
#	src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java
#	src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java
#	src/main/java/com/zteits/oa/report/web/OAuthController.java
src/main/java/com/zteits/oa/api/dto/asradaily/param/AsraDailyForTotalNumAndDetailReq.java
1 1 package com.zteits.oa.api.dto.asradaily.param;
2 2  
  3 +import java.util.List;
  4 +
3 5 import com.zteits.oa.api.base.bean.BaseRequest;
4 6  
5 7 /**
... ... @@ -33,7 +35,19 @@ public class AsraDailyForTotalNumAndDetailReq extends BaseRequest{
33 35  
34 36 /**员工名称.*/
35 37 private String opName;
  38 + /**父级ID 顶级为-1.*/
  39 + private List<Long> opIds;
  40 +
36 41  
  42 +
  43 +
  44 + public List<Long> getOpIds() {
  45 + return opIds;
  46 + }
  47 +
  48 + public void setOpIds(List<Long> opIds) {
  49 + this.opIds = opIds;
  50 + }
37 51  
38 52 public String getBeginTime() {
39 53 return beginTime;
... ...
src/main/java/com/zteits/oa/api/dto/asradaily/param/AsraDailySaveOrUpdateReq.java
... ... @@ -3,6 +3,7 @@ package com.zteits.oa.api.dto.asradaily.param;
3 3 import com.zteits.oa.api.base.bean.BaiscDTO;
4 4  
5 5 import java.util.Date;
  6 +import java.util.List;
6 7  
7 8 public class AsraDailySaveOrUpdateReq extends BaiscDTO{
8 9 /**主键*/
... ... @@ -52,8 +53,21 @@ public class AsraDailySaveOrUpdateReq extends BaiscDTO{
52 53  
53 54 /**工时内容*/
54 55 private String dailyContent;
  56 +
  57 + /**员工ids.*/
  58 + private List<Long> opIds;
  59 +
  60 +
55 61  
56   - /**获取主键*/
  62 + public List<Long> getOpIds() {
  63 + return opIds;
  64 + }
  65 +
  66 + public void setOpIds(List<Long> opIds) {
  67 + this.opIds = opIds;
  68 + }
  69 +
  70 + /**获取主键*/
57 71 public Long getId() {
58 72 return id;
59 73 }
... ...
src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java
... ... @@ -25,7 +25,12 @@ public class AsraOpQueryReq extends BaseRequest{
25 25  
26 26 /**员工邮箱*/
27 27 private String email;
28   -
  28 +
  29 + /**父级ID 顶级为-1*/
  30 + private Long parentId;
  31 +
  32 +
  33 +
29 34  
30 35 /**员工idlist*/
31 36 private List<Long> opIdLists;
... ... @@ -41,12 +46,12 @@ public class AsraOpQueryReq extends BaseRequest{
41 46 this.opParentIdLists = opParentIdLists;
42 47 }
43 48  
44   - public List<Long> getOpIdLists() {
45   - return opIdLists;
  49 + public Long getParentId() {
  50 + return parentId;
46 51 }
47 52  
48   - public void setOpIdLists(List<Long> opIdLists) {
49   - this.opIdLists = opIdLists;
  53 + public void setParentId(Long parentId) {
  54 + this.parentId = parentId;
50 55 }
51 56  
52 57 public String getLoginCode() {
... ...
src/main/java/com/zteits/oa/api/service/report/query/AsraOpQueryService.java
1 1 package com.zteits.oa.api.service.report.query;
2 2  
  3 +import java.util.List;
  4 +
3 5 import com.zteits.oa.api.base.bean.BizResult;
4 6 import com.zteits.oa.api.base.bean.PageBean;
5 7 import com.zteits.oa.api.dto.asraop.AsraOpDTO;
... ... @@ -50,4 +52,12 @@ public interface AsraOpQueryService {
50 52 *
51 53 */
52 54 BizResult<AsraOpDTO> queryAsraOpByLoginCode(AsraOpQueryReq asraOpQueryReq);
  55 +
  56 + /**
  57 + * 通过员工父级Id获取员工信息.<br/>
  58 + * @param asraOpQueryRe
  59 + * @return
  60 + * 2018年7月31日 wangfs.<br/>
  61 + */
  62 + BizResult<List<AsraOpDTO>> queryAsraOpByParentId(AsraOpQueryReq asraOpQueryRe);
53 63 }
... ...
src/main/java/com/zteits/oa/report/biz/AsraOpQueryServiceImpl.java
1 1 package com.zteits.oa.report.biz;
2 2  
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
3 6 import org.slf4j.Logger;
4 7 import org.slf4j.LoggerFactory;
5 8 import org.springframework.beans.BeanUtils;
... ... @@ -15,6 +18,7 @@ import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq;
15 18 import com.zteits.oa.api.service.report.query.AsraOpQueryService;
16 19 import com.zteits.oa.report.dao.AsraOpDao;
17 20 import com.zteits.oa.report.domain.AsraOp;
  21 +import com.zteits.oa.util.ListCopyUtil;
18 22 import com.zteits.oa.util.pagepaper.PageBeanUtil;
19 23 /**
20 24 * 工时系统操作员实现类.<br/>
... ... @@ -31,7 +35,7 @@ import com.zteits.oa.util.pagepaper.PageBeanUtil;
31 35 *---------------------------------------------------------*
32 36 * 2018年7月30日 wangfs v1.0.0 创建
33 37 */
34   -@Service("")
  38 +@Service("com.zteits.oa.report.biz.AsraOpQueryServiceImpl")
35 39 public class AsraOpQueryServiceImpl implements AsraOpQueryService {
36 40  
37 41 private static final Logger logger = LoggerFactory.getLogger(AsraOpQueryServiceImpl.class);
... ... @@ -77,4 +81,18 @@ public class AsraOpQueryServiceImpl implements AsraOpQueryService {
77 81 return new BizResult<>(asraOpDTO);
78 82 }
79 83  
  84 + /**
  85 + * 通过员工父级Id获取员工信息.<br/>
  86 + * @param asraOpQueryRe
  87 + * @return
  88 + * 2018年7月31日 wangfs.<br/>
  89 + */
  90 + @Override
  91 + public BizResult<List<AsraOpDTO>> queryAsraOpByParentId(AsraOpQueryReq asraOpQueryRe) {
  92 + List<AsraOpDTO> listDTO = new ArrayList<>();
  93 + List<AsraOp> list = asraOpDao.queryAsraOpByParentId(asraOpQueryRe);
  94 + ListCopyUtil.listCopyProperties(list, listDTO, AsraOpDTO.class);
  95 + return new BizResult<List<AsraOpDTO>>(listDTO);
  96 + }
  97 +
80 98 }
... ...
src/main/java/com/zteits/oa/report/dao/AsraOpDao.java
1 1 package com.zteits.oa.report.dao;
2 2  
  3 +import java.util.List;
  4 +
3 5 import com.github.pagehelper.PageInfo;
4 6 import com.zteits.oa.api.base.bean.BizResult;
5 7 import com.zteits.oa.api.dto.asraop.AsraOpDTO;
... ... @@ -33,4 +35,12 @@ public interface AsraOpDao {
33 35 *
34 36 */
35 37 AsraOp queryAsraOpByLoginCode(String loginCode);
  38 +
  39 + /**
  40 + * 通过员工父级Id获取员工信息.<br/>
  41 + * @param asraOpQueryRe
  42 + * @return
  43 + * 2018年7月31日 wangfs.<br/>
  44 + */
  45 + List<AsraOp> queryAsraOpByParentId(AsraOpQueryReq asraOpQueryRe);
36 46 }
... ...
src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java
... ... @@ -68,8 +68,13 @@ public class AsraDailyDaoImpl implements AsraDailyDao{
68 68 public AsraDailyOpNumForCurrentDayDO queryAsraDailyOpNumForCurrentDay(AsraDailyForTotalNumAndDetailReq request) {
69 69 AsraDailyOpNumForCurrentDayDO asraDailyOpNumForCurrentDayDO = new AsraDailyOpNumForCurrentDayDO();
70 70 List<Long> opList = new ArrayList<>();
  71 +
  72 + //1.总人数获取
71 73 int employeeTotal = 0;
72   - opList.add(request.getOpId());//查询自己id
  74 + if(CollectionUtil.isNotEmpty(request.getOpIds())){
  75 + employeeTotal = request.getOpIds().size();
  76 + }
  77 +
73 78 //2.查询今日日报填写人数
74 79 AsraDailyExample exampleTwo = new AsraDailyExample();
75 80 exampleTwo.createCriteria().andAsarOpIdIn(opList)
... ...
src/main/java/com/zteits/oa/report/dao/impl/AsraOpDaoImpl.java
... ... @@ -60,6 +60,7 @@ public class AsraOpDaoImpl implements AsraOpDao {
60 60 if(asraOpQueryRe.getId() != null){
61 61 criteria.andIdEqualTo(asraOpQueryRe.getId());
62 62 }
  63 +
63 64 criteria.andDataStateEqualTo(1);
64 65 List<AsraOp> list = asraOpMapper.selectByExample(example);
65 66 return CollectionUtils.isEmpty(list) ? new AsraOp() : list.get(0);
... ... @@ -73,4 +74,18 @@ public class AsraOpDaoImpl implements AsraOpDao {
73 74 return berths.get(0);
74 75 }
75 76  
  77 + /**
  78 + * 通过员工父级Id获取员工信息.<br/>
  79 + * @param asraOpQueryRe
  80 + * @return
  81 + * 2018年7月31日 wangfs.<br/>
  82 + */
  83 + @Override
  84 + public List<AsraOp> queryAsraOpByParentId(AsraOpQueryReq asraOpQueryRe) {
  85 + AsraOpExample example = new AsraOpExample();
  86 + example.createCriteria().andParentIdEqualTo(asraOpQueryRe.getParentId());
  87 + List<AsraOp> list = asraOpMapper.selectByExample(example);
  88 + return list;
  89 + }
  90 +
76 91 }
... ...
src/main/java/com/zteits/oa/report/web/AsraDailyController.java
... ... @@ -17,6 +17,7 @@ import com.zteits.oa.api.dto.asradaily.param.AsraDailyQueryReq;
17 17 import com.zteits.oa.api.dto.asradaily.param.AsraDailySaveOrUpdateReq;
18 18 import com.zteits.oa.api.dto.asraop.AsraOpDTO;
19 19 import com.zteits.oa.api.service.report.query.AsraDailyQueryService;
  20 +import com.zteits.oa.report.domain.AsraDaily;
20 21 import com.zteits.oa.util.pagepaper.DateForObjectUtil;
21 22 import io.swagger.annotations.Api;
22 23 import io.swagger.annotations.ApiOperation;
... ... @@ -72,7 +73,7 @@ public class AsraDailyController {
72 73 if(asraOpDTO == null ){
73 74 throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
74 75 }
75   - request.setOpId(asraOpDTO.getId());
  76 + request.setOpIds(asraOpDTO.getOpIds());
76 77 BizResult<AsraDailyOpNumForCurrentDayDTO> result = asraDailyQueryService.queryAsraDailyOpNumForCurrentDay(request);
77 78 logger.info("--end工时查询-当天填报人数统计(汇总),结果={}",JSONObject.toJSON(result));
78 79 return result;
... ... @@ -93,7 +94,7 @@ public class AsraDailyController {
93 94 if(asraOpDTO == null ){
94 95 throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
95 96 }
96   - request.setOpId(asraOpDTO.getId());
  97 + request.setOpIds(asraOpDTO.getOpIds());
97 98 BizResult<QueryAsraDailyAllForListReqDTO> result = asraDailyQueryService.queryAsraDailyAllForList(request);
98 99 logger.info("--end工时查询-所有员工及自己或者自己日报,结果={}",JSONObject.toJSON(result));
99 100 return result;
... ...
src/main/java/com/zteits/oa/report/web/OAuthController.java
1 1 package com.zteits.oa.report.web;
2 2  
  3 +import static org.mockito.Matchers.contains;
  4 +
3 5 import java.util.ArrayList;
4 6 import java.util.List;
5 7  
... ... @@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
18 20 import org.springframework.web.bind.annotation.RestController;
19 21  
20 22 import com.alibaba.fastjson.JSONObject;
  23 +import com.xiaoleilu.hutool.util.CollectionUtil;
21 24 import com.zteits.oa.api.base.bean.BizResult;
22 25 import com.zteits.oa.api.base.constants.ErrorType;
23 26 import com.zteits.oa.api.base.constants.SessionEnum;
... ... @@ -97,7 +100,7 @@ public class OAuthController {
97 100 List<Long> opParentIds = new ArrayList<>();
98 101 opParentIds.add(asraOpDTO.getId());
99 102 /**递归查询员工ids.*/
100   - opIds = queryOpTreeByOpId(opParentIds,opIds);
  103 + opIds = queryOpTreeByOpIds(opParentIds,opIds);
101 104 logger.info("---获取到的opIds={}",JSONObject.toJSON(opIds));
102 105 asraOpDTO.setOpIds(opIds);
103 106 HttpSession session = request.getSession();
... ... @@ -144,7 +147,7 @@ public class OAuthController {
144 147 * @return
145 148 * 2018年8月2日 wangfs.<br/>
146 149 */
147   - private List<Long> queryOpTreeByOpId(List<Long> queryOpList,List<Long> opList){
  150 + private List<Long> queryOpTreeByOpIds(List<Long> queryOpList,List<Long> opList){
148 151 if(queryOpList != null && CollectionUtil.isNotEmpty(queryOpList)){
149 152 AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq();
150 153 asraOpQueryRe.setOpParentIdLists(queryOpList);
... ... @@ -167,6 +170,90 @@ public class OAuthController {
167 170 }
168 171  
169 172  
  173 + /**
  174 + * 递归查询员工id.<br/>
  175 + * @param parentOpId
  176 + * @param opList
  177 + * @return
  178 + * 2018年8月2日 wangfs.<br/>
  179 + */
  180 + private List<Long> queryOpTreeByOpId(Long opId){
  181 + List<Long> rootAllList = new ArrayList<>();
  182 + rootAllList.add(opId);
  183 + //1.查找第一级下的所有用户
  184 + List<Long> rootOpIds = this.getRootOpIds(opId);
  185 +
  186 + //2.查找第二级以下所有用户
  187 + if(CollectionUtil.isNotEmpty(rootOpIds)){
  188 + rootAllList.addAll(rootOpIds);
  189 + for(Long getOpId:rootOpIds ){
  190 + List<Long> childOpIds = new ArrayList<>();
  191 + this.getChildOpIds(getOpId,childOpIds);
  192 + rootAllList.addAll(childOpIds);
  193 + }
  194 +
  195 + }
  196 + return rootAllList;
  197 + }
  198 +
  199 + /**
  200 + * 递归查找一级以下的用户
  201 + * @param parentId
  202 + * @return
  203 + * 2018年8月2日 wangfs.<br/>
  204 + */
  205 + private List<Long> getChildOpIds(Long parentId,List<Long> childOpIds){
  206 + AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq();
  207 + asraOpQueryRe.setParentId(parentId);
  208 + BizResult<List<AsraOpDTO>> asraOpReult = asraOpQueryService.queryAsraOpByParentId(asraOpQueryRe);
  209 + if(asraOpReult != null && CollectionUtil.isNotEmpty(asraOpReult.getData())){
  210 + List<AsraOpDTO> list = asraOpReult.getData();
  211 + for(AsraOpDTO asraOpDTO :list){
  212 + if(asraOpDTO == null){
  213 + continue;
  214 + }
  215 + childOpIds.add(asraOpDTO.getId());
  216 + }
  217 +
  218 + //遍历下一级
  219 + if(CollectionUtil.isNotEmpty(childOpIds)){
  220 + for(Long opId:childOpIds){
  221 + if(opId != null && !opId.equals(parentId)){
  222 + getChildOpIds(opId,childOpIds);
  223 + }
  224 + break;
  225 +
  226 + }
  227 +
  228 + }
  229 + }
  230 +
  231 + return childOpIds;
  232 + }
  233 +
  234 + /**
  235 + * 查找登陆用户下一级用户
  236 + * @param opId
  237 + * @param opList
  238 + * @return
  239 + * 2018年8月2日 wangfs.<br/>
  240 + */
  241 + private List<Long> getRootOpIds(Long parentId){
  242 + List<Long> opList = new ArrayList<>();
  243 + AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq();
  244 + asraOpQueryRe.setParentId(parentId);
  245 + BizResult<List<AsraOpDTO>> asraOpReult = asraOpQueryService.queryAsraOpByParentId(asraOpQueryRe);
  246 + if(asraOpReult != null && CollectionUtil.isNotEmpty(asraOpReult.getData())){
  247 + List<AsraOpDTO> list = asraOpReult.getData();
  248 + for(AsraOpDTO asraOpDTO :list){
  249 + if(asraOpDTO == null){
  250 + continue;
  251 + }
  252 + opList.add(asraOpDTO.getId());
  253 + }
  254 + }
  255 + return opList;
  256 + }
170 257  
171 258  
172 259  
... ...