Browse Source

[feat] 客户报价

客户报价列表页面新增导出客户报价1按钮,新增对应的导出js方法,导出前进行判断,是否审核通过,是否只选择一条,是否币种是RMB
新增 采购报价子表导出模板类
新增 采购报价导出模板类
新增 导出客户报价模板1后端接口,新增具体实现类,完成对客户报价模板1导出模板的数据填充
新增 根据报价单号查询报价单信息后端方法
新增 客户报价模板1导出模板
dev
liuxiaoxu 3 months ago
parent
commit
640a61f7eb
  1. 11
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java
  2. 35
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteChildVo.java
  3. 37
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteVo.java
  4. 8
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerQuoteMapper.java
  5. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteService.java
  6. 132
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteServiceImpl.java
  7. 9
      ruoyi-admin/src/main/resources/mapper/system/SysCustomerQuoteMapper.xml
  8. BIN
      ruoyi-admin/src/main/resources/static/attachments/客户报价1.xlsx
  9. 54
      ruoyi-admin/src/main/resources/templates/system/customerQuote/customerQuote.html

11
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java

@ -335,4 +335,15 @@ public class SysCustomerQuoteController extends BaseController
}
/**
* 导出客户报价模板1
* */
@RequiresPermissions("system:customerQuote:exportCustomerQuoteOne")
@Log(title = "客户报价信息", businessType = BusinessType.EXPORT)
@GetMapping("/exportCustomerQuoteOne/{supplierCode}")
public void exportCustomerQuoteOne(@PathVariable("supplierCode") String supplierCode, HttpServletResponse response){
sysCustomerQuoteService.exportCustomerQuoteOne(supplierCode,response);
}
}

35
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteChildVo.java

@ -0,0 +1,35 @@
package com.ruoyi.system.domain.Vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 采购报价子表导出模板类
* */
@Data
public class ExportCustomerQuoteChildVo {
/** 物料的描述 */
private String describe;
/** 物料的数量 */
private BigDecimal materialNum;
/** 物料的含税单价 */
private BigDecimal materialTaxMoney;
/** 物料的不含税单价 */
private BigDecimal materialNoTaxMoney;
/** 物料的含税总价 */
private BigDecimal materialAllTaxSum;
/** 物料的不含税总价 */
private BigDecimal materialAllNoTaxSum;
}

37
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteVo.java

@ -0,0 +1,37 @@
package com.ruoyi.system.domain.Vo;
import lombok.Data;
/**
* 采购报价导出模板类
* */
@Data
public class ExportCustomerQuoteVo {
/** 客户报价编号 */
private String supplierCode;
/** 报价日期*/
private String pricingDate;
/** 联系人 from */
private String contacts;
/** 联系电话 from */
private String contactNumberFrom;
/** 邮箱 from */
private String companyEmail;
/** 客户第一联系人 to */
private String customerContact;
/** 客户第一联系人电话 to */
private String contactNumberTo;
/** 客户第一联系人邮箱 to */
private String customerEmail;
}

8
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerQuoteMapper.java

@ -90,6 +90,14 @@ public interface SysCustomerQuoteMapper
public SysCustomerQuote selectSysCustomerByCustomerQuoteCode(String customerCode);
/**
* 根据报价单号查询报价单信息
* */
public SysCustomerQuote selectSysCustomerBySupplierCode(String supplierCode);
List<SysCustomerQuote> selectSysCustomerQuoteBycode();
public int cancelSysCustomerQuoteById(Long id);

6
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteService.java

@ -6,6 +6,7 @@ import com.ruoyi.system.domain.SysCustomerQuoteVo;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -85,4 +86,9 @@ public interface ISysCustomerQuoteService
ProcessInstance restoreSysCustomerById(Long id);
public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote);
/**
* 导出客户报价模板1
* */
void exportCustomerQuoteOne(String supplierCode, HttpServletResponse response);
}

132
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteServiceImpl.java

