jinpengyong
2021-05-14 efaa96ca645875270668de1ec3a766900847732a
设备接口更新
7 files modified
566 ■■■■ changed files
screen-common/src/main/java/com/moral/constant/Constants.java 21 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/controller/DeviceController.java 175 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/mapper/DeviceMapper.java 2 ●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/pojo/vo/device/DeviceVO.java 29 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/DeviceService.java 40 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java 198 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/resources/mapper/DeviceMapper.xml 101 ●●●● patch | view | raw | blame | history
screen-common/src/main/java/com/moral/constant/Constants.java
@@ -62,7 +62,7 @@
    /*
     * 网页端渠道
     * */
    public static final String WEB_CHANNEL = "1";
    public static final String WEB_CHANNEL = "0";
    /*
     * 登陆操作类型
@@ -94,6 +94,25 @@
    * */
    public static final String SYSTEM_DICT_TYPE_UNIT = "unit";
    /*
    * 行业字典类型
    * */
    public static final String SYSTEM_DICT_TYPE_PROFESSION = "profession";
    /*
     * 设备工艺字典类型
     * */
    public static final String SYSTEM_DICT_TYPE_TECH = "tech";
    /*
     * 设备检测器字典类型
     * */
    public static final String SYSTEM_DICT_TYPE_DETECTOR = "detector";
    /*
     * 采购商字典类型
     * */
    public static final String SYSTEM_DICT_TYPE_PURCHASER = "purchaser";
}
screen-manage/src/main/java/com/moral/api/controller/DeviceController.java
@@ -14,14 +14,11 @@
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.moral.api.entity.Device;
import com.moral.api.entity.ManageAccount;
import com.moral.api.entity.Organization;
import com.moral.api.entity.User;
import com.moral.api.pojo.vo.device.DeviceVO;
import com.moral.api.service.DeviceService;
import com.moral.api.service.OrganizationService;
import com.moral.constant.Constants;
import com.moral.constant.ResultMessage;
import com.moral.util.PageResult;
@@ -34,27 +31,113 @@
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private OrganizationService organizationService;
    @ApiOperation(value = "添加设备", notes = "添加设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    public ResultMessage insert(@RequestBody Device device) {
    public ResultMessage insert(Device device) {
        deviceService.insert(device);
        return ResultMessage.ok();
    }
    @ApiOperation(value = "维护人列表", notes = "维护人列表")
    @ApiOperation(value = "删除设备", notes = "删除设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "operators", method = RequestMethod.GET)
    public ResultMessage selectOperators() {
        List<ManageAccount> operators = deviceService.selectAllOperator();
        return ResultMessage.ok(operators);
    @RequestMapping(value = "delete", method = RequestMethod.GET)
    public ResultMessage delete(Integer deviceId) {
        deviceService.delete(deviceId);
        return ResultMessage.ok();
    }
    @ApiOperation(value = "修改设备", notes = "修改设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "update", method = RequestMethod.POST)
    public ResultMessage update(Device device) {
        deviceService.update(device);
        return ResultMessage.ok();
    }
    @ApiOperation(value = "分页设备列表", notes = "分页设备列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "name", value = "设备名称模糊查询", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "mac模糊查询", required = false, paramType = "query", dataType = "String"),
    })
    @RequestMapping(value = "select", method = RequestMethod.POST)
    public ResultMessage select(@RequestBody Map<String, Object> parameters) {
        IPage<Device> page = deviceService.selectDevices(parameters);
        PageResult<Device> pageResult = new PageResult<>(
                page.getTotal(), page.getPages(), page.getRecords()
        );
        return ResultMessage.ok(pageResult);
    }
    @ApiOperation(value = "查询设备信息", notes = "查询设备信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "deviceInfo", method = RequestMethod.GET)
    public ResultMessage selectDeviceInfoById(Integer deviceId) {
        Map<String, Object> result = deviceService.selectDeviceInfoById(deviceId);
        return ResultMessage.ok(result);
    }
    @ApiOperation(value = "所有组织", notes = "所有组织")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "allOrganization", method = RequestMethod.GET)
    public ResultMessage selectAllOrganization() {
        List<Map<String, Object>> organizations = deviceService.selectAllOrganization();
        return ResultMessage.ok(organizations);
    }
    @ApiOperation(value = "所有站点", notes = "所有站点")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "allMonitorPoint", method = RequestMethod.GET)
    public ResultMessage selectAllMonitorPoint() {
        List<Map<String, Object>> organizations = deviceService.selectAllMonitorPoint();
        return ResultMessage.ok(organizations);
    }
    @ApiOperation(value = "根据组织查站点", notes = "根据组织查站点")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "monitorPoints", method = RequestMethod.GET)
    public ResultMessage selectMonitorPoints(Integer orgId) {
        List<Map<String, Object>> monitorPoints = deviceService.selectMonitorsByOrgId(orgId);
        return ResultMessage.ok(monitorPoints);
    }
    @ApiOperation(value = "根据组织查设备", notes = "根据组织查设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "devicesByOrgId", method = RequestMethod.GET)
    public ResultMessage selectDevicesByOrg(Integer orgId) {
        List<Map<String, Object>> devices = deviceService.selectDevicesByOrgId(orgId);
        return ResultMessage.ok(devices);
    }
    @ApiOperation(value = "根据站点查设备", notes = "根据站点查设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "devicesByMpId", method = RequestMethod.GET)
    public ResultMessage selectDevicesByMp(Integer mpId) {
        List<Map<String, Object>> devices = deviceService.selectDevicesByMpId(mpId);
        return ResultMessage.ok(devices);
    }
    @ApiOperation(value = "型号列表", notes = "型号列表")
@@ -63,34 +146,52 @@
        return null;
    }
    @ApiOperation(value = "组织列表", notes = "组织列表")
    @ApiOperation(value = "维护人列表", notes = "维护人列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "organizations", method = RequestMethod.GET)
    public ResultMessage selectOrganizations() {
        List<Organization> organizations = deviceService.selectAllOrganization();
        return ResultMessage.ok(organizations);
    @RequestMapping(value = "operators", method = RequestMethod.GET)
    public ResultMessage selectOperators() {
        return ResultMessage.ok(deviceService.selectAllOperators());
    }
    @ApiOperation(value = "分页设备列表", notes = "分页设备列表")
    @ApiOperation(value = "所有行业", notes = "所有行业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", defaultValue = "0", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
            @ApiImplicitParam(name = "organizationName", value = "组织模糊查询", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "monitorPointName", value = "站点模糊查询", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "deviceName", value = "设备名称模糊查询", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "mac", value = "mac模糊查询", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "select", method = RequestMethod.POST)
    public ResultMessage select(@RequestBody Map<String, Object> parameters) {
        Page<DeviceVO> userPage = deviceService.selectDevices(parameters);
        PageResult<DeviceVO> pageResult = new PageResult<>(
                userPage.getTotal(), userPage.getPages(), userPage.getRecords()
        );
        return ResultMessage.ok(pageResult);
    @RequestMapping(value = "professions", method = RequestMethod.GET)
    public ResultMessage selectProfessions() {
        List<Map<String, Object>> professions = deviceService.selectDeviceDictData(Constants.SYSTEM_DICT_TYPE_PROFESSION);
        return ResultMessage.ok(professions);
    }
    @ApiOperation(value = "所有工艺", notes = "所有工艺")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "techs", method = RequestMethod.GET)
    public ResultMessage selectTechs() {
        List<Map<String, Object>> professions = deviceService.selectDeviceDictData(Constants.SYSTEM_DICT_TYPE_TECH);
        return ResultMessage.ok(professions);
    }
    @ApiOperation(value = "所有设备检测器", notes = "所有设备检测器")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "detectors", method = RequestMethod.GET)
    public ResultMessage selectDetectors() {
        List<Map<String, Object>> professions = deviceService.selectDeviceDictData(Constants.SYSTEM_DICT_TYPE_DETECTOR);
        return ResultMessage.ok(professions);
    }
    @ApiOperation(value = "所有采购商", notes = "所有采购商")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "purchasers", method = RequestMethod.GET)
    public ResultMessage selectPurchasers() {
        List<Map<String, Object>> professions = deviceService.selectDeviceDictData(Constants.SYSTEM_DICT_TYPE_PURCHASER);
        return ResultMessage.ok(professions);
    }
}
screen-manage/src/main/java/com/moral/api/mapper/DeviceMapper.java
@@ -22,6 +22,6 @@
 */
public interface DeviceMapper extends BaseMapper<Device> {
    IPage<DeviceVO> selectAllDeviceInfo(Page<DeviceVO> page, @Param("ew") QueryWrapper<DeviceVO> queryWrapper);
    DeviceVO selectDeviceInfoById(Integer deviceId);
}
screen-manage/src/main/java/com/moral/api/pojo/vo/device/DeviceVO.java
@@ -7,7 +7,9 @@
import com.moral.api.entity.Device;
import com.moral.api.entity.ManageAccount;
import com.moral.api.entity.MonitorPoint;
import com.moral.api.entity.Organization;
import com.moral.api.entity.Version;
@Data
@EqualsAndHashCode(callSuper = false)
@@ -18,16 +20,41 @@
    * */
    private String professionName;
    /*
     * 工艺
     * */
    private String techName;
    /*
     * 检测器
     * */
    private String detectorName;
    /*
     * 采购商
     * */
    private String purchaserName;
    /*
    * 组织
    * */
    private Organization organization;
    /*
     * 设备型号
     * */
    private Version version;
    /*
     * 站点
     * */
    private MonitorPoint monitorPoint;
    /*
    * 维护人
    * */
    private List<ManageAccount> operators;
}
screen-manage/src/main/java/com/moral/api/service/DeviceService.java
@@ -3,12 +3,9 @@
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.moral.api.entity.Device;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.ManageAccount;
import com.moral.api.entity.Organization;
import com.moral.api.pojo.vo.device.DeviceVO;
/**
 * <p>
@@ -20,11 +17,40 @@
 */
public interface DeviceService extends IService<Device> {
    //设备添加
    void insert(Device device);
    List<ManageAccount> selectAllOperator();
    //删除设备
    void delete(Integer deviceId);
    List<Organization> selectAllOrganization();
    //修改设备
    void update(Device device);
    Page<DeviceVO> selectDevices(Map<String, Object> parameters);
    //所有维护人
    List<Map<String, Object>> selectAllOperators();
    //设备相关字典数据
    List<Map<String, Object>> selectDeviceDictData(String dictType);
    //查询所有组织
    List<Map<String, Object>> selectAllOrganization();
    //查询所有站点
    List<Map<String, Object>> selectAllMonitorPoint();
    //根据组织查询站点
    List<Map<String, Object>> selectMonitorsByOrgId(Integer orgId);
    //根据组织查询设备
    List<Map<String, Object>> selectDevicesByOrgId(Integer orgId);
    //根据站点查询设备
    List<Map<String, Object>> selectDevicesByMpId(Integer orgId);
    //分页获取所有设备列表
    IPage<Device> selectDevices(Map<String, Object> parameters);
    //根据设备id查询设备组织,站点,维护人,行业,工艺,设备检测器,采购商等信息
    Map<String, Object> selectDeviceInfoById(Integer deviceId);
}
screen-manage/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -1,24 +1,36 @@
package com.moral.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.Device;
import com.moral.api.entity.ManageAccount;
import com.moral.api.entity.MonitorPoint;
import com.moral.api.entity.Organization;
import com.moral.api.entity.User;
import com.moral.api.entity.SysDictData;
import com.moral.api.entity.SysDictType;
import com.moral.api.entity.Version;
import com.moral.api.mapper.DeviceMapper;
import com.moral.api.mapper.ManageAccountMapper;
import com.moral.api.mapper.MonitorPointMapper;
import com.moral.api.mapper.OrganizationMapper;
import com.moral.api.mapper.SysDictDataMapper;
import com.moral.api.mapper.SysDictTypeMapper;
import com.moral.api.pojo.vo.device.DeviceVO;
import com.moral.api.service.DeviceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.constant.Constants;
import com.moral.redis.RedisUtil;
import com.moral.util.ConvertUtils;
import com.moral.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -42,34 +54,190 @@
    @Autowired
    private OrganizationMapper organizationMapper;
    @Autowired
    private MonitorPointMapper monitorPointMapper;
    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;
    @Autowired
    private SysDictDataMapper sysDictDataMapper;
    @Override
    @Transactional
    public void insert(Device device) {
        deviceMapper.insert(device);
        Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId());
        RedisUtil.set("device_" + device.getMac(), deviceInfo);
    }
    @Override
    public List<ManageAccount> selectAllOperator() {
        QueryWrapper<ManageAccount> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "user_name").eq("is_delete", Constants.NOT_DELETE);
        return manageAccountMapper.selectList(queryWrapper);
    @Transactional
    public void delete(Integer deviceId) {
        UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", deviceId).set("is_delete", Constants.DELETE);
        deviceMapper.update(null, updateWrapper);
        String mac = deviceMapper.selectById(deviceId).getMac();
        //清除redis
        RedisUtil.del("device_" + mac);
    }
    @Override
    public List<Organization> selectAllOrganization() {
        QueryWrapper<Organization> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name").ge("expire_time", new Date()).eq("is_delete", Constants.NOT_DELETE);
        return organizationMapper.selectList(queryWrapper);
    @Transactional
    public void update(Device device) {
        deviceMapper.updateById(device);
        //更新redis
        Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId());
        RedisUtil.set("device_" + deviceInfo.get("mac"), deviceInfo);
    }
    @Override
    public Page<DeviceVO> selectDevices(Map<String, Object> parameters) {
        QueryWrapper<DeviceVO> queryWrapper = new QueryWrapper<>();
    public List<Map<String, Object>> selectAllOperators() {
        //维护人列表
        QueryWrapper<ManageAccount> operatorWrapper = new QueryWrapper<>();
        operatorWrapper.select("id", "user_name").eq("is_delete", Constants.NOT_DELETE);
        return manageAccountMapper.selectMaps(operatorWrapper);
    }
    //根据字典类型获取字典数据
    @Override
    public List<Map<String, Object>> selectDeviceDictData(String dictType) {
        QueryWrapper<SysDictType> typeQueryWrapper = new QueryWrapper<>();
        typeQueryWrapper.select("id").eq("name", dictType);
        SysDictType sysDictType = sysDictTypeMapper.selectOne(typeQueryWrapper);
        QueryWrapper<SysDictData> dataQueryWrapper = new QueryWrapper<>();
        dataQueryWrapper.select("dataKey", "dataValue").eq("dict_type_id", sysDictType.getId()).eq("is_delete", Constants.NOT_DELETE);
        return sysDictDataMapper.selectMaps(dataQueryWrapper);
    }
    @Override
    public List<Map<String, Object>> selectMonitorsByOrgId(Integer orgId) {
        QueryWrapper<MonitorPoint> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name").eq("organization_id", orgId).eq("is_delete", Constants.NOT_DELETE);
        return monitorPointMapper.selectMaps(queryWrapper);
    }
    @Override
    public List<Map<String, Object>> selectDevicesByOrgId(Integer orgId) {
        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete", Constants.NOT_DELETE).eq("organization_id", orgId);
        return deviceMapper.selectMaps(queryWrapper);
    }
    @Override
    public List<Map<String, Object>> selectDevicesByMpId(Integer mpId) {
        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete", Constants.NOT_DELETE).eq("monitor_point_id", mpId);
        return deviceMapper.selectMaps(queryWrapper);
    }
    @Override
    public IPage<Device> selectDevices(Map<String, Object> parameters) {
        QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
        Integer page = (Integer) parameters.get("page");
        Integer size = (Integer) parameters.get("size");
        Page<DeviceVO> pageData = new Page<>(page, size);
        deviceMapper.selectAllDeviceInfo(pageData, queryWrapper);
        return pageData;
        Object order = parameters.get("order");
        Object orderType = parameters.get("orderType");
        Object name = parameters.get("name");
        Object mac = parameters.get("mac");
        if (name != null) {
            queryWrapper.like("name", name);
        }
        if (mac != null) {
            queryWrapper.like("mac", mac);
        }
        //排序参数,默认create_time降序
        if (order != null && orderType != null) {
            if (Constants.ORDER_ASC.equals(orderType)) {
                queryWrapper.orderByAsc(ConvertUtils.toLine(order.toString()));
            } else {
                queryWrapper.orderByDesc(ConvertUtils.toLine(order.toString()));
            }
        } else {
            queryWrapper.orderByDesc("create_time");
        }
        queryWrapper.eq("is_delete", Constants.NOT_DELETE);
        Page<Device> devicePage = new Page<>(page, size);
        deviceMapper.selectPage(devicePage, queryWrapper);
        return devicePage;
    }
    @Override
    public Map<String, Object> selectDeviceInfoById(Integer deviceId) {
        Map<String, Object> result = new LinkedHashMap<>();
        DeviceVO device = deviceMapper.selectDeviceInfoById(deviceId);
        //设备
        result.put("id", device.getId());
        result.put("name", device.getName());
        result.put("mac", device.getMac());
        result.put("address", device.getAddress());
        result.put("longitude", device.getLongitude());
        result.put("latitude", device.getLatitude());
        result.put("createTime", DateUtils.dateToDateString(device.getCreateTime()));
        //行业
        result.put("profession", device.getProfession());
        result.put("professionName", device.getProfessionName());
        //工艺
        result.put("tech", device.getTech());
        result.put("techName", device.getTechName());
        //检测器
        result.put("detector", device.getDetector());
        result.put("detectorName", device.getDetectorName());
        //采购商
        result.put("purchaser", device.getPurchaser());
        result.put("purchaserName", device.getPurchaserName());
        //型号
        Map<String, Object> versionInfo = new LinkedHashMap<>();
        Version version = device.getVersion();
        versionInfo.put("id", version.getId());
        versionInfo.put("name", version.getName());
        result.put("version", versionInfo);
        //维护人
        List<Map<String, Object>> operatorsInfo = new ArrayList<>();
        List<ManageAccount> operators = device.getOperators();
        for (ManageAccount operator : operators) {
            Map<String, Object> operatorMap = new LinkedHashMap<>();
            operatorMap.put("id", operator.getId());
            operatorMap.put("name", operator.getUserName());
            operatorsInfo.add(operatorMap);
        }
        result.put("operators", operatorsInfo);
        //组织
        Map<String, Object> orgInfo = new LinkedHashMap<>();
        Organization organization = device.getOrganization();
        orgInfo.put("id", organization.getId());
        orgInfo.put("name", organization.getName());
        result.put("organization", orgInfo);
        //站点
        Map<String, Object> mpInfo = new LinkedHashMap<>();
        MonitorPoint monitorPoint = device.getMonitorPoint();
        mpInfo.put("id", monitorPoint.getId());
        mpInfo.put("name", monitorPoint.getName());
        result.put("monitorPoint", mpInfo);
        return result;
    }
    @Override
    public List<Map<String, Object>> selectAllOrganization() {
        QueryWrapper<Organization> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name").eq("is_delete", Constants.NOT_DELETE);
        return organizationMapper.selectMaps(queryWrapper);
    }
    @Override
    public List<Map<String, Object>> selectAllMonitorPoint() {
        QueryWrapper<MonitorPoint> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name").eq("is_delete", Constants.NOT_DELETE);
        return monitorPointMapper.selectMaps(queryWrapper);
    }
}
screen-manage/src/main/resources/mapper/DeviceMapper.xml
@@ -27,20 +27,47 @@
    </resultMap>
    <resultMap id="resultMap" type="com.moral.api.pojo.vo.device.DeviceVO" extends="BaseResultMap">
        <!--行业-->
        <result column="profession_name" property="professionName"/>
        <!--工艺-->
        <result column="tech_name" property="techName"/>
        <!--设备检测器-->
        <result column="detector_name" property="detectorName"/>
        <!--采购商-->
        <result column="purchaser_name" property="purchaserName"/>
        <!--组织-->
        <association property="organization" javaType="com.moral.api.entity.Organization">
            <result column="org_id" property="id"/>
            <result column="org_name" property="name"/>
        </association>
        <!--站点-->
        <association property="monitorPoint" javaType="com.moral.api.entity.MonitorPoint">
            <result column="mp_id" property="id"/>
            <result column="mp_name" property="name"/>
            <result column="mp_address" property="address"/>
        </association>
        <!--型号-->
        <association property="version" javaType="com.moral.api.entity.Version">
            <result column="version_id" property="id"/>
            <result column="version_name" property="name"/>
        </association>
        <!--设备维护人-->
        <collection property="operators" ofType="com.moral.api.entity.ManageAccount">
            <id column="operate_id" property="id" jdbcType="INTEGER"/>
            <result column="operate_id" property="id" jdbcType="INTEGER"/>
            <result column="operate_name" property="userName" jdbcType="VARCHAR"/>
        </collection>
    </resultMap>
    <select id="selectAllDeviceInfo" resultMap="resultMap">
        SELECT d.id,
    <select id="selectDeviceInfoById" resultMap="resultMap">
        SELECT
            d.id,
               d.`name`,
               d.mac,
               d.address,
