fix: scc流程分批分发

This commit is contained in:
2024-07-16 11:56:20 +08:00
parent 9e590d01e0
commit 622077a7a0
3 changed files with 15 additions and 10 deletions
@@ -26,6 +26,8 @@ public class ProcessStandardComplianceCheckConstants {
public static final String UNALLOCATED_QUANTITY = "unallocatedQuantity"; public static final String UNALLOCATED_QUANTITY = "unallocatedQuantity";
/** 主表Id */ /** 主表Id */
public static final String CHECK_ID = "checkId"; public static final String CHECK_ID = "checkId";
/** 分发批次唯一Id */
public static final String BATCH_ID = "batchId";
/** /**
* 法规工程师发起 * 法规工程师发起
@@ -186,6 +186,12 @@ public class ProcessStandardComplianceCheckDetail implements Serializable {
@ApiModelProperty(value = "主表Id") @ApiModelProperty(value = "主表Id")
private String checkId; private String checkId;
/**
* 分发批次唯一Id
*/
@ApiModelProperty(value = "分发批次唯一Id")
private String batchId;
@TableField(exist = false) @TableField(exist = false)
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
@@ -41,7 +41,6 @@ import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask; import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.entity.ImportParams;
@@ -52,7 +51,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -278,6 +276,7 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
boolean distributeFlag = businessInfoDTO.getStandardInfo().getDistributeFlag().equals(YesOrNoEnum.YES.getValue()); boolean distributeFlag = businessInfoDTO.getStandardInfo().getDistributeFlag().equals(YesOrNoEnum.YES.getValue());
int unallocatedQuantity = 0; int unallocatedQuantity = 0;
if (distributeFlag) { if (distributeFlag) {
String batchId = UUID.randomUUID().toString();
// 筛选出本次提交分发出的数据 // 筛选出本次提交分发出的数据
List<ProcessStandardComplianceCheckDetail> distributeDetailList = detailInfoList.stream() List<ProcessStandardComplianceCheckDetail> distributeDetailList = detailInfoList.stream()
.filter(e -> StrUtil.isNotBlank(e.getDesignEngineer())) .filter(e -> StrUtil.isNotBlank(e.getDesignEngineer()))
@@ -296,14 +295,10 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
distributeDetailList.forEach(detail -> { distributeDetailList.forEach(detail -> {
String[] engineers = detail.getDesignEngineer().split(","); String[] engineers = detail.getDesignEngineer().split(",");
for (String engineer : engineers) { for (String engineer : engineers) {
ProcessStandardComplianceCheckDetail newDetail = new ProcessStandardComplianceCheckDetail(); ProcessStandardComplianceCheckDetail newDetail = BeanCopyUtils.
try { copyBean(detail, ProcessStandardComplianceCheckDetail.class);
BeanUtils.copyProperties(detail, newDetail);
} catch (IllegalAccessException | InvocationTargetException e) {
log.error("BeanUtils.copyProperties error", e);
throw new JeroBootException(e);
}
newDetail.setDesignEngineer(engineer); newDetail.setDesignEngineer(engineer);
newDetail.setBatchId(batchId);
needAddDetailInfoList.add(newDetail); needAddDetailInfoList.add(newDetail);
} }
}); });
@@ -311,6 +306,7 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
sccDetailService.removeByIds(ids); sccDetailService.removeByIds(ids);
sccDetailService.saveBatch(needAddDetailInfoList); sccDetailService.saveBatch(needAddDetailInfoList);
runtimeService.setVariable(processInstanceId, DESIGNER_LIST, designEngineerList); runtimeService.setVariable(processInstanceId, DESIGNER_LIST, designEngineerList);
runtimeService.setVariable(processInstanceId, BATCH_ID, batchId);
userMap.put(DESIGNER_LIST, String.join(",", designEngineerList)); userMap.put(DESIGNER_LIST, String.join(",", designEngineerList));
processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, userMap); processNodeLinkService.saveNodeUserLink(processDefinitionId, processInstanceId, userMap);
} else { } else {
@@ -448,6 +444,7 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
case AUTO_TASK_3: case AUTO_TASK_3:
List<String> designerList = (List<String>) delegateTask.getVariable(DESIGNER_LIST); List<String> designerList = (List<String>) delegateTask.getVariable(DESIGNER_LIST);
String checkId = (String) delegateTask.getVariable(CHECK_ID); String checkId = (String) delegateTask.getVariable(CHECK_ID);
String batchId = (String) delegateTask.getVariable(BATCH_ID);
for (String designer : designerList) { for (String designer : designerList) {
userInfoMap.put(DESIGNER, designer); userInfoMap.put(DESIGNER, designer);
userInfoMap.put(MAIN_CHECK_USER, mainCheckUser); userInfoMap.put(MAIN_CHECK_USER, mainCheckUser);
@@ -463,7 +460,7 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
// 更新子表数据,将数据绑定给子流程 // 更新子表数据,将数据绑定给子流程
wrapper.eq(ProcessStandardComplianceCheckDetail::getCheckId, checkId); wrapper.eq(ProcessStandardComplianceCheckDetail::getCheckId, checkId);
wrapper.eq(ProcessStandardComplianceCheckDetail::getDesignEngineer, designer); wrapper.eq(ProcessStandardComplianceCheckDetail::getDesignEngineer, designer);
wrapper.isNull(ProcessStandardComplianceCheckDetail::getDesignEngineer); wrapper.eq(ProcessStandardComplianceCheckDetail::getBatchId, batchId);
wrapper.set(ProcessStandardComplianceCheckDetail::getDesignEngineer, designer); wrapper.set(ProcessStandardComplianceCheckDetail::getDesignEngineer, designer);
wrapper.set(ProcessStandardComplianceCheckDetail::getProcessInstanceId, childPrcId); wrapper.set(ProcessStandardComplianceCheckDetail::getProcessInstanceId, childPrcId);
sccDetailService.update(wrapper); sccDetailService.update(wrapper);