|
@@ -1,14 +1,22 @@
|
|
|
package org.jeecg.modules.documents.syShippingOrder.controller;
|
|
|
|
|
|
+import java.io.*;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
@@ -28,10 +36,13 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.modules.documents.syShippingOrder.service.impl.SyShippingOrderItemServiceImpl;
|
|
|
import org.jeecg.modules.spapl.entity.SizeTable;
|
|
|
import org.jeecg.modules.splt.mapper.SyPackingListTailoringItemMapper;
|
|
|
+import org.jeecg.modules.system.util.JsonChangeUtils;
|
|
|
+import org.jeecgframework.poi.excel.ExcelExportUtil;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
+import org.jeecgframework.poi.excel.entity.TemplateExportParams;
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -496,4 +507,85 @@ public class SyShippingOrderController extends JeecgController<SyShippingOrder,
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发票打印
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "发票打印")
|
|
|
+ @ApiOperation(value = "发票打印")
|
|
|
+ @RequestMapping(value = "/syShippingOrderPrint")
|
|
|
+ public SyShippingOrder syShippingOrderPrint(String id,String testName) throws ParseException {
|
|
|
+
|
|
|
+ //总毛重
|
|
|
+ BigDecimal totalGrossWeight = BigDecimal.ZERO;
|
|
|
+ //总净重
|
|
|
+ BigDecimal totalNetweight = BigDecimal.ZERO;
|
|
|
+
|
|
|
+
|
|
|
+ //查询主表数据
|
|
|
+ SyShippingOrder entity = syShippingOrderService.getById(id);
|
|
|
+
|
|
|
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = sf.parse(entity.getLatestDateOfShipment());
|
|
|
+ String lasttime = sf.format(date);
|
|
|
+ entity.setLatestDateOfShipment(lasttime);
|
|
|
+ //查询子表数据
|
|
|
+ QueryWrapper<SyShippingOrderItem> queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq("sy_shipping_order_item_id",id);
|
|
|
+ List<SyShippingOrderItem> list = syShippingOrderItemService.list(queryWrapper);
|
|
|
+
|
|
|
+ for(SyShippingOrderItem li:list){
|
|
|
+ //设置总毛重
|
|
|
+ totalGrossWeight.add(li.getGrossWeight());
|
|
|
+ //总净重
|
|
|
+ totalNetweight.add(li.getNetWeight());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ //String[] nameList = new String[]{"报关信息-报关单","报关信息-申报要素-成衣","报关信息-发票","报关信息-合同","报关信息-申报要素-面料","报关信息-装箱单"};
|
|
|
+
|
|
|
+ if(testName.equals("报关信息-报关单")){
|
|
|
+
|
|
|
+ TemplateExportParams params = new TemplateExportParams("D:\\"+testName+".xlsx");
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+
|
|
|
+ Field[] fields = entity.getClass().getDeclaredFields();
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ map.put(field.getName(), field.get(entity));
|
|
|
+ }
|
|
|
+ Map<String, SyShippingOrderItem> maps = list.stream().collect(Collectors.toMap(SyShippingOrderItem::getId, Function.identity()));
|
|
|
+ map.put("item", maps);
|
|
|
+
|
|
|
+ log.info("输出的数据:" + map);
|
|
|
+
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params, map);
|
|
|
+ File savefile = new File("C:\\Users\\Mr_zeng\\Desktop\\"+testName+".xlsx");
|
|
|
+ if (!savefile.exists()) {
|
|
|
+ savefile.mkdirs();
|
|
|
+ }
|
|
|
+ FileOutputStream fos = new FileOutputStream("C:\\Users\\Mr_zeng\\Desktop\\"+testName+".xlsx");
|
|
|
+ workbook.write(fos);
|
|
|
+ fos.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception ex){
|
|
|
+
|
|
|
+ ex.printStackTrace();
|
|
|
+ log.error("生成失败:" + ex.getMessage());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|