20250228 更新
添加根据机构查询
This commit is contained in:
@@ -84,13 +84,13 @@ public class EntrustMaterialCheckoutResultController {
|
||||
|
||||
@ApiOperation("查询所有检出检材的毒品种类清单,并按名称进行排序")
|
||||
@GetMapping("/getResultType")
|
||||
public R getResultType(Integer year){
|
||||
return R.ok(entrustMaterialCheckoutResultService.getResultType(year),"查询成功!");
|
||||
public R getResultType(Integer year, String orgId){
|
||||
return R.ok(entrustMaterialCheckoutResultService.getResultType(year, orgId),"查询成功!");
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有毒品的检出率")
|
||||
@GetMapping("/getDetectionRate")
|
||||
public R getDetectionRateByMaterial(Integer year){
|
||||
return R.ok(entrustMaterialCheckoutResultService.getDetectionRateByMaterial(year),"查询成功!");
|
||||
public R getDetectionRateByMaterial(Integer year, String orgId){
|
||||
return R.ok(entrustMaterialCheckoutResultService.getDetectionRateByMaterial(year, orgId),"查询成功!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultV
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ChenJiangBao
|
||||
@@ -50,7 +49,21 @@ public interface EntrustMaterialCheckoutResultService extends IService<EntrustMa
|
||||
*/
|
||||
IPage<EntrustMaterialCheckoutResultVO> voiPage(EntrustMaterialCheckoutResultQuery query);
|
||||
|
||||
List<String> getResultType(Integer year);
|
||||
/**
|
||||
* 查询所有检出检材的毒品种类清单,并按名称进行排序
|
||||
*
|
||||
* @param year
|
||||
* @param orgId
|
||||
* @return
|
||||
*/
|
||||
List<String> getResultType(Integer year, String orgId);
|
||||
|
||||
DetectionRateVO getDetectionRateByMaterial(Integer year);
|
||||
/**
|
||||
* 查询所有毒品的检出率
|
||||
*
|
||||
* @param year
|
||||
* @param orgId
|
||||
* @return
|
||||
*/
|
||||
DetectionRateVO getDetectionRateByMaterial(Integer year, String orgId);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import digital.laboratory.platform.entrustment.service.EntrustmentIdentification
|
||||
import digital.laboratory.platform.entrustment.service.EntrustmentService;
|
||||
import digital.laboratory.platform.entrustment.vo.DetectionRateVO;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO;
|
||||
import digital.laboratory.platform.sys.entity.Area;
|
||||
import digital.laboratory.platform.sys.entity.DrugLite;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
@@ -361,38 +360,30 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
return typeName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 获取指定年份的所有毒品类型列表(去重并排序)
|
||||
* <p>
|
||||
* 该方法通过查询指定年份内所有非空且不为空的定性结果,提取其中的毒品类型信息,
|
||||
* 并返回一个去重且按字典序排序的毒品类型列表。
|
||||
*
|
||||
* @param year 年份,若为 null 则默认使用当前年份
|
||||
* @param year 年份,若为 null 则默认使用当前年份
|
||||
* @param orgId
|
||||
* @return 包含所有毒品类型的列表,列表中的毒品类型名称已去重并排序
|
||||
*
|
||||
* @see EntrustMaterialCheckoutResult 委托材料检验结果实体类,包含定性结果字段
|
||||
* @see DrugLite 药品轻量级实体类,包含药品名称字段
|
||||
* @see DrugLiteConvert 工具类,用于将定性结果转换为毒品轻量级实体列表
|
||||
*/
|
||||
public List<String> getResultType(Integer year) {
|
||||
@Override
|
||||
public List<String> getResultType(Integer year, String orgId) {
|
||||
// 根据年份构建查询起始时间
|
||||
LocalDateTime startTime = null;
|
||||
if (year != null) {
|
||||
// 如果年份不为空,使用指定年份的1月1日 00:00:00
|
||||
startTime = LocalDateTime.of(year, 1, 1, 0, 0);
|
||||
} else {
|
||||
// 如果年份为空,默认使用当前年份的1月1日 00:00:00
|
||||
startTime = LocalDateTime.of(LocalDateTime.now().getYear(), 1, 1, 0, 0);
|
||||
}
|
||||
|
||||
LocalDateTime startTime = getStartTime(year);
|
||||
List<String> entrustIdList = getEntrustIdListByOrgId(orgId);
|
||||
// 查询所有非空且不为空的定性结果,且创建时间大于等于起始时间
|
||||
List<EntrustMaterialCheckoutResult> list = this.list(Wrappers.<EntrustMaterialCheckoutResult>lambdaQuery()
|
||||
.ne(EntrustMaterialCheckoutResult::getQualitativeResult, "") // 排除空字符串
|
||||
.isNotNull(EntrustMaterialCheckoutResult::getQualitativeResult) // 排除空值
|
||||
.ge(EntrustMaterialCheckoutResult::getCreateTime, startTime)); // 创建时间大于等于起始时间
|
||||
.in(CollUtil.isNotEmpty(entrustIdList), EntrustMaterialCheckoutResult::getEntrustId, entrustIdList)
|
||||
.ne(EntrustMaterialCheckoutResult::getQualitativeResult, "") // 排除空字符串
|
||||
.isNotNull(EntrustMaterialCheckoutResult::getQualitativeResult) // 排除空值
|
||||
.ge(EntrustMaterialCheckoutResult::getCreateTime, startTime)); // 创建时间大于等于起始时间
|
||||
|
||||
// 用于存储去重后的毒品类型列表
|
||||
ArrayList<String> typeList = new ArrayList<>();
|
||||
@@ -418,16 +409,8 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
return typeList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DetectionRateVO getDetectionRateByMaterial(Integer year) {
|
||||
// 获取所有毒品类型列表
|
||||
List<String> resultType = this.getResultType(year);
|
||||
// 用于存储毒品名称及其检出占比的映射表
|
||||
DetectionRateVO vo = new DetectionRateVO();
|
||||
ArrayList<String> nameList = new ArrayList<>();
|
||||
ArrayList<String> percentList = new ArrayList<>();
|
||||
// 根据年份构建查询起始时间
|
||||
// 获取开始时间
|
||||
private LocalDateTime getStartTime(Integer year) {
|
||||
LocalDateTime startTime = null;
|
||||
if (year != null) {
|
||||
// 如果年份不为空,使用指定年份的1月1日 00:00:00
|
||||
@@ -436,11 +419,36 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
// 如果年份为空,默认使用当前年份的1月1日 00:00:00
|
||||
startTime = LocalDateTime.of(LocalDateTime.now().getYear(), 1, 1, 0, 0);
|
||||
}
|
||||
return startTime;
|
||||
}
|
||||
|
||||
// 根据机构id获取委托id
|
||||
private List<String> getEntrustIdListByOrgId(String orgId) {
|
||||
if (StrUtil.isBlank(orgId)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Entrustment> entrustmentList = entrustmentService.list(Wrappers.<Entrustment>lambdaQuery().eq(Entrustment::getClientOrgId, orgId));
|
||||
return entrustmentList.stream().map(Entrustment::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DetectionRateVO getDetectionRateByMaterial(Integer year, String orgId) {
|
||||
// 获取所有毒品类型列表
|
||||
List<String> resultType = this.getResultType(year, orgId);
|
||||
// 用于存储毒品名称及其检出占比的映射表
|
||||
DetectionRateVO vo = new DetectionRateVO();
|
||||
ArrayList<String> nameList = new ArrayList<>();
|
||||
ArrayList<String> percentList = new ArrayList<>();
|
||||
// 根据年份构建查询起始时间
|
||||
LocalDateTime startTime = getStartTime(year);
|
||||
List<String> entrustIdList = getEntrustIdListByOrgId(orgId);
|
||||
|
||||
// 查询所有非空且不为空的定性结果,且创建时间大于等于起始时间
|
||||
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list(Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery()
|
||||
.ge(EntrustmentIdentificationMaterial::getAcceptTime, startTime)
|
||||
.eq(EntrustmentIdentificationMaterial::getAcceptPassed, 1));
|
||||
.in(CollUtil.isNotEmpty(entrustIdList), EntrustmentIdentificationMaterial::getEntrustmentId, entrustIdList)
|
||||
.ge(EntrustmentIdentificationMaterial::getAcceptTime, startTime)
|
||||
.eq(EntrustmentIdentificationMaterial::getAcceptPassed, 1));
|
||||
|
||||
|
||||
// 如果查询结果为空,直接返回 null
|
||||
|
||||
Reference in New Issue
Block a user