Jelajahi Sumber

公司产品库,客户产品库

yzc 2 tahun lalu
induk
melakukan
83d5549634

+ 9 - 3
hx-item/src/main/java/com/fjhx/item/entity/product/dto/ProductInfoSelectDto.java

@@ -48,7 +48,7 @@ public class ProductInfoSelectDto extends BaseSelectDto {
     /**
     /**
      * 数量
      * 数量
      */
      */
-    private  Integer count;
+    private Integer count;
 
 
     /**
     /**
      * 国家表ID
      * 国家表ID
@@ -58,12 +58,12 @@ public class ProductInfoSelectDto extends BaseSelectDto {
     /**
     /**
      * 排序(10 销售量排序  20 销售额排序  30 采购量排序  40 采购额排序  50 生产总量排序)
      * 排序(10 销售量排序  20 销售额排序  30 采购量排序  40 采购额排序  50 生产总量排序)
      */
      */
-    private  Integer sort;
+    private Integer sort;
 
 
     /**
     /**
      * 10 正序  20 倒序
      * 10 正序  20 倒序
      */
      */
-    private  Integer orderBy;
+    private Integer orderBy;
 
 
 
 
     /**
     /**
@@ -75,4 +75,10 @@ public class ProductInfoSelectDto extends BaseSelectDto {
      */
      */
     private String name;
     private String name;
 
 
+    /**
+     * 客户名称
+     */
+    private String customerName;
+
+
 }
 }

+ 54 - 50
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -16,9 +16,9 @@ import com.fjhx.customer.service.customer.CustomerService;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.item.entity.product.dto.ProductInfoDto;
 import com.fjhx.item.entity.product.dto.ProductInfoDto;
 import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
 import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
-import com.fjhx.item.entity.product.po.ProductInfoEhsdJson;
 import com.fjhx.item.entity.product.po.ProductClassify;
 import com.fjhx.item.entity.product.po.ProductClassify;
 import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.entity.product.po.ProductInfo;
+import com.fjhx.item.entity.product.po.ProductInfoEhsdJson;
 import com.fjhx.item.entity.product.vo.ProductInfoVo;
 import com.fjhx.item.entity.product.vo.ProductInfoVo;
 import com.fjhx.item.mapper.product.ProductInfoMapper;
 import com.fjhx.item.mapper.product.ProductInfoMapper;
 import com.fjhx.item.service.product.ProductClassifyService;
 import com.fjhx.item.service.product.ProductClassifyService;
@@ -184,6 +184,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         }
         }
         //根据产品分类id过滤
         //根据产品分类id过滤
         wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
         wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
+        //客户名称过滤
+        wrapper.like("c.name", dto.getCustomerName());
 
 
         Page<ProductInfoVo> page = baseMapper.getCustomerProductList(dto.getPage(), wrapper);
         Page<ProductInfoVo> page = baseMapper.getCustomerProductList(dto.getPage(), wrapper);
         List<ProductInfoVo> records = page.getRecords();
         List<ProductInfoVo> records = page.getRecords();
@@ -270,7 +272,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(productInfoDto.getEhsdJson(), ProductInfoEhsdJson.class);
         ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(productInfoDto.getEhsdJson(), ProductInfoEhsdJson.class);
         productInfoEhsdJson.setStatus(0);
         productInfoEhsdJson.setStatus(0);
         productInfoEhsdJson.setAssessStatus(3);
         productInfoEhsdJson.setAssessStatus(3);
-        if(ObjectUtil.isEmpty(productInfoEhsdJson.getCustomerId())){
+        if (ObjectUtil.isEmpty(productInfoEhsdJson.getCustomerId())) {
             //如果客户id为空就赋值为0 公司产品
             //如果客户id为空就赋值为0 公司产品
             productInfoEhsdJson.setCustomerId(0l);
             productInfoEhsdJson.setCustomerId(0l);
         }
         }
@@ -282,9 +284,9 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), "产品名称重复");
         this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), "产品名称重复");
         this.save(productInfoDto);
         this.save(productInfoDto);
         //图片列表
         //图片列表
-        ObsFileUtil.saveFile(productInfoDto.getImgList(), productInfoDto.getId(),1);
+        ObsFileUtil.saveFile(productInfoDto.getImgList(), productInfoDto.getId(), 1);
         //附件列表
         //附件列表
-        ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId(),2);
+        ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId(), 2);
     }
     }
 
 
     @DSTransactional
     @DSTransactional
@@ -295,8 +297,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         // 排除名称重复
         // 排除名称重复
         this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), productInfoDto.getId(), "产品名称重复");
         this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), productInfoDto.getId(), "产品名称重复");
         this.updateById(productInfoDto);
         this.updateById(productInfoDto);
-        ObsFileUtil.editFile(productInfoDto.getImgList(), productInfoDto.getId(),1);
-        ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId(),2);
+        ObsFileUtil.editFile(productInfoDto.getImgList(), productInfoDto.getId(), 1);
+        ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId(), 2);
     }
     }
 
 
     @Override
     @Override
@@ -384,19 +386,20 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
 
 
     /**
     /**
      * 产品统计(数据看板-产品分析页面)
      * 产品统计(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      * @param productInfoDto
      */
      */
     @Override
     @Override
     public Map<String, Object> productStatistics(ProductInfoDto productInfoDto) {
     public Map<String, Object> productStatistics(ProductInfoDto productInfoDto) {
         if (ObjectUtil.isEmpty(productInfoDto) && ObjectUtil.isEmpty(productInfoDto.getBeginTime())
         if (ObjectUtil.isEmpty(productInfoDto) && ObjectUtil.isEmpty(productInfoDto.getBeginTime())
-                && StringUtils.isNotEmpty(productInfoDto.getEndTime())){
-            throw  new ServiceException("参数缺失:开始时间,结束时间不能为null");
+                && StringUtils.isNotEmpty(productInfoDto.getEndTime())) {
+            throw new ServiceException("参数缺失:开始时间,结束时间不能为null");
         }
         }
         //存放产品统计数据
         //存放产品统计数据
-        Map map  =new HashMap();
+        Map map = new HashMap();
 
 
         //存放产品类型数据
         //存放产品类型数据
-        List<Map<String,Object>> typeList = new ArrayList<>();
+        List<Map<String, Object>> typeList = new ArrayList<>();
 
 
 
 
         QueryWrapper<ProductInfo> query = Wrappers.<ProductInfo>query();
         QueryWrapper<ProductInfo> query = Wrappers.<ProductInfo>query();
@@ -404,10 +407,10 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         query.groupBy("type");
         query.groupBy("type");
         //查询每个类型的总计
         //查询每个类型的总计
         List<ProductInfo> productInfos = baseMapper.selectList(query);
         List<ProductInfo> productInfos = baseMapper.selectList(query);
-        Map<String, List<ProductInfo>>  productInfoTotalMap= productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getType));
+        Map<String, List<ProductInfo>> productInfoTotalMap = productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getType));
 
 
-        query.ge("DATE_FORMAT(create_time,'%Y-%m-%d')",productInfoDto.getBeginTime());
-        query.le("DATE_FORMAT(create_time,'%Y-%m-%d')",productInfoDto.getEndTime());
+        query.ge("DATE_FORMAT(create_time,'%Y-%m-%d')", productInfoDto.getBeginTime());
+        query.le("DATE_FORMAT(create_time,'%Y-%m-%d')", productInfoDto.getEndTime());
         //查询每个类型的新增数量
         //查询每个类型的新增数量
         List<ProductInfo> productInfoList = baseMapper.selectList(query);
         List<ProductInfo> productInfoList = baseMapper.selectList(query);
         Map<String, List<ProductInfo>> productInfoTypeMap = productInfoList.stream().collect(Collectors.groupingBy(ProductInfo::getType));
         Map<String, List<ProductInfo>> productInfoTypeMap = productInfoList.stream().collect(Collectors.groupingBy(ProductInfo::getType));
@@ -416,53 +419,54 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         //总计
         //总计
         Integer total = productInfos.stream().map(ProductInfo::getCount).reduce(Integer::sum).orElse(0);
         Integer total = productInfos.stream().map(ProductInfo::getCount).reduce(Integer::sum).orElse(0);
 
 
-        map.put("newTotal",newTotal);
-        map.put("total",total);
+        map.put("newTotal", newTotal);
+        map.put("total", total);
 
 
         //获取产品类型的字典数据
         //获取产品类型的字典数据
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
         List<DictTenantDataVo> dictTenantDataVoList = getDict("product_type");
         List<DictTenantDataVo> dictTenantDataVoList = getDict("product_type");
         DynamicDataSourceContextHolder.poll();
         DynamicDataSourceContextHolder.poll();
 
 
-        if (ObjectUtil.isEmpty(dictTenantDataVoList)){
+        if (ObjectUtil.isEmpty(dictTenantDataVoList)) {
             return map;
             return map;
         }
         }
 
 
         for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
         for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
             //存放每个类型的新增与总计
             //存放每个类型的新增与总计
-            Map<String,Object> map1 = new HashMap<>();
+            Map<String, Object> map1 = new HashMap<>();
             //设置初使值
             //设置初使值