@ -1,5 +1,9 @@
package com.ruoyi.system.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.github.pagehelper.Page;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.PageDomain;
@ -9,17 +13,20 @@ import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileDownloadUtils;
import com.ruoyi.erp.domain.ErpMaterial;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.SysCustomerQuoteChildMapper;
import com.ruoyi.system.mapper.SysCustomerQuoteMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.domain.Vo.ExportCustomerQuoteChildVo;
import com.ruoyi.system.domain.Vo.ExportSalesOrderChildVo;
import com.ruoyi.system.domain.Vo.ExportSalesOrderVo;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.ISysAttachFileService;
import com.ruoyi.system.service.ISysAttachService;
import com.ruoyi.system.service.ISysCustomerQuoteService;
import com.ruoyi.system.service.ISysRoleService;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.activiti.engine.runtime.ProcessInstance;
@ -30,8 +37,13 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.*;
@Slf4j
@Service
public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
@Autowired
@ -43,6 +55,9 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
@Autowired
private SysUserMapper userMapper;
@Autowired
private SysCompanyInformationMapper companyInformationMapper;
@Autowired
private TaskService taskService;
@ -54,6 +69,14 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
@Autowired
private ISysRoleService roleService;
@Autowired
private SysCustomerMapper sysCustomerMapper;
private final static String RMB = "1"; //RMB
@Override
public SysCustomerQuoteVo selectSysCustomerQuoteById(Long id) {
SysCustomerQuoteVo sysCustomerQuoteVo = sysCustomerQuoteMapper.selectSysCustomerQuoteById(id);
@ -352,4 +375,107 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
variables.put("authority",1);
}
}
/**
* 导出客户报价模板1
* */
@Override
public void exportCustomerQuoteOne(String supplierCode, HttpServletResponse response) {
String fileName = "客户报价1.xlsx";
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils();
try {
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName);
String realFileName = supplierCode +"-" + fileName.substring(0, fileName.indexOf(".")) + ".xlsx";
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8"));
response.setContentType("application/octet-stream");
//to
SysCustomerQuote sysCustomerQuote = sysCustomerQuoteMapper.selectSysCustomerBySupplierCode(supplierCode);
if(sysCustomerQuote==null){
log.warn("客户报价信息不存在:{}", supplierCode);
}
List<SysCustomerQuoteChild> sysCustomerQuoteChildren = sysCustomerQuoteChildMapper.selectSysCustomerQuoteChildByQuoteId(sysCustomerQuote.getSupplierCode());
String customerCode = sysCustomerQuote.getCustomerCode();
SysCustomerVo sysCustomerVo = sysCustomerMapper.selectSysCustomerByEnterpriseCode(customerCode);
List<SysCompanyInformation> companyInformations = companyInformationMapper.selectSysCompanyInformationAllList();
//from
SysCompanyInformation sysCompanyInformation = companyInformations.get(0);
HashMap<String, Object> map = new HashMap<>();
String pricingDate = sysCustomerQuote.getPricingDate();
map.put("supplierCode", sysCustomerQuote.getSupplierCode());
map.put("pricingDate", pricingDate);
map.put("contacts", sysCompanyInformation.getContacts());
map.put("contactNumberFrom", sysCompanyInformation.getContactNumber());
map.put("companyEmail", sysCompanyInformation.getCompanyEmail());
map.put("customerContact", sysCustomerVo.getCustomerContact());
map.put("contactNumberTo", sysCustomerVo.getContactNumber());
map.put("customerEmail", sysCustomerVo.getCustomerEmail());
List<ExportCustomerQuoteChildVo> exportCustomerQuoteChildVos = new ArrayList<>();
for (SysCustomerQuoteChild sysCustomerQuoteChild : sysCustomerQuoteChildren) {
ExportCustomerQuoteChildVo exportCustomerQuoteChildVo = new ExportCustomerQuoteChildVo();
exportCustomerQuoteChildVo.setDescribe(sysCustomerQuoteChild.getDescribe());
exportCustomerQuoteChildVo.setMaterialNum(sysCustomerQuoteChild.getMaterialNum());
//区分币种
setMaterialPrice(exportCustomerQuoteChildVo, sysCustomerVo, sysCustomerQuoteChild);
exportCustomerQuoteChildVos.add(exportCustomerQuoteChildVo);
}
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileRelativePath).build();
WriteSheet sheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
workBook.fill(map, sheet);
workBook.fill(exportCustomerQuoteChildVos, fillConfig, sheet);
workBook.finish();
} catch (IOException e) {
throw new RuntimeException("文件处理失败",e);
}
}
private void setMaterialPrice(ExportCustomerQuoteChildVo vo, SysCustomerVo sysCustomerVo, SysCustomerQuoteChild child) {
if (RMB.equals(sysCustomerVo.getCommonCurrency())) {
// RMB
BigDecimal noTax = child.getMaterialNoRmb() != null ? child.getMaterialNoRmb() : BigDecimal.ZERO;
BigDecimal tax = child.getMaterialRmb() != null ? child.getMaterialRmb() : BigDecimal.ZERO;
BigDecimal allNoTax = child.getMaterialNoRmbSum() != null ? child.getMaterialNoRmbSum() : BigDecimal.ZERO;
BigDecimal allTax = child.getMaterialRmbSum() != null ? child.getMaterialRmbSum() : BigDecimal.ZERO;
vo.setMaterialNoTaxMoney(noTax);
vo.setMaterialTaxMoney(tax);
vo.setMaterialAllNoTaxSum(allNoTax);
vo.setMaterialAllTaxSum(allTax);
} else {
// USD
BigDecimal noTax = child.getMaterialNoUsd() != null ? child.getMaterialNoUsd() : BigDecimal.ZERO;
BigDecimal tax = child.getUsdTax() != null ? child.getUsdTax() : BigDecimal.ZERO;
BigDecimal allNoTax = child.getMaterialNoUsdSum() != null ? child.getMaterialNoUsdSum() : BigDecimal.ZERO;
BigDecimal allTax = child.getMaterialUsdSum() != null ? child.getMaterialUsdSum() : BigDecimal.ZERO;
vo.setMaterialNoTaxMoney(noTax);
vo.setMaterialTaxMoney(tax);
vo.setMaterialAllNoTaxSum(allNoTax);
vo.setMaterialAllTaxSum(allTax);
}
}
}

