Browse Source

面辅料excel导入

huxy 2 years ago
parent
commit
be022ff0b0

+ 0 - 70
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/entity/SyPreAssembledPackingListItem.java

@@ -438,74 +438,4 @@ public class SyPreAssembledPackingListItem implements Serializable {
 		syPreAssembledPackingListId+ ","+
 		id.substring(0,id.length()-1);
 	}
-
-	public String getData() {
-		return "SyPreAssembledPackingListItem{" +
-				"id='" + id + '\'' +
-				", syPreAssembledPackingListId='" + syPreAssembledPackingListId + '\'' +
-				", syDeclarationElementsId='" + syDeclarationElementsId + '\'' +
-				", syDeclarationElementsItemId='" + syDeclarationElementsItemId + '\'' +
-				", syOrderDataId='" + syOrderDataId + '\'' +
-				", syOrderDataItemId='" + syOrderDataItemId + '\'' +
-				", acSetNo='" + acSetNo + '\'' +
-				", garmentFactory='" + garmentFactory + '\'' +
-				", hod='" + hod + '\'' +
-				", styleNo='" + styleNo + '\'' +
-				", poNo='" + poNo + '\'' +
-				", itemCode='" + itemCode + '\'' +
-				", distributionPoint='" + distributionPoint + '\'' +
-				", prepackSku='" + prepackSku + '\'' +
-				", size='" + size + '\'' +
-				", startingBoxNumber='" + startingBoxNumber + '\'' +
-				", endCaseNumber='" + endCaseNumber + '\'' +
-				", colour='" + colour + '\'' +
-				", piecesBox=" + piecesBox +
-				", boxNumber=" + boxNumber +
-				", total=" + total +
-				", planQuantity=" + planQuantity +
-				", actualPackingQty=" + actualPackingQty +
-				", netWeight=" + netWeight +
-				", totalNetWeight=" + totalNetWeight +
-				", grossWeight=" + grossWeight +
-				", totalGrossWeight=" + totalGrossWeight +
-				", outerBoxLength=" + outerBoxLength +
-				", outerBoxWidth=" + outerBoxWidth +
-				", outerBoxHeight=" + outerBoxHeight +
-				", totalVolume=" + totalVolume +
-				", netWeightToo=" + netWeightToo +
-				", unitPrice=" + unitPrice +
-				", totalPrice=" + totalPrice +
-				", sort=" + sort +
-				", createBy='" + createBy + '\'' +
-				", createTime=" + createTime +
-				", updateBy='" + updateBy + '\'' +
-				", updateTime=" + updateTime +
-				", pkOrg='" + pkOrg + '\'' +
-				", delFlag='" + delFlag + '\'' +
-				", memo=" + memo +
-				", withCode='" + withCode + '\'' +
-				", smallPo='" + smallPo + '\'' +
-				", inventoryName='" + inventoryName + '\'' +
-				", factoryUnitPrice=" + factoryUnitPrice +
-				", masterMetering='" + masterMetering + '\'' +
-				", groupId='" + groupId + '\'' +
-				", sizeTables=" + sizeTables +
-				", planSize='" + planSize + '\'' +
-				", inventoryCode='" + inventoryCode + '\'' +
-				", inventoryCcode='" + inventoryCcode + '\'' +
-				", isAdd=" + isAdd +
-				", supplierCode='" + supplierCode + '\'' +
-				", supplier='" + supplier + '\'' +
-				", ompoAccount='" + ompoAccount + '\'' +
-				", ompoId='" + ompoId + '\'' +
-				", ompoIdItem='" + ompoIdItem + '\'' +
-				", ymoney=" + ymoney +
-				", orderNumber='" + orderNumber + '\'' +
-				", remainingQuantity=" + remainingQuantity +
-				", excessQuantity=" + excessQuantity +
-				", salesman='" + salesman + '\'' +
-				", salesDepartment='" + salesDepartment + '\'' +
-				", spurOrSubOrder='" + spurOrSubOrder + '\'' +
-				'}';
-	}
 }

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListService.java

@@ -107,4 +107,5 @@ public interface ISyPreAssembledPackingListService extends IService<SyPreAssembl
 	public SyLetterDepositItem typeConversion(SyPreAssembledPackingListItem syPreAssembledPackingListItem);
 
 	public boolean add(List<SyPreAssembledPackingList> items);
+
 }

+ 2 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListServiceImpl.java

