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.

1364 lines
90 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.IO;
using System.Data;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL;
using DSWeb.MvcShipping.Models.WMSOUT_GuiGe;
using DSWeb.MvcShipping.Models.MsCwVouchersGl;
using DSWeb.MvcShipping.Models.MsCwVouitemsGl;
using DSWeb.MvcShipping.Models.MsCwGenlegAccitems;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
using DSWeb.MvcShipping.DAL.WMSStock;
using Spire.Pdf.Security;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class WMSOUT_GuiGeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
#region 主表查询
public ContentResult GetDataListHJ(int start, int limit, string sort, string condition)
{
var dataList = WMSOUT_GuiGeDAL.GetDataListHJ(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), start, limit, sort);
int count = WMSOUT_GuiGeDAL.getTotalCountHJ(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["CODENAME"]), Convert.ToString(Session["COMPANYID"]));
//var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList });
return new ContentResult() { Content = json };
}
#endregion
#region 明细表查询
public ContentResult GetDetailList(string opStatus, string condition,string outType)
{
var dataList = WMSOUT_GuiGeDAL.GetDetailList(opStatus, condition,outType, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//20211022 将剩余件数=0的结果去除
if (opStatus == "add")
{
if (outType == "StockOut" || outType == "StockOutDetail")
{
var WMSOUTPKGCANZERO = MsSysParamSetDAL.GetData("PARAMNAME='WMSOUTPKGCANZERO'");
if (WMSOUTPKGCANZERO.PARAMVALUE!="1")
dataList = dataList.Where(x => x.GOODSPACKSTOCK > 0).ToList();
}
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data=dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult JudgeOutType( string condition, string outType)
{
var value = WMSOUT_GuiGeDAL.JudgeOutType( condition, outType, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = value.ToString() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string condition)
{
VwWmsDetailModels head = null;
head = WMSOUT_GuiGeDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetDataEdit(string condition)
{
VwWmsDetailModels head = null;
head = WMSOUT_GuiGeDAL.GetDataEdit(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
//打印明细列表
public ContentResult GetDataListStr(string condition)
{
var dataListStr = WMSOUT_GuiGeDAL.GetDataListStr(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
#endregion
#region 仓储费列表查询//需求编号SR2017073000001
public ContentResult GetWmsRateDetailList(string condition)
{
var dataList = WMSOUT_GuiGeDAL.GetWmsRateDetailList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetSettleRateDetailList(string condition)
{
var dataList = WMSOUT_GuiGeDAL.GetSettleRateDetailList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
#region 保存
public ContentResult SaveEdit(string opStatus, string data, string body, string outType,string changeType,bool bEIP,bool stockType2=false)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var headData = JsonConvert.Deserialize<VwWmsDetailModels>(data);
var bodyList = JsonConvert.Deserialize<List<VwWmsDetailModels>>(body);
var errorstr = "";
#region 保存
if (bodyList != null)
{
#region 基本变量
int n = 1;
string sOutBsno = headData.OUTBSNO_OUT == null ? "" : headData.OUTBSNO_OUT.ToString().Trim();
if (sOutBsno == "")
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='仓储出库' ", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
sOutBsno = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.DODATE_OUT.ToString().Trim(), headData.ACCDATE.ToString().Trim());
else
sOutBsno = WMSOUT_GuiGeDAL.getCodeRuleWmsOut("出库单号", "BSNO", 1, Convert.ToString(Session["USERID"]).Trim(), Convert.ToString(Session["COMPANYID"]).Trim());
}
Decimal dlGOODSPFSL_OUT = 0;//出库量
Decimal dlGOODSPACKPFSL_OUT = 0;//出库件数
Decimal dlARFEE_OUT = 0;//铅封费
Decimal dlARFEE_2_OUT = 0;//过磅费
Decimal dlZXFEE = 0;//装卸费
Decimal dlLoaderFee = 0;//出库装卸费
#endregion
foreach (var enumValue in bodyList)
{
#region 明细表保存
WmsOutDetailModels headRow = new WmsOutDetailModels();
#region 默认值
headRow.INBSNO = enumValue.GID == null ? "" : enumValue.GID.ToString().Trim();//关联入库单wms_in的BSNO
headRow.OUTBSNO = sOutBsno;//OUTBSNO
headRow.BSNO = sOutBsno;//提单号
//headRow.BSNO = enumValue.BSNO_OUT == null ? "" : enumValue.BSNO_OUT.ToString().Trim();//提单号
//if (headRow.BSNO.ToString().Trim() == "")
//{
// headRow.BSNO = WMSOUT_GuiGeDAL.getCodeRuleWmsOut("出库明细单号", "BSNO", n, Convert.ToString(Session["USERID"]).Trim(), Convert.ToString(Session["COMPANYID"]).Trim());//提单号
//}
headRow.CLIENTGID = "";//CLIENTGID
headRow.CLIENTCODE = "";//客户编码
headRow.CUSTOMERNAME = enumValue.CUSTOMERNAME == null ? "" : enumValue.CUSTOMERNAME.ToString().Trim();//客户名称
headRow.DODATE = headData.DODATE_OUT == null ? DateTime.Now : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//操作时间
headRow.STORAGECODE = "";//仓库编码
headRow.STORAGENAME = enumValue.STORAGENAME == null ? "" : enumValue.STORAGENAME.ToString().Trim();//仓库名称
headRow.AREACODE = "";//储位编码
headRow.AREANAME = enumValue.AREANAME == null ? "" : enumValue.AREANAME.ToString().Trim();//储位名称
headRow.GOODSCODE = "";//货物编号
headRow.GOODSNAME = enumValue.GOODSNAME == null ? "" : enumValue.GOODSNAME.ToString().Trim();//货物名称
headRow.GOODSTYPE = "";//货物类型
headRow.GOODSMODEL = enumValue.GOODSMODEL == null ? "" : enumValue.GOODSMODEL.ToString().Trim();//型号//单位//品牌
headRow.GOODSSTANDARD = enumValue.GOODSSTANDARD == null ? "" : enumValue.GOODSSTANDARD.ToString().Trim();//规格
headRow.GOODSPACK = "";//包装
headRow.CHARGEUNIT = enumValue.CHARGEUNIT == null ? "" : enumValue.CHARGEUNIT.ToString().Trim();//CHARGEUNIT
headRow.GOODSPFSL = Decimal.Parse(enumValue.GOODSPFSL_OUT.ToString().Trim());//出库量
dlGOODSPFSL_OUT = dlGOODSPFSL_OUT + headRow.GOODSPFSL;
headRow.GOODSOUTFEE = 0;//仓储费
headRow.TRUCKNO = enumValue.TRUCKNO_OUT == null ? "" : enumValue.TRUCKNO_OUT.ToString().Trim();//TRUCKNO
headRow.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headRow.CREATETIME = DateTime.Now;//创建时间
headRow.REMARK = enumValue.REMARK_OUT == null ? "" : enumValue.REMARK_OUT.ToString().Trim();//备注
headRow.ASSOCIATEDNO = enumValue.ASSOCIATEDNO == null ? "" : enumValue.ASSOCIATEDNO.ToString().Trim();//ASSOCIATEDNO
headRow.GOODSPACKPFSL = Decimal.Parse(enumValue.GOODSPACKPFSL_OUT.ToString().Trim());//出库件数
dlGOODSPACKPFSL_OUT = dlGOODSPACKPFSL_OUT + headRow.GOODSPACKPFSL;
headRow.ARFEE = enumValue.ARFEE_OUT;//铅封费需求编号SR2017073000001
headRow.ARFEE_2 = enumValue.ARFEE_2_OUT;//过磅费需求编号SR2017073000001
dlARFEE_OUT += headRow.ARFEE;//铅封费
dlARFEE_2_OUT += headRow.ARFEE_2;//过磅费
headRow.ZHUANGXIEFEI += enumValue.ZHUANGXIEFEI;
dlZXFEE += headRow.ZHUANGXIEFEI;
headRow.LOADERFEE = enumValue.LOADERFEE;
dlLoaderFee += headRow.LOADERFEE;
headRow.APFEE = 0;//APFEE
headRow.ISLOCK = false;//ISLOCK
headRow.LOCKUSER = Convert.ToString(Session["USERID"]);//LOCKUSER
headRow.LOCKTIME = DateTime.Now;//LOCKTIME
headRow.GOODSOUTFEEAP = 0;//应付仓储费
headRow.CORPID = Convert.ToString(Session["COMPANYID"]).Trim();//CORPID
headRow.CLIENTNAMEOLD = headData.CLIENTNAMEOLD == null ? headRow.CUSTOMERNAME.ToString().Trim() : headData.CLIENTNAMEOLD.ToString().Trim();//CLIENTNAMEOLD
headRow.OLDCUSTFEEDATE = headData.OLDCUSTFEEDATE == null ? DateTime.Now : DateTime.Parse(headData.OLDCUSTFEEDATE.ToString().Trim());//上家承担仓储期限
headRow.STARTBILLINGDATE = DateTime.Now;//应收开始计费日期
headRow.ENDBILLINGDATE = headData.DODATE_OUT == null ? headRow.DODATE : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//应收结束计费日期
headRow.FEEDAYS = 0;//FEEDAYS
headRow.GOODSKGS = enumValue.GOODSKGS.ToString();
headRow.ZHONGLIANG2 = enumValue.ZHONGLIANG2.ToString();
if (headRow.GOODSSTANDARD == null)
{
headRow.GOODSSLICE = 0;//片数/包装件数//需求编号SR2017061800001-7SR2017071100001
}
else
{
if (headRow.GOODSSTANDARD.ToString().Trim() == "")
{
headRow.GOODSSLICE = 0;//片数/包装件数//需求编号SR2017061800001-7SR2017071100001
}
else
{
Decimal dl1 = Decimal.Parse(headRow.GOODSSTANDARD.ToString());
int i1 = (int)dl1;
int i2 = (int)headRow.GOODSPACKPFSL;
if (i1 != 0)
{
int i3 = i2 / i1;
headRow.GOODSSLICE = i3;//片数/包装件数//需求编号SR2017061800001-7SR2017071100001
}
}
}
headRow.GOODSGRADE = "";//品名的等级
headRow.STARTBILLINGDATEAP = DateTime.Now;//应付开始计费日期
headRow.ENDBILLINGDATEAP = headData.DODATE_OUT == null ? headRow.DODATE : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//应付结束计费日期
headRow.FEEDAYSAP = 0;//FEEDAYSAP
headRow.ISCHANGE = false;//是否是货权转移
if (changeType == "1")
{
headRow.ISCHANGE = true;//是否是货权转移
}
headRow.MARKETVALUE = 0;//市场货值
headRow.BZTCHNO = enumValue.BZTCHNO == null ? "" : enumValue.BZTCHNO.ToString().Trim();//电子账册号
headRow.WHS_CODE = enumValue.WHS_CODE == null ? "" : enumValue.WHS_CODE.ToString().Trim();//库别
headRow.GOODSNAMEID = enumValue.GOODSNAMEID == null ? "" : enumValue.GOODSNAMEID.ToString().Trim();//品名gid
headRow.TRUCKTYPE = enumValue.TRUCKTYPE_OUT == null ? "" : enumValue.TRUCKTYPE_OUT.ToString().Trim();//需求编号SR2017073000001
headRow.ZHUANGXIEGONGID = enumValue.ZHUANGXIEGONGID_OUT == null ? "" : enumValue.ZHUANGXIEGONGID_OUT.ToString().Trim();//需求编号SR2017073000001
headRow.TRUCKKGS = Math.Round(Decimal.Parse(enumValue.TRUCKKGS_OUT.ToString().Trim()),4);//需求编号SR2017073000001
headRow.QianFengNO = enumValue.QianFengNO == null ? "" : enumValue.QianFengNO.ToString().Trim();//需求编号SR2017073000001
headRow.TRAYNO = enumValue.TRAYNO == null ? "" : enumValue.TRAYNO.ToString().Trim();//EIP
headRow.CNTRNO = enumValue.EIPCNTRNO==null ? "" : enumValue.EIPCNTRNO.ToString().Trim();//EIP
enumValue.SEALNO = enumValue.SEALNO == null ? "" : enumValue.SEALNO.ToString().Trim();//EIP
headRow.DRIVERIDCARD = enumValue.DRIVERIDCARD.ToString().Trim();
//将库存
if (opStatus == "add")
headRow.GOODSCKQSTOCK = enumValue.GOODSSTOCK;
#endregion
//
if (opStatus == "add" && enumValue.GID_OUT.ToString().Trim() == "")//"add"
{
headRow.GID = Guid.NewGuid().ToString();//唯一编码 newid() varchar (36)
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.GID = enumValue.GID_OUT.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
if (bEIP)
{
WMSEIPStockDAL.UpdateSealInfo(headRow.TRAYNO, headRow.SEALNO, headRow.CNTRNO);
}
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
//var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
//return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (result.Success == true)
{
#region 出库后锁定 op_apply报关业务 BSSTATUS字段
if (enumValue.CHARGEUNIT.ToString().Trim() == "CBM" && enumValue.ISBONDED == 1)
{
string sSQL = "update op_apply set BSSTATUS=1 where WMSIN_GID='" + enumValue.GID.ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
#endregion
}
n++;
#endregion
}
#region 主表保存
WMSOUT_GuiGe2 headRow2 = new WMSOUT_GuiGe2();
#region 默认值
// headRow2.ASSOCIATEDNO = bodyList[0].ASSOCIATEDNO.ToString();//关联号
if (headData.EXPRESSCORP == null) headData.EXPRESSCORP = "";
headRow2.BSNO = sOutBsno;//仓单明细号
headRow2.CLIENTGID = "";//CLIENTGID
headRow2.CLIENTCODE = "";//客户编码
headRow2.CUSTOMERNAME = bodyList[0].CUSTOMERNAME.ToString().Trim();//客户名称
headRow2.DODATE = headData.DODATE_OUT == null ? DateTime.Now : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//操作时间
headRow2.STORAGECODE = "";//仓库编码
headRow2.STORAGENAME = bodyList[0].STORAGENAME.ToString().Trim();//仓库名称
headRow2.AREACODE = "";//储位编码
headRow2.AREANAME = bodyList[0].AREANAME.ToString().Trim();//储位名称
headRow2.GOODSCODE = "";//货物编号
headRow2.GOODSNAME = bodyList[0].GOODSNAME.ToString().Trim();//货物名称
headRow2.GOODSTYPE = "";//货物类型
headRow2.GOODSMODEL = bodyList[0].GOODSMODEL.ToString().Trim();//型号//单位//品牌
headRow2.GOODSSTANDARD = bodyList[0].GOODSSTANDARD.ToString().Trim();//规格
headRow2.GOODSPACK = "";//包装
headRow2.GOODSPFSL = dlGOODSPFSL_OUT;//出库量
headRow2.GOODSOUTFEE = 0;//仓储费用
headRow2.TRUCKNO = "";//TRUCKNO
headRow2.REMARK = headData.OUTREMARK == null ? "" : headData.OUTREMARK.ToString().Trim();//备注
headRow2.ISDELETE = false;//是否废除
headRow2.DELETETIME = DateTime.Now;//废除时间
headRow2.DELETEUSER = Convert.ToString(Session["USERID"]);//废除操作人
headRow2.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headRow2.CREATETIME = DateTime.Now;//创建时间
headRow2.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次更新操作人
headRow2.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
headRow2.GOODSPACKPFSL = dlGOODSPACKPFSL_OUT;//出库件数
headRow2.TRUCKNAME = headData.TRUCKNAME_OUT == null ? "" : headData.TRUCKNAME_OUT.ToString().Trim();//TRUCKNAME
headRow2.WMSOP = Convert.ToString(Session["SHOWNAME"]).Trim();//WMSOP
headRow2.STOREMAN = "";//STOREMAN
headRow2.ISLOCK = false;//ISLOCK
headRow2.LOCKUSER = "";//LOCKUSER
headRow2.LOCKTIME = DateTime.Now;//LOCKTIME
headRow2.GOODSOUTFEEAP = 0;//GOODSOUTFEEAP
headRow2.ARFEE = dlARFEE_OUT;//ARFEE需求编号SR2017073000001
headRow2.ARFEE_2 = dlARFEE_2_OUT;//ARFEE需求编号SR2017073000001
headRow2.APFEE = 0;//APFEE
headRow2.INSPECTIONNO = "";//INSPECTIONNO
headRow2.CUSTOMNO = bodyList[0].CUSTOMNO.ToString().Trim();//CUSTOMNO
headRow2.CORPID = Convert.ToString(Session["COMPANYID"]).Trim();//CORPID
headRow2.CLIENTNAMEOLD = headData.CLIENTNAMEOLD == null ? headRow2.CUSTOMERNAME.ToString().Trim() : headData.CLIENTNAMEOLD.ToString().Trim();//CLIENTNAMEOLD
headRow2.OLDCUSTFEEDATE = headData.OLDCUSTFEEDATE == null ? DateTime.Now : DateTime.Parse(headData.OLDCUSTFEEDATE.ToString().Trim());//OLDCUSTFEEDATE
headRow2.CLIENTBSNO = "";//CLIENTBSNO
headRow2.ARCLIENT = headData.ARCLIENT == null ? headRow2.CUSTOMERNAME.ToString().Trim() : headData.ARCLIENT.ToString().Trim();//ARCLIENT
headRow2.INGIDNEW = "";//INGIDNEW
headRow2.TOTALNO = "";//TOTALNO
headRow2.REMARK2 = headData.OUTREMARK2 == null ? "" : headData.OUTREMARK2.ToString().Trim();//备注;//REMARK2
headRow2.VALIDDATE = DateTime.Now;//VALIDDATE
headRow2.CHARGEUNIT = bodyList[0].CHARGEUNIT.ToString().Trim();//CHARGEUNIT
headRow2.MBLNONEW = "";//MBLNONEW
headRow2.ISCHANGE = false;//ISCHANGE
headRow2.ZHUANGXIEFEI = dlZXFEE;//装卸费
headRow2.RENTAREA = Convert.ToDecimal(headData.RENTAREA.ToString().Trim());
if (changeType == "1")
{
headRow2.ISCHANGE = true;//是否是货权转移
}
headRow2.ISDETAIL = "0";
if (outType == "StockOutDetail")
{
headRow2.ISDETAIL = "1";//是否明细出库
}
headRow2.MARKETVALUE = 0;//MARKETVALUE
headRow2.ARCLIENTWMSOUT = headData.ARCLIENTWMSOUT == null ? headRow2.CUSTOMERNAME.ToString().Trim() : headData.ARCLIENTWMSOUT.ToString().Trim();//ARCLIENTWMSOUT
headRow2.ISCOLLECTING = false;//ISCOLLECTING
headRow2.WMSOUTSTATUS = 0;//WMSOUTSTATUS
headRow2.BZTCHNO = bodyList[0].BZTCHNO.ToString().Trim();//电子账册号
headRow2.WHS_CODE = bodyList[0].WHS_CODE.ToString().Trim();//库别
headRow2.GOODSNAMEID = bodyList[0].GOODSNAMEID.ToString().Trim();//品名gid
headRow2.ACCDATE = headData.ACCDATE_OUT == null ? "" : headData.ACCDATE_OUT.ToString().Trim();//会计期间
headRow2.FEESTATUS = headData.FEESTATUSREF_OUT.ToString().Trim() == "锁定" ? true : false;//费用状态
headRow2.EXPRESSEXNO= headData.EXPRESSEXNO.Trim();
headRow2.EXPRESSCORP= headData.EXPRESSCORP.Trim();
headRow2.EIP = bEIP;
headRow2.QUOTANO = headData.QUOTANO;
#endregion
//
if (opStatus == "add" && headData.OUTGID.ToString().Trim()=="")//"add"
{
headRow2.GID = Guid.NewGuid().ToString();//唯一编码 newid() varchar (36)
headRow2.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow2.GID = headData.OUTGID.ToString().Trim();// bodyList[0].OUTGID.ToString();//唯一编码
headRow2.DbOperationType = DbOperationType.DbotUpd;
headRow2.ModelUIStatus = "E";
}
headRow2.ASSOCIATEDNO = headRow2.GID;
if (WMSOUT_GuiGeDAL.GetFeeConfig(outType, bodyList[0].GID.ToString()))
headRow2.ASSOCIATEDNO = bodyList[0].ASSOCIATEDNO.ToString();//关联号
//SR2020030900003 增加三个字段
headRow2.CNTRTOTAL = headData.CNTRTOTAL;
headRow2.KGS_OUT = headData.KGS_OUT;
headRow2.PKGS_OUT = headData.PKGS_OUT;
headRow2.CBM_OUT = headData.CBM_OUT;
//
var modb2 = new ModelObjectDB();
DBResult result2 = modb2.Save(headRow2);
if (result2.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
//var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
//return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
if (result2.Success == true)
{
#region 出库件数 返 入库库存//需求编号SR2017073000001
foreach (var enumValue in bodyList)
{
//if(enumValue.CHARGEUNIT.ToString().Trim() == "CBM")
//Modified by xxq 20181213
if (outType == "StockOutDetail")
{
//EIP是华腾项目参数
if (!bEIP)
{
string sSQL = "update wms_in set GOODSPACKSTOCK=GOODSPACK-isnull((select sum(GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_STOCK_DETAIL where GID='" + enumValue.GID.ToString().Trim() + "'),0),GOODSSTOCK=GOODSRKSL-isnull((select sum(GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_STOCK_DETAIL where GID='" + enumValue.GID.ToString().Trim() + "'),0) where GID='" + enumValue.GID.ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
sSQL = "update wms set GOODSPACKSTOCK=isnull((select sum(GOODSPACKSTOCK) as GOODSPACKSTOCK from wms_in where ASSOCIATEDNO='" + enumValue.WMSGID.ToString().Trim() + "'),0),GOODSSTOCK=isnull((select sum(GOODSSTOCK) as GOODSSTOCK from wms_in where ASSOCIATEDNO='" + enumValue.WMSGID.ToString().Trim() + "'),0) where gid='" + enumValue.WMSGID.ToString().Trim() + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
else
{
string sSQL = "update wms_in set GOODSPACKSTOCK=0,GOODSSTOCK=0 where GID='" + enumValue.GID.ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
sSQL = "update wms set GOODSPACKSTOCK=0,GOODSSTOCK=0 where gid='" + enumValue.WMSGID.ToString().Trim() + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
}
if (outType == "StockOut")
{
bool bl = WMSOUT_GuiGeDAL.UpdateWMSIN(enumValue.GID.ToString().Trim(), headRow2.GID.ToString().Trim());
//string sSQL = "update wms_in set GOODSPACKSTOCK=GOODSPACK-isnull((select sum(GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_STOCK where GID='" + enumValue.GID.ToString().Trim() + "'),0),GOODSSTOCK=GOODSRKSL-isnull((select sum(GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_STOCK where GID='" + enumValue.GID.ToString().Trim() + "'),0) where ASSOCIATEDNO='" + enumValue.GID.ToString().Trim() + "'";
//bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
//string sSQL = "update wms set GOODSPACKSTOCK=GOODSPACK-isnull((select top 1 (GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_STOCK where GID='" + enumValue.GID.ToString().Trim() + "'),0),GOODSSTOCK=GOODSRKSL-isnull((select top 1 (GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_STOCK where GID='" + enumValue.GID.ToString().Trim() + "'),0) where GID='" + enumValue.GID.ToString().Trim() + "'";
//bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
}
#endregion
#region 出库后锁定op_apply报关业务BSSTATUS字段
foreach (var enumValue in bodyList)
{
if (enumValue.CHARGEUNIT.ToString().Trim() == "CBM" && enumValue.ISBONDED == 1)
{
string sSQL = "update op_apply set BSSTATUS=1 where WMSIN_GID='" + enumValue.GID.ToString().Trim() + "' and ISCLEAR='1' and CUSTOMTYPE='出区报关'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
}
#endregion
}
}
#endregion
#region 计算仓储费
Decimal totaloutfee = 0;//应收出库单的仓储费
Decimal totaloutfeeap = 0;//应付出库单的仓储费
var dataList = WMSOUT_GuiGeDAL.GetDetailList("edit", "outgid='" + headRow2.GID.ToString() + "'", outType, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
foreach (var enumValue in dataList)
{
// <param name="sqlTran">事务</param>
// <param name="strSTARTBILLINGDATE">开始计费日期</param>
// <param name="strOLDCUSTFEEDATE">上家承担仓储期限</param>
// <param name="strINBSNO">出库明细关联的入库单wms或wms_in的BSNO</param>
// <param name="strCUSTOMERNAME">出库主表的客户名称</param>
// <param name="outnums">出库量</param>
// <param name="strASSOCIATEDNO">关联wms_out_detail的GID</param>
// <param name="strFEETYPE">区别费用收、付类型</param>
int feedays = 0;//应收仓储天数
int feedaysap = 0;//应付仓储天数
Decimal sumfee = 0;//应收出库明细的仓储费
Decimal sumfeeap = 0;//应付出库明细的仓储费
#region 应收
if (enumValue.ARCLIENTWMSOUT.ToString().Trim() != "")
{
string getstr = WMSOUT_GuiGeDAL.getWmsRate(enumValue.STARTBILLINGDATE.ToString().Trim(), headData.OLDCUSTFEEDATE.ToString().Trim(), enumValue.INBSNO_OUT.ToString().Trim(), enumValue.ARCLIENTWMSOUT.ToString().Trim(), Decimal.Parse(enumValue.GOODSPFSL_OUT.ToString().Trim()), enumValue.GID_OUT.ToString(), 1, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), enumValue.OUTBSNO_OUT.ToString().Trim(), headRow2.GID.ToString().Trim(), headData.cbCCF, false);
string[] strls = getstr.Trim().Split(new string[] { "" }, StringSplitOptions.RemoveEmptyEntries);
sumfee = Decimal.Parse(strls[0].ToString());
totaloutfee += sumfee;//仓储费合计
if (strls.Length==2)
feedays += int.Parse(strls[1].ToString());
#region 更新出库明细表的仓储费信息
string sSQL = "update wms_out_detail set GOODSOUTFEE=" + sumfee //应收仓储费
+ ",STARTBILLINGDATE='" + enumValue.STARTBILLINGDATE.ToString().Trim() + "'"//应收开始计费日期
+ ",ENDBILLINGDATE='" + headData.OLDCUSTFEEDATE.ToString().Trim() + "'"//应收结束计费日期
+ ",FEEDAYS=" + feedays//应收计费天数
+ " where GID='" + enumValue.GID_OUT.ToString() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
#endregion
}
#endregion
#region 应付
if (enumValue.TRUCKNAME.ToString().Trim()!="")
{
string getstr = WMSOUT_GuiGeDAL.getWmsRate(enumValue.STARTBILLINGDATEAP.ToString().Trim(), headData.OLDCUSTFEEDATE.ToString().Trim(), enumValue.INBSNO_OUT.ToString().Trim(), enumValue.TRUCKNAME.ToString().Trim(), Decimal.Parse(enumValue.GOODSPFSL_OUT.ToString().Trim()), enumValue.GID_OUT.ToString(), 2, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), enumValue.OUTBSNO_OUT.ToString().Trim(), headRow2.GID.ToString().Trim(), headData.cbCCF, false);
string[] strls = getstr.Trim().Split(new string[] { "" }, StringSplitOptions.RemoveEmptyEntries);
sumfeeap = Decimal.Parse(strls[0].ToString());
totaloutfeeap += sumfeeap;//仓储费合计
feedaysap += int.Parse(strls[1].ToString());
#region 更新出库明细表的仓储费信息
string sSQL = "update wms_out_detail set GOODSOUTFEEAP=" + sumfeeap //应付仓储费
+ ",STARTBILLINGDATEAP='" + enumValue.STARTBILLINGDATE.ToString().Trim() + "'"//应付开始计费日期
+ ",ENDBILLINGDATEAP='" + headData.OLDCUSTFEEDATE.ToString().Trim() + "'"//应付结束计费日期
+ ",FEEDAYSAP=" + feedaysap//应付计费天数
+ " where GID='" + enumValue.GID_OUT.ToString() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
#endregion
}
#endregion
}
#region 更新出库主表的仓储费信息
string sSQL2 = "update wms_out set GOODSOUTFEE=" + totaloutfee //应收仓储费
+ ",GOODSOUTFEEAP=" + totaloutfeeap//应付仓储费
+ " where GID='" + headRow2.GID.ToString().Trim() + "'";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(sSQL2);
#endregion
#endregion
#region 货权转移
if (changeType == "1")
{
string sSQL = "";
string newWmsGid = "Wms" + Guid.NewGuid().ToString().Replace("-", "");
if (opStatus == "edit")
{
#region 提取货权转移后的入库主表GID
sSQL = "select top 1 INGIDNEW from wms_out where gid='" + headData.OUTGID.ToString() + "'";
string sINGIDNEW = T_ALL_DA.GetStrSQL("INGIDNEW", sSQL);
if (sINGIDNEW.Trim() != "")
{
newWmsGid = sINGIDNEW;
}
#endregion
#region 删除入库明细
sSQL = "delete from wms_in where ASSOCIATEDNO='" + newWmsGid + "'";
#endregion
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
#region 删除主表信息
sSQL = "delete from wms where gid='" + newWmsGid + "'";
#endregion
bool bl3 = T_ALL_DA.GetExecuteSqlCommand(sSQL);
#region 删除入库仓储费率表
sSQL = "delete from wms_rate where BSNO='" + newWmsGid + "'";
#endregion
bool bl4 = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
else
{
#region 更新现出库货权转移的入库wmsgidINGIDNEW
sSQL = "update wms_out set INGIDNEW='" + newWmsGid + "' where gid='" + headRow2.GID.ToString() + "'";
#endregion
bool bl5 = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
#region 基本变量
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='仓储入库'", Convert.ToString(Session["COMPANYID"]));
string newWMSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.DODATE_OUT.ToString(), headData.ACCDATE_OUT.ToString());
int feedays = WMSOUT_GuiGeDAL.GetDaysCount("day", headData.DODATE_OUT.ToString(), headData.OLDCUSTFEEDATE.ToString())-1;//出库-开始计费日期+1
string WMSGID = "";
dlGOODSPACKPFSL_OUT = 0;
dlGOODSPFSL_OUT = 0;
#endregion
#region 入库明细
//用于存放key=WMS_IN.GOODSNAME+'-'+CNTRNO value=WMS_IN.GID
//用途是生成完毕以后如果报关单号CUSTOMNO有值则相应的用WMS_IN.GID去更新对应报关单的品名相同的报关明细Op_apply_detail的WMSIN_GID字段
//仅用于明细货转 实际只使用在虎鲸的报税业务当中
//var wmsindic = new Dictionary<string, string>();
int nList = dataList.Count;
if (nList > 0)
{
WMSGID = dataList[0].WMSGID.ToString();
if ((dataList[0].CHARGEUNIT.ToString().Trim() == "CBM") || (outType == "StockOutDetail"))
{
//明细
foreach (var enumValue in dataList)
{
dlGOODSPACKPFSL_OUT += enumValue.GOODSPACKPFSL_OUT;
dlGOODSPFSL_OUT += enumValue.GOODSPFSL_OUT;
if ((enumValue.CHARGEUNIT.ToString().Trim() == "CBM") || (outType == "StockOutDetail"))
{
#region 提取原入库明细信息插入
var _newwmsingid = Guid.NewGuid().ToString();
//wmsindic.Add(enumValue.GOODSNAME + '-' + enumValue.CNTRNO, _newwmsingid);
sSQL = "insert into wms_in (GID,ASSOCIATEDNO,BLNO,CONTRACTNO,CTNALL,CNTRNO,SEALNO,BSNO,CLIENTCODE,CLIENTNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,GOODSPACKSTOCK,GOODSKGS,CHARGEUNIT,GOODSRKSL,GOODSSTOCK,FREESTORAGEPERIOD,ISLOCK,LOCKTIME,LOCKUSER,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,CLIENTCODEOLD,CLIENTNAMEOLD,KINDPKGS,ARFEE,APFEE,CORPID,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSGRADE,STACKLOCATION,GOODSPACKACTUAL,GOODSRKSLACTUAL,ISCHANGE,MARKETVALUE,BANKVALUE,LINENUM,GOODSNAMEID,ISLOCK2,XIANGHAO2,JIANSHU2,ZHUANGXIEGONGID,TRUCKNO,CHIMA1,CHIMA2,ZHONGLIANG2,SHIJIZHONGLIANG,SHIJICHIMA,JIANSHU1)"
+ " select"
+ " '"+ _newwmsingid + "' as GID" //惟一编号" //Varchar(100)
+ ",'" + newWmsGid + "' as ASSOCIATEDNO" //关联号" //Varchar(100)
+ ",BLNO" //提单号" //Varchar(30)
+ ",CONTRACTNO" //合同号" //Varchar(100)
+ ",CTNALL" //箱型" //Varchar(10)
+ ",CNTRNO" //箱号" //Varchar(30)
+ ",SEALNO" //封号" //Varchar(12)
+ ",'" + newWMSNO + "' as BSNO" //入库单号" //Varchar(100)
+ ",CLIENTCODE" //客户编码" //varchar(20)
+ ",'" + headData.CLIENTNAMEOLD.ToString() + "' as CLIENTNAME" //客户名称" //varchar(20)
+ ",'" + headData.DODATE_OUT.ToString() + "' as DODATE" //入库日期" //Datetime
+ ",STORAGECODE" //仓库编码" //Varchar(50)
+ ",STORAGENAME" //仓库名称" //Varchar(100)
+ ",AREACODE" //库位编码" //Varchar(50)
+ ",AREANAME" //库位名称/储位" //Varchar(100)
+ ",GOODSCODE" //货物编号" //Varchar(50)
+ ",GOODSNAME" //货物名称/品名" //Varchar(100)
+ ",GOODSTYPE" //货物类型" //Varchar(50)
+ ",GOODSMODEL" //型号/品牌" //Varchar(100)
+ ",GOODSSTANDARD" //规格" //Varchar(100)
+ "," + enumValue.GOODSPACKPFSL_OUT + " as GOODSPACK" //入库件数" //Numeric(18,4)
+ "," + enumValue.GOODSPACKPFSL_OUT + " as GOODSPACKSTOCK" //剩余件数" //Numeric(18,4)
//+ ",0 as GOODSKGS" //单位重量" //Numeric(18,4) 目前已作为重量1使用应该写入入库数量GOODSRKSL
+ "," + enumValue.GOODSPACKPFSL_OUT + " as GOODSKGS" //单位重量" //Numeric(18,4)
+ ",CHARGEUNIT" //计费单位" //Varchar(10)
+ "," + enumValue.GOODSPFSL_OUT + " as GOODSRKSL" //入库量" //Numeric(18,4)
+ "," + enumValue.GOODSPFSL_OUT + " as GOODSSTOCK" //库存量" //Numeric(18,4)
+ "," + feedays + " as FREESTORAGEPERIOD" //免仓储期" //int
+ ",0 as ISLOCK" //是否锁定" //bit
+ ",getdate() as LOCKTIME" //锁定时间" //Datetime
+ ",LOCKUSER" //锁定操作人" //Varchar(36)
+ ",0 as ISDELETE" //是否废除" //bit
+ ",getdate() as DELETETIME" //废除时间" //Datetime
+ ",DELETEUSER" //废除操作人" //Varchar(36)
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as CREATEUSER" //创建人" //Varchar(36)
+ ",getdate() as CREATETIME" //创建时间" //Datetime
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as MODIFIEDUSER" //最后一次更新操作人" //Varchar(36)
+ ",getdate() as MODIFIEDTIME" //最后一次更新操作时间" //Datetime
+ ",'货权转移' as REMARK" //备注" //Varchar(1024)
+ ",CLIENTCODEOLD" //原客户编码" //varchar(20)
+ ",CLIENTNAME as CLIENTNAMEOLD" //原客户名称" //varchar(20)
+ ",KINDPKGS" //包装" //varchar(20)
+ ",0 as ARFEE" //应收账款 account receivable" //Numeric(18,2)
+ ",0 as APFEE" //应付账款 account payable" //Numeric(18,2)
+ ",'" + Convert.ToString(Session["COMPANYID"]).Trim() + "' as CORPID" //分公司代码" //Varchar(36)" //" //
+ ",0 as GOODSTHICKNESS" //厚度" //Numeric(18,4)
+ ",0 as GOODSWIDTH" //宽度" //Numeric(18,4)
+ ",0 as GOODSLENGTH" //长度" //Numeric(18,4)
+ ",0 as GOODSSLICE" //片数/件/包装件数" //Numeric(18,4)
+ ",GOODSGRADE" //品名的等级" //Varchar(50)
+ ",STACKLOCATION" //码放位置" //Varchar(50)
+ "," + enumValue.GOODSPACKPFSL_OUT + " as GOODSPACKACTUAL" //实际件数" //Numeric(18,4)
+ "," + enumValue.GOODSPFSL_OUT + " as GOODSRKSLACTUAL" //实际数量" //Numeric(18,4)
+ ",1 as ISCHANGE" //是否是货权转移" //bit
+ ",0 as MARKETVALUE" //市场货值" //Numeric(18,2)
+ ",0 as BANKVALUE" //银行货值" //Numeric(18,2)
+ ",LINENUM=(select top 1 LINENUM=isnull((select top 1 LINENUM from wms_in WITH(NOLOCK) where ASSOCIATEDNO='" + newWmsGid + "' order by LINENUM desc),0)+1)" //单个grid的行号" //Int" //" //
+ ",GOODSNAMEID" //品名id" //Varchar(50)" //" //
+ ",0 as ISLOCK2" //是否锁定" //Bit
+ ",XIANGHAO2" //箱号2" //varchar(100)
+ ",0 as JIANSHU2" //件数2" //numeric(18, 4)
+ ",ZHUANGXIEGONGID" //装卸工ID" //varchar(100)
+ ",TRUCKNO" //车牌号" //varchar(100)
+ ",0 as CHIMA1" //尺码1" //Float
+ ",0 as CHIMA2" //尺码2" //Float
+ "," + enumValue.GOODSPFSL_OUT + " as ZHONGLIANG2" //重量2" //numeric(18, 4)
+ ",0 as SHIJIZHONGLIANG" //实际重量" //float
+ ",0 as SHIJICHIMA" //实际尺码" //Float
+ ",0 as JIANSHU1" //件数1" //numeric(18, 4)
+ " from wms_in where GID='" + enumValue.GID.ToString() + "'";
#endregion
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
}
//此时
}
else
{
dlGOODSPACKPFSL_OUT = dataList[0].GOODSPACKPFSL_OUT;
dlGOODSPFSL_OUT = dataList[0].GOODSPFSL_OUT;
//整体
//wmsindic.Add("GOODSNAME", "");
#region 提取原入库主表信息插入
sSQL = "insert into wms_in (GID,ASSOCIATEDNO,BLNO,CONTRACTNO,CTNALL,CNTRNO,SEALNO,BSNO,CLIENTCODE,CLIENTNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,GOODSPACKSTOCK,GOODSKGS,CHARGEUNIT,GOODSRKSL,GOODSSTOCK,FREESTORAGEPERIOD,ISLOCK,LOCKTIME,LOCKUSER,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,CLIENTCODEOLD,CLIENTNAMEOLD,KINDPKGS,ARFEE,APFEE,CORPID,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSGRADE,STACKLOCATION,GOODSPACKACTUAL,GOODSRKSLACTUAL,ISCHANGE,MARKETVALUE,BANKVALUE,LINENUM,GOODSNAMEID,ISLOCK2,XIANGHAO2,JIANSHU2,ZHUANGXIEGONGID,TRUCKNO,CHIMA1,CHIMA2,ZHONGLIANG2,SHIJIZHONGLIANG,SHIJICHIMA,JIANSHU1)" //应付仓储费
+ " select top 1"
+ " newid() as GID" //惟一编号" //Varchar(100)
+ ",'" + newWmsGid + "' as ASSOCIATEDNO" //关联号" //Varchar(100)
+ ",BLNO" //提单号" //Varchar(30)
+ ",CONTRACTNO" //合同号" //Varchar(100)
+ ",CTNALL" //箱型" //Varchar(10)
+ ",CNTRNO" //箱号" //Varchar(30)
+ ",SEALNO" //封号" //Varchar(12)
+ ",'" + newWMSNO + "' as BSNO" //入库单号" //Varchar(100)
+ ",CLIENTCODE" //客户编码" //varchar(20)
+ ",'" + headData.CLIENTNAMEOLD.ToString() + "' as CLIENTNAME" //客户名称" //varchar(20)
+ ",'" + headData.DODATE_OUT.ToString() + "' as DODATE" //入库日期" //Datetime
+ ",STORAGECODE" //仓库编码" //Varchar(50)
+ ",STORAGENAME" //仓库名称" //Varchar(100)
+ ",AREACODE" //库位编码" //Varchar(50)
+ ",AREANAME" //库位名称/储位" //Varchar(100)
+ ",GOODSCODE" //货物编号" //Varchar(50)
+ ",GOODSNAME" //货物名称/品名" //Varchar(100)
+ ",GOODSTYPE" //货物类型" //Varchar(50)
+ ",GOODSMODEL" //型号/品牌" //Varchar(100)
+ ",GOODSSTANDARD" //规格" //Varchar(100)
+ "," + dataList[0].GOODSPACKPFSL_OUT + " as GOODSPACK" //入库件数" //Numeric(18,4)
+ "," + dataList[0].GOODSPACKPFSL_OUT + " as GOODSPACKSTOCK" //剩余件数" //Numeric(18,4)
+ "," + dataList[0].GOODSPACKPFSL_OUT + " as GOODSKGS" //单位重量" //Numeric(18,4)//重量1
+ ",CHARGEUNIT" //计费单位" //Varchar(10)
+ "," + dataList[0].GOODSPFSL_OUT + " as GOODSRKSL" //入库量" //Numeric(18,4)
+ "," + dataList[0].GOODSPFSL_OUT + " as GOODSSTOCK" //库存量" //Numeric(18,4)
+ "," + feedays + " as FREESTORAGEPERIOD" //免仓储期" //int
+ ",0 as ISLOCK" //是否锁定" //bit
+ ",LOCKTIME" //锁定时间" //Datetime
+ ",LOCKUSER" //锁定操作人" //Varchar(36)
+ ",0 as ISDELETE" //是否废除" //bit
+ ",DELETETIME" //废除时间" //Datetime
+ ",DELETEUSER" //废除操作人" //Varchar(36)
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as CREATEUSER" //创建人" //Varchar(36)
+ ",getdate() as CREATETIME" //创建时间" //Datetime
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as MODIFIEDUSER" //最后一次更新操作人" //Varchar(36)
+ ",getdate() as MODIFIEDTIME" //最后一次更新操作时间" //Datetime
+ ",'货权转移' as REMARK" //备注" //Varchar(1024)
+ ",CLIENTCODEOLD" //原客户编码" //varchar(20)
+ ",CLIENTNAME as CLIENTNAMEOLD" //原客户名称" //varchar(20)
+ ",KINDPKGS" //包装" //varchar(20)
+ ",0 as ARFEE" //应收账款 account receivable" //Numeric(18,2)
+ ",0 as APFEE" //应付账款 account payable" //Numeric(18,2)
+ ",'" + Convert.ToString(Session["COMPANYID"]).Trim() + "' as CORPID" //分公司代码" //Varchar(36)" //" //
+ ",0 as GOODSTHICKNESS" //厚度" //Numeric(18,4)
+ ",0 as GOODSWIDTH" //宽度" //Numeric(18,4)
+ ",0 as GOODSLENGTH" //长度" //Numeric(18,4)
+ ",0 as GOODSSLICE" //片数/件/包装件数" //Numeric(18,4)
+ ",GOODSGRADE" //品名的等级" //Varchar(50)
+ ",STACKLOCATION" //码放位置" //Varchar(50)
+ "," + dataList[0].GOODSPACKPFSL_OUT + " as GOODSPACKACTUAL" //实际件数" //Numeric(18,4)
+ "," + dataList[0].GOODSPFSL_OUT + " as GOODSRKSLACTUAL" //实际数量" //Numeric(18,4)
+ ",1 as ISCHANGE" //是否是货权转移" //bit
+ ",0 as MARKETVALUE" //市场货值" //Numeric(18,2)
+ ",0 as BANKVALUE" //银行货值" //Numeric(18,2)
+ ",LINENUM=(select top 1 LINENUM=isnull((select top 1 LINENUM from wms_in WITH(NOLOCK) where ASSOCIATEDNO='" + newWmsGid + "' order by LINENUM desc),0)+1)" //单个grid的行号" //Int" //" //
+ ",GOODSNAMEID" //品名id" //Varchar(50)" //" //
+ ",0 as ISLOCK2" //是否锁定" //Bit
+ ",XIANGHAO2" //箱号2" //varchar(100)
+ ",0 as JIANSHU2" //件数2" //numeric(18, 4)
+ ",ZHUANGXIEGONGID" //装卸工ID" //varchar(100)
+ ",TRUCKNO" //车牌号" //varchar(100)
+ ",0 as CHIMA1" //尺码1" //Float
+ ",0 as CHIMA2" //尺码2" //Float
+ "," + dataList[0].GOODSPFSL_OUT + " as ZHONGLIANG2" //重量2" //numeric(18, 4)
+ ",0 as SHIJIZHONGLIANG" //实际重量" //float
+ ",0 as SHIJICHIMA" //实际尺码" //Float
+ ",0 as JIANSHU1" //件数1" //numeric(18, 4)
+ " from wms_in where ASSOCIATEDNO='" + dataList[0].GID.ToString() + "'";
#endregion
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
}
#endregion
#region 提取原入库主表信息插入
var BLNOstr = ",BLNO,CONTRACTNO";
var ASSOCIATEDNOStr = ",ASSOCIATEDNO";
if (stockType2) {
BLNOstr = ",'' BLNO,'' CONTRACTNO";
ASSOCIATEDNOStr = ",'"+ newWmsGid + "' ASSOCIATEDNO";
}
sSQL = "insert into wms (GID,WMSNO,WMSDATE,CUSTOMERNAME,WMSOP,STOREMAN,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,ISDELETE,DELETEUSER,DELETETIME,ARCLIENT,TRUCKNAME,ISLOCK,LOCKTIME,LOCKUSER,GOODSNAME,GOODSMODEL,CHARGEUNIT,GOODSPACK,GOODSPACKSTOCK,GOODSRKSL,GOODSSTOCK,ARFEE,APFEE,FREESTORAGEPERIOD,ASSOCIATEDNO,BLNO,CONTRACTNO,CLIENTCODEOLD,CLIENTNAMEOLD,STORAGENAME,CORPID,STARTBILLINGDATE,CUSTOMNO,CUSTNO,GOODSSTANDARD,GOODSPACKACTUAL,GOODSRKSLACTUAL,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,ISCHANGE,AREANAME,MARKETVALUE,BANKVALUE,BZTCHNO,CLIENTBSNO,WHS_CODE,GOODSNAMEID,ACCDATE,FEESTATUS,ISLOCK2)"
+ " select "
+ " '" + newWmsGid + "' as GID" //惟一编号 Varchar(36)
+ ",'" + newWMSNO + "' as WMSNO" //入库单号 Varchar(100)
+ ",'" + headData.DODATE_OUT.ToString() + "' as WMSDATE" //入库时间 Datetime
+ ",'" + headData.CLIENTNAMEOLD.ToString() + "' as CUSTOMERNAME" //客户名称 Varchar(20)
+ ",'" + Convert.ToString(Session["SHOWNAME"]).Trim() + "' as WMSOP" //制表人 Varchar(10)
+ ",'" + Convert.ToString(Session["SHOWNAME"]).Trim() + "' as STOREMAN" //保管人 Varchar(10)
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as CREATEUSER" //创建人 Varchar(36)
+ ",getdate() as CREATETIME" //创建时间 Datetime
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as MODIFIEDUSER" //最后一次更新操作人 Varchar(36)
+ ",getdate() as MODIFIEDTIME" //最后一次更新操作时间 Datetime
+ ",0 as ISDELETE" //是否废除 Bit
+ ",DELETEUSER" //废除人 Varchar(36)
+ ",getdate() as DELETETIME" //废除时间 Datetime
+ ",'" + headData.CLIENTNAMEOLD.ToString() + "' as ARCLIENT" //应收账款客户名称/仓库或客户 Varchar(20)
+ ",'" + headData.CLIENTNAMEOLD.ToString() + "' as TRUCKNAME" //装卸队名称 /应付账款客户名称 Varchar(20)
+ ",0 as ISLOCK" //是否锁定 Bit/新协行tinyint
+ ",getdate() as LOCKTIME" //锁定时间 Datetime
+ ",LOCKUSER" //锁定操作人 Varchar(36)
+ ",GOODSNAME" //货物名称/品名 Varchar(100)
+ ",GOODSMODEL" //型号 Varchar(100)
+ ",CHARGEUNIT" //计费单位 Varchar(10)
+ "," + dlGOODSPACKPFSL_OUT + " as GOODSPACK" //入库件数 Numeric(18,4)
+ "," + dlGOODSPACKPFSL_OUT + " as GOODSPACKSTOCK" //*剩余件数(出货时减) Numeric(18,4)
+ "," + dlGOODSPFSL_OUT + " as GOODSRKSL" //入库量 Numeric(18,4)
+ "," + dlGOODSPFSL_OUT + " as GOODSSTOCK" //*库存量(出货时减) Numeric(18,4)
+ ",0 as ARFEE" //应收账款 account receivable Numeric(18,2)
+ ",0 as APFEE" //应付账款 account payable Numeric(18,2)
+ "," + feedays + " as FREESTORAGEPERIOD" //应收免仓储期 int
+ ASSOCIATEDNOStr//+ ",ASSOCIATEDNO" //关联号 Varchar(100)
//+ ",BLNO" //提单号 Varchar(30)
//+ ",CONTRACTNO" //合同号 Varchar(100)
+ BLNOstr
+ ",CLIENTCODEOLD" //原客户编码 Varchar(20)
+ ",CUSTOMERNAME as CLIENTNAMEOLD" //原客户名称 Varchar(20)
+ ",STORAGENAME" //仓库名称 Varchar(100)
+ ",'" + Convert.ToString(Session["COMPANYID"]).Trim() + "' as CORPID" //分公司代码 Varchar(36)
+ ",'" + headData.OLDCUSTFEEDATE.AddDays(1) + "' as STARTBILLINGDATE" //应收开始计费日期 Datetime
+ ",CUSTOMNO" //报关单号/备案清单号 Varchar(20)
+ ",CUSTNO" //委托编号 Varchar(30)
+ ",GOODSSTANDARD" //规格 Varchar(100)
+ "," + dlGOODSPACKPFSL_OUT + " as GOODSPACKACTUAL" //实际件数 Numeric(18,4)
+ "," + dlGOODSPFSL_OUT + " as GOODSRKSLACTUAL" //实际数量 Numeric(18,4)
+ "," + feedays + " as FREESTORAGEPERIODAP" //应付免仓储期 int
+ ",'" + headData.OLDCUSTFEEDATE.AddDays(1) + "' as STARTBILLINGDATEAP" //应付开始计费日期 Datetime
+ ",1 as ISCHANGE" //是否是货权转移 Bit
+ ",AREANAME" //库位名称/储位 Varchar(100)
+ ",0 as MARKETVALUE" //市场货值 Numeric(18,2)
+ ",0 as BANKVALUE" //银行货值 Numeric(18,2)
+ ",BZTCHNO" //批次号/电子账册号 Varchar(100)
+ ",CLIENTBSNO" //不同客户的重复的出库单/客户出库仓单号 Varchar(100)
+ ",WHS_CODE" //库别 Varchar(20)
+ ",GOODSNAMEID" //品名id Varchar(50)
+ ",ACCDATE" //会计期间 Varchar(7)
+ ",0 as FEESTATUS" //费用状态 Bit
+ ",0 as ISLOCK2" //是否锁定 Bit
+ " from wms where GID='" + WMSGID + "'";
#endregion
bool bl6 = T_ALL_DA.GetExecuteSqlCommand(sSQL);
#region 入库仓储费率表
sSQL = "insert into wms_rate (GID,CUSTOMERNAME,FEETYPE,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,BSNO,ADDPRICE,ENDBILLINGDATE,RATETYPE,FEENAME,ISCHANGE,CAPPRICE)"
+ " select newid() as GID" //惟一编号" //Varchar(36)
+ ",'" + headData.CLIENTNAMEOLD.ToString() + "' as CUSTOMERNAME" //客户名称" //varchar(20)
+ ",FEETYPE" //费用类别" //Int
+ ",FEEGRADE" //计费等级" //Int
+ ",FEESCALE" //计费区间" //Int
+ ",FEEPRICE" //计费单价" //Numeric(18,2)
+ ",FEEUNIT" //计费单位" //Varchar(10)
+ ",'" + Convert.ToString(Session["USERID"]).Trim() + "' as CREATEUSER" //创建人" //Varchar(20)
+ ",getdate() as CREATETIME" //创建时间" //Datetime
+ ",'" + Convert.ToString(Session["SHOWNAME"]).Trim() + "' as MODIFIEDUSER" //最后一次操作人" //Varchar(20)
+ ",getdate() as MODIFIEDTIME" //最后一次操作时间" //Datetime
+ ",'货权转移' as REMARK" //备注" //varchar(100)
+ ",'" + newWmsGid + "' as BSNO" //关联GID" //varchar(100)
+ ",ADDPRICE" //增值价" //Numeric(18,2)
+ ",ENDBILLINGDATE" //结束计费日期" //Datetime
+ ",RATETYPE" //费率类型" //int
+ ",FEENAME" //费用中文名称" //varchar(100)
+ ",1 as ISCHANGE" //是否是货权转移" //bit
+ ",CAPPRICE" //封顶价" //Numeric(18,2)
+ " from wms_rate where bsno='" + WMSGID + "'";
#endregion
bool bl7 = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
#endregion
var jsonRespose = new JsonResponse
{
Success = result2.Success,
Message = result2.Message,
Data = WMSOUT_GuiGeDAL.GetData("outgid='" + headRow2.GID.ToString() + "'", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = "数据出错,不允许保存,请重试...",
Data = WMSOUT_GuiGeDAL.GetData("1<0", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
#endregion
#region 删除
public ContentResult Delete(string gids,bool eip=false)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = WMSOUT_GuiGeDAL.Delete(gids,eip,Convert.ToString(Session["USERID"]).Trim());
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 出库费用入账
public ContentResult setislock(string sOUTGID,bool EIP,string outType)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = WMSOUT_GuiGeDAL.setislock(sOUTGID,EIP, outType,Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["DEPTNAME"]), Convert.ToString(Session["SHOWNAME"]).ToString().Trim());
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 取消入账
public ContentResult setnotlock(string sOUTGID,bool EIP)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
DBResult result = WMSOUT_GuiGeDAL.setnotlock(sOUTGID, EIP,Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["DEPTNAME"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 清库
public ContentResult GetSysDeStockConfig(string userid)
{
var value = WMSOUT_GuiGeDAL.GetSysDeStockConfig("");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = value.ToString() });
return new ContentResult() { Content = json };
}
public ContentResult ClearStock(string data)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
bool bl = false;
var bodyList = JsonConvert.Deserialize<List<VwWmsDetailModels>>(data);
foreach (var enumValue in bodyList)
{
string sSQL = "update wms_in set GOODSPACKSTOCK=0,GOODSSTOCK=0 where GID='" + enumValue.GID.ToString().Trim() + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
sSQL = "update wms set GOODSPACKSTOCK=0,GOODSSTOCK=0 where gid='" + enumValue.WMSGID.ToString().Trim() + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
var jsonRespose = new JsonResponse { Success = bl, Message = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 生成费用
public ContentResult CreateCost(string OutBsno,string OutType)
{
string msg = "";
string userid = Session["USERID"] == null ? "" : Session["USERID"].ToString();
bool rst = WMSOUT_GuiGeDAL.CreateCost(OutBsno,OutType, userid, out msg);
var json = JsonConvert.Serialize(new { Success = rst, Message = msg, totalCount = 1 });
return new ContentResult() { Content = json };
}
#endregion
#region 良通捷运 保存
public ContentResult SaveEdit_Box(string opStatus, string data, string body, string outType)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var headData = JsonConvert.Deserialize<VwWmsDetailModels>(data);
var bodyList = JsonConvert.Deserialize<List<VwWmsDetail_BoxModels>>(body);
var errorstr = "";
//headData.FEESTATUS = false;
#region 保存
if (bodyList != null)
{
#region 基本变量
int n = 1;
string sOutBsno = headData.OUTBSNO_OUT == null ? "" : headData.OUTBSNO_OUT.ToString().Trim();
if (sOutBsno == "")
{
sOutBsno = WMSOUT_GuiGeDAL.getCodeRuleWmsOut("出库单号", "BSNO", 1, Convert.ToString(Session["USERID"]).Trim(), Convert.ToString(Session["COMPANYID"]).Trim());
}
Decimal dlGOODSPFSL_OUT = 0;//出库量
Decimal dlGOODSPACKPFSL_OUT = 0;//出库件数
Decimal dlARFEE_OUT = 0;//铅封费
Decimal dlARFEE_2_OUT = 0;//过磅费
#endregion
foreach (var enumValue in bodyList)
{
#region 明细表保存
WmsOutDetailModels headRow = new WmsOutDetailModels();
#region 默认值
headRow.INBSNO = enumValue.GID == null ? "" : enumValue.GID.ToString().Trim();//关联入库单wms_in的BSNO
headRow.OUTBSNO = sOutBsno;//OUTBSNO
headRow.BSNO = sOutBsno;//提单号
//headRow.BSNO = enumValue.BSNO_OUT == null ? "" : enumValue.BSNO_OUT.ToString().Trim();//提单号
//if (headRow.BSNO.ToString().Trim() == "")
//{
// headRow.BSNO = WMSOUT_GuiGeDAL.getCodeRuleWmsOut("出库明细单号", "BSNO", n, Convert.ToString(Session["USERID"]).Trim(), Convert.ToString(Session["COMPANYID"]).Trim());//提单号
//}
headRow.CLIENTGID = "";//CLIENTGID
headRow.CLIENTCODE = "";//客户编码
headRow.CUSTOMERNAME = enumValue.CUSTOMERNAME == null ? "" : enumValue.CUSTOMERNAME.ToString().Trim();//客户名称
headRow.DODATE = headData.DODATE_OUT == null ? DateTime.Now : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//操作时间
headRow.STORAGECODE = "";//仓库编码
headRow.STORAGENAME = enumValue.STORAGENAME == null ? "" : enumValue.STORAGENAME.ToString().Trim();//仓库名称
headRow.AREACODE = "";//储位编码
headRow.AREANAME = enumValue.AREANAME == null ? "" : enumValue.AREANAME.ToString().Trim();//储位名称
headRow.GOODSCODE = "";//货物编号
headRow.GOODSNAME = enumValue.GOODSNAME == null ? "" : enumValue.GOODSNAME.ToString().Trim();//货物名称
headRow.GOODSTYPE = "";//货物类型
headRow.GOODSMODEL = enumValue.GOODSMODEL == null ? "" : enumValue.GOODSMODEL.ToString().Trim();//型号//单位//品牌
headRow.GOODSSTANDARD = enumValue.GOODSSTANDARD == null ? "" : enumValue.GOODSSTANDARD.ToString().Trim();//规格
headRow.GOODSPACK = "";//包装
headRow.CHARGEUNIT = enumValue.CHARGEUNIT == null ? "" : enumValue.CHARGEUNIT.ToString().Trim();//CHARGEUNIT
headRow.GOODSPFSL = Decimal.Parse(enumValue.GOODSPFSL_OUT.ToString().Trim());//出库量
dlGOODSPFSL_OUT = dlGOODSPFSL_OUT + headRow.GOODSPFSL;
headRow.GOODSOUTFEE = 0;//仓储费
headRow.TRUCKNO = enumValue.TRUCKNO_OUT == null ? "" : enumValue.TRUCKNO_OUT.ToString().Trim();//TRUCKNO
headRow.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headRow.CREATETIME = DateTime.Now;//创建时间
headRow.REMARK = enumValue.REMARK_OUT == null ? "" : enumValue.REMARK_OUT.ToString().Trim();//备注
headRow.ASSOCIATEDNO = enumValue.ASSOCIATEDNO == null ? "" : enumValue.ASSOCIATEDNO.ToString().Trim();//ASSOCIATEDNO
headRow.GOODSPACKPFSL = Decimal.Parse(enumValue.GOODSPACKPFSL_OUT.ToString().Trim());//出库件数
dlGOODSPACKPFSL_OUT = dlGOODSPACKPFSL_OUT + headRow.GOODSPACKPFSL;
headRow.ARFEE = enumValue.ARFEE_OUT;//铅封费需求编号SR2017073000001
headRow.ARFEE_2 = enumValue.ARFEE_2_OUT;//过磅费需求编号SR2017073000001
dlARFEE_OUT += headRow.ARFEE;//铅封费
dlARFEE_2_OUT += headRow.ARFEE_2;//过磅费
headRow.APFEE = 0;//APFEE
headRow.ISLOCK = false;//ISLOCK
headRow.LOCKUSER = Convert.ToString(Session["USERID"]);//LOCKUSER
headRow.LOCKTIME = DateTime.Now;//LOCKTIME
headRow.GOODSOUTFEEAP = 0;//应付仓储费
headRow.CORPID = Convert.ToString(Session["COMPANYID"]).Trim();//CORPID
headRow.CLIENTNAMEOLD = headData.CLIENTNAMEOLD == null ? headRow.CUSTOMERNAME.ToString().Trim() : headData.CLIENTNAMEOLD.ToString().Trim();//CLIENTNAMEOLD
headRow.OLDCUSTFEEDATE = headData.OLDCUSTFEEDATE == null ? DateTime.Now : DateTime.Parse(headData.OLDCUSTFEEDATE.ToString().Trim());//上家承担仓储期限
headRow.STARTBILLINGDATE = DateTime.Now;//应收开始计费日期
headRow.ENDBILLINGDATE = headData.DODATE_OUT == null ? headRow.DODATE : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//应收结束计费日期
headRow.FEEDAYS = 0;//FEEDAYS
if (headRow.GOODSSTANDARD == null)
{
headRow.GOODSSLICE = 0;//片数/包装件数//需求编号SR2017061800001-7SR2017071100001
}
else
{
if (headRow.GOODSSTANDARD.ToString().Trim() == "")
{
headRow.GOODSSLICE = 0;//片数/包装件数//需求编号SR2017061800001-7SR2017071100001
}
else
{
Decimal dl1 = Decimal.Parse(headRow.GOODSSTANDARD.ToString());
int i1 = (int)dl1;
int i2 = (int)headRow.GOODSPACKPFSL;
int i3 = i2 / i1;
headRow.GOODSSLICE = i3;//片数/包装件数//需求编号SR2017061800001-7SR2017071100001
}
}
headRow.GOODSGRADE = "";//品名的等级
headRow.STARTBILLINGDATEAP = DateTime.Now;//应付开始计费日期
headRow.ENDBILLINGDATEAP = headData.DODATE_OUT == null ? headRow.DODATE : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//应付结束计费日期
headRow.FEEDAYSAP = 0;//FEEDAYSAP
headRow.ISCHANGE = false;//是否是货权转移
if (outType == "货权转移")
{
headRow.ISCHANGE = true;//是否是货权转移
}
headRow.MARKETVALUE = 0;//市场货值
headRow.BZTCHNO = enumValue.BZTCHNO == null ? "" : enumValue.BZTCHNO.ToString().Trim();//电子账册号
headRow.WHS_CODE = enumValue.WHS_CODE == null ? "" : enumValue.WHS_CODE.ToString().Trim();//库别
headRow.GOODSNAMEID = enumValue.GOODSNAMEID == null ? "" : enumValue.GOODSNAMEID.ToString().Trim();//品名gid
headRow.TRUCKTYPE = enumValue.TRUCKTYPE_OUT == null ? "" : enumValue.TRUCKTYPE_OUT.ToString().Trim();//需求编号SR2017073000001
headRow.ZHUANGXIEGONGID = enumValue.ZHUANGXIEGONGID_OUT == null ? "" : enumValue.ZHUANGXIEGONGID_OUT.ToString().Trim();//需求编号SR2017073000001
headRow.TRUCKKGS = Decimal.Parse(enumValue.TRUCKKGS_OUT.ToString().Trim());//需求编号SR2017073000001
headRow.QianFengNO = enumValue.QianFengNO == null ? "" : enumValue.QianFengNO.ToString().Trim();//需求编号SR2017073000001
#endregion
//
if (opStatus == "add" && enumValue.GID_OUT.ToString().Trim() == "")//"add"
{
headRow.GID = Guid.NewGuid().ToString();//唯一编码 newid() varchar (36)
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.GID = enumValue.GID_OUT.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
//var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
//return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (result.Success == true)
{
#region 出库后锁定 op_apply报关业务 BSSTATUS字段
if (enumValue.CHARGEUNIT.ToString().Trim() == "CBM" && enumValue.ISBONDED == 1)
{
string sSQL = "update op_apply set BSSTATUS=1 where WMSIN_GID='" + enumValue.GID.ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
#endregion
}
n++;
#endregion
}
#region 主表保存
WMSOUT_GuiGe headRow2 = new WMSOUT_GuiGe();
#region 默认值
headRow2.ASSOCIATEDNO = bodyList[0].ASSOCIATEDNO.ToString();//关联号
headRow2.BSNO = sOutBsno;//仓单明细号
headRow2.CLIENTGID = "";//CLIENTGID
headRow2.CLIENTCODE = "";//客户编码
headRow2.CUSTOMERNAME = bodyList[0].CUSTOMERNAME.ToString().Trim();//客户名称
headRow2.DODATE = headData.DODATE_OUT == null ? DateTime.Now : DateTime.Parse(headData.DODATE_OUT.ToString().Trim());//操作时间
headRow2.STORAGECODE = "";//仓库编码
headRow2.STORAGENAME = bodyList[0].STORAGENAME.ToString().Trim();//仓库名称
headRow2.AREACODE = "";//储位编码
headRow2.AREANAME = bodyList[0].AREANAME.ToString().Trim();//储位名称
headRow2.GOODSCODE = "";//货物编号
headRow2.GOODSNAME = bodyList[0].GOODSNAME.ToString().Trim();//货物名称
headRow2.GOODSTYPE = "";//货物类型
headRow2.GOODSMODEL = bodyList[0].GOODSMODEL.ToString().Trim();//型号//单位//品牌
headRow2.GOODSSTANDARD = bodyList[0].GOODSSTANDARD.ToString().Trim();//规格
headRow2.GOODSPACK = "";//包装
headRow2.GOODSPFSL = dlGOODSPFSL_OUT;//出库量
headRow2.GOODSOUTFEE = 0;//仓储费用
headRow2.TRUCKNO = "";//TRUCKNO
headRow2.REMARK = headData.OUTREMARK == null ? "" : headData.OUTREMARK.ToString().Trim();//备注
headRow2.ISDELETE = false;//是否废除
headRow2.DELETETIME = DateTime.Now;//废除时间
headRow2.DELETEUSER = Convert.ToString(Session["USERID"]);//废除操作人
headRow2.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人
headRow2.CREATETIME = DateTime.Now;//创建时间
headRow2.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次更新操作人
headRow2.MODIFIEDTIME = DateTime.Now;//最后一次更新操作时间
headRow2.GOODSPACKPFSL = dlGOODSPACKPFSL_OUT;//出库件数
headRow2.TRUCKNAME = headData.TRUCKNAME_OUT == null ? "" : headData.TRUCKNAME_OUT.ToString().Trim();//TRUCKNAME
headRow2.WMSOP = Convert.ToString(Session["SHOWNAME"]).Trim();//WMSOP
headRow2.STOREMAN = "";//STOREMAN
headRow2.ISLOCK = false;//ISLOCK
headRow2.LOCKUSER = "";//LOCKUSER
headRow2.LOCKTIME = DateTime.Now;//LOCKTIME
headRow2.GOODSOUTFEEAP = 0;//GOODSOUTFEEAP
headRow2.ARFEE = dlARFEE_OUT;//ARFEE需求编号SR2017073000001
headRow2.ARFEE_2 = dlARFEE_2_OUT;//ARFEE需求编号SR2017073000001
headRow2.APFEE = 0;//APFEE
headRow2.INSPECTIONNO = "";//INSPECTIONNO
headRow2.CUSTOMNO = bodyList[0].CUSTOMNO.ToString().Trim();//CUSTOMNO
headRow2.CORPID = Convert.ToString(Session["COMPANYID"]).Trim();//CORPID
headRow2.CLIENTNAMEOLD = headData.CLIENTNAMEOLD == null ? headRow2.CUSTOMERNAME.ToString().Trim() : headData.CLIENTNAMEOLD.ToString().Trim();//CLIENTNAMEOLD
headRow2.OLDCUSTFEEDATE = headData.OLDCUSTFEEDATE == null ? DateTime.Now : DateTime.Parse(headData.OLDCUSTFEEDATE.ToString().Trim());//OLDCUSTFEEDATE
headRow2.CLIENTBSNO = "";//CLIENTBSNO
headRow2.ARCLIENT = headData.ARCLIENT == null ? headRow2.CUSTOMERNAME.ToString().Trim() : headData.ARCLIENT.ToString().Trim();//ARCLIENT
headRow2.INGIDNEW = "";//INGIDNEW
headRow2.TOTALNO = "";//TOTALNO
headRow2.REMARK2 = "";//REMARK2
headRow2.VALIDDATE = DateTime.Now;//VALIDDATE
headRow2.CHARGEUNIT = bodyList[0].CHARGEUNIT.ToString().Trim();//CHARGEUNIT
headRow2.MBLNONEW = "";//MBLNONEW
headRow2.ISCHANGE = false;//ISCHANGE
if (outType == "货权转移")
{
headRow2.ISCHANGE = true;//是否是货权转移
}
headRow2.MARKETVALUE = 0;//MARKETVALUE
headRow2.ARCLIENTWMSOUT = headData.ARCLIENTWMSOUT == null ? headRow2.CUSTOMERNAME.ToString().Trim() : headData.ARCLIENTWMSOUT.ToString().Trim();//ARCLIENTWMSOUT
headRow2.ISCOLLECTING = false;//ISCOLLECTING
headRow2.WMSOUTSTATUS = 0;//WMSOUTSTATUS
headRow2.BZTCHNO = bodyList[0].BZTCHNO.ToString().Trim();//电子账册号
headRow2.WHS_CODE = bodyList[0].WHS_CODE.ToString().Trim();//库别
headRow2.GOODSNAMEID = bodyList[0].GOODSNAMEID.ToString().Trim();//品名gid
headRow2.ACCDATE = headData.ACCDATE_OUT == null ? "" : headData.ACCDATE_OUT.ToString().Trim();//会计期间
headRow2.FEESTATUS = headData.FEESTATUSREF_OUT.ToString().Trim() == "锁定" ? true : false;//费用状态
#endregion
//
if (opStatus == "add" && headData.OUTGID.ToString().Trim() == "")//"add"
{
headRow2.GID = Guid.NewGuid().ToString();//唯一编码 newid() varchar (36)
headRow2.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow2.GID = headData.OUTGID.ToString().Trim();// bodyList[0].OUTGID.ToString();//唯一编码
headRow2.DbOperationType = DbOperationType.DbotUpd;
headRow2.ModelUIStatus = "E";
}
//
var modb2 = new ModelObjectDB();
DBResult result2 = modb2.Save(headRow2);
if (result2.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
//var jsonRespose = new JsonResponse { Success = false, Message = "重复,不允许保存!" };
//return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
if (result2.Success == true)
{
#region 出库件数 返 入库库存//需求编号SR2017073000001
foreach (var enumValue in bodyList)
{
if (enumValue.CHARGEUNIT.ToString().Trim() == "箱")
{
string sSQL = "update wms_in set GOODSPACKSTOCK=GOODSPACK-isnull((select sum(GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_DETAIL where GID='" + enumValue.GID.ToString().Trim() + "'),0),GOODSSTOCK=GOODSRKSL-isnull((select sum(GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_DETAIL where GID='" + enumValue.GID.ToString().Trim() + "'),0) where GID='" + enumValue.GID.ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
sSQL = "update wms set GOODSPACKSTOCK=isnull((select sum(GOODSPACKSTOCK) as GOODSPACKSTOCK from wms_in where ASSOCIATEDNO='" + enumValue.WMSGID.ToString().Trim() + "'),0),GOODSSTOCK=isnull((select sum(GOODSSTOCK) as GOODSSTOCK from wms_in where ASSOCIATEDNO='" + enumValue.WMSGID.ToString().Trim() + "'),0) where gid='" + enumValue.WMSGID.ToString().Trim() + "'";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
else
{
string sSQL = "update wms set GOODSPACKSTOCK=GOODSPACK-isnull((select sum(GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_DETAIL where GID='" + enumValue.GID.ToString().Trim() + "'),0),GOODSSTOCK=GOODSRKSL-isnull((select sum(GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_DETAIL where GID='" + enumValue.GID.ToString().Trim() + "'),0) where GID='" + enumValue.GID.ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
}
}
#endregion
#region 出库后锁定op_apply报关业务BSSTATUS字段
//foreach (var enumValue in bodyList)
//{
// if (enumValue.CHARGEUNIT.ToString().Trim() == "CBM" && enumValue.ISBONDED == 1)
// {
// string sSQL = "update op_apply set BSSTATUS=1 where WMSIN_GID='" + enumValue.GID.ToString().Trim() + "' and ISCLEAR='1' and CUSTOMTYPE='出区报关'";
// bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
// }
//}
#endregion
}
}
#endregion
//
var jsonRespose = new JsonResponse
{
Success = result2.Success,
Message = result2.Message,
Data = WMSOUT_GuiGeDAL.GetData_Box("outgid='" + headRow2.GID.ToString() + "'", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = "数据出错,不允许保存,请重试...",
Data = WMSOUT_GuiGeDAL.GetData_Box("1<0", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
#endregion
#region 出库明细表查询 包含两部分 已保存的和待出库的。用于良通捷运的按箱出入逻辑
public ContentResult GetDetailList_Box(string opStatus, string condition)
{
var dataList = WMSOUT_GuiGeDAL.GetDetailList_Box(opStatus, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData_Box(string condition)
{
VwWmsDetailModels head = null;
head = WMSOUT_GuiGeDAL.GetData_Box(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
//打印明细列表
public ContentResult GetDataListStr_Box(string condition)
{
var dataListStr = WMSOUT_GuiGeDAL.GetDataListStr_Box(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
#endregion
}
}