|
|
|
@ -19,9 +19,11 @@ import com.epmet.dto.form.ReportEditFormDTO; |
|
|
|
import com.epmet.dto.result.PreviewReportResDTO; |
|
|
|
import com.epmet.dto.result.ReportResultDTO; |
|
|
|
import com.epmet.entity.IcCustomerReportEntity; |
|
|
|
import com.epmet.entity.IcReportFunEntity; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import com.epmet.service.IcCustomerReportService; |
|
|
|
import com.epmet.service.IcReportFunService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -29,6 +31,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -48,6 +51,8 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor |
|
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private IcReportFunService reportFunService; |
|
|
|
|
|
|
|
|
|
|
|
private QueryWrapper<IcCustomerReportEntity> getWrapper(Map<String, Object> params){ |
|
|
|
@ -124,7 +129,42 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void reportEdit(ReportEditFormDTO formDTO) { |
|
|
|
if (formDTO.getType().equals(CustomerFunctionConstant.REPORT_EDIT)){ |
|
|
|
// 单个编辑
|
|
|
|
baseDao.delCustomerReport(Arrays.asList(formDTO.getCustomerList().get(NumConstant.ZERO).getCustomerId())); |
|
|
|
}else if (formDTO.getType().equals(CustomerFunctionConstant.REPORT_ADD)){ |
|
|
|
baseDao.delCustomerReport(null); |
|
|
|
} |
|
|
|
baseDao.delCustomerReportFun(Arrays.asList(formDTO.getReportId())); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getCustomerList())){ |
|
|
|
List<IcCustomerReportEntity> entities = new ArrayList<>(); |
|
|
|
List<IcReportFunEntity> funEntities = new ArrayList<>(); |
|
|
|
formDTO.getCustomerList().forEach(c -> { |
|
|
|
IcCustomerReportEntity reportEntity = new IcCustomerReportEntity(); |
|
|
|
reportEntity.setReportId(formDTO.getReportId()); |
|
|
|
reportEntity.setCustomerId(c.getCustomerId()); |
|
|
|
if (CollectionUtils.isNotEmpty(c.getCategoryKeys())){ |
|
|
|
c.getCategoryKeys().forEach(key -> { |
|
|
|
IcReportFunEntity funEntity = new IcReportFunEntity(); |
|
|
|
funEntity.setCustomerReportId(formDTO.getReportId()); |
|
|
|
funEntity.setFunCategoryKey(key); |
|
|
|
funEntities.add(funEntity); |
|
|
|
}); |
|
|
|
} |
|
|
|
entities.add(reportEntity); |
|
|
|
}); |
|
|
|
insetCustomerReportAndFun(entities,funEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insetCustomerReportAndFun(List<IcCustomerReportEntity> reportEntities,List<IcReportFunEntity> funEntities){ |
|
|
|
if (CollectionUtils.isNotEmpty(reportEntities)){ |
|
|
|
insertBatch(reportEntities); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(funEntities)){ |
|
|
|
reportFunService.insertBatch(funEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |