From 4790119bedab62ce14d25e89b7ec28668383d027 Mon Sep 17 00:00:00 2001
From: gong <328255720@qq.com>
Date: Mon, 17 Jun 2024 16:22:31 +0800
Subject: [PATCH] 加个异步处理项目和设备的状态
---
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgGxStepServiceImpl.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 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..46e0f24 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,7 +1,10 @@
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.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.service.SgGxStepService;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -10,6 +13,9 @@
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.List;
/**
@@ -24,6 +30,8 @@
public class SgGxStepServiceImpl extends ServiceImpl<SgGxStepMapper, SgGxStepDO> implements SgGxStepService {
@Autowired
private SgGxStepMapper sgGxStepMapper;
+ @Autowired
+ private SgGxRoleMapper sgGxRoleMapper;
@Override
public void add(SgGxStepDO sgGxStepDO) {
List<SgGxStepDO> list= sgGxStepMapper.selectByGxInfoId(sgGxStepDO.getGxInfoId());
@@ -55,4 +63,92 @@
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(Long.valueOf(roleIds.get(i)));
+ sgGxRoleDO.setSgOrder(sgGxRoleVO.getOrders().get(i));
+ sgGxRoles.add(sgGxRoleDO);
+ }
+ sgGxRoleMapper.insertBach(sgGxRoles);
+ }
+
+
+ /**
+ * 更新工序角色配置
+ * @param sgGxRoleVO
+ */
+ @Override
+@Transactional
+public void updateSgGxRole(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){
+ //删除原来的
+ 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(Long.valueOf(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);
+
+ }
}
--
Gitblit v1.9.3