VueWebApi/DLL/DAL/ProductModelDAL.cs
@@ -465,7 +465,7 @@
                var total = 0; //总条数
                var sql = @"select A.id,A.partcode,A.partname,A.partspec,A.uom_code,B.name as uom_name,D.code as stocktypecode,D.name as stocktypename,
                            C.code as materialtypecode,C.name as materialtypename,A.stck_code,T.name as stck_name,A.maxqty,A.minqty,U.username as lm_user,A.default_route,
                            A.lm_date,A.proute_id
                            A.lm_date,A.proute_id,A.is_batchno,A.is_fifo,A.is_incheck,A.is_outcheck
                            from TMateriel_Info A
                            left join TUom B on A.uom_code=B.code
                            left join TMateriel_Type C on A.materieltype_code=C.code
@@ -491,7 +491,7 @@
        #endregion
        #region[存货档案新增编辑]
        public static ToMessage AddUpdateInventoryFile(string materialid, string materialcode, string materialname, string materialspec, string uomcode, string warehousecode, string stocktypecode, string materialtypecode, string minstockqty, string maxstockqty, string username, string operType)
        public static ToMessage AddUpdateInventoryFile(string materialid, string materialcode, string materialname, string materialspec, string uomcode, string warehousecode, string stocktypecode, string materialtypecode, string minstockqty, string maxstockqty,string is_batchno,string is_fifo,string is_incheck,string is_outcheck, string username, string operType)
        {
            var dynamicParams = new DynamicParameters();
            try
@@ -509,8 +509,8 @@
                        mes.data = null;
                        return mes;
                    }
                    var sql = @"insert into TMateriel_Info(partcode,partname,partspec,uom_code,stocktype_code,materieltype_code,stck_code,maxqty,minqty,lm_user,lm_date)
                            values(@materialcode,@materialname,@materialspec,@uomcode,@stocktypecode,@materialtypecode,@warehousecode,@maxstockqty,@minstockqty,@username,@CreateDate)";
                    var sql = @"insert into TMateriel_Info(partcode,partname,partspec,uom_code,stocktype_code,materieltype_code,stck_code,maxqty,minqty,lm_user,lm_date,is_batchno,is_fifo,is_incheck,is_outcheck)
                            values(@materialcode,@materialname,@materialspec,@uomcode,@stocktypecode,@materialtypecode,@warehousecode,@maxstockqty,@minstockqty,@username,@CreateDate,@is_batchno,@is_fifo,@is_incheck,@is_outcheck)";
                    dynamicParams.Add("@materialcode", materialcode);
                    dynamicParams.Add("@materialname", materialname);
                    dynamicParams.Add("@materialspec", materialspec);
@@ -522,6 +522,10 @@
                    dynamicParams.Add("@maxstockqty", maxstockqty);
                    dynamicParams.Add("@username", username);
                    dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
                    dynamicParams.Add("@is_batchno", is_batchno);
                    dynamicParams.Add("@is_fifo", is_fifo);
                    dynamicParams.Add("@is_incheck", is_incheck);
                    dynamicParams.Add("@is_outcheck", is_outcheck);
                    int cont = DapperHelper.SQL(sql, dynamicParams);
                    if (cont > 0)
                    {
@@ -541,7 +545,8 @@
                if (operType == "Update")
                {
                    var sql = @"update TMateriel_Info set partname=@materialname,partspec=@materialspec,uom_code=@uomcode,stocktype_code=@stocktypecode,materieltype_code=@materialtypecode,stck_code=@warehousecode,
                                maxqty=@maxstockqty,minqty=@minstockqty,lm_user=@username,lm_date=@CreateDate where id=@materialid";
                                maxqty=@maxstockqty,minqty=@minstockqty,lm_user=@username,lm_date=@CreateDate,is_batchno=@is_batchno,is_fifo=@is_fifo,
                                is_incheck=@is_incheck,is_outcheck=@is_outcheck where id=@materialid";
                    dynamicParams.Add("@materialid", materialid);
                    dynamicParams.Add("@materialname", materialname);
                    dynamicParams.Add("@materialspec", materialspec);
@@ -553,6 +558,10 @@
                    dynamicParams.Add("@maxstockqty", maxstockqty);
                    dynamicParams.Add("@username", username);
                    dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
                    dynamicParams.Add("@is_batchno", is_batchno);
                    dynamicParams.Add("@is_fifo", is_fifo);
                    dynamicParams.Add("@is_incheck", is_incheck);
                    dynamicParams.Add("@is_outcheck", is_outcheck);
                    int cont = DapperHelper.SQL(sql, dynamicParams);
                    if (cont > 0)
                    {
@@ -986,12 +995,12 @@
                        str = sql,
                        parm = new
                        {
                            id = bomid,
                            bomid = bomid,
                            materiel_code = parentpartcode,
                            quantity = quantity,
                            status = status,
                            username = username,
                            CreateDate = DateTime.Now.ToString()
                            lm_user = username,
                            lm_date = DateTime.Now.ToString()
                        }
                    });
                    //删除BOM子表
@@ -1001,7 +1010,7 @@
                        str = sql,
                        parm = new
                        {
                            id = bomid
                            bomid = bomid
                        }
                    });
                    //写入BOM子表
