新增设备分组
This commit is contained in:
@ -0,0 +1,96 @@
|
||||
package com.fuyuanshen;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class CorrectVCardGenerator {
|
||||
public static void main(String[] args) {
|
||||
// // 定义江西上饶的134号段(共22个)
|
||||
// String[] prefixes = {
|
||||
// "1340703", "1340793", "1342650", "1342651", "1342663",
|
||||
// "1342664", "1342665", "1343703", "1343793", "1347901",
|
||||
// "1347902", "1347903", "1347930", "1347931", "1347932",
|
||||
// "1347933", "1347934", "1347935", "1347936", "1347937",
|
||||
// "1347938", "1347939"
|
||||
// }; 1340700 号段(移动)
|
||||
// 1340708 号段(移动)
|
||||
// 1340709 号段(移动)
|
||||
// 1340791 号段(移动)
|
||||
// 1342668 号段(移动)
|
||||
// 1343700 号段(移动)
|
||||
// 1343708 号段(移动)
|
||||
// 1343709 号段(移动)
|
||||
// 1343790 号段(移动)
|
||||
// 1343791 号段(移动)
|
||||
// 1347910 号段(移动)
|
||||
// 1347911 号段(移动)
|
||||
// 1347912 号段(移动)
|
||||
// 1347913 号段(移动)
|
||||
// 1347914 号段(移动)
|
||||
// 1347915 号段(移动)
|
||||
// 1347916 号段(移动)
|
||||
// 1347917 号段(移动)
|
||||
// 1347918 号段(移动)
|
||||
// 1347919 号段(移动)
|
||||
|
||||
// 定义江西南昌的134号段(共22个)
|
||||
String[] prefixes = {
|
||||
"1340700", "1340708", "1340709", "1340791", "1342668",
|
||||
"1343700", "1343708", "1343709", "1343790", "1343791",
|
||||
"1347910", "1347911", "1347912", "1347913", "1347914",
|
||||
"1347915", "1347916", "1347917", "1347918", "1347919"
|
||||
};
|
||||
|
||||
// 创建.vcf文件
|
||||
String filename = "南昌联系人.vcf";
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filename))) {
|
||||
// 生成所有联系人
|
||||
int count = 0;
|
||||
for (String prefix : prefixes) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String middle = String.format("%02d", i);
|
||||
String phoneNumber = prefix + middle + "51";
|
||||
|
||||
// 每个联系人以BEGIN:VCARD开始
|
||||
writer.write("BEGIN:VCARD");
|
||||
writer.newLine();
|
||||
writer.write("VERSION:3.0");
|
||||
writer.newLine();
|
||||
|
||||
// 中文姓名(用户+序号)
|
||||
writer.write("FN:用户" + (count + 1));
|
||||
writer.newLine();
|
||||
|
||||
// 手机号码
|
||||
writer.write("TEL;TYPE=CELL;TYPE=VOICE:" + phoneNumber);
|
||||
writer.newLine();
|
||||
|
||||
// 添加唯一标识符
|
||||
writer.write("UID:" + phoneNumber + "@shangrao");
|
||||
writer.newLine();
|
||||
|
||||
// 添加备注信息
|
||||
writer.write("NOTE:生成于" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
|
||||
writer.newLine();
|
||||
|
||||
// 每个联系人以END:VCARD结束
|
||||
writer.write("END:VCARD");
|
||||
writer.newLine();
|
||||
writer.newLine(); // 联系人之间空一行
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("成功生成 " + count + " 个联系人");
|
||||
System.out.println("文件已保存为: " + filename);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("文件写入错误: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.fuyuanshen.web;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class ChineseVCardGenerator {
|
||||
public static void main(String[] args) {
|
||||
// 定义江西上饶的134号段(共22个)
|
||||
String[] prefixes = {
|
||||
"1340703", "1340793", "1342650", "1342651", "1342663",
|
||||
"1342664", "1342665", "1343703", "1343793", "1347901",
|
||||
"1347902", "1347903", "1347930", "1347931", "1347932",
|
||||
"1347933", "1347934", "1347935", "1347936", "1347937",
|
||||
"1347938", "1347939"
|
||||
};
|
||||
|
||||
// 创建.vcf文件
|
||||
String filename = "上饶联系人.vcf";
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filename, true))) {
|
||||
// 添加文件头信息(包含中文)
|
||||
writer.write("BEGIN:VCARD");
|
||||
writer.newLine();
|
||||
writer.write("VERSION:3.0");
|
||||
writer.newLine();
|
||||
writer.write("X-GENERATOR:Java VCard Generator");
|
||||
writer.newLine();
|
||||
writer.write("PRODID:-//Apple Inc.//iPhone OS 15.6//EN");
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
|
||||
// 生成所有联系人
|
||||
int count = 0;
|
||||
for (String prefix : prefixes) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String middle = String.format("%02d", i);
|
||||
String phoneNumber = prefix + middle + "51";
|
||||
|
||||
// 写入单个联系人(使用中文)
|
||||
writer.write("FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:用户" + (count + 1)); // 中文姓名
|
||||
writer.newLine();
|
||||
writer.write("TEL;TYPE=CELL;CHARSET=UTF-8:" + phoneNumber); // 手机号
|
||||
writer.newLine();
|
||||
writer.write("NOTE;CHARSET=UTF-8:生成时间 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
|
||||
writer.newLine();
|
||||
writer.write("END:VCARD");
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("成功生成 " + count + " 个中文联系人");
|
||||
System.out.println("文件已保存为: " + filename);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("文件写入错误: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.fuyuanshen.web;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PhoneNumberGenerator {
|
||||
public static void main(String[] args) {
|
||||
// 定义江西上饶的134号段(共22个)
|
||||
String[] prefixes = {
|
||||
"1340703", "1340793", "1342650", "1342651", "1342663",
|
||||
"1342664", "1342665", "1343703", "1343793", "1347901",
|
||||
"1347902", "1347903", "1347930", "1347931", "1347932",
|
||||
"1347933", "1347934", "1347935", "1347936", "1347937",
|
||||
"1347938", "1347939"
|
||||
};
|
||||
|
||||
// 输出到控制台
|
||||
System.out.println("江西上饶134号段完整手机号码(共2200个):");
|
||||
for (String prefix : prefixes) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String middle = String.format("%02d", i); // 生成00-99的中间数字
|
||||
System.out.println(prefix + middle + "51");
|
||||
}
|
||||
}
|
||||
|
||||
// 同时输出到文件(可选)
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter("shangrao_phones.txt"))) {
|
||||
for (String prefix : prefixes) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String middle = String.format("%02d", i);
|
||||
writer.write(prefix + middle + "51");
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
System.out.println("\n同时已保存到文件:shangrao_phones.txt");
|
||||
} catch (IOException e) {
|
||||
System.err.println("文件写入错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.fuyuanshen.web;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class VCardGenerator {
|
||||
public static void main(String[] args) {
|
||||
// 定义江西上饶的134号段(共22个)
|
||||
String[] prefixes = {
|
||||
"1340703", "1340793", "1342650", "1342651", "1342663",
|
||||
"1342664", "1342665", "1343703", "1343793", "1347901",
|
||||
"1347902", "1347903", "1347930", "1347931", "1347932",
|
||||
"1347933", "1347934", "1347935", "1347936", "1347937",
|
||||
"1347938", "1347939"
|
||||
};
|
||||
|
||||
// 创建.vcf文件
|
||||
String filename = "shangrao_contacts.vcf";
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filename))) {
|
||||
// 写入文件头
|
||||
writer.write("BEGIN:VCARD");
|
||||
writer.newLine();
|
||||
writer.write("VERSION:3.0");
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
|
||||
// 生成所有联系人
|
||||
int count = 0;
|
||||
for (String prefix : prefixes) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String middle = String.format("%02d", i);
|
||||
String phoneNumber = prefix + middle + "51";
|
||||
|
||||
// 写入单个联系人
|
||||
writer.write("FN:" + phoneNumber); // 姓名字段使用手机号
|
||||
writer.newLine();
|
||||
writer.write("TEL;TYPE=CELL:" + phoneNumber); // 电话字段使用手机号
|
||||
writer.newLine();
|
||||
writer.write("END:VCARD");
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// 写入文件尾
|
||||
writer.write("END:VCARD");
|
||||
|
||||
System.out.println("成功生成 " + count + " 个联系人");
|
||||
System.out.println("文件已保存为: " + filename);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("文件写入错误: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.fuyuanshen.equipment.controller;
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -11,7 +11,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
@ -30,11 +29,12 @@ import com.fuyuanshen.equipment.service.IDeviceGroupService;
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/fys-equipment/group")
|
||||
@RequestMapping("/api/device/group")
|
||||
public class DeviceGroupController extends BaseController {
|
||||
|
||||
private final IDeviceGroupService deviceGroupService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备分组列表
|
||||
*/
|
||||
@ -64,10 +64,11 @@ public class DeviceGroupController extends BaseController {
|
||||
@SaCheckPermission("fys-equipment:group:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<DeviceGroupVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
@PathVariable Long id) {
|
||||
return R.ok(deviceGroupService.queryById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增设备分组
|
||||
*/
|
||||
@ -79,6 +80,7 @@ public class DeviceGroupController extends BaseController {
|
||||
return toAjax(deviceGroupService.insertByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备分组
|
||||
*/
|
||||
@ -98,8 +100,8 @@ public class DeviceGroupController extends BaseController {
|
||||
@SaCheckPermission("fys-equipment:group:remove")
|
||||
@Log(title = "设备分组", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
return toAjax(deviceGroupService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.fuyuanshen.equipment.domain.bo;
|
||||
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.equipment.domain.DeviceGroup;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
@ -21,7 +23,7 @@ public class DeviceGroupBo extends BaseEntity {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
|
||||
// @NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -33,7 +35,7 @@ public class DeviceGroupBo extends BaseEntity {
|
||||
/**
|
||||
* 状态:0-禁用,1-正常
|
||||
*/
|
||||
@NotNull(message = "状态:0-禁用,1-正常不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
// @NotNull(message = "状态:0-禁用,1-正常不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
@ -49,7 +51,7 @@ public class DeviceGroupBo extends BaseEntity {
|
||||
/**
|
||||
* 删除标记:0-未删除,1-已删除
|
||||
*/
|
||||
@NotNull(message = "删除标记:0-未删除,1-已删除不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
// @NotNull(message = "删除标记:0-未删除,1-已删除不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long isDeleted;
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fuyuanshen.equipment.domain.bo;
|
||||
|
||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.equipment.domain.DeviceRepairRecords;
|
||||
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
|
@ -11,7 +11,7 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -64,5 +64,9 @@ public class DeviceGroupVo implements Serializable {
|
||||
@ExcelProperty(value = "删除标记:0-未删除,1-已删除")
|
||||
private Long isDeleted;
|
||||
|
||||
/**
|
||||
* 嵌套子分组
|
||||
*/
|
||||
private List<DeviceGroupVo> children;
|
||||
|
||||
}
|
||||
|
@ -66,4 +66,5 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
* @return
|
||||
*/
|
||||
List<Device> findByOriginalDeviceId(Long originalDeviceId);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -37,7 +39,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
* @return 设备分组
|
||||
*/
|
||||
@Override
|
||||
public DeviceGroupVo queryById(Long id){
|
||||
public DeviceGroupVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增设备分组
|
||||
*
|
||||
@ -74,8 +77,21 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DeviceGroupBo bo) {
|
||||
|
||||
// 验证分组名称唯一性
|
||||
DeviceGroup deviceGroup = baseMapper.selectOne(new QueryWrapper<DeviceGroup>().eq("group_name", bo.getGroupName()));
|
||||
if (deviceGroup != null) {
|
||||
throw new RuntimeException("分组名称已存在,请勿重复添加");
|
||||
}
|
||||
|
||||
// 验证父分组是否存在(如果提供了parentId)
|
||||
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
|
||||
if (bo.getParentId() != null && pDeviceGroup == null) {
|
||||
throw new RuntimeException("父分组不存在");
|
||||
}
|
||||
|
||||
DeviceGroup add = MapstructUtils.convert(bo, DeviceGroup.class);
|
||||
validEntityBeforeSave(add);
|
||||
// validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
@ -83,6 +99,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备分组
|
||||
*
|
||||
@ -99,8 +116,8 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DeviceGroup entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
private void validEntityBeforeSave(DeviceGroup entity) {
|
||||
// TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,8 +129,8 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceRepairRecordsBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceRepairRecordsVo;
|
||||
|
Reference in New Issue
Block a user