⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 register_ok.java

📁 ERO系统.针对生产型、分销型、服务型企业等不同的行业特点
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
if(rs10.next()){
	double amount1=Double.parseDouble(amount[i])+rs10.getDouble("amount");

String sql101="update stock_balance_details_details set amount='"+amount1+"' where stock_name='"+reason+"' and product_ID='"+product_ID[i]+"' and serial_number='"+serial_number1+"'";
		stock_db.executeUpdate(sql101);

}else{

String sqlb10="insert into stock_balance_details_details(chain_id,chain_name,product_ID,product_name,amount,cost_price,subtotal,stock_ID,stock_name,max_capacity_amount,nick_name,serial_number,register_time) values('"+chain_id+"','"+chain_name+"','"+product_ID[i]+"','"+product_name[i]+"','"+amount[i]+"','"+cost_price[i]+"','"+subtotal+"','"+stock_ID[i]+"','"+reason+"','"+max_capacity_amount[i]+"','"+nick_name[i]+"','"+serial_number1+"','"+time+"')";
		stock_db.executeUpdate(sqlb10);

}
String sqlm10="select * from stock_balance_details_details_for_cost where stock_name='"+reason+"' and product_ID='"+product_ID[i]+"' and serial_number='"+serial_number1+"'";
ResultSet rsm10=stock_db.executeQuery(sqlm10);
if(rsm10.next()){
	double amount1=Double.parseDouble(amount[i])+rsm10.getDouble("amount");

String sqlm101="update stock_balance_details_details_for_cost set amount='"+amount1+"' where stock_name='"+reason+"' and product_ID='"+product_ID[i]+"' and serial_number='"+serial_number1+"'";
		stock_db.executeUpdate(sqlm101);

}else{

String sqln10="insert into stock_balance_details_details_for_cost(chain_id,chain_name,product_ID,product_name,amount,cost_price,subtotal,stock_ID,stock_name,max_capacity_amount,nick_name,serial_number,register_time) values('"+chain_id+"','"+chain_name+"','"+product_ID[i]+"','"+product_name[i]+"','"+amount[i]+"','"+cost_price[i]+"','"+subtotal+"','"+stock_ID[i]+"','"+reason+"','"+max_capacity_amount[i]+"','"+nick_name[i]+"','"+serial_number1+"','"+time+"')";
		stock_db.executeUpdate(sqln10);

}
}
		}
		}
	}
	String sql2="select * from stock_balance_details where product_ID='"+product_ID[i]+"' and stock_ID='"+stock_ID[i]+"'"; 
	ResultSet rs2=stock_db.executeQuery(sql2);
	if(rs2.next()){
		double amount2=rs2.getDouble("amount")+Double.parseDouble(amount[i]);
		double subtotal2=rs2.getDouble("subtotal")+Double.parseDouble(cost_price[i])*Double.parseDouble(amount[i]);
		double cost_price2=rs2.getDouble("cost_price");
		if(amount2!=0){
			cost_price2=subtotal2/amount2;
		}
		String sql3="update stock_balance_details set amount='"+amount2+"',subtotal='"+subtotal2+"',cost_price='"+cost_price2+"' where id='"+rs2.getString("id")+"'";
		stock_db.executeUpdate(sql3);
	}else{
		
		String sql10="insert into stock_balance_details(chain_id,chain_name,product_ID,product_name,amount,cost_price,subtotal,stock_ID,stock_name,max_capacity_amount,nick_name) values('"+chain_id+"','"+chain_name+"','"+product_ID[i]+"','"+product_name[i]+"','"+amount[i]+"','"+cost_price[i]+"','"+subtotal+"','"+stock_ID[i]+"','"+stock_name[i]+"','"+max_capacity_amount[i]+"','"+nick_name[i]+"')";
		stock_db.executeUpdate(sql10);
	}
	if(!reason.equals("生产入库")&&!reason.equals("委外入库")&&!reason.equals("采购入库")&&!reason.equals("生产领料")&&!reason.equals("销售出库")&&!reason.equals("库存初始")){
		String sql222="select * from stock_balance_details where product_ID='"+product_ID[i]+"' and stock_name='"+reason+"'"; 
	ResultSet rs222=stock_db.executeQuery(sql222);
	if(rs222.next()){
		double amount222=rs222.getDouble("amount")-Double.parseDouble(amount[i]);
		double subtotal222=rs222.getDouble("subtotal")+Double.parseDouble(cost_price[i])*Double.parseDouble(amount[i]);
		double cost_price222=rs222.getDouble("cost_price");
		if(amount222!=0){
			cost_price222=subtotal222/amount222;
		}
		String sql3="update stock_balance_details set amount='"+amount222+"',subtotal='"+subtotal222+"',cost_price='"+cost_price222+"' where id='"+rs222.getString("id")+"'";
		stock_db.executeUpdate(sql3);
	}else{
		double virtual_amount=-Double.parseDouble(amount[i]);
		double virtual_subtotal=-subtotal;
		String sql10="insert into stock_balance_details(chain_id,chain_name,product_ID,product_name,amount,cost_price,subtotal,stock_ID,stock_name) values('"+chain_id+"','"+chain_name+"','"+product_ID[i]+"','"+product_name[i]+"','"+virtual_amount+"','"+cost_price[i]+"','"+virtual_subtotal+"','','"+reason+"')";
		stock_db.executeUpdate(sql10);
	}
	}
