Dmc_update.java 7.3 KB
package com.servlet.bksh.DMC;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.bksh.SHDataBase;
import com.service.bksh.SHExecuteService;
import com.vo.SHDataManage;

/**
 * Servlet implementation class Dmc_selectdate
 */
public class Dmc_update extends HttpServlet {
	private static final long serialVersionUID = 1L;
      static SHDataBase sh = new SHDataBase(); 
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Dmc_update() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String a_idfromForm=request.getParameter("a_id");
		String date = request.getParameter("a_datetime");
		String cxwsjh_incod_eq=request.getParameter("cxwsjh_incod_eq");
		String a_incod_note=request.getParameter("a_incod_note");
		String cxwsjh_innh4n_eq=request.getParameter("cxwsjh_innh4n_eq");
		String a_innh4n_note=request.getParameter("a_innh4n_note");
		String cxwsjh_inph_eq=request.getParameter("cxwsjh_inph_eq");
		String a_inph_note=request.getParameter("a_inph_note");
		String cxwsjh_outcod_eq=request.getParameter("cxwsjh_outcod_eq");
		String a_outcod_note=request.getParameter("a_outcod_note");
		String cxwsjh_outnh4n_eq=request.getParameter("cxwsjh_outnh4n_eq");
		String a_outnh4n_note=request.getParameter("a_outnh4n_note");
		String cxwsjh_outph_eq=request.getParameter("cxwsjh_outph_eq");
		String a_outph_note=request.getParameter("a_outph_note");
		
		String cxwsjh_outzd_eq=request.getParameter("cxwsjh_outzd_eq");
		String a_outzd_note=request.getParameter("a_outzd_note");
		String cxwsjh_outzl_eq=request.getParameter("cxwsjh_outzl_eq");
		String a_outzl_note=request.getParameter("a_outzl_note");
		
		String cxwsjh_intp_eq=request.getParameter("cxwsjh_intp_eq");
		String a_intp_note=request.getParameter("a_intp_note");
		int a_id = Integer.parseInt(a_idfromForm);
		
		   List<String> recod= sh.Select_reason(date,"出水口","COD");
		   List<String> reph= sh.Select_reason(date,"出水口","PH值");
		   List<String> renh4n= sh.Select_reason(date,"出水口","氨氮");
		   List<String> reincod= sh.Select_reason(date,"进水口","COD");
		   List<String> reinph= sh.Select_reason(date,"进水口","PH值");
		   List<String> reinnh4n= sh.Select_reason(date,"进水口","氨氮");
		   
		   List<String> rezd= sh.Select_reason(date,"出水口","总氮");
		   List<String> rezl= sh.Select_reason(date,"出水口","总磷");
		   List<String> retp= sh.Select_reason(date,"进水口","总磷");
		   
		   
		   int cod = recod.size(); 
		   int ph = reph.size(); 
		   int nh4n = renh4n.size(); 
		   int incod = reincod.size(); 
		   int inph = reinph.size(); 
		   int innh4n = reinnh4n.size();
		   
		   
		   int zd = recod.size();		   
		   int zl = recod.size();
		   int in_tp = recod.size();
		   
		   
			if(cxwsjh_outcod_eq.equals("--")){
				if(cod==0)
				sh.insert_reason(date,"COD","出水口",a_outcod_note,a_id);
				else 
				sh.update_reason( "COD",a_outcod_note,a_id,"出水口");
			}
			else if(!cxwsjh_outcod_eq.equals("--")){
				sh.delete_reason(a_id,"出水口", "COD");
			}
			if(cxwsjh_outph_eq.equals("--")){
				if(ph==0)
				sh.insert_reason(date,"PH值","出水口",a_outph_note,a_id);
				else 
				sh.update_reason( "PH值",a_outph_note,a_id,"出水口");
			}
			else if(!cxwsjh_outph_eq.equals("--")){
				sh.delete_reason(a_id, "出水口","PH值");
			}
			if(cxwsjh_outnh4n_eq.equals("--")){
				if(nh4n==0)
				sh.insert_reason(date,"氨氮","出水口",a_outnh4n_note,a_id);
				else 
				sh.update_reason( "氨氮",a_outnh4n_note,a_id,"出水口");
			}
			else if(!cxwsjh_outnh4n_eq.equals("--")){
				sh.delete_reason(a_id,"出水口", "氨氮");
			}
			if(cxwsjh_incod_eq.equals("--")){
				if(incod==0)
				sh.insert_reason(date,"COD","进水口",a_incod_note,a_id);
				else 
				sh.update_reason( "COD",a_incod_note,a_id,"进水口");
			}
			else if(!cxwsjh_incod_eq.equals("--")){
				sh.delete_reason(a_id,"进水口", "COD");
			}
			if(cxwsjh_inph_eq.equals("--")){
				if(inph==0)
				sh.insert_reason(date,"PH值","进水口",a_inph_note,a_id);
				else 
				sh.update_reason( "PH值",a_inph_note,a_id,"进水口");
			}
			else if(!cxwsjh_inph_eq.equals("--")){
				sh.delete_reason(a_id,"进水口", "PH值");
		}
			
