Browse Source

销售出库报表

zhangyuewww 3 years ago
parent
commit
310236c39c

+ 53 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/SalesDeliveryReportController.java

@@ -1,9 +1,11 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.SalesDeliveryReport;
+import com.yh.saas.plugin.yiliangyiyun.service.ISalesDeliveryReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -16,6 +18,54 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/salesDeliveryReport")
 public class SalesDeliveryReportController {
+    @Autowired
+    private ISalesDeliveryReportService salesDeliveryReportService;
+    /**
+     * 销售出库统计列表
+     * @param salesDeliveryReport
+     * @return
+     */
+    @GetMapping("/selectSalesDeliveryReport")
+    public Page<SalesDeliveryReport> selectPurchaseOrder(SalesDeliveryReport salesDeliveryReport){
+        return salesDeliveryReportService.selectSalesDeliveryReport(salesDeliveryReport);
+    }
+
+    /**
+     * 出纳收款
+     * @param salesDeliveryReport
+     * @return
+     */
+    @PostMapping("/api/collectMoney")
+    public String collectMoney(@RequestBody SalesDeliveryReport salesDeliveryReport){
+        return salesDeliveryReportService.collectMoney(salesDeliveryReport);
+    }
+    /**
+     * 开发票
+     * @param salesDeliveryReport
+     * @return
+     */
+    @PostMapping("/api/openInvoice")
+    public String openInvoice(@RequestBody SalesDeliveryReport salesDeliveryReport) {
+        return salesDeliveryReportService.openInvoice(salesDeliveryReport);
+    }
+    /**
+     * 批量开发票
+     * @param salesDeliveryReport
+     * @return
+     */
+    @PostMapping("/api/openInvoiceList")
+    public String openInvoiceList(@RequestBody SalesDeliveryReport salesDeliveryReport) {
+        return salesDeliveryReportService.openInvoiceList(salesDeliveryReport);
+    }
+    /**
+     * 最终结算价
+     * @param salesDeliveryReport
+     * @return
+     */
+    @PostMapping("/api/editSalesDeliveryReport")
+    public String editSalesDeliveryReport(@RequestBody SalesDeliveryReport salesDeliveryReport){
+        return salesDeliveryReportService.editSalesDeliveryReport(salesDeliveryReport);
+    }
 
 }
 

+ 20 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/SalesDeliveryReport.java

@@ -3,7 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.entity;
 import java.util.Date;
 import com.baomidou.mybatisplus.activerecord.Model;
 import java.io.Serializable;
+import java.util.List;
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.annotations.Version;
@@ -155,6 +157,24 @@ public class SalesDeliveryReport extends BaseModel<SalesDeliveryReport> {
      * 审核流id
      */
     private String workflowId;
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+    /**
+     *收款金额
+     */
+    @TableField(exist = false)
+    private Float money;
+
+    /**
+     *查询类型
+     */
+    @TableField(exist = false)
+    private String searchType;
+    @TableField(exist = false)
+    private List<SalesDeliveryReport> salesDeliveryReportList;
 
 
     @Override

+ 18 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/SalesDeliveryReportMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.SalesDeliveryReport;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 销售出库报表 Mapper 接口
@@ -12,5 +15,20 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  * @since 2021-08-05
  */
 public interface SalesDeliveryReportMapper extends BaseMapper<SalesDeliveryReport> {
+    /**
+     * 根据条件查询销售出库他统计总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询销售出库统计列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<SalesDeliveryReport> getListByCondition(Map<String, Object> pageView);
 
 }

+ 27 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/ISalesDeliveryReportService.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.SalesDeliveryReport;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -12,5 +13,31 @@ import com.baomidou.mybatisplus.service.IService;
  * @since 2021-08-05
  */
 public interface ISalesDeliveryReportService extends IService<SalesDeliveryReport> {
+    /**
+     * 销售出库统计列表
+     * @param salesDeliveryReport
+     */
+    Page<SalesDeliveryReport> selectSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport);
+    /**
+     * 出纳收款
+     * @param salesDeliveryReport
+     */
+    String collectMoney(SalesDeliveryReport salesDeliveryReport);
+    /**
+     * 开发票
+     * @param salesDeliveryReport
+     * @return
+     */
+    String openInvoice(SalesDeliveryReport salesDeliveryReport);
+    /**
+     * 批量开发票
+     * @param salesDeliveryReport
+     */
+    String openInvoiceList(SalesDeliveryReport salesDeliveryReport);
+    /**
+     * 最终结算价
+     * @param salesDeliveryReport
+     */
+    String editSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport);
 
 }

+ 160 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/SalesDeliveryReportServiceImpl.java

@@ -1,10 +1,27 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.alipay.sofa.runtime.api.annotation.SofaReference;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.winsea.svc.base.base.entity.CommonRoleResource;
+import com.winsea.svc.base.base.service.ICommonRoleResourceService;
+import com.winsea.svc.base.security.entity.User;
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.SalesDeliveryReport;
 import com.yh.saas.plugin.yiliangyiyun.mapper.SalesDeliveryReportMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.ISalesDeliveryReportService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.toolkit.workflow.service.IWorkflowService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -16,5 +33,148 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class SalesDeliveryReportServiceImpl extends ServiceImpl<SalesDeliveryReportMapper, SalesDeliveryReport> implements ISalesDeliveryReportService {
+    @Autowired
+    private IWorkflowService workflowService;
+    @SofaReference
+    private ICommonRoleResourceService roleResourceService;
+
+
+    /**
+     * 销售出库统计列表
+     * @param salesDeliveryReport
+     */
+    @Override
+    public Page<SalesDeliveryReport> selectSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (salesDeliveryReport.getCurrentPage() - 1)
+                * salesDeliveryReport.getPageSize());
+        List<String> businessKeys = null;
+        businessKeys = workflowService.getTaskBusinessKeysByCode("PURCHASE-RECEIPT-REPORT");
+        List<String> statusSet = new ArrayList<>();
+        List<String> resourceIdList = this.getResourceIdList();
+        if (resourceIdList.contains("PURCHAS")) { // 填写,提交    权限做完以后替换
+            List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
+            statusSet.addAll(statusList);
+        }
+
+        //公司id
+        pageView.put("compId", salesDeliveryReport.getCompId());
+        pageView.put("searchKeyWord", salesDeliveryReport.getSearchKeyWord());
+        pageView.put("searchType", salesDeliveryReport.getSearchType());
+        pageView.put("pageSize", salesDeliveryReport.getPageSize());
+        pageView.put("currentPage", salesDeliveryReport.getCurrentPage());
+        pageView.put("contractNo", salesDeliveryReport.getContractNo());
+        pageView.put("businessKeys", businessKeys);
+        pageView.put("statusSet", statusSet);
+
+
+        // 查询采购订单总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<SalesDeliveryReport> dataList = baseMapper.getListByCondition(pageView);
+        Page<SalesDeliveryReport> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(salesDeliveryReport.getCurrentPage());
+        page.setSize(salesDeliveryReport.getPageSize());
+        return page;
+    }
+
+    /**
+     * 出纳收款
+     * @param salesDeliveryReport
+     * @return
+     */
+    @Override
+    public String collectMoney(SalesDeliveryReport salesDeliveryReport) {
+        List<SalesDeliveryReport> salesDeliveryReportList=salesDeliveryReport.getSalesDeliveryReportList();
+        Float money = salesDeliveryReport.getMoney();
+        //收款多条
+        if (!CollectionUtils.isEmpty(salesDeliveryReportList)){
+            for (SalesDeliveryReport salesDeliveryReport1 : salesDeliveryReportList) {
+                //收款金额大于本次循环未收金额
+                if (money >= salesDeliveryReport1.getCollectionNotPayable()) {
+                    money=money-salesDeliveryReport1.getCollectionNotPayable();
+                    //全部收款
+                    salesDeliveryReport1.setStatus(StatusEnum.PUR_PAYaLL.getName());
+                    salesDeliveryReport1.setStatusFlag(StatusEnum.PUR_PAYaLL.getFlag());
+                    salesDeliveryReport1.setCollectionEdPayable(salesDeliveryReport1.getCollectionEdPayable()+salesDeliveryReport1.getCollectionNotPayable());
+                    salesDeliveryReport1.setCollectionNotPayable(0.0f);
+                    this.updateById(salesDeliveryReport1);
+                } else if (money> 0) {
+                    Float moneyTmp = money-salesDeliveryReport1.getCollectionNotPayable();
+                    //部分收款
+                    salesDeliveryReport1.setStatus(StatusEnum.PUR_PAY.getName());
+                    salesDeliveryReport1.setStatusFlag(StatusEnum.PUR_PAY.getFlag());
+                    salesDeliveryReport1.setCollectionEdPayable(salesDeliveryReport1.getCollectionEdPayable()+money);
+                    salesDeliveryReport1.setCollectionNotPayable(salesDeliveryReport1.getCollectionNotPayable()-money);
+                    this.updateById(salesDeliveryReport1);
+                    money=moneyTmp;
+                } else {
+                    break;
+                }
+            }
+        }
+        return "ok";
+    }
+
+    /**
+     * 开发票
+     * @param salesDeliveryReport
+     * @return
+     */
+    @Override
+    public String openInvoice(SalesDeliveryReport salesDeliveryReport) {
+        //查询销售出库报表
+        SalesDeliveryReport salesDeliveryReport1=this.selectById(salesDeliveryReport.getId());
+        if (salesDeliveryReport1 != null ){
+            //更改已开发票
+            salesDeliveryReport1.setAlreadyInvoice(salesDeliveryReport1.getAlreadyInvoice()+salesDeliveryReport1.getAlreadyInvoice());
+            //更改销售出库报表信息
+            this.updateById(salesDeliveryReport1);
+            return "OK";
+        }
+        return "NG";
+    }
+
+
+    /**
+     * 批量开发票
+     * @param salesDeliveryReport
+     * @return
+     */
+    @Override
+    public String openInvoiceList(SalesDeliveryReport salesDeliveryReport) {
+        List<SalesDeliveryReport> salesDeliveryReportList=salesDeliveryReport.getSalesDeliveryReportList();
+        //批量
+        if (!CollectionUtils.isEmpty(salesDeliveryReportList)){
+            for (SalesDeliveryReport salesDeliveryReport1 : salesDeliveryReportList) {
+                //已开发票金额等于已收金额
+                salesDeliveryReport1.setAlreadyInvoice(salesDeliveryReport1.getCollectionEdPayable());
+                this.updateById(salesDeliveryReport1);
+            }
+        }
+        return "ok";
+    }
+
+    /**
+     * 最终结算价
+     * @param salesDeliveryReport
+     */
+    @Override
+    public String editSalesDeliveryReport(SalesDeliveryReport salesDeliveryReport) {
+        boolean one = this.updateById(salesDeliveryReport);
+        if (one) {
+            return "OK";
+        } else {
+            return "NG";
+        }
+    }
+
+    private List<String> getResourceIdList() {
+        User currentUser = AuthSecurityUtils.getCurrentUserInfo();
+        // 当前登录人主要角色
+        return roleResourceService.getBindResourcesByUserId(currentUser.getUserId()).stream()
+                .map(CommonRoleResource::getResourceId).collect(Collectors.toList());
 
+    }
 }

