shenyijian
2024-08-30 44d30cbd79df473dbdf6d28decde2bbc931c0821
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java
@@ -19,8 +19,10 @@
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
 * <p>
@@ -57,16 +59,19 @@
   }
   @Override
   public void delete(String id) {
      SgGxStepDO sgGxStepDO = sgGxStepMapper.selectById(id);
      if (!new LambdaQueryChainWrapper<>(sgGxRoleMapper).eq(SgGxRoleDO::getGxStepId,id).list().isEmpty()){
         throw  new ServiceException(sgGxStepDO.getGxStepName()+ "已绑定角色,无法删除");
   public void delete(String ids) {
      List<String> idList = Stream.of(ids.split(",")).sorted(Comparator.reverseOrder()) .collect(Collectors.toList());
      for (String id : idList) {
         SgGxStepDO sgGxStepDO = sgGxStepMapper.selectById(id);
         if (!new LambdaQueryChainWrapper<>(sgGxRoleMapper).eq(SgGxRoleDO::getGxStepId,id).list().isEmpty()){
            throw  new ServiceException(sgGxStepDO.getGxStepName()+ "已绑定角色,无法删除");
         }
         List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
         if (!sgGxStepDO.getGxStepNum().equals(list.get(0).getGxStepNum())){
            throw  new ServiceException("请按顺序删除工序步骤");
         }
         this.removeById(id);
      }
      List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
      if (!sgGxStepDO.getGxStepNum().equals(list.get(0).getGxStepNum())){
         throw  new ServiceException("请按顺序删除工序步骤");
      }
      this.removeById(id);
   }
   @Override
@@ -104,7 +109,7 @@
         SgGxRoleDO sgGxRoleDO=new SgGxRoleDO();
         sgGxRoleDO.setGxDeviceType(sgGxRoleVO.getGxDeviceType());
         sgGxRoleDO.setGxStepId(sgGxRoleVO.getGxStepId());
         sgGxRoleDO.setRoleId(Long.valueOf(roleIds.get(i)));
         sgGxRoleDO.setRoleId(roleIds.get(i));
         sgGxRoleDO.setSgOrder(sgGxRoleVO.getOrders().get(i));
         sgGxRoles.add(sgGxRoleDO);
      }
@@ -120,7 +125,7 @@
@Transactional
public void updateSgGxRole(SgGxRoleVO sgGxRoleVO){
      String gxStepId = sgGxRoleVO.getGxStepId();
      List<SgProgressReportDO> reportDOS = new LambdaQueryChainWrapper<>(sgProgressReportMapper).eq(s -> s.getGxStepId(), gxStepId).list();
      List<SgProgressReportDO> reportDOS = new LambdaQueryChainWrapper<>(sgProgressReportMapper).eq(SgProgressReportDO::getGxStepId, gxStepId).list();
      List<SgGxRoleDO> list = new LambdaQueryChainWrapper<>(sgGxRoleMapper).eq(SgGxRoleDO::getGxStepId, gxStepId).orderByAsc(SgGxRoleDO::getSgOrder).list();
      List<String> roles = list.stream().map(SgGxRoleDO::getRoleId).map(Object::toString).collect(Collectors.toList());
      List<Integer> orders  = list.stream().map(SgGxRoleDO::getSgOrder).collect(Collectors.toList());
@@ -151,7 +156,7 @@
      SgGxRoleDO sgGxRoleDO=new SgGxRoleDO();
      sgGxRoleDO.setGxDeviceType(sgGxRoleVO.getGxDeviceType());
      sgGxRoleDO.setGxStepId(sgGxRoleVO.getGxStepId());
      sgGxRoleDO.setRoleId(Long.valueOf(roleIds.get(i)));
      sgGxRoleDO.setRoleId(roleIds.get(i));
      sgGxRoleDO.setSgOrder(sgGxRoleVO.getOrders().get(i));
      sgGxRoles.add(sgGxRoleDO);
   }
@@ -170,4 +175,9 @@
      return    sgGxRoleMapper.getSgGxRoles(gxDeviceType, gxStepId);
   }
   @Override
   public List<SgGxStepDO> sgGxStepList() {
      return sgGxStepMapper.getDEviceGXtwo();
   }
}