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.

766 lines
32 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using System.IO;
using System.Text;
using System.Data;
using DSWeb.MvcShipping.DAL.MsOpApplyDAL;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
using DSWeb.MvcShipping.DAL.MsCodeFtpSet;
using DSWeb.MvcShipping.DAL.MsOpSeaeEdiPortDAL;
using DSWeb.MvcShipping.DAL.MsOpApplyEdiPortDAL;
using DSWeb.Areas.Import.DAL.ReceiptDoc;
using DSWeb.Areas.Import.Models.ImportTrade;
using System.Collections;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpApplyController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult RWIndex()
{
return View();
}
public ActionResult HistryFeeIndex()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult FeeEdit()
{
return View();
}
public ActionResult ApplyFeeView()
{
return View();
}
public ActionResult FeeAmendEdit()
{
return View();
}
public ActionResult ReceiptEdit()
{
return View();
}
public ActionResult PiLiangFeeEdit()
{
return View();
}
public ActionResult PiLiangServiceFeeEdit()
{
return View();
}
public ActionResult LSEdit()
{
return View();
}
public ActionResult EditView()
{
return View();
}
public ActionResult ChuQu()
{//用于给货转时选择一个出区报关的报关业务
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = MsOpApplyDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListStr(string sort, string condition)
{
var dataListStr = MsOpApplyDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListSum(int start, int limit, string sort, string condition)
{
var dataList = MsOpApplyDAL.GetDataListSum(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataCtnList(int start, int limit, string sort, string condition)
{
var dataList = MsOpApplyDAL.GetDataCtnList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataCtnSumList(string sort, string condition)
{
var dataList = MsOpApplyDAL.GetDataCtnSumList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
MsOpApply head = null;
if (handle == "edit")
{
head = MsOpApplyDAL.GetData(condition);
}
if (head == null)
{
head = new MsOpApply();
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.BSTYPE = "2";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList(string BsNo)
{
var dataList = MsOpApplyDAL.GetBodyList(" BsNo='" + BsNo + "'");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetCtnBodyList(string condition, string sort)
{
var dataList = MsOpApplyDAL.GetCtnBodyList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetWmsIn(string wmsno)
{
var strSql = new StringBuilder();
if (wmsno != "")
{
strSql.Append("SELECT d.GID,g.GOODNAME+'-'+d.GOODSMODEL+'-'+d.CNTRNO NAMEMODEL,g.GOODNAME+'-'+d.CNTRNO GOODSNAME,d.GOODSMODEL,d.GOODSSTANDARD,GOODSSLICE GOODSPACK,d.GOODSPACKSTOCK,ISNULL((SELECT SUM(GOODSNUM) FROM op_apply_detail WHERE WMSIN_GID=d.GID),0) GOODAPPLYNUM FROM wms_in d ");
strSql.Append("left join wms w on (w.GID = d.ASSOCIATEDNO) ");
strSql.Append("left join code_goods g on (g.GID = d.GOODSNAMEID) ");
strSql.Append(" where d.GOODSPACKSTOCK>0 and w.WMSNO='" + wmsno + "'");
}
else {
strSql.Append("SELECT d.GID,g.GOODNAME+'-'+d.GOODSDETAILNAME NAMEMODEL,g.GOODNAME GOODSNAME,d.GOODSDETAILNAME GOODSMODEL,d.GOODSDETAILPKGS GOODSSTANDARD,0 GOODSPACK,0 GOODSPACKSTOCK,1000000 GOODAPPLYNUM FROM code_goods_detail d ");
strSql.Append("left join code_goods g on (g.GID = d.LINKGID) ");
}
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 10000, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult GetWmsNo(string constr)
{
var strSql = new StringBuilder();
strSql.Append("SELECT DISTINCT w.WMSNO FROM wms_in d ");
strSql.Append("left join wms w on (w.GID = d.ASSOCIATEDNO) ");
strSql.Append(" where 1=1 ");
if (!string.IsNullOrEmpty(constr))
{
strSql.Append(" AND " + constr);
}
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 100, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult GetBsCustomNo(string constr)
{
var strSql = new StringBuilder();
strSql.Append("SELECT DISTINCT CUSTOMNO FROM OP_APPLY ");
if (!string.IsNullOrEmpty(constr))
{
strSql.Append(" WHERE " + constr);
}
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 100, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string data2, string data3, string body, string ctnbody)
{
var headData = JsonConvert.Deserialize<MsOpApply>(data.Replace("}", "") + data2.Replace("{", ",").Replace("}", ",") + data3.Replace("{", ""));//需求编号SR2017081100003
var bodyList = JsonConvert.Deserialize<List<MsOpApplyDetail>>(body);
var ctnbodyList = JsonConvert.Deserialize<List<MsOpCtn>>(ctnbody);
var isPost = true;
var errorstr = "";
var iscreatecustno = false;
if (headData.CUSTNO =="")
{
var isuse = false;
var _r = MsOpApplyDAL.getCUSTNO(headData, Session["USERID"].ToString(), Session["SHOWNAME"].ToString(), Session["COMPANYID"].ToString());
if (_r.Success)
{
headData.CUSTNO = _r.Data.ToString();
iscreatecustno = true;
}
else {
var jsonRespose2 = new JsonResponse
{
Success = _r.Success,
Message = _r.Message,
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
else
{
//if (!isuse) {
// {
var ct = MsOpApplyDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND CUSTNO='" + headData.CUSTNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "委托编号";
}
// }
//}
}
if (headData.CORPID == ""||headData.CORPID ==null)
{
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
}
var mblreapeat = MsSysParamSetDAL.GetData("PARAMNAME='ApplyMblrepeat'");
if (mblreapeat.PARAMVALUE != "1" && headData.MBLNO != "" && headData.MBLNO != null)
{
var ct = MsOpApplyDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "主提单号";
}
}
if (headData.CUSTOMNO != "" && headData.CUSTOMNO != null)
{
var ct = MsOpApplyDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND CUSTOMNO='" + headData.CUSTOMNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "报关单号";
}
}
//if (headData.HBLNO != "" && headData.HBLNO != null)
//{
// var ct = MsOpApplyDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
// if (ct != 0)
// {
// isPost = false;
// errorstr = "分提单号";
// }
//}
if (opstatus == "add")
{
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
headData.BSDATE = DateTime.Now;
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.MASTERNO == null) { headData.MASTERNO = headData.BSNO; }
if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
if (headData.CLEARCUSTOMDATE == "") headData.CLEARCUSTOMDATE = null;
if (!string.IsNullOrEmpty(headData.BSCUSTOMNO))
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var PKGS = T_ALL_DA.GetStrSQL("PKGS", "select SUM(PKGS) PKGS from op_apply where CUSTOMNO='" + headData.BSCUSTOMNO + "'");
var BSPKGS = T_ALL_DA.GetStrSQL("BSPKGS", "select SUM(PKGS) BSPKGS from op_apply where BSCUSTOMNO='" + headData.BSCUSTOMNO + "' AND BSNO<>'"+headData.BSNO+"'");
if (PKGS == "") PKGS = "0";
if (BSPKGS == "") BSPKGS = "0";
var SPKGS = Convert.ToInt32(BSPKGS) + headData.PKGS;
if (Convert.ToInt32(PKGS) == SPKGS) {
headData.ISCUSTOMEND = "1";
}
else headData.ISCUSTOMEND = "0";
}
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
var BSNO = headData.BSNO;
if (result.Success == true)
{
result = MsOpApplyDAL.SaveDetail(headData, bodyList, Convert.ToString(Session["USERID"]));
result = MsOpApplyDAL.SaveCtnDetail(headData.BSNO, ctnbodyList, Convert.ToString(Session["USERID"]),true);
if (headData.CUSTOMNO != "")
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var blUpSQL1 = "update op_seai set CUSTOMNO='" + headData.CUSTOMNO + "' where BSNO='" + headData.MASTERNO + "' and (CUSTOMNO='' OR CUSTOMNO IS NULL) ";
bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1);
}
}
else
{
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpApplyDAL.GetData("BSNO='" + BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
if (iscreatecustno == true)
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
var jsonRespose = new JsonResponse { Success = false, Message =errorstr+"重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete(string data)
{
var head = JsonConvert.Deserialize<MsOpApply>(data);
var isfee = MsOpApplyDAL.GetFeeCount(head.BSNO);
if (isfee)
{
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var BSNO = head.BSNO;
var ct = MsOpApplyDAL.GetRdCount("BSNO='" + BSNO + "' AND exists (select 1 from op_apply_detail where bsno=op_apply.bsno and isnull(wmsin_gid,'')<>'')");
if (ct != 0)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "此票业务已出库,不能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
if (result.Success == true) { MsOpApplyDAL.DeleteDetail(head); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DeleteList(string data)
{
var headData = JsonConvert.Deserialize<List<MsOpApply>>(data);
var errstr = "";
if (headData != null)
{
foreach (var enumValue in headData)
{
var isfee = MsOpApplyDAL.GetFeeCount(enumValue.BSNO);
if (isfee)
{
if (errstr == "")
errstr = enumValue.CUSTNO;
else
errstr = errstr + "," + enumValue.CUSTNO;
}
else
{
//if (enumValue.BLTYPE == "拼箱主票")
//{
var ct = MsOpApplyDAL.GetRdCount("BSNO='" + enumValue.BSNO + "' AND exists (select 1 from op_apply_detail where bsno=op_apply.bsno and isnull(wmsin_gid,'')<>'')");
if (ct == 0)
{
var BSNO = enumValue.BSNO;
var modb = new ModelObjectDB();
DBResult result = modb.Delete(enumValue);
if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(enumValue.CUSTNO); }
if (result.Success == true) { MsOpApplyDAL.DeleteDetail(enumValue); }
}
else
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "此票业务已出库,不能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
}
}
if (errstr == "") errstr = "删除成功!";
else errstr = errstr + "存在费用,请先删除费用才能删除此票业务!";
var jsonRespose = new JsonResponse { Success = true, Message = errstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteCtnDetail(string data)
{
var head = JsonConvert.Deserialize<MsOpCtn>(data);
DBResult result = MsOpApplyDAL.DeleteCtnDetail(head, CookieConfig.GetCookie_UserId(Request));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetENTERPLIST()
{
var dataList = MsOpApplyDAL.GetENTERPLIST();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult PiliangServiceFee(string bill, string fee)
{
var billList = JsonConvert.Deserialize<List<MsOpApply>>(bill);
var feeList = JsonConvert.Deserialize<List<MsCodeServiceFeeTemplateDetail>>(fee);
DBResult result = MsOpApplyDAL.PiliangServiceFee(billList, feeList, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult modify(string data, string modifydata)
{
var bodyList = JsonConvert.Deserialize<List<MsOpApply>>(data);
var amodifydata = JsonConvert.Deserialize<MsOpApply>(modifydata);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpApplyDAL.Modify(bodyList, amodifydata, Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 舱单状态
public ContentResult Get56CDCSTATUSList(string mblno, string bsno)
{
var result = new DBResult();
result = MsOpApplyDAL.Get56CDCSTATUSList(mblno, bsno);
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message, totalCount = 10, data = result.Data });
return new ContentResult() { Content = json };
}
public ContentResult Refresh56CDCSTATUSList(string data)
{
var bodyList = JsonConvert.Deserialize<List<MsOpApply>>(data);
var result = new DBResult();
if (bodyList != null)
{
result = MsOpApplyDAL.RefreshManifestStatus(bodyList);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
//public ContentResult GetENTERPLIST()
//{
// var list = MsOpApplyDAL.GetENTERPLIST();
// var json = JsonConvert.Serialize(
// new { Success = true, Message = "查询成功", data = list.ToList() });
// return new ContentResult() { Content = json };
//}
#region EDI报文导出
#region 易航线 EDI导出
public ContentResult CreateELineEDIList(string bsnos, string mblno, string filetype, string filerole, int isbill, string carrier)
{
bsnos = bsnos.Replace(",", "','");
var headList = MsOpApplyDAL.GetDataList("OP_APPLY.BSNO IN ('" + bsnos + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//
var path = Server.MapPath("../../EDIFiles/ApplyEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
//
var result = new DBResult();
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='ELineEDI'", Convert.ToString(Session["COMPANYID"]));// AND CARRIERID='" + carrier + "'
if (ftpset.SENDCODE == "" || ftpset.RECEIVECODE == "")
{
result.Success = false;
result.Message = "EDI参数没有设置,请先设置EDI参数!";
}
else
{
var error = MsOpApplyEdiPortDAL.IsCreateEdiELineEDI(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "ELineEDI", isbill, 0, carrier, "", "", filetype, Convert.ToString(Session["COMPANYID"]));
if (error == "")
{
var filename = MsOpApplyEdiPortDAL.CreateEdiELineESI(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "ELineEDI", isbill, 0, carrier, "", "", filetype, Convert.ToString(Session["COMPANYID"]));
//
if (ftpset.SERVERIP != "" && ftpset.SERVERIP != null)
{
ArrayList alFile = new ArrayList();
List<ReceiptDocmb> rdList = ReceiptDocDAL.GetDocList("bsno='" + headList[0].BSNO.ToString() + "' and RECEIPTTYPE like '易航线%'");
if (rdList != null)
{
if (rdList.Count > 0)
{
foreach (var opFuJian in rdList)
{
var sDriect_URL = Server.MapPath(opFuJian.Driect_URL);
var filename2 = MsOpApplyEdiPortDAL.CreateEdiELineESI2(headList, path, mblno, ftpset, opFuJian, sDriect_URL);
alFile.Add(filename2);
}
}
}
//
//result = MsOpSeaeEdiPortDAL.FtpFile(filename, ftpset);
result = MsOpApplyEdiPortDAL.WebFile(filename, ftpset, alFile);
//
//var afilename = Path.GetFileName(filename);
//MsOpSeaeEdiPortDAL.InsertEdiLog(bsnos, "ELineEDI", filetype, carrier, ftpset.SERVERIP, afilename, "../../EDIFiles/ApplyEdi/" + afilename, Convert.ToString(Session["SHOWNAME"]));
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//foreach (var bill in headList)
//{
// if (filetype == "B")
// {
// var blUpSQL = " if (select CID from Op_SeaCover where bsno='" + bill.BSNO + "' AND COVERTITLE='发送SO') is null insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + bill.BSNO + "','发送SO','','" + Session["SHOWNAME"] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
// bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
// }
// else
// {
// var blUpSQL = " if (select CID from Op_SeaCover where bsno='" + bill.BSNO + "' AND COVERTITLE='发送SI') is null insert into Op_SeaCover(CID,BSNO,COVERTITLE,COVERCONTEXT,OPERATOR,OPTIME,ISSYS) values(NEWID(),'" + bill.BSNO + "','发送SI','','" + Session["SHOWNAME"] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','1')";
// bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
// }
//}
}
else
{
result.Success = false;
result.Message = "上传接口参数没有设置,请先设置上传接口参数!";
}
}
else
{
result.Success = false;
result.Message = error;
}
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveELineEDIList(string bsnos, string mblno, string filetype, string filerole, int isbill, string carrier)
{
bsnos = bsnos.Replace(",", "','");
var headList = MsOpApplyDAL.GetDataList("OP_APPLY.BSNO IN ('" + bsnos + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//
var path = Server.MapPath("../../EDIFiles/ApplyEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='ELineEDI'", Convert.ToString(Session["COMPANYID"]));// AND CARRIERID='" + carrier + "'
if (ftpset.SENDCODE == "" || ftpset.RECEIVECODE == "")
{
result.Success = false;
result.Message = "EDI参数没有设置,请先设置EDI参数!";
}
else
{
var error = MsOpApplyEdiPortDAL.IsCreateEdiELineEDI(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "ELineEDI", isbill, 0, carrier, "", "", filetype, Convert.ToString(Session["COMPANYID"]));
if (error == "")
{
string urlAll = "";
string filenameAll = "";
var filename = MsOpApplyEdiPortDAL.CreateEdiELineESI(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "ELineEDI", isbill, 0, carrier, "", "", filetype, Convert.ToString(Session["COMPANYID"]));
filename = Path.GetFileName(filename);
urlAll = "../../EDIFiles/ApplyEdi/" + filename;
filenameAll = filename;
//
List<ReceiptDocmb> rdList = ReceiptDocDAL.GetDocList("bsno='" + headList[0].BSNO.ToString() + "' and RECEIPTTYPE like '易航线%'");
if (rdList != null)
{
if (rdList.Count > 0)
{
foreach (var opFuJian in rdList)
{
var sDriect_URL = Server.MapPath(opFuJian.Driect_URL);
var filename2 = MsOpApplyEdiPortDAL.CreateEdiELineESI2(headList, path, mblno, ftpset, opFuJian, sDriect_URL);
filename2 = Path.GetFileName(filename2);
urlAll += "&" + "../../EDIFiles/ApplyEdi/" + filename2;
filenameAll += "&" + filename2;
}
}
}
//
result.Data = urlAll;// "../../EDIFiles/ApplyEdi/" + filename;
result.Success = true;
result.Message = filenameAll;//filename
//filename = Path.GetFileName(filename);
//result.Data = "../../EDIFiles/ApplyEdi/" + filename;
//result.Success = true;
//result.Message = filename;
}
else
{
result.Success = false;
result.Message = error;
}
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#endregion
}
}