diff --git a/src/main/java/com/wflow/controller/CustomListenController.java b/src/main/java/com/wflow/controller/CustomListenController.java new file mode 100644 index 0000000..f608900 --- /dev/null +++ b/src/main/java/com/wflow/controller/CustomListenController.java @@ -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("修改成功"); + } +} diff --git a/src/main/java/com/wflow/service/CustomListenService.java b/src/main/java/com/wflow/service/CustomListenService.java index c2caab6..a4b328a 100644 --- a/src/main/java/com/wflow/service/CustomListenService.java +++ b/src/main/java/com/wflow/service/CustomListenService.java @@ -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); } diff --git a/src/main/java/com/wflow/service/OrgRepositoryService.java b/src/main/java/com/wflow/service/OrgRepositoryService.java index 389daef..daf7171 100644 --- a/src/main/java/com/wflow/service/OrgRepositoryService.java +++ b/src/main/java/com/wflow/service/OrgRepositoryService.java @@ -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); } diff --git a/src/main/java/com/wflow/service/impl/CustomListenServiceImpl.java b/src/main/java/com/wflow/service/impl/CustomListenServiceImpl.java index 2c0df25..a80dcfa 100644 --- a/src/main/java/com/wflow/service/impl/CustomListenServiceImpl.java +++ b/src/main/java/com/wflow/service/impl/CustomListenServiceImpl.java @@ -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 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()); + } + } + } + } diff --git a/src/main/java/com/wflow/service/impl/ModelOrgRepositoryServiceImpl.java b/src/main/java/com/wflow/service/impl/ModelOrgRepositoryServiceImpl.java index e637887..d0f81ce 100644 --- a/src/main/java/com/wflow/service/impl/ModelOrgRepositoryServiceImpl.java +++ b/src/main/java/com/wflow/service/impl/ModelOrgRepositoryServiceImpl.java @@ -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; + } } diff --git a/src/main/java/com/zhgd/xmgl/security/SecurityUtil.java b/src/main/java/com/zhgd/xmgl/security/SecurityUtil.java deleted file mode 100644 index 31a2995..0000000 --- a/src/main/java/com/zhgd/xmgl/security/SecurityUtil.java +++ /dev/null @@ -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 - *

- */ - 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); - } -}