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 fb246d52..13c3e8e6 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; @@ -47,5 +48,7 @@ public interface DepartmentsDao extends BaseMapper { List selectDepartmentIdsByparentIds(@Param("parentIds") List parentIds); + List selectDepartmentIdsByparentIds(@Param("parentIds") List parentIds, @Param("page") IPage page); + List selectDeparmentLevel1(); } 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 991c4ef0..84b29c0d 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 08bb7f87..f56ec600 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,10 +8,14 @@ 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.apache.commons.collections.CollectionUtils; @@ -30,6 +34,8 @@ public class DepartmentsServiceImpl extends ServiceImpl params) { @@ -188,7 +194,7 @@ public class DepartmentsServiceImpl extends ServiceImpl(set); } - public void addDD(Set set ,String dd){ + public void addDD(Set set , String dd){ if(StringUtil.isNotBlank(dd)){ set.add(dd); } @@ -221,4 +227,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/equipment/controller/EquipmentBrandController.java b/src/main/java/com/lz/modules/equipment/controller/EquipmentBrandController.java index a357bcc6..6023884c 100644 --- a/src/main/java/com/lz/modules/equipment/controller/EquipmentBrandController.java +++ b/src/main/java/com/lz/modules/equipment/controller/EquipmentBrandController.java @@ -9,6 +9,7 @@ import com.lz.modules.equipment.entity.EquipmentBrandReq; import com.lz.modules.equipment.entity.EquipmentType; import com.lz.modules.equipment.entity.resp.EquipmentBrandResp; import com.lz.modules.equipment.service.EquipmentBrandService; +import com.lz.modules.equipment.service.IEquipmentInfoService; import com.lz.modules.equipment.service.IEquipmentTypeService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -39,6 +40,9 @@ public class EquipmentBrandController { @Autowired private IEquipmentTypeService equipmentTypeService; + @Resource + private IEquipmentInfoService equipmentInfoService; + /** * 添加品牌表页面 * @@ -91,6 +95,7 @@ public class EquipmentBrandController { EquipmentBrand equipmentBrand = equipmentBrandService.selectEquipmentBrandById(req.getId()); BeanUtils.copyProperty(equipmentBrand, req, true); equipmentBrandService.updateEquipmentBrandById(equipmentBrand); + equipmentInfoService.updateCoverEquipmentInfoByBrandId(equipmentBrand.getId(), equipmentBrand.getBrand()); return R.ok("编辑成功"); } 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 72b9c884..7b6cfc60 100644 --- a/src/main/java/com/lz/modules/equipment/controller/EquipmentController.java +++ b/src/main/java/com/lz/modules/equipment/controller/EquipmentController.java @@ -64,23 +64,27 @@ public class EquipmentController extends AbstractController { return R.ok(); } FindEquipmentResModel model = new FindEquipmentResModel(); + /*//下面的逻辑有bug下周修复20200925 20200927修复,注释掉 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); @@ -112,8 +116,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/controller/EquipmentSpecsController.java b/src/main/java/com/lz/modules/equipment/controller/EquipmentSpecsController.java index 0cb91227..992f7ac4 100644 --- a/src/main/java/com/lz/modules/equipment/controller/EquipmentSpecsController.java +++ b/src/main/java/com/lz/modules/equipment/controller/EquipmentSpecsController.java @@ -10,6 +10,7 @@ import com.lz.modules.equipment.entity.EquipmentType; import com.lz.modules.equipment.entity.resp.EquipmentSpecsResp; import com.lz.modules.equipment.service.EquipmentBrandService; import com.lz.modules.equipment.service.EquipmentSpecsService; +import com.lz.modules.equipment.service.IEquipmentInfoService; import com.lz.modules.equipment.service.IEquipmentTypeService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -40,6 +41,9 @@ public class EquipmentSpecsController { @Autowired private EquipmentBrandService equipmentBrandService; + @Resource + private IEquipmentInfoService equipmentInfoService; + /** * 添加规格表页面 * @@ -97,6 +101,7 @@ public class EquipmentSpecsController { equipmentSpecs.setGmtCreate(equipmentSpecs.getGmtCreate()); equipmentSpecs.setGmtModified(new Date()); equipmentSpecsService.updateEquipmentSpecsById(equipmentSpecs); + equipmentInfoService.updateCoverEquipmentInfoBySpecsId(equipmentSpecs.getId(), equipmentSpecs.getSpecs()); return R.ok("编辑成功"); } diff --git a/src/main/java/com/lz/modules/equipment/controller/EquipmentTypeController.java b/src/main/java/com/lz/modules/equipment/controller/EquipmentTypeController.java index 3c33384f..41d77eb7 100644 --- a/src/main/java/com/lz/modules/equipment/controller/EquipmentTypeController.java +++ b/src/main/java/com/lz/modules/equipment/controller/EquipmentTypeController.java @@ -6,6 +6,7 @@ import com.lz.common.utils.R; import com.lz.modules.app.utils.BeanUtils; import com.lz.modules.equipment.entity.EquipmentType; import com.lz.modules.equipment.entity.EquipmentTypeReq; +import com.lz.modules.equipment.service.IEquipmentInfoService; import com.lz.modules.equipment.service.IEquipmentTypeService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +30,9 @@ public class EquipmentTypeController { @Resource private IEquipmentTypeService equipmentTypeService; + @Resource + private IEquipmentInfoService equipmentInfoService; + /** * 添加类型表页面 @@ -79,6 +83,8 @@ public class EquipmentTypeController { EquipmentType equipmentType = equipmentTypeService.selectEquipmentTypeById(req.getId()); BeanUtils.copyProperty(equipmentType,req,true); equipmentTypeService.updateEquipmentTypeById(equipmentType); + //更新所有再记录中所有的类型名称 + equipmentInfoService.updateCoverEquipmentInfoByTypeId(equipmentType.getId(), equipmentType.getType()); return R.ok("编辑成功"); } diff --git a/src/main/java/com/lz/modules/equipment/dao/EquipmentInfoMapper.java b/src/main/java/com/lz/modules/equipment/dao/EquipmentInfoMapper.java index dfd4e972..1100e4d3 100644 --- a/src/main/java/com/lz/modules/equipment/dao/EquipmentInfoMapper.java +++ b/src/main/java/com/lz/modules/equipment/dao/EquipmentInfoMapper.java @@ -54,4 +54,8 @@ public interface EquipmentInfoMapper extends BaseMapper { int selectCountByNotFind(@Param("num") Integer num); int selectCountAllDepartment(@Param("num") Integer num); + + int updateCoverEquipmentInfoByTypeId(@Param("id") Long id, @Param("type") String type); + int updateCoverEquipmentInfoByBrandId(@Param("id") Long id, @Param("brand") String brand); + int updateCoverEquipmentInfoBySpecsId(@Param("id") Long id, @Param("specs") String specs); } \ No newline at end of file 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..0bc5bdf4 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 @@ -427,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{" + @@ -454,6 +485,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/IEquipmentInfoService.java b/src/main/java/com/lz/modules/equipment/service/IEquipmentInfoService.java index a7b64429..8642a129 100644 --- a/src/main/java/com/lz/modules/equipment/service/IEquipmentInfoService.java +++ b/src/main/java/com/lz/modules/equipment/service/IEquipmentInfoService.java @@ -61,4 +61,10 @@ public interface IEquipmentInfoService extends IService { int selectCountByNotFind(Integer num); int selectCountAllDepartment(int num); + + int updateCoverEquipmentInfoByTypeId(Long id, String type); + + int updateCoverEquipmentInfoByBrandId(Long id, String brand); + + int updateCoverEquipmentInfoBySpecsId(Long id, String specs); } \ 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 4d5cf5e4..e6094e20 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 @@ -108,13 +108,13 @@ public class EquipmentInfoServiceImpl extends ServiceImpl { 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 fd8e9750..c6711464 100644 --- a/src/main/resources/mapper/app/ResultRecordMapper.xml +++ b/src/main/resources/mapper/app/ResultRecordMapper.xml @@ -273,10 +273,12 @@ @@ -293,10 +295,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/equipment/EquipmentInfoMapper.xml b/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml index 1db2ec23..5ad34d5f 100644 --- a/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml +++ b/src/main/resources/mapper/equipment/EquipmentInfoMapper.xml @@ -28,12 +28,15 @@ + + + - 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} @@ -278,5 +293,17 @@ select ifnull(count(*),0) from equipment_info where is_delete = 0 and count =#{num} and depart_id is not null and depart_id > 0 + + update equipment_info set type = #{type} where type_id=#{id} + + + + update equipment_info set brand_name = #{brand} where type_id=#{id} + + + + update equipment_info set spec_type = #{specs} where type_id=#{id} + + 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 @@ diff --git a/src/main/resources/mapper/generator/DepartmentsDao.xml b/src/main/resources/mapper/generator/DepartmentsDao.xml index f8a4bcb1..17e94aae 100644 --- a/src/main/resources/mapper/generator/DepartmentsDao.xml +++ b/src/main/resources/mapper/generator/DepartmentsDao.xml @@ -119,11 +119,15 @@