| | |
| | |
|
| | | List<Map<String, Object>> getDeviceVersionIdByMonitorPoint(Integer monitorPointId);
|
| | |
|
| | | List<Device> selectByOrgIdAndDevName(@Param("orgId")Integer orgId,@Param("devState") String state,@Param("name")String name);
|
| | | List<Device> selectByOrgIdAndDevName(@Param("orgId")Integer orgId, @Param("orgIds")List<Integer> orgIds,@Param("devState") String state,@Param("name")String name);
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | * @param mpId
|
| | | * @return 返回未删除结果
|
| | | */
|
| | | List<Device> selectByOrgIdAndMpId(@Param("orgId")Integer orgId,@Param("mpId")Integer mpId);
|
| | | List<Device> selectByOrgIdAndMpId(@Param("orgId")Integer orgId,@Param("orgIds")List<Integer> orgIds,@Param("mpId")Integer mpId);
|
| | | List<Device> selectByMap(Map<String, Object> params);
|
| | | Device selectWithOrgIdsByMac(String mac);
|
| | | List<Integer> getDeviceVersionIdByAreaCode(Map<String, Object> parameters);
|
| | |
| | | import com.moral.common.util.ExampleUtil;
|
| | | import com.moral.common.util.RedisUtils;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import org.apache.commons.collections.MapUtils;
|
| | | import org.apache.commons.lang3.BooleanUtils;
|
| | | import org.apache.commons.lang3.StringUtils;
|
| | |
| | | @Resource
|
| | | private AccountService accountService;
|
| | | private Class ENTITY_CLASS = Device.class;
|
| | | @Resource
|
| | | OrganizationMapper orgMapper;
|
| | | @Resource
|
| | | RedisUtils redisUtils;
|
| | | @Override
|
| | |
| | |
|
| | | /**
|
| | | *
|
| | | * @param map
|
| | | * @param params
|
| | | * map里 包括 组织id和4个坐标点
|
| | | * @return 返回未删除结果集
|
| | | */
|
| | | @Override
|
| | | public List<Device> query(Map<String, Object> map) {
|
| | | List <Device> list = deviceMapper.selectByMap(map);
|
| | | loadDeviceState(list);
|
| | | return list;
|
| | | public List<Device> query(Map<String, Object> params) {
|
| | | Object orgIdObj = params.get("orgId");
|
| | | List<Device> deviceList = null;
|
| | | if(orgIdObj != null) {
|
| | | Integer orgId = Integer.parseInt(orgIdObj.toString());
|
| | | List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
|
| | | params.put("orgIds", orgIds);
|
| | | deviceList = deviceMapper.selectByMap(params);
|
| | | loadDeviceState(deviceList);
|
| | | }
|
| | | return deviceList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据组织id和设备名称 分页查询设备
|
| | | * @param orgId
|
| | |
| | | */
|
| | | @Override
|
| | | public PageResult query(Integer orgId, String deviceName, Integer pageSize, Integer pageNo) {
|
| | | List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
|
| | | if(!ObjectUtils.isEmpty(pageSize)&&!ObjectUtils.isEmpty(pageNo)){
|
| | | PageHelper.startPage(pageNo,pageSize);
|
| | | }
|
| | |
| | | state = "4";
|
| | | deviceName = null;break;
|
| | | }
|
| | | List<Device> list = deviceMapper.selectByOrgIdAndDevName(orgId,state,deviceName);
|
| | | List<Device> list = deviceMapper.selectByOrgIdAndDevName(orgId,orgIds,state,deviceName);
|
| | | //从redis里取状态
|
| | | loadDeviceState(list);
|
| | | if(list instanceof Page){
|
| | |
| | | */
|
| | | @Override
|
| | | public PageResult query(Integer orgId, Integer mpId, Integer pageSize, Integer pageNo) {
|
| | | List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
|
| | | if(!ObjectUtils.isEmpty(pageSize)&&!ObjectUtils.isEmpty(pageNo)){
|
| | | PageHelper.startPage(pageNo,pageSize);
|
| | | }
|
| | | List<Device> list = deviceMapper.selectByOrgIdAndMpId(orgId,mpId);
|
| | | List<Device> list = deviceMapper.selectByOrgIdAndMpId(orgId,orgIds,mpId);
|
| | | //从redis里取状态
|
| | | loadDeviceState(list);
|
| | | if(list instanceof Page){
|
| | |
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.moral.mapper.DictionaryDataMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | |
| | | @Resource
|
| | | private DeviceMapper deviceMapper;
|
| | | @Resource
|
| | | private OrganizationMapper orgMapper;
|
| | | @Resource
|
| | | RedisUtils redisUtils;
|
| | | @Resource
|
| | | DictionaryDataMapper dictionaryDataMapper;
|
| | |
|
| | | private static Class ENTITY_CLASS = MonitorPoint.class;
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters) {
|
| | |
| | | @Override
|
| | | public List<MonitorPoint> queryWithStateByMap(Map<String, Object> params){
|
| | | params.put("isDelete",Constants.IS_DELETE_FALSE);
|
| | | List<MonitorPoint> monitorPointList = monitorPointMapper.selectByMap(params);
|
| | | for(MonitorPoint monitorPoint:monitorPointList){
|
| | | Integer state = getStateFromRedis(monitorPoint.getId());
|
| | | monitorPoint.setState(state);
|
| | | Object orgIdObj = params.get("orgId");
|
| | | List<MonitorPoint> monitorPointList = null;
|
| | | if(orgIdObj != null) {
|
| | | Integer orgId = Integer.parseInt(orgIdObj.toString());
|
| | | List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
|
| | | params.put("orgIds",orgIds);
|
| | | monitorPointList = monitorPointMapper.selectByMap(params);
|
| | | for(MonitorPoint monitorPoint:monitorPointList){
|
| | | Integer state = getStateFromRedis(monitorPoint.getId());
|
| | | monitorPoint.setState(state);
|
| | | }
|
| | | }
|
| | | return monitorPointList;
|
| | | return monitorPointList == null ? new ArrayList<>() : monitorPointList;
|
| | | }
|
| | | private Integer getStateFromRedis(Integer monitorPointId){
|
| | | StringBuilder key = new StringBuilder();
|
| | |
| | | WHERE |
| | | mp.area_code = #{areaCode} |
| | | AND d.monitor_point_id = mp.id |
| | | <if test="orgIds != null and orgIds.size > 0"> |
| | | <if test="orgIds != null and orgIds.size() > 0"> |
| | | AND mp.organization_id IN |
| | | <foreach collection="orgIds" open="(" separator="," close=")" item="listItem"> |
| | | #{listItem} |
| | |
| | | left join device_version dve on dev.device_version_id = dve.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId} |
| | | ( |
| | | 1 > 1 |
| | | <if test="orgIds!=null and orgIds.size() > 0"> |
| | | or mpt.organization_id in |
| | | <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=","> |
| | | #{tempOrgId,jdbcType=INTEGER} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | and dev.is_delete = 0 |
| | | <if test="devState!=null"> |
| | |
| | | left join device_version dve on dev.device_version_id = dve.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId} |
| | | ( |
| | | 1 > 1 |
| | | <if test="orgIds!=null and orgIds.size() > 0"> |
| | | or mpt.organization_id in |
| | | <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=","> |
| | | #{tempOrgId,jdbcType=INTEGER} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | and dev.monitor_point_id = #{mpId} |
| | | and dev.is_delete = 0 |
| | |
| | | left join device_version dve on dev.device_version_id = dve.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId,jdbcType=VARCHAR} |
| | | ( |
| | | 1 > 1 |
| | | <if test="orgIds!=null and orgIds.size() > 0"> |
| | | or mpt.organization_id in |
| | | <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=","> |
| | | #{tempOrgId,jdbcType=INTEGER} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | <![CDATA[ |
| | | AND dev.longitude < #{mapBounds.Ge,jdbcType=NUMERIC} |
| | |
| | | SELECT mpt.* from monitor_point mpt |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId,jdbcType=VARCHAR} |
| | | ( |
| | | 1 > 1 |
| | | <if test="orgIds!=null and orgIds.size() > 0"> |
| | | or mpt.organization_id in |
| | | <foreach collection="orgIds" item="tempOrgId" open="(" close=")" separator=","> |
| | | #{tempOrgId,jdbcType=INTEGER} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | <![CDATA[ |
| | | AND mpt.longitude < #{mapBounds.Ge,jdbcType=NUMERIC} |