Przeglądaj źródła

设备类型区域

lin 4 lat temu
rodzic
commit
202410667b

+ 22 - 0
src/main/java/com/zoniot/ccrc/commom/utils/TreeUtil.java

@@ -1,5 +1,6 @@
 package com.zoniot.ccrc.commom.utils;
 
+import com.zoniot.ccrc.dto.AreaDto;
 import com.zoniot.ccrc.dto.BuildingSelectDto;
 import com.zoniot.ccrc.dto.OrganizationDto;
 import com.zoniot.ccrc.entity.Permission;
@@ -119,6 +120,27 @@ public class TreeUtil {
         }
     }
 
+    public static List<AreaDto> getArea(List<AreaDto> list, Integer id, Integer leve) {
+        List<AreaDto> temList = newArrayList();
+        if (list != null) {
+            for (AreaDto areaDto : list) {
+                if (id.equals(areaDto.getPid())) {
+                    List<AreaDto> chidren = getArea(list, areaDto.getCode(), ++leve);
+                    AreaDto tempArea = new AreaDto();
+                    BeanUtils.copyProperties(areaDto, tempArea);
+                    tempArea.setChildren(chidren);
+                    temList.add(tempArea);
+                    leve--;
+                }
+            }
+        }
+        if(temList.size() > 0){
+            return temList;
+        }else {
+            return null;
+        }
+    }
+
 
 
 }

+ 73 - 0
src/main/java/com/zoniot/ccrc/controller/common/CommonController.java