@@ -329,13 +329,13 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 		for(SyPreAssembledPackingListItem item :list){
 			sizes=syPreAssembledPackingListItemMapper.querySize(item.getSyDeclarationElementsId(),item.getGroupId());//获取尺码信息
 			int row=0;
-	/*		String planSize="";//计划各尺码数量
+			String planSize="";//计划各尺码数量
 			for (SizeTable size : sizes){
 				planSize=planSize+size.getSize()+":"+size.getQuantity().intValue()+"+";
 				size.setNum(++row);
 			}
 			planSize=planSize.substring(0,planSize.length()-1);
-			item.setPlanSize(planSize);*/
+			item.setPlanSize(planSize);
 			item.setSizeTables(sizes);
 		}
 		sizes=syPreAssembledPackingListItemMapper.querySizes(id,gqroupId);
@@ -501,12 +501,6 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 					syPreAssembledPackingList.setTotalGrossWeight(syPreAssembledPackingList.getTotalGrossWeight().add(item.getTotalGrossWeight()));
 					syPreAssembledPackingList.setTotalVolume(syPreAssembledPackingList.getTotalVolume().add(item.getTotalVolume()));
 					syPreAssembledPackingList.setTotalPrice(syPreAssembledPackingList.getTotalPrice().add(item.getTotalPrice()));
-					System.out.println("item.getTotal()"+item.getTotal());
-					System.out.println("item.getBoxNumber()"+item.getBoxNumber());
-					System.out.println("item.getTotalNetWeight()"+item.getTotalNetWeight());
-					System.out.println("item.getTotalGrossWeight()"+item.getTotalGrossWeight());
-					System.out.println("item.getTotalVolume()"+item.getTotalVolume());
-					System.out.println("item.getTotalPrice()"+item.getTotalPrice());
 					List<SizeTable> sizes=item.getSizeTables();//获取尺码表信息
 					item.setSyPreAssembledPackingListId(syPreAssembledPackingList.getId());//获取主表id
 					BigDecimal boxNumber1=item.getBoxNumber();//获取箱数

+ 20 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/controller/SyPackingListFabricController.java

@@ -28,6 +28,7 @@ import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo
 import org.jeecg.modules.openApi.entity.DxpDataPlan;
 import org.jeecg.modules.openApi.service.IDxpDataPlanService;
 import org.jeecg.modules.spapl.entity.SyPreAssembledPackingList;
