chenrui
2025-05-13 3c5072913efbda0c2341cac904a55383ad82f8c8
开票台账前后端联调
已修改9个文件
184 ■■■■■ 文件已修改
src/main/java/com/ruoyi/common/vo/FileVo.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/controller/InvoiceLedgerController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/dto/InvoiceLedgerDto.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/mapper/InvoiceLedgerMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/pojo/InvoiceLedger.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/pojo/InvoiceLedgerFile.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/InvoiceLedgerService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/InvoiceLedgerServiceImpl.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sales/InvoiceLedgerMapper.xml 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/vo/FileVo.java
@@ -9,10 +9,10 @@
public class FileVo {
    @ApiModelProperty(value = "文件名称")
    private String fileName;
    private String name;
    @ApiModelProperty(value = "文件路径")
    private String filePath;
    private String url;
    @ApiModelProperty(value = "文件大小")
    private int fileSize;
@@ -28,4 +28,6 @@
    @ApiModelProperty(value = "修改用户")
    private Integer updateUser;
    private Integer id;
}
src/main/java/com/ruoyi/sales/controller/InvoiceLedgerController.java
@@ -23,9 +23,9 @@
     * @param invoiceLedgerDto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult invoiceLedgerAdd(@RequestBody InvoiceLedgerDto invoiceLedgerDto) {
        invoiceLedgerService.invoiceLedgerAdd(invoiceLedgerDto);
    @PostMapping("/saveOrUpdate")
    public AjaxResult invoiceLedgerSaveOrUpdate(@RequestBody InvoiceLedgerDto invoiceLedgerDto) {
        invoiceLedgerService.invoiceLedgerSaveOrUpdate(invoiceLedgerDto);
        return AjaxResult.success();
    }
@@ -35,19 +35,8 @@
     * @return
     */
    @DeleteMapping("/del")
    public AjaxResult invoiceLedgerDel(@RequestParam List<Integer> ids) {
    public AjaxResult invoiceLedgerDel(@RequestBody List<Integer> ids) {
        invoiceLedgerService.invoiceLedgerDel(ids);
        return AjaxResult.success();
    }
    /**
     * 开票台账修改
     * @param invoiceLedgerDto
     * @return
     */
    @PostMapping("/update")
    public AjaxResult invoiceLedgerUpdate(@RequestBody InvoiceLedgerDto invoiceLedgerDto) {
        invoiceLedgerService.invoiceLedgerUpdate(invoiceLedgerDto);
        return AjaxResult.success();
    }
@@ -97,4 +86,14 @@
        invoiceLedgerService.invoiceLedgerDownload(response, invoiceLedgerDto);
    }
    /**
     * 开票台账详情
     * @param id
     * @return
     */
    @GetMapping("/info")
    public AjaxResult invoiceLedgerInfo(Integer id) {
        return AjaxResult.success(invoiceLedgerService.invoiceLedgerDetail(id));
    }
}
src/main/java/com/ruoyi/sales/dto/InvoiceLedgerDto.java
@@ -16,4 +16,10 @@
    @ApiModelProperty(value = "客户名称")
    private String customerName;
    @ApiModelProperty(value = "客户合同号")
    private String customerContractNo;
    @ApiModelProperty(value = "业务员")
    private String salesman;
}
src/main/java/com/ruoyi/sales/mapper/InvoiceLedgerMapper.java
@@ -26,4 +26,11 @@
     */
    List<InvoiceLedgerDto> invoiceLedgerList(@Param("invoiceLedgerDto") InvoiceLedgerDto invoiceLedgerDto);
    /**
     * 开票台账详情
     * @param id
     * @return
     */
    InvoiceLedgerDto invoiceLedgerInfo(Integer id);
}
src/main/java/com/ruoyi/sales/pojo/InvoiceLedger.java
@@ -45,9 +45,9 @@
    private String invoicePerson;
    @ApiModelProperty(value = "开票时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime invoiceDate;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate invoiceDate;
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
src/main/java/com/ruoyi/sales/pojo/InvoiceLedgerFile.java
@@ -11,10 +11,10 @@
public class InvoiceLedgerFile {
    @ApiModelProperty(value = "文件名称")
    private String fileName;
    private String name;
    @ApiModelProperty(value = "文件路径")
    private String filePath;
    private String url;
    @ApiModelProperty(value = "文件大小")
    private int fileSize;
src/main/java/com/ruoyi/sales/service/InvoiceLedgerService.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.vo.FileVo;
import com.ruoyi.sales.dto.InvoiceLedgerDto;
import com.ruoyi.sales.pojo.InvoiceLedger;
import com.ruoyi.sales.pojo.InvoiceLedgerFile;
import org.springframework.web.multipart.MultipartFile;
@@ -18,7 +17,7 @@
     * @param invoiceLedgerDto
     * @return
     */
    int invoiceLedgerAdd( InvoiceLedgerDto invoiceLedgerDto);
    int invoiceLedgerSaveOrUpdate( InvoiceLedgerDto invoiceLedgerDto);
    /**
     * 开票台账删除
@@ -26,13 +25,6 @@
     * @return
     */
    int invoiceLedgerDel(List<Integer> ids);
    /**
     * 开票台账修改
     * @param invoiceLedgerDto
     * @return
     */
    int invoiceLedgerUpdate(InvoiceLedgerDto invoiceLedgerDto);
    /**
     * 开票台账分页查询
@@ -63,4 +55,11 @@
     * @return
     */
    void invoiceLedgerDownload(HttpServletResponse response ,InvoiceLedgerDto invoiceLedgerDto);
    /**
     * 开票台账详情
     * @param id
     * @return
     */
    InvoiceLedgerDto invoiceLedgerDetail(Integer id);
}
src/main/java/com/ruoyi/sales/service/impl/InvoiceLedgerServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.sales.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,11 +25,14 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
@@ -50,10 +54,19 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int invoiceLedgerAdd(InvoiceLedgerDto invoiceLedgerDto) {
    public int invoiceLedgerSaveOrUpdate(InvoiceLedgerDto invoiceLedgerDto) {
        InvoiceLedger invoiceLedger = new InvoiceLedger();
        BeanUtils.copyProperties(invoiceLedgerDto, invoiceLedger);
        int result = invoiceLedgerMapper.insert(invoiceLedger);
        int result;
        if(invoiceLedgerDto.getId() == null){
            result = invoiceLedgerMapper.insert(invoiceLedger);
        }else {
            result = invoiceLedgerMapper.updateById(invoiceLedger);
            //删除所有附件关联
            LambdaQueryWrapper<InvoiceLedgerFile> delWrapper = new LambdaQueryWrapper<>();
            delWrapper.eq(InvoiceLedgerFile::getInvoiceLedgerId, invoiceLedgerDto.getId());
            invoiceLedgerFileMapper.delete(delWrapper);
        }
        List<FileVo> fileList = invoiceLedgerDto.getFileList();
        if(CollectionUtils.isNotEmpty(fileList)){
            fileList.forEach(fileVo -> {
@@ -76,34 +89,6 @@
        LambdaQueryWrapper<InvoiceLedger> delWrapper = new LambdaQueryWrapper<>();
        delWrapper.in(InvoiceLedger::getId, ids);
        return invoiceLedgerMapper.delete(delWrapper);
    }
    /**
     * 开票台账修改
     * @param invoiceLedgerDto
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int invoiceLedgerUpdate(InvoiceLedgerDto invoiceLedgerDto) {
        InvoiceLedger invoiceLedger = new InvoiceLedger();
        BeanUtils.copyProperties(invoiceLedgerDto, invoiceLedger);
        int result = invoiceLedgerMapper.updateById(invoiceLedger);
        // 删除关联附件
        LambdaQueryWrapper<InvoiceLedgerFile> delWrapper = new LambdaQueryWrapper<>();
        delWrapper.eq(InvoiceLedgerFile::getInvoiceLedgerId, invoiceLedger.getId());
        invoiceLedgerFileMapper.delete(delWrapper);
        // 重新插入附件关联表
        List<FileVo> fileList = invoiceLedgerDto.getFileList();
        if(CollectionUtils.isNotEmpty(fileList)){
            fileList.forEach(fileVo -> {
                InvoiceLedgerFile invoiceLedgerFile = new InvoiceLedgerFile();
                BeanUtils.copyProperties(fileVo, invoiceLedgerFile);
                invoiceLedgerFile.setInvoiceLedgerId(invoiceLedger.getId());
                invoiceLedgerFileMapper.insert(invoiceLedgerFile);
            });
        }
        return result;
    }
    /**
@@ -139,9 +124,14 @@
        FileVo fileVo = new FileVo();
        try {
            String baseDir = uploadFile + File.separatorChar + "invoiceLedger";
            String filePath = FileUploadUtils.upload(baseDir, file);
            fileVo.setFileName(file.getOriginalFilename());
            fileVo.setFilePath(filePath);
            File dirFile = new File(baseDir);
            if(!dirFile.exists()){
                dirFile.mkdirs();
            }
            String filePath = baseDir + File.separatorChar + UUID.randomUUID() + "_" + file.getOriginalFilename();
            file.transferTo(new File(filePath));
            fileVo.setName(file.getOriginalFilename());
            fileVo.setUrl(filePath);
            fileVo.setFileSize((int)file.getSize());
        }catch (Exception e){
            e.printStackTrace();
@@ -168,4 +158,28 @@
        util.exportExcel(response, invoiceLedgerExcelDtoList, "供应商导出");
    }
    /**
     * 开票台账详情
     * @param id
     * @return
     */
    @Override
    public InvoiceLedgerDto invoiceLedgerDetail(Integer id) {
        InvoiceLedgerDto invoiceLedgerDto  = invoiceLedgerMapper.invoiceLedgerInfo(id);
        if(ObjectUtils.isEmpty(invoiceLedgerDto)){
            throw new RuntimeException("开票台账查找失败");
        }
        // 查询附件
        QueryWrapper<InvoiceLedgerFile> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("invoice_ledger_id", id);
        List<InvoiceLedgerFile> invoiceLedgerFileList = invoiceLedgerFileMapper.selectList(queryWrapper);
        List<FileVo> fileList = invoiceLedgerFileList.stream().map(item -> {
            FileVo fileVo = new FileVo();
            BeanUtils.copyProperties(item, fileVo);
            return fileVo;
        }).collect(Collectors.toList());
        invoiceLedgerDto.setFileList(fileList);
        return invoiceLedgerDto;
    }
}
src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
@@ -19,9 +19,12 @@
            T1.update_time       ,
            T1.update_user       ,
            T1.tenant_id         ,
            T2.customer_name
            T2.customer_name,
            T3.customer_contract_no,
            T3.salesman
        FROM invoice_ledger T1
        LEFT JOIN customer T2 ON T1.customer_id = T2.id
        LEFT JOIN sales_ledger T3 ON T1.sales_ledger_id = T3.id
        <where>
            <if test="invoiceLedgerDto.searchText != null and invoiceLedgerDto.searchText != ''">
                AND (
@@ -66,4 +69,28 @@
            </if>
        </where>
    </select>
    <select id="invoiceLedgerInfo" resultType="com.ruoyi.sales.dto.InvoiceLedgerDto">
        SELECT
        T1.id                ,
        T1.sales_ledger_id   ,
        T1.sales_contract_no ,
        T1.customer_id       ,
        T1.invoice_no        ,
        T1.invoice_amount    ,
        T1.tax_rate          ,
        T1.invoice_person    ,
        T1.invoice_date      ,
        T1.create_time       ,
        T1.create_user       ,
        T1.update_time       ,
        T1.update_user       ,
        T1.tenant_id         ,
        T2.customer_name
        FROM invoice_ledger T1
        LEFT JOIN customer T2 ON T1.customer_id = T2.id
        WHERE T1.id = #{id}
    </select>
</mapper>