yangle
2023-06-29 2d3fc93b131c7aa771e8f7d08a82d5e9b4946eff
WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/JIT_DayPlanPlatFormImportController.cs
@@ -55,10 +55,12 @@
                tb2.Columns.Add("单据号", typeof(string));
                tb2.Columns.Add("HWorkShopID", typeof(Int32));//生产车间
                tb2.Columns.Add("HEmpID", typeof(Int32));//职员
                tb2.Columns.Add("员工", typeof(string));//职员
                tb2.Columns.Add("HUnitID", typeof(Int32));//计量单位
                tb2.Columns.Add("HSourceID", typeof(Int32));//生产资源id
                tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));//生产订单主id
                tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//生产订单子id
                tb2.Columns.Add("HProdORGID", typeof(Int32));//组织id
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
@@ -104,8 +106,10 @@
                    ds = oCN.RunProcReturn(sql1, "h_v_IF_ICMOBillList");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        error += $"没有生产订单信息,生产订单号:{ tb2.Rows[i]["生产订单号*"].ToString()},生产车间编码:{tb2.Rows[i]["生产车间编码*"].ToString()}" +
                            $",生产订单明细行号:{ tb2.Rows[i]["生产订单明细行号*"].ToString()},物料编码:{ tb2.Rows[i]["物料编码*"].ToString()}";
                               $",生产订单明细行号:{ tb2.Rows[i]["生产订单明细行号*"].ToString()},物料编码:{ tb2.Rows[i]["物料编码*"].ToString()}";
                    }
                    if (error.Length > 0)
                    {
@@ -141,6 +145,7 @@
                        tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HSourceID"].ToString();
                        tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HEmpID"].ToString();
                        tb2.Rows[i]["员工编码"] = ds.Tables[0].Rows[0]["职员代码"].ToString();
                        tb2.Rows[i]["员工"] = ds.Tables[0].Rows[0]["职员"].ToString();
                        tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HUnitID"].ToString();
                        tb2.Rows[i]["计量单位"] = ds.Tables[0].Rows[0]["计量单位"].ToString();
                        tb2.Rows[i]["批次号"] = ds.Tables[0].Rows[0]["批次"].ToString();
@@ -151,18 +156,61 @@
                    {
                        //员工
                        ds = oCN.RunProcReturn($"select * from Gy_Employee  where HNumber='{tb2.Rows[i]["员工编码"].ToString()}'", "Gy_Employee");
                        if (ds.Tables[0].Rows.Count > 0)
                            tb2.Rows[i]["员工编码"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        if (ds.Tables[0].Rows.Count > 0) {
                            tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            tb2.Rows[i]["员工"] = ds.Tables[0].Rows[0]["HName"].ToString();
                        }
                        else
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = $"第{i + 1}行,员工查无数据!";
                            objJsonResult.data = tb2;
                            return objJsonResult;
                        }
                        //计量单位
                        ds = oCN.RunProcReturn($"select * from Gy_Unit  where HNumber='{tb2.Rows[i]["计量单位"].ToString()}'", "Gy_Unit");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        else
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = $"第{i + 1}行,计量单位查无数据!";
                            objJsonResult.data = tb2;
                            return objJsonResult;
                        }
                        //生产资源
                        ds = oCN.RunProcReturn($"select * from Gy_Source  where HNumber='{tb2.Rows[i]["生产资源编码*"].ToString()}'", "Gy_Source");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        else {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = $"第{i+1}行,生产资源查无数据!";
                            objJsonResult.data = tb2;
                            return objJsonResult;
                        }
                    }
                    //组织
                    ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS  where HNumber='{tb2.Rows[i]["组织编码*"].ToString()}'", "Xt_ORGANIZATIONS");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        tb2.Rows[i]["HProdORGID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = $"第{i + 1}行,组织查无数据!";
                        objJsonResult.data = tb2;
                        return objJsonResult;
                    }
                }
@@ -257,7 +305,7 @@
                        HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//获得一个新的id
                        var HICMOBillNo = list[i]["生产订单号*"].ToString();
                        var HICMOEntrySEQ = list[i]["生产订单明细行号*"].ToString();
                        var HProdORGID = list[i]["组织编码*"].ToString();
                        var HProdORGID = list[i]["HProdORGID"].ToString();
                        var HWorkShopID = list[i]["HWorkShopID"].ToString();
                        var HSourceID = list[i]["HSourceID"].ToString();
                        var HYX = list[i]["优先级"].ToString();
@@ -292,13 +340,13 @@
                            "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX, HEmpID," +
                            " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," +
                            " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," +
                            "HMainSourceInterID,HMainSourceEntryID,HProdORGID)values" +
                            "HMainSourceInterID,HMainSourceEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec)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)}, {(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},{HProdORGID})");
                            $" {HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID})");
                    }
                    int SumDay = 31; //动态两月之差 DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days;