From 55dffef68aa4c67ab0ca4c2832ac34b9a7671755 Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期三, 13 八月 2025 14:11:57 +0800
Subject: [PATCH] 新增定时任务

---
 service/src/main/java/com/ruoyi/cwgl/domain/EstimatedReceivableBill.java                    |    4 
 service/src/main/java/com/ruoyi/cwgl/domain/PendingSettlementBusiness.java                  |   16 +++
 service/src/main/java/com/ruoyi/cwgl/mapper/PendingSettlementBusinessMapper.java            |    4 
 service/src/main/java/com/ruoyi/cwgl/controller/PendingSettlementBusinessController.java    |   35 +++++++
 service/src/main/java/com/ruoyi/cwgl/domain/vo/CreateBillVo.java                            |   32 ++++++
 service/src/main/java/com/ruoyi/cwgl/service/impl/PendingSettlementBusinessServiceImpl.java |  154 ++++++++++++++++++++++++++++++
 service/src/main/resources/mapper/cwgl/PendingSettlementBusinessMapper.xml                  |   28 +++++
 service/src/main/java/com/ruoyi/cwgl/mapper/EstimatedReceivableMapper.java                  |    1 
 service/src/main/java/com/ruoyi/cwgl/service/IPendingSettlementBusinessService.java         |   11 ++
 9 files changed, 277 insertions(+), 8 deletions(-)

diff --git a/service/src/main/java/com/ruoyi/cwgl/controller/PendingSettlementBusinessController.java b/service/src/main/java/com/ruoyi/cwgl/controller/PendingSettlementBusinessController.java
index 47c07c8..377d8a6 100644
--- a/service/src/main/java/com/ruoyi/cwgl/controller/PendingSettlementBusinessController.java
+++ b/service/src/main/java/com/ruoyi/cwgl/controller/PendingSettlementBusinessController.java
@@ -1,6 +1,8 @@
 package com.ruoyi.cwgl.controller;
 
 import java.util.List;
+
+import com.ruoyi.cwgl.domain.vo.CreateBillVo;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -105,4 +107,37 @@
     {
         return toAjax(pendingSettlementBusinessService.deletePendingSettlementBusinessByIds(ids));
     }
+    /**
+     * 鏌ヨ鍏ヨ处涓氬姟
+     */
+	@GetMapping("bill/{ids}")
+    public AjaxResult billIds(@PathVariable Integer[] ids)
+    {
+        return AjaxResult.success(pendingSettlementBusinessService.billIds(ids));
+    }
+    /**
+     * 鏌ヨ鍏ヨ处涓氬姟
+     */
+	@GetMapping("bill/list")
+    public AjaxResult billList(PendingSettlementBusiness pendingSettlementBusiness)
+    {
+        return AjaxResult.success(pendingSettlementBusinessService.billList(pendingSettlementBusiness));
+    }
+
+    @GetMapping("create/bill/{ids}")
+    public AjaxResult createBillIds(@PathVariable Integer[] ids, @RequestBody CreateBillVo createBillVo)
+    {
+        return toAjax(pendingSettlementBusinessService.createBillIds(ids,createBillVo));
+    }
+    @GetMapping("create/bill/list")
+    public AjaxResult createBillList(PendingSettlementBusiness pendingSettlementBusiness)
+    {
+        return toAjax(pendingSettlementBusinessService.createBillList(pendingSettlementBusiness));
+    }
+    @GetMapping("select/customName")
+    public AjaxResult selectCustomName()
+    {
+        return AjaxResult.success(pendingSettlementBusinessService.selectCustomName());
+    }
+
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/EstimatedReceivableBill.java b/service/src/main/java/com/ruoyi/cwgl/domain/EstimatedReceivableBill.java
index baa150c..f59a7f5 100644
--- a/service/src/main/java/com/ruoyi/cwgl/domain/EstimatedReceivableBill.java
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/EstimatedReceivableBill.java
@@ -54,14 +54,14 @@
     @Excel(name = "搴旂粨绠楅噾棰�")
 
         @TableField("total_amount")
-    private BigDecimal totalAmount;
+    private Long totalAmount;
 
 
     /** 宸茬粨绠楅噾棰� */
     @Excel(name = "宸茬粨绠楅噾棰�")
 
         @TableField("settled_amount")
-    private BigDecimal settledAmount;
+    private Long settledAmount;
 
 
     /** 寮�绁ㄧ姸鎬� */
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/PendingSettlementBusiness.java b/service/src/main/java/com/ruoyi/cwgl/domain/PendingSettlementBusiness.java
index 6f580d0..35c804f 100644
--- a/service/src/main/java/com/ruoyi/cwgl/domain/PendingSettlementBusiness.java
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/PendingSettlementBusiness.java
@@ -364,6 +364,22 @@
         /**涓氬姟id淇敼鐢�*/
         @TableField(exist = false)
      private Integer serviceId;
+    /**
+     * 鏄惁鐢熸垚杩囧叆璐�0鍚�1鏄�
+     */
+    @TableField("is_create")
+    private Integer isCreate;
+    /**
+     * 鍏宠仈璐﹀崟id
+     */
+    @TableField("bill_id")
+    private Integer billId;
+
+    /**
+     * 鍏宠仈璐﹀崟id
+     */
+    @TableField("bill_name")
+    private String billName;
 
     public String getActualDepartureTimeBegin() {
         return actualDepartureTimeBegin;
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/vo/CreateBillVo.java b/service/src/main/java/com/ruoyi/cwgl/domain/vo/CreateBillVo.java
new file mode 100644
index 0000000..5637e5c
--- /dev/null
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/vo/CreateBillVo.java
@@ -0,0 +1,32 @@
+package com.ruoyi.cwgl.domain.vo;
+
+
+import lombok.Data;
+
+/**
+ * 鍒涘缓璐﹀崟vo
+ */
+@Data
+public class CreateBillVo {
+
+    /**
+     * 璐﹀崟鍚嶇О
+     */
+    private String billName;
+
+
+    /**
+     * 瀹㈡埛鍚嶇О
+     */
+    private String customerName;
+
+    /**
+     * 璐﹀崟鏁伴噺
+     */
+    private Integer count;
+
+    /**
+     * 缁撶畻閲戦
+     */
+    private Long price;
+}
diff --git a/service/src/main/java/com/ruoyi/cwgl/mapper/EstimatedReceivableMapper.java b/service/src/main/java/com/ruoyi/cwgl/mapper/EstimatedReceivableMapper.java
index 362fbcc..2bd95e1 100644
--- a/service/src/main/java/com/ruoyi/cwgl/mapper/EstimatedReceivableMapper.java
+++ b/service/src/main/java/com/ruoyi/cwgl/mapper/EstimatedReceivableMapper.java
@@ -3,6 +3,7 @@
 import java.util.List;
 import com.ruoyi.cwgl.domain.EstimatedReceivable;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 
 /**
diff --git a/service/src/main/java/com/ruoyi/cwgl/mapper/PendingSettlementBusinessMapper.java b/service/src/main/java/com/ruoyi/cwgl/mapper/PendingSettlementBusinessMapper.java
index 985b908..c2ed53c 100644
--- a/service/src/main/java/com/ruoyi/cwgl/mapper/PendingSettlementBusinessMapper.java
+++ b/service/src/main/java/com/ruoyi/cwgl/mapper/PendingSettlementBusinessMapper.java
@@ -4,6 +4,7 @@
 import com.ruoyi.cwgl.domain.PendingSettlementBusiness;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.cwgl.domain.ReceivableLineTruckPriceRule;
+import org.apache.ibatis.annotations.Param;
 
 
 /**
@@ -97,4 +98,7 @@
 
     List<ReceivableLineTruckPriceRule> selectPayableLineTruckPriceRule();
 
+    int updatePendingSettlementBusinessIsCreate(@Param("list") List<String> list,@Param("id")Integer id,@Param("billName")String billName);
+
+    List<String> selectCustomName();
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/IPendingSettlementBusinessService.java b/service/src/main/java/com/ruoyi/cwgl/service/IPendingSettlementBusinessService.java
index 54d2454..5d54f33 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/IPendingSettlementBusinessService.java
+++ b/service/src/main/java/com/ruoyi/cwgl/service/IPendingSettlementBusinessService.java
@@ -4,6 +4,7 @@
 import com.ruoyi.cwgl.domain.PendingSettlementBusiness;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.cwgl.domain.ReceivableLineTruckPriceRule;
+import com.ruoyi.cwgl.domain.vo.CreateBillVo;
 
 /**
  * 寰呭叆璐︿笟鍔ervice鎺ュ彛
@@ -130,4 +131,14 @@
      * @return
      */
     List<ReceivableLineTruckPriceRule> selectPayableLineTruckPriceRule();
+
+    CreateBillVo billIds(Integer[] ids);
+
+    int createBillIds(Integer[] ids, CreateBillVo createBillVo);
+
+    CreateBillVo billList(PendingSettlementBusiness pendingSettlementBusiness);
+
+    int createBillList(PendingSettlementBusiness pendingSettlementBusiness);
+
+    List<String> selectCustomName();
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/PendingSettlementBusinessServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/PendingSettlementBusinessServiceImpl.java
index e174d1a..5aeaa3e 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/impl/PendingSettlementBusinessServiceImpl.java
+++ b/service/src/main/java/com/ruoyi/cwgl/service/impl/PendingSettlementBusinessServiceImpl.java
@@ -1,18 +1,29 @@
 package com.ruoyi.cwgl.service.impl;
 
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
 
 import cn.hutool.core.collection.CollectionUtil;
-import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.*;
+
 import javax.annotation.Resource;
 
+import com.ruoyi.cwgl.domain.EstimatedReceivableBill;
 import com.ruoyi.cwgl.domain.ReceivableLineTruckPriceRule;
+import com.ruoyi.cwgl.domain.vo.CreateBillVo;
+import com.ruoyi.cwgl.mapper.EstimatedReceivableBillMapper;
+import com.ruoyi.cwgl.mapper.EstimatedReceivableMapper;
+import com.ruoyi.cwgl.service.IEstimatedReceivableBillService;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.stereotype.Service;
 import org.springframework.scheduling.annotation.Async;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
@@ -36,7 +47,10 @@
     protected final Logger logger = LoggerFactory.getLogger(getClass());
     @Resource
     private PendingSettlementBusinessMapper pendingSettlementBusinessMapper;
-
+    @Resource
+    private EstimatedReceivableBillMapper estimatedReceivableBillMapper;
+    @Resource
+    private EstimatedReceivableMapper estimatedReceivableMapper;
 
     /**
      * 鏌ヨ寰呭叆璐︿笟鍔�
@@ -223,4 +237,138 @@
     public List<ReceivableLineTruckPriceRule> selectPayableLineTruckPriceRule() {
         return pendingSettlementBusinessMapper.selectPayableLineTruckPriceRule();
     }
+
+    @Override
+    public CreateBillVo billIds(Integer[] ids) {
+        List<PendingSettlementBusiness> pendingSettlementBusinesses = pendingSettlementBusinessMapper.selectBatchIds(Arrays.asList(ids));
+        if (CollectionUtil.isEmpty(pendingSettlementBusinesses)){
+            throw new ServiceException("璐﹀崟涓嶅瓨鍦�");
+        }
+        CreateBillVo createBillVo = new CreateBillVo();
+        String customerName = pendingSettlementBusinesses.get(0).getCustomerName();
+        createBillVo.setCustomerName(customerName);
+        createBillVo.setCount(pendingSettlementBusinesses.size());
+        long priceTotal = 0L;
+        for (PendingSettlementBusiness pendingSettlementBusiness : pendingSettlementBusinesses) {
+            if (pendingSettlementBusiness.getIsCreate().equals(1)){
+                throw new ServiceException(pendingSettlementBusiness.getDispatchNo()+"宸插叆璐�");
+
+            }
+                if (!pendingSettlementBusiness.getCustomerName().equals(customerName)){
+                    throw new ServiceException("鍙兘閫夋嫨鐩稿悓瀹㈡埛鍚嶇О鐨勬暟鎹�");
+
+                }
+                priceTotal += pendingSettlementBusiness.getEstimatedTotalIncome()==null?0L:pendingSettlementBusiness.getEstimatedTotalIncome();
+        }
+        createBillVo.setPrice(priceTotal);
+        return createBillVo;
+    }
+
+    @Override
+    public CreateBillVo billList(PendingSettlementBusiness pendingSettlementBusiness) {
+        String customerName = pendingSettlementBusiness.getCustomerName();
+        if (StringUtils.isEmpty(customerName)){
+            throw new ServiceException("瀹㈡埛鍚嶇О涓嶈兘涓虹┖");
+        }
+        pendingSettlementBusiness.setIsCreate(0);
+        List<PendingSettlementBusiness> pendingSettlementBusinesses = pendingSettlementBusinessMapper.selectPendingSettlementBusinessList(pendingSettlementBusiness);
+        long priceTotal = pendingSettlementBusinesses.stream()
+                .mapToLong(b -> Optional.ofNullable(b.getEstimatedTotalIncome()).orElse(0L))
+                .sum();
+        CreateBillVo createBillVo = new CreateBillVo();
+        createBillVo.setCustomerName(customerName);
+        createBillVo.setCount(pendingSettlementBusinesses.size());
+        createBillVo.setPrice(priceTotal);
+        return createBillVo;
+    }
+
+    @Override
+    public int createBillIds(Integer[] ids, CreateBillVo createBillVo) {
+        String username = SecurityUtils.getUsername();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd");
+        Date date = new Date();
+        String datePart = dateFormat.format(date);
+        List<PendingSettlementBusiness> pendingSettlementBusinesses = pendingSettlementBusinessMapper.selectBatchIds(Arrays.asList(ids));
+        if (CollectionUtil.isEmpty(pendingSettlementBusinesses)){
+            throw new ServiceException("璐﹀崟涓嶅瓨鍦�");
+        }
+        for (PendingSettlementBusiness pendingSettlementBusiness : pendingSettlementBusinesses) {
+            if (pendingSettlementBusiness.getIsCreate().equals(1)){
+                throw new ServiceException(pendingSettlementBusiness.getDispatchNo()+"宸插叆璐�");
+
+            }
+            String customerName = pendingSettlementBusinesses.get(0).getCustomerName();
+
+            if (!pendingSettlementBusiness.getCustomerName().equals(customerName)){
+                throw new ServiceException("鍙兘閫夋嫨鐩稿悓瀹㈡埛鍚嶇О鐨勬暟鎹�");
+
+            }
+        }
+        //璋冨害鍗曢泦鍚�
+        List<String> collect = pendingSettlementBusinesses.stream().map(PendingSettlementBusiness::getDispatchNo).collect(Collectors.toList());
+        EstimatedReceivableBill estimatedReceivableBill = new EstimatedReceivableBill();
+        estimatedReceivableBill.setCreateTime(date);
+        estimatedReceivableBill.setBillSystemNo("ZD"+datePart+RandomUtils.random(4));
+        estimatedReceivableBill.setBillName(createBillVo.getBillName());
+        estimatedReceivableBill.setCustomerName(createBillVo.getCustomerName());
+        estimatedReceivableBill.setDispatchCount(createBillVo.getCount());
+        estimatedReceivableBill.setTotalAmount(createBillVo.getPrice());
+        estimatedReceivableBill.setSettledAmount(0L);
+        estimatedReceivableBill.setInvoiceStatus(0);
+        estimatedReceivableBill.setStatus(0);
+        estimatedReceivableBill.setCreateBy(username);
+        estimatedReceivableBillMapper.insertEstimatedReceivableBill(estimatedReceivableBill);
+
+        //淇敼璋冨害鍗曚负宸插垱寤鸿处鍗�
+        return  pendingSettlementBusinessMapper.updatePendingSettlementBusinessIsCreate(collect,estimatedReceivableBill.getId(),createBillVo.getBillName());
+
+    }
+
+    @Override
+    public int createBillList(PendingSettlementBusiness pendingSettlementBusiness) {
+        String customerName = pendingSettlementBusiness.getCustomerName();
+        if (StringUtils.isEmpty(customerName)){
+            throw new ServiceException("瀹㈡埛鍚嶇О涓嶈兘涓虹┖");
+        }
+        String billName = pendingSettlementBusiness.getBillName();
+        if (StringUtils.isEmpty(billName)){
+            throw new ServiceException("璐﹀崟鍚嶇О涓嶈兘涓虹┖");
+        }
+        pendingSettlementBusiness.setIsCreate(0);
+        List<PendingSettlementBusiness> pendingSettlementBusinesses = pendingSettlementBusinessMapper.selectPendingSettlementBusinessList(pendingSettlementBusiness);
+        if (CollectionUtil.isEmpty(pendingSettlementBusinesses)){
+            throw new ServiceException("濉啓鐨勫鎴锋病鏈夎兘鍏ヨ处鏁版嵁");
+
+        }
+        String username = SecurityUtils.getUsername();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd");
+        Date date = new Date();
+        String datePart = dateFormat.format(date);
+
+        long priceTotal = pendingSettlementBusinesses.stream()
+                .mapToLong(b -> Optional.ofNullable(b.getEstimatedTotalIncome()).orElse(0L))
+                .sum();
+        //璋冨害鍗曢泦鍚�
+        List<String> collect = pendingSettlementBusinesses.stream().map(PendingSettlementBusiness::getDispatchNo).collect(Collectors.toList());
+        EstimatedReceivableBill estimatedReceivableBill = new EstimatedReceivableBill();
+        estimatedReceivableBill.setCreateTime(date);
+        estimatedReceivableBill.setBillSystemNo("ZD"+datePart+RandomUtils.random(4));
+        estimatedReceivableBill.setBillName(billName);
+        estimatedReceivableBill.setCustomerName(customerName);
+        estimatedReceivableBill.setDispatchCount(pendingSettlementBusinesses.size());
+        estimatedReceivableBill.setTotalAmount(priceTotal);
+        estimatedReceivableBill.setSettledAmount(0L);
+        estimatedReceivableBill.setInvoiceStatus(0);
+        estimatedReceivableBill.setStatus(0);
+        estimatedReceivableBill.setCreateBy(username);
+        estimatedReceivableBillMapper.insertEstimatedReceivableBill(estimatedReceivableBill);
+
+        //淇敼璋冨害鍗曚负宸插垱寤鸿处鍗�
+        return  pendingSettlementBusinessMapper.updatePendingSettlementBusinessIsCreate(collect,estimatedReceivableBill.getId(),billName);
+    }
+
+    @Override
+    public List<String> selectCustomName() {
+        return pendingSettlementBusinessMapper.selectCustomName();
+    }
 }
diff --git a/service/src/main/resources/mapper/cwgl/PendingSettlementBusinessMapper.xml b/service/src/main/resources/mapper/cwgl/PendingSettlementBusinessMapper.xml
index 8532055..1516884 100644
--- a/service/src/main/resources/mapper/cwgl/PendingSettlementBusinessMapper.xml
+++ b/service/src/main/resources/mapper/cwgl/PendingSettlementBusinessMapper.xml
@@ -53,10 +53,13 @@
         <result property="settlementStatus"    column="settlement_status"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="isCreate"    column="is_create"    />
+        <result property="billId"    column="bill_id"    />
+        <result property="billId"    column="bill_name"    />
     </resultMap>
 
     <sql id="selectPendingSettlementBusinessVo">
-        select thisTab.id, thisTab.booking_no, thisTab.customer_id, thisTab.carrier_id, thisTab.project_name, thisTab.dispatch_no, thisTab.created_time, thisTab.transport_mode, thisTab.product_id, thisTab.customer_name, thisTab.operation_mode, thisTab.carrier_name, thisTab.departure_location, thisTab.arrival_location, thisTab.vehicle_id, thisTab.license_plate_number, thisTab.vehicle_type, thisTab.main_driver, thisTab.assistant_driver, thisTab.point_num, thisTab.business_contact, thisTab.estimated_total_income, thisTab.estimated_total_cost, thisTab.estimated_profit, thisTab.electronic_lock, thisTab.re_weighing_weight, thisTab.quantity, thisTab.actual_departure_time, thisTab.required_arrival_time, thisTab.actual_arrival_time, thisTab.be_return, thisTab.dispatch_quantity, thisTab.dispatch_weight, thisTab.dispatch_volume, thisTab.empty_mileage, thisTab.empty_fuel, thisTab.heavy_mileage, thisTab.heavy_fuel, thisTab.be_scheduled, thisTab.tracking_no, thisTab.seal_no, thisTab.schedule_no, thisTab.transport_status, thisTab.estimated_bill_id, thisTab.settlement_bill_id, thisTab.settlement_status, thisTab.create_time, thisTab.update_time from pending_settlement_business AS thisTab
+        select thisTab.id, thisTab.booking_no, thisTab.customer_id, thisTab.carrier_id, thisTab.project_name, thisTab.dispatch_no, thisTab.created_time, thisTab.transport_mode, thisTab.product_id, thisTab.customer_name, thisTab.operation_mode, thisTab.carrier_name, thisTab.departure_location, thisTab.arrival_location, thisTab.vehicle_id, thisTab.license_plate_number, thisTab.vehicle_type, thisTab.main_driver, thisTab.assistant_driver, thisTab.point_num, thisTab.business_contact, thisTab.estimated_total_income, thisTab.estimated_total_cost, thisTab.estimated_profit, thisTab.electronic_lock, thisTab.re_weighing_weight, thisTab.quantity, thisTab.actual_departure_time, thisTab.required_arrival_time, thisTab.actual_arrival_time, thisTab.be_return, thisTab.dispatch_quantity, thisTab.dispatch_weight, thisTab.dispatch_volume, thisTab.empty_mileage, thisTab.empty_fuel, thisTab.heavy_mileage, thisTab.heavy_fuel, thisTab.be_scheduled, thisTab.tracking_no, thisTab.seal_no, thisTab.schedule_no, thisTab.transport_status, thisTab.estimated_bill_id, thisTab.settlement_bill_id, thisTab.settlement_status, thisTab.create_time, thisTab.update_time, thisTab.is_create, thisTab.bill_name from pending_settlement_business AS thisTab
     </sql>
     <sql id="selectPendingSettlementBusinessVoCount">
         select count(0) from pending_settlement_business as thisTab
@@ -98,6 +101,8 @@
         <if test="dispatchVolume != null "> and thisTab.dispatch_volume = #{dispatchVolume}</if>
         <if test="emptyMileage != null "> and thisTab.empty_mileage = #{emptyMileage}</if>
         <if test="emptyFuel != null "> and thisTab.empty_fuel = #{emptyFuel}</if>
+        <if test="isCreate != null "> and thisTab.is_create = #{isCreate}</if>
+        <if test="billId != null "> and thisTab.bill_id = #{billId}</if>
         <if test="heavyMileage != null "> and thisTab.heavy_mileage = #{heavyMileage}</if>
         <if test="heavyFuel != null "> and thisTab.heavy_fuel = #{heavyFuel}</if>
         <if test="beScheduled != null  and beScheduled != ''"> and thisTab.be_scheduled = #{beScheduled}</if>
@@ -265,6 +270,10 @@
 	rt.STATUS = 'ACTIVE'
 	AND rt.NAME = '搴斾粯绾胯矾鏁磋溅浠锋牸' and rtd.REFERENCE1='杩愯垂'
     </select>
+    <select id="selectCustomName" resultType="java.lang.String">
+        SELECT customer_name from pending_settlement_business group by customer_name
+
+    </select>
 
     <!-- 鏂板 -->
     <insert id="insertPendingSettlementBusiness" parameterType="com.ruoyi.cwgl.domain.PendingSettlementBusiness"  useGeneratedKeys="true" keyProperty="id">
@@ -317,6 +326,7 @@
             <if test="settlementStatus != null">settlement_status,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
+            <if test="isCreate != null">is_create,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="bookingNo != null">#{bookingNo},</if>
@@ -366,17 +376,18 @@
             <if test="settlementStatus != null">#{settlementStatus},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
+            <if test="isCreate != null">#{isCreate},</if>
          </trim>
     </insert>
 
     <insert id="insertPendingSettlementBusinessBatch" parameterType="java.util.List">
         insert into pending_settlement_business
         <trim prefix="(" suffix=") values" suffixOverrides=",">
-            booking_no,customer_id,carrier_id,project_name,dispatch_no,created_time,transport_mode,product_id,customer_name,operation_mode,carrier_name,departure_location,arrival_location,vehicle_id,license_plate_number,vehicle_type,main_driver,assistant_driver,point_num,business_contact,estimated_total_income,estimated_total_cost,estimated_profit,electronic_lock,re_weighing_weight,quantity,actual_departure_time,required_arrival_time,actual_arrival_time,be_return,dispatch_quantity,dispatch_weight,dispatch_volume,empty_mileage,empty_fuel,heavy_mileage,heavy_fuel,be_scheduled,tracking_no,seal_no,schedule_no,transport_status,estimated_bill_id,settlement_bill_id,settlement_status,create_time,update_time,
+            booking_no,customer_id,carrier_id,project_name,dispatch_no,created_time,transport_mode,product_id,customer_name,operation_mode,carrier_name,departure_location,arrival_location,vehicle_id,license_plate_number,vehicle_type,main_driver,assistant_driver,point_num,business_contact,estimated_total_income,estimated_total_cost,estimated_profit,electronic_lock,re_weighing_weight,quantity,actual_departure_time,required_arrival_time,actual_arrival_time,be_return,dispatch_quantity,dispatch_weight,dispatch_volume,empty_mileage,empty_fuel,heavy_mileage,heavy_fuel,be_scheduled,tracking_no,seal_no,schedule_no,transport_status,estimated_bill_id,settlement_bill_id,settlement_status,create_time,update_time,is_create,
         </trim>
         <foreach item="item" index="index" collection="list" separator=",">
             <trim prefix="(" suffix=") " suffixOverrides=",">
-                #{item.bookingNo},#{item.customerId},#{item.carrierId},#{item.projectName},#{item.dispatchNo},#{item.createdTime},#{item.transportMode},#{item.productId},#{item.customerName},#{item.operationMode},#{item.carrierName},#{item.departureLocation},#{item.arrivalLocation},#{item.vehicleId},#{item.licensePlateNumber},#{item.vehicleType},#{item.mainDriver},#{item.assistantDriver},#{item.pointNum},#{item.businessContact},#{item.estimatedTotalIncome},#{item.estimatedTotalCost},#{item.estimatedProfit},#{item.electronicLock},#{item.reWeighingWeight},#{item.quantity},#{item.actualDepartureTime},#{item.requiredArrivalTime},#{item.actualArrivalTime},#{item.beReturn},#{item.dispatchQuantity},#{item.dispatchWeight},#{item.dispatchVolume},#{item.emptyMileage},#{item.emptyFuel},#{item.heavyMileage},#{item.heavyFuel},#{item.beScheduled},#{item.trackingNo},#{item.sealNo},#{item.scheduleNo},#{item.transportStatus},#{item.estimatedBillId},#{item.settlementBillId},#{item.settlementStatus},#{item.createTime},#{item.updateTime},
+                #{item.bookingNo},#{item.customerId},#{item.carrierId},#{item.projectName},#{item.dispatchNo},#{item.createdTime},#{item.transportMode},#{item.productId},#{item.customerName},#{item.operationMode},#{item.carrierName},#{item.departureLocation},#{item.arrivalLocation},#{item.vehicleId},#{item.licensePlateNumber},#{item.vehicleType},#{item.mainDriver},#{item.assistantDriver},#{item.pointNum},#{item.businessContact},#{item.estimatedTotalIncome},#{item.estimatedTotalCost},#{item.estimatedProfit},#{item.electronicLock},#{item.reWeighingWeight},#{item.quantity},#{item.actualDepartureTime},#{item.requiredArrivalTime},#{item.actualArrivalTime},#{item.beReturn},#{item.dispatchQuantity},#{item.dispatchWeight},#{item.dispatchVolume},#{item.emptyMileage},#{item.emptyFuel},#{item.heavyMileage},#{item.heavyFuel},#{item.beScheduled},#{item.trackingNo},#{item.sealNo},#{item.scheduleNo},#{item.transportStatus},#{item.estimatedBillId},#{item.settlementBillId},#{item.settlementStatus},#{item.createTime},#{item.updateTime},#{item.isCreate},
             </trim>
         </foreach>
     </insert>
@@ -432,6 +443,7 @@
             <if test="settlementStatus != null">settlement_status = #{settlementStatus},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="isCreate != null">is_create = #{isCreate},</if>
         </trim>
         where id = #{id}
     </update>
@@ -487,6 +499,7 @@
                 <if test="item.settlementStatus != null">settlement_status = #{item.settlementStatus},</if>
                 <if test="item.createTime != null">create_time = #{item.createTime},</if>
                 <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
+                <if test="item.isCreate != null">is_create = #{item.isCreate},</if>
             </trim>
         where id = #{item.id}
         </foreach>
@@ -499,6 +512,15 @@
         </foreach>
 
     </update>
+    <update id="updatePendingSettlementBusinessIsCreate">
+
+        UPDATE pending_settlement_business
+        SET is_create = 1 ,bill_id = #{id},bill_name = #{billName}
+        WHERE dispatch_no IN
+        <foreach item="item" collection="list" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </update>
 
     <!--鍒犻櫎-->
     <delete id="deletePendingSettlementBusinessById" parameterType="Integer">

--
Gitblit v1.8.0