Showing
2 changed files
with
43 additions
and
7 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/customer/CustomerDevelopPlanServiceImpl.java
| @@ -4,13 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | @@ -4,13 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 4 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 6 | import com.github.pagehelper.PageInfo; | 6 | import com.github.pagehelper.PageInfo; |
| 7 | -import com.lframework.starter.bpm.dto.FlowTaskDto; | ||
| 8 | -import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper; | ||
| 9 | import com.lframework.starter.bpm.service.FlowInstanceWrapperService; | 7 | import com.lframework.starter.bpm.service.FlowInstanceWrapperService; |
| 10 | import com.lframework.starter.bpm.service.FlowTaskWrapperService; | 8 | import com.lframework.starter.bpm.service.FlowTaskWrapperService; |
| 11 | -import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo; | ||
| 12 | import com.lframework.starter.web.core.components.security.SecurityUtil; | 9 | import com.lframework.starter.web.core.components.security.SecurityUtil; |
| 13 | import com.lframework.starter.web.core.utils.*; | 10 | import com.lframework.starter.web.core.utils.*; |
| 11 | +import com.lframework.xingyun.basedata.service.customer.CustomerService; | ||
| 14 | import com.lframework.xingyun.sc.bo.customer.develop.CustomerDevelopPlanStatisticsBo; | 12 | import com.lframework.xingyun.sc.bo.customer.develop.CustomerDevelopPlanStatisticsBo; |
| 15 | import com.lframework.xingyun.sc.entity.CustomerDevelopPlan; | 13 | import com.lframework.xingyun.sc.entity.CustomerDevelopPlan; |
| 16 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | 14 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| @@ -37,7 +35,6 @@ import org.springframework.stereotype.Service; | @@ -37,7 +35,6 @@ import org.springframework.stereotype.Service; | ||
| 37 | import javax.annotation.Resource; | 35 | import javax.annotation.Resource; |
| 38 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
| 39 | import java.util.List; | 37 | import java.util.List; |
| 40 | -import java.util.stream.Collectors; | ||
| 41 | 38 | ||
| 42 | 39 | ||
| 43 | @Service | 40 | @Service |
| @@ -49,8 +46,6 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | @@ -49,8 +46,6 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | ||
| 49 | 46 | ||
| 50 | 47 | ||
| 51 | @Resource | 48 | @Resource |
| 52 | - private FlowTaskWrapperMapper flowTaskWrapperMapper; | ||
| 53 | - @Resource | ||
| 54 | private FlowInstanceWrapperService flowInstanceWrapperService; | 49 | private FlowInstanceWrapperService flowInstanceWrapperService; |
| 55 | @Resource | 50 | @Resource |
| 56 | private FlowTaskWrapperService flowTaskWrapperService; | 51 | private FlowTaskWrapperService flowTaskWrapperService; |
| @@ -140,7 +135,13 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | @@ -140,7 +135,13 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | ||
| 140 | data.setId(id); | 135 | data.setId(id); |
| 141 | // 审核中 | 136 | // 审核中 |
| 142 | data.setStatus(CustomerDevelopStatus.AUDIT); | 137 | data.setStatus(CustomerDevelopStatus.AUDIT); |
| 143 | - data.setCustomerId(vo.getCustomerId()); | 138 | + String customerId = vo.getCustomerId(); |
| 139 | + // 检查客户是否已存在 | ||
| 140 | + List<CustomerDevelopPlan> planList = listByCustomerId(customerId); | ||
| 141 | + if (CollectionUtils.isNotEmpty(planList)) { | ||
| 142 | + throw new DefaultClientException("当前客户名称已存在,请勿重复添加!"); | ||
| 143 | + } | ||
| 144 | + data.setCustomerId(customerId); | ||
| 144 | if (!StringUtil.isBlank(vo.getCustomerType())) { | 145 | if (!StringUtil.isBlank(vo.getCustomerType())) { |
| 145 | data.setCustomerType(vo.getCustomerType()); | 146 | data.setCustomerType(vo.getCustomerType()); |
| 146 | } | 147 | } |
| @@ -210,6 +211,15 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | @@ -210,6 +211,15 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | ||
| 210 | if (!CustomerDevelopStatus.REFUSE.equals(status)) { | 211 | if (!CustomerDevelopStatus.REFUSE.equals(status)) { |
| 211 | throw new DefaultClientException("仅驳回状态下可编辑!"); | 212 | throw new DefaultClientException("仅驳回状态下可编辑!"); |
| 212 | } | 213 | } |
| 214 | + // 检查客户名称是否重复 | ||
| 215 | + List<CustomerDevelopPlan> planList = listByCustomerId(vo.getCustomerId()); | ||
| 216 | + if (CollectionUtils.isNotEmpty(planList)) { | ||
| 217 | + for (CustomerDevelopPlan plan : planList) { | ||
| 218 | + if (!vo.getId().equals(plan.getId())) { | ||
| 219 | + throw new DefaultClientException("当前客户名称已存在,请勿重复添加!"); | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + } | ||
| 213 | // 重新发起流程 | 223 | // 重新发起流程 |
| 214 | Instance instance = flowInstanceWrapperService.startInstance("CUSTOMER_DEVELOP", vo.getId(), BPM_FLAG, data); | 224 | Instance instance = flowInstanceWrapperService.startInstance("CUSTOMER_DEVELOP", vo.getId(), BPM_FLAG, data); |
| 215 | 225 | ||
| @@ -298,4 +308,22 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | @@ -298,4 +308,22 @@ public class CustomerDevelopPlanServiceImpl extends BaseMpServiceImpl<CustomerDe | ||
| 298 | 308 | ||
| 299 | return statisticsBo; | 309 | return statisticsBo; |
| 300 | } | 310 | } |
| 311 | + | ||
| 312 | + /** | ||
| 313 | + * 根据客户ID获取有效的开发计划 | ||
| 314 | + * | ||
| 315 | + * @param customerId 客户ID | ||
| 316 | + * @return List<CustomerDevelopPlan> | ||
| 317 | + */ | ||
| 318 | + @Override | ||
| 319 | + public List<CustomerDevelopPlan> listByCustomerId(String customerId) { | ||
| 320 | + if (StringUtils.isBlank(customerId)) { | ||
| 321 | + return new ArrayList<>(); | ||
| 322 | + } | ||
| 323 | + LambdaQueryWrapper<CustomerDevelopPlan> queryWrapper = Wrappers.lambdaQuery(CustomerDevelopPlan.class); | ||
| 324 | + queryWrapper.eq(CustomerDevelopPlan::getCustomerId, customerId) | ||
| 325 | + .ne(CustomerDevelopPlan::getStatus, CustomerDevelopStatus.CANCEL.getCode()); | ||
| 326 | + | ||
| 327 | + return getBaseMapper().selectList(queryWrapper); | ||
| 328 | + } | ||
| 301 | } | 329 | } |
| @@ -84,4 +84,12 @@ public interface CustomerDevelopPlanService extends BaseMpService<CustomerDevelo | @@ -84,4 +84,12 @@ public interface CustomerDevelopPlanService extends BaseMpService<CustomerDevelo | ||
| 84 | * @return CustomerDevelopPlanStatisticsBo | 84 | * @return CustomerDevelopPlanStatisticsBo |
| 85 | */ | 85 | */ |
| 86 | CustomerDevelopPlanStatisticsBo todoTypeStatistics(QueryCustomerDevelopPlanVo vo); | 86 | CustomerDevelopPlanStatisticsBo todoTypeStatistics(QueryCustomerDevelopPlanVo vo); |
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 根据客户ID获取有效的开发计划 | ||
| 90 | + * | ||
| 91 | + * @param customerId 客户ID | ||
| 92 | + * @return List<CustomerDevelopPlan> | ||
| 93 | + */ | ||
| 94 | + List<CustomerDevelopPlan> listByCustomerId(String customerId); | ||
| 87 | } | 95 | } |