Commit eb70c748 by 王祖波

周报月报修改

parent fd048d8b
package com.gic.haoban.manage.api.dto.content.report;
import java.io.Serializable;
import java.util.List;
/**
* @Author MUSI
......@@ -28,6 +29,11 @@ public class MaterialReportDTO implements Serializable {
*/
private Integer reportType;
/**
* 周报内容
*/
private List<String> rightMenuCodeList;
public String getEnterpriseId() {
return enterpriseId;
}
......@@ -51,4 +57,12 @@ public class MaterialReportDTO implements Serializable {
public void setReportType(Integer reportType) {
this.reportType = reportType;
}
public List<String> getRightMenuCodeList() {
return rightMenuCodeList;
}
public void setRightMenuCodeList(List<String> rightMenuCodeList) {
this.rightMenuCodeList = rightMenuCodeList;
}
}
......@@ -15,6 +15,7 @@ public enum NoticeMessageCategoryTypeEnum {
MATERIAL(6, "素材相关"),
POTENTIAL_CUSTOMER(7, "销售线索"),
AUTHORIZED(8, "授权登陆"),
WEEK_MONTH(9, "周报月报"),
OTHER(3, "其它"),;
private int type;
private String name;
......
......@@ -91,9 +91,9 @@ public enum NoticeMessageTypeEnum {
//
MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center", "materialsNotice", "clerkMaterialsNotice"),
MATERIAL_REPORT_NOTIFY_WEEK(6002, "素材周报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialWeek", "clerkMaterialsReport"),
MATERIAL_REPORT_NOTIFY_WEEK(6002, "周报通知", NoticeMessageCategoryTypeEnum.WEEK_MONTH.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialWeek", "clerkMaterialsReport"),
POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center", "salesLeadNotice", "haobanNotice"),
MATERIAL_REPORT_NOTIFY_MONTH(6004, "素材月报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_month_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialMonth", "clerkMaterialsReport"),
MATERIAL_REPORT_NOTIFY_MONTH(6004, "月报通知", NoticeMessageCategoryTypeEnum.WEEK_MONTH.getType(), "material_month_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialMonth", "clerkMaterialsReport"),
CLERK_COMMISSION_NOTIFY(6005, "客户下单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "clerk_commission_notify", "/pages/route/index?pageType=", "hbapp_withdraw_list", "clerkCommissionNotify", "haobanNotice"),
MATERIAL_AUDIT_NOTIFY(6006, "素材审核通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_audit_notify", "/pages/route/index?pageType=", "hbapp_create_center", "materialAuditNotify", "haobanNotice"),
KNOWLEDGE_NEW_NOTIFY(6007, "知识库上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "knowledge_new_notify", "/pages/route/index?pageType=", "hbapp_guide_knowledge", "knowledgeNewNotify", "clerkMaterialsNotice"),
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
......@@ -32,8 +33,8 @@ import java.util.stream.Collectors;
@Builder
public class MaterialReportContext {
private static final String week_title = "素材使用周报";
private static final String month_title = "素材使用月报";
private static final String week_title = "%s周报";
private static final String month_title = "%s月报";
private static final String week_desc = "%s~%s的素材使用周报已生成,请查收";
private static final String month_desc = "%s~%s的素材使用月报已生成,请查收";
......@@ -48,6 +49,11 @@ public class MaterialReportContext {
private Integer reportType;
/**
* 周报内容
*/
private List<String> rightMenuCodeList;
/**
* 成员id
*/
private String staffId;
......@@ -134,10 +140,18 @@ public class MaterialReportContext {
}
public String getMessageTitle() {
String title = "素材使用";
if (CollectionUtils.isNotEmpty(rightMenuCodeList)) {
if (rightMenuCodeList.size() > 1) {
title = "门店";
}else if (rightMenuCodeList.contains(EnterpriseServiceEnum.CONTENT.getRightMenuCode())){
title = "潜客雷达";
}
}
if (MaterialReportType.WEEK.getCode().equals(this.reportType)) {
return week_title;
return String.format(week_title, title);
}
return month_title;
return String.format(month_title, title);
}
public String getMessageDesc() {
......
......@@ -4,6 +4,7 @@ import com.gic.haoban.manage.service.pojo.bo.content.GroupMessageInfoBo;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialEnterpriseAdaptor;
import java.util.List;
import java.util.Map;
/**
* @Author MUSI
......@@ -28,4 +29,10 @@ public interface GroupMessageService {
* @return
*/
List<String> hasMaterialRightEnterprise(Integer level);
/**
* 查询发送周报月报企业
* @return
*/
Map<String,List<String>> weekMonthEnterprise();
}
package com.gic.haoban.manage.service.service.content;
import com.gic.haoban.manage.api.dto.content.report.MaterialReportDTO;
/**
* @Author MUSI
* @Date 2023/3/24 3:58 PM
......@@ -17,5 +19,5 @@ public interface MaterialReportService {
* @see com.gic.haoban.manage.api.enums.content.MaterialReportType
* @param reportType
*/
void handlerMaterialReport(String enterpriseId, String staffId, Integer reportType);
void handlerMaterialReport(MaterialReportDTO materialReportDTO);
}
package com.gic.haoban.manage.service.service.content.adaptor;
import cn.hutool.core.lang.Pair;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
......@@ -14,9 +15,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -65,6 +64,38 @@ public class MaterialEnterpriseAdaptor {
.collect(Collectors.toList());
}
public Map<String, List<String>> getWeekMonthEid() {
ServiceResponse<List<EnterpriseUsingStatusDTO>> serviceResponse1 =
enterpriseUseForbidService.getUseEnterpriseByCode(EnterpriseServiceEnum.CONTENT.getRightMenuCode(), null);
ServiceResponse<List<EnterpriseUsingStatusDTO>> serviceResponse2 =
enterpriseUseForbidService.getUseEnterpriseByCode(EnterpriseServiceEnum.APPOINTMENT.getRightMenuCode(), null);
if (!serviceResponse1.isSuccess() || !serviceResponse2.isSuccess()) {
return Collections.emptyMap();
}
Map<String, List<String>> map = new HashMap<>();
// 处理内容相关企业ID
Optional.ofNullable(serviceResponse1.getResult()).orElse(Collections.emptyList())
.stream()
.filter(item -> item.getVersion() != null && item.getVersion() >= MaterialEnterpriseAdaptor.MaterialLevel.LOW.getCode())
.filter(item -> Boolean.TRUE.equals(item.getVaild()))
.map(EnterpriseUsingStatusDTO::getEnterpriseId)
.forEach(eid -> map.computeIfAbsent(eid, k -> new ArrayList<>())
.add(EnterpriseServiceEnum.CONTENT.getRightMenuCode()));
// 处理潜客相关企业ID
Optional.ofNullable(serviceResponse2.getResult()).orElse(Collections.emptyList())
.stream()
.filter(item -> Boolean.TRUE.equals(item.getVaild()))
.map(EnterpriseUsingStatusDTO::getEnterpriseId)
.forEach(eid -> map.computeIfAbsent(eid, k -> new ArrayList<>())
.add(EnterpriseServiceEnum.APPOINTMENT.getRightMenuCode()));
return map;
}
/**
* 校验企业是否有内容权限
* @param enterpriseId
......
package com.gic.haoban.manage.service.service.content.adaptor;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
......@@ -9,14 +8,17 @@ import com.gic.commons.util.DateUtil;
import com.gic.content.api.dto.material.ContentMaterialBaseDTO;
import com.gic.content.api.enums.MaterialPurposeEnum;
import com.gic.content.api.service.ContentMaterialApiService;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.service.pojo.bo.content.context.MaterialReportContext;
import com.gic.haoban.manage.service.util.DataTargetHttpUtils;
import com.gic.haoban.manage.service.util.DrawImageUtils;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -38,7 +40,7 @@ import java.util.Optional;
**/
@Slf4j
@Component
public class MaterialDataAdaptor {
public class WeekMonthDataAdaptor {
/**
......@@ -59,6 +61,18 @@ public class MaterialDataAdaptor {
* 区经 月报
*/
private static final String AREA_MONTH_DATA = "data_cms_store_month_report_total";
/**
* 潜客雷达 周报
*/
private static final String POTENTIAL_WEEK_DATA = "data_cms_clerk_week_report_list";
/**
* 潜客雷达 月报
*/
private static final String POTENTIAL_MONTH_DATA = "data_cms_store_month_report_total";
@Autowired
private ContentMaterialApiService contentMaterialApiService;
......@@ -82,15 +96,55 @@ public class MaterialDataAdaptor {
private String storeId;
}
public MaterialDataResult queryClerkReportData(MaterialReportContext context,String storeId,String bizDate) {
String enterpriseId = context.getEnterpriseId();
String clerkId = context.getClerkId();
Integer reportType = context.getReportType();
List<String> rightMenuCodeList = context.getRightMenuCodeList();
if (CollectionUtils.isEmpty(rightMenuCodeList)) {
return MaterialDataResult.buildEmpty();
}
if (rightMenuCodeList.size() > 1) {
MaterialDataResult contentResult = queryClerkReportDataContent(enterpriseId, clerkId, storeId, reportType, bizDate);
MaterialDataResult potentialResult = queryReportDataPotential(enterpriseId, clerkId, Lists.newArrayList(storeId), reportType, bizDate);
return new MaterialDataResult(potentialResult.getFirstValue(),contentResult.getSecondValue());
} else if (rightMenuCodeList.contains(EnterpriseServiceEnum.APPOINTMENT.getRightMenuCode())) {
return queryReportDataPotential(enterpriseId, clerkId, Lists.newArrayList(storeId), reportType, bizDate);
} else if (rightMenuCodeList.contains(EnterpriseServiceEnum.CONTENT.getRightMenuCode())) {
return queryClerkReportDataContent(enterpriseId, clerkId, storeId, reportType, bizDate);
}
return MaterialDataResult.buildEmpty();
}
public MaterialDataResult queryAreaReportData(MaterialReportContext context,List<String> storeIds,String bizDate) {
String enterpriseId = context.getEnterpriseId();
String clerkId = context.getClerkId();
Integer reportType = context.getReportType();
List<String> rightMenuCodeList = context.getRightMenuCodeList();
if (CollectionUtils.isEmpty(rightMenuCodeList)) {
return MaterialDataResult.buildEmpty();
}
if (rightMenuCodeList.size() > 1) {
MaterialDataResult contentResult = queryAreaReportDataContent(enterpriseId, clerkId, storeIds, reportType, bizDate);
MaterialDataResult potentialResult = queryReportDataPotential(enterpriseId, clerkId, storeIds, reportType, bizDate);
return new MaterialDataResult(potentialResult.getFirstValue(),contentResult.getSecondValue());
} else if (rightMenuCodeList.contains(EnterpriseServiceEnum.APPOINTMENT.getRightMenuCode())) {
return queryReportDataPotential(enterpriseId, clerkId, storeIds, reportType, bizDate);
} else if (rightMenuCodeList.contains(EnterpriseServiceEnum.CONTENT.getRightMenuCode())) {
return queryAreaReportDataContent(enterpriseId, clerkId, storeIds, reportType, bizDate);
}
return MaterialDataResult.buildEmpty();
}
/**
* 查询导购/店长的数据
* 查询导购/店长的数据 素材
* @param enterpriseId
* @param clerkId
* @param storeId
* @param reportType
* @return
*/
public MaterialDataResult queryClerkReportData(String enterpriseId, String clerkId, String storeId, Integer reportType, String bizDate) {
public MaterialDataResult queryClerkReportDataContent(String enterpriseId, String clerkId, String storeId, Integer reportType, String bizDate) {
String apolloKey = CLERK_WEEK_DATA;
if (MaterialReportType.MONTH.getCode().equals(reportType)) {
......@@ -128,14 +182,14 @@ public class MaterialDataAdaptor {
/**
* 区经
* 区经 素材
* @param enterpriseId
* @param clerkId
* @param storeIds
* @param reportType
* @return
*/
public MaterialDataResult queryAreaReportData(String enterpriseId, String clerkId, List<String> storeIds, Integer reportType, String bizDate) {
public MaterialDataResult queryAreaReportDataContent(String enterpriseId, String clerkId, List<String> storeIds, Integer reportType, String bizDate) {
String apolloKey = AREA_WEEK_DATA;
if (MaterialReportType.MONTH.getCode().equals(reportType)) {
......@@ -176,6 +230,53 @@ public class MaterialDataAdaptor {
return new MaterialDataResult(numFormat, (formatAmount + amountUnit));
}
/**
* 查询数据 潜客雷达 todo 对接数据
* @param enterpriseId
* @param clerkId
* @param storeIds
* @param reportType
* @return
*/
public MaterialDataResult queryReportDataPotential(String enterpriseId, String clerkId, List<String> storeIds, Integer reportType, String bizDate) {
String apolloKey = POTENTIAL_WEEK_DATA;
if (MaterialReportType.MONTH.getCode().equals(reportType)) {
apolloKey = POTENTIAL_MONTH_DATA;
}
Map<String, Object> inlineParams = new HashMap<>();
if (org.apache.commons.lang3.StringUtils.isNotBlank(clerkId)) {
inlineParams.put("clerkId", clerkId);
}
if (CollectionUtils.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ","));
}
inlineParams.put("enterpriseId", enterpriseId);
inlineParams.put("bizDate", bizDate);
inlineParams.put("orderByFields", 2);
inlineParams.put("orderByType", 1);
Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), apolloKey);
if (result.get("data") == null) {
return null;
}
JSONObject jsonObject = DataApiUtils.getPageOne(result);
if (jsonObject.isEmpty()) {
return null;
}
int useMatlNum = jsonObject.getIntValue("useMatlNum");
BigDecimal convSalesAmt = Optional.ofNullable(jsonObject.getBigDecimal("omniConvSalesAmt")).orElse(BigDecimal.ZERO);
String amountUnit = "";
if (convSalesAmt.compareTo(new BigDecimal(10000)) >= 0) {
convSalesAmt = convSalesAmt.divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
amountUnit = "万";
}
DecimalFormat decimalFormat = new DecimalFormat("#,###,###.##");
String formatAmount = decimalFormat.format(convSalesAmt);
String numFormat = decimalFormat.format(useMatlNum);
return new MaterialDataResult(numFormat, (formatAmount + amountUnit));
}
private Map<String, Object> doHttp(String jsonParam, String apolloKey) {
try {
log.info("调用接口 apolloKey:{}, 参数:{}", apolloKey, jsonParam);
......
package com.gic.haoban.manage.service.service.content.adaptor;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
......@@ -23,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
......@@ -37,13 +36,13 @@ import java.util.Optional;
@Slf4j
@Component
public class MaterialReportBuilder {
public class WeekMonthReportBuilder {
@Autowired
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private ClerkMainStoreRelatedService clerkMainStoreRelatedService;
@Autowired
private MaterialDataAdaptor materialDataAdaptor;
private WeekMonthDataAdaptor weekMonthDataAdaptor;
@Autowired
private Config config;
@Autowired
......@@ -123,41 +122,52 @@ public class MaterialReportBuilder {
}
String clerkId = context.getClerkId();
String enterpriseId = context.getEnterpriseId();
MaterialDataAdaptor.MaterialDataResult materialDataResult;
WeekMonthDataAdaptor.MaterialDataResult materialDataResult;
String bizDate = this.calcBizDate(context.getReportType());
context.setBizDate(bizDate);
// todo 潜客雷达数据
if (StringUtils.isBlank(context.getMainStoreId())) {
// 区经
List<String> storeIds = this.queryClerkStoreIds(clerkId, context.getStaffInfo().getWxEnterpriseId());
materialDataResult = materialDataAdaptor.queryAreaReportData(enterpriseId, clerkId, storeIds, context.getReportType(), bizDate);
materialDataResult = weekMonthDataAdaptor.queryAreaReportData(context, storeIds, bizDate);
} else {
String mainStoreId = context.getMainStoreId();
materialDataResult = materialDataAdaptor.queryClerkReportData(enterpriseId, clerkId, mainStoreId, context.getReportType(), bizDate);
materialDataResult = weekMonthDataAdaptor.queryClerkReportData(context, mainStoreId, bizDate);
}
log.info("获取成员海报数据 clerkId:{}, data: {}", clerkId, JSON.toJSONString(materialDataResult));
if (materialDataResult == null) {
materialDataResult = MaterialDataAdaptor.MaterialDataResult.buildEmpty();
}
DrawImageUtils.DrawBkgImg templatePath = null;
if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) {
if (StringUtils.isBlank(context.getMainStoreId())) {
templatePath = DrawImageUtils.DrawBkgImg.AREA_WEEK_BKG;
} else {
templatePath = DrawImageUtils.DrawBkgImg.CLERK_WEEK_BKG;
}
} else {
if (StringUtils.isBlank(context.getMainStoreId())) {
templatePath = DrawImageUtils.DrawBkgImg.AREA_MONTH_BKG;
} else {
templatePath = DrawImageUtils.DrawBkgImg.CLERK_MONTH_BKG;
}
materialDataResult = WeekMonthDataAdaptor.MaterialDataResult.buildEmpty();
}
DrawImageUtils.DrawBkgImg templatePath = getDrawBkgImg(context);
if (templatePath == null) {
return;
}
// 生成图片地址
String url = DrawImageUtils.drawImage(context.getFactoryCode(), materialDataResult.getFirstValue(), materialDataResult.getSecondValue(), templatePath);
context.setMaterialReportUrl(url);
}
private static DrawImageUtils.DrawBkgImg getDrawBkgImg(MaterialReportContext context) {
boolean isWeek = MaterialReportType.WEEK.getCode().equals(context.getReportType());
boolean hasMainStore = StringUtils.isNotBlank(context.getMainStoreId());
List<String> rightMenuCodeList = context.getRightMenuCodeList();
if (rightMenuCodeList.size() > 1) {
String key = (hasMainStore ? "CLERK" : "AREA") + (isWeek ? "_WEEK" : "_MONTH");
return DrawImageUtils.templateMap.get(key);
}
else if (rightMenuCodeList.contains(EnterpriseServiceEnum.APPOINTMENT.getRightMenuCode())) {
String key = "POTENTIAL_" + (hasMainStore ? "CLERK" : "AREA") + (isWeek ? "_WEEK" : "_MONTH");
return DrawImageUtils.templateMap.get(key);
}
else if (rightMenuCodeList.contains(EnterpriseServiceEnum.CONTENT.getRightMenuCode())) {
String key = "CONTENT_" + (hasMainStore ? "CLERK" : "AREA") + (isWeek ? "_WEEK" : "_MONTH");
return DrawImageUtils.templateMap.get(key);
}
return null;
}
/**
* 计算素材周报的周期
* yyyy-biz
......
......@@ -617,4 +617,9 @@ public class GroupMessageServiceImpl implements GroupMessageService {
log.info("有权限的企业信息 level:{}, enterpriseIds:{}", level, JSON.toJSONString(enterpriseIds));
return enterpriseIds;
}
@Override
public Map<String, List<String>> weekMonthEnterprise() {
return materialEnterpriseAdaptor.getWeekMonthEid();
}
}
......@@ -7,9 +7,9 @@ import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.content.report.MaterialReportDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
......@@ -17,7 +17,7 @@ import com.gic.haoban.manage.service.pojo.bo.content.context.MaterialReportConte
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialReportBuilder;
import com.gic.haoban.manage.service.service.content.adaptor.WeekMonthReportBuilder;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.haoban.manage.service.util.ApolloUtils;
......@@ -52,7 +52,7 @@ public class MaterialReportServiceImpl implements MaterialReportService {
@Autowired
private NoticeMessageService noticeMessageService;
@Autowired
private MaterialReportBuilder materialReportBuilder;
private WeekMonthReportBuilder weekMonthReportBuilder;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
......@@ -74,7 +74,11 @@ public class MaterialReportServiceImpl implements MaterialReportService {
* @param enterpriseId
*/
@Override
public void handlerMaterialReport(String enterpriseId, String staffId, Integer reportType) {
public void handlerMaterialReport(MaterialReportDTO materialReportDTO) {
String enterpriseId = materialReportDTO.getEnterpriseId();
String staffId = materialReportDTO.getStaffId();
Integer reportType = materialReportDTO.getReportType();
List<String> rightMenuCodeList = materialReportDTO.getRightMenuCodeList();
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
if (enterpriseDTO == null) {
......@@ -92,17 +96,18 @@ public class MaterialReportServiceImpl implements MaterialReportService {
.staffId(staffId)
.staffInfo(staffInfo)
.reportType(reportType)
.rightMenuCodeList(rightMenuCodeList)
.build();
// 获取成员关联的导购
materialReportBuilder.buildStaffRelationClerk(context);
weekMonthReportBuilder.buildStaffRelationClerk(context);
if (CollectionUtils.isEmpty(context.getStaffClerkRelations())) {
log.info("处理成员周报月报数据, 成员{}未绑定导购", staffId);
return;
}
// 判断是区经还是 店长/导购 填充主门店
materialReportBuilder.fillMainStore(context);
weekMonthReportBuilder.fillMainStore(context);
// 获取素材数据
materialReportBuilder.buildMaterialReportData(context);
weekMonthReportBuilder.buildMaterialReportData(context);
// 保存小程序消息
List<NoticeMessageBO> noticeMessageBos = context.buildNotifyMessageBos();
......@@ -125,7 +130,7 @@ public class MaterialReportServiceImpl implements MaterialReportService {
// 发送企微消息
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffInfo.getWxEnterpriseId());
QywxNewsSendMessageDTO newsSendMessageDTO = materialReportBuilder.buildQywxNewsMessage(context, qwDTO);
QywxNewsSendMessageDTO newsSendMessageDTO = weekMonthReportBuilder.buildQywxNewsMessage(context, qwDTO);
if (newsSendMessageDTO == null) {
log.info("构建企业应用消息异常 clerkId:{}m staffId: {}", context.getClerkId(), context.getStaffId());
return;
......
package com.gic.haoban.manage.service.service.out.impl.content;
import cn.hutool.db.DaoTemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
......@@ -25,13 +24,9 @@ import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordBO;
import com.gic.haoban.manage.service.pojo.bo.content.OrderEventMqBO;
import com.gic.haoban.manage.service.pojo.bo.content.binlog.MemberOrderBo;
import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessageBO;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.service.service.content.adaptor.WeekMonthDataAdaptor;
import com.gic.haoban.manage.service.service.content.message.InteractRecordMessageService;
import com.gic.haoban.manage.service.task.KafkaMessageServiceImpl;
import com.gic.order.api.dto.OrderDTO;
import com.gic.order.api.dto.req.MemberOrderOptional;
import com.gic.order.api.service.member.MemberOrderReadApiService;
import com.gic.orderecommerce.api.service.EcommerceOrderOutputApiService;
import com.gic.redis.data.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
......@@ -59,7 +54,7 @@ public class MallOrderStatusChangeApiServiceImpl implements MallOrderStatusChang
@Autowired
InteractRecordMessageService interactRecordMessageService;
@Autowired
private MaterialDataAdaptor materialDataAdaptor;
private WeekMonthDataAdaptor weekMonthDataAdaptor;
@Autowired
private EnterpriseUseForbidService enterpriseUseForbidService;
@Autowired
......@@ -251,7 +246,7 @@ public class MallOrderStatusChangeApiServiceImpl implements MallOrderStatusChang
InteractRecordMessageBO interactRecordMessageBO = new InteractRecordMessageBO();
interactRecordMessageBO.setEnterpriseId(enterpriseId);
interactRecordMessageBO.setMemberId(memberId);
MaterialDataAdaptor.MaterialBizInfo materialBizInfo = null;
WeekMonthDataAdaptor.MaterialBizInfo materialBizInfo = null;
MemberBuryPointOrderQDTO memberBuryPointOrderQDTO = new MemberBuryPointOrderQDTO();
memberBuryPointOrderQDTO.setEnterpriseId(enterpriseId);
memberBuryPointOrderQDTO.setOrderCreateTime(orderTime);
......@@ -262,7 +257,7 @@ public class MallOrderStatusChangeApiServiceImpl implements MallOrderStatusChang
ServiceResponse<ContentMemberBuryPointDTO> buryPointResponse = contentMemberBuryPointApiService.queryMemberBuryPoint(memberBuryPointOrderQDTO);
if (buryPointResponse.isSuccess() && buryPointResponse.getResult() != null) {
ContentMemberBuryPointDTO result = buryPointResponse.getResult();
materialBizInfo = new MaterialDataAdaptor.MaterialBizInfo(result.getClerkId(), String.valueOf(result.getContentMaterialId()), result.getStoreId());
materialBizInfo = new WeekMonthDataAdaptor.MaterialBizInfo(result.getClerkId(), String.valueOf(result.getContentMaterialId()), result.getStoreId());
}
// MaterialDataAdaptor.MaterialBizInfo materialBizInfo = materialDataAdaptor.queryMaterialBizInfo(enterpriseId, memberId, orderTime, null);
if (materialBizInfo == null) {
......
package com.gic.haoban.manage.service.service.out.impl.content.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.Week;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.PropertyNamingStrategy;
......@@ -36,7 +36,7 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.content.GroupMessageService;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.service.service.content.adaptor.WeekMonthDataAdaptor;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialEnterpriseAdaptor;
import com.gic.haoban.manage.service.task.KafkaMessageServiceImpl;
import com.gic.haoban.manage.service.task.RouterConstant;
......@@ -96,7 +96,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
@Autowired
private ClerkService clerkService;
@Autowired
private MaterialDataAdaptor materialDataAdaptor;
private WeekMonthDataAdaptor weekMonthDataAdaptor;
@Autowired
EnterpriseUseForbidService enterpriseUseForbidService;
......@@ -189,11 +189,13 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
* @return
*/
private ServiceResponse<Void> doHandlerReportInner(Integer reportType, String params) {
List<String> enterpriseIds = groupMessageService.hasMaterialRightEnterprise(MaterialEnterpriseAdaptor.MaterialLevel.LOW.getCode());
if (CollectionUtils.isEmpty(enterpriseIds)) {
Map<String, List<String>> weekMonthEnterprise = groupMessageService.weekMonthEnterprise();
if (MapUtil.isEmpty(weekMonthEnterprise)) {
return ServiceResponse.success();
}
for (String enterpriseId : enterpriseIds) {
for (Map.Entry<String, List<String>> map : weekMonthEnterprise.entrySet()) {
String enterpriseId = map.getKey();
List<String> rightMenuCodeList = map.getValue();
if (StringUtils.isNotBlank(params) && !StringUtils.equals("-1", params)) {
log.info("执行指定企业的数据 {}", params);
......@@ -217,6 +219,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
temp.setStaffId(staffId);
temp.setEnterpriseId(enterpriseId);
temp.setReportType(reportType);
temp.setRightMenuCodeList(rightMenuCodeList);
boolean sendMQResult = this.sendMaterialReportMQ(temp);
log.info("发送企业{}, 成员id: {}, 结果: {}", enterpriseId, staffId, sendMQResult);
}
......@@ -239,7 +242,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
log.info("参数异常 {}", params);
return ServiceResponse.success();
}
materialReportService.handlerMaterialReport(materialReportDTO.getEnterpriseId(), materialReportDTO.getStaffId(), materialReportDTO.getReportType());
materialReportService.handlerMaterialReport(materialReportDTO);
return ServiceResponse.success();
}
......@@ -469,7 +472,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
orderHoloBo.setCreateTime(DateUtil.dateToStr(orderDTO.getCreateTime(), DateUtil.FORMAT_DATETIME_19));
orderHoloBo.setUpdateTime(DateUtil.dateToStr(orderDTO.getCreateTime(), DateUtil.FORMAT_DATETIME_19));
orderHoloBo.setDeleteFlag(0);
MaterialDataAdaptor.MaterialBizInfo materialBizInfo = materialDataAdaptor.queryMaterialBizInfo(orderDTO.getEnterpriseId(), orderDTO.getMemberId(), orderDTO.getOrderTime(), null);
WeekMonthDataAdaptor.MaterialBizInfo materialBizInfo = weekMonthDataAdaptor.queryMaterialBizInfo(orderDTO.getEnterpriseId(), orderDTO.getMemberId(), orderDTO.getOrderTime(), null);
if (materialBizInfo != null) {
orderHoloBo.setContentMaterialId(Long.parseLong(materialBizInfo.getBizId()));
orderHoloBo.setShareClerkId(materialBizInfo.getClerkId());
......@@ -500,11 +503,11 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
orderItemHoloBo.setUpdateTime(orderItemHoloBo.getUpdateTime());
orderItemHoloBo.setDeleteFlag(0);
MaterialDataAdaptor.MaterialBizInfo tempMaterialInfo
= materialDataAdaptor.queryMaterialBizInfo(orderItemHoloBo.getEnterpriseId(), item.getMemberId(), orderDTO.getOrderTime(), item.getProductCode());
WeekMonthDataAdaptor.MaterialBizInfo tempMaterialInfo
= weekMonthDataAdaptor.queryMaterialBizInfo(orderItemHoloBo.getEnterpriseId(), item.getMemberId(), orderDTO.getOrderTime(), item.getProductCode());
if (tempMaterialInfo != null) {
orderItemHoloBo.setContentMaterialId(Long.parseLong(tempMaterialInfo.getBizId()));
Long materialBaseId = materialDataAdaptor.queryMaterialBaseId(orderItemHoloBo.getEnterpriseId(), orderItemHoloBo.getContentMaterialId());
Long materialBaseId = weekMonthDataAdaptor.queryMaterialBaseId(orderItemHoloBo.getEnterpriseId(), orderItemHoloBo.getContentMaterialId());
orderItemHoloBo.setAuditMaterialId(materialBaseId);
}
return orderItemHoloBo;
......@@ -544,10 +547,10 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
orderHoloBo.setCreateTime(DateUtil.dateToStr(eorderDTO.getCreateTime(), DateUtil.FORMAT_DATETIME_19));
orderHoloBo.setUpdateTime(DateUtil.dateToStr(eorderDTO.getUpdateTime(), DateUtil.FORMAT_DATETIME_19));
orderHoloBo.setDeleteFlag(0);
MaterialDataAdaptor.MaterialBizInfo materialBizInfo = materialDataAdaptor.queryMaterialBizInfo(eorderDTO.getEnterpriseId(), eorderDTO.getMemberId(), eorderDTO.getOrderCreateTime(), null);
WeekMonthDataAdaptor.MaterialBizInfo materialBizInfo = weekMonthDataAdaptor.queryMaterialBizInfo(eorderDTO.getEnterpriseId(), eorderDTO.getMemberId(), eorderDTO.getOrderCreateTime(), null);
if (materialBizInfo != null) {
orderHoloBo.setContentMaterialId(Long.parseLong(materialBizInfo.getBizId()));
Long materialBaseId = materialDataAdaptor.queryMaterialBaseId(eorderDTO.getEnterpriseId(), orderHoloBo.getContentMaterialId());
Long materialBaseId = weekMonthDataAdaptor.queryMaterialBaseId(eorderDTO.getEnterpriseId(), orderHoloBo.getContentMaterialId());
orderHoloBo.setAuditMaterialId(materialBaseId);
orderHoloBo.setShareClerkId(materialBizInfo.getClerkId());
orderHoloBo.setShareStoreId(materialBizInfo.getStoreId());
......@@ -581,11 +584,11 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
orderItemHoloBo.setUpdateTime(DateUtil.dateToStr(eorderDTO.getUpdateTime(), DateUtil.FORMAT_DATETIME_19));
orderItemHoloBo.setDeleteFlag(0);
MaterialDataAdaptor.MaterialBizInfo tempMaterialInfo
= materialDataAdaptor.queryMaterialBizInfo(item.getEnterpriseId(), item.getMemberId(), eorderDTO.getOrderCreateTime(), item.getGoodsCode());
WeekMonthDataAdaptor.MaterialBizInfo tempMaterialInfo
= weekMonthDataAdaptor.queryMaterialBizInfo(item.getEnterpriseId(), item.getMemberId(), eorderDTO.getOrderCreateTime(), item.getGoodsCode());
if (tempMaterialInfo != null) {
orderItemHoloBo.setContentMaterialId(Long.parseLong(tempMaterialInfo.getBizId()));
Long materialBaseId = materialDataAdaptor.queryMaterialBaseId(eorderDTO.getEnterpriseId(), orderItemHoloBo.getContentMaterialId());
Long materialBaseId = weekMonthDataAdaptor.queryMaterialBaseId(eorderDTO.getEnterpriseId(), orderItemHoloBo.getContentMaterialId());
orderItemHoloBo.setAuditMaterialId(materialBaseId);
}
return orderItemHoloBo;
......
......@@ -14,6 +14,7 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Random;
/**
......@@ -28,10 +29,21 @@ public class DrawImageUtils {
@Getter
@AllArgsConstructor
public enum DrawBkgImg {
AREA_WEEK_BKG("template/area_week_bkg.png", "区经周报背景图", 352, 416, 320),
AREA_MONTH_BKG("template/area_month_bkg.png", "区经月报背景图", 352, 416, 320),
CLERK_WEEK_BKG("template/week_bkg.png", "导购/店长周报背景图", 260, 320, 353),
CLERK_MONTH_BKG("template/month_bkg.png", "导购/店长月报背景图", 260, 320, 353),
CONTENT_AREA_WEEK_BKG("template/content_area_week_bkg.png", "素材区经周报背景图", 352, 416, 320),
CONTENT_AREA_MONTH_BKG("template/content_area_month_bkg.png", "素材区经月报背景图", 352, 416, 320),
CONTENT_CLERK_WEEK_BKG("template/content_week_bkg.png", "素材导购/店长周报背景图", 260, 320, 353),
CONTENT_CLERK_MONTH_BKG("template/content_month_bkg.png", "素材导购/店长月报背景图", 260, 320, 353),
POTENTIAL_AREA_WEEK_BKG("template/potential_week_bkg.png", "潜客雷达区经周报背景图", 260, 320, 353),
POTENTIAL_AREA_MONTH_BKG("template/potential_month_bkg.png", "潜客雷达区经月报背景图", 260, 320, 353),
POTENTIAL_CLERK_WEEK_BKG("template/potential_week_bkg.png", "潜客雷达导购/店长周报背景图", 260, 320, 353),
POTENTIAL_CLERK_MONTH_BKG("template/potential_month_bkg.png", "潜客雷达导购/店长月报背景图", 260, 320, 353),
AREA_WEEK_BKG("template/week_bkg.png", "门店增长区经周报背景图", 352, 416, 320),
AREA_MONTH_BKG("template/month_bkg.png", "门店增长区经月报背景图", 352, 416, 320),
CLERK_WEEK_BKG("template/week_bkg.png", "门店增长导购/店长周报背景图", 352, 416, 320),
CLERK_MONTH_BKG("template/month_bkg.png", "门店增长导购/店长月报背景图", 352, 416, 320),
;
private String path;
private String desc;
......@@ -49,7 +61,27 @@ public class DrawImageUtils {
*/
private int amountWidth;
}
public static final HashMap<String, DrawImageUtils.DrawBkgImg> templateMap = new HashMap<>();
static {
// 区域+周/月
templateMap.put("AREA_WEEK", DrawImageUtils.DrawBkgImg.AREA_WEEK_BKG);
templateMap.put("AREA_MONTH", DrawImageUtils.DrawBkgImg.AREA_MONTH_BKG);
// 导购+周/月
templateMap.put("CLERK_WEEK", DrawImageUtils.DrawBkgImg.CLERK_WEEK_BKG);
templateMap.put("CLERK_MONTH", DrawImageUtils.DrawBkgImg.CLERK_MONTH_BKG);
// 预约 + 区域/导购 + 周/月
templateMap.put("POTENTIAL_AREA_WEEK", DrawImageUtils.DrawBkgImg.POTENTIAL_AREA_WEEK_BKG);
templateMap.put("POTENTIAL_CLERK_WEEK", DrawImageUtils.DrawBkgImg.POTENTIAL_CLERK_WEEK_BKG);
templateMap.put("POTENTIAL_AREA_MONTH", DrawImageUtils.DrawBkgImg.POTENTIAL_AREA_MONTH_BKG);
templateMap.put("POTENTIAL_CLERK_MONTH", DrawImageUtils.DrawBkgImg.POTENTIAL_CLERK_MONTH_BKG);
// 内容 + 区域/导购 + 周/月
templateMap.put("CONTENT_AREA_WEEK", DrawImageUtils.DrawBkgImg.CONTENT_AREA_WEEK_BKG);
templateMap.put("CONTENT_CLERK_WEEK", DrawImageUtils.DrawBkgImg.CONTENT_CLERK_WEEK_BKG);
templateMap.put("CONTENT_AREA_MONTH", DrawImageUtils.DrawBkgImg.CONTENT_AREA_MONTH_BKG);
templateMap.put("CONTENT_CLERK_MONTH", DrawImageUtils.DrawBkgImg.CONTENT_CLERK_MONTH_BKG);
}
/**
......
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.haoban.manage.api.dto.content.report.MaterialReportDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.api.service.content.task.QywxGroupMsgTaskApiService;
......@@ -10,14 +12,14 @@ import com.gic.haoban.manage.service.entity.content.TabHaobanInteractRecord;
import com.gic.haoban.manage.service.service.MemberQueryService;
import com.gic.haoban.manage.service.service.content.GroupMessageService;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.service.service.content.adaptor.WeekMonthDataAdaptor;
import com.gic.member.api.dto.es.MemberDataDTO;
import com.gic.search.engine.api.constant.MemberDataEnum;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
......@@ -47,7 +49,7 @@ public class MaterialReportServiceTest {
@Autowired
private TabHaobanInteractRecordMapper interactRecordMapper;
@Autowired
private MaterialDataAdaptor materialDataAdaptor;
private WeekMonthDataAdaptor weekMonthDataAdaptor;
@Autowired
private MemberQueryService memberQueryService;
......@@ -61,8 +63,14 @@ public class MaterialReportServiceTest {
@Test
public void handlerMaterialWeekReportTest() {
System.setProperty("gic.module.name", "haoban-manage3-service");
materialReportService.handlerMaterialReport(eid, staffId, MaterialReportType.WEEK.getCode());
materialReportService.handlerMaterialReport(eid, staffId, MaterialReportType.MONTH.getCode());
MaterialReportDTO materialReportDTO = new MaterialReportDTO();
materialReportDTO.setEnterpriseId(eid);
materialReportDTO.setStaffId(staffId);
materialReportDTO.setReportType(MaterialReportType.WEEK.getCode());
materialReportDTO.setRightMenuCodeList(Lists.newArrayList(EnterpriseServiceEnum.CONTENT.getRightMenuCode()));
materialReportService.handlerMaterialReport(materialReportDTO);
materialReportDTO.setReportType(MaterialReportType.MONTH.getCode());
materialReportService.handlerMaterialReport(materialReportDTO);
}
@Test
......@@ -111,7 +119,7 @@ public class MaterialReportServiceTest {
@Test
public void queryData(){
MaterialDataAdaptor.MaterialDataResult materialDataResult = materialDataAdaptor.queryClerkReportData(eid, clerkId, storeId, MaterialReportType.MONTH.getCode(), "2023-14");
WeekMonthDataAdaptor.MaterialDataResult materialDataResult = weekMonthDataAdaptor.queryClerkReportDataContent(eid, clerkId, storeId, MaterialReportType.MONTH.getCode(), "2023-14");
System.out.println(JSON.toJSONString(materialDataResult));
}
......
......@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 潜客雷达-跟进记录
* 潜客雷达-数据
*/
@RestController
@RequestMapping()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment