Browse Source

面料的总价计算

huxy 2 years ago
parent
commit
1cf484ebfd

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

@@ -114,9 +114,12 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 			entity.setPurOrSubOrder(detailsItem.getPurOrSubOrder());//采购委外订单号
 			entity.setFactoryUnitPrice(detailsItem.getFactoryUnitPrice());//工厂单价
 			if(entity!=null&&entity.getMasterMetering().equals("KG")){//当单位为KG时
-				entity.setTotalPrice(entity.getNetWeight().subtract(entity.getPrice()));//净重*单价
+				entity.setTotalPrice(entity.getNetWeight().multiply(entity.getPrice()));//净重*单价
+				System.out.println("单价\t"+entity.getPrice());
+				System.out.println("净重\t"+entity.getNetWeight());
+				System.out.println("总价\t"+entity.getTotalPrice());
 			}else{
-				entity.setTotalPrice(entity.getActualDeclaredQuantity().subtract(entity.getPrice()));//实际报关数量*单价
+				entity.setTotalPrice(entity.getActualDeclaredQuantity().multiply(entity.getPrice()));//实际报关数量*单价
 			}
 			syShippingDetailsItemMapper.updateById(detailsItem);
 			syPackingListFabricItemMapper.insert(entity);
@@ -151,9 +154,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				s1.setExcessQuantity(entity.getInventoryQuantity().subtract(s1.getSurplusQuantity()));
 				syShippingDetailsItemMapper.updateById(s1);*/
 				if(entity!=null&&entity.getMasterMetering().equals("KG")){//当单位为KG时
-					entity.setTotalPrice(entity.getNetWeight().subtract(entity.getPrice()));//净重*单价
+					entity.setTotalPrice(entity.getNetWeight().multiply(entity.getPrice()));//净重*单价
 				}else{
-					entity.setTotalPrice(entity.getActualDeclaredQuantity().subtract(entity.getPrice()));//实际报关数量*单价
+					entity.setTotalPrice(entity.getActualDeclaredQuantity().multiply(entity.getPrice()));//实际报关数量*单价
 				}
 				entity.setId(null);
 				syPackingListFabricItemMapper.insert(entity);
@@ -318,7 +321,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 					SyPackingListFabric sy = JSONObject.toJavaObject(json, SyPackingListFabric.class);
 					QueryWrapper<SyPackingListFabric> queryWrapperCount=new QueryWrapper<>();
 					queryWrapperCount.like("create_time", new SimpleDateFormat("yyyy-MM-dd").format(System.currentTimeMillis()));//今天生成
-					queryWrapper.eq("is_U8_Data","1");//判断是不是辅料
+					queryWrapperCount.eq("is_U8_Data","1");//判断是不是辅料
 					queryWrapperCount.select("lpad(count(0)+1,6,0) as id");
 					String dateNo ="FL"+sf.format(System.currentTimeMillis())+getOne(queryWrapperCount).getId();//获取单据号
 					sy.setDocumentNo(dateNo);//单据号
@@ -385,9 +388,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 						sy1.setGroupId(sy1.getOrderNumber()+"-"+sy1.getInventoryCode()+"-"+sy1.getSize());
 						sy1.setSyPackingListFabricId(sy.getId());//获取主表id
 						if(sy1.getMasterMetering().equals("KG")){//当单位为KG时
-							sy1.setTotalPrice(sy1.getNetWeight().subtract(sy1.getPrice()));//净重*单价
+							sy1.setTotalPrice(sy1.getNetWeight().multiply(sy1.getPrice()));//净重*单价
 						}else{
-							sy1.setTotalPrice(sy1.getActualDeclaredQuantity().subtract(sy1.getPrice()));//实际报关数量*单价
+							sy1.setTotalPrice(sy1.getActualDeclaredQuantity().multiply(sy1.getPrice()));//实际报关数量*单价
 						}
 						sy1.setU8Pid(sy.getU8Id());
 						QueryWrapper<SyShippingDetailsItem> queryWrapper2 = new QueryWrapper<>();
