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.

4522 lines
232 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.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using System.Xml;
using DSWeb.SoftMng.BLL;
using DSWeb.SoftMng.DAL;
using DSWeb.SoftMng.Model;
using DSWeb.SoftMng.XmlHelper;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using HcUtility.Comm;
using Newtonsoft.Json.Linq;
using DSWeb.Areas.MvcShipping.Comm;
using DSWeb.MvcShipping.DAL.MsOpApplyDAL;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.MvcShipping.Models.MsOpApply_BOSH383;
using DSWeb.MvcShipping.Models.MsOpApply_BOSH385;
using DSWeb.Areas.MvcShipping.DB;
using System.Text.RegularExpressions;
using HcUtility.Core;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.MvcShipping.DAL.MsOpSeaiDAL;
using DSWeb.MvcShipping.DAL.MsCodeSgAuditRule;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Common.DB;
using DSWeb.Common.Helper;
using Terminal_CDMA;
using DSWeb.Areas.Mobile.DAL;
using DSWeb.MvcShipping.Models.MsCodeSgAuditRule;
using sun.net.idn;
using DSWeb.MvcShipping.Models.MsOpSeai;
using System.Data.Entity.Migrations;
using DSWeb.EntityDA;
using System.Configuration;
namespace DSWeb.SoftMng.Controllers
{
public class ExportController : Controller
{
private readonly DecHeadBLL bll = new DecHeadBLL();
private readonly DecListBLL lbll = new DecListBLL();
private readonly ContainerBLL cbll = new ContainerBLL();
private readonly LicenseDocuBLL dbll = new LicenseDocuBLL();
private readonly DecFreeTxBLL tbll = new DecFreeTxBLL();
private readonly DecGoodsLimitBLL gbll = new DecGoodsLimitBLL();
private readonly DecGoodsLimitVinBLL vbll = new DecGoodsLimitVinBLL();
private readonly DecCopLimitBLL ebll = new DecCopLimitBLL();
private readonly DecRequestCertBLL rcbll = new DecRequestCertBLL();
private readonly DecCopLimitBLL clbll = new DecCopLimitBLL();
private readonly DecOtherPackBLL opbll = new DecOtherPackBLL();
#region View
/// <summary>
/// 首页
/// </summary>
/// <returns></returns>
//[ModuleAuthFilter(Name = "secRegist")]//过滤器
public ActionResult Index()
{
if (Session["CODENAME"] == null)
Response.Redirect("/login.aspx");
return View();
}
public ActionResult Single() {
DecModelBLL mbll = new DecModelBLL();
var model = mbll.GetModelList("type=0").FirstOrDefault();
if (model != null)
ViewData["AgentInfo"] = model.Model;
var pmodel = bll.GetModelList("PDate in (select min(pdate) from DecHead)").FirstOrDefault();
if (pmodel != null)
ViewData["FirstRecord"] = pmodel;
return View();
}
public ActionResult SingleAudit()
{
return View();
}
/// <summary>
/// 模板管理
/// </summary>
/// <returns></returns>
public ActionResult DecModel()
{
if (Session["CODENAME"] == null)
Response.Redirect("/login.aspx");
return View();
}
#endregion
#region Handler
/// <summary>
/// 对应 单一窗口 暂存 上传 按钮
/// </summary>
/// <param name="headData"></param>
/// <param name="dataList"></param>
/// <param name="containerList"></param>
/// <param name="licensedocuList"></param>
/// <param name="decfreeTx"></param>
/// <param name="decGoodsLimitList"></param>
/// <param name="decGoodsLimitVinList"></param>
/// <param name="decRequestCert"></param>
/// <param name="decCopLimit"></param>
/// <param name="decOtherPack"></param>
/// <param name="action"></param>
/// <returns></returns>
public JsonResult Save(string headData, string dataList, string containerList, string licensedocuList, string decfreeTx, string decGoodsLimitList, string decGoodsLimitVinList, string decRequestCert, string decCopLimit, string decOtherPack, string action)
{
try
{
JavaScriptSerializer json = new JavaScriptSerializer();
//DecHead
DecHead model = json.Deserialize<DecHead>(headData);
MsOpApply applyhead = MsOpApplyDAL.GetData("BSNO='" + model.BSNO + "'");
model.AgentStatus = action == "post" ? "已上传" : "暂存";
/* CopCode
* 录入单位代码
*/
model.CopCode = "";
/* CopCode
* 录入单位名称
*/
model.CopName = "";
/* IEFlag
* 进出口标志
* “I”进口
* “E”出口
*/
model.IEFlag = "E";
if (applyhead.BSTYPEREF.IndexOf("进口")>0) model.IEFlag = "I";
/* Type
* 报关单类型
前两位:一般报关单填空值;
ML保税区进出境备案清单
SD: “属地申报,口岸验放”报关单
LY:两单一审备案清单;
CL:汇总征税报关单;
SS:”属地申报,属地验放”报关单
ZB自主报税
SW税单无纸化
SZ水运中转普通报关单
SM水运中转保税区进出境备案清单
SL水运中转两单一审备案清单
Z:自报自缴
MF:公路舱单跨境快速通关报关单
MK: 公路舱单跨境快速通关备案清单
ZY:自报自缴,两单一审备案清单
ZC:自报自缴,汇总征税报关单
ZW:自报自缴,税单无纸化
ZF:自报自缴,公路舱单跨境快速通关
ZX自报自缴多项式联运
MT:多项式联运。
EX低值快速货物报关单
EC低值快速货物汇总征税报关单
EZ低值快速货物自报自缴报关单
ES低值快速货物汇总征税、自报自缴报关单。
*/
//20210621 改为从"cusRemark": "{\\"cusRemark\\":\\"SW\\"}", 中解析出两个字母
//然后
//第三位:
//0 / 空:整合申报一次录入;
//1概要申报
//2完整申报;
//3两步申报一次录入人工提交如之前进行过辅助提交该值表示取消辅助提交且调整为人工提交。
//4两步申报一次录入辅助提交
//第四位涉证标记0 - 否1 - 是,概要申报必传。
//第五位涉检标记0 - 否1 - 是,概要申报必传。
//第六位涉税标记0 - 否1 - 是,概要申报必传
model.Type = "";
/* EdiId
* 报关标志
* 1普通报关
* 3北方转关提前
* 5南方转关提前
* 6普通报关运输工具名称以开头南方H2000直转
*/
model.EdiId = "1";
/* PDate
* 打印日期
*/
model.PDate = DateTime.Now;
/* TypistNo
* 录入员IC卡号
*/
model.TypistNo = "";
/* InputerName
* 录入员名称
*/
model.InputerName = "";
/* PartenerID
* 申报人标识
*/
model.PartenerID = "";
/* DeclTrnRel
* 报关/转关关系标志
* 0一般报关单
* 1转关提前报关单
*/
model.DeclTrnRel = "0";
/* ChkSurety
* 担保验放标志
*/
model.ChkSurety = "";
/* CheckFlow
* 查验分流:
* 1:表示是查验分流
* 0:表示不是查验分流
*/
model.CheckFlow = "";
/* TaxAaminMark
* 税收征管标记:
* 0-无
* 1-有
*/
model.TaxAaminMark = "";
/*
* 入境口岸代码【货物从运输工具卸离的第一个境内口岸】
*/
model.EntyPortCode = model.DespPortCode;
/* BLNo
* 提货单号【本批货物的提货单或出库单号码】
*/
model.BLNo = "";
if (model.DDateStr!="")
model.DDate= DateTime.ParseExact(model.DDateStr, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
if (model.IEDateStr != "")
model.IEDate= DateTime.ParseExact(model.IEDateStr, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
//20200109 需求编号SR2020010700004
//20200306 由于单一窗口和报关业务的关系已改为一对一 故此序列号改为使用报关业务的CUSTNO
if (string.IsNullOrWhiteSpace(model.ClientSeqNo))
{
//var ClientSeqNo = MsSysBillNoSetDAL.GetNewNo("报关业务", "委托编号", "0125", Session["COMPANYID"].ToString(), System.DateTime.Now.ToString("yyyy-MM-dd"));
//model.ClientSeqNo = ClientSeqNo;
model.ClientSeqNo = applyhead.CUSTNO;
}
if (string.IsNullOrEmpty(model.GID))
{
model.GID = Guid.NewGuid().ToString();
bll.Add(model);
}
else
bll.Update(model);
//decGoodsLimitList
List<DecGoodsLimit> list3 = json.Deserialize<List<DecGoodsLimit>>(decGoodsLimitList);
gbll.DeleteListWhere("PID in (select GID from DecList where PID ='" + model.GID + "')");
foreach (var item in list3)
gbll.Add(item);
//decGoodsLimitVinList
List<DecGoodsLimitVin> list4 = json.Deserialize<List<DecGoodsLimitVin>>(decGoodsLimitVinList);
vbll.DeleteListWhere("PID in (select GID from DecGoodsLimit where PID in (select GID from DecList where PID ='" + model.GID + "'))");
foreach (var item in list4)
vbll.Add(item);
//DecList
List<DecList> list = json.Deserialize<List<DecList>>(dataList);
lbll.DeleteListWhere("PID='" + model.GID + "'");
foreach (var item in list)
{
item.PID = model.GID;
lbll.Add(item);
}
//containerList
List<Container> list1 = json.Deserialize<List<Container>>(containerList);
cbll.DeleteListWhere("PID='" + model.GID + "'");
foreach (var item in list1)
{
item.PID = model.GID;
cbll.Add(item);
}
//licensedocuList
List<LicenseDocu> list2 = json.Deserialize<List<LicenseDocu>>(licensedocuList);
dbll.DeleteListWhere("PID='" + model.GID + "'");
foreach (var item in list2)
{
item.PID = model.GID;
dbll.Add(item);
}
//decfreeTx
//右下角关联业务信息
tbll.DeleteListWhere("PID='" + model.GID + "'");
DecFreeTx tmodel = json.Deserialize<DecFreeTx>(decfreeTx);
tmodel.GID = Guid.NewGuid().ToString();
tmodel.PID = model.GID;
tbll.Add(tmodel);
//decRequestCert
List<DecRequestCert> list5 = json.Deserialize<List<DecRequestCert>>(decRequestCert);
rcbll.DeleteListWhere("PID='" + model.GID + "'");
foreach (var item in list5)
{
item.PID = model.GID;
rcbll.Add(item);
}
//decOtherPack
List<DecOtherPack> list6 = json.Deserialize<List<DecOtherPack>>(decOtherPack);
opbll.DeleteListWhere("PID='" + model.GID + "'");
foreach (var item in list6)
{
item.PID = model.GID;
opbll.Add(item);
}
//decCopLimit
List<DecCopLimit> list7 = json.Deserialize<List<DecCopLimit>>(decCopLimit);
clbll.DeleteListWhere("PID='" + model.GID + "'");
foreach (var item in list7)
{
item.PID = model.GID;
clbll.Add(item);
}
if (action == "post")
{
model.EntyPortCode = model.DespPortCode;
//生成XML
XmlDocument doc = new XmlDocument();
XmlDeclaration ver = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(ver);
//根节点
XmlElement root = doc.CreateElement("DecMessage");
doc.AppendChild(root);
root.SetAttribute("xmlns", "http://www.chinaport.gov.cn/dec");
//报关单表头
XmlHelper<DecHead>.EntityToXml(doc, model, root, new ArrayList() { "Insp_cert", "AgentStatus" });
//报关单表体
XmlElement decLists = doc.CreateElement("DecLists");
root.AppendChild(decLists);
foreach (var item in list)
{
var decxmlItem = XmlHelper<DecList>.EntityToXml(doc, item, decLists);
//产品许可证
XmlElement decGoodsLimits = doc.CreateElement("DecGoodsLimits");
decxmlItem.AppendChild(decGoodsLimits);
foreach (var item1 in list3.FindAll(p => p.PID == item.GID))
{
var limitxmlItem = XmlHelper<DecGoodsLimit>.EntityToXml(doc, item1, decGoodsLimits);
var vinModel = list4.Find(p => p.PID == item1.GID);
if (vinModel != null)
//许可证VIN信息
XmlHelper<DecGoodsLimitVin>.EntityToXml(doc, vinModel, limitxmlItem, new ArrayList() { "GoodsNoVin" });
}
}
//集装箱信息
var containerXml = XmlHelper<Container>.EntityToXml(doc, list1, "DecContainers");
root.AppendChild(containerXml);
//单证信息
var licenseDocuXml = XmlHelper<LicenseDocu>.EntityToXml(doc, list2, "DecLicenseDocus");
root.AppendChild(licenseDocuXml);
//申报要素
var requestCertXml = XmlHelper<DecRequestCert>.EntityToXml(doc, list5, "DecRequestCerts");
root.AppendChild(requestCertXml);
//其他包装
var otherPackXml = XmlHelper<DecOtherPack>.EntityToXml(doc, list6, "DecOtherPacks");
root.AppendChild(otherPackXml);
//企业资质
var copLimitXml = XmlHelper<DecCopLimit>.EntityToXml(doc, list7, "DecCopLimits");
root.AppendChild(copLimitXml);
//自由文本信息
XmlHelper<DecFreeTx>.EntityToXml(doc, tmodel, root);
//报关单签名
var signmodel = new DecSignBLL().GetModelList("").FirstOrDefault();
//ClientSeqNo 客户端报关单编号 需求编号SR2020010700004
signmodel.ClientSeqNo = model.ClientSeqNo;
XmlHelper<DecSign>.EntityToXml(doc, signmodel, root);
var newPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "OutBox");
Directory.CreateDirectory(newPath);
doc.Save(Path.Combine(newPath, model.GID + ".xml"));
bll.UpdateBillState(model.GID, "L","");
}
return Json(new { success = true, gid = model.GID });
}
catch (Exception se)
{
return Json(new { success = false, message = se.Message + se.Source });
}
}
/// <summary>
/// 对应 单一窗口 提交、复核 按钮
/// </summary>
/// <param name="billGID"></param>
/// <param name="billState"></param>
/// <returns></returns>
public JsonResult Audit(string billGID, string billState,string reason="",string isaudit="0")
{
try
{
if (billState == "P"&& isaudit=="0") {
var AuditdataList = MsCodeSgAuditRuleDAL.GetDataList("", Convert.ToString(Session["COMPANYID"]));
var CodeSgAuditRuleGroupList = new List<CodeSgAuditRuleGroup>();
foreach (var audit in AuditdataList)
{ var newCodeSgAuditRuleGroup=CodeSgAuditRuleGroupList.Find(x => x.SGANO == audit.SGANO);
if (newCodeSgAuditRuleGroup == null)
{
var CodeSgAuditRuleGroup = new CodeSgAuditRuleGroup();
CodeSgAuditRuleGroup.SGANO = audit.SGANO;
var CodeSgAuditRuleList = new List<CodeSgAuditRule>();
CodeSgAuditRuleList.Add(audit);
CodeSgAuditRuleGroup.CodeSgAuditRuleList = CodeSgAuditRuleList;
CodeSgAuditRuleGroupList.Add(CodeSgAuditRuleGroup);
}
else {
newCodeSgAuditRuleGroup.CodeSgAuditRuleList.Add(audit);
}
}
var model = bll.GetModel(billGID);
var list = lbll.GetModelList(0, 100, "PID='" + billGID + "'", String.Format("{0} {1}", "", "CONVERT(int, gno)"));
var propArr = model.GetType().GetProperties();
var errorstr = "";
foreach (var CodeSgAuditRuleGroup in CodeSgAuditRuleGroupList) {
var iserror = true;
var billerrorstr = "";
foreach (var audit in CodeSgAuditRuleGroup.CodeSgAuditRuleList) {
if (1==2)
{
}
else
{
if (audit.BSTYPE == "DecHead")
{
var prop = propArr.FirstOrDefault(p => p.Name.ToLower() == audit.FIELDNAME.ToLower());
if (audit.COMPARETYPE == "字段")
{
var newprop = propArr.FirstOrDefault(p => p.Name.ToLower() == audit.VALUE.ToLower());
if (prop != null && newprop != null)
{
if (audit.COMPARE == "包含")
{
if (prop.GetValue(model).ToString().IndexOf(newprop.GetValue(model).ToString()) > 0)
{
if(!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
iserror = true;
}
else
{
iserror = false;
}
}
else if (audit.COMPARE == "不包含")
{
if (prop.GetValue(model).ToString().IndexOf(newprop.GetValue(model).ToString()) <= 0)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
iserror = true;
}
else
{
iserror = false;
}
}
else if (audit.COMPARE == "大于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) > Convert.ToDecimal(newprop.GetValue(model)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
}
else {
iserror = false;
}
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) > Convert.ToInt32(newprop.GetValue(model)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; }
else {
iserror = false;
}
}
}
else if (audit.COMPARE == "小于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) < Convert.ToDecimal(newprop.GetValue(model)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; }
else {
iserror = false;
}
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) < Convert.ToInt32(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
}
else if (audit.COMPARE == "大于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) >= Convert.ToDecimal(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) >= Convert.ToInt32(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
}
else if (audit.COMPARE == "小于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) <= Convert.ToDecimal(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) <= Convert.ToInt32(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
}
else if (audit.COMPARE == "等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) == Convert.ToDecimal(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) == Convert.ToInt32(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
else
{
if (prop.GetValue(model).ToString() == newprop.GetValue(model).ToString())
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
}
else if (audit.COMPARE == "不等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) != Convert.ToDecimal(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) != Convert.ToInt32(newprop.GetValue(model)))
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
else
{
if (prop.GetValue(model).ToString() != newprop.GetValue(model).ToString())
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
else iserror = false;
}
}
}
}
else
{
if (prop != null)
{
if (audit.COMPARE == "包含")
{
if (audit.VALUE.IndexOf(";") > 0)
{
var valuelist = audit.VALUE.Split(';');
var isnobh = false;
foreach (var valuestr in valuelist)
{
if (prop.GetValue(model).ToString().IndexOf(valuestr) > 0) isnobh = true;
}
if (isnobh) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else
{
if (prop.GetValue(model).ToString().IndexOf(audit.VALUE) > 0) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
}
else if (audit.COMPARE == "不包含")
{
if (audit.VALUE.IndexOf(";") > 0)
{
var valuelist = audit.VALUE.Split(';');
var isnobh = false;
foreach (var valuestr in valuelist)
{
if (prop.GetValue(model).ToString().IndexOf(valuestr) > 0) isnobh = true;
}
if (!isnobh)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else
if (prop.GetValue(model).ToString().IndexOf(audit.VALUE) <= 0) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
else if (audit.COMPARE == "大于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) > Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) > Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
}
else if (audit.COMPARE == "小于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) < Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) < Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
}
else if (audit.COMPARE == "大于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) >= Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) >= Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
}
else if (audit.COMPARE == "小于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) <= Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) <= Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
}
else if (audit.COMPARE == "等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) == Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) == Convert.ToInt32(audit.VALUE))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.GetValue(model).ToString() == audit.VALUE)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (audit.COMPARE == "不等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(model)) != Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(model)) != Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (prop.GetValue(model).ToString() != audit.VALUE)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
}
}
}
if (audit.BSTYPE == "DecList")
{
foreach (var dec in list)
{
var decArr = dec.GetType().GetProperties();
var prop = decArr.FirstOrDefault(p => p.Name.ToLower() == audit.FIELDNAME.ToLower());
if (audit.COMPARETYPE == "字段")
{
var newprop = decArr.FirstOrDefault(p => p.Name.ToLower() == audit.VALUE.ToLower());
if (prop != null && newprop != null)
{
if (audit.COMPARE == "包含")
{
if (prop.GetValue(dec).ToString().IndexOf(newprop.GetValue(dec).ToString()) > 0) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
else if (audit.COMPARE == "不包含")
{
if (prop.GetValue(dec).ToString().IndexOf(newprop.GetValue(dec).ToString()) <= 0)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; }
else iserror = false;
}
else if (audit.COMPARE == "大于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) > Convert.ToDecimal(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) > Convert.ToInt32(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
}
else if (audit.COMPARE == "小于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) < Convert.ToDecimal(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) < Convert.ToInt32(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
}
else if (audit.COMPARE == "大于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) >= Convert.ToDecimal(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) >= Convert.ToInt32(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
}
else if (audit.COMPARE == "小于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) <= Convert.ToDecimal(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) <= Convert.ToInt32(newprop.GetValue(dec))) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
}
else if (audit.COMPARE == "等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) == Convert.ToDecimal(newprop.GetValue(dec)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
}
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) == Convert.ToInt32(newprop.GetValue(dec)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
}
else iserror = false;
}
else if (prop.GetValue(dec).ToString() == newprop.GetValue(dec).ToString()) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
else if (audit.COMPARE == "不等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) != Convert.ToDecimal(newprop.GetValue(dec)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
}
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) != Convert.ToInt32(newprop.GetValue(dec)))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF;
}
else iserror = false;
}
else if (prop.GetValue(dec).ToString() != newprop.GetValue(dec).ToString()) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUEREF; } else iserror = false;
}
}
}
else
{
if (prop != null)
{
if (audit.COMPARE == "包含")
{
if (audit.VALUE.IndexOf(";") > 0)
{
var valuelist = audit.VALUE.Split(';');
var isnobh = false;
foreach (var valuestr in valuelist)
{
if (prop.GetValue(dec).ToString().IndexOf(valuestr) > 0) isnobh = true;
}
if (isnobh)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.GetValue(dec).ToString().IndexOf(audit.VALUE) > 0) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
else if (audit.COMPARE == "不包含")
{
if (audit.VALUE.IndexOf(";") > 0)
{
var valuelist = audit.VALUE.Split(';');
var isnobh = false;
foreach (var valuestr in valuelist)
{
if (prop.GetValue(dec).ToString().IndexOf(valuestr) > 0) isnobh = true;
}
if (!isnobh)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.GetValue(dec).ToString().IndexOf(audit.VALUE) <= 0) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
else if (audit.COMPARE == "大于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) > Convert.ToDecimal(audit.VALUE))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) > Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
}
else if (audit.COMPARE == "小于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) < Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) < Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
}
else if (audit.COMPARE == "大于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) >= Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) >= Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
}
else if (audit.COMPARE == "小于等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) <= Convert.ToDecimal(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) <= Convert.ToInt32(audit.VALUE)) {
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; } else iserror = false;
}
}
else if (audit.COMPARE == "等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) == Convert.ToDecimal(audit.VALUE))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) == Convert.ToInt32(audit.VALUE))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.GetValue(dec).ToString() == audit.VALUE)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
else if (audit.COMPARE == "不等于")
{
if (prop.PropertyType == typeof(decimal?))
{
if (Convert.ToDecimal(prop.GetValue(dec)) != Convert.ToDecimal(audit.VALUE))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.PropertyType == typeof(int?))
{
if (Convert.ToInt32(prop.GetValue(dec)) != Convert.ToInt32(audit.VALUE))
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE;
}
else iserror = false;
}
else if (prop.GetValue(dec).ToString() != audit.VALUE)
{
if (!string.IsNullOrEmpty(audit.WARNINGSTR))
billerrorstr = billerrorstr + Environment.NewLine + audit.WARNINGSTR;
else
billerrorstr = billerrorstr + Environment.NewLine + audit.FIELDNAMEREF + "[" + audit.COMPARE + "]" + audit.VALUE; }
else iserror = false;
}
}
}
}
}
}
}
if (iserror) {
errorstr = errorstr + "<br>序号:" + CodeSgAuditRuleGroup.SGANO + "(" + billerrorstr + ")";
}
//if (!string.IsNullOrEmpty(billerrorstr)) {
// errorstr = errorstr+ "<br>序号:" + CodeSgAuditRuleGroup.SGANO+"("+billerrorstr+")";
//}
}
//20230824 增加校验:
//1:货值超过50万提示确认币值
//2、进出口报关单分项净重合计要与净重一致系统比对提示
//3、境内收发货人与生产销售单位保持一致不一致需要提示是否确认用查询条件方式解决
//4、进口报关单添加复核提示特殊关系确认用查询条件方式解决
//5、原产国与启运国一致否则提示用查询条件方式解决
//6、分项价格合计总数
var ch = .getHelper(model, list);
ch.GetErrorString(ref errorstr);
if (errorstr != "") {
return Json(new { success = false, message ="审核条件不通过:"+errorstr});
}
}
if (billState == "S" || billState == "P" || billState == "R") {
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdupdateStatus =
db.GetSqlStringCommand(
@"insert op_status (ST_ID,BSNO,STATUS,ISCOMP,COMPTIME,COMPOP,INPUTTIME,STTYPE,REMARK)
Select NEWID(),BSNO,@STATUS,@ISCOMP,@COMPTIME,@COMPOP,@INPUTTIME,'1',@REMARK FROM DecHead WHERE GID IN ('" + billGID + "') ");
var statusstr ="报关单待复核";
if (billState == "P") {
statusstr = "报关单可正式申报";
if (BasicDataRefDAL.webconfig("JGWL"))
{
//20230904 金港物流 【系统中复审通过的“报关单可正式申报”状态改为“报关单复核完成”)】
statusstr = "报关单复核完成";
}
}
if (billState == "R") statusstr = "报关单复核驳回";
cmdupdateStatus.Parameters.Clear();
db.AddInParameter(cmdupdateStatus, "@STATUS", DbType.String,statusstr);
db.AddInParameter(cmdupdateStatus, "@ISCOMP", DbType.Boolean, true);
db.AddInParameter(cmdupdateStatus, "@COMPTIME", DbType.DateTime, DateTime.Now);
db.AddInParameter(cmdupdateStatus, "@COMPOP", DbType.String, Convert.ToString(Session["SHOWNAME"]));
db.AddInParameter(cmdupdateStatus, "@INPUTTIME", DbType.DateTime, DateTime.Now);
db.AddInParameter(cmdupdateStatus, "@REMARK", DbType.String, reason);
db.ExecuteNonQuery(cmdupdateStatus, tran);
tran.Commit();
}
catch (Exception)
{
}
}
}
if (bll.UpdateBillState(billGID, billState,reason) > 0)
{
return Json(new { success = true });
}
else
{
return Json(new { success = true });
}
}
catch (Exception se)
{
return Json(new { success = false, message = se.Message + se.Source });
}
}
/// <summary>
///20230824 增加校验:
///1:货值超过50万提示确认币值
///2、进出口报关单分项净重合计要与净重一致系统比对提示
///3、境内收发货人与生产销售单位保持一致不一致需要提示是否确认用查询条件方式解决
///4、进口报关单添加复核提示特殊关系确认用查询条件方式解决
///5、原产国与启运国一致否则提示用查询条件方式解决
///6、分项价格合计总数
/// </summary>
public class {
public DecHead head { get; set; }
public List<DecList> body { get; set; }
public () { }
public static getHelper(DecHead Head, List<DecList> Body) {
var result = new ();
result.head = Head;
result.body = Body;
return result;
}
public DBResult DoCheck(string checktype) {
var result = new DBResult();
result.OK();
if (checktype=="明细净重")
{ ///2、进出口报关单分项净重合计要与净重一致系统比对提示
//用declist.FirstQty 的合计 与 dechead.NetWt 比对 如不一致则提示
var = 0M;
foreach (var item in body) {
if (item.FirstUnit_Text == "千克")
{
+= item.FirstQty == null ? 0 : (decimal)item.FirstQty;
}
}
if (!=0M && != head.NetWt) {
result.SetErrorInfo($"明细合计净重{第一法定数量合计},与报关单净重{head.NetWt}不相等,请注意核对!");
}
}
if (checktype == "明细价格")
{
///1:货值超过50万提示确认币值
//用declist.DeclTotal 的合计 高于系统配置的50w则提示
var = 0M;
foreach (var item in body)
{
+= item.DeclTotal == null ? 0 : (decimal)item.DeclTotal;
}
var maxvalue = 500000M;
var setamountmax= MsSysParamSetDAL.GetSysParamValue("OpApply_Check_MaxAmount");
if (!string.IsNullOrEmpty(setamountmax))
{
try {
maxvalue = Convert.ToDecimal(setamountmax);
}catch (Exception) { }
}
if ( > maxvalue)
{
result.SetErrorInfo($"金额合计{金额合计}大于警戒值{maxvalue},请注意核对!");
}
///6、分项价格合计总数
//用declist.FirstQty 的合计 与 dechead.NetWt 比对 如不一致则提示
//头表没有金额合计 放弃
}
if (checktype == "国家比对")
{
//1 头表ieflag=e时 对比头表的tradecountry 和明细的DestinationCountry
//2 头表ieflag=i时 对比头表的tradecountry 和明细的originCountry
var headcountry = head.TradeCountry;
if (head.IEFlag == "E") {
foreach (var item in body) {
if (item.DestinationCountry != headcountry) {
result.SetErrorInfo($"报关单国别{headcountry}与商品明细值{item.DestinationCountry}不一致,请注意核对!");
return result;
}
}
}
if (head.IEFlag == "I")
{
foreach (var item in body)
{
if (item.OriginCountry != headcountry)
{
result.SetErrorInfo($"报关单国别{headcountry}与商品明细值{item.OriginCountry}不一致,请注意核对!");
return result;
}
}
}
}
return result;
}
public void GetErrorString(ref string errorstr)
{
var _r = DoCheck("明细净重");
if (!_r.Success) {
errorstr += "<br>序号9001 (" + _r.Message + ")";
}
_r = DoCheck("明细价格");
if (!_r.Success)
{
errorstr += "<br>序号9002 (" + _r.Message + ")";
}
_r = DoCheck("国家比对");
if (!_r.Success)
{
errorstr += "<br>序号9003 (" + _r.Message + ")";
}
}
}
public JsonResult GetHead(string gid)
{
var model = bll.GetModel(gid);
var tmodel = tbll.GetModelList("PID='" + gid + "'").FirstOrDefault();
var rclist = rcbll.GetModelList("PID='" + gid + "'");
var oplist = opbll.GetModelList("PID='" + gid + "'");
var cllist = clbll.GetModelList("PID='" + gid + "'");
var goodsLimit = gbll.GetModelList("PID in (SELECT GID FROM DecList WHERE PID ='" + gid + "')").OrderBy(p => p.GoodsNo).ToList();
var goodsLimitVin = vbll.GetModelList("PID in (SELECT GID FROM DecGoodsLimit WHERE PID IN(SELECT GID FROM DecList WHERE PID ='" + gid + "'))").OrderBy(p => p.GoodsNoVin).ToList();
return Json(new { success = true, model, tmodel, rclist, oplist, cllist, goodsLimit, goodsLimitVin });
}
/// <summary>
/// 报文列表
/// </summary>
/// <param name="startIndex"></param>
/// <param name="limit"></param>
/// <param name="sortOrder"></param>
/// <param name="sortName"></param>
/// <returns></returns>
public JsonResult GetList(int startIndex, int limit, string sortOrder, string sortName, string pId)
{
if (sortName.ToLower() == "gno") {
sortName = "CONVERT(int, gno)";
}
var list = lbll.GetModelList(startIndex, limit, "PID='" + pId + "'", String.Format("{0} {1}", sortName, sortOrder));
var count = lbll.GetRecordCount("PID='" + pId + "'");
return Json(new { total = count, rows = list });
}
/// <summary>
/// 集装箱列表
/// </summary>
/// <returns></returns>
public JsonResult GetList1(string pId)
{
var list = cbll.GetModelList("PID='" + pId + "'");
return Json(list);
}
/// <summary>
/// 获取单证
/// </summary>
/// <returns></returns>
public JsonResult GetList2(string pId)
{
var list = dbll.GetModelList("PID='" + pId + "'");
return Json(list);
}
/// <summary>
/// 产品许可证列表
/// </summary>
/// <returns></returns>
public JsonResult GetList3(string pId)
{
var list = gbll.GetModelList("PID='" + pId + "'").OrderBy(p => p.GoodsNo).ToList();
return Json(list);
}
/// <summary>
/// 许可证VIN列表
/// </summary>
/// <returns></returns>
public JsonResult GetList4(string pId)
{
var list = vbll.GetModelList("PID='" + pId + "'").OrderBy(p => p.GoodsNoVin).ToList();
return Json(list);
}
/// <summary>
/// 企业资质列表
/// </summary>
/// <returns></returns>
public JsonResult GetList5(string pId)
{
var list = ebll.GetModelList("PID='" + pId + "'");
return Json(list);
}
/// <summary>
/// 按类别获取下拉列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="query"></param>
/// <returns></returns>
public JsonResult GetSelection(int pageIndex, int pageSize, string query, string type)
{
sys_EnumerationBLL bll = new sys_EnumerationBLL();
StringBuilder where = new StringBuilder();
where.Append("Type='" + type + "'");
if (!String.IsNullOrEmpty(query))
where.Append(string.Format("And ([Value] LIKE '%{0}%' OR Name LIKE '%{0}%')", query));
var total = bll.GetRecordCount(where.ToString());
var list = bll.GetModelList(pageIndex, pageSize, where.ToString(), "[Value] collate Chinese_PRC_CS_AS_KS_WS");
var result = from p in list
select new
{
id = p.Value,
text = p.Value + " - " + p.Name
};
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取指运港
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="query"></param>
/// <returns></returns>
public JsonResult GetPort(int pageIndex, int pageSize, string query)
{
sys_b_PortBLL bll = new sys_b_PortBLL();
StringBuilder where = new StringBuilder();
where.Append("1=1");
if (!String.IsNullOrEmpty(query))
where.Append(string.Format(" And ([Value] LIKE '%{0}%' OR Name LIKE '%{0}%')", query));
var total = bll.GetRecordCount(where.ToString());
var list = bll.GetModelList(pageIndex, pageSize, where.ToString(), "[Value] collate Chinese_PRC_CS_AS_KS_WS");
var result = from p in list
select new
{
id = p.Value,
text = p.Value + " - " + p.Name
};
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
}
#region 导入XML文件生成报关和单一窗口数据
[HttpPost]
public ContentResult ImportXmlBs()
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (Request.Files.Count != 1)
{
jsonRespose.Success = false;
jsonRespose.Message = "请选择上传的文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var file = Request.Files["LoadXml"];
if (file == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath(OPAPPLYFilePath);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var bsno = Request.Form["bsno"];
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
file.SaveAs(filename);
if (!System.IO.File.Exists(filename))
{
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件发生未知错误,请重新上传" });
return new ContentResult() { Content = json };
}
string ext = Path.GetExtension(file.FileName).ToLower();
if (ext == ".asp" || ext == ".aspx")
{
jsonRespose.Success = false;
jsonRespose.Message = "不允许上传ASP货ASPX文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var result = DecHeadDAL.Deal381XML(filename, Session["USERID"].ToString(), Session["SHOWNAME"].ToString(), Session["COMPANYID"].ToString());
//try
//{
// XmlSerializer serializer = new XmlSerializer(typeof(SHIPMENT_CDF_INBOUND_V2));
// using (FileStream fs = new FileStream(filename, FileMode.Open))
// {
// SHIPMENT_CDF_INBOUND_V2 SHIPMENTLIST = (SHIPMENT_CDF_INBOUND_V2)serializer.Deserialize(fs);
// result = ImportXmlBs(SHIPMENTLIST,Session["USERID"].ToString(), Session["SHOWNAME"].ToString(), Session["COMPANYID"].ToString());
// }
// var json = JsonConvert.Serialize(new { success = result.Success, Message = result.Message });
// return new ContentResult() { Content = json };
//}
//catch (Exception e)
//{
// jsonRespose.Success = false;
// jsonRespose.Message = "读取文件出错,请确认文件正确性" + e.Message;
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
var json2 = JsonConvert.Serialize(new { success = result.Success, Message = result.Message });
return new ContentResult() { Content = json2 };
}
[HttpGet]
public ContentResult ImportXmlBs(string fullname,string USERID,string SHOWNAME,string COMPANYID) {
var result = DecHeadDAL.Deal381XML(fullname, USERID, SHOWNAME, COMPANYID);
var json2 = JsonConvert.Serialize(new { success = result.Success, Message = result.Message });
return new ContentResult() { Content = json2 };
}
//移动到DAL层 以方便被调用
public DBResult Deal381XML(string filename) {
var result = new DBResult();
try
{
XmlSerializer serializer = new XmlSerializer(typeof(SHIPMENT_CDF_INBOUND_V2));
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
SHIPMENT_CDF_INBOUND_V2 SHIPMENTLIST = (SHIPMENT_CDF_INBOUND_V2)serializer.Deserialize(fs);
result = DecHeadDAL.ImportXmlBs(SHIPMENTLIST, Session["USERID"].ToString(), Session["SHOWNAME"].ToString(), Session["COMPANYID"].ToString());
}
}
catch (Exception e)
{
result.SetErrorInfo("读取文件出错,请确认文件正确性:" + e.Message);
}
return result;
}
public static bool TryToInt32(object value, out int result)
{
if (value == null)
{
result = 0;
return false;
}
return int.TryParse(value.ToString(), out result);
}
public static bool TryToDecimal(object value, out Decimal result)
{
if (value == null)
{
result = 0;
return false;
}
return Decimal.TryParse(value.ToString(), out result);
}
public static string GetTextByCode(EnumerableRowCollection<DataRow> emlistQuery, string emtype, string emcode)
{
var result = "";
var emlists =
emlistQuery.Where(p => p.Field<string>("type") == emtype && p.Field<string>("Value") == emcode);
foreach (DataRow em in emlists)
{
result = em.Field<string>("Name");
}
return result;
}
public static string GetCodeByText(EnumerableRowCollection<DataRow> emlistQuery, string emtype, string emname)
{
var result = "";
var emlists =
emlistQuery.Where(p => p.Field<string>("type") == emtype && p.Field<string>("Name") == emname);
foreach (DataRow em in emlists)
{
result = em.Field<string>("Value");
}
return result;
}
private const string OPAPPLYFilePath= "../../UploadFiles/OpApply";
private const string LOGICNAME_381 = "381HEAD";
//移动到DAL层
public DBResult ImportXmlBs(SHIPMENT_CDF_INBOUND_V2 SHIPMENT, string userid, string showname, string companyid)
{
var result = new DBResult();
int blcount = 0;
var CCS_HEADERLIST = SHIPMENT.CCS_HEADER;
foreach (var items in CCS_HEADERLIST)
{
var OPAPPLY = MsOpApplyDAL.GetData(" CUSTOMNO='" + items.CCS_NUMBER + "'");
var needinsert = false;//需要新建 还是更新信息
if (string.IsNullOrWhiteSpace(OPAPPLY.CUSTOMNO))
{
needinsert = true;
}
#region 报关信息
OPAPPLY.CUSTOMNO = items.CCS_NUMBER;
//根据报关单号 结尾0出口 结尾1进口
OPAPPLY.setbstype();
OPAPPLY.BSSTATUS = false;
OPAPPLY.FEESTATUS = false;
OPAPPLY.BSDATE = DateTime.Now;
OPAPPLY.CUSTOMDATE = items.DECLARATION_DATE;//报关日期=申报日期
OPAPPLY.OPDATE = items.IMPORT_EXPORT_DATE;//业务日期=申报日期
OPAPPLY.MBLNO = items.BL_NUMBER;//20210610 从BLNo改为使用 BL_NUMBER
OPAPPLY.INPUTBY = showname;
OPAPPLY.CORPID = companyid;
OPAPPLY.CONTRACTNO = items.CONTRACT_NUMBER;
OPAPPLY.ACCDATE = DateTime.Now.ToString("yyyy-MM");
if (needinsert)
{
OPAPPLY.DbOperationType = DbOperationType.DbotIns;
OPAPPLY.ModelUIStatus = "I";
OPAPPLY.BSNO = Guid.NewGuid().ToString();
OPAPPLY.MASTERNO = OPAPPLY.BSNO;
var _r = MsOpApplyDAL.getCUSTNO(OPAPPLY, userid, showname, companyid);
if (_r.Success)
{
OPAPPLY.CUSTNO = _r.Data.ToString();
}
}
else
{
OPAPPLY.DbOperationType = DbOperationType.DbotUpd;
OPAPPLY.ModelUIStatus = "E";
}
//OPAPPLY.CUSTNO = items.INTERNAL_CCS;
OPAPPLY.CUSTOMNO = items.CCS_NUMBER;//20210609 经过比对确认这个字段是博世写报关单号的字段
OPAPPLY.BOOKNO = items.HANDBOOK_NUMBER;
OPAPPLY.BYCUSTOM = items.DECLARATION_PORT;
OPAPPLY.EXPCUSTOMTYPE = items.IMPORT_EXPORT_PORT;
OPAPPLY.ETD = items.IMPORT_EXPORT_DATE;
OPAPPLY.BSTYPE = items.TRANSPORTATION_METHOD;
OPAPPLY.VESSEL = items.TRAF_NAME;
OPAPPLY.VOYNO = items.VOYAGE_NUMBER;
if (string.IsNullOrEmpty(OPAPPLY.ENTERP))
OPAPPLY.ENTERP = items.CUSTOMS_BROKER_NAME;
OPAPPLY.ENTERPID = items.CUSTOMS_BROKER_CODE;
OPAPPLY.TRADETERM = items.TRADE_MODE;
OPAPPLY.PORTDISCHARGE = items.DESTINATION_PORT;
OPAPPLY.PKGS = Convert.ToDecimal(items.PIECES);
OPAPPLY.KGS = Convert.ToDecimal(items.GROSS_WEIGHT);
OPAPPLY.NETWEIGHT = Convert.ToDecimal(items.NET_WEIGHT);
OPAPPLY.ARCOUNTRY = items.COUNTRY;
#endregion
#region 20210610邓羽 记录381头部信息
var HeadDic = new Dictionary<string, string>();
HeadDic.Add("ACTION", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.ACTION);
HeadDic.Add("COMPANY_CODE", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.COMPANY_CODE);
HeadDic.Add("ORG_CODE", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.ORG_CODE);
HeadDic.Add("PRIORITY", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.PRIORITY.ToString());
HeadDic.Add("MESSAGE_TYPE", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.MESSAGE_TYPE);
HeadDic.Add("USERID", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.USERID);
HeadDic.Add("RECEIVER", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.RECEIVER);
HeadDic.Add("SENDER", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.SENDER);
HeadDic.Add("BATCH_ID", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.BATCH_ID);
//HeadDic.Add("ORG_CODE", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.BUS_KEY.ORG_CODE);
HeadDic.Add("SHIPMENT_NUMBER", SHIPMENT.INTEGRATION_MESSAGE_CONTROL.BUS_KEY.SHIPMENT_NUMBER);
HeadDic.Add("INCOMING_STATUS", items.INCOMING_STATUS);
HeadDic.Add("INTERNAL_CCS", items.INTERNAL_CCS);
BasicDataRefDAL.SaveLogicInfo(OPAPPLY.BSNO, LOGICNAME_381, HeadDic);
#endregion
#region 单一窗口
SoftMng.BLL.sys_EnumerationBLL bllEM = new SoftMng.BLL.sys_EnumerationBLL();
var emlistdataset = bllEM.GetList("");
var emlisttable = emlistdataset.Tables[0];
var emlistQuery =
from emlist in emlisttable.AsEnumerable()
select emlist;
DecHead model = new DecHead();
model.AgentStatus = "暂存";
model.BSNO = OPAPPLY.BSNO;
model.GID = Guid.NewGuid().ToString();
model.EntryType = items.CCS_TYPE;
if (model.EntryType == "M") model.EntryType_Text = "无纸化通关";
if (model.EntryType == "O") model.EntryType_Text = "普通报关单";
if (model.EntryType == "L") model.EntryType_Text = "为带报关单清单的报关单";
if (model.EntryType == "W") model.EntryType_Text = "无纸报关类型";
if (model.EntryType == "D") model.EntryType_Text = "既是清单又是无纸报关的情况";
model.EntryId = items.CCS_NUMBER;
model.ManualNo = items.HANDBOOK_NUMBER;
model.CustomMaster = items.DECLARATION_PORT;
model.CustomMaster_Text = GetTextByCode(emlistQuery, "关区代码", model.CustomMaster);
model.IEPort = items.IMPORT_EXPORT_PORT;
model.IEPort_Text = GetTextByCode(emlistQuery, "关区代码", model.IEPort);
model.ContrNo = items.CONTRACT_NUMBER;
if (!string.IsNullOrEmpty(items.IMPORT_EXPORT_DATE))
model.IEDate = Convert.ToDateTime(items.IMPORT_EXPORT_DATE);
model.BillNo = items.BL_NUMBER;
model.TrafMode = items.TRANSPORTATION_METHOD;
model.TrafMode_Text = GetTextByCode(emlistQuery, "运输方式", model.TrafMode);
model.TrafName = items.TRAF_NAME;
model.NativeVoyageNo = items.VOYAGE_NUMBER;
model.TradeCode = items.TRADING_COMPANY_CODE;
model.TradeName = items.TRADING_COMPANY_NAME;
model.OwnerCode = items.RECEIVER_COMPANY_CODE;
model.OwnerName = items.RECEIVER_COMPANY_NAME;
model.AgentCode = items.CUSTOMS_BROKER_CODE;
model.AgentName = items.CUSTOMS_BROKER_NAME;
model.TradeCountry = items.COUNTRY;
model.TradeCountry_Text = GetTextByCode(emlistQuery, "国别地区", model.TradeCountry);
model.TradeMode = items.TRADE_MODE;
model.TradeMode_Text = GetTextByCode(emlistQuery, "监管方式", model.TradeMode);
model.TransMode = items.TRANSACTION_METHOD;
model.TransMode_Text = GetTextByCode(emlistQuery, "成交方式", model.TransMode);
model.CutMode = items.TAX_OPTION;
model.CutMode_Text = GetTextByCode(emlistQuery, "征免性质", model.CutMode);
model.FeeMark = items.FREIGHT_COST_BASIS;
decimal feerate = 0;
TryToDecimal(items.FREIGHT_RATE, out feerate);
model.FeeRate = feerate;
model.FeeCurr = items.FREIGHT_CURRENCY;
model.FeeCurr_Text = GetTextByCode(emlistQuery, "币别", model.FeeCurr);
model.LicenseNo = items.PERMIT;
model.InsurMark = items.INSURANCE_FEE_BASIS;
decimal InsurRate = 0;
TryToDecimal(items.INSURANCE_RATE, out InsurRate);
model.InsurRate = InsurRate;
model.FeeRate = feerate;
model.InsurCurr = items.INSURANCE_CURRENCY;
model.InsurCurr_Text = GetTextByCode(emlistQuery, "币别", model.InsurCurr);
model.ApprNo = items.MOFCOM_APPROVAL_NUMBER;
model.OtherMark = items.MISCELLANEOUS_EXPENSE_BASIS;
decimal OtherRate = 0;
TryToDecimal(items.MISCELLANEOUS_EXPENSE_RATE, out OtherRate);
model.OtherRate = OtherRate;
model.OtherCurr = items.MISCELLANEOUS_EXPENSE_CURRENCY;
model.OtherCurr_Text = GetTextByCode(emlistQuery, "币别", model.OtherCurr);
model.WrapType = items.PACKAGING_TYPE;
model.WrapType_Text = GetTextByCode(emlistQuery, "包装种类", model.WrapType);
Int32 PackNo = 0;
TryToInt32(items.PIECES, out PackNo);
model.PackNo = PackNo;
decimal NetWt = 0;
TryToDecimal(items.NET_WEIGHT, out NetWt);
model.NetWt = NetWt;
decimal GrossWet = 0;
TryToDecimal(items.GROSS_WEIGHT, out GrossWet);
model.GrossWet = GrossWet;
model.NoteS = items.REMARK;
model.SeqNo = items.E_PORT_DECLARATION_ID;
model.ChkSurety = items.ChkSurety;
model.BillType = items.BillType;
model.AgentCodeScc = items.AgentCodeScc;
model.OwnerCodeScc = items.OwnerCodeScc;
model.TradeCoScc = items.TradeCodeScc;
model.CopCodeScc = items.CopCodeScc;
model.PromiseItmes = items.PromiseItmes;
model.TradeAreaCode = items.TradeAreaCode;
// model.TrnHead = items.TradeCodeScc;
model.PreEntryId = items.PreEntryId;
model.Type = items.Type;
model.OverseasConsignorCode = items.OverseasConsignorCode;
model.OverseasConsignorCname = items.OverseasConsignorCname;
model.OverseasConsignorEname = items.OverseasConsignorEname;
model.OverseasConsignorAddr = items.OverseasConsignorAddr;
model.OverseasConsigneeCode = items.OverseasConsigneeCode;
model.OverseasConsigneeEname = items.OverseasConsigneeEname;
model.GoodsPlace = items.GoodsPlace;
model.MarkNo = items.MarkNo;
model.DespPortCode = items.DespPortCode;
model.EntyPortCode = items.EntyPortCode;
model.DeclareName = items.DeclareName;
model.NoOtherPack = items.NoOtherPack;
model.DeclTrnRel = items.DeclTrnRel;
model.EdiId = items.EdiId;
model.CheckFlow = items.CheckFlow;
model.TaxAaminMark = items.TaxAaminMark;
model.BLNo = items.BLNo;
model.InspOrgCode = items.InspOrgCode;
model.SpecDeclFlag = items.SpecDeclFlag;
model.PurpOrgCode = items.PurpOrgCode;
if (!string.IsNullOrEmpty(items.DespDate))
model.DespDate = DateTime.ParseExact(items.DespDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
if (!string.IsNullOrEmpty(items.CmplDschrgDt))
model.CmplDschrgDt = DateTime.ParseExact(items.CmplDschrgDt, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
model.CorrelationReasonFlag = items.CorrelationReasonFlag;
model.VsaOrgCode = items.VsaOrgCode;
model.OrigBoxFlag = items.OrigBoxFlag;
model.CorrelationNo = items.CorrelationNo;
model.EdiRemark = items.EdiRemark;
model.EdiRemark2 = items.EdiRemark2;
model.TradeCiqCode = items.TradeCiqCode;
model.OwnerCiqCode = items.OwnerCiqCode;
model.DeclCiqCode = items.DeclCiqCode;
model.OrgCode = items.OrgCode;
bll.Add(model);
#endregion
List<DecGoodsLimit> list3 = new List<DecGoodsLimit>();
decimal TOTAL_AMOUNT = 0;
if (items.CCS_DETAIL != null)
foreach (var GOOD in items.CCS_DETAIL)
{
OPAPPLY.CURRENCY = GOOD.CURRENCY;
TOTAL_AMOUNT = TOTAL_AMOUNT + GOOD.TOTAL_AMOUNT;
var Dec = new DecList();
Dec.PID = model.GID;
Dec.GID = Guid.NewGuid().ToString();
Dec.GNo = GOOD.SEQUENCE_NUMBER;
Dec.ContrItem = GOOD.CUSTOMS_ITEM_NUMBER;
Dec.ExgVersion = GOOD.PRODUCT_VERSION_NUMBER;
Dec.CodeTS = GOOD.HS_CODE;
Dec.GName = GOOD.CHINESE_DESCRIPTION;
Dec.GModel = GOOD.MODEL;
Dec.GQty = GOOD.DECLARATION_QTY;
Dec.GUnit = GOOD.CUSTOMS_UM;
Dec.GUnit_Text = GetTextByCode(emlistQuery, "成交计量单位", Dec.GUnit);
Dec.FirstQty = GOOD.CUSTOMS_QUANTITY;
Dec.FirstUnit = GOOD.FIRST_CUSTOMS_UM;
Dec.FirstUnit_Text = GetTextByCode(emlistQuery, "成交计量单位", Dec.FirstUnit);
decimal SecondQty = 0;
TryToDecimal(GOOD.SECOND_CUSTOMS_QUANTITY, out SecondQty);
Dec.SecondQty = SecondQty;
Dec.SecondUnit = GOOD.SECOND_CUSTOMS_UM;
Dec.SecondUnit_Text = GetTextByCode(emlistQuery, "成交计量单位", Dec.SecondUnit);
decimal DeclPrice = 0;
TryToDecimal(GOOD.UNIT_PRICE, out DeclPrice);
Dec.DeclPrice = DeclPrice;
Dec.DeclTotal = GOOD.TOTAL_AMOUNT;
Dec.TradeCurr = GOOD.CURRENCY;
Dec.TradeCurr_Text = GetTextByCode(emlistQuery, "币别", Dec.TradeCurr);
Dec.OriginCountry = GOOD.COUNTRY;
Dec.OriginCountry_Text = GetTextByCode(emlistQuery, "国别地区", Dec.OriginCountry);
Dec.DutyMode = GOOD.TAX_OPTION;
Dec.DutyMode_Text = GetTextByCode(emlistQuery, "征免方式", Dec.DutyMode);
Dec.DestinationCountry = GOOD.DestinationCountry;
Dec.DestinationCountry_Text = GetTextByCode(emlistQuery, "征免方式", Dec.DestinationCountry);
Dec.CiqCode = GOOD.CiqCode;
Dec.DistrictCode = GOOD.DistrictCode;
Dec.DestCode = GOOD.DESTINATION_DISTRICT;
//Dec.Factor = GOOD.Factor;
//Dec.DeclGoodsEname = GOOD.DeclGoodsEname;
//Dec.OrigPlaceCode = GOOD.OrigPlaceCode;
Dec.Purpose = GOOD.Purpose;
Dec.Purpose_Text = GetTextByCode(emlistQuery, "用途", Dec.Purpose);
if (!string.IsNullOrEmpty(GOOD.ProdValidDt))
Dec.ProdValidDt = DateTime.ParseExact(GOOD.ProdValidDt, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); ;
Int32 ProdQgp = 0;
TryToInt32(GOOD.ProdQgp, out ProdQgp);
Dec.ProdQgp = ProdQgp;
Dec.GoodsAttr = GOOD.GoodsAttr;
Dec.GoodsAttr_Text = GetTextByCode(emlistQuery, "货物属性", Dec.GoodsAttr);
Dec.Stuff = GOOD.Stuff;
Dec.Uncode = GOOD.Uncode;
Dec.DangName = GOOD.DangName;
Int32 DangPackType = 0;
TryToInt32(GOOD.DangPackType, out DangPackType);
Dec.ProdQgp = DangPackType;
Dec.DangPackSpec = GOOD.DangPackSpec;
Dec.DangPackSpec_Text = GetTextByCode(emlistQuery, "危包规格", Dec.DangPackSpec);
Dec.EngManEntCnm = GOOD.EngManEntCnm;
Int32 NoDangFlag = 0;
TryToInt32(GOOD.NoDangFlag, out NoDangFlag);
Dec.NoDangFlag = NoDangFlag;
Dec.GoodsSpec = GOOD.GoodsSpec;
Dec.GoodsModel = GOOD.GoodsModel;
Dec.GoodsBrand = GOOD.GoodsBrand;
Dec.ProduceDate = GOOD.ProduceDate;
Dec.ProdBatchNo = GOOD.ProdBatchNo;
lbll.Add(Dec);
//Dec.CiqName = GOOD.CiqName;
//Dec.MnufctrRegno = GOOD.MnufctrRegno;
//Dec.MnufctrRegName = GOOD.MnufctrRegName;
if (GOOD.DecGoodsLimits!=null)
foreach (var GOODLIMIT in GOOD.DecGoodsLimits)
{
var DecGood = new DecGoodsLimit();
DecGood.PID = Dec.GID;
DecGood.GID = Guid.NewGuid().ToString();
DecGood.GoodsNo = GOODLIMIT.GoodsNo;
DecGood.LicTypeCode = GOODLIMIT.LicTypeCode;
DecGood.LicTypeCode_Text = GetTextByCode(emlistQuery, "许可证类别", DecGood.LicTypeCode);
DecGood.LicenceNo = GOODLIMIT.LicenceNo;
DecGood.LicWrtofDetailNo = GOODLIMIT.LicWrtofDetailNo;
DecGood.LicWrtofQty = Convert.ToInt32(GOODLIMIT.LicWrtofQty);
gbll.Add(DecGood);
if (GOODLIMIT.DecGoodsLimitVin != null)
foreach (var GOODLIMITVIN in GOODLIMIT.DecGoodsLimitVin)
{
var DecGoodvin = new DecGoodsLimitVin();
DecGoodvin.PID = DecGood.GID;
DecGoodvin.GID = Guid.NewGuid().ToString();
////DecGoodvin.LicenceNo = GOODLIMITVIN.LicenceNo;
//DecGoodvin.LicTypeCode = GOODLIMITVIN.LicTypeCode;
DecGoodvin.VinNo = GOODLIMITVIN.VinNo;
if (!string.IsNullOrEmpty(GOODLIMITVIN.BillLadDate))
DecGoodvin.BillLadDate = DateTime.ParseExact(GOODLIMITVIN.BillLadDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
DecGoodvin.QualityQgp = GOODLIMITVIN.QualityQgp;
DecGoodvin.MotorNo = GOODLIMITVIN.MotorNo;
DecGoodvin.VinCode = GOODLIMITVIN.VinCode;
DecGoodvin.ChassisNo = GOODLIMITVIN.ChassisNo;
Int32 InvoiceNum = 0;
TryToInt32(GOODLIMITVIN.InvoiceNum, out InvoiceNum);
DecGoodvin.InvoiceNum = InvoiceNum;
DecGoodvin.ProdCnnm = GOODLIMITVIN.ProdCnnm;
DecGoodvin.ProdEnnm = GOODLIMITVIN.ProdEnnm;
DecGoodvin.ModelEn = GOODLIMITVIN.ModelEn;
decimal PricePerUnit = 0;
TryToDecimal(GOODLIMITVIN.PricePerUnit, out PricePerUnit);
DecGoodvin.PricePerUnit = PricePerUnit;
DecGoodvin.InvoiceNo = GOODLIMITVIN.InvoiceNo;
vbll.Add(DecGoodvin);
}
}
}
OPAPPLY.CARGOVALUE = TOTAL_AMOUNT.ToString();
//var modb = new ModelObjectDB();
// var tempresult = modb.Save(OPAPPLY);
var bodyList = new List<MsOpCtn>();
if (items.CONTAINER_DETAIL != null)
foreach (var ctn in items.CONTAINER_DETAIL)
{
var opctn = new MsOpCtn();
opctn.BSNO ="*";
opctn.CNTRNO = ctn.CONTAINER_NUMBER;
opctn.CTNALL = ctn.CONTAINER_TYPE;
opctn.KGS = Convert.ToDecimal(ctn.GoodsContaWt);
Container ctnitem = new Container();
ctnitem.PID = model.GID;
ctnitem.GID = Guid.NewGuid().ToString();
ctnitem.ContainerId = ctn.CONTAINER_NUMBER;
ctnitem.ContainerMd = ctn.CONTAINER_TYPE;
decimal ContainerWt = 0;
TryToDecimal(ctn.CONTAINER_TARE_WEIGHT, out ContainerWt);
ctnitem.ContainerWt = ContainerWt;
ctnitem.GoodsNo = ctn.GoodsNo;
decimal GoodsContaWt = 0;
TryToDecimal(ctn.GoodsContaWt, out GoodsContaWt);
ctnitem.GoodsContaWt = GoodsContaWt;
cbll.Add(ctnitem);
}
if (items.ATTACHED_DOCUMENT_DETAIL != null)
foreach (var DOC in items.ATTACHED_DOCUMENT_DETAIL)
{
LicenseDocu docitem = new LicenseDocu();
docitem.PID = model.GID;
docitem.GID = Guid.NewGuid().ToString();
docitem.DocuCode = DOC.DOCUMENT_TYPE;
docitem.DocuCode_Text = GetTextByCode(emlistQuery, "随附单证代码", docitem.DocuCode);
docitem.CertCode = DOC.DOCUMENT_NUMBER;
dbll.Add(docitem);
}
if (items.DecOtherPack != null)
foreach (var OTHERPACK in items.DecOtherPack)
{
DecOtherPack otheritem = new DecOtherPack();
otheritem.PID = model.GID;
otheritem.GID = Guid.NewGuid().ToString();
otheritem.PackQty = OTHERPACK.PackQty;
otheritem.PackType = OTHERPACK.PackType;
opbll.Add(otheritem);
}
if (items.DecCopLimits != null)
foreach (var COPLIMITLIST in items.DecCopLimits)
{
DecCopLimit otheritem = new DecCopLimit();
otheritem.PID = model.GID;
otheritem.GID = Guid.NewGuid().ToString();
otheritem.EntQualifNo = COPLIMITLIST.EntQualifNo;
otheritem.EntQualifTypeCode = COPLIMITLIST.EntQualifTypeCode;
otheritem.EntQualifTypeCode_Text = GetTextByCode(emlistQuery, "企业资质类别", otheritem.EntQualifTypeCode);
clbll.Add(otheritem);
}
var modb = new ModelObjectDB();
result = modb.Save(OPAPPLY);
if (result.Success)
{
MsOpApplyDAL.SaveCtnDetail(OPAPPLY.BSNO, bodyList, userid, true);
}
blcount = blcount + 1;
}
result.Message=""+blcount+"票业务";
return result;
}
/// <summary>
/// 20210603 百特凯瑞 根据报关业务信息 生成两个xml文件 代号383 385
/// 参数为报关单号 返回值为两个文件名 ,用;;隔开
/// </summary>
/// <param name="SHIPMENT"></param>
/// <param name="userid"></param>
/// <param name="showname"></param>
/// <param name="companyid"></param>
/// <returns></returns>
///
[HttpPost]
public ContentResult GetCreateXmlBs(string CUSTOMNOs) {
var result = new DBResult();
var jsonRespose = new JsonResponse { Success = false, Message = "" };
try
{
result = DoCreateXmlBs(CUSTOMNOs);
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message,data=result.Data });
return new ContentResult() { Content = json };
}
catch (Exception e)
{
jsonRespose.Success = false;
jsonRespose.Message = "生成报文出错:" + e.Message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
private DBResult DoCreateXmlBs(string CUSTOMNOs)//, string userid, string showname, string companyid
{
var CUSTOMNOList = CUSTOMNOs.Split(',').ToList();
//var SHIPMENT = Get383Xml(CUSTOMNOList);
//XmlSerializer XML_1 = new XmlSerializer(SHIPMENT.GetType());
//var path = Server.MapPath("../../UploadFiles/OpApply");
//if (!Directory.Exists(path))
//{
// Directory.CreateDirectory(path);
//}
//var usercode = CookieConfig.GetCookie_UserCode(Request);
//string filename = path + "\\" + usercode + "_383.xml";
//if (System.IO.File.Exists(Path.GetFullPath(filename)))
//{
// System.IO.File.Delete(Path.GetFullPath(filename));
//}
//var tw = new StreamWriter(filename);
//XML_1.Serialize(tw, SHIPMENT);
//tw.Close();
var Filename383 = Get383XmlFile(CUSTOMNOList);
var Filename385 = Get385XmlFile(CUSTOMNOList);
var filename = Filename383 + ";;" + Filename385;
var result = new DBResult(true,"", filename);
result.Message = "";
return result;
}
private string Get383XmlFile(List<string> CUSTOMNOList) {
var SHIPMENT = Get383Xml(CUSTOMNOList);
if (SHIPMENT == null) return "";
XmlSerializer XML_1 = new XmlSerializer(SHIPMENT.GetType());
var path = Server.MapPath(OPAPPLYFilePath);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + "_383.xml";
if (System.IO.File.Exists(Path.GetFullPath(filename)))
{
System.IO.File.Delete(Path.GetFullPath(filename));
}
var tw = new StreamWriter(filename);
XML_1.Serialize(tw, SHIPMENT);
tw.Close();
var result = OPAPPLYFilePath +"/"+usercode + "_383.xml";
return result;
}
private SHIPMENT_CDF_OUTBOUND_V2 Get383Xml(List<string> CUSTOMNOList) {
var SHIPMENT = new SHIPMENT_CDF_OUTBOUND_V2();
var CCS_HEADERLIST = new MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPE[CUSTOMNOList.Count()];
var CCS_HEADERLIST_COUNT = 0;
var headinfo = new DSWeb.MvcShipping.Models.MsOpApply_BOSH383.SHIPMENT_CDF_OUTBOUND_V2INTEGRATION_MESSAGE_CONTROL();
foreach (var CUSTOMNO in CUSTOMNOList) {
var OPAPPLY = MsOpApplyDAL.GetData(" CUSTOMNO='" + CUSTOMNO + "'");
#region 20210610 获取逻辑信息表的数据 如无信息则返回空
var HeadDic = BasicDataRefDAL.GetLogicInfo(OPAPPLY.BSNO, LOGICNAME_381);
if (HeadDic == null || HeadDic.Count() == 0) return SHIPMENT;
headinfo.ACTION = HeadDic["ACTION"];
headinfo.COMPANY_CODE = HeadDic["COMPANY_CODE"];
headinfo.ORG_CODE = HeadDic["ORG_CODE"];
var _t = decimal.Parse(HeadDic["PRIORITY"]);
if (HeadDic["PRIORITY"] == "")
{
headinfo.PRIORITY = null;
}
else {
headinfo.PRIORITY = _t;
}
headinfo.MESSAGE_TYPE = HeadDic["MESSAGE_TYPE"];
headinfo.USERID = HeadDic["USERID"];
headinfo.RECEIVER = HeadDic["RECEIVER"];
headinfo.SENDER = HeadDic["SENDER"];
headinfo.BATCH_ID = HeadDic["BATCH_ID"];
headinfo.SOURCE_SYSTEM_TOKEN = "";
headinfo.BUS_KEY = new SHIPMENT_CDF_OUTBOUND_V2INTEGRATION_MESSAGE_CONTROLBUS_KEY();
headinfo.BUS_KEY.ORG_CODE= HeadDic["ORG_CODE"];
headinfo.BUS_KEY.SHIPMENT_NUMBER = HeadDic["SHIPMENT_NUMBER"];
SHIPMENT.INTEGRATION_MESSAGE_CONTROL = headinfo;
#endregion
var items = new DSWeb.MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPE();
var bll = new DecHeadBLL();
var model = bll.GetModelList("BSNO='" + OPAPPLY.BSNO + "'")[0];
DecListBLL lbll = new DecListBLL();
var DecList = lbll.GetModelList("PID='" + model.GID + "'").ToList();
#region 报关信息
//20210610 增加三个节点
items.SHIPMENT_NUMBER = HeadDic["SHIPMENT_NUMBER"];
items.INTERNAL_SHIPMENT_NUMBER = "";
items.INCOMING_STATUS = HeadDic["INCOMING_STATUS"];
items.CCS_NUMBER= "";
//根据报关单号 结尾0出口 结尾1进口
//OPAPPLY.setbstype();
//OPAPPLY.BSSTATUS = false;
//OPAPPLY.FEESTATUS = false;
//OPAPPLY.BSDATE = DateTime.Now;
//items.DECLARATION_DATE = OPAPPLY.CUSTOMDATE; //报关日期=申报日期 在上传时 此字段改为使用单一窗口的申报日期 DDate
items.DECLARATION_DATE = model.DDateStr;//报关日期=申报日期 在上传时 此字段改为使用单一窗口的申报日期 DDate
items.IMPORT_EXPORT_DATE = OPAPPLY.OPDATE ;//业务日期=申报日期
items.BLNo = OPAPPLY.MBLNO ;
//OPAPPLY.INPUTBY = showname;
//OPAPPLY.CORPID = companyid;
items.CONTRACT_NUMBER=OPAPPLY.CONTRACTNO ;
//OPAPPLY.ACCDATE = DateTime.Now.ToString("yyyy-MM");
//if (needinsert)
//{
// OPAPPLY.DbOperationType = DbOperationType.DbotIns;
// OPAPPLY.ModelUIStatus = "I";
// OPAPPLY.BSNO = Guid.NewGuid().ToString();
// OPAPPLY.MASTERNO = OPAPPLY.BSNO;
// var _r = MsOpApplyDAL.getCUSTNO(OPAPPLY, userid, showname, companyid);
// if (_r.Success)
// {
// OPAPPLY.CUSTNO = _r.Data.ToString();
// }
//}
//else
//{
// OPAPPLY.DbOperationType = DbOperationType.DbotUpd;
// OPAPPLY.ModelUIStatus = "E";
//}
items.INTERNAL_CCS = HeadDic["INTERNAL_CCS"] ;
items.CCS_NUMBER = OPAPPLY.CUSTOMNO;
items.HANDBOOK_NUMBER=OPAPPLY.BOOKNO ;
items.DECLARATION_PORT=OPAPPLY.BYCUSTOM ;
items.IMPORT_EXPORT_PORT=OPAPPLY.EXPCUSTOMTYPE ;
items.IMPORT_EXPORT_DATE=OPAPPLY.ETD ;
items.TRANSPORTATION_METHOD=OPAPPLY.BSTYPE ;
items.TRAF_NAME=OPAPPLY.VESSEL ;
items.VOYAGE_NUMBER=OPAPPLY.VOYNO ;
items.CUSTOMS_BROKER_NAME=OPAPPLY.ENTERP ;
items.CUSTOMS_BROKER_CODE=OPAPPLY.ENTERPID ;
items.TRADE_MODE=OPAPPLY.TRADETERM ;
items.DESTINATION_PORT=OPAPPLY.PORTDISCHARGE ;
items.PIECES =OPAPPLY.PKGS.ToString();
items.GROSS_WEIGHT=OPAPPLY.KGS.ToString();
items.NET_WEIGHT =OPAPPLY.NETWEIGHT.ToString();
items.COUNTRY=OPAPPLY.ARCOUNTRY ;
#endregion
#region 单一窗口
SoftMng.BLL.sys_EnumerationBLL bllEM = new SoftMng.BLL.sys_EnumerationBLL();
var emlistdataset = bllEM.GetList("");
var emlisttable = emlistdataset.Tables[0];
var emlistQuery =
from emlist in emlisttable.AsEnumerable()
select emlist;
//DecHead model = new DecHead();
//model.AgentStatus = "暂存";
//model.BSNO = OPAPPLY.BSNO;
//model.GID = Guid.NewGuid().ToString();
//model.EntryType = items.CCS_TYPE;
//if (model.EntryType == "M") model.EntryType_Text = "无纸化通关";
//if (model.EntryType == "O") model.EntryType_Text = "普通报关单";
//if (model.EntryType == "L") model.EntryType_Text = "为带报关单清单的报关单";
//if (model.EntryType == "W") model.EntryType_Text = "无纸报关类型";
//if (model.EntryType == "D") model.EntryType_Text = "既是清单又是无纸报关的情况";
items.CCS_NUMBER = model.EntryId ;
items.HANDBOOK_NUMBER= model.ManualNo ;
items.DECLARATION_PORT=model.CustomMaster ;
//model.CustomMaster_Text = GetTextByCode(emlistQuery, "关区代码", model.CustomMaster);
items.IMPORT_EXPORT_PORT =model.IEPort ;
//.IEPort_Text = GetTextByCode(emlistQuery, "关区代码", model.IEPort);
items.CONTRACT_NUMBER=model.ContrNo ;
//if (!string.IsNullOrEmpty(items.IMPORT_EXPORT_DATE))
// model.IEDate = Convert.ToDateTime(items.IMPORT_EXPORT_DATE);
if (model.IEDate != null)
items.IMPORT_EXPORT_DATE = ((DateTime)model.IEDate).ToString("yyyy-MM-dd");
items.BL_NUMBER=model.BillNo ;
items.TRANSPORTATION_METHOD=model.TrafMode ;
//model.TrafMode_Text = GetTextByCode(emlistQuery, "运输方式", model.TrafMode);
items.TRAF_NAME=model.TrafName ;
items.VOYAGE_NUMBER=model.NativeVoyageNo ;
items.TRADING_COMPANY_CODE=model.TradeCode ;
items.TRADING_COMPANY_NAME=model.TradeName ;
items.RECEIVER_COMPANY_CODE=model.OwnerCode ;
items.RECEIVER_COMPANY_NAME=model.OwnerName ;
items.CUSTOMS_BROKER_CODE=model.AgentCode ;
items.CUSTOMS_BROKER_NAME=model.AgentName ;
items.COUNTRY= model.TradeCountry ;
//model.TradeCountry_Text = GetTextByCode(emlistQuery, "国别地区", model.TradeCountry);
items.TRADE_MODE=model.TradeMode ;
//model.TradeMode_Text = GetTextByCode(emlistQuery, "监管方式", model.TradeMode);
items.TRANSACTION_METHOD=model.TransMode ;
//model.TransMode_Text = GetTextByCode(emlistQuery, "成交方式", model.TransMode);
items.TAX_OPTION=model.CutMode ;
//model.CutMode_Text = GetTextByCode(emlistQuery, "征免性质", model.CutMode);
items.FREIGHT_COST_BASIS=model.FeeMark ;
//decimal feerate = 0;
//TryToDecimal(items.FREIGHT_RATE, out feerate);
//model.FeeRate = feerate;
items.FREIGHT_RATE = model.FeeRate.ToString();
items.FREIGHT_CURRENCY=model.FeeCurr ;
//model.FeeCurr_Text = GetTextByCode(emlistQuery, "币别", model.FeeCurr);
items.PERMIT=model.LicenseNo ;
items.INSURANCE_FEE_BASIS=model.InsurMark ;
//decimal InsurRate = 0;
//TryToDecimal(items.INSURANCE_RATE, out InsurRate);
//model.InsurRate = InsurRate;
items.INSURANCE_RATE = model.InsurRate.ToString();
//model.FeeRate = feerate;
items.INSURANCE_CURRENCY=model.InsurCurr ;
//model.InsurCurr_Text = GetTextByCode(emlistQuery, "币别", model.InsurCurr);
items.MOFCOM_APPROVAL_NUMBER=model.ApprNo ;
items.MISCELLANEOUS_EXPENSE_BASIS=model.OtherMark ;
//decimal OtherRate = 0;
//TryToDecimal(items.MISCELLANEOUS_EXPENSE_RATE, out OtherRate);
//model.OtherRate = OtherRate;
items.MISCELLANEOUS_EXPENSE_RATE = model.OtherRate.ToString();
items.MISCELLANEOUS_EXPENSE_CURRENCY=model.OtherCurr ;
//model.OtherCurr_Text = GetTextByCode(emlistQuery, "币别", model.OtherCurr);
items.PACKAGING_TYPE=model.WrapType ;
//model.WrapType_Text = GetTextByCode(emlistQuery, "包装种类", model.WrapType);
//Int32 PackNo = 0;
//TryToInt32(items.PIECES, out PackNo);
//model.PackNo = PackNo;
items.PIECES = model.PackNo.ToString();
//decimal NetWt = 0;
//TryToDecimal(items.NET_WEIGHT, out NetWt);
//model.NetWt = NetWt;
items.NET_WEIGHT = model.NetWt.ToString();
//decimal GrossWet = 0;
//TryToDecimal(items.GROSS_WEIGHT, out GrossWet);
//model.GrossWet = GrossWet;
items.GROSS_WEIGHT = model.GrossWet.ToString();
items.REMARK=model.NoteS ;
items.E_PORT_DECLARATION_ID=model.SeqNo ;
items.ChkSurety=model.ChkSurety ;
items.BillType=model.BillType ;
items.AgentCodeScc=model.AgentCodeScc ;
items.OwnerCodeScc=model.OwnerCodeScc ;
items.TradeCodeScc=model.TradeCoScc ;
items.CopCodeScc=model.CopCodeScc ;
items.PromiseItmes=model.PromiseItmes ;
items.TradeAreaCode=model.TradeAreaCode ;
// model.TrnHead = items.TradeCodeScc;
items.PreEntryId=model.PreEntryId ;
items.Type=model.Type ;
items.OverseasConsignorCode=model.OverseasConsignorCode ;
items.OverseasConsignorCname=model.OverseasConsignorCname ;
items.OverseasConsignorEname=model.OverseasConsignorEname ;
items.OverseasConsignorAddr=model.OverseasConsignorAddr ;
items.OverseasConsigneeCode=model.OverseasConsigneeCode ;
items.OverseasConsigneeEname=model.OverseasConsigneeEname ;
items.GoodsPlace=model.GoodsPlace ;
items.MarkNo=model.MarkNo ;
items.DespPortCode=model.DespPortCode ;
items.EntyPortCode=model.EntyPortCode ;
items.DeclareName= model.DeclareName ;
items.NoOtherPack=model.NoOtherPack ;
items.DeclTrnRel=model.DeclTrnRel ;
items.EdiId=model.EdiId ;
items.CheckFlow=model.CheckFlow ;
items.TaxAaminMark=model.TaxAaminMark ;
items.BLNo=model.BLNo ;
items.InspOrgCode=model.InspOrgCode ;
items.SpecDeclFlag=model.SpecDeclFlag ;
items.PurpOrgCode=model.PurpOrgCode ;
//if (!string.IsNullOrEmpty(items.DespDate))
// model.DespDate = DateTime.ParseExact(items.DespDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
//if (!string.IsNullOrEmpty(items.CmplDschrgDt))
// model.CmplDschrgDt = DateTime.ParseExact(items.CmplDschrgDt, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
if(model.DespDate!=null)
items.DespDate = ((DateTime)model.DespDate).ToString("yyyyMMdd");
if(model.CmplDschrgDt!=null)
items.CmplDschrgDt = ((DateTime)model.CmplDschrgDt).ToString("yyyyMMdd");
items.CorrelationReasonFlag=model.CorrelationReasonFlag ;
items.VsaOrgCode=model.VsaOrgCode ;
items.OrigBoxFlag=model.OrigBoxFlag ;
items.CorrelationNo=model.CorrelationNo ;
items.EdiRemark=model.EdiRemark ;
items.EdiRemark2=model.EdiRemark2 ;
items.TradeCiqCode=model.TradeCiqCode ;
items.OwnerCiqCode=model.OwnerCiqCode ;
items.DeclCiqCode=model.DeclCiqCode ;
//items.OrgCode=model.OrgCode ;//20210610 删去此节点
//bll.Add(model);
#endregion
var DecListLength = DecList.Count();
var CCS_DETAILList = new MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPECCS_DETAIL[DecListLength];
var CCS_DETAILList_COUNT = 0;
foreach (var Dec in DecList) {
var CCS_DETAIL = new DSWeb.MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPECCS_DETAIL();
CCS_DETAIL.CURRENCY=OPAPPLY.CURRENCY ;
//TOTAL_AMOUNT = TOTAL_AMOUNT + CCS_DETAIL.TOTAL_AMOUNT;
//var Dec = new DecList();
//Dec.PID = model.GID;
//Dec.GID = Guid.NewGuid().ToString();
CCS_DETAIL.SEQUENCE_NUMBER=Dec.GNo ;
CCS_DETAIL.CUSTOMS_ITEM_NUMBER=Dec.ContrItem ;
CCS_DETAIL.PRODUCT_VERSION_NUMBER=Dec.ExgVersion ;
CCS_DETAIL.HS_CODE=Dec.CodeTS ;
CCS_DETAIL.CHINESE_DESCRIPTION=Dec.GName ;
CCS_DETAIL.MODEL=Dec.GModel ;
CCS_DETAIL.DECLARATION_QTY=Dec.GQty==null?0: (decimal)Dec.GQty;
CCS_DETAIL.CUSTOMS_UM=Dec.GUnit ;
//Dec.GUnit_Text = GetTextByCode(emlistQuery, "成交计量单位", Dec.GUnit);
CCS_DETAIL.CUSTOMS_QUANTITY= Dec.FirstQty==null?0:(decimal)Dec.FirstQty ;
CCS_DETAIL.FIRST_CUSTOMS_UM=Dec.FirstUnit ;
//Dec.FirstUnit_Text = GetTextByCode(emlistQuery, "成交计量单位", Dec.FirstUnit);
//decimal SecondQty = 0;
//TryToDecimal(CCS_DETAIL.SECOND_CUSTOMS_QUANTITY, out SecondQty);
//Dec.SecondQty = SecondQty;
CCS_DETAIL.SECOND_CUSTOMS_QUANTITY = Dec.SecondQty.ToString();
CCS_DETAIL.SECOND_CUSTOMS_UM=Dec.SecondUnit ;
//Dec.SecondUnit_Text = GetTextByCode(emlistQuery, "成交计量单位", Dec.SecondUnit);
//decimal DeclPrice = 0;
//TryToDecimal(CCS_DETAIL.UNIT_PRICE, out DeclPrice);
//Dec.DeclPrice = DeclPrice;
CCS_DETAIL.UNIT_PRICE = Dec.DeclPrice.ToString();
CCS_DETAIL.TOTAL_AMOUNT=Dec.DeclTotal==null?0: (decimal)Dec.DeclTotal ;
CCS_DETAIL.CURRENCY=Dec.TradeCurr ;
//Dec.TradeCurr_Text = GetTextByCode(emlistQuery, "币别", Dec.TradeCurr);
CCS_DETAIL.COUNTRY=Dec.OriginCountry ;
//Dec.OriginCountry_Text = GetTextByCode(emlistQuery, "国别地区", Dec.OriginCountry);
CCS_DETAIL.TAX_OPTION=Dec.DutyMode ;
//Dec.DutyMode_Text = GetTextByCode(emlistQuery, "征免方式", Dec.DutyMode);
CCS_DETAIL.DestinationCountry=Dec.DestinationCountry ;
//Dec.DestinationCountry_Text = GetTextByCode(emlistQuery, "征免方式", Dec.DestinationCountry);
CCS_DETAIL.CiqCode=Dec.CiqCode ;
CCS_DETAIL.DistrictCode=Dec.DistrictCode ;
CCS_DETAIL.DESTINATION_DISTRICT=Dec.DestCode ;
//Dec.Factor = CCS_DETAIL.Factor;
//Dec.DeclGoodsEname = CCS_DETAIL.DeclGoodsEname;
//Dec.OrigPlaceCode = CCS_DETAIL.OrigPlaceCode;
CCS_DETAIL.Purpose=Dec.Purpose ;
//Dec.Purpose_Text = GetTextByCode(emlistQuery, "用途", Dec.Purpose);
//if (!string.IsNullOrEmpty(CCS_DETAIL.ProdValidDt))
// Dec.ProdValidDt = DateTime.ParseExact(CCS_DETAIL.ProdValidDt, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); ;
if(Dec.ProdValidDt!=null)
CCS_DETAIL.ProdValidDt = ((DateTime)Dec.ProdValidDt).ToString("yyyyMMdd");
//Int32 ProdQgp = 0;
//TryToInt32(CCS_DETAIL.ProdQgp, out ProdQgp);
//Dec.ProdQgp = ProdQgp;
CCS_DETAIL.ProdQgp = Dec.ProdQgp.ToString();
CCS_DETAIL.GoodsAttr=Dec.GoodsAttr ;
//Dec.GoodsAttr_Text = GetTextByCode(emlistQuery, "货物属性", Dec.GoodsAttr);
CCS_DETAIL.Stuff=Dec.Stuff ;
CCS_DETAIL.Uncode=Dec.Uncode ;
CCS_DETAIL.DangName=Dec.DangName ;
//Int32 DangPackType = 0;
//TryToInt32(CCS_DETAIL.DangPackType, out DangPackType);
//Dec.ProdQgp = DangPackType;
//CCS_DETAIL.DangPackTyp = Dec.ProdQgp.ToString();
CCS_DETAIL.DangPackSpec=Dec.DangPackSpec ;
//Dec.DangPackSpec_Text = GetTextByCode(emlistQuery, "危包规格", Dec.DangPackSpec);
CCS_DETAIL.EngManEntCnm=Dec.EngManEntCnm ;
//Int32 NoDangFlag = 0;
//TryToInt32(CCS_DETAIL.NoDangFlag, out NoDangFlag);
//Dec.NoDangFlag = NoDangFlag;
CCS_DETAIL.NoDangFlag = Dec.NoDangFlag.ToString();
CCS_DETAIL.GoodsSpec=Dec.GoodsSpec ;
CCS_DETAIL.GoodsModel=Dec.GoodsModel ;
CCS_DETAIL.GoodsBrand=Dec.GoodsBrand ;
CCS_DETAIL.ProduceDate=Dec.ProduceDate ;
CCS_DETAIL.ProdBatchNo=Dec.ProdBatchNo ;
DecGoodsLimitBLL gbll = new DecGoodsLimitBLL();
var DecGoodsLimitList = gbll.GetModelList("PID='" + Dec.GID + "'").ToList();
if (DecGoodsLimitList.Count == 0) { }
else
{
var DecGoodsLimitList_COUNT = 0;
var GOODLIMITList = new MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPECCS_DETAILDecGoodsLimit[DecGoodsLimitList.Count()];
foreach (var DecGood in DecGoodsLimitList)
{
var GOODLIMIT = new MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPECCS_DETAILDecGoodsLimit();
//DecGood.PID = Dec.GID;
//DecGood.GID = Guid.NewGuid().ToString();
GOODLIMIT.GoodsNo = DecGood.GoodsNo;
GOODLIMIT.LicTypeCode = DecGood.LicTypeCode;
//DecGood.LicTypeCode_Text = GetTextByCode(emlistQuery, "许可证类别", DecGood.LicTypeCode);
GOODLIMIT.LicenceNo = DecGood.LicenceNo;
GOODLIMIT.LicWrtofDetailNo = DecGood.LicWrtofDetailNo;
//DecGood.LicWrtofQty = Convert.ToInt32(GOODLIMIT.LicWrtofQty);
GOODLIMIT.LicWrtofQty = DecGood.LicWrtofQty.ToString();
var glvbll = new DecGoodsLimitVinBLL();
var DecGoodsLimitVinList = glvbll.GetModelList("PID='" + DecGood.GID + "'").ToList();
if (DecGoodsLimitVinList.Count == 0)
{}
else
{
var DecGoodsLimitVin_XMLArray= new MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPECCS_DETAILDecGoodsLimitDecGoodsLimitVin[DecGoodsLimitVinList.Count()];
var DecGoodsLimitVinList_COUNT = 0;
foreach (var DecGoodvin in DecGoodsLimitVinList) {
var GOODLIMITVIN = new MvcShipping.Models.MsOpApply_BOSH383.CCS_HEADER_TYPECCS_DETAILDecGoodsLimitDecGoodsLimitVin();
//DecGoodvin.PID = DecGood.GID;
//DecGoodvin.GID = Guid.NewGuid().ToString();
////DecGoodvin.LicenceNo = GOODLIMITVIN.LicenceNo;
//DecGoodvin.LicTypeCode = GOODLIMITVIN.LicTypeCode;
GOODLIMITVIN.VinNo=DecGoodvin.VinNo ;
//if (!string.IsNullOrEmpty(GOODLIMITVIN.BillLadDate))
// DecGoodvin.BillLadDate = DateTime.ParseExact(GOODLIMITVIN.BillLadDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
if (DecGoodvin.BillLadDate != null)
GOODLIMITVIN.BillLadDate = ((DateTime)DecGoodvin.BillLadDate).ToString("yyyyMMdd");
GOODLIMITVIN.QualityQgp=DecGoodvin.QualityQgp ;
GOODLIMITVIN.MotorNo=DecGoodvin.MotorNo ;
GOODLIMITVIN.VinCode=DecGoodvin.VinCode ;
GOODLIMITVIN.ChassisNo=DecGoodvin.ChassisNo ;
//Int32 InvoiceNum = 0;
//TryToInt32(GOODLIMITVIN.InvoiceNum, out InvoiceNum);
//DecGoodvin.InvoiceNum = InvoiceNum;
GOODLIMITVIN.InvoiceNum = DecGoodvin.InvoiceNum.ToString();
GOODLIMITVIN.ProdCnnm=DecGoodvin.ProdCnnm ;
GOODLIMITVIN.ProdEnnm=DecGoodvin.ProdEnnm ;
GOODLIMITVIN.ModelEn=DecGoodvin.ModelEn ;
//decimal PricePerUnit = 0;
//TryToDecimal(GOODLIMITVIN.PricePerUnit, out PricePerUnit);
//DecGoodvin.PricePerUnit = PricePerUnit;
GOODLIMITVIN.PricePerUnit = DecGoodvin.PricePerUnit.ToString();
GOODLIMITVIN.InvoiceNo = DecGoodvin.InvoiceNo ;
DecGoodsLimitVin_XMLArray[DecGoodsLimitVinList_COUNT] = GOODLIMITVIN;
DecGoodsLimitVinList_COUNT++;
}
GOODLIMIT.DecGoodsLimitVin = DecGoodsLimitVin_XMLArray;
}
GOODLIMITList[DecGoodsLimitList_COUNT] = GOODLIMIT;
DecGoodsLimitList_COUNT++;
}
}
CCS_DETAILList[CCS_DETAILList_COUNT] = CCS_DETAIL;
CCS_DETAILList_COUNT++;
}
items.CCS_DETAIL = CCS_DETAILList;
CCS_HEADERLIST[CCS_HEADERLIST_COUNT] = items;
CCS_HEADERLIST_COUNT++;
}
SHIPMENT.CCS_HEADER = CCS_HEADERLIST;
SHIPMENT.INTEGRATION_MESSAGE_CONTROL = headinfo;
return SHIPMENT;
}
private string Get385XmlFile(List<string> CUSTOMNOList)
{
var SHIPMENT = Get385Xml(CUSTOMNOList);
XmlSerializer XML_1 = new XmlSerializer(SHIPMENT.GetType());
var path = Server.MapPath(OPAPPLYFilePath);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + "_385.xml";
if (System.IO.File.Exists(Path.GetFullPath(filename)))
{
System.IO.File.Delete(Path.GetFullPath(filename));
}
var tw = new StreamWriter(filename);
XML_1.Serialize(tw, SHIPMENT);
tw.Close();
var result = OPAPPLYFilePath+"/" + usercode + "_385.xml";
return result;
}
private SHIPMENT_STATUS_OUTBOUND_V2 Get385Xml(List<string> CUSTOMNOList) {
var SHIPMENT = new SHIPMENT_STATUS_OUTBOUND_V2();
var headinfo = new DSWeb.MvcShipping.Models.MsOpApply_BOSH385.SHIPMENT_STATUS_OUTBOUND_V2INTEGRATION_MESSAGE_CONTROL();
foreach (var CUSTOMNO in CUSTOMNOList)
{
var OPAPPLY = MsOpApplyDAL.GetData(" CUSTOMNO='" + CUSTOMNO + "'");
#region 20210610 获取逻辑信息表的数据 如无信息则返回空
var HeadDic = BasicDataRefDAL.GetLogicInfo(OPAPPLY.BSNO, LOGICNAME_381);
if (HeadDic == null || HeadDic.Count() == 0) return SHIPMENT;
headinfo.ACTION = HeadDic["ACTION"];
headinfo.COMPANY_CODE = HeadDic["COMPANY_CODE"];
headinfo.ORG_CODE = HeadDic["ORG_CODE"];
var _t = decimal.Parse(HeadDic["PRIORITY"]);
if (HeadDic["PRIORITY"] == "")
{
headinfo.PRIORITY = null;
}
else
{
headinfo.PRIORITY = _t;
}
headinfo.MESSAGE_TYPE = HeadDic["MESSAGE_TYPE"];
headinfo.USERID = HeadDic["USERID"];
headinfo.RECEIVER = HeadDic["RECEIVER"];
headinfo.SENDER = HeadDic["SENDER"];
headinfo.BATCH_ID = HeadDic["BATCH_ID"];
headinfo.SOURCE_SYSTEM_TOKEN = "";
headinfo.BUS_KEY = new DSWeb.MvcShipping.Models.MsOpApply_BOSH385.SHIPMENT_STATUS_OUTBOUND_V2INTEGRATION_MESSAGE_CONTROLBUS_KEY();
headinfo.BUS_KEY.ORG_CODE = HeadDic["ORG_CODE"];
headinfo.BUS_KEY.SHIPMENT_NUMBER = HeadDic["SHIPMENT_NUMBER"];
SHIPMENT.INTEGRATION_MESSAGE_CONTROL = headinfo;
#endregion
var bll = new DecHeadBLL();
var model = bll.GetModelList("BSNO='" + OPAPPLY.BSNO + "'")[0];
//var message = new SHIPMENT_STATUS_OUTBOUND_V2INTEGRATION_MESSAGE_CONTROL();
//message.BATCH_ID = OPAPPLY.BSNO;
//message.BUS_KEY = new SHIPMENT_STATUS_OUTBOUND_V2INTEGRATION_MESSAGE_CONTROLBUS_KEY();
//message.BUS_KEY.SHIPMENT_NUMBER = OPAPPLY.BSNO;
SHIPMENT.INTEGRATION_MESSAGE_CONTROL = headinfo;
var header = new SHIPMENT_STATUS_HEADER_TYPE();
//SHIPMENT.SHIPMENT_STATUS_HEADER
header.SHIPMENT_NUMBER = HeadDic["SHIPMENT_NUMBER"];
header.HWB = OPAPPLY.HBLNO;
header.MWB = OPAPPLY.MBLNO;
header.INTERNAL_SHIPMENT_NUMBER = "";
var ies = "E";
if (OPAPPLY.BSTYPEREF.IndexOf("进口") >= 0)
{
ies = "I";
}
header.INCOMING_STATUS = ies;
header.INTERNAL_CCS = OPAPPLY.CUSTOMNO;
header.CCS_NUMBER = model.EntryId;
var DetailList = new SHIPMENT_STATUS_DETAIL_TYPE[3];
DetailList[0] = new SHIPMENT_STATUS_DETAIL_TYPE();
DetailList[0].STATUS_TYPE = "0";
DetailList[0].STATUS_CODE = "54";//海关系统申报日 //取单一窗口申报日期
DetailList[0].STATUS_TIME = string.IsNullOrWhiteSpace( model.DDateStr)?"": model.DDateStr + " 00:00:00";
DetailList[1] = new SHIPMENT_STATUS_DETAIL_TYPE();
DetailList[1].STATUS_TYPE = "0";
DetailList[1].STATUS_CODE = "16";//海关放行日期 //取单一窗口进出口日期
DetailList[1].STATUS_TIME = string.IsNullOrWhiteSpace(model.IEDateStr) ? "" : model.IEDateStr + " 00:00:00";
DetailList[2] = new SHIPMENT_STATUS_DETAIL_TYPE();
DetailList[2].STATUS_TYPE = "0";
DetailList[2].STATUS_CODE = "55";//海关查验日 //取报关业务的通关日期
DetailList[2].STATUS_TIME = string.IsNullOrWhiteSpace(OPAPPLY.CUSTOMDATE) ? "" : OPAPPLY.CUSTOMDATE + " 00:00:00";
header.SHIPMENT_STATUS_DETAIL = DetailList;
SHIPMENT.SHIPMENT_STATUS_HEADER = header;
}
return SHIPMENT;
}
[HttpPost]
public ContentResult UploadXmlBs(string CUSTOMNOs) {
var result = new DBResult();
var jsonRespose = new JsonResponse { Success = false, Message = "" };
BasicDataRefDAL.SaveLog("", "", "博世上传", "开始");
try
{
result = DoUploadXmlBs(CUSTOMNOs);
var json = JsonConvert.Serialize(new { Success = result.Success, Message = result.Message, data = result.Data });
return new ContentResult() { Content = json };
}
catch (Exception e)
{
BasicDataRefDAL.SaveLog(e.Message, "", "博世上传", "错误");
jsonRespose.Success = false;
jsonRespose.Message = "生成报文出错:" + e.Message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public DBResult DoUploadXmlBs(string CUSTOMNOs) {
var result = new DBResult();
var mark = 0;
try
{
mark = 1;
var CUSTOMNOList = CUSTOMNOs.Split(',').ToList();
//寻找ftp信息
CommonDataContext cdc = new CommonDataContext();
var ftpinfo = new code_FtpSet_md();
var ftpinfoList = cdc.code_FtpSet.Where(x => x.EDINAME.StartsWith("BOSCH")).ToList();
if (ftpinfoList == null || ftpinfoList.Count == 0)
{
result.SetErrorInfo("没有找到BOSCH的FTP信息");
return result;
}
else
{
ftpinfo = ftpinfoList[0];
}
mark = 2;
//制作两个xml文件
var Filename383 = Get383XmlFile(CUSTOMNOList);
if (Filename383 == "") {
result.SetErrorInfo("没有找到导入的原始报文信息!");
}
mark = 3;
var Filename385 = Get385XmlFile(CUSTOMNOList);
mark = 4;
var path = Server.MapPath(OPAPPLYFilePath);
Filename383 = Filename383.Replace(OPAPPLYFilePath, path);
mark = 5;
Filename385 = Filename385.Replace(OPAPPLYFilePath, path);
mark = 6;
var targetfullpath_383 = (ftpinfo.FOLDERNAME.Replace(@"\", "/").EndsWith("/") ? ftpinfo.FOLDERNAME : ftpinfo.FOLDERNAME + "/") + CUSTOMNOList[0] + "_383.XML";
mark = 7;
var targetfullpath_385 = (ftpinfo.FOLDERNAME2.Replace(@"\", "/").EndsWith("/") ? ftpinfo.FOLDERNAME2 : ftpinfo.FOLDERNAME2 + "/") + CUSTOMNOList[0] + "_385.XML";
mark = 8;
//然后登陆ftp 把这两个文件放上去
SFTPHelper FTPDA = new SFTPHelper(ftpinfo);
mark = 9;
FTPDA.Connect();
mark = 10;
using (var file = System.IO.File.OpenRead(Filename383))
{
FTPDA.sftp.UploadFile(file, targetfullpath_383);
}
mark = 11;
using (var file = System.IO.File.OpenRead(Filename385))
{
FTPDA.sftp.UploadFile(file, targetfullpath_385);
}
mark = 12;
FTPDA.Disconnect();
}
catch (Exception ex) {
BasicDataRefDAL.SaveLog(mark.ToString()+"_"+ ex.Message, "", "博世上传", "");
}
result.setMessage(true, "发送成功");
return result;
}
#endregion
/// <summary>
/// 获取HS检验检疫名称
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="query"></param>
/// <returns></returns>
public JsonResult GetHsQua(int pageIndex, int pageSize, string query, string type)
{
Dec_HsQuaBLL bll = new Dec_HsQuaBLL();
StringBuilder where = new StringBuilder();
where.Append("HSCode='" + type + "'");
if (!String.IsNullOrEmpty(query))
where.Append(string.Format(" And ([Value] LIKE '%{0}%' OR Name LIKE '%{0}%')", query));
var total = bll.GetRecordCount(where.ToString());
var list = bll.GetModelList(pageIndex, pageSize, where.ToString(), "[Value] collate Chinese_PRC_CS_AS_KS_WS");
var result = from p in list
select new
{
id = p.Value,
text = p.Value + " - " + p.Name
};
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取模板
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="query"></param>
/// <returns></returns>
public JsonResult GetDecModel(int pageIndex, int pageSize, string query, string type)
{
DecModelBLL bll = new DecModelBLL();
StringBuilder where = new StringBuilder();
where.Append("[Type]=" + type);
if (!String.IsNullOrEmpty(query))
where.Append(string.Format(" And [Value] LIKE '%{0}%'", query));
var total = bll.GetRecordCount(where.ToString());
var list = bll.GetModelList(pageIndex, pageSize, where.ToString(), "[Value] collate Chinese_PRC_CS_AS_KS_WS");
var result = from p in list
select new
{
id = p.Value,
text = p.Value,
model = p.Model
};
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取产地代码
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="query"></param>
/// <returns></returns>
public JsonResult GetOriginCode(int pageIndex, int pageSize, string query)
{
sys_b_OriginCodeBLL bll = new sys_b_OriginCodeBLL();
StringBuilder where = new StringBuilder();
where.Append("1=1");
if (!String.IsNullOrEmpty(query))
where.Append(string.Format("And ([Value] LIKE '%{0}%' OR Name LIKE '%{0}%')", query));
var total = bll.GetRecordCount(where.ToString());
var list = bll.GetModelList(pageIndex, pageSize, where.ToString(), "[Value] collate Chinese_PRC_CS_AS_KS_WS");
var result = from p in list
select new
{
id = p.Value,
text = p.Value + " - " + p.Name
};
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取商品编码
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="query"></param>
/// <returns></returns>
public JsonResult GetProductCode(int pageIndex, int pageSize, string query)
{
sys_EnumerationBLL ebll = new sys_EnumerationBLL();
Dec_ProductBLL bll = new Dec_ProductBLL();
StringBuilder where = new StringBuilder();
where.Append("1=1");
if (!String.IsNullOrEmpty(query))
where.Append(string.Format("And ([HSCODE] LIKE '%{0}%' OR Name LIKE '%{0}%')", query));
var total = bll.GetRecordCount(where.ToString());
var list = bll.GetModelList(pageIndex, pageSize, where.ToString(), "[HSCODE] collate Chinese_PRC_CS_AS_KS_WS");
var result = from p in list
select new
{
id = p.HSCODE,
text = p.HSCODE,
name = p.NAME,
unit = p.UNIT,
code1 = ebll.GetModelList("NAME ='" + p.UNIT.Split('/')[0] + "'").FirstOrDefault(),
code2 = p.UNIT.Split('/').Length > 1 ? ebll.GetModelList("NAME ='" + p.UNIT.Split('/')[1] + "'").FirstOrDefault() : null
};
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 获取模板列表
/// </summary>
/// <returns></returns>
public JsonResult GetModelList(int startIndex, int limit, string sortOrder, string sortName, string search)
{
DecModelBLL mbll = new DecModelBLL();
StringBuilder where = new StringBuilder();
if (!String.IsNullOrEmpty(search))
where.Append(string.Format("[Value] LIKE '%{0}%'", search));
var list = mbll.GetModelList(startIndex, limit, where.ToString(), String.Format("{0} {1}", sortName, sortOrder));
var count = mbll.GetRecordCount(where.ToString());
return Json(new { total = count, rows = list });
}
/// <summary>
/// 保存模板
/// </summary>
/// <returns></returns>
public JsonResult SaveModel(DecModel dmodel)
{
DecModelBLL mbll = new DecModelBLL();
bool result;
var pmodel = mbll.GetModelList("Value='" + dmodel.Value + "' and type=" + dmodel.Type).FirstOrDefault();
if (pmodel == null)
{
dmodel.GID = Guid.NewGuid().ToString();
result = mbll.Add(dmodel) > 0;
} //新增
else
{
//类反射
Type type = typeof(DecModel);
PropertyInfo[] piArr = type.GetProperties();
foreach (var pi in piArr)
{
if (Array.IndexOf(Request.Params.AllKeys, pi.Name) < 0)
pi.SetValue(dmodel, pi.GetValue(pmodel, null), null);
}
result = mbll.Update(dmodel) > 0;
} //修改
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
}
/// <summary>
/// 删除模板
/// </summary>
/// <returns></returns>
public JsonResult DelModel(string ids)
{
DecModelBLL mbll = new DecModelBLL();
bool result = mbll.DeleteListWhere(string.Format("GID in({0})", ids)) > 0;
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
}
/// <summary>
/// 删除单一窗口信息
/// </summary>
/// <param name="gid"></param>
/// <returns></returns>
public JsonResult Delete(string gid)
{
try
{
//删除主单
bll.Delete(gid);
gbll.DeleteListWhere("PID in (select GID from DecList where PID ='" + gid + "')");
vbll.DeleteListWhere("PID in (select GID from DecGoodsLimit where PID in (select GID from DecList where PID ='" + gid + "'))");
lbll.DeleteListWhere("PID='" + gid + "'");
cbll.DeleteListWhere("PID='" + gid + "'");
dbll.DeleteListWhere("PID='" + gid + "'");
tbll.DeleteListWhere("PID='" + gid + "'");
clbll.DeleteListWhere("PID='" + gid + "'");
opbll.DeleteListWhere("PID='" + gid + "'");
rcbll.DeleteListWhere("PID='" + gid + "'");
return Json(new { success = true });
}
catch (Exception se)
{
return Json(new { success = false, message = se.Message });
}
}
/// <summary>
/// 获取申报要素
/// </summary>
/// <param name="hscode"></param>
/// <returns></returns>
public JsonResult GetGmodel(string hscode)
{
string code = hscode.Substring(0, 3);
var ds = DBUtility.DbHelperSQL.Query("select distinct [CODE] from [Dec_ProductStandard] where [CODE] LIKE'" + code + "%' ");
if (ds.Tables.Count > 0)
{
var dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
var rowcode = item[0].ToString();
if (rowcode.Length > code.Length && hscode.Contains(rowcode))
{
code = rowcode;
}
}
}
}
Dec_ProductStandardBLL bll = new Dec_ProductStandardBLL();
var list = bll.GetModelList("[CODE] = '" + code + "'").OrderBy(p => p.SORT).ToList();
return Json(list);
}
/// <summary>
/// 获取单一窗口列表
/// </summary>
/// <param name="bsno"></param>
/// <returns></returns>
public JsonResult GetSingleList(string bsno)
{
var list = bll.GetModelList("BSNO='" + bsno + "'");
// op_applyBLL opbll = new op_applyBLL();
// var model = opbll.GetModelList("BSNO='" + bsno + "'").FirstOrDefault();
var model = MsOpApplyDAL.GetData("BSNO='"+bsno+"'");
return Json(new { list, model });
}
#region 单一窗口审核
/// <summary>
/// 单一窗口列表信息
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
int count = 0;
var dataList = DecHeadDAL.GetDataList(condition, start, limit, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), out count, sort);
var timeStamp = DateTime.Now.ToShortDateString();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList(), timeStamp = timeStamp });
return new ContentResult() { Content = json };
}
#endregion
#region 读取单一窗口信息(读取接口)带附件
public const string _IURL = "http://47.104.90.170:9000/sw/download";
public const string _IURL_Nodoc= "http://47.104.90.170:9000/sw/merge/detail";
private string getPortStr(string starttime = "", string endtime = "", string CUSTOMNO = "", string MBLNO = "", string ies = "", string clearance = "0", string yardid = "sw",string unicode="",string etps_category="A",int cdntype=0, bool withdoc=true) {
string rtn = "";
var t_str = "";
var swcn = MsSysParamSetDAL.GetSysParamValue("OpApplySingle_User");
var swpw = MsSysParamSetDAL.GetSysParamValue("OpApplySingle_Pwd");
//20230518 如果有唯一编号 则将提单号置为0
if (!string.IsNullOrWhiteSpace(unicode)) {
MBLNO = "";
}
if (withdoc)
{
JObject reqObj = new JObject
{
/*网站代号sw
卡号
密码md5加密后
报关单号
进出口标志(只有两个值) I大写i: 进口, E: 出口
是否结关(只有两个值) 1:是0:否
string swcn = "2020030084935", string swpw = "8a5889ea8e53b257e2a3ba053979ee64"
*/
{ "yardid", yardid },
{ "swcn", swcn },
{ "swpw", swpw },
{ "cdn", CUSTOMNO },//报关单号
{ "billno", MBLNO },//主提单号
{ "unicode", unicode },//统一编号
{ "ies", ies },
{ "clearance", clearance },//未结关
{ "cdnType", cdntype },//单据类型
{ "starttime", starttime },//
{ "endtime", endtime },//
{ "etps_category", etps_category }//
};
//reqObj.Add("billno", "KMTCSIN2287541");
//reqObj.Add("ies", "I");
//reqObj.Add("clearance", "0");
t_str = reqObj.ToString(Newtonsoft.Json.Formatting.None);
rtn = DSWeb.Areas.MvcShipping.Comm.WebRequestHelper.DoPost(_IURL, t_str, 180000);
BasicDataRefDAL.SaveLog("_IURL=" + _IURL + ";t_str=" + t_str + ";rtn=" + rtn, "单一窗口", "读取单一窗口", "一次业务");
}
if (!withdoc) {
JObject reqObj = new JObject
{
/*网站代号sw
卡号
密码md5加密后
报关单号
进出口标志(只有两个值) I大写i: 进口, E: 出口
是否结关(只有两个值) 1:是0:否
string swcn = "2020030084935", string swpw = "8a5889ea8e53b257e2a3ba053979ee64"
*/
{ "card", swcn },
{ "pwd", swpw },
{ "ies", ies },
{ "clear", clearance },//未结关
{ "cdnType", cdntype },//单据类型
{ "cdn", CUSTOMNO },
{ "bill", MBLNO },
{ "unicode", unicode },
{ "start", starttime },//
{ "end", endtime },//
{ "startNumber", "0" },//
{ "endNumber", "1" },//
{ "etps_category", etps_category }//
};
reqObj.ToString(Newtonsoft.Json.Formatting.None);
t_str = reqObj.ToString(Newtonsoft.Json.Formatting.None);
rtn = DSWeb.Areas.MvcShipping.Comm.WebRequestHelper.DoPost(_IURL_Nodoc, t_str, 180000);
BasicDataRefDAL.SaveLog("_IURL=" + _IURL_Nodoc + ";t_str=" + t_str + ";rtn=" + rtn, "单一窗口", "读取单一窗口", "一次业务");
}
return rtn;
}
//二步申报业务的读取
public const string _IURL_2 = "http://47.104.90.170:9000/sw/ts/downloads";
public const string _IURL_2_Nodoc = "http://47.104.90.170:9000/sw/ts/details";
/// <summary>
/// 二步申报 读取
/// </summary>
/// <param name="starttime"></param>
/// <param name="endtime"></param>
/// <param name="CUSTOMNO"></param>
/// <param name="MBLNO"></param>
/// <param name="ies"></param>
/// <param name="clearance"></param>
/// <param name="yardid"></param>
/// <returns></returns>
private string getPortStr_2( string CUSTOMNO = "", string MBLNO = "", string SeqNo = "", string etps_category = "A", int cdntype = 0, bool withdoc = true)
{
//20230518 如果有唯一编号 则将提单号置为0
if (!string.IsNullOrWhiteSpace(SeqNo))
{
MBLNO = "";
}
string rtn = "";
JObject reqObj = new JObject();
/*
### 单一窗口两步申报总数据详情和pdf查询 API
#### 请求的数据:
请求方式POST
url定义http://47.104.90.170:9000/sw/ts/downloads
请求参数formdata
| 参数 | 类型 | 是否必须传 | 描述 |
| :---------: | :----: | :--------: | :--------------------------: |
| card | 字符串 | 是 | 卡号 |
| pwd | 字符串 | 是 | 密码 |
| cdn | 字符串 | 否 | 报关单号 |
| bill | 字符串 | 否 | 提单号 |
| unicode | 字符串 | 否 | 统一编号 |
| start | 字符串 | 否 | 查询开始日期 (2020-06-09) |
| end | 字符串 | 否 | 查询结束日期 (2020-06-09) |
| startNumber | 数值 | 否 | 查询数据开始数1,11,21 |
| endNumber | 数值 | 否 | 查询数据结束数10,20,30 |
*/
var swcn = MsSysParamSetDAL.GetSysParamValue("OpApplySingle_User");
var swpw = MsSysParamSetDAL.GetSysParamValue("OpApplySingle_Pwd");
reqObj.Add("card", swcn);
reqObj.Add("pwd", swpw);
reqObj.Add("cdnType", cdntype);//单据类型
reqObj.Add("cdn", CUSTOMNO);
reqObj.Add("bill", MBLNO);
reqObj.Add("unicode", SeqNo);
reqObj.Add("start", "");
reqObj.Add("end", "");
reqObj.Add("startNumber", "1");
reqObj.Add("endNumber", "10");
reqObj.Add("etps_category", etps_category);//
var t_str = reqObj.ToString(Newtonsoft.Json.Formatting.None);
var useurl = "";
if (withdoc)
{
useurl = _IURL_2;
//rtn = DSWeb.Areas.MvcShipping.Comm.WebRequestHelper.DoPost(_IURL_2, t_str, 180000);
}
if (!withdoc)
{
useurl = _IURL_2_Nodoc;
//rtn = DSWeb.Areas.MvcShipping.Comm.WebRequestHelper.DoPost(_IURL_2_Nodoc, t_str, 180000);
}
rtn = DSWeb.Areas.MvcShipping.Comm.WebRequestHelper.DoPost(useurl, t_str, 180000);
BasicDataRefDAL.SaveLog("_IURL=" + useurl + ";t_str=" + t_str + ";rtn=" + rtn, "单一窗口", "读取单一窗口", "二步申报");
return rtn;
}
/// <summary>
/// 读取单一窗口数据 指定报关单号/提单号/统一编号 读取
/// </summary>
/// <param name="bsno"></param>
/// <returns></returns>
private JsonResult GetDecHead_Port(string bsno,string userid,string username, bool withdoc=true)
{
//var username = Session["SHOWNAME"].ToString();
//var userid = Session["USERID"].ToString();
var DecHead_Local = bll.GetModelList("BSNO='" + bsno + "'").FirstOrDefault();
var opapplyhead = MsOpApplyDAL.GetData("BSNO='" + bsno + "'");
//var billno = opapplyhead.MBLNO;
var CUSTOMNO = "";
var MBLNO = "";
var SeqNo = "";
CUSTOMNO = opapplyhead.CUSTOMNO;
if (string.IsNullOrWhiteSpace(CUSTOMNO)) {
}
MBLNO = opapplyhead.MBLNO;
var updateseai = false;
//20230606 根据系统配置值
var updopseaiType = MsSysParamSetDAL.GetSysParamValue("ApplySaveToOpseai");
//0不保存 1提单号 2报关单号 3提单号或报关单号
var opseaiheadList = new List<MsOpSeai>();
//MsOpSeaiDAL.GetDataAll(" ((isnull(MBLNO,'')<>'' and MBLNO='" + MBLNO + "' ) or (isnull(CUSTOMNO,'')<>'' and CUSTOMNO='" + CUSTOMNO + "') )");
//if (!string.IsNullOrEmpty(opseaihead.CUSTNO) && !opseaihead.BSSTATUS) updateseai = true;
var opseaihead = new MsOpSeai();
if (updopseaiType != "0")
{
var condition = "1=2";
if (updopseaiType == "1") {
condition = " (isnull(MBLNO,'')<>'' and MBLNO='" + MBLNO + "' ) ";
}
if (updopseaiType == "2")
{
condition = " (isnull(CUSTOMNO,'')<>'' and CUSTOMNO='" + MBLNO + "' ) ";
}
if (updopseaiType == "3")
{
condition = " ( (isnull(MBLNO,'')<>'' and MBLNO='" + MBLNO + "' ) or (isnull(CUSTOMNO,'')<>'' and CUSTOMNO='" + CUSTOMNO + "') )";
}
opseaiheadList = MsOpSeaiDAL.GetDataAll(condition);
if (opseaiheadList == null || opseaiheadList.Count == 0 || (opseaiheadList != null && opseaiheadList.Count > 1))
{
updateseai = false;
}
else
{
opseaihead = opseaiheadList[0];
updateseai = true;
}
}
else {
updateseai = false;
}
SeqNo = opapplyhead.CUSCIQNO;
var needinsert = false;
var needupd = false;
if (DecHead_Local == null)
{
DecHead_Local = new DecHead();
needinsert = true;
}
else needupd = true;
///从接口读取信息
string rtn = "";
var result = new DBResult();
result.Success = true;
var ies = "E";
if (opapplyhead.BSTYPEREF.IndexOf("进口") >= 0)
{
ies = "I";
}
var clearance = opapplyhead.ISCLEAR;
//20210706 增加参数 opapply. ETPS_CATEGORY 取值范围 A C D 存储于枚举类型96100
var etps_category = opapplyhead.ETPS_CATEGORY;
var cdntype = opapplyhead.CDNTYPE;
if (string.IsNullOrWhiteSpace(etps_category)) etps_category = "A";
if (DecHead_Local.ApplyType == 1 || DecHead_Local.ApplyType == null)
rtn = getPortStr("", "", CUSTOMNO, MBLNO, ies, clearance,"sw", SeqNo, etps_category, cdntype, withdoc);
else
rtn = getPortStr_2(CUSTOMNO, MBLNO, SeqNo, etps_category, cdntype, withdoc);
var _status = "0";
var portresultstatus = Newtonsoft.Json.JsonConvert.DeserializeObject<DecHead_status>(rtn);
_status = portresultstatus.status;
var PortReturn = new DecHead_WebModel();
if (_status == "1")
{
//rtn = getPortStr(CUSTOMNO, MBLNO, ies, "0");
//rtn = formatresult(rtn);
PortReturn = Newtonsoft.Json.JsonConvert.DeserializeObject<DecHead_WebModel>(rtn);
if (PortReturn.message[0].ok == false)
{
return Json(new { status = false, message = PortReturn.message[0].data.message });
}
}
else {
var _r = Newtonsoft.Json.JsonConvert.DeserializeObject<DecHead_statusmessage>(rtn);
return Json(new { status = false, message = _r.message });
}
//if (DecHead_Local.ApplyType == 1 || DecHead_Local.ApplyType == null)
//{
// rtn = getPortStr("", "", CUSTOMNO, MBLNO, ies, "1");
// //rtn = formatresult(rtn);
// PortReturn = Newtonsoft.Json.JsonConvert.DeserializeObject<DecHead_WebModel>(rtn);
//}
opapplyhead.ISDY = "1";
opapplyhead.ModelUIStatus="E";
//PortReturn.Message= JsonConvert.Deserialize<MessageModel>(PortReturn.message[0]);
//PortReturn.Message.Data = JsonConvert.Deserialize<DecHead_data>(PortReturn.Message.data);
//PortReturn.Message.Data.PreDecHeadVo = JsonConvert.Deserialize<preDecHeadVo>(PortReturn.Message.Data.preDecHeadVo);
//var preDecHeadVo = PortReturn.Message.Data.PreDecHeadVo;
foreach (var head in PortReturn.message) {
var preDecHeadVo = head.data.getdata();
var trueinfo = true;
//if (!string.IsNullOrWhiteSpace(CUSTOMNO)|| !string.IsNullOrWhiteSpace(MBLNO) || !string.IsNullOrWhiteSpace(SeqNo))
//{
// trueinfo = true;
//}
//else
//{
// //解析之后判断是否存在 提单号billNo 监管方式supvModeCdde 这两个字段正确的信息
// if (!string.IsNullOrWhiteSpace(preDecHeadVo.billNo) && !string.IsNullOrWhiteSpace(preDecHeadVo.supvModeCdde))
// {
// if (DecHead_Local.BillNo == preDecHeadVo.billNo && DecHead_Local.TradeMode == preDecHeadVo.supvModeCdde)
// {
// trueinfo = true;
// }
// }
//}
opapplyhead.VESSEL = preDecHeadVo.trafName;
opapplyhead.VOYNO = preDecHeadVo.cusVoyageNo;
if (ies == "E")
{
opapplyhead.PORTDISCHARGE = preDecHeadVo.distinatePortName;
}
if (ies == "I")
{//进口时 应将distinatePortName填入 装货港
opapplyhead.PORTLOAD = preDecHeadVo.distinatePortName;
}
//OPAPPLY.PORTLOAD = preDecHeadVo.despPortCode
if (preDecHeadVo.cusTradeCountry == "CHN")
{
//if (string.IsNullOrEmpty(opapplyhead.ENTERP.Trim()))
opapplyhead.ENTERP = DecHead_Local.TradeName;
}
else
{
//if (string.IsNullOrEmpty(opapplyhead.ENTERP.Trim()))
opapplyhead.ENTERP = preDecHeadVo.consigneeCname;
}
if (string.IsNullOrEmpty(opapplyhead.MBLNO.Trim()))
opapplyhead.MBLNO = preDecHeadVo.billNo;
if (string.IsNullOrEmpty(opapplyhead.CUSTOMNO.Trim()))
opapplyhead.CUSTOMNO = preDecHeadVo.entryId;
//opseaihead.GOODSNAME
opapplyhead.PKGS = Convert.ToInt32(preDecHeadVo.packNo);
opapplyhead.KGS = Convert.ToDecimal(preDecHeadVo.grossWt);
opapplyhead.NETWEIGHT = Convert.ToDecimal(preDecHeadVo.netWt);
opapplyhead.CONTRACTNO = DecHead_Local.ContrNo;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.transMode))
opapplyhead.TRADETERM = preDecHeadVo.transMode;
if (opapplyhead.ENTERP == null || string.IsNullOrEmpty(opapplyhead.ENTERP.Trim()))
opapplyhead.ENTERP = DecHead_Local.TradeName;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.iEDate)) {
if (ies == "E") {
if (string.IsNullOrWhiteSpace(opapplyhead.ETD)) {
opapplyhead.ETD= DateTime.ParseExact(preDecHeadVo.iEDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
}
}
if (ies == "I")
{
if (string.IsNullOrWhiteSpace(opapplyhead.ETA))
{
opapplyhead.ETA = DateTime.ParseExact(preDecHeadVo.iEDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
}
}
}
//20230612 增加逻辑 如果是 preDecHeadVo.AgentStatus='查验通知'
//则增加一条业务状态
//
if (preDecHeadVo.cusDecStatusName == "查验通知") {
opapplyhead.InspectionNotice = "查验通知";
BasicDataRefDAL.OP_STATUSHelper.(opapplyhead.BSNO, username);
}
opapplyhead.CUSTOMDATE = preDecHeadVo.dDate;//报关日期=申报日期
//写入海运进口业务
if (updateseai)
{
if (!string.IsNullOrWhiteSpace(preDecHeadVo.trafName))
opseaihead.VESSEL = preDecHeadVo.trafName;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.cusVoyageNo))
opseaihead.VOYNO = preDecHeadVo.cusVoyageNo;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.iEDate))
opseaihead.ETD = DateTime.ParseExact(preDecHeadVo.iEDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
if (!string.IsNullOrWhiteSpace(preDecHeadVo.distinatePortName))
opseaihead.PORTLOAD = preDecHeadVo.distinatePortName;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.customMasterName))
opseaihead.MaTou = preDecHeadVo.customMasterName;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.consigneeCname))
opseaihead.ENTERP = preDecHeadVo.consigneeCname;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.supvModeCddeName))
opseaihead.TRADETYPE = preDecHeadVo.supvModeCddeName;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.contrNo))
opseaihead.CONTRACTNO = preDecHeadVo.contrNo;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.dDate))
opseaihead.CUSTOMDATE = preDecHeadVo.dDate;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.entryId))
opseaihead.CUSTOMNO = preDecHeadVo.entryId;
//opseaihead.GOODSNAME
if (!string.IsNullOrWhiteSpace(preDecHeadVo.packNo))
opseaihead.PKGS = Convert.ToInt32(preDecHeadVo.packNo);
if (!string.IsNullOrWhiteSpace(preDecHeadVo.wrapTypeName))
opseaihead.KINDPKGS = preDecHeadVo.wrapTypeName;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.grossWt))
opseaihead.KGS = Convert.ToDecimal(preDecHeadVo.grossWt);
if (!string.IsNullOrWhiteSpace(preDecHeadVo.netWt))
opseaihead.NETWEIGHT = Convert.ToDecimal(preDecHeadVo.netWt);
if (!string.IsNullOrWhiteSpace(preDecHeadVo.transMode))
opseaihead.TRADETERM = preDecHeadVo.transMode;
if (!string.IsNullOrWhiteSpace(preDecHeadVo.dDate))
opseaihead.UPDATETIME = preDecHeadVo.dDate;
//opseaihead.CUSTOMDATE=
}
//opapplyhead.RelId
if (trueinfo)
{
if (needupd)
{
preDecHeadVo.setvalue(DecHead_Local);
bll.Update(DecHead_Local);
}
else {
DecHead_Local.BillNo = opapplyhead.MBLNO;
DecHead_Local.TradeMode = opapplyhead.TRADETYPE;
DecHead_Local.GID = Guid.NewGuid().ToString();
DecHead_Local.BSNO = bsno;
preDecHeadVo.setvalue(DecHead_Local);
bll.Add(DecHead_Local);
}
opapplyhead.CUSCIQNO = DecHead_Local.SeqNo;
//!string.IsNullOrWhiteSpace(cnsnTradeScc) ? cnsnTradeScc : rcvgdTradeScc;
//20210709 经营单位改为存储TradeName
//20210803 改为如果经营单位为空 才填
if(string.IsNullOrWhiteSpace(opapplyhead.ENTERP))
opapplyhead.ENTERP = DecHead_Local.TradeName;
//20210708 合同协议号 DecHead.ContrNo 填入 OPAPPLY.CONTRACTNO
opapplyhead.CONTRACTNO = DecHead_Local.ContrNo;
#region 电子文档信息
ReceiptContext receiptContext = new ReceiptContext();
if (head.pdfFile != null)
{
foreach (var pdf in head.pdfFile)
{
Receipt_Doc receipt = receiptContext.ReceiptDocs.FirstOrDefault(o => o.BSNO == bsno && o.URL == pdf.filename);
if (receipt == null)
{
receipt = new Receipt_Doc();
receipt.GID = Guid.NewGuid().ToString();
receipt.BSNO = bsno;
receipt.URL = pdf.filename;
receipt.Driect_URL = pdf.path;
receipt.MODIFIEDUSER = userid;
receipt.MODIFIEDTIME = System.DateTime.Now;
receiptContext.ReceiptDocs.Add(receipt);
}
else
{
receipt.URL = pdf.filename;
receipt.Driect_URL = pdf.path;
receipt.MODIFIEDUSER = userid;
receipt.MODIFIEDTIME = System.DateTime.Now;
}
var _r = receiptContext.SaveChanges();
}
}
#endregion
#region 集装箱信息
var containerlist = cbll.GetModelList("PID='" + DecHead_Local.GID + "'");
var portContainerlist = preDecHeadVo.getpreDecContainerVo();
if (portContainerlist.Count > 0)
{
foreach (var portContainer in portContainerlist)
{
var upd = false;
foreach (var container in containerlist)
{
if (container.ContainerId.Trim() == portContainer.containerNo.Trim())
{
upd = true;
var updcontainer = portContainer.getContainerValue(container);
cbll.Update(updcontainer);
}
}
if (!upd)
{
var updcontainer = new Container();
updcontainer = portContainer.getContainerValue(updcontainer);
updcontainer.GID = Guid.NewGuid().ToString();
updcontainer.PID = DecHead_Local.GID;
cbll.Add(updcontainer);
}
}
//20210628 增加报关业务的箱信息
//20210630 客户又取消此逻辑 部分原因是读入的箱信息的箱型无法对应
//20230515 修改后仍然禁用
/*
CommonDataContext cdc = new CommonDataContext();
//WEIGHKGS称重重量=ContainerWt
//CNTRNO = ContainerId
var ctncode = 0;
var op_ctnList = cdc.OP_CTN.Where(x => x.BSNO == opapplyhead.BSNO).ToList();
foreach (var item in portContainerlist)
{
var needinsert_ctn = true;
if (op_ctnList != null && op_ctnList.Count > 0)
{
if (op_ctnList.Exists(x => x.CNTRNO == item.containerNo))
{
var upditem = op_ctnList.First(x => x.CNTRNO == item.containerNo);
if(item.containerWt!=null)
upditem.WEIGHKGS = decimal.Parse(item.containerWt);
needinsert_ctn = false;
}
}
if (needinsert_ctn)
{
ctncode++;
var insertitem = new op_ctn_md();
var ctnapplycode = new Dictionary<string, string>
{
{ "11", "40GP" },
{ "32", "40HQ" },
{ "12", "40RH" },
{ "22", "20RH" },
{ "21", "20GP" },
{ "31", "20HQ" },
{ "23", "20TK" },
{ "N", "" },
{ "13", "40TK" },
};
string ctnall(string cntnrModeCode) {
if (ctnapplycode.ContainsKey(cntnrModeCode)) {
return ctnapplycode[cntnrModeCode];
}
return "";
}
//11 普通2* 标准箱L
//32 其他2* 标准箱L
//12 冷藏2* 标准箱L
//22 冷藏标准箱S
//21 普通标准箱S
//31 其他标准箱S
//23 罐式标准箱S
//N 非集装箱
//13 罐式2* 标准箱L
insertitem.CTN_ID = Guid.NewGuid().ToString();
insertitem.BSNO = opapplyhead.BSNO;
insertitem.CNTRNO = item.containerNo;
insertitem.WEIGHKGS = (string.IsNullOrWhiteSpace( item.containerWt))?0: decimal.Parse(item.containerWt);
insertitem.vgmconncom = "";
insertitem.CTNNUM = 1;
insertitem.TEU = 2;
insertitem.CTNALL = ctnall(item.cntnrModeCode);
insertitem.CTNCODE= string.Format("{0:d2}", ctncode);
cdc.OP_CTN.Add(insertitem);
}
}
cdc.SaveChangesAsync();
*/
}
containerlist = cbll.GetModelList("PID='" + DecHead_Local.GID + "'");
#endregion
#region 项信息
var declist_List = lbll.GetModelList(0, 99, "PID='" + DecHead_Local.GID + "'", String.Format("{0}", "CONVERT(int, gno)", ""));
var port_decMergeListVoList = preDecHeadVo.getdecMergeListVo();
var goodstr = "";
decimal goodsvalue = 0;
var GoodsList = new List<MsOpApplyDetail>();
int goodnum = 0;
var updDetailList = new List<op_apply_detail_md>();
CommonDataContext cdc = new CommonDataContext();
var currOpApplyDetail = cdc.op_apply_detail.Where(x => x.BSNO == opapplyhead.BSNO).ToList();
if (port_decMergeListVoList.Count > 0)
{
foreach (var port_decMergeListVo in port_decMergeListVoList)
{
var upd = false;
foreach (var declist in declist_List)
{
if (declist.GNo.Trim() == port_decMergeListVo.gNo.Trim())
{
upd = true;
var upddeclist = port_decMergeListVo.getDecListValue(declist);
lbll.Update(upddeclist);
}
}
if (!upd)
{
var upddeclist = new DecList();
upddeclist = port_decMergeListVo.getDecListValue(upddeclist);
upddeclist.GID = Guid.NewGuid().ToString();
upddeclist.PID = DecHead_Local.GID;
lbll.Add(upddeclist);
}
if (updateseai)
{
if (port_decMergeListVo.gName != "")
opseaihead.GOODSNAME = port_decMergeListVo.gName;
if (port_decMergeListVo.cusOriginCountryName != "")
opseaihead.COUNTRYOFORIGIN = port_decMergeListVo.cusOriginCountryName;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declTotal))
goodsvalue = goodsvalue + Convert.ToDecimal(port_decMergeListVo.declTotal);
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declPrice))
opseaihead.UNITPRICE = Convert.ToDecimal(port_decMergeListVo.declPrice);
if (port_decMergeListVo.tradeCurrName != "")
opseaihead.CURRENCY = port_decMergeListVo.tradeCurrName;
goodstr = goodstr + port_decMergeListVo.codeTs + " " + port_decMergeListVo.gModel + " " + port_decMergeListVo.gName + " " + port_decMergeListVo.hsCodeDesc;
}
goodnum = goodnum + 1;
//#原生成业务明细逻辑
/*
var opapplygood = new MsOpApplyDetail();
opapplygood.BsNo = "*";
opapplygood.SerialNo = goodnum;
opapplygood.GoodsName = port_decMergeListVo.gName;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declPrice))
opapplygood.Price = Convert.ToDecimal(port_decMergeListVo.declPrice);
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declTotal))
opapplygood.Total = Convert.ToDecimal(port_decMergeListVo.declTotal);
opapplygood.GOODSMODEL = port_decMergeListVo.gModel;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.gQty))
opapplygood.Pkgs = Convert.ToDecimal(port_decMergeListVo.gQty);
opapplygood.Currency = port_decMergeListVo.tradeCurr;
opapplygood.GoodsCode = port_decMergeListVo.codeTs;
GoodsList.Add(opapplygood);
*/
//
if (currOpApplyDetail == null || currOpApplyDetail.Count == 0)
{
//如果原来没有 则完全使用原有的新增逻辑
var opapplygood = new MsOpApplyDetail();
opapplygood.BsNo = "*";
opapplygood.SerialNo = goodnum;
opapplygood.GoodsName = port_decMergeListVo.gName;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declPrice))
opapplygood.Price = Convert.ToDecimal(port_decMergeListVo.declPrice);
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declTotal))
opapplygood.Total = Convert.ToDecimal(port_decMergeListVo.declTotal);
opapplygood.GOODSMODEL = port_decMergeListVo.gModel;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.gQty))
opapplygood.Pkgs = Convert.ToDecimal(port_decMergeListVo.gQty);
opapplygood.Currency = port_decMergeListVo.tradeCurr;
opapplygood.GoodsCode = port_decMergeListVo.codeTs;
GoodsList.Add(opapplygood);
}
else {
var updrecList = cdc.op_apply_detail.Where(x => x.BSNO == opapplyhead.BSNO && x.SerialNo.ToString() == port_decMergeListVo.gNo).ToList();
if (updrecList != null && updrecList.Count > 0)
{
var updrec = updrecList[0];
updrec.GOODSNAME = port_decMergeListVo.gName;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declPrice))
updrec.PRICE = Convert.ToDecimal(port_decMergeListVo.declPrice);
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declTotal))
updrec.TOTAL = Convert.ToDecimal(port_decMergeListVo.declTotal);
updrec.GOODSMODEL = port_decMergeListVo.gModel;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.gQty))
updrec.PKGS = Convert.ToDecimal(port_decMergeListVo.gQty);
updrec.CURRENCY = port_decMergeListVo.tradeCurr;
updrec.GOODSCODE = port_decMergeListVo.codeTs;
updDetailList.Add(updrec);
}
else {
var opapplygood = new MsOpApplyDetail();
opapplygood.BsNo = "*";
opapplygood.SerialNo = goodnum;
opapplygood.GoodsName = port_decMergeListVo.gName;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declPrice))
opapplygood.Price = Convert.ToDecimal(port_decMergeListVo.declPrice);
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.declTotal))
opapplygood.Total = Convert.ToDecimal(port_decMergeListVo.declTotal);
opapplygood.GOODSMODEL = port_decMergeListVo.gModel;
if (!string.IsNullOrWhiteSpace(port_decMergeListVo.gQty))
opapplygood.Pkgs = Convert.ToDecimal(port_decMergeListVo.gQty);
opapplygood.Currency = port_decMergeListVo.tradeCurr;
opapplygood.GoodsCode = port_decMergeListVo.codeTs;
GoodsList.Add(opapplygood);
}
}
opapplyhead.ARCOUNTRY = port_decMergeListVo.cusOriginCountryName;
}
}
opapplyhead.CARGOVALUE = goodsvalue.ToString();
if (updateseai)
{
opseaihead.IMPORTVALUE = goodsvalue;
opseaihead.REMARK2 = goodstr;
var modb2 = new ModelObjectDB();
modb2.Save(opseaihead);
}
var modb3 = new ModelObjectDB();
modb3.Save(opapplyhead);
MsOpApplyDAL.SaveDetail(opapplyhead, GoodsList, userid);
if (updDetailList != null && updDetailList.Count > 0) {
foreach (var item in updDetailList)
{
cdc.op_apply_detail.AddOrUpdate(item);
}
//删除当前存在 而单一窗口中没有的顺序号的明细
var gnoList = updDetailList.Select(s => s.SerialNo).ToList();
foreach (var item in currOpApplyDetail) {
if (gnoList.Contains(item.SerialNo))
{
}
else {
cdc.op_apply_detail.Remove(item);
}
}
cdc.SaveChanges();
}
var Declist = lbll.GetModelList(0, 99, "PID='" + DecHead_Local.GID + "'", String.Format("{0}", "CONVERT(int, gno)", ""));
var count = lbll.GetRecordCount("PID='" + DecHead_Local.GID + "'");
#endregion
#region 单证信息
var preDecDocVoList = preDecHeadVo.getpreDecDocVo();
var currList= dbll.GetModelList(" PID='"+ DecHead_Local.GID + "' ");
if (preDecDocVoList!=null && preDecDocVoList.Count > 0){
foreach (var item in preDecDocVoList) {
LicenseDocu docitem = new LicenseDocu();
docitem.PID = DecHead_Local.GID;
docitem.GID = Guid.NewGuid().ToString();
//docitem.DocuCode = item.attFmtTypeCode;
docitem.DocuCode_Text = item.attFmtTypeCode;
docitem.CertCode = item.attEdocNo;
if (currList.Exists(x => x.CertCode == docitem.CertCode)) {
continue;
}
dbll.Add(docitem);
}
}
var cusLicenseListVoList = preDecHeadVo.getcusLicenseListVo();
if (cusLicenseListVoList != null && cusLicenseListVoList.Count > 0)
{
foreach (var item in cusLicenseListVoList)
{
LicenseDocu docitem = new LicenseDocu();
docitem.PID = DecHead_Local.GID;
docitem.GID = Guid.NewGuid().ToString();
//docitem.DocuCode = item.attFmtTypeCode;
docitem.DocuCode_Text = item.acmpFormCode;
docitem.CertCode = item.acmpFormNo;
if (currList.Exists(x => x.CertCode == docitem.CertCode))
{
continue;
}
dbll.Add(docitem);
}
}
var docList = dbll.GetModelList(" PID='" + DecHead_Local.GID + "' ");
#endregion
#region 右下角 关联信息
List<DecFreeTx> currDFTList = tbll.GetModelList(" PID='" + DecHead_Local.GID + "' ");
var tmodel = new DecFreeTx();
if (currDFTList != null && currDFTList.Count() > 0)
{
tmodel = currDFTList[0];
tmodel.RelId = preDecHeadVo.relativeId;//关联报关单
tmodel.RelManNo = preDecHeadVo.relmanNo;//关联备案
tbll.Update(tmodel);
}
else {
tmodel.GID = Guid.NewGuid().ToString();
tmodel.PID = DecHead_Local.GID;
tmodel.RelId = preDecHeadVo.relativeId;//关联报关单
tmodel.RelManNo = preDecHeadVo.relmanNo;//关联备案
tbll.Add(tmodel);
}
#endregion
return Json(new { DecHead_Local, containerlist, docList, total = count, rows = Declist });
}
}
if (updateseai)
{
var modb2 = new ModelObjectDB();
modb2.Save(opseaihead);
}
var modb = new ModelObjectDB();
modb.Save(opapplyhead);
//如无 则不进行操作
//如有 则看是需要更新还是新增
return Json(new { PortReturn });
}
/// <summary>
/// 原逻辑
/// </summary>
/// <param name="bsno"></param>
/// <param name="withdoc"></param>
/// <returns></returns>
public JsonResult GetDecHead_Port(string bsno, bool withdoc = true)
{
var username = Session["SHOWNAME"].ToString();
var userid = Session["USERID"].ToString();
return GetDecHead_Port(bsno, userid, username, withdoc);
}
public JsonResult GetDecHead_Port_NoDoc(string bsno)
{
var username = Session["SHOWNAME"].ToString();
var userid = Session["USERID"].ToString();
return GetDecHead_Port(bsno, userid, username, false);
}
public JsonResult GetDecHead_Port_JGWL(string bsno,string userid, string username ,bool withdoc = true)
{
//var username = Session["SHOWNAME"].ToString();
//var userid = Session["USERID"].ToString();
if (ConfigurationManager.AppSettings["COMPANYCODE"] != null)
{
if (ConfigurationManager.AppSettings["COMPANYCODE"] == "JGWL")
{
return GetDecHead_Port(bsno, userid, username, withdoc);
}
}
return Json(null);
}
public class timeclass {
public string starttime;
public string endtime;
public timeclass(string starttime, string endtime) {
this.starttime= starttime;
this.endtime = endtime;
}
}
/// <summary>
/// 批量读取单一窗口信息 依据时间段
/// </summary>
/// <param name="bsno"></param>
/// <returns></returns>
public JsonResult GetDecHead_Port_Time(string endtime = "", string starttime = "", string ies="E"
, string cdnType = "0", string clearance="0", string isSecondApply = "0", string withPdf = "0")///
{
if (endtime == "")
{
endtime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
if (starttime == "")
{
starttime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
}
}
else
{
if (starttime == "")
{
starttime = Convert.ToDateTime(endtime).AddDays(-1).ToString("yyyy-MM-dd");
}
}
List<timeclass> lt = new List<timeclass>();
starttime = Convert.ToDateTime(starttime).AddDays(0).ToString("yyyy-MM-dd");
var CUSTOMDATE = starttime;
endtime = Convert.ToDateTime(endtime).AddDays(0).ToString("yyyy-MM-dd");
if (Convert.ToDateTime(starttime).AddDays(2) < Convert.ToDateTime(endtime)) {
string Message = "时间跨度不能超过3天";
return Json(new { Message });
}
//如果日期起止不相同 则将其改为一个日期列表(每天)
/*
if (Convert.ToDateTime(starttime) != Convert.ToDateTime(endtime))
{
while (Convert.ToDateTime( starttime) <= Convert.ToDateTime(endtime))
{
var tc = new timeclass(starttime, starttime);
starttime = Convert.ToDateTime(starttime).AddDays(1).ToString("yyyy-MM-dd");
lt.Add(tc);
}
}
else {
lt.Add(new timeclass(starttime, endtime));
}
if (lt.Count > 0)
{
}
else {
return Json(new {});
}*/
//var ies = "E";
//var clearance = "0";
SingleCondition sc = new SingleCondition(starttime,endtime,ies, cdnType, clearance,isSecondApply,withPdf,Session["USERID"].ToString(), Session["SHOWNAME"].ToString(), Session["COMPANYID"].ToString());
var sc1 = sc.copy();
sc1.change(starttime,endtime, ies, clearance);
readDAL_2.getPortInfo_thread(sc1);
//////////20201019 改为前台传入查询条件
//foreach (var tc in lt)
//{
// var sc1 = sc.copy();
// sc1.change(tc.starttime,tc.endtime,"E", "0");
// readDAL.getPortInfo_thread(sc1);
// var sc2 = sc.copy();
// sc2.change(tc.starttime, tc.endtime, "E", "1");
// readDAL.getPortInfo_thread(sc2);
// var sc3 = sc.copy();
// sc3.change(tc.starttime, tc.endtime, "I", "0");
// readDAL.getPortInfo_thread(sc3);
// var sc4 = sc.copy();
// sc4.change(tc.starttime, tc.endtime, "I", "1");
// readDAL.getPortInfo_thread(sc4);
//}
//////
//Dealrtn(PortReturn1);
//Dealrtn(PortReturn2);
//readDAL.Dealrtn(PortReturn3,Session["USERID"].ToString(),Session["SHOWNAME"].ToString(),Session["COMPANYID"].ToString());
//Dealrtn(PortReturn4);
return Json(new { });
}
public DecHead_WebModel getrtn(string starttime, string endtime, string ies, string clearance) {
var rtn = getPortStr(starttime, endtime, "", "", ies, clearance);
var _status = Newtonsoft.Json.JsonConvert.DeserializeObject<DecHead_status>(rtn).status;
var result = new DecHead_WebModel();
if (_status == "1")
{
result = Newtonsoft.Json.JsonConvert.DeserializeObject<DecHead_WebModel>(rtn);
}
return result;
}
public void Dealrtn(DecHead_WebModel PortReturn)
{
foreach (var head in PortReturn.message)
{
var preDecHeadVo = head.data.getdata();
if (string.IsNullOrWhiteSpace(preDecHeadVo.entryId)) {
continue;//没有报关单号的不做处理
}
var currCUSTOMNO = preDecHeadVo.entryId;
//本地是否存在该业务 以报关单号为准
//根据报关单号寻找报关业务 看是否存在
var OPAPPLY = MsOpApplyDAL.GetData(" CUSTOMNO='" + currCUSTOMNO.Trim() + "'");
var needinsert = false;//需要新建 还是更新信息
if (string.IsNullOrWhiteSpace(OPAPPLY.CUSTOMNO)) {
needinsert = true;
}
var bsno = "";
var decheadGID = "";
if (needinsert)
{
//新建 op_apply
saveinfo("insert", head, OPAPPLY);
}
else
{
saveinfo("edit", head, OPAPPLY);
}
}
}
public void saveinfo(string dealtype, MessageModel head, MsOpApply OPAPPLY) {
if (dealtype == "insert")
{
OPAPPLY.DbOperationType = DbOperationType.DbotIns;
OPAPPLY.ModelUIStatus = "I";
OPAPPLY.BSNO = Guid.NewGuid().ToString();
OPAPPLY.MASTERNO = OPAPPLY.BSNO;
OPAPPLY.CUSTNO = MsSysBillNoSetDAL.GetNewNo("报关业务", "委托编号", Session["COMPANYID"].ToString(), System.DateTime.Now.ToString("yyyy-MM-dd"));
}
else {
OPAPPLY.DbOperationType = DbOperationType.DbotUpd;
OPAPPLY.ModelUIStatus = "E";
}
var bsno = OPAPPLY.BSNO;
var preDecHeadVo = head.data.getdata();
OPAPPLY.CUSTOMNO = preDecHeadVo.entryId;
//根据报关单号 结尾0出口 结尾1进口
OPAPPLY.setbstype();
OPAPPLY.BSSTATUS = false;
OPAPPLY.FEESTATUS = false;
OPAPPLY.BSDATE = Convert.ToDateTime( preDecHeadVo.dDate);
OPAPPLY.CUSTOMDATE = preDecHeadVo.dDate;//报关日期=申报日期
OPAPPLY.OPDATE = preDecHeadVo.dDate;//业务日期=申报日期
OPAPPLY.MBLNO = preDecHeadVo.billNo;
OPAPPLY.INPUTBY = Session["SHOWNAME"].ToString();
OPAPPLY.CORPID = Session["COMPANYID"].ToString();
OPAPPLY.TRADETYPE = preDecHeadVo.supvModeCddeName;
var modb = new ModelObjectDB();
var tempresult = modb.Save(OPAPPLY);
var dealtype_detail = "edit";
var DecHead_Local = bll.GetModelList("BSNO='" + OPAPPLY.BSNO + "'").FirstOrDefault();
if (DecHead_Local == null)
{
DecHead_Local = new DecHead();
dealtype_detail = "insert";
}
if (dealtype_detail == "insert")
{
DecHead_Local.GID = Guid.NewGuid().ToString();
DecHead_Local.BSNO = OPAPPLY.BSNO;
preDecHeadVo.setvalue(DecHead_Local);
bll.Add(DecHead_Local);
}
else
{
preDecHeadVo.setvalue(DecHead_Local);
bll.Update(DecHead_Local);
}
#region 电子文档信息
ReceiptContext receiptContext = new ReceiptContext();
foreach (var pdf in head.pdfFile)
{
Receipt_Doc receipt = receiptContext.ReceiptDocs.FirstOrDefault(o => o.BSNO == bsno && o.URL == pdf.filename);
if (receipt == null)
{
receipt = new Receipt_Doc();
receipt.GID = Guid.NewGuid().ToString();
receipt.BSNO = bsno;
receipt.URL = pdf.filename;
receipt.Driect_URL = pdf.path;
receipt.MODIFIEDUSER = Session["USERID"].ToString();
receipt.MODIFIEDTIME = System.DateTime.Now;
receiptContext.ReceiptDocs.Add(receipt);
}
else
{
receipt.URL = pdf.filename;
receipt.Driect_URL = pdf.path;
receipt.MODIFIEDUSER = Session["USERID"].ToString();
receipt.MODIFIEDTIME = System.DateTime.Now;
}
var _r = receiptContext.SaveChanges();
}
#endregion
#region 集装箱信息
var containerlist = cbll.GetModelList("PID='" + DecHead_Local.GID + "'");
var portContainerlist = preDecHeadVo.getpreDecContainerVo();
if (portContainerlist.Count > 0)
foreach (var portContainer in portContainerlist)
{
var upd = false;
foreach (var container in containerlist)
{
if (container.ContainerId.Trim() == portContainer.containerNo.Trim())
{
upd = true;
var updcontainer = portContainer.getContainerValue(container);
cbll.Update(updcontainer);
}
}
if (!upd)
{
var updcontainer = new Container();
updcontainer = portContainer.getContainerValue(updcontainer);
updcontainer.GID = Guid.NewGuid().ToString();
updcontainer.PID = DecHead_Local.GID;
cbll.Add(updcontainer);
}
}
containerlist = cbll.GetModelList("PID='" + DecHead_Local.GID + "'");
#endregion
#region 项信息
var declist_List = lbll.GetModelList(0, 99, "PID='" + DecHead_Local.GID + "'", String.Format("{0}", "CONVERT(int, gno)", ""));
var port_decMergeListVoList = preDecHeadVo.getdecMergeListVo();
if (port_decMergeListVoList.Count > 0)
foreach (var port_decMergeListVo in port_decMergeListVoList)
{
var upd = false;
foreach (var declist in declist_List)
{
if (declist.GNo.Trim() == port_decMergeListVo.gNo.Trim())
{
upd = true;
var upddeclist = port_decMergeListVo.getDecListValue(declist);
lbll.Update(upddeclist);
}
}
if (!upd)
{
var upddeclist = new DecList();
upddeclist = port_decMergeListVo.getDecListValue(upddeclist);
upddeclist.GID = Guid.NewGuid().ToString();
upddeclist.PID = DecHead_Local.GID;
lbll.Add(upddeclist);
}
}
var Declist = lbll.GetModelList(0, 99, "PID='" + DecHead_Local.GID + "'", String.Format("{0}", "CONVERT(int, gno)", ""));
var count = lbll.GetRecordCount("PID='" + DecHead_Local.GID + "'");
#endregion
}
}
#endregion
#endregion
}