Browse Source

update

tags/v0
zhaohe 7 months ago
parent
commit
75562b1886
  1. 4
      src/main/java/a8k/app/a8ktype/state/enumtype/TubeState.java
  2. 2
      src/main/java/a8k/app/dao/db/DeviceStatisticDao.java
  3. 12
      src/main/java/a8k/app/dao/db/SampleRecordDBDao.java
  4. 11
      src/main/java/a8k/app/service/statemgr/ConsumableStateAnalyzer.java
  5. 5
      src/main/java/a8k/app/service/statemgr/ProjectContextMgrService.java
  6. 64
      src/main/java/a8k/app/service/statemgr/TubeStateMgrService.java
  7. 10
      src/main/java/a8k/extui/page/test/frond_end_test/VirtualEventGeneratorPage.java

4
src/main/java/a8k/app/a8ktype/state/enumtype/TubeState.java

@ -13,7 +13,9 @@ public enum TubeState {
ERROR,//处理出错
;
public Boolean isEq(List<TubeState> states) {
public Boolean isEq(TubeState ... states) {
for (TubeState state : states) {
if (this.equals(state)) {
return true;

2
src/main/java/a8k/app/dao/db/DeviceStatisticDao.java

@ -63,7 +63,7 @@ public class DeviceStatisticDao {
ZSqliteJdbcHelper.addObj(jdbcTemplate, tableName, tClass, statistic);
} else {
DeviceStatistic statistic = statisticList.get(0);
statistic.cnt += cnt;
statistic.cnt = cnt;
ZSqliteJdbcHelper.updateObj(jdbcTemplate, tableName, tClass, statistic);
}
}

12
src/main/java/a8k/app/dao/db/SampleRecordDBDao.java

@ -21,15 +21,17 @@ public class SampleRecordDBDao extends ZSqlite<SampleRecord> {
init(jdbcTemplate, "zapp_a8k_sample_record", SampleRecord.class);
}
// public Integer getRecordCntToday() {
// Long startOfDay = DateUtil.getDayStartTime(new Date());
// Long endOfDay = DateUtil.getDayEndTime(new Date());
// return jdbcTemplate.queryForObject("select count(*) from " + tableName + " where createDate >= ? and createDate < ?", Integer.class, startOfDay, endOfDay);
// }
public SampleRecord findBySampleId(String sampleId) {
return queryOne("select * from " + tableName + " where sampleId = ?;", sampleId);
}
public void deleteBySampleId(String sampleId) {
SampleRecord record = findBySampleId(sampleId);
if (record != null) {
delete(record.id);
}
}
}

11
src/main/java/a8k/app/service/statemgr/ConsumableStateAnalyzer.java

@ -65,12 +65,12 @@ public class ConsumableStateAnalyzer {
return consumableStatInfoList;
}
static public List<ConsumableStatInfo> analyze(ConsumablesMgrService consumablesMgrService, Tube tube) {
static public List<ConsumableStatInfo> analyze(ConsumablesMgrService consumablesMgrService, List<Integer> projIds) {
//统计所有项目
List<Integer> projs = new ArrayList<>();
for (Integer projId : tube.getProjIds()) {
for (Integer projId : projIds) {
if (!projs.contains(projId)) {
projs.add(projId);
}
@ -87,7 +87,7 @@ public class ConsumableStateAnalyzer {
}
//统计每个项目的需求量
for (Integer projId : tube.getProjIds()) {
for (Integer projId : projIds) {
for (ConsumableStatInfo consumableStatInfo : consumableStatInfoList) {
if (consumableStatInfo.projId.equals(projId)) {
consumableStatInfo.requireCnt++;
@ -98,6 +98,11 @@ public class ConsumableStateAnalyzer {
return consumableStatInfoList;
}
static public List<ConsumableStatInfo> analyze(ConsumablesMgrService consumablesMgrService, Tube tube) {
return analyze(consumablesMgrService, tube.getProjIds());
}
static public Boolean isEnough(List<ConsumableStatInfo> consumableStatInfoList) {
for (ConsumableStatInfo consumableStatInfo : consumableStatInfoList) {
if (consumableStatInfo.totalCnt < consumableStatInfo.requireCnt) {

5
src/main/java/a8k/app/service/statemgr/ProjectContextMgrService.java

@ -60,6 +60,11 @@ public class ProjectContextMgrService {
return ret;
}
synchronized public void deleteCxt(ProjectTaskContext cxt) {
contexts.remove(cxt);
}
synchronized public void clearCxts() {
contexts.clear();
}

64
src/main/java/a8k/app/service/statemgr/TubeStateMgrService.java

@ -115,6 +115,11 @@ public class TubeStateMgrService {
sampleRecordDBDao.update(sampleRecord);
}
private void deleteSampleInfo(String sampleId) {
sampleRecordDBDao.deleteBySampleId(sampleId);
}
//
//试管状态管理
//
@ -165,6 +170,7 @@ public class TubeStateMgrService {
// 急诊试管状态管理
//
/**
* 提交紧急样本设置
* @param userid 用户ID
@ -186,9 +192,35 @@ public class TubeStateMgrService {
throw new AppException(A8kEcode.PROJ_CARD_ERROR_WRONG_UNSUPPORTED);
}
if (!tube.getState().isEq(TubeState.EMPTY, TubeState.TO_BE_PROCESSED, TubeState.PROCESS_COMPLETE, TubeState.ERROR)) {
throw new AppException(A8kEcode.APPE_EMERGENCY_SAMPLE_IS_PROCESSING);
}
if (tube.getState().equals(TubeState.EMPTY) || tube.getState().equals(TubeState.PROCESS_COMPLETE) || tube.getState().equals(TubeState.ERROR)) {
//try delete the last emergency sample
if (tube.getState().isEq(TubeState.TO_BE_PROCESSED)) {
//bak reserve consumable,delete cxt
for (Integer projId : tube.getProjIds()) {
var cxt = projectContextMgrService.findCxt(tube.getSampleId(), projId);
if (cxt != null) {
consumablesMgrService.bakReserveConsumable(cxt.getConsumable());
projectContextMgrService.deleteCxt(cxt);
}
}
//delete sample info
deleteSampleInfo(tube.getSampleId());
}
var reports = ConsumableStateAnalyzer.analyze(consumablesMgrService, projIds);
log.info("耗材状态 {}", reports);
if (!ConsumableStateAnalyzer.isEnough(reports)) {
throw new AppException(new AEConsumeNotEnoughError(reports));
}
if (!ConsumableStateAnalyzer.isHasEnoughTip(consumablesMgrService, reports)) {
throw new AppException(new AppError(A8kEcode.APPE_TIP_NOT_ENOUGH));
}
try {
tube.setSampleId(newSample(tube));
tube.setUserid(userid);
tube.setBloodType(bloodType);
tube.setSampleBarcode(sampleBarcode);
@ -196,16 +228,7 @@ public class TubeStateMgrService {
tube.setProjInfo(ProjInfoUtils.buidProjBriefInfoList(projBuildInInfos));
tube.setProjIds(projIds);
tube.setProjBuildinInfos(projBuildInInfos);
tube.setSampleId(newSample(tube));
var reports = ConsumableStateAnalyzer.analyze(consumablesMgrService, tube);
if (!ConsumableStateAnalyzer.isEnough(reports)) {
throw new AppException(new AEConsumeNotEnoughError(reports));
}
if (!ConsumableStateAnalyzer.isHasEnoughTip(consumablesMgrService, reports)) {
throw new AppException(new AppError(A8kEcode.APPE_TIP_NOT_ENOUGH));
}
//!! 这行代码后续代码需要保证无异常发生
for (Integer projId : projIds) {
Consumable consumable = consumablesMgrService.reserveConsumable(projId);
ZAppChecker.notNull(consumable, A8kEcode.CODEERROR, "APPLY CONSUMABLE ERROR,ID:%d", projId);
@ -217,9 +240,24 @@ public class TubeStateMgrService {
}
tube.setState(TubeState.TO_BE_PROCESSED);
log.info("添加紧急样本设置成功 {}", ZJsonHelper.objectToJson(tube));
} else {
throw new AppException(A8kEcode.APPE_EMERGENCY_SAMPLE_IS_PROCESSING);
} catch (Exception e) {
String sampleId = tube.getSampleId();
if (sampleId != null && !sampleId.isEmpty()) {
for (Integer projId : tube.getProjIds()) {
var cxt = projectContextMgrService.findCxt(sampleId, projId);
if (cxt != null) {
consumablesMgrService.bakReserveConsumable(cxt.getConsumable());
projectContextMgrService.deleteCxt(cxt);
}
}
deleteSampleInfo(sampleId);
}
throw e;
}
}

10
src/main/java/a8k/extui/page/test/frond_end_test/VirtualEventGeneratorPage.java

@ -61,13 +61,17 @@ public class VirtualEventGeneratorPage {
frontEndMessageBoxAndEventMgr.pushMessageBox(new MessageBox(level, info));
}
public void pushTubeHolderUpdateEvent() {
eventBus.pushEvent(new AppTubeholderSettingUpdateEvent());
}
@PostConstruct
void init() {
ExtUIPageCfg page = new ExtUIPageCfg(this);
page.addFunction("构建弹窗事件", this::buildInfoPromoptEvent);
page.addFunction("构造消息", this::pushMessageBoxEvent);
page.addFunction("构造消息", this::pushMessageBoxEvent)
.setParamVal("info", "测试消息");
page.addFunction("构造TubeHolderUpdateEvent", this::pushTubeHolderUpdateEvent);
extApiPageMgr.addPage(page);
}
}
Loading…
Cancel
Save