yusijie
7 天以前 01685f3ab68f64b51b83eee40af90f4030866691
WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/JIT_DayPlanPlatFormImportController.cs
@@ -64,6 +64,7 @@
                tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//生产订单子id
                tb2.Columns.Add("HProdORGID", typeof(Int32));//组织id
                tb2.Columns.Add("HSeOrderBillNo", typeof(string));//销售订单号                
                tb2.Columns.Add("HVersion_Import", typeof(string));//导入序列号
                //获取系统参数
                string Ret = "";
@@ -110,6 +111,9 @@
                //查询生产订单表判断有没有生产订单信息
                for (int i = 0; i < tb2.Rows.Count; i++)
                {
                    tb2.Rows[i]["HVersion_Import"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    if (tb2.Rows[i]["组织编码*"].ToString() == "")
                        error += "组织编码不能为空;";
                    if (tb2.Rows[i]["生产订单号*"].ToString() == "")
@@ -132,8 +136,16 @@
                        return objJsonResult;
                    }
                    string sql1 = string.Format("select * from h_v_JIT_ICMOBillList_DR where å•据号='{0}' and ç”Ÿäº§è½¦é—´ä»£ç ='{1}' and äº§å“ä»£ç ='{2}' and æ˜Žç»†è¡Œå·={3} ",
                    string sql1 = "";
                    if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                    {
                        sql1 = "select * from h_v_JIT_ICMOBillList_DR where å•据号='" + tb2.Rows[i]["生产订单号*"].ToString() +  "' and äº§å“ä»£ç ='" + tb2.Rows[i]["物料编码*"].ToString() + "' and æ˜Žç»†è¡Œå·=" + tb2.Rows[i]["生产订单明细行号*"].ToString();
                    }
                    else
                    {
                        sql1 = string.Format("select * from h_v_JIT_ICMOBillList_DR where å•据号='{0}' and ç”Ÿäº§è½¦é—´ä»£ç ='{1}' and äº§å“ä»£ç ='{2}' and æ˜Žç»†è¡Œå·={3} ",
                        tb2.Rows[i]["生产订单号*"].ToString(), tb2.Rows[i]["生产车间编码*"].ToString(), tb2.Rows[i]["物料编码*"].ToString(), tb2.Rows[i]["生产订单明细行号*"].ToString());
                    }
                    ds = oCN.RunProcReturn(sql1, "h_v_JIT_ICMOBillList_DR");
                    if (ds.Tables[0].Rows.Count == 0)
@@ -255,6 +267,24 @@
                        objJsonResult.data = tb2;
                        return objJsonResult;
                    }
                    if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                    {
                        string HOrgID = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //生产车间
                        ds = oCN.RunProcReturn($"select * from Gy_Department with(nolock) where HUSEORGID = {HOrgID} and HNumber='{tb2.Rows[i]["生产车间编码*"].ToString()}'", "Gy_Department");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        else
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = $"第{i + 1}行,生产车间查无数据!";
                            objJsonResult.data = tb2;
                            return objJsonResult;
                        }
                    }
                }
                objJsonResult.code = "1";
@@ -368,6 +398,7 @@
                        var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString();
                        var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString();
                        var HSeOrderBillNo = list[i]["HSeOrderBillNo"].ToString();
                        var HVersion_Import = list[i]["HVersion_Import"].ToString();
                        string sql = $"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
                          $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'') = ''";
@@ -389,14 +420,14 @@
                            " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," +
                            " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," +
                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" +
                            ",HSeOrderBillNo)values" +
                            ",HSeOrderBillNo,HVersion_Import)values" +
                            $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
                            $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," +
                            $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)},{(HWorkQty)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," +
                            $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," +
                            $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," +
                            $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" +
                            $",'{HSeOrderBillNo}')");
                            $",'{HSeOrderBillNo}','{HVersion_Import}')");
                    }
                    int SumDay = 31; //动态两月之差 DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days;