| | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.exception.GlobalException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | public class TPedigreeChartController { |
| | | @Resource |
| | | private TPedigreeChartDetailService pedigreeChartDetailService; |
| | | |
| | | @Resource |
| | | private TPedigreeChartService pedigreeChartService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | @Resource |
| | | 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")){ |
| | | 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) |
| | | .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<>()); |
| | | |
| | | } |
| | | }else if (!sysUser.getRoleType().equals("1")){ |
| | | 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<>()); |
| | | |
| | | } |
| | | } |
| | | return R.ok(pedigreeChartService.pageList(query)); |
| | | } |
| | | |
| | |
| | | TPedigreeChartParentAllDTO dto = JSON.parseObject(param, TPedigreeChartParentAllDTO.class); |
| | | TPedigreeChart parent = dto.getParent(); |
| | | if (!dto.getOne().isEmpty()){ |
| | | String one1Json = JSON.toJSONString(dto.getOne().get(0)); |
| | | parent.setJson(one1Json); |
| | | String child = JSON.toJSONString(dto.getOne().get(0)); |
| | | parent.setJson(child); |
| | | } |
| | | List<String> projectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId()) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | if (!projectIds.isEmpty()){ |
| | | TProjectTeam projectTeam = projectTeamService.lambdaQuery().in(TProjectTeam::getId, projectIds) |
| | | .eq(TProjectTeam::getStatus, 1) |
| | | .orderByDesc(BaseModel::getCreateTime) |
| | | .last("limit 1").one(); |
| | | parent.setProjectId(projectTeam.getId()); |
| | | } |
| | | pedigreeChartService.save(parent); |
| | | if (!dto.getOne().isEmpty()){ |
| | | TPedigreeChartParentOneDTO one = dto.getOne().get(0); |
| | | one.setParentId("0"); |
| | | one.setType(1); |
| | | one.setStatus(one.getStatus()); |
| | | one.setStorageTime(LocalDateTime.now()); |
| | | one.setPedigreeChartId(parent.getId()); |
| | | one.setVaccinateId(loginUser.getUserId()+""); |
| | | one.setVaccinateSignature(one.getVaccinateSignature()); |
| | | one.setVaccinateTime(LocalDateTime.now()); |
| | | one.setId(null); |
| | | pedigreeChartDetailService.save(one); |
| | | List<TPedigreeChartParentOneCountDTO> countList = one.getChildren(); |
| | | TPedigreeChartParentOneDTO oneLevel = dto.getOne().get(0); |
| | | oneLevel.setParentId("0"); |
| | | oneLevel.setType(1); |
| | | oneLevel.setStatus(oneLevel.getStatus()); |
| | | oneLevel.setStorageTime(LocalDateTime.now()); |
| | | oneLevel.setPedigreeChartId(parent.getId()); |
| | | oneLevel.setVaccinateId(loginUser.getUserId()+""); |
| | | oneLevel.setVaccinateSignature(oneLevel.getVaccinateSignature()); |
| | | oneLevel.setVaccinateTime(LocalDateTime.now()); |
| | | oneLevel.setId(null); |
| | | pedigreeChartDetailService.save(oneLevel); |
| | | List<TPedigreeChartParentOneCountDTO> countList = oneLevel.getChildren(); |
| | | |
| | | if (!countList.isEmpty()){ |
| | | TPedigreeChartParentOneCountDTO count = countList.get(0); |
| | | count.setParentId(one.getId()); |
| | | count.setParentId(oneLevel.getId()); |
| | | count.setType(2); |
| | | count.setStatus(1); |
| | | count.setPedigreeChartId(parent.getId()); |
| | |
| | | pedigreeChartDetailService.save(count); |
| | | if (count.getChildren()!=null){ |
| | | for (TPedigreeChartParentTwoDTO tPedigreeChartParentTwoDTO : count.getChildren()) { |
| | | tPedigreeChartParentTwoDTO.setParentId(one.getId()); |
| | | tPedigreeChartParentTwoDTO.setParentId(oneLevel.getId()); |
| | | tPedigreeChartParentTwoDTO.setPedigreeChartId(parent.getId()); |
| | | tPedigreeChartParentTwoDTO.setType(1); |
| | | if (tPedigreeChartParentTwoDTO.getStatus()==null){ |
| | |
| | | tPedigreeChartParentTwoDTO.setVaccinateTime(LocalDateTime.now()); |
| | | tPedigreeChartParentTwoDTO.setStorageTime(LocalDateTime.now()); |
| | | tPedigreeChartParentTwoDTO.setParentId(count.getId()); |
| | | tPedigreeChartParentTwoDTO.setPedigreeChartId(parent.getId()); |
| | | tPedigreeChartParentTwoDTO.setId(null); |
| | | |
| | | pedigreeChartDetailService.save(tPedigreeChartParentTwoDTO); |
| | | List<TPedigreeChartParentTwoCountDTO> count1List = tPedigreeChartParentTwoDTO.getChildren(); |
| | | if (!count1List.isEmpty()){ |
| | | // 传代数 |
| | | TPedigreeChartParentTwoCountDTO count1 = count1List.get(0); |
| | | count1.setType(2); |
| | | count1.setParentId(tPedigreeChartParentTwoDTO.getId()); |
| | | count1.setPedigreeChartId(parent.getId()); |
| | | count1.setStatus(1); |
| | | count1.setId(null); |
| | | pedigreeChartDetailService.save(count1); |
| | | if (count1.getChildren()!=null){ |
| | | for (TPedigreeChartParentThreeDTO tPedigreeChartParentThreeDTO : count1.getChildren()) { |
| | | tPedigreeChartParentThreeDTO.setParentId(count1.getId()); |
| | | TPedigreeChartParentTwoCountDTO childCount = count1List.get(0); |
| | | childCount.setType(2); |
| | | childCount.setParentId(tPedigreeChartParentTwoDTO.getId()); |
| | | childCount.setPedigreeChartId(parent.getId()); |
| | | childCount.setStatus(1); |
| | | childCount.setId(null); |
| | | pedigreeChartDetailService.save(childCount); |
| | | if (childCount.getChildren()!=null){ |
| | | for (TPedigreeChartParentThreeDTO tPedigreeChartParentThreeDTO : childCount.getChildren()) { |
| | | tPedigreeChartParentThreeDTO.setParentId(childCount.getId()); |
| | | tPedigreeChartParentThreeDTO.setPedigreeChartId(parent.getId()); |
| | | tPedigreeChartParentThreeDTO.setType(1); |
| | | tPedigreeChartParentThreeDTO.setVaccinateId(loginUser.getUserId()+""); |
| | | if (tPedigreeChartParentThreeDTO.getStatus()==null){ |
| | | tPedigreeChartParentThreeDTO.setStatus(1); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | String one1Json = JSON.toJSONString(one); |
| | | parent.setJson(one1Json); |
| | | String child = JSON.toJSONString(oneLevel); |
| | | parent.setJson(child); |
| | | pedigreeChartService.updateById(parent); |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | List<String> collect = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId()) |
| | | .eq(TProjectTeamStaff::getRoleType, 2) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()){ |
| | | TProjectTeam team = projectTeamService.lambdaQuery().in(TProjectTeam::getId, collect) |
| | | .eq(TProjectTeam::getStatus, 1) |
| | | .orderByDesc(BaseModel::getCreateTime).last("limit 1").one(); |
| | | TProjectTeamStaff one1 = projectTeamStaffService.lambdaQuery() |
| | | .eq(TProjectTeamStaff::getTeamId, team.getId()).eq(TProjectTeamStaff::getRoleType, 2).one(); |
| | | tNotice.setCommitId(tokenService.getLoginUser().getUserId()+""); |
| | | tNotice.setUserId(one1.getUserId()); |
| | | tNotice.setStatus(1); |
| | | tNotice.setNoticeContent("菌种实验员新增【1】条【菌种传代生产谱系图】操作,等待您签字确认;"); |
| | | tNotice.setDataId(parent.getId()); |
| | | tNotice.setNoticeType(4); |
| | | noticeService.save(tNotice); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | List<String> allProjectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getTeamId,parent.getProjectId() ) |
| | | .eq(TProjectTeamStaff::getRoleType, 2) |
| | | .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | if (!allProjectIds.isEmpty()){ |
| | | TProjectTeam team = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds) |
| | | .eq(TProjectTeam::getStatus, 1) |
| | | .orderByDesc(BaseModel::getCreateTime).last("limit 1").one(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.lambdaQuery() |
| | | .eq(TProjectTeamStaff::getTeamId, team.getId()).eq(TProjectTeamStaff::getRoleType, 2).one(); |
| | | tNotice.setCommitId(tokenService.getLoginUser().getUserId()+""); |
| | | tNotice.setUserId(projectTeamStaff.getUserId()); |
| | | tNotice.setStatus(1); |
| | | tNotice.setNoticeContent("菌种实验员新增【1】条【菌种传代生产谱系图】操作,等待您签字确认;"); |
| | | tNotice.setDataId(parent.getId()); |
| | | tNotice.setNoticeType(4); |
| | | noticeService.save(tNotice); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | private TNoticeService noticeService; |
| | | /** |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:addProgenitor')") |
| | | @Log(title = "谱系图-编辑谱系图-编辑谱系图", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "编辑谱系图-编辑谱系图",response = TPedigreeChartParentAllDTO.class) |
| | | @PostMapping(value = "/api/t-pedigree-chart/editProgenitor") |
| | |
| | | TPedigreeChartParentAllDTO dto = JSON.parseObject(param, TPedigreeChartParentAllDTO.class); |
| | | TPedigreeChart parent = dto.getParent(); |
| | | if (!dto.getOne().isEmpty()){ |
| | | String one1Json = JSON.toJSONString(dto.getOne().get(0)); |
| | | parent.setJson(one1Json); |
| | | String child = JSON.toJSONString(dto.getOne().get(0)); |
| | | parent.setJson(child); |
| | | } |
| | | pedigreeChartService.updateById(parent); |
| | | if (parent.getGenerationType()==1){ |
| | | TPedigreeChartDetail one = pedigreeChartDetailService.getOne(new LambdaQueryWrapper<TPedigreeChartDetail>() |
| | | .eq(TPedigreeChartDetail::getPedigreeChartId, "0")); |
| | | if (one!=null){ |
| | | one.setStrainName(parent.getStrainName()); |
| | | one.setStrainCode(parent.getStrainCode()); |
| | | pedigreeChartDetailService.updateById( one); |
| | | } |
| | | } |
| | | |
| | | // pedigreeChartDetailService.remove(new LambdaQueryWrapper<TPedigreeChartDetail>() |
| | | // .eq(TPedigreeChartDetail::getPedigreeChartId, dto.getParent().getId())); |
| | | // if (!dto.getOne().isEmpty()){ |
| | |
| | | } |
| | | TPedigreeChartDetailDTO dto = JSON.parseObject(param, TPedigreeChartDetailDTO.class); |
| | | if (dto.getParentId().equals("0")){ |
| | | // 新增祖代 |
| | | // 新增祖/母代 |
| | | dto.setParentId("0"); |
| | | pedigreeChartDetailService.save(dto); |
| | | }else{ |
| | |
| | | // 祖代/母代 |
| | | TPedigreeChartParentOneDTO tPedigreeChartParentOneDTO = new TPedigreeChartParentOneDTO(); |
| | | BeanUtils.copyProperties(pedigreeChartDetail,tPedigreeChartParentOneDTO); |
| | | TPedigreeChartDetail pedigreeChartDetail1 = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentOneDTO.getId()) |
| | | TPedigreeChartDetail childCount = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentOneDTO.getId()) |
| | | && e.getType() == 2).findFirst().orElse(null); |
| | | // 传代计划数 |
| | | if (pedigreeChartDetail1!=null){ |
| | | if (childCount!=null){ |
| | | TPedigreeChartParentOneCountDTO tPedigreeChartParentOneCountDTO = new TPedigreeChartParentOneCountDTO(); |
| | | List<TPedigreeChartParentOneCountDTO> tPedigreeChartParentOneCountDTOS = new ArrayList<>(); |
| | | |
| | | BeanUtils.copyProperties(pedigreeChartDetail1,tPedigreeChartParentOneCountDTO); |
| | | BeanUtils.copyProperties(childCount,tPedigreeChartParentOneCountDTO); |
| | | tPedigreeChartParentOneCountDTO.setParent(pedigreeChartDetail); |
| | | // 祖代母代传代数 |
| | | List<TPedigreeChartDetail> collect = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentOneCountDTO.getId()) |
| | | 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 : collect) { |
| | | for (TPedigreeChartDetail tPedigreeChartDetail : childs) { |
| | | TPedigreeChartParentTwoDTO tPedigreeChartParentTwoDTO = new TPedigreeChartParentTwoDTO(); |
| | | BeanUtils.copyProperties(tPedigreeChartDetail,tPedigreeChartParentTwoDTO); |
| | | tPedigreeChartParentTwoDTO.setParent(pedigreeChartDetail1); |
| | | TPedigreeChartDetail pedigreeChartDetail2 = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoDTO.getId()) |
| | | tPedigreeChartParentTwoDTO.setParent(childCount); |
| | | TPedigreeChartDetail childCountChild = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoDTO.getId()) |
| | | && e.getType() == 2).findFirst().orElse(null); |
| | | if (pedigreeChartDetail2!=null){ |
| | | if (childCountChild!=null){ |
| | | ArrayList<TPedigreeChartParentTwoCountDTO> tPedigreeChartParentTwoCountDTOS = new ArrayList<>(); |
| | | TPedigreeChartParentTwoCountDTO tPedigreeChartParentTwoCountDTO = new TPedigreeChartParentTwoCountDTO(); |
| | | BeanUtils.copyProperties(pedigreeChartDetail2,tPedigreeChartParentTwoCountDTO); |
| | | List<TPedigreeChartDetail> collect1 = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoCountDTO.getId()) |
| | | BeanUtils.copyProperties(childCountChild,tPedigreeChartParentTwoCountDTO); |
| | | List<TPedigreeChartDetail> childChilds = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoCountDTO.getId()) |
| | | && e.getType() == 1).collect(Collectors.toList()); |
| | | for (TPedigreeChartDetail chartDetail : collect1) { |
| | | for (TPedigreeChartDetail chartDetail : childChilds) { |
| | | TPedigreeChartParentThreeDTO tPedigreeChartParentThreeDTO = new TPedigreeChartParentThreeDTO(); |
| | | BeanUtils.copyProperties(chartDetail,tPedigreeChartParentThreeDTO); |
| | | tPedigreeChartParentThreeDTO.setParent(pedigreeChartDetail2); |
| | | tPedigreeChartParentThreeDTO.setParent(childCountChild); |
| | | tPedigreeChartParentThreeDTOS.add(tPedigreeChartParentThreeDTO); |
| | | } |
| | | tPedigreeChartParentTwoCountDTO.setChildren(tPedigreeChartParentThreeDTOS); |
| | |
| | | /** |
| | | * 谱系图-菌种传代生产谱系图详情-菌种详情 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:strainInfo')") |
| | | @ApiOperation(value = "谱系图-菌种传代生产谱系图详情-菌种详情") |
| | | @GetMapping(value = "/api/t-pedigree-chart/strainInfo") |
| | | public R strainInfo(@RequestParam String id) { |
| | |
| | | pedigreeChartDetail1.setVaccinateId(tokenService.getLoginUser().getUserId()+""); |
| | | pedigreeChartDetail1.setVaccinateTime(LocalDateTime.now()); |
| | | pedigreeChartDetail1.setVaccinateSignature(dto.getVaccinateSignature()); |
| | | TPedigreeChartDetail byId = pedigreeChartDetailService.getById(dto.getParentId()); |
| | | TPedigreeChartDetail tPedigreeChartDetail = pedigreeChartDetailService.getById(dto.getParentId()); |
| | | pedigreeChartDetail1.setGenerationCount(dto.getGenerationCount()); |
| | | pedigreeChartDetail1.setPedigreeChartId(byId.getPedigreeChartId()); |
| | | pedigreeChartDetail1.setPedigreeChartId(tPedigreeChartDetail.getPedigreeChartId()); |
| | | pedigreeChartDetail1.setType(2); |
| | | pedigreeChartDetailService.save(pedigreeChartDetail1); |
| | | return R.ok(); |
| | |
| | | pedigreeChartDetailService.updateById(pedigreeChartDetail); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 谱系图-代确认入库菌种列表 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:listConfirm')") |
| | | // @ApiOperation(value = "谱系图-代确认入库菌种列表",response = TPedigreeChartConfirmQuery.class) |
| | | // @GetMapping(value = "/api/t-pedigree-chart/listConfirm") |
| | | // public R<PageInfo<TPedigreeChartConfirmVO>> listConfirm(@RequestBody String param) { |
| | | // TPedigreeChartConfirmQuery query = JSON.parseObject(param, TPedigreeChartConfirmQuery.class); |
| | | // return R.ok(pedigreeChartService.listConfirm(query)); |
| | | // } |
| | | |
| | | } |
| | | |