Commit f7354cae by Ren Ping

feat:容量类消息增加日期、图层判断

1 parent 5d7a522a
...@@ -91,9 +91,6 @@ public class MsgController { ...@@ -91,9 +91,6 @@ public class MsgController {
@PostMapping("/msg/add") @PostMapping("/msg/add")
public Result<Boolean> add(@RequestBody @Valid MsgDTO dto) { public Result<Boolean> add(@RequestBody @Valid MsgDTO dto) {
CommonUtil.setNullValue(dto); CommonUtil.setNullValue(dto);
AssertUtil.checkArgument(StrUtil.isNotEmpty(dto.getClusterId())
|| StrUtil.isNotEmpty(dto.getBranchId())
|| StrUtil.isNotEmpty(dto.getGroupId()), "大区Id、分部Id、分组Id不能同时为空");
msgService.add(dto); msgService.add(dto);
return Result.success(true); return Result.success(true);
} }
......
...@@ -86,4 +86,19 @@ public interface MsgDao extends JpaRepository<MsgEntity, Integer> { ...@@ -86,4 +86,19 @@ public interface MsgDao extends JpaRepository<MsgEntity, Integer> {
" from zzz_msg tt join zzz_msg_receiver r on r.deleted=0 and r.msg_id=tt.id and r.is_read=0 and r.user_id=?1" " from zzz_msg tt join zzz_msg_receiver r on r.deleted=0 and r.msg_id=tt.id and r.is_read=0 and r.user_id=?1"
, nativeQuery = true) , nativeQuery = true)
Integer getUnReadNum(String userId); Integer getUnReadNum(String userId);
@Query(value = "SELECT count(t.id)" +
" from zzz_msg t" +
" where IF(:groupId is not null, t.group_id =:groupId, t.group_id is null)" +
" and IF(:branchId is not null, t.branch_id =:branchId, t.branch_id is null)" +
" and IF(:clusterId is not null, t.cluster_id =:clusterId, t.cluster_id is null)" +
" and t.capacity_layer_id = :capacityLayerId" +
" and t.capacity_date = :capacityDate"
, nativeQuery = true
)
Integer getCapacityMsgCount(@Param("clusterId") String clusterId,
@Param("branchId") String branchId,
@Param("groupId") String groupId,
@Param("capacityLayerId") String capacityLayerId,
@Param("capacityDate") String capacityDate);
} }
...@@ -50,6 +50,16 @@ public class MsgDTO { ...@@ -50,6 +50,16 @@ public class MsgDTO {
@Max(value = 1, message = "标签类型格式不对") @Max(value = 1, message = "标签类型格式不对")
private Integer tag; private Integer tag;
/**
* 容量所属图层 ID
*/
private String capacityLayerId;
/**
* 容量所属日期
*/
private String capacityDate;
@Data @Data
public static class IdDTO { public static class IdDTO {
......
...@@ -73,5 +73,17 @@ public class MsgEntity { ...@@ -73,5 +73,17 @@ public class MsgEntity {
@Column(name = "update_time", nullable = false, columnDefinition = "datetime default current_timestamp") @Column(name = "update_time", nullable = false, columnDefinition = "datetime default current_timestamp")
private Date updateTime; private Date updateTime;
/**
* 容量类所属图层ID
*/
@Column(name = "capacity_layer_id")
private String capacityLayerId;
/**
* 容量类所属日期:2022-10-20
*/
@Column(name = "capacity_date")
private String capacityDate;
} }
...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dituhui.pea.common.PageResult; import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
...@@ -16,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity; ...@@ -16,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.enums.MsgTagEnum; import com.dituhui.pea.order.enums.MsgTagEnum;
import com.dituhui.pea.order.enums.MsgTypeEnum; import com.dituhui.pea.order.enums.MsgTypeEnum;
import com.dituhui.pea.order.service.MsgService; import com.dituhui.pea.order.service.MsgService;
import com.dituhui.pea.order.utils.AssertUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*; import org.springframework.data.domain.*;
...@@ -121,6 +123,14 @@ public class MsgServiceImpl implements MsgService { ...@@ -121,6 +123,14 @@ public class MsgServiceImpl implements MsgService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void add(MsgDTO dto) { public void add(MsgDTO dto) {
AssertUtil.checkArgument(StrUtil.isNotEmpty(dto.getClusterId())
|| StrUtil.isNotEmpty(dto.getBranchId())
|| StrUtil.isNotEmpty(dto.getGroupId()), "大区Id、分部Id、分组Id不能同时为空");
AssertUtil.checkArgument(ObjectUtil.equals(MsgTypeEnum.CAPACITY.getCode(), dto.getType())
&& ObjectUtil.isNotEmpty(dto.getCapacityLayerId())
&& ObjectUtil.isNotEmpty(dto.getCapacityDate()), "容量类消息图层ID、所属日期不能为空");
if (Objects.nonNull(dto.getGroupId())) { if (Objects.nonNull(dto.getGroupId())) {
OrgGroupEntity group = groupDao.getByGroupId(dto.getGroupId()); OrgGroupEntity group = groupDao.getByGroupId(dto.getGroupId());
dto.setBranchId(group.getBranchId()); dto.setBranchId(group.getBranchId());
...@@ -133,6 +143,19 @@ public class MsgServiceImpl implements MsgService { ...@@ -133,6 +143,19 @@ public class MsgServiceImpl implements MsgService {
dto.setClusterId(branch.getClusterId()); dto.setClusterId(branch.getClusterId());
} }
if (ObjectUtil.equals(MsgTypeEnum.CAPACITY.getCode(), dto.getType())) {
AssertUtil.checkArgument(ObjectUtil.isNotEmpty(dto.getCapacityLayerId())
&& ObjectUtil.isNotEmpty(dto.getCapacityDate()), "容量类消息图层ID、所属日期不能为空");
int count = msgDao.getCapacityMsgCount(dto.getClusterId(),
dto.getBranchId(),
dto.getGroupId(),
dto.getCapacityLayerId(),
dto.getCapacityDate());
if (count > 0) {
return;
}
}
List<String> userList = msgDao.getDispatchUserList(dto.getClusterId(), dto.getBranchId(), dto.getGroupId()); List<String> userList = msgDao.getDispatchUserList(dto.getClusterId(), dto.getBranchId(), dto.getGroupId());
MsgEntity msgEntity = new MsgEntity(); MsgEntity msgEntity = new MsgEntity();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!