WYB
2021-04-06 7953aa09d09ed7889f8806f1e4fe2ccc18c1f548
WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -215,15 +215,114 @@
            try
            {
                DAL.ClsSc_ProcessSendWork dal = new DAL.ClsSc_ProcessSendWork();
                DAL.ClsSc_ProcessSendWork Sendwork = new DAL.ClsSc_ProcessSendWork();
                List<Model.ClsSc_ProcessSendWorkMain> lsmain = new List<Model.ClsSc_ProcessSendWorkMain>();
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");
                lsmain = oListModels.getObjectByJson_SendWorkMain(msg2);
                foreach ( Model.ClsSc_ProcessSendWorkMain  oItem in lsmain)
                {
                    UserName = oItem.HMaker;
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HDate = DateTime.Now;
                    oItem.HMainSourceInterID = oItem.HInterID;
                    oItem.HInterID = 0;
                    if (DBUtility.ClsPub.isStrNull(oItem.HPlanBeginDate) == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!没有填写计划开工日期,无法保存!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    Sendwork.omodel = oItem;
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
                }
                //表体数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
                msg3 = msg3.Replace("\\", "");
                msg3 = msg3.Replace("\n", "");  //\n
                List<WebAPI.Models.Sc_ProcessPlanViewModel> ls = new List<WebAPI.Models.Sc_ProcessPlanViewModel>();
                ls = oListModels.getObjectByJson_SendWorkSub(msg3);
                int i = 0;
                Model.ClsSc_ProcessSendWorkSub sendworksub = new Model.ClsSc_ProcessSendWorkSub();
                foreach (WebAPI.Models.Sc_ProcessPlanViewModel oItemSub in ls)
                {
                    //foreach (var item in collection)
                    //{
                    //}
                    //i++;
                    //if (oItemSub.HQty <= 0)
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "保存失败!第" + i.ToString() + "行数量不大于0无法保存!";
                    //    objJsonResult.data = 1;
                    //    return objJsonResult;
                    //}
                    //if (oItemSub.HQty > oItemSub.HRelationQty)
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "保存失败!第" + i.ToString() + "行数量不能大于未关联数量!";
                    //    objJsonResult.data = 1;
                    //    return objJsonResult;
                    //}
                    //if (DBUtility.ClsPub.isStrNull(oItemSub.HBatChNo) == "")
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "保存失败!第" + i.ToString() + "行未填写批号!";
                    //    objJsonResult.data = 1;
                    //    return objJsonResult;
                    //}
                    //oItemSub.HEntryID = i;
                    //oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    //oItemSub.HRemark = "";
                    //oItemSub.HCloseMan = "";
                    //oItemSub.HCloseType = false;
                    //Sendwork.DetailColl.Add(oItemSub);
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (Sendwork.omodel.HInterID == 0)
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = Sendwork.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
                {
                    bResult = Sendwork.ModifyBill(Sendwork.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                if (bResult)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {