mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
+1
-1
@@ -134,7 +134,7 @@ public class GlobalExceptionHandler {
|
||||
log.warn("[handleBindException]", ex);
|
||||
FieldError fieldError = ex.getFieldError();
|
||||
assert fieldError != null; // 断言,避免告警
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数不正确:%s", fieldError.getDefaultMessage()));
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数不正确:%s", fieldError.getRejectedValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+112
-5
@@ -153,6 +153,14 @@ public class OrderController {
|
||||
List<OrderBodyRespVO> orderBodyMap = orderService.getOrderBody(orderId);
|
||||
return success(orderBodyMap);
|
||||
}
|
||||
@GetMapping("/get-roomToString")
|
||||
@Operation(summary = "生产单详情-房间和柜体id(toString)")
|
||||
@Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
|
||||
public CommonResult<String> getRoomToString(@RequestParam("orderId") Long orderId) {
|
||||
String orderBodyMap = orderService.getOrderBodyToString(orderId);
|
||||
return success(orderBodyMap);
|
||||
}
|
||||
|
||||
@GetMapping("/get-room-and-body")
|
||||
@Operation(summary = "获取柜体和房间信息")
|
||||
@@ -191,7 +199,29 @@ public class OrderController {
|
||||
List<OrderPlatesDetailReqVO> moduleDOList = orderService.getPlatesDetail(orderId, roomId, bodyId, groupId, groupName);
|
||||
return success(moduleDOList);
|
||||
}
|
||||
@GetMapping("/get-platesDetailsPage")
|
||||
@Operation(summary = "生产单详情-板材详细信息(分页)")
|
||||
@Parameters({
|
||||
@Parameter(name = "orderId", description = "生产单编号", example = "1024"),
|
||||
@Parameter(name = "roomId", description = "房间编号", example = "1024"),
|
||||
@Parameter(name = "bodyId", description = "柜体编号", example = "1024"),
|
||||
@Parameter(name = "groupId", description = "加工组编号", example = "1024"),
|
||||
@Parameter(name = "groupName", description = "加工组名称", example = "弧形"),
|
||||
@Parameter(name = "pageNo", description = "第几页", example = "1"),
|
||||
@Parameter(name = "pageSize", description = "条数", example = "10")
|
||||
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
|
||||
public CommonResult<PageResult<OrderPlatesDetailReqVO>> platesDetails(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam(value = "roomId", required = false) Long roomId,
|
||||
@RequestParam(value = "bodyId", required = false) Long bodyId,
|
||||
@RequestParam(value = "groupId", required = false) Long groupId,
|
||||
@RequestParam(value = "groupName", required = false) String groupName,
|
||||
@RequestParam(value = "pageNo") Integer pageNo,
|
||||
@RequestParam(value = "pageSize") Integer pageSize) {
|
||||
PageResult<OrderPlatesDetailReqVO> moduleDOList = orderService.getPlatesDetail(orderId, roomId, bodyId, groupId, groupName, pageNo, pageSize);
|
||||
return success(moduleDOList);
|
||||
}
|
||||
@GetMapping("/get-partsDetails")
|
||||
@Operation(summary = "生产单详情-配件详细信息")
|
||||
@Parameters({
|
||||
@@ -208,7 +238,26 @@ public class OrderController {
|
||||
List<OrderPartsRespVO> moduleDOList = orderService.getPartsDetail(orderId, roomId, bodyId, name);
|
||||
return success(moduleDOList);
|
||||
}
|
||||
|
||||
@GetMapping("/get-partsDetailsPage")
|
||||
@Operation(summary = "生产单详情-配件详细信息(分页)")
|
||||
@Parameters({
|
||||
@Parameter(name = "orderId", description = "生产单编号", example = "1024"),
|
||||
@Parameter(name = "roomId", description = "房间编号", example = "1024"),
|
||||
@Parameter(name = "bodyId", description = "柜体编号", example = "1024"),
|
||||
@Parameter(name = "name", description = "配件名称", example = "1024"),
|
||||
@Parameter(name = "pageNo", description = "第几页", example = "1"),
|
||||
@Parameter(name = "pageSize", description = "条数", example = "10")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
|
||||
public CommonResult<PageResult<OrderPartsRespVO>> partsDetails(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam(value = "roomId", required = false) Long roomId,
|
||||
@RequestParam(value = "bodyId", required = false) Long bodyId,
|
||||
@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "pageNo") Integer pageNo,
|
||||
@RequestParam(value = "pageSize") Integer pageSize) {
|
||||
PageResult<OrderPartsRespVO> moduleDOList = orderService.getPartsDetail(orderId, roomId, bodyId, name, pageNo, pageSize);
|
||||
return success(moduleDOList);
|
||||
}
|
||||
// 柜体数据获取,需要加上柜体的属性
|
||||
@GetMapping("/get-body")
|
||||
@Operation(summary = "生产单柜体数据获取")
|
||||
@@ -366,6 +415,8 @@ public class OrderController {
|
||||
return success(orderService.getApiOrderList(orderList));
|
||||
}
|
||||
|
||||
|
||||
// 统计
|
||||
// 生产单状态分组统计返回
|
||||
@GetMapping("/getOrderStatusCount")
|
||||
@Operation(summary = "生产单状态分组统计返回")
|
||||
@@ -383,12 +434,68 @@ public class OrderController {
|
||||
return success(orderService.getOrderPlateAnalysisCount());
|
||||
}
|
||||
|
||||
// 生产单超期告警
|
||||
// 生产单超期/到期告警 (工作台)
|
||||
@GetMapping("/getOrderWarn")
|
||||
@Operation(summary = "生产单警告")
|
||||
@Parameter(name = "startTerm", description = "时间段选择", required = false, example = "1,3,7")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Map<String,List<OrderOverdueRespVO>>> getOrderOverdue(@RequestParam(value = "startTerm", required = false) Integer startTerm) {
|
||||
return success(orderService.getOrderWarn(startTerm));
|
||||
public CommonResult<Map<String,List<OrderOverdueRespVO>>> getOrderOverdue() {
|
||||
return success(orderService.getOrderWarn());
|
||||
}
|
||||
|
||||
// 生产单总数
|
||||
@GetMapping("/orderCount")
|
||||
@Operation(summary = "生产单总数")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Integer> getOrderCount() {
|
||||
return success(orderService.orderCount());
|
||||
}
|
||||
|
||||
// 今日新增生产单总数
|
||||
@GetMapping("/orderCountToday")
|
||||
@Operation(summary = "今日新增生产单总数")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Integer> getOrderCountToday() {
|
||||
return success(orderService.orderCountToday());
|
||||
}
|
||||
|
||||
// 今日生产单完成总数
|
||||
@GetMapping("/orderCountTodayFinish")
|
||||
@Operation(summary = "今日生产单完成总数")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Integer> getOrderCountTodayFinish() {
|
||||
return success(orderService.orderCountTodayFinish());
|
||||
}
|
||||
|
||||
// 生产中生产单总数
|
||||
@GetMapping("/orderCountProduce")
|
||||
@Operation(summary = "生产中生产单总数")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Integer> getOrderCountProduce() {
|
||||
return success(orderService.orderCountProduce());
|
||||
}
|
||||
|
||||
// 生产中生产平方数
|
||||
@GetMapping("/orderSquareProduce")
|
||||
@Operation(summary = "生产中生产平方数")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Integer> getOrderSquareProduce() {
|
||||
return success(orderService.orderSquareProduce());
|
||||
}
|
||||
|
||||
// 小板数量
|
||||
@GetMapping("/getPlateCount")
|
||||
@Operation(summary = "小板数量")
|
||||
@Parameters({
|
||||
@Parameter(name = "startTime", description = "开始时间", required = false),
|
||||
@Parameter(name = "endTime", description = "结束时间", required = false),
|
||||
@Parameter(name = "goodsId", description = "材料id", required = true),
|
||||
@Parameter(name = "organId", description = "组织id", required = false, example = "1")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<Integer> getPlateCount(@RequestParam(value = "startTime", required = false) String startTime,
|
||||
@RequestParam(value = "endTime", required = false) String endTime,
|
||||
@RequestParam(value = "goodsId", required = false) Set<String> goodsId,
|
||||
@RequestParam("orderId") Long organId) {
|
||||
return success(orderService.plateCount());
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order.vo.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Schema(description = "分析页 - 小板数量")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
public class OrderPlateCountVO {
|
||||
@Schema(description = "订单id")
|
||||
private Long orderId;
|
||||
}
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class OrderPlatesDetailReqVO {
|
||||
private Boolean isSculpt;
|
||||
|
||||
@Schema(description = "是否排孔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Boolean isHole;
|
||||
private Boolean isRowHole;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
|
||||
+5
-1
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plate.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
@@ -15,7 +16,7 @@ import com.alibaba.excel.annotation.*;
|
||||
@Schema(description = "管理后台 - 生产单板件 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PlateRespVO {
|
||||
public class PlateRespVO extends PageParam {
|
||||
|
||||
@Schema(description = "板件 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32523")
|
||||
@ExcelProperty("板件 ID")
|
||||
@@ -165,6 +166,9 @@ public class PlateRespVO {
|
||||
@ExcelProperty("是否作废")
|
||||
private Boolean isCancel;
|
||||
|
||||
@Schema(description = "是否排孔", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Boolean isRowHole;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
+4
@@ -49,6 +49,10 @@ public class OrderDO extends BaseDO {
|
||||
* 交付日期
|
||||
*/
|
||||
private LocalDateTime deliveryDate;
|
||||
/**
|
||||
* 生产单的完成时间
|
||||
*/
|
||||
private LocalDateTime finishTime;
|
||||
/**
|
||||
* 生产单类型,1主单 2子单
|
||||
*/
|
||||
|
||||
+60
@@ -9,12 +9,14 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.QueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderOverdueRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatusRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -145,4 +147,62 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
|
||||
// 生产单逾期统计
|
||||
List<OrderOverdueRespVO> selectOrderOverdue(@Param("today") LocalDateTime today, @Param("organId") Long organId);
|
||||
|
||||
// 生产单数量统计
|
||||
default Integer selectOrderCount(Long organId){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getOrganId, organId)
|
||||
.eq(OrderDO::getDeleted, 0)));
|
||||
}
|
||||
@OrganIgnore
|
||||
default Integer selectOrderCount(){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getDeleted, 0)));
|
||||
}
|
||||
|
||||
// 今日新增生产单总数统计
|
||||
default Integer selectOrderCountToday(Long organId){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getOrganId, organId)
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.between(OrderDO::getCreateTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59))));
|
||||
}
|
||||
@OrganIgnore
|
||||
default Integer selectOrderCountToday(){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.between(OrderDO::getCreateTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59))));
|
||||
}
|
||||
|
||||
// 今日新增生产单总数统计
|
||||
default Integer selectOrderCountTodayFinish(Long organId){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getOrganId, organId)
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.between(OrderDO::getFinishTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59))));
|
||||
}
|
||||
@OrganIgnore
|
||||
default Integer selectOrderCountTodayFinish(){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.between(OrderDO::getFinishTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59))));
|
||||
}
|
||||
|
||||
// 今日新增生产单总数统计
|
||||
default Integer selectOrderCountProduce(Long organId){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getOrganId, organId)
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.eq(OrderDO::getStatus, OrderStatusEnum.IN_PRODUCTION.getStatus())));
|
||||
}
|
||||
@OrganIgnore
|
||||
default Integer selectOrderCountProduce(){
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
.eq(OrderDO::getDeleted, 0)
|
||||
.eq(OrderDO::getStatus, OrderStatusEnum.IN_PRODUCTION.getStatus())));
|
||||
}
|
||||
|
||||
// 生产中生产平方数
|
||||
@OrganIgnore
|
||||
Integer selectOrderSquareProduce(@Param("organId") Long organId);
|
||||
}
|
||||
|
||||
+11
@@ -1,5 +1,8 @@
|
||||
package com.cf.imes.module.executor.dal.mysql.orderItem;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderModuleRespVO;
|
||||
@@ -10,6 +13,7 @@ import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.PrintOrder
|
||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderModuleExtra.OrderModuleExtraDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.remainplaten.RemainPlateDO;
|
||||
@@ -31,10 +35,17 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
||||
@Param("bodyId") Long bodyId, @Param("groupId") Long groupId,
|
||||
@Param("groupName") String groupName, @Param("organId") Long organId,
|
||||
@Param("deleted") Integer deleted);
|
||||
IPage<PlateRespVO> selectPlatesDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Long roomId,
|
||||
@Param("bodyId") Long bodyId, @Param("groupId") Long groupId,
|
||||
@Param("groupName") String groupName, @Param("organId") Long organId,
|
||||
@Param("deleted") Integer deleted);
|
||||
|
||||
List<OrderPartsRespVO> selectPartsDetailByOrderId(@Param("orderId") Long orderId, @Param("roomId") Long roomId,
|
||||
@Param("bodyId") Long bodyId, @Param("name") String name,
|
||||
@Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
IPage<OrderPartsRespVO> selectPartsDetailByOrderId(@Param("page") IPage page,@Param("orderId") Long orderId, @Param("roomId") Long roomId,
|
||||
@Param("bodyId") Long bodyId, @Param("name") String name,
|
||||
@Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
|
||||
|
||||
List<OrderPlatesDetailRespVO> selectPartsByOrderId(@Param("orderId") Long orderId,
|
||||
|
||||
+40
-1
@@ -96,6 +96,7 @@ public interface OrderService {
|
||||
* 需要修改返回值
|
||||
*/
|
||||
List<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Long roomId , Long bodyId , Long groupId, String groupName);
|
||||
PageResult<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Long roomId, Long bodyId, Long groupId, String groupName, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* @param orderId: 生产单id
|
||||
@@ -105,6 +106,7 @@ public interface OrderService {
|
||||
* 需要修改返回值
|
||||
*/
|
||||
List<OrderPartsRespVO> getPartsDetail(Long orderId, Long roomId , Long bodyId , String name);
|
||||
PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Long roomId , Long bodyId , String name, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 删除柜体
|
||||
@@ -185,5 +187,42 @@ public interface OrderService {
|
||||
/**
|
||||
* 生产单超期告警分析统计
|
||||
*/
|
||||
Map<String,List<OrderOverdueRespVO>> getOrderWarn(Integer startTerm);
|
||||
Map<String,List<OrderOverdueRespVO>> getOrderWarn();
|
||||
|
||||
/**
|
||||
* 今日要完成生产单数
|
||||
*/
|
||||
List<OrderRespVO> getOrderOverdue();
|
||||
|
||||
String getOrderBodyToString(Long orderId);
|
||||
|
||||
/**
|
||||
* 生产单总数统计
|
||||
*/
|
||||
Integer orderCount();
|
||||
|
||||
/**
|
||||
* 今日新增生产单总数统计
|
||||
*/
|
||||
Integer orderCountToday();
|
||||
|
||||
/**
|
||||
* 今日生产单完成总数
|
||||
*/
|
||||
Integer orderCountTodayFinish();
|
||||
|
||||
/**
|
||||
* 今日生产单完成总数
|
||||
*/
|
||||
Integer orderCountProduce();
|
||||
|
||||
/**
|
||||
* 今日生产单完成总数
|
||||
*/
|
||||
Integer orderSquareProduce();
|
||||
|
||||
/**
|
||||
* 小板数量
|
||||
*/
|
||||
Integer plateCount();
|
||||
}
|
||||
+113
-19
@@ -1,19 +1,25 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import cn.smallbun.screw.core.util.CollectionUtils;
|
||||
import co.elastic.clients.elasticsearch.nodes.Ingest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.framework.datapermission.core.util.DataPermissionUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRemark;
|
||||
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy;
|
||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateGoodsIdVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
|
||||
@@ -279,6 +285,78 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderBodyMapper.selectList(orderId, deleted, SecurityFrameworkUtils.getLoginUser().getOrganId()), OrderBodyRespVO.class);
|
||||
return orderBodyRespVOList;
|
||||
}
|
||||
@Override
|
||||
public String getOrderBodyToString(Long orderId) {
|
||||
// 判断生产单是否删除
|
||||
Integer deleted = getOrderDeleted(orderId);
|
||||
|
||||
List<OrderBodyRespVO> orderBodyRespVOList = BeanUtils.toBean(
|
||||
orderBodyMapper.selectList(orderId, deleted, SecurityFrameworkUtils.getLoginUser().getOrganId()), OrderBodyRespVO.class);
|
||||
String orderBodyToString = JSON.toJSONString(orderBodyRespVOList);
|
||||
|
||||
return JsonUtils.zipString(orderBodyToString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer orderCount() {
|
||||
// 角色判断
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
System.out.println("loginUser " + loginUser);
|
||||
// 数据查询
|
||||
if (loginUser.getIsSupAdmin()){
|
||||
return orderMapper.selectOrderCount();
|
||||
}
|
||||
return orderMapper.selectOrderCount(getUserOrganId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer orderCountToday() {
|
||||
// 角色判断
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
// 数据查询
|
||||
if (loginUser.getIsSupAdmin()){
|
||||
return orderMapper.selectOrderCountToday();
|
||||
}
|
||||
return orderMapper.selectOrderCountToday(getUserOrganId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer orderCountTodayFinish() {
|
||||
// 角色判断
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
// 数据查询
|
||||
if (loginUser.getIsSupAdmin()){
|
||||
return orderMapper.selectOrderCountTodayFinish();
|
||||
}
|
||||
return orderMapper.selectOrderCountTodayFinish(getUserOrganId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer orderCountProduce() {
|
||||
// 角色判断
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
// 数据查询
|
||||
if (loginUser.getIsSupAdmin()){
|
||||
return orderMapper.selectOrderCountProduce();
|
||||
}
|
||||
return orderMapper.selectOrderCountProduce(getUserOrganId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer orderSquareProduce() {
|
||||
// 角色判断
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
// 数据查询
|
||||
if (loginUser.getIsSupAdmin()){
|
||||
return orderMapper.selectOrderSquareProduce(null);
|
||||
}
|
||||
return orderMapper.selectOrderSquareProduce(getUserOrganId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer plateCount() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderRoomBodyRespVO> getRoomAndBody(Long planId) {
|
||||
@@ -317,14 +395,26 @@ public class OrderServiceImpl implements OrderService {
|
||||
List<OrderPlatesDetailReqVO> platesDetailReqVOS = new ArrayList<>();
|
||||
orderDetail.forEach(orderPlatesDetailRespVO -> {
|
||||
OrderPlatesDetailReqVO orderPlatesDetailReqVO = BeanUtils.toBean(orderPlatesDetailRespVO, OrderPlatesDetailReqVO.class)
|
||||
.setIsHole(false);
|
||||
.setIsRowHole(false);
|
||||
if (orderPlatesDetailRespVO.getUnregularPointCount() > 0 || orderPlatesDetailRespVO.getFrontHoleCount() > 0
|
||||
|| orderPlatesDetailRespVO.getBackHoleCount() > 0 || orderPlatesDetailRespVO.getSideHoleCount() > 0)
|
||||
orderPlatesDetailReqVO.setIsHole(true);
|
||||
orderPlatesDetailReqVO.setIsRowHole(true);
|
||||
platesDetailReqVOS.add(orderPlatesDetailReqVO);
|
||||
});
|
||||
return platesDetailReqVOS;
|
||||
}
|
||||
@Override
|
||||
public PageResult<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Long roomId, Long bodyId, Long groupId, String groupName, Integer pageNo, Integer pageSize) {
|
||||
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageNo, pageSize);
|
||||
// 判断生产单是否删除 (包含判断存在)
|
||||
Integer deleted = getOrderDeleted(orderId);
|
||||
IPage<PlateRespVO> plateRespVOPage = orderItemMapper.selectPlatesDetailByOrderId(page,orderId, roomId, bodyId, groupId,
|
||||
groupName, SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted);
|
||||
List<PlateRespVO> orderDetail = plateRespVOPage.getRecords();
|
||||
List<OrderPlatesDetailReqVO> platesDetailReqVOS = BeanUtils.toBean(orderDetail, OrderPlatesDetailReqVO.class);
|
||||
PageResult<OrderPlatesDetailReqVO> pageResult = new PageResult(platesDetailReqVOS, plateRespVOPage.getTotal());
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderPartsRespVO> getPartsDetail(Long orderId, Long roomId, Long bodyId, String name) {
|
||||
@@ -334,6 +424,16 @@ public class OrderServiceImpl implements OrderService {
|
||||
SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted);
|
||||
return orderDetail;
|
||||
}
|
||||
@Override
|
||||
public PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Long roomId, Long bodyId, String name, Integer pageNo, Integer pageSize) {
|
||||
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageNo, pageSize);
|
||||
// 判断生产单是否删除 (包含判断存在)
|
||||
Integer deleted = getOrderDeleted(orderId);
|
||||
IPage<OrderPartsRespVO> orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId, name,
|
||||
SecurityFrameworkUtils.getLoginUser().getOrganId(), deleted);
|
||||
PageResult<OrderPartsRespVO> pageResult = new PageResult(orderDetail.getRecords(), orderDetail.getTotal());
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -607,34 +707,28 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,List<OrderOverdueRespVO>> getOrderWarn(Integer startTerm) {
|
||||
public Map<String,List<OrderOverdueRespVO>> getOrderWarn() {
|
||||
Map<String,List<OrderOverdueRespVO>> map = new HashMap<>();
|
||||
|
||||
LocalDateTime today = LocalDateTime.now();
|
||||
// 根据开始条件选择
|
||||
LocalDateTime orderDate = null;
|
||||
LocalDateTime yesterdayDay = LocalDateTime.now().minus(1, ChronoUnit.DAYS).withHour(23).withMinute(59).withSecond(59);
|
||||
|
||||
switch (startTerm) {
|
||||
case 3:
|
||||
orderDate = LocalDateTime.now().minus(3, ChronoUnit.DAYS);
|
||||
break;
|
||||
case 7:
|
||||
orderDate = LocalDateTime.now().minus(7, ChronoUnit.DAYS);
|
||||
break;
|
||||
default:
|
||||
orderDate = LocalDateTime.now().minus(1, ChronoUnit.DAYS);
|
||||
break;
|
||||
LocalDateTime today = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime tomorrowDay = LocalDateTime.now().plus(1, ChronoUnit.DAYS).withHour(23).withMinute(59).withSecond(59);
|
||||
|
||||
}
|
||||
// 查询预警单
|
||||
List<OrderOverdueRespVO> orderNearVOS = orderMapper.selectOrderNear(today, orderDate, OrganContextHolder.getOrganId());
|
||||
List<OrderOverdueRespVO> orderNearVOS = orderMapper.selectOrderNear(today, tomorrowDay, OrganContextHolder.getOrganId());
|
||||
map.put("orderNearVOS",orderNearVOS);
|
||||
// 查询超时单
|
||||
List<OrderOverdueRespVO> orderOverdueVOS = orderMapper.selectOrderOverdue(today, OrganContextHolder.getOrganId());
|
||||
List<OrderOverdueRespVO> orderOverdueVOS = orderMapper.selectOrderOverdue(yesterdayDay, OrganContextHolder.getOrganId());
|
||||
map.put("orderOverdueVOS",orderOverdueVOS);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderRespVO> getOrderOverdue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 判断是否已经导入
|
||||
private Boolean validateOrderNoExists(String orderNo, Long organId) {
|
||||
if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
|
||||
|
||||
+12
@@ -122,6 +122,7 @@
|
||||
from orders o
|
||||
where o.organ_id = #{organId}
|
||||
and o.deleted = 0
|
||||
and o.status != 4
|
||||
and o.delivery_date between #{orderDate} and #{today}
|
||||
</select>
|
||||
|
||||
@@ -155,6 +156,17 @@
|
||||
from orders o
|
||||
where o.organ_id = #{organId}
|
||||
and o.deleted = 0
|
||||
and o.status != 4
|
||||
and #{today} > DATE(o.delivery_date)
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectOrderSquareProduce" resultType="java.lang.Integer">
|
||||
SELECT SUM(op.area) as area FROM orders o
|
||||
LEFT JOIN order_plate op on op.order_id = o.id
|
||||
WHERE o.deleted = 0
|
||||
<if test="organId != null">
|
||||
AND o.organ_id = #{organId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<select id="selectPlatesDetailByOrderId" resultType="com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO">
|
||||
SELECT DISTINCT i.order_id, p.id, p.plate_no, g.material, p.name, p.area, p.seal_left, p.seal_down,
|
||||
p.seal_right, p.seal_up, p.texture, p.is_special_shaped, p.is_sculpt, p.unregular_point_count, p.front_hole_count,
|
||||
p.back_hole_count, p.side_hole_count,p.width,p.height,p.thickness,p.remark,g.color
|
||||
p.back_hole_count, p.side_hole_count,p.width,p.height,p.thickness,p.remark,g.color,p.is_row_hole
|
||||
FROM order_item i
|
||||
RIGHT JOIN `order_plate` p ON i.plate_id = p.id
|
||||
LEFT JOIN `order_goods` g ON g.id = p.goods_id
|
||||
|
||||
+8
-28
@@ -4,7 +4,6 @@ import com.cf.imes.framework.common.enums.UserTypeEnum;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
@@ -19,10 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@@ -51,7 +46,9 @@ public class NotifyMessageController {
|
||||
@Operation(summary = "获得站内信分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:notify-message:query')")
|
||||
public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
|
||||
pageVO.setUserId(getLoginUserId());
|
||||
pageVO.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO);
|
||||
return success(BeanUtils.toBean(pageResult, NotifyMessageRespVO.class));
|
||||
}
|
||||
|
||||
@@ -59,18 +56,11 @@ public class NotifyMessageController {
|
||||
|
||||
@GetMapping("/my-page")
|
||||
@Operation(summary = "获得我的站内信分页")
|
||||
public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) {
|
||||
Long loginUserId = getLoginUserId();
|
||||
if(!Objects.isNull(pageVO.getReadStatus())) {
|
||||
return success(notifyMessageService.getPageResultByRead(pageVO));
|
||||
}
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO,
|
||||
loginUserId, UserTypeEnum.ADMIN.getValue());
|
||||
public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
|
||||
pageVO.setUserId(getLoginUserId());
|
||||
pageVO.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO);
|
||||
PageResult<NotifyMessageRespVO> respVOPageResult = BeanUtils.toBean(pageResult, NotifyMessageRespVO.class);
|
||||
Set<String> messageRead = notifyMessageService.getMessageRead(pageResult.getList().stream().map(e -> String.valueOf(e.getId())).collect(Collectors.toSet()), loginUserId);
|
||||
respVOPageResult.getList().forEach(e->{
|
||||
e.setReadStatus(messageRead.contains(e.getId().toString()));
|
||||
});
|
||||
return success(respVOPageResult);
|
||||
}
|
||||
|
||||
@@ -89,19 +79,9 @@ public class NotifyMessageController {
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@GetMapping("/get-unread-list")
|
||||
@Operation(summary = "获取当前用户的最新站内信列表,默认 10 条")
|
||||
@Parameter(name = "size", description = "10")
|
||||
public CommonResult<List<NotifyMessageRespVO>> getUnreadNotifyMessageList(
|
||||
@RequestParam(name = "size", defaultValue = "10") Integer size) {
|
||||
List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(
|
||||
getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size);
|
||||
return success(BeanUtils.toBean(list, NotifyMessageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-unread-count")
|
||||
@Operation(summary = "获得当前用户的未读站内信数量")
|
||||
public CommonResult<Long> getUnreadNotifyMessageCount() {
|
||||
public CommonResult<Integer> getUnreadNotifyMessageCount() {
|
||||
return success(notifyMessageService.getUnreadNotifyMessageCount(
|
||||
getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
|
||||
}
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.cf.imes.module.system.controller.admin.notify.vo.message;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 站内信分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class NotifyMessageMyPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "是否已读", example = "true")
|
||||
private Boolean readStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+2
@@ -33,4 +33,6 @@ public class NotifyMessagePageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "是否已读", example = "true")
|
||||
private Boolean readStatus;
|
||||
}
|
||||
|
||||
+5
-2
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.*;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
@@ -88,12 +89,14 @@ public class NotifyMessageDO extends BaseDO {
|
||||
// ========= 读取相关字段 =========
|
||||
|
||||
/**
|
||||
* 是否已读 现在这个状态存在redis中,所以先注释此字段
|
||||
* 是否已读
|
||||
*/
|
||||
/*private Boolean readStatus;*/
|
||||
@Transient
|
||||
private Boolean readStatus;
|
||||
/**
|
||||
* 阅读时间
|
||||
*/
|
||||
@Transient
|
||||
private LocalDateTime readTime;
|
||||
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.cf.imes.module.system.dal.dataobject.notify;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/15 14:46
|
||||
*/
|
||||
@TableName(value = "system_notify_message_readinfo")
|
||||
@KeySequence("system_notify_message_readinfo_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NotifyMessageReadInfoDO {
|
||||
/**
|
||||
* 主键,自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 站内信消息id
|
||||
*/
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 阅读时间
|
||||
*/
|
||||
private LocalDateTime readTime;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
}
|
||||
+26
-57
@@ -1,71 +1,40 @@
|
||||
package com.cf.imes.module.system.dal.mysql.notify;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.QueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
|
||||
/**
|
||||
* 分页查询我的站内信
|
||||
*
|
||||
* @param page 分页信息
|
||||
* @param pageReqVO 请求参数
|
||||
* @return
|
||||
*/
|
||||
IPage<NotifyMessageDO> getMyMyNotifyMessage(@Param("page") IPage page, @Param("reqVo") NotifyMessagePageReqVO pageReqVO);
|
||||
|
||||
default PageResult<NotifyMessageDO> selectPage(NotifyMessagePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
|
||||
.likeIfPresent(NotifyMessageDO::getTemplateCode, reqVO.getTemplateCode())
|
||||
.eqIfPresent(NotifyMessageDO::getTemplateType, reqVO.getTemplateType())
|
||||
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(NotifyMessageDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<NotifyMessageDO> selectPage(NotifyMessageMyPageReqVO reqVO, Long userId, Integer userType) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
//.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
|
||||
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
|
||||
.in(NotifyMessageDO::getUserId, Arrays.asList(userId, 0L))
|
||||
.eq(NotifyMessageDO::getUserType, userType)
|
||||
.orderByDesc(NotifyMessageDO::getId));
|
||||
}
|
||||
|
||||
default int updateListRead(Collection<Long> ids, Long userId, Integer userType) {
|
||||
return update(new NotifyMessageDO().setReadTime(LocalDateTime.now()),
|
||||
new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.in(NotifyMessageDO::getId, ids)
|
||||
.eq(NotifyMessageDO::getUserId, userId)
|
||||
.eq(NotifyMessageDO::getUserType, userType));
|
||||
//.eq(NotifyMessageDO::getReadStatus, false));
|
||||
}
|
||||
|
||||
default int updateListRead(Long userId, Integer userType) {
|
||||
return update(new NotifyMessageDO().setReadTime(LocalDateTime.now()),
|
||||
new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.eq(NotifyMessageDO::getUserId, userId)
|
||||
.eq(NotifyMessageDO::getUserType, userType));
|
||||
//.eq(NotifyMessageDO::getReadStatus, false));
|
||||
}
|
||||
|
||||
default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) {
|
||||
return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句,所以只能用 QueryWrapperX
|
||||
.in("user_id", Arrays.asList(userId, 0L))
|
||||
.eq("user_type", userType)
|
||||
.eq("read_status", false)
|
||||
.orderByDesc("id").limitN(size));
|
||||
}
|
||||
|
||||
default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
|
||||
return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
//.eq(NotifyMessageDO::getReadStatus, false)
|
||||
.in(NotifyMessageDO::getUserId, Arrays.asList(userId, 0L))
|
||||
.eq(NotifyMessageDO::getUserType, userType));
|
||||
}
|
||||
/**
|
||||
* 统计未读消息数量
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userType 接受用户类型
|
||||
* @return
|
||||
*/
|
||||
Integer getUnreadNotifyMessageCount(@Param("userId") Long userId, @Param("userType") Integer userType);
|
||||
|
||||
/**
|
||||
* 获取未读消息id列表
|
||||
*
|
||||
* @param userId
|
||||
* @param userType
|
||||
* @return
|
||||
*/
|
||||
List<Long> getUnreadNotifyMessageIds(@Param("userId") Long userId, @Param("userType") Integer userType);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.cf.imes.module.system.dal.mysql.notify;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageReadInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface NotifyMessageReadInfoMapper extends BaseMapperX<NotifyMessageReadInfoDO> {
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cf.imes.module.system.service.notify;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 站内信阅读信息 Service 接口
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/15 15:28
|
||||
*/
|
||||
public interface NotifyMessageReadInfoService {
|
||||
/**
|
||||
* 获取任一站内信阅读信息
|
||||
*
|
||||
* @param messageId 消息id
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
LocalDateTime getAny(Long messageId, Long userId);
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.service.notify;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageReadInfoDO;
|
||||
import com.cf.imes.module.system.dal.mysql.notify.NotifyMessageReadInfoMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/15 15:29
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class NotifyMessageReadInfoServiceImpl implements NotifyMessageReadInfoService {
|
||||
|
||||
@Resource
|
||||
private NotifyMessageReadInfoMapper notifyMessageReadInfoMapper;
|
||||
|
||||
@Override
|
||||
public LocalDateTime getAny(Long messageId, Long userId) {
|
||||
NotifyMessageReadInfoDO one = notifyMessageReadInfoMapper.selectOne(new LambdaQueryWrapper<NotifyMessageReadInfoDO>()
|
||||
.eq(NotifyMessageReadInfoDO::getMessageId, messageId)
|
||||
.eq(NotifyMessageReadInfoDO::getUserId, userId)
|
||||
.select(NotifyMessageReadInfoDO::getReadTime));
|
||||
return one != null ? one.getReadTime() : null;
|
||||
}
|
||||
}
|
||||
+2
-43
@@ -1,16 +1,12 @@
|
||||
package com.cf.imes.module.system.service.notify;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 站内信 Service 接口
|
||||
@@ -19,8 +15,6 @@ import java.util.Set;
|
||||
*/
|
||||
public interface NotifyMessageService {
|
||||
|
||||
String NOTIFY_MESSAGE_KEY = "notify-message:";
|
||||
|
||||
/**
|
||||
* 创建站内信
|
||||
*
|
||||
@@ -34,23 +28,13 @@ public interface NotifyMessageService {
|
||||
Long createNotifyMessage(Long userId, Integer userType,
|
||||
NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams);
|
||||
|
||||
/**
|
||||
* 获得站内信分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 站内信分页
|
||||
*/
|
||||
PageResult<NotifyMessageDO> getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得【我的】站内信分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param userId 用户编号
|
||||
* @param userType 用户类型
|
||||
* @return 站内信分页
|
||||
*/
|
||||
PageResult<NotifyMessageDO> getMyMyNotifyMessagePage(NotifyMessageMyPageReqVO pageReqVO, Long userId, Integer userType);
|
||||
PageResult<NotifyMessageDO> getMyMyNotifyMessagePage(NotifyMessagePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得站内信
|
||||
@@ -60,16 +44,6 @@ public interface NotifyMessageService {
|
||||
*/
|
||||
NotifyMessageDO getNotifyMessage(Long id);
|
||||
|
||||
/**
|
||||
* 获得【我的】未读站内信列表
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userType 用户类型
|
||||
* @param size 数量
|
||||
* @return 站内信列表
|
||||
*/
|
||||
List<NotifyMessageDO> getUnreadNotifyMessageList(Long userId, Integer userType, Integer size);
|
||||
|
||||
/**
|
||||
* 统计用户未读站内信条数
|
||||
*
|
||||
@@ -77,7 +51,7 @@ public interface NotifyMessageService {
|
||||
* @param userType 用户类型
|
||||
* @return 返回未读站内信条数
|
||||
*/
|
||||
Long getUnreadNotifyMessageCount(Long userId, Integer userType);
|
||||
Integer getUnreadNotifyMessageCount(Long userId, Integer userType);
|
||||
|
||||
/**
|
||||
* 标记站内信为已读
|
||||
@@ -97,19 +71,4 @@ public interface NotifyMessageService {
|
||||
* @return 更新到的条数
|
||||
*/
|
||||
int updateAllNotifyMessageRead(Long userId, Integer userType);
|
||||
|
||||
/**
|
||||
* 获取用户的站内信以读
|
||||
* @param messageIds
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Set<String> getMessageRead(Collection<String> messageIds, Long userId);
|
||||
|
||||
/**
|
||||
* 查询已读或未读站内信分页
|
||||
* @param pageVO
|
||||
* @return
|
||||
*/
|
||||
PageResult<NotifyMessageRespVO> getPageResultByRead(NotifyMessageMyPageReqVO pageVO);
|
||||
}
|
||||
|
||||
+27
-107
@@ -1,27 +1,21 @@
|
||||
package com.cf.imes.module.system.service.notify;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageReadInfoDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import com.cf.imes.module.system.dal.mysql.notify.NotifyMessageMapper;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import com.cf.imes.module.system.dal.mysql.notify.NotifyMessageReadInfoMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* 站内信 Service 实现类
|
||||
@@ -30,13 +24,14 @@ import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.ge
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class NotifyMessageServiceImpl implements NotifyMessageService {
|
||||
|
||||
@Resource
|
||||
private NotifyMessageMapper notifyMessageMapper;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
private NotifyMessageReadInfoMapper notifyMessageReadInfoMapper;
|
||||
|
||||
@Override
|
||||
public Long createNotifyMessage(Long userId, Integer userType,
|
||||
@@ -50,13 +45,10 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<NotifyMessageDO> getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
|
||||
return notifyMessageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<NotifyMessageDO> getMyMyNotifyMessagePage(NotifyMessageMyPageReqVO pageReqVO, Long userId, Integer userType) {
|
||||
return notifyMessageMapper.selectPage(pageReqVO, userId, userType);
|
||||
public PageResult<NotifyMessageDO> getMyMyNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
|
||||
PageDTO page = new PageDTO(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
IPage<NotifyMessageDO> myMyNotifyMessage = notifyMessageMapper.getMyMyNotifyMessage(page, pageReqVO);
|
||||
return new PageResult<>(myMyNotifyMessage.getRecords(), myMyNotifyMessage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,104 +57,32 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotifyMessageDO> getUnreadNotifyMessageList(Long userId, Integer userType, Integer size) {
|
||||
return notifyMessageMapper.selectUnreadListByUserIdAndUserType(userId, userType, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getUnreadNotifyMessageCount(Long userId, Integer userType) {
|
||||
List<NotifyMessageDO> notifyMessageDOS = notifyMessageMapper.selectList(new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.eq(NotifyMessageDO::getUserType, userType)
|
||||
.in(NotifyMessageDO::getUserId, Arrays.asList(userId, 0L))
|
||||
.select(NotifyMessageDO::getId)
|
||||
);
|
||||
if(CollUtil.isEmpty(notifyMessageDOS)) {
|
||||
return 0L;
|
||||
}
|
||||
Set<String> messageIds = notifyMessageDOS.stream().map(e->e.getId().toString()).collect(Collectors.toSet());
|
||||
Set<String> set = bitGet(messageIds, userId);
|
||||
messageIds.removeAll(set);
|
||||
return (long) messageIds.size();
|
||||
//return notifyMessageMapper.selectUnreadCountByUserIdAndUserType(userId, userType);
|
||||
public Integer getUnreadNotifyMessageCount(Long userId, Integer userType) {
|
||||
return notifyMessageMapper.getUnreadNotifyMessageCount(userId, userType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateNotifyMessageRead(Collection<Long> ids, Long userId, Integer userType) {
|
||||
bitset(ids.stream().map(Object::toString).collect(Collectors.toSet()), userId);
|
||||
List<NotifyMessageReadInfoDO> batchInsertReadInfoList = ids.stream().map(messageId -> NotifyMessageReadInfoDO.builder().messageId(messageId).userId(userId).build()).toList();
|
||||
Boolean insertBatch = notifyMessageReadInfoMapper.insertBatch(batchInsertReadInfoList);
|
||||
if (!insertBatch) {
|
||||
log.error("[updateNotifyMessageRead][新增站内信消息阅读信息失败]");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
//return notifyMessageMapper.updateListRead(ids, userId, userType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateAllNotifyMessageRead(Long userId, Integer userType) {
|
||||
List<NotifyMessageDO> notifyMessageDOS = notifyMessageMapper.selectList(new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.in(NotifyMessageDO::getUserId, Arrays.asList(userId, 0))
|
||||
.eq(NotifyMessageDO::getUserType, 2)
|
||||
.select(NotifyMessageDO::getId)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(notifyMessageDOS)) {
|
||||
Set<String> messageIds = notifyMessageDOS.stream().map(e -> String.valueOf(e.getId())).collect(Collectors.toSet());
|
||||
bitset(messageIds, userId);
|
||||
List<Long> messageIds = notifyMessageMapper.getUnreadNotifyMessageIds(userId, userType);
|
||||
if (CollUtil.isNotEmpty(messageIds)) {
|
||||
List<NotifyMessageReadInfoDO> batchInsertReadInfoList = messageIds.stream().map(messageId -> NotifyMessageReadInfoDO.builder().messageId(messageId).userId(userId).build()).toList();
|
||||
Boolean insertBatch = notifyMessageReadInfoMapper.insertBatch(batchInsertReadInfoList);
|
||||
if (!insertBatch) {
|
||||
log.error("[updateAllNotifyMessageRead][新增站内信消息阅读信息失败]");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
//return notifyMessageMapper.updateListRead(userId, userType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMessageRead(Collection<String> messageIds, Long userId) {
|
||||
return bitGet(messageIds,userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<NotifyMessageRespVO> getPageResultByRead(NotifyMessageMyPageReqVO pageVO) {
|
||||
Boolean readStatus = pageVO.getReadStatus();
|
||||
Long userId = getLoginUserId();
|
||||
List<NotifyMessageDO> notifyMessageDOS = notifyMessageMapper.selectList(new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.eq(NotifyMessageDO::getUserType, 2)
|
||||
.in(NotifyMessageDO::getUserId, Arrays.asList(userId, 0L))
|
||||
.betweenIfPresent(NotifyMessageDO::getCreateTime, pageVO.getCreateTime())
|
||||
);
|
||||
Set<String> messageIds = notifyMessageDOS.stream().map(e -> e.getId().toString()).collect(Collectors.toSet());
|
||||
Set<String> set = bitGet(messageIds, userId);
|
||||
List<NotifyMessageRespVO> respVOS = notifyMessageDOS.stream()
|
||||
.filter(f -> readStatus ? set.contains(f.getId().toString()): !set.contains(f.getId().toString()))
|
||||
.skip((long) (pageVO.getPageNo() - 1) * pageVO.getPageSize())
|
||||
.limit(pageVO.getPageSize())
|
||||
.map(e -> {
|
||||
NotifyMessageRespVO respVO = BeanUtils.toBean(e, NotifyMessageRespVO.class);
|
||||
respVO.setReadStatus(readStatus);
|
||||
return respVO;
|
||||
})
|
||||
.toList();
|
||||
|
||||
return new PageResult<>(respVOS, (long)respVOS.size());
|
||||
}
|
||||
|
||||
private Boolean bitset(Collection<String> keys, Long userId) {
|
||||
return stringRedisTemplate.execute((RedisCallback<Boolean>) connection -> {
|
||||
AtomicReference<Boolean> flag = new AtomicReference<>(false);
|
||||
keys.forEach(key -> flag.set(connection.setBit(joinKey(key).getBytes(StandardCharsets.UTF_8), userId, true)));
|
||||
return flag.get();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private Set<String> bitGet(Collection<String> keys, Long userId) {
|
||||
return stringRedisTemplate.execute((RedisCallback<Set<String>>)connection -> {
|
||||
Set<String> set = new HashSet<>();
|
||||
keys.forEach(key->{
|
||||
Boolean bit = connection.getBit(joinKey(key).getBytes(StandardCharsets.UTF_8), userId);
|
||||
if(bit) {
|
||||
set.add(key);
|
||||
}
|
||||
});
|
||||
return set;
|
||||
});
|
||||
}
|
||||
|
||||
private String joinKey(String key) {
|
||||
return NOTIFY_MESSAGE_KEY + key;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -187,6 +187,7 @@ chenfeng:
|
||||
- system_label_element_template
|
||||
- system_data_source
|
||||
- system_notify_message
|
||||
- system_notify_message_readinfo
|
||||
- system_data_source_field
|
||||
use-data-code: imes_prod #动态数据源标识,后期添加的数据源需要修改此值
|
||||
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.notify.NotifyMessageMapper">
|
||||
<resultMap id="messageMap" type="com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageDO">
|
||||
<result property="templateParams" column="template_params" javaType="java.util.Map" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getMyMyNotifyMessage" resultMap="messageMap">
|
||||
select distinct m.*,
|
||||
coalesce(r.id is not null, true) as readStatus
|
||||
, r.read_time readTime
|
||||
from system_notify_message m
|
||||
left join system_notify_message_readinfo r on r.message_id = m.id and r.user_id = #{reqVo.userId}
|
||||
<where>
|
||||
<if test="reqVo.readStatus != null and reqVo.readStatus">
|
||||
r.id is not null
|
||||
</if>
|
||||
<if test="reqVo.readStatus != null and !reqVo.readStatus">
|
||||
r.id is null
|
||||
</if>
|
||||
<if test="reqVo.createTime != null">
|
||||
and m.create_time between #{reqVo.createTime[0]} and #{reqVo.createTime[1]}
|
||||
</if>
|
||||
<if test="reqVo.userType != null">
|
||||
and m.user_type = #{reqVo.userType}
|
||||
</if>
|
||||
<if test="reqVo.templateCode != null and reqVo.templateCode != ''">
|
||||
and m.template_code = #{reqVo.templateCode}
|
||||
</if>
|
||||
<if test="reqVo.templateType != null">
|
||||
and m.template_type = #{reqVo.templateType}
|
||||
</if>
|
||||
</where>
|
||||
order by m.id desc
|
||||
</select>
|
||||
|
||||
<select id="getUnreadNotifyMessageCount" resultType="java.lang.Integer">
|
||||
select count(distinct m.id)
|
||||
from system_notify_message m
|
||||
left join system_notify_message_readinfo r on r.message_id = m.id and r.user_id = #{userId}
|
||||
where r.id is null
|
||||
and m.user_type = #{userType}
|
||||
</select>
|
||||
|
||||
<select id="getUnreadNotifyMessageIds" resultType="java.lang.Long">
|
||||
select m.id
|
||||
from system_notify_message m
|
||||
left join system_notify_message_readinfo r on r.message_id = m.id and r.user_id = #{userId}
|
||||
where r.id is null
|
||||
and m.user_type = #{userType}
|
||||
</select>
|
||||
</mapper>
|
||||
+14
-11
@@ -5,7 +5,6 @@ import com.cf.imes.framework.common.enums.UserTypeEnum;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.enums.SqlConstants;
|
||||
import com.cf.imes.framework.test.core.ut.BaseDbUnitTest;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
@@ -17,7 +16,6 @@ import org.springframework.context.annotation.Import;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
@@ -101,7 +99,7 @@ public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
|
||||
reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10));
|
||||
|
||||
// 调用
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
@@ -144,12 +142,14 @@ public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
|
||||
// 准备参数
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
NotifyMessageMyPageReqVO reqVO = new NotifyMessageMyPageReqVO();
|
||||
NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
|
||||
reqVO.setReadStatus(true);
|
||||
reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10));
|
||||
reqVO.setUserId(userId);
|
||||
reqVO.setUserType(userType);
|
||||
|
||||
// 调用
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO, userId, userType);
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
@@ -163,7 +163,6 @@ public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
//o.setReadStatus(false);
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
@@ -176,13 +175,17 @@ public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
|
||||
// 准备参数
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
Integer size = 10;
|
||||
|
||||
NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
|
||||
reqVO.setReadStatus(false);
|
||||
reqVO.setPageSize(10);
|
||||
reqVO.setPageNo(1);
|
||||
reqVO.setUserId(userId);
|
||||
reqVO.setUserType(userType);
|
||||
// 调用
|
||||
List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(userId, userType, size);
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbNotifyMessage, list.get(0));
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user