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

📄 sellsaction.java

📁 医药供应链管理系统
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.captainli.struts.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.captainli.bean.MessageBean;
import com.captainli.bean.PurchaseBean;
import com.captainli.bean.RaidBean;
import com.captainli.bean.SellsBean;
import com.captainli.dboperation.BankDA;
import com.captainli.dboperation.MessageDA;
import com.captainli.dboperation.ProduitDA;
import com.captainli.dboperation.PurchaseDA;
import com.captainli.dboperation.RaidDA;
import com.captainli.dboperation.SellsDA;
import com.captainli.dboperation.intercourseDA;
import com.captainli.struts.form.SellsForm;

/** 
 * MyEclipse Struts
 * Creation date: 12-24-2008
 * 
 * XDoclet definition:
 * @struts.action path="/sells" name="sellsForm" scope="request" validate="true"
 */
public class SellsAction extends DispatchAction {
	/*
	 * Generated Methods
	 */

	/** 
	 * 出库单生成
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws IOException 
	 */
	public ActionForward addsells(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		//获得系统时间
		Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s_time=sdf.format(cal.getTime());
		
        PrintWriter out = response.getWriter();
		SellsForm sellsForm = (SellsForm) form;// TODO Auto-generated method stub
		SellsBean bean = new SellsBean();
		int p_id = new ProduitDA().showProId(sellsForm.getS_p_id().trim());
		
		bean.setS_no(sellsForm.getS_no());
		bean.setS_type(0);
		bean.setS_i_id(Integer.parseInt(sellsForm.getS_i_id()));
		bean.setS_l_id(Integer.parseInt(sellsForm.getS_l_id()));
		bean.setS_w_id(Integer.parseInt(sellsForm.getS_w_id()));
		bean.setS_p_id(p_id);
		bean.setS_u_id(Integer.parseInt(sellsForm.getS_u_id()));
		bean.setS_raidtime(request.getParameter("s_raidtime"));
		bean.setS_prodate(request.getParameter("s_prodate"));
		bean.setS_durdate(request.getParameter("s_durdate"));
		bean.setS_r_no(request.getParameter("r_id").toString());
		bean.setS_purprice(Double.valueOf(request.getParameter("s_purprice")));
		bean.setS_i_name(request.getParameter("s_i_name"));
		bean.setS_quantity(Integer.parseInt(sellsForm.getS_quantity()));
		bean.setS_price(sellsForm.getS_price());
		bean.setS_amount(sellsForm.getS_amount());
		bean.setS_actual(sellsForm.getS_actual());
		bean.setS_b_id(Integer.parseInt(sellsForm.getS_b_id()));
		bean.setS_note(sellsForm.getS_note());
		bean.setS_ver(Integer.parseInt(sellsForm.getS_ver()));
		bean.setS_time(s_time);
		if(sellsForm.getS_actual().equals(sellsForm.getS_amount())){
			bean.setS_mongeytype(true);
		}else{
			bean.setS_mongeytype(false);
		}
		
		//生成出库单
		new SellsDA().addSells(bean);
		//发送消息
		MessageBean mbean = new MessageBean();
		mbean.setM_content("销售出库单据编号为:"+sellsForm.getS_no()+"需要审核!");
		mbean.setM_reciever(Integer.parseInt(sellsForm.getS_ver()));
		mbean.setM_sender(Integer.parseInt(sellsForm.getS_l_id()));
		mbean.setM_time(s_time);
		mbean.setM_type(false);
		new MessageDA().addMessage(mbean);
		
		out.write("<script language=javascript>window.alert('出库提交成功!');window.location.href='sellsPages/sells_warehousing.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 出库单审核通过
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward sellsYes(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
        PrintWriter out = response.getWriter();
        int s_id = Integer.parseInt(request.getParameter("s_id"));
		//String s_no = request.getParameter("s_no");
		
        //获得出库单据数据
		SellsBean bean = new SellsDA().showAllByS_id(s_id);
		//修改出库单为通过状态
		new SellsDA().updateSellsS_type(s_id);
		//修改仓库中的批次信息
		//先得到批次信息
		RaidBean beanRaid = new RaidDA().showRaidByR_no(bean.getS_r_no());
		new RaidDA().updateRaid(bean.getS_quantity(), beanRaid.getR_id());
		double newAmount = (beanRaid.getR_quantity() - bean.getS_quantity())*beanRaid.getR_price();
		new RaidDA().updateRaid(newAmount, beanRaid.getR_id());
		//修改出库日期
		//获得系统时间
		Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s_time=sdf.format(cal.getTime());
        new SellsDA().updateSellsS_time(s_time, bean.getS_id());        
		//生成应收金额
		double i_yingshou = bean.getS_amount() - bean.getS_actual();
		//往来单位应收发生变化
		new intercourseDA().updateYingShou(bean.getS_i_id(), i_yingshou);
		//银行帐务发生变化,增加实际收到的钱
		new BankDA().updateBankMoney(bean.getS_b_id(), bean.getS_actual());
		
		out.write("<script language=javascript>window.alert('审核通过!');window.opener.location.reload();window.close();</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 出库单退回
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward sellsNo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
        PrintWriter out = response.getWriter();
		
        int s_id = Integer.parseInt(request.getParameter("s_id"));
        //获得出库单据数据
		SellsBean bean = new SellsDA().showAllByS_id(s_id);
		//修改出库单据为拒绝状态
		new SellsDA().updateSellsS_typeFalse(s_id);
		//单据删除
		new SellsDA().delSellsFalse(s_id);
		//发送消息
		//获得系统时间
		Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String m_time=sdf.format(cal.getTime());
        MessageBean mbean = new MessageBean();
		mbean.setM_content("销售出库单据编号为:"+bean.getS_no()+"拒绝通过!");
		mbean.setM_reciever(bean.getS_l_id());
		mbean.setM_sender(bean.getS_ver());
		mbean.setM_time(m_time);
		mbean.setM_type(false);
		new MessageDA().addMessage(mbean);
        
		out.write("<script language=javascript>window.alert('出库单据拒绝!');window.opener.location.reload();window.opener=null;window.close();</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 出库单据冲红
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward sellsChongHong(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
        PrintWriter out = response.getWriter();
		
        int s_id = Integer.parseInt(request.getParameter("s_id"));
        //获得出库单据数据
		SellsBean bean = new SellsDA().showAllByS_id(s_id);
		//修改出库单据为冲红状态
		new SellsDA().updateSellsChongHong(s_id);
		//生成应收金额
		double i_yingshou = bean.getS_amount() - bean.getS_actual();
		//银行帐务变化
		new BankDA().updateBankMoney(bean.getS_b_id(), 0 - bean.getS_actual());
		//往来单位应收变化
		new intercourseDA().updateYingShou(bean.getS_i_id(), 0 - i_yingshou);
		//批次信息修改
		RaidBean beanRaid = new RaidDA().showRaidByR_no(bean.getS_r_no());
		new RaidDA().updateRaid(0 - bean.getS_quantity(), beanRaid.getR_id());
		double newAmount = (beanRaid.getR_quantity() + bean.getS_quantity())*beanRaid.getR_price();
		new RaidDA().updateRaid(newAmount, beanRaid.getR_id());
        
		out.write("<script language=javascript>window.alert('单据冲红成功!');window.location.href='sellsPages/sells_record_frame.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 删除冲红的出库单据
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward delHongChong(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
        PrintWriter out = response.getWriter();
		
        int s_id = Integer.parseInt(request.getParameter("s_id"));
        new SellsDA().delSellsChongHong(s_id);
        
		out.write("<script language=javascript>window.alert('冲红单据删除成功!');window.location.href='sellsPages/sells_recordhongchong_frame.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
	/**
	 * 清空冲红的出库单据
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	public ActionForward delAll(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		//js乱码问题解决
		response.setContentType("text/html;UTF-8");
		response.setCharacterEncoding("UTF-8");
		
        PrintWriter out = response.getWriter();
		
        new SellsDA().delAllChongHong();
        
		out.write("<script language=javascript>window.alert('冲红单据清空成功!');window.location.href='sellsPages/sells_recordhongchong_frame.jsp';</script>");
		out.flush();
		out.close();
		return null;
	}
}

⌨️ 快捷键说明

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