package com.engine.htsc.fundbusinesspay.web;

import com.engine.common.util.ServiceUtil;
import com.engine.htsc.fundbusinesspay.service.FundBusinessService;
import com.engine.htsc.fundbusinesspay.service.impl.FundBusinessServiceImpl;
import com.engine.htsc.fundbusinesspay.utils.FundBizUtil;
import com.engine.htsc.trip.util.AjaxResult;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

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

public class FundBusinessCubeAction {

	/**
	 * 建模资金付款更新数据导出状态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_paydetal set isread=1 where reqid=? ";
				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_paydetal set isexport=1 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_paydetal set isprint =1,printdate=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;
	}


}