+import org.jeecg.modules.splfi.vo.SyPackingListFabricVo;
 import org.jeecg.modules.splt.entity.SyPackingListTailoring;
 import org.jeecg.modules.splt.entity.SyPackingListTailoringItem;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -461,16 +462,26 @@ public class SyPackingListFabricController {
 	  for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
 		  MultipartFile file = entity.getValue();// 获取上传文件对象
 		  ImportParams params = new ImportParams();
-		  params.setTitleRows(2);
-		  params.setHeadRows(1);
+		  //params.setTitleRows(1);//注释后就能读取数据了
+		  //params.setHeadRows(1);
 		  params.setNeedSave(true);
 		  try {
-			  List<SyPackingListFabricPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyPackingListFabricPage.class, params);
-			  for (SyPackingListFabricPage page : list) {
-				  SyPackingListFabric po = new SyPackingListFabric();
-				  BeanUtils.copyProperties(page, po);
-				  syPackingListFabricService.saveMain(po);
+			  List<SyPackingListFabricVo> list = ExcelImportUtil.importExcel(file.getInputStream(), SyPackingListFabricVo.class, params);
+			  Map<String,SyPackingListFabric> maps=new HashMap<>();
+			  for (SyPackingListFabricVo vo : list) {
+				  SyPackingListFabricItem po =new SyPackingListFabricItem();
+				  BeanUtils.copyProperties(vo,po);
+			  	 if(!maps.containsKey(vo.getSyShippingDetailsId())){
+					 SyPackingListFabric main =new SyPackingListFabric();
+					 main.setGarmentFactory(vo.getTheGarmentFactory());//成衣工厂
+					 main.setSyPackingListFabricItem(new ArrayList<>());
+					 main.getSyPackingListFabricItem().add(po);
+					 maps.put(vo.getSyShippingDetailsId(),main);
+				 }else{
+			  	 	maps.get(vo.getSyShippingDetailsId()).getSyPackingListFabricItem().add(po);
+				 }
 			  }
+			  syPackingListFabricService.excelAdd(maps);
 			  return Result.OK("文件导入成功!数据行数:" + list.size());
 		  } catch (Exception e) {
 			  log.error(e.getMessage(),e);
@@ -545,7 +556,6 @@ public class SyPackingListFabricController {
 	 @ApiOperation(value="导出测试", notes="导出测试")
 	 @RequestMapping(value = "/exportXls")
 	 public Result<SyPackingListFabric> exportXls(HttpServletRequest request,HttpServletResponse response,String id) {
-		 //初始时间
 		 long startTime = System.currentTimeMillis();
 		 /*要计算的程序部分*/
 		 SyPackingListFabric syPackingListFabric=new SyPackingListFabric();
@@ -581,6 +591,8 @@ public class SyPackingListFabricController {
 				 Map<String, Object> map = new HashMap<String, Object>();
 				 map.put("entity", exportList2);//主表数据
 				 map.put("maps", exportList2.getSyPackingListFabricItem());//子表数据
+				 System.out.println(" map.get(maps)\t"+map.get("maps"));
+				 System.out.println(" map.get(maps).size()\t"+exportList2.getSyPackingListFabricItem().size());
 				 listMap.add(map);
 			 }
 			 maps.put(0,listMap);

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/entity/SyPackingListFabricItem.java

@@ -44,7 +44,7 @@ public class SyPackingListFabricItem implements Serializable {
 	@ApiModelProperty(value = "发运明细子表id")
 	private String syShippingDetailsItemId;
 	/**业务员*/
-    @Excel(name = "业务员", width = 15)
+    @Excel(name = "业务员 Merchandiser", width = 15)
 	@ApiModelProperty(value = "业务员")
 	private String salesman;
 	/**计划单号*/
@@ -142,7 +142,7 @@ public class SyPackingListFabricItem implements Serializable {
 	/**是否手册纱*/
     @Excel(name = "是否手册纱", width = 15)
 	@ApiModelProperty(value = "是否手册纱")
-	private int manualYarnFlag;
+	private Integer manualYarnFlag;
 	/**手册纱单价*/
     @Excel(name = "手册纱单价", width = 15)
 	@ApiModelProperty(value = "手册纱单价")

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/ISyPackingListFabricService.java

@@ -12,6 +12,7 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 面料装箱单
@@ -70,5 +71,7 @@ public interface ISyPackingListFabricService extends IService<SyPackingListFabri
 
 	String cancelSubmitBatch(String[] ids);
 
-    void saveList(List<SyPackingListFabric> syPackingListTailorings);
+    void saveList(List<SyPackingListFabric> syPackingListFabrics);
+
+    boolean excelAdd(Map<String,SyPackingListFabric> maps);
 }

+ 37 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricServiceImpl.java

@@ -490,6 +490,43 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		}
 	}
 
+	@Override
+	@Transactional
+	public boolean excelAdd(Map<String,SyPackingListFabric> maps) {
+		boolean bool=false;
+		try{
+			for (String str : maps.keySet()){
+				SimpleDateFormat sf= new SimpleDateFormat("yyMMdd");
+				QueryWrapper<SyPackingListFabric> queryWrapperCount=new QueryWrapper<>();
+				queryWrapperCount.like("create_time", new SimpleDateFormat("yyyy-MM-dd").format(System.currentTimeMillis()));
+				queryWrapperCount.eq("is_U8_Data","0");//判断是不是面料
+				queryWrapperCount.select("lpad(count(0)+1,6,0) as id");
+				String dateNo ="ML"+sf.format(System.currentTimeMillis())+getOne(queryWrapperCount).getId();//获取单据号
+				SyPackingListFabric syPackingListFabric =maps.get(str);
+				//syPackingListFabric.setGarmentFactory(str);//成衣工厂
+				syPackingListFabric.setDocumentNo(dateNo);//单据号
+				syPackingListFabric.setStatus("0");//状态
+				syPackingListFabric.setDelFlag("0");//是否删除
+				syPackingListFabricMapper.insert(syPackingListFabric);
+				List<SyPackingListFabricItem> items=syPackingListFabric.getSyPackingListFabricItem();
+				for(SyPackingListFabricItem item :items){
+					if(item.getPrice()!=null&&item.getActualDeclaredQuantity()!=null){
+						item.setTotalPrice(item.getPrice().subtract(item.getActualDeclaredQuantity()));//总价
+					}
+					item.setDelFlag("0");//是否删除
+					item.setSyPackingListFabricId(syPackingListFabric.getId());
+					syPackingListFabricItemMapper.insert(item);
+				}
+			}
+			bool=true;
+		}catch (Exception e){
+			e.printStackTrace();
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
+			return bool;
+		}
+		return bool;
+	}
+
 	//@Override
 	public void getU8Data(){
 		String[] arrs=syPackingListFabricItemMapper.getu8Data();//获取发运明细已提交的辅料

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/vo/SyPackingListFabricPage.java

@@ -23,6 +23,7 @@ import io.swagger.annotations.ApiModelProperty;
 public class SyPackingListFabricPage {
 	
 	/**id*/
+	@Excel(name = "主表ID", width = 15)
 	private String id;
 	/**创建人*/
   	@Excel(name = "创建人", width = 15)

+ 99 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/vo/SyPackingListFabricVo.java

@@ -0,0 +1,99 @@
+package org.jeecg.modules.splfi.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.modules.splfi.entity.SyPackingListFabricItem;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description: 面料装箱单
+ * @Author: jeecg-boot
+ * @Date:   2022-07-27
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="SyPackingListFabricVo对象", description="面料装箱单")
+public class SyPackingListFabricVo {
+
+	@Excel(name = "主表ID", width = 15)
+	private String syShippingDetailsId;
+	@Excel(name = "子表ID", width = 15)
+	private String syShippingDetailsItemId;
+	@Excel(name = "报关ID", width = 15)
+	private String elementsId;
+  	@Excel(name = "成衣工厂", width = 15)
+	private String theGarmentFactory;
+	@Excel(name = "业务员 Merchandiser", width = 15)
+	private String salesman;
+	@Excel(name = "计划单号", width = 15)
+	private String planLotNumber;
+	@Excel(name = "款号/Kimball", width = 15)
+	private String itemNumber;
+	@Excel(name = "颜色/Color", width = 15)
+	private String colour;
+	@Excel(name = "缸号/Batch no.", width = 15)
+	private String dyelotNumber;
+	@Excel(name = "项目/Item(存货编码)", width = 15)
+	private String inventoryCode;
+	@Excel(name = "存货名称(辅料名称)", width = 15)
+	private String inventoryName;
+	@Excel(name = "报关品名", width = 15)
+	private String declarationName;
+	@Excel(name = "成分/Composition", width = 15)
+	private String composition;
+	@Excel(name = "门幅/Width", width = 15)
+	private String width;
+	@Excel(name = "匹数/Rolls", width = 15)
+	private java.math.BigDecimal rolls;
+	@Excel(name = "毛重/GW/kg", width = 15)
+	private java.math.BigDecimal grossWeight;
+	@Excel(name = "净重/NW/kg", width = 15)
+	private java.math.BigDecimal netWeight;
+	@Excel(name = "染后重", width = 15)
+	private java.math.BigDecimal afterHeavy;
+	@Excel(name = "拷布重", width = 15)
+	private java.math.BigDecimal kaoClothWeight;
+	@Excel(name = "米数/Length/m ", width = 15)
+	private java.math.BigDecimal meter;
+	@Excel(name = "单价", width = 15)
+	private java.math.BigDecimal price;
+	@Excel(name = "克重/G", width = 15)
+	private String gramWeight;
+	@Excel(name = "供应商编码(染厂)", width = 15)
+	private String supplierCodeDyeingPlant;
+	@Excel(name = "供应商(染厂)", width = 15)
+	private String supplierDyeingPlant;
+	@Excel(name = "供应商编码(印厂)", width = 15)
+	private String supplierCodePrintingPlant;
+	@Excel(name = "供应商(印厂)", width = 15)
+	private String supplierPrintingPlant;
+	@Excel(name = "规格型号", width = 15)
+	private String specificationAndModel;
+	@Excel(name = "单位", width = 15)
+	private String masterMetering;
+	@Excel(name = "包装方式", width = 15)
+	private String mannerOfPacking;
+	@Excel(name = "处理方式", width = 15)
+	private String treatmentMethod;
+	@Excel(name = "是否手册纱", width = 15)
+	private Integer manualYarnFlag;
+	@Excel(name = "手册纱单价", width = 15)
+	private java.math.BigDecimal manualYarnUnitPrice;
+	@Excel(name = "手册纱占比%", width = 15)
+	private String manualYarnProportion;
+	@Excel(name = "柜号", width = 15)
+	private String containerNumber;
+	@Excel(name = "备注(U8)", width = 15)
+	private Object remarks1;
+	@Excel(name = "超发", width = 15)
+	private java.math.BigDecimal excessQuantity;
+	@Excel(name = "实际报关数量", width = 15)
+	private java.math.BigDecimal actualDeclaredQuantity;
+}