|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package org.springblade.lims.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
@ -9,6 +10,7 @@ import org.springblade.lims.mapper.TaskBlueprintMapper; |
|
|
|
|
import org.springblade.lims.service.*; |
|
|
|
|
import org.springblade.resource.enums.SysTypeEnum; |
|
|
|
|
import org.springblade.resource.feign.IMessageClient; |
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
@ -18,6 +20,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author swj |
|
|
|
|
@ -65,20 +68,37 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe |
|
|
|
|
List<ETask> eTasks = taskBlueprint.getTasks(); |
|
|
|
|
for (ETask eTask : eTasks) { |
|
|
|
|
// 发送提示消息
|
|
|
|
|
List<User> userList = userClient.listDeptUserByCurrentUser(eTask.getDeptId().toString()).getData(); |
|
|
|
|
if (userList != null) { |
|
|
|
|
for (User user : userList) { |
|
|
|
|
// position1
|
|
|
|
|
if ("1432876315142520834".equals(user.getRoleId())) { |
|
|
|
|
messageClient.event(SysTypeEnum.INFORM.getValue(), "新的检验", |
|
|
|
|
"你有新的检验待领取,请及时处理", 1, 5, user.getId().toString(), "/plugin/workflow/process/experimentcrew"); |
|
|
|
|
} else { |
|
|
|
|
messageClient.event(SysTypeEnum.INFORM.getValue(), "新的检验", |
|
|
|
|
"你有新的检验待分配,请及时处理", 1, 5, user.getId().toString(), "/plugin/workflow/process/experimentcrew"); |
|
|
|
|
} |
|
|
|
|
sendMessage(String.valueOf(eTask.getDeptId())); |
|
|
|
|
|
|
|
|
|
// 本次传来的检验
|
|
|
|
|
List<Examine> examines = eTask.getExamines(); |
|
|
|
|
|
|
|
|
|
// 库里的检验
|
|
|
|
|
QueryWrapper<Examine> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("dept_id", eTask.getDeptId()); |
|
|
|
|
List<Examine> examinesInDB = examineService.list(queryWrapper); |
|
|
|
|
|
|
|
|
|
// 要加的检验
|
|
|
|
|
List<Examine> examinesWillAdd = new ArrayList<>(); |
|
|
|
|
// 要去掉的检验
|
|
|
|
|
List<Examine> examinesWillSub = new ArrayList<>(); |
|
|
|
|
// 不变的检验
|
|
|
|
|
List<Examine> examinesWillKeep = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// 计算出要保持的
|
|
|
|
|
for (Examine dbExamine : examinesInDB) { |
|
|
|
|
if (examines.contains(dbExamine)) { |
|
|
|
|
examinesWillKeep.add(dbExamine); |
|
|
|
|
examines.remove(dbExamine); |
|
|
|
|
examinesInDB.remove(dbExamine); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
List<Examine> examines = eTask.getExamines(); |
|
|
|
|
// 要加的
|
|
|
|
|
examinesWillAdd.addAll(examines); |
|
|
|
|
// 要去掉的
|
|
|
|
|
examinesWillSub.addAll(examinesInDB); |
|
|
|
|
|
|
|
|
|
// 找样品当前位置?
|
|
|
|
|
String simpleCurrPlace = ""; |
|
|
|
|
for (Examine examine : examines) { |
|
|
|
|
if (examine.getSimpleCurrPlace() != null && !"".equals(examine.getSimpleCurrPlace())) { |
|
|
|
|
@ -86,7 +106,20 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (Examine examine : examines) { |
|
|
|
|
|
|
|
|
|
// 获取委托单所有样品
|
|
|
|
|
LambdaQueryWrapper<Simple> wrapperTemp = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapperTemp.eq(Simple::getEntrustId, taskBlueprint.getEntrustId()); |
|
|
|
|
wrapperTemp.orderByAsc(Simple::getSort); |
|
|
|
|
List<Simple> simplesTemp = simpleService.list(wrapperTemp); |
|
|
|
|
for (int i = 0; i < simplesTemp.size(); i++) { |
|
|
|
|
simplesTemp.get(i).setIsDistribution(0); |
|
|
|
|
} |
|
|
|
|
simpleService.updateBatchById(simplesTemp); |
|
|
|
|
|
|
|
|
|
// 遍历检验
|
|
|
|
|
List<Examine> examinesWillAddTemp = new ArrayList<>(); |
|
|
|
|
for (Examine examine : examinesWillAdd) { |
|
|
|
|
if (!"".equals(examine.getExperieNum())) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
@ -94,10 +127,12 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe |
|
|
|
|
// 获取委托单所有样品
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
// 组装样品log表
|
|
|
|
|
SimpleDoExamineLog log = new SimpleDoExamineLog(); |
|
|
|
|
log.setExamineId(examine.getId()); |
|
|
|
|
log.setIsFinished(0); |
|
|
|
|
@ -113,19 +148,25 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe |
|
|
|
|
simples.get(i).setIsDistribution(1); |
|
|
|
|
experieNum.append(simples.get(i).getExperieNum()); |
|
|
|
|
} |
|
|
|
|
simpleService.updateBatchById(simples); |
|
|
|
|
|
|
|
|
|
examine.setExperieNum(experieNum.toString()); |
|
|
|
|
log.setExperieNum(experieNum.toString()); |
|
|
|
|
simpleDoExamineLogService.save(log); |
|
|
|
|
|
|
|
|
|
examine.setSimpleCount(max - min + 1); |
|
|
|
|
examine.setETaskId(eTask.getId()); |
|
|
|
|
examine.setIsDistribute(0); |
|
|
|
|
examine.setIsFinished("-1"); |
|
|
|
|
examine.setSimpleCurrPlace("接样室"); |
|
|
|
|
examine.setDemandCompletionTime(taskBlueprint.getDemandCompletionTime()); |
|
|
|
|
examine.setDeptId(eTask.getDeptId()); |
|
|
|
|
examine.setSimpleCurrPlace(simpleCurrPlace); |
|
|
|
|
simpleService.updateBatchById(simples); |
|
|
|
|
examinesWillAddTemp.add(examine); |
|
|
|
|
} |
|
|
|
|
examineService.updateBatchById(examines); |
|
|
|
|
examineService.saveOrUpdateBatch(examinesWillAddTemp); |
|
|
|
|
// 删掉要去掉的
|
|
|
|
|
List<Long> collect = examinesWillSub.stream().map(Examine::getId).collect(Collectors.toList()); |
|
|
|
|
examineService.removeByIds(collect); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 第一次计划提交
|
|
|
|
|
@ -228,6 +269,25 @@ public class TaskBlueprintServiceImpl extends BaseServiceImpl<TaskBlueprintMappe |
|
|
|
|
return entrtrustService.updateById(entrust); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发送提示消息 |
|
|
|
|
*/ |
|
|
|
|
private void sendMessage(String deptId) { |
|
|
|
|
List<User> userList = userClient.listDeptUserByCurrentUser(deptId).getData(); |
|
|
|
|
if (userList != null) { |
|
|
|
|
for (User user : userList) { |
|
|
|
|
// position1
|
|
|
|
|
if ("1432876315142520834".equals(user.getRoleId())) { |
|
|
|
|
messageClient.event(SysTypeEnum.INFORM.getValue(), "新的检验", |
|
|
|
|
"你有新的检验待领取,请及时处理", 1, 5, user.getId().toString(), "/plugin/workflow/process/experimentcrew"); |
|
|
|
|
} else { |
|
|
|
|
messageClient.event(SysTypeEnum.INFORM.getValue(), "新的检验", |
|
|
|
|
"你有新的检验待分配,请及时处理", 1, 5, user.getId().toString(), "/plugin/workflow/process/experimentcrew"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public TaskBlueprint continuePlan(String id) { |
|
|
|
|
|