From 82d7d7088176b76308d131332449c65aa130660f Mon Sep 17 00:00:00 2001 From: wulin Date: Fri, 25 Sep 2020 19:28:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper/equipment/EquipmentSpecsMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mapper/equipment/EquipmentSpecsMapper.xml b/src/main/resources/mapper/equipment/EquipmentSpecsMapper.xml index c014ecd7..18bc5e86 100644 --- a/src/main/resources/mapper/equipment/EquipmentSpecsMapper.xml +++ b/src/main/resources/mapper/equipment/EquipmentSpecsMapper.xml @@ -117,7 +117,7 @@ From 8cdd665768a86dc07265087d7e1eb06ed056f9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E5=BB=BA=E8=B6=85?= <3182967682@qq.com> Date: Sun, 27 Sep 2020 09:48:06 +0800 Subject: [PATCH 2/4] fix --- src/main/java/com/lz/config/ShiroConfig.java | 2 +- .../controller/ReportResultController.java | 62 +++----- .../lz/modules/app/dao/DepartmentsDao.java | 3 + .../app/dto/ReportDistributionDto.java | 34 ++++ .../modules/app/dto/StaffDepartmentsDto.java | 20 +++ .../app/enums/ResultRecordStatusEnum.java | 28 +++- .../com/lz/modules/app/req/ReportListReq.java | 23 ++- .../app/req/ResultDistributionReq.java | 18 +++ .../app/service/DepartmentsService.java | 8 + .../lz/modules/app/service/StaffService.java | 1 + .../service/impl/DepartmentsServiceImpl.java | 27 ++++ .../app/service/impl/StaffServiceImpl.java | 7 +- .../sys/dao/app/ResultRecordMapper.java | 3 +- .../modules/sys/service/app/ChartService.java | 8 + .../service/app/impl/ChartServiceImpl.java | 149 ++++++++++++++++-- .../mapper/app/ResultRecordMapper.xml | 35 +++- .../mapper/generator/DepartmentsDao.xml | 14 +- 17 files changed, 367 insertions(+), 75 deletions(-) create mode 100644 src/main/java/com/lz/modules/app/dto/ReportDistributionDto.java create mode 100644 src/main/java/com/lz/modules/app/dto/StaffDepartmentsDto.java create mode 100644 src/main/java/com/lz/modules/app/req/ResultDistributionReq.java diff --git a/src/main/java/com/lz/config/ShiroConfig.java b/src/main/java/com/lz/config/ShiroConfig.java index 98c33d21..5d559436 100644 --- a/src/main/java/com/lz/config/ShiroConfig.java +++ b/src/main/java/com/lz/config/ShiroConfig.java @@ -69,7 +69,7 @@ public class ShiroConfig { filterMap.put("/dtlg/jump", "anon"); filterMap.put("/luck/getLuckById", "anon"); filterMap.put("/luck/updateLuck", "anon"); - filterMap.put("/report/**","anon"); + filterMap.put("/result/**","anon"); filterMap.put("/**", "oauth2"); shiroFilter.setFilterChainDefinitionMap(filterMap); diff --git a/src/main/java/com/lz/modules/app/controller/ReportResultController.java b/src/main/java/com/lz/modules/app/controller/ReportResultController.java index 138c1915..aa8cca21 100644 --- a/src/main/java/com/lz/modules/app/controller/ReportResultController.java +++ b/src/main/java/com/lz/modules/app/controller/ReportResultController.java @@ -9,6 +9,7 @@ import com.lz.modules.app.entity.DepartmentsStaffRelateEntity; import com.lz.modules.app.enums.ResultRecordStatusEnum; import com.lz.modules.app.enums.ResultRecordTypeEnum; import com.lz.modules.app.req.ReportListReq; +import com.lz.modules.app.req.ResultDistributionReq; import com.lz.modules.app.resp.OwnResultResp; import com.lz.modules.app.resp.ReportChartResp; import com.lz.modules.app.service.DepartmentsService; @@ -49,13 +50,17 @@ public class ReportResultController extends AbstractController{ @Autowired private ChartService chartService; - static final String[] levels = new String[]{"3.25","3.5-","3.5","3.5+","3.75-","3.75","3.75+","4"}; - @RequestMapping("chart") public R reportChart(String selectMonthTime,String departmentId){ if(StringUtil.isBlank(selectMonthTime)){ selectMonthTime = YearMonth.now().toString(); + } + Long userId = getUserId(); + //是自己部门得领导 + DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectByStaffId(userId); + if("1".equals(departmentsStaffRelateEntity.getIsLeader())){ + } ReportChartResp reportChartResp = chartService.reportChart(selectMonthTime, departmentId); return R.ok().put("data",reportChartResp); @@ -74,6 +79,22 @@ public class ReportResultController extends AbstractController{ } + // 未解决问题 部门负责人游离在外 无法统计 + @RequestMapping("/distribution") + public R distribution(ResultDistributionReq req){ + req.setDepartmentId("1"); + PageUtils pageUtils = chartService.reportDistribution(req); + return R.ok().put("page",pageUtils); + } + + + + @RequestMapping("/departmentTreeByStaffId") + public R departmentTreeByStaffId(ResultDistributionReq req){ + //Long userId = getUserId(); + List data = departmentsService.getDepartmentTreeByStaffId("303",true); + return R.ok().put("data",data); + } @RequestMapping("/own/result") public R ownResult(Long userId){ @@ -89,21 +110,7 @@ public class ReportResultController extends AbstractController{ - //是在这个地方查询出所有的部门选择 还是 通过关键字搜索 - /* @RequestMapping("underDepartment") - public R underDepartment(){ - DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectByStaffId(null); - if(departmentsStaffRelateEntity == null){ - } - if(departmentsStaffRelateEntity.getIsLeader().equals(1)){ - //如果是leader 查询负责几个部门 - List departmentsDtos = departmentsService.selectByParentDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); - - } - return R.ok(); - - }*/ @@ -133,26 +140,3 @@ public class ReportResultController extends AbstractController{ return result; } */ - - - - - - -// 0人是否需要展示 - /* List sortStaffLevels = new ArrayList<>(); - Map map = Maps.newHashMap(); - for (GraphicsStatisticalDto staffLevel : staffLevels) { - map.put(staffLevel.getCategory(),staffLevel.getNumber()); - } - // 默认等级赋予默认值并排序 - for (String level : levels) { - GraphicsStatisticalDto dto = new GraphicsStatisticalDto(); - dto.setCategory(level); - if(!map.containsKey(level)){ - dto.setNumber(0); - }else { - dto.setNumber(map.get(level)); - } - sortStaffLevels.add(dto); - }*/ \ No newline at end of file diff --git a/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java b/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java index d191c00e..c4dc4a57 100644 --- a/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java +++ b/src/main/java/com/lz/modules/app/dao/DepartmentsDao.java @@ -1,5 +1,6 @@ package com.lz.modules.app.dao; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.lz.modules.app.dto.DepartmentInfos; import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dto.StaffDepartmentDto; @@ -45,4 +46,6 @@ public interface DepartmentsDao extends BaseMapper { List selectDepartmentIdsByparentIds(@Param("parentIds") List parentIds); + List selectDepartmentIdsByparentIds(@Param("parentIds") List parentIds, @Param("page") IPage page); + } diff --git a/src/main/java/com/lz/modules/app/dto/ReportDistributionDto.java b/src/main/java/com/lz/modules/app/dto/ReportDistributionDto.java new file mode 100644 index 00000000..8ae1374f --- /dev/null +++ b/src/main/java/com/lz/modules/app/dto/ReportDistributionDto.java @@ -0,0 +1,34 @@ +package com.lz.modules.app.dto; + +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2020/9/24 16:31 + */ +@Data +public class ReportDistributionDto { + //序号 + private String departmentId; + //业务线 + private String businessLine; + //部门 + private String departmentName; + //3.25 + private int level1; + //3.5- + private int level2; + //3.5 + private int level3; + //3.5+ + private int level4; + //3.75- + private int level5; + //3.75 + private int level6; + //3.75+ + private int level7; + //4 + private int level8; +} diff --git a/src/main/java/com/lz/modules/app/dto/StaffDepartmentsDto.java b/src/main/java/com/lz/modules/app/dto/StaffDepartmentsDto.java new file mode 100644 index 00000000..e7846ee2 --- /dev/null +++ b/src/main/java/com/lz/modules/app/dto/StaffDepartmentsDto.java @@ -0,0 +1,20 @@ +package com.lz.modules.app.dto; + +import java.util.List; + +/** + * @Author: djc + * @Desc: + * @Date: 2020/9/25 14:24 + */ +public class StaffDepartmentsDto { + //父级部门名称 + private String departmentName; + + //父级部门id + private String departmentId; + + //管理得所有部门 + List departmentsDtos; + +} diff --git a/src/main/java/com/lz/modules/app/enums/ResultRecordStatusEnum.java b/src/main/java/com/lz/modules/app/enums/ResultRecordStatusEnum.java index df8e321a..52a1ef56 100644 --- a/src/main/java/com/lz/modules/app/enums/ResultRecordStatusEnum.java +++ b/src/main/java/com/lz/modules/app/enums/ResultRecordStatusEnum.java @@ -1,5 +1,9 @@ package com.lz.modules.app.enums; +import com.google.common.collect.Lists; + +import java.util.List; + /** * @Author: djc * @Desc: @@ -11,7 +15,13 @@ public enum ResultRecordStatusEnum { REFUSE(2,"拒绝"), WAIT_COMMIT(3,"侍提交"), AGREE(4,"审批通过"), - REJECT(5,"驳回"); + REJECT(5,"驳回"), + APPEAL(6,"申述"), + SUSPEND(7,"流程中止"), + + //组合状态 + PROCESS(108,"审核中"), + FINISH(109,"已完成"); private int status; private String desc; @@ -21,6 +31,22 @@ public enum ResultRecordStatusEnum { this.desc = desc; } + public static List getGroupStatus(Integer status){ + if(status ==null){ + return null; + } + if(status == PROCESS.getStatus()){ + return Lists.newArrayList(AUDIT.getStatus(),WAIT_COMMIT.getStatus(),REJECT.getStatus(),APPEAL.getStatus()); + } + if(status == FINISH.getStatus()){ + return Lists.newArrayList(REFUSE.getStatus(),AGREE.getStatus(),SUSPEND.getStatus()); + } + return Lists.newArrayList(status); + + } + + + public int getStatus() { return status; } diff --git a/src/main/java/com/lz/modules/app/req/ReportListReq.java b/src/main/java/com/lz/modules/app/req/ReportListReq.java index 5c25c32d..2573abbe 100644 --- a/src/main/java/com/lz/modules/app/req/ReportListReq.java +++ b/src/main/java/com/lz/modules/app/req/ReportListReq.java @@ -4,6 +4,7 @@ import com.lz.modules.equipment.entity.model.BasePage; import lombok.Data; import java.time.YearMonth; +import java.util.List; /** * @Author: djc @@ -12,15 +13,23 @@ import java.time.YearMonth; */ @Data public class ReportListReq extends BasePage { - String departmentId; + + private String departmentId; + + private String selectMonthTime = YearMonth.now().toString(); + //提交审核状态 + private Integer status; + //真是查询得状态 + private List realStatus; + //目标还是结果 + private int type =1; + + private String staffName; + + private String level; + //String startMonthTime; //String endMonthTime; - - String selectMonthTime = YearMonth.now().toString(); - //提交审核状态 - int status =0; - //目标还是结果 - int type =1; } diff --git a/src/main/java/com/lz/modules/app/req/ResultDistributionReq.java b/src/main/java/com/lz/modules/app/req/ResultDistributionReq.java new file mode 100644 index 00000000..bb9b111c --- /dev/null +++ b/src/main/java/com/lz/modules/app/req/ResultDistributionReq.java @@ -0,0 +1,18 @@ +package com.lz.modules.app.req; + +import com.lz.modules.equipment.entity.model.BasePage; +import lombok.Data; + +import java.time.YearMonth; + +/** + * @Author: djc + * @Desc: + * @Date: 2020/9/25 9:30 + */ +@Data +public class ResultDistributionReq extends BasePage { + private String departmentId = "1"; + + private String selectMonthTime = YearMonth.now().toString(); +} diff --git a/src/main/java/com/lz/modules/app/service/DepartmentsService.java b/src/main/java/com/lz/modules/app/service/DepartmentsService.java index 5cf45307..7610a6df 100644 --- a/src/main/java/com/lz/modules/app/service/DepartmentsService.java +++ b/src/main/java/com/lz/modules/app/service/DepartmentsService.java @@ -45,5 +45,13 @@ public interface DepartmentsService extends IService { Map selectUserAllDepartmentInFo(String departmentId); + /** + * 获取自己管理得部门列表 + * @param staffId 人员id + * @param containSelf 是否包含本身 + * @return + */ + List getDepartmentTreeByStaffId(String staffId,boolean containSelf); + } diff --git a/src/main/java/com/lz/modules/app/service/StaffService.java b/src/main/java/com/lz/modules/app/service/StaffService.java index 13b88aab..d93963fb 100644 --- a/src/main/java/com/lz/modules/app/service/StaffService.java +++ b/src/main/java/com/lz/modules/app/service/StaffService.java @@ -80,6 +80,7 @@ public interface StaffService extends IService { //查询部门下的所有子部门 List selectAllDeparmentIdsByDepartmentParentId(String departmentId); + //统计部门下的人 List staffsByAllDeparmentIds(List deparmentIds); diff --git a/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java b/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java index 5dcf7bca..d5e938a2 100644 --- a/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java +++ b/src/main/java/com/lz/modules/app/service/impl/DepartmentsServiceImpl.java @@ -8,16 +8,21 @@ import com.lz.common.utils.PageUtils; import com.lz.common.utils.Query; import com.lz.common.utils.StringUtil; import com.lz.modules.app.dao.DepartmentsDao; +import com.lz.modules.app.dao.DepartmentsStaffRelateDao; +import com.lz.modules.app.dao.StaffDao; import com.lz.modules.app.dto.DepartmentInfos; import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dto.StaffDepartmentDto; import com.lz.modules.app.entity.DepartmentsEntity; +import com.lz.modules.app.entity.DepartmentsStaffRelateEntity; +import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.service.DepartmentsService; import com.lz.modules.job.model.responseBo.DepartmentInfosBo; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,6 +35,8 @@ public class DepartmentsServiceImpl extends ServiceImpl params) { @@ -200,4 +207,24 @@ public class DepartmentsServiceImpl extends ServiceImpl getDepartmentTreeByStaffId(String staffId,boolean containSelf) { + DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateDao.selectByStaffId(Long.valueOf(staffId)); + List departmentsParentsList = departmentsDao.getDepartmentsByparentId(departmentsStaffRelateEntity.getDepartmentId()); + getDepartmentTreeList(departmentsParentsList); + if(containSelf){ + List result = new ArrayList<>(); + DepartmentsDto departmentsDto = new DepartmentsDto(); + departmentsDto.setDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); + DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); + departmentsDto.setDepartmentName(departmentsEntity.getDepartmentName()); + departmentsDto.setMemberCount(departmentsEntity.getMemberCount()); + departmentsDto.setList(departmentsParentsList); + result.add(departmentsDto); + return result; + } + return departmentsParentsList; + } + } diff --git a/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java b/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java index 656c36de..67d06556 100644 --- a/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java +++ b/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java @@ -392,14 +392,15 @@ public class StaffServiceImpl extends ServiceImpl impleme } List parentsIds = Lists.newArrayList(departmentId); List departmentsList = new ArrayList<>(); + departmentsList.addAll(parentsIds); List childs = departmentsDao.selectDepartmentIdsByparentIds(parentsIds); if(CollectionUtils.isEmpty(childs)){ - departmentsList.addAll(parentsIds); return departmentsList; } departmentsList.addAll(childs); List allChilds = getAllChilds(departmentsList, childs); - return allChilds; + allChilds.remove("1"); + return allChilds.stream().distinct().collect(Collectors.toList()); } @@ -408,7 +409,7 @@ public class StaffServiceImpl extends ServiceImpl impleme if(CollectionUtils.isEmpty(deparmentIds)){ return Lists.newArrayList(); } - //获取所有子部门 + //获取所有人员 List list = departmentsStaffRelateService.list(new QueryWrapper() .select("staff_id") .eq("is_delete", 0) diff --git a/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java b/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java index 823ff78b..07f6bbd6 100644 --- a/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java +++ b/src/main/java/com/lz/modules/sys/dao/app/ResultRecordMapper.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.lz.modules.app.dto.GraphicsStatisticalDto; import com.lz.modules.app.dto.ReportProgressListDto; +import com.lz.modules.app.req.ReportListReq; import com.lz.modules.app.req.ResultRecordReq; import com.lz.modules.app.resp.OwnResultResp; import com.lz.modules.flow.model.ResultRecordDto; @@ -59,5 +60,5 @@ public interface ResultRecordMapper extends BaseMapper { ResultRecord selectResultRecordByStaffIdStatus(@Param("staffId") Long staffId, @Param("status") int status); - List targetReportList(@Param("monthTime") String monthTime,@Param("staffIds") List staffIds,@Param("page") IPage page); + List targetReportList(@Param("req")ReportListReq req, @Param("staffIds") List staffIds, @Param("page") IPage page); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/sys/service/app/ChartService.java b/src/main/java/com/lz/modules/sys/service/app/ChartService.java index 67527f5f..85c13cb0 100644 --- a/src/main/java/com/lz/modules/sys/service/app/ChartService.java +++ b/src/main/java/com/lz/modules/sys/service/app/ChartService.java @@ -1,9 +1,12 @@ package com.lz.modules.sys.service.app; import com.lz.common.utils.PageUtils; +import com.lz.modules.app.dto.DepartmentsDto; import com.lz.modules.app.dto.GraphicsStatisticalDto; +import com.lz.modules.app.dto.ReportDistributionDto; import com.lz.modules.app.dto.ReportProgressListDto; import com.lz.modules.app.req.ReportListReq; +import com.lz.modules.app.req.ResultDistributionReq; import com.lz.modules.app.resp.ReportChartResp; import java.util.List; @@ -27,6 +30,11 @@ public interface ChartService { ReportChartResp reportChart(String selectMonthTime, String departmentId); + PageUtils reportDistribution(ResultDistributionReq req); + + String businessLineByStaffId(String staffId); + + } diff --git a/src/main/java/com/lz/modules/sys/service/app/impl/ChartServiceImpl.java b/src/main/java/com/lz/modules/sys/service/app/impl/ChartServiceImpl.java index 9054f31c..03d72967 100644 --- a/src/main/java/com/lz/modules/sys/service/app/impl/ChartServiceImpl.java +++ b/src/main/java/com/lz/modules/sys/service/app/impl/ChartServiceImpl.java @@ -1,25 +1,31 @@ package com.lz.modules.sys.service.app.impl; +import cn.hutool.core.util.PageUtil; +import com.alibaba.druid.sql.PagerUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.lz.common.utils.BigDecimalUtil; import com.lz.common.utils.PageUtils; +import com.lz.common.utils.StringUtil; +import com.lz.modules.app.dao.DepartmentsDao; import com.lz.modules.app.dao.DepartmentsStaffRelateDao; import com.lz.modules.app.dao.StaffDao; -import com.lz.modules.app.dto.CharBarDto; -import com.lz.modules.app.dto.GraphicsDto; -import com.lz.modules.app.dto.GraphicsStatisticalDto; -import com.lz.modules.app.dto.ReportProgressListDto; +import com.lz.modules.app.dto.*; +import com.lz.modules.app.entity.DepartmentsEntity; +import com.lz.modules.app.entity.DepartmentsStaffRelateEntity; import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.enums.ResultRecordStatusEnum; import com.lz.modules.app.enums.ResultRecordTypeEnum; import com.lz.modules.app.req.ReportListReq; +import com.lz.modules.app.req.ResultDistributionReq; import com.lz.modules.app.resp.ReportChartResp; import com.lz.modules.app.service.StaffService; import com.lz.modules.sys.dao.app.ResultRecordMapper; import com.lz.modules.sys.entity.app.ResultRecord; import com.lz.modules.sys.service.app.ChartService; import com.lz.modules.sys.service.app.ResultRecordService; +import com.sun.org.apache.regexp.internal.RE; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -28,8 +34,10 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; /** @@ -50,6 +58,11 @@ public class ChartServiceImpl implements ChartService { private DepartmentsStaffRelateDao departmentsStaffRelateDao; @Autowired private StaffDao staffDao; + @Autowired + private DepartmentsDao departmentsDao; + + static final String[] levels = new String[]{"3.25","3.5-","3.5","3.5+","3.75-","3.75","3.75+","4"}; + @Override public List resultProgressDistribution(int type, String monthTime,String departmentId) { @@ -68,7 +81,7 @@ public class ChartServiceImpl implements ChartService { .eq("is_delete", 0) .eq("type", type) .like("month_time",monthTime) - .in("status", ResultRecordStatusEnum.REFUSE.getStatus(),ResultRecordStatusEnum.AGREE.getStatus())); + .in("status", ResultRecordStatusEnum.REFUSE.getStatus(),ResultRecordStatusEnum.AGREE.getStatus(),ResultRecordStatusEnum.SUSPEND.getStatus())); GraphicsStatisticalDto dto = new GraphicsStatisticalDto(); if(total-commit>0){ @@ -133,13 +146,14 @@ public class ChartServiceImpl implements ChartService { @Override public PageUtils resultReportList(ReportListReq req, List staffIds) { // 状态为0的数据存在两张表,单独处理 - if(req.getStatus()!=0){ + if(!"0".equals(req.getStatus())){ + //获取真实状态 + List groupStatus = ResultRecordStatusEnum.getGroupStatus(req.getStatus()); + req.setRealStatus(groupStatus); //获取处理过业绩目标的人员 PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(),req.getPageSize()).doSelect( - page -> resultRecordMapper.targetReportList(req.getSelectMonthTime(), staffIds, page) + page -> resultRecordMapper.targetReportList(req, staffIds, page) ); - List list = pageUtils.getList(); - return pageUtils; }else { @@ -152,7 +166,7 @@ public class ChartServiceImpl implements ChartService { .ne("status", ResultRecordStatusEnum.CREATE.getStatus()) .select("staff_id")); if(CollectionUtils.isNotEmpty(collect)){ - commitStaffIds = collect.stream().map((Function) o -> o.toString()).collect(Collectors.toList()); + commitStaffIds = collect.stream().map(o -> o.toString()).collect(Collectors.toList()); } //去除已经提交的 staffIds.removeAll(commitStaffIds); @@ -173,4 +187,119 @@ public class ChartServiceImpl implements ChartService { return pageUtils; } } + + + @Override + public PageUtils reportDistribution(ResultDistributionReq req) { + List allDeparmentIds = staffService.selectAllDeparmentIdsByDepartmentParentId(req.getDepartmentId()); + // 去除存在子部门得id + allDeparmentIds.removeIf(s -> { + List departmentsEntities = departmentsDao.selectEntityByParentDepartmentId(s); + if(CollectionUtils.isNotEmpty(departmentsEntities)){ + return true; + } + return false; + }); + + // 由于deparmentIds 递归所得无法分页 则list分页 + List list = startPage(allDeparmentIds, req.getCurrPage(), req.getPageSize()); + return buildPages(list,req,allDeparmentIds.size()); + } + + + @Override + public String businessLineByStaffId(String staffId) { + DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateDao.selectByStaffId(Long.valueOf(staffId)); + String departmentId = departmentsStaffRelateEntity.getDepartmentId(); + return getBussinessLine(departmentId); + } + + private String getBussinessLine(String departmentId){ + DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(departmentId); + if("1".equals(departmentsEntity.getDepartmentParentId())){ + return departmentsEntity.getDepartmentName(); + } + return getBussinessLine(departmentsEntity.getDepartmentParentId()); + + } + + + private PageUtils buildPages( List departments,ResultDistributionReq req, int totalSize){ + List data = new ArrayList<>(); + if(CollectionUtils.isEmpty(departments)){ + return new PageUtils(); + } + departments.forEach(s -> { + DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(s); + List departmentsEntities = departmentsDao.selectEntityByParentDepartmentId(departmentsEntity.getDepartmentParentId()); + List staffIds = staffService.staffsByAllDeparmentIds(Lists.newArrayList(s)); + List staffLevels = resultRecordService.staffDistribution(req.getSelectMonthTime(),staffIds); + Map map = Maps.newHashMap(); + for (GraphicsStatisticalDto staffLevel : staffLevels) { + map.put(staffLevel.getCategory(),staffLevel.getNumber()); + } + ReportDistributionDto dto = new ReportDistributionDto(); + dto.setDepartmentId(s); + dto.setDepartmentName(departmentsEntity.getDepartmentName()); + dto.setBusinessLine(getBussinessLine(s)); + dto.setLevel1(map.get(levels[0])==null?0:map.get(levels[0])); + dto.setLevel2(map.get(levels[1])==null?0:map.get(levels[1])); + dto.setLevel3(map.get(levels[2])==null?0:map.get(levels[2])); + dto.setLevel4(map.get(levels[3])==null?0:map.get(levels[3])); + dto.setLevel5(map.get(levels[4])==null?0:map.get(levels[4])); + dto.setLevel6(map.get(levels[5])==null?0:map.get(levels[5])); + dto.setLevel7(map.get(levels[6])==null?0:map.get(levels[6])); + dto.setLevel8(map.get(levels[7])==null?0:map.get(levels[7])); + data.add(dto); + + }); + + PageUtils result = new PageUtils(); + result.setList(data); + result.setTotalCount(totalSize); + result.setCurrPage(req.getCurrPage()); + result.setPageSize(req.getPageSize()); + result.setTotalPage(PageUtil.totalPage(totalSize,req.getPageSize())); + return result; + } + + + + public static List startPage(List list, Integer pageNum, + Integer pageSize) { + if (list == null) { + return null; + } + if (list.size() == 0) { + return null; + } + + Integer count = list.size(); // 记录总数 + Integer pageCount = 0; // 页数 + if (count % pageSize == 0) { + pageCount = count / pageSize; + } else { + pageCount = count / pageSize + 1; + } + + int fromIndex = 0; // 开始索引 + int toIndex = 0; // 结束索引 + + if (!Objects.equals(pageNum, pageCount)) { + fromIndex = (pageNum - 1) * pageSize; + toIndex = fromIndex + pageSize; + } else { + fromIndex = (pageNum - 1) * pageSize; + toIndex = count; + } + + List pageList = list.subList(fromIndex, toIndex); + + return pageList; + } + + private boolean hasPermissions(Long staffId){ + return true; + + } } diff --git a/src/main/resources/mapper/app/ResultRecordMapper.xml b/src/main/resources/mapper/app/ResultRecordMapper.xml index 5e2c7236..4103e760 100644 --- a/src/main/resources/mapper/app/ResultRecordMapper.xml +++ b/src/main/resources/mapper/app/ResultRecordMapper.xml @@ -267,10 +267,12 @@ @@ -287,10 +289,27 @@ LEFT JOIN lz_staff_occupation o on r.staff_id = o.staff_id where r.is_delete=0 and o.is_delete=0 and type = 1 - and r.staff_id in - - #{item} - + + and r.staff_id in + + #{item} + + + + and r.staff_name like concat('%',#{req.staffName},'%') + + + and r.score_level = #{req.level} + + + and r.status in + + #{item} + + + + + GROUP BY r.staff_id diff --git a/src/main/resources/mapper/generator/DepartmentsDao.xml b/src/main/resources/mapper/generator/DepartmentsDao.xml index baa7b336..55e71d7c 100644 --- a/src/main/resources/mapper/generator/DepartmentsDao.xml +++ b/src/main/resources/mapper/generator/DepartmentsDao.xml @@ -119,11 +119,15 @@ From 469a9f70986e1fe2144c4e65ceac1a27f2f0e795 Mon Sep 17 00:00:00 2001 From: wulin Date: Sun, 27 Sep 2020 15:02:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0equipment=5Finfo=E7=9A=84?= =?UTF-8?q?=E4=B8=89=E4=B8=AA=E7=B1=BB=E5=9E=8B=E7=9A=84id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EquipmentController.java | 14 +++++++++----- .../modules/equipment/entity/EquipmentInfo.java | 10 ++++++++++ .../service/impl/EquipmentInfoServiceImpl.java | 6 +++--- .../mapper/equipment/EquipmentInfoMapper.xml | 17 ++++++++++++++++- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/lz/modules/equipment/controller/EquipmentController.java b/src/main/java/com/lz/modules/equipment/controller/EquipmentController.java index f3264b0b..948f2ae2 100644 --- a/src/main/java/com/lz/modules/equipment/controller/EquipmentController.java +++ b/src/main/java/com/lz/modules/equipment/controller/EquipmentController.java @@ -62,23 +62,27 @@ public class EquipmentController extends AbstractController { return R.ok(); } FindEquipmentResModel model = new FindEquipmentResModel(); + /*//下面的逻辑有bug下周修复20200925 EquipmentType equipmentType = iEquipmentTypeService.selectByType(equipmentInfo.getType()); EquipmentBrand equipmentBrand = equipmentBrandService.selectByBrand(equipmentInfo.getBrandName()); - EquipmentSpecs equipmentSpecs = equipmentSpecsService.selectSpecs(equipmentInfo.getSpecType()); + EquipmentSpecs equipmentSpecs = equipmentSpecsService.selectSpecs(equipmentInfo.getSpecType());*/ BeanUtils.copyProperties(equipmentInfo,model); model.setState(equipmentInfo.getEquipmentState()); if(equipmentInfo.getSaiId()!=null){ model.setUserId(equipmentInfo.getSaiId()); model.setEmployee(false); } - Optional.ofNullable(equipmentType).ifPresent(equipmentType1 -> model.setTypeId(equipmentType1.getId())); + model.setTypeId(equipmentInfo.getTypeId()); + model.setBrandId(equipmentInfo.getBrandId()); + model.setSpecId(equipmentInfo.getSpecsId()); + /*Optional.ofNullable(equipmentType).ifPresent(equipmentType1 -> model.setTypeId(equipmentType1.getId())); Optional.ofNullable(equipmentBrand).ifPresent(equipmentBrand1 -> model.setBrandId(equipmentBrand1.getId())); Optional.ofNullable(equipmentSpecs).ifPresent(new Consumer() { @Override public void accept(EquipmentSpecs equipmentSpecs1) { model.setSpecId(equipmentSpecs1.getId()); } - }); + });*/ // addRecord(equipmentInfo); return R.ok().put("data", model); @@ -109,8 +113,8 @@ public class EquipmentController extends AbstractController { try { iEquipmentInfoService.changeEquipmentInfo(dto,getUser()); } catch (Exception e) { - log.error("绑定设备异常",e); - return R.error(); + log.error("绑定设备异常{}",e); + return R.error(e.getMessage()); } return R.ok(); diff --git a/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java b/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java index 6965a7f3..0713e273 100644 --- a/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java +++ b/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java @@ -67,6 +67,13 @@ public class EquipmentInfo implements java.io.Serializable { private Long saiId; //第几次盘点 private Integer count; + + //类型id + private Long typeId; + //品牌id + private Long brandId; + //规格id + private Long specsId; /** * 主键id * @return @@ -454,6 +461,9 @@ public class EquipmentInfo implements java.io.Serializable { ",userId=" + userId + ",saiId=" + saiId + ",count=" + count + + ",typeId=" + typeId + + ",brandId=" + brandId + + ",specsId=" + specsId + "}"; } } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/equipment/service/impl/EquipmentInfoServiceImpl.java b/src/main/java/com/lz/modules/equipment/service/impl/EquipmentInfoServiceImpl.java index 69db429a..af8717eb 100644 --- a/src/main/java/com/lz/modules/equipment/service/impl/EquipmentInfoServiceImpl.java +++ b/src/main/java/com/lz/modules/equipment/service/impl/EquipmentInfoServiceImpl.java @@ -102,13 +102,13 @@ public class EquipmentInfoServiceImpl extends ServiceImpl + + + - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, brand_name AS brandName, spec_type AS specType, type AS type, num AS num, unit AS unit, user AS user, owner AS owner, qr AS qr, original_code AS originalCode, code AS code, mark AS mark, gmt_outbound AS gmtOutbound, gmt_inbound AS gmtInbound, equipment_state AS equipmentState, buy_amount AS buyAmount, sale_amount AS saleAmount, no AS no, user_id AS userId, sai_id AS saiId, count AS count + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, brand_name AS brandName, spec_type AS specType, type AS type, num AS num, unit AS unit, user AS user, owner AS owner, qr AS qr, original_code AS originalCode, code AS code, mark AS mark, gmt_outbound AS gmtOutbound, gmt_inbound AS gmtInbound, equipment_state AS equipmentState, buy_amount AS buyAmount, sale_amount AS saleAmount, no AS no, user_id AS userId, sai_id AS saiId, count AS count, type_id AS typeId, brand_id AS brandId, specs_id AS specsId @@ -65,6 +68,9 @@ no, user_id, sai_id, + type_id, + brand_id, + specs_id, count, is_delete, gmt_create, @@ -89,6 +95,9 @@ #{ no}, #{ userId}, #{ saiId}, + #{typeId}, + #{brandId}, + #{specsId]}, #{ count}, 0, now(), @@ -122,6 +131,9 @@ no = #{no}, user_id = #{userId}, sai_id = #{saiId}, + type_id=#{typeId}, + brand_id=#{brandId}, + specs_id=#{specsId]}, count = #{count} ,gmt_modified = now() @@ -154,6 +166,9 @@ no = #{no}, user_id = #{userId}, sai_id = #{saiId}, + type_id=#{typeId}, + brand_id=#{brandId}, + specs_id=#{specsId]}, count = #{count} ,gmt_modified = now() where id = #{id} From 2b4e7023d3048064b1903e6911dc0987e7ad60be Mon Sep 17 00:00:00 2001 From: wulin Date: Sun, 27 Sep 2020 15:11:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DspecsId=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipment/entity/EquipmentInfo.java | 24 +++++++++++++++++++ .../mapper/equipment/EquipmentInfoMapper.xml | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java b/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java index 0713e273..0bc5bdf4 100644 --- a/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java +++ b/src/main/java/com/lz/modules/equipment/entity/EquipmentInfo.java @@ -434,6 +434,30 @@ public class EquipmentInfo implements java.io.Serializable { this.count = count; } + public Long getTypeId() { + return typeId; + } + + public void setTypeId(Long typeId) { + this.typeId = typeId; + } + + public Long getBrandId() { + return brandId; + } + + public void setBrandId(Long brandId) { + this.brandId = brandId; + } + + public Long getSpecsId() { + return specsId; + } + + public void setSpecsId(Long specsId) { + this.specsId = specsId; + } + @Override public String toString() { return "EquipmentInfo{" + diff --git a/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml b/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml index 08d0998d..03a9771b 100644 --- a/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml +++ b/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml @@ -168,7 +168,7 @@ sai_id = #{saiId}, type_id=#{typeId}, brand_id=#{brandId}, - specs_id=#{specsId]}, + specs_id=#{specsId}, count = #{count} ,gmt_modified = now() where id = #{id}