|
|
|
@ -12,6 +12,7 @@ import com.epmet.commons.tools.dto.result.YtHscyResDTO; |
|
|
|
import com.epmet.commons.tools.dto.result.YtHsjcResDTO; |
|
|
|
import com.epmet.commons.tools.enums.GenderEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
@ -39,12 +40,16 @@ import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -72,6 +77,12 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
@Autowired |
|
|
|
private ExecutorService executorService; |
|
|
|
|
|
|
|
@Resource(name = "yantaiNamedParamLantuJdbcTemplate") |
|
|
|
private NamedParameterJdbcTemplate yantaiNamedParamLantuJdbcTemplate; |
|
|
|
|
|
|
|
@Resource(name = "yantaiLantuJdbcTemplate") |
|
|
|
private JdbcTemplate yantaiJdbcTemplate; |
|
|
|
|
|
|
|
@Override |
|
|
|
public DataSyncConfigDTO get(String id) { |
|
|
|
DataSyncConfigEntity entity = baseDao.selectById(id); |
|
|
|
@ -769,4 +780,125 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 烟台核酸检测(视图方式获取数据) |
|
|
|
* @param resiInfos |
|
|
|
* @param customerId |
|
|
|
* @param isSync |
|
|
|
*/ |
|
|
|
public void yantaiHsjcByDbView(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) { |
|
|
|
List<List<NatUserInfoResultDTO>> resiInfobatchs = ListUtils.partition(resiInfos, 50); |
|
|
|
for (List<NatUserInfoResultDTO> resibatch : resiInfobatchs) { |
|
|
|
// n个一批,来处理他们的核酸信息,太多怕给数据库查崩了。
|
|
|
|
try { |
|
|
|
yantaiHsjcByDbViewPartition(resibatch, customerId, isSync); |
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
log.error("【更新核酸检测信息(from 兰图)】失败,信息:{}", errorMsg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* n个一批,来处理他们的核酸信息,太多怕给数据库查崩了。 |
|
|
|
* @param resiInfos |
|
|
|
* @param customerId |
|
|
|
* @param isSync |
|
|
|
*/ |
|
|
|
public void yantaiHsjcByDbViewPartition(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) { |
|
|
|
// 将居民信息转化为<idCard,resiInfo>的map
|
|
|
|
Map<String, NatUserInfoResultDTO> idCardAndResiInfo = resiInfos.stream().collect(Collectors.toMap(resi -> resi.getIdCard(), Function.identity())); |
|
|
|
List<String> idCards = new ArrayList<>(idCardAndResiInfo.keySet()); |
|
|
|
// 1.获取核酸采样信息
|
|
|
|
Map<String, Object> args = new HashMap<>(); |
|
|
|
args.put("idcards", idCards); |
|
|
|
|
|
|
|
log.info("【更新核酸检测信息(from 兰图)】本批次身份证号为:{}", String.join(",", idCards)); |
|
|
|
|
|
|
|
// 2.=====================核酸采样=========================
|
|
|
|
// 这一批居民的核酸采样列表
|
|
|
|
List<Map<String, Object>> hscyList = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
|
"select id, name,card_no, create_time, realname from hscyxxb where card_no in (:idcards) order by create_time desc", args); |
|
|
|
if (CollectionUtils.isNotEmpty(hscyList)) { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
hscyList.forEach(resiHscyInfo -> { |
|
|
|
// 从视图中获取到的核酸采样相关信息
|
|
|
|
String name = (String) resiHscyInfo.get("name"); |
|
|
|
String cardNo = (String) resiHscyInfo.get("card_no"); |
|
|
|
String createTime = (String) resiHscyInfo.get("create_time"); |
|
|
|
|
|
|
|
// 本地数据库中,居民信息
|
|
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
|
|
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
e.setUserId(currentResiInfo.getUserId()); |
|
|
|
e.setMobile(""); |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
e.setName(StringUtils.isNotBlank(name) ? name : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(cardNo) ? cardNo : ""); |
|
|
|
e.setSampleTime(DateUtils.parseDate(createTime, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setAgencyId(currentResiInfo.getAgencyId()); |
|
|
|
e.setPids(currentResiInfo.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
|
e.setAttachmentUrl(""); |
|
|
|
entities.add(e); |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(entities)){ |
|
|
|
List<NatUserInfoResultDTO> existSampleInfo = icNatDao.getExistNatInfo(entities); |
|
|
|
sampleAndNat(existSampleInfo,entities,NumConstant.ONE_STR,customerId,isSync); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 2.=====================核酸采样=========================
|
|
|
|
|
|
|
|
// 这一批居民的核酸采样列表
|
|
|
|
List<Map<String, Object>> hsjcResultList = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
|
"select name, telephone, card_no, test_time, SAMPLE_TIME, SAMPLE_RESULT_PCR, SAMPLING_ORG_PCR from hsjcxxb where card_no in (:idcards)", args); |
|
|
|
if (CollectionUtils.isNotEmpty(hsjcResultList)) { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
hsjcResultList.forEach(natResult -> { |
|
|
|
// 从视图中获取到的核酸采样相关信息
|
|
|
|
String name = (String) natResult.get("name"); |
|
|
|
String cardNo = (String) natResult.get("card_no"); |
|
|
|
String testTime = (String) natResult.get("test_time"); |
|
|
|
String telephone = (String) natResult.get("telephone"); |
|
|
|
String sampleTime = (String) natResult.get("SAMPLE_TIME"); |
|
|
|
String sampleResultPcr = (String) natResult.get("SAMPLE_RESULT_PCR"); |
|
|
|
String samplingOrgPcr = (String) natResult.get("SAMPLING_ORG_PCR"); |
|
|
|
|
|
|
|
// 本地数据库中,居民信息
|
|
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
|
|
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
e.setUserId(currentResiInfo.getUserId()); |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
e.setName(StringUtils.isNotBlank(name) ? name : ""); |
|
|
|
e.setMobile(StringUtils.isNotBlank(telephone) ? telephone : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(cardNo) ? cardNo : ""); |
|
|
|
e.setNatTime(DateUtils.parseDate(testTime, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setSampleTime(DateUtils.parseDate(sampleTime, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
String resultPcr = sampleResultPcr; |
|
|
|
//检测结果 转换 我们 0:阴性 1:阳性, 他们 :1:阳性,2:阴性
|
|
|
|
e.setNatResult(NumConstant.ZERO_STR); |
|
|
|
if (NumConstant.ONE_STR.equals(resultPcr)) { |
|
|
|
e.setNatResult(NumConstant.ONE_STR); |
|
|
|
} |
|
|
|
e.setNatAddress(samplingOrgPcr); |
|
|
|
e.setAgencyId(currentResiInfo.getAgencyId()); |
|
|
|
e.setPids(currentResiInfo.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
|
e.setAttachmentUrl(""); |
|
|
|
entities.add(e); |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(entities)) { |
|
|
|
List<NatUserInfoResultDTO> existNatInfos = icNatDao.getExistNatInfo(entities); |
|
|
|
sampleAndNat(existNatInfos,entities,NumConstant.TWO_STR,customerId,isSync); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|