Commit 912a1499 by HlQ

[chg] 代码优化

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