7 files added
	
		
		17 files modified
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  | import com.moral.util.PageResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"组"}) | 
|---|
|  |  |  | @Api(tags = {"组管理"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/group") | 
|---|
|  |  |  | public class GroupController { | 
|---|
|  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/log") | 
|---|
|  |  |  | @Api(tags = "日志") | 
|---|
|  |  |  | @Api(tags = "日志管理") | 
|---|
|  |  |  | public class LogController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"菜单"}) | 
|---|
|  |  |  | @Api(tags = {"菜单管理"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/menu") | 
|---|
|  |  |  | public class MenuController { | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.moral.util.PageResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"用户"}) | 
|---|
|  |  |  | @Api(tags = {"用户管理"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/user") | 
|---|
|  |  |  | public class UserController { | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 渠道 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Integer channel; | 
|---|
|  |  |  | private String channelKey; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 组织Id | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.moral.api.entity; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableField; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonIgnore; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonProperty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  | Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization"); | 
|---|
|  |  |  | UpdateWrapper<GroupMenu> deleteWrapper = new UpdateWrapper<>(); | 
|---|
|  |  |  | deleteWrapper.eq("group_id", groupId).eq("channel", Constants.WEB_CHANNEL); | 
|---|
|  |  |  | deleteWrapper.eq("group_id", groupId).eq("channel_key", Constants.WEB_CHANNEL); | 
|---|
|  |  |  | groupMenuMapper.delete(deleteWrapper); | 
|---|
|  |  |  | List<String> menus = new ArrayList<>(); | 
|---|
|  |  |  | if (menuIds != null && !menuIds.isEmpty()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | GroupMenu groupMenu = new GroupMenu(); | 
|---|
|  |  |  | groupMenu.setGroupId(groupId); | 
|---|
|  |  |  | groupMenu.setMenuId(menuId); | 
|---|
|  |  |  | groupMenu.setChannel(Constants.WEB_CHANNEL); | 
|---|
|  |  |  | groupMenu.setChannelKey(Constants.WEB_CHANNEL); | 
|---|
|  |  |  | groupMenu.setOrganizationId((Integer) orgInfo.get("id")); | 
|---|
|  |  |  | groupMenuMapper.insert(groupMenu); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 
|---|
|  |  |  | <id column="id" property="id" /> | 
|---|
|  |  |  | <result column="group_id" property="groupId" /> | 
|---|
|  |  |  | <result column="menu_id" property="menuId" /> | 
|---|
|  |  |  | <result column="channel" property="channel" /> | 
|---|
|  |  |  | <result column="channel_key" property="channelKey" /> | 
|---|
|  |  |  | <result column="organization_id" property="organizationId" /> | 
|---|
|  |  |  | <result column="create_time" property="createTime" /> | 
|---|
|  |  |  | <result column="update_time" property="updateTime" /> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectUserMenu" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | <include refid="Base_Column_List"/> | 
|---|
|  |  |  | FROM `user_group` ug,`group_menu` gm,`menu` m | 
|---|
|  |  |  | WHERE ug.user_id = #{userId} | 
|---|
|  |  |  | AND ug.group_id = gm.group_id | 
|---|
|  |  |  | AND gm.menu_id = m.id | 
|---|
|  |  |  | AND ug.is_delete = 0 | 
|---|
|  |  |  | AND gm.is_delete = 0 | 
|---|
|  |  |  | AND gm.channel = 1 | 
|---|
|  |  |  | AND gm.channel_key = 1 | 
|---|
|  |  |  | AND m.is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectOrganizationMenu" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | <include refid="Base_Column_List"/> | 
|---|
|  |  |  | FROM `menu` m, `organization_menu` om | 
|---|
|  |  |  | WHERE om.organization_id = #{orgId} | 
|---|
|  |  |  | AND m.id = om.menu_id | 
|---|
|  |  |  | AND om.channel = 1 | 
|---|
|  |  |  | AND om.channel_key = 1 | 
|---|
|  |  |  | AND om.menu_id = m.id | 
|---|
|  |  |  | AND om.is_delete = 0 | 
|---|
|  |  |  | AND m.is_delete = 0 | 
|---|
|  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 网页端渠道 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | public static final Integer WEB_CHANNEL = 1; | 
|---|
|  |  |  | public static final String WEB_CHANNEL = "1"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 登陆操作类型 | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMethod; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.moral.api.entity.ManageAccount; | 
|---|
|  |  |  | import com.moral.api.entity.Organization; | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.device.DeviceVO; | 
|---|
|  |  |  | import com.moral.api.service.DeviceService; | 
|---|
|  |  |  | import com.moral.api.service.OrganizationService; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.PageResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"设备管理"}) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping(value = "/device") | 
|---|
|  |  |  | public class DeviceController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceService deviceService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrganizationService organizationService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加设备", notes = "添加设备") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "insert", method = RequestMethod.POST) | 
|---|
|  |  |  | public ResultMessage insert(@RequestBody Device device) { | 
|---|
|  |  |  | deviceService.insert(device); | 
|---|
|  |  |  | return ResultMessage.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "维护人列表", notes = "维护人列表") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "operators", method = RequestMethod.GET) | 
|---|
|  |  |  | public ResultMessage selectOperators() { | 
|---|
|  |  |  | List<ManageAccount> operators = deviceService.selectAllOperator(); | 
|---|
|  |  |  | return ResultMessage.ok(operators); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "型号列表", notes = "型号列表") | 
|---|
|  |  |  | @RequestMapping(value = "versions", method = RequestMethod.GET) | 
|---|
|  |  |  | public ResultMessage selectVersions() { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "组织列表", notes = "组织列表") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @RequestMapping(value = "organizations", method = RequestMethod.GET) | 
|---|
|  |  |  | public ResultMessage selectOrganizations() { | 
|---|
|  |  |  | List<Organization> organizations = deviceService.selectAllOrganization(); | 
|---|
|  |  |  | return ResultMessage.ok(organizations); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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 = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", defaultValue = "0", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "organizationName", value = "组织模糊查询", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "monitorPointName", value = "站点模糊查询", required = false, paramType = "query", dataType = "String"), | 
|---|
|  |  |  | @ApiImplicitParam(name = "deviceName", 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) { | 
|---|
|  |  |  | Page<DeviceVO> userPage = deviceService.selectDevices(parameters); | 
|---|
|  |  |  | PageResult<DeviceVO> pageResult = new PageResult<>( | 
|---|
|  |  |  | userPage.getTotal(), userPage.getPages(), userPage.getRecords() | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return ResultMessage.ok(pageResult); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.entity; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | * 设备表 | 
|---|
|  |  |  | * </p> | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author moral | 
|---|
|  |  |  | * @since 2021-05-11 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @EqualsAndHashCode(callSuper = false) | 
|---|
|  |  |  | public class Device extends Model<Device> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final long serialVersionUID = 1L; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 主键id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @TableId(value = "id", type = IdType.AUTO) | 
|---|
|  |  |  | private Integer id; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备名称 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String name; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * mac号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String mac; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备地址 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String address; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 经度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Double longitude; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 纬度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Double latitude; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备状态,与字典表关联 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String state; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 维护人id,多个逗号隔开,来源于manage_account | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String operateIds; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 站点id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Integer monitorPointId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 组织id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Integer organizationId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备型号id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Integer deviceVersionId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 行业,与字典表关联 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String profession; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备工艺,1:烟道;2:厂界;3:车间,基本数据在字典表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String tech; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备检测器,与字典表关联 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String detector; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 采购商,与字典表关联 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String purchaser; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建(生产)时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 安装时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date installTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 逻辑删除,0:不删除;1:删除 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String isDelete; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备工艺扩展字段 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String extend; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | protected Serializable pkVal() { | 
|---|
|  |  |  | return this.id; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableName; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableName; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private Integer menuId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 渠道字典键 | 
|---|
|  |  |  | * 渠道 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String channelKey; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonProperty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 密码 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) | 
|---|
|  |  |  | private String password; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 创建时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date updateTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 过期时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date expireTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.IdType; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.activerecord.Model; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.annotation.TableId; | 
|---|
|  |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.Serializable; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 操作时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
|---|
|  |  |  | private Date createTime; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.mapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.ibatis.annotations.Param; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.device.DeviceVO; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | * 设备表 Mapper 接口 | 
|---|
|  |  |  | * </p> | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author moral | 
|---|
|  |  |  | * @since 2021-05-11 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface DeviceMapper extends BaseMapper<Device> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<DeviceVO> selectAllDeviceInfo(Page<DeviceVO> page, @Param("ew") QueryWrapper<DeviceVO> queryWrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.pojo.vo.device; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.moral.api.entity.ManageAccount; | 
|---|
|  |  |  | import com.moral.api.entity.Organization; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @EqualsAndHashCode(callSuper = false) | 
|---|
|  |  |  | public class DeviceVO extends Device { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 行业 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | private String professionName; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 组织 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | private Organization organization; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 维护人 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | private List<ManageAccount> operators; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.IService; | 
|---|
|  |  |  | import com.moral.api.entity.ManageAccount; | 
|---|
|  |  |  | import com.moral.api.entity.Organization; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.device.DeviceVO; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | * 设备表 服务类 | 
|---|
|  |  |  | * </p> | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author moral | 
|---|
|  |  |  | * @since 2021-05-11 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface DeviceService extends IService<Device> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void insert(Device device); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<ManageAccount> selectAllOperator(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Organization> selectAllOrganization(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<DeviceVO> selectDevices(Map<String, Object> parameters); | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.moral.api.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.moral.api.entity.ManageAccount; | 
|---|
|  |  |  | import com.moral.api.entity.Organization; | 
|---|
|  |  |  | import com.moral.api.entity.User; | 
|---|
|  |  |  | import com.moral.api.mapper.DeviceMapper; | 
|---|
|  |  |  | import com.moral.api.mapper.ManageAccountMapper; | 
|---|
|  |  |  | import com.moral.api.mapper.OrganizationMapper; | 
|---|
|  |  |  | 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.constant.Constants; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | * 设备表 服务实现类 | 
|---|
|  |  |  | * </p> | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author moral | 
|---|
|  |  |  | * @since 2021-05-11 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements DeviceService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceMapper deviceMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ManageAccountMapper manageAccountMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrganizationMapper organizationMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void insert(Device device) { | 
|---|
|  |  |  | deviceMapper.insert(device); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<ManageAccount> selectAllOperator() { | 
|---|
|  |  |  | QueryWrapper<ManageAccount> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.select("id", "user_name").eq("is_delete", Constants.NOT_DELETE); | 
|---|
|  |  |  | return manageAccountMapper.selectList(queryWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Organization> selectAllOrganization() { | 
|---|
|  |  |  | QueryWrapper<Organization> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.select("id", "name").ge("expire_time", new Date()).eq("is_delete", Constants.NOT_DELETE); | 
|---|
|  |  |  | return organizationMapper.selectList(queryWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Page<DeviceVO> selectDevices(Map<String, Object> parameters) { | 
|---|
|  |  |  | QueryWrapper<DeviceVO> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | Integer page = (Integer) parameters.get("page"); | 
|---|
|  |  |  | Integer size = (Integer) parameters.get("size"); | 
|---|
|  |  |  | Page<DeviceVO> pageData = new Page<>(page, size); | 
|---|
|  |  |  | deviceMapper.selectAllDeviceInfo(pageData, queryWrapper); | 
|---|
|  |  |  | return pageData; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | <?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.moral.api.mapper.DeviceMapper"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 通用查询映射结果 --> | 
|---|
|  |  |  | <resultMap id="BaseResultMap" type="com.moral.api.entity.Device"> | 
|---|
|  |  |  | <id column="id" property="id"/> | 
|---|
|  |  |  | <result column="name" property="name"/> | 
|---|
|  |  |  | <result column="mac" property="mac"/> | 
|---|
|  |  |  | <result column="address" property="address"/> | 
|---|
|  |  |  | <result column="longitude" property="longitude"/> | 
|---|
|  |  |  | <result column="latitude" property="latitude"/> | 
|---|
|  |  |  | <result column="state" property="state"/> | 
|---|
|  |  |  | <result column="operate_ids" property="operateIds"/> | 
|---|
|  |  |  | <result column="monitor_point_id" property="monitorPointId"/> | 
|---|
|  |  |  | <result column="organization_id" property="organizationId"/> | 
|---|
|  |  |  | <result column="device_version_id" property="deviceVersionId"/> | 
|---|
|  |  |  | <result column="profession" property="profession"/> | 
|---|
|  |  |  | <result column="tech" property="tech"/> | 
|---|
|  |  |  | <result column="detector" property="detector"/> | 
|---|
|  |  |  | <result column="purchaser" property="purchaser"/> | 
|---|
|  |  |  | <result column="create_time" property="createTime"/> | 
|---|
|  |  |  | <result column="update_time" property="updateTime"/> | 
|---|
|  |  |  | <result column="install_time" property="installTime"/> | 
|---|
|  |  |  | <result column="is_delete" property="isDelete"/> | 
|---|
|  |  |  | <result column="extend" property="extend"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <resultMap id="resultMap" type="com.moral.api.pojo.vo.device.DeviceVO" extends="BaseResultMap"> | 
|---|
|  |  |  | <result column="profession_name" property="professionName"/> | 
|---|
|  |  |  | <association property="organization" javaType="com.moral.api.entity.Organization"> | 
|---|
|  |  |  | <result column="org_id" property="id"/> | 
|---|
|  |  |  | <result column="org_name" property="name"/> | 
|---|
|  |  |  | </association> | 
|---|
|  |  |  | <!--设备维护人--> | 
|---|
|  |  |  | <collection property="operators" ofType="com.moral.api.entity.ManageAccount"> | 
|---|
|  |  |  | <id column="operate_id" property="id" jdbcType="INTEGER"/> | 
|---|
|  |  |  | <result column="operate_name" property="userName" jdbcType="VARCHAR"/> | 
|---|
|  |  |  | </collection> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectAllDeviceInfo" resultMap="resultMap"> | 
|---|
|  |  |  | SELECT d.id, | 
|---|
|  |  |  | d.`name`, | 
|---|
|  |  |  | d.mac, | 
|---|
|  |  |  | d.address, | 
|---|
|  |  |  | d.longitude, | 
|---|
|  |  |  | d.latitude, | 
|---|
|  |  |  | d.operate_ids, | 
|---|
|  |  |  | d.organization_id, | 
|---|
|  |  |  | d.monitor_point_id, | 
|---|
|  |  |  | d.organization_id, | 
|---|
|  |  |  | d.device_version_id, | 
|---|
|  |  |  | d.profession profession, | 
|---|
|  |  |  | o.id org_id, | 
|---|
|  |  |  | o.`name` org_name, | 
|---|
|  |  |  | ma.id operate_id, | 
|---|
|  |  |  | ma.user_name operate_name, | 
|---|
|  |  |  | sd.dataValue profession_name | 
|---|
|  |  |  | FROM `device` d | 
|---|
|  |  |  | LEFT JOIN `organization` o | 
|---|
|  |  |  | ON d.organization_id = o.id | 
|---|
|  |  |  | LEFT JOIN `manage_account` ma | 
|---|
|  |  |  | ON FIND_IN_SET( | 
|---|
|  |  |  | ma.id, (SELECT operate_ids FROM device) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | LEFT JOIN | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | SELECT sdt.`name`, sdd.dataKey, sdd.dataValue | 
|---|
|  |  |  | FROM sys_dict_type sdt, | 
|---|
|  |  |  | sys_dict_data sdd | 
|---|
|  |  |  | WHERE sdt.id = sdd.dict_type_id | 
|---|
|  |  |  | ) sd | 
|---|
|  |  |  | on sd.`name` = 'profession' | 
|---|
|  |  |  | and d.profession = sd.dataKey | 
|---|
|  |  |  | AND d.is_delete = 0 | 
|---|
|  |  |  | ${ew.customSqlSegment} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </mapper> | 
|---|
|  |  |  | 
|---|
|  |  |  | <id column="id" property="id" /> | 
|---|
|  |  |  | <result column="group_id" property="groupId" /> | 
|---|
|  |  |  | <result column="menu_id" property="menuId" /> | 
|---|
|  |  |  | <result column="channel" property="channel" /> | 
|---|
|  |  |  | <result column="channel_key" property="channelKey"/> | 
|---|
|  |  |  | <result column="organization_id" property="organizationId" /> | 
|---|
|  |  |  | <result column="create_time" property="createTime" /> | 
|---|
|  |  |  | <result column="update_time" property="updateTime" /> | 
|---|