Showing
4 changed files
with
152 additions
and
0 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/customer/CustomerDevelopPlanServiceImpl.java
| ... | ... | @@ -250,4 +250,17 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 250 | 250 | .eq(CustomerDevelopPlan::getId, id); |
| 251 | 251 | getBaseMapper().update(updateWrapper); |
| 252 | 252 | } |
| 253 | + | |
| 254 | + @OpLog(type = OtherOpLogType.class, name = "更新状态,ID:{}", params = {"#id"}) | |
| 255 | + @Transactional(rollbackFor = Exception.class) | |
| 256 | + @Override | |
| 257 | + public void updateStatus(String id, CustomerDevelopStatus status) { | |
| 258 | + if (StringUtils.isBlank(id) || status == null) { | |
| 259 | + return; | |
| 260 | + } | |
| 261 | + LambdaUpdateWrapper<CustomerDevelopPlan> updateWrapper = Wrappers.lambdaUpdate(CustomerDevelopPlan.class) | |
| 262 | + .set(CustomerDevelopPlan::getStatus, status) | |
| 263 | + .eq(CustomerDevelopPlan::getId, id); | |
| 264 | + getBaseMapper().update(updateWrapper); | |
| 265 | + } | |
| 253 | 266 | } | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/listeners/flow/NodeFinishListener.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.listeners.flow; | |
| 2 | + | |
| 3 | +import com.lframework.starter.bpm.enums.FlowInstanceStatus; | |
| 4 | +import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; | |
| 5 | +import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.apache.commons.collections4.MapUtils; | |
| 8 | +import org.dromara.warm.flow.core.entity.Instance; | |
| 9 | +import org.dromara.warm.flow.core.listener.Listener; | |
| 10 | +import org.dromara.warm.flow.core.listener.ListenerVariable; | |
| 11 | +import org.springframework.stereotype.Component; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +@Component | |
| 17 | +@Slf4j | |
| 18 | +public class NodeFinishListener implements Listener { | |
| 19 | + | |
| 20 | + | |
| 21 | + @Resource | |
| 22 | + private CustomerDevelopPlanService customerDevelopPlanService; | |
| 23 | + | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 业务表新增或者更新操作 | |
| 27 | + * | |
| 28 | + * @param listenerVariable 监听器变量 | |
| 29 | + */ | |
| 30 | + @Override | |
| 31 | + public void notify(ListenerVariable listenerVariable) { | |
| 32 | + log.info("==================== 流程节点完成监听器开始......"); | |
| 33 | + Instance instance = listenerVariable.getInstance(); | |
| 34 | + Map<String, Object> variable = listenerVariable.getVariable(); | |
| 35 | + if (MapUtils.isEmpty(variable)) { | |
| 36 | + return; | |
| 37 | + } | |
| 38 | + String businessId = instance.getBusinessId(); | |
| 39 | + String businessType = (String) variable.get("businessType"); | |
| 40 | + // 获取审核结果 | |
| 41 | + String flowStatus = listenerVariable.getFlowParams().getFlowStatus(); | |
| 42 | + // 更新业务数据 | |
| 43 | + switch (businessType) { | |
| 44 | + case "CUSTOMER_DEVELOP": | |
| 45 | + handleCustomerDevelopData(flowStatus, businessId); | |
| 46 | + break; | |
| 47 | + default: | |
| 48 | + break; | |
| 49 | + } | |
| 50 | + log.info("==================== 流程节点完成监听器结束......"); | |
| 51 | + } | |
| 52 | + | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 客户开发业务数据处理 | |
| 56 | + * | |
| 57 | + * @param businessId 业务ID | |
| 58 | + */ | |
| 59 | + private void handleCustomerDevelopData(String flowStatus, String businessId) { | |
| 60 | + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)) { | |
| 61 | + customerDevelopPlanService.updateStatus(businessId, CustomerDevelopStatus.PASS); | |
| 62 | + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)) { | |
| 63 | + customerDevelopPlanService.updateStatus(businessId, CustomerDevelopStatus.REFUSE); | |
| 64 | + } | |
| 65 | + } | |
| 66 | +} | |
| \ No newline at end of file | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/listeners/flow/ProcessCompleteListener.java
0 → 100644
| 1 | +//import lombok.extern.slf4j.Slf4j; | |
| 2 | +// | |
| 3 | +//@Component | |
| 4 | +//@Slf4j | |
| 5 | +//public class ProcessCompleteListener implements ExecutionListener { | |
| 6 | +// | |
| 7 | +// | |
| 8 | +// @Autowired | |
| 9 | +// private JdbcTemplate jdbcTemplate; // 或者使用其他数据访问方式 | |
| 10 | +// | |
| 11 | +// @Override | |
| 12 | +// public void notify(DelegateExecution execution) throws Exception { | |
| 13 | +// try { | |
| 14 | +// // 1. 获取流程变量或执行结果 | |
| 15 | +// String businessKey = execution.getProcessBusinessKey(); // 获取业务主键 | |
| 16 | +// String processInstanceId = execution.getProcessInstanceId(); | |
| 17 | +// String result = (String) execution.getVariable("processResult"); // 假设流程结果存储在变量中 | |
| 18 | +// | |
| 19 | +// // 2. 根据业务逻辑确定要更新的表和状态 | |
| 20 | +// String tableName = determineTableName(execution); // 实现此方法以确定表名 | |
| 21 | +// String status = determineStatus(result); // 实现此方法以映射状态 | |
| 22 | +// | |
| 23 | +// // 3. 构建并执行更新语句 | |
| 24 | +// String sql = "UPDATE " + tableName + " SET status = ? WHERE process_instance_id = ?"; | |
| 25 | +// int updatedRows = jdbcTemplate.update(sql, status, processInstanceId); | |
| 26 | +// | |
| 27 | +// if (updatedRows > 0) { | |
| 28 | +// log.info("Successfully updated {} rows in table {} for process instance {}", | |
| 29 | +// updatedRows, tableName, processInstanceId); | |
| 30 | +// } else { | |
| 31 | +// log.warn("No rows updated in table {} for process instance {}", | |
| 32 | +// tableName, processInstanceId); | |
| 33 | +// } | |
| 34 | +// } catch (Exception e) { | |
| 35 | +// log.error("Error updating business table status for process instance: " + | |
| 36 | +// execution.getProcessInstanceId(), e); | |
| 37 | +// throw e; // 重新抛出异常以便流程引擎处理 | |
| 38 | +// } | |
| 39 | +// } | |
| 40 | +// | |
| 41 | +// /** | |
| 42 | +// * 根据流程信息确定业务表名 | |
| 43 | +// */ | |
| 44 | +// private String determineTableName(DelegateExecution execution) { | |
| 45 | +// // 示例:根据流程定义key或其他变量确定表名 | |
| 46 | +// String processDefinitionKey = execution.getProcessDefinitionId().split(":")[0]; | |
| 47 | +// // 这里可以加入具体的业务逻辑来映射表名 | |
| 48 | +// return "business_table"; // 示例表名 | |
| 49 | +// } | |
| 50 | +// | |
| 51 | +// /** | |
| 52 | +// * 根据流程结果映射业务状态 | |
| 53 | +// */ | |
| 54 | +// private String determineStatus(String processResult) { | |
| 55 | +// // 示例:将流程结果映射为业务状态 | |
| 56 | +// if ("approved".equalsIgnoreCase(processResult)) { | |
| 57 | +// return "APPROVED"; | |
| 58 | +// } else if ("rejected".equalsIgnoreCase(processResult)) { | |
| 59 | +// return "REJECTED"; | |
| 60 | +// } else { | |
| 61 | +// return "PROCESSING"; | |
| 62 | +// } | |
| 63 | +// } | |
| 64 | +//} | ... | ... |
| 1 | 1 | package com.lframework.xingyun.sc.service.customer; |
| 2 | 2 | |
| 3 | +import com.lframework.xingyun.sc.enums.CustomerDevelopStatus; | |
| 3 | 4 | import com.lframework.xingyun.sc.vo.customer.develop.CreateCustomerDevelopPlanVo; |
| 4 | 5 | import com.lframework.xingyun.sc.vo.customer.develop.QueryCustomerDevelopPlanVo; |
| 5 | 6 | import com.lframework.xingyun.sc.vo.customer.develop.UpdateCustomerDevelopPlanVo; |
| ... | ... | @@ -67,4 +68,12 @@ public interface CustomerDevelopPlanService extends BaseMpService<CustomerDevelo |
| 67 | 68 | * @param id 主键ID |
| 68 | 69 | */ |
| 69 | 70 | void cancel(String id); |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 根据主键ID更新状态 | |
| 74 | + * | |
| 75 | + * @param id 主键ID | |
| 76 | + * @param status 状态 | |
| 77 | + */ | |
| 78 | + void updateStatus(String id, CustomerDevelopStatus status); | |
| 70 | 79 | } | ... | ... |