Kaynağa Gözat

订单汇总

yzc 11 ay önce
ebeveyn
işleme
728adff937

+ 8 - 0
hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerController.java

@@ -138,4 +138,12 @@ public class CustomerController {
         customerService.exportExcel(dto, httpServletResponse);
     }
 
+    /**
+     * 修改客户简称
+     */
+    @PostMapping("/editShortName")
+    public void editShortName(@RequestBody CustomerDto customerDto) {
+        customerService.editShortName(customerDto);
+    }
+
 }

+ 3 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerService.java

@@ -62,6 +62,7 @@ public interface CustomerService extends BaseService<Customer> {
 
     /**
      * 来源增量(客户分析)
+     *
      * @param query
      * @return
      */
@@ -69,6 +70,8 @@ public interface CustomerService extends BaseService<Customer> {
 
     void editTag(CustomerDto customerDto);
 
+    void editShortName(CustomerDto customerDto);
+
     /**
      * 客户来源统计
      */

+ 6 - 4
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -335,8 +335,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
 
         // 修改客户表的信息
         this.updateById(customerDto);
-        // 删除客户-用户表的信息
-        customerUserService.remove(Wrappers.<CustomerUser>lambdaQuery().eq(CustomerUser::getCustomerId, customerDto.getId()));
         // 添加客户-联系人表的信息
         saveCustomerUse(customerDto);
 
@@ -386,8 +384,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
     private void saveCustomerUse(CustomerDto customerDto) {
         List<CustomerUser> customerUserDtoList = customerDto.getCustomerUserList();
         customerUserDtoList.forEach(customerUserDto -> customerUserDto.setCustomerId(customerDto.getId()));
-        customerUserDtoList.forEach(customerUserDto -> customerUserDto.setId(null));//防止传id过来导致key冲突
-        customerUserService.saveBatch(customerUserDtoList);
+        customerUserService.editLinked(customerUserDtoList, CustomerUser::getCustomerId, customerDto.getId());
     }
 
     /**
@@ -398,6 +395,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         this.updateById(customerDto);
     }
 
+    @Override
+    public void editShortName(CustomerDto customerDto) {
+        this.updateById(customerDto);
+    }
+
     /**
      * 客户来源统计
      */

+ 8 - 0
hx-form/src/main/java/com/fjhx/form/controller/ReportController.java

@@ -54,4 +54,12 @@ public class ReportController {
         return reportService.waitShipmentReport(dto);
     }
 
+    /**
+     * 订单汇总
+     */
+    @PostMapping("/orderSummary")
+    Page<OrderSummaryBo> orderSummary(@RequestBody OrderSummarySelectDto dto) {
+        return reportService.orderSummary(dto);
+    }
+
 }

+ 98 - 0
hx-form/src/main/java/com/fjhx/form/entity/OrderSummaryBo.java

@@ -0,0 +1,98 @@
+package com.fjhx.form.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Getter
+@Setter
+public class OrderSummaryBo extends BasePo {
+    /**
+     * 订单号
+     */
+    private String contractCode;
+    /**
+     * 业务员
+     */
+    private Long salesmanId;
+    private String salesmanName;
+    /**
+     * 跟单员
+     */
+    private Long merchUserId;
+    private String merchUserName;
+    /**
+     * 订单性质
+     */
+    private String belongType;
+    /**
+     * 销售金额
+     */
+    private BigDecimal amount;
+    /**
+     * 订单出货金额(工厂供货价)
+     */
+    private BigDecimal factoryAmount;
+    /**
+     * 出货申请金额(实际出货的工厂供货价)
+     */
+    private BigDecimal sumOutFactoryMoney;
+    /**
+     * 已收定金
+     */
+    private BigDecimal deposit;
+    /**
+     * 差额调整
+     */
+    private String difference;
+    /**
+     * 是否可结算
+     */
+    private String isSettlement;
+    /**
+     * 结算开始时间
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date settleStartDate;
+    /**
+     * 结算结束时间
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date settleEndDate;
+    /**
+     * 订单类型
+     */
+    private String contractType;
+
+    /**
+     * 客户名称
+     */
+    private String customerName;
+    private String customerShortName;
+    /**
+     * 应收金额
+     */
+    private BigDecimal receivableAmount;
+    /**
+     * 收款金额
+     */
+    private BigDecimal sumClaimMoney;
+    /**
+     * 未收金额
+     */
+    private BigDecimal outstandingAmount;
+    /**
+     * 出货日期(第一次出货)
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date firstTruckDate;
+
+    /**
+     * 账龄
+     */
+    private String accountAge;
+}

+ 16 - 0
hx-form/src/main/java/com/fjhx/form/entity/OrderSummarySelectDto.java

@@ -0,0 +1,16 @@
+package com.fjhx.form.entity;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+@Getter
+@Setter
+public class OrderSummarySelectDto extends BaseSelectDto {
+
+    private Date accountAgeDate;
+
+    private String accountAge;
+}

+ 3 - 4
hx-form/src/main/java/com/fjhx/form/mapper/ReportMapper.java

@@ -1,10 +1,7 @@
 package com.fjhx.form.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.form.entity.ProductionReportBo;
-import com.fjhx.form.entity.SaleReportBo;
-import com.fjhx.form.entity.WaitShipmentReportBo;
-import com.fjhx.form.entity.WaitShipmentReportStatisticBo;
+import com.fjhx.form.entity.*;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -21,4 +18,6 @@ public interface ReportMapper {
     Page<WaitShipmentReportBo> waitShipmentReport(@Param("page") Page<Object> page, @Param("ew") IWrapper<Object> wrapper);
 
     List<WaitShipmentReportStatisticBo> waitShipmentReportStatistic();
+
+    Page<OrderSummaryBo> orderSummary(@Param("page") Page<Object> page, @Param("dto") OrderSummarySelectDto dto, @Param("ew") IWrapper<Object> wrapper);
 }

+ 2 - 0
hx-form/src/main/java/com/fjhx/form/service/ReportService.java

@@ -25,4 +25,6 @@ public interface ReportService {
      * 已完工未出货报表
      */
     Page<WaitShipmentReportBo> waitShipmentReport(ProductionReportSelectDto dto);
+
+    Page<OrderSummaryBo> orderSummary(OrderSummarySelectDto dto);
 }

+ 19 - 0
hx-form/src/main/java/com/fjhx/form/service/impl/ReportServiceImpl.java

@@ -10,6 +10,7 @@ import com.fjhx.mes.entity.report.po.ReportLossesDetails;
 import com.fjhx.mes.service.report.ReportLossesDetailsService;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.common.utils.wrapper.SqlField;
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -153,4 +154,22 @@ public class ReportServiceImpl implements ReportService {
 
         return waitShipmentReportBoPage;
     }
+
+    @Override
+    public Page<OrderSummaryBo> orderSummary(OrderSummarySelectDto dto) {
+        IWrapper<Object> wrapper = IWrapper.getWrapper();
+        wrapper.having("accountAge = {0}", dto.getAccountAge());
+        wrapper.keyword(dto.getKeyword(),
+                new SqlField("c.code"),
+                new SqlField("cu.name"),
+                new SqlField("cu.short_name")
+        );
+        wrapper.orderByDesc("c.create_time", "c.id");
+        Page<OrderSummaryBo> page = reportMapper.orderSummary(dto.getPage(), dto, wrapper);
+
+        List<OrderSummaryBo> records = page.getRecords();
+        UserUtil.assignmentNickName(records, OrderSummaryBo::getSalesmanId, OrderSummaryBo::setSalesmanName);
+        UserUtil.assignmentNickName(records, OrderSummaryBo::getMerchUserId, OrderSummaryBo::setMerchUserName);
+        return page;
+    }
 }

