Ejemplo n.º 1
0
        /// <summary>
        /// 获取出货牌
        /// </summary>
        /// <param name="jsondata"></param>
        /// <returns></returns>
        public async Task <MessageModel <GetShipCardReturns> > GetShipCard(GetShipCardParam jsondata)
        {
            MessageModel <GetShipCardReturns> message = new MessageModel <GetShipCardReturns>();
            GetShipCardReturns model       = new GetShipCardReturns();
            string             productCode = string.Empty;

            //if (jsondata.productType == "正极打胶")
            //{
            //    productCode = "ZD";
            //}
            //if(jsondata.productType =="负极打胶")
            //{
            //    productCode = "FD";
            //}
            productCode = jsondata.device_sn.Substring(0, 3);
            GlueModel fistResult = await _dal.GetSerialnumber(jsondata);

            //fistResult = _mapper.Map<GlueModel>(jsondata);
            if (fistResult != null)
            {
                fistResult.sys_Date = fistResult.sys_Date.Replace("/", "");
                int intDevice = jsondata.device_sn.Length;
                if (fistResult.s_date == fistResult.sys_Date)
                {
                    fistResult.s_date   = fistResult.s_date.Replace("/", "");
                    fistResult.strLSH   = (fistResult.s_number.TrimStart('0').ObjToInt() + 1).ToString().PadLeft(2, '0');
                    fistResult.shipCard = productCode + fistResult.s_date + jsondata.device_sn.Substring(intDevice - 2, 2) + fistResult.strLSH;
                }
                else
                {
                    fistResult.strLSH   = "01";
                    fistResult.shipCard = productCode + fistResult.sys_Date + jsondata.device_sn.Substring(intDevice - 2, 2) + fistResult.strLSH;
                }
                GlueSubmitParam gpModel = new GlueSubmitParam();
                gpModel = _mapper.Map <GlueSubmitParam>(fistResult);
                await _dal.UpdateShipcartCode(gpModel);
            }
            else
            {
                await _dal.InsertSerialnumber(jsondata);

                await GetShipCard(jsondata);
            }
            model            = _mapper.Map <GetShipCardReturns>(fistResult);
            message.success  = true;
            message.msg      = "";
            message.response = model;
            return(message);
        }
        /// <summary>
        /// 获取出货牌
        /// </summary>
        /// <param name="model">{productType,device_sn}</param>
        /// <returns></returns>
        public async Task <MessageModel <GetShipCardReturns> > GetShipCarts(GetShipCardParam model)
        {
            MessageModel <GetShipCardReturns> message = new MessageModel <GetShipCardReturns>();
            GetShipCardReturns Rsultmode   = new GetShipCardReturns();
            string             productCode = string.Empty;

            //if (model.productType == "正极搅拌")
            //{
            //    productCode = "ZJ";
            //}
            //if (model.productType == "负极搅拌")
            //{
            //    productCode = "FJ";
            //}
            productCode = model.device_sn.Substring(0, 3);
            var result = await _dal.GetSerialnumber(model);

            if (result != null)
            {
                int intLenght = model.device_sn.Length;
                result.sys_Date = result.sys_Date.Replace("/", "");
                result.strLSH   = string.Empty;
                if (result.s_date == result.sys_Date)
                {
                    result.s_date      = result.s_date.Replace("/", "");
                    result.strLSH      = (Int32.Parse(result.s_number) + 1).ToString().PadLeft(2, '0');
                    result.shipment_no = productCode + result.s_date + model.package + model.formula + model.device_sn.Substring(intLenght - 2, 2) + result.strLSH;
                }
                else
                {
                    result.strLSH      = "01";
                    result.shipment_no = productCode + result.sys_Date + model.package + model.formula + model.device_sn.Substring(intLenght - 2, 2) + result.strLSH;
                }
                result.productType = model.productType;
                await _dal.UpdateShipcartCode(result);

                Rsultmode        = _mapper.Map <GetShipCardReturns>(result);
                message.success  = true;
                message.msg      = "";
                message.response = Rsultmode;
            }
            else
            {
                message.success = false;
                message.msg     = "获取出货牌失败";
            }
            return(message);
        }