Commit 58b91050 authored by 廖旭伟's avatar 廖旭伟

名片发送接口

parent 42750468
......@@ -217,6 +217,7 @@ public class FavoriteApiController extends AbstractBaseController<FavoriteReq>{
long id = productList.get(i).getProductId();
ProductEntity productEntity = productService.selectOne(new ProductQuery().id(id));
if(!ObjectUtils.isEmpty(productEntity)){
productEntity.setProductDetail(null);
list.add(productEntity);
}
}
......@@ -234,6 +235,7 @@ public class FavoriteApiController extends AbstractBaseController<FavoriteReq>{
long id = newsList.get(i).getNewsId();
NewsEntity newsEntity = newsService.selectOne(new NewsQuery().id(id));
if(!ObjectUtils.isEmpty(newsEntity)){
newsEntity.setContent(null);
list.add(newsEntity);
}
}
......
......@@ -11,6 +11,7 @@ import com.mortals.framework.model.Result;
import com.mortals.xhx.busiz.applets.req.ProductReq;
import com.mortals.xhx.busiz.applets.req.StaffReq;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.bussinesscard.service.BussinesscardService;
import com.mortals.xhx.module.category.model.CategoryQuery;
import com.mortals.xhx.module.category.service.CategoryService;
import com.mortals.xhx.module.product.model.ProductEntity;
......@@ -53,6 +54,8 @@ public class StaffApiController extends AbstractBaseController<StaffReq>{
private StaffService staffService;
@Autowired
private StaffRecordService staffRecordService;
@Autowired
private BussinesscardService bussinesscardService;
/**
* 员工详情
......@@ -119,4 +122,30 @@ public class StaffApiController extends AbstractBaseController<StaffReq>{
}
return rest;
}
/**
* 发送名片
*/
@PostMapping(value = "sendBusinessCard")
public Rest<Object> sendBusinessCard(@RequestBody StaffReq staffReq){
String busiDesc = "发送名片";
log.info("【{}】【请求体】--> {}", busiDesc, JSONObject.toJSONString(staffReq));
Rest<Object> rest = Rest.ok();
Context context = this.getContext();
if (ObjectUtils.isEmpty(context) || ObjectUtils.isEmpty(context.getUser())) {
throw new AppException(ERROR_TOKEN_EXPIRED, ERROR_TOKEN_EXPIRED_CONTENT);
}
try {
if(!ObjectUtils.isEmpty(staffReq.getId())){
bussinesscardService.sendBusinessCard(staffReq.getId());
}else {
rest = Rest.fail("缺少id");
}
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error(busiDesc, e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
}
......@@ -13,4 +13,10 @@ import com.mortals.xhx.module.bussinesscard.dao.BussinesscardDao;
public interface BussinesscardService extends ICRUDService<BussinesscardEntity,Long>{
BussinesscardDao getDao();
/**
* 发送名片
* @param id
*/
void sendBusinessCard(Long id);
}
\ No newline at end of file
......@@ -21,6 +21,11 @@ import com.mortals.xhx.module.bussinesscard.dao.BussinesscardDao;
import com.mortals.xhx.module.bussinesscard.model.BussinesscardEntity;
import com.mortals.xhx.module.bussinesscard.service.BussinesscardService;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* BussinesscardService
* 名片基本信息 service实现
......@@ -109,4 +114,17 @@ public class BussinesscardServiceImpl extends AbstractCRUDServiceImpl<Bussinessc
}
return entity;
}
@Override
public void sendBusinessCard(Long id) {
BussinesscardEntity entity = this.get(id);
if(entity!=null) {
Map condition = new HashMap();
condition.put("id", id);
Map data = new HashMap();
data.put("sendBusinessCardTimesIncrement", 1);
data.put("updateTime", new Date());
this.dao.update(data,condition);
}
}
}
\ No newline at end of file
......@@ -36,5 +36,9 @@ public class CompanyVo extends BaseEntityLong {
//名片数量
private Integer businessCardNums = 0;
/**
* 发送名片次数
*/
private Integer sendBusinessCardTimes;
}
\ No newline at end of file
package com.mortals.xhx.module.company.model.vo;
import com.mortals.xhx.module.bussinesscard.model.BussinesscardEntity;
import com.mortals.xhx.module.company.model.CompanyEntity;
import com.mortals.xhx.module.news.model.NewsCategoryEntity;
import com.mortals.xhx.module.product.model.ProductEntity;
......@@ -73,7 +74,7 @@ public class HomeStatInfo {
/**
* 发送卡片总量
*/
private List<StaffEntity> sendCardStaffList;
private List<BussinesscardEntity> sendCardStaffList;
}
......@@ -243,22 +243,20 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
homeStatInfo.setProductDistributionList(companyList);
//发送名片分布
List<BussinesscardEntity> bussinesscardList = bussinesscardService.find(new BussinesscardQuery());
Map<Long, Integer> collect = bussinesscardList.stream().collect(Collectors.groupingBy(x -> x.getCompanyId(), Collectors.summingInt(BussinesscardEntity::getSendBusinessCardTimes)));
List<BussinesscardEntity> bussinesscardList = bussinesscardService.getAllList();
Map<Long, List<BussinesscardEntity>> collect = bussinesscardList.stream().collect(Collectors.groupingBy(x -> x.getCompanyId()));
/* Map<String, Integer> collect = staffList.stream().collect(Collectors.groupingBy(x -> x.getCompanyIds(), Collectors.summingInt(StaffEntity::getSendBusinessCardTimes)));
*/
companyList.forEach(company -> {
//归集公司发送卡片数量
Long companyId = company.getId();
company.setBusinessCardNums(collect.getOrDefault(companyId,0));
/* collect.entrySet().stream().forEach(item -> {
String key = item.getKey();
Integer nums = item.getValue();
List<String> split = StrUtil.split(key, ",");
if (split.contains(companyId.toString())) {
company.setBusinessCardNums(company.getBusinessCardNums() + nums);
}
});*/
if(collect.containsKey(companyId)){
company.setBusinessCardNums(collect.get(companyId).size());
int sendBusinessCardTimes = collect.get(companyId).stream().mapToInt(BussinesscardEntity::getSendBusinessCardTimes).sum();
company.setSendBusinessCardTimes(sendBusinessCardTimes);
}else {
company.setBusinessCardNums(0);
}
});
homeStatInfo.setBusinessCardDistributionList(companyList);
......@@ -291,7 +289,7 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
homeStatInfo.setAccessStatList(dayAccessList);
homeStatInfo.setSendCardStaffList(staffList);
homeStatInfo.setSendCardStaffList(bussinesscardList);
return Rest.ok(homeStatInfo);
}
......
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