Browse Source

地图设置查询、保存

yuejiaying 4 years ago
parent
commit
72d7bf31b4

+ 76 - 0
sms_water/src/main/java/com/huaxu/controller/MapSettingController.java

@@ -0,0 +1,76 @@
+package com.huaxu.controller;
+
+import com.huaxu.entity.MapSetting;
+import com.huaxu.model.AjaxMessage;
+import com.huaxu.model.LoginUser;
+import com.huaxu.model.ResultStatus;
+import com.huaxu.service.MapSettingService;
+import com.huaxu.util.UserUtil;
+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.web.bind.annotation.*;
+
+/**
+ * 地图设置控制层
+ *
+ * @author yjy
+ * @since 2020-12-4
+ */
+@RestController
+@RequestMapping("/mapSetting")
+@Api(tags = "地图设置")
+public class MapSettingController {
+    /**
+     * 服务对象
+     */
+    @Autowired
+    private MapSettingService mapSettingService;
+
+    /**
+     * 根据机构查询地图设置数据
+     *
+     * @param sceneTypeName 一级场景类型名称
+     * @return 单条数据
+     */
+    @RequestMapping(value = "selectMap", method = RequestMethod.GET)
+    @ApiOperation(value = "查询用户单条地图配置数据")
+    public AjaxMessage<MapSetting> selectMap(
+            @ApiParam(value = "一级场景类型名称", required = true) @RequestParam String sceneTypeName) {
+       if(sceneTypeName==null) {
+           return new AjaxMessage<>(ResultStatus.PARAM_ERROR);
+       }
+        LoginUser currentUser = UserUtil.getCurrentUser();
+        Integer userId=currentUser.getId();
+        MapSetting result = mapSettingService.selectMap(sceneTypeName,userId);
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+    /**
+     * 保存地图配置数据
+     *
+     * @param mapSetting 地图设置信息
+     * @return
+     */
+    @RequestMapping(value = "saveSystem", method = RequestMethod.POST)
+    @ApiOperation(value = "保存单条地图配置数据")
+    public AjaxMessage<Boolean> saveSystem(
+            @ApiParam(value = "地图设置信息", required = true) @RequestBody MapSetting mapSetting) {
+        LoginUser currentUser = UserUtil.getCurrentUser();
+        MapSetting idSetting= mapSettingService.selectMap(mapSetting.getSceneTypeName(),currentUser.getId());
+        Integer mapId=idSetting != null?idSetting.getId():null;
+        Integer id = mapSetting.getId() != null?mapSetting.getId():mapId;
+        mapSetting.setUserId(currentUser.getId());
+        if(id==null){//没有查询到数据则新增
+            mapSetting.setCreateBy(currentUser.getUsername());
+        }else {//修改
+            mapSetting.setId(id);
+            mapSetting.setUpdateBy(currentUser.getUsername());
+        }
+        mapSetting.setStatus(1);
+        boolean result = mapSettingService.saveMap(mapSetting);
+
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+}

+ 1 - 20
sms_water/src/main/java/com/huaxu/controller/OnlineMonitorController.java

@@ -65,7 +65,7 @@ public class OnlineMonitorController {
     }
 
     @RequestMapping(value="selectMapSuspension" , method = RequestMethod.GET)
-    @ApiOperation(value = "查询地图悬浮数据")
+    @ApiOperation(value = "查询地图悬浮数据及用水量排行")
     public AjaxMessage<List<MonitorDataCollectDto>> selectMapSuspension(
             @ApiParam(value = "一级场景类型名称", required = true) @RequestParam String sceneTypeName){
         MonitorDataCollectDto monitorDataCollectDto=new MonitorDataCollectDto();
@@ -84,25 +84,6 @@ public class OnlineMonitorController {
         return new AjaxMessage<>(ResultStatus.OK, onlineMonitorService.selectMapParam(monitorDataCollectDto));
     }
 
-    @RequestMapping(value="selectUsageRank" , method = RequestMethod.GET)
-    @ApiOperation(value = "查询用水量排行")
-    public AjaxMessage<List<MonitorDataCollectDto>> selectUsageRank(
-            @ApiParam(value = "一级场景类型名称", required = true) @RequestParam String sceneTypeName){
-        //查询该场景类型的一级场景
-        SceneEntity sceneEntity = new SceneEntity();
-        sceneEntity.setSceneTypeName(sceneTypeName);
-        List<SceneEntity> sceneEntities = sceneService.selectByTypeName(sceneEntity);
-        List<MonitorDataCollectDto> result=new ArrayList<MonitorDataCollectDto>();
-        for(SceneEntity scene:sceneEntities){
-            MonitorDataCollectDto monitorDataCollectDto=new MonitorDataCollectDto();
-            monitorDataCollectDto.setSceneId(scene.getId());
-            monitorDataCollectDto.setSceneName(scene.getSceneName());
-            //计算用水量
-            result.add(monitorDataCollectDto);
-        }
-        return new AjaxMessage<>(ResultStatus.OK, result);
-    }
-
     @RequestMapping(value="selectPage" , method = RequestMethod.GET)
     @ApiOperation(value = "查询实时数据列表")
     public AjaxMessage<Pagination<OnlineDataDto>> selectPage(

+ 3 - 1
sms_water/src/main/java/com/huaxu/controller/SystemSettingController.java

@@ -46,8 +46,10 @@ public class SystemSettingController {
     public AjaxMessage<SystemSetting> selectSystem(
             @ApiParam(value = "所属公司", required = false) @RequestParam(required = false) Integer companyOrgId,
             @ApiParam(value = "所属部门", required = false) @RequestParam(required = false) Integer deptOrgId) {
+        LoginUser currentUser = UserUtil.getCurrentUser();
        if(companyOrgId==null&&deptOrgId==null) {
-           return new AjaxMessage<>(ResultStatus.PARAM_ERROR);
+           companyOrgId=currentUser.getCompanyId();
+           deptOrgId=currentUser.getDepartmentId();
        }
         SystemSetting result = systemSettingService.selectSystem(companyOrgId,deptOrgId);
         return new AjaxMessage<>(ResultStatus.OK, result);

+ 18 - 0
sms_water/src/main/java/com/huaxu/dao/MapSettingMapper.java

@@ -0,0 +1,18 @@
+package com.huaxu.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.huaxu.entity.MapSetting;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ *
+ * 地图设置Dao接口
+ *
+ * @author yjy
+ * @since 2020-12-4
+ */
+@Mapper
+public interface MapSettingMapper extends BaseMapper<MapSetting> {
+
+
+}

+ 1 - 1
sms_water/src/main/java/com/huaxu/dto/OnlineDataDto.java

@@ -49,7 +49,7 @@ public class OnlineDataDto {
     @ApiModelProperty("供水浊度、出水浊度")
     private MonitorDataDto yieldTurbidity;
 
-    @ApiModelProperty("取水PH、水PH")
+    @ApiModelProperty("取水PH、水PH")
     private MonitorDataDto intakePh;
 
     @ApiModelProperty("取水浊度、进水浊度")

+ 92 - 0
sms_water/src/main/java/com/huaxu/entity/MapSetting.java

@@ -0,0 +1,92 @@
+package com.huaxu.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 地图设置(sms_map_setting)实体类
+ *
+ * @author yjy
+ * @since 2020-12-4
+ */
+@Data
+@ApiModel
+@TableName("sms_map_setting")
+public class MapSetting implements Serializable {
+    private static final long serialVersionUID = 460807634914426955L;
+    /**
+     * 主键
+     */
+    @ApiModelProperty(value = "主键")
+    @TableId(type= IdType.AUTO)
+    private Integer id;
+    /**
+     * 用户编号
+     */
+    @ApiModelProperty(value = "用户编号")
+    private Integer userId;
+    /**
+     * 场景类型名称
+     */
+    @ApiModelProperty(value = "场景类型名称")
+    private String sceneTypeName;
+    /**
+     * 中心点经度
+     */
+    @ApiModelProperty(value = "中心点经度")
+    private BigDecimal pointX;
+    /**
+     * 中心点纬度
+     */
+    @ApiModelProperty(value = "中心点纬度")
+    private BigDecimal pointY;
+    /**
+     * 地图层级
+     */
+    @ApiModelProperty(value = "地图层级")
+    private Integer mapLevel;
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 数据删除标识
+     */
+    @ApiModelProperty(value = "数据删除标识")
+    @TableLogic
+    private Integer status;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private Date dateCreate;
+    /**
+     * 更新人
+     */
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
+    @ApiModelProperty(value = "更新时间")
+    private Date dateUpdate;
+}

+ 43 - 0
sms_water/src/main/java/com/huaxu/service/MapSettingService.java

@@ -0,0 +1,43 @@
+package com.huaxu.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.huaxu.dao.MapSettingMapper;
+import com.huaxu.entity.MapSetting;
+import com.huaxu.model.LoginUser;
+import com.huaxu.util.UserUtil;
+import org.springframework.stereotype.Service;
+
+/**
+ * 地图设置服务接口
+ *
+ * @author yjy
+ * @since 2020-12-4
+ */
+@Service
+public class MapSettingService extends ServiceImpl<MapSettingMapper,MapSetting> {
+
+    /**
+     * 根据机构查询单条数据
+     *
+     * @param sceneTypeName 一级场景类型名称
+     * @return 单条数据
+     */
+    public MapSetting selectMap(String sceneTypeName,Integer userId){
+        MapSetting res=new MapSetting();
+        if(userId != null) {
+            res = this.getOne(new QueryWrapper<MapSetting>().eq("USER_ID", userId).eq("SCENE_TYPE_NAME",sceneTypeName));
+        }
+        return res;
+    }
+    /**
+     * 保存数据
+     *
+     * @param MapSetting 地图设置信息
+     * @return
+     */
+    public boolean saveMap(MapSetting MapSetting) {
+        return this.saveOrUpdate(MapSetting);
+    }
+
+}