|
@@ -3,7 +3,10 @@ package com.fjhx.purchase.service.subscribe.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
@@ -18,19 +21,22 @@ import com.fjhx.purchase.entity.subscribe.vo.SubscribeDetailVo;
|
|
|
import com.fjhx.purchase.mapper.subscribe.SubscribeDetailMapper;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
|
import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
|
+import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
+import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
+import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
import com.fjhx.wms.entity.warehouse.po.Warehouse;
|
|
|
import com.fjhx.wms.service.warehouse.WarehouseService;
|
|
|
import com.obs.services.internal.ServiceException;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.poi.util.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -54,6 +60,9 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
@Autowired
|
|
|
PurchaseDetailService purchaseDetailService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DictTenantDataService dictTenantDataService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页
|
|
|
*
|
|
@@ -63,12 +72,24 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
@Override
|
|
|
public Page<SubscribeDetailVo> getPage(SubscribeDetailSelectDto dto) {
|
|
|
IWrapper<SubscribeDetail> wrapper = getWrapper();
|
|
|
+ //申购单号
|
|
|
+ wrapper.like(StringUtils.isEmpty(dto.getCode()),"t2.code",dto.getCode());
|
|
|
+
|
|
|
+ //申购时间
|
|
|
+ wrapper.ge(ObjectUtil.isNotEmpty(dto.getBeginTime()),"t2.create_time",dto.getBeginTime());
|
|
|
+ wrapper.ge(ObjectUtil.isNotEmpty(dto.getEndTime()),"t2.create_time",dto.getEndTime());
|
|
|
+ wrapper.ge(ObjectUtil.isNotEmpty(dto.getSubscribeStatus()),"t2.subcribe_status",dto.getSubscribeStatus());
|
|
|
+
|
|
|
if (ObjectUtil.isNotEmpty(dto.getStatus())) {
|
|
|
wrapper.in("t1", SubscribeDetail::getStatus, Arrays.asList(dto.getStatus().split(",")));
|
|
|
}
|
|
|
|
|
|
// 如果类型存在带入类型查询
|
|
|
- List<ProductInfoVo> productList = productInfoService.getListByProductType(dto.getProductType(), dto.getDefinition());
|
|
|
+ List<ProductInfoVo> productList = productInfoService.getListByProductType(dto.getProductType(),
|
|
|
+ dto.getDefinition(),
|
|
|
+ dto.getProductName(),
|
|
|
+ dto.getProductCode()
|
|
|
+ );
|
|
|
if (ObjectUtil.isEmpty(productList)) {
|
|
|
return new Page<>();
|
|
|
}
|
|
@@ -228,4 +249,65 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 申购统计(申购单分页)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> subscribeStatistics(SubscribeDetailSelectDto dto) {
|
|
|
+ //存放申购统计数据
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ //存放申购统计详情数据
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<Object> query = Wrappers.query();
|
|
|
+ query.groupBy("pi.type");
|
|
|
+ //查询申购统计(产品类型分组)
|
|
|
+ List<SubscribeDetailVo> subscribeDetailVos = baseMapper.subscribeStatistics(query);
|
|
|
+ Map<String, List<SubscribeDetailVo>> subscribeDetailVoMap = subscribeDetailVos.stream()
|
|
|
+ .collect(Collectors.groupingBy(SubscribeDetailVo::getType));
|
|
|
+
|
|
|
+ //计算申购笔合计数据
|
|
|
+ Integer amount = subscribeDetailVos.stream().map(SubscribeDetailVo::getCounts).reduce(Integer::sum).orElse(0);
|
|
|
+ map.put("amount",amount);
|
|
|
+ //计算申购货品种类合计数据
|
|
|
+ Integer typeAmount = subscribeDetailVos.stream().map(SubscribeDetailVo::getTypeCount).reduce(Integer::sum).orElse(0);
|
|
|
+ map.put("typeAmount",typeAmount);
|
|
|
+ //切换数据源
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ //获取产品类型字典数据
|
|
|
+ List<DictTenantDataVo> dictTenantDataVoList = getDict("product_type");
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(dictTenantDataVoList)){
|
|
|
+ throw new ServiceException("数据有误:产品没有配置产品类型字典,请先添加产品类型字典");
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值笔数、货品种类数据
|
|
|
+ for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
|
|
|
+ //设置初始值
|
|
|
+ Map<String,Object> typeMap = new HashMap<>();
|
|
|
+ typeMap.put("type",dictTenantDataVo.getDictValue());
|
|
|
+ typeMap.put("count",0);
|
|
|
+ typeMap.put("typeCount",0);
|
|
|
+
|
|
|
+ //赋值
|
|
|
+ List<SubscribeDetailVo> subscribeDetailVoList = subscribeDetailVoMap.get(dictTenantDataVo.getDictKey());
|
|
|
+ if (ObjectUtil.isNotEmpty(subscribeDetailVoList)){
|
|
|
+ typeMap.put("count",subscribeDetailVoList.get(0).getCounts());
|
|
|
+ typeMap.put("typeCount",subscribeDetailVoList.get(0).getTypeCount());
|
|
|
+ }
|
|
|
+ list.add(typeMap);
|
|
|
+ }
|
|
|
+ map.put("productTypeList",list);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据字典编码获取字典的数据
|
|
|
+ private List<DictTenantDataVo> getDict(String code){
|
|
|
+ DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|
|
|
+ dto.setDictCode(code);
|
|
|
+ return dictTenantDataService.getList(dto);
|
|
|
+ }
|
|
|
+
|
|
|
}
|