You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

452 lines
17 KiB
C#

10 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Account.DAL.Chfee_Payapplication;
using DSWeb.Areas.Account.Models.Chfee_Payapplication;
using DSWeb.Areas.Account.DAL.Chfee_Invoicehexiao;
using DSWeb.Areas.Account.Models.Chfee_Invoicehexiao;
using DSWeb.MvcShipping.Helper;
using DSWeb.Areas.CommMng.DAL;
using System.Collections.Generic;
using HcUtility.Comm;
using System.IO;
using System.Text;
using DSWeb.Areas.CommMng.Models;
using System.Data;
using DSWeb.Common.DB;
using System.Web.UI.WebControls;
using DSWeb.MvcShipping.DAL.MsInfoClient;
using DSWeb.MvcShipping.Models.MsInfoClient;
using DSWeb.Areas.Account.DAL.Chfee_Invoiceapplication;
using static java.security.cert.CertPathValidatorException;
using DSWeb.Areas.Account.DAL.Chfee_payapplication;
namespace DSWeb.Areas.CommMng.Controllers
{
[JsonRequestBehavior]
public class DSWEBAPPInterfaceController : Controller
{
/// <summary>
/// 用于提供给app的查询入口
/// 需传入userid
/// </summary>
/// <param name="userid"></param>
/// <param name="condition"></param>
/// <returns></returns>
///
public class AppParam
{
public string userid { get; set; }
public string formname { get; set; }
public string isaudit { get; set; }
public string condition { get; set; }
public string showname { get; set; }
public string companyid { get; set; }
}
public class FeeAutidParam
{
public string USERID { get; set; }
public string COMPANYID { get; set; }
public string optype { get; set; }
public string IDs { get; set; }
public string ISSALEWORK { get; set; } = "0";
}
/// <summary>
/// 付费申请审批
/// </summary>
/// <returns></returns>
public ContentResult PayApplicationInterface()
{
StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8);
var strJson = new StringBuilder();
string line = null;
while (((line = sr.ReadLine())) != null)
{
strJson.Append(line);
}
var appparam = JsonConvert.Deserialize<AppParam>(strJson.ToString());
var cdc = new CommonDataContext();
string userid = appparam.userid;
string formname = appparam.formname;
string isaudit = appparam.isaudit;
string condition = appparam.condition;
var userlist = cdc.VW_user.Where(x => x.USERID == userid).ToList();
if (userlist == null || userlist.Count == 0)
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "没有找到用户" });
return new ContentResult() { Content = json0 };
}
var json = JsonConvert.Serialize(new { Success = true, Message = "未找到查询方法" });
var user = userlist[0];
if (formname == "查询列表")
{
var dataList = ChpayapplicationDAL.GetAuditDataList(condition, user.USERID, isaudit, user.SHOWNAME, user.COMPANYID, null);
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "查询明细")
{
var dataList = ChpayapplicationDAL.GetBodyAuditList(0, 9999, condition, "");
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "审批通过")
{
var audithead = ChpayapplicationDAL.GetData(condition, user.USERID, user.SHOWNAME, user.COMPANYID);
var bodyList = new List<ChPayapplication>() { audithead };
DBResult result = ChpayapplicationDAL.AuditList(bodyList, user.USERID);
return BasicDataRefDAL.GetContentResult(result);
}
if (formname == "驳回")
{
var audithead = ChpayapplicationDAL.GetData(condition, user.USERID, user.SHOWNAME, user.COMPANYID);
var bodyList = new List<ChPayapplication>() { audithead };
DBResult result = ChpayapplicationDAL.AuditBackList(bodyList, user.USERID, isaudit);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (formname == "查询业务")
{
//var dataList = ChpayapplicationDAL.GetBodyAuditList(0, 9999, condition, "");
//var billList = new List<v_op_bs_mb>();
//if (dataList != null && dataList.Count > 0) {
// var bsnoList= dataList.Select(s=>s.BSNO).Distinct().ToList();
// billList = cdc.v_op_bs.Where(x => bsnoList.Contains(x.BSNO)).ToList();
//}
return GetVOPBS(condition);
}
return new ContentResult() { Content = json };
}
public static ContentResult GetVOPBS(string BSNO) {
var cdc = new CommonDataContext();
var billList = cdc.v_op_bs.Where(x => x.BSNO == BSNO).ToList();
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = billList.ToList() });
return new ContentResult() { Content = json1 };
}
/// <summary>
/// 付费发票审核
/// </summary>
/// <returns></returns>
public ContentResult PayInvInterface()
{
StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8);
var strJson = new StringBuilder();
string line = null;
while (((line = sr.ReadLine())) != null)
{
strJson.Append(line);
}
var appparam = JsonConvert.Deserialize<AppParam>(strJson.ToString());
var cdc = new CommonDataContext();
string userid = appparam.userid;
string formname = appparam.formname;
string isaudit = appparam.isaudit;
string condition = appparam.condition;
var userlist = cdc.VW_user.Where(x => x.USERID == userid).ToList();
if (userlist == null || userlist.Count == 0)
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "没有找到用户" });
return new ContentResult() { Content = json0 };
}
var json = JsonConvert.Serialize(new { Success = true, Message = "未找到查询方法" });
var user = userlist[0];
if (formname == "查询列表")
{
var dataList = ChinvoicehexiaoDAL.GetAuditDataList(condition, user.USERID, isaudit, user.SHOWNAME, user.COMPANYID, null);
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "查询明细")
{
var dataList = ChinvoicehexiaoDAL.GetBodyList( condition, "");
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "审批通过")
{
var audithead = ChinvoicehexiaoDAL.GetData(condition);
var bodyList = new List<ChInvoicehexiao>() { audithead };
DBResult result = ChinvoicehexiaoDAL.AuditList(bodyList, user.USERID);
return BasicDataRefDAL.GetContentResult(result);
}
if (formname == "驳回")
{
var audithead = ChinvoicehexiaoDAL.GetData(condition);
var bodyList = new List<ChInvoicehexiao>() { audithead };
DBResult result = ChinvoicehexiaoDAL.AuditBackList(bodyList, user.USERID);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (formname == "查询业务")
{
return GetVOPBS(condition);
}
return new ContentResult() { Content = json };
}
/// <summary>
/// 往来单位审批
/// </summary>
/// <returns></returns>
public ContentResult InfoClientAuditInterface()
{
StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8);
var strJson = new StringBuilder();
string line = null;
while (((line = sr.ReadLine())) != null)
{
strJson.Append(line);
}
var appparam = JsonConvert.Deserialize<AppParam>(strJson.ToString());
var cdc = new CommonDataContext();
string userid = appparam.userid;
string formname = appparam.formname;
string isaudit = appparam.isaudit;
string condition = appparam.condition;
var userlist = cdc.VW_user.Where(x => x.USERID == userid).ToList();
if (userlist == null || userlist.Count == 0)
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "没有找到用户" });
return new ContentResult() { Content = json0 };
}
var json = JsonConvert.Serialize(new { Success = true, Message = "未找到查询方法" });
var user = userlist[0];
if (formname == "查询列表")
{
var dataList = MsInfoClientDAL.GetDataList(0,50,condition, user.USERID, user.SHOWNAME, user.COMPANYID, null);
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "审批通过")
{
var audithead = MsInfoClientDAL.GetData(condition);
var bodyList = new List<MsClient>() { audithead };
DBResult result = MsInfoClientDAL.IC_Audit(bodyList, user.USERID);
return BasicDataRefDAL.GetContentResult(result);
}
if (formname == "驳回")
{
var audithead = MsInfoClientDAL.GetData(condition);
var bodyList = new List<MsClient>() { audithead };
DBResult result = MsInfoClientDAL.IC_Auditback(bodyList, user.USERID);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
return new ContentResult() { Content = json };
}
/// <summary>
/// 发票申请审批
/// </summary>
/// <returns></returns>
public ContentResult InvApplicationAuditInterface()
{
StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8);
var strJson = new StringBuilder();
string line = null;
while (((line = sr.ReadLine())) != null)
{
strJson.Append(line);
}
var appparam = JsonConvert.Deserialize<AppParam>(strJson.ToString());
var cdc = new CommonDataContext();
string userid = appparam.userid;
string formname = appparam.formname;
string isaudit = appparam.isaudit;
string condition = appparam.condition;
var userlist = cdc.VW_user.Where(x => x.USERID == userid).ToList();
if (userlist == null || userlist.Count == 0)
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "没有找到用户" });
return new ContentResult() { Content = json0 };
}
var json = JsonConvert.Serialize(new { Success = true, Message = "未找到查询方法" });
var user = userlist[0];
if (formname == "查询列表")
{
var total = 0;
//var dataList = ChinvoiceapplicationDAL.GetDataList(0,50,condition,out total, user.USERID, user.SHOWNAME, user.COMPANYID, null);
var dataList = ChinvoiceapplicationDAL.GetAuditDataList(0, 50, condition,out total,user.USERID, isaudit, user.COMPANYID, null);
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "查询明细")
{
var dataList = ChinvoiceapplicationDAL.GetBodyList( condition, "");
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "查询附件")
{
//condition当中只写billno
var dataList = ChfeeFileDal.GetFileList(condition);
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json1 };
}
if (formname == "审批通过")
{
var total = 0;
var audithead = ChinvoiceapplicationDAL.GetDataList(0, 1, condition, out total, user.USERID, user.SHOWNAME, user.COMPANYID, null);
//var bodyList = new List<ChPayapplication>() { audithead };
DBResult result = ChinvoiceapplicationDAL.AuditList(audithead, user.COMPANYID, user.USERID);
return BasicDataRefDAL.GetContentResult(result);
}
if (formname == "驳回")
{
var total = 0;
var audithead = ChinvoiceapplicationDAL.GetDataList(0, 1, condition, out total, user.USERID, user.SHOWNAME, user.COMPANYID, null);
//var bodyList = new List<ChPayapplication>() { audithead };
DBResult result = ChinvoiceapplicationDAL.AuditBackList(audithead, user.USERID, isaudit);
return BasicDataRefDAL.GetContentResult(result);
}
if (formname == "查询业务")
{
return GetVOPBS(condition);
}
return new ContentResult() { Content = json };
}
/// <summary>
/// 发票申请审批
/// </summary>
/// <returns></returns>
public ContentResult DS7Search()
{
StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8);
var strJson = new StringBuilder();
string line = null;
while (((line = sr.ReadLine())) != null)
{
strJson.Append(line);
}
var appparam = JsonConvert.Deserialize<AppParam>(strJson.ToString());
var cdc = new CommonDataContext();
string userid = appparam.userid;
string formname = appparam.formname;
string customername = appparam.condition;
string showname = appparam.showname;
string companyid = appparam.companyid;
var userlist = cdc.VW_user.Where(x => x.USERID == userid).ToList();
if (userlist == null || userlist.Count == 0)
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "没有找到用户" });
return new ContentResult() { Content = json0 };
}
var json = JsonConvert.Serialize(new { Success = true, Message = "未找到查询方法" });
var user = userlist[0];
if (formname == "客户合同查询")
{
var total = 0;
//根据 userid companyid showname customername
//查询
var condition = $" LINKID in(select gid from info_client where shortname='{customername}')";
var dataList = MsInfoClientDAL.GetContractDataList(condition, "", userid, showname, companyid);
var contractidList = new List<string>();
if (dataList != null && dataList.Count > 0) {
contractidList = dataList.Select(s => s.GID).ToList();
}
//根据这些gid 查找Receipt_Doc当中Receipt_Doc.BSNO=info_client_contract.GID 的附件
var docList = cdc.Receipt_Doc.Where(x => contractidList.Contains(x.BSNO)).OrderBy(o => o.URL).ToList();
var json1 = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = docList.ToList() });
return new ContentResult() { Content = json1 };
}
return new ContentResult() { Content = json };
}
}
}