|
@@ -7,6 +7,7 @@ import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
+import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -38,6 +39,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
@@ -146,10 +148,25 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
//文件名称:课题名称-申请人-申请日期-随机四位.docx
|
|
|
String applyDate = DateUtil.format(sampleInfo.getApplyTime(), DatePattern.CHINESE_DATE_PATTERN);
|
|
|
String fileName = String.format("病理实验计划表-%s-%s-%s-%s.docx",
|
|
|
- pathologicalVo.getSubjectName(), sampleInfo.getApplicantName(), applyDate,
|
|
|
+ StrUtil.nullToEmpty(pathologicalVo.getSubjectName()), StrUtil.nullToEmpty(sampleInfo.getApplicantName()),
|
|
|
+ applyDate,
|
|
|
RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER_LOWER, 4));
|
|
|
log.info("生成word 课题名称:{} 文件名称:{}", pathologicalVo.getSubjectName(), fileName);
|
|
|
|
|
|
+ //切片数量为负数,重新设置为null
|
|
|
+ Field[] intFields = ReflectUtil.getFields(SamplePathologicalVo.class, f -> f.getType().equals(Integer.class));
|
|
|
+ for (Field field : intFields) {
|
|
|
+ try {
|
|
|
+ field.setAccessible(true);
|
|
|
+ Integer value = (Integer) field.get(pathologicalVo);
|
|
|
+ if (value!= null && value < 0) {
|
|
|
+ field.set(pathologicalVo, null);
|
|
|
+ }
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ log.error("反射获取字段值失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
JSONObject dataMap = new JSONObject();
|
|
|
wordDataService.fillDocCreator(dataMap);
|
|
|
|