UpSound.java 2.7 KB
package com.servlet.bkyld;

import java.io.IOException;

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

import com.service.bkyld.YLDExecuteService;
import com.vo.yld_Sound;

public class UpSound extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html");

		yld_Sound sh = new yld_Sound();
		YLDExecuteService serve=new YLDExecuteService();
		boolean re=true;
		sh.setDate(request.getParameter("date")+"-01");
		sh.setSound_n(Double.valueOf(request.getParameter("sound_n")));
		sh.setSound_n_note(request.getParameter("sound_n_note"));
		sh.setSound_s(Double.valueOf(request.getParameter("sound_s")));
		sh.setSound_s_note(request.getParameter("sound_s_note"));
		sh.setSound_w(Double.valueOf(request.getParameter("sound_w")));
		sh.setSound_w_note(request.getParameter("sound_w_note"));
		sh.setSound_e(Double.valueOf(request.getParameter("sound_e")));
		sh.setSound_e_note(request.getParameter("sound_e_note"));
		sh.setSound_n_night(Double.valueOf(request.getParameter("sound_n_night")));
		sh.setSound_n_night_note(request.getParameter("sound_n_night_note"));
		sh.setSound_s_night(Double.valueOf(request.getParameter("sound_s_night")));
		sh.setSound_s_night_note(request.getParameter("sound_s_night_note"));
		sh.setSound_w_night(Double.valueOf(request.getParameter("sound_w_night")));
		sh.setSound_w_night_note(request.getParameter("sound_w_night_note"));
		sh.setSound_e_night(Double.valueOf(request.getParameter("sound_e_night")));
		sh.setSound_e_night_note(request.getParameter("sound_e_night_note"));
		String id = request.getParameter("id");
		String date=request.getParameter("date");
//		System.out.println(id);
		if (id == null) {
			if (serve.selectSound(date).size()==0) {
				re=serve.insertSound(sh);
				//System.out.println(re);
			}
			else{
				re=true;
			}
			
		} else {
			sh.setAid(Integer.valueOf(id));
			re=serve.updataSound(sh);
		}
		if(!re){
			System.out.println(re);
			response.getWriter().print("{success:true,msg:'数据操作成功'}");
			response.getWriter().close();
		}else{
			response.getWriter().print("{success:true,msg:'数据操作失败,请检查时间和数据是否正确'}");
			response.getWriter().close();
		}
	}
}