fengxiang
2018-05-16 5fa78e073c5c6269997e7d03b56176b157c7a327
设备删除,更新redis
4 files modified
38 ■■■■ changed files
src/main/java/com/moral/mapper/DeviceMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 25 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceMapper.xml 4 ●●●● patch | view | raw | blame | history
src/main/resources/system/alarmLevels.json 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DeviceMapper.java
@@ -20,6 +20,13 @@
    List<Map<String, Object>> getDeviceVersionIdByMonitorPoint(Integer monitorPointId);
    List<Device> selectByOrgIdAndDevName(@Param("orgId")Integer orgId,@Param("devName")String devName);
    /**
     *
     * @param orgId
     * @param mpId
     * @return 返回未删除结果
     */
    List<Device> selectByOrgIdAndMpId(@Param("orgId")Integer orgId,@Param("mpId")Integer mpId);
    List<Device> selectByMap(Map<String, Object> params);
    Device selectWithOrgIdsByMac(String mac);
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -181,7 +181,7 @@
     *
     * @param map
     * map里 包括 组织id和4个坐标点
     * @return
     * @return 返回未删除结果集
     */
    @Override
    public List<Device> query(Map<String, Object> map) {
@@ -196,7 +196,7 @@
     * @param deviceName
     * @param pageSize
     * @param pageNo
     * @return
     * @return 返回未删除结果
     */
    @Override
    public PageResult query(Integer orgId, String deviceName, Integer pageSize, Integer pageNo) {
@@ -218,7 +218,7 @@
     * @param mpId
     * @param pageSize
     * @param pageNo
     * @return
     * @return 返回未删除结果
     */
    @Override
    public PageResult query(Integer orgId, Integer mpId, Integer pageSize, Integer pageNo) {
@@ -332,15 +332,28 @@
        Device device = new Device();
        device.setIsDelete(Constants.IS_DELETE_TRUE);
        if(ids!=null&&ids.length>0){
            Example example = new Example(ENTITY_CLASS);
            example.or().andIn("id", Arrays.asList(ids));
            if(ids.length==1){
                device.setId(ids[0]);
                deviceMapper.updateByPrimaryKeySelective(device);
            }else{
                Example example = new Example(ENTITY_CLASS);
                example.or().andIn("id", Arrays.asList(ids));
                deviceMapper.updateByExampleSelective(device,example);
            }
            List<Device> deviceList = deviceMapper.selectByExample(example);
            List<String> adjustAndDeviceKeys = deviceList.stream().collect(
                    ArrayList<String>::new,
                    (list,dev) -> {
                        if(!StringUtils.isBlank(dev.getMac())){
                            list.add("device_"+dev.getMac());
                            list.add("adjust_"+dev.getMac());
                        }
                    },
                    (oList,nList)-> {
                        oList.addAll(nList);
                    }
            );
            redisUtils.remove(adjustAndDeviceKeys.toArray(new String [adjustAndDeviceKeys.size()]));
        }
    }
src/main/resources/mapper/DeviceMapper.xml
@@ -177,6 +177,7 @@
        <if test="devName!=null and ''!=devName">
            and dev.name like CONCAT('%',#{devName},'%')
        </if>
            and dev.is_delete = 0
        </where>
    </select>
    <select id="selectByOrgIdAndMpId" resultMap="BaseResultMap">
@@ -188,6 +189,7 @@
                mpt.organization_id =  #{orgId}
            </if>
            and dev.monitor_point_id = #{mpId}
            and dev.is_delete = 0
        </where>
    </select>
    <select id="selectByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
@@ -204,6 +206,7 @@
            AND dev.latitude  < #{mapBounds.Fe,jdbcType=NUMERIC}
            AND dev.latitude  > #{mapBounds.Ke,jdbcType=NUMERIC}
              ]]>
            AND dev.is_delete =0
        </where>
    </select>
    <resultMap id="BaseResultWithOrgIdsMap" type="com.moral.entity.Device" extends="BaseResultMap">
@@ -222,6 +225,7 @@
        left join monitor_point  mpt on dev.monitor_point_id = mpt.id
        left join profession  pro on pro.id = dev.profession_id
        where dev.mac = #{mac,jdbcType=VARCHAR}
        limit 0,1
    </select>
    <select id="getDeviceCountByRegion" resultType="java.lang.Integer">
src/main/resources/system/alarmLevels.json
@@ -72,7 +72,7 @@
      "increment": [
        25,
        30,
        40
        60
      ],
      "degressEnable": 0,
      "degression": [0,0,0]