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.
DS7/DSWeb/Areas/Dispatch/Controllers/InterfaceController.cs

135 lines
4.7 KiB
C#

3 years ago
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.Dispatch.DB;
using DSWeb.Areas.Dispatch.Helper;
using DSWeb.Areas.Dispatch.Models;
using DSWeb.Dispatch.DAL;
using Newtonsoft.Json;
using NPOI;
using NPOI.HSSF.UserModel;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.Util;
using DSWeb.Interface;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsOpOtherDAL;
namespace DSWeb.Areas.Dispatch.Controllers
{
public class InterfaceController : Controller
{
public class headinfo
{
public string ac { get; set; }
public string uid { get; set; }
public string skey { get; set; }
public string optype { get; set; }
public List<infoitem> mdata { get; set; }
}
public class infoitem {
public string GID { get; set; }
public string CORPCODE { get; set; }
}
[HttpGet]
public ActionResult GetInterface()
{
var json4 = JsonConvert.SerializeObject(
new { Success = false, Message = "没有找到接口" });
return new ContentResult() { Content = json4 };
}
[HttpPost]
public ActionResult PostInterface()
{
try
{
StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8);
var strJson = new StringBuilder();
string line = null;
while ((line = sr.ReadLine()) != null)
{
strJson.Append(line);
}
var headinfo = JsonConvert.DeserializeObject<headinfo>(strJson.ToString());
var companylist = BasicDataRefDAL.GetcompanyList();
var corpid = companylist[0].gid;
var CUSTNOList = new List<string>();
//红柿子青银
if (headinfo.ac == "wmsfee_1") {
var = headinfo.mdata.Count();
#region 委托编号规则
for (var _i = 0; _i < ; _i++)
{
var isuse = false;
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='综合业务'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
isuse = true;
else
isuse = MsBaseInfoDAL.GetRuleUse("委托编号", "6");
if (companylist.Exists(x => x.code == headinfo.mdata[_i].CORPCODE))
{
corpid = companylist.First(x => x.code == headinfo.mdata[_i].CORPCODE).gid;
}
else {
var json = JsonConvert.SerializeObject(
new { Success = false, Message = "公司代码["+ headinfo.mdata[_i].CORPCODE + "]没有找到匹配的分公司" });
return new ContentResult() { Content = json };
}
if (isuse)
{
var CUSTNO = "";
if (billnoset.BILLTYPE != "")
{
CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), "", "", corpid);
}
else
CUSTNO = MsOpOtherDAL.getCodeRule("委托编号", 6, "CUSTNO", DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), "", corpid);
CUSTNOList.Add(CUSTNO);
}
}
#endregion
}
var interfaceresult = HeadClass.PostInterface(headinfo.ac, CUSTNOList, strJson.ToString());
BasicDataRefDAL.SaveLog(strJson.ToString(), "", "接口接收", "");
var json4 = JsonConvert.SerializeObject(
new { Success = interfaceresult.Success, Message = interfaceresult.Message });
return new ContentResult() { Content = json4 };
}
catch (Exception ex)
{
var json4 = JsonConvert.SerializeObject(
new { Success = false, Message = ex.Message });
return new ContentResult() { Content = json4 };
}
}
}
}