Commit 912a1499 by HlQ

[chg] 代码优化

1 parent faa790fc
...@@ -531,10 +531,13 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont ...@@ -531,10 +531,13 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "合同施工申请,请及时处理哦~_~"); content.set("title", "合同施工申请,请及时处理哦~_~");
String markdown = StrUtil.format("#### 合同编号: **{}**" + String template = """
" \n #### 合同名称:**{}**" + #### 合同编号: **{}**" +
" \n #### 申请人:{}" + #### 合同名称:**{}**
" \n #### 发送时间:{}", #### 申请人:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
contract.getContractNo(), contract.getName(), applicantName, DateUtil.now()); contract.getContractNo(), contract.getName(), applicantName, DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
...@@ -552,12 +555,15 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont ...@@ -552,12 +555,15 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "验收提醒"); content.set("title", "验收提醒");
String markdown = StrUtil.format("#### 验收提醒" + String template = """
" \n #### 合同编号:**{}**" + #### 验收提醒" +
" \n #### 合同名称:**{}**" + #### 合同编号:**{}**" +
" \n #### 状态:{}" + #### 合同名称:**{}**" +
" \n #### 验收时间:{}" + #### 状态:{}" +
" \n #### 发送时间:{}", #### 验收时间:{}" +
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
contract.getContractNo(), contract.getName(), statusStr, DateUtil.formatDate(dto.getNodeDate()), DateUtil.now()); contract.getContractNo(), contract.getName(), statusStr, DateUtil.formatDate(dto.getNodeDate()), DateUtil.now());
content.set("text", markdown); content.set("text", markdown);
......
...@@ -155,14 +155,17 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord ...@@ -155,14 +155,17 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "设备发货提醒"); content.set("title", "设备发货提醒");
String markdown = StrUtil.format("#### 发货通知" + String template = """
" \n #### 合同名称:**{}**" + #### 发货通知
" \n #### 合同编号:**{}**" + #### 合同名称:**{}**
" \n #### 快递公司:{}" + #### 合同编号:**{}**
" \n #### 快递单号:{}" + #### 快递公司:{}
" \n #### 收件人:{}" + #### 快递单号:{}
" \n #### 发货日期:{}" + #### 收件人:{}
" \n #### 发送时间:{}", #### 发货日期:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
contract.getName(), contract.getContractNo(), rec.getCourierCompany(), rec.getTrackingNumber(), rec.getConsignee(), DateUtil.formatDate(rec.getShipDate()), DateUtil.now()); contract.getName(), contract.getContractNo(), rec.getCourierCompany(), rec.getTrackingNumber(), rec.getConsignee(), DateUtil.formatDate(rec.getShipDate()), DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
content.set("btn_orientation", "1"); content.set("btn_orientation", "1");
......
...@@ -178,14 +178,17 @@ public class InvoiceServiceImpl extends MPJBaseServiceImpl<InvoiceMapper, Invoic ...@@ -178,14 +178,17 @@ public class InvoiceServiceImpl extends MPJBaseServiceImpl<InvoiceMapper, Invoic
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "开票提醒"); content.set("title", "开票提醒");
String markdown = StrUtil.format("#### 开票提醒" + String template = """
" \n #### 合同编号:**{}**" + #### 开票提醒
" \n #### 合同名称:**{}**" + #### 合同编号:**{}**
" \n #### 发票编号:{}" + #### 合同名称:**{}**
" \n #### 发票金额:{}" + #### 发票编号:{}
" \n #### 开票时间:{}" + #### 发票金额:{}
" \n #### 备注:{}" + #### 开票时间:{}
" \n #### 发送时间:{}", #### 备注:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
contract.getContractNo(), contract.getName(), invoice.getInvoiceNo(), invoice.getInvoiceAmount(), DateUtil.formatDate(invoice.getInvoicingTime()), invoice.getRemark(), DateUtil.now()); contract.getContractNo(), contract.getName(), invoice.getInvoiceNo(), invoice.getInvoiceAmount(), DateUtil.formatDate(invoice.getInvoicingTime()), invoice.getRemark(), DateUtil.now());
content.set("text", markdown); content.set("text", markdown);
......
...@@ -188,13 +188,16 @@ public class PaymentServiceImpl extends MPJBaseServiceImpl<PaymentMapper, Paymen ...@@ -188,13 +188,16 @@ public class PaymentServiceImpl extends MPJBaseServiceImpl<PaymentMapper, Paymen
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "收款提醒"); content.set("title", "收款提醒");
String markdown = StrUtil.format("#### 收款提醒" + String template = """
" \n #### 合同编号:**{}**" + #### 收款提醒
" \n #### 合同名称:**{}**" + #### 合同编号:**{}**
" \n #### 收款金额:{}" + #### 合同名称:**{}**
" \n #### 收款时间:{}" + #### 收款金额:{}
" \n #### 备注:{}" + #### 收款时间:{}
" \n #### 发送时间:{}", #### 备注:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
contract.getContractNo(), contract.getName(), payment.getPaymentAmount(), DateUtil.formatDate(payment.getCollectionTime()), payment.getRemark(), DateUtil.now()); contract.getContractNo(), contract.getName(), payment.getPaymentAmount(), DateUtil.formatDate(payment.getCollectionTime()), payment.getRemark(), DateUtil.now());
content.set("text", markdown); content.set("text", markdown);
......
...@@ -67,6 +67,7 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po ...@@ -67,6 +67,7 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
@Value("${fileUrl:}") @Value("${fileUrl:}")
private String fileUrl; private String fileUrl;
// todo 点位设计推送机器人消息到群组
private final static String DING_GROUP_TOKEN = "未定"; private final static String DING_GROUP_TOKEN = "未定";
@Override @Override
...@@ -107,9 +108,11 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po ...@@ -107,9 +108,11 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
saveFile(id, infile, dto); saveFile(id, infile, dto);
})); }));
String content = StrUtil.format("### 新的点位设计需要处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 新的点位设计需要处理
" \n #### 联系人:{}", dto.getProjectName(), dto.getContact()); #### 项目名称:{}
#### 联系人:{}
""", dto.getProjectName(), dto.getContact());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content));
return MapUtil.<String, Long>builder() return MapUtil.<String, Long>builder()
.put("id", pointInfo.getId()) .put("id", pointInfo.getId())
...@@ -157,9 +160,11 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po ...@@ -157,9 +160,11 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
final Long finalId = id; final Long finalId = id;
Opt.ofNullable(dto.getContractFile()).ifPresent(infile -> { Opt.ofNullable(dto.getContractFile()).ifPresent(infile -> {
String content = StrUtil.format("### 门店合同已上传请及时处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 门店合同已上传请及时处理
" \n #### 联系人:{}", existPoint.getProjectName(), existPoint.getContact()); #### 项目名称:{}
#### 联系人:{}
""", existPoint.getProjectName(), existPoint.getContact());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content));
dto.setSourceType(19); dto.setSourceType(19);
saveFile(finalId, infile, dto); saveFile(finalId, infile, dto);
...@@ -180,29 +185,37 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po ...@@ -180,29 +185,37 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
Opt.ofNullable(dto.getFiles()) Opt.ofNullable(dto.getFiles())
.ifPresent(fileList -> Arrays.stream(fileList).forEach(infile -> { .ifPresent(fileList -> Arrays.stream(fileList).forEach(infile -> {
if (ObjUtil.isNotNull(dto.getSourceType()) && dto.getSourceType().equals(16)) { if (ObjUtil.isNotNull(dto.getSourceType()) && dto.getSourceType().equals(16)) {
String content = StrUtil.format("### 门店新图纸已上传请及时处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 门店新图纸已上传请及时处理
" \n #### 联系人:{}", existPoint.getProjectName(), existPoint.getContact()); #### 项目名称:{}
#### 联系人:{}
""", existPoint.getProjectName(), existPoint.getContact());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content));
} }
if (ObjUtil.isNotNull(dto.getSourceType()) && dto.getSourceType().equals(20)) { if (ObjUtil.isNotNull(dto.getSourceType()) && dto.getSourceType().equals(20)) {
String content = StrUtil.format("### 门店回执单已上传请及时处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 门店回执单已上传请及时处理
" \n #### 联系人:{}", existPoint.getProjectName(), existPoint.getContact()); #### 项目名称:{}
#### 联系人:{}
""", existPoint.getProjectName(), existPoint.getContact());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计提醒", content));
} }
saveFile(finalId, infile, dto); saveFile(finalId, infile, dto);
})); }));
if (ObjUtil.isNotNull(dto.getIsConstruct()) && dto.getIsConstruct().equals(1)) { if (ObjUtil.isNotNull(dto.getIsConstruct()) && dto.getIsConstruct().equals(1)) {
String content = StrUtil.format("### 门店需要施工请及时处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 门店需要施工请及时处理
" \n #### 联系人:{}", existPoint.getProjectName(), existPoint.getContact()); #### 项目名称:{}
#### 联系人:{}
""", existPoint.getProjectName(), existPoint.getContact());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计施工提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计施工提醒", content));
} }
if (ObjUtil.isNotNull(dto.getIsInvoice()) && dto.getIsInvoice().equals(1)) { if (ObjUtil.isNotNull(dto.getIsInvoice()) && dto.getIsInvoice().equals(1)) {
String content = StrUtil.format("### 门店需要开票请及时处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 门店需要开票请及时处理
" \n #### 联系人:{}", existPoint.getProjectName(), existPoint.getContact()); #### 项目名称:{}
#### 联系人:{}
""", existPoint.getProjectName(), existPoint.getContact());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计开票提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计开票提醒", content));
} }
return "编辑成功"; return "编辑成功";
...@@ -334,10 +347,12 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po ...@@ -334,10 +347,12 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
} else if (dto.getType() == 2 && StrUtil.equals(userStr, "client")) { } else if (dto.getType() == 2 && StrUtil.equals(userStr, "client")) {
if (this.lambdaUpdate().set(PointInfo::getStatus, 4).eq(PointInfo::getId, dto.getPointId()).update(new PointInfo())) { if (this.lambdaUpdate().set(PointInfo::getStatus, 4).eq(PointInfo::getId, dto.getPointId()).update(new PointInfo())) {
PointInfo info = this.getById(dto.getPointId()); PointInfo info = this.getById(dto.getPointId());
String content = StrUtil.format("### 门店驳回点位实际图,请及时处理" + String content = StrUtil.format("""
" \n #### 项目名称:{}" + ### 门店驳回点位实际图,请及时处理
" \n #### 联系人:{}" + #### 项目名称:{}
" \n #### 驳回意见:{}", info.getProjectName(), info.getContact(), dto.getContent()); #### 联系人:{}
#### 驳回意见:{}
""", info.getProjectName(), info.getContact(), dto.getContent());
dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计图驳回提醒", content)); dingMod.robotPush(DING_GROUP_TOKEN, buildMsg("点位设计图驳回提醒", content));
} }
} else if (dto.getType() == 3) { } else if (dto.getType() == 3) {
...@@ -452,18 +467,17 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po ...@@ -452,18 +467,17 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
} }
private String wechatPush(PointInfo pointInfo, String openid, String content, String url) { private String wechatPush(PointInfo pointInfo, String openid, String content, String url) {
Map<Integer, String> statusMap = MapUtil.<Integer, String>builder() Map<Integer, String> statusMap = Map.of(
.put(1, "图纸已上传") 1, "图纸已上传",
.put(2, "图纸已驳回") 2, "图纸已驳回",
.put(3, "设计待确认") 3, "设计待确认",
.put(4, "驳回设计") 4, "驳回设计",
.put(5, "合同签订中") 5, "合同签订中",
.put(6, "合同待确认") 6, "合同待确认",
.put(7, "合同完成") 7, "合同完成",
.put(8, "金蝶订单生成") 8, "金蝶订单生成",
.put(9, "已发货") 9, "已发货",
.put(10, "已签收") 10, "已签收");
.build();
List<WxMpTemplateData> wxMpTemplateDataList = ListUtil.of( List<WxMpTemplateData> wxMpTemplateDataList = ListUtil.of(
new WxMpTemplateData("thing4", pointInfo.getProjectName()), new WxMpTemplateData("thing4", pointInfo.getProjectName()),
......
...@@ -267,18 +267,13 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem ...@@ -267,18 +267,13 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
} }
private String getFaultLogContent(int status) { private String getFaultLogContent(int status) {
switch (status) { return switch (status) {
case 2: case 2 -> "工单正在处理中";
return "工单正在处理中"; case 3 -> "工单处理完成";
case 3: case 4 -> "工单挂起";
return "工单处理完成"; case 5 -> "工单已关闭";
case 4: default -> "";
return "工单挂起"; };
case 5:
return "工单已关闭";
default:
return "";
}
} }
/** /**
...@@ -429,13 +424,16 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem ...@@ -429,13 +424,16 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "您有一条新工单请及时处理哦~_~"); content.set("title", "您有一条新工单请及时处理哦~_~");
String markdown = StrUtil.format("#### 门店信息: **{}** [FullOfVitality]" + String template = """
" \n #### 任务编号:{}" + #### 门店信息: **{}** [FullOfVitality]" +
" \n #### 报修人:{}" + #### 任务编号:{}
" \n #### 联系方式:{}" + #### 报修人:{}
" \n #### 当前工单状态:{}" + #### 联系方式:{}
" \n #### 故障描述:{}" + #### 当前工单状态:{}
" \n #### 发送时间:{}", #### 故障描述:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus().toString()), task.getFaultDescription(), DateUtil.now()); storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus().toString()), task.getFaultDescription(), DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
content.set("btn_orientation", "1"); content.set("btn_orientation", "1");
...@@ -458,11 +456,14 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem ...@@ -458,11 +456,14 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "工单消息提醒"); content.set("title", "工单消息提醒");
String markdown = StrUtil.format("#### 门店信息: **{}**" + String template = """
" \n #### 报修人:{}" + #### 门店信息: **{}**
" \n #### 联系方式:{}" + #### 报修人:{}
" \n #### 故障描述:{}" + #### 联系方式:{}
" \n #### 发送时间:{}", #### 故障描述:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
storeName, task.getRepairPeople(), task.getRepairPhone(), task.getFaultDescription(), DateUtil.now()); storeName, task.getRepairPeople(), task.getRepairPhone(), task.getFaultDescription(), DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
content.set("btn_orientation", "1"); content.set("btn_orientation", "1");
...@@ -487,13 +488,16 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem ...@@ -487,13 +488,16 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "工单转发提醒"); content.set("title", "工单转发提醒");
String markdown = StrUtil.format("#### 门店信息: **{}** [FullOfVitality]" + String template = """
" \n #### 任务编号:{}" + #### 门店信息: **{}** [FullOfVitality]`
" \n #### 报修人:{}" + #### 任务编号:{}
" \n #### 联系方式:{}" + #### 报修人:{}
" \n #### 当前工单状态:{}" + #### 联系方式:{}
" \n #### 故障描述:{}" + #### 当前工单状态:{}
" \n #### 发送时间:{}", #### 故障描述:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus().toString()), task.getFaultDescription(), DateUtil.now()); storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus().toString()), task.getFaultDescription(), DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
content.set("btn_orientation", "1"); content.set("btn_orientation", "1");
...@@ -518,13 +522,16 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem ...@@ -518,13 +522,16 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "工单催办提醒"); content.set("title", "工单催办提醒");
String markdown = StrUtil.format("#### 门店信息: **{}** [FullOfVitality]" + String template = """
" \n #### 任务编号:{}" + #### 门店信息: **{}** [FullOfVitality]
" \n #### 报修人:{}" + #### 任务编号:{}
" \n #### 联系方式:{}" + #### 报修人:{}
" \n #### 当前工单状态:{}" + #### 联系方式:{}
" \n #### 催办提醒:**{}**" + #### 当前工单状态:{}
" \n #### 发送时间:{}", #### 催办提醒:**{}**
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus().toString()), remark, DateUtil.now()); storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus().toString()), remark, DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
content.set("btn_orientation", "1"); content.set("btn_orientation", "1");
......
...@@ -146,11 +146,14 @@ public class TaskTempServiceImpl extends MPJBaseServiceImpl<TaskTempMapper, Task ...@@ -146,11 +146,14 @@ public class TaskTempServiceImpl extends MPJBaseServiceImpl<TaskTempMapper, Task
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.set("title", "客户提交工单,请及时处理哦~_~"); content.set("title", "客户提交工单,请及时处理哦~_~");
String markdown = StrUtil.format("#### 门店信息: **{}**" + String template = """
" \n #### 客户姓名:{}" + #### 门店信息: **{}**
" \n #### 联系方式:{}" + #### 客户姓名:{}
" \n #### 故障描述:{}" + #### 联系方式:{}
" \n #### 发送时间:{}", #### 故障描述:{}
#### 发送时间:{}
""";
String markdown = StrUtil.format(template,
taskTemp.getStoreName(), taskTemp.getRepairPeople(), taskTemp.getRepairPhone(), taskTemp.getFaultDescription(), DateUtil.now()); taskTemp.getStoreName(), taskTemp.getRepairPeople(), taskTemp.getRepairPhone(), taskTemp.getFaultDescription(), DateUtil.now());
content.set("markdown", markdown); content.set("markdown", markdown);
content.set("btn_orientation", "1"); content.set("btn_orientation", "1");
......
...@@ -7,7 +7,6 @@ import io.github.linpeilie.Converter; ...@@ -7,7 +7,6 @@ import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.collection.ListUtil; import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.lang.Opt; import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.tree.MapTree; import org.dromara.hutool.core.tree.MapTree;
import org.dromara.hutool.core.tree.TreeNode; import org.dromara.hutool.core.tree.TreeNode;
import org.dromara.hutool.core.tree.TreeUtil; import org.dromara.hutool.core.tree.TreeUtil;
...@@ -26,6 +25,7 @@ import vion.vo.UserVO; ...@@ -26,6 +25,7 @@ import vion.vo.UserVO;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -38,18 +38,18 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem ...@@ -38,18 +38,18 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
@Override @Override
public Page<UserVO> getUserList(UserDTO dto) { public Page<UserVO> getUserList(UserDTO dto) {
MPJLambdaWrapper<User> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, User.class)) var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, User.class))
.selectAll(User.class) .selectAll(User.class)
.select(Dept::getDeptName) .select(Dept::getDeptName)
.leftJoin(Dept.class, Dept::getDeptId, User::getDeptId) .leftJoin(Dept.class, Dept::getDeptId, User::getDeptId)
.orderByAsc(User::getStatus); .orderByAsc(User::getStatus);
Page<UserVO> userVOS = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), UserVO.class, wrapper); var userVOS = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), UserVO.class, wrapper);
MPJLambdaWrapper<Role> roleWrapper = new MPJLambdaWrapper<Role>() var roleWrapper = new MPJLambdaWrapper<Role>()
.selectAll(Role.class) .selectAll(Role.class)
.select(RUserRole::getUserId) .select(RUserRole::getUserId)
.leftJoin(RUserRole.class, RUserRole::getRoleId, Role::getId) .leftJoin(RUserRole.class, RUserRole::getRoleId, Role::getId)
.in(RUserRole::getUserId, Opt.ofEmptyAble(userVOS.getRecords().stream().map(UserVO::getId).collect(Collectors.toList())).orElse(ListUtil.of(-1L))); .in(RUserRole::getUserId, Opt.ofEmptyAble(userVOS.getRecords().stream().map(UserVO::getId).collect(Collectors.toList())).orElse(ListUtil.of(-1L)));
List<RoleVO> roleVOList = roleService.selectJoinList(RoleVO.class, roleWrapper); var roleVOList = roleService.selectJoinList(RoleVO.class, roleWrapper);
Opt.ofEmptyAble(roleVOList) Opt.ofEmptyAble(roleVOList)
.map(l -> l.stream().collect(Collectors.groupingBy(RoleVO::getUserId))) .map(l -> l.stream().collect(Collectors.groupingBy(RoleVO::getUserId)))
.ifPresent(m -> userVOS.getRecords().forEach(u -> u.setRoleVOList(m.getOrDefault(u.getId(), ListUtil.empty())))); .ifPresent(m -> userVOS.getRecords().forEach(u -> u.setRoleVOList(m.getOrDefault(u.getId(), ListUtil.empty()))));
...@@ -58,21 +58,21 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem ...@@ -58,21 +58,21 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
@Override @Override
public List<MapTree<String>> getOrgTree(String deptId) { public List<MapTree<String>> getOrgTree(String deptId) {
List<Dept> deptList = deptService.list(); var deptList = deptService.list();
List<User> userList = this.list(); var userList = this.list();
List<TreeNode<String>> nodeList = ListUtil.zero(); List<TreeNode<String>> nodeList = ListUtil.zero();
deptList.forEach(v -> { deptList.forEach(v -> {
TreeNode<String> node = new TreeNode<>(v.getDeptId().toString(), v.getParentId().toString(), v.getDeptName(), 1); TreeNode<String> node = new TreeNode<>(v.getDeptId().toString(), v.getParentId().toString(), v.getDeptName(), 1);
node.setExtra(MapUtil.<String, Object>builder().put("type", "dept").put("pkId", v.getId()).build()); node.setExtra(Map.of("type", "dept","pkId", v.getId()));
nodeList.add(node); nodeList.add(node);
}); });
userList.forEach(v -> { userList.forEach(v -> {
TreeNode<String> node = new TreeNode<>(v.getUserid(), v.getDeptId().toString(), v.getUsername(), 2); TreeNode<String> node = new TreeNode<>(v.getUserid(), v.getDeptId().toString(), v.getUsername(), 2);
node.setExtra(MapUtil.<String, Object>builder().put("type", "user").put("pkId", v.getId()).build()); node.setExtra(Map.of("type", "user","pkId", v.getId()));
nodeList.add(node); nodeList.add(node);
}); });
List<MapTree<String>> wholeTree = TreeUtil.build(nodeList, "1"); var wholeTree = TreeUtil.build(nodeList, "1");
return Opt.ofBlankAble(deptId).map(d -> { return Opt.ofBlankAble(deptId).map(d -> {
List<MapTree<String>> resTree = new ArrayList<>(); List<MapTree<String>> resTree = new ArrayList<>();
wholeTree.forEach(t -> wholeTree.forEach(t ->
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!