重工电子论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 4952|回复: 4
打印 上一主题 下一主题

[C#] 广仁 国网对接 SQL

[复制链接]

299

主题

684

帖子

6998

积分

学生管理组

Rank: 8Rank: 8

积分
6998
跳转到指定楼层
楼主
发表于 2023-7-10 00:02:23 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
[SQL] syntaxhighlighter_viewsource syntaxhighlighter_copycode
SELECT Physics2,matFactoryDate,mtsManufacturer,mtsPatch,tadQualityNum,lName,mtsNum,mfName,etName,mfSpec,
C,Si,Mn,P,S,V,Nb,Ti,YieldPoint,TensileStrength,Elongation,ImpactTest,ImpactTest1,ImpactTest2,mtDate as DETECTION_TIME,ItemStr3 as DETECTION_USER
FROM [fzyk1].[fzyk].dbo.q_materialTestReportView 
where  WriteDate > DATEADD(mm, -6, getdate()) and mfSpec='∠220*26'
GROUP BY Physics2,matFactoryDate,mtsManufacturer,mtsPatch,tadQualityNum,lName,mtsNum,mfName,etName,mfSpec,
C,Si,Mn,P,S,V,Nb,Ti,YieldPoint,TensileStrength,Elongation,ImpactTest,ImpactTest1,ImpactTest2,mtDate,ItemStr3 ORDER BY mtDate desc


SELECT * FROM [fzyk1].[fzyk].dbo.f_taskpart a INNER JOIN [fzyk1].[fzyk].dbo.F_MaterialDetail b ON a.mdid=b.mdID WHERE  a.scdID=45059 ORDER BY a.tpsectName,tpPartsID
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

299

主题

684

帖子

6998

积分

学生管理组

Rank: 8Rank: 8

积分
6998
5#
 楼主| 发表于 2024-10-28 22:22:57 | 只看该作者
[JavaScript] syntaxhighlighter_viewsource syntaxhighlighter_copycode
        $("#btn_YJPL").on("click", function () {
            loading = layer.msg('正在生成', { icon: 16, shade: 0.3, time: 0 });
            layer.confirm('<span class="layui-icon"></span>' + '准备一键配料,请确保还有未配零件', {
                btn: ['确定', '取消'] //可以无限个按钮
                , btn1: function (index) {

                    //首先获取材料规格
                    admin.req({
                        url: '/api/WH_Matching/YCPL_YJPL',  //一次配料 提取
                        contentType: 'application/x-www-form-urlencoded',
                        dataType: 'json',
                        async: true,
                        data: { "TLB_PCID": TLB_PCID, "YCPLID": PLID },
                        type: 'post',
                        done: function (res) {
                            if (res.msg == "OK") {


                                layer.msg("成功");
                                layer.close(loading);
                                //打开自动配料对话框
                                index2 = layer.open({
                                    type: 1, // page 层类型,其他类型详见「基础属性」
                                    area: ['1050px', '700px'],
                                    title: ['一键配料方案', 'font-size:14px;'],
                                    offset: 'auto',
                                    content: $("#Div_YJPL"),
                                    success: function (layero, index, that) {
                                        layer.full(index);
                                        //YJPL_FA = [];
                                        //YJPL_FA = res.data;
                                        table.reload("Table_YJPL_LS_GG", { where: { SortName: "ID", Order: "ASC", Condition: " YCPLID=" + PLID } });
                                        Get_ZHLYL()
                                    },
                                    cancel: function (index, layero, that) {
                                        //$(document).unbind("contextmenu", "");
                                        //return false; // 阻止默认关闭行为
                                    }
                                });


                            }
                            else {
                                layer.msg(res.msg);
                                layer.close(loading);
                            }
                        }
                    })
                }
                , btn2: function (index) {
                    //按钮【按钮三】的回调
                    //alert("2");
                }
            });


        })


[C#] syntaxhighlighter_viewsource syntaxhighlighter_copycode
        /// <summary>
        /// 一次配料-一键配料
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Route("YCPL_YJPL")]
        public IHttpActionResult YCPL_YJPL()
        {
            HttpRequest Request = HttpContext.Current.Request;
            
            Dictionary<string, object> result = new Dictionary<string, object>();
            //获取料单
            string YCPLID = Request.Form["YCPLID"] == null ? null : Request.Form["YCPLID"].ToString();

            string sql = "";

            //BOM单提取详情
            t_CLB_YCPL_TQXX fields = new t_CLB_YCPL_TQXX();
            System.Reflection.PropertyInfo[] properties = fields.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
            string strFields = "";
            string ClassName = fields.GetType().Name;
            foreach (var item in properties)
            {
                strFields += item.Name + ",";
            }
            strFields = strFields.Substring(0, strFields.Length - 1);
            string[] filed = strFields.Split(',');
            sql = "select * from t_clb_ycpl_tqxx where clmc='角钢' and ycplid=" + YCPLID;
            var TQXXList = dao.GetList(sql, filed);
            if (TQXXList.Find(t => int.Parse(t["SYSL_LS"].ToString()) > 0) == null)
            {
                result.Add("code", 0);
                result.Add("msg", "没有可配置的零部件");
                return Json(result);
            } 


            //获取原材料信息
            sql = "select * from t_clb_ycpl_lxkcgz";
            var TempLXGCGZ = dao.GetList(sql, new string[] { "ID", "ZK_DY", "ZK_XY", "DKKD", "DTCD", "ZXKYCD", "LXKCC" });
            for (int i = 0; i < TempLXGCGZ.Count; i++)
            {
                string LXKCC = TempLXGCGZ[i]["LXKCC"].ToString();

                string[] str = LXKCC.Split(new char[] { '/' });
                List<Dictionary<string, object>> LXCKList = new List<Dictionary<string, object>>();
                for (int j = 0; j < str.Length; j++)
                {
                    Dictionary<string, object> TempMap = new Dictionary<string, object>()
                    {
                        ["CD"] = double.Parse(str[j]) * 1000,
                        ["KY"] = 9999,
                    };
                    LXCKList.Add(TempMap);
                }
                TempLXGCGZ[i].Add("CDMX", LXCKList);
            }


            //材质规格归类
            var ALLBOMList = TQXXList;
            var GroupList = BOM2GroupList(ALLBOMList);
            var BOMSArray = BOMS2Array(ALLBOMList, GroupList);

            //验证行数是否正确
            int num = 0;
            for (int i = 0; i < BOMSArray.Count; i++)
            {
                List<Dictionary<string, object>> tempList = BOMSArray[i] as List<Dictionary<string, object>>;
                num += tempList.Count;
            }
            if (num != ALLBOMList.Count)
            {
                result.Add("code", 0);
                result.Add("msg", "分组失败,行数有问题");
                return Json(result);
            }

            
            BOMSArray = BOMSArray2Sort(BOMSArray);

            List<WH_Matching> PLList = new List<WH_Matching>();   //配料列表
            List<Dictionary<string, object>> PLCWList = new List<Dictionary<string, object>>();     //配料错误的List;
            //对每一种规格进行配料
            foreach (var item in BOMSArray)
            {
                var tempItemList = item as List<Dictionary<string, object>>;
                //获取原材料长度
                int GG_ZK = int.Parse(tempItemList[0]["GG_ZK"].ToString());
                string CZ = tempItemList[0]["CZ"].ToString();
                string GG = tempItemList[0]["GG"].ToString();
                int DK = int.Parse(TempLXGCGZ.Find(t => int.Parse(t["ZK_DY"].ToString()) < GG_ZK && GG_ZK <= int.Parse(t["ZK_XY"].ToString()))["DKKD"].ToString());
                int DTCD = int.Parse(TempLXGCGZ.Find(t => int.Parse(t["ZK_DY"].ToString()) < GG_ZK && GG_ZK <= int.Parse(t["ZK_XY"].ToString()))["DTCD"].ToString());
                int ZDKS = 3;               //理论最大开数


                var YCLCDList = TempLXGCGZ.Find(t => int.Parse(t["ZK_DY"].ToString()) < GG_ZK && GG_ZK <= int.Parse(t["ZK_XY"].ToString()))["CDMX"] 
                    as List<Dictionary<string, object>>;



                int LoopCount = 0;
                while (true)
                {
                    //防止死循环,这里需要控制while循环最大次数,这里最大次数应该不大于 部件数量ALLBOMList.Count
                    LoopCount++;
                    if (LoopCount > 100000)
                    {
                        result.Add("code", 0);
                        result.Add("msg", "error:配料循环次数超过部件数量");
                        return Json(result);
                        //break;
                    }

                    //找到一个需要配料的件 用多个原材料长度去配
                    if (tempItemList.Find(x => int.Parse(x["SYSL"].ToString()) > 0) != null)
                    {
                        List<WH_Matching> PLJGList = new List<WH_Matching>(); 
                        for (int i_YCLCD = 0; i_YCLCD < YCLCDList.Count; i_YCLCD++)
                        {
                            WH_Matching C_BJH = new WH_Matching();      //定义一个配料类
                            int KS = 0;  //开数   最多3开
                            int YCLCD = int.Parse(YCLCDList[i_YCLCD]["CD"].ToString());     //长度余量
                            int tempCDYL = YCLCD;     //长度余量

                            //开始配料
                            //初始化原材料参数
                            C_BJH.PM = "角钢";
                            C_BJH.CZ = CZ;
                            C_BJH.GG = GG;
                            C_BJH.CD = YCLCD;
                            C_BJH.JG_CD = DTCD;
                            C_BJH.DK_CD = DK;

                            //选中一个件 且从长度最大的那个件选起走 而且是必选的件 作为配料表第 1 个件
                            Dictionary<string, object> BJH_Map = new Dictionary<string, object>();
                            BJH_Map = tempItemList.Find(x => int.Parse(x["SYSL"].ToString()) > 0);
                            int BJH_num = int.Parse(BJH_Map["SYSL"].ToString());

                            //这里搜索原材料长度  第一个件能否配  默认从还剩的 最长的那个件往下取
                            if ((tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD) > 0)
                            {
                                BJH_num -= 1;
                                tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //第一个件必然配上
                                C_BJH.BJH_1 = BJH_Map["BJH"].ToString();
                                C_BJH.BJH_1_DM = BJH_Map["DM"].ToString();
                                C_BJH.BJH_1_CD = int.Parse(BJH_Map["CD"].ToString());
                                C_BJH.BJH_1_SL += 1;

                                //改写剩余件号数量
                                BJH_Map["SYSL"] = BJH_num;
                                KS += 1;
                                C_BJH.Index = 1;

                                PLJGList.Add(C_BJH);        //把部件号加到PLJG里面
                            }
                            else  //该原材料长度不够配当前最长的一根件,需要更换
                            {
                                continue;
                            }

                            //下面开始循环配料剩余的
                            for (int i = 0; i < tempItemList.Count; i++)
                            {
                                BJH_num = int.Parse(tempItemList[i]["SYSL"].ToString());//获取剩余件号
                                if (BJH_num <= 0)
                                {
                                    continue;   //说明是0,循环到下一个件号
                                }
                                else  //如果能进入该循环,必有数量大于0的
                                {
                                    BJH_Map = tempItemList[i];  //取出当前件号
                                                                //检查剩余长度是否添加到当前材料上
                                    if ((tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD) > 0)
                                    {
                                        //检查当前部件名是否已经存在,在当前材料上  比较部件号和段名
                                        switch (C_BJH.Index)
                                        {
                                            case 1:     //在第1开位置
                                                if (C_BJH.BJH_1 == BJH_Map["BJH"].ToString() && C_BJH.BJH_1_DM == BJH_Map["DM"].ToString()) //同件号
                                                {
                                                    BJH_num -= 1;
                                                    tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //获得剩余长度
                                                    C_BJH.BJH_1_SL += 1;
                                                    BJH_Map["SYSL"] = BJH_num;

                                                }
                                                else  //存在不同的件号  需要把配料放到第2开的位置
                                                {
                                                    if (ZDKS == 2 || ZDKS == 3)
                                                    {
                                                        BJH_num -= 1;
                                                        tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //第一个件必然配上
                                                        C_BJH.BJH_2 = BJH_Map["BJH"].ToString();
                                                        C_BJH.BJH_2_DM = BJH_Map["DM"].ToString();
                                                        C_BJH.BJH_2_CD = int.Parse(BJH_Map["CD"].ToString());
                                                        C_BJH.BJH_2_SL += 1;

                                                        //改写剩余件号数量
                                                        BJH_Map["SYSL"] = BJH_num;
                                                    }
                                                    KS += 1;
                                                    C_BJH.Index = 2;
                                                }
                                                i = -1;
                                                break;
                                            case 2:     //在第2开位置
                                                if (C_BJH.BJH_1 == BJH_Map["BJH"].ToString() && C_BJH.BJH_1_DM == BJH_Map["DM"].ToString())
                                                {
                                                    BJH_num -= 1;
                                                    tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //获得剩余长度
                                                    C_BJH.BJH_1_SL += 1;
                                                    BJH_Map["SYSL"] = BJH_num;
                                                }
                                                else if (C_BJH.BJH_2 == BJH_Map["BJH"].ToString() && C_BJH.BJH_2_DM == BJH_Map["DM"].ToString()) //同件号
                                                {
                                                    if (ZDKS == 2 || ZDKS == 3)
                                                    {
                                                        BJH_num -= 1;
                                                        tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //获得剩余长度
                                                        C_BJH.BJH_2_SL += 1;
                                                        BJH_Map["SYSL"] = BJH_num;
                                                    }
                                                }
                                                else    //存在不同的件号  需要把配料放到第3开的位置
                                                {
                                                    if (ZDKS == 3)
                                                    {
                                                        BJH_num -= 1;
                                                        tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //第一个件必然配上
                                                        C_BJH.BJH_3 = BJH_Map["BJH"].ToString();
                                                        C_BJH.BJH_3_DM = BJH_Map["DM"].ToString();
                                                        C_BJH.BJH_3_CD = int.Parse(BJH_Map["CD"].ToString());
                                                        C_BJH.BJH_3_SL += 1;

                                                        //改写剩余件号数量
                                                        BJH_Map["SYSL"] = BJH_num;

                                                    }
                                                    KS += 1;
                                                    C_BJH.Index = 3;
                                                }
                                                i = -1;
                                                break;
                                            case 3:     //在第3开位置
                                                if (C_BJH.BJH_1 == BJH_Map["BJH"].ToString() && C_BJH.BJH_1_DM == BJH_Map["DM"].ToString())
                                                {
                                                    BJH_num -= 1;
                                                    tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //获得剩余长度
                                                    C_BJH.BJH_1_SL += 1;
                                                    BJH_Map["SYSL"] = BJH_num;
                                                }
                                                else if (C_BJH.BJH_2 == BJH_Map["BJH"].ToString() && C_BJH.BJH_2_DM == BJH_Map["DM"].ToString()) //同件号
                                                {
                                                    if (ZDKS == 2 || ZDKS == 3)
                                                    {
                                                        BJH_num -= 1;
                                                        tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //获得剩余长度
                                                        C_BJH.BJH_2_SL += 1;
                                                        BJH_Map["SYSL"] = BJH_num;
                                                    }
                                                }
                                                else if (C_BJH.BJH_3 == BJH_Map["BJH"].ToString() && C_BJH.BJH_3_DM == BJH_Map["DM"].ToString()) //同件号
                                                {
                                                    if (ZDKS == 3)
                                                    {
                                                        BJH_num -= 1;
                                                        tempCDYL = tempCDYL - int.Parse(BJH_Map["CD"].ToString()) - DK - DTCD;    //获得剩余长度
                                                        C_BJH.BJH_3_SL += 1;
                                                        BJH_Map["SYSL"] = BJH_num;

                                                    }
                                                    i = -1;
                                                }
                                                else    //存在不同的件号  需要把配料放到第4开的位置
                                                {
                                                    //第4开暂时不开放,
                                                }
                                                break;
                                            default:
                                                break;
                                        }
                                    }
                                }
                            }
                            //循环完了,确认一个配料方案
                            //计算余料长度
                            C_BJH.YLCD = tempCDYL;
                            C_BJH.LYL = (double)(C_BJH.CD - C_BJH.YLCD) / (double)(C_BJH.CD);

                            //返还剩余数量
                            if (C_BJH.BJH_1_SL>0)
                            {
                                int tempNum = int.Parse(tempItemList.Find(t => t["DM"].ToString() == C_BJH.BJH_1_DM && t["BJH"].ToString() == C_BJH.BJH_1)["SYSL"].ToString())
                                    + C_BJH.BJH_1_SL;
                                tempItemList.Find(t => t["DM"].ToString() == C_BJH.BJH_1_DM && t["BJH"].ToString() == C_BJH.BJH_1)["SYSL"] = tempNum;
                            }
                            //返还剩余数量
                            if (C_BJH.BJH_2_SL > 0)
                            {
                                int tempNum = int.Parse(tempItemList.Find(t => t["DM"].ToString() == C_BJH.BJH_2_DM && t["BJH"].ToString() == C_BJH.BJH_2)["SYSL"].ToString())
                                    + C_BJH.BJH_2_SL;
                                tempItemList.Find(t => t["DM"].ToString() == C_BJH.BJH_2_DM && t["BJH"].ToString() == C_BJH.BJH_2)["SYSL"] = tempNum;
                            }
                            //返还剩余数量
                            if (C_BJH.BJH_3_SL > 0)
                            {
                               int tempNum =int.Parse(tempItemList.Find(t => t["DM"].ToString() == C_BJH.BJH_3_DM && t["BJH"].ToString() == C_BJH.BJH_3)["SYSL"].ToString()) 
                                    + C_BJH.BJH_3_SL;
                               tempItemList.Find(t => t["DM"].ToString() == C_BJH.BJH_3_DM && t["BJH"].ToString() == C_BJH.BJH_3)["SYSL"] = tempNum;
                            }



                        }
                        //如果最终配料方案List里面配料方案个数为0,则表明该物料不能配出来
                        if (PLJGList.Count  == 0)
                        {
                            var TempMap = tempItemList.Find(x => int.Parse(x["SYSL"].ToString()) > 0);
                            Dictionary<string, object> PLCWMap = new Dictionary<string, object>(TempMap);
                            PLCWList.Add(PLCWMap);
                            tempItemList.Remove(TempMap);
                        }

                        //选择一个临时配料方案 到最终的配料方案里面
                        var PLFAMap = PLJGList.OrderBy(t => t.YLCD).First();
                        PLList.Add(PLFAMap);

                        //在方案里面减去剩余数量
                        if (PLFAMap.BJH_1_SL > 0)
                        {
                            int tempSL = int.Parse(tempItemList.Find(t => t["DM"].ToString() == PLFAMap.BJH_1_DM && t["BJH"].ToString() == PLFAMap.BJH_1)["SYSL"].ToString());
                            tempSL = tempSL - PLFAMap.BJH_1_SL;
                            tempItemList.Find(t => t["DM"].ToString() == PLFAMap.BJH_1_DM && t["BJH"].ToString() == PLFAMap.BJH_1)["SYSL"] = tempSL;
                        }
                        if (PLFAMap.BJH_2_SL > 0)
                        {
                            int tempSL = int.Parse(tempItemList.Find(t => t["DM"].ToString() == PLFAMap.BJH_2_DM && t["BJH"].ToString() == PLFAMap.BJH_2)["SYSL"].ToString());
                            tempSL = tempSL - PLFAMap.BJH_2_SL;
                            tempItemList.Find(t => t["DM"].ToString() == PLFAMap.BJH_2_DM && t["BJH"].ToString() == PLFAMap.BJH_2)["SYSL"] = tempSL;
                        }
                        if (PLFAMap.BJH_3_SL > 0)
                        {
                            int tempSL = int.Parse(tempItemList.Find(t => t["DM"].ToString() == PLFAMap.BJH_3_DM && t["BJH"].ToString() == PLFAMap.BJH_3)["SYSL"].ToString());
                            tempSL = tempSL - PLFAMap.BJH_3_SL;
                            tempItemList.Find(t => t["DM"].ToString() == PLFAMap.BJH_3_DM && t["BJH"].ToString() == PLFAMap.BJH_3)["SYSL"] = tempSL;
                        }



                    }
                    else    // 待配数量全部都为0了,则跳出循环
                    {
                        break;
                    }
                }
            }

            List<WH_Matching> DistinctList = new List<WH_Matching>();
            for (int i = 0; i < PLList.Count; i++)
            {
                if (DistinctList.Find(x =>
                x.BJH_1 == PLList[i].BJH_1 && x.BJH_1_CD == PLList[i].BJH_1_CD && x.BJH_1_DM == PLList[i].BJH_1_DM && x.BJH_1_SL == PLList[i].BJH_1_SL
                && x.BJH_2 == PLList[i].BJH_2 && x.BJH_2_CD == PLList[i].BJH_2_CD && x.BJH_2_DM == PLList[i].BJH_2_DM && x.BJH_2_SL == PLList[i].BJH_2_SL
                && x.BJH_3 == PLList[i].BJH_3 && x.BJH_3_CD == PLList[i].BJH_3_CD && x.BJH_3_DM == PLList[i].BJH_3_DM && x.BJH_3_SL == PLList[i].BJH_3_SL
                ) == null)
                {
                    DistinctList.Add(PLList[i]);
                }
                else
                {
                    DistinctList.Find(x =>
                    x.BJH_1 == PLList[i].BJH_1 && x.BJH_1_CD == PLList[i].BJH_1_CD && x.BJH_1_DM == PLList[i].BJH_1_DM && x.BJH_1_SL == PLList[i].BJH_1_SL
                    && x.BJH_2 == PLList[i].BJH_2 && x.BJH_2_CD == PLList[i].BJH_2_CD && x.BJH_2_DM == PLList[i].BJH_2_DM && x.BJH_2_SL == PLList[i].BJH_2_SL
                    && x.BJH_3 == PLList[i].BJH_3 && x.BJH_3_CD == PLList[i].BJH_3_CD && x.BJH_3_DM == PLList[i].BJH_3_DM && x.BJH_3_SL == PLList[i].BJH_3_SL
                    ).SL++;
                }
            }


            //写入数据库操作
            sql = "delete from t_clb_ycpl_plfa_ls where ycplid=" + YCPLID;
            SqlConn.execute(sql);

            for (int i = 0; i < DistinctList.Count; i++)
            {

                Dictionary<string, object> SaveMap = new Dictionary<string, object>()
                {
                    ["YCPLID"]=YCPLID,
                    ["YCLCD"] = DistinctList[i].CD,
                    ["YCLSL"] = DistinctList[i].SL,
                    ["CZ"] = DistinctList[i].CZ,
                    ["GG"] = DistinctList[i].GG,
                    ["JG_CD"] = DistinctList[i].JG_CD,
                    ["DK_CD"] = DistinctList[i].DK_CD,
                    ["BJH_1"] = DistinctList[i].BJH_1,
                    ["BJH_1_CD"] = DistinctList[i].BJH_1_CD,
                    ["BJH_1_SL"] = DistinctList[i].BJH_1_SL,
                    ["BJH_1_DM"] = DistinctList[i].BJH_1_DM,
                    ["BJH_2"] = DistinctList[i].BJH_2,
                    ["BJH_2_CD"] = DistinctList[i].BJH_2_CD,
                    ["BJH_2_SL"] = DistinctList[i].BJH_2_SL,
                    ["BJH_2_DM"] = DistinctList[i].BJH_2_DM,
                    ["BJH_3"] = DistinctList[i].BJH_3,
                    ["BJH_3_CD"] = DistinctList[i].BJH_3_CD,
                    ["BJH_3_SL"] = DistinctList[i].BJH_3_SL,
                    ["BJH_3_DM"] = DistinctList[i].BJH_3_DM,
                    ["LYL"]=DistinctList[i].LYL,
                    ["SYCD"]=DistinctList[i].YLCD
                };
                dao.save("t_clb_ycpl_plfa_ls", SaveMap);


                //sql="insert into()"



            }

            result.Add("code", 0);
            result.Add("msg", "OK");
            //result.Add("data", DistinctList);
            return Json(result);


        }



回复 支持 反对

使用道具 举报

299

主题

684

帖子

6998

积分

学生管理组

Rank: 8Rank: 8

积分
6998
地板
 楼主| 发表于 2024-7-1 16:54:01 | 只看该作者
[SQL] syntaxhighlighter_viewsource syntaxhighlighter_copycode
SELECT gadQualityNum, gadHeatNum, barCode into #tmp FROM W_StockInDetail wsid INNER JOIN W_StockIn si ON si.siID = wsid.siID  INNER JOIN B_InOutType iot ON iot.iotID = si.iotID LEFT OUTER JOIN C_GoodsAcceptDetail cgad ON wsid.gadID = cgad.gadID WHERE Tag = '原材料' AND ISNULL(siZi,'') = '' AND iotName <> '退货出库'  



SELECT sidOldCode,'有' AS ifBack into #tmp2 FROM W_StockInDetail Group BY sidOldCode 

SELECT sodpaID, wsod.sodID,sodWeight,sodApplyCount,sodApplyWeight,sodPlanPrice,sodPlanMoney ,sodPrice,sodMoney,sodPriceNoTax,sodMoneyNoTax,sodRemark,wsod.soNum,iotID,soPickDept,soPickPerson,soTeam ,CASE sodCount WHEN 0 THEN 0 ELSE sodWeight/sodCount END AS sUnitWeight,CASE soDate WHEN '1900-1-1' THEN '' ELSE  CONVERT(VARCHAR(10),soDate,120) END AS soDate,soRed,Writer,sodProject,sodTowerType,sodTaskNum,sodProduceNum,sodcNum,CASE wsod.WriteDate WHEN '1900-1-1' THEN '' ELSE  CONVERT(VARCHAR(10),wsod.WriteDate,120) END AS WriteDate,soID,Locker,CASE wsod.LockDate WHEN '1900-1-1' THEN '' ELSE  CONVERT(VARCHAR(10),wsod.LockDate,120) END AS LockDate,wsod.State,soRemark,wsod.mfName,wsod.barCode,wsod.mfSpec,wsod.mfNum,wsod.gsName,wsod.zName,wsod.wID,wsod.wName,wsod.indexNum,wsod.iotName,wsod.mfID,wsod.etName,wsod.lName,wsod.mfUnit,wsod.mcName,sodLength,sodWidth,sodCount,Keeper,CASE OutDate WHEN '1900-1-1' THEN '' ELSE  CONVERT(VARCHAR(10),OutDate,120) END AS OutDate,sodDiameter,sodThick,sodRealWeight,sodUse ,wsod.mcNum,wsod.mfQuickNum,sodAccountType,mfcCode ,sodpaState ,approveState,CASE sodBackTime WHEN '1900-1-1' THEN '' ELSE  CONVERT(VARCHAR(10),sodBackTime,120) END AS sodBackTime,Valid,sodApplyID,sodrddDeal,sodrddPriceNew,sodUseDept ,gadQualityNum,gadHeatNum,ISNULL(ifBack,'') AS ifBack,isnull(t.soNum,'') as soApplyNum,ptTaskType into #tmp3  FROM W_StockOutView AS wsod LEFT OUTER JOIN  #tmp cgad ON wsod.barCode = cgad.barCode LEFT OUTER JOIN #tmp2  wsid2 ON wsid2 .sidOldCode = wsod.barCode  left join ( select soNum,sodid from W_StockPickDetail wspd left join W_StockPick wsp on wspd.soID = wsp.soID) t on t.sodid = wsod.sodapplyid  WHERE (1=1)  AND soApply = 0 AND Tag = '原材料'  AND Tag1 = ''  AND  sodproducenum LIKE '%20231209-01%' ORDER BY CASE Writer WHEN '' THEN 1 ELSE 2 END ASC, soDate DESC,sodID DESC 

select * from #tmp3  

drop table #tmp  

drop table #tmp2  

drop table #tmp3 


找钢材报告
[SQL] syntaxhighlighter_viewsource syntaxhighlighter_copycode
SELECT Physics2,matFactoryDate,mtsManufacturer,mtsPatch,tadQualityNum,lName,mtsNum,mfName,etName,mfSpec, C,Si,Mn,P,S,V,Nb,Ti,Cr,YieldPoint,TensileStrength,Elongation,ImpactTest,ImpactTest1,ImpactTest2,mtDate as DETECTION_TIME,ItemStr3 as DETECTION_USER FROM [fzyk1].[fzyk].dbo.q_materialTestReportView  where mtDate > DATEADD(mm, -60, getdate()) GROUP BY Physics2,matFactoryDate,mtsManufacturer,mtsPatch,tadQualityNum,lName,mtsNum,mfName,etName,mfSpec, C,Si,Mn,P,S,V,Nb,Ti,Cr,YieldPoint,TensileStrength,Elongation,ImpactTest,ImpactTest1,ImpactTest2,mtDate,ItemStr3 ORDER BY mtDate desc
回复 支持 反对

使用道具 举报

299

主题

684

帖子

6998

积分

学生管理组

Rank: 8Rank: 8

积分
6998
板凳
 楼主| 发表于 2024-4-3 10:40:40 | 只看该作者
回复 支持 反对

使用道具 举报

299

主题

684

帖子

6998

积分

学生管理组

Rank: 8Rank: 8

积分
6998
沙发
 楼主| 发表于 2023-11-1 23:23:11 | 只看该作者
本帖最后由 李维强-15级 于 2023-11-1 23:24 编辑

添加锌锅温度

  1. BEGIN

  2. SELECT * INTO #myTemp from (SELECT TOP 40000 row_number() over(ORDER BY feedingTime desc) as Num, machineName,feedingTime,[Value],WriteTime FROM [FZYK1].[superfzyk].dbo.TemperatureOfGalvanize ) as a;

  3. INSERT INTO  [FZYK1].[superfzyk].dbo.TemperatureOfGalvanize (machineName,feedingTime,[Value],WriteTime)  SELECT machineName, DATEADD(minute,Num+Num-1, feedingTime) as feedingTime,[Value],DATEADD(minute,Num+Num-1, WriteTime) as WriteTime FROM #myTemp;

  4. DROP TABLE #myTemp;

  5. end
复制代码

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|cqutlab ( 渝ICP备15004556号

GMT+8, 2024-12-22 01:06 , Processed in 0.162516 second(s), 28 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表