@@ -1286,7 +1295,7 @@
                        {
                            is_firststep = "Y";
                        }
                        else if (Convert.ToInt32(json.Data.Rows[i]["SEQ"].ToString()) == json.Data.Rows.Count) //是否末道工序
                        if (Convert.ToInt32(json.Data.Rows[i]["SEQ"].ToString()) == json.Data.Rows.Count) //是否末道工序
                        {
                            is_laststep = "Y";
                        }
@@ -1330,6 +1339,18 @@
            var dynamicParams = new DynamicParameters();
            try
            {
                //判断工艺路路线是否被存货绑定
                sql = @"select *   from TMateriel_Route where route_code=@routecode";
                dynamicParams.Add("@routecode", routecode);
                var data_0 = DapperHelper.selectdata(sql, dynamicParams);
                if (data_0.Rows.Count > 0)
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "存货档案已关联工艺路线,不允许删除!";
                    mes.data = null;
                    return mes;
                }
                //判断工艺路线是否被工单引用(被引用则不能删除)
                sql = @"select *   from TK_Wrk_Man where route_code=@routecode";
                dynamicParams.Add("@routecode", routecode);
@@ -1340,6 +1361,7 @@
                    mes.count = 0;
                    mes.Message = "工艺路线已被工单引用,不允许删除!";
                    mes.data = null;
                    return mes;
                }
                else
                {
@@ -1353,6 +1375,7 @@
                        mes.count = 0;
                        mes.Message = "工艺路线已设置节拍工价,请先删除设置!";
                        mes.data = null;
                        return mes;
                    }
                    else
                    {
@@ -1366,21 +1389,23 @@
                        sql = @"delete TMateriel_Route  where route_code=@routecode";
                        list.Add(new { str = sql, parm = new { routecode = routecode } });
                    }
                }
                bool aa = DapperHelper.DoTransaction(list);
                if (aa)
                {
                    mes.code = "200";
                    mes.count = 0;
                    mes.Message = "删除成功!";
                    mes.data = null;
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "删除失败!";
                    mes.data = null;
                    bool aa = DapperHelper.DoTransaction(list);
                    if (aa)
                    {
                        mes.code = "200";
                        mes.count = 0;
                        mes.Message = "删除成功!";
                        mes.data = null;
                        return mes;
                    }
                    else
                    {
                        mes.code = "300";
                        mes.count = 0;
                        mes.Message = "删除失败!";
                        mes.data = null;
                        return mes;
                    }
                }
            }
            catch (Exception e)
@@ -1389,6 +1414,7 @@
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
                return mes;
            }
            return mes;
        }
@@ -1561,6 +1587,9 @@
                            //修改工序表关联工作站标识
                            sql_1 = @"update TStep set is_eqp='N' where stepcode=@stepcode";
                            list.Add(new { str = sql_1, parm = new { stepcode = stepcode } });
                            //删除设备节拍工价表
                            sql_1 = @"delete TPrteEqp_Stad  where step_code=@stepcode";
                            list.Add(new { str = sql_1, parm = new { stepcode = stepcode } });
                        }
                    }
