DESKTOP-DIHMM3I\22375 2 years ago
parent
commit
c805c64536
  1. 1
      ICSSoft.ERP.WebAPI/ICSSoft.DataProject/ICSSoft.DataProject.csproj
  2. 169
      ICSSoft.ERP.WebAPI/ICSSoft.DataProject/ManufactureOrderPick.cs
  3. 74
      ICSSoft.ERP.WebAPI/ICSSoft.ERP.WebAPI/Controllers/ValuesController.cs
  4. 27
      ICSSoft.ERP.WebAPI/ICSSoft.Entity/ICSManufactureOrderPick.cs
  5. 1
      ICSSoft.ERP.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj

1
ICSSoft.ERP.WebAPI/ICSSoft.DataProject/ICSSoft.DataProject.csproj

@ -69,6 +69,7 @@
<Compile Include="DisassemblyDoc.cs" />
<Compile Include="ISComplete.cs" />
<Compile Include="JSON.cs" />
<Compile Include="ManufactureOrderPick.cs" />
<Compile Include="MOIssueDocApprove.cs" />
<Compile Include="OtherInDoc.cs" />
<Compile Include="OtherOutDoc.cs" />

169
ICSSoft.ERP.WebAPI/ICSSoft.DataProject/ManufactureOrderPick.cs

