package jnpf.limsService.print;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import jnpf.exception.DataException;
import jnpf.limsEntity.LimsHuanjingJianceBaogaoEntity;
import jnpf.limsEntity.LimsHuanjingJianceBaogaoZixiangEntity;
import jnpf.limsEntity.LimsHuanjingJianceBiaozhunEntity;
import jnpf.limsEntity.LimsHuanjingJianceYijuEntity;
import jnpf.limsEntity.LimsHuanjingQuyuEntity;
import jnpf.limsEntity.LimsPrintTemplateEntity;
import jnpf.limsMapper.LimsHuanjingJianceBaogaoMapper;
import jnpf.limsMapper.LimsHuanjingJianceBaogaoZixiangMapper;
import jnpf.limsMapper.LimsHuanjingJianceBiaozhunMapper;
import jnpf.limsMapper.LimsHuanjingJianceYijuMapper;
import jnpf.limsMapper.LimsHuanjingQuyuMapper;
import jnpf.permission.UserApi;
import jnpf.permission.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* "表面微生物检测记录"模板渲染器(template_id = huanjing_weishengwu)。
*
*
输入:lims_huanjing_jiance_baogao.f_id;子项来自
* lims_huanjing_jiance_baogao_zixiang.f_foreign_id。
*/
@Component
public class HuanjingWeishengwuRenderer implements PrintTemplateRenderer {
public static final String TEMPLATE_ID = "huanjing_weishengwu";
private static final String DEFAULT_COMPANY_NAME = "华道(上海)生物医药有限公司";
private static final String DEFAULT_DOC_NUMBER = "SOP-MBC-A020-TO-R01-02";
private static final String DEFAULT_REVIEW_CYCLE = "3年";
private static final String DEFAULT_METHOD_TEXT = "SOP-MBC-A020-TO《表面微生物检测标准操作规程》";
@Autowired
private LimsHuanjingJianceBaogaoMapper baogaoMapper;
@Autowired
private LimsHuanjingJianceBaogaoZixiangMapper zixiangMapper;
@Autowired
private LimsHuanjingJianceBiaozhunMapper biaozhunMapper;
@Autowired
private LimsHuanjingJianceYijuMapper yijuMapper;
@Autowired
private LimsHuanjingQuyuMapper quyuMapper;
@Autowired
private UserApi usersApi;
@Autowired
private ObjectMapper objectMapper;
@Override
public String getTemplateId() {
return TEMPLATE_ID;
}
@Override
public Map render(String baogaoId, LimsPrintTemplateEntity tpl) {
if (baogaoId == null || baogaoId.isEmpty()) {
throw new DataException("缺少环境监测报告 id");
}
Map baogao = getBaogaoMap(baogaoId);
if (baogao.isEmpty()) {
throw new DataException("环境监测报告不存在或已删除: " + baogaoId);
}
Map cfg = parseConfig(tpl);
List