forked from dyf/fys-Multi-tenant
Merge branch 'dyf-device'
This commit is contained in:
@ -65,6 +65,12 @@
|
|||||||
<artifactId>fys-common-mail</artifactId>
|
<artifactId>fys-common-mail</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 客户管理模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-customer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 设备管理模块 -->
|
<!-- 设备管理模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
@ -157,6 +157,11 @@ public class SysLoginService {
|
|||||||
loginUser.setUsername(user.getUserName());
|
loginUser.setUsername(user.getUserName());
|
||||||
loginUser.setNickname(user.getNickName());
|
loginUser.setNickname(user.getNickName());
|
||||||
loginUser.setUserType(user.getUserType());
|
loginUser.setUserType(user.getUserType());
|
||||||
|
// 用户级别
|
||||||
|
loginUser.setUserLevel(user.getUserLevel());
|
||||||
|
// pid
|
||||||
|
loginUser.setPid(user.getPid());
|
||||||
|
|
||||||
loginUser.setMenuPermission(permissionService.getMenuPermission(userId));
|
loginUser.setMenuPermission(permissionService.getMenuPermission(userId));
|
||||||
loginUser.setRolePermission(permissionService.getRolePermission(userId));
|
loginUser.setRolePermission(permissionService.getRolePermission(userId));
|
||||||
if (ObjectUtil.isNotNull(user.getDeptId())) {
|
if (ObjectUtil.isNotNull(user.getDeptId())) {
|
||||||
@ -242,7 +247,7 @@ public class SysLoginService {
|
|||||||
log.info("登录租户:{} 已被停用.", tenantId);
|
log.info("登录租户:{} 已被停用.", tenantId);
|
||||||
throw new TenantException("tenant.blocked");
|
throw new TenantException("tenant.blocked");
|
||||||
} else if (ObjectUtil.isNotNull(tenant.getExpireTime())
|
} else if (ObjectUtil.isNotNull(tenant.getExpireTime())
|
||||||
&& new Date().after(tenant.getExpireTime())) {
|
&& new Date().after(tenant.getExpireTime())) {
|
||||||
log.info("登录租户:{} 已超过有效期.", tenantId);
|
log.info("登录租户:{} 已超过有效期.", tenantId);
|
||||||
throw new TenantException("tenant.expired");
|
throw new TenantException("tenant.expired");
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ logging:
|
|||||||
org.springframework: warn
|
org.springframework: warn
|
||||||
org.mybatis.spring.mapper: error
|
org.mybatis.spring.mapper: error
|
||||||
org.apache.fury: warn
|
org.apache.fury: warn
|
||||||
|
com.fuyuanshen.web.service.impl.ClientServiceImpl: debug
|
||||||
config: classpath:logback-plus.xml
|
config: classpath:logback-plus.xml
|
||||||
|
|
||||||
# 用户配置
|
# 用户配置
|
||||||
@ -135,7 +136,7 @@ tenant:
|
|||||||
# https://baomidou.com/config/
|
# https://baomidou.com/config/
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
# 自定义配置 是否全局开启逻辑删除 关闭后 所有逻辑删除功能将失效
|
# 自定义配置 是否全局开启逻辑删除 关闭后 所有逻辑删除功能将失效
|
||||||
enableLogicDelete: true
|
enableLogicDelete: false
|
||||||
# 多包名使用 例如 com.fuyuanshen.**.mapper,org.xxx.**.mapper
|
# 多包名使用 例如 com.fuyuanshen.**.mapper,org.xxx.**.mapper
|
||||||
mapperPackage: com.fuyuanshen.**.mapper
|
mapperPackage: com.fuyuanshen.**.mapper
|
||||||
# 对应的 XML 文件位置
|
# 对应的 XML 文件位置
|
||||||
@ -213,6 +214,8 @@ springdoc:
|
|||||||
packages-to-scan: com.fuyuanshen.workflow
|
packages-to-scan: com.fuyuanshen.workflow
|
||||||
- group: 设备管理模块
|
- group: 设备管理模块
|
||||||
packages-to-scan: com.fuyuanshen.equipment
|
packages-to-scan: com.fuyuanshen.equipment
|
||||||
|
- group: 客户管理模块
|
||||||
|
packages-to-scan: com.fuyuanshen.customer
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
xss:
|
xss:
|
||||||
|
@ -22,6 +22,11 @@ public interface TenantConstants {
|
|||||||
*/
|
*/
|
||||||
String TENANT_ADMIN_ROLE_KEY = "admin";
|
String TENANT_ADMIN_ROLE_KEY = "admin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 富源晟内部员工 roleKey
|
||||||
|
*/
|
||||||
|
String FYS_ROLE_KEY = "fel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户管理员角色名称
|
* 租户管理员角色名称
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PageResult<T> implements Serializable {
|
public class PageResult<T> implements Serializable {
|
||||||
|
|
||||||
private List<T> content;
|
private List<T> rows;
|
||||||
|
|
||||||
private long totalElements;
|
private long total;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.fuyuanshen.common.core.domain.model;
|
package com.fuyuanshen.common.core.domain.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import com.fuyuanshen.common.core.domain.dto.PostDTO;
|
import com.fuyuanshen.common.core.domain.dto.PostDTO;
|
||||||
@ -31,6 +32,7 @@ public class LoginUser implements Serializable {
|
|||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
@ -132,6 +134,11 @@ public class LoginUser implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户等级
|
||||||
|
*/
|
||||||
|
private Byte userLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录id
|
* 获取登录id
|
||||||
*/
|
*/
|
||||||
|
@ -39,8 +39,8 @@ public class EncryptUtilsTest {
|
|||||||
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
|
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
|
||||||
loginBody.setGrantType("password");
|
loginBody.setGrantType("password");
|
||||||
loginBody.setTenantId("894078");
|
loginBody.setTenantId("894078");
|
||||||
loginBody.setCode("21");
|
loginBody.setCode("0");
|
||||||
loginBody.setUuid("39785885a3ef42d59501502848cd1dcb");
|
loginBody.setUuid("1c285b27f516486f9535face77023aeb");
|
||||||
// loginBody.setUsername("admin");
|
// loginBody.setUsername("admin");
|
||||||
// loginBody.setPassword("admin123");
|
// loginBody.setPassword("admin123");
|
||||||
loginBody.setUsername("dyf");
|
loginBody.setUsername("dyf");
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
package com.fuyuanshen.app.controller.equipment;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
|
import com.fuyuanshen.app.domain.APPDeviceType;
|
||||||
|
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||||
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
|
import com.fuyuanshen.app.service.equipment.APPDeviceService;
|
||||||
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
|
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/16
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Tag(name = "APP:客户设备管理", description = "APP:客户设备管理")
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/api/app/device")
|
||||||
|
public class APPDeviceController {
|
||||||
|
|
||||||
|
private final APPDeviceService appDeviceService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/list")
|
||||||
|
@Operation(summary = "APP客户设备列表")
|
||||||
|
public ResponseVO<PageResult<APPDevice>> appDeviceList(@RequestBody APPDeviceQueryCriteria criteria) {
|
||||||
|
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
PageResult<APPDevice> devices = null;
|
||||||
|
try {
|
||||||
|
devices = appDeviceService.appDeviceList(page, criteria);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("queryDevice error: " + e.getMessage());
|
||||||
|
return ResponseVO.fail("");
|
||||||
|
}
|
||||||
|
return ResponseVO.success(devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/typeList")
|
||||||
|
@Operation(summary = "APP客户设备类型列表")
|
||||||
|
public ResponseVO<List<APPDeviceType>> appTypeList(@RequestBody APPDeviceQueryCriteria criteria) {
|
||||||
|
List<APPDeviceType> typeList = appDeviceService.appTypeList(criteria);
|
||||||
|
return ResponseVO.success(typeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/bind")
|
||||||
|
@Operation(summary = "APP客户设备绑定")
|
||||||
|
public ResponseVO<String> appBindDevice(@RequestBody APPDeviceQueryCriteria criteria) {
|
||||||
|
appDeviceService.appBindDevice(criteria);
|
||||||
|
return ResponseVO.success("绑定成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@Operation(summary = "WEB端查看APP客户设备绑定")
|
||||||
|
public ResponseVO<PageResult<APPDevice>> queryAPPDevice(APPDeviceQueryCriteria criteria) {
|
||||||
|
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
PageResult<APPDevice> devices = null;
|
||||||
|
try {
|
||||||
|
devices = appDeviceService.queryAll(page, criteria);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("queryDevice error: " + e.getMessage());
|
||||||
|
return ResponseVO.fail("");
|
||||||
|
}
|
||||||
|
return ResponseVO.success(devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/unbind")
|
||||||
|
@Operation(summary = "WEB端APP客户设备解绑")
|
||||||
|
public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
||||||
|
appDeviceService.unbindAPPDevice(deviceForm);
|
||||||
|
return ResponseVO.success("解绑成功!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
package com.fuyuanshen.app.domain;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备表
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/16
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@TableName("app_device")
|
||||||
|
public class APPDevice extends TenantEntity {
|
||||||
|
|
||||||
|
@TableId(value = "app_device_id", type = IdType.AUTO)
|
||||||
|
@Schema(name = "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(name = "设备类型")
|
||||||
|
private Long deviceType;
|
||||||
|
|
||||||
|
@Schema(name = "设备类型名称")
|
||||||
|
private String deviceTypeName;
|
||||||
|
|
||||||
|
@Schema(name = "客户号")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(name = "所属客户")
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
|
/*@Schema(name = "设备编号")
|
||||||
|
private String deviceNo;*/
|
||||||
|
|
||||||
|
@Schema(name = "设备名称")
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
@Schema(name = "设备图片")
|
||||||
|
private String devicePic;
|
||||||
|
|
||||||
|
@Schema(name = "设备MAC")
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
@Schema(name = "设备IMEI")
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
|
@Schema(name = "设备SN")
|
||||||
|
private String deviceSn;
|
||||||
|
|
||||||
|
@Schema(name = "经度")
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
@Schema(name = "纬度")
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@Schema(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(name = "设备类型名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "tenant_id")
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
* 0 失效
|
||||||
|
* 1 正常
|
||||||
|
*/
|
||||||
|
@Schema(name = "设备状态")
|
||||||
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定状态
|
||||||
|
* 0 未绑定
|
||||||
|
* 1 已绑定
|
||||||
|
*/
|
||||||
|
@Schema(name = "绑定状态")
|
||||||
|
private Integer bindingStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定类型
|
||||||
|
* 0 APP
|
||||||
|
* 1 小程序
|
||||||
|
*/
|
||||||
|
@Schema(name = "绑定类型")
|
||||||
|
private Integer bindingType;
|
||||||
|
|
||||||
|
|
||||||
|
public void copy(APPDevice source) {
|
||||||
|
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.fuyuanshen.app.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备类型
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/14
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@TableName("app_device_type")
|
||||||
|
public class APPDeviceType extends TenantEntity {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
@Schema(name = "ID", hidden = true)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(name = "客户号")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(name = "创建该类型的客户")
|
||||||
|
private Long ownerCustomerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户ID
|
||||||
|
*/
|
||||||
|
// @TableField(value = "tenant_id")
|
||||||
|
// @ApiModelProperty(hidden = true)
|
||||||
|
// private Long tenantId;
|
||||||
|
|
||||||
|
@NotBlank(message = "设备类型名称不能为空")
|
||||||
|
@Schema(name = "类型名称", required = true)
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@Schema(name = "是否支持蓝牙")
|
||||||
|
private Boolean isSupportBle;
|
||||||
|
|
||||||
|
@Schema(name = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
|
||||||
|
private String locateMode;
|
||||||
|
|
||||||
|
@Schema(name = "联网方式", example = "0:无;1:4G;2:WIFI")
|
||||||
|
private String networkWay;
|
||||||
|
|
||||||
|
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
|
private String communicationMode;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.fuyuanshen.app.domain.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-1818:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class APPUnbindDTO {
|
||||||
|
|
||||||
|
// @NotBlank(message = "设备MAC不能为空")
|
||||||
|
@Schema(name = "设备MAC", required = true)
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
@Schema(name = "设备IMEI")
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
|
@NotNull(message = "客户号不能为空")
|
||||||
|
@Schema(name = "客户号")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.fuyuanshen.app.domain.query;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/16
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class APPDeviceQueryCriteria {
|
||||||
|
|
||||||
|
@Schema(name = "设备名称")
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
@Schema(name = "设备类型")
|
||||||
|
private Long deviceType;
|
||||||
|
|
||||||
|
@Schema(name = "设备MAC")
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
@Schema(name = "设备IMEI")
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
|
@Schema(name = "设备SN")
|
||||||
|
private String deviceSn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
* 0 失效
|
||||||
|
* 1 正常
|
||||||
|
*/
|
||||||
|
@Schema(name = "设备状态 0 失效 1 正常 ")
|
||||||
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||||
|
@Schema(name = "创建时间")
|
||||||
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@Schema(name = "页码", example = "1")
|
||||||
|
private Integer page = 1;
|
||||||
|
|
||||||
|
@Schema(name = "每页数据量", example = "10")
|
||||||
|
private Integer size = 10;
|
||||||
|
|
||||||
|
@Schema(name = "客户id")
|
||||||
|
private Long customerId;
|
||||||
|
private Set<Long> customerIds;
|
||||||
|
|
||||||
|
@Schema(name = "当前所有者")
|
||||||
|
private Long currentOwnerId;
|
||||||
|
|
||||||
|
@Schema(name = "租户ID")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
|
private Integer communicationMode;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.fuyuanshen.app.mapper.equipment;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/16
|
||||||
|
**/
|
||||||
|
@Mapper
|
||||||
|
public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<APPDevice> appDeviceList(Page<APPDevice> page,@Param("criteria") APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询APP/小程序设备
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria") APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.fuyuanshen.app.service.equipment;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
|
import com.fuyuanshen.app.domain.APPDeviceType;
|
||||||
|
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||||
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/16
|
||||||
|
**/
|
||||||
|
public interface APPDeviceService extends IService<APPDevice> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
PageResult<APPDevice> appDeviceList(Page<APPDevice> page, APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备类型列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<APPDeviceType> appTypeList(APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP/小程序用户设备绑定
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
void appBindDevice(APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询APP/小程序设备绑定
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageResult<APPDevice> queryAll(Page<APPDevice> page, APPDeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP/小程序用户设备解绑
|
||||||
|
*
|
||||||
|
* @param deviceForm
|
||||||
|
*/
|
||||||
|
void unbindAPPDevice(APPUnbindDTO deviceForm);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
package com.fuyuanshen.app.service.impl.equipment;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fuyuanshen.app.domain.APPDevice;
|
||||||
|
import com.fuyuanshen.app.domain.APPDeviceType;
|
||||||
|
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||||
|
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||||
|
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
|
||||||
|
import com.fuyuanshen.app.service.equipment.APPDeviceService;
|
||||||
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/16
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice> implements APPDeviceService {
|
||||||
|
|
||||||
|
private final APPDeviceMapper appDeviceMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<APPDevice> appDeviceList(Page<APPDevice> page, APPDeviceQueryCriteria criteria) {
|
||||||
|
// criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||||
|
// IPage<APPDevice> devices = appDeviceMapper.appDeviceList(page, criteria);
|
||||||
|
// return new PageResult<>(devices.getRecords(), devices.getTotal());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备类型列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<APPDeviceType> appTypeList(APPDeviceQueryCriteria criteria) {
|
||||||
|
// criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||||
|
// return appDeviceTypeMapper.appTypeList(criteria);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP/小程序用户设备绑定
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void appBindDevice(APPDeviceQueryCriteria criteria) {
|
||||||
|
//
|
||||||
|
// List<Device> devices = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// if (criteria.getCommunicationMode().equals(CommunicationModeEnum.BLUETOOTH.getValue())) {
|
||||||
|
// devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_mac", criteria.getDeviceMac()));
|
||||||
|
// if (CollectionUtil.isEmpty(devices)) {
|
||||||
|
// throw new BadRequestException("请先将设备入库!!!");
|
||||||
|
// }
|
||||||
|
// List<APPDevice> appDevices = appDeviceMapper.selectList(new QueryWrapper<APPDevice>()
|
||||||
|
// .eq("device_mac", criteria.getDeviceMac()).eq("binding_type", UserType.APP.getValue()));
|
||||||
|
// if (CollectionUtil.isNotEmpty(appDevices)) {
|
||||||
|
// throw new BadRequestException("该设备已绑定!!!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (criteria.getCommunicationMode().equals(CommunicationModeEnum.FOUR_G.getValue())) {
|
||||||
|
// devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_imei", criteria.getDeviceImei()));
|
||||||
|
// if (CollectionUtil.isEmpty(devices)) {
|
||||||
|
// throw new BadRequestException("请先将设备入库!!!");
|
||||||
|
// }
|
||||||
|
// List<APPDevice> appDevices = appDeviceMapper.selectList(new QueryWrapper<APPDevice>()
|
||||||
|
// .eq("device_imei", criteria.getDeviceImei()).eq("binding_type", UserType.APP.getValue()));
|
||||||
|
// if (CollectionUtil.isNotEmpty(appDevices)) {
|
||||||
|
// throw new BadRequestException("该设备已绑定!!!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Device device = devices.get(0);
|
||||||
|
// device.setBindingStatus(BindingStatusEnum.BOUND.getCode());
|
||||||
|
// deviceMapper.updateById(device);
|
||||||
|
//
|
||||||
|
// APPDevice appDevice = new APPDevice();
|
||||||
|
// BeanUtil.copyProperties(device, appDevice);
|
||||||
|
// appDevice.setBindingType(UserType.APP.getValue());
|
||||||
|
// appDevice.setBindingStatus(BindingStatusEnum.BOUND.getCode());
|
||||||
|
// Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
// appDevice.setCustomerId(currentUserId);
|
||||||
|
// appDevice.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
// // 设备类型名称
|
||||||
|
// appDevice.setDeviceTypeName(device.getTypeName());
|
||||||
|
// appDeviceMapper.insert(appDevice);
|
||||||
|
//
|
||||||
|
// APPDeviceType appDeviceType = appDeviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
// if (appDeviceType == null) {
|
||||||
|
// DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
// APPDeviceType type = new APPDeviceType();
|
||||||
|
// BeanUtil.copyProperties(deviceType, type);
|
||||||
|
// type.setCustomerId(currentUserId);
|
||||||
|
// appDeviceTypeMapper.insert(type);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询APP/小程序设备
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<APPDevice> queryAll(Page<APPDevice> page, APPDeviceQueryCriteria criteria) {
|
||||||
|
// IPage<APPDevice> devices = appDeviceMapper.queryAll(page, criteria);
|
||||||
|
// return new PageResult<>(devices.getRecords(), devices.getTotal());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP/小程序用户设备解绑
|
||||||
|
*
|
||||||
|
* @param deviceForm
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void unbindAPPDevice(APPUnbindDTO deviceForm) {
|
||||||
|
// QueryWrapper<APPDevice> queryWrapper = new QueryWrapper<>();
|
||||||
|
// QueryWrapper<Device> qw = new QueryWrapper<>();
|
||||||
|
// if (StringUtils.isNotEmpty(deviceForm.getDeviceMac())) {
|
||||||
|
// queryWrapper.eq("device_mac", deviceForm.getDeviceMac());
|
||||||
|
// qw.eq("device_mac", deviceForm.getDeviceMac());
|
||||||
|
// }
|
||||||
|
// if (StringUtils.isNotEmpty(deviceForm.getDeviceImei())) {
|
||||||
|
// queryWrapper.eq("device_imei", deviceForm.getDeviceImei());
|
||||||
|
// qw.eq("device_imei", deviceForm.getDeviceImei());
|
||||||
|
// }
|
||||||
|
// queryWrapper.eq("binding_type", UserType.APP.getValue());
|
||||||
|
// APPDevice appDevice = appDeviceMapper.selectOne(queryWrapper);
|
||||||
|
// appDeviceMapper.delete(queryWrapper);
|
||||||
|
//
|
||||||
|
// List<Device> devices = deviceMapper.selectList(qw);
|
||||||
|
// List<Long> ids = devices.stream()
|
||||||
|
// .map(Device::getId)
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// if (CollectionUtil.isNotEmpty(ids)) {
|
||||||
|
// appDeviceTypeMapper.deleteBatchIds(ids);
|
||||||
|
// }
|
||||||
|
// Device device = new Device();
|
||||||
|
// device.setId(appDevice.getId());
|
||||||
|
// device.setBindingStatus(BindingStatusEnum.UNBOUND.getCode());
|
||||||
|
// deviceMapper.updateById(device);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
<?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.fuyuanshen.app.mapper.equipment.APPDeviceMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.fuyuanshen.app.domain.APPDevice">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="device_type" property="deviceType"/>
|
||||||
|
<result column="customer_id" property="customerId"/>
|
||||||
|
<!--<result column="device_no" property="deviceNo"/>-->
|
||||||
|
<result column="device_name" property="deviceName"/>
|
||||||
|
<result column="device_pic" property="devicePic"/>
|
||||||
|
<result column="device_mac" property="deviceMac"/>
|
||||||
|
<result column="device_sn" property="deviceSn"/>
|
||||||
|
<result column="device_status" property="deviceStatus"/>
|
||||||
|
<result column="remark" property="remark"/>
|
||||||
|
<result column="create_by" property="createBy"/>
|
||||||
|
<result column="update_by" property="updateBy"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="binding_status" property="bindingStatus"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- APP用户设备列表 -->
|
||||||
|
<select id="appDeviceList" resultType="com.fuyuanshen.app.domain.APPDevice">
|
||||||
|
select d.* from app_device as d
|
||||||
|
<where>
|
||||||
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
|
||||||
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
|
||||||
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceSn != null">
|
||||||
|
and d.device_sn = #{criteria.deviceSn}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceType != null">
|
||||||
|
and d.device_type = #{criteria.deviceType}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceStatus != null">
|
||||||
|
and d.device_status = #{criteria.deviceStatus}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.tenantId != null">
|
||||||
|
AND tenant_id = #{criteria.tenantId}
|
||||||
|
</if>
|
||||||
|
and d.customer_id = #{criteria.customerId}
|
||||||
|
</where>
|
||||||
|
order by d.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 分页查询APP/小程序设备 -->
|
||||||
|
<select id="queryAll" resultType="com.fuyuanshen.app.domain.APPDevice">
|
||||||
|
select d.* from app_device as d
|
||||||
|
<where>
|
||||||
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
|
||||||
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
|
||||||
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceSn != null">
|
||||||
|
and d.device_sn = #{criteria.deviceSn}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceType != null">
|
||||||
|
and d.device_type = #{criteria.deviceType}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceStatus != null">
|
||||||
|
and d.device_status = #{criteria.deviceStatus}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.tenantId != null">
|
||||||
|
AND tenant_id = #{criteria.tenantId}
|
||||||
|
</if>
|
||||||
|
and d.customer_id = #{criteria.customerId}
|
||||||
|
</where>
|
||||||
|
order by d.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
117
fys-modules/fys-customer/pom.xml
Normal file
117
fys-modules/fys-customer/pom.xml
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-modules</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>fys-customer</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
富源晟客户管理
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-doc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-mybatis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-translation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OSS功能模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-oss</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SMS功能模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-sms</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-tenant</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-idempotent</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-sensitive</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-encrypt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-common-sse</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.fuyuanshen.customer.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.crypto.digest.BCrypt;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||||
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.customer.domain.Customer;
|
||||||
|
import com.fuyuanshen.customer.domain.query.UserQueryCriteria;
|
||||||
|
import com.fuyuanshen.customer.domain.vo.ConsumerVo;
|
||||||
|
import com.fuyuanshen.customer.service.CustomerService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.undertow.util.BadRequestException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-07-0114:20
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Tag(name = "WEB:客户管理", description = "WEB:客户管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/customers")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CustomerController {
|
||||||
|
|
||||||
|
private final CustomerService customerService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询客户(限制子客户)
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Operation(summary = "分页查询客户")
|
||||||
|
@GetMapping(value = "/customer")
|
||||||
|
public TableDataInfo<ConsumerVo> queryCustomer(UserQueryCriteria criteria) {
|
||||||
|
Page<Customer> page = new Page<>(criteria.getPageNum(), criteria.getPageSize());
|
||||||
|
return customerService.queryCustomers(criteria, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping(value = "/allCustomer")
|
||||||
|
@Operation(summary = "查询所有客户")
|
||||||
|
public ResponseVO<List<Customer>> queryAllCustomer(UserQueryCriteria criteria) {
|
||||||
|
List<Customer> customers = customerService.queryAllCustomers(criteria);
|
||||||
|
return ResponseVO.success(customers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Log("新增客户")
|
||||||
|
@Operation(summary = "新增客户")
|
||||||
|
@PostMapping(value = "/addCustomer")
|
||||||
|
public ResponseVO<Object> addCustomer(@Validated @RequestBody Customer customer) throws BadRequestException {
|
||||||
|
if (StringUtils.isBlank(customer.getPassword())) {
|
||||||
|
throw new BadRequestException("账号密码不能为空");
|
||||||
|
}
|
||||||
|
customer.setPassword(BCrypt.hashpw(customer.getPassword()));
|
||||||
|
customerService.addCustomer(customer);
|
||||||
|
return ResponseVO.success("新增客户成功!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Log("修改客户")
|
||||||
|
@Operation(summary = "修改客户")
|
||||||
|
@PutMapping(value = "updateCustomer")
|
||||||
|
public ResponseVO<Object> updateCustomer(@RequestBody Customer resources) throws Exception {
|
||||||
|
customerService.updateCustomer(resources);
|
||||||
|
return ResponseVO.success(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Log("删除客户")
|
||||||
|
@Operation(summary = "删除客户")
|
||||||
|
@DeleteMapping(value = "/deleteCustomer")
|
||||||
|
public ResponseVO<Object> deleteCustomer(@RequestBody Set<Long> ids) throws BadRequestException {
|
||||||
|
if (CollectionUtil.isEmpty(ids)) {
|
||||||
|
throw new BadRequestException("请选择要删除的客户");
|
||||||
|
}
|
||||||
|
customerService.delete(ids);
|
||||||
|
return ResponseVO.success(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,131 @@
|
|||||||
|
package com.fuyuanshen.customer.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||||
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户对象 sys_user
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_user")
|
||||||
|
public class Customer extends TenantEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "user_id")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父id
|
||||||
|
*/
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
@TableField(value = "user_level")
|
||||||
|
private Byte userLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型(sys_user系统用户)
|
||||||
|
*/
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
*/
|
||||||
|
private String phonenumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户性别
|
||||||
|
*/
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
private Long avatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
@TableField(
|
||||||
|
insertStrategy = FieldStrategy.NOT_EMPTY,
|
||||||
|
updateStrategy = FieldStrategy.NOT_EMPTY,
|
||||||
|
whereStrategy = FieldStrategy.NOT_EMPTY
|
||||||
|
)
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帐号状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标志(0代表存在 1代表删除)
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Schema(name = "是否启用")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后登录IP
|
||||||
|
*/
|
||||||
|
private String loginIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后登录时间
|
||||||
|
*/
|
||||||
|
private Date loginDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
public Customer(Long userId) {
|
||||||
|
this.customerId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSuperAdmin() {
|
||||||
|
return SystemConstants.SUPER_ADMIN_ID.equals(this.customerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2025 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.fuyuanshen.customer.domain.query;
|
||||||
|
|
||||||
|
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2018-11-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserQueryCriteria extends BaseEntity {
|
||||||
|
|
||||||
|
@Schema(name = "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(name = "ids")
|
||||||
|
private Set<Long> ids;
|
||||||
|
|
||||||
|
@Schema(name = "pid")
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
|
@Schema(name = "多个ID")
|
||||||
|
private Set<Long> deptIds = new HashSet<>();
|
||||||
|
|
||||||
|
@Schema(name = "模糊查询")
|
||||||
|
private String blurry;
|
||||||
|
|
||||||
|
@Schema(name = "是否启用")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
@Schema(name = "部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
// @Schema(name = "创建时间")
|
||||||
|
// // private List<Timestamp> createTime;
|
||||||
|
|
||||||
|
@Schema(name = "页码", example = "1")
|
||||||
|
private Integer pageNum = 1;
|
||||||
|
|
||||||
|
@Schema(name = "每页数据量", example = "10")
|
||||||
|
private Integer pageSize = 10;
|
||||||
|
|
||||||
|
@Schema(name = "偏移量", hidden = true)
|
||||||
|
private long offset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型
|
||||||
|
* 0 app
|
||||||
|
* 1 小程序
|
||||||
|
*/
|
||||||
|
@Schema(name = "用户类型 0 app 1 小程序")
|
||||||
|
private Integer userType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号
|
||||||
|
*/
|
||||||
|
@Schema(name = "APP/小程序账号")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户名称
|
||||||
|
*/
|
||||||
|
@Schema(name = "客户名称")
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package com.fuyuanshen.customer.domain.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-1211:34
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ConsumerVo extends TenantEntity {
|
||||||
|
|
||||||
|
@Schema(name = "ID", hidden = true)
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Byte userLevel;
|
||||||
|
|
||||||
|
@Schema(name = "账号")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(name = "用户昵称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
@Schema(name = "邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Schema(name = "电话号码")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Schema(name = "用户性别")
|
||||||
|
private String gender;
|
||||||
|
|
||||||
|
@Schema(name = "头像真实名称", hidden = true)
|
||||||
|
private String avatarName;
|
||||||
|
|
||||||
|
@Schema(name = "头像存储的路径", hidden = true)
|
||||||
|
private String avatarPath;
|
||||||
|
|
||||||
|
@Schema(name = "密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(name = "是否启用")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
@Schema(name = "是否为admin账号", hidden = true)
|
||||||
|
private Boolean isAdmin = false;
|
||||||
|
|
||||||
|
@Schema(name = "最后修改密码的时间", hidden = true)
|
||||||
|
private Date pwdResetTime;
|
||||||
|
|
||||||
|
private List<ConsumerVo> children;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ConsumerVo consumer = (ConsumerVo) o;
|
||||||
|
return Objects.equals(customerId, consumer.customerId) && Objects.equals(userName, consumer.userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(customerId, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.fuyuanshen.customer.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.fuyuanshen.customer.domain.Customer;
|
||||||
|
import com.fuyuanshen.customer.domain.query.UserQueryCriteria;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-07-0114:37
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CustomerMapper extends BaseMapper<Customer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Customer> findCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分页总数
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Long countCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Customer> queryAllCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据条件查询客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Customer> queryCustomers(@Param("criteria") UserQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询客户
|
||||||
|
*
|
||||||
|
* @param customerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Customer queryCustomerById(@Param("customerId") Long customerId, @Param("pid") Long pid);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.fuyuanshen.customer.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.customer.domain.Customer;
|
||||||
|
import com.fuyuanshen.customer.domain.query.UserQueryCriteria;
|
||||||
|
import com.fuyuanshen.customer.domain.vo.ConsumerVo;
|
||||||
|
import io.undertow.util.BadRequestException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-07-0114:31
|
||||||
|
*/
|
||||||
|
public interface CustomerService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
TableDataInfo<ConsumerVo> queryCustomers(UserQueryCriteria criteria, Page<Customer> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Customer> queryAllCustomers(UserQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增客户
|
||||||
|
*
|
||||||
|
* @param customer /
|
||||||
|
*/
|
||||||
|
void addCustomer(Customer customer) throws BadRequestException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改客户
|
||||||
|
*
|
||||||
|
* @param resources /
|
||||||
|
* @throws Exception /
|
||||||
|
*/
|
||||||
|
void updateCustomer(Customer resources) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除客户
|
||||||
|
*
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
|
void delete(Set<Long> ids);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
package com.fuyuanshen.customer.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||||
|
import com.fuyuanshen.customer.domain.Customer;
|
||||||
|
import com.fuyuanshen.customer.domain.query.UserQueryCriteria;
|
||||||
|
import com.fuyuanshen.customer.domain.vo.ConsumerVo;
|
||||||
|
import com.fuyuanshen.customer.mapper.CustomerMapper;
|
||||||
|
import com.fuyuanshen.customer.service.CustomerService;
|
||||||
|
import io.undertow.util.BadRequestException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-07-0114:31
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
||||||
|
|
||||||
|
private final CustomerMapper customerMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<ConsumerVo> queryCustomers(UserQueryCriteria criteria, Page<Customer> page) {
|
||||||
|
criteria.setOffset(page.offset());
|
||||||
|
criteria.setPid(LoginHelper.getUserId());
|
||||||
|
List<Customer> users = customerMapper.findCustomers(criteria);
|
||||||
|
List<ConsumerVo> consumerVoList = BeanUtil.copyToList(users, ConsumerVo.class);
|
||||||
|
Long total = customerMapper.countCustomers(criteria);
|
||||||
|
// return PageUtil.toPage(consumerVoList, total);
|
||||||
|
return new TableDataInfo<ConsumerVo>(consumerVoList, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有客户
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Customer> queryAllCustomers(UserQueryCriteria criteria) {
|
||||||
|
List<Customer> users = customerMapper.queryAllCustomers(criteria);
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增客户
|
||||||
|
*
|
||||||
|
* @param customer /
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void addCustomer(Customer customer) throws BadRequestException {
|
||||||
|
|
||||||
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
|
|
||||||
|
UserQueryCriteria userQueryCriteria = new UserQueryCriteria();
|
||||||
|
userQueryCriteria.setCustomerName(customer.getUserName());
|
||||||
|
List<Customer> customers = customerMapper.queryCustomers(userQueryCriteria);
|
||||||
|
if (!customers.isEmpty()) {
|
||||||
|
throw new BadRequestException("用户名已存在!!!");
|
||||||
|
}
|
||||||
|
customer.setUserLevel((byte) (loginUser.getUserLevel() + 1));
|
||||||
|
customer.setPid(loginUser.getUserId());
|
||||||
|
|
||||||
|
save(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改客户
|
||||||
|
*
|
||||||
|
* @param resources /
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateCustomer(Customer resources) throws Exception {
|
||||||
|
saveOrUpdate(resources);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除客户
|
||||||
|
*
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(Set<Long> ids) {
|
||||||
|
customerMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
spring.application.name=fys-customer
|
@ -0,0 +1,204 @@
|
|||||||
|
<?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.fuyuanshen.customer.mapper.CustomerMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.fuyuanshen.customer.domain.Customer">
|
||||||
|
<id column="user_user_id" property="customerId"/>
|
||||||
|
<result column="user_dept_id" property="deptId"/>
|
||||||
|
<result column="user_user_name" property="userName"/>
|
||||||
|
<result column="user_nick_name" property="nickName"/>
|
||||||
|
<result column="user_email" property="email"/>
|
||||||
|
<result column="user_pid" property="pid"/>
|
||||||
|
<result column="user_create_by" property="createBy"/>
|
||||||
|
<result column="user_update_by" property="updateBy"/>
|
||||||
|
<result column="user_create_time" property="createTime"/>
|
||||||
|
<result column="user_update_time" property="updateTime"/>
|
||||||
|
<result column="tenant_id" property="tenantId"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 公共查询字段 -->
|
||||||
|
<sql id="selectUserColumns">
|
||||||
|
u
|
||||||
|
.
|
||||||
|
user_user_id
|
||||||
|
AS user_user_id,
|
||||||
|
u.user_name,
|
||||||
|
u.nick_name AS nickName,
|
||||||
|
u.email,
|
||||||
|
u.phone,
|
||||||
|
u.gender,
|
||||||
|
u.avatar_name AS avatarName,
|
||||||
|
u.avatar_path AS avatarPath,
|
||||||
|
u.enabled,
|
||||||
|
IF(u.is_admin = 1, true, false) AS isAdmin,
|
||||||
|
u.pwd_reset_time AS pwdResetTime,
|
||||||
|
u.dept_id AS deptId,
|
||||||
|
u.tenant_id AS tenantId
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
u1
|
||||||
|
.
|
||||||
|
user_id
|
||||||
|
as user_user_id, u1.dept_id as user_dept_id, u1.user_name as user_user_name,
|
||||||
|
u1.nick_name as user_nick_name, u1.email as user_email, u1.phone as user_phone,
|
||||||
|
u1.gender as user_gender, u1.avatar_name as user_avatar_name, u1.avatar_path as user_avatar_path,
|
||||||
|
u1.enabled as user_enabled, u1.pwd_reset_time as user_pwd_reset_time, u1.create_by as user_create_by,
|
||||||
|
u1.update_by as user_update_by, u1.create_time as user_create_time, u1.update_time as user_update_time,
|
||||||
|
u1.user_level, u1.pid as user_pid,u1.is_admin AS admin,
|
||||||
|
d.dept_id as dept_id, d.name as dept_name
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="Job_Column_List">
|
||||||
|
j
|
||||||
|
.
|
||||||
|
job_id
|
||||||
|
as job_id, j.name as job_name
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="Role_Column_List">
|
||||||
|
r
|
||||||
|
.
|
||||||
|
role_id
|
||||||
|
as role_id, r.name as role_name, r.level as role_level, r.data_scope as role_data_scope
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="Whrer_Sql">
|
||||||
|
<where>
|
||||||
|
<if test="criteria.id != null">
|
||||||
|
and u1.user_id = #{criteria.id}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.enabled != null">
|
||||||
|
and u1.enabled = #{criteria.enabled}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deptIds != null and criteria.deptIds.size() != 0">
|
||||||
|
and u1.dept_id in
|
||||||
|
<foreach collection="criteria.deptIds" item="deptId" open="(" separator="," close=")">
|
||||||
|
#{deptId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="criteria.blurry != null and criteria.blurry != ''">
|
||||||
|
and (
|
||||||
|
u1.user_name like concat('%', #{criteria.blurry}, '%')
|
||||||
|
or u1.nick_name like concat('%', #{criteria.blurry}, '%')
|
||||||
|
or u1.email like concat('%', #{criteria.blurry}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
|
and u1.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 分页查询客户 -->
|
||||||
|
<select id="findCustomers" resultType="com.fuyuanshen.customer.domain.Customer">
|
||||||
|
select
|
||||||
|
u.user_id as customerId, u.nick_name , u.user_name, u.enabled, u.create_time
|
||||||
|
from sys_user u
|
||||||
|
<where>
|
||||||
|
<if test="criteria.ids != null and !criteria.ids.isEmpty()">
|
||||||
|
and u.pid IN
|
||||||
|
<foreach item="item" collection="criteria.ids" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="criteria.pid != null">
|
||||||
|
and u.pid = #{criteria.pid}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.blurry != null and criteria.blurry.trim() != ''">
|
||||||
|
and u.nick_name like concat('%', TRIM(#{criteria.blurry}), '%')
|
||||||
|
</if>
|
||||||
|
<if test="criteria.enabled != null">
|
||||||
|
and u.enabled = #{criteria.enabled}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||||
|
and u.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by u.user_id desc
|
||||||
|
<if test="criteria.offset != null">
|
||||||
|
limit #{criteria.offset}, #{criteria.pageSize}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取分页总数 -->
|
||||||
|
<select id="countCustomers" resultType="java.lang.Long">
|
||||||
|
select count(*)
|
||||||
|
from sys_user u
|
||||||
|
<where>
|
||||||
|
<if test="criteria.ids != null and !criteria.ids.isEmpty()">
|
||||||
|
and u.pid IN
|
||||||
|
<foreach item="item" collection="criteria.ids" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="criteria.pid != null">
|
||||||
|
and u.pid = #{criteria.pid}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.blurry != null and criteria.blurry.trim() != ''">
|
||||||
|
and u.nick_name like concat('%', TRIM(#{criteria.blurry}), '%')
|
||||||
|
</if>
|
||||||
|
<if test="criteria.enabled != null">
|
||||||
|
and u.enabled = #{criteria.enabled}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||||
|
and u.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询所有客户 -->
|
||||||
|
<select id="queryAllCustomers" resultType="com.fuyuanshen.customer.domain.Customer">
|
||||||
|
select u.user_id as customerId,
|
||||||
|
u.nick_name,
|
||||||
|
u.user_name,
|
||||||
|
u.enabled,
|
||||||
|
u.create_time
|
||||||
|
from sys_user u
|
||||||
|
<where>
|
||||||
|
<!-- 增加非空判断 -->
|
||||||
|
<if test="criteria.ids != null and !criteria.ids.isEmpty()">
|
||||||
|
u.pid IN
|
||||||
|
<foreach item="item" collection="criteria.ids" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 根据条件查询客户 -->
|
||||||
|
<select id="queryCustomers" resultType="com.fuyuanshen.customer.domain.Customer"
|
||||||
|
parameterType="com.fuyuanshen.customer.domain.query.UserQueryCriteria">
|
||||||
|
select u.user_id as customerId,
|
||||||
|
u.nick_name,
|
||||||
|
u.user_name,
|
||||||
|
u.enabled,
|
||||||
|
u.create_time
|
||||||
|
from sys_user u
|
||||||
|
<where>
|
||||||
|
<if test="criteria.customerName != null and criteria.customerName.trim() != ''">
|
||||||
|
and u.user_name = TRIM(#{criteria.customerName})
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据id查询客户 -->
|
||||||
|
<select id="queryCustomerById" resultType="com.fuyuanshen.customer.domain.Customer">
|
||||||
|
select u.*
|
||||||
|
from sys_user u
|
||||||
|
<where>
|
||||||
|
<if test="customerId!= null">
|
||||||
|
and u.user_id = customerId)
|
||||||
|
</if>
|
||||||
|
<if test="pid != null">
|
||||||
|
and u.pid = pid)
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
6
fys-modules/fys-customer/web2/WEB-INF/web.xml
Normal file
6
fys-modules/fys-customer/web2/WEB-INF/web.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||||
|
version="4.0">
|
||||||
|
</web-app>
|
@ -38,6 +38,11 @@
|
|||||||
<artifactId>fys-common-translation</artifactId>
|
<artifactId>fys-common-translation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- OSS功能模块 -->
|
<!-- OSS功能模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
@ -101,16 +106,22 @@
|
|||||||
<artifactId>fys-common-sse</artifactId>
|
<artifactId>fys-common-sse</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 客户管理模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-customer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>3.3.1</version>
|
||||||
<exclusions>
|
</dependency>
|
||||||
<exclusion>
|
|
||||||
<artifactId>poi-ooxml-schemas</artifactId>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
</exclusion>
|
<artifactId>ooxml-schemas</artifactId>
|
||||||
</exclusions>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -3,14 +3,17 @@ package com.fuyuanshen.equipment.controller;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuyuanshen.common.core.constant.ResponseMessageConstants;
|
import com.fuyuanshen.common.core.constant.ResponseMessageConstants;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
|
||||||
import com.fuyuanshen.common.core.domain.ResponseVO;
|
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
|
import com.fuyuanshen.equipment.service.impl.DeviceExportService;
|
||||||
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
@ -37,21 +40,17 @@ import java.util.List;
|
|||||||
@RequestMapping("/api/device")
|
@RequestMapping("/api/device")
|
||||||
public class DeviceController {
|
public class DeviceController {
|
||||||
|
|
||||||
|
private final ISysOssService ossService;
|
||||||
private final DeviceService deviceService;
|
private final DeviceService deviceService;
|
||||||
|
|
||||||
|
private final DeviceExportService exportService;
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "分页查询设备列表", security = {@SecurityRequirement(name = "bearer-key")})
|
@Operation(summary = "分页查询设备列表", security = {@SecurityRequirement(name = "bearer-key")})
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseVO<PageResult<Device>> queryDevice(DeviceQueryCriteria criteria) {
|
public TableDataInfo<Device> queryDevice(DeviceQueryCriteria criteria) throws IOException {
|
||||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<Device> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
PageResult<Device> devices = null;
|
return deviceService.queryAll(criteria, page);
|
||||||
try {
|
|
||||||
devices = deviceService.queryAll(criteria, page);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("queryDevice error: " + e.getMessage());
|
|
||||||
return ResponseVO.fail("");
|
|
||||||
}
|
|
||||||
return ResponseVO.success(devices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +96,6 @@ public class DeviceController {
|
|||||||
@DeleteMapping(value = "/delete")
|
@DeleteMapping(value = "/delete")
|
||||||
public ResponseVO<Object> deleteDevice(@Parameter(name = "传ID数组[]") @RequestBody List<Long> ids) {
|
public ResponseVO<Object> deleteDevice(@Parameter(name = "传ID数组[]") @RequestBody List<Long> ids) {
|
||||||
deviceService.deleteAll(ids);
|
deviceService.deleteAll(ids);
|
||||||
// deviceService.deleteAssign(ids);
|
|
||||||
return ResponseVO.success(ResponseMessageConstants.DELETE_SUCCESS);
|
return ResponseVO.success(ResponseMessageConstants.DELETE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +118,7 @@ public class DeviceController {
|
|||||||
|
|
||||||
|
|
||||||
// @Log("撤回设备")
|
// @Log("撤回设备")
|
||||||
@Operation(summary = "撤回设备")
|
@Operation(summary = "撤回分配设备")
|
||||||
@PostMapping(value = "/withdraw")
|
@PostMapping(value = "/withdraw")
|
||||||
public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||||
try {
|
try {
|
||||||
@ -151,7 +149,8 @@ public class DeviceController {
|
|||||||
@Operation(summary = "导出数据设备")
|
@Operation(summary = "导出数据设备")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
public void exportDevice(HttpServletResponse response, DeviceQueryCriteria criteria) throws IOException {
|
public void exportDevice(HttpServletResponse response, DeviceQueryCriteria criteria) throws IOException {
|
||||||
|
List<Device> devices = deviceService.queryAll(criteria);
|
||||||
|
exportService.export(devices, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,6 +158,8 @@ public class DeviceController {
|
|||||||
@PostMapping(value = "/import", consumes = "multipart/form-data")
|
@PostMapping(value = "/import", consumes = "multipart/form-data")
|
||||||
public ResponseVO<ImportResult> importData(@Parameter(name = "文件", required = true) @RequestPart("file") MultipartFile file) {
|
public ResponseVO<ImportResult> importData(@Parameter(name = "文件", required = true) @RequestPart("file") MultipartFile file) {
|
||||||
|
|
||||||
|
SysOssVo upload = ossService.upload(file);
|
||||||
|
|
||||||
// String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
|
// String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
|
||||||
// if (!("xlsx".equalsIgnoreCase(suffix))) {
|
// if (!("xlsx".equalsIgnoreCase(suffix))) {
|
||||||
// throw new BadRequestException("只能上传Excel——xlsx格式文件");
|
// throw new BadRequestException("只能上传Excel——xlsx格式文件");
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package com.fuyuanshen.equipment.controller;
|
package com.fuyuanshen.equipment.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
|
||||||
import com.fuyuanshen.common.core.domain.ResponseVO;
|
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -33,9 +32,9 @@ public class DeviceTypeController {
|
|||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Operation(summary = "分页查询设备类型")
|
@Operation(summary = "分页查询设备类型")
|
||||||
public ResponseVO<PageResult<DeviceType>> queryDeviceType(DeviceTypeQueryCriteria criteria) {
|
public TableDataInfo<DeviceType> queryDeviceType(DeviceTypeQueryCriteria criteria) {
|
||||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<DeviceType> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
return ResponseVO.success(deviceTypeService.queryAll(criteria, page));
|
return deviceTypeService.queryAll(criteria, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ public class DeviceTypeController {
|
|||||||
// @Log("修改设备类型")
|
// @Log("修改设备类型")
|
||||||
@Operation(summary = "修改设备类型")
|
@Operation(summary = "修改设备类型")
|
||||||
@PutMapping(value = "/update")
|
@PutMapping(value = "/update")
|
||||||
public ResponseVO<Object> updateDeviceType(@Validated @RequestBody DeviceType resources) {
|
public ResponseVO<Object> updateDeviceType(@Validated @RequestBody DeviceTypeForm resources) {
|
||||||
deviceTypeService.update(resources);
|
deviceTypeService.update(resources);
|
||||||
return ResponseVO.success(null);
|
return ResponseVO.success(null);
|
||||||
}
|
}
|
||||||
@ -68,17 +67,16 @@ public class DeviceTypeController {
|
|||||||
// @Log("删除设备类型")
|
// @Log("删除设备类型")
|
||||||
@Operation(summary = "删除设备类型")
|
@Operation(summary = "删除设备类型")
|
||||||
@DeleteMapping(value = "/delete")
|
@DeleteMapping(value = "/delete")
|
||||||
public ResponseEntity<Object> deleteDeviceType(@Parameter(name = "传ID数组[]") @RequestBody List<Long> ids) {
|
public ResponseVO<Object> deleteDeviceType(@Parameter(name = "传ID数组[]") @RequestBody List<Long> ids) {
|
||||||
deviceTypeService.deleteAll(ids);
|
deviceTypeService.deleteAll(ids);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return ResponseVO.success("删除成功!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/communicationMode")
|
@GetMapping(value = "/communicationMode")
|
||||||
@Operation(summary = "获取设备类型通讯方式")
|
@Operation(summary = "获取设备类型通讯方式")
|
||||||
public ResponseVO<DeviceType> getCommunicationMode(@Parameter(name = "设备类型ID", required = true) Long id) {
|
public ResponseVO<DeviceType> getCommunicationMode(@Parameter(name = "设备类型ID", required = true) Long id) {
|
||||||
return ResponseVO.success(deviceTypeService.getById(id));
|
return ResponseVO.success(deviceTypeService.getCommunicationMode(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.fuyuanshen.equipment.converter;
|
||||||
|
|
||||||
|
import com.alibaba.excel.converters.Converter;
|
||||||
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||||
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-0618:56
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IgnoreFailedImageConverter implements Converter<URL> {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(IgnoreFailedImageConverter.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> supportJavaTypeKey() {
|
||||||
|
return URL.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
// return CellDataTypeEnum.STRING;
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WriteCellData<?> convertToExcelData(URL value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
URLConnection conn = value.openConnection();
|
||||||
|
conn.setConnectTimeout(2000); // 2秒超时
|
||||||
|
conn.setReadTimeout(3000); // 3秒超时
|
||||||
|
|
||||||
|
try (InputStream inputStream = conn.getInputStream()) {
|
||||||
|
// byte[] bytes = FileUtils.readInputStream(inputStream, value.toString());
|
||||||
|
// 替代 FileUtils.readInputStream 的自定义方法
|
||||||
|
byte[] bytes = readInputStream(inputStream);
|
||||||
|
return new WriteCellData<>(bytes);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 静默忽略错误,只记录日志
|
||||||
|
logger.debug("忽略图片加载失败: {}, 原因: {}", value, e.getMessage());
|
||||||
|
// return null; // 返回null表示不写入图片
|
||||||
|
return new WriteCellData<>(new byte[0]); // 返回空数组而不是 null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替代 FileUtils.readInputStream 的自定义方法
|
||||||
|
*
|
||||||
|
* @param inputStream 输入流
|
||||||
|
* @return 字节数组
|
||||||
|
* @throws Exception 读取异常
|
||||||
|
*/
|
||||||
|
private byte[] readInputStream(InputStream inputStream) throws Exception {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputStream.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.fuyuanshen.equipment.converter;// package com.fuyuanshen.modules.system.converter;
|
||||||
|
//
|
||||||
|
// import com.alibaba.excel.converters.Converter;
|
||||||
|
// import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
// import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
|
// import com.alibaba.excel.metadata.data.ReadCellData;
|
||||||
|
// import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
//
|
||||||
|
// import java.io.ByteArrayOutputStream;
|
||||||
|
// import java.io.IOException;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @author: 默苍璃
|
||||||
|
// * @date: 2025-06-0710:01
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// public class ImageReadConverter implements Converter<byte[]> {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Class<?> supportJavaTypeKey() {
|
||||||
|
// return byte[].class;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // @Override
|
||||||
|
// // public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
// // return CellDataTypeEnum.IMAGE;
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public byte[] convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws IOException {
|
||||||
|
// if (cellData.getType() == CellDataTypeEnum.IMAGE) {
|
||||||
|
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
// cellData.getImageValueList().forEach(image -> {
|
||||||
|
// try {
|
||||||
|
// outputStream.write(image.getImageBytes());
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// return outputStream.toByteArray();
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,83 +18,77 @@ import lombok.Data;
|
|||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
@TableName("device")
|
@TableName("device")
|
||||||
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
|
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
|
||||||
public class Device extends TenantEntity {
|
public class Device extends TenantEntity {
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
// @Schema(value = "ID")
|
@Schema(name = "ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
// @Schema(value = "设备记录ID")
|
@Schema(name = "设备记录ID")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long assignId;
|
private Long assignId;
|
||||||
|
|
||||||
// @Schema(value = "设备类型")
|
@Schema(name = "设备类型")
|
||||||
private Long deviceType;
|
private Long deviceType;
|
||||||
|
|
||||||
// @Schema(value = "设备类型名称")
|
@Schema(name = "设备类型名称")
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
// @Schema(value = "客户号")
|
@Schema(name = "客户号")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(name = "所属客户")
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前所有者
|
* 当前所有者
|
||||||
* current_owner_id
|
* current_owner_id
|
||||||
*/
|
*/
|
||||||
// @Schema(value = "当前所有者")
|
@Schema(name = "当前所有者")
|
||||||
private Long currentOwnerId;
|
private Long currentOwnerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原始所有者(创建者)
|
* 原始所有者(创建者)
|
||||||
* original_owner_id
|
* original_owner_id
|
||||||
*/
|
*/
|
||||||
// @Schema(value = "原始所有者(创建者)")
|
@Schema(name = "原始所有者(创建者)")
|
||||||
private Long originalOwnerId;
|
private Long originalOwnerId;
|
||||||
|
|
||||||
// @Schema(value = "所属客户")
|
|
||||||
private String customerName;
|
|
||||||
|
|
||||||
/*@Schema(value = "设备编号")
|
/*@Schema( name = "设备编号")
|
||||||
private String deviceNo;*/
|
private String deviceNo;*/
|
||||||
|
|
||||||
// @Schema(value = "设备名称")
|
@Schema(name = "设备名称")
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
|
|
||||||
// @Schema(value = "设备图片")
|
@Schema(name = "设备图片")
|
||||||
private String devicePic;
|
private String devicePic;
|
||||||
|
|
||||||
// @Schema(value = "设备MAC")
|
@Schema(name = "设备MAC")
|
||||||
private String deviceMac;
|
private String deviceMac;
|
||||||
|
|
||||||
// @Schema(value = "设备IMEI")
|
@Schema(name = "设备IMEI")
|
||||||
private String deviceImei;
|
private String deviceImei;
|
||||||
|
|
||||||
// @Schema(value = "设备SN")
|
@Schema(name = "设备SN")
|
||||||
private String deviceSn;
|
private String deviceSn;
|
||||||
|
|
||||||
// @Schema(value = "经度")
|
@Schema(name = "经度")
|
||||||
private String longitude;
|
private String longitude;
|
||||||
|
|
||||||
// @Schema(value = "纬度")
|
@Schema(name = "纬度")
|
||||||
private String latitude;
|
private String latitude;
|
||||||
|
|
||||||
// @Schema(value = "备注")
|
@Schema(name = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户ID
|
|
||||||
*/
|
|
||||||
// @TableField(value = "tenant_id")
|
|
||||||
// // @Schema(hidden = true)
|
|
||||||
// private Long tenantId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备状态
|
* 设备状态
|
||||||
* 0 失效
|
* 0 失效
|
||||||
* 1 正常
|
* 1 正常
|
||||||
*/
|
*/
|
||||||
// @Schema(value = "设备状态")
|
@Schema(name = "设备状态")
|
||||||
private Integer deviceStatus;
|
private Integer deviceStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,12 +96,13 @@ public class Device extends TenantEntity {
|
|||||||
* 0 未绑定
|
* 0 未绑定
|
||||||
* 1 已绑定
|
* 1 已绑定
|
||||||
*/
|
*/
|
||||||
// @Schema(value = "绑定状态")
|
@Schema(name = "绑定状态")
|
||||||
private Integer bindingStatus;
|
private Integer bindingStatus;
|
||||||
|
|
||||||
|
|
||||||
public void copy(Device source) {
|
/**
|
||||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
* 创建人名称
|
||||||
}
|
*/
|
||||||
|
private String createByName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,7 @@ package com.fuyuanshen.equipment.domain;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
@ -45,6 +43,10 @@ public class DeviceType extends TenantEntity {
|
|||||||
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
private String communicationMode;
|
private String communicationMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人名称
|
||||||
|
*/
|
||||||
|
private String createByName;
|
||||||
|
|
||||||
public void copy(DeviceType source) {
|
public void copy(DeviceType source) {
|
||||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.dto;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||||
|
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||||
|
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||||
|
import com.fuyuanshen.equipment.converter.IgnoreFailedImageConverter;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-0618:16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@HeadRowHeight(20) // 表头行高
|
||||||
|
@ContentRowHeight(100) // 内容行高
|
||||||
|
public class DeviceExcelExportDTO {
|
||||||
|
|
||||||
|
@ExcelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ExcelProperty("设备类型")
|
||||||
|
private Long deviceType;
|
||||||
|
|
||||||
|
// @ExcelProperty("客户号")
|
||||||
|
// private Long customerId;
|
||||||
|
|
||||||
|
@ExcelProperty("所属客户")
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
|
@ExcelProperty("设备名称")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "设备图片", converter = IgnoreFailedImageConverter.class)
|
||||||
|
@ColumnWidth(15) // 设置图片列宽度
|
||||||
|
private URL devicePic; // 使用URL类型
|
||||||
|
|
||||||
|
@ExcelProperty("设备MAC")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
@ExcelProperty("设备IMEI")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
|
@ExcelProperty("经度")
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
@ExcelProperty("纬度")
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
@ColumnWidth(30)
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ExcelProperty("设备类型名称")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
* 0 失效
|
||||||
|
* 1 正常
|
||||||
|
*/
|
||||||
|
@ExcelProperty("设备状态")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String deviceStatus;
|
||||||
|
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@ExcelProperty("创建人")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
}
|
@ -21,7 +21,7 @@ public class DeviceForm {
|
|||||||
private Long assignId;
|
private Long assignId;
|
||||||
|
|
||||||
@Schema(title = "设备类型")
|
@Schema(title = "设备类型")
|
||||||
private Long deviceType;
|
private Long deviceTypeId;
|
||||||
|
|
||||||
@Schema(title = "客户号")
|
@Schema(title = "客户号")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.fuyuanshen.equipment.domain.form;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 设备类型
|
||||||
|
* @Author: WY
|
||||||
|
* @Date: 2025/5/14
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class DeviceTypeForm {
|
||||||
|
|
||||||
|
@Schema(name = "ID", hidden = true)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(name = "类型名称", required = true)
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@Schema(name = "是否支持蓝牙")
|
||||||
|
private Boolean isSupportBle;
|
||||||
|
|
||||||
|
@Schema(name = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
|
||||||
|
private String locateMode;
|
||||||
|
|
||||||
|
@Schema(name = "联网方式", example = "0:无;1:4G;2:WIFI")
|
||||||
|
private String networkWay;
|
||||||
|
|
||||||
|
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
|
private String communicationMode;
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.fuyuanshen.equipment.domain.query;
|
package com.fuyuanshen.equipment.domain.query;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -16,19 +17,22 @@ import java.util.Set;
|
|||||||
@Data
|
@Data
|
||||||
public class DeviceQueryCriteria {
|
public class DeviceQueryCriteria {
|
||||||
|
|
||||||
// @Schema(value = "设备名称")
|
@Schema(name = "设备id")
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
@Schema(name = "设备名称")
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
|
|
||||||
// @Schema(value = "设备类型")
|
@Schema(name = "设备类型")
|
||||||
private Long deviceType;
|
private Long deviceTypeId;
|
||||||
|
|
||||||
// @Schema(value = "设备MAC")
|
@Schema(name = "设备MAC")
|
||||||
private String deviceMac;
|
private String deviceMac;
|
||||||
|
|
||||||
// @Schema(value = "设备IMEI")
|
@Schema(name = "设备IMEI")
|
||||||
private String deviceImei;
|
private String deviceImei;
|
||||||
|
|
||||||
// @Schema(value = "设备SN")
|
@Schema(name = "设备SN")
|
||||||
private String deviceSn;
|
private String deviceSn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,29 +40,29 @@ public class DeviceQueryCriteria {
|
|||||||
* 0 失效
|
* 0 失效
|
||||||
* 1 正常
|
* 1 正常
|
||||||
*/
|
*/
|
||||||
// @Schema(value = "设备状态 0 失效 1 正常 ")
|
@Schema(name = "设备状态 0 失效 1 正常 ")
|
||||||
private Integer deviceStatus;
|
private Integer deviceStatus;
|
||||||
|
|
||||||
// @Schema(value = "创建时间")
|
@Schema(name = "创建时间")
|
||||||
private List<Timestamp> createTime;
|
private List<Timestamp> createTime;
|
||||||
|
|
||||||
// @Schema(value = "页码", example = "1")
|
@Schema(name = "页码", example = "1")
|
||||||
private Integer page = 1;
|
private Integer page = 1;
|
||||||
|
|
||||||
// @Schema(value = "每页数据量", example = "10")
|
@Schema(name = "每页数据量", example = "10")
|
||||||
private Integer size = 10;
|
private Integer size = 10;
|
||||||
|
|
||||||
// @Schema(value = "客户id")
|
@Schema(name = "客户id")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
private Set<Long> customerIds;
|
private Set<Long> customerIds;
|
||||||
|
|
||||||
// @Schema(value = "当前所有者")
|
@Schema(name = "当前所有者")
|
||||||
private Long currentOwnerId;
|
private Long currentOwnerId;
|
||||||
|
|
||||||
// @Schema(value = "租户ID")
|
@Schema(name = "租户ID")
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
// @Schema(value = "通讯方式", example = "0:4G;1:蓝牙")
|
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
private Integer communicationMode;
|
private Integer communicationMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ import java.util.Set;
|
|||||||
@Data
|
@Data
|
||||||
public class DeviceTypeQueryCriteria extends BaseEntity implements Serializable {
|
public class DeviceTypeQueryCriteria extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
@Schema(name = "设备类型id")
|
||||||
|
private Long deviceTypeId;
|
||||||
|
|
||||||
@Schema(name = "型号名称")
|
@Schema(name = "型号名称")
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
* @param page
|
* @param page
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
IPage<Device> findAll(@Param("criteria") DeviceQueryCriteria criteria, Page<Object> page);
|
IPage<Device> findAll(@Param("criteria") DeviceQueryCriteria criteria, Page<Device> page);
|
||||||
|
|
||||||
List<Device> findAll(@Param("criteria") DeviceQueryCriteria criteria);
|
List<Device> findAll(@Param("criteria") DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public interface DeviceTypeMapper extends BaseMapper<DeviceType> {
|
|||||||
* @param page
|
* @param page
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
IPage<DeviceType> findAll(@Param("criteria") DeviceTypeQueryCriteria criteria, Page<Object> page);
|
IPage<DeviceType> findAll(@Param("criteria") DeviceTypeQueryCriteria criteria, Page<DeviceType> page);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,7 @@ package com.fuyuanshen.equipment.service;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||||
@ -25,7 +26,15 @@ public interface DeviceService extends IService<Device> {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return PageResult
|
* @return PageResult
|
||||||
*/
|
*/
|
||||||
PageResult<Device> queryAll(DeviceQueryCriteria criteria, Page<Object> page) throws IOException;
|
TableDataInfo<Device> queryAll(DeviceQueryCriteria criteria, Page<Device> page) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有数据不分页
|
||||||
|
*
|
||||||
|
* @param criteria 条件参数
|
||||||
|
* @return List<DeviceDto>
|
||||||
|
*/
|
||||||
|
List<Device> queryAll(DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有设备信息
|
* 查询所有设备信息
|
||||||
|
@ -3,7 +3,9 @@ package com.fuyuanshen.equipment.service;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -22,7 +24,7 @@ public interface DeviceTypeService extends IService<DeviceType> {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return PageResult
|
* @return PageResult
|
||||||
*/
|
*/
|
||||||
PageResult<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<Object> page);
|
TableDataInfo<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<DeviceType> page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据不分页
|
* 查询所有数据不分页
|
||||||
@ -51,7 +53,7 @@ public interface DeviceTypeService extends IService<DeviceType> {
|
|||||||
*
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void update(DeviceType resources);
|
void update(DeviceTypeForm resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
@ -60,4 +62,11 @@ public interface DeviceTypeService extends IService<DeviceType> {
|
|||||||
*/
|
*/
|
||||||
void deleteAll(List<Long> ids);
|
void deleteAll(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备类型通讯方式
|
||||||
|
*
|
||||||
|
* @param id /
|
||||||
|
* @return DeviceTypeDto
|
||||||
|
*/
|
||||||
|
DeviceType getCommunicationMode(Long id);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.fuyuanshen.equipment.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.util.DateUtils;
|
||||||
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.dto.DeviceExcelExportDTO;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-0618:22
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DeviceExportService {
|
||||||
|
|
||||||
|
public void export(List<Device> devices, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
String fileName = "设备列表_" + System.currentTimeMillis() + ".xlsx";
|
||||||
|
// 使用URLEncoder进行RFC 5987编码
|
||||||
|
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()).replaceAll("\\+", "%20");
|
||||||
|
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
// 使用RFC 5987标准编码文件名
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename*=UTF-8''" + encodedFileName);
|
||||||
|
|
||||||
|
// 转换为DTO列表
|
||||||
|
List<DeviceExcelExportDTO> dtoList = devices.stream().map(device -> {
|
||||||
|
DeviceExcelExportDTO dto = new DeviceExcelExportDTO();
|
||||||
|
dto.setId(device.getId());
|
||||||
|
dto.setDeviceType(device.getDeviceType());
|
||||||
|
dto.setCustomerName(device.getCustomerName());
|
||||||
|
dto.setDeviceName(device.getDeviceName());
|
||||||
|
dto.setDeviceMac(device.getDeviceMac());
|
||||||
|
// 设备IMEI
|
||||||
|
dto.setDeviceImei(device.getDeviceImei());
|
||||||
|
dto.setLongitude(device.getLongitude());
|
||||||
|
dto.setLatitude(device.getLatitude());
|
||||||
|
dto.setRemark(device.getRemark());
|
||||||
|
dto.setTypeName(device.getTypeName());
|
||||||
|
dto.setCreateBy(device.getCreateByName());
|
||||||
|
Integer deviceStatus = device.getDeviceStatus();
|
||||||
|
dto.setDeviceStatus(deviceStatus == 1 ? "正常" : "失效");
|
||||||
|
// 时间戳转换
|
||||||
|
dto.setCreateTime(DateUtils.format(device.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|
||||||
|
// 处理图片URL转换
|
||||||
|
handleDevicePic(device, dto);
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 写入Excel
|
||||||
|
EasyExcel.write(response.getOutputStream(), DeviceExcelExportDTO.class).sheet("设备数据").doWrite(dtoList);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("导出Excel失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void handleDevicePic(Device device, DeviceExcelExportDTO dto) {
|
||||||
|
String picUrl = device.getDevicePic();
|
||||||
|
if (picUrl != null && !picUrl.trim().isEmpty()) {
|
||||||
|
try {
|
||||||
|
// 尝试创建URL对象(会自动验证格式)
|
||||||
|
dto.setDevicePic(new URL(picUrl));
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
// 不是有效URL时设置为null
|
||||||
|
dto.setDevicePic(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dto.setDevicePic(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,19 +1,26 @@
|
|||||||
package com.fuyuanshen.equipment.service.impl;
|
package com.fuyuanshen.equipment.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||||
import com.fuyuanshen.common.core.utils.PageUtil;
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||||
|
import com.fuyuanshen.customer.domain.Customer;
|
||||||
|
import com.fuyuanshen.customer.mapper.CustomerMapper;
|
||||||
import com.fuyuanshen.equipment.constants.DeviceConstants;
|
import com.fuyuanshen.equipment.constants.DeviceConstants;
|
||||||
import com.fuyuanshen.equipment.domain.Device;
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||||
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.equipment.service.DeviceService;
|
import com.fuyuanshen.equipment.service.DeviceService;
|
||||||
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -24,7 +31,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:
|
* @Description:
|
||||||
@ -41,8 +50,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Value("${file.device.ip}")
|
@Value("${file.device.ip}")
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
|
|
||||||
private final DeviceMapper deviceMapper;
|
private final DeviceMapper deviceMapper;
|
||||||
|
private final DeviceTypeMapper deviceTypeMapper;
|
||||||
|
|
||||||
|
private final CustomerMapper customerMapper;
|
||||||
|
|
||||||
|
private final ISysOssService ossService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,8 +67,10 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<Device> queryAll(DeviceQueryCriteria criteria, Page<Object> page) throws IOException {
|
public TableDataInfo<Device> queryAll(DeviceQueryCriteria criteria, Page<Device> page) throws IOException {
|
||||||
|
|
||||||
|
// criteria.setCustomerId(LoginHelper.getUserId());
|
||||||
|
criteria.setCurrentOwnerId(LoginHelper.getUserId());
|
||||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||||
|
|
||||||
List<Device> records = devices.getRecords();
|
List<Device> records = devices.getRecords();
|
||||||
@ -65,7 +80,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PageUtil.toPage(devices);
|
// return PageUtil.toPage(devices);
|
||||||
|
return new TableDataInfo<Device>(records, devices.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> queryAll(DeviceQueryCriteria criteria) {
|
||||||
|
return deviceMapper.findAll(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,17 +112,25 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void addDevice(DeviceForm deviceForm) throws Exception {
|
public void addDevice(DeviceForm deviceForm) throws Exception {
|
||||||
|
DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria();
|
||||||
// 获取当前登录用户信息
|
queryCriteria.setDeviceTypeId(deviceForm.getId());
|
||||||
// LoginUser user = LoginHelper.getLoginUser();
|
queryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||||
|
List<DeviceType> deviceTypes = deviceTypeMapper.findAll(queryCriteria);
|
||||||
|
if (deviceTypes.isEmpty()) {
|
||||||
|
throw new Exception("设备类型不存在!!!");
|
||||||
|
}
|
||||||
|
|
||||||
// 保存图片并获取URL
|
// 保存图片并获取URL
|
||||||
String imageUrl = saveDeviceImage(deviceForm.getFile(), deviceForm.getDeviceName());
|
// String imageUrl = saveDeviceImage(deviceForm.getFile(), deviceForm.getDeviceName());
|
||||||
|
SysOssVo upload = ossService.upload(deviceForm.getFile());
|
||||||
// 设置图片路径
|
// 设置图片路径
|
||||||
deviceForm.setDevicePic(imageUrl);
|
deviceForm.setDevicePic(upload.getUrl());
|
||||||
|
|
||||||
// 转换对象并插入数据库
|
// 转换对象并插入数据库
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
|
device.setCurrentOwnerId(loginUser.getUserId());
|
||||||
|
device.setCreateByName(loginUser.getNickname());
|
||||||
BeanUtil.copyProperties(deviceForm, device, true);
|
BeanUtil.copyProperties(deviceForm, device, true);
|
||||||
|
|
||||||
deviceMapper.insert(device);
|
deviceMapper.insert(device);
|
||||||
@ -118,14 +148,28 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DeviceForm deviceForm) throws Exception {
|
public void update(DeviceForm deviceForm) throws Exception {
|
||||||
|
|
||||||
Device device = getById(deviceForm.getId());
|
DeviceTypeQueryCriteria deviceTypeQueryCriteria = new DeviceTypeQueryCriteria();
|
||||||
if (device == null) {
|
deviceTypeQueryCriteria.setDeviceTypeId(deviceForm.getId());
|
||||||
throw new Exception("设备不存在!!!");
|
deviceTypeQueryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||||
|
List<DeviceType> deviceTypes = deviceTypeMapper.findAll(deviceTypeQueryCriteria);
|
||||||
|
if (deviceTypes.isEmpty()) {
|
||||||
|
throw new Exception("设备类型不存在!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceQueryCriteria queryCriteria = new DeviceQueryCriteria();
|
||||||
|
queryCriteria.setDeviceId(deviceForm.getId());
|
||||||
|
queryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||||
|
List<Device> devices = deviceMapper.findAll(queryCriteria);
|
||||||
|
if (devices.isEmpty()) {
|
||||||
|
throw new Exception("设备不存在!!!");
|
||||||
|
}
|
||||||
|
Device device = devices.get(0);
|
||||||
|
|
||||||
// 处理上传的图片
|
// 处理上传的图片
|
||||||
String imageUrl = saveDeviceImage(deviceForm.getFile(), device.getDeviceName());
|
// String imageUrl = saveDeviceImage(deviceForm.getFile(), device.getDeviceName());
|
||||||
deviceForm.setDevicePic(imageUrl);
|
SysOssVo upload = ossService.upload(deviceForm.getFile());
|
||||||
|
// 设置图片路径
|
||||||
|
deviceForm.setDevicePic(upload.getUrl());
|
||||||
|
|
||||||
// 更新字段
|
// 更新字段
|
||||||
BeanUtil.copyProperties(deviceForm, device, true);
|
BeanUtil.copyProperties(deviceForm, device, true);
|
||||||
@ -171,6 +215,18 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAll(List<Long> ids) {
|
public void deleteAll(List<Long> ids) {
|
||||||
|
List<Long> invalidIds = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Long id : ids) {
|
||||||
|
Device deviceType = deviceMapper.selectById(id);
|
||||||
|
if (deviceType == null || !Objects.equals(deviceType.getCurrentOwnerId(), LoginHelper.getUserId())) {
|
||||||
|
invalidIds.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!invalidIds.isEmpty()) {
|
||||||
|
throw new RuntimeException("以下设备无法删除(ID 不存在或无权限): " + invalidIds);
|
||||||
|
}
|
||||||
|
|
||||||
deviceMapper.deleteByIds(ids);
|
deviceMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +239,46 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void assignCustomer(CustomerVo customerVo) {
|
public void assignCustomer(CustomerVo customerVo) {
|
||||||
|
List<Long> deviceIds = customerVo.getDeviceIds();
|
||||||
|
Long customerId = customerVo.getCustomerId();
|
||||||
|
|
||||||
|
Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid());
|
||||||
|
if (customer == null) {
|
||||||
|
throw new RuntimeException("待分配的客户不存在!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Long> invalidIds = new ArrayList<>();
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
for (Long id : deviceIds) {
|
||||||
|
Device device = deviceMapper.selectById(id);
|
||||||
|
if (device == null || !Objects.equals(device.getCurrentOwnerId(), LoginHelper.getUserId())) {
|
||||||
|
invalidIds.add(id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
device.setCustomerId(customerId);
|
||||||
|
device.setCustomerName(customer.getNickName());
|
||||||
|
devices.add(device);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!invalidIds.isEmpty()) {
|
||||||
|
throw new RuntimeException("以下设备无法分配(ID 不存在或无权限): " + invalidIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
devices.forEach((device) -> {
|
||||||
|
deviceMapper.updateById(device);
|
||||||
|
device.setId(null);
|
||||||
|
device.setCurrentOwnerId(customerId);
|
||||||
|
deviceMapper.insert(device);
|
||||||
|
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
deviceType.setId(null);
|
||||||
|
device.setCurrentOwnerId(customerId);
|
||||||
|
deviceTypeMapper.insert(deviceType);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void assign(List<Long> deviceIds) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +307,4 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package com.fuyuanshen.equipment.service.impl;
|
package com.fuyuanshen.equipment.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.common.core.domain.PageResult;
|
import com.fuyuanshen.common.core.domain.PageResult;
|
||||||
|
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||||
import com.fuyuanshen.common.core.utils.PageUtil;
|
import com.fuyuanshen.common.core.utils.PageUtil;
|
||||||
|
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||||
|
import com.fuyuanshen.equipment.domain.Device;
|
||||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||||
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
|
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
@ -14,7 +21,9 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:
|
* @Description:
|
||||||
@ -37,8 +46,11 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<Object> page) {
|
public TableDataInfo<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<DeviceType> page) {
|
||||||
return PageUtil.toPage(deviceTypeMapper.findAll(criteria, page));
|
criteria.setCustomerId(LoginHelper.getUserId());
|
||||||
|
// return
|
||||||
|
IPage<DeviceType> deviceTypeIPage = deviceTypeMapper.findAll(criteria, page);
|
||||||
|
return new TableDataInfo<DeviceType>(deviceTypeIPage.getRecords(), deviceTypeIPage.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -70,9 +82,10 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DeviceType resources) {
|
public void create(DeviceType resources) {
|
||||||
Long userId = LoginHelper.getUserId();
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
resources.setCustomerId(userId);
|
resources.setCustomerId(loginUser.getUserId());
|
||||||
resources.setOwnerCustomerId(userId);
|
resources.setOwnerCustomerId(loginUser.getUserId());
|
||||||
|
resources.setCreateByName(loginUser.getNickname());
|
||||||
deviceTypeMapper.insert(resources);
|
deviceTypeMapper.insert(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +97,18 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DeviceType resources) {
|
public void update(DeviceTypeForm resources) {
|
||||||
deviceTypeMapper.updateById(resources);
|
DeviceType deviceType = deviceTypeMapper.selectById(resources.getId());
|
||||||
|
if (deviceType == null) {
|
||||||
|
throw new RuntimeException("设备类型不存在");
|
||||||
|
}
|
||||||
|
if (!Objects.equals(deviceType.getCustomerId(), LoginHelper.getUserId())) {
|
||||||
|
throw new RuntimeException("无权修改该设备类型");
|
||||||
|
}
|
||||||
|
// if (deviceMapper.countByTypeId(resources.getId()) > 0)
|
||||||
|
// throw new RuntimeException("该设备类型已被使用,无法删除");
|
||||||
|
BeanUtil.copyProperties(resources, deviceType);
|
||||||
|
deviceTypeMapper.updateById(deviceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,8 +120,49 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAll(List<Long> ids) {
|
public void deleteAll(List<Long> ids) {
|
||||||
|
|
||||||
|
List<Long> invalidIds = new ArrayList<>();
|
||||||
|
List<Long> invalidId2 = new ArrayList<>();
|
||||||
|
for (Long id : ids) {
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(id);
|
||||||
|
if (deviceType == null || !Objects.equals(deviceType.getCustomerId(), LoginHelper.getUserId())) {
|
||||||
|
invalidIds.add(id);
|
||||||
|
}
|
||||||
|
DeviceQueryCriteria deviceQueryCriteria = new DeviceQueryCriteria();
|
||||||
|
deviceQueryCriteria.setDeviceTypeId(id);
|
||||||
|
List<Device> devices = deviceMapper.findAll(deviceQueryCriteria);
|
||||||
|
if (!devices.isEmpty()) {
|
||||||
|
invalidId2.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!invalidIds.isEmpty()) {
|
||||||
|
throw new RuntimeException("以下设备类型无法删除(ID 不存在或无权限): " + invalidIds);
|
||||||
|
}
|
||||||
|
if (!invalidId2.isEmpty()) {
|
||||||
|
throw new RuntimeException("以下设备类型无法删除(已绑定设备): " + invalidId2);
|
||||||
|
}
|
||||||
|
|
||||||
deviceTypeMapper.deleteByIds(ids);
|
deviceTypeMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备类型通讯方式
|
||||||
|
*
|
||||||
|
* @param id /
|
||||||
|
* @return DeviceTypeDto
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DeviceType getCommunicationMode(Long id) {
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(id);
|
||||||
|
if (deviceType == null) {
|
||||||
|
throw new RuntimeException("设备类型不存在");
|
||||||
|
}
|
||||||
|
if (!Objects.equals(deviceType.getCustomerId(), LoginHelper.getUserId())) {
|
||||||
|
throw new RuntimeException("无权获取该设备类型通讯方式");
|
||||||
|
}
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,15 +38,9 @@
|
|||||||
|
|
||||||
<!-- 分页查询设备 -->
|
<!-- 分页查询设备 -->
|
||||||
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||||
select
|
select d.* ,t.type_name
|
||||||
d.id,d.device_name,
|
FROM device d
|
||||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
|
||||||
d.update_time, d.device_type, d.remark, d.binding_status,t.type_name
|
|
||||||
-- da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
|
||||||
-- da.assigned_at AS create_time , da.assigner_name AS create_by , da.id AS assignId
|
|
||||||
from device d
|
|
||||||
LEFT JOIN device_type t ON d.device_type = t.id
|
LEFT JOIN device_type t ON d.device_type = t.id
|
||||||
-- LEFT JOIN device_assignments da ON da.device_id = d.id
|
|
||||||
<where>
|
<where>
|
||||||
<!-- 时间范围等其他条件保持原样 -->
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
@ -58,94 +52,22 @@
|
|||||||
<if test="criteria.deviceImei != null">
|
<if test="criteria.deviceImei != null">
|
||||||
and d.device_imei = #{criteria.deviceImei}
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceType != null">
|
<if test="criteria.deviceTypeId != null">
|
||||||
and d.device_type = #{criteria.deviceType}
|
and d.device_type = #{criteria.deviceTypeId}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceStatus != null">
|
<if test="criteria.deviceStatus != null">
|
||||||
-- and da.active = #{criteria.deviceStatus}
|
-- and da.active = #{criteria.deviceStatus}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.currentOwnerId != null">
|
||||||
|
d.current_owner_id = #{criteria.currentOwnerId}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="criteria.tenantId != null">
|
<if test="criteria.tenantId != null">
|
||||||
AND tenant_id = #{criteria.tenantId}
|
AND tenant_id = #{criteria.tenantId}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 下面这两个条件只需满足一个 -->
|
|
||||||
<!-- <if test="criteria.customerId != null"> -->
|
|
||||||
<!-- AND ( -->
|
|
||||||
<!-- tenant_id = #{criteria.tenantId} -->
|
|
||||||
<!-- OR d.customer_id = #{criteria.customerId} -->
|
|
||||||
<!-- ) -->
|
|
||||||
<!-- </if> -->
|
|
||||||
<!-- <if test="criteria.customerId == null"> -->
|
|
||||||
<!-- AND tenant_id = #{criteria.tenantId} -->
|
|
||||||
<!-- </if> -->
|
|
||||||
</where>
|
</where>
|
||||||
-- ORDER BY create_time DESC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="findAll1" resultType="com.fuyuanshen.equipment.domain.Device">
|
|
||||||
SELECT
|
|
||||||
d.id, d.customer_id, d.customer_name, d.device_name,
|
|
||||||
d.device_pic, d.device_mac, d.device_sn, d.create_by, d.update_by,
|
|
||||||
d.create_time, d.update_time, d.device_type, d.remark, d.device_status, t.type_name
|
|
||||||
from device d
|
|
||||||
left join device_type t
|
|
||||||
on d.device_type = t.id
|
|
||||||
<where>
|
|
||||||
<!-- 时间范围等其他条件保持原样 -->
|
|
||||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
|
||||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
|
||||||
</if>
|
|
||||||
<if test="criteria.deviceMac != null">
|
|
||||||
and d.device_mac = #{criteria.deviceMac}
|
|
||||||
</if>
|
|
||||||
<if test="criteria.deviceSn != null">
|
|
||||||
and d.device_sn = #{criteria.deviceSn}
|
|
||||||
</if>
|
|
||||||
<if test="criteria.deviceType != null">
|
|
||||||
and d.device_type = #{criteria.deviceType}
|
|
||||||
</if>
|
|
||||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
|
||||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<!-- 将两个客户相关条件合并成一个逻辑组 -->
|
|
||||||
<if test="criteria.customerId != null or (criteria.customerIds != null and !criteria.customerIds.isEmpty())">
|
|
||||||
AND (
|
|
||||||
<!-- 条件1: 用户或其下属创建,且 customer_id 为空 -->
|
|
||||||
<if test="criteria.customerId != null">
|
|
||||||
d.create_by IN (
|
|
||||||
SELECT username FROM sys_user
|
|
||||||
WHERE user_id = #{criteria.customerId} OR pid = #{criteria.customerId}
|
|
||||||
) AND d.customer_id IS NULL
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<!-- 如果前面的条件不存在,则只保留第二个条件 -->
|
|
||||||
<choose>
|
|
||||||
<when test="criteria.customerId != null and (criteria.customerIds != null and !criteria.customerIds.isEmpty())">
|
|
||||||
OR
|
|
||||||
</when>
|
|
||||||
<when test="criteria.customerId == null and (criteria.customerIds != null and !criteria.customerIds.isEmpty())">
|
|
||||||
<!-- 仅当第一个条件不存在时才开始括号 -->
|
|
||||||
</when>
|
|
||||||
</choose>
|
|
||||||
|
|
||||||
<!-- 条件2: 客户ID在列表中 -->
|
|
||||||
<if test="criteria.customerIds != null and !criteria.customerIds.isEmpty()">
|
|
||||||
(d.customer_id IN
|
|
||||||
<foreach item="customerId" collection="criteria.customerIds" open="(" separator="," close=")">
|
|
||||||
#{customerId}
|
|
||||||
</foreach>
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
|
|
||||||
order by d.id desc
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||||
@ -161,8 +83,8 @@
|
|||||||
<if test="criteria.deviceMac != null">
|
<if test="criteria.deviceMac != null">
|
||||||
and d.device_mac = #{criteria.deviceMac}
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceType != null">
|
<if test="criteria.deviceTypeId != null">
|
||||||
and d.device_type = #{criteria.deviceType}
|
and d.device_type = #{criteria.deviceTypeId}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
<if test="criteria.typeName != null and criteria.typeName.trim() != ''">
|
<if test="criteria.typeName != null and criteria.typeName.trim() != ''">
|
||||||
and dt.type_name like concat('%', TRIM(#{criteria.typeName}), '%')
|
and dt.type_name like concat('%', TRIM(#{criteria.typeName}), '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.tenantId != null">
|
<if test="criteria.deviceTypeId != null">
|
||||||
and dt.tenant_id = #{criteria.tenantId}
|
and dt.id = #{criteria.deviceTypeId}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.createBy != null">
|
<if test="criteria.customerId != null">
|
||||||
and dt.create_by = #{criteria.createBy}
|
and dt.owner_customer_id = #{criteria.customerId}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
ORDER BY dt.create_time DESC
|
ORDER BY dt.create_time DESC
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.fuyuanshen.system.controller.system;
|
package com.fuyuanshen.system.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.fuyuanshen.common.core.constant.CacheNames;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
import com.fuyuanshen.common.excel.utils.ExcelUtil;
|
||||||
import com.fuyuanshen.common.log.annotation.Log;
|
import com.fuyuanshen.common.log.annotation.Log;
|
||||||
@ -13,6 +14,7 @@ import com.fuyuanshen.system.domain.vo.SysConfigVo;
|
|||||||
import com.fuyuanshen.system.service.ISysConfigService;
|
import com.fuyuanshen.system.service.ISysConfigService;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -134,4 +136,15 @@ public class SysConfigController extends BaseController {
|
|||||||
configService.resetConfigCache();
|
configService.resetConfigCache();
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空所有客户端缓存
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/clearAllClientCache")
|
||||||
|
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, allEntries = true)
|
||||||
|
public void clearAllClientCache() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,9 @@ public class SysMenuController extends BaseController {
|
|||||||
* 获取菜单列表
|
* 获取菜单列表
|
||||||
*/
|
*/
|
||||||
@SaCheckRole(value = {
|
@SaCheckRole(value = {
|
||||||
TenantConstants.SUPER_ADMIN_ROLE_KEY,
|
TenantConstants.SUPER_ADMIN_ROLE_KEY,
|
||||||
TenantConstants.TENANT_ADMIN_ROLE_KEY
|
TenantConstants.TENANT_ADMIN_ROLE_KEY,
|
||||||
|
TenantConstants.FYS_ROLE_KEY
|
||||||
}, mode = SaMode.OR)
|
}, mode = SaMode.OR)
|
||||||
@SaCheckPermission("system:menu:list")
|
@SaCheckPermission("system:menu:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ -67,8 +68,9 @@ public class SysMenuController extends BaseController {
|
|||||||
* @param menuId 菜单ID
|
* @param menuId 菜单ID
|
||||||
*/
|
*/
|
||||||
@SaCheckRole(value = {
|
@SaCheckRole(value = {
|
||||||
TenantConstants.SUPER_ADMIN_ROLE_KEY,
|
TenantConstants.SUPER_ADMIN_ROLE_KEY,
|
||||||
TenantConstants.TENANT_ADMIN_ROLE_KEY
|
TenantConstants.TENANT_ADMIN_ROLE_KEY,
|
||||||
|
TenantConstants.FYS_ROLE_KEY
|
||||||
}, mode = SaMode.OR)
|
}, mode = SaMode.OR)
|
||||||
@SaCheckPermission("system:menu:query")
|
@SaCheckPermission("system:menu:query")
|
||||||
@GetMapping(value = "/{menuId}")
|
@GetMapping(value = "/{menuId}")
|
||||||
@ -96,8 +98,8 @@ public class SysMenuController extends BaseController {
|
|||||||
public R<MenuTreeSelectVo> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
public R<MenuTreeSelectVo> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId());
|
List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId());
|
||||||
MenuTreeSelectVo selectVo = new MenuTreeSelectVo(
|
MenuTreeSelectVo selectVo = new MenuTreeSelectVo(
|
||||||
menuService.selectMenuListByRoleId(roleId),
|
menuService.selectMenuListByRoleId(roleId),
|
||||||
menuService.buildMenuTreeSelect(menus));
|
menuService.buildMenuTreeSelect(menus));
|
||||||
return R.ok(selectVo);
|
return R.ok(selectVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +114,8 @@ public class SysMenuController extends BaseController {
|
|||||||
public R<MenuTreeSelectVo> tenantPackageMenuTreeselect(@PathVariable("packageId") Long packageId) {
|
public R<MenuTreeSelectVo> tenantPackageMenuTreeselect(@PathVariable("packageId") Long packageId) {
|
||||||
List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId());
|
List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId());
|
||||||
MenuTreeSelectVo selectVo = new MenuTreeSelectVo(
|
MenuTreeSelectVo selectVo = new MenuTreeSelectVo(
|
||||||
menuService.selectMenuListByPackageId(packageId),
|
menuService.selectMenuListByPackageId(packageId),
|
||||||
menuService.buildMenuTreeSelect(menus));
|
menuService.buildMenuTreeSelect(menus));
|
||||||
return R.ok(selectVo);
|
return R.ok(selectVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ public class SysUser extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
private Byte userLevel;
|
||||||
|
|
||||||
|
|
||||||
public SysUser(Long userId) {
|
public SysUser(Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
@ -32,6 +32,7 @@ public class SysUserVo implements Serializable {
|
|||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户ID
|
* 租户ID
|
||||||
@ -139,4 +140,6 @@ public class SysUserVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
|
private Byte userLevel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
@Cacheable(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
|
@Cacheable(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
|
||||||
@Override
|
@Override
|
||||||
public SysClientVo queryByClientId(String clientId) {
|
public SysClientVo queryByClientId(String clientId) {
|
||||||
|
log.debug("【queryByClientId】缓存未命中,开始执行数据库查询,clientId={}", clientId);
|
||||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysClient>().eq(SysClient::getClientId, clientId));
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysClient>().eq(SysClient::getClientId, clientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,16 +126,16 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
@Override
|
@Override
|
||||||
public int updateClientStatus(String clientId, String status) {
|
public int updateClientStatus(String clientId, String status) {
|
||||||
return baseMapper.update(null,
|
return baseMapper.update(null,
|
||||||
new LambdaUpdateWrapper<SysClient>()
|
new LambdaUpdateWrapper<SysClient>()
|
||||||
.set(SysClient::getStatus, status)
|
.set(SysClient::getStatus, status)
|
||||||
.eq(SysClient::getClientId, clientId));
|
.eq(SysClient::getClientId, clientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
private void validEntityBeforeSave(SysClient entity) {
|
private void validEntityBeforeSave(SysClient entity) {
|
||||||
//TODO 做一些数据校验,如唯一约束
|
// TODO 做一些数据校验,如唯一约束
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +145,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
// TODO 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<module>fys-system</module>
|
<module>fys-system</module>
|
||||||
<module>fys-workflow</module>
|
<module>fys-workflow</module>
|
||||||
<module>fys-equipment</module>
|
<module>fys-equipment</module>
|
||||||
|
<module>fys-customer</module>
|
||||||
<module>fys-app</module>
|
<module>fys-app</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
23
pom.xml
23
pom.xml
@ -344,6 +344,20 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 设备管理模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-equipment</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 客户管理模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
<artifactId>fys-customer</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
<artifactId>fys-job</artifactId>
|
<artifactId>fys-job</artifactId>
|
||||||
@ -355,22 +369,21 @@
|
|||||||
<artifactId>fys-generator</artifactId>
|
<artifactId>fys-generator</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
<artifactId>fys-app</artifactId>
|
<artifactId>fys-app</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fuyuanshen</groupId>
|
|
||||||
<artifactId>fys-equipment</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
<artifactId>fys-demo</artifactId>
|
<artifactId>fys-demo</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 工作流模块 -->
|
<!-- 工作流模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fuyuanshen</groupId>
|
<groupId>com.fuyuanshen</groupId>
|
||||||
|
Reference in New Issue
Block a user