|  | @@ -51,6 +51,7 @@ import org.jeecg.modules.splfi.service.ISyPackingListFabricService;
 | 
											
												
													
														|  |  import org.jeecg.modules.splfi.vo.SyPackingListFabricPage;
 |  |  import org.jeecg.modules.splfi.vo.SyPackingListFabricPage;
 | 
											
												
													
														|  |  import org.jeecg.modules.splt.entity.SyPackingListTailoring;
 |  |  import org.jeecg.modules.splt.entity.SyPackingListTailoring;
 | 
											
												
													
														|  |  import org.jeecg.modules.splt.entity.SyPackingListTailoringItem;
 |  |  import org.jeecg.modules.splt.entity.SyPackingListTailoringItem;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.modules.splt.mapper.SyPackingListTailoringItemMapper;
 | 
											
												
													
														|  |  import org.jeecg.modules.splt.mapper.SyPackingListTailoringMapper;
 |  |  import org.jeecg.modules.splt.mapper.SyPackingListTailoringMapper;
 | 
											
												
													
														|  |  import org.jeecg.modules.system.entity.SysUser;
 |  |  import org.jeecg.modules.system.entity.SysUser;
 | 
											
												
													
														|  |  import org.jeecg.modules.system.mapper.SysUserMapper;
 |  |  import org.jeecg.modules.system.mapper.SysUserMapper;
 | 
											
										
											
												
													
														|  | @@ -1203,6 +1204,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 | 
											
												
													
														|  |  	@Resource
 |  |  	@Resource
 | 
											
												
													
														|  |  	private SyPackingListTailoringMapper syPackingListTailoringMapper;//成衣mapper
 |  |  	private SyPackingListTailoringMapper syPackingListTailoringMapper;//成衣mapper
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +	@Resource
 | 
											
												
													
														|  | 
 |  | +	private SyPackingListTailoringItemMapper syPackingListTailoringItemMapper;//成衣子表mapper
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  	@Resource
 |  |  	@Resource
 | 
											
												
													
														|  |  	private PurchaseWarehousingMapper purchaseWarehousingMapper;//采购入库表
 |  |  	private PurchaseWarehousingMapper purchaseWarehousingMapper;//采购入库表
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2870,6 +2874,375 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 | 
											
												
													
														|  |  		return "推送成功";
 |  |  		return "推送成功";
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	/**
 | 
											
												
													
														|  | 
 |  | +	 * 合并批量推送销售发票单
 | 
											
												
													
														|  | 
 |  | +	 * @param
 | 
											
												
													
														|  | 
 |  | +	 * @return
 | 
											
												
													
														|  | 
 |  | +	 */
 | 
											
												
													
														|  | 
 |  | +	@Override
 | 
											
												
													
														|  | 
 |  | +	@DS("multi-two")
 | 
											
												
													
														|  | 
 |  | +	public String pushInvoiceTwo(List<SyPackingListFabric> listFabrics) {
 | 
											
												
													
														|  | 
 |  | +		List<String> codes=getList2(listFabrics);//获取出库单号
 | 
											
												
													
														|  | 
 |  | +		System.out.println("面辅料查看出库单号\t"+codes);
 | 
											
												
													
														|  | 
 |  | +		if(codes.size()==0){
 | 
											
												
													
														|  | 
 |  | +			return "推送失败,未查询到对应的出库单号!";
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<String>> customers=getCustomers(codes);//key:供应商编码,value:出库单id
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<SyPackingListFabricItem>> listFabricItemMaps=getListFabricItemMaps(customers,listFabrics);//key:供应商编码,value:子表数据
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<SyPackingListFabric>> listFabricMaps=getListFabricMaps(customers,listFabrics);//key:供应商编码,value:主表数据
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<SyPackingListFabric>> codeMaps=new HashMap<>();//key:传入销售发票单id,value:主表数据
 | 
											
												
													
														|  | 
 |  | +		JSONArray jsonArrays1=new JSONArray();
 | 
											
												
													
														|  | 
 |  | +		String code=redisUtil.get("pushsno005").toString();//发票号
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		for (String customer : customers.keySet()){
 | 
											
												
													
														|  | 
 |  | +			SyPackingListFabric syPackingListFabric=listFabricMaps.get(customer).get(0);
 | 
											
												
													
														|  | 
 |  | +			List<SyPackingListFabricItem> listFabricItems=listFabricItemMaps.get(customer);
 | 
											
												
													
														|  | 
 |  | +			List<Map<String,Object>> invoices=getInvoices(customers.get(customer));
 | 
											
												
													
														|  | 
 |  | +			JSONObject  jsonObject1=new JSONObject();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			String orderNumber=listFabrics.get(0).getShippingOrderNumber().substring(0,syPackingListFabric.getShippingOrderNumber().indexOf("-"));
 | 
											
												
													
														|  | 
 |  | +			Map<String,Object> order=syPackingListTailoringMapper.getSoMainCode(syPackingListFabric.getRdrecord32Code());//随便哪一个做主表信息
 | 
											
												
													
														|  | 
 |  | +			code=org.jeecg.modules.system.util.oConvertUtils.addOne(code);
 | 
											
												
													
														|  | 
 |  | +			code=orderNumber+code.substring(code.indexOf("0"));
 | 
											
												
													
														|  | 
 |  | +			redisUtil.set("pushsno005", code);//采购委外入库单
 | 
											
												
													
														|  | 
 |  | +			codeMaps.put(code,listFabricMaps.get(customer));
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CVOUCHCODE",code.replaceAll("DZ",orderNumber));//发票号
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CMAKER","进出口平台管理员");//制单人
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CVERIFIER","进出口平台管理员");//审核人
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CACCID","103");//账套号
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CTYPE","专用");//发票类型
 | 
											
												
													
														|  | 
 |  | +			if(order.get("cCusCode").equals("T020001")){
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CTYPE","普通");//发票类型
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CGLTYPE","销售出库单");//上游单据
 | 
											
												
													
														|  | 
 |  | +			if (syPackingListFabric.getEndCustomer()!=null){
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CDEFINE11",syPackingListFabric.getEndCustomer().replace("&","(-)"));//最终客户
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("DDATE",syPackingListFabric.getTheFinalShippingDate().substring(0,10));//日期
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE4",syPackingListFabric.getTheFinalShippingDate());//最终船期
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE6",syPackingListFabric.getTheFinalShippingDate2());//合同日期
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE10",syPackingListFabric.getShippingOrderNumber());//托书号
 | 
											
												
													
														|  | 
 |  | +			if(syPackingListFabric.getSupplierCode()!=null){
 | 
											
												
													
														|  | 
 |  | +				String	venName=syPackingListTailoringMapper.getCvenName(syPackingListFabric.getSupplierCode());
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CDEFINE12",venName);//供应商全称
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CBUSTYPE",order.get("cBusType"));//业务类型
 | 
											
												
													
														|  | 
 |  | +			if(order.get("cBusType").toString().indexOf("采购")>-1){
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CPTCODE","01");
 | 
											
												
													
														|  | 
 |  | +			}else{
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CPTCODE","02");
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CCUSCODE",order.get("cCusCode"));//客户编码
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEPCODE",order.get("cDepCode"));//部门编码
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("SALETPYECODE",order.get("cSTCode"));//销售类型编码
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("IEXCHRATE",order.get("iExchRate"));//汇率
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CEXCH_NAME",order.get("cexch_name"));//币种名称
 | 
											
												
													
														|  | 
 |  | +			if(!order.get("cexch_name").equals("人民币")){//不为人民币
 | 
											
												
													
														|  | 
 |  | +				SimpleDateFormat sf1 = new SimpleDateFormat("yyyy-M-dd");
 | 
											
												
													
														|  | 
 |  | +				String dd="";
 | 
											
												
													
														|  | 
 |  | +				try {
 | 
											
												
													
														|  | 
 |  | +					dd = sf1.format(sf1.parse(syPackingListFabric.getTheFinalShippingDate()));
 | 
											
												
													
														|  | 
 |  | +				}catch (Exception e){
 | 
											
												
													
														|  | 
 |  | +					throw new JeecgBootException("最终船期转换异常");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				String rateSplit[] = dd.split("-");
 | 
											
												
													
														|  | 
 |  | +				Map<String, Object> rate= syShippingOrderMapper.queryU8Rate(rateSplit[0], rateSplit[1]);
 | 
											
												
													
														|  | 
 |  | +				if (rate==null||rate.size()==0){
 | 
											
												
													
														|  | 
 |  | +					throw new JeecgBootException("该船期查询不到汇率,请检查日期是否填错");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("IEXCHRATE",rate.get("nflat").toString());//汇率(如果传空,接口默认1)cPayCode
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			JSONArray jsonArrays=new JSONArray();
 | 
											
												
													
														|  | 
 |  | +			List<Object> autoIds=new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +			for (SyPackingListFabricItem item : listFabricItems){
 | 
											
												
													
														|  | 
 |  | +				JSONObject  jsonObject=new JSONObject();
 | 
											
												
													
														|  | 
 |  | +				if(item.getMasterMetering().equalsIgnoreCase("KG")){
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("IQUANTITY",item.getNetWeight());//净重
 | 
											
												
													
														|  | 
 |  | +				}else{
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("IQUANTITY",item.getActualDeclaredQuantity());//实际报关数量
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CINVCODE",item.getInventoryCode());//存货编码
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +				String istc2=item.getIsTc();
 | 
											
												
													
														|  | 
 |  | +				if (istc2!=null&&istc2.equals("1")){
 | 
											
												
													
														|  | 
 |  | +					if(item.getRemarks2()!=null){
 | 
											
												
													
														|  | 
 |  | +						item.setRemarks2(item.getRemarks2()+"TC证书");
 | 
											
												
													
														|  | 
 |  | +					}else{
 | 
											
												
													
														|  | 
 |  | +						item.setRemarks2("TC证书");
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CBATCH",item.getDyelotNumber());//批号-缸号
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CBMEMO",item.getRemarks2());//子表备注
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("DISAUTOIDCOL","AUTOID");//对应类型
 | 
											
												
													
														|  | 
 |  | +				boolean bool=true;
 | 
											
												
													
														|  | 
 |  | +				for (Map<String,Object> map : invoices){
 | 
											
												
													
														|  | 
 |  | +					if(Double.parseDouble(map.get("iQuantity").toString())==Double.parseDouble(jsonObject.get("IQUANTITY").toString())&&
 | 
											
												
													
														|  | 
 |  | +							map.get("cInvCode").toString().equalsIgnoreCase(item.getInventoryCode())&&!autoIds.contains(map.get("AutoID"))){
 | 
											
												
													
														|  | 
 |  | +						autoIds.add(map.get("AutoID"));
 | 
											
												
													
														|  | 
 |  | +						jsonObject.put("AUTOID_DIS",map.get("AutoID"));
 | 
											
												
													
														|  | 
 |  | +						////System.out.println("map\t"+map);
 | 
											
												
													
														|  | 
 |  | +						getcFree(jsonObject,map);
 | 
											
												
													
														|  | 
 |  | +						//invoices.remove(map);
 | 
											
												
													
														|  | 
 |  | +						bool=false;
 | 
											
												
													
														|  | 
 |  | +						break;
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				if(item.getMasterMetering()!=null&&item.getMasterMetering().equals("KG")){
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("CDEFINE23","千克");//报关单位
 | 
											
												
													
														|  | 
 |  | +				}else if(item.getMasterMetering()!=null&&item.getMasterMetering().equals("M")){
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("CDEFINE23","米");//报关单位
 | 
											
												
													
														|  | 
 |  | +				}else{
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("CDEFINE23",item.getDeclarationUnit());//报关单位
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CDEFINE31",item.getDeclarationName());//存货名称
 | 
											
												
													
														|  | 
 |  | +				String iTaxRate=syPackingListFabricItemMapper.getItaxRate(item.getOmpoIdItem());
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("iTaxRate","13.0000000000");//税率
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CWHCODE",syPackingListFabricItemMapper.getVencode(item.getSupplier()));//获取仓库编码
 | 
											
												
													
														|  | 
 |  | +				jsonArrays.add(jsonObject);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("DETAILList",jsonArrays);
 | 
											
												
													
														|  | 
 |  | +			jsonArrays1.add(jsonObject1);
 | 
											
												
													
														|  | 
 |  | +			Map<String,List<String>> maps=new HashMap<>();//key:客户编码-字符,value:主表id-数组 用于区分维度完成分组条件
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		text(jsonArrays1,"测试合并推送面辅料销售发票");
 | 
											
												
													
														|  | 
 |  | +//		System.out.println("102销售发票\t"+jsonArrays1);
 | 
											
												
													
														|  | 
 |  | +		JSONArray resturnJsonArrays = InterfaceConnUtils.doPost(jsonArrays1,"saleinvoice_import");//销售发票单
 | 
											
												
													
														|  | 
 |  | +		Map<String,String> codeMaps2 = result(resturnJsonArrays);
 | 
											
												
													
														|  | 
 |  | +		for (String code1 : codeMaps.keySet()){
 | 
											
												
													
														|  | 
 |  | +			List<SyPackingListFabric> listFabricList=codeMaps.get(code1);
 | 
											
												
													
														|  | 
 |  | +			if(!codeMaps2.containsKey(code1)){//循环中没有就退出
 | 
											
												
													
														|  | 
 |  | +				continue;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			for (SyPackingListFabric fabric : listFabricList){
 | 
											
												
													
														|  | 
 |  | +				if (codeMaps2.get(code1).indexOf("失败")>-1){
 | 
											
												
													
														|  | 
 |  | +					fabric.setSaleInvoiceError(codeMaps2.get(code1));
 | 
											
												
													
														|  | 
 |  | +				}else{
 | 
											
												
													
														|  | 
 |  | +					fabric.setSaleInvoiceCode(codeMaps2.get(code1));
 | 
											
												
													
														|  | 
 |  | +					fabric.setRecordingError(null);
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		return "推送成功";
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	/**
 | 
											
												
													
														|  | 
 |  | +	 * 合并批量推送采购发票单
 | 
											
												
													
														|  | 
 |  | +	 * @param
 | 
											
												
													
														|  | 
 |  | +	 * @return
 | 
											
												
													
														|  | 
 |  | +	 */
 | 
											
												
													
														|  | 
 |  | +	@Override
 | 
											
												
													
														|  | 
 |  | +	@DS("multi-one")
 | 
											
												
													
														|  | 
 |  | +	public String pushInvoiceOne(List<SyPackingListFabric> listFabrics) {
 | 
											
												
													
														|  | 
 |  | +		//删除入库单号记录
 | 
											
												
													
														|  | 
 |  | +		String account="101";
 | 
											
												
													
														|  | 
 |  | +		List<String> codes=getList3(listFabrics);//获取入库单号
 | 
											
												
													
														|  | 
 |  | +		System.out.println("面辅料查看入库单号  "+codes);
 | 
											
												
													
														|  | 
 |  | +		if(codes.size()==0){
 | 
											
												
													
														|  | 
 |  | +			return "无可推送数据!";
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<String>> customers=getSuppliers(listFabrics);//key:供应商编码,value:入库单单据号
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<SyPackingListFabricItem>> listFabricItemMaps=getListFabricItemMaps(customers,listFabrics);//key:供应商编码,value:子表数据
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<SyPackingListFabric>> listFabricMaps=getListFabricMaps(customers,listFabrics);//key:供应商编码,value:主表数据
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<SyPackingListFabric>> codeMaps=new HashMap<>();//key:传入销售发票单id,value:主表数据
 | 
											
												
													
														|  | 
 |  | +		JSONArray jsonArrays1=new JSONArray();
 | 
											
												
													
														|  | 
 |  | +		String code=redisUtil.get("pushsno002").toString();//发-票号
 | 
											
												
													
														|  | 
 |  | +		for (String customer : customers.keySet()){
 | 
											
												
													
														|  | 
 |  | +			SyPackingListFabric syPackingListFabric=listFabricMaps.get(customer).get(0);//面辅料主表
 | 
											
												
													
														|  | 
 |  | +			Map<String, Object> orderData=syPackingListTailoringMapper.getOmOrPo("po_pomain",
 | 
											
												
													
														|  | 
 |  | +					"cpoid=(select  top 1 cOrderCode from rdrecord01 where ccode='"+syPackingListFabric.getRdrecord32Code()+"')","poid");
 | 
											
												
													
														|  | 
 |  | +			if (orderData.size()==0){
 | 
											
												
													
														|  | 
 |  | +				getError(syPackingListFabric,account+"查询不到对应的采购订单");
 | 
											
												
													
														|  | 
 |  | +				throw new JeecgBootException(account+"查询不到对应的采购订单");
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			String orderNumber=listFabrics.get(0).getShippingOrderNumber().substring(0,syPackingListFabric.getShippingOrderNumber().indexOf("-"));
 | 
											
												
													
														|  | 
 |  | +			List<SyPackingListFabricItem> listTailoringItems=listFabricItemMaps.get(customer);
 | 
											
												
													
														|  | 
 |  | +			List<Map<String,Object>> invoices=getInvoices1(customers.get(customer));
 | 
											
												
													
														|  | 
 |  | +			JSONObject  jsonObject1=new JSONObject();
 | 
											
												
													
														|  | 
 |  | +			code=org.jeecg.modules.system.util.oConvertUtils.addOne(code);
 | 
											
												
													
														|  | 
 |  | +			code=orderNumber+code.substring(code.indexOf("0"));
 | 
											
												
													
														|  | 
 |  | +			redisUtil.set("pushsno002", code);//采购委外发-票单
 | 
											
												
													
														|  | 
 |  | +			codeMaps.put(code,listFabricMaps.get(customer));
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CVOUCHCODE",code);//发-票号 CBUSTYPE
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CMAKER","进出口平台管理员");//制单人
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CHANDLER","进出口平台管理员");//审核人
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CACCID",account);//账套号
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CTYPE","专用");//发-票类型
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CGLTYPE","入库单");//上游单据
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("DDATE",syPackingListFabric.getTheFinalShippingDate().substring(0,10));//装运期限
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE4",syPackingListFabric.getTheFinalShippingDate().substring(0,10));//最终船期
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE6",syPackingListFabric.getTheFinalShippingDate2().substring(0,10));//合同日期
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE10",syPackingListFabric.getShippingOrderNumber());//托书号
 | 
											
												
													
														|  | 
 |  | +			String venName=syPackingListTailoringMapper.getCvenName3(syPackingListFabric.getRdrecord32Code());
 | 
											
												
													
														|  | 
 |  | +			if (venName==null){
 | 
											
												
													
														|  | 
 |  | +				venName=syPackingListTailoringMapper.getCvenName4(syPackingListFabric.getRdrecord32Code());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CDEFINE12",venName);//供应商全称
 | 
											
												
													
														|  | 
 |  | +			if (orderData.containsKey("cPayCode")){
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CPAYCODE",orderData.get("cPayCode"));//付款条件编码
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if (orderData.containsKey("cBusType")){
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("CBUSTYPE",orderData.get("cBusType"));//业务类型
 | 
											
												
													
														|  | 
 |  | +				if(orderData.get("cBusType").toString().indexOf("采购")>-1){
 | 
											
												
													
														|  | 
 |  | +					jsonObject1.put("CPTCODE","01");
 | 
											
												
													
														|  | 
 |  | +				}else{
 | 
											
												
													
														|  | 
 |  | +					jsonObject1.put("CPTCODE","02");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("IEXCHRATE",orderData.get("nflat"));//汇率
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("CEXCH_NAME",orderData.get("cexchname"));//币种名称
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if(!orderData.get("cexchname").equals("人民币")){//不为人民币
 | 
											
												
													
														|  | 
 |  | +				SimpleDateFormat sf1 = new SimpleDateFormat("yyyy-M-dd");
 | 
											
												
													
														|  | 
 |  | +				String dd="";
 | 
											
												
													
														|  | 
 |  | +				try {
 | 
											
												
													
														|  | 
 |  | +					dd = sf1.format(sf1.parse(syPackingListFabric.getTheFinalShippingDate()));
 | 
											
												
													
														|  | 
 |  | +				}catch (Exception e){
 | 
											
												
													
														|  | 
 |  | +					getError(syPackingListFabric,account+"最终船期转换异常");
 | 
											
												
													
														|  | 
 |  | +					throw new JeecgBootException(account+"最终船期转换异常");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				String rateSplit[] = dd.split("-");
 | 
											
												
													
														|  | 
 |  | +				Map<String, Object> rate= syShippingOrderMapper.queryU8Rate(rateSplit[0], rateSplit[1]);
 | 
											
												
													
														|  | 
 |  | +				if (rate==null||rate.size()==0){
 | 
											
												
													
														|  | 
 |  | +					getError(syPackingListFabric,account+"该船期查询不到汇率,请检查日期是否填错");
 | 
											
												
													
														|  | 
 |  | +					throw new JeecgBootException(account+"该船期查询不到汇率,请检查日期是否填错");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject1.put("IEXCHRATE",rate.get("nflat").toString());//汇率(如果传空,接口默认1)cPayCode
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			JSONArray jsonArrays=new JSONArray();
 | 
											
												
													
														|  | 
 |  | +			List<Object> autoIds=new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +			BigDecimal dzMoney=new BigDecimal("0");//单证金额合计
 | 
											
												
													
														|  | 
 |  | +			BigDecimal u8Money=new BigDecimal("0");//u8金额合计
 | 
											
												
													
														|  | 
 |  | +			for (SyPackingListFabricItem item : listTailoringItems){
 | 
											
												
													
														|  | 
 |  | +				JSONObject  jsonObject=new JSONObject();
 | 
											
												
													
														|  | 
 |  | +				BigDecimal iquantity=new BigDecimal("0");
 | 
											
												
													
														|  | 
 |  | +				if(item.getMasterMetering().equalsIgnoreCase("KG")){
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("IQUANTITY",item.getNetWeight());//净重
 | 
											
												
													
														|  | 
 |  | +					iquantity=item.getNetWeight();
 | 
											
												
													
														|  | 
 |  | +				}else{
 | 
											
												
													
														|  | 
 |  | +					jsonObject.put("IQUANTITY",item.getActualDeclaredQuantity());//实际报关数量
 | 
											
												
													
														|  | 
 |  | +					iquantity=item.getActualDeclaredQuantity();
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("size",item.getSize());//尺码
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CINVCODE",item.getInventoryCode());//存货编码
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("POAUTOIDCOL","Autoid");//对应类型
 | 
											
												
													
														|  | 
 |  | +				String istc2=item.getIsTc();
 | 
											
												
													
														|  | 
 |  | +				if (istc2!=null&&istc2.equals("1")){
 | 
											
												
													
														|  | 
 |  | +					item.setMemo("TC证书");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CBMEMO",item.getMemo());//备注
 | 
											
												
													
														|  | 
 |  | +				for (Map<String,Object> map : invoices){
 | 
											
												
													
														|  | 
 |  | +					if(Double.parseDouble(map.get("iQuantity").toString())==Double.parseDouble(jsonObject.get("IQUANTITY").toString())&&
 | 
											
												
													
														|  | 
 |  | +							map.get("cInvCode").toString().equalsIgnoreCase(item.getInventoryCode())/*&&map.get("cFree2").equals(item.getSize())*/
 | 
											
												
													
														|  | 
 |  | +							&&!autoIds.contains(map.get("AutoID"))){
 | 
											
												
													
														|  | 
 |  | +						autoIds.add(map.get("AutoID"));
 | 
											
												
													
														|  | 
 |  | +						jsonObject.put("AUTOID_PO",map.get("AutoID"));
 | 
											
												
													
														|  | 
 |  | +						jsonObject.put("IORITAXCOST",item.getPrice());//改成使用报关单价
 | 
											
												
													
														|  | 
 |  | +						BigDecimal u8Price=new BigDecimal(jsonObject.get("IORITAXCOST").toString());
 | 
											
												
													
														|  | 
 |  | +						dzMoney=dzMoney.add(iquantity.multiply(u8Price).setScale(2,RoundingMode.HALF_UP));//单证合计
 | 
											
												
													
														|  | 
 |  | +						u8Money=u8Money.add(u8Price.multiply(iquantity).setScale(2, RoundingMode.HALF_UP));//单证合计
 | 
											
												
													
														|  | 
 |  | +						jsonObject.put("IORIMONEY",iquantity.multiply(u8Price).setScale(2, RoundingMode.HALF_UP));//改成使用报关单价*成衣参考单价
 | 
											
												
													
														|  | 
 |  | +						getcFree(jsonObject,map);
 | 
											
												
													
														|  | 
 |  | +						jsonObject.put("CDEFINE28",item.getSmallPo());//小po
 | 
											
												
													
														|  | 
 |  | +						break;
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CDEFINE23",item.getDeclarationUnit());//报关单位
 | 
											
												
													
														|  | 
 |  | +				jsonObject.put("CDEFINE33",item.getDeclarationName());//存货名称
 | 
											
												
													
														|  | 
 |  | +				jsonArrays.add(jsonObject);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			dzMoney=dzMoney.setScale(2, RoundingMode.HALF_UP);
 | 
											
												
													
														|  | 
 |  | +			if(dzMoney.compareTo(u8Money)!=0){
 | 
											
												
													
														|  | 
 |  | +				BigDecimal dividePrice =dzMoney.subtract(u8Money);
 | 
											
												
													
														|  | 
 |  | +				BigDecimal ioriMoney=new BigDecimal(jsonArrays.getJSONObject(jsonArrays.size()-1).get("IORIMONEY").toString());
 | 
											
												
													
														|  | 
 |  | +				jsonArrays.getJSONObject(jsonArrays.size()-1).put("IORIMONEY",ioriMoney.add(dividePrice));
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +//			jsonObject.put("IORIMONEY",item.getUnitPrice());//金额
 | 
											
												
													
														|  | 
 |  | +			jsonObject1.put("DETAILList",jsonArrays);
 | 
											
												
													
														|  | 
 |  | +			jsonArrays1.add(jsonObject1);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		text(jsonArrays1,"测试合并推送面辅料采购发票");
 | 
											
												
													
														|  | 
 |  | +		JSONArray resturnJsonArrays = InterfaceConnUtils.doPost(jsonArrays1,"purinvoice_import");//采购发-票单
 | 
											
												
													
														|  | 
 |  | +		Map<String,String> codeMaps2 = result(resturnJsonArrays,"采购发票",account);
 | 
											
												
													
														|  | 
 |  | +		for (String code1 : codeMaps.keySet()){
 | 
											
												
													
														|  | 
 |  | +			List<SyPackingListFabric> listFabricList=codeMaps.get(code1);
 | 
											
												
													
														|  | 
 |  | +			for (SyPackingListFabric fabric : listFabricList){
 | 
											
												
													
														|  | 
 |  | +				fabric.setRdrecord32Code(null);
 | 
											
												
													
														|  | 
 |  | +				if (codeMaps2.get(code1).indexOf("失败")>-1){
 | 
											
												
													
														|  | 
 |  | +					if(fabric.getSaleInvoiceError()==null){
 | 
											
												
													
														|  | 
 |  | +						fabric.setSaleInvoiceError(codeMaps2.get(code1));
 | 
											
												
													
														|  | 
 |  | +					}else{
 | 
											
												
													
														|  | 
 |  | +						fabric.setSaleInvoiceError(fabric.getSaleInvoiceError()+";"+codeMaps2.get(code1));
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}else{
 | 
											
												
													
														|  | 
 |  | +					if(fabric.getSaleInvoiceCode()==null){
 | 
											
												
													
														|  | 
 |  | +						fabric.setSaleInvoiceCode(codeMaps2.get(code1));
 | 
											
												
													
														|  | 
 |  | +					}else{
 | 
											
												
													
														|  | 
 |  | +						fabric.setSaleInvoiceCode(fabric.getSaleInvoiceCode()+";"+codeMaps2.get(code1));
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		return "推送成功";
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	/**
 | 
											
												
													
														|  | 
 |  | +	 * 采购发票
 | 
											
												
													
														|  | 
 |  | +	 * @param listTailorings
 | 
											
												
													
														|  | 
 |  | +	 * @return
 | 
											
												
													
														|  | 
 |  | +	 */
 | 
											
												
													
														|  | 
 |  | +	public Map<String,List<String>> getSuppliers(List<SyPackingListFabric> listTailorings){
 | 
											
												
													
														|  | 
 |  | +		Map<String,List<String>> mapLists=new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +		for (SyPackingListFabric tailoring : listTailorings){
 | 
											
												
													
														|  | 
 |  | +			if(tailoring.getRdrecord32Code()==null){
 | 
											
												
													
														|  | 
 |  | +				continue;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(mapLists.containsKey(tailoring.getSupplierCode())){
 | 
											
												
													
														|  | 
 |  | +				mapLists.get(tailoring.getSupplierCode()).add(tailoring.getRdrecord32Code());
 | 
											
												
													
														|  | 
 |  | +			}else{
 | 
											
												
													
														|  | 
 |  | +				List<String> list=new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +				list.add(tailoring.getRdrecord32Code());
 | 
											
												
													
														|  | 
 |  | +				mapLists.put(tailoring.getSupplierCode(),list);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		return mapLists;
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	// 101入库单记录
 | 
											
												
													
														|  | 
 |  | +	public List<Map<String,Object>> getInvoices1(List<String> codes){
 | 
											
												
													
														|  | 
 |  | +		List<Map<String,Object>> invoices=syPackingListTailoringItemMapper.getInvoice1(codes.toArray(new String[codes.size()]));
 | 
											
												
													
														|  | 
 |  | +		return invoices;
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	//获取报错原因
 | 
											
												
													
														|  | 
 |  | +	public void getError(SyPackingListFabric syPackingListFabric,String error){
 | 
											
												
													
														|  | 
 |  | +		if (syPackingListFabric.getSaleInvoiceError()==null){
 | 
											
												
													
														|  | 
 |  | +			syPackingListFabric.setSaleInvoiceError(error);
 | 
											
												
													
														|  | 
 |  | +		}else{
 | 
											
												
													
														|  | 
 |  | +			syPackingListFabric.setSaleInvoiceError(syPackingListFabric.getSaleInvoiceError()+";"+error);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	//回写报错
 | 
											
												
													
														|  | 
 |  | +	public Map<String,String> result(JSONArray jsonArray,String pushName,String account){
 | 
											
												
													
														|  | 
 |  | +		Map<String,String> codeMaps=new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +		for (int i=0;i<jsonArray.size();i++){
 | 
											
												
													
														|  | 
 |  | +			JSONObject jsonObject=jsonArray.getJSONObject(i);
 | 
											
												
													
														|  | 
 |  | +			if(jsonObject.get("Result").equals("F")){//获取发货单是否成功添加
 | 
											
												
													
														|  | 
 |  | +				//throw new JeecgBootException("账套"+account+"接口"+tableName+",原因"+ jsonObject.get("Description"));
 | 
											
												
													
														|  | 
 |  | +				codeMaps.put(jsonObject.get("ReceiptNo").toString(),account+"账套"+pushName+"接口推送失败原因:"+jsonObject.get("Description").toString());//key:传入的单号,value:失败的信息
 | 
											
												
													
														|  | 
 |  | +			}else{
 | 
											
												
													
														|  | 
 |  | +				codeMaps.put(jsonObject.get("ReceiptNo").toString(),account+pushName+"单号"+jsonObject.get("U8ReceiptNo").toString());//key:传入的单号,value:生成的单号
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		return codeMaps;//账套号-序号-生成的单号
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  	public Map<String,String> result(JSONArray jsonArray){
 |  |  	public Map<String,String> result(JSONArray jsonArray){
 | 
											
												
													
														|  |  		Map<String,String> codeMaps=new HashMap<>();
 |  |  		Map<String,String> codeMaps=new HashMap<>();
 | 
											
												
													
														|  |  		for (int i=0;i<jsonArray.size();i++){
 |  |  		for (int i=0;i<jsonArray.size();i++){
 | 
											
										
											
												
													
														|  | @@ -2965,6 +3338,29 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 | 
											
												
													
														|  |  		return ids;
 |  |  		return ids;
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +	public List<String> getList2(List<SyPackingListFabric> listFabrics){
 | 
											
												
													
														|  | 
 |  | +		List<String> ids=new ArrayList<>();//获取出库单号
 | 
											
												
													
														|  | 
 |  | +		for (SyPackingListFabric syPackingListFabric : listFabrics){
 | 
											
												
													
														|  | 
 |  | +			if(syPackingListFabric.getDocumentNo().substring(0,3).equals("102")){
 | 
											
												
													
														|  | 
 |  | +				ids.add(syPackingListFabric.getDocumentNo().substring(3));
 | 
											
												
													
														|  | 
 |  | +				syPackingListFabric.setRdrecord32Code(syPackingListFabric.getDocumentNo().substring(3));
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		return ids;
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	public List<String> getList3(List<SyPackingListFabric> listFabrics){
 | 
											
												
													
														|  | 
 |  | +		List<String> ids=new ArrayList<>();//获取出库单号
 | 
											
												
													
														|  | 
 |  | +		for (SyPackingListFabric syPackingListFabric : listFabrics){
 | 
											
												
													
														|  | 
 |  | +			if(syPackingListFabric.getDocumentNo().substring(0,3).equals("102")){
 | 
											
												
													
														|  | 
 |  | +				ids.add(syPackingListFabric.getDocumentNo().substring(3));
 | 
											
												
													
														|  | 
 |  | +				String rdrecord01Code=syPackingListTailoringItemMapper.getRdrecord01Code(syPackingListFabric.getDocumentNo().substring(3));
 | 
											
												
													
														|  | 
 |  | +				syPackingListFabric.setRdrecord32Code(rdrecord01Code);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		return ids;
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  	@Override
 |  |  	@Override
 | 
											
												
													
														|  |  	@Transactional(rollbackFor = Exception.class)
 |  |  	@Transactional(rollbackFor = Exception.class)
 | 
											
												
													
														|  |  	public RespUpdateVO saveSrmBill(SyPackingListFabric syPackingListFabric){
 |  |  	public RespUpdateVO saveSrmBill(SyPackingListFabric syPackingListFabric){
 |