@@ -49,20 +76,37 @@
               d.operate_ids,
               d.organization_id,
               d.monitor_point_id,
               d.organization_id,
               d.device_version_id,
               d.profession profession,
            d.profession,
            d.tech,
            d.detector,
            d.purchaser,
            d.create_time,
            d.extend,
               o.id org_id,
               o.`name` org_name,
            mp.id mp_id,
            mp.`name` mp_name,
            mp.address mp_address,
               ma.id operate_id,
            v.id version_id,
            v.`name` version_name,
               ma.user_name operate_name,
               sd.dataValue profession_name
        FROM `device` d
            profession.dataValue profession_name,
            tech.dataValue tech_name,
            detector.dataValue detector_name,
            purchaser.dataValue purchaser_name
        FROM device d
                 LEFT JOIN version v
                           on d.device_version_id=v.id
        LEFT JOIN `organization` o
        ON d.organization_id = o.id
                 LEFT JOIN `monitor_point` mp
                           ON mp.id = d.monitor_point_id
        LEFT JOIN `manage_account` ma
        ON FIND_IN_SET(
            ma.id, (SELECT operate_ids FROM device)
                           ON FIND_IN_SET
                               (
                                   ma.id, (SELECT operate_ids FROM device WHERE id = d.id)
            )
        LEFT JOIN
             (
@@ -70,11 +114,40 @@
                 FROM sys_dict_type sdt,
                      sys_dict_data sdd
                 WHERE sdt.id = sdd.dict_type_id
             ) sd
        on sd.`name` = 'profession'
        and d.profession = sd.dataKey
        AND d.is_delete = 0
        ${ew.customSqlSegment}
                   AND sdt.`name` = 'profession'
             ) profession
             ON d.profession = profession.dataKey
                 LEFT JOIN
             (
                 SELECT sdt.`name`, sdd.dataKey, sdd.dataValue
                 FROM sys_dict_type sdt,
                      sys_dict_data sdd
                 WHERE sdt.id = sdd.dict_type_id
                   AND sdt.`name` = 'tech'
             ) tech
             ON d.tech = tech.dataKey
                 LEFT JOIN
             (
                 SELECT sdt.`name`, sdd.dataKey, sdd.dataValue
                 FROM sys_dict_type sdt,
                      sys_dict_data sdd
                 WHERE sdt.id = sdd.dict_type_id
                   AND sdt.`name` = 'detector'
             ) detector
             ON d.detector = detector.dataKey
                 LEFT JOIN
             (
                 SELECT sdt.`name`, sdd.dataKey, sdd.dataValue
                 FROM sys_dict_type sdt,
                      sys_dict_data sdd
                 WHERE sdt.id = sdd.dict_type_id
                   AND sdt.`name` = 'purchaser'
             ) purchaser
             ON d.purchaser = purchaser.dataKey
        WHERE d.id = #{deviceId}
    </select>