Ejemplo n.º 1
0
        //返回值 -1 没有需要同步的数据 0 同步成功   1同步失败
        public bool sendIQCInspection(List <QM_IQC_TOP> topList)
        {
            bool flag = true;

            strCom.Clear();
            using (TransactionScope ts = new TransactionScope())
            {
                for (int i = 0; i < topList.Count; i++)
                {
                    if (i != 0)
                    {
                        strCom.Append(",");
                    }
                    strCom.AppendFormat("'{0}'", topList[i].OrderID);
                    //更改检验批的状态
                    topList[i].OrderStatus = "已提交";
                    iqc_top_bo.UpdateSome(topList[i]);
                }
                log.Info(strCom.ToString());
                IList <CV_QM_IQC_INSPECTION_RESULT> iqcInsResults = cv_iqc_resultbo.getGetEntities(strCom.ToString());
                if (iqcInsResults != null)
                {
                    //将数据插入中间表
                    List <QM_TEMP_IQC_INSPECTION_DETIAL> detialList = new List <QM_TEMP_IQC_INSPECTION_DETIAL>();
                    List <String> orderList  = new List <string>();
                    List <String> itemIdList = new List <String>();
                    foreach (CV_QM_IQC_INSPECTION_RESULT result in iqcInsResults)
                    {
                        QM_TEMP_IQC_INSPECTION_DETIAL detial = new QM_TEMP_IQC_INSPECTION_DETIAL();
                        detial.PRUEFOS = result.OrderID;      //检验批
                        string orderRes = result.OrderResult; //检验批结果
                        //先判断检验批的结果
                        if (orderRes.Equals("OK"))
                        {
                            if (orderList.Contains(detial.PRUEFOS))
                            {
                                continue;
                            }
                            //对于检验批合格的,只需传递一条数据
                            detial.VCODE = "A";//检验批结果

                            itemIdList.Clear();
                            orderList.Add(detial.PRUEFOS);
                        }
                        else
                        {
                            if (!orderList.Contains(detial.PRUEFOS))
                            {
                                itemIdList.Clear();
                                orderList.Add(detial.PRUEFOS);
                            }
                            detial.VCODE  = "R";           //检验批结果
                            detial.MERKNR = result.ItemID; //检验特性行号

                            //判断检验特性的检验项目属性
                            if (result.ItemProperty.Equals(dingxing))
                            {
                                //定性只需要传1行
                                if (itemIdList.Contains(detial.MERKNR))
                                {
                                    continue;
                                }

                                itemIdList.Add(detial.MERKNR);
                                //判断检验特性的检验结果
                                detial.ATTRIBUTE = 1;//检验项目属性
                                if (result.ItemResult.Equals("OK"))
                                {
                                    detial.M_RESULT = "0";//检验特性行结果
                                }
                                else
                                {
                                    detial.M_RESULT     = "1";                            //检验特性行结果
                                    detial.QUALI_COUNT  = result.SampleSize;              //检验数量
                                    detial.QUALI_RESULT = Convert.ToInt32(result.BadQua); //不合格数量
                                }
                            }
                            else
                            {
                                //定量传明细
                                detial.ATTRIBUTE = 2;                                          //检验项目属性
                                detial.M_RESULT  = result.ItemResult.Equals("OK") ? "0" : "1"; //检验特性行结果
                                detial.EINFELD   = Convert.ToDecimal(result.Value);            //检验特性明细结果(标准值)
                            }
                            detial.PRUEFER = result.InspectUser;                               //检验特性人员
                            DateTime itemDate = result.ItemDate.Value;
                            detial.PRUEFDATUV = itemDate.Date.ToString("yyyy-MM-dd");          //检验特性开始日期
                            detial.PRUEFZEITV = itemDate.TimeOfDay.ToString();                 //检验特性开始时间
                            detial.PRUEFDATUB = detial.PRUEFDATUV;
                            detial.PRUEFZEITP = detial.PRUEFZEITV;
                        }
                        if (!string.IsNullOrEmpty(result.InspectUser))
                        {
                            detial.VNAME = result.InspectUser;//检验人员
                        }
                        //if (dt.Rows[i]["InspectTime"] == DBNull.Value)
                        DateTime inspectTime = result.InspectTime.Value;
                        //检验批提交日期
                        //ToLongDateString 2017年11月22日
                        detial.VDATUM = inspectTime.Date.ToString("yyyy-MM-dd"); //2017/11/22
                        //检验批提交时间
                        detial.VEZEITERF = inspectTime.TimeOfDay.ToString();     //09:18:50
                        if (result.ScrapQua.HasValue)
                        {
                            detial.LMENGEZER = result.ScrapQua; //报废数
                        }
                        detialList.Add(detial);
                        //操作中间表
                        // temp_iqc_inspection_detial_bo.Insert(detial);
                    }
                    //传SAP
                    CustomJsonConverter customConverter = new CustomJsonConverter()
                    {
                        PropertyNullValueReplaceValue = ""
                    };
                    Web.SAP.IQCInspection.ZMM_IF0005_WSDL_TQSService sapservice = new Web.SAP.IQCInspection.ZMM_IF0005_WSDL_TQSService();
                    ZMM_IF0005_T zmm            = new ZMM_IF0005_T();
                    string       sendSapRequest = JsonConvert.SerializeObject(detialList, customConverter);
                    log.Info("send sap json\r\n" + sendSapRequest);
                    zmm.I_JSON = sendSapRequest;
                    ZMM_IF0005_TResponse respone = sapservice.ZMM_IF0005_T(zmm);
                    string sapResponse           = respone.O_JSON;
                    log.Info("sap return json\r\n" + sapResponse);
                    ReturnValueSAP sapJson = JsonConvert.DeserializeObject <ReturnValueSAP>(sapResponse);
                    if (sapJson.Success == 2)
                    {
                        flag = false;
                    }
                }
                if (flag)
                {
                    ts.Complete();
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public string sendMaintainOrderResultToSap(EQMMaintainSendSap param)
        {
            log.Info("sendMaintainOrderResultToSap satrt");
            string errorMes = "";
            EQM_EQUIP_SPARE_LIST spareParam = new EQM_EQUIP_SPARE_LIST()
            {
                mesMaintainID = param.mesMaintainID
            };

            IList <IF0004WSDL> spareDatas = new List <IF0004WSDL>();
            //获得备品备件
            IList <EQM_EQUIP_SPARE_LIST> spareLists = getMaintainOrderSpares(spareParam);

            if (spareLists == null || spareLists.Count == 0)
            {
                //只需要传1条数据   备品备件为空时,不需要传设备编码
                IF0004WSDL s = new IF0004WSDL()
                {
                    mesMaintainID = param.mesMaintainID,
                    DeviceID      = "",
                    VORNR         = "0010",
                    spentMater    = "",
                    direction     = "",
                    num           = "",
                    StartTime     = param.startTime.Substring(0, 10),
                    EndTime       = param.endTime.Substring(0, 10)
                };
                spareDatas.Add(s);
            }
            else
            {
                foreach (EQM_EQUIP_SPARE_LIST spare in spareLists)
                {
                    IF0004WSDL s = new IF0004WSDL()
                    {
                        mesMaintainID = param.mesMaintainID,
                        DeviceID      = param.deviceID,
                        VORNR         = "0010",
                        spentMater    = spare.spentMater,
                        direction     = spare.direction,
                        num           = spare.num,
                        StartTime     = param.startTime.Substring(0, 10),
                        EndTime       = param.endTime.Substring(0, 10)
                    };
                    spareDatas.Add(s);
                }
            }
            //传SAP
            CustomJsonConverter customConverter = new CustomJsonConverter()
            {
                PropertyNullValueReplaceValue = ""
            };
            string sendSapRequest = JsonConvert.SerializeObject(spareDatas, customConverter);

            log.Info("send sap json\r\n" + sendSapRequest);
            ZPM_IF0004_WSDL_TQSService service = new ZPM_IF0004_WSDL_TQSService();
            ZPM_IF0004_TResponse       respone = service.ZPM_IF0004_T(new ZPM_IF0004_T()
            {
                I_JSON = sendSapRequest
            });
            string sapResponse = respone.O_JSON;

            log.Info("sap return json\r\n" + sapResponse);
            //SAPJSONResponse sapJson = JsonConvert.DeserializeObject<SAPJSONResponse>(sapResponse);
            //if (sapJson.resultcode.Equals("2"))
            //{
            //    errorMes = sapJson.resultmsg;
            //}
            ReturnValueSAP sapJson = JsonConvert.DeserializeObject <ReturnValueSAP>(sapResponse);

            if (sapJson.Success == 2)
            {
                errorMes = sapJson.Message;
            }
            else
            {
                //更新保养单的状态及保养人
                EQM_EQUIP_MAINTAIN updateParam = new EQM_EQUIP_MAINTAIN()
                {
                    KID            = param.kid,
                    Maintainer     = param.maintainer,
                    Maintain_state = "已完成"
                };
                maintainBO.UpdateSome(updateParam);
            }
            log.Info("sendMaintainOrderResultToSap end");
            return(errorMes);
        }