Explorar o código

Merge remote-tracking branch 'origin/master'

caozj hai 1 ano
pai
achega
e906394d75

+ 1 - 2
hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountPaymentServiceImpl.java

@@ -24,7 +24,6 @@ import com.fjhx.account.service.account.AccountRunningWaterService;
 import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.file.utils.ObsFileUtil;
-import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.system.service.ISysDeptService;
@@ -75,7 +74,7 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
         // 归属部门
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getDepartmentId()), "ap.department_id", dto.getDepartmentId());
         // 申请人
-        wrapper.eq(ObjectUtil.isNotEmpty(dto.getCreateUser()), "ap.create_user", dto.getCreateUser());
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getCreateUser()), "ap.data_user", dto.getCreateUser());
         // 打款类型
         wrapper.eq(ObjectUtil.isNotEmpty(dto.getType()), "ap.type", dto.getType());
         // 请款时间

+ 2 - 0
hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountRequestFundsServiceImpl.java

@@ -20,6 +20,7 @@ import com.fjhx.account.service.account.AccountRequestFundsService;
 import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.entity.corporation.po.Corporation;
 import com.fjhx.common.service.corporation.CorporationService;
+import com.fjhx.common.utils.Assert;
 import com.fjhx.flow.entity.flow.po.FlowExample;
 import com.fjhx.flow.service.flow.FlowExampleService;
 import com.ruoyi.common.core.domain.BasePo;
@@ -154,6 +155,7 @@ public class AccountRequestFundsServiceImpl extends ServiceImpl<AccountRequestFu
     @Override
     public AccountRequestFundsVo detail(Long id) {
         AccountRequestFunds accountRequestFunds = this.getById(id);
+        Assert.notEmpty(accountRequestFunds, "查询不到请款信息");
         AccountRequestFundsVo accountRequestFundsVo = BeanUtil.toBean(accountRequestFunds, AccountRequestFundsVo.class);
 
         // 获取到请款明细信息

+ 10 - 0
hx-item/src/main/java/com/fjhx/item/controller/product/ProductInfoController.java

@@ -206,6 +206,16 @@ public class ProductInfoController {
     }
 
     /**
+     * 产品类型排行(数据看板-产品分析页面)
+     *
+     * @param productInfoDto
+     */
+    @PostMapping("/productClassifyRanking")
+    public List<Map<String, Object>> productTypeRankingByClassify(@RequestBody ProductInfoSelectDto productInfoDto) {
+        return productInfoService.productClassifyRanking(productInfoDto);
+    }
+
+    /**
      * 产品排行(数据看板-产品分析页面)
      *
      * @param productInfoDto

+ 5 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/vo/ProductInfoVo.java

@@ -55,4 +55,9 @@ public class ProductInfoVo extends ProductInfo {
      * 产品分类列表树
      */
     private String productClassifyNames;
+
+    /**
+     * 产品父id列表
+     */
+    private String parentIdSet;
 }

+ 11 - 2
hx-item/src/main/java/com/fjhx/item/service/product/ProductInfoService.java

@@ -129,16 +129,25 @@ public interface ProductInfoService extends BaseService<ProductInfo> {
      * 产品分布(数据看板-产品分析页面)
      * @param productInfoDto
      */
-    List<Map<String,Object>> productDistribution(ProductInfoDto productInfoDto);
+    List<Map<String, Object>> productDistribution(ProductInfoDto productInfoDto);
 
     /**
      * 产品类型排行(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      */
-    List<Map<String,Object>> productTypeRanking(ProductInfoSelectDto productInfoDto);
+    List<Map<String, Object>> productTypeRanking(ProductInfoSelectDto productInfoDto);
+
+    /**
+     * 产品顶级分类排行(数据看板-产品分析页面)
+     *
+     * @param productInfoDto
+     */
+    List<Map<String, Object>> productClassifyRanking(ProductInfoSelectDto productInfoDto);
 
     /**
      * 产品排行(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      */
     Page<ProductInfoVo> productRanking(ProductInfoSelectDto productInfoDto);

+ 86 - 28
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -181,7 +181,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
             //将部门id转为字符串(帮助解决前端问题)
             json.put("deptId", json.getString("deptId"));
 
-            record.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
+            record.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         }
 
         return page;
@@ -239,7 +239,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
                 ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
                 String customerName = customerMap.get(Long.parseLong(productInfoEhsdJson.getCustomerId()));
                 productInfoEhsdJson.setCustomerName(customerName);
-                record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
+                record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
             }
         }
         //赋值创建人名称
@@ -260,27 +260,27 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         //赋值维多利亚组合产品信息
         JSONObject json = JSONObject.parseObject(result.getVictoriatouristJson());
         List<Long> ids = new ArrayList<>();
-        if(ObjectUtil.isNotEmpty(json) && ObjectUtil.isNotEmpty(json.getJSONArray("productCombinationList"))){
+        if (ObjectUtil.isNotEmpty(json) && ObjectUtil.isNotEmpty(json.getJSONArray("productCombinationList"))) {
             JSONArray productCombinationList = json.getJSONArray("productCombinationList");
-            for (int i=0;i<productCombinationList.size();i++) {
+            for (int i = 0; i < productCombinationList.size(); i++) {
                 JSONObject item = productCombinationList.getJSONObject(i);
                 ids.add(item.getLong("linkProductId"));
             }
-            if(ObjectUtil.isNotEmpty(ids)){
+            if (ObjectUtil.isNotEmpty(ids)) {
                 List<ProductInfo> productInfoList = this.listByIds(ids);
                 Map<Long, ProductInfo> productInfoMap = productInfoList.stream().collect(Collectors.toMap(ProductInfo::getId, Function.identity()));
                 JSONArray jsonArray = new JSONArray();
-                for (int i=0;i<productCombinationList.size();i++) {
+                for (int i = 0; i < productCombinationList.size(); i++) {
                     JSONObject item = productCombinationList.getJSONObject(i);
                     ProductInfo productInfo1 = productInfoMap.get(item.getLong("linkProductId"));
-                    if(ObjectUtil.isNotEmpty(productInfo1)) {
-                        item.put("code",productInfo1.getCode());
-                        item.put("customCode",productInfo1.getCustomCode());
-                        item.put("name",productInfo1.getName());
+                    if (ObjectUtil.isNotEmpty(productInfo1)) {
+                        item.put("code", productInfo1.getCode());
+                        item.put("customCode", productInfo1.getCustomCode());
+                        item.put("name", productInfo1.getName());
                     }
                     jsonArray.add(item);
                 }
-                json.put("productCombinationList",jsonArray);
+                json.put("productCombinationList", jsonArray);
                 result.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
             }
         }
@@ -326,7 +326,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
             productInfoEhsdJson.setCustomerId("0");
             productInfoEhsdJson.setType("1");//默认公司产品
         }
-        productInfoDto.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
+        productInfoDto.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
 
         // 赋值产品编号
         productInfoDto.setCode(CodeEnum.PRODUCT.getCode());
@@ -351,7 +351,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         productInfoEhsdJson.setCostPrice(newProductInfoEhsdJson.getCostPrice());//成本价
         productInfoEhsdJson.setNetWeight(newProductInfoEhsdJson.getNetWeight());//净重
         productInfo.setRemark(productInfoDto.getRemark());//备注
-        productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
+        productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
         this.updateById(productInfo);
         //修改图片
         ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
@@ -369,7 +369,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
             Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
             if (ObjectUtil.isNotEmpty(customer)) {
                 productInfoEhsdJson.setCustomerName(customer.getName());
-                result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
+                result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
             }
         }
         //赋值创建人名称
@@ -440,7 +440,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
                 }
                 productInfoEhsdJson.setOuterPackMethod(String.join(",", split));
             }
-            productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
+            productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
             productInfoList.add(productInfo);
         }
         saveBatch(productInfoList);
@@ -454,7 +454,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         if (ObjectUtil.isNotEmpty(victoriatouristJson)) {
             JSONObject json = JSONObject.parseObject(victoriatouristJson);
             json.put("deptId", SecurityUtils.getDeptId());
-            productInfoDto.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
+            productInfoDto.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         }
         add(productInfoDto);
     }
@@ -510,8 +510,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
      * @return
      */
     @Override
-    public List<ProductInfoVo> getListByProductType(Integer productType, Integer definition,String productName,String productCode) {
-        return baseMapper.getListByProductType(productType, definition,productName,productCode);
+    public List<ProductInfoVo> getListByProductType(Integer productType, Integer definition, String productName, String productCode) {
+        return baseMapper.getListByProductType(productType, definition, productName, productCode);
     }
 
     @Override
@@ -525,7 +525,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         String victoriatouristJson = productInfo.getVictoriatouristJson();
         JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
         json.put("deptId", productInfoDto.getDeptId());
-        productInfo.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
+        productInfo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         updateById(productInfo);
     }
 
@@ -706,6 +706,63 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         return list;
     }
 
+    /**
+     * 产品分类排行(数据看板-产品分析页面)
+     *
+     * @param productInfoDto
+     */
+    @Override
+    public List<Map<String, Object>> productClassifyRanking(ProductInfoSelectDto productInfoDto) {
+        //存放产品类型排行数据
+        List<Map<String, Object>> list = new ArrayList<>();
+
+        QueryWrapper<Object> query = Wrappers.query();
+        String beginTime = DateUtil.format(productInfoDto.getBeginTime(), "yyyy-MM-dd");
+        String endTime = DateUtil.format(productInfoDto.getEndTime(), "yyyy-MM-dd");
+        query.ge("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", beginTime);
+        query.le("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", endTime);
+        query.eq(ObjectUtil.isNotEmpty(productInfoDto.getCountryId()), "bc.buy_country_id", productInfoDto.getCountryId());
+        query.groupBy("pi.id");
+        //查询产品类型排行数据
+        List<ProductInfoVo> productInfoVos = baseMapper.productTypeRanking(query);
+        if (productInfoVos.size() == 0) {
+            return list;
+        }
+
+        //获取所有产品分类
+        List<ProductClassify> productClassifyList = productClassifyService.list();
+        //获取顶级分类
+        List<ProductClassify> topProductClassifyList = productClassifyList.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList());
+
+        //赋值
+        for (ProductClassify productClassify : topProductClassifyList) {
+            //初始化
+            Map<String, Object> map = new HashMap<>();
+            map.put("name", productClassify.getName());
+            map.put("contractAmount", new BigDecimal(0));
+            map.put("contractQuantity", new BigDecimal(0));
+            map.put("purchaseAmount", new BigDecimal(0));
+            map.put("purchaseQuantity", new BigDecimal(0));
+            //赋值
+            List<ProductInfoVo> productInfoVos1 = productInfoVos.stream().filter(item ->
+                    item.getProductClassifyId().equals(productClassify.getId())
+                            || (ObjectUtil.isEmpty(item.getParentIdSet()) ? "0" : item.getParentIdSet()).contains(productClassify.getId().toString())
+            ).collect(Collectors.toList());
+            if (ObjectUtil.isNotEmpty(productInfoVos1)) {
+                map.put("contractAmount", productInfoVos1.get(0).getContractAmount());
+                map.put("contractQuantity", productInfoVos1.get(0).getContractQuantity());
+                map.put("purchaseAmount", productInfoVos1.get(0).getPurchaseAmount());
+                map.put("purchaseQuantity", productInfoVos1.get(0).getPurchaseQuantity());
+            }
+            list.add(map);
+        }
+        if (ObjectUtil.isNotEmpty(list)) {
+            //排序
+            list = typeSort(list, productInfoDto);
+        }
+        return list;
+    }
+
 
     /**
      * 产品排行(数据看板-产品分析页面)
@@ -728,6 +785,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
 
     /**
      * 产品统计
+     *
      * @return
      */
     @Override
