陈昶聿
12 小时以前 5dcd6447f315e821727508cd26bf05f8220b39c8
smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -74,6 +74,8 @@
    @Override
    public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
        PatMedOuthospQueryReq patMedOuthospQueryReq = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatMedOuthospQueryReq.class);
        patMedOuthospQueryReq.setBeginAdmitdate(patMedOuthosp.getBeginTime());
        patMedOuthospQueryReq.setEndAdmitdate(patMedOuthosp.getEndTime());
        List<PatMedOuthosp> patMedOuthospQueryResps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospQueryReq);
        if (patMedOuthosp.getPageNum() != null) {
            for (PatMedOuthosp patMedOuthosp1 : patMedOuthospQueryResps) {
@@ -166,20 +168,28 @@
     */
    @Override
    public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) {
        if (patMedOuthosp.getAdmitdate() != null) {
        if (patMedOuthosp.getAdmitdate() == null) {
            log.error("门急就诊时间不能为空");
            return 0;
        }
        // 需要插入到哪个表,根据就诊时间的日期来定,如果根据就诊时间来确定的表不存在,则存在pat_med_outhosp表中
        String targetTable = resolveTargetTable(patMedOuthosp.getAdmitdate());
        if (targetTable == null) {
            return 0;
        }
        // 插入前按 serialnum 查重,防止重复采集导致重复入库
        if (org.apache.commons.lang3.StringUtils.isNotBlank(patMedOuthosp.getSerialnum())) {
            int exists = patMedOuthospMapper.countBySerialnum(targetTable, patMedOuthosp.getSerialnum());
            if (exists > 0) {
                log.debug("[insert] serialnum={} 已存在于表 {},跳过插入", patMedOuthosp.getSerialnum(), targetTable);
                return 0;
            }
        }
        patMedOuthosp.setCreateTime(DateUtils.getNowDate());
        patMedOuthosp.setUpdateTime(DateUtils.getNowDate());
        patMedOuthosp.setGuid(UUID.randomUUID().toString());
        //需要插入到哪个表,根据就诊时间的日期来定,如果根据就诊时间来确定的表不存在,则存在pat_med_outhosp表中
        String targetTable = resolveTargetTable(patMedOuthosp.getAdmitdate());
        if (targetTable != null) {
            log.info("[insert] 路由到分表: {}", targetTable);
            return patMedOuthospMapper.insertIntoTable(targetTable, patMedOuthosp);
        }
        return 0;
        log.info("[insert] 路由到分表: {}", targetTable);
        return patMedOuthospMapper.insertIntoTable(targetTable, patMedOuthosp);
    }
    /**