9
ruoyi-admin/src/main/resources/mapper/system/SysCustomerQuoteMapper.xml

@ -103,10 +103,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select customerCode,cusotomerName from sys_customer_quote
</select>
<select id="selectSysCustomerBySupplierCode" parameterType="String" resultMap="SysCustomerQuoteResult">
<include refid="selectSysCustomerQuoteVo"/>
where supplierCode = #{supplierCode}
</select>
<select id="selectSysCustomerByCustomerQuoteCode" parameterType="String" resultMap="SysCustomerQuoteResult">
<include refid="selectSysCustomerQuoteVo"/>
where customerCode = #{cusotomerCode}
</select>
<insert id="insertSysCustomerQuote" parameterType="SysCustomerQuote" useGeneratedKeys="true" keyProperty="id">
insert into sys_customer_quote
<trim prefix="(" suffix=")" suffixOverrides=",">

BIN
ruoyi-admin/src/main/resources/static/attachments/客户报价1.xlsx

Binary file not shown.

54
ruoyi-admin/src/main/resources/templates/system/customerQuote/customerQuote.html

@ -70,6 +70,11 @@
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:customerQuote:export">
<i class="fa fa-download"></i> 导出
</a>
<a class="btn btn-warning" onclick="exportCustomerQuoteOne()" shiro:hasPermission="system:customerQuote:exportCustomerQuoteOne">
<i class="fa fa-download"></i> 导出客户报价1
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" style="white-space:nowrap"></table>
@ -207,6 +212,55 @@
};
$.table.init(options);
});
// 导出客户报价模板1
function exportCustomerQuoteOne(){
const selectRows = $("#bootstrap-table").bootstrapTable('getSelections');
// 定义状态码常量
const AUDIT_STATUS_APPROVED = "1";//审核通过
const DELETE_FLAG = "2"; //作废
if (selectRows.length === 1){
const row = selectRows[0];
// 检查是否已作废
if (row.useStatus === DELETE_FLAG) {
showWarning("该订单已作废");
}else {
// 检查是否已审核
if (row.auditStatus === AUDIT_STATUS_APPROVED) {
if (row.commonCurrency === '1'){
// 使用 $.modal.confirm 显示确认对话框
$.modal.confirm("确定导出这条数据的客户报价吗?", function() {
// 如果用户点击确定,继续导出
var supplierCode = row.supplierCode;
window.location.href = prefix + "/exportCustomerQuoteOne/" + supplierCode;
$('#bootstrap-table').bootstrapTable('refresh'); // 刷新表格
});
}else {
showWarning("请选择报价币种为RMB的数据进行导出");
}
} else {
showWarning("请先审核");
}
}
}else {
$.modal.alertWarning("请选择一条数据");
return;
}
}
// 显示警告消息的通用函数
function showWarning(message) {
$.modal.msgWarning(message);
}
</script>
</body>
</html>
Loading…
Cancel
Save