lyh
2025-02-14 f2f8241dd52ef12ec109f6f4f0f13042055338ac
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -7,15 +7,18 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.mdc.dto.MdcEquDepDto;
import org.jeecg.modules.mdc.dto.MdcEquProDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
import org.jeecg.modules.mdc.entity.*;
import org.jeecg.modules.mdc.mapper.DncDevicePermissionMapper;
import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper;
import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper;
import org.jeecg.modules.mdc.model.MdcEquipmentTree;
@@ -92,6 +95,9 @@
    @Resource
    private ISysParamsService ISysParamsService;
    @Resource
    private DncDevicePermissionMapper dncDevicePermissionMapper;
    @Override
    public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) {
@@ -139,6 +145,13 @@
        }
        //step.1 保存设备
        this.save(mdcEquipment);
        //DNC添加设备权限
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        DncDevicePermission dncDevicePermission=new DncDevicePermission();
        dncDevicePermission.setDeviceId(mdcEquipment.getId());
        dncDevicePermission.setUserId(userId);
        dncDevicePermissionMapper.insert(dncDevicePermission);
        //step.2 保存所属部门
        if (oConvertUtils.isNotEmpty(selectedDeparts)) {
            String[] arr = selectedDeparts.split(",");
@@ -161,6 +174,22 @@
    @Transactional(rollbackFor = Exception.class)
    @CacheEvict(value = {"mdc:cache:encrypt:equipment"}, allEntries = true)
    public void editMdcEquipment(MdcEquipment mdcEquipment) {
        if (mdcEquipment.getSystemValue()!=null) {
            switch (mdcEquipment.getSystemValue()){
                case "1":
                    mdcEquipment.setDeviceTypeDnc("1");
                    mdcEquipment.setDeviceTypeMdc("0");
                    break;
                case "2":
                    mdcEquipment.setDeviceTypeDnc("0");
                    mdcEquipment.setDeviceTypeMdc("1");
                    break;
                case "3":
                    mdcEquipment.setDeviceTypeDnc("1");
                    mdcEquipment.setDeviceTypeMdc("1");
                    break;
            }
        }
        //step.1 修改设备基础信息
        this.updateById(mdcEquipment);
        //step.2 修改部门