解决检验驳回流程问题

dev
litao 3 years ago
parent c0c4233b8e
commit 413a892cf5
  1. 77
      lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/TaskBlueprintServiceImpl.java

@ -1,5 +1,6 @@
package org.springblade.lims.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
@ -62,6 +63,11 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addBluePrint(TaskBlueprint taskBlueprint) {
// 获取委托单所有样品
LambdaQueryWrapper<Simple> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(Simple::getEntrustId, taskBlueprint.getEntrustId());
wrapper1.orderByAsc(Simple::getSort);
List<Simple> simples = simpleService.list(wrapper1);
// 如果是追加检验计划提交
if (taskBlueprint.getIsContinue() != null && taskBlueprint.getIsContinue() == 1) {
@ -76,6 +82,7 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
// 库里的检验
QueryWrapper<Examine> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dept_id", eTask.getDeptId());
queryWrapper.eq("entrust_id", taskBlueprint.getEntrustId());
List<Examine> examinesInDB = examineService.list(queryWrapper);
// 要加的检验
@ -87,16 +94,34 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
// 计算出要保持的
for (Examine dbExamine : examinesInDB) {
if (examines.contains(dbExamine)) {
// 判断对象是都在该集合中包含
if (isContain(examines, dbExamine)) {
// 如果在,添加到不变的检验接集合中
examinesWillKeep.add(dbExamine);
examines.remove(dbExamine);
examinesInDB.remove(dbExamine);
// 最新检验集合中删除包含的
for (Examine examine : examines) {
if (examine.getId().equals(dbExamine.getId())) {
examine.setIsDeleted(1);
}
}
// examines.remove(dbExamine);
// 之前检验集合中删除包含的
dbExamine.setIsDeleted(1);
// examinesInDB.remove(dbExamine);
}
}
// 要加的
examinesWillAdd.addAll(examines);
for (Examine examine : examines) {
if (examine.getIsDeleted() == null || examine.getIsDeleted() == 0) {
examinesWillAdd.add(examine);
}
}
// 要去掉的
examinesWillSub.addAll(examinesInDB);
for (Examine examine : examinesInDB) {
if (examine.getIsDeleted() == 0) {
examinesWillSub.add(examine);
}
}
// 找样品当前位置?
String simpleCurrPlace = "";
@ -125,12 +150,12 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
}
// 获取委托单所有样品
LambdaQueryWrapper<Simple> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(Simple::getEntrustId, taskBlueprint.getEntrustId());
// LambdaQueryWrapper<Simple> wrapper1 = new LambdaQueryWrapper<>();
// wrapper1.eq(Simple::getEntrustId, taskBlueprint.getEntrustId());
// 加这个查询条件是因为防止一个委托单加了牛拭子、牛血清、牛组织导致在样品log表检测编号都一样的情况
wrapper1.eq(Simple::getSimpleName, examine.getSimpleName());
wrapper1.orderByAsc(Simple::getSort);
List<Simple> simples = simpleService.list(wrapper1);
// wrapper1.eq(Simple::getSimpleName, examine.getSimpleName());
// wrapper1.orderByAsc(Simple::getSort);
// List<Simple> simples = simpleService.list(wrapper1);
// 组装样品log表
SimpleDoExamineLog log = new SimpleDoExamineLog();
@ -148,7 +173,7 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
simples.get(i).setIsDistribution(1);
experieNum.append(simples.get(i).getExperieNum());
}
simpleService.updateBatchById(simples);
// simpleService.updateBatchById(simples);
examine.setExperieNum(experieNum.toString());
log.setExperieNum(experieNum.toString());
@ -208,11 +233,11 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
for (Examine examine : examines) {
// 获取委托单所有样品
LambdaQueryWrapper<Simple> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(Simple::getEntrustId, taskBlueprint.getEntrustId());
wrapper1.eq(Simple::getSimpleName, examine.getSimpleName());
wrapper1.orderByAsc(Simple::getSort);
List<Simple> simples = simpleService.list(wrapper1);
// LambdaQueryWrapper<Simple> wrapper1 = new LambdaQueryWrapper<>();
// wrapper1.eq(Simple::getEntrustId, taskBlueprint.getEntrustId());
// wrapper1.eq(Simple::getSimpleName, examine.getSimpleName());
// wrapper1.orderByAsc(Simple::getSort);
// List<Simple> simples = simpleService.list(wrapper1);
SimpleDoExamineLog log = new SimpleDoExamineLog();
log.setExamineId(examine.getId());
@ -237,7 +262,7 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
examine.setIsFinished("-1");
examine.setDemandCompletionTime(taskBlueprint.getDemandCompletionTime());
examine.setDeptId(eTask.getDeptId());
simpleService.updateBatchById(simples);
// simpleService.updateBatchById(simples);
}
examineService.updateBatchById(examines);
}
@ -263,6 +288,7 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
this.save(taskBlueprint);
}
simpleService.updateBatchById(simples);
Entrust entrust = new Entrust();
entrust.setId(taskBlueprint.getEntrustId());
entrust.setEntrustStatus("111");
@ -333,4 +359,21 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe
return taskBlueprint;
}
/**
* 判断该对象是否在集合中
*/
private boolean isContain(List<Examine> examines, Examine dbExamine) {
// 判断该集合不为空
if (CollectionUtils.isNotEmpty(examines)) {
// 循环检测
for (Examine examine : examines) {
// 判断传过来的检测对象是否在集合中包含
if (examine.getId().equals(dbExamine.getId())) {
return true;
}
}
}
return false;
}
}

Loading…
Cancel
Save