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/MvcShipping/Controllers/MsOpApplyController.cs

1019 lines
42 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;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL;
using DSWeb.MvcShipping.DAL.MsCodeOpTemplate;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
using DSWeb.Common.DB;
using DSWeb.Areas.MvcShipping.Helper;
using DSWeb.SoftMng.BLL;
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";
head.ETPS_CATEGORY = "A";
head.CDNTYPE = 0;
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
private readonly DecListBLL lbll = new DecListBLL();
private readonly DecHeadBLL hbll = new DecHeadBLL();
public ContentResult GetOpseaiData(string handle, string condition)
{
MsOpApply_Opseai head = null;
if (handle == "edit")
{
head = AutoMapperHelper.MapTo<MsOpApply,MsOpApply_Opseai >( MsOpApplyDAL.GetData(condition));
var BodyList = MsOpApplyDAL.GetBodyList(" BsNo='" + head.BSNO + "'");
if (BodyList != null && BodyList.Count > 0)
{
head. = BodyList[0].GoodsName;
head. = BodyList[0].Price.ToString();
}
else
{
var decheadList = hbll.GetModelList(" BSNO='" + head.BSNO + "'");
if (decheadList != null && decheadList.Count > 0)
{
var dechead = decheadList[0];
var Declist = lbll.GetModelList(0, 99, "PID='" + dechead.GID + "'", String.Format("{0}", "CONVERT(int, gno)", ""));
if (Declist != null && Declist.Count > 0)
{
head. = Declist[0].GName;
head. = Declist[0].DeclPrice.ToString();
}
}
}
}
if (head == null)
{
head = new MsOpApply_Opseai();
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.BSTYPE = "2";
head.ETPS_CATEGORY = "A";
head.CDNTYPE = 0;
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetCopyData(string handle, string condition, string copyfee = "false")
{
MsOpApply head = null;
var oldhead = MsOpApplyDAL.GetData(condition);
var copyfieldlist = MsCodeOpTemplateDAL.GetCodeOpTemplateDetail(" LINKGID in (select top 1 GID from CODE_OP_TEMPLATE where BSTYPE='报关业务' and (op='" + CookieConfig.GetCookie_UserId(Request) + "' or ISPUBLIC='是') order by ISPUBLIC)");
if (copyfieldlist.Count == 0)
{
head = oldhead;
head.BSNO = "topapply" + Guid.NewGuid().ToString();
head.MASTERNO = "";
head.CUSTNO = "";
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
}
else
{
head.ACCDATE = DateTime.Now.ToString("yyyy-MM");
}
head.BSSTATUS = false;
head.FEESTATUS = false;
head.BSSTATUSREF = "未锁定";
head.FEESTATUSREF = "未锁定";
if (copyfee == "true")
{
//var feelist = MsChFeeDAL.GetAllDataList(condition);
var feelist = MsChFeeDAL.GetDataList(condition, 1, "op_apply", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (feelist != null)
{
for (int _i = 0; _i < feelist.Count; _i++)
{
feelist[_i].BsNo = "*";
}
MsChFeeDAL.SaveFee(feelist, head.BSNO, CookieConfig.GetCookie_UserId(Request));
}
}
}
else
{
if (head == null)
{
head = new MsOpApply();
head.BSNO = "topapply" + Guid.NewGuid().ToString();
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
}
else
{
head.ACCDATE = DateTime.Now.ToString("yyyy-MM");
}
var propArr = head.GetType().GetProperties();
foreach (var enumValue in copyfieldlist)
{
var prop = propArr.FirstOrDefault(p => p.Name.ToLower() == enumValue.FIELDNAME.ToLower());
if (prop != null)
{
prop.SetValue(head, oldhead.GetPropertyValue(enumValue.FIELDNAME));
}
}
if (copyfee == "true")
{
var feelist = MsChFeeDAL.GetAllDataList(condition);
if (feelist != null)
{
for (int _i = 0; _i < feelist.Count; _i++)
{
feelist[_i].BsNo = "*";
}
MsChFeeDAL.SaveFee(feelist, head.BSNO, CookieConfig.GetCookie_UserId(Request));
}
}
}
}
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) };
}
}
/// <summary>
/// 由解析软件触发 建立新报关业务 或返回现有报关业务的BSNO
/// </summary>
/// <param name="MBLNO"></param>
/// <param name="USERID"></param>
/// <param name="SHOWNAME"></param>
/// <param name="COMPANYID"></param>
/// <returns></returns>
public ContentResult NewApply(string MBLNO, string USERID) {
MsOpApply headData = null;
var cdc = new CommonDataContext();
var userinfo = cdc.VW_user.FirstOrDefault(x => x.USERID == USERID);
//var COMPANYID = userinfo
headData = MsOpApplyDAL.GetData($" MBLNO='{MBLNO}' ");
if (headData == null || headData.MBLNO=="")
{
//建立一个新报关业务
headData = new MsOpApply();
headData.BSNO = "topapply" + Guid.NewGuid().ToString();
headData.MASTERNO = headData.BSNO;
headData.MBLNO = MBLNO;
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
headData.BSDATE = DateTime.Now;
headData.DbOperationType = DbOperationType.DbotIns;
headData.CUSTOMDATE = null;
headData.CLEARCUSTOMDATE = null;
headData.CORPID = userinfo.COMPANYID;
headData.INPUTBY = userinfo.SHOWNAME;
var _r = MsOpApplyDAL.getCUSTNO(headData, USERID, userinfo.SHOWNAME, userinfo.COMPANYID);
if (_r.Success)
{
headData.CUSTNO = _r.Data.ToString();
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Success)
{
DBResult dr = new DBResult(true, "", headData.BSNO);
return BasicDataRefDAL.GetContentResult(dr);
}
else
{
return BasicDataRefDAL.GetContentResult(result);
}
//iscreatecustno = true;
//DBResult dr = new DBResult(true,"", headData.BSNO);
//return BasicDataRefDAL.GetContentResult(dr);
}
else
{
return BasicDataRefDAL.GetContentResult(_r);
}
}
else {
DBResult dr = new DBResult(true, "", headData.BSNO);
return BasicDataRefDAL.GetContentResult(dr);
}
}
/// <summary>
/// 由解析软件触发 令数据从dechead declist container解析至op_apply
/// </summary>
/// <param name="BSNO"></param>
/// <returns></returns>
public ContentResult SaveNewApply(string BSNO) {
var result = new DBResult(true,"","");
return BasicDataRefDAL.GetContentResult(result);
}
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 = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
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);
var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + enumValue.BSNO + "','删除报关业务','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + enumValue.MBLNO + '(' + enumValue.CUSTOMERNAME + ')' + "','" + Convert.ToString(Session["USERID"]) + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
}
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
}
}