diff --git a/fys-admin/pom.xml b/fys-admin/pom.xml index 62479bb..e706cd4 100644 --- a/fys-admin/pom.xml +++ b/fys-admin/pom.xml @@ -65,6 +65,12 @@ fys-common-mail + + + com.fuyuanshen + fys-customer + + com.fuyuanshen diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/SysLoginService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/SysLoginService.java index 81472b5..0d55a4e 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/SysLoginService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/SysLoginService.java @@ -157,6 +157,11 @@ public class SysLoginService { loginUser.setUsername(user.getUserName()); loginUser.setNickname(user.getNickName()); loginUser.setUserType(user.getUserType()); + // 用户级别 + loginUser.setUserLevel(user.getUserLevel()); + // pid + loginUser.setPid(user.getPid()); + loginUser.setMenuPermission(permissionService.getMenuPermission(userId)); loginUser.setRolePermission(permissionService.getRolePermission(userId)); if (ObjectUtil.isNotNull(user.getDeptId())) { @@ -242,7 +247,7 @@ public class SysLoginService { log.info("登录租户:{} 已被停用.", tenantId); throw new TenantException("tenant.blocked"); } else if (ObjectUtil.isNotNull(tenant.getExpireTime()) - && new Date().after(tenant.getExpireTime())) { + && new Date().after(tenant.getExpireTime())) { log.info("登录租户:{} 已超过有效期.", tenantId); throw new TenantException("tenant.expired"); } diff --git a/fys-admin/src/main/resources/application.yml b/fys-admin/src/main/resources/application.yml index dbc7ca5..b99b5d2 100644 --- a/fys-admin/src/main/resources/application.yml +++ b/fys-admin/src/main/resources/application.yml @@ -39,6 +39,7 @@ logging: org.springframework: warn org.mybatis.spring.mapper: error org.apache.fury: warn + com.fuyuanshen.web.service.impl.ClientServiceImpl: debug config: classpath:logback-plus.xml # 用户配置 @@ -135,7 +136,7 @@ tenant: # https://baomidou.com/config/ mybatis-plus: # 自定义配置 是否全局开启逻辑删除 关闭后 所有逻辑删除功能将失效 - enableLogicDelete: true + enableLogicDelete: false # 多包名使用 例如 com.fuyuanshen.**.mapper,org.xxx.**.mapper mapperPackage: com.fuyuanshen.**.mapper # 对应的 XML 文件位置 @@ -213,6 +214,8 @@ springdoc: packages-to-scan: com.fuyuanshen.workflow - group: 设备管理模块 packages-to-scan: com.fuyuanshen.equipment + - group: 客户管理模块 + packages-to-scan: com.fuyuanshen.customer # 防止XSS攻击 xss: diff --git a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/TenantConstants.java b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/TenantConstants.java index c51e256..43839b2 100644 --- a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/TenantConstants.java +++ b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/TenantConstants.java @@ -22,6 +22,11 @@ public interface TenantConstants { */ String TENANT_ADMIN_ROLE_KEY = "admin"; + /** + * 富源晟内部员工 roleKey + */ + String FYS_ROLE_KEY = "fel"; + /** * 租户管理员角色名称 */ diff --git a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/PageResult.java b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/PageResult.java index 2ab8173..2d46205 100644 --- a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/PageResult.java +++ b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/PageResult.java @@ -18,7 +18,7 @@ import java.util.List; @AllArgsConstructor public class PageResult implements Serializable { - private List content; + private List rows; - private long totalElements; + private long total; } diff --git a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/model/LoginUser.java b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/model/LoginUser.java index f24e9f2..2f6260b 100644 --- a/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/model/LoginUser.java +++ b/fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/domain/model/LoginUser.java @@ -1,5 +1,6 @@ package com.fuyuanshen.common.core.domain.model; +import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import lombok.NoArgsConstructor; import com.fuyuanshen.common.core.domain.dto.PostDTO; @@ -31,6 +32,7 @@ public class LoginUser implements Serializable { * 用户ID */ private Long userId; + private Long pid; /** * 部门ID @@ -132,6 +134,11 @@ public class LoginUser implements Serializable { */ private String deviceType; + /** + * 用户等级 + */ + private Byte userLevel; + /** * 获取登录id */ diff --git a/fys-common/fys-common-encrypt/src/main/java/com/fuyuanshen/common/encrypt/utils/EncryptUtilsTest.java b/fys-common/fys-common-encrypt/src/main/java/com/fuyuanshen/common/encrypt/utils/EncryptUtilsTest.java index 04662bf..c81f353 100644 --- a/fys-common/fys-common-encrypt/src/main/java/com/fuyuanshen/common/encrypt/utils/EncryptUtilsTest.java +++ b/fys-common/fys-common-encrypt/src/main/java/com/fuyuanshen/common/encrypt/utils/EncryptUtilsTest.java @@ -39,8 +39,8 @@ public class EncryptUtilsTest { loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e"); loginBody.setGrantType("password"); loginBody.setTenantId("894078"); - loginBody.setCode("21"); - loginBody.setUuid("39785885a3ef42d59501502848cd1dcb"); + loginBody.setCode("0"); + loginBody.setUuid("1c285b27f516486f9535face77023aeb"); // loginBody.setUsername("admin"); // loginBody.setPassword("admin123"); loginBody.setUsername("dyf"); diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java new file mode 100644 index 0000000..df1098f --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/controller/equipment/APPDeviceController.java @@ -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> appDeviceList(@RequestBody APPDeviceQueryCriteria criteria) { + Page page = new Page<>(criteria.getPage(), criteria.getSize()); + PageResult 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> appTypeList(@RequestBody APPDeviceQueryCriteria criteria) { + List typeList = appDeviceService.appTypeList(criteria); + return ResponseVO.success(typeList); + } + + + @PostMapping(value = "/bind") + @Operation(summary = "APP客户设备绑定") + public ResponseVO appBindDevice(@RequestBody APPDeviceQueryCriteria criteria) { + appDeviceService.appBindDevice(criteria); + return ResponseVO.success("绑定成功!"); + } + + + @GetMapping + @Operation(summary = "WEB端查看APP客户设备绑定") + public ResponseVO> queryAPPDevice(APPDeviceQueryCriteria criteria) { + Page page = new Page<>(criteria.getPage(), criteria.getSize()); + PageResult 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 unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) { + appDeviceService.unbindAPPDevice(deviceForm); + return ResponseVO.success("解绑成功!!!"); + } + + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/APPDevice.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/APPDevice.java new file mode 100644 index 0000000..a7e1537 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/APPDevice.java @@ -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)); + } + + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/APPDeviceType.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/APPDeviceType.java new file mode 100644 index 0000000..ce56330 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/APPDeviceType.java @@ -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; + + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/dto/APPUnbindDTO.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/dto/APPUnbindDTO.java new file mode 100644 index 0000000..40dc18e --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/dto/APPUnbindDTO.java @@ -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; + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/query/APPDeviceQueryCriteria.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/query/APPDeviceQueryCriteria.java new file mode 100644 index 0000000..11d4411 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/query/APPDeviceQueryCriteria.java @@ -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 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 customerIds; + + @Schema(name = "当前所有者") + private Long currentOwnerId; + + @Schema(name = "租户ID") + private Long tenantId; + + @Schema(name = "通讯方式", example = "0:4G;1:蓝牙") + private Integer communicationMode; + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/mapper/equipment/APPDeviceMapper.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/mapper/equipment/APPDeviceMapper.java new file mode 100644 index 0000000..0ccf897 --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/mapper/equipment/APPDeviceMapper.java @@ -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 { + + /** + * APP用户设备列表 + * + * @param page + * @param criteria + * @return + */ + IPage appDeviceList(Page page,@Param("criteria") APPDeviceQueryCriteria criteria); + + + /** + * 分页查询APP/小程序设备 + * + * @param criteria + * @param page + * @return + */ + IPage queryAll(Page page, @Param("criteria") APPDeviceQueryCriteria criteria); + + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java new file mode 100644 index 0000000..3f7160d --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/equipment/APPDeviceService.java @@ -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 { + + /** + * APP用户设备列表 + * + * @param criteria + */ + PageResult appDeviceList(Page page, APPDeviceQueryCriteria criteria); + + + /** + * APP用户设备类型列表 + * + * @param criteria + * @return + */ + List appTypeList(APPDeviceQueryCriteria criteria); + + /** + * APP/小程序用户设备绑定 + * + * @param criteria + */ + void appBindDevice(APPDeviceQueryCriteria criteria); + + /** + * 分页查询APP/小程序设备绑定 + * + * @param criteria + * @param page + * @return + */ + PageResult queryAll(Page page, APPDeviceQueryCriteria criteria); + + /** + * APP/小程序用户设备解绑 + * + * @param deviceForm + */ + void unbindAPPDevice(APPUnbindDTO deviceForm); + + +} diff --git a/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java new file mode 100644 index 0000000..d5c659b --- /dev/null +++ b/fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/equipment/APPDeviceServiceImpl.java @@ -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 implements APPDeviceService { + + private final APPDeviceMapper appDeviceMapper; + + + /** + * APP用户设备列表 + * + * @param criteria + */ + @Override + public PageResult appDeviceList(Page page, APPDeviceQueryCriteria criteria) { + // criteria.setCustomerId(SecurityUtils.getCurrentUserId()); + // IPage devices = appDeviceMapper.appDeviceList(page, criteria); + // return new PageResult<>(devices.getRecords(), devices.getTotal()); + return null; + } + + + /** + * APP用户设备类型列表 + * + * @param criteria + * @return + */ + @Override + public List appTypeList(APPDeviceQueryCriteria criteria) { + // criteria.setCustomerId(SecurityUtils.getCurrentUserId()); + // return appDeviceTypeMapper.appTypeList(criteria); + return null; + } + + + /** + * APP/小程序用户设备绑定 + * + * @param criteria + */ + @Override + @Transactional + public void appBindDevice(APPDeviceQueryCriteria criteria) { + // + // List devices = new ArrayList<>(); + // + // if (criteria.getCommunicationMode().equals(CommunicationModeEnum.BLUETOOTH.getValue())) { + // devices = deviceMapper.selectList(new QueryWrapper().eq("device_mac", criteria.getDeviceMac())); + // if (CollectionUtil.isEmpty(devices)) { + // throw new BadRequestException("请先将设备入库!!!"); + // } + // List appDevices = appDeviceMapper.selectList(new QueryWrapper() + // .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().eq("device_imei", criteria.getDeviceImei())); + // if (CollectionUtil.isEmpty(devices)) { + // throw new BadRequestException("请先将设备入库!!!"); + // } + // List appDevices = appDeviceMapper.selectList(new QueryWrapper() + // .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 queryAll(Page page, APPDeviceQueryCriteria criteria) { + // IPage 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 queryWrapper = new QueryWrapper<>(); + // QueryWrapper 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 devices = deviceMapper.selectList(qw); + // List 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); + + } + + +} diff --git a/fys-modules/fys-app/src/main/resources/mapper/app/equipment/APPDeviceMapper.xml b/fys-modules/fys-app/src/main/resources/mapper/app/equipment/APPDeviceMapper.xml new file mode 100644 index 0000000..27b0ac9 --- /dev/null +++ b/fys-modules/fys-app/src/main/resources/mapper/app/equipment/APPDeviceMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fys-modules/fys-customer/pom.xml b/fys-modules/fys-customer/pom.xml new file mode 100644 index 0000000..7788bf9 --- /dev/null +++ b/fys-modules/fys-customer/pom.xml @@ -0,0 +1,117 @@ + + + + + com.fuyuanshen + fys-modules + ${revision} + + + 4.0.0 + fys-customer + + + 富源晟客户管理 + + + + + + com.fuyuanshen + fys-common-core + + + + com.fuyuanshen + fys-common-doc + + + + com.fuyuanshen + fys-common-mybatis + + + + com.fuyuanshen + fys-common-translation + + + + + com.fuyuanshen + fys-common-oss + + + + com.fuyuanshen + fys-common-log + + + + + com.fuyuanshen + fys-common-excel + + + + + com.fuyuanshen + fys-common-sms + + + + com.fuyuanshen + fys-common-tenant + + + + com.fuyuanshen + fys-common-security + + + + com.fuyuanshen + fys-common-web + + + + com.fuyuanshen + fys-common-idempotent + + + + com.fuyuanshen + fys-common-sensitive + + + + com.fuyuanshen + fys-common-encrypt + + + + com.fuyuanshen + fys-common-websocket + + + + com.fuyuanshen + fys-common-sse + + + + com.alibaba + easyexcel + 3.3.1 + + + poi-ooxml-schemas + org.apache.poi + + + + + + + diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/controller/CustomerController.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/controller/CustomerController.java new file mode 100644 index 0000000..b38095a --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/controller/CustomerController.java @@ -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 queryCustomer(UserQueryCriteria criteria) { + Page page = new Page<>(criteria.getPageNum(), criteria.getPageSize()); + return customerService.queryCustomers(criteria, page); + } + + + @GetMapping(value = "/allCustomer") + @Operation(summary = "查询所有客户") + public ResponseVO> queryAllCustomer(UserQueryCriteria criteria) { + List customers = customerService.queryAllCustomers(criteria); + return ResponseVO.success(customers); + } + + + // @Log("新增客户") + @Operation(summary = "新增客户") + @PostMapping(value = "/addCustomer") + public ResponseVO 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 updateCustomer(@RequestBody Customer resources) throws Exception { + customerService.updateCustomer(resources); + return ResponseVO.success(null); + } + + + // @Log("删除客户") + @Operation(summary = "删除客户") + @DeleteMapping(value = "/deleteCustomer") + public ResponseVO deleteCustomer(@RequestBody Set ids) throws BadRequestException { + if (CollectionUtil.isEmpty(ids)) { + throw new BadRequestException("请选择要删除的客户"); + } + customerService.delete(ids); + return ResponseVO.success(null); + } + + +} diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java new file mode 100644 index 0000000..9886065 --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/Customer.java @@ -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); + } + +} diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/query/UserQueryCriteria.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/query/UserQueryCriteria.java new file mode 100644 index 0000000..c454b4a --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/query/UserQueryCriteria.java @@ -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 ids; + + @Schema(name = "pid") + private Long pid; + + @Schema(name = "多个ID") + private Set deptIds = new HashSet<>(); + + @Schema(name = "模糊查询") + private String blurry; + + @Schema(name = "是否启用") + private Boolean enabled; + + @Schema(name = "部门ID") + private Long deptId; + + // @Schema(name = "创建时间") + // // private List 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; + +} diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/vo/ConsumerVo.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/vo/ConsumerVo.java new file mode 100644 index 0000000..d17971c --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/domain/vo/ConsumerVo.java @@ -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 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); + } + + +} diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/mapper/CustomerMapper.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/mapper/CustomerMapper.java new file mode 100644 index 0000000..831c46c --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/mapper/CustomerMapper.java @@ -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 { + + /** + * 分页查询客户 + * + * @param criteria + * @return + */ + List findCustomers(@Param("criteria") UserQueryCriteria criteria); + + /** + * 获取分页总数 + * + * @param criteria + * @return + */ + Long countCustomers(@Param("criteria") UserQueryCriteria criteria); + + + /** + * 查询所有客户 + * + * @param criteria + * @return + */ + List queryAllCustomers(@Param("criteria") UserQueryCriteria criteria); + + /** + * 根据条件查询客户 + * + * @param criteria + * @return + */ + List queryCustomers(@Param("criteria") UserQueryCriteria criteria); + + /** + * 根据id查询客户 + * + * @param customerId + * @return + */ + Customer queryCustomerById(@Param("customerId") Long customerId, @Param("pid") Long pid); + + +} diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/CustomerService.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/CustomerService.java new file mode 100644 index 0000000..98ccd3a --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/CustomerService.java @@ -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 queryCustomers(UserQueryCriteria criteria, Page page); + + /** + * 查询所有客户 + * + * @param criteria + * @return + */ + List 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 ids); + + +} diff --git a/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java new file mode 100644 index 0000000..5eb7705 --- /dev/null +++ b/fys-modules/fys-customer/src/main/java/com/fuyuanshen/customer/service/impl/CustomerServiceImpl.java @@ -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 implements CustomerService { + + private final CustomerMapper customerMapper; + + + /** + * 分页查询客户 + * + * @param criteria + * @param page + * @return + */ + @Override + public TableDataInfo queryCustomers(UserQueryCriteria criteria, Page page) { + criteria.setOffset(page.offset()); + criteria.setPid(LoginHelper.getUserId()); + List users = customerMapper.findCustomers(criteria); + List consumerVoList = BeanUtil.copyToList(users, ConsumerVo.class); + Long total = customerMapper.countCustomers(criteria); + // return PageUtil.toPage(consumerVoList, total); + return new TableDataInfo(consumerVoList, total); + } + + + /** + * 查询所有客户 + * + * @param criteria + * @return + */ + @Override + public List queryAllCustomers(UserQueryCriteria criteria) { + List 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 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 ids) { + customerMapper.deleteByIds(ids); + } + + +} diff --git a/fys-modules/fys-customer/src/main/resources/application.properties b/fys-modules/fys-customer/src/main/resources/application.properties new file mode 100644 index 0000000..08e63d2 --- /dev/null +++ b/fys-modules/fys-customer/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=fys-customer diff --git a/fys-modules/fys-customer/src/main/resources/mapper/customer/CustomerMapper.xml b/fys-modules/fys-customer/src/main/resources/mapper/customer/CustomerMapper.xml new file mode 100644 index 0000000..98d2817 --- /dev/null +++ b/fys-modules/fys-customer/src/main/resources/mapper/customer/CustomerMapper.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + 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 + + + + 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 + + + + j + . + job_id + as job_id, j.name as job_name + + + + r + . + role_id + as role_id, r.name as role_name, r.level as role_level, r.data_scope as role_data_scope + + + + + + and u1.user_id = #{criteria.id} + + + and u1.enabled = #{criteria.enabled} + + + and u1.dept_id in + + #{deptId} + + + + and ( + u1.user_name like concat('%', #{criteria.blurry}, '%') + or u1.nick_name like concat('%', #{criteria.blurry}, '%') + or u1.email like concat('%', #{criteria.blurry}, '%') + ) + + + and u1.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]} + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fys-modules/fys-customer/web2/WEB-INF/web.xml b/fys-modules/fys-customer/web2/WEB-INF/web.xml new file mode 100644 index 0000000..d80081d --- /dev/null +++ b/fys-modules/fys-customer/web2/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/fys-modules/fys-equipment/pom.xml b/fys-modules/fys-equipment/pom.xml index ca320b0..87cc0b3 100644 --- a/fys-modules/fys-equipment/pom.xml +++ b/fys-modules/fys-equipment/pom.xml @@ -38,6 +38,11 @@ fys-common-translation + + com.fuyuanshen + fys-system + + com.fuyuanshen @@ -101,16 +106,22 @@ fys-common-sse + + + com.fuyuanshen + fys-customer + + com.alibaba easyexcel 3.3.1 - - - poi-ooxml-schemas - org.apache.poi - - + + + + org.apache.poi + ooxml-schemas + 1.4 diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java index 663006c..d1cfb59 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java @@ -3,14 +3,17 @@ package com.fuyuanshen.equipment.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.mybatis.core.page.TableDataInfo; import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.dto.ImportResult; import com.fuyuanshen.equipment.domain.form.DeviceForm; import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; import com.fuyuanshen.equipment.domain.vo.CustomerVo; 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.Parameter; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -37,21 +40,17 @@ import java.util.List; @RequestMapping("/api/device") public class DeviceController { + private final ISysOssService ossService; private final DeviceService deviceService; + private final DeviceExportService exportService; + @Operation(summary = "分页查询设备列表", security = {@SecurityRequirement(name = "bearer-key")}) @GetMapping - public ResponseVO> queryDevice(DeviceQueryCriteria criteria) { - Page page = new Page<>(criteria.getPage(), criteria.getSize()); - PageResult devices = null; - try { - devices = deviceService.queryAll(criteria, page); - } catch (IOException e) { - log.error("queryDevice error: " + e.getMessage()); - return ResponseVO.fail(""); - } - return ResponseVO.success(devices); + public TableDataInfo queryDevice(DeviceQueryCriteria criteria) throws IOException { + Page page = new Page<>(criteria.getPage(), criteria.getSize()); + return deviceService.queryAll(criteria, page); } @@ -97,7 +96,6 @@ public class DeviceController { @DeleteMapping(value = "/delete") public ResponseVO deleteDevice(@Parameter(name = "传ID数组[]") @RequestBody List ids) { deviceService.deleteAll(ids); - // deviceService.deleteAssign(ids); return ResponseVO.success(ResponseMessageConstants.DELETE_SUCCESS); } @@ -120,7 +118,7 @@ public class DeviceController { // @Log("撤回设备") - @Operation(summary = "撤回设备") + @Operation(summary = "撤回分配设备") @PostMapping(value = "/withdraw") public ResponseVO withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) { try { @@ -151,7 +149,8 @@ public class DeviceController { @Operation(summary = "导出数据设备") @GetMapping(value = "/download") public void exportDevice(HttpServletResponse response, DeviceQueryCriteria criteria) throws IOException { - + List devices = deviceService.queryAll(criteria); + exportService.export(devices, response); } @@ -159,6 +158,8 @@ public class DeviceController { @PostMapping(value = "/import", consumes = "multipart/form-data") public ResponseVO importData(@Parameter(name = "文件", required = true) @RequestPart("file") MultipartFile file) { + SysOssVo upload = ossService.upload(file); + // String suffix = FileUtil.getExtensionName(file.getOriginalFilename()); // if (!("xlsx".equalsIgnoreCase(suffix))) { // throw new BadRequestException("只能上传Excel——xlsx格式文件"); diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceTypeController.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceTypeController.java index dccdb61..100a44c 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceTypeController.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceTypeController.java @@ -1,17 +1,16 @@ package com.fuyuanshen.equipment.controller; 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.mybatis.core.page.TableDataInfo; import com.fuyuanshen.equipment.domain.DeviceType; +import com.fuyuanshen.equipment.domain.form.DeviceTypeForm; import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria; import com.fuyuanshen.equipment.service.DeviceTypeService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -33,9 +32,9 @@ public class DeviceTypeController { @GetMapping @Operation(summary = "分页查询设备类型") - public ResponseVO> queryDeviceType(DeviceTypeQueryCriteria criteria) { - Page page = new Page<>(criteria.getPage(), criteria.getSize()); - return ResponseVO.success(deviceTypeService.queryAll(criteria, page)); + public TableDataInfo queryDeviceType(DeviceTypeQueryCriteria criteria) { + Page page = new Page<>(criteria.getPage(), criteria.getSize()); + return deviceTypeService.queryAll(criteria, page); } @@ -59,7 +58,7 @@ public class DeviceTypeController { // @Log("修改设备类型") @Operation(summary = "修改设备类型") @PutMapping(value = "/update") - public ResponseVO updateDeviceType(@Validated @RequestBody DeviceType resources) { + public ResponseVO updateDeviceType(@Validated @RequestBody DeviceTypeForm resources) { deviceTypeService.update(resources); return ResponseVO.success(null); } @@ -68,17 +67,16 @@ public class DeviceTypeController { // @Log("删除设备类型") @Operation(summary = "删除设备类型") @DeleteMapping(value = "/delete") - public ResponseEntity deleteDeviceType(@Parameter(name = "传ID数组[]") @RequestBody List ids) { + public ResponseVO deleteDeviceType(@Parameter(name = "传ID数组[]") @RequestBody List ids) { deviceTypeService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseVO.success("删除成功!!!"); } @GetMapping(value = "/communicationMode") @Operation(summary = "获取设备类型通讯方式") public ResponseVO getCommunicationMode(@Parameter(name = "设备类型ID", required = true) Long id) { - return ResponseVO.success(deviceTypeService.getById(id)); + return ResponseVO.success(deviceTypeService.getCommunicationMode(id)); } - } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/converter/IgnoreFailedImageConverter.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/converter/IgnoreFailedImageConverter.java new file mode 100644 index 0000000..650bec9 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/converter/IgnoreFailedImageConverter.java @@ -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 { + 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(); + } +} \ No newline at end of file diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/converter/ImageReadConverter.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/converter/ImageReadConverter.java new file mode 100644 index 0000000..3e6d12f --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/converter/ImageReadConverter.java @@ -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 { +// +// @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; +// } +// } \ No newline at end of file diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java index 127316b..5536e1b 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/Device.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonInclude; import com.fuyuanshen.common.tenant.core.TenantEntity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** @@ -17,83 +18,77 @@ import lombok.Data; **/ @Data @TableName("device") -@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解 +@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解 public class Device extends TenantEntity { @TableId(value = "id", type = IdType.AUTO) - // @Schema(value = "ID") + @Schema(name = "ID") private Long id; - // @Schema(value = "设备记录ID") + @Schema(name = "设备记录ID") @TableField(exist = false) private Long assignId; - // @Schema(value = "设备类型") + @Schema(name = "设备类型") private Long deviceType; - // @Schema(value = "设备类型名称") + @Schema(name = "设备类型名称") private String typeName; - // @Schema(value = "客户号") + @Schema(name = "客户号") private Long customerId; + @Schema(name = "所属客户") + private String customerName; + /** * 当前所有者 * current_owner_id */ - // @Schema(value = "当前所有者") + @Schema(name = "当前所有者") private Long currentOwnerId; /** * 原始所有者(创建者) * original_owner_id */ - // @Schema(value = "原始所有者(创建者)") + @Schema(name = "原始所有者(创建者)") private Long originalOwnerId; - // @Schema(value = "所属客户") - private String customerName; - /*@Schema(value = "设备编号") + /*@Schema( name = "设备编号") private String deviceNo;*/ - // @Schema(value = "设备名称") + @Schema(name = "设备名称") private String deviceName; - // @Schema(value = "设备图片") + @Schema(name = "设备图片") private String devicePic; - // @Schema(value = "设备MAC") + @Schema(name = "设备MAC") private String deviceMac; - // @Schema(value = "设备IMEI") + @Schema(name = "设备IMEI") private String deviceImei; - // @Schema(value = "设备SN") + @Schema(name = "设备SN") private String deviceSn; - // @Schema(value = "经度") + @Schema(name = "经度") private String longitude; - // @Schema(value = "纬度") + @Schema(name = "纬度") private String latitude; - // @Schema(value = "备注") + @Schema(name = "备注") private String remark; - /** - * 租户ID - */ - // @TableField(value = "tenant_id") - // // @Schema(hidden = true) - // private Long tenantId; - /** * 设备状态 * 0 失效 * 1 正常 */ - // @Schema(value = "设备状态") + @Schema(name = "设备状态") private Integer deviceStatus; /** @@ -101,12 +96,13 @@ public class Device extends TenantEntity { * 0 未绑定 * 1 已绑定 */ - // @Schema(value = "绑定状态") + @Schema(name = "绑定状态") private Integer bindingStatus; - public void copy(Device source) { - BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); - } + /** + * 创建人名称 + */ + private String createByName; } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceType.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceType.java index 075d305..66fdb0d 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceType.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceType.java @@ -2,9 +2,7 @@ package com.fuyuanshen.equipment.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.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import com.fuyuanshen.common.tenant.core.TenantEntity; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; @@ -45,6 +43,10 @@ public class DeviceType extends TenantEntity { @Schema(name = "通讯方式", example = "0:4G;1:蓝牙") private String communicationMode; + /** + * 创建人名称 + */ + private String createByName; public void copy(DeviceType source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/DeviceExcelExportDTO.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/DeviceExcelExportDTO.java new file mode 100644 index 0000000..28aa32c --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/dto/DeviceExcelExportDTO.java @@ -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; + +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceForm.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceForm.java index 77713ed..d1c7187 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceForm.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceForm.java @@ -21,7 +21,7 @@ public class DeviceForm { private Long assignId; @Schema(title = "设备类型") - private Long deviceType; + private Long deviceTypeId; @Schema(title = "客户号") private Long customerId; diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java new file mode 100644 index 0000000..d416718 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java @@ -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; + +} diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java index 18f86d0..6a098ab 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java @@ -1,5 +1,6 @@ package com.fuyuanshen.equipment.domain.query; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.sql.Timestamp; @@ -16,19 +17,22 @@ import java.util.Set; @Data public class DeviceQueryCriteria { - // @Schema(value = "设备名称") + @Schema(name = "设备id") + private Long deviceId; + + @Schema(name = "设备名称") private String deviceName; - // @Schema(value = "设备类型") - private Long deviceType; + @Schema(name = "设备类型") + private Long deviceTypeId; - // @Schema(value = "设备MAC") + @Schema(name = "设备MAC") private String deviceMac; - // @Schema(value = "设备IMEI") + @Schema(name = "设备IMEI") private String deviceImei; - // @Schema(value = "设备SN") + @Schema(name = "设备SN") private String deviceSn; /** @@ -36,29 +40,29 @@ public class DeviceQueryCriteria { * 0 失效 * 1 正常 */ - // @Schema(value = "设备状态 0 失效 1 正常 ") + @Schema(name = "设备状态 0 失效 1 正常 ") private Integer deviceStatus; - // @Schema(value = "创建时间") + @Schema(name = "创建时间") private List createTime; - // @Schema(value = "页码", example = "1") + @Schema(name = "页码", example = "1") private Integer page = 1; - // @Schema(value = "每页数据量", example = "10") + @Schema(name = "每页数据量", example = "10") private Integer size = 10; - // @Schema(value = "客户id") + @Schema(name = "客户id") private Long customerId; private Set customerIds; - // @Schema(value = "当前所有者") + @Schema(name = "当前所有者") private Long currentOwnerId; - // @Schema(value = "租户ID") + @Schema(name = "租户ID") private Long tenantId; - // @Schema(value = "通讯方式", example = "0:4G;1:蓝牙") + @Schema(name = "通讯方式", example = "0:4G;1:蓝牙") private Integer communicationMode; } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceTypeQueryCriteria.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceTypeQueryCriteria.java index 67b6049..9d2010e 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceTypeQueryCriteria.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceTypeQueryCriteria.java @@ -15,6 +15,9 @@ import java.util.Set; @Data public class DeviceTypeQueryCriteria extends BaseEntity implements Serializable { + @Schema(name = "设备类型id") + private Long deviceTypeId; + @Schema(name = "型号名称") private String typeName; diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceMapper.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceMapper.java index 1cccbca..c473541 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceMapper.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceMapper.java @@ -25,7 +25,7 @@ public interface DeviceMapper extends BaseMapper { * @param page * @return */ - IPage findAll(@Param("criteria") DeviceQueryCriteria criteria, Page page); + IPage findAll(@Param("criteria") DeviceQueryCriteria criteria, Page page); List findAll(@Param("criteria") DeviceQueryCriteria criteria); diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceTypeMapper.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceTypeMapper.java index 7efd78d..15f0fd1 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceTypeMapper.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/mapper/DeviceTypeMapper.java @@ -25,7 +25,7 @@ public interface DeviceTypeMapper extends BaseMapper { * @param page * @return */ - IPage findAll(@Param("criteria") DeviceTypeQueryCriteria criteria, Page page); + IPage findAll(@Param("criteria") DeviceTypeQueryCriteria criteria, Page page); /** diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceService.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceService.java index fec0c52..4990517 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceService.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceService.java @@ -3,6 +3,7 @@ package com.fuyuanshen.equipment.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; 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.form.DeviceForm; import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria; @@ -25,7 +26,15 @@ public interface DeviceService extends IService { * @param page 分页参数 * @return PageResult */ - PageResult queryAll(DeviceQueryCriteria criteria, Page page) throws IOException; + TableDataInfo queryAll(DeviceQueryCriteria criteria, Page page) throws IOException; + + /** + * 查询所有数据不分页 + * + * @param criteria 条件参数 + * @return List + */ + List queryAll(DeviceQueryCriteria criteria); /** * 查询所有设备信息 diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeService.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeService.java index 81ed641..aa2b622 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeService.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/DeviceTypeService.java @@ -3,7 +3,9 @@ package com.fuyuanshen.equipment.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; 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.form.DeviceTypeForm; import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria; import java.util.List; @@ -22,7 +24,7 @@ public interface DeviceTypeService extends IService { * @param page 分页参数 * @return PageResult */ - PageResult queryAll(DeviceTypeQueryCriteria criteria, Page page); + TableDataInfo queryAll(DeviceTypeQueryCriteria criteria, Page page); /** * 查询所有数据不分页 @@ -51,7 +53,7 @@ public interface DeviceTypeService extends IService { * * @param resources / */ - void update(DeviceType resources); + void update(DeviceTypeForm resources); /** * 多选删除 @@ -60,4 +62,11 @@ public interface DeviceTypeService extends IService { */ void deleteAll(List ids); + /** + * 获取设备类型通讯方式 + * + * @param id / + * @return DeviceTypeDto + */ + DeviceType getCommunicationMode(Long id); } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceExportService.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceExportService.java new file mode 100644 index 0000000..22650e3 --- /dev/null +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceExportService.java @@ -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 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 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); + } + } + +} \ No newline at end of file diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java index a51b8d8..df9f271 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java @@ -1,19 +1,26 @@ package com.fuyuanshen.equipment.service.impl; 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.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.fuyuanshen.common.core.domain.PageResult; -import com.fuyuanshen.common.core.utils.PageUtil; +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.mapper.CustomerMapper; import com.fuyuanshen.equipment.constants.DeviceConstants; import com.fuyuanshen.equipment.domain.Device; +import com.fuyuanshen.equipment.domain.DeviceType; import com.fuyuanshen.equipment.domain.form.DeviceForm; 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.mapper.DeviceMapper; +import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; import com.fuyuanshen.equipment.service.DeviceService; +import com.fuyuanshen.system.domain.vo.SysOssVo; +import com.fuyuanshen.system.service.ISysOssService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -24,7 +31,9 @@ import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.IOException; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @Description: @@ -41,8 +50,12 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Value("${file.device.ip}") private String ip; - 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 impleme * @throws IOException */ @Override - public PageResult queryAll(DeviceQueryCriteria criteria, Page page) throws IOException { + public TableDataInfo queryAll(DeviceQueryCriteria criteria, Page page) throws IOException { + // criteria.setCustomerId(LoginHelper.getUserId()); + criteria.setCurrentOwnerId(LoginHelper.getUserId()); IPage devices = deviceMapper.findAll(criteria, page); List records = devices.getRecords(); @@ -65,7 +80,14 @@ public class DeviceServiceImpl extends ServiceImpl impleme } } - return PageUtil.toPage(devices); + // return PageUtil.toPage(devices); + return new TableDataInfo(records, devices.getTotal()); + } + + + @Override + public List queryAll(DeviceQueryCriteria criteria) { + return deviceMapper.findAll(criteria); } @@ -90,17 +112,25 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Override @Transactional(rollbackFor = Exception.class) public void addDevice(DeviceForm deviceForm) throws Exception { - - // 获取当前登录用户信息 - // LoginUser user = LoginHelper.getLoginUser(); + DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria(); + queryCriteria.setDeviceTypeId(deviceForm.getId()); + queryCriteria.setCustomerId(LoginHelper.getUserId()); + List deviceTypes = deviceTypeMapper.findAll(queryCriteria); + if (deviceTypes.isEmpty()) { + throw new Exception("设备类型不存在!!!"); + } // 保存图片并获取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(); + LoginUser loginUser = LoginHelper.getLoginUser(); + device.setCurrentOwnerId(loginUser.getUserId()); + device.setCreateByName(loginUser.getNickname()); BeanUtil.copyProperties(deviceForm, device, true); deviceMapper.insert(device); @@ -118,14 +148,28 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Transactional(rollbackFor = Exception.class) public void update(DeviceForm deviceForm) throws Exception { - Device device = getById(deviceForm.getId()); - if (device == null) { - throw new Exception("设备不存在!!!"); + DeviceTypeQueryCriteria deviceTypeQueryCriteria = new DeviceTypeQueryCriteria(); + deviceTypeQueryCriteria.setDeviceTypeId(deviceForm.getId()); + deviceTypeQueryCriteria.setCustomerId(LoginHelper.getUserId()); + List deviceTypes = deviceTypeMapper.findAll(deviceTypeQueryCriteria); + if (deviceTypes.isEmpty()) { + throw new Exception("设备类型不存在!!!"); } + DeviceQueryCriteria queryCriteria = new DeviceQueryCriteria(); + queryCriteria.setDeviceId(deviceForm.getId()); + queryCriteria.setCustomerId(LoginHelper.getUserId()); + List devices = deviceMapper.findAll(queryCriteria); + if (devices.isEmpty()) { + throw new Exception("设备不存在!!!"); + } + Device device = devices.get(0); + // 处理上传的图片 - String imageUrl = saveDeviceImage(deviceForm.getFile(), device.getDeviceName()); - deviceForm.setDevicePic(imageUrl); + // String imageUrl = saveDeviceImage(deviceForm.getFile(), device.getDeviceName()); + SysOssVo upload = ossService.upload(deviceForm.getFile()); + // 设置图片路径 + deviceForm.setDevicePic(upload.getUrl()); // 更新字段 BeanUtil.copyProperties(deviceForm, device, true); @@ -171,6 +215,18 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Override @Transactional(rollbackFor = Exception.class) public void deleteAll(List ids) { + List 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); } @@ -183,7 +239,46 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Override @Transactional(rollbackFor = Exception.class) public void assignCustomer(CustomerVo customerVo) { + List deviceIds = customerVo.getDeviceIds(); + Long customerId = customerVo.getCustomerId(); + Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid()); + if (customer == null) { + throw new RuntimeException("待分配的客户不存在!!!"); + } + + List invalidIds = new ArrayList<>(); + List 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 deviceIds) { } @@ -212,6 +307,4 @@ public class DeviceServiceImpl extends ServiceImpl impleme } - - } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java index a064039..7c607d3 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceTypeServiceImpl.java @@ -1,11 +1,18 @@ 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.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.equipment.domain.Device; 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.mapper.DeviceMapper; import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; @@ -14,7 +21,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @Description: @@ -37,8 +46,11 @@ public class DeviceTypeServiceImpl extends ServiceImpl queryAll(DeviceTypeQueryCriteria criteria, Page page) { - return PageUtil.toPage(deviceTypeMapper.findAll(criteria, page)); + public TableDataInfo queryAll(DeviceTypeQueryCriteria criteria, Page page) { + criteria.setCustomerId(LoginHelper.getUserId()); + // return + IPage deviceTypeIPage = deviceTypeMapper.findAll(criteria, page); + return new TableDataInfo(deviceTypeIPage.getRecords(), deviceTypeIPage.getTotal()); } @@ -70,9 +82,10 @@ public class DeviceTypeServiceImpl extends ServiceImpl 0) + // throw new RuntimeException("该设备类型已被使用,无法删除"); + BeanUtil.copyProperties(resources, deviceType); + deviceTypeMapper.updateById(deviceType); } @@ -97,8 +120,49 @@ public class DeviceTypeServiceImpl extends ServiceImpl ids) { + + List invalidIds = new ArrayList<>(); + List 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 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); } + /** + * 获取设备类型通讯方式 + * + * @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; + } + + } diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 82c5ace..8879dae 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -38,15 +38,9 @@ - -