update
This commit is contained in:
@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -127,16 +128,65 @@ public class IdentifyBookDataServiceImpl implements IdentifyBookDataService {
|
|||||||
bookData.setTestMethod(getTestMethods(testRecordInfo));//设置用到的实验方法
|
bookData.setTestMethod(getTestMethods(testRecordInfo));//设置用到的实验方法
|
||||||
//设置检验过程
|
//设置检验过程
|
||||||
bookData.setTestProcessDes(testRecordInfo.getTestProcessDes());//设置检验过程
|
bookData.setTestProcessDes(testRecordInfo.getTestProcessDes());//设置检验过程
|
||||||
bookData.setTestResult(testRecordSampleDataService.generateQualitativeResults(businessId));
|
//设置检验结果
|
||||||
|
bookData.setTestResult(inspectRecordService.buildInspectOpinion(testRecordSampleDataService
|
||||||
|
.lambdaQuery()
|
||||||
|
.eq(TestRecordSampleData::getTestId, testRecordInfo.getId())
|
||||||
|
.eq(TestRecordSampleData::getSampleType, "Analyte")
|
||||||
|
.list()));
|
||||||
|
|
||||||
//检验日期
|
//检验日期
|
||||||
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
|
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
|
||||||
bookData.setTestStartDate(sdf.format(testRecordInfo.getCreateTime()));
|
bookData.setTestStartDate(sdf.format(testRecordInfo.getCreateTime()));
|
||||||
bookData.setTestOptUser(testRecordInfo.getTestUserId());
|
bookData.setTestOptUser(testRecordInfo.getTestUserId());
|
||||||
bookData.setTestFinishDate(sdf.format(testRecordInfo.getUpdateTime()));
|
LocalDateTime testFinishDate = testRecordInfo.getUpdateTime();
|
||||||
|
String chineseTestFinishDate = convertToChineseDate(testFinishDate);
|
||||||
|
bookData.setTestFinishDate(chineseTestFinishDate);
|
||||||
|
System.out.println("打印的实验结束时间:" + chineseTestFinishDate);
|
||||||
return bookData;
|
return bookData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自定义方法:将 LocalDateTime 转换为中文日期格式
|
||||||
|
public static String convertToChineseDate(LocalDateTime date) {
|
||||||
|
// 获取年月日
|
||||||
|
int year = date.getYear();
|
||||||
|
int month = date.getMonthValue();
|
||||||
|
int day = date.getDayOfMonth();
|
||||||
|
|
||||||
|
// 处理年:去掉“二零”前缀,只保留后两位
|
||||||
|
String yearStr = convertNumberToChineseForYear(year % 100) + "年";
|
||||||
|
|
||||||
|
// 处理月和日
|
||||||
|
String monthStr = convertNumberToChinese(month) + "月";
|
||||||
|
String dayStr = convertNumberToChinese(day) + "日";
|
||||||
|
|
||||||
|
return yearStr + monthStr + dayStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数字转中文
|
||||||
|
public static String convertNumberToChinese(int number) {
|
||||||
|
String[] chineseDigits = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
|
||||||
|
if (number <= 10) {
|
||||||
|
return chineseDigits[number];
|
||||||
|
} else if (number < 20) {
|
||||||
|
return "十" + chineseDigits[number % 10];
|
||||||
|
} else if (number % 10 == 0) {
|
||||||
|
return chineseDigits[number / 10] + "十";
|
||||||
|
} else {
|
||||||
|
return chineseDigits[number / 10] + "十" + chineseDigits[number % 10];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数字转中文(用于年)
|
||||||
|
public static String convertNumberToChineseForYear(int number) {
|
||||||
|
String[] chineseDigits = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
|
||||||
|
if (number < 10) {
|
||||||
|
return chineseDigits[number];
|
||||||
|
} else {
|
||||||
|
return chineseDigits[number / 10] + chineseDigits[number % 10];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//获取业务的实验对象
|
//获取业务的实验对象
|
||||||
private TestRecord getTestRecordInfo(List<TestRecordSampleSolution> testRecordSampleSolutionList) {
|
private TestRecord getTestRecordInfo(List<TestRecordSampleSolution> testRecordSampleSolutionList) {
|
||||||
List<String> testIdList = testRecordSampleSolutionList.stream().map(s -> s.getTestId()).collect(Collectors.toList());
|
List<String> testIdList = testRecordSampleSolutionList.stream().map(s -> s.getTestId()).collect(Collectors.toList());
|
||||||
|
|||||||
Reference in New Issue
Block a user