Эх сурвалжийг харах

添加近7天销售合同到货,采购合同出货列表

yzc 1 жил өмнө
parent
commit
75ede3b4c8

+ 19 - 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,20 @@ 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();
 }

+ 50 - 4
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;
 
     /**
      * 工作统计
@@ -124,4 +133,41 @@ 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");
+        DynamicDataSourceContextHolder.push(SourceConstant.SALE);
+        List<ContractVo> contractSaitShipmentList = statisticsMapper.getRecentContractShipmentList(wrapper);
+        DynamicDataSourceContextHolder.poll();
+        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);
+        DynamicDataSourceContextHolder.push(SourceConstant.SALE);
+        List<EhsdPurchaseVo> contractSaitShipmentList = statisticsMapper.getRecentPurchaseArrivalList(wrapper);
+        DynamicDataSourceContextHolder.poll();
+        return contractSaitShipmentList;
+    }
 }

+ 0 - 0
hx-form/src/main/resources/mapper/EmployeeProductivityMapperMapper.xml → hx-form/src/main/resources/mapper/EmployeeProductivityMapper.xml


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

@@ -0,0 +1,30 @@
+<?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
+        FROM ehsd_purchase p
+                 JOIN ehsd_purchase_arrival pa ON pa.purchase_id = p.id
+            ${ew.customSqlSegment}
+    </select>
+</mapper>

+ 7 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/vo/ContractVo.java

@@ -1,5 +1,6 @@
 package com.fjhx.sale.entity.contract.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fjhx.file.entity.FileInfoVo;
 import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.contract.po.ContractProduct;
@@ -226,5 +227,11 @@ public class ContractVo extends Contract {
      */
     List<ContractBudgetVo.GrossProfitInfo> grossProfitInfoList;
 
+    /**
+     * 出货时间
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date shipmentTime;
+
 }
 

+ 8 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/purchase/vo/EhsdPurchaseVo.java

@@ -1,5 +1,6 @@
 package com.fjhx.sale.entity.purchase.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fjhx.sale.entity.contract.vo.ContractBudgetVo;
 import com.fjhx.sale.entity.pack.vo.PackDetailProductVo;
 import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
@@ -7,6 +8,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -90,4 +92,10 @@ public class EhsdPurchaseVo extends EhsdPurchase {
      * 历史毛利信息
      */
     List<ContractBudgetVo.GrossProfitInfo> grossProfitInfoList;
+
+    /**
+     * 到货时间
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date arrivalTime;
 }