|
@@ -23,6 +23,8 @@ import com.fjhx.common.service.documentary.GetDocumentaryBusinessTemplate;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
+import com.fjhx.file.entity.FileInfoVo;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.sale.entity.contract.bo.ContractDocumentaryBo;
|
|
@@ -101,28 +103,48 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Override
|
|
|
public Page<ContractVo> getPage(ContractSelectDto dto) {
|
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
|
- wrapper.orderByDesc("t1",Contract::getCreateTime);
|
|
|
- wrapper.between("t1",Contract::getStatus, FlowStatusEnum.DRAFT.getKey(),FlowStatusEnum.CANCELLATION.getKey()-1);
|
|
|
- if(StringUtils.isNotEmpty(dto.getStatus())){
|
|
|
- wrapper.eq("t1",Contract::getStatus,dto.getStatus());
|
|
|
+ wrapper.orderByDesc("t1", Contract::getCreateTime);
|
|
|
+ wrapper.between("t1", Contract::getStatus, FlowStatusEnum.DRAFT.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
|
|
|
+ if (StringUtils.isNotEmpty(dto.getStatus())) {
|
|
|
+ wrapper.eq("t1", Contract::getStatus, dto.getStatus());
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getSellCorporationId())){
|
|
|
- wrapper.eq("t1",Contract::getSellCorporationId,dto.getSellCorporationId());
|
|
|
+ if (StringUtils.isNotEmpty(dto.getSellCorporationId())) {
|
|
|
+ wrapper.eq("t1", Contract::getSellCorporationId, dto.getSellCorporationId());
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
- wrapper.keyword(dto.getKeyword(),new SqlField("t1",Contract::getCode));
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
|
|
|
}
|
|
|
Page<ContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<ContractVo> list = page.getRecords();
|
|
|
if(CollectionUtils.isNotEmpty(list)){
|
|
|
List<Long> customerIds = list.stream().map(Contract::getBuyCorporationId).collect(Collectors.toList());
|
|
|
- List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId,customerIds));
|
|
|
- Map<Long,List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
|
|
|
- if(MapUtils.isNotEmpty(cusMap)){//客户
|
|
|
- for(ContractVo p:list){
|
|
|
- List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(),null);
|
|
|
- p.setBuyCorporationName(customers==null?null:customers.get(0).getName());
|
|
|
+ List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
|
|
|
+ Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
|
|
|
+
|
|
|
+ List<Long> ids = list.stream().map(ContractVo::getId).collect(Collectors.toList());
|
|
|
+ //获取交接单附件
|
|
|
+ Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);
|
|
|
+
|
|
|
+ //获取包装附件
|
|
|
+ Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);
|
|
|
+ for (ContractVo p : list) {
|
|
|
+ if (MapUtils.isNotEmpty(cusMap)) {//客户
|
|
|
+ List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(), null);
|
|
|
+ p.setBuyCorporationName(customers == null ? null : customers.get(0).getName());
|
|
|
}
|
|
|
+
|
|
|
+ //赋值交接单附件
|
|
|
+ if (MapUtils.isNotEmpty(fileMap)){
|
|
|
+ List<FileInfoVo> fileInfoVos = fileMap.get(p.getId());
|
|
|
+ p.setFileInfoVos(fileInfoVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值包装附件信息
|
|
|
+ if (MapUtils.isNotEmpty(packageFileMap)){
|
|
|
+ List<FileInfoVo> packageFileInfoVOList= packageFileMap.get(p.getId());
|
|
|
+ p.setPackageFileInfoVOList(packageFileInfoVOList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return page;
|
|
@@ -156,6 +178,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 根据客户ID查询未包装的订单
|
|
|
+ *
|
|
|
* @param customerId
|
|
|
* @return
|
|
|
*/
|
|
@@ -213,6 +236,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 查询销售额(合同总金额)
|
|
|
+ *
|
|
|
* @param id (买方公司ID)
|
|
|
*/
|
|
|
@Override
|
|
@@ -222,6 +246,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 查询指定客户的每月合同总额
|
|
|
+ *
|
|
|
* @param dto
|
|
|
*/
|
|
|
@Override
|
|
@@ -232,6 +257,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 查询成交单统计(合同)
|
|
|
+ *
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
@@ -242,20 +268,21 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
|
|
|
/**
|
|
|
* 销售趋势(数据看板-产品分析页面)
|
|
|
+ *
|
|
|
* @param productInfoDto
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> saleTrend(ProductInfoSelectDto productInfoDto) {
|
|
|
+ public List<Map<String, Object>> saleTrend(ProductInfoSelectDto productInfoDto) {
|
|
|
//存放每月的月度销售额与月度销售量的列表
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
|
- List<String> monthList = DateUtils.getMonthBetweenDate(productInfoDto.getBeginTime(),productInfoDto.getEndTime());
|
|
|
+ List<String> monthList = DateUtils.getMonthBetweenDate(productInfoDto.getBeginTime(), productInfoDto.getEndTime());
|
|
|
//查询月度销售额与月度销售量
|
|
|
QueryWrapper<ContractProduct> query = Wrappers.query();
|
|
|
String beginTime = DateUtil.format(productInfoDto.getBeginTime(), "yyyy-MM");
|
|
|
String endTime = DateUtil.format(productInfoDto.getEndTime(), "yyyy-MM");
|
|
|
- query.ge("DATE_FORMAT(create_time,'%Y-%m')",beginTime);
|
|
|
- query.le("DATE_FORMAT(create_time,'%Y-%m')",endTime);
|
|
|
+ query.ge("DATE_FORMAT(create_time,'%Y-%m')", beginTime);
|
|
|
+ query.le("DATE_FORMAT(create_time,'%Y-%m')", endTime);
|
|
|
query.select("DATE_FORMAT(create_time,'%Y-%m') time,ifnull(SUM(amount),0) contractAmount," +
|
|
|
"ifnull(SUM(quantity),0) contractQuantity");
|
|
|
query.groupBy("time");
|
|
@@ -265,17 +292,17 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
//给每月赋值月度销售额与月度销售量的值
|
|
|
for (String month : monthList) {
|
|
|
//存放每月的月度销售额与月度销售量的值
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
//赋值初使值
|
|
|
- map.put("month",month);
|
|
|
- map.put("contractAmount",new BigDecimal(0));
|
|
|
- map.put("contractQuantity",new BigDecimal(0));
|
|
|
+ map.put("month", month);
|
|
|
+ map.put("contractAmount", new BigDecimal(0));
|
|
|
+ map.put("contractQuantity", new BigDecimal(0));
|
|
|
|
|
|
//赋值
|
|
|
List<ContractProduct> contracts = contractMap.get(month);
|
|
|
- if (ObjectUtil.isNotEmpty(contracts)){
|
|
|
- map.put("contractAmount",contracts.get(0).getContractAmount());
|
|
|
- map.put("contractQuantity",contracts.get(0).getContractQuantity());
|
|
|
+ if (ObjectUtil.isNotEmpty(contracts)) {
|
|
|
+ map.put("contractAmount", contracts.get(0).getContractAmount());
|
|
|
+ map.put("contractQuantity", contracts.get(0).getContractQuantity());
|
|
|
}
|
|
|
list.add(map);
|
|
|
}
|
|
@@ -290,37 +317,37 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
public Map<String, Object> salesStatistics(ContractDto dto) {
|
|
|
//添加查询条件
|
|
|
QueryWrapper<Contract> query = Wrappers.<Contract>query();
|
|
|
- selectTime(query,dto);
|
|
|
+ selectTime(query, dto);
|
|
|
query.select("sum(amount) amount");
|
|
|
|
|
|
//查询销售额
|
|
|
Contract contract = baseMapper.selectOne(query);
|
|
|
query.clear();
|
|
|
//查询订单数
|
|
|
- selectTime(query,dto);
|
|
|
+ selectTime(query, dto);
|
|
|
|
|
|
Long count = baseMapper.selectCount(query);
|
|
|
|
|
|
//查询下单的客户人数
|
|
|
query.clear();
|
|
|
- selectTime(query,dto);
|
|
|
+ selectTime(query, dto);
|
|
|
query.select("count(DISTINCT(buy_corporation_id)) count");
|
|
|
Contract contract1 = baseMapper.selectOne(query);
|
|
|
|
|
|
//存放销售统计数据
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
//初始化数据
|
|
|
- map.put("amount",new BigDecimal(0));
|
|
|
- map.put("contractCount",count);
|
|
|
- map.put("customerCount",new BigDecimal(0));
|
|
|
+ map.put("amount", new BigDecimal(0));
|
|
|
+ map.put("contractCount", count);
|
|
|
+ map.put("customerCount", new BigDecimal(0));
|
|
|
|
|
|
//赋值
|
|
|
- if (ObjectUtil.isNotEmpty(contract)){
|
|
|
- map.put("amount",contract.getAmount());
|
|
|
+ if (ObjectUtil.isNotEmpty(contract)) {
|
|
|
+ map.put("amount", contract.getAmount());
|
|
|
}
|
|
|
|
|
|
- if (ObjectUtil.isNotEmpty(contract1)){
|
|
|
- map.put("customerCount",contract1.getCount());
|
|
|
+ if (ObjectUtil.isNotEmpty(contract1)) {
|
|
|
+ map.put("customerCount", contract1.getCount());
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
@@ -331,12 +358,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Override
|
|
|
public List<ContractDto> countrySalesStatistics(ContractDto dto) {
|
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
|
- query.ge("DATE_FORMAT(cc.create_time,'%Y-%m')",dto.getBeginTime());
|
|
|
- query.le("DATE_FORMAT(cc.create_time,'%Y-%m')",dto.getEndTime());
|
|
|
+ query.ge("DATE_FORMAT(cc.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(cc.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
query.groupBy("cc.buy_country_id");
|
|
|
query.orderByDesc("amount");
|
|
|
//查询销售国家统计信息
|
|
|
- List<ContractDto> contractDtoList = baseMapper.countrySalesStatistics(query);
|
|
|
+ List<ContractDto> contractDtoList = baseMapper.countrySalesStatistics(query);
|
|
|
return contractDtoList;
|
|
|
}
|
|
|
|
|
@@ -346,12 +373,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Override
|
|
|
public List<ContractDto> customSalesStatistics(ContractDto dto) {
|
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
|
- query.ge("DATE_FORMAT(cc.create_time,'%Y-%m')",dto.getBeginTime());
|
|
|
- query.le("DATE_FORMAT(cc.create_time,'%Y-%m')",dto.getEndTime());
|
|
|
+ query.ge("DATE_FORMAT(cc.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(cc.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
query.groupBy("cc.buy_corporation_id");
|
|
|
query.orderByDesc("amount");
|
|
|
//查询销售国家统计信息
|
|
|
- List<ContractDto> contractDtoList = baseMapper.customSalesStatistics(query);
|
|
|
+ List<ContractDto> contractDtoList = baseMapper.customSalesStatistics(query);
|
|
|
return contractDtoList;
|
|
|
}
|
|
|
|
|
@@ -361,12 +388,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Override
|
|
|
public List<ContractDto> salesmanSalesStatistics(ContractDto dto) {
|
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
|
- query.ge("DATE_FORMAT(cc.create_time,'%Y-%m')",dto.getBeginTime());
|
|
|
- query.le("DATE_FORMAT(cc.create_time,'%Y-%m')",dto.getEndTime());
|
|
|
+ query.ge("DATE_FORMAT(cc.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(cc.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
query.groupBy("cc.create_user");
|
|
|
query.orderByDesc("amount");
|
|
|
//查询销售国家统计信息
|
|
|
- List<ContractDto> contractDtoList = baseMapper.salesmanSalesStatistics(query);
|
|
|
+ List<ContractDto> contractDtoList = baseMapper.salesmanSalesStatistics(query);
|
|
|
return contractDtoList;
|
|
|
}
|
|
|
|
|
@@ -376,15 +403,38 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Override
|
|
|
public List<ContractDto> productSalesStatistics(ContractDto dto) {
|
|
|
QueryWrapper<Object> query = Wrappers.query();
|
|
|
- query.ge("DATE_FORMAT(cp.create_time,'%Y-%m')",dto.getBeginTime());
|
|
|
- query.le("DATE_FORMAT(cp.create_time,'%Y-%m')",dto.getEndTime());
|
|
|
+ query.ge("DATE_FORMAT(cp.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(cp.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
query.groupBy("cp.product_id");
|
|
|
query.orderByDesc("amount");
|
|
|
//查询销售国家统计信息
|
|
|
- List<ContractDto> contractDtoList = baseMapper.productSalesStatistics(query);
|
|
|
+ List<ContractDto> contractDtoList = baseMapper.productSalesStatistics(query);
|
|
|
return contractDtoList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 产品销售量统计(数据看板-销售分析页面开发)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ContractDto> salesVolumeStatistics(ContractDto dto) {
|
|
|
+ QueryWrapper<Object> query = Wrappers.query();
|
|
|
+ query.ge("DATE_FORMAT(cp.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(cp.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+ query.groupBy("cp.product_id");
|
|
|
+ query.orderByDesc("quantity");
|
|
|
+ //查询销售商品统计信息
|
|
|
+ List<ContractDto> contractDtoList = baseMapper.salesVolumeStatistics(query);
|
|
|
+ return contractDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合同交接单
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void contractHandover(ContractDto dto) {
|
|
|
+ ObsFileUtil.editFile(dto.getFileList(),dto.getId(),1);
|
|
|
+ ObsFileUtil.editFile(dto.getPackageFileList(),dto.getId(),2);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -593,6 +643,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
private void selectTime(QueryWrapper<Contract> query, ContractDto dto) {
|
|
|
query.ge("DATE_FORMAT(create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
query.le("DATE_FORMAT(create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+ //添加时间的查询条件
|
|
|
+ private void selectTime(QueryWrapper<Contract> query, ContractDto dto) {
|
|
|
+ query.ge("DATE_FORMAT(create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(create_time,'%Y-%m')", dto.getEndTime());
|
|
|
}
|
|
|
|
|
|
private void setAreaId(ContractDto contractDto) {
|