| | |
| | | using System.Security.Policy; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | |
| | | } |
| | | public IRepository<Dt_MedicineGoods> Repository => BaseDal; |
| | | |
| | | static string SearchDate = ""; |
| | | |
| | | /// <summary> |
| | | /// è·åè¯ååºç¡ä¿¡æ¯åæ¥æ¥å£ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent GetMedicineGoodsInfom() |
| | | { |
| | | var responseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo"; |
| | | |
| | | |
| | | if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | //请æ±åæ° |
| | | var requestData = new |
| | | { |
| | | searchDate = "2009-1-10 20:45:16" // æ£ç¡®çæ ¼å¼ |
| | | }; |
| | | //if (string.IsNullOrEmpty(SearchDate)) |
| | | //{ |
| | | // // é»è®¤æ¥è¯¢è¿å»24å°æ¶çæ°æ® |
| | | // SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); |
| | | //} |
| | | //// 请æ±åæ° |
| | | //var requestData = new |
| | | //{ |
| | | // searchDate = SearchDate |
| | | //}; |
| | | //SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); |
| | | // åèµ·è¯·æ± |
| | | var result = HttpHelper.Post(url, requestData.ToJsonString()); |
| | | |
| | | // ååºåå |
| | | var response = JsonConvert.DeserializeObject<UpstreamResponse<MedicationsInfo>>(result); |
| | | |
| | | if (response.resultCode != "0") |
| | | { |
| | | // è°ç¨å¼å¸¸æ¥å£ |
| | | SendErrorToUpstream(5, "", response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败", ""); |
| | | return responseContent.Error(response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败"); |
| | | } |
| | | if (response.data == null || !response.data.Any()) |
| | | { |
| | | return responseContent.OK("æ æ°è¯åæ°æ®"); |
| | | } |
| | | |
| | | //è·åææå·²åå¨çååç¼å· |
| | | var existingGoodsNos = BaseDal.Db.Queryable<Dt_MaterielInfo>() |
| | | .Select(g => g.MaterielCode) |
| | | .ToList(); |
| | | |
| | | // æ¶éææè¦æå
¥çå®ä½ |
| | | var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MaterielInfo |
| | | { |
| | | MaterielCode = Medicat.goods_no, |
| | | MaterielErpType = Medicat.materialCode, |
| | | item = Medicat.goods_tym, //éç¨å |
| | | MaterielName = Medicat.goods_spm,//ç©æåç§° |
| | | MaterielSpec = Medicat.model, |
| | | Factory = Medicat.factory, |
| | | MaterielUnit = Medicat.unit,//åä½ |
| | | // ä½¿ç¨ ?? è¿ç®ç¬¦æä¾é»è®¤å¼ |
| | | MaterielLength = (float?)Medicat.item_length , |
| | | MaterielWide = (float?)Medicat.item_width, |
| | | MaterielHeight = (float?)Medicat.item_hight, |
| | | MaterielVolume = (float?)Medicat.item_volumn, |
| | | MaterielWeight = (float?)Medicat.item_weight, |
| | | MaterielStoragecondition = float.TryParse(Medicat.storage_confition, out var val) ? val : null, //å¨åæ¡ä»¶ |
| | | Remark = Medicat.remark, |
| | | GoodStatusState = "æªä¸å", |
| | | ModifyDate = Medicat.modify_date |
| | | }).ToList(); |
| | | // 䏿¬¡æ§æ¹éæå
¥æ°æ®åº |
| | | BaseDal.Db.Insertable(entityList).ExecuteCommand(); |
| | | |
| | | ProductSynchronous(); |
| | | return responseContent.OK("忥æå"); |
| | | } |
| | | |
| | | catch (Exception ex) |
| | | { |
| | | SendErrorToUpstream(5, "", ex.Message, ""); |
| | | return responseContent.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// åç»ä¸æ¸¸wcs忥è¯åä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent ProductSynchronous() |
| | | { |
| | | try |
| | | { |
| | | //å
æ¾å°æææªä¸åçè¯å |
| | | //var list = BaseDal.QueryData(x => x.GoodStatus == "æªä¸å").ToList(); |
| | | var list =BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "æªä¸å").ToList(); |
| | | if (list == null || !list.Any()) |
| | | { |
| | | return new WebResponseContent().OK("æ æªä¸åè¯å"); |
| | | } |
| | | //æ¾å°äºå°±å°æ´ä¸ªliståç»ä¸æ¸¸ç³»ç» |
| | | foreach (var item in list) |
| | | { |
| | | var medicineDTO = new ProductInfo |
| | | { |
| | | //ç¨æ·code |
| | | customerCode = "905", |
| | | //ç©æç±»å |
| | | materialCode =item.MaterielErpType, |
| | | //产åç¼ç |
| | | productCode= item.MaterielCode, |
| | | //产åå |
| | | productName =item.MaterielName, |
| | | //äº§åæ¡ç |
| | | productBarCode= item.MaterielCode, |
| | | |
| | | //è§æ ¼ |
| | | productSpecifications=item.MaterielSpec, |
| | | //åä½ |
| | | unit = item.MaterielUnit, |
| | | //é¿ |
| | | singleProductLongNum = item.MaterielLength.ToString(), |
| | | //宽 |
| | | singleProductWideNum = item.MaterielWide.ToString(), |
| | | //é« |
| | | singleProductHighNum = item.MaterielHeight.ToString(), |
| | | //éé |
| | | singleProductWeight = item.MaterielWeight.ToString(), |
| | | //ä½ç§¯ |
| | | singleProductVolume = item.MaterielVolume.ToString(), |
| | | //æ¯å¦åæ¶ 0æ¯ä¸å é¤ï¼1å é¤ |
| | | isDelete = "0" |
| | | }; |
| | | var url = "http://172.16.1.2:9357/file-admin/api/product/productSynchronous"; |
| | | var result = HttpHelper.Post(url, medicineDTO.ToJsonString()); |
| | | var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result); |
| | | |
| | | if (resp!=null&&resp.code=="0") |
| | | { |
| | | //æ´æ°è¯åç¶æ-已宿 |
| | | BaseDal.Db.Updateable<Dt_MaterielInfo>() |
| | | .SetColumns(x => x.GoodStatusState == "ä¸å宿") |
| | | .Where(x => x.GoodStatusState == item.MaterielCode) |
| | | .ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | SendErrorToUpstream(5, medicineDTO.materialCode, resp?.msg ?? "WCSè¯åä¿¡æ¯åæ¥å¤±è´¥", ""); |
| | | |
| | | return new WebResponseContent { Status = false, Message = "è®¢åæ¨é失败" }; |
| | | } |
| | | |
| | | } |
| | | return new WebResponseContent { Status = true, Message = "æå" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine("ProductSynchronous å¼å¸¸ï¼" + ex.Message); |
| | | return new WebResponseContent { Status = false, Message = ex.Message }; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 忥å é¤å é¤ååä¿¡æ¯ |
| | |
| | | { |
| | | try |
| | | { |
| | | var goods = BaseDal.Db.Queryable< Dt_MaterielInfo >().Where(x => x.MaterielCode == goodsno).First(); |
| | | var goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno).First(); |
| | | if (goods == null) |
| | | { |
| | | return new WebResponseContent |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return new WebResponseContent { Status=false,Message = ex.Message }; |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | Console.WriteLine("å¼å¸¸æ¥å£æ¨é失败ï¼" + e.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |