|
@@ -3,26 +3,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.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 com.baomidou.mybatisplus.annotation.TableField;
|
|
|
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;
|
|
|
import org.jeecg.modules.documents.letterDeposit.entity.SyRmb;
|
|
|
import org.jeecg.modules.documents.letterDeposit.entity.SyUsd;
|
|
|
-import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
|
|
|
import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrder;
|
|
|
import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem;
|
|
|
import org.jeecg.modules.documents.syShippingOrder.entity.VO.SyPackingList;
|
|
@@ -34,23 +30,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
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;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
@@ -516,76 +501,105 @@ public class SyShippingOrderController extends JeecgController<SyShippingOrder,
|
|
|
@AutoLog(value = "发票打印")
|
|
|
@ApiOperation(value = "发票打印")
|
|
|
@RequestMapping(value = "/syShippingOrderPrint")
|
|
|
- public SyShippingOrder syShippingOrderPrint(String id,String testName) throws ParseException {
|
|
|
-
|
|
|
- //总毛重
|
|
|
- BigDecimal totalGrossWeight = BigDecimal.ZERO;
|
|
|
- //总净重
|
|
|
- BigDecimal totalNetweight = BigDecimal.ZERO;
|
|
|
+ public Result<SyShippingOrder> syShippingOrderPrint(String id,String testName) throws ParseException {
|
|
|
|
|
|
+ Result<SyShippingOrder> result= new Result<SyShippingOrder>();
|
|
|
|
|
|
- //查询主表数据
|
|
|
- SyShippingOrder entity = syShippingOrderService.getById(id);
|
|
|
+ //子表集合
|
|
|
+ List<SyShippingOrderItem> list = new ArrayList<>();
|
|
|
|
|
|
- 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);
|
|
|
+ List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
|
|
|
+ //总毛重
|
|
|
+ BigDecimal totalGrossWeight = BigDecimal.ZERO;
|
|
|
+ //总净重
|
|
|
+ BigDecimal totalNetweight = BigDecimal.ZERO;
|
|
|
+ //总数量
|
|
|
+ BigDecimal tatolNumber = BigDecimal.ZERO;
|
|
|
+ //总金额
|
|
|
+ BigDecimal tatolMoney = BigDecimal.ZERO;
|
|
|
|
|
|
- for(SyShippingOrderItem li:list){
|
|
|
- //设置总毛重
|
|
|
- totalGrossWeight.add(li.getGrossWeight());
|
|
|
+ try {
|
|
|
+ //查询主表数据
|
|
|
+ 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);
|
|
|
+
|
|
|
+ // 只要不是成品,需要做汇总操作,汇总条件为报关品名+HSCODE
|
|
|
+ if(entity.getReadyFabric().equals("成衣")){
|
|
|
+ list = syShippingOrderMapper.queryEelement(id);
|
|
|
+ for(SyShippingOrderItem li:list){
|
|
|
+ totalGrossWeight = totalGrossWeight.add(li.getGrossWeight());
|
|
|
+ totalNetweight = totalNetweight.add(li.getNetWeight());
|
|
|
+ tatolNumber = tatolNumber.add(li.getNumber());
|
|
|
+ tatolMoney = tatolMoney.add(li.getTotalPrice());
|
|
|
+ li.setDestination(entity.getArriveInCountry());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ list = syShippingOrderMapper.queryEelementMerge(id);
|
|
|
+ for(SyShippingOrderItem li:list){
|
|
|
+ totalGrossWeight = totalGrossWeight.add(li.getGrossWeight());
|
|
|
+ totalNetweight = totalNetweight.add(li.getNetWeight());
|
|
|
+ tatolNumber = tatolNumber.add(li.getNumber());
|
|
|
+ tatolMoney = tatolMoney.add(li.getTotalPrice());
|
|
|
+ li.setDestination(entity.getArriveInCountry());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //总毛重
|
|
|
+ entity.setTotalGrossWeight(totalGrossWeight);
|
|
|
//总净重
|
|
|
- totalNetweight.add(li.getNetWeight());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ entity.setTotalNetweight(totalNetweight);
|
|
|
+ //总数量
|
|
|
+ entity.setTatolNumber(tatolNumber);
|
|
|
+ //总金额
|
|
|
+ entity.setTatolMoney(tatolMoney);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- try {
|
|
|
//String[] nameList = new String[]{"报关信息-报关单","报关信息-申报要素-成衣","报关信息-发票","报关信息-合同","报关信息-申报要素-面料","报关信息-装箱单"};
|
|
|
|
|
|
if(testName.equals("报关信息-报关单")){
|
|
|
-
|
|
|
TemplateExportParams params = new TemplateExportParams("D:\\"+testName+".xlsx");
|
|
|
-
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
-
|
|
|
+ //转map
|
|
|
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);
|
|
|
+ //集合转map
|
|
|
+ for(SyShippingOrderItem li:list){
|
|
|
+ Field[] fieldsList = li.getClass().getDeclaredFields();
|
|
|
+ Map<String, Object> mapList = new HashMap<String, Object>();
|
|
|
+ for (Field field : fieldsList) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ mapList.put(field.getName(), field.get(li));
|
|
|
+ }
|
|
|
+ listMap.add(mapList);
|
|
|
+ }
|
|
|
+ map.put("item", listMap);
|
|
|
|
|
|
- Workbook workbook = ExcelExportUtil.exportExcel(params, map);
|
|
|
- File savefile = new File("C:\\Users\\Mr_zeng\\Desktop\\"+testName+".xlsx");
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(params,map);
|
|
|
+ File savefile = new File("C:\\Users\\Mr_zeng\\Desktop\\");
|
|
|
if (!savefile.exists()) {
|
|
|
savefile.mkdirs();
|
|
|
}
|
|
|
- FileOutputStream fos = new FileOutputStream("C:\\Users\\Mr_zeng\\Desktop\\"+testName+".xlsx");
|
|
|
+ FileOutputStream fos = new FileOutputStream("C:\\Users\\Mr_zeng\\Desktop\\"+testName+"1.xlsx");
|
|
|
workbook.write(fos);
|
|
|
fos.close();
|
|
|
}
|
|
|
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setMessage("导出成功,请往桌面查看!");
|
|
|
+ result.setResult(entity);
|
|
|
+
|
|
|
}catch (Exception ex){
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
log.error("生成失败:" + ex.getMessage());
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- return entity;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|