Showing
1 changed file
with
15 additions
and
41 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/customer/CustomerDevelopPlanServiceImpl.java
| ... | ... | @@ -10,10 +10,10 @@ import com.lframework.starter.bpm.enums.FlowDefinitionExtBizType; |
| 10 | 10 | import com.lframework.starter.bpm.enums.FlowDefinitionIsPublish; |
| 11 | 11 | import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper; |
| 12 | 12 | import com.lframework.starter.bpm.service.FlowDefinitionWrapperService; |
| 13 | +import com.lframework.starter.bpm.service.FlowInstanceWrapperService; | |
| 13 | 14 | import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo; |
| 14 | 15 | import com.lframework.starter.web.core.components.security.SecurityUtil; |
| 15 | 16 | import com.lframework.starter.web.core.utils.*; |
| 16 | -import com.lframework.xingyun.sc.bo.customer.develop.GetCustomerDevelopPlanBo; | |
| 17 | 17 | import com.lframework.xingyun.sc.entity.CustomerDevelopPlan; |
| 18 | 18 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 19 | 19 | import com.lframework.starter.web.core.components.resp.PageResult; |
| ... | ... | @@ -46,7 +46,7 @@ import java.util.stream.Collectors; |
| 46 | 46 | public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDevelopPlanMapper, CustomerDevelopPlan> implements CustomerDevelopPlanService { |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - private static final String BPM_FLAG = "CustomerDevelop"; | |
| 49 | + private static final String BPM_FLAG = "CUSTOMER_DEVELOP"; | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | @Resource |
| ... | ... | @@ -55,6 +55,8 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 55 | 55 | private InsService insService; |
| 56 | 56 | @Resource |
| 57 | 57 | private FlowTaskWrapperMapper flowTaskWrapperMapper; |
| 58 | + @Resource | |
| 59 | + private FlowInstanceWrapperService flowInstanceWrapperService; | |
| 58 | 60 | |
| 59 | 61 | |
| 60 | 62 | |
| ... | ... | @@ -82,18 +84,17 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 82 | 84 | workshopNameList.add("紫铜分厂"); |
| 83 | 85 | vo.setWorkshopNames(workshopNameList); |
| 84 | 86 | } |
| 85 | - List<String> ids = new ArrayList<>(); | |
| 86 | 87 | // 待办类型 |
| 87 | 88 | String todoType = vo.getTodoType(); |
| 88 | 89 | if ("COMPLETED".equals(todoType)) { |
| 89 | - | |
| 90 | + vo.setStatus(CustomerDevelopStatus.PASS.getCode()); | |
| 90 | 91 | } else if ("WAIT".equals(todoType)) { |
| 91 | 92 | // 获取当前人员的待办任务数据 |
| 92 | 93 | List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId()); |
| 93 | 94 | if (CollectionUtils.isEmpty(flowTaskList)) { |
| 94 | 95 | return PageResultUtil.convert(new PageInfo<>()); |
| 95 | 96 | } |
| 96 | - ids = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList()); | |
| 97 | + List<String> ids = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList()); | |
| 97 | 98 | vo.setIds(ids); |
| 98 | 99 | } |
| 99 | 100 | PageHelperUtil.startPage(pageIndex, pageSize); |
| ... | ... | @@ -178,16 +179,7 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 178 | 179 | } |
| 179 | 180 | data.setChargeUserId(vo.getChargeUserId()); |
| 180 | 181 | // 流程处理 |
| 181 | - FlowDefinitionWrapper flowDefinitionWrapper = flowDefinitionWrapperService.getBaseMapper().selectOne( | |
| 182 | - Wrappers.<FlowDefinitionWrapper>query() | |
| 183 | - .eq("mode", "CUSTOMER_DEVELOP") | |
| 184 | - .eq("is_publish", FlowDefinitionIsPublish.Y.getCode()) | |
| 185 | - .select("id", "flow_code") | |
| 186 | - ); | |
| 187 | - if (flowDefinitionWrapper == null) { | |
| 188 | - throw new DefaultClientException("客户开发未设计审核流程或流程未发布!"); | |
| 189 | - } | |
| 190 | - Instance instance = this.startCustomerDevelopInstance(flowDefinitionWrapper.getFlowCode(), id); | |
| 182 | + Instance instance = flowInstanceWrapperService.startInstance("CUSTOMER_DEVELOP", id, BPM_FLAG, data); | |
| 191 | 183 | data.setFlowInstanceId(instance.getId()); |
| 192 | 184 | |
| 193 | 185 | getBaseMapper().insert(data); |
| ... | ... | @@ -205,6 +197,13 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 205 | 197 | if (ObjectUtil.isNull(data)) { |
| 206 | 198 | throw new DefaultClientException("客户开发计划不存在!"); |
| 207 | 199 | } |
| 200 | + CustomerDevelopStatus status = data.getStatus(); | |
| 201 | + if (!CustomerDevelopStatus.REFUSE.equals(status)) { | |
| 202 | + throw new DefaultClientException("仅驳回状态下可编辑!"); | |
| 203 | + } | |
| 204 | + // 重新发起流程 | |
| 205 | + Instance instance = flowInstanceWrapperService.startInstance("CUSTOMER_DEVELOP", vo.getId(), BPM_FLAG, vo); | |
| 206 | + | |
| 208 | 207 | LambdaUpdateWrapper<CustomerDevelopPlan> updateWrapper = Wrappers.lambdaUpdate(CustomerDevelopPlan.class) |
| 209 | 208 | .set(CustomerDevelopPlan::getCustomerId, vo.getCustomerId()) |
| 210 | 209 | .set(CustomerDevelopPlan::getWorkshopId, StringUtil.isBlank(vo.getWorkshopId()) ? null : vo.getWorkshopId()) |
| ... | ... | @@ -224,6 +223,7 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 224 | 223 | .set(CustomerDevelopPlan::getSettleDays, vo.getSettleDays() == null ? null : vo.getSettleDays()) |
| 225 | 224 | .set(CustomerDevelopPlan::getChargeUserId, vo.getChargeUserId()) |
| 226 | 225 | .set(CustomerDevelopPlan::getStatus, CustomerDevelopStatus.AUDIT) |
| 226 | + .set(CustomerDevelopPlan::getFlowInstanceId, instance.getId()) | |
| 227 | 227 | .eq(CustomerDevelopPlan::getId, vo.getId()); |
| 228 | 228 | getBaseMapper().update(updateWrapper); |
| 229 | 229 | |
| ... | ... | @@ -250,30 +250,4 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe |
| 250 | 250 | .eq(CustomerDevelopPlan::getId, id); |
| 251 | 251 | getBaseMapper().update(updateWrapper); |
| 252 | 252 | } |
| 253 | - | |
| 254 | - | |
| 255 | - /** | |
| 256 | - * 发起流程实例 | |
| 257 | - * | |
| 258 | - * @param processCode 流程code | |
| 259 | - * @param businessId 业务ID | |
| 260 | - * @return Instance | |
| 261 | - */ | |
| 262 | - public Instance startCustomerDevelopInstance(String processCode, String businessId) { | |
| 263 | - if (this.getById(businessId) != null) { | |
| 264 | - throw new DefaultClientException("客户开发已办理完成,无法重新发起!"); | |
| 265 | - } | |
| 266 | - FlowParams flowParams = new FlowParams(); | |
| 267 | - flowParams.flowCode(processCode); | |
| 268 | - | |
| 269 | - FlowInstanceExtDto ext = new FlowInstanceExtDto(); | |
| 270 | - ext.setBizType(FlowDefinitionExtBizType.SYSTEM.getCode()); | |
| 271 | - ext.setBizFlag(BPM_FLAG); | |
| 272 | - flowParams.ext(JsonUtil.toJsonString(ext)); | |
| 273 | - // 需要传入表单变量 | |
| 274 | - GetCustomerDevelopPlanBo detail = new GetCustomerDevelopPlanBo(this.findById(businessId)); | |
| 275 | - flowParams.variable(JsonUtil.parseMap(JsonUtil.toJsonString(detail), String.class, Object.class)); | |
| 276 | - | |
| 277 | - return insService.start(businessId, flowParams); | |
| 278 | - } | |
| 279 | 253 | } | ... | ... |