|  |  |  | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using Newtonsoft.Json.Linq; | 
|---|
|  |  |  | using Pub_Class; | 
|---|
|  |  |  | using SyntacticSugar.constant; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | 
|---|
|  |  |  | long HMainInterID = 0; | 
|---|
|  |  |  | HMainInterID = list[0].HMainInterID; | 
|---|
|  |  |  | string eventType = list[0].eventType; | 
|---|
|  |  |  | string HDate = list[0].HDate; | 
|---|
|  |  |  | string BillType = "3791"; | 
|---|
|  |  |  | string HBillSubType = "3791"; | 
|---|
|  |  |  | long HInterID = list[0].HInterID;//递入type得到的单据ID | 
|---|
|  |  |  | 
|---|
|  |  |  | double HLossQty = list[0].HLossQty;//遗失数量 | 
|---|
|  |  |  | double HBackWorkByMaterQty = list[0].HBackWorkByMaterQty;//遗失数量 | 
|---|
|  |  |  | int HMouldID = list[0].HMouldID;//模具id | 
|---|
|  |  |  |  | 
|---|
|  |  |  | double HMachineWorkTimes = list[0].HMachineWorkTimes;//设备工时 | 
|---|
|  |  |  | LogService.Write($"1.字段赋值,用时" + sw.Elapsed ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //单据完整性判断 | 
|---|
|  |  |  | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为乔一 | 
|---|
|  |  |  | if(oSystemParameter.omodel.WMS_CampanyName == "乔一") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断客户不为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName != "龙山汽配" && oSystemParameter.omodel.WMS_CampanyName != "瑞与祺") //系统参数 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName != "龙山汽配" && oSystemParameter.omodel.WMS_CampanyName != "瑞与祺" && oSystemParameter.omodel.WMS_CampanyName != "添康科技") //系统参数 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (HSourceID == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" + | 
|---|
|  |  |  | ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" + | 
|---|
|  |  |  | ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HWasterQty_Work,HWasterQty_Mater,HBackWorkQty,HShiftsID" + | 
|---|
|  |  |  | ",HToCheckQty,HLossQty,HBackWorkByMaterQty,HMouldID" + | 
|---|
|  |  |  | ",HToCheckQty,HLossQty,HBackWorkByMaterQty,HMouldID,HMachineWorkTimes " + | 
|---|
|  |  |  | ") " + | 
|---|
|  |  |  | " values('" + BillType + "','" + (OperationType == "5" ? "SUB" : HBillSubType)  + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + | 
|---|
|  |  |  | " values('" + BillType + "','" + (OperationType == "5" ? "SUB" : HBillSubType)  + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",'"+ HDate + "','" + HMaker + "',getdate(),'" + HMouldNum + "'" + | 
|---|
|  |  |  | "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL + | 
|---|
|  |  |  | "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + | 
|---|
|  |  |  | ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID + | 
|---|
|  |  |  | 
|---|
|  |  |  | "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + | 
|---|
|  |  |  | "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID + | 
|---|
|  |  |  | "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + "," + HWasterQty_Work + "," + HWasterQty_Mater + "," + HBackWorkQty + | 
|---|
|  |  |  | "," + HShiftsID + "," + HToCheckQty + "," + HLossQty + ","+ HBackWorkByMaterQty + "," + HMouldID + ") "); | 
|---|
|  |  |  | "," + HShiftsID + "," + HToCheckQty + "," + HLossQty + ","+ HBackWorkByMaterQty + "," + HMouldID + ",'" + HMachineWorkTimes + "') "); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LogService.Write($"4.新增结束,用时" + sw.Elapsed); | 
|---|
|  |  |  | LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工序出站单据:" + HBillNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HSourceID4=" + HSourceID4 + | 
|---|
|  |  |  | ",HSourceID5=" + HSourceID5 + | 
|---|
|  |  |  | ",HPayProcID=" + HPayProcID + | 
|---|
|  |  |  | ",HGroupID=" + HGroupID + | 
|---|
|  |  |  | ",HWorkTimes=" + HWorkTimes + | 
|---|
|  |  |  | ",HSaveBillFlag=0 " + | 
|---|
|  |  |  | ",HBadCount=" + HBadCount + | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HShiftsID=" + HShiftsID + | 
|---|
|  |  |  | ",HBackWorkByMaterQty=" + HBackWorkByMaterQty + | 
|---|
|  |  |  | ",HMouldID=" + HMouldID + | 
|---|
|  |  |  | ",HMachineWorkTimes=" + HMachineWorkTimes + | 
|---|
|  |  |  | " where HInterID=" + HInterID); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改工序出站单据:" + HBillNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | string sReturn = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref sReturn) == true) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (oSystemParameter.omodel.MES_StationOutBill_AutoCheck == "Y") //系统参数  自动审核 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | object objResult = set_CheckBill(HInterID.ToString(), user, HBillSubType); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (oSystemParameter.omodel.MES_StationOutBill_SaveAutoAddnew == "Y") //系统参数  页面保存自动变成新增状态 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.Verify = "Y"; | 
|---|
|  |  |  | 
|---|
|  |  |  | sw.Stop();//结束计时 | 
|---|
|  |  |  | LogService.Write($"11.参数查询结束,新增结束,用时" + sw.Elapsed); | 
|---|
|  |  |  | LogService.Write("END--出站单据保存结束,出站单号:" + HBillNo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //测试语句=========================================================================================================== | 
|---|
|  |  |  | string msg_str = ""; | 
|---|
|  |  |  | string sql_str = "select a.HQty HQty_Main,b.HQty HQty_Sub " + | 
|---|
|  |  |  | "from Sc_ProcessExchangeBillMain as a " + | 
|---|
|  |  |  | "inner join Sc_ProcessExchangeBillSub as b on a.HInterID = b.HInterID " + | 
|---|
|  |  |  | "where a.HInterID = " + HProcExchInterID; | 
|---|
|  |  |  | DataSet ds_str = oCN.RunProcReturn(sql_str, "Sc_ProcessExchangeBillMain"); | 
|---|
|  |  |  | if (ds_str.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | msg_str = "HQty_Main:" + ds_str.Tables[0].Rows[0]["HQty_Main"].ToString() + ";HQty_Sub:"; | 
|---|
|  |  |  | for (int j = 0; j < ds_str.Tables[0].Rows.Count; j++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | msg_str += ds_str.Tables[0].Rows[j]["HQty_Sub"].ToString() + ","; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改工序出站单据:" + HBillNo + "[工序流转卡号:" + HProcExchBillNo + "]" + msg_str + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','新增或修改单据'", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | //============================================================================================================== | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "新增单据成功!"; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sWhere = sWhere.Replace("'", "''"); | 
|---|
|  |  |  | //sWhere = sWhere.Replace("'", "''"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 保存生成白标 | 
|---|
|  |  |  | public class WhiteLabelGeneration { | 
|---|
|  |  |  | public  string ProjectNo { get; set; } | 
|---|
|  |  |  | public  string OrderingCode { get; set; } | 
|---|
|  |  |  | public  string DrawVersionNumber { get; set; } | 
|---|
|  |  |  | public  string CustomerOrderNumber { get; set; } | 
|---|
|  |  |  | public  string WaybillNumber { get; set; } | 
|---|
|  |  |  | public  string HRemark { get; set; } | 
|---|
|  |  |  | public  string HBarCode_Pack { get; set; } | 
|---|
|  |  |  | public  string HBillType { get; set; } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | [Route("Cj_StationOutBill_Detail/MES_WhiteLabelGeneration")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object MES_WhiteLabelGeneration([FromBody] JObject oMain) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var _value = oMain["oMain"].ToString(); | 
|---|
|  |  |  | string msg1 = _value.ToString(); | 
|---|
|  |  |  | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | string msg2 = sArray[0].ToString(); //主表数据 | 
|---|
|  |  |  | WhiteLabelGeneration Main = Newtonsoft.Json.JsonConvert.DeserializeObject<WhiteLabelGeneration>(msg2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string HBillType = Main.HBillType; | 
|---|
|  |  |  | string ProjectNo = Main.ProjectNo; | 
|---|
|  |  |  | string OrderingCode = Main.OrderingCode; | 
|---|
|  |  |  | string DrawVersionNumber = Main.DrawVersionNumber; | 
|---|
|  |  |  | string CustomerOrderNumber = Main.CustomerOrderNumber; | 
|---|
|  |  |  | string WaybillNumber = Main.WaybillNumber; | 
|---|
|  |  |  | string HRemark = Main.HRemark; | 
|---|
|  |  |  | string HBarCode_Pack = Main.HBarCode_Pack; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn($"exec h_p_MES_HBarCode_White_SMR_15 '{HBillType}','{ProjectNo}','{OrderingCode}','{DrawVersionNumber}','{CustomerOrderNumber}','{WaybillNumber}','{HRemark}','{HBarCode_Pack}'", "h_p_MES_HBarCode_White_SMR_15"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string HBarCode_White = ds.Tables[0].Rows[0]["HBarCode_White"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (HBarCode_White == "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "生成白标失败,单据标识:" + HBarCode_Pack + "!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("update Sc_PackUnionBillMain set HBarCode_White='" + HBarCode_White + "' where HBarCode_Pack='" + HBarCode_Pack + "'"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.Commit(); | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "Sucess!"; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 下推质量汇报单时返回工序出站汇报单信息 | 
|---|
|  |  |  | [Route("Cj_StationOutBill/PushDownBackInfo")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object PushDownBackInfo(string linterid, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Sc_StationOutBill_PushDownBackInfo where hmainid in (" + linterid + ")", "h_v_Sc_StationOutBill_PushDownBackInfo"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0 && ds != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //添加列名 | 
|---|
|  |  |  | foreach (DataColumn col in ds.Tables[0].Columns) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Type dataType = col.DataType; | 
|---|
|  |  |  | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
|---|
|  |  |  | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "Sucess!"; | 
|---|
|  |  |  | objJsonResult.list = columnNameList; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无数据"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|