+ 0 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/PurchaseReceiptReportMapper.xml

@@ -75,7 +75,6 @@
         basis_price as basisPrice,
         unloading_charge as unloading_charge,
         invoice_fee as invoiceFee,
-        replen,
         carry_forward as carryForward,
         status,
         status_flag as statusFlag,

+ 112 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/SalesDeliveryReportMapper.xml

@@ -1,5 +1,116 @@
 <?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.yh.saas.plugin.yiliangyiyun.mapper.SalesDeliveryReportMapper">
-
+    <!-- 获得销售出库统计总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM sales_delivery_report
+        WHERE
+        delete_flag = '0'
+        AND comp_id = #{compId}
+        <if test="businessKeys != null and businessKeys.size > 0">
+            and(
+            <foreach collection="businessKeys" item="businessValue" open="(" close=")" separator="or">
+                id = #{businessValue}
+            </foreach>
+            )
+        </if>
+        <if test="statusSet != null and statusSet.size > 0">
+            or (
+            <foreach collection="statusSet" item="statusId" separator="or" open="(" close=")">
+                t1.status_flag =
+                <if test="statusId != null">
+                    #{statusId}
+                </if>
+            </foreach>
+            )
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND status_flag = '1'
+            </if>
+            <if test="searchType == 2">
+                AND amount_ing_payable-amount_ed_payable>0
+            </if>
+            <if test="searchType == 3">
+                AND amount_ing_payable-amount_ed_payable=0
+            </if>
+        </if>
+        <if test="contractNo != null and contractNo != ''">
+            contract_no = #{contractNo}
+        </if>
+    </select>
+    <!-- 获得销售出库统计列表 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.SalesDeliveryReport">
+        SELECT
+        id,
+        comp_id as compId,
+        contract_no as contractNo,
+        goods_name as goodsName,
+        position_number as positionnumber,
+        tran_car_no as tranCarNo,
+        car_no as carNo,
+        retrieval_date as retrievalDate,
+        water_content as waterContent,
+        protein,
+        settlement_price as settlementPrice,
+        net_weight as netWeight,
+        collection_ing_payable as collectionIngPayable,
+        collection_ed_payable as collectionEdPayable,
+        collection_not_payable as collectionNotPayable,
+        collection_screenshot as collectionScreenshot,
+        collection_date as collectionDate,
+        already_invoice as alreadyInvoice,
+        customer_name as customerName,
+        warehouse_name  as warehouseName,
+        unit_price as unitPrice,
+        basis_price as basisPrice,
+        invoice_fee as invoiceFee,
+        status,
+        status_flag as statusFlag,
+        approve_status as approveStatus,
+        customer_confirmation_status_flag as customerConfirmationStatusFlag,
+        workflow_id as workflowId
+        FROM purchase_receipt_report
+        WHERE
+        delete_flag = '0'
+        AND comp_id = #{compId}
+        <if test="businessKeys != null and businessKeys.size > 0">
+            and(
+            <foreach collection="businessKeys" item="businessValue" open="(" close=")" separator="or">
+                id = #{businessValue}
+            </foreach>
+            )
+        </if>
+        <if test="statusSet != null and statusSet.size > 0">
+            or (
+            <foreach collection="statusSet" item="statusId" separator="or" open="(" close=")">
+                t1.status_flag =
+                <if test="statusId != null">
+                    #{statusId}
+                </if>
+            </foreach>
+            )
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND status_flag = '1'
+            </if>
+            <if test="searchType == 2">
+                AND amount_ing_payable-amount_ed_payable>0
+            </if>
+            <if test="searchType == 3">
+                AND amount_ing_payable-amount_ed_payable=0
+            </if>
+        </if>
+        <if test="contractNo != null and contractNo != ''">
+            contract_no = #{contractNo}
+        </if>
+        ORDER BY update_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>