			if(cxwsjh_intp_eq.equals("--")){
				if(in_tp==0)
				sh.insert_reason(date,"总磷","进水口",a_intp_note,a_id);
				else 
				sh.update_reason( "总磷",a_intp_note,a_id,"进水口");
			}
			else if(!cxwsjh_inph_eq.equals("--")){
				sh.delete_reason(a_id,"进水口", "总磷");
		}
			
			
			if(cxwsjh_innh4n_eq.equals("--")){
				if(innh4n==0)
				sh.insert_reason(date,"氨氮","进水口",a_innh4n_note,a_id);
				else 
				sh.update_reason( "氨氮",a_innh4n_note,a_id,"进水口");
			}
			else if(!cxwsjh_innh4n_eq.equals("--")){
				sh.delete_reason(a_id,"进水口", "氨氮");
			}
			
			
			
			
			if(cxwsjh_outzd_eq.equals("--")){
				if(zd==0)
				sh.insert_reason(date,"总氮","出水口",a_outzd_note,a_id);
				else 
				sh.update_reason( "总氮",a_outzd_note,a_id,"出水口");
			}
			else if(!cxwsjh_outzd_eq.equals("--")){
				sh.delete_reason(a_id,"出水口", "总氮");
			}
			
			
			if(cxwsjh_outzl_eq.equals("--")){
				if(zl==0)
				sh.insert_reason(date,"总氮","出水口",a_outzl_note,a_id);
				else 
				sh.update_reason( "总氮",a_outzl_note,a_id,"出水口");
			}
			else if(!cxwsjh_outzl_eq.equals("--")){
				sh.delete_reason(a_id,"出水口", "总氮");
			}
			
		SHDataManage datavo=new SHDataManage();
		datavo.setA_id(a_id);
		datavo.setCxwsjh_incod_eq(cxwsjh_incod_eq);
		datavo.setA_incod_note(a_incod_note);
		datavo.setCxwsjh_innh4n_eq(cxwsjh_innh4n_eq);
		datavo.setA_innh4n_note(a_innh4n_note);
		datavo.setCxwsjh_inph_eq(cxwsjh_inph_eq);
		datavo.setA_inph_note(a_inph_note);
		datavo.setCxwsjh_outcod_eq(cxwsjh_outcod_eq);
		datavo.setA_outcod_note(a_outcod_note);
		datavo.setCxwsjh_outnh4n_eq(cxwsjh_outnh4n_eq);
		datavo.setA_outnh4n_note(a_outnh4n_note);
		datavo.setCxwsjh_outph_eq(cxwsjh_outph_eq);
		datavo.setA_outph_note(a_outph_note);
		
		datavo.setCxwsjh_outzd_eq(cxwsjh_outzd_eq);
		datavo.setA_outzd_note(a_outzd_note);
		datavo.setCxwsjh_outzl_eq(cxwsjh_outzl_eq);
		datavo.setA_outzl_note(a_outzl_note);
		
		datavo.setCxwsjh_intp_eq(cxwsjh_intp_eq);
		datavo.setA_intp_note(a_intp_note);
		
		SHExecuteService update=new SHExecuteService();
		update.getDataManageUpdate(datavo);
        response.getWriter().print("{success:true,msg:'◇修改成功◇'}");
        response.getWriter().close();
	}

}