From b864148d2a9afd5e1627b761da923cca8f8dfbd2 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期五, 07 三月 2025 14:44:56 +0800 Subject: [PATCH] 修改产品结构树新增删除同步结构树表,新增刀具信息与设备类 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java | 119 ++++++++++++++++++++++++++--------------------------------- 1 files changed, 53 insertions(+), 66 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java index 8cee5f7..379abd8 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java @@ -1,13 +1,13 @@ package org.jeecg.modules.dnc.service.impl; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.collections4.ListUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.system.vo.LoginUser; - +import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.mapper.ComponentInfoMapper; import org.jeecg.modules.dnc.mapper.PartsInfoMapper; @@ -16,18 +16,11 @@ import org.jeecg.modules.dnc.response.PartsInfoCode; import org.jeecg.modules.dnc.response.ProductInfoCode; import org.jeecg.modules.dnc.response.UcenterCode; - import org.jeecg.modules.dnc.service.*; -import org.jeecg.modules.dnc.ucenter.Department; import org.jeecg.modules.dnc.utils.ValidateUtil; - -import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.entity.SysUser; -import org.apache.commons.collections4.ListUtils; - import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,20 +38,17 @@ @Autowired private IPartsPermissionService partsPermissionService; @Autowired - private IPermissionStreamService permissionStreamService; + private IPermissionStreamNewService permissionStreamNewService; @Autowired private IPartsDepartmentService partsDepartmentService; @Autowired - @Lazy - private IProcessStreamService processStreamService; - @Autowired - private IDocInfoService docInfoService; - @Autowired - private INcLogInfoService iNcLogInfoService; + private IProcessSpecVersionService processSpecVersionService; @Autowired private IDocRelativeService iDocRelativeService; @Autowired private IProductPermissionService productPermissionService; + @Autowired + private IProductMixService productMixService; @Override @Transactional(rollbackFor = {Exception.class}) public boolean addPartsInfo(PartsInfo partsInfo) { @@ -87,20 +77,19 @@ ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); partsInfo.setPartsStatus(1); boolean b = super.save(partsInfo); - List<PermissionStream> oldDepartPermList = permissionStreamService.getByComponentId(componentInfo.getProductId(), componentInfo.getComponentId()); + List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","1"); if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { List<PartsDepartment> partsDepartmentList = new ArrayList<>(); - List<PermissionStream> permissionStreamList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); oldDepartPermList.forEach(item -> { PartsDepartment pd = new PartsDepartment(); pd.setDepartId(item.getDepartId()); pd.setPartsId(partsInfo.getPartsId()); partsDepartmentList.add(pd); - PermissionStream perm = new PermissionStream(); + PermissionStreamNew perm = new PermissionStreamNew(); perm.setDepartId(item.getDepartId()); - perm.setProductId(partsInfo.getProductId()); - perm.setComponentId(partsInfo.getComponentId()); - perm.setPartsId(partsInfo.getPartsId()); + perm.setBusinessId(partsInfo.getPartsId()); + perm.setBusinessType("3"); permissionStreamList.add(perm); }); if(!partsDepartmentList.isEmpty()) { @@ -109,7 +98,7 @@ ExceptionCast.cast(CommonCode.FAIL); } if(!permissionStreamList.isEmpty()) { - b = permissionStreamService.saveBatch(permissionStreamList); + b = permissionStreamNewService.saveBatch(permissionStreamList); if(!b) ExceptionCast.cast(CommonCode.FAIL); } @@ -120,13 +109,16 @@ if (!b) { ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); } + //娣诲姞缁撴瀯鏍� + ProductMix productMix = new ProductMix(Long.parseLong(partsInfo.getPartsId()),Long.parseLong(partsInfo.getComponentId()) + ,partsInfo.getPartsName(),partsInfo.getPartsCode(),"3"); + productMixService.save(productMix); //娣诲姞鐢ㄦ埛鏉冮檺 - PermissionStream stream = new PermissionStream(); - stream.setProductId(partsInfo.getProductId()); - stream.setComponentId(partsInfo.getComponentId()); - stream.setPartsId(partsInfo.getPartsId()); + PermissionStreamNew stream = new PermissionStreamNew(); + stream.setBusinessId(partsInfo.getPartsId()); + stream.setBusinessType("3"); stream.setUserId(userId); - return permissionStreamService.save(stream); + return permissionStreamNewService.save(stream); } @Override @@ -157,14 +149,13 @@ if(!b) return false; } - PermissionStream stream = permissionStreamService.getByPartsIdAndUserId(en.getProductId(), en.getComponentId(), id, userId); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId( id, userId,"3"); if(stream == null) { - stream = new PermissionStream(); - stream.setProductId(en.getProductId()); - stream.setComponentId(en.getComponentId()); - stream.setPartsId(id); + stream = new PermissionStreamNew(); + stream.setBusinessId(id); + stream.setBusinessType("3"); stream.setUserId(userId); - return permissionStreamService.save(stream); + return permissionStreamNewService.save(stream); } return b; } @@ -220,10 +211,10 @@ b = partsDepartmentService.deleteByPartsId(item.getPartsId()); if(!b) ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); - b = permissionStreamService.deleteUserPermsByPartsId(item.getProductId(), item.getComponentId(), item.getPartsId()); + b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getPartsId(),"3","0"); if(!b) ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); - b = permissionStreamService.deleteDepartPermsByPartsId(item.getProductId(), item.getComponentId(), item.getPartsId()); + b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getPartsId(),"3","1"); if(!b) ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); b = super.removeById(item.getPartsId()); @@ -241,8 +232,8 @@ PartsInfo partsInfo = super.getById(partsId); if(partsInfo == null) ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); - List<ProcessStream> processStreams = processStreamService.findByPartsId(partsId); - if(processStreams != null && !processStreams.isEmpty()) + List<ProcessSpecVersion> processSpecVersions = processSpecVersionService.getByPartsId(partsId); + if(processSpecVersions != null && !processSpecVersions.isEmpty()) ExceptionCast.cast(PartsInfoCode.PARTS_PROCESS_EXIST); boolean b = partsPermissionService.deleteByPartsId(partsInfo.getPartsId()); //楠岃瘉鏄惁瀛樺湪鏂囨。 @@ -255,13 +246,16 @@ b = partsDepartmentService.deleteByPartsId(partsInfo.getPartsId()); if(!b) ExceptionCast.cast(CommonCode.FAIL); - b = permissionStreamService.deleteUserPermsByPartsId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId()); + b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,"3","0"); if(!b) ExceptionCast.cast(CommonCode.FAIL); - b = permissionStreamService.deleteDepartPermsByPartsId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId()); + b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,"3","1"); if(!b) ExceptionCast.cast(CommonCode.FAIL); - return super.removeById(partsInfo.getPartsId()); + b = productMixService.removeById(partsId); + if (!b) + ExceptionCast.cast(CommonCode.FAIL); + return super.removeById(partsId); } @Override @@ -270,7 +264,7 @@ if(partsInfo == null || userList == null || userList.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); List<PartsPermission> permissionList = new ArrayList<>(); - List<PermissionStream> permissionStreamList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); userList.forEach(item -> { PartsPermission en = partsPermissionService.getByPartsIdAndUserId(partsInfo.getPartsId(), item.getId()); if(en == null) { @@ -279,13 +273,12 @@ en.setPartsId(partsInfo.getPartsId()); permissionList.add(en); } - PermissionStream stream = permissionStreamService.getByPartsIdAndUserId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getId()); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(partsInfo.getPartsId(), item.getId(),"3"); if(stream == null) { - stream = new PermissionStream(); + stream = new PermissionStreamNew(); stream.setUserId(item.getId()); - stream.setProductId(partsInfo.getProductId()); - stream.setComponentId(partsInfo.getComponentId()); - stream.setPartsId(partsInfo.getPartsId()); + stream.setBusinessId(partsInfo.getPartsId()); + stream.setBusinessType("3"); permissionStreamList.add(stream); } }); @@ -296,7 +289,7 @@ } } if(!permissionStreamList.isEmpty()) { - boolean b = permissionStreamService.saveBatch(permissionStreamList); + boolean b = permissionStreamNewService.saveBatch(permissionStreamList); if(!b) { ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); } @@ -310,21 +303,18 @@ if(partsInfo == null || userList == null || userList.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); List<PartsPermission> permissionList = new ArrayList<>(); - List<PermissionStream> permissionStreamList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); userList.forEach(item -> { PartsPermission en = partsPermissionService.getByPartsIdAndUserId(partsInfo.getPartsId(), item.getId()); if(en != null) { permissionList.add(en); } - PermissionStream stream = permissionStreamService.getByPartsIdAndUserId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getId()); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(partsInfo.getPartsId(), item.getId(),"3"); if(stream != null) { permissionStreamList.add(stream); } }); //娓呯┖鐢ㄦ埛鏉冮檺鏍¢獙 - /*List<PartsPermission> exitsList = partsPermissionService.getByPartsId(partsInfo.getPartsId()); - if(exitsList.size() <= permissionList.size()) - ExceptionCast.cast(PartsInfoCode.PARTS_USER_NONE);*/ if(!permissionList.isEmpty()) { boolean b = partsPermissionService.removeByCollection(permissionList); if(!b) { @@ -332,7 +322,7 @@ } } if(!permissionStreamList.isEmpty()) { - boolean b = permissionStreamService.removeByCollection(permissionStreamList); + boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); if(!b) { ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); } @@ -346,7 +336,7 @@ if(partsInfo == null || departmentList == null || departmentList.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); List<PartsDepartment> partsDepartments = new ArrayList<>(); - List<PermissionStream> permissionStreamList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); departmentList.forEach(item -> { PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); if(en == null) { @@ -355,14 +345,12 @@ en.setPartsId(partsInfo.getPartsId()); partsDepartments.add(en); } - PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), - partsInfo.getPartsId(), item.getId()); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(partsInfo.getPartsId(), item.getId(),"3"); if(stream == null) { - stream = new PermissionStream(); + stream = new PermissionStreamNew(); stream.setDepartId(item.getId()); - stream.setProductId(partsInfo.getProductId()); - stream.setComponentId(partsInfo.getComponentId()); - stream.setPartsId(partsInfo.getPartsId()); + stream.setBusinessId(partsInfo.getPartsId()); + stream.setBusinessType("3"); permissionStreamList.add(stream); } }); @@ -373,7 +361,7 @@ } } if(!permissionStreamList.isEmpty()) { - boolean b = permissionStreamService.saveBatch(permissionStreamList); + boolean b = permissionStreamNewService.saveBatch(permissionStreamList); if(!b) { ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); } @@ -387,14 +375,13 @@ if(partsInfo == null || departmentList == null || departmentList.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); List<PartsDepartment> partsDepartments = new ArrayList<>(); - List<PermissionStream> permissionStreamList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); departmentList.forEach(item -> { PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); if(en != null) { partsDepartments.add(en); } - PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), - partsInfo.getPartsId(), item.getId()); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(partsInfo.getPartsId(), item.getId(),"3"); if(stream != null) { permissionStreamList.add(stream); } @@ -406,7 +393,7 @@ } } if(!permissionStreamList.isEmpty()) { - boolean b = permissionStreamService.removeByCollection(permissionStreamList); + boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); if(!b) { ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); } -- Gitblit v1.9.3