@ -0,0 +1,169 @@
using ICSSoft.Common;
using ICSSoft.Entity;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSSoft.DataProject
{
/// <summary>
/// 生产订单备料表
/// </summary>
public class ManufactureOrderPick
{
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static string connString = System.Configuration.ConfigurationManager.AppSettings["ERPConnStr"];
private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
/// <summary>
/// 创建生产订单备料表
/// </summary>
/// <param name="infos"></param>
/// <returns></returns>
public string CreateManufactureOrderPick(List<ICSManufactureOrderPick> Bills)
{
string msg = "";
string connS = "";
if (Bills.Count <= 0)
{
throw new Exception("传送数据为空!");
}
string res = string.Empty;
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
List<string> result = Bills.Select(t => t.WorkPoint).Distinct().ToList();
foreach (string WorkPoint in result)
{
try
{
connS = string.Format(connString, WorkPoint);
conn = new System.Data.SqlClient.SqlConnection(connS);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
var list = Bills.Where(a => a.WorkPoint == WorkPoint);
foreach (ICSManufactureOrderPick head in list)
{
ICSUserInfo userInfo = new ICSUserInfo();
userInfo = DBHelper.GetPersonInfo(head.User, cmd);
string[] ss = head.WorkPoint.Split('_');
ERPDB = ss[1];
Dictionary<string, int> dic;
string sql = "";
#region 备料表
foreach (ICSManufactureOrderPicks body in head.details)
{
dic = DBHelper.GetAllCode(ERPDB, "mom_moallocate", "1", head.WorkPoint);
int iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
int iChildId = Convert.ToInt32(dic["iChildId"].ToString());
#region 生产备料表
sql = @"SELECT '{6}' AS AllocateId,d.MoDId,'{2}' AS SortSeq,ISNULL(a.OpSeq, '0000') AS OpSeq,ISNULL(a.ComponentId,c.PartId) AS ComponentId,
ISNULL(a.FVFlag,'1') AS FVFlag,'{3}' AS BaseQtyN,'{4}' AS BaseQtyD,'0' AS ParentScrap,ISNULL(a.CompScrap,'0') AS CompScrap,
'{5}' AS Qty,'0' AS IssQty,'0' AS DeclaredQty, GETDATE() AS StartDemDate, GETDATE() AS EndDemDate,
'{7}' AS WhCode,NULL AS LotNo,'{8}' AS WIPType,ISNULL(a.ByproductFlag,'0') AS ByproductFlag,'0' AS QcFlag,
'0' AS Offset,ISNULL(a.Free1,'') AS Free1,ISNULL(a.Free2,'') AS Free2,ISNULL(a.Free3,'') AS Free3
,ISNULL(a.Free4,'') AS Free4,ISNULL(a.Free5,'') AS Free5,ISNULL(a.Free6,'') AS Free6,ISNULL(a.Free7,'') AS Free7,ISNULL(a.Free8,'') AS Free8
,ISNULL(a.Free9,'') AS Free9,ISNULL(a.Free10,'') AS Free10,ISNULL(a.OpComponentId,'0') AS OpComponentId,a.Define22,a.Define23,
a.Define24,a.Define25,a.Define26,a.Define27,a.Define28,
a.Define29,a.Define30,a.Define31,a.Define32,a.Define33,
a.Define34,a.Define35,a.Define36,a.Define37,'0' AS ReplenishQty,
a.Remark,'0' AS TransQty,ISNULL(a.ProductType,'1') AS ProductType,'0' AS SoType,NULL AS SoDId,
NULL AS SoCode,NULL AS SoSeq,NULL AS DemandCode,'0' AS QmFlag,'0' AS OrgQty,
'0' AS OrgAuxQty,NULL AS CostItemCode,NULL AS CostItemName,'0' AS RequisitionFlag,'0' AS RequisitionQty,
'0' AS RequisitionIssQty,'0' AS CostWIPRel,NULL AS MoallocateSubId,NULL AS cSubSysBarCode,'0' AS PickingQty,
'0' AS PickingAuxQty,'0' AS UpperMoQty,'0' AS InvAlloeFlag,NULL AS FactoryCode
INTO #TempBOMP
FROM mom_orderdetail d
INNER JOIN bas_part p on d.InvCode = p.InvCode
LEFT JOIN bom_parent q on q.ParentId = p.PartId
LEFT JOIN bom_bom b ON q.BomId=b.BomId AND a.VersionEndDate>=CONVERT(VARCHAR(10),GETDATE(),23)
--
INNER JOIN bas_part c ON c.InvCode='{1}'
LEFT JOIN bom_opcomponent a ON a.ComponentId = c.PartId AND a.BomId=b.BomId
LEFT JOIN bom_opcomponentopt e ON a.OptionsId=e.OptionsId
WHERE d.MoDId='{0}'
ORDER BY d.MoDId";
sql = string.Format(sql, head.DetailID, body.InvCode, body.Sequence, body.BaseQtyN, body.BaseQtyD, body.Quantity, iChildId, body.WHCode, body.SupplyType);
sql += @" INSERT INTO mom_moallocate (AllocateId,MoDId,SortSeq,OpSeq,ComponentId,
FVFlag,BaseQtyN,BaseQtyD,ParentScrap,CompScrap,
Qty,IssQty,DeclaredQty,StartDemDate,EndDemDate,
WhCode,LotNo,WIPType,ByproductFlag,QcFlag,
Offset,InvCode,Free1,Free2,Free3,
Free4,Free5,Free6,Free7,Free8,
Free9,Free10,OpComponentId,Define22,Define23,
Define24,Define25,Define26,Define27,Define28,
Define29,Define30,Define31,Define32,Define33,
Define34,Define35,Define36,Define37,ReplenishQty,
Remark,TransQty,ProductType,SoType,SoDId,
SoCode,SoSeq,DemandCode,QmFlag,OrgQty,
OrgAuxQty,CostItemCode,CostItemName,RequisitionFlag,RequisitionQty,
RequisitionIssQty,CostWIPRel,cSubSysBarCode,PickingQty,
PickingAuxQty,UpperMoQty,InvAlloeFlag,FactoryCode)
SELECT AllocateId,MoDId,SortSeq,OpSeq,ComponentId,
FVFlag,BaseQtyN,BaseQtyD,ParentScrap,CompScrap,
Qty,IssQty,DeclaredQty,StartDemDate,EndDemDate,
WhCode,LotNo,WIPType,ByproductFlag,QcFlag,
Offset,InvCode,Free1,Free2,Free3,
Free4,Free5,Free6,Free7,Free8,
Free9,Free10,OpComponentId,Define22,Define23,
Define24,Define25,Define26,Define27,Define28,
Define29,Define30,Define31,Define32,Define33,
Define34,Define35,Define36,Define37,ReplenishQty,
Remark,TransQty,ProductType,SoType,SoDId,
SoCode,SoSeq,DemandCode,QmFlag,OrgQty,
OrgAuxQty,CostItemCode,CostItemName,RequisitionFlag,RequisitionQty,
RequisitionIssQty,CostWIPRel,cSubSysBarCode,PickingQty,
PickingAuxQty,UpperMoQty,InvAlloeFlag,FactoryCode
FROM #TempMOAll";
sql += @" DROP TABLE #TempMOAll" + iFatherId + Environment.NewLine;
cmd.CommandText = sql;
try
{
int count = cmd.ExecuteNonQuery();
if (count <= 0)
{
throw new Exception("生成生产订单备料表失败,受影响行数<=0;");
}
}
catch (Exception ex)
{
log.Error("生成生产订单备料表失败!异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
throw new Exception("生成生产订单备料表失败!异常:" + ex.Message + ";SQL:\r\n" + sql, ex);
}
#endregion
}
#endregion
}
cmd.Transaction.Commit();
}
catch (Exception ex)
{
cmd.Transaction.Rollback();
log.Error(ex.Message);
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Dispose();
}
}
return msg;
}
}
}

