VueWebApi/Controllers/ProductModelController.cs
@@ -17,7 +17,7 @@
    [RoutePrefix(prefix: "api/ProductModel")]
    [ControllerGroup("制造模型", "在线接口")]
    //[ChannelActionFilter]
    [ChannelActionFilter]
    public class ProductModelController : ApiController
    {
        //定义全局信息返回变量
@@ -216,9 +216,11 @@
        [HttpGet]
        public HttpResponseMessage InventoryFileSelect(string partcode = null, string partname = null, string partspec = null, string stocktypecode = null, string materialtypecode = null, string storehousecode = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.InventoryFileSelect(partcode, partname, partspec, stocktypecode, materialtypecode, storehousecode, startNum, endNum, prop, order);
            mes = ProductModelBLL.InventoryFileSelect(stu_torgcode, stu_torgtypecode,partcode, partname, partspec, stocktypecode, materialtypecode, storehousecode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
@@ -240,12 +242,15 @@
            string uomcode = obj["uomcode"].ToString();           //单位编码
            string warehousecode = obj["warehousecode"].ToString(); //所属仓库编码
            string stocktypecode = obj["stocktypecode"].ToString(); //存货类型编码
            string materialtypecode = obj["materialtypecode"].ToString(); //物料类型编码
            string minstockqty = obj["minstockqty"].ToString(); //最小库存
            string maxstockqty = obj["maxstockqty"].ToString(); //最大库存
            string is_batchno = obj["is_batchno"].ToString();   //是否批次管理
            string is_fifo = obj["is_fifo"].ToString();         //是否先进先出
            string is_incheck = obj["is_incheck"].ToString();   //是否入厂检验
            string is_outcheck = obj["is_outcheck"].ToString(); //是否出厂检验
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = ProductModelBLL.AddUpdateInventoryFile(materialid, materialcode, materialname, materialspec, uomcode, warehousecode, stocktypecode, materialtypecode, minstockqty, maxstockqty, username, OperType);
            mes = ProductModelBLL.AddUpdateInventoryFile(materialid, materialcode, materialname, materialspec, uomcode, warehousecode, stocktypecode, minstockqty, maxstockqty,is_batchno,is_fifo,is_incheck,is_outcheck, username, OperType);
            return TJson.toJson(mes);
        }
        #endregion
@@ -275,7 +280,9 @@
        [HttpGet]
        public HttpResponseMessage InventoryFileAssociationRoute(string partcode)
        {
            mes = ProductModelBLL.InventoryFileAssociationRoute(partcode);
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            mes = ProductModelBLL.InventoryFileAssociationRoute(stu_torgcode, stu_torgtypecode,partcode);
            return TJson.toJson(mes);
        }
        #endregion
@@ -290,10 +297,12 @@
        /// <returns></returns>
        [Route(template: "SaveInventoryFile")]
        [HttpPost]
        public HttpResponseMessage SaveInventoryFile(string partcode, List<ObjectData> json, string defaultroute_code = null)
        public HttpResponseMessage SaveInventoryFile(string partcode, List<PartRout> json, string defaultroute_code = null)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveInventoryFile(partcode, defaultroute_code, username, json);
            mes = ProductModelBLL.SaveInventoryFile(stu_torgcode, stu_torgtypecode, partcode, defaultroute_code, username, json);
            return TJson.toJson(mes);
        }
        #endregion
@@ -381,13 +390,28 @@
            string status = obj["status"].ToString();//启用状态
            string uomcode = obj["uomcode"].ToString(); //计量单位编码
            string quantity = obj["quantity"].ToString(); //基础数量
            string startdate = obj["startdate"].ToString(); //基础数量
            string version = obj["version"].ToString(); //基础数量
            string worklist = obj["worklist"].ToString(); //基础数量
            string opertype = obj["opertype"].ToString(); //基础数量
            string startdate = obj["startdate"].ToString(); //启用日期
            string version = obj["version"].ToString(); //版本号
            string worklist = obj["worklist"].ToString(); //提交数据
            string opertype = obj["opertype"].ToString(); //提交类型
            string username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            List<BomSub> objs = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BomSub>>(worklist);
            mes = ProductModelBLL.AddUpdateBoIventory(bomid,parentpartcode, parentpartname, parentpartspec, status, uomcode, quantity, startdate, version, username, opertype, objs);
            return TJson.toJson(mes);
        }
        #endregion
        #region[物料清单删除]
        /// <summary>
        /// 物料清单删除
        /// </summary>
        /// <param name="bomid">Bom主表id</param>
        /// <returns></returns>
        [Route(template: "DeleteBoIventory")]
        [HttpPost]
        public HttpResponseMessage DeleteBoIventory(string bomid)
        {
            mes = ProductModelBLL.DeleteBoIventory(bomid);
            return TJson.toJson(mes);
        }
        #endregion