@@ -0,0 +1,73 @@
+package com.zoniot.ccrc.controller.common;
+
+import com.alibaba.fastjson.JSONObject;
+import com.zoniot.ccrc.commom.model.AjaxMessage;
+import com.zoniot.ccrc.commom.model.ResultStatus;
+import com.zoniot.ccrc.commom.utils.TreeUtil;
+import com.zoniot.ccrc.dao.AreaMapper;
+import com.zoniot.ccrc.dto.AreaDto;
+import com.zoniot.ccrc.dto.DeviceMeasuringPointDto;
+import com.zoniot.ccrc.dto.DeviceTypeDto;
+import com.zoniot.ccrc.dto.TreeDataDto;
+import com.zoniot.ccrc.service.DeviceTypeService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Controller
+@ResponseBody
+@RequestMapping("common")
+@Api(tags = "公共模块")
+public class CommonController {
+
+
+    @Autowired
+    private DeviceTypeService deviceTypeService;
+
+    @Autowired
+    private AreaMapper areaMapper;
+
+
+
+
+
+    @GetMapping("/getDeviceTypeList")
+    @ApiOperation(value = "获取系列(设备类型)列表")
+    public AjaxMessage<List<DeviceTypeDto>> getDeviceTypeList(
+            @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
+            @ApiParam(value = "设备类型 1:传感器 2;网关设备 3:集中器 4:采集器", required = false) @RequestParam(required = false) Integer type
+    ) {
+        List<DeviceTypeDto> list = deviceTypeService.getDeviceTypeList(sysId, type);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @GetMapping("/getTreeData")
+    @ApiOperation(value = "获取厂商/系列/型号树形数据")
+    public AjaxMessage<List<TreeDataDto>> getTreeData(
+            @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
+            @ApiParam(value = "类型 1:传感器 2;网关设备 3:集中器 4:采集器", required = false) @RequestParam(required = false) Integer type
+    ) {
+        List<TreeDataDto> list = deviceTypeService.getTreeData(sysId, type);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+
+    @GetMapping("/getAllArea")
+    @ApiOperation(value = "获取所有的省市区")
+    public AjaxMessage<List<AreaDto>> getAllArea(
+    ) {
+        List<AreaDto> list = areaMapper.getAllArea();
+        return new AjaxMessage<>(ResultStatus.OK, TreeUtil.getArea(list, 100000, 1));
+    }
+
+}

+ 33 - 0
src/main/java/com/zoniot/ccrc/controller/system/DeviceController.java

@@ -5,6 +5,7 @@ import com.zoniot.ccrc.commom.model.Pagination;
 import com.zoniot.ccrc.commom.model.ResultStatus;
 import com.zoniot.ccrc.dto.BuildingSelectDto;
 import com.zoniot.ccrc.dto.DeviceDto;
+import com.zoniot.ccrc.dto.DeviceMeasuringDataDTO;
 import com.zoniot.ccrc.service.DeviceService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -17,7 +18,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 @Controller
@@ -100,4 +105,32 @@ public class DeviceController {
         List<BuildingSelectDto> list = deviceService.deviceAreaList(sysId,deviceTypeId,orgId,province,city,region,communityId,buildingId,deviceNo,clientName,locDesc,status,valveStatus);
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
+
+
+    /*@GetMapping("/getData")
+    @ApiOperation(value = "获取设备数据")
+    public void getData(
+            @ApiParam(value = "设备id", required = true) @RequestParam(required = true) Long deviceId,
+            @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer startDate,
+            @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer endDate,
+            HttpServletRequest httpServletRequest,
+            HttpServletResponse httpServletResponse
+    ) throws IOException, ServletException {
+        //RequestDispatcher dispatcher = httpServletRequest.getRequestDispatcher("http://114.135.61.188:58088/api/device/getData");
+        //dispatcher.forward(httpServletRequest,httpServletResponse);
+        httpServletResponse.sendRedirect("http://114.135.61.188:58088/api/device/getData");
+    }
+
+
+    @GetMapping("/getDataExcel")
+    @ApiOperation(value = "导出设备数据excel")
+    public void getDataExcel(
+            @ApiParam(value = "设备id", required = true) @RequestParam(required = true) Long deviceId,
+            @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer startDate,
+            @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer endDate,
+            HttpServletResponse httpServletResponse
+    ) throws IOException {
+        httpServletResponse.sendRedirect("/ceng/hello.html");
+
+    }*/
 }

+ 47 - 0
src/main/java/com/zoniot/ccrc/dao/DeviceTypeMapper.java

@@ -0,0 +1,47 @@
+package com.zoniot.ccrc.dao;
+
+import com.zoniot.ccrc.dto.DeviceTypeDto;
+import com.zoniot.ccrc.dto.TreeDataDto;
+import com.zoniot.ccrc.entity.DeviceType;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface DeviceTypeMapper {
+    int insert(@Param("deviceType") DeviceType deviceType);
+
+    int insertSelective(@Param("deviceType") DeviceType deviceType);
+
+    int insertList(@Param("deviceTypes") List<DeviceType> deviceTypes);
+
+    int updateByPrimaryKeySelective(@Param("deviceType") DeviceType deviceType);
+
+
+    List<Integer> deleteQueryByManufacturerId(@Param("manufacturerId") Integer manufacturerId);
+
+    DeviceType findByid(@Param("id") Integer id);
+
+    List<DeviceTypeDto> getDeviceTypeList(@Param("sysId") Integer sysId, @Param("type") Integer type);
+
+    List<TreeDataDto> getTreeData(@Param("sysId") Integer sysId, @Param("type") Integer type);
+
+    List<TreeDataDto> getTreeDataByManufacturerId(@Param("channelId") Integer channelId, @Param("manufacturerId") Integer manufacturerId);
+
+    int findDeviceTypeUnique(@Param("id") Integer id, @Param("manufacturerId") Integer manufacturerId, @Param("equipmentType") String equipmentType, @Param("model") String model);
+
+    List<DeviceType> queryList(@Param("param") DeviceType param);
+
+    List<DeviceTypeDto> getConditionWithDeviceType(@Param("siteId") int siteId, @Param("buildingIds") int[] buildingIds, @Param("channelId") int channelId);
+
+    List<DeviceTypeDto> getWaterMeterType(@Param("parentId") Integer parentId);
+
+    List<DeviceTypeDto> findByIds(@Param("deviceTypeIds") List<Integer> deviceTypeIds);
+
+    DeviceTypeDto getByName(@Param("deviceTypeName") String deviceTypeName, @Param("deviceTypeModel") String deviceTypeModel);
+
+    DeviceTypeDto getById(@Param("id") Integer id);
+
+    DeviceTypeDto findByDeviceTypeId(@Param("deviceTypeId") Integer deviceTypeId);
+}

+ 19 - 0
src/main/java/com/zoniot/ccrc/dto/DeviceMeasuringDataDTO.java

@@ -0,0 +1,19 @@
+package com.zoniot.ccrc.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Map;
+
+@Data
+public class DeviceMeasuringDataDTO implements Serializable {
+    @ApiModelProperty(value = "值",position = 1)
+    private Map<String,String> measuringData;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "时间",position = 2)
+    private Date dateTime;
+}

+ 23 - 0
src/main/java/com/zoniot/ccrc/dto/DeviceMeasuringPointDto.java

@@ -0,0 +1,23 @@
+package com.zoniot.ccrc.dto;
+
+import com.zoniot.ccrc.entity.DeviceMeasuringPoint;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@Data
+@ApiModel
+@EqualsAndHashCode(callSuper=false)
+public class DeviceMeasuringPointDto extends DeviceMeasuringPoint {
+    @ApiModelProperty(value="测点数据类型 1:离散 2:连续")
+    private String measuringDataType;
+
+    @ApiModelProperty(value="measuringDescId")
+    private Integer measuringDesc;
+
+    @ApiModelProperty(value="数据值")
+    private List<TplMeasuringDataDef> dataDefList;
+}

+ 48 - 0
src/main/java/com/zoniot/ccrc/dto/DeviceTypeDto.java

@@ -0,0 +1,48 @@
+package com.zoniot.ccrc.dto;
+
+
+import com.zoniot.ccrc.entity.DeviceMeasuringPoint;
+import com.zoniot.ccrc.entity.DeviceType;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@EqualsAndHashCode(callSuper=false)
+public class DeviceTypeDto extends DeviceType implements Serializable {
+
+    private static final long serialVersionUID = -4248786000656508924L;
+
+    @ApiModelProperty(value = "厂商名称", position = 100, hidden = true)
+    private String manufacturerName;
+
+    @ApiModelProperty(value = "厂商英文名称", position = 100, hidden = true)
+    private String enManufacturerName;
+
+    @ApiModelProperty(value = "英文系列", position = 100, hidden = true)
+    private String enEquipmentType;
+
+    @ApiModelProperty(value = "英文型号", position = 100, hidden = true)
+    private String enModel;
+
+    @ApiModelProperty(value = "关联Agent", position = 100, hidden = true)
+    private String agentIdentifier;
+
+    @ApiModelProperty(value = "所属系统名称", position = 101, hidden = true)
+    private String channelName;
+
+    @ApiModelProperty(value = "所属场景,水务专用")
+    private Integer channelId;
+
+    @ApiModelProperty(value = "水表类型,1:远传表,2:智能表,9:流量计")
+    private Integer meterType;
+
+    @ApiModelProperty(value = "测点", position = 102, hidden = true)
+    private List<DeviceMeasuringPoint> measuringPoint;
+
+    @ApiModelProperty(value = "测点id集合", position = 103)
+    private List<Integer> measuringPointId;
+}

+ 48 - 0
src/main/java/com/zoniot/ccrc/dto/TplMeasuringDataDef.java

@@ -0,0 +1,48 @@
+package com.zoniot.ccrc.dto;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+* Created by Mybatis Generator 2019/01/17
+*/
+@ApiModel(value="com.bz.smart_city.entity.TplMeasuringDataDef")
+@Data
+public class TplMeasuringDataDef {
+
+    @ApiModelProperty(value="测点描述")
+    private Integer measuringDesc;
+
+    @ApiModelProperty(value="数据值")
+    private String dataValue;
+
+    @ApiModelProperty(value="数据名称")
+    private String dataName;
+
+    @ApiModelProperty(value="数据描述")
+    private String dataDesc;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人")
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人")
+    private String updateBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间")
+    private LocalDateTime dateUpdate;
+}

+ 21 - 0
src/main/java/com/zoniot/ccrc/dto/TreeDataDto.java

@@ -0,0 +1,21 @@
+package com.zoniot.ccrc.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TreeDataDto {
+    @ApiModelProperty(value = "id", position = 1)
+    private Integer id;
+
+    @ApiModelProperty(value = "标签", position = 3)
+    private String label;
+
+    @ApiModelProperty(value = "值", position = 3)
+    private String value;
+
+    @ApiModelProperty(value = "子类", position = 5)
+    private List<TreeDataDto> children;
+}

+ 48 - 0
src/main/java/com/zoniot/ccrc/entity/DeviceMeasuringPoint.java

@@ -0,0 +1,48 @@
+package com.zoniot.ccrc.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("设备测点")
+public class DeviceMeasuringPoint implements Serializable {
+    @ApiModelProperty(value = "id",position = 1)
+    private Integer id;
+
+    @ApiModelProperty(value = "测点名称",position = 2)
+    private String measuringPointName;
+
+    @ApiModelProperty(value = "代号",position = 3)
+    private String codeName;
+
+    @ApiModelProperty(value = "数据单位",position = 4)
+    private String dataUnit;
+
+    @ApiModelProperty(value = "类型",position = 5)
+    private Integer measuringPointType;
+
+    @JsonIgnore
+    @ApiModelProperty(value = "状态 0:删除 1:正常", position = 6, hidden = true)
+    private Integer status;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", position = 50, hidden = true)
+    private LocalDateTime createDate;
+
+    @ApiModelProperty(value = "创建人", position = 51, hidden = true)
+    private String createBy;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新时间", position = 52, hidden = true)
+    private LocalDateTime updateDate;
+
+    @ApiModelProperty(value = "更新用户", position = 53, hidden = true)
+    private String updateBy;
+
+}

+ 63 - 0
src/main/java/com/zoniot/ccrc/entity/DeviceType.java

@@ -0,0 +1,63 @@
+package com.zoniot.ccrc.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("设备类型")
+public class DeviceType implements Serializable {
+
+    private static final long serialVersionUID = 987389838608639392L;
+
+    @ApiModelProperty(value = "id", position = 1)
+    private Integer id;
+
+    @ApiModelProperty(value = "系列", position = 2)
+    private String equipmentType;
+
+    @ApiModelProperty(value = "型号", position = 3)
+    private String model;
+
+    @ApiModelProperty(value = "厂商id", position = 5)
+    private Integer manufacturerId;
+
+    @ApiModelProperty(value = "设备类型 1:传感器 2;网关设备", position = 6)
+    private Integer deviceType;
+
+    @JsonIgnore
+    @ApiModelProperty(value = "状态 0:删除 1:正常", position = 8, hidden = true)
+    private Integer status;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", position = 50, hidden = true)
+    private LocalDateTime createDate;
+
+    @ApiModelProperty(value = "创建人", position = 51, hidden = true)
+    private String createBy;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新时间", position = 52, hidden = true)
+    private LocalDateTime updateDate;
+
+    @ApiModelProperty(value = "更新用户", position = 53, hidden = true)
+    private String updateBy;
+    
+    @ApiModelProperty(value = "上报周期,单位小时", position = 53, hidden = true)
+    private Double period ; 
+    
+    @ApiModelProperty(value = "监控作业表达式,CronExpression", position = 53, hidden = true)
+    private String expression ;
+
+    @ApiModelProperty(value = "有无阀门 0:无 1:有", position = 53, hidden = true)
+    private Integer isValve ;
+
+    @ApiModelProperty(value = "是否需要注册 0:否:是", position = 53, hidden = true)
+    private Integer isRegister ;
+
+}

+ 34 - 0
src/main/java/com/zoniot/ccrc/service/DeviceTypeService.java

@@ -0,0 +1,34 @@
+package com.zoniot.ccrc.service;
+
+
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.dto.DeviceMeasuringPointDto;
+import com.zoniot.ccrc.dto.DeviceTypeDto;
+import com.zoniot.ccrc.dto.TreeDataDto;
+import com.zoniot.ccrc.entity.DeviceType;
+
+import java.util.List;
+
+public interface DeviceTypeService {
+
+    int insert(DeviceType deviceType);
+
+    int insertSelective(DeviceType deviceType);
+
+    int insertList(List<DeviceType> deviceTypes);
+
+    int updateByPrimaryKeySelective(DeviceType deviceType);
+
+
+
+    List<DeviceTypeDto> getDeviceTypeList(Integer sysId, Integer type);
+
+    List<TreeDataDto> getTreeData(Integer sysId, Integer type);
+    
+
+
+    DeviceTypeDto getByName(String deviceTypeName, String deviceTypeModel);
+
+    DeviceTypeDto findById(Integer deviceTypeId);
+
+}

+ 142 - 0
src/main/java/com/zoniot/ccrc/service/impl/DeviceTypeServiceImpl.java

@@ -0,0 +1,142 @@
+package com.zoniot.ccrc.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.github.pagehelper.PageHelper;
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.commom.utils.UserUtil;
+import com.zoniot.ccrc.dao.DeviceTypeMapper;
+import com.zoniot.ccrc.dto.DeviceMeasuringPointDto;
+import com.zoniot.ccrc.dto.DeviceTypeDto;
+import com.zoniot.ccrc.dto.TreeDataDto;
+import com.zoniot.ccrc.entity.DeviceMeasuringPoint;
+import com.zoniot.ccrc.entity.DeviceType;
+import com.zoniot.ccrc.service.DeviceTypeService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+@Slf4j
+@Service
+public class DeviceTypeServiceImpl implements DeviceTypeService {
+
+    @Resource
+    private DeviceTypeMapper deviceTypeMapper;
+
+
+    
+    @Override
+    public int insert(DeviceType deviceType) {
+        deviceType.setStatus(1);
+        deviceType.setCreateBy(UserUtil.getCurrentUser().getUsername());
+        deviceType.setCreateDate(LocalDateTime.now());
+        deviceType.setUpdateBy(UserUtil.getCurrentUser().getUsername());
+        deviceType.setUpdateDate(LocalDateTime.now());
+        return deviceTypeMapper.insert(deviceType);
+    }
+
+    @Override
+    public int insertSelective(DeviceType deviceType) {
+        deviceType.setStatus(1);
+        deviceType.setCreateBy(UserUtil.getCurrentUser().getUsername());
+        deviceType.setCreateDate(LocalDateTime.now());
+        deviceType.setUpdateBy(UserUtil.getCurrentUser().getUsername());
+        deviceType.setUpdateDate(LocalDateTime.now());
+        return deviceTypeMapper.insertSelective(deviceType);
+    }
+
+    @Override
+    public int insertList(List<DeviceType> deviceTypes) {
+        return deviceTypeMapper.insertList(deviceTypes);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(DeviceType deviceType) {
+        deviceType.setUpdateBy(UserUtil.getCurrentUser().getUsername());
+        deviceType.setUpdateDate(LocalDateTime.now());
+        return deviceTypeMapper.updateByPrimaryKeySelective(deviceType);
+    }
+
+
+
+
+
+
+
+
+    @Override
+    public List<DeviceTypeDto> getDeviceTypeList(Integer sysId, Integer type) {
+        return deviceTypeMapper.getDeviceTypeList(sysId, type);
+    }
+
+    @Override
+    public List<TreeDataDto> getTreeData(Integer sysId, Integer type) {
+        /*List<TreeDataDto> list = deviceTypeMapper.getTreeData(sysId, type);
+        list.forEach(treeDataDto -> {
+            treeDataDto.setChildren(deviceTypeMapper.getTreeDataByManufacturerId(sysId, treeDataDto.getId()));
+        });*/
+        List<DeviceTypeDto> list = deviceTypeMapper.getDeviceTypeList(sysId,type);
+
+        List<TreeDataDto> datalist = newArrayList();
+
+        Map<String, List<DeviceTypeDto>> manufacturerNameGroupBy = list.stream().collect(Collectors.groupingBy(DeviceTypeDto::getManufacturerName));
+        for (String manufacturerNameKey:manufacturerNameGroupBy.keySet()){
+            List<DeviceTypeDto> manufacturerNameList = manufacturerNameGroupBy.get(manufacturerNameKey);
+            TreeDataDto manufacturerNameTreeDataDto = new TreeDataDto();
+            manufacturerNameTreeDataDto.setLabel(manufacturerNameKey);
+            manufacturerNameTreeDataDto.setValue(manufacturerNameKey);
+            datalist.add(manufacturerNameTreeDataDto);
+
+            Map<String, List<DeviceTypeDto>> equipmentTypeGroupBy = manufacturerNameList.stream().collect(Collectors.groupingBy(DeviceTypeDto::getEquipmentType));
+            for (String equipmentTypeKey:equipmentTypeGroupBy.keySet()){
+                TreeDataDto equipmentTypeTreeDataDto = new TreeDataDto();
+                equipmentTypeTreeDataDto.setLabel(equipmentTypeKey);
+                equipmentTypeTreeDataDto.setValue(equipmentTypeKey);
+                if (manufacturerNameTreeDataDto.getChildren() != null) {
+                    manufacturerNameTreeDataDto.getChildren().add(equipmentTypeTreeDataDto);
+                }else {
+                    manufacturerNameTreeDataDto.setChildren(newArrayList(equipmentTypeTreeDataDto));
+                }
+
+                List<DeviceTypeDto> equipmentTypeKeyList = equipmentTypeGroupBy.get(equipmentTypeKey);
+                for (DeviceTypeDto deviceTypeDto : equipmentTypeKeyList) {
+                    TreeDataDto modelTreeDataDto = new TreeDataDto();
+                    modelTreeDataDto.setId(deviceTypeDto.getId());
+                    modelTreeDataDto.setLabel(deviceTypeDto.getModel());
+                    modelTreeDataDto.setValue(deviceTypeDto.getModel());
+
+                    if (equipmentTypeTreeDataDto.getChildren() != null) {
+                        equipmentTypeTreeDataDto.getChildren().add(modelTreeDataDto);
+                    }else {
+                        equipmentTypeTreeDataDto.setChildren(newArrayList(modelTreeDataDto));
+                    }
+                }
+            }
+        }
+        return datalist;
+    }
+
+    @Override
+    @Cacheable(value = "CacheDeviceType", key = "#deviceTypeName + #deviceTypeModel",unless = "#result == null")
+    public DeviceTypeDto getByName(String deviceTypeName,String deviceTypeModel) {
+        return deviceTypeMapper.getByName(deviceTypeName,deviceTypeModel);
+    }
+
+
+    @Override
+    @Cacheable(value = "deviceTypeId", key = "#deviceTypeId")
+    public DeviceTypeDto findById(Integer deviceTypeId) {
+        return deviceTypeMapper.findByDeviceTypeId(deviceTypeId);
+    }
+
+}

+ 317 - 0
src/main/resources/mapper/DeviceTypeMapper.xml

@@ -0,0 +1,317 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.zoniot.ccrc.dao.DeviceTypeMapper">
+    <!--auto generated Code-->
+    <resultMap id="BaseResultMap" type="com.zoniot.ccrc.entity.DeviceType">
+        <result column="id" property="id" jdbcType="INTEGER"/>
+        <result column="equipment_type" property="equipmentType" jdbcType="VARCHAR"/>
+        <result column="model" property="model" jdbcType="VARCHAR"/>
+        <result column="manufacturer_id" property="manufacturerId" jdbcType="INTEGER"/>
+        <result column="device_type" property="deviceType" jdbcType="INTEGER"/>
+        <result column="status" property="status" jdbcType="INTEGER"/>
+        <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
+        <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
+        <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
+        <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
+        <result column="is_valve" property="isValve" jdbcType="INTEGER"/>
+        <result column="is_register" property="isRegister" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <!--auto generated Code-->
+    <sql id="Base_Column_List">
+        id,
+        equipment_type,
+        model,
+        manufacturer_id,
+        device_type,
+        status,
+        create_date,
+        create_by,
+        update_date,
+        update_by,
+        is_valve,
+        is_register
+</sql>
+
+    <!--auto generated Code-->
+    <insert id="insert" useGeneratedKeys="true" keyProperty="deviceType.id">
+        INSERT INTO sc_device_type (
+            id,
+            equipment_type,
+            model
+        ) VALUES (
+            #{deviceType.id,jdbcType=INTEGER},
+            #{deviceType.equipmentType,jdbcType=VARCHAR},
+            #{deviceType.model,jdbcType=VARCHAR}
+        )
+</insert>
+
+    <!--auto generated Code-->
+    <insert id="insertSelective" useGeneratedKeys="true" keyProperty="deviceType.id">
+        INSERT INTO sc_device_type
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="deviceType.id!=null"> id,</if>
+            <if test="deviceType.equipmentType!=null"> equipment_type,</if>
+            <if test="deviceType.model!=null"> model</if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="deviceType.id!=null"> #{deviceType.id,jdbcType=INTEGER},</if>
+            <if test="deviceType.equipmentType!=null"> #{deviceType.equipmentType,jdbcType=VARCHAR},</if>
+            <if test="deviceType.model!=null"> #{deviceType.model,jdbcType=VARCHAR}</if>
+        </trim>
+</insert>
+
+    <!--auto generated Code-->
+    <insert id="insertList">
+        INSERT INTO sc_device_type(
+            id,
+            equipment_type,
+            model
+        )VALUES
+        <foreach collection="deviceTypes" item="deviceType" index="index" separator=",">
+        (
+            #{deviceType.id,jdbcType=INTEGER},
+            #{deviceType.equipmentType,jdbcType=VARCHAR},
+            #{deviceType.model,jdbcType=VARCHAR}
+        )
+        </foreach>
+</insert>
+
+    <!--auto generated Code-->
+    <update id="updateByPrimaryKeySelective">
+        UPDATE sc_device_type
+        <set>
+                <if test="deviceType.id != null"> id = #{deviceType.id,jdbcType=INTEGER},</if>
+                <if test="deviceType.equipmentType != null"> equipment_type = #{deviceType.equipmentType,jdbcType=VARCHAR},</if>
+                <if test="deviceType.model != null"> model = #{deviceType.model,jdbcType=VARCHAR}</if>
+        </set>
+		WHERE id = #{deviceType.id,jdbcType=INTEGER}
+    </update>
+
+
+
+
+
+    <select id="deleteQueryByManufacturerId" resultType="java.lang.Integer">
+        select id from sc_device_type where status = 1 and manufacturer_id = #{manufacturerId}
+    </select>
+
+<!--auto generated by codehelper on 2018-12-19-->
+	<select id="findByid" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_device_type
+        where id=#{id,jdbcType=INTEGER}
+    </select>
+
+    <select id="getDeviceTypeList" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+        select
+        sdt.*,
+        sdm.name as manufacturer_name
+        from sc_device_type sdt
+        left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
+        where sdt.status = 1
+        <if test="sysId != null"> and sdt.id in (
+        select device_type_id from sc_channel_device_type_use scdtu where scdtu.status = 1
+           and scdtu.channel_id = #{sysId}
+        )</if>
+        <if test="type != null"> and sdt.device_type = #{type}</if>
+    </select>
+
+<!--    <select id="getTreeData" resultType="com.bz.smart_city.dto.TreeDataDto">
+        select id,name as label,name as `value`
+        from sc_device_manufacturer
+        where status = 1
+        <if test="type != null"> and type = #{type}</if>
+        and id in(
+            select sdt.manufacturer_id
+            from sc_device_type sdt
+            where sdt.status = 1
+            <if test="type != null"> and sdt.device_type = #{type}</if>
+            <if test="sysId != null">
+            and sdt.id in(
+              SELECT device_type_id FROM sc_channel_device_type_use WHERE status = 1 and channel_id = #{sysId}
+            )
+            </if>
+            group by manufacturer_id
+        )
+    </select>-->
+
+    <select id="getTreeData" resultType="com.zoniot.ccrc.dto.TreeDataDto">
+        select id,name as label,name as `value`
+        from sc_device_manufacturer
+        where status = 1
+        <if test="type != null"> and type = #{type}</if>
+        and id in(
+            select sdt.manufacturer_id
+            from sc_device_type sdt
+            where sdt.status = 1
+            <if test="type != null"> and sdt.device_type = #{type}</if>
+            <if test="sysId != null">
+            and sdt.id in(
+              SELECT device_type_id FROM sc_channel_device_type_use WHERE status = 1 and channel_id = #{sysId}
+            )
+            </if>
+            group by manufacturer_id
+        )
+    </select>
+
+    <resultMap id="lazyLoadDeviceType" type="com.zoniot.ccrc.dto.TreeDataDto" extends="BaseResultMap">
+        <collection property="children" ofType="com.zoniot.ccrc.dto.TreeDataDto" select="com.zoniot.ccrc.dao.DeviceTypeMapper.getTreeDataByManufacturerId"
+                    column="id">
+        </collection>
+    </resultMap>
+
+    <resultMap id="TreeDataDtoMap" type="com.zoniot.ccrc.dto.TreeDataDto">
+        <id column="id" property="id" jdbcType="INTEGER"/>
+        <result column="equipment_type" property="label" jdbcType="VARCHAR"/>
+        <result column="equipment_type" property="value" jdbcType="VARCHAR"/>
+        <collection property="children" ofType="com.zoniot.ccrc.dto.TreeDataDto">
+            <id column="id" property="id" jdbcType="INTEGER"/>
+            <result column="model" property="label" jdbcType="VARCHAR"/>
+            <result column="model" property="value" jdbcType="VARCHAR"/>
+        </collection>
+    </resultMap>
+
+    <select id="getTreeDataByManufacturerId" resultMap="TreeDataDtoMap">
+        select sdt.id,sdt.equipment_type,sdt.model
+        from sc_device_type sdt
+        where status=1 and  manufacturer_id = #{manufacturerId}
+        <if test="channelId != null">
+            and sdt.id in(
+            SELECT device_type_id FROM sc_channel_device_type_use WHERE status = 1 and channel_id = #{channelId}
+            )
+        </if>
+    </select>
+
+    <select id="findDeviceTypeUnique" resultType="int">
+        select count(1) from sc_device_type where status = 1
+        and manufacturer_id = #{manufacturerId} and equipment_type = #{equipmentType} and model = #{model}
+        <if test="id != null"> and id != #{id}</if>
+    </select>
+
+	<select id="queryList" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+		SELECT
+			id,
+			equipment_type,
+			model,
+			manufacturer_id,
+			device_type,
+			STATUS,
+			create_date,
+			create_by,
+			period,
+			expression,
+			update_date,
+			update_by 
+		FROM
+			sc_device_type 
+		WHERE
+			`status` = 1
+	</select>
+	<select id="getWaterMeterType" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+		SELECT
+			dt.id as id,
+			dt.model as model,
+			dt.equipment_type as equipment_type,
+			dt.device_type as device_type,
+			dt.manufacturer_id,
+			dm.`name` as manufacturer_name,
+            w.parent_id as meter_type
+		FROM
+			sc_device_type dt 
+			left join sc_device_manufacturer dm on (dt.manufacturer_id = dm.id and dm.`status` = 1)
+        inner join sc_w_meter_type w on (w.device_type_id = dt.id and w.`status` = 1)
+        WHERE
+			dt.`status` = 1
+            <if test = "parentId != null and parentId != 0" >
+                and w.parent_id = #{parentId}
+            </if>
+    </select>
+	<select id="getConditionWithDeviceType" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+		SELECT
+			dt.id as id,
+			dt.model as model,
+			dt.equipment_type as equipment_type,
+			dt.device_type as device_type,
+			dm.`name` as manufacturer_name
+		FROM
+			sc_device_type dt 
+			left join sc_device_manufacturer dm on (dt.manufacturer_id = dm.id and dm.`status` = 1)
+		WHERE
+			dt.`status` = 1 
+			<if test="buildingIds == null or buildingIds.length == 0">
+			AND exists (
+				select 
+					1 
+				from 
+					sc_channel_device_type_use dtu 
+				where dtu.status = 1 
+				<if test = "channelId != null ">
+				AND dtu.channel_id = #{channelId}
+				</if>
+				and dtu.device_type_id = dt.id
+			)
+			</if>
+			<if test="buildingIds != null and buildingIds.length != 0">
+			AND EXISTS (
+				SELECT
+					1 
+				FROM
+					sc_device d
+					LEFT JOIN sc_building b ON ( b.id = d.building_id AND b.`status` = 1 ) 
+				WHERE
+					d.STATUS = 1
+					<if test = "siteId != null ">
+						AND d.site_id = #{siteId} 
+					</if> 
+					<if test = "channelId != null ">
+						AND d.sys_id = #{channelId}
+					</if>
+					
+					
+			    		AND d.building_id IN
+			    		<foreach collection="buildingIds" item="item" open="(" separator="," close=")">#{item} </foreach>
+					AND d.device_type = dt.id 
+			)
+			</if>
+	</select>
+
+    <select id="findByIds" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+        select
+        sdt.id,
+        sdt.equipment_type,
+        sdt.model,
+        sdt.manufacturer_id,
+        sdt.device_type,sdm.name as manufacturer_name,
+        w.parent_id as meter_type
+        from sc_device_type sdt
+        left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
+        left join sc_w_meter_type w on (w.device_type_id = sdt.id and w.status = 1)
+        where sdt.status = 1
+        <if test="deviceTypeIds != null and deviceTypeIds.size() != 0">
+            and sdt.id in
+            <foreach collection="deviceTypeIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+        </if>
+    </select>
+    <select id="getByName" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+        select id,equipment_type,model,manufacturer_id,device_type from sc_device_type where status = 1
+        and equipment_type = #{deviceTypeName} and model =#{deviceTypeModel} limit 1
+    </select>
+
+    <select id="getById" resultType="com.zoniot.ccrc.dto.DeviceTypeDto">
+        select
+        sdt.*,
+        sdm.en_name as en_manufacturer_name
+        from sc_device_type sdt
+        left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
+        where sdt.status = 1 and sdt.id = #{id}
+    </select>
+
+    <select id="findByDeviceTypeId" resultMap="lazyLoadMeasuringPoint">
+        select id,equipment_type,model,manufacturer_id,device_type from sc_device_type where status = 1
+        and id = #{deviceTypeId}
+    </select>
+</mapper>
+