|
|
@@ -1,6 +1,7 @@
|
|
|
package com.github.jfcloud.gene.lis.service;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
@@ -20,8 +21,8 @@ import com.github.jfcloud.gene.sample.entity.SampleCheckOrder;
|
|
|
import com.github.jfcloud.gene.sample.entity.SampleInfo;
|
|
|
import com.github.jfcloud.gene.sample.enums.ScientificSampleTypeEnum;
|
|
|
import com.github.jfcloud.gene.sample.mapper.SampleCheckOrderMapper;
|
|
|
-import com.github.jfcloud.gene.sample.service.SampleAnimalService;
|
|
|
import com.github.jfcloud.gene.sample.service.SampleInfoService;
|
|
|
+import com.github.jfcloud.gene.sample.service.biz.SampleAnimalServiceImpl;
|
|
|
import com.github.jfcloud.gene.sample.vo.CheckItemSerumVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleAnimalVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleCheckSerumVo;
|
|
|
@@ -46,7 +47,7 @@ public class LisSyncService {
|
|
|
|
|
|
private final LisDb lisDb;
|
|
|
private final SampleCheckOrderMapper checkOrderMapper;
|
|
|
- private final SampleAnimalService sampleAnimalService;
|
|
|
+ private final SampleAnimalServiceImpl sampleAnimalService;
|
|
|
private final SampleInfoService sampleInfoService;
|
|
|
private final DBSystemPropertiesService systemPropertiesService;
|
|
|
private final StringRedisTemplate redisTemplate;
|
|
|
@@ -85,6 +86,7 @@ public class LisSyncService {
|
|
|
}
|
|
|
|
|
|
//根据昵称查询用户id
|
|
|
+ Assert.notEmpty(sampleInfo.getApplicantName(), "同步LIS失败,申请人姓名为空", sampleInfo.getApplicantName());
|
|
|
Entity applyUser = lisDb.queryOne("select top 1 user_id from dbo.HT_INFO_USER_EXTEND where name = N'" + sampleInfo.getApplicantName() + "' order by user_id desc");
|
|
|
Assert.notNull(applyUser, "同步LIS失败,申请人姓名[{}]不存在LIS系统", sampleInfo.getApplicantName());
|
|
|
|
|
|
@@ -155,12 +157,10 @@ public class LisSyncService {
|
|
|
scienceApply.setDeliverTime(new DateTime(item.getSendDate()));
|
|
|
scienceApply.setSampleCount(Integer.parseInt(item.getNum()));
|
|
|
Assert.isTrue(scienceApply.getSampleCount() > 0, "同步LIS失败,样本数量不能为0");
|
|
|
- scienceApply.setBeginNo(String.format("%0" + scienceApply.getSampleCount().toString().length() + "d", 1));
|
|
|
|
|
|
//HT_SCIENCE_APPLY主键非自增,为年份2位+月份2位+日期2位+483+7位序列号,为了避免冲突,这里使用480
|
|
|
String idPrefix = DateUtil.format(scienceApply.getApplyTime(), "yyMMdd") + "480";
|
|
|
long applyId = Long.parseLong(String.format("%s%07d", idPrefix, 1));
|
|
|
- scienceApply.setId(applyId);
|
|
|
|
|
|
//编号起始
|
|
|
int beginNo = 1;
|
|
|
@@ -173,10 +173,12 @@ public class LisSyncService {
|
|
|
String[] split = sampleNo.split("-");
|
|
|
beginNo = Integer.parseInt(split[2]) + 1;
|
|
|
}
|
|
|
+ scienceApply.setId(applyId);
|
|
|
|
|
|
//编号结尾
|
|
|
int endNo = beginNo + scienceApply.getSampleCount() - 1;
|
|
|
- scienceApply.setSampleNo(String.format("HKYBKY%s-%d-%d", item.getApplyDate().replace("-", ""), beginNo, endNo));
|
|
|
+ scienceApply.setBeginNo(String.format("%0" + scienceApply.getSampleCount().toString().length() + "d", 1));
|
|
|
+ scienceApply.setSampleNo(String.format("HKYBKY%s-%d-%d", DateUtil.format(scienceApply.getApplyTime(), DatePattern.PURE_DATE_FORMAT), beginNo, endNo));
|
|
|
fillNullWithDefault(scienceApply);
|
|
|
|
|
|
//检测指标
|
|
|
@@ -206,12 +208,15 @@ public class LisSyncService {
|
|
|
|
|
|
lisDb.execute(db -> {
|
|
|
try {
|
|
|
- db.insert(Entity.create("dbo.HT_SCIENCE_APPLY").parseBean(scienceApply, true, false));
|
|
|
+ Entity scienceApplyEntity = Entity.create("dbo.HT_SCIENCE_APPLY").parseBean(scienceApply, true, false);
|
|
|
+ scienceApplyEntity.set("SampleNo", scienceApply.getSampleNo());
|
|
|
+ scienceApplyEntity.remove("sample_no");
|
|
|
+ db.insert(scienceApplyEntity);
|
|
|
List<Entity> applyItemEntities = applyItemList.stream().map(x -> Entity.create("dbo.HT_SCIENCE_APPLY_ITEM").parseBean(x, true, false)).collect(Collectors.toList());
|
|
|
db.insert(applyItemEntities);
|
|
|
} catch (Exception e) {
|
|
|
log.error("同步LIS失败", e);
|
|
|
- throw new RuntimeException("同步LIS失败");
|
|
|
+ throw new RuntimeException("同步LIS失败:" + e.getMessage());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -224,6 +229,8 @@ public class LisSyncService {
|
|
|
|
|
|
redisTemplate.opsForValue().set(LIS_PREFIX + DateUtil.today(), redisPrefix, 1, TimeUnit.DAYS);
|
|
|
log.info("同步lis数据库完成 sampleId={} ", sampleId);
|
|
|
+ //更新编号规则到附件上
|
|
|
+ sampleAnimalService.generate(sampleId);
|
|
|
}
|
|
|
|
|
|
/**
|