-            map1.put("type",dictTenantDataVo.getDictKey());
-            map1.put("typeNewTotal",0);
-            map1.put("typeTotal",0);
+            map1.put("type", dictTenantDataVo.getDictKey());
+            map1.put("typeNewTotal", 0);
+            map1.put("typeTotal", 0);
 
 
             //赋值新增的款数
             //赋值新增的款数
             List<ProductInfo> productInfoNewList = productInfoTypeMap.get(dictTenantDataVo.getDictKey());
             List<ProductInfo> productInfoNewList = productInfoTypeMap.get(dictTenantDataVo.getDictKey());
             if (ObjectUtil.isNotEmpty(productInfoNewList)) {
             if (ObjectUtil.isNotEmpty(productInfoNewList)) {
-                map1.put("typeNewTotal",productInfoNewList.get(0).getCount());
+                map1.put("typeNewTotal", productInfoNewList.get(0).getCount());
             }
             }
 
 
             //赋值类型总计
             //赋值类型总计
             List<ProductInfo> productInfoTotalList = productInfoTotalMap.get(dictTenantDataVo.getDictKey());
             List<ProductInfo> productInfoTotalList = productInfoTotalMap.get(dictTenantDataVo.getDictKey());
-            if (ObjectUtil.isNotEmpty(productInfoTotalList)){
-                map1.put("typeTotal",productInfoTotalList.get(0).getCount());
+            if (ObjectUtil.isNotEmpty(productInfoTotalList)) {
+                map1.put("typeTotal", productInfoTotalList.get(0).getCount());
             }
             }
             typeList.add(map1);
             typeList.add(map1);
         }
         }
