From 44d30cbd79df473dbdf6d28decde2bbc931c0821 Mon Sep 17 00:00:00 2001
From: shenyijian <1178253012@qq.com>
Date: Fri, 30 Aug 2024 18:19:47 +0800
Subject: [PATCH] 湖北水库:工程项目树数量修改
---
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java | 137 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 131 insertions(+), 6 deletions(-)
diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java
index 4c524b7..8a63545 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java
@@ -1,16 +1,28 @@
package cn.gistack.sm.sg.service.impl;
+import cn.gistack.sm.sg.DO.SgGxRoleDO;
import cn.gistack.sm.sg.DO.SgGxStepDO;
+import cn.gistack.sm.sg.DO.SgProgressReportDO;
import cn.gistack.sm.sg.DTO.ProjectSearchDTO;
+import cn.gistack.sm.sg.VO.SgGxRoleVO;
+import cn.gistack.sm.sg.mapper.SgGxRoleMapper;
import cn.gistack.sm.sg.mapper.SgGxStepMapper;
+import cn.gistack.sm.sg.mapper.SgProgressReportMapper;
import cn.gistack.sm.sg.service.SgGxStepService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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>
@@ -24,6 +36,12 @@
public class SgGxStepServiceImpl extends ServiceImpl<SgGxStepMapper, SgGxStepDO> implements SgGxStepService {
@Autowired
private SgGxStepMapper sgGxStepMapper;
+ @Autowired
+ private SgGxRoleMapper sgGxRoleMapper;
+
+ @Autowired
+ private SgProgressReportMapper sgProgressReportMapper;
+
@Override
public void add(SgGxStepDO sgGxStepDO) {
List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
@@ -41,13 +59,19 @@
}
@Override
- public void delete(String id) {
- SgGxStepDO sgGxStepDO = sgGxStepMapper.selectById(id);
- List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
- if (!sgGxStepDO.getGxStepNum().equals(list.get(0).getGxStepNum())){
- throw new ServiceException("请按顺序删除工序步骤");
+ 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);
}
- this.removeById(id);
}
@Override
@@ -55,4 +79,105 @@
List<SgGxStepDO> list = sgGxStepMapper.queryPageList(page,searchDTO);
return page.setRecords(list);
}
+
+ /**
+ * 新增工序角色配置逻辑
+ * @param sgGxRoleVO
+ */
+ @Override
+ public void insertSgGxRole(SgGxRoleVO sgGxRoleVO){
+
+
+ if (sgGxRoleVO.getGxStepId()==null){
+ throw new ServiceException("工序步骤参数错误");
+ }
+ if (sgGxRoleVO.getGxDeviceType()==null){
+ throw new ServiceException("工序类型参数错误");
+ }
+
+ List<SgGxRoleDO> sgGxRoleDOS = sgGxRoleMapper.selectSgGxRole(sgGxRoleVO.getGxDeviceType(), sgGxRoleVO.getGxStepId());
+ if (sgGxRoleDOS==null||sgGxRoleDOS.size()>0){
+ throw new ServiceException("已存在相同的工序角色配置");
+ }
+ List<SgGxRoleDO> sgGxRoles=new ArrayList<>();
+
+ if (sgGxRoleVO.getRoleIds()==null||sgGxRoleVO.getRoleIds().size()==0){
+ throw new ServiceException("工序角色参数错误");
+ }
+ List<String> roleIds = sgGxRoleVO.getRoleIds();
+ for (int i = 0; i <roleIds.size() ; i++) {
+ SgGxRoleDO sgGxRoleDO=new SgGxRoleDO();
+ sgGxRoleDO.setGxDeviceType(sgGxRoleVO.getGxDeviceType());
+ sgGxRoleDO.setGxStepId(sgGxRoleVO.getGxStepId());
+ sgGxRoleDO.setRoleId(roleIds.get(i));
+ sgGxRoleDO.setSgOrder(sgGxRoleVO.getOrders().get(i));
+ sgGxRoles.add(sgGxRoleDO);
+ }
+ sgGxRoleMapper.insertBach(sgGxRoles);
+ }
+
+
+ /**
+ * 更新工序角色配置
+ * @param sgGxRoleVO
+ */
+ @Override
+@Transactional
+public void updateSgGxRole(SgGxRoleVO sgGxRoleVO){
+ String gxStepId = sgGxRoleVO.getGxStepId();
+ 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());
+ if (!reportDOS.isEmpty()){
+ if (! roles.equals(sgGxRoleVO.getRoleIds()) || ! orders.equals(sgGxRoleVO.getOrders())) {
+ throw new ServiceException("此配置已有上报记录,不允许修改");
+ }
+ }
+ if (sgGxRoleVO.getGxStepId()==null){
+ throw new ServiceException("工序步骤参数错误");
+ }
+ if (sgGxRoleVO.getGxDeviceType()==null){
+ throw new ServiceException("工序类型参数错误");
+ }
+
+ List<SgGxRoleDO> sgGxRoleDOS = sgGxRoleMapper.selectSgGxRole(sgGxRoleVO.getGxDeviceType(), sgGxRoleVO.getGxStepId());
+ if (sgGxRoleDOS==null||sgGxRoleDOS.size()>0){
+ //删除原来的
+ sgGxRoleMapper.deleteSgGxRoleDOs(sgGxRoleVO.getGxDeviceType(),sgGxRoleVO.getGxStepId());
+ }
+ List<SgGxRoleDO> sgGxRoles=new ArrayList<>();
+
+ if (sgGxRoleVO.getRoleIds()==null||sgGxRoleVO.getRoleIds().size()==0){
+ throw new ServiceException("工序角色参数错误");
+ }
+ List<String> roleIds = sgGxRoleVO.getRoleIds();
+ for (int i = 0; i <roleIds.size() ; i++) {
+ SgGxRoleDO sgGxRoleDO=new SgGxRoleDO();
+ sgGxRoleDO.setGxDeviceType(sgGxRoleVO.getGxDeviceType());
+ sgGxRoleDO.setGxStepId(sgGxRoleVO.getGxStepId());
+ sgGxRoleDO.setRoleId(roleIds.get(i));
+ sgGxRoleDO.setSgOrder(sgGxRoleVO.getOrders().get(i));
+ sgGxRoles.add(sgGxRoleDO);
+ }
+ sgGxRoleMapper.insertBach(sgGxRoles);
+}
+
+ /**
+ * 获取绑定的角色进行回显
+ *
+ * @param gxDeviceType
+ * @param gxStepId
+ * @return
+ */
+ @Override
+ public List<String> getSgGxRoles(String gxDeviceType, String gxStepId) {
+ return sgGxRoleMapper.getSgGxRoles(gxDeviceType, gxStepId);
+
+ }
+
+ @Override
+ public List<SgGxStepDO> sgGxStepList() {
+ return sgGxStepMapper.getDEviceGXtwo();
+ }
}
--
Gitblit v1.9.3