double amount333=0.0d;
	double cost_price_sum333=0.0d;

	String sql333="select * from stock_balance_details where product_ID='"+product_ID[i]+"'";
	ResultSet rs333=stock_db.executeQuery(sql333);
	while(rs333.next()){amount333+=rs333.getDouble("amount");
	                     cost_price_sum333+=rs333.getDouble("subtotal");
	}
	double cost_price333=0.0d;

		
		if(amount333!=0){
		cost_price333=cost_price_sum333/amount333;
		}
String sql5="select * from stock_balance where product_ID='"+product_ID[i]+"'"; 
	ResultSet rs5=stock_db.executeQuery(sql5);
	if(rs5.next()){
		
		sql6="update stock_balance set amount='"+amount333+"',cost_price_sum='"+cost_price_sum333+"',cost_price='"+cost_price333+"',address_group='"+address_group+"' where id='"+rs5.getString("id")+"'";
		//out.println(sql6);
		stock_db.executeUpdate(sql6);
		String sql24="update design_file set real_cost_price='"+cost_price333+"' where product_ID='"+product_ID[i]+"'";
		stock_db.executeUpdate(sql24);
		String sql44 = "select * from design_config_public_char where kind='priceAlarm'";
 		ResultSet rs44=stock_db.executeQuery(sql44);
 		double rate=0.0d;
 		if(rs44.next()){
			rate=Double.parseDouble(rs44.getString("type_name"))/100;
		}
 		String sql45 = "select * from design_file where product_ID='"+product_ID[i]+"'";
 		ResultSet rs45=stock_db.executeQuery(sql45);
 		if(rs45.next()){
		 double price_odds=rs45.getDouble("cost_price")-cost_price333;
		 if(Math.abs(price_odds/rs45.getDouble("cost_price"))>=rate){
 		String sql46 = "update design_file set price_alarm_tag='1' where product_ID='"+product_ID[i]+"'";
 		stock_db.executeUpdate(sql46);
			}
					}
	}else{
		String sql7="insert into stock_balance(chain_id,chain_name,product_ID,product_name,amount,cost_price,cost_price_sum,address_group) values('"+chain_id+"','"+chain_name+"','"+product_ID[i]+"','"+product_name[i]+"','"+amount333+"','"+cost_price333+"','"+cost_price_sum333+"','"+address_group+"')";
		stock_db.executeUpdate(sql7);
		String sql25="update design_file set real_cost_price='"+cost_price333+"' where product_ID='"+product_ID[i]+"'";
		stock_db.executeUpdate(sql25);
		String sql44 = "select * from design_config_public_char where kind='priceAlarm'";
 		ResultSet rs44=stock_db.executeQuery(sql44);
 		double rate=0.0d;
 		if(rs44.next()){
			rate=Double.parseDouble(rs44.getString("type_name"))/100;
		}
 		String sql45 = "select * from design_file where product_ID='"+product_ID[i]+"'";
 		ResultSet rs45=stock_db.executeQuery(sql45);
 		if(rs45.next()){
		 double price_odds=rs45.getDouble("cost_price")-cost_price333;
		 if(Math.abs(price_odds/rs45.getDouble("cost_price"))>=rate){
 		String sql46 = "update design_file set price_alarm_tag='1' where product_ID='"+product_ID[i]+"'";
 		stock_db.executeUpdate(sql46);
			}
					}
	}
