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);
        }