yangle
2024-11-28 f9c66dcfca26da4eeba5c87df4ca3916461e37f8
WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using SyntacticSugar.constant;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -131,14 +132,50 @@
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + msg4 + "','" + HComputerName + "','" + "新增工序流转卡单据:" + oBill.omodel.HBillNo + "','LMES-工序流转卡模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                    //测试语句===========================================================================================================
                    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 = " + oBill.omodel.HInterID;
                    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(),'" + msg4 + "','" + HComputerName + "','" + "新增工序流转卡单据:" + oBill.omodel.HBillNo + msg_str + "','LMES-工序流转卡模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
                {
                    LogService.Write("用户:" + msg4 + ",日期:" + DateTime.Now + ",修改工序流转卡单据:" + oBill.omodel.HBillNo);
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + msg4 + "','" + HComputerName + "','" + "修改工序流转卡单据:" + oBill.omodel.HBillNo + "','LMES-工序流转卡模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                    //测试语句===========================================================================================================
                    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 = " + oBill.omodel.HInterID;
                    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(),'" + msg4 + "','" + HComputerName + "','" + "修改工序流转卡单据:" + oBill.omodel.HBillNo + msg_str + "','LMES-工序流转卡模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                if (bResult)
                {
@@ -827,8 +864,8 @@
                string sql = string.Format(@"select 流水号 HProcNo,HProcID,工序代码 HProcNumber,工序名称 HProcName,加工说明 HWorkRemark,HCenterID,工作中心代码 HCenterNumber,
                                                工作中心 HCenterName,HSupID,供应商代码 HSupNumber,供应商 HSupName,isEntrust HSupFlag,计划数量 HQty,加工单价 HOutPrice, 表体备注 HRemark,
                                            进站关联数量 HRelationQty_In,出站关联数量 HRelationQty_Out,委外工单数量 HRelationQty_WWOrder,不合格数量 HRelationQty_Bad,超额比例 HOverRate,
                                            良率 HPassRate,累计良率 HSumPassRate,图纸编号 HPicNum,本工序确认记录 HProcCheckNote,工艺参数 HTechnologyParameter,HDeptID,
                                            加工车间代码 HDeptNumber,加工车间 HDeptName,出站报废关联数量 HRelationQty_OutBad,SN过站控制 HSNCtrl
                                            良率 HPassRate,累计良率 HSumPassRate,图纸编号 HPicNum,本工序确认记录 HProcCheckNote,工艺参数 HTechnologyParameter,HDeptID,HSourceID,
                                            加工车间代码 HDeptNumber,加工车间 HDeptName,出站报废关联数量 HRelationQty_OutBad,SN过站控制 HSNCtrl,HRoutingInterID HRoutingBillMainID,HRoutingEntryID HRoutingBillEntryID
                                            from h_v_Sc_ProcessExchangeBillQuerySub");
                ds = oCN.RunProcReturn(sql+ " where hmainid="+ HInterID + "  order by cast(流水号 as int) ", "h_v_Sc_ProcessExchangeBillQuerySub");
                objJsonResult.code = "0";
@@ -1065,7 +1102,7 @@
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = string.Format(@"exec h_p_Sc_GetProcessExchangeBillSubTech ");
                ds = oCN.RunProcReturn(sql +  HInterID, "h_p_Sc_GetProcessExchangeBillSubTech");
                ds = oCN.RunProcReturn(sql + " '" +  HInterID + "'", "h_p_Sc_GetProcessExchangeBillSubTech");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -1911,6 +1948,59 @@
        }
        #endregion
        #region 工序流转卡分页列表
        [Route("Sc_ProcessExchangeBillList/page")]
        [HttpGet]
        public json page(string sWhere, string user, int page, int size)
        {
            json res = new json();
            try
            {
                List<object> columnNameList = new List<object>();
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("Sc_ProcessExchangeBill_SubQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_ProcessExchangeBillList_Query " + page + "," + size + ",''", "h_p_Sc_ProcessExchangeBillList_Query");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_ProcessExchangeBillList_Query " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_ProcessExchangeBillList_Query");
                }
                //添加列名
                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列对象的列名
                }
                res.code = CodeConstant.SUCCEED;
                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                res.Message = "Sucess!";
                res.list = columnNameList;
                res.data = ds.Tables[0];
                return res;
            }
            catch (Exception e)
            {
                res.code = CodeConstant.FAIL;
                res.count = CountConstant.FAIL;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        #endregion
        #region 工序流转卡列表
        /// <summary>
        /// 获取工序流转卡列表信息
@@ -2083,25 +2173,32 @@
                DateTime dt = DateTime.Now;
                string sql = "";
                Int64 HInterID = 0;
                string HBillNo = "";
                Int64 HICMOInterID = 0;
                Int64 HICMOEntryID = 0;
                string HICMOBillNo = "";
                double HQty = 0;
                double HProQty = 0;
                foreach (Model.ClsSc_ProcessExchangeBillSub_BatchSplit oItemSub in ls)
                {
                    HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("3772", ref DBUtility.ClsPub.sExeReturnInfo, true);
                    //HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("3772", ref DBUtility.ClsPub.sExeReturnInfo, true);
                    HInterID = oItemSub.HInterID;
                    HBillNo = oItemSub.HBillNo;
                    HICMOInterID = oItemSub.HICMOInterID;
                    HICMOEntryID = oItemSub.HICMOEntryID;
                    HICMOBillNo = oItemSub.HICMOBillNo;
                    HQty = oItemSub.HQty;
                    HProQty = oItemSub.HProQty;
                    sql = "select * from h_v_Sc_ProcessExchangeBill_BatchSplit where hmainid = " + oItemSub.HICMOInterID + " and hentryid = " 
                         + oItemSub.HICMOEntryID;
                         + oItemSub.HICMOEntryID + " and HRoutingID = " + oItemSub.HRoutingInterID.ToString();
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessExchangeBill_BatchSplit");
                    //主表赋值
                    if (ds.Tables[0].Rows.Count > 0 && ds != null)
                    {
                        oBill.omodel.HInterID = HInterID;
                        oBill.omodel.HBillNo = HBillNo;
                        oBill.omodel.HBillSubType = "3772";
                        oBill.omodel.HMainSourceBillSubType = "3710";
@@ -2112,7 +2209,7 @@
                        oBill.omodel.HYear = DBUtility.ClsPub.isLong(oItemSub.HDate.Year);
                        oBill.omodel.HPeriod = DBUtility.ClsPub.isLong(oItemSub.HDate.Month);
                        oBill.omodel.HRemark = "";
                        oBill.omodel.HBatchNo = "";
                        oBill.omodel.HBatchNo = oItemSub.HBatchNo;
                        oBill.omodel.HMainMaterID = 0;
                        oBill.omodel.HKeyMaterID = 0;
                        oBill.omodel.HNo = 0;
@@ -2205,7 +2302,7 @@
                        oBill.omodel.HRemark_New = "";
                        oBill.omodel.HWeight_New = 0;
                        oBill.omodel.HPlanOrderProcNo = ds.Tables[0].Rows[0]["HPlanOrderProcNo"].ToString();
                        oBill.omodel.HMouldNum = "0";
                        oBill.omodel.HMouldNum = "0";
                    }   
                    //子表赋值
                    for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
@@ -2235,11 +2332,11 @@
                        oItemSubs.HDeptID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[i]["HDeptID"]);
                        oItemSubs.HDeptNumber = ds.Tables[0].Rows[i]["HDeptNumber"].ToString();
                        oItemSubs.HGroupID = 0;
                        oItemSubs.HGroupNumber = "";
                        oItemSubs.HGroupNumber = oItemSub.HGroupNumber;
                        oItemSubs.HWorkerID = 0;
                        oItemSubs.HWorkerNumber = "";
                        oItemSubs.HSourceID = 0;
                        oItemSubs.HQty = HQty;
                        oItemSubs.HQty = HProQty;
                        oItemSubs.HTimeUnit = "";
                        oItemSubs.HPlanWorkTimes = 0;
                        oItemSubs.HPlanBeginDate = Convert.ToDateTime(dt.ToShortDateString().ToString());
@@ -2280,6 +2377,8 @@
                        oItemSubs.HSeOrderInterID = 0;
                        oItemSubs.HSeOrderEntryID = 0;
                        oItemSubs.HSNCtrl = false;
                        oItemSubs.HRoutingBillMainID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[i]["HRoutingID"]);
                        oItemSubs.HRoutingBillEntryID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[i]["HRoutingEntryID"]);
                        oBill.DetailColl.Add(oItemSubs);//添加明细行值                
                    }