+ 67 - 3
hx-form/src/main/resources/mapper/ReportMapper.xml

@@ -4,18 +4,18 @@
 
     <select id="productionReport" resultType="com.fjhx.form.entity.ProductionReportBo">
         SELECT pod.id,
-               pod.company_id                                                 AS factoryId,
+               pod.company_id                                                     AS factoryId,
                po.`code`                                                      AS orderCode,
                pod.product_id,
                pod.quantity,
                po.delivery_period,
                pod.finish_time,
                IF(DATE_FORMAT(IFNULL(po.finish_time, NOW()), '%Y-%m-%d') > DATE_FORMAT(po.delivery_period, '%Y-%m-%d'),
-                  1, 0)                                                       as isOverdue,
+                  1, 0)                                                           as isOverdue,
                IF(DATE_FORMAT(IFNULL(po.finish_time, NOW()), '%Y-%m-%d') > DATE_FORMAT(po.delivery_period, '%Y-%m-%d'),
                   DATEDIFF(IFNULL(po.finish_time, NOW()), po.delivery_period), 0) as overdueDay,
                DATEDIFF(po.delivery_period, po.produce_time) /
-               DATEDIFF(IFNULL(po.finish_time, NOW()), po.produce_time) * 100 as timelyRate
+               DATEDIFF(IFNULL(po.finish_time, NOW()), po.produce_time) * 100     as timelyRate
         FROM production_order_detail pod
                  LEFT JOIN production_order po ON pod.produce_order_id = po.id
     </select>
@@ -67,4 +67,68 @@
           AND po.produce_status = 5
         GROUP BY c.salesman_id
     </select>
