1
yangle
2023-06-16 13f2dee8954b5bd589c1998a4fc2f98d93325d1c
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.Http;
@@ -52,6 +53,8 @@
                    return objJsonResult;
                }
                Stopwatch sw = new Stopwatch();
                sw.Start();//开始计时
                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2);
                long HMainInterID = 0;
@@ -121,6 +124,9 @@
                long HQCCheckID = list[0].HQCCheckID;//检验员ID
                long HPRDOrgID = list[0].HPRDOrgID;//组织ID
                double HmaterOutqty = list[0].HmaterOutqty;//白坯发布
                LogService.Write($"1.字段赋值,用时" + sw.Elapsed );
                //单据完整性判断
                if (HProcExchInterID <= 0)
                {
@@ -292,7 +298,11 @@
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                LogService.Write($"2.条件判断,用时" + sw.Elapsed);
                var num = 0;
                LogService.Write($"3.事务开始,用时" + sw.Elapsed);
                //若MAINDI重复则重新获取
                oCN.BeginTran();
@@ -308,6 +318,7 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    LogService.Write($"3.1,用时" + sw.Elapsed);
                    oCN.RunProc("Insert Into Sc_StationOutBillMain " +
                    "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
                    ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
@@ -329,6 +340,7 @@
                    "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
                     ","+ HmaterOutqty + ") ");
                    LogService.Write($"4.新增结束,用时" + sw.Elapsed);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工序出站单据:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增工序出站单据:" + HBillNo + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
@@ -378,6 +390,7 @@
                }
                //主表
                LogService.Write($"5.系统控制查询判断,用时" + sw.Elapsed);
                ds = oCN.RunProcReturn("exec h_p_MES_StationOutBill_QtyCtrl " + HInterID + "", "h_p_MES_StationOutBill_QtyCtrl");
                if (ds == null)
                {
@@ -388,6 +401,7 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                LogService.Write($"5.1,用时" + sw.Elapsed);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
@@ -397,6 +411,7 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                LogService.Write($"5.2,用时" + sw.Elapsed);
                if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
                {
                    oCN.RollBack();
@@ -406,9 +421,13 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                LogService.Write($"6.判断结束,用时" + sw.Elapsed);
                oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Out " + HInterID + ","+ num + "");
                LogService.Write($"6.1,用时" + sw.Elapsed);
                oCN.RunProc("exec h_p_Mes_ProcessExchangeChangeStatus  " + HInterID + " ");
                LogService.Write($"6.2,用时" + sw.Elapsed);
                oCN.RunProc("exec h_p_Mes_StationOutBillBackBarCode  " + HInterID + " ");
                LogService.Write($"7.存储过程结束,用时" + sw.Elapsed);
                //判断是否是 末道工序 
                ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a  " +
                                    " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID  " +
@@ -426,8 +445,10 @@
                            //判断末道 生产汇报汇报 是否勾选
                            if (oSystemParameter.omodel.MES_StationOutBill_LastAutoICMOReport == "Y") //系统参数   
                            {
                                LogService.Write($"7.1,用时" + sw.Elapsed);
                                //同步生产汇报单
                                objJsonResult= (json)SaveICMOReportBill(HInterID.ToString(), user, HBillNo, HPRDOrgID.ToString());
                                LogService.Write($"7.2,用时" + sw.Elapsed);
                                if (objJsonResult.count == 0)
                                {
                                    oCN.RollBack();
@@ -437,12 +458,15 @@
                                    objJsonResult.data = null;
                                    return objJsonResult;
                                }
                                LogService.Write($"8.生产汇报结束,用时" + sw.Elapsed);
                            }
                            //判断末道 生产入库 是否勾选
                            else if (oSystemParameter.omodel.MES_StationOutBill_AutoStockIn == "Y") //系统参数   
                            {
                                LogService.Write($"8.1,用时" + sw.Elapsed);
                                //同步生产入库单
                                objJsonResult=(json)SaveProcdutInBill(HBillNo);
                                LogService.Write($"8.2,用时" + sw.Elapsed);
                                if (objJsonResult.count == 0)
                                {
                                    oCN.RollBack();
@@ -452,6 +476,7 @@
                                    objJsonResult.data = null;
                                    return objJsonResult;
                                }
                                LogService.Write($"9.生产入库结束,用时" + sw.Elapsed);
                            }
                           
                        }
@@ -459,7 +484,7 @@
                }
               
                LogService.Write($"10.事务结束,用时" + sw.Elapsed);
                oCN.Commit();
                string sReturn = "";
                if (oSystemParameter.ShowBill(ref sReturn) == true)
@@ -473,6 +498,8 @@
                        objJsonResult.Verify = "N";
                    }
                }
                sw.Stop();//结束计时
                LogService.Write($"11.参数查询结束,新增结束,用时" + sw.Elapsed);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "新增单据成功!";