zhangherong
2025-03-25 5f470251b97ecf69aa77c654434f9af8ed16d9e2
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -8,11 +8,14 @@
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.eam.entity.EamEquipment;
import org.jeecg.modules.eam.service.IEamEquipmentService;
import org.jeecg.modules.eam.vo.EamEquipmentTree;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@@ -35,6 +38,9 @@
public class EamEquipmentController extends JeecgController<EamEquipment, IEamEquipmentService> {
    @Autowired
    private IEamEquipmentService eamEquipmentService;
    @Autowired
    private IMdcEquipmentService mdcEquipmentService;
    /**
     * 分页列表查询
@@ -70,7 +76,16 @@
    public Result<?> add(@RequestBody EamEquipment eamEquipment) {
        EamEquipment entity = eamEquipmentService.saveEquipment(eamEquipment);
        if (entity == null) {
            Result.OK("添加失败!");
            return Result.OK("添加失败!");
        }
        //调用mdcEquipment插入MDC设备
        if(CommonConstant.DEFAULT_1.equals(eamEquipment.getMdcFlag())) {
            //插入MDC设备
            MdcEquipment mdcEquipment = new MdcEquipment();
            mdcEquipment.setEquipmentId(entity.getEquipmentCode());
            mdcEquipment.setEquipmentType(entity.getDeviceType());
            mdcEquipment.setEquipmentName(entity.getEquipmentName());
            mdcEquipmentService.addNewEquipmentFromEam(mdcEquipment, eamEquipment.getOrgId());
        }
        return Result.OK("添加成功!");
    }