+    <select id="orderSummary" resultType="com.fjhx.form.entity.OrderSummaryBo">
+        SELECT c.id,
+               c.`code`                                                  AS contractCode,
+               c.salesman_id,
+               c.merch_user_id,
+               c.belong_type,
+               c.amount,
+               c.factory_amount,
+               IFNULL(cor.sumOutFactoryMoney, 0)                         AS sumOutFactoryMoney,
+               (c.amount * c.advance_ratio / 100)                        AS deposit,
+               NULL                                                      AS difference,
+               IF(IFNULL(cla.sumClaimMoney, 0) >= c.amount AND IFNULL(cor.sumOutMoney, 0) >= c.factory_amount, '可结算',
+                  '不可结算')                                            AS isSettlement,
+               c.settle_start_date,
+               c.settle_end_date,
+               c.contract_type,
+               cu.`name`                                                 AS customerName,
+               cu.short_name                                             AS customerShortName,
+               IFNULL(cor.sumOutMoney, 0)                                AS receivableAmount,
+               IFNULL(cla.sumClaimMoney, 0)                              AS sumClaimMoney,
+               IFNULL(cor.sumOutMoney, 0) - IFNULL(cla.sumClaimMoney, 0) AS outstandingAmount,
+               cor.firstTruckDate                                        AS firstTruckDate,
+               CASE
+                   WHEN IFNULL(#{dto.accountAgeDate} THEN
+            WHEN IFNULL(DATEDIFF( IFNULL(#{dto.accountAgeDate},NOW()), cor.firstTruckDate ),0) &lt;= 30 THEN
+            '0~30'
+            WHEN IFNULL(DATEDIFF( IFNULL(#{dto.accountAgeDate},NOW()), cor.firstTruckDate ),0) &lt;= 60 THEN
+            '30~60'
+            WHEN IFNULL(DATEDIFF( IFNULL(#{dto.accountAgeDate},NOW()), cor.firstTruckDate ),0) &lt;= 90 THEN
+            '60~90'
+            WHEN IFNULL(DATEDIFF( IFNULL(#{dto.accountAgeDate},NOW()), cor.firstTruckDate ),0) &lt;= 120 THEN
+            '90~120'
+            WHEN IFNULL(DATEDIFF( IFNULL(#{dto.accountAgeDate},NOW()), cor.firstTruckDate ),0) > 120 THEN
+            '120以上'
+            END AS accountAge
+        FROM
+            contract c
+                LEFT JOIN (
+                    SELECT
+                        cc.contract_id,
+                        SUM( cc.contract_money ) AS sumClaimMoney
+                    FROM
+                        claim_contract cc
+                            JOIN claim cl ON cc.claim_id = cl.id
+                    WHERE
+                        cl.confirm_status = 1
+                    GROUP BY
+                        cc.contract_id
+                ) cla ON cla.contract_id = c.id
+                LEFT JOIN (
+                    SELECT
+                        cor.contract_id,
+                        MIN( coi.truck_date ) AS firstTruckDate,
+                        sum( cor.price * cor.truck_quantity ) AS sumOutMoney,
+                        sum( cor.factory_price * cor.truck_quantity ) AS sumOutFactoryMoney
+                    FROM
+                        contract_outbound_records cor
+                            JOIN contract_outbound_info coi ON cor.record_id = coi.id
+                    GROUP BY
+                        cor.contract_id
+                ) cor ON cor.contract_id = c.id
+                LEFT JOIN customer cu ON c.buy_corporation_id = cu.id
+            ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 8 - 0
hx-sale/src/main/java/com/fjhx/sale/controller/contract/ContractController.java

@@ -373,4 +373,12 @@ public class ContractController {
         contractService.excelExport(httpServletResponse, dto);
     }
 
+    /**
+     * 修改结算日期范围
+     */
+    @PostMapping("/editSettleDateRange")
+    public void editSettleDateRange(@RequestBody ContractDto dto) {
+        contractService.editSettleDateRange(dto);
+    }
+
 }

+ 10 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/Contract.java

@@ -524,6 +524,16 @@ public class Contract extends BasePo {
      */
     private String settlementMethod;
 
+    /**
+     * 结算开始时间
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date settleStartDate;
+    /**
+     * 结算结束时间
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date settleEndDate;
     //========================================================================
     /**
      * 交接单附件列表

+ 2 - 0
hx-sale/src/main/java/com/fjhx/sale/service/contract/ContractService.java

@@ -267,4 +267,6 @@ public interface ContractService extends BaseService<Contract> {
     void contractAttach(ContractDto dto);
 
     void excelExport(HttpServletResponse httpServletResponse, ContractSelectDto dto);
+
+    void editSettleDateRange(ContractDto dto);
 }

+ 11 - 0
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -3355,4 +3355,15 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         ExcelUtil.export(httpServletResponse, contractExcelBos, ContractExcelBo.class);
     }
 
+    @Override
+    public void editSettleDateRange(ContractDto dto) {
+        this.update(q -> q
+                .eq(Contract::getId, dto.getId())
+                .set(Contract::getSettleStartDate, dto.getSettleStartDate())
+                .set(Contract::getSettleEndDate, dto.getSettleEndDate())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+                .set(BasePo::getUpdateTime, new Date())
+        );
+    }
+
 }