-        map.put("typeList",typeList);
+        map.put("typeList", typeList);
 
 
         return map;
         return map;
     }
     }
 
 
     /**
     /**
      * 产品分布(数据看板-产品分析页面)
      * 产品分布(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      * @param productInfoDto
      */
      */
     @Override
     @Override
     public List<ProductInfo> productDistribution(ProductInfoDto productInfoDto) {
     public List<ProductInfo> productDistribution(ProductInfoDto productInfoDto) {
         if (ObjectUtil.isEmpty(productInfoDto) && ObjectUtil.isEmpty(productInfoDto.getBeginTime())
         if (ObjectUtil.isEmpty(productInfoDto) && ObjectUtil.isEmpty(productInfoDto.getBeginTime())
-                && StringUtils.isNotEmpty(productInfoDto.getEndTime())){
-            throw  new ServiceException("参数缺失:开始时间,结束时间不能为null");
+                && StringUtils.isNotEmpty(productInfoDto.getEndTime())) {
+            throw new ServiceException("参数缺失:开始时间,结束时间不能为null");
         }
         }
         QueryWrapper<ProductInfo> query = Wrappers.<ProductInfo>query();
         QueryWrapper<ProductInfo> query = Wrappers.<ProductInfo>query();
         query.select("count(*) count,type");
         query.select("count(*) count,type");
@@ -474,41 +478,41 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
 
 
     /**
     /**
      * 产品类型排行(数据看板-产品分析页面)
      * 产品类型排行(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      * @param productInfoDto
      */
      */
     @Override
     @Override
     public Page<ProductInfoVo> productTypeRanking(ProductInfoSelectDto productInfoDto) {
     public Page<ProductInfoVo> productTypeRanking(ProductInfoSelectDto productInfoDto) {
         QueryWrapper<Object> query = Wrappers.query();
         QueryWrapper<Object> query = Wrappers.query();
-        query.ge("DATE_FORMAT(pc.create_time,'%Y-%m-%d')",productInfoDto.getBeginTime());
-        query.le("DATE_FORMAT(pc.create_time,'%Y-%m-%d')",productInfoDto.getEndTime());
-        query.eq(ObjectUtil.isNotEmpty(productInfoDto.getCountryId()),"bc.buy_country_id",productInfoDto.getCountryId());
-        sort(query,productInfoDto);
+        query.ge("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", productInfoDto.getBeginTime());
+        query.le("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", productInfoDto.getEndTime());
+        query.eq(ObjectUtil.isNotEmpty(productInfoDto.getCountryId()), "bc.buy_country_id", productInfoDto.getCountryId());
+        sort(query, productInfoDto);
         query.groupBy("pi.type");
         query.groupBy("pi.type");
-        Page<ProductInfoVo> productInfoVos = baseMapper.productTypeRanking(productInfoDto.getPage(),query);
+        Page<ProductInfoVo> productInfoVos = baseMapper.productTypeRanking(productInfoDto.getPage(), query);
         return productInfoVos;
         return productInfoVos;
     }
     }
 
 
     /**
     /**
      * 产品排行(数据看板-产品分析页面)
      * 产品排行(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      * @param productInfoDto
      */
      */
     @Override
     @Override
     public Page<ProductInfoVo> productRanking(ProductInfoSelectDto productInfoDto) {
     public Page<ProductInfoVo> productRanking(ProductInfoSelectDto productInfoDto) {
         QueryWrapper<Object> query = Wrappers.query();
         QueryWrapper<Object> query = Wrappers.query();
-        query.ge("DATE_FORMAT(pc.create_time,'%Y-%m-%d')",productInfoDto.getBeginTime());
-        query.le("DATE_FORMAT(pc.create_time,'%Y-%m-%d')",productInfoDto.getEndTime());
-        query.eq(ObjectUtil.isNotEmpty(productInfoDto.getCountryId()),"bc.buy_country_id",productInfoDto.getCountryId());
-        sort(query,productInfoDto);
+        query.ge("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", productInfoDto.getBeginTime());
+        query.le("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", productInfoDto.getEndTime());
+        query.eq(ObjectUtil.isNotEmpty(productInfoDto.getCountryId()), "bc.buy_country_id", productInfoDto.getCountryId());
+        sort(query, productInfoDto);
         query.groupBy("pi.name");
         query.groupBy("pi.name");
-        Page<ProductInfoVo> productInfoVos = baseMapper.productRanking(productInfoDto.getPage(),query);
+        Page<ProductInfoVo> productInfoVos = baseMapper.productRanking(productInfoDto.getPage(), query);
         return productInfoVos;
         return productInfoVos;
     }
     }
 
 
 
 
-
-
     //根据字典编码获取字典的数据
     //根据字典编码获取字典的数据
-    private List<DictTenantDataVo> getDict(String code){
+    private List<DictTenantDataVo> getDict(String code) {
         DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
         DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
         dto.setDictCode(code);
         dto.setDictCode(code);
         List<DictTenantDataVo> dictTenantDataServiceList = dictTenantDataService.getList(dto);
         List<DictTenantDataVo> dictTenantDataServiceList = dictTenantDataService.getList(dto);
@@ -516,17 +520,17 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
     }
     }
 
 
     //排序(添加排序条件)
     //排序(添加排序条件)
-    private void sort( QueryWrapper<Object> query,ProductInfoSelectDto productInfoDto){
-        if (productInfoDto.getOrderBy() ==10){//正序
-            query.orderByAsc(productInfoDto.getSort() ==10,"contractQuantity");
-            query.orderByAsc(productInfoDto.getSort() ==20,"contractAmount");
-            query.orderByAsc(productInfoDto.getSort() ==30,"purchaseQuantity");
-            query.orderByAsc(productInfoDto.getSort() ==40,"purchaseAmount");
-        }else if (productInfoDto.getOrderBy() == 20){//倒序
-            query.orderByDesc(productInfoDto.getSort() ==10,"contractQuantity");
-            query.orderByDesc(productInfoDto.getSort() ==20,"contractAmount");
-            query.orderByDesc(productInfoDto.getSort() ==30,"purchaseQuantity");
-            query.orderByDesc(productInfoDto.getSort() ==40,"purchaseAmount");
+    private void sort(QueryWrapper<Object> query, ProductInfoSelectDto productInfoDto) {
+        if (productInfoDto.getOrderBy() == 10) {//正序
+            query.orderByAsc(productInfoDto.getSort() == 10, "contractQuantity");
+            query.orderByAsc(productInfoDto.getSort() == 20, "contractAmount");
+            query.orderByAsc(productInfoDto.getSort() == 30, "purchaseQuantity");
+            query.orderByAsc(productInfoDto.getSort() == 40, "purchaseAmount");
+        } else if (productInfoDto.getOrderBy() == 20) {//倒序
+            query.orderByDesc(productInfoDto.getSort() == 10, "contractQuantity");
+            query.orderByDesc(productInfoDto.getSort() == 20, "contractAmount");
+            query.orderByDesc(productInfoDto.getSort() == 30, "purchaseQuantity");
+            query.orderByDesc(productInfoDto.getSort() == 40, "purchaseAmount");
         }
         }
     }
     }
 
 

+ 3 - 1
hx-item/src/main/resources/mapper/product/ProductInfoMapper.xml

@@ -98,9 +98,11 @@
                pi.create_time,
                pi.create_time,
                pi.update_user,
                pi.update_user,
                pi.update_time,
                pi.update_time,
-               pi.ehsd_json
+               pi.ehsd_json,
+               c.`name` customerName
         FROM product_info pi
         FROM product_info pi
                  LEFT JOIN product_classify pc ON pi.product_classify_id = pc.id
                  LEFT JOIN product_classify pc ON pi.product_classify_id = pc.id
+                 LEFT JOIN bytesailing_customer.customer c ON json_unquote(pi.ehsd_json - > '$.customerId') = c.id
             ${ew.customSqlSegment}
             ${ew.customSqlSegment}
     </select>
     </select>
 </mapper>
 </mapper>