Kaynağa Gözat

预托书打印调整

zengtx 1 yıl önce
ebeveyn
işleme
a1d8d13fe7

+ 39 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/letterDeposit/controller/SyLetterDepositController.java

@@ -1,19 +1,24 @@
 package org.jeecg.modules.documents.letterDeposit.controller;
 
 
+import java.io.*;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+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.alibaba.excel.write.metadata.fill.FillWrapper;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
@@ -687,18 +692,42 @@ public class SyLetterDepositController extends JeecgController<SyLetterDeposit,
 				 maiTouList.add(maiTou);
 			 }
 
-			 map.put("item", listMap);
-			 map.put("list", maiTouList);
+//			 map.put("item", listMap);
+//			 map.put("list", maiTouList);
+			 //获取模板输入流
+			 InputStream inStream = new FileInputStream("D:\\单证模板\\预托书数据.xlsx");
+			 //通过poi创建表对象
+			 XSSFWorkbook workbook = new XSSFWorkbook(inStream);
+			 //遍历复制sheet
+			 ByteArrayOutputStream bos = new ByteArrayOutputStream();
+			 //写到流
+			 workbook.write(bos);
+			 ServletOutputStream outputStream = response.getOutputStream();
+			 ByteArrayInputStream is = new ByteArrayInputStream(bos.toByteArray());
+			 ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(is).build();
 
-			 TemplateExportParams params = new TemplateExportParams("D:\\单证模板\\预托书数据.xlsx");
+			 //填充配置, 这里的意义是给模板中的集合数据添加新行, 保证导出不会错乱
+			 FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
 
-			 Workbook workbook = ExcelExportUtil.exportExcel(params, map);
-			 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-			 response.setCharacterEncoding("utf-8");
-			 ServletOutputStream outputStream = response.getOutputStream();
+//---------------------------申报要素------------------------------
+			 WriteSheet writeSheet1 = EasyExcel.writerSheet("预托书").build();
+
+			 excelWriter.fill(entity, fillConfig, writeSheet1);
+			 excelWriter.fill(new FillWrapper("list", listMap), fillConfig, writeSheet1);
+			 excelWriter.fill(new FillWrapper("maiTouList", maiTouList), fillConfig, writeSheet1);
 
-			 workbook.write(outputStream);
 
+//			 TemplateExportParams params = new TemplateExportParams("D:\\单证模板\\预托书数据.xlsx");
+//
+//			 Workbook workbook = ExcelExportUtil.exportExcel(params, map);
+//			 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+//			 response.setCharacterEncoding("utf-8");
+//			 ServletOutputStream outputStream = response.getOutputStream();
+//
+//			 workbook.write(outputStream);
+			 //关流
+			 excelWriter.finish();
+			 inStream.close();
 
 		 }catch (Exception ex){
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/letterDeposit/mapper/xml/SyLetterDepositMapper.xml

@@ -124,6 +124,6 @@ c.english_product_name as englishName,'PCS' as pcs, 'CTNS' as ctns,'KGS' as kgs,
          left join sy_declaration_elements c
          on b.elements_id = c.id
          where a.del_flag = 0 and a.sy_letter_deposit_id = #{id}  group by groupid  order by a.item_number,a.small_po desc
-         ) t GROUP BY t.itemNumber,t.smallPo,t.unitPrice
+         ) t GROUP BY t.itemNumber,t.smallPo,t.unitPrice order by t.supplier,t.itemNumber,t.smallPo,t.englishName,t.unitPrice
     </select>
 </mapper>

+ 3 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/mapper/xml/SyShippingOrderMapper.xml

@@ -149,12 +149,12 @@ where a.sy_shipping_order_item_id =#{id}
     <!--    成衣托书发票-->
     <select id="queryEelement" resultType="org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem">
 
-select t.id, t.hsCode,sum(t.boxNumber) as boxNumber, t.declarationName,t.englishProductName,sum(t.number) as number,round(t.unitPrice,2) as unitPrice,
+select t.supplier,t.id, t.hsCode,sum(t.boxNumber) as boxNumber, t.declarationName,t.englishProductName,sum(t.number) as number,round(t.unitPrice,2) as unitPrice,
 round(sum(t.totalPrice),2) as totalPrice,round(sum(t.grossWeight),2) as grossWeight,round(sum(t.netWeight),2) as netWeight,t.pcs,t.pacs,
 round(sum(t.volume),3) as volume,t.curr,t.dree,t.place,t.certificate,t.styleNumber,t.smailPo,t.orderNumber,t.ctns,t.kgs,t.cbm,pkOrg,t.factoryUnitPrice,
 t.outerBoxLength,t.outerBoxWidth,t.outerBoxHeight,t.hod,t.unIt,t.emp,t.purchaseOutsourcingOrderNo,t.packId,t.salesman,t.earliestDeliveryDate,t.declarationUnit,
 t.clientAbbreviation,t.pcGw,t.priceGw from (
-select GROUP_CONCAT(a.id) as id,b.hs_code as hsCode,b.declaration_name as declarationName,b.english_product_name as englishProductName,sum(a.number) as number,a.unit_price as unitPrice,
+select a.supplier,GROUP_CONCAT(a.id) as id,b.hs_code as hsCode,b.declaration_name as declarationName,b.english_product_name as englishProductName,sum(a.number) as number,a.unit_price as unitPrice,
 sum(a.number*a.unit_price) as totalPrice,a.gross_weight as grossWeight,a.net_weight as netWeight,a.master_metering as pcs,a.volume as volume,a.elements_Id as elementsId,
 'USD' as curr,'CHINA' as dree,'宁波其他/宁波象山县' as place,'照章征税' as certificate,a.style_number as styleNumber,a.smail_po as smailPo,a.box_number as boxNumber,
 a.order_number as orderNumber,a.client_abbreviation as clientAbbreviation,'PCS' as pacs,'CTNS' as ctns,'KGS' as kgs,'CBM' as cbm,c.salesman as salesman,'PC' as pcGw,'/PC' as priceGw,
@@ -166,7 +166,7 @@ on a.elements_Id = b.id
 left join sy_packing_list_tailoring_item c
 on a.tailoring_fabric_item_id = c.id
 where a.sy_shipping_order_item_id =#{id}
-group by c.group_id) t group by t.elementsId,t.styleNumber,t.smailPo,t.unitPrice order by t.styleNumber,t.smailPo desc
+group by c.group_id) t group by t.elementsId,t.styleNumber,t.smailPo,t.unitPrice order by t.supplier,t.styleNumber,t.smailPo,t.englishProductName,t.unitPrice
 
     </select>
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/service/impl/SyShippingOrderServiceImpl.java

@@ -634,7 +634,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
         //获取单据号加1
         cCode= org.jeecg.modules.system.util.oConvertUtils.addOne(purchaseWarehousingMapper.getMaxCodeSalePayVouch("cSPVCode","SalePayVouch","cSPVCode"));
         //获取ID
-        id = org.jeecg.modules.system.util.oConvertUtils.addOne(purchaseWarehousingMapper.getMaxCodeSalePayVouch("ID","SalePayVouch","cSPVCode"));
+        id = org.jeecg.modules.system.util.oConvertUtils.addOne(purchaseWarehousingMapper.getMaxCodeSalePayVouch("ID","SalePayVouch","ID"));
         //查询U8汇率
         Map<String, Object> rate = null;
         String nflat = "";