diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java index 47a81a02..2aedb852 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java @@ -141,18 +141,25 @@ public class CustomerSelectionController extends BaseController }else { workId = workList.get(0).getWorkerId(); } + // 删除历史的 + CustomerSelection hisParam = new CustomerSelection(); + hisParam.setCustomerId(customerSelection.getCustomerId()); + hisParam.setSelectionType(customerSelection.getSelectionType()); + List hisList = customerSelectionService.selectCustomerSelectionList(hisParam); + List hisIds = hisList.stream().map(CustomerSelection::getCustomerId).collect(Collectors.toList()); + StringBuilder ids = new StringBuilder(); + hisIds.forEach(model->{ + ids.append(model).append(","); + }); + if(!StringUtil.isEmpty(ids)){ + String idString = ids.substring(0, ids.length()-1); + customerSelectionService.deleteCustomerSelectionByIds(idString); + } // 判断是否有历史数据 - 有则删除 customerSelection.getDeptCategoryIds().forEach(selection->{ customerSelection.setWorkId(workId); customerSelection.setDeptCategoryId(selection); - CustomerSelection param = new CustomerSelection(); - param.setDeptCategoryId(selection); - param.setSelectionType(customerSelection.getSelectionType()); - param.setCustomerId(customerSelection.getCustomerId()); - List customerSelections = customerSelectionService.selectCustomerSelectionList(param); - if(CollectionUtils.isEmpty(customerSelections)){ - customerSelectionService.insertCustomerSelection(customerSelection); - } + customerSelectionService.insertCustomerSelection(customerSelection); }); return AjaxResult.success("新增成功"); }catch (Exception e){