/// <summary>
        /// 提交信息
        /// </summary>
        /// <param name="model">{itemValue1,shipCard,stepName,device_no,next_step,USERNAME,MONITOR,ITEM_WEIGHT,itemList[{item_No,item_Batch,item_name}]}</param>
        /// <returns></returns>
        public async Task <MessageModel <AgitationDetailModel> > Submit(AgitationDetailParam model)
        {
            // Convert.ToInt64(model.device_no);
            _loggerHelper.Info("搅拌工步提交参数", JsonConvert.SerializeObject(model));
            MessageModel <AgitationDetailModel> message = new MessageModel <AgitationDetailModel>();

            //1.不是第一个工步则判断他上个工序有没有做
            if (model.STEP_NUMBER > 1)
            {
                AgitationStrstepNameSelecteParam asns = new AgitationStrstepNameSelecteParam()
                {
                    shipCard = model.shipCard,
                    stepName = model.last_step,
                };
                var stepsns = await this.StrstepNameSelecte(asns);

                if (!stepsns.success)
                {
                    message.msg = "请完善前面的工序,不允许跨步骤";
                    return(message);
                }
            }
            //拼接物料号
            var stepcount = await _dal.GetStepNumber(model);

            AgitationDetailModel admModel = new AgitationDetailModel();

            admModel = _mapper.Map <AgitationDetailModel>(model);
            if (stepcount == null)
            {
                message.msg      = "添加失败";
                message.response = admModel;
                return(message);
            }

            //2.校验信息
            model.guleStepModel.STEP_NAME = model.stepName;
            var stepData = await _dal.GetStepListAllByStepName(model.guleStepModel);

            if (stepData == null)
            {
                message.success = false;
                message.msg     = "您还没有维护此工步,请联系相关人员维护";
                return(message);
            }
            if (string.IsNullOrEmpty(admModel.publicSpeed))
            {
                admModel.publicSpeed = null;
            }
            if (string.IsNullOrEmpty(admModel.selfVelocity))
            {
                admModel.selfVelocity = null;
            }
            if (string.IsNullOrEmpty(admModel.vacuum))
            {
                admModel.vacuum = null;
            }
            if (string.IsNullOrEmpty(admModel.temperature))
            {
                admModel.temperature = null;
            }
            if (!string.IsNullOrEmpty(stepData.ITEM_CODE))
            {
                if (model.itemList.Count <= 0)
                {
                    message.msg = "此工步需要校验物料信息,请检查";
                    return(message);
                }
            }
            //公转-搅拌速度
            if (!(admModel.publicSpeed.ObjToFloat() <= stepData.MIXING_SPEED_UPPER && admModel.publicSpeed.ObjToFloat() >= stepData.MIXING_SPEED_LOWER))
            {
                message.msg = "公转速度上下限:" + stepData.MIXING_SPEED_LOWER + "~" + stepData.MIXING_SPEED_UPPER;
                return(message);
            }
            //自转-分离速度
            if (!(admModel.selfVelocity.ObjToFloat() <= stepData.SEPARATE_UPPER && admModel.selfVelocity.ObjToFloat() >= stepData.SEPARATE_LOWER))
            {
                message.msg = "自转速度上下限:" + stepData.SEPARATE_LOWER + "~" + stepData.SEPARATE_UPPER;
                return(message);
            }
            //真空度
            if (!(admModel.vacuum.ObjToFloat() <= stepData.VACUUM_UPPER))
            {
                if (stepData.VACUUM_LOWER != null && admModel.vacuum.ObjToFloat() >= stepData.VACUUM_LOWER.ObjToFloat())
                {
                    message.msg = "真空度上下限:" + stepData.VACUUM_LOWER.ObjToFloat() + "~" + stepData.VACUUM_UPPER;
                    return(message);
                }
                message.msg = "真空度上限:" + stepData.VACUUM_UPPER;
                return(message);
            }

            //温度
            if (!(admModel.temperature.ObjToFloat() <= stepData.TEMPER_UPPER && admModel.temperature.ObjToFloat() >= stepData.TEMPER_LOWER))
            {
                message.msg = "温度上下限:" + stepData.TEMPER_LOWER + "~" + stepData.TEMPER_UPPER;
                return(message);
            }

            //3.工步是否已经录入,录入做修改,不录入新增
            var stepEntil = await this.StrstepNameSelecte(model.stepModel);

            int intStep = 0;

            if (stepEntil.success)
            {
                //删除原来,新增
                await _dal.DeleteStepInfo(model, model.stepModel);

                intStep = model.STEP_NUMBER + 1;
            }
            else
            {
                intStep = stepcount.step_num + 1;
            }
            //4.提交信息


            bool   bl        = false;
            string itemName  = string.Empty;
            string itemValue = string.Empty;

            if (model.itemList.Count > 0)
            {
                foreach (var item in model.itemList)
                {
                    admModel.item_value  = item.item_No.Trim() + "|" + item.item_Batch.Trim() + "|" + item.item_Number.Trim();
                    admModel.item_name   = item.item_name.Trim();
                    admModel.item_number = item.putNumber;
                    //item.item_value = item.item_No + item.item_Batch;
                    await _dal.AddTestValue(intStep, admModel);
                }
                bl = true;
            }
            //else
            //{
            //    message.success = false;
            //    message.msg = "物料信息不能为空";
            //    message.response = admModel;
            //    return message;
            //}
            if (!string.IsNullOrEmpty(admModel.publicSpeed))
            {
                admModel.item_name   = "公转转速";
                admModel.item_value  = admModel.publicSpeed;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.selfVelocity))
            {
                admModel.item_name   = "自转转速";
                admModel.item_value  = admModel.selfVelocity;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.stirTime))
            {
                admModel.item_name   = "搅拌时间";
                admModel.item_value  = admModel.stirTime;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.temperature))
            {
                admModel.item_name   = "温度";
                admModel.item_value  = admModel.temperature;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.vacuum))
            {
                admModel.item_name   = "真空度";
                admModel.item_value  = admModel.vacuum;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.viscosity))
            {
                admModel.item_name   = "粘度";
                admModel.item_value  = admModel.viscosity;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.fineness))
            {
                admModel.item_name   = "细度";
                admModel.item_value  = admModel.fineness;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.filter))
            {
                admModel.item_name   = "过筛况";
                admModel.item_value  = admModel.filter;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (!string.IsNullOrEmpty(admModel.chutie))
            {
                admModel.item_name   = "除铁要求";
                admModel.item_value  = admModel.chutie;
                admModel.item_weight = "";
                await _dal.AddTestValue(intStep, admModel);

                bl = true;
            }
            if (bl)
            {
                await _dal.UpdateShipCartInfo(admModel);

                message.success  = true;
                message.msg      = "添加成功";
                message.response = admModel;
            }
            return(message);
        }
示例#2
0
        /// <summary>
        ///删除工步信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> DeleteStepInfo(AgitationDetailParam model, AgitationStrstepNameSelecteParam stepModel)
        {
            string strStep = string.Format(@"delete  t_mes_stir_info t where t.SHIPMENT_NO='{0}' and t.STEP_NAME='{1}'", model.shipCard, stepModel.stepName);

            return(await base.ExecuteCommand(strStep) > 0);
        }
 public async Task <MessageModel <AgitationDetailModel> > DetailSubmit(AgitationDetailParam jsondata)
 {
     return(await _agitationServices.Submit(jsondata));
 }
示例#4
0
        public async Task <AgitationDetailModel> GetStepNumber(AgitationDetailParam model)
        {
            string strStep = string.Format(@"select b.step_num from T_MES_MACHINE_USEINFO b where b.shipment_no='{0}'and b.device_no='{1}'", model.shipCard, model.device_no);

            return(await base.SqlQuerySingleAsync <AgitationDetailModel>(strStep, new { }));
        }