|
|
@ -1,22 +1,37 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.form.DictListFormDTO; |
|
|
|
import com.epmet.commons.tools.dto.result.DictListResultDTO; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.CustomerFunctionConstant; |
|
|
|
import com.epmet.dao.IcCustomerReportDao; |
|
|
|
import com.epmet.dto.CustomerDTO; |
|
|
|
import com.epmet.dto.form.PreviewReportFormDTO; |
|
|
|
import com.epmet.dto.result.PreviewReportResDTO; |
|
|
|
import com.epmet.dto.IcCustomerReportDTO; |
|
|
|
import com.epmet.dto.form.ReportEditFormDTO; |
|
|
|
import com.epmet.dto.result.ReportResultDTO; |
|
|
|
import com.epmet.entity.IcCustomerReportEntity; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import com.epmet.service.IcCustomerReportService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 客户报表关系表 |
|
|
@ -26,22 +41,14 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerReportDao, IcCustomerReportEntity> implements IcCustomerReportService { |
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcCustomerReportDTO> page(Map<String, Object> params) { |
|
|
|
IPage<IcCustomerReportEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, IcCustomerReportDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<IcCustomerReportDTO> list(Map<String, Object> params) { |
|
|
|
List<IcCustomerReportEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
@Autowired |
|
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, IcCustomerReportDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<IcCustomerReportEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
@ -52,31 +59,71 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor |
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 报表集合 |
|
|
|
* @param |
|
|
|
* @author zxc |
|
|
|
* @date 2022/8/8 10:38 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public IcCustomerReportDTO get(String id) { |
|
|
|
IcCustomerReportEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, IcCustomerReportDTO.class); |
|
|
|
public List<ReportResultDTO> reportList() { |
|
|
|
List<ReportResultDTO> reportList = baseDao.reportList(); |
|
|
|
if (CollectionUtils.isEmpty(reportList)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
Result<List<DictListResultDTO>> dictList = adminOpenFeignClient.dictList(new DictListFormDTO(CustomerFunctionConstant.REPORT_CATEGORY)); |
|
|
|
if (!dictList.success()){ |
|
|
|
throw new EpmetException("查询字典信息失败:" + CustomerFunctionConstant.REPORT_CATEGORY); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(dictList.getData())){ |
|
|
|
dictList.getData().forEach(d -> reportList.stream().filter(r -> d.getValue().equals(r.getCategoryKey())).forEach(r -> r.setCategoryName(d.getLabel()))); |
|
|
|
} |
|
|
|
Result<List<CustomerDTO>> allCustomerList = operCrmOpenFeignClient.getAllCustomerList(); |
|
|
|
if (!allCustomerList.success()){ |
|
|
|
throw new EpmetException("获取客户信息失败..."); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(allCustomerList.getData())){ |
|
|
|
allCustomerList.getData().forEach(c -> reportList.stream().filter(r -> c.getId().equals(r.getCustomerId())).forEach(r -> r.setCustomerName(c.getCustomerName()))); |
|
|
|
} |
|
|
|
// todo 报表
|
|
|
|
List<ReportResultDTO> result = new ArrayList<>(); |
|
|
|
Map<String, List<ReportResultDTO>> groupByReport = reportList.stream().collect(Collectors.groupingBy(ReportResultDTO::getReportId)); |
|
|
|
groupByReport.forEach((reportId,l) -> { |
|
|
|
ReportResultDTO dto = new ReportResultDTO(); |
|
|
|
dto.setReportId(reportId); |
|
|
|
dto.setReportName(l.get(NumConstant.ZERO).getReportName()); |
|
|
|
dto.setCustomerList(ConvertUtils.sourceToTarget(l, ReportResultDTO.CustomerList.class)); |
|
|
|
result.add(dto); |
|
|
|
}); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 在居民信息或者房屋信息等页面点击填表,存储入参到redis,返给前端key |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(IcCustomerReportDTO dto) { |
|
|
|
IcCustomerReportEntity entity = ConvertUtils.sourceToTarget(dto, IcCustomerReportEntity.class); |
|
|
|
insert(entity); |
|
|
|
public PreviewReportResDTO previewReport(PreviewReportFormDTO formDTO) { |
|
|
|
// rediskey格式:customerId:reportId:resiinfo:staffId
|
|
|
|
PreviewReportResDTO reportResDTO = new PreviewReportResDTO(); |
|
|
|
reportResDTO.setReportId(formDTO.getReportId()); |
|
|
|
String key = formDTO.getCustomerId().concat(StrConstant.COLON).concat(formDTO.getReportId()).concat(StrConstant.COLON).concat(formDTO.getCategoryKey()).concat(StrConstant.COLON).concat(formDTO.getStaffId()); |
|
|
|
redisUtils.hMSet(key, formDTO.getParamMap(), RedisUtils.DEFAULT_EXPIRE); |
|
|
|
return reportResDTO; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
* Desc: 报表编辑 |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/8/8 14:09 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(IcCustomerReportDTO dto) { |
|
|
|
IcCustomerReportEntity entity = ConvertUtils.sourceToTarget(dto, IcCustomerReportEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
public void reportEdit(ReportEditFormDTO formDTO) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |