yzc hai 1 ano
pai
achega
097ef0b34b

+ 20 - 0
hx-form/src/main/java/com/fjhx/form/controller/StatisticsController.java

@@ -1,11 +1,14 @@
 package com.fjhx.form.controller;
 
 import com.fjhx.form.service.StatisticsService;
+import com.fjhx.sale.entity.contract.vo.ContractVo;
+import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 
@@ -26,4 +29,21 @@ public class StatisticsController {
         return statisticsService.workStatistics();
     }
 
+    /**
+     * 合同近7天出货列表
+     */
+    @GetMapping("/getRecentContractShipmentList")
+    List<ContractVo> getRecentContractShipmentList() {
+        return statisticsService.getRecentContractShipmentList();
+    }
+
+    /**
+     * 采购近7天到货列表
+     */
+    @GetMapping("/getRecentPurchaseArrivalList")
+    List<EhsdPurchaseVo> getRecentPurchaseArrivalList() {
+        return statisticsService.getRecentPurchaseArrivalList();
+    }
+
+
 }

+ 18 - 0
hx-form/src/main/java/com/fjhx/form/mapper/StatisticsMapper.java

@@ -0,0 +1,18 @@
+package com.fjhx.form.mapper;
+
+import com.fjhx.sale.entity.contract.vo.ContractVo;
+import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface StatisticsMapper {
+
+    List<ContractVo> getRecentContractShipmentList(@Param("ew") IWrapper<Object> wrapper);
+
+    List<EhsdPurchaseVo> getRecentPurchaseArrivalList(@Param("ew") IWrapper<Object> wrapper);
+
+}

+ 14 - 0
hx-form/src/main/java/com/fjhx/form/service/StatisticsService.java

@@ -1,5 +1,9 @@
 package com.fjhx.form.service;
 
