Files
8357WMS/HHWMS.Web/Areas/XWMS/Controllers/XWMSSOHController.cs
T
2023-12-24 17:58:43 +08:00

126 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using HHWMS.Web.Models;
using MESTOWMSService;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ServiceReference1;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
namespace HHWMS.Web.Controllers;
[Area("xwms")]
[ActionDescription("销售订单列表")]
public class XWMSSOHController : BaseController
{
public XWMSSOHController()
{
}
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
return PartialView("Index");
}
[ActionDescription("Sys.Search")]
public ActionResult Search(string address, string billno, string cust, string materialcode)
{
var sql = @"select * from QREQ3.XWMSSOH where 1=1";
if (!string.IsNullOrEmpty(address))
{
sql += $" and SALFCY_0 = '{address}'";
}
if (!string.IsNullOrEmpty(billno))
{
sql += $" and SOHNUM_0 like '%{billno}%'";
}
if (!string.IsNullOrEmpty(cust))
{
sql += $" and BPCNAM_0 like '%{cust}%'";
}
if (!string.IsNullOrEmpty(materialcode))
{
sql += $"and ITMREF_0 like '%{materialcode}%'";
}
var data = OracleHelper.GetDataSet(sql).Tables[0];
var list = data.AsEnumerable().Select
(x => new
{
SALFCY_0 = x.Field<string>("SALFCY_0"),
ORDDAT_0 = x.Field<DateTime>("ORDDAT_0").ToShortDateString(),
BPCORD_0 = x.Field<string>("BPCORD_0"),
BPCNAM_0 = x.Field<string>("BPCNAM_0"),
SOHNUM_0 = x.Field<string>("SOHNUM_0"),
SOPLIN_0 = x.Field<Int64>("SOPLIN_0"),
ITMREF_0 = x.Field<string>("ITMREF_0"),
ITMDES1_0 = x.Field<string>("ITMDES1_0"),
ITMDES2_0 = x.Field<string>("ITMDES2_0"),
ITMDES3_0 = x.Field<string>("ITMDES3_0"),
YITMDES4_0 = x.Field<string>("YITMDES4_0"),
QTY_0 = x.Field<decimal>("QTY_0"),
NODLQTY_0 = x.Field<decimal>("NODLQTY_0"),
THISQTYSTU = "",
STU_0 = x.Field<string>("STU_0"),
BPAADD_0 = x.Field<string>("BPAADD_0")
}
).ToList();
return JsonMore(list);
}
#endregion Search
[HttpPost]
[FixConnection(CsName = "hangyong")]
public ActionResult Create(List<XWMSSOH> data)
{
var _unitwork = new UnitWork(Wtm);
var shipment = new ShipmentHeader2();
shipment.Code = _unitwork.GetSerialNumber("XSC");
shipment.Type = "XSC";
shipment.ShipTo = data.FirstOrDefault().BPCORD_0;
shipment.FirstStatus = 0;
shipment.AppointmentTime = data.FirstOrDefault().ORDDAT_0;
shipment.UserDef1 = $"{data.FirstOrDefault().SALFCY_0} {data.FirstOrDefault().BPAADD_0}";
_unitwork.Add(shipment);
var detailList = new List<ShipmentDetail2>();
foreach (var item in data)
{
var detail = new ShipmentDetail2();
detail.ZoneCode = "L";
detail.ShipmentId = shipment.ID;
detail.ShipmentCode = shipment.Code;
detail.SourceCode = item.SOHNUM_0;
detail.SourceLine = item.SOPLIN_0.ToString();
detail.MaterialCode = item.ITMREF_0;
detail.MaterialName = item.ITMDES1_0;
detail.Lot = item.ITMDES2_0;
detail.Qty = item.THISQTYSTU;
detail.Unit = item.STU_0;
//detail.PurchasQty = item.THISQTYUOM;
//detail.PurchasUnits = item.UOM_0;
//detail.InventoryStatus = item.STA_0;
//detail.Batch = _unitwork.GetSerialNumber("HYB", 5).Remove(3, 2);
detail.Status = 0;
detail.CreateTime = DateTime.Now;
detailList.Add(detail);
}
_unitwork.BatchAdd(detailList.ToArray());
return JsonMore(null);
}
}