예제 #1
0
 public async Task <MessageModel <string> > Submit(CoatSubmitParam model)
 {
     return(await _coatServices.Submit(model));
 }
        /// <summary>
        /// 提交
        /// </summary>
        /// <returns></returns>
        public async Task <MessageModel <string> > Submit(CoatSubmitParam model)
        {
            model.group_name = model.group_name.ToUpper();
            MessageModel <string> message = new MessageModel <string>();
            CoatModel             cmodel  = _mapper.Map <CoatModel>(model);

            //添加机台使用状况
            if (string.IsNullOrEmpty(cmodel.shipment_no))
            {
                message.msg = "出货牌号不允许为空";
                return(message);
            }
            if (string.IsNullOrEmpty(cmodel.input_sum) || cmodel.input_sum == "0")
            {
                message.msg = "投入数量为0或为空";
                return(message);
            }
            if (string.IsNullOrEmpty(cmodel.user_name))
            {
                message.msg = "请输入操作员";
                return(message);
            }
            if (string.IsNullOrEmpty(cmodel.monitor))
            {
                message.msg = "请输入监控员!";
                return(message);
            }
            if (string.IsNullOrEmpty(cmodel.group_name))
            {
                message.msg = "请输入组别!";
                return(message);
            }
            if (cmodel.productType != "正极辊压" && cmodel.productType != "负极辊压" && cmodel.productType != "正极分条" && cmodel.productType != "负极分条" && cmodel.productType != "正极模切" && cmodel.productType != "负极模切" && cmodel.productType != "正极裁片" && cmodel.productType != "负极裁片")
            {
                if (model.itemList == null || model.itemList.Count <= 0)
                {
                    message.msg = "请输入物料信息";
                    return(message);
                }
            }
            if (cmodel.productType == "正极分条" || cmodel.productType == "负极分条")
            {
                if (string.IsNullOrEmpty(cmodel.Partition_Sum) || cmodel.Partition_Sum == "0")
                {
                    message.msg = "分条数不能为空或者为空0";
                    return(message);
                }
            }


            if (!model.checkPermission)
            {
                //组别校验
                string strGroup = await pmes.GroupNameCheckAsync(cmodel.previous_shipment_no + ":" + cmodel.shipment_no, cmodel.group_name, cmodel.technology, cmodel.productType, cmodel.user_name);

                if (strGroup.ToUpper() != "TRUE")
                {
                    message.msg = strGroup;
                    return(message);
                }
            }
            else
            {
                //记录组别
                await _dal.AddGroupName(cmodel);
            }
            var gsdata = await _dal.GetShipcart(cmodel);

            if (gsdata.Count > 0)
            {
                message.msg = "出货批号已存在";
                return(message);
            }
            if (cmodel.input_sum.ObjToInt() > cmodel.out_qty.ObjToInt())
            {
                message.msg = "投入量不能大于剩余量";
                return(message);
            }
            string strItem = string.Empty;

            if (cmodel.productType == "正极单面涂布")
            {
                strItem = "正极双面涂布";
            }
            else if (cmodel.productType == "正极双面涂布")
            {
                strItem = "正极辊压";
            }
            else if (cmodel.productType == "正极辊压")
            {
                strItem = "正极分条";
            }
            else if (cmodel.productType == "正极分条")
            {
                strItem = "正极模切";
            }
            else if (cmodel.productType == "正极模切")
            {
                strItem = "正极裁片";
            }
            else if (cmodel.productType == "正极裁片")
            {
                strItem = "结束";
            }
            else if (cmodel.productType == "负极单面涂布")
            {
                strItem = "负极双面涂布";
            }
            else if (cmodel.productType == "负极双面涂布")
            {
                strItem = "负极辊压";
            }
            else if (cmodel.productType == "负极辊压")
            {
                strItem = "负极分条";
            }
            else if (cmodel.productType == "负极分条")
            {
                strItem = "负极模切";
            }
            else if (cmodel.productType == "负极模切")
            {
                strItem = "负极裁片";
            }
            else if (cmodel.productType == "负极裁片")
            {
                strItem = "结束";
            }

            var momodel = await _dal.MeterialOverdue(cmodel);

            cmodel.type_name  = momodel.type_name;
            cmodel.package_id = momodel.package_id;
            cmodel.strItem    = strItem;


            if (cmodel.productType == "正极单面涂布" || cmodel.productType == "负极单面涂布" || cmodel.productType == "正极双面涂布" || cmodel.productType == "负极双面涂布")
            {
                if (!string.IsNullOrEmpty(cmodel.previous_shipment_no))
                {
                    cmodel.itemName  = "浆料批号";
                    cmodel.itemValue = cmodel.previous_shipment_no;
                    await _dal.AddMetrial(cmodel);
                }
            }
            if (cmodel.productType == "正极辊压" || cmodel.productType == "负极辊压" || cmodel.productType == "正极模切" || cmodel.productType == "负极模切" || cmodel.productType == "正极裁片" || cmodel.productType == "负极裁片")
            {
                if (!string.IsNullOrEmpty(cmodel.previous_shipment_no))
                {
                    cmodel.itemName  = "卷料批号";
                    cmodel.itemValue = cmodel.ItemName;
                    await _dal.AddMetrial(cmodel);
                }
                if (!string.IsNullOrEmpty(cmodel.Partition_XY))
                {
                    cmodel.itemName  = "X或Y";
                    cmodel.itemValue = cmodel.Partition_XY;
                    await _dal.AddMetrial(cmodel);
                }
            }
            else if (cmodel.productType == "正极分条" || cmodel.productType == "负极分条")
            {
                cmodel.itemName  = "分条数";
                cmodel.itemValue = cmodel.Partition_Sum;
                await _dal.AddMetrial(cmodel);

                cmodel.itemName  = "X或Y";
                cmodel.itemValue = cmodel.Partition_XY;
                await _dal.AddMetrial(cmodel);

                double Input_Sum = Convert.ToDouble(cmodel.input_sum) / Convert.ToDouble(cmodel.Partition_Sum);
                cmodel.input_sum = Math.Floor(Input_Sum).ToString();
                for (int i = 1; i <= cmodel.Partition_Sum.ObjToInt(); i++)
                {
                    if (i != 1)
                    {
                        GetShipCartCoatParam getshipCartModel = new GetShipCartCoatParam();
                        getshipCartModel = _mapper.Map <GetShipCartCoatParam>(cmodel);
                        MessageModel <GetShipCartCoatReturns> getShipCartReturn = await this.GetShipCartCoat(getshipCartModel, i);

                        cmodel.shipment_no = getShipCartReturn.response.shipment_no;
                    }
                    await _dal.AddShipcart(cmodel);

                    await _dal.UpShipcart(cmodel);
                }
                message.success = true;
                message.msg     = "添加成功";
                return(message);
            }
            else
            {
                string materstr = string.Empty;
                foreach (var item in model.itemList)
                {
                    materstr += "|" + item.item_No + ":" + item.item_Batch + ";0";
                }

                //先添加,再校验物料
                string strGT = await pmes.CellBOMItemsCheckAsync(cmodel.shipment_no, cmodel.technology, cmodel.user_name, cmodel.device_no, materstr);

                if (strGT.ToUpper() != "TRUE")
                {
                    message.msg = strGT;
                    //校验失败,删除出货牌
                    await _dal.DeteleShipcart(cmodel);

                    return(message);
                }
                foreach (var item in model.itemList)
                {
                    cmodel.itemName  = item.item_name;
                    cmodel.itemValue = item.item_No + "|" + item.item_Batch;
                    await _dal.AddMetrial(cmodel);
                }
            }
            await _dal.AddShipcart(cmodel);

            await _dal.UpShipcart(cmodel);

            message.success = true;
            message.msg     = "添加成功";
            return(message);
        }