zhangherong
2025-03-25 5f470251b97ecf69aa77c654434f9af8ed16d9e2
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -8,10 +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;
@@ -19,6 +23,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
/**
 * @Description: 设备台账
@@ -33,6 +38,9 @@
public class EamEquipmentController extends JeecgController<EamEquipment, IEamEquipmentService> {
    @Autowired
    private IEamEquipmentService eamEquipmentService;
    @Autowired
    private IMdcEquipmentService mdcEquipmentService;
    /**
     * 分页列表查询
@@ -68,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("添加成功!");
    }
@@ -152,4 +169,19 @@
        return super.importExcel(request, response, EamEquipment.class);
    }
    @AutoLog(value = "设备表-通过车间ids获取设备树")
    @ApiOperation(value = "设备表-通过车间ids获取设备树", notes = "设备表-通过车间ids获取设备树")
    @GetMapping(value = "/loadTreeListByProductionIds")
    public Result<List<EamEquipmentTree>> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) {
        Result<List<EamEquipmentTree>> result = new Result<>();
        try {
            List<EamEquipmentTree> mdcEquipmentTreeList = eamEquipmentService.loadTreeListByProductionIds(ids);
            result.setSuccess(true);
            result.setResult(mdcEquipmentTreeList);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return result;
    }
}