仲国强
2021-10-15 9c60b98594f1e685f4d8f99efb4e84d21b3847f3
WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
@@ -14,6 +14,7 @@
    public class Cj_StationEntrustInBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
@@ -128,7 +129,9 @@
            {
                //委外工序发出反序列化
                msg1 = "[" + msg1.ToString() + "]";
                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1);
                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1);
                long HMainInterID = 0;
                HMainInterID = list[0].HMainInterID;
                string eventType = list[0].eventType;
                long HInterID = list[0].HInterID;//递入type得到的单据ID
                int HYear = 2021;
@@ -255,7 +258,7 @@
                    ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" +
                    ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
                    ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPieceQty" +
                    ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID" +
                    ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID,HMainInterID" +
                    ") " +
                    " values('3792','3792'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillStatus.ToString() + "',getdate(),'" + HMaker + "',getdate()" +
                    ",'" + HYear.ToString() + "','" + HPeriod.ToString() + "','" + HRemark + "','" + HInnerBillNo + "'" +
@@ -263,7 +266,7 @@
                    ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID +
                    "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" +
                    "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPieceQty +
                    ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "" +
                    ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "," + HMainInterID +
                    ") ");
                }
                else if ("Modify".Equals(eventType))
@@ -332,6 +335,18 @@
                oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_In " + HInterID.ToString() + ",1");
                oCN.RunProc("exec h_p_WW_EntrustWorkOrderRelationQty_In " + HInterID.ToString() + ",1");
                oCN.Commit();
                string sReturn = "";
                if (oSystemParameter.ShowBill(ref sReturn) == true)
                {
                    if (oSystemParameter.omodel.MES_StationEntrustInBill_SaveAutoAddnew == "Y") //系统参数  自动审核
                    {
                        objJsonResult.Verify = "Y";
                    }
                    else
                    {
                        objJsonResult.Verify = "N";
                    }
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "新增单据成功!";
@@ -720,6 +735,103 @@
            }
        }
        #endregion
        #region 根据id删除委外发出单
        [Route("Cj_StationEntrustInBill/del_StationEntrustInBill")]
        [HttpGet]
        public object del_StationEntrustInBill(long HInterID, string HDeleteMan)
        {
            try
            {
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustInBill_Delete", 1, true, HDeleteMan))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsSc_StationEntrustInBill oBill = new DAL.ClsSc_StationEntrustInBill();
                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    if (oBill.omodel.HMaker != HDeleteMan && (HDeleteMan != "admin" && HDeleteMan != "Admin"))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "只能删除本人的单据!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已经审核,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                    DataSet ds;
                    //判断是否存在 相同单据号 的领料单 判断生产订单是否已结案,要求计划手工反结案
                    ds = oCn.RunProcReturn("exec h_p_MES_StationInBill_DelCtrl  '" + oBill.omodel.HBillNo + "'", "h_p_MES_StationInBill_DelCtrl");
                    if (ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "判断关联失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows.Count > 0 && Pub_Class.ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 2)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //写入删除日志
                    string WorkList = "删除委外发出单:" + oBill.omodel.HBillNo;
                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除成功!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据未找到!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        //
    }
}