chenrui
15 小时以前 862028f5d3433aecec6bf0cfd8bd015dc722b9df
销售合同号/部门新增编号
已修改6个文件
54 ■■■■ 文件已修改
src/main/java/com/ruoyi/project/system/domain/SysDept.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sales/SalesLedgerMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/system/SysDeptMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/domain/SysDept.java
@@ -51,6 +51,9 @@
    /** 父部门名称 */
    private String parentName;
    /** 部门编号 */
    private String deptNick;
    
    /** 子部门 */
    private List<SysDept> children = new ArrayList<SysDept>();
@@ -181,6 +184,14 @@
        this.children = children;
    }
    public String getDeptNick() {
        return deptNick;
    }
    public void setDeptNick(String deptNick) {
        this.deptNick = deptNick;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.mapper.ProductMapper;
@@ -11,7 +12,9 @@
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.pojo.SupplierManage;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.project.system.domain.SysUser;
@@ -97,10 +100,6 @@
    public int addOrEditPurchase(PurchaseLedgerDto purchaseLedgerDto) throws IOException {
        SalesLedger salesLedger = salesLedgerMapper.selectById(purchaseLedgerDto.getSalesLedgerId());
        if (salesLedger == null) {
            throw new BaseException("销售台账不存在");
        }
        //录入人
        SysUser sysUser = userMapper.selectUserById(purchaseLedgerDto.getRecorderId());
@@ -109,8 +108,11 @@
        // DTO转Entity
        PurchaseLedger purchaseLedger = new PurchaseLedger();
        BeanUtils.copyProperties(purchaseLedgerDto, purchaseLedger);
        purchaseLedger.setTenantId(salesLedger.getTenantId());
        purchaseLedger.setSalesContractNo(salesLedger.getSalesContractNo());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if(ObjectUtils.isNotEmpty(loginUser) && null != loginUser.getTenantId()) {
            purchaseLedger.setTenantId(loginUser.getTenantId().longValue());
        }
        purchaseLedger.setSalesContractNo(ObjectUtils.isNotEmpty(salesLedger) ? salesLedger.getSalesContractNo() : null);
        purchaseLedger.setSupplierName(supplierManage.getSupplierName());
        purchaseLedger.setRecorderId(purchaseLedgerDto.getRecorderId());
        purchaseLedger.setRecorderName(sysUser.getNickName());
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -1,5 +1,6 @@
package com.ruoyi.sales.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
@@ -44,7 +45,7 @@
     * 查询销售台账列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SalesLedgerDto salesLedgerDto) {
    public TableDataInfo list(Page page, SalesLedgerDto salesLedgerDto) {
        startPage();
        List<SalesLedger> list = salesLedgerService.selectSalesLedgerList(salesLedgerDto);
        // 计算已开票金额/未开票金额(已填写发票金额为准)
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -3,14 +3,18 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.sales.dto.MonthlyAmountDto;
import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.mapper.*;
@@ -69,7 +73,7 @@
    private final InvoiceLedgerMapper invoiceLedgerMapper;
    @Autowired
    private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
    private SysDeptMapper sysDeptMapper;
    @Value("${file.upload-dir}")
    private String uploadDir;
@@ -492,7 +496,15 @@
                throw new RuntimeException("获取合同编号生成锁失败:超时");
            }
            // 2. 查询当天已存在的序列号(与原逻辑一致)
            // 2. 查询当天/公司已存在的序列号(与原逻辑一致)
            Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
            if(null != tenantId){
                //获取公司编号
                SysDept sysDept = sysDeptMapper.selectDeptById(tenantId.longValue());
                if(!ObjectUtils.isEmpty(sysDept)){
                    datePart = (StringUtils.isEmpty(sysDept.getDeptNick()) ? "" : sysDept.getDeptNick()) + datePart;
                }
            }
            List<Integer> existingSequences = salesLedgerMapper.selectSequencesByDate(datePart);
            int nextSequence = findFirstMissingSequence(existingSequences);
src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -5,9 +5,9 @@
<mapper namespace="com.ruoyi.sales.mapper.SalesLedgerMapper">
    <select id="selectSequencesByDate" resultType="java.lang.Integer">
        SELECT CAST(SUBSTR(sales_contract_no, 9, 3) AS SIGNED)
        SELECT CAST(SUBSTR(sales_contract_no,LENGTH(#{datePart})+1 , 3) AS SIGNED)
        FROM sales_ledger
        WHERE SUBSTR(sales_contract_no, 1, 8) = #{datePart}
        WHERE sales_contract_no LIKE CONCAT('%',#{datePart},'%')
    </select>
    <select id="getSalesNo" resultType="com.ruoyi.sales.pojo.SalesLedger">
        
src/main/resources/mapper/system/SysDeptMapper.xml
@@ -60,7 +60,8 @@
    
    <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
            (select dept_name from sys_dept where dept_id = d.parent_id) parent_name
            (select dept_name from sys_dept where dept_id = d.parent_id) parent_name,
            d.dept_nick
        from sys_dept d
        where d.dept_id = #{deptId}
    </select>
@@ -97,6 +98,7 @@
             <if test="leader != null and leader != ''">leader,</if>
             <if test="phone != null and phone != ''">phone,</if>
             <if test="email != null and email != ''">email,</if>
            <if test="deptNick != null and deptNick != ''">dept_nick,</if>
             <if test="status != null">status,</if>
             <if test="createBy != null and createBy != ''">create_by,</if>
             create_time
@@ -109,6 +111,7 @@
             <if test="leader != null and leader != ''">#{leader},</if>
             <if test="phone != null and phone != ''">#{phone},</if>
             <if test="email != null and email != ''">#{email},</if>
            <if test="deptNick != null and deptNick != '' ">#{deptNick},</if>
             <if test="status != null">#{status},</if>
             <if test="createBy != null and createBy != ''">#{createBy},</if>
             sysdate()
@@ -125,6 +128,7 @@
             <if test="leader != null">leader = #{leader},</if>
             <if test="phone != null">phone = #{phone},</if>
             <if test="email != null">email = #{email},</if>
            <if test="deptNick != null and deptNick != '' ">dept_nick = #{deptNick},</if>
             <if test="status != null and status != ''">status = #{status},</if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
             update_time = sysdate()