特权逻辑
This commit is contained in:
@@ -74,4 +74,5 @@ public class LbAssessmentApplyController {
|
|||||||
}
|
}
|
||||||
return ResponseEntity.internalServerError().body(result);
|
return ResponseEntity.internalServerError().body(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,4 +77,19 @@ public class LbPurchaseApplyController {
|
|||||||
}
|
}
|
||||||
return ResponseEntity.internalServerError().body(result);
|
return ResponseEntity.internalServerError().body(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/needPrivilegeRecommenders")
|
||||||
|
@Operation(summary = "按日期范围查询需要添加特权的推荐人")
|
||||||
|
public ResponseEntity<Map<String, Object>> needPrivilegeRecommenders(
|
||||||
|
@Parameter(description = "开始日期(yyyy-MM-dd)", required = true)
|
||||||
|
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
|
||||||
|
@Parameter(description = "结束日期(yyyy-MM-dd)", required = true)
|
||||||
|
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) {
|
||||||
|
Map<String, Object> result = lbPurchaseApplyService.listNeedPrivilegeRecommenders(startDate, endDate);
|
||||||
|
Boolean success = (Boolean) result.get("success");
|
||||||
|
if (success != null && success) {
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
}
|
||||||
|
return ResponseEntity.badRequest().body(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,5 @@ public interface ILbAssessmentApplyService extends IService<LbAssessmentApply> {
|
|||||||
String applicantPhone,
|
String applicantPhone,
|
||||||
String colleagueName,
|
String colleagueName,
|
||||||
String teamLeaderName);
|
String teamLeaderName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,6 @@ public interface ILbPurchaseApplyService extends IService<LbPurchaseApply> {
|
|||||||
String colleagueName,
|
String colleagueName,
|
||||||
String teamLeader,
|
String teamLeader,
|
||||||
LocalDate applyDate);
|
LocalDate applyDate);
|
||||||
|
|
||||||
|
Map<String, Object> listNeedPrivilegeRecommenders(LocalDate startDate, LocalDate endDate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,31 @@ package com.rj.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.rj.entity.LbDailyUserTradeReport;
|
||||||
import com.rj.entity.LbPurchaseApply;
|
import com.rj.entity.LbPurchaseApply;
|
||||||
|
import com.rj.mapper.LbDailyUserTradeReportMapper;
|
||||||
import com.rj.mapper.LbPurchaseApplyMapper;
|
import com.rj.mapper.LbPurchaseApplyMapper;
|
||||||
import com.rj.service.ILbPurchaseApplyService;
|
import com.rj.service.ILbPurchaseApplyService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LbPurchaseApplyServiceImpl
|
public class LbPurchaseApplyServiceImpl
|
||||||
extends ServiceImpl<LbPurchaseApplyMapper, LbPurchaseApply>
|
extends ServiceImpl<LbPurchaseApplyMapper, LbPurchaseApply>
|
||||||
implements ILbPurchaseApplyService {
|
implements ILbPurchaseApplyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LbDailyUserTradeReportMapper lbDailyUserTradeReportMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> add(LbPurchaseApply entity) {
|
public Map<String, Object> add(LbPurchaseApply entity) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
@@ -157,4 +167,82 @@ public class LbPurchaseApplyServiceImpl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> listNeedPrivilegeRecommenders(LocalDate startDate, LocalDate endDate) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if (startDate == null || endDate == null) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "开始日期和结束日期不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (endDate.isBefore(startDate)) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "结束日期不能早于开始日期");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<LbPurchaseApply> purchaseQuery = new LambdaQueryWrapper<>();
|
||||||
|
purchaseQuery.ge(LbPurchaseApply::getApplyDate, startDate)
|
||||||
|
.le(LbPurchaseApply::getApplyDate, endDate)
|
||||||
|
.orderByDesc(LbPurchaseApply::getApplyDate)
|
||||||
|
.orderByDesc(LbPurchaseApply::getApplyDate) ;
|
||||||
|
List<LbPurchaseApply> purchaseInfo = this.list(purchaseQuery);
|
||||||
|
|
||||||
|
if (purchaseInfo == null || purchaseInfo.isEmpty()) {
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("message", "查询成功");
|
||||||
|
result.put("data", List.of());
|
||||||
|
result.put("total", 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> applyUsers = new HashSet<>();
|
||||||
|
for (LbPurchaseApply item : purchaseInfo) {
|
||||||
|
if (item.getApplyUser() != null && !item.getApplyUser().trim().isEmpty()) {
|
||||||
|
applyUsers.add(item.getApplyUser().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (applyUsers.isEmpty()) {
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("message", "查询成功");
|
||||||
|
result.put("data", List.of());
|
||||||
|
result.put("total", 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<LbDailyUserTradeReport> reportQuery = new LambdaQueryWrapper<>();
|
||||||
|
reportQuery.in(LbDailyUserTradeReport::getNickname, applyUsers)
|
||||||
|
.select(LbDailyUserTradeReport::getNickname);
|
||||||
|
List<LbDailyUserTradeReport> matchedReports = lbDailyUserTradeReportMapper.selectList(reportQuery);
|
||||||
|
|
||||||
|
Set<String> matchedNicknames = new HashSet<>();
|
||||||
|
for (LbDailyUserTradeReport report : matchedReports) {
|
||||||
|
if (report.getNickname() != null && !report.getNickname().trim().isEmpty()) {
|
||||||
|
matchedNicknames.add(report.getNickname().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LbPurchaseApply> needPrivilegeList = new ArrayList<>();
|
||||||
|
for (LbPurchaseApply item : purchaseInfo) {
|
||||||
|
String applyUser = item.getApplyUser() == null ? null : item.getApplyUser().trim();
|
||||||
|
if (applyUser != null && !applyUser.isEmpty() && matchedNicknames.contains(applyUser)) {
|
||||||
|
needPrivilegeList.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("message", "查询成功");
|
||||||
|
result.put("data", needPrivilegeList);
|
||||||
|
result.put("total", needPrivilegeList.size());
|
||||||
|
result.put("startDate", startDate);
|
||||||
|
result.put("endDate", endDate);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "查询异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user