@@ -1674,13 +1703,13 @@
                        where A.step_code=@stepcode and A.is_delete<>'1' and B.is_delete<>'1'
                        ) B on T.org_code=B.wksp_code where T.description='W' and is_delete<>'1'
                        UNION ALL
                        select distinct T.btype as wksp_code,(case T.btype  when 'WX' then '外协供方' end ) as wksp_name,'W' as type,(case when B.btype is null then 'N' else 'Y' end) flag
                        select distinct T.type as wksp_code,(case when T.type='211' then '供应商' when T.type='228' then '客户/供应商' end ) as wksp_name,'W' as type,(case when B.type is null then 'N' else 'Y' end) flag
                        from TCustomer T
                        left join(
                        select distinct A.eqp_code,B.btype  from TFlw_Rteqp A
                        select distinct A.eqp_code,B.type  from TFlw_Rteqp A
                        inner join TCustomer B on A.eqp_code=B.code 
                        where A.step_code=@stepcode and A.is_delete<>'1' and B.is_delete<>'1'
                        ) B on T.btype=B.btype where T.btype='WX' and T.is_delete<>'1'";
                        where A.step_code=@stepcode  and A.is_delete<>'1' and B.is_delete<>'1'
                        ) B on T.type=B.type where T.type in('211','228') and T.is_delete<>'1'"; //226(客户)
                dynamicParams.Add("@stepcode", stepcode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                for (int i = 0; i < data.Rows.Count; i++)
@@ -1691,7 +1720,7 @@
                    rout.type = data.Rows[i]["TYPE"].ToString();
                    rout.flag = data.Rows[i]["FLAG"].ToString();
                    rout.children = new List<StepEqpCn>();
                    if (rout.code == "WX") //外协供方
                    if (rout.code == "211"|| rout.code == "228") //外协供方
                    {
                        //根据外协供方标识编码查找外协供方信息(包含已关联标识)
                        sql = @"select A.code,A.name,'W' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
@@ -1699,8 +1728,9 @@
                                left join(
                                select distinct A.eqp_code  from TFlw_Rteqp A 
                                inner join TCustomer B on A.eqp_code=B.code 
                                where B.btype=@wxcode and A.is_delete<>'1' and B.is_delete<>'1'
                                ) B on A.code=B.eqp_code where A.btype=@wxcode and A.is_delete<>'1'";
                                where A.step_code=@stepcode and B.type=@wxcode and A.is_delete<>'1' and B.is_delete<>'1'
                                ) B on A.code=B.eqp_code where A.type=@wxcode and A.is_delete<>'1'";
                        dynamicParams.Add("@stepcode", stepcode);
                        dynamicParams.Add("@wxcode", rout.code);
                        var data0 = DapperHelper.selectdata(sql, dynamicParams);
                        for (int k = 0; k < data0.Rows.Count; k++)
@@ -1933,7 +1963,6 @@
        #region[产品信息下拉框查询]
        public static ToMessage PartSelect()
        {
@@ -2001,12 +2030,12 @@
            try
            {
                //通过产品编码查找关联的工艺路线信息
                sql = @"select B.stepcode as code,B.stepname as name
                sql = @"select B.stepcode as code,B.stepname as name,B.flwtype as flag
                        from TFlw_Rtdt A
                        inner join TStep B on A.step_code=B.stepcode
                        where A.rout_code=@routecode and B.is_delete<>'1' and A.is_delete<>'1'";
                dynamicParams.Add("@routecode", routecode);
                var data = DapperHelper.select<ObjectData>(sql, dynamicParams);
                var data = DapperHelper.select<StepDefect>(sql, dynamicParams);
                mes.code = "200";
                mes.Message = "查询成功!";
                mes.data = data;
@@ -2051,29 +2080,81 @@
        #endregion
        #region[根据工序线编码查找关联设备集合]
        public static ToMessage StepSelectEqpList(string partcode, string routecode, string stepcode, int startNum, int endNum, string prop, string order)
        public static ToMessage StepSelectEqpList(string partcode, string routecode, string stepcode,string steptype, int startNum, int endNum, string prop, string order)
        {
            var dynamicParams = new DynamicParameters();
            string search = "";
            string search = "", sql = "";
            int total = 0;
            try
            {
                // --------------查询指定数据--------------
                var total = 0; //总条数
                var sql = @"select B.code as eqpcode,B.name as eqpname,B.wksp_code,T.org_name as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
                if (steptype == "Z")  //自制工序
                {
                    total = 0; //总条数
                    //sql = @"select B.code as eqpcode,B.name as eqpname,B.wksp_code,T.org_name as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
                    //        from (
                    //        select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
                    //        where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode
                    //        union all
                    //        select @partcode as materiel_code,eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
                    //        from TFlw_Rteqp where step_code=@stepcode and style='E' and @partcode+eqp_code+step_code not in(select materiel_code+eqp_code+step_code  from TPrteEqp_Stad)
                    //        ) A
                    //        left join TEqpInfo B on A.eqp_code=B.code
                    //        left join TOrganization T on B.wksp_code=T.org_code
                    //        left join TMateriel_Info C on A.materiel_code=C.partcode
                    //        where B.is_delete<>'1' and  T.is_delete<>'1' and C.is_delete<>'1' ";
                    sql = @"select B.code as eqpcode,B.name as eqpname,B.wksp_code,T.org_name as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
                            from (
                            select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
                            where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode 
                            union all
                            select @partcode as materiel_code,eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
                            from TFlw_Rteqp where step_code=@stepcode and style='E' and @partcode+eqp_code+step_code not in(select materiel_code+eqp_code+step_code  from TPrteEqp_Stad)
                            select @partcode as materiel_code,C.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
                            from TFlw_Rout A
                            inner join TFlw_Rtdt B on A.code=B.rout_code
                            left join TFlw_Rteqp C on B.step_code=C.step_code
                            where A.code=@routecode and B.step_code=@stepcode and style='E' and @partcode+A.code+C.eqp_code+B.step_code
                            not in(select materiel_code+route_code+eqp_code+step_code  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode)
                            ) A
                            left join TEqpInfo B on A.eqp_code=B.code 
                            left join TOrganization T on B.wksp_code=T.org_code 
                            left join TMateriel_Info C on A.materiel_code=C.partcode
                            where B.is_delete<>'1' and  T.is_delete<>'1' and C.is_delete<>'1' ";
                dynamicParams.Add("@partcode", partcode);
                dynamicParams.Add("@routecode", routecode);
                dynamicParams.Add("@stepcode", stepcode);
                            where B.is_delete<>'1' and  T.is_delete<>'1' and C.is_delete<>'1'";
                    dynamicParams.Add("@partcode", partcode);
                    dynamicParams.Add("@routecode", routecode);
                    dynamicParams.Add("@stepcode", stepcode);
                }
                else  //外协工序
                {
                    total = 0; //总条数
                    //sql = @"select B.code as eqpcode,B.name as eqpname,'' as wksp_code,'' as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
                    //        from (
                    //        select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
                    //        where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode
                    //        union all
                    //        select @partcode as materiel_code,eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
                    //        from TFlw_Rteqp where step_code=@stepcode and style='W' and @partcode+eqp_code+step_code not in(select materiel_code+eqp_code+step_code  from TPrteEqp_Stad)
                    //        ) A
                    //        left join TCustomer B on A.eqp_code=B.code
                    //        where B.is_delete<>'1'";
                    sql = @"select B.code as eqpcode,B.name as eqpname,'' as wksp_code,'' as wksp_name,A.eqp_value,A.stand_value,A.cavity_qty,A.unprice
                            from (
                            select materiel_code, eqp_code,eqp_value,stand_value,cavity_qty,unprice   from TPrteEqp_Stad
                            where materiel_code=@partcode  and route_code=@routecode and step_code=@stepcode
                            union all
                            select @partcode as materiel_code,C.eqp_code,'0' as eqp_value,'0' as stand_value,'0' as cavity_qty,'0' as unprice
                            from TFlw_Rout A
                            inner join TFlw_Rtdt B on A.code=B.rout_code
                            left join TFlw_Rteqp C on B.step_code=C.step_code
                            where A.code=@routecode and B.step_code=@stepcode and style='W' and @partcode+A.code+C.eqp_code+B.step_code
                            not in(select materiel_code+route_code+eqp_code+step_code  from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode)
                            ) A
                            left join TCustomer B on A.eqp_code=B.code
                            where B.is_delete<>'1'";
                    dynamicParams.Add("@partcode", partcode);
                    dynamicParams.Add("@routecode", routecode);
                    dynamicParams.Add("@stepcode", stepcode);
                }
                var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
                mes.code = "200";
                mes.Message = "查询成功!";