String sql11="select * from stock_pre_gathering where gather_ID='"+gather_ID+"' and product_ID='"+product_ID[i]+"' and stock_ID='"+stock_ID[i]+"'";
	ResultSet rs11=stock_db.executeQuery(sql11);
	if(rs11.next()){
		double amount1=Double.parseDouble(amount[i])+rs11.getDouble("gathered_amount");
		double subtotal5=rs11.getDouble("gathered_subtotal")+Double.parseDouble(cost_price[i])*Double.parseDouble(amount[i]);
		if(rs11.getDouble("amount")==amount1){
			String sql="update stock_pre_gathering set gathered_amount='"+amount1+"',ungather_amount='0',gathered_subtotal='"+subtotal5+"',gather_tag='1',gather_check_tag='0' where gather_ID='"+gather_ID+"' and product_ID='"+product_ID[i]+"' and stock_ID='"+stock_ID[i]+"'";
			stock_db.executeUpdate(sql);
		}else{
			double amount5=rs11.getDouble("amount")-amount1;
			String sql12="update stock_pre_gathering set gathered_amount='"+amount1+"',ungather_amount='"+amount5+"',gathered_subtotal='"+subtotal5+"',gather_check_tag='0' where gather_ID='"+gather_ID+"' and product_ID='"+product_ID[i]+"' and stock_ID='"+stock_ID[i]+"'";
			stock_db.executeUpdate(sql12);
		}
	}

	
	String cost_calculate_type="";
	String sqlc1="select * from design_file where product_ID='"+product_ID[i]+"'";
	ResultSet rsc1=stock_db.executeQuery(sqlc1);
	if(rsc1.next()){
		cost_calculate_type=rsc1.getString("cost_calculate_type");
	}
	if(cost_calculate_type.equals("移动加权平均")){
		String sqlc2="select * from stock_balance where product_ID='"+product_ID[i]+"'";
		ResultSet rsc2=stock_db.executeQuery(sqlc2);
		if(rsc2.next()){
			String sqlc3="update design_file set real_cost_price='"+rsc2.getDouble("cost_price")+"' where product_ID='"+product_ID[i]+"'";
			stock_db.executeUpdate(sqlc3);
		}
	}else if(cost_calculate_type.equals("计划价格")){
		String sqlc2="select * from design_file where product_ID='"+product_ID[i]+"'";
		ResultSet rsc2=stock_db.executeQuery(sqlc2);
		if(rsc2.next()){
			String sqlc3="update design_file set real_cost_price='"+rsc2.getDouble("cost_price")+"' where product_ID='"+product_ID[i]+"'";
			stock_db.executeUpdate(sqlc3);
		}
	}else if(cost_calculate_type.equals("先进先出")){
		String sqlc2="select * from stock_balance_details_details where product_ID='"+product_ID[i]+"' order by register_time";
		ResultSet rsc2=stock_db.executeQuery(sqlc2);
		if(rsc2.next()){
			String sqlc3="update design_file set real_cost_price='"+rsc2.getDouble("cost_price")+"' where product_ID='"+product_ID[i]+"'";
			stock_db.executeUpdate(sqlc3);
		}
	}else if(cost_calculate_type.equals("后进先出")){
		String sqlc2="select * from stock_balance_details_details where product_ID='"+product_ID[i]+"' order by register_time desc";
		ResultSet rsc2=stock_db.executeQuery(sqlc2);
		if(rsc2.next()){
			String sqlc3="update design_file set real_cost_price='"+rsc2.getDouble("cost_price")+"' where product_ID='"+product_ID[i]+"'";
			stock_db.executeUpdate(sqlc3);
		}
	}
	}
//************************************

	}
	}


	if(reason.equals("采购入库")){
		String sql5="update purchase_purchase set stock_gather_tag='2' where purchase_ID='"+reasonexact+"'"; 
		stock_db.executeUpdate(sql5);
	}

