yl
2023-03-22 e235d94e5987d43117439837e3a0ee2e316e91d2
VueWebApi/DLL/DAL/AppPurchManagementDAL.cs
@@ -143,10 +143,10 @@
                    mes.data = null;
                    return mes;
                }
                //Lambda表达式过滤获取预计到货日期、部门、供应商
                string hacceptdate = json.Select(p => p.hacceptdate).ToList().Distinct().ToString(); //预计到货日期
                string dpartment = json.Select(p => p.hdepartmentcode).ToList().Distinct().ToString(); //部门
                string customercode = json.Select(p => p.hcustomercode).ToList().Distinct().ToString(); //供应商
                //Lambda表达式过滤获取预计到货日期、部门、供应商取第一个
                string hacceptdate = json.Select(p => p.hacceptdate).Distinct().ToList().First().ToString(); //预计到货日期
                string dpartment = json.Select(p => p.hdepartmentcode).Distinct().ToList().First().ToString(); //部门
                string customercode = json.Select(p => p.hcustomercode).Distinct().ToList().First().ToString(); //供应商
                //写入采购到货单主表
                sql = @"insert into T_PurchaseArrivalOrder(hbillno,hdate,hacceptdate,hbillstaus,hdepartmentcode,hcustomercode,hsourcebillno,lm_user,lm_date) 
                        values(@hbillno,@hdate,@hacceptdate,@hbillstaus,@hdepartmentcode,@hcustomercode,@hsourcebillno,@lm_user,@lm_date)";
@@ -157,7 +157,7 @@
                    {
                        hbillno = djwo,
                        hdate = DateTime.Now.ToString(),
                        hacceptdate = Convert.ToDateTime(hacceptdate),
                        hacceptdate =hacceptdate==""?null:hacceptdate,
                        hbillstaus = orderstaus,
                        hdepartmentcode = dpartment,
                        hcustomercode = customercode,
@@ -170,7 +170,7 @@
                for (int i = 0; i < json.Count; i++)
                {
                    //写入采购到货单子表
                    sql = @"insert into T_PurchaseArrivalOrder_sub(hbillno,hpartcode,hplanqty,hqty,hacceptdate,hischeck,hbatchno)
                    sql = @"insert into T_PurchaseArrivalOrder_sub(hbillno,rownumber,hpartcode,hplanqty,hqty,hacceptdate,hischeck,hbatchno)
                        values(@hbillno,@hpartcode,@hplanqty,@hqty,@hacceptdate,@hischeck,@hbatchno)";
                    list.Add(new
                    {
@@ -178,10 +178,11 @@
                        parm = new
                        {
                            hbillno = djwo,
                            rownumber=json[i].rownumber,
                            hpartcode = json[i].hpartcode,
                            hplanqty = decimal.Parse(json[i].hplanqty),
                            hqty = decimal.Parse(json[i].hqty),
                            hacceptdate = Convert.ToDateTime(hacceptdate),
                            hacceptdate = hacceptdate == "" ? null : hacceptdate,
                            hischeck = json[i].hischeck,
                            hbatchno = json[i].hbatchno
                        }
@@ -248,7 +249,7 @@
                    mes.code = "200";
                    mes.count = 0;
                    mes.Message = "采购到货成功!";
                    mes.data = null;
                    mes.data = djwo;
                }
                else
                {
@@ -268,5 +269,139 @@
            return mes;
        }
        #endregion
        #region[采购入库选择有到货采购订单]
        public static ToMessage MesAppPurchInStorSelectCGOrder()
        {
            string sql = "";
            var dynamicParams = new DynamicParameters();
            try
            {
                //有到货或者部分入库的采购订单
                sql = @"select distinct A.ordercode   from T_PurchaseOrder A
                        inner join T_PurchaseArrivalOrder B on A.ordercode=B.hsourcebillno
                        where B.hbillstaus in('BINARIVE','INARIVE','BINSTOG')";
                var data = DapperHelper.selecttable(sql);
                if (data.Rows.Count > 0)
                {
                    mes.code = "200";
                    mes.Message = "success!";
                    mes.data = data;
                }
                else
                {
                    mes.code = "300";
                    mes.Message = "无可执行订单!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[选择采购订单带出订单下有到货的物料信息]
        public static ToMessage MesAppPurchInStorSelectCGOrderPart(string ordercode)
        {
            string sql = "";
            var dynamicParams = new DynamicParameters();
            try
            {
                //选择采购订单带出订单下有到货的物料信息
                sql = @"select A.ordercode,M.partcode,M.partname,M.partspec,avg(S.hplanqty) as hplanqty,sum(S.hqty) as hqty
                        from T_PurchaseOrder A
                        inner join T_PurchaseArrivalOrder B on A.ordercode=B.hsourcebillno
                        inner join T_PurchaseArrivalOrder_sub S on B.hbillno=S.hbillno
                        left  join TMateriel_Info M on S.hpartcode=M.partcode
                        where B.hbillstaus in('BINARIVE','INARIVE','BINSTOG') and A.ordercode=@ordercode
                        group by A.ordercode,M.partcode,M.partname,M.partspec";
                dynamicParams.Add("@ordercode", ordercode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0)
                {
                    mes.code = "200";
                    mes.Message = "success!";
                    mes.data = data;
                }
                else
                {
                    mes.code = "300";
                    mes.Message = "当前订单无可执行物料!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[采购入库扫描标签条码带出到货单信息]
        public static ToMessage MesAppPurchInStorScanLabCode(string labcode,string ordercode)
        {
            string sql = "";
            var dynamicParams = new DynamicParameters();
            try
            {
                //判断条码状态
                mes = LabCodeStatusMessage.LabCodeStatus("2060", "1103",labcode);//功能编号、单据类型编码、标签编码
                if (mes.code == "300")
                {
                    return mes;
                }
                //判断扫描标签是否为当前选择采购订单下的到货单所生成标签
                sql = @"select *   from T_BarCodeBill where hsourcebillno=@ordercode";
                dynamicParams.Add("@ordercode", ordercode);
                var data0 = DapperHelper.selectdata(sql, dynamicParams);
                if (data0.Rows.Count < 0)
                {
                    mes.code = "300";
                    mes.Message = "当前条码不是采购订单【"+ ordercode + "】生成条码!";
                    mes.data = null;
                    return mes;
                }
                //根据标签条码查询到货生成的标签信息
                sql = @"select A.hbarcode,A.hbillno,A.hqty,A.hcustomercode,C.name as hcustomername,A.hbatchno,A.qualitystatus
                        from T_BarCodeBill A
                        left join TCustomer C on A.hcustomercode=C.code
                        where A.hbarcode=@labcode";
                dynamicParams.Add("@labcode", labcode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                if (data.Rows.Count > 0)
                {
                    mes.code = "200";
                    mes.Message = "success!";
                    mes.data = data;
                }
                else
                {
                    mes.code = "300";
                    mes.Message = "标签信息不存在!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
    }
}