@@ -739,9 +797,9 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
      * 产品库统计(根据产品库类型进行分类统计)
      */
     @Override
-    public  Map<String,Object> productInfoStatistics(ProductInfoSelectDto dto) {
+    public Map<String, Object> productInfoStatistics(ProductInfoSelectDto dto) {
         //存放产品库统计数据
-        Map<String,Object> map = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
 
         //存放产品分类统计数据
         List<Map<String, Object>> list = new ArrayList<>();
@@ -754,30 +812,30 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         //计算统计合计
         Integer amount = productInfos.stream().map(productInfo -> productInfo.getCount()).reduce(Integer::sum).orElse(0);
 
-        map.put("amount",amount);
+        map.put("amount", amount);
         //获取产品类型统计数据
         DynamicDataSourceContextHolder.push(SourceConstant.BASE);
         List<DictTenantDataVo> dictTenantDataVoList = getDict("product_type");
         DynamicDataSourceContextHolder.poll();
-        if (dictTenantDataVoList.size()==0){
+        if (dictTenantDataVoList.size() == 0) {
             throw new ServiceException("数据异常:产品没有设置产品类型字典,请先添加");
         }
 
         for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
             Map typeMap = new HashMap();
             //设置初始值
-            typeMap.put("type",dictTenantDataVo.getDictValue());
-            typeMap.put("count",0);
+            typeMap.put("type", dictTenantDataVo.getDictValue());
+            typeMap.put("count", 0);
 
             //赋值
             List<ProductInfo> productInfoList = productInfoMap.get(dictTenantDataVo.getDictKey());
-            if (CollectionUtils.isNotEmpty(productInfoList)){
-                typeMap.put("count",productInfoList.get(0).getCount());
+            if (CollectionUtils.isNotEmpty(productInfoList)) {
+                typeMap.put("count", productInfoList.get(0).getCount());
             }
             list.add(typeMap);
 
         }
-        map.put("typeList",list);
+        map.put("typeList", list);
         return map;
     }
 

+ 12 - 11
hx-item/src/main/resources/mapper/product/ProductInfoMapper.xml

@@ -68,17 +68,18 @@
         </where>
     </select>
     <select id="productTypeRanking" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
-        SELECT
-            pi.type type,
-            ifnull(SUM(pc.amount),0) contractAmount,
-            ifnull(SUM(pc.quantity),0) contractQuantity,
-            ifnull(sum(pd.amount),0) purchaseAmount,
-            IFNULL(SUM(pd.count),0) purchaseQuantity
-        FROM
-            product_info pi
-                LEFT JOIN bytesailing_sale.contract_product pc ON pi.id = pc.product_id
-                left join bytesailing_sale.contract bc on pc.contract_id = bc.id
-                left join bytesailing_purchase.purchase_detail pd on pi.id = pd.bussiness_id
+        SELECT pi.type                             type,
+               pi.product_classify_id,
+               pic.parent_id_set,
+               ifnull(SUM(pc.amount * bc.rate), 0) contractAmount,
+               ifnull(SUM(pc.quantity), 0)         contractQuantity,
+               ifnull(sum(pd.amount), 0)           purchaseAmount,
+               IFNULL(SUM(pd.count), 0)            purchaseQuantity
+        FROM product_info pi
+                 LEFT JOIN bytesailing_sale.contract_product pc ON pi.id = pc.product_id
+                 LEFT JOIN bytesailing_sale.contract bc ON pc.contract_id = bc.id
+                 LEFT JOIN bytesailing_purchase.purchase_detail pd ON pi.id = pd.bussiness_id
+                 LEFT JOIN product_classify pic ON pi.product_classify_id = pic.id
             ${ew.customSqlSegment}
     </select>
     <select id="productRanking" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">

+ 23 - 19
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -159,36 +159,38 @@
                arw.create_time,
                ap.type,
                arw.currency,
-               arw.amount,
-               arw.remarks,
+               pad.money          amount,
+               pad.remark         remarks,
                am.`name`          accountManagementName,
                am.account_opening accountManagementOpening,
                arw.`name`
         FROM contract c
-                 JOIN bytesailing_purchase.purchase p ON p.data_resource_id = c.id
-                 JOIN bytesailing_purchase.pay_detail pad
-        ON pad.purchase_id = p.id
-            JOIN bytesailing_purchase.pay pa ON pad.pay_id = pa.id
-            JOIN bytesailing_account.account_payment ap ON ap.business_id = pa.id
-            JOIN bytesailing_account.account_running_water arw ON arw.business_id = ap.id
-            LEFT JOIN bytesailing_account.account_management am ON arw.account_management_id = am.id
-        WHERE
-            c.id = #{contractId}
+                 JOIN bytesailing_purchase.purchase p ON p.data_resource_id = c.id AND p.del_flag = 0
+                 JOIN bytesailing_purchase.pay_detail `pad` ON pad.purchase_id = p.id AND pad.del_flag = 0
+                 JOIN bytesailing_purchase.pay pa ON pad.pay_id = pa.id AND pa.del_flag = 0
+                 JOIN bytesailing_account.account_payment ap ON ap.business_id = pa.id AND ap.del_flag = 0
+                 JOIN bytesailing_account.account_running_water arw ON arw.business_id = ap.id AND arw.del_flag = 0
+                 LEFT JOIN bytesailing_account.account_management am
+                           ON arw.account_management_id = am.id AND am.del_flag = 0
+        WHERE c.id = #{contractId}
         UNION ALL
         SELECT arw.id,
                arw.create_time,
                ap.type,
                arw.currency,
-               arw.amount,
-               arw.remarks,
+               arfd.amount,
+               arfd.remarks,
                am.`name`          accountManagementName,
                am.account_opening accountManagementOpening,
                arw.`name`
         FROM contract c
-                 JOIN bytesailing_account.account_request_funds_detail arfd ON arfd.contract_id = c.id
-                 JOIN bytesailing_account.account_payment ap ON ap.business_id = arfd.account_request_funds_id
-                 JOIN bytesailing_account.account_running_water arw ON arw.business_id = ap.id
-                 LEFT JOIN bytesailing_account.account_management am ON arw.account_management_id = am.id
+                 JOIN bytesailing_account.account_request_funds_detail arfd
+                      ON arfd.contract_id = c.id AND arfd.del_flag = 0
+                 JOIN bytesailing_account.account_payment ap
+                      ON ap.business_id = arfd.account_request_funds_id AND ap.del_flag = 0
+                 JOIN bytesailing_account.account_running_water arw ON arw.business_id = ap.id AND arw.del_flag = 0
+                 LEFT JOIN bytesailing_account.account_management am
+                           ON arw.account_management_id = am.id AND am.del_flag = 0
         WHERE c.id = #{contractId}
         UNION ALL
         SELECT arw.id,
@@ -204,8 +206,10 @@
                  JOIN claim cl ON cl.business_id = arw.id
                  JOIN claim_contract clc ON clc.claim_id = cl.id
                  JOIN contract c ON clc.contract_id = c.id
-                 LEFT JOIN bytesailing_account.account_management am ON arw.account_management_id = am.id
-        WHERE c.id = #{contractId}
+                 LEFT JOIN bytesailing_account.account_management am
+                           ON arw.account_management_id = am.id AND am.del_flag = 0
+        WHERE arw.del_flag = 0
+          AND c.id = #{contractId}
     </select>
 
 </mapper>