@@ -402,9 +426,9 @@
        /// <returns></returns>
        [Route(template: "StepSelect")]
        [HttpGet]
        public HttpResponseMessage StepSelect()
        public HttpResponseMessage StepSelect(string WorkShop)
        {
            mes = ProductModelBLL.StepSelect();
            mes = ProductModelBLL.StepSelect(WorkShop);
            return TJson.toJson(mes);
        }
        #endregion
@@ -413,6 +437,7 @@
        /// <summary>
        /// 工艺路线查询
        /// </summary>
        /// <param name="WorkShop">所属车间</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="routename">工艺路线名称</param>
        /// <param name="description">工艺路线描述</param>
@@ -424,11 +449,13 @@
        /// <returns></returns>
        [Route(template: "RouteSearch")]
        [HttpGet]
        public HttpResponseMessage RouteSearch(string routecode = null, string routename = null, string description = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        public HttpResponseMessage RouteSearch(string WorkShop=null,string routecode = null, string routename = null, string description = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.RouteSearch(routecode, routename, description, createuser, startNum, endNum, prop, order);
            mes = ProductModelBLL.RouteSearch(stu_torgcode, stu_torgtypecode, WorkShop, routecode, routename, description, createuser, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
@@ -481,12 +508,56 @@
        }
        #endregion
        #region[工艺路线关联产品查询]
        /// <summary>
        /// 工艺路线关联产品查询
        /// </summary>
        /// <param name="partcode">物料编码</param>
        /// <param name="partname">物料名称</param>
        /// <param name="partspec">物料规格</param>
        /// <param name="stocktypecode">存货类型编码</param>
        /// <param name="materialtypecode">物料类型编码</param>
        /// <param name="storehousecode">所属仓库编码</param>
        /// <returns></returns>
        [Route(template: "RputeInventorySearch")]
        [HttpGet]
        public HttpResponseMessage RputeInventorySearch(string partcode = null, string partname = null, string partspec = null, string stocktypecode = null, string materialtypecode = null, string storehousecode = null)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            mes = ProductModelBLL.RputeInventorySearch(stu_torgcode, stu_torgtypecode, partcode, partname, partspec, stocktypecode, materialtypecode, storehousecode);
            return TJson.toJson(mes);
        }
        #endregion
        #region[工艺路线批量指定物料保存]
        /// <summary>
        /// 工艺路线批量指定物料保存
        /// </summary>
        /// <param name="obj">提交数据</param>
        /// <returns></returns>
        [Route(template: "RouteBatchPartSave")]
        [HttpPost]
        public HttpResponseMessage RouteBatchPartSave([FromBody] JObject obj)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string routecode = obj["routecode"].ToString(); //工艺路线编码
            string routepart = obj["routepart"].ToString(); //工艺路线绑定产品编码
            string[] rolebatchpartcode = Array.ConvertAll<string, string>(routepart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string分割转string[]
            mes = ProductModelBLL.RouteBatchPartSave(stu_torgcode, stu_torgtypecode, username, routecode, rolebatchpartcode);
            return TJson.toJson(mes);
        }
        #endregion
        #region[工序查询]
        /// <summary>
        /// 工序查询
        /// </summary>
        /// <param name="WorkShop">所属车间</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="stepname">工序名称</param>
        /// <param name="enable">启用状态</param>
@@ -499,11 +570,13 @@
        /// <returns></returns>
        [Route(template: "StepSearch")]
        [HttpGet]
        public HttpResponseMessage StepSearch(string stepcode = null, string stepname = null, string enable = null, string steptypecode = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        public HttpResponseMessage StepSearch(string WorkShop=null, string stepcode = null, string stepname = null, string enable = null, string steptypecode = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.StepSearch(stepcode, stepname, enable, steptypecode, createuser, startNum, endNum, prop, order);
            mes = ProductModelBLL.StepSearch(stu_torgcode, stu_torgtypecode, WorkShop, stepcode, stepname, enable, steptypecode, createuser, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
@@ -519,6 +592,7 @@
        public HttpResponseMessage AddUpdateStep([FromBody] JObject obj)
        {
            string stepid = obj["id"].ToString();    //工序id(主键)
            string WorkShop = obj["WorkShop"].ToString(); //车间编码
            string stepcode = obj["stepcode"].ToString(); //工序编码
            string stepname = obj["stepname"].ToString(); //工序名称
            string steptypecode = obj["steptypecode"].ToString(); //工序类型编码
@@ -526,7 +600,7 @@
            string description = obj["description"].ToString(); //工序描述
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = ProductModelBLL.AddUpdateStep(stepid, stepcode, stepname, steptypecode, enable, description, username, OperType);
            mes = ProductModelBLL.AddUpdateStep(stepid, WorkShop,stepcode, stepname, steptypecode, enable, description, username, OperType);
            return TJson.toJson(mes);
        }
        #endregion
@@ -554,9 +628,9 @@
        /// <returns></returns>
        [Route(template: "StepAssociationEqp")]
        [HttpGet]
        public HttpResponseMessage StepAssociationEqp(string stepcode)
        public HttpResponseMessage StepAssociationEqp(string WorkShop, string stepcode)
        {
            mes = ProductModelBLL.StepAssociationEqp(stepcode);
            mes = ProductModelBLL.StepAssociationEqp(WorkShop,stepcode);
            return TJson.toJson(mes);
        }
        #endregion
@@ -565,15 +639,16 @@
        /// <summary>
        /// 工序定义关联工作站提交
        /// </summary>
        /// <param name="WorkShop">所属组织编码(车间)</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="json">提交数据</param>
        /// <returns></returns>
        [Route(template: "SaveStepAssociationEqp")]
        [HttpPost]
        public HttpResponseMessage SaveStepAssociationEqp(string stepcode, List<ObjectData> json)
        public HttpResponseMessage SaveStepAssociationEqp(string WorkShop, string stepcode, List<ObjectData> json)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveStepAssociationEqp(stepcode, username, json);
            mes = ProductModelBLL.SaveStepAssociationEqp(WorkShop,stepcode, username, json);
            return TJson.toJson(mes);
        }
        #endregion
@@ -586,9 +661,9 @@
        /// <returns></returns>
        [Route(template: "StepAssociationDefect")]
        [HttpGet]
        public HttpResponseMessage StepAssociationDefect(string stepcode)
        public HttpResponseMessage StepAssociationDefect(string WorkShop,  string stepcode)
        {
            mes = ProductModelBLL.StepAssociationDefect(stepcode);
            mes = ProductModelBLL.StepAssociationDefect(WorkShop,stepcode);
            return TJson.toJson(mes);
        }
        #endregion
@@ -602,10 +677,10 @@
        /// <returns></returns>
        [Route(template: "SaveStepAssociationDefect")]
        [HttpPost]
        public HttpResponseMessage SaveStepAssociationDefect(string stepcode, List<ObjectData> json)
        public HttpResponseMessage SaveStepAssociationDefect(string WorkShop, string stepcode, List<ObjectData> json)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveStepAssociationDefect(stepcode, username, json);
            mes = ProductModelBLL.SaveStepAssociationDefect(WorkShop,stepcode, username, json);
            return TJson.toJson(mes);
        }
        #endregion
@@ -646,7 +721,9 @@
        {
            try
            {
                mes = ProductModelBLL.PartSelectRpute(partcode);
                var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
                var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
                mes = ProductModelBLL.PartSelectRpute(stu_torgcode, stu_torgtypecode,partcode);
            }
            catch (Exception e)
            {
@@ -702,6 +779,7 @@
        /// <param name="partcode">产品编码</param>
        ///  <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="steptype">工序类型</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
@@ -709,12 +787,12 @@
        /// <returns></returns>
        [Route(template: "StepSelectEqpList")]
        [HttpGet]
        public HttpResponseMessage StepSelectEqpList(string partcode, string routecode, string stepcode, int page = 0, int rows = 0, string prop = null, string order = null)
        public HttpResponseMessage StepSelectEqpList(string partcode, string routecode, string stepcode,string steptype, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.StepSelectEqpList(partcode, routecode, stepcode, startNum, endNum, prop, order);
            mes = ProductModelBLL.StepSelectEqpList(partcode, routecode, stepcode, steptype, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
@@ -736,9 +814,11 @@
        [HttpGet]
        public HttpResponseMessage BeatRateSearch(string partcode = null, string routecode = null, string stepcode = null, string eqpcode = null,int page = 0, int rows = 0, string prop = null, string order = null)
        {
            var stu_torgcode = HttpContext.Current.Request.Cookies["stu_torgcode"].Value.ToString(); //所属组织
            var stu_torgtypecode = HttpContext.Current.Request.Cookies["description"].Value.ToString(); //所属组织类型
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.BeatRateSearch(partcode,routecode, stepcode, eqpcode, startNum, endNum, prop, order);
            mes = ProductModelBLL.BeatRateSearch(stu_torgcode, stu_torgtypecode,partcode, routecode, stepcode, eqpcode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion