Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into dev
| | |
| | | @Autowired |
| | | private MenuMapper menuMapper; |
| | | |
| | | @Autowired |
| | | private OperationLogUtils operationLogUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void allotMenus(Map<String, Object> parameters) { |
| | |
| | | //日志 |
| | | String groupName = groupMapper.selectById((Integer) parameters.get("groupId")).getGroupName(); |
| | | String content = "给组:" + groupName + "分配了菜单:" + menus.toString(); |
| | | OperationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Autowired |
| | | private UserGroupMapper userGroupMapper; |
| | | |
| | | @Autowired |
| | | private OperationLogUtils operationLogUtils; |
| | | |
| | | @Override |
| | | public Map<String, Object> addGroup(Group group) { |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | |
| | | |
| | | //日志 |
| | | String content = "添加了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content, Constants.INSERT_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.INSERT_OPERATE_TYPE); |
| | | return result; |
| | | } |
| | | |
| | |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String content = "删除了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | groupMapper.updateById(group); |
| | | //日志 |
| | | String content = "修改了组:" + before + "=>" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | return result; |
| | | } |
| | | |
| | |
| | | @Autowired |
| | | private GroupMapper groupMapper; |
| | | |
| | | @Autowired |
| | | private OperationLogUtils operationLogUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void allotGroups(Map<String, Object> parameters) { |
| | |
| | | //日志 |
| | | String account = userMapper.selectById((Integer) parameters.get("userId")).getAccount(); |
| | | String content = "给用户:" + account + "分配了组:" + groups.toString(); |
| | | OperationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Autowired |
| | | private UserLogMapper userLogMapper; |
| | | |
| | | @Autowired |
| | | private OperationLogUtils operationLogUtils; |
| | | |
| | | @Value("${AES.KEY}") |
| | | private String AESKey; |
| | | |
| | |
| | | userMapper.insert(user); |
| | | //日志 |
| | | String content = "添加了用户:" + user.getAccount(); |
| | | OperationLogUtils.insertLog(request, content, Constants.INSERT_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.INSERT_OPERATE_TYPE); |
| | | return result; |
| | | } |
| | | |
| | |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String content = "删除了用户:" + user.getAccount(); |
| | | OperationLogUtils.insertLog(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | content.append(key).append(":").append(beforeValue).append("=>").append(afterValue).append(";"); |
| | | } |
| | | } |
| | | OperationLogUtils.insertLog(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | operationLogUtils.insertLog(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | |
| | | return result; |
| | | } |
| | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.moral.api.entity.UserLog; |
| | | import com.moral.api.service.UserLogService; |
| | |
| | | @Component |
| | | public class OperationLogUtils { |
| | | |
| | | private static UserLogService userLogService; |
| | | |
| | | @Autowired |
| | | public void setUserLogService(UserLogService userLogService) { |
| | | this.userLogService = userLogService; |
| | | } |
| | | private UserLogService userLogService; |
| | | |
| | | public static void insertLog(HttpServletRequest request, String content, String type) { |
| | | @Transactional |
| | | public void insertLog(HttpServletRequest request, String content, String type) { |
| | | String token = request.getHeader("token"); |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | | UserLog userLog = new UserLog(); |
| | |
| | | MONITOR_POINT_IS_EXIST(-39,"站点已存在"), |
| | | MONITOR_POINT_IS_NOT_EXIST(-40,"站点不存在"), |
| | | VERSION_NOT_EXIST(-41,"版本不存在"), |
| | | VERSION_EXIST(-42,"版本已经存在") |
| | | VERSION_EXIST(-42,"版本已经存在"), |
| | | MAC_IS_EXIST(-42,"mac已存在") |
| | | ; |
| | | private final Integer code; |
| | | private final String msg; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.Device; |
| | | |
| | | import com.moral.api.entity.Version; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.VersionService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.PageResult; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"设备管理"}) |
| | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private VersionService versionService; |
| | | |
| | | @ApiOperation(value = "添加设备", notes = "添加设备") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "insert", method = RequestMethod.POST) |
| | | public ResultMessage insert(Device device) { |
| | | public ResultMessage insert(@RequestBody Device device) { |
| | | String name = device.getName(); |
| | | String mac = device.getMac(); |
| | | Integer monitorPointId = device.getMonitorPointId(); |
| | | Integer versionId = device.getDeviceVersionId(); |
| | | if (name == null || mac == null || monitorPointId == null || versionId == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | //判断mac是否已存在 |
| | | QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac", device.getMac()); |
| | | if (deviceService.getOne(queryWrapper) != null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); |
| | | } |
| | | deviceService.insert(device); |
| | | return ResultMessage.ok(); |
| | | } |
| | |
| | | }) |
| | | @RequestMapping(value = "delete", method = RequestMethod.GET) |
| | | public ResultMessage delete(Integer deviceId) { |
| | | if (deviceId == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | deviceService.delete(deviceId); |
| | | return ResultMessage.ok(); |
| | | } |
| | |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "update", method = RequestMethod.POST) |
| | | public ResultMessage update(Device device) { |
| | | public ResultMessage update(@RequestBody Device device) { |
| | | if (device.getId() == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | if (device.getMac() != null) { |
| | | //判断mac是否已存在 |
| | | QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac", device.getMac()); |
| | | if (deviceService.getOne(queryWrapper) != null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); |
| | | } |
| | | } |
| | | 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 = "page", value = "当前页", required = false, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "int"), |
| | | @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); |
| | | @RequestMapping(value = "select", method = RequestMethod.GET) |
| | | public ResultMessage select(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | Map<String, Object> result = deviceService.selectDevices(parameters); |
| | | return ResultMessage.ok(result); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "型号列表", notes = "型号列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "versions", method = RequestMethod.GET) |
| | | public ResultMessage selectVersions() { |
| | | return null; |
| | | QueryWrapper<Version> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("id", "name").eq("is_delete", Constants.NOT_DELETE); |
| | | List<Map<String, Object>> maps = versionService.listMaps(queryWrapper); |
| | | return ResultMessage.ok(maps); |
| | | } |
| | | |
| | | @ApiOperation(value = "维护人列表", notes = "维护人列表") |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.moral.api.entity.Device; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | |
| | | List<Map<String, Object>> selectDevicesByMpId(Integer orgId); |
| | | |
| | | //分页获取所有设备列表 |
| | | IPage<Device> selectDevices(Map<String, Object> parameters); |
| | | Map<String, Object> selectDevices(Map<String, Object> parameters); |
| | | |
| | | //根据设备id查询设备组织,站点,维护人,行业,工艺,设备检测器,采购商等信息 |
| | | Map<String, Object> selectDeviceInfoById(Integer deviceId); |
| | |
| | | |
| | | 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.pojo.vo.device.DeviceVO; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.redis.RedisUtil; |
| | | import com.moral.util.ConvertUtils; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import java.beans.PropertyDescriptor; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Autowired |
| | | private SysDictDataMapper sysDictDataMapper; |
| | | |
| | | @Autowired |
| | | private LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void insert(Device device) { |
| | | Integer orgId = monitorPointMapper.selectById(device.getMonitorPointId()).getOrganizationId(); |
| | | device.setOrganizationId(orgId); |
| | | deviceMapper.insert(device); |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId()); |
| | | //新增设备信息存入redis |
| | | RedisUtil.set("device_" + device.getMac(), deviceInfo); |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了设备:").append(device.getName()).append(";").append("mac:").append(device.getMac()); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", deviceId).set("is_delete", Constants.DELETE); |
| | | deviceMapper.update(null, updateWrapper); |
| | | String mac = deviceMapper.selectById(deviceId).getMac(); |
| | | Device device = deviceMapper.selectById(deviceId); |
| | | String mac = device.getMac(); |
| | | //清除redis |
| | | RedisUtil.del("device_" + mac); |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了设备:").append(device.getName()).append(";").append("mac:").append(mac); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void update(Device device) { |
| | | Integer deviceId = device.getId(); |
| | | Device oldDevice = deviceMapper.selectById(deviceId); |
| | | deviceMapper.updateById(device); |
| | | String mac = deviceMapper.selectById(deviceId).getMac(); |
| | | //更新redis |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId()); |
| | | RedisUtil.set("device_" + deviceInfo.get("mac"), deviceInfo); |
| | | RedisUtil.del("device_" + mac); |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(deviceId); |
| | | RedisUtil.set("device_" + mac, deviceInfo); |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("修改了设备:").append(mac).append(":"); |
| | | Field[] fields = Device.class.getDeclaredFields(); |
| | | for (Field field : fields) { |
| | | if (field.getName().equals("id")) { |
| | | continue; |
| | | } |
| | | if ("serialVersionUID".equals(field.getName())) { |
| | | continue; |
| | | } |
| | | String fieldName = field.getName(); |
| | | PropertyDescriptor pd = null; |
| | | try { |
| | | pd = new PropertyDescriptor(fieldName, Device.class); |
| | | Method method = pd.getReadMethod(); |
| | | Object o1 = method.invoke(oldDevice); |
| | | Object o2 = method.invoke(device); |
| | | if (o2 != null) { |
| | | content.append(fieldName).append(":").append(o1).append("-->").append(o2).append(";"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<Device> selectDevices(Map<String, Object> parameters) { |
| | | public Map<String, Object> selectDevices(Map<String, Object> parameters) { |
| | | QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); |
| | | Integer page = (Integer) parameters.get("page"); |
| | | Integer size = (Integer) parameters.get("size"); |
| | | int page = Integer.parseInt(parameters.get("page").toString()); |
| | | int size = Integer.parseInt(parameters.get("size").toString()); |
| | | Object order = parameters.get("order"); |
| | | Object orderType = parameters.get("orderType"); |
| | | Object name = parameters.get("name"); |
| | |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | Page<Device> devicePage = new Page<>(page, size); |
| | | deviceMapper.selectPage(devicePage, queryWrapper); |
| | | return devicePage; |
| | | List<Device> devices = devicePage.getRecords(); |
| | | List<Map<String, Object>> items = new ArrayList<>(); |
| | | for (Device device : devices) { |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId()); |
| | | items.add(deviceInfo); |
| | | } |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("total", devicePage.getTotal()); |
| | | result.put("totalPage", devicePage.getPages()); |
| | | result.put("current", devicePage.getCurrent()); |
| | | result.put("pageSize", devicePage.getSize()); |
| | | result.put("item", items); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<String, Object> selectDeviceInfoById(Integer deviceId) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | String mac = deviceMapper.selectById(deviceId).getMac(); |
| | | Map<String, Object> deviceInfo = (Map<String, Object>) RedisUtil.get("device_" + mac); |
| | | //先从redis中取 |
| | | if (deviceInfo != null) { |
| | | return deviceInfo; |
| | | } |
| | | deviceInfo = 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())); |
| | | deviceInfo.put("id", device.getId()); |
| | | deviceInfo.put("name", device.getName()); |
| | | deviceInfo.put("mac", device.getMac()); |
| | | deviceInfo.put("address", device.getAddress()); |
| | | deviceInfo.put("longitude", device.getLongitude()); |
| | | deviceInfo.put("latitude", device.getLatitude()); |
| | | deviceInfo.put("createTime", DateUtils.dateToDateString(device.getCreateTime())); |
| | | deviceInfo.put("installTime", device.getInstallTime() == null ? null : DateUtils.dateToDateString(device.getInstallTime())); |
| | | |
| | | //行业 |
| | | result.put("profession", device.getProfession()); |
| | | result.put("professionName", device.getProfessionName()); |
| | | deviceInfo.put("profession", device.getProfession()); |
| | | deviceInfo.put("professionName", device.getProfessionName()); |
| | | |
| | | //工艺 |
| | | result.put("tech", device.getTech()); |
| | | result.put("techName", device.getTechName()); |
| | | deviceInfo.put("tech", device.getTech()); |
| | | deviceInfo.put("techName", device.getTechName()); |
| | | |
| | | //检测器 |
| | | result.put("detector", device.getDetector()); |
| | | result.put("detectorName", device.getDetectorName()); |
| | | deviceInfo.put("detector", device.getDetector()); |
| | | deviceInfo.put("detectorName", device.getDetectorName()); |
| | | |
| | | //采购商 |
| | | result.put("purchaser", device.getPurchaser()); |
| | | result.put("purchaserName", device.getPurchaserName()); |
| | | deviceInfo.put("purchaser", device.getPurchaser()); |
| | | deviceInfo.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); |
| | | deviceInfo.put("version", versionInfo); |
| | | |
| | | //维护人 |
| | | List<Map<String, Object>> operatorsInfo = new ArrayList<>(); |
| | |
| | | operatorMap.put("name", operator.getUserName()); |
| | | operatorsInfo.add(operatorMap); |
| | | } |
| | | result.put("operators", operatorsInfo); |
| | | deviceInfo.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); |
| | | deviceInfo.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; |
| | | deviceInfo.put("monitorPoint", mpInfo); |
| | | RedisUtil.set("device_" + mac, deviceInfo); |
| | | return deviceInfo; |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<Sensor> wrapper = new QueryWrapper(); |
| | | wrapper.eq("is_delete",0); |
| | | int totleNum = sensorMapper.selectCount(wrapper); |
| | | String orderType = map.get("orderType").toString(); |
| | | if (orderType.equals(Constants.ORDER_ASC)){ |
| | | wrapper.orderByAsc("create_time"); |
| | | }else { |
| | | wrapper.orderByDesc("create_time"); |
| | | if (!ObjectUtils.isEmpty(map.get("orderType"))){ |
| | | String orderType = map.get("orderType").toString(); |
| | | if (orderType.equals(Constants.ORDER_DESC)){ |
| | | wrapper.orderByDesc("create_time"); |
| | | }else { |
| | | wrapper.orderByAsc("create_time"); |
| | | } |
| | | } |
| | | Page resultPage = sensorMapper.selectPage(page,wrapper); |
| | | List<Sensor> sensors = resultPage.getRecords(); |
| | |
| | | wrapper_VSU.eq("is_delete",0); |
| | | wrapper_VSU.eq("dataKey",sensor.getDefaultUnitKey()); |
| | | wrapper_VSU.eq("dict_type_id",14); |
| | | sensorMap.put("default_unit_key",sysDictDataMapper.selectOne(wrapper_VSU).getDataValue()); |
| | | if (!ObjectUtils.isEmpty(sysDictDataMapper.selectOne(wrapper_VSU))&&!ObjectUtils.isEmpty(sysDictDataMapper.selectOne(wrapper_VSU).getDataValue())){ |
| | | sensorMap.put("default_unit_key",sysDictDataMapper.selectOne(wrapper_VSU).getDataValue()); |
| | | } |
| | | } |
| | | sensorList.add(sensorMap); |
| | | } |
| | |
| | | d.detector, |
| | | d.purchaser, |
| | | d.create_time, |
| | | d.install_time, |
| | | d.extend, |
| | | o.id org_id, |
| | | o.`name` org_name, |
| | |
| | | code = #{code}, |
| | | </if> |
| | | <if test="upper != null"> |
| | | upper = #{upper}, |
| | | <if test="upper == ''"> |
| | | upper = null, |
| | | </if> |
| | | <if test="upper != ''"> |
| | | upper = #{upper}, |
| | | </if> |
| | | </if> |
| | | <if test="lower != null"> |
| | | lower = #{lower}, |
| | | <if test="lower == ''"> |
| | | lower = null, |
| | | </if> |
| | | <if test="lower != ''"> |
| | | lower = #{lower}, |
| | | </if> |
| | | </if> |
| | | <if test="default_unit_key != null"> |
| | | default_unit_key = #{default_unit_key}, |