@@ -511,7 +514,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 				List<SyPackingListFabricItem> items=syPackingListFabric.getSyPackingListFabricItem();
 				for(SyPackingListFabricItem item :items){
 					if(item.getPrice()!=null&&item.getActualDeclaredQuantity()!=null){
-						item.setTotalPrice(item.getPrice().subtract(item.getActualDeclaredQuantity()));//总价
+						item.setTotalPrice(item.getPrice().multiply(item.getActualDeclaredQuantity()));//总价
 					}
 					item.setDelFlag("0");//是否删除
 					item.setSyPackingListFabricId(syPackingListFabric.getId());
@@ -529,10 +532,162 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 
 	//@Override
 	public void getU8Data(){
+		SimpleDateFormat sf= new SimpleDateFormat("yyMMdd");
 		String[] arrs=syPackingListFabricItemMapper.getu8Data();//获取发运明细已提交的辅料
+		Map<String,List<String>> maps=new HashMap<>();
+		Map<String,List<String>> maps2=new HashMap<>();//获取主表符号
+		Map<String,String> maps3=new HashMap<>();//获取主表符号
 		for (String arr : arrs){
-			System.out.println("arr\t"+arr);
+			String account=arr.substring(0,3);
+			String id=arr.substring(3);
+			if(maps.containsKey(account)){
+				maps.get(account).add(id);
+			}else{
+				maps.put(account,new ArrayList<>());
+				maps.get(account).add(id);
+			}
+		}
+		for (String account : maps.keySet()){
+			String sql2="select " +
+					"b.AutoID as u8id ,\n" +
+					"b.id as u8pid,\n" +
+					"left(b.csocode,ISNULL(NULLIF(CHARINDEX('-',b.csocode)-1,-1),len(b.csocode))) as planLotNumber,\n" +
+					"b.csocode as orderNumber,\n" +
+					account+" as account,\n"+
+					"0  as delflag,\n" +
+					"f.AutoID  as isosid,\n" +
+					"b.iQuantity  as inventoryQuantity,\n" +
+					"b.cbMemo as remarks,\n" +
+					"b.cbMemo as memo,\n" +
+					"f.iTaxUnitPrice as price,\n"+
+					"d.cPersonName as salesman,\n" +
+					"b.cDefine22 as itemNumber,\n" +
+					"b.cFree6 as gramWeight,\n" +
+					"b.cFree1 as colour,\n" +
+					"b.cInvCode as inventoryCode,\n" +
+					"c.cInvName as inventoryName,\n" +
+					"c.cInvName as composition,\n" +
+					"b.cFree2 as size ,\n" +
+					"f.cDefine35 as rolls,\n" +
+					"e.cComUnitName as masterMetering,\n" +
+					"b.cFree4 as width,\n" +
+					"c.cInvStd  as specificationAndModel\n" +
+					"from rdrecord32 a \n" +
+					"left JOIN rdrecords32 b\n" +
+					"on a.id=b.id \n" +
+					"left join Inventory c\n" +
+					"on b.cInvCode=c.cInvCode\n" +
+					"LEFT JOIN Person  d\n" +
+					"ON d.cPersonCode = a.cPersonCode\n" +
+					"left join ComputationUnit e\n" +
+					"on c.cComunitCode=e.cComunitCode\n" +
+					"left join SO_SODetails f\n" +
+					"on b.iorderdid=f.iSOsID\n" +
+					"where " +
+					/*" cInvCCode not like '01%'\n" +
+					"and cInvCCode not like '02%'\n" +
+					"and cInvCCode not like '03%'\n" +
+					"and cInvCCode not like '04%'\n" +
+					"and cInvCCode not like '19%'\n" +
+					"and cCusCode='T020001' and\n" +*/
+					" f.AutoID in ("+maps.get(account).toString().substring(1,maps.get(account).toString().length()-1)+") ";
+			List<Map<String, Object>> list = new ArrayList<>();
+			//String groupId=oConvertUtils.getId();//获取id
+			if(account.equals("903")){
+				list = senYuDataSourceThree.queryForList(sql2);//903
+			}else{
+				list = senYuDataSourceTwo.queryForList(sql2);//902
+			}
+			List<JSONObject> jianSon = JsonChangeUtils.toJSONObject(list);
+			System.out.println("jianSon的长度\t"+jianSon.size());
+			for (JSONObject json1 :  jianSon){
+				SyPackingListFabricItem sy1 = JSONObject.toJavaObject(json1, SyPackingListFabricItem.class);
+				sy1.setU8Id(account+sy1.getU8Id());//获取账套号+id
+				sy1.setId(sy1.getU8Id());
+				sy1.setIsosid(sy1.getAccount()+sy1.getIsosid());//账套号+销售订单id
+				sy1.setActualDeclaredQuantity(sy1.getInventoryQuantity());//给报关数量赋值
+				sy1.setGroupId(sy1.getOrderNumber()+"-"+sy1.getInventoryCode()+"-"+sy1.getSize());
+
+				QueryWrapper<SyShippingDetailsItem> queryWrapper2 = new QueryWrapper<>();
+				queryWrapper2.eq("sy_order_data_item_id", sy1.getIsosid());
+				queryWrapper2.last("limit 1");
+				SyShippingDetailsItem syShippingDetailsItem=syShippingDetailsItemMapper.selectOne(queryWrapper2);
+				if(syShippingDetailsItem!=null){
+					String elementsId=syShippingDetailsItem.getElementsId();//申报要素id
+					if(oConvertUtils.isNotEmpty(elementsId)){
+						SyDeclarationElements syDeclarationElements=syDeclarationElementsMapper.selectById(elementsId);
+						if(syDeclarationElements!=null){
+							sy1.setDeclarationName(syDeclarationElements.getDeclarationName());//获取报关品名
+						}
+					}
+					sy1.setPrice(syShippingDetailsItem.getSalesUnitPrice());//销售单价
+					sy1.setSupplierCodePrintingPlant(syShippingDetailsItem.getSupplierCode());//染厂供应商编码
+					sy1.setSupplierPrintingPlant(syShippingDetailsItem.getSupplierCode());//染厂供应商
+					sy1.setSupplier(syShippingDetailsItem.getSupplier());//供应商编码
+					sy1.setSupplierCode(syShippingDetailsItem.getSupplierCode());//供应商
+					sy1.setSyShippingDetailsId(syShippingDetailsItem.getShippingDetailsId());//出运明细主表id
+					sy1.setSyShippingDetailsItemId(syShippingDetailsItem.getId());//出运明细子表id
+					sy1.setManualYarnUnitPrice(syShippingDetailsItem.getManualYarnUnitPrice());//手册纱单价
+					sy1.setManualYarnFlag(syShippingDetailsItem.getManualYarnFlag());//是否手册纱
+					sy1.setManualYarnProportion(syShippingDetailsItem.getManualYarnProportion());//手册纱占比
+					maps3.put(syShippingDetailsItem.getId(),syShippingDetailsItem.getGarmentFactory());//成衣工厂
+				}
+				if(sy1.getMasterMetering()!=null&&!sy1.getMasterMetering().equals("KG")){//当单位不为KG时
+					sy1.setTotalPrice(sy1.getActualDeclaredQuantity().multiply(sy1.getPrice()));//实际报关数量*单价
+				}else{
+					//单位为kg的物料需要填写净重才能计算
+				}
+				if(maps2.containsKey(account)){
+					maps2.get(account).add(sy1.getU8Pid());//获取主表id
+				}else {
+					maps2.put(account,new ArrayList<>());//初始化
+					maps2.get(account).add(sy1.getU8Pid());//获取主表id
+				}
+				//syPackingListFabricItemMapper.insert(sy1);//插入新数据
+			}
+		}
+		System.out.println("maps2\t"+maps2);
+		System.out.println("maps3\t"+maps3);
+		for (String account : maps2.keySet()) {
+			//先插主表数据,然后根据主表id查询子表数据再添加
+			String sql = "select     \n" +
+					"a.id u8Id,      \n" +
+					"'1' as is_U8_Data,    \n" +
+					"a.cMemo memo,    \n" +
+					"0 as delflag,    \n" +
+					"0 as status,    \n" +
+					"a.cMaker createby,    \n" +
+					"a.cMaker preparedBy,    \n" +
+					"a.cDefine10  exportInvoiceNo,    \n" +
+					"a.dnmaketime  preparedDate    \n" +
+					"from rdrecord32 a    \n" +
+					"where id in ("+maps2.get(account).toString().substring(1,maps2.get(account).toString().length()-1)+")";//根据最后一次拉去时间
+			List<Map<String, Object>> listMain = new ArrayList<>();
+			if (account.equals("903")) {
+				listMain = senYuDataSourceThree.queryForList(sql);//903
+			} else {
+				listMain = senYuDataSourceTwo.queryForList(sql);//902
+			}
+			if (listMain.size() == 0) {
+				continue;//退出本次循环
+			}
+			List<JSONObject> jsonObjects = JsonChangeUtils.toJSONObject(listMain);
+			System.out.println("jsonObjects的长度\t"+jsonObjects.size());
+			//String time=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());//获取现在时间
+			for (JSONObject json : jsonObjects) {
+				SyPackingListFabric sy = JSONObject.toJavaObject(json, SyPackingListFabric.class);
+				QueryWrapper<SyPackingListFabric> queryWrapperCount = new QueryWrapper<>();
+				queryWrapperCount.like("create_time", new SimpleDateFormat("yyyy-MM-dd").format(System.currentTimeMillis()));//获取今天时间
+				queryWrapperCount.eq("is_U8_Data", "1");//判断为辅料的数据
+				queryWrapperCount.select("lpad(count(0)+1,6,0) as id");
+				String dateNo = "FL" + sf.format(System.currentTimeMillis()) + getOne(queryWrapperCount).getId();//生成单据号
+				sy.setDocumentNo(dateNo);//单据号
+				sy.setU8Id(account + sy.getU8Id());
+				sy.setId(sy.getU8Id());
+				String pname = "";//成衣工厂
+				System.out.println("sy\t"+sy);
+				//syPackingListFabricMapper.insert(sy);//添加数据
+			}
 		}
-		System.out.println("arrs\n"+arrs);
 	}
 }