74
ICSSoft.ERP.WebAPI/ICSSoft.ERP.WebAPI/Controllers/ValuesController.cs

@ -2222,7 +2222,81 @@ namespace ICSSoft.WebAPI.Controllers
}
#endregion
#region 生产订单备料表
/// <summary>
/// 更新生产订单备料表
/// </summary>
/// <param name="JsonData"></param>
/// <returns></returns>
[Route("api/ManufactureOrderPick/Create")]
[HttpPost]
public HttpResponseMessage CreateManufactureOrderPick([FromBody]object JsonData)
{
log.Info("接口:api/ManufactureOrderPick/Create");
log.Info("创建生产订单备料表传入值:" + JsonData);
HttpResponseMessage result = new HttpResponseMessage();
Result res = new Result();
string str = string.Empty;
try
{
if (JsonData != null && !string.IsNullOrWhiteSpace(JsonData.ToString()) && JsonData.ToString() != "[]")
{
try
{
List<ICSManufactureOrderPick> infos = new List<ICSManufactureOrderPick>();
try
{
infos = JsonConvert.DeserializeObject<List<ICSManufactureOrderPick>>(JsonData.ToString());
}
catch (Exception ex)
{
log.Error("转换失败:" + ex.ToString());
res.Success = false;
res.Message = "JSON格式不正确!";
throw new Exception(res.Message);
}
ManufactureOrderPick action = new ManufactureOrderPick();
string resultStr = action.CreateManufactureOrderPick(infos);
if (!string.IsNullOrWhiteSpace(resultStr))
{
res.Success = true;
res.Message = "接口调用成功!";
res.Data = resultStr;
}
else
{
res.Success = false;
res.Data = resultStr;
}
}
catch (Exception ex)
{
log.Error("调用后台失败:" + ex.ToString());
res.Success = false;
res.Message = ex.Message;
}
}
else
{
res.Success = false;
res.Message = "请传入参数";
}
}
catch (Exception ex)
{
log.Error("参数检验失败:" + ex.ToString());
res.Success = false;
res.Message = ex.Message;
}
finally
{
str = JsonConvert.SerializeObject(res);
result.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json");
}
log.Debug("创建生产订单备料表返回值:" + str);
return result;
}
#endregion
#region 领料申请单
/// <summary>

27
ICSSoft.ERP.WebAPI/ICSSoft.Entity/ICSManufactureOrderPick.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICSSoft.Entity
{
public class ICSManufactureOrderPick
{
public string DetailID;
public string User;
public DateTime MTime;
public string WorkPoint;//站点
public List<ICSManufactureOrderPicks> details = new List<ICSManufactureOrderPicks>();
}
public class ICSManufactureOrderPicks
{
public int Sequence;
public string InvCode;
public decimal Quantity;
public decimal Amount;
public string WHCode;
public string SupplyType;
public decimal BaseQtyN;
public decimal BaseQtyD;
}
}

1
ICSSoft.ERP.WebAPI/ICSSoft.Entity/ICSSoft.Entity.csproj

@ -57,6 +57,7 @@
<Compile Include="ICSBrrowDoc.cs" />
<Compile Include="ICSDeliveryNotice.cs" />
<Compile Include="ICSDisassemblyDoc.cs" />
<Compile Include="ICSManufactureOrderPick.cs" />
<Compile Include="ICSManufactureOrder.cs" />
<Compile Include="ICSManufactureReceiveDoc.cs" />
<Compile Include="ICSMaterialAppVouch.cs" />

Loading…
Cancel
Save