From 8fad403599523f7b800a845f62a095227316d1e7 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期五, 21 三月 2025 15:46:23 +0800 Subject: [PATCH] art: 系统管理-产线表 增加mdc_flag标识,并可进行维护 --- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcProductionService.java | 8 ++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java | 6 +++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java | 74 +++++++++++++++++++++++++++++++++++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/model/MdcProductionTreeModel.java | 3 + 4 files changed, 91 insertions(+), 0 deletions(-) diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java index 5d36ad0..ce30a19 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java @@ -95,4 +95,10 @@ /**閮ㄩ棬璐熻矗浜虹殑ids*/ @TableField(exist = false) private String directorUserIds; + + /** + * 鏄惁涓篗DC浣跨敤 + */ + @ApiModelProperty(value = "鏄惁涓篗DC浣跨敤") + private String mdcFlag; } diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/model/MdcProductionTreeModel.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/model/MdcProductionTreeModel.java index 2af1b4b..2ad8b57 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/model/MdcProductionTreeModel.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/model/MdcProductionTreeModel.java @@ -80,6 +80,8 @@ private Date updateTime; + private String mdcFlag; + /** * 浜х嚎璐熻矗浜篿ds */ @@ -118,5 +120,6 @@ this.updateBy = mdcProduction.getUpdateBy(); this.updateTime = mdcProduction.getUpdateTime(); this.directorUserIds = mdcProduction.getDirectorUserIds(); + this.mdcFlag = mdcProduction.getMdcFlag(); } } diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcProductionService.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcProductionService.java index 3e2608e..67bec11 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcProductionService.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcProductionService.java @@ -123,4 +123,12 @@ * @return */ List<String> findAllProductionIds(List<String> ids); + + /** + * 鑾峰彇鏌愪釜鑺傜偣鎵�鏈変笂绾ц妭鐐圭殑id + * @param parentId 鐖惰妭鐐� id + * @param idList 鎺ユ敹缁撴灉闆� + * @return + */ + List<String> findParentIdsForProduction(String parentId, List<String> idList); } diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java index 938efca..9f36ccf 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java @@ -1,9 +1,11 @@ package org.jeecg.modules.system.service.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; 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.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; @@ -180,6 +182,13 @@ mdcProduction.setOrgType(String.valueOf(orgType)); mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); this.save(mdcProduction); + + //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� + //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� + //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 鏂板鎿嶄綔 涓嶅瓨鍦ㄦ鎯呭喌 + if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ + openParentMdcFlag(parentId); + } } } @@ -191,6 +200,18 @@ public boolean updateProductionDataById(MdcProduction mdcProduction) { if (mdcProduction != null) { this.updateById(mdcProduction); + + //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� + //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� + //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 + String parentId = mdcProduction.getParentId(); + if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ + openParentMdcFlag(parentId); + } + if(CommonConstant.DEFAULT_0.equals(mdcProduction.getMdcFlag())){ + //鍏抽棴 + closeChildrenMdcFlag(mdcProduction.getId()); + } return true; } return false; @@ -441,4 +462,57 @@ public List<String> findAllProductionIds(List<String> ids){ return this.baseMapper.recursionChildrenByList(ids); } + + @Override + public List<String> findParentIdsForProduction(String parentId, List<String> idList) { + if (StringUtils.isEmpty(parentId)) { + return null; + } + if (idList == null || idList.isEmpty()) { + idList = new ArrayList<>(); + } + boolean p = true; + if (p) { + MdcProduction en = super.getById(parentId); + if (en != null) { + idList.add(0, en.getId()); + } + if (StringUtils.isNotBlank(en.getParentId())) { + parentId = en.getParentId(); + findParentIdsForProduction(parentId, idList); + } else { + p = false; + return idList; + } + } + return idList; + } + + /** + * 鎵撳紑 鐖惰妭鐐� 鍙� 浠ヤ笂鐨刴dc鏍囪 + * @param parentId + */ + private void openParentMdcFlag(String parentId) { + List<String> listParentTree = findParentIdsForProduction(parentId, new ArrayList<>()); + if (!CollectionUtil.isEmpty(listParentTree)) { + UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", listParentTree); + updateWrapper.set("mdc_flag", "1"); + super.update(updateWrapper); + } + } + + /** + * 鍏抽棴鎵�鏈夊瓙鑺傜偣鐨刴dc鏍囪 + * @param productionId + */ + private void closeChildrenMdcFlag(String productionId) { + List<String> childrenList = recursionChildren(productionId); + if (!CollectionUtil.isEmpty(childrenList)) { + UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("id", childrenList); + updateWrapper.set("mdc_flag", "0"); + super.update(updateWrapper); + } + } } -- Gitblit v1.9.3