package com.engine.htsc.subpayment.web;

import weaver.conn.RecordSet;
import weaver.general.Util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;

public class SubcomPaymentCubeAction {

	/**
	 * 建模子公司付款更新数据导出状态01
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/updateReadStatus")
	@Produces({MediaType.APPLICATION_JSON})
	public Map<String,Object> updateReadStatus(@Context HttpServletRequest request,@Context HttpServletResponse response){
		Map<String, Object> apidatas = new HashMap<>();
		try {
			String reqid = Util.null2String(request.getParameter("reqid"));
			if(!"".equals(reqid)){
				RecordSet rs = new RecordSet();
				String updateSql = " update uf_zgsfk set lcydzt=0 where requtid=? ";
				rs.executeUpdate(updateSql,reqid);
			}
			apidatas.put("success", true);
		}catch (Exception e){
			e.printStackTrace();
			apidatas.put("success",false);
			apidatas.put("errormsg",e.getMessage());
		}
		return apidatas;
	}


	/**
	 * 香港子公司付款更新数据导出状态01
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/updateReadStatus4HK")
	@Produces({MediaType.APPLICATION_JSON})
	public Map<String,Object> updateReadStatus4HK(@Context HttpServletRequest request,@Context HttpServletResponse response){
		Map<String, Object> apidatas = new HashMap<>();
		try {
			String reqid = Util.null2String(request.getParameter("reqid"));
			if(!"".equals(reqid)){
				RecordSet rs = new RecordSet();
				String updateSql = " update uf_xgclfk set lcydzt=0 where requtid=? ";
				rs.executeUpdate(updateSql,reqid);
			}
			apidatas.put("success", true);
		}catch (Exception e){
			e.printStackTrace();
			apidatas.put("success",false);
			apidatas.put("errormsg",e.getMessage());
		}
		return apidatas;
	}

	/**
	 * 建模资金付款更新数据导出状态01
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/updateExportStatus")
	@Produces({MediaType.APPLICATION_JSON})
	public Map<String,Object> updateExportStatus(@Context HttpServletRequest request,@Context HttpServletResponse response){
		Map<String, Object> apidatas = new HashMap<>();
		try {
			String ids = Util.null2String(request.getParameter("ids"));
			if(!"".equals(ids)){
				RecordSet rs = new RecordSet();
				String updateSql = " update uf_zgsfk set sfdc=0 where id in ("+ids+") ";
				rs.executeUpdate(updateSql);
			}
			apidatas.put("success", true);
		}catch (Exception e){
			e.printStackTrace();
			apidatas.put("success",false);
			apidatas.put("errormsg",e.getMessage());
		}
		return apidatas;
	}


	/**
	 * 香港子公司资金付款更新数据导出状态01
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/updateExportStatus4HK")
	@Produces({MediaType.APPLICATION_JSON})
	public Map<String,Object> updateExportStatus4HK(@Context HttpServletRequest request,@Context HttpServletResponse response){
		Map<String, Object> apidatas = new HashMap<>();
		try {
			String ids = Util.null2String(request.getParameter("ids"));
			if(!"".equals(ids)){
				RecordSet rs = new RecordSet();
				String updateSql = " update uf_xgclfk set sfdc=0 where id in ("+ids+") ";
				rs.executeUpdate(updateSql);
			}
			apidatas.put("success", true);
		}catch (Exception e){
			e.printStackTrace();
			apidatas.put("success",false);
			apidatas.put("errormsg",e.getMessage());
		}
		return apidatas;
	}



	/**
	 * 建模资金付款更新流程打印日期和状态01
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/updatePrintStatus")
	@Produces({MediaType.APPLICATION_JSON})
	public Map<String,Object> updatePrintStatus(@Context HttpServletRequest request,@Context HttpServletResponse response){
		Map<String, Object> apidatas = new HashMap<>();
		try {
			String ids = Util.null2String(request.getParameter("ids"));
			if(!"".equals(ids)){
				RecordSet rs = new RecordSet();
				String updateSql = " update uf_zgsfk set dyzt=0,dysj=to_char(sysdate,'YYYY-MM-DD HH24:MI') where id in ("+ids+") ";
				rs.executeUpdate(updateSql);
			}
			apidatas.put("success", true);
		}catch (Exception e){
			e.printStackTrace();
			apidatas.put("success",false);
			apidatas.put("errormsg",e.getMessage());
		}
		return apidatas;
	}


	/**
	 * 香港子公司资金付款更新流程打印日期和状态01
	 * @param request
	 * @param response
	 * @return
	 */
	@POST
	@Path("/updatePrintStatus4HK")
	@Produces({MediaType.APPLICATION_JSON})
	public Map<String,Object> updatePrintStatus4HK(@Context HttpServletRequest request,@Context HttpServletResponse response){
		Map<String, Object> apidatas = new HashMap<>();
		try {
			String ids = Util.null2String(request.getParameter("ids"));
			if(!"".equals(ids)){
				RecordSet rs = new RecordSet();
				String updateSql = " update uf_xgclfk set dyzt=0,dysj=to_char(sysdate,'YYYY-MM-DD HH24:MI') where id in ("+ids+") ";
				rs.executeUpdate(updateSql);
			}
			apidatas.put("success", true);
		}catch (Exception e){
			e.printStackTrace();
			apidatas.put("success",false);
			apidatas.put("errormsg",e.getMessage());
		}
		return apidatas;
	}


}
