| | |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.*; |
| | | import com.ruoyi.system.mapper.TProjectTeamMapper; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TPedigreeChartConfirmQuery; |
| | | import com.ruoyi.system.query.TPedigreeChartDetailConfirmCountDTO; |
| | |
| | | private ISysUserService sysUserService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取谱系图分页列表 |
| | | */ |
| | |
| | | @ApiOperation(value = "谱系图-获取谱系图分页列表",response = TPedigreeChartQuery.class) |
| | | @PostMapping(value = "/api/t-pedigree-chart/pageList") |
| | | public R<PageInfo<TPedigreeChartVO>> pageList(@RequestBody String param) { |
| | | |
| | | TPedigreeChartQuery query = JSON.parseObject(param, TPedigreeChartQuery.class); |
| | | SysUser sysUser = sysUserService.selectUserById(tokenService.getLoginUser().getUserId()); |
| | | if (sysUser.getRoleType().equals("2")){ |
| | | query.setRoleType(2); |
| | | List<String> allProjectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId()) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | if (!allProjectIds.isEmpty()){ List<String> projectIds = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds) |
| | | if (!allProjectIds.isEmpty()){ |
| | | List<String> projectIds = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds) |
| | | .list().stream().map(TProjectTeam::getId).collect(Collectors.toList()); |
| | | if (projectIds.isEmpty()){ |
| | | return R.ok(new PageInfo<>()); |
| | |
| | | }else if (!sysUser.getRoleType().equals("1")){ |
| | | query.setRoleType(3); |
| | | |
| | | List<String> allProjectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId()) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | if (!allProjectIds.isEmpty()){ List<String> projectIds = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds) |
| | | .eq(TProjectTeam::getStatus, 1).list().stream().map(TProjectTeam::getId).collect(Collectors.toList()); |
| | | |
| | | if (projectIds.isEmpty()){ |
| | | if (query.getProjectIds() == null || query.getProjectIds().isEmpty()){ |
| | | List<String> allProjectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId()) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | if (!allProjectIds.isEmpty()){ |
| | | List<String> projectIds = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds) |
| | | .eq(TProjectTeam::getStatus, 1).list().stream().map(TProjectTeam::getId).collect(Collectors.toList()); |
| | | if (projectIds.isEmpty()){ |
| | | return R.ok(new PageInfo<>()); |
| | | } |
| | | query.setProjectIds(projectIds); |
| | | }else{ |
| | | return R.ok(new PageInfo<>()); |
| | | } |
| | | query.setProjectIds(projectIds); |
| | | }else{ |
| | | return R.ok(new PageInfo<>()); |
| | | |
| | | } |
| | | |
| | | }else{ |
| | | query.setRoleType(1); |
| | | } |
| | |
| | | count.setPedigreeChartId(parent.getId()); |
| | | count.setId(null); |
| | | if (parent.getStatus()==1){ |
| | | count.setAuditStatus(0); |
| | | count.setAuditStatus(1); |
| | | }else{ |
| | | count.setAuditStatus(1); |
| | | } |
| | |
| | | TPedigreeChartParentTwoCountDTO childCount = count1List.get(0); |
| | | childCount.setType(2); |
| | | if (parent.getStatus()==1){ |
| | | count.setAuditStatus(0); |
| | | childCount.setAuditStatus(1); |
| | | }else{ |
| | | count.setAuditStatus(1); |
| | | childCount.setAuditStatus(1); |
| | | } |
| | | count.setVaccinateId(loginUser.getUserId()+""); |
| | | count.setVaccinateTime(LocalDateTime.now()); |
| | | childCount.setVaccinateId(loginUser.getUserId()+""); |
| | | childCount.setVaccinateTime(LocalDateTime.now()); |
| | | childCount.setParentId(tPedigreeChartParentTwoDTO.getId()); |
| | | childCount.setPedigreeChartId(parent.getId()); |
| | | childCount.setStatus(1); |
| | |
| | | String child = JSON.toJSONString(dto.getOne().get(0)); |
| | | parent.setJson(child); |
| | | } |
| | | |
| | | //不能修改别人的数据 |
| | | TPedigreeChart byId = pedigreeChartService.getById(parent.getId()); |
| | | if (!loginUser.getUser().getNickName().equals(byId.getCreateBy())) { |
| | | return R.fail("不能修改其他工程师数据"); |
| | | } |
| | | |
| | | List<String> projectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, |
| | | tokenService.getLoginUser().getUserId()) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | |
| | | Integer status = parent.getStatus(); |
| | | TPedigreeChart pedigreeChart = pedigreeChartService.getById(parent.getId()); |
| | | if (pedigreeChart.getStatus() == 2){ |
| | | parent.setStatus(2); |
| | | return R.fail("谱系图已提交,不可编辑"); |
| | | } |
| | | pedigreeChartService.updateById(parent); |
| | | parent.setStatus( status); |
| | |
| | | count.setStatus(1); |
| | | if (count.getId()==null){ |
| | | if (parent.getStatus()==1){ |
| | | count.setAuditStatus(0); |
| | | count.setAuditStatus(1); |
| | | count.setCodeStatus(parent.getStatus()); |
| | | }else{ |
| | | count.setAuditStatus(1); |
| | |
| | | childCount.setType(2); |
| | | if (childCount.getId()==null){ |
| | | if (parent.getStatus()==1){ |
| | | childCount.setAuditStatus(0); |
| | | childCount.setAuditStatus(1); |
| | | childCount.setCodeStatus(parent.getStatus()); |
| | | }else{ |
| | | childCount.setAuditStatus(1); |
| | |
| | | .eq(TProjectTeam::getStatus, 1) |
| | | .orderByDesc(BaseModel::getCreateTime).last("limit 1").one(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.lambdaQuery() |
| | | .eq(TProjectTeamStaff::getTeamId, team.getId()).eq(TProjectTeamStaff::getRoleType, 1).one(); |
| | | .eq(TProjectTeamStaff::getTeamId, team.getId()).eq(TProjectTeamStaff::getRoleType, 2).one(); |
| | | tNotice.setCommitId(tokenService.getLoginUser().getUserId()+""); |
| | | tNotice.setUserId(projectTeamStaff.getUserId()); |
| | | tNotice.setStatus(1); |
| | |
| | | } |
| | | @Log(title = "谱系图-谱系图-删除谱系图", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "谱系图-删除谱系图") |
| | | @Transactional |
| | | @DeleteMapping(value = "/open/t-pedigree-chart/deleteProgenitor") |
| | | public R<Boolean> deleteProgenitor(@RequestParam String id) { |
| | | pedigreeChartService.removeById(id); |
| | |
| | | @ApiOperation(value = "谱系图-删除菌种传代项",response = TPedigreeChartParentDTO.class) |
| | | @DeleteMapping(value = "/open/t-pedigree-chart/deleteProgenitorChild") |
| | | public R<Boolean> deleteProgenitorChild(@RequestParam String id) { |
| | | pedigreeChartDetailService.removeById(id); |
| | | List<TPedigreeChartDetail> children = pedigreeChartDetailService.lambdaQuery().eq(TPedigreeChartDetail::getParentId, id) |
| | | .list(); |
| | | if (!children.isEmpty()){ |
| | | return R.fail("请先删除子项"); |
| | | } |
| | | pedigreeChartDetailService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "谱系图-谱系图-编辑菌种传代/传代数项", businessType = BusinessType.UPDATE) |
| | |
| | | TPedigreeChartDetailQuery query = JSON.parseObject(param, TPedigreeChartDetailQuery.class); |
| | | return R.ok(pedigreeChartService.pageListDetail(query)); |
| | | } |
| | | |
| | | @Resource |
| | | private TProjectTeamMapper tProjectTeamMapper; |
| | | |
| | | /** |
| | | * 谱系图-菌种传代生产谱系图详情 |
| | | */ |
| | |
| | | public R<TPedigreeChart> getDetailInfoById(@RequestParam String id) { |
| | | List<TPedigreeChartParentOneDTO> tPedigreeChartParentOneDTOS = new ArrayList<>(); |
| | | TPedigreeChart pedigreeChart = pedigreeChartService.getById(id); |
| | | List<TPedigreeChartDetail> details = pedigreeChartDetailService.lambdaQuery().eq(TPedigreeChartDetail::getPedigreeChartId, id).list(); |
| | | if (pedigreeChart == null) { |
| | | return R.fail("谱系图不存在或已删除"); |
| | | } |
| | | List<TPedigreeChartDetail> details = new ArrayList<>(pedigreeChartDetailService.lambdaQuery() |
| | | .eq(TPedigreeChartDetail::getPedigreeChartId, id) |
| | | .orderByDesc(TPedigreeChartDetail::getUpdateTime) |
| | | .orderByDesc(TPedigreeChartDetail::getCreateTime) |
| | | .list().stream() |
| | | .filter(detail -> StringUtils.isNotEmpty(detail.getId())) |
| | | .collect(Collectors.toMap( |
| | | TPedigreeChartDetail::getId, |
| | | detail -> detail, |
| | | (first, duplicate) -> first, |
| | | LinkedHashMap::new |
| | | )).values()); |
| | | TPedigreeChartParentAllDetailDTO tPedigreeChartParentAllDetailDTO = new TPedigreeChartParentAllDetailDTO(); |
| | | // 祖代 |
| | | TPedigreeChartDetail pedigreeChartDetail = details.stream().filter(e -> e.getParentId().equals("0") |
| | |
| | | List<TPedigreeChartDetail> childs = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentOneCountDTO.getId()) |
| | | && e.getType() == 1).collect(Collectors.toList()); |
| | | List<TPedigreeChartParentTwoDTO> tPedigreeChartParentTwoDTOS = new ArrayList<>(); |
| | | List<TPedigreeChartParentThreeDTO> tPedigreeChartParentThreeDTOS = new ArrayList<>(); |
| | | for (TPedigreeChartDetail tPedigreeChartDetail : childs) { |
| | | TPedigreeChartParentTwoDTO tPedigreeChartParentTwoDTO = new TPedigreeChartParentTwoDTO(); |
| | | BeanUtils.copyProperties(tPedigreeChartDetail,tPedigreeChartParentTwoDTO); |
| | |
| | | ArrayList<TPedigreeChartParentTwoCountDTO> tPedigreeChartParentTwoCountDTOS = new ArrayList<>(); |
| | | TPedigreeChartParentTwoCountDTO tPedigreeChartParentTwoCountDTO = new TPedigreeChartParentTwoCountDTO(); |
| | | BeanUtils.copyProperties(childCountChild,tPedigreeChartParentTwoCountDTO); |
| | | List<TPedigreeChartParentThreeDTO> tPedigreeChartParentThreeDTOS = new ArrayList<>(); |
| | | List<TPedigreeChartDetail> childChilds = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoCountDTO.getId()) |
| | | && e.getType() == 1).collect(Collectors.toList()); |
| | | for (TPedigreeChartDetail chartDetail : childChilds) { |
| | |
| | | tPedigreeChartParentAllDetailDTO.setOne(tPedigreeChartParentOneDTOS); |
| | | } |
| | | pedigreeChart.setPedigreeChartParentAllDetailDTO(tPedigreeChartParentAllDetailDTO); |
| | | |
| | | if (com.ruoyi.common.utils.StringUtils.isNotEmpty(pedigreeChart.getProjectId())) { |
| | | TProjectTeam tProjectTeam = tProjectTeamMapper.selectById(pedigreeChart.getProjectId()); |
| | | if (tProjectTeam != null) { |
| | | List<TProjectTeamStaff> list = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getTeamId, tProjectTeam.getId()).list(); |
| | | StringBuilder staffNames = new StringBuilder(); |
| | | for (TProjectTeamStaff tProjectTeamStaff : list) { |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(tProjectTeamStaff.getUserId())); |
| | | if (sysUser!=null){ |
| | | staffNames.append(sysUser.getNickName()).append(","); |
| | | } |
| | | } |
| | | if (org.springframework.util.StringUtils.hasLength(staffNames.toString())){ |
| | | tProjectTeam.setStaff(staffNames.substring(0, staffNames.toString().length() - 1)); |
| | | } |
| | | |
| | | List<TProjectTeam> tProjectTeamList = new ArrayList<>(); |
| | | tProjectTeamList.add(tProjectTeam); |
| | | pedigreeChart.setTProjectTeamList(tProjectTeamList); |
| | | } |
| | | } |
| | | |
| | | return R.ok(pedigreeChart); |
| | | } |
| | | /** |
| | |
| | | pedigreeChartDetail1.setType(2); |
| | | |
| | | pedigreeChartDetail1.setCodeStatus(dto.getCodeStatus()); |
| | | if (dto.getCodeStatus()==1){ |
| | | pedigreeChartDetail1.setAuditStatus(0); |
| | | }else{ |
| | | pedigreeChartDetail1.setAuditStatus(1); |
| | | } |
| | | pedigreeChartDetail1.setAuditStatus(1); |
| | | pedigreeChartDetailService.save(pedigreeChartDetail1); |
| | | return R.ok(); |
| | | } |