diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index c3442f7..8267c35 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -106,6 +106,23 @@ system ${basedir}/src/main/resources/lib/sapjco3.jar + + dom4j + dom4j + 1.6.1 + ${basedir}/src/main/resources/lib/dom4j-1.6.1.jar + system + + + org.freemarker + freemarker + 2.3.32 + + + net.sourceforge.jexcelapi + jxl + 2.6.12 + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/RedBookController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/RedBookController.java index 5d51978..36f3055 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/RedBookController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/RedBookController.java @@ -10,23 +10,17 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.UUID; -import com.ruoyi.customer.domain.Customer; -import com.ruoyi.quote.domain.CalculateRBParamDto; import com.ruoyi.redBook.domain.OAQuotProduct; import com.ruoyi.redBook.domain.Product; import com.ruoyi.redBook.domain.OAQuot; import com.ruoyi.redBook.domain.RbVersionDateResult; import com.ruoyi.redBook.service.IRedBookService; import com.ruoyi.web.utils.IdUtils; -import com.ruoyi.web.utils.SapFunction.RfcResult; -import com.ruoyi.web.utils.SapFunction.SapRfcUtils; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; +import javax.servlet.http.HttpServletResponse; +import java.util.*; /** * 红本管理Controller @@ -213,14 +207,19 @@ public class RedBookController extends BaseController @DataSource(DataSourceType.MASTER) @Log(title = "报价单生成", businessType = BusinessType.OTHER) @PostMapping("/madeQuot") - public AjaxResult madeQuot(@RequestBody OAQuot quot) + public void madeQuot(HttpServletResponse response, @RequestBody OAQuot quot) { quot.setQuot_id(UUID.fastUUID().toString()); quot.setQuotCode(IdUtils.createNo("BJD_",2)); quot.setCreateBy(getUsername()); redBookService.insertOAQuot(quot); - return success(); + + List list = quot.getSelectedResultData(); + + excelUtil.exportExcel(response, list); } + + /** * 获取调价日期 * @param oAQuot diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/excelUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/excelUtil.java new file mode 100644 index 0000000..d16d1f7 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/redBook/excelUtil.java @@ -0,0 +1,323 @@ +package com.ruoyi.web.controller.redBook; + +import com.ruoyi.redBook.domain.OAQuotProduct; +import jxl.HeaderFooter; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.*; +import jxl.write.Number; +import jxl.write.biff.RowsExceededException; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +public class excelUtil { + + public static void exportExcel(HttpServletResponse response, List list){ + response.setContentType("application/vnd.ms-excel"); + BigDecimal totalmoney = BigDecimal.ZERO; + try { + /*Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMddss");// + String sNow = dateFormat.format(now); + String fileName = "BJD_" + sNow; + + // 生成文件名 + response.addHeader("Content-Disposition", + "attachment; filename=\"" + fileName + ".xls" + "\"");*/ + OutputStream os = response.getOutputStream(); + WritableWorkbook wwb = Workbook.createWorkbook(os); + + // 新建一张表 + WritableSheet wsheet = wwb.createSheet("报价单", 0); + Label label = new Label(0, 0, ""); + int i= 0; + //设置单头 + WritableFont wf_merge = new WritableFont(WritableFont.ARIAL,16,WritableFont.BOLD,false); + WritableCellFormat wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.CENTRE); + wff_merge.setVerticalAlignment(VerticalAlignment.CENTRE); + //wff_merge.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); + wsheet.mergeCells(0,i,7,i); + wsheet.setRowView(i,600); + label = new Label(0, i, "无 锡 江 南 电 缆 有 限 公 司",wff_merge); + wsheet.addCell(label); + i++; + + wf_merge = new WritableFont(WritableFont.ARIAL,15,WritableFont.BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.CENTRE); + wff_merge.setVerticalAlignment(VerticalAlignment.CENTRE); + wsheet.mergeCells(0,i,7,i); + wsheet.setRowView(i,600); + label = new Label(0, i, "WUXI JIANGNAN CABLE CO.,LTD.",wff_merge); + wsheet.addCell(label); + i++; + // + wsheet.mergeCells(0,i,7,i); + wsheet.setRowView(i,500); + wf_merge = new WritableFont(WritableFont.ARIAL,15,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setVerticalAlignment(VerticalAlignment.CENTRE); + //wff_merge.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); + wff_merge.setAlignment(Alignment.CENTRE); + label = new Label(0, i, "产品报价单",wff_merge); + wsheet.addCell(label); + i++; + // + wsheet.mergeCells(0,i,7,i); + wsheet.setRowView(i,500); + wf_merge = new WritableFont(WritableFont.ARIAL,12,WritableFont.BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.CENTRE); + wff_merge.setVerticalAlignment(VerticalAlignment.CENTRE); + label = new Label(0, i, "中国线缆行业十强 中国制造业企业500强 中国民营企业500强 全国用户满意标杆企业",wff_merge); + wsheet.addCell(label); + i++; + //报价信息 + wf_merge = new WritableFont(WritableFont.ARIAL,11,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.LEFT); + wsheet.setRowView(i,380); + String[] bjs = {"询价单位:","业务联系人:","项目名称:","联 系 电 话:","询价日期:","编 制:","报价日期:","审 核:"}; + int k=0; + while(k it = list.iterator(); it.hasNext();) + { + OAQuotProduct s = it.next(); + wsheet.setRowView(i,400); + labelN = new Number(0, i,j,wff_merge); + labelN.setCellFormat(cellFormat); + wsheet.addCell(labelN); + label = new Label(1, i, s.getName_1(),wff_merge); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + label = new Label(2, i, s.getSpec(),wff_merge); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + label = new Label(3,i,s.getVoltage(),wff_merge); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + label = new Label(4,i,s.getStu(),wff_merge); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + label = new Label(5,i,"1",wff_merge); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + label = new Label(6, i, String.valueOf(s.getSetPrice()),wff_merge); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + label = new Label(7, i, String.valueOf(s.getAllPrice()),wff_merge); + + totalmoney = totalmoney.add(s.getAllPrice()); + label.setCellFormat(cellFormat); + wsheet.addCell(label); + + label = new Label(9, i, s.getName_0(),wff_merge); + label.setCellFormat(cellFormat2); + wsheet.addCell(label); + + if(j>2000) + break; //200改为2000 + i++; + j++; + } + + if(list.size()<=2000) + { + wsheet.mergeCells(1,i,6,i); + wsheet.setRowView(i,400); + wf_merge = new WritableFont(WritableFont.ARIAL,11,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.LEFT); + wff_merge.setBorder(Border.ALL, BorderLineStyle.THIN); + label = new Label(0, i, "",wff_merge); + wsheet.addCell(label); + label = new Label(1, i, " 合计(元):",wff_merge); + wsheet.addCell(label); + label = new Label(7, i, " "+totalmoney,wff_merge); + wsheet.addCell(label); + i++; + } + + wsheet.setRowView(i,390); + wf_merge = new WritableFont(WritableFont.ARIAL,11,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.LEFT); + wff_merge.setBorder(Border.RIGHT, BorderLineStyle.THIN); + wsheet.mergeCells(1,i,7,i); + label = new Label(1, i, "1、请审核报价单,如数量有误,价格以单价为准,如型号规格或产品工艺不符,需重新报价;",wff_merge); + wsheet.addCell(label); + i++; + wsheet.setRowView(i,390); + wsheet.mergeCells(1,i,7,i); + label = new Label(1, i, "2、本报价为含税、含运费价,此价为即时参考价,具体单价因考虑付款等因素以签订合同为准;",wff_merge); + wsheet.addCell(label); + i++; + wsheet.setRowView(i,390); + wsheet.mergeCells(1,i,7,i); + label = new Label(1, i, "报价为国内报价,如需出口,须提供相应信息另行报价; ",wff_merge); + wsheet.addCell(label); + i++; + wsheet.setRowView(i,390); + wsheet.mergeCells(1,i,7,i); + + wf_merge = new WritableFont(WritableFont.ARIAL,11,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.LEFT); + wff_merge.setBorder(Border.BOTTOM, BorderLineStyle.THIN); + wff_merge.setBorder(Border.RIGHT, BorderLineStyle.THIN); + + label = new Label(1, i, "3、分支电缆为多芯分支价格,不包其它附件,不含安装费,数量以供方实际测量为准;",wff_merge); + wsheet.addCell(label); + /*i++; + wsheet.setRowView(i,390); + wf_merge = new WritableFont(WritableFont.ARIAL,11,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(jxl.format.Alignment.LEFT); + wff_merge.setBorder(jxl.format.Border.BOTTOM,jxl.format.BorderLineStyle.THIN); + wff_merge.setBorder(jxl.format.Border.RIGHT,jxl.format.BorderLineStyle.THIN); + wsheet.mergeCells(1,i,7,i); +// label = new Label(1, i, "4、产品交货总数和单根交货长度允许有±1%公差,如有不符对方要求,需重制作报价单。",wff_merge); + wsheet.addCell(label);*/ + + wsheet.mergeCells(0,i-4,0,i); + wf_merge = new WritableFont(WritableFont.ARIAL,11,WritableFont.NO_BOLD,false); + wff_merge = new WritableCellFormat(wf_merge); + wff_merge.setAlignment(Alignment.CENTRE); + wff_merge.setVerticalAlignment(VerticalAlignment.CENTRE); + wff_merge.setBorder(Border.ALL, BorderLineStyle.THIN); + label = new Label(0, i-4, "备注",wff_merge); + wsheet.addCell(label); + + // 获取当前类加载器 + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + // 获取资源的URL + URL resourceUrl = classLoader.getResource("jnlogo.png"); + File file=new File(resourceUrl.getPath()); + //设置图片位置,前两个参数为插入图片的单元格坐标,后面是设置从插入的单元格开始横向和纵向分别要占用的单元格个数,最后传入图片文件 + WritableImage image=new WritableImage(0.3, 0.2, 1.25, 2.55,file); + wsheet.addImage(image); + + // 获取当前类加载器 + ClassLoader classLoader2 = Thread.currentThread().getContextClassLoader(); + // 获取资源的URL + URL resourceUrl2 = classLoader2.getResource("wc.png"); + file=new File(resourceUrl2.getPath()); + //设置图片位置,前两个参数为插入图片的单元格坐标,后面是设置从插入的单元格开始横向和纵向分别要占用的单元格个数,最后传入图片文件 + image=new WritableImage(6.7, 0.2, 1.20, 2.65,file); + wsheet.addImage(image); + + wsheet.getSettings().setBottomMargin(0.7d); + wsheet.getSettings().setTopMargin(0.7d); + wsheet.getSettings().setLeftMargin(0.6d); + wsheet.getSettings().setRightMargin(0.2d); + + HeaderFooter footer = new HeaderFooter(); + footer.getCentre().append("第 "); + footer.getCentre().appendPageNumber(); + footer.getCentre().append(" 页,共 "); + footer.getCentre().appendTotalPages(); + footer.getCentre().append(" 页 "); + footer.getCentre().setFontName("ARIAL"); + footer.getCentre().setFontSize(13); + wsheet.getSettings().setFooter(footer); + + + wsheet.getSettings().setPrintTitles(0, 8, 0, 7); + + + + wwb.write(); + + wwb.close(); + os.close(); + response.flushBuffer(); + + + } catch (RowsExceededException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (WriteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/ruoyi-admin/src/main/resources/jnlogo.png b/ruoyi-admin/src/main/resources/jnlogo.png new file mode 100644 index 0000000..4b005d0 Binary files /dev/null and b/ruoyi-admin/src/main/resources/jnlogo.png differ diff --git a/ruoyi-admin/src/main/resources/lib/dom4j-1.6.1.jar b/ruoyi-admin/src/main/resources/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/ruoyi-admin/src/main/resources/lib/dom4j-1.6.1.jar differ diff --git a/ruoyi-admin/src/main/resources/wc.png b/ruoyi-admin/src/main/resources/wc.png new file mode 100644 index 0000000..ae1f9fa Binary files /dev/null and b/ruoyi-admin/src/main/resources/wc.png differ diff --git a/ruoyi-system/src/main/java/com/ruoyi/redBook/domain/OAQuotProduct.java b/ruoyi-system/src/main/java/com/ruoyi/redBook/domain/OAQuotProduct.java index 48d2575..be3a753 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/redBook/domain/OAQuotProduct.java +++ b/ruoyi-system/src/main/java/com/ruoyi/redBook/domain/OAQuotProduct.java @@ -4,7 +4,8 @@ import java.math.BigDecimal; public class OAQuotProduct { private String uid_0;//版本uid - private String name_0;//型号 + private String name_0;//产品型号 + private String name_1;//型号 private String spec;//规格 private String voltage;//电压 private String stu;//单位 @@ -14,6 +15,9 @@ public class OAQuotProduct { private String quot_product_id;//id private String quot_id;//报价单id + private BigDecimal per;//一次折扣 + private BigDecimal per2;//二次折扣 + public String getUid_0() { return uid_0; } public void setUid_0(String uid_0) { this.uid_0 = uid_0; } @@ -26,6 +30,10 @@ public class OAQuotProduct { this.name_0 = name_0; } + public String getName_1() { return name_1; } + + public void setName_1(String name_1) { this.name_1 = name_1; } + public String getSpec() { return spec; } @@ -69,4 +77,12 @@ public class OAQuotProduct { public String getQuot_id() { return quot_id; } public void setQuot_id(String quot_id) { this.quot_id = quot_id; } + + public BigDecimal getPer() { return per; } + + public void setPer(BigDecimal per) { this.per = per; } + + public BigDecimal getPer2() { return per2; } + + public void setPer2(BigDecimal per2) { this.per2 = per2; } } diff --git a/ruoyi-system/src/main/resources/mapper/redBook/OARedBookMapper.xml b/ruoyi-system/src/main/resources/mapper/redBook/OARedBookMapper.xml index 7d58cf7..b2bbe9b 100644 --- a/ruoyi-system/src/main/resources/mapper/redBook/OARedBookMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/redBook/OARedBookMapper.xml @@ -105,9 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into OAQuotProduct(quot_product_id, name_0, spec, voltage,stu,setPrice,count,allPrice,quot_id) values + insert into OAQuotProduct(quot_product_id, name_0, spec, voltage,stu,setPrice,count,allPrice,per,per2,quot_id) values - ( #{item.quot_product_id}, #{item.name_0}, #{item.spec}, #{item.voltage}, #{item.stu},cast(#{item.setPrice,jdbcType=DECIMAL} as decimal(18,2)), cast(#{item.count,jdbcType=DECIMAL} as decimal(18,3)), cast(#{item.allPrice,jdbcType=DECIMAL} as decimal(18,2)), #{item.quot_id}) + ( #{item.quot_product_id}, #{item.name_0}, #{item.spec}, #{item.voltage}, #{item.stu},cast(#{item.setPrice,jdbcType=DECIMAL} as decimal(18,2)), cast(#{item.count,jdbcType=DECIMAL} as decimal(18,3)), cast(#{item.allPrice,jdbcType=DECIMAL} as decimal(18,2)),cast(#{item.per,jdbcType=DECIMAL} as decimal(18,2)),cast(#{item.per2,jdbcType=DECIMAL} as decimal(18,2)), #{item.quot_id}) @@ -122,14 +122,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-ui/src/api/redBook/redBook.js b/ruoyi-ui/src/api/redBook/redBook.js index 5b89453..c18aa01 100644 --- a/ruoyi-ui/src/api/redBook/redBook.js +++ b/ruoyi-ui/src/api/redBook/redBook.js @@ -1,4 +1,5 @@ import request from '@/utils/request' +import { getToken } from "@/utils/auth"; // 金额计算 export function toDecimal(x){ @@ -105,6 +106,10 @@ export function madeQuot(data) { return request({ url: '/redBook/redBook/madeQuot', method: 'post', + responseType: "blob", // 表明返回服务器返回的数据类型 + headers: { + 'X-Authorization': getToken() + }, data: data }) } diff --git a/ruoyi-ui/src/views/redBook/productSelect.vue b/ruoyi-ui/src/views/redBook/productSelect.vue index 6104138..e0190ae 100644 --- a/ruoyi-ui/src/views/redBook/productSelect.vue +++ b/ruoyi-ui/src/views/redBook/productSelect.vue @@ -51,7 +51,8 @@ - + + @@ -71,43 +72,47 @@ - + - + - + - + + + + + + + 总价:{{sumSelectedResultData}} + + + + + + - 批量调折扣率: - - - 总价:{{sumSelectedResultData}} - - - - @@ -116,19 +121,20 @@ - + + - + - + @@ -137,7 +143,7 @@ - +