包头工作流修改

This commit is contained in:
guoshengxiong 2025-02-25 11:15:07 +08:00
parent 459df86558
commit 4e372d7841
6 changed files with 103 additions and 36 deletions

View File

@ -0,0 +1,33 @@
package com.wflow.controller;
import com.wflow.service.CustomListenService;
import com.wflow.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : willian fu
* @date : 2023/11/26
*/
@RestController
@RequestMapping("wflow/custom")
public class CustomListenController {
@Autowired
private CustomListenService customListenService;
/**
* 保存抄送人单位和时间在抄送流程后面配置触发器使用这是工程质量控制点检查检测通知单
*
* @param instanceId
* @return
*/
@GetMapping("saveCcmeAndDate")
public Object saveCcmeAndDate(@RequestParam String instanceId, @RequestParam String ccMeField, @RequestParam String dateField) {
customListenService.saveCcmeAndDate(instanceId, ccMeField, dateField);
return R.ok("修改成功");
}
}

View File

@ -38,4 +38,14 @@ public interface CustomListenService {
* @param fieldId
*/
void addFormDataFromApprove(String instanceId, String fieldId);
/**
* 抄送人那里保存抄送人到表单字段
*
* @param instanceId
* @param fieldId 多个,分割
*/
void saveRecipientFormData(String instanceId, String fieldId);
void saveCcmeAndDate(String instanceId, String ccMeField, String dateField);
}

View File

@ -173,9 +173,18 @@ public interface OrgRepositoryService {
/**
* 消息通知
*
* @param notify
* @param model
* @param notifySetUp
*/
void notifyCustom(NotifyDto notify, WflowModelHistorys model, JSONObject notifySetUp);
/**
* 通过用户id查询企业
*
* @param id
* @return
*/
JSONObject getEnterpriseByUserId(String id);
}

View File

@ -12,6 +12,9 @@ import com.wflow.bean.entity.WflowModelHistorys;
import com.wflow.mapper.WflowFormDataMapper;
import com.wflow.mapper.WflowModelHistorysMapper;
import com.wflow.service.CustomListenService;
import com.wflow.service.OrgRepositoryService;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.service.ProcessInstanceService;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
@ -38,6 +41,10 @@ public class CustomListenServiceImpl implements CustomListenService {
private WflowModelHistorysMapper modelHistorysMapper;
@Autowired
private TaskService taskService;
@Autowired
private ProcessInstanceService processService;
@Autowired
private OrgRepositoryService orgRepositoryService;
@Override
public void updateFormData(String instanceId, String fieldId, String val) {
@ -158,4 +165,43 @@ public class CustomListenServiceImpl implements CustomListenService {
}
}
@Override
public void saveRecipientFormData(String instanceId, String fieldId) {
//先查实例然后判断是子流程还是主流程
// HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery()
// .processInstanceId(instanceId).singleResult();
// //是否是子流程
// boolean isSub = StrUtil.isNotBlank(instance.getSuperProcessInstanceId());
// HistoricProcessInstance mainInst = isSub ? null : instance;
// if (isSub) {
// //查出主流程表单数据
// mainInst = historyService.createHistoricProcessInstanceQuery()
// .processInstanceId(instance.getSuperProcessInstanceId()).singleResult();
// }
// //搜索当前版本流程的配置
// WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new LambdaQueryWrapper<>(WflowModelHistorys.builder()
// .processDefId(mainInst.getProcessDefinitionId()).version(mainInst.getProcessDefinitionVersion()).build()));
// 每个接口加一个instanceId
// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).singleResult();
// HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(instanceId).singleResult();
// ProcessProgressVo instanceProgress = processService.getInstanceProgress(null, instanceId);
// String val = "";
// this.updateFormData(instanceId, fieldId, val);
}
@Override
public void saveCcmeAndDate(String instanceId, String ccMeField, String dateField) {
ProcessProgressVo instanceProgress = processService.getInstanceProgress(null, instanceId);
List<ProcessProgressVo.ProgressNode> progress = instanceProgress.getProgress();
if (CollUtil.isNotEmpty(progress)) {
ProcessProgressVo.ProgressNode node = progress.get(progress.size() - 1);
JSONObject enterprise = orgRepositoryService.getEnterpriseByUserId(node.getUser().getId());
if (enterprise != null) {
String val = enterprise.getString("id");
this.updateFormData(instanceId, ccMeField, val);
this.updateFormData(instanceId, dateField, DateUtil.today());
}
}
}
}

View File

@ -137,4 +137,9 @@ public class ModelOrgRepositoryServiceImpl implements OrgRepositoryService {
public void notifyCustom(NotifyDto notify, WflowModelHistorys model, JSONObject notifySetUp) {
}
@Override
public JSONObject getEnterpriseByUserId(String id) {
return null;
}
}

View File

@ -1,36 +0,0 @@
package com.zhgd.xmgl.security;
import lombok.experimental.UtilityClass;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
@UtilityClass
public class SecurityUtil {
/**
* 获取Authentication
*/
public Authentication getAuthentication() {
return SecurityContextHolder.getContext().getAuthentication();
}
/**
* 获取用户
* @param authentication
* <p>
*/
private SecurityUser getUser(Authentication authentication) {
Object principal = authentication.getPrincipal();
if (principal instanceof SecurityUser) {
return (SecurityUser) principal;
}
return null;
}
/**
* 获取用户
*/
public SecurityUser getUser() {
Authentication authentication = getAuthentication();
return authentication == null ? null : getUser(authentication);
}
}