+import com.fjhx.sale.entity.contract.vo.ContractVo;
+import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
+
+import java.util.List;
 import java.util.Map;
 
 public interface StatisticsService {
@@ -8,4 +12,14 @@ public interface StatisticsService {
      * 工作统计
      */
     Map<String, Long> workStatistics();
+
+    /**
+     * 合同近7天出货列表
+     */
+    List<ContractVo> getRecentContractShipmentList();
+
+    /**
+     * 近7天采购待到货数据
+     */
+    List<EhsdPurchaseVo> getRecentPurchaseArrivalList();
 }

+ 46 - 8
hx-form/src/main/java/com/fjhx/form/service/impl/StatisticsServiceImpl.java

@@ -8,8 +8,10 @@ import com.fjhx.account.entity.account.po.AccountRunningWater;
 import com.fjhx.account.service.account.AccountPaymentService;
 import com.fjhx.account.service.account.AccountRunningWaterService;
 import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.customer.service.customer.CustomerService;
 import com.fjhx.flow.entity.flow.po.FlowExample;
 import com.fjhx.flow.service.flow.FlowExampleService;
+import com.fjhx.form.mapper.StatisticsMapper;
 import com.fjhx.form.service.StatisticsService;
 import com.fjhx.mail.entity.enterprise.po.EnterpriseMailbox;
 import com.fjhx.mail.entity.enterprise.po.EnterpriseMessage;
@@ -21,19 +23,22 @@ import com.fjhx.mail.service.personal.PersonalMailboxService;
 import com.fjhx.mail.service.personal.PersonalMessageService;
 import com.fjhx.purchase.entity.subscribe.po.SubscribeDetail;
 import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
+import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.contract.po.ContractProduct;
+import com.fjhx.sale.entity.contract.vo.ContractVo;
+import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
 import com.fjhx.sale.entity.sample.po.Sample;
 import com.fjhx.sale.mapper.contract.ContractProductMapper;
 import com.fjhx.sale.mapper.sample.SampleMapper;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class StatisticsServiceImpl implements StatisticsService {
@@ -57,6 +62,10 @@ public class StatisticsServiceImpl implements StatisticsService {
     private ContractProductMapper contractProductMapper;
     @Autowired
     private AccountPaymentService accountPaymentService;
+    @Autowired
+    private CustomerService customerService;
+    @Autowired
+    private StatisticsMapper statisticsMapper;
 
     /**
      * 工作统计
@@ -94,16 +103,12 @@ public class StatisticsServiceImpl implements StatisticsService {
         IWrapper<Sample> wrapper = IWrapper.getWrapper();
         wrapper.eq("t2.`status`", 30);
         wrapper.ge("t1.expend_quantity", 0);
-//        DynamicDataSourceContextHolder.push(SourceConstant.SALE);
         long sampleHandoverCount = sampleMapper.sampleHandoverList(page, wrapper).getTotal();
-//        DynamicDataSourceContextHolder.poll();
         //合同样品单
         IWrapper<ContractProduct> wrapper1 = IWrapper.getWrapper();
         wrapper.eq("t2.`status`", 30);
         wrapper.ge("t1.expend_quantity", 0);
-//        DynamicDataSourceContextHolder.push(SourceConstant.SALE);
         long contractHandoverCount = contractProductMapper.contractHandoverPage(page, wrapper1).getTotal();
-//        DynamicDataSourceContextHolder.poll();
         //待打款
         long waitAccountPayCount = accountPaymentService.count(q -> q.ne(AccountPayment::getStatus, 10));
 
@@ -124,4 +129,37 @@ public class StatisticsServiceImpl implements StatisticsService {
 
         return map;
     }
+
+    @Override
+    public List<ContractVo> getRecentContractShipmentList() {
+        IWrapper<Object> wrapper = IWrapper.getWrapper();
+
+        //不是业务员看所有
+
+
+        SysUser sysUser = UserUtil.getUserInfo();
+        if (StringUtils.isNotEmpty(sysUser.getUserCode())) {
+            //是业务员
+            List<Long> authIdList = customerService.getAuthIdList();
+            if (authIdList.size() == 0) {
+                return new ArrayList<>();
+            }
+            wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
+        }
+        wrapper.ge("DATEDIFF(t1.shipment_time,NOW())", 0);
+        wrapper.le("DATEDIFF(t1.shipment_time,NOW())", 7);
+        wrapper.apply("t1.sumPackQuantity<t1.quantity");
+        List<ContractVo> contractSaitShipmentList = statisticsMapper.getRecentContractShipmentList(wrapper);
+        return contractSaitShipmentList;
+    }
+
+    @Override
+    public List<EhsdPurchaseVo> getRecentPurchaseArrivalList() {
+        IWrapper<Object> wrapper = IWrapper.getWrapper();
+        wrapper.ge("DATEDIFF(pa.arrival_time,NOW())", 0);
+        wrapper.le("DATEDIFF(pa.arrival_time,NOW())", 7);
+        wrapper.eq("p.status", 30);
+        List<EhsdPurchaseVo> contractSaitShipmentList = statisticsMapper.getRecentPurchaseArrivalList(wrapper);
+        return contractSaitShipmentList;
+    }
 }

+ 32 - 0
hx-form/src/main/resources/mapper/StatisticsMapper.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.form.mapper.StatisticsMapper">
+
+    <select id="getRecentContractShipmentList" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
+        SELECT *
+        FROM (SELECT c.id,
+                     c.code,
+                     c.buy_corporation_id,
+                     cs.shipment_time,
+                     cs.quantity,
+                     IFNULL(SUM(pd.pack_quantity * pdp.quantity), 0) AS sumPackQuantity
+              FROM contract c
+                       JOIN contract_shipment cs ON cs.contract_id = c.id
+                       LEFT JOIN pack_detail_product pdp ON pdp.contract_id = c.id
+                  AND pdp.product_id = cs.product_id
+                       LEFT JOIN pack_detail pd ON pdp.pack_detail_id = pd.id
+              WHERE c.`status` = 30
+              GROUP BY c.id) t1
+            ${ew.customSqlSegment}
+    </select>
+    <select id="getRecentPurchaseArrivalList" resultType="com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo">
+        SELECT p.id,
+               p.`code`,
+               pa.arrival_time,
+               p.flow_id,
+               p.data_resource
+        FROM ehsd_purchase p
+                 JOIN ehsd_purchase_arrival pa ON pa.purchase_id = p.id
+            ${ew.customSqlSegment}
+    </select>
+</mapper>