yxm
2024-07-15 8014fd4239749b18c46a6edf59bd08558ddec9c4
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProgressReportServiceImpl.java
@@ -122,8 +122,16 @@
      }
      sgProgressReportDO.setStatus(0);
      sgProgressReportMapper.insert(sgProgressReportDO);
      SgDeviceDO sgDeviceDO = sgDeviceMapper.selectById(gxDeviceId);
      String deviceType = sgDeviceDO.getDeviceType();
      String deviceType ="";
      SgDeviceDO sgDeviceDO = new SgDeviceDO();
      if (gxDeviceId.equals("999")){
          deviceType = "sgzb";
      }else if(gxDeviceId.equals("998")){
         deviceType = "sgys";
      }else {
          sgDeviceDO = sgDeviceMapper.selectById(gxDeviceId);
         deviceType = sgDeviceDO.getDeviceType();
      }
      List<SgGxConfigDO> sgGxConfigDOS = new LambdaQueryChainWrapper<>(sgGxConfigMapper)
         .eq(SgGxConfigDO::getGxDeviceType, deviceType).eq(SgGxConfigDO::getGxStepId, gxStepId).orderByAsc(SgGxConfigDO::getSgOrder).list();
      List<String> roIds = sgGxConfigDOS.stream().map(SgGxConfigDO::getRoleId).collect(Collectors.toList());
@@ -443,45 +451,52 @@
      if (CollectionUtils.isNotEmpty(sgProgressReportDOS)) {
         sgProgressReportDOS.sort((u1, u2) -> u2.getCreateTime().compareTo(u1.getCreateTime()));
         SgProgressReportDO firstReport = sgProgressReportDOS.get(0);
         if (firstReport.getReportUser().equals(AuthUtil.getUserId()) && firstReport.getStatus().equals(3)) {
            sgReportVO.setGxDeviceId(deviceId);
            sgReportVO.setGxStepId(stepId);
            sgReportVO.setGxStepId(firstReport.getGxStepId());
            sgReportVO.setId(firstReport.getId());
            sgReportVO.setProframId(firstReport.getProframId());
            return sgReportVO;
         } else {
            sgReportVO.setGxDeviceId(deviceId);
            sgReportVO.setGxStepId(stepId);
            sgReportVO.setId(firstReport.getId());
            sgReportVO.setProframId(firstReport.getProframId());
            return sgReportVO;
         }
      } else {
         QueryWrapper<SgProgressReportDO> wrappers = new QueryWrapper<>();
         wrappers.eq("gx_device_id", deviceId).ne("status", 4).orderByDesc("create_time");
         sgProgressReportDOS = sgProgressReportMapper.selectList(wrappers);
         QueryWrapper<SgGxStepDO> wrapperss = new QueryWrapper<>();
         if (CollectionUtils.isNotEmpty(sgProgressReportDOS)) {
            sgProgressReportDOS.sort((u1, u2) -> u2.getCreateTime().compareTo(u1.getCreateTime()));
            SgProgressReportDO firstReport = sgProgressReportDOS.get(0);
            if (firstReport.getReportUser().equals(AuthUtil.getUserId()) && firstReport.getStatus().equals(2)) {
               sgReportVO.setGxDeviceId(deviceId);
               sgReportVO.setGxStepId(stepId);
               sgReportVO.setProframId(firstReport.getProframId());
            } else {
               throw new ServiceException("请完成上一步工序!");
            SgGxStepDO sgGxStepDO = sgGxStepMapper.selectOne(wrapperss.eq("id", stepId));
            List<SgGxStepDO> sgGxStepDOS = sgGxStepMapper.selectList(
               new QueryWrapper<SgGxStepDO>()
                  .lt("id", stepId)
                  .eq("gx_info_id", sgGxStepDO.getGxInfoId())
                  .orderByDesc("gx_step_num"));
            if (!sgGxStepDOS.isEmpty()) {
               if (sgGxStepDOS.get(0).getGxStepName().equals(firstReport.getGxStepName())&&firstReport.getStatus().equals(2)) {
                  sgReportVO.setGxDeviceId(deviceId);
                  sgReportVO.setGxStepId(sgGxStepDO.getId());
                  sgReportVO.setProframId(firstReport.getProframId());
               }else {
                  throw new ServiceException("请完成上一步工序!");
               }
            }
         }else {
            if (stepId!=null) {
               SgGxStepDO sg = sgGxStepMapper.selectOne(wrapperss.eq("id", stepId));
               if (sg.getGxStepNum().equals("01")) {
                  sgReportVO.setGxDeviceId(deviceId);
                  sgReportVO.setGxStepId(sg.getId());
                  sgReportVO.setProframId(sgProgressReportMapper.selectProframId(deviceId));
               }
               throw new ServiceException("第一工序未进行审批!");
            }
            sgReportVO.setProframId(sgProgressReportMapper.selectProframId(deviceId));
            sgReportVO.setGxStepId(sgGxStepMapper.queryStepList(deviceId.toString()).get(0).getId());
            sgReportVO.setGxDeviceId(deviceId);
         }
      }
      sgReportVO.setGxDeviceId(deviceId);
      sgReportVO.setGxStepId(stepId);
      sgReportVO.setProframId(sgProgressReportMapper.selectProframId(deviceId));
      return sgReportVO;
   }