lyh
2025-07-09 e70c3d7a34ad9e9023abd9fc669bdf4e4a082a38
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/BaseFactoryServiceImpl.java
@@ -3,10 +3,12 @@
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.toolkit.IdWorker;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.FillRuleConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.FillRuleUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.BaseFactory;
@@ -100,32 +102,34 @@
        return Collections.emptyList();
    }
    /**
     * saveProductionData 对应 add 保存用户在页面添加的新的设备车间管理对象数据
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveBaseFactoryData(BaseFactory BaseFactory) {
        if (BaseFactory != null) {
            if (BaseFactory.getParentId() == null|| StrUtil.isEmpty(BaseFactory.getParentId())) {
                BaseFactory.setParentId("");
                BaseFactory.setFactoryCategory("0");
    public void saveBaseFactoryData(BaseFactory baseFactory) {
        if (baseFactory != null) {
            if (baseFactory.getParentId() == null|| StrUtil.isEmpty(baseFactory.getParentId())) {
                baseFactory.setParentId("");
                baseFactory.setFactoryCategory("0");
            }
            if (BaseFactory.getFactoryCategory() == null|| StrUtil.isEmpty(BaseFactory.getFactoryCategory())) {
                BaseFactory.setFactoryCategory("1");
            if (baseFactory.getFactoryCategory() == null|| StrUtil.isEmpty(baseFactory.getFactoryCategory())) {
                baseFactory.setFactoryCategory("1");
            }
            BaseFactory.setId(IdWorker.getIdStr(BaseFactory));
            baseFactory.setId(IdWorker.getIdStr(baseFactory));
            // 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
            // 获取父级ID
            String parentId = BaseFactory.getParentId();
            String parentId = baseFactory.getParentId();
            JSONObject formData = new JSONObject();
            formData.put("parentId",parentId);
            String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.WORKSHOP,formData);
            BaseFactory.setOrgCode(codeArray[0]);
            baseFactory.setOrgCode(codeArray[0]);
            String orgType = codeArray[1];
            BaseFactory.setOrgType(String.valueOf(orgType));
            BaseFactory.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
            this.save(BaseFactory);
            baseFactory.setOrgType(String.valueOf(orgType));
            baseFactory.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
            this.save(baseFactory);
        }
    }
@@ -145,9 +149,15 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateBaseFactoryDataById(BaseFactory BaseFactory) {
        if (BaseFactory != null) {
            this.updateById(BaseFactory);
    public boolean updateBaseFactoryDataById(BaseFactory baseFactory) {
        QueryWrapper<BaseFactory> baseFactoryQueryWrapper = new QueryWrapper<>();
        baseFactoryQueryWrapper.eq(StrUtil.isNotEmpty(baseFactory.getFactoryCode()), "factory_code", baseFactory.getFactoryCode());
        baseFactoryQueryWrapper.eq("del_flag", CommonConstant.DEL_FLAG_0.toString());
        if (this.getOne(baseFactoryQueryWrapper) != null) {
            throw new JeecgBootException("机构编码已存在");
        }
        if (baseFactory != null) {
            this.updateById(baseFactory);
            return true;
        }
        return false;