if(rsList.size()==0){
if(reason.equals("采购入库")){
String sql5="select * from purchase_details where purchase_ID='"+reasonexact+"' and provider_name='"+reasonexact_details+"'"; 
	ResultSet rs5=stock_db.executeQuery(sql5);
	if(rs5.next()){
		double amount3=rs5.getDouble("stock_gathered_amount")+amount4;
		double subtotal3=rs5.getDouble("gathered_cost_price_sum")+cost_price_sum;
		double cost_price3=subtotal3/amount3;
		String sql6="update purchase_details set stock_gathered_amount='"+amount3+"',gathered_cost_price_sum='"+subtotal3+"' where purchase_ID='"+reasonexact+"' and provider_name='"+reasonexact_details+"'";
		stock_db.executeUpdate(sql6);
	}
}
String sql18="select * from stock_gather where gather_ID='"+gather_ID+"'"; 
	ResultSet rs18=stock_db.executeQuery(sql18);
	if(rs18.next()){
		double amount5=rs18.getDouble("gathered_amount")+amount4;
		double subtotal5=rs18.getDouble("gathered_cost_price_sum")+cost_price_sum;
		double cost_price5=subtotal5/amount5;
		String sql19="update stock_gather set gathered_amount='"+amount5+"',gathered_cost_price_sum='"+subtotal5+"',cost_price='"+cost_price5+"',checker='"+register+"',check_time='"+register_time+"' where gather_ID='"+gather_ID+"'";
		stock_db.executeUpdate(sql19);
	}
if(reason.equals("采购入库")){
String sql55="select * from purchase_purchase where purchase_ID='"+reasonexact+"'"; 
	ResultSet rs55=stock_db.executeQuery(sql55);
	if(rs55.next()){
		double amount33=rs55.getDouble("stock_gathered_amount")+amount4;
		double subtotal33=rs55.getDouble("real_cost_price_sum")+cost_price_sum;
		//double cost_price3=subtotal3/amount3;
		String sql66="update purchase_purchase set stock_gathered_amount='"+amount33+"',real_cost_price_sum='"+subtotal33+"' where purchase_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql66);
	}
}
	String sql16="select * from stock_pre_gathering where gather_ID='"+gather_ID+"' and gather_tag!='1'";
	ResultSet rs16=stock_db.executeQuery(sql16);
	if(!rs16.next()){
		String sql17="update stock_gather set finish_time='"+time+"',gather_tag='2' where gather_ID='"+gather_ID+"'";
		stock_db.executeUpdate(sql17);
		
		String sql28="select * from stock_gather where reasonexact='"+reasonexact+"' and gather_tag!='2'"; 
		ResultSet rs28=stock_db.executeQuery(sql28);
		if(!rs28.next()){
			if(reason.equals("采购入库")){
		String sql19="update purchase_purchase set stock_gather_tag='3' where purchase_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql19);
		String sql21="select * from purchase_purchase where stock_gather_tag='3' and invoice_tag='3' and gather_tag='3' and check_tag='2' and purchase_ID='"+reasonexact+"'";
		ResultSet rs21=stock_db.executeQuery(sql21);
		if(rs21.next()){
		String sql23="update purchase_purchase set purchase_tag='2' where purchase_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql23);
		}
			}
			if(reason.equals("委外入库")){
		String sql19="update intrmanufacture_intrmanufacture set stock_gather_tag='3' where intrmanufacture_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql19);
		String sql21="select * from intrmanufacture_intrmanufacture where stock_gather_tag='3' and invoice_tag='3' and gather_tag='3' and check_tag='2' and intrmanufacture_ID='"+reasonexact+"'";
		ResultSet rs21=stock_db.executeQuery(sql21);
		if(rs21.next()){
		String sql23="update intrmanufacture_intrmanufacture set intrmanufacture_tag='2' where intrmanufacture_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql23);
		}
			}
		if(reason.equals("内部调入")){
		String sql19="update stock_transfer_gather set transfer_gather_tag='1',gather_tag='2' where gather_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql19);
			}
		if(reason.equals("采购放货")||reason.equals("赠送")||reason.equals("内部借领")||reason.equals("其他借领")){
		String sql19a="update stock_apply_gather set gather_tag='2' where gather_ID='"+reasonexact+"'";
		stock_db.executeUpdate(sql19a);
			}
		}
}


}else{
	Iterator ite=rsList.iterator();
	while(ite.hasNext()){
		String[] elem=(String[])ite.next();
		String sql = "insert into stock_workflow(config_id,object_ID,describe1,describe2,gathering_time) values ('"+elem[0]+"','"+gather_ID+"','"+elem[1]+"','"+elem[2]+"','"+gathering_time+"')" ;
		stock_db.executeUpdate(sql);
	}
}

response.sendRedirect("stock/gather/register_ok.jsp?finished_tag=0");

}
catch (Exception ex){
ex.printStackTrace();
}

}else{
response.sendRedirect("stock/gather/register_ok.jsp?finished_tag=1");
}
}else{
response.sendRedirect("stock/gather/register_ok.jsp?finished_tag=2");
}
stock_db.commit();
stock_db.close();
}else{
	response.sendRedirect("error_conn.htm");
}
}
catch (Exception ex){
ex.printStackTrace();
}
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -