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/MsCodeVesselSetController.cs

276 lines
9.8 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 DSWeb.MvcShipping.DAL.MsChDui;
using DSWeb.MvcShipping.Models.MsChDui;
using DSWeb.MvcShipping.Models.MsChDuiView;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using DSWeb.Areas.CommMng.DAL;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.Areas.MvcShipping.DAL.Disports;
using DSWeb.MvcShipping.Models.MsCodeGoods;
using DSWeb.MvcShipping.DAL.MsCodeGoods;
using DSWeb.Areas.MvcShipping.Models.Disport;
using DSWeb.Areas.MvcShipping.DAL.code_vesselModelDal;
using DSWeb.Areas.MvcShipping.Models.MsCodeVesselSetModel;
using DSWeb.SoftMng.Filter;
using DSWeb.Common.DB;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCodeVesselSetController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult FootEdit()
{
return View();
}
//
// GET
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = code_vessel.GetVesselList(condition);
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetData(string handle, string condition)
{
code_vesselModel head = null;
if (handle == "edit")
{
var list = code_vessel.GetVesselByID(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new code_vesselModel();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetFootList(int start, int limit, string sort, string condition)
{
var dataList = code_vessel.GetVoynoList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetFootData(string handle, string condition)
{
code_voynoModel head = null;
if (handle == "edit")
{
var list = code_vessel.GetVoynoListById(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new code_voynoModel();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult UpdateBsVesselVoy(string data)
{
var headData = JsonConvert.Deserialize<code_voynoModel>(data);
DBResult result = code_vessel.UpdateBsVesselVoy(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 获取航次列表
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetCountryType(int start, int limit, string sort, string condition)
{
var dataList = code_vessel.GetVoynotList();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
public ContentResult Save(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<code_vesselModel>(data);
if (opstatus == "add")
{
DBResult re = code_vessel.InsertDetail(headData);
if (re.Success==false)
{
var jsonRespose = new JsonResponse { Success = re.Success, Message =re.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
modb.Save(headData);
var GID = headData.DM_ID;
DBResult result = code_vessel.SDetail(headData);
var jRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = code_vessel.GetVesselByID(GID)
//
};
return new ContentResult() { Content = JsonConvert.Serialize(jRespose) };
}
public ContentResult SaveFoot(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<code_voynoModel>(data);
if (Session["COMPANYID"] != null)
{
headData.CORPID = Session["COMPANYID"].ToString();
}
if (opstatus == "add")
{
if (string.IsNullOrEmpty(headData.VOID)) headData.VOID = Guid.NewGuid().ToString();
DBResult re = code_vessel.InsertVessel(headData);
if (re.Success == false)
{
var jsonRespose = new JsonResponse { Success = re.Success, Message = re.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.ETD == "") headData.ETD = null;
if (headData.ETA == "") headData.ETA = null;
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
if (headData.ATD == "") headData.ATD = null;
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
var modb = new ModelObjectDB();
DBResult result=modb.Save(headData);
//20240513 向大简云同步此条数据
code_vessel.SendToDJY_Vessel(headData, Session["USERID"].ToString());
var GID = headData.VOID;
//DBResult result = code_vessel.InsertVoyno(headData);
var jRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = code_vessel.GetVoynoListById(GID)
//
};
return new ContentResult() { Content = JsonConvert.Serialize(jRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<code_vesselModel>(data);
var cdc = new CommonDataContext();
var bsnos = "";
var condition = $"vsid='{headData.vsid}'";
var voyonList = code_vessel.GetVoynoList_ALL(condition);
if (voyonList != null && voyonList.Count > 0) {
foreach (var voyon in voyonList) {
if (bsnos != "") bsnos += ",";
bsnos += voyon.VOID;
}
}
DBResult result = code_vessel.DeleteDetail(headData);
if (result.Success) {
result = code_vessel.SendToDJY_DelVessel(bsnos, Session["USERID"].ToString());
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DJY_SyncVessel(string GIDList,string HeadId)
{
var result = new DBResult();
result = code_vessel.SendToDJY_Vessel_List(GIDList, HeadId, Session["USERID"].ToString());
return BasicDataRefDAL.GetContentResult(result);
}
#region 删除foot
public ContentResult DeleteFoot(string data)
{
var headData = JsonConvert.Deserialize<code_voynoModel>(data);
DBResult result = code_vessel.DeleteDetailFoot(headData);
if (result.Success) {
result = code_vessel.SendToDJY_DelVessel(headData.VOID, Session["USERID"].ToString());
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 参照部分
#endregion
}
}